Initial commit to Gerrit 1.0 1.0_branch tizen/20120530.1
authorYang Lin <lin.a.yang@intel.com>
Wed, 30 May 2012 10:26:19 +0000 (18:26 +0800)
committerYang Lin <lin.a.yang@intel.com>
Wed, 30 May 2012 10:26:19 +0000 (18:26 +0800)
941 files changed:
COPYRIGHT [new file with mode: 0644]
ChangeLog [new file with mode: 0644]
CommitLog [new file with mode: 0644]
CommitLog-4.1.0 [new file with mode: 0644]
ElectricFence/CHANGES [new file with mode: 0644]
ElectricFence/COPYING [new file with mode: 0644]
ElectricFence/Makefile.am [new file with mode: 0644]
ElectricFence/Makefile.in [new file with mode: 0644]
ElectricFence/README [new file with mode: 0644]
ElectricFence/efence.c [new file with mode: 0644]
ElectricFence/efence.h [new file with mode: 0644]
ElectricFence/eftest.c [new file with mode: 0644]
ElectricFence/libefence.3 [new file with mode: 0644]
ElectricFence/page.c [new file with mode: 0644]
ElectricFence/print.c [new file with mode: 0644]
ElectricFence/tstheap.c [new file with mode: 0644]
INSTALL [new file with mode: 0644]
Makefile.am [new file with mode: 0644]
Makefile.in [new file with mode: 0644]
NEWS [new file with mode: 0644]
NOTES.y2kfixes [new file with mode: 0644]
README [new file with mode: 0644]
README.bk [new file with mode: 0644]
README.hackers [new file with mode: 0644]
README.patches [new file with mode: 0644]
README.refclocks [new file with mode: 0644]
README.versions [new file with mode: 0644]
TODO [new file with mode: 0644]
WHERE-TO-START [new file with mode: 0644]
aclocal.m4 [new file with mode: 0644]
adjtimed/Makefile.am [new file with mode: 0644]
adjtimed/Makefile.in [new file with mode: 0644]
adjtimed/README [new file with mode: 0644]
adjtimed/adjtimed.c [new file with mode: 0644]
arlib/COPYING [new file with mode: 0644]
arlib/INSTALL [new file with mode: 0644]
arlib/Makefile.am [new file with mode: 0644]
arlib/Makefile.in [new file with mode: 0644]
arlib/README [new file with mode: 0644]
arlib/UNSHAR.HDR [new file with mode: 0644]
arlib/aclocal.m4 [new file with mode: 0644]
arlib/arlib.3 [new file with mode: 0644]
arlib/arlib.c [new file with mode: 0644]
arlib/arlib.h [new file with mode: 0644]
arlib/arplib.h [new file with mode: 0644]
arlib/configure [new file with mode: 0755]
arlib/configure.in [new file with mode: 0644]
arlib/depcomp [new file with mode: 0755]
arlib/install-sh [new file with mode: 0755]
arlib/missing [new file with mode: 0755]
arlib/sample.c [new file with mode: 0644]
bincheck.mf [new file with mode: 0644]
bootstrap [new file with mode: 0755]
build [new file with mode: 0755]
clockstuff/Makefile.am [new file with mode: 0644]
clockstuff/Makefile.in [new file with mode: 0644]
clockstuff/README [new file with mode: 0644]
clockstuff/chutest.c [new file with mode: 0644]
clockstuff/clktest.c [new file with mode: 0644]
clockstuff/propdelay.c [new file with mode: 0644]
compile [new file with mode: 0755]
conf/README [new file with mode: 0644]
conf/baldwin.conf [new file with mode: 0644]
conf/beauregard.conf [new file with mode: 0644]
conf/grundoon.conf [new file with mode: 0644]
conf/malarky.conf [new file with mode: 0644]
conf/pogo.conf [new file with mode: 0644]
conf/rackety.conf [new file with mode: 0644]
config.guess [new file with mode: 0755]
config.h.in [new file with mode: 0644]
config.sub [new file with mode: 0755]
configure [new file with mode: 0755]
configure.ac [new file with mode: 0644]
depcomp [new file with mode: 0755]
dot.emacs [new file with mode: 0644]
excludes [new file with mode: 0644]
flock-build [new file with mode: 0755]
html/accopt.html [new file with mode: 0644]
html/assoc.html [new file with mode: 0644]
html/audio.html [new file with mode: 0644]
html/authopt.html [new file with mode: 0644]
html/build/build.html [new file with mode: 0644]
html/build/config.html [new file with mode: 0644]
html/build/hints.html [new file with mode: 0644]
html/build/hints/a-ux [new file with mode: 0644]
html/build/hints/aix [new file with mode: 0644]
html/build/hints/bsdi [new file with mode: 0644]
html/build/hints/changes [new file with mode: 0644]
html/build/hints/decosf1 [new file with mode: 0644]
html/build/hints/decosf2 [new file with mode: 0644]
html/build/hints/freebsd [new file with mode: 0644]
html/build/hints/hpux [new file with mode: 0644]
html/build/hints/linux [new file with mode: 0644]
html/build/hints/mpeix [new file with mode: 0644]
html/build/hints/netbsd [new file with mode: 0644]
html/build/hints/notes-xntp-v3 [new file with mode: 0644]
html/build/hints/parse [new file with mode: 0644]
html/build/hints/refclocks [new file with mode: 0644]
html/build/hints/rs6000 [new file with mode: 0644]
html/build/hints/sco.html [new file with mode: 0644]
html/build/hints/sgi [new file with mode: 0644]
html/build/hints/solaris-dosynctodr.html [new file with mode: 0644]
html/build/hints/solaris.html [new file with mode: 0644]
html/build/hints/solaris.xtra.4023118 [new file with mode: 0644]
html/build/hints/solaris.xtra.4095849 [new file with mode: 0644]
html/build/hints/solaris.xtra.S99ntpd [new file with mode: 0644]
html/build/hints/solaris.xtra.patchfreq [new file with mode: 0644]
html/build/hints/sun4 [new file with mode: 0644]
html/build/hints/svr4-dell [new file with mode: 0644]
html/build/hints/svr4_package [new file with mode: 0644]
html/build/hints/todo [new file with mode: 0644]
html/build/hints/vxworks.html [new file with mode: 0644]
html/build/hints/winnt.html [new file with mode: 0644]
html/build/patches.html [new file with mode: 0644]
html/build/porting.html [new file with mode: 0644]
html/build/quick.html [new file with mode: 0644]
html/build/scripts/footer.txt [new file with mode: 0644]
html/build/scripts/links10.txt [new file with mode: 0644]
html/build/scripts/links11.txt [new file with mode: 0644]
html/build/scripts/links12.txt [new file with mode: 0644]
html/build/scripts/links7.txt [new file with mode: 0644]
html/build/scripts/links8.txt [new file with mode: 0644]
html/build/scripts/links9.txt [new file with mode: 0644]
html/build/scripts/style.css [new file with mode: 0644]
html/clockopt.html [new file with mode: 0644]
html/confopt.html [new file with mode: 0644]
html/copyright.html [new file with mode: 0644]
html/debug.html [new file with mode: 0644]
html/drivers/driver1.html [new file with mode: 0644]
html/drivers/driver10.html [new file with mode: 0644]
html/drivers/driver11.html [new file with mode: 0644]
html/drivers/driver12.html [new file with mode: 0644]
html/drivers/driver16.html [new file with mode: 0644]
html/drivers/driver18.html [new file with mode: 0644]
html/drivers/driver19.html [new file with mode: 0644]
html/drivers/driver2.html [new file with mode: 0644]
html/drivers/driver20.html [new file with mode: 0644]
html/drivers/driver22.html [new file with mode: 0644]
html/drivers/driver26.html [new file with mode: 0644]
html/drivers/driver27.html [new file with mode: 0644]
html/drivers/driver28.html [new file with mode: 0644]
html/drivers/driver29.html [new file with mode: 0644]
html/drivers/driver3.html [new file with mode: 0644]
html/drivers/driver30.html [new file with mode: 0644]
html/drivers/driver31.html [new file with mode: 0644]
html/drivers/driver32.html [new file with mode: 0644]
html/drivers/driver33.html [new file with mode: 0644]
html/drivers/driver34.html [new file with mode: 0644]
html/drivers/driver35.html [new file with mode: 0644]
html/drivers/driver36.html [new file with mode: 0644]
html/drivers/driver37.html [new file with mode: 0644]
html/drivers/driver38.html [new file with mode: 0644]
html/drivers/driver39.html [new file with mode: 0644]
html/drivers/driver4.html [new file with mode: 0644]
html/drivers/driver40.html [new file with mode: 0644]
html/drivers/driver42.html [new file with mode: 0644]
html/drivers/driver43.html [new file with mode: 0644]
html/drivers/driver44.html [new file with mode: 0644]
html/drivers/driver5.html [new file with mode: 0644]
html/drivers/driver6.html [new file with mode: 0644]
html/drivers/driver7.html [new file with mode: 0644]
html/drivers/driver8.html [new file with mode: 0644]
html/drivers/driver9.html [new file with mode: 0644]
html/drivers/icons/home.gif [new file with mode: 0644]
html/drivers/icons/mail2.gif [new file with mode: 0644]
html/drivers/oncore-shmem.html [new file with mode: 0644]
html/drivers/scripts/footer.txt [new file with mode: 0644]
html/drivers/scripts/style.css [new file with mode: 0644]
html/drivers/tf582_4.html [new file with mode: 0644]
html/extern.html [new file with mode: 0644]
html/gadget.html [new file with mode: 0644]
html/groups.html [new file with mode: 0644]
html/howto.html [new file with mode: 0644]
html/icons/home.gif [new file with mode: 0644]
html/icons/mail2.gif [new file with mode: 0644]
html/index.html [new file with mode: 0644]
html/kern.html [new file with mode: 0644]
html/keygen.html [new file with mode: 0644]
html/ldisc.html [new file with mode: 0644]
html/manyopt.html [new file with mode: 0644]
html/measure.html [new file with mode: 0644]
html/miscopt.html [new file with mode: 0644]
html/monopt.html [new file with mode: 0644]
html/msyslog.html [new file with mode: 0644]
html/mx4200data.html [new file with mode: 0644]
html/notes.html [new file with mode: 0644]
html/ntp_conf.html [new file with mode: 0644]
html/ntpd.html [new file with mode: 0644]
html/ntpdate.html [new file with mode: 0644]
html/ntpdc.html [new file with mode: 0644]
html/ntpdsim.html [new file with mode: 0644]
html/ntpdsim_new.html [new file with mode: 0644]
html/ntpq.html [new file with mode: 0644]
html/ntptime.html [new file with mode: 0644]
html/ntptrace.html [new file with mode: 0644]
html/parsedata.html [new file with mode: 0644]
html/parsenew.html [new file with mode: 0644]
html/pic/9400n.jpg [new file with mode: 0644]
html/pic/alice11.gif [new file with mode: 0644]
html/pic/alice13.gif [new file with mode: 0644]
html/pic/alice23.gif [new file with mode: 0644]
html/pic/alice31.gif [new file with mode: 0644]
html/pic/alice32.gif [new file with mode: 0644]
html/pic/alice35.gif [new file with mode: 0644]
html/pic/alice38.gif [new file with mode: 0644]
html/pic/alice44.gif [new file with mode: 0644]
html/pic/alice47.gif [new file with mode: 0644]
html/pic/alice51.gif [new file with mode: 0644]
html/pic/alice61.gif [new file with mode: 0644]
html/pic/barnstable.gif [new file with mode: 0644]
html/pic/beaver.gif [new file with mode: 0644]
html/pic/boom3.gif [new file with mode: 0644]
html/pic/boom3a.gif [new file with mode: 0644]
html/pic/bustardfly.gif [new file with mode: 0644]
html/pic/c51.jpg [new file with mode: 0644]
html/pic/dogsnake.gif [new file with mode: 0644]
html/pic/driver29.gif [new file with mode: 0644]
html/pic/driver43_1.gif [new file with mode: 0644]
html/pic/driver43_2.jpg [new file with mode: 0644]
html/pic/fg6021.gif [new file with mode: 0644]
html/pic/fg6039.jpg [new file with mode: 0644]
html/pic/gadget.jpg [new file with mode: 0644]
html/pic/gps167.jpg [new file with mode: 0644]
html/pic/hornraba.gif [new file with mode: 0644]
html/pic/igclock.gif [new file with mode: 0644]
html/pic/neoclock4x.gif [new file with mode: 0755]
html/pic/oncore_evalbig.gif [new file with mode: 0644]
html/pic/oncore_remoteant.jpg [new file with mode: 0644]
html/pic/oncore_utplusbig.gif [new file with mode: 0644]
html/pic/oz2.gif [new file with mode: 0644]
html/pic/panda.gif [new file with mode: 0644]
html/pic/pd_om006.gif [new file with mode: 0644]
html/pic/pd_om011.gif [new file with mode: 0644]
html/pic/pogo.gif [new file with mode: 0644]
html/pic/pogo1a.gif [new file with mode: 0644]
html/pic/pogo3a.gif [new file with mode: 0644]
html/pic/pogo4.gif [new file with mode: 0644]
html/pic/pogo5.gif [new file with mode: 0644]
html/pic/pogo6.gif [new file with mode: 0644]
html/pic/pogo8.gif [new file with mode: 0644]
html/pic/pzf511.jpg [new file with mode: 0644]
html/pic/rabbit.gif [new file with mode: 0644]
html/pic/radio2.jpg [new file with mode: 0644]
html/pic/sheepb.jpg [new file with mode: 0644]
html/pic/stack1a.jpg [new file with mode: 0644]
html/pic/tonea.gif [new file with mode: 0644]
html/pic/wingdorothy.gif [new file with mode: 0644]
html/pps.html [new file with mode: 0644]
html/prefer.html [new file with mode: 0644]
html/rdebug.html [new file with mode: 0644]
html/refclock.html [new file with mode: 0644]
html/release.html [new file with mode: 0644]
html/scripts/footer.txt [new file with mode: 0644]
html/scripts/links10.txt [new file with mode: 0644]
html/scripts/links11.txt [new file with mode: 0644]
html/scripts/links12.txt [new file with mode: 0644]
html/scripts/links7.txt [new file with mode: 0644]
html/scripts/links8.txt [new file with mode: 0644]
html/scripts/links9.txt [new file with mode: 0644]
html/scripts/style.css [new file with mode: 0644]
html/sntp.html [new file with mode: 0644]
html/tickadj.html [new file with mode: 0644]
include/Makefile.am [new file with mode: 0644]
include/Makefile.in [new file with mode: 0644]
include/README [new file with mode: 0644]
include/adjtime.h [new file with mode: 0644]
include/ascii.h [new file with mode: 0644]
include/audio.h [new file with mode: 0644]
include/autogen-version.def [new file with mode: 0644]
include/binio.h [new file with mode: 0644]
include/copyright.def [new file with mode: 0644]
include/debug-opt.def [new file with mode: 0644]
include/global.h [new file with mode: 0644]
include/gps.h [new file with mode: 0644]
include/homerc.def [new file with mode: 0644]
include/hopf6039.h [new file with mode: 0644]
include/icom.h [new file with mode: 0644]
include/ieee754io.h [new file with mode: 0644]
include/iosignal.h [new file with mode: 0644]
include/isc/Makefile.am [new file with mode: 0644]
include/isc/Makefile.in [new file with mode: 0644]
include/isc/app.h [new file with mode: 0644]
include/isc/assertions.h [new file with mode: 0644]
include/isc/boolean.h [new file with mode: 0644]
include/isc/buffer.h [new file with mode: 0644]
include/isc/error.h [new file with mode: 0644]
include/isc/formatcheck.h [new file with mode: 0644]
include/isc/int.h [new file with mode: 0644]
include/isc/interfaceiter.h [new file with mode: 0644]
include/isc/ipv6.h [new file with mode: 0644]
include/isc/lang.h [new file with mode: 0644]
include/isc/lib.h [new file with mode: 0644]
include/isc/list.h [new file with mode: 0644]
include/isc/magic.h [new file with mode: 0644]
include/isc/mem.h [new file with mode: 0644]
include/isc/msgcat.h [new file with mode: 0644]
include/isc/msgs.h [new file with mode: 0644]
include/isc/mutex.h [new file with mode: 0644]
include/isc/net.h [new file with mode: 0644]
include/isc/netaddr.h [new file with mode: 0644]
include/isc/netscope.h [new file with mode: 0644]
include/isc/offset.h [new file with mode: 0644]
include/isc/once.h [new file with mode: 0644]
include/isc/platform.h [new file with mode: 0644]
include/isc/print.h [new file with mode: 0644]
include/isc/region.h [new file with mode: 0644]
include/isc/result.h [new file with mode: 0644]
include/isc/sockaddr.h [new file with mode: 0644]
include/isc/strerror.h [new file with mode: 0644]
include/isc/string.h [new file with mode: 0644]
include/isc/types.h [new file with mode: 0644]
include/isc/util.h [new file with mode: 0644]
include/l_stdlib.h [new file with mode: 0644]
include/mbg_gps166.h [new file with mode: 0644]
include/mx4200.h [new file with mode: 0644]
include/ntif.h [new file with mode: 0644]
include/ntp.h [new file with mode: 0644]
include/ntp_calendar.h [new file with mode: 0644]
include/ntp_cmdargs.h [new file with mode: 0644]
include/ntp_config.h [new file with mode: 0644]
include/ntp_control.h [new file with mode: 0644]
include/ntp_crypto.h [new file with mode: 0644]
include/ntp_datum.h [new file with mode: 0644]
include/ntp_debug.h [new file with mode: 0644]
include/ntp_filegen.h [new file with mode: 0644]
include/ntp_fp.h [new file with mode: 0644]
include/ntp_if.h [new file with mode: 0644]
include/ntp_io.h [new file with mode: 0644]
include/ntp_machine.h [new file with mode: 0644]
include/ntp_malloc.h [new file with mode: 0644]
include/ntp_md5.h [new file with mode: 0644]
include/ntp_proto.h [new file with mode: 0644]
include/ntp_random.h [new file with mode: 0644]
include/ntp_refclock.h [new file with mode: 0644]
include/ntp_request.h [new file with mode: 0644]
include/ntp_rfc2553.h [new file with mode: 0644]
include/ntp_select.h [new file with mode: 0644]
include/ntp_sprintf.h [new file with mode: 0644]
include/ntp_stdlib.h [new file with mode: 0644]
include/ntp_string.h [new file with mode: 0644]
include/ntp_syscall.h [new file with mode: 0644]
include/ntp_syslog.h [new file with mode: 0644]
include/ntp_tty.h [new file with mode: 0644]
include/ntp_types.h [new file with mode: 0644]
include/ntp_unixtime.h [new file with mode: 0644]
include/ntpd.h [new file with mode: 0644]
include/ntpsim.h [new file with mode: 0644]
include/parse.h [new file with mode: 0644]
include/parse_conf.h [new file with mode: 0644]
include/recvbuff.h [new file with mode: 0644]
include/rsa_md5.h [new file with mode: 0644]
include/timepps-SCO.h [new file with mode: 0644]
include/timepps-Solaris.h [new file with mode: 0644]
include/timepps-SunOS.h [new file with mode: 0644]
include/trimble.h [new file with mode: 0644]
include/version.def [new file with mode: 0644]
install-sh [new file with mode: 0755]
kernel/Makefile.am [new file with mode: 0644]
kernel/Makefile.in [new file with mode: 0644]
kernel/README [new file with mode: 0644]
kernel/chuinit.c [new file with mode: 0644]
kernel/clkinit.c [new file with mode: 0644]
kernel/sys/Makefile.am [new file with mode: 0644]
kernel/sys/Makefile.in [new file with mode: 0644]
kernel/sys/README [new file with mode: 0644]
kernel/sys/bsd_audioirig.h [new file with mode: 0644]
kernel/sys/chudefs.h [new file with mode: 0644]
kernel/sys/clkdefs.h [new file with mode: 0644]
kernel/sys/i8253.h [new file with mode: 0644]
kernel/sys/parsestreams.h [new file with mode: 0644]
kernel/sys/pcl720.h [new file with mode: 0644]
kernel/sys/ppsclock.h [new file with mode: 0644]
kernel/sys/timex.h [new file with mode: 0644]
kernel/sys/tpro.h [new file with mode: 0644]
kernel/sys/tt560_api.h [new file with mode: 0644]
kernel/tty_chu.c [new file with mode: 0644]
kernel/tty_chu_STREAMS.c [new file with mode: 0644]
kernel/tty_clk.c [new file with mode: 0644]
kernel/tty_clk_STREAMS.c [new file with mode: 0644]
libisc/assertions.c [new file with mode: 0644]
libisc/error.c [new file with mode: 0644]
libisc/ifiter_getifaddrs.c [new file with mode: 0644]
libisc/ifiter_ioctl.c [new file with mode: 0644]
libisc/ifiter_sysctl.c [new file with mode: 0644]
libisc/inet_aton.c [new file with mode: 0644]
libisc/inet_ntop.c [new file with mode: 0644]
libisc/inet_pton.c [new file with mode: 0644]
libisc/interfaceiter.c [new file with mode: 0644]
libisc/isc_strerror.c [new file with mode: 0644]
libisc/lib.c [new file with mode: 0644]
libisc/mem.c [new file with mode: 0644]
libisc/msgcat.c [new file with mode: 0644]
libisc/net.c [new file with mode: 0644]
libisc/netaddr.c [new file with mode: 0644]
libisc/netscope.c [new file with mode: 0644]
libisc/sockaddr.c [new file with mode: 0644]
libisc/strerror.c [new file with mode: 0644]
libntp/Makefile.am [new file with mode: 0644]
libntp/Makefile.in [new file with mode: 0644]
libntp/README [new file with mode: 0644]
libntp/a_md5encrypt.c [new file with mode: 0644]
libntp/adjtime.c [new file with mode: 0644]
libntp/adjtimex.c [new file with mode: 0644]
libntp/atoint.c [new file with mode: 0644]
libntp/atolfp.c [new file with mode: 0644]
libntp/atouint.c [new file with mode: 0644]
libntp/audio.c [new file with mode: 0644]
libntp/authkeys.c [new file with mode: 0644]
libntp/authreadkeys.c [new file with mode: 0644]
libntp/authusekey.c [new file with mode: 0644]
libntp/buftvtots.c [new file with mode: 0644]
libntp/caljulian.c [new file with mode: 0644]
libntp/caltontp.c [new file with mode: 0644]
libntp/calyearstart.c [new file with mode: 0644]
libntp/clocktime.c [new file with mode: 0644]
libntp/clocktypes.c [new file with mode: 0644]
libntp/decodenetnum.c [new file with mode: 0644]
libntp/dofptoa.c [new file with mode: 0644]
libntp/dolfptoa.c [new file with mode: 0644]
libntp/emalloc.c [new file with mode: 0644]
libntp/findconfig.c [new file with mode: 0644]
libntp/fptoa.c [new file with mode: 0644]
libntp/fptoms.c [new file with mode: 0644]
libntp/getopt.c [new file with mode: 0644]
libntp/hextoint.c [new file with mode: 0644]
libntp/hextolfp.c [new file with mode: 0644]
libntp/humandate.c [new file with mode: 0644]
libntp/icom.c [new file with mode: 0644]
libntp/inttoa.c [new file with mode: 0644]
libntp/iosignal.c [new file with mode: 0644]
libntp/lib_strbuf.c [new file with mode: 0644]
libntp/lib_strbuf.h [new file with mode: 0644]
libntp/machines.c [new file with mode: 0644]
libntp/md5c.c [new file with mode: 0644]
libntp/memmove.c [new file with mode: 0644]
libntp/mfptoa.c [new file with mode: 0644]
libntp/mfptoms.c [new file with mode: 0644]
libntp/mktime.c [new file with mode: 0644]
libntp/modetoa.c [new file with mode: 0644]
libntp/mstolfp.c [new file with mode: 0644]
libntp/msutotsf.c [new file with mode: 0644]
libntp/msyslog.c [new file with mode: 0644]
libntp/netof.c [new file with mode: 0644]
libntp/ntp_random.c [new file with mode: 0644]
libntp/ntp_rfc2553.c [new file with mode: 0644]
libntp/numtoa.c [new file with mode: 0644]
libntp/numtohost.c [new file with mode: 0644]
libntp/octtoint.c [new file with mode: 0644]
libntp/prettydate.c [new file with mode: 0644]
libntp/recvbuff.c [new file with mode: 0644]
libntp/refnumtoa.c [new file with mode: 0644]
libntp/snprintf.c [new file with mode: 0644]
libntp/socktoa.c [new file with mode: 0644]
libntp/socktohost.c [new file with mode: 0644]
libntp/statestr.c [new file with mode: 0644]
libntp/strdup.c [new file with mode: 0644]
libntp/strerror.c [new file with mode: 0644]
libntp/strstr.c [new file with mode: 0644]
libntp/syssignal.c [new file with mode: 0644]
libntp/systime.c [new file with mode: 0644]
libntp/systime_s.c [new file with mode: 0644]
libntp/tsftomsu.c [new file with mode: 0644]
libntp/tstotv.c [new file with mode: 0644]
libntp/tvtoa.c [new file with mode: 0644]
libntp/tvtots.c [new file with mode: 0644]
libntp/uglydate.c [new file with mode: 0644]
libntp/uinttoa.c [new file with mode: 0644]
libntp/utvtoa.c [new file with mode: 0644]
libntp/ymd2yd.c [new file with mode: 0644]
libopts/COPYING.lgpl [new file with mode: 0644]
libopts/COPYING.mbsd [new file with mode: 0644]
libopts/MakeDefs.inc [new file with mode: 0644]
libopts/Makefile.am [new file with mode: 0644]
libopts/Makefile.in [new file with mode: 0644]
libopts/README [new file with mode: 0644]
libopts/autoopts.c [new file with mode: 0644]
libopts/autoopts.h [new file with mode: 0644]
libopts/autoopts/options.h [new file with mode: 0644]
libopts/autoopts/usage-txt.h [new file with mode: 0644]
libopts/boolean.c [new file with mode: 0644]
libopts/compat/compat.h [new file with mode: 0644]
libopts/compat/pathfind.c [new file with mode: 0644]
libopts/compat/snprintf.c [new file with mode: 0644]
libopts/compat/strchr.c [new file with mode: 0644]
libopts/compat/strdup.c [new file with mode: 0644]
libopts/compat/windows-config.h [new file with mode: 0644]
libopts/configfile.c [new file with mode: 0644]
libopts/cook.c [new file with mode: 0644]
libopts/enumeration.c [new file with mode: 0644]
libopts/environment.c [new file with mode: 0644]
libopts/genshell.c [new file with mode: 0644]
libopts/genshell.h [new file with mode: 0644]
libopts/libopts.c [new file with mode: 0644]
libopts/load.c [new file with mode: 0644]
libopts/m4/libopts.m4 [new file with mode: 0644]
libopts/m4/liboptschk.m4 [new file with mode: 0644]
libopts/makeshell.c [new file with mode: 0644]
libopts/nested.c [new file with mode: 0644]
libopts/numeric.c [new file with mode: 0644]
libopts/pgusage.c [new file with mode: 0644]
libopts/proto.h [new file with mode: 0644]
libopts/putshell.c [new file with mode: 0644]
libopts/restore.c [new file with mode: 0644]
libopts/save.c [new file with mode: 0644]
libopts/sort.c [new file with mode: 0644]
libopts/stack.c [new file with mode: 0644]
libopts/streqvcmp.c [new file with mode: 0644]
libopts/text_mmap.c [new file with mode: 0644]
libopts/tokenize.c [new file with mode: 0644]
libopts/usage.c [new file with mode: 0644]
libopts/version.c [new file with mode: 0644]
libparse/Makefile.am [new file with mode: 0644]
libparse/Makefile.in [new file with mode: 0644]
libparse/README [new file with mode: 0644]
libparse/binio.c [new file with mode: 0644]
libparse/clk_computime.c [new file with mode: 0644]
libparse/clk_dcf7000.c [new file with mode: 0644]
libparse/clk_hopf6021.c [new file with mode: 0644]
libparse/clk_meinberg.c [new file with mode: 0644]
libparse/clk_rawdcf.c [new file with mode: 0644]
libparse/clk_rcc8000.c [new file with mode: 0644]
libparse/clk_schmid.c [new file with mode: 0644]
libparse/clk_trimtaip.c [new file with mode: 0644]
libparse/clk_trimtsip.c [new file with mode: 0644]
libparse/clk_varitext.c [new file with mode: 0644]
libparse/clk_wharton.c [new file with mode: 0644]
libparse/data_mbg.c [new file with mode: 0644]
libparse/gpstolfp.c [new file with mode: 0644]
libparse/ieee754io.c [new file with mode: 0644]
libparse/info_trimble.c [new file with mode: 0644]
libparse/mfp_mul.c [new file with mode: 0644]
libparse/mkinfo_rcmd.sed [new file with mode: 0644]
libparse/mkinfo_scmd.sed [new file with mode: 0644]
libparse/parse.c [new file with mode: 0644]
libparse/parse_conf.c [new file with mode: 0644]
libparse/parsesolaris.c [new file with mode: 0644]
libparse/parsestreams.c [new file with mode: 0644]
libparse/trim_info.c [new file with mode: 0644]
ltmain.sh [new file with mode: 0644]
m4/define_dir.m4 [new file with mode: 0644]
m4/hs_ulong_const.m4 [new file with mode: 0644]
m4/os_cflags.m4 [new file with mode: 0644]
missing [new file with mode: 0755]
ntpd/Makefile.am [new file with mode: 0644]
ntpd/Makefile.in [new file with mode: 0644]
ntpd/check_y2k.c [new file with mode: 0644]
ntpd/cmd_args.c [new file with mode: 0644]
ntpd/jupiter.h [new file with mode: 0644]
ntpd/ntp_config.c [new file with mode: 0644]
ntpd/ntp_control.c [new file with mode: 0644]
ntpd/ntp_crypto.c [new file with mode: 0644]
ntpd/ntp_filegen.c [new file with mode: 0644]
ntpd/ntp_intres.c [new file with mode: 0644]
ntpd/ntp_io.c [new file with mode: 0644]
ntpd/ntp_loopfilter.c [new file with mode: 0644]
ntpd/ntp_monitor.c [new file with mode: 0644]
ntpd/ntp_peer.c [new file with mode: 0644]
ntpd/ntp_proto.c [new file with mode: 0644]
ntpd/ntp_refclock.c [new file with mode: 0644]
ntpd/ntp_request.c [new file with mode: 0644]
ntpd/ntp_restrict.c [new file with mode: 0644]
ntpd/ntp_timer.c [new file with mode: 0644]
ntpd/ntp_util.c [new file with mode: 0644]
ntpd/ntpd-opts.c [new file with mode: 0644]
ntpd/ntpd-opts.def [new file with mode: 0644]
ntpd/ntpd-opts.h [new file with mode: 0644]
ntpd/ntpd-opts.menu [new file with mode: 0644]
ntpd/ntpd-opts.texi [new file with mode: 0644]
ntpd/ntpd.1 [new file with mode: 0644]
ntpd/ntpd.c [new file with mode: 0644]
ntpd/ntpdbase-opts.def [new file with mode: 0644]
ntpd/ntpdsim-opts.c [new file with mode: 0644]
ntpd/ntpdsim-opts.def [new file with mode: 0644]
ntpd/ntpdsim-opts.h [new file with mode: 0644]
ntpd/ntpdsim-opts.menu [new file with mode: 0644]
ntpd/ntpdsim-opts.texi [new file with mode: 0644]
ntpd/ntpdsim.1 [new file with mode: 0644]
ntpd/ntpsim.c [new file with mode: 0644]
ntpd/ppsapi_timepps.h [new file with mode: 0644]
ntpd/refclock_acts.c [new file with mode: 0644]
ntpd/refclock_arbiter.c [new file with mode: 0644]
ntpd/refclock_arc.c [new file with mode: 0644]
ntpd/refclock_as2201.c [new file with mode: 0644]
ntpd/refclock_atom.c [new file with mode: 0644]
ntpd/refclock_bancomm.c [new file with mode: 0644]
ntpd/refclock_chronolog.c [new file with mode: 0644]
ntpd/refclock_chu.c [new file with mode: 0644]
ntpd/refclock_conf.c [new file with mode: 0644]
ntpd/refclock_datum.c [new file with mode: 0644]
ntpd/refclock_dumbclock.c [new file with mode: 0644]
ntpd/refclock_fg.c [new file with mode: 0644]
ntpd/refclock_gpsvme.c [new file with mode: 0644]
ntpd/refclock_heath.c [new file with mode: 0644]
ntpd/refclock_hopfpci.c [new file with mode: 0644]
ntpd/refclock_hopfser.c [new file with mode: 0644]
ntpd/refclock_hpgps.c [new file with mode: 0644]
ntpd/refclock_irig.c [new file with mode: 0644]
ntpd/refclock_jjy.c [new file with mode: 0644]
ntpd/refclock_jupiter.c [new file with mode: 0644]
ntpd/refclock_leitch.c [new file with mode: 0644]
ntpd/refclock_local.c [new file with mode: 0644]
ntpd/refclock_msfees.c [new file with mode: 0644]
ntpd/refclock_mx4200.c [new file with mode: 0644]
ntpd/refclock_neoclock4x.c [new file with mode: 0644]
ntpd/refclock_nmea.c [new file with mode: 0644]
ntpd/refclock_oncore.c [new file with mode: 0644]
ntpd/refclock_palisade.c [new file with mode: 0644]
ntpd/refclock_palisade.h [new file with mode: 0644]
ntpd/refclock_parse.c [new file with mode: 0644]
ntpd/refclock_pcf.c [new file with mode: 0644]
ntpd/refclock_pst.c [new file with mode: 0644]
ntpd/refclock_ripencc.c [new file with mode: 0644]
ntpd/refclock_shm.c [new file with mode: 0644]
ntpd/refclock_tpro.c [new file with mode: 0644]
ntpd/refclock_trak.c [new file with mode: 0644]
ntpd/refclock_true.c [new file with mode: 0644]
ntpd/refclock_tt560.c [new file with mode: 0644]
ntpd/refclock_ulink.c [new file with mode: 0644]
ntpd/refclock_wwv.c [new file with mode: 0644]
ntpd/refclock_wwvb.c [new file with mode: 0644]
ntpd/refclock_zyfer.c [new file with mode: 0644]
ntpdate/Makefile.am [new file with mode: 0644]
ntpdate/Makefile.in [new file with mode: 0644]
ntpdate/README [new file with mode: 0644]
ntpdate/ntpdate.c [new file with mode: 0644]
ntpdate/ntpdate.h [new file with mode: 0644]
ntpdate/ntptime_config.c [new file with mode: 0644]
ntpdate/ntptimeset.c [new file with mode: 0644]
ntpdc/Makefile.am [new file with mode: 0644]
ntpdc/Makefile.in [new file with mode: 0644]
ntpdc/README [new file with mode: 0644]
ntpdc/layout.std [new file with mode: 0644]
ntpdc/nl.pl [new file with mode: 0755]
ntpdc/nl.pl.in [new file with mode: 0644]
ntpdc/nl_in.c [new file with mode: 0644]
ntpdc/ntpdc-layout.c [new file with mode: 0644]
ntpdc/ntpdc-opts.c [new file with mode: 0644]
ntpdc/ntpdc-opts.def [new file with mode: 0644]
ntpdc/ntpdc-opts.h [new file with mode: 0644]
ntpdc/ntpdc-opts.menu [new file with mode: 0644]
ntpdc/ntpdc-opts.texi [new file with mode: 0644]
ntpdc/ntpdc.1 [new file with mode: 0644]
ntpdc/ntpdc.c [new file with mode: 0644]
ntpdc/ntpdc.h [new file with mode: 0644]
ntpdc/ntpdc_ops.c [new file with mode: 0644]
ntpq/Makefile.am [new file with mode: 0644]
ntpq/Makefile.in [new file with mode: 0644]
ntpq/README [new file with mode: 0644]
ntpq/ntpq-opts.c [new file with mode: 0644]
ntpq/ntpq-opts.def [new file with mode: 0644]
ntpq/ntpq-opts.h [new file with mode: 0644]
ntpq/ntpq-opts.menu [new file with mode: 0644]
ntpq/ntpq-opts.texi [new file with mode: 0644]
ntpq/ntpq-subs.c [new file with mode: 0644]
ntpq/ntpq.1 [new file with mode: 0644]
ntpq/ntpq.c [new file with mode: 0644]
ntpq/ntpq.h [new file with mode: 0644]
packageinfo.sh [new file with mode: 0644]
packaging/ntp-4.2.4-groups.patch [new file with mode: 0644]
packaging/ntp-4.2.4-html2man.patch [new file with mode: 0644]
packaging/ntp-4.2.4-linkfastmath.patch [new file with mode: 0644]
packaging/ntp-4.2.4-sprintf.patch [new file with mode: 0644]
packaging/ntp-4.2.4p0-droproot.patch [new file with mode: 0644]
packaging/ntp-4.2.4p0-retcode.patch [new file with mode: 0644]
packaging/ntp-4.2.4p2-clockselect.patch [new file with mode: 0644]
packaging/ntp-4.2.4p2-filegen.patch [new file with mode: 0644]
packaging/ntp-4.2.4p2-noif.patch [new file with mode: 0644]
packaging/ntp-4.2.4p2-noseed.patch [new file with mode: 0644]
packaging/ntp-4.2.4p2-tentative.patch [new file with mode: 0644]
packaging/ntp-4.2.4p4-cmsgalign.patch [new file with mode: 0644]
packaging/ntp-4.2.4p4-kernel.patch [new file with mode: 0644]
packaging/ntp-4.2.4p4-multilisten.patch [new file with mode: 0644]
packaging/ntp-4.2.4p4-resinit.patch [new file with mode: 0644]
packaging/ntp-4.2.4p5-driftonexit.patch [new file with mode: 0644]
packaging/ntp-4.2.4p5-htmldoc.patch [new file with mode: 0644]
packaging/ntp-4.2.4p5-rtnetlink.patch [new file with mode: 0644]
packaging/ntp-4.2.4p7-bcast.patch [new file with mode: 0644]
packaging/ntp-4.2.4p7-daemonpll.patch [new file with mode: 0644]
packaging/ntp-4.2.4p7-freqmode.patch [new file with mode: 0644]
packaging/ntp-4.2.4p7-ipv6.patch [new file with mode: 0644]
packaging/ntp-4.2.4p7-minpoll.patch [new file with mode: 0644]
packaging/ntp-4.2.4p7-nano.patch [new file with mode: 0644]
packaging/ntp-4.2.4p7-sleep.patch [new file with mode: 0644]
packaging/ntp-4.2.4p7-stamode.patch [new file with mode: 0644]
packaging/ntp-4.2.4p8-editline.patch [new file with mode: 0644]
packaging/ntp-4.2.4p8-gettime.patch [new file with mode: 0644]
packaging/ntp-4.2.4p8-mlock.patch [new file with mode: 0644]
packaging/ntp-4.2.4p8-nosntp.patch [new file with mode: 0644]
packaging/ntp-4.2.4p8.tar.bz2 [new file with mode: 0644]
packaging/ntp.changes [new file with mode: 0644]
packaging/ntp.conf [new file with mode: 0644]
packaging/ntp.cryptopw [new file with mode: 0644]
packaging/ntp.dhclient [new file with mode: 0644]
packaging/ntp.keys [new file with mode: 0644]
packaging/ntp.spec [new file with mode: 0644]
packaging/ntp.step-tickers [new file with mode: 0644]
packaging/ntpd.sysconfig [new file with mode: 0644]
packaging/ntpdate.sysconfig [new file with mode: 0644]
packaging/ntpstat-0.2-clksrc.patch [new file with mode: 0644]
packaging/ntpstat-0.2-multipacket.patch [new file with mode: 0644]
packaging/ntpstat-0.2.tgz [new file with mode: 0644]
parseutil/Makefile.am [new file with mode: 0644]
parseutil/Makefile.in [new file with mode: 0644]
parseutil/README [new file with mode: 0644]
parseutil/dcfd.c [new file with mode: 0644]
parseutil/testdcf.c [new file with mode: 0644]
ports/winnt/include/arpa/inet.h [new file with mode: 0644]
ports/winnt/include/clockstuff.h [new file with mode: 0644]
ports/winnt/include/config.h [new file with mode: 0644]
ports/winnt/include/hopf_PCI_io.h [new file with mode: 0755]
ports/winnt/include/isc/int.h [new file with mode: 0644]
ports/winnt/include/isc/ipv6.h [new file with mode: 0644]
ports/winnt/include/isc/mutex.h [new file with mode: 0644]
ports/winnt/include/isc/net.h [new file with mode: 0644]
ports/winnt/include/isc/offset.h [new file with mode: 0644]
ports/winnt/include/isc/once.h [new file with mode: 0644]
ports/winnt/include/isc/platform.h [new file with mode: 0644]
ports/winnt/include/isc/stat.h [new file with mode: 0644]
ports/winnt/include/isc/strerror.h [new file with mode: 0644]
ports/winnt/include/isc/win32os.h [new file with mode: 0644]
ports/winnt/include/netdb.h [new file with mode: 0644]
ports/winnt/include/netinet/in.h [new file with mode: 0644]
ports/winnt/include/netinet/in_system.h [new file with mode: 0644]
ports/winnt/include/netinet/ip.h [new file with mode: 0644]
ports/winnt/include/ntp_iocompletionport.h [new file with mode: 0644]
ports/winnt/include/ntp_timer.h [new file with mode: 0644]
ports/winnt/include/ntservice.h [new file with mode: 0644]
ports/winnt/include/sys/ioctl.h [new file with mode: 0644]
ports/winnt/include/sys/param.h [new file with mode: 0644]
ports/winnt/include/sys/resource.h [new file with mode: 0644]
ports/winnt/include/sys/signal.h [new file with mode: 0644]
ports/winnt/include/sys/socket.h [new file with mode: 0644]
ports/winnt/include/sys/time.h [new file with mode: 0644]
ports/winnt/include/sys/wait.h [new file with mode: 0644]
ports/winnt/include/syslog.h [new file with mode: 0644]
ports/winnt/include/termios.h [new file with mode: 0644]
ports/winnt/include/transmitbuff.h [new file with mode: 0644]
ports/winnt/include/unistd.h [new file with mode: 0644]
ports/winnt/include/win32_io.h [new file with mode: 0644]
ports/winnt/instsrv/Instsrv.dsp [new file with mode: 0644]
ports/winnt/instsrv/Instsrv.vcproj [new file with mode: 0644]
ports/winnt/instsrv/instsrv.c [new file with mode: 0644]
ports/winnt/libisc/interfaceiter.c [new file with mode: 0644]
ports/winnt/libisc/isc_strerror.c [new file with mode: 0644]
ports/winnt/libisc/net.c [new file with mode: 0644]
ports/winnt/libisc/once.c [new file with mode: 0644]
ports/winnt/libisc/win32os.c [new file with mode: 0644]
ports/winnt/libntp/SetSystemTime.c [new file with mode: 0644]
ports/winnt/libntp/dnslookup.c [new file with mode: 0644]
ports/winnt/libntp/interfaceiter.c [new file with mode: 0644]
ports/winnt/libntp/libntp.dsp [new file with mode: 0644]
ports/winnt/libntp/libntp.vcproj [new file with mode: 0644]
ports/winnt/libntp/messages.mc [new file with mode: 0644]
ports/winnt/libntp/mexit.c [new file with mode: 0644]
ports/winnt/libntp/randfile.c [new file with mode: 0644]
ports/winnt/libntp/strerror.c [new file with mode: 0644]
ports/winnt/libntp/syslog.c [new file with mode: 0644]
ports/winnt/libntp/transmitbuff.c [new file with mode: 0644]
ports/winnt/libntp/util_clockstuff.c [new file with mode: 0644]
ports/winnt/ntp-keygen/ntpkeygen.dsp [new file with mode: 0644]
ports/winnt/ntp-keygen/ntpkeygen.vcproj [new file with mode: 0644]
ports/winnt/ntp.dsw [new file with mode: 0644]
ports/winnt/ntp.sln [new file with mode: 0644]
ports/winnt/ntpd/hopf_PCI_io.c [new file with mode: 0644]
ports/winnt/ntpd/nt_clockstuff.c [new file with mode: 0644]
ports/winnt/ntpd/ntp_iocompletionport.c [new file with mode: 0644]
ports/winnt/ntpd/ntpd.dsp [new file with mode: 0644]
ports/winnt/ntpd/ntpd.vcproj [new file with mode: 0644]
ports/winnt/ntpd/ntservice.c [new file with mode: 0644]
ports/winnt/ntpd/refclock_trimbledc.c [new file with mode: 0644]
ports/winnt/ntpd/refclock_trimbledc.h [new file with mode: 0644]
ports/winnt/ntpd/win32_io.c [new file with mode: 0644]
ports/winnt/ntpdate/ntpdate.dsp [new file with mode: 0644]
ports/winnt/ntpdate/ntpdate.vcproj [new file with mode: 0644]
ports/winnt/ntpdc/ntpdc.dsp [new file with mode: 0644]
ports/winnt/ntpdc/ntpdc.vcproj [new file with mode: 0644]
ports/winnt/ntpq/ntpq.dsp [new file with mode: 0644]
ports/winnt/ntpq/ntpq.vcproj [new file with mode: 0644]
ports/winnt/ntptrace/ntptrace.dsp [new file with mode: 0644]
ports/winnt/scripts/mkver.bat [new file with mode: 0755]
readme.y2kfixes [new file with mode: 0644]
results.y2kfixes [new file with mode: 0644]
scripts/Makefile.am [new file with mode: 0644]
scripts/Makefile.in [new file with mode: 0644]
scripts/README [new file with mode: 0644]
scripts/VersionName [new file with mode: 0755]
scripts/calc_tickadj.in [new file with mode: 0644]
scripts/checktime.in [new file with mode: 0644]
scripts/fixautomakedepsmagic [new file with mode: 0644]
scripts/freq_adj.in [new file with mode: 0644]
scripts/genCommitLog [new file with mode: 0755]
scripts/genver [new file with mode: 0755]
scripts/hpadjtime.sh [new file with mode: 0755]
scripts/html2man.in [new file with mode: 0755]
scripts/mkver.in [new file with mode: 0644]
scripts/monitoring/README [new file with mode: 0644]
scripts/monitoring/loopwatch.config.SAMPLE [new file with mode: 0644]
scripts/monitoring/lr.pl [new file with mode: 0644]
scripts/monitoring/ntp.pl [new file with mode: 0644]
scripts/monitoring/ntploopstat [new file with mode: 0644]
scripts/monitoring/ntploopwatch [new file with mode: 0644]
scripts/monitoring/ntptrap [new file with mode: 0644]
scripts/monitoring/timelocal.pl [new file with mode: 0644]
scripts/ntp-close [new file with mode: 0755]
scripts/ntp-groper [new file with mode: 0755]
scripts/ntp-restart [new file with mode: 0755]
scripts/ntp-status [new file with mode: 0755]
scripts/ntp-wait.in [new file with mode: 0644]
scripts/ntpsweep.in [new file with mode: 0644]
scripts/ntptrace.in [new file with mode: 0755]
scripts/ntpver.in [new file with mode: 0644]
scripts/plot_summary.in [new file with mode: 0644]
scripts/rc1/postinstall [new file with mode: 0644]
scripts/rc1/preinstall [new file with mode: 0644]
scripts/rc1/preremove [new file with mode: 0644]
scripts/rc1/prototype [new file with mode: 0644]
scripts/rc1/xntp [new file with mode: 0644]
scripts/rc2/local.ntpd [new file with mode: 0644]
scripts/stats/README [new file with mode: 0644]
scripts/stats/README.stats [new file with mode: 0644]
scripts/stats/README.timecodes [new file with mode: 0644]
scripts/stats/clock.awk [new file with mode: 0755]
scripts/stats/dupe.awk [new file with mode: 0755]
scripts/stats/ensemble.S [new file with mode: 0755]
scripts/stats/ensemble.awk [new file with mode: 0755]
scripts/stats/etf.S [new file with mode: 0755]
scripts/stats/etf.awk [new file with mode: 0755]
scripts/stats/itf.S [new file with mode: 0755]
scripts/stats/itf.awk [new file with mode: 0755]
scripts/stats/loop.S [new file with mode: 0755]
scripts/stats/loop.awk [new file with mode: 0755]
scripts/stats/loop_summary [new file with mode: 0755]
scripts/stats/peer.awk [new file with mode: 0755]
scripts/stats/psummary.awk [new file with mode: 0755]
scripts/stats/summary.sh [new file with mode: 0755]
scripts/stats/tdata.S [new file with mode: 0755]
scripts/stats/tdata.awk [new file with mode: 0755]
scripts/summary.in [new file with mode: 0644]
sntp/COPYRIGHT [new file with mode: 0644]
sntp/Makefile.am [new file with mode: 0644]
sntp/Makefile.in [new file with mode: 0644]
sntp/README [new file with mode: 0644]
sntp/aclocal.m4 [new file with mode: 0644]
sntp/autogen-version.def [new file with mode: 0644]
sntp/bincheck.mf [new file with mode: 0644]
sntp/compile [new file with mode: 0755]
sntp/config.guess [new file with mode: 0755]
sntp/config.h.in [new file with mode: 0644]
sntp/config.sub [new file with mode: 0755]
sntp/configure [new file with mode: 0755]
sntp/configure.ac [new file with mode: 0644]
sntp/depcomp [new file with mode: 0755]
sntp/header.h [new file with mode: 0644]
sntp/install-sh [new file with mode: 0755]
sntp/internet.c [new file with mode: 0644]
sntp/internet.h [new file with mode: 0644]
sntp/kludges.h [new file with mode: 0644]
sntp/libopts/COPYING.lgpl [new file with mode: 0644]
sntp/libopts/COPYING.mbsd [new file with mode: 0644]
sntp/libopts/MakeDefs.inc [new file with mode: 0644]
sntp/libopts/Makefile.am [new file with mode: 0644]
sntp/libopts/Makefile.in [new file with mode: 0644]
sntp/libopts/README [new file with mode: 0644]
sntp/libopts/autoopts.c [new file with mode: 0644]
sntp/libopts/autoopts.h [new file with mode: 0644]
sntp/libopts/autoopts/options.h [new file with mode: 0644]
sntp/libopts/autoopts/usage-txt.h [new file with mode: 0644]
sntp/libopts/boolean.c [new file with mode: 0644]
sntp/libopts/compat/compat.h [new file with mode: 0644]
sntp/libopts/compat/pathfind.c [new file with mode: 0644]
sntp/libopts/compat/snprintf.c [new file with mode: 0644]
sntp/libopts/compat/strchr.c [new file with mode: 0644]
sntp/libopts/compat/strdup.c [new file with mode: 0644]
sntp/libopts/compat/windows-config.h [new file with mode: 0644]
sntp/libopts/configfile.c [new file with mode: 0644]
sntp/libopts/cook.c [new file with mode: 0644]
sntp/libopts/enumeration.c [new file with mode: 0644]
sntp/libopts/environment.c [new file with mode: 0644]
sntp/libopts/genshell.c [new file with mode: 0644]
sntp/libopts/genshell.h [new file with mode: 0644]
sntp/libopts/libopts.c [new file with mode: 0644]
sntp/libopts/load.c [new file with mode: 0644]
sntp/libopts/m4/libopts.m4 [new file with mode: 0644]
sntp/libopts/m4/liboptschk.m4 [new file with mode: 0644]
sntp/libopts/makeshell.c [new file with mode: 0644]
sntp/libopts/nested.c [new file with mode: 0644]
sntp/libopts/numeric.c [new file with mode: 0644]
sntp/libopts/pgusage.c [new file with mode: 0644]
sntp/libopts/proto.h [new file with mode: 0644]
sntp/libopts/putshell.c [new file with mode: 0644]
sntp/libopts/restore.c [new file with mode: 0644]
sntp/libopts/save.c [new file with mode: 0644]
sntp/libopts/sort.c [new file with mode: 0644]
sntp/libopts/stack.c [new file with mode: 0644]
sntp/libopts/streqvcmp.c [new file with mode: 0644]
sntp/libopts/text_mmap.c [new file with mode: 0644]
sntp/libopts/tokenize.c [new file with mode: 0644]
sntp/libopts/usage.c [new file with mode: 0644]
sntp/libopts/version.c [new file with mode: 0644]
sntp/ltmain.sh [new file with mode: 0644]
sntp/main.c [new file with mode: 0644]
sntp/missing [new file with mode: 0755]
sntp/sntp-opts.c [new file with mode: 0644]
sntp/sntp-opts.def [new file with mode: 0644]
sntp/sntp-opts.h [new file with mode: 0644]
sntp/sntp-opts.menu [new file with mode: 0644]
sntp/sntp-opts.texi [new file with mode: 0644]
sntp/sntp.1 [new file with mode: 0644]
sntp/socket.c [new file with mode: 0644]
sntp/timing.c [new file with mode: 0644]
sntp/unix.c [new file with mode: 0644]
sntp/version.def [new file with mode: 0644]
util/Makefile.am [new file with mode: 0644]
util/Makefile.in [new file with mode: 0644]
util/README [new file with mode: 0644]
util/ansi2knr.1 [new file with mode: 0644]
util/ansi2knr.c [new file with mode: 0644]
util/audio-pcm.c [new file with mode: 0644]
util/byteorder.c [new file with mode: 0644]
util/hist.c [new file with mode: 0644]
util/jitter.c [new file with mode: 0644]
util/jitter.h [new file with mode: 0644]
util/kern.c [new file with mode: 0644]
util/longsize.c [new file with mode: 0644]
util/ntp-keygen-opts.c [new file with mode: 0644]
util/ntp-keygen-opts.def [new file with mode: 0644]
util/ntp-keygen-opts.h [new file with mode: 0644]
util/ntp-keygen-opts.menu [new file with mode: 0644]
util/ntp-keygen-opts.texi [new file with mode: 0644]
util/ntp-keygen.1 [new file with mode: 0644]
util/ntp-keygen.c [new file with mode: 0644]
util/ntptime.c [new file with mode: 0644]
util/pps-api.c [new file with mode: 0644]
util/precision.c [new file with mode: 0644]
util/sht.c [new file with mode: 0644]
util/testrs6000.c [new file with mode: 0644]
util/tg.c [new file with mode: 0644]
util/tickadj.c [new file with mode: 0644]
util/timetrim.c [new file with mode: 0644]
version [new file with mode: 0644]
version.m4 [new file with mode: 0644]

diff --git a/COPYRIGHT b/COPYRIGHT
new file mode 100644 (file)
index 0000000..5497040
--- /dev/null
+++ b/COPYRIGHT
@@ -0,0 +1,176 @@
+This file is automatically generated from html/copyright.html
+
+  Copyright Notice
+  
+   jpg "Clone me," says Dolly sheepishly
+   
+   Last update: 20:31 UTC Saturday, January 06, 2007
+     _________________________________________________________________
+   
+   The following copyright notice applies to all files collectively
+   called the Network Time Protocol Version 4 Distribution. Unless
+   specifically declared otherwise in an individual file, this notice
+   applies as if the text was explicitly included in the file.
+***********************************************************************
+*                                                                     *
+* Copyright (c) David L. Mills 1992-2009                              *
+*                                                                     *
+* Permission to use, copy, modify, and distribute this software and   *
+* its documentation for any purpose with or without fee is hereby     *
+* granted, provided that the above copyright notice appears in all    *
+* copies and that both the copyright notice and this permission       *
+* notice appear in supporting documentation, and that the name        *
+* University of Delaware not be used in advertising or publicity      *
+* pertaining to distribution of the software without specific,        *
+* written prior permission. The University of Delaware makes no       *
+* representations about the suitability this software for any         *
+* purpose. It is provided "as is" without express or implied          *
+* warranty.                                                           *
+*                                                                     *
+***********************************************************************
+
+   The following individuals contributed in part to the Network Time
+   Protocol Distribution Version 4 and are acknowledged as authors of
+   this work.
+    1. [1]Mark Andrews <mark_andrews@isc.org> Leitch atomic clock
+       controller
+    2. [2]Bernd Altmeier <altmeier@atlsoft.de> hopf Elektronik serial
+       line and PCI-bus devices
+    3. [3]Viraj Bais <vbais@mailman1.intel.com> and [4]Clayton Kirkwood
+       <kirkwood@striderfm.intel.com> port to WindowsNT 3.5
+    4. [5]Michael Barone <michael,barone@lmco.com> GPSVME fixes
+    5. [6]Jean-Francois Boudreault
+       <Jean-Francois.Boudreault@viagenie.qc.ca>IPv6 support
+    6. [7]Karl Berry <karl@owl.HQ.ileaf.com> syslog to file option
+    7. [8]Greg Brackley <greg.brackley@bigfoot.com> Major rework of WINNT
+       port. Clean up recvbuf and iosignal code into separate modules.
+    8. [9]Marc Brett <Marc.Brett@westgeo.com> Magnavox GPS clock driver
+    9. [10]Piete Brooks <Piete.Brooks@cl.cam.ac.uk> MSF clock driver,
+       Trimble PARSE support
+   10. [11]Reg Clemens <reg@dwf.com> Oncore driver (Current maintainer)
+   11. [12]Steve Clift <clift@ml.csiro.au> OMEGA clock driver
+   12. [13]Casey Crellin <casey@csc.co.za> vxWorks (Tornado) port and
+       help with target configuration
+   13. [14]Sven Dietrich <sven_dietrich@trimble.com> Palisade reference
+       clock driver, NT adj. residuals, integrated Greg's Winnt port.
+   14. [15]John A. Dundas III <dundas@salt.jpl.nasa.gov> Apple A/UX port
+   15. [16]Torsten Duwe <duwe@immd4.informatik.uni-erlangen.de> Linux
+       port
+   16. [17]Dennis Ferguson <dennis@mrbill.canet.ca> foundation code for
+       NTP Version 2 as specified in RFC-1119
+   17. [18]John Hay <jhay@@icomtek.csir.co.za> IPv6 support and testing
+   18. [19]Glenn Hollinger <glenn@herald.usask.ca> GOES clock driver
+   19. [20]Mike Iglesias <iglesias@uci.edu> DEC Alpha port
+   20. [21]Jim Jagielski <jim@jagubox.gsfc.nasa.gov> A/UX port
+   21. [22]Jeff Johnson <jbj@chatham.usdesign.com> massive prototyping
+       overhaul
+   22. [23]Hans Lambermont <Hans.Lambermont@nl.origin-it.com> or
+       [24]<H.Lambermont@chello.nl> ntpsweep
+   23. [25]Poul-Henning Kamp <phk@FreeBSD.ORG> Oncore driver (Original
+       author)
+   24. [26]Frank Kardel [27]<kardel (at) ntp (dot) org> PARSE <GENERIC>
+       driver (>14 reference clocks), STREAMS modules for PARSE, support
+       scripts, syslog cleanup, dynamic interface handling
+   25. [28]William L. Jones <jones@hermes.chpc.utexas.edu> RS/6000 AIX
+       modifications, HPUX modifications
+   26. [29]Dave Katz <dkatz@cisco.com> RS/6000 AIX port
+   27. [30]Craig Leres <leres@ee.lbl.gov> 4.4BSD port, ppsclock, Magnavox
+       GPS clock driver
+   28. [31]George Lindholm <lindholm@ucs.ubc.ca> SunOS 5.1 port
+   29. [32]Louis A. Mamakos <louie@ni.umd.edu> MD5-based authentication
+   30. [33]Lars H. Mathiesen <thorinn@diku.dk> adaptation of foundation
+       code for Version 3 as specified in RFC-1305
+   31. [34]Danny Mayer <mayer@ntp.org>Network I/O, Windows Port, Code
+       Maintenance
+   32. [35]David L. Mills <mills@udel.edu> Version 4 foundation: clock
+       discipline, authentication, precision kernel; clock drivers:
+       Spectracom, Austron, Arbiter, Heath, ATOM, ACTS, KSI/Odetics;
+       audio clock drivers: CHU, WWV/H, IRIG
+   33. [36]Wolfgang Moeller <moeller@gwdgv1.dnet.gwdg.de> VMS port
+   34. [37]Jeffrey Mogul <mogul@pa.dec.com> ntptrace utility
+   35. [38]Tom Moore <tmoore@fievel.daytonoh.ncr.com> i386 svr4 port
+   36. [39]Kamal A Mostafa <kamal@whence.com> SCO OpenServer port
+   37. [40]Derek Mulcahy <derek@toybox.demon.co.uk> and [41]Damon
+       Hart-Davis <d@hd.org> ARCRON MSF clock driver
+   38. [42]Rainer Pruy <Rainer.Pruy@informatik.uni-erlangen.de>
+       monitoring/trap scripts, statistics file handling
+   39. [43]Dirce Richards <dirce@zk3.dec.com> Digital UNIX V4.0 port
+   40. [44]Wilfredo Sánchez <wsanchez@apple.com> added support for
+       NetInfo
+   41. [45]Nick Sayer <mrapple@quack.kfu.com> SunOS streams modules
+   42. [46]Jack Sasportas <jack@innovativeinternet.com> Saved a Lot of
+       space on the stuff in the html/pic/ subdirectory
+   43. [47]Ray Schnitzler <schnitz@unipress.com> Unixware1 port
+   44. [48]Michael Shields <shields@tembel.org> USNO clock driver
+   45. [49]Jeff Steinman <jss@pebbles.jpl.nasa.gov> Datum PTS clock
+       driver
+   46. [50]Harlan Stenn <harlan@pfcs.com> GNU automake/autoconfigure
+       makeover, various other bits (see the ChangeLog)
+   47. [51]Kenneth Stone <ken@sdd.hp.com> HP-UX port
+   48. [52]Ajit Thyagarajan <ajit@ee.udel.edu>IP multicast/anycast
+       support
+   49. [53]Tomoaki TSURUOKA <tsuruoka@nc.fukuoka-u.ac.jp>TRAK clock
+       driver
+   50. [54]Paul A Vixie <vixie@vix.com> TrueTime GPS driver, generic
+       TrueTime clock driver
+   51. [55]Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> corrected and
+       validated HTML documents according to the HTML DTD
+     _________________________________________________________________
+
+References
+
+   1. mailto:%20mark_andrews@isc.org
+   2. mailto:%20altmeier@atlsoft.de
+   3. mailto:%20vbais@mailman1.intel.co
+   4. mailto:%20kirkwood@striderfm.intel.com
+   5. mailto:%20michael.barone@lmco.com
+   6. mailto:%20Jean-Francois.Boudreault@viagenie.qc.ca
+   7. mailto:%20karl@owl.HQ.ileaf.com
+   8. mailto:%20greg.brackley@bigfoot.com
+   9. mailto:%20Marc.Brett@westgeo.com
+  10. mailto:%20Piete.Brooks@cl.cam.ac.uk
+  11. mailto:%20reg@dwf.com
+  12. mailto:%20clift@ml.csiro.au
+  13. mailto:casey@csc.co.za
+  14. mailto:%20Sven_Dietrich@trimble.COM
+  15. mailto:%20dundas@salt.jpl.nasa.gov
+  16. mailto:%20duwe@immd4.informatik.uni-erlangen.de
+  17. mailto:%20dennis@mrbill.canet.ca
+  18. mailto:%20jhay@icomtek.csir.co.za
+  19. mailto:%20glenn@herald.usask.ca
+  20. mailto:%20iglesias@uci.edu
+  21. mailto:%20jagubox.gsfc.nasa.gov
+  22. mailto:%20jbj@chatham.usdesign.com
+  23. mailto:Hans.Lambermont@nl.origin-it.com
+  24. mailto:H.Lambermont@chello.nl
+  25. mailto:%20phk@FreeBSD.ORG
+  26. http://www4.informatik.uni-erlangen.de/%7ekardel
+  27. mailto:%20kardel(at)ntp(dot)org
+  28. mailto:%20jones@hermes.chpc.utexas.edu
+  29. mailto:%20dkatz@cisco.com
+  30. mailto:%20leres@ee.lbl.gov
+  31. mailto:%20lindholm@ucs.ubc.ca
+  32. mailto:%20louie@ni.umd.edu
+  33. mailto:%20thorinn@diku.dk
+  34. mailto:%20mayer@ntp.org
+  35. mailto:%20mills@udel.edu
+  36. mailto:%20moeller@gwdgv1.dnet.gwdg.de
+  37. mailto:%20mogul@pa.dec.com
+  38. mailto:%20tmoore@fievel.daytonoh.ncr.com
+  39. mailto:%20kamal@whence.com
+  40. mailto:%20derek@toybox.demon.co.uk
+  41. mailto:%20d@hd.org
+  42. mailto:%20Rainer.Pruy@informatik.uni-erlangen.de
+  43. mailto:%20dirce@zk3.dec.com
+  44. mailto:%20wsanchez@apple.com
+  45. mailto:%20mrapple@quack.kfu.com
+  46. mailto:%20jack@innovativeinternet.com
+  47. mailto:%20schnitz@unipress.com
+  48. mailto:%20shields@tembel.org
+  49. mailto:%20pebbles.jpl.nasa.gov
+  50. mailto:%20harlan@pfcs.com
+  51. mailto:%20ken@sdd.hp.com
+  52. mailto:%20ajit@ee.udel.edu
+  53. mailto:%20tsuruoka@nc.fukuoka-u.ac.jp
+  54. mailto:%20vixie@vix.com
+  55. mailto:%20Ulrich.Windl@rz.uni-regensburg.de
diff --git a/ChangeLog b/ChangeLog
new file mode 100644 (file)
index 0000000..60b7f05
--- /dev/null
+++ b/ChangeLog
@@ -0,0 +1,484 @@
+---
+(4.2.4p8) 2009/12/08 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Sec 1331] DoS with mode 7 packets - CVE-2009-3563.
+
+---
+(4.2.4p7) 2009/05/18 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Sec 1151] Remote exploit if autokey is enabled - CVE-2009-1252.
+* [Bug 1187] Update the copyright date.
+* [Bug 1191] ntpd fails on Win2000 - "Address already in use" after fix
+  for [Sec 1149].
+
+---
+(4.2.4p7-RC7) 2009/05/12 Released by Harlan Stenn <stenn@ntp.org>
+
+* ntp.isc.org -> ntp.org cleanup.
+* [Bug 1178] Use prior FORCE_DNSRETRY behavior as needed at runtime,
+  add configure --enable-ignore-dns-errors to be even more stubborn
+
+---
+(4.2.4p7-RC6) 2009/05/08 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 784] Make --enable-linuxcaps the default when available
+* [Bug 1179] error messages for -u/--user and -i lacking droproot
+* Updated JJY reference clock driver from Takao Abe
+* [Bug 1071] Log a message and exit before trying to use FD_SET with a
+  descriptor larger than FD_SETSIZE, which will corrupt memory
+* On corruption of the iface list head in add_interface, log and exit
+
+---
+(4.2.4p7-RC5) 2009/05/02 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 1172] 4.2.4p7-RC{3,4} fail to build on linux.
+* flock-build script unportable 'set -m' use removed
+
+---
+(4.2.4p7-RC4) 2009/04/29 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 1167] use gcc -Winit-self only if it is understood
+
+---
+(4.2.4p7-RC3) 2009/04/22 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 787] Bug fixes for 64-bit time_t on Windows
+* [Bug 813] Conditional naming of Event
+* [Bug 1147] System errors should be logged to msyslog()
+* [Bug 1155] Fix compile problem on Windows with VS2005
+* [Bug 1156] lock_thread_to_processor() should be declared in header
+* [Bug 1157] quiet OpenSSL warnings, clean up configure.ac
+* [Bug 1158] support for aix6.1
+* [Bug 1160] MacOS X is like BSD regarding F_SETOWN
+
+---
+(4.2.4p7-RC2) 2009/04/09 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Sec 1144] limited buffer overflow in ntpq.  CVE-2009-0159
+* [Sec 1149] use SO_EXCLUSIVEADDRUSE on Windows
+
+---
+(4.2.4p7-RC1) 2009/03/30 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 1131] UDP sockets should not use SIGPOLL on Solaris.
+* build system email address cleanup
+* [Bug 774] parsesolaris.c does not compile under the new Solaris
+* [Bug 873] Windows serial refclock proper TTY line discipline emulation
+* [Bug 1014] Enable building with VC9 (in Visual Studio 2008,
+  Visual C++ 2008, or SDK)
+* [Bug 1117] Deferred interface binding under Windows works only correctly
+  if FORCE_DNSRETRY is defined
+* [BUG 1124] Lock QueryPerformanceCounter() client threads to same CPU
+* DPRINTF macro made safer, always evaluates to a statement and will not
+  misassociate an else which follows the macro.
+
+---
+(4.2.4p6) 2009/01/08 Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 1113] Fixed build errors with recent versions of openSSL. 
+* [Sec 1111] Fix incorrect check of EVP_VerifyFinal()'s return value.
+* Update the copyright year.
+
+---
+(4.2.4p5) 2008/08/17 Released by Harlan Stenn <stenn@ntp.org>
+
+* [BUG 1051] Month off by one in leap second message written to clockstats
+  file fixed.
+* [Bug 450] Windows only: Under original Windows NT we must not discard the
+  wildcard socket to workaround a bug in NT's getsockname().
+* [Bug 1038] Built-in getpass() function also prompts for password if
+  not built with DEBUG.
+* [Bug 841] Obsolete the "dynamic" keyword and make deferred binding
+  to local interfaces the default.
+  Emit a warning if that keyword is used for configuration.
+* [Bug 959] Refclock on Windows not properly releasing recvbuffs.
+* [Bug 993] Fix memory leak when fetching system messages.
+* [Bug 987] Wake up the resolver thread/process when a new interface has
+  become available.
+* Correctly apply negative-sawtooth for oncore 12 channel receiver.
+* Startup code for original LinuxPPS removed.  LinuxPPS now conforms to
+  the PPSAPI.
+* [Bug 1000] allow implicit receive buffer allocation for Windows.
+  fixes startup for windows systems with many interfaces.
+  reduces dropped packets on network bursts.
+  additionally fix timer() starvation during high load.
+* [Bug 990] drop minimum time restriction for interface update interval.
+* [Bug 977] Fix mismatching #ifdefs for builds without IPv6.
+* Update the copyright year.
+* Build system cleanup (make autogen-generated files writable).
+* [Bug 957] Windows only: Let command line parameters from the Windows SCM GUI
+  override the standard parameters from the ImagePath registry key.
+* Fixes for ntpdate:
+* [Bug 532] nptdate timeout is too long if several servers are supplied.
+* [Bug 698] timeBeginPeriod is called without timeEndPeriod in some NTP tools.
+* [Bug 857] ntpdate debug mode adjusts system clock when it shouldn't.
+* [Bug 908] ntpdate crashes sometimes.
+* [Bug 982] ntpdate(and ntptimeset) buffer overrun if HAVE_POLL_H isn't set
+  (dup of 908).
+* [Bug 997] ntpdate buffer too small and unsafe.
+* ntpdate.c: Under Windows check whether NTP port in use under same conditions
+  as under other OSs.
+* ntpdate.c: Fixed some typos and indents (tabs/spaces).
+
+---
+(4.2.4p4) Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 902] Fix problems with the -6 flag.
+* Updated include/copyright.def (owner and year).
+* [Bug 878] Avoid ntpdc use of refid value as unterminated string.
+* [Bug 881] Corrected display of pll offset on 64bit systems.
+* [Bug 886] Corrected sign handling on 64bit in ntpdc loopinfo command.
+* [Bug 889] avoid malloc() interrupted by SIGIO risk
+* ntpd/refclock_parse.c: cleanup shutdown while the file descriptor is still open.
+* [Bug 885] use emalloc() to get a message at the end of the memory
+            unsigned types cannot be less than 0
+            default_ai_family is a short
+            lose trailing , from enum list
+           clarify ntp_restrict.c for easier automated analysis
+* [Bug 884] don't access recv buffers after having them passed to the free list.
+* [Bug 882] allow loopback interfaces to share addresses with other interfaces.
+
+---
+(4.2.4p3) Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 863] unable to stop ntpd on Windows as the handle reference for events
+           changed
+
+---
+(4.2.4p2) Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 854] Broadcast address was not correctly set for interface addresses
+* [Bug 829] reduce syslog noise, while there fix Enabled/Disable logging
+           to reflect the actual configuration.
+* [Bug 795] Moved declaration of variable to top of function.
+* [Bug 789] Fix multicast client crypto authentication and make sure arriving
+           multicast packets do not disturb the autokey dance.
+* [Bug 785] improve handling of multicast interfaces
+           (multicast routers still need to run a multicast routing
+           software/daemon)
+* [Bug 527] Don't write from source address length to wrong location
+* Upgraded autogen and libopts.
+* [Bug 811] ntpd should not read a .ntprc file.
+
+---
+(4.2.4p1) (skipped)
+
+---
+(4.2.4p0) Released by Harlan Stenn <stenn@ntp.org>
+
+* [Bug 793] Update Hans Lambermont's email address in ntpsweep.
+* [Bug 776] Remove unimplemented "rate" flag from ntpdate.
+* [Bug 586] Avoid lookups if AI_NUMERICHOST is set.
+* [Bug 770] Fix numeric parameters to ntp-keygen (Alain Guibert).
+* [Bug 768] Fix io_setbclient() error message.
+* [Bug 765] Use net_bind_service capability on linux.
+* [Bug 760] The background resolver must be aware of the 'dynamic' keyword.
+* [Bug 753] make union timestamp anonymous (Philip Prindeville).
+* confopt.html: move description for "dynamic" keyword into the right section.
+* pick the right type for the recv*() length argument.
+
+---
+(4.2.4) Released by Harlan Stenn <stenn@ntp.org>
+
+* monopt.html fixes from Dave Mills.
+* [Bug 452] Do not report kernel PLL/FLL flips.
+* [Bug 746] Expert mouseCLOCK USB v2.0 support added.'
+* driver8.html updates.
+* [Bug 747] Drop <NOBR> tags from ntpdc.html.
+* sntp now uses the returned precision to control decimal places.
+* sntp -u will use an unprivileged port for its queries.
+* [Bug 741] "burst" doesn't work with !unfit peers.
+* [Bug 735] Fix a make/gmake VPATH issue on Solaris.
+* [Bug 739] ntpd -x should not take an argument.
+* [Bug 737] Some systems need help providing struct iovec.
+* [Bug 717] Fix libopts compile problem.
+* [Bug 728] parse documentation fixes.
+* [Bug 734] setsockopt(..., IP_MULTICAST_IF, ...) fails on 64-bit platforms.
+* [Bug 732] C-DEX JST2000 patch from Hideo Kuramatsu.
+* [Bug 721] check for __ss_family and __ss_len separately.
+* [Bug 666] ntpq opeers displays jitter rather than dispersion.
+* [Bug 718] Use the recommended type for the saddrlen arg to getsockname().
+* [Bug 715] Fix a multicast issue under Linux.
+* [Bug 690] Fix a Windows DNS lookup buffer overflow.
+* [Bug 670] Resolved a Windows issue with the dynamic interface rescan code.
+* K&R C support is being deprecated.
+* [Bug 714] ntpq -p should conflict with -i, not -c.
+* WWV refclock improvements from Dave Mills.
+* [Bug 708] Use thread affinity only for the clock interpolation thread.
+* [Bug 706] ntpd can be running several times in parallel.
+* [Bug 704] Documentation typos.
+* [Bug 701] coverity: NULL dereference in ntp_peer.c
+* [Bug 695] libopts does not protect against macro collisions.
+* [Bug 693] __adjtimex is independent of ntp_{adj,get}time.
+* [Bug 692] sys_limitrejected was not being incremented.
+* [Bug 691] restrictions() assumption not always valid.
+* [Bug 689] Deprecate HEATH GC-1001 II; the driver never worked.
+* [Bug 688] Fix documentation typos.
+* [Bug 686] Handle leap seconds better under Windows.
+* [Bug 685] Use the Windows multimedia timer.
+* [Bug 684] Only allow debug options if debugging is enabled.
+* [Bug 683] Use the right version string.
+* [Bug 680] Fix the generated version string on Windows.
+* [Bug 678] Use the correct size for control messages.
+* [Bug 677] Do not check uint_t in configure.ac.
+* [Bug 676] Use the right value for msg_namelen.
+* [Bug 675] Make sure ntpd builds without debugging.
+* [Bug 672] Fix cross-platform structure padding/size differences.
+* [Bug 660] New TIMESTAMP code fails tp build on Solaris Express.
+* [Bug 659] libopts does not build under Windows.
+* [Bug 658] HP-UX with cc needs -Wp,-H8166 in CFLAGS.
+* [Bug 656] ntpdate doesn't work with multicast address.
+* [Bug 638] STREAMS_TLI is deprecated - remove it.
+* [Bug 635] Fix tOptions definition.
+* [Bug 628] Fallback to ntp discipline not working for large offsets.
+* [Bug 622] Dynamic interface tracking for ntpd.
+* [Bug 603] Don't link with libelf if it's not needed.
+* [Bug 523] ntpd service under Windows does't shut down properly.
+* [Bug 500] sntp should always be built.
+* [Bug 479] Fix the -P option.
+* [Bug 421] Support the bc637PCI-U card.
+* [Bug 342] Deprecate broken TRAK refclock driver.
+* [Bug 340] Deprecate broken MSF EES refclock driver.
+* [Bug 153] Don't do DNS lookups on address masks.
+* [Bug 143] Fix interrupted system call on HP-UX.
+* [Bug 42] Distribution tarballs should be signed.
+* Support separate PPS devices for PARSE refclocks.
+* [Bug 637, 51?] Dynamic interface scanning can now be done.
+* Options processing now uses GNU AutoGen.
+
+---
+(4.2.2p4) Released by Harlan Stenn <stenn@ntp.org>
+
+ * [Bug 710] compat getnameinfo() has off-by-one error
+ * [Bug 690] Buffer overflow in Windows when doing DNS Lookups
+
+---
+(4.2.2p3) Released by Harlan Stenn <stenn@ntp.org>
+
+ * Make the ChangeLog file cleaner and easier to read
+ * [Bug 601] ntpq's decodeint uses an extra level of indirection
+ * [Bug 657] Different OSes need different sized args for IP_MULTICAST_LOOP
+ * release engineering/build changes
+ * Documentation fixes
+ * Get sntp working under AIX-5
+
+---
+(4.2.2p2) (broken)
+
+ * Get sntp working under AIX-5
+
+---
+(4.2.2p1)
+
+ * [Bug 661] Use environment variable to specify the base path to openssl.
+ * Resolve an ambiguity in the copyright notice
+ * Added some new documentation files
+ * URL cleanup in the documentation
+ * [Bug 657]: IP_MULTICAST_LOOP uses a u_char value/size
+ * quiet gcc4 complaints
+ * more Coverity fixes
+ * [Bug 614] manage file descriptors better
+ * [Bug 632] update kernel PPS offsets when PPS offset is re-configured
+ * [Bug 637] Ignore UP in*addr_any interfaces
+ * [Bug 633] Avoid writing files in srcdir
+ * release engineering/build changes
+
+---
+(4.2.2)
+
+ * SNTP
+ * Many bugfixes
+ * Implements the current "goal state" of NTPv4
+ * Autokey improvements
+ * Much better IPv6 support
+ * [Bug 360] ntpd loses handles with LAN connection disabled.
+ * [Bug 239] Fix intermittent autokey failure with multicast clients.
+ * Rewrite of the multicast code
+ * New version numbering scheme
+
+---
+(4.2.0)
+
+* More stuff than I have time to document
+* IPv6 support
+* Bugfixes
+* call-gap filtering
+* wwv and chu refclock improvements
+* OpenSSL integration
+
+---
+(4.1.2)
+
+* clock state machine bugfix
+* Lose the source port check on incoming packets
+* (x)ntpdc compatibility patch
+* Virtual IP improvements
+* ntp_loopfilter fixes and improvements
+* ntpdc improvements
+* GOES refclock fix
+* JJY driver
+* Jupiter refclock fixes
+* Neoclock4X refclock fixes
+* AIX 5 port
+* bsdi port fixes
+* Cray unicos port upgrade
+* HP MPE/iX port
+* Win/NT port upgrade
+* Dynix PTX port fixes
+* Document conversion from CVS to BK
+* readline support for ntpq
+
+---
+(4.1.0)
+
+* CERT problem fixed (99k23)
+
+* Huff-n-Puff filter
+* Preparation for OpenSSL support
+* Resolver changes/improvements are not backward compatible with mode 7
+  requests (which are implementation-specific anyway)
+* leap second stuff
+* manycast should work now
+* ntp-genkeys does new good things.
+* scripts/ntp-close
+* PPS cleanup and improvements
+* readline support for ntpdc
+* Crypto/authentication rewrite
+* WINNT builds with MD5 by default
+* WINNT no longer requires Perl for building with Visual C++ 6.0
+* algorithmic improvements, bugfixes
+* Solaris dosynctodr info update
+* html/pic/* is *lots* smaller
+* New/updated drivers: Forum Graphic GPS, WWV/H, Heath GC-100 II, HOPF
+  serial and PCI, ONCORE, ulink331
+* Rewrite of the audio drivers
+
+---
+(4.0.99)
+
+* Driver updates: CHU, DCF, GPS/VME, Oncore, PCF, Ulink, WWVB, burst
+  If you use the ONCORE driver with a HARDPPS kernel module,
+  you *must* have a properly specified:
+       pps <filename> [assert/clear] [hardpps]
+  line in the /etc/ntp.conf file.
+* PARSE cleanup
+* PPS cleanup
+* ntpd, ntpq, ntpdate cleanup and fixes
+* NT port improvements
+* AIX, BSDI, DEC OSF, FreeBSD, NetBSD, Reliant, SCO, Solaris port improvements
+
+---
+(4.0.98)
+
+* Solaris kernel FLL bug is fixed in 106541-07
+* Bug/lint cleanup
+* PPS cleanup
+* ReliantUNIX patches
+* NetInfo support
+* Ultralink driver
+* Trimble OEM Ace-II support
+* DCF77 power choices
+* Oncore improvements
+
+---
+(4.0.97)
+
+* NT patches
+* AIX,SunOS,IRIX portability
+* NeXT portability
+* ntptimeset utility added
+* cygwin portability patches
+
+---
+(4.0.96)
+
+* -lnsl, -lsocket, -lgen configuration patches
+* Y2K patches from AT&T
+* Linux portability cruft
+
+---
+(4.0.95)
+
+* NT port cleanup/replacement
+* a few portability fixes
+* VARITEXT Parse clock added
+
+---
+(4.0.94)
+
+* PPS updates (including ntp.config options)
+* Lose the old DES stuff in favor of the (optional) RSAREF stuff
+* html cleanup/updates
+* numerous drivers cleaned up
+* numerous portability patches and code cleanup
+
+---
+(4.0.93)
+
+* Oncore refclock needs PPS or one of two ioctls.
+* Don't make ntptime under Linux.  It doesn't compile for too many folks.
+* Autokey cleanup
+* ReliantUnix patches
+* html cleanup
+* tickadj cleanup
+* PARSE cleanup
+* IRIX -n32 cleanup
+* byte order cleanup
+* ntptrace improvements and patches
+* ntpdc improvements and patches
+* PPS cleanup
+* mx4200 cleanup
+* New clock state machine
+* SCO cleanup
+* Skip alias interfaces
+
+---
+(4.0.92)
+
+* chronolog and dumbclock refclocks
+* SCO updates
+* Cleanup/bugfixes
+* Y2K patches
+* Updated palisade driver
+* Plug memory leak
+* wharton kernel clock
+* Oncore clock upgrades
+* NMEA clock improvements
+* PPS improvements
+* AIX portability patches
+
+---
+(4.0.91)
+
+* New ONCORE driver
+* New MX4200 driver
+* Palisade improvements
+* config file bugfixes and problem reporting
+* autoconf upgrade and cleanup
+* HP-UX, IRIX lint cleanup
+* AIX portability patches
+* NT cleanup
+
+---
+(4.0.90)
+
+* Nanoseconds
+* New palisade driver
+* New Oncore driver
+
+---
+(4.0.73)
+
+* README.hackers added
+* PARSE driver is working again
+* Solaris 2.6 has nasty kernel bugs.  DO NOT enable pll!
+* DES is out of the distribution.
+
+---
+(4.0.72)
+
+* K&R C compiling should work again.
+* IRIG patches.
+* MX4200 driver patches.
+* Jupiter driver added.
+* Palisade driver added.  Needs work (ANSI, ntoh/hton, sizeof double, ???)
diff --git a/CommitLog b/CommitLog
new file mode 100644 (file)
index 0000000..ade3be7
--- /dev/null
+++ b/CommitLog
@@ -0,0 +1,25302 @@
+ChangeSet@1.1612, 2009-12-08 08:30:54-05:00, stenn@whimsy.udel.edu +1 -0
+  ChangeLog:
+    typo
+
+  ChangeLog@1.95, 2009-12-08 08:30:44-05:00, stenn@whimsy.udel.edu +0 -1
+    typo
+
+ChangeSet@1.1611, 2009-12-08 08:23:12-05:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P8
+  TAG: NTP_4_2_4P8
+
+  ChangeLog@1.94, 2009-12-08 08:23:01-05:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P8
+
+  ntpd/ntpd-opts.c@1.86, 2009-12-08 08:23:02-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  ntpd/ntpd-opts.h@1.86, 2009-12-08 08:23:02-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P8
+
+  ntpd/ntpd-opts.texi@1.85, 2009-12-08 08:23:03-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P8
+
+  ntpd/ntpd.1@1.84, 2009-12-08 08:23:03-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  ntpd/ntpdsim-opts.c@1.86, 2009-12-08 08:23:03-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  ntpd/ntpdsim-opts.h@1.86, 2009-12-08 08:23:04-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P8
+
+  ntpd/ntpdsim-opts.texi@1.84, 2009-12-08 08:23:05-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P8
+
+  ntpd/ntpdsim.1@1.84, 2009-12-08 08:23:05-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  ntpdc/ntpdc-opts.c@1.86, 2009-12-08 08:23:05-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  ntpdc/ntpdc-opts.h@1.86, 2009-12-08 08:23:05-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P8
+
+  ntpdc/ntpdc-opts.texi@1.84, 2009-12-08 08:23:06-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P8
+
+  ntpdc/ntpdc.1@1.84, 2009-12-08 08:23:06-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  ntpq/ntpq-opts.c@1.88, 2009-12-08 08:23:06-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  ntpq/ntpq-opts.h@1.88, 2009-12-08 08:23:06-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P8
+
+  ntpq/ntpq-opts.texi@1.85, 2009-12-08 08:23:07-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P8
+
+  ntpq/ntpq.1@1.84, 2009-12-08 08:23:07-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  packageinfo.sh@1.118, 2009-12-08 08:23:07-05:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P8
+
+  sntp/sntp-opts.c@1.84, 2009-12-08 08:23:07-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  sntp/sntp-opts.h@1.84, 2009-12-08 08:23:07-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P8
+
+  sntp/sntp-opts.texi@1.81, 2009-12-08 08:23:08-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P8
+
+  sntp/sntp.1@1.84, 2009-12-08 08:23:08-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  util/ntp-keygen-opts.c@1.85, 2009-12-08 08:23:08-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+  util/ntp-keygen-opts.h@1.85, 2009-12-08 08:23:08-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P8
+
+  util/ntp-keygen-opts.texi@1.83, 2009-12-08 08:23:09-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P8
+
+  util/ntp-keygen.1@1.83, 2009-12-08 08:23:09-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P8
+
+ChangeSet@1.1610, 2009-12-08 07:45:28-05:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P9_RC1
+  TAG: NTP_4_2_4P9_RC1
+
+  ChangeLog@1.93, 2009-12-08 07:45:19-05:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P9_RC1
+
+  ntpd/ntpd-opts.c@1.85, 2009-12-08 07:45:19-05:00, stenn@whimsy.udel.edu +5 -5
+    NTP_4_2_4P9_RC1
+
+  ntpd/ntpd-opts.h@1.85, 2009-12-08 07:45:19-05:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P9_RC1
+
+  ntpd/ntpd-opts.texi@1.84, 2009-12-08 07:45:20-05:00, stenn@whimsy.udel.edu +13 -6
+    NTP_4_2_4P9_RC1
+
+  ntpd/ntpd.1@1.83, 2009-12-08 07:45:20-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P9_RC1
+
+  ntpd/ntpdsim-opts.c@1.85, 2009-12-08 07:45:20-05:00, stenn@whimsy.udel.edu +5 -5
+    NTP_4_2_4P9_RC1
+
+  ntpd/ntpdsim-opts.h@1.85, 2009-12-08 07:45:20-05:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P9_RC1
+
+  ntpd/ntpdsim-opts.texi@1.83, 2009-12-08 07:45:21-05:00, stenn@whimsy.udel.edu +61 -2
+    NTP_4_2_4P9_RC1
+
+  ntpd/ntpdsim.1@1.83, 2009-12-08 07:45:21-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P9_RC1
+
+  ntpdc/ntpdc-opts.c@1.85, 2009-12-08 07:45:21-05:00, stenn@whimsy.udel.edu +5 -5
+    NTP_4_2_4P9_RC1
+
+  ntpdc/ntpdc-opts.h@1.85, 2009-12-08 07:45:21-05:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P9_RC1
+
+  ntpdc/ntpdc-opts.texi@1.83, 2009-12-08 07:45:21-05:00, stenn@whimsy.udel.edu +7 -4
+    NTP_4_2_4P9_RC1
+
+  ntpdc/ntpdc.1@1.83, 2009-12-08 07:45:22-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P9_RC1
+
+  ntpq/ntpq-opts.c@1.87, 2009-12-08 07:45:22-05:00, stenn@whimsy.udel.edu +5 -5
+    NTP_4_2_4P9_RC1
+
+  ntpq/ntpq-opts.h@1.87, 2009-12-08 07:45:22-05:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P9_RC1
+
+  ntpq/ntpq-opts.texi@1.84, 2009-12-08 07:45:22-05:00, stenn@whimsy.udel.edu +8 -4
+    NTP_4_2_4P9_RC1
+
+  ntpq/ntpq.1@1.83, 2009-12-08 07:45:23-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P9_RC1
+
+  packageinfo.sh@1.117, 2009-12-08 07:45:23-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P9_RC1
+
+  sntp/sntp-opts.c@1.83, 2009-12-08 07:45:23-05:00, stenn@whimsy.udel.edu +5 -5
+    NTP_4_2_4P9_RC1
+
+  sntp/sntp-opts.h@1.83, 2009-12-08 07:45:23-05:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P9_RC1
+
+  sntp/sntp-opts.texi@1.80, 2009-12-08 07:45:24-05:00, stenn@whimsy.udel.edu +54 -2
+    NTP_4_2_4P9_RC1
+
+  sntp/sntp.1@1.83, 2009-12-08 07:45:24-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P9_RC1
+
+  util/ntp-keygen-opts.c@1.84, 2009-12-08 07:45:24-05:00, stenn@whimsy.udel.edu +5 -5
+    NTP_4_2_4P9_RC1
+
+  util/ntp-keygen-opts.h@1.84, 2009-12-08 07:45:24-05:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P9_RC1
+
+  util/ntp-keygen-opts.texi@1.82, 2009-12-08 07:45:24-05:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P9_RC1
+
+  util/ntp-keygen.1@1.82, 2009-12-08 07:45:25-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P9_RC1
+
+ChangeSet@1.1609, 2009-12-08 05:36:47-05:00, stenn@whimsy.udel.edu +2 -0
+  [Sec 1331] DoS with mode 7 packets - CVE-2009-3563
+
+  NEWS@1.102, 2009-12-08 05:36:36-05:00, stenn@whimsy.udel.edu +34 -0
+    [Sec 1331] DoS with mode 7 packets - CVE-2009-3563
+
+  packageinfo.sh@1.116, 2009-12-08 05:36:36-05:00, stenn@whimsy.udel.edu +2 -2
+    [Sec 1331] DoS with mode 7 packets - CVE-2009-3563
+
+ChangeSet@1.1608, 2009-10-07 01:33:22+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+  [Sec 1331] DoS with mode 7 packets - CVE-2009-3563.
+
+  ChangeLog@1.92, 2009-10-07 01:33:21+00:00, davehart@shiny.ad.hartbrothers.com +4 -0
+    [Sec 1331] DoS with mode 7 packets - CVE-2009-3563.
+
+  ntpd/ntp_request.c@1.68, 2009-10-07 01:33:21+00:00, davehart@shiny.ad.hartbrothers.com +9 -2
+    [Sec 1331] DoS with mode 7 packets - CVE-2009-3563.
+
+ChangeSet@1.1607, 2009-05-18 05:04:41-04:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P7
+  TAG: NTP_4_2_4P7
+
+  ChangeLog@1.91, 2009-05-18 05:04:18-04:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P7
+
+  ntpd/ntpd-opts.c@1.84, 2009-05-18 05:04:19-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P7
+
+  ntpd/ntpd-opts.h@1.84, 2009-05-18 05:04:20-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P7
+
+  ntpd/ntpd-opts.texi@1.83, 2009-05-18 05:04:21-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7
+
+  ntpd/ntpd.1@1.82, 2009-05-18 05:04:22-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7
+
+  ntpd/ntpdsim-opts.c@1.84, 2009-05-18 05:04:22-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P7
+
+  ntpd/ntpdsim-opts.h@1.84, 2009-05-18 05:04:23-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P7
+
+  ntpd/ntpdsim-opts.texi@1.82, 2009-05-18 05:04:24-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7
+
+  ntpd/ntpdsim.1@1.82, 2009-05-18 05:04:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7
+
+  ntpdc/ntpdc-opts.c@1.84, 2009-05-18 05:04:26-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P7
+
+  ntpdc/ntpdc-opts.h@1.84, 2009-05-18 05:04:26-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P7
+
+  ntpdc/ntpdc-opts.texi@1.82, 2009-05-18 05:04:27-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7
+
+  ntpdc/ntpdc.1@1.82, 2009-05-18 05:04:28-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7
+
+  ntpq/ntpq-opts.c@1.86, 2009-05-18 05:04:29-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P7
+
+  ntpq/ntpq-opts.h@1.86, 2009-05-18 05:04:29-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P7
+
+  ntpq/ntpq-opts.texi@1.83, 2009-05-18 05:04:30-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7
+
+  ntpq/ntpq.1@1.82, 2009-05-18 05:04:31-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7
+
+  packageinfo.sh@1.115, 2009-05-18 05:04:32-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7
+
+  sntp/sntp-opts.c@1.82, 2009-05-18 05:04:32-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7
+
+  sntp/sntp-opts.h@1.82, 2009-05-18 05:04:33-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7
+
+  sntp/sntp-opts.texi@1.79, 2009-05-18 05:04:34-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7
+
+  sntp/sntp.1@1.82, 2009-05-18 05:04:34-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7
+
+  util/ntp-keygen-opts.c@1.83, 2009-05-18 05:04:35-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P7
+
+  util/ntp-keygen-opts.h@1.83, 2009-05-18 05:04:36-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P7
+
+  util/ntp-keygen-opts.texi@1.81, 2009-05-18 05:04:37-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7
+
+  util/ntp-keygen.1@1.81, 2009-05-18 05:04:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7
+
+ChangeSet@1.1606, 2009-05-18 03:14:59-04:00, stenn@whimsy.udel.edu +2 -0
+  4.2.4p7
+
+  NEWS@1.101, 2009-05-18 03:14:49-04:00, stenn@whimsy.udel.edu +38 -0
+    4.2.4p7
+
+  packageinfo.sh@1.114, 2009-05-18 03:14:50-04:00, stenn@whimsy.udel.edu +1 -1
+    4.2.4p7
+
+ChangeSet@1.1605, 2009-05-18 02:56:36-04:00, stenn@whimsy.udel.edu +2 -0
+  [Sec 1151] Remote exploit if autokey is enabled - CVE-2009-1252
+
+  ChangeLog@1.90, 2009-05-18 02:56:22-04:00, stenn@whimsy.udel.edu +1 -0
+    [Sec 1151] Remote exploit if autokey is enabled - CVE-2009-1252
+
+  ntpd/ntp_crypto.c@1.110, 2009-05-18 02:56:22-04:00, stenn@whimsy.udel.edu +22 -17
+    [Sec 1151] Remote exploit if autokey is enabled - CVE-2009-1252
+
+ChangeSet@1.1604, 2009-05-18 02:24:31-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 1187] Update the copyright date.
+
+  ChangeLog@1.89, 2009-05-18 02:24:21-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 1187] Update the copyright date.
+
+  include/copyright.def@1.8, 2009-05-18 02:24:22-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 1187] Update the copyright date.
+
+ChangeSet@1.1603, 2009-05-17 08:59:06+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+  [Bug 1191] ntpd fails on Win2000 - "Address already in use" after fix
+  for [Sec 1149].
+
+  ChangeLog@1.88, 2009-05-17 08:59:05+00:00, davehart@shiny.ad.hartbrothers.com +5 -0
+    [Bug 1191] ntpd fails on Win2000 - "Address already in use" after fix
+    for [Sec 1149].
+
+  ntpd/ntp_io.c@1.261, 2009-05-17 08:59:05+00:00, davehart@shiny.ad.hartbrothers.com +45 -34
+    [Bug 1191] ntpd fails on Win2000 - "Address already in use" after fix
+    for [Sec 1149].
+
+ChangeSet@1.1602, 2009-05-14 04:42:10+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  fix error from BitKeeper/triggers/pre-resolve.licfix triggered (ahem)
+  by recent BitKeeper/etc/config delta updating repologs email address
+
+  BitKeeper/triggers/pre-resolve.licfix@1.5, 2009-05-14 04:42:09+00:00, davehart@shiny.ad.hartbrothers.com +4 -1
+    bk sccscat has been removed, replaced by bk annotate -R
+    -q grep -> grep -q (untested until recent BitKeeper/etc/config commit
+    changing repologs@ntp.isc.org to repologs@ntp.org
+
+ChangeSet@1.1601, 2009-05-12 02:41:56-04:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P7_RC7
+  TAG: NTP_4_2_4P7_RC7
+
+  ChangeLog@1.87, 2009-05-12 02:41:33-04:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P7_RC7
+
+  ntpd/ntpd-opts.c@1.83, 2009-05-12 02:41:33-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpd/ntpd-opts.h@1.83, 2009-05-12 02:41:33-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpd/ntpd-opts.texi@1.82, 2009-05-12 02:41:35-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC7
+
+  ntpd/ntpd.1@1.81, 2009-05-12 02:41:35-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpd/ntpdsim-opts.c@1.83, 2009-05-12 02:41:36-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpd/ntpdsim-opts.h@1.83, 2009-05-12 02:41:37-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpd/ntpdsim-opts.texi@1.81, 2009-05-12 02:41:37-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC7
+
+  ntpd/ntpdsim.1@1.81, 2009-05-12 02:41:38-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpdc/ntpdc-opts.c@1.83, 2009-05-12 02:41:39-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpdc/ntpdc-opts.h@1.83, 2009-05-12 02:41:40-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpdc/ntpdc-opts.texi@1.81, 2009-05-12 02:41:41-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC7
+
+  ntpdc/ntpdc.1@1.81, 2009-05-12 02:41:42-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpq/ntpq-opts.c@1.85, 2009-05-12 02:41:43-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpq/ntpq-opts.h@1.85, 2009-05-12 02:41:44-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  ntpq/ntpq-opts.texi@1.82, 2009-05-12 02:41:45-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC7
+
+  ntpq/ntpq.1@1.81, 2009-05-12 02:41:46-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  packageinfo.sh@1.113, 2009-05-12 02:41:47-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC7
+
+  sntp/sntp-opts.c@1.81, 2009-05-12 02:41:47-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  sntp/sntp-opts.h@1.81, 2009-05-12 02:41:48-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  sntp/sntp-opts.texi@1.78, 2009-05-12 02:41:49-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC7
+
+  sntp/sntp.1@1.81, 2009-05-12 02:41:50-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  util/ntp-keygen-opts.c@1.82, 2009-05-12 02:41:51-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  util/ntp-keygen-opts.h@1.82, 2009-05-12 02:41:51-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+  util/ntp-keygen-opts.texi@1.80, 2009-05-12 02:41:52-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC7
+
+  util/ntp-keygen.1@1.80, 2009-05-12 02:41:53-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC7
+
+ChangeSet@1.1600, 2009-05-12 01:07:37-04:00, stenn@whimsy.udel.edu +9 -0
+  ntp.isc.org -> ntp.org cleanup
+
+  BitKeeper/etc/config@1.10, 2009-05-12 01:06:49-04:00, stenn@whimsy.udel.edu +1 -1
+    ntp.isc.org -> ntp.org cleanup
+
+  ChangeLog@1.86, 2009-05-12 01:06:01-04:00, stenn@whimsy.udel.edu +1 -0
+    ntp.isc.org -> ntp.org cleanup
+
+  README@1.23, 2009-05-12 01:06:02-04:00, stenn@whimsy.udel.edu +1 -1
+    ntp.isc.org -> ntp.org cleanup
+
+  README.bk@1.19, 2009-05-12 01:06:03-04:00, stenn@whimsy.udel.edu +1 -1
+    ntp.isc.org -> ntp.org cleanup
+
+  README.patches@1.4, 2009-05-12 01:06:03-04:00, stenn@whimsy.udel.edu +1 -1
+    ntp.isc.org -> ntp.org cleanup
+
+  WHERE-TO-START@1.7, 2009-05-12 01:06:03-04:00, stenn@whimsy.udel.edu +1 -1
+    ntp.isc.org -> ntp.org cleanup
+
+  configure.ac@1.418, 2009-05-12 01:06:04-04:00, stenn@whimsy.udel.edu +1 -1
+    ntp.isc.org -> ntp.org cleanup
+
+  include/copyright.def@1.7, 2009-05-12 01:06:49-04:00, stenn@whimsy.udel.edu +1 -1
+    ntp.isc.org -> ntp.org cleanup
+
+  sntp/sntp-opts.def@1.11, 2009-05-12 01:06:49-04:00, stenn@whimsy.udel.edu +1 -1
+    ntp.isc.org -> ntp.org cleanup
+
+ChangeSet@1.1597.1.1, 2009-05-08 18:11:36+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  configure.ac:
+    correct help text
+
+  configure.ac@1.415.1.1, 2009-05-08 18:11:24+00:00, davehart@shiny.ad.hartbrothers.com +11 -5
+    correct help text
+
+ChangeSet@1.1598, 2009-05-08 17:50:37+00:00, davehart@shiny.ad.hartbrothers.com +3 -0
+  add configure --enable-ignore-dns-errors to retry on any failure
+
+  ChangeLog@1.85, 2009-05-08 17:50:35+00:00, davehart@shiny.ad.hartbrothers.com +2 -1
+    add configure --enable-ignore-dns-errors to retry on any failure
+
+  configure.ac@1.416, 2009-05-08 17:50:35+00:00, davehart@shiny.ad.hartbrothers.com +26 -4
+    add configure --enable-ignore-dns-errors to retry on any failure
+
+  ntpd/ntp_intres.c@1.55, 2009-05-08 17:50:35+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+    add configure --enable-ignore-dns-errors to retry on any failure
+
+ChangeSet@1.1597, 2009-05-08 15:34:46+00:00, davehart@shiny.ad.hartbrothers.com +4 -0
+  Do not exceed FD_SETSIZE in ntp_intres.c
+  ---
+  ntp_intres.c:
+    typo
+  ---
+  ntp_intres.c:
+    missing comma typo
+  ---
+  ntp_intres.c:
+    typo
+
+  ntpd/ntp_intres.c@1.54, 2009-05-08 15:34:45+00:00, davehart@shiny.ad.hartbrothers.com +64 -33
+    fix typos, refine "host name not found" log message, stay under FD_SETSIZE
+
+  ntpd/ntp_request.c@1.67, 2009-05-08 15:34:45+00:00, davehart@shiny.ad.hartbrothers.com +21 -3
+    after ntp_intres adds a server entry, rescan interfaces, to notice the
+    return of connectivity sooner.
+
+  ntpd/ntp_timer.c@1.34, 2009-05-08 15:34:45+00:00, davehart@shiny.ad.hartbrothers.com +3 -5
+    indent cleanup
+
+  ports/winnt/include/config.h@1.52, 2009-05-08 15:34:45+00:00, davehart@shiny.ad.hartbrothers.com +4 -10
+    remove FORCE_DNSRETRY, no longer used
+    indent cleanup
+
+ChangeSet@1.1587.1.1, 2009-05-08 11:24:43+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+  [Bug 1178] Use prior FORCE_DNSRETRY behavior as needed at runtime
+
+  ChangeLog@1.76.1.1, 2009-05-08 11:24:42+00:00, davehart@shiny.ad.hartbrothers.com +4 -0
+    [Bug 1178] Use prior FORCE_DNSRETRY behavior as needed at runtime
+
+  ntpd/ntp_intres.c@1.53, 2009-05-08 11:24:42+00:00, davehart@shiny.ad.hartbrothers.com +53 -55
+    [Bug 1178] Use prior FORCE_DNSRETRY behavior as needed at runtime
+
+ChangeSet@1.1595, 2009-05-08 04:42:52-04:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P7_RC6
+  TAG: NTP_4_2_4P7_RC6
+
+  ChangeLog@1.83, 2009-05-08 04:42:28-04:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P7_RC6
+
+  ntpd/ntpd-opts.c@1.82, 2009-05-08 04:42:28-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  ntpd/ntpd-opts.h@1.82, 2009-05-08 04:42:29-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC6
+
+  ntpd/ntpd-opts.texi@1.81, 2009-05-08 04:42:30-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  ntpd/ntpd.1@1.80, 2009-05-08 04:42:30-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  ntpd/ntpdsim-opts.c@1.82, 2009-05-08 04:42:31-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  ntpd/ntpdsim-opts.h@1.82, 2009-05-08 04:42:32-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC6
+
+  ntpd/ntpdsim-opts.texi@1.80, 2009-05-08 04:42:33-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC6
+
+  ntpd/ntpdsim.1@1.80, 2009-05-08 04:42:34-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  ntpdc/ntpdc-opts.c@1.82, 2009-05-08 04:42:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  ntpdc/ntpdc-opts.h@1.82, 2009-05-08 04:42:35-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC6
+
+  ntpdc/ntpdc-opts.texi@1.80, 2009-05-08 04:42:36-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  ntpdc/ntpdc.1@1.80, 2009-05-08 04:42:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  ntpq/ntpq-opts.c@1.84, 2009-05-08 04:42:38-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  ntpq/ntpq-opts.h@1.84, 2009-05-08 04:42:39-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC6
+
+  ntpq/ntpq-opts.texi@1.81, 2009-05-08 04:42:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  ntpq/ntpq.1@1.80, 2009-05-08 04:42:41-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  packageinfo.sh@1.112, 2009-05-08 04:42:42-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC6
+
+  sntp/sntp-opts.c@1.80, 2009-05-08 04:42:43-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  sntp/sntp-opts.h@1.80, 2009-05-08 04:42:43-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC6
+
+  sntp/sntp-opts.texi@1.77, 2009-05-08 04:42:44-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC6
+
+  sntp/sntp.1@1.80, 2009-05-08 04:42:44-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  util/ntp-keygen-opts.c@1.81, 2009-05-08 04:42:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  util/ntp-keygen-opts.h@1.81, 2009-05-08 04:42:46-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC6
+
+  util/ntp-keygen-opts.texi@1.79, 2009-05-08 04:42:47-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+  util/ntp-keygen.1@1.79, 2009-05-08 04:42:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC6
+
+ChangeSet@1.1594, 2009-05-08 03:29:16-04:00, stenn@pogo.udel.edu +1 -0
+  typo
+
+  ChangeLog@1.82, 2009-05-08 03:28:46-04:00, stenn@pogo.udel.edu +1 -1
+    typo
+
+ChangeSet@1.1593, 2009-05-08 02:13:17+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  Add [Bug 1071] reference to ChangeLog entry
+
+  ChangeLog@1.81, 2009-05-08 02:13:16+00:00, davehart@shiny.ad.hartbrothers.com +2 -2
+    [Bug 1071] Log a message and exit before trying to use FD_SET with a
+    descriptor larger than FD_SETSIZE, which will corrupt memory
+    (adds reference to 1071 to existing description)
+
+ChangeSet@1.1592, 2009-05-08 01:23:43+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+  [Bug 1179] error messages for -u/--user and -i when built w/o droproot
+
+  ChangeLog@1.80, 2009-05-08 01:23:41+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+    [Bug 1179] error messages for -u/--user and -i when built w/o droproot
+
+  ntpd/cmd_args.c@1.49, 2009-05-08 01:23:41+00:00, davehart@shiny.ad.hartbrothers.com +39 -19
+     descriptive error messages for -u/--user and -i without droproot
+
+ChangeSet@1.1591, 2009-05-07 22:15:41+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+  ntp_io.c: do not use FD_SET beyond FD_SETSIZE, watch for corruption of inter_list.head
+
+  ChangeLog@1.79, 2009-05-07 22:15:39+00:00, davehart@shiny.ad.hartbrothers.com +3 -0
+    do not use FD_SET beyond FD_SETSIZE, watch for corruption of inter_list.head
+
+  ntpd/ntp_io.c@1.260, 2009-05-07 22:15:39+00:00, davehart@shiny.ad.hartbrothers.com +23 -0
+    do not use FD_SET beyond FD_SETSIZE, watch for corruption of inter_list.head
+
+ChangeSet@1.1590, 2009-05-07 07:39:41+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  refclock_jjy.c:
+    add missing newline before EOF
+
+  ntpd/refclock_jjy.c@1.15, 2009-05-07 07:39:32+00:00, davehart@shiny.ad.hartbrothers.com +1 -1
+    add missing newline before EOF
+
+ChangeSet@1.1589, 2009-05-07 05:19:36+00:00, davehart@shiny.ad.hartbrothers.com +3 -0
+  [Bug 784] Make --enable-linuxcaps the default when available
+  add reference to refclock_jjy.c to ports/winnt/ntpd/ntpd.vcproj
+
+  ChangeLog@1.78, 2009-05-07 05:19:34+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+    [Bug 784] Make --enable-linuxcaps the default when available
+
+  configure.ac@1.415, 2009-05-07 05:19:34+00:00, davehart@shiny.ad.hartbrothers.com +34 -33
+    [Bug 784] Make --enable-linuxcaps the default when available
+
+  ports/winnt/ntpd/ntpd.vcproj@1.2, 2009-05-07 05:19:34+00:00, davehart@shiny.ad.hartbrothers.com +4 -0
+    add reference to refclock_jjy.c to ports/winnt/ntpd/ntpd.vcproj
+
+ChangeSet@1.1588, 2009-05-07 05:10:54+00:00, davehart@shiny.ad.hartbrothers.com +4 -0
+  Updated JJY reference clock driver from Takao abe
+  Make ntpd the default project in Visual C++/Visual Studio
+
+  ChangeLog@1.77, 2009-05-07 05:10:52+00:00, davehart@shiny.ad.hartbrothers.com +4 -0
+    Updated JJY reference clock driver from Takao abe
+
+  html/drivers/driver40.html@1.14, 2009-05-07 05:10:52+00:00, davehart@shiny.ad.hartbrothers.com +103 -48
+    Updated JJY reference clock driver from Takao abe
+
+  ntpd/refclock_jjy.c@1.14, 2009-05-07 05:10:52+00:00, davehart@shiny.ad.hartbrothers.com +153 -5
+    Updated JJY reference clock driver from Takao abe
+
+  ports/winnt/ntp.sln@1.2, 2009-05-07 05:10:53+00:00, davehart@shiny.ad.hartbrothers.com +4 -4
+    Make ntpd the default project in Visual C++/Visual Studio
+
+ChangeSet@1.1587, 2009-05-02 02:38:49-04:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P7_RC5
+  TAG: NTP_4_2_4P7_RC5
+
+  ChangeLog@1.76, 2009-05-02 02:38:22-04:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P7_RC5
+
+  ntpd/ntpd-opts.c@1.81, 2009-05-02 02:38:24-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  ntpd/ntpd-opts.h@1.81, 2009-05-02 02:38:25-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC5
+
+  ntpd/ntpd-opts.texi@1.80, 2009-05-02 02:38:27-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC5
+
+  ntpd/ntpd.1@1.79, 2009-05-02 02:38:28-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  ntpd/ntpdsim-opts.c@1.81, 2009-05-02 02:38:28-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  ntpd/ntpdsim-opts.h@1.81, 2009-05-02 02:38:29-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC5
+
+  ntpd/ntpdsim-opts.texi@1.79, 2009-05-02 02:38:30-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC5
+
+  ntpd/ntpdsim.1@1.79, 2009-05-02 02:38:31-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  ntpdc/ntpdc-opts.c@1.81, 2009-05-02 02:38:31-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  ntpdc/ntpdc-opts.h@1.81, 2009-05-02 02:38:32-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC5
+
+  ntpdc/ntpdc-opts.texi@1.79, 2009-05-02 02:38:33-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC5
+
+  ntpdc/ntpdc.1@1.79, 2009-05-02 02:38:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  ntpq/ntpq-opts.c@1.83, 2009-05-02 02:38:34-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  ntpq/ntpq-opts.h@1.83, 2009-05-02 02:38:35-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC5
+
+  ntpq/ntpq-opts.texi@1.80, 2009-05-02 02:38:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC5
+
+  ntpq/ntpq.1@1.79, 2009-05-02 02:38:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  packageinfo.sh@1.111, 2009-05-02 02:38:38-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC5
+
+  sntp/sntp-opts.c@1.79, 2009-05-02 02:38:39-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  sntp/sntp-opts.h@1.79, 2009-05-02 02:38:40-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC5
+
+  sntp/sntp-opts.texi@1.76, 2009-05-02 02:38:41-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC5
+
+  sntp/sntp.1@1.79, 2009-05-02 02:38:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  util/ntp-keygen-opts.c@1.80, 2009-05-02 02:38:43-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+  util/ntp-keygen-opts.h@1.80, 2009-05-02 02:38:43-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC5
+
+  util/ntp-keygen-opts.texi@1.78, 2009-05-02 02:38:44-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC5
+
+  util/ntp-keygen.1@1.78, 2009-05-02 02:38:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC5
+
+ChangeSet@1.1586, 2009-05-02 01:49:02+00:00, davehart@shiny.ad.hartbrothers.com +3 -0
+  flock-build:
+    set -m wasn't needed with ssh -tt and caused problems, remove
+  ChangeLog:
+    [Bug 1172] 4.2.4p7-RC{3,4} fail to build on linux.
+    remove unportable 'set -m' from flock-build script
+  configure.ac:
+    reverse accidental backport from -dev of struct rtattr test in
+    configure.ac without corresponding ntp_io.c code for HAVE_RTNETLINK
+
+  ChangeLog@1.75, 2009-05-02 01:48:30+00:00, davehart@shiny.ad.hartbrothers.com +5 -0
+    [Bug 1172] 4.2.4p7-RC{3,4} fail to build on linux.
+    remove unportable 'set -m' from flock-build script
+
+  configure.ac@1.414, 2009-05-02 01:48:30+00:00, davehart@shiny.ad.hartbrothers.com +1 -12
+    reverse accidental backport from -dev of struct rtattr test in
+    configure.ac without corresponding ntp_io.c code for HAVE_RTNETLINK
+
+  flock-build@1.41, 2009-05-02 01:48:30+00:00, davehart@shiny.ad.hartbrothers.com +3 -5
+    set -m wasn't needed with ssh -tt and caused problems, remove
+
+ChangeSet@1.1585, 2009-04-29 04:03:41-04:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P7_RC4
+  TAG: NTP_4_2_4P7_RC4
+
+  ChangeLog@1.74, 2009-04-29 04:03:17-04:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P7_RC4
+
+  ntpd/ntpd-opts.c@1.80, 2009-04-29 04:03:18-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  ntpd/ntpd-opts.h@1.80, 2009-04-29 04:03:19-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC4
+
+  ntpd/ntpd-opts.texi@1.79, 2009-04-29 04:03:21-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC4
+
+  ntpd/ntpd.1@1.78, 2009-04-29 04:03:21-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  ntpd/ntpdsim-opts.c@1.80, 2009-04-29 04:03:22-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  ntpd/ntpdsim-opts.h@1.80, 2009-04-29 04:03:22-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC4
+
+  ntpd/ntpdsim-opts.texi@1.78, 2009-04-29 04:03:24-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC4
+
+  ntpd/ntpdsim.1@1.78, 2009-04-29 04:03:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  ntpdc/ntpdc-opts.c@1.80, 2009-04-29 04:03:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  ntpdc/ntpdc-opts.h@1.80, 2009-04-29 04:03:26-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC4
+
+  ntpdc/ntpdc-opts.texi@1.78, 2009-04-29 04:03:27-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC4
+
+  ntpdc/ntpdc.1@1.78, 2009-04-29 04:03:28-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  ntpq/ntpq-opts.c@1.82, 2009-04-29 04:03:29-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  ntpq/ntpq-opts.h@1.82, 2009-04-29 04:03:29-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC4
+
+  ntpq/ntpq-opts.texi@1.79, 2009-04-29 04:03:30-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC4
+
+  ntpq/ntpq.1@1.78, 2009-04-29 04:03:31-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  packageinfo.sh@1.110, 2009-04-29 04:03:31-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC4
+
+  sntp/sntp-opts.c@1.78, 2009-04-29 04:03:32-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  sntp/sntp-opts.h@1.78, 2009-04-29 04:03:33-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC4
+
+  sntp/sntp-opts.texi@1.75, 2009-04-29 04:03:34-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC4
+
+  sntp/sntp.1@1.78, 2009-04-29 04:03:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  util/ntp-keygen-opts.c@1.79, 2009-04-29 04:03:36-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+  util/ntp-keygen-opts.h@1.79, 2009-04-29 04:03:36-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC4
+
+  util/ntp-keygen-opts.texi@1.77, 2009-04-29 04:03:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC4
+
+  util/ntp-keygen.1@1.77, 2009-04-29 04:03:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC4
+
+ChangeSet@1.1584, 2009-04-29 01:50:44-04:00, stenn@pogo.udel.edu +1 -0
+  No need to know the GCC -W items in config.h
+
+  configure.ac@1.413, 2009-04-29 01:50:36-04:00, stenn@pogo.udel.edu +2 -12
+    No need to know the GCC -W items in config.h
+
+ChangeSet@1.1583, 2009-04-27 11:47:49+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  ChangeLog:
+    add [Bug 1167] to ChangeLog entry
+
+  ChangeLog@1.73, 2009-04-27 11:47:36+00:00, davehart@shiny.ad.hartbrothers.com +1 -1
+    add [Bug 1167] to ChangeLog entry
+
+ChangeSet@1.1582, 2009-04-26 06:10:27+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+  gcc -Winit-self is used only if it is understood
+
+  ChangeLog@1.72, 2009-04-26 06:10:25+00:00, davehart@shiny.ad.hartbrothers.com +4 -0
+    gcc -Winit-self is used only if it is understood
+
+  configure.ac@1.412, 2009-04-26 06:10:26+00:00, davehart@shiny.ad.hartbrothers.com +34 -2
+    gcc -Winit-self is used only if it is understood
+
+ChangeSet@1.1581, 2009-04-22 08:18:29-04:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P7_RC3
+  TAG: NTP_4_2_4P7_RC3
+
+  ChangeLog@1.71, 2009-04-22 08:18:04-04:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P7_RC3
+
+  ntpd/ntpd-opts.c@1.79, 2009-04-22 08:18:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  ntpd/ntpd-opts.h@1.79, 2009-04-22 08:18:05-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC3
+
+  ntpd/ntpd-opts.texi@1.78, 2009-04-22 08:18:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  ntpd/ntpd.1@1.77, 2009-04-22 08:18:07-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  ntpd/ntpdsim-opts.c@1.79, 2009-04-22 08:18:08-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  ntpd/ntpdsim-opts.h@1.79, 2009-04-22 08:18:08-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC3
+
+  ntpd/ntpdsim-opts.texi@1.77, 2009-04-22 08:18:09-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC3
+
+  ntpd/ntpdsim.1@1.77, 2009-04-22 08:18:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  ntpdc/ntpdc-opts.c@1.79, 2009-04-22 08:18:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  ntpdc/ntpdc-opts.h@1.79, 2009-04-22 08:18:11-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC3
+
+  ntpdc/ntpdc-opts.texi@1.77, 2009-04-22 08:18:12-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  ntpdc/ntpdc.1@1.77, 2009-04-22 08:18:13-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  ntpq/ntpq-opts.c@1.81, 2009-04-22 08:18:13-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  ntpq/ntpq-opts.h@1.81, 2009-04-22 08:18:14-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC3
+
+  ntpq/ntpq-opts.texi@1.78, 2009-04-22 08:18:15-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  ntpq/ntpq.1@1.77, 2009-04-22 08:18:16-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  packageinfo.sh@1.109, 2009-04-22 08:18:17-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC3
+
+  sntp/sntp-opts.c@1.77, 2009-04-22 08:18:19-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  sntp/sntp-opts.h@1.77, 2009-04-22 08:18:20-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC3
+
+  sntp/sntp-opts.texi@1.74, 2009-04-22 08:18:20-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC3
+
+  sntp/sntp.1@1.77, 2009-04-22 08:18:22-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  util/ntp-keygen-opts.c@1.78, 2009-04-22 08:18:23-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  util/ntp-keygen-opts.h@1.78, 2009-04-22 08:18:23-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC3
+
+  util/ntp-keygen-opts.texi@1.76, 2009-04-22 08:18:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+  util/ntp-keygen.1@1.76, 2009-04-22 08:18:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC3
+
+ChangeSet@1.1580, 2009-04-22 07:00:20-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 1155] Fix compile problem on Windows with VS2005
+
+  ChangeLog@1.70, 2009-04-22 07:00:11-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 1155] Fix compile problem on Windows with VS2005
+
+ChangeSet@1.1579, 2009-04-22 06:06:53-04:00, stenn@whimsy.udel.edu +1 -0
+  Cleanup
+
+  ChangeLog@1.69, 2009-04-22 06:06:44-04:00, stenn@whimsy.udel.edu +4 -2
+    Cleanup
+
+ChangeSet@1.1578, 2009-04-20 22:55:13+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  ChangeLog:
+    auto merge not quite right
+
+  ChangeLog@1.68, 2009-04-20 22:55:10+00:00, davehart@shiny.ad.hartbrothers.com +3 -7
+    auto merge not quite right
+
+ChangeSet@1.1577, 2009-04-20 22:42:59+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  ntp_iocompletionport.c:
+    revert overlooked CreateEvent naming/sharing change not conditionalized away already
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.32, 2009-04-20 22:42:50+00:00, davehart@shiny.ad.hartbrothers.com +2 -2
+    revert overlooked CreateEvent naming/sharing change not conditionalized away already
+
+ChangeSet@1.1567.1.11, 2009-04-20 06:17:21+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  ChangeLog:
+    [Bug 1160] Mac OS X is like BSD regarding F_SETOWN
+
+  ChangeLog@1.64.1.3, 2009-04-20 06:17:15+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+    [Bug 1160] Mac OS X is like BSD regarding F_SETOWN
+
+ChangeSet@1.1567.1.10, 2009-04-20 06:02:20+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  configure.ac:
+    [Bug 1160] MacOS X is like BSD regarding F_SETOWN
+
+  configure.ac@1.411, 2009-04-20 06:02:08+00:00, davehart@shiny.ad.hartbrothers.com +3 -0
+    [Bug 1160] MacOS X is like BSD regarding F_SETOWN
+
+ChangeSet@1.1567.1.9, 2009-04-16 02:39:01+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  configure.ac:
+    fix for --enable-ntp-signd=/my/path
+
+  configure.ac@1.410, 2009-04-16 02:38:53+00:00, davehart@shiny.ad.hartbrothers.com +1 -1
+    fix for --enable-ntp-signd=/my/path
+
+ChangeSet@1.1567.1.8, 2009-04-15 12:36:24+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  configure.ac:
+    do not cache options fix
+
+  configure.ac@1.409, 2009-04-15 12:36:12+00:00, davehart@shiny.ad.hartbrothers.com +1 -1
+    do not cache options fix
+
+ChangeSet@1.1567.1.7, 2009-04-15 10:43:51+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  configure.ac:
+    Do not cache configure --options, only current values matter
+    Default --enable-wintime when --enable-ntp-signd
+
+  configure.ac@1.408, 2009-04-15 10:43:32+00:00, davehart@shiny.ad.hartbrothers.com +575 -403
+    Do not cache configure --options, only current values matter
+    Default --enable-wintime when --enable-ntp-signd
+
+ChangeSet@1.1567.1.6, 2009-04-15 01:32:33+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+  use AC_SEARCH_LIBS to avoid problems with sntp
+
+  configure.ac@1.407, 2009-04-15 01:30:56+00:00, davehart@shiny.ad.hartbrothers.com +12 -20
+    use AC_SEARCH_LIBS in preference to AC_CHECK_LIB particulary for sockets, use AM_PROG_CC_C_O which supersets prior AC_PROG_CC_C_O
+
+  sntp/configure.ac@1.17, 2009-04-15 01:28:22+00:00, davehart@shiny.ad.hartbrothers.com +4 -4
+    use AC_SEARCH_LIBS which is recommended particularly for sockets over the older AC_CHECK_LIB
+
+ChangeSet@1.1567.1.5, 2009-04-14 13:47:29+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  configure.ac:
+    tear off sntp/configure.ac from configure.ac
+
+  configure.ac@1.406, 2009-04-14 13:46:17+00:00, davehart@shiny.ad.hartbrothers.com +6 -1
+    tear off sntp/configure.ac from configure.ac
+
+ChangeSet@1.1575, 2009-04-14 07:55:41-04:00, mayer@pogo.udel.edu +1 -0
+  Added fix for Bug 813
+
+  ChangeLog@1.66, 2009-04-14 07:55:31-04:00, mayer@pogo.udel.edu +1 -0
+    Added fix for Bug 813
+
+ChangeSet@1.1574, 2009-04-14 07:51:41-04:00, mayer@pogo.udel.edu +1 -0
+  [Bug 813] Conditional naming of Event
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.31, 2009-04-14 07:51:14-04:00, mayer@pogo.udel.edu +7 -1
+    [Bug 813] Conditional naming of Event
+
+ChangeSet@1.1567.1.4, 2009-04-14 05:21:17+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  configure.ac:
+    use unset for tickadj utility test fix
+
+  configure.ac@1.405, 2009-04-14 05:21:15+00:00, davehart@shiny.ad.hartbrothers.com +1 -1
+    use unset for tickadj utility test fix
+
+ChangeSet@1.1567.1.3, 2009-04-14 02:59:39+00:00, hart@pogo.udel.edu +1 -0
+  build:
+    do not require nice
+
+  build@1.26, 2009-04-14 02:59:20+00:00, hart@pogo.udel.edu +21 -4
+    do not require nice
+
+ChangeSet@1.1567.1.2, 2009-04-14 01:33:01+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+  configure.ac, ChangeLog:
+    [Bug 1158] support for aix6.1
+
+  ChangeLog@1.64.1.2, 2009-04-14 01:33:00+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+    [Bug 1158] support for aix6.1
+
+  configure.ac@1.404, 2009-04-14 01:33:00+00:00, davehart@shiny.ad.hartbrothers.com +8 -8
+    [Bug 1158] support for aix6.1
+
+ChangeSet@1.1567.1.1, 2009-04-14 01:28:08+00:00, davehart@shiny.ad.hartbrothers.com +5 -0
+  [Bug 1157] quiet OpenSSL warnings, clean up configure.ac
+  make flock-build quit before causing harm if another has not completed
+  
+
+  ChangeLog@1.64.1.1, 2009-04-14 01:28:06+00:00, davehart@shiny.ad.hartbrothers.com +4 -0
+    [Bug 1157] quiet OpenSSL warnings, clean up configure.ac
+
+  build@1.25, 2009-04-14 01:28:07+00:00, davehart@shiny.ad.hartbrothers.com +6 -7
+    prevent multiple flock-builds from stepping on each others work
+
+  configure.ac@1.403, 2009-04-14 01:28:07+00:00, davehart@shiny.ad.hartbrothers.com +613 -361
+    [Bug 1157] quiet OpenSSL warnings, configure.ac cleanup
+
+  flock-build@1.40, 2009-04-14 01:28:07+00:00, davehart@shiny.ad.hartbrothers.com +76 -20
+    prevent multiple flock-builds from stepping on each others work
+
+  sntp/configure.ac@1.16, 2009-04-14 01:28:07+00:00, davehart@shiny.ad.hartbrothers.com +14 -0
+    bring in line with -dev to ease merges, no functional change
+
+ChangeSet@1.1573, 2009-04-13 00:00:55-04:00, mayer@pogo.udel.edu +1 -0
+  Forgot the _WIN32_WINNT update
+
+  ports/winnt/include/config.h@1.51, 2009-04-13 00:00:24-04:00, mayer@pogo.udel.edu +10 -23
+    Forgot the _WIN32_WINNT update
+
+ChangeSet@1.1572, 2009-04-12 00:55:24-04:00, mayer@pogo.udel.edu +1 -0
+  Windows bug fixes
+
+  ChangeLog@1.65, 2009-04-12 00:54:43-04:00, mayer@pogo.udel.edu +7 -2
+    Windows bug fixes
+
+ChangeSet@1.1571, 2009-04-12 00:45:48-04:00, mayer@pogo.udel.edu +2 -0
+  [Bug 1156] lock_thread_to_processor() should be declared in header
+
+  ports/winnt/include/clockstuff.h@1.8, 2009-04-12 00:45:09-04:00, mayer@pogo.udel.edu +1 -0
+    [Bug 1156] lock_thread_to_processor() should be declared in header
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.25, 2009-04-12 00:45:09-04:00, mayer@pogo.udel.edu +0 -1
+    [Bug 1156] lock_thread_to_processor() should be declared in header
+
+ChangeSet@1.1570, 2009-04-12 00:38:47-04:00, mayer@pogo.udel.edu +1 -0
+  [Bug 1147] System errors should be logged to msyslog()
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.30, 2009-04-12 00:38:08-04:00, mayer@pogo.udel.edu +17 -14
+    [Bug 1147] System errors should be logged to msyslog()
+
+ChangeSet@1.1569, 2009-04-12 00:34:41-04:00, mayer@pogo.udel.edu +1 -0
+  [Bug 1155] Wrong header included in config.h. Should have been winsock2.h
+
+  ports/winnt/include/config.h@1.50, 2009-04-12 00:34:10-04:00, mayer@pogo.udel.edu +1 -2
+    [Bug 1155] Wrong header included in config.h. Should have been winsock2.h
+
+ChangeSet@1.1568, 2009-04-12 00:32:25-04:00, mayer@pogo.udel.edu +1 -0
+  [Bug 787] Bug fixes for 64-bit time_t on Windows
+
+  ports/winnt/libntp/SetSystemTime.c@1.4, 2009-04-12 00:30:42-04:00, mayer@pogo.udel.edu +2 -2
+    [Bug 787] Bug fixes for 64-bit time_t on Windows
+
+ChangeSet@1.1567, 2009-04-09 07:44:06-04:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P7_RC2
+  TAG: NTP_4_2_4P7_RC2
+
+  ChangeLog@1.64, 2009-04-09 07:43:41-04:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P7_RC2
+
+  ntpd/ntpd-opts.c@1.78, 2009-04-09 07:43:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  ntpd/ntpd-opts.h@1.78, 2009-04-09 07:43:43-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC2
+
+  ntpd/ntpd-opts.texi@1.77, 2009-04-09 07:43:43-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  ntpd/ntpd.1@1.76, 2009-04-09 07:43:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  ntpd/ntpdsim-opts.c@1.78, 2009-04-09 07:43:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  ntpd/ntpdsim-opts.h@1.78, 2009-04-09 07:43:47-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC2
+
+  ntpd/ntpdsim-opts.texi@1.76, 2009-04-09 07:43:47-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC2
+
+  ntpd/ntpdsim.1@1.76, 2009-04-09 07:43:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  ntpdc/ntpdc-opts.c@1.78, 2009-04-09 07:43:49-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  ntpdc/ntpdc-opts.h@1.78, 2009-04-09 07:43:50-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC2
+
+  ntpdc/ntpdc-opts.texi@1.76, 2009-04-09 07:43:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  ntpdc/ntpdc.1@1.76, 2009-04-09 07:43:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  ntpq/ntpq-opts.c@1.80, 2009-04-09 07:43:52-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  ntpq/ntpq-opts.h@1.80, 2009-04-09 07:43:53-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC2
+
+  ntpq/ntpq-opts.texi@1.77, 2009-04-09 07:43:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  ntpq/ntpq.1@1.76, 2009-04-09 07:43:55-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  packageinfo.sh@1.108, 2009-04-09 07:43:55-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC2
+
+  sntp/sntp-opts.c@1.76, 2009-04-09 07:43:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  sntp/sntp-opts.h@1.76, 2009-04-09 07:43:58-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC2
+
+  sntp/sntp-opts.texi@1.73, 2009-04-09 07:43:58-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC2
+
+  sntp/sntp.1@1.76, 2009-04-09 07:43:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  util/ntp-keygen-opts.c@1.77, 2009-04-09 07:44:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  util/ntp-keygen-opts.h@1.77, 2009-04-09 07:44:00-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC2
+
+  util/ntp-keygen-opts.texi@1.75, 2009-04-09 07:44:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+  util/ntp-keygen.1@1.75, 2009-04-09 07:44:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC2
+
+ChangeSet@1.1566, 2009-04-09 04:16:50-04:00, stenn@whimsy.udel.edu +1 -0
+  ChangLog cleanup
+
+  ChangeLog@1.63, 2009-04-09 04:16:43-04:00, stenn@whimsy.udel.edu +1 -0
+    ChangLog cleanup
+
+ChangeSet@1.1565, 2009-04-09 04:13:41-04:00, stenn@whimsy.udel.edu +2 -0
+  [Sec 1144] limited buffer overflow in ntpq.  CVE-2009-0159
+
+  ChangeLog@1.62, 2009-04-09 04:13:30-04:00, stenn@whimsy.udel.edu +2 -0
+    [Sec 1144] limited buffer overflow in ntpq.  CVE-2009-0159
+
+  ntpq/ntpq.c@1.66, 2009-04-09 04:13:30-04:00, stenn@whimsy.udel.edu +2 -2
+    [Sec 1144] limited buffer overflow in ntpq.  CVE-2009-0159
+
+ChangeSet@1.1564, 2009-04-07 09:14:58+00:00, davehart@shiny.ad.hartbrothers.com +3 -0
+  [Sec 1149] use setsockopt(SO_EXCLUSIVEADDRUSE) on Windows
+
+  ChangeLog@1.61, 2009-04-07 09:14:56+00:00, davehart@shiny.ad.hartbrothers.com +4 -0
+    [Sec 1149] use setsockopt(SO_EXCLUSIVEADDRUSE) on Windows
+
+  ntpd/ntp_io.c@1.259, 2009-04-07 09:14:56+00:00, davehart@shiny.ad.hartbrothers.com +64 -31
+    [Sec 1149] use setsockopt(SO_EXCLUSIVEADDRUSE) on Windows
+
+  ports/winnt/libntp/libntp.vcproj@1.2, 2009-04-07 09:14:57+00:00, davehart@shiny.ad.hartbrothers.com +4 -0
+    add ntp_debug.h
+
+ChangeSet@1.1563, 2009-03-30 06:47:41-05:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P7_RC1
+  TAG: NTP_4_2_4P7_RC1
+
+  ChangeLog@1.60, 2009-03-30 06:47:19-05:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P7_RC1
+
+  ntpd/ntpd-opts.c@1.77, 2009-03-30 06:47:20-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  ntpd/ntpd-opts.h@1.77, 2009-03-30 06:47:21-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC1
+
+  ntpd/ntpd-opts.texi@1.76, 2009-03-30 06:47:22-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  ntpd/ntpd.1@1.75, 2009-03-30 06:47:22-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  ntpd/ntpdsim-opts.c@1.77, 2009-03-30 06:47:23-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  ntpd/ntpdsim-opts.h@1.77, 2009-03-30 06:47:24-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC1
+
+  ntpd/ntpdsim-opts.texi@1.75, 2009-03-30 06:47:25-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC1
+
+  ntpd/ntpdsim.1@1.75, 2009-03-30 06:47:26-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  ntpdc/ntpdc-opts.c@1.77, 2009-03-30 06:47:26-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  ntpdc/ntpdc-opts.h@1.77, 2009-03-30 06:47:26-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC1
+
+  ntpdc/ntpdc-opts.texi@1.75, 2009-03-30 06:47:27-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  ntpdc/ntpdc.1@1.75, 2009-03-30 06:47:28-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  ntpq/ntpq-opts.c@1.79, 2009-03-30 06:47:29-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  ntpq/ntpq-opts.h@1.79, 2009-03-30 06:47:30-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC1
+
+  ntpq/ntpq-opts.texi@1.76, 2009-03-30 06:47:31-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  ntpq/ntpq.1@1.75, 2009-03-30 06:47:32-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  packageinfo.sh@1.107, 2009-03-30 06:47:33-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  sntp/sntp-opts.c@1.75, 2009-03-30 06:47:33-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  sntp/sntp-opts.h@1.75, 2009-03-30 06:47:34-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC1
+
+  sntp/sntp-opts.texi@1.72, 2009-03-30 06:47:35-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P7_RC1
+
+  sntp/sntp.1@1.75, 2009-03-30 06:47:35-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  util/ntp-keygen-opts.c@1.76, 2009-03-30 06:47:36-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  util/ntp-keygen-opts.h@1.76, 2009-03-30 06:47:36-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P7_RC1
+
+  util/ntp-keygen-opts.texi@1.74, 2009-03-30 06:47:37-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+  util/ntp-keygen.1@1.74, 2009-03-30 06:47:38-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P7_RC1
+
+ChangeSet@1.1562, 2009-03-30 02:31:49-05:00, stenn@whimsy.udel.edu +1 -0
+  Release Candidate
+
+  packageinfo.sh@1.106, 2009-03-30 02:31:39-05:00, stenn@whimsy.udel.edu +1 -1
+    Release Candidate
+
+ChangeSet@1.1560, 2009-03-28 02:46:45-05:00, stenn@whimsy.udel.edu +9 -0
+  build system email address cleanup
+
+  BitKeeper/triggers/changelog@1.4, 2009-03-28 02:45:21-05:00, stenn@whimsy.udel.edu +1 -1
+    trigger email address cleanup
+
+  BitKeeper/triggers/commitlogs@1.6, 2009-03-28 02:45:22-05:00, stenn@whimsy.udel.edu +1 -1
+    trigger email address cleanup
+
+  BitKeeper/triggers/delta-changelog@1.8, 2009-03-28 02:45:22-05:00, stenn@whimsy.udel.edu +2 -2
+    trigger email address cleanup
+
+  BitKeeper/triggers/notify@1.4, 2009-03-28 02:45:22-05:00, stenn@whimsy.udel.edu +1 -1
+    trigger email address cleanup
+
+  BitKeeper/triggers/paranoid@1.4, 2009-03-28 02:45:22-05:00, stenn@whimsy.udel.edu +1 -1
+    trigger email address cleanup
+
+  BitKeeper/triggers/post-incoming.license-warn@1.7, 2009-03-28 02:45:22-05:00, stenn@whimsy.udel.edu +1 -1
+    trigger email address cleanup
+
+  BitKeeper/triggers/pre-resolve.licfix@1.4, 2009-03-28 02:45:22-05:00, stenn@whimsy.udel.edu +1 -1
+    trigger email address cleanup
+
+  BitKeeper/triggers/send@1.14, 2009-03-28 02:45:22-05:00, stenn@whimsy.udel.edu +2 -2
+    trigger email address cleanup
+
+  ChangeLog@1.58, 2009-03-28 02:46:36-05:00, stenn@whimsy.udel.edu +3 -1
+    build system email address cleanup
+
+ChangeSet@1.1559, 2009-03-24 15:22:36+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  config.h:
+    include winsock.h before ws2tcpip.h to fix VS 2005 build
+
+  ports/winnt/include/config.h@1.49, 2009-03-24 15:22:23+00:00, davehart@shiny.ad.hartbrothers.com +8 -5
+    include winsock.h before ws2tcpip.h to fix VS 2005 build
+
+ChangeSet@1.1549.4.2, 2009-03-24 15:14:36+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  ntp_iocompletionport.c:
+    use one receive per socket to avoid Win2000 afd.sys bugcheck 0x76
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.26.1.2, 2009-03-24 15:14:23+00:00, davehart@shiny.ad.hartbrothers.com +10 -1
+    use one receive per socket to avoid Win2000 afd.sys bugcheck 0x76
+
+ChangeSet@1.1557, 2009-03-22 21:09:43+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+  Makefile.am, ChangeLog:
+    [Bug 774] parsesolaris.c does not compile under the new Solaris
+
+  ChangeLog@1.57, 2009-03-22 21:09:42+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+    [Bug 774] parsesolaris.c does not compile under the new Solaris
+
+  libparse/Makefile.am@1.9, 2009-03-22 21:09:42+00:00, davehart@shiny.ad.hartbrothers.com +1 -1
+    [Bug 774] parsesolaris.c does not compile under the new Solaris
+
+ChangeSet@1.1556, 2009-03-20 03:39:26+00:00, hart@pogo.udel.edu +1 -0
+  ChangeLog:
+    bk for windows isn't converting line endings correctly, remove two blank lines visible only on Unix side
+
+  ChangeLog@1.56, 2009-03-20 03:39:16+00:00, hart@pogo.udel.edu +0 -2
+    bk for windows isn't converting line endings correctly, remove two blank lines visible only on Unix side
+
+ChangeSet@1.1553, 2009-03-20 03:10:22+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  ChangeLog:
+    remove blank first line
+
+  ChangeLog@1.53, 2009-03-20 03:09:55+00:00, davehart@shiny.ad.hartbrothers.com +0 -1
+    remove blank first line
+
+ChangeSet@1.1549.4.1, 2009-03-20 01:46:15+00:00, davehart@shiny.ad.hartbrothers.com +10 -0
+  [Bug 873] Windows serial refclock proper TTY line discipline emulation
+
+  ChangeLog@1.50.4.1, 2009-03-20 01:46:11+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+    [Bug 873] Windows serial refclock proper TTY line discipline emulation
+
+  ntpd/ntp_io.c@1.256.1.1, 2009-03-20 01:46:11+00:00, davehart@shiny.ad.hartbrothers.com +26 -23
+    [Bug 873] Windows serial refclock proper TTY line discipline emulation
+
+  ntpd/ntpd.c@1.86, 2009-03-20 01:46:12+00:00, davehart@shiny.ad.hartbrothers.com +14 -25
+    slightly reduce #ifdef SYS_WINNT forest
+
+  ntpd/refclock_dumbclock.c@1.9, 2009-03-20 01:46:12+00:00, davehart@shiny.ad.hartbrothers.com +6 -5
+    [Bug 873] Windows serial refclock proper TTY line discipline emulation
+
+  ntpd/refclock_hopfser.c@1.10, 2009-03-20 01:46:12+00:00, davehart@shiny.ad.hartbrothers.com +6 -5
+    [Bug 873] Windows serial refclock proper TTY line discipline emulation
+
+  ntpd/refclock_nmea.c@1.26, 2009-03-20 01:46:12+00:00, davehart@shiny.ad.hartbrothers.com +6 -5
+    [Bug 873] Windows serial refclock proper TTY line discipline emulation
+
+  ntpd/refclock_palisade.c@1.19, 2009-03-20 01:46:12+00:00, davehart@shiny.ad.hartbrothers.com +6 -5
+    [Bug 873] Windows serial refclock proper TTY line discipline emulation
+
+  ports/winnt/include/ntp_iocompletionport.h@1.14, 2009-03-20 01:46:13+00:00, davehart@shiny.ad.hartbrothers.com +8 -9
+    [Bug 873] Windows serial refclock proper TTY line discipline emulation
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.26.1.1, 2009-03-20 01:46:13+00:00, davehart@shiny.ad.hartbrothers.com +331 -249
+    [Bug 873] Windows serial refclock proper TTY line discipline emulation
+
+  ports/winnt/ntpd/win32_io.c@1.13, 2009-03-20 01:46:13+00:00, davehart@shiny.ad.hartbrothers.com +172 -66
+    [Bug 873] Windows serial refclock proper TTY line discipline emulation
+
+ChangeSet@1.1549.3.2, 2009-03-18 11:44:59+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  [Bug 1014] Enable building with VC9 (in Visual Studio 2008, Visual C++ 2008, or SDK)
+
+  ChangeLog@1.50.3.1, 2009-03-18 11:44:52+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+    [Bug 1014] Enable building with VC9 (in Visual Studio 2008, Visual C++ 2008, or SDK)
+
+ChangeSet@1.1549.1.4, 2009-03-18 10:14:52+00:00, davehart@shiny.ad.hartbrothers.com +1 -0
+  [Bug 1117] Deferred interface binding under Windows works only correctly if FORCE_DNSRETRY is defined
+
+  ChangeLog@1.50.1.3, 2009-03-18 10:12:28+00:00, davehart@shiny.ad.hartbrothers.com +2 -0
+    [Bug 1117] Deferred interface binding under Windows works only correctly if FORCE_DNSRETRY is defined
+
+ChangeSet@1.1549.3.1, 2009-03-17 18:39:09+00:00, davehart@shiny.ad.hartbrothers.com +8 -0
+  add .sln and .vcproj files for VC9
+
+  ports/winnt/instsrv/Instsrv.vcproj@1.1, 2009-03-17 18:34:21+00:00, davehart@shiny.ad.hartbrothers.com +253 -0
+    VC9 equivalent to Instsrv.dsp
+
+  ports/winnt/instsrv/Instsrv.vcproj@1.0, 2009-03-17 18:34:21+00:00, davehart@shiny.ad.hartbrothers.com +0 -0
+
+  ports/winnt/libntp/libntp.vcproj@1.1, 2009-03-17 18:35:45+00:00, davehart@shiny.ad.hartbrothers.com +2229 -0
+    VC9 equivalent to libntp.dsp
+
+  ports/winnt/libntp/libntp.vcproj@1.0, 2009-03-17 18:35:45+00:00, davehart@shiny.ad.hartbrothers.com +0 -0
+
+  ports/winnt/ntp-keygen/ntpkeygen.vcproj@1.1, 2009-03-17 18:36:28+00:00, davehart@shiny.ad.hartbrothers.com +419 -0
+    VC9 equivalent to ntpkeygen.dsp
+
+  ports/winnt/ntp-keygen/ntpkeygen.vcproj@1.0, 2009-03-17 18:36:28+00:00, davehart@shiny.ad.hartbrothers.com +0 -0
+
+  ports/winnt/ntp.sln@1.1, 2009-03-17 18:38:44+00:00, davehart@shiny.ad.hartbrothers.com +71 -0
+    VC9 equivalent to ntp.dsw
+
+  ports/winnt/ntp.sln@1.0, 2009-03-17 18:38:44+00:00, davehart@shiny.ad.hartbrothers.com +0 -0
+
+  ports/winnt/ntpd/ntpd.vcproj@1.1, 2009-03-17 18:36:49+00:00, davehart@shiny.ad.hartbrothers.com +2198 -0
+    VC9 equivalent to ntpd.dsp
+
+  ports/winnt/ntpd/ntpd.vcproj@1.0, 2009-03-17 18:36:49+00:00, davehart@shiny.ad.hartbrothers.com +0 -0
+
+  ports/winnt/ntpdate/ntpdate.vcproj@1.1, 2009-03-17 18:37:19+00:00, davehart@shiny.ad.hartbrothers.com +327 -0
+    VC9 equivalent to ntpdate.dsp
+
+  ports/winnt/ntpdate/ntpdate.vcproj@1.0, 2009-03-17 18:37:19+00:00, davehart@shiny.ad.hartbrothers.com +0 -0
+
+  ports/winnt/ntpdc/ntpdc.vcproj@1.1, 2009-03-17 18:37:32+00:00, davehart@shiny.ad.hartbrothers.com +376 -0
+    VC9 equivalent to ntpdc.dsp
+
+  ports/winnt/ntpdc/ntpdc.vcproj@1.0, 2009-03-17 18:37:31+00:00, davehart@shiny.ad.hartbrothers.com +0 -0
+
+  ports/winnt/ntpq/ntpq.vcproj@1.1, 2009-03-17 18:37:48+00:00, davehart@shiny.ad.hartbrothers.com +370 -0
+    VC9 equivalent to ntpq.dsp
+
+  ports/winnt/ntpq/ntpq.vcproj@1.0, 2009-03-17 18:37:48+00:00, davehart@shiny.ad.hartbrothers.com +0 -0
+
+ChangeSet@1.1549.1.3, 2009-03-17 18:18:13+00:00, hart@pogo.udel.edu +1 -0
+  config.h:
+    now works with VC6 and VC9 compilers, declares DWORD_PTR on VC6
+
+  ports/winnt/include/config.h@1.48, 2009-03-17 18:18:01+00:00, hart@pogo.udel.edu +243 -96
+    now works with VC6 and VC9 compilers, declares DWORD_PTR on VC6
+
+ChangeSet@1.1549.2.1, 2009-02-21 07:45:56-05:00, utterback@pogo.udel.edu +2 -0
+  configure.ac, ChangeLog:
+    [BUG 1131] UDP sockets should not use SIGPOLL on Solaris.
+
+  ChangeLog@1.50.2.1, 2009-02-20 12:30:18-05:00, utterback@pogo.udel.edu +2 -0
+    [BUG 1131] UDP sockets should not use SIGPOLL on Solaris.
+
+  configure.ac@1.402, 2009-02-20 11:30:02-05:00, utterback@pogo.udel.edu +3 -0
+    [BUG 1131] UDP sockets should not use SIGPOLL on Solaris.
+
+ChangeSet@1.1549.1.2, 2009-02-07 21:13:17+00:00, hart@pogo.udel.edu +1 -0
+  ChangeLog:
+    formatting of newest line
+
+  ChangeLog@1.50.1.2, 2009-02-07 21:12:26+00:00, hart@pogo.udel.edu +1 -1
+    formatting of newest line
+
+ChangeSet@1.1549.1.1, 2009-02-07 21:05:32+00:00, hart@pogo.udel.edu +3 -0
+  nt_clockstuff.c, ChangeLog, ntp_iocompletionport.c:
+    [BUG 1124] Lock QueryPerformanceCounter() client threads to same CPU
+
+  ChangeLog@1.50.1.1, 2009-02-07 21:04:52+00:00, hart@pogo.udel.edu +2 -0
+    [BUG 1124] Lock QueryPerformanceCounter() client threads to same CPU
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.24, 2009-02-07 21:02:04+00:00, hart@pogo.udel.edu +89 -22
+    [BUG 1124] Lock QueryPerformanceCounter() client threads to same CPU
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.27, 2009-02-07 21:03:34+00:00, hart@pogo.udel.edu +12 -0
+    [BUG 1124] Lock QueryPerformanceCounter() client threads to same CPU
+
+ChangeSet@1.1551, 2009-02-07 14:08:35-05:00, hart@pogo.udel.edu +1 -0
+  ChangeLog:
+    DPRINTF safer
+
+  ChangeLog@1.51, 2009-02-07 14:07:34-05:00, hart@pogo.udel.edu +2 -0
+    DPRINTF safer
+
+ChangeSet@1.1550, 2009-02-06 19:00:15-05:00, hart@pogo.udel.edu +2 -0
+  ntp_debug.h:
+    DPRINTF won't eat following else, always evaluates to a statement
+  ntp_io.c:
+    DPRINTF_INTERFACE always evaluates to a statement
+    fix DPRINTF use with misplaced semicolon
+
+  include/ntp_debug.h@1.2, 2009-02-06 18:50:27-05:00, hart@pogo.udel.edu +6 -4
+    DPRINTF won't eat following else, always evaluates to a statement
+
+  ntpd/ntp_io.c@1.257, 2009-02-06 18:53:58-05:00, hart@pogo.udel.edu +2 -2
+    DPRINTF_INTERFACE always evaluates to a statement
+    fix DPRINTF use with misplaced semicolon
+
+ChangeSet@1.1549, 2009-01-08 06:21:48-05:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P6
+  TAG: NTP_4_2_4P6
+
+  ChangeLog@1.50, 2009-01-08 06:21:25-05:00, stenn@whimsy.udel.edu +1 -2
+    NTP_4_2_4P6
+
+  ntpd/ntpd-opts.c@1.76, 2009-01-08 06:21:26-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  ntpd/ntpd-opts.h@1.76, 2009-01-08 06:21:27-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P6
+
+  ntpd/ntpd-opts.texi@1.75, 2009-01-08 06:21:28-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P6
+
+  ntpd/ntpd.1@1.74, 2009-01-08 06:21:29-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  ntpd/ntpdsim-opts.c@1.76, 2009-01-08 06:21:29-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  ntpd/ntpdsim-opts.h@1.76, 2009-01-08 06:21:30-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P6
+
+  ntpd/ntpdsim-opts.texi@1.74, 2009-01-08 06:21:31-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P6
+
+  ntpd/ntpdsim.1@1.74, 2009-01-08 06:21:32-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  ntpdc/ntpdc-opts.c@1.76, 2009-01-08 06:21:33-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  ntpdc/ntpdc-opts.h@1.76, 2009-01-08 06:21:34-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P6
+
+  ntpdc/ntpdc-opts.texi@1.74, 2009-01-08 06:21:34-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P6
+
+  ntpdc/ntpdc.1@1.74, 2009-01-08 06:21:35-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  ntpq/ntpq-opts.c@1.78, 2009-01-08 06:21:36-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  ntpq/ntpq-opts.h@1.78, 2009-01-08 06:21:37-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P6
+
+  ntpq/ntpq-opts.texi@1.75, 2009-01-08 06:21:37-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P6
+
+  ntpq/ntpq.1@1.74, 2009-01-08 06:21:39-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  packageinfo.sh@1.105, 2009-01-08 06:21:39-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P6
+
+  sntp/sntp-opts.c@1.74, 2009-01-08 06:21:40-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  sntp/sntp-opts.h@1.74, 2009-01-08 06:21:41-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P6
+
+  sntp/sntp-opts.texi@1.71, 2009-01-08 06:21:42-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P6
+
+  sntp/sntp.1@1.74, 2009-01-08 06:21:42-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  util/ntp-keygen-opts.c@1.75, 2009-01-08 06:21:43-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+  util/ntp-keygen-opts.h@1.75, 2009-01-08 06:21:44-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P6
+
+  util/ntp-keygen-opts.texi@1.73, 2009-01-08 06:21:44-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P6
+
+  util/ntp-keygen.1@1.73, 2009-01-08 06:21:45-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P6
+
+ChangeSet@1.1548, 2009-01-08 04:49:23-05:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P5
+  TAG: NTP_4_2_4P5
+
+  ChangeLog@1.49, 2009-01-08 04:48:59-05:00, stenn@whimsy.udel.edu +1 -0
+    NTP_4_2_4P5
+
+  ntpd/ntpd-opts.c@1.75, 2009-01-08 04:49:01-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpd/ntpd-opts.h@1.75, 2009-01-08 04:49:01-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpd/ntpd-opts.texi@1.74, 2009-01-08 04:49:03-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpd/ntpd.1@1.73, 2009-01-08 04:49:03-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpd/ntpdsim-opts.c@1.75, 2009-01-08 04:49:04-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpd/ntpdsim-opts.h@1.75, 2009-01-08 04:49:04-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpd/ntpdsim-opts.texi@1.73, 2009-01-08 04:49:05-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpd/ntpdsim.1@1.73, 2009-01-08 04:49:06-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpdc/ntpdc-opts.c@1.75, 2009-01-08 04:49:06-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpdc/ntpdc-opts.h@1.75, 2009-01-08 04:49:07-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpdc/ntpdc-opts.texi@1.73, 2009-01-08 04:49:08-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpdc/ntpdc.1@1.73, 2009-01-08 04:49:09-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpq/ntpq-opts.c@1.77, 2009-01-08 04:49:10-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpq/ntpq-opts.h@1.77, 2009-01-08 04:49:10-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpq/ntpq-opts.texi@1.74, 2009-01-08 04:49:11-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpq/ntpq.1@1.73, 2009-01-08 04:49:12-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  packageinfo.sh@1.104, 2009-01-08 04:49:13-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  sntp/sntp-opts.c@1.73, 2009-01-08 04:49:14-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  sntp/sntp-opts.h@1.73, 2009-01-08 04:49:15-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  sntp/sntp-opts.texi@1.70, 2009-01-08 04:49:16-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  sntp/sntp.1@1.73, 2009-01-08 04:49:17-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  util/ntp-keygen-opts.c@1.74, 2009-01-08 04:49:18-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  util/ntp-keygen-opts.h@1.74, 2009-01-08 04:49:19-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  util/ntp-keygen-opts.texi@1.72, 2009-01-08 04:49:20-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  util/ntp-keygen.1@1.72, 2009-01-08 04:49:20-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+ChangeSet@1.1547, 2009-01-08 03:21:09-05:00, stenn@whimsy.udel.edu +1 -0
+  4.2.4p6
+
+  packageinfo.sh@1.103, 2009-01-08 03:20:56-05:00, stenn@whimsy.udel.edu +1 -1
+    4.2.4p6
+
+ChangeSet@1.1546, 2009-01-08 03:14:17-05:00, stenn@whimsy.udel.edu +1 -0
+  merge cleanup
+
+  ChangeLog@1.48, 2009-01-08 03:14:09-05:00, stenn@whimsy.udel.edu +1 -1
+    merge cleanup
+
+ChangeSet@1.1543.1.1, 2009-01-08 02:57:52-05:00, stenn@whimsy.udel.edu +5 -0
+  4.2.4p6
+
+  ChangeLog@1.46, 2009-01-07 05:31:52-05:00, stenn@whimsy.udel.edu +6 -0
+    Fix incorrect check of EVP_VerifyFinal()'s return value.
+
+  NEWS@1.100, 2009-01-08 02:57:32-05:00, stenn@whimsy.udel.edu +16 -0
+    4.2.4p6
+
+  html/copyright.html@1.38, 2009-01-07 05:30:58-05:00, stenn@whimsy.udel.edu +1 -1
+    Update the copyright year
+
+  ntpd/ntp_crypto.c@1.108, 2009-01-07 05:31:50-05:00, stenn@whimsy.udel.edu +1 -1
+    Fix incorrect check of EVP_VerifyFinal()'s return value.
+
+  packageinfo.sh@1.102, 2009-01-08 02:57:33-05:00, stenn@whimsy.udel.edu +1 -1
+    4.2.4p6
+
+ChangeSet@1.1544, 2009-01-07 18:00:50+01:00, burnicki@pogo.udel.edu +2 -0
+  [BUG 1113] Fixed build errors with recent versions of openSSL.
+
+  ChangeLog@1.45.1.1, 2009-01-07 18:00:47+01:00, burnicki@pogo.udel.edu +1 -0
+    [BUG 1113] Fixed build errors with recent versions of openSSL.
+
+  ntpd/ntp_crypto.c@1.107.1.1, 2009-01-07 18:00:47+01:00, burnicki@pogo.udel.edu +2 -2
+    [BUG 1113] Fixed build errors with recent versions of openSSL.
+
+ChangeSet@1.1543, 2008-08-17 06:21:39-04:00, stenn@whimsy.udel.edu +1 -0
+  typo
+
+  scripts/addChangeLogTag@1.3, 2008-08-17 06:21:25-04:00, stenn@whimsy.udel.edu +0 -3
+    typo
+
+ChangeSet@1.1542, 2008-08-17 06:16:19-04:00, stenn@whimsy.udel.edu +1 -0
+  typo
+
+  ChangeLog@1.45, 2008-08-17 06:16:08-04:00, stenn@whimsy.udel.edu +0 -2
+    typo
+
+ChangeSet@1.1541, 2008-08-17 05:30:47-04:00, stenn@whimsy.udel.edu +26 -0
+  NTP_4_2_4P5
+  TAG: NTP_4_2_4P5
+
+  ChangeLog@1.44, 2008-08-17 05:30:27-04:00, stenn@whimsy.udel.edu +3 -0
+    NTP_4_2_4P5
+
+  ntpd/ntpd-opts.c@1.74, 2008-08-17 05:30:28-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpd/ntpd-opts.h@1.74, 2008-08-17 05:30:28-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5
+
+  ntpd/ntpd-opts.texi@1.73, 2008-08-17 05:30:29-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpd/ntpd.1@1.72, 2008-08-17 05:30:30-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpd/ntpdsim-opts.c@1.74, 2008-08-17 05:30:30-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpd/ntpdsim-opts.h@1.74, 2008-08-17 05:30:31-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5
+
+  ntpd/ntpdsim-opts.texi@1.72, 2008-08-17 05:30:32-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpd/ntpdsim.1@1.72, 2008-08-17 05:30:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpdc/ntpdc-opts.c@1.74, 2008-08-17 05:30:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpdc/ntpdc-opts.h@1.74, 2008-08-17 05:30:34-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5
+
+  ntpdc/ntpdc-opts.texi@1.72, 2008-08-17 05:30:34-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpdc/ntpdc.1@1.72, 2008-08-17 05:30:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpq/ntpq-opts.c@1.76, 2008-08-17 05:30:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  ntpq/ntpq-opts.h@1.76, 2008-08-17 05:30:36-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5
+
+  ntpq/ntpq-opts.texi@1.73, 2008-08-17 05:30:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  ntpq/ntpq.1@1.72, 2008-08-17 05:30:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  packageinfo.sh@1.101, 2008-08-17 05:30:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  sntp/sntp-opts.c@1.72, 2008-08-17 05:30:38-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  sntp/sntp-opts.h@1.72, 2008-08-17 05:30:39-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5
+
+  sntp/sntp-opts.texi@1.69, 2008-08-17 05:30:39-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  sntp/sntp.1@1.72, 2008-08-17 05:30:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  util/ntp-keygen-opts.c@1.73, 2008-08-17 05:30:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+  util/ntp-keygen-opts.h@1.73, 2008-08-17 05:30:41-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5
+
+  util/ntp-keygen-opts.texi@1.71, 2008-08-17 05:30:42-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5
+
+  util/ntp-keygen.1@1.71, 2008-08-17 05:30:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5
+
+ChangeSet@1.1540, 2008-08-17 05:29:47-04:00, stenn@whimsy.udel.edu +1 -0
+  typo
+
+  scripts/addChangeLogTag@1.2, 2008-08-17 05:29:37-04:00, stenn@whimsy.udel.edu +1 -1
+    typo
+
+ChangeSet@1.1539, 2008-08-17 03:28:53-04:00, stenn@whimsy.udel.edu +5 -0
+  4.2.4p5 prep
+
+  .point-changed-filelist@1.2, 2008-08-17 03:27:42-04:00, stenn@whimsy.udel.edu +1 -0
+    4.2.4p5 prep
+
+  NEWS@1.99, 2008-08-17 03:27:42-04:00, stenn@whimsy.udel.edu +17 -0
+    4.2.4p5 prep
+
+  packageinfo.sh@1.100, 2008-08-17 03:27:43-04:00, stenn@whimsy.udel.edu +1 -1
+    4.2.4p5 prep
+
+  scripts/addChangeLogTag@1.1, 2008-08-17 03:27:55-04:00, stenn@whimsy.udel.edu +27 -0
+    BitKeeper file /deacon/backroom/ntp-stable/scripts/addChangeLogTag
+
+  scripts/addChangeLogTag@1.0, 2008-08-17 03:27:55-04:00, stenn@whimsy.udel.edu +0 -0
+
+  scripts/genChangeLogTag@1.1, 2008-08-17 03:27:55-04:00, stenn@whimsy.udel.edu +6 -0
+    BitKeeper file /deacon/backroom/ntp-stable/scripts/genChangeLogTag
+
+  scripts/genChangeLogTag@1.0, 2008-08-17 03:27:55-04:00, stenn@whimsy.udel.edu +0 -0
+
+ChangeSet@1.1538, 2008-08-16 22:42:08-04:00, stenn@whimsy.udel.edu +2 -0
+  [BUG 1051] Month off by one in leap second message written to clockstats
+
+  ChangeLog@1.43, 2008-08-16 22:41:50-04:00, stenn@whimsy.udel.edu +2 -0
+    [BUG 1051] Month off by one in leap second message written to clockstats
+
+  ntpd/refclock_oncore.c@1.63, 2008-08-16 22:41:50-04:00, stenn@whimsy.udel.edu +1 -1
+    [BUG 1051] Month off by one in leap second message written to clockstats
+
+ChangeSet@1.1537, 2008-08-10 07:44:31-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P5_RC2
+  TAG: NTP_4_2_4P5_RC2
+
+  ntpd/ntpd-opts.c@1.73, 2008-08-10 07:44:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC2
+
+  ntpd/ntpd-opts.h@1.73, 2008-08-10 07:44:09-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5_RC2
+
+  ntpd/ntpd-opts.texi@1.72, 2008-08-10 07:44:10-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5_RC2
+
+  ntpd/ntpd.1@1.71, 2008-08-10 07:44:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC2
+
+  ntpd/ntpdsim-opts.c@1.73, 2008-08-10 07:44:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC2
+
+  ntpd/ntpdsim-opts.h@1.73, 2008-08-10 07:44:12-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5_RC2
+
+  ntpd/ntpdsim-opts.texi@1.71, 2008-08-10 07:44:12-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5_RC2
+
+  ntpd/ntpdsim.1@1.71, 2008-08-10 07:44:13-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC2
+
+  ntpdc/ntpdc-opts.c@1.73, 2008-08-10 07:44:14-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC2
+
+  ntpdc/ntpdc-opts.h@1.73, 2008-08-10 07:44:15-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5_RC2
+
+  ntpdc/ntpdc-opts.texi@1.71, 2008-08-10 07:44:16-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5_RC2
+
+  ntpdc/ntpdc.1@1.71, 2008-08-10 07:44:17-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC2
+
+  ntpq/ntpq-opts.c@1.75, 2008-08-10 07:44:17-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC2
+
+  ntpq/ntpq-opts.h@1.75, 2008-08-10 07:44:18-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5_RC2
+
+  ntpq/ntpq-opts.texi@1.72, 2008-08-10 07:44:19-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5_RC2
+
+  ntpq/ntpq.1@1.71, 2008-08-10 07:44:20-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC2
+
+  packageinfo.sh@1.99, 2008-08-10 07:44:20-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5_RC2
+
+  sntp/sntp-opts.c@1.71, 2008-08-10 07:44:22-04:00, stenn@whimsy.udel.edu +4 -5
+    NTP_4_2_4P5_RC2
+
+  sntp/sntp-opts.h@1.71, 2008-08-10 07:44:23-04:00, stenn@whimsy.udel.edu +5 -6
+    NTP_4_2_4P5_RC2
+
+  sntp/sntp-opts.texi@1.68, 2008-08-10 07:44:23-04:00, stenn@whimsy.udel.edu +2 -3
+    NTP_4_2_4P5_RC2
+
+  sntp/sntp.1@1.71, 2008-08-10 07:44:24-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5_RC2
+
+  util/ntp-keygen-opts.c@1.72, 2008-08-10 07:44:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC2
+
+  util/ntp-keygen-opts.h@1.72, 2008-08-10 07:44:25-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5_RC2
+
+  util/ntp-keygen-opts.texi@1.70, 2008-08-10 07:44:27-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5_RC2
+
+  util/ntp-keygen.1@1.70, 2008-08-10 07:44:27-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC2
+
+ChangeSet@1.1531.3.1, 2008-08-10 02:22:22-04:00, stenn@whimsy.udel.edu +1 -0
+  triggert needs to handle rooted RESYNC paths now
+
+  BitKeeper/triggers/triggert@1.5, 2008-08-10 02:22:11-04:00, stenn@whimsy.udel.edu +3 -2
+    triggert needs to handle rooted RESYNC paths now
+
+ChangeSet@1.1534, 2008-08-09 20:05:06-04:00, stenn@whimsy.udel.edu +2 -0
+  AutoGen'd files must be writable
+
+  sntp/Makefile.am@1.23, 2008-08-09 20:04:56-04:00, stenn@whimsy.udel.edu +2 -2
+    AutoGen'd files must be writable
+
+  sntp/sntp-opts.menu@1.3, 2008-08-09 20:04:10-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-rw-r--
+
+ChangeSet@1.1531.2.1, 2008-08-07 20:44:31+02:00, burnicki@pogo.udel.edu +3 -0
+  [Bug 450] Windows only: Under original Windows NT we must not discard the
+  wildcard socket to workaround a bug in NT's getsockname().
+
+  ChangeLog@1.39.2.1, 2008-08-07 20:44:30+02:00, burnicki@pogo.udel.edu +2 -0
+    [Bug 450] Windows only: Under original Windows NT we must not discard the
+    wildcard socket to workaround a bug in NT's getsockname().
+
+  ntpd/ntp_peer.c@1.99.1.1, 2008-08-07 20:44:30+02:00, burnicki@pogo.udel.edu +10 -2
+    [Bug 450] Windows only: Under original Windows NT we must not discard the
+    wildcard socket to workaround a bug in NT's getsockname().
+
+  ports/winnt/ntpd/ntservice.c@1.11, 2008-08-07 20:44:30+02:00, burnicki@pogo.udel.edu +8 -1
+    [Bug 450] Windows only: Under original Windows NT we must not discard the
+    wildcard socket to workaround a bug in NT's getsockname().
+
+ChangeSet@1.1531.1.2, 2008-08-05 09:56:08+02:00, burnicki@pogo.udel.edu +1 -0
+  Removed Windows-specific debug code which has been added in ntp-dev and fails to compile in ntp-stable.
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.26, 2008-08-05 09:56:08+02:00, burnicki@pogo.udel.edu +0 -8
+    Removed Windows-specific debug code which has been added in ntp-dev and fails to compile in ntp-stable.
+
+ChangeSet@1.1531.1.1, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +10 -0
+  [Bug 841] Obsolete the "dynamic" keyword and make deferred binding 
+  to local interfaces the default.
+  Emit a warning if that keyword is used for configuration.
+
+  ChangeLog@1.39.1.1, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +3 -0
+    [Bug 841] Obsolete the "dynamic" keyword and make deferred binding
+    to local interfaces the default.
+    Emit a warning if that keyword is used for configuration.
+
+  html/confopt.html@1.36, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +0 -2
+    Bug 841: Obsolete the "dynamic" keyword.
+
+  html/ntpdc.html@1.27, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +2 -3
+    Bug 841: Obsolete the "dynamic" keyword.
+
+  include/ntp.h@1.129, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +0 -1
+    Bug 841: Obsolete the "dynamic" keyword.
+
+  include/ntp_request.h@1.31, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +0 -1
+    Bug 841: Obsolete the "dynamic" keyword.
+
+  ntpd/ntp_config.c@1.144, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +4 -2
+    [Bug 841] Obsolete the "dynamic" keyword and make deferred binding
+    to local interfaces the default.
+    Emit a warning if that keyword is used for configuration.
+
+  ntpd/ntp_intres.c@1.52, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +1 -3
+    Bug 841: Obsolete the "dynamic" keyword.
+
+  ntpd/ntp_peer.c@1.100, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +5 -25
+    [Bug 841] Obsolete the "dynamic" keyword and make deferred binding
+    to local interfaces the default.
+
+  ntpd/ntp_request.c@1.66, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +1 -3
+    Bug 841: Obsolete the "dynamic" keyword.
+
+  ntpdc/ntpdc_ops.c@1.50, 2008-08-05 09:50:23+02:00, burnicki@pogo.udel.edu +3 -3
+    [Bug 841] Obsolete the "dynamic" keyword and make deferred binding
+    to local interfaces the default.
+
+ChangeSet@1.1532, 2008-07-22 11:41:26+02:00, burnicki@pogo.udel.edu +2 -0
+  [Bug 1038] Built-in getpass() function also prompts for password if not built with DEBUG.
+
+  ChangeLog@1.40, 2008-07-22 11:41:25+02:00, burnicki@pogo.udel.edu +1 -0
+    [Bug 1038] Built-in getpass() function also prompts for password if not built with DEBUG.
+
+  libntp/machines.c@1.19, 2008-07-22 11:41:25+02:00, burnicki@pogo.udel.edu +2 -2
+    [Bug 1038] Built-in getpass() function also prompts for password if not built with DEBUG.
+
+ChangeSet@1.1531, 2008-05-20 03:51:01-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P5_RC1
+  TAG: NTP_4_2_4P5_RC1
+
+  ntpd/ntpd-opts.c@1.72, 2008-05-20 03:50:37-04:00, stenn@whimsy.udel.edu +6 -7
+    NTP_4_2_4P5_RC1
+
+  ntpd/ntpd-opts.h@1.72, 2008-05-20 03:50:37-04:00, stenn@whimsy.udel.edu +6 -7
+    NTP_4_2_4P5_RC1
+
+  ntpd/ntpd-opts.texi@1.71, 2008-05-20 03:50:38-04:00, stenn@whimsy.udel.edu +8 -11
+    NTP_4_2_4P5_RC1
+
+  ntpd/ntpd.1@1.70, 2008-05-20 03:50:39-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P5_RC1
+
+  ntpd/ntpdsim-opts.c@1.72, 2008-05-20 03:50:40-04:00, stenn@whimsy.udel.edu +6 -7
+    NTP_4_2_4P5_RC1
+
+  ntpd/ntpdsim-opts.h@1.72, 2008-05-20 03:50:41-04:00, stenn@whimsy.udel.edu +6 -7
+    NTP_4_2_4P5_RC1
+
+  ntpd/ntpdsim-opts.texi@1.70, 2008-05-20 03:50:42-04:00, stenn@whimsy.udel.edu +3 -4
+    NTP_4_2_4P5_RC1
+
+  ntpd/ntpdsim.1@1.70, 2008-05-20 03:50:43-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P5_RC1
+
+  ntpdc/ntpdc-opts.c@1.72, 2008-05-20 03:50:44-04:00, stenn@whimsy.udel.edu +6 -7
+    NTP_4_2_4P5_RC1
+
+  ntpdc/ntpdc-opts.h@1.72, 2008-05-20 03:50:44-04:00, stenn@whimsy.udel.edu +6 -7
+    NTP_4_2_4P5_RC1
+
+  ntpdc/ntpdc-opts.texi@1.70, 2008-05-20 03:50:45-04:00, stenn@whimsy.udel.edu +5 -6
+    NTP_4_2_4P5_RC1
+
+  ntpdc/ntpdc.1@1.70, 2008-05-20 03:50:46-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5_RC1
+
+  ntpq/ntpq-opts.c@1.74, 2008-05-20 03:50:47-04:00, stenn@whimsy.udel.edu +6 -7
+    NTP_4_2_4P5_RC1
+
+  ntpq/ntpq-opts.h@1.74, 2008-05-20 03:50:47-04:00, stenn@whimsy.udel.edu +6 -7
+    NTP_4_2_4P5_RC1
+
+  ntpq/ntpq-opts.texi@1.71, 2008-05-20 03:50:48-04:00, stenn@whimsy.udel.edu +5 -6
+    NTP_4_2_4P5_RC1
+
+  ntpq/ntpq.1@1.70, 2008-05-20 03:50:49-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5_RC1
+
+  packageinfo.sh@1.98, 2008-05-20 03:50:50-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC1
+
+  sntp/sntp-opts.c@1.70, 2008-05-20 03:50:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC1
+
+  sntp/sntp-opts.h@1.70, 2008-05-20 03:50:52-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5_RC1
+
+  sntp/sntp-opts.texi@1.67, 2008-05-20 03:50:52-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P5_RC1
+
+  sntp/sntp.1@1.70, 2008-05-20 03:50:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P5_RC1
+
+  util/ntp-keygen-opts.c@1.71, 2008-05-20 03:50:54-04:00, stenn@whimsy.udel.edu +6 -7
+    NTP_4_2_4P5_RC1
+
+  util/ntp-keygen-opts.h@1.71, 2008-05-20 03:50:54-04:00, stenn@whimsy.udel.edu +6 -7
+    NTP_4_2_4P5_RC1
+
+  util/ntp-keygen-opts.texi@1.69, 2008-05-20 03:50:55-04:00, stenn@whimsy.udel.edu +7 -9
+    NTP_4_2_4P5_RC1
+
+  util/ntp-keygen.1@1.69, 2008-05-20 03:50:56-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P5_RC1
+
+ChangeSet@1.1530, 2008-05-18 05:14:37-04:00, stenn@whimsy.udel.edu +1 -0
+  Start the 4.2.4p5 release candidate cycle
+
+  packageinfo.sh@1.97, 2008-05-18 05:14:27-04:00, stenn@whimsy.udel.edu +1 -1
+    Start the 4.2.4p5 release candidate cycle
+
+ChangeSet@1.1529, 2008-04-11 18:41:57-04:00, stenn@whimsy.udel.edu +1 -0
+  Solaris _XOPEN_SOURCE updates
+
+  configure.ac@1.401, 2008-04-11 18:41:47-04:00, stenn@whimsy.udel.edu +5 -1
+    Solaris _XOPEN_SOURCE updates
+
+ChangeSet@1.1524.1.3, 2008-04-10 02:09:52-04:00, stenn@pogo.udel.edu +1 -0
+  Changelog cleanup
+
+  ChangeLog@1.37.1.2, 2008-04-10 02:08:57-04:00, stenn@pogo.udel.edu +2 -1
+
+ChangeSet@1.1524.1.2, 2008-04-08 12:20:22+02:00, burnicki@pogo.udel.edu +1 -0
+  Always sleep a little before calling doconfigure() to make sure the network is completely up.
+
+  ntpd/ntp_intres.c@1.51, 2008-04-08 12:20:21+02:00, burnicki@pogo.udel.edu +5 -6
+    Always sleep a little before calling doconfigure() to make sure the network is completely up.
+
+ChangeSet@1.1524.1.1, 2008-04-03 10:19:03-04:00, burnicki@pogo.udel.edu +5 -0
+  [Bug 987] Wake up the resolver thread/process when a new interface has become available.
+
+  ChangeLog@1.37.1.1, 2008-04-03 10:18:59-04:00, burnicki@pogo.udel.edu +1 -0
+    [Bug 987] Wake up the resolver thread/process when a new interface has become available.
+
+  include/ntpd.h@1.98, 2008-04-03 10:18:59-04:00, burnicki@pogo.udel.edu +5 -0
+    Added vars used to wake up the resolver process/thread.
+
+  ntpd/ntp_config.c@1.143, 2008-04-03 10:18:59-04:00, burnicki@pogo.udel.edu +34 -1
+    Initialize synchronization variables when the resolver process/thread is started.
+
+  ntpd/ntp_intres.c@1.50, 2008-04-03 10:18:59-04:00, burnicki@pogo.udel.edu +64 -65
+    Enable the resolver to be woken up when a new interface has become available.
+
+  ntpd/ntp_io.c@1.256, 2008-04-03 10:19:00-04:00, burnicki@pogo.udel.edu +25 -5
+    Wake up the resolver thread/process when a new interface has become available.
+
+ChangeSet@1.1527, 2008-03-24 22:12:42-04:00, mayer@pogo.udel.edu +1 -0
+  bugs 993 a d 959
+
+  ChangeLog@1.38, 2008-03-24 22:12:26-04:00, mayer@pogo.udel.edu +2 -0
+    bugs 993 a d 959
+
+ChangeSet@1.1526, 2008-03-24 21:41:55-04:00, mayer@pogo.udel.edu +1 -0
+  [Bug 959] Refclock on Windows not properly releasing recvbuffs
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.25, 2008-03-24 21:41:37-04:00, mayer@pogo.udel.edu +25 -13
+    [Bug 959] Refclock on Windows not properly releasing recvbuffs
+
+ChangeSet@1.1525, 2008-03-24 21:40:32-04:00, mayer@pogo.udel.edu +1 -0
+  [Bug 993] Windows: Fix memory leak when fetching system messages
+
+  ports/winnt/libisc/isc_strerror.c@1.5, 2008-03-24 21:40:07-04:00, mayer@pogo.udel.edu +78 -18
+    [Bug 993] Windows: Fix memory leak when fetching system messages
+
+ChangeSet@1.1520.3.5, 2008-03-22 02:12:10-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 977] Fix mismatching #ifdefs for builds without IPv6
+
+  ChangeLog@1.35.3.4, 2008-03-22 02:11:57-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 977] Fix mismatching #ifdefs for builds without IPv6
+
+  libisc/net.c@1.9, 2008-03-22 02:11:58-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 977] Fix mismatching #ifdefs for builds without IPv6
+
+ChangeSet@1.1520.3.4, 2008-03-22 02:02:36-05:00, stenn@whimsy.udel.edu +3 -0
+  Update the copyright year
+
+  ChangeLog@1.35.3.3, 2008-03-22 02:02:24-05:00, stenn@whimsy.udel.edu +8 -6
+    Update the copyright year
+
+  html/copyright.html@1.37, 2008-03-22 02:02:25-05:00, stenn@whimsy.udel.edu +1 -1
+    Update the copyright year
+
+  include/copyright.def@1.6, 2008-03-22 02:02:25-05:00, stenn@whimsy.udel.edu +1 -1
+    Update the copyright year
+
+ChangeSet@1.1520.3.3, 2008-03-22 01:58:52-05:00, stenn@whimsy.udel.edu +5 -0
+  Make autogen-generated files writable
+
+  ntpd/Makefile.am@1.54, 2008-03-22 01:57:08-05:00, stenn@whimsy.udel.edu +1 -1
+    Make autogen-generated files writable
+
+  ntpdc/Makefile.am@1.35, 2008-03-22 01:57:09-05:00, stenn@whimsy.udel.edu +1 -1
+    Make autogen-generated files writable
+
+  ntpq/Makefile.am@1.27, 2008-03-22 01:57:10-05:00, stenn@whimsy.udel.edu +1 -1
+    Make autogen-generated files writable
+
+  sntp/Makefile.am@1.22, 2008-03-22 01:57:11-05:00, stenn@whimsy.udel.edu +1 -1
+    Make autogen-generated files writable
+
+  util/Makefile.am@1.36, 2008-03-22 01:57:11-05:00, stenn@whimsy.udel.edu +1 -1
+    Make autogen-generated files writable
+
+ChangeSet@1.1520.4.1, 2008-03-16 09:15:13-04:00, burnicki@pogo.udel.edu +2 -0
+  [Bug 957] Windows only: Let command line parameters from the Windows SCM GUI override the standard parameters from the ImagePath registry key.
+
+  ChangeLog@1.35.4.1, 2008-03-16 09:15:10-04:00, burnicki@pogo.udel.edu +3 -0
+    [Bug 957] Let command line parameters from the Windows SCM GUI override the standard parameters from the ImagePath registry key.
+
+  ports/winnt/ntpd/ntservice.c@1.10, 2008-03-16 09:15:11-04:00, burnicki@pogo.udel.edu +11 -2
+    [Bug 957] Let command line parameters from the Windows SCM GUI override the standard parameters from the ImagePath registry key.
+
+ChangeSet@1.1520.3.1, 2008-03-03 11:50:50+01:00, martin@pc-martin.py.meinberg.de +2 -0
+  [Bug 532] nptdate timeout is too long if several servers are supplied
+  [Bug 698] timeBeginPeriod is called without timeEndPeriod in some NTP tools
+  [Bug 857] ntpdate debug mode adjusts system clock when it shouldn't
+  [Bug 908] ntpdate crashes sometimes
+  [Bug 982] ntpdate(and ntptimeset) buffer overrun if HAVE_POLL_H isn't set (dup of 908)
+  [Bug 997] ntpdate buffer too small and unsafe
+  Under Windows check whether NTP port in use under same conditions as under other OSs.
+  Fixed some typos and indents (tabs/spaces).
+
+  ChangeLog@1.35.3.1, 2008-03-03 11:50:49+01:00, martin@pc-martin.py.meinberg.de +10 -0
+    [Bug 532] nptdate timeout is too long if several servers are supplied
+    [Bug 698] timeBeginPeriod is called without timeEndPeriod in some NTP tools
+    [Bug 857] ntpdate debug mode adjusts system clock when it shouldn't
+    [Bug 908] ntpdate crashes sometimes
+    [Bug 982] ntpdate(and ntptimeset) buffer overrun if HAVE_POLL_H isn't set (dup of 908)
+    [Bug 997] ntpdate buffer too small and unsafe
+    Under Windows check whether NTP port in use under same conditions as under other OSs.
+    Fixed some typos and indents (tabs/spaces).
+
+  ntpdate/ntpdate.c@1.62, 2008-03-03 11:50:49+01:00, martin@pc-martin.py.meinberg.de +101 -82
+    [Bug 532] nptdate timeout is too long if several servers are supplied
+    [Bug 698] timeBeginPeriod is called without timeEndPeriod in some NTP tools
+    [Bug 857] ntpdate debug mode adjusts system clock when it shouldn't
+    [Bug 908] ntpdate crashes sometimes
+    [Bug 982] ntpdate(and ntptimeset) buffer overrun if HAVE_POLL_H isn't set (dup of 908)
+    [Bug 997] ntpdate buffer too small and unsafe
+    Under Windows check whether NTP port in use under same conditions as under other OSs.
+    Fixed some typos and indents (tabs/spaces).
+
+ChangeSet@1.1520.2.7, 2008-02-20 12:13:24+01:00, martin@pc-martin4. +2 -0
+  [Bug 909] Define int32_t for Windows (backport from ntp-dev)
+
+  ChangeLog@1.35.2.3, 2008-02-20 12:13:24+01:00, martin@pc-martin4. +1 -0
+    [Bug 909] Define int32_t for Windows (backport from ntp-dev)
+
+  ports/winnt/include/config.h@1.47, 2008-02-20 12:13:24+01:00, martin@pc-martin4. +2 -0
+    [Bug 909] Define int32_t for Windows (backport from ntp-dev)
+
+ChangeSet@1.1520.2.6, 2008-02-19 11:08:55-05:00, burnicki@pogo.udel.edu +1 -0
+  Fixed indentation.
+
+  ntpd/ntp_io.c@1.255, 2008-02-19 11:08:52-05:00, burnicki@pogo.udel.edu +1 -1
+    Fixed indentation.
+
+ChangeSet@1.1520.2.5, 2008-02-18 09:30:34-05:00, burnicki@pogo.udel.edu +1 -0
+  Use new get_free_recv_buffer_alloc().
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.24, 2008-02-18 09:30:31-05:00, burnicki@pogo.udel.edu +4 -4
+    Use new get_free_recv_buffer_alloc().
+
+ChangeSet@1.1520.2.4, 2008-02-17 17:48:29+00:00, kardel@pogo.udel.edu +1 -0
+  recvbuff.c:
+    Bug 1000: add some pico optimizations
+
+  libntp/recvbuff.c@1.29, 2008-02-17 17:42:21+00:00, kardel@pogo.udel.edu +5 -8
+    Bug 1000: add some pico optimizations
+
+ChangeSet@1.1520.2.3, 2008-02-17 08:38:07+00:00, kardel@pogo.udel.edu +2 -0
+  ntpd.c:
+    Bug 1000: avoid timer() starvation during high load conditions
+  ChangeLog:
+    Bug 1000: additionally fix timer() starvation during high load
+
+  ChangeLog@1.35.2.2, 2008-02-17 08:37:20+00:00, kardel@pogo.udel.edu +1 -0
+    Bug 1000: additionally fix timer() starvation during high load
+
+  ntpd/ntpd.c@1.85, 2008-02-17 08:34:13+00:00, kardel@pogo.udel.edu +11 -0
+    Bug 1000: avoid timer() starvation during high load conditions
+
+ChangeSet@1.1520.2.2, 2008-02-17 08:10:59+00:00, kardel@pogo.udel.edu +1 -0
+  recvbuff.c:
+    Bug 1000: replenish when having expeirenced empty free lists
+
+  libntp/recvbuff.c@1.28, 2008-02-17 08:09:37+00:00, kardel@pogo.udel.edu +1 -1
+    Bug 1000: replenish when having expeirenced empty free lists
+
+ChangeSet@1.1520.2.1, 2008-02-17 07:31:29+00:00, kardel@pogo.udel.edu +4 -0
+  recvbuff.c, recvbuff.h, ntp_io.c, ChangeLog:
+    Bug 1000: Potentially insufficient number of receive buffers at startup
+
+  ChangeLog@1.35.2.1, 2008-02-17 07:29:23+00:00, kardel@pogo.udel.edu +3 -0
+    Bug 1000: Potentially insufficient number of receive buffers at startup
+
+  include/recvbuff.h@1.13, 2008-02-17 07:30:35+00:00, kardel@pogo.udel.edu +2 -1
+    Bug 1000: Potentially insufficient number of receive buffers at startup
+
+  libntp/recvbuff.c@1.27, 2008-02-17 07:30:09+00:00, kardel@pogo.udel.edu +30 -11
+    Bug 1000: Potentially insufficient number of receive buffers at startup
+
+  ntpd/ntp_io.c@1.254, 2008-02-17 07:30:50+00:00, kardel@pogo.udel.edu +6 -2
+    Bug 1000: Potentially insufficient number of receive buffers at startup
+
+ChangeSet@1.1520.1.1, 2008-01-26 06:43:33+00:00, kardel@pogo.udel.edu +3 -0
+  ntpdbase-opts.def, ChangeLog, cmd_args.c:
+    remove minimum interface update interval restriction
+
+  ChangeLog@1.35.1.1, 2008-01-26 06:42:11+00:00, kardel@pogo.udel.edu +2 -0
+    remove minimum interface update interval restriction
+
+  ntpd/cmd_args.c@1.48, 2008-01-26 06:42:47+00:00, kardel@pogo.udel.edu +2 -2
+    remove minimum interface update interval restriction
+
+  ntpd/ntpdbase-opts.def@1.11, 2008-01-26 06:43:10+00:00, kardel@pogo.udel.edu +1 -1
+    remove minimum interface update interval restriction
+
+ChangeSet@1.1523, 2007-11-01 03:52:00-04:00, clemens@pogo.udel.edu +1 -0
+  *          Negative-sawtooth not applied correctly for oncore 12 channel
+             receiver. Fixed.
+  *          Startup code for original LinuxPPS removed.  LinuxPPS now
+             conforms to the PPSAPI.
+
+  ChangeLog@1.36, 2007-11-01 03:51:58-04:00, clemens@pogo.udel.edu +4 -0
+    *          Negative-sawtooth not applied correctly for oncore 12 channel
+               receiver. Fixed.
+    *          Startup code for original LinuxPPS removed.  LinuxPPS now
+               conforms to the PPSAPI.
+
+ChangeSet@1.1522, 2007-11-01 03:29:24-04:00, clemens@pogo.udel.edu +1 -0
+  The original version of LinuxPPS did not comply with the PPSAPI and required
+  some changes to the startup code in refclock_oncore.c .  The current version
+  complies, and these changes can be removed.
+
+  ntpd/refclock_oncore.c@1.62, 2007-11-01 03:29:21-04:00, clemens@pogo.udel.edu +1 -56
+    The original version of LinuxPPS did not comply with the PPSAPI and required
+    some changes to the startup code in refclock_oncore.c .  The current version
+    complies, and these changes can be removed.
+
+ChangeSet@1.1521, 2007-11-01 02:16:36-04:00, clemens@pogo.udel.edu +1 -0
+  The oncore hardware provides a 'negative saw-tooth' the offset of the PPS signal
+  which is on the zero crossing of its internal clock, from its true value.  the
+  refclock_oncore.c driver applies this difference to correct the time of the
+  provided timestamp.  This value was being applied correctly for the 6 and 8 channel
+  receivers, but not for the 12 channel.  This has been corrected.
+
+  ntpd/refclock_oncore.c@1.61, 2007-11-01 02:16:33-04:00, clemens@pogo.udel.edu +2 -2
+    The oncore hardware provides a 'negative saw-tooth' the offset of the PPS signal
+    which is on the zero crossing of its internal clock, from its true value.  the
+    refclock_oncore.c driver applies this difference to correct the time of the
+    provided timestamp.  This value was being applied correctly for the 6 and 8 channel
+    receivers, but not for the 12 channel.  This has been corrected.
+
+ChangeSet@1.1520, 2007-09-10 20:40:19-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P4
+  TAG: NTP_4_2_4P4
+
+  ntpd/ntpd-opts.c@1.71, 2007-09-10 20:39:55-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  ntpd/ntpd-opts.h@1.71, 2007-09-10 20:39:56-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4
+
+  ntpd/ntpd-opts.texi@1.70, 2007-09-10 20:39:57-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4
+
+  ntpd/ntpd.1@1.69, 2007-09-10 20:39:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  ntpd/ntpdsim-opts.c@1.71, 2007-09-10 20:39:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  ntpd/ntpdsim-opts.h@1.71, 2007-09-10 20:39:58-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4
+
+  ntpd/ntpdsim-opts.texi@1.69, 2007-09-10 20:40:00-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4
+
+  ntpd/ntpdsim.1@1.69, 2007-09-10 20:40:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  ntpdc/ntpdc-opts.c@1.71, 2007-09-10 20:40:01-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  ntpdc/ntpdc-opts.h@1.71, 2007-09-10 20:40:02-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4
+
+  ntpdc/ntpdc-opts.texi@1.69, 2007-09-10 20:40:03-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4
+
+  ntpdc/ntpdc.1@1.69, 2007-09-10 20:40:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  ntpq/ntpq-opts.c@1.73, 2007-09-10 20:40:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  ntpq/ntpq-opts.h@1.73, 2007-09-10 20:40:05-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4
+
+  ntpq/ntpq-opts.texi@1.70, 2007-09-10 20:40:06-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4
+
+  ntpq/ntpq.1@1.69, 2007-09-10 20:40:06-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  packageinfo.sh@1.96, 2007-09-10 20:40:07-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  sntp/sntp-opts.c@1.69, 2007-09-10 20:40:08-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  sntp/sntp-opts.h@1.69, 2007-09-10 20:40:08-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4
+
+  sntp/sntp-opts.texi@1.66, 2007-09-10 20:40:09-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4
+
+  sntp/sntp.1@1.69, 2007-09-10 20:40:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  util/ntp-keygen-opts.c@1.70, 2007-09-10 20:40:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+  util/ntp-keygen-opts.h@1.70, 2007-09-10 20:40:12-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4
+
+  util/ntp-keygen-opts.texi@1.68, 2007-09-10 20:40:13-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4
+
+  util/ntp-keygen.1@1.68, 2007-09-10 20:40:14-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4
+
+ChangeSet@1.1519, 2007-09-10 16:56:09-04:00, stenn@whimsy.udel.edu +3 -0
+  Release 4.2.4p4
+
+  ChangeLog@1.35, 2007-09-10 16:55:51-04:00, stenn@whimsy.udel.edu +3 -0
+    Release 4.2.4p4
+
+  NEWS@1.98, 2007-09-10 16:55:54-04:00, stenn@whimsy.udel.edu +11 -0
+    Release 4.2.4p4
+
+  packageinfo.sh@1.95, 2007-09-10 16:55:58-04:00, stenn@whimsy.udel.edu +1 -1
+    Release 4.2.4p4
+
+ChangeSet@1.1518, 2007-09-10 01:57:20-04:00, stenn@whimsy.udel.edu +3 -0
+  [Bug 902] Fix problems with the -6 flag
+
+  ChangeLog@1.34, 2007-09-10 01:57:02-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 902] Fix problems with the -6 flag
+
+  libopts/save.c@1.2, 2007-09-10 01:57:02-04:00, stenn@whimsy.udel.edu +11 -2
+    [Bug 902] Fix problems with the -6 flag
+
+  sntp/libopts/save.c@1.2, 2007-09-10 01:57:03-04:00, stenn@whimsy.udel.edu +11 -2
+    [Bug 902] Fix problems with the -6 flag
+
+ChangeSet@1.1517, 2007-08-28 15:34:55-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P4_RC2
+  TAG: NTP_4_2_4P4_RC2
+
+  ntpd/ntpd-opts.c@1.70, 2007-08-28 15:34:28-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P4_RC2
+
+  ntpd/ntpd-opts.h@1.70, 2007-08-28 15:34:29-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P4_RC2
+
+  ntpd/ntpd-opts.texi@1.69, 2007-08-28 15:34:31-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC2
+
+  ntpd/ntpd.1@1.68, 2007-08-28 15:34:32-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC2
+
+  ntpd/ntpdsim-opts.c@1.70, 2007-08-28 15:34:32-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P4_RC2
+
+  ntpd/ntpdsim-opts.h@1.70, 2007-08-28 15:34:33-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P4_RC2
+
+  ntpd/ntpdsim-opts.texi@1.68, 2007-08-28 15:34:34-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4_RC2
+
+  ntpd/ntpdsim.1@1.68, 2007-08-28 15:34:34-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC2
+
+  ntpdc/ntpdc-opts.c@1.70, 2007-08-28 15:34:35-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P4_RC2
+
+  ntpdc/ntpdc-opts.h@1.70, 2007-08-28 15:34:36-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P4_RC2
+
+  ntpdc/ntpdc-opts.texi@1.68, 2007-08-28 15:34:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC2
+
+  ntpdc/ntpdc.1@1.68, 2007-08-28 15:34:38-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC2
+
+  ntpq/ntpq-opts.c@1.72, 2007-08-28 15:34:38-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P4_RC2
+
+  ntpq/ntpq-opts.h@1.72, 2007-08-28 15:34:39-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P4_RC2
+
+  ntpq/ntpq-opts.texi@1.69, 2007-08-28 15:34:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC2
+
+  ntpq/ntpq.1@1.68, 2007-08-28 15:34:41-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC2
+
+  packageinfo.sh@1.94, 2007-08-28 15:34:41-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4_RC2
+
+  sntp/sntp-opts.c@1.68, 2007-08-28 15:34:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC2
+
+  sntp/sntp-opts.h@1.68, 2007-08-28 15:34:43-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC2
+
+  sntp/sntp-opts.texi@1.65, 2007-08-28 15:34:44-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4_RC2
+
+  sntp/sntp.1@1.68, 2007-08-28 15:34:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC2
+
+  util/ntp-keygen-opts.c@1.69, 2007-08-28 15:34:45-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P4_RC2
+
+  util/ntp-keygen-opts.h@1.69, 2007-08-28 15:34:46-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P4_RC2
+
+  util/ntp-keygen-opts.texi@1.67, 2007-08-28 15:34:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC2
+
+  util/ntp-keygen.1@1.67, 2007-08-28 15:34:48-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC2
+
+ChangeSet@1.1516, 2007-08-27 22:38:57-04:00, stenn@whimsy.udel.edu +2 -0
+  Updated include/copyright.def (owner and year)
+
+  ChangeLog@1.33, 2007-08-27 22:38:46-04:00, stenn@whimsy.udel.edu +1 -0
+    Updated include/copyright.def (owner and year)
+
+  include/copyright.def@1.5, 2007-08-27 22:38:47-04:00, stenn@whimsy.udel.edu +2 -2
+    Updated include/copyright.def (owner and year)
+
+ChangeSet@1.1515, 2007-08-19 05:26:13-04:00, dunlop@pogo.udel.edu +2 -0
+  ntpdc_ops.c, ChangeLog:
+    [BUG 881] Corrected display of pll offset on 64bit systems.
+    [BUG 886] Corrected sign extension of il->compliance on 64 bit systems
+    [BUG 878] Avoid ntpdc use of refid value as unterminated string.
+
+  ChangeLog@1.32, 2007-08-19 05:20:42-04:00, dunlop@pogo.udel.edu +1 -0
+    [Bug 878] Avoid ntpdc use of refid value as unterminated string.
+
+  ChangeLog@1.31, 2007-08-19 05:13:18-04:00, dunlop@pogo.udel.edu +1 -0
+    [Bug 881] Corrected display of pll offset on 64bit systems.
+
+  ChangeLog@1.30, 2007-08-19 05:01:14-04:00, dunlop@pogo.udel.edu +1 -0
+    [BUG 886] Corrected sign extension of il->compliance on 64 bit systems
+
+  ntpdc/ntpdc_ops.c@1.49, 2007-08-19 05:20:34-04:00, dunlop@pogo.udel.edu +1 -3
+    [Bug 878] Avoid ntpdc use of refid value as unterminated string.
+
+  ntpdc/ntpdc_ops.c@1.48, 2007-08-19 05:12:52-04:00, dunlop@pogo.udel.edu +1 -1
+    [Bug 881] Corrected display of pll offset on 64bit systems.
+
+  ntpdc/ntpdc_ops.c@1.47, 2007-08-19 04:59:48-04:00, dunlop@pogo.udel.edu +2 -2
+    [BUG 886] Corrected sign extension of il->compliance on 64 bit systems
+
+ChangeSet@1.1514, 2007-08-18 17:11:19-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P4_RC1
+  TAG: NTP_4_2_4P4_RC1
+
+  ntpd/ntpd-opts.c@1.69, 2007-08-18 17:10:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  ntpd/ntpd-opts.h@1.69, 2007-08-18 17:10:52-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC1
+
+  ntpd/ntpd-opts.texi@1.68, 2007-08-18 17:10:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  ntpd/ntpd.1@1.67, 2007-08-18 17:10:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  ntpd/ntpdsim-opts.c@1.69, 2007-08-18 17:10:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  ntpd/ntpdsim-opts.h@1.69, 2007-08-18 17:10:54-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC1
+
+  ntpd/ntpdsim-opts.texi@1.67, 2007-08-18 17:10:56-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4_RC1
+
+  ntpd/ntpdsim.1@1.67, 2007-08-18 17:10:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  ntpdc/ntpdc-opts.c@1.69, 2007-08-18 17:10:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  ntpdc/ntpdc-opts.h@1.69, 2007-08-18 17:10:57-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC1
+
+  ntpdc/ntpdc-opts.texi@1.67, 2007-08-18 17:10:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  ntpdc/ntpdc.1@1.67, 2007-08-18 17:10:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  ntpq/ntpq-opts.c@1.71, 2007-08-18 17:10:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  ntpq/ntpq-opts.h@1.71, 2007-08-18 17:11:01-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC1
+
+  ntpq/ntpq-opts.texi@1.68, 2007-08-18 17:11:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  ntpq/ntpq.1@1.67, 2007-08-18 17:11:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  packageinfo.sh@1.93, 2007-08-18 17:11:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  sntp/sntp-opts.c@1.67, 2007-08-18 17:11:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  sntp/sntp-opts.h@1.67, 2007-08-18 17:11:05-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC1
+
+  sntp/sntp-opts.texi@1.64, 2007-08-18 17:11:07-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P4_RC1
+
+  sntp/sntp.1@1.67, 2007-08-18 17:11:08-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  util/ntp-keygen-opts.c@1.68, 2007-08-18 17:11:08-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  util/ntp-keygen-opts.h@1.68, 2007-08-18 17:11:10-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P4_RC1
+
+  util/ntp-keygen-opts.texi@1.66, 2007-08-18 17:11:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+  util/ntp-keygen.1@1.66, 2007-08-18 17:11:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P4_RC1
+
+ChangeSet@1.1513, 2007-08-18 16:16:22-04:00, stenn@whimsy.udel.edu +1 -0
+  4.2.4p4-RC
+
+  packageinfo.sh@1.92, 2007-08-18 16:16:06-04:00, stenn@whimsy.udel.edu +1 -1
+    4.2.4p4-RC
+
+ChangeSet@1.1512, 2007-08-18 12:59:45+00:00, kardel@pogo.udel.edu +2 -0
+  ntp_restrict.c:
+    Bug 885: clarify to allow tools to pick up
+    invariants easier.
+    Use NULL instead of 0 with pointers.
+  ChangeLog:
+    document ntp_restrict.c change
+
+  ChangeLog@1.29, 2007-08-18 12:59:05+00:00, kardel@pogo.udel.edu +1 -0
+    document ntp_restrict.c change
+
+  ntpd/ntp_restrict.c@1.23, 2007-08-18 12:56:40+00:00, kardel@pogo.udel.edu +21 -21
+    Bug 885: clarify to allow tools to pick up
+    invariants easier.
+    Use NULL instead of 0 with pointers.
+
+ChangeSet@1.1511, 2007-08-18 12:53:35+00:00, kardel@pogo.udel.edu +2 -0
+  recvbuff.c:
+    Bug 889: avoid malloc() interrupted by SIGIO risk
+  ChangeLog:
+    document Bug 889
+
+  ChangeLog@1.28, 2007-08-18 12:52:19+00:00, kardel@pogo.udel.edu +1 -0
+    document Bug 889
+
+  libntp/recvbuff.c@1.26, 2007-08-18 12:49:27+00:00, kardel@pogo.udel.edu +28 -21
+    Bug 889: avoid malloc() interrupted by SIGIO risk
+
+ChangeSet@1.1510, 2007-08-18 09:51:41+00:00, kardel@pogo.udel.edu +1 -0
+  cmd_args.c:
+    Bug 885: fix comparison
+
+  ntpd/cmd_args.c@1.47, 2007-08-18 09:50:28+00:00, kardel@pogo.udel.edu +1 -1
+    Bug 885: fix comparison
+
+ChangeSet@1.1502.1.1, 2007-08-17 05:28:07-04:00, stenn@pogo.udel.edu +1 -0
+  Use autoconf-2.59 and automake-1.9 for building 4.2.4
+
+  bootstrap@1.19, 2007-08-17 05:27:51-04:00, stenn@pogo.udel.edu +18 -2
+    Use autoconf-2.59 and automake-1.9 for building 4.2.4
+
+ChangeSet@1.1508, 2007-08-11 17:32:22+00:00, kardel@pogo.udel.edu +1 -0
+  ChangeLog:
+    document refclock_parse.c fix
+
+  ChangeLog@1.27, 2007-08-11 17:31:30+00:00, kardel@pogo.udel.edu +1 -0
+    document refclock_parse.c fix
+
+ChangeSet@1.1507, 2007-08-11 17:30:42+00:00, kardel@pogo.udel.edu +4 -0
+  ChangeLog:
+    document Bug 885
+  ntp_io.c:
+    Bug 885: use emalloc() to get a message at the end of the memory
+  cmd_args.c:
+    Bug 885: unsigned types cannot be less than 0
+        default_ai_family is a short
+  ntp_config.c:
+    Bug 885: lose trailing , from enum list
+
+  ChangeLog@1.26, 2007-08-11 17:30:24+00:00, kardel@pogo.udel.edu +4 -0
+    document Bug 885
+
+  ntpd/cmd_args.c@1.46, 2007-08-11 17:19:51+00:00, kardel@pogo.udel.edu +2 -2
+    Bug 885: unsigned types cannot be less than 0
+        default_ai_family is a short
+
+  ntpd/ntp_config.c@1.142, 2007-08-11 17:20:52+00:00, kardel@pogo.udel.edu +1 -1
+    Bug 885: lose trailing , from enum list
+
+  ntpd/ntp_io.c@1.253, 2007-08-11 17:21:17+00:00, kardel@pogo.udel.edu +1 -1
+    Bug 885: use emalloc() to get a message at the end of the memory
+
+ChangeSet@1.1506, 2007-08-11 17:19:45+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    remove io binding before io_closeclock() closes the file descriptor
+
+  ntpd/refclock_parse.c@1.48, 2007-08-11 17:17:16+00:00, kardel@pogo.udel.edu +25 -10
+    remove io binding before io_closeclock() closes the file descriptor
+
+ChangeSet@1.1505, 2007-08-09 20:30:55+00:00, kardel@pogo.udel.edu +1 -0
+  ChangeLog:
+    [Bug 882] allow loopback interfaces to share addresses with other interfaces.
+    [Bug 884] don't access recv buffers after having them passed to the free list.
+
+  ChangeLog@1.25, 2007-08-09 20:30:26+00:00, kardel@pogo.udel.edu +3 -0
+    [Bug 882] allow loopback interfaces to share addresses with other interfaces.
+    [Bug 884] don't access recv buffers after having them passed to the free list.
+
+ChangeSet@1.1504, 2007-08-09 19:05:17+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    Bug 884: no access to recv buffers after they are returned to free pool
+
+  ntpd/ntp_io.c@1.252, 2007-08-09 19:01:30+00:00, kardel@pogo.udel.edu +9 -7
+    Bug 884: no access to recv buffers after they are returned to free pool
+
+ChangeSet@1.1503, 2007-08-07 18:14:16+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    Bug 882: loopback interfaces may share IP addresses with other interfaces
+        thus allow addresses also found on loopback interfaces to be used
+        as local address.
+
+  ntpd/ntp_io.c@1.251, 2007-08-07 18:09:50+00:00, kardel@pogo.udel.edu +1 -1
+    Bug 882: loopback interfaces may share IP addresses with other interfaces
+        thus allow addresses also found on loopback interfaces to be used
+        as local address.
+
+ChangeSet@1.1502, 2007-06-29 15:46:00-04:00, stenn@deacon.udel.edu +25 -0
+  NTP_4_2_4P3
+  TAG: NTP_4_2_4P3
+
+  ntpd/ntpd-opts.c@1.68, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  ntpd/ntpd-opts.h@1.68, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +3 -3
+    NTP_4_2_4P3
+
+  ntpd/ntpd-opts.texi@1.67, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  ntpd/ntpd.1@1.66, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  ntpd/ntpdsim-opts.c@1.68, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  ntpd/ntpdsim-opts.h@1.68, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +3 -3
+    NTP_4_2_4P3
+
+  ntpd/ntpdsim-opts.texi@1.66, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +1 -1
+    NTP_4_2_4P3
+
+  ntpd/ntpdsim.1@1.66, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  ntpdc/ntpdc-opts.c@1.68, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  ntpdc/ntpdc-opts.h@1.68, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +3 -3
+    NTP_4_2_4P3
+
+  ntpdc/ntpdc-opts.texi@1.66, 2007-06-29 15:45:58-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  ntpdc/ntpdc.1@1.66, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  ntpq/ntpq-opts.c@1.70, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  ntpq/ntpq-opts.h@1.70, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +3 -3
+    NTP_4_2_4P3
+
+  ntpq/ntpq-opts.texi@1.67, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  ntpq/ntpq.1@1.66, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  packageinfo.sh@1.91, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  sntp/sntp-opts.c@1.66, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  sntp/sntp-opts.h@1.66, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +3 -3
+    NTP_4_2_4P3
+
+  sntp/sntp-opts.texi@1.63, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +1 -1
+    NTP_4_2_4P3
+
+  sntp/sntp.1@1.66, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  util/ntp-keygen-opts.c@1.67, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  util/ntp-keygen-opts.h@1.67, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +3 -3
+    NTP_4_2_4P3
+
+  util/ntp-keygen-opts.texi@1.65, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+  util/ntp-keygen.1@1.65, 2007-06-29 15:45:59-04:00, stenn@deacon.udel.edu +2 -2
+    NTP_4_2_4P3
+
+ChangeSet@1.1501, 2007-06-29 15:31:21-04:00, stenn@deacon.udel.edu +3 -0
+  Release 4.2.4p3
+
+  ChangeLog@1.24, 2007-06-29 15:30:58-04:00, stenn@deacon.udel.edu +1 -1
+    Release 4.2.4p3
+
+  NEWS@1.97, 2007-06-29 15:30:58-04:00, stenn@deacon.udel.edu +1 -1
+    Release 4.2.4p3
+
+  packageinfo.sh@1.90, 2007-06-29 15:30:58-04:00, stenn@deacon.udel.edu +1 -1
+    Release 4.2.4p3
+
+ChangeSet@1.1500, 2007-06-29 19:03:39+00:00, stenn@ntp1.isc.org +2 -0
+  Cosmetic reformatting
+
+  ChangeLog@1.23, 2007-06-29 19:03:32+00:00, stenn@ntp1.isc.org +70 -16
+    Cosmetic reformatting
+
+  NEWS@1.96, 2007-06-29 19:03:32+00:00, stenn@ntp1.isc.org +4 -0
+    Cosmetic reformatting
+
+ChangeSet@1.1499, 2007-06-27 07:46:44-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P3_RC1
+  TAG: NTP_4_2_4P3_RC1
+
+  ntpd/ntpd-opts.c@1.67, 2007-06-27 07:46:22-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  ntpd/ntpd-opts.h@1.67, 2007-06-27 07:46:23-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P3_RC1
+
+  ntpd/ntpd-opts.texi@1.66, 2007-06-27 07:46:24-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  ntpd/ntpd.1@1.65, 2007-06-27 07:46:24-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  ntpd/ntpdsim-opts.c@1.67, 2007-06-27 07:46:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  ntpd/ntpdsim-opts.h@1.67, 2007-06-27 07:46:26-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P3_RC1
+
+  ntpd/ntpdsim-opts.texi@1.65, 2007-06-27 07:46:27-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P3_RC1
+
+  ntpd/ntpdsim.1@1.65, 2007-06-27 07:46:28-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  ntpdc/ntpdc-opts.c@1.67, 2007-06-27 07:46:29-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  ntpdc/ntpdc-opts.h@1.67, 2007-06-27 07:46:29-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P3_RC1
+
+  ntpdc/ntpdc-opts.texi@1.65, 2007-06-27 07:46:30-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  ntpdc/ntpdc.1@1.65, 2007-06-27 07:46:31-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  ntpq/ntpq-opts.c@1.69, 2007-06-27 07:46:31-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  ntpq/ntpq-opts.h@1.69, 2007-06-27 07:46:32-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P3_RC1
+
+  ntpq/ntpq-opts.texi@1.66, 2007-06-27 07:46:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  ntpq/ntpq.1@1.65, 2007-06-27 07:46:34-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  packageinfo.sh@1.89, 2007-06-27 07:46:34-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  sntp/sntp-opts.c@1.65, 2007-06-27 07:46:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  sntp/sntp-opts.h@1.65, 2007-06-27 07:46:36-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P3_RC1
+
+  sntp/sntp-opts.texi@1.62, 2007-06-27 07:46:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P3_RC1
+
+  sntp/sntp.1@1.65, 2007-06-27 07:46:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  util/ntp-keygen-opts.c@1.66, 2007-06-27 07:46:38-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  util/ntp-keygen-opts.h@1.66, 2007-06-27 07:46:39-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P3_RC1
+
+  util/ntp-keygen-opts.texi@1.64, 2007-06-27 07:46:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+  util/ntp-keygen.1@1.64, 2007-06-27 07:46:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P3_RC1
+
+ChangeSet@1.1498, 2007-06-27 01:42:30-04:00, stenn@whimsy.udel.edu +3 -0
+  First RC for 4.2.4p3
+
+  ChangeLog@1.22, 2007-06-27 01:41:43-04:00, stenn@whimsy.udel.edu +2 -1
+    First RC for 4.2.4p3
+
+  NEWS@1.95, 2007-06-27 01:41:46-04:00, stenn@whimsy.udel.edu +8 -0
+    First RC for 4.2.4p3
+
+  packageinfo.sh@1.88, 2007-06-27 01:41:59-04:00, stenn@whimsy.udel.edu +1 -1
+    First RC for 4.2.4p3
+
+ChangeSet@1.1497, 2007-06-23 08:47:07-04:00, mayer@pogo.udel.edu +1 -0
+  Added Bug #863
+
+  ChangeLog@1.21, 2007-06-23 08:46:51-04:00, mayer@pogo.udel.edu +2 -0
+    Added Bug #863
+
+ChangeSet@1.1492.1.1, 2007-06-23 08:42:58-04:00, mayer@pogo.udel.edu +3 -0
+  Bug #863 Unable to stop ntpd because the handle index changed
+
+  ports/winnt/include/ntp_iocompletionport.h@1.13, 2007-06-23 08:42:41-04:00, mayer@pogo.udel.edu +3 -0
+    Bug #863 Unable to stop ntpd because the handle index changed
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.23, 2007-06-23 08:42:41-04:00, mayer@pogo.udel.edu +15 -1
+    Bug #863 Unable to stop ntpd because the handle index changed
+
+  ports/winnt/ntpd/ntservice.c@1.9, 2007-06-23 08:42:41-04:00, mayer@pogo.udel.edu +9 -5
+    Bug #863 Unable to stop ntpd because the handle index changed
+
+ChangeSet@1.1495, 2007-06-20 07:45:57-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P2
+  TAG: NTP_4_2_4P2
+
+  ntpd/ntpd-opts.c@1.66, 2007-06-20 07:45:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  ntpd/ntpd-opts.h@1.66, 2007-06-20 07:45:33-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2
+
+  ntpd/ntpd-opts.texi@1.65, 2007-06-20 07:45:34-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P2
+
+  ntpd/ntpd.1@1.64, 2007-06-20 07:45:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  ntpd/ntpdsim-opts.c@1.66, 2007-06-20 07:45:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  ntpd/ntpdsim-opts.h@1.66, 2007-06-20 07:45:36-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2
+
+  ntpd/ntpdsim-opts.texi@1.64, 2007-06-20 07:45:37-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2
+
+  ntpd/ntpdsim.1@1.64, 2007-06-20 07:45:38-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  ntpdc/ntpdc-opts.c@1.66, 2007-06-20 07:45:39-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  ntpdc/ntpdc-opts.h@1.66, 2007-06-20 07:45:39-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2
+
+  ntpdc/ntpdc-opts.texi@1.64, 2007-06-20 07:45:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  ntpdc/ntpdc.1@1.64, 2007-06-20 07:45:41-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  ntpq/ntpq-opts.c@1.68, 2007-06-20 07:45:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  ntpq/ntpq-opts.h@1.68, 2007-06-20 07:45:43-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2
+
+  ntpq/ntpq-opts.texi@1.65, 2007-06-20 07:45:43-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  ntpq/ntpq.1@1.64, 2007-06-20 07:45:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  packageinfo.sh@1.87, 2007-06-20 07:45:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  sntp/sntp-opts.c@1.64, 2007-06-20 07:45:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  sntp/sntp-opts.h@1.64, 2007-06-20 07:45:47-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2
+
+  sntp/sntp-opts.texi@1.61, 2007-06-20 07:45:47-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2
+
+  sntp/sntp.1@1.64, 2007-06-20 07:45:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  util/ntp-keygen-opts.c@1.65, 2007-06-20 07:45:49-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  util/ntp-keygen-opts.h@1.65, 2007-06-20 07:45:50-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2
+
+  util/ntp-keygen-opts.texi@1.63, 2007-06-20 07:45:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+  util/ntp-keygen.1@1.63, 2007-06-20 07:45:52-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2
+
+ChangeSet@1.1494, 2007-06-20 04:07:34-04:00, stenn@deacon.udel.edu +3 -0
+  4.2.4p2
+
+  ChangeLog@1.20, 2007-06-20 04:07:25-04:00, stenn@deacon.udel.edu +1 -0
+    4.2.4p2
+
+  NEWS@1.94, 2007-06-20 04:07:25-04:00, stenn@deacon.udel.edu +8 -13
+    4.2.4p2
+
+  packageinfo.sh@1.86, 2007-06-20 04:07:26-04:00, stenn@deacon.udel.edu +1 -1
+    4.2.4p2
+
+ChangeSet@1.1493, 2007-06-10 07:58:59-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P2_RC6
+  TAG: NTP_4_2_4P2_RC6
+
+  ntpd/ntpd-opts.c@1.65, 2007-06-10 07:58:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  ntpd/ntpd-opts.h@1.65, 2007-06-10 07:58:37-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC6
+
+  ntpd/ntpd-opts.texi@1.64, 2007-06-10 07:58:38-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC6
+
+  ntpd/ntpd.1@1.63, 2007-06-10 07:58:39-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  ntpd/ntpdsim-opts.c@1.65, 2007-06-10 07:58:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  ntpd/ntpdsim-opts.h@1.65, 2007-06-10 07:58:41-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC6
+
+  ntpd/ntpdsim-opts.texi@1.63, 2007-06-10 07:58:41-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC6
+
+  ntpd/ntpdsim.1@1.63, 2007-06-10 07:58:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  ntpdc/ntpdc-opts.c@1.65, 2007-06-10 07:58:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  ntpdc/ntpdc-opts.h@1.65, 2007-06-10 07:58:43-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC6
+
+  ntpdc/ntpdc-opts.texi@1.63, 2007-06-10 07:58:44-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC6
+
+  ntpdc/ntpdc.1@1.63, 2007-06-10 07:58:44-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  ntpq/ntpq-opts.c@1.67, 2007-06-10 07:58:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  ntpq/ntpq-opts.h@1.67, 2007-06-10 07:58:46-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC6
+
+  ntpq/ntpq-opts.texi@1.64, 2007-06-10 07:58:46-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC6
+
+  ntpq/ntpq.1@1.63, 2007-06-10 07:58:47-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  packageinfo.sh@1.85, 2007-06-10 07:58:48-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC6
+
+  sntp/sntp-opts.c@1.63, 2007-06-10 07:58:49-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  sntp/sntp-opts.h@1.63, 2007-06-10 07:58:50-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC6
+
+  sntp/sntp-opts.texi@1.60, 2007-06-10 07:58:50-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC6
+
+  sntp/sntp.1@1.63, 2007-06-10 07:58:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  util/ntp-keygen-opts.c@1.64, 2007-06-10 07:58:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+  util/ntp-keygen-opts.h@1.64, 2007-06-10 07:58:52-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC6
+
+  util/ntp-keygen-opts.texi@1.62, 2007-06-10 07:58:53-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC6
+
+  util/ntp-keygen.1@1.62, 2007-06-10 07:58:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC6
+
+ChangeSet@1.1492, 2007-06-07 09:28:16-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #854 Broadcast address was not correctly set for interface addresses
+
+  ChangeLog@1.19, 2007-06-07 09:28:05-04:00, mayer@pogo.udel.edu +1 -0
+    Bug #854 Broadcast address was not correctly set for interface addresses
+
+ChangeSet@1.1491, 2007-06-07 09:25:17-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #854 Broadcast address was not correctly set for interface addresses
+
+  ports/winnt/libisc/interfaceiter.c@1.7, 2007-06-07 09:24:57-04:00, mayer@pogo.udel.edu +35 -13
+    Bug #854 Broadcast address was not correctly set for interface addresses
+
+ChangeSet@1.1490, 2007-05-29 07:43:58-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P2_RC5
+  TAG: NTP_4_2_4P2_RC5
+
+  ntpd/ntpd-opts.c@1.64, 2007-05-29 07:43:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  ntpd/ntpd-opts.h@1.64, 2007-05-29 07:43:35-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC5
+
+  ntpd/ntpd-opts.texi@1.63, 2007-05-29 07:43:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC5
+
+  ntpd/ntpd.1@1.62, 2007-05-29 07:43:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  ntpd/ntpdsim-opts.c@1.64, 2007-05-29 07:43:38-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  ntpd/ntpdsim-opts.h@1.64, 2007-05-29 07:43:39-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC5
+
+  ntpd/ntpdsim-opts.texi@1.62, 2007-05-29 07:43:40-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC5
+
+  ntpd/ntpdsim.1@1.62, 2007-05-29 07:43:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  ntpdc/ntpdc-opts.c@1.64, 2007-05-29 07:43:41-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  ntpdc/ntpdc-opts.h@1.64, 2007-05-29 07:43:42-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC5
+
+  ntpdc/ntpdc-opts.texi@1.62, 2007-05-29 07:43:43-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC5
+
+  ntpdc/ntpdc.1@1.62, 2007-05-29 07:43:43-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  ntpq/ntpq-opts.c@1.66, 2007-05-29 07:43:44-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  ntpq/ntpq-opts.h@1.66, 2007-05-29 07:43:45-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC5
+
+  ntpq/ntpq-opts.texi@1.63, 2007-05-29 07:43:45-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC5
+
+  ntpq/ntpq.1@1.62, 2007-05-29 07:43:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  packageinfo.sh@1.84, 2007-05-29 07:43:47-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC5
+
+  sntp/sntp-opts.c@1.62, 2007-05-29 07:43:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  sntp/sntp-opts.h@1.62, 2007-05-29 07:43:49-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC5
+
+  sntp/sntp-opts.texi@1.59, 2007-05-29 07:43:49-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC5
+
+  sntp/sntp.1@1.62, 2007-05-29 07:43:50-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  util/ntp-keygen-opts.c@1.63, 2007-05-29 07:43:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+  util/ntp-keygen-opts.h@1.63, 2007-05-29 07:43:52-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC5
+
+  util/ntp-keygen-opts.texi@1.61, 2007-05-29 07:43:53-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC5
+
+  util/ntp-keygen.1@1.61, 2007-05-29 07:43:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC5
+
+ChangeSet@1.1489, 2007-05-29 01:32:29-04:00, stenn@whimsy.udel.edu +2 -0
+  typo cleanup
+
+  ChangeLog@1.18, 2007-05-29 01:32:14-04:00, stenn@whimsy.udel.edu +1 -1
+    typo cleanup
+
+  NEWS@1.93, 2007-05-29 01:32:15-04:00, stenn@whimsy.udel.edu +1 -2
+    typo cleanup
+
+ChangeSet@1.1488, 2007-05-28 10:00:27+00:00, kardel@pogo.udel.edu +3 -0
+  NEWS, ntp_io.c, ChangeLog:
+    Bug 829: reduce syslog noise, while there fix Enabled/Disable logging
+    to reflect the actual configuration
+
+  ChangeLog@1.17, 2007-05-28 09:54:40+00:00, kardel@pogo.udel.edu +2 -0
+    Bug 829: reduce syslog noise, while there fix Enabled/Disable logging
+    to reflect the actual configuration
+
+  NEWS@1.92, 2007-05-28 09:55:04+00:00, kardel@pogo.udel.edu +3 -0
+    Bug 829: reduce syslog noise, while there fix Enabled/Disable logging
+    to reflect the actual configuration
+
+  ntpd/ntp_io.c@1.250, 2007-05-28 09:59:44+00:00, kardel@pogo.udel.edu +58 -44
+    Bug 829: reduce syslog noise, while there fix Enabled/Disable logging
+    to reflect the actual configuration
+
+ChangeSet@1.1487, 2007-05-27 07:45:05-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P2_RC4
+  TAG: NTP_4_2_4P2_RC4
+
+  ntpd/ntpd-opts.c@1.63, 2007-05-27 07:44:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  ntpd/ntpd-opts.h@1.63, 2007-05-27 07:44:40-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC4
+
+  ntpd/ntpd-opts.texi@1.62, 2007-05-27 07:44:41-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC4
+
+  ntpd/ntpd.1@1.61, 2007-05-27 07:44:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  ntpd/ntpdsim-opts.c@1.63, 2007-05-27 07:44:43-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  ntpd/ntpdsim-opts.h@1.63, 2007-05-27 07:44:44-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC4
+
+  ntpd/ntpdsim-opts.texi@1.61, 2007-05-27 07:44:45-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC4
+
+  ntpd/ntpdsim.1@1.61, 2007-05-27 07:44:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  ntpdc/ntpdc-opts.c@1.63, 2007-05-27 07:44:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  ntpdc/ntpdc-opts.h@1.63, 2007-05-27 07:44:47-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC4
+
+  ntpdc/ntpdc-opts.texi@1.61, 2007-05-27 07:44:48-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC4
+
+  ntpdc/ntpdc.1@1.61, 2007-05-27 07:44:49-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  ntpq/ntpq-opts.c@1.65, 2007-05-27 07:44:50-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  ntpq/ntpq-opts.h@1.65, 2007-05-27 07:44:50-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC4
+
+  ntpq/ntpq-opts.texi@1.62, 2007-05-27 07:44:51-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC4
+
+  ntpq/ntpq.1@1.61, 2007-05-27 07:44:52-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  packageinfo.sh@1.83, 2007-05-27 07:44:52-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC4
+
+  sntp/sntp-opts.c@1.61, 2007-05-27 07:44:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  sntp/sntp-opts.h@1.61, 2007-05-27 07:44:54-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC4
+
+  sntp/sntp-opts.texi@1.58, 2007-05-27 07:44:55-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC4
+
+  sntp/sntp.1@1.61, 2007-05-27 07:44:55-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  util/ntp-keygen-opts.c@1.62, 2007-05-27 07:44:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+  util/ntp-keygen-opts.h@1.62, 2007-05-27 07:44:57-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC4
+
+  util/ntp-keygen-opts.texi@1.60, 2007-05-27 07:44:58-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC4
+
+  util/ntp-keygen.1@1.60, 2007-05-27 07:44:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC4
+
+ChangeSet@1.1486, 2007-05-27 00:52:52-04:00, stenn@whimsy.udel.edu +1 -0
+  update NEWS file with new fixes
+
+  NEWS@1.91, 2007-05-27 00:52:43-04:00, stenn@whimsy.udel.edu +6 -0
+    update NEWS file with new fixes
+
+ChangeSet@1.1485, 2007-05-27 00:31:51-04:00, stenn@deacon.udel.edu +1 -0
+  Cleanup
+
+  ChangeLog@1.16, 2007-05-27 00:31:40-04:00, stenn@deacon.udel.edu +2 -2
+    Cleanup
+
+ChangeSet@1.1484, 2007-05-26 08:00:03+00:00, kardel@pogo.udel.edu +2 -0
+  ntp_io.c:
+    [Bug 795] Moved declaration of variable to top of function.
+  ChangeLog:
+    [Bug 795] Moved declaration of variable to top of function.
+
+  ChangeLog@1.15, 2007-05-26 07:57:22+00:00, kardel@pogo.udel.edu +1 -0
+    Bug 795
+
+  ntpd/ntp_io.c@1.249, 2007-05-26 07:58:40+00:00, kardel@pogo.udel.edu +4 -1
+    [Bug 795] Moved declaration of variable to top of function.
+
+ChangeSet@1.1480.1.9, 2007-05-25 07:44:43-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P2_RC3
+  TAG: NTP_4_2_4P2_RC3
+
+  ntpd/ntpd-opts.c@1.62, 2007-05-25 07:44:20-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  ntpd/ntpd-opts.h@1.62, 2007-05-25 07:44:21-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC3
+
+  ntpd/ntpd-opts.texi@1.61, 2007-05-25 07:44:22-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC3
+
+  ntpd/ntpd.1@1.60, 2007-05-25 07:44:23-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  ntpd/ntpdsim-opts.c@1.62, 2007-05-25 07:44:23-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  ntpd/ntpdsim-opts.h@1.62, 2007-05-25 07:44:24-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC3
+
+  ntpd/ntpdsim-opts.texi@1.60, 2007-05-25 07:44:25-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC3
+
+  ntpd/ntpdsim.1@1.60, 2007-05-25 07:44:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  ntpdc/ntpdc-opts.c@1.62, 2007-05-25 07:44:26-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  ntpdc/ntpdc-opts.h@1.62, 2007-05-25 07:44:27-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC3
+
+  ntpdc/ntpdc-opts.texi@1.60, 2007-05-25 07:44:28-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC3
+
+  ntpdc/ntpdc.1@1.60, 2007-05-25 07:44:28-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  ntpq/ntpq-opts.c@1.64, 2007-05-25 07:44:29-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  ntpq/ntpq-opts.h@1.64, 2007-05-25 07:44:30-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC3
+
+  ntpq/ntpq-opts.texi@1.61, 2007-05-25 07:44:31-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC3
+
+  ntpq/ntpq.1@1.60, 2007-05-25 07:44:32-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  packageinfo.sh@1.82, 2007-05-25 07:44:33-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC3
+
+  sntp/sntp-opts.c@1.60, 2007-05-25 07:44:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  sntp/sntp-opts.h@1.60, 2007-05-25 07:44:35-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC3
+
+  sntp/sntp-opts.texi@1.57, 2007-05-25 07:44:35-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC3
+
+  sntp/sntp.1@1.60, 2007-05-25 07:44:36-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  util/ntp-keygen-opts.c@1.61, 2007-05-25 07:44:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+  util/ntp-keygen-opts.h@1.61, 2007-05-25 07:44:38-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC3
+
+  util/ntp-keygen-opts.texi@1.59, 2007-05-25 07:44:38-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC3
+
+  util/ntp-keygen.1@1.59, 2007-05-25 07:44:39-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC3
+
+ChangeSet@1.1480.1.8, 2007-05-25 02:18:59-04:00, stenn@whimsy.udel.edu +1 -0
+  cleanup
+
+  NEWS@1.90, 2007-05-25 02:18:48-04:00, stenn@whimsy.udel.edu +1 -0
+    cleanup
+
+ChangeSet@1.1480.2.1, 2007-05-25 02:06:52-04:00, stenn@whimsy.udel.edu +2 -0
+  Upgraded autogen and libopts
+
+  ChangeLog@1.11.2.1, 2007-05-25 02:06:37-04:00, stenn@whimsy.udel.edu +1 -0
+    Upgraded autogen and libopts
+
+  NEWS@1.89, 2007-05-25 02:06:38-04:00, stenn@whimsy.udel.edu +1 -0
+    Upgraded autogen and libopts
+
+ChangeSet@1.1480.1.6, 2007-05-25 01:07:59-04:00, stenn@pogo.udel.edu +1 -0
+  cleanup ChangeLog
+
+  ChangeLog@1.11.1.3, 2007-05-25 01:07:52-04:00, stenn@pogo.udel.edu +1 -1
+    cleanup ChangeLog
+
+ChangeSet@1.1480.1.5, 2007-05-24 08:10:30-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #527 Don't write from source address length to wrong location
+
+  ChangeLog@1.11.1.2, 2007-05-24 08:10:20-04:00, mayer@pogo.udel.edu +1 -0
+    Bug #527 Don't write from source address length to wrong location
+
+ChangeSet@1.1480.1.4, 2007-05-24 08:08:34-04:00, mayer@pogo.udel.edu +4 -0
+  Bug #527 Don't write from source address length to wrong location
+
+  include/recvbuff.h@1.12, 2007-05-24 08:08:03-04:00, mayer@pogo.udel.edu +2 -0
+    Bug #527 Don't write from source address length to wrong location
+
+  libntp/recvbuff.c@1.25, 2007-05-24 08:08:03-04:00, mayer@pogo.udel.edu +27 -13
+    Bug #527 Don't write from source address length to wrong location
+
+  ports/winnt/libntp/transmitbuff.c@1.7, 2007-05-24 08:08:03-04:00, mayer@pogo.udel.edu +10 -10
+    Bug #527 Don't write from source address length to wrong location
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.22, 2007-05-24 08:08:03-04:00, mayer@pogo.udel.edu +76 -62
+    Bug #527 Don't write from source address length to wrong location
+
+ChangeSet@1.1480.1.3, 2007-05-19 07:53:57-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P2_RC2
+  TAG: NTP_4_2_4P2_RC2
+
+  ntpd/ntpd-opts.c@1.61, 2007-05-19 07:53:35-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P2_RC2
+
+  ntpd/ntpd-opts.h@1.61, 2007-05-19 07:53:35-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC2
+
+  ntpd/ntpd-opts.texi@1.60, 2007-05-19 07:53:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC2
+
+  ntpd/ntpd.1@1.59, 2007-05-19 07:53:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC2
+
+  ntpd/ntpdsim-opts.c@1.61, 2007-05-19 07:53:38-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P2_RC2
+
+  ntpd/ntpdsim-opts.h@1.61, 2007-05-19 07:53:39-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC2
+
+  ntpd/ntpdsim-opts.texi@1.59, 2007-05-19 07:53:40-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC2
+
+  ntpd/ntpdsim.1@1.59, 2007-05-19 07:53:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC2
+
+  ntpdc/ntpdc-opts.c@1.61, 2007-05-19 07:53:41-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P2_RC2
+
+  ntpdc/ntpdc-opts.h@1.61, 2007-05-19 07:53:42-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC2
+
+  ntpdc/ntpdc-opts.texi@1.59, 2007-05-19 07:53:43-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC2
+
+  ntpdc/ntpdc.1@1.59, 2007-05-19 07:53:43-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC2
+
+  ntpq/ntpq-opts.c@1.63, 2007-05-19 07:53:44-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P2_RC2
+
+  ntpq/ntpq-opts.h@1.63, 2007-05-19 07:53:45-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC2
+
+  ntpq/ntpq-opts.texi@1.60, 2007-05-19 07:53:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC2
+
+  ntpq/ntpq.1@1.59, 2007-05-19 07:53:47-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC2
+
+  packageinfo.sh@1.81, 2007-05-19 07:53:48-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC2
+
+  sntp/sntp-opts.c@1.59, 2007-05-19 07:53:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC2
+
+  sntp/sntp-opts.h@1.59, 2007-05-19 07:53:49-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC2
+
+  sntp/sntp-opts.texi@1.56, 2007-05-19 07:53:49-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC2
+
+  sntp/sntp.1@1.59, 2007-05-19 07:53:50-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC2
+
+  util/ntp-keygen-opts.c@1.60, 2007-05-19 07:53:51-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_4P2_RC2
+
+  util/ntp-keygen-opts.h@1.60, 2007-05-19 07:53:51-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC2
+
+  util/ntp-keygen-opts.texi@1.58, 2007-05-19 07:53:52-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC2
+
+  util/ntp-keygen.1@1.58, 2007-05-19 07:53:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC2
+
+ChangeSet@1.1480.1.2, 2007-05-19 02:33:04-04:00, stenn@whimsy.udel.edu +193 -0
+  We need another RC release to be sure the new autogen/libopts works.
+
+  BitKeeper/deleted/.del-COPYING.lgpl~492b62c9d62ba57a@1.2, 2007-05-19 00:01:18-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/COPYING.lgpl
+
+  BitKeeper/deleted/.del-COPYING.lgpl~adfa2ac04d64c0f7@1.2, 2007-05-19 00:00:02-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/COPYING.lgpl
+
+  BitKeeper/deleted/.del-COPYING.mbsd~7e1baaedfa33c877@1.2, 2007-05-19 00:00:03-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/COPYING.mbsd
+
+  BitKeeper/deleted/.del-COPYING.mbsd~e8244dcf5895b58f@1.2, 2007-05-19 00:01:19-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/COPYING.mbsd
+
+  BitKeeper/deleted/.del-MakeDefs.inc~3fd54e9b117bfdad@1.2, 2007-05-19 00:01:20-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/MakeDefs.inc
+
+  BitKeeper/deleted/.del-MakeDefs.inc~511eb438badc27b@1.2, 2007-05-19 00:00:04-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/MakeDefs.inc
+
+  BitKeeper/deleted/.del-Makefile.am~65692661e68a4392@1.2, 2007-05-19 00:00:04-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/Makefile.am
+
+  BitKeeper/deleted/.del-Makefile.am~fdf1a715e04b5f2c@1.2, 2007-05-19 00:01:21-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/Makefile.am
+
+  BitKeeper/deleted/.del-README~7ed47aff36cc39c@1.2, 2007-05-19 00:01:22-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/README
+
+  BitKeeper/deleted/.del-README~cec57621589d1ea6@1.2, 2007-05-19 00:00:05-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/README
+
+  BitKeeper/deleted/.del-autoopts.c~7b48d6dc5ca9c3b@1.2, 2007-05-19 00:01:22-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/autoopts.c
+
+  BitKeeper/deleted/.del-autoopts.c~917f3eb3a2030087@1.2, 2007-05-19 00:00:06-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/autoopts.c
+
+  BitKeeper/deleted/.del-autoopts.h~4184ad33bbb8222@1.2, 2007-05-19 00:00:08-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/autoopts.h
+
+  BitKeeper/deleted/.del-autoopts.h~d0834f397c8a330d@1.2, 2007-05-19 00:01:24-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/autoopts.h
+
+  BitKeeper/deleted/.del-boolean.c~50ae286fc516eee2@1.2, 2007-05-19 00:01:25-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/boolean.c
+
+  BitKeeper/deleted/.del-boolean.c~afd23e01a43b9536@1.2, 2007-05-19 00:00:09-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/boolean.c
+
+  BitKeeper/deleted/.del-compat.h~2bcdd381f6a570a1@1.2, 2007-05-19 00:01:54-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/compat.h
+
+  BitKeeper/deleted/.del-compat.h~e5d9fc11f0b928f2@1.2, 2007-05-19 00:00:35-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/compat.h
+
+  BitKeeper/deleted/.del-configfile.c~53384c73e434a615@1.2, 2007-05-19 00:00:09-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/configfile.c
+
+  BitKeeper/deleted/.del-configfile.c~ee0b7d49d26b4f74@1.2, 2007-05-19 00:01:26-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/configfile.c
+
+  BitKeeper/deleted/.del-cook.c~760181d2119b672@1.2, 2007-05-19 00:01:27-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/cook.c
+
+  BitKeeper/deleted/.del-cook.c~84c1af00a5581292@1.2, 2007-05-19 00:00:11-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/cook.c
+
+  BitKeeper/deleted/.del-enumeration.c~551805256cb9068c@1.2, 2007-05-19 00:00:12-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/enumeration.c
+
+  BitKeeper/deleted/.del-enumeration.c~969462e75e3913a3@1.2, 2007-05-19 00:01:29-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/enumeration.c
+
+  BitKeeper/deleted/.del-environment.c~643ce1e5a16a4f94@1.2, 2007-05-19 00:01:30-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/environment.c
+
+  BitKeeper/deleted/.del-environment.c~965d8c0fdf1150f5@1.2, 2007-05-19 00:00:13-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/environment.c
+
+  BitKeeper/deleted/.del-genshell.c~20529138c60103c3@1.2, 2007-05-19 00:00:14-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/genshell.c
+
+  BitKeeper/deleted/.del-genshell.c~bd74153097ec640f@1.2, 2007-05-19 00:01:31-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/genshell.c
+
+  BitKeeper/deleted/.del-genshell.h~7f41539b135f914a@1.2, 2007-05-19 00:00:15-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/genshell.h
+
+  BitKeeper/deleted/.del-genshell.h~b2793e1ea2981ff5@1.2, 2007-05-19 00:01:32-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/genshell.h
+
+  BitKeeper/deleted/.del-libopts.c~9353e1c3a0c56ad@1.2, 2007-05-19 00:00:16-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/libopts.c
+
+  BitKeeper/deleted/.del-libopts.c~bfc74bb368a309be@1.2, 2007-05-19 00:01:33-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/libopts.c
+
+  BitKeeper/deleted/.del-libopts.m4~9851dd84df41023b@1.2, 2007-05-19 00:00:40-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/m4/libopts.m4
+
+  BitKeeper/deleted/.del-libopts.m4~9fa7e371d1cc0426@1.2, 2007-05-19 00:02:00-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/m4/libopts.m4
+
+  BitKeeper/deleted/.del-liboptschk.m4~1828e1c4576e5aea@1.2, 2007-05-19 00:00:41-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/m4/liboptschk.m4
+
+  BitKeeper/deleted/.del-liboptschk.m4~480d5c4f1634a9fa@1.2, 2007-05-19 00:02:01-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/m4/liboptschk.m4
+
+  BitKeeper/deleted/.del-load.c~688d4934eb14272@1.2, 2007-05-19 00:01:34-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/load.c
+
+  BitKeeper/deleted/.del-load.c~b6aa568c6e3eaca1@1.2, 2007-05-19 00:00:16-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/load.c
+
+  BitKeeper/deleted/.del-makeshell.c~8c63bc5a263da752@1.2, 2007-05-19 00:01:35-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/makeshell.c
+
+  BitKeeper/deleted/.del-makeshell.c~a9cd96c3bfbc0835@1.2, 2007-05-19 00:00:17-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/makeshell.c
+
+  BitKeeper/deleted/.del-nested.c~1670193227f54043@1.2, 2007-05-19 00:01:36-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/nested.c
+
+  BitKeeper/deleted/.del-nested.c~a8521c8fcff292b6@1.2, 2007-05-19 00:00:18-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/nested.c
+
+  BitKeeper/deleted/.del-numeric.c~eb3fbec29633e61@1.2, 2007-05-19 00:01:37-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/numeric.c
+
+  BitKeeper/deleted/.del-numeric.c~ec644fa246942cbc@1.2, 2007-05-19 00:00:19-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/numeric.c
+
+  BitKeeper/deleted/.del-options.h~3cb6af32ad01957@1.2, 2007-05-19 00:01:52-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/autoopts/options.h
+
+  BitKeeper/deleted/.del-options.h~f700d69ce23e3e23@1.2, 2007-05-19 00:00:33-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/autoopts/options.h
+
+  BitKeeper/deleted/.del-pathfind.c~953a96dbc9932@1.2, 2007-05-19 00:01:56-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/pathfind.c
+
+  BitKeeper/deleted/.del-pathfind.c~c132dab083075929@1.2, 2007-05-19 00:00:36-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/pathfind.c
+
+  BitKeeper/deleted/.del-pgusage.c~5c1f8f132e9a1546@1.2, 2007-05-19 00:01:39-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/pgusage.c
+
+  BitKeeper/deleted/.del-pgusage.c~cec1309617012832@1.2, 2007-05-19 00:00:20-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/pgusage.c
+
+  BitKeeper/deleted/.del-proto.h~697b4937ff37ca3f@1.2, 2007-05-19 00:01:40-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/proto.h
+
+  BitKeeper/deleted/.del-proto.h~e2a13f546fbc0d4f@1.2, 2007-05-19 00:00:21-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/proto.h
+
+  BitKeeper/deleted/.del-putshell.c~6845ea506fad6426@1.2, 2007-05-19 00:01:41-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/putshell.c
+
+  BitKeeper/deleted/.del-putshell.c~6e39e6836261f3f7@1.2, 2007-05-19 00:00:22-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/putshell.c
+
+  BitKeeper/deleted/.del-restore.c~c14d8b96be44c6a8@1.2, 2007-05-19 00:01:42-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/restore.c
+
+  BitKeeper/deleted/.del-restore.c~e2a155efceab6f0d@1.2, 2007-05-19 00:00:23-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/restore.c
+
+  BitKeeper/deleted/.del-save.c~17e5ac125a404fb0@1.2, 2007-05-19 00:00:24-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/save.c
+
+  BitKeeper/deleted/.del-save.c~e7e7366cd24e1a8f@1.2, 2007-05-19 00:01:43-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/save.c
+
+  BitKeeper/deleted/.del-snprintf.c~4b42e45647e9ccef@1.2, 2007-05-19 00:00:38-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/snprintf.c
+
+  BitKeeper/deleted/.del-snprintf.c~988df6799c67781f@1.2, 2007-05-19 00:01:57-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/snprintf.c
+
+  BitKeeper/deleted/.del-sort.c~586535d7d26d958@1.2, 2007-05-19 00:01:44-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/sort.c
+
+  BitKeeper/deleted/.del-sort.c~bb92da923b5dcb7@1.2, 2007-05-19 00:00:25-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/sort.c
+
+  BitKeeper/deleted/.del-stack.c~202d33ccdfd74ec@1.2, 2007-05-19 00:01:45-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/stack.c
+
+  BitKeeper/deleted/.del-stack.c~b60d0ab82970f41f@1.2, 2007-05-19 00:00:26-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/stack.c
+
+  BitKeeper/deleted/.del-strchr.c~4a7e412c18f53557@1.2, 2007-05-19 00:01:57-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/strchr.c
+
+  BitKeeper/deleted/.del-strchr.c~7f4589858587fcc4@1.2, 2007-05-19 00:00:38-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/strchr.c
+
+  BitKeeper/deleted/.del-strdup.c~75e27662f28944b1@1.2, 2007-05-19 00:01:58-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/strdup.c
+
+  BitKeeper/deleted/.del-strdup.c~b295027011406c46@1.2, 2007-05-19 00:00:39-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/strdup.c
+
+  BitKeeper/deleted/.del-streqvcmp.c~999e9cfa251ea4b3@1.2, 2007-05-19 00:00:28-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/streqvcmp.c
+
+  BitKeeper/deleted/.del-streqvcmp.c~dc5534ffb1c6f28@1.2, 2007-05-19 00:01:47-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/streqvcmp.c
+
+  BitKeeper/deleted/.del-text_mmap.c~52f2f1dbe57a9743@1.2, 2007-05-19 00:00:29-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/text_mmap.c
+
+  BitKeeper/deleted/.del-text_mmap.c~e5096667484e499a@1.2, 2007-05-19 00:01:48-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/text_mmap.c
+
+  BitKeeper/deleted/.del-tokenize.c~315c26f9b162f234@1.2, 2007-05-19 00:01:49-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/tokenize.c
+
+  BitKeeper/deleted/.del-tokenize.c~6a814216fa293c3c@1.2, 2007-05-19 00:00:30-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/tokenize.c
+
+  BitKeeper/deleted/.del-usage-txt.h~3737a7c76813e8c3@1.2, 2007-05-19 00:00:34-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/autoopts/usage-txt.h
+
+  BitKeeper/deleted/.del-usage-txt.h~b71acc916d68c58c@1.2, 2007-05-19 00:01:53-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/autoopts/usage-txt.h
+
+  BitKeeper/deleted/.del-usage.c~f21924faa210bfa9@1.2, 2007-05-19 00:01:50-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/usage.c
+
+  BitKeeper/deleted/.del-usage.c~fe9a0f55b3cc55e4@1.2, 2007-05-19 00:00:31-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/usage.c
+
+  BitKeeper/deleted/.del-version.c~b69eccbdea7f51d9@1.2, 2007-05-19 00:01:51-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/version.c
+
+  BitKeeper/deleted/.del-version.c~de7f014d3e2ac91e@1.2, 2007-05-19 00:00:32-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/version.c
+
+  BitKeeper/deleted/.del-windows-config.h~11a9a57b2895598f@1.2, 2007-05-19 00:01:59-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/windows-config.h
+
+  BitKeeper/deleted/.del-windows-config.h~a6ead462c3d18ff0@1.2, 2007-05-19 00:00:39-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/windows-config.h
+
+  clockstuff/clktest-opts.c@1.10, 2007-05-19 02:30:32-04:00, stenn@whimsy.udel.edu +38 -270
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  clockstuff/clktest-opts.def@1.6, 2007-05-19 02:27:39-04:00, stenn@whimsy.udel.edu +4 -0
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  clockstuff/clktest-opts.h@1.10, 2007-05-19 02:30:33-04:00, stenn@whimsy.udel.edu +22 -57
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  include/autogen-version.def@1.4, 2007-05-19 02:27:41-04:00, stenn@whimsy.udel.edu +1 -1
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  libopts/COPYING.lgpl@1.1, 2007-05-19 00:04:01-04:00, stenn@whimsy.udel.edu +502 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/COPYING.lgpl
+
+  libopts/COPYING.lgpl@1.0, 2007-05-19 00:04:01-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/COPYING.mbsd@1.1, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +26 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/COPYING.mbsd
+
+  libopts/COPYING.mbsd@1.0, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/MakeDefs.inc@1.1, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/MakeDefs.inc
+
+  libopts/MakeDefs.inc@1.0, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/Makefile.am@1.1, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +24 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/Makefile.am
+
+  libopts/Makefile.am@1.0, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/README@1.1, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +93 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/README
+
+  libopts/README@1.0, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/autoopts.c@1.1, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +1120 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/autoopts.c
+
+  libopts/autoopts.c@1.0, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/autoopts.h@1.1, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +387 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/autoopts.h
+
+  libopts/autoopts.h@1.0, 2007-05-19 00:04:02-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/autoopts/options.h@1.1, 2007-05-19 00:04:14-04:00, stenn@whimsy.udel.edu +977 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/autoopts/options.h
+
+  libopts/autoopts/options.h@1.0, 2007-05-19 00:04:14-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/autoopts/usage-txt.h@1.1, 2007-05-19 00:04:14-04:00, stenn@whimsy.udel.edu +355 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/autoopts/usage-txt.h
+
+  libopts/autoopts/usage-txt.h@1.0, 2007-05-19 00:04:14-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/boolean.c@1.1, 2007-05-19 00:04:03-04:00, stenn@whimsy.udel.edu +106 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/boolean.c
+
+  libopts/boolean.c@1.0, 2007-05-19 00:04:03-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/compat.h@1.1, 2007-05-19 00:04:15-04:00, stenn@whimsy.udel.edu +319 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/compat/compat.h
+
+  libopts/compat/compat.h@1.0, 2007-05-19 00:04:15-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/pathfind.c@1.1, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +339 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/compat/pathfind.c
+
+  libopts/compat/pathfind.c@1.0, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/snprintf.c@1.1, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +60 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/compat/snprintf.c
+
+  libopts/compat/snprintf.c@1.0, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/strchr.c@1.1, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +60 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/compat/strchr.c
+
+  libopts/compat/strchr.c@1.0, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/strdup.c@1.1, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +19 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/compat/strdup.c
+
+  libopts/compat/strdup.c@1.0, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/windows-config.h@1.1, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +130 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/compat/windows-config.h
+
+  libopts/compat/windows-config.h@1.0, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/configfile.c@1.1, 2007-05-19 00:04:03-04:00, stenn@whimsy.udel.edu +1290 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/configfile.c
+
+  libopts/configfile.c@1.0, 2007-05-19 00:04:03-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/cook.c@1.1, 2007-05-19 00:04:04-04:00, stenn@whimsy.udel.edu +354 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/cook.c
+
+  libopts/cook.c@1.0, 2007-05-19 00:04:04-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/enumeration.c@1.1, 2007-05-19 00:04:05-04:00, stenn@whimsy.udel.edu +498 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/enumeration.c
+
+  libopts/enumeration.c@1.0, 2007-05-19 00:04:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/environment.c@1.1, 2007-05-19 00:04:05-04:00, stenn@whimsy.udel.edu +279 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/environment.c
+
+  libopts/environment.c@1.0, 2007-05-19 00:04:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/genshell.c@1.1, 2007-05-19 00:04:06-04:00, stenn@whimsy.udel.edu +354 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/genshell.c
+
+  libopts/genshell.c@1.0, 2007-05-19 00:04:06-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/genshell.h@1.1, 2007-05-19 00:04:06-04:00, stenn@whimsy.udel.edu +149 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/genshell.h
+
+  libopts/genshell.h@1.0, 2007-05-19 00:04:06-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/libopts.c@1.1, 2007-05-19 00:04:06-04:00, stenn@whimsy.udel.edu +30 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/libopts.c
+
+  libopts/libopts.c@1.0, 2007-05-19 00:04:06-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/load.c@1.1, 2007-05-19 00:04:06-04:00, stenn@whimsy.udel.edu +563 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/load.c
+
+  libopts/load.c@1.0, 2007-05-19 00:04:06-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/m4/libopts.m4@1.1, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +509 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/m4/libopts.m4
+
+  libopts/m4/libopts.m4@1.0, 2007-05-19 00:04:16-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/m4/liboptschk.m4@1.1, 2007-05-19 00:04:17-04:00, stenn@whimsy.udel.edu +42 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/m4/liboptschk.m4
+
+  libopts/m4/liboptschk.m4@1.0, 2007-05-19 00:04:17-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/makeshell.c@1.1, 2007-05-19 00:04:07-04:00, stenn@whimsy.udel.edu +1122 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/makeshell.c
+
+  libopts/makeshell.c@1.0, 2007-05-19 00:04:07-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/nested.c@1.1, 2007-05-19 00:04:07-04:00, stenn@whimsy.udel.edu +733 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/nested.c
+
+  libopts/nested.c@1.0, 2007-05-19 00:04:07-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/numeric.c@1.1, 2007-05-19 00:04:08-04:00, stenn@whimsy.udel.edu +93 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/numeric.c
+
+  libopts/numeric.c@1.0, 2007-05-19 00:04:08-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/pgusage.c@1.1, 2007-05-19 00:04:08-04:00, stenn@whimsy.udel.edu +157 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/pgusage.c
+
+  libopts/pgusage.c@1.0, 2007-05-19 00:04:08-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/proto.h@1.1, 2007-05-19 00:04:08-04:00, stenn@whimsy.udel.edu +91 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/proto.h
+
+  libopts/proto.h@1.0, 2007-05-19 00:04:08-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/putshell.c@1.1, 2007-05-19 00:04:08-04:00, stenn@whimsy.udel.edu +335 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/putshell.c
+
+  libopts/putshell.c@1.0, 2007-05-19 00:04:08-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/restore.c@1.1, 2007-05-19 00:04:08-04:00, stenn@whimsy.udel.edu +250 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/restore.c
+
+  libopts/restore.c@1.0, 2007-05-19 00:04:08-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/save.c@1.1, 2007-05-19 00:04:09-04:00, stenn@whimsy.udel.edu +512 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/save.c
+
+  libopts/save.c@1.0, 2007-05-19 00:04:09-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/sort.c@1.1, 2007-05-19 00:04:09-04:00, stenn@whimsy.udel.edu +359 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/sort.c
+
+  libopts/sort.c@1.0, 2007-05-19 00:04:09-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/stack.c@1.1, 2007-05-19 00:04:10-04:00, stenn@whimsy.udel.edu +269 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/stack.c
+
+  libopts/stack.c@1.0, 2007-05-19 00:04:10-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/streqvcmp.c@1.1, 2007-05-19 00:04:11-04:00, stenn@whimsy.udel.edu +289 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/streqvcmp.c
+
+  libopts/streqvcmp.c@1.0, 2007-05-19 00:04:11-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/text_mmap.c@1.1, 2007-05-19 00:04:11-04:00, stenn@whimsy.udel.edu +363 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/text_mmap.c
+
+  libopts/text_mmap.c@1.0, 2007-05-19 00:04:11-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/tokenize.c@1.1, 2007-05-19 00:04:12-04:00, stenn@whimsy.udel.edu +321 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/tokenize.c
+
+  libopts/tokenize.c@1.0, 2007-05-19 00:04:12-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/usage.c@1.1, 2007-05-19 00:04:13-04:00, stenn@whimsy.udel.edu +740 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/usage.c
+
+  libopts/usage.c@1.0, 2007-05-19 00:04:13-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/version.c@1.1, 2007-05-19 00:04:13-04:00, stenn@whimsy.udel.edu +178 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/libopts/version.c
+
+  libopts/version.c@1.0, 2007-05-19 00:04:13-04:00, stenn@whimsy.udel.edu +0 -0
+
+  ntpd/ntpd-opts.c@1.60, 2007-05-19 02:30:34-04:00, stenn@whimsy.udel.edu +20 -11
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpd/ntpd-opts.h@1.60, 2007-05-19 02:30:36-04:00, stenn@whimsy.udel.edu +4 -4
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpd/ntpd-opts.texi@1.59, 2007-05-19 02:30:36-04:00, stenn@whimsy.udel.edu +2 -8
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpd/ntpd.1@1.58, 2007-05-19 02:30:37-04:00, stenn@whimsy.udel.edu +2 -2
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpd/ntpdsim-opts.c@1.60, 2007-05-19 02:30:40-04:00, stenn@whimsy.udel.edu +23 -14
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpd/ntpdsim-opts.h@1.60, 2007-05-19 02:30:41-04:00, stenn@whimsy.udel.edu +6 -6
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpd/ntpdsim-opts.texi@1.58, 2007-05-19 02:30:43-04:00, stenn@whimsy.udel.edu +1 -1
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpd/ntpdsim.1@1.58, 2007-05-19 02:30:44-04:00, stenn@whimsy.udel.edu +2 -2
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpdc/ntpdc-opts.c@1.60, 2007-05-19 02:30:45-04:00, stenn@whimsy.udel.edu +23 -14
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpdc/ntpdc-opts.h@1.60, 2007-05-19 02:30:48-04:00, stenn@whimsy.udel.edu +6 -6
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpdc/ntpdc-opts.texi@1.58, 2007-05-19 02:30:48-04:00, stenn@whimsy.udel.edu +3 -3
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpdc/ntpdc.1@1.58, 2007-05-19 02:30:49-04:00, stenn@whimsy.udel.edu +2 -2
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpq/ntpq-opts.c@1.62, 2007-05-19 02:30:50-04:00, stenn@whimsy.udel.edu +23 -14
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpq/ntpq-opts.h@1.62, 2007-05-19 02:30:51-04:00, stenn@whimsy.udel.edu +6 -6
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpq/ntpq-opts.texi@1.59, 2007-05-19 02:30:52-04:00, stenn@whimsy.udel.edu +3 -3
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  ntpq/ntpq.1@1.58, 2007-05-19 02:30:53-04:00, stenn@whimsy.udel.edu +2 -2
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  packageinfo.sh@1.80, 2007-05-19 02:28:15-04:00, stenn@whimsy.udel.edu +1 -1
+    We need another RC release to be sure the new autogen/libopts works.
+
+  sntp/libopts/COPYING.lgpl@1.1, 2007-05-19 00:04:59-04:00, stenn@whimsy.udel.edu +502 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/COPYING.lgpl
+
+  sntp/libopts/COPYING.lgpl@1.0, 2007-05-19 00:04:59-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/COPYING.mbsd@1.1, 2007-05-19 00:05:00-04:00, stenn@whimsy.udel.edu +26 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/COPYING.mbsd
+
+  sntp/libopts/COPYING.mbsd@1.0, 2007-05-19 00:05:00-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/MakeDefs.inc@1.1, 2007-05-19 00:05:00-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/MakeDefs.inc
+
+  sntp/libopts/MakeDefs.inc@1.0, 2007-05-19 00:05:00-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/Makefile.am@1.1, 2007-05-19 00:05:00-04:00, stenn@whimsy.udel.edu +24 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/Makefile.am
+
+  sntp/libopts/Makefile.am@1.0, 2007-05-19 00:05:00-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/README@1.1, 2007-05-19 00:05:00-04:00, stenn@whimsy.udel.edu +93 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/README
+
+  sntp/libopts/README@1.0, 2007-05-19 00:05:00-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/autoopts.c@1.1, 2007-05-19 00:05:00-04:00, stenn@whimsy.udel.edu +1120 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/autoopts.c
+
+  sntp/libopts/autoopts.c@1.0, 2007-05-19 00:05:00-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/autoopts.h@1.1, 2007-05-19 00:05:01-04:00, stenn@whimsy.udel.edu +387 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/autoopts.h
+
+  sntp/libopts/autoopts.h@1.0, 2007-05-19 00:05:01-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/autoopts/options.h@1.1, 2007-05-19 00:05:12-04:00, stenn@whimsy.udel.edu +977 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/autoopts/options.h
+
+  sntp/libopts/autoopts/options.h@1.0, 2007-05-19 00:05:12-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/autoopts/usage-txt.h@1.1, 2007-05-19 00:05:13-04:00, stenn@whimsy.udel.edu +355 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/autoopts/usage-txt.h
+
+  sntp/libopts/autoopts/usage-txt.h@1.0, 2007-05-19 00:05:13-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/boolean.c@1.1, 2007-05-19 00:05:01-04:00, stenn@whimsy.udel.edu +106 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/boolean.c
+
+  sntp/libopts/boolean.c@1.0, 2007-05-19 00:05:01-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/compat.h@1.1, 2007-05-19 00:05:13-04:00, stenn@whimsy.udel.edu +319 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/compat/compat.h
+
+  sntp/libopts/compat/compat.h@1.0, 2007-05-19 00:05:13-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/pathfind.c@1.1, 2007-05-19 00:05:14-04:00, stenn@whimsy.udel.edu +339 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/compat/pathfind.c
+
+  sntp/libopts/compat/pathfind.c@1.0, 2007-05-19 00:05:14-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/snprintf.c@1.1, 2007-05-19 00:05:14-04:00, stenn@whimsy.udel.edu +60 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/compat/snprintf.c
+
+  sntp/libopts/compat/snprintf.c@1.0, 2007-05-19 00:05:14-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/strchr.c@1.1, 2007-05-19 00:05:14-04:00, stenn@whimsy.udel.edu +60 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/compat/strchr.c
+
+  sntp/libopts/compat/strchr.c@1.0, 2007-05-19 00:05:14-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/strdup.c@1.1, 2007-05-19 00:05:14-04:00, stenn@whimsy.udel.edu +19 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/compat/strdup.c
+
+  sntp/libopts/compat/strdup.c@1.0, 2007-05-19 00:05:14-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/windows-config.h@1.1, 2007-05-19 00:05:14-04:00, stenn@whimsy.udel.edu +130 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/compat/windows-config.h
+
+  sntp/libopts/compat/windows-config.h@1.0, 2007-05-19 00:05:14-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/configfile.c@1.1, 2007-05-19 00:05:01-04:00, stenn@whimsy.udel.edu +1290 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/configfile.c
+
+  sntp/libopts/configfile.c@1.0, 2007-05-19 00:05:01-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/cook.c@1.1, 2007-05-19 00:05:02-04:00, stenn@whimsy.udel.edu +354 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/cook.c
+
+  sntp/libopts/cook.c@1.0, 2007-05-19 00:05:02-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/enumeration.c@1.1, 2007-05-19 00:05:03-04:00, stenn@whimsy.udel.edu +498 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/enumeration.c
+
+  sntp/libopts/enumeration.c@1.0, 2007-05-19 00:05:03-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/environment.c@1.1, 2007-05-19 00:05:04-04:00, stenn@whimsy.udel.edu +279 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/environment.c
+
+  sntp/libopts/environment.c@1.0, 2007-05-19 00:05:04-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/genshell.c@1.1, 2007-05-19 00:05:04-04:00, stenn@whimsy.udel.edu +354 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/genshell.c
+
+  sntp/libopts/genshell.c@1.0, 2007-05-19 00:05:04-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/genshell.h@1.1, 2007-05-19 00:05:05-04:00, stenn@whimsy.udel.edu +149 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/genshell.h
+
+  sntp/libopts/genshell.h@1.0, 2007-05-19 00:05:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/libopts.c@1.1, 2007-05-19 00:05:05-04:00, stenn@whimsy.udel.edu +30 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/libopts.c
+
+  sntp/libopts/libopts.c@1.0, 2007-05-19 00:05:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/load.c@1.1, 2007-05-19 00:05:05-04:00, stenn@whimsy.udel.edu +563 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/load.c
+
+  sntp/libopts/load.c@1.0, 2007-05-19 00:05:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/m4/libopts.m4@1.1, 2007-05-19 00:05:15-04:00, stenn@whimsy.udel.edu +509 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/m4/libopts.m4
+
+  sntp/libopts/m4/libopts.m4@1.0, 2007-05-19 00:05:15-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/m4/liboptschk.m4@1.1, 2007-05-19 00:05:15-04:00, stenn@whimsy.udel.edu +42 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/m4/liboptschk.m4
+
+  sntp/libopts/m4/liboptschk.m4@1.0, 2007-05-19 00:05:15-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/makeshell.c@1.1, 2007-05-19 00:05:05-04:00, stenn@whimsy.udel.edu +1122 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/makeshell.c
+
+  sntp/libopts/makeshell.c@1.0, 2007-05-19 00:05:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/nested.c@1.1, 2007-05-19 00:05:06-04:00, stenn@whimsy.udel.edu +733 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/nested.c
+
+  sntp/libopts/nested.c@1.0, 2007-05-19 00:05:06-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/numeric.c@1.1, 2007-05-19 00:05:06-04:00, stenn@whimsy.udel.edu +93 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/numeric.c
+
+  sntp/libopts/numeric.c@1.0, 2007-05-19 00:05:06-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/pgusage.c@1.1, 2007-05-19 00:05:06-04:00, stenn@whimsy.udel.edu +157 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/pgusage.c
+
+  sntp/libopts/pgusage.c@1.0, 2007-05-19 00:05:06-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/proto.h@1.1, 2007-05-19 00:05:06-04:00, stenn@whimsy.udel.edu +91 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/proto.h
+
+  sntp/libopts/proto.h@1.0, 2007-05-19 00:05:06-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/putshell.c@1.1, 2007-05-19 00:05:07-04:00, stenn@whimsy.udel.edu +335 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/putshell.c
+
+  sntp/libopts/putshell.c@1.0, 2007-05-19 00:05:07-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/restore.c@1.1, 2007-05-19 00:05:07-04:00, stenn@whimsy.udel.edu +250 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/restore.c
+
+  sntp/libopts/restore.c@1.0, 2007-05-19 00:05:07-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/save.c@1.1, 2007-05-19 00:05:08-04:00, stenn@whimsy.udel.edu +512 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/save.c
+
+  sntp/libopts/save.c@1.0, 2007-05-19 00:05:08-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/sort.c@1.1, 2007-05-19 00:05:08-04:00, stenn@whimsy.udel.edu +359 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/sort.c
+
+  sntp/libopts/sort.c@1.0, 2007-05-19 00:05:08-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/stack.c@1.1, 2007-05-19 00:05:09-04:00, stenn@whimsy.udel.edu +269 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/stack.c
+
+  sntp/libopts/stack.c@1.0, 2007-05-19 00:05:09-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/streqvcmp.c@1.1, 2007-05-19 00:05:09-04:00, stenn@whimsy.udel.edu +289 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/streqvcmp.c
+
+  sntp/libopts/streqvcmp.c@1.0, 2007-05-19 00:05:09-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/text_mmap.c@1.1, 2007-05-19 00:05:10-04:00, stenn@whimsy.udel.edu +363 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/text_mmap.c
+
+  sntp/libopts/text_mmap.c@1.0, 2007-05-19 00:05:10-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/tokenize.c@1.1, 2007-05-19 00:05:10-04:00, stenn@whimsy.udel.edu +321 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/tokenize.c
+
+  sntp/libopts/tokenize.c@1.0, 2007-05-19 00:05:10-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/usage.c@1.1, 2007-05-19 00:05:11-04:00, stenn@whimsy.udel.edu +740 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/usage.c
+
+  sntp/libopts/usage.c@1.0, 2007-05-19 00:05:11-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/version.c@1.1, 2007-05-19 00:05:12-04:00, stenn@whimsy.udel.edu +178 -0
+    BitKeeper file /deacon/backroom/ntp-stable-hms/sntp/libopts/version.c
+
+  sntp/libopts/version.c@1.0, 2007-05-19 00:05:12-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/sntp-opts.c@1.58, 2007-05-19 02:30:55-04:00, stenn@whimsy.udel.edu +21 -12
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  sntp/sntp-opts.h@1.58, 2007-05-19 02:30:56-04:00, stenn@whimsy.udel.edu +6 -6
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  sntp/sntp-opts.texi@1.55, 2007-05-19 02:30:57-04:00, stenn@whimsy.udel.edu +1 -1
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  sntp/sntp.1@1.58, 2007-05-19 02:30:58-04:00, stenn@whimsy.udel.edu +2 -2
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  util/ntp-keygen-opts.c@1.59, 2007-05-19 02:31:00-04:00, stenn@whimsy.udel.edu +23 -14
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  util/ntp-keygen-opts.h@1.59, 2007-05-19 02:31:02-04:00, stenn@whimsy.udel.edu +6 -6
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  util/ntp-keygen-opts.texi@1.57, 2007-05-19 02:31:04-04:00, stenn@whimsy.udel.edu +3 -3
+    We need to use the upgraded autogen/libopts in -stable too.
+
+  util/ntp-keygen.1@1.57, 2007-05-19 02:31:04-04:00, stenn@whimsy.udel.edu +2 -2
+    We need to use the upgraded autogen/libopts in -stable too.
+
+ChangeSet@1.1480.1.1, 2007-05-18 02:20:56-04:00, stenn@whimsy.udel.edu +3 -0
+  Release 4.2.4p2
+
+  ChangeLog@1.11.1.1, 2007-05-18 02:19:13-04:00, stenn@whimsy.udel.edu +4 -2
+    Release 4.2.4p2
+
+  NEWS@1.88, 2007-05-18 02:19:14-04:00, stenn@whimsy.udel.edu +6 -0
+    Release 4.2.4p2
+
+  packageinfo.sh@1.79, 2007-05-18 02:20:38-04:00, stenn@whimsy.udel.edu +1 -1
+    Release 4.2.4p2
+
+ChangeSet@1.1482, 2007-04-28 10:19:57+00:00, kardel@pogo.udel.edu +2 -0
+  ntp_peer.c:
+    Bug 789 (backported from ntp-dev):
+    Fix multicast client crypto authentication and make sure arriving
+    multicast packets do not disturb the autokey dance.
+  ChangeLog:
+    Bug 789 (backported from ntp-dev):
+    Fix multicast client crypto authentication and make sure arriving
+    multicast packets do not disturb the autokey dance.
+
+  ChangeLog@1.13, 2007-04-28 10:15:34+00:00, kardel@pogo.udel.edu +4 -1
+    Bug 789:
+    Fix multicast client crypto authentication and make sure arriving
+                multicast packets do not disturb the autokey dance.
+
+  ntpd/ntp_peer.c@1.99, 2007-04-28 10:06:31+00:00, kardel@pogo.udel.edu +21 -12
+    Bug 789 (backported from ntp-dev):
+    fix multicast client mode by re-setting
+    crypto information only when the local address
+    changes and not for BCLNTs.
+    Addtitionally don't update the local address while
+    a BCLNT is doing the autokey dance.
+
+ChangeSet@1.1481, 2007-04-28 10:03:26+00:00, kardel@pogo.udel.edu +3 -0
+  ntp_io.c, ChangeLog:
+    bug 785 (backport from ntp-dev):
+    improve handling of multicast interfaces
+    (multicast routers still need to run a multicast routing software/daemon)
+  ntp_peer.c:
+    bug 785 (backport from ntp-dev):
+    clarify debug messages
+
+  ChangeLog@1.12, 2007-04-28 10:00:26+00:00, kardel@pogo.udel.edu +1 -0
+    bug 785 (backport from ntp-dev):
+    improve handling of multicast interfaces
+    (multicast routers still need to run a multicast routing software/daemon)
+
+  ntpd/ntp_io.c@1.248, 2007-04-28 09:52:18+00:00, kardel@pogo.udel.edu +84 -62
+    bug 785 (backport from ntp-dev):
+    improve handling of multicast interfaces
+    (multicast routers still need to run a multicast routing software/daemon)
+
+  ntpd/ntp_peer.c@1.98, 2007-04-28 09:53:09+00:00, kardel@pogo.udel.edu +2 -2
+    bug 785 (backport from ntp-dev):
+    clarify debug messages
+
+ChangeSet@1.1480, 2007-04-14 19:05:07-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P2_RC1
+  TAG: NTP_4_2_4P2_RC1
+
+  ntpd/ntpd-opts.c@1.59, 2007-04-14 19:04:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  ntpd/ntpd-opts.h@1.59, 2007-04-14 19:04:46-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC1
+
+  ntpd/ntpd-opts.texi@1.58, 2007-04-14 19:04:47-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC1
+
+  ntpd/ntpd.1@1.57, 2007-04-14 19:04:47-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  ntpd/ntpdsim-opts.c@1.59, 2007-04-14 19:04:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  ntpd/ntpdsim-opts.h@1.59, 2007-04-14 19:04:49-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC1
+
+  ntpd/ntpdsim-opts.texi@1.57, 2007-04-14 19:04:50-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC1
+
+  ntpd/ntpdsim.1@1.57, 2007-04-14 19:04:50-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  ntpdc/ntpdc-opts.c@1.59, 2007-04-14 19:04:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  ntpdc/ntpdc-opts.h@1.59, 2007-04-14 19:04:52-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC1
+
+  ntpdc/ntpdc-opts.texi@1.57, 2007-04-14 19:04:52-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC1
+
+  ntpdc/ntpdc.1@1.57, 2007-04-14 19:04:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  ntpq/ntpq-opts.c@1.61, 2007-04-14 19:04:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  ntpq/ntpq-opts.h@1.61, 2007-04-14 19:04:55-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC1
+
+  ntpq/ntpq-opts.texi@1.58, 2007-04-14 19:04:55-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC1
+
+  ntpq/ntpq.1@1.57, 2007-04-14 19:04:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  packageinfo.sh@1.78, 2007-04-14 19:04:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  sntp/sntp-opts.c@1.57, 2007-04-14 19:04:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  sntp/sntp-opts.h@1.57, 2007-04-14 19:04:58-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC1
+
+  sntp/sntp-opts.texi@1.54, 2007-04-14 19:04:59-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC1
+
+  sntp/sntp.1@1.57, 2007-04-14 19:04:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  util/ntp-keygen-opts.c@1.58, 2007-04-14 19:05:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+  util/ntp-keygen-opts.h@1.58, 2007-04-14 19:05:01-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P2_RC1
+
+  util/ntp-keygen-opts.texi@1.56, 2007-04-14 19:05:02-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P2_RC1
+
+  util/ntp-keygen.1@1.56, 2007-04-14 19:05:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P2_RC1
+
+ChangeSet@1.1479, 2007-04-14 18:16:04-04:00, stenn@deacon.udel.edu +2 -0
+  Distribute include/homerc.def
+
+  include/Makefile.am@1.25, 2007-04-14 18:15:53-04:00, stenn@deacon.udel.edu +1 -1
+    Distribute include/homerc.def
+
+  packageinfo.sh@1.77, 2007-04-14 18:14:54-04:00, stenn@deacon.udel.edu +1 -1
+    restart the RC
+
+ChangeSet@1.1478, 2007-04-14 07:53:43-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P1_RC1
+  TAG: NTP_4_2_4P1_RC1
+
+  ntpd/ntpd-opts.c@1.58, 2007-04-14 07:53:21-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  ntpd/ntpd-opts.h@1.58, 2007-04-14 07:53:21-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P1_RC1
+
+  ntpd/ntpd-opts.texi@1.57, 2007-04-14 07:53:23-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  ntpd/ntpd.1@1.56, 2007-04-14 07:53:23-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  ntpd/ntpdsim-opts.c@1.58, 2007-04-14 07:53:24-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  ntpd/ntpdsim-opts.h@1.58, 2007-04-14 07:53:25-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P1_RC1
+
+  ntpd/ntpdsim-opts.texi@1.56, 2007-04-14 07:53:26-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P1_RC1
+
+  ntpd/ntpdsim.1@1.56, 2007-04-14 07:53:27-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  ntpdc/ntpdc-opts.c@1.58, 2007-04-14 07:53:28-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  ntpdc/ntpdc-opts.h@1.58, 2007-04-14 07:53:29-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P1_RC1
+
+  ntpdc/ntpdc-opts.texi@1.56, 2007-04-14 07:53:30-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  ntpdc/ntpdc.1@1.56, 2007-04-14 07:53:30-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  ntpq/ntpq-opts.c@1.60, 2007-04-14 07:53:31-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  ntpq/ntpq-opts.h@1.60, 2007-04-14 07:53:32-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P1_RC1
+
+  ntpq/ntpq-opts.texi@1.57, 2007-04-14 07:53:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  ntpq/ntpq.1@1.56, 2007-04-14 07:53:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  packageinfo.sh@1.76, 2007-04-14 07:53:34-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  sntp/sntp-opts.c@1.56, 2007-04-14 07:53:35-04:00, stenn@whimsy.udel.edu +8 -7
+    NTP_4_2_4P1_RC1
+
+  sntp/sntp-opts.h@1.56, 2007-04-14 07:53:35-04:00, stenn@whimsy.udel.edu +8 -14
+    NTP_4_2_4P1_RC1
+
+  sntp/sntp-opts.texi@1.53, 2007-04-14 07:53:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P1_RC1
+
+  sntp/sntp.1@1.56, 2007-04-14 07:53:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  util/ntp-keygen-opts.c@1.57, 2007-04-14 07:53:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  util/ntp-keygen-opts.h@1.57, 2007-04-14 07:53:38-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P1_RC1
+
+  util/ntp-keygen-opts.texi@1.55, 2007-04-14 07:53:39-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+  util/ntp-keygen.1@1.55, 2007-04-14 07:53:39-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P1_RC1
+
+ChangeSet@1.1477, 2007-04-14 05:13:18-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 811] ntpd should not read a .ntprc file
+
+  ChangeLog@1.11, 2007-04-14 05:12:51-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 811] ntpd should not read a .ntprc file
+
+ChangeSet@1.1476, 2007-04-14 04:47:21-04:00, stenn@whimsy.udel.edu +1 -0
+  start an RC cycle
+
+  packageinfo.sh@1.75, 2007-04-14 04:47:01-04:00, stenn@whimsy.udel.edu +2 -2
+    start an RC cycle
+
+ChangeSet@1.1475, 2007-04-14 02:38:03-04:00, stenn@whimsy.udel.edu +32 -0
+  [Bug 811] ntpd should not read a .ntprc file
+
+  clockstuff/Makefile.am@1.6, 2007-04-14 02:35:13-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 811] ntpd should not read a .ntprc file
+
+  clockstuff/clktest-opts.def@1.5, 2007-04-14 02:35:14-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 811] ntpd should not read a .ntprc file
+
+  include/copyright.def@1.4, 2007-04-14 02:35:14-04:00, stenn@whimsy.udel.edu +0 -7
+    [Bug 811] ntpd should not read a .ntprc file
+
+  include/homerc.def@1.1, 2007-04-14 01:19:52-04:00, stenn@whimsy.udel.edu +9 -0
+    BitKeeper file /deacon/backroom/ntp-stable/include/homerc.def
+
+  include/homerc.def@1.0, 2007-04-14 01:19:52-04:00, stenn@whimsy.udel.edu +0 -0
+
+  ntpd/Makefile.am@1.53, 2007-04-14 02:35:14-04:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpd/ntpd-opts.c@1.57, 2007-04-14 02:36:43-04:00, stenn@whimsy.udel.edu +12 -54
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpd/ntpd-opts.h@1.57, 2007-04-14 02:36:44-04:00, stenn@whimsy.udel.edu +8 -22
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpd/ntpd-opts.texi@1.56, 2007-04-14 02:36:44-04:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpd/ntpd.1@1.55, 2007-04-14 02:36:45-04:00, stenn@whimsy.udel.edu +3 -19
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpd/ntpdsim-opts.c@1.57, 2007-04-14 02:36:46-04:00, stenn@whimsy.udel.edu +7 -6
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpd/ntpdsim-opts.def@1.6, 2007-04-14 02:35:15-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpd/ntpdsim-opts.h@1.57, 2007-04-14 02:36:46-04:00, stenn@whimsy.udel.edu +6 -12
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpd/ntpdsim-opts.texi@1.55, 2007-04-14 02:36:47-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpd/ntpdsim.1@1.55, 2007-04-14 02:36:48-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpdc/Makefile.am@1.34, 2007-04-14 02:35:15-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpdc/ntpdc-opts.c@1.57, 2007-04-14 02:36:48-04:00, stenn@whimsy.udel.edu +7 -6
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpdc/ntpdc-opts.def@1.13, 2007-04-14 02:35:16-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpdc/ntpdc-opts.h@1.57, 2007-04-14 02:36:49-04:00, stenn@whimsy.udel.edu +6 -12
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpdc/ntpdc-opts.texi@1.55, 2007-04-14 02:36:50-04:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpdc/ntpdc.1@1.55, 2007-04-14 02:36:51-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpq/Makefile.am@1.26, 2007-04-14 02:35:16-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpq/ntpq-opts.c@1.59, 2007-04-14 02:36:52-04:00, stenn@whimsy.udel.edu +7 -6
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpq/ntpq-opts.def@1.12, 2007-04-14 02:35:16-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpq/ntpq-opts.h@1.59, 2007-04-14 02:36:53-04:00, stenn@whimsy.udel.edu +6 -12
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpq/ntpq-opts.texi@1.56, 2007-04-14 02:36:53-04:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 811] ntpd should not read a .ntprc file
+
+  ntpq/ntpq.1@1.55, 2007-04-14 02:36:54-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 811] ntpd should not read a .ntprc file
+
+  util/Makefile.am@1.35, 2007-04-14 02:35:17-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 811] ntpd should not read a .ntprc file
+
+  util/ntp-keygen-opts.c@1.56, 2007-04-14 02:36:55-04:00, stenn@whimsy.udel.edu +7 -6
+    [Bug 811] ntpd should not read a .ntprc file
+
+  util/ntp-keygen-opts.def@1.7, 2007-04-14 02:35:18-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 811] ntpd should not read a .ntprc file
+
+  util/ntp-keygen-opts.h@1.56, 2007-04-14 02:36:55-04:00, stenn@whimsy.udel.edu +6 -12
+    [Bug 811] ntpd should not read a .ntprc file
+
+  util/ntp-keygen-opts.texi@1.54, 2007-04-14 02:36:56-04:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 811] ntpd should not read a .ntprc file
+
+  util/ntp-keygen.1@1.54, 2007-04-14 02:36:57-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 811] ntpd should not read a .ntprc file
+
+ChangeSet@1.1474, 2007-04-14 01:11:33-04:00, stenn@whimsy.udel.edu +166 -0
+  autogen/libopts upgrade
+
+  BitKeeper/deleted/.del-COPYING.lgpl@1.3, 2007-04-13 18:58:46-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/COPYING.lgpl
+
+  BitKeeper/deleted/.del-COPYING.lgpl~54a90ba0899593cb@1.2, 2007-04-13 19:05:57-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/COPYING.lgpl
+
+  BitKeeper/deleted/.del-COPYING.mbsd@1.2, 2007-04-13 18:58:48-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/COPYING.mbsd
+
+  BitKeeper/deleted/.del-COPYING.mbsd~9b1945bb2136c70b@1.2, 2007-04-13 19:05:59-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/COPYING.mbsd
+
+  BitKeeper/deleted/.del-MakeDefs.inc@1.2, 2007-04-13 18:58:49-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/MakeDefs.inc
+
+  BitKeeper/deleted/.del-MakeDefs.inc~2b8fdfc9df6d652d@1.2, 2007-04-13 19:06:00-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/MakeDefs.inc
+
+  BitKeeper/deleted/.del-Makefile.am@1.7, 2007-04-13 18:58:50-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/Makefile.am
+
+  BitKeeper/deleted/.del-Makefile.am~fa9bd87b6045015c@1.5, 2007-04-13 19:06:01-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/Makefile.am
+
+  BitKeeper/deleted/.del-README@1.2, 2007-04-13 18:58:51-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/README
+
+  BitKeeper/deleted/.del-README~1ae087758ee867d4@1.2, 2007-04-13 19:06:02-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/README
+
+  BitKeeper/deleted/.del-autoopts.c@1.11, 2007-04-13 18:58:52-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/autoopts.c
+
+  BitKeeper/deleted/.del-autoopts.c~5b417341bc85d7a8@1.8, 2007-04-13 19:06:03-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/autoopts.c
+
+  BitKeeper/deleted/.del-autoopts.h@1.10, 2007-04-13 18:58:53-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/autoopts.h
+
+  BitKeeper/deleted/.del-autoopts.h~8cdce21b181a1a01@1.8, 2007-04-13 19:06:05-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/autoopts.h
+
+  BitKeeper/deleted/.del-boolean.c@1.9, 2007-04-13 18:58:54-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/boolean.c
+
+  BitKeeper/deleted/.del-boolean.c~a5d10c8997e6a2e2@1.6, 2007-04-13 19:06:06-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/boolean.c
+
+  BitKeeper/deleted/.del-compat.h@1.13, 2007-04-13 19:04:47-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/compat.h
+
+  BitKeeper/deleted/.del-compat.h~9682d0ac273ae32@1.9, 2007-04-13 19:06:50-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/compat.h
+
+  BitKeeper/deleted/.del-configfile.c@1.11, 2007-04-13 18:58:56-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/configfile.c
+
+  BitKeeper/deleted/.del-configfile.c~8194f784686fa804@1.8, 2007-04-13 19:06:07-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/configfile.c
+
+  BitKeeper/deleted/.del-cook.c@1.10, 2007-04-13 18:58:57-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/cook.c
+
+  BitKeeper/deleted/.del-cook.c~e48d079a438432dc@1.7, 2007-04-13 19:06:08-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/cook.c
+
+  BitKeeper/deleted/.del-enumeration.c@1.10, 2007-04-13 18:58:59-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/enumeration.c
+
+  BitKeeper/deleted/.del-enumeration.c~5f4e6af2706370ae@1.7, 2007-04-13 19:06:10-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/enumeration.c
+
+  BitKeeper/deleted/.del-environment.c@1.9, 2007-04-13 18:59:00-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/environment.c
+
+  BitKeeper/deleted/.del-environment.c~2bae2966695067c2@1.6, 2007-04-13 19:06:11-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/environment.c
+
+  BitKeeper/deleted/.del-genshell.c@1.10, 2007-04-13 18:59:01-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/genshell.c
+
+  BitKeeper/deleted/.del-genshell.c~1fd152b2b52bdab@1.7, 2007-04-13 19:06:12-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/genshell.c
+
+  BitKeeper/deleted/.del-genshell.h@1.10, 2007-04-13 18:59:02-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/genshell.h
+
+  BitKeeper/deleted/.del-genshell.h~375f0fa5b925f454@1.7, 2007-04-13 19:06:14-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/genshell.h
+
+  BitKeeper/deleted/.del-libopts.c@1.4, 2007-04-13 18:59:04-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/libopts.c
+
+  BitKeeper/deleted/.del-libopts.c~58b8fbed850e6d5e@1.4, 2007-04-13 19:06:15-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/libopts.c
+
+  BitKeeper/deleted/.del-libopts.m4@1.15, 2007-04-13 19:04:54-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/m4/libopts.m4
+
+  BitKeeper/deleted/.del-libopts.m4~9e0f33f57d3a0a9@1.12, 2007-04-13 19:06:56-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/m4/libopts.m4
+
+  BitKeeper/deleted/.del-liboptschk.m4@1.4, 2007-04-13 19:04:55-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/m4/liboptschk.m4
+
+  BitKeeper/deleted/.del-liboptschk.m4~bbeebebe76865058@1.4, 2007-04-13 19:06:58-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/m4/liboptschk.m4
+
+  BitKeeper/deleted/.del-libtool.m4@1.2, 2007-04-13 19:04:57-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/m4/libtool.m4
+
+  BitKeeper/deleted/.del-libtool.m4~db8acbd0fb34597f@1.2, 2007-04-13 19:07:00-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/m4/libtool.m4
+
+  BitKeeper/deleted/.del-load.c@1.11, 2007-04-13 18:59:05-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/load.c
+
+  BitKeeper/deleted/.del-load.c~59960aa12bb95bf7@1.8, 2007-04-13 19:06:16-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/load.c
+
+  BitKeeper/deleted/.del-makeshell.c@1.12, 2007-04-13 18:59:06-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/makeshell.c
+
+  BitKeeper/deleted/.del-makeshell.c~4fcd12fc31c0a4a4@1.9, 2007-04-13 19:06:18-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/makeshell.c
+
+  BitKeeper/deleted/.del-nested.c@1.10, 2007-04-13 18:59:07-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/nested.c
+
+  BitKeeper/deleted/.del-nested.c~85346d5d12098689@1.7, 2007-04-13 19:06:19-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/nested.c
+
+  BitKeeper/deleted/.del-numeric.c@1.10, 2007-04-13 18:59:08-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/numeric.c
+
+  BitKeeper/deleted/.del-numeric.c~cdb7deb5cf6f27c2@1.7, 2007-04-13 19:06:21-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/numeric.c
+
+  BitKeeper/deleted/.del-options.h@1.11, 2007-04-13 19:04:44-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/autoopts/options.h
+
+  BitKeeper/deleted/.del-options.h~6eb465cb95a56bee@1.8, 2007-04-13 19:06:45-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/autoopts/options.h
+
+  BitKeeper/deleted/.del-pathfind.c@1.10, 2007-04-13 19:04:49-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/pathfind.c
+
+  BitKeeper/deleted/.del-pathfind.c~a0863179d884d4a4@1.7, 2007-04-13 19:06:51-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/pathfind.c
+
+  BitKeeper/deleted/.del-pgusage.c@1.10, 2007-04-13 18:59:09-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/pgusage.c
+
+  BitKeeper/deleted/.del-pgusage.c~d981c42eb301cfdd@1.6, 2007-04-13 19:06:22-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/pgusage.c
+
+  BitKeeper/deleted/.del-proto.h@1.12, 2007-04-13 18:59:11-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/proto.h
+
+  BitKeeper/deleted/.del-proto.h~fa076f6dd9d0667e@1.9, 2007-04-13 19:06:23-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/proto.h
+
+  BitKeeper/deleted/.del-putshell.c@1.11, 2007-04-13 18:59:12-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/putshell.c
+
+  BitKeeper/deleted/.del-putshell.c~24959f5e1ba688e6@1.8, 2007-04-13 19:06:24-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/putshell.c
+
+  BitKeeper/deleted/.del-restore.c@1.10, 2007-04-13 18:59:13-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/restore.c
+
+  BitKeeper/deleted/.del-restore.c~eada4acbf21cd8bf@1.6, 2007-04-13 19:06:26-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/restore.c
+
+  BitKeeper/deleted/.del-save.c@1.11, 2007-04-13 18:59:15-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/save.c
+
+  BitKeeper/deleted/.del-save.c~a29f5bd429a568bb@1.8, 2007-04-13 19:06:27-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/save.c
+
+  BitKeeper/deleted/.del-snprintf.c@1.5, 2007-04-13 19:04:50-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/snprintf.c
+
+  BitKeeper/deleted/.del-snprintf.c~66578c716014cd3d@1.4, 2007-04-13 19:06:52-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/snprintf.c
+
+  BitKeeper/deleted/.del-sort.c@1.9, 2007-04-13 18:59:16-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/sort.c
+
+  BitKeeper/deleted/.del-sort.c~bec5a7fb6a01a5dc@1.5, 2007-04-13 19:06:28-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/sort.c
+
+  BitKeeper/deleted/.del-stack.c@1.11, 2007-04-13 18:59:17-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/stack.c
+
+  BitKeeper/deleted/.del-stack.c~e817b57b18b315c1@1.8, 2007-04-13 19:06:29-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/stack.c
+
+  BitKeeper/deleted/.del-strchr.c@1.4, 2007-04-13 19:04:51-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/strchr.c
+
+  BitKeeper/deleted/.del-strchr.c~80e88afbe7e2209a@1.4, 2007-04-13 19:06:53-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/strchr.c
+
+  BitKeeper/deleted/.del-strdup.c@1.4, 2007-04-13 19:04:52-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/strdup.c
+
+  BitKeeper/deleted/.del-strdup.c~1f262be5e55c3c4a@1.3, 2007-04-13 19:06:54-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/strdup.c
+
+  BitKeeper/deleted/.del-streqvcmp.c@1.10, 2007-04-13 18:59:19-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/streqvcmp.c
+
+  BitKeeper/deleted/.del-streqvcmp.c~66420c6082b06827@1.7, 2007-04-13 19:06:31-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/streqvcmp.c
+
+  BitKeeper/deleted/.del-text_mmap.c@1.9, 2007-04-13 18:59:20-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/text_mmap.c
+
+  BitKeeper/deleted/.del-text_mmap.c~f1915a52b87816ba@1.6, 2007-04-13 19:06:32-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/text_mmap.c
+
+  BitKeeper/deleted/.del-tokenize.c@1.6, 2007-04-13 18:59:21-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/tokenize.c
+
+  BitKeeper/deleted/.del-tokenize.c~ae2f23dbb2bee589@1.5, 2007-04-13 19:06:33-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/tokenize.c
+
+  BitKeeper/deleted/.del-usage-txt.h@1.10, 2007-04-13 19:04:46-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/autoopts/usage-txt.h
+
+  BitKeeper/deleted/.del-usage-txt.h~6ce4dce87430d1b@1.7, 2007-04-13 19:06:47-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/autoopts/usage-txt.h
+
+  BitKeeper/deleted/.del-usage.c@1.10, 2007-04-13 18:59:22-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/usage.c
+
+  BitKeeper/deleted/.del-usage.c~c868ef1e661a6eb1@1.8, 2007-04-13 19:06:34-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/usage.c
+
+  BitKeeper/deleted/.del-version.c@1.10, 2007-04-13 18:59:24-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/version.c
+
+  BitKeeper/deleted/.del-version.c~a426e6b58b20d06@1.7, 2007-04-13 19:06:35-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/version.c
+
+  BitKeeper/deleted/.del-windows-config.h@1.6, 2007-04-13 19:04:53-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libopts/compat/windows-config.h
+
+  BitKeeper/deleted/.del-windows-config.h~36f7ad2ccf764ad2@1.4, 2007-04-13 19:06:56-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: sntp/libopts/compat/windows-config.h
+
+  libopts/COPYING.lgpl@1.1, 2007-04-13 19:10:05-04:00, stenn@whimsy.udel.edu +502 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/COPYING.lgpl
+
+  libopts/COPYING.lgpl@1.0, 2007-04-13 19:10:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/COPYING.mbsd@1.1, 2007-04-13 19:10:05-04:00, stenn@whimsy.udel.edu +26 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/COPYING.mbsd
+
+  libopts/COPYING.mbsd@1.0, 2007-04-13 19:10:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/MakeDefs.inc@1.1, 2007-04-13 19:10:05-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/MakeDefs.inc
+
+  libopts/MakeDefs.inc@1.0, 2007-04-13 19:10:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/Makefile.am@1.1, 2007-04-13 19:10:05-04:00, stenn@whimsy.udel.edu +24 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/Makefile.am
+
+  libopts/Makefile.am@1.0, 2007-04-13 19:10:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/README@1.1, 2007-04-13 19:10:05-04:00, stenn@whimsy.udel.edu +93 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/README
+
+  libopts/README@1.0, 2007-04-13 19:10:05-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/autoopts.c@1.1, 2007-04-13 19:10:06-04:00, stenn@whimsy.udel.edu +1101 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/autoopts.c
+
+  libopts/autoopts.c@1.0, 2007-04-13 19:10:06-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/autoopts.h@1.1, 2007-04-13 19:10:06-04:00, stenn@whimsy.udel.edu +377 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/autoopts.h
+
+  libopts/autoopts.h@1.0, 2007-04-13 19:10:06-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/autoopts/options.h@1.1, 2007-04-13 19:10:30-04:00, stenn@whimsy.udel.edu +964 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/autoopts/options.h
+
+  libopts/autoopts/options.h@1.0, 2007-04-13 19:10:30-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/autoopts/usage-txt.h@1.1, 2007-04-13 19:10:31-04:00, stenn@whimsy.udel.edu +355 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/autoopts/usage-txt.h
+
+  libopts/autoopts/usage-txt.h@1.0, 2007-04-13 19:10:31-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/boolean.c@1.1, 2007-04-13 19:10:07-04:00, stenn@whimsy.udel.edu +106 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/boolean.c
+
+  libopts/boolean.c@1.0, 2007-04-13 19:10:07-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/compat.h@1.1, 2007-04-13 19:10:38-04:00, stenn@whimsy.udel.edu +314 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/compat/compat.h
+
+  libopts/compat/compat.h@1.0, 2007-04-13 19:10:38-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/pathfind.c@1.1, 2007-04-13 19:10:38-04:00, stenn@whimsy.udel.edu +339 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/compat/pathfind.c
+
+  libopts/compat/pathfind.c@1.0, 2007-04-13 19:10:38-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/snprintf.c@1.1, 2007-04-13 19:10:39-04:00, stenn@whimsy.udel.edu +60 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/compat/snprintf.c
+
+  libopts/compat/snprintf.c@1.0, 2007-04-13 19:10:39-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/strchr.c@1.1, 2007-04-13 19:10:39-04:00, stenn@whimsy.udel.edu +60 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/compat/strchr.c
+
+  libopts/compat/strchr.c@1.0, 2007-04-13 19:10:39-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/strdup.c@1.1, 2007-04-13 19:10:39-04:00, stenn@whimsy.udel.edu +19 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/compat/strdup.c
+
+  libopts/compat/strdup.c@1.0, 2007-04-13 19:10:39-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/compat/windows-config.h@1.1, 2007-04-13 19:10:39-04:00, stenn@whimsy.udel.edu +129 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/compat/windows-config.h
+
+  libopts/compat/windows-config.h@1.0, 2007-04-13 19:10:39-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/configfile.c@1.1, 2007-04-13 19:10:07-04:00, stenn@whimsy.udel.edu +1288 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/configfile.c
+
+  libopts/configfile.c@1.0, 2007-04-13 19:10:07-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/cook.c@1.1, 2007-04-13 19:10:08-04:00, stenn@whimsy.udel.edu +354 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/cook.c
+
+  libopts/cook.c@1.0, 2007-04-13 19:10:08-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/enumeration.c@1.1, 2007-04-13 19:10:09-04:00, stenn@whimsy.udel.edu +498 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/enumeration.c
+
+  libopts/enumeration.c@1.0, 2007-04-13 19:10:09-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/environment.c@1.1, 2007-04-13 19:10:09-04:00, stenn@whimsy.udel.edu +260 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/environment.c
+
+  libopts/environment.c@1.0, 2007-04-13 19:10:09-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/genshell.c@1.1, 2007-04-13 19:10:10-04:00, stenn@whimsy.udel.edu +345 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/genshell.c
+
+  libopts/genshell.c@1.0, 2007-04-13 19:10:10-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/genshell.h@1.1, 2007-04-13 19:10:10-04:00, stenn@whimsy.udel.edu +149 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/genshell.h
+
+  libopts/genshell.h@1.0, 2007-04-13 19:10:10-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/libopts.c@1.1, 2007-04-13 19:10:10-04:00, stenn@whimsy.udel.edu +30 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/libopts.c
+
+  libopts/libopts.c@1.0, 2007-04-13 19:10:10-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/load.c@1.1, 2007-04-13 19:10:11-04:00, stenn@whimsy.udel.edu +563 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/load.c
+
+  libopts/load.c@1.0, 2007-04-13 19:10:11-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/m4/libopts.m4@1.1, 2007-04-13 19:10:43-04:00, stenn@whimsy.udel.edu +489 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/m4/libopts.m4
+
+  libopts/m4/libopts.m4@1.0, 2007-04-13 19:10:43-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/m4/liboptschk.m4@1.1, 2007-04-13 19:10:43-04:00, stenn@whimsy.udel.edu +42 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/m4/liboptschk.m4
+
+  libopts/m4/liboptschk.m4@1.0, 2007-04-13 19:10:43-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/makeshell.c@1.1, 2007-04-13 19:10:11-04:00, stenn@whimsy.udel.edu +1122 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/makeshell.c
+
+  libopts/makeshell.c@1.0, 2007-04-13 19:10:11-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/nested.c@1.1, 2007-04-13 19:10:12-04:00, stenn@whimsy.udel.edu +733 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/nested.c
+
+  libopts/nested.c@1.0, 2007-04-13 19:10:12-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/numeric.c@1.1, 2007-04-13 19:10:12-04:00, stenn@whimsy.udel.edu +93 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/numeric.c
+
+  libopts/numeric.c@1.0, 2007-04-13 19:10:12-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/pgusage.c@1.1, 2007-04-13 19:10:12-04:00, stenn@whimsy.udel.edu +157 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/pgusage.c
+
+  libopts/pgusage.c@1.0, 2007-04-13 19:10:12-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/proto.h@1.1, 2007-04-13 19:10:12-04:00, stenn@whimsy.udel.edu +91 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/proto.h
+
+  libopts/proto.h@1.0, 2007-04-13 19:10:12-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/putshell.c@1.1, 2007-04-13 19:10:12-04:00, stenn@whimsy.udel.edu +335 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/putshell.c
+
+  libopts/putshell.c@1.0, 2007-04-13 19:10:12-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/restore.c@1.1, 2007-04-13 19:10:13-04:00, stenn@whimsy.udel.edu +250 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/restore.c
+
+  libopts/restore.c@1.0, 2007-04-13 19:10:13-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/save.c@1.1, 2007-04-13 19:10:14-04:00, stenn@whimsy.udel.edu +512 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/save.c
+
+  libopts/save.c@1.0, 2007-04-13 19:10:14-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/sort.c@1.1, 2007-04-13 19:10:14-04:00, stenn@whimsy.udel.edu +359 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/sort.c
+
+  libopts/sort.c@1.0, 2007-04-13 19:10:14-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/stack.c@1.1, 2007-04-13 19:10:15-04:00, stenn@whimsy.udel.edu +269 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/stack.c
+
+  libopts/stack.c@1.0, 2007-04-13 19:10:15-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/streqvcmp.c@1.1, 2007-04-13 19:10:15-04:00, stenn@whimsy.udel.edu +289 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/streqvcmp.c
+
+  libopts/streqvcmp.c@1.0, 2007-04-13 19:10:15-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/text_mmap.c@1.1, 2007-04-13 19:10:16-04:00, stenn@whimsy.udel.edu +363 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/text_mmap.c
+
+  libopts/text_mmap.c@1.0, 2007-04-13 19:10:16-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/tokenize.c@1.1, 2007-04-13 19:10:17-04:00, stenn@whimsy.udel.edu +321 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/tokenize.c
+
+  libopts/tokenize.c@1.0, 2007-04-13 19:10:17-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/usage.c@1.1, 2007-04-13 19:10:17-04:00, stenn@whimsy.udel.edu +731 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/usage.c
+
+  libopts/usage.c@1.0, 2007-04-13 19:10:17-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/version.c@1.1, 2007-04-13 19:10:18-04:00, stenn@whimsy.udel.edu +176 -0
+    BitKeeper file /deacon/backroom/ntp-stable/libopts/version.c
+
+  libopts/version.c@1.0, 2007-04-13 19:10:18-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/COPYING.lgpl@1.1, 2007-04-13 19:09:02-04:00, stenn@whimsy.udel.edu +502 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/COPYING.lgpl
+
+  sntp/libopts/COPYING.lgpl@1.0, 2007-04-13 19:09:02-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/COPYING.mbsd@1.1, 2007-04-13 19:09:03-04:00, stenn@whimsy.udel.edu +26 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/COPYING.mbsd
+
+  sntp/libopts/COPYING.mbsd@1.0, 2007-04-13 19:09:03-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/MakeDefs.inc@1.1, 2007-04-13 19:09:03-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/MakeDefs.inc
+
+  sntp/libopts/MakeDefs.inc@1.0, 2007-04-13 19:09:03-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/Makefile.am@1.1, 2007-04-13 19:09:03-04:00, stenn@whimsy.udel.edu +24 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/Makefile.am
+
+  sntp/libopts/Makefile.am@1.0, 2007-04-13 19:09:03-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/README@1.1, 2007-04-13 19:09:03-04:00, stenn@whimsy.udel.edu +93 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/README
+
+  sntp/libopts/README@1.0, 2007-04-13 19:09:03-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/autoopts.c@1.1, 2007-04-13 19:08:52-04:00, stenn@whimsy.udel.edu +1101 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/autoopts.c
+
+  sntp/libopts/autoopts.c@1.0, 2007-04-13 19:08:52-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/autoopts.h@1.1, 2007-04-13 19:08:51-04:00, stenn@whimsy.udel.edu +377 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/autoopts.h
+
+  sntp/libopts/autoopts.h@1.0, 2007-04-13 19:08:51-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/autoopts/options.h@1.1, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +964 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/autoopts/options.h
+
+  sntp/libopts/autoopts/options.h@1.0, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/autoopts/usage-txt.h@1.1, 2007-04-13 19:08:49-04:00, stenn@whimsy.udel.edu +355 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/autoopts/usage-txt.h
+
+  sntp/libopts/autoopts/usage-txt.h@1.0, 2007-04-13 19:08:49-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/boolean.c@1.1, 2007-04-13 19:08:52-04:00, stenn@whimsy.udel.edu +106 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/boolean.c
+
+  sntp/libopts/boolean.c@1.0, 2007-04-13 19:08:52-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/compat.h@1.1, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +314 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/compat/compat.h
+
+  sntp/libopts/compat/compat.h@1.0, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/pathfind.c@1.1, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +339 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/compat/pathfind.c
+
+  sntp/libopts/compat/pathfind.c@1.0, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/snprintf.c@1.1, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +60 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/compat/snprintf.c
+
+  sntp/libopts/compat/snprintf.c@1.0, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/strchr.c@1.1, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +60 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/compat/strchr.c
+
+  sntp/libopts/compat/strchr.c@1.0, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/strdup.c@1.1, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +19 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/compat/strdup.c
+
+  sntp/libopts/compat/strdup.c@1.0, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/compat/windows-config.h@1.1, 2007-04-13 19:08:48-04:00, stenn@whimsy.udel.edu +129 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/compat/windows-config.h
+
+  sntp/libopts/compat/windows-config.h@1.0, 2007-04-13 19:08:47-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/configfile.c@1.1, 2007-04-13 19:08:52-04:00, stenn@whimsy.udel.edu +1288 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/configfile.c
+
+  sntp/libopts/configfile.c@1.0, 2007-04-13 19:08:52-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/cook.c@1.1, 2007-04-13 19:08:53-04:00, stenn@whimsy.udel.edu +354 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/cook.c
+
+  sntp/libopts/cook.c@1.0, 2007-04-13 19:08:53-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/enumeration.c@1.1, 2007-04-13 19:08:53-04:00, stenn@whimsy.udel.edu +498 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/enumeration.c
+
+  sntp/libopts/enumeration.c@1.0, 2007-04-13 19:08:53-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/environment.c@1.1, 2007-04-13 19:08:54-04:00, stenn@whimsy.udel.edu +260 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/environment.c
+
+  sntp/libopts/environment.c@1.0, 2007-04-13 19:08:54-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/genshell.c@1.1, 2007-04-13 19:08:55-04:00, stenn@whimsy.udel.edu +345 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/genshell.c
+
+  sntp/libopts/genshell.c@1.0, 2007-04-13 19:08:55-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/genshell.h@1.1, 2007-04-13 19:08:51-04:00, stenn@whimsy.udel.edu +149 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/genshell.h
+
+  sntp/libopts/genshell.h@1.0, 2007-04-13 19:08:51-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/libopts.c@1.1, 2007-04-13 19:08:50-04:00, stenn@whimsy.udel.edu +30 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/libopts.c
+
+  sntp/libopts/libopts.c@1.0, 2007-04-13 19:08:50-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/load.c@1.1, 2007-04-13 19:08:55-04:00, stenn@whimsy.udel.edu +563 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/load.c
+
+  sntp/libopts/load.c@1.0, 2007-04-13 19:08:55-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/m4/libopts.m4@1.1, 2007-04-13 19:08:50-04:00, stenn@whimsy.udel.edu +489 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/m4/libopts.m4
+
+  sntp/libopts/m4/libopts.m4@1.0, 2007-04-13 19:08:50-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/m4/liboptschk.m4@1.1, 2007-04-13 19:08:50-04:00, stenn@whimsy.udel.edu +42 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/m4/liboptschk.m4
+
+  sntp/libopts/m4/liboptschk.m4@1.0, 2007-04-13 19:08:50-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/makeshell.c@1.1, 2007-04-13 19:08:56-04:00, stenn@whimsy.udel.edu +1122 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/makeshell.c
+
+  sntp/libopts/makeshell.c@1.0, 2007-04-13 19:08:56-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/nested.c@1.1, 2007-04-13 19:08:57-04:00, stenn@whimsy.udel.edu +733 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/nested.c
+
+  sntp/libopts/nested.c@1.0, 2007-04-13 19:08:57-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/numeric.c@1.1, 2007-04-13 19:08:57-04:00, stenn@whimsy.udel.edu +93 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/numeric.c
+
+  sntp/libopts/numeric.c@1.0, 2007-04-13 19:08:57-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/pgusage.c@1.1, 2007-04-13 19:08:57-04:00, stenn@whimsy.udel.edu +157 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/pgusage.c
+
+  sntp/libopts/pgusage.c@1.0, 2007-04-13 19:08:57-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/proto.h@1.1, 2007-04-13 19:08:52-04:00, stenn@whimsy.udel.edu +91 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/proto.h
+
+  sntp/libopts/proto.h@1.0, 2007-04-13 19:08:52-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/putshell.c@1.1, 2007-04-13 19:08:57-04:00, stenn@whimsy.udel.edu +335 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/putshell.c
+
+  sntp/libopts/putshell.c@1.0, 2007-04-13 19:08:57-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/restore.c@1.1, 2007-04-13 19:08:58-04:00, stenn@whimsy.udel.edu +250 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/restore.c
+
+  sntp/libopts/restore.c@1.0, 2007-04-13 19:08:57-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/save.c@1.1, 2007-04-13 19:08:58-04:00, stenn@whimsy.udel.edu +512 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/save.c
+
+  sntp/libopts/save.c@1.0, 2007-04-13 19:08:58-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/sort.c@1.1, 2007-04-13 19:08:59-04:00, stenn@whimsy.udel.edu +359 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/sort.c
+
+  sntp/libopts/sort.c@1.0, 2007-04-13 19:08:59-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/stack.c@1.1, 2007-04-13 19:08:59-04:00, stenn@whimsy.udel.edu +269 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/stack.c
+
+  sntp/libopts/stack.c@1.0, 2007-04-13 19:08:59-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/streqvcmp.c@1.1, 2007-04-13 19:09:00-04:00, stenn@whimsy.udel.edu +289 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/streqvcmp.c
+
+  sntp/libopts/streqvcmp.c@1.0, 2007-04-13 19:09:00-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/text_mmap.c@1.1, 2007-04-13 19:09:01-04:00, stenn@whimsy.udel.edu +363 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/text_mmap.c
+
+  sntp/libopts/text_mmap.c@1.0, 2007-04-13 19:09:01-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/tokenize.c@1.1, 2007-04-13 19:09:01-04:00, stenn@whimsy.udel.edu +321 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/tokenize.c
+
+  sntp/libopts/tokenize.c@1.0, 2007-04-13 19:09:01-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/usage.c@1.1, 2007-04-13 19:09:02-04:00, stenn@whimsy.udel.edu +731 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/usage.c
+
+  sntp/libopts/usage.c@1.0, 2007-04-13 19:09:02-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/version.c@1.1, 2007-04-13 19:09:02-04:00, stenn@whimsy.udel.edu +176 -0
+    BitKeeper file /deacon/backroom/ntp-stable/sntp/libopts/version.c
+
+  sntp/libopts/version.c@1.0, 2007-04-13 19:09:02-04:00, stenn@whimsy.udel.edu +0 -0
+
+ChangeSet@1.1473, 2007-04-12 06:32:19-04:00, stenn@whimsy.udel.edu +1 -0
+  Added ntp2 mirror
+
+  BitKeeper/triggers/2mirrors@1.4, 2007-04-12 06:30:59-04:00, stenn@whimsy.udel.edu +1 -0
+    Added ntp2 mirror
+
+ChangeSet@1.1472, 2007-03-07 06:46:09-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P0
+  TAG: NTP_4_2_4P0
+
+  ntpd/ntpd-opts.c@1.56, 2007-03-07 06:45:46-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  ntpd/ntpd-opts.h@1.56, 2007-03-07 06:45:47-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0
+
+  ntpd/ntpd-opts.texi@1.55, 2007-03-07 06:45:48-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0
+
+  ntpd/ntpd.1@1.54, 2007-03-07 06:45:48-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  ntpd/ntpdsim-opts.c@1.56, 2007-03-07 06:45:49-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  ntpd/ntpdsim-opts.h@1.56, 2007-03-07 06:45:50-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0
+
+  ntpd/ntpdsim-opts.texi@1.54, 2007-03-07 06:45:51-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0
+
+  ntpd/ntpdsim.1@1.54, 2007-03-07 06:45:51-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  ntpdc/ntpdc-opts.c@1.56, 2007-03-07 06:45:52-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  ntpdc/ntpdc-opts.h@1.56, 2007-03-07 06:45:53-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0
+
+  ntpdc/ntpdc-opts.texi@1.54, 2007-03-07 06:45:53-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0
+
+  ntpdc/ntpdc.1@1.54, 2007-03-07 06:45:54-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  ntpq/ntpq-opts.c@1.58, 2007-03-07 06:45:55-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  ntpq/ntpq-opts.h@1.58, 2007-03-07 06:45:56-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0
+
+  ntpq/ntpq-opts.texi@1.55, 2007-03-07 06:45:57-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0
+
+  ntpq/ntpq.1@1.54, 2007-03-07 06:45:58-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  packageinfo.sh@1.74, 2007-03-07 06:45:58-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  sntp/sntp-opts.c@1.55, 2007-03-07 06:45:59-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  sntp/sntp-opts.h@1.55, 2007-03-07 06:46:00-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0
+
+  sntp/sntp-opts.texi@1.52, 2007-03-07 06:46:01-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0
+
+  sntp/sntp.1@1.55, 2007-03-07 06:46:01-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  util/ntp-keygen-opts.c@1.55, 2007-03-07 06:46:03-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+  util/ntp-keygen-opts.h@1.55, 2007-03-07 06:46:03-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0
+
+  util/ntp-keygen-opts.texi@1.53, 2007-03-07 06:46:04-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0
+
+  util/ntp-keygen.1@1.53, 2007-03-07 06:46:05-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0
+
+ChangeSet@1.1471, 2007-03-07 00:53:31-05:00, stenn@whimsy.udel.edu +1 -0
+  time to release
+
+  packageinfo.sh@1.73, 2007-03-07 00:53:21-05:00, stenn@whimsy.udel.edu +3 -1
+    time to release
+
+ChangeSet@1.1470, 2007-03-03 19:21:29-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 793] Update Hans Lambermont's email address in ntpsweep
+
+  ChangeLog@1.10, 2007-03-03 19:21:16-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 793] Update Hans Lambermont's email address in ntpsweep
+
+  scripts/ntpsweep.in@1.3, 2007-03-03 19:21:17-05:00, stenn@whimsy.udel.edu +1 -2
+    [Bug 793] Update Hans Lambermont's email address in ntpsweep
+
+ChangeSet@1.1469, 2007-02-24 06:42:26-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P0_RC5
+  TAG: NTP_4_2_4P0_RC5
+
+  ntpd/ntpd-opts.c@1.55, 2007-02-24 06:42:04-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  ntpd/ntpd-opts.h@1.55, 2007-02-24 06:42:05-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC5
+
+  ntpd/ntpd-opts.texi@1.54, 2007-02-24 06:42:06-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0_RC5
+
+  ntpd/ntpd.1@1.53, 2007-02-24 06:42:07-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  ntpd/ntpdsim-opts.c@1.55, 2007-02-24 06:42:08-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  ntpd/ntpdsim-opts.h@1.55, 2007-02-24 06:42:08-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC5
+
+  ntpd/ntpdsim-opts.texi@1.53, 2007-02-24 06:42:09-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0_RC5
+
+  ntpd/ntpdsim.1@1.53, 2007-02-24 06:42:10-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  ntpdc/ntpdc-opts.c@1.55, 2007-02-24 06:42:11-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  ntpdc/ntpdc-opts.h@1.55, 2007-02-24 06:42:11-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC5
+
+  ntpdc/ntpdc-opts.texi@1.53, 2007-02-24 06:42:12-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0_RC5
+
+  ntpdc/ntpdc.1@1.53, 2007-02-24 06:42:13-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  ntpq/ntpq-opts.c@1.57, 2007-02-24 06:42:13-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  ntpq/ntpq-opts.h@1.57, 2007-02-24 06:42:14-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC5
+
+  ntpq/ntpq-opts.texi@1.54, 2007-02-24 06:42:15-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0_RC5
+
+  ntpq/ntpq.1@1.53, 2007-02-24 06:42:16-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  packageinfo.sh@1.72, 2007-02-24 06:42:17-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0_RC5
+
+  sntp/sntp-opts.c@1.54, 2007-02-24 06:42:17-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  sntp/sntp-opts.h@1.54, 2007-02-24 06:42:18-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC5
+
+  sntp/sntp-opts.texi@1.51, 2007-02-24 06:42:18-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0_RC5
+
+  sntp/sntp.1@1.54, 2007-02-24 06:42:19-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  util/ntp-keygen-opts.c@1.54, 2007-02-24 06:42:20-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+  util/ntp-keygen-opts.h@1.54, 2007-02-24 06:42:21-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC5
+
+  util/ntp-keygen-opts.texi@1.52, 2007-02-24 06:42:21-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0_RC5
+
+  util/ntp-keygen.1@1.52, 2007-02-24 06:42:22-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC5
+
+ChangeSet@1.1468, 2007-02-24 05:07:16-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 628] Fallback to ntp discipline not working for large offsets
+
+  ntpd/ntp_loopfilter.c@1.128, 2007-02-24 05:07:04-05:00, stenn@whimsy.udel.edu +9 -24
+    [Bug 628] Fallback to ntp discipline not working for large offsets
+
+ChangeSet@1.1467, 2007-02-21 15:16:15-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 776] Remove the obsolete r: from the getopt string in ntpdate
+
+  ntpdate/ntpdate.c@1.61, 2007-02-21 15:16:00-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 776] Remove the obsolete r: from the getopt string in ntpdate
+
+ChangeSet@1.1466, 2007-02-19 06:46:30-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4P0_RC4
+  TAG: NTP_4_2_4P0_RC4
+
+  ntpd/ntpd-opts.c@1.54, 2007-02-19 06:46:11-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  ntpd/ntpd-opts.h@1.54, 2007-02-19 06:46:11-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC4
+
+  ntpd/ntpd-opts.texi@1.53, 2007-02-19 06:46:12-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  ntpd/ntpd.1@1.52, 2007-02-19 06:46:13-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  ntpd/ntpdsim-opts.c@1.54, 2007-02-19 06:46:13-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  ntpd/ntpdsim-opts.h@1.54, 2007-02-19 06:46:14-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC4
+
+  ntpd/ntpdsim-opts.texi@1.52, 2007-02-19 06:46:15-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0_RC4
+
+  ntpd/ntpdsim.1@1.52, 2007-02-19 06:46:16-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  ntpdc/ntpdc-opts.c@1.54, 2007-02-19 06:46:16-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  ntpdc/ntpdc-opts.h@1.54, 2007-02-19 06:46:17-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC4
+
+  ntpdc/ntpdc-opts.texi@1.52, 2007-02-19 06:46:18-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  ntpdc/ntpdc.1@1.52, 2007-02-19 06:46:18-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  ntpq/ntpq-opts.c@1.56, 2007-02-19 06:46:19-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  ntpq/ntpq-opts.h@1.56, 2007-02-19 06:46:19-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC4
+
+  ntpq/ntpq-opts.texi@1.53, 2007-02-19 06:46:20-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  ntpq/ntpq.1@1.52, 2007-02-19 06:46:21-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  packageinfo.sh@1.71, 2007-02-19 06:46:22-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC4
+
+  sntp/sntp-opts.c@1.53, 2007-02-19 06:46:22-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  sntp/sntp-opts.h@1.53, 2007-02-19 06:46:23-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC4
+
+  sntp/sntp-opts.texi@1.50, 2007-02-19 06:46:24-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4P0_RC4
+
+  sntp/sntp.1@1.53, 2007-02-19 06:46:24-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  util/ntp-keygen-opts.c@1.53, 2007-02-19 06:46:25-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  util/ntp-keygen-opts.h@1.53, 2007-02-19 06:46:25-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4P0_RC4
+
+  util/ntp-keygen-opts.texi@1.51, 2007-02-19 06:46:26-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+  util/ntp-keygen.1@1.51, 2007-02-19 06:46:27-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4P0_RC4
+
+ChangeSet@1.1465, 2007-02-19 00:19:22-05:00, stenn@whimsy.udel.edu +1 -0
+  Ready to go...
+
+  packageinfo.sh@1.70, 2007-02-19 00:19:05-05:00, stenn@whimsy.udel.edu +2 -2
+    Ready to go...
+
+ChangeSet@1.1464, 2007-02-19 00:14:29-05:00, stenn@whimsy.udel.edu +3 -0
+  [Bug 776] Remove unimplemented "rate" flag from ntpdate
+
+  ChangeLog@1.9, 2007-02-19 00:14:19-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 776] Remove unimplemented "rate" flag from ntpdate
+
+  ntpdate/Makefile.am@1.15, 2007-02-19 00:13:50-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 776] Remove unimplemented "rate" flag from ntpdate
+
+  ntpdate/ntpdate.c@1.60, 2007-02-19 00:13:51-05:00, stenn@whimsy.udel.edu +1 -21
+    [Bug 776] Remove unimplemented "rate" flag from ntpdate
+
+ChangeSet@1.1463, 2007-02-05 06:47:44-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4_RC3
+  TAG: NTP_4_2_4_RC3
+
+  ntpd/ntpd-opts.c@1.53, 2007-02-05 06:47:21-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  ntpd/ntpd-opts.h@1.53, 2007-02-05 06:47:21-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC3
+
+  ntpd/ntpd-opts.texi@1.52, 2007-02-05 06:47:22-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC3
+
+  ntpd/ntpd.1@1.51, 2007-02-05 06:47:23-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  ntpd/ntpdsim-opts.c@1.53, 2007-02-05 06:47:24-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  ntpd/ntpdsim-opts.h@1.53, 2007-02-05 06:47:24-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC3
+
+  ntpd/ntpdsim-opts.texi@1.51, 2007-02-05 06:47:25-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC3
+
+  ntpd/ntpdsim.1@1.51, 2007-02-05 06:47:26-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  ntpdc/ntpdc-opts.c@1.53, 2007-02-05 06:47:26-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  ntpdc/ntpdc-opts.h@1.53, 2007-02-05 06:47:28-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC3
+
+  ntpdc/ntpdc-opts.texi@1.51, 2007-02-05 06:47:28-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC3
+
+  ntpdc/ntpdc.1@1.51, 2007-02-05 06:47:29-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  ntpq/ntpq-opts.c@1.55, 2007-02-05 06:47:30-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  ntpq/ntpq-opts.h@1.55, 2007-02-05 06:47:30-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC3
+
+  ntpq/ntpq-opts.texi@1.52, 2007-02-05 06:47:31-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC3
+
+  ntpq/ntpq.1@1.51, 2007-02-05 06:47:32-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  packageinfo.sh@1.69, 2007-02-05 06:47:33-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC3
+
+  sntp/sntp-opts.c@1.52, 2007-02-05 06:47:33-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  sntp/sntp-opts.h@1.52, 2007-02-05 06:47:34-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC3
+
+  sntp/sntp-opts.texi@1.49, 2007-02-05 06:47:35-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC3
+
+  sntp/sntp.1@1.52, 2007-02-05 06:47:37-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  util/ntp-keygen-opts.c@1.52, 2007-02-05 06:47:38-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+  util/ntp-keygen-opts.h@1.52, 2007-02-05 06:47:39-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC3
+
+  util/ntp-keygen-opts.texi@1.50, 2007-02-05 06:47:39-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC3
+
+  util/ntp-keygen.1@1.50, 2007-02-05 06:47:40-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC3
+
+ChangeSet@1.1462, 2007-02-04 23:08:28-05:00, stenn@whimsy.udel.edu +1 -0
+  Danny forgot to pull before editing - replace the change he undid.
+
+  ntpq/ntpq-subs.c@1.27, 2007-02-04 23:08:17-05:00, stenn@whimsy.udel.edu +3 -2
+    Danny forgot to pull before editing - replace the change he undid.
+
+ChangeSet@1.1461, 2007-02-04 22:53:32-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 586] Avoid lookups if AI_NUMERICHOST is set.
+
+  ChangeLog@1.8, 2007-02-04 22:53:22-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 586] Avoid lookups if AI_NUMERICHOST is set.
+
+ChangeSet@1.1460, 2007-02-04 21:51:15-05:00, mayer@pogo.udel.edu +1 -0
+  Bug #586 Don't do lookups if AI_NUMERICHOST is set
+
+  libntp/ntp_rfc2553.c@1.37, 2007-02-04 21:51:01-05:00, mayer@pogo.udel.edu +6 -0
+    Bug #586 Don't do lookups if AI_NUMERICHOST is set
+
+ChangeSet@1.1459, 2007-02-04 21:44:13-05:00, mayer@pogo.udel.edu +1 -0
+  Bug #586 Check for <4 characters for the refid first
+
+  ntpq/ntpq-subs.c@1.26, 2007-02-04 21:43:38-05:00, mayer@pogo.udel.edu +9 -10
+    Bug #586 Check for <4 characters for the refid first
+
+ChangeSet@1.1458, 2007-02-04 17:56:17+00:00, kardel@pogo.udel.edu +1 -0
+  ntpd.c:
+    comment clarification about capabilities used
+
+  ntpd/ntpd.c@1.84, 2007-02-04 17:55:31+00:00, kardel@pogo.udel.edu +4 -7
+    comment clarification about capabilities used
+
+ChangeSet@1.1451.1.1, 2007-02-04 17:47:20+00:00, kardel@pogo.udel.edu +1 -0
+  ntpd.c:
+    Bug 765:
+    use Linux capability mechanism to allow dynamic interface tracking to continue in 
+    unprivileged mode.
+
+  ntpd/ntpd.c@1.83, 2007-02-04 17:45:55+00:00, kardel@pogo.udel.edu +11 -1
+    Bug 765:
+    use Linux capability mechanism to allow dynamic interface tracking to continue in 
+    unprivileged mode.
+
+ChangeSet@1.1456, 2007-01-30 06:44:11-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4_RC2
+  TAG: NTP_4_2_4_RC2
+
+  ntpd/ntpd-opts.c@1.52, 2007-01-30 06:43:46-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  ntpd/ntpd-opts.h@1.52, 2007-01-30 06:43:46-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC2
+
+  ntpd/ntpd-opts.texi@1.51, 2007-01-30 06:43:47-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC2
+
+  ntpd/ntpd.1@1.50, 2007-01-30 06:43:48-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  ntpd/ntpdsim-opts.c@1.52, 2007-01-30 06:43:49-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  ntpd/ntpdsim-opts.h@1.52, 2007-01-30 06:43:50-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC2
+
+  ntpd/ntpdsim-opts.texi@1.50, 2007-01-30 06:43:51-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC2
+
+  ntpd/ntpdsim.1@1.50, 2007-01-30 06:43:52-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  ntpdc/ntpdc-opts.c@1.52, 2007-01-30 06:43:52-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  ntpdc/ntpdc-opts.h@1.52, 2007-01-30 06:43:54-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC2
+
+  ntpdc/ntpdc-opts.texi@1.50, 2007-01-30 06:43:55-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC2
+
+  ntpdc/ntpdc.1@1.50, 2007-01-30 06:43:55-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  ntpq/ntpq-opts.c@1.54, 2007-01-30 06:43:56-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  ntpq/ntpq-opts.h@1.54, 2007-01-30 06:43:57-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC2
+
+  ntpq/ntpq-opts.texi@1.51, 2007-01-30 06:43:57-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC2
+
+  ntpq/ntpq.1@1.50, 2007-01-30 06:43:58-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  packageinfo.sh@1.68, 2007-01-30 06:43:59-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC2
+
+  sntp/sntp-opts.c@1.51, 2007-01-30 06:43:59-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  sntp/sntp-opts.h@1.51, 2007-01-30 06:44:00-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC2
+
+  sntp/sntp-opts.texi@1.48, 2007-01-30 06:44:01-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC2
+
+  sntp/sntp.1@1.51, 2007-01-30 06:44:02-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  util/ntp-keygen-opts.c@1.51, 2007-01-30 06:44:03-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+  util/ntp-keygen-opts.h@1.51, 2007-01-30 06:44:03-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC2
+
+  util/ntp-keygen-opts.texi@1.49, 2007-01-30 06:44:04-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC2
+
+  util/ntp-keygen.1@1.49, 2007-01-30 06:44:05-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC2
+
+ChangeSet@1.1455, 2007-01-29 21:20:08-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 770] Fix numeric parameters to ntp-keygen (Alain Guibert).
+
+  ChangeLog@1.7, 2007-01-29 21:19:52-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 770] Fix numeric parameters to ntp-keygen (Alain Guibert).
+
+  util/ntp-keygen.c@1.38, 2007-01-29 21:19:53-05:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 770] Fix numeric parameters to ntp-keygen (Alain Guibert).
+
+ChangeSet@1.1454, 2007-01-29 17:43:41-05:00, stenn@whimsy.udel.edu +1 -0
+  More ChangeLog -> CommitLog fixes
+
+  scripts/genCommitLog@1.4, 2007-01-29 17:42:48-05:00, stenn@whimsy.udel.edu +2 -2
+    More ChangeLog -> CommitLog fixes
+
+ChangeSet@1.1453, 2007-01-29 16:52:38-05:00, stenn@whimsy.udel.edu +3 -0
+  More ChangeLog -> CommitLog fixes
+
+  Makefile.am@1.72, 2007-01-29 16:52:06-05:00, stenn@whimsy.udel.edu +5 -5
+    More ChangeLog -> CommitLog fixes
+
+  scripts/Makefile.am@1.15, 2007-01-29 16:52:07-05:00, stenn@whimsy.udel.edu +1 -1
+    More ChangeLog -> CommitLog fixes
+
+  scripts/genCommitLog@1.3, 2007-01-29 16:09:19-05:00, stenn@whimsy.udel.edu +0 -0
+    Rename: scripts/genChangeLog -> scripts/genCommitLog
+
+ChangeSet@1.1452, 2007-01-28 23:24:05-05:00, stenn@whimsy.udel.edu +1 -0
+  Entries for bugs 765 and 768
+
+  ChangeLog@1.6, 2007-01-28 23:23:45-05:00, stenn@whimsy.udel.edu +2 -0
+    Entries for bugs 765 and 768
+
+ChangeSet@1.1451, 2007-01-27 08:54:51+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    fix misleading error message when calling io_setbclient() and
+    broadcast sockets are already open and not new sockets need to
+    be opened.
+    Bug 768: fix binding for broadcast client mode (Ulrich Weber)
+
+  ntpd/ntp_io.c@1.247, 2007-01-27 08:51:50+00:00, kardel@pogo.udel.edu +6 -3
+    fix misleading error message when calling io_setbclient() and
+    broadcast sockets are already open and not new sockets need to
+    be opened.
+
+  ntpd/ntp_io.c@1.246, 2007-01-27 08:24:25+00:00, kardel@pogo.udel.edu +2 -2
+    Bug 768: fix binding for broadcast client mode (Ulrich Weber)
+
+ChangeSet@1.1450, 2007-01-23 04:47:08-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4_RC1
+  TAG: NTP_4_2_4_RC1
+
+  ntpd/ntpd-opts.c@1.51, 2007-01-23 04:46:47-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  ntpd/ntpd-opts.h@1.51, 2007-01-23 04:46:48-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC1
+
+  ntpd/ntpd-opts.texi@1.50, 2007-01-23 04:46:48-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  ntpd/ntpd.1@1.49, 2007-01-23 04:46:49-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  ntpd/ntpdsim-opts.c@1.51, 2007-01-23 04:46:50-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  ntpd/ntpdsim-opts.h@1.51, 2007-01-23 04:46:50-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC1
+
+  ntpd/ntpdsim-opts.texi@1.49, 2007-01-23 04:46:52-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC1
+
+  ntpd/ntpdsim.1@1.49, 2007-01-23 04:46:52-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  ntpdc/ntpdc-opts.c@1.51, 2007-01-23 04:46:53-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  ntpdc/ntpdc-opts.h@1.51, 2007-01-23 04:46:54-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC1
+
+  ntpdc/ntpdc-opts.texi@1.49, 2007-01-23 04:46:54-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  ntpdc/ntpdc.1@1.49, 2007-01-23 04:46:55-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  ntpq/ntpq-opts.c@1.53, 2007-01-23 04:46:56-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  ntpq/ntpq-opts.h@1.53, 2007-01-23 04:46:57-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC1
+
+  ntpq/ntpq-opts.texi@1.50, 2007-01-23 04:46:57-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  ntpq/ntpq.1@1.49, 2007-01-23 04:46:58-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  packageinfo.sh@1.67, 2007-01-23 04:46:59-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC1
+
+  sntp/sntp-opts.c@1.50, 2007-01-23 04:47:00-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  sntp/sntp-opts.h@1.50, 2007-01-23 04:47:00-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC1
+
+  sntp/sntp-opts.texi@1.47, 2007-01-23 04:47:01-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4_RC1
+
+  sntp/sntp.1@1.50, 2007-01-23 04:47:02-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  util/ntp-keygen-opts.c@1.50, 2007-01-23 04:47:03-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  util/ntp-keygen-opts.h@1.50, 2007-01-23 04:47:04-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4_RC1
+
+  util/ntp-keygen-opts.texi@1.48, 2007-01-23 04:47:04-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+  util/ntp-keygen.1@1.48, 2007-01-23 04:47:05-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4_RC1
+
+ChangeSet@1.1449, 2007-01-21 12:44:07-05:00, stenn@whimsy.udel.edu +1 -0
+  Danny fixed bug 360 in 4.2.2
+
+  ChangeLog@1.5, 2007-01-21 12:43:50-05:00, stenn@whimsy.udel.edu +1 -0
+    Danny fixed bug 360 in 4.2.2
+
+ChangeSet@1.1448, 2007-01-21 12:40:23-05:00, stenn@whimsy.udel.edu +1 -0
+  Danny fixed bug 239 in 4.2.2
+
+  ChangeLog@1.4, 2007-01-21 12:40:13-05:00, stenn@whimsy.udel.edu +2 -0
+    Danny fixed bug 239 in 4.2.2
+
+ChangeSet@1.1447, 2007-01-21 12:33:46-05:00, stenn@pogo.udel.edu +1 -0
+  Added bug 760 description to the ChangeLog
+
+  ChangeLog@1.3, 2007-01-21 12:33:38-05:00, stenn@pogo.udel.edu +1 -0
+    Added bug 760 description to the ChangeLog
+
+ChangeSet@1.1446, 2007-01-21 12:28:04-05:00, stenn@pogo.udel.edu +1 -0
+  Update the ChangeLog
+
+  ChangeLog@1.2, 2007-01-21 12:27:59-05:00, stenn@pogo.udel.edu +3 -0
+    Update the ChangeLog
+
+ChangeSet@1.1445, 2007-01-21 07:49:58+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    pick the right type for the recv*() length argument (use GETSOCKNAME_SOCKLEN_TYPE config.h define)
+
+  ntpd/ntp_io.c@1.245, 2007-01-21 07:48:16+00:00, kardel@pogo.udel.edu +1 -1
+    pick the right type for the recv*() length argument (use GETSOCKNAME_SOCKLEN_TYPE config.h define)
+
+ChangeSet@1.1444, 2007-01-20 14:38:38+00:00, kardel@pogo.udel.edu +1 -0
+  confopt.html:
+    move description for "dynamic" keyword into the right section
+
+  html/confopt.html@1.35, 2007-01-20 14:37:48+00:00, kardel@pogo.udel.edu +4 -3
+    move description for "dynamic" keyword into the right section
+
+ChangeSet@1.1443, 2007-01-14 08:46:00+00:00, kardel@pogo.udel.edu +1 -0
+  parse.h:
+    Bug 753: make union timestamp anonymous (Philip Prindeville)
+    now there are OSes that claim that name in netinet/ip.h...
+
+  include/parse.h@1.8, 2007-01-14 08:41:52+00:00, kardel@pogo.udel.edu +8 -4
+    Bug 753: make union timestamp anonymous (Philip Prindeville)
+    now there are OSes that claim that name in netinet/ip.h...
+
+ChangeSet@1.1442, 2007-01-13 11:36:29+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_intres.c:
+    support dynamic keyword
+
+  ntpd/ntp_intres.c@1.49, 2007-01-13 11:35:58+00:00, kardel@pogo.udel.edu +3 -1
+    support dynamic keyword
+
+ChangeSet@1.1441, 2007-01-06 18:24:18-05:00, stenn@whimsy.udel.edu +1 -0
+  Updated copyright year
+
+  html/copyright.html@1.36, 2007-01-06 18:23:45-05:00, stenn@whimsy.udel.edu +2 -2
+    Updated copyright year
+
+ChangeSet@1.1440, 2007-01-05 00:27:33-05:00, stenn@whimsy.udel.edu +4 -0
+  ChangeLog->CommitLog, NEWS->ChangeLog, Release Info->NEWS
+
+  ChangeLog@1.1, 2007-01-05 00:06:33-05:00, stenn@whimsy.udel.edu +260 -0
+    BitKeeper file /deacon/backroom/ntp-stable/ChangeLog
+
+  ChangeLog@1.0, 2007-01-05 00:06:33-05:00, stenn@whimsy.udel.edu +0 -0
+
+  CommitLog-4.1.0@1.592, 2007-01-05 00:05:52-05:00, stenn@whimsy.udel.edu +0 -0
+    Rename: ChangeLog-4.1.0 -> CommitLog-4.1.0
+
+  Makefile.am@1.71, 2007-01-05 00:27:13-05:00, stenn@whimsy.udel.edu +2 -1
+    ChangeLog->CommitLog, NEWS->ChangeLog, Release Info->NEWS
+
+  NEWS@1.87, 2007-01-05 00:27:14-05:00, stenn@whimsy.udel.edu +14 -256
+    ChangeLog->CommitLog, NEWS->ChangeLog, Release Info->NEWS
+
+ChangeSet@1.1439, 2007-01-04 23:41:02-05:00, stenn@whimsy.udel.edu +1 -0
+  ChangeLog->CommitLog in the ignore file
+
+  BitKeeper/etc/ignore@1.59, 2007-01-04 23:40:52-05:00, stenn@whimsy.udel.edu +1 -2
+    ChangeLog->CommitLog in the ignore file
+
+ChangeSet@1.1438, 2007-01-04 19:31:07-05:00, stenn@whimsy.udel.edu +1 -0
+  hostname updates for flock-build
+
+  flock-build@1.39, 2007-01-04 19:30:49-05:00, stenn@whimsy.udel.edu +15 -19
+    hostname updates for flock-build
+
+ChangeSet@1.1437, 2006-12-28 19:21:25-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_4
+  TAG: NTP_4_2_4
+
+  ntpd/ntpd-opts.c@1.50, 2006-12-28 19:21:05-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  ntpd/ntpd-opts.h@1.50, 2006-12-28 19:21:05-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4
+
+  ntpd/ntpd-opts.texi@1.49, 2006-12-28 19:21:06-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  ntpd/ntpd.1@1.48, 2006-12-28 19:21:07-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  ntpd/ntpdsim-opts.c@1.50, 2006-12-28 19:21:07-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  ntpd/ntpdsim-opts.h@1.50, 2006-12-28 19:21:08-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4
+
+  ntpd/ntpdsim-opts.texi@1.48, 2006-12-28 19:21:08-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4
+
+  ntpd/ntpdsim.1@1.48, 2006-12-28 19:21:09-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  ntpdc/ntpdc-opts.c@1.50, 2006-12-28 19:21:10-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  ntpdc/ntpdc-opts.h@1.50, 2006-12-28 19:21:10-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4
+
+  ntpdc/ntpdc-opts.texi@1.48, 2006-12-28 19:21:11-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  ntpdc/ntpdc.1@1.48, 2006-12-28 19:21:12-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  ntpq/ntpq-opts.c@1.52, 2006-12-28 19:21:12-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  ntpq/ntpq-opts.h@1.52, 2006-12-28 19:21:13-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4
+
+  ntpq/ntpq-opts.texi@1.49, 2006-12-28 19:21:13-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  ntpq/ntpq.1@1.48, 2006-12-28 19:21:14-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  packageinfo.sh@1.66, 2006-12-28 19:21:15-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  sntp/sntp-opts.c@1.49, 2006-12-28 19:21:15-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  sntp/sntp-opts.h@1.49, 2006-12-28 19:21:17-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4
+
+  sntp/sntp-opts.texi@1.46, 2006-12-28 19:21:18-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_4
+
+  sntp/sntp.1@1.49, 2006-12-28 19:21:18-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  util/ntp-keygen-opts.c@1.49, 2006-12-28 19:21:19-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  util/ntp-keygen-opts.h@1.49, 2006-12-28 19:21:20-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_4
+
+  util/ntp-keygen-opts.texi@1.47, 2006-12-28 19:21:20-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+  util/ntp-keygen.1@1.47, 2006-12-28 19:21:21-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_4
+
+ChangeSet@1.1436, 2006-12-28 03:09:12-05:00, stenn@whimsy.udel.edu +1 -0
+  typo
+
+  packageinfo.sh@1.65, 2006-12-28 02:47:41-05:00, stenn@whimsy.udel.edu +1 -1
+    typo
+
+ChangeSet@1.1435, 2006-12-27 21:17:55-05:00, stenn@whimsy.udel.edu +1 -0
+  updated backroom machine list
+
+  br-flock@1.11, 2006-12-27 21:17:39-05:00, stenn@whimsy.udel.edu +1 -1
+    updated backroom machine list
+
+ChangeSet@1.1434, 2006-12-27 20:50:07-05:00, stenn@whimsy.udel.edu +2 -0
+  ntp-4.2.4
+
+  NEWS@1.86, 2006-12-27 20:49:18-05:00, stenn@whimsy.udel.edu +3 -2
+    ntp-4.2.4
+
+  packageinfo.sh@1.64, 2006-12-27 20:49:19-05:00, stenn@whimsy.udel.edu +7 -5
+    ntp-4.2.4
+
+ChangeSet@1.1433, 2006-12-27 02:21:39-05:00, stenn@whimsy.udel.edu +2 -0
+  monopt.html fixes from Dave Mills.
+
+  NEWS@1.85, 2006-12-27 02:21:25-05:00, stenn@whimsy.udel.edu +1 -0
+    monopt.html fixes from Dave Mills.
+
+  html/monopt.html@1.23, 2006-12-27 02:21:26-05:00, stenn@whimsy.udel.edu +2 -2
+    monopt.html fixes from Dave Mills.
+
+ChangeSet@1.1432, 2006-12-27 01:57:20-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 452] Do not report kernel PLL/FLL flips.
+
+  NEWS@1.84, 2006-12-27 01:57:03-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 452] Do not report kernel PLL/FLL flips.
+
+  ntpd/ntp_loopfilter.c@1.127, 2006-12-27 01:57:02-05:00, stenn@whimsy.udel.edu +5 -7
+    [Bug 452] Do not report kernel PLL/FLL flips.
+
+ChangeSet@1.1431, 2006-12-27 01:45:38-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 746] Expert mouseCLOCK USB v2.0 support added.
+
+  NEWS@1.83, 2006-12-27 01:45:24-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 746] Expert mouseCLOCK USB v2.0 support added.
+
+ChangeSet@1.1429, 2006-12-27 01:37:16-05:00, stenn@whimsy.udel.edu +1 -0
+  driver8.html updates from Martin Burnicki
+
+  NEWS@1.82, 2006-12-27 01:37:10-05:00, stenn@whimsy.udel.edu +2 -1
+    driver8.html updates from Martin Burnicki
+
+ChangeSet@1.1426.2.1, 2006-12-27 01:22:30-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 747] Drop <NOBR> tags from ntpdc.html
+
+  NEWS@1.81, 2006-12-27 01:20:47-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 747] Drop <NOBR> tags from ntpdc.html
+
+  html/ntpdc.html@1.26, 2006-12-27 01:20:23-05:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 747] Drop <NOBR> tags from ntpdc.html
+
+ChangeSet@1.1426.1.1, 2006-12-22 20:35:42+00:00, kardel@pogo.udel.edu +2 -0
+  driver8.html, refclock_parse.c:
+    Bug 746 (RFE): add configuration for Expert mouseCLOCK USB v2.0 as mode 19
+
+  html/drivers/driver8.html@1.22.1.1, 2006-12-22 20:35:14+00:00, kardel@pogo.udel.edu +5 -1
+    Bug 746 (RFE): add configuration for Expert mouseCLOCK USB v2.0 as mode 19
+
+  ntpd/refclock_parse.c@1.47, 2006-12-22 20:34:30+00:00, kardel@pogo.udel.edu +34 -3
+    Bug 746 (RFE): add configuration for Expert mouseCLOCK USB v2.0 as mode 19
+
+ChangeSet@1.1427, 2006-12-06 12:18:15+00:00, burnicki@pogo.udel.edu +4 -0
+  Updated Meinberg PZF509 to PZF511.
+  Provided higher quality pictures with background color according to the web page.
+  Removed borders around images.
+
+  html/drivers/driver8.html@1.23, 2006-12-06 12:18:12+00:00, burnicki@pogo.udel.edu +5 -5
+    Removed borders around images.
+    Updated Meinberg PZF509 to PZF511.
+
+  html/pic/c51.jpg@1.2, 2006-12-06 12:18:12+00:00, burnicki@pogo.udel.edu +366 -228
+    Provided higher quality picture with background color according to the web page.
+
+  html/pic/gps167.jpg@1.2, 2006-12-06 12:18:13+00:00, burnicki@pogo.udel.edu +347 -270
+    Provided higher quality picture with background color according to the web page.
+
+  html/pic/pzf511.jpg@1.3, 2006-12-06 12:18:13+00:00, burnicki@pogo.udel.edu +453 -290
+    Provided higher quality picture with background color according to the web page.
+
+  html/pic/pzf511.jpg@1.2, 2006-12-06 12:04:23+00:00, burnicki@pogo.udel.edu +0 -0
+    Rename: html/pic/pzf509.jpg -> html/pic/pzf511.jpg
+
+ChangeSet@1.1426, 2006-11-25 06:41:49-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P70_RC
+  TAG: NTP_4_2_3P70_RC
+
+  ntpd/ntpd-opts.c@1.49, 2006-11-25 06:41:29-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  ntpd/ntpd-opts.h@1.49, 2006-11-25 06:41:30-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P70_RC
+
+  ntpd/ntpd-opts.texi@1.48, 2006-11-25 06:41:31-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P70_RC
+
+  ntpd/ntpd.1@1.47, 2006-11-25 06:41:32-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  ntpd/ntpdsim-opts.c@1.49, 2006-11-25 06:41:32-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  ntpd/ntpdsim-opts.h@1.49, 2006-11-25 06:41:33-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P70_RC
+
+  ntpd/ntpdsim-opts.texi@1.47, 2006-11-25 06:41:33-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P70_RC
+
+  ntpd/ntpdsim.1@1.47, 2006-11-25 06:41:34-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  ntpdc/ntpdc-opts.c@1.49, 2006-11-25 06:41:34-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  ntpdc/ntpdc-opts.h@1.49, 2006-11-25 06:41:36-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P70_RC
+
+  ntpdc/ntpdc-opts.texi@1.47, 2006-11-25 06:41:37-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P70_RC
+
+  ntpdc/ntpdc.1@1.47, 2006-11-25 06:41:37-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  ntpq/ntpq-opts.c@1.51, 2006-11-25 06:41:38-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  ntpq/ntpq-opts.h@1.51, 2006-11-25 06:41:38-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P70_RC
+
+  ntpq/ntpq-opts.texi@1.48, 2006-11-25 06:41:39-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P70_RC
+
+  ntpq/ntpq.1@1.47, 2006-11-25 06:41:40-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  packageinfo.sh@1.63, 2006-11-25 06:41:40-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P70_RC
+
+  sntp/sntp-opts.c@1.48, 2006-11-25 06:41:40-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  sntp/sntp-opts.h@1.48, 2006-11-25 06:41:41-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P70_RC
+
+  sntp/sntp-opts.texi@1.45, 2006-11-25 06:41:42-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P70_RC
+
+  sntp/sntp.1@1.48, 2006-11-25 06:41:43-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  util/ntp-keygen-opts.c@1.48, 2006-11-25 06:41:43-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+  util/ntp-keygen-opts.h@1.48, 2006-11-25 06:41:44-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P70_RC
+
+  util/ntp-keygen-opts.texi@1.46, 2006-11-25 06:41:45-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P70_RC
+
+  util/ntp-keygen.1@1.46, 2006-11-25 06:41:45-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P70_RC
+
+ChangeSet@1.1425, 2006-11-25 02:31:59-05:00, stenn@whimsy.udel.edu +2 -0
+  sntp now uses the returned precision to control decimal places
+
+  NEWS@1.80, 2006-11-25 02:31:35-05:00, stenn@whimsy.udel.edu +1 -0
+    sntp now uses the returned precision to control decimal places
+
+  sntp/main.c@1.8, 2006-11-25 02:31:36-05:00, stenn@whimsy.udel.edu +29 -16
+    sntp now uses the returned precision to control decimal places
+
+ChangeSet@1.1424, 2006-11-24 06:42:33-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P69_RC
+  TAG: NTP_4_2_3P69_RC
+
+  ntpd/ntpd-opts.c@1.48, 2006-11-24 06:42:12-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P69_RC
+
+  ntpd/ntpd-opts.h@1.48, 2006-11-24 06:42:13-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P69_RC
+
+  ntpd/ntpd-opts.texi@1.47, 2006-11-24 06:42:14-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P69_RC
+
+  ntpd/ntpd.1@1.46, 2006-11-24 06:42:14-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P69_RC
+
+  ntpd/ntpdsim-opts.c@1.48, 2006-11-24 06:42:15-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P69_RC
+
+  ntpd/ntpdsim-opts.h@1.48, 2006-11-24 06:42:16-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P69_RC
+
+  ntpd/ntpdsim-opts.texi@1.46, 2006-11-24 06:42:17-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P69_RC
+
+  ntpd/ntpdsim.1@1.46, 2006-11-24 06:42:18-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P69_RC
+
+  ntpdc/ntpdc-opts.c@1.48, 2006-11-24 06:42:18-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P69_RC
+
+  ntpdc/ntpdc-opts.h@1.48, 2006-11-24 06:42:19-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P69_RC
+
+  ntpdc/ntpdc-opts.texi@1.46, 2006-11-24 06:42:20-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P69_RC
+
+  ntpdc/ntpdc.1@1.46, 2006-11-24 06:42:20-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P69_RC
+
+  ntpq/ntpq-opts.c@1.50, 2006-11-24 06:42:21-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P69_RC
+
+  ntpq/ntpq-opts.h@1.50, 2006-11-24 06:42:22-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P69_RC
+
+  ntpq/ntpq-opts.texi@1.47, 2006-11-24 06:42:23-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P69_RC
+
+  ntpq/ntpq.1@1.46, 2006-11-24 06:42:23-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P69_RC
+
+  packageinfo.sh@1.62, 2006-11-24 06:42:24-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P69_RC
+
+  sntp/sntp-opts.c@1.47, 2006-11-24 06:42:25-05:00, stenn@whimsy.udel.edu +34 -13
+    NTP_4_2_3P69_RC
+
+  sntp/sntp-opts.h@1.47, 2006-11-24 06:42:26-05:00, stenn@whimsy.udel.edu +21 -14
+    NTP_4_2_3P69_RC
+
+  sntp/sntp-opts.texi@1.44, 2006-11-24 06:42:27-05:00, stenn@whimsy.udel.edu +9 -1
+    NTP_4_2_3P69_RC
+
+  sntp/sntp.1@1.47, 2006-11-24 06:42:27-05:00, stenn@whimsy.udel.edu +8 -64
+    NTP_4_2_3P69_RC
+
+  util/ntp-keygen-opts.c@1.47, 2006-11-24 06:42:28-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P69_RC
+
+  util/ntp-keygen-opts.h@1.47, 2006-11-24 06:42:29-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P69_RC
+
+  util/ntp-keygen-opts.texi@1.45, 2006-11-24 06:42:29-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P69_RC
+
+  util/ntp-keygen.1@1.45, 2006-11-24 06:42:30-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P69_RC
+
+ChangeSet@1.1423, 2006-11-23 21:09:08-05:00, stenn@whimsy.udel.edu +4 -0
+  sntp -u will use an unprivileged port for its queries
+
+  NEWS@1.79, 2006-11-23 21:08:15-05:00, stenn@whimsy.udel.edu +1 -0
+    sntp -u will use an unprivileged port for its queries
+
+  sntp/main.c@1.7, 2006-11-23 21:08:04-05:00, stenn@whimsy.udel.edu +13 -2
+    sntp -u will use an unprivileged port for its queries
+
+  sntp/sntp-opts.def@1.10, 2006-11-23 21:08:04-05:00, stenn@whimsy.udel.edu +10 -62
+    sntp -u will use an unprivileged port for its queries
+
+  sntp/socket.c@1.8, 2006-11-23 21:08:05-05:00, stenn@whimsy.udel.edu +4 -2
+    sntp -u will use an unprivileged port for its queries
+
+ChangeSet@1.1422, 2006-11-22 06:42:29-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P68_RC
+  TAG: NTP_4_2_3P68_RC
+
+  ntpd/ntpd-opts.c@1.47, 2006-11-22 06:42:08-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  ntpd/ntpd-opts.h@1.47, 2006-11-22 06:42:09-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P68_RC
+
+  ntpd/ntpd-opts.texi@1.46, 2006-11-22 06:42:10-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P68_RC
+
+  ntpd/ntpd.1@1.45, 2006-11-22 06:42:10-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  ntpd/ntpdsim-opts.c@1.47, 2006-11-22 06:42:11-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  ntpd/ntpdsim-opts.h@1.47, 2006-11-22 06:42:12-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P68_RC
+
+  ntpd/ntpdsim-opts.texi@1.45, 2006-11-22 06:42:13-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P68_RC
+
+  ntpd/ntpdsim.1@1.45, 2006-11-22 06:42:13-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  ntpdc/ntpdc-opts.c@1.47, 2006-11-22 06:42:14-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  ntpdc/ntpdc-opts.h@1.47, 2006-11-22 06:42:15-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P68_RC
+
+  ntpdc/ntpdc-opts.texi@1.45, 2006-11-22 06:42:16-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  ntpdc/ntpdc.1@1.45, 2006-11-22 06:42:16-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  ntpq/ntpq-opts.c@1.49, 2006-11-22 06:42:17-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  ntpq/ntpq-opts.h@1.49, 2006-11-22 06:42:18-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P68_RC
+
+  ntpq/ntpq-opts.texi@1.46, 2006-11-22 06:42:19-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  ntpq/ntpq.1@1.45, 2006-11-22 06:42:19-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  packageinfo.sh@1.61, 2006-11-22 06:42:20-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P68_RC
+
+  sntp/sntp-opts.c@1.46, 2006-11-22 06:42:20-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  sntp/sntp-opts.h@1.46, 2006-11-22 06:42:21-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P68_RC
+
+  sntp/sntp-opts.texi@1.43, 2006-11-22 06:42:22-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P68_RC
+
+  sntp/sntp.1@1.46, 2006-11-22 06:42:23-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  util/ntp-keygen-opts.c@1.46, 2006-11-22 06:42:23-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  util/ntp-keygen-opts.h@1.46, 2006-11-22 06:42:24-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P68_RC
+
+  util/ntp-keygen-opts.texi@1.44, 2006-11-22 06:42:25-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+  util/ntp-keygen.1@1.44, 2006-11-22 06:42:26-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P68_RC
+
+ChangeSet@1.1421, 2006-11-22 02:15:14-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 741] 'burst' doesn't work with  peers
+
+  NEWS@1.78, 2006-11-22 02:14:47-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 741] 'burst' doesn't work with !unfit peers
+
+  ntpd/ntp_proto.c@1.249, 2006-11-22 02:14:48-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 741] 'burst' doesn't work with !unfit peers
+
+ChangeSet@1.1420, 2006-11-21 23:53:23-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 735] Fix a make/gmake VPATH issue on Solaris
+
+  Makefile.am@1.70, 2006-11-21 23:53:04-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 735] Fix a make/gmake VPATH issue on Solaris
+
+  NEWS@1.77, 2006-11-21 23:53:03-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 735] Fix a make/gmake VPATH issue on Solaris
+
+ChangeSet@1.1419, 2006-11-21 06:42:26-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P67_RC
+  TAG: NTP_4_2_3P67_RC
+
+  ntpd/ntpd-opts.c@1.46, 2006-11-21 06:42:02-05:00, stenn@whimsy.udel.edu +3 -4
+    NTP_4_2_3P67_RC
+
+  ntpd/ntpd-opts.h@1.46, 2006-11-21 06:42:02-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P67_RC
+
+  ntpd/ntpd-opts.texi@1.45, 2006-11-21 06:42:03-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P67_RC
+
+  ntpd/ntpd.1@1.44, 2006-11-21 06:42:04-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P67_RC
+
+  ntpd/ntpdsim-opts.c@1.46, 2006-11-21 06:42:04-05:00, stenn@whimsy.udel.edu +3 -4
+    NTP_4_2_3P67_RC
+
+  ntpd/ntpdsim-opts.h@1.46, 2006-11-21 06:42:05-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P67_RC
+
+  ntpd/ntpdsim-opts.texi@1.44, 2006-11-21 06:42:06-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P67_RC
+
+  ntpd/ntpdsim.1@1.44, 2006-11-21 06:42:06-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P67_RC
+
+  ntpdc/ntpdc-opts.c@1.46, 2006-11-21 06:42:07-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P67_RC
+
+  ntpdc/ntpdc-opts.h@1.46, 2006-11-21 06:42:08-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P67_RC
+
+  ntpdc/ntpdc-opts.texi@1.44, 2006-11-21 06:42:09-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P67_RC
+
+  ntpdc/ntpdc.1@1.44, 2006-11-21 06:42:10-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P67_RC
+
+  ntpq/ntpq-opts.c@1.48, 2006-11-21 06:42:11-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P67_RC
+
+  ntpq/ntpq-opts.h@1.48, 2006-11-21 06:42:11-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P67_RC
+
+  ntpq/ntpq-opts.texi@1.45, 2006-11-21 06:42:12-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P67_RC
+
+  ntpq/ntpq.1@1.44, 2006-11-21 06:42:13-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P67_RC
+
+  packageinfo.sh@1.60, 2006-11-21 06:42:13-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P67_RC
+
+  sntp/sntp-opts.c@1.45, 2006-11-21 06:42:14-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P67_RC
+
+  sntp/sntp-opts.h@1.45, 2006-11-21 06:42:15-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P67_RC
+
+  sntp/sntp-opts.texi@1.42, 2006-11-21 06:42:15-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P67_RC
+
+  sntp/sntp.1@1.45, 2006-11-21 06:42:16-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P67_RC
+
+  util/ntp-keygen-opts.c@1.45, 2006-11-21 06:42:17-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P67_RC
+
+  util/ntp-keygen-opts.h@1.45, 2006-11-21 06:42:18-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P67_RC
+
+  util/ntp-keygen-opts.texi@1.43, 2006-11-21 06:42:18-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P67_RC
+
+  util/ntp-keygen.1@1.43, 2006-11-21 06:42:19-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P67_RC
+
+ChangeSet@1.1418, 2006-11-21 09:35:31+00:00, burnicki@pogo.udel.edu +1 -0
+  Fixed an uppercase typo.
+
+  html/drivers/driver8.html@1.22, 2006-11-21 09:35:24+00:00, burnicki@pogo.udel.edu +1 -1
+    Fixed an uppercase typo.
+
+ChangeSet@1.1417, 2006-11-21 02:43:36-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 717] Make sure sntp/*version.def is up-to-date
+
+  bootstrap@1.18, 2006-11-21 02:43:17-05:00, stenn@whimsy.udel.edu +5 -0
+    [Bug 717] Make sure sntp/*version.def is up-to-date
+
+ChangeSet@1.1416, 2006-11-20 23:05:54-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 739] ntpd -x should not take an argument
+
+  NEWS@1.76, 2006-11-20 23:04:55-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 739] ntpd -x should not take an argument
+
+  ntpd/ntpdbase-opts.def@1.10, 2006-11-20 23:04:27-05:00, stenn@whimsy.udel.edu +0 -1
+    [Bug 739] ntpd -x should not take an argument
+
+ChangeSet@1.1415, 2006-11-19 06:45:35-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P66_RC
+  TAG: NTP_4_2_3P66_RC
+
+  ntpd/ntpd-opts.c@1.45, 2006-11-19 06:45:13-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  ntpd/ntpd-opts.h@1.45, 2006-11-19 06:45:14-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P66_RC
+
+  ntpd/ntpd-opts.texi@1.44, 2006-11-19 06:45:14-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  ntpd/ntpd.1@1.43, 2006-11-19 06:45:15-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  ntpd/ntpdsim-opts.c@1.45, 2006-11-19 06:45:16-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  ntpd/ntpdsim-opts.h@1.45, 2006-11-19 06:45:17-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P66_RC
+
+  ntpd/ntpdsim-opts.texi@1.43, 2006-11-19 06:45:17-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P66_RC
+
+  ntpd/ntpdsim.1@1.43, 2006-11-19 06:45:18-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  ntpdc/ntpdc-opts.c@1.45, 2006-11-19 06:45:19-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  ntpdc/ntpdc-opts.h@1.45, 2006-11-19 06:45:19-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P66_RC
+
+  ntpdc/ntpdc-opts.texi@1.43, 2006-11-19 06:45:20-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  ntpdc/ntpdc.1@1.43, 2006-11-19 06:45:21-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  ntpq/ntpq-opts.c@1.47, 2006-11-19 06:45:22-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  ntpq/ntpq-opts.h@1.47, 2006-11-19 06:45:23-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P66_RC
+
+  ntpq/ntpq-opts.texi@1.44, 2006-11-19 06:45:24-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  ntpq/ntpq.1@1.43, 2006-11-19 06:45:24-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  packageinfo.sh@1.59, 2006-11-19 06:45:25-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P66_RC
+
+  sntp/sntp-opts.c@1.44, 2006-11-19 06:45:26-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  sntp/sntp-opts.h@1.44, 2006-11-19 06:45:27-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P66_RC
+
+  sntp/sntp-opts.texi@1.41, 2006-11-19 06:45:27-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P66_RC
+
+  sntp/sntp.1@1.44, 2006-11-19 06:45:28-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  util/ntp-keygen-opts.c@1.44, 2006-11-19 06:45:29-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  util/ntp-keygen-opts.h@1.44, 2006-11-19 06:45:30-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P66_RC
+
+  util/ntp-keygen-opts.texi@1.42, 2006-11-19 06:45:31-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+  util/ntp-keygen.1@1.42, 2006-11-19 06:45:31-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P66_RC
+
+ChangeSet@1.1412.1.1, 2006-11-18 21:12:41-08:00, harlan@minnie.everett.org +3 -0
+  * [Bug 737] Some systems need help providing struct iovec.
+
+  NEWS@1.75, 2006-11-18 21:12:35-08:00, harlan@minnie.everett.org +1 -0
+    * [Bug 737] Some systems need help providing struct iovec.
+
+  configure.ac@1.400, 2006-11-18 21:12:35-08:00, harlan@minnie.everett.org +44 -0
+    * [Bug 737] Some systems need help providing struct iovec.
+
+  ntpd/ntp_io.c@1.244, 2006-11-18 21:12:35-08:00, harlan@minnie.everett.org +3 -0
+    * [Bug 737] Some systems need help providing struct iovec.
+
+ChangeSet@1.1413, 2006-11-17 08:59:50+00:00, burnicki@pogo.udel.edu +1 -0
+  [Bug #728] More changes by Paul and Martin.
+
+  html/drivers/driver8.html@1.21, 2006-11-17 08:59:48+00:00, burnicki@pogo.udel.edu +93 -44
+    More changes by Paul and Martin.
+
+ChangeSet@1.1412, 2006-11-10 06:41:45-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P65_RC
+  TAG: NTP_4_2_3P65_RC
+
+  ntpd/ntpd-opts.c@1.44, 2006-11-10 06:41:23-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  ntpd/ntpd-opts.h@1.44, 2006-11-10 06:41:24-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P65_RC
+
+  ntpd/ntpd-opts.texi@1.43, 2006-11-10 06:41:24-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P65_RC
+
+  ntpd/ntpd.1@1.42, 2006-11-10 06:41:25-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  ntpd/ntpdsim-opts.c@1.44, 2006-11-10 06:41:26-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  ntpd/ntpdsim-opts.h@1.44, 2006-11-10 06:41:27-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P65_RC
+
+  ntpd/ntpdsim-opts.texi@1.42, 2006-11-10 06:41:28-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P65_RC
+
+  ntpd/ntpdsim.1@1.42, 2006-11-10 06:41:28-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  ntpdc/ntpdc-opts.c@1.44, 2006-11-10 06:41:29-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  ntpdc/ntpdc-opts.h@1.44, 2006-11-10 06:41:30-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P65_RC
+
+  ntpdc/ntpdc-opts.texi@1.42, 2006-11-10 06:41:32-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P65_RC
+
+  ntpdc/ntpdc.1@1.42, 2006-11-10 06:41:32-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  ntpq/ntpq-opts.c@1.46, 2006-11-10 06:41:33-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  ntpq/ntpq-opts.h@1.46, 2006-11-10 06:41:33-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P65_RC
+
+  ntpq/ntpq-opts.texi@1.43, 2006-11-10 06:41:34-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P65_RC
+
+  ntpq/ntpq.1@1.42, 2006-11-10 06:41:35-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  packageinfo.sh@1.58, 2006-11-10 06:41:35-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P65_RC
+
+  sntp/sntp-opts.c@1.43, 2006-11-10 06:41:36-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  sntp/sntp-opts.h@1.43, 2006-11-10 06:41:37-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P65_RC
+
+  sntp/sntp-opts.texi@1.40, 2006-11-10 06:41:37-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P65_RC
+
+  sntp/sntp.1@1.43, 2006-11-10 06:41:38-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  util/ntp-keygen-opts.c@1.43, 2006-11-10 06:41:39-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+  util/ntp-keygen-opts.h@1.43, 2006-11-10 06:41:39-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P65_RC
+
+  util/ntp-keygen-opts.texi@1.41, 2006-11-10 06:41:40-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P65_RC
+
+  util/ntp-keygen.1@1.41, 2006-11-10 06:41:41-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P65_RC
+
+ChangeSet@1.1411, 2006-11-10 00:24:06-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 717] Fix libopts compile problem for some windows versions
+
+  NEWS@1.74, 2006-11-10 00:23:54-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 717] Fix libopts compile problem for some windows versions
+
+ChangeSet@1.1398.1.1, 2006-11-09 22:57:09-05:00, mayer@pogo.udel.edu +1 -0
+  Bug #717 Add uintptr_t typedef for VS 6.0
+
+  ports/winnt/include/config.h@1.46, 2006-11-09 22:56:27-05:00, mayer@pogo.udel.edu +7 -0
+    Bug #717 Add uintptr_t typedef for VS 6.0
+
+ChangeSet@1.1409, 2006-11-09 06:42:28-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P64_RC
+  TAG: NTP_4_2_3P64_RC
+
+  ntpd/ntpd-opts.c@1.43, 2006-11-09 06:42:07-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  ntpd/ntpd-opts.h@1.43, 2006-11-09 06:42:07-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P64_RC
+
+  ntpd/ntpd-opts.texi@1.42, 2006-11-09 06:42:08-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P64_RC
+
+  ntpd/ntpd.1@1.41, 2006-11-09 06:42:08-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  ntpd/ntpdsim-opts.c@1.43, 2006-11-09 06:42:09-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  ntpd/ntpdsim-opts.h@1.43, 2006-11-09 06:42:10-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P64_RC
+
+  ntpd/ntpdsim-opts.texi@1.41, 2006-11-09 06:42:10-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P64_RC
+
+  ntpd/ntpdsim.1@1.41, 2006-11-09 06:42:11-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  ntpdc/ntpdc-opts.c@1.43, 2006-11-09 06:42:12-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  ntpdc/ntpdc-opts.h@1.43, 2006-11-09 06:42:13-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P64_RC
+
+  ntpdc/ntpdc-opts.texi@1.41, 2006-11-09 06:42:14-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P64_RC
+
+  ntpdc/ntpdc.1@1.41, 2006-11-09 06:42:14-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  ntpq/ntpq-opts.c@1.45, 2006-11-09 06:42:15-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  ntpq/ntpq-opts.h@1.45, 2006-11-09 06:42:16-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P64_RC
+
+  ntpq/ntpq-opts.texi@1.42, 2006-11-09 06:42:16-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P64_RC
+
+  ntpq/ntpq.1@1.41, 2006-11-09 06:42:17-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  packageinfo.sh@1.57, 2006-11-09 06:42:18-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P64_RC
+
+  sntp/sntp-opts.c@1.42, 2006-11-09 06:42:19-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  sntp/sntp-opts.h@1.42, 2006-11-09 06:42:19-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P64_RC
+
+  sntp/sntp-opts.texi@1.39, 2006-11-09 06:42:20-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P64_RC
+
+  sntp/sntp.1@1.42, 2006-11-09 06:42:21-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  util/ntp-keygen-opts.c@1.42, 2006-11-09 06:42:21-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+  util/ntp-keygen-opts.h@1.42, 2006-11-09 06:42:22-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P64_RC
+
+  util/ntp-keygen-opts.texi@1.40, 2006-11-09 06:42:23-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P64_RC
+
+  util/ntp-keygen.1@1.40, 2006-11-09 06:42:23-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P64_RC
+
+ChangeSet@1.1408, 2006-11-09 04:29:07-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 728] parse documentation fixes
+
+  NEWS@1.73, 2006-11-09 04:28:53-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 728] parse documentation fixes
+
+ChangeSet@1.1407, 2006-11-08 18:11:25+00:00, burnicki@pogo.udel.edu +2 -0
+  [Bug #728] Typo fixes submitted by Paul Croome plus additional updates and fixes for driver8.html and parsedata.html.
+
+  html/drivers/driver8.html@1.20, 2006-11-08 18:11:23+00:00, burnicki@pogo.udel.edu +127 -136
+    Typo fixes submitted by Paul Croome.
+    Updated docs and links.
+
+  html/parsedata.html@1.12, 2006-11-08 18:11:23+00:00, burnicki@pogo.udel.edu +92 -80
+    Updated docs and fixed some errors.
+
+ChangeSet@1.1406, 2006-11-06 06:47:05-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P63_RC
+  TAG: NTP_4_2_3P63_RC
+
+  ntpd/ntpd-opts.c@1.42, 2006-11-06 06:46:45-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  ntpd/ntpd-opts.h@1.42, 2006-11-06 06:46:46-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P63_RC
+
+  ntpd/ntpd-opts.texi@1.41, 2006-11-06 06:46:46-05:00, stenn@whimsy.udel.edu +2 -4
+    NTP_4_2_3P63_RC
+
+  ntpd/ntpd.1@1.40, 2006-11-06 06:46:47-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  ntpd/ntpdsim-opts.c@1.42, 2006-11-06 06:46:48-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  ntpd/ntpdsim-opts.h@1.42, 2006-11-06 06:46:48-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P63_RC
+
+  ntpd/ntpdsim-opts.texi@1.40, 2006-11-06 06:46:49-05:00, stenn@whimsy.udel.edu +2 -73
+    NTP_4_2_3P63_RC
+
+  ntpd/ntpdsim.1@1.40, 2006-11-06 06:46:50-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  ntpdc/ntpdc-opts.c@1.42, 2006-11-06 06:46:51-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  ntpdc/ntpdc-opts.h@1.42, 2006-11-06 06:46:51-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P63_RC
+
+  ntpdc/ntpdc-opts.texi@1.40, 2006-11-06 06:46:52-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  ntpdc/ntpdc.1@1.40, 2006-11-06 06:46:53-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  ntpq/ntpq-opts.c@1.44, 2006-11-06 06:46:54-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  ntpq/ntpq-opts.h@1.44, 2006-11-06 06:46:54-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P63_RC
+
+  ntpq/ntpq-opts.texi@1.41, 2006-11-06 06:46:55-05:00, stenn@whimsy.udel.edu +4 -244
+    NTP_4_2_3P63_RC
+
+  ntpq/ntpq.1@1.40, 2006-11-06 06:46:56-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  packageinfo.sh@1.56, 2006-11-06 06:46:57-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P63_RC
+
+  sntp/sntp-opts.c@1.41, 2006-11-06 06:46:57-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  sntp/sntp-opts.h@1.41, 2006-11-06 06:46:58-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P63_RC
+
+  sntp/sntp-opts.texi@1.38, 2006-11-06 06:46:59-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P63_RC
+
+  sntp/sntp.1@1.41, 2006-11-06 06:46:59-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  util/ntp-keygen-opts.c@1.41, 2006-11-06 06:47:00-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  util/ntp-keygen-opts.h@1.41, 2006-11-06 06:47:01-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P63_RC
+
+  util/ntp-keygen-opts.texi@1.39, 2006-11-06 06:47:01-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+  util/ntp-keygen.1@1.39, 2006-11-06 06:47:02-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P63_RC
+
+ChangeSet@1.1405, 2006-11-06 03:11:36-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 734] setsockopt(..., IP_MULTICAST_IF, ...) fails on 64-bit platforms.
+
+  NEWS@1.72, 2006-11-06 03:11:21-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 734] setsockopt(..., IP_MULTICAST_IF, ...) fails on 64-bit platforms.
+
+ChangeSet@1.1404, 2006-11-06 03:06:37-05:00, stenn@whimsy.udel.edu +2 -0
+  Build our libopts by default (static, and without installing it
+
+  configure.ac@1.399, 2006-11-06 03:06:25-05:00, stenn@whimsy.udel.edu +17 -0
+    Build our libopts by default (static, and without installing it
+
+  sntp/configure.ac@1.15, 2006-11-06 03:06:27-05:00, stenn@whimsy.udel.edu +18 -0
+    Build our libopts by default (static, and without installing it
+
+ChangeSet@1.1400.1.1, 2006-11-06 02:51:53-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 732] C-DEX JST2000 patch from Hideo Kuramatsu
+
+  NEWS@1.71, 2006-11-06 02:51:43-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 732] C-DEX JST2000 patch from Hideo Kuramatsu
+
+  ntpd/refclock_jjy.c@1.13, 2006-11-06 02:51:17-05:00, stenn@whimsy.udel.edu +5 -0
+    [Bug 732] C-DEX JST2000 patch from Hideo Kuramatsu
+
+ChangeSet@1.1402, 2006-11-05 08:28:53+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    pass correct address length for setsockopt(..., IP_MULTICAST_IF, ...)
+    (sizeof(struct sockaddr_in*) != sizeof(struct in_addr) on 64-bit platforms)
+
+  ntpd/ntp_io.c@1.243, 2006-11-05 08:25:03+00:00, kardel@pogo.udel.edu +1 -1
+    pass correct address length for setsockopt(..., IP_MULTICAST_IF, ...)
+    (sizeof(struct sockaddr_in*) != sizeof(struct in_addr) on 64 bite platforms)
+
+ChangeSet@1.1400, 2006-11-01 06:45:21-05:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P62_RC
+  TAG: NTP_4_2_3P62_RC
+
+  ntpd/ntpd-opts.c@1.41, 2006-11-01 06:45:00-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  ntpd/ntpd-opts.h@1.41, 2006-11-01 06:45:01-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P62_RC
+
+  ntpd/ntpd-opts.texi@1.40, 2006-11-01 06:45:02-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P62_RC
+
+  ntpd/ntpd.1@1.39, 2006-11-01 06:45:02-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  ntpd/ntpdsim-opts.c@1.41, 2006-11-01 06:45:03-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  ntpd/ntpdsim-opts.h@1.41, 2006-11-01 06:45:04-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P62_RC
+
+  ntpd/ntpdsim-opts.texi@1.39, 2006-11-01 06:45:05-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P62_RC
+
+  ntpd/ntpdsim.1@1.39, 2006-11-01 06:45:05-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  ntpdc/ntpdc-opts.c@1.41, 2006-11-01 06:45:06-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  ntpdc/ntpdc-opts.h@1.41, 2006-11-01 06:45:07-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P62_RC
+
+  ntpdc/ntpdc-opts.texi@1.39, 2006-11-01 06:45:07-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P62_RC
+
+  ntpdc/ntpdc.1@1.39, 2006-11-01 06:45:08-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  ntpq/ntpq-opts.c@1.43, 2006-11-01 06:45:08-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  ntpq/ntpq-opts.h@1.43, 2006-11-01 06:45:10-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P62_RC
+
+  ntpq/ntpq-opts.texi@1.40, 2006-11-01 06:45:10-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P62_RC
+
+  ntpq/ntpq.1@1.39, 2006-11-01 06:45:11-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  packageinfo.sh@1.55, 2006-11-01 06:45:12-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P62_RC
+
+  sntp/sntp-opts.c@1.40, 2006-11-01 06:45:13-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  sntp/sntp-opts.h@1.40, 2006-11-01 06:45:13-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P62_RC
+
+  sntp/sntp-opts.texi@1.37, 2006-11-01 06:45:14-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P62_RC
+
+  sntp/sntp.1@1.40, 2006-11-01 06:45:14-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  util/ntp-keygen-opts.c@1.40, 2006-11-01 06:45:16-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+  util/ntp-keygen-opts.h@1.40, 2006-11-01 06:45:16-05:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P62_RC
+
+  util/ntp-keygen-opts.texi@1.38, 2006-11-01 06:45:17-05:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P62_RC
+
+  util/ntp-keygen.1@1.38, 2006-11-01 06:45:17-05:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P62_RC
+
+ChangeSet@1.1399, 2006-10-31 23:58:45-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 721] check for __ss_family and __ss_len separately
+
+  NEWS@1.70, 2006-10-31 23:58:29-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 721] check for __ss_family and __ss_len separately
+
+  configure.ac@1.398, 2006-10-31 23:57:41-05:00, stenn@whimsy.udel.edu +41 -2
+    [Bug 721] check for __ss_family and __ss_len separately
+
+ChangeSet@1.1379.13.1, 2006-10-30 07:24:38-05:00, mayer@pogo.udel.edu +1 -0
+  Bug #695 Fix to turn off Option warnings for VS 2005
+
+  ports/winnt/include/config.h@1.45, 2006-10-30 07:24:03-05:00, mayer@pogo.udel.edu +1 -0
+    Bug #695 Fix to turn off Option warnings for VS 2005
+
+ChangeSet@1.1397, 2006-10-23 07:48:24-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P61_RC
+  TAG: NTP_4_2_3P61_RC
+
+  ntpd/ntpd-opts.c@1.40, 2006-10-23 07:48:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  ntpd/ntpd-opts.h@1.40, 2006-10-23 07:48:05-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P61_RC
+
+  ntpd/ntpd-opts.texi@1.39, 2006-10-23 07:48:05-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P61_RC
+
+  ntpd/ntpd.1@1.38, 2006-10-23 07:48:06-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  ntpd/ntpdsim-opts.c@1.40, 2006-10-23 07:48:06-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  ntpd/ntpdsim-opts.h@1.40, 2006-10-23 07:48:07-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P61_RC
+
+  ntpd/ntpdsim-opts.texi@1.38, 2006-10-23 07:48:08-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P61_RC
+
+  ntpd/ntpdsim.1@1.38, 2006-10-23 07:48:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  ntpdc/ntpdc-opts.c@1.40, 2006-10-23 07:48:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  ntpdc/ntpdc-opts.h@1.40, 2006-10-23 07:48:10-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P61_RC
+
+  ntpdc/ntpdc-opts.texi@1.38, 2006-10-23 07:48:11-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P61_RC
+
+  ntpdc/ntpdc.1@1.38, 2006-10-23 07:48:12-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  ntpq/ntpq-opts.c@1.42, 2006-10-23 07:48:12-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  ntpq/ntpq-opts.h@1.42, 2006-10-23 07:48:13-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P61_RC
+
+  ntpq/ntpq-opts.texi@1.39, 2006-10-23 07:48:14-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P61_RC
+
+  ntpq/ntpq.1@1.38, 2006-10-23 07:48:14-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  packageinfo.sh@1.54, 2006-10-23 07:48:15-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P61_RC
+
+  sntp/sntp-opts.c@1.39, 2006-10-23 07:48:15-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  sntp/sntp-opts.h@1.39, 2006-10-23 07:48:16-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P61_RC
+
+  sntp/sntp-opts.texi@1.36, 2006-10-23 07:48:17-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P61_RC
+
+  sntp/sntp.1@1.39, 2006-10-23 07:48:18-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  util/ntp-keygen-opts.c@1.39, 2006-10-23 07:48:18-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+  util/ntp-keygen-opts.h@1.39, 2006-10-23 07:48:19-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P61_RC
+
+  util/ntp-keygen-opts.texi@1.37, 2006-10-23 07:48:20-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P61_RC
+
+  util/ntp-keygen.1@1.37, 2006-10-23 07:48:21-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P61_RC
+
+ChangeSet@1.1395, 2006-10-23 00:38:50-04:00, stenn@pogo.udel.edu +2 -0
+  [Bug 666] ntpq opeers displays jitter rather than dispersion
+
+  NEWS@1.69, 2006-10-23 00:38:42-04:00, stenn@pogo.udel.edu +1 -0
+    [Bug 666] ntpq opeers displays jitter rather than dispersion
+
+  ntpq/ntpq-subs.c@1.25, 2006-10-23 00:37:58-04:00, stenn@pogo.udel.edu +3 -2
+    [Bug 666] ntpq opeers displays jitter rather than dispersion
+
+ChangeSet@1.1379.12.3, 2006-10-20 07:45:30-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P60_RC
+  TAG: NTP_4_2_3P60_RC
+
+  ntpd/ntpd-opts.c@1.39, 2006-10-20 07:45:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  ntpd/ntpd-opts.h@1.39, 2006-10-20 07:45:09-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P60_RC
+
+  ntpd/ntpd-opts.texi@1.38, 2006-10-20 07:45:10-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P60_RC
+
+  ntpd/ntpd.1@1.37, 2006-10-20 07:45:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  ntpd/ntpdsim-opts.c@1.39, 2006-10-20 07:45:12-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  ntpd/ntpdsim-opts.h@1.39, 2006-10-20 07:45:13-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P60_RC
+
+  ntpd/ntpdsim-opts.texi@1.37, 2006-10-20 07:45:13-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P60_RC
+
+  ntpd/ntpdsim.1@1.37, 2006-10-20 07:45:14-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  ntpdc/ntpdc-opts.c@1.39, 2006-10-20 07:45:15-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  ntpdc/ntpdc-opts.h@1.39, 2006-10-20 07:45:15-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P60_RC
+
+  ntpdc/ntpdc-opts.texi@1.37, 2006-10-20 07:45:16-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P60_RC
+
+  ntpdc/ntpdc.1@1.37, 2006-10-20 07:45:17-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  ntpq/ntpq-opts.c@1.41, 2006-10-20 07:45:17-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  ntpq/ntpq-opts.h@1.41, 2006-10-20 07:45:18-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P60_RC
+
+  ntpq/ntpq-opts.texi@1.38, 2006-10-20 07:45:19-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P60_RC
+
+  ntpq/ntpq.1@1.37, 2006-10-20 07:45:19-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  packageinfo.sh@1.53, 2006-10-20 07:45:20-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P60_RC
+
+  sntp/sntp-opts.c@1.38, 2006-10-20 07:45:20-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  sntp/sntp-opts.h@1.38, 2006-10-20 07:45:22-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P60_RC
+
+  sntp/sntp-opts.texi@1.35, 2006-10-20 07:45:23-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P60_RC
+
+  sntp/sntp.1@1.38, 2006-10-20 07:45:23-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  util/ntp-keygen-opts.c@1.38, 2006-10-20 07:45:24-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+  util/ntp-keygen-opts.h@1.38, 2006-10-20 07:45:25-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P60_RC
+
+  util/ntp-keygen-opts.texi@1.36, 2006-10-20 07:45:26-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P60_RC
+
+  util/ntp-keygen.1@1.36, 2006-10-20 07:45:27-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P60_RC
+
+ChangeSet@1.1379.12.2, 2006-10-20 00:49:41-04:00, stenn@whimsy.udel.edu +1 -0
+  4.2.4 Release Candidate
+
+  packageinfo.sh@1.52, 2006-10-20 00:49:29-04:00, stenn@whimsy.udel.edu +2 -2
+    4.2.4 Release Candidate
+
+ChangeSet@1.1379.12.1, 2006-10-20 00:44:54-04:00, stenn@whimsy.udel.edu +1 -0
+  refclock_wwv.c fix from Dave Mills
+
+  ntpd/refclock_wwv.c@1.66, 2006-10-20 00:44:30-04:00, stenn@whimsy.udel.edu +3 -0
+    refclock_wwv.c fix from Dave Mills
+
+ChangeSet@1.1379.1.53, 2006-10-15 14:25:15+00:00, kardel@pogo.udel.edu +1 -0
+  dcfd.c:
+    cope with cases where sa_sigaction and sa_handler are in a union
+
+  parseutil/dcfd.c@1.19, 2006-10-15 14:24:55+00:00, kardel@pogo.udel.edu +1 -1
+    cope with cases where sa_sigaction and sa_handler are in a union
+
+ChangeSet@1.1379.1.52, 2006-10-15 07:42:15-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P59
+  TAG: NTP_4_2_3P59
+
+  ntpd/ntpd-opts.c@1.38, 2006-10-15 07:41:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  ntpd/ntpd-opts.h@1.38, 2006-10-15 07:41:54-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P59
+
+  ntpd/ntpd-opts.texi@1.37, 2006-10-15 07:41:55-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P59
+
+  ntpd/ntpd.1@1.36, 2006-10-15 07:41:55-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  ntpd/ntpdsim-opts.c@1.38, 2006-10-15 07:41:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  ntpd/ntpdsim-opts.h@1.38, 2006-10-15 07:41:57-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P59
+
+  ntpd/ntpdsim-opts.texi@1.36, 2006-10-15 07:41:57-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P59
+
+  ntpd/ntpdsim.1@1.36, 2006-10-15 07:41:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  ntpdc/ntpdc-opts.c@1.38, 2006-10-15 07:41:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  ntpdc/ntpdc-opts.h@1.38, 2006-10-15 07:41:59-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P59
+
+  ntpdc/ntpdc-opts.texi@1.36, 2006-10-15 07:42:00-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P59
+
+  ntpdc/ntpdc.1@1.36, 2006-10-15 07:42:01-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  ntpq/ntpq-opts.c@1.40, 2006-10-15 07:42:01-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  ntpq/ntpq-opts.h@1.40, 2006-10-15 07:42:03-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P59
+
+  ntpq/ntpq-opts.texi@1.37, 2006-10-15 07:42:04-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P59
+
+  ntpq/ntpq.1@1.36, 2006-10-15 07:42:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  packageinfo.sh@1.51, 2006-10-15 07:42:05-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P59
+
+  sntp/sntp-opts.c@1.37, 2006-10-15 07:42:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  sntp/sntp-opts.h@1.37, 2006-10-15 07:42:06-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P59
+
+  sntp/sntp-opts.texi@1.34, 2006-10-15 07:42:07-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P59
+
+  sntp/sntp.1@1.37, 2006-10-15 07:42:08-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  util/ntp-keygen-opts.c@1.37, 2006-10-15 07:42:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+  util/ntp-keygen-opts.h@1.37, 2006-10-15 07:42:10-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P59
+
+  util/ntp-keygen-opts.texi@1.35, 2006-10-15 07:42:11-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P59
+
+  util/ntp-keygen.1@1.35, 2006-10-15 07:42:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P59
+
+ChangeSet@1.1251.94.61, 2006-10-15 03:47:49-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P4
+  TAG: NTP_4_2_2P4
+
+  packageinfo.sh@1.27.20.2, 2006-10-15 03:47:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_2P4
+
+ChangeSet@1.1251.94.60, 2006-10-15 03:14:15-04:00, stenn@whimsy.udel.edu +1 -0
+  Release 4.2.2p4
+
+  packageinfo.sh@1.27.20.1, 2006-10-15 03:14:05-04:00, stenn@whimsy.udel.edu +1 -1
+    Release 4.2.2p4
+
+ChangeSet@1.1379.1.51, 2006-10-15 06:03:07+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    Bug 715:
+    Fix from Peter Pramberger
+    do not send link scoped multicasts with a glocbal source address
+    (if present on that interface)
+
+  ntpd/ntp_io.c@1.234.1.16, 2006-10-15 06:00:32+00:00, kardel@pogo.udel.edu +9 -2
+    Bug 715:
+    Fix from Peter Pramberger
+    do not send link scoped multicasts with a glocbal source address
+    (if present on that interface)
+
+ChangeSet@1.1379.1.50, 2006-10-14 07:41:41-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P58
+  TAG: NTP_4_2_3P58
+
+  ntpd/ntpd-opts.c@1.37, 2006-10-14 07:41:22-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  ntpd/ntpd-opts.h@1.37, 2006-10-14 07:41:23-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P58
+
+  ntpd/ntpd-opts.texi@1.36, 2006-10-14 07:41:23-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P58
+
+  ntpd/ntpd.1@1.35, 2006-10-14 07:41:24-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  ntpd/ntpdsim-opts.c@1.37, 2006-10-14 07:41:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  ntpd/ntpdsim-opts.h@1.37, 2006-10-14 07:41:25-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P58
+
+  ntpd/ntpdsim-opts.texi@1.35, 2006-10-14 07:41:26-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P58
+
+  ntpd/ntpdsim.1@1.35, 2006-10-14 07:41:26-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  ntpdc/ntpdc-opts.c@1.37, 2006-10-14 07:41:27-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  ntpdc/ntpdc-opts.h@1.37, 2006-10-14 07:41:27-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P58
+
+  ntpdc/ntpdc-opts.texi@1.35, 2006-10-14 07:41:28-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P58
+
+  ntpdc/ntpdc.1@1.35, 2006-10-14 07:41:29-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  ntpq/ntpq-opts.c@1.39, 2006-10-14 07:41:29-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  ntpq/ntpq-opts.h@1.39, 2006-10-14 07:41:30-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P58
+
+  ntpq/ntpq-opts.texi@1.36, 2006-10-14 07:41:31-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P58
+
+  ntpq/ntpq.1@1.35, 2006-10-14 07:41:32-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  packageinfo.sh@1.50, 2006-10-14 07:41:32-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P58
+
+  sntp/sntp-opts.c@1.36, 2006-10-14 07:41:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  sntp/sntp-opts.h@1.36, 2006-10-14 07:41:34-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P58
+
+  sntp/sntp-opts.texi@1.33, 2006-10-14 07:41:34-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P58
+
+  sntp/sntp.1@1.36, 2006-10-14 07:41:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  util/ntp-keygen-opts.c@1.36, 2006-10-14 07:41:36-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+  util/ntp-keygen-opts.h@1.36, 2006-10-14 07:41:36-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P58
+
+  util/ntp-keygen-opts.texi@1.34, 2006-10-14 07:41:37-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P58
+
+  util/ntp-keygen.1@1.34, 2006-10-14 07:41:38-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P58
+
+ChangeSet@1.1379.1.49, 2006-10-14 08:51:43+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    Bug #715 (& dupe 723):
+    findlocalinterface() in update_interface can be replaced by
+    a simple address to interface lookup. This avoids tripping
+    over the Linux strategy to return the localhost address
+    when attempting to send to an IPv6 address of a local interface.
+    Additionally:
+      synchronize debug output with reality
+      avoid adding duplicate address entries to the address list
+      declare more functions static to reduce name space pollution
+
+  ntpd/ntp_io.c@1.234.1.15, 2006-10-14 08:30:08+00:00, kardel@pogo.udel.edu +107 -81
+    Bug #715 (& dupe 723):
+    findlocalinterface() in update_interface can be replaced by
+    a simple address to interface lookup. This avoids tripping
+    over the Linux strategy to return the localhost address
+    when attempting to send to an IPv6 address of a local interface.
+    Additionally:
+      synchronize debug output with reality
+      avoid adding duplicate address entries to the address list
+      declare more functions static to reduce name space pollution
+
+ChangeSet@1.1379.1.48, 2006-10-13 07:48:30-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P57
+  TAG: NTP_4_2_3P57
+
+  ntpd/ntpd-opts.c@1.36, 2006-10-13 07:48:10-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P57
+
+  ntpd/ntpd-opts.h@1.36, 2006-10-13 07:48:10-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P57
+
+  ntpd/ntpd-opts.texi@1.35, 2006-10-13 07:48:11-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P57
+
+  ntpd/ntpd.1@1.34, 2006-10-13 07:48:12-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P57
+
+  ntpd/ntpdsim-opts.c@1.36, 2006-10-13 07:48:12-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P57
+
+  ntpd/ntpdsim-opts.h@1.36, 2006-10-13 07:48:13-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P57
+
+  ntpd/ntpdsim-opts.texi@1.34, 2006-10-13 07:48:14-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P57
+
+  ntpd/ntpdsim.1@1.34, 2006-10-13 07:48:14-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P57
+
+  ntpdc/ntpdc-opts.c@1.36, 2006-10-13 07:48:15-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P57
+
+  ntpdc/ntpdc-opts.h@1.36, 2006-10-13 07:48:16-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P57
+
+  ntpdc/ntpdc-opts.texi@1.34, 2006-10-13 07:48:16-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P57
+
+  ntpdc/ntpdc.1@1.34, 2006-10-13 07:48:17-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P57
+
+  ntpq/ntpq-opts.c@1.38, 2006-10-13 07:48:18-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P57
+
+  ntpq/ntpq-opts.h@1.38, 2006-10-13 07:48:18-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P57
+
+  ntpq/ntpq-opts.texi@1.35, 2006-10-13 07:48:19-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P57
+
+  ntpq/ntpq.1@1.34, 2006-10-13 07:48:19-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P57
+
+  packageinfo.sh@1.49, 2006-10-13 07:48:20-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P57
+
+  sntp/sntp-opts.c@1.35, 2006-10-13 07:48:21-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P57
+
+  sntp/sntp-opts.h@1.35, 2006-10-13 07:48:22-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P57
+
+  sntp/sntp-opts.texi@1.32, 2006-10-13 07:48:22-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P57
+
+  sntp/sntp.1@1.35, 2006-10-13 07:48:23-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P57
+
+  util/ntp-keygen-opts.c@1.35, 2006-10-13 07:48:24-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P57
+
+  util/ntp-keygen-opts.h@1.35, 2006-10-13 07:48:25-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P57
+
+  util/ntp-keygen-opts.texi@1.33, 2006-10-13 07:48:26-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P57
+
+  util/ntp-keygen.1@1.33, 2006-10-13 07:48:27-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P57
+
+ChangeSet@1.1379.1.47, 2006-10-12 23:32:07-04:00, stenn@whimsy.udel.edu +24 -0
+  Autogen-5.8.7 upgrade
+
+  clockstuff/clktest-opts.c@1.9, 2006-10-12 23:31:35-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  clockstuff/clktest-opts.h@1.9, 2006-10-12 23:31:36-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpd-opts.c@1.35, 2006-10-12 23:31:37-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpd-opts.h@1.35, 2006-10-12 23:31:37-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpd-opts.texi@1.34, 2006-10-12 23:31:38-04:00, stenn@whimsy.udel.edu +3 -3
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpd.1@1.33, 2006-10-12 23:31:39-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpdsim-opts.c@1.35, 2006-10-12 23:31:40-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpdsim-opts.h@1.35, 2006-10-12 23:31:41-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpdsim-opts.texi@1.33, 2006-10-12 23:31:41-04:00, stenn@whimsy.udel.edu +3 -3
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpdsim.1@1.33, 2006-10-12 23:31:42-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpdc/ntpdc-opts.c@1.35, 2006-10-12 23:31:43-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpdc/ntpdc-opts.h@1.35, 2006-10-12 23:31:44-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpdc/ntpdc-opts.texi@1.33, 2006-10-12 23:31:44-04:00, stenn@whimsy.udel.edu +2 -2
+    Autogen-5.8.7 upgrade
+
+  ntpdc/ntpdc.1@1.33, 2006-10-12 23:31:45-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpq/ntpq-opts.c@1.37, 2006-10-12 23:31:46-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpq/ntpq-opts.h@1.37, 2006-10-12 23:31:46-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpq/ntpq-opts.texi@1.34, 2006-10-12 23:31:48-04:00, stenn@whimsy.udel.edu +3 -3
+    Autogen-5.8.7 upgrade
+
+  ntpq/ntpq.1@1.33, 2006-10-12 23:31:48-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  sntp/sntp-opts.c@1.34, 2006-10-12 23:31:49-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  sntp/sntp-opts.h@1.34, 2006-10-12 23:31:50-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  util/ntp-keygen-opts.c@1.34, 2006-10-12 23:31:51-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  util/ntp-keygen-opts.h@1.34, 2006-10-12 23:31:52-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  util/ntp-keygen-opts.texi@1.32, 2006-10-12 23:31:53-04:00, stenn@whimsy.udel.edu +2 -2
+    Autogen-5.8.7 upgrade
+
+  util/ntp-keygen.1@1.32, 2006-10-12 23:31:53-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+ChangeSet@1.1379.1.46, 2006-10-12 23:29:11-04:00, stenn@whimsy.udel.edu +1 -0
+  Require autogen-5.8.7
+
+  include/autogen-version.def@1.3, 2006-10-12 23:28:59-04:00, stenn@whimsy.udel.edu +1 -1
+    Require autogen-5.8.7
+
+ChangeSet@1.1379.1.45, 2006-10-12 22:46:49-04:00, stenn@whimsy.udel.edu +14 -0
+  Autogen-5.8.7 upgrade
+
+  clockstuff/clktest-opts.c@1.8, 2006-10-12 22:46:22-04:00, stenn@whimsy.udel.edu +2 -2
+    Autogen-5.8.7 upgrade
+
+  clockstuff/clktest-opts.h@1.8, 2006-10-12 22:46:23-04:00, stenn@whimsy.udel.edu +3 -3
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpd-opts.c@1.34, 2006-10-12 22:46:23-04:00, stenn@whimsy.udel.edu +3 -3
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpd-opts.h@1.34, 2006-10-12 22:46:24-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpdsim-opts.c@1.34, 2006-10-12 22:46:25-04:00, stenn@whimsy.udel.edu +3 -3
+    Autogen-5.8.7 upgrade
+
+  ntpd/ntpdsim-opts.h@1.34, 2006-10-12 22:46:26-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpdc/ntpdc-opts.c@1.34, 2006-10-12 22:46:27-04:00, stenn@whimsy.udel.edu +3 -3
+    Autogen-5.8.7 upgrade
+
+  ntpdc/ntpdc-opts.h@1.34, 2006-10-12 22:46:28-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  ntpq/ntpq-opts.c@1.36, 2006-10-12 22:46:30-04:00, stenn@whimsy.udel.edu +3 -3
+    Autogen-5.8.7 upgrade
+
+  ntpq/ntpq-opts.h@1.36, 2006-10-12 22:46:31-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  sntp/sntp-opts.c@1.33, 2006-10-12 22:46:32-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  sntp/sntp-opts.h@1.33, 2006-10-12 22:46:33-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+  util/ntp-keygen-opts.c@1.33, 2006-10-12 22:46:34-04:00, stenn@whimsy.udel.edu +3 -3
+    Autogen-5.8.7 upgrade
+
+  util/ntp-keygen-opts.h@1.33, 2006-10-12 22:46:35-04:00, stenn@whimsy.udel.edu +1 -1
+    Autogen-5.8.7 upgrade
+
+ChangeSet@1.1379.1.44, 2006-10-12 22:42:48-04:00, stenn@whimsy.udel.edu +62 -0
+  autogen-5.8.7 upgrade
+
+  libopts/autoopts.c@1.10, 2006-10-12 22:41:36-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/autoopts.h@1.9, 2006-10-12 22:41:37-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/autoopts/options.h@1.10, 2006-10-12 22:41:33-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen-5.8.7 upgrade
+
+  libopts/autoopts/usage-txt.h@1.9, 2006-10-12 22:41:34-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/boolean.c@1.8, 2006-10-12 22:41:39-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/compat/compat.h@1.12, 2006-10-12 22:41:39-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/compat/pathfind.c@1.9, 2006-10-12 22:41:41-04:00, stenn@whimsy.udel.edu +2 -3
+    autogen-5.8.7 upgrade
+
+  libopts/compat/windows-config.h@1.5, 2006-10-12 22:41:43-04:00, stenn@whimsy.udel.edu +8 -2
+    autogen-5.8.7 upgrade
+
+  libopts/configfile.c@1.10, 2006-10-12 22:41:44-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/cook.c@1.9, 2006-10-12 22:41:46-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/enumeration.c@1.9, 2006-10-12 22:41:47-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/environment.c@1.8, 2006-10-12 22:41:48-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/genshell.c@1.9, 2006-10-12 22:41:50-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/genshell.h@1.9, 2006-10-12 22:41:51-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/load.c@1.10, 2006-10-12 22:41:52-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/m4/libopts.m4@1.14, 2006-10-12 22:41:54-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen-5.8.7 upgrade
+
+  libopts/m4/liboptschk.m4@1.3, 2006-10-12 22:41:55-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/makeshell.c@1.11, 2006-10-12 22:41:56-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/nested.c@1.9, 2006-10-12 22:41:58-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/numeric.c@1.9, 2006-10-12 22:41:59-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/pgusage.c@1.9, 2006-10-12 22:42:00-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/proto.h@1.11, 2006-10-12 22:42:01-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/putshell.c@1.10, 2006-10-12 22:42:01-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/restore.c@1.9, 2006-10-12 22:42:03-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/save.c@1.10, 2006-10-12 22:42:05-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/sort.c@1.8, 2006-10-12 22:42:07-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/stack.c@1.10, 2006-10-12 22:42:08-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/streqvcmp.c@1.9, 2006-10-12 22:42:10-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/text_mmap.c@1.8, 2006-10-12 22:42:11-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/usage.c@1.9, 2006-10-12 22:42:13-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  libopts/version.c@1.9, 2006-10-12 22:42:15-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/autoopts.c@1.7, 2006-10-12 22:41:36-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/autoopts.h@1.7, 2006-10-12 22:41:38-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/autoopts/options.h@1.7, 2006-10-12 22:41:33-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/autoopts/usage-txt.h@1.6, 2006-10-12 22:41:35-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/boolean.c@1.5, 2006-10-12 22:41:39-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/compat/compat.h@1.8, 2006-10-12 22:41:40-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/compat/pathfind.c@1.6, 2006-10-12 22:41:42-04:00, stenn@whimsy.udel.edu +2 -3
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/compat/windows-config.h@1.3, 2006-10-12 22:41:43-04:00, stenn@whimsy.udel.edu +8 -2
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/configfile.c@1.7, 2006-10-12 22:41:45-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/cook.c@1.6, 2006-10-12 22:41:47-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/enumeration.c@1.6, 2006-10-12 22:41:48-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/environment.c@1.5, 2006-10-12 22:41:49-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/genshell.c@1.6, 2006-10-12 22:41:50-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/genshell.h@1.6, 2006-10-12 22:41:52-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/load.c@1.7, 2006-10-12 22:41:54-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/m4/libopts.m4@1.11, 2006-10-12 22:41:55-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/m4/liboptschk.m4@1.3, 2006-10-12 22:41:56-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/makeshell.c@1.8, 2006-10-12 22:41:57-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/nested.c@1.6, 2006-10-12 22:41:59-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/numeric.c@1.6, 2006-10-12 22:42:00-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/pgusage.c@1.5, 2006-10-12 22:42:00-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/proto.h@1.8, 2006-10-12 22:42:01-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/putshell.c@1.7, 2006-10-12 22:42:02-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/restore.c@1.5, 2006-10-12 22:42:04-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/save.c@1.7, 2006-10-12 22:42:06-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/sort.c@1.4, 2006-10-12 22:42:07-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/stack.c@1.7, 2006-10-12 22:42:09-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/streqvcmp.c@1.6, 2006-10-12 22:42:10-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/text_mmap.c@1.5, 2006-10-12 22:42:12-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/usage.c@1.7, 2006-10-12 22:42:14-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+  sntp/libopts/version.c@1.6, 2006-10-12 22:42:15-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen-5.8.7 upgrade
+
+ChangeSet@1.1379.1.43, 2006-10-12 19:22:09-04:00, stenn@whimsy.udel.edu +1 -0
+  Improve the getsockname() arg determination
+
+  configure.ac@1.388.1.13, 2006-10-12 19:21:57-04:00, stenn@whimsy.udel.edu +10 -6
+    Improve the getsockname() arg determination
+
+ChangeSet@1.1379.1.42, 2006-10-12 07:40:55-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P56
+  TAG: NTP_4_2_3P56
+
+  ntpd/ntpd-opts.c@1.33, 2006-10-12 07:40:34-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  ntpd/ntpd-opts.h@1.33, 2006-10-12 07:40:35-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P56
+
+  ntpd/ntpd-opts.texi@1.33, 2006-10-12 07:40:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P56
+
+  ntpd/ntpd.1@1.32, 2006-10-12 07:40:36-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  ntpd/ntpdsim-opts.c@1.33, 2006-10-12 07:40:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  ntpd/ntpdsim-opts.h@1.33, 2006-10-12 07:40:38-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P56
+
+  ntpd/ntpdsim-opts.texi@1.32, 2006-10-12 07:40:38-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P56
+
+  ntpd/ntpdsim.1@1.32, 2006-10-12 07:40:39-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  ntpdc/ntpdc-opts.c@1.33, 2006-10-12 07:40:39-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  ntpdc/ntpdc-opts.h@1.33, 2006-10-12 07:40:40-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P56
+
+  ntpdc/ntpdc-opts.texi@1.32, 2006-10-12 07:40:40-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P56
+
+  ntpdc/ntpdc.1@1.32, 2006-10-12 07:40:41-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  ntpq/ntpq-opts.c@1.35, 2006-10-12 07:40:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  ntpq/ntpq-opts.h@1.35, 2006-10-12 07:40:42-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P56
+
+  ntpq/ntpq-opts.texi@1.33, 2006-10-12 07:40:43-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P56
+
+  ntpq/ntpq.1@1.32, 2006-10-12 07:40:44-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  packageinfo.sh@1.48, 2006-10-12 07:40:45-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P56
+
+  sntp/sntp-opts.c@1.32, 2006-10-12 07:40:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  sntp/sntp-opts.h@1.32, 2006-10-12 07:40:47-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P56
+
+  sntp/sntp-opts.texi@1.31, 2006-10-12 07:40:48-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P56
+
+  sntp/sntp.1@1.34, 2006-10-12 07:40:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  util/ntp-keygen-opts.c@1.32, 2006-10-12 07:40:50-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+  util/ntp-keygen-opts.h@1.32, 2006-10-12 07:40:51-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P56
+
+  util/ntp-keygen-opts.texi@1.31, 2006-10-12 07:40:51-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P56
+
+  util/ntp-keygen.1@1.31, 2006-10-12 07:40:52-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P56
+
+ChangeSet@1.1379.1.41, 2006-10-12 02:30:52-04:00, stenn@whimsy.udel.edu +1 -0
+  Update NEWS file
+
+  NEWS@1.68, 2006-10-12 02:30:41-04:00, stenn@whimsy.udel.edu +36 -0
+    Update NEWS file
+
+ChangeSet@1.1379.11.2, 2006-10-11 22:40:46-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #690. Purify memory reference error
+
+  ports/winnt/libntp/dnslookup.c@1.4.1.4, 2006-10-11 22:40:27-04:00, mayer@pogo.udel.edu +4 -3
+    Bug #690. Purify memory reference error
+
+ChangeSet@1.1379.11.1, 2006-10-11 22:39:16-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #718. Update to config.h to deal with socklen_t
+
+  ports/winnt/include/config.h@1.44, 2006-10-11 22:38:35-04:00, mayer@pogo.udel.edu +13 -0
+    Bug #718. Update to config.h to deal with socklen_t
+
+ChangeSet@1.1379.1.39, 2006-10-11 07:44:18-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P55
+  TAG: NTP_4_2_3P55
+
+  ntpd/ntpd-opts.c@1.32, 2006-10-11 07:43:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  ntpd/ntpd-opts.h@1.32, 2006-10-11 07:44:00-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P55
+
+  ntpd/ntpd-opts.texi@1.32, 2006-10-11 07:44:00-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P55
+
+  ntpd/ntpd.1@1.31, 2006-10-11 07:44:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  ntpd/ntpdsim-opts.c@1.32, 2006-10-11 07:44:01-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  ntpd/ntpdsim-opts.h@1.32, 2006-10-11 07:44:02-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P55
+
+  ntpd/ntpdsim-opts.texi@1.31, 2006-10-11 07:44:03-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P55
+
+  ntpd/ntpdsim.1@1.31, 2006-10-11 07:44:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  ntpdc/ntpdc-opts.c@1.32, 2006-10-11 07:44:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  ntpdc/ntpdc-opts.h@1.32, 2006-10-11 07:44:04-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P55
+
+  ntpdc/ntpdc-opts.texi@1.31, 2006-10-11 07:44:05-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P55
+
+  ntpdc/ntpdc.1@1.31, 2006-10-11 07:44:06-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  ntpq/ntpq-opts.c@1.34, 2006-10-11 07:44:06-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  ntpq/ntpq-opts.h@1.34, 2006-10-11 07:44:07-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P55
+
+  ntpq/ntpq-opts.texi@1.32, 2006-10-11 07:44:08-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P55
+
+  ntpq/ntpq.1@1.31, 2006-10-11 07:44:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  packageinfo.sh@1.47, 2006-10-11 07:44:09-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P55
+
+  sntp/sntp-opts.c@1.31, 2006-10-11 07:44:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  sntp/sntp-opts.h@1.31, 2006-10-11 07:44:11-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P55
+
+  sntp/sntp-opts.texi@1.30, 2006-10-11 07:44:12-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P55
+
+  sntp/sntp.1@1.33, 2006-10-11 07:44:12-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  util/ntp-keygen-opts.c@1.31, 2006-10-11 07:44:13-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+  util/ntp-keygen-opts.h@1.31, 2006-10-11 07:44:13-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P55
+
+  util/ntp-keygen-opts.texi@1.30, 2006-10-11 07:44:15-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P55
+
+  util/ntp-keygen.1@1.30, 2006-10-11 07:44:15-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P55
+
+ChangeSet@1.1379.1.37, 2006-10-10 19:52:42-04:00, stenn@whimsy.udel.edu +3 -0
+  [Bug 718] Determine/use the correct type of saddrlen for getsockname()
+
+  configure.ac@1.388.1.12, 2006-10-10 19:52:28-04:00, stenn@whimsy.udel.edu +23 -1
+    [Bug 718] Determine/use the correct type of saddrlen for getsockname()
+
+  libisc/net.c@1.8, 2006-10-10 19:52:28-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 718] Determine/use the correct type of saddrlen for getsockname()
+
+  ntpd/ntp_io.c@1.234.1.14, 2006-10-10 19:52:29-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 718] Determine/use the correct type of saddrlen for getsockname()
+
+ChangeSet@1.1379.10.1, 2006-10-10 16:15:47+00:00, burnicki@pogo.udel.edu +1 -0
+  [Bug 708] nt_clockstuff.c has unintentionally been messed up with the previous changeset. This is the correct version.
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.23, 2006-10-10 16:15:44+00:00, burnicki@pogo.udel.edu +574 -249
+    Oops, this file has unintentionally been messed up with the previous changeset. This is the correct version.
+
+ChangeSet@1.1379.1.36, 2006-10-10 07:46:00-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P54
+  TAG: NTP_4_2_3P54
+
+  ntpd/ntpd-opts.c@1.31, 2006-10-10 07:45:36-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  ntpd/ntpd-opts.h@1.31, 2006-10-10 07:45:37-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P54
+
+  ntpd/ntpd-opts.texi@1.31, 2006-10-10 07:45:37-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P54
+
+  ntpd/ntpd.1@1.30, 2006-10-10 07:45:38-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  ntpd/ntpdsim-opts.c@1.31, 2006-10-10 07:45:39-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  ntpd/ntpdsim-opts.h@1.31, 2006-10-10 07:45:40-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P54
+
+  ntpd/ntpdsim-opts.texi@1.30, 2006-10-10 07:45:40-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P54
+
+  ntpd/ntpdsim.1@1.30, 2006-10-10 07:45:41-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  ntpdc/ntpdc-opts.c@1.31, 2006-10-10 07:45:41-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  ntpdc/ntpdc-opts.h@1.31, 2006-10-10 07:45:42-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P54
+
+  ntpdc/ntpdc-opts.texi@1.30, 2006-10-10 07:45:43-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P54
+
+  ntpdc/ntpdc.1@1.30, 2006-10-10 07:45:44-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  ntpq/ntpq-opts.c@1.33, 2006-10-10 07:45:44-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  ntpq/ntpq-opts.h@1.33, 2006-10-10 07:45:45-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P54
+
+  ntpq/ntpq-opts.texi@1.31, 2006-10-10 07:45:46-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P54
+
+  ntpq/ntpq.1@1.30, 2006-10-10 07:45:47-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  packageinfo.sh@1.46, 2006-10-10 07:45:47-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P54
+
+  sntp/sntp-opts.c@1.30, 2006-10-10 07:45:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  sntp/sntp-opts.h@1.30, 2006-10-10 07:45:49-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P54
+
+  sntp/sntp-opts.texi@1.29, 2006-10-10 07:45:50-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P54
+
+  sntp/sntp.1@1.32, 2006-10-10 07:45:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  util/ntp-keygen-opts.c@1.30, 2006-10-10 07:45:52-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+  util/ntp-keygen-opts.h@1.30, 2006-10-10 07:45:52-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P54
+
+  util/ntp-keygen-opts.texi@1.29, 2006-10-10 07:45:53-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P54
+
+  util/ntp-keygen.1@1.29, 2006-10-10 07:45:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P54
+
+ChangeSet@1.1379.1.35, 2006-10-10 02:39:26-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 718] Use the recommended type for the saddrlen arg to getsockname()
+
+  NEWS@1.67, 2006-10-10 02:39:13-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 718] Use the recommended type for the saddrlen arg to getsockname()
+
+  ntpd/ntp_io.c@1.234.1.13, 2006-10-10 02:38:43-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 718] Use the recommended type for the saddrlen arg to getsockname()
+
+ChangeSet@1.1379.1.34, 2006-10-10 02:27:12-04:00, stenn@whimsy.udel.edu +2 -0
+  Use NO_OPTION_NAME_WARNINGS if cc does not support #warning
+
+  configure.ac@1.388.1.11, 2006-10-10 02:25:45-04:00, stenn@whimsy.udel.edu +11 -0
+    Use NO_OPTION_NAME_WARNINGS if cc does not support #warning
+
+  sntp/configure.ac@1.14, 2006-10-10 02:26:57-04:00, stenn@whimsy.udel.edu +11 -0
+    Use NO_OPTION_NAME_WARNINGS if cc does not support #warning
+
+ChangeSet@1.1379.1.33, 2006-10-09 07:41:25-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P53
+  TAG: NTP_4_2_3P53
+
+  ntpd/ntpd-opts.c@1.30, 2006-10-09 07:41:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  ntpd/ntpd-opts.h@1.30, 2006-10-09 07:41:04-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P53
+
+  ntpd/ntpd-opts.texi@1.30, 2006-10-09 07:41:04-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P53
+
+  ntpd/ntpd.1@1.29, 2006-10-09 07:41:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  ntpd/ntpdsim-opts.c@1.30, 2006-10-09 07:41:06-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  ntpd/ntpdsim-opts.h@1.30, 2006-10-09 07:41:07-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P53
+
+  ntpd/ntpdsim-opts.texi@1.29, 2006-10-09 07:41:08-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P53
+
+  ntpd/ntpdsim.1@1.29, 2006-10-09 07:41:08-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  ntpdc/ntpdc-opts.c@1.30, 2006-10-09 07:41:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  ntpdc/ntpdc-opts.h@1.30, 2006-10-09 07:41:09-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P53
+
+  ntpdc/ntpdc-opts.texi@1.29, 2006-10-09 07:41:10-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P53
+
+  ntpdc/ntpdc.1@1.29, 2006-10-09 07:41:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  ntpq/ntpq-opts.c@1.32, 2006-10-09 07:41:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  ntpq/ntpq-opts.h@1.32, 2006-10-09 07:41:12-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P53
+
+  ntpq/ntpq-opts.texi@1.30, 2006-10-09 07:41:13-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P53
+
+  ntpq/ntpq.1@1.29, 2006-10-09 07:41:14-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  packageinfo.sh@1.45, 2006-10-09 07:41:15-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P53
+
+  sntp/sntp-opts.c@1.29, 2006-10-09 07:41:15-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  sntp/sntp-opts.h@1.29, 2006-10-09 07:41:17-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P53
+
+  sntp/sntp-opts.texi@1.28, 2006-10-09 07:41:17-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P53
+
+  sntp/sntp.1@1.31, 2006-10-09 07:41:19-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  util/ntp-keygen-opts.c@1.29, 2006-10-09 07:41:20-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+  util/ntp-keygen-opts.h@1.29, 2006-10-09 07:41:20-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P53
+
+  util/ntp-keygen-opts.texi@1.28, 2006-10-09 07:41:21-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P53
+
+  util/ntp-keygen.1@1.28, 2006-10-09 07:41:22-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P53
+
+ChangeSet@1.1379.1.32, 2006-10-09 06:35:20-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 715] Fix multicast issues under Linux
+
+  NEWS@1.66, 2006-10-09 06:35:05-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 715] Fix multicast issues under Linux
+
+  libisc/ifiter_ioctl.c@1.25, 2006-10-09 06:35:05-04:00, stenn@whimsy.udel.edu +45 -7
+    [Bug 715] Fix multicast issues under Linux
+
+ChangeSet@1.1379.1.31, 2006-10-08 19:39:10-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P52
+  TAG: NTP_4_2_3P52
+
+  ntpd/ntpd-opts.c@1.29, 2006-10-08 19:38:48-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P52
+
+  ntpd/ntpd-opts.h@1.29, 2006-10-08 19:38:49-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P52
+
+  ntpd/ntpd-opts.texi@1.29, 2006-10-08 19:38:50-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P52
+
+  ntpd/ntpd.1@1.28, 2006-10-08 19:38:50-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P52
+
+  ntpd/ntpdsim-opts.c@1.29, 2006-10-08 19:38:51-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P52
+
+  ntpd/ntpdsim-opts.h@1.29, 2006-10-08 19:38:52-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P52
+
+  ntpd/ntpdsim-opts.texi@1.28, 2006-10-08 19:38:52-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P52
+
+  ntpd/ntpdsim.1@1.28, 2006-10-08 19:38:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P52
+
+  ntpdc/ntpdc-opts.c@1.29, 2006-10-08 19:38:54-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P52
+
+  ntpdc/ntpdc-opts.h@1.29, 2006-10-08 19:38:54-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P52
+
+  ntpdc/ntpdc-opts.texi@1.28, 2006-10-08 19:38:55-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P52
+
+  ntpdc/ntpdc.1@1.28, 2006-10-08 19:38:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P52
+
+  ntpq/ntpq-opts.c@1.31, 2006-10-08 19:38:57-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P52
+
+  ntpq/ntpq-opts.h@1.31, 2006-10-08 19:38:57-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P52
+
+  ntpq/ntpq-opts.texi@1.29, 2006-10-08 19:38:58-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P52
+
+  ntpq/ntpq.1@1.28, 2006-10-08 19:38:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P52
+
+  packageinfo.sh@1.44, 2006-10-08 19:39:00-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P52
+
+  sntp/sntp-opts.c@1.28, 2006-10-08 19:39:01-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P52
+
+  sntp/sntp-opts.h@1.28, 2006-10-08 19:39:01-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P52
+
+  sntp/sntp-opts.texi@1.27, 2006-10-08 19:39:02-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P52
+
+  sntp/sntp.1@1.30, 2006-10-08 19:39:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P52
+
+  util/ntp-keygen-opts.c@1.28, 2006-10-08 19:39:03-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P52
+
+  util/ntp-keygen-opts.h@1.28, 2006-10-08 19:39:04-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P52
+
+  util/ntp-keygen-opts.texi@1.27, 2006-10-08 19:39:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P52
+
+  util/ntp-keygen.1@1.27, 2006-10-08 19:39:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P52
+
+ChangeSet@1.1379.1.30, 2006-10-08 04:32:17-04:00, stenn@whimsy.udel.edu +53 -0
+  libopts-27.5.3
+
+  clockstuff/clktest-opts.c@1.7, 2006-10-08 04:30:41-04:00, stenn@whimsy.udel.edu +9 -7
+    libopts-27.5.3
+
+  clockstuff/clktest-opts.h@1.7, 2006-10-08 04:30:42-04:00, stenn@whimsy.udel.edu +6 -4
+    libopts-27.5.3
+
+  libopts/Makefile.am@1.6, 2006-10-08 04:30:43-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  libopts/autoopts.c@1.9, 2006-10-08 04:30:43-04:00, stenn@whimsy.udel.edu +8 -6
+    libopts-27.5.3
+
+  libopts/autoopts/options.h@1.9, 2006-10-08 04:30:55-04:00, stenn@whimsy.udel.edu +131 -64
+    libopts-27.5.3
+
+  libopts/autoopts/usage-txt.h@1.8, 2006-10-08 04:30:56-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  libopts/configfile.c@1.9, 2006-10-08 04:30:44-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  libopts/cook.c@1.8, 2006-10-08 04:30:45-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  libopts/enumeration.c@1.8, 2006-10-08 04:30:46-04:00, stenn@whimsy.udel.edu +4 -4
+    libopts-27.5.3
+
+  libopts/genshell.c@1.8, 2006-10-08 04:30:47-04:00, stenn@whimsy.udel.edu +3 -1
+    libopts-27.5.3
+
+  libopts/genshell.h@1.8, 2006-10-08 04:30:48-04:00, stenn@whimsy.udel.edu +5 -3
+    libopts-27.5.3
+
+  libopts/load.c@1.9, 2006-10-08 04:30:48-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  libopts/m4/libopts.m4@1.13, 2006-10-08 04:30:56-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  libopts/makeshell.c@1.10, 2006-10-08 04:30:50-04:00, stenn@whimsy.udel.edu +13 -4
+    libopts-27.5.3
+
+  libopts/nested.c@1.8, 2006-10-08 04:30:50-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  libopts/numeric.c@1.8, 2006-10-08 04:30:51-04:00, stenn@whimsy.udel.edu +4 -4
+    libopts-27.5.3
+
+  libopts/proto.h@1.10, 2006-10-08 04:30:51-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  libopts/putshell.c@1.9, 2006-10-08 04:30:51-04:00, stenn@whimsy.udel.edu +8 -8
+    libopts-27.5.3
+
+  libopts/restore.c@1.8, 2006-10-08 04:30:52-04:00, stenn@whimsy.udel.edu +2 -2
+    libopts-27.5.3
+
+  libopts/save.c@1.9, 2006-10-08 04:30:53-04:00, stenn@whimsy.udel.edu +7 -8
+    libopts-27.5.3
+
+  libopts/stack.c@1.9, 2006-10-08 04:30:54-04:00, stenn@whimsy.udel.edu +3 -3
+    libopts-27.5.3
+
+  ntpd/ntpd-opts.c@1.28, 2006-10-08 04:30:57-04:00, stenn@whimsy.udel.edu +3 -1
+    libopts-27.5.3
+
+  ntpd/ntpd-opts.h@1.28, 2006-10-08 04:30:58-04:00, stenn@whimsy.udel.edu +6 -4
+    libopts-27.5.3
+
+  ntpd/ntpdsim-opts.c@1.28, 2006-10-08 04:30:59-04:00, stenn@whimsy.udel.edu +3 -1
+    libopts-27.5.3
+
+  ntpd/ntpdsim-opts.h@1.28, 2006-10-08 04:31:00-04:00, stenn@whimsy.udel.edu +6 -4
+    libopts-27.5.3
+
+  ntpdc/ntpdc-opts.c@1.28, 2006-10-08 04:31:01-04:00, stenn@whimsy.udel.edu +3 -1
+    libopts-27.5.3
+
+  ntpdc/ntpdc-opts.h@1.28, 2006-10-08 04:31:02-04:00, stenn@whimsy.udel.edu +6 -4
+    libopts-27.5.3
+
+  ntpq/ntpq-opts.c@1.30, 2006-10-08 04:31:03-04:00, stenn@whimsy.udel.edu +3 -1
+    libopts-27.5.3
+
+  ntpq/ntpq-opts.h@1.30, 2006-10-08 04:31:04-04:00, stenn@whimsy.udel.edu +6 -4
+    libopts-27.5.3
+
+  ntpq/ntpq-opts.texi@1.28, 2006-10-08 04:31:04-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  sntp/libopts/Makefile.am@1.4, 2006-10-08 04:31:07-04:00, stenn@whimsy.udel.edu +10 -6
+    libopts-27.5.3
+
+  sntp/libopts/autoopts.c@1.6, 2006-10-08 04:31:07-04:00, stenn@whimsy.udel.edu +8 -6
+    libopts-27.5.3
+
+  sntp/libopts/autoopts/options.h@1.6, 2006-10-08 04:31:18-04:00, stenn@whimsy.udel.edu +131 -64
+    libopts-27.5.3
+
+  sntp/libopts/autoopts/usage-txt.h@1.5, 2006-10-08 04:31:18-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  sntp/libopts/configfile.c@1.6, 2006-10-08 04:31:08-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  sntp/libopts/cook.c@1.5, 2006-10-08 04:31:09-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  sntp/libopts/enumeration.c@1.5, 2006-10-08 04:31:09-04:00, stenn@whimsy.udel.edu +4 -4
+    libopts-27.5.3
+
+  sntp/libopts/genshell.c@1.5, 2006-10-08 04:31:10-04:00, stenn@whimsy.udel.edu +3 -1
+    libopts-27.5.3
+
+  sntp/libopts/genshell.h@1.5, 2006-10-08 04:31:11-04:00, stenn@whimsy.udel.edu +5 -3
+    libopts-27.5.3
+
+  sntp/libopts/load.c@1.6, 2006-10-08 04:31:11-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  sntp/libopts/m4/libopts.m4@1.10, 2006-10-08 04:31:20-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  sntp/libopts/makeshell.c@1.7, 2006-10-08 04:31:12-04:00, stenn@whimsy.udel.edu +13 -4
+    libopts-27.5.3
+
+  sntp/libopts/nested.c@1.5, 2006-10-08 04:31:13-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  sntp/libopts/numeric.c@1.5, 2006-10-08 04:31:14-04:00, stenn@whimsy.udel.edu +4 -4
+    libopts-27.5.3
+
+  sntp/libopts/proto.h@1.7, 2006-10-08 04:31:14-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.5.3
+
+  sntp/libopts/putshell.c@1.6, 2006-10-08 04:31:15-04:00, stenn@whimsy.udel.edu +8 -8
+    libopts-27.5.3
+
+  sntp/libopts/restore.c@1.4, 2006-10-08 04:31:15-04:00, stenn@whimsy.udel.edu +2 -2
+    libopts-27.5.3
+
+  sntp/libopts/save.c@1.6, 2006-10-08 04:31:16-04:00, stenn@whimsy.udel.edu +7 -8
+    libopts-27.5.3
+
+  sntp/libopts/stack.c@1.6, 2006-10-08 04:31:17-04:00, stenn@whimsy.udel.edu +3 -3
+    libopts-27.5.3
+
+  sntp/sntp-opts.c@1.27, 2006-10-08 04:31:05-04:00, stenn@whimsy.udel.edu +3 -1
+    libopts-27.5.3
+
+  sntp/sntp-opts.h@1.27, 2006-10-08 04:31:06-04:00, stenn@whimsy.udel.edu +6 -4
+    libopts-27.5.3
+
+  util/ntp-keygen-opts.c@1.27, 2006-10-08 04:31:20-04:00, stenn@whimsy.udel.edu +5 -3
+    libopts-27.5.3
+
+  util/ntp-keygen-opts.h@1.27, 2006-10-08 04:31:21-04:00, stenn@whimsy.udel.edu +6 -4
+    libopts-27.5.3
+
+ChangeSet@1.1379.9.1, 2006-10-07 19:42:28+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    allow asyncio_readers to remove themselves when being run
+
+  ntpd/ntp_io.c@1.234.1.12, 2006-10-07 19:41:38+00:00, kardel@pogo.udel.edu +5 -3
+    allow asyncio_readers to remove themselves when being run
+
+ChangeSet@1.1379.1.28, 2006-10-05 10:20:42+00:00, burnicki@pogo.udel.edu +2 -0
+  [Bug 708] Set the affinity to a specific CPU for the clock interpolation thread only, not for the whole process.
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.22, 2006-10-05 10:20:40+00:00, burnicki@pogo.udel.edu +250 -575
+    Set the affinity to a specific CPU for the clock interpolation thread only, not for the whole process.
+
+  ports/winnt/ntpd/win32_io.c@1.12, 2006-10-05 10:20:40+00:00, burnicki@pogo.udel.edu +0 -22
+    Set the affinity to a specific CPU for the clock interpolation thread only, not for the whole process.
+
+ChangeSet@1.1379.1.27, 2006-09-26 23:45:08-04:00, stenn@whimsy.udel.edu +1 -0
+  update NEWS
+
+  NEWS@1.65, 2006-09-26 23:44:48-04:00, stenn@whimsy.udel.edu +2 -0
+    update
+
+ChangeSet@1.1379.8.3, 2006-09-26 22:17:09-04:00, mayer@pogo.udel.edu +1 -0
+  Unchanged
+
+  ntpd/refclock_wwv.c@1.63.1.1, 2006-09-26 22:16:51-04:00, mayer@pogo.udel.edu +4 -7
+    Unchanged
+
+ChangeSet@1.1379.8.2, 2006-09-26 18:14:39-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #670: Fix for Transfer Aborted messages on Windows on reconfiguring interfaces
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.21, 2006-09-26 18:14:26-04:00, mayer@pogo.udel.edu +98 -38
+    Bug #670: Fix for Transfer Aborted messages on Windows on reconfiguring interfaces
+
+ChangeSet@1.1379.8.1, 2006-09-26 18:11:11-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #690: Fix for buffer address issue
+
+  ports/winnt/libntp/dnslookup.c@1.4.1.3, 2006-09-26 18:10:40-04:00, mayer@pogo.udel.edu +1 -1
+    Bug #690: Fix for buffer address issue
+
+ChangeSet@1.1379.1.25, 2006-09-26 16:16:30-04:00, stenn@whimsy.udel.edu +26 -0
+  autogen update
+
+  clockstuff/clktest-opts.c@1.6, 2006-09-25 15:03:08-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen update
+
+  clockstuff/clktest-opts.h@1.6, 2006-09-25 15:03:09-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen update
+
+  ntpd/ntpd-opts.c@1.27, 2006-09-25 15:03:10-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen update
+
+  ntpd/ntpd-opts.h@1.27, 2006-09-25 15:03:11-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  ntpd/ntpd-opts.texi@1.28, 2006-09-25 15:03:12-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen update
+
+  ntpd/ntpd.1@1.27, 2006-09-25 15:03:12-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  ntpd/ntpdsim-opts.c@1.27, 2006-09-25 15:03:13-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen update
+
+  ntpd/ntpdsim-opts.h@1.27, 2006-09-25 15:03:14-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  ntpd/ntpdsim-opts.texi@1.27, 2006-09-25 15:03:15-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen update
+
+  ntpd/ntpdsim.1@1.27, 2006-09-25 15:03:16-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  ntpdc/ntpdc-opts.c@1.27, 2006-09-25 15:03:16-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen update
+
+  ntpdc/ntpdc-opts.h@1.27, 2006-09-25 15:03:17-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  ntpdc/ntpdc-opts.texi@1.27, 2006-09-25 15:03:18-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen update
+
+  ntpdc/ntpdc.1@1.27, 2006-09-25 15:03:19-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  ntpq/ntpq-opts.c@1.29, 2006-09-25 15:03:20-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen update
+
+  ntpq/ntpq-opts.h@1.29, 2006-09-25 15:03:21-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  ntpq/ntpq-opts.texi@1.27, 2006-09-25 15:03:21-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen update
+
+  ntpq/ntpq.1@1.27, 2006-09-25 15:03:22-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  sntp/sntp-opts.c@1.26, 2006-09-25 15:03:22-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  sntp/sntp-opts.h@1.26, 2006-09-25 15:03:23-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  sntp/sntp-opts.texi@1.26, 2006-09-25 15:03:24-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  sntp/sntp.1@1.29, 2006-09-25 15:03:25-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  util/ntp-keygen-opts.c@1.26, 2006-09-25 15:03:25-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen update
+
+  util/ntp-keygen-opts.h@1.26, 2006-09-25 15:03:26-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+  util/ntp-keygen-opts.texi@1.26, 2006-09-25 15:03:27-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen update
+
+  util/ntp-keygen.1@1.26, 2006-09-25 15:03:27-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen update
+
+ChangeSet@1.1379.1.24, 2006-09-25 07:49:15-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P51
+  TAG: NTP_4_2_3P51
+
+  ntpd/ntpd-opts.c@1.26, 2006-09-25 07:48:54-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P51
+
+  ntpd/ntpd-opts.h@1.26, 2006-09-25 07:48:54-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P51
+
+  ntpd/ntpd-opts.texi@1.27, 2006-09-25 07:48:55-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P51
+
+  ntpd/ntpd.1@1.26, 2006-09-25 07:48:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P51
+
+  ntpd/ntpdsim-opts.c@1.26, 2006-09-25 07:48:57-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P51
+
+  ntpd/ntpdsim-opts.h@1.26, 2006-09-25 07:48:58-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P51
+
+  ntpd/ntpdsim-opts.texi@1.26, 2006-09-25 07:48:59-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P51
+
+  ntpd/ntpdsim.1@1.26, 2006-09-25 07:48:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P51
+
+  ntpdc/ntpdc-opts.c@1.26, 2006-09-25 07:49:00-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P51
+
+  ntpdc/ntpdc-opts.h@1.26, 2006-09-25 07:49:01-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P51
+
+  ntpdc/ntpdc-opts.texi@1.26, 2006-09-25 07:49:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P51
+
+  ntpdc/ntpdc.1@1.26, 2006-09-25 07:49:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P51
+
+  ntpq/ntpq-opts.c@1.28, 2006-09-25 07:49:03-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P51
+
+  ntpq/ntpq-opts.h@1.28, 2006-09-25 07:49:04-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P51
+
+  ntpq/ntpq-opts.texi@1.26, 2006-09-25 07:49:04-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P51
+
+  ntpq/ntpq.1@1.26, 2006-09-25 07:49:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P51
+
+  packageinfo.sh@1.43, 2006-09-25 07:49:06-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P51
+
+  sntp/sntp-opts.c@1.25, 2006-09-25 07:49:06-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P51
+
+  sntp/sntp-opts.h@1.25, 2006-09-25 07:49:07-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P51
+
+  sntp/sntp-opts.texi@1.25, 2006-09-25 07:49:07-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P51
+
+  sntp/sntp.1@1.28, 2006-09-25 07:49:08-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P51
+
+  util/ntp-keygen-opts.c@1.25, 2006-09-25 07:49:09-04:00, stenn@whimsy.udel.edu +4 -4
+    NTP_4_2_3P51
+
+  util/ntp-keygen-opts.h@1.25, 2006-09-25 07:49:09-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P51
+
+  util/ntp-keygen-opts.texi@1.25, 2006-09-25 07:49:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P51
+
+  util/ntp-keygen.1@1.25, 2006-09-25 07:49:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P51
+
+ChangeSet@1.1379.1.23, 2006-09-25 01:53:46-04:00, stenn@whimsy.udel.edu +93 -0
+  autogen upgrade
+
+  NEWS@1.64, 2006-09-25 01:53:32-04:00, stenn@whimsy.udel.edu +6 -5
+    updates
+
+  clockstuff/clktest-opts.c@1.5, 2006-09-25 01:50:03-04:00, stenn@whimsy.udel.edu +6 -3
+    autogen upgrade
+
+  clockstuff/clktest-opts.h@1.5, 2006-09-25 01:50:04-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  libopts/autoopts.c@1.8, 2006-09-25 01:50:05-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/autoopts.h@1.8, 2006-09-25 01:50:05-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/autoopts/options.h@1.8, 2006-09-25 01:50:20-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  libopts/autoopts/usage-txt.h@1.7, 2006-09-25 01:50:22-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  libopts/boolean.c@1.7, 2006-09-25 01:50:06-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/compat/compat.h@1.11, 2006-09-25 01:50:22-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/compat/pathfind.c@1.8, 2006-09-25 01:50:23-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  libopts/compat/strchr.c@1.3, 2006-09-25 01:50:24-04:00, stenn@whimsy.udel.edu +0 -1
+    autogen upgrade
+
+  libopts/compat/windows-config.h@1.4, 2006-09-25 01:50:25-04:00, stenn@whimsy.udel.edu +6 -0
+    autogen upgrade
+
+  libopts/configfile.c@1.8, 2006-09-25 01:50:06-04:00, stenn@whimsy.udel.edu +34 -35
+    autogen upgrade
+
+  libopts/cook.c@1.7, 2006-09-25 01:50:07-04:00, stenn@whimsy.udel.edu +5 -6
+    autogen upgrade
+
+  libopts/enumeration.c@1.7, 2006-09-25 01:50:08-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/environment.c@1.7, 2006-09-25 01:50:08-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/genshell.c@1.7, 2006-09-25 01:50:09-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  libopts/genshell.h@1.7, 2006-09-25 01:50:10-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  libopts/load.c@1.8, 2006-09-25 01:50:10-04:00, stenn@whimsy.udel.edu +10 -11
+    autogen upgrade
+
+  libopts/m4/libopts.m4@1.12, 2006-09-25 01:50:25-04:00, stenn@whimsy.udel.edu +4 -1
+    autogen upgrade
+
+  libopts/m4/liboptschk.m4@1.2, 2006-09-25 01:50:27-04:00, stenn@whimsy.udel.edu +4 -1
+    autogen upgrade
+
+  libopts/makeshell.c@1.9, 2006-09-25 01:50:11-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/nested.c@1.7, 2006-09-25 01:50:12-04:00, stenn@whimsy.udel.edu +18 -19
+    autogen upgrade
+
+  libopts/numeric.c@1.7, 2006-09-25 01:50:12-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/pgusage.c@1.8, 2006-09-25 01:50:13-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/proto.h@1.9, 2006-09-25 01:50:13-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  libopts/putshell.c@1.8, 2006-09-25 01:50:13-04:00, stenn@whimsy.udel.edu +3 -4
+    autogen upgrade
+
+  libopts/restore.c@1.7, 2006-09-25 01:50:14-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/save.c@1.8, 2006-09-25 01:50:15-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/sort.c@1.7, 2006-09-25 01:50:15-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/stack.c@1.8, 2006-09-25 01:50:16-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/streqvcmp.c@1.8, 2006-09-25 01:50:17-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/text_mmap.c@1.7, 2006-09-25 01:50:17-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/tokenize.c@1.5, 2006-09-25 01:50:18-04:00, stenn@whimsy.udel.edu +0 -1
+    autogen upgrade
+
+  libopts/usage.c@1.8, 2006-09-25 01:50:19-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  libopts/version.c@1.8, 2006-09-25 01:50:20-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  ntpd/ntpd-opts.c@1.25, 2006-09-25 01:50:27-04:00, stenn@whimsy.udel.edu +3 -2
+    autogen upgrade
+
+  ntpd/ntpd-opts.h@1.25, 2006-09-25 01:50:28-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  ntpd/ntpd-opts.texi@1.26, 2006-09-25 01:50:29-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  ntpd/ntpd.1@1.25, 2006-09-25 01:50:30-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  ntpd/ntpdsim-opts.c@1.25, 2006-09-25 01:50:31-04:00, stenn@whimsy.udel.edu +3 -2
+    autogen upgrade
+
+  ntpd/ntpdsim-opts.h@1.25, 2006-09-25 01:50:32-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  ntpd/ntpdsim-opts.texi@1.25, 2006-09-25 01:50:32-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  ntpd/ntpdsim.1@1.25, 2006-09-25 01:50:33-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  ntpdc/ntpdc-opts.c@1.25, 2006-09-25 01:50:34-04:00, stenn@whimsy.udel.edu +3 -2
+    autogen upgrade
+
+  ntpdc/ntpdc-opts.h@1.25, 2006-09-25 01:50:34-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  ntpdc/ntpdc-opts.texi@1.25, 2006-09-25 01:52:36-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  ntpdc/ntpdc.1@1.25, 2006-09-25 01:52:37-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  ntpq/ntpq-opts.c@1.27, 2006-09-25 01:50:35-04:00, stenn@whimsy.udel.edu +3 -2
+    autogen upgrade
+
+  ntpq/ntpq-opts.h@1.27, 2006-09-25 01:50:36-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  ntpq/ntpq-opts.texi@1.25, 2006-09-25 01:52:38-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  ntpq/ntpq.1@1.25, 2006-09-25 01:52:38-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  sntp/libopts/autoopts.c@1.5, 2006-09-25 01:50:36-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/autoopts.h@1.6, 2006-09-25 01:50:37-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/autoopts/options.h@1.5, 2006-09-25 01:50:55-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  sntp/libopts/autoopts/usage-txt.h@1.4, 2006-09-25 01:50:55-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  sntp/libopts/boolean.c@1.4, 2006-09-25 01:50:38-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/compat/compat.h@1.7, 2006-09-25 01:50:56-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/compat/pathfind.c@1.5, 2006-09-25 01:50:57-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  sntp/libopts/compat/strchr.c@1.3, 2006-09-25 01:50:57-04:00, stenn@whimsy.udel.edu +0 -1
+    autogen upgrade
+
+  sntp/libopts/compat/windows-config.h@1.2, 2006-09-25 01:50:58-04:00, stenn@whimsy.udel.edu +16 -10
+    autogen upgrade
+
+  sntp/libopts/configfile.c@1.5, 2006-09-25 01:50:38-04:00, stenn@whimsy.udel.edu +34 -35
+    autogen upgrade
+
+  sntp/libopts/cook.c@1.4, 2006-09-25 01:50:40-04:00, stenn@whimsy.udel.edu +5 -6
+    autogen upgrade
+
+  sntp/libopts/enumeration.c@1.4, 2006-09-25 01:50:41-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/environment.c@1.4, 2006-09-25 01:50:42-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/genshell.c@1.4, 2006-09-25 01:50:42-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  sntp/libopts/genshell.h@1.4, 2006-09-25 01:50:43-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  sntp/libopts/load.c@1.5, 2006-09-25 01:50:44-04:00, stenn@whimsy.udel.edu +10 -11
+    autogen upgrade
+
+  sntp/libopts/m4/libopts.m4@1.9, 2006-09-25 01:50:58-04:00, stenn@whimsy.udel.edu +4 -1
+    autogen upgrade
+
+  sntp/libopts/m4/liboptschk.m4@1.2, 2006-09-25 01:50:59-04:00, stenn@whimsy.udel.edu +4 -1
+    autogen upgrade
+
+  sntp/libopts/makeshell.c@1.6, 2006-09-25 01:50:45-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/nested.c@1.4, 2006-09-25 01:50:45-04:00, stenn@whimsy.udel.edu +18 -19
+    autogen upgrade
+
+  sntp/libopts/numeric.c@1.4, 2006-09-25 01:50:46-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/pgusage.c@1.4, 2006-09-25 01:50:46-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/proto.h@1.6, 2006-09-25 01:50:47-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  sntp/libopts/putshell.c@1.5, 2006-09-25 01:50:47-04:00, stenn@whimsy.udel.edu +3 -4
+    autogen upgrade
+
+  sntp/libopts/restore.c@1.3, 2006-09-25 01:50:47-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/save.c@1.5, 2006-09-25 01:50:49-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/sort.c@1.3, 2006-09-25 01:50:50-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/stack.c@1.5, 2006-09-25 01:50:50-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/streqvcmp.c@1.5, 2006-09-25 01:50:51-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/text_mmap.c@1.4, 2006-09-25 01:50:52-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/tokenize.c@1.4, 2006-09-25 01:50:53-04:00, stenn@whimsy.udel.edu +0 -1
+    autogen upgrade
+
+  sntp/libopts/usage.c@1.6, 2006-09-25 01:50:53-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/libopts/version.c@1.5, 2006-09-25 01:50:54-04:00, stenn@whimsy.udel.edu +1 -2
+    autogen upgrade
+
+  sntp/sntp-opts.c@1.24, 2006-09-25 01:52:39-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  sntp/sntp-opts.h@1.24, 2006-09-25 01:52:40-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  sntp/sntp-opts.texi@1.24, 2006-09-25 01:52:40-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  sntp/sntp.1@1.27, 2006-09-25 01:52:42-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  util/ntp-keygen-opts.c@1.24, 2006-09-25 01:50:59-04:00, stenn@whimsy.udel.edu +3 -2
+    autogen upgrade
+
+  util/ntp-keygen-opts.h@1.24, 2006-09-25 01:51:00-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  util/ntp-keygen-opts.texi@1.24, 2006-09-25 01:52:42-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  util/ntp-keygen.1@1.24, 2006-09-25 01:52:43-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+ChangeSet@1.1379.1.22, 2006-09-24 05:30:52-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P50
+  TAG: NTP_4_2_3P50
+
+  ntpd/ntpd-opts.c@1.24, 2006-09-24 05:30:30-04:00, stenn@whimsy.udel.edu +56 -55
+    NTP_4_2_3P50
+
+  ntpd/ntpd-opts.h@1.24, 2006-09-24 05:30:31-04:00, stenn@whimsy.udel.edu +9 -9
+    NTP_4_2_3P50
+
+  ntpd/ntpd-opts.texi@1.25, 2006-09-24 05:30:32-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P50
+
+  ntpd/ntpd.1@1.24, 2006-09-24 05:30:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P50
+
+  ntpd/ntpdsim-opts.c@1.24, 2006-09-24 05:30:34-04:00, stenn@whimsy.udel.edu +74 -73
+    NTP_4_2_3P50
+
+  ntpd/ntpdsim-opts.h@1.24, 2006-09-24 05:30:35-04:00, stenn@whimsy.udel.edu +9 -9
+    NTP_4_2_3P50
+
+  ntpd/ntpdsim-opts.texi@1.24, 2006-09-24 05:30:35-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P50
+
+  ntpd/ntpdsim.1@1.24, 2006-09-24 05:30:36-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P50
+
+  ntpdc/ntpdc-opts.c@1.24, 2006-09-24 05:30:37-04:00, stenn@whimsy.udel.edu +22 -21
+    NTP_4_2_3P50
+
+  ntpdc/ntpdc-opts.h@1.24, 2006-09-24 05:30:38-04:00, stenn@whimsy.udel.edu +7 -7
+    NTP_4_2_3P50
+
+  ntpdc/ntpdc-opts.texi@1.24, 2006-09-24 05:30:38-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P50
+
+  ntpdc/ntpdc.1@1.24, 2006-09-24 05:30:39-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P50
+
+  ntpq/ntpq-opts.c@1.26, 2006-09-24 05:30:40-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P50
+
+  ntpq/ntpq-opts.h@1.26, 2006-09-24 05:30:40-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P50
+
+  ntpq/ntpq-opts.texi@1.24, 2006-09-24 05:30:41-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P50
+
+  ntpq/ntpq.1@1.24, 2006-09-24 05:30:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P50
+
+  packageinfo.sh@1.42, 2006-09-24 05:30:43-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P50
+
+  sntp/sntp-opts.c@1.23, 2006-09-24 05:30:43-04:00, stenn@whimsy.udel.edu +17 -16
+    NTP_4_2_3P50
+
+  sntp/sntp-opts.h@1.23, 2006-09-24 05:30:44-04:00, stenn@whimsy.udel.edu +7 -7
+    NTP_4_2_3P50
+
+  sntp/sntp-opts.texi@1.23, 2006-09-24 05:30:44-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P50
+
+  sntp/sntp.1@1.26, 2006-09-24 05:30:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P50
+
+  util/ntp-keygen-opts.c@1.23, 2006-09-24 05:30:46-04:00, stenn@whimsy.udel.edu +43 -43
+    NTP_4_2_3P50
+
+  util/ntp-keygen-opts.h@1.23, 2006-09-24 05:30:46-04:00, stenn@whimsy.udel.edu +10 -10
+    NTP_4_2_3P50
+
+  util/ntp-keygen-opts.texi@1.23, 2006-09-24 05:30:47-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P50
+
+  util/ntp-keygen.1@1.23, 2006-09-24 05:30:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P50
+
+ChangeSet@1.1379.1.21, 2006-09-24 03:03:52-04:00, stenn@whimsy.udel.edu +67 -0
+  autogen upgrade
+
+  clockstuff/clktest-opts.c@1.4, 2006-09-24 03:02:44-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  clockstuff/clktest-opts.c@1.3, 2006-09-24 00:44:30-04:00, stenn@whimsy.udel.edu +39 -39
+    new autogen
+
+  clockstuff/clktest-opts.h@1.4, 2006-09-24 03:02:45-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  clockstuff/clktest-opts.h@1.3, 2006-09-24 00:44:31-04:00, stenn@whimsy.udel.edu +10 -10
+    new autogen
+
+  libopts/autoopts.c@1.7, 2006-09-24 03:02:46-04:00, stenn@whimsy.udel.edu +7 -7
+    autogen upgrade
+
+  libopts/autoopts.h@1.7, 2006-09-24 03:02:46-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  libopts/autoopts/options.h@1.7, 2006-09-24 03:03:01-04:00, stenn@whimsy.udel.edu +51 -42
+    autogen upgrade
+
+  libopts/autoopts/usage-txt.h@1.6, 2006-09-24 03:03:02-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  libopts/boolean.c@1.6, 2006-09-24 03:02:47-04:00, stenn@whimsy.udel.edu +6 -6
+    autogen upgrade
+
+  libopts/compat/compat.h@1.10, 2006-09-24 03:03:03-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  libopts/compat/pathfind.c@1.7, 2006-09-24 03:03:04-04:00, stenn@whimsy.udel.edu +16 -16
+    autogen upgrade
+
+  libopts/compat/snprintf.c@1.4, 2006-09-24 03:03:05-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  libopts/compat/strchr.c@1.2, 2006-09-24 03:03:05-04:00, stenn@whimsy.udel.edu +5 -5
+    autogen upgrade
+
+  libopts/compat/strdup.c@1.3, 2006-09-24 03:03:06-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  libopts/configfile.c@1.7, 2006-09-24 03:02:48-04:00, stenn@whimsy.udel.edu +23 -23
+    autogen upgrade
+
+  libopts/cook.c@1.6, 2006-09-24 03:02:48-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  libopts/enumeration.c@1.6, 2006-09-24 03:02:49-04:00, stenn@whimsy.udel.edu +23 -23
+    autogen upgrade
+
+  libopts/environment.c@1.6, 2006-09-24 03:02:50-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  libopts/genshell.c@1.6, 2006-09-24 03:02:51-04:00, stenn@whimsy.udel.edu +8 -8
+    autogen upgrade
+
+  libopts/genshell.h@1.6, 2006-09-24 03:02:51-04:00, stenn@whimsy.udel.edu +4 -4
+    autogen upgrade
+
+  libopts/load.c@1.7, 2006-09-24 03:02:52-04:00, stenn@whimsy.udel.edu +4 -4
+    autogen upgrade
+
+  libopts/m4/libopts.m4@1.11, 2006-09-24 03:03:06-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  libopts/makeshell.c@1.8, 2006-09-24 03:02:53-04:00, stenn@whimsy.udel.edu +13 -12
+    autogen upgrade
+
+  libopts/nested.c@1.6, 2006-09-24 03:02:53-04:00, stenn@whimsy.udel.edu +38 -38
+    autogen upgrade
+
+  libopts/numeric.c@1.6, 2006-09-24 03:02:54-04:00, stenn@whimsy.udel.edu +7 -7
+    autogen upgrade
+
+  libopts/pgusage.c@1.7, 2006-09-24 03:02:54-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  libopts/proto.h@1.8, 2006-09-24 03:02:54-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  libopts/putshell.c@1.7, 2006-09-24 03:02:54-04:00, stenn@whimsy.udel.edu +12 -12
+    autogen upgrade
+
+  libopts/restore.c@1.6, 2006-09-24 03:02:55-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  libopts/save.c@1.7, 2006-09-24 03:02:56-04:00, stenn@whimsy.udel.edu +14 -12
+    autogen upgrade
+
+  libopts/sort.c@1.6, 2006-09-24 03:02:56-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  libopts/stack.c@1.7, 2006-09-24 03:02:57-04:00, stenn@whimsy.udel.edu +6 -6
+    autogen upgrade
+
+  libopts/streqvcmp.c@1.7, 2006-09-24 03:02:58-04:00, stenn@whimsy.udel.edu +9 -9
+    autogen upgrade
+
+  libopts/text_mmap.c@1.6, 2006-09-24 03:02:58-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  libopts/tokenize.c@1.4, 2006-09-24 03:02:59-04:00, stenn@whimsy.udel.edu +8 -8
+    autogen upgrade
+
+  libopts/usage.c@1.7, 2006-09-24 03:03:00-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  libopts/version.c@1.7, 2006-09-24 03:03:01-04:00, stenn@whimsy.udel.edu +9 -9
+    autogen upgrade
+
+  ntpq/ntpq-opts.c@1.25, 2006-09-24 03:03:07-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  ntpq/ntpq-opts.c@1.24, 2006-09-24 00:45:24-04:00, stenn@whimsy.udel.edu +17 -17
+    new autogen
+
+  ntpq/ntpq-opts.h@1.25, 2006-09-24 03:03:07-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  ntpq/ntpq-opts.h@1.24, 2006-09-24 00:45:25-04:00, stenn@whimsy.udel.edu +5 -5
+    new autogen
+
+  sntp/libopts/autoopts.c@1.4, 2006-09-24 03:03:08-04:00, stenn@whimsy.udel.edu +51 -7
+    autogen upgrade
+
+  sntp/libopts/autoopts.h@1.5, 2006-09-24 03:03:09-04:00, stenn@whimsy.udel.edu +10 -9
+    autogen upgrade
+
+  sntp/libopts/autoopts/options.h@1.4, 2006-09-24 03:03:23-04:00, stenn@whimsy.udel.edu +60 -51
+    autogen upgrade
+
+  sntp/libopts/autoopts/usage-txt.h@1.3, 2006-09-24 03:03:24-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  sntp/libopts/boolean.c@1.3, 2006-09-24 03:03:10-04:00, stenn@whimsy.udel.edu +5 -5
+    autogen upgrade
+
+  sntp/libopts/compat/compat.h@1.6, 2006-09-24 03:03:25-04:00, stenn@whimsy.udel.edu +7 -7
+    autogen upgrade
+
+  sntp/libopts/compat/pathfind.c@1.4, 2006-09-24 03:03:25-04:00, stenn@whimsy.udel.edu +19 -19
+    autogen upgrade
+
+  sntp/libopts/compat/snprintf.c@1.3, 2006-09-24 03:03:26-04:00, stenn@whimsy.udel.edu +4 -4
+    autogen upgrade
+
+  sntp/libopts/compat/strchr.c@1.2, 2006-09-24 03:03:26-04:00, stenn@whimsy.udel.edu +5 -5
+    autogen upgrade
+
+  sntp/libopts/compat/strdup.c@1.2, 2006-09-24 03:03:27-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  sntp/libopts/configfile.c@1.4, 2006-09-24 03:03:10-04:00, stenn@whimsy.udel.edu +37 -35
+    autogen upgrade
+
+  sntp/libopts/cook.c@1.3, 2006-09-24 03:03:11-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  sntp/libopts/enumeration.c@1.3, 2006-09-24 03:03:12-04:00, stenn@whimsy.udel.edu +23 -23
+    autogen upgrade
+
+  sntp/libopts/environment.c@1.3, 2006-09-24 03:03:12-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  sntp/libopts/genshell.c@1.3, 2006-09-24 03:03:13-04:00, stenn@whimsy.udel.edu +11 -10
+    autogen upgrade
+
+  sntp/libopts/genshell.h@1.3, 2006-09-24 03:03:14-04:00, stenn@whimsy.udel.edu +8 -8
+    autogen upgrade
+
+  sntp/libopts/load.c@1.4, 2006-09-24 03:03:15-04:00, stenn@whimsy.udel.edu +4 -4
+    autogen upgrade
+
+  sntp/libopts/m4/libopts.m4@1.8, 2006-09-24 03:03:27-04:00, stenn@whimsy.udel.edu +8 -3
+    autogen upgrade
+
+  sntp/libopts/makeshell.c@1.5, 2006-09-24 03:03:15-04:00, stenn@whimsy.udel.edu +13 -12
+    autogen upgrade
+
+  sntp/libopts/nested.c@1.3, 2006-09-24 03:03:16-04:00, stenn@whimsy.udel.edu +40 -40
+    autogen upgrade
+
+  sntp/libopts/numeric.c@1.3, 2006-09-24 03:03:17-04:00, stenn@whimsy.udel.edu +6 -6
+    autogen upgrade
+
+  sntp/libopts/proto.h@1.5, 2006-09-24 03:03:17-04:00, stenn@whimsy.udel.edu +14 -2
+    autogen upgrade
+
+  sntp/libopts/putshell.c@1.4, 2006-09-24 03:03:18-04:00, stenn@whimsy.udel.edu +11 -11
+    autogen upgrade
+
+  sntp/libopts/save.c@1.4, 2006-09-24 03:03:18-04:00, stenn@whimsy.udel.edu +14 -12
+    autogen upgrade
+
+  sntp/libopts/stack.c@1.4, 2006-09-24 03:03:19-04:00, stenn@whimsy.udel.edu +5 -5
+    autogen upgrade
+
+  sntp/libopts/streqvcmp.c@1.4, 2006-09-24 03:03:20-04:00, stenn@whimsy.udel.edu +9 -9
+    autogen upgrade
+
+  sntp/libopts/text_mmap.c@1.3, 2006-09-24 03:03:20-04:00, stenn@whimsy.udel.edu +12 -16
+    autogen upgrade
+
+  sntp/libopts/tokenize.c@1.3, 2006-09-24 03:03:21-04:00, stenn@whimsy.udel.edu +16 -16
+    autogen upgrade
+
+  sntp/libopts/usage.c@1.5, 2006-09-24 03:03:22-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  sntp/libopts/version.c@1.4, 2006-09-24 03:03:23-04:00, stenn@whimsy.udel.edu +9 -9
+    autogen upgrade
+
+ChangeSet@1.1379.1.20, 2006-09-23 17:23:36+00:00, kardel@pogo.udel.edu +5 -0
+  ntpd.h, ntpd.c, ntp_timer.c, ntp_io.c, cmd_args.c:
+    disable dynamic update when giving up the root privilege
+
+  include/ntpd.h@1.97, 2006-09-23 17:22:51+00:00, kardel@pogo.udel.edu +3 -0
+    disable dynamic update when giving up the root privilege
+
+  ntpd/cmd_args.c@1.45, 2006-09-23 17:23:01+00:00, kardel@pogo.udel.edu +0 -1
+    disable dynamic update when giving up the root privilege
+
+  ntpd/ntp_io.c@1.234.1.11, 2006-09-23 17:23:02+00:00, kardel@pogo.udel.edu +22 -5
+    disable dynamic update when giving up the root privilege
+
+  ntpd/ntp_timer.c@1.33, 2006-09-23 17:23:03+00:00, kardel@pogo.udel.edu +1 -1
+    disable dynamic update when giving up the root privilege
+
+  ntpd/ntpd.c@1.82, 2006-09-23 17:23:04+00:00, kardel@pogo.udel.edu +12 -0
+    disable dynamic update when giving up the root privilege
+
+ChangeSet@1.1379.7.2, 2006-09-22 20:27:38-04:00, stenn@whimsy.udel.edu +6 -0
+  [Bug 714] ntpq -p should conflict with -i, not -c.
+
+  NEWS@1.63, 2006-09-22 20:27:13-04:00, stenn@whimsy.udel.edu +1 -0
+    update
+
+  ntpq/ntpq-opts.c@1.23, 2006-09-22 20:26:32-04:00, stenn@whimsy.udel.edu +5 -4
+    [Bug 714] ntpq -p should conflict with -i, not -c.
+
+  ntpq/ntpq-opts.def@1.11, 2006-09-22 20:26:33-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 714] ntpq -p should conflict with -i, not -c.
+
+  ntpq/ntpq-opts.h@1.23, 2006-09-22 20:26:33-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 714] ntpq -p should conflict with -i, not -c.
+
+  ntpq/ntpq-opts.texi@1.23, 2006-09-22 20:26:34-04:00, stenn@whimsy.udel.edu +4 -4
+    [Bug 714] ntpq -p should conflict with -i, not -c.
+
+  ntpq/ntpq.1@1.23, 2006-09-22 20:26:35-04:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 714] ntpq -p should conflict with -i, not -c.
+
+ChangeSet@1.1379.7.1, 2006-09-22 19:38:01-04:00, stenn@whimsy.udel.edu +34 -0
+  Upgrade to libopts-27.4.3
+
+  libopts/Makefile.am@1.5, 2006-09-22 19:36:54-04:00, stenn@whimsy.udel.edu +10 -6
+    Upgrade to libopts-27.4.3
+
+  libopts/autoopts.c@1.6, 2006-09-22 19:36:57-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/autoopts.h@1.6, 2006-09-22 19:36:57-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/autoopts/options.h@1.6, 2006-09-22 19:36:55-04:00, stenn@whimsy.udel.edu +5 -5
+    Upgrade to libopts-27.4.3
+
+  libopts/autoopts/usage-txt.h@1.5, 2006-09-22 19:36:55-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/boolean.c@1.5, 2006-09-22 19:36:58-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/compat/compat.h@1.9, 2006-09-22 19:36:58-04:00, stenn@whimsy.udel.edu +5 -5
+    Upgrade to libopts-27.4.3
+
+  libopts/compat/pathfind.c@1.6, 2006-09-22 19:37:00-04:00, stenn@whimsy.udel.edu +2 -2
+    Upgrade to libopts-27.4.3
+
+  libopts/compat/snprintf.c@1.3, 2006-09-22 19:37:01-04:00, stenn@whimsy.udel.edu +2 -2
+    Upgrade to libopts-27.4.3
+
+  libopts/compat/strdup.c@1.2, 2006-09-22 19:37:01-04:00, stenn@whimsy.udel.edu +2 -2
+    Upgrade to libopts-27.4.3
+
+  libopts/compat/windows-config.h@1.3, 2006-09-22 19:37:01-04:00, stenn@whimsy.udel.edu +6 -6
+    Upgrade to libopts-27.4.3
+
+  libopts/configfile.c@1.6, 2006-09-22 19:37:02-04:00, stenn@whimsy.udel.edu +12 -13
+    Upgrade to libopts-27.4.3
+
+  libopts/cook.c@1.5, 2006-09-22 19:37:03-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/enumeration.c@1.5, 2006-09-22 19:37:04-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/environment.c@1.5, 2006-09-22 19:37:04-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/genshell.c@1.5, 2006-09-22 19:37:05-04:00, stenn@whimsy.udel.edu +4 -3
+    Upgrade to libopts-27.4.3
+
+  libopts/genshell.h@1.5, 2006-09-22 19:37:06-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/load.c@1.6, 2006-09-22 19:37:06-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/m4/libopts.m4@1.10, 2006-09-22 19:37:07-04:00, stenn@whimsy.udel.edu +6 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/makeshell.c@1.7, 2006-09-22 19:37:07-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/nested.c@1.5, 2006-09-22 19:37:08-04:00, stenn@whimsy.udel.edu +3 -3
+    Upgrade to libopts-27.4.3
+
+  libopts/numeric.c@1.5, 2006-09-22 19:37:09-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/pgusage.c@1.6, 2006-09-22 19:37:09-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/proto.h@1.7, 2006-09-22 19:37:10-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/putshell.c@1.6, 2006-09-22 19:37:10-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/restore.c@1.5, 2006-09-22 19:37:11-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/save.c@1.6, 2006-09-22 19:37:12-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/sort.c@1.5, 2006-09-22 19:37:12-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/stack.c@1.6, 2006-09-22 19:37:13-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/streqvcmp.c@1.6, 2006-09-22 19:37:14-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/text_mmap.c@1.5, 2006-09-22 19:37:14-04:00, stenn@whimsy.udel.edu +3 -2
+    Upgrade to libopts-27.4.3
+
+  libopts/tokenize.c@1.3, 2006-09-22 19:37:15-04:00, stenn@whimsy.udel.edu +14 -14
+    Upgrade to libopts-27.4.3
+
+  libopts/usage.c@1.6, 2006-09-22 19:37:16-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+  libopts/version.c@1.6, 2006-09-22 19:37:17-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.3
+
+ChangeSet@1.1379.1.18, 2006-09-22 22:58:27+00:00, kardel@pogo.udel.edu +2 -0
+  ntp_io.c:
+    add autoconfig enabled code to temporarily
+    set SO_REUSEADDR on wildcard sockets when
+    binding interface addresses. So OSes need
+    this
+  configure.ac:
+    add configtest for REUSEADDR enable on wildcard sockets
+    to allow binding to interface addresses
+
+  configure.ac@1.388.1.10, 2006-09-22 22:39:30+00:00, kardel@pogo.udel.edu +13 -0
+    add configtest for REUSEADDR enable on wildcard sockets
+    to allow binding to interface addresses
+
+  ntpd/ntp_io.c@1.234.1.10, 2006-09-22 22:45:16+00:00, kardel@pogo.udel.edu +96 -48
+    add autoconfig enabled code to temporarily
+    set SO_REUSEADDR on wildcard sockets when
+    binding interface addresses. So OSes need
+    this
+
+ChangeSet@1.1379.1.17, 2006-09-22 17:12:19-04:00, stenn@whimsy.udel.edu +1 -0
+  Dave fixed a bug in the pll/kernel control code, from a report by Joe Harvell
+
+  ntpd/ntp_loopfilter.c@1.126, 2006-09-22 17:12:08-04:00, stenn@whimsy.udel.edu +2 -1
+    Dave fixed a bug in the pll/kernel control code, from a report by Joe Harvell
+
+ChangeSet@1.1379.1.16, 2006-09-21 07:42:50-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P49
+  TAG: NTP_4_2_3P49
+
+  ntpd/ntpd-opts.c@1.23, 2006-09-21 07:42:29-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  ntpd/ntpd-opts.h@1.23, 2006-09-21 07:42:30-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P49
+
+  ntpd/ntpd-opts.texi@1.24, 2006-09-21 07:42:30-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P49
+
+  ntpd/ntpd.1@1.23, 2006-09-21 07:42:31-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  ntpd/ntpdsim-opts.c@1.23, 2006-09-21 07:42:32-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  ntpd/ntpdsim-opts.h@1.23, 2006-09-21 07:42:33-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P49
+
+  ntpd/ntpdsim-opts.texi@1.23, 2006-09-21 07:42:33-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P49
+
+  ntpd/ntpdsim.1@1.23, 2006-09-21 07:42:34-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  ntpdc/ntpdc-opts.c@1.23, 2006-09-21 07:42:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  ntpdc/ntpdc-opts.h@1.23, 2006-09-21 07:42:36-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P49
+
+  ntpdc/ntpdc-opts.texi@1.23, 2006-09-21 07:42:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P49
+
+  ntpdc/ntpdc.1@1.23, 2006-09-21 07:42:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  ntpq/ntpq-opts.c@1.22, 2006-09-21 07:42:38-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  ntpq/ntpq-opts.h@1.22, 2006-09-21 07:42:38-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P49
+
+  ntpq/ntpq-opts.texi@1.22, 2006-09-21 07:42:39-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P49
+
+  ntpq/ntpq.1@1.22, 2006-09-21 07:42:40-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  packageinfo.sh@1.41, 2006-09-21 07:42:41-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P49
+
+  sntp/sntp-opts.c@1.22, 2006-09-21 07:42:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  sntp/sntp-opts.h@1.22, 2006-09-21 07:42:42-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P49
+
+  sntp/sntp-opts.texi@1.22, 2006-09-21 07:42:43-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P49
+
+  sntp/sntp.1@1.25, 2006-09-21 07:42:44-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  util/ntp-keygen-opts.c@1.22, 2006-09-21 07:42:44-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+  util/ntp-keygen-opts.h@1.22, 2006-09-21 07:42:45-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P49
+
+  util/ntp-keygen-opts.texi@1.22, 2006-09-21 07:42:46-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P49
+
+  util/ntp-keygen.1@1.22, 2006-09-21 07:42:47-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P49
+
+ChangeSet@1.1379.1.15, 2006-09-20 19:41:43-04:00, stenn@whimsy.udel.edu +2 -0
+  refclock_wwv.c improvements from Dave Mills
+
+  NEWS@1.62, 2006-09-20 19:41:03-04:00, stenn@whimsy.udel.edu +1 -0
+    refclock_wwv.c improvements from Dave Mills
+
+  ntpd/refclock_wwv.c@1.64, 2006-09-20 19:41:04-04:00, stenn@whimsy.udel.edu +50 -40
+    refclock_wwv.c improvements from Dave Mills
+
+ChangeSet@1.1379.1.14, 2006-09-20 19:31:10-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 689] Deprecate HEATH GC-1001 II; the driver never worked.
+
+  NEWS@1.61, 2006-09-20 19:30:58-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 689] Deprecate HEATH GC-1001 II; the driver never worked.
+
+  ntpd/refclock_heath.c@1.13, 2006-09-20 19:29:32-04:00, stenn@whimsy.udel.edu +39 -10
+    [Bug 689] Deprecate HEATH GC-1001 II; the driver never worked.
+
+ChangeSet@1.1379.1.13, 2006-09-19 07:43:25-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P48
+  TAG: NTP_4_2_3P48
+
+  ntpd/ntpd-opts.c@1.22, 2006-09-19 07:43:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  ntpd/ntpd-opts.h@1.22, 2006-09-19 07:43:04-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P48
+
+  ntpd/ntpd-opts.texi@1.23, 2006-09-19 07:43:04-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P48
+
+  ntpd/ntpd.1@1.22, 2006-09-19 07:43:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  ntpd/ntpdsim-opts.c@1.22, 2006-09-19 07:43:07-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  ntpd/ntpdsim-opts.h@1.22, 2006-09-19 07:43:08-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P48
+
+  ntpd/ntpdsim-opts.texi@1.22, 2006-09-19 07:43:08-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P48
+
+  ntpd/ntpdsim.1@1.22, 2006-09-19 07:43:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  ntpdc/ntpdc-opts.c@1.22, 2006-09-19 07:43:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  ntpdc/ntpdc-opts.h@1.22, 2006-09-19 07:43:10-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P48
+
+  ntpdc/ntpdc-opts.texi@1.22, 2006-09-19 07:43:11-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P48
+
+  ntpdc/ntpdc.1@1.22, 2006-09-19 07:43:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  ntpq/ntpq-opts.c@1.21, 2006-09-19 07:43:12-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  ntpq/ntpq-opts.h@1.21, 2006-09-19 07:43:12-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P48
+
+  ntpq/ntpq-opts.texi@1.21, 2006-09-19 07:43:13-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P48
+
+  ntpq/ntpq.1@1.21, 2006-09-19 07:43:14-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  packageinfo.sh@1.40, 2006-09-19 07:43:15-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P48
+
+  sntp/sntp-opts.c@1.21, 2006-09-19 07:43:15-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  sntp/sntp-opts.h@1.21, 2006-09-19 07:43:16-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P48
+
+  sntp/sntp-opts.texi@1.21, 2006-09-19 07:43:17-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P48
+
+  sntp/sntp.1@1.24, 2006-09-19 07:43:18-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  util/ntp-keygen-opts.c@1.21, 2006-09-19 07:43:19-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+  util/ntp-keygen-opts.h@1.21, 2006-09-19 07:43:19-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P48
+
+  util/ntp-keygen-opts.texi@1.21, 2006-09-19 07:43:20-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P48
+
+  util/ntp-keygen.1@1.21, 2006-09-19 07:43:21-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P48
+
+ChangeSet@1.1251.94.59, 2006-09-18 23:55:40-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P4_RC4
+  TAG: NTP_4_2_2P4_RC4
+
+  packageinfo.sh@1.27.19.2, 2006-09-18 23:55:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P4_RC4
+
+ChangeSet@1.1251.94.58, 2006-09-18 18:06:02-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 710] Backport Danny's latest patch
+
+  libntp/ntp_rfc2553.c@1.27.1.6, 2006-09-18 18:05:48-04:00, stenn@whimsy.udel.edu +10 -3
+    [Bug 710] Backport Danny's latest patch
+
+ChangeSet@1.1379.1.11, 2006-09-18 16:23:45-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #710 Fix new off-by-one error
+
+  libntp/ntp_rfc2553.c@1.35, 2006-09-18 16:23:26-04:00, mayer@pogo.udel.edu +1 -1
+    Bug #710 Fix new off-by-one error
+
+ChangeSet@1.1379.1.10, 2006-09-18 16:17:26-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #655 Added refid for broadcast mode
+
+  ntpd/ntp_io.c@1.234.1.9, 2006-09-18 16:17:03-04:00, mayer@pogo.udel.edu +1 -0
+    Bug #655 Added refid for broadcast mode
+
+ChangeSet@1.1379.1.9, 2006-09-18 08:46:18-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #710 fix the length being copied in getnameinfo
+
+  libntp/ntp_rfc2553.c@1.34, 2006-09-18 08:46:00-04:00, mayer@pogo.udel.edu +10 -3
+    Bug #710 fix the length being copied in getnameinfo
+
+ChangeSet@1.1379.2.35, 2006-09-16 18:54:38-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P47
+  TAG: NTP_4_2_3P47
+
+  ntpd/ntpd-opts.c@1.21, 2006-09-16 18:54:17-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  ntpd/ntpd-opts.h@1.21, 2006-09-16 18:54:18-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P47
+
+  ntpd/ntpd-opts.texi@1.22, 2006-09-16 18:54:18-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P47
+
+  ntpd/ntpd.1@1.21, 2006-09-16 18:54:19-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  ntpd/ntpdsim-opts.c@1.21, 2006-09-16 18:54:20-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  ntpd/ntpdsim-opts.h@1.21, 2006-09-16 18:54:20-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P47
+
+  ntpd/ntpdsim-opts.texi@1.21, 2006-09-16 18:54:21-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P47
+
+  ntpd/ntpdsim.1@1.21, 2006-09-16 18:54:22-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  ntpdc/ntpdc-opts.c@1.21, 2006-09-16 18:54:23-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  ntpdc/ntpdc-opts.h@1.21, 2006-09-16 18:54:23-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P47
+
+  ntpdc/ntpdc-opts.texi@1.21, 2006-09-16 18:54:24-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P47
+
+  ntpdc/ntpdc.1@1.21, 2006-09-16 18:54:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  ntpq/ntpq-opts.c@1.20, 2006-09-16 18:54:26-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  ntpq/ntpq-opts.h@1.20, 2006-09-16 18:54:27-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P47
+
+  ntpq/ntpq-opts.texi@1.20, 2006-09-16 18:54:28-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P47
+
+  ntpq/ntpq.1@1.20, 2006-09-16 18:54:29-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  packageinfo.sh@1.39, 2006-09-16 18:54:29-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P47
+
+  sntp/sntp-opts.c@1.20, 2006-09-16 18:54:29-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  sntp/sntp-opts.h@1.20, 2006-09-16 18:54:30-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P47
+
+  sntp/sntp-opts.texi@1.20, 2006-09-16 18:54:31-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P47
+
+  sntp/sntp.1@1.23, 2006-09-16 18:54:32-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  util/ntp-keygen-opts.c@1.20, 2006-09-16 18:54:33-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+  util/ntp-keygen-opts.h@1.20, 2006-09-16 18:54:33-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P47
+
+  util/ntp-keygen-opts.texi@1.20, 2006-09-16 18:54:34-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P47
+
+  util/ntp-keygen.1@1.20, 2006-09-16 18:54:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P47
+
+ChangeSet@1.1251.94.57, 2006-09-16 17:32:32-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P4_RC3
+  TAG: NTP_4_2_2P4_RC3
+
+  packageinfo.sh@1.27.19.1, 2006-09-16 17:32:29-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P4_RC3
+
+ChangeSet@1.1251.94.56, 2006-09-16 16:52:07-04:00, stenn@whimsy.udel.edu +1 -0
+  updated NEWS
+
+  NEWS@1.50.1.6, 2006-09-16 16:51:51-04:00, stenn@whimsy.udel.edu +4 -0
+    updated
+
+ChangeSet@1.1251.94.55, 2006-09-16 15:00:36-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 710] compat getnameinfo() has off-by-one error
+
+  libntp/ntp_rfc2553.c@1.27.1.5, 2006-09-16 15:00:26-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 710] compat getnameinfo() has off-by-one error
+
+ChangeSet@1.1379.2.33, 2006-09-13 07:43:13-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P46
+  TAG: NTP_4_2_3P46
+
+  ntpd/ntpd-opts.c@1.20, 2006-09-13 07:42:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  ntpd/ntpd-opts.h@1.20, 2006-09-13 07:42:51-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P46
+
+  ntpd/ntpd-opts.texi@1.21, 2006-09-13 07:42:53-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P46
+
+  ntpd/ntpd.1@1.20, 2006-09-13 07:42:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  ntpd/ntpdsim-opts.c@1.20, 2006-09-13 07:42:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  ntpd/ntpdsim-opts.h@1.20, 2006-09-13 07:42:55-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P46
+
+  ntpd/ntpdsim-opts.texi@1.20, 2006-09-13 07:42:56-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P46
+
+  ntpd/ntpdsim.1@1.20, 2006-09-13 07:42:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  ntpdc/ntpdc-opts.c@1.20, 2006-09-13 07:42:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  ntpdc/ntpdc-opts.h@1.20, 2006-09-13 07:42:59-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P46
+
+  ntpdc/ntpdc-opts.texi@1.20, 2006-09-13 07:42:59-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P46
+
+  ntpdc/ntpdc.1@1.20, 2006-09-13 07:43:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  ntpq/ntpq-opts.c@1.19, 2006-09-13 07:43:01-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  ntpq/ntpq-opts.h@1.19, 2006-09-13 07:43:02-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P46
+
+  ntpq/ntpq-opts.texi@1.19, 2006-09-13 07:43:02-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P46
+
+  ntpq/ntpq.1@1.19, 2006-09-13 07:43:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  packageinfo.sh@1.38, 2006-09-13 07:43:04-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P46
+
+  sntp/sntp-opts.c@1.19, 2006-09-13 07:43:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  sntp/sntp-opts.h@1.19, 2006-09-13 07:43:05-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P46
+
+  sntp/sntp-opts.texi@1.19, 2006-09-13 07:43:06-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P46
+
+  sntp/sntp.1@1.22, 2006-09-13 07:43:07-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  util/ntp-keygen-opts.c@1.19, 2006-09-13 07:43:07-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+  util/ntp-keygen-opts.h@1.19, 2006-09-13 07:43:08-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P46
+
+  util/ntp-keygen-opts.texi@1.19, 2006-09-13 07:43:09-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P46
+
+  util/ntp-keygen.1@1.19, 2006-09-13 07:43:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P46
+
+ChangeSet@1.1379.2.32, 2006-09-13 04:49:48-04:00, stenn@whimsy.udel.edu +2 -0
+  WWV documentation fixes from Dave Mills.
+
+  html/drivers/driver36.html@1.28, 2006-09-13 04:49:38-04:00, stenn@whimsy.udel.edu +53 -100
+    WWV documentation fixes from Dave Mills.
+
+  html/drivers/driver44.html@1.13, 2006-09-13 04:46:46-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-rw-r--
+
+ChangeSet@1.1379.2.31, 2006-09-13 04:44:52-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 704] Fix documentation typo
+
+  html/authopt.html@1.41, 2006-09-13 04:44:37-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 704] Fix documentation typo
+
+ChangeSet@1.1379.2.30, 2006-09-12 21:35:52-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 706] Only 1 instance of ntpd should be running
+
+  ntpd/ntp_io.c@1.234.1.8, 2006-09-12 21:35:04-04:00, stenn@whimsy.udel.edu +17 -5
+    [Bug 706] Only 1 instance of ntpd should be running
+
+ChangeSet@1.1379.2.29, 2006-09-12 07:42:34-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P45
+  TAG: NTP_4_2_3P45
+
+  ntpd/ntpd-opts.c@1.19, 2006-09-12 07:42:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  ntpd/ntpd-opts.h@1.19, 2006-09-12 07:42:09-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P45
+
+  ntpd/ntpd-opts.texi@1.20, 2006-09-12 07:42:10-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P45
+
+  ntpd/ntpd.1@1.19, 2006-09-12 07:42:12-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  ntpd/ntpdsim-opts.c@1.19, 2006-09-12 07:42:13-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  ntpd/ntpdsim-opts.h@1.19, 2006-09-12 07:42:14-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P45
+
+  ntpd/ntpdsim-opts.texi@1.19, 2006-09-12 07:42:14-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P45
+
+  ntpd/ntpdsim.1@1.19, 2006-09-12 07:42:15-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  ntpdc/ntpdc-opts.c@1.19, 2006-09-12 07:42:16-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  ntpdc/ntpdc-opts.h@1.19, 2006-09-12 07:42:16-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P45
+
+  ntpdc/ntpdc-opts.texi@1.19, 2006-09-12 07:42:17-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P45
+
+  ntpdc/ntpdc.1@1.19, 2006-09-12 07:42:18-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  ntpq/ntpq-opts.c@1.18, 2006-09-12 07:42:19-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  ntpq/ntpq-opts.h@1.18, 2006-09-12 07:42:20-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P45
+
+  ntpq/ntpq-opts.texi@1.18, 2006-09-12 07:42:20-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P45
+
+  ntpq/ntpq.1@1.18, 2006-09-12 07:42:21-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  packageinfo.sh@1.37, 2006-09-12 07:42:21-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P45
+
+  sntp/sntp-opts.c@1.18, 2006-09-12 07:42:22-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  sntp/sntp-opts.h@1.18, 2006-09-12 07:42:23-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P45
+
+  sntp/sntp-opts.texi@1.18, 2006-09-12 07:42:23-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P45
+
+  sntp/sntp.1@1.21, 2006-09-12 07:42:24-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  util/ntp-keygen-opts.c@1.18, 2006-09-12 07:42:25-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+  util/ntp-keygen-opts.h@1.18, 2006-09-12 07:42:25-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P45
+
+  util/ntp-keygen-opts.texi@1.18, 2006-09-12 07:42:26-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P45
+
+  util/ntp-keygen.1@1.18, 2006-09-12 07:42:27-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P45
+
+ChangeSet@1.1379.6.1, 2006-09-12 08:25:26+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_peer.c:
+    CID 7: avoid calling broadcast/multicast setup with NULL interface
+
+  ntpd/ntp_peer.c@1.97, 2006-09-12 08:24:24+00:00, kardel@pogo.udel.edu +13 -11
+    CID 7: avoid calling broadcast/multicast setup with NULL interface
+
+ChangeSet@1.1379.2.27, 2006-09-12 04:03:30-04:00, stenn@whimsy.udel.edu +1 -0
+  WWV refclock fixes from Dave Mills
+
+  ntpd/refclock_wwv.c@1.63, 2006-09-12 04:03:17-04:00, stenn@whimsy.udel.edu +7 -4
+    WWV refclock fixes from Dave Mills
+
+ChangeSet@1.1379.2.26, 2006-09-12 06:35:18+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    unify output of "Listening in interface..." message
+    add listing of wildcard interface bindings
+
+  ntpd/ntp_io.c@1.234.1.7, 2006-09-12 06:34:04+00:00, kardel@pogo.udel.edu +25 -13
+    unify output of "Listening in interface..." message
+    add listing of wildcard interface bindings
+
+ChangeSet@1.1379.2.25, 2006-09-11 07:47:06-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P44
+  TAG: NTP_4_2_3P44
+
+  ntpd/ntpd-opts.c@1.18, 2006-09-11 07:46:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  ntpd/ntpd-opts.h@1.18, 2006-09-11 07:46:45-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P44
+
+  ntpd/ntpd-opts.texi@1.19, 2006-09-11 07:46:46-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P44
+
+  ntpd/ntpd.1@1.18, 2006-09-11 07:46:47-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  ntpd/ntpdsim-opts.c@1.18, 2006-09-11 07:46:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  ntpd/ntpdsim-opts.h@1.18, 2006-09-11 07:46:49-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P44
+
+  ntpd/ntpdsim-opts.texi@1.18, 2006-09-11 07:46:49-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P44
+
+  ntpd/ntpdsim.1@1.18, 2006-09-11 07:46:50-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  ntpdc/ntpdc-opts.c@1.18, 2006-09-11 07:46:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  ntpdc/ntpdc-opts.h@1.18, 2006-09-11 07:46:51-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P44
+
+  ntpdc/ntpdc-opts.texi@1.18, 2006-09-11 07:46:52-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P44
+
+  ntpdc/ntpdc.1@1.18, 2006-09-11 07:46:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  ntpq/ntpq-opts.c@1.17, 2006-09-11 07:46:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  ntpq/ntpq-opts.h@1.17, 2006-09-11 07:46:55-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P44
+
+  ntpq/ntpq-opts.texi@1.17, 2006-09-11 07:46:56-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P44
+
+  ntpq/ntpq.1@1.17, 2006-09-11 07:46:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  packageinfo.sh@1.36, 2006-09-11 07:46:57-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P44
+
+  sntp/sntp-opts.c@1.17, 2006-09-11 07:46:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  sntp/sntp-opts.h@1.17, 2006-09-11 07:46:58-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P44
+
+  sntp/sntp-opts.texi@1.17, 2006-09-11 07:46:59-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P44
+
+  sntp/sntp.1@1.20, 2006-09-11 07:46:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  util/ntp-keygen-opts.c@1.17, 2006-09-11 07:47:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+  util/ntp-keygen-opts.h@1.17, 2006-09-11 07:47:01-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P44
+
+  util/ntp-keygen-opts.texi@1.17, 2006-09-11 07:47:02-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P44
+
+  util/ntp-keygen.1@1.17, 2006-09-11 07:47:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P44
+
+ChangeSet@1.1379.2.24, 2006-09-10 20:47:32-04:00, stenn@whimsy.udel.edu +29 -0
+  libopts-27.4.3 updates
+
+  libopts/autoopts.c@1.5, 2006-09-10 20:46:57-04:00, stenn@whimsy.udel.edu +46 -2
+    libopts-27.4.3 updates
+
+  libopts/autoopts.h@1.5, 2006-09-10 20:46:57-04:00, stenn@whimsy.udel.edu +8 -7
+    libopts-27.4.3 updates
+
+  libopts/autoopts/options.h@1.5, 2006-09-10 20:47:14-04:00, stenn@whimsy.udel.edu +3 -3
+    libopts-27.4.3 updates
+
+  libopts/autoopts/usage-txt.h@1.4, 2006-09-10 20:47:15-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/boolean.c@1.4, 2006-09-10 20:46:58-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/compat/compat.h@1.8, 2006-09-10 20:47:16-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/compat/pathfind.c@1.5, 2006-09-10 20:47:17-04:00, stenn@whimsy.udel.edu +2 -2
+    libopts-27.4.3 updates
+
+  libopts/configfile.c@1.5, 2006-09-10 20:46:59-04:00, stenn@whimsy.udel.edu +5 -2
+    libopts-27.4.3 updates
+
+  libopts/cook.c@1.4, 2006-09-10 20:47:00-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/enumeration.c@1.4, 2006-09-10 20:47:00-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/environment.c@1.4, 2006-09-10 20:47:02-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/genshell.c@1.4, 2006-09-10 20:47:03-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/genshell.h@1.4, 2006-09-10 20:47:03-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/load.c@1.5, 2006-09-10 20:47:03-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/m4/libopts.m4@1.9, 2006-09-10 20:47:17-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/makeshell.c@1.6, 2006-09-10 20:47:05-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/nested.c@1.4, 2006-09-10 20:47:06-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/numeric.c@1.4, 2006-09-10 20:47:06-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/pgusage.c@1.5, 2006-09-10 20:47:06-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/proto.h@1.6, 2006-09-10 20:47:07-04:00, stenn@whimsy.udel.edu +13 -1
+    libopts-27.4.3 updates
+
+  libopts/putshell.c@1.5, 2006-09-10 20:47:07-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/restore.c@1.4, 2006-09-10 20:47:08-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/save.c@1.5, 2006-09-10 20:47:09-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/sort.c@1.4, 2006-09-10 20:47:09-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/stack.c@1.5, 2006-09-10 20:47:10-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/streqvcmp.c@1.5, 2006-09-10 20:47:11-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/text_mmap.c@1.4, 2006-09-10 20:47:12-04:00, stenn@whimsy.udel.edu +3 -8
+    libopts-27.4.3 updates
+
+  libopts/usage.c@1.5, 2006-09-10 20:47:13-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+  libopts/version.c@1.5, 2006-09-10 20:47:14-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3 updates
+
+ChangeSet@1.1379.2.23, 2006-09-10 18:03:04-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P43
+  TAG: NTP_4_2_3P43
+
+  ntpd/ntpd-opts.c@1.17, 2006-09-10 18:02:42-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  ntpd/ntpd-opts.h@1.17, 2006-09-10 18:02:43-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P43
+
+  ntpd/ntpd-opts.texi@1.18, 2006-09-10 18:02:44-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P43
+
+  ntpd/ntpd.1@1.17, 2006-09-10 18:02:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  ntpd/ntpdsim-opts.c@1.17, 2006-09-10 18:02:45-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  ntpd/ntpdsim-opts.h@1.17, 2006-09-10 18:02:46-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P43
+
+  ntpd/ntpdsim-opts.texi@1.17, 2006-09-10 18:02:47-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P43
+
+  ntpd/ntpdsim.1@1.17, 2006-09-10 18:02:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  ntpdc/ntpdc-opts.c@1.17, 2006-09-10 18:02:49-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  ntpdc/ntpdc-opts.h@1.17, 2006-09-10 18:02:49-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P43
+
+  ntpdc/ntpdc-opts.texi@1.17, 2006-09-10 18:02:49-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P43
+
+  ntpdc/ntpdc.1@1.17, 2006-09-10 18:02:50-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  ntpq/ntpq-opts.c@1.16, 2006-09-10 18:02:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  ntpq/ntpq-opts.h@1.16, 2006-09-10 18:02:52-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P43
+
+  ntpq/ntpq-opts.texi@1.16, 2006-09-10 18:02:53-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P43
+
+  ntpq/ntpq.1@1.16, 2006-09-10 18:02:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  packageinfo.sh@1.35, 2006-09-10 18:02:55-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P43
+
+  sntp/sntp-opts.c@1.16, 2006-09-10 18:02:55-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  sntp/sntp-opts.h@1.16, 2006-09-10 18:02:56-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P43
+
+  sntp/sntp-opts.texi@1.16, 2006-09-10 18:02:57-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P43
+
+  sntp/sntp.1@1.19, 2006-09-10 18:02:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  util/ntp-keygen-opts.c@1.16, 2006-09-10 18:02:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+  util/ntp-keygen-opts.h@1.16, 2006-09-10 18:02:59-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P43
+
+  util/ntp-keygen-opts.texi@1.16, 2006-09-10 18:03:00-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P43
+
+  util/ntp-keygen.1@1.16, 2006-09-10 18:03:01-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P43
+
+ChangeSet@1.1379.2.22, 2006-09-10 15:58:36-04:00, stenn@whimsy.udel.edu +1 -0
+  [CID 3] Not a typo. Rename variables so Harlan can read the code easier
+
+  libntp/recvbuff.c@1.24, 2006-09-10 15:58:11-04:00, stenn@whimsy.udel.edu +5 -4
+    [CID 3] Not a typo. Rename variables so Harlan can read the code easier
+
+ChangeSet@1.1379.2.21, 2006-09-10 07:48:06-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P42
+  TAG: NTP_4_2_3P42
+
+  ntpd/ntpd-opts.c@1.16, 2006-09-10 07:47:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  ntpd/ntpd-opts.h@1.16, 2006-09-10 07:47:46-04:00, stenn@whimsy.udel.edu +142 -171
+    NTP_4_2_3P42
+
+  ntpd/ntpd-opts.texi@1.17, 2006-09-10 07:47:47-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P42
+
+  ntpd/ntpd.1@1.16, 2006-09-10 07:47:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  ntpd/ntpdsim-opts.c@1.16, 2006-09-10 07:47:49-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  ntpd/ntpdsim-opts.h@1.16, 2006-09-10 07:47:50-04:00, stenn@whimsy.udel.edu +178 -216
+    NTP_4_2_3P42
+
+  ntpd/ntpdsim-opts.texi@1.16, 2006-09-10 07:47:50-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P42
+
+  ntpd/ntpdsim.1@1.16, 2006-09-10 07:47:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  ntpdc/ntpdc-opts.c@1.16, 2006-09-10 07:47:52-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  ntpdc/ntpdc-opts.h@1.16, 2006-09-10 07:47:52-04:00, stenn@whimsy.udel.edu +65 -75
+    NTP_4_2_3P42
+
+  ntpdc/ntpdc-opts.texi@1.16, 2006-09-10 07:47:53-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P42
+
+  ntpdc/ntpdc.1@1.16, 2006-09-10 07:47:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  ntpq/ntpq-opts.c@1.15, 2006-09-10 07:47:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  ntpq/ntpq-opts.h@1.15, 2006-09-10 07:47:55-04:00, stenn@whimsy.udel.edu +55 -63
+    NTP_4_2_3P42
+
+  ntpq/ntpq-opts.texi@1.15, 2006-09-10 07:47:55-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P42
+
+  ntpq/ntpq.1@1.15, 2006-09-10 07:47:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  packageinfo.sh@1.34, 2006-09-10 07:47:57-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P42
+
+  sntp/sntp-opts.c@1.15, 2006-09-10 07:47:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  sntp/sntp-opts.h@1.15, 2006-09-10 07:47:58-04:00, stenn@whimsy.udel.edu +50 -57
+    NTP_4_2_3P42
+
+  sntp/sntp-opts.texi@1.15, 2006-09-10 07:47:59-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P42
+
+  sntp/sntp.1@1.18, 2006-09-10 07:47:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  util/ntp-keygen-opts.c@1.15, 2006-09-10 07:48:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+  util/ntp-keygen-opts.h@1.15, 2006-09-10 07:48:01-04:00, stenn@whimsy.udel.edu +102 -121
+    NTP_4_2_3P42
+
+  util/ntp-keygen-opts.texi@1.15, 2006-09-10 07:48:01-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P42
+
+  util/ntp-keygen.1@1.15, 2006-09-10 07:48:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P42
+
+ChangeSet@1.1379.2.20, 2006-09-09 20:11:07-04:00, stenn@whimsy.udel.edu +1 -0
+  Fix a typo.
+
+  libntp/recvbuff.c@1.23, 2006-09-09 20:10:52-04:00, stenn@whimsy.udel.edu +1 -1
+    Fix a typo.
+
+ChangeSet@1.1379.2.19, 2006-09-09 18:29:08-04:00, stenn@whimsy.udel.edu +2 -0
+  autogen upgrade
+
+  clockstuff/clktest-opts.c@1.2, 2006-09-09 18:28:55-04:00, stenn@whimsy.udel.edu +53 -36
+    autogen upgrade
+
+  clockstuff/clktest-opts.h@1.2, 2006-09-09 18:28:55-04:00, stenn@whimsy.udel.edu +72 -14
+    autogen upgrade
+
+ChangeSet@1.1379.2.18, 2006-09-09 18:21:20-04:00, stenn@whimsy.udel.edu +30 -0
+  libopts-27.4.3
+
+  libopts/COPYING.lgpl@1.2, 2006-09-09 18:20:42-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/Makefile.am@1.4, 2006-09-09 18:20:43-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/autoopts.c@1.4, 2006-09-09 18:20:43-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/autoopts/options.h@1.4, 2006-09-09 18:20:57-04:00, stenn@whimsy.udel.edu +5 -5
+    libopts-27.4.3
+
+  libopts/autoopts/usage-txt.h@1.3, 2006-09-09 18:20:58-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/boolean.c@1.3, 2006-09-09 18:20:44-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/compat/compat.h@1.7, 2006-09-09 18:20:59-04:00, stenn@whimsy.udel.edu +3 -3
+    libopts-27.4.3
+
+  libopts/compat/pathfind.c@1.4, 2006-09-09 18:21:00-04:00, stenn@whimsy.udel.edu +5 -5
+    libopts-27.4.3
+
+  libopts/compat/windows-config.h@1.2, 2006-09-09 18:21:01-04:00, stenn@whimsy.udel.edu +4 -4
+    libopts-27.4.3
+
+  libopts/configfile.c@1.4, 2006-09-09 18:20:44-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/cook.c@1.3, 2006-09-09 18:20:45-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/enumeration.c@1.3, 2006-09-09 18:20:45-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/environment.c@1.3, 2006-09-09 18:20:46-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/genshell.c@1.3, 2006-09-09 18:20:47-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/genshell.h@1.3, 2006-09-09 18:20:48-04:00, stenn@whimsy.udel.edu +6 -6
+    libopts-27.4.3
+
+  libopts/load.c@1.4, 2006-09-09 18:20:48-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/m4/libopts.m4@1.8, 2006-09-09 18:21:01-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/makeshell.c@1.5, 2006-09-09 18:20:48-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/nested.c@1.3, 2006-09-09 18:20:50-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/numeric.c@1.3, 2006-09-09 18:20:50-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/pgusage.c@1.4, 2006-09-09 18:20:51-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/proto.h@1.5, 2006-09-09 18:20:51-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/putshell.c@1.4, 2006-09-09 18:20:51-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/restore.c@1.3, 2006-09-09 18:20:52-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/save.c@1.4, 2006-09-09 18:20:53-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/sort.c@1.3, 2006-09-09 18:20:54-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/stack.c@1.4, 2006-09-09 18:20:54-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/streqvcmp.c@1.4, 2006-09-09 18:20:55-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+  libopts/text_mmap.c@1.3, 2006-09-09 18:20:56-04:00, stenn@whimsy.udel.edu +7 -7
+    libopts-27.4.3
+
+  libopts/version.c@1.4, 2006-09-09 18:20:57-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.3
+
+ChangeSet@1.1379.5.1, 2006-09-09 05:19:19-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P41
+  TAG: NTP_4_2_3P41
+
+  ntpd/ntpd-opts.c@1.15, 2006-09-09 05:18:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  ntpd/ntpd-opts.h@1.15, 2006-09-09 05:18:59-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P41
+
+  ntpd/ntpd-opts.texi@1.16, 2006-09-09 05:19:00-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P41
+
+  ntpd/ntpd.1@1.15, 2006-09-09 05:19:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  ntpd/ntpdsim-opts.c@1.15, 2006-09-09 05:19:01-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  ntpd/ntpdsim-opts.h@1.15, 2006-09-09 05:19:02-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P41
+
+  ntpd/ntpdsim-opts.texi@1.15, 2006-09-09 05:19:03-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P41
+
+  ntpd/ntpdsim.1@1.15, 2006-09-09 05:19:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  ntpdc/ntpdc-opts.c@1.15, 2006-09-09 05:19:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  ntpdc/ntpdc-opts.h@1.15, 2006-09-09 05:19:05-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P41
+
+  ntpdc/ntpdc-opts.texi@1.15, 2006-09-09 05:19:05-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P41
+
+  ntpdc/ntpdc.1@1.15, 2006-09-09 05:19:06-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  ntpq/ntpq-opts.c@1.14, 2006-09-09 05:19:07-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  ntpq/ntpq-opts.h@1.14, 2006-09-09 05:19:07-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P41
+
+  ntpq/ntpq-opts.texi@1.14, 2006-09-09 05:19:08-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P41
+
+  ntpq/ntpq.1@1.14, 2006-09-09 05:19:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  packageinfo.sh@1.33, 2006-09-09 05:19:10-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P41
+
+  sntp/sntp-opts.c@1.14, 2006-09-09 05:19:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  sntp/sntp-opts.h@1.14, 2006-09-09 05:19:11-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P41
+
+  sntp/sntp-opts.texi@1.14, 2006-09-09 05:19:12-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P41
+
+  sntp/sntp.1@1.17, 2006-09-09 05:19:12-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  util/ntp-keygen-opts.c@1.14, 2006-09-09 05:19:13-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+  util/ntp-keygen-opts.h@1.14, 2006-09-09 05:19:14-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P41
+
+  util/ntp-keygen-opts.texi@1.14, 2006-09-09 05:19:15-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P41
+
+  util/ntp-keygen.1@1.14, 2006-09-09 05:19:16-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P41
+
+ChangeSet@1.1379.2.16, 2006-09-09 07:16:37+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    remove unnecessary test
+
+  ntpd/ntp_io.c@1.234.1.6, 2006-09-09 07:15:44+00:00, kardel@pogo.udel.edu +1 -1
+    remove unnecessary test
+
+ChangeSet@1.1379.2.15, 2006-09-08 21:33:04-04:00, stenn@whimsy.udel.edu +1 -0
+  [CID 6] Fix a possible null dereference
+
+  ntpd/ntp_io.c@1.234.1.5, 2006-09-08 21:32:51-04:00, stenn@whimsy.udel.edu +3 -3
+    [CID 6] Fix a possible null dereference
+
+ChangeSet@1.1379.2.14, 2006-09-08 19:23:32-04:00, stenn@whimsy.udel.edu +4 -0
+  [Bug 691] ntp_monitor()/restrictions() interaction fixes
+
+  include/ntpd.h@1.96, 2006-09-08 19:22:49-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 691] ntp_monitor()/restrictions() interaction fixes
+
+  ntpd/ntp_monitor.c@1.18, 2006-09-08 19:23:08-04:00, stenn@whimsy.udel.edu +7 -4
+    [Bug 691] ntp_monitor()/restrictions() interaction fixes
+
+  ntpd/ntp_proto.c@1.248, 2006-09-08 19:23:09-04:00, stenn@whimsy.udel.edu +3 -2
+    [Bug 691] ntp_monitor()/restrictions() interaction fixes
+
+  ntpd/ntp_restrict.c@1.22, 2006-09-08 19:23:11-04:00, stenn@whimsy.udel.edu +3 -2
+    [Bug 691] ntp_monitor()/restrictions() interaction fixes
+
+ChangeSet@1.1379.4.1, 2006-09-08 17:20:34-04:00, stenn@whimsy.udel.edu +1 -0
+  autogen dependency cleanup
+
+  ntpdc/Makefile.am@1.33, 2006-09-08 17:20:02-04:00, stenn@whimsy.udel.edu +4 -4
+    autogen dependency cleanup
+
+ChangeSet@1.1379.2.12, 2006-09-08 20:42:56+00:00, kardel@pogo.udel.edu +2 -0
+  configure.ac:
+    add config fragment to conditionally re-bind sockets
+    for OSes that fail to flush cached routes when more
+    specific route are discovered.
+  ntp_io.c:
+    re-bind sockets on OSes that fail to
+    flush cached routes when more specific
+    routes are discovered.
+
+  configure.ac@1.388.1.9, 2006-09-08 20:32:42+00:00, kardel@pogo.udel.edu +13 -0
+    add config fragment to conditionally re-bind sockets
+    for OSes that fail to flush cached routes when more
+    specific route are discovered.
+
+  ntpd/ntp_io.c@1.234.1.4, 2006-09-08 20:37:49+00:00, kardel@pogo.udel.edu +10 -3
+    re-bind sockets on OSes that fail to
+    flush cached routes when more specific
+    routes are discovered.
+
+ChangeSet@1.1379.2.11, 2006-09-07 21:45:01-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P39
+  TAG: NTP_4_2_3P39
+
+  ntpd/ntpd-opts.c@1.14, 2006-09-07 21:44:44-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+  ntpd/ntpd-opts.h@1.14, 2006-09-07 21:44:44-04:00, stenn@whimsy.udel.edu +185 -4
+    NTP_4_2_3P39
+
+  ntpd/ntpd-opts.texi@1.15, 2006-09-07 21:44:45-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P39
+
+  ntpd/ntpd.1@1.14, 2006-09-07 21:44:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+  ntpd/ntpdsim-opts.c@1.14, 2006-09-07 21:44:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+  ntpd/ntpdsim-opts.h@1.14, 2006-09-07 21:44:47-04:00, stenn@whimsy.udel.edu +239 -4
+    NTP_4_2_3P39
+
+  ntpd/ntpdsim-opts.texi@1.14, 2006-09-07 21:44:48-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P39
+
+  ntpd/ntpdsim.1@1.14, 2006-09-07 21:44:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+  ntpdc/ntpdc-opts.c@1.14, 2006-09-07 21:44:49-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+  ntpdc/ntpdc-opts.h@1.14, 2006-09-07 21:44:49-04:00, stenn@whimsy.udel.edu +71 -4
+    NTP_4_2_3P39
+
+  ntpdc/ntpdc-opts.texi@1.14, 2006-09-07 21:44:50-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P39
+
+  ntpdc/ntpdc.1@1.14, 2006-09-07 21:44:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+  ntpq/ntpq-opts.c@1.13, 2006-09-07 21:44:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+  ntpq/ntpq-opts.h@1.13, 2006-09-07 21:44:52-04:00, stenn@whimsy.udel.edu +59 -4
+    NTP_4_2_3P39
+
+  ntpq/ntpq-opts.texi@1.13, 2006-09-07 21:44:53-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P39
+
+  ntpq/ntpq.1@1.13, 2006-09-07 21:44:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+  packageinfo.sh@1.32, 2006-09-07 21:44:54-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P39
+
+  sntp/sntp-opts.c@1.13, 2006-09-07 21:44:55-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P39
+
+  sntp/sntp-opts.h@1.13, 2006-09-07 21:44:55-04:00, stenn@whimsy.udel.edu +53 -4
+    NTP_4_2_3P39
+
+  sntp/sntp-opts.texi@1.13, 2006-09-07 21:44:55-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P39
+
+  sntp/sntp.1@1.16, 2006-09-07 21:44:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+  util/ntp-keygen-opts.c@1.13, 2006-09-07 21:44:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+  util/ntp-keygen-opts.h@1.13, 2006-09-07 21:44:57-04:00, stenn@whimsy.udel.edu +125 -4
+    NTP_4_2_3P39
+
+  util/ntp-keygen-opts.texi@1.13, 2006-09-07 21:44:58-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P39
+
+  util/ntp-keygen.1@1.13, 2006-09-07 21:44:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P39
+
+ChangeSet@1.1379.2.10, 2006-09-07 19:12:01-04:00, stenn@whimsy.udel.edu +3 -0
+  autogen dependency cleanup
+
+  ntpd/Makefile.am@1.52, 2006-09-07 19:11:48-04:00, stenn@whimsy.udel.edu +8 -8
+    autogen dependency cleanup
+
+  ntpq/Makefile.am@1.25, 2006-09-07 19:11:49-04:00, stenn@whimsy.udel.edu +4 -4
+    autogen dependency cleanup
+
+  util/Makefile.am@1.34, 2006-09-07 19:11:50-04:00, stenn@whimsy.udel.edu +4 -4
+    autogen dependency cleanup
+
+ChangeSet@1.1379.2.9, 2006-09-07 19:07:52-04:00, stenn@whimsy.udel.edu +1 -0
+  More WWV cleanup/fixes from Dave Mills
+
+  ntpd/refclock_wwv.c@1.62, 2006-09-07 19:07:37-04:00, stenn@whimsy.udel.edu +6 -11
+    More WWV cleanup/fixes from Dave Mills
+
+ChangeSet@1.1379.2.8, 2006-09-07 03:22:04-04:00, stenn@whimsy.udel.edu +1 -0
+  sntp/autogen-version.def should be ignored by bk
+
+  BitKeeper/etc/ignore@1.58, 2006-09-07 03:19:09-04:00, stenn@whimsy.udel.edu +1 -0
+    added sntp/autogen-version.def
+
+ChangeSet@1.1379.2.7, 2006-09-07 02:06:36-04:00, stenn@whimsy.udel.edu +12 -0
+  [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  clockstuff/clktest-opts.def@1.4, 2006-09-07 02:06:15-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  include/Makefile.am@1.24, 2006-09-07 02:06:15-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  include/autogen-version.def@1.2, 2006-09-07 02:06:15-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  ntpd/Makefile.am@1.51, 2006-09-07 02:06:15-04:00, stenn@whimsy.udel.edu +3 -2
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  ntpdc/Makefile.am@1.32, 2006-09-07 02:06:16-04:00, stenn@whimsy.udel.edu +3 -2
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  ntpdc/ntpdc-opts.def@1.12, 2006-09-07 02:06:17-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  ntpq/Makefile.am@1.24, 2006-09-07 02:06:18-04:00, stenn@whimsy.udel.edu +3 -2
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  ntpq/ntpq-opts.def@1.10, 2006-09-07 02:06:18-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  sntp/Makefile.am@1.21, 2006-09-07 02:06:19-04:00, stenn@whimsy.udel.edu +12 -2
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  sntp/sntp-opts.def@1.9, 2006-09-07 02:06:19-04:00, stenn@whimsy.udel.edu +2 -0
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  util/Makefile.am@1.33, 2006-09-07 02:06:20-04:00, stenn@whimsy.udel.edu +3 -2
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+  util/ntp-keygen-opts.def@1.6, 2006-09-07 02:06:21-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 695] autogen uprgrade: warn/protect macro collisions
+
+ChangeSet@1.1379.2.6, 2006-09-07 01:58:07-04:00, stenn@whimsy.udel.edu +1 -0
+  WWV refclock changes from Dave Mills
+
+  ntpd/refclock_wwv.c@1.61, 2006-09-07 01:57:55-04:00, stenn@whimsy.udel.edu +245 -294
+    WWV refclock changes from Dave Mills
+
+ChangeSet@1.1379.2.5, 2006-09-07 00:48:56-05:00, stenn@poog.il.thewrittenword.com +1 -0
+  [Bug 693] fix configure when there is __adtimex and no ntp_*time
+
+  configure.ac@1.388.1.8, 2006-09-07 00:48:15-05:00, stenn@poog.il.thewrittenword.com +7 -10
+    [Bug 693] fix configure when there is __adtimex and no ntp_*time
+
+ChangeSet@1.1379.2.4, 2006-08-31 02:06:16-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P38
+  TAG: NTP_4_2_3P38
+
+  ntpd/ntpd-opts.c@1.13, 2006-08-31 02:05:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  ntpd/ntpd-opts.h@1.13, 2006-08-31 02:05:57-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P38
+
+  ntpd/ntpd-opts.texi@1.14, 2006-08-31 02:05:57-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P38
+
+  ntpd/ntpd.1@1.13, 2006-08-31 02:05:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  ntpd/ntpdsim-opts.c@1.13, 2006-08-31 02:05:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  ntpd/ntpdsim-opts.h@1.13, 2006-08-31 02:05:59-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P38
+
+  ntpd/ntpdsim-opts.texi@1.13, 2006-08-31 02:06:00-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P38
+
+  ntpd/ntpdsim.1@1.13, 2006-08-31 02:06:01-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  ntpdc/ntpdc-opts.c@1.13, 2006-08-31 02:06:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  ntpdc/ntpdc-opts.h@1.13, 2006-08-31 02:06:03-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P38
+
+  ntpdc/ntpdc-opts.texi@1.13, 2006-08-31 02:06:03-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P38
+
+  ntpdc/ntpdc.1@1.13, 2006-08-31 02:06:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  ntpq/ntpq-opts.c@1.12, 2006-08-31 02:06:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  ntpq/ntpq-opts.h@1.12, 2006-08-31 02:06:05-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P38
+
+  ntpq/ntpq-opts.texi@1.12, 2006-08-31 02:06:06-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P38
+
+  ntpq/ntpq.1@1.12, 2006-08-31 02:06:07-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  packageinfo.sh@1.31, 2006-08-31 02:06:07-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P38
+
+  sntp/sntp-opts.c@1.12, 2006-08-31 02:06:08-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  sntp/sntp-opts.h@1.12, 2006-08-31 02:06:09-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P38
+
+  sntp/sntp-opts.texi@1.12, 2006-08-31 02:06:09-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P38
+
+  sntp/sntp.1@1.15, 2006-08-31 02:06:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  util/ntp-keygen-opts.c@1.12, 2006-08-31 02:06:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+  util/ntp-keygen-opts.h@1.12, 2006-08-31 02:06:11-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P38
+
+  util/ntp-keygen-opts.texi@1.12, 2006-08-31 02:06:12-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P38
+
+  util/ntp-keygen.1@1.12, 2006-08-31 02:06:13-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P38
+
+ChangeSet@1.1379.2.3, 2006-08-30 06:28:59-04:00, stenn@whimsy.udel.edu +5 -0
+  [Bug 340, 342] Deprecate broken TRAK and MSF EES refclocks
+
+  NEWS@1.59, 2006-08-30 06:28:23-04:00, stenn@whimsy.udel.edu +2 -0
+    [Bug 340, 342] Deprecate broken TRAK and MSF EES refclocks
+
+  configure.ac@1.388.1.7, 2006-08-30 06:28:26-04:00, stenn@whimsy.udel.edu +20 -18
+    [Bug 340, 342] Deprecate broken TRAK and MSF EES refclocks
+
+  ntpd/Makefile.am@1.50, 2006-08-30 06:27:33-04:00, stenn@whimsy.udel.edu +6 -3
+    [Bug 340, 342] Deprecate broken TRAK and MSF EES refclocks
+
+  ntpd/ntp_control.c@1.87, 2006-08-30 06:27:35-04:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 340, 342] Deprecate broken TRAK and MSF EES refclocks
+
+  ntpd/refclock_conf.c@1.26, 2006-08-30 06:27:42-04:00, stenn@whimsy.udel.edu +4 -4
+    [Bug 340, 342] Deprecate broken TRAK and MSF EES refclocks
+
+ChangeSet@1.1379.3.1, 2006-08-29 23:45:21-04:00, stenn@whimsy.udel.edu +1 -0
+  Fix dependency order problem
+
+  sntp/Makefile.am@1.20, 2006-08-29 23:45:10-04:00, stenn@whimsy.udel.edu +2 -1
+    Fix dependency order problem
+
+ChangeSet@1.1379.2.1, 2006-08-29 16:05:33-04:00, neal@pogo.udel.edu +1 -0
+  refclock_bancomm.c:
+    [BUG 421] add support for bc637PCI
+
+  ntpd/refclock_bancomm.c@1.9, 2006-08-29 15:55:13-04:00, neal@pogo.udel.edu +138 -104
+    [BUG 421] add support for bc637PCI
+
+ChangeSet@1.1353.9.51, 2006-08-29 07:55:52-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #656: Multicast address argument copied incorrectly
+
+  ntpdate/ntpdate.c@1.59, 2006-08-29 07:55:16-04:00, mayer@pogo.udel.edu +1 -1
+    Bug #656: Multicast address argument copied wrongly
+
+ChangeSet@1.1379.1.5, 2006-08-29 06:47:20-04:00, stenn@whimsy.udel.edu +1 -0
+  loopfilter changes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.125, 2006-08-29 06:47:08-04:00, stenn@whimsy.udel.edu +12 -15
+    loopfilter changes from Dave Mills
+
+ChangeSet@1.1379.1.4, 2006-08-29 08:16:22+00:00, stenn@ntp1.isc.org +1 -0
+  [Bug 603] Cleanup the configure patch for the libelf fix
+
+  configure.ac@1.388.1.6, 2006-08-29 08:16:13+00:00, stenn@ntp1.isc.org +12 -9
+    [Bug 603] Cleanup the configure patch for the libelf fix
+
+ChangeSet@1.1379.1.3, 2006-08-28 21:48:10-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P37
+  TAG: NTP_4_2_3P37
+
+  ntpd/ntpd-opts.c@1.12, 2006-08-28 21:47:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  ntpd/ntpd-opts.h@1.12, 2006-08-28 21:47:47-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P37
+
+  ntpd/ntpd-opts.texi@1.13, 2006-08-28 21:47:48-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P37
+
+  ntpd/ntpd.1@1.12, 2006-08-28 21:47:48-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  ntpd/ntpdsim-opts.c@1.12, 2006-08-28 21:47:49-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  ntpd/ntpdsim-opts.h@1.12, 2006-08-28 21:47:50-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P37
+
+  ntpd/ntpdsim-opts.texi@1.12, 2006-08-28 21:47:50-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P37
+
+  ntpd/ntpdsim.1@1.12, 2006-08-28 21:47:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  ntpdc/ntpdc-opts.c@1.12, 2006-08-28 21:47:52-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  ntpdc/ntpdc-opts.h@1.12, 2006-08-28 21:47:54-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P37
+
+  ntpdc/ntpdc-opts.texi@1.12, 2006-08-28 21:47:54-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P37
+
+  ntpdc/ntpdc.1@1.12, 2006-08-28 21:47:55-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  ntpq/ntpq-opts.c@1.11, 2006-08-28 21:47:56-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  ntpq/ntpq-opts.h@1.11, 2006-08-28 21:47:57-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P37
+
+  ntpq/ntpq-opts.texi@1.11, 2006-08-28 21:47:58-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P37
+
+  ntpq/ntpq.1@1.11, 2006-08-28 21:47:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  packageinfo.sh@1.30, 2006-08-28 21:47:59-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P37
+
+  sntp/sntp-opts.c@1.11, 2006-08-28 21:48:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  sntp/sntp-opts.h@1.11, 2006-08-28 21:48:01-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P37
+
+  sntp/sntp-opts.texi@1.11, 2006-08-28 21:48:01-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P37
+
+  sntp/sntp.1@1.14, 2006-08-28 21:48:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  util/ntp-keygen-opts.c@1.11, 2006-08-28 21:48:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+  util/ntp-keygen-opts.h@1.11, 2006-08-28 21:48:03-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P37
+
+  util/ntp-keygen-opts.texi@1.11, 2006-08-28 21:48:04-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P37
+
+  util/ntp-keygen.1@1.11, 2006-08-28 21:48:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P37
+
+ChangeSet@1.1379.1.2, 2006-08-28 05:03:05-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 603] Only link with libelf if we need it.
+
+  configure.ac@1.388.1.5, 2006-08-28 05:02:46-04:00, stenn@whimsy.udel.edu +22 -19
+    [Bug 603] Only link with libelf if we need it.
+
+ChangeSet@1.1379.1.1, 2006-08-27 23:47:09-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 692] sys_limitrejected is no longer incremented
+
+  ntpd/ntp_proto.c@1.247, 2006-08-27 23:46:56-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 692] sys_limitrejected is no longer incremented
+
+ChangeSet@1.1379, 2006-08-27 20:49:57-04:00, stenn@whimsy.udel.edu +5 -0
+  [Bug 688] Fix documentation typos
+
+  html/clockopt.html@1.19, 2006-08-27 20:49:38-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 688] Fix documentation typos
+
+  html/notes.html@1.18, 2006-08-27 20:49:42-04:00, stenn@whimsy.udel.edu +10 -10
+    [Bug 688] Fix documentation typos
+
+  html/ntpd.html@1.39, 2006-08-27 20:49:43-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 688] Fix documentation typos
+
+  html/ntpdate.html@1.18, 2006-08-27 20:49:44-04:00, stenn@whimsy.udel.edu +3 -1
+    [Bug 688] Fix documentation typos
+
+  html/ntpdc.html@1.25, 2006-08-27 20:49:44-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 688] Fix documentation typos
+
+ChangeSet@1.1378, 2006-08-27 23:44:15+00:00, stenn@ntp1.isc.org +1 -0
+  [Bug 153] Avoid DNS lookups of known netmasks or refclocks
+
+  ntpd/ntp_config.c@1.141, 2006-08-27 23:44:07+00:00, stenn@ntp1.isc.org +30 -4
+    [Bug 153] Avoid DNS lookups of known netmasks or refclocks
+
+ChangeSet@1.1353.21.3, 2006-08-26 15:10:29-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P36
+  TAG: NTP_4_2_3P36
+
+  ntpd/ntpd-opts.c@1.11, 2006-08-26 15:10:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  ntpd/ntpd-opts.h@1.11, 2006-08-26 15:10:05-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P36
+
+  ntpd/ntpd-opts.texi@1.12, 2006-08-26 15:10:06-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P36
+
+  ntpd/ntpd.1@1.11, 2006-08-26 15:10:07-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  ntpd/ntpdsim-opts.c@1.11, 2006-08-26 15:10:08-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  ntpd/ntpdsim-opts.h@1.11, 2006-08-26 15:10:09-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P36
+
+  ntpd/ntpdsim-opts.texi@1.11, 2006-08-26 15:10:10-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P36
+
+  ntpd/ntpdsim.1@1.11, 2006-08-26 15:10:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  ntpdc/ntpdc-opts.c@1.11, 2006-08-26 15:10:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  ntpdc/ntpdc-opts.h@1.11, 2006-08-26 15:10:12-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P36
+
+  ntpdc/ntpdc-opts.texi@1.11, 2006-08-26 15:10:12-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P36
+
+  ntpdc/ntpdc.1@1.11, 2006-08-26 15:10:13-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  ntpq/ntpq-opts.c@1.10, 2006-08-26 15:10:14-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  ntpq/ntpq-opts.h@1.10, 2006-08-26 15:10:14-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P36
+
+  ntpq/ntpq-opts.texi@1.10, 2006-08-26 15:10:15-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P36
+
+  ntpq/ntpq.1@1.10, 2006-08-26 15:10:16-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  packageinfo.sh@1.29, 2006-08-26 15:10:17-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P36
+
+  sntp/sntp-opts.c@1.10, 2006-08-26 15:10:17-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  sntp/sntp-opts.h@1.10, 2006-08-26 15:10:18-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P36
+
+  sntp/sntp-opts.texi@1.10, 2006-08-26 15:10:19-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P36
+
+  sntp/sntp.1@1.13, 2006-08-26 15:10:20-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  util/ntp-keygen-opts.c@1.10, 2006-08-26 15:10:20-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+  util/ntp-keygen-opts.h@1.10, 2006-08-26 15:10:21-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P36
+
+  util/ntp-keygen-opts.texi@1.10, 2006-08-26 15:10:22-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P36
+
+  util/ntp-keygen.1@1.10, 2006-08-26 15:10:22-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P36
+
+ChangeSet@1.1251.94.54, 2006-08-26 05:34:06-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P4_RC2
+  TAG: NTP_4_2_2P4_RC2
+
+  packageinfo.sh@1.27.18.1, 2006-08-26 05:34:03-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P4_RC2
+
+ChangeSet@1.1353.22.1, 2006-08-26 05:05:56-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P35
+  TAG: NTP_4_2_3P35
+
+  ntpd/ntpd-opts.c@1.10, 2006-08-26 05:05:35-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  ntpd/ntpd-opts.h@1.10, 2006-08-26 05:05:36-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P35
+
+  ntpd/ntpd-opts.texi@1.11, 2006-08-26 05:05:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P35
+
+  ntpd/ntpd.1@1.10, 2006-08-26 05:05:37-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  ntpd/ntpdsim-opts.c@1.10, 2006-08-26 05:05:38-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  ntpd/ntpdsim-opts.h@1.10, 2006-08-26 05:05:39-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P35
+
+  ntpd/ntpdsim-opts.texi@1.10, 2006-08-26 05:05:39-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P35
+
+  ntpd/ntpdsim.1@1.10, 2006-08-26 05:05:41-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  ntpdc/ntpdc-opts.c@1.10, 2006-08-26 05:05:41-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  ntpdc/ntpdc-opts.h@1.10, 2006-08-26 05:05:42-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P35
+
+  ntpdc/ntpdc-opts.texi@1.10, 2006-08-26 05:05:43-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P35
+
+  ntpdc/ntpdc.1@1.10, 2006-08-26 05:05:43-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  ntpq/ntpq-opts.c@1.9, 2006-08-26 05:05:44-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  ntpq/ntpq-opts.h@1.9, 2006-08-26 05:05:45-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P35
+
+  ntpq/ntpq-opts.texi@1.9, 2006-08-26 05:05:45-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P35
+
+  ntpq/ntpq.1@1.9, 2006-08-26 05:05:46-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  packageinfo.sh@1.28, 2006-08-26 05:05:47-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P35
+
+  sntp/sntp-opts.c@1.9, 2006-08-26 05:05:47-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  sntp/sntp-opts.h@1.9, 2006-08-26 05:05:48-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P35
+
+  sntp/sntp-opts.texi@1.9, 2006-08-26 05:05:49-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P35
+
+  sntp/sntp.1@1.12, 2006-08-26 05:05:50-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  util/ntp-keygen-opts.c@1.9, 2006-08-26 05:05:51-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+  util/ntp-keygen-opts.h@1.9, 2006-08-26 05:05:52-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P35
+
+  util/ntp-keygen-opts.texi@1.9, 2006-08-26 05:05:52-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P35
+
+  util/ntp-keygen.1@1.9, 2006-08-26 05:05:53-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P35
+
+ChangeSet@1.1251.94.53, 2006-08-25 15:55:51-04:00, stenn@whimsy.udel.edu +1 -0
+  update README.patches
+
+  README.patches@1.3, 2006-08-25 15:55:28-04:00, stenn@whimsy.udel.edu +11 -1
+    update
+
+ChangeSet@1.1251.94.52, 2006-08-25 09:00:40-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #690: Fix length returned. Prevents buffer overflow
+
+  ports/winnt/libntp/dnslookup.c@1.3.1.1, 2006-08-25 09:00:24-04:00, mayer@pogo.udel.edu +1 -1
+    Bug #690: Fix length returned. Prevents buffer overflow
+
+ChangeSet@1.1353.20.1, 2006-08-25 08:57:39-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #690: Cleanup fix. Erroneous #define
+
+  libntp/ntp_rfc2553.c@1.32, 2006-08-25 08:57:05-04:00, mayer@pogo.udel.edu +0 -1
+    Bug #690: Cleanup fix. Erroneous #define
+
+ChangeSet@1.1353.9.48, 2006-08-25 02:26:29-04:00, stenn@whimsy.udel.edu +1 -0
+  Dependency cleanup
+
+  sntp/Makefile.am@1.19, 2006-08-25 02:26:15-04:00, stenn@whimsy.udel.edu +6 -6
+    Dependency cleanup
+
+ChangeSet@1.1353.9.47, 2006-08-25 02:24:00-04:00, stenn@whimsy.udel.edu +1 -0
+  ntp_optind needs a declaration, not a definition
+
+  ntpdc/ntpdc.c@1.54, 2006-08-25 02:23:48-04:00, stenn@whimsy.udel.edu +1 -1
+    ntp_optind needs a declaration, not a definition
+
+ChangeSet@1.1251.94.51, 2006-08-24 19:50:32-04:00, stenn@whimsy.udel.edu +1 -0
+  br-flock: mort lives
+
+  br-flock@1.10, 2006-08-24 19:49:33-04:00, stenn@whimsy.udel.edu +1 -1
+    br-flock: mort lives
+
+ChangeSet@1.1353.9.45, 2006-08-24 17:12:32-04:00, stenn@whimsy.udel.edu +3 -0
+  Changes from Dave Mills: Rename MAXSIG to MAXAMP to avoid a collision, tweak the code
+
+  ntpd/refclock_chu.c@1.38, 2006-08-24 17:10:52-04:00, stenn@whimsy.udel.edu +6 -6
+    Rename MAXSIG to MAXAMP to avoid a collision
+
+  ntpd/refclock_irig.c@1.23, 2006-08-24 17:10:52-04:00, stenn@whimsy.udel.edu +6 -6
+    Rename MAXSIG to MAXAMP to avoid a collision
+
+  ntpd/refclock_wwv.c@1.60, 2006-08-24 17:11:27-04:00, stenn@whimsy.udel.edu +124 -119
+    Rename MAXSIG to MAXAMP to avoid a collision, tweak the code
+
+ChangeSet@1.1353.9.44, 2006-08-24 16:04:18-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 638] remove STREAMS_TLI comment from legacy info
+
+  include/ntp_machine.h@1.23, 2006-08-24 16:04:02-04:00, stenn@whimsy.udel.edu +0 -2
+    [Bug 638] remove STREAMS_TLI comment from legacy info
+
+ChangeSet@1.1353.19.1, 2006-08-24 09:10:50-04:00, mayer@pogo.udel.edu +2 -0
+  Bug #690:Proper fix for length issue
+
+  libntp/ntp_rfc2553.c@1.31, 2006-08-24 09:10:22-04:00, mayer@pogo.udel.edu +2 -1
+    Bug #690:Proper fix for length issue
+
+  ports/winnt/libntp/dnslookup.c@1.4, 2006-08-24 09:10:22-04:00, mayer@pogo.udel.edu +1 -1
+    Bug #690:Proper fix for length issue
+
+ChangeSet@1.1353.9.42, 2006-08-20 20:18:08-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P34
+  TAG: NTP_4_2_3P34
+
+  ntpd/ntpd-opts.c@1.9, 2006-08-20 20:17:49-04:00, stenn@whimsy.udel.edu +19 -19
+    NTP_4_2_3P34
+
+  ntpd/ntpd-opts.h@1.9, 2006-08-20 20:17:49-04:00, stenn@whimsy.udel.edu +5 -5
+    NTP_4_2_3P34
+
+  ntpd/ntpd-opts.texi@1.10, 2006-08-20 20:17:50-04:00, stenn@whimsy.udel.edu +7 -7
+    NTP_4_2_3P34
+
+  ntpd/ntpd.1@1.9, 2006-08-20 20:17:51-04:00, stenn@whimsy.udel.edu +5 -5
+    NTP_4_2_3P34
+
+  ntpd/ntpdsim-opts.c@1.9, 2006-08-20 20:17:51-04:00, stenn@whimsy.udel.edu +19 -19
+    NTP_4_2_3P34
+
+  ntpd/ntpdsim-opts.h@1.9, 2006-08-20 20:17:52-04:00, stenn@whimsy.udel.edu +5 -5
+    NTP_4_2_3P34
+
+  ntpd/ntpdsim-opts.texi@1.9, 2006-08-20 20:17:53-04:00, stenn@whimsy.udel.edu +7 -7
+    NTP_4_2_3P34
+
+  ntpd/ntpdsim.1@1.9, 2006-08-20 20:17:54-04:00, stenn@whimsy.udel.edu +5 -5
+    NTP_4_2_3P34
+
+  ntpdc/ntpdc-opts.c@1.9, 2006-08-20 20:17:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P34
+
+  ntpdc/ntpdc-opts.h@1.9, 2006-08-20 20:17:55-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P34
+
+  ntpdc/ntpdc-opts.texi@1.9, 2006-08-20 20:17:56-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P34
+
+  ntpdc/ntpdc.1@1.9, 2006-08-20 20:17:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P34
+
+  ntpq/ntpq-opts.c@1.8, 2006-08-20 20:17:57-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P34
+
+  ntpq/ntpq-opts.h@1.8, 2006-08-20 20:17:58-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P34
+
+  ntpq/ntpq-opts.texi@1.8, 2006-08-20 20:17:59-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P34
+
+  ntpq/ntpq.1@1.8, 2006-08-20 20:18:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P34
+
+  packageinfo.sh@1.27, 2006-08-20 20:18:00-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P34
+
+  sntp/sntp-opts.c@1.8, 2006-08-20 20:18:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P34
+
+  sntp/sntp-opts.h@1.8, 2006-08-20 20:18:01-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P34
+
+  sntp/sntp-opts.texi@1.8, 2006-08-20 20:18:02-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P34
+
+  sntp/sntp.1@1.11, 2006-08-20 20:18:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P34
+
+  util/ntp-keygen-opts.c@1.8, 2006-08-20 20:18:03-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P34
+
+  util/ntp-keygen-opts.h@1.8, 2006-08-20 20:18:03-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P34
+
+  util/ntp-keygen-opts.texi@1.8, 2006-08-20 20:18:04-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P34
+
+  util/ntp-keygen.1@1.8, 2006-08-20 20:18:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P34
+
+ChangeSet@1.1353.9.41, 2006-08-19 23:55:26-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #690: don't copy to many bytes when copying the address info
+
+  libntp/ntp_rfc2553.c@1.30, 2006-08-19 23:54:56-04:00, mayer@pogo.udel.edu +1 -1
+    Bug #690: don't copy to many bytes when copying the address info
+
+ChangeSet@1.1353.9.39, 2006-08-19 23:34:01-04:00, stenn@whimsy.udel.edu +25 -0
+  NTP_4_2_3P33
+  TAG: NTP_4_2_3P33
+
+  ntpd/ntpd-opts.c@1.8, 2006-08-19 23:11:54-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  ntpd/ntpd-opts.h@1.8, 2006-08-19 23:11:54-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P33
+
+  ntpd/ntpd-opts.texi@1.9, 2006-08-19 23:11:55-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P33
+
+  ntpd/ntpd.1@1.8, 2006-08-19 23:11:55-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  ntpd/ntpdsim-opts.c@1.8, 2006-08-19 23:11:55-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  ntpd/ntpdsim-opts.h@1.8, 2006-08-19 23:11:56-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P33
+
+  ntpd/ntpdsim-opts.texi@1.8, 2006-08-19 23:11:57-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P33
+
+  ntpd/ntpdsim.1@1.8, 2006-08-19 23:11:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  ntpdc/ntpdc-opts.c@1.8, 2006-08-19 23:11:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  ntpdc/ntpdc-opts.h@1.8, 2006-08-19 23:11:59-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P33
+
+  ntpdc/ntpdc-opts.texi@1.8, 2006-08-19 23:12:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  ntpdc/ntpdc.1@1.8, 2006-08-19 23:12:01-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  ntpq/ntpq-opts.c@1.7, 2006-08-19 23:12:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  ntpq/ntpq-opts.h@1.7, 2006-08-19 23:12:02-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P33
+
+  ntpq/ntpq-opts.texi@1.7, 2006-08-19 23:12:03-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P33
+
+  ntpq/ntpq.1@1.7, 2006-08-19 23:12:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  packageinfo.sh@1.26, 2006-08-19 22:17:12-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P33
+
+  sntp/sntp-opts.c@1.7, 2006-08-19 23:12:04-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  sntp/sntp-opts.h@1.7, 2006-08-19 23:12:05-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P33
+
+  sntp/sntp-opts.texi@1.7, 2006-08-19 23:12:06-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P33
+
+  sntp/sntp.1@1.10, 2006-08-19 23:12:06-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  util/ntp-keygen-opts.c@1.7, 2006-08-19 23:12:08-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  util/ntp-keygen-opts.h@1.7, 2006-08-19 23:12:09-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P33
+
+  util/ntp-keygen-opts.texi@1.7, 2006-08-19 23:12:10-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+  util/ntp-keygen.1@1.7, 2006-08-19 23:12:11-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P33
+
+ChangeSet@1.1353.18.1, 2006-08-18 07:58:19-04:00, mayer@pogo.udel.edu +9 -0
+  Bug #685: Changes for MM timer and code cleanup
+
+  include/ntpd.h@1.95, 2006-08-18 07:56:32-04:00, mayer@pogo.udel.edu +0 -3
+    Bug #685: Changes for MM timer and code cleanup
+
+  ntpd/cmd_args.c@1.42.1.1, 2006-08-18 07:56:32-04:00, mayer@pogo.udel.edu +0 -8
+    Bug #685: Changes for MM timer and code cleanup
+
+  ntpd/ntp_timer.c@1.32, 2006-08-18 07:56:32-04:00, mayer@pogo.udel.edu +1 -1
+    Bug #685: Changes for MM timer and code cleanup
+
+  ntpd/ntpd.c@1.81, 2006-08-18 07:56:32-04:00, mayer@pogo.udel.edu +15 -7
+    Bug #685: Changes for MM timer and code cleanup
+
+  ntpd/ntpdbase-opts.def@1.7.1.1, 2006-08-18 07:56:32-04:00, mayer@pogo.udel.edu +4 -3
+    Bug #685: Changes for MM timer and code cleanup
+
+  ports/winnt/include/clockstuff.h@1.7, 2006-08-18 07:57:35-04:00, mayer@pogo.udel.edu +11 -0
+    Bug #685: Changes for MM timer and code cleanup
+
+  ports/winnt/include/config.h@1.43, 2006-08-18 07:57:35-04:00, mayer@pogo.udel.edu +7 -1
+    Bug #685: Changes for MM timer and code cleanup
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.21, 2006-08-18 07:57:35-04:00, mayer@pogo.udel.edu +4 -4
+    Bug #685: Changes for MM timer and code cleanup
+
+  ports/winnt/ntpd/ntpd.dsp@1.29, 2006-08-18 07:57:35-04:00, mayer@pogo.udel.edu +102 -2
+    Bug #685: Changes for MM timer and code cleanup
+
+ChangeSet@1.1353.9.38, 2006-08-18 06:37:36-04:00, stenn@whimsy.udel.edu +1 -0
+  Remove "commented out" items from the bk ignore file
+
+  BitKeeper/etc/ignore@1.57, 2006-08-18 06:37:19-04:00, stenn@whimsy.udel.edu +0 -13
+    Remove "commented out" items from the bk ignore file
+
+ChangeSet@1.1353.9.37, 2006-08-18 03:33:56-04:00, stenn@whimsy.udel.edu +6 -0
+  libopts upgrade
+
+  libopts/autoopts.h@1.4, 2006-08-18 03:33:36-04:00, stenn@whimsy.udel.edu +12 -4
+    libopts upgrade
+
+  libopts/m4/libopts.m4@1.7, 2006-08-18 03:33:37-04:00, stenn@whimsy.udel.edu +4 -4
+    libopts upgrade
+
+  libopts/usage.c@1.4, 2006-08-18 03:33:37-04:00, stenn@whimsy.udel.edu +3 -3
+    libopts upgrade
+
+  sntp/libopts/autoopts.h@1.4, 2006-08-18 03:33:38-04:00, stenn@whimsy.udel.edu +12 -4
+    libopts upgrade
+
+  sntp/libopts/m4/libopts.m4@1.7, 2006-08-18 03:33:39-04:00, stenn@whimsy.udel.edu +4 -4
+    libopts upgrade
+
+  sntp/libopts/usage.c@1.4, 2006-08-18 03:33:39-04:00, stenn@whimsy.udel.edu +3 -3
+    libopts upgrade
+
+ChangeSet@1.1353.9.36, 2006-08-17 01:29:37-04:00, stenn@whimsy.udel.edu +8 -0
+  [Bug 685] cleanup
+
+  ntpd/ntpd-opts.c@1.7, 2006-08-17 01:29:02-04:00, stenn@whimsy.udel.edu +58 -28
+    [Bug 685] use updated autogen-erated files
+
+  ntpd/ntpd-opts.h@1.7, 2006-08-17 01:29:03-04:00, stenn@whimsy.udel.edu +24 -20
+    [Bug 685] use updated autogen-erated files
+
+  ntpd/ntpd-opts.texi@1.8, 2006-08-17 01:29:04-04:00, stenn@whimsy.udel.edu +16 -1
+    [Bug 685] use updated autogen-erated files
+
+  ntpd/ntpd.1@1.7, 2006-08-17 01:29:05-04:00, stenn@whimsy.udel.edu +7 -2
+    [Bug 685] use updated autogen-erated files
+
+  ntpd/ntpdsim-opts.c@1.7, 2006-08-17 01:29:05-04:00, stenn@whimsy.udel.edu +70 -40
+    [Bug 685] use updated autogen-erated files
+
+  ntpd/ntpdsim-opts.h@1.7, 2006-08-17 01:29:06-04:00, stenn@whimsy.udel.edu +30 -26
+    [Bug 685] use updated autogen-erated files
+
+  ntpd/ntpdsim-opts.texi@1.7, 2006-08-17 01:29:06-04:00, stenn@whimsy.udel.edu +16 -1
+    [Bug 685] use updated autogen-erated files
+
+  ntpd/ntpdsim.1@1.7, 2006-08-17 01:29:07-04:00, stenn@whimsy.udel.edu +7 -2
+    [Bug 685] use updated autogen-erated files
+
+ChangeSet@1.1353.9.35, 2006-08-17 01:27:04-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 685] cleanup
+
+  ntpd/cmd_args.c@1.43, 2006-08-17 01:24:44-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 685] Fix a typo - WINNT -> SYS_WINNT
+
+  ntpd/ntpdbase-opts.def@1.8, 2006-08-17 01:25:41-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 685] -M should only accepted if SYS_WINNT is #defined
+
+ChangeSet@1.1353.17.1, 2006-08-17 00:52:10-04:00, stenn@whimsy.udel.edu +24 -0
+  run autogen after point release
+
+  ntpd/ntpd-opts.c@1.6, 2006-08-17 00:51:23-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  ntpd/ntpd-opts.h@1.6, 2006-08-17 00:51:23-04:00, stenn@whimsy.udel.edu +3 -3
+    run autogen after point release
+
+  ntpd/ntpd-opts.texi@1.7, 2006-08-17 00:51:24-04:00, stenn@whimsy.udel.edu +1 -1
+    run autogen after point release
+
+  ntpd/ntpd.1@1.6, 2006-08-17 00:51:24-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  ntpd/ntpdsim-opts.c@1.6, 2006-08-17 00:51:25-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  ntpd/ntpdsim-opts.h@1.6, 2006-08-17 00:51:26-04:00, stenn@whimsy.udel.edu +3 -3
+    run autogen after point release
+
+  ntpd/ntpdsim-opts.texi@1.6, 2006-08-17 00:51:27-04:00, stenn@whimsy.udel.edu +1 -1
+    run autogen after point release
+
+  ntpd/ntpdsim.1@1.6, 2006-08-17 00:51:28-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  ntpdc/ntpdc-opts.c@1.7, 2006-08-17 00:51:29-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  ntpdc/ntpdc-opts.h@1.7, 2006-08-17 00:51:29-04:00, stenn@whimsy.udel.edu +3 -3
+    run autogen after point release
+
+  ntpdc/ntpdc-opts.texi@1.7, 2006-08-17 00:51:30-04:00, stenn@whimsy.udel.edu +1 -1
+    run autogen after point release
+
+  ntpdc/ntpdc.1@1.7, 2006-08-17 00:51:30-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  ntpq/ntpq-opts.c@1.6, 2006-08-17 00:51:32-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  ntpq/ntpq-opts.h@1.6, 2006-08-17 00:51:33-04:00, stenn@whimsy.udel.edu +3 -3
+    run autogen after point release
+
+  ntpq/ntpq-opts.texi@1.6, 2006-08-17 00:51:33-04:00, stenn@whimsy.udel.edu +1 -1
+    run autogen after point release
+
+  ntpq/ntpq.1@1.6, 2006-08-17 00:51:34-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  sntp/sntp-opts.c@1.6, 2006-08-17 00:51:35-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  sntp/sntp-opts.h@1.6, 2006-08-17 00:51:35-04:00, stenn@whimsy.udel.edu +3 -3
+    run autogen after point release
+
+  sntp/sntp-opts.texi@1.6, 2006-08-17 00:51:36-04:00, stenn@whimsy.udel.edu +1 -1
+    run autogen after point release
+
+  sntp/sntp.1@1.9, 2006-08-17 00:51:37-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  util/ntp-keygen-opts.c@1.6, 2006-08-17 00:51:38-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+  util/ntp-keygen-opts.h@1.6, 2006-08-17 00:51:39-04:00, stenn@whimsy.udel.edu +3 -3
+    run autogen after point release
+
+  util/ntp-keygen-opts.texi@1.6, 2006-08-17 00:51:39-04:00, stenn@whimsy.udel.edu +1 -1
+    run autogen after point release
+
+  util/ntp-keygen.1@1.6, 2006-08-17 00:51:41-04:00, stenn@whimsy.udel.edu +2 -2
+    run autogen after point release
+
+ChangeSet@1.1353.16.2, 2006-08-15 13:14:03-04:00, mayer@pogo.udel.edu +4 -0
+  Bug #685 and #686: MM timer enhancements and leapsecond fixes
+
+  ntpd/cmd_args.c@1.42, 2006-08-15 13:12:21-04:00, mayer@pogo.udel.edu +8 -0
+    Bug #685: MM timer enhancement for Windows
+
+  ntpd/ntpdbase-opts.def@1.5.1.1, 2006-08-15 13:12:23-04:00, mayer@pogo.udel.edu +9 -0
+    Bug #685: MM timer enhancement for Windows
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.20, 2006-08-15 13:08:20-04:00, mayer@pogo.udel.edu +199 -38
+    Bug #685 and #686: MM timer fixes and leapsecond fixes
+
+  ports/winnt/ntpd/ntservice.c@1.6.1.1, 2006-08-15 13:08:20-04:00, mayer@pogo.udel.edu +13 -12
+    Bug #685 and #686: MM timer fixes and leapsecond fixes
+
+ChangeSet@1.1353.16.1, 2006-08-15 13:04:10-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #523: exit() was being overridden
+
+  include/ntpd.h@1.94, 2006-08-15 13:03:42-04:00, mayer@pogo.udel.edu +0 -2
+    Bug #523: exit() was being overridden
+
+ChangeSet@1.1353.9.32, 2006-08-15 08:10:21-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P31
+  TAG: NTP_4_2_3P31
+
+  packageinfo.sh@1.25, 2006-08-15 08:10:19-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P31
+
+ChangeSet@1.1251.94.50, 2006-08-15 07:02:21-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P4_RC1
+  TAG: NTP_4_2_2P4_RC1
+
+  packageinfo.sh@1.27.17.1, 2006-08-15 07:02:17-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_2P4_RC1
+
+ChangeSet@1.1251.94.49, 2006-08-15 06:09:54-04:00, stenn@whimsy.udel.edu +1 -0
+  Save the list of files that change if the point-level is updated
+
+  .point-changed-filelist@1.1, 2006-08-15 06:09:46-04:00, stenn@whimsy.udel.edu +1 -0
+    BitKeeper file /deacon/backroom/ntp-stable/.point-changed-filelist
+
+  .point-changed-filelist@1.0, 2006-08-15 06:09:46-04:00, stenn@whimsy.udel.edu +0 -0
+
+ChangeSet@1.1353.9.30, 2006-08-15 06:08:03-04:00, stenn@whimsy.udel.edu +1 -0
+  Save the list of files that change if the point-level is updated
+
+  .point-changed-filelist@1.1, 2006-08-15 06:04:15-04:00, stenn@whimsy.udel.edu +25 -0
+    BitKeeper file /deacon/backroom/ntp-dev/.point-changed-filelist
+
+  .point-changed-filelist@1.0, 2006-08-15 06:04:15-04:00, stenn@whimsy.udel.edu +0 -0
+
+ChangeSet@1.1353.9.29, 2006-08-15 05:53:43-04:00, stenn@whimsy.udel.edu +26 -0
+  [Bug 684] debug command-line options should not be shown if #undef DEBUG
+
+  include/debug-opt.def@1.4, 2006-08-15 05:45:38-04:00, stenn@whimsy.udel.edu +2 -0
+    [Bug 684] debug command-line options should not be shown if #undef DEBUG
+
+  ntpd/ntpd-opts.c@1.5, 2006-08-15 05:52:24-04:00, stenn@whimsy.udel.edu +29 -4
+    regenerate autogen-erated files
+
+  ntpd/ntpd-opts.h@1.5, 2006-08-15 05:52:25-04:00, stenn@whimsy.udel.edu +7 -3
+    regenerate autogen-erated files
+
+  ntpd/ntpd-opts.texi@1.6, 2006-08-15 05:52:26-04:00, stenn@whimsy.udel.edu +5 -1
+    regenerate autogen-erated files
+
+  ntpd/ntpd.1@1.5, 2006-08-15 05:52:27-04:00, stenn@whimsy.udel.edu +2 -2
+    regenerate autogen-erated files
+
+  ntpd/ntpdbase-opts.def@1.6, 2006-08-15 05:48:12-04:00, stenn@whimsy.udel.edu +1 -0
+    Make sure we are using the right version of autogen
+
+  ntpd/ntpdsim-opts.c@1.5, 2006-08-15 05:52:28-04:00, stenn@whimsy.udel.edu +29 -4
+    regenerate autogen-erated files
+
+  ntpd/ntpdsim-opts.h@1.5, 2006-08-15 05:52:29-04:00, stenn@whimsy.udel.edu +7 -3
+    regenerate autogen-erated files
+
+  ntpd/ntpdsim-opts.texi@1.5, 2006-08-15 05:52:29-04:00, stenn@whimsy.udel.edu +5 -1
+    regenerate autogen-erated files
+
+  ntpd/ntpdsim.1@1.5, 2006-08-15 05:52:30-04:00, stenn@whimsy.udel.edu +2 -2
+    regenerate autogen-erated files
+
+  ntpdc/ntpdc-opts.c@1.6, 2006-08-15 05:52:31-04:00, stenn@whimsy.udel.edu +29 -4
+    regenerate autogen-erated files
+
+  ntpdc/ntpdc-opts.h@1.6, 2006-08-15 05:52:31-04:00, stenn@whimsy.udel.edu +7 -3
+    regenerate autogen-erated files
+
+  ntpdc/ntpdc-opts.texi@1.6, 2006-08-15 05:52:32-04:00, stenn@whimsy.udel.edu +5 -1
+    regenerate autogen-erated files
+
+  ntpdc/ntpdc.1@1.6, 2006-08-15 05:52:34-04:00, stenn@whimsy.udel.edu +2 -2
+    regenerate autogen-erated files
+
+  ntpq/ntpq-opts.c@1.5, 2006-08-15 05:52:34-04:00, stenn@whimsy.udel.edu +29 -4
+    regenerate autogen-erated files
+
+  ntpq/ntpq-opts.h@1.5, 2006-08-15 05:52:35-04:00, stenn@whimsy.udel.edu +7 -3
+    regenerate autogen-erated files
+
+  ntpq/ntpq-opts.texi@1.5, 2006-08-15 05:52:36-04:00, stenn@whimsy.udel.edu +5 -1
+    regenerate autogen-erated files
+
+  ntpq/ntpq.1@1.5, 2006-08-15 05:52:36-04:00, stenn@whimsy.udel.edu +2 -2
+    regenerate autogen-erated files
+
+  sntp/sntp-opts.c@1.5, 2006-08-15 05:52:37-04:00, stenn@whimsy.udel.edu +2 -2
+    regenerate autogen-erated files
+
+  sntp/sntp-opts.h@1.5, 2006-08-15 05:52:38-04:00, stenn@whimsy.udel.edu +3 -3
+    regenerate autogen-erated files
+
+  sntp/sntp-opts.texi@1.5, 2006-08-15 05:52:38-04:00, stenn@whimsy.udel.edu +1 -1
+    regenerate autogen-erated files
+
+  sntp/sntp.1@1.8, 2006-08-15 05:52:39-04:00, stenn@whimsy.udel.edu +2 -2
+    regenerate autogen-erated files
+
+  util/ntp-keygen-opts.c@1.5, 2006-08-15 05:52:40-04:00, stenn@whimsy.udel.edu +29 -4
+    regenerate autogen-erated files
+
+  util/ntp-keygen-opts.h@1.5, 2006-08-15 05:52:40-04:00, stenn@whimsy.udel.edu +7 -3
+    regenerate autogen-erated files
+
+  util/ntp-keygen-opts.texi@1.5, 2006-08-15 05:52:41-04:00, stenn@whimsy.udel.edu +5 -1
+    regenerate autogen-erated files
+
+  util/ntp-keygen.1@1.5, 2006-08-15 05:52:42-04:00, stenn@whimsy.udel.edu +2 -2
+    regenerate autogen-erated files
+
+ChangeSet@1.1353.9.28, 2006-08-15 05:40:34-04:00, stenn@whimsy.udel.edu +1 -0
+  test -r seems more portable than test -e
+
+  sntp/Makefile.am@1.18, 2006-08-15 05:40:22-04:00, stenn@whimsy.udel.edu +1 -1
+    test -r seems more portable than test -e
+
+ChangeSet@1.1353.9.27, 2006-08-15 05:08:00-04:00, stenn@whimsy.udel.edu +1 -0
+  Make sure we use the right version of autogen
+
+  include/autogen-version.def@1.1, 2006-08-15 05:07:11-04:00, stenn@whimsy.udel.edu +1 -0
+    BitKeeper file /deacon/backroom/ntp-dev/include/autogen-version.def
+
+  include/autogen-version.def@1.0, 2006-08-15 05:07:11-04:00, stenn@whimsy.udel.edu +0 -0
+
+ChangeSet@1.1353.9.26, 2006-08-11 07:04:21-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P30
+  TAG: NTP_4_2_3P30
+
+  packageinfo.sh@1.24, 2006-08-11 07:04:18-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P30
+
+ChangeSet@1.1353.15.9, 2006-08-10 21:41:32-04:00, stenn@whimsy.udel.edu +24 -0
+  NTP_4_2_3P29
+
+  ntpd/ntpd-opts.c@1.4, 2006-08-10 21:40:58-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P29
+
+  ntpd/ntpd-opts.h@1.4, 2006-08-10 21:40:58-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P29
+
+  ntpd/ntpd-opts.texi@1.5, 2006-08-10 21:40:59-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P29
+
+  ntpd/ntpd.1@1.4, 2006-08-10 21:40:59-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P29
+
+  ntpd/ntpdsim-opts.c@1.4, 2006-08-10 21:41:00-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P29
+
+  ntpd/ntpdsim-opts.h@1.4, 2006-08-10 21:41:01-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P29
+
+  ntpd/ntpdsim-opts.texi@1.4, 2006-08-10 21:41:01-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P29
+
+  ntpd/ntpdsim.1@1.4, 2006-08-10 21:41:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P29
+
+  ntpdc/ntpdc-opts.c@1.5, 2006-08-10 21:41:02-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P29
+
+  ntpdc/ntpdc-opts.h@1.5, 2006-08-10 21:41:03-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P29
+
+  ntpdc/ntpdc-opts.texi@1.5, 2006-08-10 21:41:04-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P29
+
+  ntpdc/ntpdc.1@1.5, 2006-08-10 21:41:05-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P29
+
+  ntpq/ntpq-opts.c@1.4, 2006-08-10 21:41:06-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P29
+
+  ntpq/ntpq-opts.h@1.4, 2006-08-10 21:41:07-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P29
+
+  ntpq/ntpq-opts.texi@1.4, 2006-08-10 21:41:08-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P29
+
+  ntpq/ntpq.1@1.4, 2006-08-10 21:41:09-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P29
+
+  sntp/sntp-opts.c@1.4, 2006-08-10 21:41:09-04:00, stenn@whimsy.udel.edu +140 -4
+    NTP_4_2_3P29
+
+  sntp/sntp-opts.h@1.4, 2006-08-10 21:41:10-04:00, stenn@whimsy.udel.edu +83 -4
+    NTP_4_2_3P29
+
+  sntp/sntp-opts.texi@1.4, 2006-08-10 21:41:11-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P29
+
+  sntp/sntp.1@1.7, 2006-08-10 21:41:11-04:00, stenn@whimsy.udel.edu +82 -3
+    NTP_4_2_3P29
+
+  util/ntp-keygen-opts.c@1.4, 2006-08-10 21:41:12-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P29
+
+  util/ntp-keygen-opts.h@1.4, 2006-08-10 21:41:12-04:00, stenn@whimsy.udel.edu +3 -3
+    NTP_4_2_3P29
+
+  util/ntp-keygen-opts.texi@1.4, 2006-08-10 21:41:13-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P29
+
+  util/ntp-keygen.1@1.4, 2006-08-10 21:41:14-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_3P29
+
+ChangeSet@1.1251.94.48, 2006-08-10 20:37:44-04:00, stenn@whimsy.udel.edu +1 -0
+  Choose csets-{in,out} based on daemon/client
+
+  BitKeeper/triggers/send@1.11.1.1, 2006-08-10 20:37:23-04:00, stenn@whimsy.udel.edu +3 -1
+    Choose csets-{in,out} based on daemon/client
+
+ChangeSet@1.1353.15.8, 2006-08-10 20:34:50-04:00, stenn@whimsy.udel.edu +1 -0
+  Choose csets-{in,out} based on daemon/client
+
+  BitKeeper/triggers/send@1.12, 2006-08-10 20:34:36-04:00, stenn@whimsy.udel.edu +3 -1
+    Choose csets-{in,out} based on daemon/client
+
+ChangeSet@1.1353.15.7, 2006-08-10 20:29:08-04:00, stenn@whimsy.udel.edu +2 -0
+  cleanup
+
+  sntp/Makefile.am@1.17, 2006-08-10 20:28:24-04:00, stenn@whimsy.udel.edu +2 -1
+    use a run-ag that is for the sntp subdir
+
+  sntp/sntp-opts.def@1.8, 2006-08-10 20:28:51-04:00, stenn@whimsy.udel.edu +1 -1
+    Fix a typo in sntp-opts.def
+
+ChangeSet@1.1353.15.6, 2006-08-10 20:06:04-04:00, stenn@whimsy.udel.edu +1 -0
+  fix permissions on sntp-opts.menu
+
+  sntp/sntp-opts.menu@1.2, 2006-08-10 18:08:02-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+ChangeSet@1.1353.15.5, 2006-08-10 17:45:44-04:00, stenn@whimsy.udel.edu +1 -0
+  Maintain sntp/version.def more quietly
+
+  sntp/Makefile.am@1.16, 2006-08-10 17:45:32-04:00, stenn@whimsy.udel.edu +2 -1
+    Maintain sntp/version.def more quietly
+
+ChangeSet@1.1353.15.4, 2006-08-10 17:24:38-04:00, stenn@whimsy.udel.edu +1 -0
+  Use the new name of the sntp/COPYRIGHT file
+
+  sntp/sntp-opts.def@1.7, 2006-08-10 17:24:13-04:00, stenn@whimsy.udel.edu +1 -1
+    Use the new name of the sntp/COPYRIGHT file
+
+ChangeSet@1.1353.15.3, 2006-08-10 16:53:20-04:00, stenn@whimsy.udel.edu +6 -0
+  [Bug 683] fix version number string mismatches
+
+  ntpd/Makefile.am@1.49, 2006-08-10 16:52:04-04:00, stenn@whimsy.udel.edu +9 -6
+    [Bug 683] fix version number string mismatches
+
+  ntpdc/Makefile.am@1.31, 2006-08-10 16:52:04-04:00, stenn@whimsy.udel.edu +6 -3
+    [Bug 683] fix version number string mismatches
+
+  ntpq/Makefile.am@1.23, 2006-08-10 16:52:05-04:00, stenn@whimsy.udel.edu +6 -3
+    [Bug 683] fix version number string mismatches
+
+  sntp/Makefile.am@1.15, 2006-08-10 16:52:05-04:00, stenn@whimsy.udel.edu +15 -4
+    [Bug 683] fix version number string mismatches
+
+  sntp/sntp-opts.def@1.6, 2006-08-10 16:52:44-04:00, stenn@whimsy.udel.edu +2 -5
+    [Bug 683] fix version number string mismatches
+
+  util/Makefile.am@1.32, 2006-08-10 16:52:06-04:00, stenn@whimsy.udel.edu +6 -3
+    [Bug 683] fix version number string mismatches
+
+ChangeSet@1.1353.15.2, 2006-08-10 16:45:30-04:00, stenn@whimsy.udel.edu +1 -0
+  Rename sntp/Copyright to sntp/COPYRIGHT
+
+  sntp/COPYRIGHT@1.2, 2006-08-10 16:29:50-04:00, stenn@whimsy.udel.edu +0 -0
+    Rename: sntp/Copyright -> sntp/COPYRIGHT
+
+ChangeSet@1.1353.15.1, 2006-08-10 07:03:21-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P29
+  TAG: NTP_4_2_3P29
+
+  packageinfo.sh@1.23, 2006-08-10 07:03:19-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P29
+
+ChangeSet@1.1353.14.1, 2006-08-10 09:40:07+00:00, burnicki@pogo.udel.edu +1 -0
+  Changes by Heiko <heiko.gerstung@meinberg.de>:
+  Fixed point/rcpoint handling which resulted in wrong version strings.
+
+  ports/winnt/scripts/mkver.bat@1.9, 2006-08-10 09:40:04+00:00, burnicki@pogo.udel.edu +32 -4
+    Changes by Heiko <heiko.gerstung@meinberg.de>:
+    Fixed point/rcpoint handling which resulted in wrong version strings.
+
+ChangeSet@1.1353.9.23, 2006-08-10 08:40:06+00:00, burnicki@pogo.udel.edu +2 -0
+  Exclude debug features if building without debug.
+  Removed obsolete prototype for ntpd_usage().
+
+  include/ntp_cmdargs.h@1.4, 2006-08-10 08:40:04+00:00, burnicki@pogo.udel.edu +0 -1
+    Removed ntpd_usage() prototype which is obsolete.
+
+  ports/winnt/ntpd/ntservice.c@1.7, 2006-08-10 08:40:04+00:00, burnicki@pogo.udel.edu +2 -0
+    Exclude debug features if building without debug.
+
+ChangeSet@1.1353.13.3, 2006-08-10 01:02:20-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 659] Get the latest windows patches for libopts
+
+  libopts/compat/compat.h@1.6, 2006-08-10 01:02:08-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 659] Get the latest windows patches for libopts
+
+ChangeSet@1.1353.13.2, 2006-08-10 00:57:53-04:00, stenn@whimsy.udel.edu +3 -0
+  [Bug 659] Get the latest windows patches for libopts
+
+  libopts/m4/libopts.m4@1.6, 2006-08-10 00:57:33-04:00, stenn@whimsy.udel.edu +2 -1
+    [Bug 659] Get the latest windows patches for liboptslibopts/compat/compat.h
+
+  sntp/libopts/compat/compat.h@1.5, 2006-08-10 00:57:34-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 659] Get the latest windows patches for liboptslibopts/compat/compat.h
+
+  sntp/libopts/m4/libopts.m4@1.6, 2006-08-10 00:57:35-04:00, stenn@whimsy.udel.edu +2 -1
+    [Bug 659] Get the latest windows patches for liboptslibopts/compat/compat.h
+
+ChangeSet@1.1353.13.1, 2006-08-10 00:53:59-04:00, stenn@whimsy.udel.edu +1 -0
+  Replace the #ifdef DEBUG that got undone by Danny's recent patch
+
+  ntpd/ntp_io.c@1.234.1.3, 2006-08-10 00:53:37-04:00, stenn@whimsy.udel.edu +5 -1
+    Replace the #ifdef DEBUG that got undone by Danny's recent patch
+
+ChangeSet@1.1353.12.1, 2006-08-09 21:57:02-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #659: to allow --help through and not start services
+
+  ports/winnt/ntpd/ntservice.c@1.6, 2006-08-09 21:56:29-04:00, mayer@pogo.udel.edu +2 -2
+    Bug #659: to allow --help through and not start services
+
+ChangeSet@1.1353.9.19, 2006-08-09 18:28:43-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 682] add --disable-debugging to the test build mix
+
+  build@1.23, 2006-08-09 18:28:30-04:00, stenn@whimsy.udel.edu +6 -0
+    [Bug 682] add --disable-debugging to the test build mix
+
+  flock-build@1.37, 2006-08-09 18:28:31-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 682] add --disable-debugging to the test build mix
+
+ChangeSet@1.1251.94.47, 2006-08-09 18:24:30-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 682] add --disable-debugging to the test build mix
+
+  build@1.21.1.1, 2006-08-09 18:24:18-04:00, stenn@whimsy.udel.edu +6 -0
+    [Bug 682] add --disable-debugging to the test build mix
+
+  flock-build@1.35.1.1, 2006-08-09 18:24:19-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 682] add --disable-debugging to the test build mix
+
+ChangeSet@1.1353.9.18, 2006-08-09 07:02:54-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P28
+  TAG: NTP_4_2_3P28
+
+  packageinfo.sh@1.22, 2006-08-09 07:02:52-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P28
+
+ChangeSet@1.1353.9.17, 2006-08-08 22:38:19-04:00, mayer@pogo.udel.edu +2 -0
+  bug #671: setsockopt needs macro for Windows
+
+  ntpd/ntp_io.c@1.234.1.2, 2006-08-08 22:37:40-04:00, mayer@pogo.udel.edu +11 -6
+    bug #671: setsockopt needs macro for Windows
+
+  ports/winnt/include/config.h@1.42, 2006-08-08 22:37:40-04:00, mayer@pogo.udel.edu +1 -0
+    bug #671: setsockopt needs macro for Windows
+
+ChangeSet@1.1353.11.1, 2006-08-08 11:32:15-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #659: New include file for windows for handling file stat
+
+  ports/winnt/include/isc/stat.h@1.1, 2006-08-08 11:31:23-04:00, mayer@pogo.udel.edu +66 -0
+    BitKeeper file /pogo/users/mayer/ntp-dev/ports/winnt/include/isc/stat.h
+
+  ports/winnt/include/isc/stat.h@1.0, 2006-08-08 11:31:23-04:00, mayer@pogo.udel.edu +0 -0
+
+ChangeSet@1.1353.9.15, 2006-08-08 07:03:46-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P27
+  TAG: NTP_4_2_3P27
+
+  packageinfo.sh@1.21, 2006-08-08 07:03:43-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P27
+
+ChangeSet@1.1353.9.14, 2006-08-08 04:12:04-04:00, stenn@whimsy.udel.edu +7 -0
+  [Bug 675]: Make sure we build even when we --disable-debugging
+
+  ntpd/ntp_intres.c@1.48, 2006-08-08 04:11:04-04:00, stenn@whimsy.udel.edu +4 -0
+    [Bug 675]: Make sure we build even when we --disable-debugging
+
+  ntpd/ntp_io.c@1.234.1.1, 2006-08-08 04:11:05-04:00, stenn@whimsy.udel.edu +5 -1
+    [Bug 675]: Make sure we build even when we --disable-debugging
+
+  ntpd/refclock_jupiter.c@1.20, 2006-08-08 04:11:07-04:00, stenn@whimsy.udel.edu +2 -0
+    [Bug 675]: Make sure we build even when we --disable-debugging
+
+  ntpd/refclock_leitch.c@1.8, 2006-08-08 04:11:09-04:00, stenn@whimsy.udel.edu +11 -5
+    [Bug 675]: Make sure we build even when we --disable-debugging
+
+  ntpd/refclock_msfees.c@1.12, 2006-08-08 04:11:09-04:00, stenn@whimsy.udel.edu +28 -27
+    [Bug 675]: Make sure we build even when we --disable-debugging
+
+  ntpd/refclock_mx4200.c@1.22, 2006-08-08 04:11:10-04:00, stenn@whimsy.udel.edu +2 -0
+    [Bug 675]: Make sure we build even when we --disable-debugging
+
+  ntpd/refclock_oncore.c@1.60, 2006-08-08 04:11:11-04:00, stenn@whimsy.udel.edu +34 -10
+    [Bug 675]: Make sure we build even when we --disable-debugging
+
+ChangeSet@1.1353.9.13, 2006-08-07 18:41:58-04:00, stenn@whimsy.udel.edu +2 -0
+  Fix #include <sys/mman.h> breakage
+
+  libopts/compat/compat.h@1.5, 2006-08-07 18:41:15-04:00, stenn@whimsy.udel.edu +3 -1
+    Fix sys/mman.h breakage
+
+  sntp/libopts/compat/compat.h@1.4, 2006-08-07 18:41:15-04:00, stenn@whimsy.udel.edu +3 -1
+    Fix sys/mman.h breakage
+
+ChangeSet@1.1353.9.12, 2006-08-07 09:32:49-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #659 mman.h not always available
+
+  libopts/compat/compat.h@1.4, 2006-08-07 09:32:42-04:00, mayer@pogo.udel.edu +2 -2
+    Bug #659 mman.h not always available
+
+ChangeSet@1.1353.9.11, 2006-08-07 08:51:39-04:00, mayer@pogo.udel.edu +6 -0
+  bug #659: Changes to support libopts on Windows
+
+  ports/winnt/include/config.h@1.41, 2006-08-07 08:42:01-04:00, mayer@pogo.udel.edu +36 -1
+    bug #659: Changes to support libopts on Windows
+
+  ports/winnt/libntp/libntp.dsp@1.30, 2006-08-07 08:42:01-04:00, mayer@pogo.udel.edu +6 -2
+    bug #659: Changes to support libopts on Windows
+
+  ports/winnt/ntp-keygen/ntpkeygen.dsp@1.11, 2006-08-07 08:42:01-04:00, mayer@pogo.udel.edu +8 -4
+    bug #659: Changes to support libopts on Windows
+
+  ports/winnt/ntpd/ntpd.dsp@1.28, 2006-08-07 08:42:01-04:00, mayer@pogo.udel.edu +6 -2
+    bug #659: Changes to support libopts on Windows
+
+  ports/winnt/ntpdc/ntpdc.dsp@1.18, 2006-08-07 08:42:01-04:00, mayer@pogo.udel.edu +6 -2
+    bug #659: Changes to support libopts on Windows
+
+  ports/winnt/ntpq/ntpq.dsp@1.19, 2006-08-07 08:42:01-04:00, mayer@pogo.udel.edu +8 -4
+    bug #659: Changes to support libopts on Windows
+
+ChangeSet@1.1353.9.10, 2006-08-06 07:03:05-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P26
+  TAG: NTP_4_2_3P26
+
+  packageinfo.sh@1.20, 2006-08-06 07:03:02-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P26
+
+ChangeSet@1.1353.9.9, 2006-08-05 21:31:02-04:00, stenn@whimsy.udel.edu +1 -0
+  NEWS: Support separate PPS devices for PARSE refclocks
+
+  NEWS@1.58, 2006-08-05 21:30:52-04:00, stenn@whimsy.udel.edu +1 -0
+    NEWS: Support separate PPS devices for PARSE refclocks
+
+ChangeSet@1.1251.94.46, 2006-08-05 15:44:40-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P3
+  TAG: NTP_4_2_2P3
+
+  packageinfo.sh@1.27.16.1, 2006-08-05 15:44:38-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_2P3
+
+ChangeSet@1.1353.10.1, 2006-08-05 07:05:02-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P25
+  TAG: NTP_4_2_3P25
+
+  packageinfo.sh@1.19, 2006-08-05 07:04:56-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P25
+
+ChangeSet@1.1353.9.7, 2006-08-05 09:01:42+00:00, kardel@pogo.udel.edu +2 -0
+  driver8.html:
+    document additional Meinberg clock mode
+    document optionally separate PPS device (/dev/refclockpps-{0..3})
+  refclock_parse.c:
+    support optionally separate PPS devices via /dev/refclockpps-{0..3}
+
+  html/drivers/driver8.html@1.19, 2006-08-05 08:59:00+00:00, kardel@pogo.udel.edu +12 -9
+    document additional Meinberg clock mode
+    document optionally separate PPS device (/dev/refclockpps-{0..3})
+
+  ntpd/refclock_parse.c@1.46, 2006-08-05 08:58:19+00:00, kardel@pogo.udel.edu +57 -29
+    support optionally separate PPS devices via /dev/refclockpps-{0..3}
+
+ChangeSet@1.1353.9.6, 2006-08-05 02:10:36-04:00, stenn@whimsy.udel.edu +2 -0
+  Fixes from Dave.
+
+  ntpd/ntp_loopfilter.c@1.124, 2006-08-05 02:10:29-04:00, stenn@whimsy.udel.edu +22 -22
+    Dave sez:
+    
+    At cold start (no frequency file) the daemon sets the clock at the
+    first update, then waits 15 minutes, measures and corrects the
+    frequency (usually within 1 PPM) and assumes normal operation. This
+    saves many hours to converge the frequency within 1 PPM, especially
+    if the intrinsic frequency error is large, like 200 PPM.
+    
+    Until the frequency is corrected, the machine can have serious
+    offset and frequency errors that would drive dependent clients nuts.
+    Up to now, the leap bits and stratum were not initialized until the
+    frequency was corrected. However, the clock was set and local clients
+    were free to believe or not believe the clock. After review, the
+    external behavior is only mildly worse than without the initial
+    training period, so the leap bits and stratum are now set at the
+    first update. The billboards should now be consistent with the
+    Principle of Least Astonishment.
+
+  ntpd/ntp_proto.c@1.246, 2006-08-05 02:10:31-04:00, stenn@whimsy.udel.edu +19 -15
+    Dave sez:
+    
+    At cold start (no frequency file) the daemon sets the clock at the
+    first update, then waits 15 minutes, measures and corrects the
+    frequency (usually within 1 PPM) and assumes normal operation. This
+    saves many hours to converge the frequency within 1 PPM, especially
+    if the intrinsic frequency error is large, like 200 PPM.
+    
+    Until the frequency is corrected, the machine can have serious
+    offset and frequency errors that would drive dependent clients nuts.
+    Up to now, the leap bits and stratum were not initialized until the
+    frequency was corrected. However, the clock was set and local clients
+    were free to believe or not believe the clock. After review, the
+    external behavior is only mildly worse than without the initial
+    training period, so the leap bits and stratum are now set at the
+    first update. The billboards should now be consistent with the
+    Principle of Least Astonishment.
+
+ChangeSet@1.1353.9.5, 2006-08-05 01:27:50-04:00, stenn@whimsy.udel.edu +2 -0
+  Added uint_t check to libopts.m4
+
+  libopts/m4/libopts.m4@1.5, 2006-08-05 01:27:37-04:00, stenn@whimsy.udel.edu +1 -1
+    Added uint_t check to libopts.m4
+
+  sntp/libopts/m4/libopts.m4@1.5, 2006-08-05 01:27:38-04:00, stenn@whimsy.udel.edu +1 -1
+    Added uint_t check to libopts.m4
+
+ChangeSet@1.1251.94.45, 2006-08-05 00:52:33-04:00, stenn@whimsy.udel.edu +1 -0
+  Use the new format for the "send" emails
+
+  BitKeeper/triggers/send@1.11, 2006-08-05 00:52:03-04:00, stenn@whimsy.udel.edu +1 -4
+    Use the new format for the "send" emails
+
+ChangeSet@1.1353.9.3, 2006-08-05 00:38:57-04:00, stenn@whimsy.udel.edu +1 -0
+  copy new packageinfo from -stable
+
+  packageinfo.sh@1.18, 2006-08-05 00:38:34-04:00, stenn@whimsy.udel.edu +4 -3
+    copy new packageinfo from -stable
+
+ChangeSet@1.1251.94.44, 2006-08-04 21:46:01-04:00, stenn@whimsy.udel.edu +2 -0
+  ready for release
+
+  packageinfo.sh@1.27.15.2, 2006-08-04 21:45:50-04:00, stenn@whimsy.udel.edu +6 -6
+    ready for release
+
+  scripts/genChangeLog@1.2, 2006-08-04 16:18:47-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rwxrwxr-x
+
+ChangeSet@1.1251.94.43, 2006-08-04 16:00:28-04:00, stenn@whimsy.udel.edu +3 -0
+  Clean up the ChangeLog generation
+
+  Makefile.am@1.48.1.7, 2006-08-04 15:59:20-04:00, stenn@whimsy.udel.edu +3 -5
+    Clean up the ChangeLog generation
+
+  scripts/Makefile.am@1.14, 2006-08-04 15:59:21-04:00, stenn@whimsy.udel.edu +3 -2
+    Clean up the ChangeLog generation
+
+  scripts/genChangeLog@1.1, 2006-08-04 15:39:21-04:00, stenn@whimsy.udel.edu +7 -0
+    BitKeeper file /deacon/backroom/ntp-stable/scripts/genChangeLog
+
+  scripts/genChangeLog@1.0, 2006-08-04 15:39:21-04:00, stenn@whimsy.udel.edu +0 -0
+
+ChangeSet@1.1353.9.1, 2006-08-03 07:03:51-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P24
+  TAG: NTP_4_2_3P24
+
+  packageinfo.sh@1.17, 2006-08-03 07:03:48-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P24
+
+ChangeSet@1.1353.1.96, 2006-08-02 20:21:23-04:00, stenn@whimsy.udel.edu +24 -0
+  autogen upgrade
+
+  ntpd/ntpd-opts.c@1.3, 2006-08-02 20:20:38-04:00, stenn@whimsy.udel.edu +37 -15
+    autogen upgrade
+
+  ntpd/ntpd-opts.c@1.2, 2006-08-02 19:36:53-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpd/ntpd-opts.h@1.3, 2006-08-02 20:20:40-04:00, stenn@whimsy.udel.edu +21 -10
+    autogen upgrade
+
+  ntpd/ntpd-opts.h@1.2, 2006-08-02 19:36:54-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpd/ntpd-opts.texi@1.4, 2006-08-02 20:20:40-04:00, stenn@whimsy.udel.edu +1 -1
+    autogen upgrade
+
+  ntpd/ntpd-opts.texi@1.3, 2006-08-02 19:36:56-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpd/ntpd.1@1.3, 2006-08-02 20:20:41-04:00, stenn@whimsy.udel.edu +33 -33
+    autogen upgrade
+
+  ntpd/ntpd.1@1.2, 2006-08-02 19:36:57-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpd/ntpdsim-opts.c@1.3, 2006-08-02 20:20:42-04:00, stenn@whimsy.udel.edu +37 -15
+    autogen upgrade
+
+  ntpd/ntpdsim-opts.c@1.2, 2006-08-02 19:36:58-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpd/ntpdsim-opts.h@1.3, 2006-08-02 20:20:43-04:00, stenn@whimsy.udel.edu +21 -10
+    autogen upgrade
+
+  ntpd/ntpdsim-opts.h@1.2, 2006-08-02 19:37:00-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpd/ntpdsim-opts.texi@1.3, 2006-08-02 20:20:44-04:00, stenn@whimsy.udel.edu +4 -4
+    autogen upgrade
+
+  ntpd/ntpdsim-opts.texi@1.2, 2006-08-02 19:37:02-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpd/ntpdsim.1@1.3, 2006-08-02 20:20:45-04:00, stenn@whimsy.udel.edu +42 -42
+    autogen upgrade
+
+  ntpd/ntpdsim.1@1.2, 2006-08-02 19:37:04-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpdc/ntpdc-opts.c@1.4, 2006-08-02 20:20:46-04:00, stenn@whimsy.udel.edu +2 -4
+    autogen upgrade
+
+  ntpdc/ntpdc-opts.c@1.3, 2006-08-02 19:37:06-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpdc/ntpdc-opts.h@1.4, 2006-08-02 20:20:47-04:00, stenn@whimsy.udel.edu +5 -4
+    autogen upgrade
+
+  ntpdc/ntpdc-opts.h@1.3, 2006-08-02 19:37:07-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpdc/ntpdc-opts.texi@1.4, 2006-08-02 20:20:47-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  ntpdc/ntpdc-opts.texi@1.3, 2006-08-02 19:37:09-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpdc/ntpdc.1@1.4, 2006-08-02 20:20:48-04:00, stenn@whimsy.udel.edu +2 -2
+    autogen upgrade
+
+  ntpdc/ntpdc.1@1.3, 2006-08-02 19:37:10-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpq/ntpq-opts.c@1.3, 2006-08-02 20:20:48-04:00, stenn@whimsy.udel.edu +38 -250
+    autogen upgrade
+
+  ntpq/ntpq-opts.c@1.2, 2006-08-02 19:37:12-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpq/ntpq-opts.h@1.3, 2006-08-02 20:20:49-04:00, stenn@whimsy.udel.edu +21 -10
+    autogen upgrade
+
+  ntpq/ntpq-opts.h@1.2, 2006-08-02 19:37:13-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpq/ntpq-opts.texi@1.3, 2006-08-02 20:20:49-04:00, stenn@whimsy.udel.edu +5 -244
+    autogen upgrade
+
+  ntpq/ntpq-opts.texi@1.2, 2006-08-02 19:37:14-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  ntpq/ntpq.1@1.3, 2006-08-02 20:20:50-04:00, stenn@whimsy.udel.edu +16 -16
+    autogen upgrade
+
+  ntpq/ntpq.1@1.2, 2006-08-02 19:37:17-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  sntp/sntp-opts.c@1.3, 2006-08-02 20:20:51-04:00, stenn@whimsy.udel.edu +40 -260
+    autogen upgrade
+
+  sntp/sntp-opts.c@1.2, 2006-08-02 19:37:19-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  sntp/sntp-opts.h@1.3, 2006-08-02 20:20:52-04:00, stenn@whimsy.udel.edu +21 -10
+    autogen upgrade
+
+  sntp/sntp-opts.h@1.2, 2006-08-02 19:37:22-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  sntp/sntp-opts.texi@1.3, 2006-08-02 20:20:52-04:00, stenn@whimsy.udel.edu +4 -248
+    autogen upgrade
+
+  sntp/sntp-opts.texi@1.2, 2006-08-02 19:37:24-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  sntp/sntp.1@1.6, 2006-08-02 20:20:53-04:00, stenn@whimsy.udel.edu +129 -64
+    autogen upgrade
+
+  sntp/sntp.1@1.5, 2006-08-02 19:37:26-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  util/ntp-keygen-opts.c@1.3, 2006-08-02 20:20:54-04:00, stenn@whimsy.udel.edu +54 -36
+    autogen upgrade
+
+  util/ntp-keygen-opts.c@1.2, 2006-08-02 19:37:29-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  util/ntp-keygen-opts.h@1.3, 2006-08-02 20:20:55-04:00, stenn@whimsy.udel.edu +21 -10
+    autogen upgrade
+
+  util/ntp-keygen-opts.h@1.2, 2006-08-02 19:37:30-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  util/ntp-keygen-opts.texi@1.3, 2006-08-02 20:20:56-04:00, stenn@whimsy.udel.edu +3 -3
+    autogen upgrade
+
+  util/ntp-keygen-opts.texi@1.2, 2006-08-02 19:37:32-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  util/ntp-keygen.1@1.3, 2006-08-02 20:20:56-04:00, stenn@whimsy.udel.edu +23 -23
+    autogen upgrade
+
+  util/ntp-keygen.1@1.2, 2006-08-02 19:37:33-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+ChangeSet@1.1353.1.95, 2006-08-01 18:03:38+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    Bug 678:
+    make size of control message buffer configurable if
+    needbe. use lower default of 1536 bytes as qnx couldn't
+    cope with 5120 bytes and we are not really expecting
+    long control messages.
+    qnx limit is around 1900 bytes - qnx analysed by
+    Michael Tatarinov - thanks
+
+  ntpd/ntp_io.c@1.234, 2006-08-01 17:59:17+00:00, kardel@pogo.udel.edu +4 -1
+    Bug 678:
+    make size of control message buffer configurable if
+    needbe. use lower default of 1536 bytes as qnx couldn't
+    cope with 5120 bytes and we are not really expecting
+    long control messages.
+    qnx limit is around 1900 bytes - qnx analysed by
+    Michael Tatarinov - thanks
+
+ChangeSet@1.1353.1.94, 2006-08-01 06:41:31+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    Bug 676:
+    Correct name buffer size calculation. Found
+    by Michael Tatarinov - thanks!
+
+  ntpd/ntp_io.c@1.233, 2006-08-01 06:40:29+00:00, kardel@pogo.udel.edu +1 -1
+    Bug 676:
+    Correct name buffer size calculation. Found
+    by Michael Tatarinov - thanks!
+
+ChangeSet@1.1353.1.93, 2006-07-29 07:02:56-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P23
+  TAG: NTP_4_2_3P23
+
+  packageinfo.sh@1.16, 2006-07-29 07:02:54-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P23
+
+ChangeSet@1.1353.1.92, 2006-07-28 22:30:05-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 659] Move large "detail" description to "prog-man-descrip"
+
+  ntpq/ntpq-opts.def@1.9, 2006-07-28 22:29:50-04:00, stenn@whimsy.udel.edu +12 -1
+    [Bug 659] Move large "detail" description to "prog-man-descrip"
+
+  sntp/sntp-opts.def@1.5, 2006-07-28 22:29:50-04:00, stenn@whimsy.udel.edu +15 -4
+    [Bug 659] Move large "detail" description to "prog-man-descrip"
+
+ChangeSet@1.1353.1.91, 2006-07-28 07:42:56-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P22
+  TAG: NTP_4_2_3P22
+
+  packageinfo.sh@1.15, 2006-07-28 07:42:53-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P22
+
+ChangeSet@1.1251.94.42, 2006-07-28 07:02:21-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P3
+  TAG: NTP_4_2_2P3
+
+  packageinfo.sh@1.27.15.1, 2006-07-28 07:02:18-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P3
+
+ChangeSet@1.1251.94.41, 2006-07-28 01:28:32-04:00, stenn@whimsy.udel.edu +1 -0
+  Ready for release
+
+  packageinfo.sh@1.27.14.2, 2006-07-28 01:28:25-04:00, stenn@whimsy.udel.edu +1 -1
+    Ready for release
+
+ChangeSet@1.1251.94.40, 2006-07-28 01:20:54-04:00, stenn@whimsy.udel.edu +2 -0
+  Ready for release
+
+  NEWS@1.50.1.5, 2006-07-28 01:20:39-04:00, stenn@whimsy.udel.edu +30 -27
+    Ready for release
+
+  packageinfo.sh@1.27.14.1, 2006-07-28 01:20:39-04:00, stenn@whimsy.udel.edu +3 -3
+    Ready for release
+
+ChangeSet@1.1353.1.89, 2006-07-28 00:57:01-04:00, stenn@whimsy.udel.edu +12 -0
+  libopts-27.4.2
+
+  libopts/compat/snprintf.c@1.2, 2006-07-28 00:56:19-04:00, stenn@whimsy.udel.edu +28 -4
+    libopts-27.4.2
+
+  libopts/m4/libopts.m4@1.4, 2006-07-28 00:52:00-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.2
+
+  libopts/makeshell.c@1.4, 2006-07-28 00:51:31-04:00, stenn@whimsy.udel.edu +9 -9
+    libopts-27.4.2
+
+  libopts/proto.h@1.4, 2006-07-28 00:51:32-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.2
+
+  libopts/streqvcmp.c@1.3, 2006-07-28 00:51:34-04:00, stenn@whimsy.udel.edu +3 -5
+    libopts-27.4.2
+
+  libopts/version.c@1.3, 2006-07-28 00:51:35-04:00, stenn@whimsy.udel.edu +4 -8
+    libopts-27.4.2
+
+  sntp/libopts/compat/snprintf.c@1.2, 2006-07-28 00:52:33-04:00, stenn@whimsy.udel.edu +28 -4
+    libopts-27.4.2
+
+  sntp/libopts/m4/libopts.m4@1.4, 2006-07-28 00:55:02-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.2
+
+  sntp/libopts/makeshell.c@1.4, 2006-07-28 00:52:22-04:00, stenn@whimsy.udel.edu +9 -9
+    libopts-27.4.2
+
+  sntp/libopts/proto.h@1.4, 2006-07-28 00:52:24-04:00, stenn@whimsy.udel.edu +1 -1
+    libopts-27.4.2
+
+  sntp/libopts/streqvcmp.c@1.3, 2006-07-28 00:52:26-04:00, stenn@whimsy.udel.edu +3 -5
+    libopts-27.4.2
+
+  sntp/libopts/version.c@1.3, 2006-07-28 00:52:27-04:00, stenn@whimsy.udel.edu +4 -8
+    libopts-27.4.2
+
+ChangeSet@1.1251.94.39, 2006-07-27 22:13:37-04:00, stenn@whimsy.udel.edu +1 -0
+  NEWS: updated
+
+  NEWS@1.50.1.4, 2006-07-27 22:13:28-04:00, stenn@whimsy.udel.edu +21 -2
+    NEWS: updated
+
+ChangeSet@1.1251.94.38, 2006-07-27 22:07:57-04:00, stenn@whimsy.udel.edu +1 -0
+  Makefile.am: add a rule to generate the ChangeLog
+
+  Makefile.am@1.48.1.6, 2006-07-27 22:07:42-04:00, stenn@whimsy.udel.edu +9 -1
+    Makefile.am: add a rule to generate the ChangeLog
+
+ChangeSet@1.1353.1.87, 2006-07-26 08:19:28-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P21
+  TAG: NTP_4_2_3P21
+
+  packageinfo.sh@1.14, 2006-07-26 08:19:23-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P21
+
+ChangeSet@1.1251.94.37, 2006-07-26 07:02:51-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P3_RC2
+  TAG: NTP_4_2_2P3_RC2
+
+  packageinfo.sh@1.27.13.1, 2006-07-26 07:02:46-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P3_RC2
+
+ChangeSet@1.1353.1.86, 2006-07-26 06:34:06-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 660] Solaris wants _XOPEN_SOURCE, __EXTENSIONS__, and -lxnet -lsocket
+
+  configure.ac@1.388.1.4, 2006-07-26 06:33:48-04:00, stenn@whimsy.udel.edu +10 -3
+    [Bug 660] Solaris wants _XOPEN_SOURCE, __EXTENSIONS__, and -lxnet -lsocket
+
+ChangeSet@1.1353.1.85, 2006-07-26 04:16:13-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 638] STREAMS_TLI is no longer needed
+
+  configure.ac@1.388.1.3, 2006-07-26 04:16:02-04:00, stenn@whimsy.udel.edu +0 -20
+    [Bug 638] STREAMS_TLI is no longer needed
+
+ChangeSet@1.1251.94.36, 2006-07-26 03:53:28-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 601] ntpq's decodeint uses an extra level of indiraction
+
+  ntpq/ntpq.c@1.55.1.7, 2006-07-26 03:53:14-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 601] ntpq's decodeint uses an extra level of indiraction
+
+ChangeSet@1.1251.94.35, 2006-07-26 02:56:32-04:00, stenn@whimsy.udel.edu +1 -0
+  Don't do anything in a RESYNC repo
+
+  BitKeeper/triggers/send@1.10, 2006-07-26 02:56:23-04:00, stenn@whimsy.udel.edu +6 -0
+    Don't do anything in a RESYNC repo
+
+ChangeSet@1.1251.94.34, 2006-07-26 02:34:51-04:00, stenn@whimsy.udel.edu +1 -0
+  Test the -m option in the send trigger
+
+  BitKeeper/triggers/send@1.9, 2006-07-26 02:34:40-04:00, stenn@whimsy.udel.edu +4 -1
+    Test the -m option in the send trigger
+
+ChangeSet@1.1353.1.81, 2006-07-26 01:04:24-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 479] -P needs to set priority_done=0
+
+  ntpd/ntpd.c@1.80, 2006-07-26 00:16:05-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 479] -P needs to set priority_done=0
+
+ChangeSet@1.1353.1.80, 2006-07-26 00:55:28-04:00, stenn@whimsy.udel.edu +5 -0
+  AutoOpts cleanup - common .def entries are already in copyright.def
+
+  ntpd/ntpd-opts.def@1.5, 2006-07-26 00:55:23-04:00, stenn@whimsy.udel.edu +0 -3
+    common .def entries are already in copyright.def
+
+  ntpd/ntpd-opts.texi@1.2, 2006-07-26 00:55:23-04:00, stenn@whimsy.udel.edu +4 -4
+    Updated
+
+  ntpd/ntpdsim-opts.def@1.5, 2006-07-26 00:55:24-04:00, stenn@whimsy.udel.edu +0 -3
+    common .def entries are already in copyright.def
+
+  ntpq/ntpq-opts.def@1.8, 2006-07-25 06:08:56-04:00, stenn@whimsy.udel.edu +0 -3
+    common .def entries are already in copyright.def
+
+  util/ntp-keygen-opts.def@1.5, 2006-07-25 06:06:53-04:00, stenn@whimsy.udel.edu +0 -3
+    common .def entries are already in copyright.def
+
+ChangeSet@1.1353.1.79, 2006-07-23 07:03:50-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P20
+  TAG: NTP_4_2_3P20
+
+  packageinfo.sh@1.13, 2006-07-23 07:03:48-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P20
+
+ChangeSet@1.1353.1.78, 2006-07-22 23:35:43-04:00, stenn@whimsy.udel.edu +42 -0
+  windows-config.h:
+    BitKeeper file /deacon/backroom/ntp-dev/sntp/libopts/compat/windows-config.h
+    BitKeeper file /deacon/backroom/ntp-dev/libopts/compat/windows-config.h
+  Many files:
+    Upgrade to libopts-27.4.2
+
+  libopts/Makefile.am@1.3, 2006-07-22 23:28:42-04:00, stenn@whimsy.udel.edu +14 -14
+    Upgrade to libopts-27.4.2
+
+  libopts/autoopts.c@1.3, 2006-07-22 23:28:42-04:00, stenn@whimsy.udel.edu +7 -9
+    Upgrade to libopts-27.4.2
+
+  libopts/autoopts.h@1.3, 2006-07-22 23:28:43-04:00, stenn@whimsy.udel.edu +7 -8
+    Upgrade to libopts-27.4.2
+
+  libopts/autoopts/options.h@1.3, 2006-07-22 23:33:13-04:00, stenn@whimsy.udel.edu +64 -62
+    Upgrade to libopts-27.4.2
+
+  libopts/autoopts/usage-txt.h@1.2, 2006-07-22 23:33:14-04:00, stenn@whimsy.udel.edu +271 -395
+    Upgrade to libopts-27.4.2
+
+  libopts/compat/compat.h@1.3, 2006-07-22 23:33:15-04:00, stenn@whimsy.udel.edu +25 -9
+    Upgrade to libopts-27.4.2
+
+  libopts/compat/pathfind.c@1.3, 2006-07-22 23:33:15-04:00, stenn@whimsy.udel.edu +12 -3
+    Upgrade to libopts-27.4.2
+
+  libopts/compat/windows-config.h@1.1, 2006-07-22 23:27:32-04:00, stenn@whimsy.udel.edu +118 -0
+    BitKeeper file /deacon/backroom/ntp-dev/libopts/compat/windows-config.h
+
+  libopts/compat/windows-config.h@1.0, 2006-07-22 23:27:32-04:00, stenn@whimsy.udel.edu +0 -0
+
+  libopts/configfile.c@1.3, 2006-07-22 23:28:44-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.2
+
+  libopts/genshell.c@1.2, 2006-07-22 23:28:46-04:00, stenn@whimsy.udel.edu +50 -10
+    Upgrade to libopts-27.4.2
+
+  libopts/genshell.h@1.2, 2006-07-22 23:28:46-04:00, stenn@whimsy.udel.edu +21 -10
+    Upgrade to libopts-27.4.2
+
+  libopts/libopts.c@1.3, 2006-07-22 23:28:47-04:00, stenn@whimsy.udel.edu +0 -1
+    Upgrade to libopts-27.4.2
+
+  libopts/load.c@1.3, 2006-07-22 23:28:47-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.2
+
+  libopts/m4/libopts.m4@1.3, 2006-07-22 23:33:17-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.2
+
+  libopts/makeshell.c@1.3, 2006-07-22 23:28:48-04:00, stenn@whimsy.udel.edu +11 -2
+    Upgrade to libopts-27.4.2
+
+  libopts/pgusage.c@1.3, 2006-07-22 23:28:49-04:00, stenn@whimsy.udel.edu +7 -3
+    Upgrade to libopts-27.4.2
+
+  libopts/proto.h@1.3, 2006-07-22 23:28:50-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.2
+
+  libopts/putshell.c@1.3, 2006-07-22 23:28:50-04:00, stenn@whimsy.udel.edu +3 -3
+    Upgrade to libopts-27.4.2
+
+  libopts/save.c@1.3, 2006-07-22 23:28:51-04:00, stenn@whimsy.udel.edu +3 -3
+    Upgrade to libopts-27.4.2
+
+  libopts/stack.c@1.3, 2006-07-22 23:28:52-04:00, stenn@whimsy.udel.edu +5 -3
+    Upgrade to libopts-27.4.2
+
+  libopts/usage.c@1.3, 2006-07-22 23:28:53-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/Makefile.am@1.3, 2006-07-22 23:34:06-04:00, stenn@whimsy.udel.edu +14 -14
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/autoopts.c@1.3, 2006-07-22 23:34:07-04:00, stenn@whimsy.udel.edu +7 -9
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/autoopts.h@1.3, 2006-07-22 23:34:07-04:00, stenn@whimsy.udel.edu +7 -8
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/autoopts/options.h@1.3, 2006-07-22 23:34:18-04:00, stenn@whimsy.udel.edu +64 -62
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/autoopts/usage-txt.h@1.2, 2006-07-22 23:34:19-04:00, stenn@whimsy.udel.edu +271 -395
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/compat/compat.h@1.3, 2006-07-22 23:34:19-04:00, stenn@whimsy.udel.edu +25 -9
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/compat/pathfind.c@1.3, 2006-07-22 23:34:20-04:00, stenn@whimsy.udel.edu +12 -3
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/compat/windows-config.h@1.1, 2006-07-22 23:27:32-04:00, stenn@whimsy.udel.edu +118 -0
+    BitKeeper file /deacon/backroom/ntp-dev/sntp/libopts/compat/windows-config.h
+
+  sntp/libopts/compat/windows-config.h@1.0, 2006-07-22 23:27:32-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/libopts/configfile.c@1.3, 2006-07-22 23:34:08-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/genshell.c@1.2, 2006-07-22 23:34:10-04:00, stenn@whimsy.udel.edu +50 -10
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/genshell.h@1.2, 2006-07-22 23:34:10-04:00, stenn@whimsy.udel.edu +21 -10
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/libopts.c@1.3, 2006-07-22 23:34:11-04:00, stenn@whimsy.udel.edu +0 -1
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/load.c@1.3, 2006-07-22 23:34:11-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/m4/libopts.m4@1.3, 2006-07-22 23:34:21-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/makeshell.c@1.3, 2006-07-22 23:34:12-04:00, stenn@whimsy.udel.edu +11 -2
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/pgusage.c@1.3, 2006-07-22 23:34:13-04:00, stenn@whimsy.udel.edu +7 -3
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/proto.h@1.3, 2006-07-22 23:34:13-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/putshell.c@1.3, 2006-07-22 23:34:13-04:00, stenn@whimsy.udel.edu +3 -3
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/save.c@1.3, 2006-07-22 23:34:14-04:00, stenn@whimsy.udel.edu +3 -3
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/stack.c@1.3, 2006-07-22 23:34:15-04:00, stenn@whimsy.udel.edu +5 -3
+    Upgrade to libopts-27.4.2
+
+  sntp/libopts/usage.c@1.3, 2006-07-22 23:34:16-04:00, stenn@whimsy.udel.edu +1 -1
+    Upgrade to libopts-27.4.2
+
+ChangeSet@1.1353.1.77, 2006-07-22 10:12:26+00:00, kardel@pogo.udel.edu +2 -0
+  ntp_io.c:
+    move debug level for most interface based activity up to 3 and 4
+    3 major steps and decisions, 4 for tracing like events.
+    remove some #ifdef cruft from sendpkt() - remove SILENT exits that
+    don't make sense.
+  ntp_peer.c:
+    move debug level for some interface based activity up to 3 and 4
+    3 major steps and decisions, 4 for tracing like events.
+
+  ntpd/ntp_io.c@1.232, 2006-07-22 10:08:32+00:00, kardel@pogo.udel.edu +98 -105
+    move debug level for most interface based activity up to 3 and 4
+    3 major steps and decisions, 4 for tracing like events.
+    remove some #ifdef cruft from sendpkt() - remove SILENT exits that
+    don't make sense.
+
+  ntpd/ntp_peer.c@1.96, 2006-07-22 10:11:02+00:00, kardel@pogo.udel.edu +4 -4
+    move debug level for some interface based activity up to 3 and 4
+    3 major steps and decisions, 4 for tracing like events.
+
+ChangeSet@1.1353.1.76, 2006-07-22 10:04:56+00:00, kardel@pogo.udel.edu +2 -0
+  ntp_request.h:
+    bug 672:
+    rearrange struct info_if_stats to be compacter and
+    pad to a 64 bit size boundary for coexistance with
+    32 and 64 bit platforms
+  layout.std:
+    bug 672:
+    document changed struct info_if_stats layout
+
+  include/ntp_request.h@1.30, 2006-07-22 09:57:38+00:00, kardel@pogo.udel.edu +3 -2
+    bug 672:
+    rearrange struct info_if_stats to be compacter and
+    pad to a 64 bit size boundary for coexistance with
+    32 and 64 bit platforms
+
+  ntpdc/layout.std@1.7, 2006-07-22 10:00:27+00:00, kardel@pogo.udel.edu +16 -15
+    bug 672:
+    document changed struct info_if_stats layout
+
+ChangeSet@1.1353.1.75, 2006-07-21 08:10:58-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P19
+  TAG: NTP_4_2_3P19
+
+  packageinfo.sh@1.12, 2006-07-21 08:10:56-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P19
+
+ChangeSet@1.1251.94.33, 2006-07-21 07:02:38-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P3_RC1
+  TAG: NTP_4_2_2P3_RC1
+
+  packageinfo.sh@1.27.12.1, 2006-07-21 07:02:33-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P3_RC1
+
+ChangeSet@1.1251.94.32, 2006-07-20 17:22:04-04:00, stenn@whimsy.udel.edu +1 -0
+  Don't bother trying to mirror a RESYNC repo
+
+  BitKeeper/triggers/2mirrors@1.3, 2006-07-20 17:18:06-04:00, stenn@whimsy.udel.edu +6 -0
+    Don't bother trying to mirror a RESYNC repo
+
+ChangeSet@1.1251.94.31, 2006-07-20 15:50:44-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 671] Windows wants TYPEOF_IP_MULTICAST_SPOOL=BOOL
+
+  configure.ac@1.359.5.3, 2006-07-20 15:45:10-04:00, stenn@whimsy.udel.edu +4 -1
+    [Bug 671] Windows wants TYPEOF_IP_MULTICAST_SPOOL=BOOL
+
+ChangeSet@1.1353.1.72, 2006-07-20 13:49:44-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P18
+  TAG: NTP_4_2_3P18
+
+  packageinfo.sh@1.11, 2006-07-20 13:49:25-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P18
+
+ChangeSet@1.1251.94.30, 2006-07-20 07:20:34-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P3_RC0
+  TAG: NTP_4_2_2P3_RC0
+
+  packageinfo.sh@1.27.11.1, 2006-07-20 07:20:29-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P3_RC0
+
+ChangeSet@1.1251.94.29, 2006-07-19 22:22:49-04:00, stenn@deacon.udel.edu +1 -0
+  Send the diffs before the patch in the send trigger.
+
+  BitKeeper/triggers/send@1.8, 2006-07-19 22:22:42-04:00, stenn@deacon.udel.edu +4 -2
+    Send the diffs before the patch in the send trigger.
+
+ChangeSet@1.1251.94.28, 2006-07-19 22:19:11-04:00, stenn@deacon.udel.edu +1 -0
+  update the path to the winnt.html file
+
+  INSTALL@1.8, 2006-07-19 22:19:03-04:00, stenn@deacon.udel.edu +1 -1
+    update the path to the winnt.html file
+
+ChangeSet@1.1251.94.27, 2006-07-19 21:55:54-04:00, stenn@deacon.udel.edu +1 -0
+  Ignore autom4te.cache directories
+
+  BitKeeper/etc/ignore@1.35.1.4, 2006-07-19 21:55:46-04:00, stenn@deacon.udel.edu +2 -1
+    Ignore autom4te.cache directories
+
+ChangeSet@1.1353.1.69, 2006-07-19 21:00:05-04:00, stenn@deacon.udel.edu +1 -0
+  Run the licfix script quietly
+
+  BitKeeper/triggers/pre-resolve.licfix@1.3, 2006-07-19 20:59:54-04:00, stenn@deacon.udel.edu +1 -1
+    Run the licfix script quietly
+
+ChangeSet@1.1251.94.26, 2006-07-19 05:24:23-04:00, stenn@pogo.udel.edu +1 -0
+  [Bug 657] netbsd fix for IP_MULTICAST_LOOP test
+
+  configure.ac@1.359.5.2, 2006-07-19 05:24:14-04:00, stenn@pogo.udel.edu +1 -1
+    [Bug 657] netbsd fix for IP_MULTICAST_LOOP test
+
+ChangeSet@1.1251.94.25, 2006-07-19 03:10:22-04:00, stenn@pogo.udel.edu +2 -0
+  [Bug 657] Different OSes need different sized args for IP_MULTICAST_LOOP
+
+  configure.ac@1.359.5.1, 2006-07-19 03:10:08-04:00, stenn@pogo.udel.edu +15 -1
+    [Bug 657] Different OSes need different sized args for IP_MULTICAST_LOOP
+
+  ntpd/ntp_io.c@1.187.1.19, 2006-07-19 03:10:09-04:00, stenn@pogo.udel.edu +1 -1
+    [Bug 657] Different OSes need different sized args for IP_MULTICAST_LOOP
+
+ChangeSet@1.1353.1.67, 2006-07-15 09:35:45+00:00, kardel@pogo.udel.edu +3 -0
+  ntp_io.c:
+    cleanup debug messages
+    add RTM_REDIRECT, RTM_CHANGE as additional interface list scan 
+    routing message triggers
+  ntpd.h:
+    select_peerinterface() is comletely private to ntp_peer.c
+  ntp_peer.c:
+    - clear peer crypto when disconnecting from a bound interface
+    - re-arrange initialization for more usable debug output
+    - only bind to non wildcard interfaces even if the OS
+      would offer to send via such an interface
+
+  include/ntpd.h@1.93, 2006-07-15 09:06:47+00:00, kardel@pogo.udel.edu +0 -1
+    select_peerinterface() is comletely private to ntp_peer.c
+
+  ntpd/ntp_io.c@1.230, 2006-07-15 08:59:23+00:00, kardel@pogo.udel.edu +9 -3
+    cleanup debug messages
+    add RTM_REDIRECT, RTM_CHANGE as additional interface list scan 
+    routing message triggers
+
+  ntpd/ntp_peer.c@1.95, 2006-07-15 09:04:48+00:00, kardel@pogo.udel.edu +43 -31
+    - clear crypto when leaving a bound interface
+    - re-arrange initialization for more usable debug output
+    - only bind to non wildcard interfaces even if the OS
+      would offer to send via such an interface
+
+ChangeSet@1.1353.1.66, 2006-07-10 18:08:35+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    fix prototype argument type to match implementation
+
+  ntpd/ntp_io.c@1.229, 2006-07-10 18:07:50+00:00, kardel@pogo.udel.edu +1 -1
+    fix prototype argument type to match implementation
+
+ChangeSet@1.1353.1.65, 2006-07-10 07:42:31-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P17
+  TAG: NTP_4_2_3P17
+
+  packageinfo.sh@1.10, 2006-07-10 07:42:26-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P17
+
+ChangeSet@1.1251.97.31, 2006-07-10 07:02:26-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P3_RC
+  TAG: NTP_4_2_2P3_RC
+
+  packageinfo.sh@1.27.9.1, 2006-07-10 07:02:23-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_2P3_RC
+
+ChangeSet@1.1251.97.30, 2006-07-10 03:27:15-04:00, stenn@whimsy.udel.edu +1 -0
+  cleanup
+
+  NEWS@1.50.1.3, 2006-07-10 03:27:07-04:00, stenn@whimsy.udel.edu +1 -1
+    cleanup
+
+ChangeSet@1.1251.97.29, 2006-07-10 03:14:23-04:00, stenn@whimsy.udel.edu +1 -0
+  Start an RC cycle with the new changes
+
+  packageinfo.sh@1.27.8.1, 2006-07-10 03:14:13-04:00, stenn@whimsy.udel.edu +2 -2
+    Start an RC cycle with the new changes
+
+ChangeSet@1.1251.97.28, 2006-07-10 03:07:33-04:00, stenn@whimsy.udel.edu +1 -0
+  Use a decent Subject: line for the new send trigger
+
+  BitKeeper/triggers/send@1.7, 2006-07-10 03:07:21-04:00, stenn@whimsy.udel.edu +2 -1
+    Use a decent Subject: line for the new send trigger
+
+ChangeSet@1.1251.97.27, 2006-07-10 01:54:26-04:00, stenn@whimsy.udel.edu +1 -0
+  Also use the new "bk changes" command for the "send" emails
+
+  BitKeeper/triggers/send@1.6, 2006-07-10 01:54:10-04:00, stenn@whimsy.udel.edu +15 -0
+    Also use the new "bk changes" command for the "send" emails
+
+ChangeSet@1.1251.97.26, 2006-07-10 01:40:48-04:00, stenn@whimsy.udel.edu +1 -0
+  update
+
+  README@1.22, 2006-07-10 01:40:24-04:00, stenn@whimsy.udel.edu +3 -3
+    update
+
+ChangeSet@1.1251.97.25, 2006-07-10 01:32:25-04:00, stenn@whimsy.udel.edu +1 -0
+  update
+
+  WHERE-TO-START@1.6, 2006-07-10 01:32:11-04:00, stenn@whimsy.udel.edu +5 -5
+    update
+
+ChangeSet@1.1251.97.24, 2006-07-10 01:20:12-04:00, stenn@whimsy.udel.edu +1 -0
+  Note that sntp now builds under AIX 5
+
+  NEWS@1.50.1.2, 2006-07-10 01:19:55-04:00, stenn@whimsy.udel.edu +1 -0
+    Note that sntp now builds under AIX 5
+
+ChangeSet@1.1251.97.23, 2006-07-10 00:21:34-04:00, stenn@whimsy.udel.edu +1 -0
+  Have sntp build config.h, and cleanup some quoting
+
+  sntp/configure.ac@1.8.1.1, 2006-07-10 00:21:23-04:00, stenn@whimsy.udel.edu +3 -2
+    Have sntp build config.h, and cleanup some quoting
+
+ChangeSet@1.1353.1.62, 2006-07-09 07:25:54-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P16
+  TAG: NTP_4_2_3P16
+
+  packageinfo.sh@1.9, 2006-07-09 07:25:52-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P16
+
+ChangeSet@1.1251.97.22, 2006-07-09 07:02:21-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P2
+  TAG: NTP_4_2_2P2
+
+  packageinfo.sh@1.27.7.1, 2006-07-09 07:02:18-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P2
+
+ChangeSet@1.1353.1.60, 2006-07-09 00:41:37-04:00, stenn@whimsy.udel.edu +1 -0
+  socket.c needs stuff from config.h
+
+  sntp/socket.c@1.6, 2006-07-09 00:35:36-04:00, stenn@whimsy.udel.edu +2 -0
+    socket.c needs stuff from config.h
+
+ChangeSet@1.1251.97.21, 2006-07-09 00:39:26-04:00, stenn@whimsy.udel.edu +1 -0
+  socket.c needs stuff from config.h
+
+  sntp/socket.c@1.5.1.1, 2006-07-09 00:39:11-04:00, stenn@whimsy.udel.edu +2 -0
+    socket.c needs stuff from config.h
+
+ChangeSet@1.1353.6.1, 2006-07-08 07:26:18-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P15
+  TAG: NTP_4_2_3P15
+
+  packageinfo.sh@1.8, 2006-07-08 07:26:13-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P15
+
+ChangeSet@1.1251.97.20, 2006-07-08 07:02:36-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P1
+  TAG: NTP_4_2_2P1
+
+  packageinfo.sh@1.27.6.1, 2006-07-08 07:02:33-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P1
+
+ChangeSet@1.1353.1.56, 2006-07-08 06:36:29-04:00, stenn@whimsy.udel.edu +4 -0
+  [Bug 667] Fix ntpdc's option processing
+
+  ntpdc/ntpdc-opts.c@1.2, 2006-07-08 06:36:04-04:00, stenn@whimsy.udel.edu +38 -13
+    [Bug 667] Fix ntpdc's option processing
+
+  ntpdc/ntpdc-opts.h@1.2, 2006-07-08 06:36:05-04:00, stenn@whimsy.udel.edu +20 -10
+    [Bug 667] Fix ntpdc's option processing
+
+  ntpdc/ntpdc-opts.texi@1.2, 2006-07-08 06:36:05-04:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 667] Fix ntpdc's option processing
+
+  ntpdc/ntpdc.1@1.2, 2006-07-08 06:36:06-04:00, stenn@whimsy.udel.edu +17 -16
+    [Bug 667] Fix ntpdc's option processing
+
+ChangeSet@1.1251.97.19, 2006-07-08 06:19:53-04:00, stenn@whimsy.udel.edu +1 -0
+  Time for the point release
+
+  packageinfo.sh@1.27.5.2, 2006-07-08 06:19:45-04:00, stenn@whimsy.udel.edu +3 -3
+    Time for the point release
+
+ChangeSet@1.1251.97.18, 2006-07-08 06:16:07-04:00, stenn@whimsy.udel.edu +1 -0
+  cleanup the bk ignore file
+
+  BitKeeper/etc/ignore@1.35.1.3, 2006-07-08 06:15:30-04:00, stenn@whimsy.udel.edu +34 -34
+    cleanup the bk ignore file
+
+ChangeSet@1.1353.1.55, 2006-07-08 06:06:02-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 667] Fix ntpdc's option processing
+
+  ntpdc/ntpdc-opts.def@1.11, 2006-07-08 06:05:51-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 667] Fix ntpdc's option processing
+
+  ntpdc/ntpdc.c@1.53, 2006-07-08 06:05:51-04:00, stenn@whimsy.udel.edu +15 -0
+    [Bug 667] Fix ntpdc's option processing
+
+ChangeSet@1.1353.5.1, 2006-07-08 08:22:35+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    simplify move_fd()
+    refactor socket level udp paket time stamping by creating fetch_timestamp() for the
+    interfaces we will implement
+    implement the standard interface using the CMSG_* macros
+    only enable socket time stamping when CMSG_* macros are defined
+    cleanup minor signedness issues with pointer target types for length arguments
+
+  ntpd/ntp_io.c@1.228, 2006-07-08 08:17:45+00:00, kardel@pogo.udel.edu +93 -75
+    simplify move_fd()
+    refactor socket level udp paket time stamping by creating fetch_timestamp() for the
+    interfaces we will implement
+    implement the standard interface using the CMSG_* macros
+    only enable socket time stamping when CMSG_* macros are defined
+    cleanup minor signedness issues with pointer target types for length arguments
+
+ChangeSet@1.1353.1.54, 2006-07-08 03:04:02-04:00, stenn@whimsy.udel.edu +2 -0
+  Fix the hppa2.0-hp-hpux10.20 -H case
+
+  configure.ac@1.388, 2006-07-08 03:03:30-04:00, stenn@whimsy.udel.edu +4 -3
+    Fix the hppa2.0-hp-hpux10.20 -H case
+
+  sntp/configure.ac@1.12, 2006-07-08 03:03:31-04:00, stenn@whimsy.udel.edu +4 -3
+    Fix the hppa2.0-hp-hpux10.20 -H case
+
+ChangeSet@1.1353.1.53, 2006-07-07 18:34:28-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P14
+  TAG: NTP_4_2_3P14
+
+  packageinfo.sh@1.7, 2006-07-07 18:34:19-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P14
+
+ChangeSet@1.1353.1.52, 2006-07-07 15:20:47-04:00, stenn@whimsy.udel.edu +1 -0
+  Add the -H stuff for cc under HP-UX to sntp's configure.ac
+
+  sntp/configure.ac@1.11, 2006-07-07 15:20:21-04:00, stenn@whimsy.udel.edu +7 -0
+    Add the -H stuff for cc under HP-UX to sntp's configure.ac
+
+ChangeSet@1.1353.1.51, 2006-07-07 06:57:09-04:00, stenn@whimsy.udel.edu +1 -0
+  we want ltmain.sh now
+
+  BitKeeper/etc/ignore@1.53, 2006-07-07 06:56:13-04:00, stenn@whimsy.udel.edu +1 -1
+    we want ltmain.sh now
+
+ChangeSet@1.1353.1.50, 2006-07-07 05:53:15-04:00, stenn@whimsy.udel.edu +11 -0
+  Make sure .def files are readable, distribute libtool.m4 and ltmain.sh to solve bootstrap problem
+
+  libopts/m4/libtool.m4@1.1, 2006-07-07 05:51:53-04:00, stenn@whimsy.udel.edu +6397 -0
+    BitKeeper file /deacon/backroom/ntp-dev/libopts/m4/libtool.m4
+
+  libopts/m4/libtool.m4@1.0, 2006-07-07 05:51:53-04:00, stenn@whimsy.udel.edu +0 -0
+
+  ltmain.sh@1.1, 2006-07-07 05:51:57-04:00, stenn@whimsy.udel.edu +6863 -0
+    BitKeeper file /deacon/backroom/ntp-dev/ltmain.sh
+
+  ltmain.sh@1.0, 2006-07-07 05:51:57-04:00, stenn@whimsy.udel.edu +0 -0
+
+  ntpd/ntpd-opts.def@1.4, 2006-07-07 05:49:42-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-rw-r--
+
+  ntpd/ntpdbase-opts.def@1.5, 2006-07-07 05:49:43-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-rw-r--
+
+  ntpd/ntpdsim-opts.def@1.4, 2006-07-07 05:49:44-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-rw-r--
+
+  ntpdc/ntpdc-opts.def@1.10, 2006-07-07 05:49:45-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-rw-r--
+
+  ntpq/ntpq-opts.def@1.7, 2006-07-07 05:49:45-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-rw-r--
+
+  sntp/libopts/m4/libtool.m4@1.1, 2006-07-07 05:51:56-04:00, stenn@whimsy.udel.edu +6397 -0
+    BitKeeper file /deacon/backroom/ntp-dev/sntp/libopts/m4/libtool.m4
+
+  sntp/libopts/m4/libtool.m4@1.0, 2006-07-07 05:51:56-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/ltmain.sh@1.1, 2006-07-07 05:51:55-04:00, stenn@whimsy.udel.edu +6863 -0
+    BitKeeper file /deacon/backroom/ntp-dev/sntp/ltmain.sh
+
+  sntp/ltmain.sh@1.0, 2006-07-07 05:51:55-04:00, stenn@whimsy.udel.edu +0 -0
+
+  sntp/sntp-opts.def@1.4, 2006-07-07 05:49:46-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-rw-r--
+
+  util/ntp-keygen-opts.def@1.4, 2006-07-07 05:49:47-04:00, stenn@whimsy.udel.edu +0 -0
+    Change mode to -rw-rw-r--
+
+ChangeSet@1.1353.1.49, 2006-07-03 21:51:08-04:00, stenn@deacon.udel.edu +2 -0
+  Make prototype agree with decl
+
+  libopts/autoopts/options.h@1.2, 2006-07-03 21:50:59-04:00, stenn@deacon.udel.edu +1 -1
+    Make prototype agree with decl
+
+  sntp/libopts/autoopts/options.h@1.2, 2006-07-03 21:50:59-04:00, stenn@deacon.udel.edu +1 -1
+    Make prototype agree with decl
+
+ChangeSet@1.1353.1.48, 2006-07-03 19:05:18-04:00, stenn@deacon.udel.edu +58 -0
+  Upgrade to libopts-27.3.2
+
+  libopts/Makefile.am@1.2, 2006-07-03 18:57:04-04:00, stenn@deacon.udel.edu +10 -10
+    Upgrade to libopts-27.3.2
+
+  libopts/autoopts.c@1.2, 2006-07-03 18:57:04-04:00, stenn@deacon.udel.edu +9 -5
+    Upgrade to libopts-27.3.2
+
+  libopts/autoopts.h@1.2, 2006-07-03 18:57:04-04:00, stenn@deacon.udel.edu +15 -7
+    Upgrade to libopts-27.3.2
+
+  libopts/boolean.c@1.2, 2006-07-03 18:57:04-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  libopts/compat/compat.h@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +5 -2
+    Upgrade to libopts-27.3.2
+
+  libopts/compat/pathfind.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +2 -2
+    Upgrade to libopts-27.3.2
+
+  libopts/compat/strchr.c@1.1, 2006-07-03 18:55:11-04:00, stenn@deacon.udel.edu +61 -0
+
+  libopts/compat/strchr.c@1.0, 2006-07-03 18:55:11-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/libopts/compat/strchr.c
+
+  libopts/configfile.c@1.2, 2006-07-03 18:57:04-04:00, stenn@deacon.udel.edu +6 -6
+    Upgrade to libopts-27.3.2
+
+  libopts/cook.c@1.2, 2006-07-03 18:57:04-04:00, stenn@deacon.udel.edu +6 -6
+    Upgrade to libopts-27.3.2
+
+  libopts/enumeration.c@1.2, 2006-07-03 18:57:04-04:00, stenn@deacon.udel.edu +8 -8
+    Upgrade to libopts-27.3.2
+
+  libopts/environment.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  libopts/libopts.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +1 -0
+    Upgrade to libopts-27.3.2
+
+  libopts/load.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +7 -7
+    Upgrade to libopts-27.3.2
+
+  libopts/m4/libopts.m4@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +6 -13
+    Upgrade to libopts-27.3.2
+
+  libopts/makeshell.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +10 -10
+    Upgrade to libopts-27.3.2
+
+  libopts/nested.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  libopts/numeric.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  libopts/pgusage.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +3 -3
+    Upgrade to libopts-27.3.2
+
+  libopts/proto.h@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +2 -2
+    Upgrade to libopts-27.3.2
+
+  libopts/putshell.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +8 -8
+    Upgrade to libopts-27.3.2
+
+  libopts/restore.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  libopts/save.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +7 -7
+    Upgrade to libopts-27.3.2
+
+  libopts/sort.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +4 -4
+    Upgrade to libopts-27.3.2
+
+  libopts/stack.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +41 -2
+    Upgrade to libopts-27.3.2
+
+  libopts/streqvcmp.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  libopts/text_mmap.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +3 -3
+    Upgrade to libopts-27.3.2
+
+  libopts/tokenize.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +3 -3
+    Upgrade to libopts-27.3.2
+
+  libopts/usage.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +11 -11
+    Upgrade to libopts-27.3.2
+
+  libopts/version.c@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/Makefile.am@1.2, 2006-07-03 18:57:05-04:00, stenn@deacon.udel.edu +10 -10
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/autoopts.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +9 -5
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/autoopts.h@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +15 -7
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/boolean.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/compat/compat.h@1.2, 2006-07-03 18:57:07-04:00, stenn@deacon.udel.edu +5 -2
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/compat/pathfind.c@1.2, 2006-07-03 18:57:07-04:00, stenn@deacon.udel.edu +2 -2
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/compat/strchr.c@1.1, 2006-07-03 18:55:11-04:00, stenn@deacon.udel.edu +61 -0
+
+  sntp/libopts/compat/strchr.c@1.0, 2006-07-03 18:55:11-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/sntp/libopts/compat/strchr.c
+
+  sntp/libopts/configfile.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +6 -6
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/cook.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +6 -6
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/enumeration.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +8 -8
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/environment.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/libopts.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +1 -0
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/load.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +7 -7
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/m4/libopts.m4@1.2, 2006-07-03 18:57:07-04:00, stenn@deacon.udel.edu +6 -13
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/makeshell.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +10 -10
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/nested.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/numeric.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/pgusage.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +3 -3
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/proto.h@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +2 -2
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/putshell.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +8 -8
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/restore.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/save.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +7 -7
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/sort.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +4 -4
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/stack.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +41 -2
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/streqvcmp.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/text_mmap.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +3 -3
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/tokenize.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +3 -3
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/usage.c@1.2, 2006-07-03 18:57:06-04:00, stenn@deacon.udel.edu +11 -11
+    Upgrade to libopts-27.3.2
+
+  sntp/libopts/version.c@1.2, 2006-07-03 18:57:07-04:00, stenn@deacon.udel.edu +1 -1
+    Upgrade to libopts-27.3.2
+
+ChangeSet@1.1353.1.47, 2006-07-03 00:18:29-04:00, stenn@deacon.udel.edu +1 -0
+  typo
+
+  bootstrap@1.15, 2006-07-03 00:16:31-04:00, stenn@whimsy.udel.edu +1 -1
+    typo
+
+ChangeSet@1.1353.1.46, 2006-07-03 00:13:59-04:00, stenn@deacon.udel.edu +2 -0
+  touch the files generated by autogen to keep them from needing to be rebuilt.
+
+  bootstrap@1.14, 2006-07-03 00:13:47-04:00, stenn@deacon.udel.edu +38 -14
+    touch the files generated by autogen to keep them from needing to be rebuilt.
+
+  ntpd/ntp_proto.c@1.245, 2006-07-03 00:13:02-04:00, stenn@deacon.udel.edu +2 -2
+    Dave reformatted a line
+
+ChangeSet@1.1353.1.45, 2006-06-30 01:03:52-04:00, stenn@deacon.udel.edu +111 -0
+  Check in libopts and autgen-generated files
+
+  BitKeeper/etc/ignore@1.52, 2006-06-30 01:03:43-04:00, stenn@deacon.udel.edu +12 -12
+    Check in libopts and autgen-generated files
+
+  bootstrap@1.13, 2006-06-30 01:03:43-04:00, stenn@deacon.udel.edu +19 -18
+    Check in libopts and autgen-generated files
+
+  clockstuff/clktest-opts.c@1.1, 2006-06-30 00:58:06-04:00, stenn@deacon.udel.edu +825 -0
+
+  clockstuff/clktest-opts.c@1.0, 2006-06-30 00:58:06-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/clockstuff/clktest-opts.c
+
+  clockstuff/clktest-opts.h@1.1, 2006-06-30 00:58:06-04:00, stenn@deacon.udel.edu +192 -0
+
+  clockstuff/clktest-opts.h@1.0, 2006-06-30 00:58:06-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/clockstuff/clktest-opts.h
+
+  libopts/COPYING.lgpl@1.1, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +502 -0
+
+  libopts/COPYING.lgpl@1.0, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/COPYING.lgpl
+
+  libopts/COPYING.mbsd@1.1, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +26 -0
+
+  libopts/COPYING.mbsd@1.0, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/COPYING.mbsd
+
+  libopts/MakeDefs.inc@1.1, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +0 -0
+
+  libopts/MakeDefs.inc@1.0, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/MakeDefs.inc
+
+  libopts/Makefile.am@1.1, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +20 -0
+
+  libopts/Makefile.am@1.0, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/Makefile.am
+
+  libopts/README@1.1, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +93 -0
+
+  libopts/README@1.0, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/README
+
+  libopts/autoopts.c@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +1043 -0
+
+  libopts/autoopts.c@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/autoopts.c
+
+  libopts/autoopts.h@1.1, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +321 -0
+
+  libopts/autoopts.h@1.0, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/autoopts.h
+
+  libopts/autoopts/options.h@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +908 -0
+
+  libopts/autoopts/options.h@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/autoopts/options.h
+
+  libopts/autoopts/usage-txt.h@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +479 -0
+
+  libopts/autoopts/usage-txt.h@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/autoopts/usage-txt.h
+
+  libopts/boolean.c@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +102 -0
+
+  libopts/boolean.c@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/boolean.c
+
+  libopts/compat/compat.h@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +292 -0
+
+  libopts/compat/compat.h@1.0, 2006-06-30 00:55:13-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/compat/compat.h
+
+  libopts/compat/pathfind.c@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +330 -0
+
+  libopts/compat/pathfind.c@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/compat/pathfind.c
+
+  libopts/compat/snprintf.c@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +36 -0
+
+  libopts/compat/snprintf.c@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/compat/snprintf.c
+
+  libopts/compat/strdup.c@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +19 -0
+
+  libopts/compat/strdup.c@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/compat/strdup.c
+
+  libopts/configfile.c@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +1277 -0
+
+  libopts/configfile.c@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/configfile.c
+
+  libopts/cook.c@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +355 -0
+
+  libopts/cook.c@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/cook.c
+
+  libopts/enumeration.c@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +485 -0
+
+  libopts/enumeration.c@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/enumeration.c
+
+  libopts/environment.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +261 -0
+
+  libopts/environment.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/environment.c
+
+  libopts/genshell.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +301 -0
+
+  libopts/genshell.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/genshell.c
+
+  libopts/genshell.h@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +142 -0
+
+  libopts/genshell.h@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/genshell.h
+
+  libopts/libopts.c@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +30 -0
+
+  libopts/libopts.c@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/libopts.c
+
+  libopts/load.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +520 -0
+
+  libopts/load.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/load.c
+
+  libopts/m4/libopts.m4@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +487 -0
+
+  libopts/m4/libopts.m4@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/m4/libopts.m4
+
+  libopts/m4/liboptschk.m4@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +39 -0
+
+  libopts/m4/liboptschk.m4@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/m4/liboptschk.m4
+
+  libopts/makeshell.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +1100 -0
+
+  libopts/makeshell.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/makeshell.c
+
+  libopts/nested.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +705 -0
+
+  libopts/nested.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/nested.c
+
+  libopts/numeric.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +89 -0
+
+  libopts/numeric.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/numeric.c
+
+  libopts/pgusage.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +154 -0
+
+  libopts/pgusage.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/pgusage.c
+
+  libopts/proto.h@1.1, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +88 -0
+
+  libopts/proto.h@1.0, 2006-06-30 00:55:14-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/proto.h
+
+  libopts/putshell.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +333 -0
+
+  libopts/putshell.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/putshell.c
+
+  libopts/restore.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +207 -0
+
+  libopts/restore.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/restore.c
+
+  libopts/save.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +499 -0
+
+  libopts/save.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/save.c
+
+  libopts/sort.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +369 -0
+
+  libopts/sort.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/sort.c
+
+  libopts/stack.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +224 -0
+
+  libopts/stack.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/stack.c
+
+  libopts/streqvcmp.c@1.1, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +292 -0
+
+  libopts/streqvcmp.c@1.0, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/streqvcmp.c
+
+  libopts/text_mmap.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +367 -0
+
+  libopts/text_mmap.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/text_mmap.c
+
+  libopts/tokenize.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +322 -0
+
+  libopts/tokenize.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/tokenize.c
+
+  libopts/usage.c@1.1, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +732 -0
+
+  libopts/usage.c@1.0, 2006-06-30 00:55:15-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/usage.c
+
+  libopts/version.c@1.1, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +181 -0
+
+  libopts/version.c@1.0, 2006-06-30 00:55:16-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/libopts/version.c
+
+  ntpd/ntpd-opts.c@1.1, 2006-06-30 00:56:22-04:00, stenn@deacon.udel.edu +975 -0
+
+  ntpd/ntpd-opts.c@1.0, 2006-06-30 00:56:22-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpd/ntpd-opts.c
+
+  ntpd/ntpd-opts.h@1.1, 2006-06-30 00:56:22-04:00, stenn@deacon.udel.edu +193 -0
+
+  ntpd/ntpd-opts.h@1.0, 2006-06-30 00:56:22-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpd/ntpd-opts.h
+
+  ntpd/ntpd-opts.menu@1.1, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +1 -0
+
+  ntpd/ntpd-opts.menu@1.0, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpd/ntpd-opts.menu
+
+  ntpd/ntpd-opts.texi@1.1, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +481 -0
+
+  ntpd/ntpd-opts.texi@1.0, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpd/ntpd-opts.texi
+
+  ntpd/ntpd.1@1.1, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +307 -0
+
+  ntpd/ntpd.1@1.0, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpd/ntpd.1
+
+  ntpd/ntpdsim-opts.c@1.1, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +1173 -0
+
+  ntpd/ntpdsim-opts.c@1.0, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpd/ntpdsim-opts.c
+
+  ntpd/ntpdsim-opts.h@1.1, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +211 -0
+
+  ntpd/ntpdsim-opts.h@1.0, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpd/ntpdsim-opts.h
+
+  ntpd/ntpdsim-opts.menu@1.1, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +1 -0
+
+  ntpd/ntpdsim-opts.menu@1.0, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpd/ntpdsim-opts.menu
+
+  ntpd/ntpdsim-opts.texi@1.1, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +562 -0
+
+  ntpd/ntpdsim-opts.texi@1.0, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpd/ntpdsim-opts.texi
+
+  ntpd/ntpdsim.1@1.1, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +352 -0
+
+  ntpd/ntpdsim.1@1.0, 2006-06-30 00:56:23-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpd/ntpdsim.1
+
+  ntpdc/ntpdc-opts.c@1.1, 2006-06-30 00:56:35-04:00, stenn@deacon.udel.edu +606 -0
+
+  ntpdc/ntpdc-opts.c@1.0, 2006-06-30 00:56:35-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpdc/ntpdc-opts.c
+
+  ntpdc/ntpdc-opts.h@1.1, 2006-06-30 00:56:36-04:00, stenn@deacon.udel.edu +155 -0
+
+  ntpdc/ntpdc-opts.h@1.0, 2006-06-30 00:56:36-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpdc/ntpdc-opts.h
+
+  ntpdc/ntpdc-opts.menu@1.1, 2006-06-30 00:56:36-04:00, stenn@deacon.udel.edu +1 -0
+
+  ntpdc/ntpdc-opts.menu@1.0, 2006-06-30 00:56:36-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpdc/ntpdc-opts.menu
+
+  ntpdc/ntpdc-opts.texi@1.1, 2006-06-30 00:56:36-04:00, stenn@deacon.udel.edu +272 -0
+
+  ntpdc/ntpdc-opts.texi@1.0, 2006-06-30 00:56:36-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpdc/ntpdc-opts.texi
+
+  ntpdc/ntpdc.1@1.1, 2006-06-30 00:56:36-04:00, stenn@deacon.udel.edu +157 -0
+
+  ntpdc/ntpdc.1@1.0, 2006-06-30 00:56:36-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpdc/ntpdc.1
+
+  ntpq/ntpq-opts.c@1.1, 2006-06-30 00:56:42-04:00, stenn@deacon.udel.edu +781 -0
+
+  ntpq/ntpq-opts.c@1.0, 2006-06-30 00:56:42-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpq/ntpq-opts.c
+
+  ntpq/ntpq-opts.h@1.1, 2006-06-30 00:56:42-04:00, stenn@deacon.udel.edu +151 -0
+
+  ntpq/ntpq-opts.h@1.0, 2006-06-30 00:56:42-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpq/ntpq-opts.h
+
+  ntpq/ntpq-opts.menu@1.1, 2006-06-30 00:56:42-04:00, stenn@deacon.udel.edu +1 -0
+
+  ntpq/ntpq-opts.menu@1.0, 2006-06-30 00:56:42-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpq/ntpq-opts.menu
+
+  ntpq/ntpq-opts.texi@1.1, 2006-06-30 00:56:42-04:00, stenn@deacon.udel.edu +691 -0
+
+  ntpq/ntpq-opts.texi@1.0, 2006-06-30 00:56:42-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpq/ntpq-opts.texi
+
+  ntpq/ntpq.1@1.1, 2006-06-30 00:56:43-04:00, stenn@deacon.udel.edu +385 -0
+
+  ntpq/ntpq.1@1.0, 2006-06-30 00:56:43-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/ntpq/ntpq.1
+
+  sntp/libopts/COPYING.lgpl@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +502 -0
+
+  sntp/libopts/COPYING.lgpl@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/COPYING.lgpl
+
+  sntp/libopts/COPYING.mbsd@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +26 -0
+
+  sntp/libopts/COPYING.mbsd@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/COPYING.mbsd
+
+  sntp/libopts/MakeDefs.inc@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+
+  sntp/libopts/MakeDefs.inc@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/MakeDefs.inc
+
+  sntp/libopts/Makefile.am@1.1, 2006-06-30 01:00:05-04:00, stenn@deacon.udel.edu +20 -0
+
+  sntp/libopts/Makefile.am@1.0, 2006-06-30 01:00:05-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/Makefile.am
+
+  sntp/libopts/README@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +93 -0
+
+  sntp/libopts/README@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/README
+
+  sntp/libopts/autoopts.c@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +1043 -0
+
+  sntp/libopts/autoopts.c@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/autoopts.c
+
+  sntp/libopts/autoopts.h@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +321 -0
+
+  sntp/libopts/autoopts.h@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/autoopts.h
+
+  sntp/libopts/autoopts/options.h@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +908 -0
+
+  sntp/libopts/autoopts/options.h@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/autoopts/options.h
+
+  sntp/libopts/autoopts/usage-txt.h@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +479 -0
+
+  sntp/libopts/autoopts/usage-txt.h@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/autoopts/usage-txt.h
+
+  sntp/libopts/boolean.c@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +102 -0
+
+  sntp/libopts/boolean.c@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/boolean.c
+
+  sntp/libopts/compat/compat.h@1.1, 2006-06-30 01:00:01-04:00, stenn@deacon.udel.edu +292 -0
+
+  sntp/libopts/compat/compat.h@1.0, 2006-06-30 01:00:01-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/compat/compat.h
+
+  sntp/libopts/compat/pathfind.c@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +330 -0
+
+  sntp/libopts/compat/pathfind.c@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/compat/pathfind.c
+
+  sntp/libopts/compat/snprintf.c@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +36 -0
+
+  sntp/libopts/compat/snprintf.c@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/compat/snprintf.c
+
+  sntp/libopts/compat/strdup.c@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +19 -0
+
+  sntp/libopts/compat/strdup.c@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/compat/strdup.c
+
+  sntp/libopts/configfile.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +1277 -0
+
+  sntp/libopts/configfile.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/configfile.c
+
+  sntp/libopts/cook.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +355 -0
+
+  sntp/libopts/cook.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/cook.c
+
+  sntp/libopts/enumeration.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +485 -0
+
+  sntp/libopts/enumeration.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/enumeration.c
+
+  sntp/libopts/environment.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +261 -0
+
+  sntp/libopts/environment.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/environment.c
+
+  sntp/libopts/genshell.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +301 -0
+
+  sntp/libopts/genshell.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/genshell.c
+
+  sntp/libopts/genshell.h@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +142 -0
+
+  sntp/libopts/genshell.h@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/genshell.h
+
+  sntp/libopts/libopts.c@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +30 -0
+
+  sntp/libopts/libopts.c@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/libopts.c
+
+  sntp/libopts/load.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +520 -0
+
+  sntp/libopts/load.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/load.c
+
+  sntp/libopts/m4/libopts.m4@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +487 -0
+
+  sntp/libopts/m4/libopts.m4@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/m4/libopts.m4
+
+  sntp/libopts/m4/liboptschk.m4@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +39 -0
+
+  sntp/libopts/m4/liboptschk.m4@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/m4/liboptschk.m4
+
+  sntp/libopts/makeshell.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +1100 -0
+
+  sntp/libopts/makeshell.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/makeshell.c
+
+  sntp/libopts/nested.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +705 -0
+
+  sntp/libopts/nested.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/nested.c
+
+  sntp/libopts/numeric.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +89 -0
+
+  sntp/libopts/numeric.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/numeric.c
+
+  sntp/libopts/pgusage.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +154 -0
+
+  sntp/libopts/pgusage.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/pgusage.c
+
+  sntp/libopts/proto.h@1.1, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +88 -0
+
+  sntp/libopts/proto.h@1.0, 2006-06-30 01:00:02-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/proto.h
+
+  sntp/libopts/putshell.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +333 -0
+
+  sntp/libopts/putshell.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/putshell.c
+
+  sntp/libopts/restore.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +207 -0
+
+  sntp/libopts/restore.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/restore.c
+
+  sntp/libopts/save.c@1.1, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +499 -0
+
+  sntp/libopts/save.c@1.0, 2006-06-30 01:00:03-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/save.c
+
+  sntp/libopts/sort.c@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +369 -0
+
+  sntp/libopts/sort.c@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/sort.c
+
+  sntp/libopts/stack.c@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +224 -0
+
+  sntp/libopts/stack.c@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/stack.c
+
+  sntp/libopts/streqvcmp.c@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +292 -0
+
+  sntp/libopts/streqvcmp.c@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/streqvcmp.c
+
+  sntp/libopts/text_mmap.c@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +367 -0
+
+  sntp/libopts/text_mmap.c@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/text_mmap.c
+
+  sntp/libopts/tokenize.c@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +322 -0
+
+  sntp/libopts/tokenize.c@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/tokenize.c
+
+  sntp/libopts/usage.c@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +732 -0
+
+  sntp/libopts/usage.c@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/usage.c
+
+  sntp/libopts/version.c@1.1, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +181 -0
+
+  sntp/libopts/version.c@1.0, 2006-06-30 01:00:04-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/libopts/version.c
+
+  sntp/sntp-opts.c@1.1, 2006-06-30 01:02:22-04:00, stenn@deacon.udel.edu +742 -0
+
+  sntp/sntp-opts.c@1.0, 2006-06-30 01:02:22-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/sntp-opts.c
+
+  sntp/sntp-opts.h@1.1, 2006-06-30 01:02:22-04:00, stenn@deacon.udel.edu +149 -0
+
+  sntp/sntp-opts.h@1.0, 2006-06-30 01:02:22-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/sntp-opts.h
+
+  sntp/sntp-opts.menu@1.1, 2006-06-30 01:02:22-04:00, stenn@deacon.udel.edu +1 -0
+
+  sntp/sntp-opts.menu@1.0, 2006-06-30 01:02:22-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/sntp-opts.menu
+
+  sntp/sntp-opts.texi@1.1, 2006-06-30 01:02:22-04:00, stenn@deacon.udel.edu +410 -0
+
+  sntp/sntp-opts.texi@1.0, 2006-06-30 01:02:22-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/sntp/sntp-opts.texi
+
+  util/ntp-keygen-opts.c@1.1, 2006-06-30 00:51:39-04:00, stenn@deacon.udel.edu +989 -0
+
+  util/ntp-keygen-opts.c@1.0, 2006-06-30 00:51:39-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/util/ntp-keygen-opts.c
+
+  util/ntp-keygen-opts.h@1.1, 2006-06-30 00:51:40-04:00, stenn@deacon.udel.edu +206 -0
+
+  util/ntp-keygen-opts.h@1.0, 2006-06-30 00:51:40-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/util/ntp-keygen-opts.h
+
+  util/ntp-keygen-opts.menu@1.1, 2006-06-30 00:51:40-04:00, stenn@deacon.udel.edu +1 -0
+
+  util/ntp-keygen-opts.menu@1.0, 2006-06-30 00:51:40-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/util/ntp-keygen-opts.menu
+
+  util/ntp-keygen-opts.texi@1.1, 2006-06-30 00:51:40-04:00, stenn@deacon.udel.edu +362 -0
+
+  util/ntp-keygen-opts.texi@1.0, 2006-06-30 00:51:40-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/util/ntp-keygen-opts.texi
+
+  util/ntp-keygen.1@1.1, 2006-06-30 00:51:40-04:00, stenn@deacon.udel.edu +176 -0
+
+  util/ntp-keygen.1@1.0, 2006-06-30 00:51:40-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/util/ntp-keygen.1
+
+ChangeSet@1.1353.1.44, 2006-06-28 07:26:01-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P13
+  TAG: NTP_4_2_3P13
+
+  packageinfo.sh@1.6, 2006-06-28 07:25:51-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P13
+
+ChangeSet@1.1251.97.17, 2006-06-28 07:03:07-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P0_RC8
+  TAG: NTP_4_2_2P0_RC8
+
+  packageinfo.sh@1.27.5.1, 2006-06-28 07:02:59-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P0_RC8
+
+ChangeSet@1.1251.97.16, 2006-06-27 21:20:21+00:00, burnicki@pogo.udel.edu +8 -0
+  [BUG 661]
+  Use environment variable to specify the base path to openssl.
+  Updated hints/winnt.html accordingly.
+
+  html/build/hints/winnt.html@1.16, 2006-06-27 21:20:17+00:00, burnicki@pogo.udel.edu +42 -20
+    Added a hint to the build instructions to set up the OPENSSL environment variable.
+    Added the Meinberg link to download the GUI installer.
+    Wrapped some lines.
+
+  ports/winnt/libntp/libntp.dsp@1.29, 2006-06-27 21:20:17+00:00, burnicki@pogo.udel.edu +2 -2
+    Use environment variable to specify the base path to openssl.
+
+  ports/winnt/ntp-keygen/ntpkeygen.dsp@1.10, 2006-06-27 21:20:17+00:00, burnicki@pogo.udel.edu +4 -4
+    Use environment variable to specify the base path to openssl.
+
+  ports/winnt/ntpd/ntpd.dsp@1.27, 2006-06-27 21:20:17+00:00, burnicki@pogo.udel.edu +4 -4
+    Use environment variable to specify the base path to openssl.
+
+  ports/winnt/ntpdate/ntpdate.dsp@1.15, 2006-06-27 21:20:18+00:00, burnicki@pogo.udel.edu +2 -2
+    Use environment variable to specify the base path to openssl.
+
+  ports/winnt/ntpdc/ntpdc.dsp@1.17, 2006-06-27 21:20:18+00:00, burnicki@pogo.udel.edu +2 -2
+    Use environment variable to specify the base path to openssl.
+
+  ports/winnt/ntpq/ntpq.dsp@1.18, 2006-06-27 21:20:18+00:00, burnicki@pogo.udel.edu +2 -2
+    Use environment variable to specify the base path to openssl.
+
+  ports/winnt/ntptrace/ntptrace.dsp@1.10, 2006-06-27 21:20:18+00:00, burnicki@pogo.udel.edu +2 -2
+    Use environment variable to specify the base path to openssl.
+
+ChangeSet@1.1353.1.42, 2006-06-27 07:48:03-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P12
+  TAG: NTP_4_2_3P12
+
+  packageinfo.sh@1.5, 2006-06-27 07:47:53-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P12
+
+ChangeSet@1.1251.97.15, 2006-06-27 07:02:41-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P0_RC7
+  TAG: NTP_4_2_2P0_RC7
+
+  packageinfo.sh@1.27.4.1, 2006-06-27 07:02:33-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P0_RC7
+
+ChangeSet@1.1251.97.14, 2006-06-27 04:19:41-04:00, stenn@whimsy.udel.edu +2 -0
+  Resolve the ambiguity in the copyright file
+
+  NEWS@1.50.1.1, 2006-06-27 04:19:13-04:00, stenn@whimsy.udel.edu +2 -0
+    Resolve the ambiguity in the copyright file
+
+  html/copyright.html@1.33.1.1, 2006-06-27 04:19:12-04:00, stenn@whimsy.udel.edu +4 -4
+    Resolve the ambiguity in the copyright file
+
+ChangeSet@1.1353.1.40, 2006-06-26 07:50:16-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P11
+  TAG: NTP_4_2_3P11
+
+  packageinfo.sh@1.4, 2006-06-26 07:50:07-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P11
+
+ChangeSet@1.1251.97.13, 2006-06-26 07:03:11-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P0_RC6
+  TAG: NTP_4_2_2P0_RC6
+
+  packageinfo.sh@1.27.3.1, 2006-06-26 07:03:02-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P0_RC6
+
+ChangeSet@1.1251.97.12, 2006-06-26 03:23:59-04:00, stenn@whimsy.udel.edu +3 -0
+  Documentation updated from Dave Mills
+
+  html/ntpdsim.html@1.5, 2006-06-26 03:23:33-04:00, stenn@whimsy.udel.edu +3 -3
+    Documentation updated from Dave Mills
+
+  html/scripts/links7.txt@1.2, 2006-06-26 03:23:34-04:00, stenn@whimsy.udel.edu +1 -0
+    Documentation updated from Dave Mills
+
+  html/scripts/links9.txt@1.3, 2006-06-26 03:23:34-04:00, stenn@whimsy.udel.edu +1 -0
+    Documentation updated from Dave Mills
+
+ChangeSet@1.1251.97.11, 2006-06-26 03:06:50-04:00, stenn@whimsy.udel.edu +3 -0
+  New documentation files from Dave Mills
+
+  html/groups.html@1.1, 2006-06-26 03:06:10-04:00, stenn@whimsy.udel.edu +47 -0
+
+  html/groups.html@1.0, 2006-06-26 03:06:10-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-stable/html/groups.html
+
+  html/ntp_conf.html@1.1, 2006-06-26 03:06:11-04:00, stenn@whimsy.udel.edu +173 -0
+
+  html/ntp_conf.html@1.0, 2006-06-26 03:06:11-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-stable/html/ntp_conf.html
+
+  html/ntpdsim_new.html@1.1, 2006-06-26 03:06:11-04:00, stenn@whimsy.udel.edu +102 -0
+
+  html/ntpdsim_new.html@1.0, 2006-06-26 03:06:11-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-stable/html/ntpdsim_new.html
+
+ChangeSet@1.1251.97.10, 2006-06-26 02:52:54-04:00, stenn@whimsy.udel.edu +1 -0
+  Fix the ntp-keygen URL (Dave Mills) in authopt.html
+
+  html/authopt.html@1.40, 2006-06-26 02:52:07-04:00, stenn@whimsy.udel.edu +2 -2
+    Fix the ntp-keygen URL (Dave Mills) in authopt.html
+
+ChangeSet@1.1353.1.36, 2006-06-26 01:10:19-04:00, stenn@whimsy.udel.edu +1 -0
+  setsockopt() notes
+
+  ntpd/ntp_io.c@1.227, 2006-06-26 01:09:11-04:00, stenn@whimsy.udel.edu +3 -2
+    setsockopt() notes
+
+ChangeSet@1.1353.1.35, 2006-06-26 00:51:09-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 658] hppa2.0-hp-hpux10.20 cc needs a bigger -H for cpp
+
+  configure.ac@1.387, 2006-06-26 00:49:24-04:00, stenn@whimsy.udel.edu +8 -0
+    [Bug 658] hppa2.0-hp-hpux10.20 cc needs a bigger -H for cpp
+
+ChangeSet@1.1353.1.34, 2006-06-25 19:52:52-04:00, stenn@whimsy.udel.edu +1 -0
+  cleanup
+
+  sntp/Makefile.am@1.14, 2006-06-25 19:52:28-04:00, stenn@whimsy.udel.edu +2 -3
+    cleanup
+
+ChangeSet@1.1251.97.9, 2006-06-25 19:10:06-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 657]: IP_MULTICAST_LOOP uses a u_char value/size
+
+  ntpd/ntp_io.c@1.187.1.18, 2006-06-25 19:09:44-04:00, stenn@whimsy.udel.edu +5 -5
+    [Bug 657]: IP_MULTICAST_LOOP uses a u_char value/size
+
+ChangeSet@1.1251.97.8, 2006-06-25 17:00:47-04:00, stenn@whimsy.udel.edu +4 -0
+  distcheck fixes
+
+  BitKeeper/etc/ignore@1.35.1.2, 2006-06-25 16:56:53-04:00, stenn@whimsy.udel.edu +1 -0
+    added sntp/bincheck.mf
+
+  Makefile.am@1.48.1.5, 2006-06-25 16:58:56-04:00, stenn@whimsy.udel.edu +1 -0
+    cleanup; distcheck now works from sntp
+
+  bootstrap@1.4.3.1, 2006-06-25 16:59:01-04:00, stenn@whimsy.udel.edu +2 -0
+    cleanup; distcheck now works from sntp
+
+  sntp/Makefile.am@1.6.1.1, 2006-06-25 16:58:07-04:00, stenn@whimsy.udel.edu +5 -23
+    cleanup; distcheck now works from sntp
+
+ChangeSet@1.1353.1.31, 2006-06-25 07:51:20-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P10
+  TAG: NTP_4_2_3P10
+
+  packageinfo.sh@1.3, 2006-06-25 07:51:10-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P10
+
+ChangeSet@1.1251.97.7, 2006-06-25 07:03:22-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P0_RC5
+  TAG: NTP_4_2_2P0_RC5
+
+  packageinfo.sh@1.27.2.1, 2006-06-25 07:03:11-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P0_RC5
+
+ChangeSet@1.1353.1.30, 2006-06-25 04:50:29-04:00, stenn@whimsy.udel.edu +1 -0
+  Bail on an autogen error
+
+  bootstrap@1.11, 2006-06-25 04:50:01-04:00, stenn@whimsy.udel.edu +2 -1
+    Bail on an autogen error
+
+ChangeSet@1.1353.1.28, 2006-06-24 18:12:20-04:00, stenn@deacon.udel.edu +1 -0
+  fix quoting
+
+  BitKeeper/triggers/pre-resolve.licfix@1.2, 2006-06-24 18:11:52-04:00, stenn@deacon.udel.edu +1 -1
+    fix quoting
+
+ChangeSet@1.1251.98.4, 2006-06-24 18:45:02+00:00, kardel@pogo.udel.edu +1 -0
+  ntpq_ops.c:
+    fix a type punned pointer issue reported by gcc 4
+
+  ntpq/ntpq_ops.c@1.20.3.1, 2006-06-24 18:44:18+00:00, kardel@pogo.udel.edu +6 -6
+    fix a type punned pointer issue reported by gcc 4
+
+ChangeSet@1.1251.98.3, 2006-06-24 18:31:47+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_shm.c:
+    fix gcc 4 uninitialized warning
+
+  ntpd/refclock_shm.c@1.17, 2006-06-24 18:31:01+00:00, kardel@pogo.udel.edu +4 -0
+    fix gcc 4 uninitialized warning
+
+ChangeSet@1.1251.98.2, 2006-06-24 18:24:35+00:00, kardel@pogo.udel.edu +4 -0
+  data_mbg.c, refclock_parse.c, mbg_gps166.h, clk_rawdcf.c:
+    fix gcc 4 signedness complaints
+
+  include/mbg_gps166.h@1.5.1.2, 2006-06-24 18:24:02+00:00, kardel@pogo.udel.edu +7 -4
+    fix gcc 4 signedness complaints
+
+  libparse/clk_rawdcf.c@1.14, 2006-06-24 18:24:08+00:00, kardel@pogo.udel.edu +10 -4
+    fix gcc 4 signedness complaints
+
+  libparse/data_mbg.c@1.5.1.2, 2006-06-24 18:24:08+00:00, kardel@pogo.udel.edu +17 -14
+    fix gcc 4 signedness complaints
+
+  ntpd/refclock_parse.c@1.35.1.14, 2006-06-24 18:24:11+00:00, kardel@pogo.udel.edu +14 -7
+    fix gcc 4 signedness complaints
+
+ChangeSet@1.1251.98.1, 2006-06-24 17:39:54+00:00, kardel@pogo.udel.edu +4 -0
+  refclock_acts.c:
+    NetBSD Coverity CID 3797: bad return code check for open(2) fixed
+    (!fd replaced with fd < 0)
+  ntp_util.c:
+    NetBSD Coverity CID 3804: avoid file pointer leak
+  refclock_parse.c:
+    NetBSD Coverity CID 3796: possible NULL deref
+  ntpq.c:
+    NetBSD Coverity CID 3799: overrun static array (off by one) fixed
+
+  ntpd/ntp_util.c@1.36.2.2, 2006-06-24 17:23:41+00:00, kardel@pogo.udel.edu +1 -0
+    NetBSD Coverity CID 3804: avoid file pointer leak
+
+  ntpd/refclock_acts.c@1.25.1.2, 2006-06-24 17:29:57+00:00, kardel@pogo.udel.edu +1 -1
+    NetBSD Coverity CID 3797: bad return code check for open(2) fixed
+    (!fd replaced with fd < 0)
+
+  ntpd/refclock_parse.c@1.35.1.13, 2006-06-24 17:38:43+00:00, kardel@pogo.udel.edu +5 -1
+    NetBSD Coverity CID 3796: possible NULL deref
+
+  ntpq/ntpq.c@1.55.1.6, 2006-06-24 17:26:57+00:00, kardel@pogo.udel.edu +1 -1
+    NetBSD Coverity CID 3799: overrun static array (off by one) fixed
+
+ChangeSet@1.1353.1.26, 2006-06-24 16:50:45+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    implement fix for bug 614
+    socket fds will be moved out of the
+    stdio reserved area if at all possible
+
+  ntpd/ntp_io.c@1.224, 2006-06-24 16:48:27+00:00, kardel@pogo.udel.edu +106 -27
+    implement fix for bug 614
+    socket fds will be moved out of the
+    stdio reserved area if at all possible
+
+ChangeSet@1.1251.97.5, 2006-06-24 16:46:25+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    implement fix for bug 614
+    socket fds will be moved out of the stdio reserved
+    space if at all possible
+
+  ntpd/ntp_io.c@1.187.1.17, 2006-06-24 16:44:08+00:00, kardel@pogo.udel.edu +107 -27
+    implement fix for bug 614
+    socket fds will be moved out of the stdio reserved
+    space if at all possible
+
+ChangeSet@1.1353.1.25, 2006-06-23 07:48:33-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P9
+  TAG: NTP_4_2_3P9
+
+  packageinfo.sh@1.2, 2006-06-23 07:48:22-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P9
+
+ChangeSet@1.1251.97.4, 2006-06-23 07:02:47-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P0_RC4
+  TAG: NTP_4_2_2P0_RC4
+
+  packageinfo.sh@1.27.1.9, 2006-06-23 07:02:37-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P0_RC4
+
+ChangeSet@1.1251.97.3, 2006-06-22 17:07:33-04:00, stenn@whimsy.udel.edu +1 -0
+  Remove the license: key from etc/config to make the bk4 upgrade easier.
+
+  BitKeeper/etc/config@1.7.1.1, 2006-06-22 17:07:13-04:00, stenn@whimsy.udel.edu +2 -1
+    Remove the license: key from etc/config to make the bk4 upgrade easier.
+
+ChangeSet@1.1353.1.23, 2006-06-22 16:17:02-04:00, stenn@whimsy.udel.edu +2 -0
+  break the link between -stable and -dev copies of packageinfo.sh
+
+  BitKeeper/deleted/.del-packageinfo.sh~7f44215e99c0cd03@1.47, 2006-06-22 16:15:09-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: packageinfo.sh
+
+  packageinfo.sh@1.1, 2006-06-22 16:15:29-04:00, stenn@whimsy.udel.edu +26 -0
+
+  packageinfo.sh@1.0, 2006-06-22 16:15:29-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-632/packageinfo.sh
+
+ChangeSet@1.1251.97.2, 2006-06-22 19:28:28+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    bug 632: update kernel PPS offsets when PPS offset is re-configured
+
+  ntpd/refclock_parse.c@1.35.1.12, 2006-06-22 19:26:08+00:00, kardel@pogo.udel.edu +10 -4
+    bug 632: update kernel PPS offsets when PPS offset is re-configured
+
+ChangeSet@1.1353.1.22, 2006-06-22 07:03:29-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P8
+  TAG: NTP_4_2_3P8
+
+  packageinfo.sh@1.46, 2006-06-22 07:03:18-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P8
+
+ChangeSet@1.1353.1.21, 2006-06-22 00:29:56-04:00, stenn@whimsy.udel.edu +1 -0
+  cmd_args.c cleanup
+
+  ntpd/cmd_args.c@1.41, 2006-06-22 00:29:20-04:00, stenn@whimsy.udel.edu +3 -153
+    cleanup
+
+ChangeSet@1.1353.1.20, 2006-06-21 07:03:02-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P7
+  TAG: NTP_4_2_3P7
+
+  packageinfo.sh@1.45, 2006-06-21 07:02:55-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P7
+
+ChangeSet@1.1353.1.19, 2006-06-21 06:17:57-04:00, stenn@whimsy.udel.edu +1 -0
+  OSF4 does not have RTM_{NEW,DEL}ADDR
+
+  ntpd/ntp_io.c@1.223, 2006-06-21 06:17:28-04:00, stenn@whimsy.udel.edu +4 -0
+    OSF4 does not have RTM_{NEW,DEL}ADDR
+
+ChangeSet@1.1353.1.18, 2006-06-21 03:52:10-04:00, stenn@whimsy.udel.edu +1 -0
+  Use a pointer to feed the options to optionUsage() to avoid a struct copy
+
+  ntpd/cmd_args.c@1.40, 2006-06-21 03:51:43-04:00, stenn@whimsy.udel.edu +4 -4
+    Use a pointer to feed the options to optionUsage() to avoid a struct copy
+
+ChangeSet@1.1353.1.17, 2006-06-20 17:42:13-04:00, stenn@whimsy.udel.edu +2 -0
+  Protect COMMAND since we use it as an autogen keyword
+
+  ntpdc/ntpdc.c@1.52, 2006-06-20 17:40:31-04:00, stenn@whimsy.udel.edu +9 -4
+    Protect COMMAND since we use it as an autogen keyword
+
+  ntpq/ntpq.c@1.63, 2006-06-20 17:40:30-04:00, stenn@whimsy.udel.edu +10 -5
+    Protect COMMAND since we use it as an autogen keyword
+
+ChangeSet@1.1353.1.16, 2006-06-20 07:03:15-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P6
+  TAG: NTP_4_2_3P6
+
+  packageinfo.sh@1.44, 2006-06-20 07:03:04-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P6
+
+ChangeSet@1.1353.1.14, 2006-06-20 03:15:38-04:00, stenn@whimsy.udel.edu +1 -0
+  Fix the configure.ac check for rt_msghdr
+
+  configure.ac@1.386, 2006-06-20 03:15:13-04:00, stenn@whimsy.udel.edu +2 -3
+    Fix the configure.ac check for rt_msghdr
+
+ChangeSet@1.1353.1.13, 2006-06-19 07:24:31-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P5
+  TAG: NTP_4_2_3P5
+
+  packageinfo.sh@1.42, 2006-06-19 07:24:21-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P5
+
+ChangeSet@1.1251.97.1, 2006-06-19 07:02:56-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P0_RC3
+  TAG: NTP_4_2_2P0_RC3
+
+  packageinfo.sh@1.27.1.8, 2006-06-19 07:02:45-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P0_RC3
+
+ChangeSet@1.1353.1.12, 2006-06-19 04:16:30-04:00, stenn@whimsy.udel.edu +1 -0
+  Update the NEWS file for the dynamic interface scan fix
+
+  NEWS@1.52, 2006-06-19 04:15:56-04:00, stenn@whimsy.udel.edu +1 -0
+    Update the NEWS file for the dynamic interface scan fix
+
+ChangeSet@1.1251.96.1, 2006-06-19 02:31:54-04:00, stenn@pogo.udel.edu +1 -0
+  Avoid hardcoded path to bash for the bootstrap script
+
+  bootstrap@1.4.2.1, 2006-06-19 02:31:43-04:00, stenn@pogo.udel.edu +1 -1
+    Avoid hardcoded path to bash for the bootstrap script
+
+ChangeSet@1.1353.3.8, 2006-06-18 20:14:55-04:00, stenn@deacon.udel.edu +1 -0
+  Bash might not be in /bin/bash (for bootstrap)
+
+  bootstrap@1.9, 2006-06-18 20:14:47-04:00, stenn@deacon.udel.edu +9 -6
+    Bash might not be in /bin/bash (for bootstrap)
+
+ChangeSet@1.1353.3.7, 2006-06-18 20:12:51-04:00, stenn@deacon.udel.edu +1 -0
+  ignore:
+    added libopts/*
+
+  BitKeeper/etc/ignore@1.50, 2006-06-18 20:12:06-04:00, stenn@deacon.udel.edu +1 -0
+    added libopts/*
+
+ChangeSet@1.1251.94.19, 2006-06-18 20:09:27-04:00, stenn@deacon.udel.edu +1 -0
+  bash (for the bootstrap script) might not be /bin/bash
+
+  bootstrap@1.4.1.1, 2006-06-18 20:09:18-04:00, stenn@deacon.udel.edu +1 -1
+    bash (for the bootstrap script) might not be /bin/bash
+
+ChangeSet@1.1353.1.9, 2006-06-18 22:18:50+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    import fix for bug 637
+
+  ntpd/ntp_io.c@1.221, 2006-06-18 22:18:19+00:00, kardel@pogo.udel.edu +22 -9
+    import fix for bug 637
+
+ChangeSet@1.1353.3.6, 2006-06-18 07:24:11-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P4
+  TAG: NTP_4_2_3P4
+
+  packageinfo.sh@1.40, 2006-06-18 07:24:01-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P4
+
+ChangeSet@1.1251.94.18, 2006-06-18 07:03:14-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P0_RC2
+  TAG: NTP_4_2_2P0_RC2
+
+  packageinfo.sh@1.27.1.7, 2006-06-18 07:03:05-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P0_RC2
+
+ChangeSet@1.1353.3.5, 2006-06-18 02:18:46-04:00, stenn@whimsy.udel.edu +1 -0
+  The fix for bug 637 needs work for ntp-dev
+
+  ntpd/ntp_io.c@1.218.1.1, 2006-06-18 02:18:15-04:00, stenn@whimsy.udel.edu +2 -0
+    The fix for bug 637 needs work for ntp-dev
+
+ChangeSet@1.1353.3.4, 2006-06-18 02:14:55-04:00, stenn@whimsy.udel.edu +1 -0
+  ntp-dev uses repotype=dev
+
+  packageinfo.sh@1.39, 2006-06-18 02:14:34-04:00, stenn@whimsy.udel.edu +2 -2
+    ntp-dev uses repotype=dev
+
+ChangeSet@1.1251.94.17, 2006-06-18 02:05:42-04:00, stenn@whimsy.udel.edu +2 -0
+  Make the license check triggers work with bk3 and bk4
+
+  BitKeeper/triggers/post-incoming.license-warn@1.6, 2006-06-18 02:05:11-04:00, stenn@whimsy.udel.edu +9 -3
+    Make the license check triggers work with bk3 and bk4
+
+  BitKeeper/triggers/pre-resolve.license-chk@1.5.1.2, 2006-06-18 02:05:12-04:00, stenn@whimsy.udel.edu +10 -4
+    Make the license check triggers work with bk3 and bk4
+
+ChangeSet@1.1251.94.15, 2006-06-17 22:47:38-04:00, stenn@whimsy.udel.edu +2 -0
+  debug
+
+  BitKeeper/triggers/post-incoming.license-warn@1.5, 2006-06-17 22:47:19-04:00, stenn@whimsy.udel.edu +1 -0
+    debug
+
+  BitKeeper/triggers/pre-resolve.license-chk@1.5.1.1, 2006-06-17 22:47:19-04:00, stenn@whimsy.udel.edu +1 -0
+    debug
+
+ChangeSet@1.1353.3.1, 2006-06-17 22:32:24-04:00, stenn@whimsy.udel.edu +1 -0
+  typo
+
+  BitKeeper/triggers/pre-resolve.license-chk@1.3.1.1, 2006-06-17 22:31:40-04:00, stenn@whimsy.udel.edu +0 -1
+    typo
+
+ChangeSet@1.1251.94.14, 2006-06-17 22:05:18-04:00, stenn@whimsy.udel.edu +1 -0
+  typo
+
+  BitKeeper/triggers/pre-resolve.license-chk@1.5, 2006-06-17 22:04:50-04:00, stenn@whimsy.udel.edu +0 -1
+    typo
+
+ChangeSet@1.1353.1.7, 2006-06-18 00:01:22+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    skip interfaces that cannot be bound to
+
+  ntpd/ntp_io.c@1.219, 2006-06-17 23:59:09+00:00, kardel@pogo.udel.edu +1 -0
+    skip interfaces that cannot be bound to
+
+ChangeSet@1.1251.94.13, 2006-06-17 19:57:47-04:00, stenn@whimsy.udel.edu +2 -0
+  More bk-4 license check trigger cleanup
+
+  BitKeeper/triggers/post-incoming.license-warn@1.4, 2006-06-17 19:57:29-04:00, stenn@whimsy.udel.edu +2 -0
+    More bk-4 license check trigger cleanup
+
+  BitKeeper/triggers/pre-resolve.license-chk@1.4, 2006-06-17 19:57:29-04:00, stenn@whimsy.udel.edu +2 -0
+    More bk-4 license check trigger cleanup
+
+ChangeSet@1.1251.95.1, 2006-06-17 23:09:55+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    move decision into seperate function and insure compilability on
+    non IPv6 platforms
+
+  ntpd/ntp_io.c@1.187.1.16, 2006-06-17 23:08:26+00:00, kardel@pogo.udel.edu +24 -8
+    move decision into seperate function and insure compilability on
+    non IPv6 platforms
+
+ChangeSet@1.1251.94.12, 2006-06-17 18:42:11-04:00, stenn@whimsy.udel.edu +2 -0
+  More bk-4 license check trigger cleanup
+
+  BitKeeper/triggers/post-incoming.license-warn@1.3, 2006-06-17 18:41:50-04:00, stenn@whimsy.udel.edu +11 -4
+    More bk-4 license check trigger cleanup
+
+  BitKeeper/triggers/pre-resolve.license-chk@1.3, 2006-06-17 18:41:50-04:00, stenn@whimsy.udel.edu +12 -4
+    More bk-4 license check trigger cleanup
+
+ChangeSet@1.1251.94.11, 2006-06-17 13:53:20-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 637] Ignore UP in*addr_any interfaces
+
+  ntpd/ntp_io.c@1.187.1.15, 2006-06-17 13:53:00-04:00, stenn@whimsy.udel.edu +15 -0
+    [Bug 637] Ignore UP in*addr_any interfaces
+
+ChangeSet@1.1251.94.10, 2006-06-17 13:47:07-04:00, stenn@whimsy.udel.edu +2 -0
+  Deal with -stable rcpoint
+
+  packageinfo.sh@1.27.1.6, 2006-06-17 13:46:47-04:00, stenn@whimsy.udel.edu +1 -0
+    Deal with -stable rcpoint
+
+  scripts/VersionName@1.4, 2006-06-17 13:46:48-04:00, stenn@whimsy.udel.edu +10 -0
+    Deal with -stable rcpoint
+
+ChangeSet@1.1251.94.9, 2006-06-17 12:37:23-04:00, stenn@whimsy.udel.edu +2 -0
+   bk-3 uses sccscat, bk-4 uses annotate
+
+  BitKeeper/triggers/post-incoming.license-warn@1.2, 2006-06-17 12:37:04-04:00, stenn@whimsy.udel.edu +10 -1
+     bk-3 uses sccscat, bk-4 uses annotate
+
+  BitKeeper/triggers/pre-resolve.license-chk@1.2, 2006-06-17 12:37:04-04:00, stenn@whimsy.udel.edu +9 -1
+     bk-3 uses sccscat, bk-4 uses annotate
+
+ChangeSet@1.1353.1.4, 2006-06-17 07:21:46-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P3
+  TAG: NTP_4_2_3P3
+
+  packageinfo.sh@1.37, 2006-06-17 07:21:37-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P3
+
+ChangeSet@1.1251.94.8, 2006-06-17 07:02:53-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P0_RC
+  TAG: NTP_4_2_2P0_RC
+
+  packageinfo.sh@1.27.1.5, 2006-06-17 07:02:44-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P0_RC
+
+ChangeSet@1.1353.1.2, 2006-06-16 18:33:41-04:00, stenn@pogo.udel.edu +4 -0
+  Makefile.am:
+    "make distcheck" is now happy with the libopts/ stuff
+  configure.ac, Makefile.am:
+    [Bug 635] get libopts/ properly distributed
+    [Bug 635] Properly distribute libopts/ .
+  Makefile.am:
+    Distribute copyright.def and debug-opt.def
+  debug-opt.def:
+    Change mode to -rw-rw-rw-
+
+  Makefile.am@1.66, 2006-06-16 18:33:23-04:00, stenn@pogo.udel.edu +61 -57
+    "make distcheck" is now happy with the libopts/ stuff
+
+  Makefile.am@1.65, 2006-06-16 15:49:25-04:00, stenn@pogo.udel.edu +1 -1
+    [Bug 635] get libopts/ properly distributed
+
+  Makefile.am@1.64, 2006-06-16 03:49:12-04:00, stenn@pogo.udel.edu +6 -3
+    [Bug 635] Properly distribute libopts/ .
+
+  configure.ac@1.385, 2006-06-16 15:49:26-04:00, stenn@pogo.udel.edu +1 -2
+    [Bug 635] get libopts/ properly distributed
+
+  configure.ac@1.384, 2006-06-16 03:49:13-04:00, stenn@pogo.udel.edu +1 -0
+    [Bug 635] Properly distribute libopts/ .
+
+  include/Makefile.am@1.23, 2006-06-16 03:47:49-04:00, stenn@pogo.udel.edu +1 -1
+    Distribute copyright.def and debug-opt.def
+
+  include/debug-opt.def@1.3, 2006-06-16 03:46:23-04:00, stenn@pogo.udel.edu +0 -0
+    Change mode to -rw-rw-rw-
+
+ChangeSet@1.1251.94.7, 2006-06-16 18:02:54-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 633] Avoid writing files in srcdir
+
+  scripts/genver@1.4, 2006-06-16 17:58:49-04:00, stenn@whimsy.udel.edu +8 -8
+    [Bug 633] Avoid writing files in srcdir
+
+ChangeSet@1.1351.1.1, 2006-06-16 02:54:50-04:00, stenn@pogo.udel.edu +1 -0
+  Use separate copies of libopts for ntp and sntp
+
+  bootstrap@1.6.1.1, 2006-06-16 02:54:38-04:00, stenn@pogo.udel.edu +7 -0
+    Use separate copies of libopts for ntp and sntp
+
+ChangeSet@1.1353, 2006-06-15 07:12:32-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P2
+  TAG: NTP_4_2_3P2
+
+  packageinfo.sh@1.35, 2006-06-15 07:12:20-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P2
+
+ChangeSet@1.1352, 2006-06-15 04:46:11-04:00, stenn@whimsy.udel.edu +1 -0
+  Try harder to get sntp/libopts/Makefile.in to get the correct srcdir path
+
+  bootstrap@1.7, 2006-06-15 04:45:42-04:00, stenn@whimsy.udel.edu +4 -0
+    Try harder to get sntp/libopts/Makefile.in to get the correct srcdir path
+
+ChangeSet@1.1347.2.3, 2006-06-13 07:27:18-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P1
+  TAG: NTP_4_2_3P1
+
+  packageinfo.sh@1.34, 2006-06-13 07:27:10-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P1
+
+ChangeSet@1.1251.94.6, 2006-06-13 07:02:41-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P0_RC
+  TAG: NTP_4_2_2P0_RC
+
+  packageinfo.sh@1.27.1.4, 2006-06-13 07:02:31-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2P0_RC
+
+ChangeSet@1.1251.94.5, 2006-06-13 04:43:41-04:00, stenn@whimsy.udel.edu +1 -0
+  Distribute the bootstrap script
+
+  Makefile.am@1.48.1.4, 2006-06-13 04:43:22-04:00, stenn@whimsy.udel.edu +1 -0
+    Distribute the bootstrap script
+
+ChangeSet@1.1347.2.1, 2006-06-12 07:47:44-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3P0
+  TAG: NTP_4_2_3P0
+
+  packageinfo.sh@1.32, 2006-06-12 07:47:36-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3P0
+
+ChangeSet@1.1251.94.4, 2006-06-12 07:03:05-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2P0_RC
+  TAG: NTP_4_2_2P0_RC
+
+  packageinfo.sh@1.27.1.3, 2006-06-12 07:02:55-04:00, stenn@whimsy.udel.edu +2 -2
+    NTP_4_2_2P0_RC
+
+ChangeSet@1.1347.1.10, 2006-06-12 01:42:27-04:00, stenn@whimsy.udel.edu +1 -0
+  Explain how to disable the trigger stuff
+
+  BitKeeper/triggers/trigger.README@1.4, 2006-06-12 01:41:47-04:00, stenn@whimsy.udel.edu +6 -0
+    Explain how to disable the trigger stuff
+
+ChangeSet@1.1347.1.9, 2006-06-12 01:37:08-04:00, stenn@whimsy.udel.edu +1 -0
+  cleanup
+
+  packageinfo.sh@1.31, 2006-06-12 01:36:39-04:00, stenn@whimsy.udel.edu +2 -2
+    cleanup
+
+ChangeSet@1.1251.94.3, 2006-06-11 18:38:11-04:00, stenn@whimsy.udel.edu +2 -0
+  Install license check triggers.
+
+  BitKeeper/triggers/post-incoming.license-warn@1.1, 2006-06-11 18:35:50-04:00, stenn@whimsy.udel.edu +14 -0
+
+  BitKeeper/triggers/post-incoming.license-warn@1.0, 2006-06-11 18:35:50-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-stable/BitKeeper/triggers/post-incoming.license-warn
+
+  BitKeeper/triggers/pre-resolve.license-chk@1.1, 2006-06-11 18:35:51-04:00, stenn@whimsy.udel.edu +21 -0
+
+  BitKeeper/triggers/pre-resolve.license-chk@1.0, 2006-06-11 18:35:51-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-stable/BitKeeper/triggers/pre-resolve.license-chk
+
+ChangeSet@1.1251.94.2, 2006-06-11 17:49:08-04:00, stenn@whimsy.udel.edu +1 -0
+  Add some internal distribution checks
+
+  packageinfo.sh@1.27.1.2, 2006-06-11 17:48:43-04:00, stenn@whimsy.udel.edu +3 -3
+    Add some internal distribution checks
+
+ChangeSet@1.1347.1.7, 2006-06-11 01:34:07+00:00, rick@pogo.udel.edu +1 -0
+  pre-resolve.fixlic:
+  Block bad repos from being pulled into this repo,
+  or if this repo is bad, stops it from being used.
+  
+  Please do a 'bk fix -c' and edit pre-resolve.fixlic
+  to either rename it or make it better.
+  Then bk new them and bk commit.
+  Thanks.  -- Rick Smith
+
+  BitKeeper/triggers/pre-resolve.licfix@1.1, 2006-06-11 01:33:05+00:00, rick@pogo.udel.edu +32 -0
+
+  BitKeeper/triggers/pre-resolve.licfix@1.0, 2006-06-11 01:33:05+00:00, rick@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/lm/ntp-fixed.license/BitKeeper/triggers/pre-resolve.licfix
+
+ChangeSet@1.1347.1.6, 2006-06-10 01:37:28-04:00, stenn@whimsy.udel.edu +2 -0
+  bootstrap:
+    there was a libopts dependency name problem with the old autoreconf sequence - change it to something slower that works.
+  flock-build:
+    lose --with-sntp as it is no longer needed
+
+  bootstrap@1.6, 2006-06-10 01:36:09-04:00, stenn@whimsy.udel.edu +2 -2
+    there was a libopts dependency name problem with the old autoreconf sequence - change it to something slower that works.
+
+  flock-build@1.36, 2006-06-10 01:34:40-04:00, stenn@whimsy.udel.edu +1 -1
+    lose --with-sntp as it is no longer needed
+
+ChangeSet@1.1347.1.5, 2006-06-09 19:30:12-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_3
+  TAG: NTP_4_2_3
+
+  packageinfo.sh@1.29, 2006-06-09 19:29:55-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_3
+
+ChangeSet@1.1251.94.1, 2006-06-06 16:19:55-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_2
+  TAG: NTP_4_2_2
+
+  packageinfo.sh@1.27.1.1, 2006-06-06 16:19:45-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_2
+
+ChangeSet@1.1347.1.4, 2006-06-06 05:05:56-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 500] sntp is now part of the team
+
+  Makefile.am@1.62, 2006-06-06 05:04:23-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 500] sntp is now part of the team
+
+  configure.ac@1.381.1.1, 2006-06-06 05:04:28-04:00, stenn@whimsy.udel.edu +1 -20
+    [Bug 500] sntp is now part of the team
+
+ChangeSet@1.1350, 2006-06-06 08:47:18+00:00, kardel@pogo.udel.edu +2 -0
+  ntpdbase-opts.def:
+    add U option for update interval for
+    interface scan
+  cmd_args.c:
+    adjust argument processing to a number
+
+  ntpd/cmd_args.c@1.39, 2006-06-06 08:45:49+00:00, kardel@pogo.udel.edu +5 -5
+    adjust argument processing to a number
+
+  ntpd/ntpdbase-opts.def@1.2.1.1, 2006-06-06 08:46:25+00:00, kardel@pogo.udel.edu +13 -0
+    add U option for update interval for
+    interface scan
+
+ChangeSet@1.1347.1.3, 2006-06-06 04:44:33-04:00, stenn@deacon.udel.edu +1 -0
+  Mention autogen in NEWS
+
+  NEWS@1.51, 2006-06-06 04:44:26-04:00, stenn@deacon.udel.edu +2 -0
+    Mention autogen in NEWS
+
+ChangeSet@1.1347.1.2, 2006-06-06 04:21:52-04:00, stenn@deacon.udel.edu +14 -0
+  Copyright cleanup
+
+  clockstuff/Makefile.am@1.5, 2006-06-06 04:14:26-04:00, stenn@deacon.udel.edu +2 -0
+    Copyright cleanup
+
+  clockstuff/clktest-opts.def@1.3, 2006-06-06 04:14:26-04:00, stenn@deacon.udel.edu +0 -22
+    Copyright cleanup
+
+  include/copyright.def@1.3, 2006-06-06 04:14:33-04:00, stenn@deacon.udel.edu +3 -2
+    Copyright cleanup
+
+  ntpd/Makefile.am@1.48, 2006-06-06 04:14:58-04:00, stenn@deacon.udel.edu +6 -6
+    Copyright cleanup
+
+  ntpd/ntpd-opts.def@1.3, 2006-06-06 04:14:58-04:00, stenn@deacon.udel.edu +1 -28
+    Copyright cleanup
+
+  ntpd/ntpdbase-opts.def@1.3, 2006-06-06 04:14:58-04:00, stenn@deacon.udel.edu +0 -13
+    Copyright cleanup
+
+  ntpd/ntpdsim-opts.def@1.3, 2006-06-06 04:14:58-04:00, stenn@deacon.udel.edu +1 -28
+    Copyright cleanup
+
+  ntpdc/Makefile.am@1.30, 2006-06-06 04:15:06-04:00, stenn@deacon.udel.edu +3 -3
+    Copyright cleanup
+
+  ntpdc/ntpdc-opts.def@1.9, 2006-06-06 04:15:06-04:00, stenn@deacon.udel.edu +0 -22
+    Copyright cleanup
+
+  ntpq/Makefile.am@1.22, 2006-06-06 04:15:10-04:00, stenn@deacon.udel.edu +3 -3
+    Copyright cleanup
+
+  ntpq/ntpq-opts.def@1.6, 2006-06-06 04:15:10-04:00, stenn@deacon.udel.edu +1 -42
+    Copyright cleanup
+
+  sntp/sntp-opts.def@1.3, 2006-06-06 04:15:29-04:00, stenn@deacon.udel.edu +3 -24
+    Copyright cleanup
+
+  util/Makefile.am@1.31, 2006-06-06 04:15:34-04:00, stenn@deacon.udel.edu +3 -3
+    Copyright cleanup
+
+  util/ntp-keygen-opts.def@1.3, 2006-06-06 04:15:34-04:00, stenn@deacon.udel.edu +3 -32
+    Copyright cleanup
+
+ChangeSet@1.1347.1.1, 2006-06-06 03:06:10-04:00, stenn@whimsy.udel.edu +2 -0
+  re-enable auto-gen
+
+  bootstrap@1.5, 2006-06-06 03:05:34-04:00, stenn@whimsy.udel.edu +14 -14
+    Re-enable autogen now that we need it.
+
+  ntpd/ntpd.c@1.77.1.1, 2006-06-06 03:03:16-04:00, stenn@whimsy.udel.edu +0 -2
+    lose some old debug output
+
+ChangeSet@1.1251.80.72, 2006-06-05 21:31:04-04:00, stenn@whimsy.udel.edu +1 -0
+  ntp-4.2.3
+
+  packageinfo.sh@1.28, 2006-06-05 21:30:39-04:00, stenn@whimsy.udel.edu +1 -1
+    ntp-4.2.3
+
+ChangeSet@1.1251.80.71, 2006-06-05 19:53:12-04:00, stenn@whimsy.udel.edu +3 -0
+  ntp-4.2.2
+
+  NEWS@1.50, 2006-06-05 19:21:53-04:00, stenn@whimsy.udel.edu +6 -1
+    Release ntp-4.2.2
+
+  packageinfo.sh@1.27, 2006-06-05 19:22:00-04:00, stenn@whimsy.udel.edu +4 -4
+    Release ntp-4.2.2
+
+  scripts/VersionName@1.3, 2006-06-05 19:51:58-04:00, stenn@whimsy.udel.edu +1 -0
+    clean up a corner case
+
+ChangeSet@1.1251.80.70, 2006-05-29 07:02:40-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P257_RC
+  TAG: NTP_4_2_1P257_RC
+
+  packageinfo.sh@1.26, 2006-05-29 07:02:30-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P257_RC
+
+ChangeSet@1.1251.72.45, 2006-05-27 11:04:43+00:00, kardel@pogo.udel.edu +6 -0
+  monopt.html:
+    document conditional nature of process timing debugging
+  ntpd.c:
+    make process timing debug conditional
+    cleanup conditional compilation
+  ntp_util.c, ntp_io.c:
+    make process timing debug conditional
+  ntpd.h:
+    cleanup conditional compile cruft in ntpd.c by defining a macro
+  configure.ac:
+    make process timing debug code conditional (default off)
+
+  configure.ac@1.359.1.30, 2006-05-27 10:59:02+00:00, kardel@pogo.udel.edu +9 -0
+    make process timing debug code conditional (default off)
+
+  html/monopt.html@1.22, 2006-05-27 11:02:54+00:00, kardel@pogo.udel.edu +1 -1
+    document conditional nature of process timing debugging
+
+  include/ntpd.h@1.82.1.16, 2006-05-27 10:59:44+00:00, kardel@pogo.udel.edu +5 -0
+    cleanup conditional compile cruft in ntpd.c by defining a macro
+
+  ntpd/ntp_io.c@1.217, 2006-05-27 11:00:51+00:00, kardel@pogo.udel.edu +9 -7
+    make process timing debug conditional
+
+  ntpd/ntp_util.c@1.41, 2006-05-27 11:01:08+00:00, kardel@pogo.udel.edu +3 -3
+    make process timing debug conditional
+
+  ntpd/ntpd.c@1.61.1.26, 2006-05-27 11:01:15+00:00, kardel@pogo.udel.edu +11 -21
+    make process timing debug conditional
+    cleanup conditional compilation
+
+ChangeSet@1.1251.80.68, 2006-05-27 07:02:40-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P256_RC
+  TAG: NTP_4_2_1P256_RC
+
+  packageinfo.sh@1.25, 2006-05-27 07:02:32-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P256_RC
+
+ChangeSet@1.1251.93.1, 2006-05-26 17:08:21+00:00, kardel@pogo.udel.edu +2 -0
+  ntpdc.h:
+    bug 621
+    change arg_v to struct, add type field
+  ntpdc.c:
+    bug 621
+    change arg_v to struct, add type field, initialize string member
+    always as the 'new' parsing code seems to make that previously
+    unfounded assumption.
+
+  ntpdc/ntpdc.c@1.40.2.6, 2006-05-26 17:05:10+00:00, kardel@pogo.udel.edu +9 -2
+    bug 621
+    change arg_v to struct, add type field, initialize string member
+    always as the 'new' parsing code seems to make that previously
+    unfounded assumption.
+
+  ntpdc/ntpdc.h@1.7, 2006-05-26 17:07:45+00:00, kardel@pogo.udel.edu +4 -2
+    bug 621
+    change arg_v to struct, add type field
+
+ChangeSet@1.1251.80.67, 2006-05-26 14:40:03+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    bug 619
+    delay io_addclock() even further as suggested by Ronan Flood
+
+  ntpd/refclock_parse.c@1.35.1.11, 2006-05-26 14:38:20+00:00, kardel@pogo.udel.edu +25 -19
+    bug 619
+    delay io_addclock() even further as suggested by Ronan Flood
+
+ChangeSet@1.1251.80.66, 2006-05-26 07:02:46-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P255_RC
+  TAG: NTP_4_2_1P255_RC
+
+  packageinfo.sh@1.24, 2006-05-26 07:02:38-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P255_RC
+
+ChangeSet@1.1251.92.3, 2006-05-25 18:25:23+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    bug #619
+    terminate parse io engine after de-registering
+    from refclock io engine
+
+  ntpd/refclock_parse.c@1.35.3.3, 2006-05-25 18:24:49+00:00, kardel@pogo.udel.edu +12 -7
+    bug #619
+    terminate parse io engine after de-registering
+    from refclock io engine
+
+ChangeSet@1.1251.92.2, 2006-05-25 18:08:49+00:00, kardel@pogo.udel.edu +2 -0
+  ntp_io.c:
+    add missing BLOCKIO()/UNBLOCKIO() calls in refclock io
+    handling found during analysis for bug #619
+  refclock_parse.c:
+    bug #619
+    complete refclock io structure initialization *before* inserting it into the
+    refclock input machine (avoids null pointer deref)
+
+  ntpd/ntp_io.c@1.187.1.14, 2006-05-25 17:47:54+00:00, kardel@pogo.udel.edu +4 -0
+    add missing BLOCKIO()/UNBLOCKIO() calls in refclock io
+    handling found during analysis for bug #619
+
+  ntpd/refclock_parse.c@1.35.3.2, 2006-05-25 17:44:26+00:00, kardel@pogo.udel.edu +19 -12
+    bug #619
+    complete refclock io structure initialization *before* inserting it into the
+    refclock input machine (avoids null pointer deref)
+
+ChangeSet@1.1251.92.1, 2006-05-25 07:02:50-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P254_RC
+  TAG: NTP_4_2_1P254_RC
+
+  packageinfo.sh@1.23, 2006-05-25 07:02:41-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P254_RC
+
+ChangeSet@1.1251.72.42, 2006-05-25 07:55:42+00:00, kardel@pogo.udel.edu +6 -0
+  monopt.html:
+    document timingstats (only available when daemon is compiled with DEBUG)
+  ntpd.h, ntpd.c, ntp_util.c:
+    support collection of timing data
+  ntp_io.c:
+    implement SO_TIMESTAMP for systems that have it
+    support collection of timing data
+    fix io signal blocking in refclock io handling functions
+  ntp_crypto.c:
+    return OK when interface is not bound
+
+  html/monopt.html@1.21, 2006-05-25 07:36:35+00:00, kardel@pogo.udel.edu +5 -1
+    document timingstats (only available when daemon is compiled with DEBUG)
+
+  include/ntpd.h@1.82.1.15, 2006-05-25 06:55:55+00:00, kardel@pogo.udel.edu +6 -0
+    support collection of timing data
+
+  ntpd/ntp_crypto.c@1.107, 2006-05-25 06:52:30+00:00, kardel@pogo.udel.edu +1 -1
+    return OK when interface is not bound
+
+  ntpd/ntp_io.c@1.215, 2006-05-25 06:53:01+00:00, kardel@pogo.udel.edu +119 -12
+    implement SO_TIMESTAMP for systems that have it
+    support collection of timing data
+    fix io signal blocking in refclock io handling functions
+
+  ntpd/ntp_util.c@1.40, 2006-05-25 06:54:36+00:00, kardel@pogo.udel.edu +39 -0
+    support collection of timing data
+
+  ntpd/ntpd.c@1.61.1.25, 2006-05-25 06:54:47+00:00, kardel@pogo.udel.edu +43 -17
+    support collection of timing data
+
+ChangeSet@1.1251.80.62, 2006-05-24 22:01:55-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #504 Allow forced DNS retry even on failure only if macro FORCE_DNSRETRY is defined
+
+  ntpd/ntp_intres.c@1.47, 2006-05-24 22:01:00-04:00, mayer@pogo.udel.edu +13 -0
+    Bug #504 Allow forced DNS retry even on failure only if macro FORCE_DNSRETRY is defined
+
+ChangeSet@1.1251.80.61, 2006-05-21 14:57:46-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #614 Remove errno manipulation from move_fd()
+
+  ntpd/ntp_io.c@1.187.1.13, 2006-05-21 14:57:23-04:00, mayer@pogo.udel.edu +1 -3
+    Bug #614 Remove errno manipulation from move_fd()
+
+ChangeSet@1.1251.91.1, 2006-05-21 12:10:13-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #614 Changed dup_fd to move_fd and remove for Windows
+
+  ntpd/ntp_io.c@1.187.1.12, 2006-05-21 12:09:34-04:00, mayer@pogo.udel.edu +5 -5
+    Bug #614 Changed dup_fd to move_fd and remove for Windows
+
+ChangeSet@1.1251.80.59, 2006-05-21 07:03:00-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P253_RC
+  TAG: NTP_4_2_1P253_RC
+
+  packageinfo.sh@1.22, 2006-05-21 07:02:52-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P253_RC
+
+ChangeSet@1.1251.80.57, 2006-05-20 19:15:50-04:00, mayer@pogo.udel.edu +2 -0
+  Fix Bug #612: Erroneous FAR macro
+
+  libntp/ntp_rfc2553.c@1.27.1.4, 2006-05-20 19:14:58-04:00, mayer@pogo.udel.edu +2 -5
+    Fix Bug #612: Erroneous FAR macro
+
+  ports/winnt/libntp/dnslookup.c@1.3, 2006-05-20 19:15:27-04:00, mayer@pogo.udel.edu +3 -3
+    Fix Bug #612: Erroneous FAR macro
+
+ChangeSet@1.1251.90.5, 2006-05-20 18:16:07-04:00, stenn@whimsy.udel.edu +2 -0
+  Update the UDel host lists and handle the PWD better
+
+  br-flock@1.9, 2006-05-20 18:15:44-04:00, stenn@whimsy.udel.edu +1 -1
+    Update the UDel host lists and handle the PWD better
+
+  flock-build@1.35, 2006-05-20 18:15:45-04:00, stenn@whimsy.udel.edu +2 -3
+    Update the UDel host lists and handle the PWD better
+
+ChangeSet@1.1251.80.56, 2006-05-20 17:01:51-04:00, mayer@pogo.udel.edu +3 -0
+   Bug fixes for #611, 612, 614 and 530
+
+  libntp/ntp_rfc2553.c@1.27.1.3, 2006-05-20 16:59:38-04:00, mayer@pogo.udel.edu +4 -2
+    Bug #612 Added include for netent structure
+
+  ntpd/ntp_intres.c@1.46, 2006-05-20 17:01:06-04:00, mayer@pogo.udel.edu +1 -1
+    Bug #611 Check for various EAI_* macros
+
+  ntpd/ntp_io.c@1.187.1.11, 2006-05-20 16:58:11-04:00, mayer@pogo.udel.edu +6 -4
+    Bug #530 and #614 fixes to add comments
+
+ChangeSet@1.1251.80.55, 2006-05-16 07:58:39-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #614 Add FOPEN_MAX as a parameter for dup_fd() usage. Also this is the fix for Bug #530
+
+  ntpd/ntp_io.c@1.187.1.10, 2006-05-16 07:58:06-04:00, mayer@pogo.udel.edu +5 -2
+    Bug #614 Add FOPEN_MAX as a parameter for dup_fd() usage. Also this is the fix for Bug #530
+
+ChangeSet@1.1251.80.54, 2006-05-15 19:45:34-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #611. Refix to add additional condition for Win32
+
+  ntpd/ntp_intres.c@1.45, 2006-05-15 19:44:22-04:00, mayer@pogo.udel.edu +2 -0
+    Bug #611. Refix to add additional condition for Win32
+
+ChangeSet@1.1251.80.53, 2006-05-15 19:30:22-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #614 Fix duplicate descriptor code and properly handle error conditions
+
+  ntpd/ntp_io.c@1.187.1.9, 2006-05-15 19:29:52-04:00, mayer@pogo.udel.edu +6 -1
+    Bug #614 Fix duplicate descriptor code and properly handle error conditions
+
+ChangeSet@1.1251.90.4, 2006-05-13 07:02:51-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P252_RC
+  TAG: NTP_4_2_1P252_RC
+
+  packageinfo.sh@1.21, 2006-05-13 07:02:38-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P252_RC
+
+ChangeSet@1.1251.90.3, 2006-05-12 14:57:38-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 611] Fix based on Danny's comment
+
+  ntpd/ntp_intres.c@1.44, 2006-05-12 14:57:20-04:00, stenn@whimsy.udel.edu +2 -0
+    [Bug 611] Fix based on Danny's comment
+
+ChangeSet@1.1251.90.2, 2006-05-12 16:29:02+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    Bug 613: fix spelling
+
+  ntpd/refclock_parse.c@1.35.3.1, 2006-05-12 16:28:09+00:00, kardel@pogo.udel.edu +2 -2
+    Bug 613: fix spelling
+
+ChangeSet@1.1251.90.1, 2006-05-11 13:45:28-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P251_RC
+  TAG: NTP_4_2_1P251_RC
+
+  packageinfo.sh@1.20, 2006-05-11 13:45:21-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P251_RC
+
+ChangeSet@1.1251.89.1, 2006-05-11 15:07:05+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    fix spelling
+
+  ntpd/refclock_parse.c@1.35.1.8, 2006-05-11 15:05:06+00:00, kardel@pogo.udel.edu +2 -2
+    fix spelling
+
+ChangeSet@1.1251.80.51, 2006-05-10 23:55:45-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #611 Fix for EAI_* codes and netent definitions
+
+  libntp/ntp_rfc2553.c@1.27.1.2, 2006-05-10 23:55:08-04:00, mayer@pogo.udel.edu +3 -0
+    Bug #612 Fix for EAI_* codes and netent definitions - add netdb.h include
+
+ChangeSet@1.1251.80.50, 2006-05-10 15:05:24-04:00, stenn@whimsy.udel.edu +1 -0
+  allow the AUTORECONF envariable to supply the name of autoreconf
+
+  bootstrap@1.4, 2006-05-10 15:04:31-04:00, stenn@whimsy.udel.edu +4 -2
+    allow the AUTORECONF envariable to supply the name of autoreconf
+
+ChangeSet@1.1251.80.49, 2006-05-09 06:44:15-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P250_RC
+  TAG: NTP_4_2_1P250_RC
+
+  packageinfo.sh@1.19, 2006-05-09 06:44:03-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P250_RC
+
+ChangeSet@1.1251.80.48, 2006-05-09 09:56:16+00:00, kardel@pogo.udel.edu +1 -0
+  ntpd.c:
+    keep block/unblock calls balanced
+
+  ntpd/ntpd.c@1.61.1.24, 2006-05-09 09:55:06+00:00, kardel@pogo.udel.edu +4 -4
+    keep block/unblock calls balanced
+
+ChangeSet@1.1251.88.1, 2006-05-09 09:30:28+00:00, kardel@pogo.udel.edu +1 -0
+  ntpd.c:
+    refill of current buffer missing
+
+  ntpd/ntpd.c@1.61.1.23, 2006-05-09 09:29:43+00:00, kardel@pogo.udel.edu +1 -0
+    refill of current buffer missing
+
+ChangeSet@1.1251.87.1, 2006-05-09 03:22:02-04:00, stenn@whimsy.udel.edu +1 -0
+  prepare for RCs for -stable point releases
+
+  packageinfo.sh@1.18, 2006-05-09 03:21:41-04:00, stenn@whimsy.udel.edu +6 -0
+    prepare for RCs for -stable point releases
+
+ChangeSet@1.1251.80.45, 2006-05-09 07:12:14+00:00, kardel@pogo.udel.edu +1 -0
+  ntpd.c:
+    move freerecvbuf() into block io section
+    test receiver instead of just the rbuf pointer
+
+  ntpd/ntpd.c@1.61.1.22, 2006-05-09 07:11:09+00:00, kardel@pogo.udel.edu +2 -2
+    move freerecvbuf() into block io section
+    test receiver instead of just the rbuf pointer
+
+ChangeSet@1.1251.80.44, 2006-05-08 18:21:44-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P249_RC
+  TAG: NTP_4_2_1P249_RC
+
+  packageinfo.sh@1.17, 2006-05-08 18:21:33-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P249_RC
+
+ChangeSet@1.1251.80.43, 2006-05-08 10:52:36+00:00, burnicki@pogo.udel.edu +2 -0
+  Retrieve version info from packageinfo.sh also under Windows.
+
+  BitKeeper/etc/logging_ok@1.57.3.3, 2006-05-08 10:52:36+00:00, burnicki@pogo.udel.edu +1 -0
+    Logging to repologs@ntp.isc.org accepted
+
+  ports/winnt/scripts/mkver.bat@1.8, 2006-05-08 10:51:53+00:00, burnicki@pogo.udel.edu +45 -18
+    Retrieve version info from packageinfo.sh.
+
+ChangeSet@1.1251.80.42, 2006-05-08 05:34:00-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P248_RC
+  TAG: NTP_4_2_1P248_RC
+
+  packageinfo.sh@1.16, 2006-05-08 05:33:50-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P248_RC
+
+ChangeSet@1.1251.80.41, 2006-05-08 04:59:17-04:00, stenn@whimsy.udel.edu +1 -0
+  handle the initial case where no version files exist
+
+  scripts/genver@1.3, 2006-05-08 04:58:58-04:00, stenn@whimsy.udel.edu +8 -8
+    handle the initial case where no version files exist
+
+ChangeSet@1.1251.80.40, 2006-05-05 16:40:34-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #596/527 updates to remove [UN]BLOCKIO() and keep initialization for Windows
+
+  libntp/recvbuff.c@1.22, 2006-05-05 16:39:46-04:00, mayer@pogo.udel.edu +0 -10
+    Bug #596/527 updates to remove [UN]BLOCKIO() and keep initialization for Windows
+
+ChangeSet@1.1251.80.39, 2006-05-05 08:48:59-04:00, mayer@pogo.udel.edu +4 -0
+  Bug #504 Collection of changes to retry DNS in case unable to get definitive answer
+
+  libntp/ntp_rfc2553.c@1.27.1.1, 2006-05-05 08:42:45-04:00, mayer@pogo.udel.edu +43 -5
+    Bug #504 Move lookup call to dnslookup() function
+
+  ntpd/ntp_intres.c@1.43, 2006-05-05 08:45:32-04:00, mayer@pogo.udel.edu +22 -8
+    Bug  Retry DNS lookups if DNS unable to give a definitive answer or is unreachable
+
+  ports/winnt/libntp/dnslookup.c@1.2, 2006-05-05 08:47:26-04:00, mayer@pogo.udel.edu +0 -1
+    Bug #504 Windows only special lookup to fix return error codes
+
+  ports/winnt/libntp/dnslookup.c@1.1, 2006-05-05 08:36:40-04:00, mayer@pogo.udel.edu +197 -0
+
+  ports/winnt/libntp/dnslookup.c@1.0, 2006-05-05 08:36:40-04:00, mayer@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/mayer/ntp-dev/ports/winnt/libntp/dnslookup.c
+
+  ports/winnt/libntp/libntp.dsp@1.28, 2006-05-05 08:44:04-04:00, mayer@pogo.udel.edu +4 -0
+    Bug #504 add Windows only dnslookup to dsp file
+
+ChangeSet@1.1251.85.14, 2006-05-05 00:52:13-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P247_RC
+  TAG: NTP_4_2_1P247_RC
+
+  packageinfo.sh@1.15, 2006-05-05 00:52:03-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P247_RC
+
+ChangeSet@1.1251.85.13, 2006-05-05 00:47:24-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P246_RC
+  TAG: NTP_4_2_1P246_RC
+
+  packageinfo.sh@1.14, 2006-05-05 00:47:15-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P246_RC
+
+ChangeSet@1.1251.85.12, 2006-05-05 00:42:27-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P245_RC
+  TAG: NTP_4_2_1P245_RC
+
+  packageinfo.sh@1.13, 2006-05-05 00:42:21-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P245_RC
+
+ChangeSet@1.1251.85.11, 2006-05-05 00:37:38-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P244_RC
+  TAG: NTP_4_2_1P244_RC
+
+  packageinfo.sh@1.12, 2006-05-05 00:37:32-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P244_RC
+
+ChangeSet@1.1251.85.10, 2006-05-04 22:28:16-04:00, stenn@whimsy.udel.edu +1 -0
+  Clean up/fix the force code
+
+  scripts/genver@1.2, 2006-05-04 22:27:40-04:00, stenn@whimsy.udel.edu +20 -12
+    Clean up/fix the force code
+
+ChangeSet@1.1251.85.9, 2006-05-04 19:50:54-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P243_RC
+  TAG: NTP_4_2_1P243_RC
+
+  packageinfo.sh@1.11, 2006-05-04 19:50:46-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P243_RC
+
+ChangeSet@1.1251.85.8, 2006-05-04 07:03:18-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P242_RC
+  TAG: NTP_4_2_1P242_RC
+
+  packageinfo.sh@1.10, 2006-05-04 07:03:08-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P242_RC
+
+ChangeSet@1.1251.85.7, 2006-05-04 05:54:17-04:00, stenn@deacon.udel.edu +1 -0
+  Re-enable signaled I/O
+
+  configure.ac@1.359.1.29, 2006-05-04 05:54:10-04:00, stenn@deacon.udel.edu +2 -6
+    Re-enable signaled I/O
+
+ChangeSet@1.1251.86.1, 2006-05-04 05:38:51-04:00, stenn@deacon.udel.edu +5 -0
+  clean up the version generation stuff.
+
+  Makefile.am@1.48.1.3, 2006-05-04 05:34:46-04:00, stenn@deacon.udel.edu +12 -2
+    Deal with packageinfo.sh, version.m4, and include/version.def
+
+  bootstrap@1.3, 2006-05-04 05:35:44-04:00, stenn@deacon.udel.edu +2 -6
+    Use the new scripts/genver to generate the version files
+
+  include/Makefile.am@1.19.1.2, 2006-05-04 05:36:21-04:00, stenn@deacon.udel.edu +1 -1
+    distribute inclue/version.def
+
+  scripts/Makefile.am@1.13, 2006-05-04 05:36:55-04:00, stenn@deacon.udel.edu +2 -2
+    Distribute VersionName and genver.
+
+  scripts/genver@1.1, 2006-05-04 05:33:24-04:00, stenn@deacon.udel.edu +59 -0
+
+  scripts/genver@1.0, 2006-05-04 05:33:24-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/scripts/genver
+
+ChangeSet@1.1251.85.5, 2006-05-02 09:13:40+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_crypto.c:
+    handle NULL return from d2i_X509() - NetBSD Run 21 Coverity CID 2979
+
+  ntpd/ntp_crypto.c@1.98.1.13, 2006-05-02 09:12:16+00:00, kardel@pogo.udel.edu +1 -1
+    handle NULL return from d2i_X509() - NetBSD Run 21 Coverity CID 2979
+
+ChangeSet@1.1251.85.4, 2006-05-01 18:27:54+00:00, kardel@pogo.udel.edu +3 -0
+  refclock_parse.c:
+    If an input buffer parses into more than one message do insert the
+    parsed message in a new input buffer instead of processing it
+    directly. This avoids deed complicated processing in signal
+    handling.
+  ntpd.c:
+    re-instate vital io blocking protocol to insure
+    that receive buffer queue is only manipulated when
+    io is blocked
+  recvbuff.c:
+    cleanup get_full_recvbuffer() to decide only the full queue head
+    and simplify code (remove multiple tests)
+
+  libntp/recvbuff.c@1.19.1.1, 2006-05-01 18:18:25+00:00, kardel@pogo.udel.edu +4 -11
+    cleanup get_full_recvbuffer() to decide only the full queue head
+    and simplify code (remove multiple tests)
+
+  ntpd/ntpd.c@1.61.5.1, 2006-05-01 18:21:28+00:00, kardel@pogo.udel.edu +25 -12
+    re-instate vital io blocking protocol to insure
+    that receive buffer queue is only manipulated when
+    io is blocked
+
+  ntpd/refclock_parse.c@1.35.1.7, 2006-05-01 18:22:34+00:00, kardel@pogo.udel.edu +33 -18
+    If an input buffer parses into more than one message do insert the
+    parsed message in a new input buffer instead of processing it
+    directly. This avoids deed complicated processing in signal
+    handling.
+
+ChangeSet@1.1251.85.3, 2006-04-21 00:09:43-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P241_RC
+  TAG: NTP_4_2_1P241_RC
+
+  packageinfo.sh@1.9, 2006-04-21 00:09:32-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P241_RC
+
+ChangeSet@1.1251.85.2, 2006-04-20 23:59:56-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 527] Lose signalled IO.
+
+  configure.ac@1.359.1.28, 2006-04-20 23:58:47-04:00, stenn@whimsy.udel.edu +7 -2
+    [Bug 527] Lose signalled IO.
+
+ChangeSet@1.1251.85.1, 2006-04-18 05:58:13-04:00, stenn@whimsy.udel.edu +1 -0
+  there are 240 ntp-dev patch releases so far
+
+  packageinfo.sh@1.8, 2006-04-18 05:57:50-04:00, stenn@whimsy.udel.edu +1 -1
+    there are 240 ntp-dev patch releases so far
+
+ChangeSet@1.1251.80.37, 2006-04-15 18:33:29-04:00, mayer@pogo.udel.edu +1 -0
+  Fix Bug #596 and #572 to deal with polling restrictions
+
+  libntp/recvbuff.c@1.20, 2006-04-15 18:33:18-04:00, mayer@pogo.udel.edu +20 -18
+    Fix Bug #596 and #572 to deal with polling restrictions
+
+ChangeSet@1.1251.80.36, 2006-04-15 18:32:57-04:00, mayer@pogo.udel.edu +1 -0
+  Fix Bug #596 and #572 to deal with polling restrictions
+
+  ntpd/ntpd.c@1.61.1.20, 2006-04-15 18:32:25-04:00, mayer@pogo.udel.edu +3 -1
+    Fix Bug #596 and #572 to deal with polling restrictions
+
+ChangeSet@1.1251.80.35, 2006-04-13 04:14:26-04:00, stenn@whimsy.udel.edu +2 -0
+  Use ./packageinfo.sh as . may not be in the PATH.  Reported by Frank Kardel.
+
+  bootstrap@1.2, 2006-04-13 04:14:03-04:00, stenn@whimsy.udel.edu +1 -1
+    Use ./packageinfo.sh as . may not be in the PATH.  Reported by Frank Kardel.
+
+  scripts/VersionName@1.2, 2006-04-13 04:14:03-04:00, stenn@whimsy.udel.edu +2 -1
+    Use ./packageinfo.sh as . may not be in the PATH.  Reported by Frank Kardel.
+
+ChangeSet@1.1251.80.34, 2006-04-12 06:43:08-04:00, stenn@whimsy.udel.edu +1 -0
+  fix a typo
+
+  README.versions@1.4, 2006-04-12 06:42:47-04:00, stenn@whimsy.udel.edu +1 -1
+    fix a typo
+
+ChangeSet@1.1251.80.33, 2006-04-12 05:57:14-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P12_RC
+  TAG: NTP_4_2_1P12_RC
+
+  packageinfo.sh@1.7, 2006-04-12 05:57:06-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P12_RC
+
+ChangeSet@1.1251.80.32, 2006-04-12 05:27:53-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P11_RC
+  TAG: NTP_4_2_1P11_RC
+
+  packageinfo.sh@1.6, 2006-04-12 05:27:46-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P11_RC
+
+ChangeSet@1.1251.80.31, 2006-04-12 05:22:34-04:00, stenn@whimsy.udel.edu +1 -0
+  Update the NEWS file
+
+  NEWS@1.49, 2006-04-12 05:22:12-04:00, stenn@whimsy.udel.edu +2 -1
+    Update the NEWS file
+
+ChangeSet@1.1251.80.30, 2006-04-12 05:14:52-04:00, stenn@whimsy.udel.edu +1 -0
+  cleanup
+
+  packageinfo.sh@1.5, 2006-04-12 05:14:33-04:00, stenn@whimsy.udel.edu +1 -1
+    cleanup
+
+ChangeSet@1.1251.80.29, 2006-04-12 04:51:30-04:00, stenn@whimsy.udel.edu +1 -0
+  NTP_4_2_1P10_RC
+  TAG: NTP_4_2_1P10_RC
+
+  packageinfo.sh@1.4, 2006-04-12 04:51:23-04:00, stenn@whimsy.udel.edu +1 -1
+    NTP_4_2_1P10_RC
+
+ChangeSet@1.1251.80.28, 2006-04-12 04:44:14-04:00, stenn@whimsy.udel.edu +1 -0
+  use a reasonable value for "point".
+
+  packageinfo.sh@1.3, 2006-04-12 04:43:58-04:00, stenn@whimsy.udel.edu +1 -1
+    use a reasonable value for "point".
+
+ChangeSet@1.1251.80.27, 2006-04-12 04:39:22-04:00, stenn@whimsy.udel.edu +1 -0
+  update
+
+  packageinfo.sh@1.2, 2006-04-12 04:39:00-04:00, stenn@whimsy.udel.edu +3 -3
+    update
+
+ChangeSet@1.1342, 2006-04-11 18:05:00-07:00, bkorb@bach.veritas.com +5 -0
+  AutoOpt the clktest program.
+  Move copyright, version and config file stuff into a common file.
+
+  BitKeeper/etc/config@1.8, 2006-04-11 18:04:59-07:00, bkorb@bach.veritas.com +4 -0
+    New license
+
+  clockstuff/clktest-opts.def@1.2, 2006-04-11 18:00:39-07:00, bkorb@bach.veritas.com +228 -0
+    clktest option definition file.
+
+  clockstuff/clktest-opts.def@1.1, 2006-04-11 17:51:41-07:00, bkorb@bach.veritas.com +0 -0
+
+  clockstuff/clktest-opts.def@1.0, 2006-04-11 17:51:41-07:00, bkorb@bach.veritas.com +0 -0
+    BitKeeper file /home/bkorb/tools/ntp/ntp-dev-ag/clockstuff/clktest-opts.def
+
+  clockstuff/clktest.c@1.3, 2006-04-11 18:00:39-07:00, bkorb@bach.veritas.com +31 -148
+    Move includes to option definition file so the option code can use them, too.
+    Move option processing to option definition file.  Use AutoOpts to parse.
+
+  include/copyright.def@1.2, 2006-04-11 18:00:39-07:00, bkorb@bach.veritas.com +24 -0
+    version, copyright and rc file stuff for all commands.
+
+  include/copyright.def@1.1, 2006-04-11 17:51:41-07:00, bkorb@bach.veritas.com +0 -0
+
+  include/copyright.def@1.0, 2006-04-11 17:51:41-07:00, bkorb@bach.veritas.com +0 -0
+    BitKeeper file /home/bkorb/tools/ntp/ntp-dev-ag/include/copyright.def
+
+  ntpdc/ntpdc-opts.def@1.8, 2006-04-11 18:00:39-07:00, bkorb@bach.veritas.com +1 -24
+    Move common copyright and ini file stuff to a common "copyright.def" file.
+
+ChangeSet@1.1251.84.1, 2006-04-11 04:49:33-04:00, stenn@whimsy.udel.edu +2 -0
+  release prep
+
+  bootstrap@1.1, 2006-04-11 04:47:55-04:00, stenn@whimsy.udel.edu +59 -0
+
+  bootstrap@1.0, 2006-04-11 04:47:55-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/bootstrap
+
+  packageinfo.sh@1.1, 2006-04-11 04:47:12-04:00, stenn@whimsy.udel.edu +19 -0
+
+  packageinfo.sh@1.0, 2006-04-11 04:47:12-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/packageinfo.sh
+
+ChangeSet@1.1251.80.25, 2006-04-09 05:25:08-04:00, stenn@whimsy.udel.edu +3 -0
+  README* updates
+
+  README@1.21, 2006-04-09 05:24:50-04:00, stenn@whimsy.udel.edu +1 -1
+    README* updates
+
+  README.bk@1.18, 2006-04-09 05:24:50-04:00, stenn@whimsy.udel.edu +3 -51
+    README* updates
+
+  README.versions@1.3, 2006-04-09 05:24:51-04:00, stenn@whimsy.udel.edu +10 -18
+    README* updates
+
+ChangeSet@1.1251.80.24, 2006-04-09 05:00:52-04:00, stenn@whimsy.udel.edu +5 -0
+  New release numbering style support
+
+  BitKeeper/deleted/.del-version.m4~4ef47e5fd0c38ddb@1.3.2.1, 2006-04-09 04:57:32-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: version.m4
+
+  BitKeeper/etc/ignore@1.35.1.1, 2006-04-09 04:57:51-04:00, stenn@whimsy.udel.edu +2 -0
+    added include/version.def version.m4
+
+  bootstrap@1.2, 2006-04-09 04:58:41-04:00, stenn@whimsy.udel.edu +13 -11
+    cleanup
+
+  bootstrap@1.1, 2006-04-09 04:07:34-04:00, stenn@whimsy.udel.edu +57 -0
+
+  bootstrap@1.0, 2006-04-09 04:07:34-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/bootstrap
+
+  packageinfo.sh@1.1, 2006-04-09 04:05:25-04:00, stenn@whimsy.udel.edu +17 -0
+
+  packageinfo.sh@1.0, 2006-04-09 04:05:25-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/packageinfo.sh
+
+  scripts/VersionName@1.1, 2006-04-09 04:51:47-04:00, stenn@whimsy.udel.edu +29 -0
+
+  scripts/VersionName@1.0, 2006-04-09 04:51:47-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/scripts/VersionName
+
+ChangeSet@1.1341, 2006-04-09 00:16:18-04:00, stenn@pogo.udel.edu +1 -0
+  update
+
+  packageinfo.sh@1.4, 2006-04-09 00:16:12-04:00, stenn@pogo.udel.edu +4 -1
+    update
+
+ChangeSet@1.1340, 2006-04-08 22:13:54-04:00, stenn@pogo.udel.edu +1 -0
+  update
+
+  packageinfo.sh@1.3, 2006-04-08 22:13:44-04:00, stenn@pogo.udel.edu +11 -1
+    update
+
+ChangeSet@1.1339, 2006-04-08 22:11:27-04:00, stenn@pogo.udel.edu +1 -0
+  update
+
+  bootstrap@1.9, 2006-04-08 22:11:08-04:00, stenn@pogo.udel.edu +1 -1
+    update
+
+ChangeSet@1.1338, 2006-04-08 00:50:08-04:00, stenn@pogo.udel.edu +2 -0
+  Test new release numbering and snapshot method
+
+  BitKeeper/etc/ignore@1.48, 2006-04-08 00:49:18-04:00, stenn@pogo.udel.edu +2 -0
+    added version.m4 include/version.def
+
+  packageinfo.sh@1.2, 2006-04-08 00:49:59-04:00, stenn@pogo.udel.edu +4 -1
+    Test new release numbering and snapshot method
+
+ChangeSet@1.1251.80.23, 2006-04-04 03:16:32-04:00, stenn@deacon.udel.edu +1 -0
+  [Bug 588] logfile documentation problems
+
+  html/miscopt.html@1.35, 2006-04-04 03:16:00-04:00, stenn@deacon.udel.edu +5 -5
+    [Bug 588] logfile documentation problems
+
+ChangeSet@1.1251.80.22, 2006-04-01 05:14:27-05:00, stenn@deacon.udel.edu +1 -0
+  Ignore control characters
+
+  ntpd/refclock_acts.c@1.25.1.1, 2006-04-01 05:13:53-05:00, stenn@deacon.udel.edu +1 -1
+    Ignore control characters
+
+ChangeSet@1.1251.80.21, 2006-03-30 01:43:28-05:00, stenn@deacon.udel.edu +1 -0
+  [Bug 584] quiet a coverity buffer overrun
+
+  ntpd/refclock_chu.c@1.37, 2006-03-30 01:42:56-05:00, stenn@deacon.udel.edu +1 -1
+    [Bug 584] quiet a coverity buffer overrun
+
+ChangeSet@1.1336, 2006-03-26 06:02:05-05:00, stenn@pogo.udel.edu +7 -0
+  debug-opts.def cleanup
+  Allow optional hostnames on the command line for ntpq and ntpdc.
+
+  BitKeeper/etc/ignore@1.47, 2006-03-26 06:02:00-05:00, stenn@pogo.udel.edu +1 -1
+    Fix the ignore for sntp/libopts/
+
+  BitKeeper/etc/ignore@1.46, 2006-03-26 05:52:13-05:00, stenn@pogo.udel.edu +1 -0
+    added sntp/libopts
+
+  ntpd/Makefile.am@1.47, 2006-03-26 06:01:59-05:00, stenn@pogo.udel.edu +7 -7
+    debug-opt.def cleanup
+
+  ntpdc/Makefile.am@1.29, 2006-03-26 06:02:00-05:00, stenn@pogo.udel.edu +4 -4
+    debug-opts.def cleanup
+
+  ntpdc/ntpdc-opts.def@1.7, 2006-03-26 06:02:00-05:00, stenn@pogo.udel.edu +1 -0
+    Allow hostnames on the command-line.
+
+  ntpq/Makefile.am@1.21, 2006-03-26 06:02:00-05:00, stenn@pogo.udel.edu +4 -4
+    debug-opts.def cleanup
+
+  ntpq/ntpq-opts.def@1.5, 2006-03-26 06:02:00-05:00, stenn@pogo.udel.edu +3 -25
+    Allow hostnames on the command-line.
+
+  util/Makefile.am@1.30, 2006-03-26 06:02:00-05:00, stenn@pogo.udel.edu +4 -4
+    debug-opts.def cleanup
+
+ChangeSet@1.1251.80.20, 2006-03-24 00:27:03-05:00, stenn@deacon.udel.edu +1 -0
+  [Bug 571] fix a typo that prevents ntpdate from working
+
+  ntpdate/ntpdate.c@1.58, 2006-03-24 00:26:29-05:00, stenn@deacon.udel.edu +1 -1
+    [Bug 571] fix a typo that prevents ntpdate from working
+
+ChangeSet@1.1251.80.18, 2006-03-21 10:43:26+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_restrict.c:
+    null deref: fix another case of incomplete list handling (Coverity NetBSD Scan 8: CID 986)
+
+  ntpd/ntp_restrict.c@1.17.1.4, 2006-03-21 10:38:33+00:00, kardel@pogo.udel.edu +12 -3
+    null deref: fix another case of incomplete list handling (Coverity NetBSD Scan 8: CID 986)
+
+ChangeSet@1.1251.83.1, 2006-03-21 05:41:41-05:00, stenn@deacon.udel.edu +1 -0
+  [Bug 584] Fix potential buffer overrun
+
+  ntpd/refclock_chu.c@1.36, 2006-03-21 05:41:07-05:00, stenn@deacon.udel.edu +2 -2
+    [Bug 584] Fix potential buffer overrun
+
+ChangeSet@1.1251.82.1, 2006-03-20 05:56:32+00:00, kardel@pogo.udel.edu +2 -0
+  refclock_oncore.c, ntp_restrict.c:
+    standardize pointer checks
+
+  ntpd/ntp_restrict.c@1.17.2.1, 2006-03-20 05:52:19+00:00, kardel@pogo.udel.edu +3 -3
+    standardize pointer checks
+
+  ntpd/refclock_oncore.c@1.59, 2006-03-20 05:54:36+00:00, kardel@pogo.udel.edu +2 -2
+    standardize pointer checks
+
+ChangeSet@1.1251.80.16, 2006-03-19 22:14:48-05:00, mayer@pogo.udel.edu +2 -0
+  Additional fixes for Coverity items
+
+  ntpd/ntp_restrict.c@1.17.1.2, 2006-03-19 22:14:26-05:00, mayer@pogo.udel.edu +2 -2
+    Additional fixes for Coverity items
+
+  ntpdc/ntpdc.c@1.40.2.5, 2006-03-19 22:14:25-05:00, mayer@pogo.udel.edu +4 -1
+    Additional fixes for Coverity items
+
+ChangeSet@1.1251.80.15, 2006-03-19 07:23:01+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_datum.c:
+    error handling: check success of open(2) - bail out early (Coverity CID 1282 NetBSD Scan 5)
+
+  ntpd/refclock_datum.c@1.9, 2006-03-19 07:18:17+00:00, kardel@pogo.udel.edu +13 -5
+    error handling: check success of open(2) - bail out early (Coverity CID 1282 NetBSD Scan 5)
+
+ChangeSet@1.1251.80.14, 2006-03-19 07:04:21+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_restrict.c:
+    null deref: complete linked list handling beginng condition (Coverity CID 986 NetBSD Scan 5)
+
+  ntpd/ntp_restrict.c@1.17.1.1, 2006-03-19 06:59:30+00:00, kardel@pogo.udel.edu +12 -3
+    null deref: complete linked list handling beginng condition (Coverity CID 986 NetBSD Scan 5)
+
+ChangeSet@1.1251.80.13, 2006-03-18 15:25:00+00:00, kardel@pogo.udel.edu +1 -0
+  ntpdc.c:
+    mem leak: unreachable code prevented freeing of allocated memory
+    (Coverity CID 612 NetBSD Scan 5)
+
+  ntpdc/ntpdc.c@1.40.2.4, 2006-03-18 15:22:52+00:00, kardel@pogo.udel.edu +1 -2
+    mem leak: unreachable code prevented freeing of allocated memory
+    (Coverity CID 612 NetBSD Scan 5)
+
+ChangeSet@1.1251.80.12, 2006-03-18 14:33:59+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_oncore.c:
+    null deref: avoid 0 deref (Coverity CID 987 NetBSD Scan 5)
+
+  ntpd/refclock_oncore.c@1.58, 2006-03-18 14:33:30+00:00, kardel@pogo.udel.edu +1 -1
+    null deref: avoid 0 deref (Coverity CID 987 NetBSD Scan 5)
+
+ChangeSet@1.1251.80.11, 2006-03-18 14:20:27+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_arc.c:
+    buffer bounds: buffer full condition wrong for bounds check (Coverity CID 1508 NetBSD Scan 5)
+
+  ntpd/refclock_arc.c@1.18, 2006-03-18 14:19:55+00:00, kardel@pogo.udel.edu +1 -1
+    buffer bounds: buffer full condition wrong for bounds check (Coverity CID 1508 NetBSD Scan 5)
+
+ChangeSet@1.1251.80.10, 2006-03-18 14:09:32+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_leitch.c:
+    buffer bounds: correct > - >= error for bounds check (Coverity CID 1511 NetBSD Scan 5)
+
+  ntpd/refclock_leitch.c@1.7, 2006-03-18 14:09:11+00:00, kardel@pogo.udel.edu +1 -1
+    buffer bounds: correct > - >= error for bounds check (Coverity CID 1511 NetBSD Scan 5)
+
+ChangeSet@1.1251.80.9, 2006-03-18 14:08:59+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_oncore.c:
+    mem leakage: free old malloced buffer on errors (Coverity CID 2056 NetBSD Scan 5)
+
+  ntpd/refclock_oncore.c@1.57, 2006-03-18 13:43:21+00:00, kardel@pogo.udel.edu +6 -0
+    mem leakage: free old malloced buffer on errors (Coverity CID 2056 NetBSD Scan 5)
+
+ChangeSet@1.1251.80.8, 2006-03-18 09:24:46+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_crypto.c:
+    resource leak (fd/mem): fclose() streams on error (Coverity NetBSD scan CID 2055)
+
+  ntpd/ntp_crypto.c@1.98.1.12, 2006-03-18 09:11:14+00:00, kardel@pogo.udel.edu +6 -0
+    resource leak (fd/mem): fclose() streams on error (Coverity NetBSD scan CID 2055)
+
+ChangeSet@1.1251.80.7, 2006-03-18 08:53:22+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_crypto.c:
+    close stream when error occur (Coverity NetBSD Scan CID 2054)
+
+  ntpd/ntp_crypto.c@1.98.1.11, 2006-03-18 08:52:18+00:00, kardel@pogo.udel.edu +3 -0
+    close stream when error occur (Coverity NetBSD Scan CID 2054)
+
+ChangeSet@1.1251.80.6, 2006-03-18 08:01:26+00:00, kardel@pogo.udel.edu +1 -0
+  ntptime.c:
+    resolve potential but not occurring 1-pointer deref (Coverity NetBSD scan, CID 808)
+
+  util/ntptime.c@1.19, 2006-03-18 07:57:43+00:00, kardel@pogo.udel.edu +1 -1
+    resolve potential but not occurring 1-pointer deref (Coverity NetBSD scan, CID 808)
+
+ChangeSet@1.1251.80.5, 2006-03-18 07:55:03+00:00, kardel@pogo.udel.edu +1 -0
+  ntptime.c:
+    resolve bounds issue (Coverity CID 1466, NetBSD scan)
+
+  util/ntptime.c@1.18, 2006-03-18 07:53:50+00:00, kardel@pogo.udel.edu +1 -1
+    resolve bounds issue (Coverity CID 1466, NetBSD scan)
+
+ChangeSet@1.1251.80.4, 2006-03-18 01:11:42+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    coverity fixes found in NetBSD coverity scan
+
+  ntpd/refclock_parse.c@1.35.1.6, 2006-03-18 01:11:00+00:00, kardel@pogo.udel.edu +14 -7
+    coverity fixes found in NetBSD coverity scan
+
+ChangeSet@1.1251.81.1, 2006-03-17 04:22:39-05:00, stenn@deacon.udel.edu +1 -0
+  Set c_iflag=0 for RAW mode
+
+  ntpd/ntp_refclock.c@1.75, 2006-03-17 04:22:20-05:00, stenn@deacon.udel.edu +2 -0
+    Set c_iflag=0 for RAW mode
+
+ChangeSet@1.1251.80.2, 2006-03-16 17:55:20-05:00, mayer@pogo.udel.edu +1 -0
+  [Bug 479] Fix Memory Leak
+
+  ntpd/ntp_io.c@1.187.1.8, 2006-03-16 17:55:03-05:00, mayer@pogo.udel.edu +14 -12
+    Fix Bug #479 Memory Leak
+
+ChangeSet@1.1251.80.1, 2006-03-15 02:29:27-05:00, stenn@deacon.udel.edu +6 -0
+  [Bug 472] configurable driftfile write frequency
+
+  html/miscopt.html@1.34, 2006-03-15 02:28:44-05:00, stenn@deacon.udel.edu +15 -3
+    [Bug 472] configurable driftfile write frequency
+
+  include/ntpd.h@1.82.4.5, 2006-03-15 02:28:44-05:00, stenn@deacon.udel.edu +3 -1
+    [Bug 472] configurable driftfile write frequency
+
+  ntpd/ntp_config.c@1.129.6.1, 2006-03-15 02:28:44-05:00, stenn@deacon.udel.edu +10 -0
+    [Bug 472] configurable driftfile write frequency
+
+  ntpd/ntp_timer.c@1.28.1.1, 2006-03-15 02:28:44-05:00, stenn@deacon.udel.edu +7 -6
+    [Bug 472] configurable driftfile write frequency
+
+  ntpd/ntp_util.c@1.36.2.1, 2006-03-15 02:28:44-05:00, stenn@deacon.udel.edu +10 -1
+    [Bug 472] configurable driftfile write frequency
+
+  ntpd/ntpd.c@1.61.1.19, 2006-03-15 02:28:45-05:00, stenn@deacon.udel.edu +1 -0
+    [Bug 472] configurable driftfile write frequency
+
+ChangeSet@1.1251.72.34, 2006-03-15 06:37:26+00:00, kardel@pogo.udel.edu +2 -0
+  ntp_peer.c:
+    speling fix
+  copyright.html:
+    obfuscate eMail address
+    document dynamic interface handling
+
+  html/copyright.html@1.34, 2006-03-15 06:35:31+00:00, kardel@pogo.udel.edu +2 -2
+    obfuscate eMail address
+    document dynamic interface handling
+
+  ntpd/ntp_peer.c@1.94, 2006-03-15 06:36:56+00:00, kardel@pogo.udel.edu +1 -1
+    speling fix
+
+ChangeSet@1.1251.72.33, 2006-03-14 23:09:12+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_proto.c:
+    peer.{first,last} gone
+
+  ntpd/ntp_proto.c@1.244, 2006-03-14 08:46:44+00:00, kardel@pogo.udel.edu +0 -3
+    peer.{first,last} gone
+
+ChangeSet@1.1333, 2006-03-14 00:51:12-05:00, stenn@pogo.udel.edu +1 -0
+  cleanup
+
+  Makefile.am@1.60, 2006-03-14 00:51:04-05:00, stenn@pogo.udel.edu +1 -1
+    cleanup
+
+ChangeSet@1.1251.79.2, 2006-03-05 16:34:07-05:00, stenn@deacon.udel.edu +1 -0
+  [Bug 553] QNX does not want adjtime.h
+
+  ntpdate/ntpdate.c@1.57, 2006-03-05 16:33:57-05:00, stenn@deacon.udel.edu +0 -4
+    [Bug 553] QNX does not want adjtime.h
+
+ChangeSet@1.1251.79.1, 2006-03-05 16:26:53-05:00, stenn@deacon.udel.edu +1 -0
+  [Bug 576] Use __adjtimex if we have it and not ntp_adjtime
+
+  include/ntp_machine.h@1.22, 2006-03-05 16:26:44-05:00, stenn@deacon.udel.edu +4 -0
+    [Bug 576] Use __adjtimex if we have it and not ntp_adjtime
+
+ChangeSet@1.1251.72.30, 2006-03-02 15:03:35-05:00, clemens@pogo.udel.edu +1 -0
+  Clean up on exit.
+
+  ntpd/refclock_oncore.c@1.56, 2006-03-02 15:03:32-05:00, clemens@pogo.udel.edu +6 -1
+    Clean up on exit.
+
+ChangeSet@1.1251.72.29, 2006-03-01 04:20:05-05:00, stenn@deacon.udel.edu +1 -0
+  AUTOMAKE_OPTIONS: We require automake 1.8 or later.
+
+  Makefile.am@1.48.1.2, 2006-03-01 04:19:58-05:00, stenn@deacon.udel.edu +1 -1
+    AUTOMAKE_OPTIONS: We require automake 1.8 or later.
+
+ChangeSet@1.1251.72.28, 2006-02-28 23:43:36-05:00, stenn@deacon.udel.edu +1 -0
+  RC1 for 4.2.1
+  TAG: ntp-dev
+  TAG: NTP_4_2_0B_RC1
+
+  version.m4@1.3.1.1, 2006-02-28 23:41:38-05:00, stenn@deacon.udel.edu +1 -1
+    RC1 for 4.2.1
+
+ChangeSet@1.1251.78.1, 2006-02-28 09:38:25-05:00, hilbrecht@pogo.udel.edu +2 -0
+  refclock_neoclock4x.c:
+    update driver to version 1.15
+    fix bug #499 and #574
+
+  BitKeeper/etc/logging_ok@1.57.5.1, 2006-02-28 09:38:24-05:00, hilbrecht@pogo.udel.edu +1 -0
+    Logging to repologs@ntp.isc.org accepted
+
+  ntpd/refclock_neoclock4x.c@1.13.1.1, 2006-02-28 09:36:19-05:00, hilbrecht@pogo.udel.edu +16 -30
+    update driver to version 1.15
+    fix bug #499 and #574
+
+ChangeSet@1.1251.77.3, 2006-02-25 19:18:31-05:00, clemens@pogo.udel.edu +2 -0
+      The following 5 changes were made.
+      (1) Fixes for warnings from the curreng gcc compiler.
+      (2) Fix for a possible segfault if restarting with a damaged shmem file.
+      (3) Change all possible fprintf's to record_clock_stats, to get all
+          output in the same place.
+      (4) [Bug 541] Apply a patch by Russell J. Yount <rjy@cmu.edu> for new (and
+          possibly old) M12+T: UTC not correct immediately after a new Almanac
+          read.
+      (5) Apply patch for new PPS implementation by Rodolfo Giometti
+          <giometti@linux.it>.  The code can now useither the old
+          Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> implementation, or 
+          the new one, depending on the timepps.h seen.
+
+  BitKeeper/etc/logging_ok@1.57.4.1, 2006-02-25 19:18:30-05:00, clemens@pogo.udel.edu +1 -0
+    Logging to repologs@ntp.isc.org accepted
+
+  ntpd/refclock_oncore.c@1.55, 2006-02-25 19:17:10-05:00, clemens@pogo.udel.edu +214 -99
+    The following 5 changes were made.
+    (1) Fixes for warnings from the curreng gcc compiler.
+    (2) Fix for a possible segfault if restarting with a damaged shmem file.
+    (3) Change all possible fprintf's to record_clock_stats, to get all
+        output in the same place.
+    (4) [Bug 541] Apply a patch by Russell J. Yount <rjy@cmu.edu> for new (and
+        possibly old) M12+T: UTC not correct immediately after a new Almanac
+        read.
+    (5) Apply patch for new PPS implementation by Rodolfo Giometti
+        <giometti@linux.it>.  The code can now useither the old
+        Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> implementation, or 
+        the new one, depending on the timepps.h seen.
+
+ChangeSet@1.1178.5.9, 2006-02-24 04:24:12-05:00, stenn@deacon.udel.edu +1 -0
+  mort is gone, replaced by macabre
+
+  br-flock@1.4.1.2, 2006-02-24 04:24:01-05:00, stenn@deacon.udel.edu +1 -1
+    mort is gone, replaced by macabre
+
+ChangeSet@1.1251.77.1, 2006-02-24 04:20:07-05:00, stenn@deacon.udel.edu +4 -0
+  Let there be fuzz.  Make sure sys_precision is visible and present.
+
+  libntp/systime.c@1.38, 2006-02-24 04:19:02-05:00, stenn@deacon.udel.edu +9 -7
+    Let there be fuzz.  Make sure sys_precision is visible and present.
+
+  ntpdate/ntpdate.c@1.56, 2006-02-24 04:19:02-05:00, stenn@deacon.udel.edu +5 -0
+    Let there be fuzz.  Make sure sys_precision is visible and present.
+
+  ntpdc/ntpdc.c@1.40.3.1, 2006-02-24 04:19:02-05:00, stenn@deacon.udel.edu +5 -0
+    Let there be fuzz.  Make sure sys_precision is visible and present.
+
+  ntpq/ntpq.c@1.55.1.5, 2006-02-24 04:19:02-05:00, stenn@deacon.udel.edu +5 -0
+    Let there be fuzz.  Make sure sys_precision is visible and present.
+
+ChangeSet@1.1251.72.25, 2006-02-24 02:10:29+00:00, rayvt@pogo.udel.edu +3 -0
+  ntcdc options update
+
+  ntpd/ntp_request.c@1.58.1.2, 2006-02-24 02:10:25+00:00, rayvt@pogo.udel.edu +18 -3
+    ntcdc options update
+
+  ntpdc/ntpdc.h@1.6, 2006-02-24 02:10:25+00:00, rayvt@pogo.udel.edu +2 -1
+    ntcdc options update
+
+  ntpdc/ntpdc_ops.c@1.38.1.2, 2006-02-24 02:10:25+00:00, rayvt@pogo.udel.edu +132 -87
+    ntcdc options update
+
+ChangeSet@1.1251.72.24, 2006-02-24 02:08:52+00:00, rayvt@pogo.udel.edu +7 -0
+  ntpdc options update
+
+  BitKeeper/etc/logging_ok@1.57.3.1, 2006-02-24 02:08:51+00:00, rayvt@pogo.udel.edu +1 -0
+    Logging to repologs@ntp.isc.org accepted
+
+  html/ntpdc.html@1.20.1.3, 2006-02-24 02:08:16+00:00, rayvt@pogo.udel.edu +42 -11
+    ntcdc options update
+
+  include/ntp.h@1.120.1.7, 2006-02-24 02:08:16+00:00, rayvt@pogo.udel.edu +1 -0
+    ntcdc options update
+
+  include/ntp_request.h@1.23.1.1, 2006-02-24 02:08:16+00:00, rayvt@pogo.udel.edu +1 -0
+    ntcdc options update
+
+  ntpd/ntp_loopfilter.c@1.123, 2006-02-24 02:08:16+00:00, rayvt@pogo.udel.edu +18 -0
+    ntcdc options update
+
+  ntpd/ntp_peer.c@1.84.1.2, 2006-02-24 02:08:16+00:00, rayvt@pogo.udel.edu +6 -1
+    ntcdc options update
+
+  ntpdc/ntpdc.c@1.40.2.2, 2006-02-24 02:08:17+00:00, rayvt@pogo.udel.edu +8 -4
+    ntcdc options update
+
+ChangeSet@1.1251.72.23, 2006-02-22 20:01:03-05:00, stenn@deacon.udel.edu +1 -0
+  Fix a typo.
+
+  libntp/systime.c@1.37, 2006-02-22 20:00:33-05:00, stenn@deacon.udel.edu +1 -1
+    Fix a typo.
+
+ChangeSet@1.1251.72.22, 2006-02-22 19:58:12-05:00, stenn@deacon.udel.edu +1 -0
+  Copyright updates from Dave Mills
+
+  html/copyright.html@1.33, 2006-02-22 19:57:52-05:00, stenn@deacon.udel.edu +2 -2
+    Updates from Dave Mills
+
+ChangeSet@1.1251.72.21, 2006-02-17 23:50:33-05:00, stenn@deacon.udel.edu +1 -0
+  Only fuzz the time after we know sys_precision (gettimeofday only)
+
+  libntp/systime.c@1.36, 2006-02-17 23:50:24-05:00, stenn@deacon.udel.edu +10 -2
+    Only fuzz the time after we know sys_precision (gettimeofday only)
+
+ChangeSet@1.1251.72.20, 2006-02-15 23:21:06-05:00, mayer@pogo.udel.edu +1 -0
+  Fix next references for recvbuf
+
+  ntpd/ntpsim.c@1.11.1.1, 2006-02-15 23:20:23-05:00, mayer@pogo.udel.edu +4 -10
+    Fix next references for recvbuf
+
+ChangeSet@1.1251.72.18, 2006-01-31 21:40:26-05:00, stenn@deacon.udel.edu +1 -0
+  Added the new RFC4330 spec (SNTP)
+
+  sntp/RFC4330.TXT@1.1, 2006-01-31 21:39:46-05:00, stenn@deacon.udel.edu +1515 -0
+
+  sntp/RFC4330.TXT@1.0, 2006-01-31 21:39:46-05:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/sntp/RFC4330.TXT
+
+ChangeSet@1.1178.5.8, 2006-01-26 22:18:41-05:00, stenn@deacon.udel.edu +2 -0
+  Make --enable-simulator part of the flock build
+
+  br-flock@1.4.1.1, 2006-01-26 22:18:24-05:00, stenn@deacon.udel.edu +1 -1
+    Make --enable-simulator part of the flock build
+
+  flock-build@1.30.2.1, 2006-01-26 22:18:24-05:00, stenn@deacon.udel.edu +7 -7
+    Make --enable-simulator part of the flock build
+
+ChangeSet@1.1251.72.16, 2006-01-26 06:07:05+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    output errno on PPS setup failure
+
+  ntpd/refclock_parse.c@1.35.1.5, 2006-01-26 06:06:37+00:00, kardel@pogo.udel.edu +1 -1
+    output errno on PPS setup failure
+
+ChangeSet@1.1251.72.15, 2006-01-23 01:55:53-05:00, stenn@deacon.udel.edu +2 -0
+  configure.ac:
+    Cleanup from Ralf Wildenhues
+  authopt.html:
+    typo
+
+  configure.ac@1.359.1.27, 2006-01-23 01:55:36-05:00, stenn@deacon.udel.edu +4 -0
+    Cleanup from Ralf Wildenhues
+
+  html/authopt.html@1.39, 2006-01-23 01:54:55-05:00, stenn@deacon.udel.edu +2 -2
+    typo
+
+ChangeSet@1.1328, 2006-01-23 01:20:16-05:00, stenn@pogo.udel.edu +12 -0
+  Cleanup from Ralf Wildenhues
+
+  include/ntp_stdlib.h@1.24, 2006-01-23 01:14:40-05:00, stenn@pogo.udel.edu +1 -1
+    const cleanup from Ralf Wildenhues
+
+  include/ntpd.h@1.90, 2006-01-23 01:14:40-05:00, stenn@pogo.udel.edu +2 -2
+    const cleanup from Ralf Wildenhues
+
+  libntp/ntp_rfc2553.c@1.28, 2006-01-23 01:15:49-05:00, stenn@pogo.udel.edu +1 -1
+    lint cleanup from Ralf Wildenhues
+
+  ntpd/cmd_args.c@1.37, 2006-01-23 01:17:41-05:00, stenn@pogo.udel.edu +15 -15
+    const and lint cleanup from Ralf Wildenhues
+
+  ntpd/ntp_control.c@1.79.1.8, 2006-01-23 01:17:41-05:00, stenn@pogo.udel.edu +5 -1
+    const and lint cleanup from Ralf Wildenhues
+
+  ntpd/ntp_util.c@1.36.1.3, 2006-01-23 01:17:42-05:00, stenn@pogo.udel.edu +3 -3
+    const and lint cleanup from Ralf Wildenhues
+
+  ntpd/ntpd.c@1.74, 2006-01-23 01:17:43-05:00, stenn@pogo.udel.edu +8 -8
+    const and lint cleanup from Ralf Wildenhues
+
+  ntpd/refclock_acts.c@1.26, 2006-01-23 01:17:43-05:00, stenn@pogo.udel.edu +1 -1
+    const and lint cleanup from Ralf Wildenhues
+
+  ntpd/refclock_neoclock4x.c@1.14, 2006-01-23 01:17:44-05:00, stenn@pogo.udel.edu +1 -1
+    const and lint cleanup from Ralf Wildenhues
+
+  ntpdc/ntpdc.c@1.46, 2006-01-23 01:18:43-05:00, stenn@pogo.udel.edu +2 -2
+    const cleanup from Ralf Wildenhues
+
+  ntpq/ntpq.c@1.61, 2006-01-23 01:18:54-05:00, stenn@pogo.udel.edu +2 -2
+    const cleanup from Ralf Wildenhues
+
+  util/ntp-keygen.c@1.37, 2006-01-23 01:19:17-05:00, stenn@pogo.udel.edu +1 -1
+    lint cleanup from Ralf Wildenhues
+
+ChangeSet@1.1251.72.13, 2006-01-23 00:47:20-05:00, stenn@deacon.udel.edu +1 -0
+  Fix from Dave Mills: etemp gets min(), not max()
+
+  ntpd/ntp_loopfilter.c@1.122, 2006-01-23 00:47:11-05:00, stenn@deacon.udel.edu +1 -1
+    Fix from Dave Mills: etemp gets min(), not max()
+
+ChangeSet@1.1251.72.12, 2006-01-23 00:09:50-05:00, stenn@pogo.udel.edu +1 -0
+  Recover eaten patches
+
+  ntpd/ntpd.c@1.61.1.18, 2006-01-23 00:09:40-05:00, stenn@pogo.udel.edu +21 -0
+    Recover eaten patches
+
+ChangeSet@1.1251.74.11, 2006-01-22 15:58:25+00:00, kardel@pogo.udel.edu +1 -0
+  clk_rawdcf.c:
+    update version information
+
+  libparse/clk_rawdcf.c@1.13, 2006-01-22 15:56:43+00:00, kardel@pogo.udel.edu +6 -3
+    update version information
+
+ChangeSet@1.1251.74.10, 2006-01-22 15:49:38+00:00, kardel@pogo.udel.edu +1 -0
+  clk_rawdcf.c:
+    generate reasonable time code output on invalid input
+
+  libparse/clk_rawdcf.c@1.12, 2006-01-22 15:48:19+00:00, kardel@pogo.udel.edu +2 -2
+    generate reasonable time code output on invalid input
+
+ChangeSet@1.1251.74.9, 2006-01-14 17:42:21-05:00, stenn@deacon.udel.edu +1 -0
+  Fixes from Dave Mills
+
+  ntpd/refclock_wwv.c@1.59, 2006-01-14 17:42:08-05:00, stenn@deacon.udel.edu +7 -4
+    Fixes from Dave Mills
+
+ChangeSet@1.1325, 2006-01-12 18:52:24-05:00, stenn@pogo.udel.edu +2 -0
+  get libopts.m4 from libopts/m4
+
+  Makefile.am@1.58, 2006-01-12 18:52:12-05:00, stenn@pogo.udel.edu +1 -1
+    get libopts.m4 from libopts/m4
+
+  sntp/Makefile.am@1.12, 2006-01-12 18:52:13-05:00, stenn@pogo.udel.edu +1 -1
+    get libopts.m4 from libopts/m4
+
+ChangeSet@1.1324, 2006-01-12 18:23:36-05:00, stenn@pogo.udel.edu +3 -0
+  .del-libopts.m4~ebff9cfbfbe104c8:
+    Delete: sntp/m4/libopts.m4
+  bootstrap:
+    Leave libopts.m4 in sntp/
+  Makefile.am:
+    Get libopts.m4 from the sntp/m4 subdir
+
+  BitKeeper/deleted/.del-libopts.m4~ebff9cfbfbe104c8@1.7, 2006-01-12 18:22:02-05:00, stenn@pogo.udel.edu +97 -88
+    Delete: sntp/m4/libopts.m4
+
+  Makefile.am@1.57, 2006-01-12 18:21:25-05:00, stenn@pogo.udel.edu +1 -1
+    Get libopts.m4 from the sntp/m4 subdir
+
+  bootstrap@1.8, 2006-01-12 18:21:48-05:00, stenn@pogo.udel.edu +0 -1
+    Leave libopts.m4 in sntp/
+
+ChangeSet@1.1323, 2006-01-12 06:00:55-05:00, stenn@pogo.udel.edu +1 -0
+  libopts.m4 is in m4/ now
+
+  bootstrap@1.7, 2006-01-12 06:00:45-05:00, stenn@pogo.udel.edu +1 -1
+    libopts.m4 is in m4/ now
+
+ChangeSet@1.1319.1.1, 2006-01-12 04:36:58-05:00, stenn@pogo.udel.edu +1 -0
+  bootstrap wiggles
+
+  bootstrap@1.4.1.1, 2006-01-12 04:36:40-05:00, stenn@pogo.udel.edu +3 -1
+    autoreconf in sntp first, and avoid -f
+
+ChangeSet@1.1251.74.8, 2006-01-10 00:43:36-05:00, stenn@deacon.udel.edu +3 -0
+  doc changes from Dave Mills
+
+  html/authopt.html@1.38, 2006-01-10 00:43:14-05:00, stenn@deacon.udel.edu +4 -4
+    doc changes from Dave Mills
+
+  html/copyright.html@1.32, 2006-01-10 00:43:14-05:00, stenn@deacon.udel.edu +1 -1
+    doc changes from Dave Mills
+
+  html/miscopt.html@1.33, 2006-01-10 00:43:14-05:00, stenn@deacon.udel.edu +2 -3
+    doc changes from Dave Mills
+
+ChangeSet@1.1251.74.7, 2006-01-10 00:34:58-05:00, stenn@deacon.udel.edu +2 -0
+  Fixes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.121, 2006-01-10 00:34:48-05:00, stenn@deacon.udel.edu +72 -48
+    Fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.16, 2006-01-10 00:34:48-05:00, stenn@deacon.udel.edu +0 -1
+    Fixes from Dave Mills
+
+ChangeSet@1.1251.76.3, 2006-01-09 17:55:37-05:00, mayer@pogo.udel.edu +1 -0
+  Set multicast interface to ignore packets from self
+
+  ntpd/ntp_io.c@1.187.1.7, 2006-01-09 17:54:50-05:00, mayer@pogo.udel.edu +24 -0
+    Set multicast interface to ignore packets from self
+
+ChangeSet@1.1251.76.1, 2006-01-06 16:49:43-05:00, mayer@pogo.udel.edu +2 -0
+  Fix to have completion ports behave properly
+
+  ports/winnt/include/ntp_iocompletionport.h@1.12, 2006-01-06 16:47:39-05:00, mayer@pogo.udel.edu +0 -19
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.20, 2006-01-06 16:48:00-05:00, mayer@pogo.udel.edu +150 -115
+
+ChangeSet@1.1320, 2005-12-30 16:09:52-08:00, bkorb@bach.veritas.com +8 -0
+  Warning patrol, mostly.  Also ensure that $(top_srcdir)/version is built
+  in those subdirectories that need it.
+
+  bootstrap@1.5, 2005-12-30 16:09:50-08:00, bkorb@bach.veritas.com +1 -1
+    Correct the directory where the libopts.m4 file is found
+
+  include/debug-opt.def@1.2, 2005-12-30 16:09:51-08:00, bkorb@bach.veritas.com +8 -0
+    The -D option requires "atoi(3C)".  Ensure it is declared.  Don't know if
+    ``#ifdef __windows'' is the right guard.  Someone needs to correct it....
+
+  ntpd/Makefile.am@1.46, 2005-12-30 16:09:51-08:00, bkorb@bach.veritas.com +3 -0
+    The various subdirectories seem to need a rule for making ../version.
+    Provide it by invoking ``$(MAKE) version'' in that directory.
+
+  ntpd/cmd_args.c@1.36, 2005-12-30 16:09:51-08:00, bkorb@bach.veritas.com +1 -0
+    Declare global variable
+
+  ntpd/ntpd.c@1.72, 2005-12-30 16:09:51-08:00, bkorb@bach.veritas.com +11 -11
+    Correct "const char" usage.
+    Also, disambiguate local "ntp_optarg" from a global
+
+  ntpdate/Makefile.am@1.14, 2005-12-30 16:09:51-08:00, bkorb@bach.veritas.com +3 -0
+    The various subdirectories seem to need a rule for making ../version.
+    Provide it by invoking ``$(MAKE) version'' in that directory.
+
+  ntpdc/Makefile.am@1.28, 2005-12-30 16:09:51-08:00, bkorb@bach.veritas.com +3 -0
+    The various subdirectories seem to need a rule for making ../version.
+    Provide it by invoking ``$(MAKE) version'' in that directory.
+
+  ntpq/Makefile.am@1.20, 2005-12-30 16:09:51-08:00, bkorb@bach.veritas.com +3 -0
+    The various subdirectories seem to need a rule for making ../version.
+    Provide it by invoking ``$(MAKE) version'' in that directory.
+
+ChangeSet@1.1251.74.6, 2005-12-30 14:50:03-05:00, stenn@pogo.udel.edu +1 -0
+  [Bug 545] Provide needed headers to test for sys/timepps.h
+
+  configure.ac@1.359.1.26, 2005-12-30 14:49:50-05:00, stenn@pogo.udel.edu +16 -2
+    [Bug 545] Provide needed headers to test for sys/timepps.h
+
+ChangeSet@1.1319, 2005-12-30 14:07:38-05:00, stenn@pogo.udel.edu +2 -0
+  verbose bootstrap, lose m4/libopts.m4
+
+  BitKeeper/deleted/.del-libopts.m4~9f04cbceeedbd0cf@1.10, 2005-12-30 14:06:59-05:00, stenn@pogo.udel.edu +97 -88
+    Delete: m4/libopts.m4
+
+  bootstrap@1.4, 2005-12-30 14:07:15-05:00, stenn@pogo.udel.edu +3 -2
+    be verbose
+
+ChangeSet@1.1318, 2005-12-29 01:38:14-05:00, stenn@pogo.udel.edu +4 -0
+  wiggles
+
+  BitKeeper/deleted/.del-version.m4~4ef47e5fd0c38ddb@1.4, 2005-12-29 01:36:03-05:00, stenn@pogo.udel.edu +0 -0
+    Delete: version.m4
+
+  Makefile.am@1.56, 2005-12-29 01:37:08-05:00, stenn@pogo.udel.edu +16 -1
+    wiggles
+
+  bootstrap@1.3, 2005-12-29 01:37:08-05:00, stenn@pogo.udel.edu +2 -20
+    wiggles
+
+  packageinfo.sh@1.1, 2005-12-29 01:35:53-05:00, stenn@pogo.udel.edu +1 -0
+
+  packageinfo.sh@1.0, 2005-12-29 01:35:53-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/packageinfo.sh
+
+ChangeSet@1.1251.74.5, 2005-12-27 19:50:58-05:00, stenn@deacon.udel.edu +1 -0
+  [Bug 543] Leap second warning in ONCORE driver, from Luis Batanero Guerrero
+
+  ntpd/refclock_oncore.c@1.54, 2005-12-27 19:50:08-05:00, stenn@deacon.udel.edu +12 -12
+    [Bug 543] Leap second warning in ONCORE driver, from Luis Batanero Guerrero
+
+ChangeSet@1.1251.74.4, 2005-12-25 00:24:24-05:00, stenn@pogo.udel.edu +3 -0
+  [Bug 536] more filegen cleanup
+
+  include/ntp_filegen.h@1.3, 2005-12-25 00:23:31-05:00, stenn@pogo.udel.edu +1 -1
+    [Bug 536] more filegen cleanup
+
+  ntpd/ntp_filegen.c@1.11, 2005-12-25 00:23:38-05:00, stenn@pogo.udel.edu +24 -1
+    [Bug 536] more filegen cleanup
+
+  ntpd/ntp_util.c@1.36.1.2, 2005-12-25 00:23:39-05:00, stenn@pogo.udel.edu +6 -30
+    [Bug 536] more filegen cleanup
+
+ChangeSet@1.1316, 2005-12-23 13:56:31-08:00, bkorb@bach.veritas.com +51 -0
+  Extract the debug options into a separate file included by all the
+  option files.  Place the file in the "include" directory.  Modify
+  the makefiles so autogen adds that directory to its search list.
+
+  BitKeeper/deleted/.del-COPYING.lgpl~a697cd34fe132e8a@1.2, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/COPYING.lgpl
+
+  BitKeeper/deleted/.del-COPYING.mbsd~bfae58672feaeb37@1.2, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/COPYING.mbsd
+
+  BitKeeper/deleted/.del-MakeDefs.inc~5e2e772dad68df1a@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/MakeDefs.inc
+
+  BitKeeper/deleted/.del-Makefile.am~6d6a227df4a598ae@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/Makefile.am
+
+  BitKeeper/deleted/.del-README~e3d36052eb50258b@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/README
+
+  BitKeeper/deleted/.del-autoopts.c~85fbb1bcfe1504ac@1.4, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/autoopts.c
+
+  BitKeeper/deleted/.del-autoopts.h~4c10cd8f919f6342@1.5, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/autoopts.h
+
+  BitKeeper/deleted/.del-boolean.c~2a088bf49e080afe@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/boolean.c
+
+  BitKeeper/deleted/.del-compat.h~1cf561c3e113254d@1.7, 2005-12-23 12:11:25-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/compat/compat.h
+
+  BitKeeper/deleted/.del-configfile.c~bd820799c8dfa50e@1.2, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/configfile.c
+
+  BitKeeper/deleted/.del-cook.c~3fdbc751394ee14d@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/cook.c
+
+  BitKeeper/deleted/.del-enumeration.c~e0416dead0d88f06@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/enumeration.c
+
+  BitKeeper/deleted/.del-environment.c~abe99889ca57817e@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/environment.c
+
+  BitKeeper/deleted/.del-genshell.c~9d621c66b4bd754@1.5, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/genshell.c
+
+  BitKeeper/deleted/.del-genshell.h~f5d1af5bffb3ba@1.5, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/genshell.h
+
+  BitKeeper/deleted/.del-libopts.c~f2125365b6c69db9@1.4, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/libopts.c
+
+  BitKeeper/deleted/.del-libopts.m4~11b56b285499781a@1.5, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/libopts.m4
+
+  BitKeeper/deleted/.del-load.c~c55b985b7f4e79cc@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/load.c
+
+  BitKeeper/deleted/.del-makeshell.c~4e0d2f7e41c164dc@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/makeshell.c
+
+  BitKeeper/deleted/.del-nested.c~2ab62bdc3ff6240d@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/nested.c
+
+  BitKeeper/deleted/.del-numeric.c~6f61173230495e21@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/numeric.c
+
+  BitKeeper/deleted/.del-options.h~4ef9db18f2de6a59@1.4, 2005-12-23 12:11:19-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/autoopts/options.h
+
+  BitKeeper/deleted/.del-pathfind.c~4d249636f5082615@1.2, 2005-12-23 12:11:25-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/compat/pathfind.c
+
+  BitKeeper/deleted/.del-pgusage.c~7d50638aa3ccd579@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/pgusage.c
+
+  BitKeeper/deleted/.del-proto.h~93d0676a173a4b6e@1.5, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/proto.h
+
+  BitKeeper/deleted/.del-putshell.c~8fdade676545e0ad@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/putshell.c
+
+  BitKeeper/deleted/.del-restore.c~2d36a183c65e46b2@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/restore.c
+
+  BitKeeper/deleted/.del-save.c~1e35dba6263bdb0@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/save.c
+
+  BitKeeper/deleted/.del-snprintf.c~34bb5dbb6f424fa4@1.2, 2005-12-23 12:11:25-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/compat/snprintf.c
+
+  BitKeeper/deleted/.del-sort.c~f2dbbab8aecd13de@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/sort.c
+
+  BitKeeper/deleted/.del-stack.c~66471a39d92bf493@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/stack.c
+
+  BitKeeper/deleted/.del-strdup.c~1ff3ed47354b9cab@1.2, 2005-12-23 12:11:25-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/compat/strdup.c
+
+  BitKeeper/deleted/.del-streqvcmp.c~7d82b266e654e41f@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/streqvcmp.c
+
+  BitKeeper/deleted/.del-text_mmap.c~75102303341e937b@1.4, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/text_mmap.c
+
+  BitKeeper/deleted/.del-tokenize.c~f26cbe6a73d13566@1.2, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/tokenize.c
+
+  BitKeeper/deleted/.del-usage-txt.h~e22bfd18a5765c49@1.5, 2005-12-23 12:11:19-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/autoopts/usage-txt.h
+
+  BitKeeper/deleted/.del-usage.c~ce3b6af7dd1009cc@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/usage.c
+
+  BitKeeper/deleted/.del-version.c~bf32cf48f59dabf1@1.3, 2005-12-23 12:11:02-08:00, bkorb@bach.veritas.com +0 -0
+    Delete: sntp/libopts/version.c
+
+  BitKeeper/etc/logging_ok@1.57.2.1, 2005-12-23 13:56:31-08:00, bkorb@bach.veritas.com +1 -0
+    Logging to repologs@ntp.isc.org accepted
+
+  Makefile.am@1.55, 2005-12-23 12:17:32-08:00, bkorb@bach.veritas.com +1 -16
+    Move some commands out into the bootstrap script
+
+  bootstrap@1.2, 2005-12-23 12:17:54-08:00, bkorb@bach.veritas.com +12 -0
+    Add in the commands that were part of Makefile.am
+
+  bootstrap@1.1, 2005-12-23 10:56:19-08:00, bkorb@bach.veritas.com +61 -0
+
+  bootstrap@1.0, 2005-12-23 10:56:19-08:00, bkorb@bach.veritas.com +0 -0
+    BitKeeper file /home/bkorb/tools/ntp/ntp-dev-ag/bootstrap
+
+  include/debug-opt.def@1.1, 2005-12-23 10:56:50-08:00, bkorb@bach.veritas.com +24 -0
+
+  include/debug-opt.def@1.0, 2005-12-23 10:56:50-08:00, bkorb@bach.veritas.com +0 -0
+    BitKeeper file /home/bkorb/tools/ntp/ntp-dev-ag/include/debug-opt.def
+
+  ntpd/Makefile.am@1.45, 2005-12-23 13:55:50-08:00, bkorb@bach.veritas.com +7 -8
+    Option def files must include from the ntp/include directory.
+
+  ntpd/ntpdbase-opts.def@1.2, 2005-12-23 13:55:50-08:00, bkorb@bach.veritas.com +1 -24
+    Move debug options to common file.
+
+  ntpdc/Makefile.am@1.27, 2005-12-23 13:55:50-08:00, bkorb@bach.veritas.com +4 -5
+    Option def files must include from the ntp/include directory.
+
+  ntpdc/ntpdc-opts.def@1.6, 2005-12-23 13:55:50-08:00, bkorb@bach.veritas.com +1 -24
+    Move debug options to a common file.
+
+  ntpq/Makefile.am@1.19, 2005-12-23 13:55:50-08:00, bkorb@bach.veritas.com +4 -5
+    Option def files must include from the ntp/include directory.
+
+  sntp/Makefile.am@1.11, 2005-12-23 13:55:50-08:00, bkorb@bach.veritas.com +4 -4
+    Option def files must include from the ntp/include directory.
+
+  util/Makefile.am@1.29, 2005-12-23 13:55:50-08:00, bkorb@bach.veritas.com +4 -4
+    When building option source, be sure to look in the include file for
+    the debug option file.
+
+  util/ntp-keygen-opts.def@1.2, 2005-12-23 13:55:50-08:00, bkorb@bach.veritas.com +3 -27
+    Move debug options to a common file.
+
+  util/ntp-keygen.c@1.36, 2005-12-23 13:55:50-08:00, bkorb@bach.veritas.com +8 -39
+    Remove some confusing #ifdef's and replace "iffsw" with "HAVE_OPT(ID_KEY)".
+
+ChangeSet@1.1251.71.10, 2005-12-20 23:14:56-05:00, stenn@pogo.udel.edu +1 -0
+  bail early from get_full_recv_buffer() if there is nothing to do.
+
+  libntp/recvbuff.c@1.18, 2005-12-20 23:14:18-05:00, stenn@pogo.udel.edu +3 -0
+    bail early from get_full_recv_buffer() if there is nothing to do.
+
+ChangeSet@1.1251.72.5, 2005-12-20 22:09:09-05:00, mayer@pogo.udel.edu +1 -0
+  Fix recvbuff code with missing refetch when needing more buffers
+
+  libntp/recvbuff.c@1.13.1.2, 2005-12-20 22:08:49-05:00, mayer@pogo.udel.edu +10 -5
+    Fix recvbuff code with missing refetch when needing more buffers
+
+ChangeSet@1.1178.5.7, 2005-12-20 22:05:18-05:00, stenn@deacon.udel.edu +6 -0
+  Send email to ntp.isc.org now
+
+  BitKeeper/triggers/changelog@1.3, 2005-12-20 22:04:44-05:00, stenn@deacon.udel.edu +1 -1
+    Send email to ntp.isc.org now
+
+  BitKeeper/triggers/commitlogs@1.5, 2005-12-20 22:04:45-05:00, stenn@deacon.udel.edu +2 -1
+    Send email to ntp.isc.org now
+
+  BitKeeper/triggers/delta-changelog@1.7, 2005-12-20 22:04:45-05:00, stenn@deacon.udel.edu +2 -2
+    Send email to ntp.isc.org now
+
+  BitKeeper/triggers/notify@1.3, 2005-12-20 22:04:46-05:00, stenn@deacon.udel.edu +2 -1
+    Send email to ntp.isc.org now
+
+  BitKeeper/triggers/paranoid@1.3, 2005-12-20 22:04:46-05:00, stenn@deacon.udel.edu +1 -1
+    Send email to ntp.isc.org now
+
+  BitKeeper/triggers/send@1.5, 2005-12-20 22:04:46-05:00, stenn@deacon.udel.edu +1 -1
+    Send email to ntp.isc.org now
+
+ChangeSet@1.1251.74.2, 2005-12-20 21:46:45-05:00, stenn@pogo.udel.edu +2 -0
+  [Bug 536] Clean up the filegen initialization
+
+  ntpd/ntp_filegen.c@1.10, 2005-12-20 21:33:19-05:00, stenn@pogo.udel.edu +2 -1
+    reformat comment
+
+  ntpd/ntp_util.c@1.36.1.1, 2005-12-20 21:46:11-05:00, stenn@pogo.udel.edu +36 -71
+    [Bug 536] Clean up the filegen initialization
+
+ChangeSet@1.1251.74.1, 2005-12-20 18:30:52-05:00, stenn@pogo.udel.edu +1 -0
+  Tolerate leap second notifications in sntp
+
+  sntp/main.c@1.6, 2005-12-20 18:30:44-05:00, stenn@pogo.udel.edu +4 -3
+    Tolerate leap second notifications in sntp
+
+ChangeSet@1.1251.73.4, 2005-12-20 09:26:06-05:00, mayer@pogo.udel.edu +1 -0
+  Update the way packets are processed
+
+  ntpd/ntpd.c@1.61.4.1, 2005-12-20 09:25:53-05:00, mayer@pogo.udel.edu +8 -5
+    Update the way packets are processed
+
+ChangeSet@1.1251.73.3, 2005-12-20 09:25:05-05:00, mayer@pogo.udel.edu +2 -0
+  Bug #527 - Fix buffer problems when under load
+
+  ports/winnt/include/ntp_iocompletionport.h@1.11, 2005-12-20 09:23:36-05:00, mayer@pogo.udel.edu +1 -6
+    Bug #527 - Fix buffer problems when under load
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.19, 2005-12-20 09:23:36-05:00, mayer@pogo.udel.edu +150 -83
+    Bug #527 - Fix buffer problems when under load
+
+ChangeSet@1.1251.72.3, 2005-12-19 18:12:59-05:00, stenn@deacon.udel.edu +1 -0
+  leap change notification cleanup from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.120, 2005-12-19 18:11:24-05:00, stenn@deacon.udel.edu +0 -8
+    leap change notification cleanup from Dave Mills
+
+ChangeSet@1.1315, 2005-12-16 03:37:46-05:00, stenn@pogo.udel.edu +1 -0
+  Use AutoOpts
+
+  util/ntp-keygen.c@1.35, 2005-12-16 03:37:32-05:00, stenn@pogo.udel.edu +46 -172
+    Use AutoOpts
+
+ChangeSet@1.1314, 2005-12-15 06:34:59-05:00, stenn@pogo.udel.edu +9 -0
+  AutoGen stuff
+
+  m4/libopts.m4@1.9, 2005-12-15 06:33:50-05:00, stenn@pogo.udel.edu +15 -17
+    AutoGen stuff
+
+  ntpd/Makefile.am@1.44, 2005-12-15 06:33:50-05:00, stenn@pogo.udel.edu +10 -10
+    AutoGen stuff
+
+  ntpdc/Makefile.am@1.26, 2005-12-15 06:33:50-05:00, stenn@pogo.udel.edu +5 -5
+    AutoGen stuff
+
+  ntpq/Makefile.am@1.18, 2005-12-15 06:33:51-05:00, stenn@pogo.udel.edu +4 -4
+    AutoGen stuff
+
+  sntp/Makefile.am@1.10, 2005-12-15 06:33:51-05:00, stenn@pogo.udel.edu +4 -4
+    AutoGen stuff
+
+  sntp/libopts/compat/compat.h@1.6, 2005-12-15 06:33:51-05:00, stenn@pogo.udel.edu +1 -1
+    AutoGen stuff
+
+  sntp/libopts/compat/snprintf.c@1.1, 2005-12-15 06:32:56-05:00, stenn@pogo.udel.edu +36 -0
+
+  sntp/libopts/compat/snprintf.c@1.0, 2005-12-15 06:32:56-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/compat/snprintf.c
+
+  sntp/libopts/compat/strdup.c@1.1, 2005-12-15 06:32:56-05:00, stenn@pogo.udel.edu +19 -0
+
+  sntp/libopts/compat/strdup.c@1.0, 2005-12-15 06:32:56-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/compat/strdup.c
+
+  sntp/m4/libopts.m4@1.6, 2005-12-15 06:33:51-05:00, stenn@pogo.udel.edu +15 -17
+    AutoGen stuff
+
+ChangeSet@1.1312, 2005-12-15 06:27:57-05:00, stenn@pogo.udel.edu +3 -0
+  ntp-keygen conversion from Bruce Korb
+
+  BitKeeper/etc/ignore@1.45, 2005-12-15 06:25:25-05:00, stenn@pogo.udel.edu +1 -0
+    added util/ntp-keygen.1
+
+  util/Makefile.am@1.26.1.1, 2005-12-15 06:27:29-05:00, stenn@pogo.udel.edu +21 -4
+    ntp-keygen conversion from Bruce Korb
+
+  util/ntp-keygen-opts.def@1.1, 2005-12-15 06:23:17-05:00, stenn@pogo.udel.edu +263 -0
+
+  util/ntp-keygen-opts.def@1.0, 2005-12-15 06:23:17-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/util/ntp-keygen-opts.def
+
+ChangeSet@1.1251.71.9, 2005-12-13 05:22:27-05:00, stenn@pogo.udel.edu +2 -0
+  more full_recvbuf cleanup
+
+  libntp/recvbuff.c@1.17, 2005-12-13 05:22:14-05:00, stenn@pogo.udel.edu +2 -0
+    more full_recvbuf cleanup
+
+  ntpd/ntpd.c@1.61.1.16, 2005-12-13 05:22:03-05:00, stenn@pogo.udel.edu +2 -3
+    more full_recvbuf cleanup
+
+ChangeSet@1.1251.71.8, 2005-12-13 04:01:10-05:00, stenn@pogo.udel.edu +1 -0
+  Only call get_full_recv_buffer() if we have something
+
+  ntpd/ntpd.c@1.61.1.15, 2005-12-13 04:00:42-05:00, stenn@pogo.udel.edu +12 -8
+    Only call get_full_recv_buffer() if we have something
+
+ChangeSet@1.1251.73.2, 2005-12-12 23:35:01-05:00, mayer@pogo.udel.edu +2 -0
+  Fixes for buffer loss and DOS attacks
+
+  ports/winnt/include/ntp_iocompletionport.h@1.10, 2005-12-12 23:34:36-05:00, mayer@pogo.udel.edu +1 -1
+    Fixes for buffer loss and DOS attacks
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.18, 2005-12-12 23:34:36-05:00, mayer@pogo.udel.edu +5 -1
+    Fixes for buffer loss and DOS attacks
+
+ChangeSet@1.1251.73.1, 2005-12-12 23:32:47-05:00, mayer@pogo.udel.edu +2 -0
+  Make recvbuf unlimited and add check for full buffers
+
+  include/recvbuff.h@1.11, 2005-12-12 23:31:40-05:00, mayer@pogo.udel.edu +6 -0
+    Make recvbuf unlimited and add check for full buffers
+
+  libntp/recvbuff.c@1.13.1.1, 2005-12-12 23:31:40-05:00, mayer@pogo.udel.edu +24 -15
+    Make recvbuf unlimited and add check for full buffers
+
+ChangeSet@1.1251.72.2, 2005-12-11 18:54:45-05:00, stenn@deacon.udel.edu +5 -0
+  [Bug 531]: ntpdc limitations on addserver & addpeer (Ray Van Tassle)
+
+  html/ntpdc.html@1.20.1.2, 2005-12-11 18:51:32-05:00, stenn@deacon.udel.edu +27 -5
+    [Bug 531]: ntpdc limitations on addserver & addpeer (Ray Van Tassle)
+
+  ntpd/ntp_request.c@1.58.1.1, 2005-12-11 18:53:37-05:00, stenn@deacon.udel.edu +23 -5
+    [Bug 531]: ntpdc limitations on addserver & addpeer (Ray Van Tassle)
+
+  ntpdc/ntpdc.c@1.40.2.1, 2005-12-11 18:51:45-05:00, stenn@deacon.udel.edu +15 -0
+    [Bug 531]: ntpdc limitations on addserver & addpeer (Ray Van Tassle)
+
+  ntpdc/ntpdc.h@1.5, 2005-12-11 18:51:46-05:00, stenn@deacon.udel.edu +2 -2
+    [Bug 531]: ntpdc limitations on addserver & addpeer (Ray Van Tassle)
+
+  ntpdc/ntpdc_ops.c@1.38.1.1, 2005-12-11 18:51:47-05:00, stenn@deacon.udel.edu +4 -2
+    [Bug 531]: ntpdc limitations on addserver & addpeer (Ray Van Tassle)
+
+ChangeSet@1.1251.71.6, 2005-12-11 17:16:25-05:00, stenn@maccarony.ntp.org +1 -0
+  diagnostic cleanup
+
+  libntp/recvbuff.c@1.15, 2005-12-11 17:16:16-05:00, stenn@maccarony.ntp.org +2 -3
+    diagnostic cleanup
+
+ChangeSet@1.1251.71.5, 2005-12-11 17:04:21-05:00, stenn@maccarony.ntp.org +3 -0
+  recvbuf typo fix and diagnostics
+
+  BitKeeper/etc/logging_ok@1.55.1.2, 2005-12-11 17:04:20-05:00, stenn@maccarony.ntp.org +1 -0
+    Logging to repologs@ntp.isc.org accepted
+
+  libntp/recvbuff.c@1.14, 2005-12-11 17:02:36-05:00, stenn@maccarony.ntp.org +10 -2
+    full_recvbuf diagnostics
+
+  ntpd/ntpd.c@1.61.1.14, 2005-12-11 17:03:33-05:00, stenn@maccarony.ntp.org +1 -1
+    Danny's typo fix for checking tot_full_recvbufs
+
+ChangeSet@1.1251.71.4, 2005-12-10 23:49:14-05:00, mayer@pogo.udel.edu +2 -0
+  revbuf rewrite
+
+  libntp/recvbuff.c@1.13, 2005-12-10 23:48:53-05:00, mayer@pogo.udel.edu +26 -11
+    revbuf rewrite
+
+  ntpd/ntp_io.c@1.187.1.6, 2005-12-10 23:48:53-05:00, mayer@pogo.udel.edu +48 -8
+    revbuf rewrite
+
+ChangeSet@1.1251.72.1, 2005-12-07 23:23:03-05:00, stenn@deacon.udel.edu +2 -0
+  cleanup from Dave Mills
+
+  ntpd/refclock_irig.c@1.22, 2005-12-07 23:21:50-05:00, stenn@deacon.udel.edu +3 -4
+    cleanup from Dave Mills
+
+  ntpd/refclock_wwv.c@1.58, 2005-12-07 23:22:01-05:00, stenn@deacon.udel.edu +11 -0
+    cleanup from Dave Mills
+
+ChangeSet@1.1251.1.178, 2005-12-05 18:36:24-05:00, stenn@pogo.udel.edu +1 -0
+  tg cleanup
+
+  util/tg.c@1.3, 2005-12-05 18:35:58-05:00, stenn@pogo.udel.edu +1 -0
+    tg cleanup
+
+ChangeSet@1.1251.67.29, 2005-12-05 17:37:57-05:00, stenn@deacon.udel.edu +2 -0
+  Added 'tg'
+
+  util/Makefile.am@1.27, 2005-12-05 17:37:21-05:00, stenn@deacon.udel.edu +1 -1
+    Added 'tg'
+
+  util/tg.c@1.2, 2005-12-05 17:35:32-05:00, stenn@deacon.udel.edu +5 -4
+    cleanup
+
+  util/tg.c@1.1, 2005-12-05 16:03:46-05:00, stenn@deacon.udel.edu +650 -0
+
+  util/tg.c@1.0, 2005-12-05 16:03:46-05:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/util/tg.c
+
+ChangeSet@1.1251.67.28, 2005-12-05 04:55:50-05:00, stenn@deacon.udel.edu +2 -0
+  leap second stuff from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.119, 2005-12-05 03:43:10-05:00, stenn@deacon.udel.edu +11 -11
+    leap second stuff from Dave Mills
+
+  ntpd/refclock_wwv.c@1.57, 2005-12-05 03:43:34-05:00, stenn@deacon.udel.edu +8 -6
+    leap second stuff from Dave Mills
+
+ChangeSet@1.1251.67.27, 2005-11-28 20:54:35-05:00, stenn@deacon.udel.edu +1 -0
+   WWV doc updates from Dave Mills
+
+  html/drivers/driver36.html@1.27, 2005-11-28 20:54:02-05:00, stenn@deacon.udel.edu +14 -22
+     WWV doc updates from Dave Mills
+
+ChangeSet@1.1251.71.3, 2005-11-27 18:35:43-05:00, mayer@pogo.udel.edu +1 -0
+  Name the timer event
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.19, 2005-11-27 18:35:26-05:00, mayer@pogo.udel.edu +2 -2
+    Name the timer event
+
+ChangeSet@1.1251.71.2, 2005-11-27 18:33:06-05:00, mayer@pogo.udel.edu +9 -0
+  Upgrade recvbuf and transmitbuf to use ISC_LIST_* lists
+
+  include/recvbuff.h@1.10, 2005-11-27 18:32:24-05:00, mayer@pogo.udel.edu +6 -4
+    Upgrade recvbuf and transmitbuf to use ISC_LIST_* lists
+
+  libntp/recvbuff.c@1.12, 2005-11-27 18:32:24-05:00, mayer@pogo.udel.edu +48 -137
+    Upgrade recvbuf and transmitbuf to use ISC_LIST_* lists
+
+  ntpd/ntpd.c@1.61.1.13, 2005-11-27 18:32:24-05:00, mayer@pogo.udel.edu +8 -35
+    Upgrade recvbuf and transmitbuf to use ISC_LIST_* lists
+
+  ntpd/refclock_parse.c@1.35.1.4, 2005-11-27 18:32:24-05:00, mayer@pogo.udel.edu +0 -1
+    Upgrade recvbuf and transmitbuf to use ISC_LIST_* lists
+
+  ntpdate/ntpdate.c@1.55, 2005-11-27 18:32:25-05:00, mayer@pogo.udel.edu +8 -8
+    Upgrade recvbuf and transmitbuf to use ISC_LIST_* lists
+
+  ntpdate/ntptimeset.c@1.13, 2005-11-27 18:32:25-05:00, mayer@pogo.udel.edu +7 -13
+    Upgrade recvbuf and transmitbuf to use ISC_LIST_* lists
+
+  ports/winnt/include/transmitbuff.h@1.5, 2005-11-27 18:32:25-05:00, mayer@pogo.udel.edu +7 -4
+    Upgrade recvbuf and transmitbuf to use ISC_LIST_* lists
+
+  ports/winnt/libntp/transmitbuff.c@1.6, 2005-11-27 18:32:25-05:00, mayer@pogo.udel.edu +56 -129
+    Upgrade recvbuf and transmitbuf to use ISC_LIST_* lists
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.17, 2005-11-27 18:32:25-05:00, mayer@pogo.udel.edu +45 -21
+    Upgrade recvbuf and transmitbuf to use ISC_LIST_* lists
+
+ChangeSet@1.1251.70.1, 2005-11-27 18:23:40-05:00, mayer@pogo.udel.edu +1 -0
+  Removed setting next variable in recvbuff
+
+  ntpd/refclock_parse.c@1.35.2.1, 2005-11-27 18:22:58-05:00, mayer@pogo.udel.edu +185 -222
+    Removed setting next variable in recvbuff
+
+ChangeSet@1.1251.67.26, 2005-11-27 17:38:02-05:00, stenn@deacon.udel.edu +1 -0
+  WWV updates from Dave Mills
+
+  ntpd/refclock_wwv.c@1.56, 2005-11-27 17:37:30-05:00, stenn@deacon.udel.edu +329 -479
+    WWV updates from Dave Mills
+
+ChangeSet@1.1251.67.25, 2005-11-15 04:55:14-05:00, stenn@deacon.udel.edu +1 -0
+  more tm_mon fixes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.118, 2005-11-15 04:55:02-05:00, stenn@deacon.udel.edu +3 -2
+    more tm_mon fixes from Dave Mills
+
+ChangeSet@1.1251.69.1, 2005-11-09 22:13:13+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    utilize full PPS timestamp resolution from PPS API
+
+  ntpd/refclock_parse.c@1.35.1.2, 2005-11-09 21:00:26+00:00, kardel@pogo.udel.edu +23 -13
+    utilize full PPS timestamp resolution from PPS API
+
+ChangeSet@1.1251.67.22, 2005-11-09 00:32:54-05:00, stenn@deacon.udel.edu +2 -0
+  Documentation fixes from Dave Mills
+
+  html/authopt.html@1.37, 2005-11-09 00:32:40-05:00, stenn@deacon.udel.edu +10 -10
+    Documentation fixes from Dave Mills
+
+  html/keygen.html@1.8, 2005-11-09 00:32:40-05:00, stenn@deacon.udel.edu +5 -5
+    Documentation fixes from Dave Mills
+
+ChangeSet@1.1251.68.1, 2005-11-08 09:15:35-05:00, mayer@pogo.udel.edu +1 -0
+  bug 495 - fix for multicasting and reuseaddr got lost
+
+  ntpd/ntp_io.c@1.187.1.5, 2005-11-08 09:15:02-05:00, mayer@pogo.udel.edu +6 -2
+    bug 495 - fix for multicasting and reuseaddr got lost
+
+ChangeSet@1.1251.67.21, 2005-11-07 22:11:10-05:00, stenn@deacon.udel.edu +1 -0
+  [Bug 481] do not check $build paths for openssl if cross-compiling.  Other $build/$host cleanup, too.
+
+  configure.ac@1.359.1.25, 2005-11-07 22:11:02-05:00, stenn@deacon.udel.edu +35 -20
+    [Bug 481] do not check $build paths for openssl if cross-compiling.  Other $build/$host cleanup, too.
+
+ChangeSet@1.1251.67.20, 2005-11-07 03:15:55-05:00, stenn@deacon.udel.edu +10 -0
+  Fixes from Dave Mills
+
+  html/authopt.html@1.36, 2005-11-07 03:15:21-05:00, stenn@deacon.udel.edu +3 -4
+    Fixes from Dave Mills
+
+  ntpd/ntp_config.c@1.129.4.2, 2005-11-07 03:13:23-05:00, stenn@deacon.udel.edu +4 -4
+    Fixes from Dave Mills
+
+  ntpd/ntp_control.c@1.79.1.7, 2005-11-07 03:13:23-05:00, stenn@deacon.udel.edu +2 -7
+    Fixes from Dave Mills
+
+  ntpd/ntp_crypto.c@1.98.1.10, 2005-11-07 03:13:23-05:00, stenn@deacon.udel.edu +12 -23
+    Fixes from Dave Mills
+
+  ntpd/ntp_refclock.c@1.74, 2005-11-07 03:13:24-05:00, stenn@deacon.udel.edu +2 -9
+    Fixes from Dave Mills
+
+  ntpd/refclock_atom.c@1.54, 2005-11-07 03:13:24-05:00, stenn@deacon.udel.edu +0 -5
+    Fixes from Dave Mills
+
+  ntpd/refclock_fg.c@1.10, 2005-11-07 03:13:24-05:00, stenn@deacon.udel.edu +0 -3
+    Fixes from Dave Mills
+
+  ntpd/refclock_local.c@1.15, 2005-11-07 03:13:24-05:00, stenn@deacon.udel.edu +1 -1
+    Fixes from Dave Mills
+
+  ntpd/refclock_wwv.c@1.55, 2005-11-07 03:13:24-05:00, stenn@deacon.udel.edu +36 -20
+    Fixes from Dave Mills
+
+  util/ntp-keygen.c@1.34, 2005-11-07 03:12:02-05:00, stenn@deacon.udel.edu +2 -2
+    Fixes from Dave Mills
+
+ChangeSet@1.1251.67.19, 2005-11-06 17:15:15-05:00, mayer@pogo.udel.edu +1 -0
+  Fixes from Heiko and Martin for ntpdate on Windows
+
+  ntpdate/ntpdate.c@1.54, 2005-11-06 17:14:04-05:00, mayer@pogo.udel.edu +47 -6
+    Fixes from Heiko and Martin for ntpdate on Windows
+
+ChangeSet@1.1251.67.17, 2005-11-02 06:54:06-05:00, stenn@deacon.udel.edu +1 -0
+  Updates from Dave Mills
+
+  html/authopt.html@1.35, 2005-11-02 06:53:56-05:00, stenn@deacon.udel.edu +5 -5
+    Updates from Dave Mills
+
+ChangeSet@1.1251.64.4, 2005-11-01 23:40:29-05:00, mayer@pogo.udel.edu +8 -0
+  Bug fixes to support IPv6 changes for non-IPv6 capable systems
+
+  include/isc/ipv6.h@1.7, 2005-11-01 23:40:06-05:00, mayer@pogo.udel.edu +2 -2
+    Bug fixes to support IPv6 changes for non-IPv6 capable systems
+
+  include/isc/net.h@1.8, 2005-11-01 23:40:06-05:00, mayer@pogo.udel.edu +2 -2
+    Bug fixes to support IPv6 changes for non-IPv6 capable systems
+
+  include/ntp_machine.h@1.21, 2005-11-01 23:40:06-05:00, mayer@pogo.udel.edu +1 -0
+    Bug fixes to support IPv6 changes for non-IPv6 capable systems
+
+  include/ntp_rfc2553.h@1.28, 2005-11-01 23:40:06-05:00, mayer@pogo.udel.edu +21 -16
+    Bug fixes to support IPv6 changes for non-IPv6 capable systems
+
+  libisc/net.c@1.7, 2005-11-01 23:40:06-05:00, mayer@pogo.udel.edu +0 -1
+    Bug fixes to support IPv6 changes for non-IPv6 capable systems
+
+  libisc/sockaddr.c@1.5, 2005-11-01 23:40:06-05:00, mayer@pogo.udel.edu +2 -2
+    Bug fixes to support IPv6 changes for non-IPv6 capable systems
+
+  libntp/ntp_rfc2553.c@1.27, 2005-11-01 23:40:06-05:00, mayer@pogo.udel.edu +7 -1
+    Bug fixes to support IPv6 changes for non-IPv6 capable systems
+
+  ntpdate/ntpdate.c@1.53, 2005-11-01 23:40:06-05:00, mayer@pogo.udel.edu +41 -18
+    Bug fixes to support IPv6 changes for non-IPv6 capable systems
+
+ChangeSet@1.1251.67.16, 2005-10-31 05:26:54-05:00, stenn@deacon.udel.edu +2 -0
+  fixes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.117, 2005-10-31 05:25:49-05:00, stenn@deacon.udel.edu +10 -5
+    MOD_NANO fixes from Dave Mills
+
+  ntpd/refclock_wwv.c@1.54, 2005-10-31 05:26:37-05:00, stenn@deacon.udel.edu +1 -1
+    Bump MAXFREQ from 125 to 187 PPM, from Dave Mills
+
+ChangeSet@1.1251.67.15, 2005-10-28 19:05:28-04:00, stenn@deacon.udel.edu +1 -0
+  Weed-whack NANO stuff from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.116, 2005-10-28 19:05:08-04:00, stenn@deacon.udel.edu +29 -22
+    Weed-whack NANO stuff from Dave Mills
+
+ChangeSet@1.1251.67.14, 2005-10-27 22:12:21-04:00, stenn@deacon.udel.edu +4 -0
+  [Bug 521] calleapwhen.c is obsolete
+
+  BitKeeper/deleted/.del-calleapwhen.c~3e480692@1.3, 2005-10-27 22:07:30-04:00, stenn@deacon.udel.edu +0 -0
+    Delete: libntp/calleapwhen.c
+
+  include/ntp_stdlib.h@1.23, 2005-10-27 22:11:51-04:00, stenn@deacon.udel.edu +0 -1
+    [Bug 521] calleapwhen.c is obsolete
+
+  libntp/Makefile.am@1.37, 2005-10-27 22:11:51-04:00, stenn@deacon.udel.edu +1 -1
+    [Bug 521] calleapwhen.c is obsolete
+
+  ports/winnt/libntp/libntp.dsp@1.27, 2005-10-27 22:11:51-04:00, stenn@deacon.udel.edu +0 -4
+    [Bug 521] calleapwhen.c is obsolete
+
+ChangeSet@1.1251.67.13, 2005-10-27 21:59:11-04:00, stenn@deacon.udel.edu +2 -0
+  More updates from Dave Mills
+
+  include/ntp.h@1.120.1.6, 2005-10-27 21:57:49-04:00, stenn@deacon.udel.edu +0 -4
+    More updates from Dave Mills
+
+  ntpd/ntp_crypto.c@1.98.1.9, 2005-10-27 21:57:52-04:00, stenn@deacon.udel.edu +64 -23
+    More updates from Dave Mills
+
+ChangeSet@1.1251.67.12, 2005-10-27 21:38:04-04:00, stenn@deacon.udel.edu +1 -0
+  [Bug 516] unprotected crypto_update() call fix from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.14, 2005-10-27 21:37:53-04:00, stenn@deacon.udel.edu +5 -7
+    [Bug 516] unprotected crypto_update() call fix from Dave Mills
+
+ChangeSet@1.1251.67.11, 2005-10-25 20:15:47-04:00, stenn@deacon.udel.edu +2 -0
+  [Bug 517] Allow dynamic SSL libraries
+
+  configure.ac@1.359.1.24, 2005-10-25 20:15:34-04:00, stenn@deacon.udel.edu +3 -2
+    [Bug 517] Allow dynamic SSL libraries: also check /usr/sfw/{lib,include}
+
+  ntpd/ntpd.c@1.61.1.12, 2005-10-25 20:14:38-04:00, stenn@deacon.udel.edu +9 -0
+    [Bug 517] Allow dynamic SSL libraries: check SSLeay() for version info
+
+ChangeSet@1.1251.67.10, 2005-10-24 04:35:24-04:00, stenn@deacon.udel.edu +2 -0
+  Fixes from Dave Mills
+
+  ntpd/ntp_control.c@1.79.1.6, 2005-10-24 04:35:10-04:00, stenn@deacon.udel.edu +2 -2
+    More 0-11 -> 1-12 month stuff
+
+  ntpd/ntp_crypto.c@1.98.1.8, 2005-10-24 04:34:41-04:00, stenn@deacon.udel.edu +0 -5
+    Lose the coredumping cinfo-> tests
+
+ChangeSet@1.1251.67.9, 2005-10-23 16:43:06-04:00, stenn@deacon.udel.edu +3 -0
+  Crypto cleanup from Dave Mills
+
+  include/ntp.h@1.120.1.5, 2005-10-23 16:41:51-04:00, stenn@deacon.udel.edu +1 -1
+    member reorder from Dave Mills
+
+  ntpd/ntp_crypto.c@1.98.1.7, 2005-10-23 16:42:49-04:00, stenn@deacon.udel.edu +143 -157
+    Crypto cleanup from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.13, 2005-10-23 16:42:49-04:00, stenn@deacon.udel.edu +0 -1
+    Crypto cleanup from Dave Mills
+
+ChangeSet@1.1251.64.3, 2005-10-22 23:43:31-04:00, mayer@pogo.udel.edu +1 -0
+  Bug #411 fix from Marc
+
+  ntpd/ntp_intres.c@1.40.1.2, 2005-10-22 23:43:02-04:00, mayer@pogo.udel.edu +1 -1
+    Bug #411 fix from Marc
+
+ChangeSet@1.1251.67.8, 2005-10-22 00:26:41-04:00, stenn@deacon.udel.edu +3 -0
+  Crypto cleanup/changes from Dave Mills
+
+  include/ntp_crypto.h@1.38, 2005-10-22 00:22:40-04:00, stenn@deacon.udel.edu +0 -1
+    Lose CRYPTO_FLAG_INVLD.  From Dave Mills
+
+  ntpd/ntp_crypto.c@1.98.1.6, 2005-10-22 00:26:03-04:00, stenn@deacon.udel.edu +72 -58
+    Crypto cleanup/changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.12, 2005-10-22 00:26:03-04:00, stenn@deacon.udel.edu +15 -7
+    Crypto cleanup/changes from Dave Mills
+
+ChangeSet@1.1251.67.7, 2005-10-21 23:39:36-04:00, stenn@deacon.udel.edu +1 -0
+  [Bug 515] ntp_set_tod() displays stale errno
+
+  libntp/machines.c@1.18, 2005-10-21 23:39:28-04:00, stenn@deacon.udel.edu +2 -0
+    [Bug 515] ntp_set_tod() displays stale errno
+
+ChangeSet@1.1251.67.6, 2005-10-21 23:23:52-04:00, stenn@deacon.udel.edu +1 -0
+  [Bug 512] Reintroduce -m to ntptrace.  From Frederic Planchon
+
+  scripts/ntptrace.in@1.5, 2005-10-21 23:23:45-04:00, stenn@deacon.udel.edu +8 -2
+    [Bug 512] Reintroduce -m to ntptrace.  From Frederic Planchon
+
+ChangeSet@1.1251.67.5, 2005-10-20 20:22:12-04:00, stenn@deacon.udel.edu +7 -0
+  Fixes from Dave Mills
+
+  include/ntp.h@1.120.1.4, 2005-10-20 20:14:25-04:00, stenn@deacon.udel.edu +4 -2
+    cleanup from Dave Mills
+
+  include/ntp_crypto.h@1.37, 2005-10-20 20:14:26-04:00, stenn@deacon.udel.edu +3 -1
+    cleanup from Dave Mills
+
+  include/ntpd.h@1.82.4.4, 2005-10-20 20:14:26-04:00, stenn@deacon.udel.edu +1 -1
+    cleanup from Dave Mills
+
+  libntp/statestr.c@1.10, 2005-10-20 20:15:27-04:00, stenn@deacon.udel.edu +2 -1
+    Dave Mills added "server certificate expired".
+
+  ntpd/ntp_crypto.c@1.98.1.5, 2005-10-20 20:21:17-04:00, stenn@deacon.udel.edu +71 -7
+    host and server certificate changes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.115, 2005-10-20 20:19:28-04:00, stenn@deacon.udel.edu +13 -5
+    leap second fix plus 0-11 -> 1-12 month fix from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.11, 2005-10-20 20:20:59-04:00, stenn@deacon.udel.edu +3 -3
+    test reorder from Dave Mills
+
+ChangeSet@1.1251.64.2, 2005-10-16 18:43:40-04:00, mayer@pogo.udel.edu +1 -0
+  Fixes from bug #411 Marc de la Gueronniere
+
+  ntpd/ntp_intres.c@1.40.1.1, 2005-10-16 18:43:09-04:00, mayer@pogo.udel.edu +44 -34
+    Fixes from bug #411 Marc de la Gueronniere
+
+ChangeSet@1.1251.67.4, 2005-10-16 03:18:13-04:00, stenn@deacon.udel.edu +1 -0
+  Fix (unused) reversed tests
+
+  ntpd/ntp_intres.c@1.41, 2005-10-16 03:18:05-04:00, stenn@deacon.udel.edu +2 -2
+    Fix (unused) reversed tests
+
+ChangeSet@1.1251.67.3, 2005-10-16 02:30:43-04:00, stenn@deacon.udel.edu +1 -0
+  fix quoting in ISC_PLATFORM_NEEDIN6ADDRANY test
+
+  configure.ac@1.359.1.23, 2005-10-16 02:30:33-04:00, stenn@deacon.udel.edu +1 -1
+    fix quoting in ISC_PLATFORM_NEEDIN6ADDRANY test
+
+ChangeSet@1.1251.67.2, 2005-10-15 23:35:54-04:00, stenn@deacon.udel.edu +1 -0
+  leap and orphan fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.10, 2005-10-15 23:35:37-04:00, stenn@deacon.udel.edu +86 -36
+    leap and orphan fixes from Dave Mills
+
+ChangeSet@1.1251.67.1, 2005-10-15 20:39:31-04:00, stenn@deacon.udel.edu +4 -0
+  Fixes from Dave Mills
+
+  ntpd/ntp_control.c@1.79.1.5, 2005-10-15 20:34:40-04:00, stenn@deacon.udel.edu +4 -4
+    hostkey->update and ctl_putfs() fixes from Dave Mills
+
+  ntpd/ntp_crypto.c@1.98.1.4, 2005-10-15 20:35:24-04:00, stenn@deacon.udel.edu +2 -3
+    Cleanup
+
+  ntpd/ntp_loopfilter.c@1.114, 2005-10-15 20:37:17-04:00, stenn@deacon.udel.edu +31 -11
+    leap second and pll_control/kern_enable fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.9, 2005-10-15 20:39:03-04:00, stenn@deacon.udel.edu +90 -41
+    Comment, crypto_update(), orphan, and leap second fixes from Dave Mills
+
+ChangeSet@1.1251.59.9, 2005-10-14 16:08:06-04:00, stenn@deacon.udel.edu +3 -0
+  Updates from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.113, 2005-10-14 16:05:18-04:00, stenn@deacon.udel.edu +13 -8
+    S_SPIK and kern_enable fixes from Dave Mills
+
+  ntpd/ntp_refclock.c@1.73, 2005-10-14 16:06:08-04:00, stenn@deacon.udel.edu +2 -2
+    cleanup from Dave Mills
+
+  ntpd/refclock_arbiter.c@1.13, 2005-10-14 16:06:41-04:00, stenn@deacon.udel.edu +4 -5
+    cleanup from Dave Mills
+
+ChangeSet@1.1251.59.8, 2005-10-14 15:52:35-04:00, stenn@deacon.udel.edu +1 -0
+  finish Frank's [] conversion to a block of code
+
+  configure.ac@1.359.1.22, 2005-10-14 15:52:20-04:00, stenn@deacon.udel.edu +1 -1
+    finish Frank's [] conversion to a block of code
+
+ChangeSet@1.1251.61.10, 2005-10-13 00:33:46-04:00, stenn@deacon.udel.edu +5 -0
+  documentation updates from Dave Mills
+
+  html/confopt.html@1.31.1.3, 2005-10-13 00:32:58-04:00, stenn@deacon.udel.edu +25 -35
+    documentation updates from Dave Mills
+
+  html/gadget.html@1.1, 2005-10-12 23:35:51-04:00, stenn@deacon.udel.edu +33 -0
+
+  html/gadget.html@1.0, 2005-10-12 23:35:50-04:00, stenn@deacon.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/gadget.html
+
+  html/manyopt.html@1.13, 2005-10-13 00:32:58-04:00, stenn@deacon.udel.edu +33 -26
+    documentation updates from Dave Mills
+
+  html/release.html@1.31, 2005-10-13 00:32:59-04:00, stenn@deacon.udel.edu +20 -9
+    documentation updates from Dave Mills
+
+  html/scripts/links11.txt@1.2, 2005-10-13 00:33:14-04:00, stenn@deacon.udel.edu +2 -0
+    documentation updates from Dave Mills
+
+ChangeSet@1.1251.61.9, 2005-10-09 23:38:00-04:00, stenn@deacon.udel.edu +2 -0
+  Fixes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.112, 2005-10-09 23:37:32-04:00, stenn@deacon.udel.edu +1 -1
+    calleapwhen() change from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.8, 2005-10-09 23:37:48-04:00, stenn@deacon.udel.edu +11 -3
+    crypto fixes from Dave Mills
+
+ChangeSet@1.1251.59.6, 2005-10-08 10:04:12+00:00, kardel@pogo.udel.edu +1 -0
+  dolfptoa.c:
+    safeguard against sign extensions and other mishaps on 64 bit platforms
+
+  libntp/dolfptoa.c@1.6, 2005-10-08 10:03:31+00:00, kardel@pogo.udel.edu +11 -0
+    safeguard against sign extensions and other mishaps on 64 bit platforms
+
+ChangeSet@1.1251.66.2, 2005-10-08 02:28:24-04:00, stenn@deacon.udel.edu +6 -0
+  documentation fixes from Dave Mills
+
+  html/authopt.html@1.34, 2005-10-08 02:28:12-04:00, stenn@deacon.udel.edu +24 -14
+    documentation fixes from Dave Mills
+
+  html/confopt.html@1.31.1.2, 2005-10-08 02:28:12-04:00, stenn@deacon.udel.edu +2 -2
+    documentation fixes from Dave Mills
+
+  html/keygen.html@1.7, 2005-10-08 02:28:12-04:00, stenn@deacon.udel.edu +1 -1
+    documentation fixes from Dave Mills
+
+  html/manyopt.html@1.12, 2005-10-08 02:28:12-04:00, stenn@deacon.udel.edu +4 -3
+    documentation fixes from Dave Mills
+
+  html/miscopt.html@1.32, 2005-10-08 02:28:12-04:00, stenn@deacon.udel.edu +22 -5
+    documentation fixes from Dave Mills
+
+  html/msyslog.html@1.5, 2005-10-08 02:28:12-04:00, stenn@deacon.udel.edu +49 -54
+    documentation fixes from Dave Mills
+
+ChangeSet@1.1251.59.4, 2005-10-08 06:06:03+00:00, kardel@pogo.udel.edu +4 -0
+  refclock_parse.c:
+    avoid unexpected buffer overflows due to sprintf("%f") on strange floats:
+    replace almost all str* and *printf functions by their buffer bounded
+    counterparts
+  data_mbg.c, mbg_gps166.h:
+    bounded buffer implementation
+  dcfd.c:
+    make dcfd.c compile on NetBSD 3.99.9 again (configure/sigvec compatibility fix)
+
+  include/mbg_gps166.h@1.5.1.1, 2005-10-07 23:02:16+00:00, kardel@pogo.udel.edu +10 -4
+    bounded buffer implementation
+
+  libparse/data_mbg.c@1.5.1.1, 2005-10-07 23:03:25+00:00, kardel@pogo.udel.edu +61 -49
+    bounded buffer implementation
+
+  ntpd/refclock_parse.c@1.35.1.1, 2005-10-07 23:03:44+00:00, kardel@pogo.udel.edu +221 -185
+    avoid unexpected buffer overflows due to sprintf("%f") on strange floats:
+    replace almost all str* and *printf functions be their buffer bounded
+    counterparts
+
+  parseutil/dcfd.c@1.18, 2005-10-07 23:02:47+00:00, kardel@pogo.udel.edu +25 -18
+    make dcfd.c compile on NetBSD 3.99.9 again (configure/sigvec compatibility fix)
+
+ChangeSet@1.1251.66.1, 2005-10-08 00:29:29-04:00, stenn@deacon.udel.edu +1 -0
+  orphan fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.7, 2005-10-08 00:29:21-04:00, stenn@deacon.udel.edu +11 -4
+    orphan fixes from Dave Mills
+
+ChangeSet@1.1251.65.1, 2005-10-05 01:38:06-07:00, murray@glypnod.example.com +5 -0
+  Add support for the HP Z3801 GPS clock.  Needs 19200 buad, 7 bits, odd parity.
+
+  BitKeeper/etc/logging_ok@1.54.2.1, 2005-10-05 01:38:06-07:00, murray@glypnod.example.com +1 -0
+    Logging to repologs@ntp.isc.org accepted
+
+  html/drivers/driver26.html@1.10, 2005-10-05 01:37:37-07:00, murray@glypnod.example.com +12 -9
+    Add description of HP Z3801A
+
+  include/ntp_refclock.h@1.20, 2005-10-05 01:37:37-07:00, murray@glypnod.example.com +2 -1
+    Add LDISC_7O1 flag for 7 bit, odd parity
+
+  ntpd/ntp_refclock.c@1.72, 2005-10-05 01:37:37-07:00, murray@glypnod.example.com +4 -0
+    Add support for LDISC_7O1 flag - 7 bit, odd parity.
+
+  ntpd/refclock_hpgps.c@1.7, 2005-10-05 01:37:37-07:00, murray@glypnod.example.com +18 -3
+    Add support for HP Z3810A - 19200, 7bits, odd parity
+
+ChangeSet@1.1251.61.6, 2005-10-05 03:02:11-04:00, stenn@deacon.udel.edu +1 -0
+  orphan fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.6, 2005-10-05 03:01:54-04:00, stenn@deacon.udel.edu +18 -16
+    orphan fixes from Dave Mills
+
+ChangeSet@1.1251.64.1, 2005-10-04 12:22:54-04:00, mayer@pogo.udel.edu +1 -0
+  Fix extra y at beginning of file
+
+  ntpd/ntp_proto.c@1.232.2.1, 2005-10-04 12:22:23-04:00, mayer@pogo.udel.edu +1 -1
+    Fix extra y at beginning of file
+
+ChangeSet@1.1251.61.5, 2005-10-04 02:52:27-04:00, stenn@deacon.udel.edu +5 -0
+  fixes from Dave Mills
+
+  include/ntp.h@1.120.1.3, 2005-10-04 02:50:55-04:00, stenn@deacon.udel.edu +3 -1
+    fixes from Dave Mills
+
+  include/ntpd.h@1.82.4.3, 2005-10-04 02:50:55-04:00, stenn@deacon.udel.edu +0 -1
+    fixes from Dave Mills
+
+  ntpd/ntp_control.c@1.79.1.4, 2005-10-04 02:51:46-04:00, stenn@deacon.udel.edu +1 -1
+    fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.5, 2005-10-04 02:51:47-04:00, stenn@deacon.udel.edu +49 -29
+    fixes from Dave Mills
+
+  ntpd/refclock_local.c@1.14, 2005-10-04 02:51:47-04:00, stenn@deacon.udel.edu +2 -8
+    fixes from Dave Mills
+
+ChangeSet@1.1251.63.1, 2005-10-02 04:12:05-04:00, stenn@deacon.udel.edu +10 -0
+  NEWS update; orphan/revoke/expire stuff from Dave Mills
+
+  NEWS@1.48, 2005-10-02 04:11:28-04:00, stenn@deacon.udel.edu +2 -0
+    updated
+
+  include/ntp.h@1.120.1.2, 2005-10-02 03:57:42-04:00, stenn@deacon.udel.edu +3 -2
+    orphan and revoke stuff from Dave Mills
+
+  include/ntp_config.h@1.37.1.2, 2005-10-02 03:57:42-04:00, stenn@deacon.udel.edu +1 -0
+    orphan and revoke stuff from Dave Mills
+
+  include/ntp_control.h@1.29, 2005-10-02 03:57:42-04:00, stenn@deacon.udel.edu +2 -1
+    orphan and revoke stuff from Dave Mills
+
+  ntpd/ntp_config.c@1.129.4.1, 2005-10-02 04:08:11-04:00, stenn@deacon.udel.edu +5 -0
+    fixes, and orphan and expire stuff from Dave Mills
+
+  ntpd/ntp_control.c@1.79.1.3, 2005-10-02 04:08:11-04:00, stenn@deacon.udel.edu +50 -20
+    fixes, and orphan and expire stuff from Dave Mills
+
+  ntpd/ntp_crypto.c@1.98.1.3, 2005-10-02 04:08:11-04:00, stenn@deacon.udel.edu +114 -94
+    fixes, and orphan and expire stuff from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.111, 2005-10-02 04:08:12-04:00, stenn@deacon.udel.edu +1 -1
+    fixes, and orphan and expire stuff from Dave Mills
+
+  ntpd/ntp_peer.c@1.84.1.1, 2005-10-02 04:08:12-04:00, stenn@deacon.udel.edu +0 -1
+    fixes, and orphan and expire stuff from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.4, 2005-10-02 04:08:12-04:00, stenn@deacon.udel.edu +200 -124
+    fixes, and orphan and expire stuff from Dave Mills
+
+ChangeSet@1.1251.61.3, 2005-10-01 01:02:12-04:00, mayer@pogo.udel.edu +5 -0
+  Fixes for handling IPv6 issues and getaddrinfo()
+
+  include/isc/net.h@1.7, 2005-10-01 01:00:52-04:00, mayer@pogo.udel.edu +2 -2
+    Fixes for handling IPv6 issues and getaddrinfo)_
+
+  libisc/net.c@1.6, 2005-10-01 01:00:52-04:00, mayer@pogo.udel.edu +1 -0
+    Fixes for handling IPv6 issues and getaddrinfo)_
+
+  libntp/ntp_rfc2553.c@1.26, 2005-10-01 01:00:52-04:00, mayer@pogo.udel.edu +124 -21
+    Fixes for handling IPv6 issues and getaddrinfo)_
+
+  ports/winnt/include/isc/net.h@1.6, 2005-10-01 01:00:52-04:00, mayer@pogo.udel.edu +1 -1
+    Fixes for handling IPv6 issues and getaddrinfo)_
+
+  ports/winnt/libisc/net.c@1.7, 2005-10-01 01:00:52-04:00, mayer@pogo.udel.edu +1 -1
+    Fixes for handling IPv6 issues and getaddrinfo)_
+
+ChangeSet@1.1251.61.2, 2005-09-26 02:19:59-04:00, stenn@deacon.udel.edu +2 -0
+  sntp is now built by default.
+
+  configure.ac@1.359.4.1, 2005-09-26 02:19:47-04:00, stenn@deacon.udel.edu +2 -2
+    sntp is now built by default.
+
+  flock-build@1.33, 2005-09-26 02:19:47-04:00, stenn@deacon.udel.edu +6 -7
+    sntp is now built by default.
+
+ChangeSet@1.1251.60.4, 2005-09-25 12:21:08+00:00, kardel@pogo.udel.edu +3 -0
+  ntpdc_ops.c:
+    output broadcast address information when broadcast flag is set
+  ntp_peer.c:
+    re-bind broad and multi cast on re-fresh
+  ntp_io.c:
+    re-bind interfaces on re-scans
+
+  ntpd/ntp_io.c@1.211, 2005-09-25 12:10:52+00:00, kardel@pogo.udel.edu +90 -43
+    re-bind interfaces on re-scans
+
+  ntpd/ntp_peer.c@1.91, 2005-09-25 12:11:28+00:00, kardel@pogo.udel.edu +18 -1
+    re-bind broad and multi cast on re-fresh
+
+  ntpdc/ntpdc_ops.c@1.45, 2005-09-25 12:12:38+00:00, kardel@pogo.udel.edu +10 -9
+    output broadcast address information when broadcast flag is set
+
+ChangeSet@1.1251.60.3, 2005-09-25 12:10:35+00:00, kardel@pogo.udel.edu +4 -0
+  refclock_parse.c:
+    avoid unexpected buffer overflows due to sprintf("%f") on strange floats:
+    replace almost all str* and *printf functions be their buffer bounded
+    counterparts
+    limit re-set rate of trimble clocks
+  data_mbg.c:
+    support fully bounded buffers
+  clk_meinberg.c:
+    cleanup buffer bounds
+  mbg_gps166.h 
+    support fully bounded buffers
+
+  include/mbg_gps166.h@1.6, 2005-09-25 12:06:41+00:00, kardel@pogo.udel.edu +7 -4
+
+  libparse/clk_meinberg.c@1.9, 2005-09-25 12:07:49+00:00, kardel@pogo.udel.edu +7 -4
+    cleanup buffer bounds
+
+  libparse/data_mbg.c@1.6, 2005-09-25 12:08:11+00:00, kardel@pogo.udel.edu +58 -49
+    support fully bounded buffers
+
+  ntpd/refclock_parse.c@1.36, 2005-09-25 12:08:50+00:00, kardel@pogo.udel.edu +204 -185
+    avoid unexpected buffer overflows due to sprintf("%f") on strange floats:
+    replace almost all str* and *printf functions be their buffer bounded
+    counterparts
+    limit re-set rate of trimble clocks
+
+ChangeSet@1.1251.61.1, 2005-09-25 04:17:34-04:00, stenn@deacon.udel.edu +1 -0
+  Add missing ISC_PLATFORM_HAVESCOPEID checks.
+
+  ntpd/ntp_io.c@1.187.1.4, 2005-09-25 04:17:25-04:00, stenn@deacon.udel.edu +12 -1
+    Add missing ISC_PLATFORM_HAVESCOPEID checks.
+
+ChangeSet@1.1251.58.1, 2005-09-25 05:54:32+00:00, stenn@ntp1.isc.org +2 -0
+  [Bug 467] Reorder #include order to avoid linux collision
+
+  BitKeeper/etc/logging_ok@1.54.1.1, 2005-09-25 05:54:32+00:00, stenn@ntp1.isc.org +1 -0
+    Logging to repologs@ntp.isc.org accepted
+
+  ntpd/ntp_config.c@1.129.3.4, 2005-09-25 05:54:11+00:00, stenn@ntp1.isc.org +8 -2
+    [Bug 467] Reorder #include order to avoid linux collision
+
+ChangeSet@1.1251.1.153, 2005-09-24 23:18:13-04:00, stenn@deacon.udel.edu +6 -0
+  [Bug 498] Patches from Miroslaw Pabich
+
+  include/adjtime.h@1.4, 2005-09-24 23:17:22-04:00, stenn@deacon.udel.edu +0 -6
+    [Bug 498] Patches from Miroslaw Pabich
+
+  libntp/iosignal.c@1.13, 2005-09-24 23:17:32-04:00, stenn@deacon.udel.edu +6 -6
+    [Bug 498] Patches from Miroslaw Pabich
+
+  ntpd/refclock_hopfser.c@1.9, 2005-09-24 23:17:43-04:00, stenn@deacon.udel.edu +5 -3
+    [Bug 498] Patches from Miroslaw Pabich
+
+  ntpd/refclock_neoclock4x.c@1.13, 2005-09-24 23:17:43-04:00, stenn@deacon.udel.edu +5 -3
+    [Bug 498] Patches from Miroslaw Pabich
+
+  ntpd/refclock_palisade.h@1.8, 2005-09-24 23:17:43-04:00, stenn@deacon.udel.edu +2 -0
+    [Bug 498] Patches from Miroslaw Pabich
+
+  ntpdate/ntpdate.c@1.52, 2005-09-24 23:17:53-04:00, stenn@deacon.udel.edu +0 -4
+    [Bug 498] Patches from Miroslaw Pabich
+
+ChangeSet@1.1251.53.6, 2005-09-24 17:39:29-04:00, mayer@pogo.udel.edu +1 -0
+  Revamped the code in getaddrinfo
+
+  libntp/ntp_rfc2553.c@1.25, 2005-09-24 17:39:04-04:00, mayer@pogo.udel.edu +31 -37
+    Revamped the code in getaddrinfo
+
+ChangeSet@1.1251.56.1, 2005-09-23 19:27:51-04:00, mayer@pogo.udel.edu +1 -0
+  Refix for memory leak. Some checks were incorrect
+
+  libntp/ntp_rfc2553.c@1.24, 2005-09-23 19:26:56-04:00, mayer@pogo.udel.edu +19 -15
+    Refix for memory leak. Some checks were incorrect
+
+ChangeSet@1.1251.53.4, 2005-09-22 22:07:15-04:00, stenn@deacon.udel.edu +1 -0
+  [Bug 496]: Updated adjtime for QNX from Miroslaw Pabich
+
+  libntp/adjtime.c@1.7, 2005-09-22 22:07:07-04:00, stenn@deacon.udel.edu +80 -17
+    [Bug 496]: Updated adjtime for QNX from Miroslaw Pabich
+
+ChangeSet@1.1251.55.1, 2005-09-21 23:23:47-04:00, gunturu@pogo.udel.edu +2 -0
+  timing.c:
+    unable settimeofday and adjtime as temporary fix until we port utmp.
+
+  BitKeeper/etc/logging_ok@1.55, 2005-09-21 23:23:47-04:00, gunturu@pogo.udel.edu +1 -0
+    Logging to repologs@ntp.isc.org accepted
+
+  sntp/timing.c@1.3, 2005-09-21 23:21:58-04:00, gunturu@pogo.udel.edu +4 -4
+    unable settimeofday and adjtime as temporary fix until we port utmp.
+
+ChangeSet@1.1305, 2005-09-21 00:31:27-04:00, stenn@pogo.udel.edu +1 -0
+  autoopts cleanup
+
+  ntpd/ntpd.c@1.70, 2005-09-21 00:31:17-04:00, stenn@pogo.udel.edu +2 -0
+    autoopts cleanup
+
+ChangeSet@1.1304, 2005-09-21 00:30:39-04:00, stenn@pogo.udel.edu +1 -0
+  libopts update
+
+  sntp/libopts/compat/compat.h@1.5, 2005-09-21 00:30:27-04:00, stenn@pogo.udel.edu +5 -4
+    libopts update
+
+ChangeSet@1.1303, 2005-09-21 00:28:47-04:00, stenn@pogo.udel.edu +10 -0
+  libopts upgrade
+
+  sntp/libopts/autoopts.c@1.3, 2005-09-21 00:26:36-04:00, stenn@pogo.udel.edu +9 -1
+    libopts upgrade
+
+  sntp/libopts/autoopts.h@1.4, 2005-09-21 00:26:36-04:00, stenn@pogo.udel.edu +1 -8
+    libopts upgrade
+
+  sntp/libopts/autoopts/options.h@1.3, 2005-09-17 03:23:25-04:00, stenn@pogo.udel.edu +30 -5
+    libopts upgrade
+
+  sntp/libopts/autoopts/usage-txt.h@1.4, 2005-09-17 03:23:25-04:00, stenn@pogo.udel.edu +1 -1
+    libopts upgrade
+
+  sntp/libopts/compat/compat.h@1.4, 2005-09-17 03:23:25-04:00, stenn@pogo.udel.edu +1 -1
+    libopts upgrade
+
+  sntp/libopts/genshell.c@1.4, 2005-09-17 03:23:25-04:00, stenn@pogo.udel.edu +1 -1
+    libopts upgrade
+
+  sntp/libopts/genshell.h@1.4, 2005-09-17 03:23:25-04:00, stenn@pogo.udel.edu +2 -2
+    libopts upgrade
+
+  sntp/libopts/libopts.c@1.3, 2005-09-21 00:26:37-04:00, stenn@pogo.udel.edu +0 -1
+    libopts upgrade
+
+  sntp/libopts/libopts.m4@1.4, 2005-09-21 00:26:37-04:00, stenn@pogo.udel.edu +15 -17
+    libopts upgrade
+
+  sntp/libopts/proto.h@1.4, 2005-09-21 00:26:37-04:00, stenn@pogo.udel.edu +1 -1
+    libopts upgrade
+
+ChangeSet@1.1251.53.3, 2005-09-20 23:35:55-04:00, mayer@pogo.udel.edu +1 -0
+  bug #486 and Fix memory leak and add heiko's change for hints
+
+  libntp/ntp_rfc2553.c@1.23, 2005-09-20 23:35:18-04:00, mayer@pogo.udel.edu +15 -5
+    bug #486 and Fix memory leak and add heiko's change for hints
+
+ChangeSet@1.1251.54.1, 2005-09-19 18:05:35-04:00, mayer@pogo.udel.edu +2 -0
+  Frank Kardel's fixes for the flags and broadcast address
+
+  libisc/ifiter_getifaddrs.c@1.5, 2005-09-19 18:04:58-04:00, mayer@pogo.udel.edu +2 -2
+    Frank Kardel's fixes for the flags and broadcast address
+
+  libisc/ifiter_sysctl.c@1.12, 2005-09-19 18:04:58-04:00, mayer@pogo.udel.edu +1 -1
+    Frank Kardel's fixes for the flags and broadcast address
+
+ChangeSet@1.1251.52.2, 2005-09-17 10:11:26+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    cleanup merge fallout
+
+  ntpd/ntp_io.c@1.209, 2005-09-17 10:10:39+00:00, kardel@pogo.udel.edu +6 -5
+    cleanup merge fallout
+
+ChangeSet@1.1301, 2005-09-17 00:45:06-04:00, stenn@pogo.udel.edu +14 -0
+  libopts upgrade
+
+  m4/libopts.m4@1.8, 2005-09-17 00:39:38-04:00, stenn@pogo.udel.edu +36 -1
+    libopts upgrade
+
+  sntp/Makefile.am@1.9, 2005-09-17 00:39:46-04:00, stenn@pogo.udel.edu +1 -1
+    libopts upgrade
+
+  sntp/libopts/Makefile.am@1.2, 2005-09-17 00:40:04-04:00, stenn@pogo.udel.edu +1 -1
+    libopts upgrade
+
+  sntp/libopts/autoopts.h@1.3, 2005-09-17 00:40:04-04:00, stenn@pogo.udel.edu +1 -21
+    libopts upgrade
+
+  sntp/libopts/autoopts/usage-txt.h@1.3, 2005-09-11 23:12:25-04:00, stenn@pogo.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  sntp/libopts/autoopts/usage-txt.h@1.2, 2005-09-11 23:09:56-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/compat/compat.h@1.3, 2005-09-17 00:41:18-04:00, stenn@pogo.udel.edu +5 -4
+    libopts upgrade
+
+  sntp/libopts/genshell.c@1.3, 2005-09-11 23:12:24-04:00, stenn@pogo.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  sntp/libopts/genshell.c@1.2, 2005-09-11 23:09:38-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/genshell.h@1.3, 2005-09-11 23:12:25-04:00, stenn@pogo.udel.edu +0 -0
+    Change mode to -rw-r--r--
+
+  sntp/libopts/genshell.h@1.2, 2005-09-11 23:09:38-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/libopts.c@1.2, 2005-09-17 00:40:05-04:00, stenn@pogo.udel.edu +1 -0
+    libopts upgrade
+
+  sntp/libopts/libopts.m4@1.3, 2005-09-17 00:40:05-04:00, stenn@pogo.udel.edu +36 -1
+    libopts upgrade
+
+  sntp/libopts/proto.h@1.3, 2005-09-17 00:40:05-04:00, stenn@pogo.udel.edu +1 -10
+    libopts upgrade
+
+  sntp/libopts/text_mmap.c@1.3, 2005-09-17 00:40:05-04:00, stenn@pogo.udel.edu +74 -33
+    libopts upgrade
+
+  sntp/m4/libopts.m4@1.5, 2005-09-17 00:39:52-04:00, stenn@pogo.udel.edu +36 -1
+    libopts upgrade
+
+  sntp/m4/libopts.m4@1.4, 2005-09-12 17:12:47-04:00, stenn@pogo.udel.edu +0 -0
+    Rename: sntp/libopts.m4 -> sntp/m4/libopts.m4
+
+  sntp/sntp-opts.def@1.2, 2005-09-17 00:39:47-04:00, stenn@pogo.udel.edu +2 -0
+    libopts upgrade
+
+ChangeSet@1.1251.51.6, 2005-09-17 00:34:07-04:00, stenn@deacon.udel.edu +5 -0
+  more leap stuff from Dave Mills
+
+  include/ntpd.h@1.82.4.2, 2005-09-17 00:33:27-04:00, stenn@deacon.udel.edu +1 -0
+    more leap stuff from Dave Mills
+
+  ntpd/ntp_control.c@1.79.1.2, 2005-09-17 00:33:17-04:00, stenn@deacon.udel.edu +1 -1
+    more leap stuff from Dave Mills
+
+  ntpd/ntp_crypto.c@1.98.1.2, 2005-09-17 00:33:17-04:00, stenn@deacon.udel.edu +2 -5
+    more leap stuff from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.110, 2005-09-17 00:33:17-04:00, stenn@deacon.udel.edu +11 -13
+    more leap stuff from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.3, 2005-09-17 00:33:17-04:00, stenn@deacon.udel.edu +4 -2
+    more leap stuff from Dave Mills
+
+ChangeSet@1.1251.51.5, 2005-09-16 22:47:54-04:00, mayer@pogo.udel.edu +1 -0
+  Fix wildcards to return valid socket interface structure addresses - for Heiko's fix bug #450
+
+  ntpd/ntp_io.c@1.187.1.3, 2005-09-16 22:47:16-04:00, mayer@pogo.udel.edu +10 -18
+    Fix wildcards to return valid socket interface structure addresses - for Heiko's fix bug #450
+
+ChangeSet@1.1251.51.4, 2005-09-15 02:37:45-04:00, stenn@whimsy.udel.edu +1 -0
+  strip quotes from filenames in the config file.  From Heiko Gerstung
+
+  ntpd/ntp_config.c@1.129.3.3, 2005-09-15 02:37:30-04:00, stenn@whimsy.udel.edu +18 -0
+    strip quotes from filenames in the config file.  From Heiko Gerstung
+
+ChangeSet@1.1251.51.3, 2005-09-15 02:26:33-04:00, stenn@whimsy.udel.edu +64 -0
+  Documentation changes from Dave Mills
+
+  html/accopt.html@1.24, 2005-09-15 02:22:25-04:00, stenn@whimsy.udel.edu +66 -61
+    Documentation changes from Dave Mills
+
+  html/assoc.html@1.21, 2005-09-15 02:22:25-04:00, stenn@whimsy.udel.edu +52 -51
+    Documentation changes from Dave Mills
+
+  html/audio.html@1.17, 2005-09-15 02:22:26-04:00, stenn@whimsy.udel.edu +48 -47
+    Documentation changes from Dave Mills
+
+  html/authopt.html@1.33, 2005-09-15 02:22:26-04:00, stenn@whimsy.udel.edu +139 -137
+    Documentation changes from Dave Mills
+
+  html/clockopt.html@1.18, 2005-09-15 02:22:26-04:00, stenn@whimsy.udel.edu +61 -60
+    Documentation changes from Dave Mills
+
+  html/confopt.html@1.31.1.1, 2005-09-15 02:22:27-04:00, stenn@whimsy.udel.edu +18 -15
+    Documentation changes from Dave Mills
+
+  html/copyright.html@1.31, 2005-09-15 02:22:27-04:00, stenn@whimsy.udel.edu +72 -71
+    Documentation changes from Dave Mills
+
+  html/debug.html@1.23, 2005-09-15 02:22:28-04:00, stenn@whimsy.udel.edu +119 -118
+    Documentation changes from Dave Mills
+
+  html/drivers/driver1.html@1.15, 2005-09-15 02:22:47-04:00, stenn@whimsy.udel.edu +59 -58
+    Documentation changes from Dave Mills
+
+  html/drivers/driver18.html@1.15, 2005-09-15 02:22:48-04:00, stenn@whimsy.udel.edu +56 -55
+    Documentation changes from Dave Mills
+
+  html/drivers/driver20.html@1.14, 2005-09-15 02:22:49-04:00, stenn@whimsy.udel.edu +59 -65
+    Documentation changes from Dave Mills
+
+  html/drivers/driver22.html@1.17, 2005-09-15 02:22:49-04:00, stenn@whimsy.udel.edu +47 -46
+    Documentation changes from Dave Mills
+
+  html/drivers/driver27.html@1.14, 2005-09-15 02:22:50-04:00, stenn@whimsy.udel.edu +198 -200
+    Documentation changes from Dave Mills
+
+  html/drivers/driver29.html@1.14, 2005-09-15 02:22:50-04:00, stenn@whimsy.udel.edu +769 -790
+    Documentation changes from Dave Mills
+
+  html/drivers/driver3.html@1.11, 2005-09-15 02:22:50-04:00, stenn@whimsy.udel.edu +47 -47
+    Documentation changes from Dave Mills
+
+  html/drivers/driver30.html@1.19, 2005-09-15 02:22:51-04:00, stenn@whimsy.udel.edu +77 -78
+    Documentation changes from Dave Mills
+
+  html/drivers/driver31.html@1.2, 2005-09-15 02:22:51-04:00, stenn@whimsy.udel.edu +52 -50
+    Documentation changes from Dave Mills
+
+  html/drivers/driver32.html@1.12, 2005-09-15 02:22:51-04:00, stenn@whimsy.udel.edu +23 -23
+    Documentation changes from Dave Mills
+
+  html/drivers/driver33.html@1.12, 2005-09-15 02:22:52-04:00, stenn@whimsy.udel.edu +23 -23
+    Documentation changes from Dave Mills
+
+  html/drivers/driver34.html@1.11, 2005-09-15 02:22:52-04:00, stenn@whimsy.udel.edu +44 -50
+    Documentation changes from Dave Mills
+
+  html/drivers/driver35.html@1.14, 2005-09-15 02:22:52-04:00, stenn@whimsy.udel.edu +41 -40
+    Documentation changes from Dave Mills
+
+  html/drivers/driver36.html@1.26, 2005-09-15 02:22:53-04:00, stenn@whimsy.udel.edu +162 -151
+    Documentation changes from Dave Mills
+
+  html/drivers/driver37.html@1.12, 2005-09-15 02:22:53-04:00, stenn@whimsy.udel.edu +44 -43
+    Documentation changes from Dave Mills
+
+  html/drivers/driver38.html@1.13, 2005-09-15 02:22:53-04:00, stenn@whimsy.udel.edu +124 -131
+    Documentation changes from Dave Mills
+
+  html/drivers/driver39.html@1.13, 2005-09-15 02:22:54-04:00, stenn@whimsy.udel.edu +106 -109
+    Documentation changes from Dave Mills
+
+  html/drivers/driver4.html@1.12, 2005-09-15 02:22:54-04:00, stenn@whimsy.udel.edu +59 -58
+    Documentation changes from Dave Mills
+
+  html/drivers/driver40.html@1.13, 2005-09-15 02:22:54-04:00, stenn@whimsy.udel.edu +129 -138
+    Documentation changes from Dave Mills
+
+  html/drivers/driver42.html@1.12, 2005-09-15 02:22:55-04:00, stenn@whimsy.udel.edu +23 -22
+    Documentation changes from Dave Mills
+
+  html/drivers/driver43.html@1.10, 2005-09-15 02:22:55-04:00, stenn@whimsy.udel.edu +35 -34
+    Documentation changes from Dave Mills
+
+  html/drivers/driver44.html@1.12, 2005-09-15 02:22:55-04:00, stenn@whimsy.udel.edu +81 -82
+    Documentation changes from Dave Mills
+
+  html/drivers/driver6.html@1.20, 2005-09-15 02:22:56-04:00, stenn@whimsy.udel.edu +73 -72
+    Documentation changes from Dave Mills
+
+  html/drivers/driver7.html@1.22, 2005-09-15 02:22:56-04:00, stenn@whimsy.udel.edu +207 -206
+    Documentation changes from Dave Mills
+
+  html/drivers/driver8.html@1.18, 2005-09-15 02:22:57-04:00, stenn@whimsy.udel.edu +230 -419
+    Documentation changes from Dave Mills
+
+  html/drivers/oncore-shmem.html@1.12, 2005-09-15 02:22:57-04:00, stenn@whimsy.udel.edu +58 -55
+    Documentation changes from Dave Mills
+
+  html/drivers/tf582_4.html@1.2, 2005-09-15 02:22:58-04:00, stenn@whimsy.udel.edu +57 -58
+    Documentation changes from Dave Mills
+
+  html/extern.html@1.14, 2005-09-15 02:22:28-04:00, stenn@whimsy.udel.edu +26 -25
+    Documentation changes from Dave Mills
+
+  html/howto.html@1.18, 2005-09-15 02:22:28-04:00, stenn@whimsy.udel.edu +89 -88
+    Documentation changes from Dave Mills
+
+  html/index.html@1.32, 2005-09-15 02:22:29-04:00, stenn@whimsy.udel.edu +1 -1
+    Documentation changes from Dave Mills
+
+  html/kern.html@1.14, 2005-09-15 02:22:29-04:00, stenn@whimsy.udel.edu +27 -26
+    Documentation changes from Dave Mills
+
+  html/keygen.html@1.6, 2005-09-15 02:22:29-04:00, stenn@whimsy.udel.edu +109 -105
+    Documentation changes from Dave Mills
+
+  html/ldisc.html@1.12, 2005-09-15 02:22:30-04:00, stenn@whimsy.udel.edu +35 -34
+    Documentation changes from Dave Mills
+
+  html/manyopt.html@1.11, 2005-09-15 02:22:30-04:00, stenn@whimsy.udel.edu +51 -50
+    Documentation changes from Dave Mills
+
+  html/measure.html@1.11, 2005-09-15 02:22:30-04:00, stenn@whimsy.udel.edu +16 -15
+    Documentation changes from Dave Mills
+
+  html/miscopt.html@1.31, 2005-09-15 02:22:31-04:00, stenn@whimsy.udel.edu +87 -83
+    Documentation changes from Dave Mills
+
+  html/monopt.html@1.20, 2005-09-15 02:22:31-04:00, stenn@whimsy.udel.edu +122 -117
+    Documentation changes from Dave Mills
+
+  html/msyslog.html@1.4, 2005-09-15 02:22:31-04:00, stenn@whimsy.udel.edu +120 -118
+    Documentation changes from Dave Mills
+
+  html/mx4200data.html@1.11, 2005-09-15 02:22:32-04:00, stenn@whimsy.udel.edu +1069 -1068
+    Documentation changes from Dave Mills
+
+  html/notes.html@1.17, 2005-09-15 02:22:32-04:00, stenn@whimsy.udel.edu +150 -149
+    Documentation changes from Dave Mills
+
+  html/ntpd.html@1.36.1.1, 2005-09-15 02:22:33-04:00, stenn@whimsy.udel.edu +167 -169
+    Documentation changes from Dave Mills
+
+  html/ntpdate.html@1.17, 2005-09-15 02:22:33-04:00, stenn@whimsy.udel.edu +63 -62
+    Documentation changes from Dave Mills
+
+  html/ntpdc.html@1.20.1.1, 2005-09-15 02:22:33-04:00, stenn@whimsy.udel.edu +153 -152
+    Documentation changes from Dave Mills
+
+  html/ntpdsim.html@1.4, 2005-09-15 02:22:34-04:00, stenn@whimsy.udel.edu +58 -57
+    Documentation changes from Dave Mills
+
+  html/ntpq.html@1.27, 2005-09-15 02:22:34-04:00, stenn@whimsy.udel.edu +1 -1
+    Documentation changes from Dave Mills
+
+  html/ntptime.html@1.15, 2005-09-15 02:22:34-04:00, stenn@whimsy.udel.edu +41 -40
+    Documentation changes from Dave Mills
+
+  html/ntptrace.html@1.13, 2005-09-15 02:22:35-04:00, stenn@whimsy.udel.edu +37 -36
+    Documentation changes from Dave Mills
+
+  html/parsedata.html@1.11, 2005-09-15 02:22:35-04:00, stenn@whimsy.udel.edu +77 -76
+    Documentation changes from Dave Mills
+
+  html/parsenew.html@1.10, 2005-09-15 02:22:35-04:00, stenn@whimsy.udel.edu +50 -47
+    Documentation changes from Dave Mills
+
+  html/pps.html@1.18, 2005-09-15 02:22:36-04:00, stenn@whimsy.udel.edu +34 -33
+    Documentation changes from Dave Mills
+
+  html/prefer.html@1.15, 2005-09-15 02:22:36-04:00, stenn@whimsy.udel.edu +65 -64
+    Documentation changes from Dave Mills
+
+  html/rdebug.html@1.15, 2005-09-15 02:22:36-04:00, stenn@whimsy.udel.edu +26 -25
+    Documentation changes from Dave Mills
+
+  html/refclock.html@1.32, 2005-09-15 02:22:37-04:00, stenn@whimsy.udel.edu +89 -89
+    Documentation changes from Dave Mills
+
+  html/release.html@1.30, 2005-09-15 02:22:37-04:00, stenn@whimsy.udel.edu +52 -50
+    Documentation changes from Dave Mills
+
+  html/sntp.html@1.4, 2005-09-15 02:22:37-04:00, stenn@whimsy.udel.edu +50 -49
+    Documentation changes from Dave Mills
+
+  html/tickadj.html@1.14, 2005-09-15 02:22:38-04:00, stenn@whimsy.udel.edu +36 -35
+    Documentation changes from Dave Mills
+
+ChangeSet@1.1251.51.2, 2005-09-15 01:59:15-04:00, stenn@whimsy.udel.edu +10 -0
+  "ident" changes from Dave Mills
+
+  include/ntp_config.h@1.37.1.1, 2005-09-15 01:57:52-04:00, stenn@whimsy.udel.edu +5 -4
+    "ident" changes from Dave Mills
+
+  include/ntp_control.h@1.28, 2005-09-15 01:57:53-04:00, stenn@whimsy.udel.edu +2 -1
+    "ident" changes from Dave Mills
+
+  include/ntp_crypto.h@1.36, 2005-09-15 01:57:53-04:00, stenn@whimsy.udel.edu +6 -4
+    "ident" changes from Dave Mills
+
+  include/ntpd.h@1.82.4.1, 2005-09-15 01:57:58-04:00, stenn@whimsy.udel.edu +8 -0
+    "ident" changes from Dave Mills
+
+  ntpd/ntp_config.c@1.129.3.2, 2005-09-15 01:58:05-04:00, stenn@whimsy.udel.edu +6 -0
+    "ident" changes from Dave Mills
+
+  ntpd/ntp_control.c@1.79.1.1, 2005-09-15 01:58:05-04:00, stenn@whimsy.udel.edu +21 -4
+    "ident" changes from Dave Mills
+
+  ntpd/ntp_crypto.c@1.98.1.1, 2005-09-15 01:58:06-04:00, stenn@whimsy.udel.edu +57 -63
+    "ident" changes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.109, 2005-09-15 01:58:07-04:00, stenn@whimsy.udel.edu +41 -8
+    "ident" changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.2, 2005-09-15 01:58:08-04:00, stenn@whimsy.udel.edu +4 -8
+    "ident" changes from Dave Mills
+
+  ntpd/refclock_wwvb.c@1.16, 2005-09-15 01:58:20-04:00, stenn@whimsy.udel.edu +1 -1
+    "ident" changes from Dave Mills
+
+ChangeSet@1.1298, 2005-09-11 22:43:01-04:00, stenn@pogo.udel.edu +35 -0
+  libopts updates
+
+  build@1.22, 2005-09-11 22:40:14-04:00, stenn@pogo.udel.edu +6 -0
+    libopts updates
+
+  m4/libopts.m4@1.7, 2005-09-11 22:41:00-04:00, stenn@pogo.udel.edu +79 -55
+    libopts updates
+
+  ntpd/Makefile.am@1.43, 2005-09-11 22:41:01-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  ntpd/ntpd-opts.def@1.2, 2005-09-11 22:41:03-04:00, stenn@pogo.udel.edu +1 -0
+    libopts updates
+
+  ntpd/ntpdsim-opts.def@1.2, 2005-09-11 22:41:03-04:00, stenn@pogo.udel.edu +1 -0
+    libopts updates
+
+  ntpdc/ntpdc-opts.def@1.5, 2005-09-11 22:41:07-04:00, stenn@pogo.udel.edu +1 -0
+    libopts updates
+
+  ntpq/ntpq-opts.def@1.4, 2005-09-11 22:41:08-04:00, stenn@pogo.udel.edu +1 -0
+    libopts updates
+
+  sntp/configure.ac@1.10, 2005-09-11 22:41:15-04:00, stenn@pogo.udel.edu +3 -2
+    libopts updates
+
+  sntp/libopts.m4@1.3, 2005-09-11 22:41:15-04:00, stenn@pogo.udel.edu +79 -55
+    libopts updates
+
+  sntp/libopts/MakeDefs.inc@1.2, 2005-09-11 22:41:16-04:00, stenn@pogo.udel.edu +0 -5
+    libopts updates
+
+  sntp/libopts/README@1.2, 2005-09-11 22:41:16-04:00, stenn@pogo.udel.edu +9 -7
+    libopts updates
+
+  sntp/libopts/autoopts.c@1.2, 2005-09-11 22:41:16-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/autoopts.h@1.2, 2005-09-11 22:41:16-04:00, stenn@pogo.udel.edu +3 -5
+    libopts updates
+
+  sntp/libopts/autoopts/options.h@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +4 -4
+    libopts updates
+
+  sntp/libopts/boolean.c@1.2, 2005-09-11 22:41:16-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/compat/compat.h@1.2, 2005-09-11 22:41:19-04:00, stenn@pogo.udel.edu +51 -10
+    libopts updates
+
+  sntp/libopts/cook.c@1.2, 2005-09-11 22:41:16-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/enumeration.c@1.2, 2005-09-11 22:41:16-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/environment.c@1.2, 2005-09-11 22:41:16-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/libopts.m4@1.2, 2005-09-11 22:41:17-04:00, stenn@pogo.udel.edu +83 -56
+    libopts updates
+
+  sntp/libopts/load.c@1.2, 2005-09-11 22:41:17-04:00, stenn@pogo.udel.edu +14 -10
+    libopts updates
+
+  sntp/libopts/makeshell.c@1.2, 2005-09-11 22:41:17-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/nested.c@1.2, 2005-09-11 22:41:17-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/numeric.c@1.2, 2005-09-11 22:41:17-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/pgusage.c@1.2, 2005-09-11 22:41:17-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/proto.h@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +1 -28
+    libopts updates
+
+  sntp/libopts/putshell.c@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/restore.c@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/save.c@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/sort.c@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/stack.c@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/streqvcmp.c@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/text_mmap.c@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/usage.c@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+  sntp/libopts/version.c@1.2, 2005-09-11 22:41:18-04:00, stenn@pogo.udel.edu +1 -1
+    libopts updates
+
+ChangeSet@1.1251.50.1, 2005-09-06 22:16:23-04:00, mayer@pogo.udel.edu +1 -0
+  Revamped the input_handler code to separate the reading of  packets from the selection process and logic
+
+  ntpd/ntp_io.c@1.187.2.1, 2005-09-06 22:15:55-04:00, mayer@pogo.udel.edu +250 -283
+    Revamped the input_handler code to separate the reading of  packets from the selection process and logic
+
+ChangeSet@1.1251.38.40, 2005-09-06 19:34:59+00:00, kardel@pogo.udel.edu +3 -0
+  ntp_io.c:
+    remove address family agnostic port assignment
+  ntp_proto.c:
+    minor debug code cleanup
+  ntp_peer.c:
+    only call peer_crypto_clear() when disconnecting the interface
+
+  ntpd/ntp_io.c@1.207, 2005-09-06 19:33:08+00:00, kardel@pogo.udel.edu +0 -1
+    remove address family agnostic port assignment
+
+  ntpd/ntp_peer.c@1.90, 2005-09-04 10:28:53+00:00, kardel@pogo.udel.edu +15 -6
+    only call peer_crypto_clear() when disconnecting the interface
+
+  ntpd/ntp_proto.c@1.238, 2005-09-04 10:29:51+00:00, kardel@pogo.udel.edu +6 -5
+    minor debug code cleanup
+
+ChangeSet@1.1251.1.142, 2005-09-04 15:32:05-05:00, stenn@poog.il.thewrittenword.com +1 -0
+  scopeid and WANT_IPV6 cleanup
+
+  ntpd/ntp_io.c@1.187.1.1, 2005-09-04 15:31:35-05:00, stenn@poog.il.thewrittenword.com +18 -6
+    scopeid and WANT_IPV6 cleanup
+
+ChangeSet@1.1251.49.1, 2005-09-04 06:44:18+00:00, kardel@pogo.udel.edu +1 -0
+  configure.ac:
+    with NetBSD 3.99.8 the CTTY requirement has been lifted
+
+  configure.ac@1.359.3.1, 2005-09-04 06:42:31+00:00, kardel@pogo.udel.edu +3 -3
+    with NetBSD 3.99.8 the CTTY requirement has been lifted
+
+ChangeSet@1.1251.47.6, 2005-09-01 21:52:27-04:00, stenn@pogo.udel.edu +1 -0
+  net/route.h fixups
+
+  configure.ac@1.359.1.19, 2005-09-01 21:52:04-04:00, stenn@pogo.udel.edu +5 -1
+    net/route.h fixups
+
+ChangeSet@1.1251.47.5, 2005-09-01 05:11:00-04:00, stenn@pogo.udel.edu +1 -0
+  look for net/route.h and struct rt_msghdr
+
+  configure.ac@1.359.1.18, 2005-09-01 05:10:49-04:00, stenn@pogo.udel.edu +16 -0
+    look for net/route.h and struct rt_msghdr
+
+ChangeSet@1.1251.38.37, 2005-09-01 08:01:32+00:00, kardel@pogo.udel.edu +2 -0
+  ntp_proto.c:
+    avoid double free by cleaning up peer_crypto_clear() as
+    the clear_to_zero trick didn't work any more here and
+    also covered up some memory leaks.
+  ntp_crypto.c:
+    mark possible memleak - MUST be verified
+
+  ntpd/ntp_crypto.c@1.100, 2005-09-01 07:59:08+00:00, kardel@pogo.udel.edu +3 -0
+    mark possible memleak - MUST be verified
+
+  ntpd/ntp_proto.c@1.237, 2005-09-01 07:59:43+00:00, kardel@pogo.udel.edu +35 -7
+    avoid double free by cleaning up peer_crypto_clear() as
+    the clear_to_zero trick didn't work any more here and
+    also covered up some memory leaks.
+
+ChangeSet@1.1178.6.1, 2005-08-31 18:35:44-04:00, stenn@pogo.udel.edu +1 -0
+  lose snavely
+
+  flock-build@1.30.1.1, 2005-08-31 18:35:34-04:00, stenn@pogo.udel.edu +2 -2
+    lose snavely
+
+ChangeSet@1.1251.38.36, 2005-08-31 08:05:42+00:00, kardel@pogo.udel.edu +6 -0
+  ntpdc_ops.c, layout.std, ntp_request.c, ntp_io.c, ntp_request.h, ntp.h:
+    output interface life time in log and via ntpdc
+
+  include/ntp.h@1.125, 2005-08-31 08:04:57+00:00, kardel@pogo.udel.edu +1 -0
+    output interface life time in log and via ntpdc
+
+  include/ntp_request.h@1.28, 2005-08-31 08:04:58+00:00, kardel@pogo.udel.edu +1 -0
+    output interface life time in log and via ntpdc
+
+  ntpd/ntp_io.c@1.206, 2005-08-31 08:05:09+00:00, kardel@pogo.udel.edu +7 -2
+    output interface life time in log and via ntpdc
+
+  ntpd/ntp_request.c@1.64, 2005-08-31 08:05:10+00:00, kardel@pogo.udel.edu +1 -0
+    output interface life time in log and via ntpdc
+
+  ntpdc/layout.std@1.6, 2005-08-31 08:05:14+00:00, kardel@pogo.udel.edu +8 -7
+    output interface life time in log and via ntpdc
+
+  ntpdc/ntpdc_ops.c@1.44, 2005-08-31 08:05:15+00:00, kardel@pogo.udel.edu +6 -5
+    output interface life time in log and via ntpdc
+
+ChangeSet@1.1251.38.35, 2005-08-29 20:50:15+00:00, kardel@pogo.udel.edu +2 -0
+  ntp_peer.c:
+    just disconnect from interface when no interface can be found
+  ntp_io.c:
+    rename HAS_BSD_ROUTING_SOCKET to HAS_ROUTING_SOCKET
+
+  ntpd/ntp_io.c@1.205, 2005-08-29 20:48:09+00:00, kardel@pogo.udel.edu +9 -9
+    rename HAS_BSD_ROUTING_SOCKET to HAS_ROUTING_SOCKET
+
+  ntpd/ntp_peer.c@1.89, 2005-08-29 20:49:02+00:00, kardel@pogo.udel.edu +1 -15
+    just disconnect from interface when no interface can be found
+
+ChangeSet@1.1251.38.34, 2005-08-29 11:36:25+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    fix compile conditional for asyncio_readers
+    make RTM_IFINFO also optional
+    make RTM_IFANNOUNCE optional to compile on platforms that that have that message (Solaris)
+
+  ntpd/ntp_io.c@1.204, 2005-08-29 11:24:27+00:00, kardel@pogo.udel.edu +5 -5
+    fix compile conditional for asyncio_readers
+
+  ntpd/ntp_io.c@1.203, 2005-08-29 11:15:04+00:00, kardel@pogo.udel.edu +2 -0
+    make RTM_IFINFO also optional
+
+  ntpd/ntp_io.c@1.202, 2005-08-29 11:05:23+00:00, kardel@pogo.udel.edu +2 -0
+    make RTM_IFANNOUNCE optional to compile on platforms that that have that message (Solaris)
+
+ChangeSet@1.1251.38.33, 2005-08-29 10:23:15+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    cleanup compilation for HAS_BSD_ROUTING_SOCKET in undefined case
+    move on variable into corresponding conditional block
+
+  ntpd/ntp_io.c@1.201, 2005-08-29 10:19:59+00:00, kardel@pogo.udel.edu +18 -9
+    cleanup compilation for HAS_BSD_ROUTING_SOCKET in undefined case
+    move on variable into corresponding conditional block
+
+ChangeSet@1.1251.38.31, 2005-08-28 15:49:21-04:00, mayer@pogo.udel.edu +1 -0
+  Remove O/S Specific macro and add conditions for SUPPORT_ASYNCIO_READER that replaced it
+
+  ntpd/ntp_io.c@1.197.1.1, 2005-08-28 15:48:45-04:00, mayer@pogo.udel.edu +6 -3
+    Remove O/S Specific macro and add conditions for SUPPORT_ASYNCIO_READER that replaced it
+
+ChangeSet@1.1295, 2005-08-28 04:51:03-04:00, stenn@pogo.udel.edu +5 -0
+  libopts cleanup
+
+  Makefile.am@1.54, 2005-08-28 04:48:59-04:00, stenn@pogo.udel.edu +0 -2
+    libopts cleanup
+
+  configure.ac@1.374, 2005-08-28 04:49:00-04:00, stenn@pogo.udel.edu +1 -1
+    libopts cleanup
+
+  m4/libopts.m4@1.6, 2005-08-28 04:49:38-04:00, stenn@pogo.udel.edu +8 -5
+    libopts cleanup
+
+  sntp/Makefile.am@1.8, 2005-08-28 04:49:50-04:00, stenn@pogo.udel.edu +0 -1
+    libopts cleanup
+
+  sntp/libopts.m4@1.2, 2005-08-28 04:49:51-04:00, stenn@pogo.udel.edu +8 -5
+    libopts cleanup
+
+ChangeSet@1.1251.48.3, 2005-08-28 08:37:28+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    more enum cleanup
+
+  ntpd/ntp_io.c@1.199, 2005-08-28 08:36:06+00:00, kardel@pogo.udel.edu +1 -1
+    more enum cleanup
+
+ChangeSet@1.1251.48.2, 2005-08-28 07:37:24+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    add FreeBSD for routing socket notification
+
+  ntpd/ntp_io.c@1.198, 2005-08-28 07:36:29+00:00, kardel@pogo.udel.edu +3 -1
+    add FreeBSD for routing socket notification
+
+ChangeSet@1.1251.48.1, 2005-08-28 06:43:17+00:00, kardel@pogo.udel.edu +1 -0
+  ntpd.h:
+    typoe
+
+  include/ntpd.h@1.82.1.9, 2005-08-27 23:20:18+00:00, kardel@pogo.udel.edu +1 -1
+    typoe
+
+ChangeSet@1.1251.38.30, 2005-08-27 22:03:00-04:00, mayer@pogo.udel.edu +1 -0
+  Fixed mispelled function
+
+  include/ntpd.h@1.82.3.1, 2005-08-27 22:02:43-04:00, mayer@pogo.udel.edu +1 -1
+    Fixed mispelled function
+
+ChangeSet@1.1251.38.29, 2005-08-27 23:08:36+00:00, kardel@pogo.udel.edu +3 -0
+  add async io readers (non-refclock, non-socket input)
+  re-factor (simplify) descriptor handling
+  add routing socket listening for quick interface updates
+
+  include/ntpd.h@1.82.1.8, 2005-08-27 23:02:32+00:00, kardel@pogo.udel.edu +2 -0
+
+  ntpd/ntp_io.c@1.197, 2005-08-27 23:02:42+00:00, kardel@pogo.udel.edu +354 -249
+
+  ntpd/ntp_timer.c@1.30, 2005-08-27 23:02:44+00:00, kardel@pogo.udel.edu +7 -1
+
+ChangeSet@1.1251.47.2, 2005-08-26 17:47:52-04:00, mayer@pogo.udel.edu +1 -0
+  add ntp_random.h to include list
+
+  libntp/systime.c@1.35, 2005-08-26 17:47:29-04:00, mayer@pogo.udel.edu +1 -0
+    add ntp_random.h to include list
+
+ChangeSet@1.1251.47.1, 2005-08-26 17:12:27-04:00, mayer@pogo.udel.edu +2 -0
+  Additional changes to support ntp_random
+
+  include/Makefile.am@1.19.1.1, 2005-08-26 17:12:02-04:00, mayer@pogo.udel.edu +1 -0
+    Additional changes to support ntp_random
+
+  util/ntp-keygen.c@1.33, 2005-08-26 17:12:02-04:00, mayer@pogo.udel.edu +1 -0
+    Additional changes to support ntp_random
+
+ChangeSet@1.1251.38.26, 2005-08-26 09:17:19-04:00, mayer@pogo.udel.edu +1 -0
+  Added ntp_debug.h
+
+  include/Makefile.am@1.20, 2005-08-26 09:17:04-04:00, mayer@pogo.udel.edu +2 -0
+    Added ntp_debug.h
+
+ChangeSet@1.1293, 2005-08-26 04:40:05-04:00, stenn@pogo.udel.edu +9 -0
+  autogen stuff
+
+  BitKeeper/etc/ignore@1.44, 2005-08-26 04:39:02-04:00, stenn@pogo.udel.edu +40 -48
+    Update the ignore list
+
+  BitKeeper/etc/ignore@1.43, 2005-08-26 04:26:21-04:00, stenn@pogo.udel.edu +3 -0
+    added ntpd/ntpd.1 ntpd/ntpdsim.1 sntp/sntp.1
+
+  BitKeeper/etc/ignore@1.42, 2005-08-26 04:25:08-04:00, stenn@pogo.udel.edu +1 -0
+    added *-opts.texi
+
+  BitKeeper/etc/ignore@1.41, 2005-08-26 04:25:02-04:00, stenn@pogo.udel.edu +1 -0
+    added *-opts.menu
+
+  BitKeeper/etc/ignore@1.40, 2005-08-26 04:24:24-04:00, stenn@pogo.udel.edu +1 -0
+    added *-opts.h
+
+  BitKeeper/etc/ignore@1.39, 2005-08-26 04:24:21-04:00, stenn@pogo.udel.edu +1 -0
+    added *-opts.c
+
+  Makefile.am@1.53, 2005-08-26 04:20:12-04:00, stenn@pogo.udel.edu +3 -3
+    new libopts stuff
+
+  configure.ac@1.373, 2005-08-26 04:20:13-04:00, stenn@pogo.udel.edu +0 -1
+    new libopts stuff
+
+  m4/libopts.m4@1.5, 2005-08-26 04:38:44-04:00, stenn@pogo.udel.edu +1 -1
+    changes for 1 copy of libopts
+
+  m4/libopts.m4@1.4, 2005-08-26 04:20:13-04:00, stenn@pogo.udel.edu +147 -94
+    new libopts stuff
+
+  ntpd/ntpd-opts.def@1.1, 2005-08-26 04:18:41-04:00, stenn@pogo.udel.edu +42 -0
+
+  ntpd/ntpd-opts.def@1.0, 2005-08-26 04:18:41-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/ntpd/ntpd-opts.def
+
+  ntpd/ntpdbase-opts.def@1.1, 2005-08-26 04:18:41-04:00, stenn@pogo.udel.edu +472 -0
+
+  ntpd/ntpdbase-opts.def@1.0, 2005-08-26 04:18:41-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/ntpd/ntpdbase-opts.def
+
+  ntpd/ntpdsim-opts.def@1.1, 2005-08-26 04:18:41-04:00, stenn@pogo.udel.edu +43 -0
+
+  ntpd/ntpdsim-opts.def@1.0, 2005-08-26 04:18:41-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/ntpd/ntpdsim-opts.def
+
+  sntp/libopts.m4@1.1, 2005-08-26 04:20:29-04:00, stenn@pogo.udel.edu +418 -0
+
+  sntp/libopts.m4@1.0, 2005-08-26 04:20:29-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts.m4
+
+  sntp/sntp-opts.def@1.1, 2005-08-26 04:18:42-04:00, stenn@pogo.udel.edu +388 -0
+
+  sntp/sntp-opts.def@1.0, 2005-08-26 04:18:42-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/sntp-opts.def
+
+ChangeSet@1.1292, 2005-08-26 04:17:32-04:00, stenn@pogo.udel.edu +36 -0
+  New sntp/libopts/
+
+  sntp/libopts/COPYING.lgpl@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +502 -0
+
+  sntp/libopts/COPYING.lgpl@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/COPYING.lgpl
+
+  sntp/libopts/COPYING.mbsd@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +26 -0
+
+  sntp/libopts/COPYING.mbsd@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/COPYING.mbsd
+
+  sntp/libopts/MakeDefs.inc@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +5 -0
+
+  sntp/libopts/MakeDefs.inc@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/MakeDefs.inc
+
+  sntp/libopts/Makefile.am@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +19 -0
+
+  sntp/libopts/Makefile.am@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/Makefile.am
+
+  sntp/libopts/README@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +89 -0
+
+  sntp/libopts/README@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/README
+
+  sntp/libopts/autoopts.c@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +1033 -0
+
+  sntp/libopts/autoopts.c@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/autoopts.c
+
+  sntp/libopts/autoopts.h@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +350 -0
+
+  sntp/libopts/autoopts.h@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/autoopts.h
+
+  sntp/libopts/autoopts/options.h@1.1, 2005-08-26 04:16:29-04:00, stenn@pogo.udel.edu +864 -0
+
+  sntp/libopts/autoopts/options.h@1.0, 2005-08-26 04:16:29-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/autoopts/options.h
+
+  sntp/libopts/autoopts/usage-txt.h@1.1, 2005-08-26 04:16:29-04:00, stenn@pogo.udel.edu +479 -0
+
+  sntp/libopts/autoopts/usage-txt.h@1.0, 2005-08-26 04:16:29-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/autoopts/usage-txt.h
+
+  sntp/libopts/boolean.c@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +102 -0
+
+  sntp/libopts/boolean.c@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/boolean.c
+
+  sntp/libopts/compat/compat.h@1.1, 2005-08-26 04:16:36-04:00, stenn@pogo.udel.edu +249 -0
+
+  sntp/libopts/compat/compat.h@1.0, 2005-08-26 04:16:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/compat/compat.h
+
+  sntp/libopts/compat/pathfind.c@1.1, 2005-08-26 04:16:36-04:00, stenn@pogo.udel.edu +330 -0
+
+  sntp/libopts/compat/pathfind.c@1.0, 2005-08-26 04:16:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/compat/pathfind.c
+
+  sntp/libopts/configfile.c@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +1277 -0
+
+  sntp/libopts/configfile.c@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/configfile.c
+
+  sntp/libopts/cook.c@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +355 -0
+
+  sntp/libopts/cook.c@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/cook.c
+
+  sntp/libopts/enumeration.c@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +449 -0
+
+  sntp/libopts/enumeration.c@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/enumeration.c
+
+  sntp/libopts/environment.c@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +261 -0
+
+  sntp/libopts/environment.c@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/environment.c
+
+  sntp/libopts/genshell.c@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +300 -0
+
+  sntp/libopts/genshell.c@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/genshell.c
+
+  sntp/libopts/genshell.h@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +143 -0
+
+  sntp/libopts/genshell.h@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/genshell.h
+
+  sntp/libopts/libopts.c@1.1, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +29 -0
+
+  sntp/libopts/libopts.c@1.0, 2005-08-26 04:16:19-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/libopts.c
+
+  sntp/libopts/libopts.m4@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +418 -0
+
+  sntp/libopts/libopts.m4@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/libopts.m4
+
+  sntp/libopts/load.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +516 -0
+
+  sntp/libopts/load.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/load.c
+
+  sntp/libopts/makeshell.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +1100 -0
+
+  sntp/libopts/makeshell.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/makeshell.c
+
+  sntp/libopts/nested.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +705 -0
+
+  sntp/libopts/nested.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/nested.c
+
+  sntp/libopts/numeric.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +89 -0
+
+  sntp/libopts/numeric.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/numeric.c
+
+  sntp/libopts/pgusage.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +154 -0
+
+  sntp/libopts/pgusage.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/pgusage.c
+
+  sntp/libopts/proto.h@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +124 -0
+
+  sntp/libopts/proto.h@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/proto.h
+
+  sntp/libopts/putshell.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +333 -0
+
+  sntp/libopts/putshell.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/putshell.c
+
+  sntp/libopts/restore.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +207 -0
+
+  sntp/libopts/restore.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/restore.c
+
+  sntp/libopts/save.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +499 -0
+
+  sntp/libopts/save.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/save.c
+
+  sntp/libopts/sort.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +369 -0
+
+  sntp/libopts/sort.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/sort.c
+
+  sntp/libopts/stack.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +224 -0
+
+  sntp/libopts/stack.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/stack.c
+
+  sntp/libopts/streqvcmp.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +292 -0
+
+  sntp/libopts/streqvcmp.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/streqvcmp.c
+
+  sntp/libopts/text_mmap.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +312 -0
+
+  sntp/libopts/text_mmap.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/text_mmap.c
+
+  sntp/libopts/tokenize.c@1.1, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +322 -0
+
+  sntp/libopts/tokenize.c@1.0, 2005-08-26 04:16:20-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/tokenize.c
+
+  sntp/libopts/usage.c@1.1, 2005-08-26 04:16:21-04:00, stenn@pogo.udel.edu +651 -0
+
+  sntp/libopts/usage.c@1.0, 2005-08-26 04:16:21-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/usage.c
+
+  sntp/libopts/version.c@1.1, 2005-08-26 04:16:21-04:00, stenn@pogo.udel.edu +177 -0
+
+  sntp/libopts/version.c@1.0, 2005-08-26 04:16:21-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/sntp/libopts/version.c
+
+ChangeSet@1.1291, 2005-08-26 04:14:47-04:00, stenn@pogo.udel.edu +82 -0
+  Remove old libopts/
+
+  BitKeeper/deleted/.del-AUTHORS~919220bd6931acb6@1.2, 2005-08-26 04:10:25-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/AUTHORS
+
+  BitKeeper/deleted/.del-COPYING.lgpl~853519b5bad8e831@1.2, 2005-08-26 04:10:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/COPYING.lgpl
+
+  BitKeeper/deleted/.del-COPYING.mbsd~aff4e32ff033d919@1.2, 2005-08-26 04:10:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/COPYING.mbsd
+
+  BitKeeper/deleted/.del-COPYING~8c2b7b26f1103860@1.2, 2005-08-26 04:10:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/COPYING
+
+  BitKeeper/deleted/.del-ChangeLog~c979333e966b22d9@1.2, 2005-08-26 04:10:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/ChangeLog
+
+  BitKeeper/deleted/.del-INSTALL~ca12b1677cba0915@1.3, 2005-08-26 04:10:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/INSTALL
+
+  BitKeeper/deleted/.del-MakeDefs.inc~c24ab9f3f0dafc84@1.2, 2005-08-26 04:10:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/MakeDefs.inc
+
+  BitKeeper/deleted/.del-Makefile.am~11c11bf4e04c9fef@1.2, 2005-08-26 04:10:31-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/Makefile.am
+
+  BitKeeper/deleted/.del-Makefile.am~b09ab3b23945dc7d@1.2, 2005-08-26 04:10:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/Makefile.am
+
+  BitKeeper/deleted/.del-NEWS~e38f345aacec5424@1.2, 2005-08-26 04:10:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/NEWS
+
+  BitKeeper/deleted/.del-README~3d9dfae6a0b32f8f@1.2, 2005-08-26 04:10:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/README
+
+  BitKeeper/deleted/.del-aclocal.m4~a95cc6b1d68ce121@1.2, 2005-08-26 04:10:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/aclocal.m4
+
+  BitKeeper/deleted/.del-autoopts.c~4dc696de338cb6ff@1.2, 2005-08-26 04:10:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/autoopts.c
+
+  BitKeeper/deleted/.del-autoopts.c~7c82dc5b2088549a@1.2, 2005-08-26 04:10:32-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/autoopts.c
+
+  BitKeeper/deleted/.del-autoopts.h~173454953926d863@1.2, 2005-08-26 04:10:32-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/autoopts.h
+
+  BitKeeper/deleted/.del-autoopts.h~fd482d3a2757e6af@1.2, 2005-08-26 04:10:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/autoopts.h
+
+  BitKeeper/deleted/.del-boolean.c~2652efe8d27b68e9@1.2, 2005-08-26 04:10:32-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/boolean.c
+
+  BitKeeper/deleted/.del-boolean.c~9803ac347fdb027d@1.2, 2005-08-26 04:10:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/boolean.c
+
+  BitKeeper/deleted/.del-bootstrap~9952937cb65f4e1f@1.2, 2005-08-26 04:10:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/bootstrap
+
+  BitKeeper/deleted/.del-compat.h~cd9fa19720e0fe1c@1.2, 2005-08-26 04:10:31-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/compat/compat.h
+
+  BitKeeper/deleted/.del-compile~f47b1af5aede22b6@1.3, 2005-08-26 04:10:35-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/m4/compile
+
+  BitKeeper/deleted/.del-config-h.in~8d2fefd4275dba47@1.2, 2005-08-26 04:10:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/config-h.in
+
+  BitKeeper/deleted/.del-config-h.in~~fc94cec5e99b4813@1.2, 2005-08-26 04:10:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/config-h.in~
+
+  BitKeeper/deleted/.del-config.guess~8473c3316e92525f@1.3, 2005-08-26 04:10:35-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/m4/config.guess
+
+  BitKeeper/deleted/.del-config.sub~bf4f78cdfb8642b@1.3, 2005-08-26 04:10:35-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/m4/config.sub
+
+  BitKeeper/deleted/.del-configfile.c~87486f85c5694535@1.2, 2005-08-26 04:10:32-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/configfile.c
+
+  BitKeeper/deleted/.del-configfile.c~922a8f1381d4425f@1.2, 2005-08-26 04:10:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/configfile.c
+
+  BitKeeper/deleted/.del-configure.ac~1f0f0eec3e2cb683@1.2, 2005-08-26 04:10:28-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/configure.ac
+
+  BitKeeper/deleted/.del-configure~76f3b0b55a913ee5@1.2, 2005-08-26 04:10:28-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/configure
+
+  BitKeeper/deleted/.del-cook.c~288d493179287c2@1.2, 2005-08-26 04:10:28-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/cook.c
+
+  BitKeeper/deleted/.del-cook.c~513ed79970fc81b@1.2, 2005-08-26 04:10:32-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/cook.c
+
+  BitKeeper/deleted/.del-depcomp~40528c8625c2eb1f@1.3, 2005-08-26 04:10:35-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/m4/depcomp
+
+  BitKeeper/deleted/.del-enumeration.c~680ef3a6fda2472@1.2, 2005-08-26 04:10:32-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/enumeration.c
+
+  BitKeeper/deleted/.del-enumeration.c~741b004a8edc0491@1.2, 2005-08-26 04:10:28-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/enumeration.c
+
+  BitKeeper/deleted/.del-environment.c~886b51f1289ec004@1.2, 2005-08-26 04:10:28-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/environment.c
+
+  BitKeeper/deleted/.del-environment.c~cbea5891d018489b@1.2, 2005-08-26 04:10:32-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/environment.c
+
+  BitKeeper/deleted/.del-genshell.c~4665114445e930eb@1.2, 2005-08-26 04:10:32-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/genshell.c
+
+  BitKeeper/deleted/.del-genshell.c~d3404cb6e62977d2@1.2, 2005-08-26 04:10:28-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/genshell.c
+
+  BitKeeper/deleted/.del-genshell.h~4cbba4ca99e1ce0d@1.2, 2005-08-26 04:10:33-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/genshell.h
+
+  BitKeeper/deleted/.del-genshell.h~9fcd6a369b750dc@1.2, 2005-08-26 04:10:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/genshell.h
+
+  BitKeeper/deleted/.del-install-sh~5350b467a9780ac5@1.3, 2005-08-26 04:10:35-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/m4/install-sh
+
+  BitKeeper/deleted/.del-libopts.c~322a932038fac5bb@1.2, 2005-08-26 04:10:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts.c
+
+  BitKeeper/deleted/.del-libopts.c~a3b1fda2ee8709ec@1.2, 2005-08-26 04:10:33-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/libopts.c
+
+  BitKeeper/deleted/.del-libopts.m4~71eb82c61ddaa00e@1.2, 2005-08-26 04:10:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts.m4
+
+  BitKeeper/deleted/.del-libopts.m4~dba275de2f39a7f7@1.2, 2005-08-26 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/m4/libopts.m4
+
+  BitKeeper/deleted/.del-load.c~7f48d00d8b58104a@1.2, 2005-08-26 04:10:33-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/load.c
+
+  BitKeeper/deleted/.del-load.c~b61a8aee9ce882d5@1.2, 2005-08-26 04:10:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/load.c
+
+  BitKeeper/deleted/.del-ltmain.sh~1c7887b5d1c077fc@1.3, 2005-08-26 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/m4/ltmain.sh
+
+  BitKeeper/deleted/.del-makeshell.c~a1d60647811b3095@1.2, 2005-08-26 04:10:33-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/makeshell.c
+
+  BitKeeper/deleted/.del-makeshell.c~f8b9cf5964d39db3@1.2, 2005-08-26 04:10:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/makeshell.c
+
+  BitKeeper/deleted/.del-missing~f915814376b31ab6@1.3, 2005-08-26 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/m4/missing
+
+  BitKeeper/deleted/.del-nested.c~86ef6834b872d57@1.2, 2005-08-26 04:10:33-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/nested.c
+
+  BitKeeper/deleted/.del-nested.c~96ea01864b196d05@1.2, 2005-08-26 04:10:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/nested.c
+
+  BitKeeper/deleted/.del-numeric.c~e2c152233ded2202@1.2, 2005-08-26 04:10:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/numeric.c
+
+  BitKeeper/deleted/.del-numeric.c~f02f2a6d69035d0c@1.2, 2005-08-26 04:10:33-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/numeric.c
+
+  BitKeeper/deleted/.del-options.h~7de16fb1feb01fb9@1.2, 2005-08-26 04:10:31-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/autoopts/options.h
+
+  BitKeeper/deleted/.del-pathfind.c~4df984bf91869e5@1.2, 2005-08-26 04:10:31-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/compat/pathfind.c
+
+  BitKeeper/deleted/.del-pgusage.c~c9ca334462225a7a@1.2, 2005-08-26 04:10:33-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/pgusage.c
+
+  BitKeeper/deleted/.del-pgusage.c~ca33905e5c7aa1df@1.2, 2005-08-26 04:10:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/pgusage.c
+
+  BitKeeper/deleted/.del-proto.h~452f423c89ac200e@1.2, 2005-08-26 04:10:33-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/proto.h
+
+  BitKeeper/deleted/.del-proto.h~e8c7a2af94986c41@1.2, 2005-08-26 04:10:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/proto.h
+
+  BitKeeper/deleted/.del-putshell.c~229e9255825c2699@1.2, 2005-08-26 04:10:34-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/putshell.c
+
+  BitKeeper/deleted/.del-putshell.c~3f90a9637c1cb3f8@1.2, 2005-08-26 04:10:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/putshell.c
+
+  BitKeeper/deleted/.del-restore.c~786e9e008c497959@1.2, 2005-08-26 04:10:34-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/restore.c
+
+  BitKeeper/deleted/.del-restore.c~c5d1d1e9dde10cf6@1.2, 2005-08-26 04:10:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/restore.c
+
+  BitKeeper/deleted/.del-save.c~16cdb7b3a7320c91@1.2, 2005-08-26 04:10:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/save.c
+
+  BitKeeper/deleted/.del-save.c~9ac698c63285dcdf@1.2, 2005-08-26 04:10:34-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/save.c
+
+  BitKeeper/deleted/.del-sort.c~437339de5156edc@1.2, 2005-08-26 04:10:34-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/sort.c
+
+  BitKeeper/deleted/.del-sort.c~b07de2fbf0002b9e@1.2, 2005-08-26 04:10:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/sort.c
+
+  BitKeeper/deleted/.del-stack.c~23d824507da8a741@1.2, 2005-08-26 04:10:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/stack.c
+
+  BitKeeper/deleted/.del-stack.c~c65d211fa8d2c6d9@1.2, 2005-08-26 04:10:34-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/stack.c
+
+  BitKeeper/deleted/.del-streqvcmp.c~2b01ea402455a9d5@1.2, 2005-08-26 04:10:34-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/streqvcmp.c
+
+  BitKeeper/deleted/.del-streqvcmp.c~ecb35a72608d3d8c@1.2, 2005-08-26 04:10:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/streqvcmp.c
+
+  BitKeeper/deleted/.del-text_mmap.c~7e8b2fb878ad6465@1.2, 2005-08-26 04:10:34-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/text_mmap.c
+
+  BitKeeper/deleted/.del-text_mmap.c~8276cd532e35d7d@1.2, 2005-08-26 04:10:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/text_mmap.c
+
+  BitKeeper/deleted/.del-tokenize.c~994b2aafabe0643a@1.2, 2005-08-26 04:10:31-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/tokenize.c
+
+  BitKeeper/deleted/.del-tokenize.c~e1d05f5d9da9f103@1.2, 2005-08-26 04:10:34-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/tokenize.c
+
+  BitKeeper/deleted/.del-usage-txt.h~3f152e2762854446@1.2, 2005-08-26 04:10:31-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/autoopts/usage-txt.h
+
+  BitKeeper/deleted/.del-usage.c~35ccdb8f15358479@1.2, 2005-08-26 04:10:31-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/usage.c
+
+  BitKeeper/deleted/.del-usage.c~7218cbdb39fe114@1.2, 2005-08-26 04:10:35-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/usage.c
+
+  BitKeeper/deleted/.del-version.c~51a770ed71ec2abe@1.2, 2005-08-26 04:10:35-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts/version.c
+
+  BitKeeper/deleted/.del-version.c~f7d51067e17b5364@1.2, 2005-08-26 04:10:31-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/version.c
+
+ChangeSet@1.1251.45.17, 2005-08-25 21:01:42+00:00, kardel@pogo.udel.edu +5 -0
+  ntpdc_ops.c, ntp_request.c, ntp_peer.c, ntpd.h, ntp_request.h:
+    remove reset pollinterval feature
+
+  include/ntp_request.h@1.27, 2005-08-25 20:59:02+00:00, kardel@pogo.udel.edu +0 -1
+    remove reset pollinterval feature
+
+  include/ntpd.h@1.82.2.6, 2005-08-25 20:59:37+00:00, kardel@pogo.udel.edu +0 -1
+    remove reset pollinterval feature
+
+  ntpd/ntp_peer.c@1.82.1.6, 2005-08-25 21:00:06+00:00, kardel@pogo.udel.edu +0 -41
+    remove reset pollinterval feature
+
+  ntpd/ntp_request.c@1.63, 2005-08-25 21:00:30+00:00, kardel@pogo.udel.edu +0 -107
+    remove reset pollinterval feature
+
+  ntpdc/ntpdc_ops.c@1.43, 2005-08-25 21:00:51+00:00, kardel@pogo.udel.edu +0 -60
+    remove reset pollinterval feature
+
+ChangeSet@1.1251.45.16, 2005-08-24 21:42:33+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    fix interface number log output
+
+  ntpd/ntp_io.c@1.196, 2005-08-24 21:35:29+00:00, kardel@pogo.udel.edu +6 -5
+    fix interface number log output
+
+ChangeSet@1.1251.45.15, 2005-08-24 13:30:29+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    keep others out while rebuilding the environment
+
+  ntpd/ntp_io.c@1.195, 2005-08-24 13:29:28+00:00, kardel@pogo.udel.edu +2 -2
+    keep others out while rebuilding the environment
+
+ChangeSet@1.1251.45.14, 2005-08-24 13:09:54+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    paren missing
+
+  ntpd/ntp_io.c@1.194, 2005-08-24 13:09:07+00:00, kardel@pogo.udel.edu +1 -0
+    paren missing
+
+ChangeSet@1.1251.45.13, 2005-08-24 09:28:44+00:00, kardel@pogo.udel.edu +8 -0
+  layout.std:
+    ifnum introduced
+  ntpdc_ops.c:
+    list ifnum and ifindex
+  layout.std:
+    ifnum added
+  ntp_request.c, ntp_peer.c:
+    re-name interface_t to struct interface - _t collides with POSIX system namespaces
+  ntp_io.c:
+    change interface_t to struct interface ad _t typedef pollute POSIX system name space
+    use ifnum for interface numbers (ifindex seems often to be 0 on NetBSD)
+    re-arrange intialization
+    move setting of loopback interface variable out of conversion function to just before inserting the
+    interface structure into the lists
+    make ifindex be the original
+  ntpd.h:
+    change interface_t to struct interface as _t typdef pollute POSIX system name space
+  ntp_request.h:
+    add ifnum as interface instance generation number
+  ntp.h:
+    change interface_t to struct interface as _t typedef pollute POSIX system namespace
+    add ifnum as interface instance generation number
+
+  include/ntp.h@1.118.1.6, 2005-08-24 08:38:28+00:00, kardel@pogo.udel.edu +2 -3
+    change interface_t to struct interface as _t typedef pollute POSIX system namespace
+    add ifnum as interface instance generation number
+
+  include/ntp_request.h@1.26, 2005-08-24 08:39:48+00:00, kardel@pogo.udel.edu +2 -1
+    add ifnum as interface instance generation number
+
+  include/ntpd.h@1.82.2.5, 2005-08-24 08:39:56+00:00, kardel@pogo.udel.edu +7 -7
+    change interface_t to struct interface as _t typdef pollute POSIX system name space
+
+  ntpd/ntp_io.c@1.193, 2005-08-24 08:41:23+00:00, kardel@pogo.udel.edu +172 -179
+    change interface_t to struct interface ad _t typedef pollute POSIX system name space
+    use ifnum for interface numbers (ifindex seems often to be 0 on NetBSD)
+    re-arrange intialization
+    move setting of loopback interface variable out of conversion function to just before inserting the
+    interface structure into the lists
+    make ifindex be the original
+
+  ntpd/ntp_peer.c@1.82.1.5, 2005-08-24 08:43:26+00:00, kardel@pogo.udel.edu +1 -1
+    re-name interface_t to struct interface - _t collides with POSIX system namespaces
+
+  ntpd/ntp_request.c@1.62, 2005-08-24 08:43:36+00:00, kardel@pogo.udel.edu +2 -1
+    re-name interface_t to struct interface - _t collides with POSIX system namespaces
+
+  ntpdc/layout.std@1.5, 2005-08-24 09:14:07+00:00, kardel@pogo.udel.edu +1 -0
+    ifnum introduced
+
+  ntpdc/layout.std@1.4, 2005-08-24 08:44:08+00:00, kardel@pogo.udel.edu +4 -4
+    ifnum added
+
+  ntpdc/ntpdc_ops.c@1.42, 2005-08-24 08:44:19+00:00, kardel@pogo.udel.edu +6 -5
+    list ifnum and ifindex
+
+ChangeSet@1.1251.45.12, 2005-08-24 06:24:42+00:00, kardel@pogo.udel.edu +11 -0
+  ntpdc_ops.c, ntp_request.c:
+    support dynamic modifier
+    support pollreset request
+  ntpdc.c:
+    allow first argument to be optional
+  ntp_peer.c, ntp_config.c, ntp_config.h, ntp.h:
+    support dynamic modifier
+  ntpd.h:
+    support resetting of poll interval on interface changes and manually
+  ntp_request.h:
+    support dynamic modifier
+    add pollreset mode 7 request
+  ntpdc.html, confopt.html:
+    document "dynamic" modifier keyword for peer/server configuration
+
+  html/confopt.html@1.32, 2005-08-23 21:57:40+00:00, kardel@pogo.udel.edu +4 -2
+    document "dynamic" modifier keyword for peer/server configuration
+
+  html/ntpdc.html@1.22, 2005-08-23 21:58:22+00:00, kardel@pogo.udel.edu +4 -4
+    document "dynamic" modifier keyword for peer/server configuration
+
+  include/ntp.h@1.118.1.5, 2005-08-23 21:58:53+00:00, kardel@pogo.udel.edu +1 -0
+    support dynamic modifier
+
+  include/ntp_config.h@1.38, 2005-08-23 21:59:22+00:00, kardel@pogo.udel.edu +1 -0
+    support dynamic modifier
+
+  include/ntp_request.h@1.25, 2005-08-23 21:59:35+00:00, kardel@pogo.udel.edu +2 -0
+    support dynamic modifier
+    add pollreset mode 7 request
+
+  include/ntpd.h@1.82.2.4, 2005-08-23 22:00:13+00:00, kardel@pogo.udel.edu +2 -0
+    support resetting of poll interval on interface changes and manually
+
+  ntpd/ntp_config.c@1.129.2.4, 2005-08-23 22:01:04+00:00, kardel@pogo.udel.edu +6 -0
+    support dynamic modifier
+
+  ntpd/ntp_peer.c@1.82.1.4, 2005-08-23 22:01:20+00:00, kardel@pogo.udel.edu +96 -53
+    support dynamic modifier
+
+  ntpd/ntp_request.c@1.61, 2005-08-23 22:01:31+00:00, kardel@pogo.udel.edu +116 -5
+    support dynamic modifier
+    support pollreset request
+
+  ntpdc/ntpdc.c@1.40.1.3, 2005-08-23 22:02:13+00:00, kardel@pogo.udel.edu +1 -1
+    allow first argument to be optional
+
+  ntpdc/ntpdc_ops.c@1.41, 2005-08-23 22:02:29+00:00, kardel@pogo.udel.edu +62 -1
+    support dynamic modifier
+    support pollreset request
+
+ChangeSet@1.1251.45.11, 2005-08-23 06:45:17+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    cleanup debug output handling
+
+  ntpd/ntp_io.c@1.192, 2005-08-23 06:44:45+00:00, kardel@pogo.udel.edu +10 -5
+    cleanup debug output handling
+
+ChangeSet@1.1251.45.10, 2005-08-23 06:26:45+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    fixed crash in debug error message
+
+  ntpd/ntp_io.c@1.191, 2005-08-23 06:25:35+00:00, kardel@pogo.udel.edu +10 -5
+    fixed crash in debug error message
+
+ChangeSet@1.1251.46.1, 2005-08-22 19:45:14-04:00, stenn@whimsy.udel.edu +4 -0
+  beacon stuff from Dave Mills
+
+  include/ntp.h@1.118.2.1, 2005-08-22 19:44:08-04:00, stenn@whimsy.udel.edu +2 -1
+    beacon stuff from Dave Mills
+
+  include/ntp_config.h@1.37, 2005-08-22 19:44:09-04:00, stenn@whimsy.udel.edu +1 -0
+    beacon stuff from Dave Mills
+
+  ntpd/ntp_config.c@1.129.2.3, 2005-08-22 19:44:35-04:00, stenn@whimsy.udel.edu +9 -0
+    beacon stuff from Dave Mills
+
+  ntpd/ntp_proto.c@1.232.1.1, 2005-08-22 19:44:37-04:00, stenn@whimsy.udel.edu +26 -9
+    beacon stuff from Dave Mills
+
+ChangeSet@1.1251.45.8, 2005-08-22 22:43:21+00:00, kardel@pogo.udel.edu +3 -0
+  ntp_request.c:
+     return clean 0.0.0.0 addresses while a peer has no interface
+  ntp_control.c:
+    return clean 0.0.0.0 addresses while a peer has no interface
+  ntpd.h:
+    cleanup declarations
+
+  include/ntpd.h@1.82.2.3, 2005-08-22 22:41:56+00:00, kardel@pogo.udel.edu +1 -1
+    cleanup declarations
+
+  ntpd/ntp_control.c@1.81, 2005-08-22 22:42:21+00:00, kardel@pogo.udel.edu +3 -0
+    return clean 0.0.0.0 addresses while a peer has no interface
+
+  ntpd/ntp_request.c@1.60, 2005-08-22 22:42:49+00:00, kardel@pogo.udel.edu +2 -2
+     return clean 0.0.0.0 addresses while a peer has no interface
+
+ChangeSet@1.1251.45.7, 2005-08-22 21:57:08+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_proto.c:
+    don't attempt to transmit on peers that currently have not interface
+
+  ntpd/ntp_proto.c@1.235, 2005-08-22 21:56:14+00:00, kardel@pogo.udel.edu +3 -0
+    don't attempt to transmit on peers that currently have not interface
+
+ChangeSet@1.1251.45.6, 2005-08-22 16:19:29+00:00, kardel@pogo.udel.edu +4 -0
+  ntpdc_ops.c:
+    cleanup output format
+    add enable/disable output
+  ntp_proto.c:
+    as we are re-binding all interfaces on interface list changes a refresh on
+    transmit is not needed
+  ntp_peer.c:
+    re-bind all interfaces when the interface list changes
+    unbind interface when refclock configuration fails
+    correct setting of a new interface for a peer
+  ntp_io.c:
+    re-bind all interfaces when the interface list changes
+
+  ntpd/ntp_io.c@1.190, 2005-08-22 16:16:16+00:00, kardel@pogo.udel.edu +12 -6
+    re-bind all interfaces when the interface list changes
+
+  ntpd/ntp_peer.c@1.82.1.3, 2005-08-22 16:16:37+00:00, kardel@pogo.udel.edu +42 -21
+    re-bind all interfaces when the interface list changes
+    unbind interface when refclock configuration fails
+    correct setting of a new interface for a peer
+
+  ntpd/ntp_proto.c@1.234, 2005-08-22 16:17:21+00:00, kardel@pogo.udel.edu +0 -14
+    as we are re-binding all interfaces on interface list changes a refresh on
+    transmit is not needed
+
+  ntpdc/ntpdc_ops.c@1.40, 2005-08-22 16:18:50+00:00, kardel@pogo.udel.edu +4 -3
+    cleanup output format
+    add enable/disable output
+
+ChangeSet@1.1251.45.5, 2005-08-22 12:05:51+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_io.c:
+    fix list initialization for interface->peer
+    correct initizalization of loopback_interface global
+
+  ntpd/ntp_io.c@1.189, 2005-08-22 12:03:15+00:00, kardel@pogo.udel.edu +8 -0
+    fix list initialization for interface->peer
+    correct initizalization of loopback_interface global
+
+ChangeSet@1.1251.45.4, 2005-08-21 19:22:34+00:00, kardel@pogo.udel.edu +19 -0
+  ntpdc_ops.c:
+    add ifstats and ifreload commands
+  layout.std:
+    update with data structure used with ntpdc's ifstats and ifreload commands
+  ntp_debug.h:
+    new file
+  ntpd.h:
+    add support for dynamic interface updates
+  ntp_request.h:
+    define data structure needed for ntpdc's ifstats and ifreload command
+  ntp.h:
+    integrate dynamic interface update support
+  ntp_util.c:
+    prepare for exit logging - not active yet
+  ntp_timer.c:
+    add timeout routine to periodically update ntpd's interface list
+  ntp_restrict.c:
+    support forcefully removing an interface entry (dynamic interface update support)
+  ntp_request.c:
+    add ifstats and ifreload backend implementation
+  ntp_proto.c:
+    cope with peeers that have no interface
+  ntp_peer.c:
+    rework peer management to cope with dynamic interface list updates
+  ntp_monitor.c:
+    remove monitor information when an interface is removed
+  ntp_io.c:
+    rework to support dynamic interface updating
+    array inter_list[] is gone
+    reduce #ifdef DEBUG section with DPRINTF macro
+  ntp_crypto.c, ntp_control.c:
+    cope with peers having no current interface
+  cmd_args.c:
+    add "-U interface_update_interval" option
+  ntpdc.html:
+    document ifstats and ifreload commands
+  ntpd.html:
+    document dynamic interface update interval option (-U <value>)
+
+  html/ntpd.html@1.37, 2005-08-21 18:58:34+00:00, kardel@pogo.udel.edu +3 -1
+    document dynamic interface update interval option (-U <value>)
+
+  html/ntpdc.html@1.21, 2005-08-21 19:00:12+00:00, kardel@pogo.udel.edu +4 -0
+    document ifstats and ifreload commands
+
+  include/ntp.h@1.118.1.3, 2005-08-21 19:08:54+00:00, kardel@pogo.udel.edu +19 -10
+    integrate dynamic interface update support
+
+  include/ntp_debug.h@1.1, 2005-08-21 19:13:08+00:00, kardel@pogo.udel.edu +26 -0
+
+  include/ntp_debug.h@1.0, 2005-08-21 19:13:08+00:00, kardel@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/kardel/ntp-dev/include/ntp_debug.h
+
+  include/ntp_request.h@1.24, 2005-08-21 19:09:23+00:00, kardel@pogo.udel.edu +38 -0
+    define data structure needed for ntpdc's ifstats and ifreload command
+
+  include/ntpd.h@1.82.2.2, 2005-08-21 19:09:58+00:00, kardel@pogo.udel.edu +21 -7
+    add support for dynamic interface updates
+
+  ntpd/cmd_args.c@1.34.1.1, 2005-08-21 19:01:02+00:00, kardel@pogo.udel.edu +21 -2
+    add "-U interface_update_interval" option
+
+  ntpd/ntp_control.c@1.80, 2005-08-21 19:01:42+00:00, kardel@pogo.udel.edu +4 -2
+    cope with peers having no current interface
+
+  ntpd/ntp_crypto.c@1.97.1.1, 2005-08-21 19:02:16+00:00, kardel@pogo.udel.edu +6 -0
+    cope with peers having no current interface
+
+  ntpd/ntp_io.c@1.188, 2005-08-21 19:02:25+00:00, kardel@pogo.udel.edu +885 -557
+    rework to support dynamic interface updating
+    array inter_list[] is gone
+    reduce #ifdef DEBUG section with DPRINTF macro
+
+  ntpd/ntp_monitor.c@1.15.1.1, 2005-08-21 19:03:40+00:00, kardel@pogo.udel.edu +18 -0
+    remove monitor information when an interface is removed
+
+  ntpd/ntp_peer.c@1.82.1.2, 2005-08-21 19:04:10+00:00, kardel@pogo.udel.edu +159 -40
+    rework peer management to cope with dynamic interface list updates
+
+  ntpd/ntp_proto.c@1.233, 2005-08-21 19:05:07+00:00, kardel@pogo.udel.edu +117 -92
+    cope with peeers that have no interface
+
+  ntpd/ntp_request.c@1.59, 2005-08-21 19:06:16+00:00, kardel@pogo.udel.edu +145 -32
+    add ifstats and ifreload backend implementation
+
+  ntpd/ntp_restrict.c@1.18, 2005-08-21 19:06:45+00:00, kardel@pogo.udel.edu +4 -2
+    support forcefully removing an interface entry (dynamic interface update support)
+
+  ntpd/ntp_timer.c@1.29, 2005-08-21 19:07:17+00:00, kardel@pogo.udel.edu +16 -0
+    add timeout routine to periodically update ntpd's interface list
+
+  ntpd/ntp_util.c@1.37, 2005-08-21 19:08:06+00:00, kardel@pogo.udel.edu +15 -3
+    prepare for exit logging - not active yet
+
+  ntpdc/layout.std@1.3, 2005-08-21 19:13:42+00:00, kardel@pogo.udel.edu +19 -0
+    update with data structure used with ntpdc's ifstats and ifreload commands
+
+  ntpdc/ntpdc_ops.c@1.39, 2005-08-21 19:14:33+00:00, kardel@pogo.udel.edu +125 -0
+    add ifstats and ifreload commands
+
+ChangeSet@1.1251.45.3, 2005-08-16 20:49:01-04:00, stenn@whimsy.udel.edu +2 -0
+  preempt stuff from Dave Mills
+
+  include/ntp.h@1.118.1.2, 2005-08-16 20:47:23-04:00, stenn@whimsy.udel.edu +1 -2
+    preempt stuff from Dave Mills
+
+  ntpd/ntp_proto.c@1.232, 2005-08-16 20:48:26-04:00, stenn@whimsy.udel.edu +34 -45
+    preempt stuff from Dave Mills
+
+ChangeSet@1.1251.45.2, 2005-08-16 05:34:28-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 478] use "end" keyword to stop config file processing
+
+  include/ntp_config.h@1.36, 2005-08-16 05:34:09-04:00, stenn@whimsy.udel.edu +2 -1
+    [Bug 478] use "end" keyword to stop config file processing
+
+  ntpd/ntp_config.c@1.129.2.2, 2005-08-16 05:34:10-04:00, stenn@whimsy.udel.edu +9 -0
+    [Bug 478] use "end" keyword to stop config file processing
+
+ChangeSet@1.1251.45.1, 2005-08-16 02:49:46-04:00, stenn@whimsy.udel.edu +6 -0
+  preempt stuff from Dave Mills
+
+  include/ntp.h@1.118.1.1, 2005-08-16 02:49:21-04:00, stenn@whimsy.udel.edu +6 -5
+    preempt stuff from Dave Mills
+
+  include/ntp_config.h@1.35, 2005-08-16 02:49:22-04:00, stenn@whimsy.udel.edu +1 -1
+    preempt stuff from Dave Mills
+
+  include/ntpd.h@1.82.2.1, 2005-08-16 02:49:27-04:00, stenn@whimsy.udel.edu +0 -1
+    preempt stuff from Dave Mills
+
+  ntpd/ntp_config.c@1.129.2.1, 2005-08-16 02:48:22-04:00, stenn@whimsy.udel.edu +3 -3
+    preempt stuff from Dave Mills
+
+  ntpd/ntp_peer.c@1.82.1.1, 2005-08-16 02:48:24-04:00, stenn@whimsy.udel.edu +5 -32
+    preempt stuff from Dave Mills
+
+  ntpd/ntp_proto.c@1.231, 2005-08-16 02:48:25-04:00, stenn@whimsy.udel.edu +69 -70
+    preempt stuff from Dave Mills
+
+ChangeSet@1.1251.44.1, 2005-08-15 19:41:00-04:00, mayer@pogo.udel.edu +14 -0
+  Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  include/ntp.h@1.119, 2005-08-15 17:50:32-04:00, mayer@pogo.udel.edu +1 -0
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  include/ntp_random.h@1.1, 2005-08-15 17:59:37-04:00, mayer@pogo.udel.edu +14 -0
+
+  include/ntp_random.h@1.0, 2005-08-15 17:59:37-04:00, mayer@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/mayer/ntp-dev/include/ntp_random.h
+
+  include/ntpd.h@1.82.1.2, 2005-08-15 17:50:34-04:00, mayer@pogo.udel.edu +0 -7
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  libntp/Makefile.am@1.36, 2005-08-15 17:50:35-04:00, mayer@pogo.udel.edu +1 -1
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  libntp/ntp_random.c@1.5, 2005-08-15 17:50:37-04:00, mayer@pogo.udel.edu +5 -2
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  libntp/ntp_random.c@1.4, 2005-08-14 15:51:54-04:00, mayer@pogo.udel.edu +0 -0
+    Rename: libntp/random.c -> libntp/ntp_random.c
+
+  ntpd/ntp_config.c@1.129.1.2, 2005-08-15 17:50:39-04:00, mayer@pogo.udel.edu +1 -0
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  ntpd/ntp_crypto.c@1.98, 2005-08-15 17:50:40-04:00, mayer@pogo.udel.edu +1 -0
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  ntpd/ntp_monitor.c@1.16, 2005-08-15 17:50:40-04:00, mayer@pogo.udel.edu +1 -0
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  ntpd/ntp_peer.c@1.83, 2005-08-15 17:50:41-04:00, mayer@pogo.udel.edu +1 -0
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  ntpd/ntpd.c@1.61.3.1, 2005-08-15 17:50:41-04:00, mayer@pogo.udel.edu +1 -0
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  ports/winnt/include/config.h@1.40, 2005-08-15 17:52:01-04:00, mayer@pogo.udel.edu +1 -0
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  ports/winnt/libntp/libntp.dsp@1.26, 2005-08-15 17:52:52-04:00, mayer@pogo.udel.edu +8 -20
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  ports/winnt/ntp-keygen/ntpkeygen.dsp@1.9, 2005-08-15 17:53:57-04:00, mayer@pogo.udel.edu +4 -0
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+  ports/winnt/ntpd/ntpd.dsp@1.26, 2005-08-15 17:53:22-04:00, mayer@pogo.udel.edu +5 -1
+    Fixes to support ntp_random on Windows and miscellaneous fixes for all platforms to get everything in the right place
+
+ChangeSet@1.1178.5.6, 2005-08-15 04:01:26-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 477] Linux needs larger RLIM_MEMLOCK, from Cristoph Gysin
+
+  ntpd/ntpd.c@1.54.1.1, 2005-08-15 04:01:12-04:00, stenn@whimsy.udel.edu +12 -0
+    [Bug 477] Linux needs larger RLIM_MEMLOCK, from Cristoph Gysin
+
+ChangeSet@1.1288, 2005-08-15 01:27:24-04:00, stenn@pogo.udel.edu +0 -0
+  Merge pogo.udel.edu:/pogo/users/stenn/ntp-dev-ag
+  into  pogo.udel.edu:/pogo/users/stenn/ntp-dev-ag+
+  [no longer a merge: surgery done]
+
+ChangeSet@1.1287, 2005-08-13 22:08:44-04:00, stenn@pogo.udel.edu +1 -0
+  add to gone file
+
+  BitKeeper/etc/gone@1.7, 2005-08-13 22:07:17-04:00, stenn@pogo.udel.edu +1 -0
+
+ChangeSet@1.1251.38.16, 2005-08-12 04:45:21-04:00, stenn@whimsy.udel.edu +3 -0
+  preempt stuff from Dave Mills
+
+  include/ntpd.h@1.82.1.1, 2005-08-12 04:45:04-04:00, stenn@whimsy.udel.edu +2 -2
+    preempt stuff from Dave Mills
+
+  ntpd/ntp_peer.c@1.82, 2005-08-12 04:44:31-04:00, stenn@whimsy.udel.edu +10 -6
+    preempt stuff from Dave Mills
+
+  ntpd/ntp_proto.c@1.230, 2005-08-12 04:44:31-04:00, stenn@whimsy.udel.edu +18 -17
+    preempt stuff from Dave Mills
+
+ChangeSet@1.1251.38.15, 2005-08-12 04:39:52-04:00, stenn@whimsy.udel.edu +1 -0
+  typo
+
+  ntpdate/Makefile.am@1.13, 2005-08-12 04:39:32-04:00, stenn@whimsy.udel.edu +1 -1
+    typo
+
+ChangeSet@1.1251.38.14, 2005-08-10 10:13:26+00:00, kardel@pogo.udel.edu +1 -0
+  dcfd.c:
+    output revision information
+
+  parseutil/dcfd.c@1.17, 2005-08-10 10:12:31+00:00, kardel@pogo.udel.edu +8 -3
+    output revision information
+
+ChangeSet@1.1251.38.12, 2005-08-10 06:50:23+00:00, kardel@pogo.udel.edu +1 -0
+  dcfd.c:
+    cleanup warnings
+    fix setting of baud rate
+
+  parseutil/dcfd.c@1.16, 2005-08-10 06:49:50+00:00, kardel@pogo.udel.edu +14 -4
+    cleanup warnings
+    fix setting of baud rate
+
+ChangeSet@1.1251.42.9, 2005-08-09 17:02:19-04:00, stenn@whimsy.udel.edu +5 -0
+  cleanup, added "preempt" and "maxclock".  From Dave Mills.
+
+  include/ntp.h@1.118, 2005-08-09 16:59:29-04:00, stenn@whimsy.udel.edu +19 -16
+    cleanup, added "preempt".  From Dave Mills.
+
+  include/ntp_config.h@1.34, 2005-08-09 16:59:30-04:00, stenn@whimsy.udel.edu +9 -7
+    cleanup, added "preempt".  From Dave Mills.
+
+  ntpd/ntp_config.c@1.129.1.1, 2005-08-09 17:01:40-04:00, stenn@whimsy.udel.edu +11 -0
+    cleanup, added "preempt" and "maxclock".  From Dave Mills.
+
+  ntpd/ntp_peer.c@1.81, 2005-08-09 17:01:42-04:00, stenn@whimsy.udel.edu +6 -8
+    cleanup, added "preempt" and "maxclock".  From Dave Mills.
+
+  ntpd/ntp_proto.c@1.229, 2005-08-09 17:01:42-04:00, stenn@whimsy.udel.edu +102 -130
+    cleanup, added "preempt" and "maxclock".  From Dave Mills.
+
+ChangeSet@1.1285, 2005-08-08 02:53:55-04:00, stenn@pogo.udel.edu +18 -0
+  autogen update and more conversion
+
+  include/ntpd.h@1.78.2.1, 2005-08-08 02:52:58-04:00, stenn@pogo.udel.edu +0 -1
+    autogen update and more conversion
+
+  libopts/INSTALL@1.2, 2005-08-08 02:53:06-04:00, stenn@pogo.udel.edu +8 -3
+    autogen update and more conversion
+
+  libopts/m4/compile@1.2, 2005-08-08 02:53:11-04:00, stenn@pogo.udel.edu +4 -4
+    autogen update and more conversion
+
+  libopts/m4/config.guess@1.2, 2005-08-08 02:53:11-04:00, stenn@pogo.udel.edu +234 -270
+    autogen update and more conversion
+
+  libopts/m4/config.sub@1.2, 2005-08-08 02:53:11-04:00, stenn@pogo.udel.edu +13 -17
+    autogen update and more conversion
+
+  libopts/m4/depcomp@1.2, 2005-08-08 02:53:11-04:00, stenn@pogo.udel.edu +30 -23
+    autogen update and more conversion
+
+  libopts/m4/install-sh@1.2, 2005-08-08 02:53:11-04:00, stenn@pogo.udel.edu +3 -3
+    autogen update and more conversion
+
+  libopts/m4/ltmain.sh@1.2, 2005-08-08 02:53:12-04:00, stenn@pogo.udel.edu +124 -222
+    autogen update and more conversion
+
+  libopts/m4/missing@1.2, 2005-08-08 02:53:12-04:00, stenn@pogo.udel.edu +10 -6
+    autogen update and more conversion
+
+  ntpd/Makefile.am@1.42, 2005-08-08 02:53:13-04:00, stenn@pogo.udel.edu +37 -6
+    autogen update and more conversion
+
+  ntpd/cmd_args.c@1.35, 2005-08-08 02:53:13-04:00, stenn@pogo.udel.edu +169 -216
+    autogen update and more conversion
+
+  ntpd/ntp_config.c@1.128.1.1, 2005-08-08 02:53:14-04:00, stenn@pogo.udel.edu +1 -3
+    autogen update and more conversion
+
+  ntpd/ntpd.c@1.66, 2005-08-08 02:53:16-04:00, stenn@pogo.udel.edu +129 -31
+    autogen update and more conversion
+
+  ntpd/ntpsim.c@1.9.1.1, 2005-08-08 02:53:16-04:00, stenn@pogo.udel.edu +9 -0
+    autogen update and more conversion
+
+  ntpdc/ntpdc-opts.def@1.4, 2005-08-08 02:53:20-04:00, stenn@pogo.udel.edu +3 -3
+    autogen update and more conversion
+
+  ntpq/ntpq-opts.def@1.3, 2005-08-08 02:53:20-04:00, stenn@pogo.udel.edu +25 -21
+    autogen update and more conversion
+
+  sntp/Makefile.am@1.7, 2005-08-08 02:53:27-04:00, stenn@pogo.udel.edu +28 -0
+    autogen update and more conversion
+
+  sntp/configure.ac@1.9, 2005-08-08 02:53:27-04:00, stenn@pogo.udel.edu +13 -6
+    autogen update and more conversion
+
+ChangeSet@1.1251.42.8, 2005-08-07 18:12:45-04:00, mayer@pogo.udel.edu +1 -0
+  Fix check for errors when recvfrom() is used
+
+  ntpd/ntp_io.c@1.187, 2005-08-07 18:12:07-04:00, mayer@pogo.udel.edu +4 -5
+    Fix check for errors when recvfrom() is used
+
+ChangeSet@1.1251.38.11, 2005-08-07 15:10:14+00:00, kardel@pogo.udel.edu +4 -0
+  testdcf.c:
+    cleanup warnings
+    document revision on startup
+    fix setting of baud rate
+  refclock_parse.c, parse.c:
+    cleanup size handling wrt/ to buffer boundaries
+  clk_rawdcf.c:
+    clean log output
+    cleanup size handling wrt/ to buffer boundaries
+
+  libparse/clk_rawdcf.c@1.11, 2005-08-07 15:05:50+00:00, kardel@pogo.udel.edu +44 -36
+    clean log output
+    cleanup size handling wrt/ to buffer boundaries
+
+  libparse/parse.c@1.11, 2005-08-07 15:06:09+00:00, kardel@pogo.udel.edu +8 -5
+    cleanup size handling wrt/ to buffer boundaries
+
+  ntpd/refclock_parse.c@1.35, 2005-08-07 15:06:49+00:00, kardel@pogo.udel.edu +7 -4
+    cleanup size handling wrt/ to buffer boundaries
+
+  parseutil/testdcf.c@1.7, 2005-08-07 15:07:56+00:00, kardel@pogo.udel.edu +24 -7
+    cleanup warnings
+    document revision on startup
+    fix setting of baud rate
+
+ChangeSet@1.1251.42.7, 2005-08-05 19:29:48-04:00, mayer@pogo.udel.edu +1 -0
+  Fix for systems that do not support MCAST
+
+  ntpd/ntp_io.c@1.186, 2005-08-05 19:29:28-04:00, mayer@pogo.udel.edu +2 -34
+    Fix for systems that do not support MCAST
+
+ChangeSet@1.1251.42.6, 2005-08-02 23:04:57-04:00, stenn@whimsy.udel.edu +4 -0
+  Lose UDP_WILDCARD_DELIVERY
+
+  TODO@1.8, 2005-08-02 23:04:37-04:00, stenn@whimsy.udel.edu +0 -2
+    Lose UDP_WILDCARD_DELIVERY
+
+  configure.ac@1.359.1.17, 2005-08-02 23:04:38-04:00, stenn@whimsy.udel.edu +0 -60
+    Lose UDP_WILDCARD_DELIVERY
+
+  include/ntp_machine.h@1.20, 2005-08-02 23:04:38-04:00, stenn@whimsy.udel.edu +0 -5
+    Lose UDP_WILDCARD_DELIVERY
+
+  ports/winnt/include/config.h@1.39, 2005-08-02 23:04:39-04:00, stenn@whimsy.udel.edu +0 -1
+    Lose UDP_WILDCARD_DELIVERY
+
+ChangeSet@1.1251.42.5, 2005-08-02 21:48:09-04:00, stenn@whimsy.udel.edu +1 -0
+  Another RANDOM -> ntp_random()
+
+  libntp/systime.c@1.34, 2005-08-02 21:47:51-04:00, stenn@whimsy.udel.edu +2 -1
+    Another RANDOM -> ntp_random()
+
+ChangeSet@1.1251.42.4, 2005-08-02 20:19:27-04:00, stenn@whimsy.udel.edu +17 -0
+  libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  BitKeeper/deleted/.del-ranny.c~3e480692@1.4, 2005-08-02 19:36:07-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: libntp/ranny.c
+
+  configure.ac@1.359.1.16, 2005-08-02 20:18:13-04:00, stenn@whimsy.udel.edu +1 -11
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  include/l_stdlib.h@1.15, 2005-08-02 20:18:14-04:00, stenn@whimsy.udel.edu +0 -13
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  include/ntp.h@1.117, 2005-08-02 20:18:14-04:00, stenn@whimsy.udel.edu +1 -9
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  include/ntp_machine.h@1.19, 2005-08-02 20:18:15-04:00, stenn@whimsy.udel.edu +0 -2
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  include/ntpd.h@1.82, 2005-08-02 20:18:15-04:00, stenn@whimsy.udel.edu +3 -0
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  libntp/Makefile.am@1.35, 2005-08-02 20:18:16-04:00, stenn@whimsy.udel.edu +2 -2
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  libntp/random.c@1.3, 2005-08-02 20:18:16-04:00, stenn@whimsy.udel.edu +9 -9
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  ntpd/ntp_config.c@1.129, 2005-08-02 20:18:17-04:00, stenn@whimsy.udel.edu +1 -1
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  ntpd/ntp_crypto.c@1.97, 2005-08-02 20:18:17-04:00, stenn@whimsy.udel.edu +1 -1
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  ntpd/ntp_monitor.c@1.15, 2005-08-02 20:18:18-04:00, stenn@whimsy.udel.edu +2 -1
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  ntpd/ntp_peer.c@1.80, 2005-08-02 20:18:19-04:00, stenn@whimsy.udel.edu +1 -1
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  ntpd/ntp_proto.c@1.228, 2005-08-02 20:18:19-04:00, stenn@whimsy.udel.edu +1 -1
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  ntpd/ntpd.c@1.61.1.9, 2005-08-02 20:18:20-04:00, stenn@whimsy.udel.edu +1 -1
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  ntpd/ntpsim.c@1.11, 2005-08-02 20:18:21-04:00, stenn@whimsy.udel.edu +1 -1
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  util/Makefile.am@1.26, 2005-08-02 20:18:21-04:00, stenn@whimsy.udel.edu +1 -1
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+  util/ntp-keygen.c@1.32, 2005-08-02 20:18:21-04:00, stenn@whimsy.udel.edu +2 -2
+    libntp/random.c now always provides ntp_[s]random().  Use them instead of RANDOM and SRANDOM.
+
+ChangeSet@1.1251.43.3, 2005-08-02 03:45:25-04:00, stenn@whimsy.udel.edu +1 -0
+  Make it easy to distinguish -stable and -dev snapshots
+
+  version.m4@1.3, 2005-08-02 03:45:00-04:00, stenn@whimsy.udel.edu +1 -1
+    Make it easy to distinguish -stable and -dev snapshots
+
+ChangeSet@1.1251.43.2, 2005-08-02 03:25:30-04:00, stenn@whimsy.udel.edu +6 -0
+  Lose libntp/ranny.c
+
+  include/ntp_stdlib.h@1.22, 2005-08-02 03:22:43-04:00, stenn@whimsy.udel.edu +0 -1
+    Lose libntp/ranny.c
+
+  libntp/Makefile.am@1.34, 2005-08-02 03:23:01-04:00, stenn@whimsy.udel.edu +1 -1
+    Lose libntp/ranny.c
+
+  libntp/systime.c@1.33, 2005-08-02 03:23:15-04:00, stenn@whimsy.udel.edu +3 -1
+    Lose libntp/ranny.c
+
+  ntpd/ntp_peer.c@1.76.1.2, 2005-08-02 03:23:26-04:00, stenn@whimsy.udel.edu +1 -3
+    Lose libntp/ranny.c
+
+  ntpd/ntpd.c@1.61.1.8, 2005-08-02 03:23:28-04:00, stenn@whimsy.udel.edu +0 -1
+    Lose libntp/ranny.c
+
+  ntpd/ntpsim.c@1.10, 2005-08-02 03:23:29-04:00, stenn@whimsy.udel.edu +0 -1
+    Lose libntp/ranny.c
+
+ChangeSet@1.1251.43.1, 2005-08-01 19:40:14-04:00, stenn@whimsy.udel.edu +3 -0
+  Dave Mills: change findpeer(), other cleanup
+
+  include/ntpd.h@1.79.1.1, 2005-08-01 19:36:40-04:00, stenn@whimsy.udel.edu +1 -1
+    Dave Mills: change findpeer()
+
+  ntpd/ntp_peer.c@1.76.1.1, 2005-08-01 19:37:38-04:00, stenn@whimsy.udel.edu +0 -4
+    Dave Mills: change findpeer()
+
+  ntpd/ntp_proto.c@1.227, 2005-08-01 19:37:50-04:00, stenn@whimsy.udel.edu +4 -4
+    Dave Mills: change findpeer(), other cleanup
+
+ChangeSet@1.1251.41.2, 2005-08-01 12:36:38-04:00, mayer@pogo.udel.edu +1 -0
+  Missing break in switch selection
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.16, 2005-08-01 12:36:22-04:00, mayer@pogo.udel.edu +1 -48
+    Missing break in switch selection
+
+ChangeSet@1.1251.41.1, 2005-08-01 12:34:24-04:00, mayer@pogo.udel.edu +3 -0
+  Enable IPv6 multicast interface
+
+  include/ntpd.h@1.78.1.1, 2005-08-01 12:34:07-04:00, mayer@pogo.udel.edu +1 -0
+    Enable IPv6 multicast interface
+
+  ntpd/ntp_io.c@1.185, 2005-08-01 12:34:07-04:00, mayer@pogo.udel.edu +61 -2
+    Enable IPv6 multicast interface
+
+  ntpd/ntp_peer.c@1.77, 2005-08-01 12:34:08-04:00, mayer@pogo.udel.edu +14 -3
+    Enable IPv6 multicast interface
+
+ChangeSet@1.1251.40.1, 2005-07-27 21:25:59+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    fix a long (> 11 years) misconfiguration wrt/ Meinberg cflag factory
+    default setup. CSTOPB was missing for the 7E2 default data format of
+    the DCF77 clocks.
+
+  ntpd/refclock_parse.c@1.34, 2005-07-27 21:24:36+00:00, kardel@pogo.udel.edu +9 -4
+    fix a long (> 11 years) misconfiguration wrt/ Meinberg cflag factory
+    default setup. CSTOPB was missing for the 7E2 default data format of
+    the DCF77 clocks.
+
+ChangeSet@1.1251.38.7, 2005-07-25 12:46:00-04:00, mayer@pogo.udel.edu +1 -0
+  Always provide the addr_ismulticast function
+
+  ntpd/ntp_io.c@1.184, 2005-07-25 12:45:27-04:00, mayer@pogo.udel.edu +1 -1
+    Always provide the addr_ismulticast function
+
+ChangeSet@1.1251.38.6, 2005-07-24 16:41:43-04:00, mayer@pogo.udel.edu +1 -0
+  Fix isaddr_multicast to not be dependent on whether or not MCAST is supported
+
+  ntpd/ntp_io.c@1.183, 2005-07-24 16:41:20-04:00, mayer@pogo.udel.edu +5 -5
+    Fix isaddr_multicast to not be dependent on whether or not MCAST is supported
+
+ChangeSet@1.1251.38.5, 2005-07-24 15:50:24-04:00, mayer@pogo.udel.edu +7 -0
+  Revamp of I/O Completion ports for Windows
+
+  include/recvbuff.h@1.9, 2005-07-24 15:48:34-04:00, mayer@pogo.udel.edu +0 -2
+    Revamp of I/O Completion ports for Windows
+
+  libntp/recvbuff.c@1.11, 2005-07-24 15:48:34-04:00, mayer@pogo.udel.edu +22 -17
+    Revamp of I/O Completion ports for Windows
+
+  ports/winnt/include/ntp_iocompletionport.h@1.9, 2005-07-24 15:48:34-04:00, mayer@pogo.udel.edu +16 -3
+    Revamp of I/O Completion ports for Windows
+
+  ports/winnt/include/transmitbuff.h@1.4, 2005-07-24 15:48:34-04:00, mayer@pogo.udel.edu +4 -14
+    Revamp of I/O Completion ports for Windows
+
+  ports/winnt/libntp/transmitbuff.c@1.5, 2005-07-24 15:48:34-04:00, mayer@pogo.udel.edu +113 -43
+    Revamp of I/O Completion ports for Windows
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.18, 2005-07-24 15:48:34-04:00, mayer@pogo.udel.edu +1 -1
+    Revamp of I/O Completion ports for Windows
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.15, 2005-07-24 15:48:34-04:00, mayer@pogo.udel.edu +182 -61
+    Revamp of I/O Completion ports for Windows
+
+ChangeSet@1.1251.39.4, 2005-07-22 20:32:47-04:00, stenn@pogo.udel.edu +1 -0
+  Remove binio.c,gpstolfp.c,ieee754io.c,mfp_mul.c from libntp.a
+
+  libntp/Makefile.am@1.33, 2005-07-22 20:32:35-04:00, stenn@pogo.udel.edu +4 -4
+    Remove binio.c,gpstolfp.c,ieee754io.c,mfp_mul.c from libntp.a
+
+ChangeSet@1.1251.39.3, 2005-07-21 19:43:37+00:00, kardel@pogo.udel.edu +30 -0
+  Makefile.am:
+    support is gone - overaged files
+  .del-sun4.sun4m~3e480692:
+    Delete: scripts/support/conf/sun4.sun4m
+  .del-sun4.sun4m.faui45m~3e480692:
+    Delete: scripts/support/conf/sun4.sun4m.faui45m
+  .del-sun4.sun4m.faui42~3e480692:
+    Delete: scripts/support/conf/sun4.sun4m.faui42
+  .del-sun4.sun4c~3e480692:
+    Delete: scripts/support/conf/sun4.sun4c
+  .del-sun4.sun4c.Lucifer~3e480692:
+    Delete: scripts/support/conf/sun4.sun4c.Lucifer
+  .del-sun4.sun4.faui45~3e480692:
+    Delete: scripts/support/conf/sun4.sun4.faui45
+  .del-sun4.sun4.faui10~3e480692:
+    Delete: scripts/support/conf/sun4.sun4.faui10
+  .del-sun4.sun4.faui01~3e480692:
+    Delete: scripts/support/conf/sun4.sun4.faui01
+  .del-sun3.sun3~3e480692:
+    Delete: scripts/support/conf/sun3.sun3
+  .del-hp800.hp800~3e480692:
+    Delete: scripts/support/conf/hp800.hp800
+  .del-hp700.hp700~3e480692:
+    Delete: scripts/support/conf/hp700.hp700
+  .del-hp700.hp700.faui47~3e480692:
+    Delete: scripts/support/conf/hp700.hp700.faui47
+  .del-hp300.hp300~3e480692:
+    Delete: scripts/support/conf/hp300.hp300
+  refclock_parse.c:
+    fix bug 455: tripping over NULL pointer on cleanup
+    fix shadow storage logic for ppsphaseadjust and trustime wrt/ time2
+    fix compiler warnings for some platforms wrt/ printf formatstrings and
+        varying structure element sizes
+    reorder assignment in binding to avoid tripping over NULL pointers
+    change contents of version string to include the RCS/CVS Id
+  mfp_mul.c:
+    correct carry propagation implementation
+  Makefile.am:
+    move binio.c, ieee754io.c into libparse
+  .del-setup~3e480692:
+    Delete: scripts/support/etc/setup
+  .del-rc~3e480692:
+    Delete: scripts/support/etc/rc
+  .del-install~3e480692:
+    Delete: scripts/support/etc/install
+  .del-crontab~3e480692:
+    Delete: scripts/support/etc/crontab
+  .del-cron~3e480692:
+    Delete: scripts/support/etc/cron
+  .del-tickconf~3e480692:
+    Delete: scripts/support/conf/tickconf
+  .del-ntp.conf~3e480692:
+    Delete: scripts/support/conf/ntp.conf
+  .del-mvstats~3e480692:
+    Delete: scripts/support/bin/mvstats
+  .del-monl~3e480692:
+    Delete: scripts/support/bin/monl
+  .del-README~3e480692:
+    Delete: scripts/support/README
+  ieee754io.c:
+    Rename: libntp/ieee754io.c -> libparse/ieee754io.c
+  binio.c:
+    Rename: libntp/binio.c -> libparse/binio.c
+  gpstolfp.c:
+    Rename: libntp/gpstolfp.c -> libparse/gpstolfp.c
+  mfp_mul.c:
+    Rename: libntp/mfp_mul.c -> libparse/mfp_mul.c
+
+  BitKeeper/deleted/.del-README~3e480692@1.3, 2005-07-17 20:54:05+00:00, kardel@pogo.udel.edu +0 -73
+    Delete: scripts/support/README
+
+  BitKeeper/deleted/.del-crontab~3e480692@1.3, 2005-07-17 20:54:50+00:00, kardel@pogo.udel.edu +0 -8
+    Delete: scripts/support/etc/crontab
+
+  BitKeeper/deleted/.del-cron~3e480692@1.3, 2005-07-17 20:54:44+00:00, kardel@pogo.udel.edu +0 -18
+    Delete: scripts/support/etc/cron
+
+  BitKeeper/deleted/.del-hp300.hp300~3e480692@1.3, 2005-07-21 13:55:24+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/hp300.hp300
+
+  BitKeeper/deleted/.del-hp700.hp700.faui47~3e480692@1.3, 2005-07-21 13:55:24+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/hp700.hp700.faui47
+
+  BitKeeper/deleted/.del-hp700.hp700~3e480692@1.3, 2005-07-21 13:55:24+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/hp700.hp700
+
+  BitKeeper/deleted/.del-hp800.hp800~3e480692@1.3, 2005-07-21 13:55:24+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/hp800.hp800
+
+  BitKeeper/deleted/.del-install~3e480692@1.3, 2005-07-17 20:54:58+00:00, kardel@pogo.udel.edu +0 -67
+    Delete: scripts/support/etc/install
+
+  BitKeeper/deleted/.del-monl~3e480692@1.3, 2005-07-17 20:54:13+00:00, kardel@pogo.udel.edu +0 -213
+    Delete: scripts/support/bin/monl
+
+  BitKeeper/deleted/.del-mvstats~3e480692@1.3, 2005-07-17 20:54:20+00:00, kardel@pogo.udel.edu +0 -23
+    Delete: scripts/support/bin/mvstats
+
+  BitKeeper/deleted/.del-ntp.conf~3e480692@1.3, 2005-07-17 20:54:28+00:00, kardel@pogo.udel.edu +0 -3
+    Delete: scripts/support/conf/ntp.conf
+
+  BitKeeper/deleted/.del-rc~3e480692@1.3, 2005-07-17 20:55:05+00:00, kardel@pogo.udel.edu +0 -198
+    Delete: scripts/support/etc/rc
+
+  BitKeeper/deleted/.del-setup~3e480692@1.3, 2005-07-17 20:55:11+00:00, kardel@pogo.udel.edu +0 -72
+    Delete: scripts/support/etc/setup
+
+  BitKeeper/deleted/.del-sun3.sun3~3e480692@1.3, 2005-07-21 13:55:24+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/sun3.sun3
+
+  BitKeeper/deleted/.del-sun4.sun4.faui01~3e480692@1.3, 2005-07-21 13:55:25+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/sun4.sun4.faui01
+
+  BitKeeper/deleted/.del-sun4.sun4.faui10~3e480692@1.3, 2005-07-21 13:55:25+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/sun4.sun4.faui10
+
+  BitKeeper/deleted/.del-sun4.sun4.faui45~3e480692@1.3, 2005-07-21 13:55:25+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/sun4.sun4.faui45
+
+  BitKeeper/deleted/.del-sun4.sun4c.Lucifer~3e480692@1.3, 2005-07-21 13:55:25+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/sun4.sun4c.Lucifer
+
+  BitKeeper/deleted/.del-sun4.sun4c~3e480692@1.3, 2005-07-21 13:55:25+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/sun4.sun4c
+
+  BitKeeper/deleted/.del-sun4.sun4m.faui42~3e480692@1.3, 2005-07-21 13:55:25+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/sun4.sun4m.faui42
+
+  BitKeeper/deleted/.del-sun4.sun4m.faui45m~3e480692@1.3, 2005-07-21 13:55:25+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/sun4.sun4m.faui45m
+
+  BitKeeper/deleted/.del-sun4.sun4m~3e480692@1.3, 2005-07-21 13:55:25+00:00, kardel@pogo.udel.edu +0 -0
+    Delete: scripts/support/conf/sun4.sun4m
+
+  BitKeeper/deleted/.del-tickconf~3e480692@1.3, 2005-07-17 20:54:36+00:00, kardel@pogo.udel.edu +0 -19
+    Delete: scripts/support/conf/tickconf
+
+  libparse/Makefile.am@1.8, 2005-07-21 13:50:56+00:00, kardel@pogo.udel.edu +23 -2
+    move binio.c, ieee754io.c into libparse
+
+  libparse/binio.c@1.6, 2005-07-17 20:51:59+00:00, kardel@pogo.udel.edu +0 -0
+    Rename: libntp/binio.c -> libparse/binio.c
+
+  libparse/gpstolfp.c@1.8, 2005-07-17 20:51:38+00:00, kardel@pogo.udel.edu +0 -0
+    Rename: libntp/gpstolfp.c -> libparse/gpstolfp.c
+
+  libparse/ieee754io.c@1.8, 2005-07-17 20:52:13+00:00, kardel@pogo.udel.edu +0 -0
+    Rename: libntp/ieee754io.c -> libparse/ieee754io.c
+
+  libparse/mfp_mul.c@1.7, 2005-07-21 13:51:45+00:00, kardel@pogo.udel.edu +42 -11
+    correct carry propagation implementation
+
+  libparse/mfp_mul.c@1.6, 2005-07-17 20:51:19+00:00, kardel@pogo.udel.edu +0 -0
+    Rename: libntp/mfp_mul.c -> libparse/mfp_mul.c
+
+  ntpd/refclock_parse.c@1.33, 2005-07-21 13:53:00+00:00, kardel@pogo.udel.edu +41 -33
+    fix bug 455: tripping over NULL pointer on cleanup
+    fix shadow storage logic for ppsphaseadjust and trustime wrt/ time2
+    fix compiler warnings for some platforms wrt/ printf formatstrings and
+        varying structure element sizes
+    reorder assignment in binding to avoid tripping over NULL pointers
+    change contents of version string to include the RCS/CVS Id
+
+  scripts/Makefile.am@1.12, 2005-07-21 19:40:00+00:00, kardel@pogo.udel.edu +1 -1
+    support is gone - overaged files
+
+ChangeSet@1.1178.5.5, 2005-07-19 21:21:45-04:00, stenn@whimsy.udel.edu +3 -0
+  FreeBSD porting issues
+
+  Makefile.am@1.46.1.1, 2005-07-19 21:21:29-04:00, stenn@whimsy.udel.edu +5 -5
+    FreeBSD porting issues
+
+  ntpdc/ntpdc.c@1.33.2.1, 2005-07-19 21:21:29-04:00, stenn@whimsy.udel.edu +5 -1
+    FreeBSD porting issues
+
+  ntpq/ntpq.c@1.48.2.1, 2005-07-19 21:21:29-04:00, stenn@whimsy.udel.edu +5 -1
+    FreeBSD porting issues
+
+ChangeSet@1.1178.5.4, 2005-07-19 21:20:36-04:00, stenn@whimsy.udel.edu +4 -0
+  [Bug 466] Fix compilation under gcc4
+
+  include/ntp_control.h@1.25.1.1, 2005-07-19 21:20:00-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 466] Fix compilation under gcc4
+
+  include/ntp_refclock.h@1.15.1.1, 2005-07-19 21:20:01-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 466] Fix compilation under gcc4
+
+  include/ntp_stdlib.h@1.21, 2005-07-19 21:20:01-04:00, stenn@whimsy.udel.edu +0 -4
+    [Bug 466] Fix compilation under gcc4
+
+  include/ntpd.h@1.66.1.1, 2005-07-19 21:20:02-04:00, stenn@whimsy.udel.edu +0 -2
+    [Bug 466] Fix compilation under gcc4
+
+ChangeSet@1.1178.5.3, 2005-07-19 20:13:43-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 464] building ntp with debugging disabled fails
+
+  ntpd/ntp_proto.c@1.179.1.1, 2005-07-19 20:12:20-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 464] building ntp with debugging disabled fails
+
+ChangeSet@1.1251.38.4, 2005-07-16 17:30:55-04:00, mayer@pogo.udel.edu +1 -0
+  Add debug code to print the broadcast interface used
+
+  ntpd/ntp_peer.c@1.76, 2005-07-16 17:30:35-04:00, mayer@pogo.udel.edu +5 -0
+    Add debug code to print the broadcast interface used
+
+ChangeSet@1.1251.38.3, 2005-07-16 17:29:55-04:00, mayer@pogo.udel.edu +1 -0
+  Fix read loop to skip out if nothing to do and not complain about it
+
+  ntpd/ntp_io.c@1.182, 2005-07-16 17:29:39-04:00, mayer@pogo.udel.edu +143 -146
+    Fix read loop to skip out if nothing to do and not complain about it
+
+ChangeSet@1.1283, 2005-07-04 04:15:16-04:00, stenn@pogo.udel.edu +86 -0
+  New libopts
+
+  Makefile.am@1.51, 2005-07-04 04:09:28-04:00, stenn@pogo.udel.edu +2 -2
+    Cleanup
+
+  configure.ac@1.371, 2005-07-04 04:09:29-04:00, stenn@pogo.udel.edu +2 -0
+    Cleanup
+
+  libopts/AUTHORS@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +2 -0
+
+  libopts/AUTHORS@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/AUTHORS
+
+  libopts/COPYING@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +502 -0
+
+  libopts/COPYING@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/COPYING
+
+  libopts/COPYING.lgpl@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +502 -0
+
+  libopts/COPYING.lgpl@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/COPYING.lgpl
+
+  libopts/COPYING.mbsd@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +26 -0
+
+  libopts/COPYING.mbsd@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/COPYING.mbsd
+
+  libopts/ChangeLog@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +4 -0
+
+  libopts/ChangeLog@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/ChangeLog
+
+  libopts/INSTALL@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +231 -0
+
+  libopts/INSTALL@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/INSTALL
+
+  libopts/MakeDefs.inc@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +5 -0
+
+  libopts/MakeDefs.inc@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/MakeDefs.inc
+
+  libopts/Makefile.am@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +4 -0
+
+  libopts/Makefile.am@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/Makefile.am
+
+  libopts/NEWS@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +6 -0
+
+  libopts/NEWS@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/NEWS
+
+  libopts/README@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +2 -0
+
+  libopts/README@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/README
+
+  libopts/aclocal.m4@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +6827 -0
+
+  libopts/aclocal.m4@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/aclocal.m4
+
+  libopts/autoopts.c@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +1033 -0
+
+  libopts/autoopts.c@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/autoopts.c
+
+  libopts/autoopts.h@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +337 -0
+
+  libopts/autoopts.h@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/autoopts.h
+
+  libopts/autoopts/options.h@1.1, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +864 -0
+
+  libopts/autoopts/options.h@1.0, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/autoopts/options.h
+
+  libopts/autoopts/usage-txt.h@1.1, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +479 -0
+
+  libopts/autoopts/usage-txt.h@1.0, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/autoopts/usage-txt.h
+
+  libopts/boolean.c@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +102 -0
+
+  libopts/boolean.c@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/boolean.c
+
+  libopts/bootstrap@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +34 -0
+
+  libopts/bootstrap@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/bootstrap
+
+  libopts/compat/compat.h@1.1, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +249 -0
+
+  libopts/compat/compat.h@1.0, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/compat/compat.h
+
+  libopts/compat/pathfind.c@1.1, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +332 -0
+
+  libopts/compat/pathfind.c@1.0, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/compat/pathfind.c
+
+  libopts/config-h.in@1.1, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +140 -0
+
+  libopts/config-h.in@1.0, 2005-07-04 04:10:36-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/config-h.in
+
+  libopts/config-h.in~@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +236 -0
+
+  libopts/config-h.in~@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/config-h.in~
+
+  libopts/configfile.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +1282 -0
+
+  libopts/configfile.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/configfile.c
+
+  libopts/configure@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +23905 -0
+
+  libopts/configure@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/configure
+
+  libopts/configure.ac@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +54 -0
+
+  libopts/configure.ac@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/configure.ac
+
+  libopts/cook.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +355 -0
+
+  libopts/cook.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/cook.c
+
+  libopts/enumeration.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +449 -0
+
+  libopts/enumeration.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/enumeration.c
+
+  libopts/environment.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +261 -0
+
+  libopts/environment.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/environment.c
+
+  libopts/genshell.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +300 -0
+
+  libopts/genshell.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/genshell.c
+
+  libopts/genshell.h@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +143 -0
+
+  libopts/genshell.h@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/genshell.h
+
+  libopts/libopts.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +29 -0
+
+  libopts/libopts.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts.c
+
+  libopts/libopts.m4@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +387 -0
+
+  libopts/libopts.m4@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts.m4
+
+  libopts/libopts/Makefile.am@1.1, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +12 -0
+
+  libopts/libopts/Makefile.am@1.0, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/Makefile.am
+
+  libopts/libopts/autoopts.c@1.1, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +1033 -0
+
+  libopts/libopts/autoopts.c@1.0, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/autoopts.c
+
+  libopts/libopts/autoopts.h@1.1, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +337 -0
+
+  libopts/libopts/autoopts.h@1.0, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/autoopts.h
+
+  libopts/libopts/boolean.c@1.1, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +102 -0
+
+  libopts/libopts/boolean.c@1.0, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/boolean.c
+
+  libopts/libopts/configfile.c@1.1, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +1282 -0
+
+  libopts/libopts/configfile.c@1.0, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/configfile.c
+
+  libopts/libopts/cook.c@1.1, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +355 -0
+
+  libopts/libopts/cook.c@1.0, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/cook.c
+
+  libopts/libopts/enumeration.c@1.1, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +449 -0
+
+  libopts/libopts/enumeration.c@1.0, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/enumeration.c
+
+  libopts/libopts/environment.c@1.1, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +261 -0
+
+  libopts/libopts/environment.c@1.0, 2005-07-04 04:12:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/environment.c
+
+  libopts/libopts/genshell.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +300 -0
+
+  libopts/libopts/genshell.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/genshell.c
+
+  libopts/libopts/genshell.h@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +143 -0
+
+  libopts/libopts/genshell.h@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/genshell.h
+
+  libopts/libopts/libopts.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +29 -0
+
+  libopts/libopts/libopts.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/libopts.c
+
+  libopts/libopts/load.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +470 -0
+
+  libopts/libopts/load.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/load.c
+
+  libopts/libopts/makeshell.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +1100 -0
+
+  libopts/libopts/makeshell.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/makeshell.c
+
+  libopts/libopts/nested.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +707 -0
+
+  libopts/libopts/nested.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/nested.c
+
+  libopts/libopts/numeric.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +89 -0
+
+  libopts/libopts/numeric.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/numeric.c
+
+  libopts/libopts/pgusage.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +154 -0
+
+  libopts/libopts/pgusage.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/pgusage.c
+
+  libopts/libopts/proto.h@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +124 -0
+
+  libopts/libopts/proto.h@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/proto.h
+
+  libopts/libopts/putshell.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +333 -0
+
+  libopts/libopts/putshell.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/putshell.c
+
+  libopts/libopts/restore.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +207 -0
+
+  libopts/libopts/restore.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/restore.c
+
+  libopts/libopts/save.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +499 -0
+
+  libopts/libopts/save.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/save.c
+
+  libopts/libopts/sort.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +369 -0
+
+  libopts/libopts/sort.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/sort.c
+
+  libopts/libopts/stack.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +224 -0
+
+  libopts/libopts/stack.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/stack.c
+
+  libopts/libopts/streqvcmp.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +292 -0
+
+  libopts/libopts/streqvcmp.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/streqvcmp.c
+
+  libopts/libopts/text_mmap.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +312 -0
+
+  libopts/libopts/text_mmap.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/text_mmap.c
+
+  libopts/libopts/tokenize.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +322 -0
+
+  libopts/libopts/tokenize.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/tokenize.c
+
+  libopts/libopts/usage.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +651 -0
+
+  libopts/libopts/usage.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/usage.c
+
+  libopts/libopts/version.c@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +177 -0
+
+  libopts/libopts/version.c@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts/version.c
+
+  libopts/load.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +470 -0
+
+  libopts/load.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/load.c
+
+  libopts/m4/compile@1.1, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +142 -0
+
+  libopts/m4/compile@1.0, 2005-07-04 04:12:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/m4/compile
+
+  libopts/m4/config.guess@1.1, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +1495 -0
+
+  libopts/m4/config.guess@1.0, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/m4/config.guess
+
+  libopts/m4/config.sub@1.1, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +1570 -0
+
+  libopts/m4/config.sub@1.0, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/m4/config.sub
+
+  libopts/m4/depcomp@1.1, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +522 -0
+
+  libopts/m4/depcomp@1.0, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/m4/depcomp
+
+  libopts/m4/install-sh@1.1, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +323 -0
+
+  libopts/m4/install-sh@1.0, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/m4/install-sh
+
+  libopts/m4/libopts.m4@1.1, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +331 -0
+
+  libopts/m4/libopts.m4@1.0, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/m4/libopts.m4
+
+  libopts/m4/ltmain.sh@1.1, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +6500 -0
+
+  libopts/m4/ltmain.sh@1.0, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/m4/ltmain.sh
+
+  libopts/m4/missing@1.1, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +353 -0
+
+  libopts/m4/missing@1.0, 2005-07-04 04:12:39-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/m4/missing
+
+  libopts/makeshell.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +1100 -0
+
+  libopts/makeshell.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/makeshell.c
+
+  libopts/nested.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +707 -0
+
+  libopts/nested.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/nested.c
+
+  libopts/numeric.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +89 -0
+
+  libopts/numeric.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/numeric.c
+
+  libopts/pgusage.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +154 -0
+
+  libopts/pgusage.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/pgusage.c
+
+  libopts/proto.h@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +124 -0
+
+  libopts/proto.h@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/proto.h
+
+  libopts/putshell.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +333 -0
+
+  libopts/putshell.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/putshell.c
+
+  libopts/restore.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +207 -0
+
+  libopts/restore.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/restore.c
+
+  libopts/save.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +499 -0
+
+  libopts/save.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/save.c
+
+  libopts/sort.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +369 -0
+
+  libopts/sort.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/sort.c
+
+  libopts/stack.c@1.1, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +224 -0
+
+  libopts/stack.c@1.0, 2005-07-04 04:10:37-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/stack.c
+
+  libopts/streqvcmp.c@1.1, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +292 -0
+
+  libopts/streqvcmp.c@1.0, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/streqvcmp.c
+
+  libopts/text_mmap.c@1.1, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +312 -0
+
+  libopts/text_mmap.c@1.0, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/text_mmap.c
+
+  libopts/tokenize.c@1.1, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +322 -0
+
+  libopts/tokenize.c@1.0, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/tokenize.c
+
+  libopts/usage.c@1.1, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +651 -0
+
+  libopts/usage.c@1.0, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/usage.c
+
+  libopts/version.c@1.1, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +177 -0
+
+  libopts/version.c@1.0, 2005-07-04 04:10:38-04:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/version.c
+
+  ntpdc/ntpdc-opts.def@1.3, 2005-07-04 04:09:16-04:00, stenn@pogo.udel.edu +22 -7
+    Cleanup
+
+  ntpq/ntpq-opts.def@1.2, 2005-07-04 04:09:17-04:00, stenn@pogo.udel.edu +242 -5
+    Cleanup
+
+ChangeSet@1.1282, 2005-07-04 02:40:36-04:00, stenn@pogo.udel.edu +33 -0
+  Remove old libopts/
+
+  BitKeeper/deleted/.del-COPYING.lgpl~446c1c486f21fd2e@1.2, 2005-07-04 02:37:24-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/COPYING.lgpl
+
+  BitKeeper/deleted/.del-COPYING.mbsd~7a99797cacd53056@1.2, 2005-07-04 02:37:25-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/COPYING.mbsd
+
+  BitKeeper/deleted/.del-MakeDefs.inc~159b003e2ec363b5@1.2, 2005-07-04 02:37:25-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/MakeDefs.inc
+
+  BitKeeper/deleted/.del-Makefile.am~fbc0c90887a6abe1@1.3, 2005-07-04 02:37:25-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/Makefile.am
+
+  BitKeeper/deleted/.del-README~863ded79da7cd04e@1.2, 2005-07-04 02:37:25-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/README
+
+  BitKeeper/deleted/.del-autoopts.c~8d508a4c6d6337a8@1.3, 2005-07-04 02:37:25-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/autoopts.c
+
+  BitKeeper/deleted/.del-autoopts.h~24ccfda237b1a4e4@1.3, 2005-07-04 02:37:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/autoopts.h
+
+  BitKeeper/deleted/.del-boolean.c~76d65cce6791b639@1.3, 2005-07-04 02:37:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/boolean.c
+
+  BitKeeper/deleted/.del-compat.h~b5311be51765bbc8@1.3, 2005-07-04 02:37:50-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/compat/compat.h
+
+  BitKeeper/deleted/.del-enumeration.c~406a20f27bb1e70b@1.3, 2005-07-04 02:37:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/enumeration.c
+
+  BitKeeper/deleted/.del-environment.c~cb6a850da6dc34bd@1.3, 2005-07-04 02:37:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/environment.c
+
+  BitKeeper/deleted/.del-genshell.c~f2627aa3ed9ec273@1.3, 2005-07-04 02:37:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/genshell.c
+
+  BitKeeper/deleted/.del-genshell.h~e70a6981bf25d8d7@1.3, 2005-07-04 02:37:26-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/genshell.h
+
+  BitKeeper/deleted/.del-libopts.c~48986232bbeb4a0@1.2, 2005-07-04 02:37:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts.c
+
+  BitKeeper/deleted/.del-libopts.m4~b877c4d87dcb4b42@1.3, 2005-07-04 02:37:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/libopts.m4
+
+  BitKeeper/deleted/.del-load.c~ac03722a64c7070c@1.3, 2005-07-04 02:37:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/load.c
+
+  BitKeeper/deleted/.del-makeshell.c~83bda01ad08e7d2@1.3, 2005-07-04 02:37:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/makeshell.c
+
+  BitKeeper/deleted/.del-numeric.c~fb3a05758eeebb76@1.3, 2005-07-04 02:37:27-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/numeric.c
+
+  BitKeeper/deleted/.del-options.h~21d498cf4fa940d7@1.3, 2005-07-04 02:37:28-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/options.h
+
+  BitKeeper/deleted/.del-pathfind.c~f2717c337308e580@1.3, 2005-07-04 02:37:50-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/compat/pathfind.c
+
+  BitKeeper/deleted/.del-pgusage.c~a02c107578a438f@1.3, 2005-07-04 02:37:28-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/pgusage.c
+
+  BitKeeper/deleted/.del-putshell.c~cc1d047a2bea9716@1.3, 2005-07-04 02:37:28-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/putshell.c
+
+  BitKeeper/deleted/.del-restore.c~9b4b04133eb12966@1.3, 2005-07-04 02:37:28-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/restore.c
+
+  BitKeeper/deleted/.del-save.c~d8aaf91115194b06@1.3, 2005-07-04 02:37:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/save.c
+
+  BitKeeper/deleted/.del-sort.c~a3a8ea89587b8a4@1.3, 2005-07-04 02:37:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/sort.c
+
+  BitKeeper/deleted/.del-stack.c~b43aa38ab8b08c0d@1.3, 2005-07-04 02:37:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/stack.c
+
+  BitKeeper/deleted/.del-streqv.h~961ec0971a342cd6@1.3, 2005-07-04 02:37:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/streqv.h
+
+  BitKeeper/deleted/.del-streqvcmp.c~7ef8826c4cd9bd3f@1.3, 2005-07-04 02:37:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/streqvcmp.c
+
+  BitKeeper/deleted/.del-tokenize.c~7729f53ebb45f578@1.2, 2005-07-04 02:37:29-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/tokenize.c
+
+  BitKeeper/deleted/.del-tokenize.h~cabedf7f2026e66@1.2, 2005-07-04 02:37:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/tokenize.h
+
+  BitKeeper/deleted/.del-usage-txt.h~53df7a61187840e9@1.3, 2005-07-04 02:37:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/usage-txt.h
+
+  BitKeeper/deleted/.del-usage.c~d5db6221d54a6f45@1.3, 2005-07-04 02:37:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/usage.c
+
+  BitKeeper/deleted/.del-version.c~39f34e94894b40d2@1.3, 2005-07-04 02:37:30-04:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/version.c
+
+ChangeSet@1.1251.38.2, 2005-07-03 08:30:38-04:00, mayer@pogo.udel.edu +2 -0
+  Additional IPv6 multicasting fixes and fix for size of default_ai_family
+
+  ntpd/ntp_config.c@1.128, 2005-07-02 15:27:13-04:00, mayer@pogo.udel.edu +3 -7
+    Fix the size of default_ai_family which should have been short
+
+  ntpd/ntp_io.c@1.181, 2005-07-02 15:25:25-04:00, mayer@pogo.udel.edu +32 -10
+    Additional fixes for IPv6 multicasting
+
+ChangeSet@1.1178.5.2, 2005-07-03 01:54:05-04:00, stenn@whimsy.udel.edu +1 -0
+  Change from openlogging to a list at ntp.isc.org
+
+  BitKeeper/etc/config@1.7, 2005-07-03 01:53:43-04:00, stenn@whimsy.udel.edu +2 -1
+    Change from openlogging to a list at ntp.isc.org
+
+ChangeSet@1.1251.36.5, 2005-07-01 10:42:55+02:00, claas@nixfix.(none) +1 -0
+  refclock_neoclock4x.c:
+    solve AIX problems
+
+  ntpd/refclock_neoclock4x.c@1.12, 2005-07-01 10:41:47+02:00, claas@nixfix.(none) +65 -6
+    solve AIX problems
+
+ChangeSet@1.1251.36.4, 2005-06-29 04:31:59-04:00, stenn@whimsy.udel.edu +1 -0
+  VxWorks cleanup
+
+  ntpq/ntpq.c@1.55.1.3, 2005-06-29 04:31:37-04:00, stenn@whimsy.udel.edu +4 -3
+    VxWorks cleanup
+
+ChangeSet@1.1251.37.1, 2005-06-28 20:30:44-04:00, stenn@whimsy.udel.edu +1 -0
+  Cleanup from Dave Mills
+
+  ntpd/ntp_proto.c@1.225, 2005-06-28 20:30:25-04:00, stenn@whimsy.udel.edu +4 -2
+    Cleanup from Dave Mills
+
+ChangeSet@1.1251.36.1, 2005-06-28 04:28:30-04:00, stenn@whimsy.udel.edu +1 -0
+  Only look for sys/sched.h if sched.h is not found
+
+  configure.ac@1.359.1.15, 2005-06-28 04:28:06-04:00, stenn@whimsy.udel.edu +5 -1
+    Only look for sys/sched.h if sched.h is not found
+
+ChangeSet@1.1251.35.1, 2005-06-27 03:23:38-04:00, stenn@whimsy.udel.edu +2 -0
+  Fixes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.108, 2005-06-27 03:23:15-04:00, stenn@whimsy.udel.edu +2 -3
+    Fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.224, 2005-06-27 03:23:13-04:00, stenn@whimsy.udel.edu +1 -1
+    Fixes from Dave Mills
+
+ChangeSet@1.1251.1.129, 2005-06-26 12:34:11-04:00, mayer@pogo.udel.edu +1 -0
+  Added MULTICAST_NONEWSOCKET to configuration, Windows doesn't allow separate socket for multicast
+
+  ports/winnt/include/config.h@1.38, 2005-06-26 12:33:08-04:00, mayer@pogo.udel.edu +5 -3
+    Added MULTICAST_NONEWSOCKET to configuration, Windows doesn't allow separate socket for multicast
+
+ChangeSet@1.1251.1.127, 2005-06-25 22:13:01-04:00, mayer@pogo.udel.edu +1 -0
+  Fixes for IPv6 multicast at least for FreeBSD
+
+  ntpd/ntp_io.c@1.180, 2005-06-25 22:12:38-04:00, mayer@pogo.udel.edu +162 -34
+    Fixes for IPv6 multicast at least for FreeBSD
+
+ChangeSet@1.1251.33.8, 2005-06-25 21:28:14+00:00, kardel@pogo.udel.edu +7 -0
+  refclock_parse.c:
+    fix acceptance of clocks unsync clocks right at start
+    change status reporting to use fixed refclock_report()
+    clarify trust logic
+    collect samples only if samples are ok (sync or trusted flywheel)
+    propagate pps phase adjustment value to kernel via PPSAPI to help HARDPPS
+    en- and dis-able HARDPPS in correlation to receiver sync state
+    sort out log output sequence
+  ntp_refclock.c:
+    complete event to statistic mapping
+    make refclock_report to follow RFC1305 rules for clock.status
+    and event reporting
+  parsestreams.h:
+    update copyright
+  parse_conf.h, parse.h, mbg_gps166.h:
+    add missing log keywords
+  driver8.html:
+    anonymize version number in sample output
+
+  html/drivers/driver8.html@1.17, 2005-06-25 21:21:23+00:00, kardel@pogo.udel.edu +1 -1
+    anonymize version number in sample output
+
+  include/mbg_gps166.h@1.5, 2005-06-25 21:22:33+00:00, kardel@pogo.udel.edu +7 -2
+    add missing log keywords
+
+  include/parse.h@1.7, 2005-06-25 21:22:45+00:00, kardel@pogo.udel.edu +6 -3
+    add missing log keywords
+
+  include/parse_conf.h@1.5, 2005-06-25 21:22:49+00:00, kardel@pogo.udel.edu +12 -3
+    add missing log keywords
+
+  kernel/sys/parsestreams.h@1.7, 2005-06-25 21:23:23+00:00, kardel@pogo.udel.edu +33 -9
+    update copyright
+
+  ntpd/ntp_refclock.c@1.71, 2005-06-25 21:24:13+00:00, kardel@pogo.udel.edu +36 -8
+    complete event to statistic mapping
+    make refclock_report to follow RFC1305 rules for clock.status
+    and event reporting
+
+  ntpd/refclock_parse.c@1.32, 2005-06-25 21:25:42+00:00, kardel@pogo.udel.edu +152 -103
+    fix acceptance of clocks unsync clocks right at start
+    change status reporting to use fixed refclock_report()
+    clarify trust logic
+    collect samples only if samples are ok (sync or trusted flywheel)
+    propagate pps phase adjustment value to kernel via PPSAPI to help HARDPPS
+    en- and dis-able HARDPPS in correlation to receiver sync state
+    sort out log output sequence
+
+ChangeSet@1.1251.33.7, 2005-06-23 21:24:16-04:00, stenn@whimsy.udel.edu +1 -0
+  Fixes from Dave Mills
+
+  ntpd/ntp_refclock.c@1.70, 2005-06-23 21:23:55-04:00, stenn@whimsy.udel.edu +8 -2
+    Fixes from Dave Mills
+
+ChangeSet@1.1251.33.6, 2005-06-23 21:20:53-04:00, stenn@whimsy.udel.edu +1 -0
+  Bump NBUF to 80k.  From Dave Mills
+
+  util/jitter.c@1.8, 2005-06-23 21:20:32-04:00, stenn@whimsy.udel.edu +1 -1
+    Bump NBUF to 80k.  From Dave Mills
+
+ChangeSet@1.1251.33.5, 2005-06-14 00:56:12-04:00, stenn@whimsy.udel.edu +1 -0
+  Changes from Dave Mills
+
+  ntpd/ntp_refclock.c@1.69, 2005-06-14 00:55:52-04:00, stenn@whimsy.udel.edu +0 -1
+    Changes from Dave Mills
+
+ChangeSet@1.1251.33.4, 2005-06-11 02:35:12-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 448] want_getifaddrs typo fix (from Enrique Perez-Terron)
+
+  configure.ac@1.359.1.14, 2005-06-11 02:34:44-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 448] want_getifaddrs typo fix (from Enrique Perez-Terron)
+
+ChangeSet@1.1251.34.1, 2005-06-09 21:42:42-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 447] typo in ntpq.html
+
+  html/ntpq.html@1.26, 2005-06-09 21:42:23-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 447] typo in ntpq.html
+
+ChangeSet@1.1251.33.2, 2005-05-30 13:17:56+02:00, martin@pc-martin4. +2 -0
+  Added SIZEOF_TIME_T for Windows.
+
+  BitKeeper/etc/logging_ok@1.54, 2005-05-30 13:17:55+02:00, martin@pc-martin4. +1 -0
+    Logging to logging@openlogging.org accepted
+
+  ports/winnt/include/config.h@1.37, 2005-05-30 13:17:51+02:00, martin@pc-martin4. +1 -0
+    Added SIZEOF_TIME_T for Windows.
+
+ChangeSet@1.1251.33.1, 2005-05-30 01:02:52-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 434] Fix from Dave Mills
+
+  ntpd/ntp_refclock.c@1.68, 2005-05-30 01:02:23-04:00, stenn@whimsy.udel.edu +0 -3
+    [Bug 434] Fix from Dave Mills
+
+ChangeSet@1.1251.26.19, 2005-05-28 06:27:19-04:00, stenn@pogo.udel.edu +1 -0
+  Cleanup building of parse clocks
+
+  configure.ac@1.359.1.12, 2005-05-28 06:27:07-04:00, stenn@pogo.udel.edu +3 -2
+    Cleanup building of parse clocks
+
+ChangeSet@1.1251.26.18, 2005-05-28 10:13:03+00:00, kardel@pogo.udel.edu +1 -0
+  ntp_refclock.c:
+    We know that peer_leap can be LEAPNOTINSYNC from startup (peer_clear when
+    FLAG_REFCLOCK is not set yet) or when copied from pp->leap.
+    Thus interrogating peer->leap only gives a a false refclock_report from
+    initialization. False in that respect that new knowledge is available
+    (pp->leap) and will be the current information from then on.
+    See Bug 434
+
+  ntpd/ntp_refclock.c@1.67, 2005-05-28 10:07:44+00:00, kardel@pogo.udel.edu +1 -2
+    We know that peer_leap can be LEAPNOTINSYNC from startup (peer_clear when
+    FLAG_REFCLOCK is not set yet) or when copied from pp->leap.
+    Thus interrogating peer->leap only gives a a false reclock_report from
+    initialization. False in that respect that new knowledge is available
+    (pp->leap) and will be the current information from then on.
+
+ChangeSet@1.1251.32.1, 2005-05-28 04:45:19-04:00, stenn@whimsy.udel.edu +2 -0
+  sys_clocktime defn/decl cleanup
+
+  include/ntpd.h@1.78, 2005-05-28 04:44:42-04:00, stenn@whimsy.udel.edu +1 -0
+    sys_clocktime defn/decl cleanup
+
+  ntpd/ntp_proto.c@1.223, 2005-05-28 04:44:42-04:00, stenn@whimsy.udel.edu +0 -1
+    sys_clocktime defn/decl cleanup
+
+ChangeSet@1.1251.29.14, 2005-05-28 04:36:31-04:00, stenn@pogo.udel.edu +1 -0
+  [Bug 443] Remove duplicate LDISC_ #defines (from Brian Utterback)
+
+  include/ntp_tty.h@1.3, 2005-05-28 04:36:11-04:00, stenn@pogo.udel.edu +0 -13
+    [Bug 443] Remove duplicate LDISC_ #defines (from Brian Utterback)
+
+ChangeSet@1.1251.29.13, 2005-05-28 04:22:37-04:00, stenn@pogo.udel.edu +1 -0
+  [Bug 442] some constants should be UL
+
+  ntpd/ntp_control.c@1.79, 2005-05-28 04:22:21-04:00, stenn@pogo.udel.edu +3 -2
+    [Bug 442] some constants should be UL
+
+ChangeSet@1.1251.29.12, 2005-05-28 04:10:30-04:00, stenn@pogo.udel.edu +1 -0
+  [Bug 441] Treat *-*-solaris2* the same WRT AM_C_PROTOTYPES
+
+  configure.ac@1.359.2.2, 2005-05-28 04:10:16-04:00, stenn@pogo.udel.edu +6 -2
+    [Bug 441] Treat *-*-solaris2* the same WRT AM_C_PROTOTYPES
+
+ChangeSet@1.1251.29.11, 2005-05-27 05:39:09-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 437] Trailing comma in enumeration (fix from Brian Utterback)
+
+  ntpd/ntp_config.c@1.126, 2005-05-27 05:38:47-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 437] Trailing comma in enumeration (fix from Brian Utterback)
+
+ChangeSet@1.1251.31.3, 2005-05-26 20:51:10-04:00, stenn@pogo.udel.edu +1 -0
+  [Bug 432] More in6addr_any cleanup
+
+  libisc/ifiter_ioctl.c@1.22.1.2, 2005-05-26 20:50:37-04:00, stenn@pogo.udel.edu +2 -0
+    [Bug 432] More in6addr_any cleanup
+
+ChangeSet@1.1251.26.15, 2005-05-26 22:05:19+00:00, kardel@pogo.udel.edu +2 -0
+  refclock_parse.c:
+    cleanup status reporting
+  ntp_refclock.c:
+    initialize currentstatus to CEVNT_FAULT to avoid misleading
+    clk_fault report at first successful reception from
+    a refclock driver
+
+  ntpd/ntp_refclock.c@1.66, 2005-05-26 22:03:15+00:00, kardel@pogo.udel.edu +3 -1
+    initialize currentstatus to CEVNT_FAULT to avoid misleading
+    clk_fault report at first successful reception from
+    a refclock driver
+
+  ntpd/refclock_parse.c@1.31, 2005-05-26 22:04:31+00:00, kardel@pogo.udel.edu +17 -14
+    cleanup status reporting
+
+ChangeSet@1.1251.26.14, 2005-05-26 19:36:08+00:00, kardel@pogo.udel.edu +1 -0
+  refclock_parse.c:
+    implement fast refclock startup
+
+  ntpd/refclock_parse.c@1.30, 2005-05-26 19:35:31+00:00, kardel@pogo.udel.edu +9 -5
+    implement fast refclock startup
+
+ChangeSet@1.1251.31.2, 2005-05-26 06:28:54-04:00, stenn@pogo.udel.edu +1 -0
+  [Bug 432] More in6addr_any cleanup
+
+  libisc/ifiter_ioctl.c@1.22.1.1, 2005-05-26 06:28:40-04:00, stenn@pogo.udel.edu +1 -0
+    [Bug 432] More in6addr_any cleanup
+
+ChangeSet@1.1251.29.9, 2005-05-26 06:27:24-04:00, stenn@pogo.udel.edu +1 -0
+  [Bug 432] More in6addr_any cleanup
+
+  libisc/ifiter_ioctl.c@1.23, 2005-05-26 06:27:16-04:00, stenn@pogo.udel.edu +1 -0
+    [Bug 432] More in6addr_any cleanup
+
+ChangeSet@1.1251.31.1, 2005-05-26 06:23:51-04:00, stenn@pogo.udel.edu +1 -0
+  [Bug 432] More in6addr_any cleanup
+
+  libisc/ifiter_ioctl.c@1.22, 2005-05-26 06:23:34-04:00, stenn@pogo.udel.edu +1 -0
+    [Bug 432] More in6addr_any cleanup
+
+ChangeSet@1.1251.29.7, 2005-05-26 05:20:13-04:00, stenn@pogo.udel.edu +2 -0
+  [Bug 432] More in6addr_any cleanup
+
+  libisc/netaddr.c@1.4, 2005-05-26 05:18:57-04:00, stenn@pogo.udel.edu +2 -0
+    [Bug 432] More in6addr_any cleanup
+
+  libisc/sockaddr.c@1.4, 2005-05-26 05:18:57-04:00, stenn@pogo.udel.edu +2 -0
+    [Bug 432] More in6addr_any cleanup
+
+ChangeSet@1.1251.29.6, 2005-05-25 05:43:34-04:00, stenn@pogo.udel.edu +1 -0
+  [Bug 432] in6addr_any cleanup
+
+  libisc/sockaddr.c@1.3, 2005-05-25 05:43:19-04:00, stenn@pogo.udel.edu +2 -0
+    [Bug 432] in6addr_any cleanup
+
+ChangeSet@1.1251.29.4, 2005-05-25 05:01:29-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 433] Avoid epoch overflow on 32 bit systems
+
+  libntp/prettydate.c@1.5, 2005-05-25 05:01:11-04:00, stenn@whimsy.udel.edu +9 -0
+    [Bug 433] Avoid epoch overflow on 32 bit systems
+
+ChangeSet@1.1251.29.3, 2005-05-25 04:57:45-04:00, stenn@whimsy.udel.edu +1 -0
+  Try adding mort back in to the br-flock
+
+  br-flock@1.6, 2005-05-25 04:57:30-04:00, stenn@whimsy.udel.edu +1 -1
+    Try adding mort back in to the br-flock
+
+ChangeSet@1.1251.29.2, 2005-05-24 04:37:05-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 433] get SIZEOF_TIME_T
+
+  configure.ac@1.359.2.1, 2005-05-24 04:36:44-04:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 433] get SIZEOF_TIME_T
+
+ChangeSet@1.1251.28.2, 2005-05-24 03:36:59-04:00, stenn@pogo.udel.edu +3 -0
+  [Bug 432] clean up in6addrany usage
+
+  libisc/netaddr.c@1.3, 2005-05-24 03:36:39-04:00, stenn@pogo.udel.edu +2 -0
+    [Bug 432] clean up in6addrany usage
+
+  libntp/ntp_rfc2553.c@1.22, 2005-05-24 03:36:39-04:00, stenn@pogo.udel.edu +0 -12
+    [Bug 432] clean up in6addrany usage
+
+  ntpd/ntp_intres.c@1.40, 2005-05-24 03:36:39-04:00, stenn@pogo.udel.edu +2 -0
+    [Bug 432] clean up in6addrany usage
+
+ChangeSet@1.1251.28.1, 2005-05-24 03:11:09-04:00, stenn@pogo.udel.edu +1 -0
+  Added barnstable to the flock list
+
+  flock-build@1.31, 2005-05-24 03:10:56-04:00, stenn@pogo.udel.edu +1 -1
+    Added barnstable to the flock list
+
+ChangeSet@1.1251.27.2, 2005-05-24 01:06:58-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 431] More fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.222, 2005-05-24 01:06:32-04:00, stenn@whimsy.udel.edu +4 -3
+    [Bug 431] More fixes from Dave Mills
+
+ChangeSet@1.1251.27.1, 2005-05-22 04:21:05-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 431]: FLAG_AUTHENABLE/FLAG_AUTHENTIC fixes from Dave Mills
+
+  ntpd/ntp_config.c@1.125, 2005-05-22 04:20:45-04:00, stenn@whimsy.udel.edu +0 -1
+    FLAG_AUTHENABLE/FLAG_AUTHENTIC fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.221, 2005-05-22 04:20:45-04:00, stenn@whimsy.udel.edu +2 -0
+    FLAG_AUTHENABLE/FLAG_AUTHENTIC fixes from Dave Mills
+
+ChangeSet@1.1251.26.12, 2005-05-21 10:53:09+00:00, kardel@pogo.udel.edu +39 -0
+  refclock_parse.c:
+    add simple timstamp reading Meinberg clock (type 18)
+    for the sake of cooperation in a multi client environment
+    adjust to new pps setup
+  Many files:
+    copyright maintenance
+  driver8.html:
+    document new clock type (Meinberg only time reading)
+  copyright.html:
+    update eMail address
+  configure.ac:
+    NetBSD supports parse fully
+  ChangeLog-4.1.0:
+    obfuscate email addresses
+
+  BitKeeper/etc/logging_ok@1.53, 2005-05-21 10:53:09+00:00, kardel@pogo.udel.edu +1 -0
+    Logging to logging@openlogging.org accepted
+
+  ChangeLog-4.1.0@1.591, 2005-05-21 10:19:07+00:00, kardel@pogo.udel.edu +14 -14
+    obfuscate email addresses
+
+  configure.ac@1.359.1.10, 2005-05-21 10:19:24+00:00, kardel@pogo.udel.edu +4 -4
+    NetBSD supports parse fully
+
+  html/copyright.html@1.30, 2005-05-21 10:24:49+00:00, kardel@pogo.udel.edu +1 -1
+    update eMail address
+
+  html/drivers/driver8.html@1.16, 2005-05-21 10:26:00+00:00, kardel@pogo.udel.edu +414 -302
+    document new clock type (Meinberg only time reading)
+
+  include/ascii.h@1.4, 2005-05-21 10:27:17+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  include/binio.h@1.4, 2005-05-21 10:27:17+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  include/ieee754io.h@1.4, 2005-05-21 10:27:18+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  include/mbg_gps166.h@1.4, 2005-05-21 10:27:18+00:00, kardel@pogo.udel.edu +3 -3
+    copyright maintenance
+
+  include/parse.h@1.6, 2005-05-21 10:27:19+00:00, kardel@pogo.udel.edu +4 -4
+    copyright maintenance
+
+  include/parse_conf.h@1.4, 2005-05-21 10:27:19+00:00, kardel@pogo.udel.edu +4 -4
+    copyright maintenance
+
+  include/trimble.h@1.4, 2005-05-21 10:27:19+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  kernel/sys/parsestreams.h@1.6, 2005-05-21 10:28:50+00:00, kardel@pogo.udel.edu +1 -1
+    copyright maintenance
+
+  libntp/binio.c@1.5, 2005-05-21 10:29:41+00:00, kardel@pogo.udel.edu +3 -3
+    copyright maintenance
+
+  libntp/gpstolfp.c@1.7, 2005-05-21 10:29:41+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libntp/ieee754io.c@1.7, 2005-05-21 10:29:42+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libntp/mfp_mul.c@1.5, 2005-05-21 10:29:42+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/clk_computime.c@1.8, 2005-05-21 10:22:58+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/clk_dcf7000.c@1.8, 2005-05-21 10:22:58+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/clk_hopf6021.c@1.8, 2005-05-21 10:22:58+00:00, kardel@pogo.udel.edu +2 -2
+    copyright maintenance
+
+  libparse/clk_meinberg.c@1.8, 2005-05-21 10:22:58+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/clk_rawdcf.c@1.10, 2005-05-21 10:22:58+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/clk_rcc8000.c@1.8, 2005-05-21 10:22:58+00:00, kardel@pogo.udel.edu +2 -2
+    copyright maintenance
+
+  libparse/clk_schmid.c@1.8, 2005-05-21 10:22:58+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/clk_trimtaip.c@1.8, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/clk_trimtsip.c@1.8, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/clk_varitext.c@1.7, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/clk_wharton.c@1.6, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +2 -2
+    copyright maintenance
+
+  libparse/data_mbg.c@1.5, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/info_trimble.c@1.4, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +6 -4
+    copyright maintenance
+
+  libparse/parse.c@1.10, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +7 -4
+    copyright maintenance
+
+  libparse/parse_conf.c@1.9, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  libparse/parsesolaris.c@1.6, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +8 -5
+    copyright maintenance
+
+  libparse/parsestreams.c@1.6, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +9 -6
+    copyright maintenance
+
+  libparse/trim_info.c@1.4, 2005-05-21 10:22:59+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  ntpd/refclock_parse.c@1.29, 2005-05-21 10:31:59+00:00, kardel@pogo.udel.edu +71 -23
+    add simple timstamp reading Meinberg clock (type 18)
+    for the sake of cooperation in a multi client environment
+    adjust to new pps setup
+
+  parseutil/dcfd.c@1.15, 2005-05-21 10:30:39+00:00, kardel@pogo.udel.edu +6 -3
+    copyright maintenance
+
+  parseutil/testdcf.c@1.6, 2005-05-21 10:30:39+00:00, kardel@pogo.udel.edu +7 -4
+    copyright maintenance
+
+  scripts/monitoring/ntploopwatch@1.4, 2005-05-21 10:31:06+00:00, kardel@pogo.udel.edu +1 -1
+    copyright maintenance
+
+ChangeSet@1.1251.26.11, 2005-05-18 05:36:08-04:00, stenn@whimsy.udel.edu +3 -0
+  [Bug 408] fix based on proposed patch from cipo
+
+  ntpq/ntpq.c@1.55.1.2, 2005-05-18 05:35:39-04:00, stenn@whimsy.udel.edu +10 -4
+    [Bug 408] fix based on proposed patch from cipo
+
+  ntpq/ntpq.h@1.5, 2005-05-18 05:35:39-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 408] fix based on proposed patch from cipo
+
+  ntpq/ntpq_ops.c@1.20.2.1, 2005-05-18 05:35:39-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 408] fix based on proposed patch from cipo
+
+ChangeSet@1.1251.26.10, 2005-05-17 01:17:18-04:00, stenn@whimsy.udel.edu +6 -0
+  Stuff from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.107, 2005-05-17 01:10:34-04:00, stenn@whimsy.udel.edu +4 -4
+    Fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.220, 2005-05-17 01:07:54-04:00, stenn@whimsy.udel.edu +26 -3
+    Stratum checks from Dave Mills
+
+  ntpd/refclock_arbiter.c@1.12, 2005-05-17 01:16:28-04:00, stenn@whimsy.udel.edu +6 -4
+    Dave Mills: Call refclock_receive() once a second for the first few seconds
+
+  ntpd/refclock_atom.c@1.53, 2005-05-17 01:09:52-04:00, stenn@whimsy.udel.edu +8 -0
+    Dave Mills: flag4 in atom driver records offset to clockstats
+
+  ntpd/refclock_pst.c@1.8, 2005-05-17 01:16:27-04:00, stenn@whimsy.udel.edu +2 -1
+    Dave Mills: Call refclock_receive() once a second for the first few seconds
+
+  ntpd/refclock_wwvb.c@1.15, 2005-05-17 01:16:27-04:00, stenn@whimsy.udel.edu +2 -0
+    Dave Mills: Call refclock_receive() once a second for the first few seconds
+
+ChangeSet@1.1251.26.9, 2005-05-06 00:23:53-04:00, stenn@whimsy.udel.edu +4 -0
+  Changes from Dave Mills
+
+  BitKeeper/deleted/.del-driver23.html~3aed0663@1.13, 2005-05-06 00:11:21-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: html/drivers/driver23.html
+
+  BitKeeper/deleted/.del-driver24.html~3e480692@1.10, 2005-05-06 00:11:21-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: html/drivers/driver24.html
+
+  BitKeeper/deleted/.del-footer.txt~29fb3ec8f08446d2@1.2, 2005-05-06 00:10:07-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: html/drivers/footer.txt
+
+  html/index.html@1.31, 2005-05-06 00:23:32-04:00, stenn@whimsy.udel.edu +94 -94
+    Changes from Dave Mills
+
+ChangeSet@1.1251.26.8, 2005-05-05 23:55:29-04:00, stenn@whimsy.udel.edu +5 -0
+  Changes from Dave Mills
+
+  include/ntp_refclock.h@1.18, 2005-05-05 23:55:12-04:00, stenn@whimsy.udel.edu +6 -5
+    Changes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.106, 2005-05-05 23:54:57-04:00, stenn@whimsy.udel.edu +2 -1
+    Changes from Dave Mills
+
+  ntpd/ntp_refclock.c@1.65, 2005-05-05 23:54:57-04:00, stenn@whimsy.udel.edu +1 -1
+    Changes from Dave Mills
+
+  ntpd/refclock_acts.c@1.25, 2005-05-05 23:54:57-04:00, stenn@whimsy.udel.edu +30 -18
+    Changes from Dave Mills
+
+  ntpd/refclock_heath.c@1.12, 2005-05-05 23:54:58-04:00, stenn@whimsy.udel.edu +4 -3
+    Changes from Dave Mills
+
+ChangeSet@1.1251.26.7, 2005-04-27 05:53:39-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 401] ntpdc: only ask for keyid once, from Jason Fountain
+
+  ntpdc/ntpdc.c@1.40.1.1, 2005-04-27 05:53:22-04:00, stenn@whimsy.udel.edu +10 -6
+    [Bug 401] ntpdc: only ask for keyid once, from Jason Fountain
+
+ChangeSet@1.1251.26.6, 2005-04-27 04:09:54-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 409] Add DNS-SD/Rendezvous to ntpd, from Andre Masella
+
+  configure.ac@1.359.1.9, 2005-04-27 04:09:12-04:00, stenn@whimsy.udel.edu +11 -1
+    [Bug 409] Add DNS-SD/Rendezvous to ntpd, from Andre Masella
+
+  ntpd/ntpd.c@1.61.2.1, 2005-04-27 04:09:12-04:00, stenn@whimsy.udel.edu +16 -0
+    [Bug 409] Add DNS-SD/Rendezvous to ntpd, from Andre Masella
+
+ChangeSet@1.1251.1.126, 2005-04-23 16:24:51-04:00, mayer@pogo.udel.edu +2 -0
+  Added support for -4 and -6 command line options
+
+  ntpd/cmd_args.c@1.34, 2005-04-23 16:24:18-04:00, mayer@pogo.udel.edu +9 -2
+    Added support for -4 and -6 command line options
+
+  ntpd/ntp_config.c@1.123.1.1, 2005-04-23 16:24:18-04:00, mayer@pogo.udel.edu +6 -21
+    Added support for -4 and -6 command line options
+
+ChangeSet@1.1251.26.5, 2005-04-21 00:27:25-04:00, stenn@whimsy.udel.edu +3 -0
+  Documentation changes from Dave Mills
+
+  html/drivers/driver18.html@1.14, 2005-04-21 00:27:12-04:00, stenn@whimsy.udel.edu +10 -11
+    Documentation changes from Dave Mills
+
+  html/drivers/driver36.html@1.25, 2005-04-21 00:27:11-04:00, stenn@whimsy.udel.edu +4 -88
+    Documentation changes from Dave Mills
+
+  html/drivers/driver6.html@1.19, 2005-04-21 00:27:12-04:00, stenn@whimsy.udel.edu +6 -2
+    Documentation changes from Dave Mills
+
+ChangeSet@1.1251.26.4, 2005-04-21 00:23:40-04:00, stenn@whimsy.udel.edu +4 -0
+  Documentation changes from Dave Mills
+
+  html/audio.html@1.16, 2005-04-21 00:23:03-04:00, stenn@whimsy.udel.edu +95 -3
+    Documentation changes from Dave Mills
+
+  html/confopt.html@1.31, 2005-04-21 00:23:06-04:00, stenn@whimsy.udel.edu +1 -1
+    Documentation changes from Dave Mills
+
+  html/ntpd.html@1.36, 2005-04-21 00:23:06-04:00, stenn@whimsy.udel.edu +4 -4
+    Documentation changes from Dave Mills
+
+  html/ntpq.html@1.25, 2005-04-21 00:23:06-04:00, stenn@whimsy.udel.edu +258 -255
+    Documentation changes from Dave Mills
+
+ChangeSet@1.1251.26.3, 2005-04-21 00:08:47-04:00, stenn@whimsy.udel.edu +4 -0
+  anti-clockhop changes from Dave Mills
+
+  include/ntp.h@1.116, 2005-04-21 00:07:57-04:00, stenn@whimsy.udel.edu +6 -6
+    anti-clockhop changes from Dave Mills
+
+  include/ntp_config.h@1.33, 2005-04-21 00:07:57-04:00, stenn@whimsy.udel.edu +1 -0
+    anti-clockhop changes from Dave Mills
+
+  ntpd/ntp_config.c@1.124, 2005-04-21 00:08:24-04:00, stenn@whimsy.udel.edu +5 -0
+    anti-clockhop changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.219, 2005-04-21 00:08:25-04:00, stenn@whimsy.udel.edu +17 -7
+    anti-clockhop changes from Dave Mills
+
+ChangeSet@1.1251.1.124, 2005-04-20 23:55:08-04:00, mayer@pogo.udel.edu +3 -0
+  Remove log.* from make files
+
+  BitKeeper/deleted/.del-log.c~3e480692@1.7, 2005-04-20 23:29:37-04:00, mayer@pogo.udel.edu +0 -0
+    Delete: libntp/log.c
+
+  BitKeeper/deleted/.del-log.h~3e480692@1.5, 2005-04-20 23:29:43-04:00, mayer@pogo.udel.edu +0 -0
+    Delete: libntp/log.h
+
+  libntp/Makefile.am@1.32, 2005-04-20 23:54:14-04:00, mayer@pogo.udel.edu +2 -2
+    Remove log.* from make files
+
+ChangeSet@1.1251.1.123, 2005-04-20 23:25:01-04:00, mayer@pogo.udel.edu +3 -0
+  Changes for multicasting
+
+  libntp/log.c@1.6, 2005-04-17 18:22:24-04:00, mayer@pogo.udel.edu +0 -0
+    Rename: BitKeeper/deleted/.del-log.c~3e480692 -> libntp/log.c
+
+  BitKeeper/deleted/.del-log.c~3e480692@1.5, 2005-04-17 18:18:17-04:00, mayer@pogo.udel.edu +0 -0
+    Delete: libntp/log.c
+
+  libntp/log.h@1.4, 2005-04-17 18:22:49-04:00, mayer@pogo.udel.edu +0 -0
+    Rename: BitKeeper/deleted/.del-log.h~3e480692 -> libntp/log.h
+
+  BitKeeper/deleted/.del-log.h~3e480692@1.3, 2005-04-17 18:18:20-04:00, mayer@pogo.udel.edu +0 -0
+    Delete: libntp/log.h
+
+  ntpd/ntp_io.c@1.179, 2005-04-20 23:24:43-04:00, mayer@pogo.udel.edu +35 -11
+    Changes for multicasting
+
+ChangeSet@1.1251.26.2, 2005-04-18 22:29:49-04:00, stenn@whimsy.udel.edu +2 -0
+  anti-clockhop changes from Dave Mills
+
+  include/ntp.h@1.115, 2005-04-18 22:29:19-04:00, stenn@whimsy.udel.edu +1 -3
+    anti-clockhop changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.218, 2005-04-18 22:29:27-04:00, stenn@whimsy.udel.edu +21 -25
+    anti-clockhop changes from Dave Mills
+
+ChangeSet@1.1251.26.1, 2005-04-18 01:01:32-04:00, stenn@whimsy.udel.edu +5 -0
+  Changes from Dave Mills
+
+  include/ntp.h@1.114, 2005-04-18 01:01:12-04:00, stenn@whimsy.udel.edu +2 -2
+    Changes from Dave Mills
+
+  include/ntp_control.h@1.26, 2005-04-18 01:01:13-04:00, stenn@whimsy.udel.edu +9 -10
+    Changes from Dave Mills
+
+  ntpd/ntp_control.c@1.78, 2005-04-18 01:01:02-04:00, stenn@whimsy.udel.edu +10 -15
+    Changes from Dave Mills
+
+  ntpd/ntp_peer.c@1.75, 2005-04-18 01:01:04-04:00, stenn@whimsy.udel.edu +0 -2
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.217, 2005-04-18 01:01:03-04:00, stenn@whimsy.udel.edu +37 -43
+    Changes from Dave Mills
+
+ChangeSet@1.1251.18.2, 2005-04-16 23:26:04-04:00, mayer@tecotoo. +10 -0
+  Martin Burnicki's cleanup of command line options and setting the registry for NTP
+
+  BitKeeper/deleted/.del-log.c~87fe33f8@1.3, 2005-04-16 23:11:57-04:00, mayer@tecotoo. +0 -0
+    Delete: ports/winnt/libntp/log.c
+
+  BitKeeper/deleted/.del-log.h~29080509@1.5, 2005-04-16 23:12:02-04:00, mayer@tecotoo. +0 -0
+    Delete: ports/winnt/libntp/log.h
+
+  include/ntp_cmdargs.h@1.3, 2005-04-16 23:15:27-04:00, mayer@tecotoo. +1 -0
+    Martin Burnicki's changes to fix ntpd usage message
+
+  libntp/msyslog.c@1.19, 2005-04-16 23:21:23-04:00, mayer@tecotoo. +0 -1
+    Martin Burnicki's changes to remove unnecessary log.h include
+
+  ntpd/cmd_args.c@1.33, 2005-04-16 23:15:35-04:00, mayer@tecotoo. +38 -42
+    Martin Burnicki's changes to fix ntpd usage message
+
+  ntpd/ntpd.c@1.61.1.6, 2005-04-16 23:22:57-04:00, mayer@tecotoo. +0 -1
+    Martin Burnicki's changes to remove unnecessary log.h include
+
+  ports/winnt/instsrv/Instsrv.dsp@1.6, 2005-04-16 23:25:00-04:00, mayer@tecotoo. +1 -1
+    Miscellaneous cleanup
+
+  ports/winnt/libntp/libntp.dsp@1.25, 2005-04-16 23:24:18-04:00, mayer@tecotoo. +0 -8
+    Remove references to log.c and log.h
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.17, 2005-04-16 23:20:47-04:00, mayer@tecotoo. +0 -2
+    Martin Burnicki's changes to remove unnecessary registry call
+
+  ports/winnt/ntpd/ntservice.c@1.5, 2005-04-16 23:19:51-04:00, mayer@tecotoo. +11 -5
+    Martin Burnicki's changes to fix ntpd usage message
+
+ChangeSet@1.1251.1.121, 2005-04-12 17:43:36-04:00, stenn@whimsy.udel.edu +4 -0
+  Documentation changes from Dave Mills (including [Bug 412])
+
+  html/accopt.html@1.23, 2005-04-12 17:43:00-04:00, stenn@whimsy.udel.edu +3 -5
+    Documentation changes from Dave Mills
+
+  html/confopt.html@1.30, 2005-04-12 17:42:45-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 412] multicastclient requires an address (Dave Mills)
+
+  html/ntpq.html@1.24, 2005-04-12 17:43:03-04:00, stenn@whimsy.udel.edu +2 -3
+    Documentation changes from Dave Mills
+
+  html/refclock.html@1.31, 2005-04-12 17:43:01-04:00, stenn@whimsy.udel.edu +8 -10
+    Documentation changes from Dave Mills
+
+ChangeSet@1.1251.1.120, 2005-04-12 00:52:34-04:00, stenn@whimsy.udel.edu +2 -0
+  Changes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.105, 2005-04-12 00:52:23-04:00, stenn@whimsy.udel.edu +3 -4
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.216, 2005-04-12 00:52:21-04:00, stenn@whimsy.udel.edu +1 -1
+    Changes from Dave Mills
+
+ChangeSet@1.1251.1.119, 2005-04-07 20:36:24-04:00, stenn@whimsy.udel.edu +3 -0
+  [Bug 405] and other fixes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.104, 2005-04-07 20:35:24-04:00, stenn@whimsy.udel.edu +0 -1
+    Fixes from Dave Mills
+
+  ntpd/ntp_peer.c@1.74, 2005-04-07 20:35:04-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 405] Fix from Dave Mills
+
+  ntpd/ntp_proto.c@1.215, 2005-04-07 20:35:22-04:00, stenn@whimsy.udel.edu +37 -44
+    Fixes from Dave Mills
+
+ChangeSet@1.1251.1.118, 2005-04-06 23:54:32-04:00, stenn@whimsy.udel.edu +1 -0
+  Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.214, 2005-04-06 23:54:11-04:00, stenn@whimsy.udel.edu +1 -2
+    Changes from Dave Mills
+
+ChangeSet@1.1251.1.117, 2005-04-06 01:09:48-04:00, stenn@whimsy.udel.edu +2 -0
+  Changes from Dave Mills
+
+  ntpd/ntp_peer.c@1.73, 2005-04-06 01:08:29-04:00, stenn@whimsy.udel.edu +2 -3
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.213, 2005-04-06 01:08:28-04:00, stenn@whimsy.udel.edu +25 -24
+    Changes from Dave Mills
+
+ChangeSet@1.1251.1.116, 2005-04-04 18:15:45-04:00, stenn@whimsy.udel.edu +3 -0
+  Changes from Dave Mills
+
+  include/ntp.h@1.113, 2005-04-04 18:15:12-04:00, stenn@whimsy.udel.edu +4 -7
+    Changes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.103, 2005-04-04 18:15:05-04:00, stenn@whimsy.udel.edu +4 -1
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.212, 2005-04-04 18:15:04-04:00, stenn@whimsy.udel.edu +1 -0
+    Changes from Dave Mills
+
+ChangeSet@1.1251.1.115, 2005-04-04 00:22:10-04:00, stenn@whimsy.udel.edu +1 -0
+  Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.211, 2005-04-04 00:21:25-04:00, stenn@whimsy.udel.edu +3 -3
+    Changes from Dave Mills
+
+ChangeSet@1.1251.1.114, 2005-04-03 20:41:23-04:00, stenn@whimsy.udel.edu +3 -0
+  Changes from Dave Mills
+
+  include/ntp.h@1.112, 2005-04-03 20:40:55-04:00, stenn@whimsy.udel.edu +1 -0
+    Changes from Dave Mills
+
+  ntpd/ntp_peer.c@1.72, 2005-04-03 20:40:27-04:00, stenn@whimsy.udel.edu +4 -3
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.210, 2005-04-03 20:40:26-04:00, stenn@whimsy.udel.edu +98 -93
+    Changes from Dave Mills
+
+ChangeSet@1.1251.25.1, 2005-04-02 19:05:57-05:00, mayer@pogo.udel.edu +1 -0
+  Use any for the IPv4 join interface for mcast
+
+  ntpd/ntp_io.c@1.178, 2005-04-02 19:05:32-05:00, mayer@pogo.udel.edu +1 -1
+    Use any for the IPv4 join interface for mcast
+
+ChangeSet@1.1251.24.1, 2005-04-02 18:47:52-05:00, stenn@whimsy.udel.edu +7 -0
+  Changes from Dave Mills
+
+  include/ntp.h@1.111, 2005-04-02 18:47:06-05:00, stenn@whimsy.udel.edu +6 -7
+    Changes from Dave Mills
+
+  include/ntp_crypto.h@1.35, 2005-04-02 18:47:09-05:00, stenn@whimsy.udel.edu +3 -2
+    Changes from Dave Mills
+
+  include/ntpd.h@1.77, 2005-04-02 18:47:06-05:00, stenn@whimsy.udel.edu +1 -1
+    Changes from Dave Mills
+
+  libntp/statestr.c@1.9, 2005-04-02 18:47:18-05:00, stenn@whimsy.udel.edu +4 -3
+    Changes from Dave Mills
+
+  ntpd/ntp_crypto.c@1.96, 2005-04-02 18:47:26-05:00, stenn@whimsy.udel.edu +47 -38
+    Changes from Dave Mills
+
+  ntpd/ntp_peer.c@1.71, 2005-04-02 18:47:25-05:00, stenn@whimsy.udel.edu +2 -2
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.209, 2005-04-02 18:47:25-05:00, stenn@whimsy.udel.edu +49 -81
+    Changes from Dave Mills
+
+ChangeSet@1.1251.1.111, 2005-04-02 18:36:32-05:00, mayer@pogo.udel.edu +1 -0
+  If unable to create a separate socket for multicast, find a local interface and use that instead of the wildcard sockets
+
+  ntpd/ntp_io.c@1.177, 2005-04-02 18:35:59-05:00, mayer@pogo.udel.edu +46 -25
+    If unable to create a separate socket for multicast, find a local interface and use that instead of the wildcard sockets
+
+ChangeSet@1.1251.1.110, 2005-04-02 03:28:33-05:00, stenn@whimsy.udel.edu +1 -0
+  Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.208, 2005-04-02 03:28:12-05:00, stenn@whimsy.udel.edu +48 -44
+    Changes from Dave Mills
+
+ChangeSet@1.1251.1.109, 2005-03-31 23:03:22-05:00, stenn@whimsy.udel.edu +3 -0
+  Changes from Dave Mills
+
+  include/ntpd.h@1.76, 2005-03-31 23:02:22-05:00, stenn@whimsy.udel.edu +1 -1
+    Changes from Dave Mills
+
+  ntpd/ntp_peer.c@1.70, 2005-03-31 23:02:53-05:00, stenn@whimsy.udel.edu +7 -5
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.207, 2005-03-31 23:02:52-05:00, stenn@whimsy.udel.edu +140 -135
+    Changes from Dave Mills
+
+ChangeSet@1.1251.23.1, 2005-03-31 21:57:56-05:00, mayer@pogo.udel.edu +1 -0
+  Change ignore packet message to only print if debug > 3
+
+  ntpd/ntp_io.c@1.176, 2005-03-31 21:56:44-05:00, mayer@pogo.udel.edu +1 -1
+    Change ignore packet message to only print if debug > 3
+
+ChangeSet@1.1251.1.107, 2005-03-31 11:15:14+02:00, root@sonne. +1 -0
+  Remove quotes from tokens to handle paths with spaces correctly.
+
+  ntpd/ntp_config.c@1.123, 2005-03-31 11:15:07+02:00, root@sonne. +21 -0
+    Remove quotes from tokens to handle paths with spaces correctly.
+
+ChangeSet@1.1251.1.106, 2005-03-31 11:11:43+02:00, root@sonne. +2 -0
+  Fixed braces in conditional for OPENSSL.
+
+  BitKeeper/etc/logging_ok@1.52, 2005-03-31 11:11:43+02:00, root@sonne. +1 -0
+    Logging to logging@openlogging.org accepted
+
+  ntpd/ntp_proto.c@1.206, 2005-03-31 11:11:33+02:00, root@sonne. +2 -1
+    Fixed braces in conditional for OPENSSL.
+
+ChangeSet@1.1251.22.2, 2005-03-30 23:41:14-05:00, stenn@whimsy.udel.edu +3 -0
+  Changes from Dave Mills
+
+  include/ntp.h@1.108.1.1, 2005-03-30 23:40:58-05:00, stenn@whimsy.udel.edu +18 -8
+    Changes from Dave Mills
+
+  ntpd/ntp_peer.c@1.69, 2005-03-30 23:40:46-05:00, stenn@whimsy.udel.edu +9 -8
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.203.1.2, 2005-03-30 23:40:46-05:00, stenn@whimsy.udel.edu +205 -205
+    Changes from Dave Mills
+
+ChangeSet@1.1251.1.104, 2005-03-30 23:07:59-05:00, mayer@pogo.udel.edu +1 -0
+  Bug #396 Windows-only fix to ignore incoming packets if flag on socket is set
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.14, 2005-03-30 23:07:23-05:00, mayer@pogo.udel.edu +1 -1
+    Bug #396 Windows-only fix to ignore incoming packets if flag on socket is set
+
+ChangeSet@1.1251.22.1, 2005-03-27 18:39:02-05:00, stenn@whimsy.udel.edu +1 -0
+  Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.203.1.1, 2005-03-27 18:38:48-05:00, stenn@whimsy.udel.edu +6 -6
+    Changes from Dave Mills
+
+ChangeSet@1.1251.21.3, 2005-03-27 16:29:59-05:00, mayer@pogo.udel.edu +1 -0
+  Change in configuration setup prevented multicast packets from being accepted
+
+  ntpd/ntp_proto.c@1.201.1.1, 2005-03-27 16:29:44-05:00, mayer@pogo.udel.edu +17 -16
+    Change in configuration setup prevented multicast packets from being accepted
+
+ChangeSet@1.1251.21.2, 2005-03-27 16:28:44-05:00, mayer@pogo.udel.edu +1 -0
+  Bug #396: Don't accept broadcast packets if they are not enabled. wildcard socket was accepting them. Bind all sockets but drop any packet  arriving on socket not specifically enabled
+
+  ntpd/ntp_io.c@1.175, 2005-03-27 16:28:25-05:00, mayer@pogo.udel.edu +81 -50
+    Bug #396: Don't accept broadcast packets if they are not enabled. wildcard socket was accepting them. Bind all sockets but drop any packet  arriving on socket not specifically enabled
+
+ChangeSet@1.1251.21.1, 2005-03-27 16:25:17-05:00, mayer@pogo.udel.edu +1 -0
+  Added ignore_packets to interface for sockets which will drop all requests
+
+  include/ntp.h@1.109, 2005-03-27 16:24:55-05:00, mayer@pogo.udel.edu +3 -0
+    Added ignore_packets to interface for sockets which will drop all requests
+
+ChangeSet@1.1251.1.102, 2005-03-24 00:54:17-05:00, stenn@whimsy.udel.edu +2 -0
+  Changes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.102, 2005-03-24 00:54:02-05:00, stenn@whimsy.udel.edu +1 -2
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.203, 2005-03-24 00:54:01-05:00, stenn@whimsy.udel.edu +6 -11
+    Changes from Dave Mills
+
+ChangeSet@1.1251.20.1, 2005-03-18 00:43:24-05:00, stenn@whimsy.udel.edu +1 -0
+  Updates from Dave Mills
+
+  ntpd/ntp_proto.c@1.202, 2005-03-18 00:43:10-05:00, stenn@whimsy.udel.edu +15 -15
+    Updates from Dave Mills
+
+ChangeSet@1.1251.1.100, 2005-03-17 15:35:36-05:00, mayer@pogo.udel.edu +1 -0
+  Bug #396 - Disable wildcards for now to prevent this happening
+
+  ntpd/ntp_io.c@1.174, 2005-03-17 15:35:07-05:00, mayer@pogo.udel.edu +8 -1
+    Bug #396 - Disable wildcards for now to prevent this happening
+
+ChangeSet@1.1251.1.99, 2005-03-15 23:31:42-05:00, stenn@whimsy.udel.edu +1 -0
+  ntp_proto.c fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.201, 2005-03-15 23:31:28-05:00, stenn@whimsy.udel.edu +111 -116
+    ntp_proto.c fixes from Dave Mills
+
+ChangeSet@1.1251.1.98, 2005-03-15 22:52:55-05:00, stenn@whimsy.udel.edu +1 -0
+  Only check OpenSSL Major/Minor/Fix/Status, not Patch
+
+  util/ntp-keygen.c@1.31, 2005-03-15 22:52:41-05:00, stenn@whimsy.udel.edu +5 -1
+    Only check OpenSSL Major/Minor/Fix/Status, not Patch
+
+ChangeSet@1.1251.19.1, 2005-03-14 19:11:49-05:00, stenn@whimsy.udel.edu +1 -0
+  Comment fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.200, 2005-03-14 19:08:56-05:00, stenn@whimsy.udel.edu +7 -2
+    Comment fixes from Dave Mills
+
+ChangeSet@1.1251.1.96, 2005-03-14 18:30:20-05:00, mayer@pogo.udel.edu +1 -0
+  Wrong Macro used should have been PROTO_MULTICAST_ADD instead of PROTO_BROADCLIENT
+
+  ntpd/ntp_config.c@1.122, 2005-03-14 18:30:00-05:00, mayer@pogo.udel.edu +1 -1
+    Wrong Macro used should have been PROTO_MULTICAST_ADD instead of PROTO_BROADCLIENT
+
+ChangeSet@1.1251.1.95, 2005-03-13 17:02:41-05:00, stenn@whimsy.udel.edu +7 -0
+  Changes from Dave Mills (flash TEST bits changed!)
+
+  include/ntp.h@1.108, 2005-03-13 17:01:30-05:00, stenn@whimsy.udel.edu +35 -24
+    Changes from Dave Mills (flashh  TEST bits changed!)
+
+  include/ntpd.h@1.75, 2005-03-13 17:01:30-05:00, stenn@whimsy.udel.edu +1 -0
+    Changes from Dave Mills (flashh  TEST bits changed!)
+
+  ntpd/ntp_control.c@1.77, 2005-03-13 17:01:47-05:00, stenn@whimsy.udel.edu +3 -1
+    Changes from Dave Mills (flash TEST bits changed!)
+
+  ntpd/ntp_crypto.c@1.95, 2005-03-13 17:01:49-05:00, stenn@whimsy.udel.edu +11 -11
+    Changes from Dave Mills (flash TEST bits changed!)
+
+  ntpd/ntp_peer.c@1.68, 2005-03-13 17:01:48-05:00, stenn@whimsy.udel.edu +6 -18
+    Changes from Dave Mills (flash TEST bits changed!)
+
+  ntpd/ntp_proto.c@1.199, 2005-03-13 17:01:48-05:00, stenn@whimsy.udel.edu +233 -293
+    Changes from Dave Mills (flash TEST bits changed!)
+
+  ntpq/ntpq.c@1.55.1.1, 2005-03-13 17:02:04-05:00, stenn@whimsy.udel.edu +14 -12
+    Changes from Dave Mills (flash TEST bits changed!)
+
+ChangeSet@1.1251.18.1, 2005-03-09 22:23:03-05:00, mayer@tecotoo. +1 -0
+  Update for UTC information version string - from Heiko Gerstung
+
+  ports/winnt/scripts/mkver.bat@1.7, 2005-03-09 22:22:30-05:00, mayer@tecotoo. +99 -23
+    Update for UTC information version string - from Heiko Gerstung
+
+ChangeSet@1.1251.1.93, 2005-03-09 01:04:51-05:00, stenn@whimsy.udel.edu +1 -0
+  Lose arbiter debug line.  From Dave Mills.
+
+  ntpd/refclock_arbiter.c@1.11, 2005-03-09 01:04:29-05:00, stenn@whimsy.udel.edu +0 -2
+    Lose debug line.  From Dave Mills.
+
+ChangeSet@1.1251.1.90, 2005-03-08 22:14:49-05:00, mayer@tecotoo. +1 -0
+  Fix to correctly create version string - from Heiko Gerstung
+
+  ports/winnt/scripts/mkver.bat@1.6, 2005-03-08 22:13:54-05:00, mayer@tecotoo. +265 -50
+    Fix to correctly create version string - from Heiko Gerstung
+
+ChangeSet@1.1251.17.1, 2005-03-07 23:18:40-05:00, mayer@pogo.udel.edu +1 -0
+  Check for max value of skips before adding
+
+  ntpd/ntp_io.c@1.169.1.6, 2005-03-07 23:18:23-05:00, mayer@pogo.udel.edu +7 -4
+    Check for max value of skips before adding
+
+ChangeSet@1.1271, 2005-03-05 02:03:58-05:00, stenn@pogo.udel.edu +1 -0
+  cleanup
+
+  configure.ac@1.366, 2005-03-05 02:03:38-05:00, stenn@pogo.udel.edu +0 -33
+
+ChangeSet@1.1251.15.11, 2005-03-05 01:40:18-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 390] Do not run check-layout if cross-compiling
+
+  configure.ac@1.359.1.8, 2005-03-05 01:39:53-05:00, stenn@whimsy.udel.edu +46 -33
+    [Bug 390] Do not run check-layout if cross-compiling
+
+  ntpdc/Makefile.am@1.23.1.1, 2005-03-05 01:39:53-05:00, stenn@whimsy.udel.edu +1 -6
+    [Bug 390] Do not run check-layout if cross-compiling
+
+ChangeSet@1.1251.1.88, 2005-03-02 20:52:53-05:00, mayer@tecotoo. +1 -0
+  Test code
+
+  ntpd/ntp_io.c@1.171, 2005-03-02 20:51:46-05:00, mayer@tecotoo. +1 -1
+    Test code
+
+ChangeSet@1.1178.5.1, 2005-03-02 16:18:07-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 389] Fix from Remi Demis-Courmont, via Loic Minier (http://bugs.debian.org/293793
+
+  ntpdate/ntpdate.c@1.47.1.1, 2005-03-02 16:17:50-05:00, stenn@whimsy.udel.edu +46 -16
+    [Bug 389] Fix from Remi Demis-Courmont, via Loic Minier (http://bugs.debian.org/293793
+
+ChangeSet@1.1251.15.9, 2005-03-02 15:50:06-05:00, stenn@whimsy.udel.edu +1 -0
+  Clock filter bugfix from Dave Mills
+
+  ntpd/ntp_proto.c@1.198, 2005-03-02 15:49:47-05:00, stenn@whimsy.udel.edu +3 -3
+    Clock filter bugfix from Dave Mills
+
+ChangeSet@1.1251.15.8, 2005-03-02 14:53:27-05:00, mayer@pogo.udel.edu +1 -0
+  Bug #392 fix group number
+
+  ntpd/ntpd.c@1.61.1.5, 2005-03-02 14:53:15-05:00, mayer@pogo.udel.edu +1 -1
+    Bug #392 fix group number
+
+ChangeSet@1.1251.16.1, 2005-03-02 14:37:49-05:00, mayer@pogo.udel.edu +1 -0
+  Fix to ignore 0 or less readlengths after the first one
+
+  ntpd/ntp_io.c@1.169.1.5, 2005-03-02 14:37:18-05:00, mayer@pogo.udel.edu +50 -6
+    Fix to ignore 0 or less readlengths after the first one
+
+ChangeSet@1.1251.15.6, 2005-03-01 22:32:42-05:00, stenn@whimsy.udel.edu +6 -0
+  Changes from Dave Mills
+
+  include/ntpd.h@1.74, 2005-03-01 22:30:11-05:00, stenn@whimsy.udel.edu +1 -0
+    Changes from Dave Mills
+
+  ntpd/ntp_crypto.c@1.94, 2005-03-01 22:32:16-05:00, stenn@whimsy.udel.edu +2 -1
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.197, 2005-03-01 22:32:16-05:00, stenn@whimsy.udel.edu +3 -1
+    Changes from Dave Mills
+
+  ntpd/ntp_util.c@1.36, 2005-03-01 22:32:18-05:00, stenn@whimsy.udel.edu +7 -5
+    Changes from Dave Mills
+
+  ntpd/ntpd.c@1.61.1.4, 2005-03-01 22:32:15-05:00, stenn@whimsy.udel.edu +2 -1
+    Changes from Dave Mills
+
+  ntpd/ntpsim.c@1.9, 2005-03-01 22:32:19-05:00, stenn@whimsy.udel.edu +1 -0
+    Changes from Dave Mills
+
+ChangeSet@1.1251.15.5, 2005-02-28 20:17:40-05:00, mayer@pogo.udel.edu +1 -0
+  Fixed input_handler loops
+
+  ntpd/ntp_io.c@1.169.1.4, 2005-02-28 20:17:10-05:00, mayer@pogo.udel.edu +29 -38
+    Fixed input_handler loops
+
+ChangeSet@1.1251.15.3, 2005-02-28 13:23:19-05:00, mayer@pogo.udel.edu +1 -0
+  fixes in input_handler - additional changes required
+
+  ntpd/ntp_io.c@1.169.1.2, 2005-02-28 13:22:50-05:00, mayer@pogo.udel.edu +16 -3
+    fixes in input_handler - additional changes required
+
+ChangeSet@1.1251.15.2, 2005-02-28 13:21:47-05:00, mayer@pogo.udel.edu +1 -0
+  Bug #392 - using wrong group id for account
+
+  ntpd/ntpd.c@1.61.1.3, 2005-02-28 13:21:29-05:00, mayer@pogo.udel.edu +1 -1
+    Bug #392 - using wrong group id for account
+
+ChangeSet@1.1251.13.3, 2005-02-28 12:52:33-05:00, stenn@whimsy.udel.edu +5 -0
+  Changes from Dave Mills
+
+  include/ntp.h@1.107, 2005-02-28 12:51:30-05:00, stenn@whimsy.udel.edu +1 -1
+    Changes from Dave Mills
+
+  ntpd/ntp_config.c@1.121, 2005-02-28 12:51:04-05:00, stenn@whimsy.udel.edu +1 -1
+    Changes from Dave Mills
+
+  ntpd/ntp_io.c@1.167.1.1, 2005-02-28 12:51:05-05:00, stenn@whimsy.udel.edu +1 -8
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.196, 2005-02-28 12:51:05-05:00, stenn@whimsy.udel.edu +18 -34
+    Changes from Dave Mills
+
+  ntpd/refclock_acts.c@1.21.1.3, 2005-02-28 12:51:06-05:00, stenn@whimsy.udel.edu +218 -207
+    Changes from Dave Mills
+
+ChangeSet@1.1251.15.1, 2005-02-22 18:10:26-05:00, mayer@pogo.udel.edu +1 -0
+  Fix loop limits
+
+  ntpd/ntp_io.c@1.169.1.1, 2005-02-22 18:10:10-05:00, mayer@pogo.udel.edu +3 -3
+    Fix loop limits
+
+ChangeSet@1.1251.14.1, 2005-02-21 00:34:25-05:00, mayer@tecotoo. +1 -0
+  ntp_io.c:
+    Make MAXZEROREADS 1
+
+  ntpd/ntp_io.c@1.168.1.1, 2005-02-21 00:33:05-05:00, mayer@tecotoo. +4 -4
+    Make MAXZEROREADS 1
+
+ChangeSet@1.1251.1.86, 2005-02-21 00:26:12-05:00, mayer@pogo.udel.edu +1 -0
+  Additional changes to input_handler() to correctly break in refclock read loop
+
+  ntpd/ntp_io.c@1.169, 2005-02-21 00:25:37-05:00, mayer@pogo.udel.edu +8 -7
+    Additional changes to input_handler() to correctly break in refclock read loop
+
+ChangeSet@1.1251.13.2, 2005-02-18 23:00:34-05:00, stenn@whimsy.udel.edu +4 -0
+  changes from Dave Mills
+
+  libntp/clocktypes.c@1.17, 2005-02-18 22:55:49-05:00, stenn@whimsy.udel.edu +8 -8
+    changes from Dave Mills
+
+  ntpd/ntp_control.c@1.76, 2005-02-18 22:55:58-05:00, stenn@whimsy.udel.edu +6 -6
+    changes from Dave Mills
+
+  ntpd/refclock_acts.c@1.21.1.2, 2005-02-18 22:55:59-05:00, stenn@whimsy.udel.edu +14 -32
+    changes from Dave Mills
+
+  ntpd/refclock_conf.c@1.25, 2005-02-18 22:56:02-05:00, stenn@whimsy.udel.edu +4 -4
+    changes from Dave Mills
+
+ChangeSet@1.1251.13.1, 2005-02-16 00:37:44-05:00, stenn@whimsy.udel.edu +8 -0
+  Updates from Dave Mills
+
+  include/ntp.h@1.106, 2005-02-16 00:37:11-05:00, stenn@whimsy.udel.edu +6 -3
+    Updates from Dave Mills
+
+  include/ntp_config.h@1.32, 2005-02-16 00:37:12-05:00, stenn@whimsy.udel.edu +3 -1
+    Updates from Dave Mills
+
+  ntpd/ntp_config.c@1.120, 2005-02-16 00:37:19-05:00, stenn@whimsy.udel.edu +9 -0
+    Updates from Dave Mills
+
+  ntpd/ntp_proto.c@1.195, 2005-02-16 00:37:20-05:00, stenn@whimsy.udel.edu +64 -59
+    Updates from Dave Mills
+
+  ntpd/ntp_refclock.c@1.64, 2005-02-16 00:37:21-05:00, stenn@whimsy.udel.edu +2 -6
+    Updates from Dave Mills
+
+  ntpd/refclock_acts.c@1.21.1.1, 2005-02-16 00:37:21-05:00, stenn@whimsy.udel.edu +1 -1
+    Updates from Dave Mills
+
+  ntpd/refclock_arbiter.c@1.10, 2005-02-16 00:37:24-05:00, stenn@whimsy.udel.edu +35 -26
+    Updates from Dave Mills
+
+  ntpd/refclock_atom.c@1.52, 2005-02-16 00:37:21-05:00, stenn@whimsy.udel.edu +12 -23
+    Updates from Dave Mills
+
+ChangeSet@1.1251.1.84, 2005-02-15 22:56:40-05:00, mayer@tecotoo. +1 -0
+  Make MAXZEROREADS 1 so that the first zero-length read causes code to break and go to next socket
+
+  ntpd/ntp_io.c@1.168, 2005-02-15 22:54:30-05:00, mayer@tecotoo. +1 -1
+    Make MAXZEROREADS 1 so that the first zero-length read causes code to break and go to next socket
+
+ChangeSet@1.1251.12.1, 2005-02-15 19:40:54-05:00, mayer@tecotoo. +1 -0
+  Refix SMAX to 256 and fix &C0/1 comment - per Greg Dowd's messages
+
+  ntpd/refclock_acts.c@1.22, 2005-02-15 19:40:21-05:00, mayer@tecotoo. +2 -2
+    Refix SMAX to 256 and fix &C0/1 comment - per Greg Dowd's messages
+
+ChangeSet@1.1251.1.82, 2005-02-15 19:31:10-05:00, stenn@whimsy.udel.edu +3 -0
+  Updates from Dave Mills
+
+  html/confopt.html@1.29, 2005-02-15 19:30:57-05:00, stenn@whimsy.udel.edu +3 -2
+    Updates from Dave Mills
+
+  html/manyopt.html@1.10, 2005-02-15 19:30:55-05:00, stenn@whimsy.udel.edu +22 -17
+    Updates from Dave Mills
+
+  html/miscopt.html@1.30, 2005-02-15 19:30:56-05:00, stenn@whimsy.udel.edu +5 -8
+    Updates from Dave Mills
+
+ChangeSet@1.1251.1.81, 2005-02-15 18:09:42-05:00, mayer@pogo.udel.edu +1 -0
+  Added while look to read the clock until error or number of consecutive 0 len reads exceeds MAXZEROREADS
+
+  ntpd/ntp_io.c@1.167, 2005-02-15 18:09:22-05:00, mayer@pogo.udel.edu +76 -52
+    Added while look to read the clock until error or number of consecutive 0 len reads exceeds MAXZEROREADS
+
+ChangeSet@1.1251.1.80, 2005-02-15 00:18:50-05:00, mayer@tecotoo. +2 -0
+  Martin Burnicki's fixes to allow Windows to pass command line arguments to a system service
+
+  ntpd/ntpd.c@1.61.1.2, 2005-02-15 00:18:06-05:00, mayer@tecotoo. +3 -1
+    Martin Burnicki's fixes to allow Windows to pass command line arguments to a system service
+
+  ports/winnt/ntpd/ntservice.c@1.4, 2005-02-15 00:18:08-05:00, mayer@tecotoo. +21 -64
+    Martin Burnicki's fixes to allow Windows to pass command line arguments to a system service
+
+ChangeSet@1.1251.1.79, 2005-02-14 01:15:09-05:00, mayer@tecotoo. +1 -0
+  Bug #214: Return ISC_FALSE on not equal
+
+  ntpd/ntp_io.c@1.166, 2005-02-14 01:14:42-05:00, mayer@tecotoo. +2 -0
+    Bug #214: Return ISC_FALSE on not equal
+
+ChangeSet@1.1251.1.78, 2005-02-14 00:38:25-05:00, mayer@tecotoo. +2 -0
+  Bug #214: Use strcasecmp and not stricmp
+
+  ntpd/ntp_io.c@1.165, 2005-02-14 00:36:35-05:00, mayer@tecotoo. +1 -1
+    Bug #214: Use strcasecmp and not stricmp
+
+  ports/winnt/include/config.h@1.36, 2005-02-14 00:36:37-05:00, mayer@tecotoo. +1 -0
+    Bug #214: Use strcasecmp and not stricmp
+
+ChangeSet@1.1251.1.77, 2005-02-14 00:26:43-05:00, mayer@tecotoo. +2 -0
+  Bug #214: Allow option on command line to specify specific interface only to be used
+
+  ntpd/cmd_args.c@1.32, 2005-02-14 00:26:24-05:00, mayer@tecotoo. +6 -1
+    Bug #214: Allow option on command line to specify specific interface only to be used
+
+  ntpd/ntp_io.c@1.164, 2005-02-14 00:26:24-05:00, mayer@tecotoo. +22 -4
+    Bug #214: Allow option on command line to specify specific interface only to be used
+
+ChangeSet@1.1251.1.76, 2005-02-14 00:24:26-05:00, mayer@tecotoo. +1 -0
+  add stricmp to mapped functions for win32
+
+  ports/winnt/include/config.h@1.35, 2005-02-14 00:23:20-05:00, mayer@tecotoo. +1 -0
+    add stricmp to mapped functions
+
+ChangeSet@1.1251.1.75, 2005-02-13 00:53:55-05:00, mayer@tecotoo. +1 -0
+  Clean up code and reorganize input_handler()
+
+  ntpd/ntp_io.c@1.163, 2005-02-13 00:53:15-05:00, mayer@tecotoo. +224 -251
+    Clean up code and reorganize input_handler()
+
+ChangeSet@1.1251.1.74, 2005-02-12 13:29:10-05:00, mayer@pogo.udel.edu +1 -0
+  Change from &C1 to &C0 for the modem setup
+
+  ntpd/refclock_acts.c@1.21, 2005-02-12 13:28:52-05:00, mayer@pogo.udel.edu +2 -2
+    Change from &C1 to &C0 for the modem setup
+
+ChangeSet@1.1251.1.73, 2005-02-12 13:27:15-05:00, mayer@pogo.udel.edu +1 -0
+  Remove double loop and continue reading sockets rather than skipping out
+
+  ntpd/ntp_io.c@1.162, 2005-02-12 13:26:36-05:00, mayer@pogo.udel.edu +6 -4
+    Remove double loop and continue reading sockets rather than skipping out
+
+ChangeSet@1.1251.1.72, 2005-02-10 23:28:14-05:00, mayer@tecotoo. +1 -0
+  Group ID was being obtained incorrectly. See message from Martin Pitt - Debian development
+
+  ntpd/ntpd.c@1.61.1.1, 2005-02-10 23:27:54-05:00, mayer@tecotoo. +1 -1
+    Group ID was being obtained incorrectly. See message from Martin Pitt - Debian development
+
+ChangeSet@1.1251.1.71, 2005-02-10 23:26:16-05:00, mayer@tecotoo. +1 -0
+  Fix input_handler code to not select again until other I/O read and free buffer if nothing read. (see Bug #341 and messages from cipo)
+
+  ntpd/ntp_io.c@1.161, 2005-02-10 23:25:01-05:00, mayer@tecotoo. +6 -6
+    Fix input_handler code to not select again until other I/O read and free buffer if nothing read. (see Bug #341 and messages from cipo)
+
+ChangeSet@1.1251.1.70, 2005-02-09 00:59:19-05:00, stenn@whimsy.udel.edu +3 -0
+  Cleanup from Dave Mills
+
+  ntpd/ntp_config.c@1.119, 2005-02-09 00:59:00-05:00, stenn@whimsy.udel.edu +1 -1
+    Cleanup from Dave Mills
+
+  ntpd/ntp_proto.c@1.194, 2005-02-09 00:59:01-05:00, stenn@whimsy.udel.edu +1 -1
+    Cleanup from Dave Mills
+
+  ntpd/refclock_acts.c@1.20, 2005-02-09 00:59:02-05:00, stenn@whimsy.udel.edu +1 -1
+    Cleanup from Dave Mills
+
+ChangeSet@1.1268, 2005-02-06 01:41:55-05:00, stenn@pogo.udel.edu +1 -0
+  ntpdc lint
+
+  ntpdc/ntpdc.c@1.42, 2005-02-06 01:41:42-05:00, stenn@pogo.udel.edu +0 -8
+    lint
+
+ChangeSet@1.1267, 2005-02-06 01:31:47-05:00, stenn@pogo.udel.edu +1 -0
+  start hacking the ntpdc docs...
+
+  ntpdc/ntpdc-opts.def@1.2, 2005-02-06 01:31:39-05:00, stenn@pogo.udel.edu +2 -5
+    start hacking the ntpdc docs...
+
+ChangeSet@1.1266, 2005-02-06 01:22:40-05:00, stenn@pogo.udel.edu +5 -0
+  Convert ntpdc to autogen; some cleanup in ntpq
+
+  BitKeeper/etc/ignore@1.38, 2005-02-06 01:19:27-05:00, stenn@pogo.udel.edu +5 -0
+    added ntpdc-opts.c ntpdc-opts.h ntpdc-opts.menu ntpdc-opts.texi ntpdc.1
+
+  ntpdc/Makefile.am@1.24, 2005-02-06 01:21:32-05:00, stenn@pogo.udel.edu +20 -4
+    Convert ntpdc to autogen; some cleanup in ntpq
+
+  ntpdc/ntpdc-opts.def@1.1, 2005-02-06 01:20:12-05:00, stenn@pogo.udel.edu +178 -0
+
+  ntpdc/ntpdc-opts.def@1.0, 2005-02-06 01:20:12-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/ntpdc/ntpdc-opts.def
+
+  ntpdc/ntpdc.c@1.41, 2005-02-06 01:21:32-05:00, stenn@pogo.udel.edu +54 -0
+    Convert ntpdc to autogen; some cleanup in ntpq
+
+  ntpq/Makefile.am@1.17, 2005-02-06 01:21:36-05:00, stenn@pogo.udel.edu +1 -1
+    Convert ntpdc to autogen; some cleanup in ntpq
+
+ChangeSet@1.1251.1.69, 2005-02-05 22:47:46-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 388] Update URLs
+
+  html/drivers/driver43.html@1.9, 2005-02-05 22:47:32-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 388] Update URLs
+
+ChangeSet@1.1251.1.68, 2005-02-05 22:44:47-05:00, stenn@whimsy.udel.edu +1 -0
+  Poll updates from Dave Mills.
+
+  ntpd/ntp_proto.c@1.193, 2005-02-05 22:44:32-05:00, stenn@whimsy.udel.edu +11 -8
+    Poll updates from Dave Mills.
+
+ChangeSet@1.1251.1.67, 2005-02-03 01:18:23-05:00, stenn@whimsy.udel.edu +4 -0
+  ntp_config.h, ntp.h, ntp_proto.c, ntp_config.c:
+    Fixes from Dave Mills.  In particular, Dave writes:
+  
+    After discovering the situation reported on the newsgroup where 
+    misconfigured NTP had the Netgear disease, I put it through some 
+    wickedly broken configuration tests and found and fixed a few minor 
+    things in ntp-dev (not anything like the PPS oscillator).
+  
+    1. If a notrust error and iburst are configured, the client did not back 
+    off the poll interval. It now does that under all circumstances where 
+    the reply is absent or corrupt.
+  
+    2. An unresponsive server with iburst got hammered with eight messages 
+    every poll interval until the unreach counter reaches 12, then backs off 
+    sending only a single packet per burst. I changed that to send a burst 
+    only the first time after initial start or loss of reach.
+  
+    3. By popular demand I put in "tos maxdist N", where N is the selection 
+    threshold, normally 1. Set N to 16 and the clock will be set upon first 
+    receiving a response from any server. Y'know, like SNTP.
+
+  include/ntp.h@1.105, 2005-02-03 01:16:38-05:00, stenn@whimsy.udel.edu +2 -1
+    Fixes from Dave Mills
+
+  include/ntp_config.h@1.31, 2005-02-03 01:16:38-05:00, stenn@whimsy.udel.edu +1 -0
+    Fixes from Dave Mills
+
+  ntpd/ntp_config.c@1.118, 2005-02-03 01:16:26-05:00, stenn@whimsy.udel.edu +5 -0
+    Fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.192, 2005-02-03 01:16:28-05:00, stenn@whimsy.udel.edu +85 -67
+    Fixes from Dave Mills
+
+ChangeSet@1.1251.1.66, 2005-01-23 18:54:35-05:00, mayer@tecotoo. +1 -0
+  Need reference to address for scope
+
+  ntpd/ntp_io.c@1.160, 2005-01-23 18:54:04-05:00, mayer@tecotoo. +2 -2
+    Need reference to address for scope
+
+ChangeSet@1.1251.1.65, 2005-01-23 14:37:56-05:00, mayer@tecotoo. +1 -0
+  Wasn't setting scopeid for IPv6 addresses
+
+  ntpd/ntp_io.c@1.159, 2005-01-23 14:36:52-05:00, mayer@tecotoo. +7 -9
+    Wasn't setting scopeid for IPv6 addresses
+
+ChangeSet@1.1251.1.64, 2005-01-18 00:48:54-05:00, mayer@tecotoo. +2 -0
+  Fix missing parenthesis and remove duplicate CONFIG_CDELAY
+
+  include/ntp_config.h@1.30, 2005-01-18 00:47:56-05:00, mayer@tecotoo. +1 -2
+    Remove duplicate CONFIG_CDELAY
+
+  ports/winnt/include/isc/ipv6.h@1.6, 2005-01-18 00:47:10-05:00, mayer@tecotoo. +1 -1
+    Missing parenthesis in Macro
+
+ChangeSet@1.1251.11.1, 2005-01-16 19:29:57-05:00, mayer@tecotoo. +1 -0
+  Added debug code findinterface to see if the connect() fails
+
+  ntpd/ntp_io.c@1.158, 2005-01-16 19:28:39-05:00, mayer@tecotoo. +6 -0
+
+ChangeSet@1.1251.1.62, 2005-01-11 16:15:03-05:00, mayer@pogo.udel.edu +1 -0
+  Added isc/region.h
+
+  include/isc/Makefile.am@1.4, 2005-01-11 16:14:48-05:00, mayer@pogo.udel.edu +1 -0
+    Added isc/region.h
+
+ChangeSet@1.1251.1.61, 2005-01-11 16:02:59-05:00, mayer@pogo.udel.edu +1 -0
+  Added isc/buffer.h and isc/netscope.h
+
+  include/isc/Makefile.am@1.3, 2005-01-11 16:00:10-05:00, mayer@pogo.udel.edu +2 -0
+    Added isc/buffer.h and isc/netscope.h
+
+ChangeSet@1.1261, 2005-01-10 04:19:21-05:00, stenn@pogo.udel.edu +2 -0
+  fixes
+
+  configure.ac@1.364, 2005-01-10 04:19:11-05:00, stenn@pogo.udel.edu +7 -0
+    disable shared libraries on OSF4.0
+
+  m4/libopts.m4@1.3, 2005-01-10 04:18:45-05:00, stenn@pogo.udel.edu +2 -5
+    fix from bkorb
+
+ChangeSet@1.1260, 2005-01-09 06:23:02-05:00, stenn@pogo.udel.edu +27 -0
+  autogen-5.6.5
+
+  libopts/Makefile.am@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/autoopts.c@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +36 -20
+    autogen-5.6.5
+
+  libopts/autoopts.h@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/boolean.c@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/compat/compat.h@1.2, 2005-01-09 06:19:27-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/compat/pathfind.c@1.2, 2005-01-09 06:19:27-05:00, stenn@pogo.udel.edu +2 -2
+    autogen-5.6.5
+
+  libopts/enumeration.c@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/environment.c@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/genshell.c@1.2, 2005-01-09 06:22:16-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/genshell.h@1.2, 2005-01-09 06:22:16-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/libopts.m4@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +2 -29
+    autogen-5.6.5
+
+  libopts/load.c@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +2 -2
+    autogen-5.6.5
+
+  libopts/makeshell.c@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/numeric.c@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/options.h@1.2, 2005-01-09 06:22:17-05:00, stenn@pogo.udel.edu +3 -3
+    autogen-5.6.5
+
+  libopts/pgusage.c@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/putshell.c@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/restore.c@1.2, 2005-01-09 06:18:14-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/save.c@1.2, 2005-01-09 06:18:15-05:00, stenn@pogo.udel.edu +4 -3
+    autogen-5.6.5
+
+  libopts/sort.c@1.2, 2005-01-09 06:18:15-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/stack.c@1.2, 2005-01-09 06:18:15-05:00, stenn@pogo.udel.edu +1 -7
+    autogen-5.6.5
+
+  libopts/streqv.h@1.2, 2005-01-09 06:18:15-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/streqvcmp.c@1.2, 2005-01-09 06:18:15-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/usage-txt.h@1.2, 2005-01-09 06:22:17-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/usage.c@1.2, 2005-01-09 06:18:15-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  libopts/version.c@1.2, 2005-01-09 06:18:15-05:00, stenn@pogo.udel.edu +1 -1
+    autogen-5.6.5
+
+  m4/libopts.m4@1.2, 2005-01-09 06:18:07-05:00, stenn@pogo.udel.edu +2 -29
+    autogen-5.6.5
+
+ChangeSet@1.1251.7.31, 2005-01-09 02:05:42-05:00, stenn@whimsy.udel.edu +1 -0
+  Happy New Year
+
+  html/copyright.html@1.29, 2005-01-09 02:05:28-05:00, stenn@whimsy.udel.edu +2 -2
+    Happy New Year
+
+ChangeSet@1.1251.8.12, 2005-01-08 02:23:27-05:00, stenn@whimsy.udel.edu +1 -0
+  Show more stability data.
+
+  ntpd/ntp_util.c@1.35, 2005-01-08 02:23:13-05:00, stenn@whimsy.udel.edu +1 -1
+    Show more stability data.
+
+ChangeSet@1.1251.8.11, 2005-01-08 01:13:32-05:00, stenn@whimsy.udel.edu +1 -0
+  fencepost error
+
+  libntp/systime.c@1.32, 2005-01-08 01:13:15-05:00, stenn@whimsy.udel.edu +1 -1
+    fencepost error
+
+ChangeSet@1.1259, 2005-01-05 16:47:10-05:00, stenn@pogo.udel.edu +2 -0
+  cleanup
+
+  configure.ac@1.363, 2005-01-05 16:46:01-05:00, stenn@pogo.udel.edu +44 -33
+    Reorder AC_ARG_WITH to avoid an apparent quoting/redirect problem
+
+  ntpq/Makefile.am@1.16, 2005-01-05 16:45:18-05:00, stenn@pogo.udel.edu +1 -1
+    Library reorder
+
+ChangeSet@1.1251.8.10, 2005-01-05 01:16:04-05:00, stenn@whimsy.udel.edu +1 -0
+  Don't log 'refclockio structure not found'.  From Dave Mills
+
+  ntpd/ntp_io.c@1.148.1.1, 2005-01-05 01:15:49-05:00, stenn@whimsy.udel.edu +0 -7
+    Don't log 'refclockio structure not found'.  From Dave Mills
+
+ChangeSet@1.1251.1.58, 2005-01-05 00:12:51-05:00, mayer@tecotoo. +1 -0
+  Rename index to idx
+
+  ntpd/ntp_io.c@1.156, 2005-01-05 00:12:07-05:00, mayer@tecotoo. +4 -4
+    Rename index to idx
+
+ChangeSet@1.1251.1.57, 2005-01-04 21:38:58-05:00, mayer@tecotoo. +1 -0
+  Remove unnecessary includes
+
+  ntpd/ntp_io.c@1.155, 2005-01-04 21:36:25-05:00, mayer@tecotoo. +7 -17
+    Remove unnecessary includes
+
+ChangeSet@1.1251.1.56, 2005-01-02 21:13:48-05:00, mayer@tecotoo. +1 -0
+  Remove unnecessary include ntp_if.h
+
+  ntpd/ntp_io.c@1.154, 2005-01-02 21:13:21-05:00, mayer@tecotoo. +0 -1
+    Remove unnecessary include ntp_if.h
+
+ChangeSet@1.1251.1.55, 2005-01-02 18:28:21-05:00, mayer@tecotoo. +1 -0
+  remove include net/if.h. Some O/S's don't prevent double inclusions. It is already included in isc/net.h
+
+  libisc/interfaceiter.c@1.15, 2005-01-02 18:27:51-05:00, mayer@tecotoo. +0 -1
+    remove include net/if.h. Some O/S's don't prevent double inclusions. It is already included in isc/net.h
+
+ChangeSet@1.1251.1.54, 2005-01-01 22:14:34-05:00, mayer@tecotoo. +3 -0
+  Remove reference to interface index. Remove isc_log_write references
+
+  libisc/ifiter_getifaddrs.c@1.4, 2005-01-01 22:14:04-05:00, mayer@tecotoo. +0 -1
+    Remove reference to interface index. Remove isc_log_write references
+
+  libisc/ifiter_ioctl.c@1.21, 2005-01-01 22:14:04-05:00, mayer@tecotoo. +4 -20
+    Remove reference to interface index. Remove isc_log_write references
+
+  libisc/ifiter_sysctl.c@1.11, 2005-01-01 22:14:03-05:00, mayer@tecotoo. +0 -1
+    Remove reference to interface index. Remove isc_log_write references
+
+ChangeSet@1.1251.1.53, 2005-01-01 18:10:09-05:00, mayer@tecotoo. +1 -0
+  Updated msg macros
+
+  include/isc/msgs.h@1.3, 2005-01-01 18:09:48-05:00, mayer@tecotoo. +12 -10
+    Updated msg macros
+
+ChangeSet@1.1251.8.9, 2005-01-01 06:17:25-05:00, stenn@pogo.udel.edu +1 -0
+  Library reorder
+
+  ntpd/Makefile.am@1.41, 2005-01-01 06:17:15-05:00, stenn@pogo.udel.edu +1 -2
+    Library reorder
+
+ChangeSet@1.1251.10.2, 2005-01-01 00:49:42-05:00, mayer@pogo.udel.edu +1 -0
+  Use macros in buffer routines
+
+  include/isc/buffer.h@1.2, 2005-01-01 00:49:28-05:00, mayer@pogo.udel.edu +1 -1
+    Use macros in buffer routines
+
+ChangeSet@1.1251.10.1, 2005-01-01 00:48:50-05:00, mayer@pogo.udel.edu +4 -0
+  First upgrade of interfaceiter routines
+
+  libisc/ifiter_getifaddrs.c@1.1.1.1, 2005-01-01 00:48:14-05:00, mayer@pogo.udel.edu +15 -1
+    First upgrade of interfaceiter routines
+
+  libisc/ifiter_ioctl.c@1.18.1.1, 2005-01-01 00:48:13-05:00, mayer@pogo.udel.edu +393 -157
+    First upgrade of interfaceiter routines
+
+  libisc/ifiter_sysctl.c@1.8.1.1, 2005-01-01 00:48:13-05:00, mayer@pogo.udel.edu +24 -16
+    First upgrade of interfaceiter routines
+
+  libisc/interfaceiter.c@1.12.1.1, 2005-01-01 00:48:13-05:00, mayer@pogo.udel.edu +79 -73
+    First upgrade of interfaceiter routines
+
+ChangeSet@1.1251.9.1, 2004-12-30 22:52:08-05:00, mayer@tecotoo. +4 -0
+  First upgrade of interfaceiter routines
+
+  libisc/ifiter_getifaddrs.c@1.2, 2004-12-30 22:51:28-05:00, mayer@tecotoo. +15 -1
+    First upgrade of interfaceiter routines
+
+  libisc/ifiter_ioctl.c@1.19, 2004-12-30 22:51:27-05:00, mayer@tecotoo. +393 -157
+    First upgrade of interfaceiter routines
+
+  libisc/ifiter_sysctl.c@1.9, 2004-12-30 22:51:27-05:00, mayer@tecotoo. +24 -16
+    First upgrade of interfaceiter routines
+
+  libisc/interfaceiter.c@1.13, 2004-12-30 22:51:26-05:00, mayer@tecotoo. +79 -73
+    First upgrade of interfaceiter routines
+
+ChangeSet@1.1256, 2004-12-30 20:06:10-05:00, stenn@pogo.udel.edu +2 -0
+  Cleanup
+
+  Makefile.am@1.50, 2004-12-30 20:05:27-05:00, stenn@pogo.udel.edu +3 -3
+    Fix typos
+
+  ntpq/Makefile.am@1.15, 2004-12-30 20:05:57-05:00, stenn@pogo.udel.edu +1 -1
+    Missed AM_CPPFLAGS in the merge
+
+ChangeSet@1.1255, 2004-12-30 19:47:48-05:00, stenn@pogo.udel.edu +4 -0
+  cleanup
+
+  BitKeeper/deleted/.del-Makefile.in~783ae447256d94af@1.2, 2004-12-30 19:45:00-05:00, stenn@pogo.udel.edu +0 -0
+    Delete: libopts/Makefile.in
+
+  BitKeeper/etc/ignore@1.37, 2004-12-30 19:46:58-05:00, stenn@pogo.udel.edu +1 -0
+    added ntpq/ntpq.1
+
+  BitKeeper/etc/ignore@1.36, 2004-12-30 19:46:28-05:00, stenn@pogo.udel.edu +5 -0
+    added ltmain.sh ntpq/ntpq-opts.c ntpq/ntpq-opts.h ntpq/ntpq-opts.menu ntpq/ntpq-opts.texi
+
+  configure.ac@1.362, 2004-12-30 19:44:17-05:00, stenn@pogo.udel.edu +0 -1
+    Lint removal
+
+  ntpq/Makefile.am@1.14, 2004-12-30 19:44:01-05:00, stenn@pogo.udel.edu +0 -1
+    Cleanup
+
+ChangeSet@1.1253, 2004-12-30 17:53:32-05:00, stenn@pogo.udel.edu +39 -0
+  AutoOpts conversion - starting with ntpq
+
+  Makefile.am@1.49, 2004-12-30 17:50:45-05:00, stenn@pogo.udel.edu +8 -1
+    AutoOpts conversion
+
+  libopts/COPYING.lgpl@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +504 -0
+
+  libopts/COPYING.lgpl@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/COPYING.lgpl
+
+  libopts/COPYING.mbsd@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +26 -0
+
+  libopts/COPYING.mbsd@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/COPYING.mbsd
+
+  libopts/MakeDefs.inc@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +5 -0
+
+  libopts/MakeDefs.inc@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/MakeDefs.inc
+
+  libopts/Makefile.am@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +11 -0
+
+  libopts/Makefile.am@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/Makefile.am
+
+  libopts/Makefile.in@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +496 -0
+
+  libopts/Makefile.in@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/Makefile.in
+
+  libopts/README@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +89 -0
+
+  libopts/README@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/README
+
+  libopts/autoopts.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +1136 -0
+
+  libopts/autoopts.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/autoopts.c
+
+  libopts/autoopts.h@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +322 -0
+
+  libopts/autoopts.h@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/autoopts.h
+
+  libopts/boolean.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +104 -0
+
+  libopts/boolean.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/boolean.c
+
+  libopts/compat/compat.h@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +265 -0
+
+  libopts/compat/compat.h@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/compat/compat.h
+
+  libopts/compat/pathfind.c@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +278 -0
+
+  libopts/compat/pathfind.c@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/compat/pathfind.c
+
+  libopts/enumeration.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +448 -0
+
+  libopts/enumeration.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/enumeration.c
+
+  libopts/environment.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +264 -0
+
+  libopts/environment.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/environment.c
+
+  libopts/genshell.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +295 -0
+
+  libopts/genshell.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/genshell.c
+
+  libopts/genshell.h@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +122 -0
+
+  libopts/genshell.h@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/genshell.h
+
+  libopts/libopts.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +25 -0
+
+  libopts/libopts.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts.c
+
+  libopts/libopts.m4@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +395 -0
+
+  libopts/libopts.m4@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/libopts.m4
+
+  libopts/load.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +553 -0
+
+  libopts/load.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/load.c
+
+  libopts/makeshell.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +1096 -0
+
+  libopts/makeshell.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/makeshell.c
+
+  libopts/numeric.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +96 -0
+
+  libopts/numeric.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/numeric.c
+
+  libopts/options.h@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +436 -0
+
+  libopts/options.h@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/options.h
+
+  libopts/pgusage.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +156 -0
+
+  libopts/pgusage.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/pgusage.c
+
+  libopts/putshell.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +326 -0
+
+  libopts/putshell.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/putshell.c
+
+  libopts/restore.c@1.1, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +173 -0
+
+  libopts/restore.c@1.0, 2004-12-30 17:52:50-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/restore.c
+
+  libopts/save.c@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +478 -0
+
+  libopts/save.c@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/save.c
+
+  libopts/sort.c@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +357 -0
+
+  libopts/sort.c@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/sort.c
+
+  libopts/stack.c@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +238 -0
+
+  libopts/stack.c@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/stack.c
+
+  libopts/streqv.h@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +115 -0
+
+  libopts/streqv.h@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/streqv.h
+
+  libopts/streqvcmp.c@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +196 -0
+
+  libopts/streqvcmp.c@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/streqvcmp.c
+
+  libopts/tokenize.c@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +313 -0
+
+  libopts/tokenize.c@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/tokenize.c
+
+  libopts/tokenize.h@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +40 -0
+
+  libopts/tokenize.h@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/tokenize.h
+
+  libopts/usage-txt.h@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +503 -0
+
+  libopts/usage-txt.h@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/usage-txt.h
+
+  libopts/usage.c@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +646 -0
+
+  libopts/usage.c@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/usage.c
+
+  libopts/version.c@1.1, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +176 -0
+
+  libopts/version.c@1.0, 2004-12-30 17:52:51-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/libopts/version.c
+
+  m4/libopts.m4@1.1, 2004-12-30 17:51:53-05:00, stenn@pogo.udel.edu +395 -0
+
+  m4/libopts.m4@1.0, 2004-12-30 17:51:53-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/m4/libopts.m4
+
+  ntpq/Makefile.am@1.11.1.1, 2004-12-30 17:51:34-05:00, stenn@pogo.udel.edu +18 -4
+    AutoOpts conversion
+
+  ntpq/ntpq-opts.def@1.1, 2004-12-30 17:51:53-05:00, stenn@pogo.udel.edu +156 -0
+
+  ntpq/ntpq-opts.def@1.0, 2004-12-30 17:51:53-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev-ag/ntpq/ntpq-opts.def
+
+  ntpq/ntpq.c@1.49.1.1, 2004-12-30 17:51:34-05:00, stenn@pogo.udel.edu +48 -8
+    AutoOpts conversion
+
+ChangeSet@1.1251.8.8, 2004-12-28 00:46:27-05:00, stenn@whimsy.udel.edu +3 -0
+  cleanup from Dave Mills
+
+  ntpd/refclock_acts.c@1.19, 2004-12-28 00:41:00-05:00, stenn@whimsy.udel.edu +3 -1
+    file descriptor close cleanup from Dave Mills
+
+  ntpd/refclock_atom.c@1.51, 2004-12-28 00:45:10-05:00, stenn@whimsy.udel.edu +2 -2
+    corner case cleanup from Dave Mills
+
+  ntpd/refclock_wwv.c@1.53, 2004-12-28 00:42:08-05:00, stenn@whimsy.udel.edu +9 -25
+    wwv cleanup from Dave Mills
+
+ChangeSet@1.1251.8.7, 2004-12-27 06:15:13-05:00, stenn@whimsy.udel.edu +1 -0
+  Added ISC_PLATFORM_{NEEDPORTT,FIXIN6ISADDR} for Danny
+
+  configure.ac@1.359.1.7, 2004-12-27 06:15:00-05:00, stenn@whimsy.udel.edu +36 -2
+    Added ISC_PLATFORM_{NEEDPORTT,FIXIN6ISADDR} for Danny
+
+ChangeSet@1.1251.1.49, 2004-12-24 18:25:12-05:00, mayer@tecotoo. +2 -0
+  IPv6 changes
+
+  libisc/netaddr.c@1.2, 2004-12-24 18:25:00-05:00, mayer@tecotoo. +2 -0
+    IPv6 changes
+
+  libisc/sockaddr.c@1.2, 2004-12-24 18:25:01-05:00, mayer@tecotoo. +2 -0
+    IPv6 changes
+
+ChangeSet@1.1251.1.48, 2004-12-24 18:21:09-05:00, mayer@tecotoo. +1 -0
+  IPv6 changes
+
+  libisc/interfaceiter.c@1.12, 2004-12-24 18:20:51-05:00, mayer@tecotoo. +2 -0
+    IPv6 changes
+
+ChangeSet@1.1251.1.47, 2004-12-24 18:16:16-05:00, mayer@tecotoo. +1 -0
+  IPv6 changes again
+
+  include/isc/ipv6.h@1.6, 2004-12-24 18:15:54-05:00, mayer@tecotoo. +2 -2
+    IPv6 changes again
+
+ChangeSet@1.1251.1.46, 2004-12-24 18:10:50-05:00, mayer@tecotoo. +1 -0
+  IPv6 changes
+
+  include/isc/ipv6.h@1.5, 2004-12-24 18:10:22-05:00, mayer@tecotoo. +12 -12
+    IPv6 changes
+
+ChangeSet@1.1251.1.45, 2004-12-23 22:59:14-05:00, mayer@tecotoo. +1 -0
+  Alternate method of getting interface addresses
+
+  libisc/ifiter_getifaddrs.c@1.1, 2004-12-23 22:58:38-05:00, mayer@tecotoo. +178 -0
+    Alternate method of getting interface addresses
+
+  libisc/ifiter_getifaddrs.c@1.0, 2004-12-23 22:58:38-05:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/libisc/ifiter_getifaddrs.c
+
+ChangeSet@1.1251.1.44, 2004-12-23 22:41:22-05:00, mayer@tecotoo. +4 -0
+  Added new files to build and moved some macros
+
+  include/ntp_machine.h@1.18, 2004-12-23 22:40:38-05:00, mayer@tecotoo. +0 -2
+    Moved function defines for Win32 from ntp_machine.h to winnt/config.h
+
+  libntp/Makefile.am@1.31, 2004-12-23 22:38:13-05:00, mayer@tecotoo. +2 -1
+    Added new files to build
+
+  ports/winnt/include/config.h@1.34, 2004-12-23 22:40:38-05:00, mayer@tecotoo. +8 -2
+    Moved function defines for Win32 from ntp_machine.h to winnt/config.h
+
+  ports/winnt/libntp/libntp.dsp@1.24, 2004-12-23 22:38:34-05:00, mayer@tecotoo. +20 -0
+    Added new files to build
+
+ChangeSet@1.1251.1.43, 2004-12-23 15:24:48-05:00, mayer@pogo.udel.edu +2 -0
+  Miscellaneous compiler errors from port of BIND 9 code
+
+  include/isc/net.h@1.6, 2004-12-23 15:23:28-05:00, mayer@pogo.udel.edu +2 -3
+    missing #endifs
+
+  libisc/net.c@1.5, 2004-12-23 15:24:12-05:00, mayer@pogo.udel.edu +4 -16
+    Don't use the catalog like BIND 9
+
+ChangeSet@1.1251.1.41, 2004-12-23 00:16:06-05:00, mayer@tecotoo. +14 -0
+  ports from BIND 9.3.0 and reintegrated into ntp libisc xode
+
+  include/isc/buffer.h@1.1, 2004-12-22 23:55:44-05:00, mayer@tecotoo. +800 -0
+    isc_buffer header file
+
+  include/isc/buffer.h@1.0, 2004-12-22 23:55:44-05:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/include/isc/buffer.h
+
+  include/isc/net.h@1.5, 2004-12-23 00:15:11-05:00, mayer@tecotoo. +56 -10
+    ports from BIND 9.3.0 and reintegrated into ntp libisc code
+
+  include/isc/netaddr.h@1.4, 2004-12-23 00:15:11-05:00, mayer@tecotoo. +22 -12
+    ports from BIND 9.3.0 and reintegrated into ntp libisc code
+
+  include/isc/netscope.h@1.1, 2004-12-22 23:56:31-05:00, mayer@tecotoo. +40 -0
+    isc_netscope header file
+
+  include/isc/netscope.h@1.0, 2004-12-22 23:56:31-05:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/include/isc/netscope.h
+
+  include/isc/region.h@1.1, 2004-12-22 23:57:06-05:00, mayer@tecotoo. +95 -0
+    isc_region header file
+
+  include/isc/region.h@1.0, 2004-12-22 23:57:06-05:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/include/isc/region.h
+
+  include/isc/result.h@1.3, 2004-12-23 00:15:12-05:00, mayer@tecotoo. +14 -11
+    ports from BIND 9.3.0 and reintegrated into ntp libisc code
+
+  include/isc/sockaddr.h@1.3, 2004-12-23 00:15:12-05:00, mayer@tecotoo. +6 -0
+    ports from BIND 9.3.0 and reintegrated into ntp libisc code
+
+  libisc/net.c@1.4, 2004-12-23 00:15:13-05:00, mayer@tecotoo. +210 -10
+    ports from BIND 9.3.0 and reintegrated into ntp libisc code
+
+  libisc/netaddr.c@1.1, 2004-12-22 23:58:40-05:00, mayer@tecotoo. +357 -0
+    isc_netaddr functions
+
+  libisc/netaddr.c@1.0, 2004-12-22 23:58:40-05:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/libisc/netaddr.c
+
+  libisc/netscope.c@1.1, 2004-12-22 23:59:18-05:00, mayer@tecotoo. +74 -0
+
+  libisc/netscope.c@1.0, 2004-12-22 23:59:18-05:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/libisc/netscope.c
+
+  libisc/sockaddr.c@1.1, 2004-12-23 00:00:01-05:00, mayer@tecotoo. +474 -0
+    isc_sockaddr functions
+
+  libisc/sockaddr.c@1.0, 2004-12-23 00:00:01-05:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/libisc/sockaddr.c
+
+  ports/winnt/include/isc/ipv6.h@1.5, 2004-12-23 00:15:13-05:00, mayer@tecotoo. +16 -12
+    ports from BIND 9.3.0 and reintegrated into ntp libisc code
+
+  ports/winnt/include/isc/net.h@1.5, 2004-12-23 00:15:14-05:00, mayer@tecotoo. +60 -12
+    ports from BIND 9.3.0 and reintegrated into ntp libisc code
+
+  ports/winnt/libisc/net.c@1.6, 2004-12-23 00:15:14-05:00, mayer@tecotoo. +206 -10
+    ports from BIND 9.3.0 and reintegrated into ntp libisc code
+
+ChangeSet@1.1251.8.6, 2004-12-22 00:35:41-05:00, stenn@whimsy.udel.edu +1 -0
+   unused variable cleanup
+
+  ntpd/cmd_args.c@1.31, 2004-12-22 00:35:24-05:00, stenn@whimsy.udel.edu +0 -1
+     unused variable cleanup
+
+ChangeSet@1.1251.8.5, 2004-12-20 21:34:16-05:00, stenn@whimsy.udel.edu +1 -0
+  wwv cleanup from Dave Mills
+
+  ntpd/refclock_wwv.c@1.52, 2004-12-20 21:34:03-05:00, stenn@whimsy.udel.edu +6 -5
+    wwv cleanup from Dave Mills
+
+ChangeSet@1.1251.8.4, 2004-12-20 21:01:08-05:00, stenn@whimsy.udel.edu +1 -0
+  If "prefer" is set, only huffpuff to the preferred peer. From Dave Mills.
+
+  ntpd/ntp_loopfilter.c@1.101, 2004-12-20 21:00:54-05:00, stenn@whimsy.udel.edu +5 -1
+    If "prefer" is set, only huffpuff to the preferred peer. From Dave Mills.
+
+ChangeSet@1.1251.8.3, 2004-12-20 20:54:34-05:00, stenn@whimsy.udel.edu +1 -0
+  Lose -m from ntpd.html
+
+  html/ntpd.html@1.35, 2004-12-20 20:54:24-05:00, stenn@whimsy.udel.edu +6 -6
+    Lose -m from ntpd.html
+
+ChangeSet@1.1251.8.2, 2004-12-20 20:41:57-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 374] Always declare atom_shutdown().
+
+  ntpd/refclock_atom.c@1.50, 2004-12-20 20:41:44-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 374] Always declare atom_shutdown().
+
+ChangeSet@1.1251.8.1, 2004-12-20 20:36:18-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 378]: Added macros for Danny
+
+  configure.ac@1.359.1.6, 2004-12-20 20:36:06-05:00, stenn@whimsy.udel.edu +84 -1
+    [Bug 378]: Added macros for Danny
+
+ChangeSet@1.1251.7.26, 2004-12-18 04:55:09+00:00, abe@pogo.udel.edu +3 -0
+  
+
+  BitKeeper/etc/logging_ok@1.51, 2004-12-18 04:55:08+00:00, abe@pogo.udel.edu +1 -0
+    Logging to logging@openlogging.org accepted
+
+  html/drivers/driver40.html@1.12, 2004-12-18 04:43:20+00:00, abe@pogo.udel.edu +46 -4
+
+  ntpd/refclock_jjy.c@1.12, 2004-12-18 04:42:11+00:00, abe@pogo.udel.edu +275 -21
+
+ChangeSet@1.1251.7.25, 2004-12-17 04:49:29-05:00, stenn@whimsy.udel.edu +1 -0
+  atom cleanup from Dave Mills
+
+  ntpd/refclock_atom.c@1.49, 2004-12-17 04:49:09-05:00, stenn@whimsy.udel.edu +52 -18
+    atom cleanup from Dave Mills
+
+ChangeSet@1.1251.7.24, 2004-12-17 04:28:23-05:00, stenn@whimsy.udel.edu +2 -0
+  cleanup
+
+  ntpdc/ntpdc.c@1.40, 2004-12-17 04:28:05-05:00, stenn@whimsy.udel.edu +2 -2
+    cleanup
+
+  ntpq/ntpq.c@1.55, 2004-12-17 04:28:06-05:00, stenn@whimsy.udel.edu +2 -4
+    cleanup
+
+ChangeSet@1.1178.4.1, 2004-12-17 03:49:20-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 373] ntpq and ntpdv help menu improvement, from Charles Maier
+
+  ntpdc/ntpdc.c@1.33.1.1, 2004-12-17 03:48:58-05:00, stenn@whimsy.udel.edu +33 -37
+    [Bug 373] ntpq and ntpdv help menu improvement
+
+  ntpq/ntpq.c@1.48.1.1, 2004-12-17 03:48:58-05:00, stenn@whimsy.udel.edu +33 -33
+    [Bug 373] ntpq and ntpdv help menu improvement
+
+ChangeSet@1.1251.7.22, 2004-12-17 03:28:27-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 368] Use config.h for jitter.c
+
+  util/jitter.c@1.7, 2004-12-17 03:28:08-05:00, stenn@whimsy.udel.edu +4 -0
+    [Bug 368] Use config.h
+
+ChangeSet@1.1251.7.21, 2004-12-17 00:15:55-05:00, stenn@whimsy.udel.edu +1 -0
+  Lose -m
+
+  ntpd/cmd_args.c@1.30, 2004-12-17 00:15:38-05:00, stenn@whimsy.udel.edu +3 -11
+    Lose -m
+
+ChangeSet@1.1251.7.20, 2004-12-16 00:38:18-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 367]: Bump CONNECT to 20, fix typo accessing sys_phone[].
+
+  ntpd/refclock_acts.c@1.18, 2004-12-16 00:38:03-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 367]: Bump CONNECT to 20, fix typo accessing sys_phone[].
+
+ChangeSet@1.1251.7.19, 2004-12-14 00:09:04-05:00, stenn@whimsy.udel.edu +1 -0
+  netdb.h isnow handled by ntp_rcf2553.h
+
+  libntp/ntp_rfc2553.c@1.21, 2004-12-14 00:08:51-05:00, stenn@whimsy.udel.edu +0 -1
+    netdb.h isnow handled by ntp_rcf2553.h
+
+ChangeSet@1.1251.7.18, 2004-12-13 13:53:13-05:00, stenn@whimsy.udel.edu +1 -0
+  refclock_atom fixes.
+
+  ntpd/refclock_atom.c@1.48, 2004-12-13 13:53:10-05:00, stenn@whimsy.udel.edu +28 -25
+    Call atom_shutdown at shutdown time (Dave Mills).
+    Isolate HAVE_PPSAPI-specific code in atom_shutdown (Dave Mills).
+    
+    [Bug 366] Fix uninitialized pointer (Dave Mills, Martin Burnicki).
+
+ChangeSet@1.1251.7.17, 2004-12-13 02:11:09-05:00, stenn@whimsy.udel.edu +1 -0
+  more wwv cleanup from Dave Mills.
+
+  ntpd/refclock_wwv.c@1.51, 2004-12-13 02:10:59-05:00, stenn@whimsy.udel.edu +11 -17
+    more wwv cleanup from Dave Mills.
+
+ChangeSet@1.1251.7.16, 2004-12-11 22:42:45-05:00, stenn@whimsy.udel.edu +2 -0
+  New pps features from Dave Mills.
+
+  html/drivers/driver22.html@1.16, 2004-12-11 22:42:41-05:00, stenn@whimsy.udel.edu +10 -7
+    documentation  updates
+
+  ntpd/refclock_atom.c@1.47, 2004-12-11 22:42:41-05:00, stenn@whimsy.udel.edu +42 -35
+    flag2 controls the on-time edge (assert/clear).
+    
+    flag3 enables or disables kernel PPS support.
+    
+    ppsapi-timepps header cleanup.
+
+ChangeSet@1.1251.7.15, 2004-12-11 22:28:49-05:00, stenn@whimsy.udel.edu +6 -0
+  ppsapi header cleanup
+
+  ntpd/refclock_jupiter.c@1.19, 2004-12-11 22:28:43-05:00, stenn@whimsy.udel.edu +3 -1
+    ppsapi header cleanup
+
+  ntpd/refclock_mx4200.c@1.21, 2004-12-11 22:28:44-05:00, stenn@whimsy.udel.edu +3 -7
+    ppsapi header cleanup
+
+  ntpd/refclock_nmea.c@1.25, 2004-12-11 22:28:44-05:00, stenn@whimsy.udel.edu +1 -7
+    ppsapi header cleanup
+
+  ntpd/refclock_oncore.c@1.53, 2004-12-11 22:28:44-05:00, stenn@whimsy.udel.edu +3 -1
+    ppsapi header cleanup
+
+  ntpd/refclock_parse.c@1.28, 2004-12-11 22:28:44-05:00, stenn@whimsy.udel.edu +3 -1
+    ppsapi header cleanup
+
+  ntpd/refclock_ripencc.c@1.6, 2004-12-11 22:28:45-05:00, stenn@whimsy.udel.edu +3 -1
+    ppsapi header cleanup
+
+ChangeSet@1.1251.7.14, 2004-12-11 22:22:10-05:00, stenn@whimsy.udel.edu +2 -0
+  Lose the "pps" stuff from ntp.conf.  From Dave Mills.
+
+  include/ntp_config.h@1.29, 2004-12-11 22:22:06-05:00, stenn@whimsy.udel.edu +1 -8
+    Lose the PPS config stuff.
+
+  ntpd/ntp_config.c@1.117, 2004-12-11 22:22:06-05:00, stenn@whimsy.udel.edu +0 -1
+    Lose the "pps"  configuration stuff.
+
+ChangeSet@1.1251.7.13, 2004-12-10 23:33:03-05:00, stenn@whimsy.udel.edu +1 -0
+  More WWV cleanup from Dave Mills.
+
+  ntpd/refclock_wwv.c@1.50, 2004-12-10 23:32:59-05:00, stenn@whimsy.udel.edu +2 -2
+    More wwv cleanup from Dave Mills.
+
+ChangeSet@1.1251.7.12, 2004-12-10 18:03:43-05:00, stenn@whimsy.udel.edu +1 -0
+  refclock_wwv.c fixes from Dave Mills
+
+  ntpd/refclock_wwv.c@1.49, 2004-12-10 18:03:28-05:00, stenn@whimsy.udel.edu +85 -129
+    refclock_wwv.c fixes from Dave Mills
+
+ChangeSet@1.1251.7.11, 2004-12-10 18:00:32-05:00, stenn@whimsy.udel.edu +1 -0
+  FIXPOLL fix from Dave Mills
+
+  ntpd/ntp_proto.c@1.191, 2004-12-10 18:00:19-05:00, stenn@whimsy.udel.edu +4 -3
+    FIXPOLL fix from Dave Mills
+
+ChangeSet@1.1251.7.10, 2004-12-09 14:36:18-05:00, stenn@whimsy.udel.edu +1 -0
+  cleanup
+
+  configure.ac@1.359.1.5, 2004-12-09 14:35:49-05:00, stenn@whimsy.udel.edu +2 -2
+    cleanup
+
+ChangeSet@1.1251.7.9, 2004-12-08 22:09:06-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 368] net/if.h needs sys/socket.h
+
+  configure.ac@1.359.1.4, 2004-12-08 22:08:52-05:00, stenn@whimsy.udel.edu +2 -0
+    [Bug 368] net/if.h needs sys/socket.h
+
+ChangeSet@1.1251.7.8, 2004-12-08 21:49:05-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 368]: Distribute jitter.h, provide missing stdlib.h, fix LDADD
+
+  util/Makefile.am@1.25, 2004-12-08 21:48:52-05:00, stenn@whimsy.udel.edu +3 -0
+    [Bug 368]: Distribute jitter.h, provide missing stdlib.h, fix LDADD
+
+  util/jitter.c@1.6, 2004-12-08 21:48:52-05:00, stenn@whimsy.udel.edu +5 -4
+    [Bug 368]: Distribute jitter.h, provide missing stdlib.h, fix LDADD
+
+ChangeSet@1.1251.1.39, 2004-12-07 20:31:52-05:00, mayer@tecotoo. +1 -0
+  Renable wildcard for testing
+
+  ntpd/ntp_io.c@1.153, 2004-12-07 20:31:36-05:00, mayer@tecotoo. +2 -1
+    Renable wildcard for testing
+
+ChangeSet@1.1251.1.38, 2004-12-07 19:44:54-05:00, mayer@tecotoo. +1 -0
+  Add debugging detail for adding mcast group membership- error fix
+
+  ntpd/ntp_io.c@1.152, 2004-12-07 19:44:30-05:00, mayer@tecotoo. +0 -1
+    Add debugging detail for adding mcast group membership- error fix
+
+ChangeSet@1.1251.1.37, 2004-12-07 19:40:34-05:00, mayer@tecotoo. +1 -0
+  Add debugging detail for adding mcast group membership
+
+  ntpd/ntp_io.c@1.151, 2004-12-07 19:39:51-05:00, mayer@tecotoo. +11 -6
+    Add debugging detail for adding mcast group membership
+
+ChangeSet@1.1251.7.7, 2004-12-06 14:07:32-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 366] Distribute the ppsapi_timepps.h header
+
+  ntpd/Makefile.am@1.40, 2004-12-06 14:07:10-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 366] Distribute the ppsapi_timepps.h header
+
+ChangeSet@1.1251.7.6, 2004-12-06 03:51:05-05:00, stenn@whimsy.udel.edu +1 -0
+  timepps.h header cleanup
+
+  configure.ac@1.359.1.3, 2004-12-06 03:50:52-05:00, stenn@whimsy.udel.edu +1 -0
+    timepps.h header cleanup
+
+ChangeSet@1.1251.7.5, 2004-12-06 03:41:48-05:00, stenn@whimsy.udel.edu +6 -0
+  timepps.h header cleanup
+
+  configure.ac@1.359.1.2, 2004-12-06 03:41:00-05:00, stenn@whimsy.udel.edu +12 -6
+    timepps.h header cleanup
+
+  ntpd/ppsapi_timepps.h@1.1, 2004-12-06 03:40:00-05:00, stenn@whimsy.udel.edu +26 -0
+
+  ntpd/ppsapi_timepps.h@1.0, 2004-12-06 03:40:00-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/ntpd/ppsapi_timepps.h
+
+  ntpd/refclock_jupiter.c@1.18, 2004-12-06 03:41:00-05:00, stenn@whimsy.udel.edu +1 -9
+    timepps.h header cleanup
+
+  ntpd/refclock_oncore.c@1.52, 2004-12-06 03:41:00-05:00, stenn@whimsy.udel.edu +1 -30
+    timepps.h header cleanup
+
+  ntpd/refclock_parse.c@1.27, 2004-12-06 03:41:01-05:00, stenn@whimsy.udel.edu +1 -30
+    timepps.h header cleanup
+
+  ntpd/refclock_ripencc.c@1.5, 2004-12-06 03:41:01-05:00, stenn@whimsy.udel.edu +1 -7
+    timepps.h header cleanup
+
+ChangeSet@1.1251.7.4, 2004-12-05 23:38:24-05:00, stenn@whimsy.udel.edu +2 -0
+  WWV improvements from Dave Mills.
+
+  html/drivers/driver36.html@1.24, 2004-12-05 23:38:05-05:00, stenn@whimsy.udel.edu +80 -67
+    WWV improvements from Dave Mills.
+
+  ntpd/refclock_wwv.c@1.48, 2004-12-05 23:38:06-05:00, stenn@whimsy.udel.edu +155 -103
+    WWV improvements from Dave Mills.
+
+ChangeSet@1.1251.7.3, 2004-12-05 23:33:36-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 357] Fixed and additional improvements from Dave Mills
+
+  html/drivers/driver18.html@1.13, 2004-12-05 23:33:24-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 357] Fixed and additional improvements from Dave Mills
+
+ChangeSet@1.1251.7.2, 2004-12-05 21:12:40-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 357] Fixed and additional improvements from Dave Mills
+
+  html/miscopt.html@1.29, 2004-12-05 21:12:25-05:00, stenn@whimsy.udel.edu +3 -2
+    [Bug 357] Fixed and additional improvements from Dave Mills
+
+ChangeSet@1.1251.7.1, 2004-12-05 21:06:26-05:00, stenn@whimsy.udel.edu +3 -0
+  [Bug 357] Fixed and additional improvements from Dave Mills
+
+  include/ntpd.h@1.73, 2004-12-05 21:05:57-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 357] Fixed and additional improvements from Dave Mills
+
+  ntpd/ntp_config.c@1.116, 2004-12-05 21:05:57-05:00, stenn@whimsy.udel.edu +7 -7
+    [Bug 357] Fixed and additional improvements from Dave Mills
+
+  ntpd/refclock_acts.c@1.17, 2004-12-05 21:05:57-05:00, stenn@whimsy.udel.edu +11 -9
+    [Bug 357] Fixed and additional improvements from Dave Mills
+
+ChangeSet@1.1251.1.36, 2004-12-03 22:36:37-05:00, mayer@tecotoo. +1 -0
+  Undefine UDP_WILDCARD_DELIVERY for testing
+
+  ntpd/ntp_io.c@1.150, 2004-12-03 22:36:23-05:00, mayer@tecotoo. +5 -5
+    Undefine UDP_WILDCARD_DELIVERY for testing
+
+ChangeSet@1.1251.1.35, 2004-12-03 22:29:34-05:00, mayer@tecotoo. +1 -0
+  Undefine UDP_WILDCARD_DELIVERY for testing
+
+  ntpd/ntp_io.c@1.149, 2004-12-03 22:29:08-05:00, mayer@tecotoo. +5 -0
+    Undefine UDP_WILDCARD_DELIVERY for testing
+
+ChangeSet@1.1251.1.34, 2004-12-02 20:58:35-05:00, mayer@tecotoo. +1 -0
+  Add info on cast_flags in newpeer
+
+  ntpd/ntp_peer.c@1.67, 2004-12-02 20:58:08-05:00, mayer@tecotoo. +5 -0
+    Add info on cast_flags in newpeer
+
+ChangeSet@1.1251.1.33, 2004-11-30 05:20:17-05:00, stenn@pogo.udel.edu +16 -0
+  netdb.h cleanup
+
+  include/ntp_fp.h@1.12, 2004-11-30 05:18:39-05:00, stenn@pogo.udel.edu +1 -0
+    netdb.h cleanup
+
+  include/ntp_rfc2553.h@1.27, 2004-11-30 05:18:39-05:00, stenn@pogo.udel.edu +2 -0
+    netdb.h cleanup
+
+  libntp/decodenetnum.c@1.6, 2004-11-30 05:18:43-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+  libntp/numtohost.c@1.3, 2004-11-30 05:18:44-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+  libntp/socktoa.c@1.8, 2004-11-30 05:18:44-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+  libntp/socktohost.c@1.5, 2004-11-30 05:18:44-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+  ntpd/ntp_config.c@1.115, 2004-11-30 05:18:46-05:00, stenn@pogo.udel.edu +0 -2
+    netdb.h cleanup
+
+  ntpd/ntp_intres.c@1.39, 2004-11-30 05:18:46-05:00, stenn@pogo.udel.edu +0 -2
+    netdb.h cleanup
+
+  ntpd/ntp_resolver.c@1.18, 2004-11-30 05:18:47-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+  ntpd/refclock_nmea.c@1.24, 2004-11-30 05:18:49-05:00, stenn@pogo.udel.edu +0 -2
+    netdb.h cleanup
+
+  ntpdate/ntpdate.c@1.50, 2004-11-30 05:18:50-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+  ntpdate/ntptimeset.c@1.12, 2004-11-30 05:18:50-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+  ntpdc/ntpdc.c@1.38, 2004-11-30 05:18:50-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+  ntpdc/ntpdc_ops.c@1.38, 2004-11-30 05:18:53-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+  ntpq/ntpq.c@1.53, 2004-11-30 05:18:54-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+  ntpq/ntpq_ops.c@1.20.1.2, 2004-11-30 05:18:54-05:00, stenn@pogo.udel.edu +0 -1
+    netdb.h cleanup
+
+ChangeSet@1.1251.6.1, 2004-11-29 22:45:56-05:00, stenn@pogo.udel.edu +1 -0
+  findinterface() and findbcastinterf() should ignore wildcard sockets.  From Danny Mayer.
+
+  ntpd/ntp_io.c@1.148, 2004-11-29 22:45:45-05:00, stenn@pogo.udel.edu +2 -2
+    findinterface() and findbcastinterf() should ignore wildcard sockets.  From Danny Mayer.
+
+ChangeSet@1.1251.5.1, 2004-11-29 22:27:18-05:00, mayer@tecotoo. +1 -0
+  Fix winioctl warning messages
+
+  ports/winnt/ntpd/hopf_PCI_io.c@1.6, 2004-11-29 22:26:45-05:00, mayer@tecotoo. +5 -4
+    Fix winioctl warning messages
+
+ChangeSet@1.1251.1.30, 2004-11-29 01:09:27-05:00, stenn@whimsy.udel.edu +9 -0
+  FIXPOLL changes and cleanup from Dave Mills
+
+  include/ntp.h@1.104, 2004-11-29 01:06:29-05:00, stenn@whimsy.udel.edu +1 -0
+    FIXPOLL changes and cleanup from Dave Mills
+
+  ntpd/ntp_peer.c@1.66, 2004-11-29 01:06:45-05:00, stenn@whimsy.udel.edu +1 -2
+    FIXPOLL changes and cleanup from Dave Mills
+
+  ntpd/ntp_proto.c@1.190, 2004-11-29 01:06:45-05:00, stenn@whimsy.udel.edu +2 -6
+    FIXPOLL changes and cleanup from Dave Mills
+
+  ntpd/ntp_refclock.c@1.63, 2004-11-29 01:06:45-05:00, stenn@whimsy.udel.edu +1 -1
+    FIXPOLL changes and cleanup from Dave Mills
+
+  ntpd/refclock_acts.c@1.16, 2004-11-29 01:06:46-05:00, stenn@whimsy.udel.edu +1 -0
+    FIXPOLL changes and cleanup from Dave Mills
+
+  ntpd/refclock_arbiter.c@1.9, 2004-11-29 01:06:46-05:00, stenn@whimsy.udel.edu +48 -33
+    FIXPOLL changes and cleanup from Dave Mills
+
+  ntpd/refclock_atom.c@1.46, 2004-11-29 01:06:47-05:00, stenn@whimsy.udel.edu +36 -58
+    FIXPOLL changes and cleanup from Dave Mills
+
+  ntpd/refclock_wwv.c@1.47, 2004-11-29 01:06:50-05:00, stenn@whimsy.udel.edu +145 -139
+    FIXPOLL changes and cleanup from Dave Mills
+
+  ntpd/refclock_wwvb.c@1.14, 2004-11-29 01:06:50-05:00, stenn@whimsy.udel.edu +50 -28
+    FIXPOLL changes and cleanup from Dave Mills
+
+ChangeSet@1.1251.1.29, 2004-11-29 00:45:58-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 363] ntpdate: use -1 to represent an invalid fd (from Rainer Weikusat)
+
+  ntpdate/ntpdate.c@1.49, 2004-11-29 00:45:43-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 363] ntpdate: use -1 to represent an invalid fd (from Rainer Weikusat)
+
+ChangeSet@1.1251.1.28, 2004-11-28 03:35:01-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 363] ntpdate: use -1 to represent an invalid fd.
+  Fix from Rainer Weikusat.
+
+  ntpdate/ntpdate.c@1.48, 2004-11-28 03:34:45-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 363] ntpdate: use -1 to represent an invalid fd
+    Fix from Rainer Weikusat.
+
+ChangeSet@1.1251.1.27, 2004-11-21 21:33:09-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 349] Patches from Takao Abe
+
+  html/drivers/driver40.html@1.11, 2004-11-21 21:32:56-05:00, stenn@whimsy.udel.edu +6 -4
+    [Bug 349] Patches from Takao Abe
+
+  ntpd/refclock_jjy.c@1.11, 2004-11-21 21:32:56-05:00, stenn@whimsy.udel.edu +57 -15
+    [Bug 349] Patches from Takao Abe
+
+ChangeSet@1.1251.1.26, 2004-11-21 05:31:43-05:00, stenn@pogo.udel.edu +1 -0
+  lint
+
+  ntpd/refclock_parse.c@1.26, 2004-11-21 05:31:32-05:00, stenn@pogo.udel.edu +2 -2
+    lint
+
+ChangeSet@1.1251.1.25, 2004-11-21 05:23:35-05:00, stenn@whimsy.udel.edu +2 -0
+  Stuff from Dave Mills
+
+  libntp/icom.c@1.9, 2004-11-21 05:07:05-05:00, stenn@whimsy.udel.edu +1 -0
+    cleanup
+
+  ntpd/refclock_wwv.c@1.46, 2004-11-21 05:10:47-05:00, stenn@whimsy.udel.edu +159 -148
+    Fixes from Dave Mills
+
+  ntpd/refclock_wwv.c@1.45, 2004-11-20 02:38:44-05:00, stenn@whimsy.udel.edu +90 -93
+    lint
+
+ChangeSet@1.1251.1.24, 2004-11-21 04:26:47-05:00, stenn@whimsy.udel.edu +3 -0
+  [Bug 359] Fix qsort first-arg casting
+
+  ntpd/ntp_refclock.c@1.62, 2004-11-20 02:38:41-05:00, stenn@whimsy.udel.edu +7 -2
+    [Bug 359] Fix qsort first-arg casting
+
+  ntpd/refclock_msfees.c@1.11, 2004-11-20 02:38:43-05:00, stenn@whimsy.udel.edu +7 -1
+    [Bug 359] Fix qsort first-arg casting
+
+  util/hist.c@1.6, 2004-11-21 04:26:44-05:00, stenn@whimsy.udel.edu +7 -1
+    [Bug 359] Fix qsort first-arg casting
+
+ChangeSet@1.1251.1.23, 2004-11-21 03:55:29-05:00, stenn@whimsy.udel.edu +1 -0
+  Lint.
+
+  ntpd/refclock_mx4200.c@1.20, 2004-11-20 02:38:35-05:00, stenn@whimsy.udel.edu +3 -3
+    lint
+
+ChangeSet@1.1251.1.22, 2004-11-19 21:44:19-05:00, stenn@www.ntp.org +2 -0
+  qsort cast cleanup
+
+  ntpdc/ntpdc.c@1.37, 2004-11-19 21:44:09-05:00, stenn@www.ntp.org +4 -6
+    qsort cast cleanup
+
+  ntpq/ntpq.c@1.52, 2004-11-19 21:44:09-05:00, stenn@www.ntp.org +4 -6
+    qsort cast cleanup
+
+ChangeSet@1.1251.1.21, 2004-11-19 04:21:49-05:00, stenn@whimsy.udel.edu +1 -0
+  refclock_parse.c needs ntp_string.h now.
+
+  ntpd/refclock_parse.c@1.25, 2004-11-19 04:21:31-05:00, stenn@whimsy.udel.edu +1 -0
+    refclock_parse.c needs ntp_string.h now.
+
+ChangeSet@1.1251.4.1, 2004-11-19 03:04:35-05:00, stenn@whimsy.udel.edu +46 -0
+  [Bug 341] Patches from Frank Kardel
+
+  html/build/hints/parse@1.4, 2004-11-19 03:02:44-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 341] Patches from Frank Kardel
+
+  html/drivers/driver8.html@1.15, 2004-11-19 03:02:48-05:00, stenn@whimsy.udel.edu +306 -133
+    [Bug 341] Patches from Frank Kardel
+
+  html/parsenew.html@1.9, 2004-11-19 03:02:42-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 341] Patches from Frank Kardel
+
+  include/ascii.h@1.3, 2004-11-19 03:02:53-05:00, stenn@whimsy.udel.edu +34 -2
+    [Bug 341] Patches from Frank Kardel
+
+  include/binio.h@1.3, 2004-11-19 03:02:54-05:00, stenn@whimsy.udel.edu +34 -2
+    [Bug 341] Patches from Frank Kardel
+
+  include/ieee754io.h@1.3, 2004-11-19 03:02:54-05:00, stenn@whimsy.udel.edu +34 -2
+    [Bug 341] Patches from Frank Kardel
+
+  include/mbg_gps166.h@1.3, 2004-11-19 03:02:54-05:00, stenn@whimsy.udel.edu +33 -3
+    [Bug 341] Patches from Frank Kardel
+
+  include/parse.h@1.5, 2004-11-19 03:02:56-05:00, stenn@whimsy.udel.edu +34 -11
+    [Bug 341] Patches from Frank Kardel
+
+  include/parse_conf.h@1.3, 2004-11-19 03:02:57-05:00, stenn@whimsy.udel.edu +29 -9
+    [Bug 341] Patches from Frank Kardel
+
+  include/trimble.h@1.3, 2004-11-19 03:02:57-05:00, stenn@whimsy.udel.edu +34 -2
+    [Bug 341] Patches from Frank Kardel
+
+  kernel/chuinit.c@1.3, 2004-11-19 03:02:59-05:00, stenn@whimsy.udel.edu +0 -2
+    [Bug 341] Patches from Frank Kardel
+
+  kernel/clkinit.c@1.3, 2004-11-19 03:03:00-05:00, stenn@whimsy.udel.edu +0 -2
+    [Bug 341] Patches from Frank Kardel
+
+  kernel/sys/parsestreams.h@1.5, 2004-11-19 03:03:00-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 341] Patches from Frank Kardel
+
+  libntp/binio.c@1.4, 2004-11-19 03:03:02-05:00, stenn@whimsy.udel.edu +29 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libntp/buftvtots.c@1.4, 2004-11-19 03:03:02-05:00, stenn@whimsy.udel.edu +12 -83
+    [Bug 341] Patches from Frank Kardel
+
+  libntp/gpstolfp.c@1.6, 2004-11-19 03:03:04-05:00, stenn@whimsy.udel.edu +34 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libntp/ieee754io.c@1.6, 2004-11-19 03:03:04-05:00, stenn@whimsy.udel.edu +34 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libntp/mfp_mul.c@1.4, 2004-11-19 03:03:05-05:00, stenn@whimsy.udel.edu +34 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libntp/mktime.c@1.8, 2004-11-19 03:03:05-05:00, stenn@whimsy.udel.edu +0 -1
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/README@1.3, 2004-11-19 03:03:08-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_computime.c@1.7, 2004-11-19 03:03:08-05:00, stenn@whimsy.udel.edu +32 -9
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_dcf7000.c@1.7, 2004-11-19 03:03:08-05:00, stenn@whimsy.udel.edu +31 -8
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_hopf6021.c@1.7, 2004-11-19 03:03:08-05:00, stenn@whimsy.udel.edu +5 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_meinberg.c@1.7, 2004-11-19 03:03:08-05:00, stenn@whimsy.udel.edu +31 -8
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_rawdcf.c@1.9, 2004-11-19 03:03:08-05:00, stenn@whimsy.udel.edu +31 -8
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_rcc8000.c@1.7, 2004-11-19 03:03:09-05:00, stenn@whimsy.udel.edu +5 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_schmid.c@1.7, 2004-11-19 03:03:09-05:00, stenn@whimsy.udel.edu +32 -8
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_trimtaip.c@1.7, 2004-11-19 03:03:09-05:00, stenn@whimsy.udel.edu +33 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_trimtsip.c@1.7, 2004-11-19 03:03:09-05:00, stenn@whimsy.udel.edu +35 -3
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_varitext.c@1.6, 2004-11-19 03:03:10-05:00, stenn@whimsy.udel.edu +40 -8
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/clk_wharton.c@1.5, 2004-11-19 03:03:10-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/data_mbg.c@1.4, 2004-11-19 03:03:10-05:00, stenn@whimsy.udel.edu +32 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/info_trimble.c@1.3, 2004-11-19 03:03:10-05:00, stenn@whimsy.udel.edu +0 -2
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/parse.c@1.9, 2004-11-19 03:03:10-05:00, stenn@whimsy.udel.edu +35 -9
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/parse_conf.c@1.8, 2004-11-19 03:03:10-05:00, stenn@whimsy.udel.edu +31 -8
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/parsesolaris.c@1.5, 2004-11-19 03:03:10-05:00, stenn@whimsy.udel.edu +36 -12
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/parsestreams.c@1.5, 2004-11-19 03:03:11-05:00, stenn@whimsy.udel.edu +37 -11
+    [Bug 341] Patches from Frank Kardel
+
+  libparse/trim_info.c@1.3, 2004-11-19 03:03:11-05:00, stenn@whimsy.udel.edu +33 -2
+    [Bug 341] Patches from Frank Kardel
+
+  ntpd/ntp_config.c@1.114, 2004-11-19 03:03:11-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 341] Patches from Frank Kardel
+
+  ntpd/ntp_refclock.c@1.61, 2004-11-19 03:03:13-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 341] Patches from Frank Kardel
+
+  ntpd/refclock_atom.c@1.45, 2004-11-19 03:03:14-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 341] Patches from Frank Kardel
+
+  ntpd/refclock_parse.c@1.24, 2004-11-19 03:03:16-05:00, stenn@whimsy.udel.edu +513 -121
+    [Bug 341] Patches from Frank Kardel
+
+  parseutil/dcfd.c@1.14, 2004-11-19 03:03:18-05:00, stenn@whimsy.udel.edu +37 -11
+    [Bug 341] Patches from Frank Kardel
+
+  parseutil/testdcf.c@1.5, 2004-11-19 03:03:18-05:00, stenn@whimsy.udel.edu +38 -11
+    [Bug 341] Patches from Frank Kardel
+
+  scripts/monitoring/lr.pl@1.4, 2004-11-19 03:03:25-05:00, stenn@whimsy.udel.edu +12 -12
+    [Bug 341] Patches from Frank Kardel
+
+  scripts/monitoring/ntploopwatch@1.3, 2004-11-19 03:03:25-05:00, stenn@whimsy.udel.edu +31 -31
+    [Bug 341] Patches from Frank Kardel
+
+ChangeSet@1.1251.1.19, 2004-11-18 23:20:44-05:00, mayer@tecotoo. +4 -0
+  Miscellaneous Win32 fixes
+
+  ntpdc/ntpdc.c@1.36, 2004-11-18 23:15:41-05:00, mayer@tecotoo. +4 -1
+    Win32 uses a slightly different prototype for qsort
+
+  ntpq/ntpq.c@1.51, 2004-11-18 23:15:40-05:00, mayer@tecotoo. +4 -1
+    Win32 uses a slightly different prototype for qsort
+
+  ports/winnt/include/config.h@1.33, 2004-11-18 23:13:26-05:00, mayer@tecotoo. +12 -18
+    Code cleanup - eliminate duplicate entries
+
+  ports/winnt/ntpd/ntservice.c@1.3, 2004-11-18 23:14:20-05:00, mayer@tecotoo. +3 -3
+    Use main instead of ntpmain for entry
+
+ChangeSet@1.1251.3.3, 2004-11-16 22:16:52-05:00, mayer@tecotoo. +1 -0
+  Recommit fix
+
+  ntpd/cmd_args.c@1.28, 2004-11-16 22:16:34-05:00, mayer@tecotoo. +1 -1
+    Recommit fix
+
+  ntpd/cmd_args.c@1.27, 2004-11-16 00:16:58-05:00, mayer@tecotoo. +0 -1
+    Remove obsolete windows specific code
+
+ChangeSet@1.1251.3.2, 2004-11-16 00:13:54-05:00, mayer@tecotoo. +1 -0
+  cmd_args.c, cmd_Args.c:
+    Remove obsolete windows specific code
+
+  ntpd/cmd_args.c@1.26, 2004-11-06 21:38:12-05:00, mayer@tecotoo. +0 -0
+    Remove obsolete windows specific code
+
+  ntpd/cmd_Args.c@1.25, 2004-11-06 21:36:28-05:00, mayer@tecotoo. +0 -0
+    Remove obsolete windows specific code
+
+  ntpd/cmd_args.c@1.24, 2004-11-06 21:34:23-05:00, mayer@tecotoo. +0 -7
+    Remove obsolete windows specific code
+
+ChangeSet@1.1251.1.17, 2004-11-15 23:32:18-05:00, mayer@pogo.udel.edu +1 -0
+  John Hays burst mode fix for multicast
+
+  ntpd/ntp_proto.c@1.187.1.1, 2004-11-15 23:32:00-05:00, mayer@pogo.udel.edu +2 -0
+    John Hays burst mode fix for multicast
+
+ChangeSet@1.1251.3.1, 2004-11-15 23:24:51-05:00, mayer@tecotoo. +1 -0
+  John Hays burst mode fix for multicast
+
+  ntpd/ntp_proto.c@1.188, 2004-11-15 23:24:20-05:00, mayer@tecotoo. +2 -0
+    John Hays burst mode fix for multicast
+
+ChangeSet@1.1251.1.16, 2004-11-15 23:14:53-05:00, mayer@pogo.udel.edu +1 -0
+  Force the update. Refuses on Windows. Remove NoWinService code
+
+  ntpd/cmd_args.c@1.23.1.1, 2004-11-15 23:14:24-05:00, mayer@pogo.udel.edu +0 -8
+    Force the update. Refuses on Windows. Remove NoWinService code
+
+ChangeSet@1.1251.1.15, 2004-11-15 20:45:45-05:00, mayer@tecotoo. +1 -0
+  findbcastinter should be using INT_BCASTOPEN flag
+
+  ntpd/ntp_io.c@1.147, 2004-11-15 20:45:12-05:00, mayer@tecotoo. +2 -2
+    findbcastinter should be using INT_BCASTOPEN flag
+
+ChangeSet@1.1251.1.14, 2004-11-14 22:42:23-05:00, mayer@tecotoo. +2 -0
+  Added debugging code to track multicast issues
+
+  ntpd/ntp_io.c@1.146, 2004-11-14 22:41:46-05:00, mayer@tecotoo. +15 -1
+    Added debugging code to track multicast issues
+
+  ntpd/ntp_peer.c@1.65, 2004-11-14 22:41:48-05:00, mayer@tecotoo. +6 -0
+    Added debugging code to track multicast issues
+
+ChangeSet@1.1251.1.13, 2004-11-12 20:39:57-05:00, mayer@tecotoo. +1 -0
+  Add debugging information
+
+  ntpd/ntp_proto.c@1.187, 2004-11-12 20:39:35-05:00, mayer@tecotoo. +3 -0
+    Add debugging information
+
+ChangeSet@1.1251.1.12, 2004-11-12 20:39:10-05:00, mayer@tecotoo. +1 -0
+  Only enable broadcast for servers
+
+  ntpd/ntp_peer.c@1.64, 2004-11-12 20:38:48-05:00, mayer@tecotoo. +1 -1
+    Only enable broadcast for servers
+
+ChangeSet@1.1251.1.11, 2004-11-12 20:34:52-05:00, mayer@tecotoo. +1 -0
+  Need both windows.h and winsock2.h for VC 6.0
+
+  ports/winnt/include/config.h@1.32, 2004-11-12 20:34:18-05:00, mayer@tecotoo. +1 -1
+    Need both windows.h and winsock2.h for VC 6.0
+
+ChangeSet@1.1251.2.2, 2004-11-09 22:05:28-05:00, mayer@tecotoo. +3 -0
+  Move code to windows specific files
+
+  ntpd/ntpd.c@1.59.1.1, 2004-11-09 22:02:06-05:00, mayer@tecotoo. +3 -56
+    Remove Windows code from ntpd.c into nt_clockstuff.c
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.16, 2004-11-09 22:02:16-05:00, mayer@tecotoo. +15 -0
+    Remove Windows code from ntpd.c into nt_clockstuff.c
+
+  ports/winnt/ntpd/ntpd.dsp@1.25, 2004-11-09 22:01:05-05:00, mayer@tecotoo. +0 -5
+    Remove ntp_iopackets.c from compile list. Not ready
+
+ChangeSet@1.1251.1.9, 2004-11-09 04:38:42-05:00, stenn@whimsy.udel.edu +1 -0
+  re-enable the first call to getstartup()
+
+  ntpd/ntpd.c@1.60, 2004-11-09 04:38:29-05:00, stenn@whimsy.udel.edu +1 -1
+    re-enable the first call to getstartup()
+
+ChangeSet@1.1250.1.4, 2004-11-08 23:08:38-05:00, mayer@tecotoo. +3 -0
+  Fixes forInclude paths and extraneous windows code
+
+  ports/winnt/ntp-keygen/ntpkeygen.dsp@1.8, 2004-11-08 23:07:36-05:00, mayer@tecotoo. +1 -1
+    Fix include paths
+
+  ports/winnt/ntpdate/ntpdate.dsp@1.14, 2004-11-08 23:07:36-05:00, mayer@tecotoo. +2 -2
+    Fix include paths
+
+  ports/winnt/ntpq/ntpq.dsp@1.17, 2004-11-08 23:07:37-05:00, mayer@tecotoo. +1 -1
+    Fix include paths
+
+ChangeSet@1.1251.1.7, 2004-11-08 01:02:59-05:00, stenn@pogo.udel.edu +3 -0
+  [sntp] Lint removal
+
+  sntp/internet.c@1.4, 2004-11-08 01:02:36-05:00, stenn@pogo.udel.edu +10 -22
+    Lint removal
+
+  sntp/internet.h@1.3, 2004-11-08 01:02:36-05:00, stenn@pogo.udel.edu +2 -2
+    Lint removal
+
+  sntp/socket.c@1.5, 2004-11-08 01:02:36-05:00, stenn@pogo.udel.edu +4 -8
+    Lint removal
+
+ChangeSet@1.1251.1.5, 2004-11-07 17:14:12-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 344] Handle some corner cases better
+
+  bincheck.mf@1.2, 2004-11-07 17:14:00-05:00, stenn@whimsy.udel.edu +3 -2
+    [Bug 344] Handle some corner cases better
+
+ChangeSet@1.1251.1.4, 2004-11-07 04:13:44-05:00, stenn@whimsy.udel.edu +1 -0
+  AM_CPPFLAGS needed for nl.c
+
+  ntpdc/Makefile.am@1.23, 2004-11-07 04:13:14-05:00, stenn@whimsy.udel.edu +2 -2
+    AM_CPPFLAGS needed for nl.c
+
+ChangeSet@1.1251.1.3, 2004-11-07 03:01:26-05:00, stenn@pogo.udel.edu +9 -0
+  [Bug 344] Allow daemons to be installed in sbin
+
+  adjtimed/Makefile.am@1.3, 2004-11-07 03:00:37-05:00, stenn@pogo.udel.edu +10 -8
+    [Bug 344] Allow daemons to be installed in sbin
+
+  bincheck.mf@1.1, 2004-11-07 02:56:30-05:00, stenn@pogo.udel.edu +14 -0
+
+  bincheck.mf@1.0, 2004-11-07 02:56:30-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev/bincheck.mf
+
+  configure.ac@1.359.1.1, 2004-11-07 03:00:02-05:00, stenn@pogo.udel.edu +21 -2
+    [Bug 344] Allow daemons to be installed in sbin
+
+  ntpd/Makefile.am@1.39, 2004-11-07 03:00:02-05:00, stenn@pogo.udel.edu +17 -9
+    [Bug 344] Allow daemons to be installed in sbin
+
+  ntpdate/Makefile.am@1.12, 2004-11-07 03:00:02-05:00, stenn@pogo.udel.edu +15 -12
+    [Bug 344] Allow daemons to be installed in sbin
+
+  ntpdc/Makefile.am@1.22, 2004-11-07 03:00:02-05:00, stenn@pogo.udel.edu +6 -3
+    [Bug 344] Allow daemons to be installed in sbin
+
+  ntpq/Makefile.am@1.12, 2004-11-07 03:00:37-05:00, stenn@pogo.udel.edu +10 -10
+    [Bug 344] Allow daemons to be installed in sbin
+
+  sntp/Makefile.am@1.6, 2004-11-07 03:00:02-05:00, stenn@pogo.udel.edu +4 -1
+    [Bug 344] Allow daemons to be installed in sbin
+
+  sntp/configure.ac@1.8, 2004-11-07 03:00:02-05:00, stenn@pogo.udel.edu +18 -0
+    [Bug 344] Allow daemons to be installed in sbin
+
+ChangeSet@1.1249.1.11, 2004-11-06 21:43:44-05:00, mayer@tecotoo. +2 -0
+  Miscellaneous
+
+  include/recvbuff.h@1.8, 2004-11-06 21:42:39-05:00, mayer@tecotoo. +1 -0
+    Add flags about the received packet
+
+  ports/winnt/libntp/syslog.c@1.3, 2004-11-06 21:43:16-05:00, mayer@tecotoo. +2 -1
+    modifed variable definition
+
+ChangeSet@1.1249.1.10, 2004-11-06 21:36:41-05:00, mayer@tecotoo. +8 -0
+  Updates to move windows-specific code into the windows-specific files
+
+  ntpd/ntp_config.c@1.113, 2004-11-06 21:35:04-05:00, mayer@tecotoo. +1 -1
+    Remove obsolete windows specific code
+
+  ntpd/ntpd.c@1.57.1.1, 2004-11-06 21:26:26-05:00, mayer@tecotoo. +16 -155
+    Remove Windows specific code. Put in other files
+
+  ports/winnt/include/clockstuff.h@1.6, 2004-11-06 21:32:48-05:00, mayer@tecotoo. +1 -0
+    Move Console setup and service setup to nt_clockstuff.c
+
+  ports/winnt/include/ntp_iocompletionport.h@1.8, 2004-11-06 21:28:49-05:00, mayer@tecotoo. +2 -0
+    Move completion events from ntpd.c to ntp_iocompletionport.c
+
+  ports/winnt/include/ntservice.h@1.2, 2004-11-06 21:30:09-05:00, mayer@tecotoo. +1 -0
+    Move Console setup to ntservice
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.15, 2004-11-06 21:32:49-05:00, mayer@tecotoo. +35 -15
+    Move Console setup and service setup to nt_clockstuff.c
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.13, 2004-11-06 21:28:49-05:00, mayer@tecotoo. +46 -0
+    Move completion events from ntpd.c to ntp_iocompletionport.c
+
+  ports/winnt/ntpd/ntservice.c@1.2, 2004-11-06 21:30:09-05:00, mayer@tecotoo. +70 -17
+    Move Console setup to ntservice
+
+ChangeSet@1.1250.1.2, 2004-11-06 04:13:33-05:00, stenn@whimsy.udel.edu +1 -0
+  lint
+
+  ntpd/ntpd.c@1.58, 2004-11-06 04:13:21-05:00, stenn@whimsy.udel.edu +0 -1
+    lint
+
+ChangeSet@1.1249.1.9, 2004-11-04 00:03:35-05:00, mayer@tecotoo. +6 -0
+  Prefix constants with NTP_ to avoid collisions with VS.NET
+
+  ntpdc/ntpdc.c@1.35, 2004-11-04 00:02:40-05:00, mayer@tecotoo. +9 -8
+    Prefix constants with NTP_ to avoid collisions with VS.NET
+
+  ntpdc/ntpdc.h@1.4, 2004-11-04 00:02:41-05:00, mayer@tecotoo. +7 -7
+    Prefix constants with NTP_ to avoid collisions with VS.NET
+
+  ntpdc/ntpdc_ops.c@1.37, 2004-11-04 00:02:42-05:00, mayer@tecotoo. +21 -21
+    Prefix constants with NTP_ to avoid collisions with VS.NET
+
+  ntpq/ntpq.c@1.50, 2004-11-04 00:03:08-05:00, mayer@tecotoo. +18 -17
+    Prefix constants with NTP_ to avoid collisions with VS.NET
+
+  ntpq/ntpq.h@1.4, 2004-11-04 00:03:08-05:00, mayer@tecotoo. +10 -7
+    Prefix constants with NTP_ to avoid collisions with VS.NET
+
+  ntpq/ntpq_ops.c@1.20.1.1, 2004-11-04 00:03:09-05:00, mayer@tecotoo. +17 -17
+    Prefix constants with NTP_ to avoid collisions with VS.NET
+
+ChangeSet@1.1202.1.47, 2004-11-03 02:43:58-05:00, stenn@pogo.udel.edu +2 -0
+  autogen
+
+  configure.ac@1.351.1.10, 2004-11-03 02:40:39-05:00, stenn@pogo.udel.edu +2 -0
+    autogen
+
+  ntpq/ntpq-subs.c@1.21, 2004-10-30 17:25:09-04:00, stenn@pogo.udel.edu +0 -0
+    Rename: ntpq/ntpq_ops.c -> ntpq/ntpq-subs.c
+
+ChangeSet@1.1251, 2004-11-03 01:51:42-05:00, stenn@pogo.udel.edu +1 -0
+  Disable mlockall() under linux for now - resolver problems.
+
+  configure.ac@1.359, 2004-11-03 01:51:29-05:00, stenn@pogo.udel.edu +3 -0
+    Disable mlockall() under linux for now - resolver problems.
+
+ChangeSet@1.1249.1.8, 2004-11-02 23:25:17-05:00, mayer@tecotoo. +1 -0
+  Moved NT Services to it's own file
+
+  ntpd/ntpd.c@1.57, 2004-11-02 23:24:59-05:00, mayer@tecotoo. +56 -151
+    Moved NT Services to it's own file
+
+ChangeSet@1.1249.1.7, 2004-11-02 23:23:49-05:00, mayer@tecotoo. +1 -0
+  Changes to support VS.NET
+
+  ports/winnt/ntp-keygen/ntpkeygen.dsp@1.7, 2004-11-02 23:23:25-05:00, mayer@tecotoo. +4 -4
+    Changes to support VS.NET
+
+ChangeSet@1.1249.1.6, 2004-11-02 23:22:53-05:00, mayer@tecotoo. +3 -0
+  Changes to support VS.NET
+
+  ports/winnt/include/isc/ipv6.h@1.4, 2004-11-02 23:22:24-05:00, mayer@tecotoo. +15 -3
+    Changes to support VS.NET
+
+  ports/winnt/include/isc/net.h@1.4, 2004-11-02 23:18:10-05:00, mayer@tecotoo. +4 -2
+    Changes to support VS.NET
+
+  ports/winnt/libisc/net.c@1.5, 2004-11-02 23:18:10-05:00, mayer@tecotoo. +2 -0
+    Changes to support VS.NET
+
+ChangeSet@1.1249.1.5, 2004-11-02 23:15:30-05:00, mayer@tecotoo. +1 -0
+  Changes to support VS.NET
+
+  ports/winnt/include/config.h@1.31, 2004-11-02 23:15:16-05:00, mayer@tecotoo. +44 -6
+    Changes to support VS.NET
+
+ChangeSet@1.1249.1.4, 2004-11-02 23:14:21-05:00, mayer@tecotoo. +2 -0
+  NT Services for NTP
+
+  ports/winnt/include/ntservice.h@1.1, 2004-11-02 23:13:56-05:00, mayer@tecotoo. +34 -0
+    NT Services for NTP
+
+  ports/winnt/include/ntservice.h@1.0, 2004-11-02 23:13:56-05:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/ports/winnt/include/ntservice.h
+
+  ports/winnt/ntpd/ntservice.c@1.1, 2004-11-02 23:13:56-05:00, mayer@tecotoo. +241 -0
+    NT Services for NTP
+
+  ports/winnt/ntpd/ntservice.c@1.0, 2004-11-02 23:13:56-05:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/ports/winnt/ntpd/ntservice.c
+
+ChangeSet@1.1249.1.3, 2004-11-02 23:07:27-05:00, mayer@tecotoo. +1 -0
+  Redefine various error functions for win32
+
+  ports/winnt/libisc/isc_strerror.c@1.4, 2004-11-02 23:07:08-05:00, mayer@tecotoo. +8 -8
+    Redefine various error functions for win32
+
+ChangeSet@1.1249.1.2, 2004-11-02 23:05:22-05:00, mayer@tecotoo. +3 -0
+  Remove unnecessary time variable references
+
+  libntp/mktime.c@1.7, 2004-11-02 23:04:56-05:00, mayer@tecotoo. +3 -5
+    Remove unnecessary time variable references
+
+  libntp/ranny.c@1.3, 2004-11-02 23:04:56-05:00, mayer@tecotoo. +0 -2
+    Remove unnecessary time variable references
+
+  ports/winnt/ntpd/nt_clockstuff.c@1.14, 2004-11-02 23:04:57-05:00, mayer@tecotoo. +25 -27
+    Remove unnecessary time variable references
+
+ChangeSet@1.1249.1.1, 2004-11-02 23:02:31-05:00, mayer@tecotoo. +5 -0
+  Updates to support changes required for VS.NET
+
+  ports/winnt/libntp/libntp.dsp@1.23, 2004-11-02 23:01:14-05:00, mayer@tecotoo. +4 -7
+    Updates to support changes required for VS.NET
+
+  ports/winnt/ntpd/ntpd.dsp@1.24, 2004-11-02 23:01:25-05:00, mayer@tecotoo. +40 -4
+    Updates to support changes required for VS.NET
+
+  ports/winnt/ntpdate/ntpdate.dsp@1.13, 2004-11-02 23:01:44-05:00, mayer@tecotoo. +2 -2
+    Updates to support changes required for VS.NET
+
+  ports/winnt/ntpdc/ntpdc.dsp@1.16, 2004-11-02 23:01:33-05:00, mayer@tecotoo. +2 -2
+    Updates to support changes required for VS.NET
+
+  ports/winnt/ntpq/ntpq.dsp@1.16, 2004-11-02 23:01:54-05:00, mayer@tecotoo. +2 -2
+    Updates to support changes required for VS.NET
+
+ChangeSet@1.1249, 2004-11-01 23:46:20-05:00, mayer@tecotoo. +1 -0
+  Mulitcast IPv6 check
+
+  ntpd/ntp_io.c@1.145, 2004-11-01 23:46:00-05:00, mayer@tecotoo. +2 -3
+    Mulitcast IPv6 check
+
+ChangeSet@1.1247, 2004-11-01 23:03:40-05:00, mayer@tecotoo. +3 -0
+  IPv6 fixes and Added dump of interface function
+
+  include/ntpd.h@1.71, 2004-11-01 23:01:45-05:00, mayer@tecotoo. +1 -0
+    Added dump of interface function
+
+  ntpd/ntp_config.c@1.109.1.1, 2004-11-01 22:59:30-05:00, mayer@tecotoo. +41 -20
+    Fix for IPv6
+
+  ntpd/ntp_intres.c@1.35.1.1, 2004-11-01 22:59:29-05:00, mayer@tecotoo. +22 -2
+    Fix for IPv6
+
+ChangeSet@1.1246, 2004-11-01 22:55:10-05:00, mayer@tecotoo. +1 -0
+  Fix multicast to open it's own socket. Fall back on wildcard if it fails
+
+  ntpd/ntp_io.c@1.143, 2004-11-01 22:54:41-05:00, mayer@tecotoo. +287 -494
+    Fix multicast to open it's own socket. Fall back on wildcard if it fails
+
+ChangeSet@1.1202.5.10, 2004-10-31 16:23:23-05:00, stenn@whimsy.udel.edu +1 -0
+  PTB responses are 78 bytes long, not 40.
+
+  ntpd/refclock_acts.c@1.15, 2004-10-31 16:23:09-05:00, stenn@whimsy.udel.edu +1 -1
+    PTB responses are 78 bytes long, not 40.
+
+ChangeSet@1.1202.5.8, 2004-10-29 22:56:12-04:00, mayer@pogo.udel.edu +2 -0
+  Should have used ISC_R_SUCCESS and not ISC_TRUE for return from isc_net_probeipv6(). Don't allow IPv6 addreses when no IPv6 available
+
+  ntpd/ntp_config.c@1.111, 2004-10-29 22:55:08-04:00, mayer@pogo.udel.edu +36 -22
+    Should have used ISC_R_SUCCESS and not ISC_TRUE for return from isc_net_probeipv6(). Don't allow IPv6 addreses when no IPv6 available
+
+  ntpd/ntp_intres.c@1.37, 2004-10-29 22:54:13-04:00, mayer@pogo.udel.edu +4 -4
+    Should have used ISC_R_SUCCESS and not ISC_TRUE for return from isc_net_probeipv6()
+
+ChangeSet@1.1202.7.1, 2004-10-29 05:52:47-04:00, stenn@whimsy.udel.edu +10 -0
+  Updates from Dave Mills
+
+  html/build/hints.html@1.15, 2004-10-29 05:51:12-04:00, stenn@whimsy.udel.edu +1 -1
+    Updates from Dave Mills
+
+  html/build/hints/solaris-dosynctodr.html@1.5, 2004-10-29 05:51:13-04:00, stenn@whimsy.udel.edu +11 -11
+    Updates from Dave Mills
+
+  html/drivers/driver18.html@1.12, 2004-10-29 05:51:15-04:00, stenn@whimsy.udel.edu +44 -49
+    Updates from Dave Mills
+
+  html/drivers/driver29.html@1.13, 2004-10-29 05:51:15-04:00, stenn@whimsy.udel.edu +1 -1
+    Updates from Dave Mills
+
+  html/drivers/driver38.html@1.12, 2004-10-29 05:51:16-04:00, stenn@whimsy.udel.edu +3 -3
+    Updates from Dave Mills
+
+  html/drivers/driver39.html@1.12, 2004-10-29 05:51:16-04:00, stenn@whimsy.udel.edu +3 -3
+    Updates from Dave Mills
+
+  html/drivers/driver44.html@1.11, 2004-10-29 05:51:17-04:00, stenn@whimsy.udel.edu +3 -6
+    Updates from Dave Mills
+
+  html/drivers/driver5.html@1.12, 2004-10-29 05:51:17-04:00, stenn@whimsy.udel.edu +1 -1
+    Updates from Dave Mills
+
+  html/drivers/driver8.html@1.14, 2004-10-29 05:51:17-04:00, stenn@whimsy.udel.edu +1 -1
+    Updates from Dave Mills
+
+  html/ntpd.html@1.34, 2004-10-29 05:51:10-04:00, stenn@whimsy.udel.edu +5 -8
+    Updates from Dave Mills
+
+ChangeSet@1.1202.6.1, 2004-10-28 20:49:19-04:00, mayer@pogo.udel.edu +2 -0
+  Ensure that DNS lookups on IPv6-absent systems only look up IPv4 addresses
+
+  ntpd/ntp_config.c@1.110, 2004-10-28 20:48:42-04:00, mayer@pogo.udel.edu +7 -0
+    Ensure that DNS lookups on IPv6-absent systems only look up IPv4 addresses
+
+  ntpd/ntp_intres.c@1.36, 2004-10-28 20:48:43-04:00, mayer@pogo.udel.edu +21 -1
+    Ensure that DNS lookups on IPv6-absent systems only look up IPv4 addresses
+
+ChangeSet@1.1202.5.6, 2004-10-27 19:52:51-04:00, stenn@whimsy.udel.edu +6 -0
+  Updates from Dave Mills
+
+  html/copyright.html@1.28, 2004-10-27 19:52:28-04:00, stenn@whimsy.udel.edu +2 -2
+    Updates from Dave Mills
+
+  html/drivers/footer.txt@1.1, 2004-10-27 19:50:59-04:00, stenn@whimsy.udel.edu +7 -0
+
+  html/drivers/footer.txt@1.0, 2004-10-27 19:50:59-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/drivers/footer.txt
+
+  html/drivers/tf582_4.html@1.1, 2004-10-27 19:50:59-04:00, stenn@whimsy.udel.edu +72 -0
+
+  html/drivers/tf582_4.html@1.0, 2004-10-27 19:50:59-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/drivers/tf582_4.html
+
+  html/keygen.html@1.5, 2004-10-27 19:52:28-04:00, stenn@whimsy.udel.edu +1 -1
+    Updates from Dave Mills
+
+  html/ntpd.html@1.33, 2004-10-27 19:52:30-04:00, stenn@whimsy.udel.edu +1 -1
+    Updates from Dave Mills
+
+  html/refclock.html@1.30, 2004-10-27 19:52:28-04:00, stenn@whimsy.udel.edu +8 -6
+    Updates from Dave Mills
+
+ChangeSet@1.1202.5.5, 2004-10-26 20:25:31-04:00, stenn@whimsy.udel.edu +1 -0
+  Remove mort from the backroom auto-build list
+
+  br-flock@1.5, 2004-10-26 20:25:19-04:00, stenn@whimsy.udel.edu +1 -1
+    Remove mort from the backroom auto-build list
+
+ChangeSet@1.1202.4.5, 2004-10-24 22:46:38-04:00, mayer@pogo.udel.edu +1 -0
+  Add interface_dump functionality
+
+  include/ntpd.h@1.69.1.1, 2004-10-24 22:46:22-04:00, mayer@pogo.udel.edu +1 -0
+    Add interface_dump functionality
+
+ChangeSet@1.1202.4.4, 2004-10-24 22:45:54-04:00, mayer@pogo.udel.edu +1 -0
+  Add interface_dump functionality
+
+  ntpd/ntp_io.c@1.119.1.5, 2004-10-24 22:45:35-04:00, mayer@pogo.udel.edu +58 -0
+    Add interface_dump functionality
+
+ChangeSet@1.1202.4.3, 2004-10-24 22:44:25-04:00, mayer@pogo.udel.edu +1 -0
+  Remove interface_dump
+
+  ntpd/ntp_control.c@1.70.1.4, 2004-10-24 22:43:43-04:00, mayer@pogo.udel.edu +0 -1
+    Remove interface_dump
+
+ChangeSet@1.1202.4.2, 2004-10-24 22:42:51-04:00, mayer@pogo.udel.edu +1 -0
+  Don't allow null interfaces
+
+  ntpd/ntp_peer.c@1.60.1.1, 2004-10-24 22:42:12-04:00, mayer@pogo.udel.edu +8 -0
+    Don't allow null interfaces
+
+ChangeSet@1.1245, 2004-10-24 22:37:46-04:00, mayer@tecotoo. +1 -0
+  Don't allow null interfaces
+
+  ntpd/ntp_peer.c@1.62, 2004-10-24 22:37:27-04:00, mayer@tecotoo. +8 -0
+    Don't allow null interfaces
+
+ChangeSet@1.1202.5.3, 2004-10-23 03:25:29-04:00, stenn@whimsy.udel.edu +1 -0
+  sntp can be installed in sbin
+
+  sntp/Makefile.am@1.5, 2004-10-23 03:25:14-04:00, stenn@whimsy.udel.edu +1 -1
+    sntp can be installed in sbin
+
+ChangeSet@1.1202.5.2, 2004-10-23 03:09:05-04:00, stenn@whimsy.udel.edu +6 -0
+  Lose broadcast and server modes from sntp.
+
+  sntp/README@1.2, 2004-10-23 03:07:46-04:00, stenn@whimsy.udel.edu +28 -27
+    Lose broadcast and server modes.
+
+  sntp/draft-mills-sntp-v4-00.txt@1.1, 2004-10-23 00:12:58-04:00, stenn@whimsy.udel.edu +1514 -0
+
+  sntp/draft-mills-sntp-v4-00.txt@1.0, 2004-10-23 00:12:58-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/sntp/draft-mills-sntp-v4-00.txt
+
+  sntp/header.h@1.6, 2004-10-23 03:07:45-04:00, stenn@whimsy.udel.edu +1 -3
+    Lose broadcast and server modes.
+
+  sntp/main.c@1.5, 2004-10-23 03:07:45-04:00, stenn@whimsy.udel.edu +19 -115
+    Lose broadcast and server modes.
+
+  sntp/sntp.1@1.4, 2004-10-23 03:07:46-04:00, stenn@whimsy.udel.edu +0 -23
+    Lose broadcast and server modes.
+
+  sntp/socket.c@1.4, 2004-10-23 03:07:45-04:00, stenn@whimsy.udel.edu +6 -22
+    Lose broadcast and server modes.
+
+ChangeSet@1.1202.5.1, 2004-10-23 00:09:11-04:00, stenn@whimsy.udel.edu +2 -0
+  Fixes from Dave Mills
+
+  ntpd/ntp_util.c@1.34, 2004-10-23 00:07:18-04:00, stenn@whimsy.udel.edu +1 -1
+    loopstats output cleanup
+
+  ntpd/refclock_atom.c@1.44, 2004-10-23 00:08:19-04:00, stenn@whimsy.udel.edu +1 -0
+    Specify PPS_API_VERS_1
+
+ChangeSet@1.1202.1.42, 2004-10-19 21:26:34-04:00, stenn@pogo.udel.edu +2 -0
+  select() EINTR and mlockall() under linux problem avoidance.
+
+  configure.ac@1.351.1.9, 2004-10-19 21:25:15-04:00, stenn@pogo.udel.edu +3 -0
+    Stop using mlockall() under linux
+
+  ntpd/ntpd.c@1.55.1.1, 2004-10-19 21:23:14-04:00, stenn@pogo.udel.edu +1 -1
+    Only show the select() EINTR reports at debug >5
+
+ChangeSet@1.1202.1.41, 2004-10-18 00:37:02-04:00, stenn@whimsy.udel.edu +1 -0
+  lint fixes for refclock_mx4200.c
+
+  ntpd/refclock_mx4200.c@1.19, 2004-10-18 00:36:35-04:00, stenn@whimsy.udel.edu +3 -3
+    lint
+
+ChangeSet@1.1202.1.40, 2004-10-16 07:30:33-04:00, stenn@www.ntp.org +3 -0
+  Rename html2man.pl to html2man.in so we can use PATH_PERL.
+
+  configure.ac@1.351.1.8, 2004-10-16 07:28:54-04:00, stenn@www.ntp.org +1 -0
+    Rename html2man.pl to html2man.in so we can use PATH_PERL.
+
+  scripts/Makefile.am@1.11, 2004-10-16 07:28:38-04:00, stenn@www.ntp.org +2 -2
+    Rename html2man.pl to html2man.in so we can use PATH_PERL.
+
+  scripts/html2man.in@1.5, 2004-10-16 07:28:39-04:00, stenn@www.ntp.org +4 -6
+    Rename html2man.pl to html2man.in so we can use PATH_PERL.
+
+  scripts/html2man.in@1.4, 2004-10-16 06:50:52-04:00, stenn@www.ntp.org +0 -0
+    Rename: scripts/html2man.pl -> scripts/html2man.in
+
+ChangeSet@1.1202.1.39, 2004-10-16 06:19:50-04:00, stenn@www.ntp.org +1 -0
+  [Bug 348] genkeys -> keygen, and .htm -> .html
+
+  scripts/html2man.pl@1.3, 2004-10-16 06:19:02-04:00, stenn@www.ntp.org +2 -2
+    [Bug 348] genkeys -> keygen, and .htm -> .html
+
+ChangeSet@1.1202.3.1, 2004-10-14 00:35:10-04:00, mayer@pogo.udel.edu +1 -0
+  Fix to broadcast. broadcast address socket was not being opened
+
+  ntpd/ntp_io.c@1.119.1.4, 2004-10-14 00:34:40-04:00, mayer@pogo.udel.edu +27 -9
+    Fix to broadcast. broadcast address socket was not being opened
+
+ChangeSet@1.1202.1.37, 2004-10-12 21:08:44-04:00, stenn@whimsy.udel.edu +2 -0
+  Fixes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.100, 2004-10-12 21:08:25-04:00, stenn@whimsy.udel.edu +9 -15
+    Dave Mills: kernel cleanup
+
+  ntpd/ntp_proto.c@1.181.1.5, 2004-10-12 21:07:56-04:00, stenn@whimsy.udel.edu +1 -1
+    Dave Mills: If MCAST, turn off BURST as well.
+
+ChangeSet@1.1244, 2004-10-10 19:46:59-04:00, mayer@tecotoo. +1 -0
+  Fix for refclock_open  for Windows due to signature change (Again)
+
+  ports/winnt/include/win32_io.h@1.7, 2004-10-10 19:46:39-04:00, mayer@tecotoo. +1 -2
+    Fix for refclock_open  for Windows due to signature change (Again)
+
+ChangeSet@1.1243, 2004-10-10 19:46:22-04:00, mayer@tecotoo. +1 -0
+  Add support for enable_broadcast() call for servers (Again)
+
+  ntpd/ntp_io.c@1.142, 2004-10-10 19:45:28-04:00, mayer@tecotoo. +2 -1
+    Add support for enable_broadcast() call for servers (Again)
+
+ChangeSet@1.1241, 2004-10-10 19:10:18-04:00, mayer@tecotoo. +2 -0
+  Fix for refclock_open  for Windows due to signature change
+
+  ports/winnt/include/win32_io.h@1.4.1.1, 2004-10-10 19:09:56-04:00, mayer@tecotoo. +1 -1
+    Fix for refclock_open  for Windows due to signature change
+
+  ports/winnt/ntpd/win32_io.c@1.9.1.1, 2004-10-10 19:09:56-04:00, mayer@tecotoo. +2 -2
+    Fix for refclock_open  for Windows due to signature change
+
+ChangeSet@1.1240, 2004-10-10 19:08:19-04:00, mayer@tecotoo. +3 -0
+  Add support for enable_broadcast() call for servers
+
+  include/ntpd.h@1.68.1.1, 2004-10-10 19:06:55-04:00, mayer@tecotoo. +4 -4
+    Add support for enable_broadcast() call for servers
+
+  ntpd/ntp_io.c@1.139.1.1, 2004-10-10 19:06:53-04:00, mayer@tecotoo. +21 -3
+    Add support for enable_broadcast() call for servers
+
+  ntpd/ntp_peer.c@1.59.1.1, 2004-10-10 19:06:54-04:00, mayer@tecotoo. +8 -0
+    Add support for enable_broadcast() call for servers
+
+ChangeSet@1.1202.1.36, 2004-10-08 22:24:44-04:00, stenn@whimsy.udel.edu +3 -0
+  Changes/cleanup from Dave Mills
+
+  ntpd/ntp_control.c@1.70.1.3, 2004-10-08 22:24:26-04:00, stenn@whimsy.udel.edu +1 -1
+    Changes/cleanup from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.99, 2004-10-08 22:24:27-04:00, stenn@whimsy.udel.edu +9 -12
+    Changes/cleanup from Dave Mills
+
+  ntpd/ntp_util.c@1.33, 2004-10-08 22:24:28-04:00, stenn@whimsy.udel.edu +2 -2
+    Changes/cleanup from Dave Mills
+
+ChangeSet@1.1202.1.35, 2004-10-08 19:43:05-04:00, stenn@whimsy.udel.edu +1 -0
+  Dave Mills: No autokey over the wildcard interface
+
+  ntpd/ntp_proto.c@1.181.1.4, 2004-10-08 19:42:51-04:00, stenn@whimsy.udel.edu +17 -15
+    Dave Mills: No autokey over the wildcard interface
+
+ChangeSet@1.1202.1.34, 2004-10-07 22:49:19-04:00, mayer@pogo.udel.edu +2 -0
+  Win32 fix for refclock_open() signature change
+
+  ports/winnt/include/win32_io.h@1.5, 2004-10-07 22:48:58-04:00, mayer@pogo.udel.edu +1 -1
+    Win32 fix for refclock_open() signature change
+
+  ports/winnt/ntpd/win32_io.c@1.7.1.2, 2004-10-07 22:48:59-04:00, mayer@pogo.udel.edu +2 -2
+    Win32 fix for refclock_open() signature change
+
+ChangeSet@1.1202.1.33, 2004-10-07 22:43:33-04:00, mayer@pogo.udel.edu +1 -0
+  Modification to have broadcast servers enable the socket for broadcast (missing argument)
+
+  ntpd/ntp_io.c@1.119.1.3, 2004-10-07 22:42:40-04:00, mayer@pogo.udel.edu +1 -1
+    Modification to have broadcast servers enable the socket for broadcast (missing argument)
+
+ChangeSet@1.1202.1.32, 2004-10-07 22:40:57-04:00, mayer@pogo.udel.edu +3 -0
+  Modification to have broadcast servers enable the socket for broadcast
+
+  include/ntpd.h@1.69, 2004-10-07 22:40:33-04:00, mayer@pogo.udel.edu +4 -4
+    Modification to have broadcast servers enable the socket for broadcast
+
+  ntpd/ntp_io.c@1.119.1.2, 2004-10-07 22:40:33-04:00, mayer@pogo.udel.edu +18 -0
+    Modification to have broadcast servers enable the socket for broadcast
+
+  ntpd/ntp_peer.c@1.60, 2004-10-07 22:40:33-04:00, mayer@pogo.udel.edu +8 -0
+    Modification to have broadcast servers enable the socket for broadcast
+
+ChangeSet@1.1202.1.31, 2004-10-06 22:21:10-04:00, stenn@whimsy.udel.edu +2 -0
+  Remove PTB and USNO lint
+
+  README.refclocks@1.3, 2004-10-06 22:20:56-04:00, stenn@whimsy.udel.edu +2 -2
+    Remove PTB and USNO lint
+
+  configure.ac@1.351.1.7, 2004-10-06 22:20:56-04:00, stenn@whimsy.udel.edu +0 -40
+    Remove PTB and USNO lint
+
+ChangeSet@1.1202.1.30, 2004-10-05 18:27:54-04:00, stenn@whimsy.udel.edu +4 -0
+  Cleanup from Dave Mills
+
+  ntpd/ntp_control.c@1.70.1.2, 2004-10-05 18:27:37-04:00, stenn@whimsy.udel.edu +2 -2
+    Cleanup from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.98, 2004-10-05 18:27:37-04:00, stenn@whimsy.udel.edu +4 -4
+    Cleanup from Dave Mills
+
+  ntpd/ntp_request.c@1.58, 2004-10-05 18:27:41-04:00, stenn@whimsy.udel.edu +1 -1
+    Cleanup from Dave Mills
+
+  ntpd/ntp_util.c@1.32, 2004-10-05 18:27:39-04:00, stenn@whimsy.udel.edu +2 -2
+    Cleanup from Dave Mills
+
+ChangeSet@1.1202.1.29, 2004-10-02 03:56:39-04:00, stenn@whimsy.udel.edu +9 -0
+  Cleanup from Dave Mills
+
+  include/ntp_refclock.h@1.17, 2004-10-02 03:54:54-04:00, stenn@whimsy.udel.edu +6 -4
+    Cleanup from Dave Mills
+
+  include/ntpd.h@1.68, 2004-10-02 03:54:55-04:00, stenn@whimsy.udel.edu +0 -1
+    Cleanup from Dave Mills
+
+  ntpd/ntp_config.c@1.109, 2004-10-02 03:55:07-04:00, stenn@whimsy.udel.edu +4 -1
+    Cleanup from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.97, 2004-10-02 03:55:08-04:00, stenn@whimsy.udel.edu +37 -31
+    Cleanup from Dave Mills
+
+  ntpd/ntp_proto.c@1.181.1.3, 2004-10-02 03:55:09-04:00, stenn@whimsy.udel.edu +2 -5
+    Cleanup from Dave Mills
+
+  ntpd/ntp_refclock.c@1.60, 2004-10-02 03:55:09-04:00, stenn@whimsy.udel.edu +205 -180
+    Cleanup from Dave Mills
+
+  ntpd/ntp_request.c@1.57, 2004-10-02 03:55:09-04:00, stenn@whimsy.udel.edu +2 -2
+    Cleanup from Dave Mills
+
+  ntpd/refclock_acts.c@1.14, 2004-10-02 03:55:10-04:00, stenn@whimsy.udel.edu +134 -72
+    Cleanup from Dave Mills
+
+  ntpd/refclock_wwvb.c@1.13, 2004-10-02 03:55:13-04:00, stenn@whimsy.udel.edu +4 -11
+    Cleanup from Dave Mills
+
+ChangeSet@1.1202.1.28, 2004-09-22 23:23:06-04:00, mayer@pogo.udel.edu +5 -0
+  Fix the precompiled header issue
+
+  ports/winnt/libntp/libntp.dsp@1.18.1.1, 2004-09-22 23:22:41-04:00, mayer@pogo.udel.edu +13 -1
+    Fix the precompiled header issue
+
+  ports/winnt/ntp-keygen/ntpkeygen.dsp@1.4.1.1, 2004-09-22 23:22:42-04:00, mayer@pogo.udel.edu +2 -2
+    Fix the precompiled header issue
+
+  ports/winnt/ntpd/ntpd.dsp@1.21.1.1, 2004-09-22 23:22:41-04:00, mayer@pogo.udel.edu +6 -2
+    Fix the precompiled header issue
+
+  ports/winnt/ntpdc/ntpdc.dsp@1.13.1.1, 2004-09-22 23:22:42-04:00, mayer@pogo.udel.edu +2 -2
+    Fix the precompiled header issue
+
+  ports/winnt/ntpq/ntpq.dsp@1.13.1.1, 2004-09-22 23:22:42-04:00, mayer@pogo.udel.edu +2 -2
+    Fix the precompiled header issue
+
+ChangeSet@1.1202.1.27, 2004-09-22 23:21:56-04:00, mayer@pogo.udel.edu +1 -0
+  Add support for VS.NET (aka V7) and finally fix the RPC Async header issues
+
+  ports/winnt/include/config.h@1.26.1.1, 2004-09-22 23:21:29-04:00, mayer@pogo.udel.edu +9 -6
+    Add support for VS.NET (aka V7) and finally fix the RPC Async header issues
+
+ChangeSet@1.1202.1.26, 2004-09-22 23:20:39-04:00, mayer@pogo.udel.edu +1 -0
+  total_buffs() and full_buffs() were returning the wrong value
+
+  libntp/recvbuff.c@1.8.1.1, 2004-09-22 23:20:07-04:00, mayer@pogo.udel.edu +2 -2
+    total_buffs() and full_buffs() were returning the wrong value
+
+ChangeSet@1.1238, 2004-09-22 23:19:14-04:00, mayer@tecotoo. +1 -0
+  total_buffs() and full_buffs() were returning the wrong value
+
+  libntp/recvbuff.c@1.9, 2004-09-22 23:18:57-04:00, mayer@tecotoo. +2 -2
+    total_buffs() and full_buffs() were returning the wrong value
+
+ChangeSet@1.1237, 2004-09-22 23:09:51-04:00, mayer@tecotoo. +1 -0
+  Add support for VS.NET (aka V7) and finally fix the RPC Async header issues
+
+  ports/winnt/include/config.h@1.29, 2004-09-22 23:09:16-04:00, mayer@tecotoo. +7 -6
+    Add support for VS.NET (aka V7) and finally fix the RPC Async header issues
+
+ChangeSet@1.1236, 2004-09-22 00:40:32-04:00, mayer@tecotoo. +5 -0
+  Fix the precompiled header issue
+
+  ports/winnt/libntp/libntp.dsp@1.21, 2004-09-22 00:40:02-04:00, mayer@tecotoo. +1 -1
+    Fix the precompiled header issue
+
+  ports/winnt/ntp-keygen/ntpkeygen.dsp@1.5, 2004-09-22 00:40:03-04:00, mayer@tecotoo. +2 -2
+    Fix the precompiled header issue
+
+  ports/winnt/ntpd/ntpd.dsp@1.22, 2004-09-22 00:40:02-04:00, mayer@tecotoo. +6 -2
+    Fix the precompiled header issue
+
+  ports/winnt/ntpdc/ntpdc.dsp@1.14, 2004-09-22 00:40:03-04:00, mayer@tecotoo. +2 -2
+    Fix the precompiled header issue
+
+  ports/winnt/ntpq/ntpq.dsp@1.14, 2004-09-22 00:40:03-04:00, mayer@tecotoo. +2 -2
+    Fix the precompiled header issue
+
+ChangeSet@1.1202.1.25, 2004-09-16 22:45:42-04:00, stenn@whimsy.udel.edu +1 -0
+  look for recvmsg()
+
+  configure.ac@1.351.1.6, 2004-09-16 22:45:32-04:00, stenn@whimsy.udel.edu +1 -1
+    look for recvmsg()
+
+ChangeSet@1.1202.1.24, 2004-09-13 22:31:34-04:00, stenn@whimsy.udel.edu +1 -0
+  Remove #undef UDP_WILDCARD_DELIVERY per Danny Mayer
+
+  ntpd/ntp_io.c@1.119.1.1, 2004-09-13 22:31:16-04:00, stenn@whimsy.udel.edu +0 -1
+    Remove #undef UDP_WILDCARD_DELIVERY per Danny Mayer
+
+ChangeSet@1.1202.1.23, 2004-09-13 04:09:52-04:00, stenn@whimsy.udel.edu +1 -0
+  Dave Mills: flag3 chooses 1200 or 9600 baud.
+
+  ntpd/refclock_acts.c@1.13, 2004-09-13 04:09:38-04:00, stenn@whimsy.udel.edu +9 -4
+    Dave Mills: flag3 chooses 1200 or 9600 baud.
+
+ChangeSet@1.1202.1.22, 2004-09-12 16:53:03-04:00, stenn@whimsy.udel.edu +5 -0
+  more modem cleanup stuff
+
+  BitKeeper/deleted/.del-refclock_ptbacts.c~3e480692@1.3, 2004-09-12 16:44:28-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: ntpd/refclock_ptbacts.c
+
+  BitKeeper/deleted/.del-refclock_usno.c~3aed0663@1.9, 2004-09-12 16:44:28-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: ntpd/refclock_usno.c
+
+  ntpd/Makefile.am@1.38, 2004-09-12 16:47:56-04:00, stenn@whimsy.udel.edu +2 -2
+    Remove the old ptbs and usno drivers
+
+  ntpd/refclock_acts.c@1.12, 2004-09-12 16:46:44-04:00, stenn@whimsy.udel.edu +23 -34
+    cleanup and fixes from Dave Mills
+
+  ports/winnt/ntpd/ntpd.dsp@1.21, 2004-09-12 16:47:57-04:00, stenn@whimsy.udel.edu +0 -10
+    Remove the old ptbs and usno drivers
+
+ChangeSet@1.1202.2.3, 2004-09-12 01:00:57-04:00, stenn@whimsy.udel.edu +10 -0
+  Changes from Dave Mills.  Combine/simplify the modem driver to
+  handle ACTS, NIST, PTB, and USNO.
+
+  include/ntp.h@1.101.1.2, 2004-09-12 01:00:50-04:00, stenn@whimsy.udel.edu +5 -11
+    Combine the modem refclocks into a single driver.
+    
+    Update the poll randomization stuff.
+
+  include/ntp_refclock.h@1.16, 2004-09-12 01:00:50-04:00, stenn@whimsy.udel.edu +2 -1
+    Added refclock_timer().
+
+  include/ntpd.h@1.67, 2004-09-12 01:00:50-04:00, stenn@whimsy.udel.edu +1 -0
+    added refclock_timeout().
+
+  libntp/clocktypes.c@1.16, 2004-09-12 01:00:51-04:00, stenn@whimsy.udel.edu +6 -6
+    Use the new refclock_acts for NIST, PTB, USNO
+
+  ntpd/ntp_config.c@1.108, 2004-09-12 01:00:51-04:00, stenn@whimsy.udel.edu +2 -1
+    phone numbers now need a \r appended.
+
+  ntpd/ntp_proto.c@1.181.2.1, 2004-09-12 01:00:51-04:00, stenn@whimsy.udel.edu +92 -99
+    Cleanup and fixes.
+
+  ntpd/ntp_refclock.c@1.59, 2004-09-12 01:00:52-04:00, stenn@whimsy.udel.edu +18 -0
+    Added refclock_timer().
+
+  ntpd/ntp_timer.c@1.28, 2004-09-12 01:00:52-04:00, stenn@whimsy.udel.edu +9 -0
+    Call refclock_timer().
+
+  ntpd/refclock_acts.c@1.11, 2004-09-12 01:00:52-04:00, stenn@whimsy.udel.edu +586 -705
+    Handle NIST/USNO/PTB/NPL over a modem.
+
+  ntpd/refclock_conf.c@1.24, 2004-09-12 01:00:52-04:00, stenn@whimsy.udel.edu +3 -15
+    PTB and USNO now use the common ACTS code.
+
+ChangeSet@1.1202.2.2, 2004-09-07 06:41:51-04:00, stenn@whimsy.udel.edu +1 -0
+  Use SNDCTL_DSP_SETFRAGMENT if available.  From Tim Shoppa.
+
+  libntp/audio.c@1.23, 2004-09-07 06:41:36-04:00, stenn@whimsy.udel.edu +9 -0
+    Use SNDCTL_DSP_SETFRAGMENT if available.  From Tim Shoppa.
+
+ChangeSet@1.1202.2.1, 2004-09-03 22:34:20-04:00, stenn@whimsy.udel.edu +1 -0
+  Comment improvement from Dave Mills
+
+  include/ntp.h@1.101.1.1, 2004-09-03 22:33:10-04:00, stenn@whimsy.udel.edu +1 -1
+    Comment improvement from Dave Mills
+
+ChangeSet@1.1202.1.20, 2004-09-03 22:04:08-04:00, mayer@pogo.udel.edu +2 -0
+  INT_MULTICAST now INT_MCASTOPEN
+
+  ntpd/ntp_monitor.c@1.12.1.1, 2004-09-03 22:03:45-04:00, mayer@pogo.udel.edu +1 -1
+    INT_MULTICAST now INT_MCASTOPEN
+
+  ntpd/ntp_proto.c@1.181.1.1, 2004-09-03 22:03:44-04:00, mayer@pogo.udel.edu +2 -2
+    INT_MULTICAST now INT_MCASTOPEN
+
+ChangeSet@1.1233, 2004-09-03 21:56:58-04:00, mayer@tecotoo. +2 -0
+  INT_MULTICAST now INT_MCASTOPEN
+
+  ntpd/ntp_monitor.c@1.13, 2004-09-03 21:56:28-04:00, mayer@tecotoo. +1 -1
+    INT_MULTICAST now INT_MCASTOPEN
+
+  ntpd/ntp_proto.c@1.182, 2004-09-03 21:56:27-04:00, mayer@tecotoo. +2 -2
+    INT_MULTICAST now INT_MCASTOPEN
+
+ChangeSet@1.1202.1.19, 2004-09-02 21:41:05-04:00, stenn@whimsy.udel.edu +1 -0
+  Dave Mills: RSTR kiss+iburst retried too often
+
+  ntpd/ntp_proto.c@1.181, 2004-09-02 21:40:49-04:00, stenn@whimsy.udel.edu +24 -33
+    Dave Mills: RSTR kiss+iburst retried too often
+
+ChangeSet@1.1202.1.18, 2004-08-30 04:27:54-04:00, stenn@www.ntp.org +1 -0
+  [Bug 153] Initial pass at framework to fix bug
+
+  ntpd/ntp_config.c@1.107, 2004-08-30 04:27:40-04:00, stenn@www.ntp.org +19 -9
+    [Bug 153] Initial pass at framework to fix bug
+
+ChangeSet@1.1202.1.17, 2004-08-25 21:27:18-04:00, stenn@www.ntp.org +1 -0
+  avoid overwriting self
+
+  util/ntp-keygen.c@1.30, 2004-08-25 21:27:06-04:00, stenn@www.ntp.org +5 -1
+    avoid overwriting self
+
+ChangeSet@1.1202.1.16, 2004-08-25 01:16:52-04:00, stenn@whimsy.udel.edu +4 -0
+  added sntp.1 and did a little cleanup
+
+  sntp/Makefile.am@1.4, 2004-08-25 01:16:12-04:00, stenn@whimsy.udel.edu +5 -1
+    added sntp.1 and did a little cleanup
+
+  sntp/header.h@1.5, 2004-08-25 01:16:12-04:00, stenn@whimsy.udel.edu +2 -2
+    added sntp.1 and did a little cleanup
+
+  sntp/main.c@1.4, 2004-08-25 01:16:11-04:00, stenn@whimsy.udel.edu +8 -8
+    added sntp.1 and did a little cleanup
+
+  sntp/sntp.1@1.3, 2004-08-25 01:16:12-04:00, stenn@whimsy.udel.edu +25 -15
+    added sntp.1 and did a little cleanup
+
+  sntp/sntp.1@1.2, 2004-08-25 00:51:55-04:00, stenn@whimsy.udel.edu +0 -0
+    Rename: sntp/msntp.1 -> sntp/sntp.1
+
+  sntp/msntp.1@1.1, 2004-08-25 00:46:59-04:00, stenn@whimsy.udel.edu +325 -0
+
+  sntp/msntp.1@1.0, 2004-08-25 00:46:59-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/sntp/msntp.1
+
+ChangeSet@1.1202.1.15, 2004-08-23 22:08:55-04:00, stenn@www.ntp.org +2 -0
+  make propdelay compile/link
+
+  clockstuff/Makefile.am@1.4, 2004-08-23 22:08:44-04:00, stenn@www.ntp.org +1 -1
+    make propdelay compile/link
+
+  clockstuff/propdelay.c@1.4, 2004-08-23 22:08:44-04:00, stenn@www.ntp.org +6 -6
+    make propdelay compile/link
+
+ChangeSet@1.1202.1.14, 2004-08-19 23:22:20-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 300] Properly report V3 reslist bits
+
+  ntpdc/ntpdc_ops.c@1.34.1.1, 2004-08-19 23:22:06-04:00, stenn@whimsy.udel.edu +25 -7
+    [Bug 300] Properly report V3 reslist bits
+
+ChangeSet@1.1202.1.13, 2004-08-19 23:15:44-04:00, stenn@whimsy.udel.edu +1 -0
+  typo fix
+
+  ntpd/ntp_loopfilter.c@1.96, 2004-08-19 23:15:26-04:00, stenn@whimsy.udel.edu +1 -1
+    typo fix
+
+ChangeSet@1.1229, 2004-08-19 18:34:48-04:00, mayer@pogo.udel.edu +1 -0
+  Change debug level of interrupted select to 5
+
+  ntpd/ntpd.c@1.56, 2004-08-19 18:34:22-04:00, mayer@pogo.udel.edu +3 -3
+    Change debug level of interrupted select to 5
+
+ChangeSet@1.1228, 2004-08-19 18:33:09-04:00, mayer@pogo.udel.edu +1 -0
+  Fixed IPv6 multicast to use correct scope for interface
+
+  ntpd/ntp_io.c@1.138, 2004-08-19 18:32:26-04:00, mayer@pogo.udel.edu +24 -12
+    Fixed IPv6 multicast to use correct scope for interface
+
+ChangeSet@1.1227, 2004-08-16 19:31:28-04:00, mayer@pogo.udel.edu +1 -0
+  Miscellaneous fixes for sitelocal and linklocal IPv6 addresses
+
+  ntpd/ntp_io.c@1.137, 2004-08-16 19:30:48-04:00, mayer@pogo.udel.edu +23 -6
+    Miscellaneous fixes for sitelocal and linklocal IPv6 addresses
+
+ChangeSet@1.1226, 2004-08-15 23:32:21-04:00, mayer@tecotoo. +1 -0
+  Typo, should have checked for INT_MULTICAST instead of INT_BROADCAST
+
+  ntpd/ntp_io.c@1.136, 2004-08-15 23:31:48-04:00, mayer@tecotoo. +1 -1
+    Typo should have checked for INT_MULTICAST instead of INT_BROADCAST
+
+ChangeSet@1.1225, 2004-08-15 23:16:22-04:00, mayer@tecotoo. +1 -0
+  In IPv6 when looking for a multicast address check if the remote address is multicast
+
+  ntpd/ntp_io.c@1.135, 2004-08-15 23:15:56-04:00, mayer@tecotoo. +21 -2
+    In IPv6 when looking for a multicast address check if the remote address is multicast
+
+ChangeSet@1.1224, 2004-08-15 21:45:50-04:00, mayer@tecotoo. +1 -0
+  Added more detailed debug print statements
+
+  ntpd/ntp_io.c@1.134, 2004-08-15 21:45:25-04:00, mayer@tecotoo. +18 -18
+    Added more detailed debug print statements
+
+ChangeSet@1.1223, 2004-08-15 12:14:57-04:00, mayer@tecotoo. +1 -0
+  rewrote adding multicast client and added find_interface_index
+
+  ntpd/ntp_io.c@1.133, 2004-08-15 12:14:33-04:00, mayer@tecotoo. +44 -54
+    rewrote adding multicast client and added find_interface_index
+
+ChangeSet@1.1222, 2004-08-15 01:34:53-04:00, mayer@tecotoo. +1 -0
+  Use Id of the interface when printing join multicast group failures
+
+  ntpd/ntp_io.c@1.132, 2004-08-15 01:34:33-04:00, mayer@tecotoo. +3 -3
+    Use Id of the interface when printing join multicast group failures
+
+ChangeSet@1.1221, 2004-08-15 01:20:41-04:00, mayer@tecotoo. +1 -0
+  Added debug print statements
+
+  ntpd/ntp_io.c@1.131, 2004-08-15 01:20:19-04:00, mayer@tecotoo. +12 -6
+    Added debug print statements
+
+ChangeSet@1.1220, 2004-08-14 23:33:00-04:00, mayer@tecotoo. +2 -0
+  Redid findinterface and findbcastinter to properly find appropriate interface and use the family member from the interface struct
+
+  include/ntp.h@1.102, 2004-08-14 23:30:57-04:00, mayer@tecotoo. +14 -13
+    Added family to interface struct
+
+  ntpd/ntp_io.c@1.130, 2004-08-14 23:32:23-04:00, mayer@tecotoo. +86 -97
+    Redid findinterface and findbcastinter to properly find appropriate interface and use the family member from the interface struct
+
+ChangeSet@1.1202.1.12, 2004-08-13 05:48:21-04:00, stenn@pogo.udel.edu +1 -0
+  [Bug 301] ntp-keygen has no usage statement
+
+  util/ntp-keygen.c@1.29, 2004-08-13 05:47:54-04:00, stenn@pogo.udel.edu +44 -4
+    [Bug 301] ntp-keygen has no usage statement
+
+ChangeSet@1.1218, 2004-08-12 16:54:31-04:00, mayer@pogo.udel.edu +1 -0
+  findbcastinter needs to find a proper broadcast interface
+
+  ntpd/ntp_io.c@1.129, 2004-08-12 16:52:29-04:00, mayer@pogo.udel.edu +236 -5
+    findbcastinter needs to find a proper broadcast interface
+
+ChangeSet@1.1202.1.11, 2004-08-12 05:12:15-04:00, stenn@whimsy.udel.edu +1 -0
+  Use AC_HELP_STRING in configure.ac
+
+  configure.ac@1.351.1.5, 2004-08-12 05:12:06-04:00, stenn@whimsy.udel.edu +35 -20
+    Use AC_HELP_STRING in configure.ac
+
+ChangeSet@1.1217, 2004-08-11 23:06:43-04:00, mayer@tecotoo. +1 -0
+  Added files for inet_*ton functions
+
+  ports/winnt/libntp/libntp.dsp@1.20, 2004-08-11 23:06:27-04:00, mayer@tecotoo. +4 -0
+    Added files for inet_*ton functions
+
+ChangeSet@1.1202.1.10, 2004-08-11 22:28:30-04:00, stenn@whimsy.udel.edu +3 -0
+  FreeBSD lint
+
+  Makefile.am@1.48, 2004-08-11 22:28:10-04:00, stenn@whimsy.udel.edu +5 -5
+    FreeBSD lint
+
+  ntpdc/ntpdc.c@1.34, 2004-08-11 22:28:11-04:00, stenn@whimsy.udel.edu +5 -1
+    FreeBSD lint
+
+  ntpq/ntpq.c@1.49, 2004-08-11 22:28:11-04:00, stenn@whimsy.udel.edu +5 -1
+    FreeBSD lint
+
+ChangeSet@1.1216, 2004-08-11 18:04:11-04:00, mayer@pogo.udel.edu +1 -0
+  interfaces are not TCP-specific
+
+  ports/winnt/libisc/interfaceiter.c@1.4.1.1, 2004-08-11 18:03:09-04:00, mayer@pogo.udel.edu +1 -1
+    interfaces are not TCP-specific
+
+ChangeSet@1.1202.1.9, 2004-08-11 18:00:52-04:00, mayer@pogo.udel.edu +1 -0
+  interfaces are not TCP-specific
+
+  ports/winnt/libisc/interfaceiter.c@1.5, 2004-08-11 18:00:16-04:00, mayer@pogo.udel.edu +1 -1
+    interfaces are not TCP-specific
+
+ChangeSet@1.1202.1.8, 2004-08-10 19:36:31-04:00, mayer@pogo.udel.edu +1 -0
+  Fix to emit error strings when getting errors from system
+
+  ports/winnt/ntpd/win32_io.c@1.7.1.1, 2004-08-10 19:36:17-04:00, mayer@pogo.udel.edu +8 -8
+    Fix to emit error strings when getting errors from system
+
+ChangeSet@1.1214, 2004-08-10 19:25:24-04:00, mayer@pogo.udel.edu +1 -0
+  Fix to emit error strings when getting errors from system
+
+  ports/winnt/ntpd/win32_io.c@1.8, 2004-08-10 19:24:38-04:00, mayer@pogo.udel.edu +8 -8
+    Fix to emit error strings when getting errors from system
+
+ChangeSet@1.1202.1.7, 2004-08-10 01:24:58-04:00, stenn@www.ntp.org +1 -0
+  [Bug 208] Use -R in LDFLAGS when needed.  (some other cleanup, too)
+
+  configure.ac@1.351.1.4, 2004-08-10 01:24:48-04:00, stenn@www.ntp.org +34 -12
+    [Bug 208] Use -R in LDFLAGS when needed.  (some other cleanup, too)
+
+ChangeSet@1.1202.1.6, 2004-08-09 05:39:43-05:00, stenn@poog.il.thewrittenword.com +1 -0
+  OSF needs sys/time.h to test for sys/timex.h
+
+  configure.ac@1.351.1.3, 2004-08-09 05:39:22-05:00, stenn@poog.il.thewrittenword.com +7 -1
+    OSF needs sys/time.h to test for sys/timex.h
+
+ChangeSet@1.1202.1.5, 2004-08-09 05:38:32-05:00, stenn@poog.il.thewrittenword.com +2 -0
+  OSF cflags cleanup
+
+  BitKeeper/etc/logging_ok@1.50, 2004-08-09 05:38:31-05:00, stenn@poog.il.thewrittenword.com +1 -0
+    Logging to logging@openlogging.org accepted
+
+  m4/os_cflags.m4@1.2, 2004-08-09 05:38:03-05:00, stenn@poog.il.thewrittenword.com +23 -22
+    OSF cflags cleanup
+
+ChangeSet@1.1202.1.4, 2004-08-07 07:22:03-04:00, stenn@whimsy.udel.edu +6 -0
+  [Bug 166] Clean up Irix compile/link flags for 32/64 bits
+
+  BitKeeper/deleted/.del-acinclude.m4~457f12ef@1.13, 2004-08-07 06:27:18-04:00, stenn@whimsy.udel.edu +0 -0
+    Delete: acinclude.m4
+
+  Makefile.am@1.47, 2004-08-07 07:20:57-04:00, stenn@whimsy.udel.edu +5 -2
+    [Bug 166] Clean up Irix compile/link flags for 32/64 bits
+
+  configure.ac@1.351.1.2, 2004-08-07 07:20:58-04:00, stenn@whimsy.udel.edu +1 -19
+    [Bug 166] Clean up Irix compile/link flags for 32/64 bits
+
+  configure.ac@1.351.1.1, 2004-08-07 05:41:16-04:00, stenn@whimsy.udel.edu +0 -0
+    Rename: configure.in -> configure.ac
+
+  m4/define_dir.m4@1.1, 2004-08-07 06:28:00-04:00, stenn@whimsy.udel.edu +26 -0
+
+  m4/define_dir.m4@1.0, 2004-08-07 06:28:00-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/m4/define_dir.m4
+
+  m4/hs_ulong_const.m4@1.1, 2004-08-07 06:28:00-04:00, stenn@whimsy.udel.edu +11 -0
+
+  m4/hs_ulong_const.m4@1.0, 2004-08-07 06:28:00-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/m4/hs_ulong_const.m4
+
+  m4/os_cflags.m4@1.1, 2004-08-07 06:28:00-04:00, stenn@whimsy.udel.edu +86 -0
+
+  m4/os_cflags.m4@1.0, 2004-08-07 06:28:00-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev-hms/m4/os_cflags.m4
+
+ChangeSet@1.1202.1.3, 2004-08-06 03:42:21-04:00, stenn@www.ntp.org +2 -0
+  [Bug 321] Fix some alpha alignment issues and avoid a possibile DOS
+
+  BitKeeper/etc/logging_ok@1.49, 2004-08-06 03:42:20-04:00, stenn@www.ntp.org +1 -0
+    Logging to logging@openlogging.org accepted
+
+  ntpd/ntp_control.c@1.70.1.1, 2004-08-06 03:42:03-04:00, stenn@www.ntp.org +7 -4
+    [Bug 321] Fix some alpha alignment issues and avoid a possibile DOS
+
+ChangeSet@1.1202.1.2, 2004-08-05 23:40:16-04:00, stenn@whimsy.udel.edu +1 -0
+  No more autokey/rsa for mkver, just openssl now.
+
+  scripts/mkver.in@1.11, 2004-08-05 23:40:02-04:00, stenn@whimsy.udel.edu +5 -8
+    No more autokey/rsa for mkver, just openssl now.
+
+ChangeSet@1.1202.1.1, 2004-08-05 23:33:23-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 326] handle MAXTOKEN overflow better.
+
+  ntpd/ntp_config.c@1.106, 2004-08-05 23:33:09-04:00, stenn@whimsy.udel.edu +27 -10
+    [Bug 326] handle MAXTOKEN overflow better.
+
+ChangeSet@1.1212, 2004-08-05 00:14:18-04:00, mayer@tecotoo. +1 -0
+  Look for PPP for interface to the outside
+
+  ntpd/ntp_io.c@1.128, 2004-08-05 00:13:51-04:00, mayer@tecotoo. +18 -0
+    Look for PPP for interface to the outside
+
+ChangeSet@1.1211, 2004-08-04 18:41:17-04:00, mayer@pogo.udel.edu +1 -0
+  Fix cast in ntohl
+
+  ntpdc/ntpdc_ops.c@1.35, 2004-08-04 18:35:01-04:00, mayer@pogo.udel.edu +23 -23
+    Fix cast in ntohl
+
+ChangeSet@1.1210, 2004-08-04 18:10:22-04:00, mayer@pogo.udel.edu +2 -0
+  Fixes for scope ID
+
+  libisc/interfaceiter.c@1.11, 2004-08-04 18:09:36-04:00, mayer@pogo.udel.edu +6 -1
+    Fixes for scope ID
+
+  ntpd/ntp_io.c@1.127, 2004-08-04 18:09:36-04:00, mayer@pogo.udel.edu +3 -2
+    Fixes for scope ID
+
+ChangeSet@1.1209, 2004-08-04 02:28:09-04:00, mayer@tecotoo. +1 -0
+  Fix setting of only interface code
+
+  ntpd/ntp_io.c@1.126, 2004-08-04 02:27:41-04:00, mayer@tecotoo. +2 -2
+    Fix setting of only interface code
+
+ChangeSet@1.1208, 2004-08-03 18:39:54-04:00, mayer@pogo.udel.edu +2 -0
+  Linklocal and sitelocal IPv6 changes
+
+  include/ntp_rfc2553.h@1.26, 2004-08-03 18:38:57-04:00, mayer@pogo.udel.edu +14 -0
+    Add link-local and site-local IPv6 macros
+
+  ntpd/ntp_io.c@1.125, 2004-08-03 18:38:07-04:00, mayer@pogo.udel.edu +18 -0
+    Add check for link-local and site-local for IPv6 addresses when looking for interfaces
+
+ChangeSet@1.1207, 2004-08-02 22:36:39-04:00, mayer@tecotoo. +1 -0
+  findbcastinter should look for INT_BROADCAST flag
+
+  ntpd/ntp_io.c@1.124, 2004-08-02 22:36:20-04:00, mayer@tecotoo. +1 -1
+    findbcastinter should look for INT_BROADCAST flag
+
+ChangeSet@1.1206, 2004-08-02 22:19:13-04:00, mayer@tecotoo. +3 -0
+  findinterface cleanup and IPv4/IPv6 fixes
+
+  configure.in@1.352, 2004-08-02 22:15:55-04:00, mayer@tecotoo. +2 -0
+    Add check for inet_pton and inet_aton
+
+  libntp/ntp_rfc2553.c@1.20, 2004-08-02 22:16:44-04:00, mayer@tecotoo. +8 -2
+    fix port assignment
+
+  ntpd/ntp_io.c@1.123, 2004-08-02 22:18:20-04:00, mayer@tecotoo. +1 -2
+    Ongoing findinterface cleanup
+
+ChangeSet@1.1205, 2004-08-02 20:44:31-04:00, mayer@pogo.udel.edu +5 -0
+  Changes for proper IPv4 and IPv6 support
+
+  libisc/inet_aton.c@1.2, 2004-08-02 17:25:20-04:00, mayer@pogo.udel.edu +0 -3
+    Remove temporary changes to support Winnt
+
+  libntp/Makefile.am@1.30, 2004-08-02 18:27:20-04:00, mayer@pogo.udel.edu +3 -1
+    Added inet_pton and inet_aton to libisc
+
+  libntp/ntp_rfc2553.c@1.19, 2004-08-02 17:58:55-04:00, mayer@pogo.udel.edu +2 -2
+    Reorder the includes to prevent warnings
+
+  libntp/ntp_rfc2553.c@1.18, 2004-08-02 17:28:33-04:00, mayer@pogo.udel.edu +20 -15
+    Change to use inet_pton and cleanly support at least IPv6 addresses
+
+  ntpd/ntp_io.c@1.122, 2004-08-02 17:29:31-04:00, mayer@pogo.udel.edu +2 -15
+    changes to find the right local interface for outgoing packets
+
+  ports/winnt/include/config.h@1.28, 2004-08-02 17:23:51-04:00, mayer@pogo.udel.edu +1 -0
+    Added isascii, required for inet_aton
+
+ChangeSet@1.1204, 2004-08-02 00:35:56-04:00, mayer@tecotoo. +7 -0
+  Updates to support finding interfaces and address lookups
+
+  libisc/inet_aton.c@1.1, 2004-08-02 00:35:48-04:00, mayer@tecotoo. +198 -0
+
+  libisc/inet_aton.c@1.0, 2004-08-02 00:35:48-04:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/libisc/inet_aton.c
+
+  libisc/inet_pton.c@1.1, 2004-08-02 00:35:49-04:00, mayer@tecotoo. +211 -0
+
+  libisc/inet_pton.c@1.0, 2004-08-02 00:35:49-04:00, mayer@tecotoo. +0 -0
+    BitKeeper file H:/ntpbk/ntp-dev/libisc/inet_pton.c
+
+  libntp/ntp_rfc2553.c@1.17, 2004-08-02 00:35:44-04:00, mayer@tecotoo. +15 -74
+    fix the code to properly handle addresses.
+
+  ntpd/ntp_control.c@1.71, 2004-08-02 00:35:45-04:00, mayer@tecotoo. +0 -1
+    no change
+
+  ntpd/ntp_io.c@1.121, 2004-08-02 00:35:46-04:00, mayer@tecotoo. +82 -3
+    changes to properly find outgoing interfaces
+
+  ports/winnt/include/config.h@1.27, 2004-08-02 00:35:47-04:00, mayer@tecotoo. +1 -0
+    Need inet_pton
+
+  ports/winnt/libntp/libntp.dsp@1.19, 2004-08-02 00:35:47-04:00, mayer@tecotoo. +8 -0
+    Add inet_pton and inet_aton
+
+ChangeSet@1.1203, 2004-07-28 23:44:06-04:00, mayer@tecotoo. +1 -0
+  clean up finding addresses and interfaces
+
+  ntpd/ntp_io.c@1.120, 2004-07-28 23:43:44-04:00, mayer@tecotoo. +37 -50
+    clean up finding addresses and interfaces
+
+ChangeSet@1.1202, 2004-07-27 19:24:53-04:00, mayer@pogo.udel.edu +1 -0
+  Changes for conditional support of broadcast and multicast on some platforms
+
+  ntpd/ntp_io.c@1.119, 2004-07-27 19:24:10-04:00, mayer@pogo.udel.edu +3 -2
+    Changes for conditional support of broadcast and multicast on some platforms
+
+ChangeSet@1.1201, 2004-07-26 23:12:26-04:00, mayer@tecotoo. +1 -0
+  Code cleanup and simplification
+
+  ntpd/ntp_io.c@1.118, 2004-07-26 23:11:58-04:00, mayer@tecotoo. +104 -101
+    Code cleanup and simplification
+
+ChangeSet@1.1200, 2004-07-26 10:18:16-04:00, mayer@pogo.udel.edu +1 -0
+  Not all O/S's support broadcast. Conditionally build the socket_broadcast_* code
+
+  ntpd/ntp_io.c@1.117, 2004-07-26 10:17:29-04:00, mayer@pogo.udel.edu +6 -4
+    Not all O/S's support broadcast. Conditionally build the socket_broadcast_* code
+
+ChangeSet@1.1199, 2004-07-25 23:28:14-04:00, mayer@tecotoo. +1 -0
+  Not all platforms support Multicast
+
+  ntpd/ntp_io.c@1.116, 2004-07-25 23:27:58-04:00, mayer@tecotoo. +6 -0
+    Not all platforms support Multicast
+
+ChangeSet@1.1198, 2004-07-25 23:07:04-04:00, mayer@tecotoo. +1 -0
+  Minor bugs in IPv6 codes. Remove unused variables
+
+  ntpd/ntp_io.c@1.115, 2004-07-25 23:06:44-04:00, mayer@tecotoo. +3 -6
+    Minor bugs in IPv6 codes. Remove unused variables
+
+ChangeSet@1.1197, 2004-07-25 22:44:57-04:00, mayer@tecotoo. +1 -0
+  Rewrite multicast and broadcast routines to remove wildcard requirements, improve flexibility and general code improvements
+
+  ntpd/ntp_io.c@1.114, 2004-07-25 22:44:21-04:00, mayer@tecotoo. +328 -245
+    Rewrite multicast and broadcast routines to remove wildcard requirements, improve flexibility and general code improvements
+
+ChangeSet@1.1192.1.2, 2004-07-22 00:20:36-04:00, mayer@tecotoo. +1 -0
+  If we can't figure out the address type assume it's IPv4
+
+  libntp/socktoa.c@1.7, 2004-07-22 00:20:18-04:00, mayer@tecotoo. +3 -0
+    If we can't figure out the address type assume it's IPv4
+
+ChangeSet@1.1189.1.2, 2004-07-22 00:11:05-04:00, mayer@tecotoo. +1 -0
+  For Multicast make sure socket can handle multicast
+
+  ntpd/ntp_io.c@1.113, 2004-07-22 00:10:36-04:00, mayer@tecotoo. +16 -10
+    For Multicast make sure socket can handle multicast
+
+ChangeSet@1.1195, 2004-07-20 02:42:59-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 307] Typo fix from Volkmar Grote
+
+  html/monopt.html@1.19, 2004-07-20 02:42:38-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 307] Typo fix from Volkmar Grote
+
+ChangeSet@1.1194, 2004-07-20 02:26:12-04:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 233] Apply rest of patch from Matthias Drochner
+
+  ntpd/refclock_shm.c@1.16, 2004-07-20 02:25:58-04:00, stenn@whimsy.udel.edu +4 -1
+    [Bug 233] Apply rest of patch from Matthias Drochner
+
+  ntpdc/ntpdc_ops.c@1.34, 2004-07-20 02:25:58-04:00, stenn@whimsy.udel.edu +5 -5
+    [Bug 233] Apply rest of patch from Matthias Drochner
+
+ChangeSet@1.1193, 2004-07-16 01:20:38-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 315] Provide prereq headers for configure.in
+
+  configure.in@1.351, 2004-07-16 01:20:22-04:00, stenn@whimsy.udel.edu +28 -2
+    [Bug 315] Provide prereq headers for configure.in
+
+ChangeSet@1.1189.1.1, 2004-07-12 21:57:57-04:00, mayer@tecotoo. +1 -0
+  IPv6 addresses caused the resultant refid to get it's values swapped on some machines
+
+  libntp/a_md5encrypt.c@1.18, 2004-07-12 21:57:30-04:00, mayer@tecotoo. +1 -1
+    IPv6 addresses caused the resultant refid to get it's values swapped on some machines
+
+ChangeSet@1.1191, 2004-07-12 19:36:51-04:00, stenn@whimsy.udel.edu +1 -0
+  Use UTC for the date in the version string for mkver.in
+
+  scripts/mkver.in@1.10, 2004-07-12 19:36:32-04:00, stenn@whimsy.udel.edu +1 -1
+    Use UTC for the date in the version string
+
+ChangeSet@1.1178.1.13, 2004-07-07 00:52:39-04:00, stenn@whimsy.udel.edu +1 -0
+  Fix from Dave Mills
+
+  libntp/systime.c@1.31, 2004-07-07 00:52:22-04:00, stenn@whimsy.udel.edu +2 -7
+    Fix from Dave Mills
+
+ChangeSet@1.1189, 2004-07-05 23:36:39-04:00, mayer@tecotoo. +3 -0
+  Multicast modifications and extraneous macro definition removal
+
+  include/ntp.h@1.101, 2004-07-05 23:36:31-04:00, mayer@tecotoo. +2 -1
+    Flags change to differentiate between mulitcast capable and multicast in use
+
+  ntpd/ntp_io.c@1.112, 2004-07-05 23:36:32-04:00, mayer@tecotoo. +8 -6
+    Add multicast capable flags when available.
+    Change multicast flag to show socket is being used for multicast
+
+  ntpd/ntpd.c@1.55, 2004-07-05 23:36:33-04:00, mayer@tecotoo. +2 -4
+    Remove unnecessary macro condition
+
+ChangeSet@1.1188, 2004-07-03 18:30:24-04:00, mayer@tecotoo. +2 -0
+  include updates for winnt
+
+  ports/winnt/libntp/libntp.dsp@1.18, 2004-07-03 18:08:42-04:00, mayer@tecotoo. +4 -0
+    Added ntp_rfc2553.h to list of includes
+
+  ports/winnt/ntpd/ntpd.dsp@1.20, 2004-07-03 18:08:42-04:00, mayer@tecotoo. +0 -4
+    map_vme.c not used.
+
+ChangeSet@1.1187, 2004-07-03 17:54:02-04:00, mayer@tecotoo. +1 -0
+  Removed unreachable code
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.12, 2004-07-03 17:53:47-04:00, mayer@tecotoo. +0 -1
+    Removed unreachable code
+
+ChangeSet@1.1186, 2004-07-03 17:52:50-04:00, mayer@tecotoo. +1 -0
+  #endif was in wrong place
+
+  ntpd/ntp_proto.c@1.180, 2004-07-03 17:52:29-04:00, mayer@tecotoo. +1 -1
+    #endif was in wrong place
+
+ChangeSet@1.1183, 2004-07-03 16:56:20-04:00, mayer@tecotoo. +1 -0
+  handle empty sockets and unknown address family
+
+  libntp/socktoa.c@1.6, 2004-07-03 16:55:09-04:00, mayer@tecotoo. +8 -2
+    handle empty sockets and unknown address family
+
+ChangeSet@1.1178.1.12, 2004-05-06 01:39:49-04:00, stenn@whimsy.udel.edu +5 -0
+  Cleanup from Dave Mills
+
+  html/drivers/driver36.html@1.23, 2004-05-06 01:39:06-04:00, stenn@whimsy.udel.edu +0 -2
+    Cleanup from Dave Mills
+
+  html/drivers/driver6.html@1.18, 2004-05-06 01:39:06-04:00, stenn@whimsy.udel.edu +0 -2
+    Cleanup from Dave Mills
+
+  html/drivers/driver7.html@1.21, 2004-05-06 01:39:07-04:00, stenn@whimsy.udel.edu +0 -2
+    Cleanup from Dave Mills
+
+  html/drivers/scripts/footer.txt@1.1, 2004-05-06 01:37:41-04:00, stenn@whimsy.udel.edu +7 -0
+
+  html/drivers/scripts/footer.txt@1.0, 2004-05-06 01:37:41-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/drivers/scripts/footer.txt
+
+  html/drivers/scripts/style.css@1.1, 2004-05-06 01:37:41-04:00, stenn@whimsy.udel.edu +64 -0
+
+  html/drivers/scripts/style.css@1.0, 2004-05-06 01:37:41-04:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/drivers/scripts/style.css
+
+ChangeSet@1.1178.1.11, 2004-05-04 03:43:00-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 305] More lint
+
+  ntpd/ntp_refclock.c@1.58, 2004-05-04 03:42:37-04:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 305] More lint
+
+ChangeSet@1.1178.3.1, 2004-05-04 01:01:59-04:00, stenn@whimsy.udel.edu +3 -0
+  Cleanup/fixes from Dave Mills.
+
+  include/ntpd.h@1.66, 2004-05-04 01:01:25-04:00, stenn@whimsy.udel.edu +1 -0
+    Cleanup/fixes from Dave Mills.
+
+  ntpd/ntp_filegen.c@1.9, 2004-05-04 01:01:25-04:00, stenn@whimsy.udel.edu +5 -0
+    Cleanup/fixes from Dave Mills.
+
+  ntpd/ntp_loopfilter.c@1.95, 2004-05-04 01:01:32-04:00, stenn@whimsy.udel.edu +5 -3
+    Cleanup/fixes from Dave Mills.
+
+ChangeSet@1.1181, 2004-04-25 10:35:51-04:00, mayer@tecotoo. +1 -0
+  Bug fix
+
+  ports/winnt/include/config.h@1.24.1.1, 2004-04-25 10:35:16-04:00, mayer@tecotoo. +1 -1
+
+ChangeSet@1.1178.1.8, 2004-04-23 19:23:39-04:00, mayer@pogo.udel.edu +3 -0
+  Modification to correct for type errors
+
+  include/ntp_rfc2553.h@1.25, 2004-04-23 19:21:15-04:00, mayer@pogo.udel.edu +16 -16
+    Move u_int*_t types to ntp_* to avoid conflicts
+
+  include/ntp_types.h@1.8, 2004-04-23 19:21:15-04:00, mayer@pogo.udel.edu +3 -5
+    Move u_int*_t types to ntp_* to avoid conflicts
+
+  ntpd/ntp_io.c@1.110, 2004-04-23 19:22:36-04:00, mayer@pogo.udel.edu +4 -0
+    Modified to add hex value of network address to output for Multicast errors
+
+ChangeSet@1.1178.2.3, 2004-04-19 20:20:20-04:00, stenn@whimsy.udel.edu +1 -0
+  manycast poll bugfix from Dave Mills.
+
+  ntpd/ntp_proto.c@1.178, 2004-04-19 20:19:55-04:00, stenn@whimsy.udel.edu +1 -1
+    manycast poll bugfix from Dave Mills.
+
+ChangeSet@1.1178.2.2, 2004-04-17 17:33:32-04:00, stenn@pogo.udel.edu +1 -0
+  Always see if we need in6addr_any
+
+  configure.in@1.350, 2004-04-17 17:33:17-04:00, stenn@pogo.udel.edu +6 -5
+    Always see if we need in6addr_any
+
+ChangeSet@1.1178.2.1, 2004-04-17 17:32:38-04:00, stenn@pogo.udel.edu +1 -0
+  Added cowbird to the flock-build
+
+  flock-build@1.30, 2004-04-17 17:32:22-04:00, stenn@pogo.udel.edu +1 -1
+    Added cowbird to the flock-build
+
+ChangeSet@1.1178.1.5, 2004-04-16 20:42:21-04:00, mayer@pogo.udel.edu +2 -0
+  Fix for AIX to initialize in6addr_any
+
+  libntp/ntp_rfc2553.c@1.16, 2004-04-16 20:40:05-04:00, mayer@pogo.udel.edu +4 -1
+    Fix for AIX to initialize in6addr_any
+
+  ports/winnt/include/config.h@1.25, 2004-04-16 20:41:27-04:00, mayer@pogo.udel.edu +2 -0
+    Fix for AIX to initialize in6addr_any
+
+ChangeSet@1.1152.34.1, 2004-04-11 18:53:56+01:00, mbrett@rgs16.fordson.demon.co.uk +7 -0
+  Many files:
+    Changes for type-paranoid MIPSpro compiler.
+
+  ntpd/ntp_config.c@1.100.1.1, 2004-04-11 18:52:24+01:00, mbrett@rgs16.fordson.demon.co.uk +1 -1
+    Changes for type-paranoid MIPSpro compiler.
+
+  ntpd/ntp_intres.c@1.32.1.1, 2004-04-11 18:52:33+01:00, mbrett@rgs16.fordson.demon.co.uk +1 -1
+    Changes for type-paranoid MIPSpro compiler.
+
+  ntpd/ntp_io.c@1.105.2.1, 2004-04-11 18:52:36+01:00, mbrett@rgs16.fordson.demon.co.uk +4 -4
+    Changes for type-paranoid MIPSpro compiler.
+
+  ntpd/ntp_proto.c@1.172.1.1, 2004-04-11 18:52:40+01:00, mbrett@rgs16.fordson.demon.co.uk +3 -3
+    Changes for type-paranoid MIPSpro compiler.
+
+  ntpdc/ntpdc_ops.c@1.29.1.1, 2004-04-11 18:51:44+01:00, mbrett@rgs16.fordson.demon.co.uk +17 -17
+    Changes for type-paranoid MIPSpro compiler.
+
+  ntpq/ntpq.c@1.45.1.1, 2004-04-11 18:52:43+01:00, mbrett@rgs16.fordson.demon.co.uk +2 -2
+    Changes for type-paranoid MIPSpro compiler.
+
+  ntpq/ntpq_ops.c@1.20, 2004-04-11 18:52:47+01:00, mbrett@rgs16.fordson.demon.co.uk +1 -1
+    Changes for type-paranoid MIPSpro compiler.
+
+ChangeSet@1.1178.1.4, 2004-04-07 20:45:38-04:00, stenn@whimsy.udel.edu +1 -0
+  refclock_oncore.c cleanup from Reg Clemens
+
+  ntpd/refclock_oncore.c@1.51, 2004-04-07 20:45:29-04:00, stenn@whimsy.udel.edu +0 -11
+    refclock_oncore.c cleanup from Reg Clemens
+
+ChangeSet@1.1177.1.5, 2004-04-07 20:38:47-04:00, stenn@whimsy.udel.edu +8 -0
+  Cleanup from Dave Mills
+
+  include/ntp.h@1.100, 2004-04-07 20:38:35-04:00, stenn@whimsy.udel.edu +2 -0
+    Cleanup from Dave Mills
+
+  include/ntp_control.h@1.25, 2004-04-07 20:38:36-04:00, stenn@whimsy.udel.edu +7 -6
+    Cleanup from Dave Mills
+
+  include/ntp_crypto.h@1.34, 2004-04-07 20:38:36-04:00, stenn@whimsy.udel.edu +2 -3
+    Cleanup from Dave Mills
+
+  ntpd/ntp_control.c@1.70, 2004-04-07 20:38:36-04:00, stenn@whimsy.udel.edu +20 -10
+    Cleanup from Dave Mills
+
+  ntpd/ntp_crypto.c@1.93, 2004-04-07 20:38:36-04:00, stenn@whimsy.udel.edu +21 -18
+    Cleanup from Dave Mills
+
+  ntpd/ntp_proto.c@1.177, 2004-04-07 20:38:37-04:00, stenn@whimsy.udel.edu +9 -5
+    Cleanup from Dave Mills
+
+  ntpd/refclock_chu.c@1.35, 2004-04-07 20:38:37-04:00, stenn@whimsy.udel.edu +1 -1
+    Cleanup from Dave Mills
+
+  ntpq/ntpq.c@1.47, 2004-04-07 20:38:37-04:00, stenn@whimsy.udel.edu +1 -1
+    Cleanup from Dave Mills
+
+ChangeSet@1.1178.1.1, 2004-04-07 16:48:52-04:00, mayer@pogo.udel.edu +1 -0
+  Fix for Windows select timeout
+
+  ntpdate/ntpdate.c@1.47, 2004-04-07 16:48:07-04:00, mayer@pogo.udel.edu +17 -0
+    Fix for Windows select timeout
+
+ChangeSet@1.1177.1.4, 2004-04-07 15:48:32-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 275] Expose needed glue in ntp-keygen
+
+  util/ntp-keygen.c@1.28, 2004-04-07 15:48:18-04:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 275] Expose needed glue in ntp-keygen
+
+ChangeSet@1.1177.1.3, 2004-04-06 00:56:17-04:00, stenn@whimsy.udel.edu +1 -0
+  cleanup
+
+  include/timepps-Solaris.h@1.4, 2004-04-06 00:55:43-04:00, stenn@whimsy.udel.edu +0 -1
+    cleanup
+
+ChangeSet@1.1177.2.1, 2004-04-06 00:36:24-04:00, stenn@whimsy.udel.edu +2 -0
+  Cleanup from Reg Clemens
+
+  include/timepps-Solaris.h@1.3, 2004-04-06 00:36:03-04:00, stenn@whimsy.udel.edu +5 -0
+    Cleanup from Reg Clemens
+
+  include/timepps-SunOS.h@1.3, 2004-04-06 00:36:03-04:00, stenn@whimsy.udel.edu +1 -4
+    Cleanup from Reg Clemens
+
+ChangeSet@1.1177.1.1, 2004-04-05 14:11:34-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 299] Distribute timepps-*.h
+
+  include/Makefile.am@1.19, 2004-04-05 14:11:11-04:00, stenn@whimsy.udel.edu +3 -0
+    [Bug 299] Distribute timepps-*.h
+
+ChangeSet@1.1177, 2004-04-04 23:00:44-04:00, stenn@whimsy.udel.edu +2 -0
+  Cleanup from Dave Mills
+
+  include/ntp_crypto.h@1.33, 2004-04-04 23:00:29-04:00, stenn@whimsy.udel.edu +1 -0
+    Cleanup from Dave Mills
+
+  ntpd/ntp_crypto.c@1.92, 2004-04-04 23:00:29-04:00, stenn@whimsy.udel.edu +65 -42
+    Cleanup from Dave Mills
+
+ChangeSet@1.1176, 2004-04-04 22:44:03-04:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 241] Dave agrees the patch is correct.
+
+  ntpd/ntp_config.c@1.102.1.2, 2004-04-04 22:43:48-04:00, stenn@whimsy.udel.edu +0 -5
+    [Bug 241] Dave agrees the patch is correct.
+
+ChangeSet@1.1175, 2004-04-03 21:18:24-05:00, stenn@whimsy.udel.edu +3 -0
+  [Bug 275] Build ntp-keygen even if no OPENSSL.
+
+  configure.in@1.349, 2004-04-03 21:18:09-05:00, stenn@whimsy.udel.edu +0 -3
+    [Bug 275] Build ntp-keygen even if no OPENSSL.
+
+  util/Makefile.am@1.24, 2004-04-03 21:18:09-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 275] Build ntp-keygen even if no OPENSSL.
+
+  util/ntp-keygen.c@1.27, 2004-04-03 21:18:09-05:00, stenn@whimsy.udel.edu +49 -5
+    [Bug 275] Build ntp-keygen even if no OPENSSL.
+
+ChangeSet@1.1174, 2004-04-03 02:48:23-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 241] Fix from Matthias Drochner
+
+  ntpd/ntp_config.c@1.102.1.1, 2004-04-03 02:48:10-05:00, stenn@whimsy.udel.edu +2 -1
+    [Bug 241] Fix from Matthias Drochner
+
+ChangeSet@1.1152.33.2, 2004-04-03 02:17:22-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 277] Ultralink 325 support from Frank Migge
+
+  ntpd/refclock_ulink.c@1.13, 2004-04-03 02:17:05-05:00, stenn@whimsy.udel.edu +161 -69
+    [Bug 277] Ultralink 325 support from Frank Migge
+
+ChangeSet@1.1152.33.1, 2004-04-03 01:56:25-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 217] Typo in ntptrace
+
+  scripts/ntptrace.in@1.4, 2004-04-03 01:56:06-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 217] Typo in ntptrace
+
+ChangeSet@1.1152.1.98, 2004-04-02 16:07:14-05:00, mayer@pogo.udel.edu +1 -0
+  remove pps_device[] array that crept back in
+
+  ntpd/ntp_config.c@1.103, 2004-04-02 16:06:37-05:00, mayer@pogo.udel.edu +0 -1
+    remove pps_device[] array that crept back in
+
+ChangeSet@1.1152.1.97, 2004-04-02 15:20:54-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 298] Fix typos in configure.in
+
+  configure.in@1.348, 2004-04-02 15:20:37-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 298] Fix typos in configure.in
+
+ChangeSet@1.1152.32.5, 2004-04-01 15:23:22-05:00, mayer@pogo.udel.edu +8 -0
+  ntpdc_ops.c:
+    undo all of the changes to the header include order as some systems in the flock had trouble with the reordering
+  ntpdc_ops.c, ntp_intres.c:
+    Undo some of the reordering of includes
+  Many files:
+    reorder includes to make sure that the AI_* macros don't get defined before the system has a chance to define them
+  ntp_fp.h:
+    change inclusion order of netinet/in.h and ntp_rfc2553.h
+
+  include/ntp_fp.h@1.11, 2004-03-30 18:09:26-05:00, mayer@pogo.udel.edu +1 -1
+    change inclusion order of netinet/in.h and ntp_rfc2553.h
+
+  ntpd/ntp_config.c@1.102, 2004-03-30 18:41:19-05:00, mayer@pogo.udel.edu +3 -2
+    reorder includes to make sure that the AI_* macros don't get defined before the system has a chance to define them
+
+  ntpd/ntp_intres.c@1.34, 2004-03-30 20:12:11-05:00, mayer@pogo.udel.edu +9 -8
+    Undo some of the reordering of includes
+
+  ntpd/ntp_intres.c@1.33, 2004-03-30 18:41:20-05:00, mayer@pogo.udel.edu +7 -7
+    reorder includes to make sure that the AI_* macros don't get defined before the system has a chance to define them
+
+  ntpd/ntp_resolver.c@1.17, 2004-03-30 18:41:20-05:00, mayer@pogo.udel.edu +7 -7
+    reorder includes to make sure that the AI_* macros don't get defined before the system has a chance to define them
+
+  ntpd/refclock_nmea.c@1.23, 2004-03-30 18:42:44-05:00, mayer@pogo.udel.edu +5 -5
+    reorder includes to make sure that the AI_* macros don't get defined before the system has a chance to define them
+
+  ntpdc/ntpdc.c@1.33, 2004-03-30 18:26:37-05:00, mayer@pogo.udel.edu +5 -5
+    reorder includes to make sure that the AI_* macros don't get defined before the system has a chance to define them
+
+  ntpdc/ntpdc_ops.c@1.32, 2004-04-01 15:02:55-05:00, mayer@pogo.udel.edu +6 -7
+    undo all of the changes to the header include order as some systems in the flock had trouble with the reordering
+
+  ntpdc/ntpdc_ops.c@1.31, 2004-03-30 20:12:11-05:00, mayer@pogo.udel.edu +5 -4
+    Undo some of the reordering of includes
+
+  ntpdc/ntpdc_ops.c@1.30, 2004-03-30 18:43:04-05:00, mayer@pogo.udel.edu +8 -8
+    reorder includes to make sure that the AI_* macros don't get defined before the system has a chance to define them
+
+  ntpq/ntpq.c@1.46, 2004-03-30 18:26:45-05:00, mayer@pogo.udel.edu +7 -6
+    reorder includes to make sure that the AI_* macros don't get defined before the system has a chance to define them
+
+ChangeSet@1.1152.1.95, 2004-03-29 21:57:51-05:00, stenn@whimsy.udel.edu +1 -0
+  New irig notes from Dave Mills
+
+  ntpd/refclock_irig.c@1.21, 2004-03-29 21:57:12-05:00, stenn@whimsy.udel.edu +14 -14
+    New notes from Dave Mills
+
+ChangeSet@1.1152.32.4, 2004-03-26 20:10:51-05:00, mayer@pogo.udel.edu +1 -0
+  remove reference to include netdb.h. porkypine doesn't protect itself against multiple includes
+
+  include/ntp_rfc2553.h@1.24, 2004-03-26 20:09:03-05:00, mayer@pogo.udel.edu +0 -1
+    remove reference to include netdb.h. porkypine doesn't protect itself against multiple includes
+
+ChangeSet@1.1152.32.3, 2004-03-26 19:39:33-05:00, mayer@pogo.udel.edu +1 -0
+  Remove some includes as porkypine complained
+
+  include/ntp_rfc2553.h@1.23, 2004-03-26 19:38:13-05:00, mayer@pogo.udel.edu +1 -13
+    Remove some includes as porkypine complained
+
+ChangeSet@1.1152.32.2, 2004-03-26 17:53:26-05:00, mayer@pogo.udel.edu +2 -0
+  Fix the macros in ntp_rfc2553.h by including network headers and make ntp_io.c conditionally allow IPv6 multicast only if the macros are defined
+
+  include/ntp_rfc2553.h@1.22, 2004-03-26 17:49:45-05:00, mayer@pogo.udel.edu +13 -0
+    add includes to ntp_rfc2553.h to ensure that macros are defined in case they don't need to be defined
+
+  ntpd/ntp_io.c@1.109, 2004-03-26 17:50:53-05:00, mayer@pogo.udel.edu +2 -2
+    Make IPV6 multicast conditional on the inclusion of the IPV6_JOIN_GROUP and IPV6_LEAVE_GROUP
+
+ChangeSet@1.1152.32.1, 2004-03-26 09:46:49-05:00, mayer@pogo.udel.edu +1 -0
+  #endif for DEBUG was one line too far down, causing problems with release builds
+
+  ntpd/ntp_proto.c@1.176, 2004-03-26 09:44:50-05:00, mayer@pogo.udel.edu +1 -1
+    #endif for DEBUG was one line too far down, causing problems with release builds
+
+ChangeSet@1.1152.31.6, 2004-03-25 21:20:54-05:00, stenn@whimsy.udel.edu +1 -0
+  Fixed from Dave Mills.
+
+  ntpd/ntp_loopfilter.c@1.94, 2004-03-25 21:20:41-05:00, stenn@whimsy.udel.edu +3 -3
+    Fixed from Dave Mills.
+
+ChangeSet@1.1152.31.5, 2004-03-25 21:17:21-05:00, stenn@whimsy.udel.edu +1 -0
+  jitter.c fixes from Dave Mills.
+
+  util/jitter.c@1.5, 2004-03-25 21:17:03-05:00, stenn@whimsy.udel.edu +67 -5
+    fixes from Dave Mills.
+
+ChangeSet@1.1152.31.4, 2004-03-25 21:13:54-05:00, stenn@whimsy.udel.edu +46 -0
+  Documentation cleanup/resync with Dave.
+
+  html/build/build.html@1.20, 2004-03-25 21:12:17-05:00, stenn@whimsy.udel.edu +12 -12
+    Documentation cleanup/resync with Dave.
+
+  html/build/config.html@1.18, 2004-03-25 21:12:17-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/build/hints.html@1.14, 2004-03-25 21:12:17-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/build/hints/solaris.html@1.8, 2004-03-25 21:12:18-05:00, stenn@whimsy.udel.edu +1 -1
+    Documentation cleanup/resync with Dave.
+
+  html/build/hints/vxworks.html@1.7, 2004-03-25 21:12:19-05:00, stenn@whimsy.udel.edu +5 -5
+    Documentation cleanup/resync with Dave.
+
+  html/build/hints/winnt.html@1.15, 2004-03-25 21:12:19-05:00, stenn@whimsy.udel.edu +4 -4
+    Documentation cleanup/resync with Dave.
+
+  html/build/patches.html@1.17, 2004-03-25 21:12:17-05:00, stenn@whimsy.udel.edu +3 -3
+    Documentation cleanup/resync with Dave.
+
+  html/build/porting.html@1.13, 2004-03-25 21:12:17-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/build/quick.html@1.16, 2004-03-25 21:12:17-05:00, stenn@whimsy.udel.edu +6 -6
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver1.html@1.14, 2004-03-25 21:12:20-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver10.html@1.11, 2004-03-25 21:12:20-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver11.html@1.11, 2004-03-25 21:12:20-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver12.html@1.11, 2004-03-25 21:12:20-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver16.html@1.10, 2004-03-25 21:12:20-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver18.html@1.11, 2004-03-25 21:12:21-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver19.html@1.10, 2004-03-25 21:12:21-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver2.html@1.11, 2004-03-25 21:12:21-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver20.html@1.13, 2004-03-25 21:12:21-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver22.html@1.15, 2004-03-25 21:12:21-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver23.html@1.12, 2004-03-25 21:12:21-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver24.html@1.9, 2004-03-25 21:12:21-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver26.html@1.9, 2004-03-25 21:12:22-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver27.html@1.13, 2004-03-25 21:12:22-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver28.html@1.10, 2004-03-25 21:12:22-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver29.html@1.12, 2004-03-25 21:12:22-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver3.html@1.10, 2004-03-25 21:12:22-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver30.html@1.18, 2004-03-25 21:12:22-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver32.html@1.11, 2004-03-25 21:12:23-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver33.html@1.11, 2004-03-25 21:12:23-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver34.html@1.10, 2004-03-25 21:12:23-05:00, stenn@whimsy.udel.edu +80 -45
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver35.html@1.13, 2004-03-25 21:12:23-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver36.html@1.22, 2004-03-25 21:12:23-05:00, stenn@whimsy.udel.edu +3 -3
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver37.html@1.11, 2004-03-25 21:12:23-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver38.html@1.11, 2004-03-25 21:12:24-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver39.html@1.11, 2004-03-25 21:12:24-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver4.html@1.11, 2004-03-25 21:12:24-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver40.html@1.10, 2004-03-25 21:12:24-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver42.html@1.11, 2004-03-25 21:12:24-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver43.html@1.8, 2004-03-25 21:12:24-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver44.html@1.10, 2004-03-25 21:12:24-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver5.html@1.11, 2004-03-25 21:12:25-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver6.html@1.17, 2004-03-25 21:12:25-05:00, stenn@whimsy.udel.edu +3 -3
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver7.html@1.20, 2004-03-25 21:12:25-05:00, stenn@whimsy.udel.edu +3 -3
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver8.html@1.13, 2004-03-25 21:12:25-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/driver9.html@1.13, 2004-03-25 21:12:25-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+  html/drivers/oncore-shmem.html@1.11, 2004-03-25 21:12:25-05:00, stenn@whimsy.udel.edu +2 -2
+    Documentation cleanup/resync with Dave.
+
+ChangeSet@1.1152.1.90, 2004-03-25 20:04:11-05:00, mayer@pogo.udel.edu +2 -0
+  Added conditional macro for scope_id
+
+  libisc/interfaceiter.c@1.10, 2004-03-25 20:03:21-05:00, mayer@pogo.udel.edu +5 -1
+    Added conditional macro for scope_id
+
+  ntpd/ntp_io.c@1.108, 2004-03-25 20:03:21-05:00, mayer@pogo.udel.edu +4 -0
+    Added conditional macro for scope_id
+
+ChangeSet@1.1152.31.3, 2004-03-24 23:31:23-05:00, stenn@whimsy.udel.edu +49 -0
+  Resync html/ with the master copy from Dave.
+
+  html/authopt.html@1.32, 2004-03-24 23:25:13-05:00, stenn@whimsy.udel.edu +5 -5
+    Resync html/ with the master copy from Dave.
+
+  html/build/build.html@1.19, 2004-03-24 23:19:36-05:00, stenn@whimsy.udel.edu +0 -0
+    Rename: html/build.html -> html/build/build.html
+
+  html/build/config.html@1.17, 2004-03-24 23:19:36-05:00, stenn@whimsy.udel.edu +0 -0
+    Rename: html/config.html -> html/build/config.html
+
+  html/build/hints.html@1.13, 2004-03-24 23:19:36-05:00, stenn@whimsy.udel.edu +0 -0
+    Rename: html/hints.html -> html/build/hints.html
+
+  html/build/hints/a-ux@1.3, 2004-03-24 23:10:45-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/aix@1.3, 2004-03-24 23:10:45-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/bsdi@1.3, 2004-03-24 23:10:46-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/changes@1.3, 2004-03-24 23:10:46-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/decosf1@1.3, 2004-03-24 23:10:46-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/decosf2@1.3, 2004-03-24 23:10:46-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/freebsd@1.3, 2004-03-24 23:10:46-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/hpux@1.3, 2004-03-24 23:10:46-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/linux@1.3, 2004-03-24 23:10:46-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/mpeix@1.3, 2004-03-24 23:10:46-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/netbsd@1.2, 2004-03-24 23:10:47-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/notes-xntp-v3@1.3, 2004-03-24 23:10:47-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/parse@1.3, 2004-03-24 23:10:47-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/refclocks@1.3, 2004-03-24 23:10:47-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/rs6000@1.3, 2004-03-24 23:10:47-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/sco.html@1.7, 2004-03-24 23:10:47-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/sgi@1.3, 2004-03-24 23:10:47-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/solaris-dosynctodr.html@1.4, 2004-03-24 23:10:47-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/solaris.html@1.7, 2004-03-24 23:10:48-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/solaris.xtra.4023118@1.3, 2004-03-24 23:10:48-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/solaris.xtra.4095849@1.3, 2004-03-24 23:10:48-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/solaris.xtra.S99ntpd@1.4, 2004-03-24 23:10:48-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/solaris.xtra.patchfreq@1.3, 2004-03-24 23:10:48-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/sun4@1.3, 2004-03-24 23:10:48-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/svr4-dell@1.3, 2004-03-24 23:10:48-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/svr4_package@1.3, 2004-03-24 23:10:48-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/todo@1.3, 2004-03-24 23:10:49-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/vxworks.html@1.6, 2004-03-24 23:10:49-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/hints/winnt.html@1.14, 2004-03-24 23:10:49-05:00, stenn@whimsy.udel.edu +0 -0
+    mvdir
+
+  html/build/patches.html@1.16, 2004-03-24 23:19:37-05:00, stenn@whimsy.udel.edu +0 -0
+    Rename: html/patches.html -> html/build/patches.html
+
+  html/build/porting.html@1.12, 2004-03-24 23:19:37-05:00, stenn@whimsy.udel.edu +0 -0
+    Rename: html/porting.html -> html/build/porting.html
+
+  html/build/quick.html@1.15, 2004-03-24 23:22:11-05:00, stenn@whimsy.udel.edu +0 -0
+    Rename: html/quick.html -> html/build/quick.html
+
+  html/build/scripts/footer.txt@1.1, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +7 -0
+
+  html/build/scripts/footer.txt@1.0, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/build/scripts/footer.txt
+
+  html/build/scripts/links10.txt@1.1, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +5 -0
+
+  html/build/scripts/links10.txt@1.0, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/build/scripts/links10.txt
+
+  html/build/scripts/links11.txt@1.1, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +5 -0
+
+  html/build/scripts/links11.txt@1.0, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/build/scripts/links11.txt
+
+  html/build/scripts/links12.txt@1.1, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +5 -0
+
+  html/build/scripts/links12.txt@1.0, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/build/scripts/links12.txt
+
+  html/build/scripts/links7.txt@1.1, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +5 -0
+
+  html/build/scripts/links7.txt@1.0, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/build/scripts/links7.txt
+
+  html/build/scripts/links8.txt@1.1, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +6 -0
+
+  html/build/scripts/links8.txt@1.0, 2004-03-24 23:29:11-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/build/scripts/links8.txt
+
+  html/build/scripts/links9.txt@1.1, 2004-03-24 23:29:12-05:00, stenn@whimsy.udel.edu +7 -0
+
+  html/build/scripts/links9.txt@1.0, 2004-03-24 23:29:12-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/build/scripts/links9.txt
+
+  html/build/scripts/style.css@1.1, 2004-03-24 23:29:12-05:00, stenn@whimsy.udel.edu +64 -0
+
+  html/build/scripts/style.css@1.0, 2004-03-24 23:29:12-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/build/scripts/style.css
+
+  html/drivers/driver31.html@1.1, 2004-03-24 23:28:57-05:00, stenn@whimsy.udel.edu +56 -0
+
+  html/drivers/driver31.html@1.0, 2004-03-24 23:28:57-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /deacon/backroom/ntp-dev/html/drivers/driver31.html
+
+  html/howto.html@1.17, 2004-03-24 23:25:14-05:00, stenn@whimsy.udel.edu +2 -2
+    Resync html/ with the master copy from Dave.
+
+  html/index.html@1.30, 2004-03-24 23:25:14-05:00, stenn@whimsy.udel.edu +9 -9
+    Resync html/ with the master copy from Dave.
+
+  html/notes.html@1.16, 2004-03-24 23:25:15-05:00, stenn@whimsy.udel.edu +2 -2
+    Resync html/ with the master copy from Dave.
+
+  html/release.html@1.29, 2004-03-24 23:25:16-05:00, stenn@whimsy.udel.edu +1 -1
+    Resync html/ with the master copy from Dave.
+
+ChangeSet@1.1152.31.2, 2004-03-24 22:04:57-05:00, stenn@whimsy.udel.edu +5 -0
+  PPS cleanup from Dave Mills.
+
+  include/ntpd.h@1.65, 2004-03-24 22:04:41-05:00, stenn@whimsy.udel.edu +1 -2
+    PPS cleanup from Dave Mills.
+
+  ntpd/ntp_config.c@1.101, 2004-03-24 22:04:41-05:00, stenn@whimsy.udel.edu +0 -1
+    PPS cleanup from Dave Mills.
+
+  ntpd/ntp_loopfilter.c@1.93, 2004-03-24 22:04:41-05:00, stenn@whimsy.udel.edu +8 -1
+    PPS cleanup from Dave Mills.
+
+  ntpd/ntp_refclock.c@1.57, 2004-03-24 22:04:42-05:00, stenn@whimsy.udel.edu +7 -15
+    PPS cleanup from Dave Mills.
+
+  ntpd/refclock_atom.c@1.43, 2004-03-24 22:04:42-05:00, stenn@whimsy.udel.edu +11 -13
+    PPS cleanup from Dave Mills.
+
+ChangeSet@1.1152.31.1, 2004-03-24 21:55:36-05:00, stenn@whimsy.udel.edu +1 -0
+  Have configure look for struct sockaddr_in6.sin6_scope_id
+
+  configure.in@1.347, 2004-03-24 21:55:23-05:00, stenn@whimsy.udel.edu +9 -0
+    Have configure look for struct sockaddr_in6.sin6_scope_id
+
+ChangeSet@1.1152.29.3, 2004-03-24 17:27:43-05:00, mayer@pogo.udel.edu +2 -0
+  Change u_int64_t to ntp_int64_t to avoid O/S problems
+
+  include/ntp_rfc2553.h@1.21, 2004-03-24 17:26:57-05:00, mayer@pogo.udel.edu +2 -2
+    Change u_int64_t to ntp_int64_t to avoid O/S problems
+
+  include/ntp_types.h@1.7, 2004-03-24 17:26:57-05:00, mayer@pogo.udel.edu +1 -3
+    Change u_int64_t to ntp_int64_t to avoid O/S problems
+
+ChangeSet@1.1152.1.88, 2004-03-24 00:57:20-05:00, stenn@pogo.udel.edu +1 -0
+  No parse clocks if we disable all clocks
+
+  flock-build@1.29, 2004-03-24 00:57:07-05:00, stenn@pogo.udel.edu +2 -1
+    No parse clocks if we disable all clocks
+
+ChangeSet@1.1152.1.87, 2004-03-23 00:26:24-05:00, stenn@whimsy.udel.edu +2 -0
+  Do --disable-all-clocks in flock-build, too.
+
+  build@1.21, 2004-03-23 00:26:15-05:00, stenn@whimsy.udel.edu +6 -0
+    Do --disable-all-clocks in flock-build, too.
+
+  flock-build@1.28, 2004-03-23 00:26:15-05:00, stenn@whimsy.udel.edu +3 -1
+    Do --disable-all-clocks in flock-build, too.
+
+ChangeSet@1.1152.1.86, 2004-03-23 00:07:02-05:00, stenn@whimsy.udel.edu +2 -0
+  no refclock fixes from Dave Mills
+
+  ntpd/ntp_control.c@1.69, 2004-03-23 00:06:49-05:00, stenn@whimsy.udel.edu +2 -0
+    no refclock fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.175, 2004-03-23 00:06:50-05:00, stenn@whimsy.udel.edu +4 -1
+    no refclock fixes from Dave Mills
+
+ChangeSet@1.1152.1.85, 2004-03-22 23:59:43-05:00, stenn@whimsy.udel.edu +1 -0
+  From Dave Mills: remove legacy local_refclock/prefer wrinkle.
+
+  ntpd/ntp_loopfilter.c@1.92, 2004-03-22 23:59:30-05:00, stenn@whimsy.udel.edu +0 -13
+    From Dave Mills: remove legacy local_refclock/prefer wrinkle.
+
+ChangeSet@1.1152.1.84, 2004-03-20 01:20:11-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 293] - out of bounds array write: Nathan Hintz
+
+  util/ntp-keygen.c@1.26, 2004-03-20 01:19:59-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 293] - out of bounds array write: Nathan Hintz
+
+ChangeSet@1.1152.29.2, 2004-03-19 19:11:17-05:00, mayer@pogo.udel.edu +1 -0
+  Move AI_NUMERICHOST outside of the ISC_PLATFORM_HAVEIPV6 macro to conditionally include it if it's not defined
+
+  include/ntp_rfc2553.h@1.20, 2004-03-19 19:10:40-05:00, mayer@pogo.udel.edu +14 -14
+    Move AI_NUMERICHOST outside of the ISC_PLATFORM_HAVEIPV6 macro to conditionally include it if it's not defined
+
+ChangeSet@1.1152.1.82, 2004-03-19 01:48:58-05:00, stenn@deacon.udel.edu +2 -0
+  Oncore: Remove obsolete checks
+
+  BitKeeper/etc/logging_ok@1.48, 2004-03-19 01:48:57-05:00, stenn@deacon.udel.edu +1 -0
+    Logging to logging@openlogging.org accepted
+
+  ntpd/refclock_oncore.c@1.50, 2004-03-19 01:48:32-05:00, stenn@deacon.udel.edu +0 -4
+    Remove obsolete checks
+
+ChangeSet@1.1152.1.81, 2004-03-18 23:54:58-05:00, stenn@whimsy.udel.edu +3 -0
+  Use "inline" instead of "__inline" so configure can DTRT.
+
+  include/timepps-SCO.h@1.2, 2004-03-18 23:54:40-05:00, stenn@whimsy.udel.edu +7 -7
+    Use "inline" instead of "__inline" so configure can DTRT.
+
+  include/timepps-Solaris.h@1.2, 2004-03-18 23:54:40-05:00, stenn@whimsy.udel.edu +7 -7
+    Use "inline" instead of "__inline" so configure can DTRT.
+
+  include/timepps-SunOS.h@1.2, 2004-03-18 23:54:40-05:00, stenn@whimsy.udel.edu +7 -7
+    Use "inline" instead of "__inline" so configure can DTRT.
+
+ChangeSet@1.1152.1.80, 2004-03-18 23:38:17-05:00, stenn@whimsy.udel.edu +5 -0
+  Documentation updates from Dave Mills
+
+  html/authopt.html@1.31, 2004-03-18 23:37:51-05:00, stenn@whimsy.udel.edu +3 -3
+    Updates from Dave Mills
+
+  html/howto.html@1.16, 2004-03-18 23:37:52-05:00, stenn@whimsy.udel.edu +1 -1
+    Updates from Dave Mills
+
+  html/index.html@1.29, 2004-03-18 23:37:52-05:00, stenn@whimsy.udel.edu +3 -3
+    Updates from Dave Mills
+
+  html/monopt.html@1.18, 2004-03-18 23:37:52-05:00, stenn@whimsy.udel.edu +2 -2
+    Updates from Dave Mills
+
+  html/refclock.html@1.29, 2004-03-18 23:37:52-05:00, stenn@whimsy.udel.edu +2 -2
+    Updates from Dave Mills
+
+ChangeSet@1.1152.1.79, 2004-03-18 23:24:57-05:00, stenn@whimsy.udel.edu +10 -0
+  Cleanup and fixed from Dave Mills
+
+  include/ntp.h@1.99, 2004-03-18 23:24:41-05:00, stenn@whimsy.udel.edu +2 -2
+    Cleanup and fixed from Dave Mills
+
+  include/ntpd.h@1.64, 2004-03-18 23:24:41-05:00, stenn@whimsy.udel.edu +2 -1
+    Cleanup and fixed from Dave Mills
+
+  libntp/systime.c@1.30, 2004-03-18 23:24:41-05:00, stenn@whimsy.udel.edu +7 -4
+    Cleanup and fixed from Dave Mills
+
+  ntpd/ntp_control.c@1.68, 2004-03-18 23:24:42-05:00, stenn@whimsy.udel.edu +3 -4
+    Cleanup and fixed from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.91, 2004-03-18 23:24:42-05:00, stenn@whimsy.udel.edu +26 -43
+    Cleanup and fixed from Dave Mills
+
+  ntpd/ntp_proto.c@1.174, 2004-03-18 23:24:42-05:00, stenn@whimsy.udel.edu +128 -126
+    Cleanup and fixed from Dave Mills
+
+  ntpd/ntp_refclock.c@1.56, 2004-03-18 23:24:43-05:00, stenn@whimsy.udel.edu +72 -36
+    Cleanup and fixed from Dave Mills
+
+  ntpd/ntp_request.c@1.56, 2004-03-18 23:24:43-05:00, stenn@whimsy.udel.edu +0 -18
+    Cleanup and fixed from Dave Mills
+
+  ntpd/refclock_arbiter.c@1.8, 2004-03-18 23:24:43-05:00, stenn@whimsy.udel.edu +20 -20
+    Cleanup and fixed from Dave Mills
+
+  ntpd/refclock_wwvb.c@1.12, 2004-03-18 23:24:43-05:00, stenn@whimsy.udel.edu +4 -3
+    Cleanup and fixed from Dave Mills
+
+ChangeSet@1.1152.1.78, 2004-03-18 23:15:06-05:00, stenn@whimsy.udel.edu +2 -0
+  Driver36 cleanup from Dave Mills
+
+  html/drivers/driver36.html@1.21, 2004-03-18 23:14:38-05:00, stenn@whimsy.udel.edu +4 -3
+    Cleanup from Dave Mills
+
+  html/scripts/links8.txt@1.2, 2004-03-18 23:14:38-05:00, stenn@whimsy.udel.edu +3 -3
+    Cleanup from Dave Mills
+
+ChangeSet@1.1152.1.77, 2004-03-17 17:11:42-05:00, stenn@pogo.udel.edu +1 -0
+  Pedantic compiler lint
+
+  sntp/header.h@1.4, 2004-03-17 17:11:29-05:00, stenn@pogo.udel.edu +2 -2
+    Pedantic compiler lint
+
+ChangeSet@1.1152.1.76, 2004-03-17 17:10:30-05:00, stenn@pogo.udel.edu +4 -0
+  oncore fixes from Reg Clemens
+
+  include/timepps-SCO.h@1.1, 2004-03-17 17:03:57-05:00, stenn@pogo.udel.edu +503 -0
+
+  include/timepps-SCO.h@1.0, 2004-03-17 17:03:57-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev/include/timepps-SCO.h
+
+  include/timepps-Solaris.h@1.1, 2004-03-17 17:03:58-05:00, stenn@pogo.udel.edu +497 -0
+
+  include/timepps-Solaris.h@1.0, 2004-03-17 17:03:58-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev/include/timepps-Solaris.h
+
+  include/timepps-SunOS.h@1.1, 2004-03-17 17:03:58-05:00, stenn@pogo.udel.edu +507 -0
+
+  include/timepps-SunOS.h@1.0, 2004-03-17 17:03:58-05:00, stenn@pogo.udel.edu +0 -0
+    BitKeeper file /pogo/users/stenn/ntp-dev/include/timepps-SunOS.h
+
+  ntpd/refclock_oncore.c@1.49, 2004-03-17 17:09:39-05:00, stenn@pogo.udel.edu +85 -132
+    Patches/cleanup from Reg Clemens.
+    Header realignment from Harlan.
+
+ChangeSet@1.1152.29.1, 2004-03-15 21:04:56-05:00, mayer@tecotoo. +1 -0
+  Update to ensure the I/O Completion Ports code checks the various error states and sets the return status correctly
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.11, 2004-03-15 21:04:28-05:00, mayer@tecotoo. +20 -6
+    Update to ensure the I/O Completion Ports code checks the various error states and sets the return status correctly
+
+ChangeSet@1.1152.1.72, 2004-03-14 22:04:31-05:00, mayer@tecotoo. +1 -0
+  LIB_GETBUF only has space for 20 entries and does not zero out the contents. Change the limit to 200 and zero out the contents before returning it
+
+  libntp/lib_strbuf.h@1.3, 2004-03-14 22:04:03-05:00, mayer@tecotoo. +2 -1
+    LIB_GETBUF only has space for 20 entries and does not zero out the contents. Change the limit to 200 and zero out the contents before returning it
+
+ChangeSet@1.1152.1.71, 2004-03-13 22:06:42-05:00, mayer@tecotoo. +2 -0
+  ntp_types.h needs to include sys/types.h
+
+  include/ntp_rfc2553.h@1.19, 2004-03-13 22:06:13-05:00, mayer@tecotoo. +0 -1
+    ntp_types.h needs to include sys/types.h
+
+  include/ntp_types.h@1.6, 2004-03-13 22:06:14-05:00, mayer@tecotoo. +1 -0
+    ntp_types.h needs to include sys/types.h
+
+ChangeSet@1.1152.28.1, 2004-03-12 22:17:41-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 283] fix (md5.h header check)
+
+  configure.in@1.346, 2004-03-12 22:17:29-05:00, stenn@whimsy.udel.edu +5 -1
+    [Bug 283] fix (md5.h header check)
+
+ChangeSet@1.1152.1.70, 2004-03-11 23:47:33-05:00, mayer@tecotoo. +1 -0
+  move some conditionals back inside ISC_PLATFORM_HAVEIPV6 to reduce warnings if already defined elsewhere
+
+  include/ntp_rfc2553.h@1.18, 2004-03-11 23:47:05-05:00, mayer@tecotoo. +2 -2
+    move some conditionals back inside ISC_PLATFORM_HAVEIPV6 to reduce warnings if already defined elsewhere
+
+ChangeSet@1.1152.1.69, 2004-03-11 22:55:24-05:00, mayer@tecotoo. +2 -0
+  move integer type definitions from ntp_rfc2553.h into ntp_types.h where they belong
+
+  include/ntp_rfc2553.h@1.17, 2004-03-11 22:54:56-05:00, mayer@tecotoo. +0 -10
+    move integer type definitions from ntp_rfc2553.h into ntp_types.h where they belong
+
+  include/ntp_types.h@1.5, 2004-03-11 22:54:56-05:00, mayer@tecotoo. +10 -0
+    move integer type definitions from ntp_rfc2553.h into ntp_types.h where they belong
+
+ChangeSet@1.1152.1.68, 2004-03-10 17:51:29-05:00, mayer@pogo.udel.edu +1 -0
+  Move some macros outside of ISC_PLATFORM_HAVEIPV6 conditional macro and check for inclusion
+
+  include/ntp_rfc2553.h@1.16, 2004-03-10 17:50:19-05:00, mayer@pogo.udel.edu +16 -8
+    Move some macros outside of ISC_PLATFORM_HAVEIPV6 conditional macro and check for inclusion
+
+ChangeSet@1.1152.1.67, 2004-03-09 22:24:49-05:00, mayer@tecotoo. +1 -0
+  Fix order of variable declarations to ensure required types are declared first for the following structures
+
+  include/ntp_rfc2553.h@1.15, 2004-03-09 22:24:24-05:00, mayer@tecotoo. +15 -15
+    Fix order of variable declarations to ensure required types are declared first for the following structures
+
+ChangeSet@1.1172, 2004-03-05 12:45:00-08:00, gnu@ring.wraith.sf.ca.us +1 -0
+  add Ross Alexander's fixes for /etc/ntp.audioX
+
+  libntp/audio.c@1.22, 2004-03-05 12:45:00-08:00, gnu@ring.wraith.sf.ca.us +15 -9
+    add Ross Alexander's fixes for /etc/ntp.audioX
+
+ChangeSet@1.1152.1.64, 2004-03-03 00:57:05-05:00, stenn@whimsy.udel.edu +2 -0
+  More cleanup/fixes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.90, 2004-03-03 00:56:51-05:00, stenn@whimsy.udel.edu +139 -141
+    More cleanup/fixes from Dave Mills
+
+  ntpd/ntp_proto.c@1.173, 2004-03-03 00:56:52-05:00, stenn@whimsy.udel.edu +27 -11
+    More cleanup/fixes from Dave Mills
+
+ChangeSet@1.1152.1.63, 2004-03-03 00:49:55-05:00, stenn@whimsy.udel.edu +1 -0
+  Fix the sockaddr_storage check
+
+  configure.in@1.345, 2004-03-03 00:49:41-05:00, stenn@whimsy.udel.edu +1 -2
+    Fix the sockaddr_storage check
+
+ChangeSet@1.1152.1.62, 2004-03-02 22:21:11-05:00, stenn@whimsy.udel.edu +1 -0
+  Re-enable support for Reliant & SCO
+
+  libntp/systime.c@1.29, 2004-03-02 22:20:46-05:00, stenn@whimsy.udel.edu +5 -1
+    Re-enable support for Reliant & SCO
+
+ChangeSet@1.1152.1.61, 2004-02-18 19:56:01-05:00, stenn@whimsy.udel.edu +3 -0
+  More cleanup from Dave Mills
+
+  include/ntpd.h@1.63, 2004-02-18 19:55:47-05:00, stenn@whimsy.udel.edu +1 -1
+    More cleanup from Dave Mills
+
+  ntpd/ntp_proto.c@1.172, 2004-02-18 19:55:47-05:00, stenn@whimsy.udel.edu +40 -37
+    More cleanup from Dave Mills
+
+  ntpd/ntp_refclock.c@1.55, 2004-02-18 19:55:48-05:00, stenn@whimsy.udel.edu +1 -1
+    More cleanup from Dave Mills
+
+ChangeSet@1.1152.1.60, 2004-02-18 00:56:22-05:00, stenn@whimsy.udel.edu +2 -0
+  Revert the change that required Recent auto*, to fix bug 230.
+  
+  I will still roll tarballs with these recent releases so folks who
+  get tarballs won't see that bug.  Only folks otherwise affected by
+  bug 230 will need the latest auto*.
+
+  Makefile.am@1.46, 2004-02-18 00:56:17-05:00, stenn@whimsy.udel.edu +1 -1
+    Revert the change that required Recent auto*, to fix bug 230.
+    
+    I will still roll tarballs with these recent releases so folks who
+    get tarballs won't see that bug.  Only folks otherwise affected by
+    bug 230 will need the latest auto*.
+
+  configure.in@1.344, 2004-02-18 00:56:18-05:00, stenn@whimsy.udel.edu +1 -1
+    Revert the change that required Recent auto*, to fix bug 230.
+    
+    I will still roll tarballs with these recent releases so folks who
+    get tarballs won't see that bug.  Only folks otherwise affected by
+    bug 230 will need the latest auto*.
+
+ChangeSet@1.1152.26.1, 2004-02-17 01:43:41-05:00, stenn@whimsy.udel.edu +8 -0
+  Cleanup from Dave Mills.
+
+  include/ntp.h@1.98, 2004-02-17 01:43:25-05:00, stenn@whimsy.udel.edu +0 -1
+    Cleanup from Dave Mills.
+
+  include/ntpd.h@1.62, 2004-02-17 01:43:25-05:00, stenn@whimsy.udel.edu +1 -1
+    Cleanup from Dave Mills.
+
+  ntpd/ntp_crypto.c@1.91, 2004-02-17 01:43:25-05:00, stenn@whimsy.udel.edu +9 -9
+    Cleanup from Dave Mills.
+
+  ntpd/ntp_loopfilter.c@1.89, 2004-02-17 01:43:26-05:00, stenn@whimsy.udel.edu +0 -4
+    Cleanup from Dave Mills.
+
+  ntpd/ntp_peer.c@1.59, 2004-02-17 01:43:26-05:00, stenn@whimsy.udel.edu +1 -2
+    Cleanup from Dave Mills.
+
+  ntpd/ntp_proto.c@1.171, 2004-02-17 01:43:27-05:00, stenn@whimsy.udel.edu +98 -84
+    Cleanup from Dave Mills.
+
+  ntpd/ntp_refclock.c@1.54, 2004-02-17 01:43:27-05:00, stenn@whimsy.udel.edu +1 -1
+    Cleanup from Dave Mills.
+
+  ntpd/refclock_arbiter.c@1.7, 2004-02-17 01:43:28-05:00, stenn@whimsy.udel.edu +2 -1
+    Cleanup from Dave Mills.
+
+ChangeSet@1.1152.25.6, 2004-02-16 22:35:20-05:00, stenn@whimsy.udel.edu +3 -0
+  Let the ONCORE refclock build without PPS.  From Reg Clemens.
+
+  html/drivers/driver30.html@1.17, 2004-02-16 22:34:32-05:00, stenn@whimsy.udel.edu +2 -2
+    Let the ONCORE refclock build without PPS.  From Reg Clemens.
+
+  ntpd/refclock_conf.c@1.23, 2004-02-16 22:34:33-05:00, stenn@whimsy.udel.edu +1 -1
+    Let the ONCORE refclock build without PPS.  From Reg Clemens.
+
+  ntpd/refclock_oncore.c@1.48, 2004-02-16 22:34:33-05:00, stenn@whimsy.udel.edu +89 -53
+    Let the ONCORE refclock build without PPS.  From Reg Clemens.
+
+ChangeSet@1.1152.25.5, 2004-02-14 22:05:42-05:00, stenn@whimsy.udel.edu +1 -0
+  Disable check_y2k for now (34 year bug?)
+
+  configure.in@1.343, 2004-02-14 22:05:29-05:00, stenn@whimsy.udel.edu +2 -1
+    Disable check_y2k for now (34 year bug?)
+
+ChangeSet@1.1152.25.4, 2004-02-13 23:54:07-05:00, stenn@whimsy.udel.edu +1 -0
+  Dave's recent patch assumed we had OPENSSL.  Handle the other case.
+
+  ntpd/ntp_proto.c@1.170, 2004-02-13 23:53:52-05:00, stenn@whimsy.udel.edu +2 -0
+    Dave's recent patch assumed we had OPENSSL.  Handle the other case.
+
+ChangeSet@1.1152.25.3, 2004-02-12 04:27:25-05:00, stenn@whimsy.udel.edu +4 -0
+  Changes from Dave Mills:
+  
+  1. Servers presented with key IDs they don't have (a common mistake)
+  return a crypt-NAK. This also happens when the server rolls new private
+  values daily without telling the clients. To protect against bad guys
+  tossing an old duplicate over the wall, the client doesn't believe this
+  unless the timestamps pass the loopback check. If the server was
+  previously reachable, the client simply restarts the association without
+  missing a beat. If not, and to protect against a restart loop or later
+  server restart, the client disregards the NAK and continues (while
+  disabling burst mode). If really invalid, the association timeout will
+  eventually expire following which a persistent association is marked
+  permanently disabled or an ephemeral association is demobilized.
+  
+  2. One of the most common mistakes is to goof up the identity
+  credentials. If the client received these credentials via mail, the
+  script in the message installs the file and link automatically. If done
+  by hand and done wrong, either the server or client will find the error
+  and disable the association. As in all such cases, a server or client
+  ephemeral association is demobilized and the resources recovered.
+  
+  3. Symmetric modes have always been tricky, much more so with Autokey,
+  and even more so with misconfigured identity keys. It gets even wilder
+  when either peer is restarted in the middle of negotiations. All the
+  evil scenarios I can thing of seem to come out on the other side,
+  although there are a few that have to wait the association timeout to
+  properly close down and recover resources.
+  
+  4. The association is permanently disabled upon kiss-o'-death or
+  unrecoverable crypto error. So, I re-enabled log reporting for these
+  smooches. At least the offender is notified.
+  
+  5. When a really tenacious clogger shows up and lights the call-gap, the
+  server puts it in the restrict list. He stays there until the server is
+  restarted. Not only does this discourage the terriot, but evidence is
+  collected for possible further action.
+  
+  What more do we have to do to turn this stuff into a real Secure
+  Timestamping Service? I think the security model, protocols, abuse
+  hardening and time performance are consistent with a bulletproof service
+  assuming, that is, PGP mail is used to get the keys and the server
+  certificates are properly signed.
+
+  include/ntp.h@1.97, 2004-02-12 04:22:55-05:00, stenn@whimsy.udel.edu +7 -5
+    Changes from Dave Mills
+
+  ntpd/ntp_crypto.c@1.90, 2004-02-12 04:22:56-05:00, stenn@whimsy.udel.edu +16 -17
+    Changes from Dave Mills
+
+  ntpd/ntp_proto.c@1.169, 2004-02-12 04:22:56-05:00, stenn@whimsy.udel.edu +200 -199
+    Changes from Dave Mills
+
+  ntpd/ntp_refclock.c@1.53, 2004-02-12 04:22:57-05:00, stenn@whimsy.udel.edu +1 -2
+    Changes from Dave Mills
+
+ChangeSet@1.1152.14.12, 2004-02-11 20:02:55-05:00, stenn@whimsy.udel.edu +7 -0
+  Prepare for move from whimsy to deacon.
+
+  BitKeeper/triggers/2mirrors@1.2, 2004-02-11 20:01:56-05:00, stenn@whimsy.udel.edu +1 -0
+    Prepare for move from whimsy to deacon.
+
+  BitKeeper/triggers/changelog@1.2, 2004-02-11 20:01:56-05:00, stenn@whimsy.udel.edu +1 -0
+    Prepare for move from whimsy to deacon.
+
+  BitKeeper/triggers/commitlogs@1.4, 2004-02-11 20:01:57-05:00, stenn@whimsy.udel.edu +1 -0
+    Prepare for move from whimsy to deacon.
+
+  BitKeeper/triggers/delta-changelog@1.6, 2004-02-11 20:01:57-05:00, stenn@whimsy.udel.edu +2 -1
+    Prepare for move from whimsy to deacon.
+
+  BitKeeper/triggers/notify@1.2, 2004-02-11 20:01:57-05:00, stenn@whimsy.udel.edu +2 -1
+    Prepare for move from whimsy to deacon.
+
+  BitKeeper/triggers/paranoid@1.2, 2004-02-11 20:01:57-05:00, stenn@whimsy.udel.edu +4 -1
+    Prepare for move from whimsy to deacon.
+
+  BitKeeper/triggers/send@1.4, 2004-02-11 20:01:58-05:00, stenn@whimsy.udel.edu +1 -0
+    Prepare for move from whimsy to deacon.
+
+ChangeSet@1.1152.14.11, 2004-02-10 20:05:16-05:00, stenn@whimsy.udel.edu +1 -0
+  Cleanup
+
+  README.bk@1.17, 2004-02-10 20:05:04-05:00, stenn@whimsy.udel.edu +3 -11
+    Cleanup
+
+ChangeSet@1.1152.22.10, 2004-02-10 16:42:03-05:00, mayer@pogo.udel.edu +1 -0
+  Move NT specific add to completion ports inside of the open_socket code
+
+  ntpd/ntp_io.c@1.105.1.1, 2004-02-10 16:41:39-05:00, mayer@pogo.udel.edu +18 -20
+    Move NT specific add to completion ports inside of the open_socket code
+
+ChangeSet@1.1152.24.3, 2004-02-07 17:53:39+00:00, mbrett@rgs16.fordson.demon.co.uk +4 -0
+  humandate.c, caljulian.c, ntp_fp.h:
+    Syntax changes to allow K&R compilers
+
+  BitKeeper/etc/logging_ok@1.42.1.2, 2004-02-07 17:53:38+00:00, mbrett@rgs16.fordson.demon.co.uk +1 -0
+    Logging to logging@openlogging.org accepted
+
+  include/ntp_fp.h@1.7.1.1, 2004-02-07 17:46:59+00:00, mbrett@rgs16.fordson.demon.co.uk +2 -0
+    Syntax changes to allow K&R compilers
+
+  libntp/caljulian.c@1.6, 2004-02-07 17:47:52+00:00, mbrett@rgs16.fordson.demon.co.uk +2 -3
+    Syntax changes to allow K&R compilers
+
+  libntp/humandate.c@1.6, 2004-02-07 17:48:04+00:00, mbrett@rgs16.fordson.demon.co.uk +0 -2
+    Syntax changes to allow K&R compilers
+
+ChangeSet@1.1152.22.8, 2004-02-05 19:46:43-05:00, mayer@pogo.udel.edu +1 -0
+  Fix for sockaddr_storage includes
+
+  include/ntp_rfc2553.h@1.12.1.1, 2004-02-05 19:46:02-05:00, mayer@pogo.udel.edu +45 -31
+    Fix for sockaddr_storage includes
+
+ChangeSet@1.1152.24.2, 2004-01-26 21:43:00-05:00, stenn@whimsy.udel.edu +2 -0
+  struct sockaddr_storage progress
+
+  configure.in@1.342, 2004-01-26 21:42:46-05:00, stenn@whimsy.udel.edu +0 -2
+    struct sockaddr_storage progress
+
+  include/ntp_rfc2553.h@1.13, 2004-01-26 21:42:47-05:00, stenn@whimsy.udel.edu +0 -2
+    struct sockaddr_storage progress
+
+ChangeSet@1.1152.24.1, 2004-01-25 22:14:09-05:00, stenn@whimsy.udel.edu +1 -0
+  Don't use IPv6 on AIX4.
+
+  configure.in@1.341, 2004-01-25 22:13:57-05:00, stenn@whimsy.udel.edu +10 -5
+    Don't use IPv6 on AIX4.
+
+ChangeSet@1.1152.22.6, 2004-01-22 20:59:27-05:00, stenn@whimsy.udel.edu +1 -0
+  Postpone the stuct sockaddr_storage test for now.
+
+  configure.in@1.340, 2004-01-22 20:59:18-05:00, stenn@whimsy.udel.edu +2 -0
+    Postpone the stuct sockaddr_storage test for now.
+
+ChangeSet@1.1152.22.5, 2004-01-22 17:49:57-05:00, stenn@whimsy.udel.edu +1 -0
+  Use doubles instead of NTP timestamps to work around the  34 year problem.  From Dave Mills.
+
+  ntpd/ntp_proto.c@1.168, 2004-01-22 17:49:28-05:00, stenn@whimsy.udel.edu +32 -21
+    Use doubles instead of NTP timestamps to work around the  34 year problem.  From Dave Mills.
+
+ChangeSet@1.1152.22.4, 2004-01-22 17:45:13-05:00, stenn@whimsy.udel.edu +2 -0
+  jitter utility fixes from Dave Mills.
+
+  util/jitter.c@1.4, 2004-01-22 17:42:39-05:00, stenn@whimsy.udel.edu +15 -16
+    Fixes from Dave Mills.
+
+  util/jitter.h@1.1, 2004-01-22 17:42:50-05:00, stenn@whimsy.udel.edu +412 -0
+
+  util/jitter.h@1.0, 2004-01-22 17:42:50-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /backroom/ntp-dev/util/jitter.h
+
+ChangeSet@1.1152.23.2, 2004-01-22 17:35:01-05:00, mayer@pogo.udel.edu +1 -0
+  L_RSHIFTU was mapped to M_RSHIFT instead of M_RSHIFTU
+
+  include/ntp_fp.h@1.8, 2004-01-22 17:34:04-05:00, mayer@pogo.udel.edu +1 -1
+    L_RSHIFTU was mapped to M_RSHIFT instead of M_RSHIFTU
+
+ChangeSet@1.1152.22.3, 2004-01-22 04:07:41+01:00, blk@frobozz.local +2 -0
+  nl.pl.in:
+    Better accounting for possible whitespace at the end of C routines (Bug 210).
+
+  BitKeeper/etc/logging_ok@1.42.1.1, 2004-01-22 04:07:34+01:00, blk@frobozz.local +1 -0
+    Logging to logging@openlogging.org accepted
+
+  ntpdc/nl.pl.in@1.8, 2004-01-22 04:05:55+01:00, blk@frobozz.local +1 -1
+    Better accounting for possible whitespace at the end of C routines (Bug 210).
+
+ChangeSet@1.1152.23.1, 2004-01-21 19:35:11-05:00, mayer@pogo.udel.edu +1 -0
+  eliminate no error select reporting
+
+  ntpdate/ntpdate.c@1.46, 2004-01-21 19:34:29-05:00, mayer@pogo.udel.edu +4 -7
+    eliminate no error select reporting
+
+ChangeSet@1.1152.22.2, 2004-01-10 21:10:11-05:00, stenn@whimsy.udel.edu +2 -0
+  initial attempt at more rfc2553 cleanup
+
+  configure.in@1.339, 2004-01-10 21:09:59-05:00, stenn@whimsy.udel.edu +87 -1
+    initial attempt at more rfc2553 cleanup
+
+  include/ntp_rfc2553.h@1.12, 2004-01-10 21:10:00-05:00, stenn@whimsy.udel.edu +2 -0
+    initial attempt at more rfc2553 cleanup
+
+ChangeSet@1.1152.14.10, 2004-01-10 02:27:07-05:00, stenn@pogo.udel.edu +2 -0
+  Fixes from Reg Clemens:
+  
+  Cleanup.
+  [Bug 233]
+  [Bug 246]
+  [Bug 260]
+
+  html/drivers/driver30.html@1.16, 2004-01-10 02:27:01-05:00, stenn@pogo.udel.edu +8 -8
+    Fixes from Reg Clemens:
+    
+    I have changed the documentation page for the ONCORE so it no longer
+    references Flag2/Flag3.
+
+  ntpd/refclock_oncore.c@1.47, 2004-01-10 02:27:01-05:00, stenn@pogo.udel.edu +104 -137
+    Fixes from Reg Clemens:
+    
+    some (minor) changes:
+       (a) some changes to messages printed.
+       (b) can now find config file in /etc/ntp/ as well as /etc/
+    
+    Bug 233: New LP64 Patches
+    patch imported from original author
+    
+    Bug 246: 3 issues with the ONCORE driver
+    (1) You can reset the ONCORE driver back to defaults by *reading*
+        the variables from across the net.
+    
+    This bug was introduced when I (foolishly) 'fixed' the code so it
+    would understand the FLAG variables that corresponded to its own
+    input variables from the ntp.ONCORE.x file.  Since I do NOT understand
+    all the implications of ntp_control, I will remove this 'fix'.
+    The variables can now only be set in ntp.ONCORE.  They can NOT be
+    changed dynamically.  The documentation will be changed back.  Perhaps
+    at some time in the future I will dig through the ntp code to
+    understand ntp_control.
+    
+    (2) Fudge acted upon AFTER ntp.ONCORE.
+    
+    Fixed by (1) the FUDGE flag/time variables are ignored, use the
+    ntp.ONCORE file.
+    
+    (3) In the driver, ONCORE_start and a few other procedures do not
+        produce any output in the clockstats file.
+    
+    The originator of the bug is running FreeBSD 5.1.
+    I have looked at the output from MY copy of FreeBSD 5.1, and several
+    Linux versions (7.3 -> 9), and Fedora and do NOT see any missing
+    messages.  The messages start with an "ONCORE DRIVER -- CONFIGURING"
+    message written when the driver is first entered, and contain all the
+    messages I would expect after that.
+    
+    I have no idea why he is not seeing the messages.
+    
+    No action.
+    
+    Bug 260, Patches for item (1) in the above.
+    
+    The patch purports to fix the problem in Bug 246.
+    
+    As noted I don't understand the details of what is going on behind the
+    curtain, so I would rather remove the offending code, than try to fix it.
+    
+    There is also an increase buffer size so that longer messages can be
+    sent to the clockstats file.  Ill leave that for the user to do on his
+    own if he wants to change the messages, but with slightly more effort
+    he could do the same using SHMEM.
+    
+    He found an error in determining the ONCORE M12/M12+T. (thanks)
+    Rather than his #ifdef, I have corrected the code.
+    
+
+ChangeSet@1.1152.19.3, 2004-01-08 18:21:43-05:00, mayer@pogo.udel.edu +1 -0
+  Make call to get_scopeid conditional
+
+  libisc/ifiter_ioctl.c@1.18, 2004-01-08 18:20:39-05:00, mayer@pogo.udel.edu +2 -1
+    Make call to get_scopeid conditional
+
+ChangeSet@1.1152.19.2, 2004-01-08 16:07:57-05:00, mayer@pogo.udel.edu +1 -0
+  Make fetch of broadcast address conditional on existence of macro
+
+  libisc/ifiter_ioctl.c@1.17, 2004-01-08 16:07:23-05:00, mayer@pogo.udel.edu +2 -1
+    Make fetch of broadcast address conditional on existence of macro
+
+ChangeSet@1.1152.1.56, 2004-01-08 17:55:23+00:00, mbrett@rgs16.fordson.demon.co.uk +1 -0
+  Makefile.am:
+    Remove $(NULL).  It has no effect.
+
+  util/Makefile.am@1.23, 2004-01-08 17:54:24+00:00, mbrett@rgs16.fordson.demon.co.uk +1 -2
+    Remove $(NULL).  It has no effect.
+
+ChangeSet@1.1152.1.55, 2004-01-08 13:36:54+00:00, mbrett@rgs16.fordson.demon.co.uk +2 -0
+  refclock_arc.c:
+    gcc lint for isdigit()
+
+  BitKeeper/etc/logging_ok@1.43, 2004-01-08 13:36:52+00:00, mbrett@rgs16.fordson.demon.co.uk +1 -0
+    Logging to logging@openlogging.org accepted
+
+  ntpd/refclock_arc.c@1.17, 2004-01-08 13:34:44+00:00, mbrett@rgs16.fordson.demon.co.uk +1 -1
+    gcc lint for isdigit()
+
+ChangeSet@1.1152.19.1, 2004-01-06 20:55:01-05:00, mayer@pogo.udel.edu +1 -0
+  Broadcast addresses were not being set for systems with IPv6 capability
+
+  libisc/ifiter_ioctl.c@1.16, 2004-01-06 20:54:15-05:00, mayer@pogo.udel.edu +21 -0
+    Broadcast addresses were not being set for systems with IPv6 capability
+
+ChangeSet@1.1152.18.1, 2004-01-06 21:19:51+01:00, a115350@y3111429.nh.ad.hydro.com +4 -0
+  Fix for NTP Epoch rollover
+
+  BitKeeper/etc/logging_ok@1.42, 2004-01-06 21:19:51+01:00, a115350@y3111429.nh.ad.hydro.com +1 -0
+    Logging to logging@openlogging.org accepted
+
+  libntp/caljulian.c@1.5, 2004-01-06 21:14:58+01:00, a115350@y3111429.nh.ad.hydro.com +32 -0
+    Fix for NTP epoch rollover: Uses time_t and 
+    localtime/gmtime for conversion
+
+  libntp/humandate.c@1.5, 2004-01-06 21:14:58+01:00, a115350@y3111429.nh.ad.hydro.com +5 -4
+    Fix for NTP epoch rollover: Uses time_t and 
+    localtime/gmtime for conversion
+
+  libntp/prettydate.c@1.4, 2004-01-06 21:14:58+01:00, a115350@y3111429.nh.ad.hydro.com +64 -9
+    Use common helper function
+
+ChangeSet@1.1152.1.51, 2004-01-02 16:01:53-05:00, stenn@whimsy.udel.edu +1 -0
+  manycast fix from Dave Mills.
+
+  ntpd/ntp_proto.c@1.167, 2004-01-02 16:01:41-05:00, stenn@whimsy.udel.edu +1 -1
+    manycast fix from Dave Mills.
+
+ChangeSet@1.1152.15.6, 2003-12-31 18:04:38-05:00, mayer@tecotoo.myibg.com +1 -0
+  Test Changes
+
+  ntpd/ntp_io.c@1.101.1.4, 2003-12-31 17:58:04-05:00, mayer@tecotoo.myibg.com +8 -4
+    Test Changes
+
+ChangeSet@1.1152.17.1, 2003-12-31 13:44:43-05:00, mayer@pogo.udel.edu +2 -0
+  Fix Broadcast support for those systems that support IPv6
+
+  libisc/ifiter_ioctl.c@1.15, 2003-12-31 13:43:31-05:00, mayer@pogo.udel.edu +3 -4
+    Fix Broadcast support for IPv6 capable queries to ioctl
+
+  ntpd/ntp_io.c@1.105, 2003-12-31 13:41:54-05:00, mayer@pogo.udel.edu +11 -10
+    Fix io_setbclient to properly use MACROS and add proper error information
+
+ChangeSet@1.1152.1.50, 2003-12-26 19:00:43-05:00, stenn@whimsy.udel.edu +1 -0
+  Dave Mills: Update EOV offset comment.
+
+  ntpd/ntp_control.c@1.65.1.1, 2003-12-26 19:00:31-05:00, stenn@whimsy.udel.edu +1 -1
+    Dave Mills: Update EOV offset comment.
+
+ChangeSet@1.1152.15.5, 2003-12-25 18:46:06-05:00, mayer@tecotoo.myibg.com +1 -0
+  EOV value was not updated when error was added
+
+  ntpd/ntp_control.c@1.66, 2003-12-25 18:44:52-05:00, mayer@tecotoo.myibg.com +1 -1
+    EOV value was not updated when error was added
+
+ChangeSet@1.1152.14.9, 2003-12-24 00:41:50-05:00, stenn@whimsy.udel.edu +4 -0
+  Cleanups, fix [Bug 320]
+
+  Makefile.am@1.45, 2003-12-24 00:38:57-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 230] Require automake-1.8.
+
+  acinclude.m4@1.12, 2003-12-24 00:39:20-05:00, stenn@whimsy.udel.edu +2 -2
+    Quote auto* stuff properly.
+
+  configure.in@1.336.1.1, 2003-12-24 00:40:35-05:00, stenn@whimsy.udel.edu +5 -4
+    Require autoconf-2.58.  Use version.m4.  Cleanup.
+
+  version.m4@1.2, 2003-12-24 00:40:05-05:00, stenn@whimsy.udel.edu +1 -1
+    4.2.0a
+
+  version.m4@1.1, 2003-12-24 00:10:17-05:00, stenn@whimsy.udel.edu +1 -0
+
+  version.m4@1.0, 2003-12-24 00:10:17-05:00, stenn@whimsy.udel.edu +0 -0
+    BitKeeper file /backroom/ntp-stable/version.m4
+
+ChangeSet@1.1152.14.8, 2003-12-20 20:28:35-05:00, stenn@whimsy.udel.edu +2 -0
+  [Bug 259] Marc Brett: lint
+
+  ntpd/refclock_arc.c@1.16, 2003-12-20 20:28:24-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 259] Marc Brett: lint
+
+  ntpd/refclock_neoclock4x.c@1.11, 2003-12-20 20:28:24-05:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 259] Marc Brett: lint
+
+ChangeSet@1.1152.14.7, 2003-12-20 20:18:51-05:00, stenn@whimsy.udel.edu +4 -0
+  [Bug 258] sntp cleanup
+
+  sntp/internet.c@1.3, 2003-12-20 20:15:55-05:00, stenn@whimsy.udel.edu +0 -2
+    [Bug 258] Matthias Drochner: sntp lint cleanup (plus IPv6 patch from HMS)
+
+  sntp/main.c@1.3, 2003-12-20 20:15:55-05:00, stenn@whimsy.udel.edu +18 -1
+    [Bug 258] Matthias Drochner: sntp lint cleanup (plus IPv6 patch from HMS)
+
+  sntp/socket.c@1.3, 2003-12-20 20:15:56-05:00, stenn@whimsy.udel.edu +7 -1
+    [Bug 258] Matthias Drochner: sntp lint cleanup (plus IPv6 patch from HMS)
+
+  sntp/timing.c@1.2, 2003-12-20 20:17:33-05:00, stenn@whimsy.udel.edu +2 -0
+    [Bug 258] Marc Brett: more sntp lint cleanup.
+
+ChangeSet@1.1152.14.6, 2003-12-20 18:44:12-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 262] Petter Reinholdtsen: Fix gcc3/Mac OS X output regexp for ntpdc/nl.pl
+
+  ntpdc/nl.pl.in@1.7, 2003-12-20 18:44:00-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 262] Petter Reinholdtsen: Fix gcc3/Mac OS X output regexp for ntpdc/nl.pl
+
+ChangeSet@1.1152.14.5, 2003-12-20 01:03:29-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 263] (NetBSD PR bin/23707)
+
+  ntpdate/ntpdate.c@1.45, 2003-12-20 01:02:39-05:00, stenn@whimsy.udel.edu +82 -78
+    Use #ifdef DEBUG where appropriate.
+
+  ntpdate/ntpdate.c@1.44, 2003-12-20 00:49:05-05:00, stenn@whimsy.udel.edu +69 -68
+    [Bug 263] Mattias Karlsson: ntpdate -s is not silent.  From NetBSD PR bin/23707
+
+ChangeSet@1.1152.16.1, 2003-12-19 15:44:14-05:00, stenn@whimsy.udel.edu +5 -0
+  [Bug 251] Timo Felbinger: Drop root under Linux
+
+  configure.in@1.337, 2003-12-19 15:43:27-05:00, stenn@whimsy.udel.edu +20 -2
+    [Bug 251] Timo Felbinger: Drop root under Linux
+
+  html/ntpd.html@1.32, 2003-12-19 15:43:27-05:00, stenn@whimsy.udel.edu +5 -1
+    [Bug 251] Timo Felbinger: Drop root under Linux
+
+  include/ntpd.h@1.61, 2003-12-19 15:43:27-05:00, stenn@whimsy.udel.edu +2 -1
+    [Bug 251] Timo Felbinger: Drop root under Linux
+
+  ntpd/cmd_args.c@1.23, 2003-12-19 15:43:28-05:00, stenn@whimsy.udel.edu +18 -10
+    [Bug 251] Timo Felbinger: Drop root under Linux
+
+  ntpd/ntpd.c@1.54, 2003-12-19 15:43:28-05:00, stenn@whimsy.udel.edu +106 -59
+    [Bug 251] Timo Felbinger: Drop root under Linux
+
+ChangeSet@1.1152.1.43, 2003-12-18 02:50:14-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 256] Fix misleading diagnostic message.
+
+  ntpd/ntp_config.c@1.100, 2003-12-18 02:49:58-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 256] Fix misleading diagnostic message.
+
+ChangeSet@1.1152.1.42, 2003-12-18 00:36:05-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 158] Alter header inclusion to avoid linux header braindamage.
+
+  libntp/iosignal.c@1.12, 2003-12-18 00:35:52-05:00, stenn@whimsy.udel.edu +19 -6
+    [Bug 158] Alter header inclusion to avoid linux header braindamage.
+
+ChangeSet@1.1152.1.41, 2003-12-17 23:35:26-05:00, stenn@whimsy.udel.edu +2 -0
+  Updates from Dave Mills.
+
+  html/confopt.html@1.28, 2003-12-17 23:35:12-05:00, stenn@whimsy.udel.edu +5 -6
+    Updates from Dave Mills.
+
+  html/ntpdc.html@1.20, 2003-12-17 23:35:12-05:00, stenn@whimsy.udel.edu +2 -2
+    Updates from Dave Mills.
+
+ChangeSet@1.1152.1.40, 2003-12-17 23:24:17-05:00, stenn@whimsy.udel.edu +2 -0
+  Dave Mills: novolley subcommand to the broadcast command.
+
+  ntpd/ntp_config.c@1.99, 2003-12-17 23:24:02-05:00, stenn@whimsy.udel.edu +8 -4
+    Dave Mills: novolley subcommand to the broadcast command.
+
+  ntpd/ntp_proto.c@1.166, 2003-12-17 23:24:02-05:00, stenn@whimsy.udel.edu +15 -18
+    Dave Mills: novolley subcommand to the broadcast command.
+
+ChangeSet@1.1152.1.39, 2003-12-16 16:22:11-05:00, stenn@whimsy.udel.edu +1 -0
+  Typo fix from Marc Brett
+
+  ntpd/ntp_io.c@1.104, 2003-12-16 16:21:57-05:00, stenn@whimsy.udel.edu +1 -1
+    Typo fix from Marc Brett
+
+ChangeSet@1.1152.15.4, 2003-12-14 21:45:10-05:00, mayer@tecotoo.myibg.com +1 -0
+  Unix didn't recognize BOOL in create_wildcard, use isc_boolean_t instead
+
+  ntpd/ntp_io.c@1.101.1.3, 2003-12-14 21:44:05-05:00, mayer@tecotoo.myibg.com +4 -3
+    Unix didn't recognize BOOL in create_wildcar, use isc_boolean_t instead
+
+ChangeSet@1.1152.15.3, 2003-12-14 11:50:12-05:00, mayer@tecotoo.myibg.com +1 -0
+  Print no interfaces message if debug is on
+
+  ntpd/ntp_io.c@1.101.1.2, 2003-12-14 11:49:13-05:00, mayer@tecotoo.myibg.com +7 -3
+    Print no interfaces message if debug is on
+
+ChangeSet@1.1152.15.2, 2003-12-13 22:02:59-05:00, mayer@tecotoo.myibg.com +1 -0
+  Clean up the open_socket code
+
+  ntpd/ntp_io.c@1.101.1.1, 2003-12-13 22:01:55-05:00, mayer@tecotoo.myibg.com +13 -8
+    Clean up the open_socket code
+
+ChangeSet@1.1152.15.1, 2003-12-13 21:38:39-05:00, mayer@tecotoo.myibg.com +1 -0
+  define lifr_index if platform uses if_laddrreq
+
+  libisc/ifiter_ioctl.c@1.14, 2003-12-13 20:28:38-05:00, mayer@tecotoo.myibg.com +1 -0
+    define lifr_index if platform uses if_laddrreq
+
+ChangeSet@1.1152.1.37, 2003-12-10 01:52:46-05:00, stenn@whimsy.udel.edu +1 -0
+  *ix doesn't do BOOL.
+
+  ntpd/ntp_io.c@1.102, 2003-12-10 01:52:27-05:00, stenn@whimsy.udel.edu +1 -1
+    *ix doesn't do BOOL.
+
+ChangeSet@1.1152.1.36, 2003-12-09 09:59:50-05:00, mayer@tecotoo.myibg.com +1 -0
+  IPV6_V6ONLY not dependent on IPTOS_LOWDELAY, etc
+
+  ntpd/ntp_io.c@1.101, 2003-12-09 09:58:45-05:00, mayer@tecotoo.myibg.com +1 -2
+    IPV6_V6ONLY not dependent on IPTOS_LOWDELAY, etc
+
+ChangeSet@1.1152.1.35, 2003-12-08 17:49:41-05:00, mayer@tecotoo.myibg.com +1 -0
+  Fix to only conditionally create a wildcard socket for IPv4 if IPV6_V6ONLY defined and no IPv4 stack
+
+  ntpd/ntp_io.c@1.100, 2003-12-08 15:00:51-05:00, mayer@tecotoo.myibg.com +25 -18
+    Fix to only conditionally create a wildcard socket for IPv4 if IPV6_V6ONLY defined
+
+ChangeSet@1.1152.1.34, 2003-12-07 19:09:45-05:00, mayer@tecotoo.myibg.com +2 -0
+  Fix to only get scope and zero address if Link-local Multicast address. Add scope information for interfaces
+
+  libisc/interfaceiter.c@1.9, 2003-12-07 19:04:48-05:00, mayer@tecotoo.myibg.com +7 -4
+    Fix to only get scope and zero address if Link-local Multicast address
+
+  ntpd/ntp_io.c@1.99, 2003-12-07 19:07:55-05:00, mayer@tecotoo.myibg.com +3 -2
+    Print scope information so we see it for interfaces we are handling
+
+ChangeSet@1.1152.1.33, 2003-12-03 23:33:46-05:00, mayer@tecotoo.myibg.com +1 -0
+  For KAME we need to fix the zeroing out of a couple of bytes. Fix to do it properly
+
+  libisc/interfaceiter.c@1.8, 2003-12-03 23:32:30-05:00, mayer@tecotoo.myibg.com +9 -2
+    For KAME we need to fix the zeroing out of a couple of bytes. Fix to do it properly
+
+ChangeSet@1.1152.1.32, 2003-12-03 22:24:47-05:00, mayer@tecotoo.myibg.com +1 -0
+  For KAME we need to fix the zeroing out of a couple of bytes. The wrong variable name got used
+
+  libisc/interfaceiter.c@1.7, 2003-12-03 22:23:28-05:00, mayer@tecotoo.myibg.com +2 -2
+    For KAME we need to fix the zeroing out of a couple of bytes. The wrong variable got used
+
+ChangeSet@1.1152.12.7, 2003-12-02 23:46:54-05:00, mayer@tecotoo.myibg.com +1 -0
+  if_index should have been ifindex
+
+  libisc/ifiter_sysctl.c@1.8, 2003-12-02 23:45:32-05:00, mayer@tecotoo.myibg.com +1 -1
+    if_index should have been ifindex
+
+ChangeSet@1.1152.1.29, 2003-12-01 04:09:21-05:00, stenn@whimsy.udel.edu +6 -0
+  Improvements from Dave Mills.
+
+  include/ntp_control.h@1.24, 2003-12-01 04:09:02-05:00, stenn@whimsy.udel.edu +15 -14
+    Improvements from Dave Mills.
+
+  include/ntpd.h@1.60, 2003-12-01 04:09:02-05:00, stenn@whimsy.udel.edu +3 -3
+    Improvements from Dave Mills.
+
+  ntpd/ntp_control.c@1.65, 2003-12-01 04:09:03-05:00, stenn@whimsy.udel.edu +20 -14
+    Improvements from Dave Mills.
+
+  ntpd/ntp_loopfilter.c@1.88, 2003-12-01 04:09:03-05:00, stenn@whimsy.udel.edu +24 -30
+    Improvements from Dave Mills.
+
+  ntpd/ntp_proto.c@1.165, 2003-12-01 04:09:03-05:00, stenn@whimsy.udel.edu +6 -6
+    Improvements from Dave Mills.
+
+  ntpd/ntp_refclock.c@1.52, 2003-12-01 04:09:04-05:00, stenn@whimsy.udel.edu +2 -3
+    Improvements from Dave Mills.
+
+ChangeSet@1.1152.12.6, 2003-11-30 22:23:45-05:00, mayer@tecotoo.myibg.com +1 -0
+  For KAME we need to zero out a couple of bytes in the address
+
+  libisc/interfaceiter.c@1.6, 2003-11-30 22:22:34-05:00, mayer@tecotoo.myibg.com +2 -0
+    For KAME we need to zero out a couple of bytes in the address
+
+ChangeSet@1.1152.12.5, 2003-11-29 21:24:54-05:00, mayer@tecotoo.myibg.com +2 -0
+  Fixes for older platforms not returning the interface index and not supporting IPv6
+
+  libisc/ifiter_ioctl.c@1.13, 2003-11-29 21:21:54-05:00, mayer@tecotoo.myibg.com +9 -0
+    Fix complaints about not finding ifr_index on older platforms
+
+  libisc/interfaceiter.c@1.5, 2003-11-29 21:23:06-05:00, mayer@tecotoo.myibg.com +2 -0
+    Fix warning on machines not supporting IPv6 to ignore the get_scopeid() function
+
+ChangeSet@1.1152.12.4, 2003-11-29 20:52:42-05:00, mayer@tecotoo.myibg.com +1 -0
+  Use scope id when address is link-local for IPv6 multicast IPV6_JOIN_GROUP
+
+  ntpd/ntp_io.c@1.98, 2003-11-29 20:51:08-05:00, mayer@tecotoo.myibg.com +9 -2
+    Use scope id when address is link-local for IPv6 multicast IPV6_JOIN_GROUP
+
+ChangeSet@1.1152.14.4, 2003-11-29 20:22:38-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 255] Lint cleanup
+
+  ntpd/ntp_loopfilter.c@1.87, 2003-11-29 20:22:22-05:00, stenn@whimsy.udel.edu +5 -1
+    [Bug 255] Lint cleanup
+
+ChangeSet@1.1152.14.3, 2003-11-29 19:18:51-05:00, stenn@whimsy.udel.edu +4 -0
+  [Bug 255] Lint cleanup
+
+  ntpd/refclock_hopfpci.c@1.10, 2003-11-29 19:09:20-05:00, stenn@whimsy.udel.edu +0 -8
+    [Bug 255] Lint clenaup in hopfpci.c
+
+  ntpd/refclock_neoclock4x.c@1.10, 2003-11-29 19:10:42-05:00, stenn@whimsy.udel.edu +0 -2
+    [Bug 255] Lint cleanup in neoclock4x
+
+  ntpdc/ntpdc.c@1.32, 2003-11-29 19:14:57-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 255] Lint cleanup in ntpdc.c
+
+  ntpq/ntpq.c@1.45, 2003-11-29 19:16:56-05:00, stenn@whimsy.udel.edu +2 -3
+    [Bug 255] Lint cleanup in ntpq.c
+
+ChangeSet@1.1152.14.2, 2003-11-29 18:53:20-05:00, stenn@whimsy.udel.edu +8 -0
+  [Bug 255] Lint cleanup (avoid HASH_* name collision)
+
+  include/ntp.h@1.95, 2003-11-29 18:52:38-05:00, stenn@whimsy.udel.edu +3 -3
+    [Bug 255] Lint cleanup (avoid HASH_* name collision)
+
+  include/ntp_request.h@1.23, 2003-11-29 18:52:42-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 255] Lint cleanup (avoid HASH_* name collision)
+
+  ntpd/ntp_control.c@1.64, 2003-11-29 18:52:54-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 255] Lint cleanup (avoid HASH_* name collision)
+
+  ntpd/ntp_peer.c@1.58, 2003-11-29 18:52:56-05:00, stenn@whimsy.udel.edu +17 -17
+    [Bug 255] Lint cleanup (avoid HASH_* name collision)
+
+  ntpd/ntp_proto.c@1.162.1.1, 2003-11-29 18:52:55-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 255] Lint cleanup (avoid HASH_* name collision)
+
+  ntpd/ntp_request.c@1.55, 2003-11-29 18:52:56-05:00, stenn@whimsy.udel.edu +4 -4
+    [Bug 255] Lint cleanup (avoid HASH_* name collision)
+
+  ntpd/ntp_timer.c@1.27, 2003-11-29 18:52:57-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 255] Lint cleanup (avoid HASH_* name collision)
+
+  ntpdc/ntpdc_ops.c@1.29, 2003-11-29 18:52:50-05:00, stenn@whimsy.udel.edu +2 -2
+    [Bug 255] Lint cleanup (avoid HASH_* name collision)
+
+ChangeSet@1.1152.14.1, 2003-11-29 18:07:18-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 254] Frederick Bruckman: Avoid the OSS emulation layer on NetBSD.
+
+  configure.in@1.336, 2003-11-29 18:07:00-05:00, stenn@whimsy.udel.edu +5 -1
+    [Bug 254] Frederick Bruckman: Avoid the OSS emulation layer on NetBSD.
+
+ChangeSet@1.1152.1.25, 2003-11-29 03:43:39-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 241] Dave Mills: Do not respond to multicast if not a manycast server.
+
+  ntpd/ntp_proto.c@1.163, 2003-11-29 03:43:26-05:00, stenn@whimsy.udel.edu +9 -3
+    [Bug 241] Dave Mills: Do not respond to multicast if not a manycast server.
+
+ChangeSet@1.1152.1.24, 2003-11-29 03:28:17-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 200] Apparently, variance data is stored squared, so we want to SQRT() it when we report it.
+
+  ntpd/ntp_request.c@1.54, 2003-11-29 03:27:53-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 200] Apparently, variance data is stored squared, so we want to SQRT() it when we report it.
+
+ChangeSet@1.1152.1.23, 2003-11-29 03:17:47-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 252] Matthias Drochner: uninitialized memory in ntp-keygen can lead to crashes.
+
+  util/ntp-keygen.c@1.25, 2003-11-29 03:17:22-05:00, stenn@whimsy.udel.edu +8 -7
+    [Bug 252] Matthias Drochner: uninitialized memory in ntp-keygen can lead to crashes.
+
+ChangeSet@1.1152.1.22, 2003-11-29 03:03:13-05:00, stenn@pogo.udel.edu +1 -0
+  Use our portable way of getting socklen
+
+  ntpd/refclock_nmea.c@1.22, 2003-11-29 03:03:01-05:00, stenn@pogo.udel.edu +1 -2
+    Use our portable way of getting socklen
+
+ChangeSet@1.1152.12.3, 2003-11-27 22:34:47-05:00, mayer@tecotoo.myibg.com +7 -0
+  Added support for scopeid and interface index in support of IPV6 multicasting.
+
+  include/isc/interfaceiter.h@1.3, 2003-11-27 22:33:40-05:00, mayer@tecotoo.myibg.com +2 -0
+    Added interface index and scope id to interface structure
+
+  include/ntp.h@1.92.1.2, 2003-11-27 22:33:44-05:00, mayer@tecotoo.myibg.com +2 -0
+    Added interface index and scope id to interface structure
+
+  libisc/ifiter_ioctl.c@1.12, 2003-11-27 22:33:46-05:00, mayer@tecotoo.myibg.com +4 -0
+    Added interface index and scope id to interface structure
+
+  libisc/ifiter_sysctl.c@1.7, 2003-11-27 22:33:49-05:00, mayer@tecotoo.myibg.com +3 -0
+    Added interface index and scope id to interface structure
+
+  libisc/interfaceiter.c@1.4, 2003-11-27 22:33:52-05:00, mayer@tecotoo.myibg.com +31 -0
+    Added get_scopeid function to fetch the scope and take care of KAME issues.
+
+  ntpd/ntp_io.c@1.97, 2003-11-27 22:33:58-05:00, mayer@tecotoo.myibg.com +6 -1
+    Copy the interface index and scope id into the interface structure. Use the scope d
+    to specify the scope and te interface index to join the group.
+
+  ports/winnt/libisc/interfaceiter.c@1.4, 2003-11-27 22:34:02-05:00, mayer@tecotoo.myibg.com +5 -0
+    Added interface index and scope id to interface. Zero for now.
+
+ChangeSet@1.1152.1.21, 2003-11-26 19:52:29-05:00, stenn@whimsy.udel.edu +1 -0
+  Document nmead support
+
+  html/drivers/driver20.html@1.12, 2003-11-26 19:52:15-05:00, stenn@whimsy.udel.edu +1 -0
+    Document nmead support
+
+ChangeSet@1.1152.13.5, 2003-11-26 19:21:41-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 202] From Jon Miner: nmead support
+
+  ntpd/refclock_nmea.c@1.21, 2003-11-26 19:21:26-05:00, stenn@whimsy.udel.edu +50 -2
+    [Bug 202] From Jon Miner: nmead support
+
+ChangeSet@1.1152.13.4, 2003-11-26 19:06:31-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 248] From Nigel Roles: Fix use of tcsetattr() and parsing.
+
+  ntpd/refclock_arc.c@1.15, 2003-11-26 19:06:18-05:00, stenn@whimsy.udel.edu +45 -5
+    [Bug 248] From Nigel Roles: Fix use of tcsetattr() and parsing.
+
+ChangeSet@1.1152.13.2, 2003-11-25 04:26:12-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 250] msec->nsec conversion bug to refclock_palisade.c (From Neil Burn)
+
+  ntpd/refclock_palisade.c@1.16.1.1, 2003-11-25 04:25:55-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 250] msec->nsec conversion bug to refclock_palisade.c (From Neil Burn)
+
+ChangeSet@1.1152.13.1, 2003-11-25 04:17:29-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 243] error handling bug in ntpdc (from Matthias Drochner)
+
+  ntpdc/ntpdc_ops.c@1.28, 2003-11-25 04:17:14-05:00, stenn@whimsy.udel.edu +18 -18
+    [Bug 243] error handling bug in ntpdc (from Matthias Drochner)
+
+ChangeSet@1.1152.12.2, 2003-11-24 09:24:33-05:00, mayer@tecotoo.myibg.com +1 -0
+  Time is in nsecs and not usecs. Multiplier was incorrect
+
+  ntpd/refclock_palisade.c@1.17, 2003-11-24 09:23:34-05:00, mayer@tecotoo.myibg.com +1 -1
+    Time is in nsecs and not usecs. Multiplier was incorrect
+
+ChangeSet@1.1152.12.1, 2003-11-24 09:18:06-05:00, mayer@tecotoo.myibg.com +1 -0
+  Fix structure name to use the generic name
+
+  include/ntp.h@1.92.1.1, 2003-11-24 09:16:55-05:00, mayer@tecotoo.myibg.com +1 -1
+    Fix structure name to use the generic name
+
+ChangeSet@1.1152.11.2, 2003-11-20 04:41:32-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 238] check for vsnprintf
+
+  configure.in@1.335, 2003-11-20 04:41:18-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 238] check for vsnprintf
+
+ChangeSet@1.1152.9.13, 2003-11-20 03:58:27-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 220] (Frederick Bruckman) The linux resolver needs more stack space.
+
+  ntpd/ntpd.c@1.53, 2003-11-20 03:58:05-05:00, stenn@whimsy.udel.edu +1 -1
+    [Bug 220] (Frederick Bruckman) The linux resolver needs more stack space.
+
+ChangeSet@1.1152.9.12, 2003-11-20 03:44:29-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 217] ntptrace should show sync distance, not rootdelay.
+
+  scripts/ntptrace.in@1.3, 2003-11-20 03:44:11-05:00, stenn@whimsy.udel.edu +6 -3
+    [Bug 217] ntptrace should show sync distance, not rootdelay.
+
+ChangeSet@1.1152.9.11, 2003-11-20 03:28:03-05:00, stenn@whimsy.udel.edu +1 -0
+  [Bug 215] Stop looking when we hit a refclock.
+
+  scripts/ntptrace.in@1.2, 2003-11-20 03:27:44-05:00, stenn@whimsy.udel.edu +1 -0
+    [Bug 215] Stop looking when we hit a refclock.
+
+ChangeSet@1.1152.9.10, 2003-11-19 21:12:51-05:00, stenn@whimsy.udel.edu +1 -0
+  Sledgehammer bug 230
+
+  util/Makefile.am@1.22, 2003-11-19 21:12:35-05:00, stenn@whimsy.udel.edu +4 -1
+    Sledgehammer bug 230
+
+ChangeSet@1.1152.9.9, 2003-11-19 10:07:45+00:00, harlanst@time.usno.navy.mil +4 -0
+  gpsvme updates from USNO
+
+  BitKeeper/deleted/.del-map_vme.c~3aed0663@1.5, 2003-11-19 10:04:09+00:00, harlanst@time.usno.navy.mil +0 -133
+    Delete: ntpd/map_vme.c
+
+  BitKeeper/etc/logging_ok@1.41, 2003-11-19 10:07:39+00:00, harlanst@time.usno.navy.mil +1 -0
+    Logging to logging@openlogging.org accepted
+
+  ntpd/Makefile.am@1.37, 2003-11-19 10:04:45+00:00, harlanst@time.usno.navy.mil +1 -1
+    map_vme.c is no more...
+
+  ntpd/refclock_gpsvme.c@1.7, 2003-11-19 10:06:43+00:00, harlanst@time.usno.navy.mil +244 -612
+    updated version from the USNO folks
+
+ChangeSet@1.1152.9.8, 2003-11-18 22:58:33-05:00, stenn@whimsy.udel.edu +2 -0
+  autoconf cleanup
+
+  configure.in@1.334, 2003-11-18 22:58:17-05:00, stenn@whimsy.udel.edu +2 -2
+    autoconf cleanup
+
+  sntp/configure.ac@1.7, 2003-11-18 22:58:18-05:00, stenn@whimsy.udel.edu +1 -1
+    autoconf cleanup
+
+ChangeSet@1.1152.10.2, 2003-11-11 02:55:22-05:00, stenn@whimsy.udel.edu +3 -0
+  [Bug 177] Fixes from Dave Mills.
+
+  libntp/systime.c@1.28, 2003-11-11 02:35:43-05:00, stenn@whimsy.udel.edu +6 -1
+    [Bug 177] Fixes from Dave Mills
+
+  ntpd/ntp_loopfilter.c@1.86, 2003-11-11 02:54:11-05:00, stenn@whimsy.udel.edu +20 -26
+    [Bug 177] Fixes from Dave Mills: state machine improvements.
+
+  ntpd/ntp_proto.c@1.162, 2003-11-11 02:52:25-05:00, stenn@whimsy.udel.edu +15 -7
+    [Bug 177] Fixes from Dave Mills: freq mgt and poll interval fixes.
+
+ChangeSet@1.1152.10.1, 2003-11-10 23:53:42-05:00, stenn@whimsy.udel.edu +2 -0
+  Stuff from Dave Mills
+
+  NEWS@1.47, 2003-11-10 01:08:47-05:00, stenn@whimsy.udel.edu +1 -0
+    Separate -dev news from -stable news.
+
+  include/ntp.h@1.93, 2003-11-10 01:28:10-05:00, stenn@whimsy.udel.edu +5 -5
+    Cleanup from Dave Mills
+
+ChangeSet@1.1152.9.6, 2003-11-08 20:32:39-05:00, mayer@tecotoo.myibg.com +1 -0
+  Ensure config.h is included in ntp_rfx2553.h before testing macros
+
+  include/ntp_rfc2553.h@1.11, 2003-11-08 20:30:05-05:00, mayer@tecotoo.myibg.com +6 -0
+    Ensure config.h is included before testing macros
+
+ChangeSet@1.1152.9.5, 2003-11-08 16:49:43-05:00, mayer@tecotoo.myibg.com +5 -0
+  Fixes to properly support platforms that do not have IPv6 support.
+
+  include/isc/ipv6.h@1.4, 2003-11-08 16:48:51-05:00, mayer@tecotoo.myibg.com +4 -2
+    Make IPv6 Macro definitions only if not previously defined.
+
+  include/ntp_rfc2553.h@1.10, 2003-11-08 16:48:56-05:00, mayer@tecotoo.myibg.com +2 -4
+    Change to only use the definitions if IPv6 not defined on the platform. This uses the
+    Macros defined during the config process which defines the Macro
+    ISC_PLATFORM_HAVEIPV6 if the platform properly supports IPv6
+
+  libntp/ntp_rfc2553.c@1.15, 2003-11-08 16:49:00-05:00, mayer@tecotoo.myibg.com +2 -2
+    Use ISC_PLATFORM_HAVEIPV6 instead of HAVE_IPV6 which was previously
+    defined in the ntp_rfc2553.h file based on the erroneously assumption about a
+    macro.
+
+  ports/winnt/include/isc/ipv6.h@1.3, 2003-11-08 16:49:04-05:00, mayer@tecotoo.myibg.com +4 -2
+    Make IPv6 Macro definitions only if not previously defined.
+
+  ports/winnt/include/isc/platform.h@1.3, 2003-11-08 16:49:06-05:00, mayer@tecotoo.myibg.com +5 -0
+    The ISC_PLATFORM_HAVEIPV6 macro should not have been defined here.
+    This was a vestige of the work being done to scan for IPv6 interfaces on
+    Windows platforms.
+
+ChangeSet@1.1152.9.4, 2003-11-07 21:27:53-05:00, mayer@pogo.udel.edu +1 -0
+  Change HAVE_IPV6 macro to ISC_PLATFORM_HAVEIPV6 since BIND 9 does a better job of figuring out what's needed for IPv6
+
+  ntpd/ntp_io.c@1.96, 2003-11-07 21:25:26-05:00, mayer@pogo.udel.edu +26 -26
+    Change HAVE_IPV6 macro to ISC_PLATFORM_HAVEIPV6 since BIND 9 does a better job of figuring out what's needed for IPv6
+
+ChangeSet@1.1152.9.3, 2003-11-02 23:18:29-05:00, mayer@tecotoo.myibg.com +1 -0
+  Fix setsockopt arguments to conform to standard declarations for various arguments
+
+  ntpd/ntp_io.c@1.95, 2003-11-02 23:17:43-05:00, mayer@tecotoo.myibg.com +4 -2
+    Fix setsockopt arguments to conform to standard declarations for various arguments
+
+ChangeSet@1.1152.9.2, 2003-10-31 23:23:43-05:00, mayer@tecotoo.myibg.com +2 -0
+  Fix for number of bytes and error message fixes (see Bugs #226 and 227)
+
+  ntpd/ntp_intres.c@1.32, 2003-10-31 23:22:50-05:00, mayer@tecotoo.myibg.com +13 -3
+    Need to use GetOverlapped result to get the number of bytes.
+
+  ports/winnt/ntpd/ntp_iocompletionport.c@1.10, 2003-10-31 23:22:56-05:00, mayer@tecotoo.myibg.com +9 -3
+    Error message fixes.
+
+ChangeSet@1.1152.9.1, 2003-10-26 10:20:36-05:00, mayer@tecotoo.myibg.com +7 -0
+  Update to OpenSSL 0.9.7c
+
+  BitKeeper/etc/ignore@1.35, 2003-10-26 10:19:50-05:00, mayer@tecotoo.myibg.com +7 -0
+    Added {ntpd/ntp_io.c.$$$} {ports/winnt/libntp/libntp.dsp.$$$} {ports/winnt/ntp-keygen/ntpkeygen.dsp.$$$} {ports/winnt/ntpd/ntpd.dsp.$$$} {ports/winnt/ntpdate/ntpdate.dsp.$$$} {ports/winnt/ntpdc/ntpdc.dsp.$$$} {ports/winnt/ntpq/ntpq.dsp.$$$} to the ignore list
+
+  ports/winnt/libntp/libntp.dsp@1.17, 2003-10-26 10:19:32-05:00, mayer@tecotoo.myibg.com +2 -2
+    Update to OpenSSL 0.9.7c
+
+  ports/winnt/ntp-keygen/ntpkeygen.dsp@1.4, 2003-10-26 10:19:35-05:00, mayer@tecotoo.myibg.com +4 -4
+    Update to OpenSSL 0.9.7c
+
+  ports/winnt/ntpd/ntpd.dsp@1.19, 2003-10-26 10:19:38-05:00, mayer@tecotoo.myibg.com +4 -4
+    Update to OpenSSL 0.9.7c
+
+  ports/winnt/ntpdate/ntpdate.dsp@1.12, 2003-10-26 10:19:40-05:00, mayer@tecotoo.myibg.com +2 -2
+    Update to OpenSSL 0.9.7c
+
+  ports/winnt/ntpdc/ntpdc.dsp@1.13, 2003-10-26 10:19:43-05:00, mayer@tecotoo.myibg.com +2 -2
+    Update to OpenSSL 0.9.7c
+
+  ports/winnt/ntpq/ntpq.dsp@1.13, 2003-10-26 10:19:46-05:00, mayer@tecotoo.myibg.com +2 -2
+    Update to OpenSSL 0.9.7c
+
+ChangeSet@1.1152.8.1, 2003-10-22 11:13:33-04:00, blu@corwin. +2 -0
+  ntpq_ops.c, ntpq.c:
+    Change formatting for multiple servers and add assID for multiple association output.
+
+  ntpq/ntpq.c@1.44, 2003-10-22 11:12:09-04:00, blu@corwin. +2 -0
+    Change formatting for multiple servers and add assID for multiple association output.
+
+  ntpq/ntpq_ops.c@1.19, 2003-10-22 11:12:55-04:00, blu@corwin. +38 -4
+    Change formatting for multiple servers and add assID for multiple association output.
+
+ChangeSet@1.1152.1.13, 2003-10-22 13:16:39+02:00, peda@sectra.se +1 -0
+  Fixes the bug for big endian machines, instead of killing the warning.
+
+  ntpd/refclock_jupiter.c@1.17, 2003-10-22 13:16:36+02:00, peda@sectra.se +5 -5
+    Fixes the bug for big endian machines, instead of killing the warning.
+
+ChangeSet@1.1152.1.12, 2003-10-22 13:12:10+02:00, peda@sectra.se +1 -0
+  Clean up PPS handling in jupiter driver.
+  Easier to modify source to get hardpps.
+
+  ntpd/refclock_jupiter.c@1.16, 2003-10-22 13:12:08+02:00, peda@sectra.se +13 -12
+    Clean up PPS handling.
+    Easier to modify source to get hardpps.
+
+ChangeSet@1.1152.1.11, 2003-10-22 13:08:28+02:00, peda@sectra.se +1 -0
+  Remove annying newline from syslog in the jupiter refclock.
+
+  ntpd/refclock_jupiter.c@1.15, 2003-10-22 13:08:26+02:00, peda@sectra.se +1 -1
+    Remove annying newline from syslog.
+
+ChangeSet@1.1152.1.10, 2003-10-20 15:10:02-04:00, stenn@whimsy.udel.edu +1 -0
+  Added IPv6 to NEWS file.
+
+  NEWS@1.46, 2003-10-20 15:08:18-04:00, stenn@whimsy.udel.edu +1 -0
+    Added IPv6
+
+ChangeSet@1.1140.1.4, 2003-08-13 10:00:10-07:00, gnu@ring.wraith.sf.ca.us +1 -0
+  dot-in-path fix
+
+  ntpdc/Makefile.am@1.16.1.1, 2003-08-11 14:44:20-07:00, gnu@ring.wraith.sf.ca.us +1 -1
+    no-dot-in-path fix for ntpdc-layout
+
+ChangeSet@1.1140.1.1, 2003-08-10 00:13:06-07:00, gnu@ring.wraith.sf.ca.us +1 -0
+  Merge bk://ntp.bkbits.net/ntp-dev
+  into ring.wraith.sf.ca.us:/home/gnu/src/ntp/ntp-dev
+
+  BitKeeper/etc/gone@1.6, 2003-08-10 00:07:52-07:00, gnu@ring.wraith.sf.ca.us +1 -0
+
+  BitKeeper/etc/gone@1.5, 2003-08-10 00:06:29-07:00, gnu@ring.wraith.sf.ca.us +1 -0
+
diff --git a/CommitLog-4.1.0 b/CommitLog-4.1.0
new file mode 100644 (file)
index 0000000..c0ce2d8
--- /dev/null
@@ -0,0 +1,6152 @@
+2001-08-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.1.0
+
+2001-07-27  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c (oncore_start): Set pps_enable=1, just
+       like the atom driver does.
+       From: reg@dwf.com
+
+       * ntpd/refclock_nmea.c (nmea_ppsapi): Set pps_enable=1, just like
+       the atom driver does.
+       From: Scott Allendorf <sca@newton.physics.uiowa.edu>
+
+       * ntpd/ntp_config.c (getconfig): CONF_CLOCK_PANIC was using the
+       wrong config flag.
+       From: <justin_forrester@hp.com>
+
+2001-07-10  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99m-rc3
+
+2001-07-06  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntp_update: COPYRIGHT needs a touch.
+       From: Mike Stump <mrs@kithrup.com>
+
+2001-07-04  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/config.htm: Major cleanup.
+       From: Martin Janzen <janzen@pixelmetrix.com>    
+
+       * configure.in (rt library check): Don't look for -lrt under
+       Linux.  Under glibc-2.1.2 and -2.2.2 (at least), the POSIX-
+       compatibility real-time library does strange things with threads
+       as other processes and we're getting lots of complaints about it.
+       Reported by: Juha Sarlin <juha@c3l.com>
+       
+2001-06-30  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/driver35.htm: Update email address.
+
+2001-06-25  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c (oncore_msg_BaEaHa): Fix wrong offset for
+       rsm.bad_almanac
+       From: Reynir Siik <reynir@royal.net>
+
+2001-06-12  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99m-rc2
+
+2001-06-10  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_config.c:
+       * include/ntp_config.h: includefile config keyword support
+       From: Dean Gibson <timekeeper@tcp-udp.net>
+
+2001-06-08  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99m-rc1b
+
+       * ntpd/refclock_true.c (true_debug): Bump some buffer sizes to
+       reduce/eliminate chance of buffer overflow.  Use snprintf()
+       instead of sprintf().  Do a better job of opening the debug file.
+       * ntpd/ntp_control.c (ctl_getitem): Count overflow packets as bad
+       and return a BADFMT.
+       * ntpd/ntp_config.c (save_resolve): call fdopen() with the correct
+       mode.
+       From: Bela Lubkin <belal@sco.com>
+
+2001-06-03  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntp.h (RES_ALLFLAGS): Add RES_DEMOBILIZE.
+       From: Dean Gibson <timekeeper@tcp-udp.net>
+
+       * configure.in: 4.0.99m-rc1a
+
+2001-06-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_refclock.c (refclock_open): Add O_NOCTTY to the open()
+       flags when opening a serial port.
+       Reported by: joseph lang <tcnojl1@earthlink.net>
+
+2001-05-31  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/notes.htm: Typo fix.
+       From: John Stone <johns@ks.uiuc.edu>
+
+       * configure.in: 4.0.99m-rc1
+
+       * html/monopt.htm: Typo fix.
+       * html/confopt.htm: Cruft removal.
+       From: John Stone <johns@ks.uiuc.edu>
+
+2001-05-30  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * README.cvs: More updates and cleanup.
+
+       * ntpd/ntp_loopfilter.c (loop_config): 
+       Check against STA_NANO instead of (NTP_API > 3) to catch kernels
+       that were rolled while the spec was evolving.
+       From: John.Hay@icomtek.csir.co.za
+
+       * README.cvs: Note that we want to check out NTP into a clean
+       subdir.
+       Reported by jrd@cc.usu.edu (Joe Doupnik)
+
+2001-05-27  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k40
+
+       * include/ntp_refclock.h: Median Filter (SAMPLE - macro) - change
+       to use most recent MAXSTAGE entries when the filter overflows (ie
+       driver poking say once per second with poll > MAXSTAGE) rather
+       than blocking after MAXSTAGE entries (turf oldest rather than turf
+       most recent).
+       From: John Woolner <vk1et@tpg.com.au>
+
+       * ntpd/refclock_true.c:
+          a. Don't cream pp->a_lastcode when we get a <cr><lf> pair 
+          b. Fix up pp->leap handling to work correctly 
+          c. clear CEVNT_BADTIME etc warnings when we get good clock 
+       CEVNT_NOMINAL. 
+       From: John Woolner <vk1et@tpg.com.au>
+
+       * kernel/sys/pcl720.h:
+       Add support for the XL clock to refclock_true.c 
+       From: Paul A Vixie <vixie@mfnx.net> 
+
+       * ntpd/ntp_loopfilter.c (local_clock): One more attempt at
+       "improving" the panic message.
+
+2001-05-26  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_cv_func_ctty_for_f_setown): BSDI3 needs a ctty
+       for F_SETOWN, too.
+       From: Paul A Vixie <vixie@mfnx.net>
+
+2001-05-24  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/ntpd.htm: Typo.
+       From: John Stone <johns@ks.uiuc.edu>
+
+2001-05-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k39
+
+       * ntpd/ntp_loopfilter.c (local_clock): huffpuff cleanup/improvements.
+       (huffpuff): Cleanup/improvements.
+       (loop_config): huffpuff initialization cleanup/improvements.
+       From: Dave Mills, Terje, Mark, and John?
+
+2001-05-22  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/release.htm:
+       * html/ntpd.htm:
+       * html/miscopt.htm:
+       From: Dave Mills: Updates.
+
+2001-05-21  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k38
+
+       * ntpd/ntp_proto.c (clock_filter): Huff-n-Puff and Popcorn
+       improvements.
+       * ntpd/ntp_loopfilter.c (local_clock): Debug cleanup
+       From: Dave Mills.
+
+       * include/ntp_syscall.h (ntp_gettime): Updated patch from Ulrich.
+       My original attempt was not backwards compatible.
+
+2001-05-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntp_syscall.h (ntp_gettime): Fill in the tai member.
+       From: Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
+
+       * configure.in: 4.0.99k37
+
+       * ntpd/ntp_proto.c (clock_filter): Lose "off", xtemp and ytemp,
+       and some obsoleted calculations.  Set the peer->offset and
+       peer->delay from the filter stages.
+
+       * ntpd/ntp_loopfilter.c: Comment/document improvements.
+       (local_clock): correct the offset by one-half the difference
+       between the sample delay and minimum delay.  Lose "mu" from the
+       debug message.
+       From: Dave Mills.
+
+2001-05-15  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k36
+
+       * ntpd/ntp_loopfilter.c: Huff-n-puff cleanup
+       From: Dave Mills.
+
+2001-05-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k35
+
+       * ntpd/refclock_atom.c (atom_ppsapi): set pps_enable=1 if
+       enb_hardpps.
+       * ntpd/ntp_timer.c: huffpuff support.
+       (init_timer): huffpuff support.
+       (timer): huffpuff support.
+       * ntpd/ntp_proto.c (init_proto): Initialize pps_enable to 0, not 1.
+       * ntpd/ntp_loopfilter.c (CLOCK_HUFFPUFF): Added.
+       Add huff-n-puff filter variables.
+       (local_clock): Lose "pps sync enabled" log noise.
+       (huffpuff): Added.
+       (loop_config): LOOP_MINPOLL and LOOP_ALLAN were missing the
+       trailing break; add LOOP_HUFFPUFF.
+       * ntpd/ntp_config.c: tinker huffpuff added.
+       (getconfig): CONF_CLOCK_HUFFPUFF support.
+       * include/ntpd.h: huffpuff() declaration.
+       * include/ntp_config.h (CONF_CLOCK_HUFFPUFF): Added.
+       * include/ntp.h (HUFFPUFF): Added.
+       (LOOP_HUFFPUFF): Added.
+       From: Dave Mills.
+
+2001-05-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/driver20.htm: Reality check.
+       * ntpd/refclock_nmea.c: Comment cleanup
+       From: John Woolner <vk1et@tpg.com.au>
+
+       * html/release.htm: Cleanup (at least).
+       * html/refclock.htm: Cleanup (at least).
+       * html/kern.htm: Cleanup (at least).
+       * html/index.htm: Cleanup (at least).
+       * html/extern.htm: Cleanup (at least).
+       * html/driver1.htm: Cleanup (at least).
+       * html/debug.htm: Cleanp (at least).
+       * html/accopt.htm: KoD documentation update.
+       From: Dave Mills.
+
+       * configure.in: 4.0.99k34
+
+       * ntpd/ntp_util.c (record_loop_stats): values are now passed in.
+       * ntpd/ntp_loopfilter.c (local_clock): pass the values to
+       record_loop_stats().
+       * include/ntpd.h: Pass the parameters in to record_loop_stats().
+       With the discipline loop opened (disable ntp) the local clock
+       updates were not being sent to loopstats. That now is.
+       From: Dave Mills.       
+
+2001-05-10  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k33
+
+       * ntpd/ntp_proto.c (receive): Validate the source port.  Lose
+       NTPv1 support.
+       * ntpd/ntp_loopfilter.c (local_clock): Sanity check sys_poll
+       earlier instead of later.
+       From: Dave Mills.
+
+       * ntpd/refclock_oncore.c (oncore_msg_any): We don't always have
+       GETTIMEOFDAY().
+
+2001-05-09  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_shm.c (shm_poll): Apply JAN_1970 correction after
+       calling TVTOTS(), just like everybody else does.
+       From: David Malone <dwmalone@maths.tcd.ie>
+
+       * ntpd/refclock_ulink.c: fixed 33x quality flag, added more
+       debugging stuff, updated 33x time code explanation.
+       From: s.l.smith (via j.c.lang).
+
+2001-05-08  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k32
+
+       * ntpd/ntp_loopfilter.c: rstclock now takes a 3rd argument, the
+       last offset.
+       (init_loopfilter): Use it.
+       (local_clock): Use it.  Clean up the code.
+       (loop_config): Use it.
+       (rstclock): Implement it.  Clean up the code.
+       From Dave Mills.
+
+2001-05-06  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k31
+
+       * ntpdc/ntpdc_ops.c (sysstats): That's 'bad packet format'
+       (instead of '... length'), and 'packets rejected' (instead of
+       'limitation rejects'.
+       * ntpd/ntp_proto.c (receive): PUBKEY fixes.  Move KoD stuff to
+       process_packet().
+       (process_packet):  Move KoD stuff here... 
+       (peer_clear): Unspec the stratum, too.
+       (clock_filter): Don't update peer->epoch here.  Fix the filter
+       test when checking the epoch.
+       (fast_xmit): Send back STRATUM_UNSPEC on a KoD packet.
+       (init_proto): Initialize sys_jitter.
+
+       * ntpd/ntp_loopfilter.c: rstclock() takes 2 parameters now.
+       (init_loopfilter): Use it...
+       (local_clock): Ditto, and change the "mu" calculation.  Improve
+       the jitter test in S_SYNC.  Use peer->epoch (not current_time) to
+       update the last_time.  Update debug info.
+       (rstclock): 2nd arg - the epoch to use.  Use it.
+       (loop_config): update call to rstclock.
+       From: Dave Mills.
+
+2001-05-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ports/winnt/ntpd/ntpd.dsp: Add cmd_args.c
+       From: Wink Saville <wink@saville.com>
+
+2001-04-29  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpq/ntpq.c (tstflags): 11 now.
+       From: John Cochran <jdc@fiawol.org>
+
+       * ntpd/ntp_proto.c (receive): KoD updates.  Improve the comments.
+       Lose the AM_PROCPKT restrictions test.
+       (peer_xmit): Check/report on no encryption key in packet.
+       (fast_xmit): Use peer_xmit's new packet length check code.
+       From  Dave Mills.
+
+2001-04-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k30
+
+2001-04-27  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpdc/ntpdc_ops.c: Added "kod", lost "demobilize".
+       * ntpd/ntp_config.c: Added "kod" keyword.  Lose "demobilize" keyword.
+       * html/release.htm: Updated.
+       * html/accopt.htm: Updated.
+       From: Dave Mills.
+
+       * ntpq/ntpq.c: Reorder and add some TEST flag bits.
+       * ntpd/ntp_proto.c (transmit): Also bail if access denied.
+       (receive): Lose RES_DEMOBILIZE and (some?) RES_DONTSERVE and
+       RES_LIMITIED stuff.  Update Kiss-Of-Death (KoD) docs.
+       Call fast_xmit with new 3rd parameter (restrict_mask).
+       Before checking for an authentic packet, check the restrict_mask
+       for RES_{DONTSERVE,LIMITED,NOPEER}.
+       Check restrictions in AM_PROCPKT case.
+       (peer_clear): Don't lose the stratum if the peer->flags don't
+       indicate FLAG_REFCLOCK.
+       (fast_xmit): Take restrict mask as a new argument, and handle
+       KoD.  Reorder some code.
+       From: Dave Mills.
+
+2001-04-26  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpdc/ntpdc_ops.c: restrict/unrestrict support for version and
+       demobilize.  Implement demobilze.
+       * ntpd/ntp_proto.c (receive): Improve version testing, including
+       RES_DEMOBILIZE support.
+       (fast_xmit): Patches to kiss-of-death packet.
+       * ntpd/ntp_loopfilter.c (local_clock): S_SYNC case now also checks
+       abs(clock_offset) against CLOCK_PGATE*sys_jitter.
+       * ntpd/ntp_config.c: CONF_RES_DEMOBILIZE/demobilize support.
+       * include/ntp_config.h (CONF_RES_DEMOBILIZE): Added.
+       * include/ntp.h (RES_DEMOBILIZE): Added.
+       From Dave Mills.
+
+2001-04-25  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/accopt.htm: Document the "version" parameter
+       From Dave Mills.
+
+       * ntpd/ntp_proto.c (fast_xmit): Implement DENY mode.
+       From Dave Mills.
+
+       * ntpd/ntp_config.c: Add the "allan" tinker variable.
+       From: Juha Sarlin <juha@c3l.tyreso.se>
+
+       * ntpd/refclock_hopfpci.c (hopfpci_start): Lose the "correct_any"
+       stuff - it's both obsolete and wrong.
+
+       * ntpd/ntp_proto.c (receive): Keep track of packet versions.
+       Implement RES_LIMITED.
+       * include/ntp_config.h (CONF_RES_LIMITED): 
+       * include/ntp.h (RES_LIMITED): Leave the bits in the original
+       order.
+       From Dave Mills.
+
+       * util/timetrim.c:
+       * util/Makefile.am:
+       * ntpdc/ntpdc_ops.c:
+       * ntpd/refclock_nmea.c:
+       * libntp/snprintf.c:
+       * configure.in:
+       * configure:
+       * config.h.in:
+       * aclocal.m4:
+       * acconfig.h:
+       Lint cleanup from: Marc Brett <mbrett@rgs0.london.waii.com>
+
+       * ntpd/ntp_config.c: Add "version" support.
+       (getconfig): version support.
+       * include/ntp_config.h (CONF_RES_VERSION): Added.
+       * include/ntp.h (RES_VERSION): Added.
+       From: Dave Mills.
+
+       * include/ntp_machine.h (ifreq): WinNT cleanup
+
+2001-04-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k29
+
+       * html/miscopt.htm: Document the "allan" tinker variable.
+       * ntpd/ntp_proto.c (clock_filter): Update comments.  Lose etemp;
+       we now use allan_xpt for this.
+       * ntpd/ntp_loopfilter.c: Added allan_xpt as a tinker variable.
+       Reorganize variables and improve comments.
+       (local_clock): Improve comments, use (new) allan_xpt instead of
+       CLOCK_ALLAN.  Fix test in S_SYNC state.  Update debug info.
+       (rstclock): No longer force allan_xpt to CVLOCK_ALLAN in S_FREQ,
+       S_SYNC, or default case.
+       (loop_config): Document dangerous tinker variables, and add
+       LOOP_ALLAN to the list.
+       * include/ntp_config.h (CONF_CLOCK_ALLAN): Added.
+       * include/ntp.h (LOOP_ALLAN): Added.
+       Allan intercept fixes from Dave Mills.
+
+       * scripts/mkver.in: Use the C locale so  the dates come out in a
+       consistent format.
+       From: ASANO Naoyuki <n_asano@imjp.co.jp>
+
+       * build: Run "config.status" before the "make" because it probably
+       saves time and trouble.  Probably...
+
+       * flock-build: Try building sequentially.
+
+2001-04-22  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_cv_make_tickadj): Fix it right...
+
+       * util/ntp-genkeys.c: extern config_netinfo, too.
+
+       * util/hist.c:
+       * ntptrace/ntptrace.c:
+       * ntpq/ntpq.c:
+       * ntpdc/ntpdc.c:
+       * ntpdate/ntptimeset.c:
+       * ntpdate/ntpdate.c:
+       * ntpd/refclock_parse.c:
+       * ntpd/refclock_msfees.c:
+       * ntpd/refclock_jupiter.c:
+       * ntpd/ntp_refclock.c:
+       * ntpd/ntp_io.c:
+       * libparse/clk_wharton.c:
+       * libparse/clk_varitext.c:
+       * libparse/clk_trimtaip.c:
+       * libparse/clk_schmid.c:
+       * libparse/clk_rcc8000.c:
+       * libparse/clk_rawdcf.c:
+       * libparse/clk_meinberg.c:
+       * libparse/clk_hopf6021.c:
+       * libparse/clk_dcf7000.c:
+       * libparse/clk_computime.c:
+       Lint.  From: Simon Burge <simonb@wasabisystems.com>
+
+2001-04-21  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_nmea.c (nmea_receive): Fixes.
+       From: John Woolner <vk1et@tpg.com.au>
+
+       * util/ntp-genkeys.c: Declare check_netinfo, don't define it.
+       From: Jack Bryans <jbryans@csulb.edu>
+
+       * configure.in (RSASRCS): rsaref2 needs digit.h (I thought I fixed
+       this already).
+       
+       * configure.in (CFLAGS): Disable -Wconversion, enable
+       -Wmissing-prototypes, and allow for -Werror.
+       From: Simon Burge <simonb@wasabisystems.com>
+
+       * util/ntp-genkeys.c (main): Reset the standard mask so the
+       symlinks are created with the standard mask.
+
+       * configure.in: 4.0.99k28
+
+       * ntpd/ntpd.c (ntpdmain): Use mode_t for umask value.
+
+       * util/ntp-genkeys.c: Create files with the right umask.
+
+       * util/ntp-genkeys.c: config_file should be declared, not defined.
+       * ntpd/refclock_mx4200.c (mx4200_pps): debug cleanup.
+       * ntpd/refclock_hopfser.c: If we're not using it, provide the _bs.
+       * ntpd/refclock_heath.c (heath_receive): Add missing "break"
+       statements.
+       * ntpd/ntp_proto.c: Lose extra definition of mode_ntpdate.
+       * librsaref/Makefile.am (nodist_librsaref_a_SOURCES): Put RSASRCS
+       on the same line as rsaref.h to improve portability.
+       * libntp/msyslog.c: Lint cleanup.
+       From: Marc.Brett@westerngeco.com
+
+       * util/ntp-genkeys.c:
+       * ntpdate/ntpdate.c:
+       * ntpd/ntp_config.c: Netinfo header reorder.
+       From: Jack Bryans <jbryans@csulb.edu>
+
+       * configure.in: timespec can be found by looking in goofy places
+       under SunOS.
+
+2001-04-20  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_nmea.c:  PPSAPI cleanup, default to RMC sentences,
+       handle milliseconds, multiple sentences, other good stuff.
+       From: John Woolner <vk1et@tpg.com.au>, Marc.Brett@westerngeco.com,
+       John.Hay@icomtek.csir.co.za
+
+       * ntpd/ntp_proto.c (receive): In the AM_NEWBCL case, return in all
+       cases at the end.
+       * ntpd/ntp_peer.c (newpeer): Check cast_flags against MDF_BCLNT,
+       not against MDF_BCAST.
+       * ntpd/ntp_loopfilter.c (local_clock): Lose debug info.
+       * ntpd/ntp_crypto.c (crypto_recv): Bugfix.
+       From: Dave Mills.
+
+       * configure.in: 4.0.99k27
+
+       * ntpd/ntp_loopfilter.c (local_clock): Check clock_panic > 0.
+       Check clock_max > 0.
+       * html/ntpd.htm: Cleanup.
+       * html/miscopt.htm: Cleanup.
+       * html/confopt.htm: Cleanup minpoll documentation.
+       From: Dave Mills.
+
+2001-04-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/cmd_args.c (getstartup): check_netinfo needs an extern
+       declaration.
+       Reported by: Jack Bryans <jbryans@csulb.edu>
+
+       * configure.in (ac_cv_make_timetrim): Added.
+       * util/Makefile.am (bin_PROGRAMS): MAKE_TIMETRIM
+       Requested by: Jack Bryans <jbryans@csulb.edu>
+
+       * configure.in: 4.0.99k26
+
+       * util/ntp-genkeys.c:
+       * ntpd/refclock_oncore.c:
+       * ntpd/ntp_peer.c:
+       * libntp/msyslog.c:
+       * libntp/audio.c:
+       Lint cleanup.
+       From: Simon Burge <simonb@wasabisystems.com>
+
+       * ntpd/ntp_loopfilter.c (local_clock): debug message improvements
+       from Dave Mills.
+
+       * libntp/emalloc.c (emalloc): Tell people we are exiting if we log
+       an out-of-memory condition.
+
+       * util/ntp-genkeys.c (main): Don't allow '#' in a generated MD5
+       key.  Reported by: Dave Tyson <Dave.Tyson@liverpool.ac.uk>
+
+2001-04-18  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (clock_update): minpoll cleanup.
+       (clock_select): minpoll cleanup.
+       (clock_filter): Bugfixes from Mark Martinec <Mark.Martinec@ijs.si>
+       * ntpd/ntp_loopfilter.c (rstclock): minpoll cleanup.  Debug cleanup.
+       * ntpd/ntp_config.c (getconfig): Initialize/bounds check minpoll
+       using NTP_MINDPOLL insted of sys_minpoll.
+       From: Dave Mills.
+
+2001-04-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/msyslog.c:
+       * ElectricFence/page.c (stringErrorReport): Follow Rainer's lead
+       and use strerror().
+
+       * ntpd/refclock_shm.c (shm_start): Always use strerror. 
+       * libntp/msyslog.c (msyslog): Use strerror if present. 
+       From: Rainer Orth  <ro@TechFak.Uni-Bielefeld.
+       
+       * ntpd/ntp_config.c (getconfig): Read stratum fudge value into 
+       long variable.
+       From: Rainer Orth <ro@TechFak.Uni-Bielefeld.DE> 
+
+       * libparse/parsesolaris.c (rdchar): Cast ~0 to unsigned long. 
+       * libntp/buftvtots.c (buftvtots): Allow for 8-byte tv_sec, tv_usec 
+       in struct timeval.
+       From: Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+2001-04-16  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_config.c (getconfig): move "tinker" so it's generally
+       available.
+
+2001-04-15  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Look for getclock().
+
+       * ntpd/ntp_config.c (getconfig): Squawk if provided minpoll or
+       maxpoll values are out of range.
+
+       * ntpd/ntp_proto.c (poll_update): Some operations can only be done
+       if we're compiling with some REFCLOCKs.
+       From Dave Mills.
+
+       * configure.in (RSASRCS): Added.
+       * librsaref/Makefile.am (nodist_librsaref_a_SOURCES): Use RSASRCS.
+
+       * configure.in: Limit the DECL_HSTRERROR_0 to aix4.3.*.  RSN, we
+       could also limit it to xlc...
+
+       * configure.in: 4.0.99k25
+
+       * html/leap.htm: Added.
+       * html/index.htm: Update.
+       * html/driver7.htm: Update.
+       * html/driver6.htm: Update.
+       * html/driver36.htm: Update.
+       * html/audio.htm: Update.
+       * html/y2k.htm: Removed.
+       From Dave Mills.
+
+2001-04-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * acconfig.h: Lose extra declarations of PACKAGE and VERSION.
+
+       * acconfig.h: 
+       * configure.in:
+       * include/l_stdlib.h: DECL_HSTRERROR_0 needed for xlc under AIX 4.3.2.
+       Reported by: Harald Barth <haba@pdc.kth.se>
+
+       * ntpd/ntp_proto.c (proto_config): cal_enable (PROTO_CAL) is
+       invalid if no refclocks are present.
+       From: Frodo Looijaard <frodol@dds.nl>
+
+       * README.cvs: On some systems, the -C option fails.
+
+       * ntpd/refclock_nmea.c:
+       * ntpd/ntp_refclock.c:
+       * html/driver20.htm:
+       PPSAPI patches for NMEA driver.
+       From: John.Hay@icomtek.csir.co.za
+
+        * README.rsa: Describe RSAEuro support, provide alternate rsa.c 
+       patch. 
+       * configure.in: Check for rsaeuro1, RSAOBJS, RSADIR respectively. 
+       * html/build.htm: Hint at rsaeuro1 directory. 
+       * include/global.h (BYTE): Define. 
+       * librsaref/Makefile.am (nodist_librsaref_a_SOURCES): Removed rsaref2 
+       specific sources. 
+       (librsaref_a_LIBADD): Add appropriate objects. 
+       (librsaref_a_DEPENDENCIES): Work around automake limitation. 
+       (stamp-rsaref): Use RSADIR. 
+       * scripts/README: Document ntp-close. 
+       * scripts/Makefile.am (EXTRA_DIST): Distribute it. 
+       * Makefile.am (DISTCLEANFILES): Remove .warning.
+       * librsaref/Makefile.am (DISTCLEANFILES): Remove copied/touched
+       librsaref sources, stamp-rsaref.
+       * ntpdate/Makefile.am (DISTCLEANFILES): Remove version.c.
+       * ntpq/Makefile.am (DISTCLEANFILES): Likewise.
+       * parseutil/Makefile.am (DISTCLEANFILES): Remove $(EXTRA_PROGRAMS).
+       Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * ntpd/ntp_control.c: Header cleanup
+
+2001-04-13  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Properly align --help output.
+       Explain ElectricFence.
+       From: Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * ntpd/ntp_loopfilter.c (local_clock): Lose debugging statements.
+       * ntpd/ntp_proto.c (clock_filter): Rewrite.
+       From: Dave Mills
+
+       * ntpd/ntp_control.c (ctl_getitem): msyslog() possible buffer
+       overflow exploit.
+
+       * configure.in: 4.0.99k24
+
+       * html/pic/radio2.jpg:
+       * html/release.htm:
+       * html/refclock.htm:
+       * html/pps.htm:
+       * html/ntpd.htm:
+       * html/miscopt.htm:
+       * html/driver22.htm:
+       * html/confopt.htm:
+       Updated documentation from Dave Mills.
+
+       * util/ntp-genkeys.c: sys_minpoll.
+       * ntpd/refclock_atom.c: Comment additions.
+       * ntpd/ntp_proto.c: mode_ntpdate and peer_ntpdate added.
+       (transmit): We want 3, not 2, consecutive polls.  hpoll logic
+       cleanup.  mode_ntpdate changes.
+       (receive): When setting up a newpeer, use our sys_minpoll, not the
+       peer->ppoll.
+       (clock_update): sys_minpoll changes.  Reorder some case 1 code.
+       Don't exit in case 2.
+       (poll_update): hpoll cleanup.
+       (peer_clear): u_rand.  Use u_rand to randomize the initial poll.
+       * ntpd/ntp_peer.c (newpeer): Bump peer_ntpdate if we're in
+       mode_ntpdate.
+       * ntpd/ntp_loopfilter.c: Initialize sys_poll and sys_minpoll to
+       NTP_MINDPOLL.
+       (local_clock): Clean up some debug/info messages.
+       (rstclock): Use sys_minpoll.
+       (loop_config): KERNEL_PLL sanity checks.  LOOP_MINPOLL support.
+       * ntpd/ntp_crypto.c (crypto_recv): Turn off FLAG_AUTOKEY when we
+       turn off TEST10.
+       * ntpd/ntp_control.c (ctl_getitem): Buffer overflow check.  Clean
+       up some loop logic.
+       * ntpd/ntp_config.c: Added "tinker" and "minpoll".  Use
+       sys_minpoll now, instead of old manifest constant.
+       (save_resolve): Print keyid using decimal, not hex.  From Lars-Owe
+       Ivarsson <larsowe@paradisaea.its.uu.se>
+       * include/ntpd.h: Added peer_ntpdate and sys_minpoll.
+       * include/ntp_config.h (CONF_CLOCK_MINPOLL): Added.
+       * include/ntp.h: keyid cleanup.  LOOP_* cleanup.
+       From Dave Mills.
+
+2001-04-03  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (clock_filter): Swell stuff.
+       From: Mark Martinec <Mark.Martinec@ijs.si>
+
+       * ports/winnt/ntpd/ntpd.dsp:
+       * ports/winnt/ntpd/hopf_PCI_io.c:
+       * ports/winnt/include/hopf_PCI_io.h:
+       * ports/winnt/include/config.h:
+       * ntpd/refclock_hopfser.c:
+       * ntpd/refclock_hopfpci.c:
+       * ntpd/refclock_conf.c:
+       * ntpd/ntp_control.c:
+       * ntpd/Makefile.am:
+       * libntp/clocktypes.c:
+       * include/ntp.h:
+       * include/hopf6039.h:
+       * include/Makefile.in:
+       * include/Makefile.am:
+       * html/pic/fg6039.jpg:
+       * html/refclock.htm:
+       * html/driver39.htm:
+       * html/driver38.htm:
+       * html/copyright.htm:
+       Updated Oncore dudes.
+
+       * configure.in:
+       HOPF drivers and documentation.
+       From: Bernd Altmeier <altmeier@atlsoft.de> (with some light
+       hacking from Harlan to clean up indentation and lose the // comments)
+
+       * ntpd/refclock_oncore.c:
+       * ntpd/refclock_conf.c: Make it go.
+       From: Reg Clemens <reg@dwf.com>
+
+       * configure.in (openssl): Publish and default to RSAREF; hide
+       openssl, and only use it if explicitly requested (at least until
+       we work with it).
+
+2001-04-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/y2k.htm:
+       * html/tickadj.htm:
+       * html/release.htm:
+       * html/refclock.htm:
+       * html/quick.htm:
+       * html/pps.htm:
+       * html/ntptrace.htm:
+       * html/ntptime.htm:
+       * html/ntpq.htm:
+       * html/ntpdc.htm:
+       * html/ntpdate.htm:
+       * html/ntpd.htm:
+       * html/miscopt.htm:
+       * html/index.htm:
+       * html/genkeys.htm:
+       * html/exec.htm:
+       * html/driver7.htm:
+       * html/driver22.htm:
+       * html/copyright.htm:
+       * html/confopt.htm:
+       * html/build.htm:
+       * html/authopt.htm:
+       * html/assoc.htm:
+       Updates from Dave Mills.
+
+2001-04-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (OPENSSL): Just use -lcrypto.
+       Reported by Dave Mills.
+
+2001-03-31  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k20
+
+       * ntpd/refclock_heath.c: Add support for GC-1000 II.
+       From Dave Mills.
+
+       * ntpd/ntp_proto.c (transmit): Check peer->unreach.
+       (peer_clear): peer->outdate is a f(BURST_INTERVAL1), not
+       NTP_MINPOLL.
+       * ntpd/ntp_loopfilter.c (local_clock): mode_ntpdate stuff.
+       * ntpd/ntp_crypto.c: OpenSSL/RSAREF support.
+       * ntpd/cmd_args.c: Use -q, not -z, for mode_ntpdate.
+       (getstartup): nofork on mode_ntpdate. Usage update.
+       * include/ntp_crypto.h: OpenSSL/RSAREF support.
+       From: Dave Mills.
+
+       * configure.in (rsaref): Buglet.
+
+2001-03-30  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (clock_update): mode_ntpdate support.
+       * ntpd/ntp_loopfilter.c (local_clock): mode_ntpdate support.
+       * ntpd/cmd_args.c: Added -z (mode_ntpdate).
+       * include/ntpd.h: mode_ntpdate added.
+       * include/ntp_crypto.h: RSAREF/OPENSSL cleanup.
+       From: Dave Mills.
+
+2001-03-29  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * config.h.in:
+       * aclocal.m4:
+       * configure.in: Prepare for OpenSSL support
+
+2001-03-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * README.rsa: Note that RSAEURO will not work.
+       Reported by: pieter.delacourt@banksys.be
+
+2001-03-25  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntp_if.h:
+       * include/ntp_machine.h:
+       * include/ntp_unixtime.h:
+       * libntp/humandate.c:
+       * libntp/iosignal.c:
+       * libntp/mktime.c:
+       * libntp/prettydate.c:
+       * libntp/systime.c:
+       * libntp/tvtoa.c:
+       * libntp/uglydate.c:
+       * libntp/utvtoa.c:
+       * libparse/clk_computime.c:
+       * libparse/clk_dcf7000.c:
+       * libparse/clk_hopf6021.c:
+       * libparse/clk_meinberg.c:
+       * libparse/clk_rawdcf.c:
+       * libparse/clk_rcc8000.c:
+       * libparse/clk_schmid.c:
+       * libparse/clk_trimtaip.c:
+       * libparse/clk_trimtsip.c:
+       * libparse/clk_varitext.c:
+       * libparse/parse.c:
+       * libparse/parse_conf.c:
+       * ntpd/check_y2k.c:
+       * ntpd/ntp_config.c:
+       * ntpd/ntp_control.c:
+       * ntpd/ntp_intres.c:
+       * ntpd/ntp_io.c:
+       * ntpd/ntp_loopfilter.c:
+       * ntpd/ntp_monitor.c:
+       * ntpd/ntp_proto.c:
+       * ntpd/ntp_refclock.c:
+       * ntpd/ntp_request.c:
+       * ntpd/ntp_resolver.c:
+       * ntpd/ntp_timer.c:
+       * ntpd/ntp_util.c:
+       * ntpd/ntpd.c:
+       * ntpd/refclock_acts.c:
+       * ntpd/refclock_arbiter.c:
+       * ntpd/refclock_arc.c:
+       * ntpd/refclock_as2201.c:
+       * ntpd/refclock_atom.c:
+       * ntpd/refclock_bancomm.c:
+       * ntpd/refclock_chronolog.c:
+       * ntpd/refclock_chu.c:
+       * ntpd/refclock_datum.c:
+       * ntpd/refclock_dumbclock.c:
+       * ntpd/refclock_fg.c:
+       * ntpd/refclock_gpsvme.c:
+       * ntpd/refclock_heath.c:
+       * ntpd/refclock_hpgps.c:
+       * ntpd/refclock_irig.c:
+       * ntpd/refclock_jupiter.c:
+       * ntpd/refclock_leitch.c:
+       * ntpd/refclock_local.c:
+       * ntpd/refclock_msfees.c:
+       * ntpd/refclock_mx4200.c:
+       * ntpd/refclock_nmea.c:
+       * ntpd/refclock_oncore.c:
+       * ntpd/refclock_pcf.c:
+       * ntpd/refclock_pst.c:
+       * ntpd/refclock_shm.c:
+       * ntpd/refclock_tpro.c:
+       * ntpd/refclock_trak.c:
+       * ntpd/refclock_true.c:
+       * ntpd/refclock_ulink.c:
+       * ntpd/refclock_usno.c:
+       * ntpd/refclock_wwv.c:
+       * ntpd/refclock_wwvb.c:
+       * ntpdate/ntpdate.c:
+       * ntpdate/ntptime_config.c:
+       * ntpdate/ntptimeset.c:
+       * ntpdc/ntpdc.c:
+       * ntpdc/ntpdc_ops.c:
+       * ntpq/ntpq.c:
+       * ntpq/ntpq_ops.c:
+       * ntptrace/ntptrace.c:
+       * parseutil/testdcf.c:
+       * util/hist.c:
+       * util/ntp-genkeys.c:
+       * util/ntptime.c:
+       * util/precision.c:
+       * util/tickadj.c:
+       time.h and sys/time.h cleanup.
+
+2001-03-24  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: '99k19
+
+       * ntpd/refclock_atom.c (atom_ppsapi): PPS API RFC alignment patches.
+       From: Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
+
+       * util/ntptime.c: MNT options
+       From: Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
+
+       * ntpd/ntp_refclock.c (refclock_newpeer): Lose "extra" free().
+       From: Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
+
+       * configure.in: 4.0.99k18 and auto* upgrade
+
+2001-03-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpdc/ntpdc_ops.c (printpeer): No more "valid".
+       * ntpd/ntp_request.c (peer_info): No more "valid".
+       * ntpd/ntp_refclock.c (refclock_transmit): valid/hpoll cleanup.
+       * ntpd/ntp_proto.c (transmit): valid/hpoll and peer->ttl cleanup.
+       peer->valid/oreach cleanup.
+       (receive): Call newpeer() with the pkt->ppoll, not
+       NTP_MINDPOLL (in several places).
+       In AM_NEWPASS, if we have a NULL peer, return.
+       (poll_update): Added xpoll definition, fixed oldpoll definition.
+       Algorithmic improvements.
+       * ntpd/ntp_peer.c (newpeer): Better minpoll/maxpoll
+       initialization.
+       (resetmanycast): That's a poll_update() on an MDF_ACAST, not a
+       poll_clear().
+       * ntpd/ntp_crypto.c: include <fcntl.h>.
+       (crypto_recv): Leave the crypto_flags alone when wiggling the
+       peer-> stuff.
+       (crypto_cert): Make room for daddy.  Do a real open() on the cert
+       file.  Read the cert.  Initial hack and slash.  Better debug info.
+       * ntpd/ntp_control.c: CP_VALID now does "unreach".
+       (ctl_putpeer): Ditto.
+       * include/ntp_request.h: info_peer gets a placeholder for "valid".
+       * include/ntp_crypto.h (CRYPTO_FLAG_CERT): Comment update.
+       * include/ntp.h: Lose "valid" from struct peer.
+       From: Dave Mills.
+
+2001-03-05  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (transmit): hpoll calc logic cleanup.
+       (receive): New cert stuff.
+       (poll_update): Improvements.
+       (peer_clear): New cert stuff.
+       (peer_xmit): New cert stuff.
+       * ntpd/ntp_crypto.c: New cert stuff, documentation cleanup.  Lose
+       extraneous poll_uopdate()s.
+       * ntpd/ntp_control.c: Deal with new cert stuff.
+       * ntpd/ntp_config.c (getconfig): Handle CONF_CRYPTO_CERT.
+       * include/ntp_crypto.h (CRYPTO_FLAG_CERT): Added.
+       (CRYPTO_CERT): Added.
+       (CRYPTO_CONF_CERT): Added.
+       Add declaration for struct value certif.
+       * include/ntp_control.h (CS_CERTIF): Added.
+       (CP_CERTIF): Added.
+       * include/ntp_config.h (CONF_CRYPTO_CERT): Added.
+       * include/ntp.h (TEST10,TEST11): New meaning.  Add certif to
+       struct peer.
+       (FLAG_PROVEN): Added.
+       (MAX_EXT_LEN): Removed.
+       exten grew from 672/4 to 5000/4 for PUBKEY.
+       From: Dave Mills.
+
+2001-03-03  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (transmit): Documentation cleanup.
+       (receive): Watch for NULL peer->pubkey.ptr (TEST11).
+       (poll_update): peer->nextdate, not ->outdate. More cleanup around
+       the disabled PUBKEY chunk.
+       * ntpd/ntp_crypto.c (make_keylist): ltemp might be smaller than
+       sys_automax - check peer->kpoll, too.  Other ltemp cleanup.
+       (crypto_recv): fstamp is a PUBKEY-only variable.
+       * include/ntp.h (NTP_AUTOMAX): 13, not 12.
+       From: Dave Mills.
+
+2001-03-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (transmit): hpoll cleanup.  Call clock_select()
+       after calling poll_update, not before.
+       (receive): Call poll_update after crypto_recv if FLAG_SKEY.
+       (process_packet): Set peer->ppoll Later.
+       (poll_update): peer->hpoll sanity checking.  Set peer->outdate,
+       not ->nextate, when burst > 0.  MDF_ACAST cleanup.
+       (clock_select): Fix hpoll typo in call to poll_update().
+       * ntpd/ntp_crypto.c (crypto_xmit): tstamp's value is a function of
+       PUBKEY.
+       * include/ntp.h (clear_to_zero): #define value is a function of
+       AUTOKEY.
+       From: Dave Mills.
+
+2001-02-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (transmit): Documentation/code update.
+       (poll_update): Sanity check peer->hpoll.  Improve debug info.
+       (peer_clear): Improve debug info.  Turn off FLAG_ASSOC in addition
+       to FLAG_AUTOKEY.
+       (clock_select): peer->status is CTL_PST_SEL_DISTSYSPEER, and don't
+       call poll_update().  Make each entry in the peer_list a
+       CTL_PST_SEL_SELCAND sooner, too.  Rework similar logic later on.
+       Change debug level on some info.
+       (peer_xmit): Check peer->flags using FLAG_ASSOC, not
+       CRYPTO_FLAG_AUTO in a couple places.  Don't call poll_update() if
+       sendlen > LEN_PKT_NOMAC.
+       * ntpd/ntp_loopfilter.c (local_clock): Improve debug info.
+       Sanity-check sys_poll sooner.
+       * ntpd/ntp_crypto.c: New artwork.
+       (COOKIE_LEN,AUTOKEY_LEN,VALUE_LEN): New.
+       (make_keylist): More debug info.  Use FLAG_ASSOC, not
+       CRYPTO_FLAG_ASSOC.
+       (crypto_recv): More debug info.  Clean up/improve sanity checks on
+       CRYPTO_ASSOC and CRYPTO_RESP packets, and in other places.
+       (crypto_xmit): Clean up/improve sanity checks on CRYPTO_ASSOC and
+       CRYPTO_RESP packets.  Use FLAG_ASSOC, not CRYPTO_FLAG_ASSOC.  More
+       debug info.
+       * include/ntp.h (NTP_CANLOCK): Lose it.
+       (clear_to_zero): is now "assoc".
+       (FLAG_ASSOC): Added.
+       From: Dave Mills
+
+2001-02-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpdate/ntpdate.h (NTP_MAXAGE): Added.
+       * ntpd/ntp_refclock.c (refclock_receive): Cleanup.
+       * ntpd/ntp_proto.c (transmit): Don't reset peer->ppoll in one case.
+       Update peer->hpoll based on CTL_PST_SEL_CORRECT, not FLAG_SYSPEER.
+       Don't update peer->ppoll based on MDF_[BM]CAST.
+       (peer_clear): ppoll is initialized to maxpoll.
+       (clock_select): call poll_update(peer->hpoll) earlier.
+       (peer_xmit): Call poll_update later.
+       * ntpd/ntp_peer.c (peer_config): Rework initial values of [hkp]poll.
+       * ntpd/ntp_loopfilter.c (CLOCK_PHI): Added.  Deal with other
+       (allow_*) stuff.  Treat Windows/NT the same as others regarding
+       panic steps.  Deal with tinker stuff.
+       * ntpd/ntp_config.c: Tinker stuff.
+       * ntpd/cmd_args.c (getCmdOpts): -g now wiggles "allow_panic"
+       (renamed from "correct_any").  -x now wiggles "allow_step"
+       (renamed from "allow_step_backward").
+       * include/ntpd.h: Add tinker variables.  Rename/rework variables
+       associated with "permission to step" and "permission to make a
+       panic correction"
+       * include/ntp_config.h (CONFIG_TINKER): Added.
+       (CONF_CLOCK_MAX): Tinker keyword
+       (CONF_CLOCK_PANIC): Tinker keyword
+       (CONF_CLOCK_PHI): Tinker keyword
+       (CONF_CLOCK_MINSTEP): Tinker keyword
+       * include/ntp.h (NTP_MINCLOCK): Tinker and other cleanup.
+       From: Dave Mills
+
+2001-02-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (transmit): Don't peer_clear() and reset
+       minpoll unconditionally; make sure the peer is configured.
+       (poll_update): When updating peer->ppoll, check on BCAST and
+       MCAST, not ACAST
+       (peer_clear): PUBKEY cleanup.  Zero out the peer structure
+       earlier. Initialization cleanup/fixes.
+       (peer_xmit): CRYPTO_FLAG_AUTO is in peer->flags now.
+       (key_expire): Debug output.
+       * ntpd/ntp_peer.c (unpeer): PUBKEY cleanup.
+       (newpeer): peer variable setup cleanup.
+       * ntpd/ntp_crypto.c (make_keylist): Keep CRYPTO_FLAG_AUTO in
+       peer->flags, not crypto_flags.
+       (crypto_xmit): Ditto.
+       (crypto_recv): Fix up RV_TSP logic (several places).
+       * include/ntp.h (clear_to_zero): Moved...
+       From: Dave Mills.
+
+2001-02-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (peer_xmit): Crypto-related fixes
+       From Dave Mills.
+
+       * ntpd/ntp_crypto.c (crypto_recv): Allocate space for the trailing
+       NUL on the keystr.
+
+2001-01-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k17
+
+       * ntpd/refclock_local.c (STRATUM): 3 -> 5
+       * ntpd/ntp_proto.c: sys_maxd -> sys_selerr, sys_epsil ->
+       sys_syserr.  various cleanups and improvements.
+       From: Dave Mills.
+
+2001-01-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k16
+
+       * config.h.in: Regenerated - became empty somehow.
+       Reported by John.Hay@icomtek.csir.co.za
+
+       * ntpd/ntp_proto.c (clock_select): Fix sdisp calculation.
+       From Dave Mills.
+
+       * util/ntp-genkeys.c:
+       * ntpd/refclock_chu.c:
+       * ntpd/refclock_atom.c:
+       * ntpd/ntpd.c:
+       * ntpd/ntp_loopfilter.c:
+       * ntpd/ntp_io.c:
+       * ntpd/cmd_args.c:
+       * libntp/audio.c:
+       * include/l_stdlib.h:
+       * html/copyright.htm:
+       Lint fixes (Thanks bunches!)
+       From: Marc.Brett@westerngeco.com
+
+2001-01-18  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k15
+
+       * ntpd/ntp_proto.c (clock_select): Track error[] items sooner.
+       Typo grabbing the dtemp value and in the sdisp calculation.
+       From Dave Mills.
+
+2001-01-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k14
+
+       * ntpd/ntp_proto.c: Change description of sys_rootdelay and
+       sys_rootdispersion.
+       (process_packet): Fix p_del test (bad distance).
+       (process_packet): Fix bad synch distance test.
+       (process_packet): Fix call to clock_filter (p_disp)
+       (clock_update): Fix sys_rootdelay calculation.
+       (clock_filter): Initialize jit to f(sys_precision)
+       (clock_filter): Update jit using distance[i] instead of
+       SQUARE().  peer->jitter uses dtemp instead of SQUARE().
+       (clock_filter): Updated CLOCK_SGATE checks.  When printing debug
+       info, show jitter along with popcorn spike.
+       (clock_select): New sdisp calc.
+       (root_distance): New return value calc.
+       (peer_xmit): xpkt.rootdispersion value change.
+       * include/ntp.h (CLOCK_SGATE): Popcorn spike gate (Whoa, Molly!)
+       From Dave Mills.
+
+2001-01-13  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * config.sub (Repository): Updated.
+       * config.guess (Repository): Updated.
+
+       * ntpd/ntp_loopfilter.c (local_clock): Just use sys_jitter in the
+       calculation for rootdispersion.
+       From Dave Mills.
+
+2001-01-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (transmit): Fix documentation. Set
+       peer->outdate and call poll_update in a new place.  Sanity checks
+       in the MODE_BROADCAST case.
+       (clock_select): Track the old peer.  Use the old peer in
+       subsequent checks, where appropriate.  Clean up unpeer() logic.
+       From Dave Mills.
+
+2001-01-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_chu.c: Start using HAVE_AUDIO.
+       * ntpd/ntp_proto.c (clock_select): If about to discard an
+       ephemeral association, do it only if not the system peer.
+       From Dave Mills.
+
+       * html/pic/wingdorothy.gif:
+       * html/pic/bustardfly.gif:
+       * html/pic/boom3a.gif:
+       * html/pic/tonea.gif:
+       * html/pic/stack1a.jpg:
+       * html/pic/pogoa.gif:
+       * html/pic/pogo8.gif:
+       * html/pic/pogo6.gif:
+       * html/pic/pogo5.gif:
+       * html/pic/pogo4.gif:
+       * html/pic/pogo3.gif:
+       * html/pic/pogo1.gif:
+       * html/pic/oz2.gif:
+       * html/pic/flatheads.gif:
+       * html/pic/boom4.gif:
+       * html/pic/boom3.gif:
+       * html/pic/appletree.gif:
+       * html/pic/alice51.gif:
+       * html/pic/alice44.gif:
+       * html/pic/alice35.gif:
+       * html/pic/alice31.gif:
+       * html/pic/alice15b.gif:
+       * html/pic/alice13.gif:
+       * html/pic/alice11.gif:
+       * html/release.htm:
+       * html/rdebug.htm:
+       * html/prefer.htm:
+       * html/porting.htm:
+       * html/ntptrace.htm:
+       * html/ntpq.htm:
+       * html/ntpdate.htm:
+       * html/monopt.htm:
+       * html/kernpps.htm:
+       * html/index.htm:
+       * html/hints.htm:
+       * html/gadget.htm:
+       * html/driver7.htm:
+       * html/copyright.htm:
+       * html/config.htm:
+       * html/build.htm:
+       * html/authopt.htm:
+       * html/assoc.htm:
+       * html/accopt.htm:
+       Cleanup from Dave Mills.
+
+2000-12-30  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k13
+
+       * ntpd/refclock_wwv.c (wwv_start): Call audio_init with DEVICE_AUDIO.
+       * ntpd/refclock_irig.c (irig_start): Call audio_init with DEVICE_AUDIO.
+       * ntpd/refclock_chu.c: Documentation cleanup.
+       (DEVICE_AUDIO): Added.
+       (fd_audio): Added.
+       (chu_start): Separate audio from serial device.
+       (chu_receive): Rewrite - get data from serial or audio device as
+       appropriate.
+       (chu_audio_receive): Renamed (from chu_receive) to allow both
+       audio and serial capability.
+       (chu_serial_receive): Ditto.
+       (chu_decode): Do the Right Thing based on audio/serial data.
+       * ntpd/ntp_refclock.c (refclock_open): Check for failure using <0
+       instead of ==-1.
+       * libntp/audio.c: Header cleanup, and remove
+       HAVE_STRUCT_AUDIO_INFO_* related fields.
+       (audio_init): Func arg is device to attempt to open.
+       * include/audio.h (audio_init): Now takes a char * argument.
+       From Dave Mills.
+
+       * configure.in (ntp_refclock): HAVE_AUDIO added.  Remove
+       HAVE_STRUCT_AUDIO_INFO_* stuff; Dave rewrote the audio stuff.
+
+2000-12-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k12
+
+2000-12-27  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/release.htm:
+       * html/patches.htm:
+       * html/measure.htm:
+       * html/confopt.htm:
+       * html/clockopt.htm:
+       * html/biblio.htm:
+       * html/authopt.htm:
+       * html/assoc.htm:
+       Updates from Dave Mills.
+
+       * include/ntp_crypto.h: Make sure crypto_flags is visible.
+       From Dave Mills.
+
+2000-12-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (process_packet): pleap/pstratum.
+       (peer_xmit): Use CRYPTO_FLAG_AUTO.
+       * ntpd/ntp_crypto.c (make_keylist): Use CRYPTO_FLAG_AUTO. Only
+       sign host name and timestamps if the clock is synched.
+       * include/ntp_crypto.h (CRYPTO_FLAG_AUTO): Added.
+       From: Dave Mills
+
+2000-12-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (transmit): Call clock_select in a few new
+       places.  BURST/IBURST cleanup.  Don't turn off FLAG_BURST at the
+       EOburst.
+       (receive): Set peer->unreach = 0 before we call process_packet().
+       (process_packet): ditto, before calling poll_update().  Lose some
+       debugging, MODE_BCLIENT/CLIENT cleanup.
+       (poll_update): Bump nextupdate on FLAG_REFCLOCK, not _REFCLOCK or
+       _IBURST.
+       (peer_clear): Don't set IBURST on MDF_BCLNT.
+       From: Dave Mills.
+
+       * ntpdate/ntpdate.c (alarming): Appease ansi2knr.
+
+2000-12-10  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_control.c (ctl_putpeer): CP_TTL and CP_TTLMAX
+       MDF_ACAST and MDF_MCAST cleanup.
+
+       * ntpd/refclock_wwv.c (wwv_start): ttlmax/ttl cleanup.
+       * ntpd/refclock_usno.c (usno_timeout): ttlmax/ttl cleanup.
+       * ntpd/refclock_parse.c (CLK_REALTYPE): ttlmax/ttl cleanup.
+       * ntpd/refclock_chu.c (chu_start): ttlmax/ttl cleanup.
+       * ntpd/refclock_acts.c (acts_timeout): ttlmax/ttl cleanup.
+       * ntpd/ntp_refclock.c (refclock_newpeer): Don't do the
+       any_interface -> loopback_interface trick.
+       * ntpd/ntp_proto.c (transmit): Broadcast/manycast cleanup.
+       * ntpd/ntp_peer.c: Cleanup.
+       * ntpd/ntp_io.c: Cleanup.
+       * ntpd/ntp_crypto.c (crypto_recv): AUTOKEY based on BCLNT, not MCAST2.
+       * include/ntpd.h: Declare findbcastinter().
+       * include/ntp.h: struct peer's ttlmax is now max ttl/refclock
+       mode.  ttl is now ttl for manycast mode.
+       (FLAG_MCAST): Reworked several FLAG_ bits.
+       From Dave Mills.
+
+2000-12-05  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpq/ntpq.c: CP_TTLMAX support.
+       * ntpd/ntp_proto.c (transmit): MDF_ACAST ttl fixes.
+       * ntpd/ntp_peer.c (resetmanycast): Reset ttl if MDF_ACAST.
+       (peer_config): Save max ttl in ttlmax.
+       * ntpd/ntp_control.c: ttlmax support.
+       * include/ntp_control.h (CP_TTLMAX): Added.
+       * include/ntp.h: Added ttlmax to struct peer.
+       Dave Mills.
+
+2000-12-03  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (receive): That any_interface is now an
+       rbufp->dstadr.
+       Various other doc and code cleanup.
+       * ntpd/ntp_peer.c (findmanycastpeer): Fixes
+       From Dave Mills
+
+2000-12-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_request.c (do_conf): call peer_config with
+       any_interface, not 0.
+       * ntpd/ntp_proto.c (transmit): Manycast cleanup
+       * ntpd/ntp_peer.c (findmanycastpeer): manycast cleanup
+       * ntpd/ntp_io.c (sendpkt): Only check ttl if we have a ttl
+       (findinterface): Cleanup
+       * ntpd/ntp_control.c: cleanup
+       * include/ntpd.h: Added resetmanycast.
+       * include/ntp_control.h (CP_TTL): disp -> ttl
+       * ntpq/ntpq.c: disp -> ttl
+       From Dave Mills
+
+2000-11-26  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k11
+
+       * ntpd/ntp_proto.c (transmit):
+       * ntpd/ntp_peer.c:
+       * ntpd/ntp_io.c:
+       * ntpd/ntp_control.c (ctl_putpeer):
+       * ntpd/ntp_config.c (getconfig):
+       * include/ntpd.h: mcast/ucast interface cleanup.
+       From: Dave Mills
+
+       * include/ntp_request.h: Put data[] as MAXFILENAME+16.  This will
+       fix the conf_peer requests again, but re-break compatibility with
+       old versions of the daemon.  Sigh.
+
+       * util/ntp-genkeys.c (cleanlinks): Don't do it if nosymlinks.
+
+2000-11-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_parse.c (rawdcf_init_1): make Linux happier with
+       some modem control stuff.
+       From: Wolfram Pienkoss <wp@bszh.de> (via Frank Kardel)
+
+       * ntpd/refclock_pcf.c (pcf_poll): isdst fix
+       From: Andreas Voegele <andreas.voegele@gmx.de>
+
+2000-10-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k10
+
+       * ntpd/refclock_wwvb.c (wwvb_start): Cosmetic reorder.
+       * ntpd/refclock_atom.c (RANGEGATE): Cleanup.  Add ASTAGE.
+       Add ppsparams to struct ppsunit.
+       (atom_start): Init peer->burst to ASTAGE.
+       (atom_shutdown): Multi-handle
+       (atom_pps): Multi-handle
+       (atom_pps): RANGEGATE cleanup
+       (atom_poll): Poll count cleanup.  Error check cleanup.  Burst cleanup.
+       * ntpd/ntp_refclock.c (refclock_transmit): Lose the pre-burst
+       check poll_update().
+       (refclock_sample): Fix the jitter calc.
+       (refclock_receive): Pass the jitter to the clock_filter().
+
+       * ntpd/ntp_proto.c (clock_update): If we lose sync, reset the poll
+       to NTP_MINDPOLL.
+       (poll_update): Poll wiggles.  Make sure peer->nextdate is timely.
+       (clock_select): If we lose sync, reset the poll to NTP_MINDPOLL.
+       * ntpd/ntp_loopfilter.c (local_clock): Show the asocid in debug
+       output.  popcorn debug message changes.  Clamp the poll interval
+       if the system peer has changed.  PPS wiggle changes.
+       From Dave Mills.
+
+2000-10-16  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_pcf.c (pcf_start):
+       * html/driver35.htm:
+       The radio clock transmits 69 bits with a period of 2.5
+       milliseconds per bit. Thus the driver now sets the default
+       calibration offset to 0.1725 (69 * 2.5 = 172.5).
+       Its now possible to disable the check of the radio clock's
+       synchronisation status bit. Several users requested this option.
+       From: Andreas Voegele <andreas.voegele@gmx.de>
+
+       * html/refclock.htm:
+       * html/rdebug.htm:
+       * html/prefer.htm:
+       * html/pps.htm:
+       * html/ntpdc.htm:
+       * html/miscopt.htm:
+       * html/ldisc.htm:
+       * html/kern.htm:
+       * html/index.htm:
+       * html/exec.htm:
+       * html/driver22.htm:
+       * html/clockopt.htm:
+       Updates from Dave Mills
+
+       * ntpd/ntp_intres.c (request): Sanity check the size of the response
+
+2000-10-15  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpq/ntpq_ops.c (dopeers): Dave didn't like the patch to show
+       the units on the times...
+       * ntpdc/ntpdc_ops.c (doset): SYS_FLAG_PPS cleanup
+       * ntpd/refclock_wwv.c (wwv_newchan): Update the peer refid if
+       we're talking to a stratum 0 source
+       * ntpd/refclock_trak.c: Needs PPS
+       * ntpd/refclock_oncore.c: Disable for now
+       * ntpd/refclock_mx4200.c: Needs PPSAPI, not PPS
+       Header cleanup.  PPS interface cleanup.
+       Process sentences with a switch
+       Cleanup and sanity checks
+       * ntpd/refclock_datum.c: header cleanup, light body cleanup
+       * ntpd/refclock_conf.c: CLOCK_TRAK needs PPS
+       MX4200 needs PPSAPI, not PPS
+       Disable ONCORE for now
+       * ntpd/refclock_bancomm.c: Surgery
+       * ntpd/refclock_atom.c: Cleanup
+       (atom_control): added
+       (atom_ppsapi): added
+       * ntpd/ntp_request.c (setclr_flags): SYS_FLAG_PPS cleanup
+       * ntpd/ntp_refclock.c: stropts.h back in in TTYCLK and
+       HAVE_SYS_CLKDEFS_H
+       Get ntp_syscall if KERNEL_PLL
+       Define cal_enable
+       (refclock_receive): Cleanup
+       (refclock_control): sanity check procptr
+       * ntpd/ntp_proto.c (init_proto): pps_enable
+       (proto_config): Turn on/off PPS discipline
+       * ntpd/ntp_loopfilter.c: pps_enable
+       (local_clock): record_loop_stats() if !ntp_enable
+       (local_clock): Turn off PPS if it's not enabled
+       Other cleanup/fixes
+       * ntpd/ntp_config.c: pps and calibrate keywords.  Initialize
+       pps_assert to 0, not 1 (swap assert/clear?)
+       * include/ntpd.h: We have pll_status if KERNEL_PLL
+       Added pps_enable and cal_enable
+       * include/ntp_request.h (SYS_FLAG_PPS): Renamed from
+       SYS_FLAG_AUTHENTICATE
+       * include/ntp.h (PROTO_PPS): Added
+       (PROTO_CAL): Added
+       From: Dave Mills
+
+2000-09-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntp_refclock.h (stropts.h, sys/clkdefs.h): Harmful and
+       useless file include's turned off.
+       * libntp/iosignal.c (netinet/in.h, sys/sockio.h): Duplicate file
+       include's turned off.
+       * ntpd/ntp_refclock.c (ntp_tty.h): File included.
+       (refclock_open, refclock_ioctl): Use `TTY' from ntp_tty.h.
+       * ntpd/refclock_atom.c: Grab a few headers regardless; if we don't
+       CLOCK_ATOM we provide a stub pps_sample() routine so the WHARTON
+       can be compiled/used.
+       * ntpq/ntpq_ops.c (dopeers, doopeers): Print the units for
+       each column header.
+       Tue Sep 12 16:25:51 2000  Philippe De Muyter  <phdm@macqel.be>
+
+       * ntpd/refclock_atom.c (atom_start): Lose "temp", because we now
+       initially either CAPTUREASSERT or CAPTURECLEAR.
+       (atom_pps): pps_info_t is our friend.  Update comments to reflect
+       reality.  DTRT with pps_info.  Do some overflow checks.
+       From: Dave Mills.
+
+2000-09-21  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Much improved Solaris patch-level check for the
+       FLL bug test.
+       From: Marc.Brett@westgeo.com
+
+2000-09-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/Makefile.am (noinst_HEADERS): Added ntp_tty.h
+       Reported by Dave Mills
+
+2000-09-16  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntptrace/ntptrace.c:
+       * ntpdate/ntptimeset.c (receive):
+       * ntpdate/ntpdate.c (receive):
+       STRATUM cleanup
+       * ntpd/refclock_atom.c (atom_poll): Autostratum.  Lose the leap.
+       * ntpd/ntp_proto.c: sys_prefer
+       (process_packet): stratum cleanup
+       (clock_select): Autostratum the ATOM
+       * ntpd/ntp_loopfilter.c: pps_update/pps_stratum wiggle.
+       * include/ntpd.h: Lose pps_update, gain sys_prefer
+       * include/ntp.h: STRATUM variable cleanup
+       From Dave Mills
+
+2000-09-13  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c (oncore_get_timestamp): Print debug
+       messages being aware of HAVE_STRUCT_TIMESPEC.
+
+       * ntpd/refclock_atom.c: Have pps_params tag along in the ppsunit
+       structure, where it really belongs.
+       (atom_pps): Use PPS_CAPTURE{ASSERT,CLEAR}
+       From: Dave Mills.
+
+2000-09-12  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_cv_var_atom_ok): Cleanup ATOM/PPSAPI stuff...
+
+       * scripts/ntp-close: Find "close" ntp servers.
+       From: Neal McBurnett <neal@bcn.boulder.co.us>
+
+       * ntpd/refclock_conf.c:
+       * ntpd/refclock_oncore.c: Re-enabled oncore driver for HAVE_PPSAPI
+       case only.
+
+2000-09-12  Philippe De Muyter  <phdm@macqel.be>
+
+        * ntpd/refclock_parse.c (we400a_pollinfo): Useless variable removed.
+        [WHARTON slot]: Set NO_POLL, NO_INIT and NO_DATA; fix `fixed format'
+        and `offset' fields.
+
+       * include/ntp_tty.h: New file
+       * libntp/icom.c: Use it.
+
+       * ntp_update (UPDATE_OPTIONS): Use -d, too.  Fix Pass 1 comment.
+
+2000-09-12  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c: shmem_fname added.  oncore_init_shmem()
+       updated.
+       (oncore_start): Comment cleanup
+       (oncore_read_config): Move call to oncore_shmem_init()
+       (oncore_init_shmem): Prototype change
+       (oncore_init_shmem): Don't exit on errors
+       (oncore_msg_any): timespec/timeval cleanup
+       (oncore_msg_Cj_id): shmem_fname changes
+       (oncore_msg_BaEaHa): saw_At bugfix
+       (oncore_get_timestamp): Added current_mode/current_params.  Commented.
+       Added time_pps_getcap() calls.
+       From: Reg Clemens <reg@dwf.com>
+
+       * ntpd/ntp_io.c (input_handler): Better recvfrom() error message
+       From: Dean Gibson <timekeeper@tcp-udp.net>
+
+       * ntpdc/ntpdc.c (passwd): Get them working again.
+       From: Benjamin Greenwald <beng@lcs.mit.edu>
+
+2000-09-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_atom.c:
+       (atom_start):
+       * ntpd/ntp_refclock.c: Comment cleanup.  PPS/PPSAPI cleanup
+       (refclock_open): PPS/PPSAPI cleanup
+       From: Dave Mills
+
+       * ntpd/refclock_oncore.c:
+       * ntpd/refclock_mx4200.c:
+       HAVE_TIMESPEC -> HAVE_STRUCT_TIMESPEC
+
+       * configure.in: ATOM requires struct timespec, not PPSAPI.  Clean
+       up dependencies accordingly.
+
+2000-09-09  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_cv_var_atom_ok): Improve ATOM configure message
+       PARSE requires ATOM.
+
+       * ntpd/ntpd.c (set_process_priority): Clean up debug messages.
+
+2000-09-07  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: ac_cv_atom_ok, depends on HAVE_PPSAPI.
+       I notice the PARSE clocks require ATOM.  Could be interesting...
+
+2000-09-06  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * Makefile.in (distdir): Seems to be a bug in an automake library
+       somewhere...
+
+2000-09-05  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_loopfilter.c (loop_config): V3 API needs MOD_BITS when
+       initializing ntv.modes.  Initialize ntv.{maxerror,esterror,status}
+       earlier.  Clean up KERNEL_PLL code.
+
+2000-09-04  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpq/ntpq.c: report offset as "offset", not "phase".  Lose
+       compliance.
+       * ntpd/refclock_local.c (local_poll): variance -> jitter
+       * ntpd/refclock_chu.c (chu_major): Lose variance.
+       * ntpd/ntp_util.c (hourly_stats): sys_error -> sys_jitter
+       (record_loop_stats): ditto
+       * ntpd/ntp_request.c (peer_info): variance -> jitter
+       * ntpd/ntp_refclock.c (refclock_sample): variance -> jitter
+       (refclock_receive): variance -> jitter
+       * ntpd/ntp_proto.c (process_packet): variance -> jitter
+       (clock_filter): variance -> jitter
+       (clock_select): variance -> jitter
+       (root_distance): variance -> jitter
+       * ntpd/ntp_peer.c (newpeer): variance -> jitter
+       * ntpd/ntp_loopfilter.c: Cleanup pll_nano selection bogon.
+       Centralize the kernel API data.
+       (local_clock): Lose sys_error.
+       (loop_config): Code cleanup.
+       * ntpd/ntp_control.c: Call offset "offset" and not "phase". Lose
+       CS_COMPLIANCE.  Deal with variance/jitter rename.
+       * include/ntp_refclock.h: Rename variance to jitter in struct
+       refclockproc.
+       * include/ntp_control.h (CS_COMPLIANCE): Lose it.
+       * include/ntp.h: Rename variance to jitter in struct peer.
+       From: Dave Mills
+
+2000-09-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_atom.c: Use the new ppsunit.  Cleanup and improve
+       documentation.
+       * ntpd/ntp_refclock.c (refclock_sample): Don't accumulate
+       variance.
+       From Dave Mills
+
+2000-08-31  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/driver22.htm: Update the docs.
+       * ntpd/refclock_atom.c (atom_start): Open the device if it hasn't
+       been opened already.
+       (pps_sample): Make it more visible.
+       From Dave Mills.
+
+       * configure.in: 4.0.99k8
+
+       Revert to the older automake.
+
+       * configure.in: The PPSAPI headers use "inline", so require a STDC
+       compiler.
+
+       * ntpd/refclock_atom.c (atom_shutdown): Typo
+       From Dave Mills
+
+       * configure.in: Convert to autoconf-2.49
+
+       * ntpd/refclock_atom.c: Header cleanup Comment cleanup.  Lose the
+       TTYCLK stuff.  Convert to PPSAPI.
+       * ntpd/ntp_refclock.c (refclock_newpeer): Move refclock_unpeer().
+       From: Dave Mills
+
+2000-08-29  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure: Fix the autoconf problem...
+
+2000-08-20  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 99k7
+
+       * util/ntptime.c (main): Report TAI stuff
+       * ntpq/ntpq.c: CS_COMPLIANCE/CS_JITTER cleanup
+       * ntpd/ntp_loopfilter.c (local_clock): sys_error/sys_jitter cleanup.
+       kernel PPL cleanup.
+       * ntpd/ntp_crypto.c: Check NTP_API if we're doing KERNEL_PLL so we
+       can get the TAI stuff.
+       * ntpd/ntp_control.c: CS_COMPLIANCE now reports "error" instead of
+       "jitter".  CS_JITTER now reports jitter.
+       * include/ntpd.h: Added sys_jitter
+       * include/ntp_control.h (CS_JITTER): Added
+       From: Dave Mills
+
+       * ntpd/cmd_args.c (getCmdOpts): Crack -N at pre-scan, as we do the
+       priority wiggle before the final scan.
+       From: Tom Smith <smith@cag.lkg.dec.com>
+       We might do better to move the priority wiggle to after the final
+       scan.  Especially if we want to permit command-line options to
+       have decent control over the priority.  When we rewrite the config
+       file stuff we might go to a multi-scan to solve some of these
+       problems.
+
+2000-08-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: '99k6, and manually fix configure.
+
+       * include/ntp_request.h (NTP_MAXHOSTNAME): 144 -> 32
+
+2000-08-18  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntp-genkeys.c (main): Don't call fclose if stream is NULL.
+
+2000-08-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/driver35.htm:
+       * ntpd/refclock_pcf.c: Updates and improvements
+       From: Andreas Voegele <andreas.voegele@gmx.de>
+
+       * configure.in (ac_cv_struct_ntptimeval): Lose the TAI check - we
+       don't need it since we can check NTP_API.  Re-hack the generated
+       configure script.
+
+       * configure: Manual hack to the ntptimeval.time.tv_nsec stuff
+       because we're running an old autoconf.
+
+2000-08-16  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntptime.c: Use: HAVE_STRUCT_NTPTIMEVAL_TIME_TV_NSEC, it's
+       the standard name.
+
+       * configure.in: Look for struct ntptimeval.tai in sys/timex.h
+       Cleanup struct tptimeval member tests.
+
+       * util/ntp-genkeys.c: New command-line arguments
+
+2000-08-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntp-genkeys.c (main): More small steps...
+
+2000-08-13  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_crypto.c (crypto_rsa): Now that we're using
+       NTP_KEYSDIR, make sure there is a '/ between the dir and the file.
+
+       * util/ntp-genkeys.c (main): More small steps...
+
+2000-08-12  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntp-genkeys.c (main): Another small step...
+
+       * configure.in: 99k5
+
+       * include/ntp_request.h: Make data[] member of req_pkt 32 again.
+       Bump the version number...
+
+       * ntpd/ntp_loopfilter.c (local_clock): Change 0. to 0 in a couple
+       of places.
+       From Dave Mills
+
+2000-08-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntp-genkeys.c (main): Minimal progress...
+
+2000-08-06  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/check_y2k.c: Make debug definition match ntpd.h's declaration
+
+       * ntpd/Makefile.am (check-local): Use test in favor of [
+
+2000-08-05  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (NTP_KEYSDIR): Typo
+
+2000-08-04  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ElectricFence/Makefile.am (check-local): use test instead of [
+
+       * configure.in: AC_REPLACE_FUNCS(strdup)
+       * libntp/strdup.c (strdup): Added.
+       * libntp/Makefile.am (EXTRA_libntp_a_SOURCES): Added strdup.c
+
+       * util/Makefile.am (ntp_genkeys_DEPENDENCIES): Use $U on .o files
+       (ntp_genkeys_LDADD): ditto.
+
+       * ntpd/ntp_crypto.c: Use NTP_KEYSDIR
+
+       * util/ntp-genkeys.c (snifflink): Ignore ENOENT, too.
+
+       * ntpd/ntp_proto.c (peer_xmit): Crypto cleanup
+       * ntpd/ntp_crypto.c: Cleanup
+       * ntpd/ntp_control.c: Join the club
+       * ntpd/ntp_config.c: Call crypto_config() instead; we got rid of
+       crypto_flags.
+       * include/ntp_crypto.h (CRYPTO_FLAG_ENAB): New crypto flags, rework
+       * include/ntp_control.h (CS_FLAGS): Wiggle in.
+       * include/ntp.h: Added crypto peer status to struct peer
+       From Dave Mills
+
+2000-08-03  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntp-genkeys.c: Initialize path_keysdir to NTP_KEYSDIR.
+
+       * configure.in (NTP_KEYSDIR): Added
+       * acinclude.m4: Added AC_DEFINE_DIR macro
+
+       * util/ntp-genkeys.c (main): Sanity checks on the file paths.
+
+2000-08-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntp-genkeys.c (crypto_config): Only #ifdef PUBKEY
+       (PATH_MAX): Try harder...
+
+2000-08-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntp-genkeys.c (main): Use snifflink()
+       (snifflink): Implement...
+
+       * configure.in: Check for readlink()
+
+2000-07-31  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntp-genkeys.c (main): Use strdup on the tokens returned
+       from ntp_config...
+       (crypto_config): Fix a typo...
+       (crypto_config): Even more...
+       (usage): Flesh it out.
+
+       * include/ntp_config.h:
+       * ntpd/ntp_config.c: Move a whack of #defines to ntp_config.h so
+       ntp-genkeys.c can see them, too.
+
+       * util/ntp-genkeys.c: Add stubs to work with ../ntpd/ntp_config.o,
+       start hooking things up.
+       (main): debugging
+       (crypto_config): better implementation
+
+
+       * ntpd/ntp_config.c (getconfig):
+       * ntpd/ntpd.c: Initialize "debug" here, not in ntp_config.c
+
+       * util/Makefile.am (ntp_genkeys_LDADD): Added ../ntpd/ntp_config.o
+       * util/Makefile.am (ntp_genkeys_DEPENDENCIES): Added.
+
+2000-07-30  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99k4
+       * util/ntp-genkeys.c: Start hacking for new functionality.
+       * include/Makefile.am (noinst_HEADERS): Added ntp_cmdargs.h and
+       ntp_config.h .
+       * ntpd/ntp_config.c: Grab ntp_cmdargs.h.  Make some new globals
+       (ugh), move ntpd-specific variables and code to cmd_args.c .
+       * ntpd/cmd_args.c: Move command argument processing functions from
+       ntp_config.c to this file.
+       * ntpd/Makefile.am (ntpd_SOURCES): Added cmd_args.c
+       * include/ntpd.h: Move getstartup() to ntp_cmdargs.h
+       * include/ntp_cmdargs.h: New file
+       Begin the hacking fest to make it easier for ntp-genkeys to use
+       ntpd's config processing code.  I really hope this is the lesser
+       of the evils...
+
+2000-07-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntp-genkeys.c (usage): Added.
+
+       * ntpd/ntp_crypto.c: Cleanup
+       * ntpd/ntp_proto.c (transmit): Add some parens.
+       (peer_xmit): Add ntohl when grabbing sndauto.seq for broadcast.
+       * ntpd/ntp_peer.c (findpeer): Cleanup
+       * ntpd/ntp_loopfilter.c (local_clock): Typo
+       From Dave Mills
+
+       * include/ntp_config.h: Created
+
+       * util/ntp-genkeys.c: Always build, but realize we may not have
+       RSAREF.  Compile parts appropriately.
+
+       * util/Makefile.am (bin_PROGRAMS): Always make ntp-genkeys
+       (ntp-genkeys_LDADD): Use $LIBRSAREF instead of the "real path"
+       * configure.in: Lose MAKE_NTP_GENKEYS
+
+       * configure.in:
+       * util/ntp-genkeys.c:
+       * util/Makefile.am:
+       Renamed ntp_genkeys to ntp-genkeys.
+
+2000-07-27  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpdate/ntpdate.c (ntpdatemain): Cleanup error message.
+
+       * ntpdate/ntpdate.c (ntpdatemain): Add missing authtrust() call
+       From: Jason Heiss <jheiss@cruzeiro.ugcs.caltech.edu>
+
+       * ntpd/refclock_ulink.c (ulink_receive):
+       * ntpd/ntp_crypto.c:
+       * libntp/authparity.c:
+       Lint/noise cleanup
+       From: Marc Brett <mbrett@rgs0.london.waii.com>
+
+       * ntpd/ntp_proto.c: Specifically track manycastserver and
+       survivors
+       From: Dave Mills
+
+2000-07-26  Sven Dietrich  <sven_dietrich@trimble.com>
+
+       * ntpd/ntpd.c: remove WINNT priority adjustment to the ports/winnt area
+       where it does not clutter up the main distribution.
+
+2000-07-24  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (receive): dstadr_sin needs  higher visibility
+       From: Dave Mills
+
+       * flock-build: Added baldwin
+
+       * ntpd/ntp_request.c:
+       * ntpd/ntp_proto.c:
+       * ntpd/ntp_peer.c:
+       * ntpd/ntp_io.c:
+       * ntpd/ntp_intres.c:
+       * ntpd/ntp_crypto.c (make_keylist):
+       * ntpd/ntp_control.c:
+       * ntpd/ntp_config.c (CONF_MOD_IBURST, save_resolve):
+       * include/ntpd.h (findpeerbyassoc, newpeer, peer_config, *_interface):
+       * include/ntp_request.h (CONF_FLAG_IBURST):
+       * include/ntp_crypto.h (crypto_xmit, make_keylist):
+       * include/ntp.h (FLAG_IBURST):
+       * html/release.htm:
+       * html/confopt.htm:
+       * html/assoc.htm:
+       Add iburst option, fix broadcast/multicast and some types.
+       From: Dave Mills
+
+2000-07-20  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * scripts/Makefile.am (bin_SCRIPTS): Install ntp-wait
+
+       * configure.in: 4.0.99k
+
+2000-07-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (peer_xmit): PUBKEY cleanup
+
+2000-07-18  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99j5
+
+       * html/ntpd.htm (HREF): Document other missing command-line options
+
+       * html/ntpd.htm (HREF): Document
+       * html/confopt.htm (href): Undocument
+       * ntpd/ntp_config.c (getconfig): -N high for high-priority.
+       Lose the ntp.conf way of setting priority.
+
+       * ntpd/ntp_crypto.c: PUBKEY/AUTOKEY cleanup
+       From Dave Mills
+
+2000-07-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/confopt.htm (href): Document it.
+       * ntpd/ntp_config.c (getconfig): CONFIG_PRIORITY support
+       * ntpd/ntpd.c (set_process_priority): Use it.
+
+       * ntpd/ntp_crypto.c: Crypto key stuff
+       * ntpd/ntp_proto.c: pubkey -> pubkey.ptr
+       * ntpd/ntp_control.c (ctl_putpeer): fstamp -> pubkey.fstamp
+       * ntpd/ntp_peer.c:
+       * include/ntpd.h:
+       * include/ntp_types.h:
+       * include/ntp_request.h:
+       * include/ntp_crypto.h:
+       * include/ntp_control.h:
+       * include/ntp.h: Type cleanup
+       From: Dave Mills
+
+2000-07-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ElectricFence/Makefile.am (check-local): Don't run the tests if
+       we didn't build the programs...
+       (check-local): Same, but watch the return codes...
+
+       * ElectricFence/page.c: #include config.h if it's there.
+       Properly handle the sys_errlist declaration.
+
+       * html/ntpq.htm:
+       * html/index.htm:
+       * html/debug.htm:
+       * html/authopt.htm:
+       Reality check.
+       From Dave Mills
+
+2000-07-13  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * Makefile.am (SUBDIRS): Added ElectricFence
+       * configure.in (AC_CONFIG_FILES): Added ElectricFence support
+       * ElectricFence: Imporpted.
+
+2000-07-12  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/ntp_genkeys.c (main): Cleanup
+       * ntpd/refclock_wwv.c (wwv_qrz): sqrt -> SQRT
+       * ntpd/refclock_chu.c (chu_rf): sqrt -> SQRT
+       * ntpd/ntpd.c (set_process_priority): Disable  high-priority for now.
+       PUBKEY cleanup.
+       * ntpd/ntp_timer.c: sys_revoketime cleanup.
+       * ntpd/ntp_proto.c (receive): PUBKEY cleanup.  Comment and code
+       cleanup.
+       (process_packet): Comment and code (PUBKEY) cleanup.
+       (peer_xmit): Comment and code cleanup.
+       (fast_xmit): Comment and code cleanup.
+       * ntpd/ntp_peer.c (expire_all): revoketime cleanup.  PUBKEY cleanup.
+       * ntpd/ntp_crypto.c: Comment reorg.  DH parameters are now
+       file-static instead of local to subroutines.
+       (make_keylist): peer->pcookie.key cleanup/fix
+       (crypto_recv): Subroutine documentation cleanup, other cleanup
+       (crypto_xmit): Cleanup/document.
+       (crypto_setup): Cleanup/document.
+       (crypto_agree): Cleanup/document.
+       (crypto_rsa): now static
+       (crypto_dh): now static.  Comment cleanup.  Code cleanup.
+       (crypto_tai): now static.  Code and comment cleanup.
+       (crypto_config): Deal with CRYPTO_CONF_LEAP.
+       * ntpd/ntp_control.c (CS_DHPARAMS): Rename corresponding token to
+       "params".  Remove CS_TAI from def_sys_var[].
+       (ctl_putsys): CS_HOST, CS_DHPARAMSm CS_REVTIME, and CS_LEAPTIME
+       bugfix.  CS_TAI cleanup.
+       * ntpd/ntp_config.c (CONF_CRYPTO_LEAP): Added
+       (getconfig): Added CONF_CRYPTO_LEAP support.
+       * include/ntp_syslog.h: Lose GIZMO stuff.
+       * include/ntp_crypto.h (CRYPTO_CONF_LEAP): Added
+       * include/ntp.h: struct autokey, cookie,value, and pkt changes for
+       signature field.  Update the inline docs on pkt's exten field.
+       From: Dave Mills
+
+
+2000-07-08  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_util.c (stats_config): If we read a bogus old_drift,
+       use 0 instead of failing.
+
+2000-07-03  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * README.cvs: Cleanup.
+
+       * ntpd/refclock_datum.c (datum_pts_poll): index -> unit_index
+       * ntpd/ntp_resolver.c (findhostaddr): const cleanup
+       * libntp/recvbuff.c:
+       * libntp/msyslog.c:
+       * libntp/emalloc.c:
+       * libntp/authreadkeys.c:
+       Fix header order.
+       From: Simon Burge <simonb@netbsd.org>
+
+       * ntpd/ntp_util.c (stats_config): Use HAVE_FINITE and HAVE_ISFINITE
+       * configure.in (ac_cv_struct_ntptimeval_timespec): isfinite()
+       checks for HP-UX11.
+       From: Albert Chin-A-Young <china@thewrittenword.com>
+
+2000-07-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * flock-build (LIST): Lose malarky, update some machine/OS descriptions
+
+       * configure.in: 4.0.99j4
+
+       * ntpq/ntpq.c: Lose PUBKEY stuff - older ntpq's will complain when
+       they see the info in a packet.
+       * ntpd/ntp_proto.c (peer_xmit): TAI changes.
+       * ntpd/ntp_crypto.c: Fix host/network byteorder stuff.  Follow
+       global->struct changes.  TAI changes.  Bugfixes.
+       * ntpd/ntp_control.c: Follow field reorder/rename.
+       * include/ntp_crypto.h: Move crypto stuff from separate globals
+       into structs.
+       * include/ntp_control.h (CS_HOST): Reorder/rename some fields
+       From: Dave Mills
+
+2000-06-30  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_peer.c (unpeer): Moved keystr cleanup inside ifdef PUBKEY
+
+       * configure.in: 4.0.99j3
+
+       * html/release.htm:
+       * html/ntpq.htm:
+       * html/authopt.htm:
+       Updates from Dave Mills
+
+       * ntpd/ntp_request.c (dns_a): Don't call crypto_public for now...
+       * ntpd/ntp_proto.c (receive): Follow the TEST wiggles
+       (peer_xmit): TAI support
+       * ntpd/ntp_crypto.c: TAI support
+       * ntpd/ntp_control.c: CS_VERSION  and CS_TAI support
+       * include/ntp_crypto.h (CRYPTO_FLAG_TAI): Added.
+       * include/ntp_control.h (CS_VERSION): Added.
+       * include/ntp.h (TEST4,TEST5,TEST8,TEST9): Wiggle.
+       From: Dave Mills
+
+       * ntpd/Makefile.am (ntpd_SOURCES): Lose refclock_ulink331.c
+       because the new refclock_ulink.c handles it.
+
+2000-06-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_config.c (getconfig): Sanity check the right variable
+       From: Dave Mills.
+
+2000-06-25  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99j2
+
+       * ntpd/ntp_proto.c:
+       * ntpd/ntp_peer.c:
+       * ntpd/ntp_crypto.c:
+       * include/ntp_crypto.h:
+       * include/ntp.h:
+       AUTOKEY/PUBKEY/DH/crypto changes
+       From: Dave Mills
+
+2000-06-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/driver34.htm:
+       * ntpd/refclock_ulink.c:
+       * ntpd/refclock_ulink331.c: (removed)
+       Updated for 320/330 series refclocks
+       From: joseph lang <tcnojl1@earthlink.net>
+
+       * ntpd/refclock_oncore.c: Patches/improvements
+       * html/driver30.htm: New release
+       From: Reg Clemens <reg@orion.dwf.com>
+
+2000-06-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99j1
+
+       * ntpdc/ntpdc.c (getcmds):
+       * configure.in:
+       Readline support.
+       From: Aaron Sherman <ajs@narn.ajs.com>
+
+       * ntpd/refclock_ulink331.c: Added.
+       Sent in by Doug Grosso <dgrosso@mint.net>
+       * ntpd/Makefile.am (ntpd_SOURCES): Added refclock_ulink331.c
+
+       * libntp/snprintf.c: Added stdio.h
+       From: Marc Brett <mbrett@rgs0.london.waii.com>
+
+       * include/ntp.h: struct autokey's siglen is u_int32.  So is the
+       siglen in struct cookie.  So is siglen and value length in struct
+       value. Add fstamp to struct peer.  Resize the exten AUTOKEY field
+       in struct pkt.
+       * include/ntp_crypto.h: crypto_enable -> crypto_flags and a
+       variety of other cleanups.
+       * ntpd/ntp_config.c: crypto_enable -> crypto_flags, and some
+       key/fudge cleanup.
+       * ntpd/ntp_control.c: Much cleanup.
+       * ntpd/ntp_crypto.c: Many changes that Harlan is too tired to
+       properly document.
+       * ntpd/ntp_peer.c: crypto_enable -> crypto_flags
+       (peer_config): Hold off on crypto_public() until some resolver
+       issue is fixed.
+       * ntpd/ntp_proto.c (receive): Disable the reverse DNS lookup for now.
+       (process_packet): Don't record_raw_stats() for now.
+       crypto_enable was renamed to crypto_flags.
+       (peer_xmit): In MODE_ACTIVE or MODE_PASSIVE, only call
+       crypto_xmit() if the peer->cmmd is not CRYPTO_AUTO.  Reset
+       peer->cmmd to 0 when we're thru.
+       Don't reset peer->cmmd to 0 until the end of MODE_CLIENT.
+       * ntpd/ntpd.c: Lose the call to crypto_init().  Instead, call
+       crypto_setup() later on if we have crypto_flags.
+       * util/ntp_genkeys.c: Lose GENLEN; use PRIMELEN/2 .
+       From Dave Mills.
+
+       * ntpd/ntp_crypto.c (crypto_rsa):
+       (crypto_dh):
+       Do some debug logging if readlink() fails with something other
+       than EINVAL (file isn't a symlink).
+
+2000-06-04  James R. Van Zandt  <jrv@vanzandt.mv.com>
+
+       * html/miscopt.htm (trap): punctuation
+
+       * html/ntpd.htm (-g): typo
+
+       * html/miscopt.htm (logconfig): List the "clock" event class.
+       "allprefix" should be two words.
+
+2000-05-31  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_timer.c: Protect <unistd.h>
+
+2000-05-30  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/Makefile.am: Document what we expect from -lm
+
+2000-05-29  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99j
+
+2000-05-22  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/ntptime.htm: More fixes
+       From: Kazu TAKAMUNE <takamune@avrl.mei.co.jp>
+
+2000-05-16  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * build (KEYSUF):
+       * flock-build:
+       * configure.in: Lose the "md5" options from the --with-crypto
+       check; Dave hates it.
+
+       * ntpd/ntp_util.c (stats_config):
+       * ntpd/ntp_loopfilter.c (loop_config):
+       * libntp/systime.c (adj_systime):
+       * include/ntp_proto.h (NTP_MAXFREQ):
+       Renamed MAX_FREQ to NTP_MAXFREQ
+
+       * ntpd/ntpd.c (ntpdmain):
+       * ntpd/ntp_proto.c (receive):
+       (poll_update):
+       * ntpd/ntp_intres.c (addentry):
+       * ntpd/ntp_config.c (getconfig):
+       Lint cleanup
+       From: Marc Brett <mbrett@rgs0.london.waii.com>
+
+       * include/ntp_stdlib.h:
+       * libntp/systime.c (adj_systime):
+       * ntpd/ntp_loopfilter.c (loop_config):
+       * ntpd/ntp_util.c (stats_config):
+       * ports/winnt/ntpd/nt_clockstuff.c (adj_systime):
+       MAXFREQ -> MAX_FREQ
+       * include/ntp_proto.h: Define MAX_FREQ
+
+2000-05-15  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntp_stdlib.h:
+       * libntp/systime.c (adj_systime):
+       * ntpd/ntp_loopfilter.c (loop_config):
+       * ntpd/ntp_util.c (stats_config):
+       * ports/winnt/ntpd/nt_clockstuff.c (adj_systime):
+       sys_maxfreq -> MAXFREQ
+       Per Dave Mills.
+
+2000-05-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * acinclude.m4: Typo...
+
+2000-05-13  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/gpstolfp.c (GPSORIGIN): Try new ULONG_CONST macro
+
+       * ntpdate/ntptimeset.c:
+       * ntpdate/ntpdate.h:
+       * ntpd/refclock_oncore.c (oncore_msg_En):
+       * ntpd/ntp_util.c (stats_config):
+       * ntpd/ntp_request.c:
+       * ntpd/ntp_intres.c (findhostaddr):
+       * ntpd/ntp_config.c (getconfig):
+       * libntp/systime.c (adj_systime):
+       * libntp/lib_strbuf.c:
+       * libntp/authparity.c:
+       * libntp/audio.c:
+       Header/lint cleanup
+       From/reported by: Simon Burge <simonb@netbsd.org>
+
+       * ntpd/ntp_resolver.c (findhostaddr): Compiler noise cleanup
+
+       * ntpd/ntp_intres.c: Compiler noise cleanup
+
+       * html/ntptime.htm: Document reality check
+       From: Kazu TAKAMUNE <takamune@avrl.mei.co.jp>
+
+2000-05-12  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_intres.c (ntp_intres): Quiet some debug messages
+       Reported by: Brian Bergstrand <brianb@mac.com>
+
+2000-05-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * scripts/mkver.in (ConfStr): Use -r if we're using RSAREF,
+       otherwise use -a if we're using autokey, otherwise use no extra
+       suffix.
+
+2000-05-11  Sven Dietrich  <sven_dietrich@trimble.com>
+
+       * ports/winnt/include/config.h: New defines to support AUTOKEY
+       * ports/winnt/include/unistd.h: Added another dummy placeholder.h
+       * ports/winnt/ntpd/ntpd.dsp: Added ntp_crypt.c to makefile
+       * ports/winnt/ntpd/ntpd.c: service_main needs a local hostname[]
+       * html/hints/winnt.htm: Add remark about 4.0.99i not compiling.
+       These changes got WINNT running again. No idea if the keys stuff
+       works however.
+
+2000-05-10  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99i9
+
+       * ntpd/ntp_crypto.c: tstamp and autokey cleanup
+       From: Dave Mills
+
+       * ntpd/ntp_proto.c (clock_update): Only call expire_all() if
+       AUTOKEY
+       From many folks, including Reg Clemens <reg@dwf.com>
+
+2000-05-07  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99i8
+
+       * flock-build: Use new --with-crypto choices
+       * build (KEYSUF): Deal with new --with-crypto
+       * configure.in: --with-crypto={md5,autokey,rsaref};
+       lose --enable-autokey
+
+2000-05-06  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * build (KEYSUF): Catch --disable-autokey first.
+
+2000-05-05  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * flock-build: If we don't use autokey, don't use rsaref either.
+
+       * configure.in: 4.0.99i7
+
+       * build (KEYSUF):
+       * flock-build:
+       It's --disable-autokey now
+
+       * configure.in: MD5 is not optional (but AUTOKEY is)
+       * include/ntp_stdlib.h:
+       * libntp/a_md5encrypt.c:
+       * libntp/authkeys.c:
+       (authhavekey):
+       (MD5auth_setkey):
+       (auth_delkeys):
+       (authencrypt):
+       (authdecrypt):
+       * libntp/authreadkeys.c:
+       (authreadkeys):
+       * ntpd/ntp_proto.c (init_proto):
+       * libntp/authusekey.c:
+       MD5 is required.
+
+2000-05-04  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99i6
+
+       * ntpd/ntp_proto.c (transmit): Fix up the UNREACH code.
+       (receive): Lose some debug code.
+       (clock_update): expire_all() if LEAP_NOTINSYNC
+       crypto_xmit() a CRYPTO_AUTO if !FLAG_AUTOKEY instead of recauto.tstamp
+       crypto_xmit() a CRYPTO_PRIV (not CRYPTO_AUTO) based on pcookie.tstamp
+       crypto_xmit() a CRYPTO_AUTO (not CRYPTO_PRIV) based on FLAG_MCAST2
+       and !FLAG_AUTOKEY
+       * ntpd/ntp_crypto.c (crypto_recv): Clean up debug output.
+       Don't AUTOKEY if FLAG_MCAST2
+       From: Dave Mills
+
+       * flock-build: Also make obe withouyt md5 (no AUTOKEY)
+       * build (BDIR): Handle -noautokey build directory suffix
+       * configure.in: Prepare for AUTOKEY in mkver.in
+       * scripts/mkver.in (ConfStr): Indicate in the version string if
+       we're not using AUTOKEY.
+
+2000-05-03  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * scripts/ntp-wait.in: Fun things with backspaces
+
+       * configure.in: 4.0.99i5
+
+       * ntptrace/ntptrace.c: Protect sys/ioctl.h; grab config.h
+
+       * ntpd/ntp_proto.c (transmit): AUTOKEY and tstamp fixes.
+       (clock_update): Check oleap against LEAP_NOTINSYNC
+       (peer_clear): Free pubkey when we're done
+       Check peer's keynumber against the seq in MODE_BROADCAST.
+       Reorder tstamp changes.
+       * ntpd/ntp_crypto.c (crypto_recv): Check the packet if we get a
+       CRYPTO_RESP and reorder the update of tstamp.
+       (crypto_recv): Don't expire the peer until we're thru with it.
+       * include/ntp.h: AUTOKEY and pkeyid changes
+       From Dave Mills
+
+       * ntpdate/ntpdate.c: Protect sys/ioctl.h
+
+2000-05-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99i4
+
+       * include/ntp.h:
+       * include/ntp_crypto.h:
+       * include/ntpd.h:
+       * ntpd/ntp_crypto.c:
+       * ntpd/ntp_proto.c:
+       * ntpd/ntpd.c:
+       * util/ntp_genkeys.c:
+       Dave Mills closed some potential vulnerabilities in the key protocol.
+
+2000-04-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99i3
+
+       * ntpd/ntp_proto.c: Just check tstamp, forget about sndauto.seq
+       * ntpd/ntp_crypto.c (crypto_recv): Lose inappropriate ntohl()
+       conversion on tstamp.
+       AUTOKEY if tstamp>0, not !=
+       Stash tstamp before we check pcookie.key (several places)
+       * ntpd/ntp_control.c (ctl_putpeer): In CP_INITSEQ, check
+       recauto.key, not keylist.
+       From: Dave Mills
+
+2000-04-27  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99i2
+
+       * ntpq/ntpq.c: PUBKEY stuff
+       * ntpd/ntp_proto.c (clock_select): nreach, and better survivor pick.
+       * ntpd/ntp_peer.c (newpeer): Better nextdate choice.
+       * ntpd/ntp_control.c (ctl_putsys): Buglet in CS_HOSTNAM code.
+       From Dave Mills.
+
+2000-04-24  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * build (IAM): Show hostname if we trip a buildkey check.
+
+2000-04-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * build: deal with optional 1st argument (SIG), which must match
+       the contents of .buildkey
+
+       * flock-build: Generalize, implement SIG and .buildkey, and drive
+       list from LIST, which the user can override.
+
+2000-04-21  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99i1
+       Dave updated some docs, implemented the kpoll variable, and
+       wiggled a host/network byte order thing in the crypto key code.
+
+2000-04-16  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_wwvb.c (wwvb_receive): Grab any character (instead
+       of just a space) before the DSTchar.
+       From: Dave Mills
+
+2000-04-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99i
+
+       Dave made some documentation updates.
+
+2000-04-08  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * flock-build: Add malarky.  By default, --enable-parse-clocks.
+       Start 2 builds, one with and the other without rsaref.
+
+       * configure.in: 4.0.99h6
+       Dave improved the crypto stuff some more.
+
+2000-04-05  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_acts.c (acts_receive): Do a better job with year
+       conversions and leap-year checks.  The PTB stuff caught this.
+       Reported by: Daniel.Aeby@eam.admin.ch
+
+2000-04-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_atom.c (atom_pps): Bugfix
+       From: Philippe Charnier <charnier@xp11.frmug.org>
+
+2000-03-30  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libparse/clk_wharton.c (cvt_wharton_400a): Do not return
+       CVT_NONE when receiving the early warning bit set.
+       From: Philippe De Muyter  <phdm@macqel.be>
+
+       * configure.in: 4.0.99h5
+       Dave made more changes to the auth key stuff.
+
+2000-03-29  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99h4
+       Dave made a bunch of changes/fixes to the auth key stuff.
+
+2000-03-22  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_resolver.c: Typos.
+
+2000-03-21  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99h3
+
+       * ntpd/ntp_intres.c: Use LOG_INFO instead of LOG_DEBUG.
+       * ntpd/ntp_resolver.c: Ditto.
+
+2000-03-20  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/Makefile.am (ntp_genkeys_LDADD): Might need snprintf (-lntp)
+
+       * librsaref/Makefile.am (stamp-rsaref): nodist_HEADERS are not
+       supoprted yet.  Hack around it.
+
+       * ntpd/ntp_resolver.c (findhostaddr): hstrerror isn't always available.
+
+       * configure.in: Look for hstrerror.
+
+       * util/ntp_genkeys.c (main): Use snprintf, not sprintf.
+
+       * ntpd/ntp_crypto.c: Use gethostname, not uname
+       * util/ntp_genkeys.c: Ditto
+       From: Dave Mills
+
+2000-03-19  Harlan Stenn  <harlan@pfcs.com>
+
+       * ntpd/ntp_proto.c (receive): Rename ntp_res_send() to
+         ntp_res_name() and adjust the number of arguments.
+       * ntpd/ntp_resolver.c (ntp_res_name): Ditto
+       * include/ntpd.h: Ditto
+
+       * ntpd/ntp_resolver.c: Add de_done to the dns_entry structure.
+
+2000-03-18  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99h2
+
+       * libparse/Makefile.am (info_trimble.c): Use $(srcdir)/foo.sed
+       instead of foo.sed .
+
+       * librsaref/Makefile.am (stamp-rsaref): Copy each file to the build
+       directory, not to the source directory.  This sucks; it wastes
+       space (but it's more portable).
+
+       * configure.in (ac_busted_vpath_in_make): Add FreeBSD.  I bet all
+       systems that use pmake will need this.
+       (ac_busted_vpath_in_make): Remove FreeBSD - I found a workaround.
+
+       * Makefile.am: General cleanup
+
+       * configure.in: 4.0.99h1
+
+       * ntpd/ntp_resolver.c: Lose unneeded header.
+
+2000-03-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/snprintf.c: #include <config.h>
+
+       * libntp/Makefile.am (EXTRA_libntp_a_SOURCES): Use it correctly...
+
+2000-03-16  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/Makefile.am (EXTRA_DIST): Added snprintf.c
+
+       * configure.in: Look for (and provide if it's missing) snprintf()
+
+       * ntpd/ntp_request.c (dns_a): Call crypto_public with the resolved
+       name and the peer pointer.
+       (dns_a): crypto_public() is only available if PUBKEY is #defined.
+
+       * ntpd/ntp_crypto.c (crypto_public): sprintf is Evil.  Use snprintf.
+       (crypto_setup): Ditto
+       (crypto_read): Ditto
+
+       * ntpd/ntp_resolver.c (ntp_res_send): Lose some debugging noise.
+
+       * ntpd/ntp_config.c (getconfig): Lose testing code.
+
+       * ntpd/ntp_request.c (dns_a): Fix buglet in hostname length check.
+
+2000-03-16  Harlan Stenn  <harlan@pfcs.com>
+
+       * ntpd/ntp_request.c (dns_a): Start cracking the returned information.
+
+2000-03-15  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_resolver.c (ntp_res): Authenticate the keyid.
+
+       * ntpd/ntp_crypto.c (crypto_line): Fix definition
+       (crypto_read): Ditto.
+
+       * ntpd/ntp_config.c (getconfig): Move req_keyid generation here.
+
+       * librsaref/Makefile.am (BUILT_SOURCES): Cleanup more nodist_ stuff.
+
+2000-03-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * build (RSASUF): If we have rsaref2/ and are building
+       --without-rsaref, note it as a build-directory suffix.
+
+       * configure.in: 4.0.99h
+       Crypto merge
+
+       * librsaref/Makefile.am (nodist_librsaref_a_SOURCES): Added nodist_
+
+2000-02-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Lose the changequote calls and fix the quoting.
+       Reported by: Akim Demaille <akim@epita.fr>
+
+       * ntpd/ntp_request.c: Log various error conditions.
+
+2000-02-27  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99g
+
+       * ntpd/ntpd.c: Only log EINTR if debug > 2.
+
+2000-02-25  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * scripts/mkver.in (ConfStr): Use `-r' when configured with crypto.
+
+       * ntpd/refclock_wwvb.c (wwvb_receive): Undo the previous chagne.
+
+2000-02-24  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_wwvb.c (wwvb_receive): LENWWVB0 can return 6 or 7
+       fields.
+       From: Michael Sinatra <msinatra@uclink4.berkeley.edu>
+       with a cleanup from Ulrich.
+
+       * scripts/mkver.in (ConfStr): Make RSAREF appear as part of the
+       version.
+
+2000-02-21  Sven Dietrich <sven_dietrich@trimble.com>
+
+       * ports/winnt/include/config.h: Enable MD5 and RANDOM by default
+       * ports/winnt/libntp/SetSystemTime.c: Fix warning and const declaration
+       From: Carl Byington <carl@five-ten-sg.com>
+
+2000-02-21  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * Makefile.am (SUBDIRS): Make librsaref right after includes so we
+       can copy any needed header files over.
+
+       * libntp/Makefile.am (INCLUDES): Also look in librsaref for des.h
+       * ntpd/Makefile.am (INCLUDES): Ditto
+       * util/Makefile.am (INCLUDES): Ditto
+
+       * librsaref/Makefile.am (librsaref_a_SOURCES): Use the des.h from
+       the rsaref2 distribution.
+
+       * include/Makefile.am (noinst_HEADERS): No, we don't want des.h
+
+2000-02-20  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/Makefile.am (noinst_HEADERS): Add des.h
+
+2000-02-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_config.c (do_resolve_internal): Try Real Hard to
+       generate a full random key.
+       From: Carl Byington <carl@five-ten-sg.com>
+
+       * include/ntp.h: Now we know we have either mrand48() or random().
+       * configure.in: If we have mrand48, use it.  Otherwise, use (and
+       provide if necessary) random().
+       * libntp/Makefile.am (EXTRA_DIST): random.c
+       * libntp/random.c: Added.
+
+2000-02-18  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * librsaref/Makefile.am (stamp-rsaref): Typo
+
+       * configure.in (ac_cv_func_ctty_for_f_setown): Yes for OpenBSD
+       (ac_cv_var_ntp_syscalls): Fix quoting of description
+       From: Jonathan Rozes <jrozes@vinton.com>
+
+       * librsaref/Makefile.am: Fix stamp-rsaref dependency order.
+
+       * configure.in: 4.0.99f
+
+2000-02-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_mx4200.c: Remove the DOP-weighted position
+       averaging code and revert to a simple mean average.  The weighted
+       average consistently produced a *worse* result.  Go figure.
+       * html/mx4200data.htm: Cleanup, reflect current reality.
+       * html/driver9.htm: Cleanup, reflect current reality.
+       * html/copyright.htm: Cleanup, and credit where credit is due.
+       From: Marc.Brett@westgeo.com
+
+       * ntpd/refclock_oncore.c: Cleanup/fixes
+       * html/driver30.htm: Cleanup
+       * html/Oncore-SHMEM.htm: Cleanup
+       From: Reg Clemens <reg@dwf.com>
+
+2000-02-16  Sven Dietrich <sven_dietrich@trimble.com>
+
+       * winnt/scripts/mkver.bat:    Frederick Czajka [w2k@austin.rr.com]
+         winnt/ntpq/ntpq.dsp:        modified mkver.bat to eliminate the
+         winnt/ntpd/ntpd.dsp:        need to have Perl installed and the
+         winnt/ntpdc/ntpdc.dsp:      PERL environment variable to be set.
+         winnt/ntpdate/ntpdate.dsp:
+         winnt/ntptrace/ntptrace.dsp:    Thanks, Frederick!
+
+       * ntpd/refclock_nmea.c: Correctly interpret the quality indicator.
+
+2000-02-15  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_nmea.c: Correctly interpret the quality indicator.
+       Deal with the time supplied in centiseconds.  GPGCA/GPGGA cleanup.
+       From: Andrew Hood <ajhood@fl.net.au>
+
+       * libparse/Makefile.am (K_CFLAGS): Use instead.  Add NEED_NTP_BOPS.
+
+2000-02-10  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * scripts/ntp-wait.in: Intensify, including some suggestions from
+       Ulrich.
+
+       * configure.in: 4.0.99e
+
+       * scripts/ntp-wait.in: Lose cruft, sleep after each try.
+
+       * scripts/ntp-restart: It's ntpd now.  Also, call ntp-wait.
+
+       * configure.in (AC_CONFIG_*): New scripts that use PATH_PERL
+
+       * scripts/Makefile.am (noinst_SCRIPTS): Added ntp-wait
+       (noinst_SCRIPTS): Added all of the scripts that now use PATH_PERL
+
+       * configure.in: Get the path to perl
+       (AC_CONFIG_*): Added scripts/ntp-wait
+
+       * ntptrace/ntptrace.c (DoTrace): If the server's srcadr is 0.0.0.0
+       then we haven't synced yet.  Note and punt.
+       Reported by: Bdale Garbee <bdale@gag.com>,http://bugs.debian.org/56551
+
+2000-02-09  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ports/winnt/include/config.h: Typo (CLOCK_PALISADE comment)
+       From: Carl Byington <carl@five-ten-sg.com>
+
+       * configure.in: Disable kernel_fll_bug for Generic_105181-17 under
+       Solaris-2.6
+       From: Juergen Georgi <georgi@belwue.de>
+
+2000-02-07  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99d
+
+       * html/Oncore-SHMEM.htm: New document
+       * html/driver30.htm: Cleanup and improvements
+       From: Reg Clemens <reg@dwf.com>
+
+2000-01-30  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c: Patches/improvements
+       From: Reg Clemens <reg@dwf.com>
+
+2000-01-29  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99c
+
+2000-01-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Autoconf update...
+
+       * ntpdate/ntpdate.c (ntpdatemain): Typo
+       From: Jack Bryans <jbryans@csulb.edu>
+
+       * Makefile.am (EXTRA_DIST): Add flock-build.  Probably UDel specific...
+
+2000-01-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/check_y2k.c (main): Reformat for ansi2knr
+
+       * configure.in (AC_OUTPUT): Revert to obsolete form until automake
+       catches up.
+
+2000-01-22  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Use AC_CHECK_TYPES((s_char)) instead of
+       AC_CHECK_TYPE.
+       (ac_cv_var_kernel_fll_bug): Generic_106541-08 is apparently OK, too.
+
+       * scripts/Makefile.am (EXTRA_DIST): Need to explicitly distribute
+       mkver.in and ntpver.in now, apparently.
+       * configure.in: Search for the various audio_info members so the
+       printing in audio_show is less of a circus.  This required an
+       autoconf upgrade.  Major sigh.
+
+       * libntp/audio.c (audio_show): Clean up (more) properly.
+
+2000-01-21  Sven Dietrich <sven_dietrich@trimble.com>
+
+       * Add pointer to html/hints/winnt.htm to INSTALL file
+       * Fix NT makefiles to accomodate at least one weird
+         version of Visual C that can't handle the LFs without
+         the DOS CR also.
+
+2000-01-20  Sven Dietrich <sven_dietrich@trimble.com>
+
+       * Update Copyright in Palisade driver to 2000
+       * Fix Palisade MIN & MAX POLL to optimal values
+
+2000-01-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/driver7.htm: Patches from Dave Mills
+       * html/driver36.htm: Patches from Dave Mills
+
+       * html/copyright.htm: Added Kamal Mostafa
+
+2000-01-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99b
+
+2000-01-18  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_chu.c: NCHAN is used with generic ICOM.
+
+       * ntpd/refclock_wwv.c: Use new audio stuff
+       * ntpd/refclock_irig.c: Use new audio stuff
+       * ntpd/refclock_chu.c: Use new audio stuff
+       * ntpd/ntp_proto.c: Clean up
+       * ntpd/ntp_loopfilter.c (local_clock): Clean up error message
+       * include/icom.h: Number of arguments changed
+       * libntp/Makefile.am (libntp_a_SOURCES): Added audio.c
+       * libntp/audio.c: New file
+       * include/Makefile.am (noinst_HEADERS): audio.h added
+       * include/audio.h: New file
+       From: Dave Mills <mills@udel.edu>
+
+       * scripts/freq_adj: Added.  FreeBSD frequency adjustment script.
+
+       * configure.in: Do a better job on my oncore_ok check for SCO.
+
+2000-01-15  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99a
+
+       * scripts/ntpsweep: New version
+       * html/copyright.htm: Added Hans Lambermont
+       From: Hans Lambermont <Hans.Lambermont@nl.origin-it.com>
+
+2000-01-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c (oncore_start): Only dance with the
+       pps_device if it's there.
+       From: reg@dwf.com
+
+       * configure.in: ONCORE is OK if ac_cv_hdr_def_tiocdcdtimestamp=yes
+
+       * build: Just overwrite the log file each time; sometimes NFS goes
+       a little goofy.
+
+       * ntpd/refclock_fg.c: Syntax/punctuation cleanup
+
+2000-01-13  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * scripts/ntpsweep: New version
+       From: Hans Lambermont <Hans.Lambermont@nl.origin-it.com>
+
+       * ntpd/refclock_fg.c: New version
+       * html/driver37.htm: New version
+       From: Dmitry Smirnov <das@online.nsk.su>
+
+2000-01-12  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * README.des: Cleanup
+
+2000-01-12  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.99
+
+       * html/driver36.htm: Cleanup
+       * html/monopt.htm: Ditto
+       From: Dave Mills <mills@udel.edu>
+
+       * ntpd/ntp_intres.c (ntp_intres): Put "NTP_INTRES running" at a
+       higher debug level
+
+2000-01-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_wwv.c: More improvements
+       From: Dave Mills <mills@udel.edu>
+
+2000-01-10  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_wwv.c: Bugfixes/improvements
+       From: Dave Mills <mills@udel.edu>
+
+       * configure.in: Get the quoting right on the sys_errlist check.
+       From documentation by: Akim Demaille <akim@epita.fr>
+
+2000-01-08  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: <netinet/ip.h> cannot be detected...
+       * ntpd/ntp_io.h: ...but every OS has it
+       * ntpd/refclock_oncore.c: Lint removal
+       * ntpq/ntpq_ops.c: Lint removal
+       * ntpq/refclock_chu.c: chu_major() is not an audio routine (?), lint
+       * libntp/icom.c: AIX doesn't have <sys/termios.h>
+       From: Marc.Brett@westgeo.com
+
+       * ntpd/refclock_chu.c: NetBSD needs sys/ioctl.h
+       (chu_debug): NetBSD-specific debug output.
+       From: Frederick Bruckman <fb@enteract.com>
+
+2000-01-06  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98m
+       I skipped `l' - it looks like a `1'.
+
+       * html/driver7.htm: Doc update
+       * html/driver36.htm: Ditto
+       * html/audio.htm: Ditto
+
+       * ntpd/refclock_wwv.c: Dvae snuck another fix/change in on me.
+
+       * configure.in: 4.0.98k
+
+       * ntpd/refclock_chu.c (chu_start): Call icom_init with the speed
+       * ntpd/refclock_wwv.c (wwv_start): Ditto, plus other improvements.
+       * libntp/icom.c (icom_init): Add speed parameter
+       * include/icom.h: Update declaration
+       From: Dave Mills <mills@udel.edu>
+
+       * include/Makefile.am (noinst_HEADERS): Added icom.h
+       From: Frederick Bruckman <fb@enteract.com>
+
+2000-01-05  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98j
+
+       * ntpd/refclock_wwv.c (timecode): Make definition == declaration
+       (wwv_newchan): Ditto
+       (wwv_corr4): Dave fixed the declaration.
+
+       * flock-build: Add rackety to the flock - it runs SunOS 4.1.3/cc
+
+       * ntpd/refclock_wwv.c: Undo that declaration cleanup for now...
+
+       * ntpd/ntp_io.c (open_socket): TOS support
+       From: Marc.Brett@westgeo.com
+
+2000-01-04  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_wwv.c: Declaration cleanup
+       * ntpd/refclock_fg.c (fg_receive): Not all sprintf's are created
+       equal...
+       From: Marc.Brett@westgeo.com
+
+       * ntpd/refclock_wwv.c: Dave Cleaned and Improved things.
+       * ntpd/ntp_loopfilter.c (local_clock): Dave fixed something.
+
+       * ntpd/refclock_wwv.c: Rename max to p_max or s_max as appropriate
+       to avoid native SunOS compiler collision.
+       (wwv_epoch): Make declaration == definition
+       (wwv_rsec): Ditto
+       (wwv_newchan): Ditto
+       (wwv_qsy): Ditto
+       (timecode): Ditto
+
+       * ntpd/refclock_oncore.c (oncore_init_shmem): Use a cast to widen
+       mmap's NIL offset.
+
+       * ntpd/refclock_chu.c (chu_rf): Make declaration == definition.
+       Rename min/max to es_min/es_max to avoid native SunOS compiler
+       collision.
+       (chu_uart): Make declaration == definition.
+
+       * libntp/icom.c (sndpkt): Make declaration and definition equivalent.
+       (doublefreq): Ditto.
+
+       * ntpd/refclock_oncore.c (MAP_FAILED): Some systems do not #define
+       this.
+
+       * ntpd/refclock_wwv.c:
+       * ntpd/refclock_chu.c:
+       * libntp/icom.c:
+       * libntp/Makefile.am:
+       * include/icom.h:
+       * html/driver7.htm:
+       * html/driver36.htm:
+       Support for ICOM.  The WWV/H driver, by the way, is getting truly
+       awesome.  The CHU autotune function works okay as it is.  I'd like
+       to find somebody else to test the audio drivers just to make sure
+       I haven't done something stupid.  There is a new define ICOM
+       intended for the driver autotune function; however, I crafted the
+       thing in much the same way as the refclock_atom.c thing - it tries
+       to open /dev/icom and, if that fails, goes quietly to sleep.
+       From: Dave Mills <mills@udel.edu>
+
+2000-01-03  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c (oncore_read_config): Patches and cleanup
+       From: Poul-Henning Kamp <phk@critter.freebsd.dk>
+       more isascii() stuff from HMS.
+
+       * ntpd/refclock_fg.c (fg_receive): Cast.
+       From: Tom Smith <smith@cag.lkg.dec.com>
+
+       * ntpd/map_vme.c (map_vme): tx.access_result indicates failure on
+       < 0, not <= 0.  A fix that apparently did not get brought over
+       from the ntp3 base.
+       From: Michael Barone <michael.barone@lmco.com>
+
+       * configure.in: Move the ONCORE_SHMEM_STATUS check and definition
+       here.
+
+       * ntpd/refclock_oncore.c (oncore_init_shmem): Some systems do not
+       have MAP_HASSEMAPHORE.
+
+       * ntpd/refclock_oncore.c: Drive ONCORE_SHMEM_STATUS based on
+       HAVE_SYS_MMAN_H .  If this needs finer checks, do it in
+       configure.in .
+       (oncore_read_config): Add the isascii() checks; older versions of
+       Unix don't guarantee correct behavior of is*() without it.
+
+       * ntpd/refclock_oncore.c: Add proof-of-concept support for
+         delivering receiver data stream to other processes through
+         a memory-mapped file.
+         From: Poul-Henning Kamp <phk@FreeBSD.org>
+
+2000-01-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_refclock_chu): Provide the CHU driver by
+       default, and by default prefer the AUDIO version.  We used to
+       limit this to SunOS or Solaris; now we drive by the availability
+       of the audioio header file.
+       Select the IRIG and WWV audio drivers the same way.
+
+       * flock-build: build ignores the -l flag; lose it.
+       (BUILD_ARGS): added.
+       * build: Remove unused -l stuff (LOG variable).
+
+       * ntpd/ntp_refclock.c: HAVE_PPSAPI header cleanup
+       From: Reg Clemens <reg@dwf.com>
+
+2000-01-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (CLOCK_WWV): Require <sys/audioio.h> or <sun/audioio.h>
+
+1999-12-29  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98i
+
+       * ntpd/refclock_gpsvme.c: Fixes
+       From: Michael Barone <michael.barone@lmco.com>
+       Patch severely hacked by HMS to "make it conform".  I hope I
+       didn't break anything.
+
+       * scripts/ntpsweep: Nifty utility
+       From: Hans.Lambermont@nl.origin-it.com
+
+       * ntpd/refclock_fg.c:
+       * ntpd/refclock_conf.c:
+       * ntpd/ntp_control.c:
+       * ntpd/Makefile.am:
+       * libntp/clocktypes.c:
+       * include/ntp.h:
+       * html/refclock.htm:
+       * html/driver37.htm:
+       * configure.in:
+       * acconfig.h:
+       Forum Graphic GPS clock support
+       From: Dmitry Smirnov <das@online.nsk.su>
+
+       * configure.in: Default to compile the IRIG, CHU and WWV/H
+       drivers and compile the CHU driver for audio, not modem.
+       Requested by Dave Mills.
+
+       * html/audio.htm:
+       * html/driver36.htm:
+       * html/qth.htm:
+       Dave wrote these to go along with the changes I checked in yesterday.
+
+1999-12-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_wwv.c:
+       * ntpd/refclock_conf.c:
+       * ntpd/refclock_chu.c:
+       * ntpd/ntp_refclock.c:
+       * ntpd/ntp_loopfilter.c:
+       * html/refclock.htm:
+       * html/pps.htm:
+       * html/index.htm:
+       * html/driver7.htm:
+       * html/driver6.htm:
+       * html/copyright.htm:
+
+       I indulged an old agenda to polish up some programs originally
+       written for a DSP evaluation board. The result is a really hot
+       audio driver for the NIST WWV/WWVH time/frequency station plus a
+       makeover for the CHU audio driver. Currently, they and their IRIG
+       audio driver buddy use the SunOS/Solaris audio interface, which is
+       clean and simple. I hook the line in jack to a shortwave radio and
+       these drivers (driver 7 for CHU and driver 36 for WWV) and the
+       drivers do the rest. The WWV/H driver is really hot - I am
+       currently watching the ionosphere move from the doppler that shows
+       up on the tick modulation tracked by the program. During midday
+       when the F2 layer settles down, the program closes in on a few
+       tens of microseconds of spare jitter and wander.  This watch on
+       whichever 15/20 MHz signal sounds the best. At night on 5/10 MHz
+       and even 2.5 HMz where the multipath, interference and noise are
+       much worse, the driver bangs around somewhat more.
+
+       The CHU driver makeover discovered a few broken bones after all
+       these years, but its majority decoder is back in business. For
+       various reasons to icky to reveal here, its 103-modem demodulator
+       is not quite as good as the chip, but it comes close and hey,
+       2025/2125 FSK is just not a good idea for HF radio. This driver is
+       not nearly as sophisitcated as the WWV/H driver, but here a few
+       hundred miles south of Ottawa, it does a passably good job.
+
+       I tell you this in the hopes of getting somebody interested in
+       porting the audio interface to other machines, in particular
+       Linux, FreeBSD and anything else with a sound card. When the
+       ionosphere stays cool, the WWV/H driver is as good as anything
+       else around here and with much less jitter than a serial port. The
+       only downside is all the audio drivers chew up a modest fraction
+       of cycles for the DSP routines - a few percent on the newer
+       silicon, up to half the cycles on an old Sparc IPC. Whattheheck,
+       these old machines aren't doing anything else around here except
+       serving time, and even when sucking cycles for DSP they still mind
+       the PPS microseconds.
+
+       The audio driver documentation had a makeover, too.
+       From: Dave Mills <mills@udel.edu>
+
+1999-12-20  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98h
+
+1999-12-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/syssignal.c: Small cleanup to Marc's patch.
+
+       * ntpd/ntp_refclock.c:
+       * ntpd/refclock_atom.c: Header cleanup
+       * html/driver30.htm: Cleanup and improvements.
+       From: Reg Clemens <reg@dwf.com>
+
+       * ntpd/ntp_refclock.c:
+       * ntpd/refclock_jupiter.c:
+       * ntpd/refclock_msfees.c:
+       * ntpd/refclock_mx4200.c:
+       Portability (Solaris) patches
+       * ntpd/refclock_mx4200.c:
+       Self-survey improvements, cleanup for, PPS re-activation
+       * libntp/syssignal.c:
+       Fix for "interrupted system call" (EINTR) failure of the PPS
+       ioctl(TIOCGPPSEV) call in Solaris.  Not sure why it was
+       interrupted, but this works around the failure.  Not sure if
+       the (now silent) interrupt affects the timing accuracy.
+               THERE IS A CHANCE THIS PART OF THE PATCH MAY ADVERSELY
+               AFFECT OTHER SYSTEMS!
+       * scripts/ntp-status: Added.
+       From: Marc.Brett@westgeo.com
+
+       * ntpdate/ntpdate.c: Deal with multiple addresses.
+       From: Jeffrey C Honig <jch@bsdi.com>
+
+       * ntpd/refclock_conf.c: Replaced macro SHM with CLOCK_SHM.
+       * ntpd/refclock_shm.c (shm_poll): Take clock time in UTC.
+               pp->day starts at 1, t->tm_yday starts at 0.
+       From: Jakob Stoklund Olesen <stoklund@taxidriver.dk>
+
+1999-12-16  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * NEWS: Updated ONCORE instructions
+       From: Kamal A Mostafa <kamal@whence.com>
+
+1999-12-13  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98g
+
+       * ntpd/refclock_oncore.c: Cleanup and fixes
+       From: Reg Clemens <reg@dwf.com> and Kamal A Mostafa <kamal@whence.com>
+
+1999-12-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_wwv.c: Cleanup/checkin of the current state of affairs.
+       From: Dave Mills <mills@udel.edu>
+
+       * ntpd/refclock_oncore.c: #elif conversion.  I can only hope I did
+       it right.
+
+       * ntpd/refclock_oncore.c: Various patches
+       From: Reg Clemens <reg@dwf.com> and Kamal A Mostafa <kamal@whence.com>
+
+1999-12-09  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_proto.c (default_get_precision): Use the right arg type
+       to pass "sizeof freq" to sysctlbyname().
+       From: Ollivier Robert <roberto@eurocontrol.fr>
+
+       * ntpd/refclock_wwv.c: Cleanup and fixes.
+       From: Dave Mills <mills@udel.edu>
+
+1999-12-08  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_wwv.c: Cleanup and fixes
+       * ntpd/refclock_conf.c: WWV declaration cleanup.
+       From: Dave Mills <mills@udel.edu>
+
+1999-12-07  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libparse/clk_rawdcf.c (cvt_rawdcf): Buglet.
+       From: Frank Kardel <kardel <AT> acm.org>
+
+1999-12-06  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/Makefile.am (ntpd_SOURCES): Added refclock_wwv.c
+
+       * ntpd/refclock_wwvb.c:
+       * ntpd/refclock_wwv.c:
+       * ntpd/refclock_conf.c:
+       * ntpd/refclock_chu.c:
+       * libntp/clocktypes.c:
+       * include/ntp.h: Dave cleaned some things up
+       Dave cleaned some things up (WWVB -> SPECTRACOM, CHU -> CHU_AUDIO,
+       WWV_AUDIO)
+
+       * acconfig.h: REFCLOCK_WWVB -> REFCLOCK_SPECTRACOM, added REFCLOCK_WWV
+       * configure.in: Deal with it.
+
+1999-12-05  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_refclock.c (refclock_open): More PPS cleanup
+       From: Dave Mills <mills@udel.edu>
+
+       * ntpq/ntpq.c:
+       * ntpq/ntpq_ops.c:
+       Make `ntpq -pn' independent of DNS, ad advertised.
+       From: Kamal A Mostafa <kamal@whence.com>
+
+       * ntpd/refclock_mx4200.c (mx4200_start): make missing 3rd
+       parameter a 0.
+
+1999-12-04  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_refclock.c (refclock_open): "flags" processing cleanup
+       (refclock_open): PPS device initialization cleanup
+       * include/ntp_refclock.h (LDISC_CHU):
+       (LDISC_PPS): Clean up comments
+       From: Dave Mills <mills@udel.edu>
+
+1999-12-03  Sven Dietrich <sven_dietrich@trimble.com>
+
+       * libntp/mexit.c: Moved WINNT port specific file to ports/winnt/libntp
+       * ports/winnt/libntp/libntp.dsp: Fix WinNT makefile for new source loc.
+
+1999-12-03  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/Makefile.am (libntp_a_SOURCES): Lose mexit.c - Sven will
+       move it to the winnt port area.
+
+1999-12-03  Sven Dietrich <sven_dietrich@trimble.com>
+
+       * libntp/systime.c: Removed adjtime hack for WINNT
+       * ports/winnt/ntpd/nt_clockstuff.c: Winnt double precision adjtime
+       * ports/winnt/inlcude/clockstuff.h: Remove no longer needed externs
+
+1999-12-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libparse/Makefile.in: Manually hacked to remove the
+       libparse_kernel.a.[co] cruft
+
+       * libparse/Makefile.am (k*.o): Generate these form the Makefile,
+       not from separate .c files
+
+       * html/tickadj.htm:
+       * html/notes.htm:
+       * html/hints/solaris.html:
+       Point to the new dosynctodr report.
+
+       * html/hints/solaris.xtra.S99ntpd:
+       Update.  Should be rewritten to take advantage of the new -g
+       switch and perhaps a loop to wait until ntpd hits a reasonable
+       "state".
+
+       * html/hints/solaris-dosynctodr.html: New information
+       From: "John W. Sopko Jr." <sopko@cs.unc.edu>
+
+1999-12-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/authkeys.c (auth_moremem): Clear memory allocated for sk.
+       From: Hugo Mildenberger <hugo.mildenberger@topmail.de>
+
+1999-12-01  Sven Dietrich <sven_dietrich@trimble.com>
+
+       * libntp/recvbuff.c: Unused functions cleanup
+       * ntpd/ntpd.c: ProcessorAffinity, IO cleanup
+       * ports/winnt/instsrv/instsrv.c: Service name changed to NTP
+
+       NT port shouldn;t hop between CPUs. Set affinity to first processor.
+       Service name was NetworkTimeProtocol. Too long. Now NTP.
+
+1999-12-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * scripts/plot_summary.pl: Improved option parsing.  Fixed one
+       minor Perl compatibility error.
+       * scripts/summary.pl: Official revision for NTPv4: Parse new
+       statistic file formats correctly, provide error checking for bad
+       input files, and guard against negative arguments to sqrt()
+       because of numeric effects.  Use one pattern to select valid
+       statistic files.  Add selectable output directory
+       (``--output-directory'') and improved option parsing.  Directory
+       with statistic files (now settable also with
+       ``--input-directory'') defaults to ``/var/log/ntp''.
+       From: Ulrich Windl  <Ulrich.Windl@rz.uni-regensburg.de>
+
+       * html/driver8.htm:
+       * libparse/clk_computime.c:
+       * libparse/clk_dcf7000.c:
+       * libparse/clk_hopf6021.c:
+       * libparse/clk_meinberg.c:
+       * libparse/clk_rawdcf.c:
+       * libparse/clk_rcc8000.c:
+       * libparse/clk_schmid.c:
+       * libparse/clk_trimtaip.c:
+       * libparse/clk_trimtsip.c:
+       * libparse/data_mbg.c:
+       * libparse/kclk_computime.c:
+       * libparse/kclk_dcf7000.c:
+       * libparse/kclk_hopf6021.c:
+       * libparse/kclk_meinberg.c:
+       * libparse/kclk_rawdcf.c:
+       * libparse/kclk_rcc8000.c:
+       * libparse/kclk_schmid.c:
+       * libparse/kclk_trimtaip.c:
+       * libparse/kclk_trimtsip.c:
+       * libparse/kparse.c:
+       * libparse/kparse_conf.c:
+       * libparse/parse.c:
+       * libparse/parse_conf.c:
+       * libparse/parsesolaris.c:
+       * libparse/parsestreams.c:
+       * ntpd/refclock_parse.c:
+       Mods and updates
+       From: Frank Kardel <kardel <AT> acm.org>
+
+       * acconfig.h: PCF refclock
+       * configure.in:
+       * html/driver35.htm:
+       * html/refclock.htm:
+       * include/ntp.h:
+       * libntp/clocktypes.c:
+       * ntpd/Makefile.am:
+       * ntpd/ntp_control.c:
+       * ntpd/refclock_conf.c:
+       * ntpd/refclock_pcf.c:
+       From: Andreas Voegele <andreas.voegele@gmx.de>
+
+       * acconfig.h: DECL_STIME_1
+
+       * configure.in (iCFLAGS): Use -std1 for alpha*-dec-osf* if we are
+       using "cc".
+       Reported by: Tom Smith <smith@cag.lkg.dec.com>
+
+1999-11-30  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/l_stdlib.h: DECL_SYSTIME_1 --- a long *
+       * configure.in: Use it for DEC OSF[45]
+       Reported by: Tom Smith <smith@cag.lkg.dec.com>
+
+       * ntpd/refclock_parse.c: Add missing declarations
+       * ntptrace/ntptrace.c: Ditto
+       * ntpd/ntp_proto.c: Ditto
+       * ntpd/refclock_palisade.c: Ditto
+       From: Jonathan Stone <jonathan@dsg.stanford.edu>
+
+1999-11-18  Sven Dietrich  <sven_dietrich@trimble.com>
+       * Win NT port updates
+       * ntpd.dsp: makefile only builds supported refclocks
+       * config.h: cleanup, undefine unsupported clock_atom
+       * win32_io, clock_NMEA: foundation for future refclock support
+       * recvbuff, transmitbuff, IOcompletionport: streamline packet handler
+       * html/hints/winnt.htm: Added up-to-date html docs for WINNT
+
+1999-11-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/copyright.htm: Credit Jack for his work.
+
+       * html/pic/*: Save a *ton* of space on the pictures.
+       From: Jack Sasportas <jack@innovativeinternet.com>
+
+1999-11-16  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in :  changequote for osf[45] test.
+       Reported by: Tom Smith <smith@cag.lkg.dec.com>
+
+       * ntp_update: Ignore stuff in any A.* directory.
+
+1999-11-15  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Clean up header checks for sys/syssgi.h and
+       sys/select.h .  Originally, we did not check for sys/select.h
+       under some versions of SCO (see xntp3-5).  Somewhere in ntp4 we
+       dropped the SCO check and added the check for sys/syssgi.h,
+       exclusive of checking for sys/select.h.  Marc Brett can't think of
+       a reason why we should not be checking for sys/select.h, so let's
+       look for it now.
+
+1999-11-13  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpdate/ntpdate.c: Add the ability for ntpdate to query a
+       multicast address.  We use the response to the multicast address
+       to learn new servers which we then add to the peer list and query.
+       In changing this I made the list of peers a linked list.
+
+       To be complete I should detect a broadcast address and make it
+       behave the same way.  But that requires a scan of the interface
+       list which is more complicated that I want to deal with...
+
+       Fix a bug, allowing ntpdate to compile if SLEWALWAYS and STEP_SLEW
+       are both defined.
+
+       From: Jeffrey C Honig <jch@bsdi.com>
+
+       * ntpd/ntp_refclock.c: sys/sio.h and SCO5_CLOCK cleanup
+       From: Kamal A Mostafa <kamal@whence.com>
+
+       * ntpd/ntp_loopfilter.c: Let -g do a "correct any" for the first
+       time adjustment.
+       From: Dave Mills <mills@udel.edu>
+
+       * configure.in: sys/sio.h needs to be checked independently.
+       Reported by: Kamal A Mostafa <kamal@whence.com>
+
+1999-11-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98f
+
+       * configure.in: DECL_PLOCK_0 and DECL_STIME_0 are for dec-osf5*, too
+       * ntpd/ntpd.c:  DEC OSF cleanup (editorial comments by HMS)
+       From: Tom Smith <smith@cag.lkg.dec.com>
+
+       * ntpd/ntp_refclock.c: MAXUNIT bugfix
+       From: Marc.Brett@westgeo.com
+
+       * ntpd/ntp_refclock.c:
+       * ntpd/ntpd.c:
+       * ntpd/refclock_arc.c:
+       * ntpd/refclock_as2201.c:
+       * ntpd/refclock_atom.c:
+       * ntpdc/ntpdc.c:
+       * ntpq/ntpq.c:
+       Code cleanup.
+       From: Marc.Brett@westgeo.com
+
+       * include/ntp_stdlib.h:
+       * libntp/systime.c:
+       * ntpd/ntp_proto.c:
+       Replaced the 'sco5_oldclock' variable with 'systime_10ms_ticks'.
+       Cleared libntp/systime.c and include/ntp_stdlib.h of references
+       to SCO5_CLOCK and RELIANTUNIX_CLOCK (moved to ntpd/ntp_proto.c).
+       From: Kamal A Mostafa <kamal@whence.com>
+
+       * configure.in: alpha-dec-osf4* -> alpha*-dec-osf4*|alpha*-dec-osf5*
+       From: Tom Smith <smith@cag.lkg.dec.com>
+
+       * configure.in: Look for <sys/sio.h>.  If TIOCDCDTIMESTAMP is
+       there, we have TTYCLK.
+       * acconfig.h: Lose old AIOCTIMESTAMP stuff
+       Reported by: Kamal A Mostafa <kamal@whence.com>
+
+1999-11-10  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntpd.c (set_process_priority): Clean up nice() and setpriority()
+
+1999-11-09  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * Makefile.am (EXTRA_DIST): Added README.cvs
+       Reported by: Kamal A Mostafa <kamal@whence.com>
+
+1999-11-08  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98e
+
+1999-11-07  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Lose AIOCTIMESTAMP tests
+
+       * ntpd/ntpd.c: lose select() EINTR debug warning
+       * ntpd/ntp_refclock.c: AIOCTIMESTAMP -> TIOCDCDTIMESTAMP.  Watch
+       CLK_SETSTR.
+       * ntpd/refclock_atom.c: fdpps is only there for PPS or PPSAPI.
+       AIOCTIMESTAMP is gone now.
+       From: Kamal A Mostafa <kamal@whence.com>
+
+       * configure.in (HAVE_MLOCKALL): Deal with dec-osf5 realities
+       * ntpd/refclock_ulink.c (ulink_poll): Fix cast.
+       * libntp/machines.c (ntp_set_tod): Use a long* for the argument to
+       stime().
+       Reported by: Tom Smith <smith@cag.lkg.dec.com>
+
+       * ntpd/ntpd.c (set_process_priority): Use whatever we have until
+       something works.
+
+       * ntpd/ntp_loopfilter.c: Keep clock_frequency changes in a temp
+       variable so we can record it to loopstats (near as HMS can tell).
+       From: Dave Mills <mills@udel.edu>
+
+1999-11-06  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * acconfig.h: RELIANTUNIX_CLOCK
+       * configure.in (ac_cv_var_tickadj): RELIANTUNIX_CLOCK
+       * libntp/systime.c (adj_systime): Reliant patches
+       From: Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
+
+1999-11-05  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_parse.c (parse_start): ASYNC_PPS_CD_NEG cleanup
+       * configure.in (ac_cv_make_ntptime): OK on Linux
+       From: <Ulrich.Windl@rz.uni-regensburg.de>
+
+       * configure.in: NetBSD has PPSAPI now
+       F_SETOWN is needed for NetBSD
+       From: Jonathan Stone <jonathan@dsg.stanford.edu>
+
+1999-11-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98d
+
+       * ntpd/refclock_parse.c: Cleanup/fixes
+       From: John Hay <jhay@mikom.csir.co.za>
+
+       * ntpd/refclock_parse.c: Lose #include "ntp_select.h"
+       * ntpd/ntpd.c: Lose #include "ntp_select.h"
+       * ntpd/ntp_io.c: Lose #include "ntp_select.h"
+       * ntpd/ntp_intres.c: Lose #include "ntp_select.h"
+       * libntp/iosignal.c: Lose #include "ntp_select.h"
+       * include/ntpd.h: #include "ntp_select.h" for declaration of activefds
+       Reported by: Christian Krackowizer <kra1@technodat.co.at>
+
+1999-11-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98c
+
+       * libntp/syssignal.c: Don't warn about SA_RESTART
+       * libntp/recvbuff.c: Fix free buffer count
+       From: Jeffrey C Honig <jch@bsdi.com>
+
+       * html/pps.htm:
+       * html/howto.htm:
+       * html/confopt.htm:
+       * html/clockopt.htm:
+       * html/uthopt.htm:
+       Updates.
+       From: Dave Mills <mills@udel.edu>
+
+       * ntpd/refclock_wwvb.c: burst fixes
+       * ntpd/refclock_ulink.c: burst fixes
+       * ntpd/refclock_tpro.c: burst and NSTAGE fixes
+       * ntpd/refclock_pst.c: burst fixes
+       * ntpd/refclock_irig.c: SAMPLE -> SAMPLES
+       * ntpd/refclock_heath.c: burst fixes
+       * ntpd/refclock_dumbclock.c: burst fixes
+       * ntpd/refclock_chronolog.c: burst fixes
+       * ntpd/refclock_bancomm.c: burst fixes
+       * ntpd/refclock_atom.c: burst fixes
+       * ntpd/refclock_as2201.c: burst fixes
+       * ntpd/ntp_refclock.c: PPSAPI, code, and comment cleanup/fixes
+       * ntpd/ntp_proto.c: Broadcast/restrict cleanup
+       * ntpd/ntp_loopfilter.c: Cleanup and fixes
+       * libntp/gpstolfp.c: Lose the UL qualifiers - old compilers hate them
+       From: Dave Mills <mills@udel.edu>
+
+1999-10-31  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: TIOCSPPS cleanup
+
+1999-10-20  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98b
+
+       * ntpd/refclock_atom.c: AIOCTIMESTAMP patch
+       * ntpd/ntpd.c: SCO clock patch
+       * ntpd/ntp_request.c: noselect patch
+       * ntpd/ntp_refclock.c: AIOCTIMESTAMP patch
+       * ntpd/ntp_proto.c: noselect patch
+       * ntpd/ntp_intres.c: noselect patch
+       * ntpd/ntp_config.c: noselect patch
+       * include/ntp_request.h: noselect patch
+       * include/ntp.h: noselect patch
+       From: Kamal A Mostafa <kamal@whence.com>
+
+       * configure.in:
+       * acconfig.h: TTYCLK_AIOCTIMESTAMP
+       Stuff for Kamal
+
+       * ntpd/refclock_atom.c (atom_pps): make "result" initialization
+       uglier, but more bulletproof.
+
+       * configure.in (sys/timepps.h): Fixed.
+       From: John Hay <jhay@mikom.csir.co.za>
+
+1999-10-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c: Rename instance.state to instance.o_state
+
+       * refclock_oncore.c:
+       * refclock_mx4200.c:
+       * refclock_chu.c:
+       * refclock_atom.c:
+       * ntp_refclock.c:
+       * ntp_peer.c:
+       * ntp_loopfilter.c:
+       * include/ntp_refclock.h:
+       Various cleanup and fixes
+       From: Dave Mills <mills@udel.edu>
+
+1999-10-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_config.c (CONFIG_FILE): NT changes
+       From: Sven Dietrich <Sven_Dietrich@trimble.com>
+
+1999-10-16  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: sys/timepps.h verification changes
+
+       * ntpd/refclock_atom.c (atom_poll): PPS cleanup
+       From: Dave Mills <mills@udel.edu>
+       (atom_pps): Portability patch
+       From: John Hay <jhay@mikom.csir.co.za>
+
+
+       * libntp/msyslog.c:
+       * libntp/gpstolfp.c:
+       Lint cleanup
+       From: Jonathan Stone <jonathan@dsg.stanford.edu>
+
+       * parseutil/dcfd.c:  abs() -> l_abs(), time.h (AIX 4.3.2 patches)
+       From: Dana Kaempen <decay@flash.net>
+
+       * ntpd/refclock_oncore.c:
+       * ntpd/refclock_atom.c:
+       * ntpd/ntp_refclock.c:
+       PPS cleanup
+       From: John.Hay@mikom.csir.co.za
+
+       * util/ntptime.c:
+       * ntpdate/ntptimeset.c:
+       * ntpdate/ntpdate.c:
+       * ntpd/refclock_trak.c:
+       * ntpd/refclock_oncore.c:
+       * ntpd/refclock_mx4200.c:
+       * ntpd/refclock_msfees.c:
+       * ntpd/refclock_atom.c:
+       * ntpd/ntp_control.c:
+       * ntpd/ntp_config.c:
+       * configure.in:
+       * configure:
+       PPS, Solaris 7, cleanup patches
+       From: Marc.Brett@westgeo.com
+
+       * ports/winnt/ntptrace/ntptrace.dsp:
+       * ports/winnt/ntpq/ntpq.dsp:
+       * ports/winnt/ntpdc/ntpdc.dsp:
+       * ports/winnt/ntpdate/ntpdate.dsp:
+       * ports/winnt/ntpd/refclock_trimbledc.c:
+       * ports/winnt/ntpd/ntpd.dsp:
+       * ports/winnt/ntpd/ntp_iocompletionport.c:
+       * ports/winnt/ntpd/nt_clockstuff.c:
+       * ports/winnt/libntp/util_clockstuff.c:
+       * ports/winnt/libntp/libntp.dsp:
+       * ports/winnt/libntp/SetSystemTime.c:
+       * ports/winnt/instsrv/instsrv.c:
+       * ports/winnt/include/sys/ioctl.h:
+       * ports/winnt/include/termios.h:
+       * ports/winnt/include/config.h:
+       * ports/winnt/include/clockstuff.h:
+       * ports/winnt/ntp.dsw:
+       * ntpd/refclock_shm.c:
+       * ntpd/refclock_palisade.c:
+       * ntpd/ntpd.c:
+       * ntpd/ntp_timer.c:
+       * ntpd/ntp_refclock.c:
+       * libntp/systime.c:
+       * libntp/machines.c:
+       NT patches
+       From: Sven Dietrich <Sven_Dietrich@trimble.com>
+
+1999-10-15  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_wwvb.c:
+       * ntpd/refclock_usno.c:
+       * ntpd/refclock_ulink.c:
+       * ntpd/refclock_tpro.c:
+       * ntpd/refclock_pst.c:
+       * ntpd/refclock_parse.c:
+       * ntpd/refclock_palisade.c:
+       * ntpd/refclock_oncore.c:
+       * ntpd/refclock_mx4200.c:
+       * ntpd/refclock_msfees.c:
+       * ntpd/refclock_jupiter.c:
+       * ntpd/refclock_irig.c:
+       * ntpd/refclock_heath.c:
+       * ntpd/refclock_chu.c:
+       * ntpd/refclock_atom.c:
+       * ntpd/refclock_as2201.c:
+       * ntpd/refclock_arc.c:
+       * ntpd/refclock_arbiter.c:
+       * ntpd/refclock_acts.c:
+       * ntpd/ntp_refclock.c:
+       * include/ntp_refclock.h:
+       Bunches of fixes.
+       From: Dave Mills <mills@udel.edu>
+
+1999-10-10  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/driver16.htm: New version
+       * ntpd/refclock_bancomm.c: New version
+       From: "Cliff, Gary" <gary.cliff@cdott.com>
+       "Ramasivan, Ganesh" <ganesh.ramasivan@cdott.com>
+
+       * ntpd/refclock_ulink.c (ulink_receive): Cleanup
+       (ulink_poll): Cleanup
+       * ntpd/refclock_atom.c (atom_pps): SunOS timespec/timeval cleanup
+       From: Marc.Brett@westgeo.com
+
+       * INSTALL: Point NT folks at ports/winnt
+       Reported by: Stephen Gildea <gildea@intouchsys.com>
+
+       * include/ntp_stdlib.h: Noise abatement
+       * include/ntpd.h: Noise abatement
+       Reported by: "W. David Higgins" <wdh@grouper.ccur.com>
+
+       * configure.in: DECL_STDIO_0 with gcc under solaris.
+
+       * include/l_stdlib.h: DECL_TOUPPER_0
+       DECL_STRERROR_0
+
+       * configure.in: Fix a bunch of implicit declarations for SunOS
+
+       * html/release.htm: cleanup - we still provide MD5.
+       Reported by: Winslowe Lacesso <lacesso@cs.ubc.ca>
+
+1999-10-09  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c:
+       * ntpd/refclock_atom.c:
+       * ntpd/ntp_refclock.c:
+       PPS API code updated to the current spec
+       From: Dave Mills
+
+       * configure.in (ac_cv_make_tickadj): Don't make tickadj starting
+       with solaris2.5
+       Requested by: Dave Mills
+
+1999-10-04  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: We might need -lsocket for the -lnsl check.
+
+1999-09-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_ulink.c: Typos in C++ comment
+       Reported by: Thomas.Tornblom@Sun.SE
+
+       * configure.in: 4.0.98a
+
+       * ntpd/ntp_config.c (getconfig): Fix typo.
+       From: "David E. Myers" <dem@skyline.rtp.nc.us>
+       From: David Godfrey <dave@delta.demon.co.uk>
+       From: Geoffrey Sisson <geoff@nominet.org.uk>
+
+1999-09-17  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.98
+
+       NetInfo support:
+
+       * config.guess
+       * config.sub
+       Add Mac OS (versions 10 and up).
+
+       * acconfig.h
+       * config.h.in
+       * configure.in
+       Check for NetInfo API; add HAVE_NETINFO macro and friends.
+
+       * include/ntp.h
+       * ntpd/ntp_config.c
+       * ntpdate/ntpdate.c
+       Add support for reading configuration from NetInfo.
+
+       * ntpd/ntp_config.c
+       Get rid of unnecessary eol variable in tokenizer.
+
+       * html/notes.htm
+       * html/ntpd.htm
+       * html/ntpdate.htm
+       Document NetInfo functionality.
+
+       * util/tickadj.c
+       Use HAVE_KVM_OPEN conditional around kvm.h include.
+
+       From: Wilfredo Sanchez <wsanchez@apple.com>
+
+1999-09-15  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * acconfig.h:
+       * config.h.in:
+       * configure.in:
+       * html/driver34.htm:
+       * html/refclock.htm:
+       * include/ntp.h:
+       * libntp/clocktypes.c:
+       * ntpd/Makefile.am:
+       * ntpd/ntp_control.c:
+       * ntpd/refclock_conf.c:
+       * ntpd/refclock_ulink.c:
+       Ultralink driver
+       From: Dave Strout <dstrout@linuxfoundary.com>
+
+1999-09-14  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: ReliantUNIX patches
+       From: Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
+
+       * ntpd/refclock_atom.c: PPS cleanup
+       * ntpd/ntp_refclock.c (refclock_ioctl): PPS cleanup
+       From: Dave Mills <mills@udel.edu>
+
+       * ntptrace/ntptrace.c (ReceiveBuf): addserver() can return NIL.
+       Reported by: "Alan J. Wylie" <alanw@cyrano.com>
+
+       * libntp/ieee754io.c:
+       * ntpd/ntp_proto.c:
+       * ntpd/ntp_refclock.c:
+       Lint cleanup.
+       From: Marc.Brett@westgeo.com
+
+1999-09-12  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_refclock.c (refclock_ioctl): Declaration cleanup.
+
+       * ntpd/ntp_proto.c (init_proto): msyslog kern_enable at LOG_DEBUG.
+
+       * ntpd/refclock_atom.c: Add missing declaration.
+
+1999-09-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_cv_make_ntptime): Just look for struct
+       ntptimeval, not timespec or nsec (Solaris 2.7 should get ntptime
+       and it uses msec).
+       (ac_cv_var_oncore_ok): Reorder so it's a "normal" clock
+
+       * configure.in: Solaris Kernel FLL bug fixed in 106541-07
+
+1999-09-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.97f
+
+       * ntptrace/ntptrace.c:
+       * ntpdate/ntptimeset.c:
+       * ntpdate/ntptime_config.c:
+       * ntpdate/ntpdate.c:
+       * util/ntptime.c:
+       * parseutil/dcfd.c:
+       * libparse/parsestreams.c:
+       * libparse/parse_conf.c:
+       * libparse/parse.c:
+       * libparse/clk_varitext.c:
+       * libparse/clk_trimtsip.c:
+       * libparse/clk_trimtaip.c:
+       * libparse/clk_schmid.c:
+       * libparse/clk_rcc8000.c:
+       * libparse/clk_rawdcf.c:
+       * libparse/clk_meinberg.c:
+       * libparse/clk_hopf6021.c:
+       * libparse/clk_dcf7000.c:
+       * libparse/clk_computime.c:
+       * libntp/msyslog.c:
+       * libntp/iosignal.c:
+       * libntp/syssignal.c:
+       * adjtimed/adjtimed.c:
+       * ntpd/refclock_shm.c:
+       * ntpd/refclock_parse.c:
+       * ntpd/refclock_palisade.c:
+       * ntpd/refclock_mx4200.c:
+       * ntpd/refclock_jupiter.c:
+       * ntpd/refclock_datum.c:
+       * ntpd/ntpd.c:
+       * ntpd/ntp_util.c:
+       * ntpd/ntp_timer.c:
+       * ntpd/ntp_request.c:
+       * ntpd/ntp_refclock.c:
+       * ntpd/ntp_monitor.c:
+       * ntpd/ntp_loopfilter.c:
+       * ntpd/ntp_io.c:
+       * ntpd/ntp_intres.c:
+       * ntpd/ntp_filegen.c:
+       * include/l_stdlib.h:
+       <errno.h> and errno declaration cleanup.
+
+       * ntpd/map_vme.c: cleanup some spacing.
+
+1999-09-01  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.97e
+
+       * configure.in (ac_cv_struct_sigaction_has_sa_sigaction):
+       * acconfig.h: Ditto
+       * parseutil/dcfd.c (main): Use it.
+       From: HOSAKA Eiichi <HOSAKA.Eiichi@dd.anritsu.co.jp>
+
+1999-08-29  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.97d
+
+       * include/ntp_stdlib.h: Clean up previous NeXT patch.
+       From: Jack Bryans <jbryans@csulb.edu>
+
+       * ntpd/refclock_parse.c: Permit RTS to power a DCF77.
+       From: Carsten Paeth <calle@calle.in-berlin.de>
+
+       * ntpd/refclock_oncore.c (oncore_start): This makes the Oncore run
+       on systems without hardpps().
+       From: Poul-Henning Kamp <phk@freebsd.org>
+
+1999-08-28  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.97c
+
+       * configure.in (ac_cv_make_ntptime):  Typo.
+       From: Ulrich Windl <ulrich.windl@rz.uni-regensburg.de>
+
+1999-08-26  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.97b
+
+       * libntp/iosignal.c:
+       * ntpd/ntp_peer.c:
+       * ntpd/refclock_nmea.c:
+       * ntpdate/ntptime_config.c:
+       * ntpdate/ntptimeset.c:
+       AIX, Irix, and SunOS lint cleanup
+       From: Marc.Brett@westgeo.com
+
+1999-08-24  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in 4.0.97a
+
+       * configure.in (AC_OUTPUT): added scripts/Makefile
+       * Makefile.am (SUBDIRS): Added scripts
+       * scripts/Makefile.am: Added
+
+1999-08-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_nmea.c: Patches for:
+        Trimble OEM Ace-II receiver. Low cost PCB with single
+        voltage input, external active antenna and two serial
+        ports with either NMEA and ITAPs output. Programmable
+        to be tuned for 'time' accuracy in fixed station config.
+       From: Nick Hibma <nick.hibma@jrc.it>
+
+1999-08-21  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_config.c: Added listen_to_virtual_ips support (-L flag)
+       * ntpd/ntp_io.c: Ditto
+
+1999-08-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_intres.c (request): Lint cleanup
+       * ntpd/ntp_control.c (ctl_putclock): Ditto
+       * libntp/recvbuff.c (getrecvbufs): Ditto
+       (get_free_recv_buffer): Ditto
+       * libntp/systime.c (adj_systime): Ditto
+
+1999-08-18  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.97
+
+       * libntp/systime.c:
+       * ntpd/ntp_loopfilter.c:
+       * ntpd/ntpd.c:
+       * ports/winnt/libntp/nt_clockstuff.c:
+       From: Sven Dietrich <Sven_Dietrich@trimble.com>
+
+       * README.cvs: Updated.
+
+       * configure.in:
+       * include/ntp_machine.h:
+       * libntp/mexit.c:
+       * ntpd/ntp_config.c:
+       * ntpd/ntp_peer.c:
+       * ntpd/ntp_restrict.c:
+       * ntpd/refclock_arc.c:
+       * ntpdate/ntpdate.c:
+       Irix, SunOS, AIX, lint patches
+       From: Marc.Brett@westgeo.com
+
+       * util/ansi2knr.c: New release (fix for bug reported by Marc Brett)
+       From: "L. Peter Deutsch" <ghost@aladdin.com>
+
+       * include/ntp_stdlib.h: NeXT portability patch
+       From: Jack Bryans <jbryans@csulb.edu>
+
+       * configure.in:
+       * dot.emacs: (cleanup)
+       * ntpdate/Makefile.am:
+       * ntpdate/ntpdate.h:
+       * ntpdate/ntptime_config.c:
+       * ntpdate/ntptimeset.c:
+       ntptimeset patches.
+       From: Jeffrey Hutzelman <jhutz@cmu.edu>
+
+       * ntpd/refclock_parse.c (local_input): ts.l_ui -> ts.fp.l_ui
+
+1999-08-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.96p1
+
+       * ntpd/ntpd.c (sys/resource.h): Include this file only #if
+       HAVE_SYS_RESOURCE_H.
+       (set_process_priority): Use TIOCNOTTY only if it is #define'd.
+       * ntpd/refclock_parse.c (STREAM): STREAM does not imply HAVE_TERMIOS.
+       (termios.h, termio.h, fcntl.h): Do not include those files here;
+       they are already included by ntp_refclock.h or ntp_io.h.
+       * ntpd/refclock_leitch.c (sgtty.h, termios.h, termio.h): Do not
+       include those files here; they are already included by ntp_refclock.h.
+       * ntpdate/ntpdate.c (sys/resource.h) : Include that file only #if
+       HAVE_RESOURCE_H.
+       From: Philippe De Muyter <phdm@macqel.be>
+
+       * ntptrace/ntptrace.c (input_handler): Make it a "normal" function
+       definition.
+       Reported by: GIANNI_CATANIA@hp-italy-om6.om.hp.com
+
+       * configure.in:  pc-cygwin32 -> pc-cygwin* because of a change in
+       B20.
+       From: Stephen Gildea <gildea@intouchsys.com>
+
+1999-08-09  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.96
+
+       * parseutil/dcfd.c (main): Replace SA_ONSTACK and SV_ONSTACK with
+       HAVE_SIGACTION and HAVE_SIGVEC, respectively.  HP-UX provides both
+       of the former but only one of the latter...
+
+1999-08-08  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Better tests for -lnsl and -lsocket
+       From: Albert Chin-A-Young <china@thewrittenword.com>
+
+       Works for me - handle openlog() and -lgen the same way.
+
+       * Makefile.am (EXTRA_DIST): Add in the y2k notes
+
+       * parseutil/dcfd.c: Renamed drift_comp to accum_drift
+
+       * configure.in: Added MAKE_CHECK_Y2K support; check_y2k needs libparse.
+       * ntpd/Makefile.am (check_PROGRAMS): Use MAKE_CHECK_Y2K
+       * ntpd/Makefile.am (check-local): Added.
+       * parseutil/Makefile.am (check-local): Added.
+
+       * include/ntp.h: Y2KFixes
+       * libparse/parse.c: Ditto
+       * ntpd/Makefile.am (check_PROGRAMS): Ditto
+       * ntpd/refclock_acts.c: Ditto
+       * ntpd/refclock_arc.c (arc_receive): Ditto
+       * ntpd/refclock_heath.c: Ditto
+       * ntpd/refclock_hpgps.c: Ditto
+       * parseutil/Makefile.am (check-local): Ditto
+       * parseutil/dcfd.c (check_y2k): Ditto
+       * NOTES.y2kfixes: Ditto
+       * readme.y2kfixes: Ditto
+       * results.y2kfixes: Ditto
+       * ntpd/check_y2k.c: Ditto
+       From: y2k@y2k.labs.att.com
+
+1999-08-07  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Look for sys/ppstime.h.
+
+1999-07-31  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_io.c (create_sockets): Typo.
+       From: Doug Wells <dmw@contek.com>
+
+1999-07-29  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_cv_struct_ntptimeval): Explicitly look for
+       struct ntptimeval.
+       (ac_cv_var_kernel_pll): Require struct ntptimeval.
+       Linux.  Grrr.
+       Reported by: Ronald Kuetemeier <ronaldk@smginc.com>
+
+1999-07-27  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.95
+
+       * ports/winnt: New release
+       From: Sven Dietrich <Sven_Dietrich@trimble.com>
+
+1999-07-26  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/machines.c (ntp_set_tod): Bugfix
+       From: Andrej Borsenkow <Andrej.Borsenkow@mow.siemens.ru>
+
+1999-07-25  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.94b
+
+       * acconfig.h:
+       * configure.in:
+       * libparse/Makefile.am:
+       * libparse/parse_conf.c:
+       * libparse/clk_varitext.c:
+       * libparse/kclk_varitext.c:
+       * ntpd/refclock_parse.c: VARITEXT parse clock
+       * ntpdate/ntpdate.c: bugfix
+       From: Tony McConnell <tonym@datel-technology.co.uk>
+
+1999-07-24  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntp_syscall.h (ntp_gettime): Make it static
+       * configure.in: Added AC_C_INLINE
+       Reported by: "Charles C. Fu" <ccwf@klab.caltech.edu>
+
+1999-07-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntpd.h:
+       * libntp/machines.c:
+       * libntp/systime.c:
+       * ntpd/ntp_config.c:
+       * ntpd/ntp_filegen.c:
+       * ntpd/ntp_io.c:
+       * ntpd/ntp_proto.c:
+       * ntpd/ntp_timer.c:
+       * ntpdate/ntpdate.c: Windows NT port cleanup
+       From: Sven Dietrich <Sven_Dietrich@trimble.com>
+
+1999-07-22  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/authkeys.c:
+       * libntp/ieee754io.c:
+       * libntp/iosignal.c:
+       * libntp/machines.c:
+       * libntp/mexit.c:
+       * libntp/recvbuff.c:
+       * ntpd/ntp_filegen.c:
+       * ntpd/ntp_loopfilter.c:
+       * ntpd/ntp_request.c:
+       * ntpd/ntp_timer.c:
+       * ntpd/ntpd.c: Compile/lint cleanup
+       From: Allen Smith <easmith@beatrice.rutgers.edu>
+
+1999-07-21  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.94a
+
+       * configure.in (ac_cv_make_ntptime): Add tv_nsec check.
+
+       * include/Makefile.am (noinst_HEADERS): Forgot ntp_syscall.h
+       From: John.Hay@mikom.csir.co.za
+
+       * configure.in: 4.0.94
+
+       * Makefile.am (SUBDIRS): librsaref
+       (dist-hook): Lose CVS subdirs in the distribution tarball
+
+       * include/Makefile.am (noinst_HEADERS): Added iosignal.h, recvbuff.h
+
+       * Makefile.am (dist-hook): Don't call dos2unix anymore
+
+1999-07-20  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * acconfig.h:
+       * util/ntptime.c: FreeBSD nano patches
+       From: Per Hedeland <per@erix.ericsson.se> and
+       Allen Smith <easmith@beatrice.rutgers.edu>
+
+       * include/ntp.h:
+       include/ntp_fp.h:
+       include/ntp_io.h:
+       include/ntp_machine.h:
+       include/ntp_refclock.h:
+       include/ntp_stdlib.h:
+       include/ntpd.h:
+       libntp/Makefile.am:
+       libntp/emalloc.c:
+       libntp/machines.c:
+       libntp/mexit.c:
+       libntp/msyslog.c:
+       libntp/statestr.c:
+       libntp/syssignal.c:
+       libntp/systime.c:
+       libparse/parse.c:
+       libparse/parse_conf.c:
+       ntpd/ntp_control.c:
+       ntpd/ntp_intres.c:
+       ntpd/ntp_io.c:
+       ntpd/ntp_proto.c:
+       ntpd/ntp_refclock.c:
+       ntpd/ntp_request.c:
+       ntpd/ntp_timer.c:
+       ntpd/ntp_util.c:
+       ntpd/ntpd.c:
+       ntpd/refclock_nmea.c:
+       ntpd/refclock_palisade.c:
+       ntpd/refclock_palisade.h:
+       ntpd/refclock_shm.c:
+       ntpdate/ntpdate.c:
+       ntptrace/ntptrace.c: Cleanup
+       * libntp/recvbuff.c:
+       libntp/iosignal.c:
+       include/iosignal.h:
+       include/recvbuff.h: Added
+       From: Sven_Dietrich@Trimble.COM
+
+       * README: Add README.cvs
+
+       * configure.in (ac_cv_var_struct_ntptime_val_timespec): Typo.
+       From: John Hay <jhay@mikom.csir.co.za>
+
+1999-07-19  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * Makefile.am (EXTRA_DIST): Lose ntpmak; "build" does a better job.
+
+       * ntpq/Makefile.am (version.o): Use mkver
+       * ntptrace/Makefile.am (version.o): Ditto
+       * ntpdate/Makefile.am (version.o): Ditto
+       * ntpd/Makefile.am (version.o): Ditto
+       * ntpdc/Makefile.am (version.o): Ditto
+
+       * configure.in (AC_OUTPUT): scripts/mkver
+
+       * scripts/mkver.in: Created.  Note RSAREF in the version string
+
+1999-07-18  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * README.des: Updated.
+
+       * ntpq/Makefile.am (LDADD): Add LIBRSAREF
+
+       * ntpdc/Makefile.am (LDADD): Add LIBRSAREF
+
+       * ntpdate/Makefile.am (LDADD): Add LIBRSAREF
+
+       * ntpd/Makefile.am (LDADD): Add LIBRSAREF
+
+       * configure.in (AC_OUTPUT): Added librsaref/Makefile
+       Added tests for making/using librsaref.a
+       Lose old DES stuff; AC_DEFINE(DES) if we find the rsaref stuff.
+
+1999-07-11  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_trak.c (trak_receive): disambiguate expression.
+       At least now it is unambiguous.  It may even still be correct.
+       Reported by: Tom Smith <smith@cag.lkg.dec.com>
+
+       * ntp_update (UPDATE_OPTIONS): Typo.
+
+1999-07-07  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntp_update: Check out copyright.htm before COPYRIGHT
+
+       * ntpd/ntp_config.c: Support for PPS assert/clear/hardpps
+       * ntpd/ntp_refclock.c (refclock_ioctl): Ditto
+       (refclock_gtlin): Ditto
+       * html/clockopt.htm: Document.
+       From: John Hay <jhay@mikom.csir.co.za>
+
+        * html/monopt.htm: We have four types of files now
+        * ntpd/refclock_oncore.c: If debug is on, tell when
+        we are waiting for a valid almanac
+       From: Poul-Henning Kamp <phk@critter.freebsd.dk>
+
+       * include/ntp_machine.h (HAVE_TERMIOS): STREAMS does not imply
+       HAVE_TERMIOS !!!
+       * include/parse.h (timercmp): Macro defined if needed.
+       * ntpd/ntp_config.c (SIGCHLD): Macro defined as SIGCLD if needed.
+       (sys/wait.h): File included only if HAVE_SYS_WAIT_H.
+       * configure.in (sys/wait.h): File added to AC_CHECK_HEADERS list.
+       From: Philippe De Muyter  <phdm@macqel.be>
+
+1999-06-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_irig.c (irig_debug): NetBSD patches
+       From: Frederick Bruckman <fb@enteract.com>
+
+       * util/ntptime.c (main): ntx.freq bugfix (-f option)
+       From: Frederick Bruckman <fb@enteract.com>
+
+1999-06-22  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Fix typo with DECL_H_ERRNO test
+
+       * ntpd/ntp_loopfilter.c: Lose syscall decl, it's handled in
+       l_stdlib.h now.
+       * ntpd/ntp_request.c: Ditto
+       * util/ntptime.c: Ditto
+
+Mon May 31 18:49:49 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * ntpd/ntp_proto.c (proto_config): Don't set sys_bclient on
+       PROTO_MULTICAST_ADD, only caller can decide; remove wrong set on
+       PROTO_MULTICAST_DEL.
+
+Mon May 31 18:49:49 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * ntpd/refclock_parse.c (stream_receive): Cast size_t to int to
+       match format.
+       (local_receive): Likewise.
+       (trimbletaip_event): Likewise.
+       (stream_receive): Cast struct timeval members to long to match
+       format.
+       (local_receive): Likewise.
+
+       * ntpd/ntp_util.c (stats_config): Cast size_t to int to match
+       format.
+
+       * libparse/clk_rawdcf.c (cvt_rawdcf): Cast ptr difference to int
+       to match format.
+       * ntpd/refclock_parse.c (gps16x_poll): Likewise.
+
+       * ntpd/ntp_filegen.c (filegen_open): Use long format, cast arg to
+       match.
+
+       * ntpd/refclock_parse.c (list_err): Use long format to match arg.
+       (parse_statistics): Likewise.
+       (gps16x_message): Likewise.
+       (cvt_ts): Use long format, cast args to match.
+       (parse_start): Add missing arg.
+       (gps16x_message): Swap args to match format.
+
+       * ntpd/ntpd.c (ntpdmain): Cast uid to long, adapt format.
+
+       * ntpd/ntp_intres.c (readconf): Use long format to match arg.
+       * ntpd/ntp_io.c (getrecvbufs): Likewise.
+       * ntpd/ntp_proto.c (default_get_precision): Likewise.
+
+       * ntpd/ntp_loopfilter.c (local_clock): Cast clock_panic to int to
+       match format.
+
+       * ntpd/ntp_io.c (io_multicast_add): Print s_addr member, not
+       struct in_addr, to match format.
+
+       * include/ntp_stdlib.h: Declare msyslog() as printf-like for gcc
+       format checking.
+
+Fri May 28 16:39:35 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * ntpdc/ntpdc_ops.c (iostats): Align timereset line.
+
+       * ntpq/ntpq_ops.c (doopeers): Properly align header.
+
+       * ntpdc/ntpdc_ops.c (debug): Removed declaration, already in
+       ntp_stdlib.h.
+       * ntpq/ntpq_ops.c: Likewise.
+
+       * ntpdate/ntpdate.c (debug): Declare volatile to match
+       ntp_stdlib.h.
+       * ntpdc/ntpdc.c, ntpq/ntpq.c, ntptrace/ntptrace.c, util/tickadj.c,
+       util/ntptime.c: Likewise.
+
+       * include/parse.h (debug): Don't declare to avoid clash with
+       ntp_stdlib.h.
+
+       * include/Makefile.am (noinst_HEADERS): Add new ntp_syscall.h.
+
+       * configure.in: Also check for -lrt for POSIX.1c functions.
+
+Wed May 26 21:03:30 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * configure.in: Removed -Wwrite-strings from CFLAGS.
+
+       * ntpdc/ntpdc.c (help): Remove superfluous cast.
+       * ntpq/ntpq.c (help): Likewise.
+
+Tue May 25 18:00:49 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * ntpq/ntpq_ops.c (struct varlist): name cannot be const char *
+       since it may be malloc'ed.
+
+       * ntpdc/ntpdc.c (sendrequest): Declare pass as const char *, don't
+       lose const in cast.
+       * ntpq/ntpq.c (sendrequest): Likewise.
+
+       * ntpd/ntp_control.c (ctl_getitem): Remove superfluous cast.
+       * include/ntpd.h (struct ctl_var): text cannot be const char *
+       since it's malloc'ed.
+
+1999-06-22  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/l_stdlib.h: Don't include <netinet/in.h>, add forward
+       declaration of struct in_addr instead.
+       From: Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+       Patch:
+
+       * include/l_stdlib.h: Fixed syscall() declaration.
+       * configure.in: Updated test to match.
+
+       * configure.in: Check if we need to declare errno and h_errno.
+       Check for <resolv.h> which may provide a h_errno declaration and
+       <arpa/nameserv.h> which the latter needs.
+       * acconfig.h: Provide the necessary templates.
+
+       * include/ntp_syscall.h: New file, hides various implementations
+       of ntp_adjtime() and ntp_gettime() syscalls.
+       * ntpd/ntp_loopfilter.c: Use it.
+       * ntpd/ntp_request.c: Likewise.
+       * ntpd/refclock_local.c: Likewise.
+       * util/ntptime.c: Likewise.
+
+       * include/l_stdlib.h: Include <netinet/in.h>, declare inet_ntoa if
+       necessary.
+       Moved syscall() declaration here.
+
+       * kernel/sys/parsestreams.h: Include <sys/termios.h> for it's
+       definition of struct ppsclockev.
+       Include <sys/ppsclock.h> unconditionally for definition of
+       CIOGETEV via TIOCGPPSEV.
+       * kernel/sys/ppsclock.h: Protect struct ppsclockev from
+       redefinition.
+
+       * include/ntp_refclock.h: Protect it from multiple inclusion.
+       * include/ntp_fp.h: Likewise.
+       * include/ntp.h: Likewise.
+
+       * include/ntpd.h: Include ntp_refclock.h for MAXDIAL declaration.
+       * libntp/authkeys.c: Include ntpd.h for current_time declaration.
+
+       * include/ntpd.h (getauthkeys, auth_agekeys, rereadkeys): Moved
+       prototypes to ntp_stdlib.h
+
+       * include/ntp_stdlib.h: Declare variables exported by libntp.
+       * include/ntpd.h: Likewise for ntpd.
+
+       * libntp/authkeys.c (key_hash, authnokey, authfreekeys,
+       cache_flags): Made static.
+       * libntp/systime.c (tvu_maxslew, tsf_maxslew, sys_clock_offset,
+       sys_residual): Likewise.
+       * ntpd/ntp_intres.c (confentries): Likewise.
+       * ntpd/ntp_loopfilter.c (clock_offset, clock_panic): Likewise.
+       (pll_nano): Likewise. Removed duplicate definition.
+       * ntpd/ntp_peer.c (peer_free, current_association_ID,
+       assocpeer_calls, init_peer_starttime): Likewise.
+       * ntpd/ntp_proto.c (sys_offset, sys_authdly): Likewise.
+       * ntpd/ntp_request.c (numrequests, numresppkts, errorcounter):
+       Likewise.
+       * ntpd/ntp_restrict.c (res_calls, res_found, res_not_found,
+       res_timereset, res_limited_refcnt): Likewise.
+       * ntpd/ntpd.c (was_alarmed, worker_thread): Likewise.
+
+       * ntpq/ntpq_ops.c: Moved declaration of external variable from
+       ntpq.c to file scope.
+
+       * adjtimed/adjtimed.c: Moved declarations of external variables to
+       ntpd.h and ntp_stdlib.h.
+       * clockstuff/propdelay.c: Likewise.
+       * libntp/a_md5encrypt.c, libntp/authencrypt.c, libntp/authkeys.c,
+       libntp/mfp_mul.c, libntp/msyslog.c, libntp/systime.c: Likewise.
+       * ntpd/ntp_config.c, ntpd/ntp_control.c, ntpd/ntp_filegen.c,
+       ntpd/ntp_intres.c, ntpd/ntp_io.c, ntpd/ntp_loopfilter.c,
+       ntpd/ntp_monitor.c, ntpd/ntp_peer.c, ntpd/ntp_proto.c,
+       ntpd/ntp_refclock.c, ntpd/ntp_request.c, ntpd/ntp_restrict.c,
+       ntpd/ntp_timer.c, ntpd/ntp_util.c, ntpd/ntpd.c,
+       ntpd/refclock_acts.c, ntpd/refclock_arbiter.c, ntpd/refclock_arc.c,
+       ntpd/refclock_as2201.c, ntpd/refclock_atom.c,
+       ntpd/refclock_bancomm.c, ntpd/refclock_chronolog.c,
+       ntpd/refclock_chu.c, ntpd/refclock_datum.c,
+       ntpd/refclock_dumbclock.c, ntpd/refclock_gpsvme.c,
+       ntpd/refclock_heath.c, ntpd/refclock_hpgps.c, ntpd/refclock_irig.c,
+       ntpd/refclock_jupiter.c, ntpd/refclock_leitch.c,
+       ntpd/refclock_local.c, ntpd/refclock_msfees.c,
+       ntpd/refclock_mx4200.c, ntpd/refclock_nmea.c,
+       ntpd/refclock_oncore.c, ntpd/refclock_palisade.h,
+       ntpd/refclock_parse.c, ntpd/refclock_pst.c, ntpd/refclock_shm.c,
+       ntpd/refclock_tpro.c, ntpd/refclock_trak.c, ntpd/refclock_true.c,
+       ntpd/refclock_usno.c, ntpd/refclock_wwvb.c: Likewise.
+       * ntpdate/ntpdate.c: Likewise.
+       * ntpdc/ntpdc.c, ntpdc/ntpdc_ops.c: Likewise.
+       * ntpq/ntpq.c: Likewise.
+       * ntptrace/ntptrace.c: Likewise.
+       * util/ntptime.c, til/tickadj.c: Likewise.
+       From: Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+       * include/ntp_machine.h: Removed superfluous yy/mm/dd comments.
+       * include/ntpd.h: Likewise.
+       * libntp/authencrypt.c: Likewise.
+       * libntp/a_md5encrypt.c: Likewise.
+       * libntp/caljulian.c: Likewise.
+       * libntp/ymd2yd.c: Likewise.
+       * libntp/syssignal.c: Likewise.
+       * libntp/ymd2yd.c: Likewise.
+       * ntpd/ntp_control.c: Likewise.
+       * ntpd/ntp_io.c: Likewise.
+       * ntpd/ntp_timer.c: Likewise.
+       * ntpdate/ntpdate.c: Likewise.
+       * ntpq/ntpq_ops.c: Likewise.
+       * ntpd/ntp_peer.c (findpeer): Wrap debug output in DEBUG/debug.
+       From: Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+       * dot.emacs: Removed wrong indentation of substatements.
+       Wrap in c-style.
+       From: Rainer Orth <ro@TechFak.Uni-Bielefeld.DE>
+
+       * ntpd/refclock_palisade.c: Patches from Marc Brett
+       * ntpd/refclock_palisade.h: Ditto.
+       * util/hist.c: Ditto.
+
+Tue Jun  1 00:40:04 1999  Harlan Stenn  <stenn@pogo.udel.edu>
+
+       * build: mips-dec-ultrix4.4 hates "set -e"
+
+       * flock-build: Created
+
+       * build: added -l option
+
+Mon May 31 20:28:40 1999  Harlan Stenn  <stenn@pogo.udel.edu>
+
+       * README: Removed auto{make,conf}.patch files
+
+Tue May 25 01:20:53 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * Makefile.am ($(srcdir)/COPYRIGHT): Added
+       (EXTRA_DIST): Remove auto*.patches
+
+Thu May 20 01:03:00 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * Makefile.am (dist-hook): Call dos2unix on the .htm files
+
+       * ntpd/refclock_palisade.h: Clean up declarations.
+
+       * configure.in (ac_cv_struct_ntptimeval_timespec): Added.
+       (ac_cv_make_ntptime): Only if ntptimeval does not use timespec.
+
+       * util/tickadj.c: Linux Patches
+       From: Reg Clemens <reg@dwf.com>
+
+Wed May 19 01:18:24 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.93a
+
+       * ntpd/refclock_palisade.h: Restore some lost patches
+       From: Kamal A Mostafa <kamal@whence.com>
+
+Sun May 16 13:18:32 1999  Philippe De Muyter  <phdm@macqel.be>
+
+       * libparse/clk_wharton.c (cvt_wharton_400a, inp_wharton_400a): Expect
+       serial output format number 1, not 5.
+       (clock_wharton_400a) : Likewise.
+       * ntpd/refclock_parse.c (parse_clockinfo): For Wharton 400a clock,
+       do not poll, but expect a message every second.
+       * html/parsedata.htm : Entry added for Wharton 400a clock.
+       * html/driver8.htm : Entry fixed for Wharton 400a clock.
+
+Sun May 16 02:59:46 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.93
+
+Sat May 15 18:53:47 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ntp_refclock): ONCORE requires PPSAPI, CIOGETEV,
+       or TIOCGPPSEV.
+       Reported by: Reg Clemens <reg@dwf.com>
+
+Fri May 14 23:58:35 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.92h2
+
+       * configure.in (ac_cv_make_ntptime): Not under Linux.  Yes, it
+       works for some people.  We're tired of the complaints from the
+       others.
+
+Fri May 14 18:58:59 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * libntp/authreadkeys.c (authreadkeys): Reject autokey keys.
+       Include ntp.h for NTP_MAXKEY definition, ntp_fp.h for types used
+       in ntp.h.
+
+Wed May 12 23:02:22 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * libntp/authkeys.c (auth_delkeys): Don't remove autokey keys,
+       leave info on KEY_TRUSTED flag alone.
+       Include ntp.h for NTP_MAXKEY definition.
+
+Thu May 13 02:19:02 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.92h1
+
+       * configure.in: patch for ReliantUNIX
+       From: Andrej Borsenkow <borsenkow.msk@sni.de>
+
+       * ntpd/refclock_oncore.c: Patches
+       From: Reg Clemens <reg@dwf.com>
+
+Thu Apr 29 14:01:04 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * html/*.htm: Remove unnecessary &nbsp;.  Cleanup <pre></pre>
+       sections.
+
+       * configure.in: Properly align configure --help output.
+       * html/config.htm: Include this version, removing Netscape &nbsp;
+       cruft.
+
+Wed Apr 28 15:08:55 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * kernel/sys/parsestreams.h: Only include <sys/ppsclock.h> if
+       struct ppsclockev is missing from system headers.
+
+       * util/tickadj.c (getoffsets): Define kernels[] only if used.
+       (openfile): Rename fd to avoid shadowing global fd.
+       (writevar): Likewise.
+       (readvar): Likewise.
+
+       * parseutil/dcfd.c (read_drift): drift_file is const char *.
+       (update_drift): Likewise.
+       (adjust_clock): Likewise.
+       (main): Likewise.
+
+       * ntpd/refclock_parse.c (gps16x_poll): Adapt format to match
+       parse->localstate type.
+
+       * ntpd/ntp_refclock.c (refclock_gtlin): Only define gotit label
+       if used.
+
+       * include/l_stdlib.h (openlog, syslog): char * args are const.
+
+       * configure.in (*-*-osf4*): Enable declaration of stime().
+
+       * ntpd/refclock_oncore.c (oncore_msg_any): Cast args to long to
+       match prototype.
+       (oncore_msg_En): Likewise.
+
+       * include/ntp_refclock.h (struct refclockstat): Declare p_lastcode
+       as const char *.
+
+       * ntpq/ntpq_ops.c (struct varlist): Define name as const.
+
+       * ntpdc/ntpdc.c (tokenize): Define cp as const char *, remove
+       wrong cast instead.
+
+       * ntpd/ntp_util.c (record_clock_stats): Make text arg const.
+       * include/ntpd.h (record_clock_stats): Adapt declaration.
+       * ntpd/refclock_oncore.c (oncore_start): Removed superfluous casts.
+       (oncore_msg_Cf): Likewise.
+       (oncore_msg_Fa): Likewise.
+       (oncore_msg_Cj): Likewise.
+       (oncore_msg_Ea): Likewise.
+       (oncore_msg_Bj): Likewise.
+
+       * configure.in (*-*-solaris2.4): Enable declarations of
+       gettimeofday(), settimeofday(); they are `protected' by
+       __cplusplus in <sys/time.h>.
+
+Tue Apr 27 21:14:47 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * scripts/summary.pl: Use . as default statsdir.
+       (do_loop): Accept new loopstats format with additional sys_error
+       and clock_stability fields.
+       (do_peer): Accept new peerstats format with additional skew field.
+
+Mon Apr 26 01:50:38 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * Upgraded automake (1.4a) and autoconf (2.14.1)
+
+       * configure.in (ac_refclock_irig): We no longer need stropts.h.
+       * ntpd/refclock_irig.c: Ditto
+
+Mon Apr 26 17:33:33 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * configure.in (*-*-irix6*): Don't pass MIPSpro cc-only flag -n32
+       to gcc.
+
+Thu Apr 22 15:06:40 1999  Rainer Orth  <ro@TechFak.Uni-Bielefeld.DE>
+
+       * ntpd/ntp_config.c (getconfig): IN_CLASSD() expects address in
+       host byte order, but struct sockaddr_in.s_addr is in network byte
+       order.
+       * ntpd/ntp_io.c (io_multicast_del): Likewise.
+
+Sat Apr 24 01:00:53 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.92h
+
+       * ntptrace/ntptrace.c: -m maxhost patch
+       From: "R. Gary Cutbill" <rgary@chrysalis.com>
+
+       * util/ntptime.c: Patches.
+       From: Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
+
+       * html/accopt.htm, html/assoc.htm, html/authopt.htm,
+       html/biblio.htm, html/build.htm, html/clockopt.htm,
+       html/confopt.htm, html/copyright.htm, html/debug.htm,
+       html/exec.htm, html/extern.htm, html/hints.htm, html/index.htm,
+       html/kern.htm, html/miscopt.htm, html/monopt.htm, html/notes.htm,
+       html/ntpd.htm, html/ntpdate.htm, html/ntpdc.htm, html/ntpq.htm,
+       html/ntptime.htm, html/ntptrace.htm, html/patches.htm,
+       html/porting.htm, html/pps.htm, html/rdebug.htm,
+       html/refclock.htm, html/release.htm, html/tickadj.htm,
+       html/hints/solaris.html: Fixed many typos and problems.
+       * acconfig.h (DECL_CFSETISPEED_0, DECL_MRAND48_0, DECL_NLIST_0,
+       DECL_SRAND48_0, DECL_STIME_0): New templates.
+       * include/l_stdlib.h: Include termios.h to get definition of
+       speed_t.
+       (cfsetispeed, cfsetospeed, mrand48, nlist, srand48, stime): New
+       declarations.
+       (openlog): Declare 2- or 3-argument form.
+       * configure.in: Enable declarations of functions missing from
+       Ultrix V4.3 system headers.
+       * ntpd/refclock_oncore.c: Include <sys/types.h>, Ultrix V4.3
+       <sys/stat.h> needs it for dev_t.
+       From: Rainer Orth <ro@techfak.uni-bielefeld.de>
+
+       * ntpdc/ntpdc_ops.c: Reality checks.
+
+       * configure.in: netbsd has stubs for the timer_* stuff and doesn't
+       support PPSAPI.  IRIG requires <stropts.h> .
+       From: Frederick Bruckman <fb@enteract.com>
+
+       * ntpdc/ntpdc_ops.c: (kerninfo)  Report in seconds regardless of
+       kernel precision.  Report kernel flags as text.
+       From: Poul-Henning Kamp <phk@critter.freebsd.dk>
+
+Sun Apr 18 14:26:51 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.92g
+
+       * ntpd/ntp_refclock.c (refclock_ioctl): We don't want
+       PPS_HARDPPSONASSERT by default.
+       * ntpd/refclock_oncore.c: Prefer timepps.h over sys/timepps.h
+       From: Poul-Henning Kamp <phk@freebsd.org>
+
+Tue Apr 13 17:32:35 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.92f
+
+       * ntpd/ntp_refclock.c (refclock_open): VMIN should be 1, not 0
+       From: Reg Clemens <reg@dwf.com>
+
+Sun Apr 11 18:26:44 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_mx4200.c: Patches/improvements
+       * ntpd/ntpd.c (set_process_priority): Lint
+       From: Marc.Brett@westgeo.com
+
+       * util/ntptime.c: Lint, bit definition cleanup
+       From: Ulrich Windl <ulrich.windl@rz.uni-regensburg.de>
+
+Wed Apr  7 03:02:23 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c: Use timepps.h or sys/timepps.h
+       * configure.in: Look for either timepps.h or sys/timepps.h
+       From: Poul-Henning Kamp <phk@critter.freebsd.dk>
+
+       * ntpd/ntp_io.c (create_sockets): Don't warn about ENXIO.
+       (Several places)
+       From: Andrej Borsenkow <borsenkow.msk@sni.de>
+
+       * libntp/mfp_mul.c (mfp_mul): Lint.
+       Marc.Brett@westgeo.com
+
+Sun Apr  4 03:23:53 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.92e
+       Dave redesigned the clock state machine.
+
+1999-02-28  Frank Kardel  <kardel <AT> acm.org>
+
+       * parseutil/dcfd.c: added DCF77 module powersetup
+
+       * ntpd/refclock_parse.c (parse_control): using gmprettydate instead of prettydate()
+       (mk_utcinfo): new function for formatting GPS derived UTC information
+       (gps16x_message): changed to use mk_utcinfo()
+       (trimbletsip_message): changed to use mk_utcinfo()
+       ignoring position information in unsynchronized mode
+       (parse_start): augument linux support for optional ASYNC_LOW_LATENCY
+
+       * ntpd/ntp_control.c (ctl_putclock): cleanup of end of buffer handling
+
+       * libparse/parse.c (timepacket): removed unnecessary code
+
+       * libparse/clk_trimtsip.c (struct trimble): new member t_utcknown
+       (cvt_trimtsip): fixed status monitoring, bad receiver states are
+       now recognized
+
+       * libntp/prettydate.c (gmprettydate): new function for format date
+       and time with respect to UTC
+
+       * libntp/gpstolfp.c (GPSWRAP): update GPS rollover to 990 weeks
+
+       * include/trimble.h (CMD_RUTCPARAM): control variable name unification
+
+       * include/ntp_fp.h: added prototype for gmprettydate()
+
+Sat Feb 27 00:03:16 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/systime.c: definition
+       * ntpd/ntp_proto.c: sco5_oldclock declaration
+       * configure.in: SCO5_CLOCK for *-*-sco3.2v5*
+       * util/tickadj.c (main): SCO5_OLDCLOCK -> SCO5_CLOCK
+       From: Kees Hendrikse <kees@echelon.nl>
+
+       * ntpd/ntp_config.c (getconfig): Indentation cleanup
+       Deal with 'P' case better
+       * ntpd/ntpd.c: Declare set_process_priority()
+       * ntpd/refclock_dumbclock.c: Lint cleanup
+       From: Marc.Brett@westgeo.com
+
+Wed Feb 24 10:22:51 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.92d
+
+       * configure.in: Dave says we can't enable PARSE clocks by default.
+       Also, Solaris 2.7 still has its kernel bug - disable kernel FLL
+       there.
+       Reported by: Dave Mills <dlm@udel.edu>
+
+Tue Feb 23 23:37:44 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libparse/Makefile.am (parsesolaris.o): Devious hack to deal
+       with bug in sys/systm.h .
+       Suggested by: Chaim Frenkel <chaimf@pobox.com>
+
+Tue Feb 23 20:46:31 1999  Frank Kardel  <kardel <AT> acm.org>
+
+       * ntpd/refclock_parse.c: fixed #endifs
+       (stream_receive): fixed formats
+
+Mon Feb 22 00:35:06 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.92c
+
+       * ntpd/refclock_chronolog.c: Lint
+       * ntpd/refclock_dumbclock.c: Ditto
+       * ntpd/refclock_oncore.c: Ditto
+       From: Marc.Brett@westgeo.com
+
+       * ntpd/refclock_oncore.c (oncore_msg_any): Call GETTIMEOFDAY, not
+       gettimeofday().
+       From: david.higgins@mail.ccur.com
+
+       * configure.in (MCAST): Not in i386-sequent-sysv4
+       Reported by: Joseph Geter <joe.geter@somills.com>
+
+       * util/ntptime.c: Linux cleanup.
+       From: Reg Clemens <reg@dwf.com>
+
+       * configure.in: Rename SCO5_OLDCLOCK to SCO5_CLOCK
+       * acconfig.h: Ditto
+
+       * ntpd/ntp_proto.c: SCO5_CLOCK stuff
+       (init_proto): Use the SCO5_CLOCK stuff
+       * libntp/systime.c: SCO5_CLOCK stuff
+       (get_systime): Use the SCO5_CLOCK stuff
+       (adj_systime): Use the SCO5_CLOCK stuff
+       From: Kees Hendrikse <kees@echelon.nl>
+
+       * ntpd/ntp_config.c: Added -P option and associated baggage.
+       (getstartup): Update help text
+       (getconfig): Process -P option
+       (getconfig): Update help text
+       * ntpd/ntpd.c (set_process_priority): Created.
+       (service_main): remove process priority stuff - we want to do at
+       after we start up the resolver, so call set_process_priority()
+       after getconfig().
+       From: Kamal A Mostafa <kamal@whence.com>
+
+1999-02-21  Frank Kardel  <kardel <AT> acm.org>
+
+       * ntpd/ntp_util.c (hourly_stats): removed unused variable
+
+       * libntp/ieee754io.c: renamed index to fieldindex to avoid index() name clash
+
+       * ntpd/refclock_parse.c (parse_start): add initialization for Linux PPSkit
+
+Sun Feb 21 17:53:33 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_io.c (create_sockets): Skip interfaces that are really
+       just aliases.
+       From: "Erik R. Leo" <erikl@sover.net>
+
+       * configure.in: 4.0.92b
+
+       * ntpd/ntpd.c (service_main): Check for an error return from
+       sched_get_priority_max().
+
+Wed Feb 17 03:48:47 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.92a
+
+       * configure.in: configure.in requires autoconf 2.13 or later.
+       Reported by Ulrich Windl <ulrich.windl@rz.uni-regensburg.de>
+
+Wed Feb 17 00:12:11 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * acconfig.h: TERMIOS_NEEDS__SVID3
+       * configure.in: Ditto
+       * ntpd/refclock_palisade.h: Ditto
+       * include/ntp_refclock.h: Ditto
+       * ntpd/ntpd.c (service_main): We want sched_get_priority_max().
+       From: Kamal A Mostafa <kamal@whence.com>
+
+       * ntpd/ntp_refclock.c (refclock_open): Zero the entire c_cc[] array.
+       From: Reg Clemens <reg@dwf.com>
+
+Tue Feb 16 23:37:49 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * Updated ansi2knr
+       Reported by: Marc Brett
+
+Mon Feb 15 02:55:28 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.92
+
+       * ntpd/ntp_refclock.c: Added refclock_chronolog and
+       refclock_dumbclock.
+       From: Robert McMillin <rlm@syseca-us.com>
+
+Sun Feb 14 15:57:53 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * dropped SCO3 support #defines.
+       * changed SCO5_TICKADJ #define to SCO5_OLDCLOCK
+       * Added code in libntp/systime.c to accumulate changes until a whole
+         tick can be added or dropped. Adjusted gettimeofday() output
+         to include the contents of the accumulator.
+       * cleaned up util/tickadj.c; tickadj -As now does the right thing.
+       From: Kees Hendrikse <kees@echelon.nl>
+
+       * ntpq/ntpq.c: Rename delay() to auth_delay()
+       Reported by: Andrej Borsenkow <borsenkow.msk@sni.de>
+
+       * ntpd/refclock_palisade.h: Cleanup.
+       From: Marc.Brett@westgeo.com
+
+       * ntpd/ntp_refclock.c (refclock_ioctl): Typo.
+       From: Reg Clemens <reg@dwf.com>
+
+       * ntpd/ntp_io.c (create_sockets): Only bind a given network once.
+       From: Wolfgang Rupprecht <wolfgang@wsrcc.com>
+
+Sat Jan 30 11:48:37 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.91f
+
+Thu Jan 28 22:58:40 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_parse.c (CLK_REALTYPE): We really want ttl, not hmode.
+       * ntpd/ntp_config.c (getconfig): "mode" really should update the
+       ttl member, not the hmode member.
+
+       * ntpd/refclock_local.c: More offset cleanup from Dave.
+
+Thu Jan 28 00:15:20 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.91e
+
+       * ntpd/refclock_local.c: Bugfix.
+       From: Dave Mills
+
+       * ntpd/refclock_palisade.c: Lint/IRIX portability cleanup
+       * ntpd/refclock_palisade.h: Re-enable the declaration of float()
+       * ntpd/ntp_io.c (create_sockets): Initialize size to 0
+       From: Marc.Brett@westgeo.com
+
+       * ntpd/refclock_parse.c (CLK_REALTYPE): Use hmode, not ttl.
+       * configure.in (ac_cv_var_no_parenb_ignpar): Not under Linux.
+       Reported by: Thomas Quinot <thomas@Cuivre.FR.EU.ORG>
+
+       * ntpdc/ntpdc.c (my_delay): Renamed, from delay.
+       Reported by: Andrej Borsenkow <borsenkow.msk@sni.de>
+
+Tue Jan 26 00:56:10 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.91d
+
+       * ntpq/ntpq.c: Y2K patches
+       From: Marc.Brett@westgeo.com
+
+       * html/driver29.htm: New version
+       * ntpd/refclock_palisade.c: Ditto
+       * ntpd/refclock_palisade.h: Ditto
+       From: Sven_Dietrich@Trimble.COM
+
+       * upgrade ansi2knr.c
+
+       * Some stuff that Dave did.
+
+       * configure.in: 4.0.91c
+
+       * ntpd/refclock_oncore.c: Prototype cleanup.  Enum cleanup.
+       * ntpd/ntp_proto.c (clock_select): Fix memory leak.
+       * configure.in (ac_cv_struct_ppsclockev): Might need sys/time.h to
+       check for struct clockppsev.  Return pce->serial, not 0;
+       From: Marc.Brett@westgeo.com
+
+       * ntpd/refclock_oncore.c (oncore_msg_En): Clean up.
+       From: John.Hay@mikom.csir.co.za
+
+Mon Jan 25 11:50:29 1999  Philippe De Muyter  <phdm@macqel.be>
+
+       * libparse/parse_conf.c (clockformats): Entry added for
+       clock_wharton_400a.
+       * libparse/clk_wharton.c: New file.
+       * libparse/Makefile.am (libparse_a_SOURCES): clk_wharton.c added;
+       (libparse_kernel_a_SOURCES): kclk_wharton.c added.
+       (kclk_wharton.o): New dependency rule.
+       * ntpd/refclock_parse.c (parse_clockinfo): Entry added for the
+       WHARTON clock (mode 15).
+       * acconfig.h (CLOCK_WHARTON_400A): New configuration macro.
+       * configure.in (CLOCK_WHARTON_400A): Macro defined like other
+       CLOCK_xxx macros.
+
+Sun Jan 24 13:51:30 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_config.c (do_resolve_internal): Missing #ifdef DEBUG
+       From: Sven Dietrich <Sven_Dietrich@Trimble.COM>
+
+       * Makefile.am (SUBDIRS): Lose authstuff
+       * configure.in: Ditto
+
+Sat Jan 23 15:28:03 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.91b
+
+Sat Jan 23 15:02:25 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_oncore.c: use HAVE_STRUCT_PPSCLOCKEV
+       * acconfig.h: HAVE_STRUCT_PPSCLOCKEV
+       * configure.in (ac_cv_struct_ppsclockev): Added test
+
+Thu Jan 21 15:35:25 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.91a
+
+       * ntpd/refclock_nmea.c (nmea_receive): Call refclock_process()
+       every second (or each time a nmea string is received).
+       From: John Hay <jhay@mikom.csir.co.za>
+
+       * ntpd/ntp_refclock.c (refclock_ioctl): Use TIOCPPS if we have it.
+       (refclock_ioctl): Use LDISC_CLKPPS, not LDISC_PPS when deciding
+       how to set str.
+       * ntpd/ntp_loopfilter.c: Lose unused ntp_gettime() stuff.
+       * ntpd/ntp_request.c: Ditto.
+       * ntpd/refclock_local.c: Ditto.
+       * ntpd/refclock_shm.c (shm_poll): Fix the refclock_process() call.
+       * ntpd/refclock_oncore.c: patches and cleanup
+       * configure.in: ioctl/PPS checks, ONCORE cleanup
+       * acconfig.h: ONCORE cleanup
+       From: Reg Clemens <reg@dwf.com>
+
+       * configure.in (CFLAGS): cc on Sequent wants -Wc,+abi-socket.
+       We also need to figure out why -lsocket isn't being detected;
+       -lsocket is needed.
+       From: Dana Kaempen <decay@flash.net>
+
+       * include/ntp_stdlib.h: AIX portability patches, header cleanup.
+       * ntptrace/ntptrace.c: Ditto.
+       * ntpdate/ntpdate.c: Ditto.
+       * ntpd/refclock_true.c: Ditto.
+       * ntpd/refclock_mx4200.c: Ditto.
+       * ntpd/refclock_jupiter.c: Ditto.
+       * libntp/msyslog.c: Ditto.
+       From: Marc.Brett@waii.com
+
+Sun Jan 10 15:15:07 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.91
+
+Sat Jan  9 00:11:34 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntp_stdlib.h: msyslog() is declared differently if we're
+       not __STDC__.
+
+       * include/ntp_types.h: It's HAVE_PROTOTYPES, not USE_PROTOTYPES.
+       * include/ntp_machine.h: Ditto.
+
+Fri Jan  8 20:47:10 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Upgrade to autoconf-2.13
+       Do the prototypes check much earlier, as it might alter CFLAGS and
+       things which will affect other tests.
+
+       * ntpd/ntp_request.c (do_conf): The problem was with a template
+       for "version" on an IRIX C compiler...
+       From: Marc.Brett@waii.com
+
+       * libntp/authkeys.c: #include config.h first.
+       Reported by: brian.bumpass@funb.com
+
+Thu Jan  7 00:24:35 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * util/tickadj.c (main): return() instead of exit().
+       * ntpd/ntp_request.c (do_conf): Disambiguate ||.
+       * ntpd/ntp_proto.c (clock_select): Initialize variables.
+       From: Marc.Brett@waii.com
+
+       * scripts/ntpver.in: Use PATH_SH
+
+       * configure.in (PATH_SH): Added.
+
+Tue Jan  5 19:02:51 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.90h
+
+       * html/driver30.htm: Updated.
+       * html/refclock.htm: Refer to driver30
+       * ntpd/refclock_oncore.c: Vastly improve and make less FreeBSD centric,
+       From: Poul-Henning Kamp <phk@critter.freebsd.dk> and
+               Reg.Clemens <reg@dwf.com>
+
+       * include/ntp.h: Portability/lint patches
+       * libntp/binio.c: Ditto.
+       * libntp/caljulian.c: Ditto.
+       * libntp/caltontp.c: Ditto.
+       * libntp/ieee754io.c: Ditto.
+       * libntp/md5c.c: Ditto.
+       * libntp/mfp_mul.c: Ditto.
+       * libntp/msyslog.c: Ditto.
+       * libntp/statestr.c: Ditto.
+       * libntp/systime.c: Ditto.
+       * libparse/clk_trimtsip.c: Ditto.
+       * libparse/data_mbg.c: Ditto.
+       * libparse/parse.c: Ditto.
+       * ntpd/ntp_control.c: Ditto.
+       * ntpd/ntp_filegen.c: Ditto.
+       * ntpd/ntp_intres.c: Ditto.
+       * ntpd/ntp_io.c: Ditto.
+       * ntpd/ntp_peer.c: Ditto.
+       * ntpd/ntp_proto.c: Ditto.
+       * ntpd/ntp_util.c: Ditto.
+       * ntpd/ntpd.c: Ditto.
+       * ntpd/refclock_arc.c: Ditto.
+       * ntpd/refclock_chu.c: Ditto.
+       * ntpd/refclock_datum.c: Ditto.
+       * ntpd/refclock_leitch.c: Ditto.
+       * ntpd/refclock_parse.c: Ditto.
+       * ntpd/refclock_usno.c: Ditto.
+       * ntpq/ntpq.c: Ditto.
+       * util/tickadj.c: Ditto.
+       From: Marc.Brett@waii.com
+
+Mon Jan  4 00:56:55 1999  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.90g
+
+       * ntpd/ntp_config.c (getconfig): MODE was setting ttl, not hmode.
+       Reported by: Carsten Emde <ce@ceag.ch>
+
+Fri Dec  4 01:01:14 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.90f
+
+       * ntpd/refclock_mx4200.c: New version
+       From: Marc.Brett@waii.com
+
+1998-12-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_config.c (do_resolve_internal): If fork fails, say why.
+       Reported by: Jeff_Dennison@admin.tc.faa.gov
+
+       * ntpd/ntpd.c (ntpdmain):  fork() can return a -1.  Someday we'll
+       report this condition...
+
+1998-12-02  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.90e
+
+       * ntpd/refclock_palisade.c: Reformat code so ansi2knr will work
+       * ntpd/refclock_palisade.h: Ditto
+       From: Marc.Brett@waii.com
+
+Sun Nov 29 21:00:53 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.90d
+
+       * configure.in (CFLAGS): Use "-O2 -g3 -n32" by default for Irix6.2
+       and later.
+       Reported by: Jack Bryans <jbryans@csulb.edu>
+
+1998-11-29  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.90c
+
+       * ntpd/refclock_oncore.c (oncore_msg_En): Convert to nano
+       From: John Hay <jhay@mikom.csir.co.za>
+
+       * include/ntp_request.h (RM_VN_MODE): Add version parameter, so
+       xntpdc will work across v3 and v4.
+       * ntpd/ntp_request.c: Track requested version
+       (req_ack): Use requested version in RM_VN_MODE
+       (more_pkt): Ditto
+       (flush_pkt): Ditto
+       (process_private): Get requested version
+       * ntpd/ntp_intres.c (request): Use default version
+       * ntpdc/ntpdc.c (sendrequest): Ditto
+       From: John Hay <jhay@mikom.csir.co.za>
+
+Fri Nov 27 14:27:21 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_palisade.c: Lint cleanup
+       * ntpd/refclock_palisade.h: Ditto.
+       From: Marc Brett <mbrett@rgs0.london.waii.com>
+
+Mon Nov 23 04:45:03 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.90b
+
+       * New code and cleanup for the NT stuff
+       From: Carl Byington <carl@five-ten-sg.com>
+
+Sat Nov 21 21:21:45 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.90a
+
+       * libntp/systime.c (step_systime): net_set_tod calls clock_settime.
+       * libntp/machines.c (ntp_set_tod): Take a 2nd arg for NT.
+       * include/ntp_machine.h: ntp_set_tod() has 2 args always.
+       * ports/winnt/bldrel.bat: Typo.
+       From: Carl Byington <carl@five-ten-sg.com>
+
+       * ntpd/ntp_intres.c (findhostaddr): h_errno is a #define under AIX.
+       * configure.in:  clock_settime is a stub in AIX4.
+       From: Perry Ross <pross@platinum.com>
+
+       * libntp/Makefile.am (EXTRA_DIST): Lose libntp.mak
+       * ntpd/Makefile.am (EXTRA_DIST): Ditto.
+       * ntpdate/Makefile.am (EXTRA_DIST): Ditto.
+       * ntpdc/Makefile.am (EXTRA_DIST): Ditto.
+       * ntpq/Makefile.am (EXTRA_DIST): Ditto.
+       From: Greg Schueman <schueman@ix.netcom.com>
+
+Sat Nov 21 12:33:16 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.90
+
+       Nano changes from Dave Mills.
+
+Thu Nov 19 04:23:46 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntp_machine.h: STREAM also needs HAVE_SYS_STREAM_H
+       Reported by: Ronald Cole <ronald@forte-intl.com>
+
+Mon Nov 16 19:17:34 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.73e14
+
+       * util/ntptime.c (main): Protect STA_NANO
+
+       * ntpd/refclock_oncore.c: General overhaul and simplifications.
+       The new manual clarifies a lot of fine points, and the driver has
+       been suitably simplified.  Uses Site Survey if possible, otherwise
+       does it by hand.  Should also work with non-UT models, as long as
+       they talk the Motorola Binary Protocol.  The driver Doesn't (need
+       to) know where the author lives anymore.
+       From: Poul-Henning Kamp <phk@critter.freebsd.dk>
+
+       * ntpd/refclock_palisade.h: New version.
+       * ntpd/refclock_palisade.c: New version.
+       From: Sven Dietrich <Sven_Dietrich@Trimble.COM>
+
+Sat Oct 24 01:19:21 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.73e13
+
+       * ntpdc/ntpdc_ops.c (clkbug): Patches
+       * ntpd/ntp_refclock.c (refclock_buginfo): Patches
+       From: Marc.Brett@waii.com
+
+Sat Oct 10 20:13:14 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.73e12
+
+       * ntpd/ntp_util.c (hourly_stats): Added prio_set stuff.
+
+       * ntpd/ntpd.c (ntpdmain): HAVE_SETPGRP_0 typo.
+       * parseutil/dcfd.c (detach): Ditto.
+       * ntpd/ntp_control.c (ctl_putpeer): Sometimes, peer->dstadr is
+       NIL.
+       From: Perry Ross <pross@platinum.com>
+
+       * ntpd/ntpd.c:
+       Some systems use sys/sched.h, not sched.h (Irix)
+       * configure.in (CFLAGS): nextstep needs -posix.
+       Reported by: Jack Bryans <jbryans@csulb.edu>
+
+Sat Oct  3 02:32:46 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.73e11
+
+       * configure.in (ac_refclock_palisade): Needs termios.
+
+       * libntp/mktime.c: Some systems need sys/types.h
+
+       * configure.in: Added AC_TYPE_SIZE_T and AC_CHECK_TYPE(time_t, long)
+       The time_t stuff should only be needed on Older machines, so the
+       fact that I'm using a long shouldn't be a problem (hollow laugh).
+
+       * include/l_stdlib.h: Sometimes we need to #include <sys/types.h>
+
+       * libntp/Makefile.am (../include/des.h): Typo.
+
+Fri Oct  2 20:52:47 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_intres.c (request): Accept responses back thru V2.
+
+Thu Oct  1 00:11:16 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.73e9
+
+       * ntpd/ntpd.c (catch_danger): Added.
+       (ntpdmain): AIX SIGDANGER stuff
+       From: Lars-Owe Ivarsson <larsowe@paradisaea.its.uu.se>
+
+       * configure.in:
+       * include/ntp_machine.h:
+       * include/ntp_string.h:
+       * libntp/machines.c:
+       * libparse/clk_hopf6021.c:
+       * libparse/clk_trimtsip.c:
+       * ntpd/refclock_leitch.c:
+       * ntpd/refclock_palisade.c:
+       * ntpd/refclock_parse.c:
+       Here are some patches to suppress warnings from various compilers
+       (IRIX 5.3, MipsPro C 7.1 on IRIX 6.4, AIX 4.1) and loaders (IRIX
+       5.3, IRIX 6.4).  Shouldn't affect functionality at all.
+       From: Marc Brett <mbrett@rgs0.london.waii.com>
+       (I got similar patches for AIX from Lars-Owe Ivarsson
+       <larsowe@paradisaea.its.uu.se>)
+
+Thu Sep 24 21:33:50 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: '73e8
+
+       * configure.in: AIX4 stubs the POSIX timer_ stuff,
+       sched_setscheduler, and mlockall.
+       Reported by: Lars-Owe Ivarsson <larsowe@paradisaea.its.uu.se>
+
+       * configure.in: OpenBSD stubs the POSIX timer_ stuff.
+       Reported by:  sidney august cammeresi iv <cammeres@uiuc.edu>
+       (and several other folks whose names I can't find at the moment)
+
+Mon Sep 21 15:35:23 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: '73e7
+
+       * ntpd/refclock_parse.c: Missing declaration
+       From: Marc Brett <mbrett@rgs0.london.waii.com>
+
+       * include/README: Remove old MCAST descriptions
+
+       * include/Makefile.am (noinst_HEADERS): Lose sun-in.h .
+
+Mon Sep 21 14:50:12 1998  Harlan Stenn  <stenn@grundoon.udel.edu>
+
+       * ntpdate/ntpdate.c (timer): Properly format the definition.
+
+Sun Sep 20 23:02:50 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: '73e6
+
+       * include/Makefile.am (noinst_HEADERS): Renamed in.h to sun-in.h
+
+Fri Sep 18 01:05:55 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: '73e5
+
+       * ntpd/refclock_palisade.c: SCO patch
+       From: Kamal A Mostafa <kamalm@sco.com>
+
+       * libparse/clk_trimtsip.c (cvt_trimtsip): Fix rollover bug.
+       From: "Michael J. Tubby B.Sc. G8TIC" <Mike.Tubby@thorcom.co.uk>
+
+       * libntp/authencrypt.c:
+       * libntp/systime.c:
+       * ntpd/refclock_acts.c:
+       * ntpd/refclock_arbiter.c:
+       * ntpd/refclock_arc.c:
+       * ntpd/refclock_as2201.c:
+       * ntpd/refclock_atom.c:
+       * ntpd/refclock_chu.c:
+       * ntpd/refclock_conf.c:
+       * ntpd/refclock_datum.c:
+       * ntpd/refclock_heath.c:
+       * ntpd/refclock_hpgps.c:
+       * ntpd/refclock_irig.c:
+       * ntpd/refclock_leitch.c:
+       * ntpd/refclock_nmea.c:
+       * ntpd/refclock_palisade.c:
+       * ntpd/refclock_parse.c:
+       * ntpd/refclock_pst.c:
+       * ntpd/refclock_trak.c:
+       * ntpd/refclock_true.c:
+       * ntpd/refclock_usno.c:
+       * ntpd/refclock_wwvb.c:
+       Typos, cleanup, and bugfixes
+       From: Marc Brett <mbrett@rgs0.london.waii.com>
+
+       * ntpd/ntp_timer.c (timer): Typo.
+       * include/ntp_refclock.h: in refclockstat, clockdesc should be const.
+       * ntpd/ntp_io.c (create_sockets): Typo.
+       * ntpd/ntp_control.c (free_varlist): Use the appropriate cast when
+       calling free().
+       (set_var): Use char *td for non-const char data.
+       (ctl_getitem): Use char * for non-const data.
+       (Many of these reported by Marc Brett)
+
+Sun Sep 13 19:19:09 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntpd.c: Added nofork declaration.
+       (ntpdmain): Initialize it...
+       * ntpd/ntp_config.c: added nofork.
+       Updated ntp_options.
+       (getstartup): Updated "usage" string.  Deal with -n flag.
+       (getconfig): Ditto.
+       From: Jeffrey Hutzelman <jhutz@cs.cmu.edu>
+
+       * ntpd/ntp_io.c (open_socket): Use ntoa() to print out the address
+       when bind() fails. (in 2 places)
+       Reported by: "Markus W. Fehr" <mfehr@ch.ibm.com>
+       Only soft-fail if an interface is unavailable.
+       (create_sockets):  Don't SO_REUSEADDR if the interface is unavailable.
+       From: "Markus W. Fehr" <mfehr@ch.ibm.com>
+
+       * configure.in:  If we --disable-all-clocks, then don't enable
+       parse clocks by default.
+       Reported by: Marion Hakanson <hakanson@cse.ogi.edu>
+
+Sat Aug 22 23:58:14 1998  Frank Kardel  <kardel <AT> acm.org>
+
+       * ntpd/refclock_parse.c (local_input): fixed IO handling for non-STREAM IO
+
+Sun Aug 16 20:13:32 1998  Frank Kardel  <kardel <AT> acm.org>
+
+       * libntp/ieee754io.c: debug information only compile for LIBDEBUG case
+
+       * ntpd/refclock_parse.c (gps16x_message): reduced UTC parameter information (dropped A0,A1)
+       made uval a local variable (killed one of the last globals)
+       (sendetx): added logging of messages when in debug mode
+       (trimble_check): added periodic checks to facilitate re-initialization
+       (trimbletsip_init): made use of EOL character if in non-kernel operation
+       (trimbletsip_message): extended message interpretation
+       (getdbl): fixed data conversion
+
+       * libparse/parse_conf.c (clockformats): Trimble TSIP driver now also
+       available for kernel operation
+
+       * libparse/info_trimble.c: re-generated
+
+       * libparse/clk_trimtsip.c (cvt_trimtsip): initial kernel capable version (no more floats)
+       (clock_trimtsip =): new format name
+
+       * libparse/clk_trimtaip.c (clock_trimtaip =): changed format name
+
+       * include/trimble.h (CMD_RSTATTRACK): renamed mode 6 variable name
+
+       * scripts/monitoring/ntploopwatch: moved emacs mode selector
+
+Mon Aug 10 15:32:48 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_acts.c: Patch cleanup
+       * ntpd/ntp_refclock.c: Patch cleanup
+       * ntpd/ntp_timer.c: Patch cleanup
+       From: qli@huey.udel.edu
+
+Wed Jul 29 15:23:21 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/machines.c: IRIX needs time.h
+       Reported by: Judith E Bush <jbush@fi.edu>
+
+       * ntpd/ntpd.c (service_main): Better AIX PROCLOCK fix.
+       From: Matt Ladendorf <matt.ladendorf@anheuser-busch.com> and
+       Grover Davidson <Grover.Davidson@anheuser-busch.com>
+
+Wed Jul 29 01:36:48 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntpd.h (MAXINTERFACES): Moved here...
+       * ntpd/ntp_io.c: From here...
+       (create_sockets): Only deal with MAXINTERFACES.
+       (create_sockets): Only deal with specified interfaces.
+
+       * ntpd/ntp_config.c (CONFIG_LISTEN): Added
+       Added ifnum and listenaddrs[]
+       (getconfig): Added defn for "addr"
+       (getconfig): Initialize ifnum.
+
+       * ntpd/ntpd.c (service_main): call init_io after getconfig
+       From: Vebjorn Ljosa <ljosa@initio.no>
+
+Wed Jul 29 00:42:28 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_palisade.c: Use NEED_HPUX9_TIOCM_STUFF
+
+       * acconfig.h (NEED_HPUX9_TIOCM_STUFF):  Added.
+
+       * configure.in (REFCLOCK_PALISADE): Needs termio*.h
+       (NEED_HPUX9_TIOCM_STUFF): Added.
+
+       * ntpd/ntp_io.c (create_sockets): Use strchr instead of strstr.
+
+       * libntp/mktime.c: #include <sys/types.h>
+
+       * libntp/ieee754io.c: #include <sys/types.h>
+
+Wed Jul 29 00:24:22 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_acts.c (ACTS_MAXPOLL): 14 -> 18.
+       Import current_nextdate
+       (acts_receive): Update peer->nextdate with current_nextdate
+       (acts_poll): Call acts_timeout() (debugging)
+
+       * ntpd/ntp_refclock.c: Export current_nextdate.
+       (refclock_transmit): Check peer->valid >= NTP_SHIFT - 2, not >.
+       (refclock_transmit): hpoll wiggles, update current_nextdate
+
+       * ntpd/ntp_timer.c: #include "ntp_refclock.h"
+       (MODE_MANUAL): Added.
+       (timer): MODE_MANUAL stuff
+
+       From: qli@huey.udel.edu
+
+Tue Jul 28 23:23:15 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Check for inet_ntoa in -lbind .
+
+       * ntpd/ntpd.c: #undef PROCLOCK for AIX.
+
+Mon Jul 20 01:06:24 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (AC_TYPE_SIZE_T): Added.
+
+Sat Jul 11 09:38:30 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.73e
+
+       * ports/winnt/: Replaced with new code (no SHM or PALISADE)
+       From: Greg Schueman <schueman@ix.netcom.com>
+
+Fri Jul 10 12:12:59 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.73d
+
+       * include/ntp_machine.h (HAVE_SRANDOM): VxWorks patches
+       (HAVE_RANDOM): Ditto.
+       (CALL): Ditto.
+       From: Casey Crellin <ccrellin@mweb.com>
+
+       * ntpd/refclock_parse.c (local_input): Typo.
+       Reported by: Tony Li <tony1@home.net>
+
+Wed Jul  8 01:49:01 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.73c
+
+       * PARSE patches from Frank Kardel
+
+       * libntp/machines.c (ntp_set_tod): Get it right.
+
+Sun Jul  5 22:15:34 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.73a
+
+       * kernel/sys/timex.h (MOD_CANSCALE): Add rest of patch to handle
+       scaling.
+       From: Poul-Henning Kamp <phk@critter.freebsd.dk>
+
+Wed Jun 10 21:16:01 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.73
+
+       * ntpd/ntp_loopfilter.c (local_clock): MOD_CANSCALE patches, and
+       be careful with the integration if we're nearly perfect.
+       From: Poul-Henning Kamp <phk@critter.freebsd.dk>
+
+       * util/tickadj.c (main): Typo fix...
+       From: Marion Hakanson <hakanson@cse.ogi.edu>
+
+       * ntpd/ntp_io.c (create_sockets): Attempt to ignore alias
+       interfaces.
+       From: Kenneth Maupin <maupin@easystreet.com>
+
+       * ntpd/ntp_refclock.c: PPS fixes
+       * ntpd/refclock_msfees.c (msfees_start): Portability fixes and
+       PPS/STREAM enhancements
+       From: John Hay <jhay@mikom.csir.co.za>
+
+       * ntpd/ntp_refclock.c (refclock_gtlin): Patch...
+       From: Jonathan Stone <jonathan@DSG.Stanford.EDU>
+
+Sun Jun 28 18:43:30 1998  Frank Kardel  <kardel <AT> acm.org>
+
+       * libntp/buftvtots.c (buftvtots): using WORD_BIGENDIAN instead of XNTP_BIG_ENDIAN
+
+       * libparse/clk_trimtsip.c (getflt): fixed ENDIAN issue
+       (getdbl): fixed ENDIAN issue
+       (getint): use get_msb_short()
+       (cvt_trimtsip): use gpstolfp() for conversion
+
+       * libntp/Makefile.am (libntp_a_SOURCES): added gpstolfp.c source
+
+       * libntp/binio.c: added {get,put}_msb_{short,long}() functions
+
+       * include/ntp_fp.h: added gpstolfp() prototype
+
+       * include/binio.h: added binio MSB prototypes
+
+Sat Jun 13 13:48:17 1998  Frank Kardel  <kardel <AT> acm.org>
+
+       * parseutil/testdcf.c: signed/unsigned
+       SYSV clock name clash fixed
+
+       * parseutil/dcfd.c: signed/unsigned
+       SYSV clock name clash fixed
+       year wrapping at 1998
+       ctype macros take ints as args
+
+       * ntptrace/ntptrace.c (decodeipaddr): ctype macros take ints as args
+
+       * ntpq/ntpq_ops.c (doprintpeers): signed/unsigned
+
+       * ntpq/ntpq.c: ctype macros take ints as args
+       signed/unsigned
+
+       * ntpdc/ntpdc.c: signed/unsigned
+
+       * ntpd/refclock_usno.c: signed/unsigned
+
+       * ntpd/refclock_true.c (true_send): signed/unsigned, name clashes
+
+       * ntpd/refclock_parse.c: signed/unsigned, name clashes
+
+       * ntpd/refclock_nmea.c (nmea_receive): ctype macros take ints as args
+
+       * ntpd/refclock_heath.c (heath_receive): prototypes (signed/unsigned issues)
+
+       * ntpd/refclock_arc.c: prototypes (signed/unsigned issues)
+
+       * ntpd/refclock_acts.c: prototypes (signed/unsigned issues)
+
+       * ntpd/ntpd.c: prototypes (signed/unsigned issues)
+
+       * ntpd/ntp_util.c (getauthkeys): prototypes (signed/unsigned issues)
+       fix SYSV clock name clash
+
+       * ntpd/ntp_request.c: prototypes (signed/unsigned issues)
+       fix SYSV clock name clash
+
+       * ntpd/ntp_io.c (input_handler): variable naming, signed/unsigned
+
+       * ntpd/ntp_intres.c (readconf): signed/unsigned issues
+
+       * ntpd/ntp_control.c: prototypes (signed/unsigned issues)
+       fix SYSV clock name clash
+
+       * ntpd/ntp_config.c: fix SYSV clock name clash
+        ctype macros take ints as args
+
+       * libparse/parsestreams.c: dirt (debug) removed
+
+       * libparse/parsesolaris.c: more prototypes
+       fix name clashes
+       allow for ansi2knr
+
+       * libparse/parse.c: bcopy/memcpy cleanup
+       fix SYSV clock name clash
+
+       * libparse/clk_trimtsip.c (cvt_trimtsip): fix SYSV clock name clash
+
+       * libparse/clk_trimtaip.c (cvt_trimtaip): fix SYSV clock name clash
+
+       * libparse/clk_schmid.c (cvt_schmid): fix SYSV clock name clash
+
+       * libparse/clk_rcc8000.c (cvt_rcc8000): fix SYSV clock name clash
+
+       * libparse/clk_rawdcf.c (cvt_rawdcf): fix SYSV clock name clash
+
+       * libparse/clk_hopf6021.c (cvt_hopf6021): fix SYSV clock name clash
+
+       * libparse/clk_dcf7000.c (cvt_dcf7000): fix SYSV clock name clash
+
+       * libparse/clk_computime.c: fix SYSV clock name clash
+
+       * libntp/octtoint.c (octtoint): ctype macros take ints as args
+
+       * libntp/mstolfp.c (mstolfp): ctype macros take ints as args
+
+       * libntp/hextolfp.c (hextolfp): ctype macros take ints as args
+
+       * libntp/hextoint.c (hextoint): ctype macros take ints as args
+
+       * libntp/decodenetnum.c (decodenetnum): ctype macros take ints as args
+
+       * libntp/atouint.c (atouint): ctype macros take ints as args
+
+       * libntp/atolfp.c (atolfp): ctype macros take ints as args
+
+       * libntp/atoint.c (atoint): ctype macros take ints as args
+
+       * kernel/sys/parsestreams.h:  STREAM macro gone in favor of HAVE_SYS_STREAM_H
+
+       * include/parse.h: STREAM macro gone in favor of HAVE_SYS_STREAM_H
+
+Fri Jun 12 11:08:53 1998  Frank Kardel  <kardel <AT> acm.org>
+
+       * ntpd/ntp_timer.c: prototype fixes (ansi2knr/knr compiler)
+
+       * ntpd/ntp_proto.c (make_keylist): type cast for e(!!!)malloc()
+
+       * libparse/Makefile.am: adjust for ansi2knr
+
+       * libntp/ieee754io.c: ansi2knr compatibility
+
+       * include/ntp_refclock.h: added pps_sample() extern declaration
+       added refclock_process_offset() extern declaration
+
+       * include/ntp.h: fixed function * prototypes
+
+       * ntpd/refclock_parse.c (bind): added input routine
+       (local_input): added input routine
+
+       * ntpd/ntp_io.c (input_handler): direct input processing for
+       refclocks to save input recv buffers
+
+       * include/ntp_refclock.h: added int io_input(struct recvbuf *)
+       pointer to allow direct processing of read refclock data in
+       order to save many bug recv buffers on single character input
+       (problem with "fast" machines)
+
+       * parse_conf.c:  conditional compile macros fixed
+
+       * parse.c:  conditional compile macros fixed
+       printf prototype
+
+       * clk_trimtaip.c:  conditional compile macros fixed
+       printf prototype
+
+       * clk_schmid.c:  conditional compile macros fixed
+       printf prototype
+
+       * clk_rcc8000.c:  conditional compile macros fixed
+       printf prototype
+
+       * clk_hopf6021.c:  conditional compile macros fixed
+       printf prototype
+
+       * clk_dcf7000.c: conditional compile macros fixed
+       printf prototype
+
+       * clk_computime.c: conditional compile macros fixed
+       printf prototype
+
+Sat Jun  6 07:41:54 1998  Frank Kardel  <kardel <AT> acm.org>
+
+       * ntpd/refclock_palisade.c: fixed termio.h / termios.h inclusion
+
+       * include/ntp_refclock.h: made refclockproc/clockdesc const
+
+       * ntpd/ntp_control.c (ctl_putpeer): avoided ambigous 'else' (gcc)
+
+       * ntpd/refclock_parse.c (parse_start): added BURST mode initialisation
+
+       * scripts/stats/summary.sh (CLOCK): allow for Y2K log files
+
+       * libparse/clk_rawdcf.c: simplified condidional compile expression
+
+Wed May 27 08:10:43 1998  Frank Kardel  <kardel <AT> acm.org>
+
+       * include/Makefile.am (noinst_HEADERS): added new header files
+       mbg_gps166.h binio.h ascii.h ieee754io.h
+
+       * ntpdc/ntpdc.c (sendrequest): fixed info_auth_keyid setting it
+       got accidentally trashed every other round
+
+Mon May 25 22:55:07 1998  Frank Kardel  <kardel <AT> acm.org>
+
+       * configure.in: PARSE clocks are enabled by default whenever
+       possible (termio.h or termios.h present)
+       removed RAWDCF_SETDTR feature
+
+       * acconfig.h: removed RAWDCF_SETDTR option (now implicit by
+       compilation and run time configuration)
+
+       * ntpd/refclock_parse.c (rawdcf_init): offer a RAWDCF clock (type 14)
+       that attempts to set the DTR modem line for receiver power
+
+       * libparse/clk_meinberg.c (cvt_meinberg): support current standard
+       Meinberg data formats
+
+Sun May 24 09:43:19 1998  Frank Kardel  <kardel <AT> acm.org>
+
+       * libparse/clk_rawdcf.c (pps_rawdcf): trigger pps on zero going
+       edge - that is simpler wiring (Rx->DCD).
+
+       * parseutil/testdcf.c (wday): const keyword
+
+       * parseutil/dcfd.c (cvt_rawdcf): sign issues and calling interfaces
+
+       * ntpq/ntpq.c (MAXVARLEN): adjusted internal buffer length for
+       variable values
+
+       * ntpd/refclock_parse.c: adjust to new io handling (fixed formats
+       only)
+       (mkreadable): don't include >"< in readable ASCII output (-> ntpq
+       parsing)
+       output debug messages to stdout instead of msyslog()
+       fixed version information string
+
+       * ntpd/refclock_atom.c (pps_sample): new auxiliary pps interface
+
+       * libparse/parsestreams.c (parserput): get event status consistent
+       with direct calls
+       (zs_xsisr): simulate CARRIER status to avoid unnecessary M_xHANGUP
+       events
+
+       * libparse/parsesolaris.c (parserput): get event status consistent
+       with direct calls
+       (zs_xsisr): simulate CARRIER status to avoid unnecessary M_xHANGUP
+       events
+
+       * libparse/parse.c: removed old input cruft
+       (parse_restart): new generic input help function
+       (parse_addchar): ditto
+       (parse_end): ditto
+       (pps_one): new generic pps help function
+       (pps_zero): ditto
+
+       * libparse/clk_trimtsip.c (clock_trimtsip =): new input handling
+
+       * libparse/clk_trimtaip.c (clock_trimtaip =): new input handling
+       (inp_trimtaip): new input handler
+
+       * libparse/clk_schmid.c (clock_schmid =): new input handling
+       (inp_schmid): new input handler
+
+       * libparse/clk_rcc8000.c (clock_rcc8000 =): new input handling
+       (inp_rcc8000): new input handler
+
+       * libparse/clk_rawdcf.c (clock_rawdcf =): new input handling
+       (snt_rawdcf): adjusted to new input handling
+       (inp_rawdcf): new input handler
+
+       * libparse/clk_meinberg.c (clock_meinberg): new input handling
+       (gps_input): new input handler
+       (mbg_input): new input handler
+
+       * libparse/clk_hopf6021.c (clock_hopf6021 =): new input handling
+       (inp_hopf6021): new input handler
+
+       * libparse/clk_dcf7000.c (clock_dcf7000 =): new input handling
+       (inp_dcf7000): new input handler
+
+       * libparse/clk_computime.c (clock_computime =): new input handling
+       (inp_computime): new input handler
+
+       * libparse/Makefile.am: link kernel module with libntp.a
+
+       * include/parse.h (struct parse): removed old data structure cruft
+       (new input model) new PARSE_INP* macros for input handling
+       removed old SYNC_* macros from old input model
+       (struct clockformat): removed old parse functions in favor of the
+       new input model
+       updated prototypes
+
+       * include/ntp_refclock.h: prototype for refclock_atom pps_sample()
+       interface
+
+       * acconfig.h: added PPS_SAMPLE define
+       * configure.in (LIBPARSE): added PPS_SAMPLE configuration
+       <refclock_atom aux interface>
+
+       * libntp/systime.c (adj_systime): debug output (> level 6) for
+       adjtime results
+
+       * libntp/mfp_mul.c (mfp_mul): controlled debug output
+
+       * libntp/ieee754io.c (get_byte): controlled debug output
+       (fetch_ieee754): ditto
+       (put_ieee754): ditto
+
+Tue May  5 20:09:51 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: document DES is not usually present.
+
+Wed Apr 29 22:00:22 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.72h
+
+       * authstuff/Makefile.am (check-local-rsn): check-local doesn't
+       work with RSAREF...
+       Reported by: "Auteria Wally Winzer Jr." <wally.winzer@champusa.com>
+
+       * libntp/machines.c: the settime() choices were ordered badly.
+       Reported by: Michael Joosten <joost@c-lab.de>
+
+Sat Apr 25 00:35:53 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_cv_var_no_parenb_ignpar): Undo the kernel PLL
+       block I just installed - Dave wants to control this via
+       KERNEL_FLL_BUG.
+
+Fri Apr 24 20:35:57 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/Makefile.am (libntp_a_DEPENDENCIES): Set per libntp_a_LIBADD
+
+       * configure.in: Do a better job of blocking kernel PLL under
+       solaris2.6.
+
+Fri Apr 24 00:41:12 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: 4.0.72f
+       (ac_cv_struct_nlist_n_un): Don't look for ntp_adjtime or
+       ntp_gettime under solaris2.6.
+
+       * ntpd/ntp_proto.c (process_packet): Give verbose error messages
+
+       * include/global.h (PROTOTYPES): Drive via HAVE_PROTOTYPES.
+
+Wed Apr 22 16:55:55 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_cv_var_use_des): Added. 4.0.72e.
+       * libntp/Makefile.am (libntp_a_LIBADD): Added DESOBJS
+
+Tue Apr 21 02:08:06 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_arc.c (arc_receive): Typo...
+       From: Sam Steingold <sds@usa.net>
+
+Fri Apr 10 03:05:35 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_refclock_chu): AUDIO_CHU support.  Disabled by
+       default, and currently only supported on SunOS and Solaris.
+       * acconfig.h: AUDIO_CHU
+
+Wed Apr  8 19:53:53 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/Makefile.am (EXTRA_DIST): Added mktime.c
+
+       * configure.in:  AC_REPLACE_FUNCS(mktime).
+       (--enable-dst-minutes=60): Added, for (missing) mktime().
+
+       * ntpd/refclock_heath.c (heath_receive): Use mktime() instead of
+       the old hack.
+
+Tue Apr  7 21:15:14 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (LIBOBJS): Hack it before AC_OUTPUT to deal with
+       ANSI2KNR-filtering rules.
+       From: Jim Meyering <meyering@ascend.com>
+
+Mon Apr  6 01:40:45 1998  Harlan Stenn  <stenn@grundoon.udel.edu>
+
+       * libntp/strerror.c: ANSIfy strerror's definition.
+
+Thu Mar 12 20:24:45 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * libntp/statestr.c: Only #include <config.h> if HAVE_CONFIG_H is
+       #define'd.
+       From: Sven Dietrich <Sven_Dietrich@Trimble.COM>
+
+Wed Mar 11 00:27:32 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Cygwin needs to check for the advapi32 library.
+       NT doesn't support a root user, so don't bother with getuid().
+       Also, don't bother with umask().
+
+       * ntpd/ntp_io.c: cygwin32 patches
+       * ntpd/ntp_proto.c: Ditto.
+       * ntpd/ntpd.c: Ditto.
+       * ntpd/ntp_timer.c: Ditto.
+       * ntpdate/ntpdate.c: Ditto.
+       * libntp/machines.c: Ditto.
+       * libntp/systime.c: Ditto.
+       * include/ntp_machine.h: Ditto.
+       * include/ntp_unixtime.h: Ditto.
+       From: Sven Dietrich <Sven_Dietrich@Trimble.COM>
+
+Tue Mar 10 22:26:14 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_cv_make_tickadj): Added.
+       Now that tickadj is the only(?) utility that cares about tick and
+       tickadj, we don't need to have NOKMEM and no PRESET_* be fatal.
+
+Sat Mar  7 02:57:17 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_loopfilter.c (local_clock): Patch STA_FLL check
+       From: Poul-Henning Kamp <phk@freebsd.org>
+
+       * various: Renamed ACTS to CLOCK_ACTS, ARBITER to CLOCK_ARBITER,
+       ARCRON_MSF to CLOCK_ARCRON_MSF, AS2201 to CLOCK_AS2201, BANC to
+       CLOCK_BANC, DATUM to CLOCK_DATUM, GPSVME to CLOCK_GPSVME, HEATH to
+       CLOCK_HEATH, HPGPS to CLOCK_HPGPS, IRIG to CLOCK_IRIG, JUPITER to
+       CLOCK_JUPITER, LEITCH to CLOCK_LEITCH, MSFEES to CLOCK_MSFEES,
+       MX4200 to CLOCK_MX4200, NMEA to CLOCK_NMEA, PALISADE to
+       CLOCK_PALISADE, PARSE to CLOCK_PARSE, PPS720 to CLOCK_PPS720, PST
+       to CLOCK_PST, PTBACTS to CLOCK_PTBACTS, SHM_CLOCK to CLOCK_SHM,
+       ONCORE to CLOCK_ONCORE, TPRO to CLOCK_TPRO, TRAK to CLOCK_TRAK,
+       TRUETIME to CLOCK_TRUETIME, USNO to CLOCK_USNO, WWVB to CLOCK_WWVB
+
+       * Makefile.am (ETAGS_ARGS): Added acconfig.h
+
+       * various: Renamed LOCAL_CLOCK to CLOCK_LOCAL.
+
+       * configure.in: First cut at  *-pc-cygwin32 support
+       Requested by: Sven Dietrich <Sven_Dietrich@Trimble.COM>
+
+       * configure.in: gdt-surveying code is gone.  Sigh.
+       Reported by: Poul-Henning Kamp <phk@critter.freebsd.dk>
+
+Wed Mar  4 21:41:06 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * many places: Renamed ATOM to CLOCK_ATOM
+
+Tue Mar  3 03:18:13 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_timer.c (timer): Only call refclock_transmit if
+       REFCLOCK is #define'd.
+       Reported by a bunch of folks.
+
+Mon Mar  2 03:46:07 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ntp_refclock): Use CLOCK_CHU, which no longer
+       needs any special headers.
+       * ntpd/refclock_chu.c: Call it CLOCK_CHU
+       (chu_receive): Define it correctly.
+
+       * include/winnt/sys/time.h (gettimeofday): Prototypes are OK.
+       (settimeofday): Prototypes are OK.
+       From: JJEVNISEK@qgraph.com
+
+       * ntpq/ntpq_ops.c: varlist name and value aren't const.
+       * ntpdc/ntpdc_ops.c (fudge): The flags are u_val, not val.
+       * ntpdc/ntpdc.c: const cleanup, exit cleanup.
+       * ntpd/refclock_wwvb.c (wwvb_receive): Move the definition of tz
+       somewhere more normal.
+       * ntpd/ntp_request.c (do_trustkey): kp gets u_long data, not
+       u_int32 (but Harlan thinks this patch may be wrong).
+       * ntpd/ntp_refclock.c (refclock_process): clocktime needs
+       offset.l_ui, not offset.l_i .
+       * ntpd/ntp_control.c (set_var): t isn't const.
+       * libntp/a_md5encrypt.c (session_key): Cast 2nd arg to MD5auth_setkey.
+       * include/ntpd.h: ctl_var's text field isn't const.
+       * include/ntp_refclock.h: clockdesc isn't const.
+       From: Marc Brett <Marc.Brett@waii.com>
+
+       * ntpd/ntp_loopfilter.c (local_clock): Limit ntv.constant to
+       MAXTC, and log error returns from ntp_adjtime.
+       From: Juha Sarlin <juha@c3l.tyreso.se>
+
+Mon Mar  2 03:05:23 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (ac_cv_var_kernel_fll_bug): KERNEL_FLL_BUG
+       * acconfig.h: KERNEL_FLL_BUG: added.
+       * ntpd/ntp_loopfilter.c (local_clock): Only avoid STA_FLL if
+       KERNEL_FLL_BUG is #define'd (Solaris2.6)
+
+Sat Feb 21 00:45:10 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * automake-1.2d.patches: Added ansi2knr.o rules.
+
+       * ntpd/refclock_tpro.c: P() stuff
+
+Fri Feb 20 20:10:20 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in: Improve the ${CC} -pipe test (cygwin-32's gcc -pipe
+       silently does nothing).
+       Reported by: Sven Dietrich <Sven_Dietrich@Trimble.COM>
+
+Wed Feb 18 00:51:08 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+* configure.in: 4.0.72 released.
+
+* configure.in:AC_REPLACE_FUNCS(strerror), check for poll.h, and deal
+  with the --enable-JUPITER stuff.
+* libntp/Makefile.am (libntp_a_LIBADD): Added (for strerror support).
+* libntp/clocktypes.c: Added REFCLK_GPS_JUPITER.
+* ntpdate/ntpdate.c: poll() support
+* ntpd/Makefile.am: Add refclock_jupiter.c
+* ntpd/refclock_conf.c: Added refclock_jupiter
+* ntpd/refclock_mx4200.c (mx4200_pps): Bugfixes.
+* include/ntp.h (REFCLK_GPS_JUPITER): Added, and bumped REFCLK_MAX.
+  From: Craig Leres <leres@ee.lbl.gov>
+
+Mon Feb 16 21:02:42 1998  Harlan Stenn  <stenn@grundoon.udel.edu>
+
+       * ntpd/ntp_proto.c: P()
+
+Mon Feb 16 12:43:11 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+* include/ntp_types.h: Added P() prototyping hack back in.
+* include/parse.h: Ditto.
+* include/ntpd.h:  Ditto.
+* include/ntp_unixtime.h:  Ditto.
+* include/ntp_stdlib.h: Ditto.
+* include/ntp_select.h: Ditto.
+* include/ntp_refclock.h: Ditto.
+* include/ntp_fp.h: Ditto.
+* include/md5.h: Ditto.
+* include/ntp_filegen.h: Ditto.
+* include/ntp_calendar.h: Ditto.
+* include/l_stdlib.h: Ditto.
+
+       * configure.in (ACTS): Sometimes, TIOCMBIS is in sys/ioctl.h
+         Reported by Kenneth Jaldehag <kenneth.jaldehag@sp.se>
+       * configure.in (HEATH): Ditto.
+       * configure.in (PTBACTS): Ditto.
+       * configure.in (USNO): Ditto.
+
+Sat Feb 14 00:02:14 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_irig.c (irig_rf): Rename sincos[] to sin_cos[].
+
+Fri Feb 13 22:22:08 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * include/ntp.h (RANDPOLL): Use random or mrand48.
+       * ntpd/ntp_config.c (do_resolve_internal): Ditto.
+       * ntpd/ntp_peer.c (unpeer): Ditto.
+       * ntpd/ntp_proto.c (make_keylist): Ditto.
+
+       * ntpd/ntpd.c (xntpdmain): Use srandom or srand48.
+
+       * configure.in: Look for {s,}random() and [ms]rand48().
+
+Wed Feb 11 22:50:24 1998  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/ntp_restrict.c (hack_restrict): Renamed restrict()
+       * include/ntpd.h: Ditto
+       * ntpd/ntp_request.c (do_restrict): Ditto
+       * ntpd/ntp_config.c (getconfig):
+       * ntpd/ntp_io.c (create_sockets): Ditto.
+
+1998-01-23  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_irig.c: Allow either <sun/audioio.h> or
+       <sys/audioio.h> .  From Dave Mills.
+
+       * configure.in: Under SunOS, it's sun/audioio.h .
+
+1998-01-22  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * html/driver6.html: Updated header file info
+       * html/irig.html: Ditto.
+       * configure.in: sys/bsd_audioirig.h replaced with sys/audioio.h
+       for new irig driver that Dave installed.
+
+1998-01-08  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * Many places: Lose the P(()) prototype stuff
+
+       * util/tickadj.c (writevar): Make offset an off_t
+       (readvar): Ditto
+       (getoffsets): Make offsets off_t
+
+       * adjtimed/adjtimed.c (GetClockRate): Fix lseek arg 2.
+       (SetClockRate): Ditto
+
+       * Many things in many places from many people.
+
+       * configure.in: Added AC_TYPE_OFF_T
+
+1997-11-26  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * ntpd/refclock_palisade.c: ANSIfied.
+
+Wed Sep  3 23:51:44 1997  Harlan Stenn  <stenn@whimsy.udel.edu>
+
+       * configure.in (AM_C_PROTOTYPES): Added.
+
+       * Makefile.am (AUTOMAKE_OPTIONS): Added ansi2knr.
+
diff --git a/ElectricFence/CHANGES b/ElectricFence/CHANGES
new file mode 100644 (file)
index 0000000..454aff6
--- /dev/null
@@ -0,0 +1,23 @@
+2.0.1
+       Add work-arounds for kernel and library bugs under HP-UX.       
+       HP has been notified and will repair these soon.
+
+2.0.2
+       Add support for DEC Alpha. Add %a pattern for printing addresses, which
+       assumes they are passed in a void *.
+
+2.0.3 30-Sep-1993
+       When realloc is passed a zero address, it should work the same
+       way as malloc(). Fix forward declaration of mprotect() in page.c to
+       use void *, not caddr_t, for addresses. IRIX 5.0.1 complained about that.
+
+2.0.4 29-May-1994
+       Don't attempt to allow access to a zero-sized page when
+       EF_ALLOW_MALLOC_0 is set. Attempt to un-map memory from
+       Page_Delete(). If that doesn't work, fall back by protecting the
+       page from all references. Un-mapping small segments of a mapping
+       used to crash my SGI IRIX 5.0 system. I assume that nobody is running
+       5.0 any longer.
+
+2.0.5 20-January-1995
+       Port to Linux.
diff --git a/ElectricFence/COPYING b/ElectricFence/COPYING
new file mode 100644 (file)
index 0000000..a43ea21
--- /dev/null
@@ -0,0 +1,339 @@
+                   GNU GENERAL PUBLIC LICENSE
+                      Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+                          675 Mass Ave, Cambridge, MA 02139, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+\f
+                   GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+\f
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+\f
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+\f
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+                           NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+\f
+       Appendix: How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) 19yy  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) 19yy name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/ElectricFence/Makefile.am b/ElectricFence/Makefile.am
new file mode 100644 (file)
index 0000000..df97338
--- /dev/null
@@ -0,0 +1,31 @@
+# Harlan Stenn <stenn@whimsy.udel.edu>
+# Converted the original Makefile (now in Makefile-) to Makefile.am
+# in July of '00
+
+EXTRA_DIST = libefence.3 CHANGES
+libefence_a_SOURCES = efence.h efence.c page.c print.c
+check_PROGRAMS = @EF_PROGS@
+EXTRA_PROGRAMS = eftest tstheap
+# TESTS = eftest tstheap
+noinst_LIBRARIES = @EF_LIBS@
+EXTRA_LIBRARIES = libefence.a
+LDADD = libefence.a
+
+# Un-comment the following if you are running HP/UX.
+# CFLAGS= -Aa -g -D_HPUX_SOURCE -DPAGE_PROTECTION_VIOLATED_SIGNAL=SIGBUS
+
+# Un-comment the following if you are running AIX. This makes sure you won't
+# get the shared-library malloc() rather than the Electric Fence malloc().
+# COMPILE THE PROGRAMS YOU ARE DEBUGGING WITH THESE FLAGS, TOO.
+# CFLAGS= -g -bnso -bnodelcsect -bI:/lib/syscalls.exp
+
+# Un-comment the following if you are running SunOS 4.X
+# Note the definition of PAGE_PROTECTION_VIOLATED_SIGNAL. This may vary
+# depend on what version of Sun hardware you have.
+# You'll probably have to link the program you are debugging with -Bstatic
+# as well if using Sun's compiler, -static if using GCC.
+# CFLAGS= -g -Bstatic -DPAGE_PROTECTION_VIOLATED_SIGNAL=SIGBUS
+
+check-local:
+       test ! -f eftest  || ./eftest
+       test ! -f tstheap || ./tstheap 3072
diff --git a/ElectricFence/Makefile.in b/ElectricFence/Makefile.in
new file mode 100644 (file)
index 0000000..4617865
--- /dev/null
@@ -0,0 +1,549 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Harlan Stenn <stenn@whimsy.udel.edu>
+# Converted the original Makefile (now in Makefile-) to Makefile.am
+# in July of '00
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+EXTRA_PROGRAMS = eftest$(EXEEXT) tstheap$(EXEEXT)
+subdir = ElectricFence
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       COPYING
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libefence_a_AR = $(AR) $(ARFLAGS)
+libefence_a_LIBADD =
+am_libefence_a_OBJECTS = efence.$(OBJEXT) page.$(OBJEXT) \
+       print.$(OBJEXT)
+libefence_a_OBJECTS = $(am_libefence_a_OBJECTS)
+eftest_SOURCES = eftest.c
+eftest_OBJECTS = eftest.$(OBJEXT)
+eftest_LDADD = $(LDADD)
+eftest_DEPENDENCIES = libefence.a
+tstheap_SOURCES = tstheap.c
+tstheap_OBJECTS = tstheap.$(OBJEXT)
+tstheap_LDADD = $(LDADD)
+tstheap_DEPENDENCIES = libefence.a
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(libefence_a_SOURCES) eftest.c tstheap.c
+DIST_SOURCES = $(libefence_a_SOURCES) eftest.c tstheap.c
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+EXTRA_DIST = libefence.3 CHANGES
+libefence_a_SOURCES = efence.h efence.c page.c print.c
+check_PROGRAMS = @EF_PROGS@
+# TESTS = eftest tstheap
+noinst_LIBRARIES = @EF_LIBS@
+EXTRA_LIBRARIES = libefence.a
+LDADD = libefence.a
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ElectricFence/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign ElectricFence/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+       -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libefence.a: $(libefence_a_OBJECTS) $(libefence_a_DEPENDENCIES) 
+       -rm -f libefence.a
+       $(libefence_a_AR) libefence.a $(libefence_a_OBJECTS) $(libefence_a_LIBADD)
+       $(RANLIB) libefence.a
+
+clean-checkPROGRAMS:
+       @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+eftest$(EXEEXT): $(eftest_OBJECTS) $(eftest_DEPENDENCIES) 
+       @rm -f eftest$(EXEEXT)
+       $(LINK) $(eftest_OBJECTS) $(eftest_LDADD) $(LIBS)
+tstheap$(EXEEXT): $(tstheap_OBJECTS) $(tstheap_DEPENDENCIES) 
+       @rm -f tstheap$(EXEEXT)
+       $(LINK) $(tstheap_OBJECTS) $(tstheap_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/efence.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/eftest.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/page.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/print.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tstheap.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+       $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+       $(MAKE) $(AM_MAKEFLAGS) check-local
+check: check-am
+all-am: Makefile $(LIBRARIES)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-checkPROGRAMS clean-generic clean-libtool \
+       clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am check-local clean \
+       clean-checkPROGRAMS 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-libtool pdf pdf-am ps ps-am \
+       tags uninstall uninstall-am
+
+
+# Un-comment the following if you are running HP/UX.
+# CFLAGS= -Aa -g -D_HPUX_SOURCE -DPAGE_PROTECTION_VIOLATED_SIGNAL=SIGBUS
+
+# Un-comment the following if you are running AIX. This makes sure you won't
+# get the shared-library malloc() rather than the Electric Fence malloc().
+# COMPILE THE PROGRAMS YOU ARE DEBUGGING WITH THESE FLAGS, TOO.
+# CFLAGS= -g -bnso -bnodelcsect -bI:/lib/syscalls.exp
+
+# Un-comment the following if you are running SunOS 4.X
+# Note the definition of PAGE_PROTECTION_VIOLATED_SIGNAL. This may vary
+# depend on what version of Sun hardware you have.
+# You'll probably have to link the program you are debugging with -Bstatic
+# as well if using Sun's compiler, -static if using GCC.
+# CFLAGS= -g -Bstatic -DPAGE_PROTECTION_VIOLATED_SIGNAL=SIGBUS
+
+check-local:
+       test ! -f eftest  || ./eftest
+       test ! -f tstheap || ./tstheap 3072
+
+# 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.
+.NOEXPORT:
diff --git a/ElectricFence/README b/ElectricFence/README
new file mode 100644 (file)
index 0000000..8223850
--- /dev/null
@@ -0,0 +1,46 @@
+This is Electric Fence 2.0.5
+
+Electric Fence is a different kind of malloc() debugger. It uses the virtual
+memory hardware of your system to detect when software overruns the boundaries
+of a malloc() buffer. It will also detect any accesses of memory that has
+been released by free(). Because it uses the VM hardware for detection,
+Electric Fence stops your program on the first instruction that causes
+a bounds violation. It's then trivial to use a debugger to display the
+offending statement.
+
+This version will run on:
+       Linux kernel version 1.1.83 and above. Earlier kernels have problems
+       with the memory protection implementation.
+
+       All System V Revision 4 platforms (and possibly earlier revisions)
+       including:
+               Every 386 System V I've heard of.
+               Solaris 2.x
+               SGI IRIX 5.0 (but not 4.x)
+
+       IBM AIX on the RS/6000.
+
+       SunOS 4.X (using an ANSI C compiler and probably static linking).
+
+       HP/UX 9.01, and possibly earlier versions.
+
+       OSF 1.3 (and possibly earlier versions) on a DECalpha.
+
+On some of these platforms, you'll have to uncomment lines in the Makefile
+that apply to your particular system.
+
+If you test Electric Fence on a platform not mentioned here, please send me a
+report.
+
+It will probably port to any ANSI/POSIX system that provides mmap(), and
+mprotect(), as long as mprotect() has the capability to turn off all access
+to a memory page, and mmap() can use /dev/zero or the MAP_ANONYMOUS flag
+to create virtual memory pages.
+
+Complete information on the use of Electric Fence is in the manual page
+libefence.3 .
+
+       Thanks
+
+       Bruce Perens
+       Bruce@Pixar.com
diff --git a/ElectricFence/efence.c b/ElectricFence/efence.c
new file mode 100644 (file)
index 0000000..f797e75
--- /dev/null
@@ -0,0 +1,786 @@
+/*
+ * Electric Fence - Red-Zone memory allocator.
+ * Bruce Perens, 1988, 1993
+ * 
+ * This is a special version of malloc() and company for debugging software
+ * that is suspected of overrunning or underrunning the boundaries of a
+ * malloc buffer, or touching free memory.
+ *
+ * It arranges for each malloc buffer to be followed (or preceded)
+ * in the address space by an inaccessable virtual memory page,
+ * and for free memory to be inaccessable. If software touches the
+ * inaccessable page, it will get an immediate segmentation
+ * fault. It is then trivial to uncover the offending code using a debugger.
+ *
+ * An advantage of this product over most malloc debuggers is that this one
+ * detects reading out of bounds as well as writing, and this one stops on
+ * the exact instruction that causes the error, rather than waiting until the
+ * next boundary check.
+ *
+ * There is one product that debugs malloc buffer overruns
+ * better than Electric Fence: "Purify" from Purify Systems, and that's only
+ * a small part of what Purify does. I'm not affiliated with Purify, I just
+ * respect a job well done.
+ *
+ * This version of malloc() should not be linked into production software,
+ * since it tremendously increases the time and memory overhead of malloc().
+ * Each malloc buffer will consume a minimum of two virtual memory pages,
+ * this is 16 kilobytes on many systems. On some systems it will be necessary
+ * to increase the amount of swap space in order to debug large programs that
+ * perform lots of allocation, because of the per-buffer overhead.
+ */
+#include "efence.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <memory.h>
+#include <string.h>
+
+#ifdef malloc
+#undef malloc
+#endif
+
+#ifdef calloc
+#undef calloc
+#endif
+
+static const char      version[] = "\n  Electric Fence 2.0.5"
+ " Copyright (C) 1987-1995 Bruce Perens.\n";
+
+/*
+ * MEMORY_CREATION_SIZE is the amount of memory to get from the operating
+ * system at one time. We'll break that memory down into smaller pieces for
+ * malloc buffers. One megabyte is probably a good value.
+ */
+#define                        MEMORY_CREATION_SIZE    1024 * 1024
+
+/*
+ * Enum Mode indicates the status of a malloc buffer.
+ */
+enum _Mode {
+       NOT_IN_USE = 0, /* Available to represent a malloc buffer. */
+       FREE,           /* A free buffer. */
+       ALLOCATED,      /* A buffer that is in use. */
+       PROTECTED,      /* A freed buffer that can not be allocated again. */
+       INTERNAL_USE    /* A buffer used internally by malloc(). */
+};
+typedef enum _Mode     Mode;
+
+/*
+ * Struct Slot contains all of the information about a malloc buffer except
+ * for the contents of its memory.
+ */
+struct _Slot {
+       void *          userAddress;
+       void *          internalAddress;
+       size_t          userSize;
+       size_t          internalSize;
+       Mode            mode;
+};
+typedef struct _Slot   Slot;
+
+/*
+ * EF_ALIGNMENT is a global variable used to control the default alignment
+ * of buffers returned by malloc(), calloc(), and realloc(). It is all-caps
+ * so that its name matches the name of the environment variable that is used
+ * to set it. This gives the programmer one less name to remember.
+ * If the value is -1, it will be set from the environment or sizeof(int)
+ * at run time.
+ */
+int            EF_ALIGNMENT = -1;
+
+/*
+ * EF_PROTECT_FREE is a global variable used to control the disposition of
+ * memory that is released using free(). It is all-caps so that its name
+ * matches the name of the environment variable that is used to set it.
+ * If its value is greater non-zero, memory released by free is made
+ * inaccessable and never allocated again. Any software that touches free
+ * memory will then get a segmentation fault. If its value is zero, freed
+ * memory will be available for reallocation, but will still be inaccessable
+ * until it is reallocated.
+ * If the value is -1, it will be set from the environment or to 0 at run-time.
+ */
+int            EF_PROTECT_FREE = -1;
+
+/*
+ * EF_PROTECT_BELOW is used to modify the behavior of the allocator. When
+ * its value is non-zero, the allocator will place an inaccessable page
+ * immediately _before_ the malloc buffer in the address space, instead
+ * of _after_ it. Use this to detect malloc buffer under-runs, rather than
+ * over-runs. It won't detect both at the same time, so you should test your
+ * software twice, once with this value clear, and once with it set.
+ * If the value is -1, it will be set from the environment or to zero at
+ * run-time
+ */
+int            EF_PROTECT_BELOW = -1;
+
+/*
+ * EF_ALLOW_MALLOC_0 is set if Electric Fence is to allow malloc(0). I
+ * trap malloc(0) by default because it is a common source of bugs.
+ */
+int            EF_ALLOW_MALLOC_0 = -1;
+
+/*
+ * allocationList points to the array of slot structures used to manage the
+ * malloc arena.
+ */
+static Slot *          allocationList = 0;
+
+/*
+ * allocationListSize is the size of the allocation list. This will always
+ * be a multiple of the page size.
+ */
+static size_t          allocationListSize = 0;
+
+/*
+ * slotCount is the number of Slot structures in allocationList.
+ */
+static size_t          slotCount = 0;
+
+/*
+ * unUsedSlots is the number of Slot structures that are currently available
+ * to represent new malloc buffers. When this number gets too low, we will
+ * create new slots.
+ */
+static size_t          unUsedSlots = 0;
+
+/*
+ * slotsPerPage is the number of slot structures that fit in a virtual
+ * memory page.
+ */
+static size_t          slotsPerPage = 0;
+
+/*
+ * internalUse is set when allocating and freeing the allocatior-internal
+ * data structures.
+ */
+static int             internalUse = 0;
+
+/*
+ * noAllocationListProtection is set to tell malloc() and free() not to
+ * manipulate the protection of the allocation list. This is only set in
+ * realloc(), which does it to save on slow system calls, and in
+ * allocateMoreSlots(), which does it because it changes the allocation list.
+ */
+static int             noAllocationListProtection = 0;
+
+/*
+ * bytesPerPage is set at run-time to the number of bytes per virtual-memory
+ * page, as returned by Page_Size().
+ */
+static size_t          bytesPerPage = 0;
+
+/*
+ * internalError is called for those "shouldn't happen" errors in the
+ * allocator.
+ */
+static void
+internalError(void)
+{
+       EF_Abort("Internal error in allocator.");
+}
+
+/*
+ * initialize sets up the memory allocation arena and the run-time
+ * configuration information.
+ */
+static void
+initialize(void)
+{
+       size_t  size = MEMORY_CREATION_SIZE;
+       size_t  slack;
+       char *  string;
+       Slot *  slot;
+
+       EF_Print(version);
+
+       /*
+        * Import the user's environment specification of the default
+        * alignment for malloc(). We want that alignment to be under
+        * user control, since smaller alignment lets us catch more bugs,
+        * however some software will break if malloc() returns a buffer
+        * that is not word-aligned.
+        *
+        * I would like
+        * alignment to be zero so that we could catch all one-byte
+        * overruns, however if malloc() is asked to allocate an odd-size
+        * buffer and returns an address that is not word-aligned, or whose
+        * size is not a multiple of the word size, software breaks.
+        * This was the case with the Sun string-handling routines,
+        * which can do word fetches up to three bytes beyond the end of a
+        * string. I handle this problem in part by providing
+        * byte-reference-only versions of the string library functions, but
+        * there are other functions that break, too. Some in X Windows, one
+        * in Sam Leffler's TIFF library, and doubtless many others.
+        */
+       if ( EF_ALIGNMENT == -1 ) {
+               if ( (string = getenv("EF_ALIGNMENT")) != 0 )
+                       EF_ALIGNMENT = (size_t)atoi(string);
+               else
+                       EF_ALIGNMENT = sizeof(int);
+       }
+
+       /*
+        * See if the user wants to protect the address space below a buffer,
+        * rather than that above a buffer.
+        */
+       if ( EF_PROTECT_BELOW == -1 ) {
+               if ( (string = getenv("EF_PROTECT_BELOW")) != 0 )
+                       EF_PROTECT_BELOW = (atoi(string) != 0);
+               else
+                       EF_PROTECT_BELOW = 0;
+       }
+
+       /*
+        * See if the user wants to protect memory that has been freed until
+        * the program exits, rather than until it is re-allocated.
+        */
+       if ( EF_PROTECT_FREE == -1 ) {
+               if ( (string = getenv("EF_PROTECT_FREE")) != 0 )
+                       EF_PROTECT_FREE = (atoi(string) != 0);
+               else
+                       EF_PROTECT_FREE = 0;
+       }
+
+       /*
+        * See if the user wants to allow malloc(0).
+        */
+       if ( EF_ALLOW_MALLOC_0 == -1 ) {
+               if ( (string = getenv("EF_ALLOW_MALLOC_0")) != 0 )
+                       EF_ALLOW_MALLOC_0 = (atoi(string) != 0);
+               else
+                       EF_ALLOW_MALLOC_0 = 0;
+       }
+
+       /*
+        * Get the run-time configuration of the virtual memory page size.
+        */
+       bytesPerPage = Page_Size();
+
+       /*
+        * Figure out how many Slot structures to allocate at one time.
+        */
+       slotCount = slotsPerPage = bytesPerPage / sizeof(Slot);
+       allocationListSize = bytesPerPage;
+
+       if ( allocationListSize > size )
+               size = allocationListSize;
+
+       if ( (slack = size % bytesPerPage) != 0 )
+               size += bytesPerPage - slack;
+
+       /*
+        * Allocate memory, and break it up into two malloc buffers. The
+        * first buffer will be used for Slot structures, the second will
+        * be marked free.
+        */
+       slot = allocationList = (Slot *)Page_Create(size);
+       memset((char *)allocationList, 0, allocationListSize);
+
+       slot[0].internalSize = slot[0].userSize = allocationListSize;
+       slot[0].internalAddress = slot[0].userAddress = allocationList;
+       slot[0].mode = INTERNAL_USE;
+       if ( size > allocationListSize ) {
+               slot[1].internalAddress = slot[1].userAddress
+                = ((char *)slot[0].internalAddress) + slot[0].internalSize;
+               slot[1].internalSize
+                = slot[1].userSize = size - slot[0].internalSize;
+               slot[1].mode = FREE;
+       }
+
+       /*
+        * Deny access to the free page, so that we will detect any software
+        * that treads upon free memory.
+        */
+       Page_DenyAccess(slot[1].internalAddress, slot[1].internalSize);
+
+       /*
+        * Account for the two slot structures that we've used.
+        */
+       unUsedSlots = slotCount - 2;
+}
+
+/*
+ * allocateMoreSlots is called when there are only enough slot structures
+ * left to support the allocation of a single malloc buffer.
+ */
+static void
+allocateMoreSlots(void)
+{
+       size_t  newSize = allocationListSize + bytesPerPage;
+       void *  newAllocation;
+       void *  oldAllocation = allocationList;
+
+       Page_AllowAccess(allocationList, allocationListSize);
+       noAllocationListProtection = 1;
+       internalUse = 1;
+
+       newAllocation = malloc(newSize);
+       memcpy(newAllocation, allocationList, allocationListSize);
+       memset(&(((char *)newAllocation)[allocationListSize]), 0, bytesPerPage);
+
+       allocationList = (Slot *)newAllocation;
+       allocationListSize = newSize;
+       slotCount += slotsPerPage;
+       unUsedSlots += slotsPerPage;
+
+       free(oldAllocation);
+
+       /*
+        * Keep access to the allocation list open at this point, because
+        * I am returning to memalign(), which needs that access.
+        */
+       noAllocationListProtection = 0;
+       internalUse = 0;
+}
+
+/*
+ * This is the memory allocator. When asked to allocate a buffer, allocate
+ * it in such a way that the end of the buffer is followed by an inaccessable
+ * memory page. If software overruns that buffer, it will touch the bad page
+ * and get an immediate segmentation fault. It's then easy to zero in on the
+ * offending code with a debugger.
+ *
+ * There are a few complications. If the user asks for an odd-sized buffer,
+ * we would have to have that buffer start on an odd address if the byte after
+ * the end of the buffer was to be on the inaccessable page. Unfortunately,
+ * there is lots of software that asks for odd-sized buffers and then
+ * requires that the returned address be word-aligned, or the size of the
+ * buffer be a multiple of the word size. An example are the string-processing
+ * functions on Sun systems, which do word references to the string memory
+ * and may refer to memory up to three bytes beyond the end of the string.
+ * For this reason, I take the alignment requests to memalign() and valloc()
+ * seriously, and 
+ * 
+ * Electric Fence wastes lots of memory. I do a best-fit allocator here
+ * so that it won't waste even more. It's slow, but thrashing because your
+ * working set is too big for a system's RAM is even slower. 
+ */
+extern C_LINKAGE void *
+memalign(size_t alignment, size_t userSize)
+{
+       register Slot * slot;
+       register size_t count;
+       Slot *          fullSlot = 0;
+       Slot *          emptySlots[2];
+       size_t          internalSize;
+       size_t          slack;
+       char *          address;
+
+       if ( allocationList == 0 )
+               initialize();
+
+       if ( userSize == 0 && !EF_ALLOW_MALLOC_0 )
+               EF_Abort("Allocating 0 bytes, probably a bug.");
+
+       /*
+        * If EF_PROTECT_BELOW is set, all addresses returned by malloc()
+        * and company will be page-aligned.
+        */
+       if ( !EF_PROTECT_BELOW && alignment > 1 ) {
+               if ( (slack = userSize % alignment) != 0 )
+                       userSize += alignment - slack;
+       }
+
+       /*
+        * The internal size of the buffer is rounded up to the next page-size
+        * boudary, and then we add another page's worth of memory for the
+        * dead page.
+        */
+       internalSize = userSize + bytesPerPage;
+       if ( (slack = internalSize % bytesPerPage) != 0 )
+               internalSize += bytesPerPage - slack;
+
+       /*
+        * These will hold the addresses of two empty Slot structures, that
+        * can be used to hold information for any memory I create, and any
+        * memory that I mark free.
+        */
+       emptySlots[0] = 0;
+       emptySlots[1] = 0;
+
+       /*
+        * The internal memory used by the allocator is currently
+        * inaccessable, so that errant programs won't scrawl on the
+        * allocator's arena. I'll un-protect it here so that I can make
+        * a new allocation. I'll re-protect it before I return.
+        */
+       if ( !noAllocationListProtection )
+               Page_AllowAccess(allocationList, allocationListSize);
+
+       /*
+        * If I'm running out of empty slots, create some more before
+        * I don't have enough slots left to make an allocation.
+        */
+       if ( !internalUse && unUsedSlots < 7 ) {
+               allocateMoreSlots();
+       }
+       
+       /*
+        * Iterate through all of the slot structures. Attempt to find a slot
+        * containing free memory of the exact right size. Accept a slot with
+        * more memory than we want, if the exact right size is not available.
+        * Find two slot structures that are not in use. We will need one if
+        * we split a buffer into free and allocated parts, and the second if
+        * we have to create new memory and mark it as free.
+        *
+        */
+       
+       for ( slot = allocationList, count = slotCount ; count > 0; count-- ) {
+               if ( slot->mode == FREE
+                && slot->internalSize >= internalSize ) {
+                       if ( !fullSlot
+                        ||slot->internalSize < fullSlot->internalSize){
+                               fullSlot = slot;
+                               if ( slot->internalSize == internalSize
+                                && emptySlots[0] )
+                                       break;  /* All done, */
+                       }
+               }
+               else if ( slot->mode == NOT_IN_USE ) {
+                       if ( !emptySlots[0] )
+                               emptySlots[0] = slot;
+                       else if ( !emptySlots[1] )
+                               emptySlots[1] = slot;
+                       else if ( fullSlot
+                        && fullSlot->internalSize == internalSize )
+                               break;  /* All done. */
+               }
+               slot++;
+       }
+       if ( !emptySlots[0] )
+               internalError();
+
+       if ( !fullSlot ) {
+               /*
+                * I get here if I haven't been able to find a free buffer
+                * with all of the memory I need. I'll have to create more
+                * memory. I'll mark it all as free, and then split it into
+                * free and allocated portions later.
+                */
+               size_t  chunkSize = MEMORY_CREATION_SIZE;
+
+               if ( !emptySlots[1] )
+                       internalError();
+
+               if ( chunkSize < internalSize )
+                       chunkSize = internalSize;
+
+               if ( (slack = chunkSize % bytesPerPage) != 0 )
+                       chunkSize += bytesPerPage - slack;
+
+               /* Use up one of the empty slots to make the full slot. */
+               fullSlot = emptySlots[0];
+               emptySlots[0] = emptySlots[1];
+               fullSlot->internalAddress = Page_Create(chunkSize);
+               fullSlot->internalSize = chunkSize;
+               fullSlot->mode = FREE;
+               unUsedSlots--;
+       }
+
+       /*
+        * If I'm allocating memory for the allocator's own data structures,
+        * mark it INTERNAL_USE so that no errant software will be able to
+        * free it.
+        */
+       if ( internalUse )
+               fullSlot->mode = INTERNAL_USE;
+       else
+               fullSlot->mode = ALLOCATED;
+
+       /*
+        * If the buffer I've found is larger than I need, split it into
+        * an allocated buffer with the exact amount of memory I need, and
+        * a free buffer containing the surplus memory.
+        */
+       if ( fullSlot->internalSize > internalSize ) {
+               emptySlots[0]->internalSize
+                = fullSlot->internalSize - internalSize;
+               emptySlots[0]->internalAddress
+                = ((char *)fullSlot->internalAddress) + internalSize;
+               emptySlots[0]->mode = FREE;
+               fullSlot->internalSize = internalSize;
+               unUsedSlots--;
+       }
+
+       if ( !EF_PROTECT_BELOW ) {
+               /*
+                * Arrange the buffer so that it is followed by an inaccessable
+                * memory page. A buffer overrun that touches that page will
+                * cause a segmentation fault.
+                */
+               address = (char *)fullSlot->internalAddress;
+
+               /* Set up the "live" page. */
+               if ( internalSize - bytesPerPage > 0 )
+                               Page_AllowAccess(
+                                fullSlot->internalAddress
+                               ,internalSize - bytesPerPage);
+                       
+               address += internalSize - bytesPerPage;
+
+               /* Set up the "dead" page. */
+               if ( EF_PROTECT_FREE )
+                       Page_Delete(address, bytesPerPage);
+               else
+                       Page_DenyAccess(address, bytesPerPage);
+
+               /* Figure out what address to give the user. */
+               address -= userSize;
+       }
+       else {  /* EF_PROTECT_BELOW != 0 */
+               /*
+                * Arrange the buffer so that it is preceded by an inaccessable
+                * memory page. A buffer underrun that touches that page will
+                * cause a segmentation fault.
+                */
+               address = (char *)fullSlot->internalAddress;
+
+               /* Set up the "dead" page. */
+               if ( EF_PROTECT_FREE )
+                       Page_Delete(address, bytesPerPage);
+               else
+                       Page_DenyAccess(address, bytesPerPage);
+                       
+               address += bytesPerPage;
+
+               /* Set up the "live" page. */
+               if ( internalSize - bytesPerPage > 0 )
+                       Page_AllowAccess(address, internalSize - bytesPerPage);
+       }
+
+       fullSlot->userAddress = address;
+       fullSlot->userSize = userSize;
+
+       /*
+        * Make the pool's internal memory inaccessable, so that the program
+        * being debugged can't stomp on it.
+        */
+       if ( !internalUse )
+               Page_DenyAccess(allocationList, allocationListSize);
+
+       return address;
+}
+
+/*
+ * Find the slot structure for a user address.
+ */
+static Slot *
+slotForUserAddress(void * address)
+{
+       register Slot * slot = allocationList;
+       register size_t count = slotCount;
+       
+       for ( ; count > 0; count-- ) {
+               if ( slot->userAddress == address )
+                       return slot;
+               slot++;
+       }
+
+       return 0;
+}
+
+/*
+ * Find the slot structure for an internal address.
+ */
+static Slot *
+slotForInternalAddress(void * address)
+{
+       register Slot * slot = allocationList;
+       register size_t count = slotCount;
+       
+       for ( ; count > 0; count-- ) {
+               if ( slot->internalAddress == address )
+                       return slot;
+               slot++;
+       }
+       return 0;
+}
+
+/*
+ * Given the internal address of a buffer, find the buffer immediately
+ * before that buffer in the address space. This is used by free() to
+ * coalesce two free buffers into one.
+ */
+static Slot *
+slotForInternalAddressPreviousTo(void * address)
+{
+       register Slot * slot = allocationList;
+       register size_t count = slotCount;
+       
+       for ( ; count > 0; count-- ) {
+               if ( ((char *)slot->internalAddress)
+                + slot->internalSize == address )
+                       return slot;
+               slot++;
+       }
+       return 0;
+}
+
+extern C_LINKAGE void
+free(void * address)
+{
+       Slot *  slot;
+       Slot *  previousSlot = 0;
+       Slot *  nextSlot = 0;
+
+       if ( address == 0 )
+               return;
+
+       if ( allocationList == 0 )
+               EF_Abort("free() called before first malloc().");
+
+       if ( !noAllocationListProtection )
+               Page_AllowAccess(allocationList, allocationListSize);
+
+       slot = slotForUserAddress(address);
+
+       if ( !slot )
+               EF_Abort("free(%a): address not from malloc().", address);
+
+       if ( slot->mode != ALLOCATED ) {
+               if ( internalUse && slot->mode == INTERNAL_USE )
+                       /* Do nothing. */;
+               else {
+                       EF_Abort(
+                        "free(%a): freeing free memory."
+                       ,address);
+               }
+       }
+
+       if ( EF_PROTECT_FREE )
+               slot->mode = PROTECTED;
+       else
+               slot->mode = FREE;
+
+       previousSlot = slotForInternalAddressPreviousTo(slot->internalAddress);
+       nextSlot = slotForInternalAddress(
+        ((char *)slot->internalAddress) + slot->internalSize);
+
+       if ( previousSlot
+        && (previousSlot->mode == FREE || previousSlot->mode == PROTECTED) ) {
+               /* Coalesce previous slot with this one. */
+               previousSlot->internalSize += slot->internalSize;
+               if ( EF_PROTECT_FREE )
+                       previousSlot->mode = PROTECTED;
+
+               slot->internalAddress = slot->userAddress = 0;
+               slot->internalSize = slot->userSize = 0;
+               slot->mode = NOT_IN_USE;
+               slot = previousSlot;
+               unUsedSlots++;
+       }
+       if ( nextSlot
+        && (nextSlot->mode == FREE || nextSlot->mode == PROTECTED) ) {
+               /* Coalesce next slot with this one. */
+               slot->internalSize += nextSlot->internalSize;
+               nextSlot->internalAddress = nextSlot->userAddress = 0;
+               nextSlot->internalSize = nextSlot->userSize = 0;
+               nextSlot->mode = NOT_IN_USE;
+               unUsedSlots++;
+       }
+
+       slot->userAddress = slot->internalAddress;
+       slot->userSize = slot->internalSize;
+
+       /*
+        * Free memory is _always_ set to deny access. When EF_PROTECT_FREE
+        * is true, free memory is never reallocated, so it remains access
+        * denied for the life of the process. When EF_PROTECT_FREE is false, 
+        * the memory may be re-allocated, at which time access to it will be
+        * allowed again.
+        *
+        * Some operating systems allow munmap() with single-page resolution,
+        * and allow you to un-map portions of a region, rather than the
+        * entire region that was mapped with mmap(). On those operating
+        * systems, we can release protected free pages with Page_Delete(),
+        * in the hope that the swap space attached to those pages will be
+        * released as well.
+        */
+       if ( EF_PROTECT_FREE )
+           Page_Delete(slot->internalAddress, slot->internalSize);
+       else
+           Page_DenyAccess(slot->internalAddress, slot->internalSize);
+
+       if ( !noAllocationListProtection )
+               Page_DenyAccess(allocationList, allocationListSize);
+}
+
+extern C_LINKAGE void *
+realloc(void * oldBuffer, size_t newSize)
+{
+       void *  newBuffer = malloc(newSize);
+
+       if ( oldBuffer ) {
+               size_t  size;
+               Slot *  slot;
+
+               Page_AllowAccess(allocationList, allocationListSize);
+               noAllocationListProtection = 1;
+               
+               slot = slotForUserAddress(oldBuffer);
+
+               if ( slot == 0 )
+                       EF_Abort(
+                        "realloc(%a, %d): address not from malloc()."
+                       ,oldBuffer
+                       ,newSize);
+
+               if ( newSize < (size = slot->userSize) )
+                       size = newSize;
+
+               if ( size > 0 )
+                       memcpy(newBuffer, oldBuffer, size);
+
+               free(oldBuffer);
+               noAllocationListProtection = 0;
+               Page_DenyAccess(allocationList, allocationListSize);
+
+               if ( size < newSize )
+                       memset(&(((char *)newBuffer)[size]), 0, newSize - size);
+               
+               /* Internal memory was re-protected in free() */
+       }
+
+       return newBuffer;
+}
+
+extern C_LINKAGE void *
+malloc(size_t size)
+{
+       if ( allocationList == 0 )
+               initialize();   /* This sets EF_ALIGNMENT */
+
+       return memalign(EF_ALIGNMENT, size);
+}
+
+extern C_LINKAGE void *
+calloc(size_t nelem, size_t elsize)
+{
+       size_t  size = nelem * elsize;
+       void *  allocation = malloc(size);
+
+       memset(allocation, 0, size);
+       return allocation;
+}
+
+/*
+ * This will catch more bugs if you remove the page alignment, but it
+ * will break some software.
+ */
+extern C_LINKAGE void *
+valloc (size_t size)
+{
+       return memalign(bytesPerPage, size);
+}
+
+#ifdef __hpux
+/*
+ * HP-UX 8/9.01 strcat reads a word past source when doing unaligned copies!
+ * Work around it here. The bug report has been filed with HP.
+ */
+char *strcat(char *d, const char *s)
+{
+       strcpy(d+strlen(d), s);
+       return d;
+}
+#endif
diff --git a/ElectricFence/efence.h b/ElectricFence/efence.h
new file mode 100644 (file)
index 0000000..60eb30f
--- /dev/null
@@ -0,0 +1,42 @@
+#include <sys/types.h>
+#include <sys/param.h>
+
+/*
+ * ef_number is the largest unsigned integer we'll need. On systems that
+ * support 64-bit pointers, this may be "unsigned long long".
+ */
+#if defined(USE_LONG_LONG)
+typedef unsigned long long     ef_number;
+#else
+typedef unsigned long          ef_number;
+#endif
+
+/*
+ * NBBY is the number of bits per byte. Some systems define it in
+ * <sys/param.h> .
+ */
+#ifndef        NBBY
+#define        NBBY    8
+#endif
+
+/*
+ * This is used to declare functions with "C" linkage if we are compiling
+ * with C++ .
+ */
+#ifdef __cplusplus
+#define        C_LINKAGE       "C"
+#else
+#define        C_LINKAGE
+#endif
+
+void                   Page_AllowAccess(void * address, size_t size);
+void *                 Page_Create(size_t size);
+void                   Page_Delete(void * address, size_t size);
+void                   Page_DenyAccess(void * address, size_t size);
+size_t                 Page_Size(void);
+
+void                   EF_Abort(const char * message, ...);
+void                   EF_Exit(const char * message, ...);
+void                   EF_Print(const char * message, ...);
+void                   EF_Lock();
+void                   EF_UnLock();
diff --git a/ElectricFence/eftest.c b/ElectricFence/eftest.c
new file mode 100644 (file)
index 0000000..03489d0
--- /dev/null
@@ -0,0 +1,219 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+#include <setjmp.h>
+#include <signal.h>
+#include "efence.h"
+
+/*
+ * Electric Fence confidence tests.
+ * Make sure all of the various functions of Electric Fence work correctly.
+ */
+
+#ifndef        PAGE_PROTECTION_VIOLATED_SIGNAL
+#define        PAGE_PROTECTION_VIOLATED_SIGNAL SIGSEGV
+#endif
+
+struct diagnostic {
+       int             (*test)(void);
+       int             expectedStatus;
+       const char *    explanation;
+};
+
+extern int     EF_PROTECT_BELOW;
+extern int     EF_ALIGNMENT;
+
+static jmp_buf env;
+
+/*
+ * There is still too little standardization of the arguments and return
+ * type of signal handler functions.
+ */
+static
+void
+segmentationFaultHandler(
+int signalNumber
+#if ( defined(_AIX) )
+, ...
+#endif
+)
+ {
+       signal(PAGE_PROTECTION_VIOLATED_SIGNAL, SIG_DFL);
+       longjmp(env, 1);
+}
+
+static int
+gotSegmentationFault(int (*test)(void))
+{
+       if ( setjmp(env) == 0 ) {
+               int                     status;
+
+               signal(PAGE_PROTECTION_VIOLATED_SIGNAL
+               ,segmentationFaultHandler);
+               status = (*test)();
+               signal(PAGE_PROTECTION_VIOLATED_SIGNAL, SIG_DFL);
+               return status;
+       }
+       else
+               return 1;
+}
+
+static char *  allocation;
+/* c is global so that assignments to it won't be optimized out. */
+char   c;
+
+static int
+testSizes(void)
+{
+       /*
+        * If ef_number can't hold all of the bits of a void *, have the user
+        * add -DUSE_ LONG_LONG to the compiler flags so that ef_number will be
+        * declared as "unsigned long long" instead of "unsigned long".
+        */
+       return ( sizeof(ef_number) < sizeof(void *) );
+}
+
+static int
+allocateMemory(void)
+{
+       allocation = (char *)malloc(1);
+
+       if ( allocation != 0 )
+               return 0;
+       else
+               return 1;
+}
+
+static int
+freeMemory(void)
+{
+       free(allocation);
+       return 0;
+}
+
+static int
+protectBelow(void)
+{
+       EF_PROTECT_BELOW = 1;
+       return 0;
+}
+
+static int
+read0(void)
+{
+       c = *allocation;
+
+       return 0;
+}
+
+static int
+write0(void)
+{
+       *allocation = 1;
+
+       return 0;
+}
+
+static int
+read1(void)
+{
+       c = allocation[1];
+
+       return 0;
+}
+
+static int
+readMinus1(void)
+{
+       c = allocation[-1];
+       return 0;
+}
+
+static struct diagnostic diagnostics[] = {
+       {
+               testSizes, 0,
+               "Please add -DLONG_LONG to the compiler flags and recompile."
+       },
+       {
+               allocateMemory, 0,
+               "Allocation 1: This test allocates a single byte of memory."
+       },
+       {
+               read0, 0,
+               "Read valid memory 1: This test reads the allocated memory."
+       },
+       {
+               write0, 0,
+               "Write valid memory 1: This test writes the allocated memory."
+       },
+       {
+               read1, 1,
+               "Read overrun: This test reads beyond the end of the buffer."
+       },
+       {
+               freeMemory, 0,
+               "Free memory: This test frees the allocated memory."
+       },
+       {
+               protectBelow, 0,
+               "Protect below: This sets Electric Fence to protect\n"
+               "the lower boundary of a malloc buffer, rather than the\n"
+               "upper boundary."
+       },
+       {
+               allocateMemory, 0,
+               "Allocation 2: This allocates memory with the lower boundary"
+               " protected."
+       },
+       {
+               read0, 0,
+               "Read valid memory 2: This test reads the allocated memory."
+       },
+       {
+               write0, 0,
+               "Write valid memory 2: This test writes the allocated memory."
+       },
+       {
+               readMinus1, 1,
+               "Read underrun: This test reads before the beginning of the"
+               " buffer."
+       },
+       {
+               0, 0, 0
+       }
+};
+
+static const char      failedTest[]
+ = "Electric Fence confidence test failed.\n";
+
+static const char      newline = '\n';
+
+int
+main(int argc, char * * argv)
+{
+       static const struct diagnostic *        diag = diagnostics;
+       
+
+       EF_PROTECT_BELOW = 0;
+       EF_ALIGNMENT = 0;
+
+       while ( diag->explanation != 0 ) {
+               int     status = gotSegmentationFault(diag->test);
+
+               if ( status != diag->expectedStatus ) {
+                       /*
+                        * Don't use stdio to print here, because stdio
+                        * uses malloc() and we've just proven that malloc()
+                        * is broken. Also, use _exit() instead of exit(),
+                        * because _exit() doesn't flush stdio.
+                        */
+                       write(2, failedTest, sizeof(failedTest) - 1);
+                       write(2, diag->explanation, strlen(diag->explanation));
+                       write(2, &newline, 1);
+                       _exit(-1);
+               }
+               diag++;
+       }
+       return 0;
+}
diff --git a/ElectricFence/libefence.3 b/ElectricFence/libefence.3
new file mode 100644 (file)
index 0000000..34fd25c
--- /dev/null
@@ -0,0 +1,382 @@
+.TH efence 3 27-April-1993
+.SH NAME
+efence \- Electric Fence Malloc Debugger
+.SH SYNOPSIS
+.nf
+.ft B
+#include <stdlib.h>
+.ft
+.fi
+.LP
+.nf
+.ft B
+void * malloc (size_t size);
+.ft
+.fi
+.LP
+.nf
+.ft B
+void free (void *ptr);
+.ft
+.fi
+.LP
+.nf
+.ft B
+void * realloc (void *ptr, size_t size);
+.ft
+.fi
+.LP
+.nf
+.ft B
+void * calloc (size_t nelem, size_t elsize);
+.ft
+.fi
+.LP
+.nf
+.ft B
+void * memalign (size_t alignment, size_t size);
+.ft
+.fi
+.LP
+.nf
+.ft B
+void * valloc (size_t size);
+.ft
+.fi
+.LP
+.nf
+.ft B
+extern int EF_ALIGNMENT;
+.ft
+.fi
+.LP
+.nf
+.ft B
+extern int EF_PROTECT_BELOW;
+.ft
+.fi
+.LP
+.nf
+.ft B
+extern int EF_PROTECT_FREE;
+.ft
+.fi
+.SH DESCRIPTION
+.I Electric Fence
+helps you detect two common programming bugs:
+software that overruns the boundaries of a malloc() memory
+allocation, and software that touches a memory allocation that has been
+released by free(). Unlike other malloc() debuggers, Electric Fence will
+detect
+.I read
+accesses as well as writes, and it will pinpoint the exact instruction that
+causes an error. It has been in use at Pixar since 1987, and at many other
+sites for years.
+.LP
+Electric Fence uses the virtual memory hardware of your computer to place an
+inaccessible memory page immediately after (or before, at the user's option)
+each memory allocation. When software reads or writes this inaccessible page,
+the
+hardware issues a segmentation fault, stopping the program at the offending
+instruction. It is then trivial to find the erroneous statement using your
+favorite debugger. In a similar manner, memory that has been released by
+free() is made inaccessible, and any code that touches it will get a
+segmentation fault.
+.LP
+Simply linking your application with libefence.a will allow you to detect
+most, but not all, malloc buffer overruns and accesses of free memory.
+If you want to be reasonably sure that you've found
+.I all
+bugs of this type, you'll have to read and understand the rest of this
+man page.
+.SH USAGE
+Link your program with the library
+.B libefence.a .
+Make sure you are
+.I not
+linking with
+.B -lmalloc,
+.B -lmallocdebug,
+or with other malloc-debugger or malloc-enhancer libraries.
+You can only use one at a time.
+If your system administrator
+has installed Electric Fence for public use, you'll be able to use the
+.B -lefence
+argument to the linker, otherwise you'll have to put the path-name for
+.B libefence.a
+in the linker's command line.
+Some systems will require special arguments to the linker to assure that
+you are using the Electric Fence malloc() and not the one from your C library.
+On AIX systems, you may have to use the flags
+.br
+.B -bnso
+.B -bnodelcsect
+.B -bI:/lib/syscalls.exp
+.br
+On Sun systems running SunOS 4.X, you'll probably have to use
+.B -Bstatic.
+.LP
+Run your program
+.I using a debugger. 
+It's easier to work this way than to create a
+.B core
+file and post-mortem debug it. Electric Fence can create
+.I huge
+core files, and some operating systems will thus take minutes simply to dump
+core! Some operating systems will not create usable core files from programs
+that are linked with Electric Fence.
+If your program has one of the errors detected by Electric Fence, it will
+get a segmentation fault (SIGSEGV) at the offending instruction. Use the
+debugger to locate the erroneous statement, and repair it.
+.SH GLOBAL AND ENVIRONMENT VARIABLES
+Electric Fence has four configuration switches that can be enabled via
+the shell environment, or by setting the value of global integer variables
+using a debugger. These switches change what bugs Electric Fence will detect,
+so it's important that you know how to use them.
+.TP
+EF_ALIGNMENT
+This is an integer that specifies the alignment for any memory allocations
+that will be returned by malloc(), calloc(), and realloc().
+The value is specified in
+bytes, thus a value of 4 will cause memory to be aligned to 32-bit boundaries
+unless your system doesn't have a 8-bit characters. EF_ALIGNMENT is set to
+sizeof(int) by default, since that is generally the word-size of your CPU.
+If your program requires that allocations be aligned to 64-bit
+boundaries and you have a 32-bit
+.B int
+you'll have to set this value to 8. This is the case when compiling with the
+.B -mips2
+flag on MIPS-based systems such as those from SGI.
+The memory allocation that is returned by Electric Fence malloc() is aligned
+using the value in EF_ALIGNMENT, and
+.I its size the multiple of
+.I that value
+that is greater than or equal to the requested size.
+For this reason, you will sometimes want to set EF_ALIGNMENT to 0 (no
+alignment), so that
+you can detect overruns of less than your CPU's word size. Be sure to read
+the section
+.I WORD-ALIGNMENT AND OVERRUN DETECTION
+in this manual page before you try this.
+To change this value, set EF_ALIGNMENT in the shell environment to an
+integer value, or assign
+to the global integer variable EF_ALIGNMENT using a debugger.
+.TP
+EF_PROTECT_BELOW
+Electric Fence usually places an inaccessible page immediately after each
+memory allocation, so that software that runs past the end of the allocation
+will be detected. Setting EF_PROTECT_BELOW to 1 causes Electric Fence
+to place the inaccessible page
+.I before
+the allocation in the address space, so that under-runs will be detected
+instead of over-runs.
+When EF_PROTECT_BELOW is set, the EF_ALIGNMENT parameter is ignored.
+All allocations will be aligned to virtual-memory-page boundaries, and
+their size will be the exact size that was requested.
+To change this value, set EF_PROTECT_BELOW in the shell environment to an
+integer value, or assign to the global integer variable EF_PROTECT_BELOW using
+a debugger.
+.TP
+EF_PROTECT_FREE
+Electric Fence usually returns free memory to a pool from which it may be
+re-allocated. If you suspect that a program may be touching free memory,
+set EF_PROTECT_FREE to 1. This will cause Electric Fence to never re-allocate
+memory once it has been freed, so that any access to free memory will be
+detected. Some programs will use tremendous amounts of memory when this
+parameter is set.
+To change this value, set EF_PROTECT_FREE in the shell environment to an
+integer value, or assign to the global integer variable EF_PROTECT_FREE using
+a debugger.
+.TP
+EF_ALLOW_MALLOC_0
+By default, Electric Fence traps calls to malloc() with a size of zero, because
+they are often the result of a software bug. If EF_ALLOW_MALLOC_0 is non-zero,
+the software will not trap calls to malloc() with a size of zero.
+To change this value, set EF_ALLOC_MALLOC_0 in the shell environment to an
+integer value, or assign to the global integer variable EF_ALLOC_MALLOC_0 using
+a debugger.
+.SH WORD-ALIGNMENT AND OVERRUN DETECTION
+There is a conflict between the alignment restrictions that malloc() operates
+under and the debugging strategy used by Electric Fence. When detecting
+overruns, Electric Fence malloc() allocates two or more virtual memory
+pages for each allocation. The last page is made inaccessible in such a way
+that any read, write, or execute access will cause a segmentation fault.
+Then, Electric Fence malloc() will return an address such that the first
+byte after
+the end of the allocation is on the inaccessible page.
+Thus, any overrun
+of the allocation will cause a segmentation fault.
+.LP
+It follows that the
+address returned by malloc() is the address of the inaccessible page minus
+the size of the memory allocation.
+Unfortunately, malloc() is required to return
+.I word-aligned
+allocations, since many CPUs can only access a word when its address is aligned.
+The conflict happens when software makes a memory allocation using a size that
+is not a multiple of the word size, and expects to do word accesses to that
+allocation. The location of the inaccessible page is fixed by hardware at
+a word-aligned address. If Electric Fence malloc() is to return an aligned
+address, it must increase the size of the allocation to a multiple of the
+word size.
+In addition, the functions memalign() and valloc() must honor explicit
+specifications on the alignment of the memory allocation, and this, as well
+can only be implemented by increasing the size of the allocation.
+Thus, there will be situations in which the end of a memory allocation
+contains some padding space, and accesses of that padding space will not
+be detected, even if they are overruns.
+.LP
+Electric Fence provides the variable EF_ALIGNMENT so that the user can
+control the default alignment used by malloc(), calloc(), and realloc().
+To debug overruns as small as a single byte, you can set EF_ALIGNMENT to
+zero. This will result in Electric Fence malloc() returning unaligned
+addresses for allocations with sizes that are not a multiple of the word
+size. This is not a problem in most cases, because compilers must pad the
+size of objects so that alignment restrictions are honored when storing
+those objects in arrays. The problem surfaces when software allocates
+odd-sized buffers for objects that must be word-aligned. One case of this
+is software that allocates a buffer to contain a structure and a
+string, and the string has an odd size (this example was in a popular TIFF
+library). If word references are made to un-aligned buffers, you will see
+a bus error (SIGBUS) instead of a segmentation fault. The only way to fix
+this is to re-write the offending code to make byte references or not make
+odd-sized allocations, or to set EF_ALIGNMENT to the word size.
+.LP
+Another example of software incompatible with
+EF_ALIGNMENT < word-size
+is the strcmp() function and other string functions on SunOS (and probably
+Solaris), which make word-sized accesses to character strings, and may
+attempt to access up to three bytes beyond the end of a string. These
+result in a segmentation fault (SIGSEGV). The only way around this is to
+use versions of the string functions that perform byte references instead
+of word references.
+.SH INSTRUCTIONS FOR DEBUGGING YOUR PROGRAM
+.TP
+1.
+Link with libefence.a as explained above.
+.TP
+2.
+Run your program in a debugger and fix any overruns or accesses to free memory.
+.TP
+3.
+Quit the debugger.
+.TP
+4.
+Set EF_PROTECT_BELOW = 1 in the shell environment.
+.TP
+5.
+Repeat step 2, this time repairing underruns if they occur.
+.TP
+6.
+Quit the debugger.
+.TP
+7.
+Read the restrictions in the section on
+.I WORD-ALIGNMENT AND OVERRUN DETECTION.
+See if you can
+set EF_ALIGNMENT to 0 and repeat step 2. Sometimes this will be too much work,
+or there will be problems with library routines for which you don't have the
+source, that will prevent you from doing this.
+.SH MEMORY USAGE AND EXECUTION SPEED
+Since Electric Fence uses at least two virtual memory pages for each of its
+allocations, it's a terrible memory hog. I've sometimes found it necessary to
+add a swap file using swapon(8) so that the system would have enough virtual
+memory to debug my program. Also, the way we manipulate memory results in
+various cache and translation buffer entries being flushed with each call
+to malloc or free. The end result is that your program will be much slower
+and use more resources while you are debugging it with Electric Fence.
+.LP
+Don't leave libefence.a linked into production software! Use it only
+for debugging.
+.SH PORTING
+Electric Fence is written for ANSI C. You should be able to port it with
+simple changes to the Makefile and to page.c,
+which contains the memory management primitives .
+Many POSIX platforms will require only a re-compile.
+The operating system facilities required to port Electric Fence are:
+.IP
+A way to allocate memory pages
+.br
+A way to make selected pages inaccessible.
+.br
+A way to make the pages accessible again.
+.br
+A way to detect when a program touches an inaccessible page.
+.br
+A way to print messages.
+.LP
+Please e-mail me a copy of any changes you have to make, so that I can
+merge them into the distribution.
+.SH AUTHOR
+Bruce Perens
+.SH WARNINGS
+I have tried to do as good a job as I can on this software, but I doubt
+that it is even theoretically possible to make it bug-free.
+This software has no warranty. It will not detect some bugs that you might
+expect it to detect, and will indicate that some non-bugs are bugs.
+Bruce Perens and/or Pixar will not be liable to any claims resulting
+from the use of this software or the ideas within it.
+The entire responsibility for its use must
+be assumed by the user. If you use it and it results in loss of life
+and/or property, tough. If it leads you on a wild goose chase and you waste
+two weeks debugging something, too bad.
+If you can't deal with the above, please don't use the software! I've written
+this in an attempt to help other people, not to get myself sued or prosecuted.
+.SH LICENSE
+Copyright 1987-1995 Bruce Perens. All rights reserved.
+.br
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License, Version 2,
+as published by the Free Software Foundation. A copy of this license is
+distributed with this software in the file "COPYING".
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. Read the
+file "COPYING" for more details.
+.SH CONTACTING THE AUTHOR
+.nf
+Bruce Perens
+c/o Pixar
+1001 West Cutting Blvd., Suite 200
+Richmond, CA 94804
+
+Telephone: 510-215-3502
+Fax: 510-236-0388
+Internet: Bruce@Pixar.com
+.fi
+.ft
+.SH FILES
+/dev/zero: Source of memory pages (via mmap(2)).
+.SH SEE ALSO
+malloc(3), mmap(2), mprotect(2), swapon(8)
+.SH DIAGNOSTICS
+Segmentation Fault: Examine the offending statement for violation of the
+boundaries of a memory allocation.
+.br
+Bus Error: See the section on
+.I WORD-ALIGNMENT AND OVERRUN DETECTION.
+in this manual page.
+.SH BUGS
+My explanation of the alignment issue could be improved.
+.LP
+Some Sun systems running SunOS 4.1 are reported to signal an access to a
+protected page with
+.B  SIGBUS
+rather than
+.B SIGSEGV,
+I suspect this is an undocumented feature of a particular Sun hardware
+version, not just the operating system.
+On these systems, eftest will fail with a bus error until you modify the
+Makefile to define
+.B PAGE_PROTECTION_VIOLATED_SIGNAL
+as
+.B SIGBUS.
+.LP
+There are, without doubt, other bugs and porting issues. Please contact me via
+e-mail if you have any bug reports, ideas, etc.
+.SH WHAT'S BETTER
+PURIFY, from Purify Systems, does a much better job than Electric Fence, and
+does much more. It's available at this writing on SPARC and HP.
+I'm not affiliated with Purify, I just think it's a wonderful product
+and you should check it out.
diff --git a/ElectricFence/page.c b/ElectricFence/page.c
new file mode 100644 (file)
index 0000000..c10b163
--- /dev/null
@@ -0,0 +1,175 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include "efence.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <fcntl.h>
+#include <sys/mman.h>
+#include <stdio.h>
+#include <errno.h>
+#include <string.h>
+
+/*
+ * Lots of systems are missing the definition of PROT_NONE.
+ */
+#ifndef        PROT_NONE
+#define        PROT_NONE       0
+#endif
+
+/*
+ * 386 BSD has MAP_ANON instead of MAP_ANONYMOUS.
+ */
+#if ( !defined(MAP_ANONYMOUS) && defined(MAP_ANON) )
+#define        MAP_ANONYMOUS   MAP_ANON
+#endif
+
+/*
+ * For some reason, I can't find mprotect() in any of the headers on
+ * IRIX or SunOS 4.1.2
+ */
+/* extern C_LINKAGE int mprotect(void * addr, size_t len, int prot); */
+
+static caddr_t startAddr = (caddr_t) 0;
+
+static const char *
+stringErrorReport(void)
+{
+       return strerror(errno);
+}
+
+/*
+ * Create memory.
+ */
+#if defined(MAP_ANONYMOUS)
+void *
+Page_Create(size_t size)
+{
+       caddr_t         allocation;
+
+       /*
+        * In this version, "startAddr" is a _hint_, not a demand.
+        * When the memory I map here is contiguous with other
+        * mappings, the allocator can coalesce the memory from two
+        * or more mappings into one large contiguous chunk, and thus
+        * might be able to find a fit that would not otherwise have
+        * been possible. I could _force_ it to be contiguous by using
+        * the MMAP_FIXED flag, but I don't want to stomp on memory mappings
+        * generated by other software, etc.
+        */
+       allocation = (caddr_t) mmap(
+        startAddr
+       ,(int)size
+       ,PROT_READ|PROT_WRITE
+       ,MAP_PRIVATE|MAP_ANONYMOUS
+       ,-1
+       ,0);
+
+#ifndef        __hpux
+       /*
+        * Set the "address hint" for the next mmap() so that it will abut
+        * the mapping we just created.
+        *
+        * HP/UX 9.01 has a kernel bug that makes mmap() fail sometimes
+        * when given a non-zero address hint, so we'll leave the hint set
+        * to zero on that system. HP recently told me this is now fixed.
+        * Someone please tell me when it is probable to assume that most
+        * of those systems that were running 9.01 have been upgraded.
+        */
+       startAddr = allocation + size;
+#endif
+
+       if ( allocation == (caddr_t)-1 )
+               EF_Exit("mmap() failed: %s", stringErrorReport());
+
+       return (void *)allocation;
+}
+#else
+void *
+Page_Create(size_t size)
+{
+       static int      devZeroFd = -1;
+       caddr_t         allocation;
+
+       if ( devZeroFd == -1 ) {
+               devZeroFd = open("/dev/zero", O_RDWR);
+               if ( devZeroFd < 0 )
+                       EF_Exit(
+                        "open() on /dev/zero failed: %s"
+                       ,stringErrorReport());
+       }
+
+       /*
+        * In this version, "startAddr" is a _hint_, not a demand.
+        * When the memory I map here is contiguous with other
+        * mappings, the allocator can coalesce the memory from two
+        * or more mappings into one large contiguous chunk, and thus
+        * might be able to find a fit that would not otherwise have
+        * been possible. I could _force_ it to be contiguous by using
+        * the MMAP_FIXED flag, but I don't want to stomp on memory mappings
+        * generated by other software, etc.
+        */
+       allocation = (caddr_t) mmap(
+        startAddr
+       ,(int)size
+       ,PROT_READ|PROT_WRITE
+       ,MAP_PRIVATE
+       ,devZeroFd
+       ,0);
+
+       startAddr = allocation + size;
+
+       if ( allocation == (caddr_t)-1 )
+               EF_Exit("mmap() failed: %s", stringErrorReport());
+
+       return (void *)allocation;
+}
+#endif
+
+static void
+mprotectFailed(void)
+{
+       EF_Exit("mprotect() failed: %s", stringErrorReport());
+}
+
+void
+Page_AllowAccess(void * address, size_t size)
+{
+       if ( mprotect((caddr_t)address, size, PROT_READ|PROT_WRITE) < 0 )
+               mprotectFailed();
+}
+
+void
+Page_DenyAccess(void * address, size_t size)
+{
+       if ( mprotect((caddr_t)address, size, PROT_NONE) < 0 )
+               mprotectFailed();
+}
+
+void
+Page_Delete(void * address, size_t size)
+{
+       if ( munmap((caddr_t)address, size) < 0 )
+               Page_DenyAccess(address, size);
+}
+
+#if defined(_SC_PAGESIZE)
+size_t
+Page_Size(void)
+{
+       return (size_t)sysconf(_SC_PAGESIZE);
+}
+#elif defined(_SC_PAGE_SIZE)
+size_t
+Page_Size(void)
+{
+       return (size_t)sysconf(_SC_PAGE_SIZE);
+}
+#else
+/* extern int  getpagesize(); */
+size_t
+Page_Size(void)
+{
+       return getpagesize();
+}
+#endif
diff --git a/ElectricFence/print.c b/ElectricFence/print.c
new file mode 100644 (file)
index 0000000..f32ed2b
--- /dev/null
@@ -0,0 +1,170 @@
+#include "efence.h"
+#include <stdlib.h>
+#include <unistd.h>
+#include <stdarg.h>
+#include <string.h>
+#include <signal.h>
+
+/*
+ * These routines do their printing without using stdio. Stdio can't
+ * be used because it calls malloc(). Internal routines of a malloc()
+ * debugger should not re-enter malloc(), so stdio is out.
+ */
+
+/*
+ * NUMBER_BUFFER_SIZE is the longest character string that could be needed
+ * to represent an unsigned integer, assuming we might print in base 2.
+ */
+#define        NUMBER_BUFFER_SIZE      (sizeof(ef_number) * NBBY)
+
+static void
+printNumber(ef_number number, ef_number base)
+{
+       char            buffer[NUMBER_BUFFER_SIZE];
+       char *          s = &buffer[NUMBER_BUFFER_SIZE];
+       int             size;
+       
+       do {
+               ef_number       digit;
+
+               if ( --s == buffer )
+                       EF_Abort("Internal error printing number.");
+
+               digit = number % base;
+
+               if ( digit < 10 )
+                       *s = '0' + digit;
+               else
+                       *s = 'a' + digit - 10;
+
+       } while ( (number /= base) > 0 );
+
+       size = &buffer[NUMBER_BUFFER_SIZE] - s;
+
+       if ( size > 0 )
+               write(2, s, size);
+}
+
+static void
+vprint(const char * pattern, va_list args)
+{
+       static const char       bad_pattern[] =
+        "\nBad pattern specifier %%%c in EF_Print().\n";
+       const char *    s = pattern;
+       char            c;
+
+       while ( (c = *s++) != '\0' ) {
+               if ( c == '%' ) {
+                       c = *s++;
+                       switch ( c ) {
+                       case '%':
+                               (void) write(2, &c, 1);
+                               break;
+                       case 'a':
+                               /*
+                                * Print an address passed as a void pointer.
+                                * The type of ef_number must be set so that
+                                * it is large enough to contain all of the
+                                * bits of a void pointer.
+                                */
+                               printNumber(
+                                (ef_number)va_arg(args, void *)
+                               ,0x10);
+                               break;
+                       case 's':
+                               {
+                                       const char *    string;
+                                       size_t          length;
+
+                                       string = va_arg(args, char *);
+                                       length = strlen(string);
+
+                                       (void) write(2, string, length);
+                               }
+                               break;
+                       case 'd':
+                               {
+                                       int     n = va_arg(args, int);
+
+                                       if ( n < 0 ) {
+                                               char    c = '-';
+                                               write(2, &c, 1);
+                                               n = -n;
+                                       }
+                                       printNumber(n, 10);
+                               }
+                               break;
+                       case 'x':
+                               printNumber(va_arg(args, u_int), 0x10);
+                               break;
+                       case 'c':
+                               {
+                                       char    c = va_arg(args, char);
+                                       
+                                       (void) write(2, &c, 1);
+                               }
+                               break;
+                       default:
+                               {
+                                       EF_Print(bad_pattern, c);
+                               }
+               
+                       }
+               }
+               else
+                       (void) write(2, &c, 1);
+       }
+}
+
+void
+EF_Abort(const char * pattern, ...)
+{
+       va_list args;
+
+       va_start(args, pattern);
+
+       EF_Print("\nElectricFence Aborting: ");
+       vprint(pattern, args);
+       EF_Print("\n");
+
+       va_end(args);
+
+       /*
+        * I use kill(getpid(), SIGILL) instead of abort() because some
+        * mis-guided implementations of abort() flush stdio, which can
+        * cause malloc() or free() to be called.
+        */
+       kill(getpid(), SIGILL);
+       /* Just in case something handles SIGILL and returns, exit here. */
+       _exit(-1);
+}
+
+void
+EF_Exit(const char * pattern, ...)
+{
+       va_list args;
+
+       va_start(args, pattern);
+
+       EF_Print("\nElectricFence Exiting: ");
+       vprint(pattern, args);
+       EF_Print("\n");
+
+       va_end(args);
+
+       /*
+        * I use _exit() because the regular exit() flushes stdio,
+        * which may cause malloc() or free() to be called.
+        */
+       _exit(-1);
+}
+
+void
+EF_Print(const char * pattern, ...)
+{
+       va_list args;
+
+       va_start(args, pattern);
+       vprint(pattern, args);
+       va_end(args);
+}
diff --git a/ElectricFence/tstheap.c b/ElectricFence/tstheap.c
new file mode 100644 (file)
index 0000000..c712fed
--- /dev/null
@@ -0,0 +1,61 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+#include <limits.h>
+#include "efence.h"
+
+/*
+ * This is a simple program to exercise the allocator. It allocates and frees
+ * memory in a pseudo-random fashion. It should run silently, using up time
+ * and resources on your system until you stop it or until it has gone
+ * through TEST_DURATION (or the argument) iterations of the loop.
+ */
+
+extern C_LINKAGE double drand48(void); /* For pre-ANSI C systems */
+
+#define        POOL_SIZE       1024
+#define        LARGEST_BUFFER  30000
+#define        TEST_DURATION   1000000
+
+void * pool[POOL_SIZE];
+
+#ifdef FAKE_DRAND48
+/*
+ * Add -DFAKE_DRAND48 to your compile flags if your system doesn't
+ * provide drand48().
+ */
+
+#ifndef        ULONG_MAX
+#define        ULONG_MAX       ~(1L)
+#endif
+
+double
+drand48(void)
+{
+       return (random() / (double)ULONG_MAX);
+}
+#endif
+
+int
+main(int argc, char * * argv)
+{
+       int     count = 0;
+       int     duration = TEST_DURATION;
+
+       if ( argc >= 2 )
+               duration = atoi(argv[1]);
+
+       for ( ; count < duration; count++ ) {
+               void * *        element = &pool[(int)(drand48() * POOL_SIZE)];
+               size_t          size = (size_t)(drand48() * (LARGEST_BUFFER + 1));
+
+               if ( *element ) {
+                       free( *element );
+                       *element = 0;
+               }
+               else if ( size > 0 ) {
+                       *element = malloc(size);
+               }
+       }
+       return 0;
+}
diff --git a/INSTALL b/INSTALL
new file mode 100644 (file)
index 0000000..0d95578
--- /dev/null
+++ b/INSTALL
@@ -0,0 +1,178 @@
+Basic Installation
+==================
+
+   These are generic *nix installation instructions.
+
+   For Windows/NT, please see ports/winnt and html/build/hints/winnt.html.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+   The file `configure.in' is used to create `configure' by a program
+called `autoconf'.  You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.  If you're
+     using `csh' on an old version of System V, you might need to type
+     `sh ./configure' instead to prevent `csh' from trying to execute
+     `configure' itself.
+
+     Running `configure' takes a while.  While running, it prints some
+     messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  You can give `configure'
+initial values for variables by setting them in the environment.  Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+     CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+     env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory.  After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+   By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc.  You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on.  Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+     CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+   If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+     Use and save the results of the tests in FILE instead of
+     `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
+     debugging `configure'.
+
+`--help'
+     Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--version'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
+
diff --git a/Makefile.am b/Makefile.am
new file mode 100644 (file)
index 0000000..4db3a09
--- /dev/null
@@ -0,0 +1,177 @@
+#AUTOMAKE_OPTIONS = util/ansi2knr foreign dist-tarZ no-dependencies
+AUTOMAKE_OPTIONS = util/ansi2knr foreign 1.8
+ACLOCAL_AMFLAGS= -I m4 -I libopts/m4
+
+NULL=
+
+SUBDIRS=
+if NEED_LIBOPTS
+SUBDIRS+= libopts
+endif
+SUBDIRS+=              \
+       scripts         \
+       include         \
+       ElectricFence   \
+       @ARLIB_DIR@     \
+       libntp          \
+       libparse        \
+       ntpd            \
+       ntpdate         \
+       ntpdc           \
+       ntpq            \
+       parseutil       \
+       adjtimed        \
+       clockstuff      \
+       kernel          \
+       sntp            \
+       util            \
+       $(NULL)
+
+DIST_SUBDIRS=          \
+       scripts         \
+       include         \
+       ElectricFence   \
+       arlib           \
+       libntp          \
+       libopts         \
+       libparse        \
+       ntpd            \
+       ntpdate         \
+       ntpdc           \
+       ntpq            \
+       parseutil       \
+       adjtimed        \
+       clockstuff      \
+       kernel          \
+       sntp            \
+       util            \
+       $(NULL)
+
+DISTCHECK_CONFIGURE_FLAGS=     --with-arlib --enable-local-libopts
+
+EXTRA_DIST =           \
+       COPYRIGHT       \
+       ChangeLog       \
+       CommitLog       \
+       CommitLog-4.1.0 \
+       NEWS            \
+       NOTES.y2kfixes  \
+       README.bk       \
+       README.hackers  \
+       README.patches  \
+       README.refclocks \
+       README.versions \
+       TODO            \
+       WHERE-TO-START  \
+       bootstrap       \
+       build           \
+       config.guess    \
+       config.h.in     \
+       config.sub      \
+       dot.emacs       \
+       excludes        \
+       flock-build     \
+       install-sh      \
+       packageinfo.sh  \
+       readme.y2kfixes \
+       results.y2kfixes        \
+       \
+       conf            \
+       html            \
+       libisc          \
+       ports           \
+       \
+       bincheck.mf     \
+       version         \
+       version.m4      \
+       \
+       $(NULL)
+
+DISTCLEANFILES = .gcc-warning
+
+#ETAGS_ARGS = $(srcdir)/Makefile.am $(srcdir)/configure.ac
+ETAGS_ARGS = Makefile.am configure.ac
+
+# HMS: make ports be the last directory...
+# DIST_HOOK_DIRS = conf html scripts ports
+
+# HMS: Keep .gcc-warning first, as that way it gets printed first.
+BUILT_SOURCES = .gcc-warning $(srcdir)/COPYRIGHT $(srcdir)/version $(srcdir)/version.m4 $(srcdir)/include/version.def
+
+$(srcdir)/COPYRIGHT: $(srcdir)/html/copyright.html
+       ( echo "This file is automatically generated from html/copyright.html" ; lynx -dump $(srcdir)/html/copyright.html ) > $(srcdir)/COPYRIGHT.new && mv $(srcdir)/COPYRIGHT.new $(srcdir)/COPYRIGHT
+
+# HMS: The next bit is still suboptimal.  If bk is present but this NTP
+# repo is not a bk repo, we'll get an error message from the prs command.
+# Unfortunately, I haven't found the necessary magic to redirect this error
+# output to /dev/null under ancient/unique shells like the one Ultrix uses.
+# We'll also get an error if srcdir or version is unwritable.
+$(srcdir)/version: FRC.version
+       -(bk version) >/dev/null 2>&1 && \
+           cd $(srcdir) && \
+            x=`bk -R prs -hr+ -nd:I: ChangeSet` && \
+           y=`cat version 2>/dev/null` || true && \
+           case "$$x" in ''|$$y) ;; *) echo $$x > version ;; esac
+
+$(srcdir)/version.m4: $(srcdir)/packageinfo.sh
+       cd $(srcdir) && \
+       ./scripts/genver version.m4
+
+$(srcdir)/include/version.def: $(srcdir)/packageinfo.sh
+       cd $(srcdir) && \
+       ./scripts/genver include/version.def
+
+dist-hook:
+       @find $(distdir) -type d -name CVS -print | xargs rm -rf
+       @find $(distdir) -type d -name SCCS -print | xargs rm -rf
+       @chmod u+w $(distdir)/ports/winnt
+       @for i in `find $(distdir)/ports/winnt -type f -name '*.ds*' -print`; \
+          do chmod u+w $$i ; unix2dos $$i $$i; done
+
+.gcc-warning:
+       @echo "Compiling with GCC now generates lots of new warnings."
+       @echo " "
+       @echo "Don't be concerned. They're just warnings."
+       @echo " "
+       @echo "Don't send bug reports about the warnings, either."
+       @echo " "
+       @echo "Feel free to send patches that fix these warnings, though."
+       @echo " "
+       @sleep 1
+       @touch $@
+
+CommitLog: FRC.CommitLog
+       cd $(srcdir)                                    \
+       && /bin/test -e CommitLog                       \
+               -a SCCS/s.ChangeSet -ot CommitLog       \
+       || scripts/genCommitLog
+
+# HMS: The following seems to be a work-in-progress...
+
+CVO=`$(srcdir)/config.guess`
+
+.buildcvo:
+       echo "$(CVO)" > .buildcvo
+
+.checkcvo: .buildcvo FRC.checkcvo
+       @if [ "`cat .buildcvo`" != "$(CVO)" ];then      \
+               echo "This directory was configured for `cat .buildcvo`"; \
+               echo "but this machine is a $(CVO)";    \
+               exit 1; \
+       fi
+
+BHOST=`(hostname || uname -n)`
+
+.buildhost:
+       echo "$(BHOST)" > .buildhost
+
+.checkhost: .buildhost FRC.checkhost
+       @if [ "`cat .buildhost`" != "$(BHOST)" ];then   \
+               echo "Built on `cat .buildhost` but this is $(BHOST)"; \
+               echo " "; \
+       fi
+
+FRC.CommitLog FRC.distwarn FRC.checkcvo FRC.checkhost FRC.version:
+
+# HMS: what was I trying to do with this?
+#dot.emacs: FRC.distwarn
diff --git a/Makefile.in b/Makefile.in
new file mode 100644 (file)
index 0000000..42b2e2e
--- /dev/null
@@ -0,0 +1,899 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+@NEED_LIBOPTS_TRUE@am__append_1 = libopts
+subdir = .
+DIST_COMMON = README $(am__configure_deps) $(srcdir)/Makefile.am \
+       $(srcdir)/Makefile.in $(srcdir)/config.h.in \
+       $(top_srcdir)/configure ChangeLog INSTALL NEWS TODO compile \
+       config.guess config.sub depcomp install-sh ltmain.sh missing
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+       html-recursive info-recursive install-data-recursive \
+       install-dvi-recursive install-exec-recursive \
+       install-html-recursive install-info-recursive \
+       install-pdf-recursive install-ps-recursive install-recursive \
+       installcheck-recursive installdirs-recursive pdf-recursive \
+       ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+       $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+       distdir dist dist-all distcheck
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d "$(distdir)" \
+    || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr "$(distdir)"; }; }
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#AUTOMAKE_OPTIONS = util/ansi2knr foreign dist-tarZ no-dependencies
+AUTOMAKE_OPTIONS = util/ansi2knr foreign 1.8
+ACLOCAL_AMFLAGS = -I m4 -I libopts/m4
+NULL = 
+SUBDIRS = $(am__append_1) scripts include ElectricFence @ARLIB_DIR@ \
+       libntp libparse ntpd ntpdate ntpdc ntpq parseutil adjtimed \
+       clockstuff kernel sntp util $(NULL)
+DIST_SUBDIRS = \
+       scripts         \
+       include         \
+       ElectricFence   \
+       arlib           \
+       libntp          \
+       libopts         \
+       libparse        \
+       ntpd            \
+       ntpdate         \
+       ntpdc           \
+       ntpq            \
+       parseutil       \
+       adjtimed        \
+       clockstuff      \
+       kernel          \
+       sntp            \
+       util            \
+       $(NULL)
+
+DISTCHECK_CONFIGURE_FLAGS = --with-arlib --enable-local-libopts
+EXTRA_DIST = \
+       COPYRIGHT       \
+       ChangeLog       \
+       CommitLog       \
+       CommitLog-4.1.0 \
+       NEWS            \
+       NOTES.y2kfixes  \
+       README.bk       \
+       README.hackers  \
+       README.patches  \
+       README.refclocks \
+       README.versions \
+       TODO            \
+       WHERE-TO-START  \
+       bootstrap       \
+       build           \
+       config.guess    \
+       config.h.in     \
+       config.sub      \
+       dot.emacs       \
+       excludes        \
+       flock-build     \
+       install-sh      \
+       packageinfo.sh  \
+       readme.y2kfixes \
+       results.y2kfixes        \
+       \
+       conf            \
+       html            \
+       libisc          \
+       ports           \
+       \
+       bincheck.mf     \
+       version         \
+       version.m4      \
+       \
+       $(NULL)
+
+DISTCLEANFILES = .gcc-warning
+
+#ETAGS_ARGS = $(srcdir)/Makefile.am $(srcdir)/configure.ac
+ETAGS_ARGS = Makefile.am configure.ac
+
+# HMS: make ports be the last directory...
+# DIST_HOOK_DIRS = conf html scripts ports
+
+# HMS: Keep .gcc-warning first, as that way it gets printed first.
+BUILT_SOURCES = .gcc-warning $(srcdir)/COPYRIGHT $(srcdir)/version $(srcdir)/version.m4 $(srcdir)/include/version.def
+
+# HMS: The following seems to be a work-in-progress...
+CVO = `$(srcdir)/config.guess`
+BHOST = `(hostname || uname -n)`
+all: $(BUILT_SOURCES) config.h
+       $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+am--refresh:
+       @:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
+             $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
+               && exit 0; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           echo ' $(SHELL) ./config.status'; \
+           $(SHELL) ./config.status;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       $(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+config.h: stamp-h1
+       @if test ! -f $@; then \
+         rm -f stamp-h1; \
+         $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+       else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+       @rm -f stamp-h1
+       cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in:  $(am__configure_deps) 
+       ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+       rm -f stamp-h1
+       touch $@
+
+distclean-hdr:
+       -rm -f config.h stamp-h1
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+distclean-libtool:
+       -rm -f libtool config.lt
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       rev=''; for subdir in $$list; do \
+         if test "$$subdir" = "."; then :; else \
+           rev="$$subdir $$rev"; \
+         fi; \
+       done; \
+       rev="$$rev ."; \
+       target=`echo $@ | sed s/-recursive//`; \
+       for subdir in $$rev; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done && test -z "$$fail"
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+ctags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+       done
+
+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: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       list='$(SOURCES) $(HEADERS) config.h.in $(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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS) config.h.in $(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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       $(am__remove_distdir)
+       test -d "$(distdir)" || mkdir "$(distdir)"
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test -d "$(distdir)/$$subdir" \
+           || $(MKDIR_P) "$(distdir)/$$subdir" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || exit 1; \
+         fi; \
+       done
+       $(MAKE) $(AM_MAKEFLAGS) \
+         top_distdir="$(top_distdir)" distdir="$(distdir)" \
+         dist-hook
+       -test -n "$(am__skip_mode_fix)" \
+       || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+         ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+       || chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+dist-bzip2: distdir
+       tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+       $(am__remove_distdir)
+
+dist-lzma: distdir
+       tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+       $(am__remove_distdir)
+
+dist-xz: distdir
+       tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
+       $(am__remove_distdir)
+
+dist-tarZ: distdir
+       tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+       $(am__remove_distdir)
+
+dist-shar: distdir
+       shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+       $(am__remove_distdir)
+
+dist-zip: distdir
+       -rm -f $(distdir).zip
+       zip -rq $(distdir).zip $(distdir)
+       $(am__remove_distdir)
+
+dist dist-all: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+       case '$(DIST_ARCHIVES)' in \
+       *.tar.gz*) \
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+       *.tar.bz2*) \
+         bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+       *.tar.lzma*) \
+         unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
+       *.tar.xz*) \
+         xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+       *.tar.Z*) \
+         uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+       *.shar.gz*) \
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+       *.zip*) \
+         unzip $(distdir).zip ;;\
+       esac
+       chmod -R a-w $(distdir); chmod a+w $(distdir)
+       mkdir $(distdir)/_build
+       mkdir $(distdir)/_inst
+       chmod a-w $(distdir)
+       test -d $(distdir)/_build || exit 0; \
+       dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+         && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+         && am__cwd=`pwd` \
+         && $(am__cd) $(distdir)/_build \
+         && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+           $(DISTCHECK_CONFIGURE_FLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) dvi \
+         && $(MAKE) $(AM_MAKEFLAGS) check \
+         && $(MAKE) $(AM_MAKEFLAGS) install \
+         && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+         && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+         && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+               distuninstallcheck \
+         && chmod -R a-w "$$dc_install_base" \
+         && ({ \
+              (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+                   distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+             } || { rm -rf "$$dc_destdir"; exit 1; }) \
+         && rm -rf "$$dc_destdir" \
+         && $(MAKE) $(AM_MAKEFLAGS) dist \
+         && rm -rf $(DIST_ARCHIVES) \
+         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+         && cd "$$am__cwd" \
+         || exit 1
+       $(am__remove_distdir)
+       @(echo "$(distdir) archives ready for distribution: "; \
+         list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+         sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+       @$(am__cd) '$(distuninstallcheck_dir)' \
+       && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+          || { echo "ERROR: files left after uninstall:" ; \
+               if test -n "$(DESTDIR)"; then \
+                 echo "  (check DESTDIR support)"; \
+               fi ; \
+               $(distuninstallcheck_listfiles) ; \
+               exit 1; } >&2
+distcleancheck: distclean
+       @if test '$(srcdir)' = . ; then \
+         echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+         exit 1 ; \
+       fi
+       @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+         || { echo "ERROR: files left in build directory after distclean:" ; \
+              $(distcleancheck_listfiles) ; \
+              exit 1; } >&2
+check-am: all-am
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-recursive
+all-am: Makefile config.h
+installdirs: installdirs-recursive
+installdirs-am:
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+       -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+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-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-hdr \
+       distclean-libtool distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf $(top_srcdir)/autom4te.cache
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \
+       ctags-recursive install install-am install-strip \
+       tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+       all all-am am--refresh check check-am clean clean-generic \
+       clean-libtool ctags ctags-recursive dist dist-all dist-bzip2 \
+       dist-gzip dist-hook dist-lzma dist-shar dist-tarZ dist-xz \
+       dist-zip distcheck distclean distclean-generic distclean-hdr \
+       distclean-libtool distclean-tags distcleancheck distdir \
+       distuninstallcheck 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 \
+       installdirs-am maintainer-clean maintainer-clean-generic \
+       mostlyclean mostlyclean-generic mostlyclean-libtool pdf pdf-am \
+       ps ps-am tags tags-recursive uninstall uninstall-am
+
+
+$(srcdir)/COPYRIGHT: $(srcdir)/html/copyright.html
+       ( echo "This file is automatically generated from html/copyright.html" ; lynx -dump $(srcdir)/html/copyright.html ) > $(srcdir)/COPYRIGHT.new && mv $(srcdir)/COPYRIGHT.new $(srcdir)/COPYRIGHT
+
+# HMS: The next bit is still suboptimal.  If bk is present but this NTP
+# repo is not a bk repo, we'll get an error message from the prs command.
+# Unfortunately, I haven't found the necessary magic to redirect this error
+# output to /dev/null under ancient/unique shells like the one Ultrix uses.
+# We'll also get an error if srcdir or version is unwritable.
+$(srcdir)/version: FRC.version
+       -(bk version) >/dev/null 2>&1 && \
+           cd $(srcdir) && \
+            x=`bk -R prs -hr+ -nd:I: ChangeSet` && \
+           y=`cat version 2>/dev/null` || true && \
+           case "$$x" in ''|$$y) ;; *) echo $$x > version ;; esac
+
+$(srcdir)/version.m4: $(srcdir)/packageinfo.sh
+       cd $(srcdir) && \
+       ./scripts/genver version.m4
+
+$(srcdir)/include/version.def: $(srcdir)/packageinfo.sh
+       cd $(srcdir) && \
+       ./scripts/genver include/version.def
+
+dist-hook:
+       @find $(distdir) -type d -name CVS -print | xargs rm -rf
+       @find $(distdir) -type d -name SCCS -print | xargs rm -rf
+       @chmod u+w $(distdir)/ports/winnt
+       @for i in `find $(distdir)/ports/winnt -type f -name '*.ds*' -print`; \
+          do chmod u+w $$i ; unix2dos $$i $$i; done
+
+.gcc-warning:
+       @echo "Compiling with GCC now generates lots of new warnings."
+       @echo " "
+       @echo "Don't be concerned. They're just warnings."
+       @echo " "
+       @echo "Don't send bug reports about the warnings, either."
+       @echo " "
+       @echo "Feel free to send patches that fix these warnings, though."
+       @echo " "
+       @sleep 1
+       @touch $@
+
+CommitLog: FRC.CommitLog
+       cd $(srcdir)                                    \
+       && /bin/test -e CommitLog                       \
+               -a SCCS/s.ChangeSet -ot CommitLog       \
+       || scripts/genCommitLog
+
+.buildcvo:
+       echo "$(CVO)" > .buildcvo
+
+.checkcvo: .buildcvo FRC.checkcvo
+       @if [ "`cat .buildcvo`" != "$(CVO)" ];then      \
+               echo "This directory was configured for `cat .buildcvo`"; \
+               echo "but this machine is a $(CVO)";    \
+               exit 1; \
+       fi
+
+.buildhost:
+       echo "$(BHOST)" > .buildhost
+
+.checkhost: .buildhost FRC.checkhost
+       @if [ "`cat .buildhost`" != "$(BHOST)" ];then   \
+               echo "Built on `cat .buildhost` but this is $(BHOST)"; \
+               echo " "; \
+       fi
+
+FRC.CommitLog FRC.distwarn FRC.checkcvo FRC.checkhost FRC.version:
+
+# HMS: what was I trying to do with this?
+#dot.emacs: FRC.distwarn
+
+# 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.
+.NOEXPORT:
diff --git a/NEWS b/NEWS
new file mode 100644 (file)
index 0000000..729a91f
--- /dev/null
+++ b/NEWS
@@ -0,0 +1,157 @@
+NTP 4.2.4p8 (Harlan Stenn <stenn@ntp.org>, 2009/12/08)
+
+Focus: Security Fixes
+
+Severity: HIGH
+
+This release fixes the following high-severity vulnerability:
+
+* [Sec 1331] DoS with mode 7 packets - CVE-2009-3563.
+
+  See http://support.ntp.org/security for more information.
+
+  NTP mode 7 (MODE_PRIVATE) is used by the ntpdc query and control utility.
+  In contrast, ntpq uses NTP mode 6 (MODE_CONTROL), while routine NTP time
+  transfers use modes 1 through 5.  Upon receipt of an incorrect mode 7
+  request or a mode 7 error response from an address which is not listed
+  in a "restrict ... noquery" or "restrict ... ignore" statement, ntpd will
+  reply with a mode 7 error response (and log a message).  In this case:
+
+       * If an attacker spoofs the source address of ntpd host A in a
+         mode 7 response packet sent to ntpd host B, both A and B will
+         continuously send each other error responses, for as long as
+         those packets get through.
+
+       * If an attacker spoofs an address of ntpd host A in a mode 7
+         response packet sent to ntpd host A, A will respond to itself
+         endlessly, consuming CPU and logging excessively.
+
+  Credit for finding this vulnerability goes to Robin Park and Dmitri
+  Vinokurov of Alcatel-Lucent.
+
+THIS IS A STRONGLY RECOMMENDED UPGRADE.
+
+---
+NTP 4.2.4p7 (Harlan Stenn <stenn@ntp.org>, 2009/05/04)
+
+Focus: Security and Bug Fixes
+
+Severity: HIGH
+
+This release fixes the following high-severity vulnerability:
+
+* [Sec 1151] Remote exploit if autokey is enabled.  CVE-2009-1252
+
+  See http://support.ntp.org/security for more information.
+
+  If autokey is enabled (if ntp.conf contains a "crypto pw whatever"
+  line) then a carefully crafted packet sent to the machine will cause
+  a buffer overflow and possible execution of injected code, running
+  with the privileges of the ntpd process (often root).
+
+  Credit for finding this vulnerability goes to Chris Ries of CMU.
+
+This release fixes the following low-severity vulnerabilities:
+
+* [Sec 1144] limited (two byte) buffer overflow in ntpq.  CVE-2009-0159
+  Credit for finding this vulnerability goes to Geoff Keating of Apple.
+  
+* [Sec 1149] use SO_EXCLUSIVEADDRUSE on Windows
+  Credit for finding this issue goes to Dave Hart.
+
+This release fixes a number of bugs and adds some improvements:
+
+* Improved logging
+* Fix many compiler warnings
+* Many fixes and improvements for Windows
+* Adds support for AIX 6.1
+* Resolves some issues under MacOS X and Solaris
+
+THIS IS A STRONGLY RECOMMENDED UPGRADE.
+
+---
+NTP 4.2.4p6 (Harlan Stenn <stenn@ntp.org>, 2009/01/07)
+
+Focus: Security Fix
+
+Severity: Low
+
+This release fixes oCERT.org's CVE-2009-0021, a vulnerability affecting
+the OpenSSL library relating to the incorrect checking of the return
+value of EVP_VerifyFinal function.
+
+Credit for finding this issue goes to the Google Security Team for
+finding the original issue with OpenSSL, and to ocert.org for finding
+the problem in NTP and telling us about it.
+
+This is a recommended upgrade.
+---
+NTP 4.2.4p5 (Harlan Stenn <stenn@ntp.org>, 2008/08/17)
+
+Focus: Minor Bugfixes 
+
+This release fixes a number of Windows-specific ntpd bugs and 
+platform-independent ntpdate bugs. A logging bugfix has been applied
+to the ONCORE driver.
+
+The "dynamic" keyword and is now obsolete and deferred binding to local 
+interfaces is the new default. The minimum time restriction for the 
+interface update interval has been dropped. 
+
+A number of minor build system and documentation fixes are included. 
+
+This is a recommended upgrade for Windows. 
+
+---
+NTP 4.2.4p4 (Harlan Stenn <stenn@ntp.org>, 2007/09/10)
+
+Focus: Minor Bugfixes
+
+This release updates certain copyright information, fixes several display
+bugs in ntpdc, avoids SIGIO interrupting malloc(), cleans up file descriptor
+shutdown in the parse refclock driver, removes some lint from the code,
+stops accessing certain buffers immediately after they were freed, fixes
+a problem with non-command-line specification of -6, and allows the loopback
+interface to share addresses with other interfaces.
+
+---
+NTP 4.2.4p3 (Harlan Stenn <stenn@ntp.org>, 2007/06/29)
+
+Focus: Minor Bugfixes
+
+This release fixes a bug in Windows that made it difficult to
+terminate ntpd under windows.
+This is a recommended upgrade for Windows.
+
+---
+NTP 4.2.4p2 (Harlan Stenn <stenn@ntp.org>, 2007/06/19)
+
+Focus: Minor Bugfixes
+
+This release fixes a multicast mode authentication problem, 
+an error in NTP packet handling on Windows that could lead to 
+ntpd crashing, and several other minor bugs. Handling of 
+multicast interfaces and logging configuration were improved. 
+The required versions of autogen and libopts were incremented.
+This is a recommended upgrade for Windows and multicast users.
+
+---
+NTP 4.2.4 (Harlan Stenn <stenn@ntp.org>, 2006/12/31)
+
+Focus: enhancements and bug fixes.
+
+Dynamic interface rescanning was added to simplify the use of ntpd in 
+conjunction with DHCP. GNU AutoGen is used for its command-line options 
+processing. Separate PPS devices are supported for PARSE refclocks, MD5 
+signatures are now provided for the release files. Drivers have been 
+added for some new ref-clocks and have been removed for some older 
+ref-clocks. This release also includes other improvements, documentation 
+and bug fixes. 
+
+K&R C is no longer supported as of NTP-4.2.4. We are now aiming for ANSI 
+C support.
+
+---
+NTP 4.2.0 (Harlan Stenn <stenn@ntp.org>, 2003/10/15)
+
+Focus: enhancements and bug fixes.
diff --git a/NOTES.y2kfixes b/NOTES.y2kfixes
new file mode 100644 (file)
index 0000000..cf181c1
--- /dev/null
@@ -0,0 +1,107 @@
+Name of the Application: xntp
+
+Version Number:  4.0.91
+
+Download Size: 4541953 bytes
+
+Downloaded from: http://www.eecis.udel.edu/~ntp/
+
+Operating Systems Supported: many
+
+Operating Systems Tested: unix
+
+Testing
+
+Dates tested (CPU clock set)
+
+       1999-12-31
+       2000-01-01
+       2000-02-29
+
+       Critical fragments of code tested with other dates by special
+       algorithms.
+
+Hardware Platform: Sun Sparc
+
+OS: Solaris 2.6
+
+Compiler: gcc
+
+Version: 2.8.1
+
+Repairs:  9
+
+No. of files Repaired: 13
+
+
+Compilation of Patches Required: yes
+
+Results Description:
+
+1)     Tested suspicious code.
+
+2)     Repaired problem code and added documentation to ntp.h.
+
+3)     Verified ntpd works on critical Y2K dates.
+
+
+Comments:
+
+1)     Errors were found in improper use of tm_year within struct tm,
+       calculations that did not support year 2000 as a leap year
+       (it truly is, despite any unchanged comments remaining in 
+       the NTP source), and some incorrect date calculations, while
+       not traditional Y2K errors, would break in the year 2000.
+
+2)     include/ntpd.h
+       Added some definitions and documentation about the right way
+        of doing things.  Definitions used by most, if not all, of
+        the Y2K repairs.
+
+Cautions:
+
+1)     Some of the Y2K repairs were to reference clock drivers that
+       we did not have the local hardware to test.  While I believe
+       the changes are sound, they really need to be tested.
+       This includes:
+
+               refclock_arc.c
+               refclock_heath.c
+               refclock_hpgps.c
+
+       Also, parseutil/dcfd.c is another hardware dependent module that
+       was repaired without live testing.
+
+Non-Y2K Problems Observed:
+
+1)     Inconsistent casts of variables containing time values may
+       make expansion to 64 bit integer values in a portable manner
+       difficult.
+
+2)     libntp/caltontp.c:
+        Has logic I believe will fail starting in year 2100 or so.
+        Left unchanged/untested as it works well beyond basic NTP 2036 
+       limit checked by check_y2k.c.
+        If NTP is implemented on 64-bit machines, this should be fixed
+
+3)     ntpd/refclock_acts.c:
+       ACTS time format has changed somewhat since the code was written.
+       In particular the '*' '#' character switch no longer occurs...
+       only '*' is typed.
+
+      NOTE: Author (falsely) stated Y2K is NOT a leap year when it 
+      really is.
+
+      TRUTH: ACTS will go beyond Y2K: it uses FourDigitYear % 100 values
+      for year so year 2000 will revert to "00".
+
+
+4)     ntpd/refclock_oncore.c
+       Some very strange logic in manipulating year values:
+       1122         instance->pp->year = buf[6]*256+buf[7];
+       Multiply by 256????
+    Response from PHK:
+       The entire protocol is binary, the year is a 16 bit quantity 
+       which according to the manual can have the range 1998-2018. 
diff --git a/README b/README
new file mode 100644 (file)
index 0000000..dde61e2
--- /dev/null
+++ b/README
@@ -0,0 +1,148 @@
+
+Submit patches, bug reports, and enhancement requests via
+
+                       http://bugs.ntp.org
+
+                 The ntp Distribution Base Directory
+
+This directory and its subdirectories contain the Network Time Protocol
+Version 4 (NTP) distribution for Unix and Windows/NT systems.  This release
+may still work on VxWorks, too.
+
+The contents of the base directory are given in this file. The contents of
+subdirectories are given in the README files in each subdirectory.
+
+A complete explanation of the configure, compile and install process, as
+well as setting up an NTP subnet, is in the HTML pages in the ./html/
+directory. For more information on NTP and how to get a working setup,
+read WHERE-TO-START.
+
+For Windows/NT, visit html/build/hints/winnt.html .
+
+The base directory ./ contains the autoconfiguration files, source
+directories and related stuff:
+
+COPYRIGHT      Excerpt from the HTML file ./html/copyright.html. This file
+               specifies copyright conditions, together with a list of
+               major authors and electric addresses.
+
+INSTALL                Generic installation instructions for autoconf-based programs.
+               Unless you really know what you are doing, you should read the
+               directions in the HTML pages, starting with ./html/index.html.
+
+NEWS           What's new in this release.
+
+README         This file.
+
+README.bk      Instructions for folks who use the BitKeeper-repository
+               version of NTP.
+
+README.hackers Notes to folks who want to hack on the code.
+
+TODO            List of items the NTP developers are working on.
+
+WHERE-TO-START Hints on what to read in order to get a working
+               configuration.
+
+Makefile.am    Automake file configuration file. Edit only if you have the
+               GNU automake and autoconf utilities installed.
+
+Makefile.in    Autoconf make file template for Unix.
+
+adjtimed        Directory containing the sources for the adjtime daemon
+               for HP/UX systems prior to HP-UX 10.0.
+
+authstuff       Directory containing sources for miscellaneous programs
+               to test, calibrate and certify the cryptographic
+               mechanisms for DES and MD5 based authentication. These
+               programs do not include the cryptographic routines
+               themselves, so are free of U.S. export restrictions.
+
+build          A script to build the distribution in A.`config.guess`
+               subdirectory (more or less).
+
+clockstuff     Directory containing sources for miscellaneous programs
+               to test certain auxiliary programs used with some kernel
+               configurations, together with a program to calculate
+               propagation delays for use with radio clocks and
+               national time dissemination services such as WWV/WWVH,
+               WWVB and CHU.
+
+conf            Directory containing a motley collection of
+               configuration files for various systems. For example only.
+
+config.guess   Script used to identify the machine architecture and
+               operating system.
+
+config.h.in    Configuration file generated automatically from
+               configure.in. Do not edit.
+
+configure      Script used to configure the distribution. See the HTML pages
+               (./html/index.html) for a complete description of the options
+               available.
+
+configure.in   Master configuration template. Edit only if you have the
+               GNU automake and autoconf utilities installed.
+
+dot.emacs      C-mode indentation rules for code "Just the way Dave likes it".
+
+flock_build    (UDel only) Build the distribution on a number of
+               different platforms.
+
+html            Directory containing a complete set of documentation on
+               building and configuring a NTP server or client. The
+               documentation is in the form of HTML files suitable for
+               browsing and contains links to additional documentation
+               at various web sites. If a browser is unavailable, an
+               ordinary text editor can be used.
+
+include                Directory containing include header files used by most
+               programs in the distribution.
+
+install-sh     Script to install a program, script or data file.
+
+kernel         Directory containing sources for kernel programs such as
+               line disciplines and STREAMS modules used with the CHU
+               decoder and precision PPS signals.
+
+libntp         Directory containing library source code used by most
+               programs in the distribution.
+
+ntpdate                Directory containing sources for a program to set the
+               local machine time from one or more remote machines
+               running NTP.  Operates like rdate, but much more accurate.
+
+ntpq            Directory containing sources for a utility program to
+               query local and remote NTP peers for state variables and
+               related timekeeping information. This program conforms
+               to Appendix A of the NTP Version 3 Specification RFC 1305.
+
+ntptrace        Directory containing sources for a utility program that
+               can be used to reveal the chain of NTP peers from a
+               designated peer to the primary server at the root of the
+               timekeeping subnet.
+
+parse          Directory containing files belonging to the generic
+               parse reference clock driver. For reasonably simple
+               clocks it is possible to get away with about 3-4Kb of
+               code. additionally the SunOS 4.x/Solaris 5.3 streams
+               module for parse squats here.
+
+patches                Directory containing patches already applied to this
+               distribution. These are included for record and to help
+               in possible porting problems.
+
+scripts                Directory containing scripts to build the configuration
+               files in this directory and then the makefiles used in
+               various dependent directories. the subdirectories
+               monitoring and support hold various perl and shell
+               scripts for visualizing synchronization and daemon startup.
+
+stamp.h.in     Configuration file generated automatically from configure.in.
+               Do not edit.
+
+util            Directory containing sources for various utility and
+               testing programs.
+
+David L. Mills (mills@udel.edu)
+21 June 1998
diff --git a/README.bk b/README.bk
new file mode 100644 (file)
index 0000000..8d8b296
--- /dev/null
+++ b/README.bk
@@ -0,0 +1,7 @@
+In order to use the BitKeeper repository version of NTP you should visit
+
+ http://support.ntp.org/Main/SoftwareDevelopment
+
+for important information.
+
+If you want to submit patches, please see the README.hackers file.
diff --git a/README.hackers b/README.hackers
new file mode 100644 (file)
index 0000000..a33b004
--- /dev/null
@@ -0,0 +1,28 @@
+Notes to hackers.
+
+See README.patches for information about submitting patches.
+
+---
+
+Dave likes this code indented formatted in a consistent way.
+The file "dot.emacs" has the emacs C-mode indentation style that Dave likes.
+
+---
+
+NTP4 uses ANSI C.  Some folks are blessed with a pre-ansi C compiler.  We
+support them by using "ansi2knr" in the Makefiles, which is automatically
+detected and selected by the configure process.
+
+For ansi2knr to work, we MUST define functions as follows:
+
+type stuff
+function_name ( actual parameters )
+
+While the whitespace is optional, the function name MUST start at column 0.
+
+---
+
+We'd like to see *all* system function declarations live in include/l_stdlib.h
+and NEVER appear in the .c files.
+
+---
diff --git a/README.patches b/README.patches
new file mode 100644 (file)
index 0000000..f4cf755
--- /dev/null
@@ -0,0 +1,49 @@
+See README.hackers for notes on coding styles.
+
+The master copy of this information can be found at:
+
+ http://support.ntp.org/Dev/MaintainerIssues#How_to_work_on_a_bug_using_BitKe
+
+If you are going to patch both ntp-stable and ntp-dev
+please do it this way:
+
+ > cd ntp-stable
+ > (make and test your changes to ntp-stable first)
+ > (commit your changes to ntp-stable)
+ > cd ../ntp-dev
+ > bk pull ../ntp-stable       (get your changes from ntp-stable)
+ > (resolve any problems and test your changes)
+ > (commit your changes to ntp-dev)
+
+With the current release of bitkeeper it is *much* easier to move changes
+from ntp-stable to ntp-dev than it is to move changes from ntp-dev to
+ntp-stable.
+
+If you make your changes in the above order and then submit them,
+it will be trivial to apply your patches.
+
+Otherwise, it will be much more difficult to apply your patches.
+
+You are pretty much done now if your repos are on pogo.udel.edu.
+
+If these patches are for a bugzilla issue, mark the issue as Resolved/READY
+with a comment of "Please pick up the patches in pogo:/wherever"
+
+---
+
+Please read (and follow) the previous section if you want to submit
+patches for both ntp-stable and ntp-dev.
+
+If you cannot easily get your patches to pogo, you may submit patches
+via the 'bk send' command:
+
+ > cd REPO
+ > bk citool   (or bk ci ... ;  bk commit ... )
+ > bk pull     # make sure your repo is up-to-date
+ > bk send -d -ubk://www.ntp.org/home/bk/REPO - > file-containing-the-patch
+ > bk receive -vv -a < file-containing-the-patch
+               # Sanity check.
+
+ # Open a bugzilla item at <http://bugzilla.ntp.org>
+
+ # After the bug is opened, visit the bug and attach file-containing-the-patch
diff --git a/README.refclocks b/README.refclocks
new file mode 100644 (file)
index 0000000..99a2815
--- /dev/null
@@ -0,0 +1,50 @@
+This is a list of the #define REFCLK_* stuff.
+
+If you want to add a new refclock let us know and we'll assign you a number.
+
+Should this list also include the name of the party responsible for the
+refclock?
+
+LOCALCLOCK     1       /* external (e.g., lockclock) */
+GPS_TRAK       2       /* TRAK 8810 GPS Receiver */
+WWV_PST                3       /* PST/Traconex 1020 WWV/H */
+SPECTRACOM     4       /* Spectracom (generic) Receivers */
+TRUETIME       5       /* TrueTime (generic) Receivers */
+IRIG_AUDIO     6       /* IRIG-B/W audio decoder */
+CHU_AUDIO      7       /* CHU audio demodulator/decoder */
+PARSE          8       /* generic driver (usually DCF77,GPS,MSF) */
+GPS_MX4200     9       /* Magnavox MX4200 GPS */
+GPS_AS2201     10      /* Austron 2201A GPS */
+GPS_ARBITER    11      /* Arbiter 1088A/B/ GPS */
+IRIG_TPRO      12      /* KSI/Odetics TPRO-S IRIG */
+ATOM_LEITCH    13      /* Leitch CSD 5300 Master Clock */
+MSF_EES                14      /* EES M201 MSF Receiver */
+GPSTM_TRUE     15      /* OLD TrueTime GPS/TM-TMD Receiver */
+IRIG_BANCOMM   16      /* Bancomm GPS/IRIG Interface */
+GPS_DATUM      17      /* Datum Programmable Time System */
+NIST_ACTS      18      /* NIST Auto Computer Time Service */
+WWV_HEATH      19      /* Heath GC1000 WWV/WWVH Receiver */
+GPS_NMEA       20      /* NMEA based GPS clock */
+GPS_VME                21      /* TrueTime GPS-VME Interface */
+ATOM_PPS       22      /* 1-PPS Clock Discipline */
+PTB_ACTS       NIST_ACTS
+USNO           NIST_ACTS
+GPS_HP         26      /* HP 58503A Time/Frequency Receiver */
+ARCRON_MSF     27      /* ARCRON MSF radio clock. */
+SHM            28      /* clock attached thru shared memory */
+PALISADE       29      /* Trimble Navigation Palisade GPS */
+ONCORE         30      /* Motorola UT Oncore GPS */
+GPS_JUPITER    31      /* Rockwell Jupiter GPS receiver */
+CHRONOLOG      32      /* Chrono-log K WWVB receiver */
+DUMBCLOCK      33      /* Dumb localtime clock */
+ULINK          34      /* Ultralink M320 WWVB receiver */
+PCF            35      /* Conrad parallel port radio clock */
+WWV_AUDIO      36      /* WWV/H audio demodulator/decoder */
+FG             37      /* Forum Graphic GPS */
+HOPF_SERIAL    38      /* hopf DCF77/GPS serial line receiver */
+HOPF_PCI       39      /* hopf DCF77/GPS PCI receiver */
+JJY            40      /* JJY receiver */
+TT560          41      /* TrueTime 560 IRIG-B decoder */
+ZYFER          42      /* Zyfer GPStarplus receiver */
+RIPENCC                43      /* RIPE NCC Trimble driver */
+???????                44      Claas Hilbrecht (20020711)
diff --git a/README.versions b/README.versions
new file mode 100644 (file)
index 0000000..018d59d
--- /dev/null
@@ -0,0 +1,27 @@
+
+NTP uses A.B.C - style release numbers.
+
+At the moment:
+
+ A is 4, for ntp V4.
+ B is the major release number.
+ C is the minor release number.  Even numbers are 'stable' releases and
+ odd numbers are "development" releases.
+
+Following the release number may be the letter 'p' followed by a number.
+This indicates a point (or patch) release.
+
+Release candidates have -RC in the release number.
+
+Here are some recent versions numbers as an example:
+
+ 4.2.2         A production release (from the ntp-stable repository)
+ 4.2.2p2       A production release (from the ntp-stable repository)
+ 4.2.3p12      A development release
+ 4.2.3p15-rc1  A release candidate for 4.2.4
+
+Note that after the ntp-dev repo produces a production release it will
+be copied into the ntp-stable and the cycle will repeat.
+
+Feel free to suggest improvements...
+
diff --git a/TODO b/TODO
new file mode 100644 (file)
index 0000000..e72ee7b
--- /dev/null
+++ b/TODO
@@ -0,0 +1,122 @@
+
+      *** IF YOU CAN HELP FIX ANY OF THESE THINGS, PLEASE DO! ***
+
+010402: Look harder at -lm and -lelf - they are needed less and less...
+
+970711: Look Real Hard at changing the key stuff from u_long to u_int32.
+
+970711: Make sure it's safe to convert proto_config's 2nd argument from
+       u_long to u_int32.  Watch "set" in ntp_request.c:setclr_flags().
+
+970318: in hourly_stats(?), squawk if the magnitude of the drift is,
+       say, >400.
+
+970301: Implement the utmp/wtmp timestamping on time steps.
+
+970210: Find a way to dump the current configuration to either syslog or
+       a file.
+
+Problems that need to be fixed:
+
+- Get rid of the old SYS_* macros:
+  (It's worth noting that any code that would have been "enabled" by any
+  of these macros has not been used since 5.83, and there have been very
+  few complaints...)
+
+  SYS_44BSD:
+   authstuff/md5driver.c
+
+  SYS_BSDI:
+   authstuff/md5driver.c
+
+  SYS_DECOSF1:
+   util/ntptime.c
+
+  SYS_DOMAINOS:
+   parseutil/dcfd.c
+   xntpd/ntpd.c
+
+  SYS_HPUX:
+   kernel/sys/ppsclock.h
+   ntpdate/ntpdate.c
+   ntptrace/ntptrace.c
+
+  SYS_PTX:
+   libntp/machines.c
+
+  SYS_SOLARIS:
+   libparse/parse.c
+   libparse/clk_trimtsip.c
+   xntpd/ntp_io.c
+   xntpd/ntp_refclock.c
+   xntpd/ntpd.c
+
+  SYS_SUNOS4:
+   libparse/parse.c
+   libparse/clk_trimsip.c
+
+  SYS_WINNT:
+   include/ntp.h
+   include/ntp_fp.h
+   include/ntp_if.h
+   include/ntp_machine.h
+   include/ntp_select.h
+   include/ntp_syslog.h
+   include/ntp_unixtime.h
+   include/ntpd.h
+   libntp/libntp.mak
+   libntp/machines.c
+   libntp/mexit.c
+   libntp/msyslog.c
+   libntp/systime.c
+   ntpdate/ntpdate.c
+   ntpdate/ntpdate.mak
+   ntpq/ntpq.c
+   ntpq/ntpq.mak
+   ntpq/ntpq_ops.c
+   ntptrace/ntptrace.c
+   ntptrace/ntptrace.mak
+   xntpd/ntp_config.c
+   xntpd/ntp_filegen.c
+   xntpd/ntp_intres.c
+   xntpd/ntp_io.c
+   xntpd/ntp_loopfilter.c
+   xntpd/ntp_peer.c
+   xntpd/ntp_proto.c
+   xntpd/ntp_refclock.c
+   xntpd/ntp_timer.c
+   xntpd/ntp_unixclock.c
+   xntpd/ntp_util.c
+   xntpd/ntpd.c
+   xntpd/xntpd.mak
+   xntpdc/ntpdc.c
+   xntpdc/xntpdc.mak
+
+- config.guess might need help to identify:
+
+  Fujitsu's UXP                                --enable-adjtime-is-accurate
+                                       --enable-step-slew
+
+  Unixware                             --enable-adjtime-is-accurate
+                                       --enable-tick=10000
+                                       --enable-tickadj=80
+                                       --enable-udp-wildcard
+                                       --disable-step-slew
+
+  DomainOS                             --enable-adjtime-is-accurate
+                                       --disable-kmem
+                                       --enable-tick=1000000
+
+  OpenVMS                              --enable-slew-always
+                                       --enable-hourly-todr-sync
+
+  Is adjtime accurate on ALL sysv4* machines?
+  Can we identify DomainOS with *-apollo-* ?
+  Do we catch all Unixware machines with *-univel-sysv* ?
+
+- Combine enable-step-slew and enable-ntpdate-step
+
+- Make sure enable-hourly-todr-sync is always disabled
+  What about NextStep and OpenVMS, where hourly TODR sync used to be enabled?
+
+- Check dcfd.c for variables that need to be volatile.
diff --git a/WHERE-TO-START b/WHERE-TO-START
new file mode 100644 (file)
index 0000000..fb96137
--- /dev/null
@@ -0,0 +1,41 @@
+The Network Time Protocol (NTP) Version 4 Distribution
+
+This is a distribution of the Network Time Protocol (NTP) Version 4
+sources and documentation. NTP can be used by Unix, DEC VMS and
+Microsoft Windows NT platforms to synchronize the computer clock to
+external sources of time, such as other NTP time servers or a local
+radio clock. The daemon included in this distribution can operate as a
+server, a client, or a relay from a set of servers to a dependent client
+population on a local net. This distribution includes the daemon itself,
+plus utility programs and supporting documentation.
+
+You are welcome to the lot, with due consideration of the copyright
+information in the COPYRIGHT file. You are also invited to contribute
+bugfixes and drivers for new and exotic radios, telephones and sundials.
+This distribution is normally available by anonymous ftp as the
+compressed tar archive ntp-<version>.tar.gz in the pub/ntp directory on
+huey.udel.edu and <version> is the version number. The current stable
+and development version numbers can be found at <http://ntp.org>.
+
+A considerable amount of documentation, including build instructions,
+configuration advice, program usage and miscellaneous information is
+included in the ./html directory of this distribution. The intended
+access method is using a web browser such as netscape; however, the
+pages have been formatted so that viewing with an ordinary text editor
+is practical. Start the browser on the ./html/index.html page, which
+contains additional instructions and hotlinks to the remaining pages.
+Some hotlinks for the larger documents, such as related technical
+memoranda, reports and papers, lead to other web sites where this
+information is stashed. We apologize for the inconvenience this may
+cause for users without Internet and World Wide Web access.
+
+If you are an old hand and just want to build the distribution, you
+might find the INSTALL file a useful shortcut. A descriptive list of all
+files in the base directory of this distribution is in the README file.
+A list of "significant" changes for the release is in the NEWS file.
+
+If you're interested in helping us test pre-release versions of ntpd,
+please look in <ftp://huey.udel.edu/pub/ntp/testing/>.
+
+David L. Mills (mills@udel.edu)
+21 June 1998
diff --git a/aclocal.m4 b/aclocal.m4
new file mode 100644 (file)
index 0000000..69c2849
--- /dev/null
@@ -0,0 +1,7192 @@
+# generated automatically by aclocal 1.11 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+# This file 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
+[m4_warning([this file was generated for autoconf 2.65.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
+
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+
+# serial 47 AC_PROG_LIBTOOL
+
+
+# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
+# -----------------------------------------------------------
+# If this macro is not defined by Autoconf, define it here.
+m4_ifdef([AC_PROVIDE_IFELSE],
+         [],
+         [m4_define([AC_PROVIDE_IFELSE],
+                [m4_ifdef([AC_PROVIDE_$1],
+                          [$2], [$3])])])
+
+
+# AC_PROG_LIBTOOL
+# ---------------
+AC_DEFUN([AC_PROG_LIBTOOL],
+[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
+dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
+dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
+  AC_PROVIDE_IFELSE([AC_PROG_CXX],
+    [AC_LIBTOOL_CXX],
+    [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
+  ])])
+dnl And a similar setup for Fortran 77 support
+  AC_PROVIDE_IFELSE([AC_PROG_F77],
+    [AC_LIBTOOL_F77],
+    [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
+])])
+
+dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
+dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
+dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
+  AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+    [AC_LIBTOOL_GCJ],
+    [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+      [AC_LIBTOOL_GCJ],
+      [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
+       [AC_LIBTOOL_GCJ],
+      [ifdef([AC_PROG_GCJ],
+            [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+       ifdef([A][M_PROG_GCJ],
+            [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+       ifdef([LT_AC_PROG_GCJ],
+            [define([LT_AC_PROG_GCJ],
+               defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
+])])# AC_PROG_LIBTOOL
+
+
+# _AC_PROG_LIBTOOL
+# ----------------
+AC_DEFUN([_AC_PROG_LIBTOOL],
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Prevent multiple expansion
+define([AC_PROG_LIBTOOL], [])
+])# _AC_PROG_LIBTOOL
+
+
+# AC_LIBTOOL_SETUP
+# ----------------
+AC_DEFUN([AC_LIBTOOL_SETUP],
+[AC_PREREQ(2.50)dnl
+AC_REQUIRE([AC_ENABLE_SHARED])dnl
+AC_REQUIRE([AC_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_LD])dnl
+AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+
+AC_REQUIRE([AC_PROG_LN_S])dnl
+AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+AC_REQUIRE([AC_OBJEXT])dnl
+AC_REQUIRE([AC_EXEEXT])dnl
+dnl
+
+AC_LIBTOOL_SYS_MAX_CMD_LEN
+AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+AC_LIBTOOL_OBJDIR
+
+AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+_LT_AC_PROG_ECHO_BACKSLASH
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
+
+# Same as above, but do not quote variable references.
+[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Constants:
+rm="rm -f"
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+AC_CHECK_TOOL(AR, ar, false)
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+AC_CHECK_TOOL(STRIP, strip, :)
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+test -z "$AS" && AS=as
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$LD" && LD=ld
+test -z "$LN_S" && LN_S="ln -s"
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+test -z "$NM" && NM=nm
+test -z "$SED" && SED=sed
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+    ;;
+  *)
+    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    AC_PATH_MAGIC
+  fi
+  ;;
+esac
+
+AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+enable_win32_dll=yes, enable_win32_dll=no)
+
+AC_ARG_ENABLE([libtool-lock],
+    [AC_HELP_STRING([--disable-libtool-lock],
+       [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+AC_ARG_WITH([pic],
+    [AC_HELP_STRING([--with-pic],
+       [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+    [pic_mode="$withval"],
+    [pic_mode=default])
+test -z "$pic_mode" && pic_mode=default
+
+# Use C for the default configuration in the libtool script
+tagname=
+AC_LIBTOOL_LANG_C_CONFIG
+_LT_AC_TAGCONFIG
+])# AC_LIBTOOL_SETUP
+
+
+# _LT_AC_SYS_COMPILER
+# -------------------
+AC_DEFUN([_LT_AC_SYS_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_AC_SYS_COMPILER
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+AC_DEFUN([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+  case $cc_temp in
+    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+])
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+AC_DEFUN([_LT_COMPILER_BOILERPLATE],
+[ac_outfile=conftest.$ac_objext
+printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+AC_DEFUN([_LT_LINKER_BOILERPLATE],
+[ac_outfile=conftest.$ac_objext
+printf "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm conftest*
+])# _LT_LINKER_BOILERPLATE
+
+
+# _LT_AC_SYS_LIBPATH_AIX
+# ----------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
+[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi],[])
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+])# _LT_AC_SYS_LIBPATH_AIX
+
+
+# _LT_AC_SHELL_INIT(ARG)
+# ----------------------
+AC_DEFUN([_LT_AC_SHELL_INIT],
+[ifdef([AC_DIVERSION_NOTICE],
+            [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+        [AC_DIVERT_PUSH(NOTICE)])
+$1
+AC_DIVERT_POP
+])# _LT_AC_SHELL_INIT
+
+
+# _LT_AC_PROG_ECHO_BACKSLASH
+# --------------------------
+# Add some code to the start of the generated configure script which
+# will find an echo command which doesn't interpret backslashes.
+AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
+[_LT_AC_SHELL_INIT([
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+  ;;
+esac
+
+echo=${ECHO-echo}
+if test "X[$]1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X[$]1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+fi
+
+if test "X[$]1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+[$]*
+EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$ECHO"; then
+if test "X${echo_test_string+set}" != Xset; then
+# find a string as large as possible, as long as the shell can cope with it
+  for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+       echo_test_string=`eval $cmd` &&
+       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+    then
+      break
+    fi
+  done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+   echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+   test "X$echo_testing_string" = "X$echo_test_string"; then
+  :
+else
+  # The Solaris, AIX, and Digital Unix default echo programs unquote
+  # backslashes.  This makes it impossible to quote backslashes using
+  #   echo "$something" | sed 's/\\/\\\\/g'
+  #
+  # So, first we look for a working echo in the user's PATH.
+
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for dir in $PATH /usr/ucb; do
+    IFS="$lt_save_ifs"
+    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      echo="$dir/echo"
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  if test "X$echo" = Xecho; then
+    # We didn't find a better echo, so look for alternatives.
+    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      # This shell has a builtin print -r that does the trick.
+      echo='print -r'
+    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+        test "X$CONFIG_SHELL" != X/bin/ksh; then
+      # If we have ksh, try running configure again with it.
+      ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+      export ORIGINAL_CONFIG_SHELL
+      CONFIG_SHELL=/bin/ksh
+      export CONFIG_SHELL
+      exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+    else
+      # Try using printf.
+      echo='printf %s\n'
+      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+        echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+        test "X$echo_testing_string" = "X$echo_test_string"; then
+       # Cool, printf works
+       :
+      elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+          test "X$echo_testing_string" = 'X\t' &&
+          echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+          test "X$echo_testing_string" = "X$echo_test_string"; then
+       CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+       export CONFIG_SHELL
+       SHELL="$CONFIG_SHELL"
+       export SHELL
+       echo="$CONFIG_SHELL [$]0 --fallback-echo"
+      elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+          test "X$echo_testing_string" = 'X\t' &&
+          echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+          test "X$echo_testing_string" = "X$echo_test_string"; then
+       echo="$CONFIG_SHELL [$]0 --fallback-echo"
+      else
+       # maybe with a smaller string...
+       prev=:
+
+       for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+         if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+         then
+           break
+         fi
+         prev="$cmd"
+       done
+
+       if test "$prev" != 'sed 50q "[$]0"'; then
+         echo_test_string=`eval $prev`
+         export echo_test_string
+         exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+       else
+         # Oops.  We lost completely, so just stick with echo.
+         echo=echo
+       fi
+      fi
+    fi
+  fi
+fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+ECHO=$echo
+if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+   ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+fi
+
+AC_SUBST(ECHO)
+])])# _LT_AC_PROG_ECHO_BACKSLASH
+
+
+# _LT_AC_LOCK
+# -----------
+AC_DEFUN([_LT_AC_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+    [AC_HELP_STRING([--disable-libtool-lock],
+       [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *ELF-32*)
+      HPUX_IA64_MODE="32"
+      ;;
+    *ELF-64*)
+      HPUX_IA64_MODE="64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+   if test "$lt_cv_prog_gnu_ld" = yes; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -melf32bsmip"
+      ;;
+    *N32*)
+      LD="${LD-ld} -melf32bmipn32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -melf64bmip"
+      ;;
+    esac
+   else
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+   fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *32-bit*)
+      case $host in
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_i386"
+          ;;
+        ppc64-*linux*|powerpc64-*linux*)
+          LD="${LD-ld} -m elf32ppclinux"
+          ;;
+        s390x-*linux*)
+          LD="${LD-ld} -m elf_s390"
+          ;;
+        sparc64-*linux*)
+          LD="${LD-ld} -m elf32_sparc"
+          ;;
+      esac
+      ;;
+    *64-bit*)
+      case $host in
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        ppc*-*linux*|powerpc*-*linux*)
+          LD="${LD-ld} -m elf64ppc"
+          ;;
+        s390*-*linux*)
+          LD="${LD-ld} -m elf64_s390"
+          ;;
+        sparc*-*linux*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_LANG_PUSH(C)
+     AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+     AC_LANG_POP])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+  ])
+esac
+
+need_locks="$enable_libtool_lock"
+
+])# _LT_AC_LOCK
+
+
+# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#              [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
+[AC_REQUIRE([LT_AC_PROG_SED])
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+  ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$3"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+       $2=yes
+     fi
+   fi
+   $rm conftest*
+])
+
+if test x"[$]$2" = xyes; then
+    ifelse([$5], , :, [$5])
+else
+    ifelse([$6], , :, [$6])
+fi
+])# AC_LIBTOOL_COMPILER_OPTION
+
+
+# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#                          [ACTION-SUCCESS], [ACTION-FAILURE])
+# ------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
+[AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $3"
+   printf "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&AS_MESSAGE_LOG_FD
+       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
+       $SED '/^$/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         $2=yes
+       fi
+     else
+       $2=yes
+     fi
+   fi
+   $rm conftest*
+   LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+    ifelse([$4], , :, [$4])
+else
+    ifelse([$5], , :, [$5])
+fi
+])# AC_LIBTOOL_LINKER_OPTION
+
+
+# AC_LIBTOOL_SYS_MAX_CMD_LEN
+# --------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
+[# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+  i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536      # usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  *)
+    # If test is not a shell built-in, we'll probably end up computing a
+    # maximum length that is only half of the actual maximum length, but
+    # we can't tell.
+    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+    while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+              = "XX$teststring") >/dev/null 2>&1 &&
+           new_result=`expr "X$teststring" : ".*" 2>&1` &&
+           lt_cv_sys_max_cmd_len=$new_result &&
+           test $i != 17 # 1/2 MB should be enough
+    do
+      i=`expr $i + 1`
+      teststring=$teststring$teststring
+    done
+    teststring=
+    # Add a significant safety factor because C++ compilers can tack on massive
+    # amounts of additional arguments before passing them to the linker.
+    # It appears as though 1/2 is a usable value.
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    ;;
+  esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+  AC_MSG_RESULT(none)
+fi
+])# AC_LIBTOOL_SYS_MAX_CMD_LEN
+
+
+# _LT_AC_CHECK_DLFCN
+# --------------------
+AC_DEFUN([_LT_AC_CHECK_DLFCN],
+[AC_CHECK_HEADERS(dlfcn.h)dnl
+])# _LT_AC_CHECK_DLFCN
+
+
+# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+#                           ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ------------------------------------------------------------------
+AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+  [$4]
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+[#line __oline__ "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}]
+EOF
+  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) $1 ;;
+      x$lt_dlneed_uscore) $2 ;;
+      x$lt_unknown|x*) $3 ;;
+    esac
+  else :
+    # compilation failed
+    $3
+  fi
+fi
+rm -fr conftest*
+])# _LT_AC_TRY_DLOPEN_SELF
+
+
+# AC_LIBTOOL_DLOPEN_SELF
+# -------------------
+AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    AC_CHECK_LIB([dl], [dlopen],
+               [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ])
+   ;;
+
+  *)
+    AC_CHECK_FUNC([shl_load],
+         [lt_cv_dlopen="shl_load"],
+      [AC_CHECK_LIB([dld], [shl_load],
+           [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+       [AC_CHECK_FUNC([dlopen],
+             [lt_cv_dlopen="dlopen"],
+         [AC_CHECK_LIB([dl], [dlopen],
+               [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+           [AC_CHECK_LIB([svld], [dlopen],
+                 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+             [AC_CHECK_LIB([dld], [dld_link],
+                   [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+             ])
+           ])
+         ])
+       ])
+      ])
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    AC_CACHE_CHECK([whether a program can dlopen itself],
+         lt_cv_dlopen_self, [dnl
+         _LT_AC_TRY_DLOPEN_SELF(
+           lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+           lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+    ])
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      LDFLAGS="$LDFLAGS $link_static_flag"
+      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+         lt_cv_dlopen_self_static, [dnl
+         _LT_AC_TRY_DLOPEN_SELF(
+           lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+           lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
+      ])
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+])# AC_LIBTOOL_DLOPEN_SELF
+
+
+# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
+# ---------------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler
+AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
+[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+  [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+  [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
+     $SED '/^$/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+     fi
+   fi
+   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+])
+])# AC_LIBTOOL_PROG_CC_C_O
+
+
+# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
+# -----------------------------------------
+# Check to see if we can do hard links to lock some files if needed
+AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
+[AC_REQUIRE([_LT_AC_LOCK])dnl
+
+hard_links="nottested"
+if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  AC_MSG_CHECKING([if we can lock with hard links])
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  AC_MSG_RESULT([$hard_links])
+  if test "$hard_links" = no; then
+    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
+
+
+# AC_LIBTOOL_OBJDIR
+# -----------------
+AC_DEFUN([AC_LIBTOOL_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+])# AC_LIBTOOL_OBJDIR
+
+
+# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
+# ----------------------------------------------
+# Check hardcoding attributes.
+AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_AC_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
+   test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
+   test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+     test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
+    # Linking always hardcodes the temporary library directory.
+    _LT_AC_TAGVAR(hardcode_action, $1)=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    _LT_AC_TAGVAR(hardcode_action, $1)=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
+
+
+# AC_LIBTOOL_SYS_LIB_STRIP
+# ------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
+[striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         AC_MSG_RESULT([yes])
+       else
+  AC_MSG_RESULT([no])
+fi
+       ;;
+   *)
+  AC_MSG_RESULT([no])
+    ;;
+  esac
+fi
+])# AC_LIBTOOL_SYS_LIB_STRIP
+
+
+# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
+[AC_MSG_CHECKING([dynamic linker characteristics])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix4* | aix5*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[[01]] | aix4.[[01]].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[[45]]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+  if test "$GCC" = yes; then
+    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+  else
+    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+  fi
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+kfreebsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[[123]]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  *) # from 3.2 on
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,   ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+knetbsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[[89]] | openbsd2.[[89]].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+
+
+# _LT_AC_TAGCONFIG
+# ----------------
+AC_DEFUN([_LT_AC_TAGCONFIG],
+[AC_ARG_WITH([tags],
+    [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
+        [include additional configurations @<:@automatic@:>@])],
+    [tagnames="$withval"])
+
+if test -f "$ltmain" && test -n "$tagnames"; then
+  if test ! -f "${ofile}"; then
+    AC_MSG_WARN([output file `$ofile' does not exist])
+  fi
+
+  if test -z "$LTCC"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+    if test -z "$LTCC"; then
+      AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
+    else
+      AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
+    fi
+  fi
+
+  # Extract list of available tagged configurations in $ofile.
+  # Note that this assumes the entire list is on one line.
+  available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
+
+  lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+  for tagname in $tagnames; do
+    IFS="$lt_save_ifs"
+    # Check whether tagname contains only valid characters
+    case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
+    "") ;;
+    *)  AC_MSG_ERROR([invalid tag name: $tagname])
+       ;;
+    esac
+
+    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+    then
+      AC_MSG_ERROR([tag name \"$tagname\" already exists])
+    fi
+
+    # Update the list of available tags.
+    if test -n "$tagname"; then
+      echo appending configuration tag \"$tagname\" to $ofile
+
+      case $tagname in
+      CXX)
+       if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+           ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+           (test "X$CXX" != "Xg++"))) ; then
+         AC_LIBTOOL_LANG_CXX_CONFIG
+       else
+         tagname=""
+       fi
+       ;;
+
+      F77)
+       if test -n "$F77" && test "X$F77" != "Xno"; then
+         AC_LIBTOOL_LANG_F77_CONFIG
+       else
+         tagname=""
+       fi
+       ;;
+
+      GCJ)
+       if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+         AC_LIBTOOL_LANG_GCJ_CONFIG
+       else
+         tagname=""
+       fi
+       ;;
+
+      RC)
+       AC_LIBTOOL_LANG_RC_CONFIG
+       ;;
+
+      *)
+       AC_MSG_ERROR([Unsupported tag name: $tagname])
+       ;;
+      esac
+
+      # Append the new tag name to the list of available tags.
+      if test -n "$tagname" ; then
+      available_tags="$available_tags $tagname"
+    fi
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  # Now substitute the updated list of available tags.
+  if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+    mv "${ofile}T" "$ofile"
+    chmod +x "$ofile"
+  else
+    rm -f "${ofile}T"
+    AC_MSG_ERROR([unable to update list of available tagged configurations.])
+  fi
+fi
+])# _LT_AC_TAGCONFIG
+
+
+# AC_LIBTOOL_DLOPEN
+# -----------------
+# enable checks for dlopen support
+AC_DEFUN([AC_LIBTOOL_DLOPEN],
+ [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
+])# AC_LIBTOOL_DLOPEN
+
+
+# AC_LIBTOOL_WIN32_DLL
+# --------------------
+# declare package support for building win32 DLLs
+AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
+])# AC_LIBTOOL_WIN32_DLL
+
+
+# AC_ENABLE_SHARED([DEFAULT])
+# ---------------------------
+# implement the --enable-shared flag
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_SHARED],
+[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([shared],
+    [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+       [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_shared=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
+])# AC_ENABLE_SHARED
+
+
+# AC_DISABLE_SHARED
+# -----------------
+#- set the default shared flag to --disable-shared
+AC_DEFUN([AC_DISABLE_SHARED],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_SHARED(no)
+])# AC_DISABLE_SHARED
+
+
+# AC_ENABLE_STATIC([DEFAULT])
+# ---------------------------
+# implement the --enable-static flag
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_STATIC],
+[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([static],
+    [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+       [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_static=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_static=]AC_ENABLE_STATIC_DEFAULT)
+])# AC_ENABLE_STATIC
+
+
+# AC_DISABLE_STATIC
+# -----------------
+# set the default static flag to --disable-static
+AC_DEFUN([AC_DISABLE_STATIC],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_STATIC(no)
+])# AC_DISABLE_STATIC
+
+
+# AC_ENABLE_FAST_INSTALL([DEFAULT])
+# ---------------------------------
+# implement the --enable-fast-install flag
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_FAST_INSTALL],
+[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([fast-install],
+    [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+    [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_fast_install=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
+])# AC_ENABLE_FAST_INSTALL
+
+
+# AC_DISABLE_FAST_INSTALL
+# -----------------------
+# set the default to --disable-fast-install
+AC_DEFUN([AC_DISABLE_FAST_INSTALL],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_FAST_INSTALL(no)
+])# AC_DISABLE_FAST_INSTALL
+
+
+# AC_LIBTOOL_PICMODE([MODE])
+# --------------------------
+# implement the --with-pic flag
+# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+AC_DEFUN([AC_LIBTOOL_PICMODE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+pic_mode=ifelse($#,1,$1,default)
+])# AC_LIBTOOL_PICMODE
+
+
+# AC_PROG_EGREP
+# -------------
+# This is predefined starting with Autoconf 2.54, so this conditional
+# definition can be removed once we require Autoconf 2.54 or later.
+m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
+[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+   [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi])
+ EGREP=$ac_cv_prog_egrep
+ AC_SUBST([EGREP])
+])])
+
+
+# AC_PATH_TOOL_PREFIX
+# -------------------
+# find a file program which can recognise shared library
+AC_DEFUN([AC_PATH_TOOL_PREFIX],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] |  ?:[\\/]*])
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+  ac_dummy="ifelse([$2], , $PATH, [$2])"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$1; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  AC_MSG_RESULT($MAGIC_CMD)
+else
+  AC_MSG_RESULT(no)
+fi
+])# AC_PATH_TOOL_PREFIX
+
+
+# AC_PATH_MAGIC
+# -------------
+# find a file program which can recognise a shared library
+AC_DEFUN([AC_PATH_MAGIC],
+[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+  else
+    MAGIC_CMD=:
+  fi
+fi
+])# AC_PATH_MAGIC
+
+
+# AC_PROG_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([AC_PROG_LD],
+[AC_ARG_WITH([gnu-ld],
+    [AC_HELP_STRING([--with-gnu-ld],
+       [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+    [test "$withval" = no || with_gnu_ld=yes],
+    [with_gnu_ld=no])
+AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by $CC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]]* | ?:[[\\/]]*)
+      re_direlt='/[[^/]][[^/]]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+       test "$with_gnu_ld" != no && break
+       ;;
+      *)
+       test "$with_gnu_ld" != yes && break
+       ;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_PROG_LD_GNU
+])# AC_PROG_LD
+
+
+# AC_PROG_LD_GNU
+# --------------
+AC_DEFUN([AC_PROG_LD_GNU],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# AC_PROG_LD_GNU
+
+
+# AC_PROG_LD_RELOAD_FLAG
+# ----------------------
+# find reload flag for linker
+#   -- PORTME Some linkers may need a different reload flag.
+AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+  lt_cv_ld_reload_flag,
+  [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+])# AC_PROG_LD_RELOAD_FLAG
+
+
+# AC_DEPLIBS_CHECK_METHOD
+# -----------------------
+# how to check for library dependencies
+#  -- PORTME fill in with the dynamic library characteristics
+AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
+[AC_CACHE_CHECK([how to recognise dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix4* | aix5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[[45]]*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump'.
+  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | kfreebsd*-gnu | dragonfly*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+nto-qnx*)
+  lt_cv_deplibs_check_method=unknown
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sco3.2v5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+])# AC_DEPLIBS_CHECK_METHOD
+
+
+# AC_PROG_NM
+# ----------
+# find the pathname to a BSD-compatible name lister
+AC_DEFUN([AC_PROG_NM],
+[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    tmp_nm="$ac_dir/${ac_tool_prefix}nm"
+    if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      # Tru64's nm complains that /dev/null is an invalid object file
+      case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+      */dev/null* | *'Invalid file or object type'*)
+       lt_cv_path_NM="$tmp_nm -B"
+       break
+        ;;
+      *)
+       case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+       */dev/null*)
+         lt_cv_path_NM="$tmp_nm -p"
+         break
+         ;;
+       *)
+         lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+         continue # so that we can try to find one that supports BSD flags
+         ;;
+       esac
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi])
+NM="$lt_cv_path_NM"
+])# AC_PROG_NM
+
+
+# AC_CHECK_LIBM
+# -------------
+# check for math library
+AC_DEFUN([AC_CHECK_LIBM],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+  # These system don't have libm, or don't need it
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  ;;
+esac
+])# AC_CHECK_LIBM
+
+
+# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
+# -----------------------------------
+# sets LIBLTDL to the link flags for the libltdl convenience library and
+# LTDLINCL to the include flags for the libltdl header and adds
+# --enable-ltdl-convenience to the configure arguments.  Note that
+# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
+# it is assumed to be `libltdl'.  LIBLTDL will be prefixed with
+# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
+# (note the single quotes!).  If your package is not flat and you're not
+# using automake, define top_builddir and top_srcdir appropriately in
+# the Makefiles.
+AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  case $enable_ltdl_convenience in
+  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+  "") enable_ltdl_convenience=yes
+      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+  esac
+  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+  LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  # For backwards non-gettext consistent compatibility...
+  INCLTDL="$LTDLINCL"
+])# AC_LIBLTDL_CONVENIENCE
+
+
+# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
+# -----------------------------------
+# sets LIBLTDL to the link flags for the libltdl installable library and
+# LTDLINCL to the include flags for the libltdl header and adds
+# --enable-ltdl-install to the configure arguments.  Note that
+# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
+# and an installed libltdl is not found, it is assumed to be `libltdl'.
+# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and top_srcdir
+# appropriately in the Makefiles.
+# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  AC_CHECK_LIB(ltdl, lt_dlinit,
+  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+  [if test x"$enable_ltdl_install" = xno; then
+     AC_MSG_WARN([libltdl not installed, but installation disabled])
+   else
+     enable_ltdl_install=yes
+   fi
+  ])
+  if test x"$enable_ltdl_install" = x"yes"; then
+    ac_configure_args="$ac_configure_args --enable-ltdl-install"
+    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+    LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  else
+    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+    LIBLTDL="-lltdl"
+    LTDLINCL=
+  fi
+  # For backwards non-gettext consistent compatibility...
+  INCLTDL="$LTDLINCL"
+])# AC_LIBLTDL_INSTALLABLE
+
+
+# AC_LIBTOOL_CXX
+# --------------
+# enable support for C++ libraries
+AC_DEFUN([AC_LIBTOOL_CXX],
+[AC_REQUIRE([_LT_AC_LANG_CXX])
+])# AC_LIBTOOL_CXX
+
+
+# _LT_AC_LANG_CXX
+# ---------------
+AC_DEFUN([_LT_AC_LANG_CXX],
+[AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
+])# _LT_AC_LANG_CXX
+
+# _LT_AC_PROG_CXXCPP
+# ---------------
+AC_DEFUN([_LT_AC_PROG_CXXCPP],
+[
+AC_REQUIRE([AC_PROG_CXX])
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  AC_PROG_CXXCPP
+fi
+])# _LT_AC_PROG_CXXCPP
+
+# AC_LIBTOOL_F77
+# --------------
+# enable support for Fortran 77 libraries
+AC_DEFUN([AC_LIBTOOL_F77],
+[AC_REQUIRE([_LT_AC_LANG_F77])
+])# AC_LIBTOOL_F77
+
+
+# _LT_AC_LANG_F77
+# ---------------
+AC_DEFUN([_LT_AC_LANG_F77],
+[AC_REQUIRE([AC_PROG_F77])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
+])# _LT_AC_LANG_F77
+
+
+# AC_LIBTOOL_GCJ
+# --------------
+# enable support for GCJ libraries
+AC_DEFUN([AC_LIBTOOL_GCJ],
+[AC_REQUIRE([_LT_AC_LANG_GCJ])
+])# AC_LIBTOOL_GCJ
+
+
+# _LT_AC_LANG_GCJ
+# ---------------
+AC_DEFUN([_LT_AC_LANG_GCJ],
+[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
+  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
+    [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
+      [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
+        [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
+          [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
+])# _LT_AC_LANG_GCJ
+
+
+# AC_LIBTOOL_RC
+# --------------
+# enable support for Windows resource files
+AC_DEFUN([AC_LIBTOOL_RC],
+[AC_REQUIRE([LT_AC_PROG_RC])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
+])# AC_LIBTOOL_RC
+
+
+# AC_LIBTOOL_LANG_C_CONFIG
+# ------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
+AC_DEFUN([_LT_AC_LANG_C_CONFIG],
+[lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}\n'
+
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+#
+# Check for any special shared library compilation flags.
+#
+_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)=
+if test "$GCC" = no; then
+  case $host_os in
+  sco3.2v5*)
+    _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf'
+    ;;
+  esac
+fi
+if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then
+  AC_MSG_WARN([`$CC' requires `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries])
+  if echo "$old_CC $old_CFLAGS " | grep "[[    ]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[        ]]" >/dev/null; then :
+  else
+    AC_MSG_WARN([add `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure])
+    _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no
+  fi
+fi
+
+
+#
+# Check to make sure the static flag actually works.
+#
+AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works],
+  _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
+  $_LT_AC_TAGVAR(lt_prog_compiler_static, $1),
+  [],
+  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
+
+
+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
+
+# Report which librarie types wil actually be built
+AC_MSG_CHECKING([if libtool supports shared libraries])
+AC_MSG_RESULT([$can_build_shared])
+
+AC_MSG_CHECKING([whether to build shared libraries])
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case $host_os in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+
+aix4* | aix5*)
+  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
+    ;;
+esac
+AC_MSG_RESULT([$enable_shared])
+
+AC_MSG_CHECKING([whether to build static libraries])
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+AC_MSG_RESULT([$enable_static])
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_C_CONFIG
+
+
+# AC_LIBTOOL_LANG_CXX_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
+AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
+[AC_LANG_PUSH(C++)
+AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+_LT_AC_TAGVAR(always_export_symbols, $1)=no
+_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_direct, $1)=no
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+_LT_AC_TAGVAR(module_cmds, $1)=
+_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_AC_TAGVAR(no_undefined_flag, $1)=
+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Dependencies to place before and after the object being linked:
+_LT_AC_TAGVAR(predep_objects, $1)=
+_LT_AC_TAGVAR(postdep_objects, $1)=
+_LT_AC_TAGVAR(predeps, $1)=
+_LT_AC_TAGVAR(postdeps, $1)=
+_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_LD=$LD
+lt_save_GCC=$GCC
+GCC=$GXX
+lt_save_with_gnu_ld=$with_gnu_ld
+lt_save_path_LD=$lt_cv_path_LD
+if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+  lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+else
+  unset lt_cv_prog_gnu_ld
+fi
+if test -n "${lt_cv_path_LDCXX+set}"; then
+  lt_cv_path_LD=$lt_cv_path_LDCXX
+else
+  unset lt_cv_path_LD
+fi
+test -z "${LDCXX+set}" || LD=$LDCXX
+CC=${CXX-"c++"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+# We don't want -fno-exception wen compiling C++ code, so set the
+# no_builtin_flag separately
+if test "$GXX" = yes; then
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+else
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+fi
+
+if test "$GXX" = yes; then
+  # Set up default GNU C++ configuration
+
+  AC_PROG_LD
+
+  # Check if GNU C++ uses GNU ld as the underlying linker, since the
+  # archiving commands below assume that GNU ld is being used.
+  if test "$with_gnu_ld" = yes; then
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+    #     investigate it a little bit more. (MM)
+    wlarc='${wl}'
+
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+       grep 'no-whole-archive' > /dev/null; then
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    with_gnu_ld=no
+    wlarc=
+
+    # A generic and very simple default shared library creation
+    # command for GNU C++ for the case where it uses the native
+    # linker, instead of GNU ld.  If possible, this setting should
+    # overridden to take advantage of the native linker features on
+    # the platform it is being used on.
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+  fi
+
+  # Commands to make compiler produce verbose output that lists
+  # what "hidden" libraries, object files and flags are used when
+  # linking a shared library.
+  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+else
+  GXX=no
+  with_gnu_ld=no
+  wlarc=
+fi
+
+# PORTME: fill in a description of your system's C++ link characteristics
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+case $host_os in
+  aix3*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  aix4* | aix5*)
+    if test "$host_cpu" = ia64; then
+      # On IA64, the linker does run time linking by default, so we don't
+      # have to do anything special.
+      aix_use_runtimelinking=no
+      exp_sym_flag='-Bexport'
+      no_entry_flag=""
+    else
+      aix_use_runtimelinking=no
+
+      # Test if we are trying to use run time linking or normal
+      # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+      # need to do runtime linking.
+      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+       for ld_flag in $LDFLAGS; do
+         case $ld_flag in
+         *-brtl*)
+           aix_use_runtimelinking=yes
+           break
+           ;;
+         esac
+       done
+      esac
+
+      exp_sym_flag='-bexport'
+      no_entry_flag='-bnoentry'
+    fi
+
+    # When large executables or shared objects are built, AIX ld can
+    # have problems creating the table of contents.  If linking a library
+    # or program results in "error TOC overflow" add -mminimal-toc to
+    # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+    # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+    _LT_AC_TAGVAR(archive_cmds, $1)=''
+    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+    if test "$GXX" = yes; then
+      case $host_os in aix4.[[012]]|aix4.[[012]].*)
+      # We only want to do this on AIX 4.2 and lower, the check
+      # below for broken collect2 doesn't work under 4.3+
+       collect2name=`${CC} -print-prog-name=collect2`
+       if test -f "$collect2name" && \
+          strings "$collect2name" | grep resolve_lib_name >/dev/null
+       then
+         # We have reworked collect2
+         _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+       else
+         # We have old collect2
+         _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+       fi
+      esac
+      shared_flag='-shared'
+      if test "$aix_use_runtimelinking" = yes; then
+       shared_flag="$shared_flag "'${wl}-G'
+      fi
+    else
+      # not using gcc
+      if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+       shared_flag='-G'
+      else
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag='${wl}-G'
+       else
+         shared_flag='${wl}-bM:SRE'
+       fi
+      fi
+    fi
+
+    # It seems that -bexpall does not export symbols beginning with
+    # underscore (_), so it is better to generate a list of symbols to export.
+    _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+    if test "$aix_use_runtimelinking" = yes; then
+      # Warning - without using the other runtime loading flags (-brtl),
+      # -berok will link without error, but may produce a broken library.
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+      # Determine the default libpath from the value encoded in an empty executable.
+      _LT_AC_SYS_LIBPATH_AIX
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+     else
+      if test "$host_cpu" = ia64; then
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+      else
+       # Determine the default libpath from the value encoded in an empty executable.
+       _LT_AC_SYS_LIBPATH_AIX
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+       # Warning - without using the other run time loading flags,
+       # -berok will link without error, but may produce a broken library.
+       _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+       # -bexpall does not export symbols beginning with underscore (_)
+       _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+       # Exported symbols can be pulled into shared objects from archives
+       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
+       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+       # This is similar to how AIX traditionally builds its shared libraries.
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+      fi
+    fi
+    ;;
+  chorus*)
+    case $cc_basename in
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+
+
+  cygwin* | mingw* | pw32*)
+    # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+    # as there is no search path for DLLs.
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+    _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+    _LT_AC_TAGVAR(always_export_symbols, $1)=no
+    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+    if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+      # If the export-symbols file already is a .def file (1st line
+      # is EXPORTS), use it as is; otherwise, prepend...
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+       cp $export_symbols $output_objdir/$soname.def;
+      else
+       echo EXPORTS > $output_objdir/$soname.def;
+       cat $export_symbols >> $output_objdir/$soname.def;
+      fi~
+      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+  ;;
+      darwin* | rhapsody*)
+        case $host_os in
+        rhapsody* | darwin1.[[012]])
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[[012]])
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+        esac
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+    if test "$GXX" = yes ; then
+      lt_int_apple_cc_single_mod=no
+      output_verbose_link_cmd='echo'
+      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
+       lt_int_apple_cc_single_mod=yes
+      fi
+      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      else
+          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+        fi
+        _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          else
+            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          fi
+            _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+          ;;
+      esac
+      fi
+        ;;
+
+  dgux*)
+    case $cc_basename in
+      ec++*)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      ghcx*)
+       # Green Hills C++ Compiler
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+  freebsd[[12]]*)
+    # C++ shared libraries reported to be fairly broken before switch to ELF
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  freebsd-elf*)
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    ;;
+  freebsd* | kfreebsd*-gnu | dragonfly*)
+    # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+    # conventions
+    _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+    ;;
+  gnu*)
+    ;;
+  hpux9*)
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+    _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+                               # but as the default
+                               # location of the library.
+
+    case $cc_basename in
+    CC*)
+      # FIXME: insert proper C++ library support
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    aCC*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      #
+      # There doesn't appear to be a way to prevent this compiler from
+      # explicitly linking system object files so we need to strip them
+      # from the output so that they don't get included in the library
+      # dependencies.
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      ;;
+    *)
+      if test "$GXX" = yes; then
+        _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+        # FIXME: insert proper C++ library support
+        _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+    ;;
+  hpux10*|hpux11*)
+    if test $with_gnu_ld = no; then
+      case $host_cpu in
+      hppa*64*)
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+        ;;
+      ia64*)
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+        ;;
+      *)
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        ;;
+      esac
+    fi
+    case $host_cpu in
+    hppa*64*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+    ia64*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+                                             # but as the default
+                                             # location of the library.
+      ;;
+    *)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+                                             # but as the default
+                                             # location of the library.
+      ;;
+    esac
+
+    case $cc_basename in
+      CC*)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      aCC*)
+       case $host_cpu in
+       hppa*64*|ia64*)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+         ;;
+       *)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+         ;;
+       esac
+       # Commands to make compiler produce verbose output that lists
+       # what "hidden" libraries, object files and flags are used when
+       # linking a shared library.
+       #
+       # There doesn't appear to be a way to prevent this compiler from
+       # explicitly linking system object files so we need to strip them
+       # from the output so that they don't get included in the library
+       # dependencies.
+       output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+       ;;
+      *)
+       if test "$GXX" = yes; then
+         if test $with_gnu_ld = no; then
+           case $host_cpu in
+           ia64*|hppa*64*)
+             _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+             ;;
+           *)
+             _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+             ;;
+           esac
+         fi
+       else
+         # FIXME: insert proper C++ library support
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       fi
+       ;;
+    esac
+    ;;
+  irix5* | irix6*)
+    case $cc_basename in
+      CC*)
+       # SGI C++
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+
+       # Archives containing C++ object files must be created using
+       # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+       # necessary to make sure instantiated templates are included
+       # in the archive.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+       ;;
+      *)
+       if test "$GXX" = yes; then
+         if test "$with_gnu_ld" = no; then
+           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+         else
+           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+         fi
+       fi
+       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+       ;;
+    esac
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+    ;;
+  linux*)
+    case $cc_basename in
+      KCC*)
+       # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+       # KCC will only create a shared library if the output file
+       # ends with ".so" (or ".sl" for HP-UX), so rename the library
+       # to its proper name (with version) after linking.
+       _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+       # Commands to make compiler produce verbose output that lists
+       # what "hidden" libraries, object files and flags are used when
+       # linking a shared library.
+       #
+       # There doesn't appear to be a way to prevent this compiler from
+       # explicitly linking system object files so we need to strip them
+       # from the output so that they don't get included in the library
+       # dependencies.
+       output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+       # Archives containing C++ object files must be created using
+       # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+       ;;
+      icpc*)
+       # Intel C++
+       with_gnu_ld=yes
+       # version 8.0 and above of icpc choke on multiply defined symbols
+       # if we add $predep_objects and $postdep_objects, however 7.1 and
+       # earlier do not add the objects themselves.
+       case `$CC -V 2>&1` in
+       *"Version 7."*)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+         ;;
+       *)  # Version 8.0 or newer
+         tmp_idyn=
+         case $host_cpu in
+           ia64*) tmp_idyn=' -i_dynamic';;
+         esac
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+         ;;
+       esac
+       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+       ;;
+      pgCC*)
+        # Portland Group C++ compiler
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+        ;;
+      cxx*)
+       # Compaq C++
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+       runpath_var=LD_RUN_PATH
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       # Commands to make compiler produce verbose output that lists
+       # what "hidden" libraries, object files and flags are used when
+       # linking a shared library.
+       #
+       # There doesn't appear to be a way to prevent this compiler from
+       # explicitly linking system object files so we need to strip them
+       # from the output so that they don't get included in the library
+       # dependencies.
+       output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+       ;;
+    esac
+    ;;
+  lynxos*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  m88k*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  mvs*)
+    case $cc_basename in
+      cxx*)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+      wlarc=
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    fi
+    # Workaround some broken pre-1.5 toolchains
+    output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+    ;;
+  openbsd2*)
+    # C++ shared libraries are fairly broken
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  openbsd*)
+    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    fi
+    output_verbose_link_cmd='echo'
+    ;;
+  osf3*)
+    case $cc_basename in
+      KCC*)
+       # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+       # KCC will only create a shared library if the output file
+       # ends with ".so" (or ".sl" for HP-UX), so rename the library
+       # to its proper name (with version) after linking.
+       _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       # Archives containing C++ object files must be created using
+       # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+
+       ;;
+      RCC*)
+       # Rational C++ 2.4.1
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      cxx*)
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       # Commands to make compiler produce verbose output that lists
+       # what "hidden" libraries, object files and flags are used when
+       # linking a shared library.
+       #
+       # There doesn't appear to be a way to prevent this compiler from
+       # explicitly linking system object files so we need to strip them
+       # from the output so that they don't get included in the library
+       # dependencies.
+       output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+       ;;
+      *)
+       if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+         # Commands to make compiler produce verbose output that lists
+         # what "hidden" libraries, object files and flags are used when
+         # linking a shared library.
+         output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+       else
+         # FIXME: insert proper C++ library support
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       fi
+       ;;
+    esac
+    ;;
+  osf4* | osf5*)
+    case $cc_basename in
+      KCC*)
+       # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+       # KCC will only create a shared library if the output file
+       # ends with ".so" (or ".sl" for HP-UX), so rename the library
+       # to its proper name (with version) after linking.
+       _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       # Archives containing C++ object files must be created using
+       # the KAI C++ compiler.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
+       ;;
+      RCC*)
+       # Rational C++ 2.4.1
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      cxx*)
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+         echo "-hidden">> $lib.exp~
+         $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+         $rm $lib.exp'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       # Commands to make compiler produce verbose output that lists
+       # what "hidden" libraries, object files and flags are used when
+       # linking a shared library.
+       #
+       # There doesn't appear to be a way to prevent this compiler from
+       # explicitly linking system object files so we need to strip them
+       # from the output so that they don't get included in the library
+       # dependencies.
+       output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+       ;;
+      *)
+       if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+         # Commands to make compiler produce verbose output that lists
+         # what "hidden" libraries, object files and flags are used when
+         # linking a shared library.
+         output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+       else
+         # FIXME: insert proper C++ library support
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       fi
+       ;;
+    esac
+    ;;
+  psos*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  sco*)
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    case $cc_basename in
+      CC*)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+  sunos4*)
+    case $cc_basename in
+      CC*)
+       # Sun C++ 4.x
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      lcc*)
+       # Lucid
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+  solaris*)
+    case $cc_basename in
+      CC*)
+       # Sun C++ 4.2, 5.x and Centerline C++
+        _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
+       _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+       $CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+       case $host_os in
+         solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+         *)
+           # The C++ compiler is used as linker so we must use $wl
+           # flag to pass the commands to the underlying system
+           # linker. We must also pass each convience library through
+           # to the system linker between allextract/defaultextract.
+           # The C++ compiler will combine linker options so we
+           # cannot just pass the convience library names through
+           # without $wl.
+           # Supported since Solaris 2.6 (maybe 2.5.1?)
+           _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+           ;;
+       esac
+       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+       output_verbose_link_cmd='echo'
+
+       # Archives containing C++ object files must be created using
+       # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+       # necessary to make sure instantiated templates are included
+       # in the archive.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+       ;;
+      gcx*)
+       # Green Hills C++ Compiler
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+       # The C++ compiler must be used to create the archive.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+       ;;
+      *)
+       # GNU C++ compiler with Solaris linker
+       if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+         _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+         if $CC --version | grep -v '^2\.7' > /dev/null; then
+           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+           _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+         else
+           # g++ 2.7 appears to require `-G' NOT `-shared' on this
+           # platform.
+           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+           _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+         fi
+
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+       fi
+       ;;
+    esac
+    ;;
+  sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*)
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    ;;
+  tandem*)
+    case $cc_basename in
+      NCC*)
+       # NonStop-UX NCC 3.20
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+  vxworks*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  *)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+esac
+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_AC_TAGVAR(GCC, $1)="$GXX"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+AC_LIBTOOL_POSTDEP_PREDEP($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC=$lt_save_CC
+LDCXX=$LD
+LD=$lt_save_LD
+GCC=$lt_save_GCC
+with_gnu_ldcxx=$with_gnu_ld
+with_gnu_ld=$lt_save_with_gnu_ld
+lt_cv_path_LDCXX=$lt_cv_path_LD
+lt_cv_path_LD=$lt_save_path_LD
+lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+])# AC_LIBTOOL_LANG_CXX_CONFIG
+
+# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
+# ------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library.  It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
+int a;
+void foo (void) { a = 0; }
+EOF
+],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+EOF
+],[$1],[F77],[cat > conftest.$ac_ext <<EOF
+      subroutine foo
+      implicit none
+      integer*4 a
+      a=0
+      return
+      end
+EOF
+],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
+public class foo {
+  private int a;
+  public void bar (void) {
+    a = 0;
+  }
+};
+EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  # The `*' in the case matches for architectures that use `case' in
+  # $output_verbose_cmd can trigger glob expansion during the loop
+  # eval without this substitution.
+  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
+
+  for p in `eval $output_verbose_link_cmd`; do
+    case $p in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" \
+         || test $p = "-R"; then
+        prev=$p
+        continue
+       else
+        prev=
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+        case $p in
+        -L* | -R*)
+          # Internal compiler library paths should come after those
+          # provided the user.  The postdeps already come after the
+          # user supplied libs so there is no need to process them.
+          if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+            _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+          else
+            _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+          fi
+          ;;
+        # The "-l" case would never come before the object being
+        # linked, so don't bother handling this case.
+        esac
+       else
+        if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
+          _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
+        else
+          _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
+        fi
+       fi
+       ;;
+
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+        pre_test_object_deps_done=yes
+        continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+        if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
+          _LT_AC_TAGVAR(predep_objects, $1)="$p"
+        else
+          _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
+        fi
+       else
+        if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
+          _LT_AC_TAGVAR(postdep_objects, $1)="$p"
+        else
+          _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
+        fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$rm -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+ifelse([$1],[CXX],
+[case $host_os in
+solaris*)
+  case $cc_basename in
+  CC*)
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+    ;;
+  esac
+esac
+])
+
+case " $_LT_AC_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+])# AC_LIBTOOL_POSTDEP_PREDEP
+
+# AC_LIBTOOL_LANG_F77_CONFIG
+# ------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
+AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
+[AC_REQUIRE([AC_PROG_F77])
+AC_LANG_PUSH(Fortran 77)
+
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+_LT_AC_TAGVAR(always_export_symbols, $1)=no
+_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_direct, $1)=no
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+_LT_AC_TAGVAR(module_cmds, $1)=
+_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_AC_TAGVAR(no_undefined_flag, $1)=
+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="      subroutine t\n      return\n      end\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="      program t\n      end\n"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${F77-"f77"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+AC_MSG_CHECKING([if libtool supports shared libraries])
+AC_MSG_RESULT([$can_build_shared])
+
+AC_MSG_CHECKING([whether to build shared libraries])
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case $host_os in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+aix4* | aix5*)
+  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
+  ;;
+esac
+AC_MSG_RESULT([$enable_shared])
+
+AC_MSG_CHECKING([whether to build static libraries])
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+AC_MSG_RESULT([$enable_static])
+
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_AC_TAGVAR(GCC, $1)="$G77"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_F77_CONFIG
+
+
+# AC_LIBTOOL_LANG_GCJ_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
+AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
+[AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_GCJ_CONFIG
+
+
+# AC_LIBTOOL_LANG_RC_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the Windows resource compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
+AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
+[AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${RC-"windres"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_RC_CONFIG
+
+
+# AC_LIBTOOL_CONFIG([TAGNAME])
+# ----------------------------
+# If TAGNAME is not passed, then create an initial libtool script
+# with a default configuration from the untagged config vars.  Otherwise
+# add code to config.status for appending the configuration named by
+# TAGNAME from the matching tagged config vars.
+AC_DEFUN([AC_LIBTOOL_CONFIG],
+[# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    _LT_AC_TAGVAR(compiler, $1) \
+    _LT_AC_TAGVAR(CC, $1) \
+    _LT_AC_TAGVAR(LD, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
+    _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
+    _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
+    _LT_AC_TAGVAR(old_archive_cmds, $1) \
+    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
+    _LT_AC_TAGVAR(predep_objects, $1) \
+    _LT_AC_TAGVAR(postdep_objects, $1) \
+    _LT_AC_TAGVAR(predeps, $1) \
+    _LT_AC_TAGVAR(postdeps, $1) \
+    _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+    _LT_AC_TAGVAR(archive_cmds, $1) \
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
+    _LT_AC_TAGVAR(postinstall_cmds, $1) \
+    _LT_AC_TAGVAR(postuninstall_cmds, $1) \
+    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
+    _LT_AC_TAGVAR(allow_undefined_flag, $1) \
+    _LT_AC_TAGVAR(no_undefined_flag, $1) \
+    _LT_AC_TAGVAR(export_symbols_cmds, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
+    _LT_AC_TAGVAR(hardcode_automatic, $1) \
+    _LT_AC_TAGVAR(module_cmds, $1) \
+    _LT_AC_TAGVAR(module_expsym_cmds, $1) \
+    _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+    _LT_AC_TAGVAR(exclude_expsyms, $1) \
+    _LT_AC_TAGVAR(include_expsyms, $1); do
+
+    case $var in
+    _LT_AC_TAGVAR(old_archive_cmds, $1) | \
+    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
+    _LT_AC_TAGVAR(archive_cmds, $1) | \
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
+    _LT_AC_TAGVAR(module_cmds, $1) | \
+    _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
+    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
+    _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case $lt_echo in
+  *'\[$]0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
+    ;;
+  esac
+
+ifelse([$1], [],
+  [cfgfile="${ofile}T"
+  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+  $rm -f "$cfgfile"
+  AC_MSG_NOTICE([creating $ofile])],
+  [cfgfile="$ofile"])
+
+  cat <<__EOF__ >> "$cfgfile"
+ifelse([$1], [],
+[#! $SHELL
+
+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool:
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="$SED -e 1s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# The names of the tagged configurations supported by this script.
+available_tags=
+
+# ### BEGIN LIBTOOL CONFIG],
+[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
+
+# Is the compiler the GNU C compiler?
+with_gcc=$_LT_AC_TAGVAR(GCC, $1)
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
+archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
+module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
+
+# Symbols that must always be exported.
+include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
+
+ifelse([$1],[],
+[# ### END LIBTOOL CONFIG],
+[# ### END LIBTOOL TAG CONFIG: $tagname])
+
+__EOF__
+
+ifelse([$1],[], [
+  case $host_os in
+  aix3*)
+    cat <<\EOF >> "$cfgfile"
+
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+EOF
+    ;;
+  esac
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" || \
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+])
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
+])# AC_LIBTOOL_CONFIG
+
+
+# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------------------
+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
+[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+
+_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+  AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+    lt_cv_prog_compiler_rtti_exceptions,
+    [-fno-rtti -fno-exceptions], [],
+    [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
+
+
+# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+# ---------------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
+[AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([AC_PROG_NM])
+AC_REQUIRE([AC_OBJEXT])
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Transform an extracted symbol line into a proper C declaration
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[[BCDT]]'
+  ;;
+cygwin* | mingw* | pw32*)
+  symcode='[[ABCDGISTW]]'
+  ;;
+hpux*) # Its linker distinguishes data from code symbols
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDEGRST]]'
+  fi
+  lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  ;;
+linux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDGIRSTW]]'
+    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[[BCDEGRST]]'
+  ;;
+osf*)
+  symcode='[[BCDEGQRST]]'
+  ;;
+solaris* | sysv5*)
+  symcode='[[BDRT]]'
+  ;;
+sysv4)
+  symcode='[[DFNSTU]]'
+  ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[     ]]\($symcode$symcode*\)[[       ]][[    ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+  if AC_TRY_EVAL(ac_compile); then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+      else
+       rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if grep ' nm_test_var$' "$nlist" >/dev/null; then
+       if grep ' nm_test_func$' "$nlist" >/dev/null; then
+         cat <<EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+         # Now generate the symbol file.
+         eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+
+         cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[[]] =
+{
+EOF
+         $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+         cat <<\EOF >> conftest.$ac_ext
+  {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+         # Now try linking the two files.
+         mv conftest.$ac_objext conftstm.$ac_objext
+         lt_save_LIBS="$LIBS"
+         lt_save_CFLAGS="$CFLAGS"
+         LIBS="conftstm.$ac_objext"
+         CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+         if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+           pipe_works=yes
+         fi
+         LIBS="$lt_save_LIBS"
+         CFLAGS="$lt_save_CFLAGS"
+       else
+         echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+       fi
+      else
+       echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+    fi
+  else
+    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+    cat conftest.$ac_ext >&5
+  fi
+  rm -f conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  AC_MSG_RESULT(failed)
+else
+  AC_MSG_RESULT(ok)
+fi
+]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+
+
+# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
+# ---------------------------------------
+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
+[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+ ifelse([$1],[CXX],[
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+      ;;
+    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | os2* | pw32*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       ;;
+      *)
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       ;;
+      esac
+      ;;
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix4* | aix5*)
+       # All AIX code is PIC.
+       if test "$host_cpu" = ia64; then
+         # AIX 5 now supports IA64 processor
+         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+       else
+         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+       fi
+       ;;
+      chorus*)
+       case $cc_basename in
+       cxch68*)
+         # Green Hills C++ Compiler
+         # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+         ;;
+       esac
+       ;;
+       darwin*)
+         # PIC is the default on this platform
+         # Common symbols not allowed in MH_DYLIB files
+         case $cc_basename in
+           xlc*)
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           ;;
+         esac
+       ;;
+      dgux*)
+       case $cc_basename in
+         ec++*)
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           ;;
+         ghcx*)
+           # Green Hills C++ Compiler
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      freebsd* | kfreebsd*-gnu | dragonfly*)
+       # FreeBSD uses GNU C++
+       ;;
+      hpux9* | hpux10* | hpux11*)
+       case $cc_basename in
+         CC*)
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+           if test "$host_cpu" != ia64; then
+             _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+           fi
+           ;;
+         aCC*)
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+           case $host_cpu in
+           hppa*64*|ia64*)
+             # +Z the default
+             ;;
+           *)
+             _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+             ;;
+           esac
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      irix5* | irix6* | nonstopux*)
+       case $cc_basename in
+         CC*)
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           # CC pic flag -KPIC is the default.
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      linux*)
+       case $cc_basename in
+         KCC*)
+           # KAI C++ Compiler
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+           ;;
+         icpc* | ecpc*)
+           # Intel C++
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+           ;;
+         pgCC*)
+           # Portland Group C++ compiler.
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           ;;
+         cxx*)
+           # Compaq C++
+           # Make sure the PIC flag is empty.  It appears that all Alpha
+           # Linux and Compaq Tru64 Unix objects are PIC.
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      lynxos*)
+       ;;
+      m88k*)
+       ;;
+      mvs*)
+       case $cc_basename in
+         cxx*)
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      netbsd*)
+       ;;
+      osf3* | osf4* | osf5*)
+       case $cc_basename in
+         KCC*)
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+           ;;
+         RCC*)
+           # Rational C++ 2.4.1
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         cxx*)
+           # Digital/Compaq C++
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           # Make sure the PIC flag is empty.  It appears that all Alpha
+           # Linux and Compaq Tru64 Unix objects are PIC.
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      psos*)
+       ;;
+      sco*)
+       case $cc_basename in
+         CC*)
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      solaris*)
+       case $cc_basename in
+         CC*)
+           # Sun C++ 4.2, 5.x and Centerline C++
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+           ;;
+         gcx*)
+           # Green Hills C++ Compiler
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      sunos4*)
+       case $cc_basename in
+         CC*)
+           # Sun C++ 4.x
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           ;;
+         lcc*)
+           # Lucid
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      tandem*)
+       case $cc_basename in
+         NCC*)
+           # NonStop-UX NCC 3.20
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      unixware*)
+       ;;
+      vxworks*)
+       ;;
+      *)
+       _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+       ;;
+    esac
+  fi
+],
+[
+  if test "$GCC" = yes; then
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       ;;
+      esac
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      else
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+       ;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC (with -KPIC) is the default.
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    newsos6)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    linux*)
+      case $cc_basename in
+      icc* | ecc*)
+       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+       # which looks to be a dead project)
+       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      ccc*)
+        _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+        # All Alpha code is PIC.
+        _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+        ;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # All OSF/1 code is PIC.
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    sco3.2v5*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn'
+      ;;
+
+    solaris*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+      *)
+       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    unicos*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+
+    uts4*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+    esac
+  fi
+])
+AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
+  AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
+    _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
+    [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
+    [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
+     "" | " "*) ;;
+     *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+     esac],
+    [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+     _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+    ;;
+  *)
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
+    ;;
+esac
+])
+
+
+# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
+# ------------------------------------
+# See if the linker supports building shared libraries.
+AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
+[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+ifelse([$1],[CXX],[
+  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  case $host_os in
+  aix4* | aix5*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+    else
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+  ;;
+  cygwin* | mingw*)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  *)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  esac
+],[
+  runpath_var=
+  _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+  _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+  _LT_AC_TAGVAR(archive_cmds, $1)=
+  _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+  _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
+  _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+  _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+  _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+  _LT_AC_TAGVAR(hardcode_automatic, $1)=no
+  _LT_AC_TAGVAR(module_cmds, $1)=
+  _LT_AC_TAGVAR(module_expsym_cmds, $1)=
+  _LT_AC_TAGVAR(always_export_symbols, $1)=no
+  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  _LT_AC_TAGVAR(include_expsyms, $1)=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  _LT_CC_BASENAME([$compiler])
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix3* | aix4* | aix5*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+      fi
+      ;;
+
+    amigaos*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+
+      # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+      # that the semantics of dynamic libraries on AmigaOS, at least up
+      # to version 4, is to share data among multiple programs linked
+      # with the same dynamic library.  Since this doesn't match the
+      # behavior of shared libraries on other platforms, we can't use
+      # them.
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+       # support --undefined.  This deserves some investigation.  FIXME
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+      # as there is no search path for DLLs.
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(always_export_symbols, $1)=no
+      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+       # If the export-symbols file already is a .def file (1st line
+       # is EXPORTS), use it as is; otherwise, prepend...
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+         cp $export_symbols $output_objdir/$soname.def;
+       else
+         echo EXPORTS > $output_objdir/$soname.def;
+         cat $export_symbols >> $output_objdir/$soname.def;
+       fi~
+       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+      else
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    linux*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       tmp_addflag=
+       case $cc_basename,$host_cpu in
+       pgcc*)                          # Portland Group C compiler
+         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag'
+         ;;
+       pgf77* | pgf90* | pgf95*)       # Portland Group f77 and f90 compilers
+         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag -Mnomain' ;;
+       ecc*,ia64* | icc*,ia64*)                # Intel C compiler on ia64
+         tmp_addflag=' -i_dynamic' ;;
+       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
+         tmp_addflag=' -i_dynamic -nofor_main' ;;
+       ifc* | ifort*)                  # Intel Fortran compiler
+         tmp_addflag=' -nofor_main' ;;
+       esac
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+       if test $supports_anon_versioning = yes; then
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+         $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+       fi
+      else
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+       wlarc=
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris* | sysv5*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    sunos4*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+
+    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
+      runpath_var=
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      if test "$GCC" = yes && test -z "$link_static_flag"; then
+       # Neither direct hardcoding nor static linking is supported with a
+       # broken collect2.
+       _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+      fi
+      ;;
+
+    aix4* | aix5*)
+      if test "$host_cpu" = ia64; then
+       # On IA64, the linker does run time linking by default, so we don't
+       # have to do anything special.
+       aix_use_runtimelinking=no
+       exp_sym_flag='-Bexport'
+       no_entry_flag=""
+      else
+       # If we're using GNU nm, then we don't want the "-C" option.
+       # -C means demangle to AIX nm, but means don't demangle with GNU nm
+       if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+         _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+       else
+         _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+       fi
+       aix_use_runtimelinking=no
+
+       # Test if we are trying to use run time linking or normal
+       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+       # need to do runtime linking.
+       case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+         for ld_flag in $LDFLAGS; do
+         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+           aix_use_runtimelinking=yes
+           break
+         fi
+         done
+       esac
+
+       exp_sym_flag='-bexport'
+       no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      _LT_AC_TAGVAR(archive_cmds, $1)=''
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+      if test "$GCC" = yes; then
+       case $host_os in aix4.[[012]]|aix4.[[012]].*)
+       # We only want to do this on AIX 4.2 and lower, the check
+       # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" && \
+          strings "$collect2name" | grep resolve_lib_name >/dev/null
+         then
+         # We have reworked collect2
+         _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+         else
+         # We have old collect2
+         _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+         fi
+       esac
+       shared_flag='-shared'
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag="$shared_flag "'${wl}-G'
+       fi
+      else
+       # not using gcc
+       if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+       else
+       if test "$aix_use_runtimelinking" = yes; then
+           shared_flag='${wl}-G'
+         else
+           shared_flag='${wl}-bM:SRE'
+       fi
+       fi
+      fi
+
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+      if test "$aix_use_runtimelinking" = yes; then
+       # Warning - without using the other runtime loading flags (-brtl),
+       # -berok will link without error, but may produce a broken library.
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       _LT_AC_SYS_LIBPATH_AIX
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+       if test "$host_cpu" = ia64; then
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+       else
+        # Determine the default libpath from the value encoded in an empty executable.
+        _LT_AC_SYS_LIBPATH_AIX
+        _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+         # Warning - without using the other run time loading flags,
+         # -berok will link without error, but may produce a broken library.
+         _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+         # -bexpall does not export symbols beginning with underscore (_)
+         _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+         # Exported symbols can be pulled into shared objects from archives
+         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
+         _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+         # This is similar to how AIX traditionally builds its shared libraries.
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+       fi
+      fi
+      ;;
+
+    amigaos*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      # see comment about different semantics on the GNU ld section
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    bsdi[[45]]*)
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
+      # FIXME: Should let the user specify the lib program.
+      _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[[012]])
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[[012]])
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+    if test "$GCC" = yes ; then
+       output_verbose_link_cmd='echo'
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+         _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    freebsd1*)
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | kfreebsd*-gnu | dragonfly*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      ;;
+
+    hpux10* | hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*|ia64*)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       esac
+      else
+       case $host_cpu in
+       hppa*64*|ia64*)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       *)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       esac
+      fi
+      if test "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*)
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+         _LT_AC_TAGVAR(hardcode_direct, $1)=no
+         _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+         ;;
+       ia64*)
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+         _LT_AC_TAGVAR(hardcode_direct, $1)=no
+         _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+         ;;
+       *)
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+         _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+         _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+         ;;
+       esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    newsos6)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    openbsd*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      else
+       case $host_os in
+        openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+          _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+          _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+          ;;
+        *)
+          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+          _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+          ;;
+       esac
+      fi
+      ;;
+
+    os2*)
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    osf4* | osf5*)     # as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      else
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+       $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+
+       # Both c and cxx compiler support -rpath directly
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    sco3.2v5*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ;;
+
+    solaris*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+      if test "$GCC" = yes; then
+       wlarc='${wl}'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+         $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+       wlarc=''
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+       $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      case $host_os in
+      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+      *)
+       # The compiler driver will combine linker options so we
+       # cannot just pass the convience library names through
+       # without $wl, iff we do not link with $LD.
+       # Luckily, gcc supports the same syntax we need for Sun Studio.
+       # Supported since Solaris 2.6 (maybe 2.5.1?)
+       case $wlarc in
+       '')
+         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
+       *)
+         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
+       esac ;;
+      esac
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+       # Use $CC to link under sequent, because it throws in some extra .o
+       # files that make .init and .fini sections work.
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+       sni)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+       ;;
+       siemens)
+         ## LD is ld it makes a PLAMLIB
+         ## CC just makes a GrossModule.
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+         _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+         _LT_AC_TAGVAR(hardcode_direct, $1)=no
+        ;;
+       motorola)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+       ;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4.3*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+       runpath_var=LD_RUN_PATH
+       hardcode_runpath_var=yes
+       _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+      fi
+      ;;
+
+    sysv4.2uw2*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      hardcode_runpath_var=yes
+      runpath_var=LD_RUN_PATH
+      ;;
+
+   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[[78]]* | unixware7*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text'
+      if test "$GCC" = yes; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      runpath_var='LD_RUN_PATH'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv5*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+      # $CC -shared without GNU ld will not create a library from C++
+      # object files and a static libstdc++, better avoid it by now
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+      ;;
+
+    uts4*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    esac
+  fi
+])
+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+  # Assume -lc should be added
+  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $_LT_AC_TAGVAR(archive_cmds, $1) in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+      $rm conftest*
+      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
+        _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+        if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
+        then
+         _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+        else
+         _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+        fi
+        _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
+      ;;
+    esac
+  fi
+  ;;
+esac
+])# AC_LIBTOOL_PROG_LD_SHLIBS
+
+
+# _LT_AC_FILE_LTDLL_C
+# -------------------
+# Be careful that the start marker always follows a newline.
+AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
+# /* ltdll.c starts here */
+# #define WIN32_LEAN_AND_MEAN
+# #include <windows.h>
+# #undef WIN32_LEAN_AND_MEAN
+# #include <stdio.h>
+#
+# #ifndef __CYGWIN__
+# #  ifdef __CYGWIN32__
+# #    define __CYGWIN__ __CYGWIN32__
+# #  endif
+# #endif
+#
+# #ifdef __cplusplus
+# extern "C" {
+# #endif
+# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+# #ifdef __cplusplus
+# }
+# #endif
+#
+# #ifdef __CYGWIN__
+# #include <cygwin/cygwin_dll.h>
+# DECLARE_CYGWIN_DLL( DllMain );
+# #endif
+# HINSTANCE __hDllInstance_base;
+#
+# BOOL APIENTRY
+# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+# {
+#   __hDllInstance_base = hInst;
+#   return TRUE;
+# }
+# /* ltdll.c ends here */
+])# _LT_AC_FILE_LTDLL_C
+
+
+# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
+# ---------------------------------
+AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
+
+
+# old names
+AC_DEFUN([AM_PROG_LIBTOOL],   [AC_PROG_LIBTOOL])
+AC_DEFUN([AM_ENABLE_SHARED],  [AC_ENABLE_SHARED($@)])
+AC_DEFUN([AM_ENABLE_STATIC],  [AC_ENABLE_STATIC($@)])
+AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+AC_DEFUN([AM_PROG_LD],        [AC_PROG_LD])
+AC_DEFUN([AM_PROG_NM],        [AC_PROG_NM])
+
+# This is just to silence aclocal about the macro not being used
+ifelse([AC_DISABLE_FAST_INSTALL])
+
+AC_DEFUN([LT_AC_PROG_GCJ],
+[AC_CHECK_TOOL(GCJ, gcj, no)
+  test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+  AC_SUBST(GCJFLAGS)
+])
+
+AC_DEFUN([LT_AC_PROG_RC],
+[AC_CHECK_TOOL(RC, windres, no)
+])
+
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+# LT_AC_PROG_SED
+# --------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible.  Prefer GNU sed if found.
+AC_DEFUN([LT_AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+])
+SED=$lt_cv_path_SED
+AC_MSG_RESULT([$SED])
+])
+
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.11'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.11], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.11])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 9
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 10
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
+       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
+       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
+       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                   [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+#serial 5
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 8
+
+# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 16
+
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.62])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+             [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+                            [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+                 [_AM_DEPENDENCIES(CC)],
+                 [define([AC_PROG_CC],
+                         defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+                 [_AM_DEPENDENCIES(CXX)],
+                 [define([AC_PROG_CXX],
+                         defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+                 [_AM_DEPENDENCIES(OBJC)],
+                 [define([AC_PROG_OBJC],
+                         defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+])
+_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
+dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
+dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
+dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+])
+
+dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+AC_SUBST(install_sh)])
+
+# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 2
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes.                 -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 4
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Copyright (C) 1999, 2000, 2001, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 6
+
+# AM_PROG_CC_C_O
+# --------------
+# Like AC_PROG_CC_C_O, but changed for automake.
+AC_DEFUN([AM_PROG_CC_C_O],
+[AC_REQUIRE([AC_PROG_CC_C_O])dnl
+AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([compile])dnl
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+am_cc=`echo $[2] | sed ['s/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/']`
+eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
+if test "$am_t" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+dnl Make sure AC_PROG_CC is never called again, or it will override our
+dnl setting of CC.
+m4_define([AC_PROG_CC],
+          [m4_fatal([AC_PROG_CC cannot be called after AM_PROG_CC_C_O])])
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 6
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_PROG_MKDIR_P
+# ---------------
+# Check for `mkdir -p'.
+AC_DEFUN([AM_PROG_MKDIR_P],
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+  [[\\/$]]* | ?:[[\\/]]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 4
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Copyright (C) 1996, 1997, 1998, 2000, 2001, 2002, 2003, 2005, 2006
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 5
+
+AC_DEFUN([AM_C_PROTOTYPES],
+[AC_REQUIRE([AC_C_PROTOTYPES])
+if test "$ac_cv_prog_cc_stdc" != no; then
+  U= ANSI2KNR=
+else
+  U=_ ANSI2KNR=./ansi2knr
+fi
+# Ensure some checks needed by ansi2knr itself.
+AC_REQUIRE([AC_HEADER_STDC])
+AC_CHECK_HEADERS([string.h])
+AC_SUBST([U])dnl
+AC_SUBST([ANSI2KNR])dnl
+_AM_SUBST_NOTMAKE([ANSI2KNR])dnl
+])
+
+AU_DEFUN([fp_C_PROTOTYPES], [AM_C_PROTOTYPES])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 5
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \   ]]*)
+    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$[*]" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$[*]" != "X $srcdir/configure conftest.file" \
+      && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 2
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 2
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [m4_case([$1], [ustar],, [pax],,
+              [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+  case $_am_tool in
+  gnutar)
+    for _am_tar in tar gnutar gtar;
+    do
+      AM_RUN_LOG([$_am_tar --version]) && break
+    done
+    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+    am__untar="$_am_tar -xf -"
+    ;;
+  plaintar)
+    # Must skip GNU tar: if it does not support --format= it doesn't create
+    # ustar tarball either.
+    (tar --version) >/dev/null 2>&1 && continue
+    am__tar='tar chf - "$$tardir"'
+    am__tar_='tar chf - "$tardir"'
+    am__untar='tar xf -'
+    ;;
+  pax)
+    am__tar='pax -L -x $1 -w "$$tardir"'
+    am__tar_='pax -L -x $1 -w "$tardir"'
+    am__untar='pax -r'
+    ;;
+  cpio)
+    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+    am__untar='cpio -i -H $1 -d'
+    ;;
+  none)
+    am__tar=false
+    am__tar_=false
+    am__untar=false
+    ;;
+  esac
+
+  # If the value was cached, stop now.  We just wanted to have am__tar
+  # and am__untar set.
+  test -n "${am_cv_prog_tar_$1}" && break
+
+  # tar/untar a dummy directory, and stop if the command works
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  echo GrepMe > conftest.dir/file
+  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+  rm -rf conftest.dir
+  if test -s conftest.tar; then
+    AM_RUN_LOG([$am__untar <conftest.tar])
+    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+  fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([libopts/m4/libopts.m4])
+m4_include([m4/define_dir.m4])
+m4_include([m4/hs_ulong_const.m4])
+m4_include([m4/os_cflags.m4])
diff --git a/adjtimed/Makefile.am b/adjtimed/Makefile.am
new file mode 100644 (file)
index 0000000..9605d1f
--- /dev/null
@@ -0,0 +1,10 @@
+AUTOMAKE_OPTIONS=      ../util/ansi2knr
+
+bindir=                ${exec_prefix}/${BINSUBDIR}
+bin_PROGRAMS=  @MAKE_ADJTIMED@
+EXTRA_PROGRAMS=        adjtimed
+AM_CPPFLAGS=   -I$(top_srcdir)/include
+LDADD=         ../libntp/libntp.a
+ETAGS_ARGS=    Makefile.am
+
+include ../bincheck.mf
diff --git a/adjtimed/Makefile.in b/adjtimed/Makefile.in
new file mode 100644 (file)
index 0000000..2fde4c6
--- /dev/null
@@ -0,0 +1,561 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# we traditionally installed software in bindir, while it should have gone
+# in sbindir.  Now that we offer a choice, look in the "other" installation
+# subdir to warn folks if there is another version there.
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+ANSI2KNR = ../util/ansi2knr
+EXTRA_PROGRAMS = adjtimed$(EXEEXT)
+DIST_COMMON = README $(srcdir)/../bincheck.mf $(srcdir)/Makefile.am \
+       $(srcdir)/Makefile.in
+subdir = adjtimed
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+PROGRAMS = $(bin_PROGRAMS)
+adjtimed_SOURCES = adjtimed.c
+adjtimed_OBJECTS = adjtimed$U.$(OBJEXT)
+adjtimed_LDADD = $(LDADD)
+adjtimed_DEPENDENCIES = ../libntp/libntp.a
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = adjtimed.c
+DIST_SOURCES = adjtimed.c
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = ${exec_prefix}/${BINSUBDIR}
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+bin_PROGRAMS = @MAKE_ADJTIMED@
+AM_CPPFLAGS = -I$(top_srcdir)/include
+LDADD = ../libntp/libntp.a
+ETAGS_ARGS = Makefile.am
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../bincheck.mf $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign adjtimed/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign adjtimed/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p || test -f $$p1; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+           echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+           $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+       @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+adjtimed$(EXEEXT): $(adjtimed_OBJECTS) $(adjtimed_DEPENDENCIES) 
+       @rm -f adjtimed$(EXEEXT)
+       $(LINK) $(adjtimed_OBJECTS) $(adjtimed_LDADD) $(LIBS)
+
+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)/adjtimed$U.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+adjtimed_.c: adjtimed.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/adjtimed.c; then echo $(srcdir)/adjtimed.c; else echo adjtimed.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+adjtimed_.$(OBJEXT) adjtimed_.lo : $(ANSI2KNR)
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+       @$(NORMAL_INSTALL)
+       $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: ../util/ansi2knr install-am install-exec-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+       clean-generic clean-libtool ctags distclean distclean-compile \
+       distclean-generic distclean-libtool distclean-tags distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-binPROGRAMS install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-exec-hook \
+       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 uninstall-binPROGRAMS
+
+
+install-exec-hook:
+       @case ${BINSUBDIR} in                                   \
+        bin) ODIR=${exec_prefix}/sbin ;;                       \
+        sbin) ODIR=${exec_prefix}/bin ;;                       \
+       esac;                                                   \
+       test -z "${bin_PROGRAMS}${bin_SCRIPTS}"                 \
+       || for i in ${bin_PROGRAMS} ${bin_SCRIPTS} " "; do              \
+          test ! -f $$ODIR/$$i || echo "*** $$i is also in $$ODIR!";   \
+       done
+
+#
+
+# 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.
+.NOEXPORT:
diff --git a/adjtimed/README b/adjtimed/README
new file mode 100644 (file)
index 0000000..d4bd593
--- /dev/null
@@ -0,0 +1,22 @@
+------------------------------------------------------------------------------
+The adjtimed daemon emulates the BSD adjtime(2) system call.  The
+adjtime() routine communicates with this daemon via SYSV messages.
+
+The emulation uses an undocumented kernel variable (as of 6.0/2.0
+and later releases) and as such it cannot be guaranteed to work in
+future HP-UX releases.  Perhaps HP-UX will have a real adjtime(2)
+system call in the future.
+
+Author: Tai Jin (tai@sde.hp.com)
+------------------------------------------------------------------------------
+
+IMPORTANT NOTE: This stuff must be compiled with no optimization !!
+
+NOTE: This code is known to work as of 8.0 on s300's, s700's and s800's.
+      PLEASE do not modify it unless you have access to kernel sources
+      and fully understand the implications of any changes you are making.
+      One person already has trashed adjtimed by making it do "the right 
+      thing".  This is not an exact replacement for BSD adjtime(2), don't
+      try to make it into one.
+
+        -- Ken
diff --git a/adjtimed/adjtimed.c b/adjtimed/adjtimed.c
new file mode 100644 (file)
index 0000000..f38e66d
--- /dev/null
@@ -0,0 +1,491 @@
+/*************************************************************************/
+/* (c) Copyright Tai Jin, 1988.  All Rights Reserved.                    */
+/*     Hewlett-Packard Laboratories.                                     */
+/*                                                                       */
+/* Permission is hereby granted for unlimited modification, use, and     */
+/* distribution.  This software is made available with no warranty of    */
+/* any kind, express or implied.  This copyright notice must remain      */
+/* intact in all versions of this software.                              */
+/*                                                                       */
+/* The author would appreciate it if any bug fixes and enhancements were */
+/* to be sent back to him for incorporation into future versions of this */
+/* software.  Please send changes to tai@iag.hp.com or ken@sdd.hp.com.   */
+/*************************************************************************/
+
+#ifndef lint
+static char RCSid[] = "adjtimed.c,v 3.1 1993/07/06 01:04:45 jbj Exp";
+#endif
+
+/*
+ * Adjust time daemon.
+ * This daemon adjusts the rate of the system clock a la BSD's adjtime().
+ * The adjtime() routine uses SYSV messages to communicate with this daemon.
+ *
+ * Caveat: This emulation uses an undocumented kernel variable.  As such, it
+ * cannot be guaranteed to work in future HP-UX releases.  Fortunately,
+ * it will no longer be needed in HPUX 10.01 and later.
+ */
+
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <sys/lock.h>
+#include <time.h>
+#include <signal.h>
+#include <nlist.h>
+#include <fcntl.h>
+#include <stdio.h>
+#include <unistd.h>
+
+#include "ntp_syslog.h"
+#include "ntp_stdlib.h"
+
+#include "adjtime.h"
+
+double atof (const char *);
+
+int InitClockRate (void);
+int AdjustClockRate (register struct timeval *delta, register struct timeval *olddelta);
+long GetClockRate (void);
+int SetClockRate (long);
+void ResetClockRate (void);
+void Cleanup (void);
+void Exit (int);
+
+#define MILLION                1000000L
+
+/* emacs cc-mode goes nuts if we split the next line... */
+#define tvtod(tv)      ((double)tv.tv_sec + ((double)tv.tv_usec / (double)MILLION))
+
+char *progname = NULL;
+int verbose = 0;
+int sysdebug = 0;
+static int mqid;
+static double oldrate = 0.0;
+
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       struct timeval remains;
+       struct sigvec vec;
+       MsgBuf msg;
+       char ch;
+       int nofork = 0;
+       int fd;
+
+       progname = argv[0];
+
+#ifdef LOG_LOCAL6
+       openlog("adjtimed", LOG_PID, LOG_LOCAL6);
+#else
+       openlog("adjtimed", LOG_PID);
+#endif
+
+       while ((ch = ntp_getopt(argc, argv, "hkrvdfp:")) != EOF) {
+               switch (ch) {
+                   case 'k':
+                   case 'r':
+                       if ((mqid = msgget(KEY, 0)) != -1) {
+                               if (msgctl(mqid, IPC_RMID, (struct msqid_ds *)0) == -1) {
+                                       msyslog(LOG_ERR, "remove old message queue: %m");
+                                       perror("adjtimed: remove old message queue");
+                                       exit(1);
+                               }
+                       }
+
+                       if (ch == 'k')
+                           exit(0);
+
+                       break;
+
+                   case 'v':
+                       ++verbose, nofork = 1;
+                       break;
+
+                   case 'd':
+                       ++sysdebug;
+                       break;
+
+                   case 'f':
+                       nofork = 1;
+                       break;
+
+                   case 'p':
+                       fputs("adjtimed: -p option ignored\n", stderr);
+                       break;
+
+                   default:
+                       puts("usage: adjtimed -hkrvdf");
+                       puts("-h\thelp");
+                       puts("-k\tkill existing adjtimed, if any");
+                       puts("-r\trestart (kills existing adjtimed, if any)");
+                       puts("-v\tdebug output (repeat for more output)");
+                       puts("-d\tsyslog output (repeat for more output)");
+                       puts("-f\tno fork");
+                       msyslog(LOG_ERR, "usage error");
+                       exit(1);
+               } /* switch */
+       } /* while */
+
+       if (!nofork) {
+               switch (fork()) {
+                   case 0:
+                       close(fileno(stdin));
+                       close(fileno(stdout));
+                       close(fileno(stderr));
+
+#ifdef TIOCNOTTY
+                       if ((fd = open("/dev/tty")) != -1) {
+                               ioctl(fd, TIOCNOTTY, 0);
+                               close(fd);
+                       }
+#else
+                       setpgrp();
+#endif
+                       break;
+
+                   case -1:
+                       msyslog(LOG_ERR, "fork: %m");
+                       perror("adjtimed: fork");
+                       exit(1);
+
+                   default:
+                       exit(0);
+               } /* switch */
+       } /* if */
+
+       if (nofork) {
+               setvbuf(stdout, NULL, _IONBF, BUFSIZ);
+               setvbuf(stderr, NULL, _IONBF, BUFSIZ);
+       }
+
+       msyslog(LOG_INFO, "started");
+       if (verbose) printf("adjtimed: started\n");
+
+       if (InitClockRate() == -1)
+           Exit(2);
+
+       (void)signal(SIGHUP, SIG_IGN);
+       (void)signal(SIGINT, SIG_IGN);
+       (void)signal(SIGQUIT, SIG_IGN);
+       (void)signal(SIGTERM, Cleanup);
+
+       vec.sv_handler = ResetClockRate;
+       vec.sv_flags = 0;
+       vec.sv_mask = ~0;
+       sigvector(SIGALRM, &vec, (struct sigvec *)0);
+
+       if (msgget(KEY, IPC_CREAT|IPC_EXCL) == -1) {
+               if (errno == EEXIST) {
+                       msyslog(LOG_ERR, "message queue already exists, use -r to remove it");
+                       fputs("adjtimed: message queue already exists, use -r to remove it\n",
+                             stderr);
+                       Exit(1);
+               }
+
+               msyslog(LOG_ERR, "create message queue: %m");
+               perror("adjtimed: create message queue");
+               Exit(1);
+       }
+
+       if ((mqid = msgget(KEY, 0)) == -1) {
+               msyslog(LOG_ERR, "get message queue id: %m");
+               perror("adjtimed: get message queue id");
+               Exit(1);
+       }
+  
+       /* Lock process in memory to improve response time */
+       if (plock(PROCLOCK)) {
+               msyslog(LOG_ERR, "plock: %m");
+               perror("adjtimed: plock");
+               Cleanup();
+       }
+
+       /* Also raise process priority.
+        * If we do not get run when we want, this leads to bad timekeeping
+        * and "Previous time adjustment didn't complete" gripes from xntpd.
+        */
+       if (nice(-10) == -1) {
+               msyslog(LOG_ERR, "nice: %m");
+               perror("adjtimed: nice");
+               Cleanup();
+       }
+
+       for (;;) {
+               if (msgrcv(mqid, &msg.msgp, MSGSIZE, CLIENT, 0) == -1) {
+                       if (errno == EINTR) continue;
+                       msyslog(LOG_ERR, "read message: %m");
+                       perror("adjtimed: read message");
+                       Cleanup();
+               }
+
+               switch (msg.msgb.code) {
+                   case DELTA1:
+                   case DELTA2:
+                       AdjustClockRate(&msg.msgb.tv, &remains);
+
+                       if (msg.msgb.code == DELTA2) {
+                               msg.msgb.tv = remains;
+                               msg.msgb.mtype = SERVER;
+
+                               while (msgsnd(mqid, &msg.msgp, MSGSIZE, 0) == -1) {
+                                       if (errno == EINTR) continue;
+                                       msyslog(LOG_ERR, "send message: %m");
+                                       perror("adjtimed: send message");
+                                       Cleanup();
+                               }
+                       }
+
+                       if (remains.tv_sec + remains.tv_usec != 0L) {
+                               if (verbose) {
+                                       printf("adjtimed: previous correction remaining %.6fs\n",
+                                              tvtod(remains));
+                               }
+                               if (sysdebug) {
+                                       msyslog(LOG_INFO, "previous correction remaining %.6fs",
+                                               tvtod(remains));
+                               }
+                       }
+                       break;
+
+                   default:
+                       fprintf(stderr, "adjtimed: unknown message code %d\n", msg.msgb.code);
+                       msyslog(LOG_ERR, "unknown message code %d", msg.msgb.code);
+               } /* switch */
+       } /* loop */
+} /* main */
+
+/*
+ * Default clock rate (old_tick).
+ */
+#define DEFAULT_RATE   (MILLION / HZ)
+#define UNKNOWN_RATE   0L
+#define TICK_ADJ       5       /* standard adjustment rate, microsec/tick */
+
+static long default_rate = DEFAULT_RATE;
+static long tick_rate = HZ;    /* ticks per sec */
+static long slew_rate = TICK_ADJ * HZ; /* in microsec/sec */
+
+int
+AdjustClockRate(
+       register struct timeval *delta,
+       register struct timeval *olddelta
+       )
+{
+       register long rate, dt, leftover;
+       struct itimerval period, remains;
+       dt = (delta->tv_sec * MILLION) + delta->tv_usec;
+
+       if (verbose)
+           printf("adjtimed: new correction %.6fs\n", (double)dt / (double)MILLION);
+       if (sysdebug)
+           msyslog(LOG_INFO, "new correction %.6fs", (double)dt / (double)MILLION);
+       if (verbose > 2) printf("adjtimed: leftover %ldus\n", leftover);
+       if (sysdebug > 2) msyslog(LOG_INFO, "leftover %ldus", leftover);
+       rate = dt;
+
+       /*
+        * Apply a slew rate of slew_rate over a period of dt/slew_rate seconds.
+        */
+       if (dt > 0) {
+               rate = slew_rate;
+       } else {
+               rate = -slew_rate;
+               dt = -dt;
+       }
+       period.it_value.tv_sec = dt / slew_rate;
+       period.it_value.tv_usec = (dt % slew_rate) * (MILLION / slew_rate);
+       /*
+        * Note: we assume the kernel will convert the specified period into ticks
+        * using the modified clock rate rather than an assumed nominal clock rate,
+        * and therefore will generate the timer interrupt after the specified
+        * number of true seconds, not skewed seconds.
+        */
+
+       if (verbose > 1)
+           printf("adjtimed: will be complete in %lds %ldus\n",
+                  period.it_value.tv_sec, period.it_value.tv_usec);
+       if (sysdebug > 1)
+           msyslog(LOG_INFO, "will be complete in %lds %ldus",
+                   period.it_value.tv_sec, period.it_value.tv_usec);
+       /*
+        * adjust the clock rate
+        */
+       if (dt) {
+               if (SetClockRate((rate / tick_rate) + default_rate) == -1) {
+                       msyslog(LOG_ERR, "set clock rate: %m");
+                       perror("adjtimed: set clock rate");
+               }
+       }
+       /*
+        * start the timer
+        * (do this after changing the rate because the period has been rounded down)
+        */
+       period.it_interval.tv_sec = period.it_interval.tv_usec = 0L;
+       setitimer(ITIMER_REAL, &period, &remains);
+       /*
+        * return old delta
+        */
+       if (olddelta) {
+               dt = ((remains.it_value.tv_sec * MILLION) + remains.it_value.tv_usec) *
+                       oldrate;
+               olddelta->tv_sec = dt / MILLION;
+               olddelta->tv_usec = dt - (olddelta->tv_sec * MILLION); 
+       }
+
+       oldrate = (double)rate / (double)MILLION;
+       return(0);
+} /* AdjustClockRate */
+
+static struct nlist nl[] = {
+#ifdef __hp9000s800
+#ifdef PRE7_0
+       { "tick" },
+#else
+       { "old_tick" },
+#endif
+#else
+       { "_old_tick" },
+#endif
+       { "" }
+};
+
+static int kmem;
+
+/*
+ * The return value is the clock rate in old_tick units or -1 if error.
+ */
+long
+GetClockRate(void)
+{
+       long rate, mask;
+
+       if (lseek(kmem, (off_t)nl[0].n_value, 0) == -1L)
+           return (-1L);
+
+       mask = sigblock(sigmask(SIGALRM));
+
+       if (read(kmem, (caddr_t)&rate, sizeof(rate)) != sizeof(rate))
+           rate = UNKNOWN_RATE;
+
+       sigsetmask(mask);
+       return (rate);
+} /* GetClockRate */
+
+/*
+ * The argument is the new rate in old_tick units.
+ */
+int
+SetClockRate(
+       long rate
+       )
+{
+       long mask;
+
+       if (lseek(kmem, (off_t)nl[0].n_value, 0) == -1L)
+           return (-1);
+
+       mask = sigblock(sigmask(SIGALRM));
+
+       if (write(kmem, (caddr_t)&rate, sizeof(rate)) != sizeof(rate)) {
+               sigsetmask(mask);
+               return (-1);
+       }
+
+       sigsetmask(mask);
+
+       if (rate != default_rate) {
+               if (verbose > 3) {
+                       printf("adjtimed: clock rate (%lu) %ldus/s\n", rate,
+                              (rate - default_rate) * tick_rate);
+               }
+               if (sysdebug > 3) {
+                       msyslog(LOG_INFO, "clock rate (%lu) %ldus/s", rate,
+                               (rate - default_rate) * tick_rate);
+               }
+       }
+
+       return (0);
+} /* SetClockRate */
+
+int
+InitClockRate(void)
+{
+       if ((kmem = open("/dev/kmem", O_RDWR)) == -1) {
+               msyslog(LOG_ERR, "open(/dev/kmem): %m");
+               perror("adjtimed: open(/dev/kmem)");
+               return (-1);
+       }
+
+       nlist("/hp-ux", nl);
+
+       if (nl[0].n_type == 0) {
+               fputs("adjtimed: /hp-ux has no symbol table\n", stderr);
+               msyslog(LOG_ERR, "/hp-ux has no symbol table");
+               return (-1);
+       }
+       /*
+        * Set the default to the system's original value
+        */
+       default_rate = GetClockRate();
+       if (default_rate == UNKNOWN_RATE) default_rate = DEFAULT_RATE;
+       tick_rate = (MILLION / default_rate);
+       slew_rate = TICK_ADJ * tick_rate;
+       fprintf(stderr,"default_rate=%ld, tick_rate=%ld, slew_rate=%ld\n",default_rate,tick_rate,slew_rate);
+
+       return (0);
+} /* InitClockRate */
+
+/*
+ * Reset the clock rate to the default value.
+ */
+void
+ResetClockRate(void)
+{
+       struct itimerval it;
+
+       it.it_value.tv_sec = it.it_value.tv_usec = 0L;
+       setitimer(ITIMER_REAL, &it, (struct itimerval *)0);
+
+       if (verbose > 2) puts("adjtimed: resetting the clock");
+       if (sysdebug > 2) msyslog(LOG_INFO, "resetting the clock");
+
+       if (GetClockRate() != default_rate) {
+               if (SetClockRate(default_rate) == -1) {
+                       msyslog(LOG_ERR, "set clock rate: %m");
+                       perror("adjtimed: set clock rate");
+               }
+       }
+
+       oldrate = 0.0;
+} /* ResetClockRate */
+
+void
+Cleanup(void)
+{
+       ResetClockRate();
+
+       if (msgctl(mqid, IPC_RMID, (struct msqid_ds *)0) == -1) {
+               if (errno != EINVAL) {
+                       msyslog(LOG_ERR, "remove message queue: %m");
+                       perror("adjtimed: remove message queue");
+               }
+       }
+
+       Exit(2);
+} /* Cleanup */
+
+void
+Exit(status)
+     int status;
+{
+       msyslog(LOG_ERR, "terminated");
+       closelog();
+       if (kmem != -1) close(kmem);
+       exit(status);
+} /* Exit */
diff --git a/arlib/COPYING b/arlib/COPYING
new file mode 100644 (file)
index 0000000..57e5c2a
--- /dev/null
@@ -0,0 +1,46 @@
+Replied: Fri, 16 Feb 2001 14:12:54 -0500
+Replied: "Darren Reed <darrenr@reed.wattle.id.au> "
+Received: from [139.134.6.79] by whimsy.udel.edu id aa15476;
+          16 Feb 2001 04:21 EST
+Received: from CPE-61-9-164-106.vic.bigpond.net.au
+          ([139.134.4.52]) by mailin6.bigpond.com (Netscape Messaging
+          Server 4.15) with SMTP id G8UFIB00.4QI for
+          <stenn@whimsy.udel.edu>; Fri, 16 Feb 2001 19:25:23 +1000 
+Received: from CPE-61-9-164-110.vic.bigpond.net.au ([61.9.164.110]) by mail5.bigpond.com (Claudes-Retiring-MailRouter V2.9c 9/11963672); 16 Feb 2001 19:20:45
+Received: (from root@localhost)
+       by CPE-61-9-164-106.vic.bigpond.net.au (8.11.0/8.11.0) id f1G92GC29158
+       for <stenn@whimsy.udel.edu>; Fri, 16 Feb 2001 20:02:16 +1100
+From: Darren Reed <darrenr@reed.wattle.id.au>
+Message-Id: <200102160901.UAA23657@avalon.reed.wattle.id.au>
+Subject: Re: arlib?
+In-Reply-To: <901.982219274@whimsy.udel.edu> from Harlan Stenn at "Feb 15, 1 01:41:14 am"
+To: Harlan Stenn <stenn@whimsy.udel.edu>
+Date: Fri, 16 Feb 2001 20:01:46 +1100
+X-Mailer: ELM [version 2.4ME+ PL37 (25)]
+MIME-Version: 1.0
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+
+In some email I received from Harlan Stenn, sie wrote:
+> Darren,
+> 
+> I'm looking for an async resolver library that I can use with NTP.
+> 
+> I noticed your code in the contrib/ subdir of later bind8 distribution
+> and I noticed the Copyright notice in arlib.c:
+> 
+>  * arlib.c (C)opyright 1993 Darren Reed. All rights reserved.
+>  * This file may not be distributed without the author's permission in any
+>  * shape or form. The author takes no responsibility for any damage or loss
+>  * of property which results from the use of this software.
+> 
+> so I thought I'd ask your permission to distribute your files if I can
+> figure out how to make it all work with ntpd.
+
+http://coombs.anu.edu.au/~avalon/arlib.tar.gz
+
+a few bug fixes (inc. buffer overflow :) and stuff in there.
+
+But otherwise, go for it.
+
+Darren
diff --git a/arlib/INSTALL b/arlib/INSTALL
new file mode 100644 (file)
index 0000000..b42a17a
--- /dev/null
@@ -0,0 +1,182 @@
+Basic Installation
+==================
+
+   These are generic installation instructions.
+
+   The `configure' shell script attempts to guess correct values for
+various system-dependent variables used during compilation.  It uses
+those values to create a `Makefile' in each directory of the package.
+It may also create one or more `.h' files containing system-dependent
+definitions.  Finally, it creates a shell script `config.status' that
+you can run in the future to recreate the current configuration, a file
+`config.cache' that saves the results of its tests to speed up
+reconfiguring, and a file `config.log' containing compiler output
+(useful mainly for debugging `configure').
+
+   If you need to do unusual things to compile the package, please try
+to figure out how `configure' could check whether to do them, and mail
+diffs or instructions to the address given in the `README' so they can
+be considered for the next release.  If at some point `config.cache'
+contains results you don't want to keep, you may remove or edit it.
+
+   The file `configure.in' is used to create `configure' by a program
+called `autoconf'.  You only need `configure.in' if you want to change
+it or regenerate `configure' using a newer version of `autoconf'.
+
+The simplest way to compile this package is:
+
+  1. `cd' to the directory containing the package's source code and type
+     `./configure' to configure the package for your system.  If you're
+     using `csh' on an old version of System V, you might need to type
+     `sh ./configure' instead to prevent `csh' from trying to execute
+     `configure' itself.
+
+     Running `configure' takes awhile.  While running, it prints some
+     messages telling which features it is checking for.
+
+  2. Type `make' to compile the package.
+
+  3. Optionally, type `make check' to run any self-tests that come with
+     the package.
+
+  4. Type `make install' to install the programs and any data files and
+     documentation.
+
+  5. You can remove the program binaries and object files from the
+     source code directory by typing `make clean'.  To also remove the
+     files that `configure' created (so you can compile the package for
+     a different kind of computer), type `make distclean'.  There is
+     also a `make maintainer-clean' target, but that is intended mainly
+     for the package's developers.  If you use it, you may have to get
+     all sorts of other programs in order to regenerate files that came
+     with the distribution.
+
+Compilers and Options
+=====================
+
+   Some systems require unusual options for compilation or linking that
+the `configure' script does not know about.  You can give `configure'
+initial values for variables by setting them in the environment.  Using
+a Bourne-compatible shell, you can do that on the command line like
+this:
+     CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
+
+Or on systems that have the `env' program, you can do it like this:
+     env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
+
+Compiling For Multiple Architectures
+====================================
+
+   You can compile the package for more than one kind of computer at the
+same time, by placing the object files for each architecture in their
+own directory.  To do this, you must use a version of `make' that
+supports the `VPATH' variable, such as GNU `make'.  `cd' to the
+directory where you want the object files and executables to go and run
+the `configure' script.  `configure' automatically checks for the
+source code in the directory that `configure' is in and in `..'.
+
+   If you have to use a `make' that does not supports the `VPATH'
+variable, you have to compile the package for one architecture at a time
+in the source code directory.  After you have installed the package for
+one architecture, use `make distclean' before reconfiguring for another
+architecture.
+
+Installation Names
+==================
+
+   By default, `make install' will install the package's files in
+`/usr/local/bin', `/usr/local/man', etc.  You can specify an
+installation prefix other than `/usr/local' by giving `configure' the
+option `--prefix=PATH'.
+
+   You can specify separate installation prefixes for
+architecture-specific files and architecture-independent files.  If you
+give `configure' the option `--exec-prefix=PATH', the package will use
+PATH as the prefix for installing programs and libraries.
+Documentation and other data files will still use the regular prefix.
+
+   In addition, if you use an unusual directory layout you can give
+options like `--bindir=PATH' to specify different values for particular
+kinds of files.  Run `configure --help' for a list of the directories
+you can set and what kinds of files go in them.
+
+   If the package supports it, you can cause programs to be installed
+with an extra prefix or suffix on their names by giving `configure' the
+option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'.
+
+Optional Features
+=================
+
+   Some packages pay attention to `--enable-FEATURE' options to
+`configure', where FEATURE indicates an optional part of the package.
+They may also pay attention to `--with-PACKAGE' options, where PACKAGE
+is something like `gnu-as' or `x' (for the X Window System).  The
+`README' should mention any `--enable-' and `--with-' options that the
+package recognizes.
+
+   For packages that use the X Window System, `configure' can usually
+find the X include and library files automatically, but if it doesn't,
+you can use the `configure' options `--x-includes=DIR' and
+`--x-libraries=DIR' to specify their locations.
+
+Specifying the System Type
+==========================
+
+   There may be some features `configure' can not figure out
+automatically, but needs to determine by the type of host the package
+will run on.  Usually `configure' can figure that out, but if it prints
+a message saying it can not guess the host type, give it the
+`--host=TYPE' option.  TYPE can either be a short name for the system
+type, such as `sun4', or a canonical name with three fields:
+     CPU-COMPANY-SYSTEM
+
+See the file `config.sub' for the possible values of each field.  If
+`config.sub' isn't included in this package, then this package doesn't
+need to know the host type.
+
+   If you are building compiler tools for cross-compiling, you can also
+use the `--target=TYPE' option to select the type of system they will
+produce code for and the `--build=TYPE' option to select the type of
+system on which you are compiling the package.
+
+Sharing Defaults
+================
+
+   If you want to set default values for `configure' scripts to share,
+you can create a site shell script called `config.site' that gives
+default values for variables like `CC', `cache_file', and `prefix'.
+`configure' looks for `PREFIX/share/config.site' if it exists, then
+`PREFIX/etc/config.site' if it exists.  Or, you can set the
+`CONFIG_SITE' environment variable to the location of the site script.
+A warning: not all `configure' scripts look for a site script.
+
+Operation Controls
+==================
+
+   `configure' recognizes the following options to control how it
+operates.
+
+`--cache-file=FILE'
+     Use and save the results of the tests in FILE instead of
+     `./config.cache'.  Set FILE to `/dev/null' to disable caching, for
+     debugging `configure'.
+
+`--help'
+     Print a summary of the options to `configure', and exit.
+
+`--quiet'
+`--silent'
+`-q'
+     Do not print messages saying which checks are being made.  To
+     suppress all normal output, redirect it to `/dev/null' (any error
+     messages will still be shown).
+
+`--srcdir=DIR'
+     Look for the package's source code in directory DIR.  Usually
+     `configure' can determine that directory automatically.
+
+`--version'
+     Print the version of Autoconf used to generate the `configure'
+     script, and exit.
+
+`configure' also accepts some other, not widely useful, options.
diff --git a/arlib/Makefile.am b/arlib/Makefile.am
new file mode 100644 (file)
index 0000000..c0b4094
--- /dev/null
@@ -0,0 +1,15 @@
+AUTOMAKE_OPTIONS = foreign # ansi2knr
+
+#lib_LIBRARIES = libares.a
+noinst_LIBRARIES = libares.a
+libares_a_SOURCES = arlib.c arplib.h
+#include_HEADERS = arlib.h
+noinst_HEADERS = arlib.h
+
+noinst_PROGRAMS = example
+example_SOURCES = sample.c
+example_LDADD = libares.a
+#man_MANS = arlib.3
+#EXTRA_DIST = $(man_MANS) UNSHAR.HDR
+noinst_MANS = arlib.3
+EXTRA_DIST = $(noinst_MANS) UNSHAR.HDR
diff --git a/arlib/Makefile.in b/arlib/Makefile.in
new file mode 100644 (file)
index 0000000..590880f
--- /dev/null
@@ -0,0 +1,580 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+noinst_PROGRAMS = example$(EXEEXT)
+subdir = .
+DIST_COMMON = README $(am__configure_deps) $(noinst_HEADERS) \
+       $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       $(top_srcdir)/configure COPYING INSTALL depcomp install-sh \
+       missing
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/configure.in
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+AR = ar
+ARFLAGS = cru
+libares_a_AR = $(AR) $(ARFLAGS)
+libares_a_LIBADD =
+am_libares_a_OBJECTS = arlib.$(OBJEXT)
+libares_a_OBJECTS = $(am_libares_a_OBJECTS)
+PROGRAMS = $(noinst_PROGRAMS)
+am_example_OBJECTS = sample.$(OBJEXT)
+example_OBJECTS = $(am_example_OBJECTS)
+example_DEPENDENCIES = libares.a
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+COMPILE = $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) \
+       $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
+CCLD = $(CC)
+LINK = $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) $(LDFLAGS) -o $@
+SOURCES = $(libares_a_SOURCES) $(example_SOURCES)
+DIST_SOURCES = $(libares_a_SOURCES) $(example_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d "$(distdir)" \
+    || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr "$(distdir)"; }; }
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EXEEXT = @EXEEXT@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBS = @LIBS@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build_alias = @build_alias@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host_alias = @host_alias@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign # ansi2knr
+
+#lib_LIBRARIES = libares.a
+noinst_LIBRARIES = libares.a
+libares_a_SOURCES = arlib.c arplib.h
+#include_HEADERS = arlib.h
+noinst_HEADERS = arlib.h
+example_SOURCES = sample.c
+example_LDADD = libares.a
+#man_MANS = arlib.3
+#EXTRA_DIST = $(man_MANS) UNSHAR.HDR
+noinst_MANS = arlib.3
+EXTRA_DIST = $(noinst_MANS) UNSHAR.HDR
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .o .obj
+am--refresh:
+       @:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
+             $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
+               && exit 0; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           echo ' $(SHELL) ./config.status'; \
+           $(SHELL) ./config.status;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       $(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+       -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libares.a: $(libares_a_OBJECTS) $(libares_a_DEPENDENCIES) 
+       -rm -f libares.a
+       $(libares_a_AR) libares.a $(libares_a_OBJECTS) $(libares_a_LIBADD)
+       $(RANLIB) libares.a
+
+clean-noinstPROGRAMS:
+       -test -z "$(noinst_PROGRAMS)" || rm -f $(noinst_PROGRAMS)
+example$(EXEEXT): $(example_OBJECTS) $(example_DEPENDENCIES) 
+       @rm -f example$(EXEEXT)
+       $(LINK) $(example_OBJECTS) $(example_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/arlib.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sample.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(CYGPATH_W) '$<'`
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       $(am__remove_distdir)
+       test -d "$(distdir)" || mkdir "$(distdir)"
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       -test -n "$(am__skip_mode_fix)" \
+       || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+         ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+       || chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+dist-bzip2: distdir
+       tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+       $(am__remove_distdir)
+
+dist-lzma: distdir
+       tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+       $(am__remove_distdir)
+
+dist-xz: distdir
+       tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
+       $(am__remove_distdir)
+
+dist-tarZ: distdir
+       tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+       $(am__remove_distdir)
+
+dist-shar: distdir
+       shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+       $(am__remove_distdir)
+
+dist-zip: distdir
+       -rm -f $(distdir).zip
+       zip -rq $(distdir).zip $(distdir)
+       $(am__remove_distdir)
+
+dist dist-all: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+       case '$(DIST_ARCHIVES)' in \
+       *.tar.gz*) \
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+       *.tar.bz2*) \
+         bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+       *.tar.lzma*) \
+         unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
+       *.tar.xz*) \
+         xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+       *.tar.Z*) \
+         uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+       *.shar.gz*) \
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+       *.zip*) \
+         unzip $(distdir).zip ;;\
+       esac
+       chmod -R a-w $(distdir); chmod a+w $(distdir)
+       mkdir $(distdir)/_build
+       mkdir $(distdir)/_inst
+       chmod a-w $(distdir)
+       test -d $(distdir)/_build || exit 0; \
+       dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+         && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+         && am__cwd=`pwd` \
+         && $(am__cd) $(distdir)/_build \
+         && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+           $(DISTCHECK_CONFIGURE_FLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) dvi \
+         && $(MAKE) $(AM_MAKEFLAGS) check \
+         && $(MAKE) $(AM_MAKEFLAGS) install \
+         && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+         && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+         && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+               distuninstallcheck \
+         && chmod -R a-w "$$dc_install_base" \
+         && ({ \
+              (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+                   distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+             } || { rm -rf "$$dc_destdir"; exit 1; }) \
+         && rm -rf "$$dc_destdir" \
+         && $(MAKE) $(AM_MAKEFLAGS) dist \
+         && rm -rf $(DIST_ARCHIVES) \
+         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+         && cd "$$am__cwd" \
+         || exit 1
+       $(am__remove_distdir)
+       @(echo "$(distdir) archives ready for distribution: "; \
+         list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+         sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+       @$(am__cd) '$(distuninstallcheck_dir)' \
+       && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+          || { echo "ERROR: files left after uninstall:" ; \
+               if test -n "$(DESTDIR)"; then \
+                 echo "  (check DESTDIR support)"; \
+               fi ; \
+               $(distuninstallcheck_listfiles) ; \
+               exit 1; } >&2
+distcleancheck: distclean
+       @if test '$(srcdir)' = . ; then \
+         echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+         exit 1 ; \
+       fi
+       @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+         || { echo "ERROR: files left in build directory after distclean:" ; \
+              $(distcleancheck_listfiles) ; \
+              exit 1; } >&2
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf $(top_srcdir)/autom4te.cache
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am am--refresh check check-am clean \
+       clean-generic clean-noinstLIBRARIES clean-noinstPROGRAMS ctags \
+       dist dist-all dist-bzip2 dist-gzip dist-lzma dist-shar \
+       dist-tarZ dist-xz dist-zip distcheck distclean \
+       distclean-compile distclean-generic distclean-tags \
+       distcleancheck distdir distuninstallcheck 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 pdf pdf-am ps ps-am tags uninstall \
+       uninstall-am
+
+
+# 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.
+.NOEXPORT:
diff --git a/arlib/README b/arlib/README
new file mode 100644 (file)
index 0000000..1d2e787
--- /dev/null
@@ -0,0 +1,49 @@
+
+                               Asynchronous DNS
+                               ----------------
+
+       Intro.
+
+For those who write real time network applications that have to handle
+multiple TCP or UDP connections, the problem of effectively doing DNS
+lookups is quite real.  Generally, this means the program waits while
+the query finishes, holding everything else up.  This small library of
+routines aims to solve that problem by performing the DNS query and
+then returning the program to its normal flow.
+
+       Whats included ?
+
+The library routines, arlib.c, a header file for it, arlib.h, a man
+page, arlib.3 and an example of how this sort of code is used,
+sample.c.
+
+
+       Compilation & Installation.
+
+Edit the Makefile and do "make install" to install things where you
+wish them to go.  You should check it makes and works before doing
+this :)
+
+If the compilation is successful, you'll have an executeable called
+"example" and libares.a.  "example" is a simple program which will
+do hostname->IP# or IP#->hostnae lookups by entering either the
+hostname or IP# on the line with "Host-->".  You dont have to wait
+for a query to fail or succeed before typing in the next line.
+
+       Portability.
+
+I'm not sure how portable this is, it was written under SunOS 4.1.2
+on a Sparc 1+ and hasn't been tested very widely.  If you find any
+problems when compiling/execution, plase send me a patch (using
+diff -c) to avalon@coombs.anu.edu.au.  If it goes well enough, I'll
+send it to comp.unix.sources or comp.sources.misc for further testing.
+
+       Future additions.
+
+Adding a working cache would be nice but I'm not sure if that really
+is needed (?).  I guess it depends on how often your program is
+required to do a DNS lookup and whether caching would help.
+
+
+Cheers,
+Darren.
diff --git a/arlib/UNSHAR.HDR b/arlib/UNSHAR.HDR
new file mode 100644 (file)
index 0000000..c92d475
--- /dev/null
@@ -0,0 +1,32 @@
+Replied: Sun, 19 Dec 93 09:58:30 PST
+Replied: "Darren Reed <avalon@coombs.anu.edu.au> "
+Return-Path: avalon@coombs.anu.edu.au
+Received: by gw.home.vix.com id AA12017; Sun, 19 Dec 93 07:04:44 -0800
+Message-Id: <9312191504.AA12017@gw.home.vix.com>
+Received: by coombs.anu.edu.au
+       (1.37.109.8/16.2) id AA10850; Mon, 20 Dec 1993 02:07:21 +1100
+From: Darren Reed <avalon@coombs.anu.edu.au>
+Subject: Addition for 4.9 "contrib" directory
+To: paul@vix.com
+Date: Mon, 20 Dec 1993 02:07:20 +1000 (EDT)
+X-Mailer: ELM [version 2.4 PL21]
+Mime-Version: 1.0
+Content-Type: text/plain; charset=US-ASCII
+Content-Transfer-Encoding: 7bit
+Content-Length: 67950     
+
+
+Well, I just sent one letter off to dec.com, being from the 4.9 README I had.
+
+So, to sum up what I said, I've included below, some code I've written to
+perform async. DNS lookups - `replacements' for gethostbyname and
+gethostbyaddr.  I've written and tested it mainly on a HP-UX machine, so
+I'm not sure how it will port to others, but I've tried to keep the amount
+of OS specific code to a minimum.
+
+The Makefile is setup to work best from "contrib/arlib", which is how I
+checked to make sure it worked and ran well.  There's a man page included
+also.
+
+Cheers,
+Darren
diff --git a/arlib/aclocal.m4 b/arlib/aclocal.m4
new file mode 100644 (file)
index 0000000..fb69e8e
--- /dev/null
@@ -0,0 +1,951 @@
+# generated automatically by aclocal 1.11 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+# This file 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
+[m4_warning([this file was generated for autoconf 2.65.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
+
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.11'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.11], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.11])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 9
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 10
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
+       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
+       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
+       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                   [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+#serial 5
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 16
+
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.62])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+             [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+                            [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+                 [_AM_DEPENDENCIES(CC)],
+                 [define([AC_PROG_CC],
+                         defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+                 [_AM_DEPENDENCIES(CXX)],
+                 [define([AC_PROG_CXX],
+                         defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+                 [_AM_DEPENDENCIES(OBJC)],
+                 [define([AC_PROG_OBJC],
+                         defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+])
+_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
+dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
+dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
+dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+])
+
+dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+AC_SUBST(install_sh)])
+
+# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 2
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes.                 -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 4
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 6
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_PROG_MKDIR_P
+# ---------------
+# Check for `mkdir -p'.
+AC_DEFUN([AM_PROG_MKDIR_P],
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+  [[\\/$]]* | ?:[[\\/]]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 4
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 5
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \   ]]*)
+    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$[*]" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$[*]" != "X $srcdir/configure conftest.file" \
+      && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 2
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 2
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [m4_case([$1], [ustar],, [pax],,
+              [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+  case $_am_tool in
+  gnutar)
+    for _am_tar in tar gnutar gtar;
+    do
+      AM_RUN_LOG([$_am_tar --version]) && break
+    done
+    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+    am__untar="$_am_tar -xf -"
+    ;;
+  plaintar)
+    # Must skip GNU tar: if it does not support --format= it doesn't create
+    # ustar tarball either.
+    (tar --version) >/dev/null 2>&1 && continue
+    am__tar='tar chf - "$$tardir"'
+    am__tar_='tar chf - "$tardir"'
+    am__untar='tar xf -'
+    ;;
+  pax)
+    am__tar='pax -L -x $1 -w "$$tardir"'
+    am__tar_='pax -L -x $1 -w "$tardir"'
+    am__untar='pax -r'
+    ;;
+  cpio)
+    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+    am__untar='cpio -i -H $1 -d'
+    ;;
+  none)
+    am__tar=false
+    am__tar_=false
+    am__untar=false
+    ;;
+  esac
+
+  # If the value was cached, stop now.  We just wanted to have am__tar
+  # and am__untar set.
+  test -n "${am_cv_prog_tar_$1}" && break
+
+  # tar/untar a dummy directory, and stop if the command works
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  echo GrepMe > conftest.dir/file
+  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+  rm -rf conftest.dir
+  if test -s conftest.tar; then
+    AM_RUN_LOG([$am__untar <conftest.tar])
+    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+  fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
diff --git a/arlib/arlib.3 b/arlib/arlib.3
new file mode 100644 (file)
index 0000000..afdc02f
--- /dev/null
@@ -0,0 +1,230 @@
+.TH arlib 3
+.SH NAME
+ar_answer, ar_close, ar_delete, ar_gethostbyname, ar_gethostbyaddr,
+ar_init, ar_open, ar_timeout - Asynchronous DNS library routines
+.SH SYNOPSIS
+.nf
+.B #include "arlib.h"
+
+.B struct hostent *ar_answer(dataptr, size)
+.B char *dataptr;
+.B int size;
+
+.B void ar_close();
+
+.B int ar_delete(dataptr, size)
+.B char *dataptr;
+.B int size;
+
+.B int ar_gethostbyname(name, dataptr, size)
+.B char *name;
+.B char *dataptr;
+.B int size;
+
+.B int ar_gethostbyaddr(name, dataptr, size)
+.B char *name;
+.B char *dataptr;
+.B int size;
+
+.B int ar_init(flags)
+.B int flags;
+
+.B int ar_open();
+
+.B long ar_timeout(time, dataptr, size)
+.B long time;
+.B char *dataptr;
+.B int size;
+.fi
+.SH DESCRIPTION
+
+.PP
+   This small library of DNS routines is intended to provide an
+asynchronous interface to performing hostname and IP number lookups.
+Only lookups of Internet domain are handled as yet.  To use this
+set of routines properly, the presence of the
+.B "BIND 4.8"
+resolve
+libraries is required (or any library derived from it).
+.PP
+   This library should be used in conjunction with
+.B select(2)
+to wait for
+the name server's reply to arrive or the lookup to timeout.
+.PP
+   To open a fd for talking to the name server, either
+.B ar_open()
+or
+ar_init()
+must be used.
+.B  ar_open()
+ will open either a datagram socket
+or a virtual circuit with the name server, depending on the flags
+set in the _res structure (see
+.B resolv(5)
+).  In both cases, if the socket
+
+> i
+.B  ar_init()
+is
+used to both open the socket (as in
+.B ar_open()
+) and initialize the
+queues used by this library.  The values recognized as parameters to
+.B ar_init()
+are:
+
+.RS
+#define ARES_INITLIST   1
+.RE
+.RS
+#define ARES_CALLINIT   2
+.RE
+.RS
+#define ARES_INITSOCK   4
+.RE
+.RS
+#define ARES_INITDEBG   8
+.RE
+
+   ARES_INITLIST initializes the list of queries waiting for replies.
+ARES_CALLINIT is a flag which when set causes
+.B res_init()
+to be called.
+ARES_INITSOCK will close the current socket if it is open and call
+.B ar_open()
+to open a new one, returning the fd for that socket.
+ARES_INITDEBG sets the RES_DEBUG flag of the
+.B _res
+structure.
+ARES_INITCACH is as yet, unused and is for future use where the library
+keeps its own cache of replies.
+
+   To send a query about either a hostname or an IP number,
+.B ar_gethostbyname()
+and
+.B ar_gethostbyaddr()
+must be used.  Each takes
+either a pointer to the hostname or the IP number respectively for use
+when making the query.  In addition to this, both (optionally) can be
+passed a pointer to data, dataptr, with the size also passed which can
+be used for identifying individual queries.  A copy of the area pointed
+to is made if dataptr is non NULL and size is non zero.  These functions
+will always return NULL unless the answer to the query is found in
+internal caches.  A new flag, RES_CHECKPTR is checked during the
+processing of answers for
+.B ar_gethostbyname()
+which will automatically
+cause a reverse lookup to be queued, causing a failure if that reply
+differs from the original.
+
+   To check for a query,
+.B ar_answer()
+is called with a pointer to an  area
+of memory which is sufficient to hold what was originally passed via
+.B ar_gethostbyname()
+or
+.B ar_gethostbyaddr()
+through dataptr.  If an answer
+is found, a pointer to the host information is returned and the data
+segment copied if dataptr is non NULL and it was originally passed.  The
+size of the copied data is the smaller of the passed size and that of
+original data stored.
+
+   To expire old queries,
+.B ar_timeout()
+is called with the 'current' time
+(or the time for which you want to do timeouts for).  If a queue entry
+is too old, it will be expired when it has exhausted all available avenues
+for lookups and the data segment for the expired query copied into
+dataptr.  The size of the copied data is the smaller of the passed size
+and that of the original stored data.  Only 1 entry is thus expired with
+each call, requiring that it be called immediately after an expiration
+to check for others.  In addition to expiring lookups,
+.B ar_timeout()
+also
+triggers resends of queries and the searching of the domain tree for the
+host, the latter works from the
+.B _res
+structure of
+.B resolv(5).
+
+   To delete entries from the queue,
+.B ar_delete()
+can be used and by
+passing the pointer and size of the data segment, all queries have their
+data segments checked (if present) for an exact match, being deleted if
+and only if there is a match.  A NULL pointer passed to ar_deleted()
+matches all queries which were called with a NULL dataptr parameter.
+The amount of data compared is the smaller of the size passed and that
+of the data stored for the queue entry being compared.
+
+   To close a socket opened by
+.B ar_open()
+,
+.B ar_close()
+should  be used so
+that it is closed and also marked closed within this library.
+
+   
+.SH DIAGNOSIS
+
+.B ar_open()
+returns -1 if a socket isn't open and could not be opened;
+otherwise returns the current fd open or the fd it opened.
+
+.B ar_init()
+returns -1 for any errors, the value returned by
+.B res_init()
+if
+.B res_init()
+was called, the return value for
+.B ar_open()
+if that was
+called or the current socket open if 0 is passed and a socket is open.
+If neither
+.B res_init()
+or
+.B ar_open()
+are called and the flags are non-zero, -2 is returned.
+.B ar_gethostbyaddr()
+and
+.B ar_gethostbyname()
+will always return NULL in this version but may return a pointer to a hostent
+structure if a cache is being used and the answer is found in the cache.
+
+.B ar_answer()
+returns NULL if the answer is either not found or the
+query returned an error and another attempt at a lookup is attempted.
+If an answer was found, it returned a pointer to this structure and
+the contents of the data segment copied over.
+
+.B ar_timeout()
+returns the time when it should be called next or 0 if
+there are no queries in the queue to be checked later.  If any queries
+are expired, the data segment is copied over if dataptr is non NULL.
+
+.B ar_delete()
+returns the number of entries that were found to match
+and consequently deleted.
+
+.SH SEE ALSO
+
+gethostbyaddr(3), gethostbyname(3), resolv(5)
+
+.SH FILES
+.nf
+arlib.h
+/usr/include/resolv.h
+/usr/include/arpa/nameser.h
+/etc/resolv.conf
+
+.SH BUGS
+
+The results of a successful call to ar_answer() destroy the structure
+for any previous calls.
+
+.SH AUTHOR
+
+Darren Reed.  Email address: avalon@coombs.anu.edu.au
diff --git a/arlib/arlib.c b/arlib/arlib.c
new file mode 100644 (file)
index 0000000..3d76e57
--- /dev/null
@@ -0,0 +1,1056 @@
+/*
+ * arlib.c (C)opyright 1993 Darren Reed. All rights reserved.
+ * This file may not be distributed without the author's permission in any
+ * shape or form. The author takes no responsibility for any damage or loss
+ * of property which results from the use of this software.
+ */
+#ifndef lint
+static char    sccsid[] = "@(#)arlib.c 1.9 6/5/93 (C)opyright 1992 Darren \
+Reed. ASYNC DNS";
+#endif
+
+#include <stdio.h>
+#include <fcntl.h>
+#include <signal.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include "netdb.h"
+#include "arpa/nameser.h"
+#include <resolv.h>
+#include "arlib.h"
+#include "arplib.h"
+
+extern int     errno, h_errno;
+static char    ar_hostbuf[65], ar_domainname[65];
+static char    ar_dot[] = ".";
+static int     ar_resfd = -1, ar_vc = 0;
+static struct  reslist *ar_last, *ar_first;
+
+/*
+ * Statistics structure.
+ */
+static struct  resstats {
+       int     re_errors;
+       int     re_nu_look;
+       int     re_na_look;
+       int     re_replies;
+       int     re_requests;
+       int     re_resends;
+       int     re_sent;
+       int     re_timeouts;
+} ar_reinfo;
+
+static int do_query_name(/* struct resinfo *, char *, struct reslist * */);
+static int do_query_number(/* struct resinfo *, char *, struct reslist * */);
+static int ar_resend_query(/* struct reslist * */);
+
+/*
+ * ar_init
+ *
+ * Initializes the various ARLIB internal varilables and related DNS
+ * options for res_init().
+ *
+ * Returns 0 or the socket opened for use with talking to name servers
+ * if 0 is passed or ARES_INITSOCK is set.
+ */
+int    ar_init(op)
+int    op;
+{
+       int     ret = 0;
+
+       if (op & ARES_INITLIST)
+           {
+               bzero(&ar_reinfo, sizeof(ar_reinfo));
+               ar_first = ar_last = NULL;
+           }
+
+       if (op & ARES_CALLINIT && !(_res.options & RES_INIT))
+           {
+               ret = res_init();
+               (void)strcpy(ar_domainname, ar_dot);
+               (void)strncat(ar_domainname, _res.defdname,
+                               sizeof(ar_domainname)-2);
+           }
+
+       if (op & ARES_INITSOCK)
+               ret = ar_resfd = ar_open();
+
+       if (op & ARES_INITDEBG)
+               _res.options |= RES_DEBUG;
+
+       if (op == 0)
+               ret = ar_resfd;
+
+       return ret;
+}
+
+
+/*
+ * ar_open
+ *
+ * Open a socket to talk to a name server with.
+ * Check _res.options to see if we use a TCP or UDP socket.
+ */
+int    ar_open()
+{
+       if (ar_resfd == -1)
+           {
+               if (_res.options & RES_USEVC)
+                   {
+                       struct  sockaddr_in     *sip;
+                       int     i;
+
+                       sip = _res.NS_ADDR_LIST;        /* was _res.nsaddr_list */
+                       ar_vc = 1;
+                       ar_resfd = socket(AF_INET, SOCK_STREAM, 0);
+
+                       /*
+                        * Try each name server listed in sequence until we
+                        * succeed or run out.
+                        */
+                       while (connect(ar_resfd, (struct sockaddr *)sip++,
+                                       sizeof(struct sockaddr)))
+                           {
+                               (void)close(ar_resfd);
+                               ar_resfd = -1;
+                               if (i >= _res.nscount)
+                                       break;
+                               ar_resfd = socket(AF_INET, SOCK_STREAM, 0);
+                           }
+                   }
+               else
+                       ar_resfd = socket(AF_INET, SOCK_DGRAM, 0);
+           }
+       if (ar_resfd >= 0)
+           {   /* Need one of these two here - and it MUST work!! */
+               int flags;
+
+               if ((flags = fcntl(ar_resfd, F_GETFL, 0)) != -1)
+#ifdef O_NONBLOCK
+                        if (fcntl(ar_resfd, F_SETFL, flags|O_NONBLOCK) == -1)
+#else
+# ifdef        O_NDELAY
+                        if (fcntl(ar_resfd, F_SETFL, flags|O_NDELAY) == -1)
+# else
+#  ifdef       FNDELAY
+                        if (fcntl(ar_resfd, F_SETFL, flags|FNDELAY) == -1)
+#  endif
+# endif
+#endif
+                   {
+                       (void)close(ar_resfd);
+                       ar_resfd = -1;
+                   }
+           }
+       return ar_resfd;
+}
+
+
+/*
+ * ar_close
+ *
+ * Closes and flags the ARLIB socket as closed.
+ */
+void   ar_close()
+{
+       (void)close(ar_resfd);
+       ar_resfd = -1;
+       return;
+}
+
+
+/*
+ * ar_add_request
+ *
+ * Add a new DNS query to the end of the query list.
+ */
+static int     ar_add_request(new)
+struct reslist *new;
+{
+       if (!new)
+               return -1;
+       if (!ar_first)
+               ar_first = ar_last = new;
+       else {
+               ar_last->re_next = new;
+               ar_last = new;
+       }
+       new->re_next = NULL;
+       ar_reinfo.re_requests++;
+       return 0;
+}
+
+
+/*
+ * ar_remrequest
+ *
+ * Remove a request from the list. This must also free any memory that has
+ * been allocated for temporary storage of DNS results.
+ *
+ * Returns -1 if there are anyy problems removing the requested structure
+ * or 0 if the remove is successful.
+ */
+static int     ar_remrequest(old)
+struct reslist *old;
+{
+       register struct reslist *rptr, *r2ptr;
+       register char   **s;
+
+       if (!old)
+               return -1;
+       for (rptr = ar_first, r2ptr = NULL; rptr; rptr = rptr->re_next)
+           {
+               if (rptr == old)
+                       break;
+               r2ptr = rptr;
+           }
+
+       if (!rptr)
+               return -1;
+       if (rptr == ar_first)
+               ar_first = ar_first->re_next;
+       else if (rptr == ar_last)
+           {
+               if (ar_last = r2ptr)
+                       ar_last->re_next = NULL;
+           }
+       else
+               r2ptr->re_next = rptr->re_next;
+
+       if (!ar_first)
+               ar_last = ar_first;
+
+#ifdef ARLIB_DEBUG
+       ar_dump_hostent("ar_remrequest:", rptr->re_he);
+#endif
+
+       if (rptr->re_he.h_name)
+               (void)free(rptr->re_he.h_name);
+       if (s = rptr->re_he.h_aliases)
+               for (; *s; s++)
+                       (void)free(*s);
+       if (rptr->re_rinfo.ri_ptr)
+               (void)free(rptr->re_rinfo.ri_ptr);
+       (void)free(rptr);
+
+       return 0;
+}
+
+
+/*
+ * ar_make_request
+ *
+ * Create a DNS query recorded for the request being made and place it on the
+ * current list awaiting replies.  Initialization of the record with set
+ * values should also be done.
+ */
+static struct  reslist *ar_make_request(resi)
+register struct        resinfo *resi;
+{
+       register struct reslist *rptr;
+       register struct resinfo *rp;
+
+       rptr = (struct reslist *)calloc(1, sizeof(struct reslist));
+       rp = &rptr->re_rinfo;
+
+       rptr->re_next    = NULL; /* where NULL is non-zero ;) */
+       rptr->re_sentat  = time(NULL);
+       rptr->re_retries = _res.retry;
+       rptr->re_sends = 1;
+       rptr->re_resend  = 1;
+       rptr->re_timeout = rptr->re_sentat + _res.retrans;
+       rptr->re_he.h_name = NULL;
+       rptr->re_he.h_addrtype   = AF_INET;
+       rptr->re_he.h_aliases[0] = NULL;
+       rp->ri_ptr = resi->ri_ptr;
+       rp->ri_size = resi->ri_size;
+
+       (void)ar_add_request(rptr);
+
+       return rptr;
+}
+
+
+/*
+ * ar_timeout
+ *
+ * Remove queries from the list which have been there too long without
+ * being resolved.
+ */
+long   ar_timeout(now, info, size)
+time_t now;
+char   *info;
+int    size;
+{
+       register struct reslist *rptr, *r2ptr;
+       register long   next = 0;
+
+       for (rptr = ar_first, r2ptr = NULL; rptr; rptr = r2ptr)
+           {
+               r2ptr = rptr->re_next;
+               if (now >= rptr->re_timeout)
+                   {
+                       /*
+                        * If the timeout for the query has been exceeded,
+                        * then resend the query if we still have some
+                        * 'retry credit' and reset the timeout. If we have
+                        * used it all up, then remove the request.
+                        */
+                       if (--rptr->re_retries <= 0)
+                           {
+                               ar_reinfo.re_timeouts++;
+                               if (info && rptr->re_rinfo.ri_ptr)
+                                       bcopy(rptr->re_rinfo.ri_ptr, info,
+                                               MIN(rptr->re_rinfo.ri_size,
+                                                   size));
+                               (void)ar_remrequest(rptr);
+                               return now;
+                           }
+                       else
+                           {
+                               rptr->re_sends++;
+                               rptr->re_sentat = now;
+                               rptr->re_timeout = now + _res.retrans;
+                               (void)ar_resend_query(rptr);
+                           }
+                   }
+               if (!next || rptr->re_timeout < next)
+                       next = rptr->re_timeout;
+           }
+       return next;
+}
+
+
+/*
+ * ar_send_res_msg
+ *
+ * When sending queries to nameservers listed in the resolv.conf file,
+ * don't send a query to every one, but increase the number sent linearly
+ * to match the number of resends. This increase only occurs if there are
+ * multiple nameserver entries in the resolv.conf file.
+ * The return value is the number of messages successfully sent to 
+ * nameservers or -1 if no successful sends.
+ */
+static int     ar_send_res_msg(msg, len, rcount)
+char   *msg;
+int    len, rcount;
+{
+       register int    i;
+       int     sent = 0;
+
+       if (!msg)
+               return -1;
+
+       rcount = (_res.nscount > rcount) ? rcount : _res.nscount;
+       if (_res.options & RES_PRIMARY)
+               rcount = 1;
+
+       if (ar_vc)
+           {
+               ar_reinfo.re_sent++;
+               sent++;
+               if (write(ar_resfd, msg, len) == -1)
+                   {
+                       int errtmp = errno;
+                       (void)close(ar_resfd);
+                       errno = errtmp;
+                       ar_resfd = -1;
+                   }
+           }
+       else
+               for (i = 0; i < rcount; i++)
+                   {
+                       if (sendto(ar_resfd, msg, len, 0,
+                                  (struct sockaddr *)&(_res.NS_ADDR_LIST[i]),
+                               sizeof(struct sockaddr_in)) == len)
+                           {
+                               ar_reinfo.re_sent++;
+                               sent++;
+                           }
+                   }
+       return (sent) ? sent : -1;
+}
+
+
+/*
+ * ar_find_id
+ *
+ * find a dns query record by the id (id is determined by dn_mkquery)
+ */
+static struct  reslist *ar_find_id(id)
+int    id;
+{
+       register struct reslist *rptr;
+
+       for (rptr = ar_first; rptr; rptr = rptr->re_next)
+               if (rptr->re_id == id)
+                       return rptr;
+       return NULL;
+}
+
+
+/*
+ * ar_delete
+ *
+ * Delete a request from the waiting list if it has a data pointer which
+ * matches the one passed.
+ */
+int    ar_delete(ptr, size)
+char   *ptr;
+int    size;
+{
+       register struct reslist *rptr;
+       register struct reslist *r2ptr;
+       int     removed = 0;
+
+       for (rptr = ar_first; rptr; rptr = r2ptr)
+           {
+               r2ptr = rptr->re_next;
+               if (rptr->re_rinfo.ri_ptr && ptr && size &&
+                   bcmp(rptr->re_rinfo.ri_ptr, ptr, size) == 0)
+                   {
+                       (void)ar_remrequest(rptr);
+                       removed++;
+                   }
+           }
+       return removed;
+}
+
+
+/*
+ * ar_query_name
+ *
+ * generate a query based on class, type and name.
+ */
+static int     ar_query_name(name, class, type, rptr)
+char   *name;
+int    class, type;
+struct reslist *rptr;
+{
+       static  char buf[MAXPACKET];
+       int     r,s,a;
+       HEADER  *hptr;
+
+       bzero(buf, sizeof(buf));
+       r = res_mkquery(QUERY, name, class, type, NULL, 0, NULL,
+                       buf, sizeof(buf));
+       if (r <= 0)
+           {
+               h_errno = NO_RECOVERY;
+               return r;
+           }
+       hptr = (HEADER *)buf;
+       rptr->re_id = ntohs(hptr->id);
+
+       s = ar_send_res_msg(buf, r, rptr->re_sends);
+
+       if (s == -1)
+           {
+               h_errno = TRY_AGAIN;
+               return -1;
+           }
+       else
+               rptr->re_sent += s;
+       return 0;
+}
+
+
+/*
+ * ar_gethostbyname
+ *
+ * Replacement library function call to gethostbyname().  This one, however,
+ * doesn't return the record being looked up but just places the query in the
+ * queue to await answers.
+ */
+int    ar_gethostbyname(name, info, size)
+char   *name;
+char   *info;
+int    size;
+{
+       char    host[65];
+       struct  resinfo resi;
+       register struct resinfo *rp = &resi;
+
+       if (size && info)
+           {
+               rp->ri_ptr = (char *)malloc(size);
+               bcopy(info, rp->ri_ptr, size);
+               rp->ri_size = size;
+           }
+       else
+               bzero((char *)rp, sizeof(resi));
+       ar_reinfo.re_na_look++;
+       (void)strncpy(host, name, 64);
+       host[64] = '\0';
+
+       return (do_query_name(rp, host, NULL));
+}
+
+
+static int     do_query_name(resi, name, rptr)
+struct resinfo *resi;
+char   *name;
+register struct        reslist *rptr;
+{
+       char    hname[65];
+       int     len;
+
+       len = strlen((char *)strncpy(hname, name, sizeof(hname)-1));
+
+       if (rptr && (hname[len-1] != '.'))
+           {
+               (void)strncat(hname, ar_dot, sizeof(hname)-len-1);
+               /*
+                * NOTE: The logical relationship between DNSRCH and DEFNAMES
+                * is implies. ie no DEFNAES, no DNSRCH.
+                */
+               if (_res.options & (RES_DEFNAMES|RES_DNSRCH) ==
+                   (RES_DEFNAMES|RES_DNSRCH))
+                   {
+                       if (_res.dnsrch[rptr->re_srch])
+                               (void)strncat(hname, _res.dnsrch[rptr->re_srch],
+                                       sizeof(hname) - ++len -1);
+                   }
+               else if (_res.options & RES_DEFNAMES)
+                       (void)strncat(hname, ar_domainname, sizeof(hname) - len -1);
+           }
+
+       /*
+        * Store the name passed as the one to lookup and generate other host
+        * names to pass onto the nameserver(s) for lookups.
+        */
+       if (!rptr)
+           {
+               rptr = ar_make_request(resi);
+               rptr->re_type = T_A;
+               (void)strncpy(rptr->re_name, name, sizeof(rptr->re_name)-1);
+           }
+       return (ar_query_name(hname, C_IN, T_A, rptr));
+}
+
+
+/*
+ * ar_gethostbyaddr
+ *
+ * Generates a query for a given IP address.
+ */
+int    ar_gethostbyaddr(addr, info, size)
+char   *addr;
+char   *info;
+int    size;
+{
+       struct  resinfo resi;
+       register struct resinfo *rp = &resi;
+
+       if (size && info)
+           {
+               rp->ri_ptr = (char *)malloc(size);
+               bcopy(info, rp->ri_ptr, size);
+               rp->ri_size = size;
+           }
+       else
+               bzero((char *)rp, sizeof(resi));
+       ar_reinfo.re_nu_look++;
+       return (do_query_number(rp, addr, NULL));
+}
+
+
+/*
+ * do_query_number
+ *
+ * Use this to do reverse IP# lookups.
+ */
+static int     do_query_number(resi, numb, rptr)
+struct resinfo *resi;
+char   *numb;
+register struct        reslist *rptr;
+{
+       register unsigned char  *cp;
+       static  char    ipbuf[32];
+
+       /*
+        * Generate name in the "in-addr.arpa" domain.  No addings bits to this
+        * name to get more names to query!.
+        */
+       cp = (unsigned char *)numb;
+       (void)sprintf(ipbuf,"%u.%u.%u.%u.in-addr.arpa.",
+                       (unsigned int)(cp[3]), (unsigned int)(cp[2]),
+                       (unsigned int)(cp[1]), (unsigned int)(cp[0]));
+
+       if (!rptr)
+           {
+               rptr = ar_make_request(resi);
+               rptr->re_type = T_PTR;
+               rptr->re_he.h_length = sizeof(struct in_addr);
+               bcopy(numb, (char *)&rptr->re_addr, rptr->re_he.h_length);
+               bcopy(numb, (char *)&rptr->re_he.h_addr_list[0].s_addr,
+                       rptr->re_he.h_length);
+           }
+       return (ar_query_name(ipbuf, C_IN, T_PTR, rptr));
+}
+
+
+/*
+ * ar_resent_query
+ *
+ * resends a query.
+ */
+static int     ar_resend_query(rptr)
+struct reslist *rptr;
+{
+       if (!rptr->re_resend)
+               return -1;
+
+       switch(rptr->re_type)
+       {
+       case T_PTR:
+               ar_reinfo.re_resends++;
+               return do_query_number(NULL, &rptr->re_addr, rptr);
+       case T_A:
+               ar_reinfo.re_resends++;
+               return do_query_name(NULL, rptr->re_name, rptr);
+       default:
+               break;
+       }
+
+       return -1;
+}
+
+
+/*
+ * ar_procanswer
+ *
+ * process an answer received from a nameserver.
+ */
+static int     ar_procanswer(rptr, hptr, buf, eob)
+struct reslist *rptr;
+char   *buf, *eob;
+HEADER *hptr;
+{
+       char    *cp, **alias, *s;
+       int     class, type, dlen, len, ans = 0, n, i;
+       u_int32_t ttl, dr, *adr;
+       struct  hent    *hp;
+
+       cp = buf + sizeof(HEADER);
+       adr = (u_int32_t *)rptr->re_he.h_addr_list;
+
+       while (*adr)
+               adr++;
+
+       alias = rptr->re_he.h_aliases;
+       while (*alias)
+               alias++;
+
+       hp = &rptr->re_he;
+
+
+       /*
+        * Skip over the original question.
+        */
+       while (hptr->qdcount-- > 0)
+               cp += dn_skipname(cp, eob) + QFIXEDSZ;
+       /*
+        * proccess each answer sent to us. blech.
+        */
+       while (hptr->ancount-- > 0 && cp < eob) {
+               n = dn_expand(buf, eob, cp, ar_hostbuf, sizeof(ar_hostbuf));
+               cp += n;
+               if (n <= 0)
+                       return ans;
+
+               ans++;
+               /*
+                * 'skip' past the general dns crap (ttl, class, etc) to get
+                * the pointer to the right spot.  Some of thse are actually
+                * useful so its not a good idea to skip past in one big jump.
+                */
+               type = (int)_getshort(cp);
+               cp += sizeof(short);
+               class = (int)_getshort(cp);
+               cp += sizeof(short);
+               ttl = (u_int32_t)_getlong(cp);
+               cp += sizeof(u_int32_t);
+               dlen =  (int)_getshort(cp);
+               cp += sizeof(short);
+               rptr->re_type = type;
+
+               switch(type)
+               {
+               case T_A :
+                       rptr->re_he.h_length = dlen;
+                       if (ans == 1)
+                               rptr->re_he.h_addrtype=(class == C_IN) ?
+                                                       AF_INET : AF_UNSPEC;
+                       if (dlen != sizeof(dr))
+                           {
+                               h_errno = TRY_AGAIN;
+                               continue;
+                           }
+                       bcopy(cp, &dr, dlen);
+                       *adr++ = dr;
+                       *adr = 0;
+                       cp += dlen;
+                       len = strlen(ar_hostbuf);
+                       if (!rptr->re_he.h_name)
+                           {
+                               rptr->re_he.h_name = (char *)malloc(len+1);
+                               if (!rptr->re_he.h_name)
+                                       break;
+                               (void)strcpy(rptr->re_he.h_name, ar_hostbuf);
+                           }
+                       break;
+               case T_PTR :
+                       if ((n = dn_expand(buf, eob, cp, ar_hostbuf,
+                                          sizeof(ar_hostbuf) )) < 0)
+                           {
+                               cp += n;
+                               continue;
+                           }
+                       cp += n;
+                       len = strlen(ar_hostbuf)+1;
+                       /*
+                        * copy the returned hostname into the host name
+                        * or alias field if there is a known hostname
+                        * already.
+                        */
+                       if (!rptr->re_he.h_name)
+                           {
+                               rptr->re_he.h_name = (char *)malloc(len);
+                               if (!rptr->re_he.h_name)
+                                       break;
+                               (void)strcpy(rptr->re_he.h_name, ar_hostbuf);
+                           }
+                       else
+                           {
+                               *alias = (char *)malloc(len);
+                               if (!*alias)
+                                       return -1;
+                               (void)strcpy(*alias++, ar_hostbuf);
+                               *alias = NULL;
+                           }
+                       break;
+               case T_CNAME :
+                       cp += dlen;
+                       if (alias >= &(rptr->re_he.h_aliases[MAXALIASES-1]))
+                               continue;
+                       n = strlen(ar_hostbuf)+1;
+                       *alias = (char *)malloc(n);
+                       if (!*alias)
+                               return -1;
+                       (void)strcpy(*alias++, ar_hostbuf);
+                       *alias = NULL;
+                       break;
+               default :
+                       break;
+               }
+       }
+
+       return ans;
+}
+
+
+/*
+ * ar_answer
+ *
+ * Get an answer from a DNS server and process it.  If a query is found to
+ * which no answer has been given to yet, copy its 'info' structure back
+ * to where "reip" points and return a pointer to the hostent structure.
+ */
+struct hostent *ar_answer(reip, size)
+char   *reip;
+int    size;
+{
+       static  char    ar_rcvbuf[sizeof(HEADER) + MAXPACKET];
+       static  struct  hostent ar_host;
+
+       register HEADER *hptr;
+       register struct reslist *rptr = NULL;
+       register struct hostent *hp;
+       register char **s;
+       unsigned long   *adr;
+       int     rc, i, n, a;
+
+       rc = recv(ar_resfd, ar_rcvbuf, sizeof(ar_rcvbuf), 0);
+       if (rc <= 0)
+               goto getres_err;
+
+       ar_reinfo.re_replies++;
+       hptr = (HEADER *)ar_rcvbuf;
+       /*
+        * convert things to be in the right order.
+        */
+       hptr->id = ntohs(hptr->id);
+       hptr->ancount = ntohs(hptr->ancount);
+       hptr->arcount = ntohs(hptr->arcount);
+       hptr->nscount = ntohs(hptr->nscount);
+       hptr->qdcount = ntohs(hptr->qdcount);
+       /*
+        * response for an id which we have already received an answer for
+        * just ignore this response.
+        */
+       rptr = ar_find_id(hptr->id);
+       if (!rptr)
+               goto getres_err;
+
+       if ((hptr->rcode != NOERROR) || (hptr->ancount == 0))
+           {
+               switch (hptr->rcode)
+               {
+               case NXDOMAIN:
+                       h_errno = HOST_NOT_FOUND;
+                       break;
+               case SERVFAIL:
+                       h_errno = TRY_AGAIN;
+                       break;
+               case NOERROR:
+                       h_errno = NO_DATA;
+                       break;
+               case FORMERR:
+               case NOTIMP:
+               case REFUSED:
+               default:
+                       h_errno = NO_RECOVERY;
+                       break;
+               }
+               ar_reinfo.re_errors++;
+               /*
+               ** If a bad error was returned, we stop here and dont send
+               ** send any more (no retries granted).
+               */
+               if (h_errno != TRY_AGAIN)
+                   {
+                       rptr->re_resend = 0;
+                       rptr->re_retries = 0;
+                   }
+               goto getres_err;
+           }
+
+       a = ar_procanswer(rptr, hptr, ar_rcvbuf, ar_rcvbuf+rc);
+
+       if ((rptr->re_type == T_PTR) && (_res.options & RES_CHECKPTR))
+           {
+               /*
+                * For reverse lookups on IP#'s, lookup the name that is given
+                * for the ip# and return with that as the official result.
+                * -avalon
+                */
+               rptr->re_type = T_A;
+               /*
+                * Clean out the list of addresses already set, even though
+                * there should only be one :)
+                */
+               adr = (unsigned long *)rptr->re_he.h_addr_list;
+               while (*adr)
+                       *adr++ = 0L;
+               /*
+                * Lookup the name that we were given for the ip#
+                */
+               ar_reinfo.re_na_look++;
+               (void)strncpy(rptr->re_name, rptr->re_he.h_name,
+                       sizeof(rptr->re_name)-1);
+               rptr->re_he.h_name = NULL;
+               rptr->re_retries = _res.retry;
+               rptr->re_sends = 1;
+               rptr->re_resend = 1;
+               rptr->re_he.h_name = NULL;
+               ar_reinfo.re_na_look++;
+               (void)ar_query_name(rptr->re_name, C_IN, T_A, rptr);
+               return NULL;
+           }
+
+       if (reip && rptr->re_rinfo.ri_ptr && size)
+               bcopy(rptr->re_rinfo.ri_ptr, reip,
+                       MIN(rptr->re_rinfo.ri_size, size));
+       /*
+        * Clean up structure from previous usage.
+        */
+       hp = &ar_host;
+#ifdef ARLIB_DEBUG
+       ar_dump_hostent("ar_answer: previous usage", hp);
+#endif
+
+       if (hp->h_name)
+               (void)free(hp->h_name);
+       if (s = hp->h_aliases)
+           {
+               while (*s)
+                       (void)free(*s++);
+               (void)free(hp->h_aliases);
+           }
+       if (s = hp->h_addr_list)
+           {
+               /*
+                * Only free once since we allocated space for
+                * address in one big chunk.
+                */
+               (void)free(*s);
+               (void)free(hp->h_addr_list);
+           }
+       bzero((char *)hp, sizeof(*hp));
+
+       /*
+        * Setup and copy details for the structure we return a pointer to.
+        */
+       hp->h_addrtype = AF_INET;
+       hp->h_length = sizeof(struct in_addr);
+       if(rptr->re_he.h_name)
+           {
+               hp->h_name = (char *)malloc(strlen(rptr->re_he.h_name)+1);
+               if(!hp->h_name)
+                   {
+#ifdef ARLIB_DEBUG
+                       fprintf(stderr, "no memory for hostname\n");
+#endif
+                       h_errno = TRY_AGAIN;
+                       goto getres_err;
+                   }
+               (void)strcpy(hp->h_name, rptr->re_he.h_name);
+           }
+#ifdef ARLIB_DEBUG
+       ar_dump_hostent("ar_answer: (snap) store name", hp);
+#endif
+
+       /*
+        * Count IP#'s.
+        */
+       for (i = 0, n = 0; i < MAXADDRS; i++, n++)
+               if (!rptr->re_he.h_addr_list[i].s_addr)
+                       break;
+       s = hp->h_addr_list = (char **)malloc((n + 1) * sizeof(char *));
+       if (n)
+           {
+               *s = (char *)malloc(n * sizeof(struct in_addr));
+               if(!*s)
+                   {
+#ifdef ARLIB_DEBUG
+                       fprintf(stderr, "no memory for IP#'s (%d)\n", n);
+#endif
+                       h_errno = TRY_AGAIN;
+                       goto getres_err;
+                   }
+               bcopy((char *)&rptr->re_he.h_addr_list[0].s_addr, *s,
+                       sizeof(struct in_addr));
+               s++;
+               for (i = 1; i < n; i++, s++)
+                   {
+                       *s = hp->h_addr + i * sizeof(struct in_addr);
+                       bcopy((char *)&rptr->re_he.h_addr_list[i].s_addr, *s,
+                               sizeof(struct in_addr));
+                   }
+           }
+       *s = NULL;
+#ifdef ARLIB_DEBUG
+       ar_dump_hostent("ar_answer: (snap) store IP#'s", hp);
+#endif
+
+       /*
+        * Count CNAMEs
+        */
+       for (i = 0, n = 0; i < MAXADDRS; i++, n++)
+               if (!rptr->re_he.h_aliases[i])
+                       break;
+       s = hp->h_aliases = (char **)malloc((n + 1) * sizeof(char *));
+       if (!s)
+           {
+#ifdef ARLIB_DEBUG
+               fprintf(stderr, "no memory for aliases (%d)\n", n);
+#endif
+               h_errno = TRY_AGAIN;
+               goto getres_err;
+           }
+       for (i = 0; i < n; i++)
+           {
+               *s++ = rptr->re_he.h_aliases[i];
+               rptr->re_he.h_aliases[i] = NULL;
+           }
+       *s = NULL;
+#ifdef ARLIB_DEBUG
+       ar_dump_hostent("ar_answer: (snap) store CNAMEs", hp);
+       ar_dump_hostent("ar_answer: new one", hp);
+#endif
+
+       if (a > 0)
+               (void)ar_remrequest(rptr);
+       else
+               if (!rptr->re_sent)
+                       (void)ar_remrequest(rptr);
+       return hp;
+
+getres_err:
+       if (rptr)
+           {
+               if (reip && rptr->re_rinfo.ri_ptr && size)
+                       bcopy(rptr->re_rinfo.ri_ptr, reip,
+                               MIN(rptr->re_rinfo.ri_size, size));
+               if ((h_errno != TRY_AGAIN) &&
+                   (_res.options & (RES_DNSRCH|RES_DEFNAMES) ==
+                    (RES_DNSRCH|RES_DEFNAMES) ))
+                       if (_res.dnsrch[rptr->re_srch])
+                           {
+                               rptr->re_retries = _res.retry;
+                               rptr->re_sends = 1;
+                               rptr->re_resend = 1;
+                               (void)ar_resend_query(rptr);
+                               rptr->re_srch++;
+                           }
+               return NULL;
+           }
+       return NULL;
+}
+
+
+#ifdef ARLIB_DEBUG
+void ar_dump_hostent(prefix, hp)
+char *prefix;
+struct hostent *hp;
+{
+       register char **s;
+
+       fflush(stdout);
+
+       fprintf(stderr, "%s\n", prefix);
+       fprintf(stderr, "  hp %p\n", hp);
+       fprintf(stderr, "    h_name %p '%s'\n",
+       hp->h_name, hp->h_name);
+       if (s = hp->h_aliases)
+           {
+               fprintf(stderr, "    h_aliases %p\n",
+               hp->h_aliases);
+               while (*s)
+                   {
+                       fprintf(stderr, "      element %p\n", *s);
+                       s++;
+                   }
+           }
+       if (s = hp->h_addr_list)
+           {
+               fprintf(stderr, "    h_addr_list %p\n",
+               hp->h_addr_list);
+               while (*s)
+                   {
+                       fprintf(stderr, "      element %p\n", *s);
+                       s++;
+                   }
+           }
+
+       fflush(stderr);
+}
+
+
+void ar_dump_reslist(FILE* fp)
+{
+       register struct reslist *rptr;
+       int c;
+
+       c = 0;
+       for (rptr = ar_first; rptr; rptr = rptr->re_next)
+           {
+               fprintf(fp, "%4d [%p] %4d [%p]: %s\n", rptr->re_id, rptr,
+                       *(rptr->re_rinfo.ri_ptr), rptr->re_rinfo.ri_ptr,
+                       rptr->re_name);
+           }
+}
+#endif
diff --git a/arlib/arlib.h b/arlib/arlib.h
new file mode 100644 (file)
index 0000000..a295b88
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * arlib.h (C)opyright 1992 Darren Reed.
+ */
+
+#define        ARES_INITLIST   1
+#define        ARES_CALLINIT   2
+#define ARES_INITSOCK  4
+#define ARES_INITDEBG  8
+#define ARES_INITCACH  16
+
+#ifdef __STDC__
+extern struct  hostent *ar_answer(char *, int);
+extern void    ar_close();
+extern int     ar_delete(char *, int);
+extern int     ar_gethostbyname(char *, char *, int);
+extern int     ar_gethostbyaddr(char *, char *, int);
+extern int     ar_init(int);
+extern int     ar_open();
+extern long    ar_timeout(time_t, char *, int);
+#else
+extern struct  hostent *ar_answer();
+extern void    ar_close();
+extern int     ar_delete();
+extern int     ar_gethostbyname();
+extern int     ar_gethostbyaddr();
+extern int     ar_init();
+extern int     ar_open();
+extern long    ar_timeout();
+#endif
diff --git a/arlib/arplib.h b/arlib/arplib.h
new file mode 100644 (file)
index 0000000..8f905d1
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * arplib.h (C)opyright 1992 Darren Reed.
+ */
+
+#define MAXPACKET      1024
+#define MAXALIASES     35
+#define MAXADDRS       35
+
+#define        RES_CHECKPTR    0x0400
+
+struct hent {
+       char    *h_name;        /* official name of host */
+       char    *h_aliases[MAXALIASES]; /* alias list */
+       int     h_addrtype;     /* host address type */
+       int     h_length;       /* length of address */
+       /* list of addresses from name server */
+       struct  in_addr h_addr_list[MAXADDRS];
+#define        h_addr  h_addr_list[0]  /* address, for backward compatiblity */
+};
+
+struct resinfo {
+       char    *ri_ptr;
+       int     ri_size;
+};
+
+struct reslist {
+       int     re_id;
+       char    re_type;
+       char    re_retries;
+       char    re_resend;      /* send flag. 0 == dont resend */
+       char    re_sends;
+       char    re_srch;
+       int     re_sent;
+       u_long  re_sentat;
+       u_long  re_timeout;
+       struct  in_addr re_addr;
+       struct  resinfo re_rinfo;
+       struct  hent re_he;
+       struct  reslist *re_next, *re_prev;
+       char    re_name[65];
+};
+
+#ifndef        MIN
+#define        MIN(a,b)        ((a) > (b) ? (b) : (a))
+#endif
diff --git a/arlib/configure b/arlib/configure
new file mode 100755 (executable)
index 0000000..95e8a84
--- /dev/null
@@ -0,0 +1,5008 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.65.
+#
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+        /*)
+          for as_base in sh bash ksh sh5; do
+            # Try only shells that exist, to save several forks.
+            as_shell=$as_dir/$as_base
+            if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+                   { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+                  if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+          done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+             { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  # We cannot yet assume a decent shell, so we have to provide a
+       # neutralization value for shells without unset; and this also
+       # works around shells that cannot unset nonexistent variables.
+       BASH_ENV=/dev/null
+       ENV=/dev/null
+       (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+       export CONFIG_SHELL
+       exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+  fi
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with status $?, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in #(
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+PACKAGE_URL=
+
+ac_unique_file="arlib.c"
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+RANLIB
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_dependency_tracking
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)   ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) as_fn_error "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information."
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  as_fn_error "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
+               datadir sysconfdir sharedstatedir localstatedir includedir \
+               oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+               libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_myself" : 'X\(//\)[^/]' \| \
+        X"$as_myself" : 'X\(//\)$' \| \
+        X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+       cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
+       pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to the package provider.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+configure
+generated by GNU Autoconf 2.65
+
+Copyright (C) 2009 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_func
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+        return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+           return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_type
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.65.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    $as_echo "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append ac_configure_args1 " '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+       ac_must_keep_next=false # Got value, back to normal.
+      else
+       case $ac_arg in
+         *=* | --config-cache | -C | -disable-* | --disable-* \
+         | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+         | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+         | -with-* | --with-* | -without-* | --without-* | --x)
+           case "$ac_configure_args0 " in
+             "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+           esac
+           ;;
+         -* ) ac_must_keep_next=true ;;
+       esac
+      fi
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+       "s/'\''/'\''\\\\'\'''\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+       eval ac_val=\$$ac_var
+       case $ac_val in
+       *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+       esac
+       $as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  ac_site_file1=$CONFIG_SITE
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+       # differences in whitespace do not lead to failure.
+       ac_old_val_w=`echo x $ac_old_val`
+       ac_new_val_w=`echo x $ac_new_val`
+       if test "$ac_old_val_w" != "$ac_new_val_w"; then
+         { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+         ac_cache_corrupted=:
+       else
+         { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+         eval $ac_var=\$ac_old_val
+       fi
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+am__api_version='1.11'
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+  for ac_t in install-sh install.sh shtool; do
+    if test -f "$ac_dir/$ac_t"; then
+      ac_aux_dir=$ac_dir
+      ac_install_sh="$ac_aux_dir/$ac_t -c"
+      break 2
+    fi
+  done
+done
+if test -z "$ac_aux_dir"; then
+  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+  ./ | .// | /[cC]/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+         if test $ac_prog = install &&
+           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         elif test $ac_prog = install &&
+           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
+         else
+           rm -rf conftest.one conftest.two conftest.dir
+           echo one > conftest.one
+           echo two > conftest.two
+           mkdir conftest.dir
+           if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+             test -s conftest.one && test -s conftest.two &&
+             test -s conftest.dir/conftest.one &&
+             test -s conftest.dir/conftest.two
+           then
+             ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+             break 3
+           fi
+         fi
+       fi
+      done
+    done
+    ;;
+esac
+
+  done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[\\\"\#\$\&\'\`$am_lf]*)
+    as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \    ]*)
+    as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$*" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$*" != "X $srcdir/configure conftest.file" \
+      && test "$*" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      as_fn_error "ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" "$LINENO" 5
+   fi
+
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   as_fn_error "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+test "$program_prefix" != NONE &&
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in mkdir gmkdir; do
+        for ac_exec_ext in '' $ac_executable_extensions; do
+          { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+          case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+            'mkdir (GNU coreutils) '* | \
+            'mkdir (coreutils) '* | \
+            'mkdir (fileutils) '4.1*)
+              ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+              break 3;;
+          esac
+        done
+       done
+  done
+IFS=$as_save_IFS
+
+fi
+
+  test -d ./--version && rmdir ./--version
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+  [\\/$]* | ?:[\\/]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+       @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE=arlib
+ VERSION=1.0
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
+
+
+
+
+#AM_CONFIG_HEADER([config.h])
+
+# Checks for programs.
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "no acceptable C compiler found in \$PATH
+See \`config.log' for more details." "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+       ;;
+    [ab].out )
+       # We found the default executable, but exeext='' is most
+       # certainly right.
+       break;;
+    *.* )
+       if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+       then :; else
+          ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+       fi
+       # We set ac_cv_exeext here because the later test for it is not
+       # safe: cross compilers may not add the suffix if given an `-o'
+       # argument, so we may need to know it at that point already.
+       # Even if this section looks crufty: it has the advantage of
+       # actually working.
+       break;;
+    * )
+       break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "C compiler cannot create executables
+See \`config.log' for more details." "$LINENO" 5; }; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+         break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+       cross_compiling=yes
+    else
+       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if test "${ac_cv_objext+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+        CFLAGS="-g"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+
+# Checks for libraries.
+ac_fn_c_check_func "$LINENO" "gethostent" "ac_cv_func_gethostent"
+if test "x$ac_cv_func_gethostent" = x""yes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for gethostent in -lnsl" >&5
+$as_echo_n "checking for gethostent in -lnsl... " >&6; }
+if test "${ac_cv_lib_nsl_gethostent+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lnsl -lsocket $LIBS"
+
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+        test "$cross_compiling" = yes ||
+        $as_test_x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gethostent ();
+int
+main ()
+{
+return gethostent ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_nsl_gethostent=yes
+else
+  ac_cv_lib_nsl_gethostent=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_nsl_gethostent" >&5
+$as_echo "$ac_cv_lib_nsl_gethostent" >&6; }
+if test "x$ac_cv_lib_nsl_gethostent" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBNSL 1
+_ACEOF
+
+  LIBS="-lnsl $LIBS"
+
+fi
+
+fi
+
+ac_fn_c_check_func "$LINENO" "setsockopt" "ac_cv_func_setsockopt"
+if test "x$ac_cv_func_setsockopt" = x""yes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for setsockopt in -lsocket" >&5
+$as_echo_n "checking for setsockopt in -lsocket... " >&6; }
+if test "${ac_cv_lib_socket_setsockopt+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsocket  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char setsockopt ();
+int
+main ()
+{
+return setsockopt ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_socket_setsockopt=yes
+else
+  ac_cv_lib_socket_setsockopt=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_socket_setsockopt" >&5
+$as_echo "$ac_cv_lib_socket_setsockopt" >&6; }
+if test "x$ac_cv_lib_socket_setsockopt" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBSOCKET 1
+_ACEOF
+
+  LIBS="-lsocket $LIBS"
+
+fi
+
+fi
+
+ac_fn_c_check_func "$LINENO" "res_init" "ac_cv_func_res_init"
+if test "x$ac_cv_func_res_init" = x""yes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for res_init in -lresolv" >&5
+$as_echo_n "checking for res_init in -lresolv... " >&6; }
+if test "${ac_cv_lib_resolv_res_init+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lresolv  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char res_init ();
+int
+main ()
+{
+return res_init ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_resolv_res_init=yes
+else
+  ac_cv_lib_resolv_res_init=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_resolv_res_init" >&5
+$as_echo "$ac_cv_lib_resolv_res_init" >&6; }
+if test "x$ac_cv_lib_resolv_res_init" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBRESOLV 1
+_ACEOF
+
+  LIBS="-lresolv $LIBS"
+
+fi
+
+fi
+
+
+# Checks for header files.
+
+# Checks for typedefs, structures, and compiler characteristics.
+
+ac_fn_c_check_type "$LINENO" "u_int32_t" "ac_cv_type_u_int32_t" "
+#include <sys/types.h>
+#include <netinet/in.h>
+"
+if test "x$ac_cv_type_u_int32_t" = x""yes; then :
+
+else
+
+$as_echo "#define u_int32_t unsigned int" >>confdefs.h
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for name of NS address list" >&5
+$as_echo_n "checking for name of NS address list... " >&6; }
+if test "${ac_cv_var_ns_addr_list+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=''
+# Normal
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+int
+main ()
+{
+ return sizeof(_res.nsaddr_list);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ans=nsaddr_list
+else
+  # Ultrix
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>
+int
+main ()
+{
+ return sizeof(_res.ns_list);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ans=ns_list
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+       case "$ans" in
+        '') { $as_echo "$as_me:${as_lineno-$LINENO}: result: ???" >&5
+$as_echo "???" >&6; }
+            as_fn_error "Can't find nameserver address list in _res" "$LINENO" 5
+            ;;
+       esac
+       ac_cv_var_ns_addr_list=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_ns_addr_list" >&5
+$as_echo "$ac_cv_var_ns_addr_list" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define NS_ADDR_LIST $ans
+_ACEOF
+
+
+# Checks for library functions.
+
+ac_config_files="$ac_config_files Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      sed -n \
+       "s/'/'\\\\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+    cat confcache >$cache_file
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+# Transform confdefs.h into DEFS.
+# Protect against shell expansion while executing Makefile rules.
+# Protect against Makefile macro expansion.
+#
+# If the first sed substitution is executed (which looks for macros that
+# take arguments), then branch to the quote section.  Otherwise,
+# look for a macro that doesn't take arguments.
+ac_script='
+:mline
+/\\$/{
+ N
+ s,\\\n,,
+ b mline
+}
+t clear
+:clear
+s/^[    ]*#[    ]*define[       ][      ]*\([^  (][^    (]*([^)]*)\)[   ]*\(.*\)/-D\1=\2/g
+t quote
+s/^[    ]*#[    ]*define[       ][      ]*\([^  ][^     ]*\)[   ]*\(.*\)/-D\1=\2/g
+t quote
+b any
+:quote
+s/[     `~#$^&*(){}\\|;'\''"<>?]/\\&/g
+s/\[/\\&/g
+s/\]/\\&/g
+s/\$/$$/g
+H
+:any
+${
+       g
+       s/^\n//
+       s/\n/ /g
+       p
+}
+'
+DEFS=`sed -n "$ac_script" confdefs.h`
+
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+ if test -n "$EXEEXT"; then
+  am__EXEEXT_TRUE=
+  am__EXEEXT_FALSE='#'
+else
+  am__EXEEXT_TRUE='#'
+  am__EXEEXT_FALSE=
+fi
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  as_fn_error "conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  as_fn_error "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+: ${CONFIG_STATUS=./config.status}
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with status $?, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in #(
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.65.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+
+Configuration files:
+$config_files
+
+Configuration commands:
+$config_commands
+
+Report bugs to the package provider."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.65,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2009 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h |  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+
+  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = "\a"
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+  || as_fn_error "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[         ]*VPATH[        ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[    ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[      ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+
+eval set X "  :F $CONFIG_FILES      :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+        # (if the path is not absolute).  The absolute path cannot be DOS-style,
+        # because $ac_f cannot contain `:'.
+        test -f "$ac_f" ||
+          case $ac_f in
+          [\\/$]*) false;;
+          *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+          esac ||
+          as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+         $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+       `' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_file" : 'X\(//\)[^/]' \| \
+        X"$ac_file" : 'X\(//\)$' \| \
+        X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[         ]*datarootdir[  ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
+ ;;
+
+
+  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$mf" : 'X\(//\)[^/]' \| \
+        X"$mf" : 'X\(//\)$' \| \
+        X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$file" : 'X\(//\)[^/]' \| \
+        X"$file" : 'X\(//\)$' \| \
+        X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      as_dir=$dirpart/$fdir; as_fn_mkdir_p
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+ ;;
+
+  esac
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || as_fn_exit $?
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/arlib/configure.in b/arlib/configure.in
new file mode 100644 (file)
index 0000000..509e23d
--- /dev/null
@@ -0,0 +1,57 @@
+# Process this file with autoconf to produce a configure script.
+AC_INIT
+AM_INIT_AUTOMAKE(arlib, 1.0)
+AC_CONFIG_SRCDIR([arlib.c])
+#AM_CONFIG_HEADER([config.h])
+
+# Checks for programs.
+AC_PROG_CC
+AC_PROG_RANLIB
+
+# Checks for libraries.
+AC_CHECK_FUNC(gethostent, , AC_CHECK_LIB(nsl, gethostent, , , -lsocket))
+AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
+AC_CHECK_FUNC(res_init, , AC_CHECK_LIB(resolv, res_init))
+
+# Checks for header files.
+dnl AC_CHECK_HEADERS([errno.h fcntl.h netdb.h netinet/in.h strings.h sys/socket.h sys/time.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+dnl AC_HEADER_TIME
+
+AC_CHECK_TYPE(u_int32_t, ,
+       [AC_DEFINE(u_int32_t, [unsigned int], [Unsigned 32-bit type])],[
+#include <sys/types.h>
+#include <netinet/in.h>])
+
+AC_CACHE_CHECK([for name of NS address list], [ac_cv_var_ns_addr_list],
+       [ans=''
+# Normal
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>], [ return sizeof(_res.nsaddr_list);],
+[ans=nsaddr_list],
+[# Ultrix
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <arpa/nameser.h>
+#include <resolv.h>], [ return sizeof(_res.ns_list);],
+[ans=ns_list])])
+       case "$ans" in
+        '') AC_MSG_RESULT([???])
+            AC_MSG_ERROR([Can't find nameserver address list in _res])
+            ;;
+       esac
+       ac_cv_var_ns_addr_list=$ans])
+AC_DEFINE_UNQUOTED(NS_ADDR_LIST, $ans, [The name of the NS address list in _res])
+
+# Checks for library functions.
+dnl AC_HEADER_STDC
+dnl AC_FUNC_MALLOC
+dnl AC_CHECK_FUNCS([bzero inet_ntoa select socket])
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/arlib/depcomp b/arlib/depcomp
new file mode 100755 (executable)
index 0000000..04701da
--- /dev/null
@@ -0,0 +1,530 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2005-07-09.11
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> $depfile
+    echo >> $depfile
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> $depfile
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
+  tmpdepfile="$stripped.u"
+  if test "$libtool" = yes; then
+    "$@" -Wc,-M
+  else
+    "$@" -M
+  fi
+  stat=$?
+
+  if test -f "$tmpdepfile"; then :
+  else
+    stripped=`echo "$stripped" | sed 's,^.*/,,'`
+    tmpdepfile="$stripped.u"
+  fi
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+
+  if test -f "$tmpdepfile"; then
+    outname="$stripped.o"
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
+    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mecanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space in the [].
+      sed -e 's,^.*\.[a-z]*:[   ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $dashmflag |
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no
+  for arg in "$@"; do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix="`echo $object | sed 's/^.*\././'`"
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o,
+  # because we must use -o when running libtool.
+  "$@" || exit $?
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+       set fnord "$@"
+       shift
+       shift
+       ;;
+    *)
+       set fnord "$@" "$arg"
+       shift
+       shift
+       ;;
+    esac
+  done
+  "$@" -E |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::   \1 \\:p' >> "$depfile"
+  echo "       " >> "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/arlib/install-sh b/arlib/install-sh
new file mode 100755 (executable)
index 0000000..4d4a951
--- /dev/null
@@ -0,0 +1,323 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2005-05-14.22
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+chmodcmd="$chmodprog 0755"
+chowncmd=
+chgrpcmd=
+stripcmd=
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=
+dst=
+dir_arg=
+dstarg=
+no_target_directory=
+
+usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+-c         (ignored)
+-d         create directories instead of installing files.
+-g GROUP   $chgrpprog installed files to GROUP.
+-m MODE    $chmodprog installed files to MODE.
+-o USER    $chownprog installed files to USER.
+-s         $stripprog installed files.
+-t DIRECTORY  install into DIRECTORY.
+-T         report an error if DSTFILE is a directory.
+--help     display this help and exit.
+--version  display version info and exit.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
+"
+
+while test -n "$1"; do
+  case $1 in
+    -c) shift
+        continue;;
+
+    -d) dir_arg=true
+        shift
+        continue;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+        shift
+        shift
+        continue;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) chmodcmd="$chmodprog $2"
+        shift
+        shift
+        continue;;
+
+    -o) chowncmd="$chownprog $2"
+        shift
+        shift
+        continue;;
+
+    -s) stripcmd=$stripprog
+        shift
+        continue;;
+
+    -t) dstarg=$2
+       shift
+       shift
+       continue;;
+
+    -T) no_target_directory=true
+       shift
+       continue;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    *)  # When -d is used, all remaining arguments are directories to create.
+       # When -t is used, the destination is already specified.
+       test -n "$dir_arg$dstarg" && break
+        # Otherwise, the last argument is the destination.  Remove it from $@.
+       for arg
+       do
+          if test -n "$dstarg"; then
+           # $@ is not empty: it contains at least $arg.
+           set fnord "$@" "$dstarg"
+           shift # fnord
+         fi
+         shift # arg
+         dstarg=$arg
+       done
+       break;;
+  esac
+done
+
+if test -z "$1"; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src ;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    src=
+
+    if test -d "$dst"; then
+      mkdircmd=:
+      chmodcmd=
+    else
+      mkdircmd=$mkdirprog
+    fi
+  else
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dstarg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dstarg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst ;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+       echo "$0: $dstarg: Is a directory" >&2
+       exit 1
+      fi
+      dst=$dst/`basename "$src"`
+    fi
+  fi
+
+  # This sed command emulates the dirname command.
+  dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
+
+  # Make sure that the destination directory exists.
+
+  # Skip lots of stat calls in the usual case.
+  if test ! -d "$dstdir"; then
+    defaultIFS='
+        '
+    IFS="${IFS-$defaultIFS}"
+
+    oIFS=$IFS
+    # Some sh's can't handle IFS=/ for some reason.
+    IFS='%'
+    set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+    shift
+    IFS=$oIFS
+
+    pathcomp=
+
+    while test $# -ne 0 ; do
+      pathcomp=$pathcomp$1
+      shift
+      if test ! -d "$pathcomp"; then
+        $mkdirprog "$pathcomp"
+       # mkdir can fail with a `File exist' error in case several
+       # install-sh are creating the directory concurrently.  This
+       # is OK.
+       test -d "$pathcomp" || exit
+      fi
+      pathcomp=$pathcomp/
+    done
+  fi
+
+  if test -n "$dir_arg"; then
+    $doit $mkdircmd "$dst" \
+      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
+      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
+      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
+      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
+
+  else
+    dstfile=`basename "$dst"`
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+    trap '(exit $?); exit' 1 2 13 15
+
+    # Copy the file name to the temp name.
+    $doit $cpprog "$src" "$dsttmp" &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
+      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
+      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
+      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
+
+    # Now rename the file to the real destination.
+    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
+      || {
+          # The rename failed, perhaps because mv can't rename something else
+          # to itself, or perhaps because mv is so ancient that it does not
+          # support -f.
+
+          # Now remove or move aside any old file at destination location.
+          # We try this two ways since rm can't unlink itself on some
+          # systems and the destination file might be busy for other
+          # reasons.  In this case, the final cleanup might fail but the new
+          # file should still install successfully.
+          {
+            if test -f "$dstdir/$dstfile"; then
+              $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
+              || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
+              || {
+                echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+                (exit 1); exit 1
+              }
+            else
+              :
+            fi
+          } &&
+
+          # Now rename the file to the real destination.
+          $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+        }
+    }
+  fi || { (exit 1); exit 1; }
+done
+
+# The final little trick to "correctly" pass the exit status to the exit trap.
+{
+  (exit 0); exit 0
+}
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/arlib/missing b/arlib/missing
new file mode 100755 (executable)
index 0000000..894e786
--- /dev/null
@@ -0,0 +1,360 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2005-06-08.21
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
+#   Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case "$1" in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).
+case "$1" in
+  lex|yacc)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case "$1" in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case "$f" in
+      *:*) touch_files="$touch_files "`echo "$f" |
+                                      sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+          sed 's/\.am$/.in/' |
+          while read f; do touch "$f"; done
+    ;;
+
+  autom4te)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+    if test -f "$file"; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo "#! /bin/sh"
+       echo "# Created by GNU Automake missing as a replacement of"
+       echo "#  $ $@"
+       echo "exit 0"
+       chmod +x $file
+       exit 1
+    fi
+    ;;
+
+  bison|yacc)
+    echo 1>&2 "\
+WARNING: \`$1' $msg.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+       case "$LASTARG" in
+       *.y)
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" y.tab.c
+           fi
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" y.tab.h
+           fi
+         ;;
+       esac
+    fi
+    if [ ! -f y.tab.h ]; then
+       echo >y.tab.h
+    fi
+    if [ ! -f y.tab.c ]; then
+       echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+       case "$LASTARG" in
+       *.l)
+           SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" lex.yy.c
+           fi
+         ;;
+       esac
+    fi
+    if [ ! -f lex.yy.c ]; then
+       echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+        you modified a dependency of a manual page.  You may need the
+        \`Help2man' package in order for those modifications to take
+        effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+       file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+    fi
+    if [ -f "$file" ]; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo ".ab help2man is required to generate this page"
+       exit 1
+    fi
+    ;;
+
+  makeinfo)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar)
+    shift
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+       case "$firstarg" in
+       *o*)
+           firstarg=`echo "$firstarg" | sed s/o//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+       case "$firstarg" in
+       *h*)
+           firstarg=`echo "$firstarg" | sed s/h//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequisites for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/arlib/sample.c b/arlib/sample.c
new file mode 100644 (file)
index 0000000..83db6a8
--- /dev/null
@@ -0,0 +1,143 @@
+#include <stdio.h>
+#include <strings.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <netinet/in.h>
+#include <netdb.h>
+#include "arlib.h"
+
+#ifndef        lint
+static char    sccsid[] = "@(#)sample.c        1.1 12/21/92 (C)1992 Darren Reed. ASYNC DNS";
+#endif
+
+char   line[512];
+
+int    lookup = 0, seq = 0;
+long   expire = 0;
+
+main()
+{
+       struct  in_addr adr;
+       struct  timeval tv2;
+       fd_set  rd;
+       long    now;
+       char    *s;
+       int     afd, nfd, pid = getpid(), del;
+
+       afd = ar_init(ARES_INITLIST|ARES_CALLINIT|ARES_INITSOCK);
+
+       (void)printf("afd = %d pid = %d\n",afd, pid);
+
+       while (1)
+       {
+               (void)printf("Host =>");
+               (void)fflush(stdout);
+               *line = '\0';
+               FD_ZERO(&rd);
+               FD_SET(0,&rd);
+               FD_SET(afd,&rd);
+               now = time(NULL);
+               if (expire >= now)
+                   {
+                       tv2.tv_usec = 0;
+                       tv2.tv_sec = expire - now;
+                       nfd = select(FD_SETSIZE, &rd, NULL, NULL, &tv2);
+                   }
+               else
+                       nfd = select(FD_SETSIZE, &rd, NULL, NULL, NULL);
+
+               if (FD_ISSET(0, &rd))
+               {
+                       if (!fgets(line, sizeof(line) - 1, stdin))
+                               exit(0);
+                       if (s = index(line, '\n'))
+                               *s = '\0';
+               }
+
+               if (isalpha(*line))
+               {
+                       (void)printf("Asking about [%s] #%d.\n",line, ++seq);
+                       (void)ar_gethostbyname(line, (char *)&seq,
+                                              sizeof(seq));
+                       lookup++;
+               }
+               else if (isdigit(*line))
+               {
+                       (void)printf("Asking about IP#[%s] #%d.\n",
+                               line, ++seq);
+                       adr.s_addr = inet_addr(line);
+                       (void)ar_gethostbyaddr(&adr, (char *)&seq,
+                                              sizeof(seq));
+                       lookup++;
+               }
+               if (lookup)
+                       (void)printf("Waiting for answer:\n");
+               if (FD_ISSET(afd, &rd))
+                       (void)waitonlookup(afd);
+               del = 0;
+               expire = ar_timeout(time(NULL), &del, sizeof(del));
+               if (del)
+               {
+                       (void)fprintf(stderr,"#%d failed\n", del);
+                       lookup--;
+               }
+       }
+}
+
+printhostent(hp)
+struct hostent *hp;
+{
+       struct in_addr ip;
+       int i;
+
+       (void)printf("hname = %s\n", hp->h_name);
+       for (i = 0; hp->h_aliases[i]; i++)
+               (void)printf("alias %d = %s\n", i+1, hp->h_aliases[i]);
+       for (i = 0; hp->h_addr_list[i]; i++)
+       {
+               bcopy(hp->h_addr_list[i], (char *)&ip, sizeof(ip));
+               (void)printf("IP# %d = %s\n", i+1, inet_ntoa(ip));
+       }
+}
+
+int    waitonlookup(afd)
+int    afd;
+{
+       struct  timeval delay;
+       struct  hostent *hp;
+       fd_set  rd;
+       long    now;
+       int     nfd, del;
+
+waitloop:
+       FD_ZERO(&rd);
+       now = time(NULL);
+       if (expire >= now)
+               delay.tv_sec = expire - now;
+       else
+               delay.tv_sec = 1;
+       delay.tv_usec = 0;
+       FD_SET(afd, &rd);
+       FD_SET(0, &rd);
+
+       nfd = select(FD_SETSIZE, &rd, 0, 0, &delay);
+       if (nfd == 0)
+               return 0;
+       else if (FD_ISSET(afd, &rd))
+       {
+               del = 0;
+               hp = ar_answer(&del, sizeof(del));
+
+               (void)printf("hp=%x seq=%d\n",hp,del);
+               if (hp)
+                   {
+                       (void)printhostent(hp);
+                       if (!--lookup)
+                               return 1;
+                   }
+       }
+       if (FD_ISSET(0, &rd))
+               return 2;
+       return 0;
+}
diff --git a/bincheck.mf b/bincheck.mf
new file mode 100644 (file)
index 0000000..c67827d
--- /dev/null
@@ -0,0 +1,15 @@
+# we traditionally installed software in bindir, while it should have gone
+# in sbindir.  Now that we offer a choice, look in the "other" installation
+# subdir to warn folks if there is another version there.
+
+install-exec-hook:
+       @case ${BINSUBDIR} in                                   \
+        bin) ODIR=${exec_prefix}/sbin ;;                       \
+        sbin) ODIR=${exec_prefix}/bin ;;                       \
+       esac;                                                   \
+       test -z "${bin_PROGRAMS}${bin_SCRIPTS}"                 \
+       || for i in ${bin_PROGRAMS} ${bin_SCRIPTS} " "; do              \
+          test ! -f $$ODIR/$$i || echo "*** $$i is also in $$ODIR!";   \
+       done
+
+#
diff --git a/bootstrap b/bootstrap
new file mode 100755 (executable)
index 0000000..1a5aff0
--- /dev/null
+++ b/bootstrap
@@ -0,0 +1,120 @@
+#! /bin/sh
+
+#  This "bootstrap" script performs various pre-autoreconf actions
+#  that are required after pulling fresh sources from the repository.
+#
+#  NOTE:  THE NTP VERSION NUMBER COMES FROM packageinfo.sh
+#
+#  all other instances of it anywhere in the source base have propagated
+#  from this one source.
+#
+#  To use the raw sources from the repository, you must have the following
+#  tools available to you:
+#
+#  1.  Autoconf and Automake.
+#
+#  2.  lynx.  This is used to extract the COPYRIGHT file extracted from
+#      the html documentation.
+#
+#  *** The following are no longer needed for simple builds from the repo
+#  3.  AutoGen.  The repository does *not* contain the files generated from
+#      the option definition files and it does not contain the libopts
+#      tear-off/redistributable library.
+#
+#      Note: AutoGen needs GNU Guile.
+#
+#  4.  gunzip.  The tear-off library is a gzipped tarball.
+
+set -e
+
+scripts/genver
+
+# autoreconf says:
+# The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, ACLOCAL,
+# AUTOPOINT, LIBTOOLIZE, M4 are honored.
+
+AUTORECONF=${AUTORECONF:-autoreconf}
+
+case `hostname` in
+ pogo.udel.edu)
+    if fgrep -q 4.2.4 version.m4; then
+       AUTOCONF=autoconf-2.59
+       AUTOHEADER=autoheader-2.59
+       AUTOMAKE=automake-1.9
+       ACLOCAL=aclocal-1.9
+       export AUTOCONF AUTOHEADER AUTOMAKE ACLOCAL
+    fi
+    ;;
+esac
+
+# 20060629: HMS: Let's try checking in libopts and the autogen-generated files
+## The copy for ntp...
+#rm -rf libopts*
+#gunzip -c $(autoopts-config --libsrc) | (
+#  tar -xvf -
+#  mv libopts-*.*.* libopts )
+
+## The copy for sntp...
+#rm -rf sntp/libopts*
+#gunzip -c $(autoopts-config --libsrc) | (
+#  cd sntp
+#  tar -xvf -
+#  mv libopts-*.*.* libopts )
+
+def_files=`find [B-Za-z]* -type f -name '*.def' -print | fgrep -v /SCCS/`
+prog_opt_files=`grep -l '^prog.name' $def_files`
+
+## AutoGen stuff
+
+#incdir=${PWD}/include
+
+#for f in ${prog_opt_files}
+#do
+#  ( cd $(dirname ${f})
+#    echo "Running autogen on $f..."
+#    autogen -L${incdir} $(basename ${f})
+#  ) || exit 1
+#done
+
+## Non-AutoGen stuff
+
+for i in autogen-version.def version.def
+do
+    cmp -s include/$i sntp/$i || cp -p include/$i sntp/$i
+done
+
+# touch the stuff generated by the opt files
+
+for f in ${prog_opt_files}
+do
+    f=`echo $f | sed -e 's/-opts.def//'`
+    l=
+    for i in `ls -1 $f*`
+    do
+       case "$i" in
+        *.c|*.h|*.1|*.texi|*.menu)
+           l="$l $i"
+           ;;
+       esac
+    done
+    case "$l" in
+     '') ;;
+     *) touch $l
+       ;;
+    esac
+done
+
+## EOAutoGen stuff
+
+cp bincheck.mf sntp/
+
+${AUTORECONF} -i -v
+
+# HMS: 20060618: Now that we use separate copies of libopts
+# we should only need the previous line.
+#
+## HMS: 20060615: the next line seems to be needed to make sure
+## we get the correct srcdir path in sntp/libopts/Makefile.in
+#rm -rf sntp/autom4te.cache
+#
+#(cd sntp && ${AUTORECONF} -i -v)
diff --git a/build b/build
new file mode 100755 (executable)
index 0000000..2a65d86
--- /dev/null
+++ b/build
@@ -0,0 +1,122 @@
+#! /bin/sh
+
+LOGF=make.log
+IAM=`hostname || uname -n`
+MYNAME=`IFS=. ; set $IAM ; echo $1`
+SIG=
+
+case "$1" in
+ 0.*)
+    SIG=$1
+    shift
+    CONFIG_ARGS="$@"
+    KEY=`sed -e q < .buildkey-$MYNAME`
+    case "$SIG" in
+     $KEY) ;;
+     *)
+       echo "Wrong directory for build on host $IAM"
+       echo "This is <`pwd`>"
+       echo "SIG is <$SIG>"
+       echo "KEY is <$KEY>"
+        exit 1
+        ;;
+    esac
+    ;;
+ *)
+    CONFIG_ARGS="$@"
+    ;;
+esac
+
+#set -e
+#set -x
+
+CVO=`./config.guess`
+case "$CVO" in
+ *-*-*) ;;
+ *) echo "config.guess returned <$CVO>, which makes no sense to me."
+    exit 1
+    ;;
+esac
+
+case "$IAM" in
+ *.udel.edu)
+    BDIR=A.$MYNAME
+    CONFIG_ARGS="$CONFIG_ARGS --enable-local-libopts"
+    case "$CVO" in
+     *-*-ultrix*)
+       CONFIG_ARGS="$CONFIG_ARGS --with-libregex=/usr/local"
+       ;;
+    esac
+    ;;
+ *)
+    BDIR=A.$CVO
+    ;;
+esac
+
+KEYSUF=""
+
+case "$CONFIG_ARGS" in
+ *--with-crypto=autokey*)
+    KEYSUF="-autokey"
+    ;;
+ *--without-crypto*)
+    KEYSUF="-noopenssl"
+    ;;
+esac
+
+case "$CONFIG_ARGS" in
+ *--disable-all-clocks*)
+    KEYSUF="$KEYSUF-no-refclocks"
+    ;;
+esac
+
+case "$CONFIG_ARGS" in
+ *--disable-debugging*)
+    KEYSUF="$KEYSUF-nodebug"
+    ;;
+esac
+
+CCSUF=""
+
+case "$CC" in
+ '') ;;
+ *) CCSUF="-$CC"
+    ;;
+esac
+
+BDIR="$BDIR$KEYSUF$CCSUF"
+
+[ -d "$BDIR" ] || mkdir $BDIR
+[ -f "$BDIR/.buildcvo" ] || echo $CVO > $BDIR/.buildcvo
+[ -f "$BDIR/.buildhost" ] || echo $IAM > $BDIR/.buildhost
+
+
+cd $BDIR
+
+#
+# make sure we have a nice that works,
+#
+nice true && NICEB=nice
+nice true || NICEB=./.nicebuild-$MYNAME-$SIG && (
+    cat > .nicebuild-$MYNAME-$SIG <<UNLYKUHLY
+#! /bin/sh
+shift
+\$*
+UNLYKUHLY
+    chmod +x .nicebuild-$MYNAME-$SIG
+)
+
+
+(
+[ -f config.status ] || $NICEB -7 ../configure --config-cache \
+                               $CONFIG_ARGS
+
+$NICEB -5 ./config.status
+
+case "$MAKE" in
+ '') $NICEB -14 make && $NICEB -10 make check
+     ;;
+ *)  $NICEB -14 $MAKE && $NICEB -10 $MAKE check
+     ;;
+esac
+) > $LOGF 2>&1
diff --git a/clockstuff/Makefile.am b/clockstuff/Makefile.am
new file mode 100644 (file)
index 0000000..2a2ec4e
--- /dev/null
@@ -0,0 +1,18 @@
+#AUTOMAKE_OPTIONS = ../ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+noinst_PROGRAMS = @PROPDELAY@ @CHUTEST@ @CLKTEST@
+EXTRA_PROGRAMS = propdelay chutest clktest
+
+INCLUDES = -I$(top_srcdir)/include
+# We need -lm (and perhaps $(COMPAT) for propdelay, -lntp for {chu,clk}test
+propdelay_LDADD = -lm ../libntp/libntp.a
+chutest_LDADD = ../libntp/libntp.a
+clktest_LDADD = ../libntp/libntp.a
+ETAGS_ARGS = Makefile.am
+#EXTRA_DIST = TAGS
+
+# clktest-opts.def wants ../include/copyright.def ../include/homerc.def
+
+chutest$(EXEEXT): ../libntp/libntp.a
+
+clktest$(EXEEXT): ../libntp/libntp.a
diff --git a/clockstuff/Makefile.in b/clockstuff/Makefile.in
new file mode 100644 (file)
index 0000000..ba4e4cd
--- /dev/null
@@ -0,0 +1,530 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+ANSI2KNR = ../util/ansi2knr
+EXTRA_PROGRAMS = propdelay$(EXEEXT) chutest$(EXEEXT) clktest$(EXEEXT)
+subdir = clockstuff
+DIST_COMMON = README $(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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+chutest_SOURCES = chutest.c
+chutest_OBJECTS = chutest$U.$(OBJEXT)
+chutest_DEPENDENCIES = ../libntp/libntp.a
+clktest_SOURCES = clktest.c
+clktest_OBJECTS = clktest$U.$(OBJEXT)
+clktest_DEPENDENCIES = ../libntp/libntp.a
+propdelay_SOURCES = propdelay.c
+propdelay_OBJECTS = propdelay$U.$(OBJEXT)
+propdelay_DEPENDENCIES = ../libntp/libntp.a
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = chutest.c clktest.c propdelay.c
+DIST_SOURCES = chutest.c clktest.c propdelay.c
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+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
+noinst_PROGRAMS = @PROPDELAY@ @CHUTEST@ @CLKTEST@
+INCLUDES = -I$(top_srcdir)/include
+# We need -lm (and perhaps $(COMPAT) for propdelay, -lntp for {chu,clk}test
+propdelay_LDADD = -lm ../libntp/libntp.a
+chutest_LDADD = ../libntp/libntp.a
+clktest_LDADD = ../libntp/libntp.a
+ETAGS_ARGS = Makefile.am
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign clockstuff/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign clockstuff/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstPROGRAMS:
+       @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+propdelay$(EXEEXT): $(propdelay_OBJECTS) $(propdelay_DEPENDENCIES) 
+       @rm -f propdelay$(EXEEXT)
+       $(LINK) $(propdelay_OBJECTS) $(propdelay_LDADD) $(LIBS)
+
+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)/chutest$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clktest$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/propdelay$U.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+chutest_.c: chutest.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/chutest.c; then echo $(srcdir)/chutest.c; else echo chutest.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clktest_.c: clktest.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clktest.c; then echo $(srcdir)/clktest.c; else echo clktest.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+propdelay_.c: propdelay.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/propdelay.c; then echo $(srcdir)/propdelay.c; else echo propdelay.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+chutest_.$(OBJEXT) chutest_.lo clktest_.$(OBJEXT) clktest_.lo \
+propdelay_.$(OBJEXT) propdelay_.lo : $(ANSI2KNR)
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+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-noinstPROGRAMS 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
+
+#EXTRA_DIST = TAGS
+
+# clktest-opts.def wants ../include/copyright.def ../include/homerc.def
+
+chutest$(EXEEXT): ../libntp/libntp.a
+
+clktest$(EXEEXT): ../libntp/libntp.a
+
+# 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.
+.NOEXPORT:
diff --git a/clockstuff/README b/clockstuff/README
new file mode 100644 (file)
index 0000000..c7f9727
--- /dev/null
@@ -0,0 +1,31 @@
+README file for directory ./clockstuff of the NTP Version 4 distribution
+
+This directory contains the sources for utility programs designed to
+support radio clocks. The chutest.c and clktest.c are desgined to
+test the chu_clk and tty_clk line disciplines and STREAMS modules in
+the ../kernel directory.
+
+These files have been modified to work with either the line disciplines
+or the STREAMS modules. Be sure to define -DSTREAM if appropriate.
+
+These are random bits of things written to help with clocks.  You can
+make things in here by typing one or more of:
+
+       make propdelay (or `make')
+       make chutest
+       make clktest
+
+Propdelay computes high frequency propagation delays, given the
+longitude and latitude of the transmitter and receiver.  Use
+this for WWV/H and CHU.  Don't use it for WWVB (the computation
+is easier for that).
+
+Chutest can be used to input and process data from a CHU modem
+attached to a serial port.  It will use the CHU line discipline
+(if installed), or raw mode otherwise.  This was used to test
+out the initial reduction algorithms, and may not be up to date.
+
+Clktest can be used to test the clock line discipline (CLKLDISC,
+it must be available), and to take a look at radio clocks attached to a
+serial port.
+
diff --git a/clockstuff/chutest.c b/clockstuff/chutest.c
new file mode 100644 (file)
index 0000000..785c253
--- /dev/null
@@ -0,0 +1,816 @@
+/* chutest.c,v 3.1 1993/07/06 01:05:21 jbj Exp
+ * chutest - test the CHU clock
+ */
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/ioctl.h>
+#include <sys/time.h>
+#include <sys/file.h>
+#include <sgtty.h>
+
+#include "../include/ntp_fp.h"
+#include "../include/ntp.h"
+#include "../include/ntp_unixtime.h"
+
+#ifdef CHULDISC
+#ifdef STREAM
+# ifdef HAVE_SYS_CHUDEFS_H
+#include <sys/chudefs.h>
+#endif
+#include <stropts.h>
+#endif
+#endif
+
+#ifdef CHULDISC
+# ifdef HAVE_SYS_CHUDEFS_H
+#include <sys/chudefs.h>
+#endif
+#endif
+
+#ifndef CHULDISC
+#ifndef STREAM
+#define        NCHUCHARS       (10)
+
+struct chucode {
+       u_char codechars[NCHUCHARS];    /* code characters */
+       u_char ncodechars;              /* number of code characters */
+       u_char chustatus;               /* not used currently */
+       struct timeval codetimes[NCHUCHARS];    /* arrival times */
+};
+#endif
+#endif
+
+#define        STREQ(a, b)     (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+char *progname;
+int debug;
+
+int dofilter = 0;      /* set to 1 when we should run filter algorithm */
+int showtimes = 0;     /* set to 1 when we should show char arrival times */
+int doprocess = 0;     /* set to 1 when we do processing analogous to driver */
+#ifdef CHULDISC
+int usechuldisc = 0;   /* set to 1 when CHU line discipline should be used */
+#endif
+#ifdef STREAM
+int usechuldisc = 0;   /* set to 1 when CHU line discipline should be used */
+#endif
+
+struct timeval lasttv;
+struct chucode chudata;
+
+extern u_long ustotslo[];
+extern u_long ustotsmid[];
+extern u_long ustotshi[];
+
+/*
+ * main - parse arguments and handle options
+ */
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       int c;
+       int errflg = 0;
+       extern int ntp_optind;
+       extern char *ntp_optarg;
+       void init_chu();
+
+       progname = argv[0];
+       while ((c = ntp_getopt(argc, argv, "cdfpt")) != EOF)
+           switch (c) {
+               case 'c':
+#ifdef STREAM
+                   usechuldisc = 1;
+                   break;
+#endif
+#ifdef CHULDISC
+                   usechuldisc = 1;
+                   break;
+#endif
+#ifndef STREAM
+#ifndef CHULDISC
+                   (void) fprintf(stderr,
+                                  "%s: CHU line discipline not available on this machine\n",
+                                  progname);
+                   exit(2);
+#endif
+#endif
+               case 'd':
+                   ++debug;
+                   break;
+               case 'f':
+                   dofilter = 1;
+                   break;
+               case 'p':
+                   doprocess = 1;
+               case 't':
+                   showtimes = 1;
+                   break;
+               default:
+                   errflg++;
+                   break;
+           }
+       if (errflg || ntp_optind+1 != argc) {
+#ifdef STREAM
+               (void) fprintf(stderr, "usage: %s [-dft] tty_device\n",
+                              progname);
+#endif
+#ifdef CHULDISC
+               (void) fprintf(stderr, "usage: %s [-dft] tty_device\n",
+                              progname);
+#endif
+#ifndef STREAM
+#ifndef CHULDISC
+               (void) fprintf(stderr, "usage: %s [-cdft] tty_device\n",
+                              progname);
+#endif
+#endif
+               exit(2);
+       }
+
+       (void) gettimeofday(&lasttv, (struct timezone *)0);
+       c = openterm(argv[ntp_optind]);
+       init_chu();
+#ifdef STREAM
+       if (usechuldisc)
+           process_ldisc(c);
+       else
+#endif
+#ifdef CHULDISC
+           if (usechuldisc)
+               process_ldisc(c);
+           else
+#endif
+               process_raw(c);
+       /*NOTREACHED*/
+}
+
+
+/*
+ * openterm - open a port to the CHU clock
+ */
+int
+openterm(
+       char *dev
+       )
+{
+       int s;
+       struct sgttyb ttyb;
+
+       if (debug)
+           (void) fprintf(stderr, "Doing open...");
+       if ((s = open(dev, O_RDONLY, 0777)) < 0)
+           error("open(%s)", dev, "");
+       if (debug)
+           (void) fprintf(stderr, "open okay\n");
+
+       if (debug)
+           (void) fprintf(stderr, "Setting exclusive use...");
+       if (ioctl(s, TIOCEXCL, (char *)0) < 0)
+           error("ioctl(TIOCEXCL)", "", "");
+       if (debug)
+           (void) fprintf(stderr, "done\n");
+       
+       ttyb.sg_ispeed = ttyb.sg_ospeed = B300;
+       ttyb.sg_erase = ttyb.sg_kill = 0;
+       ttyb.sg_flags = EVENP|ODDP|RAW;
+       if (debug)
+           (void) fprintf(stderr, "Setting baud rate et al...");
+       if (ioctl(s, TIOCSETP, (char *)&ttyb) < 0)
+           error("ioctl(TIOCSETP, raw)", "", "");
+       if (debug)
+           (void) fprintf(stderr, "done\n");
+
+#ifdef CHULDISC
+       if (usechuldisc) {
+               int ldisc;
+
+               if (debug)
+                   (void) fprintf(stderr, "Switching to CHU ldisc...");
+               ldisc = CHULDISC;
+               if (ioctl(s, TIOCSETD, (char *)&ldisc) < 0)
+                   error("ioctl(TIOCSETD, CHULDISC)", "", "");
+               if (debug)
+                   (void) fprintf(stderr, "okay\n");
+       }
+#endif
+#ifdef STREAM
+       if (usechuldisc) {
+
+               if (debug)
+                   (void) fprintf(stderr, "Poping off streams...");
+               while (ioctl(s, I_POP, 0) >=0) ;
+               if (debug)
+                   (void) fprintf(stderr, "okay\n");
+               if (debug)
+                   (void) fprintf(stderr, "Pushing CHU stream...");
+               if (ioctl(s, I_PUSH, "chu") < 0)
+                   error("ioctl(I_PUSH, \"chu\")", "", "");
+               if (debug)
+                   (void) fprintf(stderr, "okay\n");
+       }
+#endif
+       return s;
+}
+
+
+/*
+ * process_raw - process characters in raw mode
+ */
+int
+process_raw(
+       int s
+       )
+{
+       u_char c;
+       int n;
+       struct timeval tv;
+       struct timeval difftv;
+
+       while ((n = read(s, &c, sizeof(char))) > 0) {
+               (void) gettimeofday(&tv, (struct timezone *)0);
+               if (dofilter)
+                   raw_filter((unsigned int)c, &tv);
+               else {
+                       difftv.tv_sec = tv.tv_sec - lasttv.tv_sec;
+                       difftv.tv_usec = tv.tv_usec - lasttv.tv_usec;
+                       if (difftv.tv_usec < 0) {
+                               difftv.tv_sec--;
+                               difftv.tv_usec += 1000000;
+                       }
+                       (void) printf("%02x\t%lu.%06lu\t%lu.%06lu\n",
+                                     c, tv.tv_sec, tv.tv_usec, difftv.tv_sec,
+                                     difftv.tv_usec);
+                       lasttv = tv;
+               }
+       }
+
+       if (n == 0) {
+               (void) fprintf(stderr, "%s: zero returned on read\n", progname);
+               exit(1);
+       } else
+           error("read()", "", "");
+}
+
+
+/*
+ * raw_filter - run the line discipline filter over raw data
+ */
+int
+raw_filter(
+       unsigned int c,
+       struct timeval *tv
+       )
+{
+       static struct timeval diffs[10] = { 0 };
+       struct timeval diff;
+       l_fp ts;
+       void chufilter();
+
+       if ((c & 0xf) > 9 || ((c>>4)&0xf) > 9) {
+               if (debug)
+                   (void) fprintf(stderr,
+                                  "character %02x failed BCD test\n");
+               chudata.ncodechars = 0;
+               return;
+       }
+
+       if (chudata.ncodechars > 0) {
+               diff.tv_sec = tv->tv_sec
+                       - chudata.codetimes[chudata.ncodechars].tv_sec;
+               diff.tv_usec = tv->tv_usec
+                       - chudata.codetimes[chudata.ncodechars].tv_usec;
+               if (diff.tv_usec < 0) {
+                       diff.tv_sec--;
+                       diff.tv_usec += 1000000;
+               } /*
+                   if (diff.tv_sec != 0 || diff.tv_usec > 900000) {
+                   if (debug)
+                   (void) fprintf(stderr,
+                   "character %02x failed time test\n");
+                   chudata.ncodechars = 0;
+                   return;
+                   } */
+       }
+
+       chudata.codechars[chudata.ncodechars] = c;
+       chudata.codetimes[chudata.ncodechars] = *tv;
+       if (chudata.ncodechars > 0)
+           diffs[chudata.ncodechars] = diff;
+       if (++chudata.ncodechars == 10) {
+               if (doprocess) {
+                       TVTOTS(&chudata.codetimes[NCHUCHARS-1], &ts);
+                       ts.l_ui += JAN_1970;
+                       chufilter(&chudata, &chudata.codetimes[NCHUCHARS-1]);
+               } else {
+                       register int i;
+
+                       for (i = 0; i < chudata.ncodechars; i++) {
+                               (void) printf("%x%x\t%lu.%06lu\t%lu.%06lu\n",
+                                             chudata.codechars[i] & 0xf,
+                                             (chudata.codechars[i] >>4 ) & 0xf,
+                                             chudata.codetimes[i].tv_sec,
+                                             chudata.codetimes[i].tv_usec,
+                                             diffs[i].tv_sec, diffs[i].tv_usec);
+                       }
+               }
+               chudata.ncodechars = 0;
+       }
+}
+
+
+/* #ifdef CHULDISC*/
+/*
+ * process_ldisc - process line discipline
+ */
+int
+process_ldisc(
+       int s
+       )
+{
+       struct chucode chu;
+       int n;
+       register int i;
+       struct timeval diff;
+       l_fp ts;
+       void chufilter();
+
+       while ((n = read(s, (char *)&chu, sizeof chu)) > 0) {
+               if (n != sizeof chu) {
+                       (void) fprintf(stderr, "Expected %d, got %d\n",
+                                      sizeof chu, n);
+                       continue;
+               }
+
+               if (doprocess) {
+                       TVTOTS(&chu.codetimes[NCHUCHARS-1], &ts);
+                       ts.l_ui += JAN_1970;
+                       chufilter(&chu, &ts);
+               } else {
+                       for (i = 0; i < NCHUCHARS; i++) {
+                               if (i == 0)
+                                   diff.tv_sec = diff.tv_usec = 0;
+                               else {
+                                       diff.tv_sec = chu.codetimes[i].tv_sec
+                                               - chu.codetimes[i-1].tv_sec;
+                                       diff.tv_usec = chu.codetimes[i].tv_usec
+                                               - chu.codetimes[i-1].tv_usec;
+                                       if (diff.tv_usec < 0) {
+                                               diff.tv_sec--;
+                                               diff.tv_usec += 1000000;
+                                       }
+                               }
+                               (void) printf("%x%x\t%lu.%06lu\t%lu.%06lu\n",
+                                             chu.codechars[i] & 0xf, (chu.codechars[i]>>4)&0xf,
+                                             chu.codetimes[i].tv_sec, chu.codetimes[i].tv_usec,
+                                             diff.tv_sec, diff.tv_usec);
+                       }
+               }
+       }
+       if (n == 0) {
+               (void) fprintf(stderr, "%s: zero returned on read\n", progname);
+               exit(1);
+       } else
+           error("read()", "", "");
+}
+/*#endif*/
+
+
+/*
+ * error - print an error message
+ */
+void
+error(
+       char *fmt,
+       char *s1,
+       char *s2
+       )
+{
+       (void) fprintf(stderr, "%s: ", progname);
+       (void) fprintf(stderr, fmt, s1, s2);
+       (void) fprintf(stderr, ": ");
+       perror("");
+       exit(1);
+}
+
+/*
+ * Definitions
+ */
+#define        MAXUNITS        4       /* maximum number of CHU units permitted */
+#define        CHUDEV  "/dev/chu%d"    /* device we open.  %d is unit number */
+#define        NCHUCODES       9       /* expect 9 CHU codes per minute */
+
+/*
+ * When CHU is operating optimally we want the primary clock distance
+ * to come out at 300 ms.  Thus, peer.distance in the CHU peer structure
+ * is set to 290 ms and we compute delays which are at least 10 ms long.
+ * The following are 290 ms and 10 ms expressed in u_fp format
+ */
+#define        CHUDISTANCE     0x00004a3d
+#define        CHUBASEDELAY    0x0000028f
+
+/*
+ * To compute a quality for the estimate (a pseudo delay) we add a
+ * fixed 10 ms for each missing code in the minute and add to this
+ * the sum of the differences between the remaining offsets and the
+ * estimated sample offset.
+ */
+#define        CHUDELAYPENALTY 0x0000028f
+
+/*
+ * Other constant stuff
+ */
+#define        CHUPRECISION    (-9)            /* what the heck */
+#define        CHUREFID        "CHU\0"
+
+/*
+ * Default fudge factors
+ */
+#define        DEFPROPDELAY    0x00624dd3      /* 0.0015 seconds, 1.5 ms */
+#define        DEFFILTFUDGE    0x000d1b71      /* 0.0002 seconds, 200 us */
+
+/*
+ * Hacks to avoid excercising the multiplier.  I have no pride.
+ */
+#define        MULBY10(x)      (((x)<<3) + ((x)<<1))
+#define        MULBY60(x)      (((x)<<6) - ((x)<<2))   /* watch overflow */
+#define        MULBY24(x)      (((x)<<4) + ((x)<<3))
+
+/*
+ * Constants for use when multiplying by 0.1.  ZEROPTONE is 0.1
+ * as an l_fp fraction, NZPOBITS is the number of significant bits
+ * in ZEROPTONE.
+ */
+#define        ZEROPTONE       0x1999999a
+#define        NZPOBITS        29
+
+/*
+ * The CHU table.  This gives the expected time of arrival of each
+ * character after the on-time second and is computed as follows:
+ * The CHU time code is sent at 300 bps.  Your average UART will
+ * synchronize at the edge of the start bit and will consider the
+ * character complete at the center of the first stop bit, i.e.
+ * 0.031667 ms later.  Thus the expected time of each interrupt
+ * is the start bit time plus 0.031667 seconds.  These times are
+ * in chutable[].  To this we add such things as propagation delay
+ * and delay fudge factor.
+ */
+#define        CHARDELAY       0x081b4e80
+
+static u_long chutable[NCHUCHARS] = {
+       0x2147ae14 + CHARDELAY,         /* 0.130 (exactly) */
+       0x2ac08312 + CHARDELAY,         /* 0.167 (exactly) */
+       0x34395810 + CHARDELAY,         /* 0.204 (exactly) */
+       0x3db22d0e + CHARDELAY,         /* 0.241 (exactly) */
+       0x472b020c + CHARDELAY,         /* 0.278 (exactly) */
+       0x50a3d70a + CHARDELAY,         /* 0.315 (exactly) */
+       0x5a1cac08 + CHARDELAY,         /* 0.352 (exactly) */
+       0x63958106 + CHARDELAY,         /* 0.389 (exactly) */
+       0x6d0e5604 + CHARDELAY,         /* 0.426 (exactly) */
+       0x76872b02 + CHARDELAY,         /* 0.463 (exactly) */
+};
+
+/*
+ * Keep the fudge factors separately so they can be set even
+ * when no clock is configured.
+ */
+static l_fp propagation_delay;
+static l_fp fudgefactor;
+static l_fp offset_fudge;
+
+/*
+ * We keep track of the start of the year, watching for changes.
+ * We also keep track of whether the year is a leap year or not.
+ * All because stupid CHU doesn't include the year in the time code.
+ */
+static u_long yearstart;
+
+/*
+ * Imported from the timer module
+ */
+extern u_long current_time;
+extern struct event timerqueue[];
+
+/*
+ * Time conversion tables imported from the library
+ */
+extern u_long ustotslo[];
+extern u_long ustotsmid[];
+extern u_long ustotshi[];
+
+
+/*
+ * init_chu - initialize internal chu driver data
+ */
+void
+init_chu(void)
+{
+
+       /*
+        * Initialize fudge factors to default.
+        */
+       propagation_delay.l_ui = 0;
+       propagation_delay.l_uf = DEFPROPDELAY;
+       fudgefactor.l_ui = 0;
+       fudgefactor.l_uf = DEFFILTFUDGE;
+       offset_fudge = propagation_delay;
+       L_ADD(&offset_fudge, &fudgefactor);
+
+       yearstart = 0;
+}
+
+
+void
+chufilter(
+       struct chucode *chuc,
+       l_fp *rtime
+       )
+{
+       register int i;
+       register u_long date_ui;
+       register u_long tmp;
+       register u_char *code;
+       int isneg;
+       int imin;
+       int imax;
+       u_long reftime;
+       l_fp off[NCHUCHARS];
+       l_fp ts;
+       int day, hour, minute, second;
+       static u_char lastcode[NCHUCHARS];
+       extern u_long calyearstart();
+       extern char *mfptoa();
+       void chu_process();
+       extern char *prettydate();
+
+       /*
+        * We'll skip the checks made in the kernel, but assume they've
+        * been done.  This means that all characters are BCD and
+        * the intercharacter spacing isn't unreasonable.
+        */
+
+       /*
+        * print the code
+        */
+       for (i = 0; i < NCHUCHARS; i++)
+           printf("%c%c", (chuc->codechars[i] & 0xf) + '0',
+                  ((chuc->codechars[i]>>4) & 0xf) + '0');
+       printf("\n");
+
+       /*
+        * Format check.  Make sure the two halves match.
+        */
+       for (i = 0; i < NCHUCHARS/2; i++)
+           if (chuc->codechars[i] != chuc->codechars[i+(NCHUCHARS/2)]) {
+                   (void) printf("Bad format, halves don't match\n");
+                   return;
+           }
+       
+       /*
+        * Break out the code into the BCD nibbles.  Only need to fiddle
+        * with the first half since both are identical.  Note the first
+        * BCD character is the low order nibble, the second the high order.
+        */
+       code = lastcode;
+       for (i = 0; i < NCHUCHARS/2; i++) {
+               *code++ = chuc->codechars[i] & 0xf;
+               *code++ = (chuc->codechars[i] >> 4) & 0xf;
+       }
+
+       /*
+        * If the first nibble isn't a 6, we're up the creek
+        */
+       code = lastcode;
+       if (*code++ != 6) {
+               (void) printf("Bad format, no 6 at start\n");
+               return;
+       }
+
+       /*
+        * Collect the day, the hour, the minute and the second.
+        */
+       day = *code++;
+       day = MULBY10(day) + *code++;
+       day = MULBY10(day) + *code++;
+       hour = *code++;
+       hour = MULBY10(hour) + *code++;
+       minute = *code++;
+       minute = MULBY10(minute) + *code++;
+       second = *code++;
+       second = MULBY10(second) + *code++;
+
+       /*
+        * Sanity check the day and time.  Note that this
+        * only occurs on the 31st through the 39th second
+        * of the minute.
+        */
+       if (day < 1 || day > 366
+           || hour > 23 || minute > 59
+           || second < 31 || second > 39) {
+               (void) printf("Failed date sanity check: %d %d %d %d\n",
+                             day, hour, minute, second);
+               return;
+       }
+
+       /*
+        * Compute seconds into the year.
+        */
+       tmp = (u_long)(MULBY24((day-1)) + hour);        /* hours */
+       tmp = MULBY60(tmp) + (u_long)minute;            /* minutes */
+       tmp = MULBY60(tmp) + (u_long)second;            /* seconds */
+
+       /*
+        * Now the fun begins.  We demand that the received time code
+        * be within CLOCK_WAYTOOBIG 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.
+        */
+       date_ui = tmp + yearstart;
+       if (date_ui < (rtime->l_ui + CLOCK_WAYTOOBIG)
+           && date_ui > (rtime->l_ui - CLOCK_WAYTOOBIG))
+           goto codeokay;      /* looks good */
+
+       /*
+        * Trouble.  Next check is to see if the year rolled over and, if
+        * so, try again with the new year's start.
+        */
+       date_ui = calyearstart(rtime->l_ui);
+       if (date_ui != yearstart) {
+               yearstart = date_ui;
+               date_ui += tmp;
+               (void) printf("time %u, code %u, difference %d\n",
+                             date_ui, rtime->l_ui, (long)date_ui-(long)rtime->l_ui);
+               if (date_ui < (rtime->l_ui + CLOCK_WAYTOOBIG)
+                   && date_ui > (rtime->l_ui - CLOCK_WAYTOOBIG))
+                   goto codeokay;      /* okay this time */
+       }
+
+       ts.l_uf = 0;
+       ts.l_ui = yearstart;
+       printf("yearstart %s\n", prettydate(&ts));
+       printf("received %s\n", prettydate(rtime));
+       ts.l_ui = date_ui;
+       printf("date_ui %s\n", prettydate(&ts));
+
+       /*
+        * 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 CLOCK_WAYTOOBIG seconds into the new year.
+        */
+       if ((rtime->l_ui - yearstart) < CLOCK_WAYTOOBIG) {
+               date_ui = tmp + calyearstart(yearstart - CLOCK_WAYTOOBIG);
+               if ((rtime->l_ui - date_ui) < CLOCK_WAYTOOBIG)
+                   goto codeokay;
+       }
+
+       /*
+        * 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.
+        */
+       date_ui = tmp + calyearstart(yearstart + (400*24*60*60)); /* 400 days */
+       if ((date_ui - rtime->l_ui) >= CLOCK_WAYTOOBIG) {
+               printf("Date hopelessly off\n");
+               return;         /* hopeless, let it sync to other peers */
+       }
+
+    codeokay:
+       reftime = date_ui;
+       /*
+        * We've now got the integral seconds part of the time code (we hope).
+        * The fractional part comes from the table.  We next compute
+        * the offsets for each character.
+        */
+       for (i = 0; i < NCHUCHARS; i++) {
+               register u_long tmp2;
+
+               off[i].l_ui = date_ui;
+               off[i].l_uf = chutable[i];
+               tmp = chuc->codetimes[i].tv_sec + JAN_1970;
+               TVUTOTSF(chuc->codetimes[i].tv_usec, tmp2);
+               M_SUB(off[i].l_ui, off[i].l_uf, tmp, tmp2);
+       }
+
+       /*
+        * Here is a *big* problem.  What one would normally
+        * do here on a machine with lots of clock bits (say
+        * a Vax or the gizmo board) is pick the most positive
+        * offset and the estimate, since this is the one that
+        * is most likely suffered the smallest interrupt delay.
+        * The trouble is that the low order clock bit on an IBM
+        * RT, which is the machine I had in mind when doing this,
+        * ticks at just under the millisecond mark.  This isn't
+        * precise enough.  What we can do to improve this is to
+        * average all 10 samples and rely on the second level
+        * filtering to pick the least delayed estimate.  Trouble
+        * is, this means we have to divide a 64 bit fixed point
+        * number by 10, a procedure which really sucks.  Oh, well.
+        * First compute the sum.
+        */
+       date_ui = 0;
+       tmp = 0;
+       for (i = 0; i < NCHUCHARS; i++)
+           M_ADD(date_ui, tmp, off[i].l_ui, off[i].l_uf);
+       if (M_ISNEG(date_ui, tmp))
+           isneg = 1;
+       else
+           isneg = 0;
+       
+       /*
+        * Here is a multiply-by-0.1 optimization that should apply
+        * just about everywhere.  If the magnitude of the sum
+        * is less than 9 we don't have to worry about overflow
+        * out of a 64 bit product, even after rounding.
+        */
+       if (date_ui < 9 || date_ui > 0xfffffff7) {
+               register u_long prod_ui;
+               register u_long prod_uf;
+
+               prod_ui = prod_uf = 0;
+               /*
+                * This code knows the low order bit in 0.1 is zero
+                */
+               for (i = 1; i < NZPOBITS; i++) {
+                       M_LSHIFT(date_ui, tmp);
+                       if (ZEROPTONE & (1<<i))
+                           M_ADD(prod_ui, prod_uf, date_ui, tmp);
+               }
+
+               /*
+                * Done, round it correctly.  Prod_ui contains the
+                * fraction.
+                */
+               if (prod_uf & 0x80000000)
+                   prod_ui++;
+               if (isneg)
+                   date_ui = 0xffffffff;
+               else
+                   date_ui = 0;
+               tmp = prod_ui;
+               /*
+                * date_ui is integral part, tmp is fraction.
+                */
+       } else {
+               register u_long prod_ovr;
+               register u_long prod_ui;
+               register u_long prod_uf;
+               register u_long highbits;
+
+               prod_ovr = prod_ui = prod_uf = 0;
+               if (isneg)
+                   highbits = 0xffffffff;      /* sign extend */
+               else
+                   highbits = 0;
+               /*
+                * This code knows the low order bit in 0.1 is zero
+                */
+               for (i = 1; i < NZPOBITS; i++) {
+                       M_LSHIFT3(highbits, date_ui, tmp);
+                       if (ZEROPTONE & (1<<i))
+                           M_ADD3(prod_ovr, prod_uf, prod_ui,
+                                  highbits, date_ui, tmp);
+               }
+
+               if (prod_uf & 0x80000000)
+                   M_ADDUF(prod_ovr, prod_ui, (u_long)1);
+               date_ui = prod_ovr;
+               tmp = prod_ui;
+       }
+
+       /*
+        * At this point we have the mean offset, with the integral
+        * part in date_ui and the fractional part in tmp.  Store
+        * it in the structure.
+        */
+       /*
+        * Add in fudge factor.
+        */
+       M_ADD(date_ui, tmp, offset_fudge.l_ui, offset_fudge.l_uf);
+
+       /*
+        * Find the minimun and maximum offset
+        */
+       imin = imax = 0;
+       for (i = 1; i < NCHUCHARS; i++) {
+               if (L_ISGEQ(&off[i], &off[imax])) {
+                       imax = i;
+               } else if (L_ISGEQ(&off[imin], &off[i])) {
+                       imin = i;
+               }
+       }
+
+       L_ADD(&off[imin], &offset_fudge);
+       if (imin != imax)
+           L_ADD(&off[imax], &offset_fudge);
+       (void) printf("mean %s, min %s, max %s\n",
+                     mfptoa(date_ui, tmp, 8), lfptoa(&off[imin], 8),
+                     lfptoa(&off[imax], 8));
+}
diff --git a/clockstuff/clktest.c b/clockstuff/clktest.c
new file mode 100644 (file)
index 0000000..04df4b9
--- /dev/null
@@ -0,0 +1,412 @@
+/* clktest.c,v 3.1 1993/07/06 01:05:23 jbj Exp
+ * clktest - test the clock line discipline
+ *
+ * usage: clktest -b bps -f -t timeo -s cmd -c char1 -a char2 /dev/whatever
+ */
+
+#include "clktest-opts.h"
+
+#define        STREQ(a, b)     (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+#if defined(ULT_2_0_SUCKS)
+#ifndef sigmask
+#define        sigmask(m)      (1<<(m))
+#endif
+#endif
+
+#ifndef STREAM
+# ifndef CLKLDISC
+    CLOCK_LINE_DISCIPLINE_NEEDED_BY_THIS_PROGRAM;
+# endif
+#else
+# ifdef CLKLDISC
+    ONLY_ONE_CLOCK_LINE_DISCIPLINE_FOR_THIS_PROGRAM;
+# endif
+#endif
+
+/*
+ * Mask for blocking SIGIO and SIGALRM
+ */
+#define        BLOCKSIGMASK    (sigmask(SIGIO)|sigmask(SIGALRM))
+
+#define progname clktestOptions.pzProgName
+
+struct timeval timeout = { 0 };
+char *cmd = NULL;
+int cmdlen;
+
+#ifdef CLKLDISC
+u_long magic1 = DEFMAGIC;
+u_long magic2 = DEFMAGIC;
+#endif
+
+int speed = B9600;
+int ttflags = RAW|EVENP|ODDP;
+
+volatile int wasalarmed;
+volatile int iosig;
+
+struct timeval lasttv;
+
+extern u_long ustotslo[];
+extern u_long ustotsmid[];
+extern u_long ustotshi[];
+
+int alarming();
+int ioready();
+
+/*
+ * main - parse arguments and handle options
+ */
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       int fd;
+       struct sgttyb ttyb;
+       struct itimerval itimer;
+
+#ifdef STREAM
+       magic[0] = 0;
+#endif
+
+       {
+           int ct = optionProcess( &clktestOptions, argc, argv );
+           if (HAVE_OPT(COMMAND) && (strlen(OPT_ARG(COMMAND)) == 0)) {
+               fputs( "The command option string must not be empty\n", stderr );
+               USAGE( EXIT_FAILURE );
+           }
+
+           if ((argc -= ct) != 1) {
+               fputs( "Missing tty device name\n", stderr );
+               USAGE( EXIT_FAILURE );
+           }
+           argv += ct;
+       }
+#ifdef STREAM
+       if (!strlen(magic))
+           strcpy(magic,DEFMAGIC);
+#endif
+
+       fd = open(*argv, HAVE_OPT(TIMEOUT) ? O_RDWR : O_RDONLY, 0777);
+       if (fd == -1) {
+               fprintf(stderr, "%s: open(%s): ", progname, *argv);
+               perror("");
+               exit(1);
+       }
+
+       if (ioctl(fd, TIOCEXCL, (char *)0) < 0) {
+               (void) fprintf(stderr, "%s: ioctl(TIOCEXCL): ", progname);
+               perror("");
+               exit(1);
+       }
+
+       /*
+        * If we have the clock discipline, set the port to raw.  Otherwise
+        * we run cooked.
+        */
+       ttyb.sg_ispeed = ttyb.sg_ospeed = speed;
+#ifdef CLKLDISC
+       ttyb.sg_erase = (char)magic1;
+       ttyb.sg_kill = (char)magic2;
+#endif
+       ttyb.sg_flags = (short)ttflags;
+       if (ioctl(fd, TIOCSETP, (char *)&ttyb) < 0) {
+               (void) fprintf(stderr, "%s: ioctl(TIOCSETP): ", progname);
+               perror("");
+               exit(1);
+       }
+
+       if (fcntl(fd, F_SETOWN, getpid()) == -1) {
+               (void) fprintf(stderr, "%s: fcntl(F_SETOWN): ", progname);
+               perror("");
+               exit(1);
+       }
+
+#ifdef CLKLDISC
+       {
+               int ldisc;
+               ldisc = CLKLDISC;
+               if (ioctl(fd, TIOCSETD, (char *)&ldisc) < 0) {
+                       (void) fprintf(stderr, "%s: ioctl(TIOCSETD): ", progname);
+                       perror("");
+                       exit(1);
+               }
+       }
+#endif
+#ifdef STREAM
+       if (ioctl(fd, I_POP, 0) >=0 ) ;
+       if (ioctl(fd, I_PUSH, "clk") < 0) {
+               (void) fprintf(stderr, "%s: ioctl(I_PUSH): ", progname);
+               perror("");
+               exit(1);
+       }
+       if (ioctl(fd, CLK_SETSTR, magic) < 0) {
+               (void) fprintf(stderr, "%s: ioctl(CLK_SETSTR): ", progname);
+               perror("");
+               exit(1);
+       }
+#endif
+
+
+       (void) gettimeofday(&lasttv, (struct timezone *)0);
+       if (HAVE_OPT(TIMEOUT)) {
+               /*
+                * set non-blocking, async I/O on the descriptor
+                */
+               iosig = 0;
+               (void) signal(SIGIO, ioready);
+               if (fcntl(fd, F_SETFL, FNDELAY|FASYNC) < 0) {
+                       (void) fprintf(stderr, "%s: fcntl(F_SETFL): ",
+                                      progname);
+                       perror("");
+                       exit(1);
+               }
+
+               /*
+                * Set up the alarm interrupt.
+                */
+               wasalarmed = 0;
+               (void) signal(SIGALRM, alarming);
+               timeout.tv_sec = OPT_VALUE_TIMEOUT;
+               itimer.it_interval = itimer.it_value = timeout;
+               setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
+               doboth(fd);
+       }
+       doioonly(fd);
+}
+
+
+/*
+ * doboth - handle both I/O and alarms via SIGIO
+ */
+int
+doboth(
+       int fd
+       )
+{
+       int n;
+       int sawalarm;
+       int sawiosig;
+       int omask;
+       fd_set fds;
+       struct timeval tvzero;
+
+       sawalarm = 0;
+       sawiosig = 0;
+       FD_ZERO(&fds);
+       for (;;) {
+               omask = sigblock(BLOCKSIGMASK);
+               if (wasalarmed) {               /* alarmed? */
+                       sawalarm = 1;
+                       wasalarmed = 0;
+               }
+               if (iosig) {
+                       sawiosig = 1;
+                       iosig = 0;
+               }
+
+               if (!sawalarm && !sawiosig) {
+                       /*
+                        * Nothing to do.  Wait for something.
+                        */
+                       sigpause(omask);
+                       if (wasalarmed) {               /* alarmed? */
+                               sawalarm = 1;
+                               wasalarmed = 0;
+                       }
+                       if (iosig) {
+                               sawiosig = 1;
+                               iosig = 0;
+                       }
+               }
+               (void)sigsetmask(omask);
+
+               if (sawiosig) {
+
+                       do {
+                               tvzero.tv_sec = tvzero.tv_usec = 0;
+                               FD_SET(fd, &fds);
+                               n = select(fd+1, &fds, (fd_set *)0,
+                                          (fd_set *)0, &tvzero);
+                               if (n > 0)
+                                   doio(fd);
+                       } while (n > 0);
+
+                       if (n == -1) {
+                               (void) fprintf(stderr, "%s: select: ",
+                                              progname);
+                               perror("");
+                               exit(1);
+                       }
+                       sawiosig = 0;
+               }
+               if (sawalarm) {
+                       doalarm(fd);
+                       sawalarm = 0;
+               }
+       }
+}
+
+
+/*
+ * doioonly - do I/O.  This avoids the use of signals
+ */
+int
+doioonly(
+       int fd
+       )
+{
+       int n;
+       fd_set fds;
+
+       FD_ZERO(&fds);
+       for (;;) {
+               FD_SET(fd, &fds);
+               n = select(fd+1, &fds, (fd_set *)0, (fd_set *)0,
+                          (struct timeval *)0);
+               if (n > 0)
+                   doio(fd);
+       }
+}
+
+
+/*
+ * doio - read a buffer full of stuff and print it out
+ */
+int
+doio(
+       int fd
+       )
+{
+       register char *rp, *rpend;
+       register char *cp;
+       register int i;
+       char raw[512];
+       struct timeval tv, tvd;
+       int rlen;
+       int ind;
+       char cooked[2049];
+       static char *digits = "0123456789abcdef";
+
+       rlen = read(fd, raw, sizeof(raw));
+       if (rlen < 0) {
+               (void) fprintf(stderr, "%s: read(): ", progname);
+               perror("");
+               return;
+       }
+       if (rlen == 0) {
+               (void) printf("Zero length read\n");
+               return;
+       }
+
+       cp = cooked;
+       rp = raw;
+       rpend = &raw[rlen];
+       ind = 0;
+
+       while (rp < rpend) {
+               ind = 1;
+               if (isprint(*rp))
+                   *cp++ = *rp;
+               else {
+                       *cp++ = '<';
+                       *cp++ = digits[((*rp)>>4) & 0xf];
+                       *cp++ = digits[*rp & 0xf];
+                       *cp++ = '>';
+               }
+               if (
+#ifdef CLKLDISC
+                       (*rp == (char)magic1 || *rp == (char)magic2)
+#else
+                       ( strchr( magic, *rp) != NULL )
+#endif
+                       ) {
+                       rp++;
+                       ind = 0;
+                       *cp = '\0';
+                       if ((rpend - rp) < sizeof(struct timeval)) {
+                               (void)printf(
+                                       "Too little data (%d): %s\n",
+                                       rpend-rp, cooked);
+                               return;
+                       }
+
+                       tv.tv_sec = 0;
+                       for (i = 0; i < 4; i++) {
+                               tv.tv_sec <<= 8;
+                               tv.tv_sec |= ((long)*rp++) & 0xff;
+                       }
+                       tv.tv_usec = 0;
+                       for (i = 0; i < 4; i++) {
+                               tv.tv_usec <<= 8;
+                               tv.tv_usec |= ((long)*rp++) & 0xff;
+                       }
+
+                       tvd.tv_sec = tv.tv_sec - lasttv.tv_sec;
+                       tvd.tv_usec = tv.tv_usec - lasttv.tv_usec;
+                       if (tvd.tv_usec < 0) {
+                               tvd.tv_usec += 1000000;
+                               tvd.tv_sec--;
+                       }
+
+                       (void)printf("%lu.%06lu %lu.%06lu %s\n",
+                                    tv.tv_sec, tv.tv_usec, tvd.tv_sec, tvd.tv_usec,
+                                    cooked);
+                       lasttv = tv;
+               } else {
+                       rp++;
+               }
+       }
+
+       if (ind) {
+               *cp = '\0';
+               (void)printf("Incomplete data: %s\n", cooked);
+       }
+}
+
+
+/*
+ * doalarm - send a string out the port, if we have one.
+ */
+int
+doalarm(
+       int fd
+       )
+{
+       int n;
+
+       if (! HAVE_OPT(COMMAND))
+           return;
+
+       n = write(fd, cmd, cmdlen);
+
+       if (n < 0) {
+               (void) fprintf(stderr, "%s: write(): ", progname);
+               perror("");
+       } else if (n < cmdlen) {
+               (void) printf("Short write (%d bytes, should be %d)\n",
+                             n, cmdlen);
+       }
+}
+
+
+/*
+ * alarming - receive alarm interupt
+ */
+void
+alarming(void)
+{
+       wasalarmed = 1;
+}
+
+/*
+ * ioready - handle SIGIO interrupt
+ */
+void
+ioready(void)
+{
+       iosig = 1;
+}
diff --git a/clockstuff/propdelay.c b/clockstuff/propdelay.c
new file mode 100644 (file)
index 0000000..c8df686
--- /dev/null
@@ -0,0 +1,544 @@
+/* propdelay.c,v 3.1 1993/07/06 01:05:24 jbj Exp
+ * propdelay - compute propagation delays
+ *
+ * cc -o propdelay propdelay.c -lm
+ *
+ * "Time and Frequency Users' Manual", NBS Technical Note 695 (1977).
+ */
+
+/*
+ * This can be used to get a rough idea of the HF propagation delay
+ * between two points (usually between you and the radio station).
+ * The usage is
+ *
+ * propdelay latitudeA longitudeA latitudeB longitudeB
+ *
+ * where points A and B are the locations in question.  You obviously
+ * need to know the latitude and longitude of each of the places.
+ * The program expects the latitude to be preceded by an 'n' or 's'
+ * and the longitude to be preceded by an 'e' or 'w'.  It understands
+ * either decimal degrees or degrees:minutes:seconds.  Thus to compute
+ * the delay between the WWVH (21:59:26N, 159:46:00W) and WWV (40:40:49N,
+ * 105:02:27W) you could use:
+ *
+ * propdelay n21:59:26 w159:46 n40:40:49 w105:02:27
+ *
+ * By default it prints out a summer (F2 average virtual height 350 km) and
+ * winter (F2 average virtual height 250 km) number.  The results will be
+ * quite approximate but are about as good as you can do with HF time anyway.
+ * You might pick a number between the values to use, or use the summer
+ * value in the summer and switch to the winter value when the static
+ * above 10 MHz starts to drop off in the fall.  You can also use the
+ * -h switch if you want to specify your own virtual height.
+ *
+ * You can also do a
+ *
+ * propdelay -W n45:17:47 w75:45:22
+ *
+ * to find the propagation delays to WWV and WWVH (from CHU in this
+ * case), a
+ *
+ * propdelay -C n40:40:49 w105:02:27
+ *
+ * to find the delays to CHU, and a
+ *
+ * propdelay -G n52:03:17 w98:34:18
+ *
+ * to find delays to GOES via each of the three satellites.
+ */
+
+#include <stdio.h>
+#include <string.h>
+
+#include "ntp_stdlib.h"
+
+extern double  sin     (double);
+extern double  cos     (double);
+extern double  acos    (double);
+extern double  tan     (double);
+extern double  atan    (double);
+extern double  sqrt    (double);
+
+#define        STREQ(a, b)     (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+/*
+ * Program constants
+ */
+#define        EARTHRADIUS     (6370.0)        /* raduis of earth (km) */
+#define        LIGHTSPEED      (299800.0)      /* speed of light, km/s */
+#define        PI              (3.1415926536)
+#define        RADPERDEG       (PI/180.0)      /* radians per degree */
+#define MILE           (1.609344)      /* km in a mile */
+
+#define        SUMMERHEIGHT    (350.0)         /* summer height in km */
+#define        WINTERHEIGHT    (250.0)         /* winter height in km */
+
+#define SATHEIGHT      (6.6110 * 6378.0) /* geosync satellite height in km
+                                            from centre of earth */
+
+#define WWVLAT  "n40:40:49"
+#define WWVLONG "w105:02:27"
+
+#define WWVHLAT  "n21:59:26"
+#define WWVHLONG "w159:46:00"
+
+#define CHULAT "n45:17:47"
+#define        CHULONG "w75:45:22"
+
+#define GOES_UP_LAT  "n37:52:00"
+#define GOES_UP_LONG "w75:27:00"
+#define GOES_EAST_LONG "w75:00:00"
+#define GOES_STBY_LONG "w105:00:00"
+#define GOES_WEST_LONG "w135:00:00"
+#define GOES_SAT_LAT "n00:00:00"
+
+char *wwvlat = WWVLAT;
+char *wwvlong = WWVLONG;
+
+char *wwvhlat = WWVHLAT;
+char *wwvhlong = WWVHLONG;
+
+char *chulat = CHULAT;
+char *chulong = CHULONG;
+
+char *goes_up_lat = GOES_UP_LAT;
+char *goes_up_long = GOES_UP_LONG;
+char *goes_east_long = GOES_EAST_LONG;
+char *goes_stby_long = GOES_STBY_LONG;
+char *goes_west_long = GOES_WEST_LONG;
+char *goes_sat_lat = GOES_SAT_LAT;
+
+int hflag = 0;
+int Wflag = 0;
+int Cflag = 0;
+int Gflag = 0;
+int height;
+
+char *progname;
+volatile int debug;
+
+static void    doit            (double, double, double, double, double, char *);
+static double  latlong         (char *, int);
+static double  greatcircle     (double, double, double, double);
+static double  waveangle       (double, double, int);
+static double  propdelay       (double, double, int);
+static int     finddelay       (double, double, double, double, double, double *);
+static void    satdoit         (double, double, double, double, double, double, char *);
+static void    satfinddelay    (double, double, double, double, double *);
+static double  satpropdelay    (double);
+
+/*
+ * main - parse arguments and handle options
+ */
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       int c;
+       int errflg = 0;
+       double lat1, long1;
+       double lat2, long2;
+       double lat3, long3;
+
+       progname = argv[0];
+       while ((c = ntp_getopt(argc, argv, "dh:CWG")) != EOF)
+           switch (c) {
+               case 'd':
+                   ++debug;
+                   break;
+               case 'h':
+                   hflag++;
+                   height = atof(ntp_optarg);
+                   if (height <= 0.0) {
+                           (void) fprintf(stderr, "height %s unlikely\n",
+                                          ntp_optarg);
+                           errflg++;
+                   }
+                   break;
+               case 'C':
+                   Cflag++;
+                   break;
+               case 'W':
+                   Wflag++;
+                   break;
+               case 'G':
+                   Gflag++;
+                   break;
+               default:
+                   errflg++;
+                   break;
+           }
+       if (errflg || (!(Cflag || Wflag || Gflag) && ntp_optind+4 != argc) || 
+           ((Cflag || Wflag || Gflag) && ntp_optind+2 != argc)) {
+               (void) fprintf(stderr,
+                              "usage: %s [-d] [-h height] lat1 long1 lat2 long2\n",
+                              progname);
+               (void) fprintf(stderr," - or -\n");
+               (void) fprintf(stderr,
+                              "usage: %s -CWG [-d] lat long\n",
+                              progname);
+               exit(2);
+       }
+
+                  
+       if (!(Cflag || Wflag || Gflag)) {
+               lat1 = latlong(argv[ntp_optind], 1);
+               long1 = latlong(argv[ntp_optind + 1], 0);
+               lat2 = latlong(argv[ntp_optind + 2], 1);
+               long2 = latlong(argv[ntp_optind + 3], 0);
+               if (hflag) {
+                       doit(lat1, long1, lat2, long2, height, "");
+               } else {
+                       doit(lat1, long1, lat2, long2, (double)SUMMERHEIGHT,
+                            "summer propagation, ");
+                       doit(lat1, long1, lat2, long2, (double)WINTERHEIGHT,
+                            "winter propagation, ");
+               }
+       } else if (Wflag) {
+               /*
+                * Compute delay from WWV
+                */
+               lat1 = latlong(argv[ntp_optind], 1);
+               long1 = latlong(argv[ntp_optind + 1], 0);
+               lat2 = latlong(wwvlat, 1);
+               long2 = latlong(wwvlong, 0);
+               if (hflag) {
+                       doit(lat1, long1, lat2, long2, height, "WWV  ");
+               } else {
+                       doit(lat1, long1, lat2, long2, (double)SUMMERHEIGHT,
+                            "WWV  summer propagation, ");
+                       doit(lat1, long1, lat2, long2, (double)WINTERHEIGHT,
+                            "WWV  winter propagation, ");
+               }
+
+               /*
+                * Compute delay from WWVH
+                */
+               lat2 = latlong(wwvhlat, 1);
+               long2 = latlong(wwvhlong, 0);
+               if (hflag) {
+                       doit(lat1, long1, lat2, long2, height, "WWVH ");
+               } else {
+                       doit(lat1, long1, lat2, long2, (double)SUMMERHEIGHT,
+                            "WWVH summer propagation, ");
+                       doit(lat1, long1, lat2, long2, (double)WINTERHEIGHT,
+                            "WWVH winter propagation, ");
+               }
+       } else if (Cflag) {
+               lat1 = latlong(argv[ntp_optind], 1);
+               long1 = latlong(argv[ntp_optind + 1], 0);
+               lat2 = latlong(chulat, 1);
+               long2 = latlong(chulong, 0);
+               if (hflag) {
+                       doit(lat1, long1, lat2, long2, height, "CHU ");
+               } else {
+                       doit(lat1, long1, lat2, long2, (double)SUMMERHEIGHT,
+                            "CHU summer propagation, ");
+                       doit(lat1, long1, lat2, long2, (double)WINTERHEIGHT,
+                            "CHU winter propagation, ");
+               }
+       } else if (Gflag) {
+               lat1 = latlong(goes_up_lat, 1);
+               long1 = latlong(goes_up_long, 0);
+               lat3 = latlong(argv[ntp_optind], 1);
+               long3 = latlong(argv[ntp_optind + 1], 0);
+
+               lat2 = latlong(goes_sat_lat, 1);
+
+               long2 = latlong(goes_west_long, 0);
+               satdoit(lat1, long1, lat2, long2, lat3, long3,
+                       "GOES Delay via WEST");
+
+               long2 = latlong(goes_stby_long, 0);
+               satdoit(lat1, long1, lat2, long2, lat3, long3,
+                       "GOES Delay via STBY");
+
+               long2 = latlong(goes_east_long, 0);
+               satdoit(lat1, long1, lat2, long2, lat3, long3,
+                       "GOES Delay via EAST");
+
+       }
+       exit(0);
+}
+
+
+/*
+ * doit - compute a delay and print it
+ */
+static void
+doit(
+       double lat1,
+       double long1,
+       double lat2,
+       double long2,
+       double h,
+       char *str
+       )
+{
+       int hops;
+       double delay;
+
+       hops = finddelay(lat1, long1, lat2, long2, h, &delay);
+       printf("%sheight %g km, hops %d, delay %g seconds\n",
+              str, h, hops, delay);
+}
+
+
+/*
+ * latlong - decode a latitude/longitude value
+ */
+static double
+latlong(
+       char *str,
+       int islat
+       )
+{
+       register char *cp;
+       register char *bp;
+       double arg;
+       double divby;
+       int isneg;
+       char buf[32];
+       char *colon;
+
+       if (islat) {
+               /*
+                * Must be north or south
+                */
+               if (*str == 'N' || *str == 'n')
+                   isneg = 0;
+               else if (*str == 'S' || *str == 's')
+                   isneg = 1;
+               else
+                   isneg = -1;
+       } else {
+               /*
+                * East is positive, west is negative
+                */
+               if (*str == 'E' || *str == 'e')
+                   isneg = 0;
+               else if (*str == 'W' || *str == 'w')
+                   isneg = 1;
+               else
+                   isneg = -1;
+       }
+
+       if (isneg >= 0)
+           str++;
+
+       colon = strchr(str, ':');
+       if (colon != NULL) {
+               /*
+                * in hhh:mm:ss form
+                */
+               cp = str;
+               bp = buf;
+               while (cp < colon)
+                   *bp++ = *cp++;
+               *bp = '\0';
+               cp++;
+               arg = atof(buf);
+               divby = 60.0;
+               colon = strchr(cp, ':');
+               if (colon != NULL) {
+                       bp = buf;
+                       while (cp < colon)
+                           *bp++ = *cp++;
+                       *bp = '\0';
+                       cp++;
+                       arg += atof(buf) / divby;
+                       divby = 3600.0;
+               }
+               if (*cp != '\0')
+                   arg += atof(cp) / divby;
+       } else {
+               arg = atof(str);
+       }
+
+       if (isneg == 1)
+           arg = -arg;
+
+       if (debug > 2)
+           (void) printf("latitude/longitude %s = %g\n", str, arg);
+
+       return arg;
+}
+
+
+/*
+ * greatcircle - compute the great circle distance in kilometers
+ */
+static double
+greatcircle(
+       double lat1,
+       double long1,
+       double lat2,
+       double long2
+       )
+{
+       double dg;
+       double l1r, l2r;
+
+       l1r = lat1 * RADPERDEG;
+       l2r = lat2 * RADPERDEG;
+       dg = EARTHRADIUS * acos(
+               (cos(l1r) * cos(l2r) * cos((long2-long1)*RADPERDEG))
+               + (sin(l1r) * sin(l2r)));
+       if (debug >= 2)
+           printf(
+                   "greatcircle lat1 %g long1 %g lat2 %g long2 %g dist %g\n",
+                   lat1, long1, lat2, long2, dg);
+       return dg;
+}
+
+
+/*
+ * waveangle - compute the wave angle for the given distance, virtual
+ *            height and number of hops.
+ */
+static double
+waveangle(
+       double dg,
+       double h,
+       int n
+       )
+{
+       double theta;
+       double delta;
+
+       theta = dg / (EARTHRADIUS * (double)(2 * n));
+       delta = atan((h / (EARTHRADIUS * sin(theta))) + tan(theta/2)) - theta;
+       if (debug >= 2)
+           printf("waveangle dist %g height %g hops %d angle %g\n",
+                  dg, h, n, delta / RADPERDEG);
+       return delta;
+}
+
+
+/*
+ * propdelay - compute the propagation delay
+ */
+static double
+propdelay(
+       double dg,
+       double h,
+       int n
+       )
+{
+       double phi;
+       double theta;
+       double td;
+
+       theta = dg / (EARTHRADIUS * (double)(2 * n));
+       phi = (PI/2.0) - atan((h / (EARTHRADIUS * sin(theta))) + tan(theta/2));
+       td = dg / (LIGHTSPEED * sin(phi));
+       if (debug >= 2)
+           printf("propdelay dist %g height %g hops %d time %g\n",
+                  dg, h, n, td);
+       return td;
+}
+
+
+/*
+ * finddelay - find the propagation delay
+ */
+static int
+finddelay(
+       double lat1,
+       double long1,
+       double lat2,
+       double long2,
+       double h,
+       double *delay
+       )
+{
+       double dg;      /* great circle distance */
+       double delta;   /* wave angle */
+       int n;          /* number of hops */
+
+       dg = greatcircle(lat1, long1, lat2, long2);
+       if (debug)
+           printf("great circle distance %g km %g miles\n", dg, dg/MILE);
+       
+       n = 1;
+       while ((delta = waveangle(dg, h, n)) < 0.0) {
+               if (debug)
+                   printf("tried %d hop%s, no good\n", n, n>1?"s":"");
+               n++;
+       }
+       if (debug)
+           printf("%d hop%s okay, wave angle is %g\n", n, n>1?"s":"",
+                  delta / RADPERDEG);
+
+       *delay = propdelay(dg, h, n);
+       return n;
+}
+
+/*
+ * satdoit - compute a delay and print it
+ */
+static void
+satdoit(
+       double lat1,
+       double long1,
+       double lat2,
+       double long2,
+       double lat3,
+       double long3,
+       char *str
+       )
+{
+       double up_delay,down_delay;
+
+       satfinddelay(lat1, long1, lat2, long2, &up_delay);
+       satfinddelay(lat3, long3, lat2, long2, &down_delay);
+
+       printf("%s, delay %g seconds\n", str, up_delay + down_delay);
+}
+
+/*
+ * satfinddelay - calculate the one-way delay time between a ground station
+ * and a satellite
+ */
+static void
+satfinddelay(
+       double lat1,
+       double long1,
+       double lat2,
+       double long2,
+       double *delay
+       )
+{
+       double dg;      /* great circle distance */
+
+       dg = greatcircle(lat1, long1, lat2, long2);
+
+       *delay = satpropdelay(dg);
+}
+
+/*
+ * satpropdelay - calculate the one-way delay time between a ground station
+ * and a satellite
+ */
+static double
+satpropdelay(
+       double dg
+       )
+{
+       double k1, k2, dist;
+       double theta;
+       double td;
+
+       theta = dg / (EARTHRADIUS);
+       k1 = EARTHRADIUS * sin(theta);
+       k2 = SATHEIGHT - (EARTHRADIUS * cos(theta));
+       if (debug >= 2)
+           printf("Theta %g k1 %g k2 %g\n", theta, k1, k2);
+       dist = sqrt(k1*k1 + k2*k2);
+       td = dist / LIGHTSPEED;
+       if (debug >= 2)
+           printf("propdelay dist %g height %g time %g\n", dg, dist, td);
+       return td;
+}
diff --git a/compile b/compile
new file mode 100755 (executable)
index 0000000..1b1d232
--- /dev/null
+++ b/compile
@@ -0,0 +1,142 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand `-c -o'.
+
+scriptversion=2005-05-14.22
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand `-c -o'.
+Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file `INSTALL'.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "compile $scriptversion"
+    exit $?
+    ;;
+esac
+
+ofile=
+cfile=
+eat=
+
+for arg
+do
+  if test -n "$eat"; then
+    eat=
+  else
+    case $1 in
+      -o)
+       # configure might choose to run compile as `compile cc -o foo foo.c'.
+       # So we strip `-o arg' only if arg is an object.
+       eat=1
+       case $2 in
+         *.o | *.obj)
+           ofile=$2
+           ;;
+         *)
+           set x "$@" -o "$2"
+           shift
+           ;;
+       esac
+       ;;
+      *.c)
+       cfile=$1
+       set x "$@" "$1"
+       shift
+       ;;
+      *)
+       set x "$@" "$1"
+       shift
+       ;;
+    esac
+  fi
+  shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+  # If no `-o' option was seen then we might have been invoked from a
+  # pattern rule where we don't need one.  That is ok -- this is a
+  # normal compilation that the losing compiler can handle.  If no
+  # `.c' file was seen then we are probably linking.  That is also
+  # ok.
+  exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use `[/.-]' here to ensure that we don't use the same name
+# that we are using for the .o file.  Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
+while true; do
+  if mkdir "$lockdir" >/dev/null 2>&1; then
+    break
+  fi
+  sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+  mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+  mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/conf/README b/conf/README
new file mode 100644 (file)
index 0000000..327f716
--- /dev/null
@@ -0,0 +1,13 @@
+README file for directory ./conf of the NTP Version 4 distribution
+
+This directory contains example run-time configuration files for the
+NTP Version 4 daemon ntpd. These files illustrate some of the more
+obtuse configurations you may run into. They are not likely to do
+anything good if run on machines other than their native spot, so don't
+just blindly copy something and put it up. Additional information can
+be found in the ./doc directory of the base directory.
+
+Included also are example public key and symmetric key files produced
+by the ntp-genkeys program with names prefixed by ntpkey. These are
+ordinarily kept in /usr/local/etc and used by the Autokey scheme. See
+the authopt.htm pnd genkeys.htm ages for further information.
diff --git a/conf/baldwin.conf b/conf/baldwin.conf
new file mode 100644 (file)
index 0000000..1238ba1
--- /dev/null
@@ -0,0 +1,10 @@
+#
+# NTP manycast configuration file (ntp.conf) for DCnet hosts
+#
+# Note that the .rnd random seed file  must pe in the root
+# directory and the public and private keys in /usr/local/etc.
+#
+manycastclient 239.1.1.1 autokey maxpoll 12
+manycastserver 239.1.1.1 
+crypto randfile /.rnd          # enable public key
+driftfile /etc/ntp.drift       # path for drift file
diff --git a/conf/beauregard.conf b/conf/beauregard.conf
new file mode 100644 (file)
index 0000000..72f735b
--- /dev/null
@@ -0,0 +1,23 @@
+#
+# NTP configuration file (ntp.conf)
+# bearegard.udel.edu
+#
+server 127.127.18.1            # NIST ACTS modem driver
+fudge 127.127.18.1 time1 .0035
+phone atdt913034944774 atdt913034944785 atdt913034944774
+#phone atdt913034944812 atdt913034948497 atdt913034948022
+#
+# Miscellaneous stuff
+#
+driftfile /etc/ntp.drift       # path for drift file
+statsdir /beauregard/ntpstats/ # directory for statistics files
+filegen peerstats file peerstats type day enable
+filegen loopstats file loopstats type day enable
+filegen clockstats file clockstats type day enable
+#
+# Authentication stuff
+#
+keys /usr/local/etc/ntp.keys   # path for keys file
+trustedkey 3 4 5 6 14 15       # define trusted keys
+requestkey 15                  # key (7) for accessing server variables
+controlkey 15                  # key (6) for accessing server variables
diff --git a/conf/grundoon.conf b/conf/grundoon.conf
new file mode 100644 (file)
index 0000000..eb18b3f
--- /dev/null
@@ -0,0 +1,36 @@
+#
+# NTP configuration file (ntp.conf)
+# grundoon.udel.edu
+#
+server 127.127.11.1 prefer     # Arbiter 1088 GPS receiver
+fudge 127.127.11.1 time1 .00487 flag1 1 flag4 1
+server 127.127.22.1 minpoll 4  # PPS quick poll
+fudge 127.127.22.1             # default use PLL/FLL loop
+
+broadcast 128.4.2.255 key 5    # brpadcast on LAN shared key
+broadcast 239.1.1.2 autokey    # multicast on WAN autokey
+
+manycastclient 239.1.1.1 autokey maxpoll 12 ttl 7
+manycastserver 239.1.1.1 
+#
+# Access control stuff
+#
+restrict default noserve       # default deny
+restrict 127.0.0.1             # allow local host
+restrict 128.4.0.0 mask 255.255.0.0 # allow DCnet clients
+restrict 128.175.0.0 mask 255.255.0.0 # allow UDel clients
+restrict 140.173.0.0 mask 255.255.0.0 # allow DARTnet/CAIRN clients
+#
+# Authentication stuff
+#
+crypto                         # enable public key
+keys /usr/local/etc/ntp.keys   # path for keys file
+trustedkey 3 4 5 14            # define trusted keys
+requestkey 14                  # key (7) for accessing server variables
+controlkey 14                  # key (6) for accessing server variables
+#
+# Miscellaneous stuff
+#
+driftfile /etc/ntp.drift       # path for drift file
+statsdir /var/spool/ntpstats/  # directory for statistics files
+filegen loopstats file loopstats type day enable
diff --git a/conf/malarky.conf b/conf/malarky.conf
new file mode 100644 (file)
index 0000000..1475e1e
--- /dev/null
@@ -0,0 +1,24 @@
+#
+# NTP configuration file (ntp.conf)
+#
+# This is for a broadcast/multicast client. Except for the statistics
+# stuff, this can be done with only a commmand line of the form
+#
+# /usr/local/bin/ntpd -a -k /usr/local/bin/ntp.keys -m -t 3
+#
+multicastclient                        # listen on default 224.0.1.1
+#
+# Miscellaneous stuff
+#
+driftfile /etc/ntp.drift        # path for drift file
+statsdir /malarky/ntpstats/    # directory for statistics files
+filegen peerstats file peerstats type day enable
+filegen loopstats file loopstats type day enable
+filegen clockstats file clockstats type day enable
+#
+# Authentication stuff
+#
+keys /usr/local/etc/ntp.keys   # path for key file
+trustedkey 3 4 5 6 14          # define trusted keys
+requestkey 14                  # key (7) for accessing server variables
+controlkey 14                  # key (6) for accessing server variables
diff --git a/conf/pogo.conf b/conf/pogo.conf
new file mode 100644 (file)
index 0000000..0dbc58a
--- /dev/null
@@ -0,0 +1,44 @@
+#
+# NTP configuration file (ntp.conf)
+# SunOS pogo.udel.edu 5.8 Generic sun4u sparc SUNW,Ultra-1
+#
+server 127.127.6.1 prefer      # IRIG from GPS1
+fudge 127.127.6.1 refid GPS1 time1 -.002777 flag2 1
+server 127.127.4.1             # spectracom GPS receiver
+# delays: prop 0.0088 ant .0002 rcvr .0173 = 26.3 ms; os .0035
+fudge 127.127.4.1 refid GPS2 time1 .000221 
+server 127.127.22.0            # PPS from GPS2
+fudge 127.127.22.0 flag3 1     # kernel PPS
+#
+# Backups
+#
+server 128.4.1.2               # mizbeaver
+server 128.175.60.175 version 3        # ntp1.nss
+#
+# Services
+#
+manycastclient 239.1.1.1 autokey maxpoll 12 ttl 7
+manycastserver 239.1.1.1
+#
+# Access control stuff
+#
+restrict default noserve       # default deny
+restrict 127.0.0.1             # allow local host
+restrict 128.4.0.0 mask 255.255.0.0 # allow DCnet clients
+restrict 128.175.0.0 mask 255.255.0.0 # allow UDel clients
+restrict 140.173.0.0 mask 255.255.0.0 # allow DARTnet/CAIRN clients
+#
+# Authentication stuff
+#
+crypto                         # enable public key
+keys /usr/local/etc/ntp.keys   # path for keys file
+trustedkey 3 4 5 14            # define trusted keys
+requestkey 14                  # key (7) for accessing server variables
+controlkey 14                  # key (6) for accessing server variables
+#
+# Miscellaneous stuff
+#
+driftfile /etc/ntp.drift       # path for drift file
+statsdir /var/spool/ntpstats/  # directory for statistics files
+filegen loopstats file loopstats type day enable
+filegen cryptostats file cryptostats type day enable
diff --git a/conf/rackety.conf b/conf/rackety.conf
new file mode 100644 (file)
index 0000000..684e4b7
--- /dev/null
@@ -0,0 +1,56 @@
+#
+# NTP configuration file (ntp.conf)
+# SunOS rackety.u 4.1.3 243 sun4c
+#
+# This is for a dedicated primary server connected to four reference
+# clocks and providing service via multicast, broadcast, manycast and
+# the usual suspects. It blocks previous versions and limits clients
+# per network to two and returnd a kiss-of-death packet if the
+# sender is blocked. Note that the precise fudge factors were
+# determined using the calibrate feature and that the kernel PPS
+# discipline is selected.
+#
+server 127.127.4.0 prefer      # Spectracom GPS receiver #1
+fudge 127.127.4.0 refid GPS1 time1 -.000097 flag1 1
+server 127.127.4.1             # Spectracom GPS receiver #2
+fudge 127.127.4.1 refid GPS2 time1 -.000097 flag1 1
+server 127.127.4.2             # Spectracom WWVB receiver #1
+# delays: prop 0.0088 ant .0002 rcvr .0173 = 26.3 ms; os .0035
+fudge 127.127.4.2 refid WVB1 time1 .0021 flag4 1 flag1 1
+server 127.127.4.3             # Spectracom WWVB receiver #2
+# delays: prop 0.0088 ant .0002 rcvr .0173 = 26.3 ms; os .0035
+fudge 127.127.4.3 refid WVB2 time1 .0021 flag4 1 flag1 1
+server 127.127.22.1            # PPS
+fudge 127.127.22.1 flag3 1     # kernel PPS 
+#
+# Services
+#
+broadcast 224.0.1.1 autokey    # multicast
+broadcast 128.4.1.255 autokey  # local subnet broadcast
+manycastclient 239.1.1.1 autokey maxpoll 12 ttl 7 # manycast
+manycastserver 239.1.1.1       # manycast
+#
+# Access controls
+#
+restrict default limited version kod # default limit clients per net
+restrict 127.0.0.1             # allow local host
+restrict 128.4.0.0 mask 255.255.0.0 # allow DCnet clients
+restrict 128.175.0.0 mask 255.255.0.0 # allow UDELnet clients
+restrict 140.173.0.0 mask 255.255.0.0 # allow DARTnet/CAIRN clients
+#
+# Authentication stuff
+#
+crypto                         # enable public key
+keys /usr/local/etc/ntp.keys   # symmetric keys file
+trustedkey 3 4 5 14            # define trusted keys
+requestkey 14                  # key (7) for accessing server variables
+controlkey 14                  # key (6) for accessing server variables
+#
+# Miscellaneous stuff
+#
+driftfile /etc/ntp.drift       # frequency offset
+statsdir /rackety/ntpstats/    # directory for statistics files
+filegen peerstats file peerstats type day enable
+filegen loopstats file loopstats type day enable
+filegen clockstats file clockstats type day enable
+
diff --git a/config.guess b/config.guess
new file mode 100755 (executable)
index 0000000..917bbc5
--- /dev/null
@@ -0,0 +1,1463 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+timestamp='2005-07-08'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+       for c in cc gcc c89 c99 ; do
+         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # NetBSD (nbsd) targets should (where applicable) match one or
+       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       #
+       # Note: NetBSD doesn't particularly care about the vendor
+       # portion of the name.  We always set it to "unknown".
+       sysctl="sysctl -n hw.machine_arch"
+       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+       case "${UNAME_MACHINE_ARCH}" in
+           armeb) machine=armeb-unknown ;;
+           arm*) machine=arm-unknown ;;
+           sh3el) machine=shl-unknown ;;
+           sh3eb) machine=sh-unknown ;;
+           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE_ARCH}" in
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+               eval $set_cc_for_build
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep __ELF__ >/dev/null
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       # Debian GNU/NetBSD machines have a different userland, and
+       # thus, need a distinct triplet. However, they do not need
+       # kernel version information, so it can be replaced with a
+       # suitable tag, in the style of linux-gnu.
+       case "${UNAME_VERSION}" in
+           Debian*)
+               release='-gnu'
+               ;;
+           *)
+               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               ;;
+       esac
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit ;;
+    *:OpenBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       exit ;;
+    *:ekkoBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       exit ;;
+    macppc:MirBSD:*:*)
+       echo powerppc-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    *:MirBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    alpha:OSF1:*:*)
+       case $UNAME_RELEASE in
+       *4.0)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+               ;;
+       *5.*)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+               ;;
+       esac
+       # According to Compaq, /usr/sbin/psrinfo has been available on
+       # OSF/1 and Tru64 systems produced since 1995.  I hope that
+       # covers most systems running today.  This code pipes the CPU
+       # types through head -n 1, so we only detect the type of CPU 0.
+       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+       case "$ALPHA_CPU_TYPE" in
+           "EV4 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "EV4.5 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "LCA4 (21066/21068)")
+               UNAME_MACHINE="alpha" ;;
+           "EV5 (21164)")
+               UNAME_MACHINE="alphaev5" ;;
+           "EV5.6 (21164A)")
+               UNAME_MACHINE="alphaev56" ;;
+           "EV5.6 (21164PC)")
+               UNAME_MACHINE="alphapca56" ;;
+           "EV5.7 (21164PC)")
+               UNAME_MACHINE="alphapca57" ;;
+           "EV6 (21264)")
+               UNAME_MACHINE="alphaev6" ;;
+           "EV6.7 (21264A)")
+               UNAME_MACHINE="alphaev67" ;;
+           "EV6.8CB (21264C)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8AL (21264B)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8CX (21264D)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.9A (21264/EV69A)")
+               UNAME_MACHINE="alphaev69" ;;
+           "EV7 (21364)")
+               UNAME_MACHINE="alphaev7" ;;
+           "EV7.9 (21364A)")
+               UNAME_MACHINE="alphaev79" ;;
+       esac
+       # A Pn.n version is a patched version.
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       exit ;;
+    Alpha\ *:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # Should we change UNAME_MACHINE based on the output of uname instead
+       # of the specific Alpha model?
+       echo alpha-pc-interix
+       exit ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-unknown-sysv4
+       exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-amigaos
+       exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-morphos
+       exit ;;
+    *:OS/390:*:*)
+       echo i370-ibm-openedition
+       exit ;;
+    *:z/VM:*:*)
+       echo s390-ibm-zvmoe
+       exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+       exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+       echo arm-unknown-riscos
+       exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit ;;
+    NILE*:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit ;;
+    DRS?6000:unix:4.0:6*)
+       echo sparc-icl-nx6
+       exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+       case `/usr/bin/uname -p` in
+           sparc) echo sparc-icl-nx7; exit ;;
+       esac ;;
+    sun4H:SunOS:5.*:*)
+       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    i86pc:SunOS:5.*:*)
+       echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit ;;
+    sun*:*:4.2BSD:*)
+       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       case "`/bin/arch`" in
+           sun3)
+               echo m68k-sun-sunos${UNAME_RELEASE}
+               ;;
+           sun4)
+               echo sparc-sun-sunos${UNAME_RELEASE}
+               ;;
+       esac
+       exit ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+       echo m68k-apple-machten${UNAME_RELEASE}
+       exit ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+       echo clipper-intergraph-clix${UNAME_RELEASE}
+       exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c &&
+         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`$dummy $dummyarg` &&
+           { echo "$SYSTEM_NAME"; exit; }
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit ;;
+    Motorola:*:4.3:PL8-*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       then
+           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+           else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+           fi
+       else
+           echo i586-dg-dgux${UNAME_RELEASE}
+       fi
+       exit ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+       echo i386-ibm-aix
+       exit ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               eval $set_cc_for_build
+               sed 's/^                //' << EOF >$dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               then
+                       echo "$SYSTEM_NAME"
+               else
+                       echo rs6000-ibm-aix3.2.5
+               fi
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit ;;
+    *:AIX:*:[45])
+       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit ;;
+    9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/[678][0-9][0-9])
+               if [ -x /usr/bin/getconf ]; then
+                   sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+               fi
+               if [ "${HP_ARCH}" = "" ]; then
+                   eval $set_cc_for_build
+                   sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+               {
+               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+               case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+                   switch (bits)
+                       {
+                       case 64: puts ("hppa2.0w"); break;
+                       case 32: puts ("hppa2.0n"); break;
+                       default: puts ("hppa2.0"); break;
+                       } break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+                   puts ("hppa2.0"); break;
+              #endif
+               default: puts ("hppa1.0"); break;
+               }
+                  exit (0);
+              }
+EOF
+                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+                   test -z "$HP_ARCH" && HP_ARCH=hppa
+               fi ;;
+       esac
+       if [ ${HP_ARCH} = "hppa2.0w" ]
+       then
+           eval $set_cc_for_build
+
+           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+           # generating 64-bit code.  GNU and HP use different nomenclature:
+           #
+           # $ CC_FOR_BUILD=cc ./config.guess
+           # => hppa2.0w-hp-hpux11.23
+           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+           # => hppa64-hp-hpux11.23
+
+           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+               grep __LP64__ >/dev/null
+           then
+               HP_ARCH="hppa2.0w"
+           else
+               HP_ARCH="hppa64"
+           fi
+       fi
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit ;;
+    3050*:HI-UX:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+               { echo "$SYSTEM_NAME"; exit; }
+       echo unknown-hitachi-hiuxwe2
+       exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+       echo hppa1.0-hp-mpeix
+       exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit ;;
+    i*86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+             -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*T3E:*:*:*)
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    *:UNICOS/mp:*:*)
+       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit ;;
+    sparc*:BSD/OS:*:*)
+       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:FreeBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit ;;
+    i*:CYGWIN*:*)
+       echo ${UNAME_MACHINE}-pc-cygwin
+       exit ;;
+    i*:MINGW*:*)
+       echo ${UNAME_MACHINE}-pc-mingw32
+       exit ;;
+    i*:windows32*:*)
+       # uname -m includes "-pc" on this system.
+       echo ${UNAME_MACHINE}-mingw32
+       exit ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit ;;
+    x86:Interix*:[34]*)
+       echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
+       exit ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+       echo i${UNAME_MACHINE}-pc-mks
+       exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+       # UNAME_MACHINE based on the output of uname instead of i386?
+       echo i586-pc-interix
+       exit ;;
+    i*:UWIN*:*)
+       echo ${UNAME_MACHINE}-pc-uwin
+       exit ;;
+    amd64:CYGWIN*:*:*)
+       echo x86_64-unknown-cygwin
+       exit ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin
+       exit ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    *:GNU:*:*)
+       # the GNU system
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit ;;
+    *:GNU/*:*:*)
+       # other systems with GNU libc and userland
+       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+       exit ;;
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit ;;
+    arm*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    cris:Linux:*:*)
+       echo cris-axis-linux-gnu
+       exit ;;
+    crisv32:Linux:*:*)
+       echo crisv32-axis-linux-gnu
+       exit ;;
+    frv:Linux:*:*)
+       echo frv-unknown-linux-gnu
+       exit ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m32r*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    mips:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef mips
+       #undef mipsel
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=mipsel
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=mips
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    mips64:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef mips64
+       #undef mips64el
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=mips64el
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=mips64
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-gnu
+       exit ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-gnu
+       exit ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+       objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-gnu ;;
+         PA8*) echo hppa2.0-unknown-linux-gnu ;;
+         *)    echo hppa-unknown-linux-gnu ;;
+       esac
+       exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit ;;
+    sh64*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    x86_64:Linux:*:*)
+       echo x86_64-unknown-linux-gnu
+       exit ;;
+    i*86:Linux:*:*)
+       # The BFD linker knows what the default object file format is, so
+       # first see if it will tell us. cd to the root directory to prevent
+       # problems with other programs or directories called `ld' in the path.
+       # Set LC_ALL=C to ensure ld outputs messages in English.
+       ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+                        | sed -ne '/supported targets:/!d
+                                   s/[         ][      ]*/ /g
+                                   s/.*supported targets: *//
+                                   s/ .*//
+                                   p'`
+        case "$ld_supported_targets" in
+         elf32-i386)
+               TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+               ;;
+         a.out-i386-linux)
+               echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+               exit ;;
+         coff-i386)
+               echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+               exit ;;
+         "")
+               # Either a pre-BFD a.out linker (linux-gnuoldld) or
+               # one that does not give us useful --help.
+               echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+               exit ;;
+       esac
+       # Determine whether the default compiler is a.out or elf
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <features.h>
+       #ifdef __ELF__
+       # ifdef __GLIBC__
+       #  if __GLIBC__ >= 2
+       LIBC=gnu
+       #  else
+       LIBC=gnulibc1
+       #  endif
+       # else
+       LIBC=gnulibc1
+       # endif
+       #else
+       #ifdef __INTEL_COMPILER
+       LIBC=gnu
+       #else
+       LIBC=gnuaout
+       #endif
+       #endif
+       #ifdef __dietlibc__
+       LIBC=dietlibc
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+       test x"${LIBC}" != x && {
+               echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+               exit
+       }
+       test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+       ;;
+    i*86:DYNIX/ptx:4*:*)
+       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+       # earlier versions are messed up and put the nodename in both
+       # sysname and nodename.
+       echo i386-sequent-sysv4
+       exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+       # I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       exit ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit ;;
+    i*86:XTS-300:*:STOP)
+       echo ${UNAME_MACHINE}-unknown-stop
+       exit ;;
+    i*86:atheos:*:*)
+       echo ${UNAME_MACHINE}-unknown-atheos
+       exit ;;
+    i*86:syllable:*:*)
+       echo ${UNAME_MACHINE}-pc-syllable
+       exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+       fi
+       exit ;;
+    i*86:*:5:[678]*)
+       # UnixWare 7.x, OpenUNIX and OpenServer 6.
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       exit ;;
+    i*86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit ;;
+    pc:*:*:*)
+       # Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i386.
+       echo i386-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+       echo m68k-convergent-sysv
+       exit ;;
+    M680?0:D-NIX:5.3:*)
+       echo m68k-diab-dnix
+       exit ;;
+    M68*:*:R3V[5678]*:*)
+       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    rs6000:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit ;;
+    RM*:ReliantUNIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit ;;
+    i*86:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo ${UNAME_MACHINE}-stratus-vos
+       exit ;;
+    *:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo hppa1.1-stratus-vos
+       exit ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit ;;
+    news*:NEWS-OS:6*:*)
+       echo mips-sony-newsos6
+       exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+        exit ;;
+    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
+       echo powerpc-be-beos
+       exit ;;
+    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
+       echo powerpc-apple-beos
+       exit ;;
+    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
+       echo i586-pc-beos
+       exit ;;
+    SX-4:SUPER-UX:*:*)
+       echo sx4-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-5:SUPER-UX:*:*)
+       echo sx5-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-6:SUPER-UX:*:*)
+       echo sx6-nec-superux${UNAME_RELEASE}
+       exit ;;
+    Power*:Rhapsody:*:*)
+       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Rhapsody:*:*)
+       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Darwin:*:*)
+       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+       case $UNAME_PROCESSOR in
+           *86) UNAME_PROCESSOR=i686 ;;
+           unknown) UNAME_PROCESSOR=powerpc ;;
+       esac
+       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       UNAME_PROCESSOR=`uname -p`
+       if test "$UNAME_PROCESSOR" = "x86"; then
+               UNAME_PROCESSOR=i386
+               UNAME_MACHINE=pc
+       fi
+       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       exit ;;
+    *:QNX:*:4*)
+       echo i386-pc-qnx
+       exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+       echo nse-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
+       exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+       exit ;;
+    *:DragonFly:*:*)
+       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit ;;
+    *:*VMS:*:*)
+       UNAME_MACHINE=`(uname -p) 2>/dev/null`
+       case "${UNAME_MACHINE}" in
+           A*) echo alpha-dec-vms ; exit ;;
+           I*) echo ia64-dec-vms ; exit ;;
+           V*) echo vax-dec-vms ; exit ;;
+       esac ;;
+    *:XENIX:*:SysV)
+       echo i386-pc-xenix
+       exit ;;
+    i*86:skyos:*:*)
+       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+       exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit ;;
+    c34*)
+       echo c34-convex-bsd
+       exit ;;
+    c38*)
+       echo c38-convex-bsd
+       exit ;;
+    c4*)
+       echo c4-convex-bsd
+       exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/config.h.in b/config.h.in
new file mode 100644 (file)
index 0000000..84e57fd
--- /dev/null
@@ -0,0 +1,1369 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* Define if building universal (internal helper macro) */
+#undef AC_APPLE_UNIVERSAL_BUILD
+
+/* Is adjtime() accurate? */
+#undef ADJTIME_IS_ACCURATE
+
+/* CHU audio/decoder? */
+#undef AUDIO_CHU
+
+/* Declare char *sys_errlist array */
+#undef CHAR_SYS_ERRLIST
+
+/* ACTS modem service */
+#undef CLOCK_ACTS
+
+/* Arbiter 1088A/B GPS receiver */
+#undef CLOCK_ARBITER
+
+/* ARCRON support? */
+#undef CLOCK_ARCRON_MSF
+
+/* Austron 2200A/2201A GPS receiver? */
+#undef CLOCK_AS2201
+
+/* PPS interface? */
+#undef CLOCK_ATOM
+
+/* Datum/Bancomm bc635/VME interface? */
+#undef CLOCK_BANC
+
+/* Chronolog K-series WWVB receiver? */
+#undef CLOCK_CHRONOLOG
+
+/* CHU modem/decoder */
+#undef CLOCK_CHU
+
+/* Diems Computime Radio Clock? */
+#undef CLOCK_COMPUTIME
+
+/* Datum Programmable Time System? */
+#undef CLOCK_DATUM
+
+/* ELV/DCF7000 clock? */
+#undef CLOCK_DCF7000
+
+/* Dumb generic hh:mm:ss local clock? */
+#undef CLOCK_DUMBCLOCK
+
+/* Forum Graphic GPS datating station driver? */
+#undef CLOCK_FG
+
+/* TrueTime GPS receiver/VME interface? */
+#undef CLOCK_GPSVME
+
+/* Heath GC-1000 WWV/WWVH receiver? */
+#undef CLOCK_HEATH
+
+/* HOPF 6021 clock? */
+#undef CLOCK_HOPF6021
+
+/* HOPF PCI clock device? */
+#undef CLOCK_HOPF_PCI
+
+/* HOPF serial clock device? */
+#undef CLOCK_HOPF_SERIAL
+
+/* HP 58503A GPS receiver? */
+#undef CLOCK_HPGPS
+
+/* IRIG audio decoder? */
+#undef CLOCK_IRIG
+
+/* JJY receiver? */
+#undef CLOCK_JJY
+
+/* Rockwell Jupiter GPS clock? */
+#undef CLOCK_JUPITER
+
+/* Leitch CSD 5300 Master Clock System Driver? */
+#undef CLOCK_LEITCH
+
+/* local clock reference? */
+#undef CLOCK_LOCAL
+
+/* Meinberg clocks */
+#undef CLOCK_MEINBERG
+
+/* Magnavox MX4200 GPS receiver */
+#undef CLOCK_MX4200
+
+/* NeoClock4X */
+#undef CLOCK_NEOCLOCK4X
+
+/* NMEA GPS receiver */
+#undef CLOCK_NMEA
+
+/* Motorola UT Oncore GPS */
+#undef CLOCK_ONCORE
+
+/* Palisade clock */
+#undef CLOCK_PALISADE
+
+/* PARSE driver interface */
+#undef CLOCK_PARSE
+
+/* Conrad parallel port radio clock */
+#undef CLOCK_PCF
+
+/* PCL 720 clock support */
+#undef CLOCK_PPS720
+
+/* PST/Traconex 1020 WWV/WWVH receiver */
+#undef CLOCK_PST
+
+/* DCF77 raw time code */
+#undef CLOCK_RAWDCF
+
+/* RCC 8000 clock */
+#undef CLOCK_RCC8000
+
+/* RIPE NCC Trimble clock */
+#undef CLOCK_RIPENCC
+
+/* Schmid DCF77 clock */
+#undef CLOCK_SCHMID
+
+/* clock thru shared memory */
+#undef CLOCK_SHM
+
+/* Spectracom 8170/Netclock/2 WWVB receiver */
+#undef CLOCK_SPECTRACOM
+
+/* KSI/Odetics TPRO/S GPS receiver/IRIG interface */
+#undef CLOCK_TPRO
+
+/* Trimble GPS receiver/TAIP protocol */
+#undef CLOCK_TRIMTAIP
+
+/* Trimble GPS receiver/TSIP protocol */
+#undef CLOCK_TRIMTSIP
+
+/* Kinemetrics/TrueTime receivers */
+#undef CLOCK_TRUETIME
+
+/* TrueTime 560 IRIG-B decoder? */
+#undef CLOCK_TT560
+
+/* Ultralink M320 WWVB receiver? */
+#undef CLOCK_ULINK
+
+/* VARITEXT protocol */
+#undef CLOCK_VARITEXT
+
+/* WHARTON 400A Series protocol */
+#undef CLOCK_WHARTON_400A
+
+/* WWV audio driver */
+#undef CLOCK_WWV
+
+/* Zyfer GPStarplus */
+#undef CLOCK_ZYFER
+
+/* Enable debugging? */
+#undef DEBUG
+
+/* Enable processing time debugging? */
+#undef DEBUG_TIMING
+
+/* Declaration style */
+#undef DECL_ADJTIME_0
+
+/* Declaration style */
+#undef DECL_BCOPY_0
+
+/* Declaration style */
+#undef DECL_BZERO_0
+
+/* Declaration style */
+#undef DECL_CFSETISPEED_0
+
+/* Declare errno? */
+#undef DECL_ERRNO
+
+/* Declaration style */
+#undef DECL_HSTRERROR_0
+
+/* Declare h_errno? */
+#undef DECL_H_ERRNO
+
+/* Declaration style */
+#undef DECL_INET_NTOA_0
+
+/* Declaration style */
+#undef DECL_IOCTL_0
+
+/* Declaration style */
+#undef DECL_IPC_0
+
+/* Declaration style */
+#undef DECL_MEMMOVE_0
+
+/* Declaration style */
+#undef DECL_MKSTEMP_0
+
+/* Declaration style */
+#undef DECL_MKTEMP_0
+
+/* Declaration style */
+#undef DECL_NLIST_0
+
+/* Declaration style */
+#undef DECL_PLOCK_0
+
+/* Declaration style */
+#undef DECL_RENAME_0
+
+/* Declaration style */
+#undef DECL_SELECT_0
+
+/* Declaration style */
+#undef DECL_SETITIMER_0
+
+/* Declaration style */
+#undef DECL_SETPRIORITY_0
+
+/* Declaration style */
+#undef DECL_SETPRIORITY_1
+
+/* Declaration style */
+#undef DECL_SIGVEC_0
+
+/* Declaration style */
+#undef DECL_STDIO_0
+
+/* Declaration style */
+#undef DECL_STIME_0
+
+/* Declaration style */
+#undef DECL_STIME_1
+
+/* Declaration style */
+#undef DECL_STRERROR_0
+
+/* Declaration style */
+#undef DECL_STRTOL_0
+
+/* Declare syscall()? */
+#undef DECL_SYSCALL
+
+/* Declaration style */
+#undef DECL_SYSLOG_0
+
+/* Declaration style */
+#undef DECL_TIMEOFDAY_0
+
+/* Declaration style */
+#undef DECL_TIME_0
+
+/* Declaration style */
+#undef DECL_TOLOWER_0
+
+/* Declaration style */
+#undef DECL_TOUPPER_0
+
+/* What is the fallback value for HZ? */
+#undef DEFAULT_HZ
+
+/* synch TODR hourly? */
+#undef DOSYNCTODR
+
+/* The number of minutes in a DST adjustment */
+#undef DSTMINUTES
+
+/* fopen(3) accepts a 'b' in the mode flag */
+#undef FOPEN_BINARY_FLAG
+
+/* fopen(3) accepts a 't' in the mode flag */
+#undef FOPEN_TEXT_FLAG
+
+/* force ntpdate to step the clock if !defined(STEP_SLEW) ? */
+#undef FORCE_NTPDATE_STEP
+
+/* What is getsockname()'s socklen type? */
+#undef GETSOCKNAME_SOCKLEN_TYPE
+
+/* Do we have a routing socket (struct rt_msghdr)? */
+#undef HAS_ROUTING_SOCKET
+
+/* Define to 1 if you have the <arpa/nameser.h> header file. */
+#undef HAVE_ARPA_NAMESER_H
+
+/* Do we have audio support? */
+#undef HAVE_AUDIO
+
+/* Define to 1 if you have the <bstring.h> header file. */
+#undef HAVE_BSTRING_H
+
+/* Define to 1 if you have the `canonicalize_file_name' function. */
+#undef HAVE_CANONICALIZE_FILE_NAME
+
+/* Do we have the CIOGETEV ioctl (SunOS, Linux)? */
+#undef HAVE_CIOGETEV
+
+/* Define to 1 if you have the `clock_gettime' function. */
+#undef HAVE_CLOCK_GETTIME
+
+/* Define to 1 if you have the `clock_settime' function. */
+#undef HAVE_CLOCK_SETTIME
+
+/* Define to 1 if you have the `daemon' function. */
+#undef HAVE_DAEMON
+
+/* Define this if /dev/zero is readable device */
+#undef HAVE_DEV_ZERO
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+   */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Use Rendezvous/DNS-SD registration */
+#undef HAVE_DNSREGISTRATION
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+#undef HAVE_DOPRNT
+
+/* [Can we drop root privileges?] */
+#undef HAVE_DROPROOT
+
+/* Define to 1 if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
+/* Define to 1 if you have the `EVP_md2' function. */
+#undef HAVE_EVP_MD2
+
+/* Define to 1 if you have the `EVP_mdc2' function. */
+#undef HAVE_EVP_MDC2
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the `finite' function. */
+#undef HAVE_FINITE
+
+/* Define to 1 if you have the `getbootfile' function. */
+#undef HAVE_GETBOOTFILE
+
+/* Define to 1 if you have the `getclock' function. */
+#undef HAVE_GETCLOCK
+
+/* Define to 1 if you have the `getdtablesize' function. */
+#undef HAVE_GETDTABLESIZE
+
+/* Define to 1 if you have the `getifaddrs' function. */
+#undef HAVE_GETIFADDRS
+
+/* Define to 1 if you have the `getrusage' function. */
+#undef HAVE_GETRUSAGE
+
+/* Define to 1 if you have the `getuid' function. */
+#undef HAVE_GETUID
+
+/* Define to 1 if you have the `hstrerror' function. */
+#undef HAVE_HSTRERROR
+
+/* Obvious... */
+#undef HAVE_HZ_IN_STRUCT_CLOCKINFO
+
+/* Define to 1 if you have the <ieeefp.h> header file. */
+#undef HAVE_IEEEFP_H
+
+/* have iflist_sysctl? */
+#undef HAVE_IFLIST_SYSCTL
+
+/* inline keyword or macro available */
+#undef HAVE_INLINE
+
+/* Define to 1 if the system has the type `int16_t'. */
+#undef HAVE_INT16_T
+
+/* Define to 1 if the system has the type `int32_t'. */
+#undef HAVE_INT32_T
+
+/* Define to 1 if the system has the type `int8_t'. */
+#undef HAVE_INT8_T
+
+/* Define to 1 if the system has the type `intptr_t'. */
+#undef HAVE_INTPTR_T
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Do we have IPTOS support? */
+#undef HAVE_IPTOS_SUPPORT
+
+/* Define to 1 if you have the `isfinite' function. */
+#undef HAVE_ISFINITE
+
+/* Define to 1 if you have the `kvm_open' function. */
+#undef HAVE_KVM_OPEN
+
+/* Define to 1 if you have the `K_open' function. */
+#undef HAVE_K_OPEN
+
+/* Define to 1 if you have the `advapi32' library (-ladvapi32). */
+#undef HAVE_LIBADVAPI32
+
+/* Do we have the curses library? */
+#undef HAVE_LIBCURSES
+
+/* Do we have the edit library? */
+#undef HAVE_LIBEDIT
+
+/* Define to 1 if you have the `elf' library (-lelf). */
+#undef HAVE_LIBELF
+
+/* Define to 1 if you have the `gen' library (-lgen). */
+#undef HAVE_LIBGEN
+
+/* Define to 1 if you have the <libgen.h> header file. */
+#undef HAVE_LIBGEN_H
+
+/* Define to 1 if you have the `kvm' library (-lkvm). */
+#undef HAVE_LIBKVM
+
+/* Define to 1 if you have the `ld' library (-lld). */
+#undef HAVE_LIBLD
+
+/* Define to 1 if you have the `mld' library (-lmld). */
+#undef HAVE_LIBMLD
+
+/* Define to 1 if you have the `posix4' library (-lposix4). */
+#undef HAVE_LIBPOSIX4
+
+/* Define to 1 if you have the `readline' library (-lreadline). */
+#undef HAVE_LIBREADLINE
+
+/* Define to 1 if you have the `rt' library (-lrt). */
+#undef HAVE_LIBRT
+
+/* Define to 1 if you have the <libscf.h> header file. */
+#undef HAVE_LIBSCF_H
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* [Do we have Linux capabilities?] */
+#undef HAVE_LINUX_CAPABILITIES
+
+/* Define to 1 if you have the <machine/inline.h> header file. */
+#undef HAVE_MACHINE_INLINE_H
+
+/* Define to 1 if you have the <machine/soundcard.h> header file. */
+#undef HAVE_MACHINE_SOUNDCARD_H
+
+/* Define to 1 if you have the <math.h> header file. */
+#undef HAVE_MATH_H
+
+/* Define to 1 if you have the `MD5Init' function. */
+#undef HAVE_MD5INIT
+
+/* Define to 1 if you have the <md5.h> header file. */
+#undef HAVE_MD5_H
+
+/* Define to 1 if you have the `memcpy' function. */
+#undef HAVE_MEMCPY
+
+/* Define to 1 if you have the `memlk' function. */
+#undef HAVE_MEMLK
+
+/* Define to 1 if you have the `memmove' function. */
+#undef HAVE_MEMMOVE
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the `mkstemp' function. */
+#undef HAVE_MKSTEMP
+
+/* Define to 1 if you have the `mktime' function. */
+#undef HAVE_MKTIME
+
+/* Define to 1 if you have the `mlockall' function. */
+#undef HAVE_MLOCKALL
+
+/* Define to 1 if you have the `mmap' function. */
+#undef HAVE_MMAP
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#undef HAVE_NETDB_H
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define to 1 if you have the <netinet/in_system.h> header file. */
+#undef HAVE_NETINET_IN_SYSTEM_H
+
+/* Define to 1 if you have the <netinet/in_systm.h> header file. */
+#undef HAVE_NETINET_IN_SYSTM_H
+
+/* Define to 1 if you have the <netinet/ip.h> header file. */
+#undef HAVE_NETINET_IP_H
+
+/* NetInfo support? */
+#undef HAVE_NETINFO
+
+/* Define to 1 if you have the <netinfo/ni.h> header file. */
+#undef HAVE_NETINFO_NI_H
+
+/* Define to 1 if you have the <net/if6.h> header file. */
+#undef HAVE_NET_IF6_H
+
+/* Define to 1 if you have the <net/if.h> header file. */
+#undef HAVE_NET_IF_H
+
+/* Define to 1 if you have the <net/route.h> header file. */
+#undef HAVE_NET_ROUTE_H
+
+/* Define to 1 if you have the `nice' function. */
+#undef HAVE_NICE
+
+/* Define to 1 if you have the `nlist' function. */
+#undef HAVE_NLIST
+
+/* Define to 1 if you have the `ntp_adjtime' function. */
+#undef HAVE_NTP_ADJTIME
+
+/* Define to 1 if you have the `ntp_gettime' function. */
+#undef HAVE_NTP_GETTIME
+
+/* Do we want support for Samba's signing daemon? */
+#undef HAVE_NTP_SIGND
+
+/* Define this if pathfind(3) works */
+#undef HAVE_PATHFIND
+
+/* Define to 1 if you have the `plock' function. */
+#undef HAVE_PLOCK
+
+/* Define to 1 if you have the <poll.h> header file. */
+#undef HAVE_POLL_H
+
+/* Do we have the PPS API per the Draft RFC? */
+#undef HAVE_PPSAPI
+
+/* Are function prototypes OK? */
+#undef HAVE_PROTOTYPES
+
+/* Define to 1 if you have the `pututline' function. */
+#undef HAVE_PUTUTLINE
+
+/* Define to 1 if you have the `pututxline' function. */
+#undef HAVE_PUTUTXLINE
+
+/* Define to 1 if you have the <readline/history.h> header file. */
+#undef HAVE_READLINE_HISTORY_H
+
+/* Define to 1 if you have the <readline/readline.h> header file. */
+#undef HAVE_READLINE_READLINE_H
+
+/* Define to 1 if you have the `readlink' function. */
+#undef HAVE_READLINK
+
+/* Define this if we have a functional realpath(3C) */
+#undef HAVE_REALPATH
+
+/* Define to 1 if you have the `recvmsg' function. */
+#undef HAVE_RECVMSG
+
+/* Define to 1 if you have the <resolv.h> header file. */
+#undef HAVE_RESOLV_H
+
+/* Define to 1 if you have the `rtprio' function. */
+#undef HAVE_RTPRIO
+
+/* Should be obvious... */
+#undef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+
+/* Obvious... */
+#undef HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION
+
+/* Define to 1 if you have the <sched.h> header file. */
+#undef HAVE_SCHED_H
+
+/* Define to 1 if you have the `sched_setscheduler' function. */
+#undef HAVE_SCHED_SETSCHEDULER
+
+/* Define to 1 if you have the <setjmp.h> header file. */
+#undef HAVE_SETJMP_H
+
+/* Define to 1 if you have the `setlinebuf' function. */
+#undef HAVE_SETLINEBUF
+
+/* Define to 1 if you have the `setpgid' function. */
+#undef HAVE_SETPGID
+
+/* define if setpgrp takes 0 arguments */
+#undef HAVE_SETPGRP_0
+
+/* Define to 1 if you have the `setpriority' function. */
+#undef HAVE_SETPRIORITY
+
+/* Define to 1 if you have the `setrlimit' function. */
+#undef HAVE_SETRLIMIT
+
+/* Define to 1 if you have the `setsid' function. */
+#undef HAVE_SETSID
+
+/* Define to 1 if you have the `settimeofday' function. */
+#undef HAVE_SETTIMEOFDAY
+
+/* Define to 1 if you have the `setvbuf' function. */
+#undef HAVE_SETVBUF
+
+/* Define to 1 if you have the <sgtty.h> header file. */
+#undef HAVE_SGTTY_H
+
+/* Define to 1 if you have the `sigaction' function. */
+#undef HAVE_SIGACTION
+
+/* Can we use SIGIO for tcp and udp IO? */
+#undef HAVE_SIGNALED_IO
+
+/* Define to 1 if you have the `sigset' function. */
+#undef HAVE_SIGSET
+
+/* Define to 1 if you have the `sigsuspend' function. */
+#undef HAVE_SIGSUSPEND
+
+/* Define to 1 if you have the `sigvec' function. */
+#undef HAVE_SIGVEC
+
+/* Define to 1 if you have the `snprintf' function. */
+#undef HAVE_SNPRINTF
+
+/* [Are Solaris privileges available?] */
+#undef HAVE_SOLARIS_PRIVS
+
+/* Does struct sockaddr_storage have ss_family? */
+#undef HAVE_SS_FAMILY_IN_SS
+
+/* Does struct sockaddr_storage have ss_len? */
+#undef HAVE_SS_LEN_IN_SS
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#undef HAVE_STDARG_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `stime' function. */
+#undef HAVE_STIME
+
+/* Define to 1 if you have the `strchr' function. */
+#undef HAVE_STRCHR
+
+/* Define to 1 if you have the `strdup' function. */
+#undef HAVE_STRDUP
+
+/* Define to 1 if you have the `strerror' function. */
+#undef HAVE_STRERROR
+
+/* Define this if strftime() works */
+#undef HAVE_STRFTIME
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strrchr' function. */
+#undef HAVE_STRRCHR
+
+/* Define to 1 if you have the `strstr' function. */
+#undef HAVE_STRSTR
+
+/* Do we have struct ntptimeval? */
+#undef HAVE_STRUCT_NTPTIMEVAL
+
+/* Define to 1 if `time.tv_nsec' is a member of `struct ntptimeval'. */
+#undef HAVE_STRUCT_NTPTIMEVAL_TIME_TV_NSEC
+
+/* Does a system header define struct ppsclockev? */
+#undef HAVE_STRUCT_PPSCLOCKEV
+
+/* Do we have struct snd_size? */
+#undef HAVE_STRUCT_SND_SIZE
+
+/* Does a system header define struct sockaddr_storage? */
+#undef HAVE_STRUCT_SOCKADDR_STORAGE
+
+/* Do we have struct timespec? */
+#undef HAVE_STRUCT_TIMESPEC
+
+/* Define to 1 if you have the <sun/audioio.h> header file. */
+#undef HAVE_SUN_AUDIOIO_H
+
+/* Define to 1 if you have the `sysconf' function. */
+#undef HAVE_SYSCONF
+
+/* Define to 1 if you have the `sysctl' function. */
+#undef HAVE_SYSCTL
+
+/* Define to 1 if you have the <sysexits.h> header file. */
+#undef HAVE_SYSEXITS_H
+
+/* Define to 1 if you have the <sys/audioio.h> header file. */
+#undef HAVE_SYS_AUDIOIO_H
+
+/* Define to 1 if you have the <sys/capability.h> header file. */
+#undef HAVE_SYS_CAPABILITY_H
+
+/* Define to 1 if you have the <sys/clkdefs.h> header file. */
+#undef HAVE_SYS_CLKDEFS_H
+
+/* Define to 1 if you have the <sys/clockctl.h> header file. */
+#undef HAVE_SYS_CLOCKCTL_H
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+   */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/file.h> header file. */
+#undef HAVE_SYS_FILE_H
+
+/* Define to 1 if you have the <sys/i8253.h> header file. */
+#undef HAVE_SYS_I8253_H
+
+/* Define to 1 if you have the <sys/ioctl.h> header file. */
+#undef HAVE_SYS_IOCTL_H
+
+/* Define to 1 if you have the <sys/ipc.h> header file. */
+#undef HAVE_SYS_IPC_H
+
+/* Define to 1 if you have the <sys/limits.h> header file. */
+#undef HAVE_SYS_LIMITS_H
+
+/* Define to 1 if you have the <sys/lock.h> header file. */
+#undef HAVE_SYS_LOCK_H
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#undef HAVE_SYS_MMAN_H
+
+/* Define to 1 if you have the <sys/modem.h> header file. */
+#undef HAVE_SYS_MODEM_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+   */
+#undef HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/pcl720.h> header file. */
+#undef HAVE_SYS_PCL720_H
+
+/* Define to 1 if you have the <sys/poll.h> header file. */
+#undef HAVE_SYS_POLL_H
+
+/* Define to 1 if you have the <sys/ppsclock.h> header file. */
+#undef HAVE_SYS_PPSCLOCK_H
+
+/* Define to 1 if you have the <sys/ppstime.h> header file. */
+#undef HAVE_SYS_PPSTIME_H
+
+/* Define to 1 if you have the <sys/prctl.h> header file. */
+#undef HAVE_SYS_PRCTL_H
+
+/* Define to 1 if you have the <sys/procset.h> header file. */
+#undef HAVE_SYS_PROCSET_H
+
+/* Define to 1 if you have the <sys/proc.h> header file. */
+#undef HAVE_SYS_PROC_H
+
+/* Define to 1 if you have the <sys/resource.h> header file. */
+#undef HAVE_SYS_RESOURCE_H
+
+/* Define to 1 if you have the <sys/sched.h> header file. */
+#undef HAVE_SYS_SCHED_H
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#undef HAVE_SYS_SELECT_H
+
+/* Define to 1 if you have the <sys/shm.h> header file. */
+#undef HAVE_SYS_SHM_H
+
+/* Define to 1 if you have the <sys/signal.h> header file. */
+#undef HAVE_SYS_SIGNAL_H
+
+/* Define to 1 if you have the <sys/sio.h> header file. */
+#undef HAVE_SYS_SIO_H
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#undef HAVE_SYS_SOCKET_H
+
+/* Define to 1 if you have the <sys/sockio.h> header file. */
+#undef HAVE_SYS_SOCKIO_H
+
+/* Define to 1 if you have the <sys/soundcard.h> header file. */
+#undef HAVE_SYS_SOUNDCARD_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/stream.h> header file. */
+#undef HAVE_SYS_STREAM_H
+
+/* Define to 1 if you have the <sys/stropts.h> header file. */
+#undef HAVE_SYS_STROPTS_H
+
+/* Define to 1 if you have the <sys/sysctl.h> header file. */
+#undef HAVE_SYS_SYSCTL_H
+
+/* Define to 1 if you have the <sys/syssgi.h> header file. */
+#undef HAVE_SYS_SYSSGI_H
+
+/* Define to 1 if you have the <sys/systune.h> header file. */
+#undef HAVE_SYS_SYSTUNE_H
+
+/* Define to 1 if you have the <sys/termios.h> header file. */
+#undef HAVE_SYS_TERMIOS_H
+
+/* Define to 1 if you have the <sys/timepps.h> header file. */
+#undef HAVE_SYS_TIMEPPS_H
+
+/* Define to 1 if you have the <sys/timers.h> header file. */
+#undef HAVE_SYS_TIMERS_H
+
+/* Define to 1 if you have the <sys/timex.h> header file. */
+#undef HAVE_SYS_TIMEX_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/tpro.h> header file. */
+#undef HAVE_SYS_TPRO_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Use sys/uio.h for struct iovec help */
+#undef HAVE_SYS_UIO_H
+
+/* Define to 1 if you have the <sys/un.h> header file. */
+#undef HAVE_SYS_UN_H
+
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#undef HAVE_SYS_WAIT_H
+
+/* Define to 1 if the system has the type `s_char'. */
+#undef HAVE_S_CHAR
+
+/* Define to 1 if you have the <termios.h> header file. */
+#undef HAVE_TERMIOS_H
+
+/* Define to 1 if you have the <termio.h> header file. */
+#undef HAVE_TERMIO_H
+
+/* Obvious... */
+#undef HAVE_TICKADJ_IN_STRUCT_CLOCKINFO
+
+/* Define to 1 if you have the `timegm' function. */
+#undef HAVE_TIMEGM
+
+/* Define to 1 if you have the <timepps.h> header file. */
+#undef HAVE_TIMEPPS_H
+
+/* Define to 1 if you have the `timer_create' function. */
+#undef HAVE_TIMER_CREATE
+
+/* Define to 1 if you have the `timer_settime' function. */
+#undef HAVE_TIMER_SETTIME
+
+/* Define to 1 if you have the <timex.h> header file. */
+#undef HAVE_TIMEX_H
+
+/* Do we have the TIOCGPPSEV ioctl (Solaris)? */
+#undef HAVE_TIOCGPPSEV
+
+/* Do we have the TIOCSPPS ioctl (Solaris)? */
+#undef HAVE_TIOCSPPS
+
+/* Do we have the TIO serial stuff? */
+#undef HAVE_TIO_SERIAL_STUFF
+
+/* Does u_int64_t exist? */
+#undef HAVE_TYPE_U_INT64_T
+
+/* Does u_int8_t exist? */
+#undef HAVE_TYPE_U_INT8_T
+
+/* Define to 1 if the system has the type `uint16_t'. */
+#undef HAVE_UINT16_T
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#undef HAVE_UINT32_T
+
+/* Define to 1 if the system has the type `uint8_t'. */
+#undef HAVE_UINT8_T
+
+/* Define to 1 if the system has the type `uintptr_t'. */
+#undef HAVE_UINTPTR_T
+
+/* Define to 1 if the system has the type `uint_t'. */
+#undef HAVE_UINT_T
+
+/* Define to 1 if you have the `umask' function. */
+#undef HAVE_UMASK
+
+/* Define to 1 if you have the `uname' function. */
+#undef HAVE_UNAME
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the `updwtmp' function. */
+#undef HAVE_UPDWTMP
+
+/* Define to 1 if you have the `updwtmpx' function. */
+#undef HAVE_UPDWTMPX
+
+/* Define to 1 if you have the <utime.h> header file. */
+#undef HAVE_UTIME_H
+
+/* Define to 1 if you have the <utmpx.h> header file. */
+#undef HAVE_UTMPX_H
+
+/* Define to 1 if you have the <utmp.h> header file. */
+#undef HAVE_UTMP_H
+
+/* Define to 1 if you have the <values.h> header file. */
+#undef HAVE_VALUES_H
+
+/* Define to 1 if you have the <varargs.h> header file. */
+#undef HAVE_VARARGS_H
+
+/* Define to 1 if you have the `vprintf' function. */
+#undef HAVE_VPRINTF
+
+/* Define to 1 if you have the `vsnprintf' function. */
+#undef HAVE_VSNPRINTF
+
+/* Define to 1 if you have the `vsprintf' function. */
+#undef HAVE_VSPRINTF
+
+/* Define to 1 if you have the </sys/sync/queue.h> header file. */
+#undef HAVE__SYS_SYNC_QUEUE_H
+
+/* Define to 1 if you have the </sys/sync/sema.h> header file. */
+#undef HAVE__SYS_SYNC_SEMA_H
+
+/* Define to 1 if you have the `__adjtimex' function. */
+#undef HAVE___ADJTIMEX
+
+/* Define to 1 if you have the `__ntp_gettime' function. */
+#undef HAVE___NTP_GETTIME
+
+/* Does struct sockaddr_storage have __ss_family? */
+#undef HAVE___SS_FAMILY_IN_SS
+
+/* Does struct sockaddr_storage have __ss_len? */
+#undef HAVE___SS_LEN_IN_SS
+
+/* [Retry queries on _any_ DNS error?] */
+#undef IGNORE_DNS_ERRORS
+
+/* Should we use the IRIG sawtooth filter? */
+#undef IRIG_SUCKS
+
+/* Do we need to fix in6isaddr? */
+#undef ISC_PLATFORM_FIXIN6ISADDR
+
+/* ISC: do we have if_nametoindex()? */
+#undef ISC_PLATFORM_HAVEIFNAMETOINDEX
+
+/* have struct if_laddrconf? */
+#undef ISC_PLATFORM_HAVEIF_LADDRCONF
+
+/* have struct if_laddrreq? */
+#undef ISC_PLATFORM_HAVEIF_LADDRREQ
+
+/* have struct in6_pktinfo? */
+#undef ISC_PLATFORM_HAVEIN6PKTINFO
+
+/* have IPv6? */
+#undef ISC_PLATFORM_HAVEIPV6
+
+/* ISC: struct sockaddr as sa_len? */
+#undef ISC_PLATFORM_HAVESALEN
+
+/* have sin6_scope_id? */
+#undef ISC_PLATFORM_HAVESCOPEID
+
+/* ISC: provide inet_aton() */
+#undef ISC_PLATFORM_NEEDATON
+
+/* missing in6addr_any? */
+#undef ISC_PLATFORM_NEEDIN6ADDRANY
+
+/* Do we need netinet6/in6.h? */
+#undef ISC_PLATFORM_NEEDNETINET6IN6H
+
+/* ISC: provide inet_ntop() */
+#undef ISC_PLATFORM_NEEDNTOP
+
+/* Do we need our own in_port_t? */
+#undef ISC_PLATFORM_NEEDPORTT
+
+/* ISC: provide inet_pton() */
+#undef ISC_PLATFORM_NEEDPTON
+
+/* Does the kernel have an FLL bug? */
+#undef KERNEL_FLL_BUG
+
+/* Does the kernel support precision time discipline? */
+#undef KERNEL_PLL
+
+/* What is (probably) the name of DOSYNCTODR in the kernel? */
+#undef K_DOSYNCTODR_NAME
+
+/* What is (probably) the name of NOPRINTF in the kernel? */
+#undef K_NOPRINTF_NAME
+
+/* What is the name of TICKADJ in the kernel? */
+#undef K_TICKADJ_NAME
+
+/* What is the name of TICK in the kernel? */
+#undef K_TICK_NAME
+
+/* Should we align with the NIST lockclock scheme? */
+#undef LOCKCLOCK
+
+/* Does the kernel support multicasting IP? */
+#undef MCAST
+
+/* Should we recommend a minimum value for tickadj? */
+#undef MIN_REC_TICKADJ
+
+/* Do we need HPUX adjtime() library support? */
+#undef NEED_HPUX_ADJTIME
+
+/* Do we want the HPUX FindConfig()? */
+#undef NEED_HPUX_FINDCONFIG
+
+/* Do we need the qnx adjtime call? */
+#undef NEED_QNX_ADJTIME
+
+/* Do we need extra room for SO_RCVBUF? (HPUX <8) */
+#undef NEED_RCVBUF_SLOP
+
+/* Do we need an s_char typedef? */
+#undef NEED_S_CHAR_TYPEDEF
+
+/* Might nlist() values require an extra level of indirection (AIX)? */
+#undef NLIST_EXTRA_INDIRECTION
+
+/* does struct nlist use a name union? */
+#undef NLIST_NAME_UNION
+
+/* nlist stuff */
+#undef NLIST_STRUCT
+
+/* Should we NOT read /dev/kmem? */
+#undef NOKMEM
+
+/* Define to 1 if your C compiler doesn't accept -c and -o together. */
+#undef NO_MINUS_C_MINUS_O
+
+/* Define this if optional arguments are disallowed */
+#undef NO_OPTIONAL_OPT_ARGS
+
+/* Should we avoid #warning on option name collisions? */
+#undef NO_OPTION_NAME_WARNINGS
+
+/* Is there a problem using PARENB and IGNPAR (IRIX)? */
+#undef NO_PARENB_IGNPAR
+
+/* Default location of crypto key info */
+#undef NTP_KEYSDIR
+
+/* Path to sign daemon rendezvous socket */
+#undef NTP_SIGND_PATH
+
+/* Do we have ntp_{adj,get}time in libc? */
+#undef NTP_SYSCALLS_LIBC
+
+/* Do we have ntp_{adj,get}time in the kernel? */
+#undef NTP_SYSCALLS_STD
+
+/* Do we have support for SHMEM_STATUS? */
+#undef ONCORE_SHMEM_STATUS
+
+/* Use OpenSSL? */
+#undef OPENSSL
+
+/* Should we open the broadcast socket? */
+#undef OPEN_BCAST_SOCKET
+
+/* need to recreate sockets on changed routing? */
+#undef OS_MISSES_SPECIFIC_ROUTE_UPDATES
+
+/* wildcard socket needs to set REUSEADDR when binding to interface addresses
+   */
+#undef OS_NEEDS_REUSEADDR_FOR_IFADDRBIND
+
+/* Do we need to override the system's idea of HZ? */
+#undef OVERRIDE_HZ
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* Do we have the ppsclock streams module? */
+#undef PPS
+
+/* PPS auxiliary interface for ATOM? */
+#undef PPS_SAMPLE
+
+/* PARSE kernel PLL PPS support */
+#undef PPS_SYNC
+
+/* Preset a value for 'tick'? */
+#undef PRESET_TICK
+
+/* Preset a value for 'tickadj'? */
+#undef PRESET_TICKADJ
+
+/* Define to 1 if the C compiler supports function prototypes. */
+#undef PROTOTYPES
+
+/* Does qsort expect to work on "void *" stuff? */
+#undef QSORT_USES_VOID_P
+
+/* Should we not IGNPAR (Linux)? */
+#undef RAWDCF_NO_IGNPAR
+
+/* Basic refclock support? */
+#undef REFCLOCK
+
+/* name of regex header file */
+#undef REGEX_HEADER
+
+/* Do we want the ReliantUNIX clock hacks? */
+#undef RELIANTUNIX_CLOCK
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#undef RETSIGTYPE
+
+/* Do we want the SCO clock hacks? */
+#undef SCO5_CLOCK
+
+/* The size of `char*', as computed by sizeof. */
+#undef SIZEOF_CHARP
+
+/* The size of `int', as computed by sizeof. */
+#undef SIZEOF_INT
+
+/* The size of `long', as computed by sizeof. */
+#undef SIZEOF_LONG
+
+/* The size of `short', as computed by sizeof. */
+#undef SIZEOF_SHORT
+
+/* The size of `signed char', as computed by sizeof. */
+#undef SIZEOF_SIGNED_CHAR
+
+/* The size of `time_t', as computed by sizeof. */
+#undef SIZEOF_TIME_T
+
+/* Does SIOCGIFCONF return size in the buffer? */
+#undef SIZE_RETURNED_IN_BUFFER
+
+/* Slew always? */
+#undef SLEWALWAYS
+
+/* *s*printf() functions are char* */
+#undef SPRINTF_CHAR
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Step, then slew the clock? */
+#undef STEP_SLEW
+
+/* canonical system (cpu-vendor-os) of where we should run */
+#undef STR_SYSTEM
+
+/* Buggy syscall() (Solaris2.4)? */
+#undef SYSCALL_BUG
+
+/* Does Xettimeofday take 1 arg? */
+#undef SYSV_TIMEOFDAY
+
+/* Do we need to #define _SVID3 when we #include <termios.h>? */
+#undef TERMIOS_NEEDS__SVID3
+
+/* Is K_TICKADJ_NAME in nanoseconds? */
+#undef TICKADJ_NANO
+
+/* Is K_TICK_NAME in nanoseconds? */
+#undef TICK_NANO
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
+/* Do we have the tty_clk line discipline/streams module? */
+#undef TTYCLK
+
+/* Provide a typedef for uintptr_t? */
+#ifndef HAVE_UINTPTR_T
+typedef unsigned int   uintptr_t;
+#define HAVE_UINTPTR_T 1
+#endif
+
+/* What type to use for setsockopt */
+#undef TYPEOF_IP_MULTICAST_LOOP
+
+/* Do we set process groups with -pid? */
+#undef UDP_BACKWARDS_SETOWN
+
+/* How do we create unsigned long constants? */
+#undef ULONG_CONST
+
+/* Must we have a CTTY for fsetown? */
+#undef USE_FSETOWNCTTY
+
+/* Enable extensions on AIX 3, Interix.  */
+#ifndef _ALL_SOURCE
+# undef _ALL_SOURCE
+#endif
+/* Enable GNU extensions on systems that have them.  */
+#ifndef _GNU_SOURCE
+# undef _GNU_SOURCE
+#endif
+/* Enable threading extensions on Solaris.  */
+#ifndef _POSIX_PTHREAD_SEMANTICS
+# undef _POSIX_PTHREAD_SEMANTICS
+#endif
+/* Enable extensions on HP NonStop.  */
+#ifndef _TANDEM_SOURCE
+# undef _TANDEM_SOURCE
+#endif
+/* Enable general extensions on Solaris.  */
+#ifndef __EXTENSIONS__
+# undef __EXTENSIONS__
+#endif
+
+
+/* Can we use SIGPOLL for tty IO? */
+#undef USE_TTY_SIGPOLL
+
+/* Can we use SIGPOLL for UDP? */
+#undef USE_UDP_SIGPOLL
+
+/* Version number of package */
+#undef VERSION
+
+/* configure --enable-ipv6 */
+#undef WANT_IPV6
+
+/* Do we want the windows symmetric client hack? */
+#undef WINTIME
+
+/* Define this if a working libregex can be found */
+#undef WITH_LIBREGEX
+
+/* Define WORDS_BIGENDIAN to 1 if your processor stores words with the most
+   significant byte first (like Motorola and SPARC, unlike Intel). */
+#if defined AC_APPLE_UNIVERSAL_BUILD
+# if defined __BIG_ENDIAN__
+#  define WORDS_BIGENDIAN 1
+# endif
+#else
+# ifndef WORDS_BIGENDIAN
+#  undef WORDS_BIGENDIAN
+# endif
+#endif
+
+/* Handle ss_family */
+#if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
+# define ss_family __ss_family
+#endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */
+
+/* Handle ss_len */
+#if !defined(HAVE_SS_LEN_IN_SS) && defined(HAVE___SS_LEN_IN_SS)
+# define ss_len __ss_len
+#endif /* !defined(HAVE_SS_LEN_IN_SS) && defined(HAVE_SA_LEN_IN_SS) */
+
+/* Define to 1 if on MINIX. */
+#undef _MINIX
+
+/* Define to 2 if the system does not provide POSIX.1 features except with
+   this defined. */
+#undef _POSIX_1_SOURCE
+
+/* Define to 1 if you need to in order for `stat' and other things to work. */
+#undef _POSIX_SOURCE
+
+/* Define to 1 if type `char' is unsigned and you are not using gcc.  */
+#ifndef __CHAR_UNSIGNED__
+# undef __CHAR_UNSIGNED__
+#endif
+
+/* Define like PROTOTYPES; this can be used by system headers. */
+#undef __PROTOTYPES
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+#undef gid_t
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to `long int' if <sys/types.h> does not define. */
+#undef off_t
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* Define to `long' if <sys/types.h> does not define. */
+#undef time_t
+
+/* Define to `int' if <sys/types.h> doesn't define. */
+#undef uid_t
+
+/* Alternate uintptr_t for systems without it. */
+#undef uintptr_t
+
+/* Does the compiler like "volatile"? */
+#undef volatile
diff --git a/config.sub b/config.sub
new file mode 100755 (executable)
index 0000000..1c366df
--- /dev/null
@@ -0,0 +1,1579 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+timestamp='2005-07-08'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
+  kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+       -apple | -axis | -knuth | -cray)
+               os=
+               basic_machine=$1
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond)
+               os=
+               basic_machine=$1
+               ;;
+       -scout)
+               ;;
+       -wrs)
+               os=-vxworks
+               basic_machine=$1
+               ;;
+       -chorusos*)
+               os=-chorusos
+               basic_machine=$1
+               ;;
+       -chorusrdb)
+               os=-chorusrdb
+               basic_machine=$1
+               ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco5)
+               os=-sco3.2v5
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -udk*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+       -psos*)
+               os=-psos
+               ;;
+       -mint | -mint[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       1750a | 580 \
+       | a29k \
+       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+       | am33_2.0 \
+       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+       | bfin \
+       | c4x | clipper \
+       | d10v | d30v | dlx | dsp16xx \
+       | fr30 | frv \
+       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+       | i370 | i860 | i960 | ia64 \
+       | ip2k | iq2000 \
+       | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
+       | mips | mipsbe | mipseb | mipsel | mipsle \
+       | mips16 \
+       | mips64 | mips64el \
+       | mips64vr | mips64vrel \
+       | mips64orion | mips64orionel \
+       | mips64vr4100 | mips64vr4100el \
+       | mips64vr4300 | mips64vr4300el \
+       | mips64vr5000 | mips64vr5000el \
+       | mips64vr5900 | mips64vr5900el \
+       | mipsisa32 | mipsisa32el \
+       | mipsisa32r2 | mipsisa32r2el \
+       | mipsisa64 | mipsisa64el \
+       | mipsisa64r2 | mipsisa64r2el \
+       | mipsisa64sb1 | mipsisa64sb1el \
+       | mipsisa64sr71k | mipsisa64sr71kel \
+       | mipstx39 | mipstx39el \
+       | mn10200 | mn10300 \
+       | ms1 \
+       | msp430 \
+       | ns16k | ns32k \
+       | or32 \
+       | pdp10 | pdp11 | pj | pjl \
+       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+       | pyramid \
+       | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+       | sh64 | sh64le \
+       | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
+       | sparcv8 | sparcv9 | sparcv9b \
+       | strongarm \
+       | tahoe | thumb | tic4x | tic80 | tron \
+       | v850 | v850e \
+       | we32k \
+       | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
+       | z8k)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m32c)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m6811 | m68hc11 | m6812 | m68hc12)
+               # Motorola 68HC11/12.
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+               ;;
+
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i*86 | x86_64)
+         basic_machine=$basic_machine-pc
+         ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       580-* \
+       | a29k-* \
+       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+       | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+       | avr-* \
+       | bfin-* | bs2000-* \
+       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+       | clipper-* | craynv-* | cydra-* \
+       | d10v-* | d30v-* | dlx-* \
+       | elxsi-* \
+       | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+       | h8300-* | h8500-* \
+       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+       | i*86-* | i860-* | i960-* | ia64-* \
+       | ip2k-* | iq2000-* \
+       | m32r-* | m32rle-* \
+       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+       | m88110-* | m88k-* | maxq-* | mcore-* \
+       | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+       | mips16-* \
+       | mips64-* | mips64el-* \
+       | mips64vr-* | mips64vrel-* \
+       | mips64orion-* | mips64orionel-* \
+       | mips64vr4100-* | mips64vr4100el-* \
+       | mips64vr4300-* | mips64vr4300el-* \
+       | mips64vr5000-* | mips64vr5000el-* \
+       | mips64vr5900-* | mips64vr5900el-* \
+       | mipsisa32-* | mipsisa32el-* \
+       | mipsisa32r2-* | mipsisa32r2el-* \
+       | mipsisa64-* | mipsisa64el-* \
+       | mipsisa64r2-* | mipsisa64r2el-* \
+       | mipsisa64sb1-* | mipsisa64sb1el-* \
+       | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+       | mipstx39-* | mipstx39el-* \
+       | mmix-* \
+       | ms1-* \
+       | msp430-* \
+       | none-* | np1-* | ns16k-* | ns32k-* \
+       | orion-* \
+       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+       | pyramid-* \
+       | romp-* | rs6000-* \
+       | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+       | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
+       | sparclite-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+       | tahoe-* | thumb-* \
+       | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+       | tron-* \
+       | v850-* | v850e-* | vax-* \
+       | we32k-* \
+       | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
+       | xstormy16-* | xtensa-* \
+       | ymp-* \
+       | z8k-*)
+               ;;
+       m32c-*)
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       abacus)
+               basic_machine=abacus-unknown
+               ;;
+       adobe68k)
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amd64)
+               basic_machine=x86_64-pc
+               ;;
+       amd64-*)
+               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-unknown
+               ;;
+       amigaos | amigados)
+               basic_machine=m68k-unknown
+               os=-amigaos
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-unknown
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       aux)
+               basic_machine=m68k-apple
+               os=-aux
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       c90)
+               basic_machine=c90-cray
+               os=-unicos
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | j90)
+               basic_machine=j90-cray
+               os=-unicos
+               ;;
+       craynv)
+               basic_machine=craynv-cray
+               os=-unicosmp
+               ;;
+       cr16c)
+               basic_machine=cr16c-unknown
+               os=-elf
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       crisv32 | crisv32-* | etraxfs*)
+               basic_machine=crisv32-axis
+               ;;
+       cris | cris-* | etrax*)
+               basic_machine=cris-axis
+               ;;
+       crx)
+               basic_machine=crx-unknown
+               os=-elf
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       decsystem10* | dec10*)
+               basic_machine=pdp10-dec
+               os=-tops10
+               ;;
+       decsystem20* | dec20*)
+               basic_machine=pdp10-dec
+               os=-tops20
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       djgpp)
+               basic_machine=i586-pc
+               os=-msdosdjgpp
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+       go32)
+               basic_machine=i386-pc
+               os=-go32
+               ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+       hp3k9[0-9][0-9] | hp9[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k6[0-9][0-9] | hp6[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k7[0-79][0-9] | hp7[0-79][0-9])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k78[0-9] | hp78[0-9])
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][13679] | hp8[0-9][13679])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppa-next)
+               os=-nextstep3
+               ;;
+       hppaosf)
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       hppro)
+               basic_machine=hppa1.1-hp
+               os=-proelf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               ;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+       i*86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv32
+               ;;
+       i*86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv4
+               ;;
+       i*86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv
+               ;;
+       i*86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-solaris2
+               ;;
+       i386mach)
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+       mingw32)
+               basic_machine=i386-pc
+               os=-mingw32
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       monitor)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       morphos)
+               basic_machine=powerpc-unknown
+               os=-morphos
+               ;;
+       msdos)
+               basic_machine=i386-pc
+               os=-msdos
+               ;;
+       mvs)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown
+               os=-netbsd
+               ;;
+       netwinder)
+               basic_machine=armv4l-rebel
+               os=-linux
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       mon960)
+               basic_machine=i960-intel
+               os=-mon960
+               ;;
+       nonstopux)
+               basic_machine=mips-compaq
+               os=-nonstopux
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       nsr-tandem)
+               basic_machine=nsr-tandem
+               ;;
+       op50n-* | op60c-*)
+               basic_machine=hppa1.1-oki
+               os=-proelf
+               ;;
+       openrisc | openrisc-*)
+               basic_machine=or32-unknown
+               ;;
+       os400)
+               basic_machine=powerpc-ibm
+               os=-os400
+               ;;
+       OSE68000 | ose68000)
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+       pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pentium | p5 | k5 | k6 | nexgen | viac3)
+               basic_machine=i586-pc
+               ;;
+       pentiumpro | p6 | 6x86 | athlon | athlon_*)
+               basic_machine=i686-pc
+               ;;
+       pentiumii | pentium2 | pentiumiii | pentium3)
+               basic_machine=i686-pc
+               ;;
+       pentium4)
+               basic_machine=i786-pc
+               ;;
+       pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-* | 6x86-* | athlon-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium4-*)
+               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=power-ibm
+               ;;
+       ppc)    basic_machine=powerpc-unknown
+               ;;
+       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64)  basic_machine=powerpc64-unknown
+               ;;
+       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+               basic_machine=powerpc64le-unknown
+               ;;
+       ppc64le-* | powerpc64little-*)
+               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       pw32)
+               basic_machine=i586-unknown
+               os=-pw32
+               ;;
+       rom68k)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       s390 | s390-*)
+               basic_machine=s390-ibm
+               ;;
+       s390x | s390x-*)
+               basic_machine=s390x-ibm
+               ;;
+       sa29200)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sb1)
+               basic_machine=mipsisa64sb1-unknown
+               ;;
+       sb1el)
+               basic_machine=mipsisa64sb1el-unknown
+               ;;
+       sei)
+               basic_machine=mips-sei
+               os=-seiux
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sh64)
+               basic_machine=sh64-unknown
+               ;;
+       sparclite-wrs | simso-wrs)
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)
+               basic_machine=m68k-tandem
+               ;;
+       stratus)
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       sv1)
+               basic_machine=sv1-cray
+               os=-unicos
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       t3e)
+               basic_machine=alphaev5-cray
+               os=-unicos
+               ;;
+       t90)
+               basic_machine=t90-cray
+               os=-unicos
+               ;;
+       tic54x | c54x*)
+               basic_machine=tic54x-unknown
+               os=-coff
+               ;;
+       tic55x | c55x*)
+               basic_machine=tic55x-unknown
+               os=-coff
+               ;;
+       tic6x | c6x*)
+               basic_machine=tic6x-unknown
+               os=-coff
+               ;;
+       tx39)
+               basic_machine=mipstx39-unknown
+               ;;
+       tx39el)
+               basic_machine=mipstx39el-unknown
+               ;;
+       toad1)
+               basic_machine=pdp10-xkl
+               os=-tops20
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       tpf)
+               basic_machine=s390x-ibm
+               os=-tpf
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+       vxworks29k)
+               basic_machine=a29k-wrs
+               os=-vxworks
+               ;;
+       w65*)
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       w89k-*)
+               basic_machine=hppa1.1-winbond
+               os=-proelf
+               ;;
+       xbox)
+               basic_machine=i686-pc
+               os=-mingw32
+               ;;
+       xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       z8k-*-coff)
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)
+               basic_machine=hppa1.1-oki
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       mmix)
+               basic_machine=mmix-knuth
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp10)
+               # there are many clones, so DEC is not a safe bet
+               basic_machine=pdp10-unknown
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+               basic_machine=sh-unknown
+               ;;
+       sparc | sparcv8 | sparcv9 | sparcv9b)
+               basic_machine=sparc-sun
+               ;;
+       cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)
+               basic_machine=powerpc-apple
+               ;;
+       *-unknown)
+               # Make sure to match an already-canonicalized machine name.
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -svr4*)
+               os=-sysv4
+               ;;
+       -unixware*)
+               os=-sysv4.2uw
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative MUST END IN A *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+             | -aos* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
+             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+             | -chorusos* | -chorusrdb* \
+             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+             | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+             | -skyos* | -haiku*)
+       # Remember, each alternative MUST END IN *, to match a version number.
+               ;;
+       -qnx*)
+               case $basic_machine in
+                   x86-* | i*86-*)
+                       ;;
+                   *)
+                       os=-nto$os
+                       ;;
+               esac
+               ;;
+       -nto-qnx*)
+               ;;
+       -nto*)
+               os=`echo $os | sed -e 's|nto|nto-qnx|'`
+               ;;
+       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+               ;;
+       -mac*)
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       -linux-dietlibc)
+               os=-linux-dietlibc
+               ;;
+       -linux*)
+               os=`echo $os | sed -e 's|linux|linux-gnu|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -opened*)
+               os=-openedition
+               ;;
+        -os400*)
+               os=-os400
+               ;;
+       -wince*)
+               os=-wince
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -atheos*)
+               os=-atheos
+               ;;
+       -syllable*)
+               os=-syllable
+               ;;
+       -386bsd)
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       -nova*)
+               os=-rtmk-nova
+               ;;
+       -ns2 )
+               os=-nextstep2
+               ;;
+       -nsk*)
+               os=-nsk
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+        -tpf*)
+               os=-tpf
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)
+               os=-ose
+               ;;
+       -es1800*)
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+               os=-mint
+               ;;
+       -aros*)
+               os=-aros
+               ;;
+       -kaos*)
+               os=-kaos
+               ;;
+       -zvmoe)
+               os=-zvmoe
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+       *-acorn)
+               os=-riscix1.2
+               ;;
+       arm*-rebel)
+               os=-linux
+               ;;
+       arm*-semi)
+               os=-aout
+               ;;
+    c4x-* | tic4x-*)
+        os=-coff
+        ;;
+       # This must come before the *-dec entry.
+       pdp10-*)
+               os=-tops20
+               ;;
+       pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               # This also exists in the configure program, but was not the
+               # default.
+               # os=-sunos4
+               ;;
+       m68*-cisco)
+               os=-aout
+               ;;
+       mips*-cisco)
+               os=-elf
+               ;;
+       mips*-*)
+               os=-elf
+               ;;
+       or32-*)
+               os=-coff
+               ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-be)
+               os=-beos
+               ;;
+       *-haiku)
+               os=-haiku
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-knuth)
+               os=-mmixware
+               ;;
+       *-wec)
+               os=-proelf
+               ;;
+       *-winbond)
+               os=-proelf
+               ;;
+       *-oki)
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigaos
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-next )
+               os=-nextstep
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+       *-gould)
+               os=-sysv
+               ;;
+       *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+       *-sgi)
+               os=-irix
+               ;;
+       *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       f30[01]-fujitsu | f700-fujitsu)
+               os=-uxpv
+               ;;
+       *-rom68k)
+               os=-coff
+               ;;
+       *-*bug)
+               os=-coff
+               ;;
+       *-apple)
+               os=-macos
+               ;;
+       *-atari*)
+               os=-mint
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -aix*)
+                               vendor=ibm
+                               ;;
+                       -beos*)
+                               vendor=be
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -mpeix*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs* | -opened*)
+                               vendor=ibm
+                               ;;
+                       -os400*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -tpf*)
+                               vendor=ibm
+                               ;;
+                       -vxsim* | -vxworks* | -windiss*)
+                               vendor=wrs
+                               ;;
+                       -aux*)
+                               vendor=apple
+                               ;;
+                       -hms*)
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)
+                               vendor=apple
+                               ;;
+                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+                               vendor=atari
+                               ;;
+                       -vos*)
+                               vendor=stratus
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/configure b/configure
new file mode 100755 (executable)
index 0000000..fa7716d
--- /dev/null
+++ b/configure
@@ -0,0 +1,27398 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.65 for ntp 4.2.4p8.
+#
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+        /*)
+          for as_base in sh bash ksh sh5; do
+            # Try only shells that exist, to save several forks.
+            as_shell=$as_dir/$as_base
+            if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+                   { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+                  if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+          done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+             { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  # We cannot yet assume a decent shell, so we have to provide a
+       # neutralization value for shells without unset; and this also
+       # works around shells that cannot unset nonexistent variables.
+       BASH_ENV=/dev/null
+       ENV=/dev/null
+       (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+       export CONFIG_SHELL
+       exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+  fi
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with status $?, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in #(
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','`
+  ;;
+esac
+
+echo=${ECHO-echo}
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$ECHO"; then
+if test "X${echo_test_string+set}" != Xset; then
+# find a string as large as possible, as long as the shell can cope with it
+  for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+       echo_test_string=`eval $cmd` &&
+       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+    then
+      break
+    fi
+  done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+   echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+   test "X$echo_testing_string" = "X$echo_test_string"; then
+  :
+else
+  # The Solaris, AIX, and Digital Unix default echo programs unquote
+  # backslashes.  This makes it impossible to quote backslashes using
+  #   echo "$something" | sed 's/\\/\\\\/g'
+  #
+  # So, first we look for a working echo in the user's PATH.
+
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for dir in $PATH /usr/ucb; do
+    IFS="$lt_save_ifs"
+    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      echo="$dir/echo"
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  if test "X$echo" = Xecho; then
+    # We didn't find a better echo, so look for alternatives.
+    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      # This shell has a builtin print -r that does the trick.
+      echo='print -r'
+    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+        test "X$CONFIG_SHELL" != X/bin/ksh; then
+      # If we have ksh, try running configure again with it.
+      ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+      export ORIGINAL_CONFIG_SHELL
+      CONFIG_SHELL=/bin/ksh
+      export CONFIG_SHELL
+      exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
+    else
+      # Try using printf.
+      echo='printf %s\n'
+      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+        echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+        test "X$echo_testing_string" = "X$echo_test_string"; then
+       # Cool, printf works
+       :
+      elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+          test "X$echo_testing_string" = 'X\t' &&
+          echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+          test "X$echo_testing_string" = "X$echo_test_string"; then
+       CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+       export CONFIG_SHELL
+       SHELL="$CONFIG_SHELL"
+       export SHELL
+       echo="$CONFIG_SHELL $0 --fallback-echo"
+      elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+          test "X$echo_testing_string" = 'X\t' &&
+          echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+          test "X$echo_testing_string" = "X$echo_test_string"; then
+       echo="$CONFIG_SHELL $0 --fallback-echo"
+      else
+       # maybe with a smaller string...
+       prev=:
+
+       for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+         if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+         then
+           break
+         fi
+         prev="$cmd"
+       done
+
+       if test "$prev" != 'sed 50q "$0"'; then
+         echo_test_string=`eval $prev`
+         export echo_test_string
+         exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
+       else
+         # Oops.  We lost completely, so just stick with echo.
+         echo=echo
+       fi
+      fi
+    fi
+  fi
+fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+ECHO=$echo
+if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+   ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
+fi
+
+
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME='ntp'
+PACKAGE_TARNAME='ntp'
+PACKAGE_VERSION='4.2.4p8'
+PACKAGE_STRING='ntp 4.2.4p8'
+PACKAGE_BUGREPORT=''
+PACKAGE_URL=''
+
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+enable_option_checking=no
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+LSCF
+MAKE_NTPDSIM
+MAKE_LIBNTPSIM
+MAKE_TIMETRIM
+MAKE_TICKADJ
+MAKE_NTPTIME
+MAKE_ADJTIMED
+CLKTEST
+CHUTEST
+PROPDELAY
+MAKE_PARSEKMODULE
+DCFD
+TESTDCF
+MAKE_CHECK_LAYOUT
+EF_LIBS
+EF_PROGS
+LCRYPTO
+OPENSSL_LIB
+OPENSSL_INC
+OPENSSL
+MAKE_CHECK_Y2K
+MAKE_LIBPARSE_KERNEL
+MAKE_LIBPARSE
+LIBPARSE
+HAVE_INLINE
+ANSI2KNR
+U
+READLINE_LIBS
+PATH_PERL
+PATH_SH
+LIBTOOL
+RANLIB
+AR
+ECHO
+LN_S
+ARLIB_DIR
+subdirs
+BINSUBDIR
+LIBOPTS_CFLAGS
+LIBOPTS_LDADD
+NEED_LIBOPTS_FALSE
+NEED_LIBOPTS_TRUE
+INSTALL_LIBOPTS_FALSE
+INSTALL_LIBOPTS_TRUE
+LIBOPTS_DIR
+EGREP
+GREP
+CPP
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_dependency_tracking
+enable_shared
+enable_local_libopts
+enable_libopts_install
+with_autoopts_config
+with_regex_header
+with_libregex
+with_libregex_cflags
+with_libregex_libs
+enable_optional_args
+with_binsubdir
+with_arlib
+with_rpath
+enable_static
+enable_fast_install
+with_gnu_ld
+enable_libtool_lock
+with_pic
+with_tags
+enable_getifaddrs
+enable_debugging
+enable_debug_timing
+enable_dst_minutes
+enable_ignore_dns_errors
+enable_BANCOMM
+enable_GPSVME
+enable_all_clocks
+enable_ACTS
+enable_ARBITER
+enable_ARCRON_MSF
+enable_AS2201
+enable_ATOM
+enable_CHRONOLOG
+enable_CHU
+enable_AUDIO_CHU
+enable_DATUM
+enable_DUMBCLOCK
+enable_FG
+enable_HEATH
+enable_HOPFSERIAL
+enable_HOPFPCI
+enable_HPGPS
+enable_IRIG
+enable_JJY
+enable_JUPITER
+enable_LEITCH
+enable_LOCAL_CLOCK
+enable_MX4200
+enable_NEOCLOCK4X
+enable_NMEA
+enable_ONCORE
+enable_PALISADE
+enable_PCF
+enable_PST
+enable_RIPENCC
+enable_SHM
+enable_SPECTRACOM
+enable_TPRO
+enable_TRUETIME
+enable_TT560
+enable_ULINK
+enable_WWV
+enable_ZYFER
+enable_parse_clocks
+enable_COMPUTIME
+enable_DCF7000
+enable_HOPF6021
+enable_MEINBERG
+enable_RAWDCF
+enable_RCC8000
+enable_SCHMID
+enable_TRIMTAIP
+enable_TRIMTSIP
+enable_WHARTON
+enable_VARITEXT
+with_openssl_libdir
+with_openssl_incdir
+with_crypto
+with_electricfence
+enable_kmem
+enable_accurate_adjtime
+enable_tick
+enable_tickadj
+enable_simulator
+enable_slew_always
+enable_step_slew
+enable_ntpdate_step
+enable_hourly_todr_sync
+enable_kernel_fll_bug
+enable_irig_sawtooth
+enable_nist
+enable_ntp_signd
+enable_wintime
+enable_clockctl
+enable_linuxcaps
+enable_ipv6
+with_kame
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP'
+ac_subdirs_all='arlib
+sntp'
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE_TARNAME}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)   ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) as_fn_error "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information."
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  as_fn_error "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
+               datadir sysconfdir sharedstatedir localstatedir includedir \
+               oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+               libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_myself" : 'X\(//\)[^/]' \| \
+        X"$as_myself" : 'X\(//\)$' \| \
+        X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+       cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
+       pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures ntp 4.2.4p8 to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/ntp]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+  case $ac_init_help in
+     short | recursive ) echo "Configuration of ntp 4.2.4p8:";;
+   esac
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors
+  --enable-shared[=PKGS]  build shared libraries [default=no]
+  --enable-local-libopts  Force using the supplied libopts tearoff code
+  --disable-libopts-install
+                          Do not install libopts with client installation
+  --disable-optional-args not wanting optional option args
+  --enable-static[=PKGS]  build static libraries [default=yes]
+  --enable-fast-install[=PKGS]
+                          optimize for fast installation [default=yes]
+  --disable-libtool-lock  avoid locking (might break parallel builds)
+  --enable-getifaddrs     s Enable the use of getifaddrs() [[yes|no|glibc]].
+                          glibc: Use getifaddrs() in glibc if you know it
+                          supports IPv6.
+  --enable-debugging      + include debugging code
+  --enable-debug-timing   - include processing time debugging code (costs
+                          performance)
+  --enable-dst-minutes    n minutes per DST adjustment [60]
+  --enable-ignore-dns-errors
+                          - retry DNS queries on any error
+  --enable-BANCOMM        - Datum/Bancomm bc635/VME interface
+  --enable-GPSVME         - TrueTime GPS receiver/VME interface
+  --enable-all-clocks     + include all suitable non-PARSE clocks:
+  --enable-ACTS           s ACTS modem service
+  --enable-ARBITER        + Arbiter 1088A/B GPS receiver
+  --enable-ARCRON-MSF     + Arcron MSF receiver
+  --enable-AS2201         + Austron 2200A/2201A GPS receiver
+  --enable-ATOM           s ATOM PPS interface
+  --enable-CHRONOLOG      + Chrono-log K-series WWVB receiver
+  --enable-CHU            + CHU modem/decoder
+  --enable-AUDIO-CHU      s CHU audio/decoder
+  --enable-DATUM          s Datum Programmable Time System
+  --enable-DUMBCLOCK      + Dumb generic hh:mm:ss local clock
+  --enable-FG             + Forum Graphic GPS
+  --enable-HEATH          s Heath GC-1000 WWV/WWVH receiver
+  --enable-HOPFSERIAL     + hopf serial clock device
+  --enable-HOPFPCI        + hopf 6039 PCI board
+  --enable-HPGPS          + HP 58503A GPS receiver
+  --enable-IRIG           s IRIG audio decoder
+  --enable-JJY            + JJY receiver
+  --enable-JUPITER        s Rockwell Jupiter GPS receiver
+  --enable-LEITCH         + Leitch CSD 5300 Master Clock System Driver
+  --enable-LOCAL-CLOCK    + local clock reference
+  --enable-MX4200         s Magnavox MX4200 GPS receiver
+  --enable-NEOCLOCK4X     + NeoClock4X DCF77 / TDF receiver
+  --enable-NMEA           + NMEA GPS receiver
+  --enable-ONCORE         s Motorola VP/UT Oncore GPS receiver
+  --enable-PALISADE       s Palisade clock
+  --enable-PCF            + Conrad parallel port radio clock
+  --enable-PST            + PST/Traconex 1020 WWV/WWVH receiver
+  --enable-RIPENCC        - RIPENCC specific Trimble driver
+  --enable-SHM            s SHM clock attached thru shared memory
+  --enable-SPECTRACOM     + Spectracom 8170/Netclock/2 WWVB receiver
+  --enable-TPRO           s KSI/Odetics TPRO/S GPS receiver/IRIG interface
+  --enable-TRUETIME       s Kinemetrics/TrueTime receivers
+  --enable-TT560          - TrueTime 560 IRIG-B decoder
+  --enable-ULINK          + Ultralink WWVB receiver
+  --enable-WWV            s WWV Audio receiver
+  --enable-ZYFER          + Zyfer GPStarplus receiver
+  --enable-parse-clocks   - include all suitable PARSE clocks:
+  --enable-COMPUTIME      s Diem Computime Radio Clock
+  --enable-DCF7000        s ELV/DCF7000 clock
+  --enable-HOPF6021       s HOPF 6021 clock
+  --enable-MEINBERG       s Meinberg clocks
+  --enable-RAWDCF         s DCF77 raw time code
+  --enable-RCC8000        s RCC 8000 clock
+  --enable-SCHMID         s Schmid DCF77 clock
+  --enable-TRIMTAIP       s Trimble GPS receiver/TAIP protocol
+  --enable-TRIMTSIP       s Trimble GPS receiver/TSIP protocol
+  --enable-WHARTON        s WHARTON 400A Series clock
+  --enable-VARITEXT       s VARITEXT clock
+  --enable-kmem           s read /dev/kmem for tick and/or tickadj
+  --enable-accurate-adjtime
+                          s the adjtime() call is accurate
+  --enable-tick=VALUE     s force a value for 'tick'
+  --enable-tickadj=VALUE  s force a value for 'tickadj'
+  --enable-simulator      - build/install the NTPD simulator?
+  --enable-slew-always    s always slew the time
+  --enable-step-slew      s step and slew the time
+  --enable-ntpdate-step   s if ntpdate should step the time
+  --enable-hourly-todr-sync
+                          s if we should sync TODR hourly
+  --enable-kernel-fll-bug s if we should avoid a kernel FLL bug
+  --enable-irig-sawtooth  s if we should enable the IRIG sawtooth filter
+  --enable-nist           - if we should enable the NIST lockclock scheme
+  --enable-ntp-signd      - Provide support for Samba's signing daemon,
+                          =/var/run/ntp_signd
+  --enable-wintime        - Provide the windows symmetric client hack
+  --enable-clockctl       s Use /dev/clockctl for non-root clock control
+  --enable-linuxcaps      + Use Linux capabilities for non-root clock control
+  --enable-ipv6           s use IPv6?
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-autoopts-config  specify the config-info script
+  --with-regex-header     a reg expr header is specified
+  --with-libregex         libregex installation prefix
+  --with-libregex-cflags  libregex compile flags
+  --with-libregex-libs    libregex link command arguments
+  --with-binsubdir        bin ={bin,sbin}
+  --with-arlib            - Compile the async resolver library?
+  --without-rpath         s Disable auto-added -R linker paths
+  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-pic              try to use only PIC/non-PIC objects [default=use
+                          both]
+  --with-tags[=TAGS]      include additional configurations [automatic]
+  --with-openssl-libdir   + =/something/reasonable
+  --with-openssl-incdir   + =/something/reasonable
+  --with-crypto           + =openssl
+  --with-electricfence    - compile with ElectricFence malloc debugger
+  --with-kame             - =/usr/local/v6
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to the package provider.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+ntp configure 4.2.4p8
+generated by GNU Autoconf 2.65
+
+Copyright (C) 2009 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+        test "$cross_compiling" = yes ||
+        $as_test_x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+        return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+           return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_type
+
+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
+# --------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_c_compute_int ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if test "$cross_compiling" = yes; then
+    # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid; break
+else
+  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+                       if test $ac_lo -le $ac_mid; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=$ac_mid; break
+else
+  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+                       if test $ac_mid -le $ac_hi; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid
+else
+  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+  else
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    return 1;
+  if (($2) < 0)
+    {
+      long int i = longval ();
+      if (i != ($2))
+       return 1;
+      fprintf (f, "%ld", i);
+    }
+  else
+    {
+      unsigned long int i = ulongval ();
+      if (i != ($2))
+       return 1;
+      fprintf (f, "%lu", i);
+    }
+  /* Do not output a trailing newline, as this causes \r\n confusion
+     on some platforms.  */
+  return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+  ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+  fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_compute_int
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_func
+
+# ac_fn_c_check_member LINENO AGGR MEMBER VAR INCLUDES
+# ----------------------------------------------------
+# Tries to find if the field MEMBER exists in type AGGR, after including
+# INCLUDES, setting cache variable VAR accordingly.
+ac_fn_c_check_member ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2.$3" >&5
+$as_echo_n "checking for $2.$3... " >&6; }
+if { as_var=$4; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$5
+int
+main ()
+{
+static $2 ac_aggr;
+if (ac_aggr.$3)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$4=yes"
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$5
+int
+main ()
+{
+static $2 ac_aggr;
+if (sizeof ac_aggr.$3)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$4=yes"
+else
+  eval "$4=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$4
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_member
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by ntp $as_me 4.2.4p8, which was
+generated by GNU Autoconf 2.65.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    $as_echo "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append ac_configure_args1 " '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+       ac_must_keep_next=false # Got value, back to normal.
+      else
+       case $ac_arg in
+         *=* | --config-cache | -C | -disable-* | --disable-* \
+         | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+         | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+         | -with-* | --with-* | -without-* | --without-* | --x)
+           case "$ac_configure_args0 " in
+             "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+           esac
+           ;;
+         -* ) ac_must_keep_next=true ;;
+       esac
+      fi
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+       "s/'\''/'\''\\\\'\'''\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+       eval ac_val=\$$ac_var
+       case $ac_val in
+       *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+       esac
+       $as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  ac_site_file1=$CONFIG_SITE
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+       # differences in whitespace do not lead to failure.
+       ac_old_val_w=`echo x $ac_old_val`
+       ac_new_val_w=`echo x $ac_new_val`
+       if test "$ac_old_val_w" != "$ac_new_val_w"; then
+         { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+         ac_cache_corrupted=:
+       else
+         { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+         eval $ac_var=\$ac_old_val
+       fi
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+am__api_version='1.11'
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+  for ac_t in install-sh install.sh shtool; do
+    if test -f "$ac_dir/$ac_t"; then
+      ac_aux_dir=$ac_dir
+      ac_install_sh="$ac_aux_dir/$ac_t -c"
+      break 2
+    fi
+  done
+done
+if test -z "$ac_aux_dir"; then
+  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+  ./ | .// | /[cC]/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+         if test $ac_prog = install &&
+           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         elif test $ac_prog = install &&
+           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
+         else
+           rm -rf conftest.one conftest.two conftest.dir
+           echo one > conftest.one
+           echo two > conftest.two
+           mkdir conftest.dir
+           if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+             test -s conftest.one && test -s conftest.two &&
+             test -s conftest.dir/conftest.one &&
+             test -s conftest.dir/conftest.two
+           then
+             ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+             break 3
+           fi
+         fi
+       fi
+      done
+    done
+    ;;
+esac
+
+  done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[\\\"\#\$\&\'\`$am_lf]*)
+    as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \    ]*)
+    as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$*" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$*" != "X $srcdir/configure conftest.file" \
+      && test "$*" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      as_fn_error "ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" "$LINENO" 5
+   fi
+
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   as_fn_error "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+test "$program_prefix" != NONE &&
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in mkdir gmkdir; do
+        for ac_exec_ext in '' $ac_executable_extensions; do
+          { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+          case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+            'mkdir (GNU coreutils) '* | \
+            'mkdir (coreutils) '* | \
+            'mkdir (fileutils) '4.1*)
+              ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+              break 3;;
+          esac
+        done
+       done
+  done
+IFS=$as_save_IFS
+
+fi
+
+  test -d ./--version && rmdir ./--version
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+  [\\/$]* | ?:[\\/]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+       @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE='ntp'
+ VERSION='4.2.4p8'
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
+
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if test "${ac_cv_build+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if test "${ac_cv_host+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define STR_SYSTEM "$host"
+_ACEOF
+
+ac_config_headers="$ac_config_headers config.h"
+
+
+
+ac_cv_var_atom_ok=no
+ac_cv_var_oncore_ok=no
+ac_cv_var_parse_ok=no
+ac_cv_var_ripe_ncc_ok=no
+ac_cv_var_jupiter_ok=no
+
+iCFLAGS="$CFLAGS"
+
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "no acceptable C compiler found in \$PATH
+See \`config.log' for more details." "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+       ;;
+    [ab].out )
+       # We found the default executable, but exeext='' is most
+       # certainly right.
+       break;;
+    *.* )
+       if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+       then :; else
+          ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+       fi
+       # We set ac_cv_exeext here because the later test for it is not
+       # safe: cross compilers may not add the suffix if given an `-o'
+       # argument, so we may need to know it at that point already.
+       # Even if this section looks crufty: it has the advantage of
+       # actually working.
+       break;;
+    * )
+       break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "C compiler cannot create executables
+See \`config.log' for more details." "$LINENO" 5; }; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+         break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+       cross_compiling=yes
+    else
+       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if test "${ac_cv_objext+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+        CFLAGS="-g"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                 inttypes.h stdint.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+
+  ac_fn_c_check_header_mongrel "$LINENO" "minix/config.h" "ac_cv_header_minix_config_h" "$ac_includes_default"
+if test "x$ac_cv_header_minix_config_h" = x""yes; then :
+  MINIX=yes
+else
+  MINIX=
+fi
+
+
+  if test "$MINIX" = yes; then
+
+$as_echo "#define _POSIX_SOURCE 1" >>confdefs.h
+
+
+$as_echo "#define _POSIX_1_SOURCE 2" >>confdefs.h
+
+
+$as_echo "#define _MINIX 1" >>confdefs.h
+
+  fi
+
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether it is safe to define __EXTENSIONS__" >&5
+$as_echo_n "checking whether it is safe to define __EXTENSIONS__... " >&6; }
+if test "${ac_cv_safe_to_define___extensions__+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#        define __EXTENSIONS__ 1
+         $ac_includes_default
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_safe_to_define___extensions__=yes
+else
+  ac_cv_safe_to_define___extensions__=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_safe_to_define___extensions__" >&5
+$as_echo "$ac_cv_safe_to_define___extensions__" >&6; }
+  test $ac_cv_safe_to_define___extensions__ = yes &&
+    $as_echo "#define __EXTENSIONS__ 1" >>confdefs.h
+
+  $as_echo "#define _ALL_SOURCE 1" >>confdefs.h
+
+  $as_echo "#define _GNU_SOURCE 1" >>confdefs.h
+
+  $as_echo "#define _POSIX_PTHREAD_SEMANTICS 1" >>confdefs.h
+
+  $as_echo "#define _TANDEM_SOURCE 1" >>confdefs.h
+
+
+
+
+
+# So far, the only shared library we might use is libopts.
+# It's a small library - we might as well use a static version of it.
+# Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+  enableval=$enable_shared; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_shared=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_shared=no
+fi
+
+
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "no acceptable C compiler found in \$PATH
+See \`config.log' for more details." "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+        CFLAGS="-g"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+# Ralf Wildenhues: With per-target flags we need CC_C_O
+# AM_PROG_CC_C_O supersets AC_PROG_CC_C_O
+if test "x$CC" != xcc; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC and cc understand -c and -o together" >&5
+$as_echo_n "checking whether $CC and cc understand -c and -o together... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether cc understands -c and -o together" >&5
+$as_echo_n "checking whether cc understands -c and -o together... " >&6; }
+fi
+set dummy $CC; ac_cc=`$as_echo "$2" |
+                     sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+if { as_var=ac_cv_prog_cc_${ac_cc}_c_o; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+# Make sure it works both with $CC and with simple cc.
+# We do the test twice because some compilers refuse to overwrite an
+# existing .o file with -o, though they will create one.
+ac_try='$CC -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+rm -f conftest2.*
+if { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } &&
+   test -f conftest2.$ac_objext && { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; };
+then
+  eval ac_cv_prog_cc_${ac_cc}_c_o=yes
+  if test "x$CC" != xcc; then
+    # Test first that cc exists at all.
+    if { ac_try='cc -c conftest.$ac_ext >&5'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+      ac_try='cc -c conftest.$ac_ext -o conftest2.$ac_objext >&5'
+      rm -f conftest2.*
+      if { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } &&
+        test -f conftest2.$ac_objext && { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; };
+      then
+       # cc works too.
+       :
+      else
+       # cc exists but doesn't like -o.
+       eval ac_cv_prog_cc_${ac_cc}_c_o=no
+      fi
+    fi
+  fi
+else
+  eval ac_cv_prog_cc_${ac_cc}_c_o=no
+fi
+rm -f core conftest*
+
+fi
+if eval test \$ac_cv_prog_cc_${ac_cc}_c_o = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+$as_echo "#define NO_MINUS_C_MINUS_O 1" >>confdefs.h
+
+fi
+
+# FIXME: we rely on the cache variable name because
+# there is no other way.
+set dummy $CC
+am_cc=`echo $2 | sed 's/[^a-zA-Z0-9_]/_/g;s/^[0-9]/_/'`
+eval am_t=\$ac_cv_prog_cc_${am_cc}_c_o
+if test "$am_t" != yes; then
+   # Losing compiler, so override with the script.
+   # FIXME: It is wrong to rewrite CC.
+   # But if we don't then we get into trouble of one sort or another.
+   # A longer-term fix would be to have automake use am__CC in this case,
+   # and then we could set am__CC="\$(top_srcdir)/compile \$(CC)"
+   CC="$am_aux_dir/compile $CC"
+fi
+
+
+   case $ac_cv_prog_cc_stdc in #(
+  no) :
+    ac_cv_prog_cc_c99=no; ac_cv_prog_cc_c89=no ;; #(
+  *) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C99" >&5
+$as_echo_n "checking for $CC option to accept ISO C99... " >&6; }
+if test "${ac_cv_prog_cc_c99+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c99=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdbool.h>
+#include <stdlib.h>
+#include <wchar.h>
+#include <stdio.h>
+
+// Check varargs macros.  These examples are taken from C99 6.10.3.5.
+#define debug(...) fprintf (stderr, __VA_ARGS__)
+#define showlist(...) puts (#__VA_ARGS__)
+#define report(test,...) ((test) ? puts (#test) : printf (__VA_ARGS__))
+static void
+test_varargs_macros (void)
+{
+  int x = 1234;
+  int y = 5678;
+  debug ("Flag");
+  debug ("X = %d\n", x);
+  showlist (The first, second, and third items.);
+  report (x>y, "x is %d but y is %d", x, y);
+}
+
+// Check long long types.
+#define BIG64 18446744073709551615ull
+#define BIG32 4294967295ul
+#define BIG_OK (BIG64 / BIG32 == 4294967297ull && BIG64 % BIG32 == 0)
+#if !BIG_OK
+  your preprocessor is broken;
+#endif
+#if BIG_OK
+#else
+  your preprocessor is broken;
+#endif
+static long long int bignum = -9223372036854775807LL;
+static unsigned long long int ubignum = BIG64;
+
+struct incomplete_array
+{
+  int datasize;
+  double data[];
+};
+
+struct named_init {
+  int number;
+  const wchar_t *name;
+  double average;
+};
+
+typedef const char *ccp;
+
+static inline int
+test_restrict (ccp restrict text)
+{
+  // See if C++-style comments work.
+  // Iterate through items via the restricted pointer.
+  // Also check for declarations in for loops.
+  for (unsigned int i = 0; *(text+i) != '\0'; ++i)
+    continue;
+  return 0;
+}
+
+// Check varargs and va_copy.
+static void
+test_varargs (const char *format, ...)
+{
+  va_list args;
+  va_start (args, format);
+  va_list args_copy;
+  va_copy (args_copy, args);
+
+  const char *str;
+  int number;
+  float fnumber;
+
+  while (*format)
+    {
+      switch (*format++)
+       {
+       case 's': // string
+         str = va_arg (args_copy, const char *);
+         break;
+       case 'd': // int
+         number = va_arg (args_copy, int);
+         break;
+       case 'f': // float
+         fnumber = va_arg (args_copy, double);
+         break;
+       default:
+         break;
+       }
+    }
+  va_end (args_copy);
+  va_end (args);
+}
+
+int
+main ()
+{
+
+  // Check bool.
+  _Bool success = false;
+
+  // Check restrict.
+  if (test_restrict ("String literal") == 0)
+    success = true;
+  char *restrict newvar = "Another string";
+
+  // Check varargs.
+  test_varargs ("s, d' f .", "string", 65, 34.234);
+  test_varargs_macros ();
+
+  // Check flexible array members.
+  struct incomplete_array *ia =
+    malloc (sizeof (struct incomplete_array) + (sizeof (double) * 10));
+  ia->datasize = 10;
+  for (int i = 0; i < ia->datasize; ++i)
+    ia->data[i] = i * 1.234;
+
+  // Check named initializers.
+  struct named_init ni = {
+    .number = 34,
+    .name = L"Test wide string",
+    .average = 543.34343,
+  };
+
+  ni.number = 58;
+
+  int dynamic_array[ni.number];
+  dynamic_array[ni.number - 1] = 543;
+
+  // work around unused variable warnings
+  return (!success || bignum == 0LL || ubignum == 0uLL || newvar[0] == 'x'
+         || dynamic_array[ni.number - 1] != 543);
+
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -std=gnu99 -std=c99 -c99 -AC99 -xc99=all -qlanglvl=extc99
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c99=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c99" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c99" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c99"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c99" >&5
+$as_echo "$ac_cv_prog_cc_c99" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c99" != xno; then :
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c99
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+  ac_cv_prog_cc_stdc=$ac_cv_prog_cc_c89
+else
+  ac_cv_prog_cc_stdc=no
+fi
+
+fi
+ ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO Standard C" >&5
+$as_echo_n "checking for $CC option to accept ISO Standard C... " >&6; }
+  if test "${ac_cv_prog_cc_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+fi
+
+  case $ac_cv_prog_cc_stdc in #(
+  no) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;; #(
+  '') :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;; #(
+  *) :
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_stdc" >&5
+$as_echo "$ac_cv_prog_cc_stdc" >&6; } ;;
+esac
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# HMS: These need to be moved to AM_CPPFLAGS and/or AM_CFLAGS
+case "$host" in
+ *-*-amigaos)
+    CFLAGS="$CFLAGS -Dfork=vfork -DSYS_AMIGA"
+    ;;
+ *-*-hpux10.*) # at least for hppa2.0-hp-hpux10.20
+    case "$GCC" in
+     yes)
+       ;;
+     *) CFLAGS="$CFLAGS -Wp,-H18816"
+       ;;
+    esac
+    ;;
+ *-pc-cygwin*)
+    CFLAGS="$CFLAGS -DSYS_CYGWIN32"
+    ;;
+ i386-sequent-sysv4)
+    case "$CC" in
+     cc)
+       CFLAGS="$CFLAGS -Wc,+abi-socket"
+       ;;
+    esac
+    ;;
+ *-*-mpeix*)
+    CPPFLAGS="$CPPFLAGS -DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE -I/SYSLOG/PUB"
+    LDFLAGS="$LDFLAGS -L/SYSLOG/PUB"
+    LIBS="$LIBS -lcurses"
+    ;;
+ *-*-solaris*)
+    # see "man standards".
+    # -D_XOPEN_SOURCE=500 is probably OK for c89 and before
+    # -D_XOPEN_SOURCE=600 seems OK for c99
+    #CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500 -D__EXTENSIONS__"
+    CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
+    libxnet=-lxnet
+    ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking additional compiler flags" >&5
+$as_echo_n "checking additional compiler flags... " >&6; }
+if test "${ac_cv_os_cflags+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+case "${host_os}" in
+       irix6* )
+               case "${CC}" in
+                       cc )
+                               # do not use 64-bit compiler
+                               ac_cv_os_cflags="-n32 -mips3 -Wl,-woff,84"
+                               ;;
+               esac
+               ;;
+# HMS: am-utils needed this but we don't (apparently)
+#      osf[[1-3]]* )
+#              # get the right version of struct sockaddr
+#              case "${CC}" in
+#                      cc )
+#                              ac_cv_os_cflags="-std -D_SOCKADDR_LEN -D_NO_PROTO"
+#                              ;;
+#                      * )
+#                              ac_cv_os_cflags="-D_SOCKADDR_LEN -D_NO_PROTO"
+#                              ;;
+#              esac
+#              ;;
+#      osf* )
+#              # get the right version of struct sockaddr
+#              case "${CC}" in
+#                      cc )
+#                              ac_cv_os_cflags="-std -D_SOCKADDR_LEN"
+#                              ;;
+#                      * )
+#                              ac_cv_os_cflags="-D_SOCKADDR_LEN"
+#                              ;;
+#              esac
+#              ;;
+       aix[1-3]* )
+               ac_cv_os_cflags="" ;;
+       aix4.[0-2]* )
+               # turn on additional headers
+               ac_cv_os_cflags="-D_XOPEN_EXTENDED_SOURCE"
+               ;;
+       aix* )
+               # avoid circular dependencies in yp headers
+               ac_cv_os_cflags="-DHAVE_BAD_HEADERS -D_XOPEN_EXTENDED_SOURCE"
+               ;;
+       OFF-sunos4* )
+               # make sure passing whole structures is handled in gcc
+               case "${CC}" in
+                       gcc )
+                               ac_cv_os_cflags="-fpcc-struct-return"
+                               ;;
+               esac
+               ;;
+       sunos[34]* | solaris1* | solaris2.[0-5]* | sunos5.[0-5]* )
+               ac_cv_os_cflags="" ;;
+       solaris* | sunos* )
+               # turn on 64-bit file offset interface
+               case "${CC}" in
+                       * )
+                               ac_cv_os_cflags="-D_LARGEFILE64_SOURCE"
+                               ;;
+               esac
+               ;;
+       hpux* )
+               # use Ansi compiler on HPUX
+               case "${CC}" in
+                       cc )
+                               ac_cv_os_cflags="-Ae"
+                               ;;
+               esac
+               ;;
+       darwin* | rhapsody* )
+               ac_cv_os_cflags="-D_P1003_1B_VISIBLE"
+               ;;
+       * )
+               ac_cv_os_cflags=""
+               ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_cflags" >&5
+$as_echo "$ac_cv_os_cflags" >&6; }
+CFLAGS="$CFLAGS $ac_cv_os_cflags"
+
+
+# NTP has (so far) been relying on leading-edge autogen.
+# Therefore, by default:
+# - use the version we ship with
+# - do not install it
+# - build a static copy (AC_DISABLE_SHARED - done earlier)
+case "${enable_local_libopts+set}" in
+ set) ;;
+ *) enable_local_libopts=yes ;;
+esac
+case "${enable_libopts_install+set}" in
+ set) ;;
+ *) enable_libopts_install=no ;;
+esac
+
+  NEED_LIBOPTS_DIR=''
+
+  LIBOPTS_DIR=libopts
+
+  # Check whether --enable-local-libopts was given.
+if test "${enable_local_libopts+set}" = set; then :
+  enableval=$enable_local_libopts;
+    if test x$enableval = xyes ; then
+       { $as_echo "$as_me:${as_lineno-$LINENO}: Using supplied libopts tearoff" >&5
+$as_echo "$as_me: Using supplied libopts tearoff" >&6;}
+       LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la'
+       LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts'
+       NEED_LIBOPTS_DIR=true
+    fi
+fi
+
+
+  # Check whether --enable-libopts-install was given.
+if test "${enable_libopts_install+set}" = set; then :
+  enableval=$enable_libopts_install;
+fi
+
+   if test "X${enable_libopts_install}" != Xno; then
+  INSTALL_LIBOPTS_TRUE=
+  INSTALL_LIBOPTS_FALSE='#'
+else
+  INSTALL_LIBOPTS_TRUE='#'
+  INSTALL_LIBOPTS_FALSE=
+fi
+
+
+  if test -z "${NEED_LIBOPTS_DIR}" ; then
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether autoopts-config can be found" >&5
+$as_echo_n "checking whether autoopts-config can be found... " >&6; }
+
+# Check whether --with-autoopts-config was given.
+if test "${with_autoopts_config+set}" = set; then :
+  withval=$with_autoopts_config; lo_cv_with_autoopts_config=${with_autoopts_config}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether autoopts-config is specified" >&5
+$as_echo_n "checking whether autoopts-config is specified... " >&6; }
+if test "${lo_cv_with_autoopts_config+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if autoopts-config --help 2>/dev/null 1>&2
+        then lo_cv_with_autoopts_config=autoopts-config
+        elif libopts-config --help 2>/dev/null 1>&2
+        then lo_cv_with_autoopts_config=libopts-config
+        else lo_cv_with_autoopts_config=no ; fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lo_cv_with_autoopts_config" >&5
+$as_echo "$lo_cv_with_autoopts_config" >&6; }
+
+fi
+ # end of AC_ARG_WITH
+
+     if test "${lo_cv_test_autoopts+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+        if test -z "${lo_cv_with_autoopts_config}" \
+                -o X"${lo_cv_with_autoopts_config}" = Xno
+        then
+           if autoopts-config --help 2>/dev/null 1>&2
+           then lo_cv_with_autoopts_config=autoopts-config
+           elif libopts-config --help 2>/dev/null 1>&2
+           then lo_cv_with_autoopts_config=libopts-config
+           else lo_cv_with_autoopts_config=false ; fi
+        fi
+        lo_cv_test_autoopts=`
+            ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
+        if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
+        then lo_cv_test_autoopts=no ; fi
+
+fi
+ # end of CACHE_VAL
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lo_cv_test_autoopts}" >&5
+$as_echo "${lo_cv_test_autoopts}" >&6; }
+
+     if test "X${lo_cv_test_autoopts}" != Xno
+     then
+        LIBOPTS_LDADD="${lo_cv_test_autoopts}"
+        LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
+     else
+        LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la'
+        LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts'
+        NEED_LIBOPTS_DIR=true
+     fi
+  fi # end of if test -z "${NEED_LIBOPTS_DIR}"
+
+   if test -n "${NEED_LIBOPTS_DIR}"; then
+  NEED_LIBOPTS_TRUE=
+  NEED_LIBOPTS_FALSE='#'
+else
+  NEED_LIBOPTS_TRUE='#'
+  NEED_LIBOPTS_FALSE=
+fi
+
+
+
+  LIBOPTS_DIR=libopts
+
+  ac_config_files="$ac_config_files libopts/Makefile"
+
+
+
+  if test -n "${NEED_LIBOPTS_DIR}" ; then
+
+
+if test X${INVOKE_LIBOPTS_MACROS_FIRST_done} != Xyes ; then
+  # =================
+  # AC_HEADER_STDC
+  # =================
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+  # =================
+  # AC_HEADER_DIRENT
+  # =================
+  ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+  as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
+$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <$ac_hdr>
+
+int
+main ()
+{
+if ((DIR *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_ac_Header=yes"
+else
+  eval "$as_ac_Header=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_ac_Header
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+_ACEOF
+
+ac_header_dirent=$ac_hdr; break
+fi
+
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' dir; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then :
+
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' x; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then :
+
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+
+  # =================
+  # AC_CHECK_HEADERS
+  # =================
+  for ac_header in dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \
+    setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \
+    sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h    \
+    utime.h sysexits.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+  # --------------------------------------------
+  # Verify certain entries from AC_CHECK_HEADERS
+  # --------------------------------------------
+  for f in sys_types sys_mman sys_param sys_stat sys_wait \
+           string errno stdlib memory setjmp
+  do eval as_ac_var=\${ac_cv_header_${f}_h+set}
+     test "${as_ac_var}" = set || \
+       as_fn_error "You must have ${f}.h on your system" "$LINENO" 5
+  done
+
+  # ================================================
+  # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise
+  # if varargs.h is present define HAVE_VARARGS_H.
+  # ================================================
+  for ac_header in stdarg.h varargs.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have stdarg.h or varargs.h on your system" "$LINENO" 5
+  fi
+
+  # ================================================
+  # Similarly for the string.h and strings.h headers
+  # ================================================
+  for ac_header in string.h strings.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have string.h or strings.h on your system" "$LINENO" 5
+  fi
+
+  # =====================
+  # ...and limits headers
+  # =====================
+  for ac_header in limits.h sys/limits.h values.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have one of limits.h, sys/limits.h or values.h" "$LINENO" 5
+  fi
+
+  # ========================
+  # ...and int types headers
+  # ========================
+  for ac_header in stdint.h inttypes.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default"
+if test "x$ac_cv_type_int8_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT8_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint8_t" "ac_cv_type_uint8_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint8_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT8_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default"
+if test "x$ac_cv_type_int16_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT16_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint16_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT16_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default"
+if test "x$ac_cv_type_int32_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT32_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint32_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT32_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_intptr_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INTPTR_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint_t" "ac_cv_type_uint_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT_T 1
+_ACEOF
+
+
+fi
+
+
+  # ====================
+  # uintptr type & sizes
+  # ====================
+  ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_uintptr_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINTPTR_T 1
+_ACEOF
+
+
+else
+
+$as_echo "#define uintptr_t unsigned long" >>confdefs.h
+
+fi
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char*" >&5
+$as_echo_n "checking size of char*... " >&6; }
+if test "${ac_cv_sizeof_charp+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char*))" "ac_cv_sizeof_charp"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_charp" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (char*)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_charp=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_charp" >&5
+$as_echo "$ac_cv_sizeof_charp" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_CHARP $ac_cv_sizeof_charp
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5
+$as_echo_n "checking size of int... " >&6; }
+if test "${ac_cv_sizeof_int+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_int" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (int)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_int=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5
+$as_echo "$ac_cv_sizeof_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
+$as_echo_n "checking size of long... " >&6; }
+if test "${ac_cv_sizeof_long+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (long)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
+$as_echo "$ac_cv_sizeof_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5
+$as_echo_n "checking size of short... " >&6; }
+if test "${ac_cv_sizeof_short+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_short" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (short)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_short=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5
+$as_echo "$ac_cv_sizeof_short" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+_ACEOF
+
+
+
+  # ----------------------------------------------------------------------
+  # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind.
+  # ----------------------------------------------------------------------
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pathfind in -lgen" >&5
+$as_echo_n "checking for pathfind in -lgen... " >&6; }
+if test "${ac_cv_lib_gen_pathfind+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgen  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pathfind ();
+int
+main ()
+{
+return pathfind ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_gen_pathfind=yes
+else
+  ac_cv_lib_gen_pathfind=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gen_pathfind" >&5
+$as_echo "$ac_cv_lib_gen_pathfind" >&6; }
+if test "x$ac_cv_lib_gen_pathfind" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBGEN 1
+_ACEOF
+
+  LIBS="-lgen $LIBS"
+
+fi
+
+  for ac_func in vprintf
+do :
+  ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf"
+if test "x$ac_cv_func_vprintf" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_VPRINTF 1
+_ACEOF
+
+ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt"
+if test "x$ac_cv_func__doprnt" = x""yes; then :
+
+$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h
+
+fi
+
+fi
+done
+
+
+  for ac_func in mmap canonicalize_file_name snprintf strdup strchr strrchr
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+  INVOKE_LIBOPTS_MACROS_FIRST_done=yes
+fi
+  # Check to see if a reg expr header is specified.
+
+
+# Check whether --with-regex-header was given.
+if test "${with_regex_header+set}" = set; then :
+  withval=$with_regex_header; libopts_cv_with_regex_header=${with_regex_header}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a reg expr header is specified" >&5
+$as_echo_n "checking whether a reg expr header is specified... " >&6; }
+if test "${libopts_cv_with_regex_header+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  libopts_cv_with_regex_header=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_regex_header" >&5
+$as_echo "$libopts_cv_with_regex_header" >&6; }
+
+fi
+ # end of AC_ARG_WITH
+
+  if test "X${libopts_cv_with_regex_header}" != Xno
+  then
+    cat >>confdefs.h <<_ACEOF
+#define REGEX_HEADER <${libopts_cv_with_regex_header}>
+_ACEOF
+
+  else
+
+$as_echo "#define REGEX_HEADER <regex.h>" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if a working libregex can be found.
+
+
+# Check whether --with-libregex was given.
+if test "${with_libregex+set}" = set; then :
+  withval=$with_libregex; libopts_cv_with_libregex_root=${with_libregex}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether with-libregex was specified" >&5
+$as_echo_n "checking whether with-libregex was specified... " >&6; }
+if test "${libopts_cv_with_libregex_root+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  libopts_cv_with_libregex_root=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_root" >&5
+$as_echo "$libopts_cv_with_libregex_root" >&6; }
+
+fi
+ # end of AC_ARG_WITH libregex
+
+  if test "${with_libguile+set}" = set && \
+     test "${withval}" = no
+  then ## disabled by request
+    libopts_cv_with_libregex_root=no
+    libopts_cv_with_libregex_cflags=no
+    libopts_cv_with_libregex_libs=no
+  else
+
+
+# Check whether --with-libregex-cflags was given.
+if test "${with_libregex_cflags+set}" = set; then :
+  withval=$with_libregex_cflags; libopts_cv_with_libregex_cflags=${with_regex_cflags}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether with-libregex-cflags was specified" >&5
+$as_echo_n "checking whether with-libregex-cflags was specified... " >&6; }
+if test "${libopts_cv_with_libregex_cflags+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  libopts_cv_with_libregex_cflags=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_cflags" >&5
+$as_echo "$libopts_cv_with_libregex_cflags" >&6; }
+
+fi
+ # end of AC_ARG_WITH libregex-cflags
+
+
+# Check whether --with-libregex-libs was given.
+if test "${with_libregex_libs+set}" = set; then :
+  withval=$with_libregex_libs; libopts_cv_with_libregex_libs=${with_regex_libs}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether with-libregex-libs was specified" >&5
+$as_echo_n "checking whether with-libregex-libs was specified... " >&6; }
+if test "${libopts_cv_with_libregex_libs+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  libopts_cv_with_libregex_libs=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_libs" >&5
+$as_echo "$libopts_cv_with_libregex_libs" >&6; }
+
+fi
+ # end of AC_ARG_WITH libregex-libs
+
+  case "X${libopts_cv_with_libregex_cflags}" in
+  Xyes|Xno|X )
+    case "X${libopts_cv_with_libregex_root}" in
+    Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
+    * )        libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
+    esac
+  esac
+  case "X${libopts_cv_with_libregex_libs}" in
+  Xyes|Xno|X )
+    case "X${libopts_cv_with_libregex_root}" in
+    Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
+    * )        libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex";;
+    esac
+  esac
+  libopts_save_CPPFLAGS="${CPPFLAGS}"
+  libopts_save_LIBS="${LIBS}"
+  fi ## disabled by request
+
+  case "X${libopts_cv_with_libregex_cflags}" in
+  Xyes|Xno|X )
+    libopts_cv_with_libregex_cflags="" ;;
+  * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
+  esac
+  case "X${libopts_cv_with_libregex_libs}" in
+  Xyes|Xno|X )
+    libopts_cv_with_libregex_libs="" ;;
+  * )
+    LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
+  esac
+  LIBREGEX_CFLAGS=""
+  LIBREGEX_LIBS=""
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether libregex functions properly" >&5
+$as_echo_n "checking whether libregex functions properly... " >&6; }
+  if test "${libopts_cv_with_libregex+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_with_libregex=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include REGEX_HEADER
+static regex_t re;
+void comp_re( char const* pzPat ) {
+  int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
+  if (res == 0) return;
+  exit( res ); }
+int main() {
+  regmatch_t m[2];
+  comp_re( "^.*\$"   );
+  comp_re( "()|no.*" );
+  comp_re( "."       );
+  if (regexec( &re, "X", 2, m, 0 ) != 0)  return 1;
+  if ((m[0].rm_so != 0) || (m[0].rm_eo != 1)) {
+    fputs( "error: regex -->.<-- did not match\n", stderr );
+    return 1;
+  }
+  return 0; }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_with_libregex=yes
+else
+  libopts_cv_with_libregex=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of AC_TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_with_libregex
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_with_libregex}" >&5
+$as_echo "${libopts_cv_with_libregex}" >&6; }
+
+  if test "X${libopts_cv_with_libregex}" != Xno
+  then
+
+$as_echo "#define WITH_LIBREGEX 1" >>confdefs.h
+
+  else
+    CPPFLAGS="${libopts_save_CPPFLAGS}"
+    LIBS="${libopts_save_LIBS}"
+  fi
+
+
+
+  # Check to see if pathfind(3) works.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pathfind(3) works" >&5
+$as_echo_n "checking whether pathfind(3) works... " >&6; }
+  if test "${libopts_cv_run_pathfind+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_run_pathfind=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+#include <stdlib.h>
+int main (int argc, char** argv) {
+   char* pz = pathfind( getenv( "PATH" ), "sh", "x" );
+   return (pz == 0) ? 1 : 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_run_pathfind=yes
+else
+  libopts_cv_run_pathfind=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_pathfind
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_pathfind}" >&5
+$as_echo "${libopts_cv_run_pathfind}" >&6; }
+
+  if test "X${libopts_cv_run_pathfind}" != Xno
+  then
+
+$as_echo "#define HAVE_PATHFIND 1" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if /dev/zero is readable device.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether /dev/zero is readable device" >&5
+$as_echo_n "checking whether /dev/zero is readable device... " >&6; }
+  if test "${libopts_cv_test_dev_zero+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    libopts_cv_test_dev_zero=`exec 2> /dev/null
+dzero=\`ls -lL /dev/zero | egrep ^c......r\`
+test -z "${dzero}" && exit 1
+echo ${dzero}`
+    if test $? -ne 0
+    then libopts_cv_test_dev_zero=no
+    elif test -z "$libopts_cv_test_dev_zero"
+    then libopts_cv_test_dev_zero=no
+    fi
+
+fi
+ # end of CACHE_VAL of libopts_cv_test_dev_zero
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_test_dev_zero}" >&5
+$as_echo "${libopts_cv_test_dev_zero}" >&6; }
+
+  if test "X${libopts_cv_test_dev_zero}" != Xno
+  then
+
+$as_echo "#define HAVE_DEV_ZERO 1" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if we have a functional realpath(3C).
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have a functional realpath(3C)" >&5
+$as_echo_n "checking whether we have a functional realpath(3C)... " >&6; }
+  if test "${libopts_cv_run_realpath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_run_realpath=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+#include <stdlib.h>
+int main (int argc, char** argv) {
+#ifndef PATH_MAX
+choke me!!
+#else
+   char zPath[PATH_MAX+1];
+#endif
+   char *pz = realpath(argv[0], zPath);
+   return (pz == zPath) ? 0 : 1;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_run_realpath=yes
+else
+  libopts_cv_run_realpath=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_realpath
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_realpath}" >&5
+$as_echo "${libopts_cv_run_realpath}" >&6; }
+
+  if test "X${libopts_cv_run_realpath}" != Xno
+  then
+
+$as_echo "#define HAVE_REALPATH 1" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if strftime() works.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strftime() works" >&5
+$as_echo_n "checking whether strftime() works... " >&6; }
+  if test "${libopts_cv_run_strftime+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_run_strftime=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <time.h>
+#include <string.h>
+char t_buf[ 64 ];
+int main() {
+  static char const z[] = "Thursday Aug 28 240";
+  struct tm tm;
+  tm.tm_sec   = 36;  /* seconds after the minute [0, 61]  */
+  tm.tm_min   = 44;  /* minutes after the hour [0, 59] */
+  tm.tm_hour  = 12;  /* hour since midnight [0, 23] */
+  tm.tm_mday  = 28;  /* day of the month [1, 31] */
+  tm.tm_mon   =  7;  /* months since January [0, 11] */
+  tm.tm_year  = 86;  /* years since 1900 */
+  tm.tm_wday  =  4;  /* days since Sunday [0, 6] */
+  tm.tm_yday  = 239; /* days since January 1 [0, 365] */
+  tm.tm_isdst =  1;  /* flag for daylight savings time */
+  strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
+  return (strcmp( t_buf, z ) != 0); }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_run_strftime=yes
+else
+  libopts_cv_run_strftime=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_strftime
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_strftime}" >&5
+$as_echo "${libopts_cv_run_strftime}" >&6; }
+
+  if test "X${libopts_cv_run_strftime}" != Xno
+  then
+
+$as_echo "#define HAVE_STRFTIME 1" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if fopen accepts "b" mode.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fopen accepts \"b\" mode" >&5
+$as_echo_n "checking whether fopen accepts \"b\" mode... " >&6; }
+  if test "${libopts_cv_run_fopen_binary+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_run_fopen_binary=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int main (int argc, char** argv) {
+FILE* fp = fopen("conftest.$ac_ext", "rb");
+return (fp == NULL) ? 1 : fclose(fp); }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_run_fopen_binary=yes
+else
+  libopts_cv_run_fopen_binary=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_fopen_binary}" >&5
+$as_echo "${libopts_cv_run_fopen_binary}" >&6; }
+
+  if test "X${libopts_cv_run_fopen_binary}" != Xno
+  then
+
+$as_echo "#define FOPEN_BINARY_FLAG \"b\"" >>confdefs.h
+
+  else
+
+$as_echo "#define FOPEN_BINARY_FLAG \"\"" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if fopen accepts "t" mode.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fopen accepts \"t\" mode" >&5
+$as_echo_n "checking whether fopen accepts \"t\" mode... " >&6; }
+  if test "${libopts_cv_run_fopen_text+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_run_fopen_text=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int main (int argc, char** argv) {
+FILE* fp = fopen("conftest.$ac_ext", "rt");
+return (fp == NULL) ? 1 : fclose(fp); }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_run_fopen_text=yes
+else
+  libopts_cv_run_fopen_text=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_fopen_text}" >&5
+$as_echo "${libopts_cv_run_fopen_text}" >&6; }
+
+  if test "X${libopts_cv_run_fopen_text}" != Xno
+  then
+
+$as_echo "#define FOPEN_TEXT_FLAG \"t\"" >>confdefs.h
+
+  else
+
+$as_echo "#define FOPEN_TEXT_FLAG \"\"" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if not wanting optional option args.
+
+  # Check whether --enable-optional-args was given.
+if test "${enable_optional_args+set}" = set; then :
+  enableval=$enable_optional_args; libopts_cv_enable_optional_args=${enable_optional_args}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether not wanting optional option args" >&5
+$as_echo_n "checking whether not wanting optional option args... " >&6; }
+if test "${libopts_cv_enable_optional_args+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  libopts_cv_enable_optional_args=yes
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_enable_optional_args" >&5
+$as_echo "$libopts_cv_enable_optional_args" >&6; }
+
+fi
+ # end of AC_ARG_ENABLE
+
+  if test "X${libopts_cv_enable_optional_args}" = Xno
+  then
+
+$as_echo "#define NO_OPTIONAL_OPT_ARGS 1" >>confdefs.h
+
+  fi
+
+
+
+
+  else
+
+if test X${INVOKE_LIBOPTS_MACROS_FIRST_done} != Xyes ; then
+  # =================
+  # AC_HEADER_STDC
+  # =================
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+  # =================
+  # AC_HEADER_DIRENT
+  # =================
+  ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+  as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
+$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <$ac_hdr>
+
+int
+main ()
+{
+if ((DIR *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_ac_Header=yes"
+else
+  eval "$as_ac_Header=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_ac_Header
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+_ACEOF
+
+ac_header_dirent=$ac_hdr; break
+fi
+
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' dir; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then :
+
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' x; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then :
+
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+
+  # =================
+  # AC_CHECK_HEADERS
+  # =================
+  for ac_header in dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \
+    setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \
+    sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h    \
+    utime.h sysexits.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+  # --------------------------------------------
+  # Verify certain entries from AC_CHECK_HEADERS
+  # --------------------------------------------
+  for f in sys_types sys_mman sys_param sys_stat sys_wait \
+           string errno stdlib memory setjmp
+  do eval as_ac_var=\${ac_cv_header_${f}_h+set}
+     test "${as_ac_var}" = set || \
+       as_fn_error "You must have ${f}.h on your system" "$LINENO" 5
+  done
+
+  # ================================================
+  # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise
+  # if varargs.h is present define HAVE_VARARGS_H.
+  # ================================================
+  for ac_header in stdarg.h varargs.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have stdarg.h or varargs.h on your system" "$LINENO" 5
+  fi
+
+  # ================================================
+  # Similarly for the string.h and strings.h headers
+  # ================================================
+  for ac_header in string.h strings.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have string.h or strings.h on your system" "$LINENO" 5
+  fi
+
+  # =====================
+  # ...and limits headers
+  # =====================
+  for ac_header in limits.h sys/limits.h values.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have one of limits.h, sys/limits.h or values.h" "$LINENO" 5
+  fi
+
+  # ========================
+  # ...and int types headers
+  # ========================
+  for ac_header in stdint.h inttypes.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default"
+if test "x$ac_cv_type_int8_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT8_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint8_t" "ac_cv_type_uint8_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint8_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT8_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default"
+if test "x$ac_cv_type_int16_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT16_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint16_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT16_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default"
+if test "x$ac_cv_type_int32_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT32_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint32_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT32_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_intptr_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INTPTR_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint_t" "ac_cv_type_uint_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT_T 1
+_ACEOF
+
+
+fi
+
+
+  # ====================
+  # uintptr type & sizes
+  # ====================
+  ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_uintptr_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINTPTR_T 1
+_ACEOF
+
+
+else
+
+$as_echo "#define uintptr_t unsigned long" >>confdefs.h
+
+fi
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char*" >&5
+$as_echo_n "checking size of char*... " >&6; }
+if test "${ac_cv_sizeof_charp+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char*))" "ac_cv_sizeof_charp"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_charp" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (char*)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_charp=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_charp" >&5
+$as_echo "$ac_cv_sizeof_charp" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_CHARP $ac_cv_sizeof_charp
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5
+$as_echo_n "checking size of int... " >&6; }
+if test "${ac_cv_sizeof_int+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_int" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (int)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_int=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5
+$as_echo "$ac_cv_sizeof_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
+$as_echo_n "checking size of long... " >&6; }
+if test "${ac_cv_sizeof_long+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (long)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
+$as_echo "$ac_cv_sizeof_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5
+$as_echo_n "checking size of short... " >&6; }
+if test "${ac_cv_sizeof_short+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_short" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (short)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_short=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5
+$as_echo "$ac_cv_sizeof_short" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+_ACEOF
+
+
+
+  # ----------------------------------------------------------------------
+  # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind.
+  # ----------------------------------------------------------------------
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pathfind in -lgen" >&5
+$as_echo_n "checking for pathfind in -lgen... " >&6; }
+if test "${ac_cv_lib_gen_pathfind+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgen  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pathfind ();
+int
+main ()
+{
+return pathfind ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_gen_pathfind=yes
+else
+  ac_cv_lib_gen_pathfind=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gen_pathfind" >&5
+$as_echo "$ac_cv_lib_gen_pathfind" >&6; }
+if test "x$ac_cv_lib_gen_pathfind" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBGEN 1
+_ACEOF
+
+  LIBS="-lgen $LIBS"
+
+fi
+
+  for ac_func in vprintf
+do :
+  ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf"
+if test "x$ac_cv_func_vprintf" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_VPRINTF 1
+_ACEOF
+
+ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt"
+if test "x$ac_cv_func__doprnt" = x""yes; then :
+
+$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h
+
+fi
+
+fi
+done
+
+
+  for ac_func in mmap canonicalize_file_name snprintf strdup strchr strrchr
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+  INVOKE_LIBOPTS_MACROS_FIRST_done=yes
+fi
+  fi
+# end of AC_DEFUN of LIBOPTS_CHECK
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC can handle #warning" >&5
+$as_echo_n "checking if $CC can handle #warning... " >&6; }
+if test "${ac_cv_cpp_warning+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#warning foo
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_cpp_warning=yes
+else
+  ac_cv_cpp_warning=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cpp_warning" >&5
+$as_echo "$ac_cv_cpp_warning" >&6; }
+
+case "$ac_cv_cpp_warning" in
+ no)
+
+$as_echo "#define NO_OPTION_NAME_WARNINGS 1" >>confdefs.h
+
+esac
+
+case "$GCC" in
+ yes)
+    SAVED_CFLAGS_AC="$CFLAGS"
+    CFLAGS="$CFLAGS -Wstrict-overflow"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Wstrict-overflow" >&5
+$as_echo_n "checking if $CC can handle -Wstrict-overflow... " >&6; }
+if test "${ac_cv_gcc_Wstrict_overflow+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_gcc_Wstrict_overflow=yes
+else
+  ac_cv_gcc_Wstrict_overflow=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gcc_Wstrict_overflow" >&5
+$as_echo "$ac_cv_gcc_Wstrict_overflow" >&6; }
+    CFLAGS="$SAVED_CFLAGS_AC"
+    unset SAVED_CFLAGS_AC
+    #
+    # $ac_cv_gcc_Wstrict_overflow is tested later to add the
+    # flag to CFLAGS.
+    #
+esac
+
+
+case "$GCC" in
+ yes)
+    SAVED_CFLAGS_AC="$CFLAGS"
+    CFLAGS="$CFLAGS -Winit-self"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC can handle -Winit-self" >&5
+$as_echo_n "checking if $CC can handle -Winit-self... " >&6; }
+if test "${ac_cv_gcc_Winit_self+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_gcc_Winit_self=yes
+else
+  ac_cv_gcc_Winit_self=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_gcc_Winit_self" >&5
+$as_echo "$ac_cv_gcc_Winit_self" >&6; }
+    CFLAGS="$SAVED_CFLAGS_AC"
+    unset SAVED_CFLAGS_AC
+    #
+    # $ac_cv_gcc_Winit_self is tested later to add the
+    # flag to CFLAGS.
+    #
+esac
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bin subdirectory" >&5
+$as_echo_n "checking for bin subdirectory... " >&6; }
+
+# Check whether --with-binsubdir was given.
+if test "${with_binsubdir+set}" = set; then :
+  withval=$with_binsubdir; use_binsubdir="$withval"
+else
+  use_binsubdir="bin"
+fi
+
+
+case "$use_binsubdir" in
+ bin)
+    ;;
+ sbin)
+    ;;
+ *)
+    as_fn_error "<$use_binsubdir> is illegal - must be \"bin\" or \"sbin\"" "$LINENO" 5
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_binsubdir" >&5
+$as_echo "$use_binsubdir" >&6; }
+BINSUBDIR=$use_binsubdir
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want to use arlib" >&5
+$as_echo_n "checking if we want to use arlib... " >&6; }
+
+# Check whether --with-arlib was given.
+if test "${with_arlib+set}" = set; then :
+  withval=$with_arlib; ans=$withval
+else
+  ans=no
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+if test -d $srcdir/arlib
+then
+    case "$ans" in
+     yes)
+       ARLIB_DIR=arlib
+
+
+subdirs="$subdirs arlib"
+
+       ;;
+    esac
+fi
+
+
+
+# Check whether --with-rpath was given.
+if test "${with_rpath+set}" = set; then :
+  withval=$with_rpath; ans=$withval
+else
+  ans=x
+fi
+
+case "$ans" in
+ no)
+    need_dash_r=
+    ;;
+ yes)
+    need_dash_r=1
+    ;;
+esac
+# HMS: Why isn't this $build?
+# Well, that depends on if we need this for the build toolchain or
+# for info in the host executable...
+# I still have no idea which way this should go, but nobody has complained.
+case "$host" in
+ *-*-netbsd*)
+    case "$need_dash_r" in
+     no) ;;
+     *)  need_dash_r=1
+        ;;
+    esac
+    ;;
+ *-*-solaris*)
+    case "$need_dash_r" in
+     no) ;;
+     *)  need_dash_r=1
+        ;;
+    esac
+    ;;
+esac
+
+
+case "$build" in
+ $host)
+    ;;
+ *) case "$host" in
+     *-*-vxworks*)
+       # Quick and dirty sanity check
+       case "$VX_KERNEL" in
+        '') as_fn_error "Please follow the directions in html/build/hints/vxworks.html!" "$LINENO" 5
+           ;;
+       esac
+        CFLAGS="$CFLAGS -DSYS_VXWORKS"
+        ;;
+    esac
+    ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+       @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+
+rm -f conftest*
+
+case "$GCC" in
+ yes)
+    CFLAGS="$CFLAGS -Wall"
+    # CFLAGS="$CFLAGS -Wcast-align"
+    CFLAGS="$CFLAGS -Wcast-qual"
+    # CFLAGS="$CFLAGS -Wconversion"
+    # CFLAGS="$CFLAGS -Werror"
+    # CFLAGS="$CFLAGS -Wextra"
+    # CFLAGS="$CFLAGS -Wfloat-equal"
+    CFLAGS="$CFLAGS -Wmissing-prototypes"
+    CFLAGS="$CFLAGS -Wpointer-arith"
+    CFLAGS="$CFLAGS -Wshadow"
+    #
+    # OpenSSL has a number of callback prototypes
+    # inside other function prototypes which trigger
+    # warnings with -Wstrict-prototypes, such as:
+    #
+    # int i2d_RSA_NET(const RSA *a, unsigned char **pp,
+    #                 int (*cb)(), int sgckey);
+    #                 ^^^^^^^^^^^
+    #
+    CFLAGS="$CFLAGS -Wno-strict-prototypes"
+    # CFLAGS="$CFLAGS -Wtraditional"
+    # CFLAGS="$CFLAGS -Wwrite-strings"
+    case "$ac_cv_gcc_Winit_self" in
+     yes)
+       CFLAGS="$CFLAGS -Winit-self"
+    esac
+    case "$ac_cv_gcc_Wstrict_overflow" in
+     yes)
+        #not yet: CFLAGS="$CFLAGS -Wstrict-overflow"
+    esac
+    ;;
+esac
+
+case "$host" in
+ *-next-nextstep3)
+    CFLAGS="$CFLAGS -posix"
+    ;;
+esac
+
+ac_busted_vpath_in_make=no
+
+case "$build" in
+ *-*-irix6.1*) # 64 bit only
+    # busted vpath?
+    ;;
+ *-*-irix6*)   # 6.2 (and later?)
+    ac_busted_vpath_in_make=yes
+    ;;
+ *-*-solaris2.5.1)
+    ac_busted_vpath_in_make=yes
+    ;;
+ *-*-unicosmp*)
+    ac_busted_vpath_in_make=yes
+    ;;
+esac
+
+case "$ac_busted_vpath_in_make$srcdir" in
+ no*) ;;
+ yes.) ;;
+ *) case "`${MAKE-make} -v -f /dev/null 2>/dev/null | sed -e 's/GNU Make version \(1-9.]*\).*/\1/' -e q`" in
+     '')
+       as_fn_error "building outside of the main directory requires GNU make" "$LINENO" 5
+       ;;
+     *) ;;
+    esac
+    ;;
+esac
+
+
+
+
+
+# Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then :
+  enableval=$enable_static; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_static=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_static=yes
+fi
+
+
+# Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+  enableval=$enable_fast_install; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_fast_install=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_fast_install=yes
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if test "${lt_cv_path_SED+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+
+fi
+
+SED=$lt_cv_path_SED
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SED" >&5
+$as_echo "$SED" >&6; }
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${lt_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+       test "$with_gnu_ld" != no && break
+       ;;
+      *)
+       test "$with_gnu_ld" != yes && break
+       ;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${lt_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if test "${lt_cv_ld_reload_flag+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_reload_flag='-r'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD-compatible nm" >&5
+$as_echo_n "checking for BSD-compatible nm... " >&6; }
+if test "${lt_cv_path_NM+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    tmp_nm="$ac_dir/${ac_tool_prefix}nm"
+    if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      # Tru64's nm complains that /dev/null is an invalid object file
+      case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+      */dev/null* | *'Invalid file or object type'*)
+       lt_cv_path_NM="$tmp_nm -B"
+       break
+        ;;
+      *)
+       case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+       */dev/null*)
+         lt_cv_path_NM="$tmp_nm -p"
+         break
+         ;;
+       *)
+         lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+         continue # so that we can try to find one that supports BSD flags
+         ;;
+       esac
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+NM="$lt_cv_path_NM"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognise dependent libraries" >&5
+$as_echo_n "checking how to recognise dependent libraries... " >&6; }
+if test "${lt_cv_deplibs_check_method+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix4* | aix5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[45]*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump'.
+  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | kfreebsd*-gnu | dragonfly*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+nto-qnx*)
+  lt_cv_deplibs_check_method=unknown
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sco3.2v5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+  enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *ELF-32*)
+      HPUX_IA64_MODE="32"
+      ;;
+    *ELF-64*)
+      HPUX_IA64_MODE="64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line 9126 "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+   if test "$lt_cv_prog_gnu_ld" = yes; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -melf32bsmip"
+      ;;
+    *N32*)
+      LD="${LD-ld} -melf32bmipn32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -melf64bmip"
+      ;;
+    esac
+   else
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+   fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+    *32-bit*)
+      case $host in
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_i386"
+          ;;
+        ppc64-*linux*|powerpc64-*linux*)
+          LD="${LD-ld} -m elf32ppclinux"
+          ;;
+        s390x-*linux*)
+          LD="${LD-ld} -m elf_s390"
+          ;;
+        sparc64-*linux*)
+          LD="${LD-ld} -m elf32_sparc"
+          ;;
+      esac
+      ;;
+    *64-bit*)
+      case $host in
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        ppc*-*linux*|powerpc*-*linux*)
+          LD="${LD-ld} -m elf64ppc"
+          ;;
+        s390*-*linux*)
+          LD="${LD-ld} -m elf64_s390"
+          ;;
+        sparc*-*linux*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if test "${lt_cv_cc_needs_belf+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_cc_needs_belf=yes
+else
+  lt_cv_cc_needs_belf=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+
+esac
+
+need_locks="$enable_libtool_lock"
+
+
+for ac_header in dlfcn.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default"
+if test "x$ac_cv_header_dlfcn_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+
+fi
+
+done
+
+
+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if test "${lt_cv_sys_max_cmd_len+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+    i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536      # usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  *)
+    # If test is not a shell built-in, we'll probably end up computing a
+    # maximum length that is only half of the actual maximum length, but
+    # we can't tell.
+    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+    while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
+              = "XX$teststring") >/dev/null 2>&1 &&
+           new_result=`expr "X$teststring" : ".*" 2>&1` &&
+           lt_cv_sys_max_cmd_len=$new_result &&
+           test $i != 17 # 1/2 MB should be enough
+    do
+      i=`expr $i + 1`
+      teststring=$teststring$teststring
+    done
+    teststring=
+    # Add a significant safety factor because C++ compilers can tack on massive
+    # amounts of additional arguments before passing them to the linker.
+    # It appears as though 1/2 is a usable value.
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    ;;
+  esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
+$as_echo "none" >&6; }
+fi
+
+
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Transform an extracted symbol line into a proper C declaration
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw* | pw32*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*) # Its linker distinguishes data from code symbols
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDEGRST]'
+  fi
+  lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  ;;
+linux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDGIRSTW]'
+    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris* | sysv5*)
+  symcode='[BDRT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[      ]\($symcode$symcode*\)[         ][      ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5
+  (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+      else
+       rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if grep ' nm_test_var$' "$nlist" >/dev/null; then
+       if grep ' nm_test_func$' "$nlist" >/dev/null; then
+         cat <<EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+         # Now generate the symbol file.
+         eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+
+         cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{
+EOF
+         $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+         cat <<\EOF >> conftest.$ac_ext
+  {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+         # Now try linking the two files.
+         mv conftest.$ac_objext conftstm.$ac_objext
+         lt_save_LIBS="$LIBS"
+         lt_save_CFLAGS="$CFLAGS"
+         LIBS="conftstm.$ac_objext"
+         CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+         if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+           pipe_works=yes
+         fi
+         LIBS="$lt_save_LIBS"
+         CFLAGS="$lt_save_CFLAGS"
+       else
+         echo "cannot find nm_test_func in $nlist" >&5
+       fi
+      else
+       echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.$ac_ext >&5
+  fi
+  rm -f conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if test "${lt_cv_objdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Constants:
+rm="rm -f"
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AR="${ac_tool_prefix}ar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+  ac_ct_AR=$AR
+  # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_AR="ar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+else
+  AR="$ac_cv_prog_AR"
+fi
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+test -z "$AS" && AS=as
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$LD" && LD=ld
+test -z "$LN_S" && LN_S="ln -s"
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+test -z "$NM" && NM=nm
+test -z "$SED" && SED=sed
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+    ;;
+  *)
+    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/${ac_tool_prefix}file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  else
+    MAGIC_CMD=:
+  fi
+fi
+
+  fi
+  ;;
+esac
+
+enable_dlopen=no
+enable_win32_dll=no
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+  enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then :
+  withval=$with_pic; pic_mode="$withval"
+else
+  pic_mode=default
+fi
+
+test -z "$pic_mode" && pic_mode=default
+
+# Use C for the default configuration in the libtool script
+tagname=
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}\n'
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm conftest*
+
+
+#
+# Check for any special shared library compilation flags.
+#
+lt_prog_cc_shlib=
+if test "$GCC" = no; then
+  case $host_os in
+  sco3.2v5*)
+    lt_prog_cc_shlib='-belf'
+    ;;
+  esac
+fi
+if test -n "$lt_prog_cc_shlib"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&5
+$as_echo "$as_me: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&2;}
+  if echo "$old_CC $old_CFLAGS " | grep "[     ]$lt_prog_cc_shlib[     ]" >/dev/null; then :
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5
+$as_echo "$as_me: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;}
+    lt_cv_prog_cc_can_build_shared=no
+  fi
+fi
+
+
+#
+# Check to make sure the static flag actually works.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_prog_compiler_static works" >&5
+$as_echo_n "checking if $compiler static flag $lt_prog_compiler_static works... " >&6; }
+if test "${lt_prog_compiler_static_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_prog_compiler_static_works=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_prog_compiler_static"
+   printf "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
+       $SED '/^$/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_prog_compiler_static_works=yes
+       fi
+     else
+       lt_prog_compiler_static_works=yes
+     fi
+   fi
+   $rm conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_static_works" >&5
+$as_echo "$lt_prog_compiler_static_works" >&6; }
+
+if test x"$lt_prog_compiler_static_works" = xyes; then
+    :
+else
+    lt_prog_compiler_static=
+fi
+
+
+
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+  lt_prog_compiler_no_builtin_flag=' -fno-builtin'
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+  ac_outfile=conftest.$ac_objext
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:10261: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:10265: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl='-Wl,'
+    lt_prog_compiler_static='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       lt_prog_compiler_pic=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic='-fPIC'
+       ;;
+      esac
+      ;;
+
+    *)
+      lt_prog_compiler_pic='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl='-Wl,'
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static='-Bstatic'
+      else
+       lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         lt_prog_compiler_pic='-qnocommon'
+         lt_prog_compiler_wl='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic='+Z'
+       ;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    linux*)
+      case $cc_basename in
+      icc* | ecc*)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-KPIC'
+       lt_prog_compiler_static='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+       # which looks to be a dead project)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-fpic'
+       lt_prog_compiler_static='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static='-non_shared'
+        ;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    sco3.2v5*)
+      lt_prog_compiler_pic='-Kpic'
+      lt_prog_compiler_static='-dn'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+       lt_prog_compiler_wl='-Qoption ld ';;
+      *)
+       lt_prog_compiler_wl='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl='-Qoption ld '
+      lt_prog_compiler_pic='-PIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+       lt_prog_compiler_pic='-Kconform_pic'
+       lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_can_build_shared=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic='-pic'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared=no
+      ;;
+    esac
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5
+$as_echo "$lt_prog_compiler_pic" >&6; }
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if test "${lt_prog_compiler_pic_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_prog_compiler_pic_works=no
+  ac_outfile=conftest.$ac_objext
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:10523: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:10527: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_prog_compiler_pic_works=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_works" >&5
+$as_echo "$lt_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_prog_compiler_pic_works" = xyes; then
+    case $lt_prog_compiler_pic in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+     esac
+else
+    lt_prog_compiler_pic=
+     lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic=
+    ;;
+  *)
+    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:10585: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:10589: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
+     $SED '/^$/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  runpath_var=
+  allow_undefined_flag=
+  enable_shared_with_static_runtimes=no
+  archive_cmds=
+  archive_expsym_cmds=
+  old_archive_From_new_cmds=
+  old_archive_from_expsyms_cmds=
+  export_dynamic_flag_spec=
+  whole_archive_flag_spec=
+  thread_safe_flag_spec=
+  hardcode_libdir_flag_spec=
+  hardcode_libdir_flag_spec_ld=
+  hardcode_libdir_separator=
+  hardcode_direct=no
+  hardcode_minus_L=no
+  hardcode_shlibpath_var=unsupported
+  link_all_deplibs=unknown
+  hardcode_automatic=no
+  module_cmds=
+  module_expsym_cmds=
+  always_export_symbols=no
+  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+       whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+       whole_archive_flag_spec=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix3* | aix4* | aix5*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+       ld_shlibs=no
+       cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+
+      # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+      # that the semantics of dynamic libraries on AmigaOS, at least up
+      # to version 4, is to share data among multiple programs linked
+      # with the same dynamic library.  Since this doesn't match the
+      # behavior of shared libraries on other platforms, we can't use
+      # them.
+      ld_shlibs=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       allow_undefined_flag=unsupported
+       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+       # support --undefined.  This deserves some investigation.  FIXME
+       archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec='-L$libdir'
+      allow_undefined_flag=unsupported
+      always_export_symbols=no
+      enable_shared_with_static_runtimes=yes
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+       # If the export-symbols file already is a .def file (1st line
+       # is EXPORTS), use it as is; otherwise, prepend...
+       archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+         cp $export_symbols $output_objdir/$soname.def;
+       else
+         echo EXPORTS > $output_objdir/$soname.def;
+         cat $export_symbols >> $output_objdir/$soname.def;
+       fi~
+       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    linux*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       tmp_addflag=
+       case $cc_basename,$host_cpu in
+       pgcc*)                          # Portland Group C compiler
+         whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag'
+         ;;
+       pgf77* | pgf90* | pgf95*)       # Portland Group f77 and f90 compilers
+         whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag -Mnomain' ;;
+       ecc*,ia64* | icc*,ia64*)                # Intel C compiler on ia64
+         tmp_addflag=' -i_dynamic' ;;
+       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
+         tmp_addflag=' -i_dynamic -nofor_main' ;;
+       ifc* | ifort*)                  # Intel Fortran compiler
+         tmp_addflag=' -nofor_main' ;;
+       esac
+       archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+       if test $supports_anon_versioning = yes; then
+         archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+         $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+       fi
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+       wlarc=
+      else
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris* | sysv5*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+       ld_shlibs=no
+       cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    sunos4*)
+      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec=
+      export_dynamic_flag_spec=
+      whole_archive_flag_spec=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag=unsupported
+      always_export_symbols=yes
+      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L=yes
+      if test "$GCC" = yes && test -z "$link_static_flag"; then
+       # Neither direct hardcoding nor static linking is supported with a
+       # broken collect2.
+       hardcode_direct=unsupported
+      fi
+      ;;
+
+    aix4* | aix5*)
+      if test "$host_cpu" = ia64; then
+       # On IA64, the linker does run time linking by default, so we don't
+       # have to do anything special.
+       aix_use_runtimelinking=no
+       exp_sym_flag='-Bexport'
+       no_entry_flag=""
+      else
+       # If we're using GNU nm, then we don't want the "-C" option.
+       # -C means demangle to AIX nm, but means don't demangle with GNU nm
+       if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+         export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+       else
+         export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+       fi
+       aix_use_runtimelinking=no
+
+       # Test if we are trying to use run time linking or normal
+       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+       # need to do runtime linking.
+       case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+         for ld_flag in $LDFLAGS; do
+         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+           aix_use_runtimelinking=yes
+           break
+         fi
+         done
+       esac
+
+       exp_sym_flag='-bexport'
+       no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds=''
+      hardcode_direct=yes
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+
+      if test "$GCC" = yes; then
+       case $host_os in aix4.[012]|aix4.[012].*)
+       # We only want to do this on AIX 4.2 and lower, the check
+       # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" && \
+          strings "$collect2name" | grep resolve_lib_name >/dev/null
+         then
+         # We have reworked collect2
+         hardcode_direct=yes
+         else
+         # We have old collect2
+         hardcode_direct=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         hardcode_minus_L=yes
+         hardcode_libdir_flag_spec='-L$libdir'
+         hardcode_libdir_separator=
+         fi
+       esac
+       shared_flag='-shared'
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag="$shared_flag "'${wl}-G'
+       fi
+      else
+       # not using gcc
+       if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+       else
+       if test "$aix_use_runtimelinking" = yes; then
+           shared_flag='${wl}-G'
+         else
+           shared_flag='${wl}-bM:SRE'
+       fi
+       fi
+      fi
+
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols=yes
+      if test "$aix_use_runtimelinking" = yes; then
+       # Warning - without using the other runtime loading flags (-brtl),
+       # -berok will link without error, but may produce a broken library.
+       allow_undefined_flag='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+       hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+       archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+       if test "$host_cpu" = ia64; then
+         hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+         allow_undefined_flag="-z nodefs"
+         archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+       else
+        # Determine the default libpath from the value encoded in an empty executable.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+         # Warning - without using the other run time loading flags,
+         # -berok will link without error, but may produce a broken library.
+         no_undefined_flag=' ${wl}-bernotok'
+         allow_undefined_flag=' ${wl}-berok'
+         # -bexpall does not export symbols beginning with underscore (_)
+         always_export_symbols=yes
+         # Exported symbols can be pulled into shared objects from archives
+         whole_archive_flag_spec=' '
+         archive_cmds_need_lc=yes
+         # This is similar to how AIX traditionally builds its shared libraries.
+         archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+       fi
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      # see comment about different semantics on the GNU ld section
+      ld_shlibs=no
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec=' '
+      allow_undefined_flag=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_From_new_cmds='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[012])
+         allow_undefined_flag='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[012])
+               allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      archive_cmds_need_lc=no
+      hardcode_direct=no
+      hardcode_automatic=yes
+      hardcode_shlibpath_var=unsupported
+      whole_archive_flag_spec=''
+      link_all_deplibs=yes
+    if test "$GCC" = yes ; then
+       output_verbose_link_cmd='echo'
+        archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+      archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+         module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         ld_shlibs=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    freebsd1*)
+      ld_shlibs=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | kfreebsd*-gnu | dragonfly*)
+      archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+       archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+       archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      export_dynamic_flag_spec='${wl}-E'
+      ;;
+
+    hpux10* | hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*|ia64*)
+         archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       esac
+      else
+       case $host_cpu in
+       hppa*64*|ia64*)
+         archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       *)
+         archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       esac
+      fi
+      if test "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*)
+         hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+         hardcode_libdir_flag_spec_ld='+b $libdir'
+         hardcode_libdir_separator=:
+         hardcode_direct=no
+         hardcode_shlibpath_var=no
+         ;;
+       ia64*)
+         hardcode_libdir_flag_spec='-L$libdir'
+         hardcode_direct=no
+         hardcode_shlibpath_var=no
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         hardcode_minus_L=yes
+         ;;
+       *)
+         hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+         hardcode_libdir_separator=:
+         hardcode_direct=yes
+         export_dynamic_flag_spec='${wl}-E'
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         hardcode_minus_L=yes
+         ;;
+       esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       hardcode_libdir_flag_spec_ld='-rpath $libdir'
+      fi
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      link_all_deplibs=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+       archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    newsos6)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_shlibpath_var=no
+      ;;
+
+    openbsd*)
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+       archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+       hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+       export_dynamic_flag_spec='${wl}-E'
+      else
+       case $host_os in
+        openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+          archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+          hardcode_libdir_flag_spec='-R$libdir'
+          ;;
+        *)
+          archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+          hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+          ;;
+       esac
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       allow_undefined_flag=' -expect_unresolved \*'
+       archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+
+    osf4* | osf5*)     # as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      else
+       allow_undefined_flag=' -expect_unresolved \*'
+       archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+       $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+
+       # Both c and cxx compiler support -rpath directly
+       hardcode_libdir_flag_spec='-rpath $libdir'
+      fi
+      hardcode_libdir_separator=:
+      ;;
+
+    sco3.2v5*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='${wl}-Bexport'
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ;;
+
+    solaris*)
+      no_undefined_flag=' -z text'
+      if test "$GCC" = yes; then
+       wlarc='${wl}'
+       archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+         $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+       wlarc=''
+       archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+       $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_shlibpath_var=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+       # The compiler driver will combine linker options so we
+       # cannot just pass the convience library names through
+       # without $wl, iff we do not link with $LD.
+       # Luckily, gcc supports the same syntax we need for Sun Studio.
+       # Supported since Solaris 2.6 (maybe 2.5.1?)
+       case $wlarc in
+       '')
+         whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
+       *)
+         whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
+       esac ;;
+      esac
+      link_all_deplibs=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+       # Use $CC to link under sequent, because it throws in some extra .o
+       # files that make .init and .fini sections work.
+       archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+       sni)
+         archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct=yes # is this really true???
+       ;;
+       siemens)
+         ## LD is ld it makes a PLAMLIB
+         ## CC just makes a GrossModule.
+         archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+         reload_cmds='$CC -r -o $output$reload_objs'
+         hardcode_direct=no
+        ;;
+       motorola)
+         archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+       ;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       hardcode_shlibpath_var=no
+       runpath_var=LD_RUN_PATH
+       hardcode_runpath_var=yes
+       ld_shlibs=yes
+      fi
+      ;;
+
+    sysv4.2uw2*)
+      archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=no
+      hardcode_shlibpath_var=no
+      hardcode_runpath_var=yes
+      runpath_var=LD_RUN_PATH
+      ;;
+
+   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[78]* | unixware7*)
+      no_undefined_flag='${wl}-z ${wl}text'
+      if test "$GCC" = yes; then
+       archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv5*)
+      no_undefined_flag=' -z text'
+      # $CC -shared without GNU ld will not create a library from C++
+      # object files and a static libstdc++, better avoid it by now
+      archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      hardcode_libdir_flag_spec=
+      hardcode_shlibpath_var=no
+      runpath_var='LD_RUN_PATH'
+      ;;
+
+    uts4*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      ld_shlibs=no
+      ;;
+    esac
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+$as_echo "$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+      $rm conftest*
+      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag
+        allow_undefined_flag=
+        if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+        then
+         archive_cmds_need_lc=no
+        else
+         archive_cmds_need_lc=yes
+        fi
+        allow_undefined_flag=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5
+$as_echo "$archive_cmds_need_lc" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix4* | aix5*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+  if test "$GCC" = yes; then
+    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+  else
+    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+  fi
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+kfreebsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  *) # from 3.2 on
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,       ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+knetbsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" || \
+   test -n "$runpath_var" || \
+   test "X$hardcode_automatic" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+$as_echo "$hardcode_action" >&6; }
+
+if test "$hardcode_action" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+       ;;
+   *)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    ;;
+  esac
+fi
+
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+
+fi
+
+   ;;
+
+  *)
+    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_shl_load=yes
+else
+  ac_cv_lib_dld_shl_load=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_svld_dlopen=yes
+else
+  ac_cv_lib_svld_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_dld_link=yes
+else
+  ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = x""yes; then :
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 12457 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      LDFLAGS="$LDFLAGS $link_static_flag"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self_static+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 12555 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+
+# Report which librarie types wil actually be built
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case $host_os in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+
+aix4* | aix5*)
+  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler \
+    CC \
+    LD \
+    lt_prog_compiler_wl \
+    lt_prog_compiler_pic \
+    lt_prog_compiler_static \
+    lt_prog_compiler_no_builtin_flag \
+    export_dynamic_flag_spec \
+    thread_safe_flag_spec \
+    whole_archive_flag_spec \
+    enable_shared_with_static_runtimes \
+    old_archive_cmds \
+    old_archive_from_new_cmds \
+    predep_objects \
+    postdep_objects \
+    predeps \
+    postdeps \
+    compiler_lib_search_path \
+    archive_cmds \
+    archive_expsym_cmds \
+    postinstall_cmds \
+    postuninstall_cmds \
+    old_archive_from_expsyms_cmds \
+    allow_undefined_flag \
+    no_undefined_flag \
+    export_symbols_cmds \
+    hardcode_libdir_flag_spec \
+    hardcode_libdir_flag_spec_ld \
+    hardcode_libdir_separator \
+    hardcode_automatic \
+    module_cmds \
+    module_expsym_cmds \
+    lt_cv_prog_compiler_c_o \
+    exclude_expsyms \
+    include_expsyms; do
+
+    case $var in
+    old_archive_cmds | \
+    old_archive_from_new_cmds | \
+    archive_cmds | \
+    archive_expsym_cmds | \
+    module_cmds | \
+    module_expsym_cmds | \
+    old_archive_from_expsyms_cmds | \
+    export_symbols_cmds | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="${ofile}T"
+  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+  $rm -f "$cfgfile"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ofile" >&5
+$as_echo "$as_me: creating $ofile" >&6;}
+
+  cat <<__EOF__ >> "$cfgfile"
+#! $SHELL
+
+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool:
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="$SED -e 1s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# The names of the tagged configurations supported by this script.
+available_tags=
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# ### END LIBTOOL CONFIG
+
+__EOF__
+
+
+  case $host_os in
+  aix3*)
+    cat <<\EOF >> "$cfgfile"
+
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+EOF
+    ;;
+  esac
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" || \
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+
+# Check whether --with-tags was given.
+if test "${with_tags+set}" = set; then :
+  withval=$with_tags; tagnames="$withval"
+fi
+
+
+if test -f "$ltmain" && test -n "$tagnames"; then
+  if test ! -f "${ofile}"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: output file \`$ofile' does not exist" >&5
+$as_echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;}
+  fi
+
+  if test -z "$LTCC"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+    if test -z "$LTCC"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: output file \`$ofile' does not look like a libtool script" >&5
+$as_echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;}
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5
+$as_echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;}
+    fi
+  fi
+
+  # Extract list of available tagged configurations in $ofile.
+  # Note that this assumes the entire list is on one line.
+  available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
+
+  lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+  for tagname in $tagnames; do
+    IFS="$lt_save_ifs"
+    # Check whether tagname contains only valid characters
+    case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in
+    "") ;;
+    *)  as_fn_error "invalid tag name: $tagname" "$LINENO" 5
+       ;;
+    esac
+
+    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+    then
+      as_fn_error "tag name \"$tagname\" already exists" "$LINENO" 5
+    fi
+
+    # Update the list of available tags.
+    if test -n "$tagname"; then
+      echo appending configuration tag \"$tagname\" to $ofile
+
+      case $tagname in
+      CXX)
+       if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+           ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+           (test "X$CXX" != "Xg++"))) ; then
+         :
+       else
+         tagname=""
+       fi
+       ;;
+
+      F77)
+       if test -n "$F77" && test "X$F77" != "Xno"; then
+         :
+       else
+         tagname=""
+       fi
+       ;;
+
+      GCJ)
+       if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+objext_GCJ=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm conftest*
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${GCJ-"gcj"}
+compiler=$CC
+compiler_GCJ=$CC
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+archive_cmds_need_lc_GCJ=no
+
+old_archive_cmds_GCJ=$old_archive_cmds
+
+
+lt_prog_compiler_no_builtin_flag_GCJ=
+
+if test "$GCC" = yes; then
+  lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin'
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+  ac_outfile=conftest.$ac_objext
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13334: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:13338: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+lt_prog_compiler_wl_GCJ=
+lt_prog_compiler_pic_GCJ=
+lt_prog_compiler_static_GCJ=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl_GCJ='-Wl,'
+    lt_prog_compiler_static_GCJ='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static_GCJ='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_GCJ='-fno-common'
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared_GCJ=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       lt_prog_compiler_pic_GCJ=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic_GCJ='-fPIC'
+       ;;
+      esac
+      ;;
+
+    *)
+      lt_prog_compiler_pic_GCJ='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static_GCJ='-Bstatic'
+      else
+       lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         lt_prog_compiler_pic_GCJ='-qnocommon'
+         lt_prog_compiler_wl_GCJ='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic_GCJ='+Z'
+       ;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static_GCJ='-non_shared'
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    linux*)
+      case $cc_basename in
+      icc* | ecc*)
+       lt_prog_compiler_wl_GCJ='-Wl,'
+       lt_prog_compiler_pic_GCJ='-KPIC'
+       lt_prog_compiler_static_GCJ='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+       # which looks to be a dead project)
+       lt_prog_compiler_wl_GCJ='-Wl,'
+       lt_prog_compiler_pic_GCJ='-fpic'
+       lt_prog_compiler_static_GCJ='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl_GCJ='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static_GCJ='-non_shared'
+        ;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static_GCJ='-non_shared'
+      ;;
+
+    sco3.2v5*)
+      lt_prog_compiler_pic_GCJ='-Kpic'
+      lt_prog_compiler_static_GCJ='-dn'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+       lt_prog_compiler_wl_GCJ='-Qoption ld ';;
+      *)
+       lt_prog_compiler_wl_GCJ='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl_GCJ='-Qoption ld '
+      lt_prog_compiler_pic_GCJ='-PIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+       lt_prog_compiler_pic_GCJ='-Kconform_pic'
+       lt_prog_compiler_static_GCJ='-Bstatic'
+      fi
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      lt_prog_compiler_can_build_shared_GCJ=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic_GCJ='-pic'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared_GCJ=no
+      ;;
+    esac
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_GCJ" >&5
+$as_echo "$lt_prog_compiler_pic_GCJ" >&6; }
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_GCJ"; then
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... " >&6; }
+if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_prog_compiler_pic_works_GCJ=no
+  ac_outfile=conftest.$ac_objext
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13596: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:13600: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_prog_compiler_pic_works_GCJ=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_works_GCJ" >&5
+$as_echo "$lt_prog_compiler_pic_works_GCJ" >&6; }
+
+if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then
+    case $lt_prog_compiler_pic_GCJ in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
+     esac
+else
+    lt_prog_compiler_pic_GCJ=
+     lt_prog_compiler_can_build_shared_GCJ=no
+fi
+
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_GCJ=
+    ;;
+  *)
+    lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ"
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_GCJ=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:13658: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:13662: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
+     $SED '/^$/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_GCJ=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_GCJ" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_GCJ" >&6; }
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  runpath_var=
+  allow_undefined_flag_GCJ=
+  enable_shared_with_static_runtimes_GCJ=no
+  archive_cmds_GCJ=
+  archive_expsym_cmds_GCJ=
+  old_archive_From_new_cmds_GCJ=
+  old_archive_from_expsyms_cmds_GCJ=
+  export_dynamic_flag_spec_GCJ=
+  whole_archive_flag_spec_GCJ=
+  thread_safe_flag_spec_GCJ=
+  hardcode_libdir_flag_spec_GCJ=
+  hardcode_libdir_flag_spec_ld_GCJ=
+  hardcode_libdir_separator_GCJ=
+  hardcode_direct_GCJ=no
+  hardcode_minus_L_GCJ=no
+  hardcode_shlibpath_var_GCJ=unsupported
+  link_all_deplibs_GCJ=unknown
+  hardcode_automatic_GCJ=no
+  module_cmds_GCJ=
+  module_expsym_cmds_GCJ=
+  always_export_symbols_GCJ=no
+  export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms_GCJ=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_"
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs_GCJ=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+       whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+       whole_archive_flag_spec_GCJ=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix3* | aix4* | aix5*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+       ld_shlibs_GCJ=no
+       cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_minus_L_GCJ=yes
+
+      # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+      # that the semantics of dynamic libraries on AmigaOS, at least up
+      # to version 4, is to share data among multiple programs linked
+      # with the same dynamic library.  Since this doesn't match the
+      # behavior of shared libraries on other platforms, we can't use
+      # them.
+      ld_shlibs_GCJ=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       allow_undefined_flag_GCJ=unsupported
+       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+       # support --undefined.  This deserves some investigation.  FIXME
+       archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+       ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      allow_undefined_flag_GCJ=unsupported
+      always_export_symbols_GCJ=no
+      enable_shared_with_static_runtimes_GCJ=yes
+      export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+       # If the export-symbols file already is a .def file (1st line
+       # is EXPORTS), use it as is; otherwise, prepend...
+       archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+         cp $export_symbols $output_objdir/$soname.def;
+       else
+         echo EXPORTS > $output_objdir/$soname.def;
+         cat $export_symbols >> $output_objdir/$soname.def;
+       fi~
+       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+      else
+       ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    linux*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       tmp_addflag=
+       case $cc_basename,$host_cpu in
+       pgcc*)                          # Portland Group C compiler
+         whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag'
+         ;;
+       pgf77* | pgf90* | pgf95*)       # Portland Group f77 and f90 compilers
+         whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag -Mnomain' ;;
+       ecc*,ia64* | icc*,ia64*)                # Intel C compiler on ia64
+         tmp_addflag=' -i_dynamic' ;;
+       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
+         tmp_addflag=' -i_dynamic -nofor_main' ;;
+       ifc* | ifort*)                  # Intel Fortran compiler
+         tmp_addflag=' -nofor_main' ;;
+       esac
+       archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+       if test $supports_anon_versioning = yes; then
+         archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+         $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+       fi
+      else
+       ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+       wlarc=
+      else
+       archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris* | sysv5*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+       ld_shlibs_GCJ=no
+       cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    sunos4*)
+      archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs_GCJ=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs_GCJ" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec_GCJ=
+      export_dynamic_flag_spec_GCJ=
+      whole_archive_flag_spec_GCJ=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag_GCJ=unsupported
+      always_export_symbols_GCJ=yes
+      archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L_GCJ=yes
+      if test "$GCC" = yes && test -z "$link_static_flag"; then
+       # Neither direct hardcoding nor static linking is supported with a
+       # broken collect2.
+       hardcode_direct_GCJ=unsupported
+      fi
+      ;;
+
+    aix4* | aix5*)
+      if test "$host_cpu" = ia64; then
+       # On IA64, the linker does run time linking by default, so we don't
+       # have to do anything special.
+       aix_use_runtimelinking=no
+       exp_sym_flag='-Bexport'
+       no_entry_flag=""
+      else
+       # If we're using GNU nm, then we don't want the "-C" option.
+       # -C means demangle to AIX nm, but means don't demangle with GNU nm
+       if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+         export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+       else
+         export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+       fi
+       aix_use_runtimelinking=no
+
+       # Test if we are trying to use run time linking or normal
+       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+       # need to do runtime linking.
+       case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+         for ld_flag in $LDFLAGS; do
+         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+           aix_use_runtimelinking=yes
+           break
+         fi
+         done
+       esac
+
+       exp_sym_flag='-bexport'
+       no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds_GCJ=''
+      hardcode_direct_GCJ=yes
+      hardcode_libdir_separator_GCJ=':'
+      link_all_deplibs_GCJ=yes
+
+      if test "$GCC" = yes; then
+       case $host_os in aix4.[012]|aix4.[012].*)
+       # We only want to do this on AIX 4.2 and lower, the check
+       # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" && \
+          strings "$collect2name" | grep resolve_lib_name >/dev/null
+         then
+         # We have reworked collect2
+         hardcode_direct_GCJ=yes
+         else
+         # We have old collect2
+         hardcode_direct_GCJ=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         hardcode_minus_L_GCJ=yes
+         hardcode_libdir_flag_spec_GCJ='-L$libdir'
+         hardcode_libdir_separator_GCJ=
+         fi
+       esac
+       shared_flag='-shared'
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag="$shared_flag "'${wl}-G'
+       fi
+      else
+       # not using gcc
+       if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+       else
+       if test "$aix_use_runtimelinking" = yes; then
+           shared_flag='${wl}-G'
+         else
+           shared_flag='${wl}-bM:SRE'
+       fi
+       fi
+      fi
+
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols_GCJ=yes
+      if test "$aix_use_runtimelinking" = yes; then
+       # Warning - without using the other runtime loading flags (-brtl),
+       # -berok will link without error, but may produce a broken library.
+       allow_undefined_flag_GCJ='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+       hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
+       archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+       if test "$host_cpu" = ia64; then
+         hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib'
+         allow_undefined_flag_GCJ="-z nodefs"
+         archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+       else
+        # Determine the default libpath from the value encoded in an empty executable.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+        hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
+         # Warning - without using the other run time loading flags,
+         # -berok will link without error, but may produce a broken library.
+         no_undefined_flag_GCJ=' ${wl}-bernotok'
+         allow_undefined_flag_GCJ=' ${wl}-berok'
+         # -bexpall does not export symbols beginning with underscore (_)
+         always_export_symbols_GCJ=yes
+         # Exported symbols can be pulled into shared objects from archives
+         whole_archive_flag_spec_GCJ=' '
+         archive_cmds_need_lc_GCJ=yes
+         # This is similar to how AIX traditionally builds its shared libraries.
+         archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+       fi
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_minus_L_GCJ=yes
+      # see comment about different semantics on the GNU ld section
+      ld_shlibs_GCJ=no
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec_GCJ=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec_GCJ=' '
+      allow_undefined_flag_GCJ=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_From_new_cmds_GCJ='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes_GCJ=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[012])
+         allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[012])
+               allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      archive_cmds_need_lc_GCJ=no
+      hardcode_direct_GCJ=no
+      hardcode_automatic_GCJ=yes
+      hardcode_shlibpath_var_GCJ=unsupported
+      whole_archive_flag_spec_GCJ=''
+      link_all_deplibs_GCJ=yes
+    if test "$GCC" = yes ; then
+       output_verbose_link_cmd='echo'
+        archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+      archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+         module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         ld_shlibs_GCJ=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    freebsd1*)
+      ld_shlibs_GCJ=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | kfreebsd*-gnu | dragonfly*)
+      archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+       archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+       archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      hardcode_direct_GCJ=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L_GCJ=yes
+      export_dynamic_flag_spec_GCJ='${wl}-E'
+      ;;
+
+    hpux10* | hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*|ia64*)
+         archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       esac
+      else
+       case $host_cpu in
+       hppa*64*|ia64*)
+         archive_cmds_GCJ='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       *)
+         archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       esac
+      fi
+      if test "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*)
+         hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+         hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
+         hardcode_libdir_separator_GCJ=:
+         hardcode_direct_GCJ=no
+         hardcode_shlibpath_var_GCJ=no
+         ;;
+       ia64*)
+         hardcode_libdir_flag_spec_GCJ='-L$libdir'
+         hardcode_direct_GCJ=no
+         hardcode_shlibpath_var_GCJ=no
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         hardcode_minus_L_GCJ=yes
+         ;;
+       *)
+         hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+         hardcode_libdir_separator_GCJ=:
+         hardcode_direct_GCJ=yes
+         export_dynamic_flag_spec_GCJ='${wl}-E'
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         hardcode_minus_L_GCJ=yes
+         ;;
+       esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+       archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir'
+      fi
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      link_all_deplibs_GCJ=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+       archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    newsos6)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    openbsd*)
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+       archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+       hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+       export_dynamic_flag_spec_GCJ='${wl}-E'
+      else
+       case $host_os in
+        openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+          archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+          hardcode_libdir_flag_spec_GCJ='-R$libdir'
+          ;;
+        *)
+          archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+          hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+          ;;
+       esac
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_minus_L_GCJ=yes
+      allow_undefined_flag_GCJ=unsupported
+      archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+       allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       allow_undefined_flag_GCJ=' -expect_unresolved \*'
+       archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      ;;
+
+    osf4* | osf5*)     # as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+       allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      else
+       allow_undefined_flag_GCJ=' -expect_unresolved \*'
+       archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+       $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+
+       # Both c and cxx compiler support -rpath directly
+       hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
+      fi
+      hardcode_libdir_separator_GCJ=:
+      ;;
+
+    sco3.2v5*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_GCJ=no
+      export_dynamic_flag_spec_GCJ='${wl}-Bexport'
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ;;
+
+    solaris*)
+      no_undefined_flag_GCJ=' -z text'
+      if test "$GCC" = yes; then
+       wlarc='${wl}'
+       archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+         $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+       wlarc=''
+       archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+       $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      fi
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+       # The compiler driver will combine linker options so we
+       # cannot just pass the convience library names through
+       # without $wl, iff we do not link with $LD.
+       # Luckily, gcc supports the same syntax we need for Sun Studio.
+       # Supported since Solaris 2.6 (maybe 2.5.1?)
+       case $wlarc in
+       '')
+         whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
+       *)
+         whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
+       esac ;;
+      esac
+      link_all_deplibs_GCJ=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+       # Use $CC to link under sequent, because it throws in some extra .o
+       # files that make .init and .fini sections work.
+       archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+       sni)
+         archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct_GCJ=yes # is this really true???
+       ;;
+       siemens)
+         ## LD is ld it makes a PLAMLIB
+         ## CC just makes a GrossModule.
+         archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+         reload_cmds_GCJ='$CC -r -o $output$reload_objs'
+         hardcode_direct_GCJ=no
+        ;;
+       motorola)
+         archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie
+       ;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_GCJ=no
+      export_dynamic_flag_spec_GCJ='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       hardcode_shlibpath_var_GCJ=no
+       runpath_var=LD_RUN_PATH
+       hardcode_runpath_var=yes
+       ld_shlibs_GCJ=yes
+      fi
+      ;;
+
+    sysv4.2uw2*)
+      archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=no
+      hardcode_shlibpath_var_GCJ=no
+      hardcode_runpath_var=yes
+      runpath_var=LD_RUN_PATH
+      ;;
+
+   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[78]* | unixware7*)
+      no_undefined_flag_GCJ='${wl}-z ${wl}text'
+      if test "$GCC" = yes; then
+       archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds_GCJ='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    sysv5*)
+      no_undefined_flag_GCJ=' -z text'
+      # $CC -shared without GNU ld will not create a library from C++
+      # object files and a static libstdc++, better avoid it by now
+      archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      hardcode_libdir_flag_spec_GCJ=
+      hardcode_shlibpath_var_GCJ=no
+      runpath_var='LD_RUN_PATH'
+      ;;
+
+    uts4*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    *)
+      ld_shlibs_GCJ=no
+      ;;
+    esac
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_GCJ" >&5
+$as_echo "$ld_shlibs_GCJ" >&6; }
+test "$ld_shlibs_GCJ" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_GCJ" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_GCJ=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_GCJ in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+      $rm conftest*
+      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_GCJ
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ
+        allow_undefined_flag_GCJ=
+        if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+        then
+         archive_cmds_need_lc_GCJ=no
+        else
+         archive_cmds_need_lc_GCJ=yes
+        fi
+        allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc_GCJ" >&5
+$as_echo "$archive_cmds_need_lc_GCJ" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix4* | aix5*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+  if test "$GCC" = yes; then
+    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+  else
+    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+  fi
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+kfreebsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  *) # from 3.2 on
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,       ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+knetbsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_GCJ=
+if test -n "$hardcode_libdir_flag_spec_GCJ" || \
+   test -n "$runpath_var_GCJ" || \
+   test "X$hardcode_automatic_GCJ" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct_GCJ" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no &&
+     test "$hardcode_minus_L_GCJ" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_GCJ=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_GCJ=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_GCJ=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_GCJ" >&5
+$as_echo "$hardcode_action_GCJ" >&6; }
+
+if test "$hardcode_action_GCJ" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+       ;;
+   *)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    ;;
+  esac
+fi
+
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+
+fi
+
+   ;;
+
+  *)
+    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_shl_load=yes
+else
+  ac_cv_lib_dld_shl_load=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_svld_dlopen=yes
+else
+  ac_cv_lib_svld_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_dld_link=yes
+else
+  ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = x""yes; then :
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 15530 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      LDFLAGS="$LDFLAGS $link_static_flag"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self_static+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 15628 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler_GCJ \
+    CC_GCJ \
+    LD_GCJ \
+    lt_prog_compiler_wl_GCJ \
+    lt_prog_compiler_pic_GCJ \
+    lt_prog_compiler_static_GCJ \
+    lt_prog_compiler_no_builtin_flag_GCJ \
+    export_dynamic_flag_spec_GCJ \
+    thread_safe_flag_spec_GCJ \
+    whole_archive_flag_spec_GCJ \
+    enable_shared_with_static_runtimes_GCJ \
+    old_archive_cmds_GCJ \
+    old_archive_from_new_cmds_GCJ \
+    predep_objects_GCJ \
+    postdep_objects_GCJ \
+    predeps_GCJ \
+    postdeps_GCJ \
+    compiler_lib_search_path_GCJ \
+    archive_cmds_GCJ \
+    archive_expsym_cmds_GCJ \
+    postinstall_cmds_GCJ \
+    postuninstall_cmds_GCJ \
+    old_archive_from_expsyms_cmds_GCJ \
+    allow_undefined_flag_GCJ \
+    no_undefined_flag_GCJ \
+    export_symbols_cmds_GCJ \
+    hardcode_libdir_flag_spec_GCJ \
+    hardcode_libdir_flag_spec_ld_GCJ \
+    hardcode_libdir_separator_GCJ \
+    hardcode_automatic_GCJ \
+    module_cmds_GCJ \
+    module_expsym_cmds_GCJ \
+    lt_cv_prog_compiler_c_o_GCJ \
+    exclude_expsyms_GCJ \
+    include_expsyms_GCJ; do
+
+    case $var in
+    old_archive_cmds_GCJ | \
+    old_archive_from_new_cmds_GCJ | \
+    archive_cmds_GCJ | \
+    archive_expsym_cmds_GCJ | \
+    module_cmds_GCJ | \
+    module_expsym_cmds_GCJ | \
+    old_archive_from_expsyms_cmds_GCJ | \
+    export_symbols_cmds_GCJ | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="$ofile"
+
+  cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_GCJ
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler_GCJ
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_GCJ
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_GCJ
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_GCJ
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_GCJ
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_GCJ
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds_GCJ
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_GCJ
+archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_GCJ
+module_expsym_cmds=$lt_module_expsym_cmds_GCJ
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_GCJ
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_GCJ
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_GCJ
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_GCJ
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_GCJ
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_GCJ
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_GCJ
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_GCJ
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_GCJ
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_GCJ
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_GCJ
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path_GCJ"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_GCJ
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_GCJ
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_GCJ
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_GCJ
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+       else
+         tagname=""
+       fi
+       ;;
+
+      RC)
+
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+objext_RC=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm conftest*
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${RC-"windres"}
+compiler=$CC
+compiler_RC=$CC
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+lt_cv_prog_compiler_c_o_RC=yes
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler_RC \
+    CC_RC \
+    LD_RC \
+    lt_prog_compiler_wl_RC \
+    lt_prog_compiler_pic_RC \
+    lt_prog_compiler_static_RC \
+    lt_prog_compiler_no_builtin_flag_RC \
+    export_dynamic_flag_spec_RC \
+    thread_safe_flag_spec_RC \
+    whole_archive_flag_spec_RC \
+    enable_shared_with_static_runtimes_RC \
+    old_archive_cmds_RC \
+    old_archive_from_new_cmds_RC \
+    predep_objects_RC \
+    postdep_objects_RC \
+    predeps_RC \
+    postdeps_RC \
+    compiler_lib_search_path_RC \
+    archive_cmds_RC \
+    archive_expsym_cmds_RC \
+    postinstall_cmds_RC \
+    postuninstall_cmds_RC \
+    old_archive_from_expsyms_cmds_RC \
+    allow_undefined_flag_RC \
+    no_undefined_flag_RC \
+    export_symbols_cmds_RC \
+    hardcode_libdir_flag_spec_RC \
+    hardcode_libdir_flag_spec_ld_RC \
+    hardcode_libdir_separator_RC \
+    hardcode_automatic_RC \
+    module_cmds_RC \
+    module_expsym_cmds_RC \
+    lt_cv_prog_compiler_c_o_RC \
+    exclude_expsyms_RC \
+    include_expsyms_RC; do
+
+    case $var in
+    old_archive_cmds_RC | \
+    old_archive_from_new_cmds_RC | \
+    archive_cmds_RC | \
+    archive_expsym_cmds_RC | \
+    module_cmds_RC | \
+    module_expsym_cmds_RC | \
+    old_archive_from_expsyms_cmds_RC | \
+    export_symbols_cmds_RC | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="$ofile"
+
+  cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_RC
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler_RC
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_RC
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_RC
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_RC
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_RC
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_RC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds_RC
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_RC
+archive_expsym_cmds=$lt_archive_expsym_cmds_RC
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_RC
+module_expsym_cmds=$lt_module_expsym_cmds_RC
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_RC
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_RC
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_RC
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_RC
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_RC
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_RC
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_RC
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_RC
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_RC
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_RC
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_RC
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_RC
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_RC
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path_RC"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_RC
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_RC
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_RC
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_RC
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+       ;;
+
+      *)
+       as_fn_error "Unsupported tag name: $tagname" "$LINENO" 5
+       ;;
+      esac
+
+      # Append the new tag name to the list of available tags.
+      if test -n "$tagname" ; then
+      available_tags="$available_tags $tagname"
+    fi
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  # Now substitute the updated list of available tags.
+  if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+    mv "${ofile}T" "$ofile"
+    chmod +x "$ofile"
+  else
+    rm -f "${ofile}T"
+    as_fn_error "unable to update list of available tagged configurations." "$LINENO" 5
+  fi
+fi
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+# Prevent multiple expansion
+
+
+
+
+
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+if test $ac_cv_c_compiler_gnu = yes; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC needs -traditional" >&5
+$as_echo_n "checking whether $CC needs -traditional... " >&6; }
+if test "${ac_cv_prog_gcc_traditional+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+    ac_pattern="Autoconf.*'x'"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sgtty.h>
+Autoconf TIOCGETP
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "$ac_pattern" >/dev/null 2>&1; then :
+  ac_cv_prog_gcc_traditional=yes
+else
+  ac_cv_prog_gcc_traditional=no
+fi
+rm -f conftest*
+
+
+  if test $ac_cv_prog_gcc_traditional = no; then
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <termio.h>
+Autoconf TCGETA
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "$ac_pattern" >/dev/null 2>&1; then :
+  ac_cv_prog_gcc_traditional=yes
+fi
+rm -f conftest*
+
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_gcc_traditional" >&5
+$as_echo "$ac_cv_prog_gcc_traditional" >&6; }
+  if test $ac_cv_prog_gcc_traditional = yes; then
+    CC="$CC -traditional"
+  fi
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for working volatile" >&5
+$as_echo_n "checking for working volatile... " >&6; }
+if test "${ac_cv_c_volatile+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+volatile int x;
+int * volatile y = (int *) 0;
+return !x && !y;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_volatile=yes
+else
+  ac_cv_c_volatile=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5
+$as_echo "$ac_cv_c_volatile" >&6; }
+if test $ac_cv_c_volatile = no; then
+
+$as_echo "#define volatile /**/" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing strerror" >&5
+$as_echo_n "checking for library containing strerror... " >&6; }
+if test "${ac_cv_search_strerror+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char strerror ();
+int
+main ()
+{
+return strerror ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' cposix; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_strerror=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_strerror+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_strerror+set}" = set; then :
+
+else
+  ac_cv_search_strerror=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_strerror" >&5
+$as_echo "$ac_cv_search_strerror" >&6; }
+ac_res=$ac_cv_search_strerror
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+# Extract the first word of "sh", so it can be a program name with args.
+set dummy sh; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_PATH_SH+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PATH_SH in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PATH_SH="$PATH_SH" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PATH_SH="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PATH_SH=$ac_cv_path_PATH_SH
+if test -n "$PATH_SH"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATH_SH" >&5
+$as_echo "$PATH_SH" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+# Extract the first word of "perl", so it can be a program name with args.
+set dummy perl; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_path_PATH_PERL+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $PATH_PERL in
+  [\\/]* | ?:[\\/]*)
+  ac_cv_path_PATH_PERL="$PATH_PERL" # Let the user override the test with a path.
+  ;;
+  *)
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_path_PATH_PERL="$as_dir/$ac_word$ac_exec_ext"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+  ;;
+esac
+fi
+PATH_PERL=$ac_cv_path_PATH_PERL
+if test -n "$PATH_PERL"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $PATH_PERL" >&5
+$as_echo "$PATH_PERL" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#define ACAT(a,b)a ## b
+ACAT(Cir,cus)
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Circus" >/dev/null 2>&1; then :
+  $as_echo "#define ULONG_CONST(a) a ## UL" >>confdefs.h
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#define RCAT(a,b)a/**/b
+RCAT(Rei,ser)
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "Reiser" >/dev/null 2>&1; then :
+  $as_echo "#define ULONG_CONST(a) a/**/L" >>confdefs.h
+
+else
+  as_fn_error "How do we create an unsigned long constant?" "$LINENO" 5
+fi
+rm -f conftest*
+
+fi
+rm -f conftest*
+               # remove for 4.2.5
+
+case "$host" in
+ *-*-vxworks*)
+    ac_link="$ac_link $VX_KERNEL"
+    ;;
+esac
+
+
+
+case "$host" in
+ *-pc-cygwin*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -ladvapi32" >&5
+$as_echo_n "checking for main in -ladvapi32... " >&6; }
+if test "${ac_cv_lib_advapi32_main+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ladvapi32  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+return main ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_advapi32_main=yes
+else
+  ac_cv_lib_advapi32_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_advapi32_main" >&5
+$as_echo "$ac_cv_lib_advapi32_main" >&6; }
+if test "x$ac_cv_lib_advapi32_main" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBADVAPI32 1
+_ACEOF
+
+  LIBS="-ladvapi32 $LIBS"
+
+fi
+
+    ;;
+esac
+
+ac_fn_c_check_func "$LINENO" "gethostent" "ac_cv_func_gethostent"
+if test "x$ac_cv_func_gethostent" = x""yes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostent" >&5
+$as_echo_n "checking for library containing gethostent... " >&6; }
+if test "${ac_cv_search_gethostent+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gethostent ();
+int
+main ()
+{
+return gethostent ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' nsl; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib $libxnet -lsocket $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_gethostent=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_gethostent+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_gethostent+set}" = set; then :
+
+else
+  ac_cv_search_gethostent=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostent" >&5
+$as_echo "$ac_cv_search_gethostent" >&6; }
+ac_res=$ac_cv_search_gethostent
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+ac_fn_c_check_func "$LINENO" "openlog" "ac_cv_func_openlog"
+if test "x$ac_cv_func_openlog" = x""yes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing openlog" >&5
+$as_echo_n "checking for library containing openlog... " >&6; }
+if test "${ac_cv_search_openlog+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char openlog ();
+int
+main ()
+{
+return openlog ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' gen; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_openlog=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_openlog+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_openlog+set}" = set; then :
+
+else
+  ac_cv_search_openlog=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_openlog" >&5
+$as_echo "$ac_cv_search_openlog" >&6; }
+ac_res=$ac_cv_search_openlog
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing openlog" >&5
+$as_echo_n "checking for library containing openlog... " >&6; }
+if test "${ac_cv_search_openlog+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char openlog ();
+int
+main ()
+{
+return openlog ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' syslog; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib $libxnet -lsocket $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_openlog=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_openlog+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_openlog+set}" = set; then :
+
+else
+  ac_cv_search_openlog=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_openlog" >&5
+$as_echo "$ac_cv_search_openlog" >&6; }
+ac_res=$ac_cv_search_openlog
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing MD5Init" >&5
+$as_echo_n "checking for library containing MD5Init... " >&6; }
+if test "${ac_cv_search_MD5Init+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char MD5Init ();
+int
+main ()
+{
+return MD5Init ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' md5 md; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_MD5Init=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_MD5Init+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_MD5Init+set}" = set; then :
+
+else
+  ac_cv_search_MD5Init=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_MD5Init" >&5
+$as_echo "$ac_cv_search_MD5Init" >&6; }
+ac_res=$ac_cv_search_MD5Init
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+for ac_func in MD5Init
+do :
+  ac_fn_c_check_func "$LINENO" "MD5Init" "ac_cv_func_MD5Init"
+if test "x$ac_cv_func_MD5Init" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MD5INIT 1
+_ACEOF
+
+fi
+done
+
+
+# following block becomes on 4.2.5: NTP_LINEEDITLIBS
+for ac_header in readline/history.h readline/readline.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+case "$ac_cv_header_readline_history_h$ac_cv_header_readline_readline_h" in
+ *no*) ;;
+ *) save_LIBS=$LIBS
+    LIBS=
+    # Ralf Wildenhues: either unset ... or cache READLINE_LIBS
+    unset ac_cv_lib_readline_readline
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5
+$as_echo_n "checking for readline in -lreadline... " >&6; }
+if test "${ac_cv_lib_readline_readline+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lreadline  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char readline ();
+int
+main ()
+{
+return readline ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_readline_readline=yes
+else
+  ac_cv_lib_readline_readline=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5
+$as_echo "$ac_cv_lib_readline_readline" >&6; }
+if test "x$ac_cv_lib_readline_readline" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBREADLINE 1
+_ACEOF
+
+  LIBS="-lreadline $LIBS"
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: Trying again with -lcurses" >&5
+$as_echo "$as_me: Trying again with -lcurses" >&6;}
+     unset ac_cv_lib_readline_readline
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -lreadline" >&5
+$as_echo_n "checking for readline in -lreadline... " >&6; }
+if test "${ac_cv_lib_readline_readline+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lreadline -lcurses $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char readline ();
+int
+main ()
+{
+return readline ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_readline_readline=yes
+else
+  ac_cv_lib_readline_readline=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_readline_readline" >&5
+$as_echo "$ac_cv_lib_readline_readline" >&6; }
+if test "x$ac_cv_lib_readline_readline" = x""yes; then :
+  LIBS="-lreadline -lcurses $LIBS"
+      $as_echo "#define HAVE_LIBREADLINE 1" >>confdefs.h
+
+
+$as_echo "#define HAVE_LIBCURSES /**/" >>confdefs.h
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for readline in -ledit" >&5
+$as_echo_n "checking for readline in -ledit... " >&6; }
+if test "${ac_cv_lib_edit_readline+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ledit -lcurses $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char readline ();
+int
+main ()
+{
+return readline ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_edit_readline=yes
+else
+  ac_cv_lib_edit_readline=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_edit_readline" >&5
+$as_echo "$ac_cv_lib_edit_readline" >&6; }
+if test "x$ac_cv_lib_edit_readline" = x""yes; then :
+  LIBS="-ledit -lcurses"
+
+$as_echo "#define HAVE_LIBEDIT /**/" >>confdefs.h
+
+
+$as_echo "#define HAVE_LIBCURSES /**/" >>confdefs.h
+
+
+fi
+
+
+fi
+
+fi
+
+    READLINE_LIBS=$LIBS
+
+    LIBS=$save_LIBS
+    ;;
+esac
+
+
+case "$host" in
+ *-*-*linux*) ;;
+ *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_setscheduler in -lrt" >&5
+$as_echo_n "checking for sched_setscheduler in -lrt... " >&6; }
+if test "${ac_cv_lib_rt_sched_setscheduler+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lrt  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char sched_setscheduler ();
+int
+main ()
+{
+return sched_setscheduler ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_rt_sched_setscheduler=yes
+else
+  ac_cv_lib_rt_sched_setscheduler=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_rt_sched_setscheduler" >&5
+$as_echo "$ac_cv_lib_rt_sched_setscheduler" >&6; }
+if test "x$ac_cv_lib_rt_sched_setscheduler" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBRT 1
+_ACEOF
+
+  LIBS="-lrt $LIBS"
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sched_setscheduler in -lposix4" >&5
+$as_echo_n "checking for sched_setscheduler in -lposix4... " >&6; }
+if test "${ac_cv_lib_posix4_sched_setscheduler+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lposix4  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char sched_setscheduler ();
+int
+main ()
+{
+return sched_setscheduler ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_posix4_sched_setscheduler=yes
+else
+  ac_cv_lib_posix4_sched_setscheduler=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_posix4_sched_setscheduler" >&5
+$as_echo "$ac_cv_lib_posix4_sched_setscheduler" >&6; }
+if test "x$ac_cv_lib_posix4_sched_setscheduler" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBPOSIX4 1
+_ACEOF
+
+  LIBS="-lposix4 $LIBS"
+
+fi
+
+fi
+
+    ;;
+esac
+
+ac_fn_c_check_func "$LINENO" "setsockopt" "ac_cv_func_setsockopt"
+if test "x$ac_cv_func_setsockopt" = x""yes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing setsockopt" >&5
+$as_echo_n "checking for library containing setsockopt... " >&6; }
+if test "${ac_cv_search_setsockopt+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char setsockopt ();
+int
+main ()
+{
+return setsockopt ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' socket xnet; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_setsockopt=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_setsockopt+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_setsockopt+set}" = set; then :
+
+else
+  ac_cv_search_setsockopt=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_setsockopt" >&5
+$as_echo "$ac_cv_search_setsockopt" >&6; }
+ac_res=$ac_cv_search_setsockopt
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+for ac_header in bstring.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "bstring.h" "ac_cv_header_bstring_h" "$ac_includes_default"
+if test "x$ac_cv_header_bstring_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_BSTRING_H 1
+_ACEOF
+
+fi
+
+done
+
+ac_fn_c_check_header_mongrel "$LINENO" "dns_sd.h" "ac_cv_header_dns_sd_h" "$ac_includes_default"
+if test "x$ac_cv_header_dns_sd_h" = x""yes; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for DNSServiceRegister in -ldns_sd" >&5
+$as_echo_n "checking for DNSServiceRegister in -ldns_sd... " >&6; }
+if test "${ac_cv_lib_dns_sd_DNSServiceRegister+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldns_sd  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char DNSServiceRegister ();
+int
+main ()
+{
+return DNSServiceRegister ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dns_sd_DNSServiceRegister=yes
+else
+  ac_cv_lib_dns_sd_DNSServiceRegister=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dns_sd_DNSServiceRegister" >&5
+$as_echo "$ac_cv_lib_dns_sd_DNSServiceRegister" >&6; }
+if test "x$ac_cv_lib_dns_sd_DNSServiceRegister" = x""yes; then :
+
+$as_echo "#define HAVE_DNSREGISTRATION 1" >>confdefs.h
+
+fi
+
+fi
+
+
+case "$ac_cv_lib_dns_sd_DNSServiceRegister" in
+ yes) LIBS="-ldns_sd $LIBS" ;;
+esac
+for ac_header in errno.h fcntl.h ieeefp.h math.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+# HMS: Lame, but fast.
+if test -f /etc/redhat-release
+then
+    :
+else
+    for ac_header in md5.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "md5.h" "ac_cv_header_md5_h" "#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+
+"
+if test "x$ac_cv_header_md5_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MD5_H 1
+_ACEOF
+
+fi
+
+done
+
+fi
+for ac_header in memory.h netdb.h poll.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sched.h sgtty.h stdlib.h string.h termio.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in termios.h timepps.h timex.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+case "$host" in
+ *-*-aix*)
+    for ac_header in utmpx.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "utmpx.h" "ac_cv_header_utmpx_h" "$ac_includes_default"
+if test "x$ac_cv_header_utmpx_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_UTMPX_H 1
+_ACEOF
+
+fi
+
+done
+
+    case "$ac_cv_header_utmpx_h" in
+     yes) ;;
+     *) for ac_header in utmp.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "utmp.h" "ac_cv_header_utmp_h" "$ac_includes_default"
+if test "x$ac_cv_header_utmp_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_UTMP_H 1
+_ACEOF
+
+fi
+
+done
+ ;;
+    esac
+    ;;
+ *) for ac_header in utmp.h utmpx.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+ ;;
+esac
+for ac_header in arpa/nameser.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "arpa/nameser.h" "ac_cv_header_arpa_nameser_h" "$ac_includes_default"
+if test "x$ac_cv_header_arpa_nameser_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_ARPA_NAMESER_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sys/socket.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/socket.h" "ac_cv_header_sys_socket_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_socket_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_SOCKET_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in net/if.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "net/if.h" "ac_cv_header_net_if_h" "#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+
+"
+if test "x$ac_cv_header_net_if_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_NET_IF_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in net/if6.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "net/if6.h" "ac_cv_header_net_if6_h" "$ac_includes_default"
+if test "x$ac_cv_header_net_if6_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_NET_IF6_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in net/route.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "net/route.h" "ac_cv_header_net_route_h" "
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+
+"
+if test "x$ac_cv_header_net_route_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_NET_ROUTE_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in netinet/in_system.h netinet/in_systm.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in netinet/in.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "netinet/in.h" "ac_cv_header_netinet_in_h" "$ac_includes_default"
+if test "x$ac_cv_header_netinet_in_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_NETINET_IN_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in netinet/ip.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "netinet/ip.h" "ac_cv_header_netinet_ip_h" "#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
+
+"
+if test "x$ac_cv_header_netinet_ip_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_NETINET_IP_H 1
+_ACEOF
+
+fi
+
+done
+
+
+# Check for IPTOS_PREC
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking IPPROTO_IP IP_TOS IPTOS_LOWDELAY" >&5
+$as_echo_n "checking IPPROTO_IP IP_TOS IPTOS_LOWDELAY... " >&6; }
+if test "${ac_cv_ip_tos+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+               #if HAVE_SYS_TYPES_H
+               #include <sys/types.h>
+               #endif
+               #if HAVE_NETINET_IP_H
+               #include <netinet/in.h>
+               #include <netinet/ip.h>
+               #endif
+               #if defined(IPPROTO_IP) && defined(IP_TOS) && defined(IPTOS_LOWDELAY)
+                 yes
+               #endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ac_cv_ip_tos=yes
+else
+  ac_cv_ip_tos=no
+
+fi
+rm -f conftest*
+
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_ip_tos" >&5
+$as_echo "$ac_cv_ip_tos" >&6; }
+
+case "$ac_cv_ip_tos" in
+ yes)
+
+$as_echo "#define HAVE_IPTOS_SUPPORT 1" >>confdefs.h
+
+esac
+
+for ac_header in netinfo/ni.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "netinfo/ni.h" "ac_cv_header_netinfo_ni_h" "$ac_includes_default"
+if test "x$ac_cv_header_netinfo_ni_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_NETINFO_NI_H 1
+_ACEOF
+
+$as_echo "#define HAVE_NETINFO 1" >>confdefs.h
+
+fi
+
+done
+
+for ac_header in sun/audioio.h sys/audioio.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sys/clkdefs.h sys/file.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+case "$host" in
+ *-*-sunos4*) ;;
+ *) for ac_header in sys/ioctl.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/ioctl.h" "ac_cv_header_sys_ioctl_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_ioctl_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_IOCTL_H 1
+_ACEOF
+
+fi
+
+done
+
+    ;;
+esac
+for ac_header in sys/ipc.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/ipc.h" "ac_cv_header_sys_ipc_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_ipc_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_IPC_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sys/lock.h sys/mman.h sys/modem.h sys/param.h sys/ppsclock.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+# HMS: Check sys/proc.h and sys/resource.h after some others
+for ac_header in sys/ppstime.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/ppstime.h" "ac_cv_header_sys_ppstime_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_ppstime_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_PPSTIME_H 1
+_ACEOF
+
+fi
+
+done
+
+case "$ac_cv_header_sched_h" in
+ yes) ;;
+ *) for ac_header in sys/sched.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/sched.h" "ac_cv_header_sys_sched_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_sched_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_SCHED_H 1
+_ACEOF
+
+fi
+
+done
+ ;;
+esac
+case "$host" in
+ *-*-sco*)
+    for ac_header in sys/sio.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/sio.h" "ac_cv_header_sys_sio_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_sio_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_SIO_H 1
+_ACEOF
+
+fi
+
+done
+
+    ;;
+esac
+# HMS: Check sys/shm.h after some others
+for ac_header in sys/select.h sys/signal.h sys/sockio.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+# HMS: Checked sys/socket.h earlier
+case "$host" in
+ *-*-netbsd*) ;;
+ *) for ac_header in machine/soundcard.h sys/soundcard.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+    ;;
+esac
+for ac_header in sys/stat.h sys/stream.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sys/stropts.h sys/sysctl.h sys/syssgi.h sys/systune.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sys/termios.h sys/time.h sys/signal.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#if HAVE_ERRNO_H
+# include <errno.h>
+#endif
+#include <sys/timepps.h>
+#ifdef PPS_API_VERS_1
+yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  for ac_header in sys/timepps.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "sys/timepps.h" "ac_cv_header_sys_timepps_h" "#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#if HAVE_ERRNO_H
+# include <errno.h>
+#endif
+
+"
+if test "x$ac_cv_header_sys_timepps_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_TIMEPPS_H 1
+_ACEOF
+
+fi
+
+done
+
+
+fi
+rm -f conftest*
+
+for ac_header in sys/timers.h sys/tpro.h sys/types.h sys/wait.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
+$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
+if test "${ac_cv_header_time+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_time=yes
+else
+  ac_cv_header_time=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
+$as_echo "$ac_cv_header_time" >&6; }
+if test $ac_cv_header_time = yes; then
+
+$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
+
+fi
+
+case "$host" in
+*-convex-*)
+  for ac_header in /sys/sync/queue.h /sys/sync/sema.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+  ;;
+*-*-bsdi*)
+  for ac_header in machine/inline.h sys/pcl720.h sys/i8253.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+  ;;
+esac
+
+case "$host" in
+ *-*-*linux*)
+    for ac_func in __adjtimex __ntp_gettime
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+    ;;
+esac
+case "$ac_cv_func___adjtimex" in
+ yes) ;;
+ *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nlist in -lelf" >&5
+$as_echo_n "checking for nlist in -lelf... " >&6; }
+if test "${ac_cv_lib_elf_nlist+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lelf  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char nlist ();
+int
+main ()
+{
+return nlist ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_elf_nlist=yes
+else
+  ac_cv_lib_elf_nlist=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_elf_nlist" >&5
+$as_echo "$ac_cv_lib_elf_nlist" >&6; }
+if test "x$ac_cv_lib_elf_nlist" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBELF 1
+_ACEOF
+
+  LIBS="-lelf $LIBS"
+
+fi
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lkvm" >&5
+$as_echo_n "checking for main in -lkvm... " >&6; }
+if test "${ac_cv_lib_kvm_main+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lkvm  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+int
+main ()
+{
+return main ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_kvm_main=yes
+else
+  ac_cv_lib_kvm_main=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_kvm_main" >&5
+$as_echo "$ac_cv_lib_kvm_main" >&6; }
+if test "x$ac_cv_lib_kvm_main" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBKVM 1
+_ACEOF
+
+  LIBS="-lkvm $LIBS"
+
+fi
+                   { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nlist in -lld" >&5
+$as_echo_n "checking for nlist in -lld... " >&6; }
+if test "${ac_cv_lib_ld_nlist+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char nlist ();
+int
+main ()
+{
+return nlist ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_ld_nlist=yes
+else
+  ac_cv_lib_ld_nlist=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ld_nlist" >&5
+$as_echo "$ac_cv_lib_ld_nlist" >&6; }
+if test "x$ac_cv_lib_ld_nlist" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBLD 1
+_ACEOF
+
+  LIBS="-lld $LIBS"
+
+fi
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for nlist in -lmld" >&5
+$as_echo_n "checking for nlist in -lmld... " >&6; }
+if test "${ac_cv_lib_mld_nlist+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lmld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char nlist ();
+int
+main ()
+{
+return nlist ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_mld_nlist=yes
+else
+  ac_cv_lib_mld_nlist=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_mld_nlist" >&5
+$as_echo "$ac_cv_lib_mld_nlist" >&6; }
+if test "x$ac_cv_lib_mld_nlist" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBMLD 1
+_ACEOF
+
+  LIBS="-lmld $LIBS"
+
+fi
+
+    ac_fn_c_check_header_mongrel "$LINENO" "nlist.h" "ac_cv_header_nlist_h" "$ac_includes_default"
+if test "x$ac_cv_header_nlist_h" = x""yes; then :
+
+$as_echo "#define NLIST_STRUCT 1" >>confdefs.h
+
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking for n_un in struct nlist" >&5
+$as_echo_n "checking for n_un in struct nlist... " >&6; }
+if test "${ac_cv_struct_nlist_n_un+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <nlist.h>
+int
+main ()
+{
+struct nlist n; n.n_un.n_name = 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_nlist_n_un=yes
+else
+  ac_cv_struct_nlist_n_un=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_nlist_n_un" >&5
+$as_echo "$ac_cv_struct_nlist_n_un" >&6; }
+     if test $ac_cv_struct_nlist_n_un = yes; then
+
+$as_echo "#define NLIST_NAME_UNION 1" >>confdefs.h
+
+     fi
+
+fi
+
+    ;;
+esac
+
+
+for ac_header in sys/proc.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "sys/proc.h" "ac_cv_header_sys_proc_h" "#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+
+"
+if test "x$ac_cv_header_sys_proc_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_PROC_H 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/resource.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "sys/resource.h" "ac_cv_header_sys_resource_h" "#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+
+"
+if test "x$ac_cv_header_sys_resource_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_RESOURCE_H 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/shm.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "sys/shm.h" "ac_cv_header_sys_shm_h" "#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_IPC_H
+# include <sys/ipc.h>
+#endif
+
+"
+if test "x$ac_cv_header_sys_shm_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_SHM_H 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in sys/timex.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "sys/timex.h" "ac_cv_header_sys_timex_h" "#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+
+"
+if test "x$ac_cv_header_sys_timex_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_TIMEX_H 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in resolv.h
+do :
+  ac_fn_c_check_header_compile "$LINENO" "resolv.h" "ac_cv_header_resolv_h" "#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+
+"
+if test "x$ac_cv_header_resolv_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_RESOLV_H 1
+_ACEOF
+
+fi
+
+done
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for basic volatile support" >&5
+$as_echo_n "checking for basic volatile support... " >&6; }
+if test "${ac_cv_c_volatile+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+volatile int x;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_volatile=yes
+else
+  ac_cv_c_volatile=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_volatile" >&5
+$as_echo "$ac_cv_c_volatile" >&6; }
+case "$ac_cv_c_volatile" in
+ yes)
+    ;;
+ *)
+$as_echo "#define volatile /**/" >>confdefs.h
+
+    ;;
+esac
+
+#
+# following block goes away in 4.2.5
+#
+# AM_C_PROTOTYPES gives us ansi2knr
+case "$build" in
+ *-*-solaris2*)
+    # Assume that solaris2 is Ansi C...
+    ;;
+ *)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for function prototypes" >&5
+$as_echo_n "checking for function prototypes... " >&6; }
+if test "$ac_cv_prog_cc_c89" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+$as_echo "#define PROTOTYPES 1" >>confdefs.h
+
+
+$as_echo "#define __PROTOTYPES 1" >>confdefs.h
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+if test "$ac_cv_prog_cc_stdc" != no; then
+  U= ANSI2KNR=
+else
+  U=_ ANSI2KNR=./ansi2knr
+fi
+# Ensure some checks needed by ansi2knr itself.
+
+for ac_header in string.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "string.h" "ac_cv_header_string_h" "$ac_includes_default"
+if test "x$ac_cv_header_string_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STRING_H 1
+_ACEOF
+
+fi
+
+done
+
+
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if C compiler permits function prototypes" >&5
+$as_echo_n "checking if C compiler permits function prototypes... " >&6; }
+if test "${ac_cv_have_prototypes+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+extern int foo (short);
+int foo(short i) { return i; }
+int
+main ()
+{
+
+int i;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_have_prototypes=yes
+else
+  ac_cv_have_prototypes=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_prototypes" >&5
+$as_echo "$ac_cv_have_prototypes" >&6; }
+if test "$ac_cv_have_prototypes" = yes; then
+
+$as_echo "#define HAVE_PROTOTYPES 1" >>confdefs.h
+
+fi
+#
+# end block
+#
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
+$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
+if test "${ac_cv_c_const+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this.  */
+  typedef int charset[2];
+  const charset cs;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *pcpcc;
+  char **ppc;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  pcpcc = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++pcpcc;
+  ppc = (char**) pcpcc;
+  pcpcc = (char const *const *) ppc;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+    if (s) return 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+    if (!foo) return 0;
+  }
+  return !cs[0] && !zero.x;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_const=yes
+else
+  ac_cv_c_const=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
+$as_echo "$ac_cv_c_const" >&6; }
+if test $ac_cv_c_const = no; then
+
+$as_echo "#define const /**/" >>confdefs.h
+
+fi
+
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether byte ordering is bigendian" >&5
+$as_echo_n "checking whether byte ordering is bigendian... " >&6; }
+if test "${ac_cv_c_bigendian+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_c_bigendian=unknown
+    # See if we're dealing with a universal compiler.
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef __APPLE_CC__
+              not a universal capable compiler
+            #endif
+            typedef int dummy;
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+       # Check for potential -arch flags.  It is not universal unless
+       # there are at least two -arch flags with different values.
+       ac_arch=
+       ac_prev=
+       for ac_word in $CC $CFLAGS $CPPFLAGS $LDFLAGS; do
+        if test -n "$ac_prev"; then
+          case $ac_word in
+            i?86 | x86_64 | ppc | ppc64)
+              if test -z "$ac_arch" || test "$ac_arch" = "$ac_word"; then
+                ac_arch=$ac_word
+              else
+                ac_cv_c_bigendian=universal
+                break
+              fi
+              ;;
+          esac
+          ac_prev=
+        elif test "x$ac_word" = "x-arch"; then
+          ac_prev=arch
+        fi
+       done
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    if test $ac_cv_c_bigendian = unknown; then
+      # See if sys/param.h defines the BYTE_ORDER macro.
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+            #include <sys/param.h>
+
+int
+main ()
+{
+#if ! (defined BYTE_ORDER && defined BIG_ENDIAN \
+                    && defined LITTLE_ENDIAN && BYTE_ORDER && BIG_ENDIAN \
+                    && LITTLE_ENDIAN)
+             bogus endian macros
+            #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  # It does; now see whether it defined to BIG_ENDIAN or not.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+               #include <sys/param.h>
+
+int
+main ()
+{
+#if BYTE_ORDER != BIG_ENDIAN
+                not big endian
+               #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_bigendian=yes
+else
+  ac_cv_c_bigendian=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    fi
+    if test $ac_cv_c_bigendian = unknown; then
+      # See if <limits.h> defines _LITTLE_ENDIAN or _BIG_ENDIAN (e.g., Solaris).
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+
+int
+main ()
+{
+#if ! (defined _LITTLE_ENDIAN || defined _BIG_ENDIAN)
+             bogus endian macros
+            #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  # It does; now see whether it defined to _BIG_ENDIAN or not.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+
+int
+main ()
+{
+#ifndef _BIG_ENDIAN
+                not big endian
+               #endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_bigendian=yes
+else
+  ac_cv_c_bigendian=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+    fi
+    if test $ac_cv_c_bigendian = unknown; then
+      # Compile a test program.
+      if test "$cross_compiling" = yes; then :
+  # Try to guess by grepping values from an object file.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+short int ascii_mm[] =
+                 { 0x4249, 0x4765, 0x6E44, 0x6961, 0x6E53, 0x7953, 0 };
+               short int ascii_ii[] =
+                 { 0x694C, 0x5454, 0x656C, 0x6E45, 0x6944, 0x6E61, 0 };
+               int use_ascii (int i) {
+                 return ascii_mm[i] + ascii_ii[i];
+               }
+               short int ebcdic_ii[] =
+                 { 0x89D3, 0xE3E3, 0x8593, 0x95C5, 0x89C4, 0x9581, 0 };
+               short int ebcdic_mm[] =
+                 { 0xC2C9, 0xC785, 0x95C4, 0x8981, 0x95E2, 0xA8E2, 0 };
+               int use_ebcdic (int i) {
+                 return ebcdic_mm[i] + ebcdic_ii[i];
+               }
+               extern int foo;
+
+int
+main ()
+{
+return use_ascii (foo) == use_ebcdic (foo);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  if grep BIGenDianSyS conftest.$ac_objext >/dev/null; then
+             ac_cv_c_bigendian=yes
+           fi
+           if grep LiTTleEnDian conftest.$ac_objext >/dev/null ; then
+             if test "$ac_cv_c_bigendian" = unknown; then
+               ac_cv_c_bigendian=no
+             else
+               # finding both strings is unlikely to happen, but who knows?
+               ac_cv_c_bigendian=unknown
+             fi
+           fi
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+
+            /* Are we little or big endian?  From Harbison&Steele.  */
+            union
+            {
+              long int l;
+              char c[sizeof (long int)];
+            } u;
+            u.l = 1;
+            return u.c[sizeof (long int) - 1] == 1;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  ac_cv_c_bigendian=no
+else
+  ac_cv_c_bigendian=yes
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+    fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_bigendian" >&5
+$as_echo "$ac_cv_c_bigendian" >&6; }
+ case $ac_cv_c_bigendian in #(
+   yes)
+     $as_echo "#define WORDS_BIGENDIAN 1" >>confdefs.h
+;; #(
+   no)
+      ;; #(
+   universal)
+
+$as_echo "#define AC_APPLE_UNIVERSAL_BUILD 1" >>confdefs.h
+
+     ;; #(
+   *)
+     as_fn_error "unknown endianness
+ presetting ac_cv_c_bigendian=no (or yes) will help" "$LINENO" 5 ;;
+ esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
+$as_echo_n "checking return type of signal handlers... " >&6; }
+if test "${ac_cv_type_signal+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <signal.h>
+
+int
+main ()
+{
+return *(signal (0, 0)) (0) == 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_type_signal=int
+else
+  ac_cv_type_signal=void
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5
+$as_echo "$ac_cv_type_signal" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define RETSIGTYPE $ac_cv_type_signal
+_ACEOF
+
+
+ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default"
+if test "x$ac_cv_type_off_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define off_t long int
+_ACEOF
+
+fi
+
+ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
+if test "x$ac_cv_type_size_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned int
+_ACEOF
+
+fi
+
+ac_fn_c_check_type "$LINENO" "time_t" "ac_cv_type_time_t" "$ac_includes_default"
+if test "x$ac_cv_type_time_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define time_t long
+_ACEOF
+
+fi
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of time_t" >&5
+$as_echo_n "checking size of time_t... " >&6; }
+if test "${ac_cv_sizeof_time_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (time_t))" "ac_cv_sizeof_time_t"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_time_t" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (time_t)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_time_t=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_time_t" >&5
+$as_echo "$ac_cv_sizeof_time_t" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_TIME_T $ac_cv_sizeof_time_t
+_ACEOF
+
+
+ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_uintptr_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINTPTR_T 1
+_ACEOF
+
+
+fi
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5
+$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; }
+if test "${ac_cv_struct_tm+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <time.h>
+
+int
+main ()
+{
+struct tm tm;
+                                    int *p = &tm.tm_sec;
+                                    return !p;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_tm=time.h
+else
+  ac_cv_struct_tm=sys/time.h
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5
+$as_echo "$ac_cv_struct_tm" >&6; }
+if test $ac_cv_struct_tm = sys/time.h; then
+
+$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for u_int8_t" >&5
+$as_echo_n "checking for u_int8_t... " >&6; }
+if test "${ac_cv_type_u_int8_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+int
+main ()
+{
+u_int8_t len = 42; return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_type_u_int8_t=yes
+else
+  ac_cv_type_u_int8_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_u_int8_t" >&5
+$as_echo "$ac_cv_type_u_int8_t" >&6; }
+if test $ac_cv_type_u_int8_t = yes; then
+
+$as_echo "#define HAVE_TYPE_U_INT8_T 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for u_int64_t" >&5
+$as_echo_n "checking for u_int64_t... " >&6; }
+if test "${ac_cv_type_u_int64_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+int
+main ()
+{
+u_int64_t len = 42; return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_type_u_int64_t=yes
+else
+  ac_cv_type_u_int64_t=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_u_int64_t" >&5
+$as_echo "$ac_cv_type_u_int64_t" >&6; }
+if test $ac_cv_type_u_int64_t = yes; then
+
+$as_echo "#define HAVE_TYPE_U_INT64_T 1" >>confdefs.h
+
+fi
+
+#
+# Look for in_port_t.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for in_port_t" >&5
+$as_echo_n "checking for in_port_t... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <netinet/in.h>
+int
+main ()
+{
+in_port_t port = 25; return (0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+
+$as_echo "#define ISC_PLATFORM_NEEDPORTT 1" >>confdefs.h
+
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a fallback value for HZ" >&5
+$as_echo_n "checking for a fallback value for HZ... " >&6; }
+if test "${ac_cv_var_default_hz+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_var_default_hz=100
+case "$host" in
+ alpha*-dec-osf4*|alpha*-dec-osf5*)
+    ac_cv_var_default_hz=1024
+    ;;
+ mips-dec-ultrix4*)
+    ac_cv_var_default_hz=256
+    ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_default_hz" >&5
+$as_echo "$ac_cv_var_default_hz" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define DEFAULT_HZ $ac_cv_var_default_hz
+_ACEOF
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need to override the system's value for HZ" >&5
+$as_echo_n "checking if we need to override the system's value for HZ... " >&6; }
+if test "${ac_cv_var_override_hz+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_var_override_hz=no
+case "$host" in
+ alpha*-dec-osf4*|alpha*-dec-osf5*)
+    ac_cv_var_override_hz=yes
+    ;;
+ mips-dec-ultrix4*)
+    ac_cv_var_override_hz=yes
+    ;;
+ *-*-freebsd*)
+    ac_cv_var_override_hz=yes
+    ;;
+ *-*-sunos4*)
+    ac_cv_var_override_hz=yes
+    ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_override_hz" >&5
+$as_echo "$ac_cv_var_override_hz" >&6; }
+case "$ac_cv_var_override_hz" in
+ yes)
+
+$as_echo "#define OVERRIDE_HZ 1" >>confdefs.h
+
+    ;;
+esac
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct rt_msghdr" >&5
+$as_echo_n "checking for struct rt_msghdr... " >&6; }
+if test "${ac_cv_struct_rt_msghdr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/route.h>
+int
+main ()
+{
+struct rt_msghdr p;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_rt_msghdr=yes
+else
+  ac_cv_struct_rt_msghdr=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_rt_msghdr" >&5
+$as_echo "$ac_cv_struct_rt_msghdr" >&6; }
+
+if test $ac_cv_struct_rt_msghdr = yes; then
+
+$as_echo "#define HAS_ROUTING_SOCKET 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking struct sigaction for sa_sigaction" >&5
+$as_echo_n "checking struct sigaction for sa_sigaction... " >&6; }
+if test "${ac_cv_struct_sigaction_has_sa_sigaction+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <signal.h>
+int
+main ()
+{
+struct sigaction act; act.sa_sigaction = 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_sigaction_has_sa_sigaction=yes
+else
+  ac_cv_struct_sigaction_has_sa_sigaction=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_sigaction_has_sa_sigaction" >&5
+$as_echo "$ac_cv_struct_sigaction_has_sa_sigaction" >&6; }
+if test $ac_cv_struct_sigaction_has_sa_sigaction = yes; then
+
+$as_echo "#define HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct ppsclockev" >&5
+$as_echo_n "checking for struct ppsclockev... " >&6; }
+if test "${ac_cv_struct_ppsclockev+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#ifdef HAVE_SYS_TERMIOS_H
+# include <sys/termios.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_PPSCLOCK_H
+# include <sys/ppsclock.h>
+#endif
+int
+main ()
+{
+
+extern struct ppsclockev *pce;
+return pce->serial;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_ppsclockev=yes
+else
+  ac_cv_struct_ppsclockev=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_ppsclockev" >&5
+$as_echo "$ac_cv_struct_ppsclockev" >&6; }
+if test $ac_cv_struct_ppsclockev = yes; then
+
+$as_echo "#define HAVE_STRUCT_PPSCLOCKEV 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking struct sockaddr for sa_len" >&5
+$as_echo_n "checking struct sockaddr for sa_len... " >&6; }
+if test "${ac_cv_struct_sockaddr_has_sa_len+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+int
+main ()
+{
+
+extern struct sockaddr *ps;
+return ps->sa_len;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_sockaddr_has_sa_len=yes
+else
+  ac_cv_struct_sockaddr_has_sa_len=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_sockaddr_has_sa_len" >&5
+$as_echo "$ac_cv_struct_sockaddr_has_sa_len" >&6; }
+if test $ac_cv_struct_sockaddr_has_sa_len = yes; then
+
+$as_echo "#define HAVE_SA_LEN_IN_STRUCT_SOCKADDR 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct sockaddr_storage" >&5
+$as_echo_n "checking for struct sockaddr_storage... " >&6; }
+if test "${ac_cv_struct_sockaddr_storage+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+int
+main ()
+{
+
+struct sockaddr_storage n;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_sockaddr_storage=yes
+else
+  ac_cv_struct_sockaddr_storage=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_sockaddr_storage" >&5
+$as_echo "$ac_cv_struct_sockaddr_storage" >&6; }
+if test $ac_cv_struct_sockaddr_storage = yes; then
+
+$as_echo "#define HAVE_STRUCT_SOCKADDR_STORAGE 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ss_family field in struct sockaddr_storage" >&5
+$as_echo_n "checking for ss_family field in struct sockaddr_storage... " >&6; }
+if test "${ac_cv_have_ss_family_in_struct_ss+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+main ()
+{
+ struct sockaddr_storage s; s.ss_family = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+   ac_cv_have_ss_family_in_struct_ss="yes"
+else
+   ac_cv_have_ss_family_in_struct_ss="no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_ss_family_in_struct_ss" >&5
+$as_echo "$ac_cv_have_ss_family_in_struct_ss" >&6; }
+if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
+
+$as_echo "#define HAVE_SS_FAMILY_IN_SS 1" >>confdefs.h
+
+else
+    # Hack around a problem...
+    # HMS: This is $host because we need the -D if we are building *for* it.
+    # HMS: 061029: Now that we separate the ss_* checks this is causing
+    # a problem - disable it until we get to the bottom of it.
+    case "$host" in
+     XXX*-*-hpux11.11) CPPFLAGS="$CPPFLAGS -D_NETINET_IN6_H"
+       ;;
+    esac
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __ss_family field in struct sockaddr_storage" >&5
+$as_echo_n "checking for __ss_family field in struct sockaddr_storage... " >&6; }
+if test "${ac_cv_have___ss_family_in_struct_ss+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+main ()
+{
+ struct sockaddr_storage s; s.__ss_family = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+   ac_cv_have___ss_family_in_struct_ss="yes"
+else
+   ac_cv_have___ss_family_in_struct_ss="no"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have___ss_family_in_struct_ss" >&5
+$as_echo "$ac_cv_have___ss_family_in_struct_ss" >&6; }
+if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
+
+$as_echo "#define HAVE___SS_FAMILY_IN_SS 1" >>confdefs.h
+
+fi
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ss_len field in struct sockaddr_storage" >&5
+$as_echo_n "checking for ss_len field in struct sockaddr_storage... " >&6; }
+if test "${ac_cv_have_ss_len_in_struct_ss+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+main ()
+{
+ struct sockaddr_storage s; s.ss_len = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+   ac_cv_have_ss_len_in_struct_ss="yes"
+else
+   ac_cv_have_ss_len_in_struct_ss="no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_ss_len_in_struct_ss" >&5
+$as_echo "$ac_cv_have_ss_len_in_struct_ss" >&6; }
+if test "x$ac_cv_have_ss_len_in_struct_ss" = "xyes" ; then
+
+$as_echo "#define HAVE_SS_LEN_IN_SS 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __ss_len field in struct sockaddr_storage" >&5
+$as_echo_n "checking for __ss_len field in struct sockaddr_storage... " >&6; }
+if test "${ac_cv_have___ss_len_in_struct_ss+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+main ()
+{
+ struct sockaddr_storage s; s.__ss_len = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+   ac_cv_have___ss_len_in_struct_ss="yes"
+else
+   ac_cv_have___ss_len_in_struct_ss="no"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have___ss_len_in_struct_ss" >&5
+$as_echo "$ac_cv_have___ss_len_in_struct_ss" >&6; }
+if test "x$ac_cv_have___ss_len_in_struct_ss" = "xyes" ; then
+
+$as_echo "#define HAVE___SS_LEN_IN_SS 1" >>confdefs.h
+
+fi
+
+
+
+case "$ac_cv_header_machine_soundcard_h$ac_cv_header_sys_soundcard_h" in
+  *yes*)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct snd_size" >&5
+$as_echo_n "checking for struct snd_size... " >&6; }
+if test "${ac_cv_struct_snd_size+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef HAVE_MACHINE_SOUNDCARD_H
+# include <machine/soundcard.h>
+#endif
+#ifdef HAVE_SYS_SOUNDCARD_H
+# include <sys/soundcard.h>
+#endif
+int
+main ()
+{
+
+extern struct snd_size *ss;
+return ss->rec_size;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_snd_size=yes
+else
+  ac_cv_struct_snd_size=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_snd_size" >&5
+$as_echo "$ac_cv_struct_snd_size" >&6; }
+    case "$ac_cv_struct_snd_size" in
+     yes)
+$as_echo "#define HAVE_STRUCT_SND_SIZE 1" >>confdefs.h
+ ;;
+    esac
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking struct clockinfo for hz" >&5
+$as_echo_n "checking struct clockinfo for hz... " >&6; }
+if test "${ac_cv_struct_clockinfo_has_hz+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/time.h>
+int
+main ()
+{
+
+extern struct clockinfo *pc;
+return pc->hz;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_clockinfo_has_hz=yes
+else
+  ac_cv_struct_clockinfo_has_hz=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_clockinfo_has_hz" >&5
+$as_echo "$ac_cv_struct_clockinfo_has_hz" >&6; }
+if test $ac_cv_struct_clockinfo_has_hz = yes; then
+
+$as_echo "#define HAVE_HZ_IN_STRUCT_CLOCKINFO 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking struct clockinfo for tickadj" >&5
+$as_echo_n "checking struct clockinfo for tickadj... " >&6; }
+if test "${ac_cv_struct_clockinfo_has_tickadj+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/time.h>
+int
+main ()
+{
+
+extern struct clockinfo *pc;
+return pc->tickadj;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_clockinfo_has_tickadj=yes
+else
+  ac_cv_struct_clockinfo_has_tickadj=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_clockinfo_has_tickadj" >&5
+$as_echo "$ac_cv_struct_clockinfo_has_tickadj" >&6; }
+if test $ac_cv_struct_clockinfo_has_tickadj = yes; then
+
+$as_echo "#define HAVE_TICKADJ_IN_STRUCT_CLOCKINFO 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct timespec" >&5
+$as_echo_n "checking for struct timespec... " >&6; }
+if test "${ac_cv_struct_timespec+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/time.h>
+/* Under SunOS, timespec is in sys/timepps.h, which needs errno.h and FRAC */
+#ifdef HAVE_ERRNO_H
+# include <errno.h>
+#endif
+#ifdef HAVE_SYS_TIMEPPS_H
+# define FRAC 4294967296
+# include <sys/timepps.h>
+#endif
+int
+main ()
+{
+struct timespec n;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_timespec=yes
+else
+  ac_cv_struct_timespec=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_timespec" >&5
+$as_echo "$ac_cv_struct_timespec" >&6; }
+if test $ac_cv_struct_timespec = yes; then
+
+$as_echo "#define HAVE_STRUCT_TIMESPEC 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct ntptimeval" >&5
+$as_echo_n "checking for struct ntptimeval... " >&6; }
+if test "${ac_cv_struct_ntptimeval+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/time.h>
+#include <sys/timex.h>
+int
+main ()
+{
+struct ntptimeval n;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_ntptimeval=yes
+else
+  ac_cv_struct_ntptimeval=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_ntptimeval" >&5
+$as_echo "$ac_cv_struct_ntptimeval" >&6; }
+if test $ac_cv_struct_ntptimeval = yes; then
+
+$as_echo "#define HAVE_STRUCT_NTPTIMEVAL 1" >>confdefs.h
+
+fi
+
+ac_fn_c_check_member "$LINENO" "struct ntptimeval" "time.tv_nsec" "ac_cv_member_struct_ntptimeval_time_tv_nsec" "#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+# ifdef HAVE_TIME_H
+# include <time.h>
+# endif
+#endif
+#ifdef HAVE_SYS_TIMEX_H
+#include <sys/timex.h>
+#else
+# ifdef HAVE_TIMEX_H
+# include <timex.h>
+# endif
+#endif
+"
+if test "x$ac_cv_member_struct_ntptimeval_time_tv_nsec" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_STRUCT_NTPTIMEVAL_TIME_TV_NSEC 1
+_ACEOF
+
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
+$as_echo_n "checking for inline... " >&6; }
+if test "${ac_cv_c_inline+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_inline=$ac_kw
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  test "$ac_cv_c_inline" != no && break
+done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
+$as_echo "$ac_cv_c_inline" >&6; }
+
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  *)
+    case $ac_cv_c_inline in
+      no) ac_val=;;
+      *) ac_val=$ac_cv_c_inline;;
+    esac
+    cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+    ;;
+esac
+
+
+case "$ac_cv_c_inline" in
+ '')
+    ;;
+ *)
+
+$as_echo "#define HAVE_INLINE 1" >>confdefs.h
+
+
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether char is unsigned" >&5
+$as_echo_n "checking whether char is unsigned... " >&6; }
+if test "${ac_cv_c_char_unsigned+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$ac_includes_default
+int
+main ()
+{
+static int test_array [1 - 2 * !(((char) -1) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_char_unsigned=no
+else
+  ac_cv_c_char_unsigned=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_char_unsigned" >&5
+$as_echo "$ac_cv_c_char_unsigned" >&6; }
+if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then
+  $as_echo "#define __CHAR_UNSIGNED__ 1" >>confdefs.h
+
+fi
+               # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of signed char" >&5
+$as_echo_n "checking size of signed char... " >&6; }
+if test "${ac_cv_sizeof_signed_char+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (signed char))" "ac_cv_sizeof_signed_char"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_signed_char" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (signed char)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_signed_char=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_signed_char" >&5
+$as_echo "$ac_cv_sizeof_signed_char" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SIGNED_CHAR $ac_cv_sizeof_signed_char
+_ACEOF
+
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5
+$as_echo_n "checking size of int... " >&6; }
+if test "${ac_cv_sizeof_int+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_int" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (int)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_int=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5
+$as_echo "$ac_cv_sizeof_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+_ACEOF
+
+
+# The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
+$as_echo_n "checking size of long... " >&6; }
+if test "${ac_cv_sizeof_long+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (long)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
+$as_echo "$ac_cv_sizeof_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+_ACEOF
+
+
+
+ac_fn_c_check_type "$LINENO" "s_char" "ac_cv_type_s_char" "$ac_includes_default"
+if test "x$ac_cv_type_s_char" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_S_CHAR 1
+_ACEOF
+
+
+fi
+
+case "$ac_cv_c_char_unsigned$ac_cv_sizeof_signed_char$ac_cv_type_s_char" in
+ *yes)
+    # We have a typedef for s_char.  Might as well believe it...
+    ;;
+ no0no)
+    # We have signed chars, can't say 'signed char', no s_char typedef.
+
+$as_echo "#define NEED_S_CHAR_TYPEDEF 1" >>confdefs.h
+
+    ;;
+ no1no)
+    # We have signed chars, can say 'signed char', no s_char typedef.
+    $as_echo "#define NEED_S_CHAR_TYPEDEF 1" >>confdefs.h
+
+    ;;
+ yes0no)
+    # We have unsigned chars, can't say 'signed char', no s_char typedef.
+    as_fn_error "No way to specify a signed character!" "$LINENO" 5
+    ;;
+ yes1no)
+    # We have unsigned chars, can say 'signed char', no s_char typedef.
+    $as_echo "#define NEED_S_CHAR_TYPEDEF 1" >>confdefs.h
+
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for uid_t in sys/types.h" >&5
+$as_echo_n "checking for uid_t in sys/types.h... " >&6; }
+if test "${ac_cv_type_uid_t+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "uid_t" >/dev/null 2>&1; then :
+  ac_cv_type_uid_t=yes
+else
+  ac_cv_type_uid_t=no
+fi
+rm -f conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_uid_t" >&5
+$as_echo "$ac_cv_type_uid_t" >&6; }
+if test $ac_cv_type_uid_t = no; then
+
+$as_echo "#define uid_t int" >>confdefs.h
+
+
+$as_echo "#define gid_t int" >>confdefs.h
+
+fi
+
+
+case "$host" in
+ *-*-aix[456]*)
+       # (prr) aix 4.1 doesn't have clock_settime, but in aix 4.3 it's a stub
+       # (returning ENOSYS).  I didn't check 4.2.  If, in the future,
+       # IBM pulls its thumbs out long enough to implement clock_settime,
+       # this conditional will need to change.  Maybe use AC_TRY_RUN
+       # instead to try to set the time to itself and check errno.
+    ;;
+ *) for ac_func in clock_gettime clock_settime
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+    ;;
+esac
+for ac_func in daemon
+do :
+  ac_fn_c_check_func "$LINENO" "daemon" "ac_cv_func_daemon"
+if test "x$ac_cv_func_daemon" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DAEMON 1
+_ACEOF
+
+fi
+done
+
+for ac_func in finite
+do :
+  ac_fn_c_check_func "$LINENO" "finite" "ac_cv_func_finite"
+if test "x$ac_cv_func_finite" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_FINITE 1
+_ACEOF
+
+else
+  for ac_func in isfinite
+do :
+  ac_fn_c_check_func "$LINENO" "isfinite" "ac_cv_func_isfinite"
+if test "x$ac_cv_func_isfinite" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_ISFINITE 1
+_ACEOF
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for isfinite with <math.h>" >&5
+$as_echo_n "checking for isfinite with <math.h>... " >&6; }
+    _libs=$LIBS
+    LIBS="$LIBS -lm"
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <math.h>
+int
+main ()
+{
+float f = 0.0; isfinite(f)
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+      $as_echo "#define HAVE_ISFINITE 1" >>confdefs.h
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+    LIBS=$_libs
+fi
+done
+
+fi
+done
+
+for ac_func in getbootfile getclock getdtablesize
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+# Check whether --enable-getifaddrs was given.
+if test "${enable_getifaddrs+set}" = set; then :
+  enableval=$enable_getifaddrs; want_getifaddrs="$enableval"
+else
+  want_getifaddrs="yes"
+fi
+
+
+case $want_getifaddrs in
+yes|glibc)
+#
+# Do we have getifaddrs() ?
+#
+case $host in
+*-*linux*)
+       # Some recent versions of glibc support getifaddrs() which does not
+       # provide AF_INET6 addresses while the function provided by the USAGI
+       # project handles the AF_INET6 case correctly.  We need to avoid
+       # using the former but prefer the latter unless overridden by
+       # --enable-getifaddrs=glibc.
+       if test $want_getifaddrs = glibc
+       then
+               for ac_func in getifaddrs
+do :
+  ac_fn_c_check_func "$LINENO" "getifaddrs" "ac_cv_func_getifaddrs"
+if test "x$ac_cv_func_getifaddrs" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GETIFADDRS 1
+_ACEOF
+
+fi
+done
+
+       else
+               save_LIBS="$LIBS"
+               LIBS="-L/usr/local/v6/lib $LIBS"
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for getifaddrs in -linet6" >&5
+$as_echo_n "checking for getifaddrs in -linet6... " >&6; }
+if test "${ac_cv_lib_inet6_getifaddrs+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-linet6  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char getifaddrs ();
+int
+main ()
+{
+return getifaddrs ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_inet6_getifaddrs=yes
+else
+  ac_cv_lib_inet6_getifaddrs=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_inet6_getifaddrs" >&5
+$as_echo "$ac_cv_lib_inet6_getifaddrs" >&6; }
+if test "x$ac_cv_lib_inet6_getifaddrs" = x""yes; then :
+  LIBS="$LIBS -linet6"
+                       $as_echo "#define HAVE_GETIFADDRS 1" >>confdefs.h
+
+else
+  LIBS=${save_LIBS}
+fi
+
+       fi
+       ;;
+*)
+       for ac_func in getifaddrs
+do :
+  ac_fn_c_check_func "$LINENO" "getifaddrs" "ac_cv_func_getifaddrs"
+if test "x$ac_cv_func_getifaddrs" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GETIFADDRS 1
+_ACEOF
+
+fi
+done
+
+       ;;
+esac
+;;
+no)
+;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking type of socklen arg for getsockname()" >&5
+$as_echo_n "checking type of socklen arg for getsockname()... " >&6; }
+if test "${ac_cv_func_getsockname_arg2+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "${ac_cv_func_getsockname_socklen_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+   for ac_cv_func_getsockname_arg2 in 'struct sockaddr *' 'void *'; do
+  for ac_cv_func_getsockname_socklen_type in 'socklen_t' 'size_t' 'unsigned int' 'int'; do
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+extern getsockname (int, $ac_cv_func_getsockname_arg2, $ac_cv_func_getsockname_socklen_type *);
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+      ac_not_found=no ; break 2
+else
+  ac_not_found=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   done
+  done
+
+fi
+
+fi
+if test "$ac_not_found" = yes; then
+ ac_cv_func_getsockname_socklen_type='socklen_t'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_getsockname_socklen_type" >&5
+$as_echo "$ac_cv_func_getsockname_socklen_type" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define GETSOCKNAME_SOCKLEN_TYPE $ac_cv_func_getsockname_socklen_type
+_ACEOF
+
+
+for ac_func in getrusage
+do :
+  ac_fn_c_check_func "$LINENO" "getrusage" "ac_cv_func_getrusage"
+if test "x$ac_cv_func_getrusage" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GETRUSAGE 1
+_ACEOF
+
+fi
+done
+
+ac_fn_c_check_func "$LINENO" "gettimeofday" "ac_cv_func_gettimeofday"
+if test "x$ac_cv_func_gettimeofday" = x""yes; then :
+
+else
+
+case "$host" in
+  *-*-mpeix*) ac_cv_func_gettimeofday=yes
+    ;;
+esac
+fi
+
+case "$host" in
+ *-pc-cygwin*)
+    ;;
+ *) for ac_func in getuid
+do :
+  ac_fn_c_check_func "$LINENO" "getuid" "ac_cv_func_getuid"
+if test "x$ac_cv_func_getuid" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_GETUID 1
+_ACEOF
+
+fi
+done
+
+    ;;
+esac
+for ac_func in hstrerror
+do :
+  ac_fn_c_check_func "$LINENO" "hstrerror" "ac_cv_func_hstrerror"
+if test "x$ac_cv_func_hstrerror" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_HSTRERROR 1
+_ACEOF
+
+fi
+done
+
+
+#
+# Check for if_nametoindex() for IPv6 scoped addresses support
+#
+ac_fn_c_check_func "$LINENO" "if_nametoindex" "ac_cv_func_if_nametoindex"
+if test "x$ac_cv_func_if_nametoindex" = x""yes; then :
+  ac_cv_have_if_nametoindex=yes
+else
+  ac_cv_have_if_nametoindex=no
+fi
+
+case $ac_cv_have_if_nametoindex in
+ no)
+       case "$host" in
+       *-hp-hpux*)
+               { $as_echo "$as_me:${as_lineno-$LINENO}: checking for if_nametoindex in -lipv6" >&5
+$as_echo_n "checking for if_nametoindex in -lipv6... " >&6; }
+if test "${ac_cv_lib_ipv6_if_nametoindex+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lipv6  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char if_nametoindex ();
+int
+main ()
+{
+return if_nametoindex ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_ipv6_if_nametoindex=yes
+else
+  ac_cv_lib_ipv6_if_nametoindex=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_ipv6_if_nametoindex" >&5
+$as_echo "$ac_cv_lib_ipv6_if_nametoindex" >&6; }
+if test "x$ac_cv_lib_ipv6_if_nametoindex" = x""yes; then :
+  ac_cv_have_if_nametoindex=yes
+                               LIBS="-lipv6 $LIBS"
+fi
+
+       ;;
+       esac
+esac
+case $ac_cv_have_if_nametoindex in
+ yes)
+
+$as_echo "#define ISC_PLATFORM_HAVEIFNAMETOINDEX 1" >>confdefs.h
+
+       ;;
+esac
+
+ac_fn_c_check_func "$LINENO" "inet_ntop" "ac_cv_func_inet_ntop"
+if test "x$ac_cv_func_inet_ntop" = x""yes; then :
+
+else
+
+$as_echo "#define ISC_PLATFORM_NEEDNTOP 1" >>confdefs.h
+
+fi
+
+ac_fn_c_check_func "$LINENO" "inet_pton" "ac_cv_func_inet_pton"
+if test "x$ac_cv_func_inet_pton" = x""yes; then :
+
+else
+
+$as_echo "#define ISC_PLATFORM_NEEDPTON 1" >>confdefs.h
+
+fi
+
+ac_fn_c_check_func "$LINENO" "inet_aton" "ac_cv_func_inet_aton"
+if test "x$ac_cv_func_inet_aton" = x""yes; then :
+
+else
+
+$as_echo "#define ISC_PLATFORM_NEEDATON 1" >>confdefs.h
+
+fi
+
+for ac_func in K_open kvm_open memcpy memmove memset
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+case "$host" in
+ *-*-sco3.2v5.0.*)
+    # Just stubs.  Idiots.
+    ;;
+ *) for ac_func in mkstemp
+do :
+  ac_fn_c_check_func "$LINENO" "mkstemp" "ac_cv_func_mkstemp"
+if test "x$ac_cv_func_mkstemp" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MKSTEMP 1
+_ACEOF
+
+fi
+done
+
+    ;;
+esac
+for ac_func in mktime
+do :
+  ac_fn_c_check_func "$LINENO" "mktime" "ac_cv_func_mktime"
+if test "x$ac_cv_func_mktime" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MKTIME 1
+_ACEOF
+
+fi
+done
+
+case "$host" in
+ *-*-aix[456]*)
+    # Just a stub.  Idiots.
+    ;;
+ *-*-irix[45]*)
+    # Just a stub in "old" Irix.  Idiots.
+    ;;
+ *-*-*linux*)
+    # there, but more trouble than it is worth for now (resolver problems)
+    ;;
+ *-*-qnx*)
+    # Apparently there but not working in QNX.  Idiots?
+    ;;
+ *-*-sco3.2v5.0.*)
+    # Just a stub.  Idiots.
+    ;;
+ alpha*-dec-osf4*|alpha*-dec-osf5*)
+    # mlockall is there, as a #define calling memlk via <sys/mman.h>
+    # Not easy to test for - cheat.
+    for ac_func in memlk
+do :
+  ac_fn_c_check_func "$LINENO" "memlk" "ac_cv_func_memlk"
+if test "x$ac_cv_func_memlk" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MEMLK 1
+_ACEOF
+ ac_cv_func_mlockall='yes'
+fi
+done
+
+    for ac_func in mlockall
+do :
+  ac_fn_c_check_func "$LINENO" "mlockall" "ac_cv_func_mlockall"
+if test "x$ac_cv_func_mlockall" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MLOCKALL 1
+_ACEOF
+
+fi
+done
+
+    ;;
+ *) for ac_func in mlockall
+do :
+  ac_fn_c_check_func "$LINENO" "mlockall" "ac_cv_func_mlockall"
+if test "x$ac_cv_func_mlockall" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_MLOCKALL 1
+_ACEOF
+
+fi
+done
+
+    ;;
+esac
+for ac_func in nice nlist
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+case "$host" in
+ *-*-solaris2.6)
+    # Broken...
+    ;;
+ *) for ac_func in ntp_adjtime ntp_gettime
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+    ;;
+esac
+for ac_func in plock pututline pututxline readlink recvmsg rtprio
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+case "$host" in
+ *-*-aix[456]*)
+    # Just a stub in AIX 4.  Idiots.
+    ;;
+ *-*-solaris2.5*)
+    # Just stubs in solaris2.5.  Idiots.
+    ;;
+ *) for ac_func in sched_setscheduler
+do :
+  ac_fn_c_check_func "$LINENO" "sched_setscheduler" "ac_cv_func_sched_setscheduler"
+if test "x$ac_cv_func_sched_setscheduler" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SCHED_SETSCHEDULER 1
+_ACEOF
+
+fi
+done
+
+    ;;
+esac
+for ac_func in setlinebuf setpgid setpriority setsid
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+for ac_func in setrlimit
+do :
+  ac_fn_c_check_func "$LINENO" "setrlimit" "ac_cv_func_setrlimit"
+if test "x$ac_cv_func_setrlimit" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SETRLIMIT 1
+_ACEOF
+
+fi
+done
+
+for ac_func in settimeofday
+do :
+  ac_fn_c_check_func "$LINENO" "settimeofday" "ac_cv_func_settimeofday"
+if test "x$ac_cv_func_settimeofday" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SETTIMEOFDAY 1
+_ACEOF
+
+else
+
+case "$host" in
+  *-*-mpeix*) ac_cv_func_settimeofday=yes
+    ;;
+esac
+fi
+done
+
+for ac_func in setvbuf sigaction
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+for ac_func in sigvec sigset sigsuspend stime strchr sysconf sysctl
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+for ac_func in snprintf strdup strerror strstr
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+for ac_func in timegm
+do :
+  ac_fn_c_check_func "$LINENO" "timegm" "ac_cv_func_timegm"
+if test "x$ac_cv_func_timegm" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_TIMEGM 1
+_ACEOF
+
+fi
+done
+
+case "$host" in
+ *-*-aix[456]*)
+    # Just stubs.  Idiots.
+    ;;
+ *-*-netbsd1*)
+    # Just stubs.  Idiots.
+    ;;
+ *-*-netbsdelf1*)
+    # Just stubs.  Idiots.
+    ;;
+ *-*-openbsd*)
+    # Just stubs.  Idiots.
+    ;;
+ *) for ac_func in timer_create timer_settime
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+    ;;
+esac
+case "$host" in
+ *-pc-cygwin*)
+    # I have no idea...
+    ;;
+ *) for ac_func in umask
+do :
+  ac_fn_c_check_func "$LINENO" "umask" "ac_cv_func_umask"
+if test "x$ac_cv_func_umask" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_UMASK 1
+_ACEOF
+
+fi
+done
+
+    ;;
+esac
+for ac_func in uname updwtmp updwtmpx vsnprintf vsprintf
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+
+###
+
+# http://bugs.ntp.org/737
+case "$ac_cv_func_recvmsg" in
+ yes)
+ { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need extra help to define struct iovec" >&5
+$as_echo_n "checking if we need extra help to define struct iovec... " >&6; }
+ if test "${ac_cv_struct_iovec_help+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+   for ac_cv_struct_iovec_help in '0' '1'; do
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if $ac_cv_struct_iovec_help
+#include <sys/uio.h>
+#endif
+
+void foo();
+void foo() {
+       ssize_t x;
+       int s = 0;
+       struct iovec iov;
+       struct msghdr mh;
+       int flags = 0;
+
+       mh.msg_iov = &iov;
+       x = recvmsg(s, &mh, flags);
+}
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+    ac_worked=yes ; break 1
+else
+  ac_worked=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+
+fi
+    case "$ac_worked$ac_cv_struct_iovec_help" in
+     yes1)
+
+$as_echo "#define HAVE_SYS_UIO_H 1" >>confdefs.h
+
+       ans=yes
+       ;;
+     *) ans=no
+    esac
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+    ;;
+esac
+
+case "$host" in
+ *-*-sunos4*)
+
+$as_echo "#define SPRINTF_CHAR 1" >>confdefs.h
+
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking number of arguments to gettimeofday()" >&5
+$as_echo_n "checking number of arguments to gettimeofday()... " >&6; }
+if test "${ac_cv_func_Xettimeofday_nargs+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/time.h>
+int
+main ()
+{
+
+gettimeofday((struct timeval*)0,(struct timezone*)0);
+settimeofday((struct timeval*)0,(struct timezone*)0);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_func_Xettimeofday_nargs=2
+else
+  ac_cv_func_Xettimeofday_nargs=1
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_Xettimeofday_nargs" >&5
+$as_echo "$ac_cv_func_Xettimeofday_nargs" >&6; }
+if test $ac_cv_func_Xettimeofday_nargs = 1; then
+
+$as_echo "#define SYSV_TIMEOFDAY 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking number of arguments taken by setpgrp()" >&5
+$as_echo_n "checking number of arguments taken by setpgrp()... " >&6; }
+if test "${ac_cv_func_setpgrp_nargs+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+int
+main ()
+{
+setpgrp(0,0);
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_func_setpgrp_nargs=2
+else
+  ac_cv_func_setpgrp_nargs=0
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_setpgrp_nargs" >&5
+$as_echo "$ac_cv_func_setpgrp_nargs" >&6; }
+if test $ac_cv_func_setpgrp_nargs = 0; then
+
+$as_echo "#define HAVE_SETPGRP_0 1" >>confdefs.h
+
+fi
+
+save_CFLAGS=$CFLAGS
+CFLAGS="$CFLAGS -I$srcdir/include"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking argument pointer type of qsort()'s compare function and base" >&5
+$as_echo_n "checking argument pointer type of qsort()'s compare function and base... " >&6; }
+if test "${ac_cv_func_qsort_argtype+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include "l_stdlib.h"
+
+#ifdef HAVE_PROTOTYPES
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+
+extern void *base;
+extern sortfunc P((const void *, const void *));
+int sortfunc(a, b)
+  const void *a;
+  const void *b; { return 0; }
+
+int
+main ()
+{
+
+qsort(base, 2, sizeof(char *), sortfunc);
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_func_qsort_argtype=void
+else
+  ac_cv_func_qsort_argtype=char
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_qsort_argtype" >&5
+$as_echo "$ac_cv_func_qsort_argtype" >&6; }
+case "$ac_cv_func_qsort_argtype" in
+ void)
+
+$as_echo "#define QSORT_USES_VOID_P 1" >>confdefs.h
+
+    ;;
+esac
+
+CFLAGS=$save_CFLAGS
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need to declare 'errno'" >&5
+$as_echo_n "checking if we need to declare 'errno'... " >&6; }
+if test "${ac_cv_decl_errno+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+int
+main ()
+{
+errno = 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_decl_errno=no
+else
+  ac_cv_decl_errno=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_decl_errno" >&5
+$as_echo "$ac_cv_decl_errno" >&6; }
+case "$ac_cv_decl_errno" in
+ yes)
+$as_echo "#define DECL_ERRNO 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we may declare 'h_errno'" >&5
+$as_echo_n "checking if we may declare 'h_errno'... " >&6; }
+if test "${ac_cv_decl_h_errno+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif
+int
+main ()
+{
+extern int h_errno;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_decl_h_errno=yes
+else
+  ac_cv_decl_h_errno=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_decl_h_errno" >&5
+$as_echo "$ac_cv_decl_h_errno" >&6; }
+case "$ac_cv_decl_h_errno" in
+ yes)
+$as_echo "#define DECL_H_ERRNO 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if declaring 'char *sys_errlist[]' is ok" >&5
+$as_echo_n "checking if declaring 'char *sys_errlist[]' is ok... " >&6; }
+if test "${ac_cv_decl_sys_errlist+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif
+int
+main ()
+{
+extern char *sys_errlist[];
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_decl_sys_errlist=yes
+else
+  ac_cv_decl_sys_errlist=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_decl_sys_errlist" >&5
+$as_echo "$ac_cv_decl_sys_errlist" >&6; }
+case "$ac_cv_decl_sys_errlist" in
+ yes)
+$as_echo "#define CHAR_SYS_ERRLIST 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if declaring 'syscall()' is ok" >&5
+$as_echo_n "checking if declaring 'syscall()' is ok... " >&6; }
+if test "${ac_cv_decl_syscall+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_PROTOTYPES
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+
+int
+main ()
+{
+extern int syscall P((int, ...));
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_decl_syscall=yes
+else
+  ac_cv_decl_syscall=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_decl_syscall" >&5
+$as_echo "$ac_cv_decl_syscall" >&6; }
+case "$ac_cv_decl_syscall" in
+ yes)
+$as_echo "#define DECL_SYSCALL 1" >>confdefs.h
+ ;;
+esac
+
+case "$host" in
+ *-*-aix4.3.*)
+
+$as_echo "#define DECL_HSTRERROR_0 1" >>confdefs.h
+               # Needed for XLC under AIX 4.3.2
+    ;;
+ *-*-mpeix*)
+
+$as_echo "#define DECL_ADJTIME_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_INET_NTOA_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_MKTEMP_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SELECT_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SETITIMER_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SYSLOG_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_TIMEOFDAY_0 1" >>confdefs.h
+
+    ;;
+ *-*-osf[45]*)
+
+$as_echo "#define DECL_PLOCK_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_STIME_1 1" >>confdefs.h
+
+    ;;
+ *-*-qnx*)
+
+$as_echo "#define DECL_ADJTIME_0 1" >>confdefs.h
+
+    ;;
+ *-*-riscos4*)
+
+$as_echo "#define DECL_ADJTIME_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_BZERO_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_IOCTL_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_IPC_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_MEMMOVE_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_MKTEMP_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_RENAME_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SELECT_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SETITIMER_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SETPRIORITY_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_STDIO_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_STRTOL_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SYSLOG_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_TIME_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_TIMEOFDAY_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_TOLOWER_0 1" >>confdefs.h
+
+    ;;
+ *-*-solaris2*)
+
+$as_echo "#define DECL_MKSTEMP_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SETPRIORITY_1 1" >>confdefs.h
+
+    case "$host" in
+     *-*-solaris2.4)
+
+$as_echo "#define DECL_TIMEOFDAY_0 1" >>confdefs.h
+
+       ;;
+    esac
+    ;;
+ *-*-sunos4*)
+
+$as_echo "#define DECL_ADJTIME_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_BCOPY_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_BZERO_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_IOCTL_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_IPC_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_MEMMOVE_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_MKTEMP_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_MKSTEMP_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_RENAME_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SELECT_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SETITIMER_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SETPRIORITY_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SIGVEC_0 1" >>confdefs.h
+
+    case "`basename $ac_cv_prog_CC`" in
+     acc*) ;;
+     *)
+$as_echo "#define DECL_STDIO_0 1" >>confdefs.h
+
+       ;;
+    esac
+
+$as_echo "#define DECL_STRTOL_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SYSLOG_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_TIME_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_TIMEOFDAY_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_TOLOWER_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_TOUPPER_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_STRERROR_0 1" >>confdefs.h
+
+    ;;
+ *-*-ultrix4*)
+
+$as_echo "#define DECL_ADJTIME_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_BZERO_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_CFSETISPEED_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_IOCTL_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_IPC_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_MKTEMP_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_NLIST_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_PLOCK_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SELECT_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SETITIMER_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SETPRIORITY_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_STIME_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_SYSLOG_0 1" >>confdefs.h
+
+
+$as_echo "#define DECL_TIMEOFDAY_0 1" >>confdefs.h
+
+    ;;
+esac
+
+case "$host" in
+ *-*-sco3.2*)
+
+$as_echo "#define TERMIOS_NEEDS__SVID3 1" >>confdefs.h
+
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need extra room for SO_RCVBUF" >&5
+$as_echo_n "checking if we need extra room for SO_RCVBUF... " >&6; }
+if test "${ac_cv_var_rcvbuf_slop+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=no
+case "$host" in
+ *-*-hpux[567]*)
+    ans=yes
+    ;;
+esac
+ac_cv_var_rcvbuf_slop=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_rcvbuf_slop" >&5
+$as_echo "$ac_cv_var_rcvbuf_slop" >&6; }
+case "$ac_cv_var_rcvbuf_slop" in
+ yes)
+$as_echo "#define NEED_RCVBUF_SLOP 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we will open the broadcast socket" >&5
+$as_echo_n "checking if we will open the broadcast socket... " >&6; }
+if test "${ac_cv_var_open_bcast_socket+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=yes
+case "$host" in
+ *-*-domainos)
+    ans=no
+    ;;
+esac
+ac_cv_var_open_bcast_socket=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_open_bcast_socket" >&5
+$as_echo "$ac_cv_var_open_bcast_socket" >&6; }
+case "$ac_cv_var_open_bcast_socket" in
+ yes)
+$as_echo "#define OPEN_BCAST_SOCKET 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want the HPUX version of FindConfig()" >&5
+$as_echo_n "checking if we want the HPUX version of FindConfig()... " >&6; }
+if test "${ac_cv_var_hpux_findconfig+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=no
+case "$host" in
+ *-*-hpux*)
+    ans=yes
+    ;;
+esac
+ac_cv_var_hpux_findconfig=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_hpux_findconfig" >&5
+$as_echo "$ac_cv_var_hpux_findconfig" >&6; }
+case "$ac_cv_var_hpux_findconfig" in
+ yes)
+$as_echo "#define NEED_HPUX_FINDCONFIG 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if process groups are set with -pid" >&5
+$as_echo_n "checking if process groups are set with -pid... " >&6; }
+if test "${ac_cv_arg_setpgrp_negpid+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$host" in
+ *-*-hpux[567]*)
+    ans=no
+    ;;
+ *-*-hpux*)
+    ans=yes
+    ;;
+ *-*-*linux*)
+    ans=yes
+    ;;
+ *-*-sunos3*)
+    ans=yes
+    ;;
+ *-*-ultrix2*)
+    ans=yes
+    ;;
+ *)
+    ans=no
+    ;;
+esac
+ac_cv_arg_setpgrp_negpid=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_arg_setpgrp_negpid" >&5
+$as_echo "$ac_cv_arg_setpgrp_negpid" >&6; }
+case "$ac_cv_arg_setpgrp_negpid" in
+ yes)
+$as_echo "#define UDP_BACKWARDS_SETOWN 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need a ctty for F_SETOWN" >&5
+$as_echo_n "checking if we need a ctty for F_SETOWN... " >&6; }
+if test "${ac_cv_func_ctty_for_f_setown+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$host" in
+ *-*-bsdi[23]*)
+    ans=yes
+    ;;
+ *-*-freebsd*)
+    ans=yes
+    ;;
+ *-*-netbsd*3.[0-8]*|*-*-netbsd*[0-2].*|*-*-netbsd*3.99.[0-7])
+    ans=yes
+    ;;
+ *-*-openbsd*)
+    ans=yes
+    ;;
+ *-*-osf*)
+    ans=yes
+    ;;
+ *-*-darwin*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+ac_cv_func_ctty_for_f_setown=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_func_ctty_for_f_setown" >&5
+$as_echo "$ac_cv_func_ctty_for_f_setown" >&6; }
+case "$ac_cv_func_ctty_for_f_setown" in
+ yes)
+$as_echo "#define USE_FSETOWNCTTY 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the OS fails to clear cached routes when more specific routes become available" >&5
+$as_echo_n "checking if the OS fails to clear cached routes when more specific routes become available... " >&6; }
+if test "${ac_cv_os_routeupdates+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$host" in
+ *-*-netbsd*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+ac_cv_os_routeupdates=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_routeupdates" >&5
+$as_echo "$ac_cv_os_routeupdates" >&6; }
+case "$ac_cv_os_routeupdates" in
+ yes)
+$as_echo "#define OS_MISSES_SPECIFIC_ROUTE_UPDATES 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the OS needs the wildcard socket set to REUSEADDR for binding interface addresses" >&5
+$as_echo_n "checking if the OS needs the wildcard socket set to REUSEADDR for binding interface addresses... " >&6; }
+if test "${ac_cv_os_wildcardreuse+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$host" in
+ *-*-*linux*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+ac_cv_os_wildcardreuse=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_os_wildcardreuse" >&5
+$as_echo "$ac_cv_os_wildcardreuse" >&6; }
+case "$ac_cv_os_wildcardreuse" in
+ yes)
+$as_echo "#define OS_NEEDS_REUSEADDR_FOR_IFADDRBIND 1" >>confdefs.h
+ ;;
+esac
+
+ntp_warning='GRONK'
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we'll use clock_settime or settimeofday or stime" >&5
+$as_echo_n "checking if we'll use clock_settime or settimeofday or stime... " >&6; }
+case "$ac_cv_func_clock_settime$ac_cv_func_settimeofday$ac_cv_func_stime" in
+ yes*)
+    ntp_warning=''
+    ans='clock_settime()'
+    ;;
+ noyes*)
+    ntp_warning='But clock_settime() would be better (if we had it)'
+    ans='settimeofday()'
+    ;;
+ nonoyes)
+    ntp_warning='Which is the worst of the three'
+    ans='stime()'
+    ;;
+ *)
+    case "$build" in
+     $host) ntp_warning='Which leaves us with nothing to use!'
+    ans=none
+    ;;
+esac
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+case "$ntp_warning" in
+ '') ;;
+ *) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** $ntp_warning ***" >&5
+$as_echo "$as_me: WARNING: *** $ntp_warning ***" >&2;}
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have a losing syscall()" >&5
+$as_echo_n "checking if we have a losing syscall()... " >&6; }
+if test "${ac_cv_var_syscall_bug+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$host" in
+ *-*-solaris2.4*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+ac_cv_var_syscall_bug=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_syscall_bug" >&5
+$as_echo "$ac_cv_var_syscall_bug" >&6; }
+case "$ac_cv_var_syscall_bug" in
+ yes)
+$as_echo "#define SYSCALL_BUG 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SIGIO" >&5
+$as_echo_n "checking for SIGIO... " >&6; }
+if test "${ac_cv_hdr_def_sigio+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <signal.h>
+#ifdef SIGIO
+   yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ac_cv_hdr_def_sigio=yes
+else
+  ac_cv_hdr_def_sigio=no
+fi
+rm -f conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_hdr_def_sigio" >&5
+$as_echo "$ac_cv_hdr_def_sigio" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want to use signalled IO" >&5
+$as_echo_n "checking if we want to use signalled IO... " >&6; }
+if test "${ac_cv_var_signalled_io+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=no
+case "$ac_cv_hdr_def_sigio" in
+ yes)
+    ans=yes
+    case "$host" in
+     alpha*-dec-osf4*|alpha*-dec-osf5*)
+        ans=no
+        ;;
+     *-convex-*)
+        ans=no
+        ;;
+     *-dec-*)
+        ans=no
+        ;;
+     *-pc-cygwin*)
+       ans=no
+       ;;
+     *-sni-sysv*)
+        ans=no
+        ;;
+     *-univel-sysv*)
+        ans=no
+       ;;
+     *-*-irix6*)
+       ans=no
+       ;;
+     *-*-freebsd*)
+       ans=no
+       ;;
+     *-*-*linux*)
+       ans=no
+       ;;
+     *-*-unicosmp*)
+       ans=no
+       ;;
+    esac
+    ;;
+esac
+ac_cv_var_signalled_io=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_signalled_io" >&5
+$as_echo "$ac_cv_var_signalled_io" >&6; }
+case "$ac_cv_var_signalled_io" in
+ yes)
+$as_echo "#define HAVE_SIGNALED_IO 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SIGPOLL" >&5
+$as_echo_n "checking for SIGPOLL... " >&6; }
+if test "${ac_cv_hdr_def_sigpoll+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <signal.h>
+#ifdef SIGPOLL
+  yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ac_cv_hdr_def_sigpoll=yes
+else
+  ac_cv_hdr_def_sigpoll=no
+fi
+rm -f conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_hdr_def_sigpoll" >&5
+$as_echo "$ac_cv_hdr_def_sigpoll" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SIGSYS" >&5
+$as_echo_n "checking for SIGSYS... " >&6; }
+if test "${ac_cv_hdr_def_sigsys+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <signal.h>
+#ifdef SIGSYS
+  yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ac_cv_hdr_def_sigsys=yes
+else
+  ac_cv_hdr_def_sigsys=no
+fi
+rm -f conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_hdr_def_sigsys" >&5
+$as_echo "$ac_cv_hdr_def_sigsys" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can use SIGPOLL for UDP I/O" >&5
+$as_echo_n "checking if we can use SIGPOLL for UDP I/O... " >&6; }
+if test "${ac_cv_var_use_udp_sigpoll+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=no
+case "$ac_cv_hdr_def_sigpoll" in
+ yes)
+    case "$host" in
+     mips-sgi-irix*)
+       ans=no
+       ;;
+     vax-dec-bsd)
+        ans=no
+        ;;
+     *-pc-cygwin*)
+       ans=no
+       ;;
+     *-sni-sysv*)
+        ans=no
+        ;;
+     *-*-aix[456]*)
+        ans=no
+        ;;
+     *-*-hpux*)
+        ans=no
+        ;;
+     *-*-*linux*)
+       ans=no
+       ;;
+     *-*-osf*)
+        ans=no
+        ;;
+     *-*-qnx*)
+        ans=no
+        ;;
+     *-*-sunos*)
+       ans=no
+       ;;
+     *-*-solaris*)
+       ans=no
+       ;;
+     *-*-ultrix*)
+        ans=no
+        ;;
+     *-*-unicosmp*)
+        ans=no
+        ;;
+     *) ans=yes
+        ;;
+    esac
+    ;;
+esac
+ac_cv_var_use_udp_sigpoll=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_use_udp_sigpoll" >&5
+$as_echo "$ac_cv_var_use_udp_sigpoll" >&6; }
+case "$ac_cv_var_use_udp_sigpoll" in
+ yes)
+$as_echo "#define USE_UDP_SIGPOLL 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can use SIGPOLL for TTY I/O" >&5
+$as_echo_n "checking if we can use SIGPOLL for TTY I/O... " >&6; }
+if test "${ac_cv_var_use_tty_sigpoll+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=no
+case "$ac_cv_hdr_def_sigpoll" in
+ yes)
+    case "$host" in
+     mips-sgi-irix*)
+        ans=no
+        ;;
+     vax-dec-bsd)
+        ans=no
+        ;;
+     *-pc-cygwin*)
+       ans=no
+       ;;
+     *-sni-sysv*)
+        ans=no
+        ;;
+     *-*-aix[456]*)
+       ans=no
+       ;;
+     *-*-hpux*)
+        ans=no
+        ;;
+     *-*-*linux*)
+       ans=no
+       ;;
+     *-*-osf*)
+        ans=no
+        ;;
+     *-*-sunos*)
+       ans=no
+       ;;
+     *-*-ultrix*)
+        ans=no
+        ;;
+     *-*-qnx*)
+        ans=no
+        ;;
+     *-*-unicosmp*)
+        ans=no
+        ;;
+     *) ans=yes
+        ;;
+    esac
+    ;;
+esac
+ac_cv_var_use_tty_sigpoll=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_use_tty_sigpoll" >&5
+$as_echo "$ac_cv_var_use_tty_sigpoll" >&6; }
+case "$ac_cv_var_use_tty_sigpoll" in
+ yes)
+$as_echo "#define USE_TTY_SIGPOLL 1" >>confdefs.h
+ ;;
+esac
+
+case "$ac_cv_header_sys_sio_h" in
+ yes)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking sys/sio.h for TIOCDCDTIMESTAMP" >&5
+$as_echo_n "checking sys/sio.h for TIOCDCDTIMESTAMP... " >&6; }
+if test "${ac_cv_hdr_def_tiocdcdtimestamp+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/sio.h>
+#ifdef TIOCDCDTIMESTAMP
+  yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ac_cv_hdr_def_tiocdcdtimestamp=yes
+else
+  ac_cv_hdr_def_tiocdcdtimestamp=no
+fi
+rm -f conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_hdr_def_tiocdcdtimestamp" >&5
+$as_echo "$ac_cv_hdr_def_tiocdcdtimestamp" >&6; }
+    ;;
+esac
+
+case "$ac_cv_hdr_def_tiocdcdtimestamp" in
+ yes)
+    ac_cv_var_oncore_ok=yes
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if nlist() values might require extra indirection" >&5
+$as_echo_n "checking if nlist() values might require extra indirection... " >&6; }
+if test "${ac_cv_var_nlist_extra_indirection+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=no
+case "$host" in
+ *-*-aix*)
+    ans=yes
+    ;;
+esac
+ac_cv_var_nlist_extra_indirection=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_nlist_extra_indirection" >&5
+$as_echo "$ac_cv_var_nlist_extra_indirection" >&6; }
+case "$ac_cv_var_nlist_extra_indirection" in
+ yes)
+$as_echo "#define NLIST_EXTRA_INDIRECTION 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a minimum recommended value of tickadj" >&5
+$as_echo_n "checking for a minimum recommended value of tickadj... " >&6; }
+if test "${ac_cv_var_min_rec_tickadj+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=no
+case "$host" in
+ *-*-aix*)
+    ans=40
+    ;;
+esac
+ac_cv_var_min_rec_tickadj=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_min_rec_tickadj" >&5
+$as_echo "$ac_cv_var_min_rec_tickadj" >&6; }
+case "$ac_cv_var_min_rec_tickadj" in
+ ''|no) ;;
+ *)
+cat >>confdefs.h <<_ACEOF
+#define MIN_REC_TICKADJ $ac_cv_var_min_rec_tickadj
+_ACEOF
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the TTY code permits PARENB and IGNPAR" >&5
+$as_echo_n "checking if the TTY code permits PARENB and IGNPAR... " >&6; }
+if test "${ac_cv_var_no_parenb_ignpar+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=no
+case "$host" in
+ i?86-*-*linux*)
+    ans=yes
+    ;;
+ mips-sgi-irix*)
+    ans=yes
+    ;;
+ i?86-*-freebsd[123].*)
+    ;;
+ i?86-*-freebsd*)
+    ans=yes
+    ;;
+ *-*-unicosmp*)
+    ans=yes
+    ;;
+esac
+ac_cv_var_no_parenb_ignpar=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_no_parenb_ignpar" >&5
+$as_echo "$ac_cv_var_no_parenb_ignpar" >&6; }
+case "$ac_cv_var_no_parenb_ignpar" in
+ yes)
+$as_echo "#define NO_PARENB_IGNPAR 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we're including debugging code" >&5
+$as_echo_n "checking if we're including debugging code... " >&6; }
+# Check whether --enable-debugging was given.
+if test "${enable_debugging+set}" = set; then :
+  enableval=$enable_debugging; ntp_ok=$enableval
+else
+  ntp_ok=yes
+fi
+
+if test "$ntp_ok" = "yes"; then
+
+$as_echo "#define DEBUG 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we including processing time debugging code" >&5
+$as_echo_n "checking if we including processing time debugging code... " >&6; }
+# Check whether --enable-debug-timing was given.
+if test "${enable_debug_timing+set}" = set; then :
+  enableval=$enable_debug_timing; ntp_ok=$enableval
+else
+  ntp_ok=no
+fi
+
+if test "$ntp_ok" = "yes"; then
+
+$as_echo "#define DEBUG_TIMING 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a the number of minutes in a DST adjustment" >&5
+$as_echo_n "checking for a the number of minutes in a DST adjustment... " >&6; }
+# Check whether --enable-dst_minutes was given.
+if test "${enable_dst_minutes+set}" = set; then :
+  enableval=$enable_dst_minutes; ans=$enableval
+else
+  ans=60
+
+fi
+
+
+cat >>confdefs.h <<_ACEOF
+#define DSTMINUTES $ans
+_ACEOF
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if ntpd will retry on permanent DNS errors" >&5
+$as_echo_n "checking if ntpd will retry on permanent DNS errors... " >&6; }
+# Check whether --enable-ignore-dns-errors was given.
+if test "${enable_ignore_dns_errors+set}" = set; then :
+  enableval=$enable_ignore_dns_errors; ans=$enableval
+else
+  ans=no
+
+fi
+
+case "$ans" in
+ yes)
+
+$as_echo "#define IGNORE_DNS_ERRORS 1" >>confdefs.h
+
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have the tty_clk line discipline/streams module" >&5
+$as_echo_n "checking if we have the tty_clk line discipline/streams module... " >&6; }
+if test "${ac_cv_var_tty_clk+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$ac_cv_header_sys_clkdefs_h$ac_cv_hdr_def_tiocdcdtimestamp" in
+  *yes*) ac_cv_var_tty_clk=yes ;;
+  *)     ac_cv_var_tty_clk=no ;;
+ esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tty_clk" >&5
+$as_echo "$ac_cv_var_tty_clk" >&6; }
+case "$ac_cv_var_tty_clk" in
+ yes)
+$as_echo "#define TTYCLK 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the ppsclock streams module" >&5
+$as_echo_n "checking for the ppsclock streams module... " >&6; }
+if test "${ac_cv_var_ppsclock+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_var_ppsclock=$ac_cv_struct_ppsclockev
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_ppsclock" >&5
+$as_echo "$ac_cv_var_ppsclock" >&6; }
+case "$ac_cv_var_ppsclock" in
+ yes)
+$as_echo "#define PPS 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for kernel multicast support" >&5
+$as_echo_n "checking for kernel multicast support... " >&6; }
+if test "${ac_cv_var_mcast+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_var_mcast=no
+  case "$host" in
+   i386-sequent-sysv4) ;;
+   *) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <netinet/in.h>
+#ifdef IP_ADD_MEMBERSHIP
+   yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ac_cv_var_mcast=yes
+fi
+rm -f conftest*
+ ;;
+  esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_mcast" >&5
+$as_echo "$ac_cv_var_mcast" >&6; }
+case "$ac_cv_var_mcast" in
+ yes)
+
+$as_echo "#define MCAST 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking arg type needed for IP*_MULTICAST_LOOP for setsockopt()" >&5
+$as_echo_n "checking arg type needed for IP*_MULTICAST_LOOP for setsockopt()... " >&6; }
+if test "${ac_cv_var_typeof_ip_multicast_loop+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$host" in
+        *-*-netbsd*|*-*-*linux*)
+           ac_cv_var_typeof_ip_multicast_loop=u_int
+           ;;
+        *-*-winnt*)
+           ac_cv_var_typeof_ip_multicast_loop=BOOL
+           ;;
+        *) ac_cv_var_typeof_ip_multicast_loop=u_char
+           ;;
+       esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_typeof_ip_multicast_loop" >&5
+$as_echo "$ac_cv_var_typeof_ip_multicast_loop" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define TYPEOF_IP_MULTICAST_LOOP $ac_cv_var_typeof_ip_multicast_loop
+_ACEOF
+
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking availability of ntp_{adj,get}time()" >&5
+$as_echo_n "checking availability of ntp_{adj,get}time()... " >&6; }
+if test "${ac_cv_var_ntp_syscalls+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_var_ntp_syscalls=no
+ case "$ac_cv_func_ntp_adjtime$ac_cv_func_ntp_gettime$ac_cv_func___adjtimex" in
+  yesyes*)
+    ac_cv_var_ntp_syscalls=libc
+    ;;
+  *yes)
+    ac_cv_var_ntp_syscalls=inline
+    ;;
+  *) cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/syscall.h>
+#if defined(SYS_ntp_gettime) && defined(SYS_ntp_adjtime)
+           yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ac_cv_var_ntp_syscalls=kernel
+fi
+rm -f conftest*
+
+    ;;
+ esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_ntp_syscalls" >&5
+$as_echo "$ac_cv_var_ntp_syscalls" >&6; }
+case "$ac_cv_var_ntp_syscalls" in
+ libc)
+
+$as_echo "#define NTP_SYSCALLS_LIBC 1" >>confdefs.h
+
+    ;;
+ kernel)
+
+$as_echo "#define NTP_SYSCALLS_STD 1" >>confdefs.h
+
+    ;;
+ *)
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if sys/timex.h has STA_FLL" >&5
+$as_echo_n "checking if sys/timex.h has STA_FLL... " >&6; }
+if test "${ac_cv_var_sta_fll+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/timex.h>
+#ifdef STA_FLL
+    yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ac_cv_var_sta_fll=yes
+else
+  ac_cv_var_sta_fll=no
+fi
+rm -f conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_sta_fll" >&5
+$as_echo "$ac_cv_var_sta_fll" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have kernel PLL support" >&5
+$as_echo_n "checking if we have kernel PLL support... " >&6; }
+if test "${ac_cv_var_kernel_pll+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$ac_cv_header_sys_timex_h$ac_cv_struct_ntptimeval$ac_cv_var_sta_fll$ac_cv_var_ntp_syscalls" in
+ *no*)
+    ac_cv_var_kernel_pll=no
+    ;;
+ *) ac_cv_var_kernel_pll=yes
+    ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_kernel_pll" >&5
+$as_echo "$ac_cv_var_kernel_pll" >&6; }
+case "$ac_cv_var_kernel_pll" in
+ yes)
+
+$as_echo "#define KERNEL_PLL 1" >>confdefs.h
+
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if SIOCGIFCONF returns buffer size in the buffer" >&5
+$as_echo_n "checking if SIOCGIFCONF returns buffer size in the buffer... " >&6; }
+if test "${ac_cv_var_size_returned_in_buffer+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=no
+  case "$host" in
+   *-fujitsu-uxp*)
+      ans=yes
+      ;;
+   *-ncr-sysv4*)
+      ans=yes
+      ;;
+   *-univel-sysv*)
+      ans=yes
+      ;;
+  esac
+  ac_cv_var_size_returned_in_buffer=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_size_returned_in_buffer" >&5
+$as_echo "$ac_cv_var_size_returned_in_buffer" >&6; }
+case "$ac_cv_var_size_returned_in_buffer" in
+ yes)
+$as_echo "#define SIZE_RETURNED_IN_BUFFER 1" >>confdefs.h
+ ;;
+esac
+
+
+# Check for ioctls TIOCGPPSEV
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking ioctl TIOCGPPSEV" >&5
+$as_echo_n "checking ioctl TIOCGPPSEV... " >&6; }
+if test "$ac_cv_header_termios_h" = "yes"; then
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <termios.h>
+#ifdef TIOCGPPSEV
+         yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ntp_ok=yes
+else
+  ntp_ok=no
+fi
+rm -f conftest*
+
+else
+ntp_ok=no
+fi
+if test "$ntp_ok" = "yes"; then
+
+$as_echo "#define HAVE_TIOCGPPSEV 1" >>confdefs.h
+
+    ac_cv_var_oncore_ok=yes
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+# Check for ioctls TIOCSPPS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking ioctl TIOCSPPS" >&5
+$as_echo_n "checking ioctl TIOCSPPS... " >&6; }
+if test "$ac_cv_header_termios_h" = "yes"; then
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <termios.h>
+#ifdef TIOCSPPS
+         yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ntp_ok=yes
+else
+  ntp_ok=no
+fi
+rm -f conftest*
+
+else
+    ntp_ok=no
+fi
+
+if test "$ntp_ok" = "yes"; then
+
+$as_echo "#define HAVE_TIOCSPPS 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+# Check for ioctls CIOGETEV
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking ioctl CIOGETEV" >&5
+$as_echo_n "checking ioctl CIOGETEV... " >&6; }
+if test "$ac_cv_header_sys_ppsclock_h" = "yes"; then
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/ppsclock.h>
+#ifdef CIOGETEV
+         yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ntp_ok=yes
+else
+  ntp_ok=no
+fi
+rm -f conftest*
+
+else
+ntp_ok=no
+fi
+if test "$ntp_ok" = "yes"; then
+    ac_cv_var_oncore_ok=yes
+
+$as_echo "#define HAVE_CIOGETEV 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+
+# ATOM/PPSAPI stuff.
+
+# ATOM used to require struct timespec, but that's been fixed now.
+
+# case "$ac_cv_struct_timespec" in
+#  'yes')
+#     ac_cv_var_atom_ok=yes
+#     ;;
+# esac
+ac_cv_var_atom_ok=yes
+
+# Check for header timepps.h, if found then we have PPS API (Draft RFC) stuff.
+
+# The PPSAPI headers need "inline" ($ac_cv_c_inline='inline')
+
+# The PPSAPI needs struct timespec.
+
+# The PPSAPI also needs a timepps header.
+
+case "$ac_cv_c_inline$ac_cv_struct_timespec" in
+ inlineyes)
+    case "$ac_cv_header_timepps_h$ac_cv_header_sys_timepps_h$host_os" in
+     *yes* | *sunos* | *solaris* | *sco* | *netbsd* )
+
+$as_echo "#define HAVE_PPSAPI 1" >>confdefs.h
+
+       ac_cv_var_jupiter_ok=yes
+       ac_cv_var_oncore_ok=yes
+       ac_cv_var_parse_ok=yes
+       ac_cv_var_ripe_ncc_ok=yes
+       ;;
+    esac
+    ;;
+esac
+
+# Check for ioctls TIOCGSERIAL, TIOCSSERIAL, ASYNC_PPS_CD_POS, ASYNC_PPS_CD_NEG
+ac_fn_c_check_header_mongrel "$LINENO" "linux/serial.h" "ac_cv_header_linux_serial_h" "$ac_includes_default"
+if test "x$ac_cv_header_linux_serial_h" = x""yes; then :
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking ioctl TIOCGSERIAL, TIOCSSERIAL, ASYNC_PPS_CD_POS, ASYNC_PPS_CD_NEG" >&5
+$as_echo_n "checking ioctl TIOCGSERIAL, TIOCSSERIAL, ASYNC_PPS_CD_POS, ASYNC_PPS_CD_NEG... " >&6; }
+case "$ac_cv_header_sys_ppsclock_h$ac_cv_header_linux_serial_h" in
+  yesyes)
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/time.h>
+typedef int u_int;
+
+#include <sys/ppsclock.h>
+#include <linux/serial.h>
+
+#ifdef TIOCGSERIAL
+#ifdef TIOCSSERIAL
+#ifdef ASYNC_PPS_CD_POS
+#ifdef ASYNC_PPS_CD_NEG
+#ifdef CIOGETEV
+         yes
+#endif
+#endif
+#endif
+#endif
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ntp_ok=yes
+fi
+rm -f conftest*
+
+       ;;
+  *)
+       ntp_ok=no
+       ;;
+esac
+if test "$ntp_ok" = "yes"; then
+
+$as_echo "#define HAVE_TIO_SERIAL_STUFF 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+# Check for SHMEM_STATUS support
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking SHMEM_STATUS support" >&5
+$as_echo_n "checking SHMEM_STATUS support... " >&6; }
+case "$ac_cv_header_sys_mman_h" in
+ yes) ntp_ok=yes ;;
+ *)   ntp_ok=no  ;;
+esac
+if test "$ntp_ok" = "yes"; then
+
+$as_echo "#define ONCORE_SHMEM_STATUS 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+
+ntp_refclock=no
+
+# HPUX only, and by explicit request
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Datum/Bancomm bc635/VME interface" >&5
+$as_echo_n "checking Datum/Bancomm bc635/VME interface... " >&6; }
+# Check whether --enable-BANCOMM was given.
+if test "${enable_BANCOMM+set}" = set; then :
+  enableval=$enable_BANCOMM; ntp_ok=$enableval
+else
+  ntp_ok=no
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_BANC 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$host" in
+ yes*-*-hpux*) ;;
+ yes*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** But the expected answer is... no ***" >&5
+$as_echo "$as_me: WARNING: *** But the expected answer is... no ***" >&2;} ;;
+esac
+
+#HPUX only, and only by explicit request
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking TrueTime GPS receiver/VME interface" >&5
+$as_echo_n "checking TrueTime GPS receiver/VME interface... " >&6; }
+# Check whether --enable-GPSVME was given.
+if test "${enable_GPSVME+set}" = set; then :
+  enableval=$enable_GPSVME; ntp_ok=$enableval
+else
+  ntp_ok=no
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_GPSVME 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$host" in
+ yes*-*-hpux*) ;;
+ yes*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** But the expected answer is... no ***" >&5
+$as_echo "$as_me: WARNING: *** But the expected answer is... no ***" >&2;} ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for PCL720 clock support" >&5
+$as_echo_n "checking for PCL720 clock support... " >&6; }
+case "$ac_cv_header_machine_inline_h$ac_cv_header_sys_pcl720_h$ac_cv_header_sys_i8253_h" in
+ yesyesyes)
+
+$as_echo "#define CLOCK_PPS720 1" >>confdefs.h
+
+    ans=yes
+    ;;
+ *)
+    ans=no
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default inclusion of all suitable non-PARSE clocks" >&5
+$as_echo_n "checking for default inclusion of all suitable non-PARSE clocks... " >&6; }
+# Check whether --enable-all-clocks was given.
+if test "${enable_all_clocks+set}" = set; then :
+  enableval=$enable_all_clocks; ntp_eac=$enableval
+else
+  ntp_eac=yes
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_eac" >&5
+$as_echo "$ntp_eac" >&6; }
+
+# HMS: Should we also require ac_cv_var_parse_ok?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have support for PARSE clocks" >&5
+$as_echo_n "checking if we have support for PARSE clocks... " >&6; }
+case "$ac_cv_var_atom_ok$ac_cv_header_termio_h$ac_cv_header_termios_h" in
+ yes*yes*)
+    ntp_canparse=yes
+    ;;
+ *) ntp_canparse=no
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_canparse" >&5
+$as_echo "$ntp_canparse" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have support for audio clocks" >&5
+$as_echo_n "checking if we have support for audio clocks... " >&6; }
+case "$ac_cv_header_sun_audioio_h$ac_cv_header_sys_audioio_h$ac_cv_header_machine_soundcard_h$ac_cv_header_sys_soundcard_h" in
+ *yes*)
+    ntp_canaudio=yes
+
+$as_echo "#define HAVE_AUDIO /**/" >>confdefs.h
+
+    ;;
+ *) ntp_canaudio=no ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_canaudio" >&5
+$as_echo "$ntp_canaudio" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have support for the SHM refclock interface" >&5
+$as_echo_n "checking if we have support for the SHM refclock interface... " >&6; }
+case "$ac_cv_header_sys_ipc_h$ac_cv_header_sys_shm_h" in
+ yesyes)
+    ntp_canshm=yes
+    ;;
+ *) ntp_canshm=no ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_canshm" >&5
+$as_echo "$ntp_canshm" >&6; }
+
+# Requires modem control
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking ACTS modem service" >&5
+$as_echo_n "checking ACTS modem service... " >&6; }
+# Check whether --enable-ACTS was given.
+if test "${enable_ACTS+set}" = set; then :
+  enableval=$enable_ACTS; ntp_ok=$enableval
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <termios.h>
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef TIOCMBIS
+         yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ntp_ok=$ntp_eac
+else
+  ntp_ok=no
+fi
+rm -f conftest*
+
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_ACTS 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Arbiter 1088A/B GPS receiver" >&5
+$as_echo_n "checking Arbiter 1088A/B GPS receiver... " >&6; }
+# Check whether --enable-ARBITER was given.
+if test "${enable_ARBITER+set}" = set; then :
+  enableval=$enable_ARBITER; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_ARBITER 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Arcron MSF receiver" >&5
+$as_echo_n "checking Arcron MSF receiver... " >&6; }
+# Check whether --enable-ARCRON_MSF was given.
+if test "${enable_ARCRON_MSF+set}" = set; then :
+  enableval=$enable_ARCRON_MSF; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_ARCRON_MSF 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Austron 2200A/2201A GPS receiver" >&5
+$as_echo_n "checking Austron 2200A/2201A GPS receiver... " >&6; }
+# Check whether --enable-AS2201 was given.
+if test "${enable_AS2201+set}" = set; then :
+  enableval=$enable_AS2201; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_AS2201 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking ATOM PPS interface" >&5
+$as_echo_n "checking ATOM PPS interface... " >&6; }
+# Check whether --enable-ATOM was given.
+if test "${enable_ATOM+set}" = set; then :
+  enableval=$enable_ATOM; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+case "$ac_cv_var_atom_ok" in
+ no) ntp_ok=no ;;
+esac
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_ATOM 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Chrono-log K-series WWVB receiver" >&5
+$as_echo_n "checking Chrono-log K-series WWVB receiver... " >&6; }
+# Check whether --enable-CHRONOLOG was given.
+if test "${enable_CHRONOLOG+set}" = set; then :
+  enableval=$enable_CHRONOLOG; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_CHRONOLOG 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CHU modem/decoder" >&5
+$as_echo_n "checking CHU modem/decoder... " >&6; }
+# Check whether --enable-CHU was given.
+if test "${enable_CHU+set}" = set; then :
+  enableval=$enable_CHU; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_CHU 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+ac_refclock_chu=$ntp_ok
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking CHU audio/decoder" >&5
+$as_echo_n "checking CHU audio/decoder... " >&6; }
+# Check whether --enable-AUDIO-CHU was given.
+if test "${enable_AUDIO_CHU+set}" = set; then :
+  enableval=$enable_AUDIO_CHU; ntp_ok=$enableval
+else
+  case "$ntp_eac$ac_refclock_chu$ntp_canaudio" in
+ *no*) ntp_ok=no  ;;
+ *)    ntp_ok=yes ;;
+esac
+fi
+
+if test "$ntp_ok" = "yes"; then
+
+$as_echo "#define AUDIO_CHU 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+# We used to check for sunos/solaris target...
+case "$ntp_ok$ac_refclock_chu$ntp_canaudio" in
+ yes*no*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** But the expected answer is...no ***" >&5
+$as_echo "$as_me: WARNING: *** But the expected answer is...no ***" >&2;} ;;
+esac
+
+# Not under HP-UX
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Datum Programmable Time System" >&5
+$as_echo_n "checking Datum Programmable Time System... " >&6; }
+# Check whether --enable-DATUM was given.
+if test "${enable_DATUM+set}" = set; then :
+  enableval=$enable_DATUM; ntp_ok=$enableval
+else
+  case "$ac_cv_header_termios_h" in
+    yes)
+        ntp_ok=$ntp_eac
+        ;;
+    *) ntp_ok=no
+        ;;
+    esac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_DATUM 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Dumb generic hh:mm:ss local clock" >&5
+$as_echo_n "checking Dumb generic hh:mm:ss local clock... " >&6; }
+# Check whether --enable-DUMBCLOCK was given.
+if test "${enable_DUMBCLOCK+set}" = set; then :
+  enableval=$enable_DUMBCLOCK; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_DUMBCLOCK 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Forum Graphic GPS" >&5
+$as_echo_n "checking Forum Graphic GPS... " >&6; }
+# Check whether --enable-FG was given.
+if test "${enable_FG+set}" = set; then :
+  enableval=$enable_FG; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_FG 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+# Requires modem control
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Heath GC-1000 WWV/WWVH receiver" >&5
+$as_echo_n "checking Heath GC-1000 WWV/WWVH receiver... " >&6; }
+# Check whether --enable-HEATH was given.
+if test "${enable_HEATH+set}" = set; then :
+  enableval=$enable_HEATH; ntp_ok=$enableval
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <termios.h>
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef TIOCMBIS
+         yes
+#endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "yes" >/dev/null 2>&1; then :
+  ntp_ok=$ntp_eac
+else
+  ntp_ok=no
+fi
+rm -f conftest*
+
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_HEATH 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for hopf serial clock device" >&5
+$as_echo_n "checking for hopf serial clock device... " >&6; }
+# Check whether --enable-HOPFSERIAL was given.
+if test "${enable_HOPFSERIAL+set}" = set; then :
+  enableval=$enable_HOPFSERIAL; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_HOPF_SERIAL 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for hopf PCI clock 6039" >&5
+$as_echo_n "checking for hopf PCI clock 6039... " >&6; }
+# Check whether --enable-HOPFPCI was given.
+if test "${enable_HOPFPCI+set}" = set; then :
+  enableval=$enable_HOPFPCI; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_HOPF_PCI 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking HP 58503A GPS receiver" >&5
+$as_echo_n "checking HP 58503A GPS receiver... " >&6; }
+# Check whether --enable-HPGPS was given.
+if test "${enable_HPGPS+set}" = set; then :
+  enableval=$enable_HPGPS; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_HPGPS 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking IRIG audio decoder" >&5
+$as_echo_n "checking IRIG audio decoder... " >&6; }
+# Check whether --enable-IRIG was given.
+if test "${enable_IRIG+set}" = set; then :
+  enableval=$enable_IRIG; ntp_ok=$enableval
+else
+  case "$ntp_eac$ntp_canaudio" in
+     *no*)     ntp_ok=no  ;;
+     *)                ntp_ok=yes ;;
+    esac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_IRIG 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canaudio" in
+ yesno) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** But the expected answer is... no ***" >&5
+$as_echo "$as_me: WARNING: *** But the expected answer is... no ***" >&2;} ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for JJY receiver" >&5
+$as_echo_n "checking for JJY receiver... " >&6; }
+# Check whether --enable-JJY was given.
+if test "${enable_JJY+set}" = set; then :
+  enableval=$enable_JJY; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_JJY 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Rockwell Jupiter GPS receiver" >&5
+$as_echo_n "checking Rockwell Jupiter GPS receiver... " >&6; }
+# Check whether --enable-JUPITER was given.
+if test "${enable_JUPITER+set}" = set; then :
+  enableval=$enable_JUPITER; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+case "$ac_cv_var_jupiter_ok" in
+ no) ntp_ok=no ;;
+esac
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_JUPITER 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Leitch CSD 5300 Master Clock System Driver" >&5
+$as_echo_n "checking Leitch CSD 5300 Master Clock System Driver... " >&6; }
+# Check whether --enable-LEITCH was given.
+if test "${enable_LEITCH+set}" = set; then :
+  enableval=$enable_LEITCH; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_LEITCH 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking local clock reference" >&5
+$as_echo_n "checking local clock reference... " >&6; }
+# Check whether --enable-LOCAL-CLOCK was given.
+if test "${enable_LOCAL_CLOCK+set}" = set; then :
+  enableval=$enable_LOCAL_CLOCK; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_LOCAL 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+
+# Not Ultrix
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Magnavox MX4200 GPS receiver" >&5
+$as_echo_n "checking Magnavox MX4200 GPS receiver... " >&6; }
+# Check whether --enable-MX4200 was given.
+if test "${enable_MX4200+set}" = set; then :
+  enableval=$enable_MX4200; ntp_ok=$enableval
+else
+  case "$ac_cv_var_ppsclock" in
+     yes) ntp_ok=$ntp_eac
+        ;;
+     *) ntp_ok=no
+        ;;
+    esac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_MX4200 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$host" in
+ yes*-*-ultrix*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** But the expected answer is... no ***" >&5
+$as_echo "$as_me: WARNING: *** But the expected answer is... no ***" >&2;} ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for NeoClock4X receiver" >&5
+$as_echo_n "checking for NeoClock4X receiver... " >&6; }
+# Check whether --enable-NEOCLOCK4X was given.
+if test "${enable_NEOCLOCK4X+set}" = set; then :
+  enableval=$enable_NEOCLOCK4X; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_NEOCLOCK4X 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking NMEA GPS receiver" >&5
+$as_echo_n "checking NMEA GPS receiver... " >&6; }
+# Check whether --enable-NMEA was given.
+if test "${enable_NMEA+set}" = set; then :
+  enableval=$enable_NMEA; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_NMEA 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ONCORE Motorola VP/UT Oncore GPS" >&5
+$as_echo_n "checking for ONCORE Motorola VP/UT Oncore GPS... " >&6; }
+# Check whether --enable-ONCORE was given.
+if test "${enable_ONCORE+set}" = set; then :
+  enableval=$enable_ONCORE; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+case "$ac_cv_var_oncore_ok" in
+ no) ntp_ok=no ;;
+esac
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_ONCORE 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Palisade clock" >&5
+$as_echo_n "checking for Palisade clock... " >&6; }
+# Check whether --enable-PALISADE was given.
+if test "${enable_PALISADE+set}" = set; then :
+  enableval=$enable_PALISADE; ntp_ok=$enableval
+else
+  case "$ac_cv_header_termios_h" in
+    yes)
+        ntp_ok=$ntp_eac
+        ;;
+    *) ntp_ok=no
+        ;;
+    esac
+fi
+
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_PALISADE 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Conrad parallel port radio clock" >&5
+$as_echo_n "checking Conrad parallel port radio clock... " >&6; }
+# Check whether --enable-PCF was given.
+if test "${enable_PCF+set}" = set; then :
+  enableval=$enable_PCF; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_PCF 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking PST/Traconex 1020 WWV/WWVH receiver" >&5
+$as_echo_n "checking PST/Traconex 1020 WWV/WWVH receiver... " >&6; }
+# Check whether --enable-PST was given.
+if test "${enable_PST+set}" = set; then :
+  enableval=$enable_PST; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_PST 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking RIPENCC specific Trimble driver" >&5
+$as_echo_n "checking RIPENCC specific Trimble driver... " >&6; }
+# Check whether --enable-RIPENCC was given.
+if test "${enable_RIPENCC+set}" = set; then :
+  enableval=$enable_RIPENCC; ntp_ok=$enableval
+else
+  ntp_ok=no
+fi
+
+# 020629: HMS: s/$ntp_eac -> -/no because of ptr += sprintf(ptr, ...) usage
+case "$ac_cv_var_ripe_ncc_ok" in
+ no) ntp_ok=no ;;
+esac
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_RIPENCC /**/" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+# Danny Meyer says SHM compiles (with a few warnings) under Win32.
+# For *IX, we need sys/ipc.h and sys/shm.h.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for SHM clock attached thru shared memory" >&5
+$as_echo_n "checking for SHM clock attached thru shared memory... " >&6; }
+# Check whether --enable-SHM was given.
+if test "${enable_SHM+set}" = set; then :
+  enableval=$enable_SHM; ntp_ok=$enableval
+else
+  case "$ntp_eac$ntp_canshm" in
+ *no*) ntp_ok=no  ;;
+ *)    ntp_ok=yes ;;
+esac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_SHM 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Spectracom 8170/Netclock/2 WWVB receiver" >&5
+$as_echo_n "checking Spectracom 8170/Netclock/2 WWVB receiver... " >&6; }
+# Check whether --enable-SPECTRACOM was given.
+if test "${enable_SPECTRACOM+set}" = set; then :
+  enableval=$enable_SPECTRACOM; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_SPECTRACOM 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking KSI/Odetics TPRO/S GPS receiver/IRIG interface" >&5
+$as_echo_n "checking KSI/Odetics TPRO/S GPS receiver/IRIG interface... " >&6; }
+# Check whether --enable-TPRO was given.
+if test "${enable_TPRO+set}" = set; then :
+  enableval=$enable_TPRO; ntp_ok=$enableval
+else
+  case "$ac_cv_header_sys_tpro_h" in
+     yes)
+       ntp_ok=$ntp_eac
+       ;;
+     *)        ntp_ok=no
+       ;;
+    esac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_TPRO 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ac_cv_header_sys_tpro" in
+ yesno) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** But the expected answer is... no ***" >&5
+$as_echo "$as_me: WARNING: *** But the expected answer is... no ***" >&2;} ;;
+esac
+
+
+# Not on a vax-dec-bsd
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Kinemetrics/TrueTime receivers" >&5
+$as_echo_n "checking Kinemetrics/TrueTime receivers... " >&6; }
+# Check whether --enable-TRUETIME was given.
+if test "${enable_TRUETIME+set}" = set; then :
+  enableval=$enable_TRUETIME; ntp_ok=$enableval
+else
+  case "$host" in
+     vax-dec-bsd)
+       ntp_ok=no
+       ;;
+     *)
+       ntp_ok=$ntp_eac
+       ;;
+    esac
+fi
+
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_TRUETIME 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$host" in
+ yesvax-dec-bsd) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** But the expected answer is... no ***" >&5
+$as_echo "$as_me: WARNING: *** But the expected answer is... no ***" >&2;} ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking TrueTime 560 IRIG-B decoder" >&5
+$as_echo_n "checking TrueTime 560 IRIG-B decoder... " >&6; }
+# Check whether --enable-TT560 was given.
+if test "${enable_TT560+set}" = set; then :
+  enableval=$enable_TT560; ntp_ok=$enableval
+else
+  ntp_ok=no
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_TT560 /**/" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Ultralink M320 WWVB receiver" >&5
+$as_echo_n "checking Ultralink M320 WWVB receiver... " >&6; }
+# Check whether --enable-ULINK was given.
+if test "${enable_ULINK+set}" = set; then :
+  enableval=$enable_ULINK; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_ULINK 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking WWV receiver" >&5
+$as_echo_n "checking WWV receiver... " >&6; }
+# Check whether --enable-WWV was given.
+if test "${enable_WWV+set}" = set; then :
+  enableval=$enable_WWV; ntp_ok=$enableval
+else
+  case "$ntp_eac$ntp_canaudio" in
+     *no*)     ntp_ok=no  ;;
+     *)                ntp_ok=yes ;;
+    esac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_WWV 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canaudio" in
+ yesno) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: *** But the expected answer is... no ***" >&5
+$as_echo "$as_me: WARNING: *** But the expected answer is... no ***" >&2;} ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Zyfer receiver" >&5
+$as_echo_n "checking for Zyfer receiver... " >&6; }
+# Check whether --enable-ZYFER was given.
+if test "${enable_ZYFER+set}" = set; then :
+  enableval=$enable_ZYFER; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eac
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_ZYFER 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for default inclusion of all suitable PARSE clocks" >&5
+$as_echo_n "checking for default inclusion of all suitable PARSE clocks... " >&6; }
+# Check whether --enable-parse-clocks was given.
+if test "${enable_parse_clocks+set}" = set; then :
+  enableval=$enable_parse_clocks; ntp_eapc=$enableval
+else
+  case "$ntp_eac" in
+     yes) ntp_eapc=$ntp_canparse ;;
+     *) ntp_eapc=no ;;
+    esac
+    # Delete the next line one of these days
+    ntp_eapc=no
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_eapc" >&5
+$as_echo "$ntp_eapc" >&6; }
+
+case "$ntp_eac$ntp_eapc$ntp_canparse" in
+ noyes*)
+    as_fn_error "\"--enable-parse-clocks\" requires \"--enable-all-clocks\"." "$LINENO" 5
+    ;;
+ yesyesno)
+    as_fn_error "You said \"--enable-parse-clocks\" but PARSE isn't supported on this platform!" "$LINENO" 5
+    ;;
+ *) ;;
+esac
+
+ntp_libparse=no
+ntp_parseutil=no
+ntp_rawdcf=no
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Diem Computime Radio Clock" >&5
+$as_echo_n "checking Diem Computime Radio Clock... " >&6; }
+# Check whether --enable-COMPUTIME was given.
+if test "${enable_COMPUTIME+set}" = set; then :
+  enableval=$enable_COMPUTIME; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_COMPUTIME 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking ELV/DCF7000 clock" >&5
+$as_echo_n "checking ELV/DCF7000 clock... " >&6; }
+# Check whether --enable-DCF7000 was given.
+if test "${enable_DCF7000+set}" = set; then :
+  enableval=$enable_DCF7000; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_DCF7000 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking HOPF 6021 clock" >&5
+$as_echo_n "checking HOPF 6021 clock... " >&6; }
+# Check whether --enable-HOPF6021 was given.
+if test "${enable_HOPF6021+set}" = set; then :
+  enableval=$enable_HOPF6021; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_HOPF6021 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Meinberg clocks" >&5
+$as_echo_n "checking Meinberg clocks... " >&6; }
+# Check whether --enable-MEINBERG was given.
+if test "${enable_MEINBERG+set}" = set; then :
+  enableval=$enable_MEINBERG; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_MEINBERG 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking DCF77 raw time code" >&5
+$as_echo_n "checking DCF77 raw time code... " >&6; }
+# Check whether --enable-RAWDCF was given.
+if test "${enable_RAWDCF+set}" = set; then :
+  enableval=$enable_RAWDCF; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_parseutil=yes
+    ntp_refclock=yes
+    ntp_rawdcf=yes
+
+$as_echo "#define CLOCK_RAWDCF 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+case "$ntp_rawdcf" in
+ yes)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we must enable parity for RAWDCF" >&5
+$as_echo_n "checking if we must enable parity for RAWDCF... " >&6; }
+if test "${ac_cv_var_rawdcf_parity+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=no
+    case "$host" in
+     *-*-*linux*)
+        ans=yes
+        ;;
+    esac
+    ac_cv_var_rawdcf_parity=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_rawdcf_parity" >&5
+$as_echo "$ac_cv_var_rawdcf_parity" >&6; }
+    case "$ac_cv_var_rawdcf_parity" in
+     yes)
+$as_echo "#define RAWDCF_NO_IGNPAR 1" >>confdefs.h
+ ;;
+    esac
+    ;;
+
+ *) # HMS: Is this a good idea?
+    ac_cv_var_rawdcf_parity=no
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking RCC 8000 clock" >&5
+$as_echo_n "checking RCC 8000 clock... " >&6; }
+# Check whether --enable-RCC8000 was given.
+if test "${enable_RCC8000+set}" = set; then :
+  enableval=$enable_RCC8000; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_RCC8000 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Schmid DCF77 clock" >&5
+$as_echo_n "checking Schmid DCF77 clock... " >&6; }
+# Check whether --enable-SCHMID was given.
+if test "${enable_SCHMID+set}" = set; then :
+  enableval=$enable_SCHMID; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_SCHMID 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Trimble GPS receiver/TAIP protocol" >&5
+$as_echo_n "checking Trimble GPS receiver/TAIP protocol... " >&6; }
+# Check whether --enable-TRIMTAIP was given.
+if test "${enable_TRIMTAIP+set}" = set; then :
+  enableval=$enable_TRIMTAIP; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_TRIMTAIP 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking Trimble GPS receiver/TSIP protocol" >&5
+$as_echo_n "checking Trimble GPS receiver/TSIP protocol... " >&6; }
+# Check whether --enable-TRIMTSIP was given.
+if test "${enable_TRIMTSIP+set}" = set; then :
+  enableval=$enable_TRIMTSIP; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_TRIMTSIP 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking WHARTON 400A Series clock" >&5
+$as_echo_n "checking WHARTON 400A Series clock... " >&6; }
+# Check whether --enable-WHARTON was given.
+if test "${enable_WHARTON+set}" = set; then :
+  enableval=$enable_WHARTON; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_WHARTON_400A 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking VARITEXT clock" >&5
+$as_echo_n "checking VARITEXT clock... " >&6; }
+# Check whether --enable-VARITEXT was given.
+if test "${enable_VARITEXT+set}" = set; then :
+  enableval=$enable_VARITEXT; ntp_ok=$enableval
+else
+  ntp_ok=$ntp_eapc
+fi
+
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+
+$as_echo "#define CLOCK_VARITEXT 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_ok" >&5
+$as_echo "$ntp_ok" >&6; }
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    as_fn_error "That's a parse clock and this system doesn't support it!" "$LINENO" 5
+    ;;
+esac
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need to make and use the parse libraries" >&5
+$as_echo_n "checking if we need to make and use the parse libraries... " >&6; }
+ans=no
+case "$ntp_libparse" in
+ yes)
+    ans=yes
+
+$as_echo "#define CLOCK_PARSE 1" >>confdefs.h
+
+    LIBPARSE=../libparse/libparse.a
+    MAKE_LIBPARSE=libparse.a
+    # HMS: check_y2k trips the 34 year problem now...
+    false && MAKE_CHECK_Y2K=check_y2k
+
+$as_echo "#define PPS_SAMPLE 1" >>confdefs.h
+
+    $as_echo "#define CLOCK_ATOM 1" >>confdefs.h
+
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+# AC_SUBST(RSAOBJS)
+# AC_SUBST(RSASRCS)
+# AC_SUBST(RSADIR)
+# AC_SUBST(RSAREF)
+# AC_SUBST(LIBRSAREF)
+# AC_SUBST(MAKE_LIBRSAREF)
+
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl library directory" >&5
+$as_echo_n "checking for openssl library directory... " >&6; }
+
+# Check whether --with-openssl-libdir was given.
+if test "${with_openssl_libdir+set}" = set; then :
+  withval=$with_openssl_libdir; ans=$withval
+else
+  case "$build" in
+ $host) ans=yes ;;
+ *)     ans=no ;;
+esac
+fi
+
+case "$ans" in
+ no) ;;
+ yes) # Look in:
+    ans="/usr/lib /usr/lib/openssl /usr/sfw/lib /usr/local/lib /usr/local/ssl/lib"
+    ;;
+ *) # Look where they said
+    ;;
+esac
+case "$ans" in
+ no) ;;
+ *) # Look for libcrypto.a and libssl.a:
+    for i in $ans no
+    do
+       case "$host" in
+        *-*-darwin*)
+           test -f $i/libcrypto.dylib -a -f $i/libssl.dylib && break
+           ;;
+        *)
+           test -f $i/libcrypto.so -a -f $i/libssl.so && break
+           test -f $i/libcrypto.a -a -f $i/libssl.a && break
+           ;;
+       esac
+    done
+    case "$i" in
+     no)
+       ans=no
+       OPENSSL_LIB=
+       ;;
+     *) ans=$i
+       OPENSSL_LIB=$ans
+       ;;
+    esac
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for openssl include directory" >&5
+$as_echo_n "checking for openssl include directory... " >&6; }
+
+# Check whether --with-openssl-incdir was given.
+if test "${with_openssl_incdir+set}" = set; then :
+  withval=$with_openssl_incdir; ans=$withval
+else
+  case "$build" in
+ $host) ans=yes ;;
+ *)     ans=no ;;
+esac
+fi
+
+case "$ans" in
+ no) ;;
+ yes) # look in:
+    ans="/usr/include /usr/sfw/include /usr/local/include /usr/local/ssl/include"
+    ;;
+ *) # Look where they said
+    ;;
+esac
+case "$ans" in
+ no) ;;
+ *) # look for openssl/opensslconf.h:
+    for i in $ans no
+    do
+       test -f $i/openssl/opensslconf.h && break
+    done
+    case "$i" in
+     no)
+       ans=no
+       OPENSSL_INC=
+       ;;
+     *) ans=$i
+       OPENSSL_INC=$ans
+       ;;
+    esac
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+
+# Check whether --with-crypto was given.
+if test "${with_crypto+set}" = set; then :
+  withval=$with_crypto; ans=$withval
+else
+  ans=yes
+fi
+
+case "$ans" in
+ no) ;;
+ yes|openssl)
+    if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INC"
+    then
+       ans=no
+    else
+       # We have OpenSSL inc/lib - use them.
+       ans=openssl
+       CPPFLAGS="$CPPFLAGS -I$OPENSSL_INC"
+       LDFLAGS="$LDFLAGS -L$OPENSSL_LIB"
+       case "$need_dash_r" in
+        1) LDFLAGS="$LDFLAGS -R$OPENSSL_LIB"
+           ;;
+       esac
+       LCRYPTO=-lcrypto
+
+
+$as_echo "#define OPENSSL /**/" >>confdefs.h
+
+       for ac_func in EVP_md2 EVP_mdc2
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+    fi
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the level of crypto support" >&5
+$as_echo_n "checking for the level of crypto support... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want to compile with ElectricFence" >&5
+$as_echo_n "checking if we want to compile with ElectricFence... " >&6; }
+
+# Check whether --with-electricfence was given.
+if test "${with_electricfence+set}" = set; then :
+  withval=$with_electricfence; ans=$withval
+else
+  ans=no
+fi
+
+case "$ans" in
+ no) ;;
+ *)
+    LIBS="$LIBS \${top_builddir}/ElectricFence/libefence.a"
+    EF_PROGS="eftest tstheap"
+
+    EF_LIBS=libefence.a
+
+    ans=yes
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want to run check-layout" >&5
+$as_echo_n "checking if we want to run check-layout... " >&6; }
+case "$cross_compiling$PATH_PERL" in
+ no/*)
+    MAKE_CHECK_LAYOUT=check-layout
+    ans=yes
+    ;;
+ *)
+    ans=no
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can make dcf parse utilities" >&5
+$as_echo_n "checking if we can make dcf parse utilities... " >&6; }
+ans=no
+if test "$ntp_parseutil" = "yes"; then
+    case "$host" in
+     *-*-sunos4*|*-*-solaris2*|*-*-*linux*|*-*-netbsd*)
+       ans="dcfd testdcf"
+       DCFD=dcfd
+        TESTDCF=testdcf
+       ;;
+    esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can build kernel streams modules for parse" >&5
+$as_echo_n "checking if we can build kernel streams modules for parse... " >&6; }
+ans=no
+case "$ntp_parseutil$ac_cv_header_sys_stropts_h" in
+ yesyes)
+    case "$host" in
+     sparc-*-sunos4*)
+        case "$ac_cv_var_kernel_pll" in
+       yes)
+
+$as_echo "#define PPS_SYNC 1" >>confdefs.h
+
+           ;;
+       esac
+       ans=parsestreams
+       MAKE_PARSEKMODULE=parsestreams.loadable_module.o
+       ;;
+     sparc-*-solaris2*)
+       ans=parsesolaris
+       MAKE_PARSEKMODULE=parse
+       ;;
+    esac
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we need basic refclock support" >&5
+$as_echo_n "checking if we need basic refclock support... " >&6; }
+if test "$ntp_refclock" = "yes"; then
+
+$as_echo "#define REFCLOCK 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_refclock" >&5
+$as_echo "$ntp_refclock" >&6; }
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want HP-UX adjtimed support" >&5
+$as_echo_n "checking if we want HP-UX adjtimed support... " >&6; }
+case "$host" in
+ *-*-hpux[56789]*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+if test "$ans" = "yes"; then
+    MAKE_ADJTIMED=adjtimed
+
+$as_echo "#define NEED_HPUX_ADJTIME 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want QNX adjtime support" >&5
+$as_echo_n "checking if we want QNX adjtime support... " >&6; }
+case "$host" in
+ *-*-qnx*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+if test "$ans" = "yes"; then
+
+$as_echo "#define NEED_QNX_ADJTIME 1" >>confdefs.h
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can read kmem" >&5
+$as_echo_n "checking if we can read kmem... " >&6; }
+
+#  the default is to enable it if the system has the capability
+
+case "$ac_cv_func_nlist$ac_cv_func_K_open$ac_cv_func_kvm_open" in
+ *yes*)
+    ans=yes
+    ;;
+ *) ans=no
+esac
+
+case "$host" in
+ *-*-domainos) # Won't be found...
+    ans=no
+    ;;
+ *-*-hpux*)
+    #ans=no
+    ;;
+ *-*-irix[456]*)
+    ans=no
+    ;;
+ *-*-*linux*)
+    ans=no
+    ;;
+ *-*-winnt3.5)
+    ans=no
+    ;;
+ *-*-unicosmp*)
+    ans=no
+    ;;
+esac
+
+# --enable-kmem / --disable-kmem controls if present
+# Check whether --enable-kmem was given.
+if test "${enable_kmem+set}" = set; then :
+  enableval=$enable_kmem; ans=$enableval
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ yes)
+    can_kmem=yes
+    ;;
+ *)
+    can_kmem=no
+
+$as_echo "#define NOKMEM 1" >>confdefs.h
+
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if adjtime is accurate" >&5
+$as_echo_n "checking if adjtime is accurate... " >&6; }
+
+# target-dependent defaults
+
+case "$host" in
+ i386-sequent-ptx*)
+    ans=no
+    ;;
+ i386-unknown-osf1*)
+    ans=yes
+    ;;
+ mips-sgi-irix[456]*)
+    ans=yes
+    ;;
+ *-fujitsu-uxp*)
+    ans=yes
+    ;;
+ *-ibm-aix[456]*)
+    ans=yes
+    ;;
+ *-*-*linux*)
+    ans=yes
+    ;;
+ *-*-solaris2.[01])
+    ans=no
+    ;;
+ *-*-solaris2*)
+    ans=yes
+    ;;
+ *-*-unicosmp*)
+    ans=yes
+    ;;
+ *) ans=no
+esac
+
+# --enable-accurate-adjtime / --disable-accurate-adjtime
+# override the default
+# Check whether --enable-accurate-adjtime was given.
+if test "${enable_accurate_adjtime+set}" = set; then :
+  enableval=$enable_accurate_adjtime; ans=$enableval
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ yes)
+
+$as_echo "#define ADJTIME_IS_ACCURATE 1" >>confdefs.h
+
+    adjtime_is_accurate=yes
+    ;;
+ *)
+    adjtime_is_accurate=no
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name of 'tick' in the kernel" >&5
+$as_echo_n "checking the name of 'tick' in the kernel... " >&6; }
+if test "${ac_cv_var_nlist_tick+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=_tick
+case "$host" in
+ m68*-hp-hpux*) # HP9000/300?
+    ans=_old_tick
+    ;;
+ *-apple-aux[23]*)
+    ans=tick
+    ;;
+ *-hp-hpux*)
+    ans=old_tick
+    ;;
+ *-ibm-aix[3456]*)
+    ans=no
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-ptx*)
+    ans=tick
+    ;;
+ *-*-sco3.2v[45]*)
+    ans=no
+    ;;
+ *-*-solaris2*)
+    ans=nsec_per_tick
+    ;;
+ *-*-sysv4*)
+    ans=tick
+    ;;
+esac
+ac_cv_var_nlist_tick=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_nlist_tick" >&5
+$as_echo "$ac_cv_var_nlist_tick" >&6; }
+case "$ac_cv_var_nlist_tick" in
+ ''|no) ;;     # HMS: I think we can only get 'no' here...
+ *)
+cat >>confdefs.h <<_ACEOF
+#define K_TICK_NAME "$ac_cv_var_nlist_tick"
+_ACEOF
+ ;;
+esac
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the units of 'tick'" >&5
+$as_echo_n "checking for the units of 'tick'... " >&6; }
+if test "${ac_cv_var_tick_nano+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=usec
+case "$host" in
+ *-*-solaris2*)
+    ans=nsec
+    ;;
+esac
+ac_cv_var_tick_nano=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tick_nano" >&5
+$as_echo "$ac_cv_var_tick_nano" >&6; }
+case "$ac_cv_var_tick_nano" in
+ nsec)
+
+$as_echo "#define TICK_NANO 1" >>confdefs.h
+
+    ;;
+esac
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the name of 'tickadj' in the kernel" >&5
+$as_echo_n "checking the name of 'tickadj' in the kernel... " >&6; }
+if test "${ac_cv_var_nlist_tickadj+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=_tickadj
+case "$host" in
+ m68*-hp-hpux*) # HP9000/300?
+    ans=_tickadj
+    ;;
+ *-apple-aux[23]*)
+    ans=tickadj
+    ;;
+ *-hp-hpux10*)
+    ans=no
+    ;;
+ *-hp-hpux9*)
+    ans=no
+    ;;
+ *-hp-hpux*)
+    ans=tickadj
+    ;;
+ *-*-aix*)
+    ans=tickadj
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-ptx*)
+    ans=tickadj
+    ;;
+ *-*-sco3.2v4*)
+    ans=no
+    ;;
+ *-*-sco3.2v5.0*)
+    ans=clock_drift
+    ;;
+ *-*-solaris2*)
+    ans=no     # hrestime_adj
+    ;;
+ *-*-sysv4*)
+    ans=tickadj
+    ;;
+esac
+ac_cv_var_nlist_tickadj=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_nlist_tickadj" >&5
+$as_echo "$ac_cv_var_nlist_tickadj" >&6; }
+case "$ac_cv_var_nlist_tickadj" in
+ ''|no) ;;     # HMS: I think we can only get 'no' here...
+ *)
+cat >>confdefs.h <<_ACEOF
+#define K_TICKADJ_NAME "$ac_cv_var_nlist_tickadj"
+_ACEOF
+ ;;
+esac
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for the units of 'tickadj'" >&5
+$as_echo_n "checking for the units of 'tickadj'... " >&6; }
+if test "${ac_cv_var_tickadj_nano+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ans=usec
+case "$host" in
+ *-*-solaris2*)
+    ans=nsec
+    ;;
+esac
+ac_cv_var_tickadj_nano=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_tickadj_nano" >&5
+$as_echo "$ac_cv_var_tickadj_nano" >&6; }
+case "$ac_cv_var_tickadj_nano" in
+ nsec)
+
+$as_echo "#define TICKADJ_NANO 1" >>confdefs.h
+
+    ;;
+esac
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking half-heartedly for 'dosynctodr' in the kernel" >&5
+$as_echo_n "checking half-heartedly for 'dosynctodr' in the kernel... " >&6; }
+if test "${ac_cv_var_nlist_dosynctodr+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$host" in
+ *-apple-aux[23]*)
+    ans=no
+    ;;
+ *-sni-sysv*)
+    ans=dosynctodr
+    ;;
+ *-*-aix*)
+    ans=dosynctodr
+    ;;
+ *-*-hpux*)
+    ans=no
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-nextstep*)
+    ans=_dosynctodr
+    ;;
+ *-*-ptx*)
+    ans=doresettodr
+    ;;
+ *-*-sco3.2v4*)
+    ans=no
+    ;;
+ *-*-sco3.2v5*)
+    ans=track_rtc
+    ;;
+ *-*-solaris2*)
+    ans=dosynctodr
+    ;;
+ *-*-sysv4*)
+    ans=doresettodr
+    ;;
+ *)
+    ans=_dosynctodr
+    ;;
+esac
+ac_cv_var_nlist_dosynctodr=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_nlist_dosynctodr" >&5
+$as_echo "$ac_cv_var_nlist_dosynctodr" >&6; }
+case "$ac_cv_var_nlist_dosynctodr" in
+ no) ;;
+ *)
+cat >>confdefs.h <<_ACEOF
+#define K_DOSYNCTODR_NAME "$ac_cv_var_nlist_dosynctodr"
+_ACEOF
+
+     ;;
+esac
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking half-heartedly for 'noprintf' in the kernel" >&5
+$as_echo_n "checking half-heartedly for 'noprintf' in the kernel... " >&6; }
+if test "${ac_cv_var_nlist_noprintf+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$host" in
+ *-apple-aux[23]*)
+    ans=no
+    ;;
+ *-sni-sysv*)
+    ans=noprintf
+    ;;
+ *-*-aix*)
+    ans=noprintf
+    ;;
+ *-*-hpux*)
+    ans=no
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-ptx*)
+    ans=noprintf
+    ;;
+ *-*-nextstep*)
+    ans=_noprintf
+    ;;
+ *-*-solaris2*)
+    ans=noprintf
+    ;;
+ *-*-sysv4*)
+    ans=noprintf
+    ;;
+ *)
+    ans=_noprintf
+    ;;
+esac
+ac_cv_var_nlist_noprintf=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_var_nlist_noprintf" >&5
+$as_echo "$ac_cv_var_nlist_noprintf" >&6; }
+case "$ac_cv_var_nlist_noprintf" in
+ no) ;;
+ *)
+cat >>confdefs.h <<_ACEOF
+#define K_NOPRINTF_NAME "$ac_cv_var_nlist_noprintf"
+_ACEOF
+
+     ;;
+esac
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a default value for 'tick'" >&5
+$as_echo_n "checking for a default value for 'tick'... " >&6; }
+
+# target-dependent default for tick
+
+case "$host" in
+ *-*-pc-cygwin*)
+    as_fn_error "tick needs work for cygwin" "$LINENO" 5
+    ;;
+ *-univel-sysv*)
+    ans=10000
+    ;;
+ *-*-irix*)
+    ans=10000
+    ;;
+ *-*-*linux*)
+    ans=txc.tick
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-winnt3.5)
+    ans='(every / 10)'
+    ;;
+ *-*-unicosmp*)
+    ans=10000
+    ;;
+ *)
+    ans='1000000L/hz'
+    ;;
+esac
+
+# Check whether --enable-tick was given.
+if test "${enable_tick+set}" = set; then :
+  enableval=$enable_tick; ans=$enableval
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ ''|no) ;;     # HMS: I think we can only get 'no' here...
+ *)
+cat >>confdefs.h <<_ACEOF
+#define PRESET_TICK $ans
+_ACEOF
+ ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a default value for 'tickadj'" >&5
+$as_echo_n "checking for a default value for 'tickadj'... " >&6; }
+
+# target-specific default
+
+ans='500/hz'
+
+case "$host" in
+ *-fujitsu-uxp*)
+    case "$adjtime_is_accurate" in
+     yes)
+         ans='tick/16'
+    esac
+    ;;
+ XXX-*-pc-cygwin*)
+    ans=no
+    ;;
+ *-univel-sysv*)
+    ans=80
+    ;;
+ *-*-aix*)
+    case "$can_kmem" in
+     no)
+       ans=1000
+    esac
+    ;;
+ *-*-domainos) # Skippy: won't be found...
+    case "$can_kmem" in
+     no)
+       ans=668
+    esac
+    ;;
+ *-*-hpux*)
+    case "$adjtime_is_accurate" in
+     yes)
+       ans='tick/16'
+    esac
+    ;;
+ *-*-irix*)
+    ans=150
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-sco3.2v5.0*)
+    ans=10000L/hz
+    ;;
+ *-*-winnt3.5)
+    ans=50
+    ;;
+ *-*-unicosmp*)
+    ans=150
+esac
+
+# Check whether --enable-tickadj was given.
+if test "${enable_tickadj+set}" = set; then :
+  enableval=$enable_tickadj; ans=$enableval
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+default_tickadj=$ans
+
+case "$default_tickadj" in
+ ''|no) ;;     # HMS: I think we can only get 'no' here...
+ *)
+cat >>confdefs.h <<_ACEOF
+#define PRESET_TICKADJ $default_tickadj
+_ACEOF
+ ;;
+esac
+
+# Newer versions of ReliantUNIX round adjtime() values down to
+# 1/100s (system tick). Sigh ...
+# Unfortunately, there is no easy way to know if particular release
+# has this "feature" or any obvious way to test for it.
+case "$host" in
+ mips-sni-sysv4*)
+$as_echo "#define RELIANTUNIX_CLOCK 1" >>confdefs.h
+ ;;
+esac
+
+case "$host" in
+ *-*-sco3.2v5*)
+$as_echo "#define SCO5_CLOCK 1" >>confdefs.h
+ ;;
+esac
+
+ac_cv_make_tickadj=yes
+case "$can_kmem$ac_cv_var_tick$default_tickadj" in
+ nonono)       # Don't read KMEM, no presets.  Bogus.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Can't read kmem, no PRESET_TICK or PRESET_TICKADJ.  No tickadj." >&5
+$as_echo "$as_me: WARNING: Can't read kmem, no PRESET_TICK or PRESET_TICKADJ.  No tickadj." >&2;}
+    ac_cv_make_tickadj=no
+    ;;
+ nono*)                # Don't read KMEM, no PRESET_TICK but PRESET_TICKADJ.  Bogus.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Can't read kmem but no PRESET_TICK.  No tickadj." >&5
+$as_echo "$as_me: WARNING: Can't read kmem but no PRESET_TICK.  No tickadj." >&2;}
+    ac_cv_make_tickadj=no
+    ;;
+ no*no)                # Don't read KMEM, PRESET_TICK but no PRESET_TICKADJ.  Bogus.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Can't read kmem but no PRESET_TICKADJ.  No tickadj." >&5
+$as_echo "$as_me: WARNING: Can't read kmem but no PRESET_TICKADJ.  No tickadj." >&2;}
+    ac_cv_make_tickadj=no
+    ;;
+ no*)          # Don't read KMEM, PRESET_TICK and PRESET_TICKADJ.  Cool.
+    ;;
+ yesnono)      # Read KMEM, no presets.  Cool.
+    ;;
+ yesno*)       # Read KMEM, no PRESET_TICK but PRESET_TICKADJ.  Bogus.
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: PRESET_TICKADJ is defined but not PRESET_TICK.  Please report this." >&5
+$as_echo "$as_me: WARNING: PRESET_TICKADJ is defined but not PRESET_TICK.  Please report this." >&2;}
+    ;;
+ yes*no)       # Read KMEM, PRESET_TICK but no PRESET_TICKADJ.  Cool.
+    ;;
+ yes*)         # READ KMEM, PRESET_TICK and PRESET_TICKADJ.
+    ;;
+ *)            # Generally bogus.
+    as_fn_error "This shouldn't happen." "$LINENO" 5
+    ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want and can make the ntptime utility" >&5
+$as_echo_n "checking if we want and can make the ntptime utility... " >&6; }
+if test "${ac_cv_make_ntptime+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$host" in
+ *) case "$ac_cv_struct_ntptimeval$ac_cv_var_kernel_pll" in
+     yesyes)
+       ans=yes
+       ;;
+     *)
+       ans=no
+       ;;
+    esac
+    ;;
+esac
+ac_cv_make_ntptime=$ans
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_make_ntptime" >&5
+$as_echo "$ac_cv_make_ntptime" >&6; }
+case "$ac_cv_make_ntptime" in
+ yes)
+    MAKE_NTPTIME=ntptime
+    ;;
+esac
+
+
+case "$host" in
+ mips-sni-sysv4*)
+    # tickadj is pretty useless on newer versions of ReliantUNIX
+    # Do not bother
+    ac_cv_make_tickadj=no
+    ;;
+ *-*-irix*)
+    ac_cv_make_tickadj=no
+    ;;
+ *-*-solaris2*)
+    # DLM says tickadj is a no-no starting with solaris2.5
+    case "$host" in
+     *-*-solaris2.1[0-9]*)
+       ac_cv_make_tickadj=no
+       ;;
+     *-*-solaris2.[0-4]*) ;;
+     *) ac_cv_make_tickadj=no ;;
+    esac
+    ;;
+ *-*-unicosmp*)
+    ac_cv_make_tickadj=no
+    ;;
+esac
+
+#
+# Despite all the above, we always make tickadj.  Setting
+# ac_cv_make_tickadj before AC_CACHE_CHECK will cause a false
+# report that the configuration variable was cached.  It may
+# be better to simply remove the hunk above, I did not want
+# to remove it if there is hope it will be used again.
+#
+unset ac_cv_make_tickadj
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want and can make the tickadj utility" >&5
+$as_echo_n "checking if we want and can make the tickadj utility... " >&6; }
+if test "${ac_cv_make_tickadj+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_make_tickadj=yes
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_make_tickadj" >&5
+$as_echo "$ac_cv_make_tickadj" >&6; }
+case "$ac_cv_make_tickadj" in
+ yes)
+    MAKE_TICKADJ=tickadj
+    ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want and can make the timetrim utility" >&5
+$as_echo_n "checking if we want and can make the timetrim utility... " >&6; }
+if test "${ac_cv_make_timetrim+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case "$host" in
+ *-*-irix*)
+    ac_cv_make_timetrim=yes
+    ;;
+ *-*-unicosmp*)
+    ac_cv_make_timetrim=yes
+    ;;
+ *)
+    ac_cv_make_timetrim=no
+    ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_make_timetrim" >&5
+$as_echo "$ac_cv_make_timetrim" >&6; }
+case "$ac_cv_make_timetrim" in
+ yes)
+    MAKE_TIMETRIM=timetrim
+    ;;
+esac
+
+
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want to build the NTPD simulator" >&5
+$as_echo_n "checking if we want to build the NTPD simulator... " >&6; }
+
+# Check whether --enable-simulator was given.
+if test "${enable_simulator+set}" = set; then :
+  enableval=$enable_simulator; ans=$enableval
+else
+  ans=no
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ yes)
+    MAKE_NTPDSIM=ntpdsim
+    MAKE_LIBNTPSIM=libntpsim.a
+    ;;
+esac
+
+case "$build" in
+ $host)
+    ;;
+ *) case "$host" in
+     *-*-vxworks*)
+       LDFLAGS="$LDFLAGS -r"
+       ;;
+    esac
+    ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should always slew the time" >&5
+$as_echo_n "checking if we should always slew the time... " >&6; }
+
+# target-specific defaults
+
+case "$host" in
+ *-apple-aux[23]*)
+    ans=yes
+    ;;
+ *-*-bsdi[012]*)
+    ans=no
+    ;;
+ *-*-bsdi*)
+    ans=yes
+    ;;
+ *-*-openvms*) # HMS: won't be found
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+
+# --enable-slew-always / --disable-slew-always overrides default
+
+# Check whether --enable-slew-always was given.
+if test "${enable_slew_always+set}" = set; then :
+  enableval=$enable_slew_always; ans=$enableval
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ yes)
+$as_echo "#define SLEWALWAYS 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should step and slew the time" >&5
+$as_echo_n "checking if we should step and slew the time... " >&6; }
+
+case "$host" in
+ *-sni-sysv*)
+    ans=yes
+    ;;
+ *-univel-sysv*)
+    ans=no
+    ;;
+ *-*-ptx*)
+    ans=yes
+    ;;
+ *-*-solaris2.1[0-9]*)
+    ans=no
+    ;;
+ *-*-solaris2.[012]*)
+    ans=yes
+    ;;
+ *-*-sysv4*)   # HMS: Does this catch Fujitsu UXP?
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+
+
+# Check whether --enable-step-slew was given.
+if test "${enable_step_slew+set}" = set; then :
+  enableval=$enable_step_slew; ans=$enableval
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ yes)
+$as_echo "#define STEP_SLEW 1" >>confdefs.h
+ ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if ntpdate should step the time" >&5
+$as_echo_n "checking if ntpdate should step the time... " >&6; }
+
+case "$host" in
+ *-apple-aux[23]*)
+    ans=yes
+    ;;
+ *) ans=no
+esac
+
+# Check whether --enable-ntpdate-step was given.
+if test "${enable_ntpdate_step+set}" = set; then :
+  enableval=$enable_ntpdate_step; ans=$enableval
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ yes)
+$as_echo "#define FORCE_NTPDATE_STEP 1" >>confdefs.h
+ ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should sync TODR clock every hour" >&5
+$as_echo_n "checking if we should sync TODR clock every hour... " >&6; }
+
+case "$host" in
+ *-*-nextstep*)
+    ans=yes
+    ;;
+ *-*-openvms*) # HMS: won't be found
+    ans=yes
+    ;;
+ *)
+    ans=no
+esac
+
+# Check whether --enable-hourly-todr-sync was given.
+if test "${enable_hourly_todr_sync+set}" = set; then :
+  enableval=$enable_hourly_todr_sync; ans=$enableval
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ac_cv_var_sync_todr" in
+ yes)
+$as_echo "#define DOSYNCTODR 1" >>confdefs.h
+ ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should avoid kernel FLL bug" >&5
+$as_echo_n "checking if we should avoid kernel FLL bug... " >&6; }
+
+case "$host" in
+ *-*-solaris2.6)
+    unamev=`uname -v`
+    case "$unamev" in
+     Generic_105181-*)
+       old_IFS="$IFS"
+       IFS="-"
+       set $unamev
+       IFS="$old_IFS"
+       if test "$2" -ge 17
+       then
+           # Generic_105181-17 and higher
+           ans=no
+       else
+           ans=yes
+       fi
+       ;;
+     *)
+       ans=yes
+    esac
+    ;;
+ *-*-solaris2.7)
+    unamev=`uname -v`
+    case "$unamev" in
+     Generic_106541-*)
+       old_IFS="$IFS"
+       IFS="-"
+       set $unamev
+       IFS="$old_IFS"
+       if test "$2" -ge 07
+       then
+           # Generic_106541-07 and higher
+           ans=no
+       else
+           ans=yes
+       fi
+       ;;
+     *)
+       ans=yes
+    esac
+    ;;
+ *)
+    ans=no
+esac
+
+# Check whether --enable-kernel-fll-bug was given.
+if test "${enable_kernel_fll_bug+set}" = set; then :
+  enableval=$enable_kernel_fll_bug; ans=$enableval
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ yes)
+$as_echo "#define KERNEL_FLL_BUG 1" >>confdefs.h
+ ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should use the IRIG sawtooth filter" >&5
+$as_echo_n "checking if we should use the IRIG sawtooth filter... " >&6; }
+
+case "$host" in
+ *-*-solaris2.[89])
+    ans=yes
+    ;;
+ *-*-solaris2.1[0-9]*)
+    ans=yes
+    ;;
+ *) ans=no
+esac
+
+# Check whether --enable-irig-sawtooth was given.
+if test "${enable_irig_sawtooth+set}" = set; then :
+  enableval=$enable_irig_sawtooth; ans=$enableval
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ yes)
+$as_echo "#define IRIG_SUCKS 1" >>confdefs.h
+ ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should enable NIST lockclock scheme" >&5
+$as_echo_n "checking if we should enable NIST lockclock scheme... " >&6; }
+
+# Check whether --enable-nist was given.
+if test "${enable_nist+set}" = set; then :
+  enableval=$enable_nist; ans=$enableval
+else
+  ans=no
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ yes)
+$as_echo "#define LOCKCLOCK 1" >>confdefs.h
+ ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want support for Samba's signing daemon" >&5
+$as_echo_n "checking if we want support for Samba's signing daemon... " >&6; }
+
+# Check whether --enable-ntp-signd was given.
+if test "${enable_ntp_signd+set}" = set; then :
+  enableval=$enable_ntp_signd; ans=$enableval
+else
+  ans=no
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ no)
+    ntp_signd_path=
+    ;;
+ yes)
+    ntp_signd_path=/var/run/ntp_signd
+    ;;
+ *)
+    ntp_signd_path="$ans"
+esac
+
+case "$ntp_signd_path" in
+ '')
+    wintime_default=no
+    ;;
+ *)
+    wintime_default=yes
+
+$as_echo "#define HAVE_NTP_SIGND /**/" >>confdefs.h
+
+
+cat >>confdefs.h <<_ACEOF
+#define NTP_SIGND_PATH "$ntp_signd_path"
+_ACEOF
+
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we want the windows symmetric client hack" >&5
+$as_echo_n "checking if we want the windows symmetric client hack... " >&6; }
+
+# default is no, unless --enable-ntp-signd was given
+ans=$wintime_default
+unset wintime_default
+
+# Check whether --enable-wintime was given.
+if test "${enable_wintime+set}" = set; then :
+  enableval=$enable_wintime; ans=$enableval
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ans" >&5
+$as_echo "$ans" >&6; }
+
+case "$ans" in
+ yes)
+
+$as_echo "#define WINTIME /**/" >>confdefs.h
+
+esac
+
+
+for ac_header in sys/clockctl.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/clockctl.h" "ac_cv_header_sys_clockctl_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_clockctl_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_CLOCKCTL_H 1
+_ACEOF
+
+fi
+
+done
+
+
+case "$host" in
+ *-*-netbsd*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+
+# Check whether --enable-clockctl was given.
+if test "${enable_clockctl+set}" = set; then :
+  enableval=$enable_clockctl; ntp_use_dev_clockctl=$enableval
+else
+  ntp_use_dev_clockctl=$ac_cv_header_sys_clockctl_h
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we should use /dev/clockctl" >&5
+$as_echo_n "checking if we should use /dev/clockctl... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_use_dev_clockctl" >&5
+$as_echo "$ntp_use_dev_clockctl" >&6; }
+
+
+for ac_header in sys/capability.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/capability.h" "ac_cv_header_sys_capability_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_capability_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_CAPABILITY_H 1
+_ACEOF
+
+fi
+
+done
+
+for ac_header in sys/prctl.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "sys/prctl.h" "ac_cv_header_sys_prctl_h" "$ac_includes_default"
+if test "x$ac_cv_header_sys_prctl_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SYS_PRCTL_H 1
+_ACEOF
+
+fi
+
+done
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if we have linux capabilities (libcap)" >&5
+$as_echo_n "checking if we have linux capabilities (libcap)... " >&6; }
+
+case "$ac_cv_header_sys_capability_h$ac_cv_header_sys_prctl_h" in
+ yesyes)
+    ntp_have_linuxcaps=yes
+    ;;
+ *)
+    ntp_have_linuxcaps=no
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ntp_have_linuxcaps" >&5
+$as_echo "$ntp_have_linuxcaps" >&6; }
+
+
+# Check whether --enable-linuxcaps was given.
+if test "${enable_linuxcaps+set}" = set; then :
+  enableval=$enable_linuxcaps; ntp_have_linuxcaps=$enableval
+
+fi
+
+
+
+case "$ntp_have_linuxcaps" in
+ yes)
+
+$as_echo "#define HAVE_LINUX_CAPABILITIES /**/" >>confdefs.h
+
+    LIBS="$LIBS -lcap"
+esac
+
+
+case "$ntp_use_dev_clockctl$ntp_have_linuxcaps" in
+ *yes*)
+
+$as_echo "#define HAVE_DROPROOT /**/" >>confdefs.h
+
+esac
+
+
+for ac_header in libscf.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "libscf.h" "ac_cv_header_libscf_h" "$ac_includes_default"
+if test "x$ac_cv_header_libscf_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBSCF_H 1
+_ACEOF
+
+fi
+
+done
+
+
+case "$ac_cv_header_libscf_h" in
+ yes)
+    LSCF=-lscf
+
+esac
+
+ac_fn_c_check_func "$LINENO" "setppriv" "ac_cv_func_setppriv"
+if test "x$ac_cv_func_setppriv" = x""yes; then :
+
+$as_echo "#define HAVE_SOLARIS_PRIVS /**/" >>confdefs.h
+
+
+fi
+
+
+
+#
+# ISC stuff
+#
+
+if test $ac_cv_struct_sockaddr_has_sa_len = yes; then
+
+$as_echo "#define ISC_PLATFORM_HAVESALEN /**/" >>confdefs.h
+
+fi
+
+# Check whether --enable-ipv6 was given.
+if test "${enable_ipv6+set}" = set; then :
+  enableval=$enable_ipv6;
+fi
+
+
+case "$enable_ipv6" in
+ yes|''|autodetect)
+    case "$host" in
+     powerpc-ibm-aix4*) ;;
+     *)
+
+$as_echo "#define WANT_IPV6 /**/" >>confdefs.h
+
+       ;;
+    esac
+    ;;
+ no)
+    ;;
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for IPv6 structures" >&5
+$as_echo_n "checking for IPv6 structures... " >&6; }
+if test "${ac_cv_isc_found_ipv6+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+                       #include <sys/types.h>
+                       #include <sys/socket.h>
+                       #include <netinet/in.h>
+
+int
+main ()
+{
+
+                       struct sockaddr_in6 sin6;
+
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_isc_found_ipv6=yes
+else
+  ac_cv_isc_found_ipv6=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_isc_found_ipv6" >&5
+$as_echo "$ac_cv_isc_found_ipv6" >&6; }
+
+#
+# See whether IPv6 support is provided via a Kame add-on.
+# This is done before other IPv6 linking tests so LIBS is properly set.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for Kame IPv6 support" >&5
+$as_echo_n "checking for Kame IPv6 support... " >&6; }
+
+# Check whether --with-kame was given.
+if test "${with_kame+set}" = set; then :
+  withval=$with_kame; use_kame="$withval"
+else
+  use_kame="no"
+fi
+
+
+case "$use_kame" in
+ no)
+    ;;
+ yes)
+    kame_path=/usr/local/v6
+    ;;
+ *)
+    kame_path="$use_kame"
+    ;;
+esac
+
+case "$use_kame" in
+ no)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    ;;
+ *)
+    if test -f $kame_path/lib/libinet6.a; then
+       { $as_echo "$as_me:${as_lineno-$LINENO}: result: $kame_path/lib/libinet6.a" >&5
+$as_echo "$kame_path/lib/libinet6.a" >&6; }
+       LIBS="-L$kame_path/lib -linet6 $LIBS"
+    else
+       as_fn_error "$kame_path/lib/libinet6.a not found.
+
+Please choose the proper path with the following command:
+
+    configure --with-kame=PATH
+" "$LINENO" 5
+    fi
+    ;;
+esac
+
+#
+# Whether netinet6/in6.h is needed has to be defined in isc/platform.h.
+# Including it on Kame-using platforms is very bad, though, because
+# Kame uses #error against direct inclusion.   So include it on only
+# the platform that is otherwise broken without it -- BSD/OS 4.0 through 4.1.
+# This is done before the in6_pktinfo check because that's what
+# netinet6/in6.h is needed for.
+#
+case "$host" in
+ *-bsdi4.[01]*)
+
+$as_echo "#define ISC_PLATFORM_NEEDNETINET6IN6H 1" >>confdefs.h
+
+    isc_netinet6in6_hack="#include <netinet6/in6.h>"
+    ;;
+ *)
+    isc_netinet6in6_hack=""
+esac
+
+#
+# This is similar to the netinet6/in6.h issue.
+#
+case "$host" in
+ *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
+
+$as_echo "#define ISC_PLATFORM_FIXIN6ISADDR 1" >>confdefs.h
+
+    isc_netinetin6_hack="#include <netinet/in6.h>"
+    ;;
+ *)
+    isc_netinetin6_hack=""
+esac
+
+
+case "$ac_cv_isc_found_ipv6" in
+ yes)
+
+$as_echo "#define ISC_PLATFORM_HAVEIPV6 /**/" >>confdefs.h
+
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for in6_pktinfo" >&5
+$as_echo_n "checking for in6_pktinfo... " >&6; }
+if test "${ac_cv_have_in6_pktinfo+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+                           #include <sys/types.h>
+                           #include <sys/socket.h>
+                           #include <netinet/in.h>
+                           $isc_netinetin6_hack
+                           $isc_netinet6in6_hack
+
+int
+main ()
+{
+
+                           struct in6_pktinfo xyzzy;
+
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_have_in6_pktinfo=yes
+else
+  ac_cv_have_in6_pktinfo=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_in6_pktinfo" >&5
+$as_echo "$ac_cv_have_in6_pktinfo" >&6; }
+
+    case "$ac_cv_have_in6_pktinfo" in
+     yes)
+
+$as_echo "#define ISC_PLATFORM_HAVEIN6PKTINFO /**/" >>confdefs.h
+
+    esac
+
+
+    # HMS: Use HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID instead?
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for sockaddr_in6.sin6_scope_id" >&5
+$as_echo_n "checking for sockaddr_in6.sin6_scope_id... " >&6; }
+if test "${ac_cv_have_sin6_scope_id+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+           cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+                           #include <sys/types.h>
+                           #include <sys/socket.h>
+                           #include <netinet/in.h>
+                           $isc_netinetin6_hack
+                           $isc_netinet6in6_hack
+
+int
+main ()
+{
+
+                           struct sockaddr_in6 xyzzy;
+                           xyzzy.sin6_scope_id = 0;
+
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_have_sin6_scope_id=yes
+else
+  ac_cv_have_sin6_scope_id=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_sin6_scope_id" >&5
+$as_echo "$ac_cv_have_sin6_scope_id" >&6; }
+
+    case "$ac_cv_have_sin6_scope_id" in
+     yes)
+
+$as_echo "#define ISC_PLATFORM_HAVESCOPEID /**/" >>confdefs.h
+
+    esac
+esac
+
+
+# We need this check run even without ac_cv_isc_found_ipv6=yes
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for in6addr_any" >&5
+$as_echo_n "checking for in6addr_any... " >&6; }
+if test "${ac_cv_have_in6addr_any+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+                       #include <sys/types.h>
+                       #include <sys/socket.h>
+                       #include <netinet/in.h>
+                       $isc_netinetin6_hack
+                       $isc_netinet6in6_hack
+
+int
+main ()
+{
+
+                       struct in6_addr in6;
+                       in6 = in6addr_any;
+
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_have_in6addr_any=yes
+else
+  ac_cv_have_in6addr_any=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_in6addr_any" >&5
+$as_echo "$ac_cv_have_in6addr_any" >&6; }
+
+case "$ac_cv_have_in6addr_any" in
+ no)
+
+$as_echo "#define ISC_PLATFORM_NEEDIN6ADDRANY /**/" >>confdefs.h
+
+esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct if_laddrconf" >&5
+$as_echo_n "checking for struct if_laddrconf... " >&6; }
+if test "${ac_cv_isc_struct_if_laddrconf+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+                       #include <sys/types.h>
+                       #include <net/if6.h>
+
+int
+main ()
+{
+
+                       struct if_laddrconf a;
+
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_isc_struct_if_laddrconf=yes
+else
+  ac_cv_isc_struct_if_laddrconf=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_isc_struct_if_laddrconf" >&5
+$as_echo "$ac_cv_isc_struct_if_laddrconf" >&6; }
+
+case "$ac_cv_isc_struct_if_laddrconf" in
+ yes)
+
+$as_echo "#define ISC_PLATFORM_HAVEIF_LADDRCONF /**/" >>confdefs.h
+
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for struct if_laddrreq" >&5
+$as_echo_n "checking for struct if_laddrreq... " >&6; }
+if test "${ac_cv_isc_struct_if_laddrreq+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+
+                       #include <sys/types.h>
+                       #include <net/if6.h>
+
+int
+main ()
+{
+
+                       struct if_laddrreq a;
+
+
+  ;
+  return 0;
+}
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_isc_struct_if_laddrreq=yes
+else
+  ac_cv_isc_struct_if_laddrreq=no
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_isc_struct_if_laddrreq" >&5
+$as_echo "$ac_cv_isc_struct_if_laddrreq" >&6; }
+
+case "$ac_cv_isc_struct_if_laddrreq" in
+ yes)
+
+$as_echo "#define ISC_PLATFORM_HAVEIF_LADDRREQ /**/" >>confdefs.h
+
+esac
+
+#
+# Look for a sysctl call to get the list of network interfaces.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for interface list sysctl" >&5
+$as_echo_n "checking for interface list sysctl... " >&6; }
+if test "${ac_cv_iflist_sysctl+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+           #include <sys/param.h>
+           #include <sys/sysctl.h>
+           #include <sys/socket.h>
+           #ifdef NET_RT_IFLIST
+           found_rt_iflist
+           #endif
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "found_rt_iflist" >/dev/null 2>&1; then :
+  ac_cv_iflist_sysctl=yes
+else
+  ac_cv_iflist_sysctl=no
+
+fi
+rm -f conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_iflist_sysctl" >&5
+$as_echo "$ac_cv_iflist_sysctl" >&6; }
+
+case "$ac_cv_iflist_sysctl" in
+ yes)
+
+$as_echo "#define HAVE_IFLIST_SYSCTL 1" >>confdefs.h
+
+esac
+
+
+###
+
+
+       ac_expanded=`(
+           test "x$prefix" = xNONE && prefix="$ac_default_prefix"
+           test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
+           eval echo \""$sysconfdir"\"
+        )`
+
+cat >>confdefs.h <<_ACEOF
+#define NTP_KEYSDIR "$ac_expanded"
+_ACEOF
+
+
+
+ac_config_files="$ac_config_files Makefile"
+
+ac_config_files="$ac_config_files ElectricFence/Makefile"
+
+ac_config_files="$ac_config_files adjtimed/Makefile"
+
+ac_config_files="$ac_config_files clockstuff/Makefile"
+
+ac_config_files="$ac_config_files include/Makefile"
+
+ac_config_files="$ac_config_files include/isc/Makefile"
+
+ac_config_files="$ac_config_files kernel/Makefile"
+
+ac_config_files="$ac_config_files kernel/sys/Makefile"
+
+ac_config_files="$ac_config_files libntp/Makefile"
+
+ac_config_files="$ac_config_files libparse/Makefile"
+
+ac_config_files="$ac_config_files ntpd/Makefile"
+
+ac_config_files="$ac_config_files ntpdate/Makefile"
+
+ac_config_files="$ac_config_files ntpdc/Makefile"
+
+ac_config_files="$ac_config_files ntpdc/nl.pl"
+
+ac_config_files="$ac_config_files ntpq/Makefile"
+
+ac_config_files="$ac_config_files parseutil/Makefile"
+
+ac_config_files="$ac_config_files scripts/Makefile"
+
+ac_config_files="$ac_config_files scripts/calc_tickadj"
+
+ac_config_files="$ac_config_files scripts/checktime"
+
+ac_config_files="$ac_config_files scripts/freq_adj"
+
+ac_config_files="$ac_config_files scripts/html2man"
+
+ac_config_files="$ac_config_files scripts/mkver"
+
+ac_config_files="$ac_config_files scripts/ntp-wait"
+
+ac_config_files="$ac_config_files scripts/ntpsweep"
+
+ac_config_files="$ac_config_files scripts/ntptrace"
+
+ac_config_files="$ac_config_files scripts/ntpver"
+
+ac_config_files="$ac_config_files scripts/plot_summary"
+
+ac_config_files="$ac_config_files scripts/summary"
+
+ac_config_files="$ac_config_files util/Makefile"
+
+
+subdirs="$subdirs sntp"
+
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      sed -n \
+       "s/'/'\\\\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+    cat confcache >$cache_file
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+ if test -n "$EXEEXT"; then
+  am__EXEEXT_TRUE=
+  am__EXEEXT_FALSE='#'
+else
+  am__EXEEXT_TRUE='#'
+  am__EXEEXT_FALSE=
+fi
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  as_fn_error "conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  as_fn_error "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  as_fn_error "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${INSTALL_LIBOPTS_TRUE}" && test -z "${INSTALL_LIBOPTS_FALSE}"; then
+  as_fn_error "conditional \"INSTALL_LIBOPTS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${NEED_LIBOPTS_TRUE}" && test -z "${NEED_LIBOPTS_FALSE}"; then
+  as_fn_error "conditional \"NEED_LIBOPTS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+
+: ${CONFIG_STATUS=./config.status}
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with status $?, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in #(
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by ntp $as_me 4.2.4p8, which was
+generated by GNU Autoconf 2.65.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to the package provider."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+ntp config.status 4.2.4p8
+configured by $0, generated by GNU Autoconf 2.65,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2009 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "libopts/Makefile") CONFIG_FILES="$CONFIG_FILES libopts/Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+    "ElectricFence/Makefile") CONFIG_FILES="$CONFIG_FILES ElectricFence/Makefile" ;;
+    "adjtimed/Makefile") CONFIG_FILES="$CONFIG_FILES adjtimed/Makefile" ;;
+    "clockstuff/Makefile") CONFIG_FILES="$CONFIG_FILES clockstuff/Makefile" ;;
+    "include/Makefile") CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
+    "include/isc/Makefile") CONFIG_FILES="$CONFIG_FILES include/isc/Makefile" ;;
+    "kernel/Makefile") CONFIG_FILES="$CONFIG_FILES kernel/Makefile" ;;
+    "kernel/sys/Makefile") CONFIG_FILES="$CONFIG_FILES kernel/sys/Makefile" ;;
+    "libntp/Makefile") CONFIG_FILES="$CONFIG_FILES libntp/Makefile" ;;
+    "libparse/Makefile") CONFIG_FILES="$CONFIG_FILES libparse/Makefile" ;;
+    "ntpd/Makefile") CONFIG_FILES="$CONFIG_FILES ntpd/Makefile" ;;
+    "ntpdate/Makefile") CONFIG_FILES="$CONFIG_FILES ntpdate/Makefile" ;;
+    "ntpdc/Makefile") CONFIG_FILES="$CONFIG_FILES ntpdc/Makefile" ;;
+    "ntpdc/nl.pl") CONFIG_FILES="$CONFIG_FILES ntpdc/nl.pl" ;;
+    "ntpq/Makefile") CONFIG_FILES="$CONFIG_FILES ntpq/Makefile" ;;
+    "parseutil/Makefile") CONFIG_FILES="$CONFIG_FILES parseutil/Makefile" ;;
+    "scripts/Makefile") CONFIG_FILES="$CONFIG_FILES scripts/Makefile" ;;
+    "scripts/calc_tickadj") CONFIG_FILES="$CONFIG_FILES scripts/calc_tickadj" ;;
+    "scripts/checktime") CONFIG_FILES="$CONFIG_FILES scripts/checktime" ;;
+    "scripts/freq_adj") CONFIG_FILES="$CONFIG_FILES scripts/freq_adj" ;;
+    "scripts/html2man") CONFIG_FILES="$CONFIG_FILES scripts/html2man" ;;
+    "scripts/mkver") CONFIG_FILES="$CONFIG_FILES scripts/mkver" ;;
+    "scripts/ntp-wait") CONFIG_FILES="$CONFIG_FILES scripts/ntp-wait" ;;
+    "scripts/ntpsweep") CONFIG_FILES="$CONFIG_FILES scripts/ntpsweep" ;;
+    "scripts/ntptrace") CONFIG_FILES="$CONFIG_FILES scripts/ntptrace" ;;
+    "scripts/ntpver") CONFIG_FILES="$CONFIG_FILES scripts/ntpver" ;;
+    "scripts/plot_summary") CONFIG_FILES="$CONFIG_FILES scripts/plot_summary" ;;
+    "scripts/summary") CONFIG_FILES="$CONFIG_FILES scripts/summary" ;;
+    "util/Makefile") CONFIG_FILES="$CONFIG_FILES util/Makefile" ;;
+
+  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = "\a"
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+  || as_fn_error "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[         ]*VPATH[        ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[    ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[      ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_t"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[    ]*#[    ]*define[       ][      ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = "\a"
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  as_fn_error "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+        # (if the path is not absolute).  The absolute path cannot be DOS-style,
+        # because $ac_f cannot contain `:'.
+        test -f "$ac_f" ||
+          case $ac_f in
+          [\\/$]*) false;;
+          *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+          esac ||
+          as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+         $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+       `' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_file" : 'X\(//\)[^/]' \| \
+        X"$ac_file" : 'X\(//\)$' \| \
+        X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[         ]*datarootdir[  ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+    } >"$tmp/config.h" \
+      || as_fn_error "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$tmp/config.h" "$ac_file" \
+       || as_fn_error "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error "could not create -" "$LINENO" 5
+  fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$_am_arg" : 'X\(//\)[^/]' \| \
+        X"$_am_arg" : 'X\(//\)$' \| \
+        X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$mf" : 'X\(//\)[^/]' \| \
+        X"$mf" : 'X\(//\)$' \| \
+        X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$file" : 'X\(//\)[^/]' \| \
+        X"$file" : 'X\(//\)$' \| \
+        X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      as_dir=$dirpart/$fdir; as_fn_mkdir_p
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+ ;;
+    "ntpdc/nl.pl":F) chmod +x ntpdc/nl.pl ;;
+    "scripts/calc_tickadj":F) chmod +x scripts/calc_tickadj ;;
+    "scripts/checktime":F) chmod +x scripts/checktime ;;
+    "scripts/freq_adj":F) chmod +x scripts/freq_adj ;;
+    "scripts/html2man":F) chmod +x scripts/html2man ;;
+    "scripts/mkver":F) chmod +x scripts/mkver ;;
+    "scripts/ntp-wait":F) chmod +x scripts/ntp-wait ;;
+    "scripts/ntpsweep":F) chmod +x scripts/ntpsweep ;;
+    "scripts/ntptrace":F) chmod +x scripts/ntptrace ;;
+    "scripts/ntpver":F) chmod +x scripts/ntpver ;;
+    "scripts/plot_summary":F) chmod +x scripts/plot_summary ;;
+    "scripts/summary":F) chmod +x scripts/summary ;;
+
+  esac
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || as_fn_exit $?
+fi
+
+#
+# CONFIG_SUBDIRS section.
+#
+if test "$no_recursion" != yes; then
+
+  # Remove --cache-file, --srcdir, and --disable-option-checking arguments
+  # so they do not pile up.
+  ac_sub_configure_args=
+  ac_prev=
+  eval "set x $ac_configure_args"
+  shift
+  for ac_arg
+  do
+    if test -n "$ac_prev"; then
+      ac_prev=
+      continue
+    fi
+    case $ac_arg in
+    -cache-file | --cache-file | --cache-fil | --cache-fi \
+    | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+      ac_prev=cache_file ;;
+    -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+    | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* \
+    | --c=*)
+      ;;
+    --config-cache | -C)
+      ;;
+    -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+      ac_prev=srcdir ;;
+    -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+      ;;
+    -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+      ac_prev=prefix ;;
+    -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+      ;;
+    --disable-option-checking)
+      ;;
+    *)
+      case $ac_arg in
+      *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+      esac
+      as_fn_append ac_sub_configure_args " '$ac_arg'" ;;
+    esac
+  done
+
+  # Always prepend --prefix to ensure using the same prefix
+  # in subdir configurations.
+  ac_arg="--prefix=$prefix"
+  case $ac_arg in
+  *\'*) ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+  esac
+  ac_sub_configure_args="'$ac_arg' $ac_sub_configure_args"
+
+  # Pass --silent
+  if test "$silent" = yes; then
+    ac_sub_configure_args="--silent $ac_sub_configure_args"
+  fi
+
+  # Always prepend --disable-option-checking to silence warnings, since
+  # different subdirs can have different --enable and --with options.
+  ac_sub_configure_args="--disable-option-checking $ac_sub_configure_args"
+
+  ac_popdir=`pwd`
+  for ac_dir in : $subdirs; do test "x$ac_dir" = x: && continue
+
+    # Do not complain, so a configure script can configure whichever
+    # parts of a large source tree are present.
+    test -d "$srcdir/$ac_dir" || continue
+
+    ac_msg="=== configuring in $ac_dir (`pwd`/$ac_dir)"
+    $as_echo "$as_me:${as_lineno-$LINENO}: $ac_msg" >&5
+    $as_echo "$ac_msg" >&6
+    as_dir="$ac_dir"; as_fn_mkdir_p
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+    cd "$ac_dir"
+
+    # Check for guested configure; otherwise get Cygnus style configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      ac_sub_configure=$ac_srcdir/configure.gnu
+    elif test -f "$ac_srcdir/configure"; then
+      ac_sub_configure=$ac_srcdir/configure
+    elif test -f "$ac_srcdir/configure.in"; then
+      # This should be Cygnus configure.
+      ac_sub_configure=$ac_aux_dir/configure
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: no configuration information is in $ac_dir" >&5
+$as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2;}
+      ac_sub_configure=
+    fi
+
+    # The recursion is here.
+    if test -n "$ac_sub_configure"; then
+      # Make the cache file name correct relative to the subdirectory.
+      case $cache_file in
+      [\\/]* | ?:[\\/]* ) ac_sub_cache_file=$cache_file ;;
+      *) # Relative name.
+       ac_sub_cache_file=$ac_top_build_prefix$cache_file ;;
+      esac
+
+      { $as_echo "$as_me:${as_lineno-$LINENO}: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&5
+$as_echo "$as_me: running $SHELL $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_srcdir" >&6;}
+      # The eval makes quoting arguments work.
+      eval "\$SHELL \"\$ac_sub_configure\" $ac_sub_configure_args \
+          --cache-file=\"\$ac_sub_cache_file\" --srcdir=\"\$ac_srcdir\"" ||
+       as_fn_error "$ac_sub_configure failed for $ac_dir" "$LINENO" 5
+    fi
+
+    cd "$ac_popdir"
+  done
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/configure.ac b/configure.ac
new file mode 100644 (file)
index 0000000..49cc9ae
--- /dev/null
@@ -0,0 +1,4667 @@
+dnl -*-fundamental-*-
+dnl Process this file with autoconf to produce a configure script.
+m4_include([version.m4])
+AC_INIT(ntp, VERSION_NUMBER)
+AM_INIT_AUTOMAKE
+AC_CANONICAL_HOST
+dnl the 'build' machine is where we run configure and compile
+dnl the 'host' machine is where the resulting stuff runs.
+AC_DEFINE_UNQUOTED(STR_SYSTEM, "$host", [canonical system (cpu-vendor-os) of where we should run])
+AM_CONFIG_HEADER([config.h])
+dnl AC_ARG_PROGRAM
+AC_PREREQ(2.53)
+
+ac_cv_var_atom_ok=no
+ac_cv_var_oncore_ok=no
+ac_cv_var_parse_ok=no
+ac_cv_var_ripe_ncc_ok=no
+ac_cv_var_jupiter_ok=no
+
+dnl Grab any initial CFLAGS so we can pick better defaults.
+iCFLAGS="$CFLAGS"
+
+dnl check these early to avoid autoconf warnings
+AC_AIX
+AC_MINIX
+
+# So far, the only shared library we might use is libopts.
+# It's a small library - we might as well use a static version of it.
+AC_DISABLE_SHARED
+
+dnl  we need to check for cross compile tools for vxWorks here
+AC_PROG_CC
+# Ralf Wildenhues: With per-target flags we need CC_C_O
+# AM_PROG_CC_C_O supersets AC_PROG_CC_C_O
+AM_PROG_CC_C_O
+AC_PROG_CC_STDC
+AC_PROG_CPP
+
+# HMS: These need to be moved to AM_CPPFLAGS and/or AM_CFLAGS
+case "$host" in
+ *-*-amigaos)
+    CFLAGS="$CFLAGS -Dfork=vfork -DSYS_AMIGA"
+    ;;
+ *-*-hpux10.*) # at least for hppa2.0-hp-hpux10.20
+    case "$GCC" in
+     yes)
+       ;;
+     *) CFLAGS="$CFLAGS -Wp,-H18816"
+       ;;
+    esac
+    ;;
+ *-pc-cygwin*)
+    CFLAGS="$CFLAGS -DSYS_CYGWIN32"
+    ;;
+ i386-sequent-sysv4)
+    case "$CC" in
+     cc)
+       CFLAGS="$CFLAGS -Wc,+abi-socket"
+       ;;
+    esac
+    ;;
+ *-*-mpeix*)
+    CPPFLAGS="$CPPFLAGS -DMPE -D_POSIX_SOURCE -D_SOCKET_SOURCE -I/SYSLOG/PUB"
+    LDFLAGS="$LDFLAGS -L/SYSLOG/PUB"
+    LIBS="$LIBS -lcurses"
+    ;;
+ *-*-solaris*)
+    # see "man standards".
+    # -D_XOPEN_SOURCE=500 is probably OK for c89 and before
+    # -D_XOPEN_SOURCE=600 seems OK for c99
+    #CPPFLAGS="$CPPFLAGS -D_XOPEN_SOURCE=500 -D__EXTENSIONS__"
+    CPPFLAGS="$CPPFLAGS -D__EXTENSIONS__"
+    libxnet=-lxnet
+    ;;
+esac
+
+AMU_OS_CFLAGS
+
+# NTP has (so far) been relying on leading-edge autogen.
+# Therefore, by default:
+# - use the version we ship with
+# - do not install it
+# - build a static copy (AC_DISABLE_SHARED - done earlier)
+case "${enable_local_libopts+set}" in
+ set) ;;
+ *) enable_local_libopts=yes ;;
+esac
+case "${enable_libopts_install+set}" in
+ set) ;;
+ *) enable_libopts_install=no ;;
+esac
+LIBOPTS_CHECK(libopts)
+
+AC_CACHE_CHECK(
+    [if $CC can handle @%:@warning],
+    ac_cv_cpp_warning,
+    [
+       AC_COMPILE_IFELSE(
+           AC_LANG_PROGRAM([], [#warning foo]),
+           [ac_cv_cpp_warning=yes],
+           [ac_cv_cpp_warning=no],
+       )
+    ]
+)
+
+case "$ac_cv_cpp_warning" in
+ no)
+    AC_DEFINE([NO_OPTION_NAME_WARNINGS], [1], [Should we avoid @%:@warning on option name collisions?])
+esac
+
+case "$GCC" in
+ yes)
+    SAVED_CFLAGS_AC="$CFLAGS"
+    CFLAGS="$CFLAGS -Wstrict-overflow"
+    AC_CACHE_CHECK(
+       [if $CC can handle -Wstrict-overflow], 
+       ac_cv_gcc_Wstrict_overflow, 
+       [
+           AC_COMPILE_IFELSE(
+               [AC_LANG_PROGRAM([], [])],
+               [ac_cv_gcc_Wstrict_overflow=yes],
+               [ac_cv_gcc_Wstrict_overflow=no]
+           )
+       ]
+    )
+    CFLAGS="$SAVED_CFLAGS_AC"
+    unset SAVED_CFLAGS_AC
+    #
+    # $ac_cv_gcc_Wstrict_overflow is tested later to add the 
+    # flag to CFLAGS.
+    #
+esac
+
+
+case "$GCC" in
+ yes)
+    SAVED_CFLAGS_AC="$CFLAGS"
+    CFLAGS="$CFLAGS -Winit-self"
+    AC_CACHE_CHECK(
+       [if $CC can handle -Winit-self], 
+       ac_cv_gcc_Winit_self, 
+       [
+           AC_COMPILE_IFELSE(
+               [AC_LANG_PROGRAM([], [])],
+               [ac_cv_gcc_Winit_self=yes],
+               [ac_cv_gcc_Winit_self=no]
+           )
+       ]
+    )
+    CFLAGS="$SAVED_CFLAGS_AC"
+    unset SAVED_CFLAGS_AC
+    #
+    # $ac_cv_gcc_Winit_self is tested later to add the 
+    # flag to CFLAGS.
+    #
+esac
+
+
+
+AC_MSG_CHECKING([for bin subdirectory])
+AC_ARG_WITH(binsubdir,
+       AC_HELP_STRING([--with-binsubdir], [bin ={bin,sbin}]),
+       use_binsubdir="$withval", use_binsubdir="bin")
+
+case "$use_binsubdir" in
+ bin)
+    ;;
+ sbin)
+    ;;
+ *)
+    AC_MSG_ERROR([<$use_binsubdir> is illegal - must be "bin" or "sbin"])
+    ;;
+esac
+AC_MSG_RESULT($use_binsubdir)
+BINSUBDIR=$use_binsubdir
+AC_SUBST(BINSUBDIR)
+
+AC_MSG_CHECKING([if we want to use arlib])
+AC_ARG_WITH(arlib,
+       AC_HELP_STRING([--with-arlib], [- Compile the async resolver library?]),
+       [ans=$withval], [ans=no])
+AC_MSG_RESULT([$ans])
+
+if test -d $srcdir/arlib
+then
+    case "$ans" in
+     yes)
+       ARLIB_DIR=arlib
+       AC_CONFIG_SUBDIRS(arlib)
+       ;;
+    esac
+fi
+AC_SUBST(ARLIB_DIR)
+
+AC_ARG_WITH(rpath,
+       AC_HELP_STRING([--without-rpath], [s Disable auto-added -R linker paths]),
+[ans=$withval], [ans=x])
+case "$ans" in
+ no)
+    need_dash_r=
+    ;;
+ yes)
+    need_dash_r=1
+    ;;
+esac
+# HMS: Why isn't this $build?
+# Well, that depends on if we need this for the build toolchain or
+# for info in the host executable...
+# I still have no idea which way this should go, but nobody has complained.
+case "$host" in
+ *-*-netbsd*)
+    case "$need_dash_r" in
+     no) ;;
+     *)  need_dash_r=1
+        ;;
+    esac
+    ;;
+ *-*-solaris*)
+    case "$need_dash_r" in
+     no) ;;
+     *)  need_dash_r=1
+        ;;
+    esac
+    ;;
+esac
+
+
+case "$build" in
+ $host)
+    ;;
+ *) case "$host" in
+     *-*-vxworks*)
+       # Quick and dirty sanity check
+       case "$VX_KERNEL" in
+        '') AC_MSG_ERROR(Please follow the directions in html/build/hints/vxworks.html!)
+           ;;
+       esac
+        CFLAGS="$CFLAGS -DSYS_VXWORKS"
+        ;;
+    esac
+    ;;
+esac
+
+dnl  we need to check for cross compile tools for vxWorks here
+AC_PROG_AWK
+AC_PROG_MAKE_SET
+
+rm -f conftest*
+
+case "$GCC" in
+ yes)
+    CFLAGS="$CFLAGS -Wall"
+    # CFLAGS="$CFLAGS -Wcast-align"
+    CFLAGS="$CFLAGS -Wcast-qual"
+    # CFLAGS="$CFLAGS -Wconversion"
+    # CFLAGS="$CFLAGS -Werror"
+    # CFLAGS="$CFLAGS -Wextra"
+    # CFLAGS="$CFLAGS -Wfloat-equal"
+    CFLAGS="$CFLAGS -Wmissing-prototypes"
+    CFLAGS="$CFLAGS -Wpointer-arith"
+    CFLAGS="$CFLAGS -Wshadow"
+    #
+    # OpenSSL has a number of callback prototypes
+    # inside other function prototypes which trigger
+    # warnings with -Wstrict-prototypes, such as:
+    #
+    # int i2d_RSA_NET(const RSA *a, unsigned char **pp, 
+    #                 int (*cb)(), int sgckey);
+    #                 ^^^^^^^^^^^
+    #
+    CFLAGS="$CFLAGS -Wno-strict-prototypes"
+    # CFLAGS="$CFLAGS -Wtraditional"
+    # CFLAGS="$CFLAGS -Wwrite-strings"
+    case "$ac_cv_gcc_Winit_self" in
+     yes)
+       CFLAGS="$CFLAGS -Winit-self"
+    esac
+    case "$ac_cv_gcc_Wstrict_overflow" in
+     yes)
+        #not yet: CFLAGS="$CFLAGS -Wstrict-overflow"
+    esac
+    ;;
+esac
+
+case "$host" in
+ *-next-nextstep3)
+    CFLAGS="$CFLAGS -posix"
+    ;;
+dnl This is currently commented out by bor. 
+dnl The new versions of ReliantUNIX round adjtime() interval down
+dnl to 1/100s (system tick). This makes tickadj actually useless.
+dnl So, I'd better not use additional flags.
+dnl I leave it here just in case anybody has better idea
+dnl  mips-sni-sysv4* )
+dnl     #
+dnl     # Add flags for 64 bit file access to enable tickadj to access /dev/kmem
+dnl     #
+dnl     if getconf _LFS_CFLAGS > /dev/null 2>&1 ; then
+dnl       CFLAGS="$CFLAGS `getconf _LFS_CFLAGS`"
+dnl     fi
+dnl     ;;
+esac
+
+ac_busted_vpath_in_make=no
+
+case "$build" in
+ *-*-irix6.1*) # 64 bit only
+    # busted vpath?
+    ;;
+ *-*-irix6*)   # 6.2 (and later?)
+    ac_busted_vpath_in_make=yes
+    ;;
+ *-*-solaris2.5.1)
+    ac_busted_vpath_in_make=yes
+    ;;
+ *-*-unicosmp*)
+    ac_busted_vpath_in_make=yes
+    ;;
+esac
+
+case "$ac_busted_vpath_in_make$srcdir" in
+ no*) ;;
+ yes.) ;;
+ *) case "`${MAKE-make} -v -f /dev/null 2>/dev/null | sed -e 's/GNU Make version \(1-9.]*\).*/\1/' -e q`" in
+     '')
+       AC_MSG_ERROR([building outside of the main directory requires GNU make])
+       ;;
+     *) ;;
+    esac
+    ;;
+esac
+
+AC_SUBST(CFLAGS)dnl
+AC_SUBST(LDFLAGS)dnl
+
+m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
+m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
+
+AC_PROG_LIBTOOL
+
+AC_PROG_LN_S
+AC_PROG_GCC_TRADITIONAL
+AC_C_VOLATILE
+AC_ISC_POSIX
+AC_PATH_PROG(PATH_SH, sh)
+AC_PATH_PROG(PATH_PERL, perl)
+
+hs_ULONG_CONST         # remove for 4.2.5
+
+case "$host" in
+ *-*-vxworks*)
+    ac_link="$ac_link $VX_KERNEL"
+    ;;
+esac
+
+AC_PROG_INSTALL
+
+case "$host" in
+ *-pc-cygwin*)
+    AC_CHECK_LIB(advapi32, main)
+    ;;
+esac
+
+AC_CHECK_FUNC([gethostent], ,
+  AC_SEARCH_LIBS([gethostent], [nsl], , , [$libxnet -lsocket]))
+AC_CHECK_FUNC([openlog], , 
+  AC_SEARCH_LIBS([openlog], [gen], , 
+  AC_SEARCH_LIBS([openlog], [syslog], , , [$libxnet -lsocket])))
+AC_SEARCH_LIBS([MD5Init], [md5 md])
+AC_CHECK_FUNCS(MD5Init)
+
+# following block becomes on 4.2.5: NTP_LINEEDITLIBS
+dnl HMS: What a hack...
+AC_CHECK_HEADERS(readline/history.h readline/readline.h)
+case "$ac_cv_header_readline_history_h$ac_cv_header_readline_readline_h" in
+ *no*) ;;
+ *) save_LIBS=$LIBS
+    LIBS=
+    # Ralf Wildenhues: either unset ... or cache READLINE_LIBS
+    unset ac_cv_lib_readline_readline
+    AC_CHECK_LIB(readline, readline, ,
+     AC_MSG_NOTICE([Trying again with -lcurses])
+     unset ac_cv_lib_readline_readline
+     AC_CHECK_LIB(readline, readline,
+      LIBS="-lreadline -lcurses $LIBS"
+      AC_DEFINE(HAVE_LIBREADLINE)
+      AC_DEFINE(HAVE_LIBCURSES, , [Do we have the curses library?]),
+      AC_CHECK_LIB(edit, readline,
+       LIBS="-ledit -lcurses"
+       AC_DEFINE(HAVE_LIBEDIT, , [Do we have the edit library?])
+       AC_DEFINE(HAVE_LIBCURSES, , [Do we have the curses library?])
+       , , -lcurses)
+      , -lcurses))
+    READLINE_LIBS=$LIBS
+    AC_SUBST(READLINE_LIBS)
+    LIBS=$save_LIBS
+    ;;
+esac
+
+dnl Digital UNIX V4.0 and Solaris 7 have POSIX.1c functions in -lrt
+dnl Solaris 2.6 only has -lposix4; in Solaris 7, this is a symlink to -lrt,
+dnl so only use one of them.  Linux (glibc-2.1.2 and -2.2.2, at least)
+dnl does Strange Things with extra processes using the Posix-compatibility
+dnl real-time library, so we don't want to use it.
+
+case "$host" in
+ *-*-*linux*) ;;
+ *)
+    AC_CHECK_LIB(rt, sched_setscheduler, ,
+       AC_CHECK_LIB(posix4, sched_setscheduler))
+    ;;
+esac
+
+AC_CHECK_FUNC(setsockopt, ,
+       [AC_SEARCH_LIBS([setsockopt], [socket xnet])])
+
+AC_HEADER_STDC
+AC_CHECK_HEADERS(bstring.h)
+AC_CHECK_HEADER(dns_sd.h,
+       [AC_CHECK_LIB(dns_sd,
+                       DNSServiceRegister,
+                       [AC_DEFINE(HAVE_DNSREGISTRATION, 1,
+                               [Use Rendezvous/DNS-SD registration])])])
+case "$ac_cv_lib_dns_sd_DNSServiceRegister" in
+ yes) LIBS="-ldns_sd $LIBS" ;;
+esac
+AC_CHECK_HEADERS(errno.h fcntl.h ieeefp.h math.h)
+
+# HMS: Lame, but fast.
+if test -f /etc/redhat-release
+then
+    :
+else
+    AC_CHECK_HEADERS(md5.h, [], [],
+[#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+])
+fi
+AC_CHECK_HEADERS(memory.h netdb.h poll.h)
+AC_CHECK_HEADERS(sched.h sgtty.h stdlib.h string.h termio.h)
+AC_CHECK_HEADERS(termios.h timepps.h timex.h unistd.h)
+case "$host" in
+ *-*-aix*)
+    AC_CHECK_HEADERS(utmpx.h)
+    case "$ac_cv_header_utmpx_h" in
+     yes) ;;
+     *) AC_CHECK_HEADERS(utmp.h) ;;
+    esac
+    ;;
+ *) AC_CHECK_HEADERS(utmp.h utmpx.h) ;;
+esac
+AC_CHECK_HEADERS(arpa/nameser.h)
+AC_CHECK_HEADERS(sys/socket.h)
+AC_CHECK_HEADERS(net/if.h, [], [],
+[#if HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+])
+AC_CHECK_HEADERS(net/if6.h)
+AC_CHECK_HEADERS(net/route.h, [], [], [
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+])
+AC_CHECK_HEADERS(netinet/in_system.h netinet/in_systm.h)
+AC_CHECK_HEADERS(netinet/in.h)
+AC_CHECK_HEADERS(netinet/ip.h, [], [],
+[#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_NETINET_IN_SYSTM_H
+#include <netinet/in_systm.h>
+#endif
+])
+
+# Check for IPTOS_PREC
+AC_CACHE_CHECK(
+    [IPPROTO_IP IP_TOS IPTOS_LOWDELAY],
+    ac_cv_ip_tos,
+    [
+       AC_EGREP_CPP(
+           [yes],
+           [
+               #if HAVE_SYS_TYPES_H
+               #include <sys/types.h>
+               #endif
+               #if HAVE_NETINET_IP_H
+               #include <netinet/in.h>
+               #include <netinet/ip.h>
+               #endif
+               #if defined(IPPROTO_IP) && defined(IP_TOS) && defined(IPTOS_LOWDELAY)
+                 yes
+               #endif
+           ],
+           [ac_cv_ip_tos=yes],
+           [ac_cv_ip_tos=no]
+       )
+    ]
+)
+
+case "$ac_cv_ip_tos" in
+ yes)
+    AC_DEFINE(HAVE_IPTOS_SUPPORT, 1, [Do we have IPTOS support?])
+esac
+
+AC_CHECK_HEADERS(netinfo/ni.h, [AC_DEFINE(HAVE_NETINFO, 1, [NetInfo support?])])
+AC_CHECK_HEADERS(sun/audioio.h sys/audioio.h)
+dnl AC_CHECK_HEADERS(sys/chudefs.h)
+AC_CHECK_HEADERS(sys/clkdefs.h sys/file.h)
+case "$host" in
+ *-*-sunos4*) ;;
+ *) AC_CHECK_HEADERS(sys/ioctl.h)
+    ;;
+esac
+AC_CHECK_HEADERS(sys/ipc.h)
+AC_CHECK_HEADERS(sys/lock.h sys/mman.h sys/modem.h sys/param.h sys/ppsclock.h)
+# HMS: Check sys/proc.h and sys/resource.h after some others
+AC_CHECK_HEADERS(sys/ppstime.h)
+case "$ac_cv_header_sched_h" in
+ yes) ;;
+ *) AC_CHECK_HEADERS(sys/sched.h) ;;
+esac
+case "$host" in
+ *-*-sco*)
+    AC_CHECK_HEADERS(sys/sio.h)
+    ;;
+esac
+# HMS: Check sys/shm.h after some others
+AC_CHECK_HEADERS(sys/select.h sys/signal.h sys/sockio.h)
+# HMS: Checked sys/socket.h earlier
+case "$host" in
+ *-*-netbsd*) ;;
+ *) AC_CHECK_HEADERS(machine/soundcard.h sys/soundcard.h)
+    ;;
+esac
+AC_CHECK_HEADERS(sys/stat.h sys/stream.h)
+AC_CHECK_HEADERS(sys/stropts.h sys/sysctl.h sys/syssgi.h sys/systune.h)
+AC_CHECK_HEADERS(sys/termios.h sys/time.h sys/signal.h)
+AC_EGREP_CPP(yes,
+[#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#if HAVE_ERRNO_H
+# include <errno.h>
+#endif
+#include <sys/timepps.h>
+#ifdef PPS_API_VERS_1
+yes
+#endif
+], [AC_CHECK_HEADERS(sys/timepps.h, [], [],
+[#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#if HAVE_ERRNO_H
+# include <errno.h>
+#endif
+])
+])
+AC_CHECK_HEADERS(sys/timers.h sys/tpro.h sys/types.h sys/wait.h)
+AC_HEADER_TIME
+case "$host" in
+*-convex-*)
+  AC_CHECK_HEADERS(/sys/sync/queue.h /sys/sync/sema.h)
+  ;;
+*-*-bsdi*)
+  AC_CHECK_HEADERS(machine/inline.h sys/pcl720.h sys/i8253.h)
+  ;;
+esac
+
+case "$host" in
+ *-*-*linux*)
+    AC_CHECK_FUNCS(__adjtimex __ntp_gettime)
+    ;;
+esac
+case "$ac_cv_func___adjtimex" in
+ yes) ;;
+ *)
+    AC_CHECK_LIB(elf, nlist)   dnl Only needed for tickadj...
+    dnl AC_CHECK_LIB(kvm, main, , , -lelf)
+    AC_CHECK_LIB(kvm, main)            dnl We already know about -lelf here...
+    AC_CHECK_LIB(ld, nlist)
+    AC_CHECK_LIB(mld, nlist)
+    AC_CHECK_HEADER(nlist.h,
+    [AC_DEFINE(NLIST_STRUCT, 1, [nlist stuff])
+     AC_CACHE_CHECK([for n_un in struct nlist], ac_cv_struct_nlist_n_un,
+      [AC_TRY_COMPILE([#include <nlist.h>],
+       [struct nlist n; n.n_un.n_name = 0;],
+       ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])
+     if test $ac_cv_struct_nlist_n_un = yes; then
+       AC_DEFINE(NLIST_NAME_UNION, 1, [does struct nlist use a name union?])
+     fi
+    ])dnl
+    ;;
+esac
+
+dnl AC_CHECK_HEADERS(net/if.h, [], [],
+dnl [#if HAVE_SYS_TYPES_H
+dnl # include <sys/types.h>
+dnl #endif
+dnl #if HAVE_SYS_SOCKET_H
+dnl # include <sys/socket.h>
+dnl #endif
+dnl ])
+
+AC_CHECK_HEADERS(sys/proc.h, [], [],
+[#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+])
+
+AC_CHECK_HEADERS(sys/resource.h, [], [],
+[#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+])
+
+AC_CHECK_HEADERS(sys/shm.h, [], [],
+[#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#if HAVE_SYS_IPC_H
+# include <sys/ipc.h>
+#endif
+])
+
+AC_CHECK_HEADERS(sys/timex.h, [], [],
+[#if HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+])
+
+AC_CHECK_HEADERS(resolv.h, [], [],
+[#if HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#if HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#if HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+])
+
+AC_CACHE_CHECK([for basic volatile support], ac_cv_c_volatile,
+[AC_TRY_COMPILE([],[
+volatile int x;],
+       ac_cv_c_volatile=yes,
+       ac_cv_c_volatile=no)
+])
+case "$ac_cv_c_volatile" in
+ yes)
+    ;;
+ *) AC_DEFINE(volatile, , [Does the compiler like "volatile"?])
+    ;;
+esac
+
+#
+# following block goes away in 4.2.5
+#
+# AM_C_PROTOTYPES gives us ansi2knr
+case "$build" in
+ *-*-solaris2*)
+    # Assume that solaris2 is Ansi C...
+    ;;
+ *)
+    AM_C_PROTOTYPES
+    ;;
+esac
+AC_CACHE_CHECK(if C compiler permits function prototypes, ac_cv_have_prototypes,
+[AC_TRY_COMPILE([
+extern int foo (short);
+int foo(short i) { return i; }],[
+int i;], ac_cv_have_prototypes=yes, ac_cv_have_prototypes=no)
+])
+if test "$ac_cv_have_prototypes" = yes; then
+  AC_DEFINE(HAVE_PROTOTYPES, 1, [Are function prototypes OK?])
+fi
+#
+# end block 
+#
+
+AC_C_CONST
+AC_C_BIGENDIAN
+AC_TYPE_SIGNAL
+AC_TYPE_OFF_T
+AC_TYPE_SIZE_T
+AC_CHECK_TYPE(time_t, long)
+AC_CHECK_SIZEOF(time_t)
+AC_CHECK_TYPES(uintptr_t)
+AH_VERBATIM([TYPEDEF_UINTPTR_T],
+[/* Provide a typedef for uintptr_t? */
+#ifndef HAVE_UINTPTR_T
+typedef unsigned int   uintptr_t;
+#define HAVE_UINTPTR_T 1
+#endif])
+
+AC_STRUCT_TM
+
+AC_CACHE_CHECK([for u_int8_t], ac_cv_type_u_int8_t,
+[AC_TRY_COMPILE([#include <sys/types.h>],
+       [u_int8_t len = 42; return 0;],
+       ac_cv_type_u_int8_t=yes,
+       ac_cv_type_u_int8_t=no)
+])
+if test $ac_cv_type_u_int8_t = yes; then
+       AC_DEFINE(HAVE_TYPE_U_INT8_T, 1, [Does u_int8_t exist?])
+fi
+
+AC_CACHE_CHECK([for u_int64_t], ac_cv_type_u_int64_t,
+[AC_TRY_COMPILE([#include <sys/types.h>],
+       [u_int64_t len = 42; return 0;],
+       ac_cv_type_u_int64_t=yes,
+       ac_cv_type_u_int64_t=no)
+])
+if test $ac_cv_type_u_int64_t = yes; then
+       AC_DEFINE(HAVE_TYPE_U_INT64_T, 1, [Does u_int64_t exist?])
+fi
+
+#
+# Look for in_port_t.
+#
+AC_MSG_CHECKING([for in_port_t])
+AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <netinet/in.h>],
+[in_port_t port = 25; return (0);],
+       [AC_MSG_RESULT(yes)
+       ],
+        [AC_MSG_RESULT(no)
+       AC_DEFINE(ISC_PLATFORM_NEEDPORTT, 1, [Do we need our own in_port_t?])
+       ])
+
+AC_CACHE_CHECK([for a fallback value for HZ], ac_cv_var_default_hz,
+[ac_cv_var_default_hz=100
+case "$host" in
+ alpha*-dec-osf4*|alpha*-dec-osf5*)
+    ac_cv_var_default_hz=1024
+    ;;
+ mips-dec-ultrix4*)
+    ac_cv_var_default_hz=256
+    ;;
+esac])
+AC_DEFINE_UNQUOTED(DEFAULT_HZ, $ac_cv_var_default_hz, [What is the fallback value for HZ?])
+
+AC_CACHE_CHECK([if we need to override the system's value for HZ], ac_cv_var_override_hz,
+[ac_cv_var_override_hz=no
+case "$host" in
+ alpha*-dec-osf4*|alpha*-dec-osf5*)
+    ac_cv_var_override_hz=yes
+    ;;
+ mips-dec-ultrix4*)
+    ac_cv_var_override_hz=yes
+    ;;
+ *-*-freebsd*)
+    ac_cv_var_override_hz=yes
+    ;;
+ *-*-sunos4*)
+    ac_cv_var_override_hz=yes
+    ;;
+esac])
+case "$ac_cv_var_override_hz" in
+ yes)
+    AC_DEFINE(OVERRIDE_HZ, 1, [Do we need to override the system's idea of HZ?])
+    ;;
+esac
+
+dnl AC_CACHE_CHECK(ut_host in struct utmp, ac_cv_func_ut_host_in_utmp,
+dnl [AC_TRY_LINK([#include <sys/types.h>
+dnl #include <utmp.h>], [struct utmp ut; ut.ut_host;],
+dnl ac_cv_func_ut_host_in_utmp=yes, ac_cv_func_ut_host_in_utmp=no)])
+dnl if test $su_cv_func_ut_host_in_utmp = yes; then
+dnl   AC_DEFINE(HAVE_UT_HOST)
+dnl fi
+
+dnl AC_MSG_CHECKING(if we can get the system boot time)
+dnl AC_CACHE_VAL(su_cv_have_boot_time,
+dnl [AC_EGREP_CPP(yes,
+dnl [#ifdef HAVE_UTMPX_H
+dnl #include <utmpx.h>
+dnl #else
+dnl #include <utmp.h>
+dnl #endif
+dnl #ifdef BOOT_TIME
+dnl yes
+dnl #endif
+dnl ], su_cv_have_boot_time=yes, su_cv_have_boot_time=no)])
+dnl AC_MSG_RESULT($su_cv_have_boot_time)
+
+AC_CACHE_CHECK([for struct rt_msghdr], ac_cv_struct_rt_msghdr,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <net/if.h>
+#include <net/route.h>],
+[struct rt_msghdr p;],
+       ac_cv_struct_rt_msghdr=yes,
+       ac_cv_struct_rt_msghdr=no)
+])
+
+if test $ac_cv_struct_rt_msghdr = yes; then
+    AC_DEFINE(HAS_ROUTING_SOCKET, 1, [Do we have a routing socket (struct rt_msghdr)?])
+fi
+
+AC_CACHE_CHECK(
+  [struct sigaction for sa_sigaction],
+  ac_cv_struct_sigaction_has_sa_sigaction,
+  [
+    AC_TRY_COMPILE(
+      [#include <signal.h>],
+      [struct sigaction act; act.sa_sigaction = 0;],
+      ac_cv_struct_sigaction_has_sa_sigaction=yes,
+      ac_cv_struct_sigaction_has_sa_sigaction=no
+    )
+  ]
+)
+if test $ac_cv_struct_sigaction_has_sa_sigaction = yes; then
+  AC_DEFINE(HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION, 1, [Obvious...])
+fi
+
+AC_CACHE_CHECK([for struct ppsclockev], ac_cv_struct_ppsclockev,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#ifdef HAVE_SYS_TERMIOS_H
+# include <sys/termios.h>
+#endif
+#ifdef HAVE_SYS_TIME_H
+# include <sys/time.h>
+#endif
+#ifdef HAVE_SYS_PPSCLOCK_H
+# include <sys/ppsclock.h>
+#endif],[
+extern struct ppsclockev *pce;
+return pce->serial;],
+       ac_cv_struct_ppsclockev=yes,
+       ac_cv_struct_ppsclockev=no)
+])
+if test $ac_cv_struct_ppsclockev = yes; then
+    AC_DEFINE(HAVE_STRUCT_PPSCLOCKEV, 1, [Does a system header define struct ppsclockev?])
+fi
+
+AC_CACHE_CHECK([struct sockaddr for sa_len], ac_cv_struct_sockaddr_has_sa_len,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>],[
+extern struct sockaddr *ps;
+return ps->sa_len;],
+       ac_cv_struct_sockaddr_has_sa_len=yes,
+       ac_cv_struct_sockaddr_has_sa_len=no)
+])
+if test $ac_cv_struct_sockaddr_has_sa_len = yes; then
+    AC_DEFINE(HAVE_SA_LEN_IN_STRUCT_SOCKADDR, 1, [Should be obvious...])
+fi
+
+AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_struct_sockaddr_storage,
+[AC_TRY_COMPILE([
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+],[
+struct sockaddr_storage n;],
+       ac_cv_struct_sockaddr_storage=yes,
+       ac_cv_struct_sockaddr_storage=no)
+])
+if test $ac_cv_struct_sockaddr_storage = yes; then
+    AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE, 1, [Does a system header define struct sockaddr_storage?])
+fi
+
+AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
+               ac_cv_have_ss_family_in_struct_ss, [
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <sys/socket.h>
+               ],
+               [ struct sockaddr_storage s; s.ss_family = 1; ],
+               [ ac_cv_have_ss_family_in_struct_ss="yes" ],
+               [ ac_cv_have_ss_family_in_struct_ss="no" ],
+       )
+])
+if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
+       AC_DEFINE(HAVE_SS_FAMILY_IN_SS, 1, [Does struct sockaddr_storage have ss_family?])
+else
+    # Hack around a problem...
+    # HMS: This is $host because we need the -D if we are building *for* it.
+    # HMS: 061029: Now that we separate the ss_* checks this is causing
+    # a problem - disable it until we get to the bottom of it.
+    case "$host" in
+     XXX*-*-hpux11.11) CPPFLAGS="$CPPFLAGS -D_NETINET_IN6_H"
+       ;;
+    esac
+fi
+
+AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
+               ac_cv_have___ss_family_in_struct_ss, [
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <sys/socket.h>
+               ],
+               [ struct sockaddr_storage s; s.__ss_family = 1; ],
+               [ ac_cv_have___ss_family_in_struct_ss="yes" ],
+               [ ac_cv_have___ss_family_in_struct_ss="no" ]
+       )
+])
+if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
+       AC_DEFINE(HAVE___SS_FAMILY_IN_SS, 1, [Does struct sockaddr_storage have __ss_family?])
+fi
+
+AH_VERBATIM([X_HAVE_SS_FAMILY_IN_SS],
+[/* Handle ss_family */
+#if !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE___SS_FAMILY_IN_SS)
+# define ss_family __ss_family
+#endif /* !defined(HAVE_SS_FAMILY_IN_SS) && defined(HAVE_SA_FAMILY_IN_SS) */])
+
+AC_CACHE_CHECK([for ss_len field in struct sockaddr_storage],
+               ac_cv_have_ss_len_in_struct_ss, [
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <sys/socket.h>
+               ],
+               [ struct sockaddr_storage s; s.ss_len = 1; ],
+               [ ac_cv_have_ss_len_in_struct_ss="yes" ],
+               [ ac_cv_have_ss_len_in_struct_ss="no" ],
+       )
+])
+if test "x$ac_cv_have_ss_len_in_struct_ss" = "xyes" ; then
+       AC_DEFINE(HAVE_SS_LEN_IN_SS, 1, [Does struct sockaddr_storage have ss_len?])
+fi
+
+AC_CACHE_CHECK([for __ss_len field in struct sockaddr_storage],
+               ac_cv_have___ss_len_in_struct_ss, [
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <sys/socket.h>
+               ],
+               [ struct sockaddr_storage s; s.__ss_len = 1; ],
+               [ ac_cv_have___ss_len_in_struct_ss="yes" ],
+               [ ac_cv_have___ss_len_in_struct_ss="no" ]
+       )
+])
+if test "x$ac_cv_have___ss_len_in_struct_ss" = "xyes" ; then
+       AC_DEFINE(HAVE___SS_LEN_IN_SS, 1, [Does struct sockaddr_storage have __ss_len?])
+fi
+
+AH_VERBATIM([X_HAVE_SS_LEN_IN_SS],
+[/* Handle ss_len */
+#if !defined(HAVE_SS_LEN_IN_SS) && defined(HAVE___SS_LEN_IN_SS)
+# define ss_len __ss_len
+#endif /* !defined(HAVE_SS_LEN_IN_SS) && defined(HAVE_SA_LEN_IN_SS) */])
+
+case "$ac_cv_header_machine_soundcard_h$ac_cv_header_sys_soundcard_h" in
+  *yes*)
+    AC_CACHE_CHECK([for struct snd_size], ac_cv_struct_snd_size,
+[AC_TRY_COMPILE([
+#ifdef HAVE_MACHINE_SOUNDCARD_H
+# include <machine/soundcard.h>
+#endif
+#ifdef HAVE_SYS_SOUNDCARD_H
+# include <sys/soundcard.h>
+#endif],[
+extern struct snd_size *ss;
+return ss->rec_size;],
+    ac_cv_struct_snd_size=yes,
+    ac_cv_struct_snd_size=no)
+])
+    case "$ac_cv_struct_snd_size" in
+     yes) AC_DEFINE(HAVE_STRUCT_SND_SIZE, 1,[Do we have struct snd_size?]) ;;
+    esac
+    ;;
+esac
+
+AC_CACHE_CHECK([struct clockinfo for hz], ac_cv_struct_clockinfo_has_hz,
+[AC_TRY_COMPILE([
+#include <sys/time.h>],[
+extern struct clockinfo *pc;
+return pc->hz;],
+       ac_cv_struct_clockinfo_has_hz=yes,
+       ac_cv_struct_clockinfo_has_hz=no)
+])
+if test $ac_cv_struct_clockinfo_has_hz = yes; then
+    AC_DEFINE(HAVE_HZ_IN_STRUCT_CLOCKINFO, 1, [Obvious...])
+fi
+
+AC_CACHE_CHECK([struct clockinfo for tickadj], ac_cv_struct_clockinfo_has_tickadj,
+[AC_TRY_COMPILE([
+#include <sys/time.h>],[
+extern struct clockinfo *pc;
+return pc->tickadj;],
+       ac_cv_struct_clockinfo_has_tickadj=yes,
+       ac_cv_struct_clockinfo_has_tickadj=no)
+])
+if test $ac_cv_struct_clockinfo_has_tickadj = yes; then
+    AC_DEFINE(HAVE_TICKADJ_IN_STRUCT_CLOCKINFO, 1, [Obvious...])
+fi
+
+AC_CACHE_CHECK([for struct timespec], ac_cv_struct_timespec,
+[AC_TRY_COMPILE([
+#include <sys/time.h>
+/* Under SunOS, timespec is in sys/timepps.h, which needs errno.h and FRAC */
+#ifdef HAVE_ERRNO_H
+# include <errno.h>
+#endif
+#ifdef HAVE_SYS_TIMEPPS_H
+# define FRAC 4294967296
+# include <sys/timepps.h>
+#endif],
+[struct timespec n;],
+ac_cv_struct_timespec=yes, ac_cv_struct_timespec=no)])
+if test $ac_cv_struct_timespec = yes; then
+  AC_DEFINE(HAVE_STRUCT_TIMESPEC, 1, [Do we have struct timespec?])
+fi
+
+AC_CACHE_CHECK([for struct ntptimeval], ac_cv_struct_ntptimeval,
+[AC_TRY_COMPILE([
+#include <sys/time.h>
+#include <sys/timex.h>],
+[struct ntptimeval n;],
+ac_cv_struct_ntptimeval=yes, ac_cv_struct_ntptimeval=no)])
+if test $ac_cv_struct_ntptimeval = yes; then
+  AC_DEFINE(HAVE_STRUCT_NTPTIMEVAL, 1, [Do we have struct ntptimeval?])
+fi
+
+AC_CHECK_MEMBERS([struct ntptimeval.time.tv_nsec], , ,
+[#ifdef HAVE_SYS_TIME_H
+#include <sys/time.h>
+#else
+# ifdef HAVE_TIME_H
+# include <time.h>
+# endif
+#endif
+#ifdef HAVE_SYS_TIMEX_H
+#include <sys/timex.h>
+#else
+# ifdef HAVE_TIMEX_H
+# include <timex.h>
+# endif
+#endif])
+
+AC_C_INLINE
+
+case "$ac_cv_c_inline" in
+ '')
+    ;;
+ *)
+    AC_DEFINE(HAVE_INLINE,1,[inline keyword or macro available])
+    AC_SUBST(HAVE_INLINE)
+esac
+
+AC_C_CHAR_UNSIGNED             dnl CROSS_COMPILE?
+AC_CHECK_SIZEOF(signed char)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+
+AC_CHECK_TYPES([s_char])
+case "$ac_cv_c_char_unsigned$ac_cv_sizeof_signed_char$ac_cv_type_s_char" in
+ *yes)
+    # We have a typedef for s_char.  Might as well believe it...
+    ;;
+ no0no)
+    # We have signed chars, can't say 'signed char', no s_char typedef.
+    AC_DEFINE(NEED_S_CHAR_TYPEDEF, 1, [Do we need an s_char typedef?])
+    ;;
+ no1no)
+    # We have signed chars, can say 'signed char', no s_char typedef.
+    AC_DEFINE(NEED_S_CHAR_TYPEDEF)
+    ;;
+ yes0no)
+    # We have unsigned chars, can't say 'signed char', no s_char typedef.
+    AC_MSG_ERROR(No way to specify a signed character!)
+    ;;
+ yes1no)
+    # We have unsigned chars, can say 'signed char', no s_char typedef.
+    AC_DEFINE(NEED_S_CHAR_TYPEDEF)
+    ;;
+esac
+AC_TYPE_UID_T
+
+case "$host" in
+ *-*-aix[[456]]*)
+       # (prr) aix 4.1 doesn't have clock_settime, but in aix 4.3 it's a stub
+       # (returning ENOSYS).  I didn't check 4.2.  If, in the future,
+       # IBM pulls its thumbs out long enough to implement clock_settime,
+       # this conditional will need to change.  Maybe use AC_TRY_RUN
+       # instead to try to set the time to itself and check errno.
+    ;;
+ *) AC_CHECK_FUNCS(clock_gettime clock_settime)
+    ;;
+esac
+AC_CHECK_FUNCS(daemon)
+AC_CHECK_FUNCS(finite, ,
+  [AC_CHECK_FUNCS(isfinite, ,
+    [AC_MSG_CHECKING([for isfinite with <math.h>])
+    _libs=$LIBS
+    LIBS="$LIBS -lm"
+    AC_TRY_LINK([#include <math.h>], [float f = 0.0; isfinite(f)],
+      [AC_MSG_RESULT(yes)
+      AC_DEFINE(HAVE_ISFINITE)],
+      AC_MSG_RESULT(no))
+    LIBS=$_libs])])
+AC_CHECK_FUNCS(getbootfile getclock getdtablesize)
+
+AC_ARG_ENABLE(getifaddrs,
+    AC_HELP_STRING([--enable-getifaddrs],
+       [s Enable the use of getifaddrs() [[yes|no|glibc]].
+glibc: Use getifaddrs() in glibc if you know it supports IPv6.]),
+    want_getifaddrs="$enableval",  want_getifaddrs="yes")
+
+case $want_getifaddrs in
+yes|glibc)
+#
+# Do we have getifaddrs() ?
+#
+case $host in
+*-*linux*)
+       # Some recent versions of glibc support getifaddrs() which does not
+       # provide AF_INET6 addresses while the function provided by the USAGI
+       # project handles the AF_INET6 case correctly.  We need to avoid
+       # using the former but prefer the latter unless overridden by
+       # --enable-getifaddrs=glibc.
+       if test $want_getifaddrs = glibc
+       then
+               AC_CHECK_FUNCS(getifaddrs)
+       else
+               save_LIBS="$LIBS"
+               LIBS="-L/usr/local/v6/lib $LIBS"
+               AC_CHECK_LIB(inet6, getifaddrs,
+                       LIBS="$LIBS -linet6"
+                       AC_DEFINE(HAVE_GETIFADDRS),
+                       LIBS=${save_LIBS})
+       fi
+       ;;
+*)
+       AC_CHECK_FUNCS(getifaddrs)
+       ;;
+esac
+;;
+no)
+;;
+esac
+
+AC_MSG_CHECKING([type of socklen arg for getsockname()])
+AC_CACHE_VAL(ac_cv_func_getsockname_arg2,dnl
+[AC_CACHE_VAL(ac_cv_func_getsockname_socklen_type,dnl
+ [for ac_cv_func_getsockname_arg2 in 'struct sockaddr *' 'void *'; do
+  for ac_cv_func_getsockname_socklen_type in 'socklen_t' 'size_t' 'unsigned int' 'int'; do
+   AC_TRY_COMPILE(dnl
+[#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+extern getsockname (int, $ac_cv_func_getsockname_arg2, $ac_cv_func_getsockname_socklen_type *);],,dnl
+    [ac_not_found=no ; break 2], ac_not_found=yes)
+   done
+  done
+ ])dnl AC_CACHE_VAL
+])dnl AC_CACHE_VAL
+if test "$ac_not_found" = yes; then
+ ac_cv_func_getsockname_socklen_type='socklen_t'
+fi
+AC_MSG_RESULT([$ac_cv_func_getsockname_socklen_type])
+AC_DEFINE_UNQUOTED([GETSOCKNAME_SOCKLEN_TYPE],
+                  $ac_cv_func_getsockname_socklen_type,
+                  [What is getsockname()'s socklen type?])
+
+AC_CHECK_FUNCS(getrusage)
+AC_CHECK_FUNC(gettimeofday, ,[
+case "$host" in
+  *-*-mpeix*) ac_cv_func_gettimeofday=yes
+    ;;
+esac])
+case "$host" in
+ *-pc-cygwin*)
+    ;;
+ *) AC_CHECK_FUNCS(getuid)
+    ;;
+esac
+AC_CHECK_FUNCS(hstrerror)
+
+#
+# Check for if_nametoindex() for IPv6 scoped addresses support
+#
+AC_CHECK_FUNC(if_nametoindex, ac_cv_have_if_nametoindex=yes,
+               ac_cv_have_if_nametoindex=no)
+case $ac_cv_have_if_nametoindex in
+ no)
+       case "$host" in
+       *-hp-hpux*)
+               AC_CHECK_LIB(ipv6, if_nametoindex,
+                               ac_cv_have_if_nametoindex=yes
+                               LIBS="-lipv6 $LIBS",)
+       ;;
+       esac
+esac
+case $ac_cv_have_if_nametoindex in
+ yes)
+       AC_DEFINE(ISC_PLATFORM_HAVEIFNAMETOINDEX, 1, [ISC: do we have if_nametoindex()?])
+       ;;
+esac
+
+AC_CHECK_FUNC(inet_ntop, [], [AC_DEFINE(ISC_PLATFORM_NEEDNTOP, 1, [ISC: provide inet_ntop()])])
+AC_CHECK_FUNC(inet_pton, [], [AC_DEFINE(ISC_PLATFORM_NEEDPTON, 1, [ISC: provide inet_pton()])])
+AC_CHECK_FUNC(inet_aton, [], [AC_DEFINE(ISC_PLATFORM_NEEDATON, 1, [ISC: provide inet_aton()])])
+AC_CHECK_FUNCS(K_open kvm_open memcpy memmove memset)
+case "$host" in
+ *-*-sco3.2v5.0.*)
+    # Just stubs.  Idiots.
+    ;;
+ *) AC_CHECK_FUNCS(mkstemp)
+    ;;
+esac
+AC_CHECK_FUNCS(mktime)
+case "$host" in
+ *-*-aix[[456]]*)
+    # Just a stub.  Idiots.
+    ;;
+ *-*-irix[[45]]*)
+    # Just a stub in "old" Irix.  Idiots.
+    ;;
+ *-*-*linux*)
+    # there, but more trouble than it is worth for now (resolver problems)
+    ;;
+ *-*-qnx*)
+    # Apparently there but not working in QNX.  Idiots?
+    ;;
+ *-*-sco3.2v5.0.*)
+    # Just a stub.  Idiots.
+    ;;
+ alpha*-dec-osf4*|alpha*-dec-osf5*)
+    # mlockall is there, as a #define calling memlk via <sys/mman.h>
+    # Not easy to test for - cheat.
+    AC_CHECK_FUNCS(memlk, [ac_cv_func_mlockall='yes'])
+    AC_CHECK_FUNCS(mlockall)
+    ;;
+ *) AC_CHECK_FUNCS(mlockall)
+    ;;
+esac
+AC_CHECK_FUNCS(nice nlist)
+case "$host" in
+ *-*-solaris2.6)
+    # Broken...
+    ;;
+ *) AC_CHECK_FUNCS(ntp_adjtime ntp_gettime)
+    ;;
+esac
+AC_CHECK_FUNCS(plock pututline pututxline readlink recvmsg rtprio)
+case "$host" in
+ *-*-aix[[456]]*)
+    # Just a stub in AIX 4.  Idiots.
+    ;;
+ *-*-solaris2.5*)
+    # Just stubs in solaris2.5.  Idiots.
+    ;;
+ *) AC_CHECK_FUNCS(sched_setscheduler)
+    ;;
+esac
+AC_CHECK_FUNCS(setlinebuf setpgid setpriority setsid)
+AC_CHECK_FUNCS(setrlimit)
+AC_CHECK_FUNCS(settimeofday, ,[
+case "$host" in
+  *-*-mpeix*) ac_cv_func_settimeofday=yes
+    ;;
+esac])
+AC_CHECK_FUNCS(setvbuf sigaction)
+AC_CHECK_FUNCS(sigvec sigset sigsuspend stime strchr sysconf sysctl)
+AC_CHECK_FUNCS(snprintf strdup strerror strstr)
+AC_CHECK_FUNCS(timegm)
+case "$host" in
+ *-*-aix[[456]]*)
+    # Just stubs.  Idiots.
+    ;;
+ *-*-netbsd1*)
+    # Just stubs.  Idiots.
+    ;;
+ *-*-netbsdelf1*)
+    # Just stubs.  Idiots.
+    ;;
+ *-*-openbsd*)
+    # Just stubs.  Idiots.
+    ;;
+ *) AC_CHECK_FUNCS(timer_create timer_settime)
+    ;;
+esac
+case "$host" in
+ *-pc-cygwin*)
+    # I have no idea...
+    ;;
+ *) AC_CHECK_FUNCS(umask)
+    ;;
+esac
+AC_CHECK_FUNCS(uname updwtmp updwtmpx vsnprintf vsprintf)
+
+###
+
+# http://bugs.ntp.org/737
+case "$ac_cv_func_recvmsg" in
+ yes)
+ AC_MSG_CHECKING([if we need extra help to define struct iovec])
+ AC_CACHE_VAL(ac_cv_struct_iovec_help,dnl
+ [for ac_cv_struct_iovec_help in '0' '1'; do
+   AC_TRY_COMPILE(dnl
+[#ifdef HAVE_SYS_TYPES_H
+#include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_SOCKET_H
+#include <sys/socket.h>
+#endif
+#if $ac_cv_struct_iovec_help
+#include <sys/uio.h>
+#endif
+
+void foo();
+void foo() {
+       ssize_t x;
+       int s = 0;
+       struct iovec iov;
+       struct msghdr mh;
+       int flags = 0;
+
+       mh.msg_iov = &iov;
+       x = recvmsg(s, &mh, flags);
+}],,dnl
+  [ac_worked=yes ; break 1], ac_worked=no)
+  done
+])dnl AC_CACHE_VAL
+    case "$ac_worked$ac_cv_struct_iovec_help" in
+     yes1)
+       AC_DEFINE(HAVE_SYS_UIO_H, 1, [Use sys/uio.h for struct iovec help])
+       ans=yes
+       ;;
+     *) ans=no
+    esac
+    AC_MSG_RESULT([$ans])
+    ;;
+esac
+
+case "$host" in
+ *-*-sunos4*)
+    AC_DEFINE(SPRINTF_CHAR, 1, [*s*printf() functions are char*])
+    ;;
+esac
+
+AC_CACHE_CHECK([number of arguments to gettimeofday()], ac_cv_func_Xettimeofday_nargs,
+[AC_TRY_COMPILE([#include <sys/time.h>],[
+gettimeofday((struct timeval*)0,(struct timezone*)0);
+settimeofday((struct timeval*)0,(struct timezone*)0);
+],
+       ac_cv_func_Xettimeofday_nargs=2, ac_cv_func_Xettimeofday_nargs=1)
+])
+if test $ac_cv_func_Xettimeofday_nargs = 1; then
+       AC_DEFINE(SYSV_TIMEOFDAY, 1, [Does Xettimeofday take 1 arg?])
+fi
+
+AC_CACHE_CHECK([number of arguments taken by setpgrp()], ac_cv_func_setpgrp_nargs,
+[AC_TRY_COMPILE([
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+],[setpgrp(0,0);],
+        ac_cv_func_setpgrp_nargs=2, ac_cv_func_setpgrp_nargs=0)
+])
+if test $ac_cv_func_setpgrp_nargs = 0; then
+        AC_DEFINE(HAVE_SETPGRP_0, 1, [define if setpgrp takes 0 arguments])
+fi
+
+save_CFLAGS=$CFLAGS
+CFLAGS="$CFLAGS -I$srcdir/include"
+
+AC_CACHE_CHECK([argument pointer type of qsort()'s compare function and base],
+ac_cv_func_qsort_argtype,
+[AC_TRY_COMPILE([
+#include "l_stdlib.h"
+
+#ifdef HAVE_PROTOTYPES
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+
+extern void *base;
+extern sortfunc P((const void *, const void *));
+int sortfunc(a, b)
+  const void *a;
+  const void *b; { return 0; }
+],[
+qsort(base, 2, sizeof(char *), sortfunc);
+],
+       ac_cv_func_qsort_argtype=void, ac_cv_func_qsort_argtype=char)
+])
+case "$ac_cv_func_qsort_argtype" in
+ void)
+    AC_DEFINE(QSORT_USES_VOID_P, 1, [Does qsort expect to work on "void *" stuff?])
+    ;;
+esac
+
+CFLAGS=$save_CFLAGS
+
+AC_CACHE_CHECK([if we need to declare 'errno'], ac_cv_decl_errno,
+[AC_TRY_COMPILE([#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif],
+  [errno = 0;],
+  ac_cv_decl_errno=no, ac_cv_decl_errno=yes)])
+case "$ac_cv_decl_errno" in
+ yes) AC_DEFINE(DECL_ERRNO, 1, [Declare errno?]) ;;
+esac
+
+dnl FIXME: from ntpd/ntp_intres.c, but there's no info which header produces
+dnl the clash.  <resolv.h> isn't currently used.
+dnl
+dnl (prr) aix 4.3 defines h_errno as (*(int *)h_errno_which()) for
+dnl MT purposes.  This makes the line "extern int h_errno" choke
+dnl the compiler.  Hopefully adding !defined(h_errno) fixes this
+dnl without breaking any other platforms.
+dnl
+AC_CACHE_CHECK([if we may declare 'h_errno'], ac_cv_decl_h_errno,
+[AC_TRY_COMPILE([#include <sys/types.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#ifdef HAVE_ARPA_NAMESER_H
+#include <arpa/nameser.h>
+#endif
+#ifdef HAVE_NETDB_H
+#include <netdb.h>
+#endif
+#ifdef HAVE_RESOLV_H
+#include <resolv.h>
+#endif],
+  [extern int h_errno;],
+  ac_cv_decl_h_errno=yes, ac_cv_decl_h_errno=no)])
+case "$ac_cv_decl_h_errno" in
+ yes) AC_DEFINE(DECL_H_ERRNO, 1, [Declare h_errno?]) ;;
+esac
+
+dnl See if char *sys_errlist[] is OK.
+AC_CACHE_CHECK([[if declaring 'char *sys_errlist[]' is ok]], ac_cv_decl_sys_errlist,
+[AC_TRY_COMPILE([#include <stdio.h>
+#ifdef HAVE_ERRNO_H
+#include <errno.h>
+#endif],
+  [extern char *sys_errlist[];
+],
+  ac_cv_decl_sys_errlist=yes, ac_cv_decl_sys_errlist=no)])
+case "$ac_cv_decl_sys_errlist" in
+ yes) AC_DEFINE(CHAR_SYS_ERRLIST, 1, [Declare char *sys_errlist array]) ;;
+esac
+
+AC_CACHE_CHECK([if declaring 'syscall()' is ok], ac_cv_decl_syscall,
+[AC_TRY_COMPILE([
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_PROTOTYPES
+#define P(x) x
+#else
+#define P(x) ()
+#endif
+],
+  [extern int syscall P((int, ...));],
+  ac_cv_decl_syscall=yes, ac_cv_decl_syscall=no)])
+case "$ac_cv_decl_syscall" in
+ yes) AC_DEFINE(DECL_SYSCALL, 1, [Declare syscall()?]) ;;
+esac
+
+case "$host" in
+ *-*-aix4.3.*)
+    AC_DEFINE(DECL_HSTRERROR_0, 1, [Declaration style])                # Needed for XLC under AIX 4.3.2
+    ;;
+ *-*-mpeix*)
+    AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
+    AC_DEFINE(DECL_INET_NTOA_0, 1, [Declaration style])
+    AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SYSLOG_0, 1, [Declaration style])
+    AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
+    ;;
+ *-*-osf[[45]]*)
+    AC_DEFINE(DECL_PLOCK_0, 1, [Declaration style])
+    AC_DEFINE(DECL_STIME_1, 1, [Declaration style])
+    ;;
+ *-*-qnx*)
+    AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
+    ;;
+ *-*-riscos4*)
+    AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
+    AC_DEFINE(DECL_BZERO_0, 1, [Declaration style])
+    AC_DEFINE(DECL_IOCTL_0, 1, [Declaration style])
+    AC_DEFINE(DECL_IPC_0, 1, [Declaration style])
+    AC_DEFINE(DECL_MEMMOVE_0, 1, [Declaration style])
+    AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
+    AC_DEFINE(DECL_RENAME_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SETPRIORITY_0, 1, [Declaration style])
+    AC_DEFINE(DECL_STDIO_0, 1, [Declaration style])
+    AC_DEFINE(DECL_STRTOL_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SYSLOG_0, 1, [Declaration style])
+    AC_DEFINE(DECL_TIME_0, 1, [Declaration style])
+    AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
+    AC_DEFINE(DECL_TOLOWER_0, 1, [Declaration style])
+    ;;
+ *-*-solaris2*)
+    AC_DEFINE(DECL_MKSTEMP_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SETPRIORITY_1, 1, [Declaration style])
+    case "$host" in
+     *-*-solaris2.4)
+        AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
+       ;;
+    esac
+    ;;
+ *-*-sunos4*)
+    AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
+    AC_DEFINE(DECL_BCOPY_0, 1, [Declaration style])
+    AC_DEFINE(DECL_BZERO_0, 1, [Declaration style])
+    AC_DEFINE(DECL_IOCTL_0, 1, [Declaration style])
+    AC_DEFINE(DECL_IPC_0, 1, [Declaration style])
+    AC_DEFINE(DECL_MEMMOVE_0, 1, [Declaration style])
+    AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
+    AC_DEFINE(DECL_MKSTEMP_0, 1, [Declaration style])
+    AC_DEFINE(DECL_RENAME_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SETPRIORITY_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SIGVEC_0, 1, [Declaration style])
+    case "`basename $ac_cv_prog_CC`" in
+     acc*) ;;
+     *) AC_DEFINE(DECL_STDIO_0, 1, [Declaration style])
+       ;;
+    esac
+    AC_DEFINE(DECL_STRTOL_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SYSLOG_0, 1, [Declaration style])
+    AC_DEFINE(DECL_TIME_0, 1, [Declaration style])
+    AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
+    AC_DEFINE(DECL_TOLOWER_0, 1, [Declaration style])
+    AC_DEFINE(DECL_TOUPPER_0, 1, [Declaration style])
+    AC_DEFINE(DECL_STRERROR_0, 1, [Declaration style])
+    ;;
+ *-*-ultrix4*)
+    AC_DEFINE(DECL_ADJTIME_0, 1, [Declaration style])
+    AC_DEFINE(DECL_BZERO_0, 1, [Declaration style])
+    AC_DEFINE(DECL_CFSETISPEED_0, 1, [Declaration style])
+    AC_DEFINE(DECL_IOCTL_0, 1, [Declaration style])
+    AC_DEFINE(DECL_IPC_0, 1, [Declaration style])
+    AC_DEFINE(DECL_MKTEMP_0, 1, [Declaration style])
+    AC_DEFINE(DECL_NLIST_0, 1, [Declaration style])
+    AC_DEFINE(DECL_PLOCK_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SELECT_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SETITIMER_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SETPRIORITY_0, 1, [Declaration style])
+    AC_DEFINE(DECL_STIME_0, 1, [Declaration style])
+    AC_DEFINE(DECL_SYSLOG_0, 1, [Declaration style])
+    AC_DEFINE(DECL_TIMEOFDAY_0, 1, [Declaration style])
+    ;;
+esac
+
+case "$host" in
+ *-*-sco3.2*)
+    AC_DEFINE(TERMIOS_NEEDS__SVID3, 1, [Do we need to #define _SVID3 when we #include <termios.h>?])
+    ;;
+esac
+
+AC_CACHE_CHECK([if we need extra room for SO_RCVBUF], ac_cv_var_rcvbuf_slop,
+[ans=no
+case "$host" in
+ *-*-hpux[[567]]*)
+    ans=yes
+    ;;
+esac
+ac_cv_var_rcvbuf_slop=$ans])
+case "$ac_cv_var_rcvbuf_slop" in
+ yes) AC_DEFINE(NEED_RCVBUF_SLOP, 1, [Do we need extra room for SO_RCVBUF? (HPUX <8)]) ;;
+esac
+
+AC_CACHE_CHECK([if we will open the broadcast socket], ac_cv_var_open_bcast_socket,
+[ans=yes
+case "$host" in
+ *-*-domainos)
+    ans=no
+    ;;
+esac
+ac_cv_var_open_bcast_socket=$ans])
+case "$ac_cv_var_open_bcast_socket" in
+ yes) AC_DEFINE(OPEN_BCAST_SOCKET, 1, [Should we open the broadcast socket?]) ;;
+esac
+
+AC_CACHE_CHECK([if we want the HPUX version of FindConfig()], ac_cv_var_hpux_findconfig,
+[ans=no
+case "$host" in
+ *-*-hpux*)
+    ans=yes
+    ;;
+esac
+ac_cv_var_hpux_findconfig=$ans])
+case "$ac_cv_var_hpux_findconfig" in
+ yes) AC_DEFINE(NEED_HPUX_FINDCONFIG, 1, [Do we want the HPUX FindConfig()?]) ;;
+esac
+
+AC_CACHE_CHECK([if process groups are set with -pid], ac_cv_arg_setpgrp_negpid,
+[case "$host" in
+ *-*-hpux[[567]]*)
+    ans=no
+    ;;
+ *-*-hpux*)
+    ans=yes
+    ;;
+ *-*-*linux*)
+    ans=yes
+    ;;
+ *-*-sunos3*)
+    ans=yes
+    ;;
+ *-*-ultrix2*)
+    ans=yes
+    ;;
+ *)
+    ans=no
+    ;;
+esac
+ac_cv_arg_setpgrp_negpid=$ans])
+case "$ac_cv_arg_setpgrp_negpid" in
+ yes) AC_DEFINE(UDP_BACKWARDS_SETOWN, 1, [Do we set process groups with -pid?]) ;;
+esac
+
+AC_CACHE_CHECK([if we need a ctty for F_SETOWN], ac_cv_func_ctty_for_f_setown,
+[[case "$host" in
+ *-*-bsdi[23]*)
+    ans=yes
+    ;;
+ *-*-freebsd*)
+    ans=yes
+    ;;
+ *-*-netbsd*3.[0-8]*|*-*-netbsd*[0-2].*|*-*-netbsd*3.99.[0-7])
+    ans=yes
+    ;;
+ *-*-openbsd*)
+    ans=yes
+    ;;
+ *-*-osf*)
+    ans=yes
+    ;;
+ *-*-darwin*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+ac_cv_func_ctty_for_f_setown=$ans]])
+case "$ac_cv_func_ctty_for_f_setown" in
+ yes) AC_DEFINE(USE_FSETOWNCTTY, 1, [Must we have a CTTY for fsetown?]) ;;
+esac
+
+AC_CACHE_CHECK([if the OS fails to clear cached routes when more specific routes become available], ac_cv_os_routeupdates,
+[[case "$host" in
+ *-*-netbsd*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+ac_cv_os_routeupdates=$ans]])
+case "$ac_cv_os_routeupdates" in
+ yes) AC_DEFINE(OS_MISSES_SPECIFIC_ROUTE_UPDATES, 1, [need to recreate sockets on changed routing?]) ;;
+esac
+
+AC_CACHE_CHECK([if the OS needs the wildcard socket set to REUSEADDR for binding interface addresses], ac_cv_os_wildcardreuse,
+[[case "$host" in
+ *-*-*linux*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+ac_cv_os_wildcardreuse=$ans]])
+case "$ac_cv_os_wildcardreuse" in
+ yes) AC_DEFINE(OS_NEEDS_REUSEADDR_FOR_IFADDRBIND, 1, [wildcard socket needs to set REUSEADDR when binding to interface addresses]) ;;
+esac
+
+ntp_warning='GRONK'
+AC_MSG_CHECKING([if we'll use clock_settime or settimeofday or stime])
+case "$ac_cv_func_clock_settime$ac_cv_func_settimeofday$ac_cv_func_stime" in
+ yes*)
+    ntp_warning=''
+    ans='clock_settime()'
+    ;;
+ noyes*)
+    ntp_warning='But clock_settime() would be better (if we had it)'
+    ans='settimeofday()'
+    ;;
+ nonoyes)
+    ntp_warning='Which is the worst of the three'
+    ans='stime()'
+    ;;
+ *) 
+    case "$build" in
+     $host) ntp_warning='Which leaves us with nothing to use!'
+    ans=none
+    ;;
+esac
+esac
+AC_MSG_RESULT([$ans])
+case "$ntp_warning" in
+ '') ;;
+ *) AC_MSG_WARN([*** $ntp_warning ***])
+    ;;
+esac
+
+AC_CACHE_CHECK([if we have a losing syscall()], ac_cv_var_syscall_bug,
+[case "$host" in
+ *-*-solaris2.4*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+ac_cv_var_syscall_bug=$ans])
+case "$ac_cv_var_syscall_bug" in
+ yes) AC_DEFINE(SYSCALL_BUG, 1, [Buggy syscall() (Solaris2.4)?]) ;;
+esac
+
+AC_CACHE_CHECK([for SIGIO], ac_cv_hdr_def_sigio,
+ AC_EGREP_CPP(yes,
+  [#include <signal.h>
+#ifdef SIGIO
+   yes
+#endif
+  ], ac_cv_hdr_def_sigio=yes, ac_cv_hdr_def_sigio=no))
+
+dnl Override those system that have a losing SIGIO
+AC_CACHE_CHECK([if we want to use signalled IO], ac_cv_var_signalled_io,
+[ans=no
+case "$ac_cv_hdr_def_sigio" in
+ yes)
+    ans=yes
+    case "$host" in
+     alpha*-dec-osf4*|alpha*-dec-osf5*)
+        ans=no
+        ;;
+     *-convex-*)
+        ans=no
+        ;;
+     *-dec-*)
+        ans=no
+        ;;
+     *-pc-cygwin*)
+       ans=no
+       ;;
+     *-sni-sysv*)
+        ans=no
+        ;;
+     *-univel-sysv*)
+        ans=no
+       ;;
+     *-*-irix6*)
+       ans=no
+       ;;
+     *-*-freebsd*)
+       ans=no
+       ;;
+     *-*-*linux*)
+       ans=no
+       ;;
+     *-*-unicosmp*)
+       ans=no
+       ;;
+    esac
+    ;;
+esac
+ac_cv_var_signalled_io=$ans])
+case "$ac_cv_var_signalled_io" in
+ yes) AC_DEFINE(HAVE_SIGNALED_IO, 1, [Can we use SIGIO for tcp and udp IO?]) ;;
+esac
+
+AC_CACHE_CHECK([for SIGPOLL], ac_cv_hdr_def_sigpoll,
+ AC_EGREP_CPP(yes,
+ [#include <signal.h>
+#ifdef SIGPOLL
+  yes
+#endif
+ ], ac_cv_hdr_def_sigpoll=yes, ac_cv_hdr_def_sigpoll=no))
+
+AC_CACHE_CHECK([for SIGSYS], ac_cv_hdr_def_sigsys,
+ AC_EGREP_CPP(yes,
+ [#include <signal.h>
+#ifdef SIGSYS
+  yes
+#endif
+ ], ac_cv_hdr_def_sigsys=yes, ac_cv_hdr_def_sigsys=no))
+
+AC_CACHE_CHECK([if we can use SIGPOLL for UDP I/O], ac_cv_var_use_udp_sigpoll,
+[ans=no
+case "$ac_cv_hdr_def_sigpoll" in
+ yes)
+    case "$host" in
+     mips-sgi-irix*)
+       ans=no
+       ;;
+     vax-dec-bsd)
+        ans=no
+        ;;
+     *-pc-cygwin*)
+       ans=no
+       ;;
+     *-sni-sysv*)
+        ans=no
+        ;;
+     *-*-aix[[456]]*)
+        ans=no
+        ;;
+     *-*-hpux*)
+        ans=no
+        ;;
+     *-*-*linux*)
+       ans=no
+       ;;
+     *-*-osf*)
+        ans=no
+        ;;
+     *-*-qnx*)
+        ans=no
+        ;;
+     *-*-sunos*)
+       ans=no
+       ;;
+     *-*-solaris*)
+       ans=no
+       ;;
+     *-*-ultrix*)
+        ans=no
+        ;;
+     *-*-unicosmp*)
+        ans=no
+        ;;
+     *) ans=yes
+        ;;
+    esac
+    ;;
+esac
+ac_cv_var_use_udp_sigpoll=$ans])
+case "$ac_cv_var_use_udp_sigpoll" in
+ yes) AC_DEFINE(USE_UDP_SIGPOLL, 1, [Can we use SIGPOLL for UDP?]) ;;
+esac
+
+AC_CACHE_CHECK([if we can use SIGPOLL for TTY I/O], ac_cv_var_use_tty_sigpoll,
+[ans=no
+case "$ac_cv_hdr_def_sigpoll" in
+ yes)
+    case "$host" in
+     mips-sgi-irix*)
+        ans=no
+        ;;
+     vax-dec-bsd)
+        ans=no
+        ;;
+     *-pc-cygwin*)
+       ans=no
+       ;;
+     *-sni-sysv*)
+        ans=no
+        ;;
+     *-*-aix[[456]]*)
+       ans=no
+       ;;
+     *-*-hpux*)
+        ans=no
+        ;;
+     *-*-*linux*)
+       ans=no
+       ;;
+     *-*-osf*)
+        ans=no
+        ;;
+     *-*-sunos*)
+       ans=no
+       ;;
+     *-*-ultrix*)
+        ans=no
+        ;;
+     *-*-qnx*)
+        ans=no
+        ;;
+     *-*-unicosmp*)
+        ans=no
+        ;;
+     *) ans=yes
+        ;;
+    esac
+    ;;
+esac
+ac_cv_var_use_tty_sigpoll=$ans])
+case "$ac_cv_var_use_tty_sigpoll" in
+ yes) AC_DEFINE(USE_TTY_SIGPOLL, 1, [Can we use SIGPOLL for tty IO?]) ;;
+esac
+
+case "$ac_cv_header_sys_sio_h" in
+ yes)
+    AC_CACHE_CHECK([sys/sio.h for TIOCDCDTIMESTAMP], ac_cv_hdr_def_tiocdcdtimestamp,
+     AC_EGREP_CPP(yes,
+[#include <sys/sio.h>
+#ifdef TIOCDCDTIMESTAMP
+  yes
+#endif
+     ], ac_cv_hdr_def_tiocdcdtimestamp=yes, ac_cv_hdr_def_tiocdcdtimestamp=no))
+    ;;
+esac
+
+case "$ac_cv_hdr_def_tiocdcdtimestamp" in
+ yes)
+    ac_cv_var_oncore_ok=yes
+    ;;
+esac
+
+AC_CACHE_CHECK([if nlist() values might require extra indirection],
+ac_cv_var_nlist_extra_indirection,
+[ans=no
+case "$host" in
+ *-*-aix*)
+    ans=yes
+    ;;
+esac
+ac_cv_var_nlist_extra_indirection=$ans])
+case "$ac_cv_var_nlist_extra_indirection" in
+ yes) AC_DEFINE(NLIST_EXTRA_INDIRECTION, 1, [Might nlist() values require an extra level of indirection (AIX)?]) ;;
+esac
+
+AC_CACHE_CHECK([for a minimum recommended value of tickadj],
+ac_cv_var_min_rec_tickadj,
+[ans=no
+case "$host" in
+ *-*-aix*)
+    ans=40
+    ;;
+esac
+ac_cv_var_min_rec_tickadj=$ans])
+case "$ac_cv_var_min_rec_tickadj" in
+ ''|no) ;;
+ *) AC_DEFINE_UNQUOTED(MIN_REC_TICKADJ, $ac_cv_var_min_rec_tickadj, [Should we recommend a minimum value for tickadj?]) ;;
+esac
+
+AC_CACHE_CHECK([if the TTY code permits PARENB and IGNPAR],
+ac_cv_var_no_parenb_ignpar,
+[ans=no
+case "$host" in
+ i?86-*-*linux*)
+    ans=yes
+    ;;
+ mips-sgi-irix*)
+    ans=yes
+    ;;
+ i?86-*-freebsd[[123]].*)
+    ;;
+ i?86-*-freebsd*)
+    ans=yes
+    ;;
+ *-*-unicosmp*)
+    ans=yes
+    ;;
+esac
+ac_cv_var_no_parenb_ignpar=$ans])
+case "$ac_cv_var_no_parenb_ignpar" in
+ yes) AC_DEFINE(NO_PARENB_IGNPAR, 1, [Is there a problem using PARENB and IGNPAR (IRIX)?]) ;;
+esac
+
+AC_MSG_CHECKING([if we're including debugging code])
+AC_ARG_ENABLE(debugging,
+   AC_HELP_STRING([--enable-debugging], [+ include debugging code]),
+    [ntp_ok=$enableval], [ntp_ok=yes])
+if test "$ntp_ok" = "yes"; then
+    AC_DEFINE(DEBUG, 1, [Enable debugging?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([if we including processing time debugging code])
+AC_ARG_ENABLE(debug-timing,
+   AC_HELP_STRING([--enable-debug-timing], [- include processing time debugging code (costs performance)]),
+    [ntp_ok=$enableval], [ntp_ok=no])
+if test "$ntp_ok" = "yes"; then
+    AC_DEFINE(DEBUG_TIMING, 1, [Enable processing time debugging?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([[for a the number of minutes in a DST adjustment]])
+AC_ARG_ENABLE(
+    [dst_minutes],
+    AS_HELP_STRING(
+       [--enable-dst-minutes],
+       [n minutes per DST adjustment @<:@60@:>@]       dnl @<:@ is [
+    ),
+    [ans=$enableval],
+    [ans=60]
+)
+AC_DEFINE_UNQUOTED(DSTMINUTES, $ans, [The number of minutes in a DST adjustment])
+AC_MSG_RESULT([$ans])
+
+AC_MSG_CHECKING([[if ntpd will retry on permanent DNS errors]])
+AC_ARG_ENABLE(
+    [ignore-dns-errors],
+    AS_HELP_STRING(
+       [--enable-ignore-dns-errors], 
+       [- retry DNS queries on any error]
+    ),
+    [ans=$enableval],
+    [ans=no]
+)
+case "$ans" in
+ yes)
+    AC_DEFINE(IGNORE_DNS_ERRORS, 1, [[Retry queries on _any_ DNS error?]])
+esac
+AC_MSG_RESULT([$ans])
+
+AC_CACHE_CHECK([if we have the tty_clk line discipline/streams module],
+ ac_cv_var_tty_clk,
+ [case "$ac_cv_header_sys_clkdefs_h$ac_cv_hdr_def_tiocdcdtimestamp" in
+  *yes*) ac_cv_var_tty_clk=yes ;;
+  *)     ac_cv_var_tty_clk=no ;;
+ esac])
+case "$ac_cv_var_tty_clk" in
+ yes) AC_DEFINE(TTYCLK, 1, [Do we have the tty_clk line discipline/streams module?]) ;;
+esac
+
+AC_CACHE_CHECK([for the ppsclock streams module],
+ ac_cv_var_ppsclock,
+ ac_cv_var_ppsclock=$ac_cv_struct_ppsclockev)
+case "$ac_cv_var_ppsclock" in
+ yes) AC_DEFINE(PPS, 1, [Do we have the ppsclock streams module?]) ;;
+esac
+
+AC_CACHE_CHECK([for kernel multicast support], ac_cv_var_mcast,
+  [ac_cv_var_mcast=no
+  case "$host" in
+   i386-sequent-sysv4) ;;
+   *) AC_EGREP_CPP(yes,
+  [#include <netinet/in.h>
+#ifdef IP_ADD_MEMBERSHIP
+   yes
+#endif
+  ], ac_cv_var_mcast=yes) ;;
+  esac])
+case "$ac_cv_var_mcast" in
+ yes)
+    AC_DEFINE(MCAST, 1, [Does the kernel support multicasting IP?])
+    AC_CACHE_CHECK([[arg type needed for IP*_MULTICAST_LOOP for setsockopt()]],
+       ac_cv_var_typeof_ip_multicast_loop,
+       [case "$host" in
+        *-*-netbsd*|*-*-*linux*)
+           ac_cv_var_typeof_ip_multicast_loop=u_int
+           ;;
+        *-*-winnt*)
+           ac_cv_var_typeof_ip_multicast_loop=BOOL
+           ;;
+        *) ac_cv_var_typeof_ip_multicast_loop=u_char
+           ;;
+       esac])
+    AC_DEFINE_UNQUOTED(TYPEOF_IP_MULTICAST_LOOP,
+                  $ac_cv_var_typeof_ip_multicast_loop,
+                  [What type to use for setsockopt])
+    ;;
+esac
+
+AC_CACHE_CHECK([[availability of ntp_{adj,get}time()]], ac_cv_var_ntp_syscalls,
+ [ac_cv_var_ntp_syscalls=no
+ case "$ac_cv_func_ntp_adjtime$ac_cv_func_ntp_gettime$ac_cv_func___adjtimex" in
+  yesyes*)
+    ac_cv_var_ntp_syscalls=libc
+    ;;
+  *yes)
+    ac_cv_var_ntp_syscalls=inline
+    ;;
+  *) AC_EGREP_CPP(yes,
+         [#include <sys/syscall.h>
+#if defined(SYS_ntp_gettime) && defined(SYS_ntp_adjtime)
+           yes
+#endif
+          ], ac_cv_var_ntp_syscalls=kernel)
+    ;;
+ esac])
+case "$ac_cv_var_ntp_syscalls" in
+ libc)
+    AC_DEFINE(NTP_SYSCALLS_LIBC, 1, [Do we have ntp_{adj,get}time in libc?])
+    ;;
+ kernel)
+    AC_DEFINE(NTP_SYSCALLS_STD, 1, [Do we have ntp_{adj,get}time in the kernel?])
+    ;;
+ *)
+    ;;
+esac
+
+AC_CACHE_CHECK(if sys/timex.h has STA_FLL, ac_cv_var_sta_fll,
+[AC_EGREP_CPP(yes,
+    [#include <sys/timex.h>
+#ifdef STA_FLL
+    yes
+#endif
+    ], ac_cv_var_sta_fll=yes, ac_cv_var_sta_fll=no)])
+
+AC_CACHE_CHECK(if we have kernel PLL support, ac_cv_var_kernel_pll,
+[dnl ac_cv_var_ntp_syscalls is {no,libc,kernel}
+case "$ac_cv_header_sys_timex_h$ac_cv_struct_ntptimeval$ac_cv_var_sta_fll$ac_cv_var_ntp_syscalls" in
+ *no*)
+    ac_cv_var_kernel_pll=no
+    ;;
+ *) ac_cv_var_kernel_pll=yes
+    ;;
+esac])
+case "$ac_cv_var_kernel_pll" in
+ yes)
+    AC_DEFINE(KERNEL_PLL, 1, [Does the kernel support precision time discipline?])
+    ;;
+esac
+
+AC_CACHE_CHECK(if SIOCGIFCONF returns buffer size in the buffer, ac_cv_var_size_returned_in_buffer,
+  [ans=no
+  case "$host" in
+   *-fujitsu-uxp*)
+      ans=yes
+      ;;
+   *-ncr-sysv4*)
+      ans=yes
+      ;;
+   *-univel-sysv*)
+      ans=yes
+      ;;
+  esac
+  ac_cv_var_size_returned_in_buffer=$ans])
+case "$ac_cv_var_size_returned_in_buffer" in
+ yes) AC_DEFINE(SIZE_RETURNED_IN_BUFFER, 1, [Does SIOCGIFCONF return size in the buffer?]) ;;
+esac
+
+dnl    vvvvv-- this is wrong, if you re-enable the switch do not cache the result
+dnl AC_CACHE_CHECK(if we want GDT surveying code, ac_cv_var_gdt_surveying,
+dnl [AC_ARG_ENABLE(gdt-surveying,      [  --enable-gdt-surveying   - include GDT survey code],
+dnl     [ans=$enableval], [ans=no])
+dnl ac_cv_var_gdt_surveying=$ans])
+dnl case "$ac_cv_var_gdt_surveying" in
+dnl  yes) AC_DEFINE(GDT_SURVEYING, 1, [Include the GDT Surveying code?]) ;;
+dnl esac
+
+# Check for ioctls TIOCGPPSEV
+AC_MSG_CHECKING(ioctl TIOCGPPSEV)
+if test "$ac_cv_header_termios_h" = "yes"; then
+    AC_EGREP_CPP(yes,
+    [#include <termios.h>
+#ifdef TIOCGPPSEV
+         yes
+#endif
+        ], ntp_ok=yes, ntp_ok=no)
+else
+ntp_ok=no
+fi
+if test "$ntp_ok" = "yes"; then
+    AC_DEFINE(HAVE_TIOCGPPSEV, 1, [Do we have the TIOCGPPSEV ioctl (Solaris)?])
+    ac_cv_var_oncore_ok=yes
+fi
+AC_MSG_RESULT($ntp_ok)
+
+# Check for ioctls TIOCSPPS
+AC_MSG_CHECKING(ioctl TIOCSPPS)
+if test "$ac_cv_header_termios_h" = "yes"; then
+    AC_EGREP_CPP(yes,
+    [#include <termios.h>
+#ifdef TIOCSPPS
+         yes
+#endif
+        ], ntp_ok=yes, ntp_ok=no)
+else
+    ntp_ok=no
+fi
+
+if test "$ntp_ok" = "yes"; then
+    AC_DEFINE(HAVE_TIOCSPPS, 1, [Do we have the TIOCSPPS ioctl (Solaris)?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+# Check for ioctls CIOGETEV
+AC_MSG_CHECKING([ioctl CIOGETEV])
+if test "$ac_cv_header_sys_ppsclock_h" = "yes"; then
+    AC_EGREP_CPP(yes,
+    [#include <sys/ppsclock.h>
+#ifdef CIOGETEV
+         yes
+#endif
+        ], ntp_ok=yes, ntp_ok=no)
+else
+ntp_ok=no
+fi
+if test "$ntp_ok" = "yes"; then
+    ac_cv_var_oncore_ok=yes
+    AC_DEFINE(HAVE_CIOGETEV, 1, [Do we have the CIOGETEV ioctl (SunOS, Linux)?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+
+# ATOM/PPSAPI stuff.
+
+# ATOM used to require struct timespec, but that's been fixed now.
+
+# case "$ac_cv_struct_timespec" in
+#  'yes')
+#     ac_cv_var_atom_ok=yes
+#     ;;
+# esac
+ac_cv_var_atom_ok=yes
+
+# Check for header timepps.h, if found then we have PPS API (Draft RFC) stuff.
+
+# The PPSAPI headers need "inline" ($ac_cv_c_inline='inline')
+
+# The PPSAPI needs struct timespec.
+
+# The PPSAPI also needs a timepps header.
+
+case "$ac_cv_c_inline$ac_cv_struct_timespec" in
+ inlineyes)
+    case "$ac_cv_header_timepps_h$ac_cv_header_sys_timepps_h$host_os" in
+     *yes* | *sunos* | *solaris* | *sco* | *netbsd* )
+       AC_DEFINE(HAVE_PPSAPI, 1, [Do we have the PPS API per the Draft RFC?])
+       ac_cv_var_jupiter_ok=yes
+       ac_cv_var_oncore_ok=yes
+       ac_cv_var_parse_ok=yes
+       ac_cv_var_ripe_ncc_ok=yes
+       ;;
+    esac
+    ;;
+esac
+
+# Check for ioctls TIOCGSERIAL, TIOCSSERIAL, ASYNC_PPS_CD_POS, ASYNC_PPS_CD_NEG
+AC_CHECK_HEADER(linux/serial.h)
+AC_MSG_CHECKING([ioctl TIOCGSERIAL, TIOCSSERIAL, ASYNC_PPS_CD_POS, ASYNC_PPS_CD_NEG])
+case "$ac_cv_header_sys_ppsclock_h$ac_cv_header_linux_serial_h" in
+  yesyes)
+    AC_EGREP_CPP(yes,
+    [#include <sys/time.h>
+typedef int u_int;
+
+#include <sys/ppsclock.h>
+#include <linux/serial.h>
+
+#ifdef TIOCGSERIAL
+#ifdef TIOCSSERIAL
+#ifdef ASYNC_PPS_CD_POS
+#ifdef ASYNC_PPS_CD_NEG
+#ifdef CIOGETEV
+         yes
+#endif
+#endif
+#endif
+#endif
+#endif
+        ], ntp_ok=yes)
+       ;;
+  *)
+       ntp_ok=no
+       ;;
+esac
+if test "$ntp_ok" = "yes"; then
+    AC_DEFINE(HAVE_TIO_SERIAL_STUFF, 1, [Do we have the TIO serial stuff?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+# Check for SHMEM_STATUS support
+AC_MSG_CHECKING([SHMEM_STATUS support])
+case "$ac_cv_header_sys_mman_h" in
+ yes) ntp_ok=yes ;;
+ *)   ntp_ok=no  ;;
+esac
+if test "$ntp_ok" = "yes"; then
+    AC_DEFINE(ONCORE_SHMEM_STATUS, 1, [Do we have support for SHMEM_STATUS?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+dnl dnl These are for OPT_PROGRAMS in authstuff/
+dnl AC_SUBST(AUTHCERT)
+dnl AC_SUBST(AUTHSPEED)
+dnl AC_SUBST(MD5DRIVER)
+dnl AC_SUBST(KEYPARITY)
+dnl AC_SUBST(MAKEIPFP)
+dnl AC_SUBST(MAKEPC1)
+dnl AC_SUBST(MAKEPC2)
+dnl AC_SUBST(MAKESP)
+dnl AC_SUBST(MKRANDKEYS)
+dnl AC_SUBST(OMAKEIPFP)
+dnl AC_SUBST(UNIXCERT)
+
+ntp_refclock=no
+
+# HPUX only, and by explicit request
+AC_MSG_CHECKING([Datum/Bancomm bc635/VME interface])
+AC_ARG_ENABLE(BANCOMM,
+    AC_HELP_STRING([--enable-BANCOMM], [- Datum/Bancomm bc635/VME interface]),
+    [ntp_ok=$enableval], [ntp_ok=no])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_BANC, 1, [Datum/Bancomm bc635/VME interface?])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$host" in
+ yes*-*-hpux*) ;;
+ yes*) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
+esac
+
+#HPUX only, and only by explicit request
+AC_MSG_CHECKING([TrueTime GPS receiver/VME interface])
+AC_ARG_ENABLE(GPSVME,
+    AC_HELP_STRING([--enable-GPSVME], [- TrueTime GPS receiver/VME interface]),
+    [ntp_ok=$enableval], [ntp_ok=no])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_GPSVME, 1, [TrueTime GPS receiver/VME interface?])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$host" in
+ yes*-*-hpux*) ;;
+ yes*) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
+esac
+
+AC_MSG_CHECKING([for PCL720 clock support])
+case "$ac_cv_header_machine_inline_h$ac_cv_header_sys_pcl720_h$ac_cv_header_sys_i8253_h" in
+ yesyesyes)
+    AC_DEFINE(CLOCK_PPS720, 1, [PCL 720 clock support])
+    ans=yes
+    ;;
+ *)
+    ans=no
+    ;;
+esac
+AC_MSG_RESULT([$ans])
+
+AC_MSG_CHECKING([for default inclusion of all suitable non-PARSE clocks])
+AC_ARG_ENABLE(all-clocks,
+    AC_HELP_STRING([--enable-all-clocks], [+ include all suitable non-PARSE clocks:]),
+    [ntp_eac=$enableval], [ntp_eac=yes])
+AC_MSG_RESULT($ntp_eac)
+
+# HMS: Should we also require ac_cv_var_parse_ok?
+AC_MSG_CHECKING([if we have support for PARSE clocks])
+case "$ac_cv_var_atom_ok$ac_cv_header_termio_h$ac_cv_header_termios_h" in
+ yes*yes*)
+    ntp_canparse=yes
+    ;;
+ *) ntp_canparse=no
+    ;;
+esac
+AC_MSG_RESULT($ntp_canparse)
+
+AC_MSG_CHECKING([if we have support for audio clocks])
+case "$ac_cv_header_sun_audioio_h$ac_cv_header_sys_audioio_h$ac_cv_header_machine_soundcard_h$ac_cv_header_sys_soundcard_h" in
+ *yes*)
+    ntp_canaudio=yes
+    AC_DEFINE(HAVE_AUDIO, , [Do we have audio support?])
+    ;;
+ *) ntp_canaudio=no ;;
+esac
+AC_MSG_RESULT($ntp_canaudio)
+
+AC_MSG_CHECKING([if we have support for the SHM refclock interface])
+case "$ac_cv_header_sys_ipc_h$ac_cv_header_sys_shm_h" in
+ yesyes)
+    ntp_canshm=yes
+    ;;
+ *) ntp_canshm=no ;;
+esac
+AC_MSG_RESULT($ntp_canshm)
+
+# Requires modem control
+AC_MSG_CHECKING([ACTS modem service])
+AC_ARG_ENABLE(ACTS,
+    AC_HELP_STRING([--enable-ACTS], [s ACTS modem service]),
+    [ntp_ok=$enableval],
+    [AC_EGREP_CPP(yes,
+        [#include <termios.h>
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef TIOCMBIS
+         yes
+#endif
+         ], ntp_ok=$ntp_eac, ntp_ok=no)])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_ACTS, 1, [ACTS modem service])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Arbiter 1088A/B GPS receiver])
+AC_ARG_ENABLE(ARBITER,
+    AC_HELP_STRING([--enable-ARBITER], [+ Arbiter 1088A/B GPS receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_ARBITER, 1, [Arbiter 1088A/B GPS receiver])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Arcron MSF receiver])
+AC_ARG_ENABLE(ARCRON_MSF,
+    AC_HELP_STRING([--enable-ARCRON-MSF], [+ Arcron MSF receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_ARCRON_MSF, 1, [ARCRON support?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Austron 2200A/2201A GPS receiver])
+AC_ARG_ENABLE(AS2201,
+    AC_HELP_STRING([--enable-AS2201], [+ Austron 2200A/2201A GPS receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_AS2201, 1, [Austron 2200A/2201A GPS receiver?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([ATOM PPS interface])
+AC_ARG_ENABLE(ATOM,    
+    AC_HELP_STRING([--enable-ATOM], [s ATOM PPS interface]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+case "$ac_cv_var_atom_ok" in
+ no) ntp_ok=no ;;
+esac
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_ATOM, 1, [PPS interface?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Chrono-log K-series WWVB receiver])
+AC_ARG_ENABLE(CHRONOLOG,
+    AC_HELP_STRING([--enable-CHRONOLOG], [+ Chrono-log K-series WWVB receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_CHRONOLOG, 1, [Chronolog K-series WWVB receiver?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([CHU modem/decoder])
+AC_ARG_ENABLE(CHU,
+    AC_HELP_STRING([--enable-CHU], [+ CHU modem/decoder]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_CHU, 1, [CHU modem/decoder])
+fi
+AC_MSG_RESULT($ntp_ok)
+ac_refclock_chu=$ntp_ok
+
+AC_MSG_CHECKING([CHU audio/decoder])
+AC_ARG_ENABLE(AUDIO-CHU,
+    AC_HELP_STRING([--enable-AUDIO-CHU], [s CHU audio/decoder]),
+    [ntp_ok=$enableval],
+    [case "$ntp_eac$ac_refclock_chu$ntp_canaudio" in
+ *no*) ntp_ok=no  ;;
+ *)    ntp_ok=yes ;;
+esac])
+if test "$ntp_ok" = "yes"; then
+    AC_DEFINE(AUDIO_CHU, 1, [CHU audio/decoder?])
+fi
+AC_MSG_RESULT($ntp_ok)
+# We used to check for sunos/solaris target...
+case "$ntp_ok$ac_refclock_chu$ntp_canaudio" in
+ yes*no*) AC_MSG_WARN([*** But the expected answer is...no ***]) ;;
+esac
+
+# Not under HP-UX
+AC_MSG_CHECKING([Datum Programmable Time System])
+AC_ARG_ENABLE(DATUM,
+    AC_HELP_STRING([--enable-DATUM], [s Datum Programmable Time System]),
+    [ntp_ok=$enableval],
+    [case "$ac_cv_header_termios_h" in
+    yes)
+        ntp_ok=$ntp_eac
+        ;;
+    *) ntp_ok=no
+        ;;
+    esac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_DATUM, 1, [Datum Programmable Time System?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Dumb generic hh:mm:ss local clock])
+AC_ARG_ENABLE(DUMBCLOCK,
+    AC_HELP_STRING([--enable-DUMBCLOCK], [+ Dumb generic hh:mm:ss local clock]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_DUMBCLOCK, 1, [Dumb generic hh:mm:ss local clock?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Forum Graphic GPS])
+AC_ARG_ENABLE(FG,
+    AC_HELP_STRING([--enable-FG], [+ Forum Graphic GPS]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_FG, 1, [Forum Graphic GPS datating station driver?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+# Requires modem control
+AC_MSG_CHECKING([Heath GC-1000 WWV/WWVH receiver])
+AC_ARG_ENABLE(HEATH,
+    AC_HELP_STRING([--enable-HEATH], [s Heath GC-1000 WWV/WWVH receiver]),
+    [ntp_ok=$enableval],
+    [AC_EGREP_CPP(yes,
+        [#include <termios.h>
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+#ifdef TIOCMBIS
+         yes
+#endif
+         ], ntp_ok=$ntp_eac, ntp_ok=no)])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_HEATH, 1, [Heath GC-1000 WWV/WWVH receiver?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([for hopf serial clock device])
+AC_ARG_ENABLE(HOPFSERIAL,
+    AC_HELP_STRING([--enable-HOPFSERIAL], [+ hopf serial clock device]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_HOPF_SERIAL, 1, [HOPF serial clock device?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([for hopf PCI clock 6039])
+AC_ARG_ENABLE(HOPFPCI,
+    AC_HELP_STRING([--enable-HOPFPCI], [+ hopf 6039 PCI board]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_HOPF_PCI, 1, [HOPF PCI clock device?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([HP 58503A GPS receiver])
+AC_ARG_ENABLE(HPGPS,
+    AC_HELP_STRING([--enable-HPGPS], [+ HP 58503A GPS receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_HPGPS, 1, [HP 58503A GPS receiver?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([IRIG audio decoder])
+AC_ARG_ENABLE(IRIG,
+    AC_HELP_STRING([--enable-IRIG], [s IRIG audio decoder]),
+    [ntp_ok=$enableval],
+    [case "$ntp_eac$ntp_canaudio" in
+     *no*)     ntp_ok=no  ;;
+     *)                ntp_ok=yes ;;
+    esac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_IRIG, 1, [IRIG audio decoder?])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canaudio" in
+ yesno) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
+esac
+
+AC_MSG_CHECKING([for JJY receiver])
+AC_ARG_ENABLE(JJY,
+    AC_HELP_STRING([--enable-JJY], [+ JJY receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_JJY, 1, [JJY receiver?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Rockwell Jupiter GPS receiver])
+AC_ARG_ENABLE(JUPITER,
+    AC_HELP_STRING([--enable-JUPITER], [s Rockwell Jupiter GPS receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+case "$ac_cv_var_jupiter_ok" in
+ no) ntp_ok=no ;;
+esac
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_JUPITER, 1, [Rockwell Jupiter GPS clock?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Leitch CSD 5300 Master Clock System Driver])
+AC_ARG_ENABLE(LEITCH,
+    AC_HELP_STRING([--enable-LEITCH], [+ Leitch CSD 5300 Master Clock System Driver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_LEITCH, 1, [Leitch CSD 5300 Master Clock System Driver?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([local clock reference])
+AC_ARG_ENABLE(LOCAL-CLOCK,
+    AC_HELP_STRING([--enable-LOCAL-CLOCK], [+ local clock reference]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_LOCAL, 1, [local clock reference?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+dnl Bug 340: longstanding unfixed bugs
+dnl AC_MSG_CHECKING(EES M201 MSF receiver)
+dnl AC_ARG_ENABLE(MSFEES,
+dnl     AC_HELP_STRING([--enable-MSFEES], [+ EES M201 MSF receiver]),
+dnl     [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+dnl if test "$ntp_ok" = "yes"; then
+dnl     ntp_refclock=yes
+dnl     AC_DEFINE(CLOCK_MSFEES, 1, [EES M201 MSF receiver])
+dnl fi
+dnl AC_MSG_RESULT($ntp_ok)
+
+# Not Ultrix
+AC_MSG_CHECKING([Magnavox MX4200 GPS receiver])
+AC_ARG_ENABLE(MX4200,
+    AC_HELP_STRING([--enable-MX4200 ], [s Magnavox MX4200 GPS receiver]),
+    [ntp_ok=$enableval],
+    [case "$ac_cv_var_ppsclock" in
+     yes) ntp_ok=$ntp_eac
+        ;;
+     *) ntp_ok=no
+        ;;
+    esac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_MX4200, 1, [Magnavox MX4200 GPS receiver])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$host" in
+ yes*-*-ultrix*) AC_MSG_WARN(*** But the expected answer is... no ***) ;;
+esac
+
+AC_MSG_CHECKING([for NeoClock4X receiver])
+AC_ARG_ENABLE(NEOCLOCK4X,
+    AC_HELP_STRING([--enable-NEOCLOCK4X], [+ NeoClock4X DCF77 / TDF receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_NEOCLOCK4X, 1, [NeoClock4X])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([NMEA GPS receiver])
+AC_ARG_ENABLE(NMEA,
+    AC_HELP_STRING([--enable-NMEA], [+ NMEA GPS receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_NMEA, 1, [NMEA GPS receiver])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([for ONCORE Motorola VP/UT Oncore GPS])
+AC_ARG_ENABLE(ONCORE,
+    AC_HELP_STRING([--enable-ONCORE], [s Motorola VP/UT Oncore GPS receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+case "$ac_cv_var_oncore_ok" in
+ no) ntp_ok=no ;;
+esac
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_ONCORE, 1, [Motorola UT Oncore GPS])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([for Palisade clock])
+AC_ARG_ENABLE(PALISADE,
+    AC_HELP_STRING([--enable-PALISADE], [s Palisade clock]),
+    [ntp_ok=$enableval],
+    [case "$ac_cv_header_termios_h" in
+    yes)
+        ntp_ok=$ntp_eac
+        ;;
+    *) ntp_ok=no
+        ;;
+    esac])
+
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_PALISADE, 1, [Palisade clock])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Conrad parallel port radio clock])
+AC_ARG_ENABLE(PCF,
+    AC_HELP_STRING([--enable-PCF ], [+ Conrad parallel port radio clock]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_PCF, 1, [Conrad parallel port radio clock])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([PST/Traconex 1020 WWV/WWVH receiver])
+AC_ARG_ENABLE(PST,
+    AC_HELP_STRING([--enable-PST], [+ PST/Traconex 1020 WWV/WWVH receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_PST, 1, [PST/Traconex 1020 WWV/WWVH receiver])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([RIPENCC specific Trimble driver])
+AC_ARG_ENABLE(RIPENCC,
+    AC_HELP_STRING([--enable-RIPENCC], [- RIPENCC specific Trimble driver]),
+    [ntp_ok=$enableval], [ntp_ok=no])
+# 020629: HMS: s/$ntp_eac -> -/no because of ptr += sprintf(ptr, ...) usage
+case "$ac_cv_var_ripe_ncc_ok" in
+ no) ntp_ok=no ;;
+esac
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_RIPENCC, ,[RIPE NCC Trimble clock])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+# Danny Meyer says SHM compiles (with a few warnings) under Win32.
+# For *IX, we need sys/ipc.h and sys/shm.h.
+AC_MSG_CHECKING([for SHM clock attached thru shared memory])
+AC_ARG_ENABLE(SHM,
+    AC_HELP_STRING([--enable-SHM], [s SHM clock attached thru shared memory]),
+    [ntp_ok=$enableval],
+    [case "$ntp_eac$ntp_canshm" in
+ *no*) ntp_ok=no  ;;
+ *)    ntp_ok=yes ;;
+esac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_SHM, 1, [clock thru shared memory])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Spectracom 8170/Netclock/2 WWVB receiver])
+AC_ARG_ENABLE(SPECTRACOM,
+    AC_HELP_STRING([--enable-SPECTRACOM], [+ Spectracom 8170/Netclock/2 WWVB receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_SPECTRACOM, 1, [Spectracom 8170/Netclock/2 WWVB receiver])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([KSI/Odetics TPRO/S GPS receiver/IRIG interface])
+AC_ARG_ENABLE(TPRO,
+    AC_HELP_STRING([--enable-TPRO], [s KSI/Odetics TPRO/S GPS receiver/IRIG interface]),
+    [ntp_ok=$enableval],
+    [case "$ac_cv_header_sys_tpro_h" in
+     yes)
+       ntp_ok=$ntp_eac
+       ;;
+     *)        ntp_ok=no
+       ;;
+    esac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_TPRO, 1, [KSI/Odetics TPRO/S GPS receiver/IRIG interface])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ac_cv_header_sys_tpro" in
+ yesno) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
+esac
+
+dnl Bug 342: longstanding unfixed bugs
+dnl AC_MSG_CHECKING(TRAK 8810 GPS receiver)
+dnl AC_ARG_ENABLE(TRAK,
+dnl     AC_HELP_STRING([--enable-TRAK], [+ TRAK 8810 GPS receiver]),
+dnl     [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+dnl if test "$ntp_ok" = "yes"; then
+dnl     ntp_refclock=yes
+dnl     AC_DEFINE(CLOCK_TRAK, 1, [TRAK 8810 GPS receiver])
+dnl fi
+dnl AC_MSG_RESULT($ntp_ok)
+
+# Not on a vax-dec-bsd
+AC_MSG_CHECKING([Kinemetrics/TrueTime receivers])
+AC_ARG_ENABLE(TRUETIME,
+    AC_HELP_STRING([--enable-TRUETIME], [s Kinemetrics/TrueTime receivers]),
+    [ntp_ok=$enableval],
+    [case "$host" in
+     vax-dec-bsd)
+       ntp_ok=no
+       ;;
+     *)
+       ntp_ok=$ntp_eac
+       ;;
+    esac])
+    
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_TRUETIME, 1, [Kinemetrics/TrueTime receivers])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$host" in
+ yesvax-dec-bsd) AC_MSG_WARN([*** But the expected answer is... no ***]) ;;
+esac
+
+AC_MSG_CHECKING([TrueTime 560 IRIG-B decoder])
+AC_ARG_ENABLE(TT560,
+    AC_HELP_STRING([--enable-TT560], [- TrueTime 560 IRIG-B decoder]),
+    [ntp_ok=$enableval], [ntp_ok=no])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_TT560, , [TrueTime 560 IRIG-B decoder?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([Ultralink M320 WWVB receiver])
+AC_ARG_ENABLE(ULINK,
+    AC_HELP_STRING([--enable-ULINK], [+ Ultralink WWVB receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_ULINK, 1, [Ultralink M320 WWVB receiver?])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([WWV receiver])
+AC_ARG_ENABLE(WWV,
+    AC_HELP_STRING([--enable-WWV], [s WWV Audio receiver]),
+    [ntp_ok=$enableval],
+    [case "$ntp_eac$ntp_canaudio" in
+     *no*)     ntp_ok=no  ;;
+     *)                ntp_ok=yes ;;
+    esac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_WWV, 1, [WWV audio driver])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canaudio" in
+ yesno) AC_MSG_WARN(*** But the expected answer is... no ***) ;;
+esac
+
+AC_MSG_CHECKING([for Zyfer receiver])
+AC_ARG_ENABLE(ZYFER,
+    AC_HELP_STRING([--enable-ZYFER], [+ Zyfer GPStarplus receiver]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+if test "$ntp_ok" = "yes"; then
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_ZYFER, 1, [Zyfer GPStarplus])
+fi
+AC_MSG_RESULT($ntp_ok)
+
+AC_MSG_CHECKING([for default inclusion of all suitable PARSE clocks])
+AC_ARG_ENABLE(parse-clocks,
+   AC_HELP_STRING([--enable-parse-clocks], [- include all suitable PARSE clocks:]),
+    [ntp_eapc=$enableval],
+    [case "$ntp_eac" in
+     yes) ntp_eapc=$ntp_canparse ;;
+     *) ntp_eapc=no ;;
+    esac
+    # Delete the next line one of these days
+    ntp_eapc=no])
+AC_MSG_RESULT($ntp_eapc)
+
+case "$ntp_eac$ntp_eapc$ntp_canparse" in
+ noyes*)
+    AC_MSG_ERROR(["--enable-parse-clocks" requires "--enable-all-clocks".])
+    ;;
+ yesyesno)
+    AC_MSG_ERROR([You said "--enable-parse-clocks" but PARSE isn't supported on this platform!])
+    ;;
+ *) ;;
+esac
+
+ntp_libparse=no
+ntp_parseutil=no
+ntp_rawdcf=no
+
+AC_MSG_CHECKING([Diem Computime Radio Clock])
+AC_ARG_ENABLE(COMPUTIME,
+    AC_HELP_STRING([--enable-COMPUTIME], [s Diem Computime Radio Clock]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_COMPUTIME, 1, [Diems Computime Radio Clock?])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
+    ;;
+esac
+
+AC_MSG_CHECKING([ELV/DCF7000 clock])
+AC_ARG_ENABLE(DCF7000,
+    AC_HELP_STRING([--enable-DCF7000], [s ELV/DCF7000 clock]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_DCF7000, 1, [ELV/DCF7000 clock?])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
+    ;;
+esac
+
+AC_MSG_CHECKING([HOPF 6021 clock])
+AC_ARG_ENABLE(HOPF6021,
+    AC_HELP_STRING([--enable-HOPF6021 ], [s HOPF 6021 clock]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_HOPF6021, 1, [HOPF 6021 clock?])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
+    ;;
+esac
+
+AC_MSG_CHECKING([Meinberg clocks])
+AC_ARG_ENABLE(MEINBERG,
+    AC_HELP_STRING([--enable-MEINBERG], [s Meinberg clocks]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_MEINBERG, 1, [Meinberg clocks])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
+    ;;
+esac
+
+AC_MSG_CHECKING([DCF77 raw time code])
+AC_ARG_ENABLE(RAWDCF,
+    AC_HELP_STRING([--enable-RAWDCF], [s DCF77 raw time code]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_parseutil=yes
+    ntp_refclock=yes
+    ntp_rawdcf=yes
+    AC_DEFINE(CLOCK_RAWDCF, 1, [DCF77 raw time code])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
+    ;;
+esac
+
+case "$ntp_rawdcf" in
+ yes)
+    AC_CACHE_CHECK([if we must enable parity for RAWDCF],
+    ac_cv_var_rawdcf_parity,
+    [ans=no
+    case "$host" in
+     *-*-*linux*)
+        ans=yes
+        ;;
+    esac
+    ac_cv_var_rawdcf_parity=$ans])
+    case "$ac_cv_var_rawdcf_parity" in
+     yes) AC_DEFINE(RAWDCF_NO_IGNPAR, 1, [Should we not IGNPAR (Linux)?]) ;;
+    esac
+    ;;
+
+ *) # HMS: Is this a good idea?
+    ac_cv_var_rawdcf_parity=no
+    ;;
+esac
+
+AC_MSG_CHECKING([RCC 8000 clock])
+AC_ARG_ENABLE(RCC8000,
+    AC_HELP_STRING([--enable-RCC8000], [s RCC 8000 clock]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_RCC8000, 1, [RCC 8000 clock])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
+    ;;
+esac
+
+AC_MSG_CHECKING([Schmid DCF77 clock])
+AC_ARG_ENABLE(SCHMID,
+    AC_HELP_STRING([--enable-SCHMID ], [s Schmid DCF77 clock]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_SCHMID, 1, [Schmid DCF77 clock])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
+    ;;
+esac
+
+AC_MSG_CHECKING([Trimble GPS receiver/TAIP protocol])
+AC_ARG_ENABLE(TRIMTAIP,
+    AC_HELP_STRING([--enable-TRIMTAIP], [s Trimble GPS receiver/TAIP protocol]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_TRIMTAIP, 1, [Trimble GPS receiver/TAIP protocol])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
+    ;;
+esac
+
+AC_MSG_CHECKING([Trimble GPS receiver/TSIP protocol])
+AC_ARG_ENABLE(TRIMTSIP,
+    AC_HELP_STRING([--enable-TRIMTSIP], [s Trimble GPS receiver/TSIP protocol]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_TRIMTSIP, 1, [Trimble GPS receiver/TSIP protocol])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
+    ;;
+esac
+
+AC_MSG_CHECKING([WHARTON 400A Series clock])
+AC_ARG_ENABLE(WHARTON,
+    AC_HELP_STRING([--enable-WHARTON], [s WHARTON 400A Series clock]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_WHARTON_400A, 1, [WHARTON 400A Series protocol])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR(That's a parse clock and this system doesn't support it!)
+    ;;
+esac
+
+AC_MSG_CHECKING([VARITEXT clock])
+AC_ARG_ENABLE(VARITEXT,
+    AC_HELP_STRING([--enable-VARITEXT], [s VARITEXT clock]),
+    [ntp_ok=$enableval], [ntp_ok=$ntp_eapc])
+if test "$ntp_ok" = "yes"; then
+    ntp_libparse=yes
+    ntp_refclock=yes
+    AC_DEFINE(CLOCK_VARITEXT, 1, [VARITEXT protocol])
+fi
+AC_MSG_RESULT($ntp_ok)
+case "$ntp_ok$ntp_canparse" in
+ yesno)
+    AC_MSG_ERROR([That's a parse clock and this system doesn't support it!])
+    ;;
+esac
+AC_SUBST(LIBPARSE)
+AC_SUBST(MAKE_LIBPARSE)
+AC_SUBST(MAKE_LIBPARSE_KERNEL)
+AC_SUBST(MAKE_CHECK_Y2K)
+AC_MSG_CHECKING([if we need to make and use the parse libraries])
+ans=no
+case "$ntp_libparse" in
+ yes)
+    ans=yes
+    AC_DEFINE(CLOCK_PARSE, 1, [PARSE driver interface])
+    LIBPARSE=../libparse/libparse.a
+    MAKE_LIBPARSE=libparse.a
+    # HMS: check_y2k trips the 34 year problem now...
+    false && MAKE_CHECK_Y2K=check_y2k
+    AC_DEFINE(PPS_SAMPLE, 1, [PPS auxiliary interface for ATOM?])
+    AC_DEFINE(CLOCK_ATOM)
+    ;;
+esac
+AC_MSG_RESULT([$ans])
+
+# AC_SUBST(RSAOBJS)
+# AC_SUBST(RSASRCS)
+# AC_SUBST(RSADIR)
+# AC_SUBST(RSAREF)
+# AC_SUBST(LIBRSAREF)
+# AC_SUBST(MAKE_LIBRSAREF)
+
+AC_SUBST(OPENSSL)
+AC_SUBST(OPENSSL_INC)
+AC_SUBST(OPENSSL_LIB)
+
+AC_MSG_CHECKING([for openssl library directory])
+AC_ARG_WITH(openssl-libdir,
+       AC_HELP_STRING([--with-openssl-libdir], [+ =/something/reasonable]),
+[ans=$withval],
+[case "$build" in
+ $host) ans=yes ;;
+ *)     ans=no ;;
+esac])
+case "$ans" in
+ no) ;;
+ yes) # Look in:
+    ans="/usr/lib /usr/lib/openssl /usr/sfw/lib /usr/local/lib /usr/local/ssl/lib"
+    ;;
+ *) # Look where they said
+    ;;
+esac
+case "$ans" in
+ no) ;;
+ *) # Look for libcrypto.a and libssl.a:
+    for i in $ans no
+    do
+       case "$host" in
+        *-*-darwin*)
+           test -f $i/libcrypto.dylib -a -f $i/libssl.dylib && break
+           ;;
+        *)
+           test -f $i/libcrypto.so -a -f $i/libssl.so && break
+           test -f $i/libcrypto.a -a -f $i/libssl.a && break
+           ;;
+       esac
+    done
+    case "$i" in
+     no)
+       ans=no
+       OPENSSL_LIB=
+       ;;
+     *) ans=$i
+       OPENSSL_LIB=$ans
+       ;;
+    esac
+    ;;
+esac
+AC_MSG_RESULT([$ans])
+
+AC_MSG_CHECKING([for openssl include directory])
+AC_ARG_WITH(openssl-incdir,
+       AC_HELP_STRING([--with-openssl-incdir], [+ =/something/reasonable]),
+[ans=$withval],
+[case "$build" in
+ $host) ans=yes ;;
+ *)     ans=no ;;
+esac])
+case "$ans" in
+ no) ;;
+ yes) # look in:
+    ans="/usr/include /usr/sfw/include /usr/local/include /usr/local/ssl/include"
+    ;;
+ *) # Look where they said
+    ;;
+esac
+case "$ans" in
+ no) ;;
+ *) # look for openssl/opensslconf.h:
+    for i in $ans no
+    do
+       test -f $i/openssl/opensslconf.h && break
+    done
+    case "$i" in
+     no)
+       ans=no
+       OPENSSL_INC=
+       ;;
+     *) ans=$i
+       OPENSSL_INC=$ans
+       ;;
+    esac
+    ;;
+esac
+AC_MSG_RESULT([$ans])
+
+AC_ARG_WITH(crypto,
+       AC_HELP_STRING([--with-crypto], [+ =openssl]),
+[ans=$withval], [ans=yes])
+case "$ans" in
+ no) ;;
+ yes|openssl)
+    if test -z "$OPENSSL_LIB" -o -z "$OPENSSL_INC"
+    then
+       ans=no
+    else
+       # We have OpenSSL inc/lib - use them.
+       ans=openssl
+       CPPFLAGS="$CPPFLAGS -I$OPENSSL_INC"
+       LDFLAGS="$LDFLAGS -L$OPENSSL_LIB"
+       case "$need_dash_r" in
+        1) LDFLAGS="$LDFLAGS -R$OPENSSL_LIB"
+           ;;
+       esac
+       AC_SUBST(LCRYPTO, [-lcrypto])
+       AC_DEFINE(OPENSSL, , [Use OpenSSL?])
+       AC_CHECK_FUNCS(EVP_md2 EVP_mdc2)
+    fi
+    ;;
+esac
+AC_MSG_CHECKING(for the level of crypto support)
+AC_MSG_RESULT([$ans])
+
+AC_MSG_CHECKING([if we want to compile with ElectricFence])
+AC_ARG_WITH(electricfence,
+       AC_HELP_STRING([--with-electricfence], [- compile with ElectricFence malloc debugger]),
+[ans=$withval], [ans=no])
+case "$ans" in
+ no) ;;
+ *)
+    LIBS="$LIBS \${top_builddir}/ElectricFence/libefence.a"
+    EF_PROGS="eftest tstheap"
+    AC_SUBST(EF_PROGS)
+    EF_LIBS=libefence.a
+    AC_SUBST(EF_LIBS)
+    ans=yes
+    ;;
+esac
+AC_MSG_RESULT([$ans])
+
+AC_SUBST(MAKE_CHECK_LAYOUT)
+AC_MSG_CHECKING([if we want to run check-layout])
+case "$cross_compiling$PATH_PERL" in
+ no/*)
+    MAKE_CHECK_LAYOUT=check-layout
+    ans=yes
+    ;;
+ *)
+    ans=no
+    ;;
+esac
+AC_MSG_RESULT([$ans])
+
+AC_SUBST(TESTDCF)
+AC_SUBST(DCFD)
+
+AC_MSG_CHECKING([if we can make dcf parse utilities])
+ans=no
+if test "$ntp_parseutil" = "yes"; then
+    case "$host" in
+     *-*-sunos4*|*-*-solaris2*|*-*-*linux*|*-*-netbsd*)
+       ans="dcfd testdcf"
+       DCFD=dcfd
+        TESTDCF=testdcf
+       ;;
+    esac
+fi
+AC_MSG_RESULT([$ans])
+
+AC_SUBST(MAKE_PARSEKMODULE)
+AC_MSG_CHECKING([if we can build kernel streams modules for parse])
+ans=no
+case "$ntp_parseutil$ac_cv_header_sys_stropts_h" in
+ yesyes)
+    case "$host" in
+     sparc-*-sunos4*)
+        case "$ac_cv_var_kernel_pll" in
+       yes)
+           AC_DEFINE(PPS_SYNC, 1, [PARSE kernel PLL PPS support])
+           ;;
+       esac
+       ans=parsestreams
+       MAKE_PARSEKMODULE=parsestreams.loadable_module.o
+       ;;
+     sparc-*-solaris2*)
+       ans=parsesolaris
+       MAKE_PARSEKMODULE=parse
+       ;;
+    esac
+    ;;
+esac
+AC_MSG_RESULT([$ans])
+
+AC_MSG_CHECKING([if we need basic refclock support])
+if test "$ntp_refclock" = "yes"; then
+    AC_DEFINE(REFCLOCK, 1, [Basic refclock support?])
+fi
+AC_MSG_RESULT($ntp_refclock)
+
+dnl Things that can be made in clockstuff/
+AC_SUBST(PROPDELAY)    dnl Set to "propdelay"
+AC_SUBST(CHUTEST)      dnl Set to "chutest"
+AC_SUBST(CLKTEST)      dnl Set to "clktest"
+
+AC_SUBST(MAKE_ADJTIMED)
+AC_MSG_CHECKING(if we want HP-UX adjtimed support)
+case "$host" in
+ *-*-hpux[[56789]]*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+if test "$ans" = "yes"; then
+    MAKE_ADJTIMED=adjtimed
+    AC_DEFINE(NEED_HPUX_ADJTIME, 1, [Do we need HPUX adjtime() library support?])
+fi
+AC_MSG_RESULT([$ans])
+
+AC_MSG_CHECKING([if we want QNX adjtime support])
+case "$host" in
+ *-*-qnx*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+if test "$ans" = "yes"; then
+    AC_DEFINE(NEED_QNX_ADJTIME, 1, [Do we need the qnx adjtime call?])
+fi
+AC_MSG_RESULT([$ans])
+
+AC_MSG_CHECKING([if we can read kmem])
+
+#  the default is to enable it if the system has the capability
+
+case "$ac_cv_func_nlist$ac_cv_func_K_open$ac_cv_func_kvm_open" in
+ *yes*)
+    ans=yes
+    ;;
+ *) ans=no
+esac
+
+case "$host" in
+ *-*-domainos) # Won't be found...
+    ans=no
+    ;;
+ *-*-hpux*)
+    #ans=no
+    ;;
+ *-*-irix[[456]]*)
+    ans=no
+    ;;
+ *-*-*linux*)
+    ans=no
+    ;;
+ *-*-winnt3.5)
+    ans=no
+    ;;
+ *-*-unicosmp*)
+    ans=no
+    ;;
+esac
+
+# --enable-kmem / --disable-kmem controls if present
+AC_ARG_ENABLE(
+    [kmem],
+    AC_HELP_STRING(
+       [--enable-kmem],
+       [s read /dev/kmem for tick and/or tickadj]
+    ),
+    [ans=$enableval]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ yes)
+    can_kmem=yes
+    ;;
+ *) 
+    can_kmem=no
+    AC_DEFINE(NOKMEM, 1, [Should we NOT read /dev/kmem?])
+esac
+
+
+AC_MSG_CHECKING([if adjtime is accurate])
+
+# target-dependent defaults
+
+case "$host" in
+ i386-sequent-ptx*)
+    ans=no
+    ;;
+ i386-unknown-osf1*)
+    ans=yes
+    ;;
+ mips-sgi-irix[[456]]*)
+    ans=yes
+    ;;
+ *-fujitsu-uxp*)
+    ans=yes
+    ;;
+ *-ibm-aix[[456]]*)
+    ans=yes
+    ;;
+ *-*-*linux*)
+    ans=yes
+    ;;
+ *-*-solaris2.[[01]])
+    ans=no
+    ;;
+ *-*-solaris2*)
+    ans=yes
+    ;;
+ *-*-unicosmp*)
+    ans=yes
+    ;;
+ *) ans=no
+esac
+
+# --enable-accurate-adjtime / --disable-accurate-adjtime
+# override the default
+AC_ARG_ENABLE([accurate-adjtime],
+    AC_HELP_STRING(
+        [--enable-accurate-adjtime], 
+        [s the adjtime() call is accurate]
+    ),
+    [ans=$enableval],
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ yes) 
+    AC_DEFINE(ADJTIME_IS_ACCURATE, 1, [Is adjtime() accurate?])
+    adjtime_is_accurate=yes
+    ;;
+ *)
+    adjtime_is_accurate=no
+esac
+
+AC_CACHE_CHECK([the name of 'tick' in the kernel],
+ac_cv_var_nlist_tick,
+[ans=_tick
+case "$host" in
+ m68*-hp-hpux*) # HP9000/300?
+    ans=_old_tick
+    ;;
+ *-apple-aux[[23]]*)
+    ans=tick
+    ;;
+ *-hp-hpux*)
+    ans=old_tick
+    ;;
+ *-ibm-aix[[3456]]*)
+    ans=no
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-ptx*)
+    ans=tick
+    ;;
+ *-*-sco3.2v[[45]]*)
+    ans=no
+    ;;
+ *-*-solaris2*)
+    ans=nsec_per_tick
+    ;;
+ *-*-sysv4*)
+    ans=tick
+    ;;
+esac
+ac_cv_var_nlist_tick=$ans])
+case "$ac_cv_var_nlist_tick" in
+ ''|no) ;;     # HMS: I think we can only get 'no' here...
+ *) AC_DEFINE_UNQUOTED(K_TICK_NAME, "$ac_cv_var_nlist_tick", [What is the name of TICK in the kernel?]) ;;
+esac
+#
+AC_CACHE_CHECK([for the units of 'tick'],
+ac_cv_var_tick_nano,
+[ans=usec
+case "$host" in
+ *-*-solaris2*)
+    ans=nsec
+    ;;
+esac
+ac_cv_var_tick_nano=$ans])
+case "$ac_cv_var_tick_nano" in
+ nsec)
+    AC_DEFINE(TICK_NANO, 1, [Is K_TICK_NAME in nanoseconds?])
+    ;;
+esac
+#
+AC_CACHE_CHECK([the name of 'tickadj' in the kernel],
+ac_cv_var_nlist_tickadj,
+[ans=_tickadj
+case "$host" in
+ m68*-hp-hpux*) # HP9000/300?
+    ans=_tickadj
+    ;;
+ *-apple-aux[[23]]*)
+    ans=tickadj
+    ;;
+ *-hp-hpux10*)
+    ans=no
+    ;;
+ *-hp-hpux9*)
+    ans=no
+    ;;
+ *-hp-hpux*)
+    ans=tickadj
+    ;;
+ *-*-aix*)
+    ans=tickadj
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-ptx*)
+    ans=tickadj
+    ;;
+ *-*-sco3.2v4*)
+    ans=no
+    ;;
+ *-*-sco3.2v5.0*)
+    ans=clock_drift
+    ;;
+ *-*-solaris2*)
+    ans=no     # hrestime_adj
+    ;;
+ *-*-sysv4*)
+    ans=tickadj
+    ;;
+esac
+ac_cv_var_nlist_tickadj=$ans])
+case "$ac_cv_var_nlist_tickadj" in
+ ''|no) ;;     # HMS: I think we can only get 'no' here...
+ *) AC_DEFINE_UNQUOTED(K_TICKADJ_NAME, "$ac_cv_var_nlist_tickadj", [What is the name of TICKADJ in the kernel?]) ;;
+esac
+#
+AC_CACHE_CHECK([for the units of 'tickadj'],
+ac_cv_var_tickadj_nano,
+[ans=usec
+case "$host" in
+ *-*-solaris2*)
+    ans=nsec
+    ;;
+esac
+ac_cv_var_tickadj_nano=$ans])
+case "$ac_cv_var_tickadj_nano" in
+ nsec)
+    AC_DEFINE(TICKADJ_NANO, 1, [Is K_TICKADJ_NAME in nanoseconds?])
+    ;;
+esac
+#
+AC_CACHE_CHECK([half-heartedly for 'dosynctodr' in the kernel],
+ac_cv_var_nlist_dosynctodr,
+[case "$host" in
+ *-apple-aux[[23]]*)
+    ans=no
+    ;;
+ *-sni-sysv*)
+    ans=dosynctodr
+    ;;
+ *-*-aix*)
+    ans=dosynctodr
+    ;;
+ *-*-hpux*)
+    ans=no
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-nextstep*)
+    ans=_dosynctodr
+    ;;
+ *-*-ptx*)
+    ans=doresettodr
+    ;;
+ *-*-sco3.2v4*)
+    ans=no
+    ;;
+ *-*-sco3.2v5*)
+    ans=track_rtc
+    ;;
+ *-*-solaris2*)
+    ans=dosynctodr
+    ;;
+ *-*-sysv4*)
+    ans=doresettodr
+    ;;
+ *)
+    ans=_dosynctodr
+    ;;
+esac
+ac_cv_var_nlist_dosynctodr=$ans])
+case "$ac_cv_var_nlist_dosynctodr" in
+ no) ;;
+ *)  AC_DEFINE_UNQUOTED(K_DOSYNCTODR_NAME, "$ac_cv_var_nlist_dosynctodr", [What is (probably) the name of DOSYNCTODR in the kernel?])
+     ;;
+esac
+#
+AC_CACHE_CHECK([half-heartedly for 'noprintf' in the kernel],
+ac_cv_var_nlist_noprintf,
+[case "$host" in
+ *-apple-aux[[23]]*)
+    ans=no
+    ;;
+ *-sni-sysv*)
+    ans=noprintf
+    ;;
+ *-*-aix*)
+    ans=noprintf
+    ;;
+ *-*-hpux*)
+    ans=no
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-ptx*)
+    ans=noprintf
+    ;;
+ *-*-nextstep*)
+    ans=_noprintf
+    ;;
+ *-*-solaris2*)
+    ans=noprintf
+    ;;
+ *-*-sysv4*)
+    ans=noprintf
+    ;;
+ *)
+    ans=_noprintf
+    ;;
+esac
+ac_cv_var_nlist_noprintf=$ans])
+case "$ac_cv_var_nlist_noprintf" in
+ no) ;;
+ *)  AC_DEFINE_UNQUOTED(K_NOPRINTF_NAME, "$ac_cv_var_nlist_noprintf", [What is (probably) the name of NOPRINTF in the kernel?])
+     ;;
+esac
+
+dnl The tick/tickadj sections were written by Skippy, who never learned
+dnl that it's impolite (horridly gross) to show your guts in public.
+
+dnl    tick            tickadj 
+dnl    10000           80          Unixware
+dnl    1000000L/hz     tick/16     (Solaris,UXPV,HPUX) && ADJTIME_IS_ACCURATE
+dnl    10000           150         sgi IRIX
+dnl    1000000L/hz     1000        RS6000 && NOKMEM
+dnl    1000000L/hz     668         DOMAINOS && NOKMEM
+dnl    1000000L/hz     500/HZ      other && NOKMEM
+dnl    txc.tick        1           Linux
+dnl    (every / 10)    50          WinNT - tickadj is roughly 500/hz
+dnl    1000000L/hz     (nlist)     (Solaris && !ADJTIME_IS_ACCURATE),
+dnl                                (RS6000 && !NOKMEM), SINIX MIPS
+
+dnl But we'll only use these "values" if we can't find anything else.
+
+AC_MSG_CHECKING([for a default value for 'tick'])
+
+# target-dependent default for tick
+
+case "$host" in
+ *-*-pc-cygwin*)
+    AC_MSG_ERROR([tick needs work for cygwin])
+    ;;
+ *-univel-sysv*)
+    ans=10000
+    ;;
+ *-*-irix*)
+    ans=10000
+    ;;
+ *-*-*linux*)
+    ans=txc.tick
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-winnt3.5)
+    ans='(every / 10)'
+    ;;
+ *-*-unicosmp*)
+    ans=10000
+    ;;
+ *)
+    ans='1000000L/hz'
+    ;;
+esac
+
+AC_ARG_ENABLE(
+    [tick],
+    AC_HELP_STRING(
+       [--enable-tick=VALUE],
+       [s force a value for 'tick']
+    ),
+    [ans=$enableval]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ ''|no) ;;     # HMS: I think we can only get 'no' here...
+ *) AC_DEFINE_UNQUOTED(PRESET_TICK, [$ans], [Preset a value for 'tick'?]) ;;
+esac
+
+
+AC_MSG_CHECKING([for a default value for 'tickadj'])
+
+# target-specific default
+
+ans='500/hz'
+
+case "$host" in
+ *-fujitsu-uxp*)
+    case "$adjtime_is_accurate" in
+     yes)
+         ans='tick/16'
+    esac
+    ;;
+ XXX-*-pc-cygwin*)
+    ans=no
+    ;;
+ *-univel-sysv*)
+    ans=80
+    ;;
+ *-*-aix*)
+    case "$can_kmem" in
+     no)
+       ans=1000
+    esac
+    ;;
+ *-*-domainos) # Skippy: won't be found...
+    case "$can_kmem" in
+     no)
+       ans=668
+    esac
+    ;;
+ *-*-hpux*)
+    case "$adjtime_is_accurate" in
+     yes)
+       ans='tick/16'
+    esac
+    ;;
+ *-*-irix*)
+    ans=150
+    ;;
+ *-*-mpeix*)
+    ans=no
+    ;;
+ *-*-sco3.2v5.0*)
+    ans=10000L/hz
+    ;;
+ *-*-winnt3.5)
+    ans=50
+    ;;
+ *-*-unicosmp*)
+    ans=150
+esac
+
+AC_ARG_ENABLE(
+    [tickadj],
+    AC_HELP_STRING(
+        [--enable-tickadj=VALUE],
+        [s force a value for 'tickadj']
+    ),
+    [ans=$enableval]
+)
+
+AC_MSG_RESULT([$ans])
+
+default_tickadj=$ans
+
+case "$default_tickadj" in
+ ''|no) ;;     # HMS: I think we can only get 'no' here...
+ *) AC_DEFINE_UNQUOTED(PRESET_TICKADJ, $default_tickadj, [Preset a value for 'tickadj'?]) ;;
+esac
+
+# Newer versions of ReliantUNIX round adjtime() values down to
+# 1/100s (system tick). Sigh ...
+# Unfortunately, there is no easy way to know if particular release
+# has this "feature" or any obvious way to test for it.
+case "$host" in
+ mips-sni-sysv4*) AC_DEFINE(RELIANTUNIX_CLOCK, 1, [Do we want the ReliantUNIX clock hacks?]) ;;
+esac
+
+case "$host" in
+ *-*-sco3.2v5*) AC_DEFINE(SCO5_CLOCK, 1, [Do we want the SCO clock hacks?]) ;;
+esac
+
+ac_cv_make_tickadj=yes
+case "$can_kmem$ac_cv_var_tick$default_tickadj" in
+ nonono)       # Don't read KMEM, no presets.  Bogus.
+    AC_MSG_WARN([Can't read kmem, no PRESET_TICK or PRESET_TICKADJ.  No tickadj.])
+    ac_cv_make_tickadj=no
+    ;;
+ nono*)                # Don't read KMEM, no PRESET_TICK but PRESET_TICKADJ.  Bogus.
+    AC_MSG_WARN([Can't read kmem but no PRESET_TICK.  No tickadj.])
+    ac_cv_make_tickadj=no
+    ;;
+ no*no)                # Don't read KMEM, PRESET_TICK but no PRESET_TICKADJ.  Bogus.
+    AC_MSG_WARN([Can't read kmem but no PRESET_TICKADJ.  No tickadj.])
+    ac_cv_make_tickadj=no
+    ;;
+ no*)          # Don't read KMEM, PRESET_TICK and PRESET_TICKADJ.  Cool.
+    ;;
+ yesnono)      # Read KMEM, no presets.  Cool.
+    ;;
+ yesno*)       # Read KMEM, no PRESET_TICK but PRESET_TICKADJ.  Bogus.
+    AC_MSG_WARN([PRESET_TICKADJ is defined but not PRESET_TICK.  Please report this.])
+    ;;
+ yes*no)       # Read KMEM, PRESET_TICK but no PRESET_TICKADJ.  Cool.
+    ;;
+ yes*)         # READ KMEM, PRESET_TICK and PRESET_TICKADJ.
+    ;;
+ *)            # Generally bogus.
+    AC_MSG_ERROR([This shouldn't happen.])
+    ;;
+esac
+
+AC_SUBST(MAKE_NTPTIME)
+AC_CACHE_CHECK([if we want and can make the ntptime utility], ac_cv_make_ntptime,
+[case "$host" in
+ *) case "$ac_cv_struct_ntptimeval$ac_cv_var_kernel_pll" in
+     yesyes)
+       ans=yes
+       ;;
+     *)
+       ans=no
+       ;;
+    esac
+    ;;
+esac
+ac_cv_make_ntptime=$ans])
+case "$ac_cv_make_ntptime" in
+ yes)
+    MAKE_NTPTIME=ntptime
+    ;;
+esac
+
+AC_SUBST(MAKE_TICKADJ)
+case "$host" in
+ mips-sni-sysv4*)
+    # tickadj is pretty useless on newer versions of ReliantUNIX
+    # Do not bother
+    ac_cv_make_tickadj=no
+    ;;
+ *-*-irix*)
+    ac_cv_make_tickadj=no
+    ;;
+ *-*-solaris2*)
+    # DLM says tickadj is a no-no starting with solaris2.5
+    case "$host" in
+     *-*-solaris2.1[[0-9]]*)
+       ac_cv_make_tickadj=no
+       ;;
+     *-*-solaris2.[[0-4]]*) ;;
+     *) ac_cv_make_tickadj=no ;;
+    esac
+    ;;
+ *-*-unicosmp*)
+    ac_cv_make_tickadj=no
+    ;;
+esac
+
+#
+# Despite all the above, we always make tickadj.  Setting
+# ac_cv_make_tickadj before AC_CACHE_CHECK will cause a false
+# report that the configuration variable was cached.  It may
+# be better to simply remove the hunk above, I did not want
+# to remove it if there is hope it will be used again.
+#
+unset ac_cv_make_tickadj
+
+AC_CACHE_CHECK([if we want and can make the tickadj utility], ac_cv_make_tickadj,
+ac_cv_make_tickadj=yes)
+case "$ac_cv_make_tickadj" in
+ yes)
+    MAKE_TICKADJ=tickadj
+    ;;
+esac
+
+AC_SUBST(MAKE_TIMETRIM)
+AC_CACHE_CHECK([if we want and can make the timetrim utility], ac_cv_make_timetrim,
+[case "$host" in
+ *-*-irix*)
+    ac_cv_make_timetrim=yes
+    ;;
+ *-*-unicosmp*)
+    ac_cv_make_timetrim=yes
+    ;;
+ *)
+    ac_cv_make_timetrim=no
+    ;;
+esac])
+case "$ac_cv_make_timetrim" in
+ yes)
+    MAKE_TIMETRIM=timetrim
+    ;;
+esac
+
+AC_SUBST(MAKE_LIBNTPSIM)
+AC_SUBST(MAKE_NTPDSIM)
+
+AC_MSG_CHECKING([if we want to build the NTPD simulator])
+
+AC_ARG_ENABLE(
+    [simulator],
+    AC_HELP_STRING(
+       [--enable-simulator],
+       [- build/install the NTPD simulator?]
+    ),
+    [ans=$enableval], 
+    [ans=no]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ yes)
+    MAKE_NTPDSIM=ntpdsim
+    MAKE_LIBNTPSIM=libntpsim.a
+    ;;
+esac
+
+case "$build" in
+ $host)
+    ;;
+ *) case "$host" in
+     *-*-vxworks*)
+       LDFLAGS="$LDFLAGS -r"
+       ;;
+    esac
+    ;;
+esac
+
+
+AC_MSG_CHECKING([if we should always slew the time])
+
+# target-specific defaults
+
+case "$host" in
+ *-apple-aux[[23]]*)
+    ans=yes
+    ;;
+ *-*-bsdi[[012]]*)
+    ans=no
+    ;;
+ *-*-bsdi*)
+    ans=yes
+    ;;
+ *-*-openvms*) # HMS: won't be found
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+
+# --enable-slew-always / --disable-slew-always overrides default
+
+AC_ARG_ENABLE(
+    [slew-always],
+    AC_HELP_STRING(
+       [--enable-slew-always],
+       [s always slew the time]
+    ),
+    [ans=$enableval]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ yes) AC_DEFINE(SLEWALWAYS, 1, [Slew always?]) ;;
+esac
+
+AC_MSG_CHECKING([if we should step and slew the time])
+
+case "$host" in
+ *-sni-sysv*)
+    ans=yes
+    ;;
+ *-univel-sysv*)
+    ans=no
+    ;;
+ *-*-ptx*)
+    ans=yes
+    ;;
+ *-*-solaris2.1[[0-9]]*)
+    ans=no
+    ;;
+ *-*-solaris2.[[012]]*)
+    ans=yes
+    ;;
+ *-*-sysv4*)   # HMS: Does this catch Fujitsu UXP?
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+
+
+AC_ARG_ENABLE(
+    [step-slew],
+    AC_HELP_STRING(
+       [--enable-step-slew],
+       [s step and slew the time]
+    ),
+    [ans=$enableval]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ yes) AC_DEFINE(STEP_SLEW, 1, [Step, then slew the clock?]) ;;
+esac
+
+AC_MSG_CHECKING([if ntpdate should step the time])
+
+case "$host" in
+ *-apple-aux[[23]]*)
+    ans=yes
+    ;;
+ *) ans=no
+esac
+
+AC_ARG_ENABLE(
+    [ntpdate-step],
+    AC_HELP_STRING(
+       [--enable-ntpdate-step],
+       [s if ntpdate should step the time]
+    ),
+    [ans=$enableval]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ yes) AC_DEFINE(FORCE_NTPDATE_STEP, 1, [force ntpdate to step the clock if !defined(STEP_SLEW) ?]) ;;
+esac
+
+
+AC_MSG_CHECKING([if we should sync TODR clock every hour])
+
+case "$host" in
+ *-*-nextstep*)
+    ans=yes
+    ;;
+ *-*-openvms*) # HMS: won't be found
+    ans=yes
+    ;;
+ *)
+    ans=no
+esac
+
+AC_ARG_ENABLE(
+    [hourly-todr-sync],
+    AC_HELP_STRING(
+       [--enable-hourly-todr-sync],
+       [s if we should sync TODR hourly]
+    ),
+    [ans=$enableval]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ac_cv_var_sync_todr" in
+ yes) AC_DEFINE(DOSYNCTODR, 1, [synch TODR hourly?]) ;;
+esac
+
+
+AC_MSG_CHECKING([if we should avoid kernel FLL bug])
+
+case "$host" in
+ *-*-solaris2.6)
+    unamev=`uname -v`
+    case "$unamev" in
+     Generic_105181-*)
+       old_IFS="$IFS"
+       IFS="-"
+       set $unamev
+       IFS="$old_IFS"
+       if test "$2" -ge 17
+       then
+           # Generic_105181-17 and higher
+           ans=no
+       else
+           ans=yes
+       fi
+       ;;
+     *) 
+       ans=yes
+    esac
+    ;;
+ *-*-solaris2.7)
+    unamev=`uname -v`
+    case "$unamev" in
+     Generic_106541-*)
+       old_IFS="$IFS"
+       IFS="-"
+       set $unamev
+       IFS="$old_IFS"
+       if test "$2" -ge 07
+       then
+           # Generic_106541-07 and higher
+           ans=no
+       else
+           ans=yes
+       fi
+       ;;
+     *)
+       ans=yes
+    esac
+    ;;
+ *)
+    ans=no
+esac
+
+AC_ARG_ENABLE(
+    [kernel-fll-bug],
+    AC_HELP_STRING(
+       [--enable-kernel-fll-bug],
+       [s if we should avoid a kernel FLL bug]
+    ),
+    [ans=$enableval]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ yes) AC_DEFINE(KERNEL_FLL_BUG, 1, [Does the kernel have an FLL bug?]) ;;
+esac
+
+
+AC_MSG_CHECKING([if we should use the IRIG sawtooth filter])
+
+case "$host" in
+ *-*-solaris2.[[89]])
+    ans=yes
+    ;;
+ *-*-solaris2.1[[0-9]]*)
+    ans=yes
+    ;;
+ *) ans=no
+esac
+
+AC_ARG_ENABLE(
+    [irig-sawtooth], 
+    AC_HELP_STRING(
+       [--enable-irig-sawtooth],
+       [s if we should enable the IRIG sawtooth filter]
+    ),
+    [ans=$enableval]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ yes) AC_DEFINE(IRIG_SUCKS, 1, [Should we use the IRIG sawtooth filter?]) ;;
+esac
+
+
+AC_MSG_CHECKING([if we should enable NIST lockclock scheme])
+
+AC_ARG_ENABLE(
+       [nist], 
+       AC_HELP_STRING(
+           [--enable-nist],
+           [- if we should enable the NIST lockclock scheme]
+       ),
+       [ans=$enableval],
+       [ans=no]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ yes) AC_DEFINE(LOCKCLOCK, 1, [Should we align with the NIST lockclock scheme?]) ;;
+esac
+
+
+AC_MSG_CHECKING([if we want support for Samba's signing daemon])
+
+AC_ARG_ENABLE(
+    [ntp-signd],
+    AC_HELP_STRING(
+        [--enable-ntp-signd],
+        [- Provide support for Samba's signing daemon, =/var/run/ntp_signd]
+    ),
+    [ans=$enableval],
+    [ans=no]
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ no)
+    ntp_signd_path=
+    ;;
+ yes)
+    ntp_signd_path=/var/run/ntp_signd
+    ;;
+ *)
+    ntp_signd_path="$ans"
+esac
+
+case "$ntp_signd_path" in
+ '')
+    wintime_default=no
+    ;;
+ *)
+    wintime_default=yes
+    AC_DEFINE(HAVE_NTP_SIGND, ,[Do we want support for Samba's signing daemon?])
+    AC_DEFINE_UNQUOTED(NTP_SIGND_PATH, "$ntp_signd_path", [Path to sign daemon rendezvous socket])
+esac
+
+
+AC_MSG_CHECKING([if we want the windows symmetric client hack])
+
+# default is no, unless --enable-ntp-signd was given
+ans=$wintime_default
+unset wintime_default
+
+AC_ARG_ENABLE(
+    [wintime],
+    AC_HELP_STRING(
+        [--enable-wintime],
+        [- Provide the windows symmetric client hack]
+    ),
+    [ans=$enableval],
+)
+
+AC_MSG_RESULT([$ans])
+
+case "$ans" in
+ yes)
+    AC_DEFINE(WINTIME, ,[Do we want the windows symmetric client hack?])
+esac
+
+
+AC_CHECK_HEADERS(sys/clockctl.h)
+
+case "$host" in
+ *-*-netbsd*)
+    ans=yes
+    ;;
+ *) ans=no
+    ;;
+esac
+
+AC_ARG_ENABLE(
+    [clockctl],
+    AC_HELP_STRING(
+       [--enable-clockctl],
+       [s Use /dev/clockctl for non-root clock control]
+    ),
+    [ntp_use_dev_clockctl=$enableval],
+    [ntp_use_dev_clockctl=$ac_cv_header_sys_clockctl_h]
+)
+
+AC_MSG_CHECKING([[if we should use /dev/clockctl]])
+AC_MSG_RESULT([$ntp_use_dev_clockctl])
+
+
+AC_CHECK_HEADERS([sys/capability.h])
+AC_CHECK_HEADERS([sys/prctl.h])
+
+AC_MSG_CHECKING([[if we have linux capabilities (libcap)]])
+
+case "$ac_cv_header_sys_capability_h$ac_cv_header_sys_prctl_h" in
+ yesyes)
+    ntp_have_linuxcaps=yes
+    ;;
+ *)
+    ntp_have_linuxcaps=no
+esac
+
+AC_MSG_RESULT([$ntp_have_linuxcaps])
+
+
+AC_ARG_ENABLE(
+    [linuxcaps],
+    AC_HELP_STRING(
+       [--enable-linuxcaps],
+       [+ Use Linux capabilities for non-root clock control]
+    ),
+    [ntp_have_linuxcaps=$enableval]
+)
+
+
+case "$ntp_have_linuxcaps" in
+ yes)
+    AC_DEFINE(HAVE_LINUX_CAPABILITIES, ,[[Do we have Linux capabilities?]])
+    LIBS="$LIBS -lcap"
+esac
+
+
+case "$ntp_use_dev_clockctl$ntp_have_linuxcaps" in
+ *yes*)
+    AC_DEFINE(HAVE_DROPROOT, ,[[Can we drop root privileges?]])
+esac
+
+
+AC_CHECK_HEADERS([libscf.h])
+
+case "$ac_cv_header_libscf_h" in
+ yes)
+    AC_SUBST(LSCF, [-lscf])
+esac
+
+AC_CHECK_FUNC(
+    [setppriv],
+    AC_DEFINE(HAVE_SOLARIS_PRIVS, ,[[Are Solaris privileges available?]])
+)
+
+
+#
+# ISC stuff
+#
+
+if test $ac_cv_struct_sockaddr_has_sa_len = yes; then
+    AC_DEFINE(ISC_PLATFORM_HAVESALEN, ,[ISC: struct sockaddr as sa_len?])
+fi
+
+AC_ARG_ENABLE(ipv6, AC_HELP_STRING([--enable-ipv6], [s use IPv6?]))
+
+case "$enable_ipv6" in
+ yes|''|autodetect)
+    case "$host" in
+     powerpc-ibm-aix4*) ;;
+     *)
+       AC_DEFINE(WANT_IPV6, ,[configure --enable-ipv6])
+       ;;
+    esac
+    ;;
+ no)
+    ;;
+esac
+
+
+AC_CACHE_CHECK(
+    [for IPv6 structures],
+    ac_cv_isc_found_ipv6,
+    [
+       AC_COMPILE_IFELSE(
+           [
+               AC_LANG_PROGRAM(
+                   [
+                       #include <sys/types.h>
+                       #include <sys/socket.h>
+                       #include <netinet/in.h>
+                   ],
+                   [
+                       struct sockaddr_in6 sin6;
+                   ]
+               )
+           ],
+           [ac_cv_isc_found_ipv6=yes],
+           [ac_cv_isc_found_ipv6=no]
+       )
+    ]
+)
+
+#
+# See whether IPv6 support is provided via a Kame add-on.
+# This is done before other IPv6 linking tests so LIBS is properly set.
+#
+AC_MSG_CHECKING([for Kame IPv6 support])
+AC_ARG_WITH(kame,
+       [AC_HELP_STRING([--with-kame], [- =/usr/local/v6])],
+       use_kame="$withval", use_kame="no")
+
+case "$use_kame" in
+ no)
+    ;;
+ yes)
+    kame_path=/usr/local/v6
+    ;;
+ *)
+    kame_path="$use_kame"
+    ;;
+esac
+
+case "$use_kame" in
+ no)
+    AC_MSG_RESULT(no)
+    ;;
+ *)
+    if test -f $kame_path/lib/libinet6.a; then
+       AC_MSG_RESULT($kame_path/lib/libinet6.a)
+       LIBS="-L$kame_path/lib -linet6 $LIBS"
+    else
+       AC_MSG_ERROR([$kame_path/lib/libinet6.a not found.
+
+Please choose the proper path with the following command:
+
+    configure --with-kame=PATH
+])
+    fi
+    ;;
+esac
+
+#
+# Whether netinet6/in6.h is needed has to be defined in isc/platform.h.
+# Including it on Kame-using platforms is very bad, though, because
+# Kame uses #error against direct inclusion.   So include it on only
+# the platform that is otherwise broken without it -- BSD/OS 4.0 through 4.1.
+# This is done before the in6_pktinfo check because that's what
+# netinet6/in6.h is needed for.
+#
+case "$host" in
+ *-bsdi4.[[01]]*)
+    AC_DEFINE(ISC_PLATFORM_NEEDNETINET6IN6H, 1, [Do we need netinet6/in6.h?])
+    isc_netinet6in6_hack="#include <netinet6/in6.h>"
+    ;;
+ *)
+    isc_netinet6in6_hack=""
+esac
+
+#
+# This is similar to the netinet6/in6.h issue.
+#
+case "$host" in
+ *-sco-sysv*uw*|*-*-sysv*UnixWare*|*-*-sysv*OpenUNIX*)
+    AC_DEFINE(ISC_PLATFORM_FIXIN6ISADDR, 1,[Do we need to fix in6isaddr?])
+    isc_netinetin6_hack="#include <netinet/in6.h>"
+    ;;
+ *)
+    isc_netinetin6_hack=""
+esac
+
+
+case "$ac_cv_isc_found_ipv6" in
+ yes)
+    AC_DEFINE(ISC_PLATFORM_HAVEIPV6, ,[have IPv6?])
+
+    AC_CACHE_CHECK(
+       [for in6_pktinfo],
+       ac_cv_have_in6_pktinfo,
+       [
+           AC_COMPILE_IFELSE(
+               [
+                   AC_LANG_PROGRAM(
+                       [
+                           #include <sys/types.h>
+                           #include <sys/socket.h>
+                           #include <netinet/in.h>
+                           $isc_netinetin6_hack
+                           $isc_netinet6in6_hack
+                       ],
+                       [
+                           struct in6_pktinfo xyzzy;
+                       ]
+                   )
+               ],
+               [ac_cv_have_in6_pktinfo=yes],
+               [ac_cv_have_in6_pktinfo=no]
+           )
+       ]
+    )
+
+    case "$ac_cv_have_in6_pktinfo" in
+     yes)
+       AC_DEFINE(ISC_PLATFORM_HAVEIN6PKTINFO, , [have struct in6_pktinfo?])
+    esac
+
+
+    # HMS: Use HAVE_STRUCT_SOCKADDR_IN6_SIN6_SCOPE_ID instead?
+    AC_CACHE_CHECK(
+       [for sockaddr_in6.sin6_scope_id],
+       ac_cv_have_sin6_scope_id,
+       [
+           AC_COMPILE_IFELSE(
+               [
+                   AC_LANG_PROGRAM(
+                       [
+                           #include <sys/types.h>
+                           #include <sys/socket.h>
+                           #include <netinet/in.h>
+                           $isc_netinetin6_hack
+                           $isc_netinet6in6_hack
+                       ],
+                       [
+                           struct sockaddr_in6 xyzzy;
+                           xyzzy.sin6_scope_id = 0;
+                       ]
+                   )
+               ],
+               [ac_cv_have_sin6_scope_id=yes],
+               [ac_cv_have_sin6_scope_id=no]
+           )
+       ]
+    )
+
+    case "$ac_cv_have_sin6_scope_id" in
+     yes)
+       AC_DEFINE(ISC_PLATFORM_HAVESCOPEID, , [have sin6_scope_id?])
+    esac
+esac
+
+
+# We need this check run even without ac_cv_isc_found_ipv6=yes
+
+AC_CACHE_CHECK(
+    [for in6addr_any],
+    ac_cv_have_in6addr_any,
+    [
+       AC_COMPILE_IFELSE(
+           [
+               AC_LANG_PROGRAM(
+                   [
+                       #include <sys/types.h>
+                       #include <sys/socket.h>
+                       #include <netinet/in.h>
+                       $isc_netinetin6_hack
+                       $isc_netinet6in6_hack
+                   ],
+                   [
+                       struct in6_addr in6; 
+                       in6 = in6addr_any;
+                   ]
+               )
+           ],
+           [ac_cv_have_in6addr_any=yes],
+           [ac_cv_have_in6addr_any=no]
+       )
+    ]
+)
+
+case "$ac_cv_have_in6addr_any" in
+ no)
+    AC_DEFINE(ISC_PLATFORM_NEEDIN6ADDRANY, , [missing in6addr_any?])
+esac
+
+
+AC_CACHE_CHECK(
+    [for struct if_laddrconf],
+    ac_cv_isc_struct_if_laddrconf,
+    [
+        AC_COMPILE_IFELSE(
+           [
+               AC_LANG_PROGRAM(
+                   [
+                       #include <sys/types.h>
+                       #include <net/if6.h>
+                   ],
+                   [
+                       struct if_laddrconf a;
+                   ]
+               )
+           ],
+           [ac_cv_isc_struct_if_laddrconf=yes],
+           [ac_cv_isc_struct_if_laddrconf=no]
+       )
+    ]
+)
+
+case "$ac_cv_isc_struct_if_laddrconf" in
+ yes)
+    AC_DEFINE(ISC_PLATFORM_HAVEIF_LADDRCONF, , [have struct if_laddrconf?])
+esac
+
+AC_CACHE_CHECK(
+    [for struct if_laddrreq],
+    ac_cv_isc_struct_if_laddrreq,
+    [
+        AC_COMPILE_IFELSE(
+           [
+               AC_LANG_PROGRAM(
+                   [
+                       #include <sys/types.h>
+                       #include <net/if6.h>
+                   ],
+                   [
+                       struct if_laddrreq a;
+                   ]
+               )
+           ],
+           [ac_cv_isc_struct_if_laddrreq=yes],
+           [ac_cv_isc_struct_if_laddrreq=no]
+       )
+    ]
+)
+
+case "$ac_cv_isc_struct_if_laddrreq" in
+ yes)
+    AC_DEFINE(ISC_PLATFORM_HAVEIF_LADDRREQ, , [have struct if_laddrreq?])
+esac
+
+#
+# Look for a sysctl call to get the list of network interfaces.
+#
+AC_CACHE_CHECK(
+    [for interface list sysctl],
+    ac_cv_iflist_sysctl,
+    AC_EGREP_CPP(
+       [found_rt_iflist], 
+       [
+           #include <sys/param.h>
+           #include <sys/sysctl.h>
+           #include <sys/socket.h>
+           #ifdef NET_RT_IFLIST  
+           found_rt_iflist
+           #endif
+       ],
+       [ac_cv_iflist_sysctl=yes],
+       [ac_cv_iflist_sysctl=no]
+    )
+)
+
+case "$ac_cv_iflist_sysctl" in
+ yes)
+    AC_DEFINE(HAVE_IFLIST_SYSCTL,1,[have iflist_sysctl?])
+esac
+
+
+###
+
+AC_DEFINE_DIR(NTP_KEYSDIR, sysconfdir, [Default location of crypto key info])
+
+AC_CONFIG_FILES(Makefile)
+AC_CONFIG_FILES(ElectricFence/Makefile)
+AC_CONFIG_FILES(adjtimed/Makefile)
+AC_CONFIG_FILES(clockstuff/Makefile)
+AC_CONFIG_FILES(include/Makefile)
+AC_CONFIG_FILES(include/isc/Makefile)
+AC_CONFIG_FILES(kernel/Makefile)
+AC_CONFIG_FILES(kernel/sys/Makefile)
+AC_CONFIG_FILES(libntp/Makefile)
+AC_CONFIG_FILES(libparse/Makefile)
+AC_CONFIG_FILES(ntpd/Makefile)
+AC_CONFIG_FILES(ntpdate/Makefile)
+AC_CONFIG_FILES(ntpdc/Makefile)
+AC_CONFIG_FILES(ntpdc/nl.pl,           [chmod +x ntpdc/nl.pl])
+AC_CONFIG_FILES(ntpq/Makefile)
+AC_CONFIG_FILES(parseutil/Makefile)
+AC_CONFIG_FILES(scripts/Makefile)
+AC_CONFIG_FILES(scripts/calc_tickadj,  [chmod +x scripts/calc_tickadj])
+AC_CONFIG_FILES(scripts/checktime,     [chmod +x scripts/checktime])
+AC_CONFIG_FILES(scripts/freq_adj,      [chmod +x scripts/freq_adj])
+AC_CONFIG_FILES(scripts/html2man,      [chmod +x scripts/html2man])
+AC_CONFIG_FILES(scripts/mkver,         [chmod +x scripts/mkver])
+AC_CONFIG_FILES(scripts/ntp-wait,      [chmod +x scripts/ntp-wait])
+AC_CONFIG_FILES(scripts/ntpsweep,      [chmod +x scripts/ntpsweep])
+AC_CONFIG_FILES(scripts/ntptrace,      [chmod +x scripts/ntptrace])
+AC_CONFIG_FILES(scripts/ntpver,                [chmod +x scripts/ntpver])
+AC_CONFIG_FILES(scripts/plot_summary,  [chmod +x scripts/plot_summary])
+AC_CONFIG_FILES(scripts/summary,       [chmod +x scripts/summary])
+AC_CONFIG_FILES(util/Makefile)
+
+AC_CONFIG_SUBDIRS(sntp)
+
+AC_OUTPUT
diff --git a/depcomp b/depcomp
new file mode 100755 (executable)
index 0000000..04701da
--- /dev/null
+++ b/depcomp
@@ -0,0 +1,530 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2005-07-09.11
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> $depfile
+    echo >> $depfile
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> $depfile
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
+  tmpdepfile="$stripped.u"
+  if test "$libtool" = yes; then
+    "$@" -Wc,-M
+  else
+    "$@" -M
+  fi
+  stat=$?
+
+  if test -f "$tmpdepfile"; then :
+  else
+    stripped=`echo "$stripped" | sed 's,^.*/,,'`
+    tmpdepfile="$stripped.u"
+  fi
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+
+  if test -f "$tmpdepfile"; then
+    outname="$stripped.o"
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
+    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mecanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space in the [].
+      sed -e 's,^.*\.[a-z]*:[   ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $dashmflag |
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no
+  for arg in "$@"; do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix="`echo $object | sed 's/^.*\././'`"
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o,
+  # because we must use -o when running libtool.
+  "$@" || exit $?
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+       set fnord "$@"
+       shift
+       shift
+       ;;
+    *)
+       set fnord "$@" "$arg"
+       shift
+       shift
+       ;;
+    esac
+  done
+  "$@" -E |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::   \1 \\:p' >> "$depfile"
+  echo "       " >> "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/dot.emacs b/dot.emacs
new file mode 100644 (file)
index 0000000..04241e7
--- /dev/null
+++ b/dot.emacs
@@ -0,0 +1,18 @@
+;; This is how Dave Mills likes to see the code formatted.
+
+(defconst ntp-c-style
+  '((c-basic-offset . 8)
+    (c-offsets-alist . ((arglist-intro       . +)
+                       (case-label           . *)
+                       (statement-case-intro . *)
+                       (statement-cont       . *)
+                       (substatement-open    . 0))))
+  "Dave L. Mills; programming style for use with ntp")
+
+(defun ntp-c-mode-common-hook ()
+  ;; add ntp c style
+  (c-add-style "ntp" ntp-c-style nil))
+
+(add-hook 'c-mode-common-hook 'ntp-c-mode-common-hook)
+
+;; 1997112600
diff --git a/excludes b/excludes
new file mode 100644 (file)
index 0000000..36cb351
--- /dev/null
+++ b/excludes
@@ -0,0 +1 @@
+*.obj *.pch *.bsc *.pdb *.sbr nt*.zip *.tar *.gz *.ilk beta*.zip
diff --git a/flock-build b/flock-build
new file mode 100755 (executable)
index 0000000..d80fc6d
--- /dev/null
@@ -0,0 +1,106 @@
+#! /bin/sh
+
+BUILD_ARGS="$@"
+PARSE="--enable-parse-clocks"
+#PARSE=
+STD="--enable-simulator"
+
+case "$SIMUL" in
+ '') PARALLEL_BUILDS=1
+     ;;
+ *)  PARALLEL_BUILDS=$SIMUL
+esac
+
+case "$PARALLEL_BUILDS" in
+ 1)  ;;
+ *)  echo Launching $PARALLEL_BUILDS parallel builds on each machine
+esac
+
+# Backroom:
+#   barnstable    freebsd-6.1
+#   beauregard    freebsd-6.0
+# X churchy       alpha-dec-osf5.1
+#   deacon        sparc-sun-solaris2.10
+#   grundoon      freebsd-6.2
+#   howland       freebsd-6.1
+# o macabre       freebsd-6.1-STABLE
+# o mort          freebsd-6.1
+#   whimsy        sparc-sun-solaris2.10
+
+# Campus:
+# * baldwin       sparc-sun-solaris2.10
+# * bridgeport    sparc-sun-solaris2.10
+# * cowbird       freebsd-6.1
+# * malarky       sparc-sun-solaris2.10
+# * pogo          sparc-sun-solaris2.10
+# * rackety       freebsd-6.1
+
+# HMS: we need $PWD because solaris produces /deacon/backroom when
+# we are in /backroom and in general there is no /deacon/backroom.
+c_d=${PWD:-`pwd`}
+
+SIG=`perl -e 'print rand'`
+
+case "$LIST" in
+ '') LIST="baldwin bridgeport cowbird malarky pogo rackety" ;;
+esac
+
+for i in $LIST
+do
+    SKIPTHIS=0
+    [ -f .buildkey-$i ] && SKIPTHIS=1
+    case "$SKIPTHIS" in
+     1)
+        echo flock-build running on $i? check LIST, skipping
+        ;;
+     0)   
+        echo $i
+        echo $SIG > .buildkey-$i
+        case "1" in
+         0)
+            ssh $i "cd $c_d ; ./build $SIG $PARSE $STD $BUILD_ARGS" &
+            ssh $i "cd $c_d ; ./build $SIG $PARSE $STD --without-crypto $BUILD_ARGS" &
+            ssh $i "cd $c_d ; ./build $SIG        $STD --disable-all-clocks $BUILD_ARGS" &
+            ;;
+         1)
+            cat > .flockbuild-$i-$SIG <<ENDQUOT
+#!/bin/sh
+
+# depends on job control and expects to be invoked under ssh -tt
+
+cd $c_d
+COUNT=0
+
+./build $SIG $PARSE $STD $BUILD_ARGS &
+
+COUNT=\`expr \$COUNT + 1\`
+echo $i started build \$COUNT of 4
+[ 0 -lt \`expr \$COUNT % $PARALLEL_BUILDS\` ] || wait
+
+./build $SIG $PARSE $STD --disable-debugging $BUILD_ARGS &
+
+COUNT=\`expr \$COUNT + 1\`
+echo $i started build \$COUNT of 4
+[ 0 -lt \`expr \$COUNT % $PARALLEL_BUILDS\` ] || wait
+
+./build $SIG $PARSE $STD --without-crypto $BUILD_ARGS &
+
+COUNT=\`expr \$COUNT + 1\`
+echo $i started build \$COUNT of 4
+[ 0 -lt \`expr \$COUNT % $PARALLEL_BUILDS\` ] || wait
+
+./build $SIG        $STD --disable-all-clocks $BUILD_ARGS &
+
+COUNT=\`expr \$COUNT + 1\`
+echo $i started build \$COUNT of 4
+wait
+echo \`date -u '+%H:%M:%S'\` $i flock-build $c_d done.
+rm .buildkey-$i
+ENDQUOT
+           chmod +x .flockbuild-$i-$SIG
+           ssh -tt $i "$c_d/.flockbuild-$i-$SIG ; \
+                    rm $c_d/.flockbuild-$i-$SIG" 2>/dev/null &
+        esac
+    esac
+done
+echo `date -u '+%H:%M:%S'` flock-build launched
diff --git a/html/accopt.html b/html/accopt.html
new file mode 100644 (file)
index 0000000..be8a5bb
--- /dev/null
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Access Control Options</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Access Control Options</h3>
+               <img src="pic/pogo6.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+               <p>The skunk watches for intruders and sprays.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:35</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#acx">Access Control Support</a>
+                       <li class="inline"><a href="#kiss">The Kiss-of-Death Packet</a>
+                       <li class="inline"><a href="#cmd">Access Control Commands</a>
+               </ul>
+               <hr>
+               <h4 id="acx">Access Control Support</h4>
+               The<tt> ntpd</tt> daemon implements a general purpose address/mask based restriction list. The list contains address/match entries sorted first by increasing address values and and then by increasing mask values. A match occurs when the bitwise AND of the mask and the packet source address is equal to the bitwise AND of the mask and address in the list. The list is searched in order with the last match found defining the restriction flags associated with the entry. Additional information and examples can be found in the <a href="notes.html">Notes on Configuring NTP and Setting up a NTP Subnet</a> page.
+               <p>The restriction facility was implemented in conformance with the access policies for the original NSFnet backbone time servers. Later the facility was expanded to deflect cryptographic and clogging attacks. While this facility may be useful for keeping unwanted or broken or malicious clients from congesting innocent servers, it should not be considered an alternative to the NTP authentication facilities. Source address based restrictions are easily circumvented by a determined cracker.</p>
+               <p>Clients can be denied service because they are explicitly included in the restrict list created by the <tt>restrict</tt> command or implicitly as the result of cryptographic or rate limit violations. Cryptographic violations include certificate or identity verification failure; rate limit violations generally result from defective NTP&nbsp;implementations that send packets at abusive rates. Some violations cause denied service only for the offending packet, others cause denied service for a timed period and others cause the denied service for an indefinate period. When a client or network is denied access for an indefinate period, the only way at present to remove the restrictions is by restarting the server.</p>
+               <h4 id="kiss">The Kiss-of-Death Packet</h4>
+               <p>Ordinarily, packets denied service are simply dropped with no further action except incrementing statistics counters. Sometimes a more proactive response is needed, such as a server message that explicitly requests the client to stop sending and leave a message for the system operator. A special packet format has been created for this purpose called the &quot;kiss-o'-death&quot; (KoD) packet. KoD packets have the leap bits set unsynchronized and stratum set to zero and the reference identifier field set to a four-byte ASCII code. If the <tt>noserve</tt> or <tt>notrust</tt> flag of the matching restrict list entry is set, the code is &quot;DENY&quot;; if the <tt>limited</tt> flag is set and the rate limit is exceeded, the code is &quot;RATE&quot;. Finally, if a cryptographic violation occurs, the code is &quot;CRYP&quot;.</p>
+               <p>A client receiving a KoD performs a set of sanity checks to minimize security exposure, then updates the stratum and reference identifier peer variables, sets the access denied (TEST4) bit in the peer flash variable and sends a message to the log. As long as the TEST4 bit is set, the client will send no further packets to the server. The only way at present to recover from this condition is to restart the protocol at both the client and server. This happens automatically at the client when the association times out. It will happen at the server only if the server operator cooperates.</p>
+               <h4 id="cmd">Access Control Commands</h4>
+               <dl>
+                       <dt><tt>discard [ average <i>avg</i> ][ minimum <i>min</i> ] [ monitor <i>prob</i> ]</tt>
+                       <dd>Set the parameters of the <tt>limited</tt> facility which protects the server from client abuse. The <tt>average</tt> subcommand specifies the minimum average packet spacing, while the <tt>minimum</tt> subcommand specifies the minimum packet spacing. Packets that violate these minima are discarded and a kiss-o'-death packet returned if enabled. The default minimum average and minimum are 5 and 2, respectively. The monitor subcommand specifies the probability of discard for packets that overflow the rate-control window.
+                       <dt><tt>restrict <i>address</i> [mask <i>mask</i>] [<i>flag</i>][...]</tt>
+                       <dd>The <i><tt>address</tt></i> argument expressed in dotted-quad form is the address of a host or network. Alternatively, the <tt><i>address</i></tt> argument can be a valid host DNS&nbsp;name. The <i><tt>mask</tt></i> argument expressed in dotted-quad form defaults to <tt>255.255.255.255</tt>, meaning that the <i><tt>address</tt></i> is treated as the address of an individual host. A default entry (address <tt>0.0.0.0</tt>, mask <tt>0.0.0.0</tt>) is always included and is always the first entry in the list. Note that text string <tt>default</tt>, with no mask option, may be used to indicate the default entry.
+                       <dd>In the current implementation, <i><tt>flag</tt></i> always restricts access, i.e., an entry with no flags indicates that free access to the server is to be given. The flags are not orthogonal, in that more restrictive flags will often make less restrictive ones redundant. The flags can generally be classed into two catagories, those which restrict time service and those which restrict informational queries and attempts to do run-time reconfiguration of the server. One or more of the following flags may be specified:
+                               <dl>
+                                       <dt><tt>ignore</tt>
+                                       <dd>Deny packets of all kinds, including <tt>ntpq</tt> and <tt>ntpdc</tt> queries.
+                                       <dt><tt>kod</tt>
+                                       <dd>If this flag is set when an access violation occurs, a kiss-o'-death (KoD) packet is sent. KoD packets are rate limited to no more than one per second. If another KoD packet occurs within one second after the last one, the packet is dropped
+                                       <dt><tt>limited</tt>
+                                       <dd>Deny service if the packet spacing violates the lower limits specified in the <tt>discard</tt> command. A history of clients is kept using the monitoring capability of <tt>ntpd</tt>. Thus, monitoring is always active as long as there is a restriction entry with the <tt>limited</tt> flag.
+                                       <dt><tt>lowpriotrap</tt>
+                                       <dd>Declare traps set by matching hosts to be low priority. The number of traps a server can maintain is limited (the current limit is 3). Traps are usually assigned on a first come, first served basis, with later trap requestors being denied service. This flag modifies the assignment algorithm by allowing low priority traps to be overridden by later requests for normal priority traps.
+                                       <dt><tt>nomodify</tt>
+                                       <dd>Deny <tt>ntpq</tt> and <tt>ntpdc</tt> queries which attempt to modify the state of the server (i.e., run time reconfiguration). Queries which return information are permitted.
+                                       <dt><tt>noquery</tt>
+                                       <dd>Deny <tt>ntpq</tt> and <tt>ntpdc</tt> queries. Time service is not affected.
+                                       <dt><tt>nopeer</tt>
+                                       <dd>Deny packets which would result in mobilizing a new association. &nbsp;This includes broadcast, symmetric-active and manycast client packets when a configured association does not exist.
+                                       <dt><tt>noserve</tt>
+                                       <dd>Deny all packets except <tt>ntpq</tt> and <tt>ntpdc</tt> queries.
+                                       <dt><tt>notrap</tt>
+                                       <dd>Decline to provide mode 6 control message trap service to matching hosts. The trap service is a subsystem of the <tt>ntpdq</tt> control message protocol which is intended for use by remote event logging programs.
+                                       <dt><tt>notrust</tt>
+                                       <dd>Deny packets unless the packet is cryptographically authenticated.
+                                       <dt><tt>ntpport</tt>
+                                       <dd>This is actually a match algorithm modifier, rather than a restriction flag. Its presence causes the restriction entry to be matched only if the source port in the packet is the standard NTP UDP port (123). Both <tt>ntpport</tt> and <tt>non-ntpport</tt> may be specified. The <tt>ntpport</tt> is considered more specific and is sorted later in the list.
+                                       <dt><tt>version</tt>
+                                       <dd>Deny packets that do not match the current NTP version.
+                               </dl>
+                       <dd>Default restriction list entries with the flags <tt>ignore, interface, ntpport</tt>, for each of the local host's interface addresses are inserted into the table at startup to prevent the server from attempting to synchronize to its own time. A default entry is also always present, though if it is otherwise unconfigured; no flags are associated with the default entry (i.e., everything besides your own NTP server is unrestricted).
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/assoc.html b/html/assoc.html
new file mode 100644 (file)
index 0000000..0ca1426
--- /dev/null
@@ -0,0 +1,59 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Association Management</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Association Management</h3>
+               <img src="pic/alice51.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>Make sure who your friends are.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:35</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#modes">Association Modes</a>
+                       <li class="inline"><a href="#client">Client/Server Mode</a>
+                       <li class="inline"><a href="#symact">Symmetric Active/Passive Mode</a>
+                       <li class="inline"><a href="#broad">Broadcast/Multicast Modes</a>
+                       <li class="inline"><a href="#umlt">Multicasting</a>
+                       <li class="inline"><a href="#umlt">Multicasting</a>
+                       <li class="inline"><a href="#burst">Burst Modes</a>
+               </ul>
+               <hr>
+               <h4 id="modes">Association Modes</h4>
+               <p>NTP Version 4 (NTPv4) incorporates new features and refinements to the NTP Version 3 (NTPv3) algorithms; however, it continues the tradition of backwards compatibility with older versions. A number of new operating modes for automatic server discovery and improved accuracy in occasionally connected networks are provided. Following is an overview of the new features; additional information is available on the <a href="confopt.html">Configuration Options</a> and <a href="authopt.html">Authentication Options</a> pages and in the papers, reports, memoranda and briefings at <a href="http://www.ntp.org">www.ntp.org</a>.</p>
+               <p>There are two types of associations: persistent associations, which result from configuration file commands, and ephemeral associations, which result from protocol operations described below. A persistent association is never demobilized, although it may become dormant when the associated server becomes unreachable. An ephemeral association is mobilized when a message arrives from a server; for instance, a symmetric passive association is mobilized upon arrival of a symmetric active message. A broadcast client association is mobilized upon arrival of a broadcast server message, while a Manycast client association is mobilized upon arrival of a Manycast server message.</p>
+               <p>Ordinarily, successful mobilization of an ephemeral association requires the server to be cryptographically authenticated to the dependent client. This can be done using either symmetric-key or public-key cryptography, as described in the <a href="authopt.html">Authentication Options</a> page. The cryptographic means insure an unbroken chain of trust between the dependent client and the primary servers at the root of the synchronization subnet. We call this chain the <i>provenance</i> of the client and define new vocabulary as to proventicate a client or provide proventic credentials. Once mobilized, ephemeral associations are demobilized when either (a) the server becomes unreachable or (b) the server refreshes the key media without notifying the client.</p>
+               <p>There are three principal modes of operation: client/server, symmetric active/passive and broadcast. In addition, there are two modes using IP multicast support: multicast and manycast. These modes are selected based on the scope of service, intended flow of time and proventic values and means of configuration. Following is a summary of the operations in each mode.</p>
+               <h4 id="client">Client/Server Mode</h4>
+               <p>Client/server mode is probably the most common configuration in the Internet today. It operates in the classic remote-procedure-call (RPC) paradigm with stateless servers. In this mode a client sends a request to the server and expects a reply at some future time. In some contexts this would be described as a &quot;pull&quot; operation, in that the client pulls the time and proventic values from the server. A client is configured in client mode using the <tt>server</tt> (sic) command and specifying the server IPv4 or IPv6 DNS name or address; the server requires no prior configuration. The original NTPv3 authentication scheme is applicable in this mode, as well as the new NTPv4 Autokey proventication scheme. In addition, two burst modes described below can be used in appropriate cases.</p>
+               <h4 id="symact">Symmetric Active/Passive Mode</h4>
+               <p>Symmetric active/passive mode is intended for configurations were a clique of low-stratum peers operate as mutual backups for each other. Each peer operates with one or more primary reference sources, such as a radio clock, or a subset of secondary servers known to be reliable and proventicated. Should one of the peers lose all reference sources or simply cease operation, the other peers will automatically reconfigure so that time and proventication values can flow from the surviving peers to all the others in the clique. In some contexts this would be described as a &quot;push-pull&quot; operation, in that the peer either pulls or pushes the time and proventic values depending on the particular configuration.</p>
+               <p>Symmetric peers operate with their sources in some NTP mode and with each other in symmetric mode. A peer is configured in symmetric active mode using the <tt>peer</tt> command and specifying the other peer IPv4 or IPv6 DNS name or address. The other peer can also be configured in symmetric active mode in a similar way. However, if the other peer is not specifically configured in this way, a symmetric passive association is mobilized upon arrival of a symmetric active message. Since an intruder can impersonate a symmetric active peer and inject false time values, symmetric mode should always be cryptographically validated. The original NTPv3 authentication scheme is applicable in this mode, as well as the new NTPv4 Autokey proventication scheme.</p>
+               <h4 id="broad">Broadcast/Multicast Modes</h4>
+               <p>IPv4 broadcast mode in both NTPv3 and NTPv4 is limited to directly connected subnets such as Ethernets which support broadcast technology. Ordinarily, this technology does not operate beyond the first hop router or gateway. In IPv6 and where service is intended beyond the local subnet, IP multicasting can be used where supported by the operating system and the routers support the Internet Group Management Protocol (IGMP). Most current kernels and available routers do support IP multicast technology, although service providers are sometimes reluctant to deploy it.</p>
+               <p>IPv4 broadcast mode is intended for configurations involving one or a few servers and a possibly very large client population on the same subnet. A broadcast server is configured using the <tt>broadcast</tt> command and a IPv4 local subnet broadcast address. A broadcast client is configured using the <tt>broadcastclient</tt> command, in which case it responds to broadcast messages received on any interface. Since an intruder can impersonate a broadcast server and inject false time values, this mode should always be cryptographically validated. The original NTPv3 authentication scheme is applicable in this mode, as well as the new NTPv4 Autokey proventication scheme.</p>
+               <p>The server generates broadcast messages continuously at intervals specified by the <tt>minpoll</tt> keyword and with a time-to-live span specified by the <tt>ttl</tt> keyword. A broadcast client responds to the first message received by waiting a short interval to avoid implosion at the server. Then, the client polls the server in burst mode in order to quickly set the host clock and validate the source. This normally results in a volley of eight client/server cycles at 2-s intervals during which both the synchronization and cryptographic protocols run concurrently. Following the volley, the client computes the offset between the apparent broadcast time and the (unicast) client time. This offset is used to compensate for the propagation time between the broadcast server and client. Once the offset is computed, the server continues as before and the client sends no further messages. If for some reason the broadcast server does not respond to client messages, the client will time out the volley and continue in listen-only mode with a default propagation delay.</p>
+               <h4 id="umlt">Multicasting</h4>
+               <p>Multicasting can be used to extend the scope of a timekeeping subnet in two ways: multicasting and manycasting. A general discussion of IP multicast technology is beyond the scope of this page. In simple terms a host or router sending to a IPv4 or IPv6 multicast group address expects all hosts or routers listening on this address to receive the message. There is no intrinsic limit on the number of senders or receivers and senders can be receivers and vice versa. The IANA has assigned multicast group address IPv4 224.0.1.1 and IPv6 FF05::101 (site local) to NTP, but these addresses should be used only where the multicast span can be reliably constrained to protect neighbor networks. In general, administratively scoped IPv4 group addresses should be used, as described in RFC-2365, or GLOP group addresses, as described in RFC-2770.</p>
+               <p>A multicast server is configured using the <tt>broadcast</tt> command, but with a multicast group address instead of a broadcast address. A multicast client is configured using the <tt>multicastclient</tt> command with a multicast group address. However, there is a subtle difference between IPv4 broadcasting and multicasting. IPv4 broadcasting is specific to each interface and local subnet address. If more than one interface is attached to a machine, a separate <tt>broadcast</tt> command applies to each one separately. This provides a way to limit exposure in a firewall, for example. For IPv6 the same distinction can be made using link-local prefix FF02 for each interface and site-local FF05 for all interfacesl.</p>
+               <p>IP multicasting is a different paradigm. By design, multicast messages travel from the sender via a shortest-path or shared tree to the receivers, which may require these messages emit from one or all interfaces, but carry a common source address. However, it is possible to configure multiple multicast group addresses using multiple <tt>broadcast</tt> or <tt>multicastclient</tt> commands. Other than these particulars, multicast messages are processed just like broadcast messages. Note that the calibration feature in broadcast mode is extremely important, since IP multicast messages can travel far different paths through the IP routing fabric than ordinary IP unicast messages.</p>
+               <h4 id="many">Manycasting</h4>
+               <p>Manycasting is a automatic discovery and configuration paradigm new to NTPv4. It is intended as a means for a multicast client to troll the nearby network neighborhood to find cooperating manycast servers, validate them using cryptographic means and evaluate their time values with respect to other servers that might be lurking in the vicinity. The intended result is that each manycast client mobilizes client associations with some number of the &quot;best&quot; of the nearby anycast servers, yet automatically reconfigures to sustain this number of servers should one or another fail. Additional information is on the <a href="manyopt.html">Automatic NTP Configuration Options</a> page.</p>
+               <h4 id="burst">Burst Modes</h4>
+               <p>There are two burst modes where a single poll event triggers a burst of eight packets at 2-s intervals instead of the usual one. The <tt>burst</tt> mode sends a burst when the server is reachable, while the <tt>iburst</tt> mode sends a burst when the server is unreachable. Each mode is independently of the other and both can be used if necessary. The <tt>calldelay</tt> command can be used to increase the interval between the first and second packets in the burst in order to allow a modem to complete a call. Received server packets update the clock filter, which selects the best (most accurate) time values. When the last packet in the burst is sent, the next received packet updates the system variables and sets the system clock in the usual manner, as if only a single client/server cycle had occurred. The result is not only a rapid and reliable setting of the system clock, but a considerable reduction in network jitter.</p>
+               <p>The <tt>iburst</tt> keyword is used where it is important to set the clock quickly when an association is first mobilized or first becomes reachable or when the network attachment requires an initial calling or training procedure. The burst is initiated only when the server first becomes reachable and results in good accuracy with intermittent connections typical of PPP and ISDN services. Outlyers due to initial dial-up delays, etc., are avoided and the client sets the clock within a few seconds after the first message.</p>
+               <p>The <tt>burst</tt> keyword can be configured in cases of excessive network jitter or when the network attachment requires an initial calling or training procedure. The burst is initiated at each poll interval when the server is reachable. The burst does produce additional network overhead and can cause trouble if used indiscriminately. It should only be used where the poll interval is expected to settle to values at or above 1024 s.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/audio.html b/html/audio.html
new file mode 100644 (file)
index 0000000..9cea273
--- /dev/null
@@ -0,0 +1,148 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Reference Clock Audio Drivers</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Reference Clock Audio Drivers</h3>
+               <img src="pic/radio2.jpg" alt="jpg" align="left">ICOM R-72 shortwave receiver and Sure audio mixer
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:36</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links8.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#sound">Sound Card Drivers</a>
+                       <li class="inline"><a href="#short">Shortwave Radio Drivers</a>
+                       <li class="inline"><a href="#setup">Setup and Debugging Aids</a>
+               </ul>
+               <hr>
+               <h4 id="sound">Sound Card Drivers</h4>
+               <p>There are some applications in which the computer time can be disciplined to an audio signal, rather than a serial timecode and communications port or special purpose bus peripheral. This is useful in such cases where the audio signal is sent over a telephone circuit, for example, or received directly from a shortwave receiver. In such cases the audio signal can be connected via an ordinary sound card or baseboard audio codec. The suite of NTP reference clock drivers currently includes three drivers suitable for these applications. They include a driver for the Inter Range Instrumentation Group (IRIG) signals produced by many radio clocks and timing devices, another for the Canadian time/frequency radio station CHU and a third for the NIST time/frequency radio stations WWV and WWVH. The radio drivers are designed to work with ordinary inexpensive shortwave radios and may be one of the least expensive ways to build a good primary time server.</p>
+               <p>All three drivers make ample use of sophisticated digital signal processing algorithms designed to efficiently extract timing signals from noise and interference. The radio station drivers in particular implement optimum linear demodulation and decoding techniques, including maximum likelihood and soft-decision methods. The documentation page for each driver contains an in-depth discussion on the algorithms and performance expectations. In some cases the algorithms are further analyzed, modelled and evaluated in a technical report.</p>
+               <p>Currently, the audio drivers work with with Sun operating systems and audio codecs, including SunOS 4.1.3 and Solaris from 2.6 and probably all others in between. They also work with FreeBSD from 4.1 with compatible sound card. In fact, the interface is quite generic and support for other systems, in particular the various Unix generics, should not be difficult. Volunteers are solicited.</p>
+               <p>The audio drivers include a number of common features designed to groom input signals, suppress spikes and normalize signal levels. An automatic gain control (AGC) feature provides protection against overdriven or underdriven input signals. It is designed to maintain adequate demodulator signal amplitude while avoiding occasional noise spikes. In order to assure reliable operation, the signal level must be in the range where the audio gain control is effective. In general, this means the input signal level must be such as to cause the AGC to set the gain somewhere in the middle of the range from 0 to 255, as indicated in the timecode displayed by the <tt>ntpq</tt> program.</p>
+               <p>The drivers operate by disciplining a logical clock based on the codec sample clock to the audio signal as received. This is done by stuffing or slipping samples as required to maintain exact frequency to the order of 0.1 PPM. In order for the driver to reliably lock on the audio signal, the sample clock frequency tolerance must be less than 250 PPM (.025 percent) for the IRIG driver and half that for the radio drivers. The largest error observed so far is about 60 PPM, but it is possible some sound cards or codecs may exceed that value.</p>
+               <p>The drivers include provisions to select the input port and to monitor the input signal. The <tt>fudge flag 2</tt> selects the microphone port if set to zero or the line-in port if set to one. It does not seem useful to specify the compact disc player port. The <tt>fudge flag 3</tt> enables the input signal monitor using the previously selected output port and output gain. Both of these flags can be set in the configuration file or remotely using the <tt>ntpdc</tt> utility program.</p>
+               <h4 id="short">Shortwave Radio Drivers</h4>
+               <p>The WWV/H and CHU audio drivers require an external shortwave radio with the radio output - speaker or headphone jack - connected to either the microphone or line-in port on the computer. There is some degree of art in setting up the radio and antenna and getting the setup to work. While the drivers are highly sophisticated and efficient in extracting timing signals from noise and interference, it always helps to have as clear a signal as possible.</p>
+               <p>The most important factor affecting the radio signal is the antenna. It need not be long - even 15 feet is enough if it is located outside of a metal frame building, preferably on the roof, and away from metallic objects. An ordinary CB whip mounted on a PVC pipe and wooden X-frame on the roof should work well with most portable radios, as they are optimized for small antennas.</p>
+               <p>The radio need not be located near the computer; in fact, it generally works better if the radio is outside the near field of computers and other electromagnetic noisemakers. It can be in the elevator penthouse connected by house wiring, which can also be used to power the radio. A couple of center-tapped audio transformers will minimize noise pickup and provide phantom power to the radio with return via the building ground.</p>
+               <p>The WWV/H and CHU transmitters operate on several frequencies simultaneously, so that in most parts of North America at least one frequency supports propagation to the receiver location at any given hour. While both drivers support the ICOM CI-V radio interface and can tune the radio automatically, computer-tunable radios are expensive and probably not cost effective compared to a GPS receiver. So, the radio frequency must usually be fixed and chosen by compromise.</p>
+               <p>Shortwave (3-30 MHz) radio propagation phenomena are well known to shortwave enthusiasts. The phenomena generally obey the following rules:</p>
+               <ul>
+                       <li>The optimum frequency is higher in daytime than nighttime, stays high longer on summer days and low longer on winter nights.
+                       <li>Transitions between daytime and nightime conditions generally occur somewhat after sunrise and sunset at the midpoint of the path from transmitter to receiver.
+                       <li>Ambient noise (static) on the lower frequencies follows the thunderstorm season, so is higher on summer afternoons and evenings.
+                       <li>The lower frequency bands are best for shorter distances, while the higher bands are best for longer distances.
+                       <li>The optimum frequencies are higher at the peak of the 11-year sunspot cycle and lower at the trough. The current sunspot cycle should peak in the first couple of years beginning the century.
+               </ul>
+               <p>The best way to choose a frequency is to listen at various times over the day and determine the best highest (daytime) and lowest (nighttime) frequencies. Then, assuming one is available, choose the highest frequency between these frequencies. This strategy assumes that the high frequency is more problematic than the low, that the low frequency probably comes with severe multipath and static, and insures that probably twice a day the chosen frequency will work. For instance, on the east coast the best compromise CHU frequency is probably 7335 kHz and the best WWV frequency is probably 15 MHz.</p>
+               <h4>Autotune Modes</h4>
+               <p>The shortwave drivers include support for an optional autotune function compatible with ICOM&nbsp;receivers and transceivers. The <tt>mode</tt> keyword of the <tt>server</tt> configuration command specifies the ICOM ID select code in decimal. A missing or zero argument disables the CI-V interface. Since all ICOM select codes are less than 128, the high order bit of the code is used by the driver to specify the baud rate. If this bit is not set, the rate is 9600 bps for the newer radios; if set, the rate is 1200 bps for the older radios. Following are the ID select codes for the known radios.</p>
+               <table width="100%" cols="6">
+                       <tr>
+                               <td>Radio</td>
+                               <td>Hex</td>
+                               <td>Decimal</td>
+                               <td>Radio</td>
+                               <td>Hex</td>
+                               <td>Decimal</td>
+                       </tr>
+                       <tr>
+                               <td>706</td>
+                               <td>0x4e</td>
+                               <td>78</td>
+                               <td>775</td>
+                               <td>0x46</td>
+                               <td>70</td>
+                       </tr>
+                       <tr>
+                               <td>706MKIIG</td>
+                               <td>0x58</td>
+                               <td>88</td>
+                               <td>781</td>
+                               <td>0x26</td>
+                               <td>38</td>
+                       </tr>
+                       <tr>
+                               <td>725</td>
+                               <td>0x28</td>
+                               <td>40</td>
+                               <td>970</td>
+                               <td>0x2e</td>
+                               <td>46</td>
+                       </tr>
+                       <tr>
+                               <td>726</td>
+                               <td>0x30</td>
+                               <td>48</td>
+                               <td>R71</td>
+                               <td>0x1A</td>
+                               <td>26</td>
+                       </tr>
+                       <tr>
+                               <td>735</td>
+                               <td>0x04</td>
+                               <td>4</td>
+                               <td>R72</td>
+                               <td>0x32</td>
+                               <td>50</td>
+                       </tr>
+                       <tr>
+                               <td>746</td>
+                               <td>0x66</td>
+                               <td>102</td>
+                               <td>R75</td>
+                               <td>0x5a</td>
+                               <td>90</td>
+                       </tr>
+                       <tr>
+                               <td>751</td>
+                               <td>0x1c</td>
+                               <td>28</td>
+                               <td>R7000</td>
+                               <td>0x08</td>
+                               <td>8</td>
+                       </tr>
+                       <tr>
+                               <td>756PROII</td>
+                               <td>0x64</td>
+                               <td>100</td>
+                               <td>R7100</td>
+                               <td>0x34</td>
+                               <td>52</td>
+                       </tr>
+                       <tr>
+                               <td>761</td>
+                               <td>0x1e</td>
+                               <td>30</td>
+                               <td>R8500</td>
+                               <td>0x4a</td>
+                               <td>74</td>
+                       </tr>
+                       <tr>
+                               <td>765</td>
+                               <td>0x2c</td>
+                               <td>44</td>
+                               <td>R9000</td>
+                               <td>0x2a</td>
+                               <td>42</td>
+                       </tr>
+               </table>
+               <h4 id="setup">Setup and Debugging Aids</h4>
+               <p>The audio drivers include extensive setup and debugging support to help hook up the audio signals and monitor the driver operations. The documentation page for each driver describes the various messages that can be produced either in real time or written to the <tt>clockstats</tt> file for later analysis. Of particular help in verifying signal connections and compatibility is a provision to monitor the signal via headphones or speaker.</p>
+               <p>Connecting radios and IRIG devices to the computer and verifying correct configuration is somewhat of a black art. The signals have to be connected to the correct ports and the signal level maintained within tolerances. Some radios have recorder outputs which produce a line level signal not affected by the volume control. These signals can be connected to the line-in port on the computer. If the level is too low, connect to the microphone-in port instead. If the radio does not have a recorder output, connect the headphone or speaker output to the line-in port and adjust the volume control so the driver indicates comfortably above the minimum specified and the AGC level somewhere in the middle of the range 0-255. IRIG signals are usually much larger than radio outputs, usually in the range to several volts and may even overload the line-in port. In such cases an attenuator must be used to reduce the signal level below the overload point.</p>
+               <p>It is very easy to underdrive or overdrive the audio codec, in which case the drivers will not synchronize to the signal. The drivers use <tt>fudge flag2</tt> to enable audio monitoring of the input signal. This is useful during setup to confirm the signal is actually reaching the audio codec and generally free of hum and interference. This feature is not intended for regular use, since it does increase the processor load on the system. Note that the speaker volume must be set before the driver is started.</p>
+               <p>The drivers write a synthesized timecode to the <tt>clockstats</tt> file each time the clock is set or verified and at other times if verbose monitoring is enabled. The format includes several fixed-length fields defining the UTC time to the millisecond, together with additional variable-length fields specific to each driver. The data include the intervals since the clock was last set or verified, the audio gain and various state variables and counters specific to each driver.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/authopt.html b/html/authopt.html
new file mode 100644 (file)
index 0000000..5f67b3c
--- /dev/null
@@ -0,0 +1,155 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Authentication Options</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Authentication Options</h3>
+               <img src="pic/alice44.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>Our resident cryptographer; now you see him, now you don't.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">01:29</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="338">Wednesday, September 13, 2006</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links9.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#auth">Authentication Support</a>
+                       <li class="inline"><a href="#symm">Symmetric Key Cryptography</a>
+                       <li class="inline"><a href="#pub">Public Key Cryptography</a>
+                       <li class="inline"><a href="#cfg">Configuration</a>
+                       <li class="inline"><a href="#inter">Operation</a>
+                       <li class="inline"><a href="#key">Key Management</a>
+                       <li class="inline"><a href="#cmd">Authentication Commands</a>
+                       <li class="inline"><a href="#err">Error Codes</a>
+                       <li class="inline"><a href="#file">Files</a>
+               </ul>
+               <hr>
+               <h4 id="auth">Authentication Support</h4>
+               <p>Authentication support allows the NTP client to verify that the server is in fact known and trusted and not an intruder intending accidentally or on purpose to masquerade as that server. The NTPv3 specification RFC-1305 defines a scheme which provides cryptographic authentication of received NTP packets. Originally, this was done using the Data Encryption Standard (DES) algorithm operating in Cipher Block Chaining (CBC) mode, commonly called DES-CBC. Subsequently, this was replaced by the RSA Message Digest 5 (MD5) algorithm using a private key, commonly called keyed-MD5. Either algorithm computes a message digest, or one-way hash, which can be used to verify the server has the correct private key and key identifier.</p>
+               <p>NTPv4 retains the NTPv3 scheme, properly described as symmetric key cryptography, and, in addition, provides a new Autokey scheme based on public key cryptography. Public key cryptography is generally considered more secure than symmetric key cryptography, since the security is based on a private value which is generated by each host and never revealed. With the exception of the group key described later, all key distribution and management functions involve only public values, which considerably simplifies key distribution and storage. Public key management is based on X.509 certificates, which can be provided by commercial services or produced by utility programs in the OpenSSL software library or the NTPv4 distribution.</p>
+               <p>While the algorithms for symmetric key cryptography are included in the NTPv4 distribution, public key cryptography requires the OpenSSL software library to be installed before building the NTP distribution. This library is available from <a href="http://www.openssl.org">http://www.openssl.org</a> and can be installed using the procedures outlined in the <a href="build/build.html">Building and Installing the Distribution</a> page. Once installed, the configure and build process automatically detects the library and links the library routines required.</p>
+               <p>Authentication is configured separately for each association using the <tt>key</tt> or <tt>autokey</tt> subcommand on the <tt>peer</tt>, <tt>server</tt>, <tt>broadcast</tt> and <tt>manycastclient</tt> configuration commands as described in the <a href="confopt.html">Configuration Options</a> page. The authentication options described below specify the locations of the key files, if other than default, which symmetric keys are trusted and the interval between various operations, if other than default.</p>
+               <p>Authentication is always enabled, although ineffective if not configured as described below. If a NTP packet arrives including a message authentication code (MAC), it is accepted only if it passes all cryptographic checks. The checks require correct key ID, key value and message digest. If the packet has been modified in any way or replayed by an intruder, it will fail one or more of these checks and be discarded. Furthermore, the Autokey scheme requires a preliminary protocol exchange to obtain the server certificate, verify its credentials and initialize the protocol</p>
+               <p>The <tt>auth</tt> flag controls whether new associations or remote configuration commands require cryptographic authentication. This flag can be set or reset by the <tt>enable</tt> and <tt>disable</tt> commands and also by remote configuration commands sent by a <tt>ntpdc</tt> program running on another machine. If this flag is enabled, which is the default case, new broadcast/manycast client and symmetric passive associations and remote configuration commands must be cryptographically authenticated using either symmetric key or public key cryptography. If this flag is disabled, these operations are effective even if not cryptographic authenticated. It should be understood that operating with the <tt>auth</tt> flag disabled invites a significant vulnerability where a rogue hacker can masquerade as a truechimer and seriously disrupt system timekeeping. It is important to note that this flag has no purpose other than to allow or disallow a new association in response to new broadcast and symmetric active messages and remote configuration commands and, in particular, the flag has no effect on the authentication process itself.</p>
+               <p>The security model and protocol schemes for both symmetric key and public key cryptography are summarized below; further details are in the briefings, papers and reports at the NTP project page linked from <a href="http://www.ntp.org">www.ntp.org</a>.</p>
+               <h4 id="symm">Symmetric Key Cryptography</h4>
+               
+               The original RFC-1305 specification allows any one of possibly 65,534 keys, each distinguished by a 32-bit key identifier, to authenticate an association. The servers and clients involved must agree on the key and key identifier to authenticate NTP packets. Keys and related information are specified in a key file, usually called <tt>ntp.keys</tt>, which must be distributed and stored using secure means beyond the scope of the NTP protocol itself. Besides the keys used for ordinary NTP associations, additional keys can be used as passwords for the <tt><a href="ntpq.html">ntpq</a></tt> and <tt><a href="ntpdc.html">ntpdc</a></tt> utility programs. Ordinarily, the <tt>ntp.keys</tt> file is generated by the <tt><a href="keygen.html">ntp-keygen</a></tt> program.
+               <p>When <tt>ntpd</tt> is first started, it reads the key file specified in the <tt>keys</tt> configuration command and installs the keys in the key cache. However, individual keys must be activated with the <tt>trustedkey</tt> command before use. This allows, for instance, the installation of possibly several batches of keys and then activating or deactivating each batch remotely using <tt>ntpdc</tt>. This also provides a revocation capability that can be used if a key becomes compromised. The <tt>requestkey</tt> command selects the key used as the password for the <tt>ntpdc</tt> utility, while the <tt>controlkey</tt> command selects the key used as the password for the <tt>ntpq</tt> utility.</p>
+               <h4 id="pub">Public Key Cryptography</h4>
+               <p>NTPv4 supports the original NTPv3 symmetric key scheme described in RFC-1305 and in addition the Autokey protocol, which is based on public key cryptography. The Autokey Version 2 protocol described on the <a href="http://www.eecis.udel.edu/%7emills/proto.html">Autokey Protocol</a> page verifies packet integrity using MD5 message digests and verifies the source with digital signatures and any of several digest/signature schemes. Optional identity schemes described on the <a href="http://www.eecis.udel.edu/%7emills/ident.html">Identity Schemes</a> page and based on cryptographic challenge/response algorithms are also available. Using these schemes provides strong security against replay with or without modification, spoofing, masquerade and most forms of clogging attacks.</p>
+               <p>The Autokey protocol has several modes of operation corresponding to the various NTP modes supported. Most modes use a special cookie which can be computed independently by the client and server, but encrypted in transmission. All modes use in addition a variant of the S-KEY scheme, in which a pseudo-random key list is generated and used in reverse order. These schemes are described along with an executive summary, current status, briefing slides and reading list on the <a href="http://www.eecis.udel.edu/%7emills/autokey.html">Autonomous Authentication</a> page.</p>
+               <p>The specific cryptographic environment used by Autokey servers and clients is determined by a set of files and soft links generated by the <a href="keygen.html"><tt>ntp-keygen</tt></a> program. This includes a required host key file, required host certificate file and optional sign key file, leapsecond file and identity scheme files. The digest/signature scheme is specified in the X.509 certificate along with the matching sign key. There are several schemes available in the OpenSSL software library, each identified by a specific string such as <tt>md5WithRSAEncryption</tt>, which stands for the MD5 message digest with RSA encryption scheme. The current NTP distribution supports all the schemes in the OpenSSL library, including those based on RSA and DSA digital signatures.</p>
+               <p>NTP secure groups can be used to define cryptographic compartments and security hierarchies. It is important that every host in the group be able to construct a certificate trail to one or more trusted hosts in the same group. Each group host runs the Autokey protocol to obtain the certificates for all hosts along the trail to one or more trusted hosts. This requires the configuration file in all hosts to be engineered so that, even under anticipated failure conditions, the NTP&nbsp;subnet will form such that every group host can find a trail to at least one trusted host.</p>
+               <h4>Naming and Addressing</h4>
+               <p>It is important to note that Autokey does not use DNS&nbsp;to resolve addresses, since DNS can't be completely trusted until the name servers have synchronized clocks. The cryptographic name used by Autokey to bind the host identity credentials and cryptographic values must be independent of interface, network and any other naming convention. The name appears in the host certificate in either or both the subject and issuer fields, so protection against DNS&nbsp;compromise is essential.</p>
+               <p>By convention, the name of an Autokey host is the name returned by the Unix <tt>gethostname()</tt> system call or equivalent in other systems. By the system design model, there are no provisions to allow alternate names or aliases. However, this is not to say that DNS&nbsp;aliases, different names for each interface, etc., are constrained in any way.</p>
+               <p>It is also important to note that Autokey verifies authenticity using the host name, network address and public keys, all of which are bound together by the protocol specifically to deflect masquerade attacks. For this reason Autokey includes the source and destinatino IP&nbsp;addresses in message digest computations and so the same addresses must be available at both the server and client. For this reason operation with network address translation schemes is not possible. This reflects the intended robust security model where government and corporate NTP&nbsp;servers are operated outside firewall perimeters.</p>
+               <h4 id="cfg">Configuration</h4>
+               <p>Autokey has an intimidating number of options, most of which are not necessary in typical scenarios. The simplest configuration consists of a subnet with one or more servers at the same low stratum acting as trusted hosts and with dependent clients at higher strata and sharing a single secure group and identity scheme. Each trusted host generates a host key, trusted certificate and group key. Each client generates a host key, normal certificate and installs the group key of each trusted host using secure means and renames it as the name of the trusted host.</p>
+               <p>For example, trusted host Alice generates keys using</p>
+               <p><tt>ntp-keygen -H -T -I -p xyz</tt></p>
+               <p>where H specifies a new host key, T the trusted certificate, I&nbsp;the IFF&nbsp;identity scheme and p the password used to encrypt the private key files. The group key file  is <tt>ntpkey_IFFpar_alice.<i>filestamp</i></tt><i>, </i>where <i>filestamp </i>represents the NTP&nbsp;time in seconds when the file was generated.</p>
+               <p>Host Bob generate keys using</p>
+               <p><tt>ntp-keygen -H -p abc</tt></p>
+               <p>where <tt>abc</tt> is different for each group host. The trusted host generates a password-protected group key using</p>
+               <p><tt>ntp-keygen -q xyz -p abc -e &gt;<i>temp</i></tt></p>
+               <p>where <tt>xyz</tt> is the trusted host password, <tt>abc</tt> is the password supplied by the client and <i><tt>temp</tt></i> is a temporary file. This file is transmitted to Bob using secure means and renamed to the fully qualified host name for Alice preceded by the string <tt>ntpkey_iff_</tt>.</p>
+               <h4>Operation</h4>
+               <p>A specific combination of authentication scheme (none, symmetric key, public key) and identity scheme is called a cryptotype, although not all combinations are compatible. There may be management configurations where the clients, servers and peers may not all support the same cryptotypes. A secure NTPv4 subnet can be configured in many ways while keeping in mind the principles explained above and in this section. Note however that some cryptotype combinations may successfully interoperate with each other, but may not represent good security practice.</p>
+               <p>The cryptotype of an association is determined at the time of mobilization, either at configuration time or some time later when a message of appropriate cryptotype arrives. When mobilized by a <tt>server</tt> or <tt>peer</tt> configuration command and no <tt>key</tt> or <tt>autokey</tt> subcommands are present, the association is not authenticated; if the <tt>key</tt> subcommand is present, the association is authenticated using the symmetric key ID specified; if the <tt>autokey</tt> subcommand is present, the association is authenticated using Autokey.</p>
+               <h4 id="key">Key Management</h4>
+               <p>The cryptographic values used by the Autokey protocol are incorporated as a set of files generated by the <a href="keygen.html"><tt>ntp-keygen</tt></a> utility program, including symmetric key, host key and public certificate files, as well as sign key, identity parameters and leapseconds files. Alternatively, host and sign keys and certificate files can be generated by the OpenSSL utilities and certificates can be imported from public certificate authorities. Note that symmetric keys are necessary for the <tt>ntpq</tt> and <tt>ntpdc</tt> utility programs. The remaining files are necessary only for the Autokey protocol.</p>
+               <p>Certificates imported from OpenSSL or public certificate authorities have certian limitations. The certificate should be in ASN.1 syntax, X.509 Version 3 format and encoded in PEM, which is the same format used by OpenSSL. The overall length of the certificate encoded in ASN.1 must not exceed 1024 bytes. The subject distinguished name field (<tt>CN</tt>) is the fully qualified name of the host on which it is used; the remaining subject fields are ignored. The certificate extension fields must not contain either a subject key identifier or a issuer key identifier field; however, an extended key usage field for a trusted host must contain the value <tt>trustRoot</tt>;. Other extension fields are ignored.</p>
+               <h4 id="cmd">Authentication Commands</h4>
+               <dl>
+                       <dt><tt>autokey [<i>logsec</i>]</tt>
+                       <dd>Specifies the interval between regenerations of the session key list used with the Autokey protocol. Note that the size of the key list for each association depends on this interval and the current poll interval. The default value is 12 (4096 s or about 1.1 hours). For poll intervals above the specified interval, a session key list with a single entry will be regenerated for every message sent.
+                       <dt><tt>controlkey <i>key</i></tt>
+                       <dd>Specifies the key identifier to use with the <a href="ntpq.html"><tt>ntpq</tt></a> utility, which uses the standard protocol defined in RFC-1305. The <tt><i>key</i></tt> argument is the key identifier for a trusted key, where the value can be in the range 1 to 65,534, inclusive.
+                       <dt><tt>crypto [cert <i>file</i>] [leap <i>file</i>] [randfile <i>file</i>] [host <i>file</i>] [sign <i>file</i>] [ident <i>scheme</i>] [iffpar <i>file</i>] [gqpar <i>file</i>] [mvpar <i>file</i>] [pw <i>password</i>]</tt>
+                       <dd>This command requires the OpenSSL library. It activates public key cryptography, selects the message digest and signature encryption scheme and loads the required private and public values described above. If one or more files are left unspecified, the default names are used as described above. Unless the complete path and name of the file are specified, the location of a file is relative to the keys directory specified in the <tt>keysdir</tt> command or default <tt>/usr/local/etc</tt>. Following are the subcommands:
+                               <dl>
+                                       <dt><tt>cert <i>file</i></tt>
+                                       <dd>Specifies the location of the required host public certificate file. This overrides the link <tt>ntpkey_cert_<i>hostname</i></tt> in the keys directory.
+                                       
+                                       <dt><tt>gqpar <i>file</i></tt>
+                                       <dd>Specifies the location of the client GQ parameters file. This overrides the link <tt>ntpkey_gq_<i>hostname</i></tt> in the keys directory.
+                                       
+                                       <dt><tt>host <i>file</i></tt>
+                                       <dd>Specifies the location of the required host key file. This overrides the link <tt>ntpkey_key_<i>hostname</i></tt> in the keys directory.
+                                       <dt><tt>ident <i>scheme</i></tt>
+                                       <dd>Requests the server identity <i><tt>scheme</tt></i>, which can be <tt>IFF</tt>, <tt>GQ</tt> or <tt>MV</tt>. This is used when the host will not be a server for a dependent client.<dt><tt>iffpar <i>file</i></tt>
+                                       <dd>Specifies the location of the optional IFF parameters file.This overrides the link <tt>ntpkey_iff_<i>hostname</i></tt> in the keys directory.
+                                       <dt><tt>leap <i>file</i></tt>
+                                       <dd>Specifies the location of the client leapsecond file. This overrides the link <tt>ntpkey_leap</tt> in the keys directory.
+                                       <dt><tt>mv</tt>
+                                       <dd>Requests the MV server identity scheme.
+                                       <dt><tt>mvpar <i>file</i></tt>
+                                       <dd>Specifies the location of the client MV parameters file. This overrides the link <tt>ntpkey_mv_<i>hostname</i></tt> in the keys directory.
+                                       <dt><tt>pw <i>password</i></tt>
+                                       <dd>Specifies the password to decrypt files containing private keys and identity parameters. This is required only if these files have been encrypted.
+                                       <dt><tt>randfile <i>file</i></tt>
+                                       <dd>Specifies the location of the random seed file used by the OpenSSL library. The defaults are described in the main text above.
+                                       <dt><tt>sign <i>file</i></tt>
+                                       <dd>Specifies the location of the optional sign key file. This overrides the link <tt>ntpkey_sign_<i>hostname</i></tt> in the keys directory. If this file is not found, the host key is also the sign key.
+                               </dl>
+                       <dt><tt>keys <i>keyfile</i></tt>
+                       <dd>Specifies the complete path and location of the MD5 key file containing the keys and key identifiers used by <tt>ntpd</tt>, <tt>ntpq</tt> and <tt>ntpdc</tt> when operating with symmetric key cryptography. This is the same operation as the <tt>-k </tt>command line option.
+                       <dt><tt>keysdir <i>path</i></tt>
+                       <dd>This command specifies the default directory path for cryptographic keys, parameters and certificates. The default is <tt>/usr/local/etc/</tt>.
+                       <dt><tt>requestkey <i>key</i></tt>
+                       <dd>Specifies the key identifier to use with the <a href="ntpdc.html"><tt>ntpdc</tt></a> utility program, which uses a proprietary protocol specific to this implementation of <tt>ntpd</tt>. The <tt><i>key</i></tt> argument is a key identifier for the trusted key, where the value can be in the range 1 to 65,534, inclusive.
+                       <dt><tt>revoke [<i>logsec</i>]</tt>
+                       <dd>Specifies the interval between re-randomization of certain cryptographic values used by the Autokey scheme, as a power of 2 in seconds. These values need to be updated frequently in order to deflect brute-force attacks on the algorithms of the scheme; however, updating some values is a relatively expensive operation. The default interval is 16 (65,536 s or about 18 hours). For poll intervals above the specified interval, the values will be updated for every message sent.
+                       <dt><tt>trustedkey <i>key</i> [...]</tt>
+                       <dd>Specifies the key identifiers which are trusted for the purposes of authenticating peers with symmetric key cryptography, as well as keys used by the <tt>ntpq</tt> and <tt>ntpdc</tt> programs. The authentication procedures require that both the local and remote servers share the same key and key identifier for this purpose, although different keys can be used with different servers. The <tt><i>key</i></tt> arguments are 32-bit unsigned integers with values from 1 to 65,534.
+               </dl>
+               <h4 id="err">Error Codes</h4>
+               <p>Errors can occur due to mismatched configurations, unexpected restarts, expired certificates and unfriendly people. In most cases the protocol state machine recovers automatically by retransmission, timeout and restart, where necessary. Some errors are due to mismatched keys, digest schemes or identity schemes and must be corrected by installing the correct media and/or correcting the configuration file. One of the most common errors is expired certificates, which must be regenerated and signed at least once per year using the <tt><a href="keygen.html">ntp-keygen</a></tt> program.</p>
+               <p>The following error codes are reported via the NTP control and monitoring protocol trap mechanism.</p>
+               <dl>
+                       <dt>101 (bad field format or length)
+                       <dd>The packet has invalid version, length or format.
+                       <dt>102 (bad timestamp)
+                       <dd>The packet timestamp is the same or older than the most recent received. This could be due to a replay or a server clock time step.
+                       <dt>103 (bad filestamp)
+                       <dd>The packet filestamp is the same or older than the most recent received. This could be due to a replay or a key file generation error.
+                       <dt>104 (bad or missing public key)
+                       <dd>The public key is missing, has incorrect format or is an unsupported type.
+                       <dt>105 (unsupported digest type)
+                       <dd>The server requires an unsupported digest/signature scheme.
+                       <dt>106 (unsupported identity type)<dd>The client or server has requested an identity scheme the other does not support.<dt>107 (bad signature length)
+                       <dd>The signature length does not match the current public key.
+                       <dt>108 (signature not verified)
+                       <dd>The message fails the signature check. It could be bogus or signed by a different private key.
+                       <dt>109 (certificate not verified)
+                       <dd>The certificate is invalid or signed with the wrong key.<dt>110 (host certificate expired)<dd>The old server certificate has expired.<dt>111 (bad or missing cookie)
+                       <dd>The cookie is missing, corrupted or bogus.
+                       <dt>112 (bad or missing leapseconds table)
+                       <dd>The leapseconds table is missing, corrupted or bogus.
+                       <dt>113 (bad or missing certificate)
+                       <dd>The certificate is missing, corrupted or bogus.
+                       <dt>114 (bad or missing group key)<dd>The identity key is missing, corrupt or bogus.
+               
+                       <dt>115 (protocol error)
+                       <dd>The protocol state machine has wedged due to unexpected restart
+                       <dt>116 (server certificate expired)
+                       <dd>The old server certificate has expired.
+               </dl>
+               <h4 id="file">Files</h4>
+               <p>See the <a href="keygen.html"><tt>ntp-keygen</tt></a> page.</p>
+               <h4 id="leap">Leapseconds Table</h4>
+               <p>The NIST provides a file documenting the epoch for all historic occasions of leap second insertion since 1972. The leapsecond table shows each epoch of insertion along with the offset of International Atomic Time (TAI) with respect to Coordinated Universal Time (UTC), as disseminated by NTP. The table can be obtained directly from NIST national time servers using <tt>ftp</tt> as the ASCII file <tt>pub/leap-seconds</tt>.</p>
+               <p>While not strictly a security function, the Autokey protocol provides means to securely retrieve the leapsecond table from a server or peer. Servers load the leapsecond table directly from the file specified in the <tt>crypto</tt> command, with default <tt>ntpkey_leap</tt>, while clients can obtain the table indirectly from the servers using the Autokey protocol. Once loaded, the table can be provided on request to other clients and servers.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/build/build.html b/html/build/build.html
new file mode 100644 (file)
index 0000000..0bb49af
--- /dev/null
@@ -0,0 +1,83 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta name="generator" content="HTML Tidy, see www.w3.org">
+        <title>Building and Installing the Distribution</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Building and Installing the Distribution</h3>
+        <img src="../pic/beaver.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+        <p>For putting out compiler fires.</p>
+        <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="99">03:06 AM</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="270">Monday, October 13, 2003</csobj></p>
+        <br clear="left">
+        <h4>Related Links</h4>
+        <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+        <h4>Table of Contents</h4>
+        <ul>
+            <li class="inline"><a href="#build">Building and Installing the Distribution</a>
+            <li class="inline"><a href="#unix">Building and Installing under Unix</a>
+            <li class="inline"><a href="#comp">Compilation</a>
+            <li class="inline"><a href="#install">Installation</a>
+            <li class="inline"><a href="#config">Configuration</a>
+            <li class="inline"><a href="#prob">If You Have Problems</a>
+            <li class="inline"><a href="#win">Building and Installing under Windows NT</a>
+        </ul>
+        <hr>
+        <h4 id="build">Building and Installing the Distribution</h4>
+        <p>As a practical matter, every computer architecture and operating system version seems to be different than any other. The device drivers may be different, the input/output system may be idiosyncratic and the libraries may have different semantics. It is not possible in a software distribution such as this one to support every individual system with a common set of binaries, even with the same system but different versions. Therefore, it is necessary to individually configure the software build for each system and version, both at compile time and at run time. In almost all cases, these procedures are completely automatic and all the newbie user need do is type &quot;configure&quot;, &quot;make&quot; and &quot;install&quot; in that order and the autoconfigure system does the rest. There are some exceptions, as noted below and on the <a href="hints.html">Hints and Kinks</a> page.</p>
+        <p>If available, the OpenSSL library from <a href="http://www.openssl.org">http://www.openssl.org</a> is used to support public key cryptography. The library must be built and installed prior to building NTPv4. The procedures for doing that are included in the OpenSSL documentation. The library is found during the normal NTPv4 configure phase and the interface routines compiled automatically. Only the <tt>libcrypto.a</tt> library and associated header files are used. If the library is not available or disabled, this step is not required.</p>
+        <h4 id="unix">Building and Installing under Unix</h4>
+        <p>Make sure that you have all necessary tools for building executables. These tools include <tt>cc/gcc, make, awk, sed, tr, sh, grep, egrep</tt> and a few others. Not all of these tools exist in the standard distribution of modern Unix versions (compilers are likely to be an add-on product). If this is the case, consider using the GNU tools and <tt>gcc</tt> compiler. For a successful build, all of these tools should be accessible via the current path.</p>
+        <p>The first thing to do is uncompress the distribution and extract the source tree. In the distribution base directory use the <tt>./configure</tt> command to perform an automatic configuration procedure. This command inspects the hardware and software environment and tests for the presence of system header files and the contents of these files to determine if certain features are present. When one or more of these features are present, the code is compiled to use them; if not, no special code is compiled. However, even if the code is compiled to use these features, the code does a special test at run time to see if one or more are actually present and avoids using them if not present. In such cases a warning message is sent to the system log, but the daemon should still work properly.</p>
+        <p>The default build normally includes the debugging code, which can be useful in diagnosing problems found in initial test, and all reference clock drivers known to work with each machine and operating system. Unless memory space is at a premium, this is a sensible strategy and greatly simplifies debugging and support. If you need to delete either the debugging code or one or all reference clock drivers to save space, see the <a href="config.html">Configuration Options</a> page.</p>
+        <p>If your site supports multiple architectures and uses NFS to share files, you can use a single source tree to compile executables for all architectures. While running on a target architecture machine and in the distribution base directory create a subdirectory using a command like <tt>mkdir A.`config.guess`</tt>, which will create an architecture-specific directory with name peculiar to the architecture and operating system. Then change to this directory and emit a <tt>../configure</tt> command. The remaining steps are the same whether building in the base directory or in the subdirectory.</p>
+        <h4 id="comp">Compilation</h4>
+        <p>Use the <tt>make</tt> command to compile all source modules, construct the libraries and link the distribution. Expect few or no warnings using <tt>cc</tt> and a moderate level of warnings using <tt>gcc</tt>. Note: On some Unix platforms <tt>gcc</tt> may show quite a few complaints about system header files and type inconsistencies, especially with pointer variables. This is usually the case when the system header files are not up to ANSI standards or <tt>gcc </tt>expectations, when <tt>gcc</tt> is not installed properly, or when operating system updates and patches are applied and <tt>gcc</tt> is not reinstalled. While the autoconfigure process is quite thorough, the Unix programming cultures of the various workstation makers still remain idiosyncratic.</p>
+        <h4 id="install">Installation</h4>
+        <p>As root, use the <tt>make install</tt> command to install the binaries in the destination directory. Most commonly, these programs are installed in <tt>/usr/local/bin</tt>, but this can be overridden during configuration. You must of course have write permission on the install in the destination directory. This includes the following programs:</p>
+        <ul>
+            <li><a href="../ntpd.html"><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</a>
+            <li><a href="../ntpq.html"><tt>ntpq</tt> - standard NTP query program</a>
+            <li><a href="../ntpdc.html"><tt>ntpdc</tt> - special NTP query program</a>
+            <li><a href="../ntpdate.html"><tt>ntpdate</tt> - set the date and time via NTP</a>
+            <li><a href="../ntptrace.html"><tt>ntptrace</tt> - trace a chain of NTP servers back to the primary source</a>
+        </ul>
+        <p>If the precision time kernel modifications are present, the following program is installed:</p>
+        <ul>
+            <li><a href="../ntptime.html"><tt>ntptime</tt> - read kernel time variables</a>
+        </ul>
+        <p>If the public key authentication functions are present, the following program is installed:</p>
+        <ul>
+            <li><a href="../keygen.html"><tt>ntp-keygen</tt> - generate public and private keys</a>
+        </ul>
+        <p>In some systems that include the capability to edit kernel variables, the following program is installed:</p>
+        <ul>
+            <li><a href="../tickadj.html"><tt>tickadj</tt> - set time-related kernel variables</a>
+        </ul>
+        <p>Cryptographic support, both symmetric and public key, requires one or more key files, commonly installed in <tt>/usr/local/etc</tt>. Public key cryptography requires a random seed file, usually called <tt>.rnd</tt>, installed in a dark place such as the root directory or <tt>/etc</tt>. Directions for generating keys is on the <a href="../authopt.html">Authentication Options</a> page.</p>
+        <h4 id="config">Configuration</h4>
+        <p>You are now ready to configure the daemon and start it. You will need to create a NTP configuration file <tt>ntp.conf</tt> and a cryptographic key file <tt>ntp.keys</tt>. The latter file is necessary only for remote configuration support, if needed. Newbies should see the <a href="quick.html">Quick Start</a> page for orientation. Seasoned veterans can start with the <a href="../ntpd.html"><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</a> page and move on to the specific configuration option pages from there. A tutorial on NTP subnet design and configuration options is in the <a href="../notes.html">Notes on Configuring NTP and Setting up a NTP Subnet</a> page.</p>
+        <h4 id="prob">If You Have Problems</h4>
+        <p>If you have problems peculiar to the particular hardware and software environment (e.g. operating system-specific issues), browse the <a href="hints.html">Hints and Kinks</a> page. For other problems a tutorial on debugging technique is in the <a href="../debug.html">NTP Debugging Technique</a> page. As always, the first line of general assistance is the NTP web site <a href="http://www.ntp.org">www.ntp.org</a> and the FAQ resident there. Requests for assistance of a general nature and of interest to other timekeepers should be sent to the NTP newsgroup comp.protocols.time.ntp. Bug reports of a specific nature should be sent to <a href="mailto:bugs@mail.ntp.org">bugs@ntp.org</a>. Bug reports of a specific nature on features implemented by the programmer corps mentioned in the <a href="../copyright.html">Copyright</a> page should be sent directly to the implementor listed in that page, with copy to bugs@ntp.org.</p>
+        <p>Please include the version of the source distribution (e.g., ntp-4.0.70a) in your bug report, as well as billboards from the relevant utility programs and debug trace, if available. Please include the output of <tt>config.guess</tt> in your bug report. It will look something like:</p>
+        <p><tt>pdp11-dec-fuzzos3.4</tt></p>
+        <h4>Additional <tt>make</tt> commands</h4>
+        <dl>
+            <dt><tt>make clean</tt>
+            <dd>Cleans out object files, programs and temporary files.
+            <dt><tt>make distclean</tt>
+            <dd>Does the work of <tt>clean</tt>, but cleans out all directories in preparation for a new distribution release.
+            <dt><tt>make dist</tt>
+            <dd>Does the work of <tt>make distclean</tt>, but constructs compressed tar files for distribution. You must have GNU automake to perform this function.
+        </dl>
+        <h4 id="win">Building and Installing under Windows NT</h4>
+        <p>See <tt><a href="hints/winnt.html">hints/winnt.htm</a></tt> for directions to compile the sources and install the executables.</p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/build/config.html b/html/build/config.html
new file mode 100644 (file)
index 0000000..961779d
--- /dev/null
@@ -0,0 +1,168 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta name="generator" content="HTML Tidy, see www.w3.org">
+        <title>Configuration Options</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Configuration Options</h3>
+        <img src="../pic/pogo3a.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+        <p>Gnu autoconfigure tools are in the backpack.</p>
+        <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="99">12:56 AM</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="266">Saturday, March 20, 2004</csobj></p>
+        <br clear="left">
+        <h4>Table of Contents</h4>
+        <ul>
+            <li class="inline"><a href="#basic">Basic Configuration Options - the <tt>configure</tt> utility</a>
+            <li class="inline"><a href="#opt">Options</a>
+            <li class="inline"><a href="#dir">Directory and File Names</a>
+            <li class="inline"><a href="#host">Host Type</a>
+            <li class="inline"><a href="#pkg">Optional Packages</a>
+            <li class="inline"><a href="#feat">Optional Features</a>
+            <li class="inline"><a href="#radio">Radio Clocks</a>
+            <li class="inline"><a href="#parse">PARSE Clocks</a>
+        </ul>
+        <hr>
+        <h4 id="basic">Basic Configuration Options - the <tt>configure</tt> utility</h4>
+        <p>The following options are for compiling and installing a working version of the NTP distribution. In most cases, the build process is completely automatic. In some cases where memory space is at a premium, or the binaries are to be installed in a different place, it is possible to tailor the configuration to remove such features as reference clock driver support, debugging support, and so forth.</p>
+        <p>Configuration options are specified as arguments to the <tt>configure</tt> script. Following is a summary of the current options, as of the 4.0.99m version:</p>
+        <p>Usage: <tt>configure [options] [host]</tt><br>
+        </p>
+        <h4 id="opt">Options</h4>
+        <p><tt>[defaults in brackets after descriptions]</tt> Configuration:</p>
+        <pre>
+ --cache-file=FILE      cache test results in FILE
+ --help                 print this message
+ --no-create            do not create output files
+ --quiet, --silent      do not print `checking...' messages
+ --version              print the version of autoconf that created
+configure
+</pre>
+        <h4 id="dir">Directory and File Names</h4>
+        <pre>
+ --prefix=PREFIX        install architecture-independent files in PREFIX [/usr/local]
+ --exec-prefix=EPREFIX  install architecture-dependent files in EPREFIX [same as prefix]
+ --bindir=DIR           user executables in DIR [EPREFIX/bin]
+ --sbindir=DIR          system admin executables in DIR [EPREFIX/sbin]
+ --libexecdir=DIR       program executables in DIR [EPREFIX/libexec]
+ --datadir=DIR          read-only architecture-independent data in DIR [PREFIX/share]
+ --sysconfdir=DIR       read-only single-machine data in DIR [PREFIX/etc]
+ --sharedstatedir=DIR   modifiable architecture-independent data in DIR [PREFIX/com]
+ --localstatedir=DIR    modifiable single-machine data in DIR [PREFIX/var]
+ --libdir=DIR           object code libraries in DIR [EPREFIX/lib]
+ --includedir=DIR       C header files in DIR [PREFIX/include]
+ --oldincludedir=DIR    C header files for non-gcc in DIR [/usr/include]
+ --infodir=DIR          info documentation in DIR [PREFIX/info]
+ --mandir=DIR           man documentation in DIR [PREFIX/man]
+ --srcdir=DIR           find the sources in DIR [configure dir or ..]
+ --x-includes=DIR       X include files are in DIR
+ --x-libraries=DIR      X library files are in DIR
+ --program-prefix=PREFIX           prepend PREFIX to installed program names
+ --program-suffix=SUFFIX           append SUFFIX to installed program names
+ --program-transform-name=PROGRAM  run sed PROGRAM on installed program names
+</pre>
+        <h4 id="host">Host Type</h4>
+        <pre>
+ --build=BUILD          configure for building on BUILD [BUILD=HOST]
+ --host=HOST            configure for HOST [guessed]
+ --target=TARGET        configure for TARGET [TARGET=HOST]
+</pre>
+        <h4 id="pkg">Optional Packages</h4>
+        <pre>
+ --with-PACKAGE[=ARG]   use PACKAGE [ARG=yes]
+ --without-PACKAGE      do not use PACKAGE (same as --with-PACKAGE=no)
+
+ openssl-libdir=DIR     OpenSSL object code libraries in DIR [/usr/lib/usr/local/lib/usr/local/ssl/lib]
+ openssl-incdir=DIR     OpenSSL header files in DIR [/usr/include/usr/local/include/usr/local/ssl/include]
+ crypto=autokey         Use autokey cryptography
+ crypto=rsaref          Use the RSAREF library
+ electricfence          Compile with ElectricFence malloc debugger
+</pre>
+        <h4 id="feat">Optional Features</h4>
+        <pre>
+ --disable-FEATURE      do not include FEATURE (same as
+ --enable-FEATURE=no)
+ --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
+
+ accurate-adjtime       The adjtime() call is accurate
+ clockctl               use /dev/clockctl (non root control of system clock)
+ debugging              Include debugging code [enable]
+ des                    Include support for DES keys [enable]
+ dst-minutes=VALUE      Minutes per DST adjustment [60]
+ gdt-surveying          Include GDT survey code [disable]
+ hourly-todr-sync       If we should sync TODR hourly
+ kernel-fll-bug         If we should avoid a (Solaris) kernel FLL bug
+ kmem                   Read /dev/kmem for 'tick' and/or 'tickadj'
+ md5                    Include support for MD5 keys [enable]
+ ntpdate-step           If ntpdate should step the time
+ slew-always            Always slew the time
+ step-slew              Step and slew the time
+ tick=VALUE             Force a value for 'tick'
+ tickadj=VALUE          Force a value for 'tickadj'
+ udp-wildcard           Use UDP wildcard delivery
+</pre>
+        <h4 id="radio">Radio Clocks</h4>
+        <p>(these are ordinarily enabled, if supported by the machine and operating system):</p>
+        <pre>
+ all-clocks             Include drivers for all suitable non-PARSE clocks [enable]
+ ACTS                   NIST dialup clock
+ ARBITER                Arbiter 1088A/B GPS receiver
+ ARCRON_MSF             Arcron MSF receiver
+ AS2201                 Austron 2200A or 2201A GPS receiver
+ ATOM                   ATOM PPS interface
+ AUDIO-CHU              CHU audio decoder
+ BANCOMM                Datum/Bancomm BC635/VME interface (requires an explicit --enable-BANCOMM request)
+ CHRONOLOG              Chrono-log K-series WWVB receiver
+ CHU                    CHU modem decoder
+ DATUM                  Datum Programmable Time System
+ DUMBCLOCK              Dumb generic hh:mm:ss local clock
+ FG                     Forum Graphic GPS
+ GPSVME                 TrueTime GPS receiver with VME interface (requires an explicit --enable-GPSVME request)
+ HEATH                  HeathKit GC-1000 Most Accurate Clock
+ HOPFPCI                HOPF 6039 PCI board
+ HOPFSERIAL             HOPF serial clock device
+ HPGPS                  HP 58503A GPS Time &amp; Frequency receiver
+ IRIG                   IRIG (Audio) Clock
+ JUPITER                Rockwell Jupiter GPS receiver
+ LEITCH                 Leitch CSD 5300 Master Clock System Driver
+ LOCAL-CLOCK            Local clock driver
+ MSFEES                 EES M201 MSF receiver
+ MX4200                 Magnavox MX4200 GPS receiver
+ NMEA                   NMEA GPS receiver
+ ONCORE                 Motorola VP/UT Oncore GPS receiver
+ PALISADE               Palisade clock
+ PCF                    Conrad parallel port radio clock
+ PST                    PST/Traconex 1020 WWV/H receiver
+ PTBACTS                PTB dialup clock support
+ SHM                    Clock attached through shared memory (requires an explicit --enable-SHM request)
+ SPECTRACOM             Spectracom 8170/Netclock/2 WWVB receiver
+ TRAK                   TRAK 8810 GPS station clock
+ TPRO                   KSI/Odetics TPRO/S IRIG Interface
+ TRUETIME               Kinemetrics/TrueTime (generic) receiver
+ ULINK                  Ultralink WWVB receiver
+ USNO                   US Naval Observatory dialup clock
+ WWV                    WWV audio receiver
+</pre>
+        <h4 id="parse">PARSE Clocks</h4>
+        <pre>
+ parse-clocks           Include drivers for all suitable PARSE clocks [enable]
+ COMPUTIME              Diem Computime Radio Clock
+ DCF7000                ELV/DCF7000 Clock
+ HOPF6021               HOPF 6021 Radio Clock support
+ MEINBERG               Meinberg clocks
+ RAWDCF                 DCF77 raw time code
+ RCC8000                RCC 8000 Radio Clock support
+ SCHMID                 SCHMID DCF77 clock support
+ TRIMTAIP               Trimble GPS/TAIP Protocol
+ TRIMTSIP               Trimble GPS/TSIP Protocol
+ VARITEXT               VARITEXT clock
+ WHARTON                Wharton 400A Series clock
+</pre>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/build/hints.html b/html/build/hints.html
new file mode 100644 (file)
index 0000000..b9e230b
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <title>Hints and Kinks</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Hints and Kinks</h3>
+        <img src="../pic/alice35.gif" align="left" alt="gif"><a href="http://www.eecis.udel.edu/%7emills/pictures.html"> from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+        <p>Mother in law has all the answers.</p>
+        <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="99">12:56 AM</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="266">Saturday, March 20, 2004</csobj></p>
+        <br clear="left">
+        <hr>
+        <p>This is an index for a set of troubleshooting notes contained in individual text files in the <tt>./hints</tt> directory. They were supplied by various volunteers in the form of mail messages, patches or just plain word of mouth. Each note applies to a specific computer and operating system and gives information found useful in setting up the NTP distribution or site configuration. The notes are very informal and subject to errors; no attempt has been made to verify the accuracy of the information contained in them.</p>
+        <p>Additions or corrections to this list or the information contained in the notes is solicited. The most useful submissions include the name of the computer manufacturer (and model numbers where appropriate), operating system (specific version(s) where appropriate), problem description, problem solution and submitter's name and electric address. If the submitter is willing to continue debate on the problem, please so advise. See the <a href="hints/">directory listing</a>.</p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/build/hints/a-ux b/html/build/hints/a-ux
new file mode 100644 (file)
index 0000000..f8c26d2
--- /dev/null
@@ -0,0 +1,195 @@
+-------------
+INTRODUCTION:
+-------------
+Last revision:  06-Jul-1994
+
+Included in this distribution of XNTP V3 is a configuration file suitable
+for use under Apple's A/UX Version 3.x.x  There is also one for A/UX 2.0.1
+but it has not been fully tested. To make the executables follow the steps
+outlined below.
+
+*** NOTE:  You must have gcc installed to successfully compile the current
+distribution; the native cc supplied with A/UX will NOT correctly compile
+this source.  See the FAQ in comp.unix.aux for places to obtain gcc from
+and how to install it.
+
+----------------------
+MAKING XNTPD FOR A/UX:
+----------------------
+
+First, you need to create the makefiles (after you've downloaded the
+source, of course):
+
+    % make clean
+    % make refconf
+
+After that, you should edit Config.local to make sure that BINDIR is
+correct for where you wish the programs to be "installed". The default
+(and what I use) is /usr/local/etc. Make sure that DEFS_LOCAL and
+CLOCKDEFS are commented out! Presently, only the LOCAL_CLOCK/REFCLOCK
+clock is used and supported.
+
+
+After this is done (you should be told that your system is A/UX 3), make
+'xntpd' (the options to 'gcc' are held in compilers/aux3.gcc):
+
+    % make
+
+I do not normally use the `make install' option and so have not verified its
+compatibility with A/UX.  Rather, I pull out each of the executables and
+place them in the locally appropriate locations.
+
+---------------
+STARTING XNTPD:
+---------------
+
+At this point you need to set things up so that 'xntpd' is started upon
+boot-up. You can do this in 1 of 2 ways: either add entries in /etc/inittab
+or, more ideally, create and use an /etc/rc.local file. Since rc.local is
+what I recommend, here's how you do it:
+
+By default, A/UX doesn't have rc.local, so you'll need to add the following to
+/etc/inittab:
+
+    net6:2:wait:/etc/syslogd           # set to "wait" to run a syslog daemon
++   jmj0:2:wait:/etc/rc.local 1>/dev/syscon 2>&1       # Local stuff
+    dbg2::wait:/etc/telinit v  # turn off init's verbose mode
+
+Now, the look of a sample /etc/rc.local is as follows:
+
+    #!/bin/sh
+    :
+    : rc.local
+    :
+    #  @(#)Copyright Apple Computer 1987       Version 1.17 of rc.sh on 91/11/08 15:56:21 (ATT 1.12)
+    
+    
+    #  Push line discipline/set the device so it will print
+    /etc/line_sane 1
+    echo " "
+    echo "Entering rc.local..."
+    
+    set `/bin/who -r`
+    if [ "$7" = 2 ]
+    then
+        /bin/echo " now setting the time..."
+        /usr/local/etc/ntpdate -s -b <host.domain>
+        sleep 5
+    #
+    # start up 'xntpd' if we want
+    #
+        if [ -f /etc/ntp.conf ]
+        then
+       /bin/echo " setting tick and tickadj..."
+       /usr/local/etc/tickadj -t 16672 -a 54
+       sleep 5
+       /bin/echo " starting xntpd..."
+       /usr/local/etc/xntpd <&- > /dev/null 2>&1
+       sleep 5
+        fi
+    #
+    fi
+    
+    echo "Leaving rc.local..."
+
+There are a few things to notice about the above:
+
+    o When run, 'ntpdate' forces your clock to the time returned by the
+      host(s) specified by <host.domain> (you'll need to replace this
+      be the IP address(es) of your timehosts. This is good since it gets
+      things close to start off with. You can use more than one time
+      server.
+
+    o 'tickadj' is also called. This does two things: changes the
+      default value of 'tick' (which the the amount of time, in ms, that
+      is added to the clock every 1/60 seconds) and changes the value
+      of 'tickadj' which the the amount that is added or subtracted
+      from 'tickadj' when adjtime() is called.
+
+      Now Mac clocks are pretty bad and tend to be slow. Sooo, instead of
+      having A/UX add the default of 16666ms every 1/60th of a second, you
+      may want it to add more (or less) so that it keeps better time. The
+      above value works for me but your "best" value may be different and
+      will likely require some fooling around to find the best value. As a
+      general rule of thumb, if you see 'xntpd' make a lot of negative clock
+      adjustments, then your clock is fast and you'll need to _decrease_
+      the value of 'tick'. If your adjustments are positive, then you need
+      to increase 'tick'. To make a guess on how fast/slow your clock is,
+      use 'ntpdate' to sync your clock. Now watch 'xntpd' and see how it
+      operates. If, for example, it resets your clock by 1 second every 30
+      minutes, then your clock is (1/(30*60)) is about 0.056% off and you'll
+      need to adjust 'tick' by 16666*0.00056 or about 9 (i.e. 'tick' should
+      be ~16675 if slow or ~16657 if fast)
+
+      A/UX's default value of 'tickadj' is 1666 which is too big for
+      'xntpd'... so it also needs to be adjusted. I like using larger
+      values then the recommended value of 9 for 'tickadj' (although not
+      anything near as big as 1666) since this allows for quick slews
+      when adjusting the clock. Even with semi-large values of 'tickadj'
+      (~200), getting 5ms (1/200 s) accuracy is easy.
+
+
+Finally, before A/UX and 'xntpd' will work happily together, you need to
+patch the kernel. This is due to the fact that A/UX attempts to keep the
+UNIX-software clock and the Mac-hardware clock in sync. Neither the h/w or
+the s/w clock are too accurate. Also, 'xntpd' will be attempting to adjust
+the software clock as well, so having A/UX muck around with it is asking
+for headaches. What you therefore need to do is tell the kernel _not_ to
+sync the s/w clock with the h/w one. This is done using 'adb'. The
+following is a shell script that will do the patch for you:
+
+    #! /bin/sh
+    adb -w /unix <<!
+    init_time_fix_timeout?4i
+    init_time_fix_timeout?w 0x4e75
+    init_time_fix_timeout?4i
+    $q
+    !
+
+This must be done _every_ time you create a new kernel (via newconfig or
+newunix) or else 'xntpd' will go crazy.
+
+--------
+HISTORY:
+--------
+
+John Dundas was the original porter of 'xntpd' and a lot of the additions
+and A/UX-ports are from him. I got involved when I wanted to run 'xntpd'
+on jagubox. It was also around this time that the base-patchlevel of
+'xntpd' changed relatively (the so-called "jones" version). Since then,
+I've been maintaining 'xntpd' for A/UX for the xntp development team
+
+The original kernel patch (which patched 'time_fix_timeout') was from
+Richard Todd. I suggest patching 'init_time_fix_timeout' which prevents
+'time_fix_timeout' from even being called.
+
+----------------
+TECHNICAL NOTES:
+----------------
+
+    o As configured (see machines/aux3), 'xntpd' will log messages via syslogd
+      using the LOC_LOCAL1 facility. I would suggest the following in
+      /etc/syslog.conf:
+
+       local1.notice           /usr/adm/ntpd-syslog
+
+    o As mentioned above, the clocks on A/UX and Macs are kinda bad. Not
+      only that, but logging in and out of the MacOS mode as well as
+      extensive floppy use causes A/UX to drop and lose clock interupts
+      (these are sent every 1/60th of a second). So, if you do these
+      activities a lot, you find out that you lose about 300ms of time
+      (i.e., you become 300ms slow). 'xntpd' default way of handling this
+      is to called 'settimeofday()' and step the clock to the correct
+      time. I prefer having 'xntpd' slew the clock back into line by
+      making gradual adjustments to the clock over a coupla minutes
+      or so. It's for this reason that SLEWALWAYS is defined in
+      include/ntp_machine.h for SYS_AUX3. It's also for this reason than
+      I like larger values of 'tickadj'.
+
+Good luck!  If you have problems under A/UX feel free to contact me (e-mail
+is preferred).
+--
+    Jim Jagielski               |  "That is no ordinary rabbit... 'tis the
+    jim@jagubox.gsfc.nasa.gov   |   most foul, cruel and bad-tempered
+    NASA/GSFC, Code 734.4       |   rodent you ever set eyes on"
+    Greenbelt, MD 20771         |                   Tim the Enchanter
diff --git a/html/build/hints/aix b/html/build/hints/aix
new file mode 100644 (file)
index 0000000..e53beff
--- /dev/null
@@ -0,0 +1,76 @@
+Problem with recent ANSI compilers
+
+On some systems, including AIX, the compiler quits on the ntp_refclock.c
+file when processing the refclock_report() routine. The problem, which
+is eithre a feature or a bug, has to do with an unwanted promotion of
+the u_char argument to an int and a failure of the compiler to recognize
+the preceding prototype. A workaround is to use ANSI syntax to delare
+the arguments. Since ANSI compilers are not universally available, this
+syntax can't be used in the stock distribution.
+
+(Message # 60: 2884 bytes, New)
+Date: Sat, 19 Aug 1995 13:20:50 -0400
+From: "R. Bernstein" <rocky@panix.com>
+Newsgroups: comp.protocols.time.ntp
+to: mills@udel.edu
+return-receipt-to: rocky@panix.com
+Subject: time and AIX 3.2.5 raw tty bug
+This posting isn't strictly about NTP, any program that may stop the
+clock or set the clock backwards is subject to the AIX 3.2.5 bug.
+On AIX 3.2.5, there is a bug in the tty driver for a raw device which
+may crash the box under certain conditions: basically a read() on a
+raw tty in effect, a character was read but not as many as specified
+by VMIN when a read timeout occurred. VTIME specifies the timeout. See
+the AIX manual page on termios.h or that include file. for Information
+on VMIN (or MIN) VTIME (or TIME).
+A remedy other than to not use raw tty's is to apply patch U435110.
+Details of the problem report follow.
+> ABSTRACT:
+> IX43779: TRAP IN PSX_TIMEO
+>
+> ORIGINATING DETAILS:
+> Stacktrace shows:
+> IAR:      01460214   posixdd:psx_timeo  + 8bf4: ti 4,r12,0x0
+> *LR:      014601a0   posixdd:psx_timeo  + 8b80
+> 00212c60: 014604f4   posixdd:psx_timer  + 8ed4
+> 00212cc0: 0144b74c   ttydd:tty_do_offlevel  + 4284
+> 00212d20: 000216fc  .i_offlevel + 8c
+> 00212d70: 00021d78  .i_softint + c8
+> 00001004: 00008714  .finish_interrupt + 80
+>
+> RESPONDER SUMMARY:
+> AIX asserted in psx_timeo(). Reason for the assert was that
+> the current time was behind psx_ctime. Since this state
+> can occur when the current time is changed after a character
+> is received but before the VTIME interbyte timer pops, we
+> should not assert on this.
+>
+> RESPONDER CONCLUSION:
+> Removed the requirement that current time > psx_ctime by
+> adding a new L_ntimersub macro that is used instead of the
+> ntimersub macro in time.h. Also added a test for (current
+> time - psx_ctime) being negative, in that case we do not
+> adjust the new timeout.
+>
+> Reported to Correct a PTF in Error:     NO
+> Reported as a Highly pervasive problem: NO
+>
+> PE Apar?:       NoPE
+> Hiper Apar?:    NoHiper
+> Status:         CLOSED  PER
+> Component Name: AIX V3 FOR RS/6
+> Version:        320
+> Component ID:   575603001
+> Submitted:      94/05/03
+> Closed:         94/05/05
+> ChangeTeam:     TX2527
+>
+> APAR FIXED BY:  U431696  U432151  U432844  U432870  U432979
+> U433049  U433081  U433459  U433876  U433906  U434598  U434453
+> U434672  U434737  U435110
+
diff --git a/html/build/hints/bsdi b/html/build/hints/bsdi
new file mode 100644 (file)
index 0000000..3b8bc38
--- /dev/null
@@ -0,0 +1,65 @@
+hints/bsdi
+
+Author:                Bdale Garbee, bdale@gag.com
+Last revision: 27Oct94 (Paul Vixie)
+
+Included in this distribution of XNTP is a configuration file suitable
+for use with BSDI's BSD/OS 1.1 (formerly BSD/386 1.1).  On this system,
+the "cc" command is GCC 1.4x rather than PCC or GCC 2.x.  It is imperative
+that "cc" be used since it predefines the symbol __bsdi__; if you want to
+use another compiler you will need to add -D__bsdi__ to catch the various
+#ifdef's required for this system.
+
+The Kinemetrics/Truetime GPS-TM/TMD driver is known to work on this system.
+The GPS-805 and GOES should also work fine.  Hell, they should all work fine
+but it's hard to test very many locally.
+
+Due to BNR2's strict interpretation of POSIX and XNTP's use of SIGIO, BSD/OS
+can only handle one refclock per daemon.  We're working this out with the
+system architects.
+
+The config file is machine/bsdi, and the following steps should be all that
+are required to install and use the bits.
+
+Note that you will need GNU sed; the version supplied with BSD/OS 1.1 loops
+endlessly during "make refconf".  Likewise you should get GNU make, which
+the instructions below assume that you have put in /usr/local/bin/gnumake.
+
+To build the software:
+
+       rm -f Config.local
+       gnumake refconf
+       gnumake MAKE=gnumake
+
+To install the software:
+
+       gnumake install
+
+       This will place all of the executables in /usr/local/etc.  The config
+       file is expected to be /usr/local/etc/xntp.conf and the key file for
+       the optional authentication is /etc/ntp.keys.
+
+       Craft a config file and a key file, and put them in the right places.
+       There is information on how to do this elsewhere in the documentation,
+       the only thing I'll mention is that I put the drift file in 
+       /var/log/ntp.drift, and the authdelay on my 486DX/50 system is 
+       0.000064.  Your mileage will vary, learn to use the authspeed tools
+       if you're going to authenticate.
+       
+       In the file /etc/rc.local, make sure that the invocation of ntpd is
+       commented out, and add an invocation of xntpd.  Here's what I'm using:
+
+               echo -n 'starting local daemons:'
+
+               if [ -f /etc/ntp.keys -a -f /usr/local/etc/xntp.conf ]; then
+                   echo -n ' xntpd';           /usr/local/etc/xntpd
+               fi
+
+               #XXX# echo -n ' ntpd';          /usr/libexec/ntpd -t
+
+At this point, you should be good to go.  Try running /usr/local/etc/xntpd and
+using ntpq or xntpdc to see if things are working, then pay attention the next
+time you reboot to make sure that xntpd is being invoked, and use ntpq or
+xntpdc again to make sure all is well.  
+
+Enjoy!
diff --git a/html/build/hints/changes b/html/build/hints/changes
new file mode 100644 (file)
index 0000000..177e562
--- /dev/null
@@ -0,0 +1,13 @@
+Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> (xntpd/refclock_parse.c):
+       - Added support to supply power from RS232 with CLOCK_RAWDCF.
+         Known to work with Linux 1.2.
+       - Made Linux ignore parity errors with CLOCK_RAWDCF.
+
+Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> (parse/util/dcfd.c):
+       - Removed conflicting prototype for Linux (sscanf)
+       - Corrected spelling error
+       - Made Linux ignore parity errors.
+       - Added support to supply power from RS232 with CLOCK_RAWDCF.
+
+Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> (parse/util/testdcf.c):
+       - Made Linux ignore parity errors.
diff --git a/html/build/hints/decosf1 b/html/build/hints/decosf1
new file mode 100644 (file)
index 0000000..bc4ce0b
--- /dev/null
@@ -0,0 +1,40 @@
+Some major changes were necessary to make xntp v3 run on the DEC Alpha
+hardware running DEC OSF/1.  All "long" and "u_long" declarations and
+casts in the code were changed to "LONG" and "U_LONG" and a new header
+file (include/ntp_types.h) was added.  The new header file defines
+LONG as int and U_LONG as u_int for the Alpha hardware and as long
+and u_long for anything else.  A couple of #ifs where changed in
+ntpq and xntpdc to get the result of a signal defined correctly.  The
+Config.decosf1 file built the programs here with no problems.
+
+I don't have a radio clock here, so none of that code has been tested.
+I have run xntpd, xntpdc, xntpres, ntpq, ntpdate, and tickadj under
+DEC OSF/1 v1.2-2 (BL10).
+
+Mike Iglesias                        Internet:    iglesias@draco.acs.uci.edu
+University of California, Irvine     BITNET:      iglesias@uci
+Office of Academic Computing         uucp:        ...!ucbvax!ucivax!iglesias
+Distributed Computing Support        phone:       (714) 856-6926
+
+Support for NTP Version 2 is included with the current OSF/1 release. If
+you are upgrading to NTP Version 3 with this distribution, you should not
+use the xntpd or ntpq programs that come with the OSF/1 release. The
+older programs should be replaced by the newer programs of the same name,
+either in situ or via a link to a tranquil spot like /usr/local/bin. The
+make install script in the this distribution don't work due to a silly
+install program incompatibility, so you will need to copy the programs by
+hand.
+
+Don't use the setup utility to install or configure the xntpd installation,
+as it will cheerfully clobber your painstakingly crafted ntp.conf program.
+However, assuming you put this file in /etc/ntp.conf, you can use the
+/sbin/init.d/xntpd script to start and stop the daemon.
+
+This distribution compiles with nominal mumur with the stock cc compiler
+that comes with OSF/1.
+
+Dave Mills
+Electrical Engineering Department
+Unibergisty of Delabunch
+mills@udel.edu
+
diff --git a/html/build/hints/decosf2 b/html/build/hints/decosf2
new file mode 100644 (file)
index 0000000..e4a8828
--- /dev/null
@@ -0,0 +1,54 @@
+Problems with DEC OSF/1 V2.0
+
+Compilation using gcc fails with ntp_config.c. The problem is an apparent
+error in the /usr/include/sys/procset.h and /usr/include/sys/wait.h
+include files.
+
+cowbird:/usr/include/sys# diff -c wait.h.orig wait.h
+*** wait.h.orig Tue Feb 22 02:41:38 1994
+--- wait.h      Thu Aug 25 14:52:57 1994
+***************
+*** 298,304 ****
+  #else
+  
+  _BEGIN_CPLUSPLUS
+! extern int waitid(idtype_t, id_t, siginfo_t *, int);
+  _END_CPLUSPLUS
+  #endif /* _NO_PROTO */
+  
+--- 298,304 ----
+  #else
+  
+  _BEGIN_CPLUSPLUS
+! extern int waitid(idtype_t, pid_t, siginfo_t *, int);
+  _END_CPLUSPLUS
+  #endif /* _NO_PROTO */
+
+cowbird:/usr/include/sys# diff -c procset.h.orig procset.h
+*** procset.h.orig      Tue Feb 22 02:41:44 1994
+--- procset.h   Thu Aug 25 14:43:52 1994
+***************
+*** 86,95 ****
+                                 */
+  
+        idtype_t p_lidtype;     /* The id type for the left set. */
+!       id_t p_lid;             /* The id for the left set. */
+  
+        idtype_t p_ridtype;     /* The id type of for right set. */
+!       id_t p_rid;             /* The id of the right set. */
+  } procset_t;
+  
+  
+--- 86,95 ----
+                                 */
+  
+        idtype_t p_lidtype;     /* The id type for the left set. */
+!       pid_t p_lid;            /* The id for the left set. */
+  
+        idtype_t p_ridtype;     /* The id type of for right set. */
+!       pid_t p_rid;            /* The id of the right set. */
+  } procset_t;
+
+Also, if using gcc from the freeware disk, either replace syscall.h
+in the directory /usr/local/lib/gcc-lib/alpha-dec-osf1/2.3.3/include
+or replace with a link to /usr/include/sys/syscall.h.
diff --git a/html/build/hints/freebsd b/html/build/hints/freebsd
new file mode 100644 (file)
index 0000000..ef84732
--- /dev/null
@@ -0,0 +1,15 @@
+If you are compiling under FreeBSD and see messages in the syslogs that
+indicate that the ntpd process is trying to use unavailable sched_
+calls, it means you are running a kernel that does not have the POSIX
+scheduling calls enabled.
+
+You have two choices:
+
+- Ignore the messages
+
+- Generate a new kernel, where the kernel configuration file contains
+  the lines:
+
+  options              "P1003_1B"
+  options              "_KPOSIX_PRIORITY_SCHEDULING"
+  options              "_KPOSIX_VERSION=199309L"
diff --git a/html/build/hints/hpux b/html/build/hints/hpux
new file mode 100644 (file)
index 0000000..1640d05
--- /dev/null
@@ -0,0 +1,158 @@
+Last update: Sun Mar 13 15:05:31 PST 1994
+
+This file hopefully describes the whatever and however of how to get xntp
+running on hpux 7.0 and later s300. s400, s700, and s800.  
+
+First off,  all the standard disclaimers hold here ... HP doesn't have anthing
+to do with this stuff.  I fool with it in my spare time because we use it and
+because I like to.  We just happen to have a lot of HP machines around here :-)
+Xntpd has been in use here for several years and has a fair amount of mileage
+on various HP platforms within the company.  I can't really guarantee bug fixes
+but I'd certainly like to hear about bugs and I won't hestitate to look at
+any fixes sent to me.  
+
+Now lets talk OS.  If you don't have 7.0 or later, pretty much hang it up now.
+This stuff has run here on pretty much everything from 8.0 upward on s300, 
+s700, and s800.  It is known to run on 7.0 s300/s400 but all reports are 
+from the field and not my personal experience.
+
+If you are lucky enough to have a s300 or s400 with 9.03, then you no longer
+have to worry about adjtimed as HP-UX now has adjtime(2).  The rest of you
+will have to wait on 10.0 which will have adjtime(2) and a supported though
+a bit older version of xntpd.
+
+Next, let me explain a bit about how this stuff works on HP-UX's that do not
+have adjtime(2).  The directory adjtime contains libadjtime.a and the adjtimed
+daemon.  Instead of the adjtime(2) system call, we use a library routine to
+talk to adjtimed thru message queues.  Adjtimed munges into /dev/kmem and
+causes the clock to skew properly as needed.  PLEASE NOTE that the adjtime
+code provided here is NOT a general replacement for adjtime(2) ... use of
+this adjtime(3)/adjtimed(8) other than with xntpd may yield very odd results.
+
+What to do to get this stuff running ?
+
+    * If you are running an OS less than 10.0 or do not have a s300/s400 
+      with 9.03 or better
+       -> cd machines
+       -> vi hpux
+       -> (change -DSYS_HPUX=? to match whatever you are running [7,8,9])
+       -> cd ..
+
+    * Say "make makeconfig"
+
+    * Say "make", sit back for a few minutes.
+
+    * cd authstuff
+       * Say "./authcert < certdata" and check the output.  Every line should
+         end with "OK" ... if not, we got trouble.
+       * Now try "./authspeed auth.samplekeys".  What we want to 
+         remember here is the "authentication delay in CPU time" 
+       * cd ..
+
+    * Say "make install"
+
+    * I'd suggest reading the xntp docs about now :-) ... seriously !!
+
+    * One thing I have added to this version of xntpd is a way to select 
+      config files if you are sharing /usr/local thru NFS or whatever.  
+      If the file /usr/local/etc/xntp.conf happens to be a directory, the 
+      files in that directory are searched until a match is found.  The 
+      rules for a match are:
+
+       1. Our hostname
+       2. default.<machine id> (as in default.375 or default.850)
+       3. default
+
+    * Ok, make sure adjtimed is running (just start it up for now with
+      "/usr/local/etc/adjtimed").  Using -z as an option will get you 
+      a usage message.
+
+    * Now start up xntpd and watch it work.
+
+    * Make sure that adjtimed gets started at boot right before xntpd.
+      We do this in /etc/netbsdsrc.  They must both run as root !!
+
+Possible problems ?
+
+    * On some 320's and 835's we have had to run adjtimed with "-p 45" or
+      so to get rid of syslog messages about "last adjust did not finish".
+
+    * At 9.0, there is a problem with DIAGMON (patch available from the
+      response center) which causes it to delete the message queue that
+      adjtimed/xntpd use to communicate. (see next note for result)
+
+    * Xntpd has been known to get really ticked off when adjtime() fails
+      which is usually only while running the emulation code on HP-UX.
+      When it gets mad, it usually jumps the clock into never never land.
+      Possible reasons for this are adjtimed being killed or just never
+      started or adjtimed being completely swapped out on a really busy
+      machine (newer adjtimed try to lock themselves in memory to prevent
+      this one).
+
+Anything else ... just drop me a line at ken@sdd.hp.com
+
+Received: from louie.udel.edu by huey.udel.edu id aa14418; 15 Jun 95 9:19 EDT
+Received: from host5.colby.edu (host-05.colby.edu) by host-04.colby.edu with ESMTP  (1.37.109.15/Colby 1.1)
+       id AA165442355; Thu, 15 Jun 1995 09:19:16 -0400
+Received: by host5.colby.edu  (1.37.109.15/Colby 1.1)
+       id AA056252339; Thu, 15 Jun 1995 09:18:59 -0400
+Date: Thu, 15 Jun 1995 09:18:59 -0400 (EDT)
+From: "Jeff A. Earickson" <jaearick@colby.edu>
+To: Mills@huey.udel.edu
+Subject: More minor bugs in xntp3.4s
+In-Reply-To: <9506150022.aa12727@huey.udel.edu>
+Message-Id: <Pine.HPP.3.91.950615083549.4557A-100000@host5.colby.edu>
+Mime-Version: 1.0
+Content-Type: TEXT/PLAIN; charset=US-ASCII
+
+Dave,
+   After reading the hpux hints file, I realized I didn't install or 
+start adjtimed.  In the course of doing this, I discovered that:
+
+--> $(TOP) is not defined in adjtime/Makefile, so "make install" can't
+    find the install.sh script.
+
+--> "make install" from the main Makefile never goes into the adjtime
+    directory, so I added the following two lines into the install
+    target of the main Makefile:
+
+    @echo installing from adjtime
+    @cd adjtime && $(MAKE) $(MFLAGS) MFLAGS="$(MFLAGS)" MAKE="$(MAKE)" install
+
+This twiddle may not be right for all systems, but it got adjtimed
+installed for me.
+
+   You might also want to add to the hpux hints file that one way to
+fire things up at boot time is to add the following lines to the localrc
+function of /etc/rc:
+
+    #---daemons for Network Time Protocol (version 3.4s)
+    #---note that adjtimed is only needed for HP-UX 9.X, not 10.0
+    #---adjtimed must be running or xntpd won't work right...
+    if [ -x /usr/local/bin/adjtimed ]; then
+        /usr/local/bin/adjtimed -r & echo -n ' adjtimed'
+        if [ -x /usr/local/bin/xntpd ]; then
+            /usr/local/bin/xntpd &    echo -n ' xntpd'
+        fi
+    fi
+
+I discovered that the "-r" option of adjtimed is needed to clear out any
+trash from a previous execution of it.  Otherwise adjtimed quietly dies
+and leaves xntpd in the lurch...
+
+Thanks for the help.
+
+** Jeff A. Earickson, Ph.D                         PHONE: 207-872-3659
+** Senior UNIX Sysadmin, Information Technology    EMAIL: jaearick@colby.edu
+** Colby College, 4214 Mayflower Hill,               FAX: 207-872-3555
+** Waterville ME, 04901-8842
+
+On Thu, 15 Jun 1995 Mills@huey.udel.edu wrote:
+
+> Jeff,
+> 
+> Read the hpux file in the hints directory.
+> 
+> Dave
+> 
+
diff --git a/html/build/hints/linux b/html/build/hints/linux
new file mode 100644 (file)
index 0000000..b06a36a
--- /dev/null
@@ -0,0 +1,5 @@
+The kernel PLL interface is broken, I know.
+Update RSN.
+
+       Torsten
+       (duwe@informatik.uni-erlangen.de)
diff --git a/html/build/hints/mpeix b/html/build/hints/mpeix
new file mode 100644 (file)
index 0000000..83c7241
--- /dev/null
@@ -0,0 +1,50 @@
+HP e3000 MPE/iX NTP Hints - May 29, 2001
+----------------------------------------
+
+NTP was first ported to MPE several years ago, but those diffs were never
+submitted back to the official NTP distribution.  For more information about
+that deprecated port, please see http://www.bixby.org/mark/xntpix.html.
+
+NTP was re-ported to MPE in May 2001.  What follows are hints learned from
+working with NTP 4.0.99k23.  For additional information about NTP on MPE,
+please see http://jazz.external.hp.com/src/hp_freeware/ntp/.
+
+MPE lacks the clock-related APIs expected by NTP, so adjtime(), gettimeofday(),
+and settimeofday() all had to be implemented from scratch by calling
+privileged, undocumented internal OS functions.
+
+Unfortunately the implementation of adjtime() has exposed a sub-second accuracy
+bug when slewing the system time.  This bug is documented in SR 5003462838, and
+exists on all current versions of MPE.  It has not been fixed at the time of
+this writing.  The adjtime() code may possibly need to be altered if/when this
+bug is fixed.
+
+This bug has a side-effect whereby the ntpd daemon will screw up the hardware
+PDC clock time by many minutes if used for continuous clock adjustments or in
+the one-time -q mode.  But note that you can safely run ntpd in order to become
+a time server if you include "disable ntp" in the ntp.conf configuration file.
+
+The one-time clock adjustment functionality of ntpdate and ntp_timeset is not
+affected by this bug side-effect.  You can safely use these commands to alter
+your system time with reasonable accuracy.
+
+The only reference clock that has been tested on MPE is the local clock.  So
+building NTP with --disable-all-clocks --enable-LOCAL_CLOCK is strongly
+recommended.
+
+NTP makes use of Privileged Mode (PM) capability in order to bind to the NTP
+network port (123) and to access the low-level clock functions.
+
+NTP was ported using the gcc compiler.  Attempting to use the HP C/iX compiler
+is not recommended and has not been tested.
+
+Please note that NTP is not an HP product and is NOT supported by HP.  The best
+place for asking MPE-specific questions about NTP is the HP3000-L mailing list
+at http://raven.utc.edu/Archives/hp3000-l.html or the associated Usenet
+newsgroup of comp.sys.hp.mpe.
+
+The original author of this port is:
+
+Mark Bixby
+HP CSY MPE Internet & Interoperability Engineer
+mark_bixby@hp.com
diff --git a/html/build/hints/netbsd b/html/build/hints/netbsd
new file mode 100644 (file)
index 0000000..f5f628d
--- /dev/null
@@ -0,0 +1,37 @@
+Starting with NetBSD-1.6, it is possible to delegate the system clock 
+control to a non root user. This enable running ntpd in a chroot 
+jail under a non privilegied UID/GID, using ntpd -i and -u flags.
+
+The delegation is done through the clockctl(4) pseudodevice driver. 
+This driver makes privilegied system calls such as ntp_adjtime(2)
+available through ioctl(2) on the /dev/clockctl device. If a user
+is able to write to /dev/clockctl, then (s)he can control the system 
+clock.
+
+In order to use this feature, make sure that:
+
+1) Your kernel is compiled with the following option:
+pseudo-device  clockctl
+This is true for GENERIC kernels on most ports. Please check 
+http://wwW.netbsd.org/Documentation/kernel/
+if you need information about building a kernel.
+
+2) You have a ntpd user on your system. Here is the /etc/master.passwd
+entry for ntpd user on NetBSD-1.6:
+ntpd:*:15:15::0:0:& pseudo-user:/var/chroot/ntpd:/sbin/nologin
+And here is the /etc/group entry for group 15:
+ntpd:*:15:
+
+3) /dev/clockctl exists and is writtable by user ntpd. Default 
+NetBSD-1.6 setting is:
+crw-rw----  1 root  ntpd  61, 0 Apr 1  2002 /dev/clockctl
+Major device number and date is likely to be different on your system.
+If you need to create the device, issue the following command:
+cd /dev && ./MAKEDEV clockctl
+
+Here is an example of how to run ntpd chrooted in /var/chroot/ntpd, 
+running with ntpd UID and ntpd GID:
+ntpd -i /var/chroot/ntpd -u ntpd:ntpd
+Note that -i and -u options are enabled at configure time if your 
+system supports system clock control by an unprivilegied user. If this
+is not the case, then the -i and -u options will not be available.
diff --git a/html/build/hints/notes-xntp-v3 b/html/build/hints/notes-xntp-v3
new file mode 100644 (file)
index 0000000..ba027f2
--- /dev/null
@@ -0,0 +1,119 @@
+Notes for NTP Version 3
+
+This version operates in much the same manner as Version 2 with the
+following changes and additions:
+
+1.   The protocol machinery operates in conformance with the RFC1305 NTP
+     Version 3 specification. The most visible characteristic of this
+     version is that the poll intervals for all polls, even selected
+     ones, is significantly increased. This is especially desirable when
+     serving a large client population. This implementation supports
+     previous versions as non-configured peers; for version-2 configured
+     peers a "version 2" keyword should be included on the "peer" line.
+
+2.   The configuration file has a new keyword: statfile <file>, where
+     <file> is the name of a statistics file." When present, each clock
+     update generates an entry of the form:
+
+     <day> <sec>.<frac> <addr> <status> <offset> <delay> <disp>
+
+     where <day> is the modified Julian day, <sec>.<frac> is the time of
+     day, <addr> is the peer address and <status> is the peer status.
+     The <offset>, <delay> and <disp> are the measured offset, delay and
+     dispersion, respectively, of the peer clock relative to the local
+     clock. About once per day the current file is closed and a new one
+     created with names <file>.<gen>, where <gen> starts at one and
+     increments for each new generation.
+
+3.   A number of additional platforms are supported. See ./Config file
+     for details.
+
+4.   A driver for the TrueTime 468DC GOES Synchronized Clock is
+     included. This driver (refclock_goes.c) should also work for other
+     TrueTime radio clocks, since all use the same format.
+
+5.   A replacement driver for the Spectracom 8170 WWVB Synchronized
+     Clock is included. This driver (refclock_wwvb.c) (a) does not
+     require a 1-pulse-per-second signal, (b) supports both format 0
+     (original 8170) and format 2 (Netclock/2 and upgraded 8170), (c)
+     can be connected to more than one computer and (d) automatically
+     compensates for all serial baud rates.
+
+6.   A driver for the German time/frequency station DCF77 is included.
+     This requires a special STREAMS module.
+
+7.   In Version 2 special line-discipline modules were required for the
+     CHU and WWVB drivers. This code continues to work in Version 3,
+     although it is no longer needed for the WWVB driver. However, this
+     code does not work under STREAMS, as used in SunOS 4.1.1.
+     Equivalent STREAMS modules are supplied with Version 3.
+
+8.   Support for an external 1-pulse-per-second (pps) signal is
+     provided. The signal is connected to a serial port (see
+     xntpd/ntp_loopfilter.c for details). When present the leading edge
+     of the pulse establishes the on-time epoch within an interval
+     established by the selected radio clock or other NTP time server.
+     Use of the pps is indicated when the tattletale displayed by ntpq
+     changes from "*" to "o".
+
+9.   The clock-selection and poll-update procedures have been modified
+     slightly in order to achieve better performance on high speed LANs
+     with compromise in performance on typical WANs.
+
+10.  In order to comply with U.S. Commerce Department regulations, the DES
+     encryption routine lib/authdes.c cannot be exported. For exportable
+     versions of this distribution a DES-encrypted version of this routine
+     lib/authdes.c.des is included along with an unencrypted version
+     lib/authdes.c.export, which allows normal operation, but without the
+     NTP authentication feature. Further information is available in the
+     lib/authdes.c.export file.
+
+11.  As an alternative to the DES-based authentication mechanism, an
+     implementation of the RSA Message Digest 5 algorithm is provided.
+     (see applicable copyright information in the library files).
+
+12.  A driver for the Magnavox MX4200 GPS clock.
+
+13.  A STREAMS module which captures carrier-detect data-lead transitions to
+     connect a precision source of 1-pps, yet avoid the ugly overhead in the
+     usual STREAMS processing. See the ppsclock subdirectory.
+
+14.  Support for the Apple A/UX operating system and enhanced support for the
+     Hewlet-Packard HP/UX operating system. See the various README and Config
+     files for further information. 
+
+See the COPYRIGHT file for authors and copyright information. Note that some
+modules in this distribution contain copyright information that supersedes
+the copyright information in that file.
+
+If I missed something or neglected to give due credit, please advise.
+
+David L. Mills
+University of Delaware
+31 May 1992, amended 23 July 1992, 25 October 1992
+
+Bugs and notes
+
+A bug in the original tty_clk_STREAMS.c module has been fixed.
+
+The poll-interval randomization feature of poll_update (in
+xntpd/ntp_proto.c) has been extended to apply when the poll interval is
+increased, as well as reduced. This spreads the update messages in time
+and helps avoid unpleasant bursts of messages.
+
+In the clock_select algorithm the peers selected for combining are
+limited to those survivors at the lowest stratum, not the entire list.
+This helps avoid whiplash when large numbers of peers are at the same
+stratum.
+
+The number formerly displayed by ntpq as "compliance" is now the time
+constant of integration.
+
+The DNS resolver xntpd/ntp_intres.c is now integrated into xntpd, making
+configuration of multiple hosts easier.
+
+System and peer event are now written to the system log at priority
+LOG_INFO.
+
+The leap-second code was fixed to avoid broadcasting leap warnings on
+all except the last day of June and December.
diff --git a/html/build/hints/parse b/html/build/hints/parse
new file mode 100644 (file)
index 0000000..07fbc6b
--- /dev/null
@@ -0,0 +1,105 @@
+Compilation:
+       Usual thing: rm -f Config.local ; make for vanilla
+                       make refconf for reference clock (e. g. DCF77)
+
+Directory contents:
+
+       hints/PARSE     - this file
+
+       xntpd/refclock_parse.c
+                       - reference clock support for DCF77/GPS in xntp
+       parse/parse.c
+                       - Reference clock data parser framework
+       parse/parse_conf.c
+                       - parser configuration (clock types)
+       parse/clk_meinberg.c
+                       - Meinberg clock formats (DCF U/A 31, PZF 535, GPS166)
+       parse/clk_schmid.c
+                       - Schmid receiver (DCF77)
+       parse/clk_rawdcf.c
+                       - 100/200ms pulses via 50 Baud line (DCF77)
+       parse/clk_dcf7000.c
+                       - ELV DCF7000 (DCF77)
+       parse/clk_trimble.c
+                       - Trimble SV6 GPS receiver
+
+                         If you want to add new clock types please check
+                         with kardel <AT> informatik.uni-erlangen.de. These files
+                         implement the conversion of RS232 data streams into
+                         timing information used by refclock_parse.c which is
+                         mostly generic except for NTP configuration constants.
+
+       parse/Makefile.kernel
+                       - *SIMPLE* makefile to build a loadable STREAMS
+                         module for SunOS 4.x / SunOS 5.x systems
+
+       parse/parsestreams.c
+                       - SUN Streams module (loadable) for radio clocks
+                         This streams module is designed for SunOS 4.1.X.
+
+       parse/parsesolaris.c
+                       - SUN Streams module (loadable) for radio clocks.
+                         This streams module is designed for SunOS 5.x
+                         Beware this is still new - so it might crash
+                         your machine (we have seen it working, though).
+
+       parse/parsetest.c
+                       - simple test program for STREAMS module. Its so simple,
+                         that it doesn't even set TTY-modes, thus they got to
+                         be correct on startup - works for Meinberg receivers
+
+       parse/testdcf.c
+                       - test program for raw DCF77 (100/200ms pulses)
+                         receivers
+
+        include/parse.h - interface to "parse" module and more
+        include/parse_conf.h
+                       - interface to "parse" configuration
+
+       include/sys/parsestreams.h
+                       - STREAMS specific definitions
+
+       scripts/support
+                       - scripts (perl & sh) for statistics and rc startup
+                         the startup scripts are used in Erlangen for
+                         starting the daemon on a variety of Suns and HPs
+                         and for Reference Clock startup on Suns
+                         These scripts may or may not be helpful to you.
+
+Supported clocks:
+       Meinberg DCF U/A 31
+       Meinberg PZF535/TCXO    (Software revision PZFUERL 4.6)
+       Meinberg PZF535/OCXO    (Software revision PZFUERL 4.6)
+       Meinberg GPS166         (Software version for Uni-Erlangen)
+       ELV DCF7000             (not recommended - casual/emergency use only)
+       Conrad DCF77 receiver   (email: time@informatik.uni-erlangen.de)
+         + level converter
+       TimeBrick               (email: time@informatik.uni-erlangen.de)
+       Schmid Receiver Kit
+       Trimble SV6 GPS receiver
+
+Addresses:
+  Meinberg Funkuhren
+  Auf der Landwehr 22
+  31812 Bad Pyrmont
+  Germany
+  Tel.: 05281/20 18
+  FAX:  05281/60 81 80
+
+  ELV Kundenservice
+  Postfach 1000
+  26787 Leer
+  Germany
+  Tel.: 0491/60 08 88
+
+  Walter Schmidt
+  Eichwisrain 14
+  8634 Hombrechtikon
+  Switzerland
+
+If you have problems mail to:
+
+       time@informatik.uni-erlangen.de
+
+We'll help (conditions permitting)
+
diff --git a/html/build/hints/refclocks b/html/build/hints/refclocks
new file mode 100644 (file)
index 0000000..17e7643
--- /dev/null
@@ -0,0 +1,35 @@
+This is a short overview for the reference clocks currently supported
+by xntp V3. (Ultimate wisdom can be obtained from xntpd/refclock_*.c
+this file was derived from that information - unfortunately some comments
+in the files tend to get stale - so use with caution)
+
+Refclock address       Type
+127.127.0.x            no clock (fails to configure)
+127.127.1.x            local clock - use local clock as reference
+127.127.2.x            no clock (fails to configure)
+127.127.3.x            PSTI 1010/1020 WWV Clock
+127.127.4.x            SPECTRACOM WWVB receiver 8170 and Netclock/2
+127.127.5.x            Kinimetric Truetime 468-DC GOES receiver
+127.127.6.x            IRIG audio decode (Sun & modified BSD audio driver)
+127.127.7.x            CHU Timecode (via normal receiver & Bell 103 modem)
+127.127.8.x            PARSE (generic driver for a bunch of DCF/GPS clocks
+                              can be extended for other clocks too)
+       8.0-3           Meinberg PZF535/TCXO
+       8.4-7           Meinberg PZF535/OCXO
+       8.8-11          Meinberg DCF U/A 31
+       8.12-15         ELV DCF7000
+       8.16-19         Walter Schmid DCF receiver (Kit)
+       8.20-23         Conrad DCF77 receiver module + level converter (Kit)
+       8.24-27         TimeBrick (limited availability ask
+                                  time@informatik.uni-erlangen.de)
+       8.28-31         Meinberg GPS166
+       8.32-35         Trimble SV6 GPS receiver
+127.127.9.x            MX4200 GPS receiver
+127.127.10.x           Austron 2201A GPS Timing Receiver
+127.127.11.x           Kinemetrics Truetime OM-DC OMEGA Receiver
+127.127.12.x           KSI/Odetecs TPRO-S IRIG-B / TPRO-SAT GPS
+127.127.13.x           Leitch: CSD 5300 Master Clock System Driver
+127.127.14.x           MSFEES
+127/127.15.x           TrueTime GPS/TM-TMD
+127.127.16.x           Bancomm GPS/IRIG Ticktock
+127.127.17.x           Datum Programmable Time System
diff --git a/html/build/hints/rs6000 b/html/build/hints/rs6000
new file mode 100644 (file)
index 0000000..8561ac2
--- /dev/null
@@ -0,0 +1,56 @@
+15.7.1993
+xntp3 compiles now again on AIX. I have disabled prototyping and added
+the switch -D_NO_PROTO which disables prototyping in the system include
+files.
+
+Matthias Ernst  maer@nmr.lpc.ethz.ch
+--------------------------------------------------------------------------------
+Xntp version 3 now support the cc compiler for AIX.
+The Config.aix will now use cc by default.  You can still compile xntp
+with the bsd compiler by changing "COMP= cc" to "COMP= bsdcc" and
+and removing the "-DSTUPID_SIGNAL" option from the "DEFS" option.
+
+xntp and tickadj was also modified  so that the value of tickadj is read
+form the kernel and can be set by tickadj.  For now I would not set 
+tickadj below 40 us.   
+
+Bill Jones 
+jones@chpc.utexas.edu
+-------------------------------------------------------------------------------
+
+This is a modified version of xntp version 3 for the RS6000. It works for
+AIX 3.2 and these are the same changes as have been applied tothe version 2
+implementation of xntp. It works fine for us but I have not tested all of
+the features, especially the local clock support for the RS6000 is not tested
+at all.
+
+Matthias Ernst, ETH-Zuerich, Switzerland  -  maer@nmr.lpc.ethz.ch
+
+--------------------------------------------------------------------------------
+
+Here the original README.rs6000 for the version 2 implementation:
+
+A hacked version of xntp for the IBM RS/6000 under AIX 3.1 can be found
+in xntp.rs6000.tar.Z. [ if still available at all - Frank Kardel 93/12/3 ]
+
+This will not work on older versions of AIX due to a kernel bug;  to find
+out whether you have the kernel bug, compile and run testrs6000.c (see
+comments in the code for instructions).
+
+xntp and testrs6000 require "bsdcc" to compile.  This is simply another
+entry point into the xlc compiler with various options set for BSD
+compatibility.  If your system does not have bsdcc, do the following:
+
+link /bin/bsdcc to /bin/xlc
+
+put the following into /etc/xlc.cfg:
+
+* BSD compatibility
+bsdcc:  use        = DEFLT
+        crt        = /lib/crt0.o
+        mcrt       = /lib/mcrt0.o
+        gcrt       = /lib/gcrt0.o
+        libraries  = -lbsd, -lc
+        proflibs   = -L/lib/profiled,-L/usr/lib/profiled
+        options    = -H512,-T512, -qlanglvl=extended, -qnoro, -D_BSD, -D_NONSTD_TYPES, -D_NO_PROTO, -tp,-B/lib/
+
diff --git a/html/build/hints/sco.html b/html/build/hints/sco.html
new file mode 100644 (file)
index 0000000..bd08e98
--- /dev/null
@@ -0,0 +1,24 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <title>SCO Unix hints</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h1>SCO Unix hints</h1>
+               <h2>Older SCO Unix versions</h2>
+               <p>NTP 4.0.x does not run on SCO Unix prior to version 3.2.5.0.0. If you need NTP on an older SCO Unix system and don't mind to modify your kernel, use 3.5.91 which has patches for SCO Unix 3.2.4.x. Apply the kernel modifications as described in <a href="http://www.echelon.nl/en/ntp/sco3-recipe.html">XNTP on SCO 3.2.4.2</a>.</p>
+               <h2>Compiling NTP</h2>
+               <p>Delete the old SCO supplied NTP programs using the &quot;custom&quot; utility. Run the NTP configure program with CFLAGS=&quot;-b elf -K <i>processor-type</i>&quot; for best results.</p>
+               <h2>Running NTP</h2>
+               <p>Run &quot;tickadj -As&quot; after every reboot to set the variables &quot;clock_drift&quot; and &quot;track_rtc&quot; to the right values.</p>
+               <p>Run &quot;ntpd&quot; with a high negative nice-value, i.e. &quot;nice --19 ntpd&quot; for best results.</p>
+               <h2>More information</h2>
+               <p>More information on the way SCO Unix and NTP interact can be found in <a href="http://www.echelon.nl/en/ntp/ntp-on-sco.html">NTP on SCO Unix</a>, which includes links to precompiled versions of NTP.</p>
+               <p><a href="mailto:kees@echelon.nl">Kees Hendrikse</a>, January 1999</p>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/build/hints/sgi b/html/build/hints/sgi
new file mode 100644 (file)
index 0000000..5e4f7de
--- /dev/null
@@ -0,0 +1,74 @@
+adjtime, tick and tickadj:
+--------------------------
+
+The SGI value for HZ is 100 under Irix 4, with the system clock running
+in nominal mode (ftimer off), so the value for tick is 10000 usec.
+Tickadj is a bit more tricky because of the behaviour of adjtime(),
+which seems to try to perform the correction over 100-200 seconds, with
+a rate limit of 0.04 secs/sec for large corrections.  Corrections of
+less than 0.017 seconds generally complete in less than a second,
+however.
+
+Some measured rates are as follows:
+
+       Delta       Rate (sec/sec)
+
+       > 1             0.04
+       0.75            0.04
+       0.6             0.004
+       0.5             0.004
+       0.4             0.0026
+       0.3             0.0026
+       0.2             0.0013
+       0.1             0.0015
+       0.05            0.0015
+       0.02            0.0003
+       0.01            0.015
+Strange.  Anyway, since adjtime will complete adjustments of less than
+17msec in less than a second, whether the fast clock is on or off, I
+have used a value of 150usec/tick for the tickadj value.
+
+Fast clock:
+-----------
+
+I get smoother timekeeping if I turn on the fast clock, thereby making
+the clock tick at 1kHz rather than 100Hz.  With the fast clock off, I
+see a sawtooth clock offset with an amplitude of 5msec.  With it on,
+the amplitude drops to 0.5msec (surprise!).  This may be a consequence
+of having a local reference clock which spits out the time at exactly
+one-second intervals - I am probably seeing sampling aliasing between
+that and the machine clock.  This may all be irrelevant for machines
+without a local reference clock.  Fiddling with the fast clock doesn't
+seem to compromise the above choices for tick and tickadj.
+
+I use the "ftimer" program to switch the fast clock on when the system
+goes into multiuser mode, but you can set the "fastclock" flag in
+/usr/sysgen/master.d/kernel to have it on by default.  See ftimer(1).
+
+timetrim:
+---------
+
+Irix has a kernel variable called timetrim which adjusts the system
+time increment, effectively trimming the clock frequency.  Xntpd could
+use this rather than adjtime() to do it's frequency trimming, but I
+haven't the time to explore this.  There is a utility program,
+"timetrim", in the util directory which allows manipulation of the
+timetrim value in both SGI and xntpd native units.  You can fiddle with
+default timetrim value in /usr/sysgen/master.d/kernel, but I think
+that's ugly.  I just use xntpd to figure out the right value for
+timetrim for a particular CPU and then set it using "timetrim" when
+going to multiuser mode.
+
+Serial I/O latency:
+-------------------
+
+If you use a local clock on an RS-232 line, look into the kernel
+configuration stuff with regard to improving the input latency (check
+out /usr/sysgen/master.d/[sduart|cdsio]).  I have a Kinemetrics OM-DC
+hooked onto /dev/ttyd2 (the second CPU board RS-232 port) on an SGI
+Crimson, and setting the duart_rsrv_duration flag to 0 improves things
+a bit.
+
+
+12 Jan 93
+Steve Clift, CSIRO Marine Labs, Hobart, Australia (clift@ml.csiro.au)
diff --git a/html/build/hints/solaris-dosynctodr.html b/html/build/hints/solaris-dosynctodr.html
new file mode 100644 (file)
index 0000000..fc7fae9
--- /dev/null
@@ -0,0 +1,321 @@
+
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN">
+
+
+<!-- Sun Template V4.0 9/9/98 -->
+<HTML>
+<HEAD>
+<TITLE>Symptoms and Resolutions Article 19195</title><link href="scripts/style.css" type="text/css" rel="stylesheet">
+
+<META NAME="GENERATOR" CONTENT="Sun Microsystems, Inc.">
+<META HTTP-EQUIV="content-type" CONTENT="text/html;charset=iso-8859-1">
+
+<!-- INSERT YOUR META TAGS HERE -->
+
+<META NAME="PUBLISHED_DATE" CONTENT="">
+<META NAME="KEYWORDS" CONTENT="">
+<META NAME="DESCRIPTION" CONTENT="">
+
+<!-- END META TAGS -->
+
+<LINK REL="Stylesheet" TYPE="text/css" HREF="/style.css" TITLE="Style">
+
+</HEAD>
+<!--stopindex-->
+<BODY BGCOLOR="#FFFFFF" LINK="#666699" ALINK="#FFFFFF">
+
+
+<TABLE WIDTH="623" BORDER="0">
+        <TR>
+                <TD COLSPAN="2" VALIGN="TOP" WIDTH="623">
+                <IMG BORDER="0" SRC="/images/homebuy.gif" WIDTH="149" HEIGHT="32" ALT="Home * Buy * My Sun(sm)" USEMAP="#lefttop"><IMG BORDER="0" SRC="/images/globalnavbar.gif" WIDTH="474" HEIGHT="32" ALT="sun.com Global Sections" USEMAP="#topnav"></TD>
+        </TR>
+        <TR>
+                <TD COLSPAN="2" VALIGN="TOP" WIDTH="623">
+
+        <!-- TITLEBAR IMAGE: INSERT CUSTOMIZED TITLEBAR IMAGE BELOW -->
+
+        <A HREF="http://www.sun.com/"><IMG BORDER="0" SRC="/images/sunlogo.gif" WIDTH="149" HEIGHT="72" ALT="Sun Microsystems"></A><IMG BORDER="0" SRC="/images/titlebar/doc.title.gif" alt="gif" WIDTH="474" HEIGHT="72"></TD>
+        </TR>
+                       <!-- Begin Search Elements -->
+        <TR VALIGN="top">
+            <TD BGCOLOR="#666699">      
+                        <TABLE>
+                                <TR>
+                                    <TD BGCOLOR="#666699" COLSPAN="2" WIDTH="157" VALIGN="TOP"><IMG BORDER="0" SRC="/images/search/contract/search1.gif" WIDTH="157" HEIGHT="16" ALT="Search SunSolve"></TD>
+                            </TR>
+                                <TR>
+                                        <TD VALIGN="top" ALIGN="center" WIDTH="141" BGCOLOR="#666699"><FORM ACTION="search.pl" METHOD="POST"><FONT SIZE="2"><INPUT TYPE="text" NAME="zone_32" SIZE="14"></FONT><input type=hidden name=mode value=results><BR>
+<INPUT TYPE="image" SRC="/images/search/contract/search5.gif" BORDER="0" NAME="Search"><IMG SRC="/images/cg_clear.gif" ALT="" WIDTH="2" HEIGHT="1" BORDER="0" HSPACE="29" VSPACE="0"><BR>
+
+<A HREF="search.pl?mode=advanced"><IMG BORDER="0" SRC="/images/search/contract/search3.gif" WIDTH="144" HEIGHT="16" ALT="Advanced Search"></A><BR>
+
+<A HREF="search.pl?mode=product"><IMG SRC="/images/search/contract/search4.gif" BORDER="0" ALT="Product Search" WIDTH="144" HEIGHT="19"></A><BR>
+
+<A HREF="show.pl?target=help/search_tips"><IMG SRC="/images/search/contract/search6.gif" BORDER="0" ALT="Search Tips" WIDTH="144" HEIGHT="27"></A></TD>
+                                        <TD ALIGN="right"><IMG SRC="/images/search/contract/search2.gif" ALT="" WIDTH="13" HEIGHT="117" BORDER="0"></TD>
+                                </TR>
+    <!-- End Search Elements -->
+                    <!-- Begin User Personalization (Must limit to 10 Characters)-->
+                    <TR>
+                        <TD COLSPAN="2"><TABLE><TR><TD COLSPAN="3" ALIGN="right"><IMG SRC="/images/home_con/welcom_1.gif" ALT="" WIDTH="156" HEIGHT="4" BORDER="0"></TD></TR>
+                                        <TR><TD BGCOLOR="#333366"><IMG SRC="/images/home_con/welcom_2.gif" ALT="" WIDTH="17" HEIGHT="19" BORDER="0"></TD><TD BGCOLOR="#333366" VALIGN="middle"><NOBR><FONT FACE="Geneva, Helvetica, Arial, SunSans-Regular" COLOR="#99CC33" SIZE="-2">sopko</FONT></NOBR></TD><TD BGCOLOR="#333366" ALIGN="right"><A HREF="edit-user-form.pl?viewmode=contractuser"><IMG SRC="/images/home_con/welcom_3.gif" ALT="Edit" WIDTH="45" HEIGHT="19" BORDER="0"></A></TD></TR>
+                                </TABLE>
+                                </TD>
+                                </TR> 
+                <!-- End User Personalization -->
+
+                               <TR>
+                                        <TD COLSPAN="2" ALIGN="right" VALIGN="top" WIDTH="157" BGCOLOR="#666699"><IMG BORDER="0" SRC="/images/ssolvecontents.gif" WIDTH="157" HEIGHT="37" ALT="Contents Of SunSolve"><BR>
+
+
+
+
+               <!-- PILLS: CHANGE THE PILL FOR CURRENT SECTION TO THE HIGHLIGHTED PILL -->
+               <!-- Beginning of Nav area -->
+<A HREF="show.pl?target=patches/patch-access" onmouseover="window.status='All Public Patches'; return true" onmouseout="window.status=''; return true">
+<IMG BORDER="0" SRC="/images/nav/p1.gif" WIDTH="157" HEIGHT="19" ALT="All Public Patches"></A><BR>
+<A HREF="suncourier.pl" onmouseover="window.status='Submit a Service Order'; return true" onmouseout="window.status=''; return true">
+<IMG BORDER="0" SRC="/images/nav/p5.gif" WIDTH="157" HEIGHT="19" ALT="Submit a Service Order"></A><BR>
+<A HREF="show.pl?target=resources/tools" onmouseover="window.status='Diagnostic Tools'; return true" onmouseout="window.status=''; return true">
+<IMG BORDER="0" SRC="/images/nav/p4.gif" WIDTH="157" HEIGHT="19" ALT="Diagnostic Tools"></A><BR>
+<A HREF="show.pl?target=help/collections" onmouseover="window.status='Support Docs.'; return true" onmouseout="window.status=''; return true">
+<IMG BORDER="0" SRC="/images/nav/cp2.gif" WIDTH="157" HEIGHT="19" ALT="Support Docs."></A><BR>
+<A HREF="show.pl?target=resources/y2k" onmouseover="window.status='Y2K Central'; return true" onmouseout="window.status=''; return true">
+<IMG BORDER="0" SRC="/images/nav/p3.gif" WIDTH="157" HEIGHT="19" ALT="Y2K Central"></A><BR>
+<A HREF="show.pl?target=security/sec" onmouseover="window.status='Security Information'; return true" onmouseout="window.status=''; return true">
+<IMG BORDER="0" SRC="/images/nav/p2.gif" WIDTH="157" HEIGHT="19" ALT="Security Information"></A><BR>
+<br><table width="157">
+<tr><td width="8">&nbsp;</td><td width="149">
+<table>
+<BR><tr><td><BR><img src="/images/line.gif" alt="------" width="140" height="11" border="0"><br>
+               <A HREF="mark.pl" 
+                       onmouseover="window.status='Marked Docs.';return true"
+                       onmouseout="window.status='';return true">
+                       <font class="locallink" color="#dddddd">Marked Docs.</FONT></A><BR>
+               <A HREF="notify.pl" 
+                       onmouseover="window.status='Notifications';return true"
+                       onmouseout="window.status='';return true">
+                       <font class="locallink" color="#dddddd">Notifications</FONT></A><BR>
+               <A HREF="/plain-cgi/show.pl?target=home_con" 
+                       onmouseover="window.status='Low Graphics';return true"
+                       onmouseout="window.status='';return true">
+                       <font class="locallink" color="#dddddd">Low Graphics</FONT></A><BR>
+               <A HREF="show.pl?target=link" 
+                       onmouseover="window.status='SunSolve Servers';return true"
+                       onmouseout="window.status='';return true">
+                       <font class="locallink" color="#dddddd">SunSolve Servers</FONT></A><BR>
+               <A HREF="show.pl?target=about_sunsolve" 
+                       onmouseover="window.status='About SunSolve';return true"
+                       onmouseout="window.status='';return true">
+                       <font class="locallink" color="#dddddd">About SunSolve</FONT></A><BR>
+               <A HREF="feedback.pl" 
+                       onmouseover="window.status='Contact Us';return true"
+                       onmouseout="window.status='';return true">
+                       <font class="locallink" color="#dddddd">Contact Us</FONT></A><BR>
+               <A HREF="show.pl?target=help/sitemap" 
+                       onmouseover="window.status='Site Map';return true"
+                       onmouseout="window.status='';return true">
+                       <font class="locallink" color="#dddddd">Site Map</FONT></A><BR>
+               <A HREF="show.pl?target=article/article" 
+                       onmouseover="window.status='Articles';return true"
+                       onmouseout="window.status='';return true">
+                       <font class="locallink" color="#dddddd">Articles</FONT></A><BR>
+               <A HREF="show.pl?target=home_con" 
+                       onmouseover="window.status='Home';return true"
+                       onmouseout="window.status='';return true">
+                       <font class="locallink" color="#dddddd">Home</FONT></A><BR>
+               <A HREF="show.pl?target=help/faq" 
+                       onmouseover="window.status='Help';return true"
+                       onmouseout="window.status='';return true">
+                       <font class="locallink" color="#dddddd">Help</FONT></A><BR>
+<br></td></tr></table></td></tr></table>
+<!-- End of Nav area -->
+
+               </FORM>
+               <br><br><!-- some spacers -->
+                       </TD>
+                </TR>
+               </TABLE>
+                </TD>
+                <TD VALIGN="TOP" WIDTH="466">
+
+       
+        <!--startindex-->
+        <!-- ============  -->
+        <!-- MAIN CONTENT  -->
+        <!-- ============  -->
+
+
+
+<table width=100%>
+  <tr>
+<td width=100% valign=top>
+<CENTER><FONT FACE="Geneva, Helvetica, Arial, SunSans-Regular" SIZE="2">
+[&nbsp;<a href="retrieve.pl?type=0&doc=srdb%2F19195&display=plain">Printer Friendly Page</a>&nbsp;]
+[&nbsp;<b>Was this document useful? <a href="retrieve.pl?type=0&doc=srdb/19195&vote=yes">Yes</a> or <a href="retrieve.pl?type=0&doc=srdb/19195&vote=no">No</a></b>&nbsp;]<br>[&nbsp;<a href="notify.pl?action=add&doc=srdb%2F19195&type=synopsis">Notify if Document Changes</a>&nbsp;]
+[&nbsp;<a href="mark.pl?action=add&doc=srdb%2F19195&type=0">Mark Document for Download</a>&nbsp;]<br>[&nbsp;<a href="notify.pl">View/Edit Notifications</a>&nbsp;]
+[&nbsp;<a href="mark.pl">View/Edit Marked Documents</a>&nbsp;]<br></FONT></CENTER><br>
+               <SCRIPT Language="JavaScript">
+               <!-- Hide javascript from older browsers
+               function jump() 
+               {
+                       var ctl = document.docform.jumplist;
+                       location.href = ctl.options[ctl.selectedIndex].value;
+               }
+               // End hiding contents -->
+               </SCRIPT>
+<a name="top">
+<form name="docform"><div align=center><font size=2> Jump to <select name="jumplist" size=1 onchange="jump();"></font><option value="#Hardware">Hardware</option>
+<option value="#Product">Product</option>
+<option value="#Product-Area">Product Area</option>
+<option value="#Synopsis">Synopsis</option>
+<option value="#Problem-Description">Problem Description</option>
+<option value="#Document-Content">Document Content</option>
+<option value="#Problem-Solution">Problem Solution</option>
+<option value="#SRDB-ID">SRDB ID</option>
+<option value="#OS">OS</option>
+</select></div></form>
+<table width=100%>
+<tr bgcolor=#666699><td><font size=2 color=#ffffff><b>SRDB ID</b></font></td>
+<td bgcolor=#ffffff><font size=2>&nbsp;</font></td>
+<td><font size=2 color=#ffffff><b>Synopsis</b></font></td>
+<td bgcolor=#ffffff><font size=2>&nbsp;</font></td>
+<td><font size=2 color=#ffffff><b>Date</b></font></td>
+</tr>
+<tr bgcolor=#CCCCE7><td><font size=2><b>19195</b></font></td>
+<td bgcolor=#ffffff><font size=2>&nbsp;</font></td>
+<td><font size=2><b>Upgraded to 2.6, using xntpd, but the system clock is drifting. Worked fine</b></font></td>
+<td bgcolor=#ffffff><font size=2>&nbsp;</font></td>
+<td><font size=2><b>4 Sep 1999</b></font></td>
+</tr>
+</table><br clear>
+<table width=100%><tr bgcolor=#999999>
+<td><font size=2 color=#ffffff><b><a name=Problem-Description>Problem Description</a></b></font></td>
+<td align=right><b><a href="#top"><font size=2 color=#ffffff>Top</font></a></b></td></tr></table>
+<pre>Ever since upgrading to Solaris 2.6, the system clock has been drifting and
+there are messages like 'synchronisation lost', 'Previous time adjustment
+didn''t complete' and 'time reset (step)' a lot in the /var/adm/messages 
+file. The system either was previously working fine with the freeware
+xntpd or the configuration was copied from another system that was 
+using the freeware version.
+-- 23-Apr-99 08:22 US/Eastern --</pre><table width=100%><tr bgcolor=#999999>
+<td><font size=2 color=#ffffff><b><a name=Problem-Solution>Problem Solution</a></b></font></td>
+<td align=right><b><a href="#top"><font size=2 color=#ffffff>Top</font></a></b></td></tr></table>
+<pre>The common lore for setting up xntpd on Solaris using
+the freeware version included the warning to set the 
+kernel variable <font color=red>dosynctodr</font> to 0 in the /etc/system 
+file thus: set <font color=red>dosynctodr</font>=0
+
+When using NTP on Solaris 2.6 or later, the kernel 
+variable MUST be left at the default value of 1. Prior 
+to 2.6 this variable controlled whether or not to rein  
+in the softclock using the hardware clock, with the result 
+that NTP and the hardware clock would fight for control of 
+the soft clock; thus before 2.6 you had to set <font color=red>dosynctodr</font> 
+to 0. At 2.6, every system call that adjusts the softclock 
+also sets the hard clock, thus while NTP controls the soft 
+clock, the hard clock is also controlled. Setting 
+<font color=red>dosynctodr</font> to 0 reverts the behavior back to the pre 2.6 
+defaulkt behavior, having exactly the opposite effect 
+as that intended.
+
+Do not set <font color=red>dosynctodr</font> to 0.</pre><table width=100%>
+<tr><td bgcolor=#999999 valign=top width=25%><font color=#ffffff size=2><b><a name=Product-Area>Product Area</a></b></font></td>
+<td bgcolor=#cccccc valign=top width=75%><font size=2>Bundled Network</font></td></tr>
+<tr><td bgcolor=#999999 valign=top width=25%><font color=#ffffff size=2><b><a name=Product>Product</a></b></font></td>
+<td bgcolor=#cccccc valign=top width=75%><font size=2>NTP</font></td></tr>
+<tr><td bgcolor=#999999 valign=top width=25%><font color=#ffffff size=2><b><a name=OS>OS</a></b></font></td>
+<td bgcolor=#cccccc valign=top width=75%><font size=2>Solaris 2.6</font></td></tr>
+<tr><td bgcolor=#999999 valign=top width=25%><font color=#ffffff size=2><b><a name=Hardware>Hardware</a></b></font></td>
+<td bgcolor=#cccccc valign=top width=75%><font size=2>Ultra 2</font></td></tr>
+<tr><td bgcolor=#999999 valign=top width=25%><font color=#ffffff size=2><b><a name=Document-Content>Document Content</a></b></font></td>
+<td bgcolor=#cccccc valign=top width=75%><font size=2>with freeware xntpd.</font></td></tr>
+</table><br clear>
+<font size=2><a href="#top">Top</a></font><br><br>
+</td></tr></table>
+
+        <!-- ===================  -->
+        <!-- END OF MAIN CONTENT -->
+        <!-- ===================  -->
+        <!--stopindex-->
+
+        <!-- DON'T CHANGE INFORMATION OTHER THAN titlebar BELOW THIS LINE -->
+
+        <!-- Altered Table Structure from Template to format properly with new design -->
+        </TD>
+    </TR>
+    <TR>
+        <TD>&nbsp;</TD>
+        <TD VALIGN="top">
+       <center>
+        <IMG SRC="/images/cg_grey_line.gif" ALT="" WIDTH="466" HEIGHT="2" BORDER="0"><BR>
+        <IMG SRC="/images/cg_clear.gif" ALT=""  WIDTH="1" HEIGHT="2" BORDER="0" HSPACE="0" VSPACE="4">
+       </center>
+        <CENTER>
+        <FONT FACE="Geneva, Helvetica, Arial, SunSans-Regular" SIZE="2">
+        [ <A HREF="edit-user-form.pl?viewmode=contractuser">Edit Account</A> ]
+        [ <A HREF="show.pl?target=patches/patch-access">Patches</A> ]
+        [ <A HREF="suncourier.pl">Submit a Service Order</A> ]<br>
+        [ <A HREF="show.pl?target=resources/tools">Diagnostic Tools</A> ]  
+        [ <A HREF="show.pl?target=help/collections">Support Docs.</A> ]
+        [ <A HREF="show.pl?target=resources/y2k">Y2K Central</A> ] 
+        [ <A HREF="show.pl?target=security/sec">Security Information</A> ] <br>
+        [ <A HREF="show.pl?target=link">SunSolve Servers </A> ]
+        [ <A HREF="show.pl?target=about_sunsolve">About SunSolve</A> ] 
+        [ <A HREF="feedback.pl">Contact Us</A> ] 
+        [ <A HREF="show.pl?target=help/sitemap">Site Map</A> ]
+        [ <A HREF="show.pl?target=article/article">Articles</A> ]
+        [ <A HREF="show.pl?target=home_con">Home</A> ]
+        [ <A HREF="show.pl?target=help/faq">Help</A> ]
+        </FONT>
+        </CENTER>
+
+<!-- MAPS -->
+<MAP NAME="lefttop">
+<AREA SHAPE="rect" HREF="http://www.sun.com/MySun/" ALT="My Sun" COORDS="89,0 149,32">
+<AREA SHAPE="rect" HREF="show.pl?target=home_con" ALT="Home" COORDS="0,0 42,32">
+<AREA SHAPE="rect" HREF="http://www.sun.com/sales/" ALT="Buy" COORDS="54,0 78,32">
+</MAP>
+
+
+<MAP NAME="topnav">
+<AREA SHAPE="rect" HREF="http://www.sun.com/java/" ALT="Java Technologies" COORDS="4,0,67,32">
+<AREA SHAPE="rect" HREF="http://www.sun.com/products-n-solutions/" ALT="Products and Solutions" COORDS="74,0,141,32">
+<AREA SHAPE="rect" HREF="http://www.sun.com/service/" ALT="Support, Education, and Consulting" COORDS="148,0,249,32">
+<AREA SHAPE="rect" HREF="http://www.sun.com/tech/" ALT="Technology and Research" COORDS="261,0,324,32">
+<AREA SHAPE="rect" HREF="http://www.sun.com/developers/developers.html" ALT="For Developers" COORDS="334,0,396,32">
+<AREA SHAPE="rect" HREF="http://www.sun.com/corporateoverview/" ALT="Corporate Information" COORDS="406,0,482,32">
+</MAP>
+
+<!-- INSERT titlebar HREFS BELOW -->
+<MAP NAME="titlebar">
+<!-- LINK TO SEC HOME Removed because no longer needed on this template -->
+<AREA SHAPE="rect" HREF="/visual/home/" ALT="SunSolve Online(tm)" COORDS="0,21,215,51"> <!-- LINK TO CURRENT PILL HOME -->
+</MAP>
+
+
+<!-- begin copyright notice -->
+
+<BR>
+<CENTER>
+<FONT FACE="Geneva, Helvetica, Arial, SunSans-Regular" COLOR="#999999" SIZE="2">
+<br>
+Copyright 1994-1999 Sun Microsystems, Inc., 901 San Antonio Road, Palo Alto, CA 94303 USA.
+<br>
+All rights reserved.
+<a href="http://www.sun.com/share/text/SMICopyright.html">Legal Terms</a>. 
+<a href="http://www.sun.com/privacy/">Privacy Policy</a>.
+</font>
+</CENTER>
+
+<!-- end copyright notice -->
+        
+        </TD>
+    </TR>
+</TABLE>
+
+</BODY>
+</HTML>
+
diff --git a/html/build/hints/solaris.html b/html/build/hints/solaris.html
new file mode 100644 (file)
index 0000000..9dc2ab1
--- /dev/null
@@ -0,0 +1,144 @@
+<HTML>
+<HEAD>
+<TITLE>Solaris hints and kinks</title><link href="scripts/style.css" type="text/css" rel="stylesheet">
+
+</HEAD>
+<BODY>
+Information on compiling and executing ntpd under Solaris.
+<BR>
+Last Updated: Sun Jun 21 01:32:18 EDT 1998,
+John Hawkinson,
+<! -- This is deliberately not a mailto -- > &lt;jhawk@MIT.EDU&gt;
+<P>
+If you're not running Solaris 2.5.1 or later, it is likely
+that you will have problems; upgrading would be a really good plan.
+<P>
+<H3>All Solaris versions</H3>
+<P>
+      We have a report that says starting with Solaris 2.6 we should leave
+      <I>dosynctodr</I> alone.
+      <A HREF="solaris-dosynctodr.html">Here is the report</A>.
+<P>
+Proper operation of ntp under Solaris may require setting the kernel
+variable <I>dosynctodr</I> to zero (meaning "do not synchronize the clock
+to the hardware time-of-day clock").  This can be done with the
+tickadj utility:
+<BLOCKQUOTE><TT>
+tickadj -s
+</TT></BLOCKQUOTE>
+If you prefer, it can also be done with the native Solaris kernel debugger:
+<BLOCKQUOTE><TT>
+echo dosynctodr/W0 | adb -k -w /dev/ksyms /dev/mem
+</BLOCKQUOTE></TT>
+<P>
+Or, it can also be set by adding a line to /etc/system:
+<BLOCKQUOTE><TT>
+set dosynctodr = 0
+</BLOCKQUOTE></TT>
+<P>
+Instead of the <I>tick</I> kernel variable, which many operating
+systems use to control microseconds added to the system time every
+clock tick (c.f. <A HREF="../../notes.html#frequency_tolerance">Dealing
+with Frequency Tolerance Violations</A>), Solaris has the variables
+<I>nsec_per_tick</I> and <I>usec_per_tick</I>.
+<P>
+<I>nsec_per_tick</I> and <I>usec_per_tick</I> control the number of
+nanoseconds and microseconds, respectively, added to the system clock
+each clock interrupt. Enterprising souls may set these based on
+information collected by ntpd in the <CODE>/etc/ntp.drift</CODE> file
+to correct for individual hardware variations.
+<P>
+On UltraSPARC systems, <I>nsec_per_tick</I> and <I>usec_per_tick</I>
+are ignored in favor of the <I>cpu_tick_freq</I> variable, which
+should be automatically be determined by the PROM in an accurate
+fashion.
+<P>
+In general, the same ntp binaries should not be used across multiple
+operating system releases. There is enough variation in the core operating
+system support for timekeeping that a rebuild of ntpd for the idiosyncracies
+of your specific operating system version is advisable.
+<P>
+It is recommended that ntp be started via a script like <A
+HREF="solaris.xtra.S99ntpd">this one</A>, installed in
+<CODE>/etc/init.d/ntpd</CODE> with a symbol link from
+<CODE>/etc/rc2.d/S99ntpd</CODE>.
+
+<H3>Solaris 2.6</H3>
+<P>
+Solaris 2.6 adds support for kernel PLL timekeeping, but breaks this
+support in such a fashion that using it worse than not. This is <A
+HREF="solaris.xtra.4095849"> SUN Bug ID 4095849</A>, and it is not yet
+fixed as of June 1998.
+<P>
+<H3>Solaris 2.5 and 2.5.1</H3>
+<P>
+On UltraSPARC systems, calculation of <I>cpu_tick_freq</I> is broken
+such that values that are off by significant amounts may be used
+instead. This unfortunately means that ntpd may have severe problems
+keeping synchronization. This is <A HREF="solaris.xtra.4023118"> SUN Bug ID
+4023118</A>. Bryan Cantrill <! -- &lt;bmc@eng.sun.com&gt; --> of Sun
+posted <A HREF="solaris.xtra.patchfreq">patchfreq</A>, a workaround script,
+to comp.protocols.time.ntp in March of 1997.
+<P>
+<HR>
+<H2>OLD DATA</H2>
+<STRONG>I can't vouch for the accuracy the information below this
+rule. It may be significantly dated or incorrect.</STRONG>
+<P>
+<P>
+<H3>Solaris 2.2</H3>
+<P>
+Solaris 2.2 and later contain completely re-written clock code to
+provide high resolution microsecond timers. A benefit of the
+re-written clock code is that adjtime does not round off its
+adjustments, so ntp does not have to compensate for this
+rounding. Under Solaris 2.2 and later, ntp #define's
+<CODE>ADJTIME_IS_ACCURATE</CODE>, and does not look for the <I>tickadj</I>
+kernel variable.
+<P>
+<H3>Solaris 2.1</H3>
+(This originally written by William L. Jones &lt;jones@chpc.utexas.edu&gt;)
+<P>
+Solaris 2.1 contains fairly traditional clock code, with <I>tick</I>
+and <I>tickadj</I>.
+<P>
+Since settimeofday under Solaris 2.1 only sets the seconds part of timeval
+care must be used in starting xntpd.  I suggest the following start
+up script:
+<BLOCKQUOTE><TT>
+tickadj -s -a 1000
+<BR>ntpdate -v server1 server2
+<BR>sleep 20
+<BR>ntpdate -v server1 server2
+<BR>sleep 20
+<BR>tickadj -a 200
+<BR>xntpd
+</TT></BLOCKQUOTE>
+
+The first tickadj turns of the time of day clock and sets the tick
+adjust value to 1 millisecond.  This will insure that an adjtime value
+of at most 2 seconds will complete in 20 seconds.
+<P>
+The first ntpdate will set the time to within two seconds 
+using settimeofday or it will adjust time using adjtime.
+<P>
+The first sleep insures the adjtime has completed for the first ntpdate.
+<P>
+The second ntpdate will use adjtime to set the time of day since the
+clock should be within 2 seconds of the correct time.
+<P>
+The second tickadj set the tick adjust system value to 5 microseconds.
+<P>
+The second sleeps insure that adjtime will complete before starting 
+the next xntpd.
+<P>
+I tried running with a tickadj of 5 microseconds with out much success.
+200 microseconds seems to work well.  
+<P>
+<HR>
+Prior versions of this file had major text contributed by:
+<MENU>
+<LI>Denny Gentry &lt;denny@eng.sun.com&gt;
+</MENU>
+<BODY>
+</HTML>
diff --git a/html/build/hints/solaris.xtra.4023118 b/html/build/hints/solaris.xtra.4023118
new file mode 100644 (file)
index 0000000..84c5d15
--- /dev/null
@@ -0,0 +1,36 @@
+ Bug Id: 4023118
+ Category: kernel
+ Subcategory: other
+ State: integrated
+ Synopsis: sun4u doesn't keep accurate time
+ Description:
+
+[ bmc, 12/20/96 ]
+
+The clock on a sun4u drifts unacceptably.  On a typical 143 mHz Ultra,
+the clock took 1.0001350 seconds to count 1 second.  While this may seem
+trivial, it adds up quickly.  In this case, the TOD chip will have to
+pull the clock forward by 2 seconds every 4 hours and 7 minutes.
+This drift rate is so high, that the clock is close to being too broken
+for NTP to guarantee correctness (in order for NTP's mechanism to work,
+it must be assured that the local clock drifts no more than 20 ms in 64
+seconds;  this particular 143 mHz Ultra will drift by nearly 9 ms in that
+period).  This problem has been reproduced on virtually all sun4u
+classes.
+
+The fundamental problem lies in the kernel's perception of ticks per
+second.  The PROM is responsible for determining this figure exactly,
+and the kernel extracts it into the variable cpu_tick_freq.  On sun4u's,
+this number is disconcertingly round:  143000000, 167000000, 248000000,
+etc.  Indeed, a simple experiment revealed that these numbers were
+quite far from the actual ticks per second.  Typical was the 143 mHz
+Ultra which was discovered to tick around 142,980,806 (+/- 10) times
+per second.
+
+ Work around:
+
+        Integrated in releases: s297_27
+ Duplicate of:
+ Patch id:
+ See also:
+ Summary:
diff --git a/html/build/hints/solaris.xtra.4095849 b/html/build/hints/solaris.xtra.4095849
new file mode 100644 (file)
index 0000000..8d3ce80
--- /dev/null
@@ -0,0 +1,74 @@
+ Bug Id: 4095849
+ Category: kernel
+ Subcategory: syscall
+ State: evaluated
+ Synopsis: time_constant value >6 with PLL in use leads to integer divide
+           zero trap panic
+ Description:
+If the time_constant parameter is 7 or higher, and the phase-lock looping model
+is in use, the system will take a "integer divide zero trap" panic in
+the clock routine as soon as the time_offset becomes non-zero.
+
+time_constant defaults to 0.  The only place it is set is in the ntp_adjtime
+system call, from the 'constant' element of the timex structure argument.
+
+ Work around:
+Never set the constant element of the timex structure passed to ntp_adjtime to
+a value larger than 6.
+
+satish.mynam@Eng 1998-04-30
+1. Use Sun's version of NTP software instead of PD version. This problem
+is not seen with Sun's NTP version (which is mostly eqivalent to PD NTP 3.4
+plus some Sun's local functionality futures).
+
+2. Workaround for the public domain NTP version  ONLY:
+ =====================================================
+The workaround for public domain NTP version is to disable the
+KERNEL_PLL from the NTP code. This way ntp_Adjtime() system call is
+totally bypassed without sacrificing any of the functionality of the
+NTP. The only hit you might see is the way  kernel precision timminig
+is done without the PLL algorithm in the kernel.
+
+    The easiest way to disable ntp_adjtime option is(without changing
+    any makefiles or other config files) to disable the KERNEL_PLL
+    value in the ./config.h file.
+
+After doing a ./configure for probing for all the necessary tools(compilers,
+os version, libraries),  please comment out KERNEL_PLL macro in
+the ./config.h  file.  This will disable the KERNEL_PLL part of the source
+code and the newly obtained xntpd is just similar to the old one but it
+does not use ntp_adjtime() system call. This prevents it from panic'ng
+the kernel.
+
+/*#define KERNEL_PLL 1*/
+
+I complied a new xntpd binary this way and it does nothave any ntp_adjtime()
+related stuff.
+
+Default:
+=======
+/net/divya/export/home/mynam/public_domain/ntp/xntp3-5.92/xntpd>strings
+xntpd |
+grep ntp_adjtime
+354:adj_frequency: ntp_adjtime failed: %m
+357:loop_config: ntp_adjtime() failed: %m
+435:get_kernel_info: ntp_adjtime() failed: %m
+
+With KERNEL_PLL disabled in config.h file
+-=======================
+
+/net/divya/export/home/mynam/public_domain/ntp/xntp3-5.92/xntpd>strings
+xntpd.nopll | grep ntp_adjtime
+
+        Integrated in releases:
+ Duplicate of:
+ Patch id:
+ See also: 4133517
+ Summary:
+If the time_constant parameter is 7 or higher, and the phase-lock looping model
+is in use, the system will take a "integer divide zero trap" panic in
+the clock routine as soon as the time_offset becomes non-zero.
+
+time_constant defaults to 0.  The only place it is set is in the ntp_adjtime
+system call, from the 'constant' element of the timex structure argument.
+----------------------------------------------------------------------------
diff --git a/html/build/hints/solaris.xtra.S99ntpd b/html/build/hints/solaris.xtra.S99ntpd
new file mode 100644 (file)
index 0000000..d8058fd
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+if [ $1 = "start" ]; then
+        if [ -x /usr/local/bin/xntpd ]; then
+                echo "Starting NTP daemon, takes about 1 minute... "
+               # dosynctodr may need to be left alone as of with Solaris 2.6
+               # The following line is unnecessary if you turn off 
+               # dosynctodr in /etc/system.
+                /usr/local/bin/tickadj -s  
+                /usr/local/bin/ntpdate -v server1 server2
+                sleep 5
+                /usr/local/bin/xntpd
+        fi
+else
+        if [ $1 = "stop" ]; then
+                pid=`/usr/bin/ps -e | /usr/bin/grep xntpd | /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`   
+                if [ "${pid}" != "" ]; then
+                        echo "Stopping Network Time Protocol daemon "
+                        /usr/bin/kill ${pid}
+                fi     
+        fi
+fi
diff --git a/html/build/hints/solaris.xtra.patchfreq b/html/build/hints/solaris.xtra.patchfreq
new file mode 100644 (file)
index 0000000..9600881
--- /dev/null
@@ -0,0 +1,85 @@
+#!/bin/ksh
+
+#
+# File:         patchfreq
+# Author:       Bryan Cantrill (bmc@eng.sun.com), Solaris Performance
+# Modified:     Sat Apr 26 04:00:59 PDT 1997
+#
+# This is a little script to patch a 5.5 or 5.5.1 kernel to get around
+# the cpu_tick_freq inaccuracy.  Before running this script, one must
+# know the true frequency of one's CPU;  this can be derived by NTP,
+# or by observing the clock relative to the time-of-day chip over a
+# long period of time (the TOD will pull system time when it drifts
+# by more than two seconds).
+#
+# Patching a kernel can render a machine unbootable;  do not run this
+# script unless you are prepared to accept that possibility.  It
+# is advisable to have a backout path (e.g. net booting, an alternate
+# boot disk, an installation CD) should your machine fail to boot.
+#
+# This is not a product of Sun Microsystems, and is provided "as is",
+# without warranty of any kind expressed or implied including, but not
+# limited to, the suitability of this script for any purpose.
+#
+
+if [ $# -eq 0 ]; then
+        echo "Usage:  $0 cpu_tick_freq [ alternate_kernel ]"
+        exit 1
+fi
+
+cpu_tick_freq=$1
+kernel=/platform/sun4u/kernel/unix
+
+if [ $# -eq 2 ]; then
+        kernel=$2
+fi
+
+if [ ! -w $kernel ]; then
+        echo "$0:  Cannot open $kernel for writing."
+        exit 1
+fi
+
+arch=`echo utsname+404?s | adb $kernel | cut -d: -f2`
+
+if [ ! $arch = "sun4u" ]; then
+        echo "Patch only applies to sun4u"
+        exit 1
+fi
+
+rel=`echo utsname+202?s | adb $kernel | cut -d: -f2`
+
+if [ ! $rel = "5.5" ] && [ ! $rel = "5.5.1" ]; then
+        echo "Patch only applies to 5.5 or 5.5.1..."
+        exit 1
+fi
+
+nop="1000000"           # nop
+store_mask="ffffe000"   # mask out low 13 bits
+store="da256000"        # st      %o5, [%l5 + offset]
+
+instr=`echo setcpudelay+34?X | adb $kernel | cut -d: -f 2 | nawk '{ print $1 }'`
+
+if [ $instr = $nop ]; then
+        echo "Instruction already patched..."
+else
+        let masked="(16#$store_mask & 16#$instr) - 16#$store"
+        if [ $masked -ne 0 ]; then
+                echo "Couldn't find instruction to patch;  aborting."
+                exit 1
+        fi
+
+        if ! echo setcpudelay+34?W $nop | adb -w $kernel 1> /dev/null
+        then
+                echo "adb returned an unexpected error;  aborting."
+        fi
+fi
+
+echo "Patching cpu_tick_freq to $cpu_tick_freq..."
+
+if ! echo cpu_tick_freq?W 0t$cpu_tick_freq | adb -w $kernel 1> /dev/null; then
+        echo "adb returned an unexpected error;  aborting."
+        exit 1
+fi
+
+echo "$kernel successfully patched."
+exit 0
diff --git a/html/build/hints/sun4 b/html/build/hints/sun4
new file mode 100644 (file)
index 0000000..424fa18
--- /dev/null
@@ -0,0 +1,15 @@
+Notes on CPU clock oscillator tolerance with SunOS 4.1.1 and 4.1.3
+
+A bug in SunOS 4.1.1 results in the kernel time losing 1 microsecond
+per tick of the system clock. The bug was fixed (bugid 1094383) for
+SunOS 4.1.1 and corrected in SunOS 4.1.3. The easiest way to fix this
+is to replace the 4.1.1 binary clock.o with the corresponding 4.1.3
+binary. Without this change it is necessary to use the tickadj program
+included in this distribution with the -t 9999 option.
+
+The tickadj option will work in all cases except when the kernel has
+been modified to correct the CPU clock oscillator frequency using a
+1-pps signal from a precision source. The bugfix must be installed for
+this wrinkle to work properly.
+
+Dave Mills (mills@udel.edu)
diff --git a/html/build/hints/svr4-dell b/html/build/hints/svr4-dell
new file mode 100644 (file)
index 0000000..2c92f8a
--- /dev/null
@@ -0,0 +1,8 @@
+Notes on the DELL SVR4.
+
+You should use -DSETTIMEOFDAY_BROKEN.
+
+Philip.Gladstone@mail.citicorp.com
+
+(XXX But there is no checking for SETTIMEOFDAY_BROKEN in the code)
+
diff --git a/html/build/hints/svr4_package b/html/build/hints/svr4_package
new file mode 100644 (file)
index 0000000..b9f5ca3
--- /dev/null
@@ -0,0 +1,33 @@
+Date: Wed, 12 Apr 1995 12:42:03 +0100
+Message-ID: <513.797686923@concurrent.co.uk>
+From: Andy Chittenden <asc@concurrent.co.uk>
+
+Dave
+
+Here is a uuencoded, compressed tar file. The only file I've
+changed is Makefile - I've included the full file rather than diffs.
+There are some new files as well:
+
+       xntp    shell script that starts up ntp during boot up
+               (the packaging stuff creates links to it so it comes
+               up at run level 2). As with all svr4 start/stop
+               scripts, it takes one parameter which is either
+               start or stop. It assumes that ntp.conf is in
+               /etc/inet/ntp.conf (where it should be on svr4
+               machines).
+       prototype       describes the file contents of the package.
+                       You might like to review its contents to
+                       see whether you want to include any other
+                       files or remove some. NB I've made the man 
+                       pages go into 1m as they should on svr4.
+       preinstall      runs before installation takes place. It
+                       ensures that ntp is down if it is up before
+                       installing a replacement package
+       postinstall     starts up ntp after package installation.
+       preremove       brings down ntp before removing the package.
+
+You create a package using "make package". This creates a file
+called xntp.pkg. To install this package, you use 
+"pkgadd -d `pwd`/xntp.pkg xntp". This will start up ntp if
+/etc/inet/ntp.conf exists. If you don't want the package anymore, use 
+"pkgrm xntp". I have tested this on Solaris 2.4.
diff --git a/html/build/hints/todo b/html/build/hints/todo
new file mode 100644 (file)
index 0000000..e0e5ffa
--- /dev/null
@@ -0,0 +1,4 @@
+Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>:
+       Any change in a source file in the lib directory causes all files to
+       be recompiled (because the objects are removed). Add a better rule for
+       make to update the library. Maybe just remove "-rm -f $?".
diff --git a/html/build/hints/vxworks.html b/html/build/hints/vxworks.html
new file mode 100644 (file)
index 0000000..95ad222
--- /dev/null
@@ -0,0 +1,82 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <title>vxWorks Port of NTP</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body link="#00008B" vlink="#8B0000">
+        <h1>VxWorks port of NTP</h1>
+        <p>Creating a port for vxWorks posed some problems. This port may help as a starting point for similar ports to real-time OS's and other embeddable kernels, particularly where main() is not allowed, and where the configure scripts need to be altered.</p>
+        <h1><b>Configuration issues</b></h1>
+        <p>I decided to do as little invasive surgery as possible on the NTP code, so I brought the vxWorks header tree in line with the standard unix tree. The following changes were needed, as a side effect these changes will allow for easy porting of other autoconfigure enabled code.</p>
+        <p>Where I have 386 you will need to put in your target type. The vxWorks tree entry point is /usr/wind. If these are the same for your system, you should be able to cut and paste the changes.</p>
+        <p><blink>WARNING: Check you are not overwriting files, before entering the following: there should be no conflict, but check first... </blink></p>
+        <p>export CC=&quot;cc386 -nostdlib -m486 -DCPU=I80486 -I/usr/wind/target/h&quot;<br>
+            export RANLIB=ranlib386<br>
+            export AR=ar386<br>
+            export VX_KERNEL=/usr/wind/target/config/ims_std_bsp/vxWorks<br>
+            cd /usr/wind/target/sys<br>
+            ln -s ../signal.h<br>
+            ln -s ../time.h<br>
+            ln -s socket.h sockio.h<br>
+            ln -s ../selectLib.h select.h<br>
+            ln -s ../timers.h<br>
+            touch file.h param.h resource.h utsname.h var.h ../netdb.h ../a.out.h ../termios.h<br>
+            echo &quot; ******ADD #include \&quot;sys/times.h\&quot; to sys/time.h &quot;</p>
+        <p>The configure script must be changed in the following way to get the linking tests to work, once in the correct directory issue the following commands:<br>
+            sed -e 's%main.*()%vxmain()%' configure &gt; configure.vxnew<br>
+            mv configure.vxnew configure<br>
+            chmod 755 configure</p>
+        <p>The new version 4 of NTP requires some maths functions so it links in the maths library (-lm) in the ntpd <a href="../../ntpd/Makefile.am">Makefile.am</a> change the line &quot;ntpd_LDADD = $(LDADD) -lm&quot; by removing the &quot;-lm&quot;.<br>
+            You are now ready to compile</p>
+        <p><br>
+            The <a href="../../configure.in">configure.in </a>file needed to be altered to allow for a host-target configuration to take place.</p>
+        <ul>
+            <li>The define SYS_VXWORKS was added to the compilation flags.
+            <li>Little endianess is set if the target is of type iX86.
+            <li>The size of char, integer, long values are all set. If Wind River ever changes these values they will need to be updated.
+            <li>clock_settime() is defined to be used for setting the clock.
+            <li>The Linking flags have -r added to allow for relinking into the vxWorks kernel
+        </ul>
+        <p>Unfortunately I have had to make use of the <a href="../../include/ntp_machine.h">ntp_machine.h </a>file to add in the checks that would have been checked at linking stage by autoconf, a better method should be devised.</p>
+        <ul>
+            <li>There is now a NO_MAIN_ALLOWED define that simulates command line args, this allows the use of the normal startup sysntax.
+            <li>POSIX timers have been added.
+            <li>Structures normally found in netdb.h have been added with, the corresponding code is in <a href="../../libntp/machines.c">machines.c </a>. Where possible the defines for these have been kept non-vxWorks specific.
+        </ul>
+        <p>Unfortunately there are still quite a few SYS_VXWORKS type defines in the source, but I have eliminated as many as possible. You have the choice of using the usrtime.a library avaliable from the vxworks archives or forgoing adjtime() and using the clock_[get|set]time().The <a href="../../include/ntp_machine.h">ntp_machine.h </a>file clearly marks how to do this.</p>
+        <h1><b>Compilation issues</b></h1>
+        <p>You will need autoconf and automake ... available free from the gnu archives worldwide.</p>
+        <p>The variable arch is the target architecture (e.g. i486)</p>
+        <p>mkdir A.vxworks (or whatever....)<br>
+            cd A.vxworks<br>
+            ../configure --target=arch-wrs-vxworks [any other options]<br>
+            make</p>
+        <p>Options I normally use are the --disable-all-clocks --enable-LOCAL-CLOCK flags. The program should proceed to compile without problem. The daemon ntpd, ntpdate, ntptrace, ntpdc, ntpq programs and of course the libraries are all fully ported. The other utilities are not, but they should be easy to port.</p>
+        <h1>Running the software</h1>
+        <p>Load in the various files, call them in the normal vxWorks function type manner. Here are some examples. Refer to the man pages for further information.</p>
+        <p>ld &lt; ntpdate/ntpdate<br>
+            ld &lt; ntpd/ntpd<br>
+            ld &lt; ntptrace/ntptrace<br>
+            ld &lt; ntpq/ntpq<br>
+            ld &lt; ntpdc/ntpdc<br>
+            ntpdate (&quot;-b&quot;, &quot;192.168.0.245&quot;)<br>
+            sp(ntpd, &quot;-c&quot;, &quot;/export/home/casey/ntp/ntp.conf&quot;)<br>
+            ntpdc(&quot;-c&quot;, &quot;monlist&quot;, &quot;192.168.0.244&quot;)<br>
+            ntpq(&quot;-c&quot;, &quot;peers&quot;, &quot;192.168.0.244&quot;)<br>
+            ntptrace(&quot;192.168.0.244&quot;)<br>
+        </p>
+        <h1>Bugs and such</h1>
+        <p>Should you happen across any bugs, please let me know, or better yet fix them and submit a patch. Remember to make you patch general for Vxworks, not just for your particular architecture. <a href="http://www.ccii.co.za">CCII Systems (Pty) Ltd</a>, my ex employers, sponsored the time to this port. Please let me know how it goes, I would be most interested in offsets and configurations.</p>
+        <p><br>
+        </p>
+        <p>Casey Crellin<br>
+            <a href="mailto:casey@csc.co.za">casey@csc.co.za</a></p>
+        <p><br>
+        </p>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/build/hints/winnt.html b/html/build/hints/winnt.html
new file mode 100644 (file)
index 0000000..78de15d
--- /dev/null
@@ -0,0 +1,281 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <title>NTP on Windows NT</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h1>NTP 4.x for Windows NT</h1>
+
+        <h2>Introduction</h2>
+        The NTP 4 distribution runs as service on Windows NT 4.0, Windows 2000, Windows XP,
+        Windows .NET Server 2003. It will NOT run on Windows 95, 98, ME, etc.
+        The binaries work on multi-processor systems. This port has not been tested
+        on the Alpha platform. This release now uses OpenSSL for authentication.
+        IPv6 is not implemented yet for Win32 platforms.
+        <h2>Authentication Keys</h2>
+        With this release ntp-keygen is supported. See the <a href="../../keygen.html">
+        ntp keygen documentation</a> for details on how to use ntp-keygen.
+        <p>
+        ntpd can now use the generated keys in the same way as on Unix platforms. Please
+        refer to the <a href="../../authopt.html">Authentication Options</a> for details
+        on how to use these.
+        <p><B>NOTE:</B> ntpd and ntp-keygen both use OpenSSL which requires a random
+        character file called .rnd by default. Both of these programs will automatically
+        generate this file if they are not found. The programs will look for an
+        environmental variable called RANDFILE and use that for the name of the
+        random character file if the variable exists. If it does not exist it will look for an environmental
+        variable called HOME and use that directory to search for a filed called .rnd
+        in that directory. Finally, if neither RANDFILE nor HOME exists it will look
+        in C:\ for a .rnd file. In each case it will search for and create the file
+        if the environmental variable exists or in the C:\ directory if it doesn't.
+        Note that ntpd normally runs as a service so that the only way that it will
+        have either RANDFILE or HOME defined is if it is a System environmental
+        variable or if the service is run under a specific account name and that
+        account has one of those variables defined. Otherwise it will use the file
+        "c:\.rnd". This was done so that OpenSSL will work normally on Win32 systems.
+        This obviates the need to ship the OpenSSL.exe file and explain how to
+        generate the .rnd file. A future version may change this behavior.
+
+        <p>Refer to <a href="#Compiling">Compiling Requirements</a> and Instructions for how to compile the program.</p>
+        <h2>Reference Clocks</h2>
+        Reference clock support under Windows NT is tricky because the IO functions are
+        so much different. Some of the clock types have been built into the ntpd executable
+        and should work but have not been tested by the ntp project. If you have a clock
+        that runs on Win32 and the driver is there but not implemented on Win32 you will have
+        make the required configuration changes in config.h and then build ntpd from source
+        and test it. The following reference clocks are known to work and are supported
+        by Windows NT:
+        <p><a href="../../driver1.html">Type 1</a> Undisciplined Local Clock (LOCAL)<br>
+            <a href="../../driver29.html">Type 29</a> Trimble Navigation Palisade GPS (GPS_PALISADE)</p>
+        <h2>Functions Supported</h2>
+        All NTP functions are supported with some constraints. See the <a href="#ToDo">TODO list</a> below.
+        Note that the ntptrace executable is not supported and you should use the PERL script
+        version instead.
+        <h2>Accuracy</h2>
+        Greg Brackley has implemented a fantastic interpolation scheme that improves the precision of the NTP clock
+        using a realtime thread (is that poetic or what!) which captures a tick count from the 8253 counter after each
+        OS tick. The count is used to interpolate the time between operating system ticks.
+        <p>On a typical 200+ MHz system NTP achieves a precision of about 5 microseconds and synchronizes the clock 
+        to +/-500 microseconds using the <a href="http://www.trimble.com/products/ntp">Trimble Palisade</a> as UTC reference.
+        This allows distributed applications to use the 10 milliseconds ticks available to them with high confidence.</p>
+        <h2>Binaries</h2>
+        Recent InstallShield based executable versions of NTP for Windows NT (intel) are available from:
+        <ul>
+        <li><a href="http://www.trimble.com/oem/ntp">http://www.trimble.com/oem/ntp</a>
+        <li><a href="http://www.five-ten-sg.com/">http://www.five-ten-sg.com/</a>
+        <li><a href="http://www.meinberg.de/english/sw/ntp.htm">http://www.meinberg.de/english/sw/ntp.htm</a>
+        </ul>
+        <a name="ToDo"><h2>ToDo</h2></a>
+        These tasks are in no particular order of priority.
+        <ul>
+            <li>Create a proper install/uninstall program
+            <li>Add sntp to the list of supported programs
+            <li>Add support for Visual C++ 7.0 or later (.NET)
+            <li>Add IPv6 support
+            <li>See if precision can be improved by using CPU cycle counter for tick interpolation.
+            <li>Make precision time available to applications using NTP_GETTIME API
+        </ul>
+        <h2>Compiling Requirements</h2>
+        <ul>
+            <li>Windows NT 4.0 Windows 2000, Windows XP, or Windows.NET Server 2003
+            <li>Microsoft Visual C++ 6.0. <B>NOTE:</B> VC++ 7.0 (aka .NET) is not yet supported
+            but will probably work fine.
+            <li>Some way of uncompressing and untarring the gzipped tar file.
+            <li>OpenSSL must be built on the box before building NTP. Additional steps would
+            be required to not use OpenSSL.
+        </ul>
+        <a name="Compiling"><h2>Compiling Instructions</h2></a>
+        <ol>
+            <li>Unpack and build OpenSSL according to the OpenSSL instructions for building on
+            Windows. An environment variable named OPENSSL must be set up to specify the base path 
+            of the OpenSSL directory to be used to build the NTP package
+            (e.g. <code>OPENSSL=C:\openssl-0.9.8b</code>).
+            <li>Unpack the ntp-*.tar.gz archive using utilities such as WinZip.
+            <li>Open the .\ports\winnt\ntp.dsw Visual C workspace
+            <li>Batch build all projects
+            <li>The built binaries can be found in the port\winnt\bin\Release subdirectory
+            <li>In addition you will need to install the OpenSSL libeay32.dll
+            <li>If you are shipping binaries in a kit it is strongly recommended that you
+            ship this file (winnt.html) along with the binaries.
+        </ol>
+        <h2>Configuration File</h2>
+        The default NTP configuration file path is %SystemRoot%<tt>\system32\drivers\etc\. </tt>(%SystemRoot% 
+        is an environmental variable that can be determined by typing &quot;set&quot; at the &quot;Command Prompt&quot; 
+        or from the &quot;System&quot; icon in the &quot;Control Panel&quot;).<br>
+        Refer to your system environment and <tt>c</tt>reate your<tt> ntp.conf</tt> file in the directory 
+        corresponding to your system&nbsp; installation.<br>
+        <tt>The older &lt;WINDIR&gt;\ntp.conf </tt>is still supported but you will get a log entry reporting that 
+        the first file wasn't found.
+        <h2>Installation Instructions</h2>
+        The <tt>instsrv</tt> program in the instsrv subdirectory of the distribution can be used to install 'ntpd' as 
+        a service and start automatically at boot time. Instsrv is automatically compiled with the rest of the distribution
+        if you followed the steps above.
+        <ol>
+            <li>Start a command prompt and enter &quot;instsrv.exe &lt;pathname_for_ntpd.exe&gt;&quot;
+            <li>Clicking on the &quot;Services&quot; icon in the &quot;Control Panel&quot; will display the list of 
+            currently installed services in a dialog box. The NetworkTimeProtocol service should show up in this list.
+            Select it in the list and hit the &quot;Start&quot; button in the dialog box. The NTP service should start.
+            <li>You can also stop and start the service by typing net start|stop NetworkTimeProtocol at the DOS prompt.
+            <li>View the event log by clicking on the &quot;Event Viewer&quot; icon in the &quot;Administrative Tools&quot; 
+            group, there should be several successful startup messages from NTP. NTP will keep running and restart 
+            automatically when the machine is rebooted.
+        </ol>
+        You can change the start mode (automatic/manual) and other startup parameters corresponding to the NTP service 
+        in the &quot;Services&quot; dialog box if you wish.
+        <h2>Removing NTP</h2>
+        You can also use <tt>instsrv</tt> to delete the NTP service by entering: &quot;instsrv.exe remove&quot;
+        <h2>Command Line Parameters and Registry Entries</h2>
+        Unlike the Unix environment, there is no clean way to run 'ntpdate' and reset the clock before starting 'ntpd' at boot time.<br>
+        NTP will step the clock up to 1000 seconds by default. While there is no reason that the system clock should be that much off 
+        during bootup if 'ntpd' was running before, you may wish to override this default and/or pass other command line directives.
+        <p>Use the registry editor to edit the value for the ntpd executable under LocalMachine\System\CurrentControlSet\Services\NTP.</p>
+        <p>Add the -g option to the ImagePath key, behind &quot;%INSTALLDIR&gt;\ntpd.exe&quot;. This will force NTP to accept 
+        large time errors (including 1.1.1980 00:00)</p>
+        <h2>Bug Reports</h2>
+        Send questions to <a href="news://comp.protocols.time.ntp">news://comp.protocols.time.ntp</a>
+        and bug reports should be entered in <a href="http://bugzilla.ntp.org/">Bugzilla</a> on the
+        NTP Web site.
+        <h2>Change Log</h2>
+        <h3>Last revision 2 July 2003&nbsp; Version 4.2.0</h3>
+        <b>by Danny Mayer (mayer@ntp.org>)</b>
+        <h3>Significant Changes:</h3>
+        This latest release of NTP constitutes a major upgrade to its ability to build and
+        run on Windows platforms and should now build and run cleanly. More importantly it
+        is now able to support all authentication in the same way as Unix boxes. This does
+        require the usage of OpenSSL which is now a prerequisite for build on Windows.
+        ntp-keygen is now supported and builds on Win32 platforms.
+
+        <h3>Last revision 16 February 1999&nbsp; Version 4.0.99e.</h3>
+        <b>by Sven Dietrich (sven_dietrich@trimble.com)</b>
+        <p><b>Significant Changes:</b></p>
+        <ul>
+            <li>Perl 5 is no longer needed to compile NTP. The configuration script which creates version.c 
+            with the current date and time was modified by Frederick Czajka [w2k@austin.rr.com] so that Perl
+            is no longer required.
+        </ul>
+        <h3>Last revision 15 November 1999&nbsp; Version 4.0.98f.</h3>
+        <b>by Sven Dietrich (sven_dietrich@trimble.com)</b>
+        <p><b>Significant Changes:</b></p>
+        <ul>
+            <li>Fixed I/O problem delaying packet responses which resulted in no-replys to NTPQ and others.
+            <li>The default configuration file path is <tt>&lt;WINDIR&gt;\system32\drivers\etc\ntp.conf. 
+            The old &lt;WINDIR&gt;\ntp.conf </tt>is still supported but you will get a log entry reporting 
+            that the first file wasn't found. The NTP 3.x legacy <tt>ntp.ini</tt> file is no longer supported.
+        </ul>
+        <b>Known Problems / TODO:</b>
+        <ul>
+            <li>MD5 and name resolution do not yet get along. If you define MD5, you cannot use DNS names, only IP numbers.
+        </ul>
+        <h3>Last revision 27 July 1999&nbsp; Version 4.0.95.</h3>
+        This version compiles under WINNT with Visual C 6.0.
+        <p>Greg Brackley and Sven Dietrich</p>
+        <p>Significant changes:<br>
+            -Visual Studio v6.0 support<br>
+            -Winsock 2.0 support<br>
+            -Use of I/O completion ports for sockets and comm port I/O<br>
+            -Removed the use of multimedia timers (from ntpd, others need removing)<br>
+            -Use of waitable timers (with user mode APC) and performance counters to fake getting a better time<br>
+            -Trimble Palisade NTP Reference Clock support<br>
+            -General cleanup, prototyping of functions<br>
+            -Moved receiver buffer code to a separate module (removed unused members from the recvbuff struct)<br>
+            -Moved io signal code to a separate module</p>
+        <h3>Last revision:&nbsp; 20-Oct-1996</h3>
+        This version corrects problems with building the XNTP<br>
+        version 3.5-86 distribution under Windows NT.
+        <p>The following files were modified:<br>
+            &nbsp;blddbg.bat<br>
+            &nbsp;bldrel.bat<br>
+            &nbsp;include\ntp_machine.h<br>
+            &nbsp;xntpd\ntp_unixclock.c<br>
+            &nbsp;xntpd\ntp_refclock.c<br>
+            &nbsp;scripts\wininstall\build.bat<br>
+            &nbsp;scripts\wininstall\setup.rul<br>
+            &nbsp;scripts\wininstall\readme.nt<br>
+            &nbsp;scripts\wininstall\distrib\ntpog.wri<br>
+            &nbsp;html\hints\winnt (this file)</p>
+        <p>In order to build the entire Windows NT distribution you<br>
+            need to modify the file scripts\wininstall\build.bat<br>
+            with the installation directory of the InstallShield<br>
+            software.&nbsp; Then, simply type &quot;bldrel&quot; for non-debug<br>
+            or &quot;blddbg&quot; for debug executables.</p>
+        <p>Greg Schueman<br>
+            &nbsp;&nbsp;&nbsp; &lt;schueman@acm.org&gt;</p>
+        <h3>Last revision:&nbsp; 07-May-1996</h3>
+        This set of changes fixes all known bugs, and it includes<br>
+        several major enhancements.
+        <p>Many changes have been made both to the build environment as<br>
+            well as the code.&nbsp; There is no longer an ntp.mak file, instead<br>
+            there is a buildntall.bat file that will build the entire<br>
+            release in one shot.&nbsp; The batch file requires Perl.&nbsp; Perl<br>
+            is easily available from the NT Resource Kit or on the Net.</p>
+        <p>The multiple interface support was adapted from Larry Kahn's<br>
+            work on the BIND NT port.&nbsp; I have not been able to test it<br>
+            adequately as I only have NT servers with one network<br>
+            interfaces on which to test.</p>
+        <p>Enhancements:<br>
+            * Event Logging now works correctly.<br>
+            * Version numbers now work (requires Perl during build)<br>
+            * Support for multiple network interface cards (untested)<br>
+            * NTP.CONF now default, but supports ntp.ini if not found<br>
+            * Installation procedure automated.<br>
+            * All paths now allow environment variables such as %windir%</p>
+        <p>Bug fixes:<br>
+            * INSTSRV replaced, works correctly<br>
+            * Cleaned up many warnings<br>
+            * Corrected use of an uninitialized variable in XNTPD<br>
+            * Fixed ntpdate -b option<br>
+            * Fixed ntpdate to accept names as well as IP addresses<br>
+            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; (Winsock WSAStartup was called after a gethostbyname())<br>
+            * Fixed problem with &quot;longjmp&quot; in xntpdc/ntpdc.c that<br>
+            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; caused a software exception on doing a Control-C in xntpdc.<br>
+            &nbsp;A Cntrl-C now terminates the program.</p>
+        <p>See below for more detail:</p>
+        <p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Note: SIGINT is not supported for any Win32 application including<br>
+            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Windows NT and Windows 95. When a CTRL+C interrupt occurs, Win32<br>
+            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; operating systems generate a new thread to specifically handle that<br>
+            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; interrupt. This can cause a single-thread application such as UNIX,<br>
+            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; to become multithreaded, resulting in unexpected behavior.<br>
+            &nbsp;</p>
+        <p>Possible enhancements and things left to do:<br>
+            * Reference clock drivers for NT (at least Local Clock support)<br>
+            * Control Panel Applet<br>
+            * InstallShield based installation, like NT BIND has<br>
+            * Integration with NT Performance Monitor<br>
+            * SNMP integration<br>
+            * Fully test multiple interface support<br>
+            &nbsp;</p>
+        <p>Known problems:<br>
+            *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; bug in ntptrace - if no Stratum 1 servers are available,<br>
+            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; such as on an 
+            IntraNet, the application crashes.</p>
+        <h3>Last revision:&nbsp; 12-Apr-1995</h3>
+        This NTPv3 distribution includes a sample configuration file and the project<br>
+        makefiles for WindowsNT 3.5 platform using Microsoft Visual C++ 2.0 compiler.<br>
+        Also included is a small routine to install the NTP daemon as a &quot;service&quot;<br>
+        on a WindowsNT box. Besides xntpd, the utilities that have been ported are<br>
+        ntpdate and xntpdc. The port to WindowsNT 3.5 has been tested using a Bancomm<br>
+        TimeServe2000 GPS receiver clock that acts as a strata 1 NTP server with no<br>
+        authentication (it has not been tested with any refclock drivers compiled in).<br>
+        Following are the known flaws in this port:<br>
+        1) currently, I do not know of a way in NT to get information about multiple<br>
+        &nbsp;&nbsp; network interface cards. The current port uses just one socket bound to<br>
+        &nbsp;&nbsp; INADDR_ANY address. Therefore when dealing with a multihomed NT time server,<br>
+        &nbsp;&nbsp; clients should point to the default address on the server (otherwise the<br>
+        &nbsp;&nbsp; reply is not guaranteed to come from the same interface to which the<br>
+        &nbsp;&nbsp; request was sent). Working with Microsoft to get this resolved.<br>
+        2) There is some problem with &quot;longjmp&quot; in xntpdc/ntpdc.c that causes a<br>
+        &nbsp;&nbsp; software exception on doing a Control-C in xntpdc. Be patient!<br>
+        3) The error messages logged by xntpd currently contain only the numerical<br>
+        &nbsp;&nbsp; error code. Corresponding error message string has to be looked up in<br>
+        &nbsp;&nbsp; &quot;Books Online&quot; on Visual C++ 2.0 under the topic &quot;Numerical List of Error<br>
+        &nbsp;&nbsp; Codes&quot;.
+        <p>Last HTML Update: November 17, 1999<br>
+            <a href="mailto://sven_dietrich@trimble.com">Sven_Dietrich@Trimble.COM</a></p>
+    </body>
+
+</html>
diff --git a/html/build/patches.html b/html/build/patches.html
new file mode 100644 (file)
index 0000000..00b2923
--- /dev/null
@@ -0,0 +1,36 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <title>Patching Procedures</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Patching Procedures</h3>
+        <img src="../pic/alice38.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html"> rom <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+        <p>The Mad Hatter needs patches.</p>
+        <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="99">12:56 AM</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="266">Saturday, March 20, 2004</csobj></p>
+        <br clear="left">
+        <hr>
+        <p>A distribution so widely used as this one eventually develops numerous barnacles as the result of <a href="porting.html">porting</a> to new systems, idiosyncratic new features and just plain bugs. In order to help keep order and make maintenance bearable, we ask that proposed changes to the distribution be submitted in the following form.</p>
+        <ol>
+            <li>Please submit patches to <a href="mailto:bugs@mail.ntp.org">bugs@mail.ntp.org</a> in the form of either unified-diffs (<tt>diff -u</tt>) or context-diffs (<tt>diff -c</tt>).
+            <li>Please include the <strong>output</strong> from <tt>config.guess</tt> in the description of your patch. If <tt>config.guess</tt> does not produce any output for your machine, please fix that, too!
+            <li>Please base the patch on the root directory of the distribution. The preferred procedure here is to copy your patch to the root directory and mumble
+            <p><tt>patch -p &lt;your_patch&gt;</tt></p>
+            <li>Please avoid patching the RCS subdirectories; better yet, clean them out before submitting patches.
+            <li>If you have whole new files, as well as patches, wrap the files and patches in a shell script. If you need to compress it, use either GNU <tt>gzip</tt> or the stock Unix <tt>compress</tt> utility.
+            <li>Don't forget the documentation that may be affected by the patch. Send us patches for the <tt>./htm</tt> files as well.
+            <li>We would be glad to include your name, electric address and descriptive phrase in the <a href="../copyright.html">Copyright</a> page, if you wish.
+        </ol>
+        <p>Prior to ntp3-5.83 (releases up to and including ntp3.5f) a complete patch history back to the dark ages was kept in the <tt>./patches</tt> directory, which might have been helpful to see if the same problem occurred in another port, etc. Patches were saved in that directory with file name in the form <tt>patch.<i>nnn</i></tt>, where <i>nnn</i> was approaching 200. All patches in that directory have been made; so, if yours was there, it was in the distribution.</p>
+        <p>Since we have been getting multple patches for some bugs, plus many changes are implemented locally, no two maintainers here use the same tools, and since we're not using any bug-tracking software or even source code control, there is currently no tracking of specific changes.</p>
+        <p>The best way to see what's changed between two distributions is to run a <tt>diff</tt> against them.</p>
+        <p>Thanks for your contribution and happy chime.</p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
diff --git a/html/build/porting.html b/html/build/porting.html
new file mode 100644 (file)
index 0000000..976cc66
--- /dev/null
@@ -0,0 +1,40 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <title>Porting Hints</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Porting Hints</h3>
+        <img src="../pic/wingdorothy.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>The Wizard of Oz</i>, L. Frank Baum</a>
+        <p>Porting Dorothy in Oz
+        </p>
+        <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="99">12:56 AM</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="266">Saturday, March 20, 2004</csobj></p>
+        <br clear="left">
+        <hr>
+        <p>NOTE: The following procedures have been replaced by GNU <tt>automake</tt> and <tt>autoconfigure</tt>. This page is to be updated in the next release.</p>
+        <p>Porting to a new machine or operating system ordinarily requires updating the <tt>./machines</tt> directory and the <tt>./compilers</tt> directories in order to define the build environment and autoconfigure means. You will probably have to modify the <tt>ntp_machines.h</tt> file and <tt>&quot;l_stdlib.h&quot;</tt> files as well. The two most famous trouble spots are the I/O code in <tt>./ntpd/ntp_io.c</tt> and the clock adjustment code in <tt>./ntpd/ntp_unixclock.c</tt>.</p>
+        <p>These are the rules so that older bsd systems and the POSIX standard system can coexist together.</p>
+        <ol>
+            <li>If you use <tt>select</tt> then include <tt>&quot;ntp_select.h&quot;</tt>. <tt>select</tt> is not standard, since it is very system dependent as to where it is defined. The logic to include the right system dependent include file is in <tt>&quot;ntp_select.h&quot;</tt>.
+            <li>Always use POSIX definition of strings. Include <tt>&quot;ntp_string.h&quot;</tt> instead of <tt>&lt;string.h&gt;</tt>.
+            <li>Always include <tt>&quot;ntp_malloc.h&quot;</tt> if you use <tt>malloc</tt>.
+            <li>Always include <tt>&quot;ntp_io.h&quot;</tt> instead of <tt>&lt;sys/file.h&gt;</tt> or <tt>&lt;fnctl.h&gt;</tt> to get <tt>O_*</tt> flags.
+            <li>Always include <tt>&quot;ntp_if.h&quot;</tt> instead of <tt>&lt;net/if.h&gt;</tt>.
+            <li>Always include <tt>&quot;ntp_stdlib.h&quot;</tt> instead of <tt>&lt;stdlib.h&gt;</tt>.
+            <li>Define any special defines needed for a system in <tt>./include/ntp_machine.h</tt> based on system identifier. This file is included by the <tt>&quot;ntp_types.h&quot;</tt> file and should always be placed first after the <tt>&lt;&gt;</tt> defines.
+            <li>Define any special library prototypes left over from the system library and include files in the <tt>&quot;l_stdlib.h&quot;</tt> file. This file is included by the <tt>&quot;ntp_stdlib.h&quot;</tt> file and should ordinarily be placed last in the includes list.
+            <li>Don't define a include file by the same name as a system include file.
+        </ol>
+        <p><tt>&quot;l_stdlib.h&quot;</tt> can contain any extra definitions that are needed so that <tt>gcc</tt> will shut up. They should be controlled by a system identifier and there should be a separate section for each system. Really this will make it easier to maintain.</p>
+        <p>See <tt>include/ntp_machines.h</tt> for the various compile time options.</p>
+        <p>When you are satisfied the port works and that other ports are not adversely affected, please send <a href="patches.html">patches</a> for the system files you have changed, as well as any documentation that should be updated, including the advice herein.</p>
+        <p>Good luck.</p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/build/quick.html b/html/build/quick.html
new file mode 100644 (file)
index 0000000..1693b5d
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta name="generator" content="HTML Tidy, see www.w3.org">
+        <title>Quick Start</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Quick Start</h3>
+        <img src="../pic/panda.gif" alt="gif" align="left">FAX test image for SATNET (1979).
+        <p>The baby panda was scanned at University College London and used as a FAX test image for a demonstration of the DARPA Atlantic SATNET Program and the first transatlantic Internet connection in 1978. The computing system used for that demonstration was called the <a href="http://www.eecis.udel.edu/%7emills/database/papers/fuzz.pdf">Fuzzball</a> . As it happened, this was also the first Internet multimedia presentation and the first to use NTP in regular operation. The image was widely copied and used for testing purpose throughout much of the 1980s.</p>
+        <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="99">01:01 AM</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="266">Saturday, March 20, 2004</csobj></p>
+        <br clear="left">
+        <hr>
+        <p>For the rank amateur the sheer volume of the documentation collection must be intimidating. However, it doesn't take much to fly the <tt>ntpd</tt> daemon with a simple configuration where a workstation needs to synchronize to some server elsewhere in the Internet. The first thing that needs to be done is to build the distribution for the particular workstation and install in the usual place. The <a href="build.html">Building and Installing the Distribution</a> page describes how to do this.</p>
+        <p>While it is possible that certain configurations do not need a configuration file, most do require one. The file, called by default <tt>/etc/ntp.conf</tt>, need only contain one line specifying a remote server, for instance</p>
+        <p><tt>server foo.bar.com</tt></p>
+        <p>Choosing an appropriate remote server is somewhat of a black art, but a suboptimal choice is seldom a problem. There are about two dozen public time servers operated by National Institutes of Science and Technology (NIST), US Naval Observatory (USNO), Canadian Metrology Centre (CMC) and many others available on the Internet. Lists of public primary and secondary NTP servers maintained on the <a href="http://www.eecis.udel.edu/%7emills/ntp/servers.html">Public NTP TIme Servers</a> page, which is updated frequently.The lists are sorted by country and, in the case of the US, by state. Usually, the best choice is the nearest in geographical terms, but the terms of engagement specified in each list entry should be carefully respected.</p>
+        <p>During operation <tt>ntpd</tt> measures and corrects for incidental clock frequency error and writes the current value to a file called by default <tt>/etc/ntp.drift</tt>. If <tt>ntpd</tt> is stopped and restarted, it initializes the frequency from this file. In this way the potentially lengthy interval to relearn the frequency error is avoided.</p>
+        <p>That's all there is to it, unless some problem in network connectivity or local operating system configuration occurs. The most common problem is some firewall between the workstation and server. System administrators should understand NTP uses UDP port 123 as both the source and destination port and that NTP does not involve any operating system interaction other than to set the system clock. While almost all modern Unix systems have included NTP and UDP port 123 defined in the services file, this should be checked if <tt>ntpd</tt> fails to come up at all.</p>
+        <p>The best way to confirm NTP is working is using the <a href="../ntpq.html"><tt>ntpq</tt></a> utility, although the <a href="../ntpdc.html"><tt>ntpdc</tt></a> utility may be useful in extreme cases. See the documentation pages for further information. In the most extreme cases the <tt>-d</tt> option on the <tt>ntpd</tt> command line results in a blow-by-blow trace of the daemon operations. While the trace output can be cryptic, to say the least, it gives a general idea of what the program is doing and, in particular, details the arriving and departing packets and detected errors, if present.</p>
+        <p>Sometimes the <tt>ntpd</tt>. behavior may seem to violate the Principle of Least Astonishment, but there are good reasons for this. See the <a href="../ntpd.html">Network Time Protocol (NTP) daemon</a> page for revealing insights. See this page and its dependencies for additional configuration and control options. The <a href="../notes.html">Notes on Configuring NTP and Setting up a NTP Subnet</a> page contains an extended discussion of these options.</p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/build/scripts/footer.txt b/html/build/scripts/footer.txt
new file mode 100644 (file)
index 0000000..89216ce
--- /dev/null
@@ -0,0 +1,7 @@
+document.write("\
+<table><tr>\
+<td width='50%' ><img src='../icons/home.gif' align='middle' alt='gif'>\
+<a href='../index.html'>Home Page</a></td>\
+<td width='50%' ><img src='../icons/mail2.gif' align='middle' alt='gif'>\
+<a href='http://www.ntp.org/contact.html'>Contacts</a></i></td>\
+</tr></table>")
\ No newline at end of file
diff --git a/html/build/scripts/links10.txt b/html/build/scripts/links10.txt
new file mode 100644 (file)
index 0000000..7bf9d06
--- /dev/null
@@ -0,0 +1,5 @@
+document.write("<ul>\
+<li class='inline'><a href='refclock.html'>Reference Clock Drivers</a><br>\
+<li class='inline'><a href='prefer.html'>Mitigation Rules and the <tt>prefer</tt> Keyword</a><br>\
+<li class='inline'><a href='howto.html'>How to Write a Reference Clock Driver</a><br>\
+</ul>")
\ No newline at end of file
diff --git a/html/build/scripts/links11.txt b/html/build/scripts/links11.txt
new file mode 100644 (file)
index 0000000..1fce362
--- /dev/null
@@ -0,0 +1,5 @@
+document.write("<ul>\
+<li class='inline'><a href='refclock.html'>Reference Clock Drivers</a><br>\
+<li class='inline'><a href='pps.html'>Pulse-per-second (PPS) Signal Interfacing</a><br>\
+<li class='inline'><a href='ldisc.html'>Line Disciplines and Streams Modules</a><br>\
+</ul>")
\ No newline at end of file
diff --git a/html/build/scripts/links12.txt b/html/build/scripts/links12.txt
new file mode 100644 (file)
index 0000000..512cbcf
--- /dev/null
@@ -0,0 +1,5 @@
+document.write("<ul>\
+<li class='inline'><a href='debug.html'>NTP Debugging Techniques</a><br>\
+<li class='inline'><a href='rdebug.html'>Debugging Reference Clock Drivers</a><br>\
+<li class='inline'><a href='msyslog.html'><tt>ntpd</tt> System Log Messages</a><br>\
+</ul>")
\ No newline at end of file
diff --git a/html/build/scripts/links7.txt b/html/build/scripts/links7.txt
new file mode 100644 (file)
index 0000000..4a6f186
--- /dev/null
@@ -0,0 +1,5 @@
+document.write("<ul>\
+<li class='inline'><a href='../confopt.html'>Server Options</a><br>\
+<li class='inline'><a href='../authopt.html'>Authentication Options</a><br>\
+<li class='inline'><a href='../monopt.html'>Monitoring Options</a><br>\
+</ul>")
\ No newline at end of file
diff --git a/html/build/scripts/links8.txt b/html/build/scripts/links8.txt
new file mode 100644 (file)
index 0000000..af33dca
--- /dev/null
@@ -0,0 +1,6 @@
+document.write("<ul>\
+<li class='inline'><a href='refclock.html'>Reference Clock Drivers</a><br>\
+<li class='inline'><a href='drivers/driver7.html'>Radio CHU Audio Demodulator/Decoder</a><br>\
+<li class='inline'><a href='drivers/driver36.html'>Radio WWV/H Audio Demodulator/Decoder</a><br>\
+<li class='inline'><a href='drivers/driver6.html'>IRIG Audio Decoder</a>\
+</ul>")
\ No newline at end of file
diff --git a/html/build/scripts/links9.txt b/html/build/scripts/links9.txt
new file mode 100644 (file)
index 0000000..38ffe90
--- /dev/null
@@ -0,0 +1,7 @@
+document.write("<ul>\
+<li class='inline'><a href='authopt.html'>Authentication Options</a><br>\
+<li class='inline'><a href='manyopt.html'>Automatic NTP Configuration Options</a><br>\
+<li class='inline'><a href='confopt.html'>Server Options</a><br>\
+<li class='inline'><a href='keygen.html'><tt>ntp-keygen</tt> - generate public and private keys</a>\
+<li class='inline'><a href='http://www.eecis.udel.edu/~mills/autokey.html'>Autonomous Authentication</a>\
+</ul>")
\ No newline at end of file
diff --git a/html/build/scripts/style.css b/html/build/scripts/style.css
new file mode 100644 (file)
index 0000000..096b18a
--- /dev/null
@@ -0,0 +1,64 @@
+body {background: #FDF1E1;
+      color: #006600;
+      font-family: "verdana", sans-serif;
+      text-align: justify;
+      margin-left: 5px;}
+
+p, h4, hr, li {margin-top: .6em; margin-bottom: .6em}
+li.inline {text-align: left; margin-top: 0; margin-bottom: 0}
+
+ul, dl, ol, {margin-top: .6em; margin-bottom: .6em; margin-left 5em}
+
+dt {margin-top: .6em}
+dd {margin-bottom: .6em}
+
+div.header {text-align: center;
+            font-style: italic;}
+
+div.footer {text-align: center;         
+            font-size: 60%;}
+
+img.cell {align: left;}
+
+td.sidebar {width: 40px; align: center; valign: top;}
+img.sidebar {align: center; margin-top: 5px;}
+h4.sidebar {align: center;}
+
+p.top {background: #FDF1E1;
+       color: #006600;
+       position: absolute;
+       margin-left: -90px;
+       text-align: center;}
+
+a:link.sidebar {background: transparent;
+                color: #990033;
+                font-weight: bold;}
+
+a:visited.sidebar {background: transparent;
+                   color: #990033;
+                   font-weight: bold;}
+
+a:hover.sidebar {background: #FDF1E1;
+                 color: #006600;}
+
+img {margin: 5px;}
+
+div {text-align: center;}
+
+h1 {text-align: center;
+    font-size: 250%;}
+
+caption {background: #EEEEEE;
+         color: #339999;}
+         
+tx {text-align: center;}
+
+th {background: #FFFFCC;
+    color: #006600;
+    text-align: center;
+    text-decoration: underline;
+    padding-top: 5px;}
+
+th.caption {background: #EEEEEE;
+            color: #006600;
+            text-align: center;}
\ No newline at end of file
diff --git a/html/clockopt.html b/html/clockopt.html
new file mode 100644 (file)
index 0000000..c4690a3
--- /dev/null
@@ -0,0 +1,68 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Reference Clock Options</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Reference Clock Options</h3>
+               <img src="pic/stack1a.jpg" alt="gif" align="left">
+               <p>See the radios, all in a row.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:37</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#ref">Reference Clock Support</a>
+                       <li class="inline"><a href="#cmd">Reference Clock Commands</a>
+               </ul>
+               <hr>
+               <h4 id="ref">Reference Clock Support</h4>
+               <p>The NTP Version 4 daemon supports some three dozen different radio, satellite and modem reference clocks plus a special pseudo-clock used for backup or when no other clock source is available. Detailed descriptions of individual device drivers and options can be found in the <a href="refclock.html">Reference Clock Drivers</a> page. Additional information can be found in the pages linked there, including the <a href="rdebug.html">Debugging Hints for Reference Clock Drivers</a> and <a href="howto.html">How To Write a Reference Clock Driver</a> pages. In addition, support for a PPS signal is available as described in <a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page. Many drivers support special line discipline/streams modules which can significantly improve the accuracy using the driver. These are described in the <a href="ldisc.html">Line Disciplines and Streams Drivers</a> page.</p>
+               <p>A reference clock will generally (though not always) be a radio timecode receiver which is synchronized to a source of standard time such as the services offered by the NRC in Canada and NIST and USNO in the US. The interface between the computer and the timecode receiver is device dependent, but is usually a serial port. A device driver specific to each reference clock must be selected and compiled in the distribution; however, most common radio, satellite and modem clocks are included by default. Note that an attempt to configure a reference clock when the driver has not been compiled or the hardware port has not been appropriately configured results in a scalding remark to the system log file, but is otherwise non hazardous.</p>
+               <p>For the purposes of configuration, <tt>ntpd</tt> treats reference clocks in a manner analogous to normal NTP peers as much as possible. Reference clocks are identified by a syntactically correct but invalid IP address, in order to distinguish them from normal NTP peers. Reference clock addresses are of the form <tt>127.127.<i>t.u</i></tt>, where <i><tt>t</tt></i> is an integer denoting the clock type and <i><tt>u</tt></i> indicates the unit number in the range 0-3. While it may seem overkill, it is in fact sometimes useful to configure multiple reference clocks of the same type, in which case the unit numbers must be unique.</p>
+               <p>The <tt>server</tt> command is used to configure a reference clock, where the <i><tt>address</tt></i> argument in that command is the clock address. The <tt>key</tt>, <tt>version</tt> and <tt>ttl</tt> options are not used for reference clock support. The <tt>mode</tt> option is added for reference clock support, as described below. The <tt>prefer</tt> option can be useful to persuade the server to cherish a reference clock with somewhat more enthusiasm than other reference clocks or peers. Further information on this option can be found in the <a href="prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a> page. The <tt>minpoll</tt> and <tt>maxpoll</tt> options have meaning only for selected clock drivers. See the individual clock driver document pages for additional information.</p>
+               <p>The <tt>fudge</tt> command is used to provide additional information for individual clock drivers and normally follows immediately after the <tt>server</tt> command. The <i><tt>address</tt></i> argument specifies the clock address. The <tt>refid</tt> and <tt>stratum</tt> options control can be used to override the defaults for the device. There are two optional device-dependent time offsets and four flags that can be included in the <tt>fudge</tt> command as well.</p>
+               <p>The stratum number of a reference clock is by default zero. Since the <tt>ntpd</tt> daemon adds one to the stratum of each peer, a primary server ordinarily displays an external stratum of one. In order to provide engineered backups, it is often useful to specify the reference clock stratum as greater than zero. The <tt>stratum</tt> option is used for this purpose. Also, in cases involving both a reference clock and a pulse-per-second (PPS) discipline signal, it is useful to specify the reference clock identifier as other than the default, depending on the driver. The <tt>refid</tt> option is used for this purpose. Except where noted, these options apply to all clock drivers.</p>
+               <h4 id="cmd">Reference Clock Commands</h4>
+               <dl>
+                       <dt><tt>server 127.127.<i>t.u</i> [prefer] [mode <i>int</i>] [minpoll <i>int</i>] [maxpoll <i>int</i>]</tt>
+                       <dd>This command can be used to configure reference clocks in special ways. The options are interpreted as follows:
+                               <dl>
+                                       <dt><tt>prefer</tt>
+                                       <dd>Marks the reference clock as preferred. All other things being equal, this host will be chosen for synchronization among a set of correctly operating hosts. See the <a href="prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a> page for further information.
+                                       <dt><tt>mode <i>int</i></tt>
+                                       <dd>Specifies a mode number which is interpreted in a device-specific fashion. For instance, it selects a dialing protocol in the ACTS driver and a device subtype in the <tt>parse</tt> drivers.
+                                       <dt><tt>minpoll <i>int</i></tt>
+                                       <dt><tt>maxpoll <i>int</i></tt>
+                                       <dd>These options specify the minimum and maximum polling interval for reference clock messages in seconds, interpreted as dual logarithms (2 ^ x). For most directly connected reference clocks, both <tt>minpoll</tt> and <tt>maxpoll</tt> default to 6 (2^16 = 64 s). For modem reference clocks, <tt>minpoll</tt> defaults to 10 (2^10 = 1024 s = 17.1 m) and <tt>maxpoll</tt> defaults to 14 (2^14 = 16384 s = 4.5 h). The allowable range is 4 (16 s) to 17 (36.4 h) inclusive.
+                               </dl>
+                       <dt><tt>fudge 127.127.<i>t.u</i> [time1 <i>sec</i>] [time2 <i>sec</i>] [stratum <i>int</i>] [refid <i>string</i>] [mode <i>int</i>] [flag1 0|1] [flag2 0|1] [flag3 0|1] [flag4 0|1]</tt>
+                       <dd>This command can be used to configure reference clocks in special ways. It must immediately follow the <tt>server</tt> command which configures the driver. Note that the same capability is possible at run time using the <tt><a href="ntpdc.html">ntpdc</a></tt> program. The options are interpreted as follows:
+                               <dl>
+                                       <dt><tt>time1 <i>sec</i></tt>
+                                       <dd>Specifies a constant to be added to the time offset produced by the driver, a fixed-point decimal number in seconds. This is used as a calibration constant to adjust the nominal time offset of a particular clock to agree with an external standard, such as a precision PPS signal. It also provides a way to correct a systematic error or bias due to serial port or operating system latencies, different cable lengths or receiver internal delay. The specified offset is in addition to the propagation delay provided by other means, such as internal DIPswitches. Where a calibration for an individual system and driver is available, an approximate correction is noted in the driver documentation pages.
+                                       <dd>Note: in order to facilitate calibration when more than one radio clock or PPS signal is supported, a special calibration feature is available. It takes the form of an argument to the <tt>enable</tt> command described in the <a href="miscopt.html">Miscellaneous Options</a> page and operates as described in the <a href="refclock.html">Reference Clock Drivers</a> page.
+                                       <dt><tt>time2 <i>secs</i></tt>
+                                       <dd>Specifies a fixed-point decimal number in seconds, which is interpreted in a driver-dependent way. See the descriptions of specific drivers in the <a href="refclock.html">reference clock drivers</a> page.
+                                       <dt><tt>stratum <i>int</i></tt>
+                                       <dd>Specifies the stratum number assigned to the driver, an integer between 0 and 15. This number overrides the default stratum number ordinarily assigned by the driver itself, usually zero.
+                                       <dt><tt>refid <i>string</i></tt>
+                                       <dd>Specifies an ASCII string of from one to four characters which defines the reference identifier used by the driver. This string overrides the default identifier ordinarily assigned by the driver itself.
+                                       <dt><tt>mode <i>int</i></tt>
+                                       <dd>Specifies a mode number which is interpreted in a device-specific fashion. For instance, it selects a dialing protocol in the ACTS driver and a device subtype in the <tt>parse</tt> drivers.
+                                       <dt><tt>flag1 flag2 flag3 flag4</tt>
+                                       <dd>These four flags are used for customizing the clock driver. The interpretation of these values, and whether they are used at all, is a function of the particular clock driver. However, by convention <tt>flag4</tt> is used to enable recording monitoring data to the <tt>clockstats</tt> file configured with the <tt>filegen</tt> command. Further information on the <tt>filegen</tt> command can be found in the <a href="monopt.html">Monitoring Options</a> page.
+                               </dl>
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/confopt.html b/html/confopt.html
new file mode 100644 (file)
index 0000000..e2a04c4
--- /dev/null
@@ -0,0 +1,82 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Server Options</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Server Options</h3>
+               <img src="pic/boom3a.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+               <p>The chicken is getting configuration advice.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">20:57</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="270">Monday, October 10, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#cfg">Configuration Commands</a>
+                       <li class="inline"><a href="#opt">Command Options</a>
+                       <li class="inline"><a href="#aux">Auxilliary Commands</a>
+                       <li class="inline"><a href="#bug">Bugs</a>
+               </ul>
+               <hr>
+               <p>Following is a description of the configuration commands in NTPv4. There are two classes of commands, configuration commands that configure an association with a remote server, peer or reference clock, and auxilliary commands that specify environmental variables that control various related operations.</p>
+               <h4 id="cfg">Configuration Commands</h4>
+               <p>The various modes are determined by the command keyword and the required IP address. Addresses are classed by type as (s) a remote server or peer (IPv4 class A, B and C), (b) the broadcast address of a local interface, (m) a multicast address (IPv4 class D), or (r) a reference clock address (127.127.x.x). The options that can be used with these commands are listed below.</p>
+               <p>If the Basic Socket Interface Extensions for IPv6 (RFC-2553) is detected, support for the IPv6 address family is generated in addition to the default support of the IPv4 address family. IPv6 addresses can be identified by the presence of colons &quot;:&quot; in the address field. IPv6 addresses can be used almost everywhere where IPv4 addresses can be used, with the exception of reference clock addresses, which are always IPv4. Note that in contexts where a host name is expected, a <tt>-4</tt> qualifier preceding the host name forces DNS resolution to the IPv4 namespace, while a <tt>-6</tt> qualifier forces DNS resolution to the IPv6 namespace.</p>
+               <p>There are three types of associations: persistent, preemptable and ephemeral. Persistent associations are mobilized by a configuration command and never demobilized. Preemptable associations, which are new to NTPv4, are mobilized by a configuration command which includes the <tt>prempt</tt> flag and are demobilized by timeout or error. Ephemeral associations are mobilized upon arrival of designated messages and demobilized by timeout or error.</p>
+               <dl>
+                       <dt><tt>server <i>address</i> [options ...]</tt><br>
+                               <tt>peer <i>address</i> [</tt><tt>options ...]<br>
+                                       broadcast <i>address</i> [options ...]</tt><br>
+                               <tt>manycastclient <i>address</i> [options ...]</tt>
+                       <dd>These four commands specify the time server name or address to be used and the mode in which to operate. The <i>address</i> can be either a DNS name or a IP address in dotted-quad notation. Additional information on association behavior can be found in the <a href="assoc.html">Association Management</a> page.
+                               <dl>
+                                       <dt><tt>server</tt>
+                                       <dd>For type s and r addresses (only), this command normally mobilizes a persistent client mode association with the specified remote server or local reference clock. If the <tt>preempt</tt> flag is specified, a preemptable association is mobilized instead. In client mode the client clock can synchronize to the remote server or local reference clock, but the remote server can never be synchronized to the client clock. This command should NOT be used for type <tt>b</tt> or <tt>m</tt> addresses. <dt><tt>peer</tt>
+                                       <dd>For type s addresses (only), this command mobilizes a persistent symmetric-active mode association with the specified remote peer. In this mode the local clock can be synchronized to the remote peer or the remote peer can be synchronized to the local clock. This is useful in a network of servers where, depending on various failure scenarios, either the local or remote peer may be the better source of time. This command should NOT be used for type <tt>b</tt>, <tt>m</tt> or <tt>r</tt> addresses.
+                                       <dt><tt>broadcast</tt>
+                                       <dd>For type <tt>b</tt> and <tt>m</tt> addresses (only), this command mobilizes a persistent broadcast mode association. Multiple commands can be used to specify multiple local broadcast interfaces (subnets) and/or multiple multicast groups. Note that local broadcast messages go only to the interface associated with the subnet specified, but multicast messages go to all interfaces.
+                                       <dd>In broadcast mode the local server sends periodic broadcast messages to a client population at the <i><tt>address</tt></i> specified, which is usually the broadcast address on (one of) the local network(s) or a multicast address assigned to NTP. The IANA has assigned the multicast group address IPv4 224.0.1.1 and IPv6 ff05::101 (site local) exclusively to NTP, but other nonconflicting addresses can be used to contain the messages within administrative boundaries. Ordinarily, this specification applies only to the local server operating as a sender; for operation as a broadcast client, see the <tt>broadcastclient</tt> or <tt>multicastclient</tt> commands below.
+                                       <dt><tt>manycastclient</tt>
+                                       <dd>For type <tt>m</tt> addresses (only), this command mobilizes a preemptable manycast client mode association for the multicast group address specified. In this mode a specific address must be supplied which matches the address used on the <tt>manycastserver</tt> command for the designated manycast servers. The NTP multicast address 224.0.1.1 assigned by the IANA should NOT be used, unless specific means are taken to avoid spraying large areas of the Internet with these messages and causing a possibly massive implosion of replies at the sender.
+                                       <dd>The <tt>manycastclient</tt> command specifies that the host is to operate in client mode with the remote servers that are discovered as the result of broadcast/multicast messages. The client broadcasts a request message to the group address associated with the specified <i><tt>address</tt></i> and specifically enabled servers respond to these messages. The client selects the servers providing the best time and continues as with the <tt>server </tt>command. The remaining servers are discarded as if never heard.
+                               </dl>
+               </dl>
+               <h4 id="opt">Command Options</h4>
+               <dl>
+                       <dt><tt>autokey</tt>
+                       <dd>All packets sent to and received from the server or peer are to include authentication fields encrypted using the autokey scheme described in the <a href="authopt.html">Authentication Options</a> page. This option is valid with all commands.<dt><tt>burst</tt>
+                       <dd>When the server is reachable, send a burst of eight packets instead of the usual one. The packet spacing is normally 2 s; however, the spacing between the first and second packets can be changed with the <a href="miscopt.html"><tt>calldelay</tt></a> command to allow additional time for a modem or ISDN call to complete. This option is valid with only the <tt>server</tt> command and is a recommended option with this command when the <tt>maxpoll</tt> option is 11 or greater. <dt><tt>iburst</tt>
+                       <dd>When the server is unreachable, send a burst of eight packets instead of the usual one. The packet spacing is normally 2 s; however, the spacing between the first and second packets can be changed with the <a href="miscopt.html"><tt>calldelay</tt></a> command to allow additional time for a modem or ISDN call to complete. This option is valid with only the <tt>server</tt> command and is a recommended option with this command.<dt><tt>key</tt> <i><tt>key</tt></i>
+                       <dd>All packets sent to and received from the server or peer are to include authentication fields encrypted using the specified <i><tt>key</tt></i> identifier with values from 1 to 65534, inclusive. The default is to include no encryption field. This option is valid with all commands.<dt><tt>minpoll <i>minpoll</i></tt><br>
+                               <tt>maxpoll <i>maxpoll</i></tt>
+                       <dd>These options specify the minimum and maximum poll intervals for NTP messages, in seconds as a power of two. The maximum poll interval defaults to 10 (1,024 s), but can be increased by the <tt>maxpoll</tt> option to an upper limit of 17 (36.4 h). The minimum poll interval defaults to 6 (64 s), but can be decreased by the <tt>minpoll</tt> option to a lower limit of 4 (16 s). These option are valid only with the <tt>server</tt> and <tt>peer</tt> commands.<dt><tt>noselect</tt>
+                       <dd>Marks the server as unused, except for display purposes. The server is discarded by the selection algorithm. This option is valid only with the <tt>server</tt> and <tt>peer</tt> commands.<dt><tt>preempt</tt>
+                       <dd>Specifies the association as preemptable rather than the default persistent. This option is valied only with the <tt>server</tt> command.<dt><tt>prefer</tt>
+                       <dd>Marks the server as preferred. All other things being equal, this host will be chosen for synchronization among a set of correctly operating hosts. See the <a href="prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a> page for further information. This option is valid only with the <tt>server</tt> and <tt>peer</tt> commands.<dt><tt>true</tt>
+                       <dd>Force the association to assume truechimer status; that is, always survive the selection and clustering algorithms. This option can be used with any association, but is most useful for reference clocks with large jitter on the serial port and precision pulse-per-second (PPS) signals. Caution: this option defeats the algorithms designed to cast out falsetickers and can allow these sources to set the system clock. This option is valid only with the <tt>server</tt> and <tt>peer</tt> commands.<dt><tt>ttl <i>ttl</i></tt>
+                       <dd>This option is used only with broadcast server and manycast client modes. It specifies the time-to-live <i><tt>ttl</tt></i> to use on broadcast server and multicast server and the maximum <i><tt>ttl</tt></i> for the expanding ring search with manycast client packets. Selection of the proper value, which defaults to 127, is something of a black art and should be coordinated with the network administrator.
+                       <dt><tt>version <i>version</i></tt>
+                       <dd>Specifies the version number to be used for outgoing NTP packets. Versions 1-4 are the choices, with version 4 the default. This option is valid only with the <tt>server,</tt> <tt>peer</tt> and <tt>broadcast</tt> commands.
+               </dl>
+               <h4 id="aux">Auxilliary Commands</h4>
+               <dl>
+                       <dt><tt>broadcastclient [novolley]</tt>
+                       <dd>This command enables reception of broadcast server messages to any local interface (type <tt>b</tt>) address. Ordinarily, upon receiving a message for the first time, the broadcast client measures the nominal server propagation delay using a brief client/server exchange with the server, after which it continues in listen-only mode. If the <tt>novolley</tt> keyword is present, the exchange is not used and the value specified in the <tt>broadcastdelay</tt> command is used or, if the <tt>broadcastdelay</tt> command is not used, the default 4.0 ms. Note that, in order to avoid accidental or malicious disruption in this mode, both the server and client should operate using symmetric key or public key authentication as described in the <a href="authopt.html">Authentication Options</a> page. Note that the <tt>novolley</tt> keyword is incompatible with public key authentication.<dt><tt>manycastserver <i>address</i> [...]</tt>
+                       <dd>This command enables reception of manycast client messages to the multicast group address(es) (type <tt>m</tt>) specified. At least one address is required. The NTP multicast address 224.0.1.1 assigned by the IANA should NOT be used, unless specific means are taken to limit the span of the reply and avoid a possibly massive implosion at the original sender. Note that, in order to avoid accidental or malicious disruption in this mode, both the server and client should operate using symmetric key or public key authentication as described in the <a href="authopt.html">Authentication Options</a> page.
+                       <dt><tt>multicastclient <i>address</i> [...]</tt>
+                       <dd>This command enables reception of multicast server messages to the multicast group address(es) (type <tt>m</tt>) specified. Upon receiving a message for the first time, the multicast client measures the nominal server propagation delay using a brief client/server exchange with the server, then enters the broadcast client mode, in which it synchronizes to succeeding multicast messages. Note that, in order to avoid accidental or malicious disruption in this mode, both the server and client should operate using symmetric key or public key authentication as described in the <a href="authopt.html">Authentication Options</a> page.
+               </dl>
+               <h4 id="bug">Bugs</h4>
+               <p>The syntax checking is not picky; some combinations of ridiculous and even hilarious options and modes may not be detected.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/copyright.html b/html/copyright.html
new file mode 100644 (file)
index 0000000..cf34979
--- /dev/null
@@ -0,0 +1,96 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Copyright Notice</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Copyright Notice</h3>
+               <img src="pic/sheepb.jpg" alt="jpg" align="left"> &quot;Clone me,&quot; says Dolly sheepishly
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">20:31</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="285">Saturday, January 06, 2007</csobj></p>
+               <br clear="left">
+               <hr>
+               <p>The following copyright notice applies to all files collectively called the Network Time Protocol Version 4 Distribution. Unless specifically declared otherwise in an individual file, this notice applies as if the text was explicitly included in the file.<br>
+               </p>
+               <pre>
+***********************************************************************
+*                                                                     *
+* Copyright (c) David L. Mills 1992-2009                              *
+*                                                                     *
+* Permission to use, copy, modify, and distribute this software and   *
+* its documentation for any purpose with or without fee is hereby     *
+* granted, provided that the above copyright notice appears in all    *
+* copies and that both the copyright notice and this permission       *
+* notice appear in supporting documentation, and that the name        *
+* University of Delaware not be used in advertising or publicity      *
+* pertaining to distribution of the software without specific,        *
+* written prior permission. The University of Delaware makes no       *
+* representations about the suitability this software for any         *
+* purpose. It is provided &quot;as is&quot; without express or implied          *
+* warranty.                                                           *
+*                                                                     *
+***********************************************************************
+</pre>
+               <p>The following individuals contributed in part to the Network Time Protocol Distribution Version 4 and are acknowledged as authors of this work.</p>
+               <ol>
+                       <li class="inline"><a href="mailto:%20mark_andrews@isc.org">Mark Andrews &lt;mark_andrews@isc.org&gt;</a> Leitch atomic clock controller
+                       <li class="inline"><a href="mailto:%20altmeier@atlsoft.de">Bernd Altmeier &lt;altmeier@atlsoft.de&gt;</a> hopf Elektronik serial line and PCI-bus devices
+                       <li class="inline"><a href="mailto:%20vbais@mailman1.intel.co">Viraj Bais &lt;vbais@mailman1.intel.com&gt;</a> and <a href="mailto:%20kirkwood@striderfm.intel.com">Clayton Kirkwood &lt;kirkwood@striderfm.intel.com&gt;</a> port to WindowsNT 3.5
+                       <li class="inline"><a href="mailto:%20michael.barone@lmco.com">Michael Barone &lt;michael,barone@lmco.com&gt;</a> GPSVME fixes
+                       <li class="inline"><a href="mailto:%20Jean-Francois.Boudreault@viagenie.qc.ca">Jean-Francois Boudreault &lt;Jean-Francois.Boudreault@viagenie.qc.ca&gt;</a>IPv6 support
+                       <li class="inline"><a href="mailto:%20karl@owl.HQ.ileaf.com">Karl Berry &lt;karl@owl.HQ.ileaf.com&gt;</a> syslog to file option
+                       <li class="inline"><a href="mailto:%20greg.brackley@bigfoot.com">Greg Brackley &lt;greg.brackley@bigfoot.com&gt;</a> Major rework of WINNT port. Clean up recvbuf and iosignal code into separate modules.
+                       <li class="inline"><a href="mailto:%20Marc.Brett@westgeo.com">Marc Brett &lt;Marc.Brett@westgeo.com&gt;</a> Magnavox GPS clock driver
+                       <li class="inline"><a href="mailto:%20Piete.Brooks@cl.cam.ac.uk">Piete Brooks &lt;Piete.Brooks@cl.cam.ac.uk&gt;</a> MSF clock driver, Trimble PARSE support
+                       <li class="inline"><a href="mailto:%20reg@dwf.com">Reg Clemens &lt;reg@dwf.com&gt;</a> Oncore driver (Current maintainer)
+                       <li class="inline"><a href="mailto:%20clift@ml.csiro.au">Steve Clift &lt;clift@ml.csiro.au&gt;</a> OMEGA clock driver
+                       <li class="inline"><a href="mailto:casey@csc.co.za">Casey Crellin &lt;casey@csc.co.za&gt;</a> vxWorks (Tornado) port and help with target configuration
+                       <li class="inline"><a href="mailto:%20Sven_Dietrich@trimble.COM">Sven Dietrich &lt;sven_dietrich@trimble.com&gt;</a> Palisade reference clock driver, NT adj. residuals, integrated Greg's Winnt port.
+                       <li class="inline"><a href="mailto:%20dundas@salt.jpl.nasa.gov">John A. Dundas III &lt;dundas@salt.jpl.nasa.gov&gt;</a> Apple A/UX port
+                       <li class="inline"><a href="mailto:%20duwe@immd4.informatik.uni-erlangen.de">Torsten Duwe &lt;duwe@immd4.informatik.uni-erlangen.de&gt;</a> Linux port
+                       <li class="inline"><a href="mailto:%20dennis@mrbill.canet.ca">Dennis Ferguson &lt;dennis@mrbill.canet.ca&gt;</a> foundation code for NTP Version 2 as specified in RFC-1119
+                       <li class="inline"><a href="mailto:%20jhay@icomtek.csir.co.za">John Hay &lt;jhay@@icomtek.csir.co.za&gt;</a> IPv6 support and testing
+                       <li class="inline"><a href="mailto:%20glenn@herald.usask.ca">Glenn Hollinger &lt;glenn@herald.usask.ca&gt;</a> GOES clock driver
+                       <li class="inline"><a href="mailto:%20iglesias@uci.edu">Mike Iglesias &lt;iglesias@uci.edu&gt;</a> DEC Alpha port
+                       <li class="inline"><a href="mailto:%20jagubox.gsfc.nasa.gov">Jim Jagielski &lt;jim@jagubox.gsfc.nasa.gov&gt;</a> A/UX port
+                       <li class="inline"><a href="mailto:%20jbj@chatham.usdesign.com">Jeff Johnson &lt;jbj@chatham.usdesign.com&gt;</a> massive prototyping overhaul
+                       <li class="inline"><a href="mailto:Hans.Lambermont@nl.origin-it.com">Hans Lambermont &lt;Hans.Lambermont@nl.origin-it.com&gt;</a> or <a href="mailto:H.Lambermont@chello.nl">&lt;H.Lambermont@chello.nl&gt;</a> ntpsweep
+                       <li class="inline"><a href="mailto:%20phk@FreeBSD.ORG">Poul-Henning Kamp &lt;phk@FreeBSD.ORG&gt;</a> Oncore driver (Original author)
+                       <li class="inline"><a href="http://www4.informatik.uni-erlangen.de/%7ekardel">Frank Kardel</a> <a href="mailto:%20kardel (at) ntp (dot) org">&lt;kardel (at) ntp (dot) org&gt;</a> PARSE &lt;GENERIC&gt; driver (>14 reference clocks), STREAMS modules for PARSE, support scripts, syslog cleanup, dynamic interface handling
+                       <li class="inline"><a href="mailto:%20jones@hermes.chpc.utexas.edu">William L. Jones &lt;jones@hermes.chpc.utexas.edu&gt;</a> RS/6000 AIX modifications, HPUX modifications
+                       <li class="inline"><a href="mailto:%20dkatz@cisco.com">Dave Katz &lt;dkatz@cisco.com&gt;</a> RS/6000 AIX port
+                       <li class="inline"><a href="mailto:%20leres@ee.lbl.gov">Craig Leres &lt;leres@ee.lbl.gov&gt;</a> 4.4BSD port, ppsclock, Magnavox GPS clock driver
+                       <li class="inline"><a href="mailto:%20lindholm@ucs.ubc.ca">George Lindholm &lt;lindholm@ucs.ubc.ca&gt;</a> SunOS 5.1 port
+                       <li class="inline"><a href="mailto:%20louie@ni.umd.edu">Louis A. Mamakos &lt;louie@ni.umd.edu&gt;</a> MD5-based authentication
+                       <li class="inline"><a href="mailto:%20thorinn@diku.dk">Lars H. Mathiesen &lt;thorinn@diku.dk&gt;</a> adaptation of foundation code for Version 3 as specified in RFC-1305
+                       <li class="inline"><a href="mailto:%20mayer@ntp.org">Danny Mayer &lt;mayer@ntp.org&gt;</a>Network I/O, Windows Port, Code Maintenance
+                       <li class="inline"><a href="mailto:%20mills@udel.edu">David L. Mills &lt;mills@udel.edu&gt;</a> Version 4 foundation: clock discipline, authentication, precision kernel; clock drivers: Spectracom, Austron, Arbiter, Heath, ATOM, ACTS, KSI/Odetics; audio clock drivers: CHU, WWV/H, IRIG
+                       <li class="inline"><a href="mailto:%20moeller@gwdgv1.dnet.gwdg.de">Wolfgang Moeller &lt;moeller@gwdgv1.dnet.gwdg.de&gt;</a> VMS port
+                       <li class="inline"><a href="mailto:%20mogul@pa.dec.com">Jeffrey Mogul &lt;mogul@pa.dec.com&gt;</a> ntptrace utility
+                       <li class="inline"><a href="mailto:%20tmoore@fievel.daytonoh.ncr.com">Tom Moore &lt;tmoore@fievel.daytonoh.ncr.com&gt;</a> i386 svr4 port
+                       <li class="inline"><a href="mailto:%20kamal@whence.com">Kamal A Mostafa &lt;kamal@whence.com&gt;</a> SCO OpenServer port
+                       <li class="inline"><a href="mailto:%20derek@toybox.demon.co.uk">Derek Mulcahy &lt;derek@toybox.demon.co.uk&gt;</a> and <a href="mailto:%20d@hd.org">Damon Hart-Davis &lt;d@hd.org&gt;</a> ARCRON MSF clock driver
+                       <li class="inline"><a href="mailto:%20Rainer.Pruy@informatik.uni-erlangen.de">Rainer Pruy &lt;Rainer.Pruy@informatik.uni-erlangen.de&gt;</a> monitoring/trap scripts, statistics file handling
+                       <li class="inline"><a href="mailto:%20dirce@zk3.dec.com">Dirce Richards &lt;dirce@zk3.dec.com&gt;</a> Digital UNIX V4.0 port
+                       <li class="inline"><a href="mailto:%20wsanchez@apple.com">Wilfredo S&aacute;nchez &lt;wsanchez@apple.com&gt;</a> added support for NetInfo
+                       <li class="inline"><a href="mailto:%20mrapple@quack.kfu.com">Nick Sayer &lt;mrapple@quack.kfu.com&gt;</a> SunOS streams modules
+                       <li class="inline"><a href="mailto:%20jack@innovativeinternet.com">Jack Sasportas &lt;jack@innovativeinternet.com&gt;</a> Saved a Lot of space on the stuff in the html/pic/ subdirectory
+                       <li class="inline"><a href="mailto:%20schnitz@unipress.com">Ray Schnitzler &lt;schnitz@unipress.com&gt;</a> Unixware1 port
+                       <li class="inline"><a href="mailto:%20shields@tembel.org">Michael Shields &lt;shields@tembel.org&gt;</a> USNO clock driver
+                       <li class="inline"><a href="mailto:%20pebbles.jpl.nasa.gov">Jeff Steinman &lt;jss@pebbles.jpl.nasa.gov&gt;</a> Datum PTS clock driver
+                       <li class="inline"><a href="mailto:%20harlan@pfcs.com">Harlan Stenn &lt;harlan@pfcs.com&gt;</a> GNU automake/autoconfigure makeover, various other bits (see the ChangeLog)
+                       <li class="inline"><a href="mailto:%20ken@sdd.hp.com">Kenneth Stone &lt;ken@sdd.hp.com&gt;</a> HP-UX port
+                       <li class="inline"><a href="mailto:%20ajit@ee.udel.edu">Ajit Thyagarajan &lt;ajit@ee.udel.edu&gt;</a>IP multicast/anycast support
+                       <li class="inline"><a href="mailto:%20tsuruoka@nc.fukuoka-u.ac.jp">Tomoaki TSURUOKA &lt;tsuruoka@nc.fukuoka-u.ac.jp&gt;</a>TRAK clock driver
+                       <li class="inline"><a href="mailto:%20vixie@vix.com">Paul A Vixie &lt;vixie@vix.com&gt;</a> TrueTime GPS driver, generic TrueTime clock driver
+                       <li class="inline"><a href="mailto:%20Ulrich.Windl@rz.uni-regensburg.de">Ulrich Windl &lt;Ulrich.Windl@rz.uni-regensburg.de&gt;</a> corrected and validated HTML documents according to the HTML DTD
+               </ol>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/debug.html b/html/debug.html
new file mode 100644 (file)
index 0000000..c732c42
--- /dev/null
@@ -0,0 +1,172 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>NTP Debugging Techniques</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>NTP Debugging Techniques</h3>
+               <img src="pic/pogo.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+               <p>We make house calls and bring our own bugs.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:38</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>More Help</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links12.txt"></script>
+               <hr>
+               <p>Once the NTP software distribution has been compiled and installed and the configuration file constructed, the next step is to verify correct operation and fix any bugs that may result. Usually, the command line that starts the daemon is included in the system startup file, so it is executed only at system boot time; however, the daemon can be stopped and restarted from root at any time. Usually, no command-line arguments are required, unless special actions described in the <a href="ntpd.html"><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</a> page are required. Once started, the daemon will begin sending and receiving messages, as specified in the configuration file.</p>
+               <h4>Initial Startup</h4>
+               <p>When started for the first time, the frequency file, usually called <tt>ntp.drift</tt>, has not yet been created. The daemon switches to a special training routine designed to quickly determine the system clock frequency offset of the particular machine. The routine first measures the current clock offset and sets the clock, then continues for up to twenty minutes before measuring the clock offset, which might involve setting the clock again. The two measurements are used to compute the initial frequency offset and the daemon continues in regular operation, during which the frequency offset is continuously updated. Once each hour the daemon writes the current frequency offset to the <tt>ntp.drift</tt> file. When restarted after that, the daemon reads the frequency offset from the <tt>ntp.drift</tt> file and avoids the training routine.</p>
+               <p>Note that the daemon requires at least four packet exchanges when first started in any case. This is required in order for the mitigation algorithms to insure valid and accurate measurements and defend against network delay spikes and accidental or malicious errors induced by the servers selected in the configuration file. It normally takes less than four minutes to set the clock when first started, but this can be reduced to less than ten seconds with the <tt>iburst</tt> configuration option.</p>
+               <p>The best way to verify correct operation is using the <a href="ntpq.html"><tt>ntpq</tt> - standard NTP query program</a> and <a href="ntpdc.html"><tt>ntpdc</tt> - special NTP query program</a> utility programs, either on the server itself or from another machine elsewhere in the network. The <tt>ntpq</tt> program implements the management functions specified in the NTP specification <a href="http://www.eecis.udel.edu/%7emills/database/rfc/rfc1305/rfc1305c.ps">RFC-1305, Appendix A</a>. The <tt>ntpdc</tt> program implements additional functions not provided in the standard. Both programs can be used to inspect the state variables defined in the specification and, in the case of <tt>ntpdc</tt>, additional ones intended for serious debugging. In addition, the <tt>ntpdc</tt> program can be used to selectively reconfigure and enable or disable some functions while the daemon is running.</p>
+               <p>In extreme cases with elusive bugs, the daemon can operate in two modes, depending on the presence of the <tt>-d</tt> command-line debug switch. If not present, the daemon detaches from the controlling terminal and proceeds autonomously. If one or more <tt>-d</tt> switches are present, the daemon does not detach and generates special output useful for debugging. In general, interpretation of this output requires reference to the sources. However, a single <tt>-d</tt> does produce only mildly cryptic output and can be very useful in finding problems with configuration and network troubles. With a little experience, the volume of output can be reduced by piping the output to <tt>grep</tt> and specifying the keyword of the trace you want to see.</p>
+               <p>Some problems are immediately apparent when the daemon first starts running. The most common of these are the lack of a UDP port for NTP (123) in the Unix <tt>/etc/services</tt> file (or equivalent in some systems). <b>Note that NTP does not use TCP in any form. Also note that NTP&nbsp;requires 123 for both source and destination ports.</b> These facts should be pointed out to firewall administrators.</p>
+               <p>Other problems are apparent in the system log, which ordinarily shows the startup banner, some cryptic initialization data and the computed precision value. Error messages at startup and during regular operation are sent to the system log. In real emergencies the daemon will sent a terminal error message to the system log and then cease operation.</p>
+               <p>The next most common problem is incorrect DNS names. Check that each DNS name used in the configuration file exists and that the address responds to the Unix <tt>ping</tt> command. The Unix <tt>traceroute</tt> or Windows <tt>tracert</tt> utility can be used to verify a partial or complete path exists. Most problems reported to the NTP&nbsp;newsgroup are not NTP&nbsp;problems, but problems with the network or firewall configuration.</p>
+               <p>When first started, the daemon polls the servers listed in the configuration file at 64-s intervals. In order to allow a sufficient number of samples for the NTP algorithms to reliably discriminate between truechimer servers and possible falsetickers, at least four valid messages from at least one server or peer listed in the configuration file is required before the daemon can set the clock. However, if the difference between the client time and server time is greater than the panic threshold, which defaults to 1000 s, the daemon sends a message to the system log and shuts down without setting the clock. It is necessary to set the local clock to within the panic threshold first, either manually by eyeball and wristwatch and the Unix <tt>date</tt> command, or by the <tt>ntpdate</tt> or <tt>ntpd -q</tt> commands. The panic threshold can be changed by the <tt>tinker panic</tt> command discribed on the <a href="miscopt.html">Miscellaneous Options</a> page. The panic threshold can be disabled for the first measurement by the <tt>-g</tt> command line option described on the <a href="ntpd.html"><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</a> page.</p>
+               <p>If the difference between local time and server time is less than the panic threshold but greater than the step threshold, which defaults to 128 ms, the daemon will perform a step adjustment; otherwise, it will gradually slew the clock to the nominal time. Step adjustments are extremely rare in ordinary operation, usually as the result of reboot or hardware failure. The step threshold can be changed to 300 s using the <tt>-x</tt> command line option described on the <tt>ntpd</tt> page. This is usually sufficient to avoid a step after reboot or when the operator has set the system clock to within five minutes by eyeball-and-wristwatch. In extreme cases the step threshold can be changed by the <tt>tinker step</tt> command discribed on the <a href="miscopt.html">Miscellaneous Options</a> page. If set to zero, the clock will never be stepped; however, users should understand the implications for doing this in a distributed data network where all processing must be tightly synchronized. See the <a href="http://www.eecis.udel.edu/%7emills/leap.html">NTP Timescale and Leap Seconds</a> page for further information. If a step adjustment is made, the clock discipline algorithm will start all over again, requiring another round of at least four messages as before. This is necessary so that all servers and peers operate on the same set of time values.</p>
+               <p>The clock discipline algorithm is designed to avoid large noise spikes that might occur on a congested network or access line. If an offset sample exceeds the step threshold, it is ignored and a timer started. If a later sample is below the step threshold, the counter is reset and operation continues normally. However, if the counter is greater than the stepout interval, which defaults to 900 s, the next sample will step the time as directed. The stepout threshold can be changed by the <tt>tinker stepout</tt> command discribed on the Miscellaneous Options page.</p>
+               <p>If for some reason the hardware clock oscillator frequency error is very large, say over 400 PPM, the time offset when the daemon is started for the first time may increase over time until exceeding the step threshold, which requires a frequency adjustment and another step correction. However, due to provisions that reduce vulnerability to noise spikes, the second correction will not be done until after the stepout threshold. When the frequency error is very large, it may take a number of cycles like this until converging to the nominal frequency correction and writing the <tt>ntp.drift</tt> file. If the frequency error is over 500 PPM, convergence will never occur and occasional step adjustments will occur indefinitely.</p>
+               <h4>Verifying Correct Operation</h4>
+               <p>After starting the daemon, run the <tt>ntpq</tt> program using the <tt>-n</tt> switch, which will avoid possible distractions due to name resolution problems. Use the <tt>pe</tt> command to display a billboard showing the status of configured peers and possibly other clients poking the daemon. After operating for a few minutes, the display should be something like:</p>
+               <pre>
+ntpq&gt; pe
+     remote      refid       st t when poll reach delay offset jitter
+=====================================================================
+-isipc6.cairn.ne .GPS1.        1 u  18  64  377  65.592 -5.891  0.044
++saicpc-isiepc2. pogo.udel.edu 2 u 241 128  370  10.477 -0.117  0.067
++uclpc.cairn.net pogo.udel.edu 2 u  37  64  177 212.111 -0.551  0.187
+*pogo.udel.edu   .GPS1.        1 u  95 128  377   0.607  0.123  0.027
+</pre>
+               <p>The host names or addresses shown in the <tt>remote</tt> column correspond to the server and peer entries listed in the configuration file; however, the DNS names might not agree if the names listed are not the canonical DNS names. IPv4 addresses are shown in dotted quad notation, while IPv6 addresses are shown alarmingly. The <tt>refid</tt> column shows the current source of synchronization, while the <tt>st</tt> column reveals the stratum, <tt>t</tt> the type (<tt>u</tt> = unicast, <tt>m</tt> = multicast, <tt>l</tt> = local, <tt>-</tt> = don't know), and <tt>poll</tt> the poll interval in seconds. The <tt>when</tt> column shows the time since the peer was last heard in seconds, while the <tt>reach</tt> column shows the status of the reachability register (see RFC-1305) in octal. The remaining entries show the latest delay, offset and jitter in milliseconds. Note that in NTP Version 4 what used to be the <tt>dispersion</tt> column has been replaced by the <tt>jitter</tt> column.</p>
+               <p>As per the NTP specification RFC-1305, when the <tt>stratum</tt> is between 0 and 15 for a NTP server, the <tt>refid</tt> field shows the server DNS name or, if not found, the IP address in dotted-quad. When the <tt>stratum</tt> is any value for a reference clock, this field shows the identification string assigned to the clock. However, until the client has synchronized to a server, or when the <tt>stratum</tt> for a NTP server is 0 (appears as 16 in the billboards), the status cannot be determined. As a help in debugging, the <tt>refid</tt> field is set to a four-character string called the kiss code. The current kiss codes are as as follows.</p>
+               <p>Peer Kiss Codes</p>
+               <p><tt>ACST</tt></p>
+               <dl>
+                       <dd>The association belongs to a anycast server.
+                       <dt><tt>AUTH</tt>
+                       <dd>Server authentication failed. Please wait while the association is restarted.
+                       <dt><tt>AUTO</tt>
+                       <dd>Autokey sequence failed. Please wait while the association is restarted.
+                       <dt><tt>BCST</tt>
+                       <dd>The association belongs to a broadcast server.
+                       <dt><tt>CRYP</tt>
+                       <dd>Cryptographic authentication or identification failed. The details should be in the system log file or the <tt>cryptostats</tt> statistics file, if configured. No further messages will be sent to the server.
+                       <dt><tt>DENY</tt>
+                       <dd>Access denied by remote server. No further messages will be sent to the server.
+                       <dt><tt>DROP</tt>
+                       <dd>Lost peer in symmetric mode. Please wait while the association is restarted.
+                       <dt><tt>RSTR</tt>
+                       <dd>Access denied due to local policy. No further messages will be sent to the server.
+                       <dt><tt>INIT</tt>
+                       <dd>The association has not yet synchronized for the first time.
+                       <dt><tt>MCST</tt>
+                       <dd>The association belongs to a manycast server.
+                       <dt><tt>NKEY</tt>
+                       <dd>No key found. Either the key was never installed or is not trusted.
+                       <dt><tt>RATE</tt>
+                       <dd>Rate exceeded. The server has temporarily denied access because the client exceeded the rate threshold.
+                       <dt><tt>RMOT</tt>
+                       <dd>Somebody is tinkering with the association from a remote host running <tt>ntpdc</tt>. Not to worry unless some rascal has stolen your keys.
+                       <dt><tt>STEP</tt>
+                       <dd>A step change in system time has occurred, but the association has not yet resynchronized.
+               </dl>
+               <p>System Kiss Codes</p>
+               <dl>
+                       <dt><tt>INIT</tt>
+                       <dd>The system clock has not yet synchronized for the first time.
+                       <dt><tt>STEP</tt>
+                       <dd>A step change in system time has occurred, but the system clock has not yet resynchronized.
+               </dl>
+               <p>The tattletale symbol at the left margin displays the synchronization status of each peer. The currently selected peer is marked <tt>*</tt>, while additional peers designated acceptable for synchronization are marked <tt>+</tt>. Peers marked <tt>*</tt> and <tt>+</tt> are included in the weighted average computation to set the local clock; the data produced by peers marked with other symbols are discarded. See the <tt>ntpq</tt> page for the meaning of these symbols.</p>
+               <p>Additional details for each peer separately can be determined by the following procedure. First, use the <tt>as</tt> command to display an index of association identifiers, such as</p>
+               <pre>
+ntpq&gt; as
+ind assID status  conf reach auth condition  last_event cnt
+===========================================================
+  1 50252  f314   yes   yes   ok    outlyer   reachable  1
+  2 50253  f414   yes   yes   ok   candidat   reachable  1
+  3 50254  f414   yes   yes   ok   candidat   reachable  1
+  4 50255  f614   yes   yes   ok   sys.peer   reachable  1
+</pre>
+               <p>Each line in this billboard is associated with the corresponding line in the <tt>pe</tt> billboard above. The <tt>assID</tt> shows the unique identifier for each mobilized association, while the <tt>status</tt> column shows the peer status word in hex, as defined in the NTP specification. Next, use the <tt>rv</tt> command and the respective <tt>assID</tt> identifier to display a detailed synopsis for the selected peer, such as</p>
+               <pre>
+ntpq&gt; rv 50253
+status=f414 reach, conf, auth, sel_candidat, 1 event, event_reach,
+srcadr=saicpc-isiepc2.cairn.net, srcport=123, dstadr=140.173.1.46,
+dstport=123, keyid=3816249004, stratum=2, precision=-27,
+rootdelay=10.925, rootdispersion=12.848, refid=pogo.udel.edu,
+reftime=bd11b225.133e1437  Sat, Jul  8 2000 13:59:01.075, delay=10.550,
+offset=-1.357, jitter=0.074, dispersion=1.444, reach=377, valid=7,
+hmode=1, pmode=1, hpoll=6, ppoll=7, leap=00, flash=00 ok,
+org=bd11b23c.01385836  Sat, Jul  8 2000 13:59:24.004,
+rec=bd11b23c.02dc8fb8  Sat, Jul  8 2000 13:59:24.011,
+xmt=bd11b21a.ac34c1a8  Sat, Jul  8 2000 13:58:50.672,
+filtdelay=   10.45  10.50  10.63  10.40  10.48  10.43  10.49  11.26,
+filtoffset=  -1.18  -1.26  -1.26  -1.35  -1.35  -1.42  -1.54  -1.81,
+filtdisp=     0.51   1.47   2.46   3.45   4.40   5.34   6.33   7.28,
+hostname=&quot;miro.time.saic.com&quot;, signature=md5WithRSAEncryption, flags=0x83f01, initsequence=61, initkey=0x287b649c,
+timestamp=3172053041
+</pre>
+               <p>A detailed explanation of the fields in this billboard are beyond the scope of this discussion; however, most variables defined in the NTP Version 3 specification RFC-1305 are available along with others defined for NTPv4 on the <tt>ntpq</tt> page. This particular example was chosen to illustrate probably the most complex configuration involving symmetric modes and public-key cryptography. As the result of debugging experience, the names and values of these variables may change from time to time.</p>
+               <p>A useful indicator of miscellaneous problems is the <tt>flash</tt> value, which reveals the state of the various sanity tests on incoming packets. There are currently 12 bits, one for each test, numbered from the right, which is for test 1. If the test fails, the corresponding bit is set to one and zero otherwise. If any bit is set following each processing step, the packet is discarded. The meaning of each test is described on the <tt>ntpq</tt> page.</p>
+               <p>The three lines identified as <tt>filtdelay</tt>, <tt>filtoffset</tt> and <tt>filtdisp</tt> reveal the roundtrip delay, clock offset and dispersion for each of the last eight measurement rounds, all in milliseconds. Note that the dispersion, which is an estimate of the error, increases as the age of the sample increases. From these data, it is usually possible to determine the incidence of severe packet loss, network congestion, and unstable local clock oscillators. There are no hard and fast rules here, since every case is unique; however, if one or more of the rounds show large values or change radically from one round to another, the network is probably congested or lossy.</p>
+               <p>Once the daemon has set the local clock, it will continuously track the discrepancy between local time and NTP time and adjust the local clock accordingly. There are two components of this adjustment, time and frequency. These adjustments are automatically determined by the clock discipline algorithm, which functions as a hybrid phase/frequency feedback loop. The behavior of this algorithm is carefully controlled to minimize residual errors due to network jitter and frequency variations of the local clock hardware oscillator that normally occur in practice. However, when started for the first time, the algorithm may take some time to converge on the intrinsic frequency error of the host machine.</p>
+               <p>The state of the local clock itself can be determined using the <tt>rv</tt> command (without the argument), such as</p>
+               <pre>
+ntpq&gt; rv
+status=0644 leap_none, sync_ntp, 4 events, event_peer/strat_chg,
+version=&quot;ntpd 4.0.99j4-r Fri Jul  7 23:38:17 GMT 2000 (1)&quot;,
+processor=&quot;i386&quot;, system=&quot;FreeBSD3.4-RELEASE&quot;, leap=00, stratum=2,
+precision=-27, rootdelay=0.552, rootdispersion=12.532, peer=50255,
+refid=pogo.udel.edu,
+reftime=bd11b220.ac89f40a  Sat, Jul  8 2000 13:58:56.673, poll=6,
+clock=bd11b225.ee201472  Sat, Jul  8 2000 13:59:01.930, state=4,
+phase=0.179, frequency=44.298, jitter=0.022, stability=0.001,
+hostname=&quot;barnstable.udel.edu&quot;, signature=md5WithRSAEncryption,
+flags=0x80011, hostkey=3171372095, refresh=3172016539
+cert=&quot;grundoon.udel.edu grundoon.udel.edu 0x3 3233600829&quot;
+cert=&quot;whimsy.udel.edu whimsy.udel.edu 0x5 3233682156&quot;
+</pre>
+               <p>An explanation about most of these variables is in the RFC-1305 specification. The most useful ones include <tt>clock</tt>, which shows when the clock was last adjusted, and <tt>reftime</tt>, which shows when the server clock of <tt>refid</tt> was last adjusted. The <tt>version</tt>, <tt>processor</tt> and <tt>system</tt> values are very helpful when included in bug reports. The mean millisecond time offset (<tt>phase</tt>) and deviation (<tt>jitter</tt>) monitor the clock quality, while the mean PPM frequency offset (<tt>frequency</tt>) and deviation (<tt>stability</tt>) monitor the clock stability and serve as a useful diagnostic tool. It has been the experience of NTP operators over the years that these data represent useful environment and hardware alarms. If the motherboard fan freezes up or some hardware bit sticks, the system clock is usually the first to notice it.</p>
+               <p>Among the new variables added for NTP Version 4 are the <tt>hostname</tt>, <tt>signature</tt>, <tt>flags, hostkey, refresh </tt>and<tt> cert</tt>, which are used for the Autokey public-key cryptography described on the <a href="authopt.html">Authentication Options</a> page. The numeric values show the filestamps, in NTP seconds, that the associated media files were created. These are useful in diagnosing problems with cryptographic key consistency and ordering principles.</p>
+               <p>When nothing seems to happen in the <tt>pe</tt> billboard after some minutes, there may be a network problem. One common network problem is an access controlled router on the path to the selected peer or an access controlled server using methods described on the <a href="accopt.html">Access Control Options</a> page. Another common problem is that the server is down or running in unsynchronized mode due to a local problem. Use the <tt>ntpq</tt> program to spy on the server variables in the same way you can spy on your own.</p>
+               <p>Normally, the daemon will adjust the local clock in small steps in such a way that system and user programs are unaware of its operation. The adjustment process operates continuously unless the apparent clock error exceeds the step threshold for a period longer than the stepout threshold, which for most Internet paths is a very rare event. If the event is simply an outlyer due to an occasional network delay spike, the correction is simply discarded; however, if the apparent time error persists for longer than the stepout threshold of about 17 minutes, the local clock is stepped or slewed to the new value as directed. This behavior is designed to resist errors due to severely congested network paths, as well as errors due to confused radio clocks upon the epoch of a leap second.</p>
+               <h4>Large Frequency Errors</h4>
+               <p>The frequency tolerance of computer clock oscillators can vary widely, which can put a strain on the daemon's ability to compensate for the intrinsic frequency error. While the daemon can handle frequency errors up to 500 parts-per-million (PPM), or 43 seconds per day, values much above 100 PPM reduce the headroom and increase the time to learn the particular value and record it in the <tt>ntp.drift</tt> file. In extreme cases before the particular oscillator frequency error has been determined, the residual system time offsets can sweep from one extreme to the other of the 128-ms tracking window only for the behavior to repeat at 900-s intervals until the measurements have converged.</p>
+               <p>In order to determine if excessive frequency error is a problem, observe the nominal <tt>filtoffset</tt> values for a number of rounds and divide by the poll interval. If the result is something approaching 500 PPM, there is a good chance that NTP will not work properly until the frequency error is reduced by some means. A common cause is the hardware time-of-year (TOY) clock chip, which must be disabled when NTP disciplines the software clock. For some systems this can be done using the <tt><a href="tickadj.html">tickadj</a></tt> utility and the <tt>-s</tt> command line argument. For other systems this can be done using a command in the system startup file.</p>
+               <p>If the TOY chip is not the cause, the problem may be that the hardware clock frequency may simply be too slow or two fast. In some systems this might require tweaking a trimmer capacitor on the motherboard. For other systems the clock frequency can be adjusted in increments of 100 PPM using the <tt>tickadj</tt> utility and the <tt>-t</tt> command line argument. Note that the <tt>tickadj</tt> alters certain kernel variables and, while the utility attempts to figure out an acceptable way to do this, there are many cases where <tt>tickadj</tt> is incompatible with a running kernel.</p>
+               <h4>Access Controls</h4>
+               <p>Provisions are included in <tt>ntpd</tt> for access controls which deflect unwanted traffic from selected hosts or networks. The controls described on the <a href="accopt.html">Access Control Options</a> include detailed packet filter operations based on source address and address mask. Normally, filtered packets are dropped without notice other than to increment tally counters. However, the server can be configured to send a &quot;kiss-o'-death&quot; (KOD) packet to the client either when explicitly configured or when cryptographic authentication fails for some reason. The client association is permanently disabled, the access denied bit (TEST4) is set in the flash variable and a message is sent to the system log.</p>
+               <p>The access control provisions include a limit on the packet rate from a host or network. If an incoming packet exceeds the limit, it is dropped and a KOD sent to the source. If this occurs after the client association has synchronized, the association is not disabled, but a message is sent to the system log. See the <a href="accopt.html">Access Control Options</a> page for further informatin.</p>
+               <h4>Large Delay Variations</h4>
+               <p>In some reported scenarios an access line may show low to moderate network delays during some period of the day and moderate to high delays during other periods. Often the delay on one direction of transmission dominates, which can result in large time offset errors, sometimes in the range up to a few seconds. It is not usually convenient to run <tt>ntpd</tt> throughout the day in such scenarios, since this could result in several time steps, especially if the condition persists for greater than the stepout threshold.</p>
+               <p>Specific provisions have been built into <tt>ntpd</tt> to cope with these problems. The scheme is called &quot;huff-'n-puff and is described on the <a href="miscopt.html">Miscellaneous Options</a> page. An alternative approach in such scenarios is first to calibrate the local clock frequency error by running <tt>ntpd</tt> in continuous mode during the quiet interval and let it write the frequency to the <tt>ntp.drift</tt> file. Then, run <tt>ntpd -q</tt> from a cron job each day at some time in the quiet interval. In systems with the nanokernel or microkernel performance enhancements, including Solaris, Tru64, Linux and FreeBSD, the kernel continuously disciplines the frequency so that the residual correction produced by <tt>ntpd</tt> is usually less than a few milliseconds.</p>
+               <h4>Cryptographic Authentication</h4>
+               <p>Reliable source authentication requires the use of symmetric key or public key cryptography, as described on the <a href="authopt.html">Authentication Options</a> page. In symmetric key cryptography servers and clients share session keys contained in a secret key file In public key cryptography, which requires the OpenSSL software library, the server has a private key, never shared, and a public key with unrestricted distribution. The cryptographic media required are produced by the <a href="keygen.html"><tt>ntp-keygen</tt></a> program.</p>
+               <p>Problems with symmetric key authentication are usually due to mismatched keys or improper use of the <tt>trustedkey</tt> command. A simple way to check for problems is to use the trace facility, which is enabled using the <tt>ntpd -d</tt> command line. As each packet is received a trace line is displayed which shows the authentication status in the <tt>auth</tt> field. A status of 1 indicates the packet was successful authenticated; otherwise it has failed.</p>
+               <p>A common misconception is the implication of the <tt>auth</tt> bit in the <tt>enable</tt> and <tt>disable</tt> commands. <b>This bit does not affect authentication in any way other than to enable or disable mobilization of a new persistent association in broadcast/multicast client, manycast client or symmetric passive modes.</b> If enabled, which is the default, these associations require authentication; if not, an association is mobilized even if not authenticated. Users are cautioned that running with authentication disabled is very dangerous, since an intruder can easily strike up an association and inject false time values.</p>
+               <p>Public key cryptography is supported in NTPv4 using the Autokey protocol, which is described in briefings on the NTP Project page linked from www.ntp.org. Development of this protocol is mature and the <tt>ntpd</tt> implementation is basically complete. Autokey version 2, which is the latest and current version, includes provisions to hike certificate trails, operate as certificate authorities and verify identity using challenge/response identification schemes. Further details of the protocol are on the <a href="authopt.html">Authentication Options</a> page. Common problems with configuration and key generation are mismatched key files, broken links and missing or broken random seed file.</p>
+               <p>As in the symmetric key cryptography case, the trace facility is a good way to verify correct operation. A statistics file <tt>cryptostats</tt> records protocol transactions and error messages. The daemon requires a random seed file, public/private key file and a valid certificate file; otherwise it exits immediately with a message to the system log. As each file is loaded a trace message appears with its filestamp. There are a number of checks to insure that only consistent data are used and that the certificate is valid. When the protocol is in operation a number of checks are done to verify the server has the expected credentials and its filestamps and timestamps are consistent. Errors found are reported using NTP control and monitoring protocol traps with extended trap codes shown in the Authentication Options page.</p>
+               <p>To assist debugging every NTP extension field is displayed in the trace along with the Autokey operation code. Every extension field carrying a verified signature is identified and displayed along with filestamp and timestamp where meaningful. In all except broadcast/multicast client mode, correct operation of the protocol is confirmed by the absence of extension fields and an <tt>auth</tt> value of one. It is normal in broadcast/multicast client mode that the broadcast server use one extension field to show the host name, status word and association ID.</p>
+               <h4>Debugging Checklist</h4>
+               <p>If the <tt>ntpq</tt> or <tt>ntpdc</tt> programs do not show that messages are being received by the daemon or that received messages do not result in correct synchronization, verify the following:</p>
+               <ol>
+                       <li>Verify the <tt>/etc/services</tt> file host machine is configured to accept UDP packets on the NTP port 123. NTP is specifically designed to use UDP and does not respond to TCP.
+                       <li>Check the system log for <tt>ntpd</tt> messages about configuration errors, name-lookup failures or initialization problems. Common system log messages are summarized on the <a href="msyslog.html"><tt>ntpd</tt> System Log Messages</a> page. Check to be sure that only one copy of <tt>ntpd</tt> is running.
+                       <li>Verify using <tt>ping</tt> or other utility that packets actually do make the round trip between the client and server. Verify using <tt>nslookup</tt> or other utility that the DNS server names do exist and resolve to valid Internet addresses.
+                       <li>Check that the remote NTP&nbsp;server is up and running. The usual evidence that it is not is a <tt>Connection refused</tt> message.
+                       <li>Using the <tt>ntpdc</tt> program, verify that the packets received and packets sent counters are incrementing. If the sent counter does not increment and the configuration file includes configured servers, something may be wrong in the host network or interface configuration. If this counter does increment, but the received counter does not increment, something may be wrong in the network or the server NTP daemon may not be running or the server itself may be down or not responding.
+                       <li>If both the sent and received counters do increment, but the <tt>reach</tt> values in the <tt>pe</tt> billboard with <tt>ntpq</tt> continues to show zero, received packets are probably being discarded for some reason. If this is the case, the cause should be evident from the <tt>flash</tt> variable as discussed above and on the <tt>ntpq</tt> page. It could be that the server has disabled access for the client address, in which case the refid field in the <tt>ntpq pe</tt> billboard will show a kiss code. See earlier on this page for a list of kiss codes and their meaning.
+                       <li>If the <tt>reach</tt> values in the <tt>pe</tt> billboard show the servers are alive and responding, note the tattletale symbols at the left margin, which indicate the status of each server resulting from the various grooming and mitigation algorithms. The interpretation of these symbols is discussed on the <tt>ntpq</tt> page. After a few minutes of operation, one or another of the reachable server candidates should show a * tattletale symbol. If this doesn't happen, the intersection algorithm, which classifies the servers as truechimers or falsetickers, may be unable to find a majority of truechimers among the server population.
+                       <li>If all else fails, see the FAQ and/or the discussion and briefings at the NTP Project page.
+               </ol>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver1.html b/html/drivers/driver1.html
new file mode 100644 (file)
index 0000000..afd85d2
--- /dev/null
@@ -0,0 +1,65 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Undisciplined Local Clock</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Undisciplined Local Clock</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.1.<i>u</i><br>
+                       Reference ID: <tt>LCL</tt><br>
+                       Driver ID: <tt>LOCAL</tt></p>
+               <h4>Description</h4>
+               <p>This driver is intended for use in an isolated network where no external source of synchronization such as a radio clock or modem is available. It allows a designated time server to act as a primary server to provide synchronization to other clients on the network. Pick a machine that has a good clock oscillator (Digital machines are good, Sun machines are not) and configure it with this driver. Set the clock using the best means available, like eyeball-and-wristwatch. Then, point all the other machines at this one or use broadcast (not multicast) mode to distribute time.</p>
+               <p>Another application for this driver is if a particular server clock is to be used as the clock of last resort when all other normal synchronization sources have gone away. This is especially useful if that server has an ovenized oscillator. For this you would configure this driver at a stratum greater than any other likely sources of time (say 3 or 4) to prevent the server taking over when legitimate sources are still available.</p>
+               <p>A third application for this driver is when an external discipline source is available, such as the NIST <tt>lockclock</tt> program, which synchronizes the local clock via a telephone modem and the NIST Automated Computer Time Service (ACTS), or the Digital Time Synchronization Service (DTSS), which runs on DCE machines. In this case the stratum should be set at zero, indicating a bona fide stratum-1 source. In the case of DTSS, the local clock can have a rather large jitter, depending on the interval between corrections and the intrinsic frequency error of the clock oscillator. In extreme cases, this can cause clients to exceed the 128-ms slew window and drop off the NTP subnet.</p>
+               <p>In the case where a NTP time server is synchronized to some device or protocol that is not external to the NTP daemon itself, some means should be provided to pass such things as error and health values to the NTP daemon for dissemination to its clients. If this is not done, there is a very real danger that the device or protocol could fail and with no means to tell NTP clients of the mishap. When ordinary Unix system calls like <tt>adjtime()</tt> are used to discipline the kernel clock, there is no obvious way this can be done without modifying the code for each case. However, when a modified kernel with the <tt>ntp_adjtime()</tt> system call&nbsp; is available, that routine can be used for the same purpose as the <tt>adjtime()</tt> routine and in addition provided with the estimated error, maximum error, and leap-indicator values. This is the preferred way to synchronize the kernel clock and pass information to the NTP clients.</p>
+               <p>In the default mode the behavior of the clock selection algorithm is modified when this driver is in use. The algorithm is designed so that this driver will never be selected unless no other discipline source is available. This can be overridden with the <tt>prefer</tt> keyword of the <tt>server</tt> configuration command, in which case only this driver will be selected for synchronization and all other discipline sources will be ignored. This behavior is intended for use when an external discipline source controls the system clock. See the <a href="../prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a> page for a detailed description of the exact behavior.</p>
+               <p>The stratum for this driver is set at 5 by default, but can be changed by the <tt>fudge</tt> configuration command and/or the <tt>ntpdc</tt> utility. The reference ID is <tt>LCL</tt> by default, but can be changed using the same mechanisms. <b>*NEVER*</b> configure this driver to operate at a stratum which might possibly disrupt a client with access to a bona fide primary server, unless the local clock oscillator is reliably disciplined by another source. <b>*NEVER NEVER*</b> configure a server which might devolve to an undisciplined local clock to use multicast mode.</p>
+               <p>This driver provides a mechanism to trim the local clock in both time and frequency, as well as a way to manipulate the leap bits. The <tt>fudge time1</tt> parameter adjusts the time (in seconds) and the <tt>fudge time2</tt> parameter adjusts the frequency (in parts per million). Both parameters are additive and operate only once; that is, each command (as from <tt>ntpdc</tt>) adds signed increments in time or frequency to the nominal local clock time and frequency.</p>
+               <h4>Operation with an External Reference Source</h4>
+               <p>There are special provisions for this driver to operate in conjunction with an external reference source, such as the <tt>LOCKCLOCK</tt> scheme used by the NIST&nbsp;time servers. In such schemes the system clock is disciplined by a source external to NTP, in the <tt>LOCKCLOCK</tt> case an ACTS&nbsp;telephone modem. To support <tt>LOCKCLOCK</tt> the NTP&nbsp;distribution should be built with the <tt>--enable-nist</tt> parameter in the configuration phase of the build procedure. This changes the system behavior as follows:</p>
+               <ol>
+                       <li>The system clock is not disciplined in any way other than to call the <tt>ntp_adjtime()</tt>&nbsp;system call to obtain the kernel leap code, which becomes the driver leap code and. If the kernel leap code is 11 (not synchronized), the driver stratum is infinity; otherwise the stratum is set by the <tt>stratum</tt> subcommand on the <tt>fudge</tt> command applying to the driver.
+                       <li>The NTP&nbsp;algorithms operate in the normal fashion with this driver and possibly other drivers and servers; however, the local clock driver as the <tt>prefer</tt> peer will always be selected, even if declared falseticker by the selection algorithm or fails to survive the clustering algorithm.
+                       <li>If the driver leap code is 11, the system leap code is 11, system stratum infinity and system reference identifier <tt>DOWN</tt>. This provides a definitive status condition to dependent clients.
+               </ol>
+               <p>The local clock driver should be configured something like this:</p>
+               <p><tt>server 127.127.1.1 prefer</tt></p>
+               <p><tt>fudge 127.127.1.1 stratum 0 refid NIST</tt></p>
+               <p>The <tt>prefer</tt> keyword forces the driver to discipline the clock, even if other servers are configured and running correctly. This is convenient when a number of servers watch each other for monitoring and statistics gathering. In particular, the <tt>peerstats</tt> data and <tt>sysstats</tt> data can be collected at each server, aggregated for daily or weekly reports and sent by electric mail to a monitoring site. In addition, the full suite of cryptographic authentication algorithms is avialable to other servers and dependent clients.</p>
+               <h4>Monitor Data</h4>
+               <p>No <tt>filegen clockstats</tt> monitor data are produced by this driver.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Specifies the frequency offset calibration factor, in parts per million, with default 0.0.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 3.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>LCL</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Not used by this driver.
+               </dl>
+               <h4>Additional Information</h4>
+               <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver10.html b/html/drivers/driver10.html
new file mode 100644 (file)
index 0000000..97b0495
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+        <title>Austron 2200A/2201A GPS Receivers</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Austron 2200A/2201A GPS Receivers</h3>
+        <hr>
+        <h4>Synopsis</h4>
+        <p>Address: 127.127.10.<i>u</i><br>
+            Reference ID: <tt>GPS</tt><br>
+            Driver ID: <tt>GPS_AS2201</tt><br>
+            Serial Port: <tt>/dev/gps<i>u</i></tt>; 9600 baud, 8-bits, no parity<br>
+            Features: <tt>tty_clk</tt></p>
+        <h4>Description</h4>
+        <p>This driver supports the Austron 2200A/2201A GPS/LORAN Synchronized Clock and Timing Receiver connected via a serial port. It supports several special features of the clock, including the Input Buffer Module, Output Buffer Module, IRIG-B Interface Module and LORAN Assist Module. It requires the RS232 Buffered Serial Interface module for communication with the driver. For operation with multiple computers, it requires the <tt>ppsclock</tt> streams module described in the <a href="../ldisc.html">Line Disciplines and Streams Modules</a> page. The streams module requires a gadget box and 1-PPS level converter, such as described in the <a href="../pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page.</p>
+        <p>For use with a single computer, the receiver can be connected directly to the receiver. For use with multiple computers, one of them is connected directly to the receiver and generates the polling messages. The other computers just listen to the receiver output directly or through a buffer amplifier. For computers that just listen, <tt>fudge flag2</tt> must be set and the <tt>ppsclock </tt>streams module configured on each of them.</p>
+        <p>This receiver is capable of a comprehensive and large volume of statistics and operational data. The specific data collection commands and attributes are embedded in the driver source code; however, the collection process can be enabled or disabled using the flag4 flag. If set, collection is enabled; if not, which is the default, it is disabled. A comprehensive suite of data reduction and summary scripts is in the ./scripts/stats directory</p>
+        of the ntp3 distribution.
+        <h4>Monitor Data</h4>
+        <p>When enabled by the <tt>flag4</tt> fudge flag, every received timecode is written as-is to the <tt>clockstats</tt> file.</p>
+        <h4>Fudge Factors</h4>
+        <dl>
+            <dt><tt>time1 <i>time</i></tt>
+            <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+            <dt><tt>time2 <i>time</i></tt>
+            <dd>Not used by this driver.
+            <dt><tt>stratum <i>number</i></tt>
+            <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+            <dt><tt>refid <i>string</i></tt>
+            <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>GPS</tt>.
+            <dt><tt>flag1 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag2 0 | 1</tt>
+            <dd>Set for computers that listen-only.
+            <dt><tt>flag3 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag4 0 | 1</tt>
+            <dd>Enable verbose <tt>clockstats</tt> recording if set.
+        </dl>
+        <h4>Additional Information</h4>
+        <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver11.html b/html/drivers/driver11.html
new file mode 100644 (file)
index 0000000..b36f7f3
--- /dev/null
@@ -0,0 +1,87 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+        <title>Arbiter 1088A/B GPS Receiver</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Arbiter 1088A/B GPS Receiver</h3>
+        <hr>
+        <h4>Synopsis</h4>
+        <p>Address: 127.127.11.<i>u</i><br>
+            Reference ID: <tt>GPS</tt><br>
+            Driver ID: <tt>GPS_ARBITER</tt><br>
+            Serial Port: <tt>/dev/gps<i>u</i></tt>; 9600 baud, 8-bits, no parity<br>
+            Features: <tt>tty_clk</tt></p>
+        <h4>
+            <p>Description</p>
+        </h4>
+        <p>This driver supports the Arbiter 1088A/B Satellite Controlled Clock. The claimed accuracy of this clock is 100 ns relative to the PPS output when receiving four or more satellites.</p>
+        <p>The receiver should be configured before starting the NTP daemon, in order to establish reliable position and operating conditions. It does not initiate surveying or hold mode. For use with NTP, the daylight savings time feature should be disables (<tt>D0</tt> command) and the broadcast mode set to operate in UTC (<tt>BU</tt> command).</p>
+        <p>The timecode format supported by this driver is selected by the poll sequence <tt>B5</tt>, which initiates a line in the following format to be repeated once per second until turned off by the <tt>B0</tt> command.</p>
+        <p>Format <tt>B5</tt> (24 ASCII printing characters):</p>
+        <pre>&lt;cr&gt;&lt;lf&gt;i yy ddd hh:mm:ss.000bbb
+
+on-time = &lt;cr&gt;
+i = synchronization flag (' ' = locked, '?' = unlocked)
+yy = year of century
+ddd = day of year
+hh:mm:ss = hours, minutes, seconds
+.000 = fraction of second (not used)
+bbb = tailing spaces for fill</pre>
+        <p>The alarm condition is indicated by a '?' at i, which indicates the receiver is not synchronized. In normal operation, a line consisting of the timecode followed by the time quality character (TQ) followed by the receiver status string (SR) is written to the clockstats file.</p>
+        <p>The time quality character is encoded in IEEE P1344 standard:</p>
+        <p>Format <tt>TQ</tt> (IEEE P1344 estimated worst-case time quality)</p>
+        <pre>0&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock locked, maximum accuracy
+F&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock failure, time not reliable
+4&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock unlocked, accuracy &lt; 1 us
+5&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock unlocked, accuracy &lt; 10 us
+6&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock unlocked, accuracy &lt; 100 us
+7&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock unlocked, accuracy &lt; 1 ms
+8&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock unlocked, accuracy &lt; 10 ms
+9&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock unlocked, accuracy &lt; 100 ms
+A&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock unlocked, accuracy &lt; 1 s
+B&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clock unlocked, accuracy &lt; 10 s</pre>
+        <p>The status string is encoded as follows:</p>
+        <p>Format <tt>SR</tt> (25 ASCII printing characters)</p>
+        <pre>V=vv S=ss T=t P=pdop E=ee
+
+vv = satellites visible
+ss = relative signal strength
+t = satellites tracked
+pdop = position dilution of precision (meters)
+ee = hardware errors</pre>
+        <p>A three-stage median filter is used to reduce jitter and provide a dispersion measure. The driver makes no attempt to correct for the intrinsic jitter of the radio itself.</p>
+        <h4>Monitor Data</h4>
+        <p>When enabled by the <tt>flag4</tt> fudge flag, an additional line containing the latitude, longitude, elevation and optional deviation data is written to the <tt>clockstats</tt> file. The deviation data operates with an external pulse-per-second (PPS) input, such as a cesium oscillator or another radio clock. The PPS input should be connected to the B event channel and the radio initialized for deviation data on that channel. The deviation data consists of the mean offset and standard deviation of the external PPS signal relative the GPS signal, both in microseconds over the last 16 seconds.</p>
+        <h4>Fudge Factors</h4>
+        <dl>
+            <dt><tt>time1 <i>time</i></tt>
+            <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+            <dt><tt>time2 <i>time</i></tt>
+            <dd>Not used by this driver.
+            <dt><tt>stratum <i>number</i></tt>
+            <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+            <dt><tt>refid <i>string</i></tt>
+            <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>GPS</tt>.
+            <dt><tt>flag1 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag2 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag3 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag4 0 | 1</tt>
+            <dd>Enable verbose <tt>clockstats</tt> recording if set.
+        </dl>
+        <h4>Additional Information</h4>
+        <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver12.html b/html/drivers/driver12.html
new file mode 100644 (file)
index 0000000..6d0b38a
--- /dev/null
@@ -0,0 +1,49 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+        <title>KSI/Odetics TPRO/S IRIG Interface</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>KSI/Odetics TPRO/S IRIG Interface</h3>
+        <hr>
+        <h4>Synopsis</h4>
+        <p>Address: 127.127.12.<i>u</i><br>
+            Reference ID: <tt>IRIG</tt><br>
+            Driver ID: <tt>IRIG_TPRO</tt><br>
+            TPRO Device: <tt>/dev/tpro<i>u</i></tt><br>
+            Requires: KSI/Odetics device driver, <tt>/usr/include/sys/tpro.h</tt> header file</p>
+        <h4>Description</h4>
+        <p>This driver supports the KSI/Odetics TPRO and TPRO-SAT IRIG-B Decoder, which is a module connected directly to the SBus of a Sun workstation. The module works with the IRIG-B signal generated by several radio clocks, including those made by Arbiter, Austron, Odetics, Spectracom and TrueTime, among others, although it is generally an add- on option. In the case of the TPRO-SAT, the module is an integral part of a GPS receiver, which serves as the primary timing source.</p>
+        <p>Using the TPRO interface as a NTP reference clock provides precision time only to ntpd and its clients. With suitable kernel modifications, it is possible to use the TPRO as the CPU system clock, avoiding errors introduced by the CPU clock oscillator wander. See the <a href="../kern.html">A Kernel Model for Precision Timekeeping </a>page for further details.</p>
+        <h4>Fudge Factors</h4>
+        <dl>
+            <dt><tt>time1 <i>time</i></tt>
+            <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+            <dt><tt>time2 <i>time</i></tt>
+            <dd>Not used by this driver.
+            <dt><tt>stratum <i>number</i></tt>
+            <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+            <dt><tt>refid <i>string</i></tt>
+            <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>IRIG</tt>.
+            <dt><tt>flag1 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag2 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag3 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag4 0 | 1</tt>
+            <dd>Not used by this driver.
+        </dl>
+        <h4>Additional Information</h4>
+        <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver16.html b/html/drivers/driver16.html
new file mode 100644 (file)
index 0000000..95308ba
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <meta name="GENERATOR" content="Mozilla/4.6 [en] (Win95; U) [Netscape]">
+        <meta name="Author" content="Ganesh Ramasivan">
+        <title>Bancomm bc635VME Time and Frequency Processor</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>bc635VME/bc350VXI Time and Frequency Processor</h3>
+        <hr>
+        <h4>Synopsis</h4>
+        <p>Address: 127.127.16.<i>u</i><br>
+            Reference ID: BTFP<br>
+            Driver ID: GPS_BANCOMM<br>
+            Bancomm Device <tt>/dev/btfp0</tt><br>
+            Requires: Bancomm bc635 TFP device module driver for SunOS 4.x/SunOS 5.x</p>
+        <h4>Description</h4>
+        <p>This is the clock driver for the Bancomm bc635VME Time and Frequency Processor. It requires the BANCOMM bc635VME bc350VXI Time and Frequency Processor Module Driver for SunOS 4.x/SunOS 5.x UNIX Systems.</p>
+        <p>Most of this code is originally from refclock_bancomm.c with thanks. It has been modified and tested on an UltraSparc IIi-cEngine running Solaris 2.6. A port for HPUX is not available henceforth.</p>
+        <h4>Additional Information</h4>
+        <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver18.html b/html/drivers/driver18.html
new file mode 100644 (file)
index 0000000..6acf5f2
--- /dev/null
@@ -0,0 +1,82 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+               <title>NIST Modem Time Service</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Automated Computer Time Service (ACTS)</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.18.<i>u</i><br>
+                       Reference ID: <tt>NIST | USNO | PTB | WWVB</tt><br>
+                       Driver ID: <tt>ACTS_MODEM</tt><br>
+                       Serial Port: <tt>/dev/acts<i>u</i></tt>; 9600 baud, 8-bits, no parity<br>
+                       Features: <tt>tty_clk</tt><br>
+                       Requires: <tt>/usr/include/sys/termios.h</tt> header file with modem control and a dial-out (cua)&nbsp;device.</p>
+               <h4>Description</h4>
+               <p>This driver supports the US (NIST and USNO) and European (PTB (Germany), NPL (UK), etc.) modem time services, as well as Spectracom GPS&nbsp;and WWVB receivers connected via a modem. The driver periodically dials a number from a telephone list, receives the timecode data and calculates the local clock correction. It is designed primarily for backup when neither a radio clock nor connectivity to Internet time servers are available. It can also be configured to operate full period.</p>
+               <p>For best results the indicated time must be corrected for the modem and telephone circuit propagation delays, which can reach 200 ms or more. For the NIST service, corrections are determined automatically by measuring the roundtrip delay of echoed characters. With this service the absolute accuracy is typically a millisecond or two. Corrections for the other services must be determined by other means. With these services variations from call to call and between messages during a call are typically a few milliseconds, occasionally higher.</p>
+               <p>This driver requires a 9600-bps modem with a Hayes-compatible command set and control over the modem data terminal ready (DTR) control line. The actual line speed ranges from 1200 bps with USNO&nbsp;to 14,400 bps with NIST. The modem setup string is hard-coded in the driver and may require changes for nonstandard modems or special circumstances.</p>
+               <p>There are three modes of operation selected by the <tt>mode</tt> keyword in the <tt>server</tt> configuration command. In manual mode (2) the calling program is initiated by setting fudge <tt>flag1</tt>. This can be done manually using <tt>ntpdc</tt>, or by a cron job. In auto mode (0) <tt>flag1</tt> is set at each poll event. In backup mode (1) <tt>flag1</tt> is set at each poll event, but only if no other synchronization sources are available.</p>
+               <p>When <tt>flag1</tt> is set, the calling program dials the first number in the list specified by the <tt>phone</tt> command. If the call fails for any reason, the program dials the second number and so on. The phone number is specified by the Hayes ATDT prefix followed by the number itself, including the prefix and long-distance digits and delay code, if necessary. The <tt>flag1</tt> is reset and the calling program terminated if (a) valid clock update has been determined, (b) no more numbers remain in the list, (c) a device fault or timeout occurs or (d) fudge <tt>flag1</tt> is reset manually using <tt>ntpdc</tt>.</p>
+               <p>The driver automatically recognizes the message format of each modem time service. It selects the parsing algorithm depending on the message length. There is some hazard should the message be corrupted. However, the data format is checked carefully and only if all checks succeed is the message accepted. Corrupted lines are discarded without complaint. Once the service is known, the reference identifier for the driver is set to NIST, USNO, PTB or WWVB as appropriate.</p>
+               <p>Ordinarily, the serial port is connected to a modem; however, if fudge <tt>flag3</tt> is set, it can be connected directly to a Spectracom WWV or GPS radio for testing or calibration. The Spectracom radio can be connected via a modem if the radio is connfigured to send time codes continuoulsly at 1-s intervals. In principle, fudge <tt>flag2</tt> enables port locking, allowing the modem to be shared when not in use by this driver. At least on Solaris with the current NTP I/O routines, this results in lots of ugly error messages.</p>
+               <p>The <tt>minpoll</tt> and <tt>maxpoll</tt> keywords of the server configuration command can be used to limit the intervals between calls. The recommended settings are 12 (1.1 hours) for <tt>minpoll</tt> and 17 (36 hours) for <tt>maxpoll</tt>. Ordinarily, the poll interval will start at <tt>minpoll</tt> and ramp up to <tt>maxpoll</tt> in a day or two.</p>
+               <h4>US Phone Numbers and Formats</h4>
+               <p>Note: Phone numbers include the entire Hayes modem command, including the <tt>ATDT</tt> and other control codes as may be necessary. For most cases only the <tt>ATDT</tt> may be necessary.</p>
+               <p><a href="http://www.boulder.nist.gov/timefreq">National Institute of Science and Technology (NIST)</a></p>
+               <p>Phone: (303) 494-4774 (Boulder, CO); (808) 335-4721 (Hawaii)</p>
+               <p><a href="http://www.boulder.nist.gov/timefreq/service/acts.htm">Data Format</a></p>
+               <p><tt>National Institute of Standards and Technology<br>
+                               Telephone Time Service, Generator 3B<br>
+                               Enter question mark &quot;?&quot; for HELP<br>
+                               MJD YR MO DA H M S ST S UT1 msADV &lt;OTM&gt;<br>
+                               47999 90-04-18 21:39:15 50 0 +.1 045.0 UTC(NIST) *<br>
+                               47999 90-04-18 21:39:16 50 0 +.1 045.0 UTC(NIST) #<br>
+                               ...</tt></p>
+               <p><tt>MJD</tt>, <tt>YR</tt>, <tt>ST</tt>, <tt>UT1</tt> and <tt>UTC(NIST)</tt> are not used by this driver. The <tt>&lt;OTM&gt;</tt> on-time character &quot;<tt>*</tt>&quot; changes to &quot;<tt>#</tt>&quot;&nbsp;when the delay correction is valid.</p>
+               <p><a href="http://tycho.usno.navy.mil">US Naval Observatory (USNO)</a></p>
+               <p>Phone: (202) 762-1594 (Washington, DC); (719) 567-6742 (Boulder, CO)</p>
+               <p><a href="http://tycho.usno.navy.mil/modem_time.html">Data Format</a> (two lines, repeating at one-second intervals)</p>
+               <p><tt>jjjjj nnn hhmmss UTC</tt></p>
+               <p>* on-time character for previous timecode message<br>
+                       jjjjj modified Julian day number (not used)<br>
+                       nnn day of year<br>
+                       hhmmss second of day</p>
+               <p><a href="tf582_4.html">European Phone Numbers and Formats</a></p>
+               <p><a href="http://www.spectracomcorp.com">Spectracom GPS and WWVB Receivers</a></p>
+               <p>If a modem is connected to a Spectracom receiver, this driver will call it and retrieve the time in one of two formats, 0 and 2. Ordinarily, the receiver requires a <tt>T</tt> in order to return the timecode. As this driver does not send data via the modem, it must either be configured in continuous mode or be polled by another local driver.</p>
+               <h4>Monitor Data</h4>
+               <p>The received timecode is written as-is to the <tt>clockstats</tt> file along with the Hayes connection and hangup commands and result codes.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Set by the driver to (one of) <tt>NIST</tt>, <tt>USNO</tt>, <tt>PTB</tt> or <tt>WWVB</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Initiate a call if 1. Automatically reset by program.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Enables port locking if 1, disables if 0 (default).
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Enables direct connection if 1, or modem if 0 (default). If set, the driver will send a single character 'T' at every poll event.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Not used by this driver.
+               </dl>
+               <h4>Additional Information</h4>
+               <p><a href="../refclock.html">Reference Clock Drivers</a>&nbsp;</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver19.html b/html/drivers/driver19.html
new file mode 100644 (file)
index 0000000..961ca09
--- /dev/null
@@ -0,0 +1,59 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+        <title>Heath WWV/WWVH Receiver</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Heath WWV/WWVH Receiver</h3>
+        <hr>
+        <h4>Synopsis</h4>
+        <p>Address: 127.127.19.<i>u</i><br>
+            Reference ID: <tt>WWV</tt><br>
+            Driver ID: <tt>WWV_HEATH</tt><br>
+            Serial Port: <tt>/dev/heath<i>u</i></tt>; 1200 baud, 8-bits, no parity<br>
+            Features: <tt>tty_clk</tt><br>
+            Requires: <tt>/usr/include/sys/termios.h</tt> header file with modem control</p>
+        <h4>Description</h4>
+        <p>This driver supports the Heath GC-1000 Most Accurate Clock, with RS232C Output Accessory. This is a WWV/WWVH receiver somewhat less robust than other supported receivers. Its claimed accuracy is 100 ms when actually synchronized to the broadcast signal, but this doesn't happen even most of the time, due to propagation conditions, ambient noise sources, etc. When not synchronized, the accuracy is at the whim of the internal clock oscillator, which can wander into the sunset without warning. Since the indicated precision is 100 ms, expect a host synchronized only to this thing to wander to and fro, occasionally being rudely stepped when the offset exceeds the default CLOCK_MAX of 128 ms.</p>
+        <p>The internal DIPswitches should be set to operate at 1200 baud in MANUAL mode and the current year. The external DIPswitches should be set to GMT and 24-hour format. It is very important that the year be set correctly in the DIPswitches; otherwise, the day of year will be incorrect after 28 April of a normal or leap year.</p>
+        <p>In MANUAL mode the clock responds to a rising edge of the request to send (RTS) modem control line by sending the timecode. Therefore, it is necessary that the operating system implement the <tt>TIOCMBIC</tt> and <tt>TIOCMBIS</tt> ioctl system calls and <tt>TIOCM_RTS</tt> control bit. Present restrictions require the use of a POSIX-compatible programming interface, although other interfaces may work as well.</p>
+        <p>The clock message consists of 23 ASCII printing characters in the following format:</p>
+        <pre>hh:mm:ss.f&nbsp;&nbsp;&nbsp;&nbsp; dd/mm/yr&lt;cr&gt;
+
+hh:mm:ss.f = hours, minutes, seconds
+f = deciseconds ('?' when out of spec)
+dd/mm/yr = day, month, year</pre>
+        <p>The alarm condition is indicated by '?', rather than a digit, at A. Note that 0?:??:??.? is displayed before synchronization is first established and hh:mm:ss.? once synchronization is established and then lost again for about a day.</p>
+        <p>A fudge time1 value of .07 s appears to center the clock offset residuals.</p>
+        <h4>Fudge Factors</h4>
+        <dl>
+            <dt><tt>time1 <i>time</i></tt>
+            <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+            <dt><tt>time2 <i>time</i></tt>
+            <dd>Not used by this driver.
+            <dt><tt>stratum <i>number</i></tt>
+            <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+            <dt><tt>refid <i>string</i></tt>
+            <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>WWV</tt>.
+            <dt><tt>flag1 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag2 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag3 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag4 0 | 1</tt>
+            <dd>Not used by this driver
+        </dl>
+        Additional Information
+        <p><a href="../refclock.html">Reference Clock Drivers</a>&nbsp;</p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver2.html b/html/drivers/driver2.html
new file mode 100644 (file)
index 0000000..20bad64
--- /dev/null
@@ -0,0 +1,67 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+        <title>Trak 8820 GPS Receiver</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Trak 8820 GPS Receiver</h3>
+        <hr>
+        <h4>Synopsis</h4>
+        <p>Address: 127.127.2.<i>u</i><br>
+            Reference ID: <tt>GPS</tt><br>
+            Driver ID: <tt>GPS_TRAK</tt><br>
+            Serial Port: <tt>/dev/trak<i>u</i></tt>; 9600 baud, 8-bits, no parity<br>
+            Features: <tt>tty_clk</tt></p>
+        <h4>Description</h4>
+        <p>This driver supports the Trak 8820 GPS Station Clock. The claimed accuracy at the 1-PPS output is 200-300 ns relative to the broadcast signal; however, in most cases the actual accuracy is limited by the precision of the timecode and the latencies of the serial interface and operating system.</p>
+        <p>For best accuracy, this radio requires the <tt>tty_clk</tt> line discipline, which captures a timestamp at the <tt>*</tt> on-time character of the timecode. Using this discipline the jitter is in the order of 1 ms and systematic error about 0.5 ms. If unavailable, the buffer timestamp is used, which is captured at the <tt>\r</tt> ending the timecode message. This introduces a systematic error of 23 character times, or about 24 ms at 9600 bps, together with a jitter well over 8 ms on Sun IPC-class machines.</p>
+        <p>Using the menus, the radio should be set for 9600 bps, one stop bit and no parity. It should be set to operate in computer (no echo) mode. The timecode format includes neither the year nor leap-second warning.</p>
+        <p>In operation, this driver sends a <tt>RQTS\r</tt> request to the radio at initialization in order to put it in continuous time output mode. The radio then sends the following message once each second:</p>
+        <pre>*RQTS U,ddd:hh:mm:ss.0,q&lt;cr&gt;&lt;lf&gt;
+on-time = '*'
+ddd = day of year
+hh:mm:ss = hours, minutes, seconds
+q = quality indicator (phase error), 0-6:
+&nbsp;&nbsp;&nbsp;&nbsp; 0 &gt; 20 us
+&nbsp;&nbsp;&nbsp;&nbsp; 6 &gt; 10 us
+&nbsp;&nbsp;&nbsp;&nbsp; 5 &gt; 1 us
+&nbsp;&nbsp;&nbsp;&nbsp; 4 &gt; 100 ns
+&nbsp;&nbsp;&nbsp;&nbsp; 3 &gt; 10 ns
+&nbsp;&nbsp;&nbsp;&nbsp; 2 &lt; 10 ns</pre>
+        The alarm condition is indicated by <tt>0</tt> at <tt>Q</tt>, which means the radio has a phase error greater than 20 us relative to the broadcast time. The absence of year, DST and leap-second warning in this format is also alarmed.
+        <p>The continuous time mode is disabled using the <tt>RQTX\r</tt> request, following which the radio sends a <tt>RQTX DONE&lt;cr&gt;&lt;lf&gt;</tt> response. In the normal mode, other control and status requests are effective, including the leap-second status request <tt>RQLS&lt;cr&gt;</tt>. The radio responds with <tt>RQLS yy,mm,dd&lt;cr&gt;&lt;lf&gt;</tt>, where <tt>yy,mm,dd</tt> are the year, month and day. Presumably, this gives the epoch of the next leap second, <tt>RQLS 00,00,00</tt> if none is specified in the GPS message. Specified in this form, the information is generally useless and is ignored by the driver.</p>
+        <h4>Monitor Data</h4>
+        <p>When enabled by the <tt>flag4</tt> fudge flag, every received timecode is written as-is to the <tt>clockstats</tt> file.</p>
+        <h4>Fudge Factors</h4>
+        <p></p>
+        <dl>
+            <dt><tt>time1 <i>time</i></tt>
+            <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+            <dt><tt>time2 <i>time</i></tt>
+            <dd>Not used by this driver.
+            <dt><tt>stratum <i>number</i></tt>
+            <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+            <dt><tt>refid <i>string</i></tt>
+            <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>GPS</tt>.
+            <dt><tt>flag1 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag2 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag3 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag4 0 | 1</tt>
+            <dd>Not used by this driver.
+            <p>Additional Information</p>
+            <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+        </dl>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver20.html b/html/drivers/driver20.html
new file mode 100644 (file)
index 0000000..17be32c
--- /dev/null
@@ -0,0 +1,91 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <meta name="GENERATOR" content="Mozilla/4.76 [en] (X11; U; Linux 2.2.16-22 i586) [Netscape]">
+               <title>Generic NMEA GPS Receiver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Generic NMEA GPS Receiver</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.20.<i>u</i><br>
+                       Reference ID: <tt>GPS</tt><br>
+                       Driver ID: <tt>GPS_NMEA</tt><br>
+                       Serial Port: <tt>/dev/gps<i>u</i></tt>; 4800 baud, 8-bits, no parity<br>
+                       Serial Port: <tt>/dev/gps<i>u</i></tt>; symlink to server:port (for nmead) Features: <tt>tty_clk</tt></p>
+               <h4>Description</h4>
+               <p>This driver supports GPS receivers with the <tt>$GPRMC</tt> NMEA output string by default.&nbsp; Alternately the <tt>$GPGGA</tt> or <tt>$GPGLL </tt>may be selected.</p>
+               <p>The driver expects the receiver to be set up to transmit a <tt>$GPRMC</tt> message every second.</p>
+               <p>The accuracy depend on the receiver used. Inexpesive GPS models are available with a claimed PPS signal accuracy of 1 <font face="Symbol">m</font>s or better relative to the broadcast signal. However, in most cases the actual accuracy is limited by the precision of the timecode and the latencies of the serial interface and operating system.</p>
+               <p>If the Operating System supports the PPSAPI, RFC-2783, it will be used.<br>&nbsp;</p>
+               <p>The various GPS sentences that this driver recognises look like this:<br>
+                       (others quietly ignored)</p>
+               <pre><tt>$GPRMC,POS_UTC,POS_STAT,LAT,LAT_REF,LON,LON_REF,SPD,HDG,DATE,MAG_VAR,MAG_REF*CC&lt;cr&gt;&lt;lf&gt;
+$GPGLL,LAT,LAT_REF,LONG,LONG_REF,POS_UTC,POS_STAT*CC&lt;cr&gt;&lt;lf&gt;
+$GPGGA,POS_UTC,LAT,LAT_REF,LONG,LONG_REF,FIX_MODE,SAT_USED,HDOP,ALT,ALT_UNIT,GEO,G_UNIT,D_AGE,D_REF*CC&lt;cr&gt;&lt;lf&gt;
+
+&nbsp; POS_UTC&nbsp; - UTC of position. Hours, minutes and seconds [fraction (opt.)]. (hhmmss[.fff])
+&nbsp; POS_STAT - Position status. (A = Data valid, V = Data invalid)
+&nbsp; LAT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Latitude (llll.ll)
+&nbsp; LAT_REF&nbsp; - Latitude direction. (N = North, S = South)
+&nbsp; LON&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Longitude (yyyyy.yy)
+&nbsp; LON_REF&nbsp; - Longitude direction (E = East, W = West)
+&nbsp; SPD&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Speed over ground. (knots) (x.x)
+&nbsp; HDG&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Heading/track made good (degrees True) (x.x)
+&nbsp; DATE&nbsp;&nbsp;&nbsp;&nbsp; - Date (ddmmyy)
+&nbsp; MAG_VAR&nbsp; - Magnetic variation (degrees) (x.x)
+&nbsp; MAG_REF&nbsp; - Magnetic variation (E = East, W = West)
+&nbsp; FIX_MODE - Position Fix Mode ( 0 = Invalid, &gt;0 = Valid)
+&nbsp; SAT_USED - Number Satellites used in solution
+&nbsp; HDOP&nbsp;&nbsp;&nbsp;&nbsp; - Horizontal Dilution of Precision
+&nbsp; ALT&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Antenna Altitude
+&nbsp; ALT_UNIT - Altitude Units (Metres/Feet)
+&nbsp; GEO&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Geoid/Elipsoid separation
+&nbsp; G_UNIT&nbsp;&nbsp; - Geoid units (M/F)
+&nbsp; D_AGE&nbsp;&nbsp;&nbsp; - Age of last DGPS Fix
+&nbsp; D_REF&nbsp;&nbsp;&nbsp; - Reference ID of DGPS station
+&nbsp; CC&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; - Checksum (optional)
+&nbsp; &lt;cr&gt;&lt;lf&gt; - Sentence terminator.</tt></pre>
+               Alternate GPS sentences (other than <tt>$GPRMC</tt> - the default) may be enabled by setting the relevent bits of 'mode' in the server configuration line<br>&nbsp;* server 127.127.20.x mode X<br>&nbsp;&nbsp;&nbsp; bit 0 - enables RMC&nbsp;&nbsp;&nbsp; ( value = 1)<br>&nbsp;&nbsp;&nbsp; bit 1 - enables GGA&nbsp;&nbsp;&nbsp; ( value = 2)<br>&nbsp;&nbsp;&nbsp; bit 2 - enables GLL&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ( value = 4)<br>
+               multiple sentences may be selected<br>
+               <p>The driver will send a <tt>$PMOTG,RMC,0000*1D&lt;cr&gt;&lt;lf&gt;</tt> message each time a <tt>$GPRMC</tt> string is needed. This is not needed on most GPS receivers because they automatically send the <tt>$GPRMC</tt> string every second and will only work on GPS receivers that understand the <tt>$PMOTG</tt> string. Others will just ignore it.</p>
+               <h4>Setting up the Garmin GPS-25XL</h4>
+               Switch off all output with by sending it the following string.
+               <pre>&quot;$PGRMO,,2&lt;cr&gt;&lt;lf&gt;&quot;</pre>
+               <p>Now switch only $GPRMC on by sending it the following string.</p>
+               <pre>&quot;$PGRMO,GPRMC,1&lt;cr&gt;&lt;lf&gt;&quot;</pre>
+               <p>On some systems the PPS signal isn't switched on by default. It can be switched on by sending the following string.</p>
+               <pre>&quot;$PGRMC,,,,,,,,,,,,2&lt;cr&gt;&lt;lf&gt;&quot;</pre>
+               <h4>Monitor Data</h4>
+               <p>The GPS sentence(s) that is used is written to the clockstats file.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>GPS</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Specifies the PPS signal on-time edge: 0 for assert (default), 1 for clear.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Controls the kernel PPS discipline: 0 for disable (default), 1 for enable.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Not used by this driver.
+               </dl>
+               <p>Additional Information</p>
+               <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver22.html b/html/drivers/driver22.html
new file mode 100644 (file)
index 0000000..e1ed132
--- /dev/null
@@ -0,0 +1,60 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>PPS Clock Discipline</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>PPS Clock Discipline</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.22.<i>u</i><br>
+                       Reference ID: <tt>PPS</tt><br>
+                       Driver ID: <tt>PPS</tt><br>
+                       Serial or Parallel Port: <tt>/dev/pps<i>u</i></tt><br>
+                       Requires: PPSAPI interface</p>
+               <p>Note: This driver supersedes an older one of the same name. The older driver operated with several somewhat archaic signal interface devices, required intricate configuration and was poorly documented. This driver operates only with the PPSAPI interface proposed as an IETF standard. Note also that the <tt>pps</tt> configuration command has been obsoleted by this driver.</p>
+               <h4>Description</h4>
+               <p>This driver furnishes an interface for the pulse-per-second (PPS) signal produced by a cesium clock, radio clock or related devices. It can be used to augment the serial timecode generated by a GPS receiver, for example. It can be used to remove accumulated jitter and re-time a secondary server when synchronized to a primary server over a congested, wide-area network and before redistributing the time to local clients. The driver includes extensive signal sanity checks and grooming algorithms. A range gate and frequency discriminator reject noise and signals with incorrect frequency. A multiple-stage median filter rejects jitter due to hardware interrupt and operating system latencies. A trimmed-mean algorithm determines the best time samples. With typical workstations and processing loads, the incidental jitter can be reduced to a few microseconds.</p>
+               <p>While this driver can discipline the time and frequency relative to the PPS source, it cannot number the seconds. For this purpose an auxiliary source is required, ordinarily a radio clock operated as a primary reference (stratum 1) source; however, another NTP time server can be used as well. For this purpose, the auxiliary source should be specified as the prefer peer, as described in the <a href="../prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a> page.</p>
+               <p>The driver requires the PPSAPI interface<sup>1</sup>, which is a proposed IETF standard. The interface consists of the <tt>timepps.h</tt> header file and associated kernel support. Support for this interface is included in current versions of Solaris, FreeBSD and Linux and proprietary versions of Tru64 (Alpha) and SunOS. See the <a href="../pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page for further information.</p>
+               <p>The PPS source can be connected via a serial or parallel port, depending on the hardware and operating system. A serial port can be dedicated to the PPS source or shared with another device; however, if dedicated the data leads should not be connected, as noise or unexpected signals can cause <tt>ntpd</tt> to exit.</p>
+               <p>A radio clock is usually connected via a serial port and the PPS source connected via a level converter to the data carrier detect (DCD) pin (DB-9 pin 1, DB-25 pin 8) of the same connector. In some systems where a parallel port and driver are available, the PPS signal can be connected directly to the ACK pin (pin 10) of the connector. Whether the PPS signal is connected via a dedicated port or shared with another device, the driver opens the device <tt>/dev/pps%d</tt>, where <tt>%d</tt> is the unit number. As with other drivers, links can be used to redirect the logical name to the actual physical device.</p>
+               <p>The driver normally operates like any other driver and uses the same mitigation algorithms and PLL/FLL clock discipline incorporated in the daemon. If kernel PLL/FLL support is available, the kernel PLL/FLL clock discipline can be used instead. The default behavior is not to use the kernel PPS clock discipline, even if present. This driver incorporates a good deal of signal processing to reduce jitter using the median filter and trimmed average algorithms in the driver interface. As the result, performance with minpoll and maxpoll configured at the minimum 4 (16s) is generally better than the kernel PPS discipline. However, fudge flag 3 can be used to enable the kernel PPS discipline if necessary.</p>
+               <p>Note that the PPS source is considered valid only if the auxiliary source is the prefer peer, is reachable and is selectable to discipline the system clock. By default the stratum assigned to the PPS source is automatically determined. If the auxiliary source is unreachable or inoperative, the stratum is set to 16. Otherwise it is set to the stratum specified by the <tt>fudge stratum</tt> command, if present, or the auxiliary source stratum if not present. Please note the temptation to masquerade as a primary server by forcing the stratum to zero is decidedly dangerous, as it invites timing loops.</p>
+               <p>The <tt>mode</tt> keyword of the <tt>server</tt> command can be used to set the PPSAPI mode bits which determine the capture edge and echo options. See the <tt>/usr/include/sys/timepps.h</tt> header file for the bit definitions, which must be converted to their decimal equivalents. This overrides the fudge <tt>flag2</tt> option.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>PPS</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Specifies the PPS signal on-time edge: 0 for assert (default), 1 for clear.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Controls the kernel PPS discipline: 0 for disable (default), 1 for enable.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Not used by this driver.
+               </dl>
+               <h4>Additional Information</h4>
+               <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+               <p>Reference</p>
+               <ol>
+                       <li>Mogul, J., D. Mills, J. Brittenson, J. Stone and U. Windl. Pulse-per-second API for Unix-like operating systems, version 1. Request for Comments RFC-2783, Internet Engineering Task Force, March 2000, 31 pp.
+               </ol>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver26.html b/html/drivers/driver26.html
new file mode 100644 (file)
index 0000000..f840a03
--- /dev/null
@@ -0,0 +1,53 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+        <title>Hewlett Packard 58503A GPS Receiver and HP Z3801A</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Hewlett Packard 58503A GPS Receiver and HP Z3801A</h3>
+        <hr>
+        <h4>Synopsis</h4>
+        <p>Address: 127.127.26.<i>u</i><br>
+            Reference ID: <tt>GPS</tt><br>
+            Driver ID: <tt>GPS_HP</tt><br>
+            Serial Port: <tt>/dev/hpgps<i>u</i></tt>; 9600 baud, 8-bits, no parity, 19200 baud 7-bits, odd parity for the HP Z3801A</p>
+        <h4>Description</h4>
+        <p>This driver supports the HP 58503A Time and Frequency Reference Receiver and HP Z3801A GPS Receiver. They use HP SmartClock (TM) to implement an Enhanced GPS receiver. The receiver accuracy when locked to GPS in normal operation is better than 1 usec. The accuracy when operating in holdover is typically better than 10 us per day. It receiver should be operated with factory default settings. Initial driver operation: expects the receiver to be already locked to GPS, configured and able to output timecode format 2 messages.</p>
+        <p>The driver uses the poll sequence <tt>:PTIME:TCODE?</tt> to get a response from the receiver. The receiver responds with a timecode string of ASCII printing characters, followed by a &lt;cr&gt;&lt;lf&gt;, followed by a prompt string issued by the receiver, in the following format:</p>
+        <pre>T#yyyymmddhhmmssMFLRVcc&lt;cr&gt;&lt;lf&gt;scpi &gt;</pre>
+        The driver processes the response at the &lt;cr&gt; and &lt;lf&gt;, so what the driver sees is the prompt from the previous poll, followed by this timecode. The prompt from the current poll is (usually) left unread until the next poll. So (except on the very first poll) the driver sees this:
+        <pre>scpi &gt;T#yyyymmddhhmmssMFLRVcc&lt;cr&gt;&lt;lf&gt;</pre>
+        <p>The T is the on-time character, at 980 msec. before the next 1PPS edge. The # is the timecode format type. We look for format 2. Without any of the CLK or PPS stuff, then, the receiver buffer timestamp at the &lt;cr&gt; is 24 characters later, which is about 25 msec. at 9600 bps, so the first approximation for fudge time1 is nominally -0.955 seconds. This number probably needs adjusting for each machine / OS type, so far: -0.955000 on an HP 9000 Model 712/80 HP-UX 9.05 -0.953175 on an HP 9000 Model 370 HP-UX 9.10</p>
+This driver will probably work with the 58503B and 59551A if they are setup appropriately.<P>
+To use an HP Z3801A, specify <tt>mode 1</tt> on the server config line to setup the right line paramters.<P>
+The timekeeping portion of HP's business has been sold to <a href="http://www.symmetricom.com/">Symmetricom</a>.<P>
+        <h4>Fudge Factors</h4>
+        <dl>
+            <dt><tt>time1 <i>time</i></tt>
+            <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+            <dt><tt>time2 <i>time</i></tt>
+            <dd>Not used by this driver.
+            <dt><tt>stratum <i>number</i></tt>
+            <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+            <dt><tt>refid <i>string</i></tt>
+            <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>GPS</tt>.
+            <dt><tt>flag1 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag2 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag3 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag4 0 | 1</tt>
+            <dd>Not used by this driver.
+        </dl>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
diff --git a/html/drivers/driver27.html b/html/drivers/driver27.html
new file mode 100644 (file)
index 0000000..8c2633c
--- /dev/null
@@ -0,0 +1,247 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+               <title>Arcron MSF Receiver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Arcron MSF Receiver</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.27.<i>u</i><br>
+                       Reference ID: <tt>MSFa</tt> / <tt>MSF</tt> / <tt>DCF</tt> / <tt>WWVB</tt><br>
+                       Driver ID: <tt>MSF_ARCRON</tt><br>
+                       Serial Port: <tt>/dev/arc<i>u</i></tt>; 300 baud, 8-bits, 2-stop, no parity<br>
+                       Features: <tt>tty_clk</tt></p>
+               <h4>Description</h4>
+               <p>This driver supports the Arcron MSF, DCF and WWVB receivers. The clock reports its ID as &quot;<tt>MSFa</tt>'', &quot;<tt>MSF</tt>'', &quot;<tt>DCF</tt>'' or &quot;<tt>WWVB</tt>'' to indicate the time source.</p>
+               <p>This documentation describes v1.3 (2003/2/21) of the source and has been tested against ntpd 4.1.0 on linux x86. Changes from v1.1 and v1.2 include patches to work with the new ntp-4 code, clock support for DCF and WWVB configurable via mode flag, an option to ignore resync request (for those of us at the fringes of the WWVB signal, for instance), averaging of the signal quality poll and several bug fixes, code cleanup and standardizations. In all other respects, the driver works as per v1.1 if a mode is not specified.</p>
+               <p>To use the alternate modes, the mode flag must be specified. If the mode flag is 0, or unspecified, the original MSF version is assumed. This should assure backwards compatibility and should not break existing setups.</p>
+               <p>The previous documentation described version V1.1 (1997/06/23) of the source and had been tested (amongst others) against ntpd3-5.90 on Solaris-1 (SunOS 4.1.3_U1 on an SS1 serving as a router and firewall) and against ntpd3-5.90 on Solaris-2.5 (on a SS1+ and TurboSPARC 170MHz). That code will claimed increased stability, reduced jitter and more efficiency (fewer context switches) with the <tt>tty_clk</tt> discipline/STREAMS module installed, but this has not been tested. For a to-do list see the comments at the start of the code.</p>
+               <p>This code has been significantly slimmed down since the V1.0 version, roughly halving the memory footprint of its code and data.</p>
+               <p>This driver is designed to allow the unit to run from batteries as designed, for something approaching the 2.5 years expected in the usual stand-alone mode, but no battery-life measurements have been taken.</p>
+               <p>Much of this code is originally from the other refclock driver files with thanks. The code was originally made to work with the clock by <a href="mailto:derek@toybox.demon.co.uk">Derek Mulcahy</a>, with modifications by <a href="mailto:d@hd.org">Damon Hart-Davis</a>. Thanks also to <a href="mailto:lyndond@sentinet.co.uk">Lyndon David</a> for some of the specifications of the clock. <a href="mailto:palfille@partners.org">Paul Alfille</a> added support for the WWVB clock. <a href="mailto:cprice@cs-home.com">Christopher Price</a> added enhanced support for the MSF, DCF and WWVB clocks.</p>
+               <p>There is support for a Tcl/Tk monitor written by Derek Mulcahy that examines the output stats; see the <a href="http://www2.exnet.com/NTP/ARC/ARC.html">ARC Rugby MSF Receiver</a> page for more details and the code. Information on the WWVB version is available from <a href="http://www.arctime.com">Atomic Time</a> as their <a href="http://www.atomictime.com/Product17.html">Atomic Time PC</a>.</p>
+               <p>Look at the notes at the start of the code for further information; some of the more important details follow.</p>
+               <p>The driver interrogates the clock at each poll (ie every 64s by default) for a timestamp. The clock responds at the start of the next second (with the start bit of the first byte being on-time). In the default or original MSF mode, the time is in `local' format, including the daylight savings adjustment when it is in effect. The driver code converts the time back to UTC. In modes 1-3 the driver can be configured for UTC or local time depending on the setting of flag1.</p>
+               <p>The clock claims to be accurate to within about 20ms of the broadcast time, and given the low data transmission speed from clock to host, and the fact that the clock is not in continuous sync with MSF, it seems sensible to set the `precision' of this clock to -5 or -4, -4 being used in this code, which builds in a reported dispersion of over 63ms (ie says ``This clock is not very good.''). You can improve the reported precision to -4 (and thus reduce the base dispersion to about 31ms) by setting the fudge <tt>flag3</tt> to <tt>1</tt>.</p>
+               <p>Even a busy and slow IP link can yield lower dispersions than this from polls of primary time servers on the Internet, which reinforces the idea that this clock should be used as a backup in case of problems with such an IP link, or in the unfortunate event of failure of more accurate sources such as GPS.</p>
+               <p>By default this clock reports itself to be at stratum 2 rather than the usual stratum 0 for a refclock, because it is not really suited to be used as other than a backup source. The stratum reported can be changed with the <tt>stratum</tt> directive to be whatever you like. After careful monitoring of your clock, and appropriate choice of the <tt>time1</tt> fudge factor to remove systematic errors in the clock's reported time, you might fudge the clock to stratum 1 to allow a stratum-2 secondary server to sync to it.</p>
+               <p>In default mode, the driver code arranges to resync the clock to MSF at intervals of a little less than an hour (deliberately avoiding the same time each hour to avoid any systematic problems with the signal or host). Whilst resyncing, the driver supplements the normal polls for time from the clock with polls for the reception signal quality reported by the clock. If the signal quality is too low (0--2 out of a range of 0--5), we chose not to trust the clock until the next resync (which we bring forward by about half an hour). If we don't catch the resync, and so don't know the signal quality, we do trust the clock (because this would generally be when the signal is very good and a resync happens quickly), but we still bring the next resync forward and reduce the reported precision (and thus increase reported dispersion).</p>
+               <p>If we force resyncs to MSF too often we will needlessly exhaust the batteries the unit runs from. During clock resync this driver tries to take enough time samples to avoid <tt>ntpd</tt> losing sync in case this clock is the current peer. By default the clock would only resync to MSF about once per day, which would almost certainly not be acceptable for NTP purposes.</p>
+               <p>The driver does not force an immediate resync of the clock to MSF when it starts up to avoid excessive battery drain in case <tt>ntpd</tt> is going to be repeatedly restarted for any reason, and also to allow enough samples of the clock to be taken for <tt>ntpd</tt> to sync immediately to this clock (and not remain unsynchronised or to sync briefly to another configured peer, only to hop back in a few poll times, causing unnecessary disturbance). This behaviour should not cause problems because the driver will not accept the timestamps from the clock if the status flag delivered with the time code indicates that the last resync attempt was unsuccessful, so the initial timestamps will be close to reality, even if with up to a day's clock drift in the worst case (the clock by default resyncs to MSF once per day).</p>
+               <p>When alternate modes 1-3 are selected, the driver can be configured to ignore the resync requests by setting <tt>flag2</tt> to 1. This allows clocks at the fringe of the signal to resync at night when signals are stronger.</p>
+               <p>The clock has a peculiar RS232 arrangement where the transmit lines are powered from the receive lines, presumably to minimise battery drain. This arrangement has two consequences:</p>
+               <ul>
+                       <li>Your RS232 interface must drive both +ve and -ve
+                       <li>You must (in theory) wait for an echo and a further 10ms between characters
+               </ul>
+               <p>This driver, running on standard Sun and x86 hardware, seems to work fine; note the use of the <tt>send_slow()</tt> routine to queue up command characters to be sent once every two seconds.</p>
+               <p>Three commands are sent to the clock by this driver. Each command consists of a single letter (of which only the bottom four bits are significant), followed by a CR (ASCII 13). Each character sent to the clock should be followed by a delay to allow the unit to echo the character, and then by a further 10ms. Following the echo of the command string, there may be a response (ie in the case of the <tt>g</tt> and <tt>o</tt> commands below), which in the case of the <tt>o</tt> command may be delayed by up to 1 second so as the start bit of the first byte of the response can arrive on time. The commands and their responses are:</p>
+               <dl>
+                       <dt><tt>g</tt> CR
+                       <dd>Request for signal quality. Answer only valid during (late part of) resync to MSF signal. The response consists of two characters as follows:
+                               <ol>
+                                       <dl compact>
+                                               <dt>bit 7
+                                               <dd>parity
+                                               <dt>bit 6
+                                               <dd>always 0
+                                               <dt>bit 5
+                                               <dd>always 1
+                                               <dt>bit 4
+                                               <dd>always 1
+                                               <dt>bit 3
+                                               <dd>always 0
+                                               <dt>bit 2
+                                               <dd>always 0
+                                               <dt>bit 1
+                                               <dd>always 1
+                                               <dt>bit 0
+                                               <dd>= 0 if no reception attempt at the moment, = 1 if reception attempt (ie resync) in progress
+                                       </dl>
+                                       <dl compact>
+                                               <dt>bit 7
+                                               <dd>parity
+                                               <dt>bit 6
+                                               <dd>always 0
+                                               <dt>bit 5
+                                               <dd>always 1
+                                               <dt>bit 4
+                                               <dd>always 1
+                                               <dt>bit 3
+                                               <dd>always 0
+                                               <dt>bit 2--0
+                                               <dd>reception signal quality in the range 0--5 (very poor to very good); if in the range 0--2 no successful reception is to be expected. The reported value drops to zero when not resyncing, ie when first returned byte is not `3'.
+                                       </dl>
+                               </ol>
+                       <dt><tt>h</tt> CR
+                       <dd>Request to resync to signal. Can take up from about 30s to 360s. Drains batteries so should not be used excessively. After this the clock time and date should be correct and the phase within 20ms of time as transmitted from the source signal (remember to allow for propagation time). By default the clock resyncs once per day in the late evening/early morning (presumably to catch transitions to/from daylight saving time quickly). This driver code, by default, resyncs at least once per hour to minimise clock wander.
+                       <dt><tt>o</tt> CR
+                       <dd>Request timestamp. Start bit of first byte of response is on-time, so may be delayed up to 1 second. Note that the driver will convert time to GMT, if required. The response data is as follows:
+                               <ol>
+                                       <li>hours tens (hours range from 00 to 23)
+                                       <li>hours units
+                                       <li>minutes tens (minutes range from 00 to 59)
+                                       <li>minutes units
+                                       <li>seconds tens (seconds presumed to range from 00 to 60 to allow for leap second)
+                                       <li>seconds units
+                                       <li>day of week 1 (Monday) to 7 (Sunday)
+                                       <li>day of month tens (day ranges from 01 to 31)
+                                       <li>day of month units
+                                       <li>month tens (months range from 01 to 12)
+                                       <li>month units
+                                       <li>year tens (years range from 00 to 99)
+                                       <li>year units
+                                       <li>BST/UTC status (Ignored in WWVB version)
+                                               <dl compact>
+                                                       <dt>bit 7
+                                                       <dd>parity
+                                                       <dt>bit 6
+                                                       <dd>always 0
+                                                       <dt>bit 5
+                                                       <dd>always 1
+                                                       <dt>bit 4
+                                                       <dd>always 1
+                                                       <dt>bit 3
+                                                       <dd>(MSF) always 0<br>
+                                                               (WWVB) Leap year indicator bit<br>
+                                                               0 = non-leap year<br>
+                                                               1 = leap year
+                                                       <dt>bit 2
+                                                       <dd>= (MSF) 1 if UTC is in effect (reverse of bit 1)<br>
+                                                               (WWVB) Leap second warning bit
+                                                       <dt>bit 1
+                                                       <dd>= (MSF)1 if BST is in effect (reverse of bit 2)<br>
+                                                               = (WWVB) 0 if ST is in effect, 1 if DST is in effect, 1 if transition from ST with bit 0 is set to 0
+                                                       <dt>bit 0
+                                                       <dd>= (MSF)1 if BST/UTC change pending<br>
+                                                               = (WWVB) 0 if ST is in effect, 1 if DST is in effect, 0 if transition from DST with bit 1 is set to 0
+                                               </dl>
+                                       <li>clock status
+                                               <dl compact>
+                                                       <dt>bit 7
+                                                       <dd>parity
+                                                       <dt>bit 6
+                                                       <dd>always 0
+                                                       <dt>bit 5
+                                                       <dd>always 1
+                                                       <dt>bit 4
+                                                       <dd>always 1
+                                                       <dt>bit 3
+                                                       <dd>= 1 if low battery is detected
+                                                       <dt>bit 2
+                                                       <dd>= 1 if last resync failed (though officially undefined for the MSF clock, officially defined for WWVB)
+                                                       <dt>bit 1
+                                                       <dd>= 1 if at least one reception attempt was successful<br>
+                                                               (MSF) since 0230<br>
+                                                               (DCF) since 0300<br>
+                                                               (WWVB) resets if not successful between 0300-0400
+                                                       <dt>bit 0
+                                                       <dd>= 1 if the clock has valid time---reset to zero when clock is reset (eg at power-up), and set to 1 after first successful resync attempt.
+                                               </dl>
+                               </ol>
+                               <p>The driver only accepts time from the clock if the bottom three bits of the status byte are <tt>011</tt> or <tt>flag2</tt> is set to 1 to ignore resync requests. For the MSF clock, if the UK parliament decides to move us to +0100/+0200 time as opposed to the current +0000/+0100 time, it is not clear what effect that will have on the time broadcast by MSF, and therefore on this driver's usefulness.</p>
+               </dl>
+               <p>A typical <tt>ntp.conf</tt> configuration file for this driver might be:</p>
+               <pre># hostname(n) means we expect (n) to be the stratum at which hostname runs.
+
+#------------------------------------------------------------------------------
+# SYNCHRONISATION PARTNERS
+# ========================
+
+# Default configuration (Original MSF mode)s...
+server 127.127.27.0 mode 333 # ARCRON MSF radio clock
+# Fudge stratum and other features as required.
+# ADJUST time1 VALUE FOR YOUR HOST, CLOCK AND LOCATION!
+fudge 127.127.27.0 stratum 1 time1 0.016 flag3 1
+# WWVB users should change that line to:
+server 127.127.27.0 mode 3 # ARCRON WWVB radio clock
+fudge 127.127.27.0 stratum 1 time1 0.030 flag1 1 flag3 1
+
+peer 11.22.33.9 # tick(1--2).
+peer 11.22.33.4 # tock(3), boot/NFS server.
+
+# This shouldn't get swept away unless left untouched for a long time.
+driftfile /var/tmp/ntp.drift
+
+#------------------------------------------------------------------------------
+# RESTRICTIONS
+# ============
+
+# By default, don't trust and don't allow modifications.&nbsp; Ignore in fact.
+restrict default ignore notrust nomodify
+
+# Allow others in our subnet to check us out...
+restrict 11.22.33.0 mask 255.255.255.0 nomodify notrust
+
+# Trust our peers for time.&nbsp; Don't trust others in case they are insane.
+restrict 127.127.27.0 nomodify
+restrict 11.22.33.4 nomodify
+restrict 11.22.33.9 nomodify
+
+# Allow anything from the local host.
+restrict 127.0.0.1</pre>
+               There are a few <tt>#define</tt>s in the code that you might wish to play with:
+               <dl>
+                       <dt><tt>ARCRON_KEEN</tt>
+                       <dd>With this defined, the code is relatively trusting of the clock, and assumes that you will have the clock as one of a few time sources, so will bend over backwards to use the time from the clock when available and avoid <tt>ntpd</tt> dropping sync from the clock where possible. You may wish to undefine this, especially if you have better sources of time or your reception is ropey. However, there are many checks built in even with this flag defined.
+                       <dt><tt>ARCRON_MULTIPLE_SAMPLES</tt>
+                       <dd>When is defined, we regard each character in the returned timecode as at a known delay from the start of the second, and use the smallest (most negative) offset implied by any such character, ie with the smallest kernel-induced display, and use that. This helps to reduce jitter and spikes.
+                       <dt><tt>ARCRON_LEAPSECOND_KEEN</tt>
+                       <dd>When is defined, we try to do a resync to MSF as soon as possible in the first hour of the morning of the first day of the first and seventh months, ie just after a leap-second insertion or deletion would happen if it is going to. This should help compensate for the fact that this clock does not continuously sample MSF, which compounds the fact that MSF itself gives no warning of an impending leap-second event. This code did not seem functional at the leap-second insertion of 30th June 1997 so is by default disabled.
+                       <dt><tt>PRECISION</tt>
+                       <dd>Currently set to <tt>-4</tt>, but you may wish to set it to <tt>-5</tt> if you are more conservative, or to <tt>-6</tt> if you have particularly good experience with the clock and you live on the edge. Note that the <tt>flag3</tt> fudge value will improve the reported dispersion one notch if clock signal quality is known good. So maybe just leave this alone.
+               </dl>
+               <h4>Monitor Data</h4>
+               <p>Each timecode is written to the <tt>clockstats</tt> file with a signal quality value appended (`0'--`5' as reported by the clock, or `6' for unknown).</p>
+               <p>Each resync and result (plus gaining or losing MSF sync) is logged to the system log at level <tt>LOG_NOTICE</tt>; note that each resync drains the unit's batteries, so the syslog entry seems justified.</p>
+               <p>Syslog entries are of the form:</p>
+               <pre>May 10 10:15:24 oolong ntpd[615]: ARCRON: unit 0: sending resync command
+May 10 10:17:32 oolong ntpd[615]: ARCRON: sync finished, signal quality 5: OK, will use clock
+May 10 11:13:01 oolong ntpd[615]: ARCRON: unit 0: sending resync command
+May 10 11:14:06 oolong ntpd[615]: ARCRON: sync finished, signal quality -1: UNKNOWN, will use clock anyway
+May 10 11:41:49 oolong ntpd[615]: ARCRON: unit 0: sending resync command
+May 10 11:43:57 oolong ntpd[615]: ARCRON: sync finished, signal quality 5: OK, will use clock
+May 10 12:39:26 oolong ntpd[615]: ARCRON: unit 0: sending resync command
+May 10 12:41:34 oolong ntpd[615]: ARCRON: sync finished, signal quality 3: OK, will use clock</pre>
+               <h4>Fudge Factors</h4>
+               <p></p>
+               <dl>
+                       <dt><tt>mode 0 | 1 | 2 | 3</tt>
+                       <dd>Specifies the clock hardware model. This parameter is optional, it defaults to the original mode of operation.
+                       <dd>Supported modes of operation:
+                       <dd>0 - Default, Original MSF
+                       <dd>1 - Updated MSF
+                       <dd>2 - New DCF77
+                       <dd>3 - New WWVB
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0. On a Sun SparcStation 1 running SunOS 4.1.3_U1, with the receiver in London, a value of 0.020 (20ms) seems to be appropriate.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not currently used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 2. It is suggested that the clock be not be fudged higher than stratum 1 so that it is used a backup time source rather than a primary when more accurate sources are available.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>MSFa</tt>. When used in modes 1-3, the driver will report either <tt>MSF</tt>, <tt>DCF</tt>, or <tt>WWVB</tt> respectively.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>(Modes 1-3) If set to 0 (the default), the clock is set to UTC time. If set to 1, the clock is set to localtime.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>(Modes 1-3) If set to 0 (the default), the clock will be forced to resync approximately every hour. If set to 1, the clock will resync per normal operations (approximately midnight).
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>If set to 1, better precision is reported (and thus lower dispersion) while clock's received signal quality is known to be good.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Not used by this driver.
+               </dl>
+               <h4>Additional Information</h4>
+               <p><a href="../refclock.html">Reference Clock Drivers</a><br>
+                       <a href="http://www2.exnet.com/NTP/ARC/ARC.html">ARC Rugby MSF Receiver</a></p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver28.html b/html/drivers/driver28.html
new file mode 100644 (file)
index 0000000..244de1a
--- /dev/null
@@ -0,0 +1,76 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+        <title>Shared memoy Driver</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Shared Memory Driver</h3>
+        <hr>
+        <h4>Synopsis</h4>
+        <p>Address: 127.127.28.<i>u</i><br>
+            Reference ID: <tt>SHM</tt><br>
+            Driver ID: <tt>SHM</tt></p>
+        <h4>Description</h4>
+        <p>This driver receives its reference clock info from a shared memory-segment. The shared memory-segment is created with owner-only access for unit 0 and 1, and world access for unit 2 and 3</p>
+        <h4>Structure of shared memory-segment</h4>
+        <pre>struct shmTime {
+&nbsp; int&nbsp;&nbsp;&nbsp; mode; /* 0 - if valid set
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; use values,&nbsp;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clear valid
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; * 1 - if valid set&nbsp;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; if count before and after read of&nbsp;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; values is equal,
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; use values&nbsp;
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; *&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; clear valid
+&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; */
+&nbsp; int&nbsp;&nbsp;&nbsp; count;
+&nbsp; time_t clockTimeStampSec;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; /* external clock */
+&nbsp; int&nbsp;&nbsp;&nbsp; clockTimeStampUSec;&nbsp;&nbsp;&nbsp;&nbsp; /* external clock */
+&nbsp; time_t receiveTimeStampSec;&nbsp;&nbsp;&nbsp; /* internal clock, when external value was received */
+&nbsp; int&nbsp;&nbsp;&nbsp; receiveTimeStampUSec;&nbsp;&nbsp; /* internal clock, when external value was received */
+&nbsp; int&nbsp;&nbsp;&nbsp; leap;
+&nbsp; int&nbsp;&nbsp;&nbsp; precision;
+&nbsp; int&nbsp;&nbsp;&nbsp; nsamples;
+&nbsp; int&nbsp;&nbsp;&nbsp; valid;
+&nbsp; int&nbsp;&nbsp;&nbsp; dummy[10];&nbsp;
+};</pre>
+        <h4>Operation mode=0</h4>
+        <p>When the poll-method of the driver is called, the valid-flag of the shared memory-segment is checked:</p>
+        <p>If set, the values in the record (clockTimeStampSec, clockTimeStampUSec, receiveTimeStampSec, receiveTimeStampUSec, leap, precision) are passed to ntp, and the valid-flag is cleared.</p>
+        <p>If not set, a timeout is reported to ntp, nothing else happend</p>
+        <h4>Operation mode=1</h4>
+        <p>When the poll-method of the driver is called, the valid-flag of the shared memory-segment is checked:</p>
+        <p>If set, the count-field of the record is remembered, and the values in the record (clockTimeStampSec, clockTimeStampUSec, receiveTimeStampSec, receiveTimeStampUSec, leap, precision) are read. Then, the remembered count is compared to the count now in the record. If both are equal, the values read from the record are passed to ntp. If they differ, another process has modified the record while it was read out (was not able to produce this case), and failure is reported to ntp. The valid flag is cleared.</p>
+        <p>If not set, a timeout is reported to ntp, nothing else happend</p>
+        <h4>Fudge Factors</h4>
+        <dl>
+            <dt><tt>time1 <i>time</i></tt>
+            <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+            <dt><tt>time2 <i>time</i></tt>
+            <dd>Not used by this driver.
+            <dt><tt>stratum <i>number</i></tt>
+            <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+            <dt><tt>refid <i>string</i></tt>
+            <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>SHM</tt>.
+            <dt><tt>flag1 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag2 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag3 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag4 0 | 1</tt>
+            <dd>Not used by this driver.
+            <h4>Additional Information</h4>
+            <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+        </dl>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver29.html b/html/drivers/driver29.html
new file mode 100644 (file)
index 0000000..479978f
--- /dev/null
@@ -0,0 +1,776 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <title>Trimble Palisade Receiver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
+               <h1><font size="+2">Trimble Palisade Receiver</font>
+                       <hr>
+               </h1>
+               <h2><img src="../pic/driver29.gif" alt="gif" nosave height="100" width="420"></h2>
+               <h2><font size="+1">Synopsis</font></h2>
+               <table>
+                       <tr>
+                               <td>
+                                       <div align="right">
+                                               <tt>Address:&nbsp;</tt></div>
+                               </td>
+                               <td><b>127.127.29.<i>u</i></b></td>
+                       </tr>
+                       <tr>
+                               <td>
+                                       <div align="right">
+                                               <tt>Reference ID:</tt></div>
+                               </td>
+                               <td><a name="REFID"></a><b>GPS</b></td>
+                       </tr>
+                       <tr>
+                               <td>
+                                       <div align="right">
+                                               <tt>Driver ID:</tt></div>
+                               </td>
+                               <td><b>GPS_PALISADE</b></td>
+                       </tr>
+                       <tr>
+                               <td>
+                                       <div align="right">
+                                               <tt>Serial Port:</tt></div>
+                               </td>
+                               <td><b>/dev/palisade<i>u</i></b></td>
+                       </tr>
+                       <tr>
+                               <td>
+                                       <div align="right">
+                                               <tt><font size="+1">Serial I/O:</font></tt></div>
+                               </td>
+                               <td><b>9600 baud, 8-bits, 1-stop, odd parity</b></td>
+                       </tr>
+               </table>
+               <h2><font size="+1">Description</font></h2>
+               The <b>refclock_palisade</b> driver supports <a href="http://www.trimble.com/products/ntp">Trimble Navigation's Palisade Smart Antenna GPS receiver</a>.<br>
+               Additional software and information about the Palisade GPS is available from: <a href="http://www.trimble.com/oem/ntp">http://www.trimble.com/oem/ntp</a>.<br>
+               Latest NTP driver source, executables and documentation is maintained at: <a href="ftp://ftp.trimble.com/pub/ntp">ftp://ftp.trimble.com/pub/ntp</a>
+               <p>This documentation describes version 7.12 of the GPS Firmware and version 2.46 (July 15, 1999) and later, of the driver source.<br>&nbsp;</p>
+               <h2><font size="+1">Operating System Compatibility</font></h2>
+               The Palisade driver has been tested on the following software and hardware platforms:<br>&nbsp;
+               <center>
+                       <table>
+                               <tr>
+                                       <td valign="CENTER" width="23%">Platform</td>
+                                       <td valign="CENTER">Operating System</td>
+                                       <td>NTP Sources</td>
+                                       <td>Accuracy</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="23%">i386 (PC)&nbsp;</td>
+                                       <td valign="CENTER">Linux</td>
+                                       <td>NTP Distribution</td>
+                                       <td>10 us</td>
+                               </tr>
+                               <tr>
+                                       <td>i386 (PC)&nbsp;</td>
+                                       <td>Windows NT</td>
+                                       <td><a href="ftp://ftp.trimble.com/pub/ntp">ftp://ftp.trimble.com/pub/ntp</a></td>
+                                       <td>1 ms</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="23%">SUN</td>
+                                       <td valign="CENTER">Solaris 2.x</td>
+                                       <td>NTP Distribution</td>
+                                       <td>50 us</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="23%">Hewlett-Packard</td>
+                                       <td valign="CENTER">HPUX 9, 10, 11</td>
+                                       <td><a href="http://us-support.external.hp.com">http://us-support.external.hp.com</a></td>
+                                       <td>50 us</td>
+                               </tr>
+                               <tr>
+                                       <td>Various</td>
+                                       <td>Free BSD</td>
+                                       <td>NTP Distribution</td>
+                                       <td>20 us</td>
+                               </tr>
+                       </table>
+               </center>
+               <h2><font size="+1">GPS Receiver</font></h2>
+               The Palisade GPS receiver is an 8-channel smart antenna, housing the GPS receiver, antenna and interface in a single unit, and is designed for rooftop deployment in static timing applications.
+               <p>Palisade generates a PPS synchronized to UTC within +/- 100 ns.&nbsp; The Palisade's external event input with 40 nanosecond resolution is utilized by the Palisade NTP driver for asynchronous precision time transfer.</p>
+               <p>No user initialization of the receiver is required. This driver is compatible with the following versions of Palisade:<br>&nbsp;</p>
+               <center>
+                       <table>
+                               <tr>
+                                       <td valign="CENTER">
+                                               <center>
+                                                       Version</center>
+                                       </td>
+                                       <td valign="TOP">
+                                               <center>
+                                                       Event Input</center>
+                                       </td>
+                                       <td valign="CENTER">
+                                               <center>
+                                                       Trimble Part Number</center>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER">
+                                               <center>
+                                                       7.02</center>
+                                       </td>
+                                       <td valign="TOP">
+                                               <center>
+                                                       No</center>
+                                       </td>
+                                       <td valign="CENTER">
+                                               <center>
+                                                       26664-00</center>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td align="CENTER" valign="CENTER">
+                                               <center>
+                                                       7.02E</center>
+                                       </td>
+                                       <td valign="TOP">
+                                               <center>
+                                                       Yes</center>
+                                       </td>
+                                       <td valign="CENTER">
+                                               <center>
+                                                       26664-10</center>
+                                       </td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER">
+                                               <center>
+                                                       7.12</center>
+                                       </td>
+                                       <td valign="TOP">
+                                               <center>
+                                                       Yes</center>
+                                       </td>
+                                       <td valign="CENTER">
+                                               <center>
+                                                       38158-00</center>
+                                       </td>
+                               </tr>
+                       </table>
+               </center>
+               <dl>
+                       <dl>
+                               Note: When using Palisade 26664-00, you must set fudge flag2 to 1 in <b>ntp.conf</b>. See <a href="#Configuration">configuration</a>.
+                       </dl>
+                       <dl>
+                               <h3><font size="+1">GPS&nbsp;<a name="Installation"></a>Installation</font></h3>
+                               A location with unobstructed view of the horizon is recommended. Palisade is designed to be securely mounted atop standard 3/4 inch threaded pipe.
+                               <p>The 12 conductor (dia. 10 mm)&nbsp; power and I/O cable must be routed from the rooftop site to the NTP server and properly strain relieved.</p>
+                               <h3><font size="+1">GPS&nbsp;<a name="Connection"></a>Connection</font></h3>
+                               The Palisade is equipped with dual (A &amp; B) RS-422 serial interfaces and a differential TTL PPS output. An RS-232 / RS-422 Interface Module is supplied with the Palisade NTP Synchronization Kit. Palisade <a href="#PortA">port A</a> must be connected to the NTP host server. Maximum antenna cable length is 500 meters. See the <a href="#Pinouts">pinouts</a> table for detailed connection Information.
+                               <p>Palisade's <a href="#PortB">port B</a> provides a TSIP (Trimble Standard Interface Protocol) interface for diagnostics, configuration, and monitoring. Port B and the PPS output are not currently used by the Palisade NTP reference clock driver.<br>&nbsp;</p>
+                       </dl>
+               </dl>
+               <h2><font size="+1">O/S Serial Port Configuration</font></h2>
+               The driver attempts to open the device <b><tt><a href="#REFID">/dev/palisade<i>u</i></a></tt></b> where <b><i>u</i></b> is the NTP refclock unit number as defined by the LSB of the refclock address.&nbsp; Valid refclock unit numbers are 0 - 3.
+               <p>The user is expected to provide a symbolic link to an available serial port device.&nbsp; This is typically performed by a command such as:</p>
+               <blockquote>
+                       <tt>ln -s /dev/ttyS0 /dev/palisade0</tt></blockquote>
+               Windows NT does not support symbolic links to device files. COM<b>x</b>: is used by the driver, based on the refclock unit number, where unit 1 corresponds to COM<b>1</b>: and unit 3 corresponds to COM3:<br>&nbsp;
+               <h2><a name="Configuration"></a><font size="+1">NTP Configuration</font></h2>
+               Palisade NTP configuration file <b><tt>&quot;ntp.conf&quot;</tt></b> with event polling:<br>
+               <tt>#------------------------------------------------------------------------------</tt><br>
+               <tt># The Primary reference</tt><br>
+               <tt>server 127.127.29.0 # Trimble Palisade GPS Refclock Unit #0</tt><br>
+               <tt>peer terrapin.csc.ncsu.edu # internet server</tt><br>
+               <tt># Drift file for expedient re-synchronization after downtime or reboot.</tt><br>
+               <tt>driftfile /etc/ntp.drift</tt><br>
+               <tt>#------------------------------------------------------------------------------</tt>
+               <p>Configuration without event polling:<br>
+                       <tt>#------------------------------------------------------------------------------</tt><br>
+                       <tt># The Primary reference</tt><br>
+                       <tt>server 127.127.29.0 # Trimble Palisade GPS (Stratum 1).</tt><br>
+                       <tt># Set packet delay</tt><br>
+                       <tt><a href="#time1">fudge 127.127.29.0 time1 0.020</a></tt><br>
+                       <tt># and set flag2 to turn off event polling.</tt><br>
+                       <tt><a href="#flag2">fudge 127.127.29.0 flag2 1</a></tt><br>
+                       <tt>#------------------------------------------------------------------------------</tt><br>&nbsp;</p>
+               <h2><a name="TimeTransfer"></a><font size="+1">Time Transfer and Polling</font></h2>
+               Time transfer to the NTP host is performed via the Palisade's comprehensive time packet output. The time packets are output once per second, and whenever an event timestamp is requested.
+               <p>The driver requests an event time stamp at the end of each polling interval, by pulsing the RTS (request to send) line on the serial port. The Palisade GPS responds with a time stamped event packet.</p>
+               <p>Time stamps are reported by the Palisade with respect to UTC time. The GPS receiver must download UTC offset information from GPS satellites. After an initial UTC download, the receiver will always start with correct UTC offset information.<br>&nbsp;</p>
+               <h2><font size="+1">Run NTP in Debugging Mode</font></h2>
+               The following procedure is recommended for installing and testing a Palisade NTP driver:
+               <ol>
+                       <li>Perform initial checkout procedures. Place the GPS receiver outdoors; with clear view of the sky. Allow the receiver to obtain an UTC almanac.
+                       <li>Verify presence of timing packets by observing the 1 Hz (PPS) led on the interface module. It should flash once per second.
+                       <li>Connect Palisade's port A to the NTP host.
+                       <li>Configure NTP and the serial I/O port on the host system.
+                       <li>Initially use <tt><a href="#flag2">fudge flag2</a></tt> in <b><a href="#Configuration">ntp.conf</a>,</b> to disable event polling (see configuration).
+                       <li>Run NTP in debug mode (-d -d), to observe Palisade_receive events.
+                       <li>The driver reports the <a href="#TrackingStatus">tracking status of the receiver</a>. Make sure it is tracking several satellites.
+                       <li>Remove fudge flag2 and restart <b>ntpd</b> in debug mode to observe palisade_receive events.
+                       <li>If event polling fails, verify the <a href="#Pinouts">connections</a> and that the host hardware supports RTS control.
+               </ol>
+               <h2><font size="+1">Event Logging</font></h2>
+               System and Event log entries are generated by NTP to report significant system events. Administrators should monitor the system log to observe NTP error messages. Log entries generated by the Palisade NTP reference clock driver will be of the form:
+               <blockquote>
+                       <pre>Nov 14 16:16:21 terrapin ntpd[1127]: Palisade #0: <i>message</i></pre>
+               </blockquote>
+               <h2><font size="+1">Fudge Factors</font></h2>
+               <dl>
+                       <dt><a name="time1"></a><tt><font size="+1"><a href="#Configuration">time1 <i>time</i></a></font></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0. If event capture is not used, time1 should be set to 20 milliseconds to correct serial line and operating system delays incurred in capturing time stamps from the synchronous packets.
+                       <dt><tt><font size="+1">stratum <i>number</i></font></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt><font size="+1"><a href="#REFID">refid <i>string</i></a></font></tt>
+                       <dd>Specifies the driver reference identifier, <b>GPS</b>.
+                       <dt><a name="flag2"></a><tt><font size="+1"><a href="#Configuration">flag2 0 | 1</a></font></tt>
+                       <dd>When set to 1, driver does not use hardware event capture. The synchronous packet output by the receiver at the beginning of each second is time stamped by the driver. If triggering the event pulse fails, the driver falls back to this mode automatically.
+               </dl>
+               <h2><font size="+1">Mode Parameter</font></h2>
+               <dl>
+                       <dt><tt><font size="+1">mode <i>number</i></font></tt>
+                       <dd>The mode parameter to the server command specifies the specific hardware this driver is for. The default is 0 for a normal Trimble Palisade. The only other option at this time is 1 for a Endrun Praecis in Trimble emulation mode.
+               </dl>
+               <h2><font size="+1">DEFINEs</font></h2>
+               The following constants are defined in the driver source code. These defines may be modified to improve performance or adapt to new operating systems.<br>&nbsp;
+               <center>
+                       <table border>
+                               <tr>
+                                       <td><b>Label</b></td>
+                                       <td>Definition</td>
+                                       <td>Default Value</td>
+                               </tr>
+                               <tr>
+                                       <td>DEVICE</td>
+                                       <td>The serial port device to be used by the driver</td>
+                                       <td>/dev/palisade<b><i>u</i></b></td>
+                               </tr>
+                               <tr>
+                                       <td>PRECISION</td>
+                                       <td>Accuracy of time transfer</td>
+                                       <td>1 microsecond</td>
+                               </tr>
+                               <tr>
+                                       <td>CURRENT_UTC</td>
+                                       <td>Valid GPS - UTC offset</td>
+                                       <td>13</td>
+                               </tr>
+                               <tr>
+                                       <td>SPEED232</td>
+                                       <td>Host RS-232 baud rate</td>
+                                       <td>B9600</td>
+                               </tr>
+                               <tr>
+                                       <td>TRMB_MINPOLL&nbsp;</td>
+                                       <td>Minimum polling interval</td>
+                                       <td>5 (32 seconds)</td>
+                               </tr>
+                               <tr>
+                                       <td>TRMB_MAXPOLL</td>
+                                       <td>Maximum interval between polls</td>
+                                       <td>7 (128 seconds)</td>
+                               </tr>
+                       </table>
+               </center>
+               <h2><a name="DataFormat"></a><font size="+1">Data Format</font></h2>
+               Palisade port A can output two synchronous time packets. The NTP driver can use either packet for synchronization. Packets are formatted as follows:
+               <h3><b><font size="+0">Packet 8F-AD (Primary NTP Packet)</font></b></h3>
+               <center>
+                       <table>
+                               <tr>
+                                       <td>Byte</td>
+                                       <td>Item</td>
+                                       <td>Type</td>
+                                       <td>Meaning</td>
+                               </tr>
+                               <tr>
+                                       <td>0</td>
+                                       <td>Sub-Packet ID</td>
+                                       <td>BYTE</td>
+                                       <td>Subcode 0xAD</td>
+                               </tr>
+                               <tr>
+                                       <td>1 - 2</td>
+                                       <td>Event Count</td>
+                                       <td>INTEGER</td>
+                                       <td>External event count recorded (0 = PPS)</td>
+                               </tr>
+                               <tr>
+                                       <td>3 - 10</td>
+                                       <td>Fractional Second</td>
+                                       <td>DOUBLE</td>
+                                       <td>Time elapsed in current second (s)</td>
+                               </tr>
+                               <tr>
+                                       <td>11</td>
+                                       <td>Hour</td>
+                                       <td>BYTE</td>
+                                       <td>Hour (0 - 23)</td>
+                               </tr>
+                               <tr>
+                                       <td>12</td>
+                                       <td>Minute</td>
+                                       <td>BYTE</td>
+                                       <td>Minute (0 - 59)</td>
+                               </tr>
+                               <tr>
+                                       <td>13</td>
+                                       <td>Second</td>
+                                       <td>BYTE</td>
+                                       <td>Second (0 - 59; 60 = leap)</td>
+                               </tr>
+                               <tr>
+                                       <td>14</td>
+                                       <td>Day</td>
+                                       <td>BYTE</td>
+                                       <td>Date (1 - 31)</td>
+                               </tr>
+                               <tr>
+                                       <td>15</td>
+                                       <td>Month</td>
+                                       <td>BYTE</td>
+                                       <td>Month (1 - 12)</td>
+                               </tr>
+                               <tr>
+                                       <td>16 - 17</td>
+                                       <td>Year</td>
+                                       <td>INTEGER</td>
+                                       <td>Year (4 digit)</td>
+                               </tr>
+                               <tr>
+                                       <td>18</td>
+                                       <td>Receiver Status</td>
+                                       <td>BYTE</td>
+                                       <td>Tracking Status</td>
+                               </tr>
+                               <tr>
+                                       <td>19</td>
+                                       <td>UTC Flags</td>
+                                       <td>BYTE</td>
+                                       <td>Leap Second Flags</td>
+                               </tr>
+                               <tr>
+                                       <td>20</td>
+                                       <td>Reserved</td>
+                                       <td>BYTE</td>
+                                       <td>Contains 0xFF</td>
+                               </tr>
+                               <tr>
+                                       <td>21</td>
+                                       <td>Reserved</td>
+                                       <td>BYTE</td>
+                                       <td>Contains 0xFF</td>
+                               </tr>
+                       </table>
+               </center>
+               <blockquote>
+                       <h4>Leap Second Flag Definition:</h4>Bit 0:&nbsp; (1) UTC Time is available<br>
+                       Bits 1 - 3: Undefined<br>Bit 4:&nbsp; (1) Leap Scheduled: Leap second pending asserted by GPS control segment.<br>Bit 5:&nbsp; (1) Leap Pending: set 24 hours before, until beginning of leap second.<br>Bit 6:&nbsp; (1) GPS Leap Warning: 6 hours before until 6 hours after leap event<br>Bit 7:&nbsp; (1) Leap In Progress. Only set during the leap second.
+                       <h4><a name="TrackingStatus"></a>Tracking Status Flag Definitions:</h4>
+               </blockquote>
+               <center>
+                       <table width="712" border="0" cellspacing="0">
+                               <tr>
+                                       <td valign="CENTER" width="5%">Code</td>
+                                       <td valign="CENTER" width="59%">Meaning</td>
+                                       <td>Accuracy</td>
+                                       <td>Receiver Mode</td>
+                               </tr>
+                               <tr>
+                                       <td>0</td>
+                                       <td>Receiver is Navigating</td>
+                                       <td>+/- 1 us</td>
+                                       <td>Self Survey</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">1</td>
+                                       <td valign="CENTER" width="59%">Static 1 Sat. Timing Mode&nbsp;</td>
+                                       <td>+/- 1 us</td>
+                                       <td>1-D Timing</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">2</td>
+                                       <td valign="CENTER" width="59%">Approximate Time</td>
+                                       <td>20 - 50 ms</td>
+                                       <td>Acquisition</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">3</td>
+                                       <td valign="CENTER" width="59%">Startup</td>
+                                       <td>N/A</td>
+                                       <td>Initialization</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">4</td>
+                                       <td valign="CENTER" width="59%">Startup</td>
+                                       <td>N/A</td>
+                                       <td>Initialization</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">5</td>
+                                       <td valign="CENTER" width="59%">Dilution of Position too High&nbsp;</td>
+                                       <td>5 ppm</td>
+                                       <td>Self Survey</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">6</td>
+                                       <td valign="CENTER" width="59%">Static 1 Sat. Timing: Sat. not usable</td>
+                                       <td>5 ppm</td>
+                                       <td>1-D Timing</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">7</td>
+                                       <td valign="CENTER" width="59%">No Satellites Usable</td>
+                                       <td>N/A</td>
+                                       <td>Self Survey</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">8</td>
+                                       <td valign="CENTER" width="59%">Only 1 Satellite Usable</td>
+                                       <td>20 - 50 ms</td>
+                                       <td>Self Survey</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">9</td>
+                                       <td valign="CENTER" width="59%">Only 2 Satellite Usable</td>
+                                       <td>20 - 50 ms</td>
+                                       <td>Self Survey</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">10</td>
+                                       <td valign="CENTER" width="59%">Only 3 Satellites Usable</td>
+                                       <td>20 - 50 ms</td>
+                                       <td>Self Survey</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">11</td>
+                                       <td valign="CENTER" width="59%">Invalid Solution</td>
+                                       <td>N/A</td>
+                                       <td>Error</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">12</td>
+                                       <td valign="CENTER" width="59%">Differential Corrections&nbsp;</td>
+                                       <td>N/A</td>
+                                       <td>N/A</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="5%">13</td>
+                                       <td valign="CENTER" width="59%">Overdetermined Fixes</td>
+                                       <td>+/- 100 ns</td>
+                                       <td>Timing Steady State</td>
+                               </tr>
+                       </table>
+               </center>
+               <h3><b><font size="+0">Packet 8F-0B (Comprehensive Timing Packet)</font></b></h3>
+               <center>
+                       <table border="0" cellspacing="0">
+                               <tr>
+                                       <td valign="CENTER" width="9%">Byte</td>
+                                       <td valign="CENTER" width="27%">Item</td>
+                                       <td valign="CENTER" width="16%">Type</td>
+                                       <td valign="CENTER" width="48%">Meaning</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">0</td>
+                                       <td valign="CENTER" width="27%">Sub-Packet ID</td>
+                                       <td valign="CENTER" width="16%">BYTE</td>
+                                       <td valign="CENTER" width="48%">Subcode 0x0B</td>
+                               </tr>
+                               <tr>
+                                       <td valign="TOP" width="9%">1 - 2</td>
+                                       <td valign="TOP" width="27%">Event Count</td>
+                                       <td valign="TOP" width="16%">INTEGER</td>
+                                       <td valign="TOP" width="48%">External event count recorded (0 = PPS)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="TOP" width="9%">3 - 10</td>
+                                       <td valign="TOP" width="27%">UTC / GPS TOW</td>
+                                       <td valign="TOP" width="16%">DOUBLE</td>
+                                       <td valign="TOP" width="48%">UTC / GPS time of week (seconds)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">11</td>
+                                       <td valign="CENTER" width="27%">Date</td>
+                                       <td valign="CENTER" width="16%">BYTE</td>
+                                       <td valign="CENTER" width="48%">Day of Month</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">12</td>
+                                       <td valign="CENTER" width="27%">Month</td>
+                                       <td valign="CENTER" width="16%">BYTE</td>
+                                       <td valign="CENTER" width="48%">Month of Event</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">13 - 14</td>
+                                       <td valign="CENTER" width="27%">Year</td>
+                                       <td valign="CENTER" width="16%">INT</td>
+                                       <td valign="CENTER" width="48%">Year of event</td>
+                               </tr>
+                               <tr>
+                                       <td valign="TOP" width="9%">15</td>
+                                       <td valign="TOP" width="27%">Receiver Mode</td>
+                                       <td valign="TOP" width="16%">BYTE</td>
+                                       <td valign="TOP" width="48%">Receiver operating dimensions:&nbsp;<br>0: Horizontal (2D)&nbsp;<br>1: Full Position (3D)&nbsp;<br>2: Single Satellite (0D)&nbsp;<br>3: Automatic (2D / 3D)&nbsp;<br>4: DGPS reference&nbsp;<br>5: Clock hold (2D)&nbsp;<br>
+                                               6: Over determined Clock</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">15 - 17</td>
+                                       <td valign="CENTER" width="27%">UTC Offset</td>
+                                       <td valign="CENTER" width="16%">INTEGER</td>
+                                       <td valign="CENTER" width="48%">UTC Offset value (seconds)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">18 - 25</td>
+                                       <td valign="CENTER" width="27%">Oscillator Bias</td>
+                                       <td valign="CENTER" width="16%">DOUBLE</td>
+                                       <td valign="CENTER" width="48%">Oscillator BIAS (meters)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="TOP" width="9%">26 - 33</td>
+                                       <td valign="TOP" width="27%">Oscillator Drift Rate</td>
+                                       <td valign="TOP" width="16%">DOUBLE</td>
+                                       <td valign="TOP" width="48%">Oscillator Drift (meters / second)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">34 - 37</td>
+                                       <td valign="CENTER" width="27%">Bias Uncertainty</td>
+                                       <td valign="CENTER" width="16%">SINGLE</td>
+                                       <td valign="CENTER" width="48%">Oscillator bias uncertainty (meters)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">38 - 41</td>
+                                       <td valign="CENTER" width="27%">Drift Uncertainty</td>
+                                       <td valign="CENTER" width="16%">SINGLE</td>
+                                       <td valign="CENTER" width="48%">Oscillator bias rate uncertainty (m / sec)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">42 - 49</td>
+                                       <td valign="CENTER" width="27%">Latitude</td>
+                                       <td valign="CENTER" width="16%">DOUBLE</td>
+                                       <td valign="CENTER" width="48%">Latitude in radians</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">50 - 57</td>
+                                       <td valign="CENTER" width="27%">Longitude</td>
+                                       <td valign="CENTER" width="16%">DOUBLE</td>
+                                       <td valign="CENTER" width="48%">Longitude in radians</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">58 - 65</td>
+                                       <td valign="CENTER" width="27%">Altitude</td>
+                                       <td valign="CENTER" width="16%">DOUBLE</td>
+                                       <td valign="CENTER" width="48%">Altitude above mean sea level, in meters</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="9%">66 - 73</td>
+                                       <td valign="CENTER" width="27%">Satellite ID</td>
+                                       <td valign="CENTER" width="16%">BYTE</td>
+                                       <td valign="CENTER" width="48%">SV Id No. of tracked satellites</td>
+                               </tr>
+                       </table>
+               </center>
+               <h2><a name="Pinouts"></a><font size="+1">Pinouts</font></h2>
+               <a href="#Connection">The following connections are required when connecting Palisade with a host:</a><br>&nbsp;<br>&nbsp;
+               <center>
+                       <table>
+                               <tr>
+                                       <td><u>Description</u></td>
+                                       <td><b>Host</b></td>
+                                       <td></td>
+                                       <td></td>
+                                       <td><b>Palisade&nbsp;</b></td>
+                                       <td></td>
+                                       <td></td>
+                               </tr>
+                               <tr>
+                                       <td><a name="PortA"></a><b>Port A</b></td>
+                                       <td><u>DB-9</u></td>
+                                       <td><u>DB-25</u></td>
+                                       <td></td>
+                                       <td><u>RS-232</u></td>
+                                       <td><u>RS-422</u></td>
+                                       <td><u>Palisade Pin</u></td>
+                               </tr>
+                               <tr>
+                                       <td>Receive Data&nbsp;</td>
+                                       <td>2</td>
+                                       <td>3</td>
+                                       <td>&lt;--&gt;</td>
+                                       <td>Green</td>
+                                       <td>Green / Blue</td>
+                                       <td>8 (T-) &amp; 10 (T+)</td>
+                               </tr>
+                               <tr>
+                                       <td>Request to Send</td>
+                                       <td>7</td>
+                                       <td>4</td>
+                                       <td>&lt;--&gt;</td>
+                                       <td>Gray</td>
+                                       <td>Gray / White</td>
+                                       <td>6 (R-) &amp; 7 (R+)</td>
+                               </tr>
+                               <tr>
+                                       <td>Signal Ground</td>
+                                       <td>5</td>
+                                       <td>7</td>
+                                       <td>&lt;--&gt;</td>
+                                       <td>Black</td>
+                                       <td>Black</td>
+                                       <td>9 (GND)</td>
+                               </tr>
+                               <tr>
+                                       <td></td>
+                                       <td></td>
+                                       <td></td>
+                                       <td></td>
+                                       <td></td>
+                                       <td></td>
+                                       <td></td>
+                               </tr>
+                               <tr>
+                                       <td><a name="PortB"></a><b>Port B</b></td>
+                                       <td></td>
+                                       <td></td>
+                                       <td></td>
+                                       <td></td>
+                                       <td></td>
+                                       <td></td>
+                               </tr>
+                               <tr>
+                                       <td>Receive Data&nbsp;</td>
+                                       <td>2</td>
+                                       <td>3</td>
+                                       <td>&lt;--&gt;</td>
+                                       <td>Brown</td>
+                                       <td>Brown / Yellow</td>
+                                       <td>4 (T-) &amp; 5 (T+)</td>
+                               </tr>
+                               <tr>
+                                       <td>Transmit Data</td>
+                                       <td>3</td>
+                                       <td>2</td>
+                                       <td>&lt;--&gt;</td>
+                                       <td>Violet</td>
+                                       <td>Orange/ Violet</td>
+                                       <td>2 (R-) &amp; 3 (R+)</td>
+                               </tr>
+                               <tr>
+                                       <td>Signal Ground</td>
+                                       <td>5</td>
+                                       <td>7</td>
+                                       <td>&lt;--&gt;</td>
+                                       <td>Black</td>
+                                       <td>Black</td>
+                                       <td>9 (GND)</td>
+                               </tr>
+                       </table>
+               </center>
+               <blockquote>
+                       Note: If driving the RS-422 inputs on the Palisade single ended, i.e. using the Green and Gray connections only, does not work on all serial ports. Use of the Palisade NTP Synchronization Interface Module is recommended.</blockquote>
+               <blockquote>
+                       The 12 pin connector pinout definition:<br>
+                       Face the round 12 pin connector at the end of the cable, with the notch turned upwards.<br>
+                       Pin 1 is to the left of the notch. Pins 2 - 8 wrap around the bottom, counterclockwise to pin 9 on the right of the notch. Pin 10 is just below the notch. Pins 10 (top), 11 (bottom left) and 12 (bottom right) form a triangle in the center of the connector.</blockquote>
+               <blockquote>
+                       <a name="SIM"></a>Pinouts for the Palisade NTP host adapter (Trimble PN 37070) DB-25 M connector are as follows:</blockquote>
+               <center>
+                       <table width="682" border="0" cellspacing="0">
+                               <tr>
+                                       <td valign="CENTER" width="12%">DB-25M</td>
+                                       <td valign="CENTER" width="31%">Conductor&nbsp;</td>
+                                       <td valign="CENTER" width="16%">Palisade</td>
+                                       <td valign="CENTER" width="41%">Description</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">1&nbsp;</td>
+                                       <td valign="CENTER" width="31%">Red</td>
+                                       <td valign="CENTER" width="16%">1</td>
+                                       <td valign="CENTER" width="41%">Power</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">7&nbsp;</td>
+                                       <td valign="CENTER" width="31%">Black</td>
+                                       <td valign="CENTER" width="16%">9</td>
+                                       <td valign="CENTER" width="41%">Ground</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">9</td>
+                                       <td valign="CENTER" width="31%">Black/White</td>
+                                       <td valign="CENTER" width="16%">12</td>
+                                       <td valign="CENTER" width="41%">PPS -</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">10&nbsp;</td>
+                                       <td valign="CENTER" width="31%">Green</td>
+                                       <td valign="CENTER" width="16%">8</td>
+                                       <td valign="CENTER" width="41%">Transmit Port A (T-)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">11&nbsp;</td>
+                                       <td valign="CENTER" width="31%">Brown</td>
+                                       <td valign="CENTER" width="16%">4</td>
+                                       <td valign="CENTER" width="41%">Transmit Port B (T-)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">12&nbsp;</td>
+                                       <td valign="CENTER" width="31%">Gray</td>
+                                       <td valign="CENTER" width="16%">7</td>
+                                       <td valign="CENTER" width="41%">Receive Port A (R+)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">13</td>
+                                       <td valign="CENTER" width="31%">Orange</td>
+                                       <td valign="CENTER" width="16%">3</td>
+                                       <td valign="CENTER" width="41%">Receive Port B (R+)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">21</td>
+                                       <td valign="CENTER" width="31%">Orange/White</td>
+                                       <td valign="CENTER" width="16%">11</td>
+                                       <td valign="CENTER" width="41%">PPS +</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">22</td>
+                                       <td valign="CENTER" width="31%">Blue</td>
+                                       <td valign="CENTER" width="16%">10</td>
+                                       <td valign="CENTER" width="41%">Transmit Port A (T+)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">23</td>
+                                       <td valign="CENTER" width="31%">Yellow</td>
+                                       <td valign="CENTER" width="16%">5</td>
+                                       <td valign="CENTER" width="41%">Transmit Port B (T+)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">24</td>
+                                       <td valign="CENTER" width="31%">White</td>
+                                       <td valign="CENTER" width="16%">6</td>
+                                       <td valign="CENTER" width="41%">Receive Port A (R-)</td>
+                               </tr>
+                               <tr>
+                                       <td valign="CENTER" width="12%">25</td>
+                                       <td valign="CENTER" width="31%">Violet</td>
+                                       <td valign="CENTER" width="16%">2</td>
+                                       <td valign="CENTER" width="41%">Receive Port B (R-)</td>
+                               </tr>
+                       </table>
+               </center>
+               <p></p>
+               <hr>
+               <p>Questions or Comments:<br>
+                       <a href="mailto:sven_dietrich@trimble.com">Sven Dietrich</a><br>
+                       <a href="http://www.trimble.com/">Trimble Navigation Ltd.</a></p>
+               <p>(last updated July 29, 1999)</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+               ;
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver3.html b/html/drivers/driver3.html
new file mode 100644 (file)
index 0000000..e5a06be
--- /dev/null
@@ -0,0 +1,76 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+               <title>PSTI/Traconex 1020 WWV/WWVH Receiver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>PSTI/Traconex 1020 WWV/WWVH Receiver</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.3.<i>u</i><br>
+                       Reference ID: <tt>WWV</tt><br>
+                       Driver ID: <tt>WWV_PST</tt><br>
+                       Serial Port: <tt>/dev/wwv<i>u</i></tt>; 9600 baud, 8-bits, no parity<br>
+                       Features: <tt>tty_clk</tt></p>
+               <h4>Description</h4>
+               <p>This driver supports the PSTI 1010 and Traconex 1020 WWV/WWVH Receivers. No specific claim of accuracy is made for these receiver, but actual experience suggests that 10 ms would be a conservative assumption.</p>
+               <p>The dipswitches should be set for 9600 bps line speed, 24-hour day-of-year format and UTC time zone. Automatic correction for DST should be disabled. It is very important that the year be set correctly in the DIP-switches; otherwise, the day of year will be incorrect after 28 April of a normal or leap year. As the there are only four dipswitches to set the year and the base value of zero correspondes to 1986, years beyond 2001 recycle with the value of zero corresponding to 2002. The propagation delay DIP-switches should be set according to the distance from the transmitter for both WWV and WWVH, as described in the instructions. While the delay can be set only to within 11 ms, the fudge time1 parameter can be used for vernier corrections.</p>
+               <p>Using the poll sequence <tt>QTQDQM</tt>, the response timecode is in three sections totalling 50 ASCII printing characters, as concatenated by the driver, in the following format:</p>
+               <pre>
+ahh:mm:ss.fffs&lt;cr&gt; yy/dd/mm/ddd&lt;cr&gt;
+frdzycchhSSFTttttuuxx&lt;cr&gt;
+
+on-time = first &lt;cr&gt;
+hh:mm:ss.fff = hours, minutes, seconds, milliseconds
+a = AM/PM indicator (' ' for 24-hour mode)
+yy = year (from DIPswitches)
+dd/mm/ddd = day of month, month, day of year
+s = daylight-saving indicator (' ' for 24-hour mode)
+f = frequency enable (O = all frequencies enabled)
+r = baud rate (3 = 1200, 6 = 9600)
+d = features indicator (@ = month/day display enabled)
+z = time zone (0 = UTC)
+y = year (5 = 91)
+cc = WWV propagation delay (52 = 22 ms)
+hh = WWVH propagation delay (81 = 33 ms)
+SS = status (80 or 82 = operating correctly)
+F = current receive frequency (4 = 15 MHz)
+T = transmitter (C = WWV, H = WWVH)
+tttt = time since last update (0000 = minutes)
+uu = flush character (03 = ^c)
+xx = 94 (unknown)</pre>
+               <p>The alarm condition is indicated by other than <tt>8</tt> at <tt>a</tt>, which occurs during initial synchronization and when received signal is lost for an extended period; unlock condition is indicated by other than <tt>0000</tt> in the <tt>tttt</tt> subfield.</p>
+               <h4>Monitor Data</h4>
+               <p>When enabled by the <tt>flag4</tt> fudge flag, every received timecode is written as-is to the <tt>clockstats</tt> file.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>WWV</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Not used by this driver.
+               </dl>
+               <h4>Additional Information</h4>
+               <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver30.html b/html/drivers/driver30.html
new file mode 100644 (file)
index 0000000..d29dbcf
--- /dev/null
@@ -0,0 +1,83 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <meta name="GENERATOR" content="Mozilla/4.06 [en] (X11; I; FreeBSD 3.0-CURRENT i386) [Netscape]">
+               <title>Motorola Oncore GPS Receiver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Motorola Oncore GPS receiver</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.30.<i>u</i><br>
+                       Reference ID: <tt>GPS</tt><br>
+                       Driver ID: ONCORE<br>
+                       Serial Port: <tt>/dev/oncore.serial.</tt><i>u</i>; &nbsp;9600 baud, 8-bits, no parity.<br>
+                       PPS Port: <tt>/dev/oncore.pps.</tt><i>u</i>;&nbsp; <tt>PPS_CAPTUREASSERT</tt> required,&nbsp; <tt>PPS_OFFSETASSERT</tt> supported.<br>
+                       Configuration File: <tt>ntp.oncore</tt>, or <tt>ntp.oncore.</tt><i>u</i>, or <tt>ntp.oncore</tt><i>u</i>, in <tt>/etc/ntp</tt> or <tt>/etc</tt>.</p>
+               <h4>Description</h4>
+               <p>This driver supports most models of the <a href="http://www.mot.com/AECS/PNSB/products">Motorola Oncore GPS receivers</a> (Basic, PVT6, VP, UT, UT+, GT, GT+, SL, M12, M12+T), as long as they support the <i>Motorola Binary Protocol</i>.</p>
+               <p>The interesting versions of the Oncore are the VP, the UT+, the &quot;Remote&quot; which is a prepackaged UT+, and the M12 Timing. The VP is no longer available new, and the UT, GT, and SL are at end-of-life. The Motorola evaluation kit can be recommended. It interfaces to a PC straightaway, using the serial (DCD) or parallel port for PPS input and packs the receiver in a nice and sturdy box. Less expensive interface kits are available from <a href="http://www.tapr.org">TAPR</a> and <a href="http://www.synergy-gps.com">Synergy</a>.<br>&nbsp;</p>
+               <center>
+                       <table>
+                               <tr>
+                                       <td><img src="../pic/oncore_utplusbig.gif" alt="gif" height="124" width="210"></td>
+                                       <td><img src="../pic/oncore_evalbig.gif" alt="gif" height="124" width="182"></td>
+                                       <td><img src="../pic/oncore_remoteant.jpg" alt="gif" height="188" width="178"></td>
+                               </tr>
+                               <tr>
+                                       <td>
+                                               <center>
+                                                       UT+ oncore</center>
+                                       </td>
+                                       <td>
+                                               <center>
+                                                       Evaluation kit</center>
+                                       </td>
+                                       <td>
+                                               <center>
+                                                       Oncore Remote</center>
+                                       </td>
+                               </tr>
+                       </table>
+               </center>
+               <p>The driver requires a standard <tt>PPS</tt> interface for the pulse-per-second output from the receiver. The serial data stream alone does not provide precision time stamps (0-50msec variance, according to the manual), whereas the PPS output is precise down to 50 nsec (1 sigma) for the VP/UT models and 25 nsec for the M12 Timing. If you do not have the PPS signal available, then you should probably be using the NMEA driver rather than the Oncore driver. Most of these are available on-line</p>
+               <p>The driver will use the &quot;position hold&quot; mode with user provided coordinates, the receivers built-in site-survey, or a similar algorithm implemented in this driver to determine the antenna position.</p>
+               <h4>Monitor Data</h4>
+               The driver always puts a lot of useful information on the clockstats file, and when run with debugging can be quite chatty on stdout. When first starting to use the driver you should definitely review the information written to the clockstats file to verify that the driver is running correctly.
+               <p>In addition, on platforms supporting Shared Memory, all of the messages received from the Oncore receiver are made available in shared memory for use by other programs. See the <a href="oncore-shmem.html">Oncore-SHMEM</a> manual page for information on how to use this option. For either debugging or using the SHMEM option, an Oncore Reference Manual for the specific receiver in use will be required.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>GPS</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Not used by this driver.
+               </dl>
+               <h4>Additional Information</h4>
+               <p>The driver was initially developed on FreeBSD, and has since been tested on Linux, SunOS and Solaris.</p>
+               <p><b>Configuration</b></p>
+               <p>There is a driver specific configuration file <tt>ntp.oncore</tt> (or <tt>ntp.oncore.</tt><i>u</i> or <tt>ntp.oncore</tt><i>u</i> if you must distinguish between more than one Oncore receiver) that contains information on the startup mode, the location of the GPS receiver, an offset of the PPS signal from zero, and the cable delay. The offset shifts the PPS signal to avoid interrupt pileups `on' the second, and adjusts the timestamp accordingly. See the driver source for information on this file. The default with no file is: no delay, no offset, and a site survey is done to get the location of the gps receiver.</p>
+               <p>The following three options can be set in the driver specific configuration file only if the driver is using the PPSAPI. The edge of the PPS signal that is `on-time' can be set with the keywords [ASSERT/CLEAR] and the word HARDPPS will cause the PPS signal to control the kernel PLL.</p>
+               <p><b>Performance</b></p>
+               <p>Really good. With the VP/UT+, the generated PPS pulse is referenced to UTC(GPS)&nbsp;with better than 50 nsec (1 sigma) accuracy. The limiting factor will be the timebase of the computer and the precision with which you can timestamp the rising flank of the PPS signal. Using FreeBSD, a FPGA&nbsp;based Timecounter/PPS&nbsp;interface, and an ovenized quartz oscillator, that performance has been reproduced. For more details on this aspect: <a href="http://phk.freebsd.dk/rover.html">Sub-Microsecond timekeeping under FreeBSD</a>.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver31.html b/html/drivers/driver31.html
new file mode 100644 (file)
index 0000000..aff093c
--- /dev/null
@@ -0,0 +1,58 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <meta name="GENERATOR" content="Mozilla/4.06 [en] (X11; I; FreeBSD 3.0-CURRENT i386) [Netscape]">
+               <title>Rockwell Jupiter GPS Receiver</title>
+               <link href="../scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Rockwell Jupiter GPS receiver</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.31.<i>u</i><br>
+                       Reference ID: <tt>GPS</tt><br>
+                       Driver ID: JUPITER<br>
+                       Serial Port: <tt>/dev/gps</tt><i>u</i>; &nbsp;9600 baud, 8-bits, no parity.</p>
+               <h4>Description</h4>
+               <p>This driver supports at least some models of the <a href="http://www.navman.com/oem/products/receivers/jupiter/">Rockwell Jupiter <tt>GPS</tt> receivers</a> (Jupiter 11, Jupiter-T), they must at least support the <i>Zodiac Binary Protocol</i>.</p>
+               <p>The driver requires a standard <tt>PPS</tt> interface for the pulse-per-second output from the receiver. The serial data stream alone does not provide precision time stamps, whereas the PPS output is precise down to 40 ns (1 sigma) for the Jupiter 11 and 25 ns (1 sigma) for Jupiter-T according to the documentation. If you do not have the PPS signal available, then you should probably not be using the Jupiter receiver as a time source. This driver requires a <tt>PPS</tt> signal and the time output from Jupiter receivers is not predictable in <tt>NMEA</tt> mode; the reported time can take one second steps.</p>
+               <h4>Monitor Data</h4>
+               <p>The driver always puts a lot of useful information on the clockstats file, and when run with debugging can be quite chatty on stdout. When first starting to use the driver you should definitely review the information written to the clockstats file to verify that the driver is running correctly.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver. Should be left at zero.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an <tt>ASCII</tt> string from one to four characters, with default <tt>GPS</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Specifies the mobility of the <tt>GPS</tt> receiver: 0 for walking (default), 1 for driving.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Specifies the <tt>PPS</tt> signal on-time edge: 0 for assert (default), 1 for clear.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Not used by this driver.
+               </dl>
+               <h4>Additional Information</h4>
+               <p>The driver was resurrected from a sorry state using the Windows NT port and a Jupiter 11, and has since seen little testing on other platforms. On Windows there exist a barrier though, as there is no publicly available <tt>PPSAPI</tt> implementation, at least not to my knowledge. However, there has been one success report using Linux 2.4.20 and PPSkit 2.1.1.</p>
+               <p>The Jupiter receivers seem to have quite a few names. They are referred to at least as Rockwell receivers, Navman receivers, Zodiac receivers, Conexant receivers and SiRF Technology receivers. Rockwell seems to be the original and most commonly used name and Navman seems to be the current supplier.</p>
+               <p><b>Configuration</b></p>
+               <p>The edge of the <tt>PPS</tt> signal that is `on-time' can be set with <tt>flag2</tt>. There is currently no way to cause the <tt>PPS</tt> signal to control the kernel <tt>PLL</tt>.</p>
+               <p><b>Performance</b></p>
+               <p>The performance is largely unexplored. I have achieved submillisecond stability using a Jupiter 11, but the poor result is more than likely due to the proprietary <tt>PPSAPI</tt> implementation or Windows itself.</p>
+               <p>This driver does not handle leap seconds.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="../scripts/footer.txt"></script>
+       </body>
+
+</html>
+
+=
\ No newline at end of file
diff --git a/html/drivers/driver32.html b/html/drivers/driver32.html
new file mode 100644 (file)
index 0000000..9479248
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <title>Chrono-log K-series WWVB receiver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Chrono-log K-series WWVB receiver</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.32.<i>u</i><br>
+                       Reference ID: <tt>CHRONOLOG</tt><br>
+                       Driver ID: <tt>CHRONOLOG</tt><br>
+                       Serial Port: <tt>/dev/chronolog<i>u</i></tt>; 2400 bps, 8-bits, no parity<br>
+                       <br>
+                       Features: <tt>(none)</tt></p>
+               <h4>Description</h4>
+               <p>This driver supports the Chrono-log K-series WWVB receiver. This is a very old receiver without provisions for leap seconds, quality codes, etc. It assumes output in the local time zone, and that the C library mktime()/localtime() routines will correctly convert back and forth between local and UTC. There is a hack in the driver for permitting UTC, but it has not been tested.</p>
+               <p>Most of this code is originally from refclock_wwvb.c with thanks. It has been so mangled that wwvb is not a recognizable ancestor.</p>
+               <pre>
+Timecode format: Y yy/mm/ddCLZhh:mm:ssCL
+Y - year/month/date line indicator
+yy/mm/dd -- two-digit year/month/day
+C - \r (carriage return)
+L - \n (newline)
+Z - timestamp indicator
+hh:mm:ss - local time
+</pre>
+               <!-- hhmts start -->Last modified: Sun Feb 14 11:57:27 EST 1999 <!-- hhmts end -->
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver33.html b/html/drivers/driver33.html
new file mode 100644 (file)
index 0000000..f50dfb6
--- /dev/null
@@ -0,0 +1,35 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <title>Dumb Clock</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Dumb Clock</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.33.<i>u</i><br>
+                       Reference ID: <tt>DUMBCLOCK</tt><br>
+                       Driver ID: <tt>DUMBCLOCK</tt><br>
+                       Serial Port: <tt>/dev/dumbclock<i>u</i></tt>; 9600 bps, 8-bits, no parity<br>
+                       Features: <tt>(none)</tt></p>
+               <h4>Description</h4>
+               <p>This driver supports a dumb ASCII clock that only emits localtime at a reliable interval. This has no provisions for leap seconds, quality codes, etc. It assumes output in the local time zone, and that the C library mktime()/localtime() routines will correctly convert back and forth between local and UTC.</p>
+               <p>Most of this code is originally from refclock_wwvb.c with thanks. It has been so mangled that wwvb is not a recognizable ancestor.</p>
+               <pre>
+Timecode format: hh:mm:ssCL
+hh:mm:ss - local time
+C - \r (carriage return)
+L - \n (newline)
+</pre>
+               <hr>
+               <!-- hhmts start -->Last modified: Sun Feb 14 12:07:01 EST 1999 <!-- hhmts end -->
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver34.html b/html/drivers/driver34.html
new file mode 100644 (file)
index 0000000..a98fad8
--- /dev/null
@@ -0,0 +1,117 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+
+<html>
+
+       <head>
+               <title>Ultralink Clock</title>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <link <link href="scripts/style.css" type="text/css" rel="stylesheet"> </HEAD> <BODY> <H3> Ultralink Clock</H3>
+               <hr>
+               <h4>Synopsis</h4>
+                       Address: 127.127.34.<i>u</i><br>
+                       Reference ID: <tt>WWVB</tt><br>
+                       Driver ID: <tt>ULINK</tt><br>
+                       Serial Port: <tt>/dev/wwvb<i>u</i></tt>; 9600 bps, 8-bits, no parity<br>
+               <br>
+                       Features: <tt>(none)</tt>
+               <h4>Description</h4>
+               <p>This driver supports the Ultralink Model 325 (replacement for Model 320) RS-232 powered WWVB receiver. PDF specs available on <a href="http://www.ulio.com/">http://www.ulio.com/</a>. This driver also supports the Model 320, 330,331,332 decoders in both polled or continous time code mode.<br>
+                               Leap second and quality are supported.</p>
+               <p>Most of this code is originally from refclock_wwvb.c with thanks. Any mistakes are mine. Any improvements are welcome.</p>
+               <hr>
+               <pre>  The Model 325 timecode format is:
+   &lt;cr&gt;&lt;lf&gt;RQ_1C00LYYYY+DDDUTCS_HH:MM:SSL+5
+  where:
+  R = Signal readability indicator, ranging from R1 to R5  
+  Q    R1 is unreadable, R5 is best reception
+  _ = Space
+  1 = prev. received data bit, values: 0, 1 ,M or ? unknown
+  C = Signal reception from (C)olorado or (H)awaii
+  0 = Hours since last WWVB time and flag code update, values
+  0    00 to 99 (hopefully always 00)
+  L = HEX A5 if receiver is locked to WWVB, Space if not
+  YYYY = Year from 2000 to 2099
+  + = '+' if current year is a leap year, else ' '
+  DDD = current day in the year from 1 to 365/366
+  UTC = timezone (always UTC)
+  S = Daylight savings indicator, (S)TD, (D)ST, (O) transition
+      into DST, (I) transition out of DST
+  _ = Space
+  HH = UTC hour 0 to 23
+  : = Time delimiter, ':' if synced, Space if not
+  MM = Minutes of current hour from 0 to 59
+  : = Time delimiter, ':' if synced, Space if not
+  SS = Seconds of current minute from 0 to 59
+  mm = 10's milliseconds of the current second from 00 to 99
+  L  = Leap second pending at end of month, (I)nsert, (D)elete
+       or Space
+  +5 = UT1 correction, +/- .1 sec increments
+ </pre>
+               <p>Note that Model 325 reports a very similar output like Model 33X series. The driver for this clock is similar to Model 33X behavior. On a unmodified new ULM325 clock, the polling flag (flag1 =1) needs to be set.</p>
+               <hr>
+               <pre>  The Model 320 timecode format is:
+   &lt;cr&gt;&lt;lf&gt;SQRYYYYDDD+HH:MM:SS.mmLT&lt;cr&gt;
+  where:
+  S = 'S' -- sync'd in last hour, '0'-'9' - hours x 10 since last update, else '?'
+  Q = Number of correlating time-frames, from 0 to 5
+  R = 'R' -- reception in progress, 'N' -- Noisy reception, ' ' -- standby mode
+  YYYY = year from 1990 to 2089
+  DDD = current day from 1 to 366
+  + = '+' if current year is a leap year, else ' '
+  HH = UTC hour 0 to 23
+  MM = Minutes of current hour from 0 to 59
+  SS = Seconds of current minute from 0 to 59
+  mm = 10's milliseconds of the current second from 00 to 99
+  L  = Leap second pending at end of month -- 'I' = inset, 'D'=delete
+  T  = DST &lt;-&gt; STD transition indicators
+ </pre>
+               <p>Note that this driver does not do anything with the T flag.</p>
+               <p>The M320 also has a 'U' command which returns UT1 correction information. It is not used in this driver.</p>
+               <hr>
+               <pre>  The Model 33x timecode format is:
+
+    S9+D 00 YYYY+DDDUTCS HH:MM:SSl+5
+
+  Where:
+
+  S =    sync indicator S insync N not in sync
+         the sync flag is WWVB decoder sync
+         nothing to do with time being correct
+  9+ =   signal level 0 thru 9+ If over 9 indicated as 9+
+  D  =   data bit ( fun to watch but useless ;-)
+  space
+  00 =   hours since last GOOD WWVB frame sync
+  space
+  YYYY = current year
+  +  =   leap year indicator
+  DDD =  day of year
+  UTC =  timezone (always UTC)
+  S  =   daylight savings indicator
+  space
+  HH  =  hours
+  :  =   This is the REAL in sync indicator (: = insync)
+  MM  =  minutes
+  :  =   : = in sync ? = NOT in sync
+  SS  =  seconds
+  L  =   leap second flag
+  +5 =   UT1 correction (sign + digit ))
+ </pre>
+               <p>This driver ignores UT1 correction,DST indicator,Leap year and signal level.</p>
+               <hr>
+               <h4>Fudge factors</h4>
+               <p>flag1 polling enable (1=poll 0=no poll)</p>
+               <hr>
+               <address><a href="mailto:frank.migge@oracle.com">mail</a></address>
+               <!-- hhmts start -->Last modified: Mon Mar 8 10:12:08 PST 2004<!-- hhmts end -->
+               <hr>
+               <script type="text/javascript" language="javascript" src="Ultralink Clock_files/footer.txt"></script>
+               </BODY>
+       </head>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver35.html b/html/drivers/driver35.html
new file mode 100644 (file)
index 0000000..78a0881
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Conrad parallel port radio clock</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Conrad parallel port radio clock</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.35.<i>u</i><br>
+                       Reference ID: <tt>PCF</tt><br>
+                       Driver ID: <tt>PCF</tt><br>
+                       Parallel Port: <tt>/dev/pcfclocks/<i>u</i></tt> or <tt>/dev/pcfclock<i>u</i></tt></p>
+               <h4>Description</h4>
+               <p>This driver supports the parallel port radio clock sold by <a href="http://www.conrad-electronic.com/">Conrad Electronic</a> under order numbers 967602 and 642002. This clock is put between a parallel port and your printer. It receives the legal German time, which is either CET or CEST, from the DCF77 transmitter and uses it to set its internal quartz clock. The DCF77 transmitter is located near to Frankfurt/Main and covers a radius of more than 1500 kilometers.</p>
+               <p>The pcfclock device driver is required in order to use this reference clock driver. Currently device drivers for <a href="http://home.pages.de/%7evoegele/pcf.html">Linux</a> and <a href="http://schumann.cx/pcfclock/">FreeBSD</a> are available.</p>
+               <p>This driver uses C library functions to convert the received timecode to UTC and thus requires that the local timezone be CET or CEST. If your server is not located in Central Europe you have to set the environment variable TZ to CET before starting <tt>ntpd</tt>.</p>
+               <h4>Monitor Data</h4>
+               <p>Each timecode is written to the <tt>clockstats</tt> file in the format <tt>YYYY MM DD HH MI SS</tt>.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.1725.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>PCF</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>If set to 1, the radio clock's synchronisation status bit is ignored, ie the timecode is used without a check.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Not used by this driver.
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver36.html b/html/drivers/driver36.html
new file mode 100644 (file)
index 0000000..72fa665
--- /dev/null
@@ -0,0 +1,146 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Radio WWV/H Audio Demodulator/Decoder</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Radio WWV/H Audio Demodulator/Decoder</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               Address: 127.127.36.<i>u</i><br>
+                       Reference ID: <tt>WV<i>f</i></tt> or <tt>WH<i>f</i></tt><br>
+               Driver ID: <tt>WWV_AUDIO</tt><br>
+               Autotune Port: <tt>/dev/icom</tt>; 1200/9600 baud, 8-bits, no parity<br>
+               Audio Device: <tt>/dev/audio</tt> and <tt>/dev/audioctl</tt>
+               <h4>Description</h4>
+               This driver synchronizes the computer time using data encoded in shortwave radio transmissions from NIST time/frequency stations <a href="http://www.bldrdoc.gov/timefreq/stations/wwv.html">WWV</a> in Ft. Collins, CO, and <a href="http://www.bldrdoc.gov/timefreq/stations/wwvh.htm">WWVH</a> in Kauai, HI. Transmissions are made continuously on 2.5, 5, 10 and 15 MHz from both stations and on 20 MHz from WWV. An ordinary shortwave receiver can be tuned manually to one of these frequencies or, in the case of ICOM receivers, the receiver can be tuned automatically by the driver as propagation conditions change throughout the day and season. The performance of this driver when tracking one of the stations is ordinarily better than 1 ms in time with frequency drift less than 0.1 PPM when not tracking any station.<p>The demodulation and decoding algorithms used by this driver are based on a machine language program developed for the TAPR DSP93 DSP unit, which uses the TI 320C25 DSP chip. The analysis, design and performance of the program running on this unit is described in: Mills, D.L. A precision radio clock for WWV transmissions. Electrical Engineering Report 97-8-1, University of Delaware, August 1997, 25 pp. Available from <a href="http://www.eecis.udel.edu/%7emills/reports.html">www.eecis.udel.edu/~mills/reports.htm</a>. For use in this driver, the original program was rebuilt in the C language and adapted to the NTP driver interface. The algorithms have been modified to improve performance, especially under weak signal conditions and to provide an automatic frequency and station selection feature.</p>
+               <p>This driver incorporates several features in common with other audio drivers such as described in the <a href="driver7.html">Radio CHU Audio Demodulator/Decoder</a> and the <a href="driver6.html">IRIG Audio Decoder</a> pages. They include automatic gain control (AGC), selectable audio codec port and signal monitoring capabilities. For a discussion of these common features, as well as a guide to hookup, debugging and monitoring, see the <a href="../audio.html">Reference Clock Audio Drivers</a> page.</p>
+               <p>The WWV signal format is described in NIST Special Publication 432 (Revised 1990). It consists of three elements, a 5-ms, 1000-Hz pulse, which occurs at the beginning of each second, a 800-ms, 1000-Hz pulse, which occurs at the beginning of each minute, and a pulse-width modulated 100-Hz subcarrier for the data bits, one bit per second. The WWVH format is identical, except that the 1000-Hz pulses are sent at 1200 Hz. Each minute encodes nine BCD digits for the time of century plus seven bits for the daylight savings time (DST) indicator, leap warning indicator and DUT1 correction.</p>
+               <h4>Program Architecture</h4>
+               <p>As in the original program, the clock discipline is modelled as a Markov process, with probabilistic state transitions corresponding to a conventional clock and the probabilities of received decimal digits. The result is a performance level which results in very high accuracy and reliability, even under conditions when the minute beep of the signal, normally its most prominent feature, can barely be detected by ear using  a communications receiver.</p>
+               <p>The analog audio signal from the shortwave radio is sampled at 8000 Hz and converted to digital representation. The 1000/1200-Hz pulses and 100-Hz subcarrier are first separated using two IIR filters, a 600-Hz bandpass filter centered on 1100 Hz and a 150-Hz lowpass filter. The minute synch pulse is extracted using an 800-ms synchronous matched filter and pulse grooming logic which discriminates between WWV and WWVH signals and noise. The second synch pulse is extracted using a 5-ms FIR matched filter and 8000-stage comb filter.</p>
+               <p>The phase of the 100-Hz subcarrier relative to the second synch pulse is fixed at the transmitter; however, the audio stage in many radios affects the phase response at 100 Hz in unpredictable ways. The driver adjusts for each radio using two 170-ms synchronous matched filters. The I (in-phase) filter is used to demodulate the subcarrier envelope, while the Q (quadrature-phase) filter is used in a tracking loop to discipline the codec sample clock and thus the demodulator phase.</p>
+               <p>A bipolar data signal is determined from the matched filter I and Q channels using a pulse-width discriminator. The discriminator samples the I channel at 15 ms (<i>n</i>),  200 ms (<i>s</i><sub>1</sub>) and 500 ms (<i>s</i><sub>0</sub>), and the envelope (RMS&nbsp;I and Q channels) at 200 ms (<i>e</i><sub>1</sub>)&nbsp;and the end of the second (<i>e</i><sub>0</sub>). The bipolar data signal is expressed <i>s</i><sub>1</sub> - 2<i>s</i><sub>0 </sub>- <i>n.</i> Note that, since the signals <i>s</i><sub>0</sub> and <i>s</i><sub>1</sub> include the noise <i>n</i>, this term cancels out. The data bit SNR&nbsp;is calculated as 20 log<sub>10</sub>(<i>e</i><sub>1</sub> / <i>e</i><sub>0</sub>). If the driver has not synchronized to the minute pulse, or if the data bit amplitude <i>e</i><sub>1</sub> or SNR are below thresholds, the bit is considered invalid and the bipolar signal is forced to zero.</p>
+               <p>The bipolar signal is exponentially averaged in a set of 60 accumulators, one for each second, to determine the semi-static miscellaneous bits, such as DST indicator, leap second warning and DUT1 correction. In this design a data average value larger than a positive threshold is interpreted as +1 (hit) and a value smaller than a negative threshold as a -1 (miss). Values between the two thresholds, which can occur due to signal fades, are interpreted as an erasure and result in no change of indication.</p>
+               <p>The BCD digit in each digit position of the timecode is represented as four data bits. The bits are correlated with the bits corresponding to each of the valid decimal digits in this position. If any of the four bits are invalid, the correlated value for all digits in this position is assumed zero. In either case, the values for all digits are exponentially averaged in a likelihood vector associated with this position. The digit associated with the maximum over all averaged values then becomes the maximum likelihood selection for this position and the ratio of the maximum over the next lower value represents the digit SNR.</p>
+               <p>The decoding matrix contains nine row vectors, one for each digit position. Each row vector includes the maximum likelihood digit, likelihood vector and other related data. The maximum likelihood digit for each of the nine digit positions becomes the maximum likelihood time of the century. A built-in transition function implements a conventional clock with decimal digits that count the minutes, hours, days and years, as corrected for leap seconds and leap years. The counting operation also rotates the likelihood vector corresponding to each digit as it advances. Thus, once the clock is set, each clock digit should correspond to the maximum likelihood digit as transmitted.</p>
+               <p>Each row of the decoding matrix also includes a compare counter and the most recently determined maximum likelihood digit. If a digit likelihood exceeds the decision level and compares with previous digits for a number of successive minutes in any row, the maximum likelihood digit replaces the clock digit in that row. When this condition is true for all rows and the second epoch has been reliably determined, the clock is set (or verified if it has already been set) and delivers correct time to the integral second. The fraction within the second is derived from the logical master clock, which runs at 8000 Hz and drives all system timing functions.</p>
+               <p>The logical master clock is derived from the audio codec clock. Its frequency is disciplined by a frequency-lock loop (FLL) which operates independently of the data recovery functions. At averaging intervals determined by the measured jitter, the frequency error is calculated as the difference between the most recent and the current second epoch divided by the interval. The sample clock frequency is then corrected by this amount. When first started, the frequency averaging interval is eight seconds, in order to compensate for intrinsic codec clock frequency offsets up to 125 PPM. Under most conditions, the averaging interval doubles in stages from the initial value to over 1000 seconds, which results in an ultimate frequency precision of 0.125 PPM, or about 11 ms/day.</p>
+               <p>It is important that the logical clock frequency is stable and accurately determined, since in most applications the shortwave radio will be tuned to a fixed frequency where WWV or WWVH signals are not available throughout the day. In addition, in some parts of the US, especially on the west coast, signals from either or both WWV and WWVH may be available at different times or even at the same time. Since the propagation times from either station are almost always different, each station must be reliably identified before attempting to set the clock.</p>
+               <p>Reliable station identification requires accurate discrimination between very weak signals in noise and noise alone. The driver very aggresively soaks up every scrap of signal information, but has to be careful to avoid making pseudo-sense of noise alone. The signal quality metric depends on the minute pulse amplitude and SNR&nbsp;measured in second 0 of the minute, together with the data subcarrier amplitude and SNR measured in second 1. If all four values are above defined thresholds a hit is declared, otherwise a miss. The number of hits declared in the last six minutes by each station represents the high order bits of the metric value, while the current minute pulse amplitude repressents the low order bits. The resulting value is then scaled from zero to 100 for use as a quality indicator. It is used by the autotune function described below and reported in the timecode string.</p>
+               <h4>Performance</h4>
+               <p>It is the intent of the design that the accuracy and stability of the indicated time be limited only by the characteristics of the ionospheric propagation medium. Conventional wisdom is that synchronization via the HF medium is good only to a millisecond under the best propagation conditions. The performance of the NTP daemon disciplined by the driver is clearly better than this, even under marginal conditions. Ordinarily, with marginal to good signals and a frequency averaging interval of 1024 s, the frequency is stabilized within 0.1 PPM and the time within 0.5 ms.  The frequency stability characteristic is highly important, since the clock may have to free-run for several hours before reacquiring the WWV/H signal.</p>
+               <p>The expected accuracy over a typical day was determined using the DSP93 and an oscilloscope and cesium oscillator calibrated with a GPS receiver. With marginal signals and allowing 15 minutes for initial synchronization and frequency compensation, the time accuracy determined from the WWV/H second synch pulse was reliably within 125 <font face="Symbol">m</font>s. In the particular DSP93 used for program development, the uncorrected CPU clock frequency offset was 45.8&plusmn;0.1 PPM. Over the first hour after initial synchronization, the clock frequency drifted about 1 PPM as the frequency averaging interval increased to the maximum 1024 s. Once reaching the maximum, the frequency wandered over the day up to 1 PPM, but it is not clear whether this is due to the stability of the DSP93 clock oscillator or the changing height of the ionosphere. Once the frequency had stabilized and after loss of the WWV/H signal, the frequency drift was less than 0.5 PPM, which is equivalent to 1.8 ms/h or 43 ms/d. This resulted in a step phase correction up to several milliseconds when the signal returned.</p>
+               <p>The measured propagation delay from the WWV transmitter at Boulder, CO, to the receiver at Newark, DE, is 23.5&plusmn;0.1 ms. This is measured to the peak of the pulse after the second synch comb filter and includes components due to the ionospheric propagation delay, nominally 8.9 ms, communications receiver delay and program delay. The propagation delay can be expected to change about 0.2 ms over the day, as the result of changing ionosphere height. The DSP93 program delay was measured at 5.5 ms, most of which is due to the 400-Hz bandpass filter and 5-ms matched filter. Similar delays can be expected of this driver.</p>
+               <h4>Program Operation</h4>The driver begins operation immediately upon startup. It first searches for one or both of the stations WWV and WWVH and attempts to acquire minute synch. This may take some fits and starts, as the driver expects to see several  consecutive minutes with good signals and low jitter. If the autotune function is active, the driver will rotate over all five frequencies and both WWV and WWVH stations until at least three good minutes are found.<p>When a minute synch candidate has been found, the driver acquires second synch, which can take up to several minutes, depending on signal quality. At the same time the driver accumulates likelihood values for the unit (seconds) digit of the nine digits of the timecode, plus the seven miscellaneous bits included in the WWV/H transmission format. When a good unit digit has been found, the driver accumlates likelihood values for the remaining eight digits of the timecode. When three repetitions of all nine digits have decoded correctly, which normally takes 15 minutes with good signals, and up to 40 minutes when buried in noise, and the second synch has been acquired, the clock is set (or verified) and is selectable to discipline the system clock.</p>
+               <p>Once the clock is set, it continues to provide correct timecodes, even if all signals are losst. The time is considered correct as long as the second synch amplitude and SNR are above specified thresholds and jitter is below threshold. As long as the clock is set or verified, the system clock offsets are provided once each minute to the reference clock interface, where they are processed using the same algorithms used with other local reference clocks and remote servers. Using these algorithms, the system clock can in principle be disciplined to a much finer resolution than the 125-<font face="Symbol">m</font>s sample interval would suggest, although the ultimate accuracy is probably limited by propagation delay variations as the ionspheric height varies throughout the day and night.</p>
+               <p>The codec clock frequency is disciplined during times when WWV/H signals are available. The algorithm refines the frequency offset using increasingly longer averaging intervals to 1024 s, where the precision is about 0.1 PPM. With good signals, it takes well over two hours to reach this degree of precision; however, it can take many more hours than this in case of marginal signals. Once reaching the limit, the algorithm will follow frequency variations due to temperature fluctuations and ionospheric height variations.</p>
+               <p>It may happen as the hours progress around the clock that WWV and WWVH signals may appear alone, together or not at all. When the driver has mitigated which station and frequency is best, it sets the reference identifier to the string WV<i>f</i> for WWV and WH<i>f</i> for WWVH, where <i>f</i> is the frequency in megahertz. If the propagation delays have been properly set with the <tt>fudge time1</tt> (WWV) and <tt>fudge time2</tt> (WWVH) commands in the configuration file, handover from one station to the other is seamless.</p>
+               <p>Once the clock has been set for the first time, it will appear reachable and selectable to discipline the system clock. Operation continues as long as the signal quality from at least one station on at least one frequency is acceptable. A consequence of this design is that, once the clock is set, the time and frequency are disciplined only by the second synch pulse and the clock digits themselves are driven by the clock state machine. If for some reason the state machine drifts to the wrong second, it would never reresynchronize. To protect against this most unlikely situation, if after two days with no signals, the clock is considered unset and resumes the synchronization procedure from the beginning.</p>
+               <p>However, as long as the clock has once been set correctly and allowed to converge to the intrinsic codec clock frequency, it will continue to read correctly even during the holdover interval, but with increasing dispersion. Assuming the clock frequency can be disciplined within 1 PPM, it can coast without signals for several days without exceeding the NTP step threshold of 128 ms. During such periods the root dispersion increases at 5 <font face="Symbol">m</font>s per second, which makes the driver appear less likely for selection as time goes on. Eventually, when the dispersion due all causes exceeds 1 s, it is no longer suitable for synchronization.</p>
+               <p>To work well, the driver needs a shortwave receiver with good audio response at 100 Hz. Most shortwave and communications receivers roll off the audio response below 250 Hz, so this can be a problem, especially with receivers using DSP technology, since DSP filters can have very fast rolloff outside the passband. Some DSP transceivers, in particular the ICOM 775, have a programmable low frequency cutoff which can be set as low as 80 Hz. However, this particular radio has a strong low frequency buzz at about 10 Hz which appears in the audio output and can affect data recovery under marginal conditions. Although not tested, it would seem very likely that a cheap shortwave receiver could function just as well as an expensive communications receiver.</p>
+               <h4>Autotune</h4>
+               <p>The driver includes provisions to automatically tune the radio in response to changing radio propagation conditions throughout the day and night. The radio interface is compatible with the ICOM CI-V standard, which is a bidirectional serial bus operating at TTL levels. The bus can be connected to a serial port using a level converter such as the CT-17.</p>
+               <p>Each ICOM radio is assigned a unique 8-bit ID select code, usually expressed in hex format. To activate the CI-V interface, the <tt>mode</tt> keyword of the <tt>server</tt> configuration command specifies a nonzero select code in decimal format. A table of ID select codes for the known ICOM radios is given on the <a href="../audio.html">Reference Clock Audio Drivers</a> page. A missing <tt>mode</tt> keyword or a zero argument leaves the interface disabled.</p>
+               <p>If specified, the driver will attempt to open the device <tt>/dev/icom</tt> and, if successful will activate the autotune function and tune the radio to each operating frequency in turn while attempting to acquire minute synch from either WWV or WWVH. However, the driver is liberal in what it assumes of the configuration. If the <tt>/dev/icom</tt> link is not present or the open fails or the CI-V bus or radio is inoperative, the driver quietly gives up with no harm done.</p>
+               <p>Once acquiring minute synch, the driver operates as described above to set the clock. However, during seconds 59, 0 and 1 of each minute it tunes the radio to one of the five broadcast frequencies to measure the minute synch pulse amplitude and SNR in second 0 and data pulse amplitude and SNR in second 1 to update the signal metric. In principle, the data pulse in second 58 is usable, but the AGC in most radios is not fast enough for a reliable measurement. Each of the five frequencies are probed in a five-minute rotation to build a database of current propagation conditions for all signals that can be heard at the time. At the end of each probe a mitigation procedure scans the database and retunes the radio to the best frequency and station found. For this to work well, the radio should be set for a fast AGC recovery time. This is most important while tracking a strong signal, which is normally the case, and then probing another frequency, which may have much weaker signals.</p>
+               <p>At the end of each probe, the frequency and station with the maximum metric is chosen, with ties going first to the highest frequency and then to WWV in order. A station is considered valid only if the metric is above a specified threshold' if below, the rotating probes continue until a valid station is found.</p>
+               <dl>
+                       </dl>
+               <h4>Diagnostics</h4>
+               <p>The autotune process produces diagnostic information along with the timecode. This is very useful for evaluating the performance of the algorithms, as well as radio propagation conditions in general. The message is produced once each minute for each frequency in turn after minute synch has been acquired.</p>
+               <p><tt>wwv5 status agc epoch secamp/secsnr datamp/datsnr wwv wwvh</tt></p>
+               <p>where the fields after the <tt>wwv5</tt> identifier are: <tt>status</tt> contains status bits, <tt>agc</tt> audio gain, <tt>epoch </tt>second epoch, <tt>secamp/secsnr </tt>second pulse ampliture/SNR, and <tt>wwv</tt> and <tt>wwvh</tt> are two sets of fields, one each for WWV and WWVH. Each of the two fields has the format</p>
+               <p><tt>ident score metric minamp/minsnr</tt></p>
+               <p>where <tt>ident </tt>encodes the station (<tt>WV</tt> for WWV, <tt>WH</tt> for WWVH) and frequency (2, 5, 10, 15 or 20), <tt>score</tt> 32-bit shift register recording the hits (1) and misses (0) of the last 32 probes (hits and misses enter from the right), <tt>metric</tt> is described above, and <tt>minamp/minsnr</tt> minute pulse ampliture/SNR. An example is:</p>
+               <p><tt>wwv5 000d 111 5753 3967/20.1 3523/10.2 WV20 bdeff 100 8348/30.0 WH20 0000 1 22/-12.4</tt></p>
+               <p>There are several other messages that can occur; these are documented in the source listing.</p>
+               <h4>Debugging Aids</h4>
+               <p>The most convenient way to track the driver status is using the <tt>ntpq</tt> program and the <tt>clockvar</tt> command. This displays the last determined timecode and related status and error counters, even when the driver is not disciplining the system clock. If the debugging trace feature (<tt>-d</tt> on the <tt>ntpd</tt> command line)is enabled, the driver produces detailed status messages as it operates. If the <tt>fudge flag 4</tt> is set, these messages are written to the <tt>clockstats</tt> file. All messages produced by this driver have the prefix <tt>wwv</tt> for convenient filtering with the Unix <tt>grep</tt> command.</p>
+               <h4>Monitor Data</h4>
+               
+               When enabled by the <tt>filegen</tt> facility, every received timecode is written to the <tt>clockstats</tt> file in the following format:
+               <p><tt>sq yyyy ddd hh:mm:ss ld du lset agc ident metric errs freq avg<br>
+                                    s</tt>        synch indicator (<tt>?</tt>&nbsp;or space)
+        <tt>q     </tt>quality character (see below)
+        <tt>yyyy  </tt>Gregorian year
+        <tt>ddd   </tt>day of year
+        <tt>hh    </tt>hour of day
+        <tt>mm    </tt>minute of hour
+        <tt>l     </tt>leap second warning <tt>L</tt>
+        <tt>d     </tt>DST state <tt>S, D, I, O</tt><br>
+                               <tt>dut   </tt>DUT sign and magnitude
+        <tt>lset  </tt>minutes since last set
+        <tt>agc   </tt>audio gain
+        <tt>ident </tt>station identifier and frequency
+        <tt>metric </tt>signal metric (0-100)
+        <tt>errs  </tt>data bit errors in last minute
+        <tt>freq  </tt>codec frequency offset (PPM)
+        <tt>avg   </tt>frequency averaging interval (s)
+</p>
+                       The fields beginning with <tt>year</tt> and extending through <tt>dut</tt> are decoded from the received data and are in fixed-length format. The <tt>agc</tt> and <tt>lset</tt> fields, as well as the following driver-dependent fields, are in variable-length format.
+               <dl>
+                       <dt><tt>s</tt>
+                       <dd>The synch indicator is initially <tt>?</tt> before the clock is set, but turns to space when all nine digits of the timecode are correctly set and the decoder is synchronized to the station within 125 <font face="Symbol">m</font>s.
+                       <dt><tt>q</tt>
+                       <dd>The quality character is a four-bit hexadecimal code showing which alarms have been raised. Each bit is associated with a specific alarm condition according to the following:
+                               <dl>
+                                       <dt><tt>0x8</tt>
+                                       <dd>synch alarm. The decoder is not synchronized to the station within 125 <font face="Symbol">m</font>s.
+                                       <dt><tt>0x4</tt>
+                                       <dd>Digit error alarm. Less than nine decimal digits were found in the last minute.<dt><tt>0x2</tt>
+                                       <dd>Error alarm. More than 40 data bit errors were found in the last minute.<dt><tt>0x1</tt>
+                                       <dd>Compare alarm. A maximum likelihood digit failed to agree with the current associated clock digit in the last minute.</dl>It is important to note that one or more of the above alarms does not necessarily indicate a clock error, but only that the decoder has detected a condition that may result in an error. However, the local clock update is not suppressed if any alarm bits are set other than a synch alarm.<dt><tt>yyyy ddd hh:mm:ss</tt>
+                       <dd>The timecode format itself is self explanatory. Since the driver latches the on-time epoch directly from the second synch pulse, the seconds fraction is always zero. Although the transmitted timecode includes only the year of century, the Gregorian year is augmented by 2000.<dt><tt>l</tt>
+                       <dd>The leap second warning is normally space, but changes to <tt>L</tt> if a leap second is to occur at the end of the month of June or December.
+                       <dt><tt>d</tt>
+                       <dd>The DST state is <tt>S</tt> or <tt>D</tt> when standard time or daylight time is in effect, respectively. The state is <tt>I</tt> or <tt>O</tt> when daylight time is about to go into effect or out of effect, respectively.
+                       <dt><tt>dut</tt>
+                       <dd>The DUT sign and magnitude shows the current UT1 offset relative to the displayed UTC time, in deciseconds.
+                       <dt><tt>lset</tt>
+                       <dd>Before the clock is set, the interval since last set is the number of minutes since the driver was started; after the clock is set, this is number of minutes since the decoder was last synchronized to the station within 125 <font face="Symbol">m</font>s.
+                       <dt><tt>agc</tt>
+                       <dd>The audio gain shows the current codec gain setting in the range 0 to 255. Ordinarily, the receiver audio gain control should be set for a value midway in this range.
+                       <dt><tt>ident</tt>
+                       <dd>The station identifier shows the station, <tt>WV<i>f</i></tt> for WWV or <tt>WH<i>f</i></tt> for WWVH, and frequency <i><tt>f</tt></i> being tracked. If neither station is heard on any frequency, the reference identifier shows <tt>NONE</tt>.
+                       <dt><tt>metric</tt>
+                       <dd>The signal metric described above from 0 (no signal) to 100 (best).
+                       <dt><tt>errs</tt>
+                       <dd>The bit error counter is useful to determine the quality of the data signal received in the most recent minute. It is normal to drop a couple of data bits under good signal conditions and increasing numbers as conditions worsen. While the decoder performs moderately well even with half the bits are in error in any minute, usually by that point the metric drops below threshold and the decoder switches to a different frequency.<dt><tt>freq</tt>
+                       <dd>The frequency offset is the current estimate of the codec frequency offset to within 0.1 PPM. This may wander a bit over the day due to local temperature fluctuations and propagation conditions.
+                       <dt><tt>avgt</tt>
+                       <dd>The averaging time is the interval between frequency updates in powers of two to a maximum of 1024 s. Attainment of the maximum indicates the driver is operating at the best possible resolution in time and frequency.
+               </dl>
+               <p>An example timecode is:</p>
+               <p><tt>0 2000 006 22:36:00 S +3 1 115 WV20 86 5 66.4 1024</tt></p>
+               <p>Here the clock has been set and no alarms are raised. The year, day and time are displayed along with no leap warning, standard time and DUT +0.3 s. The clock was set on the last minute, the AGC is safely in the middle ot the range 0-255, and the receiver is tracking WWV on 20 MHz. Good receiving conditions prevail, as indicated by the metric 86 and 5 bit errors during the last minute. The current frequency is 66.4 PPM and the averaging interval is 1024 s, indicating the maximum precision available.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the propagation delay for WWV (40:40:49.0N 105:02:27.0W), in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Specifies the propagation delay for WWVH (21:59:26.0N 159:46:00.0W), in seconds and fraction, with default 0.0.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Ordinarily, this field specifies the driver reference identifier; however, the driver sets the reference identifier automatically as described above.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Specifies the microphone port if set to zero or the line-in port if set to one. It does not seem useful to specify the compact disc player port.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Enables audio monitoring of the input signal. For this purpose, the speaker volume must be set before the driver is started.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Enable verbose <tt>clockstats</tt> recording if set.
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver37.html b/html/drivers/driver37.html
new file mode 100644 (file)
index 0000000..3bd5085
--- /dev/null
@@ -0,0 +1,51 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Forum Graphic GPS Dating station</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Forum Graphic GPS Dating station</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               <p>Address: 127.127.37.<i>u</i><br>
+                       Reference ID: <tt>GPS</tt><br>
+                       Driver ID: <tt>GPS</tt><br>
+                       Parallel Port: <tt>/dev/fgclock<i>u</i></tt></p>
+               <h4>Description</h4>
+               <p>This driver supports the Forum Graphic GPS Dating station sold by <a href="http://www.emr.fr/gpsclock.html">EMR company</a>.</p>
+               <p>Unfortunately sometime FG GPS start continues reporting of the same date. The only way to fix this problem is GPS power cycling and ntpd restart after GPS power-up.</p>
+               <p>After Jan,10 2000 my FG GPS unit start send a wrong answer after 10:00am till 11:00am. It repeat hour value in result string twice. I wroite a small code to avoid such problem. Unfortunately I have no second FG GPS unit to evaluate this problem. Please let me know if your GPS has no problems after Y2K.</p>
+               <p></p>
+               <h4>Monitor Data</h4>
+               <p>Each timecode is written to the <tt>clockstats</tt> file in the format <tt>YYYY YD HH MI SS</tt>.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>FG</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Not used by this driver.
+               </dl>
+               <hr>
+               <address>Dmitry Smirnov (das@amt.ru)</address>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver38.html b/html/drivers/driver38.html
new file mode 100644 (file)
index 0000000..283e38f
--- /dev/null
@@ -0,0 +1,131 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <title>hopf clock drivers by ATLSoft</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
+               <h1><font face="Arial"><i><blink><font size="5">hopf</font></blink></i><font size="+2"> </font><font size="3">Serial Line Receivers (6021 and&nbsp; kompatible)</font></font></h1>
+               <hr>
+               <h2><font size="+1">Synopsis</font></h2>
+               <table width="100%">
+                       <tr>
+                               <td>
+                                       <table bgcolor="#C0C0C0">
+                                               <tr>
+                                                       <td height="21">
+                                                               <div align="right">
+                                                                       <tt>Address:&nbsp;&nbsp;</tt></div>
+                                                       </td>
+                                                       <td><b>127.127.38.<i>X</i></b></td>
+                                               </tr>
+                                               <tr>
+                                                       <td height="1">
+                                                               <div align="right">
+                                                                       <tt>Reference ID:&nbsp;&nbsp;</tt></div>
+                                                       </td>
+                                                       <td height="1"><a name="REFID"></a><b>.hopf. </b>(default)<b>, GPS, DCF</b></td>
+                                               </tr>
+                                               <tr>
+                                                       <td height="21">
+                                                               <div align="right">
+                                                                       <tt>Driver ID:&nbsp;&nbsp;</tt></div>
+                                                       </td>
+                                                       <td height="21"><b>HOPF_S</b></td>
+                                               </tr>
+                                               <tr>
+                                                       <td height="16">
+                                                               <div align="right">
+                                                                       <tt>Serial Port:&nbsp;&nbsp;</tt></div>
+                                                       </td>
+                                                       <td height="16"><b>/dev/hopfclock<i>X</i></b></td>
+                                               </tr>
+                                               <tr>
+                                                       <td height="23">
+                                                               <div align="right">
+                                                                       <tt><font size="+1">Serial I/O</font>:&nbsp;&nbsp;</tt></div>
+                                                       </td>
+                                                       <td height="23"><b>9600 baud, 8-bits, 1-stop, no parity</b></td>
+                                               </tr>
+                                       </table>
+                               </td>
+                               <td align="center"><img src="../pic/fg6021.gif" alt="gif" height="207" width="238" border="0"></td>
+                       </tr>
+               </table>
+               <hr>
+               <h2><font size="+1">Description</font></h2>
+               <p>The <b>refclock_hopf_serial</b> driver supports <a href="http://www.hopf.com">hopf electronic receivers</a> with serial Interface kompatibel 6021.<br>
+               </p>
+               <p>Additional software and information about the software drivers is available from: <a href="http://www.ATLSoft.de/ntp">http://www.ATLSoft.de/ntp</a>.<br>
+               </p>
+               <p>Latest NTP driver source, executables and documentation is maintained at: <a href="http://www.ATLSoft.de/ntp">http://www.ATLSoft.de/ntp</a></p>
+               <hr>
+               <h2><font size="+1">Operating System Compatibility</font></h2>
+               <p align="left">The hopf clock driver has been tested on the following software and hardware platforms:<br>&nbsp;</p>
+               <table bgcolor="#C0C0C0">
+                       <tr>
+                               <td valign="CENTER" nowrap width="23%">
+                                       <p align="left"><b>Platform</b></p>
+                               </td>
+                               <td valign="CENTER" nowrap>
+                                       <p align="left"><b>Operating System</b></p>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td valign="CENTER" nowrap width="23%">
+                                       <p align="left">i386 (PC)&nbsp;</p>
+                               </td>
+                               <td valign="CENTER" nowrap>
+                                       <p align="left">Linux</p>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td nowrap>
+                                       <p align="left">i386 (PC)&nbsp;</p>
+                               </td>
+                               <td nowrap>
+                                       <p align="left">Windows NT</p>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td nowrap>
+                                       <p align="left">i386 (PC)&nbsp;</p>
+                               </td>
+                               <center>
+                                       <td nowrap>Windows 2000</td>
+                               </center>
+                       </tr>
+               </table>
+               <hr>
+               <h2><font size="+1">O/S Serial Port Configuration</font></h2>
+               The driver attempts to open the device <b><tt><a href="#REFID">/dev/hopfclock<i>X</i></a></tt></b> where <i><b>X</b></i> is the NTP refclock unit number as defined by the LSB of the refclock address.&nbsp; Valid refclock unit numbers are 0 - 3.
+               <p>The user is expected to provide a symbolic link to an available serial port device.&nbsp; This is typically performed by a command such as:</p>
+               <blockquote>
+                       <tt>ln -s /dev/ttyS0 /dev/hopfclock0</tt></blockquote>Windows NT does not support symbolic links to device files.&nbsp;<br>
+               <b>COMx</b>: is used by the driver, based on the refclock unit number, where <b>unit 1</b> corresponds to <b>COM1</b>: and <b>unit 3</b> corresponds to <b>COM3</b>:<br>&nbsp;
+               <hr>
+               <h2><font size="+1">Fudge Factors</font></h2>
+               <dl>
+                       <dt><b><a name="time1"></a><tt><font size="+1"><a href="#Configuration">time1 <i>time</i></a></font></tt></b>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0. Should be set to 20 milliseconds to correct serial line and operating system delays incurred in capturing time stamps from the synchronous packets.
+                       <dt><tt><font size="+1"><a href="#REFID"><b>refid <i>string</i></b></a></font></tt>
+                       <dd>Specifies the driver reference identifier, <b>GPS </b><i>or</i> <b>DCF</b>.
+                       <dt><tt><font size="+1"><b>flag1 0 | 1</b></font></tt>
+                       <dd>When set to 1, driver sync's even if only crystal driven.
+               </dl>
+               <hr>
+               <h2><a name="DataFormat"></a><font size="+1">Data Format</font></h2>
+               <p>as specified in clock manual under pt. <u>[ <span style="font-size:10.0pt;font-family: Arial;mso-fareast-font-family:&quot;Times New Roman&quot;;mso-bidi-font-family:&quot;Times New Roman&quot;; mso-ansi-language:EN-GB;mso-fareast-language:DE;mso-bidi-language:AR-SA" lang="EN-GB"><b>Data String for NTP</b> ( <b><i>Network Time Protocol </i></b>) </span>]</u></p>
+               <hr>
+               <h3>Questions or Comments:</h3>
+               <p><a href="mailto:altmeier@atlsoft.de">Bernd Altmeier</a><a href="http://www.ATLSoft.de"><br>Ing.-B&uuml;ro f&uuml;r Software www.ATLSoft.de</a></p>
+               <p>(last updated 02/28/2001)<br>&nbsp;</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver39.html b/html/drivers/driver39.html
new file mode 100644 (file)
index 0000000..482134e
--- /dev/null
@@ -0,0 +1,113 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <title>hopf clock drivers by ATLSoft</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
+               <h1><font face="Arial"><i><blink><font size="5">hopf</font></blink></i><font size="+2"> </font><font size="3">PCI-Bus Receiver (6039 GPS/DCF77)</font></font></h1>
+               <hr>
+               <div align="center">
+                       <center>
+                               <table width="100%">
+                                       <tr>
+                                               <td width="50%">
+                                                       <h2><font size="+1">Synopsis</font></h2>
+                                                       <table bgcolor="#C0C0C0">
+                                                               <tr>
+                                                                       <td height="21">
+                                                                               <div align="right">
+                                                                                       <tt>Address:&nbsp;&nbsp;</tt></div>
+                                                                       </td>
+                                                                       <td height="21"><b>127.127.39.<i>X</i></b></td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td height="21">
+                                                                               <div align="right">
+                                                                                       <tt>Reference ID:&nbsp;&nbsp;</tt></div>
+                                                                       </td>
+                                                                       <td height="21"><a name="REFID"></a><b>.hopf. </b>(default)<b>, GPS, DCF</b></td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td height="21">
+                                                                               <div align="right">
+                                                                                       <tt>Driver ID:&nbsp;&nbsp;</tt></div>
+                                                                       </td>
+                                                                       <td height="21"><b>HOPF_P</b></td>
+                                                               </tr>
+                                                       </table>
+                                               </td>
+                                               <td align="center" valign="middle"><font face="Arial"><i><blink><font size="5"><img src="../pic/fg6039.jpg" alt="gif" height="140" width="141" border="0"></font></blink></i></font></td>
+                                       </tr>
+                               </table>
+                       </center>
+               </div>
+               <hr>
+               <h2><font size="+1">Description</font></h2>
+               The <b>refclock_hopf_pci </b>driver supports the <a href="http://www.hopf.com">hopf</a> PCI-bus interface 6039 GPS/DCF77.<br>
+               Additional software and information about the software drivers maybe available from: <a href="http://www.ATLSoft.de/ntp">http://www.ATLSoft.de/ntp</a>.<br>
+               Latest NTP driver source, executables and documentation is maintained at: <a href="http://www.ATLSoft.de/ntp">http://www.ATLSoft.de/ntp</a>
+               <hr>
+               <h2><font size="+1">Operating System Compatibility</font></h2>
+               <p align="left">The hopf clock driver has been tested on the following software and hardware platforms:<br>&nbsp;</p>
+               <table bgcolor="#C0C0C0">
+                       <tr>
+                               <td valign="CENTER" nowrap width="23%">
+                                       <p align="left"><b>Platform</b></p>
+                               </td>
+                               <td valign="CENTER" nowrap>
+                                       <p align="left"><b>Operating System</b></p>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td valign="CENTER" nowrap width="23%">
+                                       <p align="left">i386 (PC)&nbsp;</p>
+                               </td>
+                               <td valign="CENTER" nowrap>
+                                       <p align="left">Linux</p>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td nowrap>
+                                       <p align="left">i386 (PC)&nbsp;</p>
+                               </td>
+                               <td nowrap>
+                                       <p align="left">Windows NT</p>
+                               </td>
+                       </tr>
+                       <tr>
+                               <td nowrap>
+                                       <p align="left">i386 (PC)&nbsp;</p>
+                               </td>
+                               <center>
+                                       <td nowrap>Windows 2000</td>
+                               </center>
+                       </tr>
+               </table>
+               <hr>
+               <h2><font size="+1">O/S System Configuration</font></h2>
+               <p><b>UNIX</b></p>
+               The driver attempts to open the device <b><tt><a href="#REFID">/dev/hopf6039</a></tt></b> . The device entry will be made by the installation process of the kernel module for the PCI-bus board. The driver sources belongs to the delivery equipment of the PCI-board.
+               <p><b>Windows NT/2000</b></p>
+               <p>The driver attempts to open the device by calling the function &quot;OpenHopfDevice()&quot;. This function will be installed by the Device Driver for the PCI-bus board. The driver belongs to the delivery equipment of the PCI-board.</p>
+               <hr>
+               <h2><font size="+1">Fudge Factors</font></h2>
+               <dl>
+                       <dt><tt><font size="+1"><a href="#REFID"><b>refid <i>string</i></b></a></font></tt>
+                       <dd>Specifies the driver reference identifier, <b>GPS </b><i>or</i> <b>DCF</b>.
+                       <dt><tt><font size="+1"><b>flag1 0 | 1</b></font></tt>
+                       <dd>When set to 1, driver sync's even if only crystal driven.
+               </dl>
+               <hr>
+               <h3>Questions or Comments:</h3>
+               <p><a href="mailto:altmeier@atlsoft.de">Bernd Altmeier</a><a href="http://www.ATLSoft.de"><br>Ing.-B&uuml;ro f&uuml;r Software www.ATLSoft.de</a></p>
+               <p>(last updated 03/02/2001)<br>&nbsp;</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver4.html b/html/drivers/driver4.html
new file mode 100644 (file)
index 0000000..bda4a10
--- /dev/null
@@ -0,0 +1,66 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Spectracom 8170 and Netclock/2 WWVB Receivers</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Spectracom 8170 and Netclock/2 WWVB Receivers</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               Address: 127.127.4.<i>u</i><br>
+               Reference ID: <tt>WWVB</tt><br>
+               Driver ID: <tt>WWVB_SPEC</tt><br>
+               Serial Port: <tt>/dev/wwvb<i>u</i></tt>; 9600 baud, 8-bits, no parity<br>
+               Features: <tt>tty_clk</tt>
+               <h4>Description</h4>
+               <p>This driver supports all known Spectracom radio and satellite clocks, including the Model 8170 and Netclock/2 WWVB Synchronized Clocks and the Netclock/GPS GPS Master Clock. The claimed accuracy of the WWVB clocks is 100 usec relative to the broadcast signal. These clocks have proven a reliable source of time, except in some parts of the country with high levels of conducted RF interference. WIth the GPS clock the claimed accuracy is 130 ns. However, in most cases the actual accuracy is limited by the precision of the timecode and the latencies of the serial interface and operating system.</p>
+               <p>The DIPswitches on these clocks should be set to 24-hour display, AUTO DST off, data format 0 or 2 (see below) and baud rate 9600. If this clock is used as the source for the IRIG Audio Decoder (<tt>refclock_irig.c</tt> in this distribution), set the DIPswitches for AM IRIG output and IRIG format 1 (IRIG B with signature control).</p>
+               <p>There are two timecode formats used by these clocks. Format 0, which is available with all clocks, and format 2, which is available with all clocks except the original (unmodified) Model 8170.</p>
+               <p>Format 0 (22 ASCII printing characters):<br>
+                       &lt;cr&gt;&lt;lf&gt;i ddd hh:mm:ss TZ=zz&lt;cr&gt;&lt;lf&gt;</p>
+               <p>on-time = first &lt;cr&gt;<br>
+                       i = synchronization flag (' ' = in synch, '?' = out synch)<br>
+                       hh:mm:ss = hours, minutes, seconds</p>
+               <p>The alarm condition is indicated by other than ' ' at <tt>i</tt>, which occurs during initial synchronization and when received signal is lost for about ten hours.</p>
+               <p>Format 2 (24 ASCII printing characters):<br>
+                       lt;cr&gt;lf&gt;iqyy ddd hh:mm:ss.fff ld</p>
+               <p>on-time = &lt;cr&gt;<br>
+                       i = synchronization flag (' ' = in synch, '?' = out synch)<br>
+                       q = quality indicator (' ' = locked, 'A'...'D' = unlocked)<br>
+                       yy = year (as broadcast)<br>
+                       ddd = day of year<br>
+                       hh:mm:ss.fff = hours, minutes, seconds, milliseconds</p>
+               <p>The alarm condition is indicated by other than ' ' at <tt>i</tt>, which occurs during initial synchronization and when received signal is lost for about ten hours. The unlock condition is indicated by other than ' ' at <tt>q</tt>.</p>
+               <p>The <tt>q</tt> is normally ' ' when the time error is less than 1 ms and a character in the set <tt>A...D</tt> when the time error is less than 10, 100, 500 and greater than 500 ms respectively. The <tt>l</tt> is normally ' ', but is set to <tt>L</tt> early in the month of an upcoming UTC leap second and reset to ' ' on the first day of the following month. The <tt>d</tt> is set to <tt>S</tt> for standard time <tt>S</tt>, <tt>I</tt> on the day preceding a switch to daylight time, <tt>D</tt> for daylight time and <tt>O</tt> on the day preceding a switch to standard time. The start bit of the first &lt;cr&gt; is synchronized to the indicated time as returned.</p>
+               <p>This driver does not need to be told which format is in use - it figures out which one from the length of the message. A three-stage median filter is used to reduce jitter and provide a dispersion measure. The driver makes no attempt to correct for the intrinsic jitter of the radio itself, which is a known problem with the older radios.</p>
+               <h4>Monitor Data</h4>
+               <p>The driver writes each timecode as received to the <tt>clockstats</tt> file. When enabled by the <tt>flag4</tt> fudge flag, a table of quality data maintained internally by the Netclock/2 is retrieved and written to the <tt>clockstats</tt> file when the first timecode message of a new dayis received.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>WWVB</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Enable verbose <tt>clockstats</tt> recording if set.
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver40.html b/html/drivers/driver40.html
new file mode 100644 (file)
index 0000000..1901dcd
--- /dev/null
@@ -0,0 +1,189 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html lang="en">
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <meta http-equiv="Content-Script-Type" content="text/javascript">
+               <title>JJY Receivers</title>
+               <link rev="made" href="http://www.bea.hi-ho.ne.jp/abetakao/">
+               <link rel="start" href="http://www.eecis.udel.edu/~mills/ntp/html/refclock.html">
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>JJY Receivers</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               Address: 127.127.40.<em>u</em><br>
+               Reference ID: <code>JJY</code><br>
+               Driver ID: <code>JJY</code><br>
+               Serial Port: <code>/dev/jjy<em>u</em></code>; 9600|4800(See corresponding receiver) baud, 8-bits, no parity, 1 stop bit
+               <h4>Description</h4>
+               <p>This driver supports the following JJY receivers sold in Japan.</p>
+               <ul>
+                       <li>Tristate Ltd. JJY01 <a href="http://www.tristate.ne.jp/">http://www.tristate.ne.jp/</a> (Japanese only)<br>
+                               <dl>
+                                       <dt>NTP configuration ( ntp.conf )</dt>
+                                       <dd>
+                                               <p>server &nbsp; 127.127.40.X &nbsp; mode 1</p>
+                                               <br>
+                                       </dd>
+                                       <dt>RS-232C</dt>
+                                       <dd>
+                                               <p>9600 Baud</p>
+                                               <br>
+                                       </dd>
+                                       <dt>Time code format</dt>
+                                       <dd><br>
+                                               <table summary="CommandAndReply">
+                                                       <tr>
+                                                               <td>Command</td>
+                                                               <td>&nbsp;--&gt;&nbsp;</td>
+                                                               <td>Reply</td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td><code>date&lt;CR&gt;&lt;LF&gt;</code></td>
+                                                               <td>&nbsp;--&gt;&nbsp;</td>
+                                                               <td><code>YYYY/MM/DD WWW&lt;CR&gt;&lt;LF&gt;</code></td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td><code>stim&lt;CR&gt;&lt;LF&gt;</code></td>
+                                                               <td>&nbsp;--&gt;&nbsp;</td>
+                                                               <td><code>HH:MM:SS&lt;CR&gt;&lt;LF&gt;</code></td>
+                                                       </tr>
+                                               </table>
+                                               <br>
+                                       </dd>
+                               </dl>
+                       <li>C-DEX Co.,Ltd. JST2000 <a href="http://www.c-dex.co.jp/">http://www.c-dex.co.jp/</a> (Japanese only)<br>
+                               <dl>
+                                       <dt>NTP configuration ( ntp.conf )</dt>
+                                       <dd>
+                                               <p>server &nbsp; 127.127.40.X &nbsp; mode 2</p>
+                                               <br>
+                                       </dd>
+                                       <dt>RS-232C</dt>
+                                       <dd>
+                                               <p>9600 Baud</p>
+                                               <br>
+                                       </dd>
+                                       <dt>Time code format</dt>
+                                       <dd><br>
+                                               <table summary="CommandAndReply">
+                                                       <tr>
+                                                               <td>Command</td>
+                                                               <td>&nbsp;--&gt;&nbsp;</td>
+                                                               <td>Reply</td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td><code>&lt;ENQ&gt;1J&lt;ETX&gt;</code></td>
+                                                               <td>&nbsp;--&gt;&nbsp;</td>
+                                                               <td><code>&lt;STX&gt;JYYMMDD HHMMSSS&lt;ETX&gt;</code></td>
+                                                       </tr>
+                                               </table>
+                                               <br>
+                                       </dd>
+                               </dl>
+                       <li>
+                               <p>Echo Keisokuki Co.,Ltd. LT-2000 <a href="http://www.clock.co.jp/">http://www.clock.co.jp/</a> (Japanese only)</p>
+                               <dl>
+                                       <dt>NTP configuration ( ntp.conf )</dt>
+                                       <dd>
+                                               <p>server &nbsp; 127.127.40.X &nbsp; mode 3</p>
+                                               <br>
+                                       </dd>
+                                       <dt>RS-232C</dt>
+                                       <dd>
+                                               <p>9600 Baud</p>
+                                               <br>
+                                       </dd>
+                                       <dt>Time code format</dt>
+                                       <dd><br>
+                                               <table summary="CommandAndReply">
+                                                       <tr>
+                                                               <td>Command</td>
+                                                               <td>&nbsp;--&gt;&nbsp;</td>
+                                                               <td>Reply</td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td><code>C</code></td>
+                                                               <td>&nbsp;--&gt;&nbsp;</td>
+                                                               <td>( Mode 2 : Continuous )</td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td>( Every second before 0.5 second )</td>
+                                                               <td></td>
+                                                               <td><code>YYMMDDWHHMMSS&lt;ST1&gt;&lt;ST2&gt;&lt;ST3&gt;&lt;ST4&gt;&lt;CR&gt;</code></td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td><code>#</code></td>
+                                                               <td>&nbsp;--&gt;&nbsp;</td>
+                                                               <td>( Mode 1 : Request&amp;Send )</td>
+                                                       </tr>
+                                               </table>
+                                               <br>
+                                       </dd>
+                               </dl>
+                       <li>
+                               <p>CITIZEN T.I.C. CO.,LTD. JJY-200 <a href="http://www.tic-citizen.co.jp/">http://www.tic-citizen.co.jp/</a> (Japanese only)</p>
+                               <dl>
+                                       <dt>NTP configuration ( ntp.conf )</dt>
+                                       <dd>
+                                               <p>server &nbsp; 127.127.40.X &nbsp; mode 4</p>
+                                               <br>
+                                       </dd>
+                                       <dt>RS-232C</dt>
+                                       <dd>
+                                               <p>4800 Baud</p>
+                                               <br>
+                                       </dd>
+                                       <dt>Time code format</dt>
+                                       <dd><br>
+                                               <table summary="CommandAndReply">
+                                                       <tr>
+                                                               <td>Command</td>
+                                                               <td>&nbsp;--&gt;&nbsp;</td>
+                                                               <td>Reply</td>
+                                                       </tr>
+                                                       <tr>
+                                                               <td>( Every second )</td>
+                                                               <td></td>
+                                                               <td><code>'XX YY/MM/DD W HH:MM:SS&lt;CR&gt;</code></td>
+                                                       </tr>
+                                               </table>
+                                               <br>
+                                       </dd>
+                               </dl>
+               </ul>
+               <p>JJY is the radio station which transmites the JST (Japan Standard Time) in long wave radio. The station JJY is operated by the National Institute of Information and Communications Technology. An operating announcement and some information are avaiable from <a href="http://www.nict.go.jp/">http://www.nict.go.jp/</a> (English and Japanese) and <a href="http://jjy.nict.go.jp/">http://jjy.nict.go.jp/</a> (English and Japanese)</p>
+               <p>The user is expected to provide a symbolic link to an available serial port device. This is typically performed by a command such as:</p>
+               <p><code>ln -s /dev/ttyS0 /dev/jjy0</code></p>
+               <p>Windows NT does not support symbolic links to device files. COM<em>X</em>: is the unit used by the driver, based on the refclock unit number, where unit 1 corresponds to COM1: and unit 3 corresponds to COM3:</p>
+               <h4>Monitor Data</h4>
+               <p>The driver writes each timecode as received to the <code>clockstats</code> file.</p>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><code>time1 <em>time</em></code>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><code>time2 <em>time</em></code>
+                       <dd>Not used by this driver.
+                       <dt><code>stratum <em>number</em></code>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><code>refid <em>string</em></code>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <code>JJY</code>.
+                       <dt><code>flag1 0 | 1</code>
+                       <dd>Not used by this driver.
+                       <dt><code>flag2 0 | 1</code>
+                       <dd>Not used by this driver.
+                       <dt><code>flag3 0 | 1</code>
+                       <dd>Not used by this driver.
+                       <dt><code>flag4 0 | 1</code>
+                       <dd>Not used by this driver.
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/drivers/driver42.html b/html/drivers/driver42.html
new file mode 100644 (file)
index 0000000..7082050
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Zyfer GPStarplus Receiver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Zyfer GPStarplus Receiver</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               Address: 127.127.42.<i>u</i><br>
+               Reference ID: <tt>GPS</tt><br>
+               Driver ID: <tt>Zyfer GPStarplus</tt><br>
+               Serial Port: <tt>/dev/zyfer<i>u</i></tt>; 9600 baud, 8-bits, no parity<br>
+               Features: <tt>(none)</tt>
+               <h4>Description</h4>
+               <p>This driver supports the <a href="http://www.zyfer.com/">Zyfer GPStarplus</a> receiver.</p>
+               <p>The receiver has a DB15 port on the back which has input TxD and RxD lines for configuration and control, and a separate TxD line for the once-per-second timestamp.</p>
+               <p>Additionally, there are BNC connectors on the back for things like PPS and IRIG output.</p>
+               <h4>Additional Information</h4>
+               <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver43.html b/html/drivers/driver43.html
new file mode 100644 (file)
index 0000000..0e1553f
--- /dev/null
@@ -0,0 +1,65 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>RIPE NCC interface for Trimble Palisade</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>RIPE NCC interface for Trimble Palisade</h3>
+               <hr>
+               <img src="../pic/driver43_2.jpg" alt="Trimble Acutime 2000" align="right">
+               <h4>Synopsis</h4>
+               Address: 127.127.43.<i>u</i><br>
+               Reference ID: <tt>RIPENCC</tt><br>
+               Driver ID: <tt>RIPENCC</tt>
+               <h4>Description</h4>
+               <p>This is a special driver developed to be used in conjuction with the RIPE NCC clock card in the RIPE NCC Test Traffic Measurements project.</p>
+               <h4>Why this driver?</h4>
+               <p>The reason why we created a seperated driver for an antenna for which already a (vendor supplied) driver exist is a design decision. To be more specific, the standard Trimble interface uses a 12 pin connector. The cable sold by Trimble to connect to this wire is a very thick cable. Certainly not something you wish to run for several 100 meters through your building. And if you wanted to run it for 100 meters, you always would have to really run the cable, and didn't have the option to use existing wiring.<br>
+               </p>
+               <p>This is where we wanted more flexibility. We wanted to be able to use existing wiring in buildings. That leaded us to CAT-5(UTP) which only gives us 8 wires. Therefor we decided to redesing the use of the Trimble antenna. The Trimble supports two modes: EVENT driver and PPS mode. The default is to use the EVENT mode which needs all 12 wires. We only use the PPS timestamps for which we have enough with 8 wires. For our purposes this is more than fine.</p>
+               More information about the project can be found on the <a href="http://www.ripe.net/test-traffic" target="_new">Test Traffic Measurements</a> website. <img src="../pic/driver43_1.gif" alt="RIPE NCC clock card" align="right">
+               <h4>RIPE NCC clock card</h4>
+               <p>The card is very a simple PCI card. The only feature on the bus it uses is the power supply. It uses this power supply to power the Trimble GPS antenna.</p>
+               <p>The card basicly just is a RS422 to RS232 converter. It gets the Trimble's RS422 signal on a RJ45 connector and transforms that to RS232 on a DIN9 connector. This connector should be loopbacked on the back of the machine to the serial port. As said, the card doesn't do any PCI data transfers.</p>
+               <p>The schematics of the interface card is available here: <a href="http://www.ripe.net/projects/ttm/Host_testbox/gps_if.pdf">gps_interface_schematic.pdf</a>. You are free to create this card yourself as long as you give some credit or reference to us. Note that we don't sell these cards on a commercial basis, but for interested parties we do have some spares to share.</p>
+               <p></p>
+               <h4>Monitor Data</h4>
+               <p>In the <tt>filegen clockstats</tt> file the following (example) data is collected:</p>
+               <pre>
+52445 41931.275 127.127.40.0 U1 20.6.2002 11:38:51 13 11
+52445 41931.395 127.127.40.0 C1 20062002 113851 6  364785 110.2 450 6.7 13 5222.374737 N 0453.268013 E 48  7 11 0 1 -14 20 0 -25
+52445 41931.465 127.127.40.0 S1 07 1 1 02 59.3 291.5 39.3
+52445 41931.485 127.127.40.0 S1 11 2 1 02 59.9 138.0 60.2
+52445 41931.525 127.127.40.0 S1 01 4 1 02 48.4 185.7 28.3
+52445 41931.555 127.127.40.0 S1 14 5 2 02 32.7  41.0 15.4
+52445 41931.585 127.127.40.0 S1 20 6 1 02 59.9 256.6 78.0
+52445 41931.615 127.127.40.0 S1 25 8 2 00  0.0  86.6 20.1
+</pre>
+               <p>This is in the form of:</p>
+               <pre>
+All output lines consist of a prefix and a message, the prefix is:
+[days since epoch] [sec.ms since start of day] [peer address] 
+
+And all individual messages:
+
+*Primary UTC time packet:
+U1 [date] [time] [trackstat] [utcflags]
+
+*Comprehensive time packet:
+C1 [date] [time] [mode] [bias] [biasunc] [rate] [rateunc] [utcoff] [latitude] [longtitude] [alt] [vis sat](x8)
+
+*Tracking status packet:
+S1 [prn] [channel] [aqflag] [ephstat] [snr] [azinuth] [elevation]
+</pre>
+               <h4>Additional Information</h4>
+               <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver44.html b/html/drivers/driver44.html
new file mode 100644 (file)
index 0000000..d2cddb9
--- /dev/null
@@ -0,0 +1,88 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">\r
+
+<html>\r
+
+       <head>
+               <title>NeoClock4X</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+       </head>
+
+       <body>
+               <h1>NeoClock4X - DCF77 / TDF serial line receiver<br>
+               </h1>
+               <hr size="2" width="100%">
+               <h2>Synopsis</h2>
+               <table width="100%">
+                       <tbody>
+                               <tr>
+                                       <td valign="top">
+                                               <table width="100%">
+                                                       <tbody>
+                                                               <tr>
+                                                                       <td valign="top">Adress<br>
+                                                                       </td>
+                                                                       <td valign="top">127.127.44.u<br>
+                                                                       </td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td valign="top">Reference ID<br>
+                                                                       </td>
+                                                                       <td valign="top">neol<br>
+                                                                       </td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td valign="top">Driver ID<br>
+                                                                       </td>
+                                                                       <td valign="top">NEOCLK4X<br>
+                                                                       </td>
+                                                               </tr>
+                                                               <tr>
+                                                                       <td valign="top">Serial Port<br>
+                                                                       </td>
+                                                                       <td valign="top">/dev/neoclock4x-u<br>
+                                                                       </td>
+                                                               </tr>
+                                                       </tbody>
+                                               </table>
+                                               <br>
+                                       </td>
+                                       <td align="right" valign="top"><a href="http://www.linum.com"><img src="../pic/neoclock4x.gif" alt="NeoClock4X - DCF77 receiver" height="195" width="150"> </a><br>
+                                       </td>
+                               </tr>
+                       </tbody>
+               </table>
+               <hr size="2" width="100%">
+               <h2>Description</h2>
+               The refclock_neoclock4x driver supports the NeoClock4X receiver available from <a href="http://www.linum.com">Linum Software GmbH</a>. The receiver is available as a <a href="http://www.dcf77.de">DCF77</a> or TDF receiver. Both receivers have the same output string. For more information about the NeoClock4X receiver please visit <a href="http://www.linux-funkuhr.de">http://www.linux-funkuhr.de</a>. &nbsp;
+               <hr size="2" width="100%">
+               <h2>Fudge Factors</h2>
+               <dl>
+                       <dt><b><a href="../clockopt.html">time1 time</a></b>
+                       <dd>Specifies the time offset calibration factor with the default value off 0.16958333 seconds. This offset is used&nbsp; to correct serial line and operating system delays incurred in capturing time stamps. If you want to fudge the time1 offset <b>ALWAYS</b> add a value off 0.16958333. This is neccessary to compensate to delay that is caused by transmit the timestamp at 2400 Baud. If you want to compensate the delay that the DCF77 or TDF radio signal takes to travel to your site simply add the needed millisecond delay to the given value. Note that the time here is given in seconds.
+                       <dd>Default setting is 0.16958333 seconds.<br>
+               </dl>
+               <dl>
+                       <dt><b><a href="../clockopt.html">time2 time</a></b>
+                       <dd>Not used by this driver.
+               </dl>
+               <dl>
+                       <dt><a href="../clockopt.html"><b>flag1 0 | 1</b></a>
+                       <dd>When set to 1 the driver will feed ntp with timestampe even if the radio signal is lost. In this case an internal backup clock generates the timestamps. This is ok as long as the receiver is synced once since the receiver is able to keep time for a long period.
+                       <dd>Default setting is 0 = don't synchronize to CMOS clock.
+                       <dt><a href="../clockopt.html"><b>flag2 0 | 1</b></a>
+                       <dd>You can allow the NeoClock4X driver to use the quartz clock even if it is never synchronized to a radio clock. This is usally not a good idea if you want preceise timestamps since the CMOS clock is maybe not adjusted to a dst status change. So <b>PLEASE</b> switch this only on if you now what you're doing.
+                       <dd>Default setting is 0 = don't synchronize to unsynchronized CMOS clock.
+                       <dt><a href="../clockopt.html"><b>flag3 0 | 1</b></a>
+                       <dd>Not used by this driver.
+                       <dt><a href="../clockopt.html"><b>flag4 0 | 1</b></a>
+                       <dd>It is recommended to allow extensive logging while you setup the NeoClock4X receiver. If you activate flag4 every received data is logged. You should turn off flag4 as soon as the clock works as expected to reduce logfile cluttering.
+                       <dd>Default setting is 0 = don't log received data and converted utc time.
+               </dl>
+               <hr size="2" width="100%">
+               Please send any comments or question to <a href="mailto:neoclock4@linum.com">neoclock4x@linum.com</a>.
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver5.html b/html/drivers/driver5.html
new file mode 100644 (file)
index 0000000..1b539ac
--- /dev/null
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <title>TrueTime GPS/GOES/OMEGA Receivers</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>TrueTime GPS/GOES/OMEGA Receivers</h3>
+        <hr>
+        <h4>Synopsis</h4>
+        Address: 127.127.5.<i>u</i><br>
+        Reference ID: <tt>GPS, OMEGA, GOES</tt><br>
+        Driver ID: <tt>TRUETIME</tt><br>
+        Serial Port: <tt>/dev/true<i>u</i></tt>; 9600 baud, 8-bits, no parity<br>
+        Features: <tt>tty_clk</tt>
+        <h4>Description</h4>
+        <p>This driver supports several models models of Kinemetrics/TrueTime timing receivers, including 468-DC MK III GOES Synchronized Clock, GPS- DC MK III and GPS/TM-TMD GPS Synchronized Clock, XL-DC (a 151-602-210, reported by the driver as a GPS/TM-TMD), GPS-800 TCU (an 805-957 with the RS232 Talker/Listener module), OM-DC OMEGA Synchronized Clock, and very likely others in the same model family that use the same timecode formats.</p>
+        <p>Most of this code is originally from refclock_wwvb.c with thanks. It has been so mangled that wwvb is not a recognizable ancestor.</p>
+        <p>Timcode format: <tt>ADDD:HH:MM:SSQCL</tt> A - control A (this is stripped before we see it) Q - Quality indication (see below) C - Carriage return L - Line feed Quality codes indicate possible error of</p>
+        <dl>
+            <dt>468-DC GOES Receiver<br>
+                GPS-TM/TMD Receiver
+            <dd>? +/- 500 milliseconds # +/- 50 milliseconds<br>
+                * +/- 5 milliseconds . +/- 1 millisecond<br>
+                space less than 1 millisecond
+            <dt>OM-DC OMEGA Receiver:
+            <dd>&gt; +/- 5 seconds<br>
+                ? +/- 500 milliseconds # +/- 50 milliseconds<br>
+                * +/- 5 milliseconds . +/- 1 millisecond<br>
+                A-H less than 1 millisecond. Character indicates which station is being received as follows<br>
+                A = Norway, B = Liberia, C = Hawaii, D = North Dakota, E = La Reunion, F = Argentina, G = Australia, H = Japan<br>
+                The carriage return start bit begins on 0 seconds and extends to 1 bit time.
+        </dl>
+        <h4>Notes on 468-DC and OMEGA receiver:</h4>
+        <p>Send the clock a <tt>R</tt> or <tt>C</tt> and once per second a timestamp will appear. Send a <tt>R</tt> to get the satellite position once (GOES only).</p>
+        <h4>Notes on the 468-DC receiver:</h4>
+        <p>Since the old east/west satellite locations are only historical, you can't set your clock propagation delay settings correctly and still use automatic mode. The manual says to use a compromise when setting the switches. This results in significant errors. The solution; use fudge time1 and time2 to incorporate corrections. If your clock is set for 50 and it should be 58 for using the west and 46 for using the east, use the line</p>
+        <p><tt>fudge 127.127.5.0 time1 +0.008 time2 -0.004</tt></p>
+        <p>This corrects the 4 milliseconds advance and 8 milliseconds retard needed. The software will ask the clock which satellite it sees.</p>
+        <p>The PCL720 from PC Labs has an Intel 8253 look-alike, as well as a bunch of TTL input and output pins, all brought out to the back panel. If you wire a PPS signal (such as the TTL PPS coming out of a GOES or other Kinemetrics/Truetime clock) to the 8253's GATE0, and then also wire the 8253's OUT0 to the PCL720's INPUT3.BIT0, then we can read CTR0 to get the number of microseconds since the last PPS upward edge, mediated by reading OUT0 to find out if the counter has wrapped around (this happens if more than 65535us (65ms) elapses between the PPS event and our being called.)</p>
+        <h4>Monitor Data</h4>
+        <p>When enabled by the <tt>flag4</tt> fudge flag, every received timecode is written as-is to the <tt>clockstats</tt> file.</p>
+        <h4>Fudge Factors</h4>
+        <dl>
+            <dt><tt>time1 <i>time</i></tt>
+            <dd>Specifies the time offset calibration factor, in seconds and fraction, to be used for the West satellite, with default 0.0.
+            <dt><tt>time2 <i>time</i></tt>
+            <dd>. Specifies the time offset calibration factor, in seconds and fraction, to be used for the East satellite, with default 0.0.
+            <dt><tt>stratum <i>number</i></tt>
+            <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+            <dt><tt>refid <i>string</i></tt>
+            <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>TRUE</tt>.
+            <dt><tt>flag1 0 | 1</tt>
+            <dd>Silence the clock side of ntpd, just reading the clock without trying to write to it.
+            <dt><tt>flag2 0 | 1</tt>
+            <dd>Generate a debug file /tmp/true%d.
+            <dt><tt>flag3 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag4 0 | 1</tt>
+            <dd>Not used by this driver.
+        </dl>
+        <h4>Additional Information</h4>
+        <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver6.html b/html/drivers/driver6.html
new file mode 100644 (file)
index 0000000..8a51f16
--- /dev/null
@@ -0,0 +1,92 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>IRIG Audio Decoder</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>IRIG Audio Decoder</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               Address: 127.127.6.<i>u</i><br>
+               Reference ID: <tt>IRIG</tt><br>
+               Driver ID: <tt>IRIG_AUDIO</tt><br>
+               Audio Device: <tt>/dev/audio</tt> and <tt>/dev/audioctl</tt>
+               <p>Note: This driver supersedes an older one of the same name, address and ID which required replacing the original kernel audio driver with another which worked only on older Sun SPARC architectures and SunOS operating systems. The new driver requires no modification of the operating system and works on FreeBSD, SunOS and Solaris. While it is generic and likely portable to other systems, it is somewhat slower than the original, since the extensive signal conditioning, filtering and decoding is done in user space, not kernel space.</p>
+               <h4>Description</h4>
+               <p>This driver supports the Inter-Range Instrumentation Group (IRIG) standard time distribution signal using the audio codec native to some workstations. This signal is generated by several radio clocks, including those made by Arbiter, Austron, Bancomm, Odetics, Spectracom and TrueTime, among others, although it is often an add-on option. The signal is connected via an optional attenuator box and cable to either the microphone or line-in port. The driver receives, demodulates and decodes the IRIG-B and IRIG-E signal formats using internal filters designed to reduce the effects of noise and interference.</p>
+               <p>This driver incorporates several features in common with other audio drivers such as described in the <a href="driver7.html">Radio CHU Audio Demodulator/Decoder</a> and the <a href="driver36.html">Radio WWV/H Audio Demodulator/Decoder</a> pages. They include automatic gain control (AGC), selectable audio codec port and signal monitoring capabilities. For a discussion of these common features, as well as a guide to hookup, debugging and monitoring, see the <a href="../audio.html">Reference Clock Audio Drivers</a> page.</p>
+               <p>The IRIG signal format uses an amplitude-modulated carrier with pulse-width modulated data bits. For IRIG-B, the carrier frequency is 1000 Hz and bit rate 100 b/s; for IRIG-E, the carrier frequenchy is 100 Hz and bit rate 10 b/s. While IRIG-B provides the best accuracy, generally within a few tens of microseconds relative to IRIG time, it can also generate a significant load on the processor with older workstations. Generally, the accuracy with IRIG-E is about ten times worse than IRIG-B, but the processor load is ten times less.</p>
+               <p>The program processes 8000-Hz <font face="symbol">m</font>-law companded samples using separate signal filters for IRIG-B and IRIG-E, a comb filter, envelope detector and automatic threshold corrector. Cycle crossings relative to the corrected slice level determine the width of each pulse and its value - zero, one or position identifier. The data encode 20 BCD digits which determine the second, minute, hour and day of the year and sometimes the year and synchronization condition. The comb filter exponentially averages the corresponding samples of successive baud intervals in order to reliably identify the reference carrier cycle. A type-II phase-lock loop (PLL) performs additional integration and interpolation to accurately determine the zero crossing of that cycle, which determines the reference timestamp. A pulse-width discriminator demodulates the data pulses, which are then encoded as the BCD digits of the timecode. The timecode and reference timestamp are updated once each second with IRIG-B (ten seconds with IRIG-E) and local clock offset samples saved for later processing. At poll intervals of 64 s, the saved samples are processed by a trimmed-mean filter and used to update the system clock.</p>
+               <p>Infinite impulse response (IIR) filters are used with both IRIG-B and IRIG-E formats. An 800-Hz highpass filter is used for IRIG-B and a 130-Hz lowpass filter for IRIG-E. These are intended for use with noisy signals, such as might be received over a telephone line or radio circuit, or when interfering signals may be present in the audio passband. The driver determines which IRIG format is in use by sampling the amplitude of each filter output and selecting the one with maximum signal. An automatic gain control feature provides protection against overdriven or underdriven input signal amplitudes. It is designed to maintain adequate demodulator signal amplitude while avoiding occasional noise spikes. In order to assure reliable capture, the decompanded input signal amplitude must be greater than 100 units and the codec sample frequency error less than 250 PPM (.025 percent).</p>
+               <p>The program performs a number of error checks to protect against overdriven or underdriven input signal levels, incorrect signal format or improper hardware configuration. The specific checks are detailed later in this page. Note that additional checks are done elsewhere in the reference clock interface routines.</p>
+               <p>Unlike other drivers, which can have multiple instantiations, this one supports only one. It does not seem likely that more than one audio codec would be useful in a single machine. More than one would probably chew up too much CPU time anyway.</p>
+               <h4>IRIG-B Timecode Format</h4>
+               <p>The 100 elements of the IRIG timecode are numbered from 0 through 99. Position identifiers occur at elements 0, 9, 19 and every ten thereafter to 99. The control function (CF) elements begin at element 50 (CF 1) and extend to element 78 (CF 27). The straight-binary-seconds (SBS) field, which encodes the seconds of the UTC day, begins at element 80 (CF 28) and extends to element 97 (CF 44). The encoding of elements 50 (CF 1) through 78 (CF 27) is device dependent. This driver presently decodes the CF elements, but does nothing with them.</p>
+               <p>Where feasible, the IRIG signal source should be operated with signature control so that, if the signal is lost or mutilated, the source produces an unmodulated signal, rather than possibly random digits. The driver will automatically reject the data and declare itself unsynchronized in this case. Some devices, in particular Spectracom radio/satellite clocks, provide additional year and status indication in the format:</p>
+               <pre>
+     Element   CF        Function
+     -------------------------------------
+     55        6         time sync status
+     60-63     10-13     BCD year units
+     65-68     15-18     BCD year tens
+</pre>
+               Other devices set these elements to zero.
+               <h4>Performance and Horror Stories</h4>
+               <p>The <font face="symbol">m</font>-law companded data format allows considerable latitude in signal levels; however, an automatic gain control (AGC) function is implemented to further compensate for varying input signal levels and to avoid signal distortion. For proper operation, the IRIG signal source should be configured for analog signal levels, NOT digital TTL levels.</p>
+               <p>The accuracy of the system clock synchronized to the IRIG-B source with this driver and the <tt>ntpd</tt> daemon is 10-20 <font face="symbol">m</font>s with a Sun UltraSPARC II running Solaris 2.6 and maybe twice that with a Sun SPARC IPC running SunOS 4.1.3. Be however acutely aware that the accuracy with Solaris 2.8 and presumably beyond has seriously degraded to the order of several milliseconds. The Sun kernel driver has a sawtooth modulation with amplitude over 5 ms peak-peak and period 5.5 s. The crafty IRIG&nbsp;driver uses a transverse filter to remove the modulation and something called a botttom-fisher to remove incidental positive spikes especially prevalent with Sun Blade 1000 and possibly other systems. The result is nominal accuracy and jitter something less than 0.5 ms, but the this is still far inferior to the performance with older systems.</p>
+               <p>The processor resources consumed by the daemon can be significant, ranging from about 1.2 percent on the faster UltraSPARC II to 38 percent on the slower SPARC IPC. However, the overall timing accuracy is limited by the resolution and stability of the CPU clock oscillator and the interval between clock corrections, which is 64 s with this driver. This performance, while probably the best that can be achieved by the daemon itself, can be improved with assist from the PPS discipline as described elsewhere in this documentation.</p>
+               <h4>Autotune</h4>
+               <p>The driver includes provisions to automatically tune the radio in response to changing radio propagation conditions throughout the day and night. The radio interface is compatible with the ICOM CI-V standard, which is a bidirectional serial bus operating at TTL levels. The bus can be connected to a serial port using a level converter such as the CT-17.</p>
+               <p>Each ICOM radio is assigned a unique 8-bit ID select code, usually expressed in hex format. To activate the CI-V interface, the <tt>mode</tt> keyword of the <tt>server</tt> configuration command specifies a nonzero select code in decimal format. A table of ID select codes for the known ICOM radios is given on the <a href="../audio.html">Reference Clock Audio Drivers</a> page. A missing <tt>mode</tt> keyword or a zero argument leaves the interface disabled.</p>
+               <p>If specified, the driver will attempt to open the device <tt>/dev/icom</tt> and, if successful will activate the autotune function and tune the radio to each operating frequency in turn while attempting to acquire minute sync from CHU. However, the driver is liberal in what it assumes of the configuration. If the <tt>/dev/icom</tt> link is not present or the open fails or the CI-V bus or radio is inoperative, the driver quietly gives up with no harm done.</p>
+               <h4>Monitor Data</h4>
+               The timecode format used for debugging and data recording includes data helpful in diagnosing problems with the IRIG signal and codec connections. With debugging enabled (-d on the ntpd command line), the driver produces one line for each timecode in the following format:
+               <p><tt>00 1 98 23 19:26:52 721 143 0.694 47 20 0.083 66.5 3094572411.00027</tt></p>
+               <p>The first field containes the error flags in hex, where the hex bits are interpreted as below. This is followed by the IRIG status indicator, year of century, day of year and time of day. The status indicator and year are not produced by some IRIG devices. Following these fields are the carrier amplitude (0-8100), codec gain (0-255), field phase (0-79), time constant (2-20), modulation index (0-1), carrier phase error (0&plusmn;0.5) and carrier frequency error (PPM). The last field is the on-time timestamp in NTP format. The fraction part is a good indicator of how well the driver is doing. With an UltrSPARC 30, this is normally within a few tens of microseconds relative to the IRIG-B signal and within a few hundred microseconds with IRIG-E.</p>
+               <p>The error flags are defined as follows in hex:</p>
+               <dl>
+                       <dt><tt>x01</tt>
+                       <dd>Low signal. The carrier amplitude is less than 100 units. This is usually the result of no signal or wrong input port.
+                       <dt><tt>x02</tt>
+                       <dd>Frequency error. The codec frequency error is greater than 250 PPM. This may be due to wrong signal format or (rarely) defective codec.
+                       <dt><tt>x04</tt>
+                       <dd>Modulation error. The IRIG modulation index is less than 0.5. This is usually the result of an overdriven codec, wrong signal format or wrong input port.
+                       <dt><tt>x08</tt>
+                       <dd>Frame synch error. The decoder frame does not match the IRIG frame. This is usually the result of an overdriven codec, wrong signal format or noisy IRIG signal. It may also be the result of an IRIG signature check which indicates a failure of the IRIG signal synchronization source.
+                       <dt><tt>x10</tt>
+                       <dd>Data bit error. The data bit length is out of tolerance. This is usually the result of an overdriven codec, wrong signal format or noisy IRIG signal.
+                       <dt><tt>x20</tt>
+                       <dd>Seconds numbering discrepancy. The decoder second does not match the IRIG second. This is usually the result of an overdriven codec, wrong signal format or noisy IRIG signal.
+                       <dt><tt>x40</tt>
+                       <dd>Codec error (overrun). The machine is not fast enough to keep up with the codec.
+               </dl>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>IRIG</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>Specifies the microphone port if set to zero or the line-in port if set to one. It does not seem useful to specify the compact disc player port.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>Enables audio monitoring of the input signal. For this purpose, the speaker volume must be set before the driver is started.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Enable verbose <tt>clockstats</tt> recording if set.
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver7.html b/html/drivers/driver7.html
new file mode 100644 (file)
index 0000000..8e050e7
--- /dev/null
@@ -0,0 +1,234 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Radio CHU Audio Demodulator/Decoder</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Radio CHU Audio Demodulator/Decoder</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               Address: 127.127.7.<i>u</i><br>
+               Reference ID: <tt>CHU</tt><br>
+               Driver ID: <tt>CHU</tt><br>
+               Modem Port: <tt>/dev/chu<i>u</i></tt>; 300 baud, 8-bits, no parity<br>
+               Autotune Port: <tt>/dev/icom</tt>; 1200/9600 baud, 8-bits, no parity<br>
+               Audio Device: <tt>/dev/chu_audio</tt> and <tt>/dev/audioctl</tt>
+               <h4>Description</h4>
+               <p>This driver synchronizes the computer time using data encoded in radio transmissions from Canadian time/frequency station CHU in Ottawa, Ontario. It replaces an earlier one, built by Dennis Ferguson in 1988, which required a special line discipline to preprocessed the signal. The new driver includes more powerful algorithms implemented directly in the driver and requires no preprocessing.</p>
+               <p>CHU transmissions are made continuously on 3330 kHz, 7335 kHz and 14670 kHz in upper sideband, compatible AM mode. An ordinary shortwave receiver can be tuned manually to one of these frequencies or, in the case of ICOM receivers, the receiver can be tuned automatically as propagation conditions change throughout the day and night. The performance of this driver when tracking the station is ordinarily better than 1 ms in time with frequency drift less than 0.5 PPM when not tracking the station.</p>
+               <p>While there are currently no known commercial CHU receivers, a simple but effective receiver/demodulator can be constructed from an ordinary shortwave receiver and Bell 103 compatible, 300-b/s modem or modem chip, as described on the <a href="../pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page. The driver can use the modem to receive the radio signal and demodulate the data or, if available, the driver can use the audio codec of the Sun workstation or another with compatible audio interface. In the latter case, the driver implements the modem using DSP routines, so the radio can be connected directly to either the microphone or line input port.</p>
+               <p>This driver incorporates several features in common with other audio drivers such as described in the <a href="driver36.html">Radio WWV/H Audio Demodulator/Decoder</a> and the <a href="driver6.html">IRIG Audio Decoder</a> pages. They include automatic gain control (AGC), selectable audio codec port and signal monitoring capabilities. For a discussion of these common features, as well as a guide to hookup, debugging and monitoring, see the <a href="../audio.html">Reference Clock Audio Drivers</a> page.</p>
+               <p>Ordinarily, the driver poll interval is set to 14 (about 4.5 h), although this can be changed with configuration commands. As long as the clock is set or verified at least once during this interval, the NTP algorithms will consider the source reachable and selectable to discipline the system clock. However, if this does not happen for eight poll intervals, the algorithms will consider the source unreachable and some other source will be chosen (if available) to discipline the system clock.</p>
+               <p>The decoding algorithms process the data using maximum-likelihood techniques which exploit the considerable degree of redundancy available in each broadcast message or burst. As described below, every character is sent twice and, in the case of format A bursts, the burst is sent eight times every minute. In the case of format B bursts, which are sent once each minute, the burst is considered correct only if every character matches its repetition in the burst. In the case of format A messages, a majority decoder requires at least six repetitions for each digit in the timecode and more than half of the repetitions decode to the same digit. Every character in every burst provides an independent timestamp upon arrival with a potential total of over 60 timestamps for each minute.</p>
+               <p>A timecode in the format described below is assembled when all bursts have been received in the minute. The timecode is considered valid and the clock set when at least one valid format B burst has been decoded and the above requirements are met. The <tt>yyyy</tt> year field in the timecode indicates whether a valid format B burst has been received. Upon startup, this field is initialized at zero; when a valid format B burst is received, it is set to the current Gregorian year. The <tt>q</tt> quality character field in the timecode indicates whether a valid timecode has been determined. If any of the high order three bits of this character are set, the timecode is invalid.</p>
+               <p>Once the clock has been set for the first time, it will appear reachable and selectable to discipline the system clock, even if the broadcast signal is lost. Since the signals are almost always available during some period of the day and the NTP clock discipline algorithms are designed to work well even in this case, it is unlikely that the system clock could drift more than a few tens of milliseconds during periods of signal loss. To protect against this most unlikely situation, if after four days with no signals, the clock is considered unset and resumes the synchronization procedure from the beginning.</p>
+               <p>The last three fields in the timecode are useful in assessing the quality of the radio channel during the most recent minute bursts were received. The <tt>bcnt</tt> field shows the number of format A bursts in the range 1-8. The <tt>dist</tt> field shows the majority decoder distance, or the minimum number of sample repetitions for each digit of the timecode in the range 0-16. The <tt>tsmp</tt> field shows the number of timestamps determined in the range 0-60. For a valid timecode, <tt>bcnt</tt> must be at least 3, <tt>dist</tt> must be greater than <tt>bcnt</tt> and <tt>tsmp</tt> must be at least 20.</p>
+               <h4>Program Operation</h4>
+               <p>The program consists of four major parts: the DSP modem, maximum likelihood UART, burst assembler and majority decoder. The DSP modem demodulates Bell 103 modem answer-frequency signals; that is, frequency-shift keyed (FSK) tones of 2225 Hz (mark) and 2025 Hz (space). This is done using a 4th-order IIR filter and limiter/discriminator with 500-Hz bandpass centered on 2125 Hz and followed by a FIR raised-cosine lowpass filter optimized for the 300-b/s data rate. Alternately, the driver can be compiled to delete the modem and input 300 b/s data directly from an external modem via a serial port.</p>
+               <p>The maximum likelihood UART is implemented using a set of eight 11-stage shift registers, one for each of eight phases of the 300-b/s bit clock. At each phase a new baseband signal value from the DSP modem is shifted into the corresponding register and the maximum and minimum over all 11 samples computed. This establishes a slice level midway between the maximum and minimum over all stages. For each stage, a signal level above this level is a mark (1) and below is a space (0). A quality metric is calculated for each register with respect to the slice level and the a-priori signal consisting of a mark bit (previous stop bit), space (start) bit, eight arbitrary information bits and the first of the two mark (stop) bits.</p>
+               <p>The shift registers are processed in round-robin order as each modem value arrives until one of them shows a valid framing pattern consisting of a mark bit, space bit, eight arbitrary data bits and a mark bit. When found, the data bits from the register with the best metric is chosen as the maximum likelihood character and the UART begins to process the next character.</p>
+               <p>The burst assembler processes characters either from the maximum likelihood UART or directly from the serial port as configured. A burst begins when a character is received and is processed after a timeout interval when no characters are received. If the interval between characters is greater than two characters, but less than the timeout interval, the burst is rejected as a runt and a new burst begun. As each character is received, a timestamp is captured and saved for later processing.</p>
+               <p>A valid burst consists of ten characters in two replicated five-character blocks. A format B block contains the year and other information in ten hexadecimal digits. A format A block contains the timecode in ten decimal digits, the first of which is a framing code (6). The burst assembler must deal with cases where the first character of a format A burst is lost or is noise. This is done using the framing code to correct the phase, either one character early or one character late.</p>
+               <p>The burst distance is incremented by one for each bit in the first block that matches the corresponding bit in the second block and decremented by one otherwise. In a format B burst the second block is bit-inverted relative to the first, so a perfect burst of five 8-bit characters has distance -40. In a format A block the two blocks are identical, so a perfect burst has distance +40. Format B bursts must be perfect to be acceptable; however, format A bursts, which are further processed by the majority decoder, are acceptable if the distance is at least 28.</p>
+               <p>Each minute of transmission includes eight format A bursts containing two timecodes for each second from 31 through 39. The majority decoder uses a decoding matrix of ten rows, one for each digit position in the timecode, and 16 columns, one for each 4-bit code combination that might be decoded at that position. In order to use the character timestamps, it is necessary to reliably determine the second number of each burst. In a valid burst, the last digit of the two timecodes in the block must match and the value must be in the range 2-9 and greater than in the previous burst.</p>
+               <p>As each hex digit of a valid burst is processed, the value at the row corresponding to the digit position in the timecode and column corresponding to the code found at that position is incremented. At the end of each minute of transmission, each row of the decoding matrix encodes the number of occurrences of each code found at the corresponding position of the timecode. However, the first digit (framing code) is always 6, the ninth (second tens) is always 3 and the last (second units) changes for each burst, so are not used.</p>
+               <p>The maximum over all occurrences at each timecode digit position is the distance for that position and the corresponding code is the maximum likelihood candidate. If the distance is zero, the decoder assumes a miss; if the distance is not more than half the total number of occurrences, the decoder assumes a soft error; if two different codes with the same distance are found, the decoder assumes a hard error. In all these cases the decoder encodes a non-decimal character which will later cause a format error when the timecode is reformatted. The decoding distance is defined as the minimum distance over the first nine digits; the tenth digit varies over the seconds and is uncounted.</p>
+               <p>The result of the majority decoder is a nine-digit timecode representing the maximum likelihood candidate for the transmitted timecode in that minute. Note that the second and fraction within the minute are always zero and that the actual reference point to calculate timestamp offsets is backdated to the first second of the minute. At this point the timecode block is reformatted and the year, days, hours and minutes extracted along with other information from the format B burst, including DST state, DUT1 correction and leap warning. The reformatting operation checks the timecode for invalid code combinations that might have been left by the majority decoder and rejects the entire timecode if found.</p>
+               <p>If the timecode is valid, it is passed to the reference clock interface along with the backdated timestamp offsets accumulated over the minute. A perfect set of nine bursts could generate as many as 90 timestamps, but the maximum the interface can handle is 60. These are processed by the interface using a median filter and trimmed-mean average, so the resulting system clock correction is usually much better than would otherwise be the case with radio noise, UART jitter and occasional burst errors.</p>
+               <h4>Autotune</h4>
+               <p>The driver includes provisions to automatically tune the radio in response to changing radio propagation conditions throughout the day and night. The radio interface is compatible with the ICOM CI-V standard, which is a bidirectional serial bus operating at TTL levels. The bus can be connected to a standard serial port using a level converter such as the CT-17.</p>
+               <p>Each ICOM radio is assigned a unique 8-bit ID select code, usually expressed in hex format. To activate the CI-V interface, the <tt>mode</tt> keyword of the <tt>server</tt> configuration command specifies a nonzero select code in decimal format. A table of ID select codes for the known ICOM radios is given below. Since all ICOM select codes are less than 128, the high order bit of the code is used by the driver to specify the baud rate. If this bit is not set, the rate is 9600 bps for the newer radios; if set, the rate is 1200 bps for the older radios. A missing <tt>mode</tt> keyword or a zero argument leaves the interface disabled.</p>
+               <p>If specified, the driver will attempt to open the device <tt>/dev/icom</tt> and, if successful will tune the radio to 3.330 MHz. If after five minutes at this frequency not more than two format A bursts have been received for any minute, the driver will tune to 7.335 MHz, then to 14.670 MHz, then return to 3.330 MHz and continue in this cycle. However, the driver is liberal in what it assumes of the configuration. If the <tt>/dev/icom</tt> link is not present or the open fails or the CI-V bus or radio is inoperative, the driver quietly gives up with no harm done.</p>
+               <h4>Radio Broadcast Format</h4>
+               <p>The CHU time broadcast includes an audio signal compatible with the Bell 103 modem standard (mark = 2225 Hz, space = 2025 Hz). It consist of nine, ten-character bursts transmitted at 300 b/s and beginning each second from second 31 to second 39 of the minute. Each character consists of eight data bits plus one start bit and two stop bits to encode two hex digits. The burst data consist of five characters (ten hex digits) followed by a repeat of these characters. In format A, the characters are repeated in the same polarity; in format B, the characters are repeated in the opposite polarity.</p>
+               <p>Format A bursts are sent at seconds 32 through 39 of the minute in hex digits</p>
+               <p><tt>6dddhhmmss6dddhhmmss</tt></p>
+               <p>The first ten digits encode a frame marker (<tt>6</tt>) followed by the day (<tt>ddd</tt>), hour (<tt>hh</tt>), minute (<tt>mm</tt>) and second (<tt>ss</tt>). Since format A bursts are sent during the third decade of seconds the tens digit of <tt>ss</tt> is always 3. The driver uses this to determine correct burst synchronization. These digits are then repeated with the same polarity.</p>
+               <p>Format B bursts are sent at second 31 of the minute in hex digits</p>
+               <p><tt>xdyyyyttaaxdyyyyttaa</tt></p>
+               <p>The first ten digits encode a code (<tt>x</tt> described below) followed by the DUT1 (<tt>d</tt> in deciseconds), Gregorian year (<tt>yyyy</tt>), difference TAI - UTC (<tt>tt</tt>) and daylight time indicator (<tt>aa</tt>) peculiar to Canada. These digits are then repeated with inverted polarity.</p>
+               <p>The <tt>x</tt> is coded</p>
+               <dl>
+                       <dt><tt>1</tt>
+                       <dd>Sign of DUT (0 = +)/dd&gt;
+                       <dt><tt>2</tt>
+                       <dd>Leap second warning. One second will be added.
+                       <dt><tt>4</tt>
+                       <dd>Leap second warning. One second will be subtracted. This is not likely to happen in our universe.
+                       <dt><tt>8</tt>
+                       <dd>Even parity bit for this nibble.
+               </dl>
+               <p>By design, the last stop bit of the last character in the burst coincides with 0.5 second. Since characters have 11 bits and are transmitted at 300 b/s, the last stop bit of the first character coincides with 0.5 - 10 * 11/300 = 0.133 second. Depending on the UART, character interrupts can vary somewhere between the beginning of bit 9 and end of bit 11. These eccentricities can be corrected along with the radio propagation delay using the <tt>fudge time1</tt> variable.</p>
+               <h4>Debugging Aids</h4>
+               <p>The most convenient way to track the program status is using the <tt>ntpq</tt> program and the <tt>clockvar</tt> command. This displays the last determined timecode and related status and error counters, even when the program is not discipline the system clock. If the debugging trace feature (<tt>-d</tt> on the <tt>ntpd</tt> command line)is enabled, the program produces detailed status messages as it operates. If the <tt>fudge flag 4</tt> is set, these messages are written to the <tt>clockstats</tt> file. All messages produced by this driver have the prefix <tt>chu</tt> for convenient filtering with the Unix <tt>grep</tt> command.</p>
+               <p>With debugging enabled the driver produces messages in the following formats:</p>
+               <p>A format <tt>chuA</tt> message is produced for each format A burst received in seconds 32 through 39 of the minute:</p>
+               <p><tt>chuA n b s code</tt></p>
+               <p>where <tt>n</tt> is the number of characters in the burst (0-11), <tt>b</tt> the burst distance (0-40), <tt>s</tt> the synchronization distance (0-40) and <tt>code</tt> the burst characters as received. Note that the hex digits in each character are reversed and the last ten digits inverted, so the burst</p>
+               <p><tt>11 40 1091891300ef6e76ecff</tt></p>
+               <p>is interpreted as containing 11 characters with burst distance 40. The nibble-swapped timecode shows DUT1 +0.1 second, year 1998 and TAI -UTC 31 seconds.</p>
+               <p>A format <tt>chuB</tt> message is produced for each format B burst received in second 31 of the minute:</p>
+               <p><tt>chuB n b f s m code</tt></p>
+               <p>where <tt>n</tt> is the number of characters in the burst (0-11), <tt>b</tt> the burst distance (0-40), <tt>f</tt> the field alignment (-1, 0, 1), <tt>s</tt>the synchronization distance (0-16), <tt>m</tt>the burst number (2-9) and <tt>code</tt> the burst characters as received. Note that the hex digits in each character are reversed, so the burst</p>
+               <p><tt>10 38 0 16 9 06851292930685129293</tt></p>
+               <p>is interpreted as containing 11 characters with burst distance 38, field alignment 0, synchronization distance 16 and burst number 9. The nibble-swapped timecode shows day 58, hour 21, minute 29 and second 39.</p>
+               <p>If the CI-V interface for ICOM radios is active, a debug level greater than 1 will produce a trace of the CI-V command and response messages. Interpretation of these messages requires knowledge of the CI-V protocol, which is beyond the scope of this document.</p>
+               <h4>Monitor Data</h4>
+               When enabled by the <tt>filegen</tt> facility, every received timecode is written to the <tt>clockstats</tt> file in the following format:
+               <pre>
+        sq yy ddd hh:mm:ss.fff ld dut lset agc rfrq bcnt dist tsmp
+
+        s       sync indicator
+        q       quality character
+        yyyy    Gregorian year
+        ddd     day of year
+        hh      hour of day
+        mm      minute of hour
+        ss      second of minute
+        fff     millisecond of second
+        l       leap second warning
+        d       DST state
+        dut     DUT sign and magnitude in deciseconds
+        lset    minutes since last set
+        agc     audio gain (0-255)
+        rfrq    radio frequency
+        bcnt    burst count
+        dist    decoding distance
+        tsmp    timestamps captured
+</pre>
+               The fields beginning with <tt>year</tt> and extending through <tt>dut</tt> are decoded from the received data and are in fixed-length format. The <tt>agc</tt> and <tt>lset</tt> fields, as well as the following driver-dependent fields, are in variable-length format.
+               <dl>
+                       <dt><tt>s</tt>
+                       <dd>The sync indicator is initially <tt>?</tt> before the clock is set, but turns to space when the clock is correctly set.
+                       <dt><tt>q</tt>
+                       <dd>The quality character is a four-bit hexadecimal code showing which alarms have been raised during the most recent minute. Each bit is associated with a specific alarm condition according to the following:
+                               <dl>
+                                       <dt><tt>8</tt>
+                                       <dd>Decoder alarm. A majority of repetitions for at least one digit of the timecode fails to agree.
+                                       <dt><tt>4</tt>
+                                       <dd>Timestamp alarm. Fewer than 20 timestamps have been determined.
+                                       <dt><tt>2</tt>
+                                       <dd>Format alarm. The majority timecode contains invalid bit combinations.
+                                       <dt><tt>1</tt>
+                                       <dd>Frame alarm. A framing or format error occurred on at least one burst during the minute.
+                               </dl>
+                               <p>It is important to note that one or more of the above alarms does not necessarily indicate a clock error, but only that the decoder has detected a condition that may in future result in an error.</p>
+                       <dt><tt>yyyy ddd hh:mm:ss.fff</tt>
+                       <dd>The timecode format itself is self explanatory. Note that the Gregorian year is decoded directly from the transmitted timecode.
+                       <dt><tt>l</tt>
+                       <dd>The leap second warning is normally space, but changes to <tt>L</tt> if a leap second is to occur at the end of the month of June or December.
+                       <dt><tt>d</tt>
+                       <dd>The DST code for Canada encodes the state for all provinces.
+                       <dt><tt>dut</tt>
+                       <dd>The DUT sign and magnitude shows the current UT1 offset relative to the displayed UTC time, in deciseconds.
+                       <dt><tt>lset</tt>
+                       <dd>Before the clock is set, the interval since last set is the number of minutes since the program was started; after the clock is set, this is number of minutes since the time was last verified relative to the broadcast signal.
+                       <dt><tt>agc</tt>
+                       <dd>The audio gain shows the current codec gain setting in the range 0 to 255. Ordinarily, the receiver audio gain control or IRIG level control should be set for a value midway in this range.
+                       <dt><tt>rfrq</tt>
+                       <dd>The current radio frequency, if the CI-V interface is active, or 'X' if not.
+                       <dt><tt>bcnt</tt>
+                       <dd>The number of format A bursts received during the most recent minute bursts were received.
+                       <dt><tt>dist</tt>
+                       <dd>The minimum decoding distance determined during the most recent minute bursts were received.
+                       <dt><tt>tsmp</tt>
+                       <dd>The number of timestamps determined during the most recent minute bursts were received.
+               </dl>
+               <h4>Modes</h4>
+               <p>The <tt>mode</tt> keyword of the <tt>server</tt> configuration command specifies the ICOM ID select code. A missing or zero argument disables the CI-V interface. Following are the ID select codes for the known radios.</p>
+               <table width="100%" cols="6">
+                       <tr>
+                               <td>Radio</td>
+                               <td>Hex</td>
+                               <td>Decimal</td>
+                               <td>Radio</td>
+                               <td>Hex</td>
+                               <td>Decimal</td>
+                       </tr>
+                       <tr>
+                               <td>IC725</td>
+                               <td>0x28</td>
+                               <td>40</td>
+                               <td>IC781</td>
+                               <td>0x26</td>
+                               <td>38</td>
+                       </tr>
+                       <tr>
+                               <td>IC726</td>
+                               <td>0x30</td>
+                               <td>48</td>
+                               <td>R7000</td>
+                               <td>0x08</td>
+                               <td>8</td>
+                       </tr>
+                       <tr>
+                               <td>IC735</td>
+                               <td>0x04</td>
+                               <td>4</td>
+                               <td>R71</td>
+                               <td>0x1A</td>
+                               <td>26</td>
+                       </tr>
+                       <tr>
+                               <td>IC751</td>
+                               <td>0x1c</td>
+                               <td>28</td>
+                               <td>R7100</td>
+                               <td>0x34</td>
+                               <td>52</td>
+                       </tr>
+                       <tr>
+                               <td>IC761</td>
+                               <td>0x1e</td>
+                               <td>30</td>
+                               <td>R72</td>
+                               <td>0x32</td>
+                               <td>50</td>
+                       </tr>
+                       <tr>
+                               <td>IC765</td>
+                               <td>0x2c</td>
+                               <td>44</td>
+                               <td>R8500</td>
+                               <td>0x4a</td>
+                               <td>74</td>
+                       </tr>
+                       <tr>
+                               <td>IC775</td>
+                               <td>0x46</td>
+                               <td>68</td>
+                               <td>R9000</td>
+                               <td>0x2a</td>
+                               <td>42</td>
+                       </tr>
+               </table>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the propagation delay for CHU (45:18N 75:45N), in seconds and fraction, with default 0.0.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>stratum <i>number</i></tt>
+                       <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+                       <dt><tt>refid <i>string</i></tt>
+                       <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>CHU</tt>.
+                       <dt><tt>flag1 0 | 1</tt>
+                       <dd>Not used by this driver.
+                       <dt><tt>flag2 0 | 1</tt>
+                       <dd>When the audio driver is compiled, this flag selects the audio input port, where 0 is the mike port (default) and 1 is the line-in port. It does not seem useful to select the compact disc player port.
+                       <dt><tt>flag3 0 | 1</tt>
+                       <dd>When the audio driver is compiled, this flag enables audio monitoring of the input signal. For this purpose, the speaker volume must be set before the driver is started.
+                       <dt><tt>flag4 0 | 1</tt>
+                       <dd>Enable verbose <tt>clockstats</tt> recording if set.
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/driver8.html b/html/drivers/driver8.html
new file mode 100644 (file)
index 0000000..fc12f33
--- /dev/null
@@ -0,0 +1,279 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Generic Reference Driver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Generic Reference Driver</h3>
+               <hr>
+               <h4>Synopsis</h4>
+               Address: 127.127.8.<i>u</i><br>
+               Reference ID: <tt>PARSE</tt><br>
+               Driver ID: <tt>GENERIC</tt><br>
+               Serial Port: <tt>/dev/refclock-<i>u</i></tt>; TTY mode according to clock type<br>
+                PPS device: <tt>/dev/refclockpps-<i>u</i></tt>; alternate PPS device (if not available via the serial port)
+               <h4>Description</h4>
+               The PARSE driver supports 20 different clock types/configurations. PARSE is actually a multi-clock driver.<br>
+               <br>
+               <p>The actual receiver status is mapped into various synchronization states generally used by receivers. The driver is configured to interpret the time codes of Meinberg DCF77 AM receivers, DCF77 FM receivers, Meinberg GPS16x/17x receivers, Trimble SV6 GPS, ELV DCF7000, Schmid, Wharton 400A and low cost receivers (see <a href="#clocklist">list below</a>).</p>
+               <p>The reference clock support in NTP contains the necessary configuration tables for those receivers. In addition to supporting several different clock types and up to 4 devices, the processing of a PPS signal is also provided as a configuration option. The PPS configuration option uses the receiver-generated time stamps for feeding the PPS loopfilter control for much finer clock synchronization.</p>
+               <p>CAUTION: The PPS configuration option is different from the hardware PPS signal, which is also supported (see below), as it controls the way ntpd is synchronized to the reference clock, while the hardware PPS signal controls the way time offsets are determined.</p>
+               <p>The use of the PPS option requires receivers with an accuracy of better than 1ms.</p>
+               <h4>Timecode variables listed by ntpq (8)</h4>
+               <p>The ntpq program can read and display several clock variables. These hold the following information:</p>
+               <dl>
+                       <dt><tt>refclock_format</tt></dt>
+                       <dd>A qualification of the decoded time code format.</dd>
+                       <dt><tt>refclock_states</tt></dt>
+                       <dd>The overall running time and the accumulated times for the clock event states.</dd>
+                       <dt><tt>refclock_status</tt></dt>
+                       <dd>Lists the currently active receiver flags. Additional feature flags for the receiver are optionally listed in parentheses.</dd>
+                       <dt><tt>refclock_time</tt></dt>
+                       <dd>The local time with the offset to UTC (format HHMM).</dd>
+                       <dt><tt>timecode</tt></dt>
+                       <dd>The actual time code.</dd>
+               </dl>
+               <p>If PPS information is present, additional variables are available:</p>
+               <dl>
+                       <dt><tt>refclock_ppsskew</tt></dt>
+                       <dd>The difference between the RS-232-derived timestamp and the PPS timestamp.</dd>
+                       <dt><tt>refclock_ppstime</tt></dt>
+                       <dd>The PPS timestamp.</dd>
+               </dl>
+               <h4>Supported Devices</h4>
+               <p>Currently, nineteen clock types (devices /dev/refclock-0 - /dev/refclock-3) are supported by the PARSE driver.<br>
+                       A note on the implementations:</p>
+               <ul>
+                       <li>These implementations were mainly done without actual access to the hardware, thus not all implementations provide full support. The development was done with the help of many kind souls who had the hardware and kindly lent me their time and patience during the development and debugging cycle. Thus for continued support and quality, direct access to the receivers is a big help. Nevertheless I am not prepared to buy these reference clocks - donations to (<a href="mailto:kardel <AT> ntp.org">kardel &lt;AT&gt; ntp.org</a>) are welcome as long as they work within Europe 8-).
+                               <p>Verified implementations are:</p>
+                               <ul>
+                                       <li>RAWDCF variants
+                                               <p>These variants have been tested for correct decoding with my own homegrown receivers. Interfacing with specific commercial products may involve some fiddling with cables. In particular, commercial RAWDCF receivers have a seemingly unlimited number of ways to draw power from the RS-232 port and to encode the DCF77 datastream. You are mainly on your own here unless I have a sample of the receiver.</p>
+                                       <li><a href="http://www.meinberg.de">Meinberg clocks</a>
+                                               <p>These implementations have been verified by the Meinberg people themselves and I have access to one of these clocks.</p>
+                               </ul>
+               </ul>
+               <p>The pictures below have been taken from and are linked to the vendors' web pages.</p>
+               <a name="clocklist"></a>
+               <ul>
+                       <li><b><tt>server 127.127.8.0-3 mode 0</tt></b>
+                               <p><b><tt><a href="http://www.meinberg.de">Meinberg</a> <a href="http://www.meinberg.de/english/products/timesource.htm#dcf---freq_sync">PZF5xx receiver family</a> (FM demodulation/TCXO / 50&mu;s)</tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 1</tt></b>
+                               <p><b><tt><a href="http://www.meinberg.de">Meinberg</a> <a href="http://www.meinberg.de/english/products/timesource.htm#dcf---freq_sync">PZF5xx receiver family</a> (FM demodulation/OCXO / 50&mu;s)</tt></b><br>
+                                       <a href="http://www.meinberg.de/english/products/pzf-eurocard.htm"><img src="../pic/pzf511.jpg" alt="Image PZF511" height="300" width="260" align="top" border="0"></a><br>
+                               <br></p>
+
+                       <li><a name="mode2"></a><b><tt>server 127.127.8.0-3 mode 2</tt></b>
+                               <p><b><tt><a href="http://www.meinberg.de">Meinberg</a> <a href="http://www.meinberg.de/english/products/c51.htm">DCF C51 receiver and similar</a> (AM demodulation / 4ms)</tt></b><br>
+                                       <a href="http://www.meinberg.de/english/products/c51.htm"><img src="../pic/c51.jpg" alt="Image C51" height="239" width="330" align="top"  border="0"></a><br>
+                               </p>
+                               <p>This mode expects the Meinberg standard time string format with 9600/7E2.</p>
+                               <p><b>Note:</b> mode 2 must also be used for <a href="http://www.meinberg.de/english/products/formfactor.htm#slot_card">Meinberg PCI cards</a> under Linux, e.g. <a href="http://www.meinberg.de/english/products/gps-pcicard.htm">the GPS PCI card</a> or <a href="http://www.meinberg.de/english/products/dcf-pcicard.htm">the DCF77 PCI card</a>. Please note the <a href="http://www.meinberg.de/english/sw/#linux">Meinberg Linux driver</a> must be installed. That driver emulates a refclock device in order to allow ntpd to access those cards. For details, please refer to the README file that comes with the Meinberg driver package.<br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 3</tt></b>
+                               <p><b><tt><a href="http://www.elv.de">ELV</a> DCF7000 (sloppy AM demodulation / 50ms)</tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 4</tt></b>
+                               <p><b><tt>Walter Schmid DCF receiver Kit (AM demodulation / 1ms)</tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 5</tt></b>
+                               <p><b><tt>RAW DCF77 100/200ms pulses (Conrad DCF77 receiver module / 5ms)</tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 6</tt></b>
+                               <p><b><tt>RAW DCF77 100/200ms pulses (TimeBrick DCF77 receiver module / 5ms)</tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 7</tt></b>
+                               <p><b><tt><a href="http://www.meinberg.de">Meinberg</a> <a href="http://www.meinberg.de/english/products/timesource.htm#gps---freq_sync">GPS16x/GPS17x receivers</a> (GPS / &lt;&lt;1&mu;s)</tt></b><br>
+                                       <a href="http://www.meinberg.de/english/products/gps-eurocard.htm"><img src="../pic/gps167.jpg" alt="Image GPS167" height="300" width="280" align="top" border="0"></a><br>
+                               </p>
+                               <p>This mode expects either the University of Erlangen time string format or the Meinberg standard time string format at 19200/8N1.</p>
+                               <p>The University of Erlangen format is preferred. Newer Meinberg GPS receivers can be configured to transmit that format; for older devices, a special firmware version may be available.</p>
+                               <p>In this mode some additional GPS receiver status information is also read. However, this requires a point-to-point connection. <a href="#mode18">Mode 18</a> should be used if the device is accessed by a multidrop connection.</p>
+                               <p><b>Note:</b> mode 7 must not be used with Meinberg PCI cards; use <a href="#mode2">mode 2</a> instead.<br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 8</tt></b>
+                               <p><b><tt><a href="http://www.igel.de">IGEL</a> <a href="http://www.igel.de/eigelmn.html">clock</a></tt></b><br>
+                                       <a href="http://www.igel.de/eigelmn.html"><img src="../pic/igclock.gif" alt="Image IGEL clock" height="174" width="200" border="0"></a><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 9</tt></b>
+                               <p><b><tt><a href="http://www.trimble.com">Trimble</a> <a href="http://www.trimble.com/cgi/omprod.cgi/pd_om011.html">SVeeSix GPS receiver</a> TAIP protocol (GPS / &lt;&lt;1&mu;s)</tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 10</tt></b>
+                               <p><b><tt><a href="http://www.trimble.com">Trimble</a> <a href="http://www.trimble.com/cgi/omprod.cgi/pd_om011.html">SVeeSix GPS receiver</a> TSIP protocol (GPS / &lt;&lt;1&mu;s) (no kernel support yet)</tt></b><br>
+                                       <a href="http://www.trimble.com/cgi/omprod.cgi/pd_om011.html"><img src="../pic/pd_om011.gif" alt="Image SVeeSix-CM3" height="100" width="420" align="top" border="0"></a><br>
+                                       <a href="http://www.trimble.com/cgi/omprod.cgi/pd_om006.html"><img src="../pic/pd_om006.gif" alt="Image Lassen-SK8" height="100" width="420" border="0"></a><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 11</tt></b>
+                               <p><b><tt>Radiocode Clocks Ltd RCC 8000 Intelligent Off-Air Master Clock support </tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 12</tt></b>
+                               <p><b><tt><a href="http://www.hopf-time.com">HOPF</a> <a href="http://www.hopf-time.com/kart6021.html">Funkuhr 6021</a></tt></b><br>
+                                       <a href="http://www.hopf-time.com/engl/kart6021.html"><img src="../pic/fg6021.gif" alt="Image DCF77 Interface Board" height="207" width="238" align="top" border="0"></a><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 13</tt></b>
+                               <p><b><tt>Diem's Computime Radio Clock</tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 14</tt></b>
+                               <p><b><tt>RAWDCF receiver (DTR=high/RTS=low)</tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 15</tt></b>
+                               <p><b><tt>WHARTON 400A Series Clocks with a 404.2 Serial Interface</tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 16</tt></b>
+                               <p><b><tt>RAWDCF receiver (DTR=low/RTS=high) </tt></b><br>
+                               <br></p>
+
+                       <li><b><tt>server 127.127.8.0-3 mode 17</tt></b>
+                               <p><b><tt>VARITEXT Receiver (MSF) </tt></b><br>
+                               <br></p>
+
+                       <li><a name="mode18"></a><b><tt>server 127.127.8.0-3 mode 18</tt></b>
+                               <p><b><tt><a href="http://www.meinberg.de">Meinberg </a><a href="http://www.meinberg.de/english/products/timesource.htm#gps---freq_sync">GPS16x/GPS17x receivers</a> (GPS / &lt;&lt;1&mu;s)</tt></b><br>
+                               </p>
+                               <p>This mode works without additional data communication (version, GPS status etc.) and thus should be used with multidrop, heterogeneous multiclient operation.</p>
+                               <p><b>Note:</b> mode 18 must not be used with Meinberg PCI cards, use mode 2 instead.<br>
+                               <br></p>
+                       <li><b><tt>server 127.127.8.0-3 mode 19</tt></b>
+                               <p><b><tt>Gude Analog- und Digitalsystem GmbH 'Expert mouseCLOCK USB v2.0'</tt></b><br>
+                               <br></p>
+
+               </ul>
+               <p>Actual data formats and setup requirements of the various clocks can be found in <a href="../parsedata.html">NTP PARSE clock data formats</a>.</p>
+               <h4>Operation</h4>
+               <p>The reference clock support software carefully monitors the state transitions of the receiver. All state changes and exceptional events (such as loss of time code transmission) are logged via the syslog facility. Every hour a summary of the accumulated times for the clock states is listed via syslog.</p>
+               <p>PPS support is only available when the receiver is completely synchronized. The receiver is believed to deliver correct time for an additional period of time after losing synchronization, unless a disruption in time code transmission is detected (possible power loss). The trust period is dependent on the receiver oscillator and thus is a function of clock type.</p>
+               <p>Raw DCF77 pulses can be fed via a level converter to the RXD pin of an RS-232 serial port (pin 3 of a 25-pin connector or pin 2 of a 9-pin connector). The telegrams are decoded and used for synchronization. DCF77 AM receivers can be bought for as little as $25. The accuracy is dependent on the receiver and is somewhere between 2ms (expensive) and 10ms (cheap). Synchronization ceases when reception of the DCF77 signal deteriorates, since no backup oscillator is available as usually found in other reference clock receivers. So it is important to have a good place for the DCF77 antenna. During transmitter shutdowns you are out of luck unless you have other NTP servers with alternate time sources available.</p>
+               <p>In addition to the PPS loopfilter control, a true PPS hardware signal can be utilized via the PPSAPI interface. PPS pulses are usually fed via a level converter to the DCD pin of an RS-232 serial port (pin 8 of a 25-pin connector or pin 1 of a 9-pin connector). To select PPS support, the mode parameter is the mode value as above plus 128. If 128 is not added to the mode value, PPS will be detected to be available but will not be used.
+               </p>
+               <h4>Hardware PPS support<br>
+               </h4>
+               <p>For PPS to be used, add 128 to the mode parameter.</p>
+                <p>If the PPS signal is fed in from a device different from the device providing the serial communication (/dev/refclock-{0..3}), this device is configured as /dev/refclockpps-{0..3}. This allows the PPS information to be fed in e.g. via the parallel port (if supported by the underlying operation system) and the date/time telegrams to be handled via the serial port.</p>
+               <h4>Monitor Data</h4>
+               <p>Clock state statistics are written hourly to the syslog service. Online information can be found by examining the clock variables via the <code>ntpq cv</code> command.<br>
+                       Some devices have quite extensive additional information (GPS16x/GPS17x, Trimble). The driver reads out much of the internal GPS data
+                       and makes it accessible via clock variables. To find out about additional variable names, query for the clock_var_list variable on
+                       a specific clock association as shown below.
+               </p>
+               <p>First let <code>ntpq</code> display the table of associations:</p>
+               <pre>
+  ntpq&gt; as
+  ind assID status  conf reach auth condition  last_event cnt
+  ===========================================================
+    1 19556  9154   yes   yes  none falsetick   reachable  5
+    2 19557  9435   yes   yes  none  candidat  clock expt  3
+    3 19558  9714   yes   yes  none  pps.peer   reachable  1
+               </pre>
+               <p>Then switch to raw output. This may be required because of display limitations in ntpq/ntpd - so large lists need to be retrieved in several queries.</p>
+               <pre>
+  ntpq&gt; raw
+  Output set to raw
+               </pre>
+               <p>Use the cv command to read the list of clock variables of a selected association:</p>
+               <pre>
+  ntpq&gt; cv 19557 clock_var_list
+               </pre>
+               <p>The long output of the command above looks similar to:</p>
+               <pre>
+  assID=19557 status=0x0000,
+  clock_var_list=&quot;type,timecode,poll,noreply,badformat,baddata,fudgetime1,
+  fudgetime2,stratum,refid,flags,device,clock_var_list,refclock_time,refclock_status,
+  refclock_format,refclock_states,refclock_id,refclock_iomode,refclock_driver_version,
+  meinberg_gps_status,gps_utc_correction,gps_message,meinberg_antenna_status,gps_tot_51,
+  gps_tot_63,gps_t0a,gps_cfg[1],gps_health[1],gps_cfg[2],gps_health[2],gps_cfg[3],
+  gps_health[3],gps_cfg[4],gps_health[4],gps_cfg[5]&quot;
+               </pre>
+               <p>Then use the cv command again to list selected clock variables. The following command must be entered as a single line:</p>
+               <pre>
+  ntpq&gt; cv 19557 refclock_status,refclock_format,refclock_states,refclock_id,
+  refclock_iomode,refclock_driver_version,meinberg_gps_status,gps_utc_correction,
+  gps_message,meinberg_antenna_status,gps_tot_51,gps_tot_63,gps_t0a,gps_cfg[1],
+  gps_health[1],gps_cfg[2],gps_health[2],gps_cfg[3],gps_health[3],gps_cfg[4],
+  gps_health[4],gps_cfg[5]
+               </pre>
+               <p>The output of the command above is wrapped around depending on the screen width and looks similar to:</p>
+               <pre>
+  status=0x0003,
+  refclock_status=&quot;UTC DISPLAY; TIME CODE; PPS; POSITION; (LEAP INDICATION;
+  PPS SIGNAL; POSITION)&quot;,
+  refclock_format=&quot;Meinberg GPS Extended&quot;,
+  refclock_states=&quot;*NOMINAL: 21:21:36 (99.99%); FAULT: 00:00:03 (0.00%);
+  running time: 21:21:39&quot;,
+  refclock_id=&quot;GPS&quot;, refclock_iomode=&quot;normal&quot;,
+  refclock_driver_version=&quot;refclock_parse.c,v 4.77 2006/08/05 07:44:49
+  kardel RELEASE_20060805_A&quot;,
+  meinberg_gps_status=&quot;[0x0000] &lt;OK&gt;&quot;,
+  gps_utc_correction=&quot;current correction 14 sec, last correction
+  on c7619a00.00000000  Sun, Jan  1 2006  0:00:00.000&quot;,
+  gps_message=&quot;/PFU3SOP-4WG14EPU0V1KA&quot;,
+  meinberg_antenna_status=&quot;RECONNECTED on 2006-07-18 08:13:20.0000000 (+0000)
+  UTC CORR, LOCAL TIME, reconnect clockoffset +0.0000000 s,
+  disconnect time 0000-00-00 00:00:00.0000000 (+0000) &quot;,
+  gps_tot_51=&quot;week 1400 + 3 days + 42300.0000000 sec&quot;,
+  gps_tot_63=&quot;week 1400 + 3 days + 42294.0000000 sec&quot;,
+  gps_t0a=&quot;week 1400 + 5 days + 71808.0000000 sec&quot;,
+  gps_cfg[1]=&quot;[0x9] BLOCK II&quot;, gps_health[1]=&quot;[0x0] OK;SIGNAL OK&quot;,
+  gps_cfg[2]=&quot;[0x0] BLOCK I&quot;, gps_health[2]=&quot;[0x3f] PARITY;MULTIPLE ERRS&quot;,
+  gps_cfg[3]=&quot;[0x9] BLOCK II&quot;, gps_health[3]=&quot;[0x0] OK;SIGNAL OK&quot;,
+  gps_cfg[4]=&quot;[0x9] BLOCK II&quot;, gps_health[6]=&quot;[0x0] OK;SIGNAL OK&quot;,
+  gps_cfg[5]=&quot;[0x9] BLOCK II&quot;
+               </pre>
+               <h4>Fudge Factors</h4>
+               <dl>
+                       <dt><tt>time1 <i>time</i></tt>
+                       <dd>Specifies the time offset calibration factor, in seconds and fraction. The default value depends on the clock type.
+                       <dt><tt>time2 <i>time</i></tt>
+                       <dd>
+                               If flag1 is 0, time2 specifies the offset of the PPS signal from the actual time (PPS fine tuning).
+                       <dd>
+                               If flag1 is 1, time2 specifies the number of seconds a receiver with a premium local oscillator can be trusted after losing synchronisation.
+                       <dt><tt>stratum <i>stratum</i></tt>
+                       <dd>The stratum for this reference clock.
+                       <dt><tt>refid <i>refid</i></tt>
+                       <dd>The refid for this reference clock.
+               </dl>
+               <dl>
+                       <dt><tt>flag1 { 0 | 1 }</tt>
+                       <dd>If 0, the fudge factor <tt>time2</tt> refers to the PPS offset.
+                       <dd>If 1, <tt>time2</tt> refers to the TRUST TIME.
+                       <dt><tt>flag2 { 0 | 1 }</tt>
+                       <dd>If <tt>flag2</tt> is 1, sample PPS on CLEAR instead of on ASSERT.
+                       <dt><tt>flag3 { 0 | 1 }</tt>
+                       <dd>If <tt>flag3</tt> is 1, link kernel PPS tracking to this refclock instance.
+                       <dt><tt>flag4 { 0 | 1 }</tt>
+                       <dd>Delete next leap second instead of adding it. (You'll need to wait a bit for that to happen 8-)
+               </dl>
+               <span style="font-weight: bold;">Note about auxiliary Sun STREAMS modules (SunOS and Solaris):</span><br>
+               <dl>
+                       <dt>The timecode of these receivers can be sampled via a STREAMS module in the kernel. (The STREAMS module has been designed for use with Sun systems under SunOS 4.1.x or Solaris 2.3 - 2.8. It can be linked directly into the kernel or loaded via the loadable driver mechanism.) This STREAMS module can be adapted to convert different time code formats. Nowadays the PPSAPI mechanism is usually used.
+               </dl>
+               <h4>Making your own PARSE clocks</h4>
+               <p>The parse clock mechanism deviates from the way other NTP reference clocks work. For a short description of how to build parse reference clocks, see <a href="../parsenew.html">making PARSE clocks</a>.</p>
+               <p>Additional Information</p>
+               <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/drivers/driver9.html b/html/drivers/driver9.html
new file mode 100644 (file)
index 0000000..112f2d7
--- /dev/null
@@ -0,0 +1,58 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+    <head>
+        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
+        <meta name="GENERATOR" content="Mozilla/4.01 [en] (Win95; I) [Netscape]">
+        <title>Magnavox MX4200 GPS Receiver</title>
+        <link href="scripts/style.css" type="text/css" rel="stylesheet">
+    </head>
+
+    <body>
+        <h3>Magnavox MX4200 GPS Receiver</h3>
+        <hr>
+        <h4>Synopsis</h4>
+        Address: 127.127.9.<i>u</i><br>
+        Reference ID: <tt>GPS</tt><br>
+        Driver ID: <tt>GPS_MX4200</tt><br>
+        Serial Port: <tt>/dev/gps<i>u</i></tt>; 4800 baud, 8-bits, no parity<br>
+        Features: <tt>ppsclock</tt> (required)
+        <h4>Description</h4>
+        <p>This driver supports the Magnavox MX4200 Navigation Receiver adapted to precision timing applications. It requires the <tt>ppsclock</tt> line discipline or streams module described in the <a href="../ldisc.html">Line Disciplines and Streams Modules</a> page. It also requires a level converter such as described in the <a href="../pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page.</p>
+        <p>This driver supports all compatible receivers such as the 6-channel MX4200, MX4200D, and the 12-channel MX9212, MX9012R, MX9112.</p>
+        <p><a href="http://www.leica-gps.com/"><img src="../pic/9400n.jpg" alt="Leica MX9400N Navigator" height="143" width="180" align="left"></a> <a href="http://www.leica-gps.com/">Leica Geosystems</a> acquired the Magnavox commercial GPS technology business in February of 1994. They now market and support former Magnavox GPS products such as the MX4200 and its successors.</p>
+        <br clear="LEFT">
+        <p>Leica MX9400N Navigator.</p>
+        <h4>Operating Modes</h4>
+        <p>This driver supports two modes of operation, static and mobile, controlled by clock flag 2.</p>
+        <p>In static mode (the default) the driver assumes that the GPS antenna is in a fixed location. The receiver is initially placed in a &quot;Static, 3D Nav&quot; mode, where latitude, longitude, elevation and time are calculated for a fixed station. An average position is calculated from this data. After 24 hours, the receiver is placed into a &quot;Known Position&quot; mode, initialized with the calculated position, and then solves only for time.</p>
+        <p>In mobile mode, the driver assumes the GPS antenna is mounted on a moving platform such as a car, ship, or aircraft. The receiver is placed in &quot;Dynamic, 3D Nav&quot; mode and solves for position, altitude and time while moving. No position averaging is performed.</p>
+        <h4>Monitor Data</h4>
+        <p>The driver writes each timecode as received to the <tt>clockstats</tt> file. Documentation for the <cite>NMEA-0183</cite> proprietary sentences produced by the MX4200 can be found in <a href="../mx4200data.html">MX4200 Receiver Data Format</a>.</p>
+        <h4>Fudge Factors</h4>
+        <dl>
+            <dt><tt>time1 <i>time</i></tt>
+            <dd>Specifies the time offset calibration factor, in seconds and fraction, with default 0.0.
+            <dt><tt>time2 <i>time</i></tt>
+            <dd>Not used by this driver.
+            <dt><tt>stratum <i>number</i></tt>
+            <dd>Specifies the driver stratum, in decimal from 0 to 15, with default 0.
+            <dt><tt>refid <i>string</i></tt>
+            <dd>Specifies the driver reference identifier, an ASCII string from one to four characters, with default <tt>GPS</tt>.
+            <dt><tt>flag1 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag2 0 | 1</tt>
+            <dd>Assume GPS receiver is on a mobile platform if set.
+            <dt><tt>flag3 0 | 1</tt>
+            <dd>Not used by this driver.
+            <dt><tt>flag4 0 | 1</tt>
+            <dd>Not used by this driver.
+        </dl>
+        <h4>Additional Information</h4>
+        <p><a href="../refclock.html">Reference Clock Drivers</a>&nbsp;</p>
+        <hr>
+        <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+    </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/icons/home.gif b/html/drivers/icons/home.gif
new file mode 100644 (file)
index 0000000..e181298
Binary files /dev/null and b/html/drivers/icons/home.gif differ
diff --git a/html/drivers/icons/mail2.gif b/html/drivers/icons/mail2.gif
new file mode 100644 (file)
index 0000000..21bc1c4
Binary files /dev/null and b/html/drivers/icons/mail2.gif differ
diff --git a/html/drivers/oncore-shmem.html b/html/drivers/oncore-shmem.html
new file mode 100644 (file)
index 0000000..8942927
--- /dev/null
@@ -0,0 +1,161 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>ONCORE - SHMEM</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Motorola ONCORE - The Shared Memory Interface</h3>
+               <hr>
+               <h4>Introduction</h4>
+               <p>In NMEA mode, the Oncore GPS receiver provides the user with the same information as other GPS receivers. In BINARY mode, it can provide a lot of additional information.</p>
+               <p>In particular, you can ask for satellite positions, satellite health, signal levels, the ephemeris and the almanac, and you can set many operational parameters. In the case of the VP, you can get the pseudorange corrections necessary to act as a DGPS base station, and you can see the raw satellite data messages themselves.</p>
+               <p>When using the Oncore GPS receiver with NTP, this additional information is usually not available since the receiver is only talking to the oncore driver in NTPD. To make this information available for use in other programs, (say graphic displays of satellites positions, plots of SA, etc.), a shared memory interface (SHMEM) has been added to the refclock_oncore driver on those operating systems that support shared memory.</p>
+               <p>To make use of this information you will need an Oncore Reference Manual for the Oncore GPS receiver that you have. The Manual for the VP only exists as a paper document, the UT+/GT+/M12 manuals are available as a pdf documents at <a href="http://www.synergy-gps.com/Mot_Manuals.html">Synergy</a> .</p>
+               <p>This interface was written by Poul-Henning Kamp (phk@FreeBSD.org), and modified by Reg Clemens (reg@dwf.com). The interface is known to work in FreeBSD, Linux, and Solaris.</p>
+               <h4>Activating the Interface</h4>
+               <p>Although the Shared Memory Interface will be compiled into the Oncore driver on those systems where Shared Memory is supported, to activate this interface you must include a <b>STATUS</b> or <b>SHMEM</b> line in the <tt>/etc/ntp.oncore</tt> data file that looks like</p>
+               <pre>
+        STATUS &lt; file_name &gt;<br>
+                       
+        or<br>
+                       
+        SHMEM &lt; file_name &gt;
+</pre>
+               Thus a line like
+               <pre>
+        SHMEM /var/adm/ntpstats/ONCORE
+</pre>
+               <p>would be acceptable. This file name will be used to access the Shared Memory.</p>
+               <p>In addition, one the two keywords <b>Posn2D</b> and <b>Posn3D</b> can be added to see @@Ea records containing the 2D or 3D position of the station (see below). Thus to activate the interface, and see 3D positions, something like</p>
+               <pre>
+        SHMEM /var/adm/ntpstats/ONCORE
+        Posn3D
+</pre>
+               <p>would be required.</p>
+               <h4>Storage of Messages in Shared Memory</h4>
+               <p>With the shared memory interface, the oncore driver (refclock_oncore) allocates space for all of the messages that it is configured to receive, and then puts each message in the appropriate slot in shared memory as it arrives from the receiver. Since there is no easy way for a client program to know when the shared memory has been updated, a sequence number is associated with each message, and is incremented when a new message arrives. With the sequence number it is easy to check through the shared memory segment for messages that have changed.</p>
+               <p>The Oncore binary messages are kept in their full length, as described in the Reference manual, that is everything from the @@ prefix thru the &lt;checksum&gt;&lt;CR&gt;&lt;LF&gt;.</p>
+               <p>The data starts at location ONE of SHMEM (NOT location ZERO).</p>
+               <p>The messages are stacked in a series of variable length structures, that look like</p>
+               <pre>
+        struct message {
+                u_int   length;
+                u_char  sequence;
+                u_char  message[length];
+        }
+</pre>
+               <p>if something like that were legal. That is, there are two bytes (caution, these may NOT be aligned with word boundaries, so the field needs to be treated as a pair of u_char), that contains the length of the next message. This is followed by a u_char sequence number, that is incremented whenever a new message of this type is received. This is followed by 'length' characters of the actual message.</p>
+               <p>The next structure starts immediately following the last char of the previous message (no alignment). Thus, each structure starts a distance of 'length+3' from the previous structure.</p>
+               <p>Following the last structure, is a u_int containing a zero length to indicate the end of the data.</p>
+               <p>The messages are recognized by reading the headers in the data itself, viz @@Ea or whatever.</p>
+               <p>There are two special cases.</p>
+               <p>(1) The almanac takes a total of 34 submessages all starting with @@Cb.<br>
+                       35 slots are allocated in shared memory. Each @@Cb message is initially placed in the first of these locations, and then later it is moved to the appropriate location for that submessage. The submessages can be distinguished by the first two characters following the @@Cb header, and new data is received only when the almanac changes.</p>
+               <p>(2) The @@Ea message contains the calculated location of the antenna, and is received once per second. However, when in timekeeping mode, the receiver is normally put in 0D mode, with the position fixed, to get better accuracy. In 0D mode no position is calculated.</p>
+               <p>When the SHMEM option is active, and if one of <b>Posn2D</b> or <b>Posn3D</b> is specified, one @@Ea record is hijacked each 15s, and the receiver is put back in 2D/3D mode so the the current location can be determined (for position determination, or for tracking SA). The timekeeping code is careful NOT to use the time associated with this (less accurate) 2D/3D tick in its timekeeping functions.</p>
+               <p>Following the initial @@Ea message are 3 additional slots for a total of four. As with the almanac, the first gets filled each time a new record becomes available, later in the code, the message is distributed to the appropriate slot. The additional slots are for messages containing 0D, 2D and 3D positions. These messages can be distinguished by different bit patterns in the last data byte of the record.</p>
+               <h4>Opening the Shared Memory File</h4>
+               <p>The shared memory segment is accessed through a file name given on a <b>SHMEM</b> card in the <tt>/etc/ntp.oncore</tt> input file. The following code could be used to open the Shared Memory Segment:</p>
+               <pre>
+        char *Buf, *file;
+        int size, fd;
+        struct stat statbuf;
+
+        file = &quot;/var/adm/ntpstats/ONCORE&quot;;  /* the file name on my ACCESS card */
+        if ((fd=open(file, O_RDONLY)) &lt; 0) {
+                fprintf(stderr, &quot;Cant open %s\n&quot;, file);
+                exit(1);
+        }
+
+        if (stat(file, &amp;statbuf) &lt; 0) {
+                fprintf(stderr, &quot;Cant stat %s\n&quot;, file);
+                exit(1);
+        }
+
+        size = statbuf.st_size;
+        if ((Buf=mmap(0, size, PROT_READ, MAP_SHARED, fd, (off_t) 0)) &lt; 0) {
+                fprintf(stderr, &quot;MMAP failed\n&quot;);
+                exit(1);
+        }
+</pre>
+               <h4>Accessing the data</h4>
+               <p>The following code shows how to get to the individual records.</p>
+               <pre>
+        void    oncore_msg_Ea(), oncore_msg_As(), oncore_msg_Bb();
+
+        struct Msg {
+            char         c[5];
+            unsigned int seq;
+            void         (*go_to)(uchar *);
+        };
+
+        struct Msg Hdr[] = { {&quot;@@Bb&quot;, 0, &amp;oncore_msg_Bb},
+                             {&quot;@@Ea&quot;, 0, &amp;oncore_msg_Ea},
+                             {&quot;@@As&quot;, 0, &amp;oncore_msg_As}};
+
+        void
+        read_data()
+        {
+            int     i, j, k, n, iseq, jseq;
+            uchar   *cp, *cp1;
+
+
+            for(cp=Buf+1; (n = 256*(*cp) + *(cp+1)) != 0;  cp+=(n+3)) {
+                for (k=0; k &lt; sizeof(Hdr)/sizeof(Hdr[0]);  k++) {
+                    if (!strncmp(cp+3, Hdr[k].c, 4)) {      /* am I interested? */
+                        iseq = *(cp+2);
+                        jseq = Hdr[k].seq;
+                        Hdr[k].seq = iseq;
+                        if (iseq &gt; jseq) {              /* has it changed? */
+                            /* verify checksum */
+                            j = 0;
+                            cp1 = cp+3;             /* points to start of oncore response */
+                            for (i=2; i &lt; n-3; i++)
+                                j ^= cp1[i];
+                            if (j == cp1[n-3]) {    /* good checksum */
+                                    Hdr[k].go_to(cp1);
+                            } else {
+                                fprintf(stderr, &quot;Bad Checksum for %s\n&quot;, Hdr[k].c);
+                                break;
+                            }
+                        }
+                    }
+                }
+                if (!strncmp(cp+3, &quot;@@Ea&quot;, 4))
+                    cp += 3*(n+3);
+                if (!strncmp(cp+3, &quot;@@Cb&quot;, 4))
+                    cp += 34*(n+3);
+            }
+        }
+
+        oncore_msg_Bb(uchar *buf)
+        {
+                /* process Bb messages */
+        }
+
+        oncore_msg_Ea(uchar *buf)
+        {
+                /* process Ea messages */
+        }
+
+        oncore_msg_As(uchar *buf)
+        {
+                /* process As messages */
+        }
+</pre>
+               <p>The structure Hdr contains the Identifying string for each of the messages that we want to examine, and the name of a program to call when a new message of that type is arrives. The loop can be run every few seconds to check for new data.</p>
+               <h4>Examples</h4>
+               <p>There are two complete examples available. The first plots satellite positions and the station position as affected by SA, and keeps track of the mean station position, so you can run it for periods of days to get a better station position. The second shows the effective horizon by watching satellite tracks. The examples will be found in the GNU-zipped tar file <a href="ftp://ftp.udel.edu/pub/ntp/software/OncorePlot.tar.gz">ftp://ftp.udel.edu/pub/ntp/software/OncorePlot.tar.gz</a>.</p>
+               <p>Try the new interface, enjoy.</p>
+               <hr>
+               <address>Reg.Clemens (reg@dwf.com), Poul-Henning Kamp (phk@FreeBSD.org)</address>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/drivers/scripts/footer.txt b/html/drivers/scripts/footer.txt
new file mode 100644 (file)
index 0000000..89216ce
--- /dev/null
@@ -0,0 +1,7 @@
+document.write("\
+<table><tr>\
+<td width='50%' ><img src='../icons/home.gif' align='middle' alt='gif'>\
+<a href='../index.html'>Home Page</a></td>\
+<td width='50%' ><img src='../icons/mail2.gif' align='middle' alt='gif'>\
+<a href='http://www.ntp.org/contact.html'>Contacts</a></i></td>\
+</tr></table>")
\ No newline at end of file
diff --git a/html/drivers/scripts/style.css b/html/drivers/scripts/style.css
new file mode 100644 (file)
index 0000000..096b18a
--- /dev/null
@@ -0,0 +1,64 @@
+body {background: #FDF1E1;
+      color: #006600;
+      font-family: "verdana", sans-serif;
+      text-align: justify;
+      margin-left: 5px;}
+
+p, h4, hr, li {margin-top: .6em; margin-bottom: .6em}
+li.inline {text-align: left; margin-top: 0; margin-bottom: 0}
+
+ul, dl, ol, {margin-top: .6em; margin-bottom: .6em; margin-left 5em}
+
+dt {margin-top: .6em}
+dd {margin-bottom: .6em}
+
+div.header {text-align: center;
+            font-style: italic;}
+
+div.footer {text-align: center;         
+            font-size: 60%;}
+
+img.cell {align: left;}
+
+td.sidebar {width: 40px; align: center; valign: top;}
+img.sidebar {align: center; margin-top: 5px;}
+h4.sidebar {align: center;}
+
+p.top {background: #FDF1E1;
+       color: #006600;
+       position: absolute;
+       margin-left: -90px;
+       text-align: center;}
+
+a:link.sidebar {background: transparent;
+                color: #990033;
+                font-weight: bold;}
+
+a:visited.sidebar {background: transparent;
+                   color: #990033;
+                   font-weight: bold;}
+
+a:hover.sidebar {background: #FDF1E1;
+                 color: #006600;}
+
+img {margin: 5px;}
+
+div {text-align: center;}
+
+h1 {text-align: center;
+    font-size: 250%;}
+
+caption {background: #EEEEEE;
+         color: #339999;}
+         
+tx {text-align: center;}
+
+th {background: #FFFFCC;
+    color: #006600;
+    text-align: center;
+    text-decoration: underline;
+    padding-top: 5px;}
+
+th.caption {background: #EEEEEE;
+            color: #006600;
+            text-align: center;}
\ No newline at end of file
diff --git a/html/drivers/tf582_4.html b/html/drivers/tf582_4.html
new file mode 100644 (file)
index 0000000..6b0ce0a
--- /dev/null
@@ -0,0 +1,71 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta name="GENERATOR" content="Adobe PageMill 3.0 per Windows">
+               <meta http-equiv="Content-Type" content="text/html;charset=iso-8859-1">
+               <title>PTB Modem Time Service</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>European Automated Computer Time Services</h3>
+               <hr>
+               <p>Several European countries use the following message data format:</p>
+               <p><font size="-1" face="Courier New">Data format<br>
+                               0000000000111111111122222222223333333333444444444455555555556666666666777777777 7<br>
+                               0123456789012345678901234567890123456789012345678901234567890123456789012345678 9<br>
+                               1995-01-23 20:58:51 MEZ 10402303260219950123195849740+40000500 *<br>
+                               A B C D EF G H IJ K L M N O P Q R S T U V W XY Z&lt;CR&gt;&lt;LF&gt;<br>
+                               A year<br>
+                               B month<br>
+                               C day<br>
+                               D hour<br>
+                               E : normally<br>
+                               A for DST to ST switch first hour<br>
+                               B for DST to ST switch second hour if not marked in H<br>
+                               F minute<br>
+                               G second<br>
+                               H timezone<br>
+                               I day of week<br>
+                               J week of year<br>
+                               K day of year<br>
+                               L month for next ST/DST changes<br>
+                               M day<br>
+                               N hour<br>
+                               O UTC year<br>
+                               P UTC month<br>
+                               Q UTC day<br>
+                               R UTC hour<br>
+                               S UTC minute<br>
+                               T modified julian day (MJD)<br>
+                               U DUT1<br>
+                               V direction and month if leap second<br>
+                               W signal delay (assumed/measured)<br>
+                               X sequence number for additional text line in Y<br>
+                               Y additional text<br>
+                               Z on time marker (* - assumed delay / # measured delay)<br>
+                               &lt;CR&gt;!&lt;LF&gt; ! is second change !<br>
+                       </font></p>
+               <p>This format is an ITU-R Recommendation (ITU-R TF583.4) and is now available from the primary timing centres of the following countries: Austria, Belgium, Germany, Italy, The Netherlands, Poland, Portugal, Romania, Spain, Sweden, Switzerland, Turkey and United Kingdom. Some examples are:</p>
+               <ul>
+                       <li>In Germany by Physikalisch-Technische Bundesanstalt (PTB)'s timecode service. Phone number: +49 5 31 51 20 38.
+                               <p>For more detail, see <a href="http://www.ptb.de/english/org/4/43/433/disse.html">http://www.ptb.de/english/org/4/43/433/disse.htm</a></p>
+                       <li>In the UK by National Physical Laboratory (NPL)'s TRUETIME service. Phone number: 0891 516 333
+                               <p>For more detail, see <a href="http://www.npl.co.uk/npl/ctm/truetime.html">http://www.npl.co.uk/npl/ctm/truetime.html</a></p>
+                       <li>In Italy by Istituto Elettrotecnico Nazionale &quot;Galileo Ferrais&quot; (IEN)'s CTD service. Phone number: 166 11 46 15
+                               <p>For more detail, see <a href="http://www.ien.it/tf/time/Pagina42.html">http://www.ien.it/tf/time/Pagina42.html</a></p>
+                       <li>In Switzerland by Swiss Federal Office of Metrology's timecode service. Phone number: 031 323 32 25
+                               <p>For more detail, see <a href="http://www.metas.ch/en/labors/official-time/modem/index.html">http://www.ofmet.admin.ch/de/labors/4/Zeitvert.html </a></p>
+                       <li>In Sweden by SP Swedish National Testing and Research Institute 's timecode service. Phone number: +46 33 415783.
+                               <p>For more detail, see <a href="http://www.sp.se/metrology/timefreq/eng/tandf.htm">http://www.sp.se/metrology/timefreq/eng/tandf.htm</a></p>
+               </ul>
+               <dl></dl>
+               <h4>Additional Information</h4>
+               <p><a href="../refclock.html">Reference Clock Drivers</a></p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/extern.html b/html/extern.html
new file mode 100644 (file)
index 0000000..3245fca
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>External Clock Discipline and the Local Clock Driver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>External Clock Discipline and the Local Clock Driver</h3>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:38</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <hr>
+               <p>The NTPv4 implementation includes provisions for an external clock, where the system clock is implemented by some external hardware device. One implementation might take the form of a bus peripheral with a high resolution counter disciplined by a GPS receiver, for example. Another implementation might involve another synchronization protocol, such as the Digital Time Synchronization Service (DTSS), where the system time is disciplined to this protocol and NTP clients of the server obtain synchronization indirectly via the server. A third implementation might be a completely separate clock discipline algorithm and synchronization protocol, such as the <tt>Lockclock</tt> algorithm used with NIST Automated Computer Time Service (ACTS) modem synchronized time.</p>
+               <p>When external clocks are used in conjunction with NTP service, some way needs to be provided for the external clock driver and NTP daemon <tt>ntpd</tt> to communicate and determine which discipline is in control. This is necessary in order to provide backup, for instance if the external clock or protocol were to fail and synchronization service fall back to other means, such as a local reference clock or another NTP server. In addition, when the external clock and driver are in control, some means needs to be provided for the clock driver to pass on status information and error statistics to the NTP daemon.</p>
+               <p>Control and monitoring functions for the external clock and driver are implemented using the <a href="drivers/driver1.html">Local Clock (type 1) driver</a> and the <tt>ntp_adjtime()</tt> system call. This system call is implemented by special kernel provisions included in the kernel of several operating systems, including Solaris, Tru64, FreeBSD and Linux, and possibly others. When the external clock is disabled or not implemented, the system call is used to pass time and frequency information, as well as error statistics, to the kernel. Besides disciplining the system time, the same interface can be used by other applications to determine the operating parameters of the discipline.</p>
+               <p>When the external clock is enabled, <tt>ntpd</tt> does not discipline the system clock, nor does it maintain the error statistics. In this case, the external clock and driver do this using mechanisms unknown to <tt>ntpd</tt>; however, in this case the kernel state variables are retrieved at 64-s intervals by the Local Clock driver and used by the clock selection and mitigation algorithms to determine the system variables presented to other NTP clients and peers. In this way, downstream clients and servers in the NTP subnet can make an intelligent choice when more than one server is available.</p>
+               <p>In order to implement a reliable mitigation between ordinary NTP sources and the external clock source, a protocol is necessary between the local clock driver and the external clock driver. This is implemented using Boolean variables and certain bits in the kernel clock status word. The Boolean variables include the following:</p>
+               <p><tt>ntp_enable</tt>. set/reset by the <tt>enable</tt> command. enables ntp clock discipline</p>
+               <p><tt>ntp_contro</tt>l. set during initial configuration if kernel support is available</p>
+               <p><tt>kern_enable</tt> Set/reset by the <tt>enable</tt> command</p>
+               <p>If the <tt>kern_enable</tt> switch is set, the daemon computes the offset, frequency, maximum error, estimated error, time constand and status bits, then provides them to the kernel via <tt>ntp_adjtime()</tt>. If this switch is not set, these values are not passed to the kernel; however, the daemon retrieves their present values and uses them in place of the values computed by the daemon.</p>
+               <p>The <tt>pps_update</tt> bit set in the protocol routine if the prefer peer has survived and has offset less than 128 ms; otherwise set to zero.</p>
+               <p>The <tt>pps_contro</tt>l Updated to the current time by kernel support if the PPS signal is enabled and working correctly. Set to zero in the adjust routine if the interval since the last update exceeds 120 s.</p>
+               <p>The <tt>ntp_enable</tt> and <tt>kern_enable</tt> are set by the configuration module. Normally, both switches default on, so the daemon can control the time and the kernel discipline can be used, if available. The <tt>pps_update</tt> switch is set by the protocol module when it believes the PPS provider source is legitimate and operating within nominals. The <tt>ntp_control</tt> switch is set during configuration by interrogating the kernel. If both the <tt>kern_enable</tt> and <tt>ntp_control</tt> switches are set, the daemon disciplines the clock via the kernel and the internal daemon discipline is disabled.</p>
+               <p>The external clock driver controls the system time and clock selection in the following way. Normally, the driver adjusts the kernel time using the <tt>ntp_adjtime()</tt> system call in the same way as the daemon. In the case where the kernel discipline is to be used intact, the clock offset is provided in this call and the loop operates as specified. In the case where the driver steers only the frequency, the offset is specified as zero.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/gadget.html b/html/gadget.html
new file mode 100644 (file)
index 0000000..b13fe08
--- /dev/null
@@ -0,0 +1,33 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Gadget Box PPS Level Converter and CHU Modem</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Gadget Box PPS Level Converter and CHU Modem</h3>
+               <img src="pic/gadget.jpg" alt="gif" align="left">A Gadget Box built by Chuck Hanavin
+               <h4>Related Links</h4>
+               <p>
+                       <script type="text/javascript" language="javascript" src="scripts/links11.txt"></script>
+                       <br clear="left">
+               </p>
+               <h4>table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#intro">Introduction</a>
+                       <li class="inline"><a href="#ckt">Circuit Description</a>
+                       <li class="inline"><a href="#file">Files</a>
+               </ul>
+               <hr>
+               <h4 id="intro">Introduction</h4>
+               <p>Many radio clocks used as a primary reference source for NTP servers produce a pulse-per-second (PPS) signal that can be used to improve accuracy to a high degree. However, the signals produced are usually incompatible with the modem interface signals on the serial ports used to connect the signal to the host. The gadget box consists of a handful of electronic components assembled in a small aluminum box. It includes level converters and a optional radio modem designed to decode the radio timecode signals transmitted by the Canadian time and frequency station CHU. A complete set of schematics, PCB artwork, drill templates can be obrtained via the web from ftp.udel.edu as <a href="ftp://ftp.udel.edu/pub/ntp/hardware/gadget.tar.Z">gadget.tar.Z</a>.</p>
+               <p>The gadget box is assembled in a 5&quot;x3&quot;x2&quot; aluminum minibox containing the level converter and modem circuitry. It includes two subcircuits. One of these converts a TTL positive edge into a fixed-width pulse at EIA levels and is for use with a timecode receiver or oscillator including a TTL PPS output. The other converts the timecode modulation broadcast by Canadian time/frequency standard station CHU into a 300-bps serial character stream at EIA levels and is for use with the <a href="drivers/driver7.html">Radio CHU Audio Demodulator/Decoder</a> driver.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/groups.html b/html/groups.html
new file mode 100644 (file)
index 0000000..7f6d14b
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Trusted Hosts and Groups</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Trusted Hosts and Groups</h3>
+               <img src="pic/alice23.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>Alice holds the key.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">00:12</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="299">Tuesday, November 08, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links9.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#idexp">Identity Schemes</a>
+                       <li class="inline"><a href="#exam">Example</a>
+                       <li class="inline"><a href="#cmd">Command Line Options</a>
+                       <li class="inline"><a href="#rand">Random Seed File</a>
+                       <li class="inline"><a href="#fmt">Cryptographic Data Files</a>
+                       <li class="inline"><a href="#bug">Bugs</a>
+               </ul>
+               <hr>
+               <h4 id="synop">Trusted Hosts and Groups</h4>
+               <p>Each cryptographic configuration involves selection of a signature scheme and identification scheme, called a cryptotype, as explained in the <a href="authopt.html">Authentication Options</a> page. The default cryptotype uses RSA encryption, MD5 message digest and TC identification. First, configure a NTP subnet including one or more low-stratum trusted hosts from which all other hosts derive synchronization directly or indirectly. Trusted hosts have trusted certificates; all other hosts have nontrusted certificates. These hosts will automatically and dynamically build authoritative certificate trails to one or more trusted hosts. A trusted group is the set of all hosts that have, directly or indirectly, a certificate trail ending at a trusted host. The trail is defined by static configuration file entries or dynamic means described on the <a href="manyopt.html">Automatic NTP Configuration Options</a> page.</p>
+               <p>On each trusted host as root, change to the keys directory. To insure a fresh fileset, remove all <tt>ntpkey</tt> files. Then run <tt>ntp-keygen -T</tt> to generate keys and a trusted certificate. On all other hosts do the same, but leave off the <tt>-T</tt> flag to generate keys and nontrusted certificates. When complete, start the NTP daemons beginning at the lowest stratum and working up the tree. It may take some time for Autokey to instantiate the certificate trails throughout the subnet, but setting up the environment is completely automatic.</p>
+               <p>If it is necessary to use a different sign key or different digest/signature scheme than the default, run <tt>ntp-keygen</tt> with the <tt>-S</tt><i><tt> type</tt></i> option, where <i><tt>type</tt></i> is either <tt>RSA</tt> or <tt>DSA</tt>. The most often need to do this is when a DSA-signed certificate is used. If it is necessary to use a different certificate scheme than the default, run <tt>ntp-keygen</tt> with the <tt>-c <i>scheme</i></tt> option and selected <i><tt>scheme</tt></i> as needed. If <tt>ntp-keygen</tt> is run again without these options, it generates a new certificate using the same scheme and sign key.</p>
+               <p>After setting up the environment it is advisable to update certificates from time to time, if only to extend the validity interval. Simply run <tt>ntp-keygen</tt> with the same flags as before to generate new certificates using existing keys. However, if the host or sign key is changed, <tt>ntpd</tt> should be restarted. When ntpd is restarted, it loads any new files and restarts the protocol. Other dependent hosts will continue as usual until signatures are refreshed, at which time the protocol is restarted.</p>
+               <h4 id="idexp">Identity Schemes</h4>
+               <p>As mentioned on the Autonomous Authentication page, the default TC identity scheme is vulnerable to a middleman attack. However, there are more secure identity schemes available, including PC, IFF, GQ and MV described on the <a href="http://www.eecis.udel.edu/%7emills/keygen.html">Identification Schemes</a> page. These schemes are based on a TA, one or more trusted hosts and some number of nontrusted hosts. Trusted hosts prove identity using values provided by the TA, while the remaining hosts prove identity using values provided by a trusted host and certificate trails that end on that host. The name of a trusted host is also the name of its sugroup and also the subject and issuer name on its trusted certificate. The TA is not necessarily a trusted host in this sense, but often is.</p>
+               <p>In some schemes there are separate keys for servers and clients. A server can also be a client of another server, but a client can never be a server for another client. In general, trusted hosts and nontrusted hosts that operate as both server and client have parameter files that contain both server and client keys. Hosts that operate only as clients have key files that contain only client keys.</p>
+               <p>The PC scheme supports only one trusted host in the group. On trusted host <i>alice</i> run <tt>ntp-keygen -P -p <i>password</i></tt> to generate the host key file <tt>ntpkey_RSAkey_<i>alice.filestamp</i></tt> and trusted private certificate file <tt>ntpkey_RSA-MD5_cert_<i>alice.filestamp</i></tt>. Copy both files to all group hosts; they replace the files which would be generated in other schemes. On each host <i>bob</i> install a soft link from the generic name <tt>ntpkey_host_<i>bob</i></tt> to the host key file and soft link <tt>ntpkey_cert_<i>bob</i></tt> to the private certificate file. Note the generic links are on <i>bob</i>, but point to files generated by trusted host <i>alice</i>. In this scheme it is not possible to refresh either the keys or certificates without copying them to all other hosts in the group.</p>
+               <p>For the IFF scheme proceed as in the TC scheme to generate keys and certificates for all group hosts, then for every trusted host in the group, generate the IFF&nbsp;parameter file. On trusted host <i>alice</i> run <tt>ntp-keygen -T </tt><tt>-I -p <i>password</i></tt> to produce her parameter file <tt>ntpkey_IFFpar_<i>alice.filestamp</i></tt>, which includes both server and client keys. Copy this file to all group hosts that operate as both servers and clients and install a soft link from the generic <tt>ntpkey_iff_<i>alice</i></tt> to this file. If there are no hosts restricted to operate only as clients, there is nothing further to do. As the IFF scheme is independent of keys and certificates, these files can be refreshed as needed.</p>
+               <p>If a rogue client has the parameter file, it could masquerade as a legitimate server and present a middleman threat. To eliminate this threat, the client keys can be extracted from the parameter file and distributed to all restricted clients. After generating the parameter file, on <i>alice</i> run <tt>ntp-keygen</tt> <tt>-e</tt> and pipe the output to a file or mail program. Copy or mail this file to all restricted clients. On these clients install a soft link from the generic <tt>ntpkey_iff_<i>alice</i></tt> to this file. To further protect the integrity of the keys, each file can be encrypted with a secret password.</p>
+               <p>For the GQ scheme proceed as in the TC scheme to generate keys and certificates for all group hosts, then for every trusted host in the group, generate the IFF parameter file. On trusted host <i>alice</i> run <tt>ntp-keygen -T </tt><tt>-G -p <i>password</i></tt> to produce her parameter file <tt>ntpkey_GQpar_<i>alice.filestamp</i></tt>, which includes both server and client keys. Copy this file to all group hosts and install a soft link from the generic <tt>ntpkey_gq_<i>alice</i></tt> to this file. In addition, on each host <i>bob</i> install a soft link from generic <tt>ntpkey_gq_<i>bob</i></tt> to this file. As the GQ scheme updates the GQ parameters file and certificate at the same time, keys and certificates can be regenerated as needed.</p>
+               <p>For the MV scheme, proceed as in the TC scheme to generate keys and certificates for all group hosts. For illustration assume <i>trish</i> is the TA, <i>alice</i> one of several trusted hosts and <i>bob</i> one of her clients. On TA <i>trish</i> run <tt>ntp-keygen </tt><tt>-V&nbsp;<i>n</i> -p <i>password</i></tt>, where <i>n</i> is the number of revokable keys (typically 5) to produce the parameter file <tt>ntpkeys_MVpar_<i>trish.filestamp </i></tt>and client key files <tt>ntpkeys_MVkey<i>d</i>_<i>trish.filestamp</i></tt> where <i><tt>d</tt></i> is the key number (0 &lt; <i><tt>d</tt></i> &lt; <i>n</i>). Copy the parameter file to <i>alice</i> and install a soft link from the generic <tt>ntpkey_mv_<i>alice</i></tt> to this file. Copy one of the client key files to <i>alice</i> for later distribution to her clients. It doesn't matter which client key file goes to <i>alice</i>, since they all work the same way. <i>Alice</i> copies the client key file to all of her cliens. On client <i>bob</i> install a soft link from generic <tt>ntpkey_mvkey_<i>bob </i></tt>to the client key file. As the MV scheme is independent of keys and certificates, these files can be refreshed as needed.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/howto.html b/html/howto.html
new file mode 100644 (file)
index 0000000..3a1007f
--- /dev/null
@@ -0,0 +1,109 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>How to Write a Reference Clock Driver</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>How to Write a Reference Clock Driver</h3>
+               <img src="pic/pogo4.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+               <p>You need a little magic.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:39</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links10.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#desc">Description</a>
+                       <li class="inline"><a href="#file">Files Which Need to be Changed</a>
+                       <li class="inline"><a href="#intf">Interface Routine Overview</a>
+               </ul>
+               <hr>
+               <h4 id="desc">Description</h4>
+               <p>NTP reference clock support maintains the fiction that the clock is actually an ordinary peer in the NTP tradition, but operating at a synthetic stratum of zero. The entire suite of algorithms used to filter the received data, select the best clocks or peers and combine them to produce a system clock correction operate just like ordinary NTP peers. In this way, defective clocks can be detected and removed from the peer population. As no packets are exchanged with a reference clock; however, the transmit, receive and packet procedures are replaced with separate code to simulate them.</p>
+               <p>It is important to understand how the NTP clock driver interface works. The driver assumes three timescales: standard time maintained by a distant laboratory such as USNO or NIST, reference time maintained by the external radio and the system time maintained by NTP. The radio synchronizes reference time and frequency to standard time via radio, satellite or modem. As the transmission means may not always be reliable, most radios continue to provide clock updates for some time after signal loss using an internal reference oscillator. In such cases the radio may or may not reveal the time since last synchronized and/or the estimated time error.</p>
+               <p>All three timescales run <i>only</i> in Coordinated Universal Time (UTC), 24-hour format, and are not adjusted for local timezone or standard/daylight time. The local timezone, standard/daylight indicator and year, if provided, are ignored. However, it is important to determine whether a leap second is to be inserted in the UTC timescale in the near future so NTP can insert it in the system timescale at the appropriate epoch.</p>
+               <p>The NTP clock driver synchronizes the system time and frequency to the radio via serial or parallel port, PPS signal or other means. The driver routinely checks the radio timecode string or status indicators to determine whether it is operating correctly or not. If it is, the driver decodes the radio timecode in days, hours, minutes, seconds and nanoseconds and provides these data with the NTP receive timestamp corresponding to the on-time epoch of the timecode. The driver interface computes the difference between the timecode time and NTP timestamp and saves the difference in a circular buffer for later processing. Once each poll interval, usually 64 s, the driver provides ancillary data including leap bits and last reference time to the interface. The interface processes the circular buffer using a median/trimmed mean algorithm to extract the best estimate and provides this and the ancillary data to the clock filter as with ordinary NTP peers.</p>
+               <p>The audio drivers are designed to look like a typical external radio in that the reference oscillator is derived from the audio codec oscillator and separate from the system clock oscillator. In the WWV and IRIG drivers, the codec oscillator is disciplined in frequency to the standard timescale via radio or local sources and can be assumed to have the same reliability and accuracy as an external radio. In these cases the driver continues to provide updates to the clock filter even if the WWV or IRIG signals are lost. However, the interface is provided the last reference time when the signals were received and increases the dispersion as expected with an ordinary peer.</p>
+               <p>The best way to understand how the clock drivers work is to study the <tt>ntp_refclock.c</tt> module and one of the drivers already implemented, such as <tt>refclock_wwvb.c</tt>. Routines <tt>refclock_transmit()</tt> and <tt>refclock_receive()</tt> maintain the peer variables in a state analogous to a network peer and pass received data on through the clock filters. Routines <tt>refclock_peer()</tt> and <tt>refclock_unpeer()</tt> initialize and terminate reference clock associations, should this ever be necessary. A set of utility routines is included to open serial devices, process sample data, edit input lines to extract embedded timestamps and to perform various debugging functions.</p>
+               <p>The main interface used by these routines is the <tt>refclockproc</tt> structure, which contains for most drivers the decimal equivalents of the year, day, month, hour, second and nanosecond decoded from the radio timecode. Additional information includes the receive timestamp, reference timestamp, exception reports, statistics tallies, etc. The support routines are passed a pointer to the <tt>peer</tt> structure, which is used for all peer-specific processing and contains a pointer to the <tt>refclockproc</tt> structure, which in turn contains a pointer to the unit structure, if used. For legacy purposes, a table <tt>typeunit[type][unit]</tt> contains the peer structure pointer for each configured clock type and unit. This structure should not be used for new implementations.</p>
+               <p>The reference clock interface supports auxiliary functions to support in-stream timestamping, pulse-per-second (PPS) interfacing and precision time kernel support. In most cases the drivers do not need to be aware of them, since they are detected at autoconfigure time and loaded automatically when the device is opened. These include the <tt>tty_clk</tt> STREAMS module and <tt>ppsapi</tt> PPS interface described in the <a href="ldisc.html">Line Disciplines and Streams Modules</a> page. The <tt>tty_clk</tt> module reduces latency errors due to the operating system and serial port code in slower systems. The <tt>ppsapi</tt> PPS interface replaces the <tt>ppsclock</tt> STREAMS module and is expected to become the IETF standard cross-platform interface for PPS signals. In either case, the PPS signal can be connected via a level converter/pulse generator described in the <a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page.</p>
+               <p>Radio and modem reference clocks by convention have addresses in the form <tt>127.127.<i>t</i>.<i>u</i></tt>, where <i>t</i> is the clock type and <i>u</i> in the range 0-3 is used to distinguish multiple instances of clocks of the same type. Most clocks require a serial or parallel port or special bus peripheral. The particular device is normally specified by adding a soft link <tt>/dev/device<i>d</i>d</tt> to the particular hardware device involved, where <tt><i>d</i></tt> corresponds to the unit number.</p>
+               <p>By convention, reference clock drivers are named in the form <tt>refclock_<i>xxxx</i>.c</tt>, where <i>xxxx</i> is a unique string. Each driver is assigned a unique type number, long-form driver name, short-form driver name and device name. The existing assignments are in the <a href="refclock.html">Reference Clock Drivers</a> page and its dependencies. All drivers supported by the particular hardware and operating system are automatically detected in the autoconfigure phase and conditionally compiled. They are configured when the daemon is started according to the configuration file, as described in the <a href="build/config.html">Configuration Options</a> page.</p>
+               <p>The standard clock driver interface includes a set of common support routines some of which do such things as start and stop the device, open the serial port, and establish special functions such as PPS signal support. Other routines read and write data to the device and process time values. Most drivers need only a little customizing code to, for instance, transform idiosyncratic timecode formats to standard form, poll the device as necessary, and handle exception conditions. A standard interface is available for remote debugging and monitoring programs, such as <tt>ntpq</tt> and <tt>ntpdc</tt>, as well as the <tt>filegen</tt> facility, which can be used to record device status on a continuous basis.</p>
+               <p>The general organization of a typical clock driver includes a receive-interrupt routine to read a timecode from the I/O buffer and convert to internal format, generally in days, hours, minutes, seconds and fraction. Some timecode formats include provisions for leap-second warning and determine the clock hardware and software health. The interrupt routine then calls <tt>refclock_process()</tt> with these data and the timestamp captured at the on-time character of the timecode. This routine saves each sample as received in a circular buffer, which can store from a few up to 60 samples, in cases where the timecodes arrive one per second.</p>
+               <p>The <tt>refclock_transmit()</tt> routine in the interface is called by the system at intervals defined by the poll interval in the peer structure, generally 64 s. This routine in turn calls the transmit poll routine in the driver. In the intended design, the driver calls the <tt>refclock_receive()</tt> to process the offset samples that have accumulated since the last poll and produce the final offset and variance. The samples are processed by recursively discarding median outlyers until about 60 percent of samples remain, then averaging the surviving samples. When a reference clock must be explicitly polled to produce a timecode, the driver can reset the poll interval so that the poll routine is called a specified number of times at 1-s intervals.</p>
+               <p>The interface code and this documentation have been developed over some time and required not a little hard work converting old drivers, etc. Should you find success writing a driver for a new radio or modem service, please consider contributing it to the common good. Send the driver file itself and patches for the other files to Dave Mills (mills@udel.edu).</p>
+               <h4>Conventions, Fudge Factors and Flags</h4>
+               <p>Most drivers support manual or automatic calibration for systematic offset bias using values encoded in the <tt>fudge</tt> configuration command. By convention, the <tt>time1</tt> value defines the calibration offset in seconds. For those drivers that support statistics collection using the <tt>filegen</tt> utility and the <tt>clockstats</tt> file, the <tt>flag4</tt> switch enables the utility. When a PPS signal is available, a special automatic calibration facility is provided. If the <tt>flag1</tt> switch is set and the PPS signal is actively disciplining the system time, the calibration value is automatically adjusted to maintain a residual offset of zero. Should the PPS signal or the prefer peer fail, the adjustment is frozen and the remaining drivers continue to discipline the system clock with a minimum of residual error.</p>
+               <h4 id="file">Files Which Need to be Changed</h4>
+               <p>A new reference clock implementation needs to supply, in addition to the driver itself, several changes to existing files.</p>
+               <dl>
+                       <dt><tt>./include/ntp.h</tt>
+                       <dd>The reference clock type defines are used in many places. Each driver is assigned a unique type number. Unused numbers are clearly marked in the list. A unique <tt>REFCLK_<i>xxxx</i></tt> identification code should be recorded in the list opposite its assigned type number.
+                       <dt><tt>./libntp/clocktypes.c</tt>
+                       <dd>The <tt>./libntp/clktype</tt> array is used by certain display functions. A unique short-form name of the driver should be entered together with its assigned identification code.
+                       <dt><tt>./ntpd/ntp_control.c</tt>
+                       <dd>The <tt>clocktypes</tt> array is used for certain control message displays functions. It should be initialized with the reference clock class assigned to the driver, as per the NTP specification RFC-1305. See the <tt>./include/ntp_control.h</tt> header file for the assigned classes.
+                       <dt><tt>./ntpd/refclock_conf.c</tt>
+                       <dd>This file contains a list of external structure definitions which are conditionally defined. A new set of entries should be installed similar to those already in the table. The <tt>refclock_conf</tt> array is a set of pointers to transfer vectors in the individual drivers. The external name of the transfer vector should be initialized in correspondence with the type number.
+                       <dt><tt>./configure.in</tt>
+                       <dd>This is a configuration file used by the autoconfigure scheme. Add lines similar to the following:
+                               <pre>
+  AC_MSG_CHECKING(FOO clock_description)
+  AC_ARG_ENABLE(FOO,
+      AC_HELP_STRING([--enable-FOO], [x clock_description]),
+      [ntp_ok=$enableval], [ntp_ok=$ntp_eac])
+  if test &quot;$ntp_ok&quot; = &quot;yes&quot;; then
+      ntp_refclock=yes
+      AC_DEFINE(CLOCK_FOO, 1, [Foo clock?])
+  fi
+  AC_MSG_RESULT($ntp_ok)
+</pre>
+                       <dd>(Note that <tt>$ntp_eac</tt> is the value from <tt>--{dis,en}able-all-clocks</tt> for non-PARSE clocks and <tt>$ntp_eacp</tt> is the value from <tt>--{dis,en}able-parse-clocks</tt> for PARSE clocks. See the documentation on the autoconf and automake tools from the GNU distributions.)
+                       <dt><tt>./ntpd/Makefile.am</tt>
+                       <dd>This is the makefile prototype used by the autoconfigure scheme. Add the driver file name to the entries already in the <tt>ntpd_SOURCES</tt> list.
+                       <dd>Do the following sequence of commands:
+                               <pre>
+  autoreconf
+  configure
+</pre>
+                       <dd>or simply run <tt>make</tt>, which will do this command sequence automatically.
+               </dl>
+               <h4 id="intf">Interface Routine Overview</h4>
+               <dl>
+                       <dt><tt>refclock_newpeer</tt> - initialize and start a reference clock
+                       <dd>This routine allocates and initializes the interface structure which supports a reference clock in the form of an ordinary NTP peer. A driver-specific support routine completes the initialization, if used. Default peer variables which identify the clock and establish its reference ID and stratum are set here. It returns one if success and zero if the clock address is invalid or already running, insufficient resources are available or the driver declares a bum rap.
+                       <dt><tt>refclock_unpeer</tt> - shut down a clock
+                       <dd>This routine is used to shut down a clock and return its resources to the system.
+                       <dt><tt>refclock_transmit</tt> - simulate the transmit procedure
+                       <dd>This routine implements the NTP transmit procedure for a reference clock. This provides a mechanism to call the driver at the NTP poll interval, as well as provides a reachability mechanism to detect a broken radio or other madness.
+                       <dt><tt>refclock_sample</tt> - process a pile of samples from the clock
+                       <dd>This routine converts the timecode in the form days, hours, minutes, seconds, milliseconds/microseconds to internal timestamp format. It then calculates the difference from the receive timestamp and assembles the samples in a shift register. It implements a recursive median filter to suppress spikes in the data, as well as determine a rough dispersion estimate. A configuration constant time adjustment <tt>fudgetime1</tt> can be added to the final offset to compensate for various systematic errors. The routine returns one if success and zero if failure due to invalid timecode data or very noisy offsets.
+                       <dd>Note that no provision is included for the year, as provided by some (but not all) radio clocks. Ordinarily, the year is implicit in the Unix file system and hardware/software clock support, so this is ordinarily not a problem. Nevertheless, the absence of the year should be considered more a bug than a feature and may be supported in future.
+                       <dt><tt>refclock_receive</tt> - simulate the receive and packet procedures
+                       <dd>This routine simulates the NTP receive and packet procedures for a reference clock. This provides a mechanism in which the ordinary NTP filter, selection and combining algorithms can be used to suppress misbehaving radios and to mitigate between them when more than one is available for backup.
+                       <dt><tt>refclock_gtlin</tt> - groom next input line and extract timestamp
+                       <dd>This routine processes the timecode received from the clock and removes the parity bit and control characters. If a timestamp is present in the timecode, as produced by the <tt>tty_clk</tt> line discipline/streams module, it returns that as the timestamp; otherwise, it returns the buffer timestamp. The routine return code is the number of characters in the line.
+                       <dt><tt>refclock_open</tt> - open serial port for reference clock
+                       <dd>This routine opens a serial port for I/O and sets default options. It returns the file descriptor if success and zero if failure.
+                       <dt><tt>refclock_ioctl</tt> - set serial port control functions
+                       <dd>This routine attempts to hide the internal, system-specific details of serial ports. It can handle POSIX (<tt>termios</tt>), SYSV (<tt>termio</tt>) and BSD (<tt>sgtty</tt>) interfaces with varying degrees of success. The routine sets up the <tt>tty_clk, chu_clk</tt> and <tt>ppsclock</tt> streams module/line discipline, if compiled in the daemon and requested in the call. The routine returns one if success and zero if failure.
+                       <dt><tt>refclock_control</tt> - set and/or return clock values
+                       <dd>This routine is used mainly for debugging. It returns designated values from the interface structure that can be displayed using ntpdc and the clockstat command. It can also be used to initialize configuration variables, such as <tt>fudgetimes, fudgevalues,</tt> reference ID and stratum.
+                       <dt><tt>refclock_buginfo</tt> - return debugging info
+                       <dd>This routine is used mainly for debugging. It returns designated values from the interface structure that can be displayed using <tt>ntpdc</tt> and the <tt>clkbug</tt> command.
+               </dl>
+               <hr>
+               <center>
+                       <img src="pic/pogo1a.gif" alt="gif"></center>
+               <br>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/icons/home.gif b/html/icons/home.gif
new file mode 100644 (file)
index 0000000..e181298
Binary files /dev/null and b/html/icons/home.gif differ
diff --git a/html/icons/mail2.gif b/html/icons/mail2.gif
new file mode 100644 (file)
index 0000000..21bc1c4
Binary files /dev/null and b/html/icons/mail2.gif differ
diff --git a/html/index.html b/html/index.html
new file mode 100644 (file)
index 0000000..5c19313
--- /dev/null
@@ -0,0 +1,101 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>The Network Time Protocol (NTP) Distribution</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>The Network Time Protocol (NTP) Distribution</h3>
+               <img src="pic/barnstable.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html"><i>P.T. Bridgeport Bear</i>; from <i>Pogo</i>, Walt Kelly</a>
+               <p>Pleased to meet you.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:39</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               <br clear="left">
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#intro">Introduction</a>
+                       <li class="inline"><a href="#build">Building and Installing NTP</a>
+                       <li class="inline"><a href="#conf">Configuring Clients and Servers</a>
+                       <li class="inline"><a href="#prog">Program Manual Pages</a>
+                       <li class="inline"><a href="#docs">Supporting Documentation</a>
+                       <li class="inline"><a href="#back">Background Information</a>
+                       <li class="inline"><a href="#app">Application Notes</a>
+               </ul>
+               <hr>
+               <h4 id="intro">Introduction</h4>
+               <p>Note: The software contained in this distribution is available without charge under the conditions set forth in the <a href="copyright.html">Copyright Notice</a>.</p>
+               <p>The Network Time Protocol (NTP) is used to synchronize the time of a computer client or server to another server or reference time source, such as a radio or satellite receiver or modem. It provides accuracies typically within a millisecond on LANs and up to a few tens of milliseconds on WANs relative to Coordinated Universal Time (UTC) via a Global Positioning Service (GPS) receiver, for example. Typical NTP configurations utilize multiple redundant servers and diverse network paths in order to achieve high accuracy and reliability.</p>
+               <p>This software release implements NTP Version 4 (NTPv4), but is in general backwards compatible with previous versions except NTP Version 1, support for which is no longer viable. NTPv4 includes support for both symmetric key and public key cryptography to prevent accidental or malicious protocol attacks, as well as automatic server discovery using IP multicast means. This release includes full support for the IPv6 address family, where the operating system supports it, as well as the default IPv4 address family. Either or both families can be used at the same time on the same machine.</p>
+               <p>Background information on computer network time synchronization can be found on the <a href="http://www.eecis.udel.edu/%7emills/exec.html">Executive Summary - Computer Network Time Synchronization</a> page. Discussion on protocol conformance issues and interoperability with previous NTP versions can be found on the <a href="http://www.eecis.udel.edu/%7emills/biblio.html">Protocol Conformance Statement</a> page. Discussion on how NTP reckons the time can be found on the <a href="http://www.eecis.udel.edu/%7emills/leap.html">NTP Timescale and Leap Seconds</a> page. Background information, bibliography and briefing slides suitable for presentations can be found on the <a href="http://www.eecis.udel.edu/%7emills/ntp.html">Network Time Synchronization Project</a> page. Additional information can be found at the NTP web site <a href="http://www.ntp.org">www.ntp.org</a>. Please send bug reports to <a href="mailto:bugs@mail.ntp.org">&lt;bugs@mail.ntp.org&gt;</a>.</p>
+               <h4 id="build">Building and Installing NTP</h4>
+               <p>NTP supports Unix and Windows (XP, NT4 and 2000) systems. The <a href="build/build.html">Building and Installing the Distribution</a> page presents an overview of the procedures for compiling the distribution and installing it on a typical client or server. The build procedures inspect the system hardware and software environment and automatically select the appropriate options for that environment. While these procedures work with most computers and operating systems marketed today, exceptions requiring manual intervention do exist, as documented on the <a href="build/config.html">Configuration Options</a> and <a href="release.html">Release Notes</a> pages.</p>
+               <p>Bringing up a NTP primary server requires a radio or satellite receiver or modem. The distribution includes hardware drivers for some forty radio and satellite clocks and modem services. A list of supported drivers is given on the <a href="refclock.html">Reference Clock Drivers</a> page. It is also possible to use an otherwise undisciplined machine as a primary or backup server, as described on the <a href="drivers/driver1.html">Undisciplined Local Clock</a> page. For most popular workstations marketed by Sun, Silicon Graphics and Hewlett Packard, as well as widely available Unix clones such as FreeBSD and Linux, the automatic build procedures select all drivers that run on the target machine. While this increases the size of the executable binary somewhat, individual drivers can be included or excluded using the configure utility documented in the Configuration Options page.</p>
+               <p>Some programs included in this distribution use cryptographic algorithms to verify authenticity and credentials. Where local security policy permits relatively weak symmetric key cryptography, the required software is included in this distribution. However, where local policy requires stronger public key cryptography, additional software not in this distribution is required. This distribution uses the OpenSSL library available from <a href="http://www.openssl.org">http://www.openssl.org</a>. This library is also used by the Secure Shell facility, so is often already installed on Unix workstations and servers. It includes support for most message digest and digital signature algorithms used in the industry, as well as X.509 certificate generation, signing and verification.</p>
+               <p>While public key cryptography is optional but highly recommended for all NTP operations, it is required for the NTPv4 Autokey protocol described on the <a href="http://www.eecis.udel.edu/%7emills/autokey.html">Autonomous Authentication</a> page and is an integral component of the generic automatic configuration scheme described on the <a href="http://www.eecis.udel.edu/%7emills/autocfg.html">Autonomous Configuration</a> page. In addition, access can be restricted in various ways described on the <a href="accopt.html">Access Control Options</a> page.</p>
+               <h4 id="conf">Configuring Clients and Servers</h4>
+               <p>NTP is by its very nature a complex distributed network application and can be configured and used for a great many widely divergent timekeeping scenarios. The documentation presented on these pages attempts to cover the entire suite of configuration, operation and maintenance facilities which this distribution supports. However, most applications will need only a few of these facilities. If this is the case, the <a href="build/quick.html">Quick Start</a> page may be useful to get a simple workstation on the air with an existing server.</p>
+               <p>However, in order to participate in the existing NTP synchronization subnet and obtain accurate, reliable time, it is usually necessary to construct an appropriate configuration file, commonly called <tt>ntp.conf</tt>, which establishes the servers and/or external receivers or modems to be used by this particular machine. Directions for constructing this file are in the <a href="notes.html">Notes on Configuring NTP and Setting up a NTP Subnet</a> page. However, in many common cases involving simple network topologies and workstations, the configuration data can be specified entirely on the command line for the <a href="ntpd.html"><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</a>.</p>
+               <p>The most important factor in providing accurate, reliable time is the selection of modes and servers to be used in the configuration file. A discussion on the available modes is on the <a href="assoc.html">Association Management</a> page. NTP support for one or more computers is normally engineered as part of the existing public NTP synchronization subnet. The public subnet consists of a multiply redundant hierarchy of servers and clients, with each level in the hierarchy identified by stratum number. Primary servers operate at stratum one and provide synchronization to secondary servers operating at stratum two and so on to higher strata. In this hierarchy, clients are simply servers that have no dependents.</p>
+               <p>Configuring a corporate or campus NTP subnet can be an engineering challenge. NTP contains many features designed to survive system and network failures, software bugs, clock errors and hacker attacks. Surviving these hazards requires intricate design of the timekeeping network using good principles of server redundancy and path diversity. The Manycast mode, new to NTPv4, is designed to track the current server and network states and adjust the client/server configuration for the best available accuracy and reliability. More information on the Manycast mode is on the <a href="authopt.html">Athentication Options</a> and <a href="manyopt.html">Automatic NTP Configuration Options</a> pages.</p>
+               <p>The NTP subnet in early 2003 includes well over a hundred public primary (stratum 1) servers synchronized directly to UTC by radio, satellite or modem and located in every continent of the globe, including Antarctica. Normally, client workstations and servers with a relatively small number of clients do not synchronize to primary servers. There are well over a hundred public secondary (stratum 2) servers synchronized to the primary servers and providing synchronization to a total well over 100,000 clients and servers in the Internet. The current lists are maintained on the <a href="http://www.eecis.udel.edu/%7emills/ntp/index.html">Information on Time and Frequency Services</a> page, which is updated frequently. There are thousands upon thousands of private primary and secondary servers not normally available to the public, many hiding behind firewalls. Clients are strongly discouraged against using these servers, since they sometimes hide in little ghettos behind dinky links to the outside world and unwanted traffic can bring up expensive ISDN lines, causing much grief and frustration. There are defensive means described on the Access Control Options page, including the Kiss-of-Death packet.</p>
+               <h4 id="prob">Resolving Problems</h4>
+               <p>Like other things Internet, the NTP synchronization subnets tend to be large and devilishly intricate, with many opportunities for misconfiguration and network problems. The NTP engineering model is specifically designed to help isolate and repair such problems using an integrated management protocol, together with a suite of monitoring and debugging tools. There is an optional statistics data recording facility which can be used to record normal and aberrant operation, log problems to the system log facility, and retain records of client access. The <a href="debug.html">NTP Debugging Techniques</a> and <a href="build/hints.html">Hints and Kinks</a> pages contain useful information for identifying problems and devising solutions. In extreme cases, problems can be detected through the use of the <a href="ntpdsim.html"><tt>ntpdsim</tt> - Network Time Protocol (NTP) simulator</a> included in this software distribution.</p>
+               <p>Users are requested to report bugs, offer suggestions and contribute additions to this distribution. The <a href="build/patches.html">Patching Procedures</a> page suggests procedures which greatly simplify distribution updates, while the <a href="build/porting.html">Porting Hints</a> page suggest ways to make porting this code to new hardware and operating systems easier. Additional information on reference clock driver construction and debugging can be found in the <a href="rdebug.html">Debugging Hints for Reference Clock Drivers</a> page.</p>
+               <h4 id="prog">Program Manual Pages</h4>
+               <ul>
+                       <li class="inline"><a href="ntpd.html"><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</a>
+                       <li class="inline"><a href="ntpq.html"><tt>ntpq</tt> - standard NTP query program</a>
+                       <li class="inline"><a href="ntpdc.html"><tt>ntpdc</tt> - special NTP query program</a>
+                       <li class="inline"><a href="ntpdate.html"><tt>ntpdate</tt> - set the date and time via NTP</a>
+                       <li class="inline"><a href="ntptrace.html"><tt>ntptrace</tt> - trace a chain of NTP servers back to the primary source</a>
+                       <li class="inline"><a href="tickadj.html"><tt>tickadj</tt> - set time-related kernel variables</a>
+                       <li class="inline"><a href="ntptime.html"><tt>ntptime</tt> - read kernel time variables</a>
+                       <li class="inline"><a href="keygen.html"><tt>ntp-keygen</tt> - generate public and private keys</a>
+                       <li class="inline"><a href="ntpdsim.html"><tt>ntpdsim</tt> - Network Time Protocol (NTP) simulator</a>
+               </ul>
+               <h4 id="docs">Supporting Documentation</h4>
+               <ul>
+                       <li class="inline"><a href="copyright.html">Copyright Notice</a>
+                       <li class="inline"><a href="notes.html">Notes on Configuring NTP and Setting up a NTP Subnet</a>
+                       <li class="inline"><a href="release.html">NTP Version 4 Release Notes</a>
+                       <li class="inline"><a href="build/build.html">Building and Installing the Distribution</a>
+                       <li class="inline"><a href="build/config.html">Configuration Options</a>
+                       <li class="inline"><a href="refclock.html">Reference Clock Drivers</a>
+                       <li class="inline"><a href="debug.html">NTP Debugging Techniques</a>
+                       <li class="inline"><a href="rdebug.html">Debugging Reference Clock Drivers</a>
+                       <li class="inline"><a href="msyslog.html"><tt>ntpd</tt> System Log Messages</a>
+                       <li class="inline"><a href="build/patches.html">Patching Procedures</a>
+                       <li class="inline"><a href="build/hints.html">Hints and Kinks</a>
+                       <li class="inline"><a href="build/porting.html">Porting Hints</a>
+               </ul>
+               <h4 id="back">Background Information</h4>
+               <ul>
+                       <li class="inline"><a href="http://www.eecis.udel.edu/%7emills/ntp.html">NTP Project and Reference Library</a>
+                       <li class="inline"><a href="http://www.eecis.udel.edu/%7emills/exec.html">Executive Summary - Computer Network Time Synchronization</a>
+                       <li class="inline"><a href="http://www.eecis.udel.edu/%7emills/y2k.html">The Network Time Protocol Timescale and Era Numbering</a>
+                       <li class="inline"><a href="http://www.eecis.udel.edu/%7emills/leap.html">NTP Timescale and Leap Seconds</a>
+                       <li class="inline"><a href="http://www.eecis.udel.edu/%7emills/biblio.html">Protocol Conformance Statement</a>
+               </ul>
+               <h4 id="app">Application Notes</h4>
+               <ul>
+                       <li class="inline"><a href="prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a>
+                       <li class="inline"><a href="assoc.html">Association Management</a>
+                       <li class="inline"><a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a>
+                       <li class="inline"><a href="measure.html">Time and Time Interval Measurement with Application to Computer and Network Performance Evaluation</a>
+                       <li class="inline"><a href="kern.html">Kernel Model for Precision Timekeeping</a>
+               </ul>
+               <hr>
+               <div align="center">
+                       <img src="pic/pogo1a.gif" alt="gif"></div>
+               <br>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/kern.html b/html/kern.html
new file mode 100644 (file)
index 0000000..cc23504
--- /dev/null
@@ -0,0 +1,34 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Kernel Model for Precision Timekeeping</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Kernel Model for Precision Timekeeping</h3>
+               <p><img src="pic/alice61.gif" alt="gif" align="left"> <a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a></p>
+               <p>Alice touched the kernel and it exploded.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:40</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links11.txt"></script>
+               <hr>
+               <p>The technical report [2], which is a major revision and update of RFC-1589 [3], describes an engineering model for a precision time-of-day function for a generic operating system. The model is based on the principles of disciplined oscillators using phase-lock loops (PLL) and frequency-lock loops (FLL) often found in the engineering literature. The model uses a hybrid PLL/FLL discipline algorithm implemented in the kernel. The algorithm, which is very similar to the algorithm implemented in the NTP daemon, provides automatic time and frequency steering with update intervals from a few seconds to tens of minutes.</p>
+               <p>The hybrid PLL/FLL code described in [2] is included in Solaris and Digital/Compaq/HP Tru64. It includes two system calls <tt>ntp_gettime()</tt> and <tt>ntp_adjtime()</tt> and can discipline the system clock with microsecond resolution. However, newer hardware and kernels with the same system calls can discipline the clock with nanosecond resolution. The new code described in [1] is available for Linux, FreeBSD, SunOS and Tru64; however, only the Linux and FreeBSD implementations, which do not include licensed code, are readily available. The software and documentation, including a simulator used to verify correct behavior, but not involving licensed code, is available at <a href="ftp://ftp.udel.edu/pub/ntp/software/nanokernel.tar.gz">nanokernel.tar.gz</a>.</p>
+               <p>The model also changes the way the system clock is adjusted in time and frequency relative to an external precision timing source, such as described in the <a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page. The NTP software daemon uses the PPS to provide synchronization limited in principle only by the accuracy and stability of the external timing source.</p>
+               <h4>References</h4>
+               <ol>
+                       <li>Mills, D.L., and P.-H. Kamp. The nanokernel. <i>Proc. Precision Time and Time Interval (PTTI) Applications and Planning Meeting</i> (Reston VA, November 2000). Paper: <a href="http://www.eecis.udel.edu/%7emills/database/papers/nano/nano2.ps">PostScript</a> | <a href="http://www.eecis.udel.edu/%7emills/database/papers/nano/nano2.pdf">PDF</a>, Slides: <a href="http://www.eecis.udel.edu/%7emills/database/brief/nano/nano.html">HTML</a> | <a href="http://www.eecis.udel.edu/%7emills/database/brief/nano/nano.ps">PostScript</a> | <a href="http://www.eecis.udel.edu/%7emills/database/brief/nano/nano.pdf">PDF</a> | <a href="http://www.eecis.udel.edu/%7emills/database/brief/nano/nano.ppt">PowerPoint</a>
+                       <li>Mills, D.L. Unix kernel modifications for precision time synchronization. Electrical Engineering Department Report 94-10-1, University of Delaware, October 1994, 24 pp. Abstract: <a href="http://www.eecis.udel.edu/%7emills/database/reports/kern/kerna.ps">PostScript</a> | <a href="http://www.eecis.udel.edu/%7emills/database/reports/kern/kerna.pdf">PDF</a>, Body: <a href="http://www.eecis.udel.edu/%7emills/database/reports/kern/kernb.ps">PostScript</a> | <a href="http://www.eecis.udel.edu/%7emills/database/reports/kern/kernb.pdf">PDF</a>
+                       <li>Mills, D.L. A kernel model for precision timekeeping. Network Working Group Report RFC-1589, University of Delaware, March 1994. 31 pp. <a href="http://www.eecis.udel.edu/%7emills/database/rfc/rfc1589.txt">ASCII</a>
+               </ol>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/keygen.html b/html/keygen.html
new file mode 100644 (file)
index 0000000..7953eb1
--- /dev/null
@@ -0,0 +1,116 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>ntp-keygen - generate public and private keys</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3><tt>ntp-keygen</tt> - generate public and private keys</h3>
+               <img src="pic/alice23.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>Alice holds the key.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">22:32</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="294">Monday, November 07, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links9.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#synop">Synopsis</a>
+                       <li class="inline"><a href="#descrip">Description</a>
+                       <li class="inline"><a href="#run">Running the program</a>
+                       <li class="inline"><a href="#trust">Trusted Hosts and Groups</a>
+                       <li class="inline"><a href="#idexp">Identity Schemes</a>
+                       <li class="inline"><a href="#exam">Example</a>
+                       <li class="inline"><a href="#cmd">Command Line Options</a>
+                       <li class="inline"><a href="#rand">Random Seed File</a>
+                       <li class="inline"><a href="#fmt">Cryptographic Data Files</a>
+                       <li class="inline"><a href="#bug">Bugs</a>
+               </ul>
+               <hr>
+               <h4 id="synop">Synopsis</h4>
+               <p id="intro"><tt>ntp-keygen [ -deGgHIMnPT ] [ -c [RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] [ -i <i>name</i> ] [ -p <i>password</i> ] [ -S [ RSA | DSA ] ] [ -s <i>name</i> ] [ -v <i>nkeys</i> ]</tt></p>
+               <h4 id="descrip">Description</h4>
+               <p>This program generates cryptographic data files used by the NTPv4 authentication and identification schemes. It generates MD5 key files used in symmetric key cryptography. In addition, if the OpenSSL software library has been installed, it generates keys, certificate and identity files used in public key cryptography. These files are used for cookie encryption, digital signature and challenge/response identification algorithms compatible with the Internet standard security infrastructure.</p>
+               <p>By default, files are not encrypted by <tt>ntp-keygen</tt>. The <tt>-p <i>password</i></tt> option specifies the write password and <tt>-q <i>password</i></tt> option the read password for previously encrypted files. The <tt>ntp-keygen</tt> program prompts for the password if it reads an encrypted file and the password is missing or incorrect. If an encrypted file is read successfully and no write password is specified, the read password is used as the write password by default.</p>
+               <p>The <tt>ntpd</tt> configuration command <tt>crypto pw <i>password</i></tt> specifies the read password for previously encrypted files. The daemon expires on the spot if the password is missing or incorrect. For convenience, if a file has been previously encrypted, the default read password is the name of the host running the program. If the previous write password is specified as the host name, these files can be read by that host with no explicit password.</p>
+               <p>All files are in PEM-encoded printable ASCII format, so they can be embedded as MIME attachments in mail to other sites and certificate authorities. File names begin with the prefix <tt>ntpkey_</tt> and end with the postfix <tt><i>_hostname.filestamp</i></tt>, where <tt><i>hostname</i></tt> is usually the string returned by the Unix <tt>gethostname()</tt> routine, and <tt><i>filestamp</i></tt> is the NTP seconds when the file was generated, in decimal digits. This both guarantees uniqueness and simplifies maintenance procedures, since all files can be quickly removed by a <tt>rm ntpkey*</tt> command or all files generated at a specific time can be removed by a <tt>rm *<i>filestamp</i></tt> command. To further reduce the risk of misconfiguration, the first two lines of a file contain the file name and generation date and time as comments.</p>
+               <p>All files are installed by default in the keys directory <tt>/usr/local/etc</tt>, which is normally in a shared filesystem in NFS-mounted networks. The actual location of the keys directory and each file can be overridden by configuration commands, but this is not recommended. Normally, the files for each host are generated by that host and used only by that host, although exceptions exist as noted later on this page.</p>
+               <p>Normally, files containing private values, including the host key, sign key and identification parameters, are permitted root read/write-only; while others containing public values are permitted world readable. Alternatively, files containing private values can be encrypted and these files permitted world readable, which simplifies maintenance in shared file systems. Since uniqueness is insured by the hostname and file name extensions, the files for a NFS server and dependent clients can all be installed in the same shared directory.</p>
+               <p>The recommended practice is to keep the file name extensions when installing a file and to install a soft link from the generic names specified elsewhere on this page to the generated files. This allows new file generations to be activated simply by changing the link. If a link is present, <tt>ntpd</tt> follows it to the file name to extract the filestamp. If a link is not present, <tt>ntpd</tt> extracts the filestamp from the file itself. This allows clients to verify that the file and generation times are always current. The <tt>ntp-keygen</tt> program uses the same extension for all files generated at one time, so each generation is distinct and can be readily recognized in monitoring data.</p>
+               <h4 id="run">Running the program</h4>
+               <p>The safest way to run the <tt>ntp-keygen</tt> program is logged in directly as root. The recommended procedure is change to the keys directory, usually <tt>/ust/local/etc</tt>, then run the program. When run for the first time, or if all <tt>ntpkey</tt> files have been removed, the program generates a RSA host key file and matching RSA-MD5 certificate file, which is all that is necessary in many cases. The program also generates soft links from the generic names to the respective files. If run again, the program uses the same host key file, but generates a new certificate file and link.</p>
+               <p>The host key is used to encrypt the cookie when required and so must be RSA type. By default, the host key is also the sign key used to encrypt signatures. When necessary, a different sign key can be specified and this can be either RSA or DSA type. By default, the message digest type is MD5, but any combination of sign key type and message digest type supported by the OpenSSL library can be specified, including those using the MD2, MD5, SHA, SHA1, MDC2 and RIPE160 message digest algorithms. However, the scheme specified in the certificate must be compatible with the sign key. Certificates using any digest algorithm are compatible with RSA sign keys; however, only SHA and SHA1 certificates are compatible with DSA sign keys.</p>
+               <p>Private/public key files and certificates are compatible with other OpenSSL applications and very likely other libraries as well. Certificates or certificate requests derived from them should be compatible with extant industry practice, although some users might find the interpretation of X509v3 extension fields somewhat liberal. However, the identification parameter files, although encoded as the other files, are probably not compatible with anything other than Autokey.</p>
+               <p>Running the program as other than root and using the Unix <tt>su</tt> command to assume root may not work properly, since by default the OpenSSL library looks for the random seed file <tt>.rnd</tt> in the user home directory. However, there should be only one <tt>.rnd</tt>, most conveniently in the root directory, so it is convenient to define the <tt>$RANDFILE</tt> environment variable used by the OpenSSL library as the path to <tt>/.rnd</tt>.</p>
+               <p>Installing the keys as root might not work in NFS-mounted shared file systems, as NFS clients may not be able to write to the shared keys directory, even as root. In this case, NFS clients can specify the files in another directory such as <tt>/etc</tt> using the <tt>keysdir</tt> command. There is no need for one client to read the keys and certificates of other clients or servers, as these data are obtained automatically by the Autokey protocol.</p>
+               <p>Ordinarily, cryptographic files are generated by the host that uses them, but it is possible for a trusted agent (TA) to generate these files for other hosts; however, in such cases files should always be encrypted. The subject name and trusted name default to the hostname of the host generating the files, but can be changed by command line options. It is convenient to designate the owner name and trusted name as the subject and issuer fields, respectively, of the certificate. The owner name is also used for the host and sign key files, while the trusted name is used for the identity files.</p>
+               <h4 id="trust">Trusted Hosts and Groups</h4>
+               <p>Each cryptographic configuration involves selection of a signature scheme and identification scheme, called a cryptotype, as explained in the <a href="authopt.html">Authentication Options</a> page. The default cryptotype uses RSA encryption, MD5 message digest and TC identification. First, configure a NTP subnet including one or more low-stratum trusted hosts from which all other hosts derive synchronization directly or indirectly. Trusted hosts have trusted certificates; all other hosts have nontrusted certificates. These hosts will automatically and dynamically build authoritative certificate trails to one or more trusted hosts. A trusted group is the set of all hosts that have, directly or indirectly, a certificate trail ending at a trusted host. The trail is defined by static configuration file entries or dynamic means described on the <a href="manyopt.html">Automatic NTP Configuration Options</a> page.</p>
+               <p>On each trusted host as root, change to the keys directory. To insure a fresh fileset, remove all <tt>ntpkey</tt> files. Then run <tt>ntp-keygen -T</tt> to generate keys and a trusted certificate. On all other hosts do the same, but leave off the <tt>-T</tt> flag to generate keys and nontrusted certificates. When complete, start the NTP daemons beginning at the lowest stratum and working up the tree. It may take some time for Autokey to instantiate the certificate trails throughout the subnet, but setting up the environment is completely automatic.</p>
+               <p>If it is necessary to use a different sign key or different digest/signature scheme than the default, run <tt>ntp-keygen</tt> with the <tt>-S</tt><i><tt> type</tt></i> option, where <i><tt>type</tt></i> is either <tt>RSA</tt> or <tt>DSA</tt>. The most often need to do this is when a DSA-signed certificate is used. If it is necessary to use a different certificate scheme than the default, run <tt>ntp-keygen</tt> with the <tt>-c <i>scheme</i></tt> option and selected <i><tt>scheme</tt></i> as needed. If <tt>ntp-keygen</tt> is run again without these options, it generates a new certificate using the same scheme and sign key.</p>
+               <p>After setting up the environment it is advisable to update certificates from time to time, if only to extend the validity interval. Simply run <tt>ntp-keygen</tt> with the same flags as before to generate new certificates using existing keys. However, if the host or sign key is changed, <tt>ntpd</tt> should be restarted. When ntpd is restarted, it loads any new files and restarts the protocol. Other dependent hosts will continue as usual until signatures are refreshed, at which time the protocol is restarted.</p>
+               <h4 id="idexp">Identity Schemes</h4>
+               <p>As mentioned on the Autonomous Authentication page, the default TC identity scheme is vulnerable to a middleman attack. However, there are more secure identity schemes available, including PC, IFF, GQ and MV described on the <a href="http://www.eecis.udel.edu/%7emills/keygen.html">Identification Schemes</a> page. These schemes are based on a TA, one or more trusted hosts and some number of nontrusted hosts. Trusted hosts prove identity using values provided by the TA, while the remaining hosts prove identity using values provided by a trusted host and certificate trails that end on that host. The name of a trusted host is also the name of its sugroup and also the subject and issuer name on its trusted certificate. The TA is not necessarily a trusted host in this sense, but often is.</p>
+               <p>In some schemes there are separate keys for servers and clients. A server can also be a client of another server, but a client can never be a server for another client. In general, trusted hosts and nontrusted hosts that operate as both server and client have parameter files that contain both server and client keys. Hosts that operate only as clients have key files that contain only client keys.</p>
+               <p>The PC scheme supports only one trusted host in the group. On trusted host <i>alice</i> run <tt>ntp-keygen -P -p <i>password</i></tt> to generate the host key file <tt>ntpkey_RSAkey_<i>alice.filestamp</i></tt> and trusted private certificate file <tt>ntpkey_RSA-MD5_cert_<i>alice.filestamp</i></tt>. Copy both files to all group hosts; they replace the files which would be generated in other schemes. On each host <i>bob</i> install a soft link from the generic name <tt>ntpkey_host_<i>bob</i></tt> to the host key file and soft link <tt>ntpkey_cert_<i>bob</i></tt> to the private certificate file. Note the generic links are on <i>bob</i>, but point to files generated by trusted host <i>alice</i>. In this scheme it is not possible to refresh either the keys or certificates without copying them to all other hosts in the group.</p>
+               <p>For the IFF scheme proceed as in the TC scheme to generate keys and certificates for all group hosts, then for every trusted host in the group, generate the IFF&nbsp;parameter file. On trusted host <i>alice</i> run <tt>ntp-keygen -T </tt><tt>-I -p <i>password</i></tt> to produce her parameter file <tt>ntpkey_IFFpar_<i>alice.filestamp</i></tt>, which includes both server and client keys. Copy this file to all group hosts that operate as both servers and clients and install a soft link from the generic <tt>ntpkey_iff_<i>alice</i></tt> to this file. If there are no hosts restricted to operate only as clients, there is nothing further to do. As the IFF scheme is independent of keys and certificates, these files can be refreshed as needed.</p>
+               <p>If a rogue client has the parameter file, it could masquerade as a legitimate server and present a middleman threat. To eliminate this threat, the client keys can be extracted from the parameter file and distributed to all restricted clients. After generating the parameter file, on <i>alice</i> run <tt>ntp-keygen</tt> <tt>-e</tt> and pipe the output to a file or mail program. Copy or mail this file to all restricted clients. On these clients install a soft link from the generic <tt>ntpkey_iff_<i>alice</i></tt> to this file. To further protect the integrity of the keys, each file can be encrypted with a secret password.</p>
+               <p>For the GQ scheme proceed as in the TC scheme to generate keys and certificates for all group hosts, then for every trusted host in the group, generate the IFF parameter file. On trusted host <i>alice</i> run <tt>ntp-keygen -T </tt><tt>-G -p <i>password</i></tt> to produce her parameter file <tt>ntpkey_GQpar_<i>alice.filestamp</i></tt>, which includes both server and client keys. Copy this file to all group hosts and install a soft link from the generic <tt>ntpkey_gq_<i>alice</i></tt> to this file. In addition, on each host <i>bob</i> install a soft link from generic <tt>ntpkey_gq_<i>bob</i></tt> to this file. As the GQ scheme updates the GQ parameters file and certificate at the same time, keys and certificates can be regenerated as needed.</p>
+               <p>For the MV scheme, proceed as in the TC scheme to generate keys and certificates for all group hosts. For illustration assume <i>trish</i> is the TA, <i>alice</i> one of several trusted hosts and <i>bob</i> one of her clients. On TA <i>trish</i> run <tt>ntp-keygen </tt><tt>-V&nbsp;<i>n</i> -p <i>password</i></tt>, where <i>n</i> is the number of revokable keys (typically 5) to produce the parameter file <tt>ntpkeys_MVpar_<i>trish.filestamp </i></tt>and client key files <tt>ntpkeys_MVkey<i>d</i>_<i>trish.filestamp</i></tt> where <i><tt>d</tt></i> is the key number (0 &lt; <i><tt>d</tt></i> &lt; <i>n</i>). Copy the parameter file to <i>alice</i> and install a soft link from the generic <tt>ntpkey_mv_<i>alice</i></tt> to this file. Copy one of the client key files to <i>alice</i> for later distribution to her clients. It doesn't matter which client key file goes to <i>alice</i>, since they all work the same way. <i>Alice</i> copies the client key file to all of her cliens. On client <i>bob</i> install a soft link from generic <tt>ntpkey_mvkey_<i>bob </i></tt>to the client key file. As the MV scheme is independent of keys and certificates, these files can be refreshed as needed.</p>
+               <h4 id="cmd">Command Line Options</h4>
+               <dl>
+                       <dt><tt>-c [ RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ]</tt>
+                       <dd>Select certificate message digest/signature encryption scheme. Note that RSA schemes must be used with a RSA sign key and DSA schemes must be used with a DSA sign key. The default without this option is <tt>RSA-MD5</tt>.
+                       <dt><tt>-d</tt>
+                       <dd>Enable debugging. This option displays the cryptographic data produced in eye-friendly billboards.
+                       <dt><tt>-e</tt>
+                       <dd>Write the IFF&nbsp;client keys to the standard output. This is intended for automatic key distribution by mail.
+                       <dt><tt>-G</tt>
+                       <dd>Generate parameters and keys for the GQ identification scheme, obsoleting any that may exist.
+                       <dt><tt>-g</tt>
+                       <dd>Generate keys for the GQ identification scheme using the existing GQ parameters. If the GQ parameters do not yet exist, create them first.
+                       <dt><tt>-H</tt>
+                       <dd>Generate new host keys, obsoleting any that may exist.
+                       <dt><tt>-I</tt>
+                       <dd>Generate parameters for the IFF identification scheme, obsoleting any that may exist.
+                       <dt><tt>-i <i>name</i></tt>
+                       <dd>Set the suject name to <i>name</i>. This is used as the subject field in certificates and in the file name for host and sign keys.
+                       <dt><tt>-M</tt>
+                       <dd>Generate MD5 keys, obsoleting any that may exist.
+                       <dt><tt>-P</tt>
+                       <dd>Generate a private certificate. By default, the program generates public certificates.
+                       <dt><tt>-p <i>password</i></tt>
+                       <dd>Encrypt generated files containing private data with <tt><i>password</i></tt> and the DES-CBC algorithm.
+                       <dt><tt>-q</tt>
+                       <dd>Set the password for reading files to <tt><i>password</i></tt>.
+                       <dt><tt>-S [ RSA | DSA ]</tt>
+                       <dd>Generate a new sign key of the designated type, obsoleting any that may exist. By default, the program uses the host key as the sign key.
+                       <dt><tt>-s <i>name</i></tt>
+                       <dd>Set the issuer name to <i>name</i>. This is used for the issuer field in certificates and in the file name for identity files.
+                       <dt><tt>-T</tt>
+                       <dd>Generate a trusted certificate. By default, the program generates a non-trusted certificate.
+                       <dt><tt>-V <i>nkeys</i></tt>
+                       <dd>Generate parameters and keys for the Mu-Varadharajan (MV) identification scheme.
+               </dl>
+               <h4 id="rand">Random Seed File</h4>
+               <p>All cryptographically sound key generation schemes must have means to randomize the entropy seed used to initialize the internal pseudo-random number generator used by the library routines. The OpenSSL library uses a designated random seed file for this purpose. The file must be available when starting the NTP daemon and <tt>ntp-keygen</tt> program. If a site supports OpenSSL or its companion OpenSSH, it is very likely that means to do this are already available.</p>
+               <p>It is important to understand that entropy must be evolved for each generation, for otherwise the random number sequence would be predictable. Various means dependent on external events, such as keystroke intervals, can be used to do this and some systems have built-in entropy sources. Suitable means are described in the OpenSSL software documentation, but are outside the scope of this page.</p>
+               <p>The entropy seed used by the OpenSSL library is contained in a file, usually called <tt>.rnd</tt>, which must be available when starting the NTP daemon or the <tt>ntp-keygen</tt> program. The NTP daemon will first look for the file using the path specified by the <tt>randfile</tt> subcommand of the <tt>crypto</tt> configuration command. If not specified in this way, or when starting the <tt>ntp-keygen</tt> program, the OpenSSL library will look for the file using the path specified by the <tt>RANDFILE</tt> environment variable in the user home directory, whether root or some other user. If the <tt>RANDFILE</tt> environment variable is not present, the library will look for the <tt>.rnd</tt> file in the user home directory. If the file is not available or cannot be written, the daemon exits with a message to the system log and the program exits with a suitable error message.</p>
+               <h4 id="priv">Cryptographic Data Files</h4>
+               <p>All other file formats begin with two lines. The first contains the file name, including the generated host name and filestamp. The second contains the datestamp in conventional Unix <tt>date</tt> format. Lines beginning with <tt>#</tt> are considered comments and ignored by the <i><tt>ntp-keygen </tt></i>program and <tt>ntpd</tt> daemon. Cryptographic values are encoded first using ASN.1 rules, then encrypted if necessary, and finally written PEM-encoded printable ASCII format preceded and followed by MIME content identifier lines.</p>
+               <p id="symkey">The format of the symmetric keys file is somewhat different than the other files in the interest of backward compatibility. Since DES-CBC is deprecated in NTPv4, the only key format of interest is MD5 alphanumeric strings. Following hte heard the keys are entered one per line in the format</p>
+               <p><i><tt>keyno type key</tt></i></p>
+               <p>where <i><tt>keyno</tt></i> is a positive integer in the range 1-65,535, <i><tt>type</tt></i> is the string <tt>MD5</tt> defining the key format and <i><tt>key</tt></i> is the key itself, which is a printable ASCII string 16 characters or less in length. Each character is chosen from the 93 printable characters in the range 0x21 through 0x7f excluding space and the '#' character.</p>
+               <p>Note that the keys used by the <tt>ntpq</tt> and <tt>ntpdc</tt> programs are checked against passwords requested by the programs and entered by hand, so it is generally appropriate to specify these keys in human readable ASCII format.</p>
+               <p>The <tt>ntp-keygen</tt> program generates a MD5 symmetric keys file <tt>ntpkey_MD5key_<i>hostname.filestamp</i></tt>. Since the file contains private shared keys, it should be visible only to root and distributed by secure means to other subnet hosts. The NTP daemon loads the file <tt>ntp.keys</tt>, so <tt>ntp-keygen</tt> installs a soft link from this name to the generated file. Subsequently, similar soft links must be installed by manual or automated means on the other subnet hosts. While this file is not used with the Autokey Version 2 protocol, it is needed to authenticate some remote configuration commands used by the <a href="ntpdc.html"><tt>ntpq</tt></a> and <a href="ntpq.html"><tt>ntpdc</tt></a> utilities.</p>
+               <h4 id="bug">Bugs</h4>
+               <p>It can take quite a while to generate some cryptographic values, from one to several minutes with modern architectures such as UltraSPARC and up to tens of minutes to an hour with older architectures such as SPARC IPC.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/ldisc.html b/html/ldisc.html
new file mode 100644 (file)
index 0000000..428a251
--- /dev/null
@@ -0,0 +1,47 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Line Disciplines and Streams Modules</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Line Disciplines and Streams Modules</h3>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:40</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links11.txt"></script>
+               <hr>
+               <h4>Description</h4>
+               <p>Most radio and modem clocks used for a primary (stratum-1) NTP server utilize serial ports operating at speeds of 9600 baud or greater. The intrinsic delay and jitter contributed by the serial port hardware and software driver can accumulate up to a millisecond in newer Unix systems and tens of milliseconds in older ones. In order to reduce the effects of delay and jitter, a set of special line disciplines, stream modules and operating system calls (<tt>ioctls</tt>) can be configured in some Unix kernels. These routines intercept special characters or signals provided by the radio or modem clock and save a timestamp for later processing.</p>
+               <p>The routines provide two important functions. Some insert a timestamp in the receive data stream upon occurance of a designated character or characters at the serial interface. This can be used to timestamp an on-time character produced by a radio clock, for example. Other routines support an application program interface for pulse-per-second (PPS) signals generated by some radio clocks and laboratory instruments. These routines are normally accessed through the PPSAPI application program interface described below.</p>
+               <p>The routines can be compiled in the kernel in older BSD-derived systems, or installed as System V streams modules and either compiled in the kernel or dynamically loaded when required. In either case, they require minor changes in some kernel files and in the NTP daemon <tt>ntpd</tt>. The streams modules can be pushed and popped from the streams stack using conventional System V streams program primitives. Note that some Unix kernels do not support line disciplines and some do not support System V streams. The routines described here are known to work correctly with the Unix kernels called out in the descriptions, but have not been tested for other kernels.</p>
+               <h4><tt>tty_clk</tt> Line Discipline/Streams Module</h4>
+               <p>This routine intercepts characters received from the serial port and passes unchanged all except a set of designated characters to the generic serial port discipline. For each of the exception characters, the character is inserted in the receiver buffer followed by a local timestamp in Unix <tt>timeval</tt> format. Both <tt>select()</tt> and <tt>SIGIO</tt> are supported by the routine. Support for this routine is automatically detected during the NTP build process and interface code compiled as necessary.</p>
+               <p>There are two versions of the <tt>tty_clk</tt> routine. The <tt>tty_clk.c</tt> line discipline is designed for older BSD systems and is compiled in the kernel. The <tt>tty_clk_STREAMS.c</tt> is designed for System V streams, in which case it can be either compiled in the kernel or dynamically loaded. Since these programs are small, unobtrusive, and do nothing unless specifically enabled by an application program, it probably doesn't matter which version is chosen. Instructions on how to configure and build a kernel supporting either of these routines is in the <tt>README</tt> file in the <tt>./kernel</tt> directory.</p>
+               <p>The <tt>tty_clk</tt> routine defines a new ioctl <tt>CLK_SETSTR</tt>, which takes a pointer to a string of no more than 32 characters. Until the first <tt>CLK_SETSTR</tt> is performed, the routine will simply pass through characters. Once it is passed a string by <tt>CLK_SETSTR</tt>, any character in that string will be immediately followed by a timestamp in Unix <tt>timeval</tt> format. You can change the string whenever you want by doing another <tt>CLK_SETSTR</tt>. The character must be an exact, 8 bit match. The character '\000' cannot, be used, as it is the string terminator. Passing an empty string to <tt>CLK_SETSTR</tt> turns off timestamping. Passing <tt>NULL</tt> may produce surprising results.</p>
+               <h4><tt>TIOCDCDTIMESTAMP</tt> ioctl in FreeBSD</h4>
+               <p>This ioctl is included in FreeBSD 2.2 and later. It causes a timestamp to be inserted in the serial port receive data stream when the data carrier detect (DCD) signal is asserted. This is useful for those radio clocks that indicate the on-time epoch by means of a modem control signal. It is not recommended that this be used for PPS timestamps, as this function is available using the PPS application program interface included in FreeBSD 3.4 and later.</p>
+               <p>The <tt>TIOCDCDTIMESTAMP</tt> ioctl() is detected and compiled automatically on FreeBSD systems if available. With FreeBSD 2.2 the measured delay between activation of the DCD signal and the time the timestamp is captured on a 66MHz 486DX2 is 19 <font face="Symbol">m</font>s and on a 100MHz Pentium is 6 <font face="Symbol">m</font>s.</p>
+               <h4><tt>ppsclock</tt>Streams Module (depredated)</h4>
+               <p>This routine is a streams module which causes a timestamp to be captured when the DCD signal is asserted. It is normally used in connection with a PPS signal generated by some radio clocks. However, it is normally used only by the PPSAPI interface and SunOS 4.1.3 and should be avoided in other contexts. Instructions on how to configure and build a kernel supporting either of these routines is in the <tt>README</tt> file in the <tt>./kernel</tt> directory.</p>
+               <p>The ppsclock streams module implements the <tt>CIOGETEV</tt> ioctl, which takes a pointer to the structure</p>
+               <pre>
+struct ppsclockev {
+     struct timeval tv;
+     u_int serial;
+};
+</pre>
+               <p>The <tt>ppsclock</tt> module is pushed on the streams stack of the serial port connected to the DCD line. At each positive-going edge of the PPS signal, the routine latches the current local timestamp and increments a counter. At each <tt>CIOGETEV</tt> ioctl call, the current values of the timestamp and counter are returned in the <tt>ppsclockev</tt> structure.</p>
+               <h4><tt>TIOCSPPS</tt> and <tt>TIOCGETPPSEV</tt> ioctls in Solaris</h4>
+               <p>These ioctls are included in Solaris 2.4 and later. They implement the same function as the <tt>ppsclock</tt> streams module, but are implemented as integrated system calls independent of the streams facility. They are normally used in connection with a pulse-per-second (PPS) signal generated by some radio clocks. However, these ioctls are normally used only by the PPSAPI interface and should be avoided in other contexts. See the Sun documentation for the calling sequence and return values.</p>
+               <p>Users are cautioned that these ioctls function improperly in Solaris versions prior to 2.8 with patch Generic_108528-02.</p>
+               <h4><tt>tty_chu</tt> Line Discipline/Streams Module (depredated)</h4>
+               <p>This routine is a special purpose line discipline for receiving a special timecode broadcast by Canadian time and frequency standard station CHU. It has been removed from the distribution since its function has been replaced by the <a href="drivers/driver7.html">Radio CHU Audio Demodulator/Decoder (type 7)</a> clock driver.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/manyopt.html b/html/manyopt.html
new file mode 100644 (file)
index 0000000..83869ca
--- /dev/null
@@ -0,0 +1,83 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Automatic NTP Configuration Options</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Automatic NTP Configuration Options</h3>
+               <img src="pic/alice51.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>Make sure who your friends are.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">20:55</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="275">Tuesday, October 11, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links9.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#bcst">Broadcasting</a>
+                       <li class="inline"><a href="#mcst">Manycasting</a>
+                       <li class="inline"><a href="#orphan">Orphan Mode</a>
+                       <li class="inline"><a href="#opt">Server Discovery Options</a>
+               </ul>
+               <hr>
+               <h4 id="bcst">Broadcasting</h4>
+               <p>Broadcasting is the simplest way to provide automatic server discovery. It uses the multi-destination paradigm, where the subnet spanning tree is constructed automatically, either by the switches in an Ethernet LAN&nbsp;or the DVMRP&nbsp;or PIM&nbsp;protocols when spanning multiple networks.</p>
+               <p>A broadcast or multicast server is mobilized by the broadcast configuration command. The addresses can be either from the IPv4 broadcast/mulitcast address family or the IPv6 address family. Multiple broadcast server associations can be specified for a single host.</p>
+               <p>A host is enabled for broadcast reception using the <tt>broadcastclient</tt> configuration command, with or without the <tt>novolley</tt> option. Upon receiving the first message from a broadcast server, the client mobilizes an ephemeral client association and exchanges a volley of client/server messages in order to quickly authenticate the source, set the clock and measure the propagation delay, then reverts to listen-only mode. A multicast client is mobilized in the same way using the <tt>multicastclient</tt> configuration command and specified multicast group address.</p>
+               <p>Broadcasting can be used with either symmetric key or public key cryptography. Public key cryptography offers the best protection against compromised keys and is generally considered stronger. By default, either of these two means is required, but this can be overridden by the <tt>disable auth</tt> command.</p>
+               <p>In both broadcast and multicast client operations the client association is demobilized in case of error or timeout due to loss of server or connectivity. </p>
+               <h4 id="mcst">Manycasting</h4>
+               <p>Manycasting is a automatic discovery and configuration paradigm new to NTPv4. It is intended as a means for a client to troll the nearby network neighborhood to find cooperating servers, validate them using cryptographic means and evaluate their time values with respect to other servers that might be lurking in the vicinity. The intended result is that each client mobilizes associations with a given number of the &quot;best&quot; nearby servers, yet automatically reconfigures to sustain this number of servers should one or another fail.</p>
+               <p>Note that the manycast paradigm does not coincide with the anycast paradigm described in RFC-1546, which is designed to find a single server from a clique of servers providing the same service. The manycast paradigm is designed to find a plurality of redundant servers satisfying defined optimality criteria.</p>
+               <p>Manycasting can be used with either symmetric key or public key cryptography. Public key cryptography offers the best protection against compromised keys and is generally considered stronger. By default, either of these two means is required, but this can be overridden by the <tt>disable auth</tt> command.</p>
+               <p>A manycast client association is configured using the <tt>manycastclient</tt> configuration command, which is similar to the <tt>server</tt> configuration command, but with a broadcast or multicast address. Depending on address family. The manycast client sends ordinary client mode messages, but with a broadcast address rather than a unicast address. It sends only if less than a given threshold of servers have been found and then only at the minimum feasible rate and minimum feasible time-to-live (TTL) hops. There can be as many manycast client associations as different broadcast addresses, each one serving as a template for a future unicast client/server association.</p>
+               <p>Manycast servers configured with the <tt>manycastserver</tt> command listen on the specified broadcast address for manycast client messages. If a manycast server is in scope of the current TTL and is itself synchronized to a valid source and operating at a stratum level equal to or lower than the manycast client, it replies to the manycast client message with an ordinary unicast server message.</p>
+               <p>The manycast client receiving this message mobilizes a preemptable client association according to the matching manycast client template, but only if cryptographically authenticated and the server stratum is less than or equal to the client stratum. The client runs the NTP mitigation algorithms, which act to demobilize all but a threshold number of associations according to stratum and synchronization distance. The surviving associations then continue in ordinary client/server mode.</p>
+               <p>If for some reason the number of available servers falls below the threshold, the manycast client resumes sending broadcast messages. The polling strategy is designed to reduce as much as possible the volume of broadcast messages and the effects of implosion due to near-simultaneous arrival of manycast server messages. The strategy is determined by the <tt>tos</tt> and <tt>ttl</tt> configuration commands described below.</p>
+               <p>It is possible and frequently useful to configure a host as both manycast client and manycast server. A number of hosts configured this way and sharing a common group address will automatically organize themselves in an optimum configuration based on stratum and synchronization distance.</p>
+               <p>For example, consider an NTP subnet of two primary servers and several secondary servers and a number of dependent clients. With twoAll servers and clients have identical configuration files including both <tt>multicastclient</tt> and <tt>multicastserver</tt> commands using, for instance, multicast group address 239.1.1.1. Each primary server configuration file must include commands for the primary reference source such as a GPS receiver.</p>
+               <p>The remaining configuration files for all secondary servers and clients have the same contents, except for the <tt>tos</tt> command, which is specific for each stratum level. For stratum 1 and stratum 2 servers, that command is not necessary. For stratum 3 and above servers the <tt>tos floor</tt> value is set to the intended stratum number. Thus, all stratum 3 configuration files use <tt>tos floor 3</tt>, all stratum 4 files use <tt>tos floor 4</tt> and so forth.</p>
+               <p>Once operations have stabilized, the primary servers will find the primary reference source and each other, since they both operate at the same stratum (1), but not with any secondary server or client, since these operate at a higher stratum. The secondary servers will find the servers at the same stratum level. If one of the primary servers loses its GPS receiver, it will continue to operate as a client and other clients will time out the corresponding association and re-associate accordingly.</p>
+               <h4 id="orphan">Orphan Mode</h4>
+               <p>Sometimes it is necessary to operate an NTP&nbsp;subnet in isolation, because a local reference clock is unavailable or connectivity to the Internet is not provided. In such cases it may be necessary that the subnet servers and clients remain synchronized to a common timescale, not necessarily the UTC&nbsp;timescale. Previously, this function was provided by the local clock driver, which could be configured for a server that could be reached, directly or indirectly from all other servers and clients in the subnet.</p>
+               <p>There are many disadvantages using the local clock driver: multiple source redundancy is not possible and the subnet is vulnerable to single-point failures. Orphan mode is intended to replace the need for the local clock driver. It operates in subnet configurations in all modes, including broadcast, and multiple servers and clients and handles seamless switching as primary sources fail and recover.</p>
+               <p>A server or client is enabled for orphan mode using the <tt>tos orphan <i>stratum</i></tt> command, where <tt><i>stratum</i></tt> is some stratum less than 16 and greater than any anticipated stratum that might occur with ordinary Internet servers. This is the same consideration that guides the local clock driver stratum.</p>
+               <p>As long as the stratum of any orphan is less than the orphan stratum, the servers and clients operate in the normal way. However, if the stratum equals or exceeds this stratum, the server or client is considered an orphan. If under these conditions a host has no sources of the same or lower stratum, it is designated an orphan parent; otherwise, it is considered an orphan child. Orphan parents show offset zero, root delay zero and reference ID&nbsp;127.0.0.1, which of course is the Unix loopback address. Orphan children show the mitigated offset of their servers, root delay randomized over a moderate range and reference ID of their system peer. An important distinction is that the entire subnet operates at the same orphan stratum and that the order of preference is the root delay, not the stratum and root distance as usual.</p>
+               <p>For the most flexible and reliable operation, all servers and clients in the subnet should include the <tt>orphan</tt> command in the configuration file and with the same orphan stratum. This provides mutual redundancy and diversity for all NTP&nbsp;modes of operation, including broadcast.</p>
+               <p>For example, consider the case where several campus secondary (stratum 2) servers are configured for public Internet primary servers and with each other using symmetric modes. These servers provide synchronization with a number of department servers using broadcast mode, where each of these servers is configured as both a broadcast server and broadcast client. Individual workstations on the department LAN&nbsp;are configured as broadcast clients only. All servers (not necessarily the clients) have the <tt>orphan 5</tt> command, for example.</p>
+               <p>In normal operation all servers and clients operate below stratum 5, so operate with the subnet configuration determined by stratum and root distance. If all sources are lost at any stratum level, the server or client continues operation as orphan parent. However, if sources at the orphan stratum are found, the host synchronizes to the source with lowest root delay. Since orphan root delay is determined randomly at startup, loops are avoided, even in broadcast modes where multiple servers are available.</p>
+               <h4 id="opt">Server Discovery Options</h4>
+               <dl>
+                       <dt><tt>tos [ ceiling <i>ceiling</i> | cohort {0 | 1} | floor <i>floor</i> | orphan <i>orphan</i> | maxdistance <i>maxdistance</i> | minclock <i>minclock</i> | minsane <i>minsane</i> ]</tt>
+                       <dd>This command affects the clock selection and clustering algorithms. It can be used to select the quality and quantity of peers used to synchronize the system clock and is most useful in manycast mode. The variables operate as follows:
+                               <dl>                                    <dt><tt>beacon <i>beacon</i></tt>
+                                       <dd>The manycast server sends packets at intervals of 64 s if less than  <i><tt>maxclock</tt></i> servers are available. Otherwise, it sends packets at the <i><tt>beacon</tt></i> interval in seconds. The default is 3600 s.<dt><tt>ceiling <i>ceiling</i></tt>
+                                       <dd>Servers with stratum at or above <i>ceiling</i> will be discarded if there are at least <i><tt>minclock</tt></i> peers remaining. This value defaults to 15, but can be changed to any number from 1 to 15.
+                                       <dt><tt>cohort { 0 | 1 }</tt>
+                                       <dd>This is a binary flag which enables (0) or disables (1) manycast server replies to manycast clients with the same stratum level. This is useful to reduce implosions where large numbers of clients with the same stratum level are present. The default is to enable these replies.
+                                       <dt><tt>floor <i>floor</i></tt>
+                                       <dd>Peers with strata below <i>floor</i> will be discarded if there are at least <i>minclock</i> peers remaining. This value defaults to 1, but can be changed to any number from 1 to 15.
+                                       <dt><tt>orphan <i>stratum</i></tt>
+                                       <dd>If <tt><i>stratum</i></tt> is set at some value less than 16 a special orphan mode is enterred when no outside source of synchronization is available. To use orphan mode a number of participants are identically configured both as broadcast client and as broadcast server. One or more participants are configured to use an outside source, either a reference clock or another Internet server. When the source or sources fail, the system stratum is set at <tt><i>stratum</i></tt> and a leader is elected to serve as the reference source. When an outside source of synchronization is again available, the orphan mode is disabled.<dt><tt>mindist <i>mindistance</i></tt>
+                                       <dd>The slection algorithm normally pads each intersection a minimum of one millisecond to avoid needless classification. In some cases, such as reference clocks with high jitter and a PPS signal, it is useful to increase the padding. This command can be used for that purpose. As a general rule, set the mindistance to the maximum expected offset plus the maxiumum expected jitter, in seconds.
+                                       <dt><tt>maxdist <i>maxdistance</i></tt>
+                                       <dd>The selection algorithm accumulates a number of packets before setting the clock in order to use the best data available. The number is determined by the synchronization distance for each association and a limit called the distance threshold. The synchronization distance starts at 16, then drops by a factor of about two as each packet is received. The default distance threshold is 1.0, which usually results in four packets. Setting maxdistance to some value between 1 and 16 can be used to change the number of packets required. For instance, setting it to 16 will set the clock on the first packet received; howver, setting it to this value essentially disables the mitigation and grooming algorithms.
+                                       <dt><tt>minclock <i>minclock</i></tt>
+                                       <dd>The clustering algorithm repeatedly casts out outlyer associations until no more than <i>minclock</i> associations remain. This value defaults to 3, but can be changed to any number from 1 to the number of configured sources.
+                                       <dt><tt>minsane <i>minsane</i></tt>
+                                       <dd>This is the minimum number of candidates available to the clock selection algorithm in order to produce one or more truechimers for the clustering algorithm. If fewer than this number are available, the clock is undisciplined and allowed to run free. The default is 1 for legacy purposes. However, according to principles of Byzantine agreement, <i>minsane</i> should be at least 4 in order to detect and discard a single falseticker.
+                               </dl>
+                       
+                       <dt><tt>ttl <i>hop</i> ...</tt>
+                       <dd>This command specifies a list of TTL values in increasing order. up to 8 values can be specified. In manycast mode these values are used in turn in an expanding-ring search. The default is eight multiples of 32 starting at 31.
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/measure.html b/html/measure.html
new file mode 100644 (file)
index 0000000..9cce97a
--- /dev/null
@@ -0,0 +1,23 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Time and Time Interval Measurement with Application to Computer and Network Performance Evaluation</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Time and Time Interval Measurement with Application to Computer and Network Performance Evaluation</h3>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:41</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <hr>
+               <p>The technical memorandum: <cite>Time and Time Interval Measurement with Application to Computer and Network Performance Evaluation</cite><a href="http://www.eecis.udel.edu/%7emills/database/memos/memo96a.ps">(PostScript) </a>describes a number of techniques for conducting experiments typical of computer network and transmission systems engineering.</p>
+               <p>In most experiments in which time is involved, it is necessary to develop estimates of time, frequency and measurement errors from a series of time measurements between the clocks of a number of computers and ancillary devices interconnected by some kind of computer network. However, time is not a physical quantity, such as mass, nor can it be measured relative to an absolute frame of reference, such as velocity. The only way to measure time in our universe is to compare the reading of one clock, which runs according to its own timescale, with another clock, which runs according to a given timescale, at some given instant or epoch. The errors arise from the precision of time comparisons and the accuracy of frequency estimates between the timescales involved.</p>
+               <p>The usual data collected during a performance run of some experiment might include time offsets, time delays, frequency offsets and various error statistics. While time offsets between two clocks can be measured directly, frequency offsets can be estimated only from two or more time offsets made over some time interval in the experiment. In practice, a sequence of time comparisons can be performed over the lifetime of the experiment and the instantaneous frequency estimated either in real time with a recurrence relation, or retrospectively with a polynomial fit to the data.</p>
+               <p>Estimating time and frequency errors in real time has been studied by a distinct subspecies of physicists who have made a career of the technology involved. Various means including autoregressive models, Kalman filters and simple weighted-average algorithms are used extensively by national standards laboratories to model cesium-clock ensembles. These techniques have been adapted to computer network and transmission engineering problems as well. This memorandum explores issues in performing experiments of this type and summarizes various techniques found useful in practice.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/miscopt.html b/html/miscopt.html
new file mode 100644 (file)
index 0000000..54041b1
--- /dev/null
@@ -0,0 +1,123 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Miscellaneous Options</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Miscellaneous Options</h3>
+               <img src="pic/boom3.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+               <p>We have three, now looking for more.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:50</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="271">Monday, January 09, 2006</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               <hr>
+               <dl>
+                       <dt><tt>broadcastdelay <i>seconds</i></tt>
+                       <dd>The broadcast and multicast modes require a special calibration to determine the network delay between the local and remote servers. Ordinarily, this is done automatically by the initial protocol exchanges between the client and server. In some cases, the calibration procedure may fail due to network or server access controls, for example. This command specifies the default delay to be used under these circumstances. Typically (for Ethernet), a number between 0.003 and 0.007 seconds is appropriate. The default when this command is not used is 0.004 seconds.
+                       <dt><tt>calldelay <i>delay</i></tt>
+                       <dd>This option controls the delay in seconds between the first and second packets sent in burst or iburst mode to allow additional time for a modem or ISDN call to complete.
+                       <dt><tt>driftfile <i>driftfile</i> [<i>
+               minutes </i> [<i> tolerance </i>] ]</tt>
+                       <dd>This command specifies the complete path and name of the file used to record the frequency of the local clock oscillator. This is the same operation as the <tt>-f</tt> command linke option. If the file exists, it is read at startup in order to set the initial frequency and then updated once per hour with the current frequency computed by the daemon. If the file name is specified, but the file itself does not exist, the starts with an initial frequency of zero and creates the file when writing it for the first time. If this command is not given, the daemon will always start with an initial frequency of zero.
+                               <p>The file format consists of a single line containing a single floating point number, which records the frequency offset measured in parts-per-million (PPM). The file is updated by first writing the current drift value into a temporary file and then renaming this file to replace the old version. This implies that <tt>ntpd</tt> must have write permission for the directory the drift file is located in, and that file system links, symbolic or otherwise, should be avoided.</p>
+                       
+<p>The two optional values determine how often the file is written, and
+are particuarly useful when is it desirable to avoid spinning up the
+disk unnecessarily.  The parameter <tt>minutes</tt> is how often the file will be written.  If omitted or less
+than 1, the interval will be 60 minutes (one hour).  The parameter <tt>tolerance</tt> is the
+threshold to skip writing the new value.  If the new value is within
+<tt>tolerance</tt> percent of the last value written (compared out to 3
+decimal places), the write will be
+skipped. The default is 0.0, which means that the write will occur
+unless the current and previous values are the same.  A tolerance of
+.1 equates roughly to a difference in the 2nd decimal place.</p>
+<dt><tt>enable [ auth | bclient | calibrate | kernel | monitor | ntp | pps | stats]</tt><br>
+                               <tt>disable [ auth | bclient | calibrate | kernel | monitor | ntp | pps | stats ]</tt>
+                       <dd>Provides a way to enable or disable various system options. Flags not mentioned are unaffected. Note that all of these flags can be controlled remotely using the <a href="ntpdc.html"><tt>ntpdc</tt></a> utility program.
+                               <dl>
+                                       <dt><tt>auth</tt>
+                                       <dd>Enables the server to synchronize with unconfigured peers only if the peer has been correctly authenticated using either public key or private key cryptography. The default for this flag is enable.
+                                       <dt><tt>bclient</tt>
+                                       <dd>Enables the server to listen for a message from a broadcast or multicast server, as in the <tt>multicastclient</tt> command with default address. The default for this flag is disable.
+                                       <dt><tt>calibrate</tt>
+                                       <dd>Enables the calibrate feature for reference clocks. The default for this flag is disable.
+                                       <dt><tt>kernel</tt>
+                                       <dd>Enables the kernel time discipline, if available. The default for this flag is enable if support is available, otherwise disable.
+                                       <dt><tt>monitor</tt>
+                                       <dd>Enables the monitoring facility. See the <tt>ntpdc</tt> program and the <tt>monlist</tt> command or further information. The default for this flag is enable.
+                                       <dt><tt>ntp</tt>
+                                       <dd>Enables time and frequency discipline. In effect, this switch opens and closes the feedback loop, which is useful for testing. The default for this flag is enable.
+                                       <dt><tt>pps</tt>
+                                       <dd>Enables the pulse-per-second (PPS) signal when frequency and time is disciplined by the precision time kernel modifications. See the <a href="kern.html">A Kernel Model for Precision Timekeeping</a> page for further information. The default for this flag is disable.
+                                       <dt><tt>stats</tt>
+                                       <dd>Enables the statistics facility. See the <a href="monopt.html">Monitoring Options</a> page for further information. The default for this flag is disable
+                               </dl>
+                       <dt><tt>includefile <i>includefile</i></tt>
+                       <dd>This command allows additional configuration commands to be included from a separate file. Include files may be nested to a depth of five; upon reaching the end of any include file, command processing resumes in the previous configuration file. This option is useful for sites that run <tt>ntpd</tt> on multiple hosts, with (mostly) common options (e.g., a restriction list).
+                       <dt><tt>logconfig <i>configkeyword</i></tt>
+                       <dd>This command controls the amount and type of output written to the system <tt>syslog</tt> facility or the alternate <tt>logfile</tt> log file. All <i><tt>configkeyword</tt></i> keywords can be prefixed with <tt>=</tt>, <tt>+</tt> and <tt>-</tt>, where <tt>=</tt> sets the <tt>syslogmask</tt>, <tt>+</tt> adds and <tt>-</tt> removes messages. <tt>syslog messages</tt> can be controlled in four classes (<tt>clock</tt>, <tt>peer</tt>, <tt>sys</tt> and <tt>sync</tt>). Within these classes four types of messages can be controlled: informational messages (<tt>info</tt>), event messages (<tt>events</tt>), statistics messages (<tt>statistics</tt>) and status messages (<tt>status</tt>).
+                               <p>Configuration keywords are formed by concatenating the message class with the event class. The <tt>all</tt> prefix can be used instead of a message class. A message class may also be followed by the <tt>all</tt> keyword to enable/disable all messages of the respective message class. By default, <tt>logconfig</tt> output is set to <tt>allsync</tt>.
+                       <p>Thus, a minimal log configuration could look like this:</p>
+                               <p><tt>logconfig=syncstatus +sysevents</tt></p>
+                               <dl>
+                                       <dd>
+                                               <p>This would just list the synchronizations state of <tt>ntpd</tt> and the major system events. For a simple reference server, the following minimum message configuration could be useful:</p>
+                                       
+                               </dl>
+                       
+                       <dd>
+                               <p><tt>logconfig=allsync +allclock</tt></p>
+                               <dl>
+                                       <dd>
+                                               <p>This configuration will list all clock information and synchronization information. All other events and messages about peers, system events and so on is suppressed.</p>
+                                       
+                               </dl>
+                               <dt><tt>logfile <i>logfile</i></tt>
+                               <dl>
+                                       <dd>
+                                               <p>This command specifies the location of an alternate log file to be used instead of the default system <tt>syslog</tt> facility. This is the same operation as the <tt>-l </tt>command line option.</p>
+                                       
+                               </dl>
+                       <dt><tt>phone <i>dial</i>1 <i>dial</i>2 ...</tt>
+                               <dl>
+                                       <dd>This command is used in conjunction with the ACTS modem driver (type 18). The arguments consist of a maximum of 10 telephone numbers used to dial USNO, NIST or European time services. The Hayes command ATDT&nbsp;is normally prepended to the number, which can contain other modem control codes as well.
+                               </dl>
+                       <dt><tt>setvar <i>variable</i> [default]</tt>
+                       <dd>This command adds an additional system variable. These variables can be used to distribute additional information such as the access policy. If the variable of the form <tt><i>name</i> = <i>value</i></tt> is followed by the <tt>default</tt> keyword, the variable will be listed as part of the default system variables (<tt>ntpq rv</tt> command). These additional variables serve informational purposes only. They are not related to the protocol other that they can be listed. The known protocol variables will always override any variables defined via the <tt>setvar</tt> mechanism. There are three special variables that contain the names of all variable of the same group. The <tt>sys_var_list</tt> holds the names of all system variables. The <tt>peer_var_list</tt> holds the names of all peer variables and the <tt>clock_var_list</tt> holds the names of the reference clock variables.
+                       <dt><tt>tinker [ allan <i>allan</i> | dispersion <i>dispersion</i> | freq <i>freq</i> | huffpuff <i>huffpuff</i> | panic <i>panic</i> | step <i>step</i> | stepout <i>stepout</i> ]</tt>
+                       <dd>This command can be used to alter several system variables in very exceptional circumstances. It should occur in the configuration file before any other configuration options. The default values of these variables have been carefully optimized for a wide range of network speeds and reliability expectations. In general, they interact in intricate ways that are hard to predict and some combinations can result in some very nasty behavior. Very rarely is it necessary to change the default values; but, some folks can't resist twisting the knobs anyway and this command is for them. Emphasis added: twisters are on their own and can expect no help from the support group.
+                               <p>The variables operate as follows:</p>
+                               <dl>
+                                       <dt><tt>allan <i>allan</i></tt>
+                                       <dd>The argument becomes the new value for the Allan intercept, which is a parameter of the PLL/FLL clock discipline algorithm. The value is in  seconds with default 1500 s, which is appropriate for most computer clocks.<dt><tt>dispersion <i>dispersion</i></tt>
+                                       <dd>The argument becomes the new value for the dispersion increase rate, normally .000015 s/s.
+                                       <dt><tt>freq <i>freq</i></tt>
+                                       <dd>The argument becomes the initial value of the frequency offset in parts-per-million. This overrides the value in the frequency file, if present, and avoids the initial training state if it is not.
+                                       <dt><tt>huffpuff <i>huffpuff</i></tt>
+                                       <dd>The argument becomes the new value for the experimental huff-n'-puff filter span, which determines the most recent interval the algorithm will search for a minimum delay. The lower limit is 900 s (15 m), but a more reasonable value is 7200 (2 hours). There is no default, since the filter is not enabled unless this command is given.
+                                       <dt><tt>panic <i>panic</i></tt>
+                                       <dd>The argument is the panic threshold, by default 1000 s. If set to zero, the panic sanity check is disabled and a clock offset of any value will be accepted.
+                                       <dt><tt>step <i>step</i></tt>
+                                       <dd>The argument is the step threshold, by default 0.128 s. It can be set to any positive number in seconds. If set to zero, step adjustments will never occur. Note:&nbsp;The kernel time discipline is disabled if the step threshold is set to zero or greater than the default.
+                                       <dt><tt>stepout <i>stepout</i></tt>
+                                       <dd>The argument is the stepout timeout, by default 900 s. It can be set to any positive number in seconds. If set to zero, the stepout pulses will not be suppressed.
+                               </dl>
+                       <dt><tt>trap <i>host_address</i> [port <i>port_number</i>] [interface <i>interface_address</i>]</tt>
+                       <dd>This command configures a trap receiver at the given host address and port number for sending messages with the specified local interface address. If the port number is unspecified, a value of 18447 is used. If the interface address is not specified, the message is sent with a source address of the local interface the message is sent through. Note that on a multihomed host the interface used may vary from time to time with routing changes.
+                               <p>The trap receiver will generally log event messages and other information from the server in a log file. While such monitor programs may also request their own trap dynamically, configuring a trap receiver will ensure that no messages are lost when the server is started.</p>
+                       <dt><tt>ttl <i>hop</i> ...</tt>
+                       <dd>This command specifies a list of TTL values in increasing order. up to 8 values can be specified. In manycast mode these values are used in turn in an expanding-ring search. The default is eight multiples of 32 starting at 31.
+               </dl>
+               <h4>Files</h4>
+               <tt>ntp.drift</tt> frequency compensation (PPM)
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/monopt.html b/html/monopt.html
new file mode 100644 (file)
index 0000000..a4c073a
--- /dev/null
@@ -0,0 +1,132 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Monitoring Options</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Monitoring Options</h3>
+               <img src="pic/pogo8.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+               <p>The pig watches the logs.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">00:40</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="290">Sunday, December 24, 2006</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               <hr>
+               <tt>ntpd</tt> includes a comprehensive monitoring facility suitable for continuous, long term recording of server and client timekeeping performance. See the <tt>statistics</tt> command below for a listing and example of each type of statistics currently supported. Statistic files are managed using file generation sets and scripts in the <tt>./scripts</tt> directory of this distribution. Using these facilities and Unix <tt>cron</tt> jobs, the datacan be automatically summarized and archived for retrospective analysis.
+               <h4>Monitoring Commands</h4>
+               <dl>
+                       <dt><tt>statistics <i>name</i> [...]</tt>
+                       <dd>Enables writing of statistics records. Currently, six kinds of <i><tt>name</tt></i>statistics are supported.
+                               <dl>
+                                       <dt><tt>clockstats</tt>
+                                       <dd>Enables recording of clock driver statistics information. Each update received from a clock driver appends a line of the following form to the file generation set named <tt>clockstats</tt>:
+                                       <dd><tt>49213 525.624 127.127.4.1 93 226 00:08:29.606 D</tt>
+                                       <dd>The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next field shows the clock address in dotted-quad notation, The final field shows the last timecode received from the clock in decoded ASCII format, where meaningful. In some clock drivers a good deal of additional information can be gathered and displayed as well. See information specific to each clock for further details.
+                                       <dt><tt>cryptostats</tt>
+                                       <dd>This option requires the OpenSSL cryptographic software library. It enables recording of cryptographic public key protocol information. Each message received by the protocol module appends a line of the following form to the file generation set named <tt>cryptostats</tt>:
+                                       <dd><tt>49213 525.624 127.127.4.1 <i>message</i></tt>
+                                       <dd>The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next field shows the peer address in dotted-quad notation, The final <tt><i>message</i></tt> field includes the message type and certain ancillary information. See the <a href="authopt.html">Authentication Options</a> page for further information.
+                                       <dt><tt>loopstats</tt>
+                                       <dd>Enables recording of loop filter statistics information. Each update of the local clock outputs a line of the following form to the file generation set named <tt>loopstats</tt>:
+                                       <dd><tt>50935 75440.031 0.000006019 13.778190 0.000351733 0.0133806     6</tt>
+                                       <dd>The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next five fields show time offset (seconds), frequency offset (parts per million - PPM), RMS jitter (seconds), Allan deviation (PPM) and clock discipline time constant.
+                                       <dt><tt>peerstats</tt>
+                                       <dd>Enables recording of peer statistics information. This includes statistics records of all peers of a NTP server and of special signals, where present and configured. Each valid update appends a line of the following form to the current element of a file generation set named <tt>peerstats</tt>:
+                                       <dt><tt>48773 10847.650 127.127.4.1 9714 -0.001605376 0.000000000 0.001424877 0.000958674</tt>
+                                       <dd>The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next two fields show the peer address in dotted-quad notation and status, respectively. The status field is encoded in hex in the format described in Appendix B of the NTP specification RFC 1305. The final four fields show the offset, delay, dispersion and RMS jitter, all in seconds.
+                                       <dt><tt>rawstats</tt>
+                                       <dd>Enables recording of raw-timestamp statistics information. This includes statistics records of all peers of a NTP server and of special signals, where present and configured. Each NTP message received from a peer or clock driver appends a line of the following form to the file generation set named <tt>rawstats</tt>:
+                                       <dt><tt>50928 2132.543 128.4.1.1 128.4.1.20 3102453281.584327000 3102453281.58622800031 02453332.540806000 3102453332.541458000</tt>
+                                       <dd>The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next two fields show the remote peer or clock address followed by the local address in dotted-quad notation, The final four fields show the originate, receive, transmit and final NTP timestamps in order. The timestamp values are as received and before processing by the various data smoothing and mitigation algorithms.
+                                       <dt><tt>sysstats</tt>
+                                       <dd>Enables recording of <tt>ntpd</tt> statistics counters on a periodic basis. Each hour a line of the following form is appended to the file generation set named <tt>sysstats</tt>:
+                                       <dd><tt>50928 2132.543 36000 81965 0 9546 56 71793 512 540 10 147</tt>
+                                       <dd>The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The remaining ten fields show the statistics counter values accumulated since the last generated line.
+                                               <dl>
+                                                       <dt>Time since restart <tt>36000</tt>
+                                                       <dd>Time in hours since the system was last rebooted.
+                                                       <dt>Packets received <tt>81965</tt>
+                                                       <dd>Total number of packets received.
+                                                       <dt>Packets processed <tt>0</tt>
+                                                       <dd>Number of packets received in response to previous packets sent
+                                                       <dt>Current version <tt>9546</tt>
+                                                       <dd>Number of packets matching the current NTP version.
+                                                       <dt>Previous version <tt>56</tt>
+                                                       <dd>Number of packets matching the previous NTP version.
+                                                       <dt>Bad version <tt>71793</tt>
+                                                       <dd>Number of packets matching neither NTP version.
+                                                       <dt>Access denied <tt>512</tt>
+                                                       <dd>Number of packets denied access for any reason.
+                                                       <dt>Bad length or format <tt>540</tt>
+                                                       <dd>Number of packets with invalid length, format or port number.
+                                                       <dt>Bad authentication <tt>10</tt>
+                                                       <dd>Number of packets not verified as authentic.
+                                                       <dt>Rate exceeded <tt>147</tt>
+                                                       <dd>Number of packets discarded due to rate limitation.
+                                               </dl>
+                                       <dt><tt>timingstats</tt>
+                                       <dd><b>ONLY</b> available when the deamon is compiled with process time debugging support (--enable-debug-timing - costs performance). Enables recording of <tt>ntpd</tt> processing time information for various selected code paths:
+                                       <dd><tt>53876 36.920 10.0.3.5 1 0.000014592 input processing delay</tt>
+                                       <dd>The first two fields show the date (Modified Julian Day) and time (seconds and fraction past UTC midnight). The next field is a potential <tt>peer address</tt>, <tt>-</tt> or <tt>-REFCLOCK-</tt> depending on the associated io source. Then an event count for the number of processed events in the code path follows. The fifth field is the total time spend for the events. The rest of the line denotes the code path description (see source for more information).
+                                       <dt><tt>statsdir <i>directory_path</i></tt>
+                                       <dd>Indicates the full path of a directory where statistics files should be created (see below). This keyword allows the (otherwise constant) <tt>filegen</tt> filename prefix to be modified for file generation sets, which is useful for handling statistics logs.
+                                       <dt><tt>filegen <i>name</i> [file <i>filename</i>] [type <i>typename</i>] [link | nolink] [enable | disable]</tt>
+                                       <dd>Configures setting of generation file set <i>name</i>. Generation file sets provide a means for handling files that are continuously growing during the lifetime of a server. Server statistics are a typical example for such files. Generation file sets provide access to a set of files used to store the actual data. At any time at most one element of the set is being written to. The type given specifies when and how data will be directed to a new element of the set. This way, information stored in elements of a file set that are currently unused are available for administrational operations without the risk of disturbing the operation of <tt>ntpd</tt>. (Most important: they can be removed to free space for new data produced.)
+                                       <dd>Note that this command can be sent from the <tt>ntpdc</tt> program running at a remote location.
+                                               <dl>
+                                                       <dt><i><tt>name</tt></i>
+                                                       <dd>This is the type of the statistics records, as shown in the <tt>statistics</tt> command.
+                                               </dl>
+                                       <dd><tt>file <i>filename</i></tt>
+                                               <dl>
+                                                       <dd>This is the file name for the statistics records. Filenames of set members are built from three concatenated elements <i><tt>prefix</tt></i>, <i><tt>filename</tt></i> and <i><tt>suffix</tt></i>:
+                                                               <dl>
+                                                                       <dt><i><tt>prefix</tt></i>
+                                                                       <dd>This is a constant filename path. It is not subject to modifications via the <tt>filegen</tt> option. It is defined by the server, usually specified as a compile-time constant. It may, however, be configurable for individual file generation sets via other commands. For example, the prefix used with <tt>loopstats</tt> and <tt>peerstats</tt> generation can be configured using the <tt>statsdir</tt> option explained above.
+                                                                       <dt><i><tt>filename</tt></i>
+                                                                       <dd>This string is directly concatenated to the prefix mentioned above (no intervening <tt>/</tt> (slash)). This can be modified using the <tt>file</tt> argument to the <tt>filegen</tt> statement. No <tt>..</tt> elements are allowed in this component to prevent filenames referring to parts outside the filesystem hierarchy denoted by <tt>prefix</tt>.
+                                                                       <dt><i><tt>suffix</tt></i>
+                                                                       <dd>This part is reflects individual elements of a file set. It is generated according to the type of a file set.
+                                                               </dl>
+                                               </dl>
+                                       <dd><tt>type <i>typename</i></tt>
+                                               <dl>
+                                                       <dd>A file generation set is characterized by its type. The following types are supported:
+                                                               <dl>
+                                                                       <dt><tt>none</tt>
+                                                                       <dd>The file set is actually a single plain file.
+                                                                       <dt><tt>pid</tt>
+                                                                       <dd>One element of file set is used per incarnation of a <tt>ntpd</tt> server. This type does not perform any changes to file set members during runtime, however it provides an easy way of separating files belonging to different <tt>ntpd</tt> server incarnations. The set member filename is built by appending a <tt>.</tt> (dot) to concatenated <i>prefix</i> and <i>filename</i> strings, and appending the decimal representation of the process ID of the <tt>ntpd</tt> server process.
+                                                                       <dt><tt>day</tt>
+                                                                       <dd>One file generation set element is created per day. A day is defined as the period between 00:00 and 24:00 UTC. The file set member suffix consists of a <tt>.</tt> (dot) and a day specification in the form <tt>YYYYMMdd. YYYY</tt> is a 4-digit year number (e.g., 1992). <tt>MM</tt> is a two digit month number. <tt>dd</tt> is a two digit day number. Thus, all information written at 10 December 1992 would end up in a file named <tt><i>prefix filename</i>.19921210</tt>.
+                                                                       <dt><tt>week</tt>
+                                                                       <dd>Any file set member contains data related to a certain week of a year. The term week is defined by computing day-of-year modulo 7. Elements of such a file generation set are distinguished by appending the following suffix to the file set filename base: A dot, a 4-digit year number, the letter <tt>W</tt>, and a 2-digit week number. For example, information from January, 10th 1992 would end up in a file with suffix <tt>.1992W1</tt>.
+                                                                       <dt><tt>month</tt>
+                                                                       <dd>One generation file set element is generated per month. The file name suffix consists of a dot, a 4-digit year number, and a 2-digit month.
+                                                                       <dt><tt>year</tt>
+                                                                       <dd>One generation file element is generated per year. The filename suffix consists of a dot and a 4 digit year number.
+                                                                       <dt><tt>age</tt>
+                                                                       <dd>This type of file generation sets changes to a new element of the file set every 24 hours of server operation. The filename suffix consists of a dot, the letter <tt>a</tt>, and an 8-digit number. This number is taken to be the number of seconds the server is running at the start of the corresponding 24-hour period. Information is only written to a file generation by specifying <tt>enable</tt>; output is prevented by specifying <tt>disable</tt>.
+                                                               </dl>
+                                               </dl>
+                                       <dd><tt>link | nolink</tt>
+                                               <dl>
+                                                       <dd>It is convenient to be able to access the current element of a file generation set by a fixed name. This feature is enabled by specifying <tt>link</tt> and disabled using <tt>nolink</tt>. If <tt>link</tt> is specified, a hard link from the current file set element to a file without suffix is created. When there is already a file with this name and the number of links of this file is one, it is renamed appending a dot, the letter <tt>C</tt>, and the pid of the <tt>ntpd</tt> server process. When the number of links is greater than one, the file is unlinked. This allows the current file to be accessed by a constant name.
+                                               </dl>
+                                       <dd><tt>enable | disable</tt>
+                                               <dl>
+                                                       <dd>Enables or disables the recording function.
+                                               </dl>
+                               </dl>
+                               <hr>
+                               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+               </dl>
+       </body>
+
+</html>
diff --git a/html/msyslog.html b/html/msyslog.html
new file mode 100644 (file)
index 0000000..9e03cf8
--- /dev/null
@@ -0,0 +1,122 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+<html>
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>ntpd System Log Messages</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+       <body>
+               <h3><tt>ntpd</tt> System Log Messages</h3>
+               <img src="pic/alice47.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>The mushroom knows all the error codes, which is more than most of us do.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">19:24</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="284">Saturday, October 01, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <p><script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               </p>
+               <hr>
+               <p>You have come here because you found a cryptic message in the system log. This page by no means lists all messages that might be found, since new ones come and old ones go. Generally, however, the most common ones will be found here. They are listed by program module and log severity code in bold: <tt><b>LOG_ERR</b></tt>, <b><tt>LOG_NOTICE</tt></b> and <tt><b>LOG_INFO</b></tt>.</p>
+               <p>Most of the time <b><tt>LOG_ERR</tt></b> messages are fatal, but often <tt>ntpd</tt> limps onward in the hopes of discovering more errors. The <tt><b>LOG_NOTICE</b></tt> messages usually mean the time has changed or some other condition that probably should be noticed. The <tt><b>LOG_INFO</b></tt>&nbsp;messages usually say something about the system operations, but do not affect the time.</p>
+               <p>In the following a '?' character stands for text in the message. The meaning should be clear from context.</p>
+               <h4>Protocol Module</h4>
+               <p><tt><b>LOG_ERR</b></tt></p>
+               <dl>
+                       <dt><tt>buffer overflow ?
+                       </tt>
+                       <dd>Fatal error. An input packet is too long for processing.
+               </dl>
+               <p><tt><b>LOG_NOTICE</b></tt></p>
+               <dl>
+                       <dt><tt>no reply; clock not set</tt>
+                       <dd>In <tt>ntpdate</tt> mode no servers have been found. The server(s) and/or network may be down. Standard debugging procedures apply.
+                               <p><tt><b>LOG_INFO</b></tt></p>
+                       <dt><tt>proto_config: illegal item ?, value ?</tt>
+                       <dd>Program error. Please report to bugs@ntp.org.
+                       <dt><tt>pps sync enabled</tt>
+                       <dd>The PPS signal has been detected and enabled.
+                       <dt><tt>transmit: encryption key ? not found</tt>
+                       <dd>The encryption key is not defined or not trusted.
+                       <dt><tt>precision = ? usec </tt>
+                       <dd>This reports the precision measured for this machine.
+                       <dt><tt>using 10ms tick adjustments</tt>
+                       <dd>Gotcha for some machines with dirty rotten clock hardware.
+                       <dt><tt>no servers reachable</tt>
+                       <dd>The system clock is running on internal batteries. The server(s) and/or network may be down.
+               </dl>
+               <h4>Clock Discipline Module</h4>
+               <p><tt><b>LOG_ERR</b></tt></p>
+               <dl>
+                       <dt><tt>time correction of ? seconds exceeds sanity limit (?); set clock manually to the correct UTC time</tt>.
+                       <dd>Fatal error. Better do what it says, then restart the daemon. Be advised NTP and Unix know nothing about local time zones. The clock must be set to Coordinated Universal Time (UTC). Believe it; by international agreement abbreviations are in French and descriptions are in English.
+                       <dt><tt>sigaction() fails to save SIGSYS trap: ?<br>
+                               </tt><tt>sigaction() fails to restore SIGSYS trap: ?</tt>
+                       <dt>Program error. Please report to bugs@ntp.org.
+               </dl>
+               <p><tt><b>LOG_NOTICE</b></tt></p>
+               <dl>
+                       <dt><tt>frequency error ? exceeds tolerance 500 PPM</tt>
+                       <dd>The hardware clock frequency error exceeds the rate the kernel can correct. This could be a hardware or a kernel problem.
+                       <dt><tt>time slew ? s</tt>
+                       <dd>The time error exceeds the step threshold and is being slewed to the correct time. You may have to wait a very long time.
+                       <dt><tt>time reset ? s</tt>
+                       <dd>The time error exceeds the step threshold and has been reset to the correct time. Computer scientists don't like this, but they can set the <tt>ntpd -x</tt> option and wait forever.
+                       <dt><tt>kernel time sync disabled ?</tt>
+                       <dd>The kernel reports an error. See the codes in the <tt>timex.h</tt> file.
+                       <dt><tt>pps sync disabled</tt>
+                       <dd>The PPS signal has died, probably due to a dead radio, broken wire or loose connector.
+               </dl>
+               <p><tt><b>LOG_INFO</b></tt></p>
+               <dl>
+                       <dt><tt>kernel time sync status ? </tt>
+                       <dd>For information only. See the codes in the <tt>timex.h</tt> file.
+               </dl>
+               <h4>Cryptographic Module</h4>
+               <p><tt><b>LOG_ERR</b></tt></p>
+               <dl>
+                       <dt><tt>cert_parse ?<br>
+                               </tt><tt>cert_sign ?<br>
+                               </tt><tt>crypto_cert ?<br>
+                               </tt><tt>crypto_encrypt ?<br>
+                               </tt><tt>crypto_gq ?<br>
+                               </tt><tt>crypto_iff ?<br>
+                               </tt><tt>crypto_key ?<br>
+                               </tt><tt>crypto_mv ?<br>
+                               </tt><tt>crypto_setup ?<br>
+                               </tt><tt>make_keys ?</tt>
+                       <dd>Usually fatal errors. These messages display error codes returned from the OpenSSL library. See the OpenSSL documentation for explanation.
+                       <dt><tt>crypto_setup: certificate ? is trusted, but not self signed.<br>
+                               </tt><tt>crypto_setup: certificate ? not for this host<br>
+                               </tt><tt>crypto_setup: certificate file ? not found or corrupt<br>
+                               </tt><tt>crypto_setup: host key file ? not found or corrupt<br>
+                               </tt><tt>crypto_setup: host key is not RSA key type<br>
+                               </tt><tt>crypto_setup: random seed file ? not found<br>
+                               </tt><tt>rypto_setup: random seed file not specified</tt>
+                       <dd>Fatal errors. These messages show problems during the initialization procedure.
+               </dl>
+               <p><tt><b>LOG_INFO</b></tt></p>
+               <dl>
+                       <dt><tt>cert_parse: expired ?<br>
+                               </tt><tt>cert_parse: invalid issuer ?<br>
+                               </tt><tt>cert_parse: invalid signature ?<br>
+                               </tt><tt>cert_parse: invalid subject ?</tt>
+                       <dd>There is a problem with a certificate. Operation cannot proceed untill the problem is fixed. If the certificate is local, it can be regenerated using the <tt>ntp-keygen</tt> program. If it is held somewhere else, it must be fixed by the holder.
+                       <dt><tt>crypto_?: defective key<br>
+                               </tt><tt>crypto_?: invalid filestamp<br>
+                               </tt><tt>crypto_?: missing challenge<br>
+                               </tt><tt>crypto_?: scheme unavailable</tt>
+                       <dd>There is a problem with the identity scheme. Operation cannot proceed untill the problem is fixed. Usually errors are due to misconfiguration or an orphan association. If the latter, <tt>ntpd</tt> will usually time out and recover by itself.
+                       <dt><tt>crypto_cert: wrong PEM type ?</tt>
+                       <dd>The certificate does not have MIME type <tt>CERTIFICATE</tt>. You are probably using the wrong type from OpenSSL or an external certificate authority.
+                       <dt><tt>crypto_ident: no compatible identity scheme found</tt>
+                       <dd>Configuration error. The server and client identity schemes are incompatible.
+                       <dt><tt>crypto_tai: kernel TAI update failed</tt>
+                       <dd>The kernel does not support this function. You may need a new kernel or patch.
+                       <dt><tt>crypto_tai: leapseconds file ? error ?</tt>
+                       <dd>The leapseconds file is corrupt. Obtain the latest file from <tt>time.nist.gov</tt>.
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/mx4200data.html b/html/mx4200data.html
new file mode 100644 (file)
index 0000000..7bf66b1
--- /dev/null
@@ -0,0 +1,1074 @@
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>MX4200 Receiver Data Format</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h1>MX4200 Receiver Data Format</h1>
+               <hr>
+               <h2>Table of Contents</h2>
+               <ul>
+                       <li><a href="#control">Control Port Sentences</a>
+                       <li><a href="#input">Control Port Input Sentences</a>
+                               <ul>
+                                       <li><a href="#input_000">$PMVXG,000</a> Initialization/Mode Control - Part A
+                                       <li><a href="#input_001">$PMVXG,001</a> Initialization/Mode Control - Part B
+                                       <li><a href="#input_007">$PMVXG,007</a> Control Port Configuration
+                                       <li><a href="#input_023">$PMVXG,023</a> Time Recovery Configuration
+                                       <li><a href="#input_gpq">$CDGPQ,YYY</a> Query From a Remote Device / Request to Output a Sentence
+                               </ul>
+                       <li><a href="#output">Control Port Output Sentences</a>
+                               <ul>
+                                       <li><a href="#output_000">$PMVXG,000</a> Receiver Status
+                                       <li><a href="#output_021">$PMVXG,021</a> Position, Height, Velocity
+                                       <li><a href="#output_022">$PMVXG,022</a> DOPs
+                                       <li><a href="#output_030">$PMVXG,030</a> Software Configuration
+                                       <li><a href="#output_101">$PMVXG,101</a> Control Sentence Accept/Reject
+                                       <li><a href="#output_523">$PMVXG,523</a> Time Recovery Configuration
+                                       <li><a href="#output_830">$PMVXG,830</a> Time Recovery Results
+                               </ul>
+               </ul>
+               <hr>
+               <h2><a name="control">Control Port Sentences</a></h2>
+               <p>The Control (CDU) Port is used to initialize, monitor, and control the receiver. The structure of the control port sentences is based on the <cite>NMEA-0183</cite> Standard for Interfacing Marine Electronics Navigation Devices (version 1.5). For more details, please refer to the <cite>NMEA-0183</cite> Specification available from the <a href="http://www.nmea.org/">National Marine Electronics Association</a>.</p>
+               <p>Reserved characters are used to indicate the beginning and the end of records in the data stream, and to delimit data fields within a sentence. Only printable ASCII characters (Hex 20 through 7F) may be used in a sentence. <a href="#table_2">Table 2</a> lists the reserved characters and defines their usage. <a href="#table_1">Table 1</a> illustrates the general Magnavox proprietary NMEA sentence format.</p>
+               <h4><a name="table_1">Table 1. Magnavox Proprietary NMEA Sentence Format</a></h4>
+               <code>$PMVXG,XXX,...................*CK </code>
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Character</th>
+                               <th>Meaning</th>
+                       </tr>
+                       <tr>
+                               <td><code>$</code></td>
+                               <td>Sentence Start Character</td>
+                       </tr>
+                       <tr>
+                               <td><code>P</code></td>
+                               <td>Special ID (P = Proprietary)</td>
+                       </tr>
+                       <tr>
+                               <td><code>MVX</code></td>
+                               <td>Originator ID (MVX = Magnavox)</td>
+                       </tr>
+                       <tr>
+                               <td><code>G</code></td>
+                               <td>Interface ID (G = GPS)</td>
+                       </tr>
+                       <tr>
+                               <td><code>XXX</code></td>
+                               <td>Sentence Type</td>
+                       </tr>
+                       <tr>
+                               <td><code>...</code></td>
+                               <td>Data</td>
+                       </tr>
+                       <tr>
+                               <td><code>*</code></td>
+                               <td>Optional Checksum Field Delimiter</td>
+                       </tr>
+                       <tr>
+                               <td><code>CK</code></td>
+                               <td>Optional Checksum</td>
+                       </tr>
+               </table>
+               <h4><a name="table_2">Table 2. NMEA Sentence Reserved Characters</a></h4>
+               <table border>
+                       <tr>
+                               <th>Character</th>
+                               <th>Hex Value</th>
+                               <th>Usage</th>
+                       </tr>
+                       <tr>
+                               <td><code>$</code></td>
+                               <td>24</td>
+                               <td>Start of Sentence Identifier</td>
+                       </tr>
+                       <tr>
+                               <td><code>{cr}{lf}</code></td>
+                               <td>0D 0A</td>
+                               <td>End of Sentence Identifier</td>
+                       </tr>
+                       <tr>
+                               <td><code>,</code></td>
+                               <td>2C</td>
+                               <td>Sentence Delimiter</td>
+                       </tr>
+                       <tr>
+                               <td><code>*</code></td>
+                               <td>2A</td>
+                               <td>Optional Checksum Field Delimiter</td>
+                       </tr>
+               </table>
+               <p>Following the start character <code>$</code>, are five characters which constitute the block label of the sentence. For Magnavox proprietary sentences, this label is always <code>PMVXG</code>. The next field after the block label is the sentence type, consisting of three decimal digits.</p>
+               <p>The data, delimited by commas, follows the sentence type. Note that the receiver uses a free-format parsing algorithm, so you need not send the exact number of characters shown in the examples. You will need to use the commas to determine how many bytes of data need to be retrieved.</p>
+               <p>The notation <code>CK</code> shown in <a href="#table_1">Table 1</a> symbolically indicates the optional checksum in the examples. The checksum is computed by exclusive-ORing all of the bytes between the <code>$</code> and the <code>*</code> characters. The <code>$</code>, <code>*</code> and the checksum are not included in the checksum computation.</p>
+               <p>Checksums are optional for Control Port input sentences, but are highly recommended to limit the effects of communication errors. Magnavox receivers always generate checksums for Control Port output sentences.</p>
+               <p>ASCII data characters are transmitted in the following format:</p>
+               <table border>
+                       <tr>
+                               <td>Data Bits</td>
+                               <td>8 (msb always 0)</td>
+                       </tr>
+                       <tr>
+                               <td>Parity</td>
+                               <td>None</td>
+                       </tr>
+                       <tr>
+                               <td>Stop Bits</td>
+                               <td>1</td>
+                       </tr>
+               </table>
+               <p>NULL fields are fields which do not contain any data. They would appear as two commas together in the sentence format, except for the final field. Some Magnavox proprietary sentences require that the format contain NULL fields. mandatory NULL fields are identified by an '*' next to the respective field.</p>
+               <hr>
+               <h2><a name="input">Control Port Input Sentences</a></h2>
+               These are the subset of the MX4200 control port input sentences sent by the NTP driver to the GPS receiver.
+               <hr>
+               <h3><a name="input_000">$PMVXG,000</a></h3>
+               <h4>Initialization/Mode Control - Part A</h4>
+               Initializes the time, position and antenna height of the MX4200.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Default</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>1</td>
+                               <td>Day</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                               <td>1-31</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>Month</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                               <td>1-12</td>
+                       </tr>
+                       <tr>
+                               <td>3</td>
+                               <td>Year</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                               <td>1991-9999</td>
+                       </tr>
+                       <tr>
+                               <td>4</td>
+                               <td>GMT Time</td>
+                               <td>HHMMSS</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                               <td>000000-235959</td>
+                       </tr>
+                       <tr>
+                               <td>5</td>
+                               <td>WGS-84 Latitude</td>
+                               <td>DDMM.MMMM</td>
+                               <td>Float</td>
+                               <td>0.0</td>
+                               <td>0 - 8959.9999</td>
+                       </tr>
+                       <tr>
+                               <td>6</td>
+                               <td>North/South Indicator</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>N</td>
+                               <td>N,S</td>
+                       </tr>
+                       <tr>
+                               <td>7</td>
+                               <td>WGS-84 Longitude</td>
+                               <td>DDDMM.MMMM</td>
+                               <td>Float</td>
+                               <td>0.0</td>
+                               <td>0 - 17959.9999</td>
+                       </tr>
+                       <tr>
+                               <td>8</td>
+                               <td>East/West Indicator</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>E</td>
+                               <td>E,W</td>
+                       </tr>
+                       <tr>
+                               <td>9</td>
+                               <td>Altitude (height above Mean Sea Level) in meters (WGS-84)</td>
+                               <td>Meters</td>
+                               <td>Float</td>
+                               <td>0.0</td>
+                               <td>+/-99999.0</td>
+                       </tr>
+                       <tr>
+                               <td>10</td>
+                               <td>Not Used</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,000,,,,,,,,,,*48</code><br>
+               <code>$PMVXG,000,,,,,5128.4651,N,00020.0715,W,58.04,*4F</code>
+               <hr>
+               <h3><a name="input_001">$PMVXG,001</a></h3>
+               <h4>Initialization/Mode Control - Part B</h4>
+               Specifies various navigation parameters: Altitude aiding, acceleration DOP limits, and satellite elevation limits.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Default</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>*1</td>
+                               <td>Constrain Altitude</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1</td>
+                               <td>0=3D Only<br>
+                                       1=Auto<br>
+                                       2=2D Only</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>Not Used</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>*3</td>
+                               <td>Horizontal Acceleration Factor</td>
+                               <td>m/sec^2</td>
+                               <td>Float</td>
+                               <td>1.0</td>
+                               <td>0.5-10.0</td>
+                       </tr>
+                       <tr>
+                               <td>*4</td>
+                               <td>Not Used</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>*5</td>
+                               <td>VDOP Limit</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>10</td>
+                               <td>1-9999</td>
+                       </tr>
+                       <tr>
+                               <td>*6</td>
+                               <td>HDOP Limit</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>10</td>
+                               <td>1-9999</td>
+                       </tr>
+                       <tr>
+                               <td>7</td>
+                               <td>Elevation Limit</td>
+                               <td>Deg</td>
+                               <td>Int</td>
+                               <td>5</td>
+                               <td>0-90</td>
+                       </tr>
+                       <tr>
+                               <td>8</td>
+                               <td>Time Output Mode</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>U</td>
+                               <td>U=UTC<br>
+                                       L=Local Time</td>
+                       </tr>
+                       <tr>
+                               <td>9</td>
+                               <td>Local Time Offset</td>
+                               <td>HHMM</td>
+                               <td>Int</td>
+                               <td>0</td>
+                               <td>+/- 0-2359</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,001,3,,0.1,0.1,10,10,5,U,0*06</code>
+               <hr>
+               <h3><a name="input_007">$PMVXG,007</a></h3>
+               <h4>Control Port Output Configuration</h4>
+               This message enables or disables output of the specified sentence and defines the output rate. The user sends this message for each sentence that the receiver is to output.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Default</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>1</td>
+                               <td>Control Port Output Block Label</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>Clear Current Output List</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                               <td>0=No<br>
+                                       1=Yes</td>
+                       </tr>
+                       <tr>
+                               <td>3</td>
+                               <td>Add/Delete Sentence from List</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                               <td>1=Append<br>
+                                       2=Delete</td>
+                       </tr>
+                       <tr>
+                               <td>4</td>
+                               <td>Not Used</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>5</td>
+                               <td>Sentence Output Rate</td>
+                               <td>Sec</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                               <td>1-9999</td>
+                       </tr>
+                       <tr>
+                               <td>6</td>
+                               <td># digits of Precision for CGA and GLL sentences</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>2</td>
+                               <td>2-4</td>
+                       </tr>
+                       <tr>
+                               <td>7</td>
+                               <td>Not Used</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>8</td>
+                               <td>Not Used</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,007,022,0,1,,1,,,*4F</code>
+               <hr>
+               <h3><a name="input_023">$PMVXG,023</a></h3>
+               <h4>Time Recovery Configuration</h4>
+               This message is used to enable/disable the time recovery feature of the receiver. The time synchronization for the 1PPS output is specified in addition to a user time bias and an error tolerance for a valid pulse. This record is accepted in units configured for time recovery. If the back panel contains a 1PPS outlet, the receiver is a time recovery unit.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Default</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>*1</td>
+                               <td>Time Recovery Mode</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>D</td>
+                               <td>D=Dynamic<br>
+                                       S=Static<br>
+                                       K=Known Position<br>
+                                       N=No Time Recovery</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>Time Synchronization</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>G</td>
+                               <td>U=UTC<br>
+                                       G=GPS</td>
+                       </tr>
+                       <tr>
+                               <td>3</td>
+                               <td>Time Mark Mode</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>A</td>
+                               <td>A=Always<br>
+                                       V=Valid Pulses Only</td>
+                       </tr>
+                       <tr>
+                               <td>4</td>
+                               <td>Maximum Time Error</td>
+                               <td>Nsec</td>
+                               <td>Int</td>
+                               <td>100</td>
+                               <td>50-1000</td>
+                       </tr>
+                       <tr>
+                               <td>5</td>
+                               <td>User Time Bias</td>
+                               <td>Nsec</td>
+                               <td>Int</td>
+                               <td>0</td>
+                               <td>+/- 99999</td>
+                       </tr>
+                       <tr>
+                               <td>6</td>
+                               <td>ASCII Time Message Control</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>0</td>
+                               <td>0=No Output<br>
+                                       1=830 to Control Port<br>
+                                       2=830 to Equipment Port</td>
+                       </tr>
+                       <tr>
+                               <td>7</td>
+                               <td>Known Pos PRN</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>0</td>
+                               <td>1-32<br>
+                                       0=Track All Sats</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,023,S,U,A,500,0,1,*16</code>
+               <hr>
+               <h3><a name="input_gpq">$CDGPQ,YYY</a></h3>
+               <h4>Query From a Remote Device / Request to Output a Sentence</h4>
+               Enables the controller to request a one-time transmission of a specific block label. To output messages at a periodic rate, refer to input sentence <a href="#input_007">$PMVXG,007</a>.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Default</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>1:CD</td>
+                               <td>ID of Remote Device</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>&nbsp;</td>
+                               <td>(See <cite>NMEA-0183</cite>)</td>
+                       </tr>
+                       <tr>
+                               <td>2:GP</td>
+                               <td>GPS</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>&nbsp;</td>
+                               <td>(See <cite>NMEA-0183</cite>)</td>
+                       </tr>
+                       <tr>
+                               <td>3:Q</td>
+                               <td>Query</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>&nbsp;</td>
+                               <td>(See <cite>NMEA-0183</cite>)</td>
+                       </tr>
+                       <tr>
+                               <td>4:YYY</td>
+                               <td>Label of Desired Sentence</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>&nbsp;</td>
+                               <td>Any Valid NMEA or Magnavox Sentence Type</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$CDGPQ,030*5E</code>
+               <hr>
+               <h2><a name="output">Control Port Output Sentences</a></h2>
+               These are the subset of the MX4200 control port output sentences recognized by the NTP driver.
+               <hr>
+               <h3><a name="output_000">$PMVXG,000</a></h3>
+               <h4>Receiver Status</h4>
+               Returns the current status of the receiver including the operating mode, number of satellites visible, and the number of satellites being tracked.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>1</td>
+                               <td>Current Receiver Status</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>ACQ=Reacquisition<br>
+                                       ALT=Constellation Selection<br>
+                                       IAC=Initial Acquisition<br>
+                                       IDL=Idle, No Satellites<br>
+                                       NAV=Navigating<br>
+                                       STS=Search The Sky<br>
+                                       TRK=Tracking</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>Number of Satellites that should be Visible</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>0-12</td>
+                       </tr>
+                       <tr>
+                               <td>3</td>
+                               <td>Number of Satellites being Tracked</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>0-12</td>
+                       </tr>
+                       <tr>
+                               <td>4</td>
+                               <td>Time since Last Navigation</td>
+                               <td>HHMM</td>
+                               <td>Int</td>
+                               <td>0-2359</td>
+                       </tr>
+                       <tr>
+                               <td>5</td>
+                               <td>Initialization Status</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>0=Waiting for Initialization<br>
+                                       1=Initialization Complete</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,000,TRK,3,3,0122,1*19</code>
+               <hr>
+               <h3><a name="output_021">$PMVXG,021</a></h3>
+               <h4>Position, Height, Velocity</h4>
+               This sentence gives the receiver position, height, navigation mode and velocity north/east. <em>This sentence is intended for post analysis applications.</em>
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>1</td>
+                               <td>UTC Measurement Time</td>
+                               <td>Seconds into the week</td>
+                               <td>Float</td>
+                               <td>0-604800.00</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>WGS-84 Latitude</td>
+                               <td>DDMM.MMMM</td>
+                               <td>Float</td>
+                               <td>0-89.9999</td>
+                       </tr>
+                       <tr>
+                               <td>3</td>
+                               <td>North/South Indicator</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>N, S</td>
+                       </tr>
+                       <tr>
+                               <td>4</td>
+                               <td>WGS-84 Longitude</td>
+                               <td>DDDMM.MMMM</td>
+                               <td>Float</td>
+                               <td>0-179.9999</td>
+                       </tr>
+                       <tr>
+                               <td>5</td>
+                               <td>East/West Indicator</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>E, W</td>
+                       </tr>
+                       <tr>
+                               <td>6</td>
+                               <td>Altitude (MSL)</td>
+                               <td>Meters</td>
+                               <td>Float</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>7</td>
+                               <td>Geoidal Height</td>
+                               <td>Meters</td>
+                               <td>Float</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>8</td>
+                               <td>Velocity East</td>
+                               <td>M/Sec</td>
+                               <td>Float</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>9</td>
+                               <td>Velocity North</td>
+                               <td>M/Sec</td>
+                               <td>Float</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>10</td>
+                               <td>Navigation Mode</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td><em>Navigating</em><br>
+                                       1=Position From a Remote Device<br>
+                                       2=2D<br>
+                                       3=3D<br>
+                                       4=2D differential<br>
+                                       5=3D differential<br>
+                                       <em>Not Navigating</em><br>
+                                       51=Too Few Satellites<br>
+                                       52=DOPs too large<br>
+                                       53=Position STD too large<br>
+                                       54=Velocity STD too large<br>
+                                       55=Too many iterations for velocity<br>
+                                       56=Too many iterations for position<br>
+                                       57=3 Sat Startup failed</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,021,142244.00,5128.4744,N,00020.0593,W,00054.4,0047.4,0000.1,-000.2,03*66</code>
+               <hr>
+               <h3><a name="output_022">$PMVXG,022</a></h3>
+               <h4>DOPs</h4>
+               This sentence reports the DOP (Dilution Of Precision) values actually used in the measurement processing corresponding to the satellites listed. The satellites are listed in receiver channel order. Fields 11-16 are output only on 12-channel receivers.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>1</td>
+                               <td>UTC Measurement Time</td>
+                               <td>Seconds into the week</td>
+                               <td>Float</td>
+                               <td>0-604800.00</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>East DOP (EDOP)</td>
+                               <td>&nbsp;</td>
+                               <td>Float</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>3</td>
+                               <td>North DOP (NDOP)</td>
+                               <td>&nbsp;</td>
+                               <td>Float</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>4</td>
+                               <td>Vertical DOP (VDOP)</td>
+                               <td>&nbsp;</td>
+                               <td>Float</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>5</td>
+                               <td>PRN on Channel #1</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>6</td>
+                               <td>PRN on Channel #2</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>7</td>
+                               <td>PRN on Channel #3</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>8</td>
+                               <td>PRN on Channel #4</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>9</td>
+                               <td>PRN on Channel #5</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>10</td>
+                               <td>PRN on Channel #6</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>11</td>
+                               <td>PRN on Channel #7</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>12</td>
+                               <td>PRN on Channel #8</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>13</td>
+                               <td>PRN on Channel #9</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>14</td>
+                               <td>PRN on Channel #10</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>15</td>
+                               <td>PRN on Channel #11</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+                       <tr>
+                               <td>16</td>
+                               <td>PRN on Channel #12</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-32</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,022,142243.00,00.7,00.8,01.9,27,26,10,09,13,23*77</code>
+               <hr>
+               <h3><a name="output_030">$PMVXG,030</a></h3>
+               <h4>Software Configuration</h4>
+               This sentence contains the navigation processor and baseband firmware version numbers.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>1</td>
+                               <td>Nav Processor Version Number</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>Baseband Firmware Version Number</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>&nbsp;</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,030,DA35,015</code>
+               <hr>
+               <h3><a name="output_101">$PMVXG,101</a></h3>
+               <h4>Control Sentence Accept/Reject</h4>
+               This sentence is returned (on the Control Port) for every <strong>$PMVXG</strong> and <strong>$XXGPQ</strong> sentence that is received.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>1</td>
+                               <td>Sentence ID</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>Accept/Reject Status</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>0=Sentence Accepted<br>
+                                       1=Bad Checksum<br>
+                                       2=Illegal Value<br>
+                                       3=Unrecognized ID<br>
+                                       4=Wrong # of fields<br>
+                                       5=Required Data Field Missing<br>
+                                       6=Requested Sentence Unavailable</td>
+                       </tr>
+                       <tr>
+                               <td>3</td>
+                               <td>Bad Field Index</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>4</td>
+                               <td>Requested Sentence ID (If field #1 = GPQ)</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>&nbsp;</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,101,GPQ,0,,030*0D</code>
+               <hr>
+               <h3><a name="output_523">$PMVXG,523</a></h3>
+               <h4>Time Recovery Configuration</h4>
+               This sentence contains the configuration of the time recovery function of the receiver.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>1</td>
+                               <td>Time Recovery Mode</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>D=Dynamic<br>
+                                       S=Static<br>
+                                       K=Known Position<br>
+                                       N=No Time Recovery</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>Time Synchronization</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>U=UTC Time<br>
+                                       G=GPS Time</td>
+                       </tr>
+                       <tr>
+                               <td>3</td>
+                               <td>Time Mark Mode</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>A=Always Output Time Pulse<br>
+                                       V=Only when Valid</td>
+                       </tr>
+                       <tr>
+                               <td>4</td>
+                               <td>Maximum Time Error for which a time mark will be considered valid</td>
+                               <td>Nsec</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>5</td>
+                               <td>User Time Bias</td>
+                               <td>Nsec</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>6</td>
+                               <td>Time Message Control</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>0=No Message<br>
+                                       1=830 to Control Port<br>
+                                       2=830 to Equipment Port</td>
+                       </tr>
+                       <tr>
+                               <td>7</td>
+                               <td>Not Used</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                               <td>&nbsp;</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,523,S,U,A,0500,000000,1,0*23</code>
+               <hr>
+               <h3><a name="output_830">$PMVXG,830</a></h3>
+               <h4>Time Recovery Results</h4>
+               This sentence is output approximately 1 second preceding the 1PPS output. It indicates the exact time of the next pulse, whether or not the time mark will be valid (based on operator-specified error tolerance), the time to which the pulse is synchronized, the receiver operating mode, and the time error of the <strong>last</strong> 1PPS output. The leap second flag (Field #11) is not output by older receivers.
+               <p></p>
+               <table border>
+                       <tr>
+                               <th>Field</th>
+                               <th>Description</th>
+                               <th>Units</th>
+                               <th>Format</th>
+                               <th>Range</th>
+                       </tr>
+                       <tr>
+                               <td>1</td>
+                               <td>Time Mark Valid</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>T=Valid<br>
+                                       F=Not Valid</td>
+                       </tr>
+                       <tr>
+                               <td>2</td>
+                               <td>Year</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1993-</td>
+                       </tr>
+                       <tr>
+                               <td>3</td>
+                               <td>Month</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>1-12</td>
+                       </tr>
+                       <tr>
+                               <td>4</td>
+                               <td>Day</td>
+                               <td>Nsec</td>
+                               <td>Int</td>
+                               <td>1-31</td>
+                       </tr>
+                       <tr>
+                               <td>5</td>
+                               <td>Time</td>
+                               <td>HH:MM:SS</td>
+                               <td>Int</td>
+                               <td>00:00:00-23:59:59</td>
+                       </tr>
+                       <tr>
+                               <td>6</td>
+                               <td>Time Synchronization</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>U=UTC<br>
+                                       G=GPS</td>
+                       </tr>
+                       <tr>
+                               <td>7</td>
+                               <td>Operating Mode</td>
+                               <td>&nbsp;</td>
+                               <td>Char</td>
+                               <td>D=Dynamic<br>
+                                       S=Static<br>
+                                       K=Known Position</td>
+                       </tr>
+                       <tr>
+                               <td>8</td>
+                               <td>Oscillator Offset - estimate of oscillator frequency error</td>
+                               <td>PPB</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>9</td>
+                               <td>Time Mark Error of last pulse</td>
+                               <td>Nsec</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>10</td>
+                               <td>User Time Bias</td>
+                               <td>Nsec</td>
+                               <td>Int</td>
+                               <td>&nbsp;</td>
+                       </tr>
+                       <tr>
+                               <td>11</td>
+                               <td>Leap Second Flag - indicates that a leap second will occur. This value is usually zero except during the week prior to a leap second occurrence, when this value will be set to +/-1. A value of +1 indicates that GPS time will be 1 second further ahead of UTC time.</td>
+                               <td>&nbsp;</td>
+                               <td>Int</td>
+                               <td>-1,0,1</td>
+                       </tr>
+               </table>
+               Example:<br>
+               <code>$PMVXG,830,T,1998,10,12,15:30:46,U,S,000298,00003,000000,01*02</code>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/notes.html b/html/notes.html
new file mode 100644 (file)
index 0000000..e757dbd
--- /dev/null
@@ -0,0 +1,280 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Notes on setting up a NTP subnet</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Notes on setting up a NTP subnet</h3>
+               <img src="pic/tonea.gif" alt="gif" align="left">From NBS Special Publication 432 (out of print)
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:44</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <hr>
+               <h4>Introduction</h4>
+               <p>This document is a collection of notes concerning the use of ntpd and related programs, and on coping with the Network Time Protocol (NTP) in general. It is a major rewrite and update of an earlier document written by Dennis Ferguson of the University of Toronto and includes many changes and additions resulting from the NTP Version 3 specification and new Version 4 implementation features. It supersedes earlier documents, which should no longer be used for new configurations.</p>
+               <p><tt>ntpd</tt> includes a complete implementation of the NTP Version 3 specification, as defined in:</p>
+               <ul>
+                       <li>Mills, D.L. Network Time Protocol (Version 3) specification, implementation and analysis. Network Working Group Report RFC-1305, University of Delaware, March 1992, 113 pp. Abstract: <a href="http://www.eecis.udel.edu/%7emills/database/rfc/rfc1305/rfc1305a.ps">PostScript</a> | <a href="http://www.eecis.udel.edu/%7emills/database/rfc/rfc1305/rfc1305a.pdf">PDF</a>, Body: <a href="http://www.eecis.udel.edu/%7emills/database/rfc/rfc1305/rfc1305b.ps">PostScript</a> | <a href="http://www.eecis.udel.edu/%7emills/database/rfc/rfc1305/rfc1305b.pdf">PDF</a>, Appendices: <a href="http://www.eecis.udel.edu/%7emills/database/rfc/rfc1305/rfc1305c.ps">PostScript</a> | <a href="http://www.eecis.udel.edu/%7emills/database/rfc/rfc1305/rfc1305c.pdf">PDF</a>
+               </ul>
+               <p>Additional features have are described for <a href="release.html">NTP Version 4 Release Notes</a>. It also retains compatibility with both NTP Version 2, as defined in RFC-1119, and NTP Version 1, as defined in RFC-1059, although this compatibility is sometimes strained and only semiautomatic. In order to support in principle the ultimate precision of about 232 picoseconds in the NTP specification, <tt>ntpd</tt> uses NTP timestamp format for external communication and double precision floating point arithmetic internally. <tt>ntpd</tt> fully implements NTP Versions 2 and 3 authentication and in addition Version 4 autokey. It supports the NTP mode-6 control message facility along with a private mode-7 control- message facility used to remotely reconfigure the system and monitor a considerable amount of internal detail. As extensions to the specification, a flexible address-and-mask restriction facility has been included.</p>
+               <p>The code is biased towards the needs of a busy time server with numerous, often hundreds, of clients and other servers. Tables are hashed to allow efficient handling of many associations, though at the expense of additional overhead when the number of associations is small. Many fancy features have been included to permit efficient management and monitoring of a busy primary server, features which are probably excess baggage for a high stratum client. In such cases, a stripped-down version of the protocol, the Simple Network Time Protocol (SNTP) can be used. SNTP and NTP servers and clients can interwork in most situations, as described in: Mills, D.L. Simple Network Time Protocol (SNTP). Network Working Group Report RFC-2030, University of Delaware, October 1996, 14 pp. <a href="http://www.eecis.udel.edu/%7emills/database/rfc2030.txt">(ASCII)</a>.</p>
+               <p>The code was written with near demonic attention to details which can affect precision and as a consequence should be able to make good use of high performance, special purpose hardware such as precision oscillators and radio clocks. The present code supports a number of radio clocks, including those for the WWV, CHU, WWVB, MSF, DCF77, GOES and GPS radio and satellite time services and USNO, ACTS and PTB modem time services. It also supports the IRIG-B and IRIG-E signal format connected via an audio codec. The server methodically avoids the use of Unix-specific library routines where possible by implementing local versions, in order to aid in porting the code to perverse Unix and non-Unix platforms.</p>
+               <p>While this implementation conforms in most respects to the NTP Version 3 specification RFC-1305, a number of improvements have been made which are described in the conformance statement in the <a href="http://www.eecis.udel.edu/%7emills/biblio.html">NTP Protocol Conformance Statement</a> page. It has been specifically tuned to achieve the highest accuracy possible on whatever hardware and operating-system platform is available. In general, its precision and stability are limited only by the characteristics of the onboard clock source used by the hardware and operating system, usually an uncompensated crystal oscillator. On modern RISC-based processors connected directly to radio clocks via serial-asynchronous interfaces, the accuracy is usually limited by the radio clock and interface to the order of a millisecond or less. The code includes special features to support a pulse-per-second (PPS) signal and/or an IRIG-B signal generated by some radio clocks. When used in conjunction with a suitable hardware level converter, the accuracy can be improved to a few tens of microseconds. Further improvement is possible using an outboard, stabilized frequency source, in which the accuracy and stability are limited only by the characteristics of that source.</p>
+               <p>The NTP Version 4 distribution includes, in addition to the daemon itself (<tt><a href="ntpd.html">ntpd</a></tt>), several utility programs, including two remote-monitoring programs (<a href="ntpq.html"><tt>ntpq</tt></a>, <tt><a href="ntpdc.html">ntpdc</a></tt>), a remote clock-setting program similar to the Unix rdate program (<tt>ntpdate</tt>), a traceback utility useful to discover suitable synchronization sources (<tt>ntptrace</tt>), and various programs used to configure the local platform and calibrate the intrinsic errors. NTP has been ported to a large number of platforms, including most RISC and CISC workstations and mainframes manufactured today. Example configuration files for many models of these machines are included in the distribution. While in most cases the standard version of the implementation runs with no hardware or operating system modifications, not all features of the distribution are available on all platforms. For instance, a special feature allowing Sun workstations to achieve accuracies in the order of 100 microseconds requires some minor changes and additions to the kernel and input/output support.</p>
+               <p>There are, however, several drawbacks to all of this. <tt>ntpd</tt> is quite fat. This is rotten if your intended platform for the daemon is memory limited. <tt>ntpd</tt> uses <tt>SIGIO</tt> for all input, a facility which appears to not enjoy universal support and whose use seems to exercise the parts of your vendors' kernels which are most likely to have been done poorly. The code is unforgiving in the face of kernel problems which affect performance, and generally requires that you repair the problems in order to achieve acceptable performance. The code has a distinctly experimental flavour and contains features which could charitably be termed failed experiments, but which have not been completely hacked out. Much was learned from the addition of support for a variety of radio clocks, with the result that some radio clock drivers could use some rewriting.</p>
+               <h4>How NTP Works</h4>
+               <p>The approach used by NTP to achieve reliable time synchronization from a set of possibly unreliable remote time servers is somewhat different than other protocols. In particular, NTP does not attempt to synchronize clocks to each other. Rather, each server attempts to synchronize to Universal Coordinated Time (UTC) using the best available source and available transmission paths to that source. This is a fine point which is worth understanding. A group of NTP-synchronized clocks may be close to each other in time, but this is not a consequence of the clocks in the group having synchronized to each other, but rather because each clock has synchronized closely to UTC via the best source it has access to. As such, trying to synchronize a set of clocks to a set of servers whose time is not in mutual agreement may not result in any sort of useful synchronization of the clocks, even if you don't care about UTC. However, in networks isolated from UTC sources, provisions can made to nominate one of them as a phantom UTC source.</p>
+               <p>NTP operates on the premise that there is one true standard time, and that if several servers which claim synchronization to standard time disagree about what that time is, then one or more of them must be broken. There is no attempt to resolve differences more gracefully since the premise is that substantial differences cannot exist. In essence, NTP expects that the time being distributed from the root of the synchronization subnet will be derived from some external source of UTC (e.g., a radio clock). This makes it somewhat inconvenient (though by no means impossible) to synchronize hosts together without a reliable source of UTC to synchronize them to. If your network is isolated and you cannot access other people's servers across the Internet, a radio clock may make a good investment.</p>
+               <p>Time is distributed through a hierarchy of NTP servers, with each server adopting a <i>stratum</i> which indicates how far away from an external source of UTC it is operating at. Stratum-1 servers, which are at the top of the pile (or bottom, depending on your point of view), have access to some external time source, usually a radio clock synchronized to time signal broadcasts from radio stations which explicitly provide a standard time service. A stratum-2 server is one which is currently obtaining time from a stratum-1 server, a stratum-3 server gets its time from a stratum-2 server, and so on. To avoid long lived synchronization loops the number of strata is limited to 15.</p>
+               <p>Each client in the synchronization subnet (which may also be a server for other, higher stratum clients) chooses exactly one of the available servers to synchronize to, usually from among the lowest stratum servers it has access to. This is, however, not always an optimal configuration, for indeed NTP operates under another premise as well, that each server's time should be viewed with a certain amount of distrust. NTP really prefers to have access to several sources of lower stratum time (at least three) since it can then apply an agreement algorithm to detect insanity on the part of any one of these. Normally, when all servers are in agreement, NTP will choose the best of these, where &quot;best&quot; is defined in terms of lowest stratum, closest (in terms of network delay) and claimed precision, along with several other considerations. The implication is that, while one should aim to provide each client with three or more sources of lower stratum time, several of these will only be providing backup service and may be of lesser quality in terms of network delay and stratum (i.e., a same-stratum peer which receives time from lower stratum sources the local server doesn't access directly can also provide good backup service).</p>
+               <p>Finally, there is the issue of association modes. There are a number of modes in which NTP servers can associate with each other, with the mode of each server in the pair indicating the behaviour the other server can expect from it. In particular, when configuring a server to obtain time from other servers, there is a choice of two modes which may be used. Configuring an association in symmetric-active mode (usually indicated by a <tt>peer</tt> declaration in the configuration file) indicates to the remote server that one wishes to obtain time from the remote server and that one is also willing to supply time to the remote server if need be. This mode is appropriate in configurations involving a number of redundant time servers interconnected via diverse network paths, which is presently the case for most stratum-1 and stratum-2 servers on the Internet today. Configuring an association in client mode (usually indicated by a <tt>server</tt> declaration in the configuration file) indicates that one wishes to obtain time from the remote server, but that one is not willing to provide time to the remote server. This mode is appropriate for file-server and workstation clients that do not provide synchronization to other local clients. Client mode is also useful for boot-date-setting programs and the like, which really have no time to provide and which don't retain state about associations over the longer term.</p>
+               <p>Where the requirements in accuracy and reliability are modest, clients can be configured to use broadcast and/or multicast modes. These modes are not normally utilized by servers with dependent clients. The advantage of these modes is that clients do not need to be configured for a specific server, so that all clients operating can use the same configuration file. Broadcast mode requires a broadcast server on the same subnet, while multicast mode requires support for IP multicast on the client machine, as well as connectivity via the MBONE to a multicast server. Since broadcast messages are not propagated by routers, only those broadcast servers on the same subnet will be used. There is at present no way to select which of possibly many multicast servers will be used, since all operate on the same group address.</p>
+               <p>Where the maximum accuracy and reliability provided by NTP are needed, clients and servers operate in either client/server or symmetric modes. Symmetric modes are most often used between two or more servers operating as a mutually redundant group. In these modes, the servers in the group members arrange the synchronization paths for maximum performance, depending on network jitter and propagation delay. If one or more of the group members fail, the remaining members automatically reconfigure as required. Dependent clients and servers normally operate in client/server mode, in which a client or dependent server can be synchronized to a group member, but no group member can synchronize to the client or dependent server. This provides protection against malfunctions or protocol attacks.</p>
+               <p>Servers that provide synchronization to a sizeable population of clients normally operate as a group of three or more mutually redundant servers, each operating with three or more stratum-one or stratum-two servers in client-server modes, as well as all other members of the group in symmetric modes. This provides protection against malfunctions in which one or more servers fail to operate or provide incorrect time. The NTP algorithms have been specifically engineered to resist attacks where some fraction of the configured synchronization sources accidently or purposely provide incorrect time. In these cases a special voting procedure is used to identify spurious sources and discard their data.</p>
+               <h4>Configuring Your Subnet</h4>
+               At startup time the <tt>ntpd</tt> daemon running on a host reads the initial configuration information from a file, usually <tt>/etc/ntp.conf</tt>, unless a different name has been specified at compile time. Putting something in this file which will enable the host to obtain time from somewhere else is usually the first big hurdle after installation of the software itself, which is described in the <a href="build/build.html">Building and Installing the Distribution</a> page. At its simplest, what you need to do in the configuration file is declare the servers that the daemon should poll for time synchronization. In principle, no such list is needed if some other time server operating in broadcast/multicast mode is available, which requires the client to operate in a broadcastclient mode.
+               <p>In the case of a workstation operating in an enterprise network for a public or private organization, there is often an administrative department that coordinates network services, including NTP. Where available, the addresses of appropriate servers can be provided by that department. However, if this infrastructure is not available, it is necessary to explore some portion of the existing NTP subnet now running in the Internet. There are at present many thousands of time servers running NTP in the Internet, a significant number of which are willing to provide a public time- synchronization service. Some of these are listed in the list of public time servers, which can be accessed via the <a href="http://www.eecis.udel.edu/%7entp">NTP web page</a>. These data are updated on a regular basis using information provided voluntarily by various site administrators. There are other ways to explore the nearby subnet using the <tt><a href="ntptrace.html">ntptrace</a></tt> and <tt><a href="ntpdc.html">ntpdc</a></tt> programs.</p>
+               <p>It is vital to carefully consider the issues of robustness and reliability when selecting the sources of synchronization. Normally, not less than three sources should be available, preferably selected to avoid common points of failure. It is usually better to choose sources which are likely to be &quot;close&quot; to you in terms of network topology, though you shouldn't worry overly about this if you are unable to determine who is close and who isn't. Normally, it is much more serious when a server becomes faulty and delivers incorrect time than when it simply stops operating, since an NTP-synchronized host normally can coast for hours or even days without its clock accumulating serious error approaching a second, for instance. Selecting at least three sources from different operating administrations, where possible, is the minimum recommended, although a lesser number could provide acceptable service with a degraded degree of robustness.</p>
+               <p>Normally, it is not considered good practice for a single workstation to request synchronization from a primary (stratum-1) time server. At present, these servers provide synchronization for hundreds of clients in many cases and could, along with the network access paths, become seriously overloaded if large numbers of workstation clients requested synchronization directly. Therefore, workstations located in sparsely populated administrative domains with no local synchronization infrastructure should request synchronization from nearby stratum-2 servers instead. In most cases the keepers of those servers in the lists of public servers provide unrestricted access without prior permission; however, in all cases it is considered polite to notify the administrator listed in the file upon commencement of regular service. In all cases the access mode and notification requirements listed in the file must be respected. Under no conditions should servers not in these lists be used without prior permission, as to do so can create severe problems in the local infrastructure, especially in cases of dial-up access to the Internet.</p>
+               <p>In the case of a gateway or file server providing service to a significant number of workstations or file servers in an enterprise network it is even more important to provide multiple, redundant sources of synchronization and multiple, diversity-routed, network access paths. The preferred configuration is at least three administratively coordinated time servers providing service throughout the administrative domain including campus networks and subnetworks. Each of these should obtain service from at least two different outside sources of synchronization, preferably via different gateways and access paths. These sources should all operate at the same stratum level, which is one less than the stratum level to be used by the local time servers themselves. In addition, each of these time servers should peer with all of the other time servers in the local administrative domain at the stratum level used by the local time servers, as well as at least one (different) outside source at this level. This configuration results in the use of six outside sources at a lower stratum level (toward the primary source of synchronization, usually a radio clock), plus three outside sources at the same stratum level, for a total of nine outside sources of synchronization. While this may seem excessive, the actual load on network resources is minimal, since the interval between polling messages exchanged between peers usually ratchets back to no more than one message every 17 minutes.</p>
+               <p>The stratum level to be used by the local time servers is an engineering choice. As a matter of policy, and in order to reduce the load on the primary servers, it is desirable to use the highest stratum consistent with reliable, accurate time synchronization throughout the administrative domain. In the case of enterprise networks serving hundreds or thousands of client file servers and workstations, conventional practice is to obtain service from stratum-1 primary servers listed for public access. When choosing sources away from the primary sources, the particular synchronization path in use at any time can be verified using the <tt>ntptrace</tt> program included in this distribution. It is important to avoid loops and possible common points of failure when selecting these sources. Note that, while NTP detects and rejects loops involving neighboring servers, it does not detect loops involving intervening servers. In the unlikely case that all primary sources of synchronization are lost throughout the subnet, the remaining servers on that subnet can form temporary loops and, if the loss continues for an interval of many hours, the servers will drop off the subnet and free-run with respect to their internal (disciplined) timing sources. After some period with no outside timing source (currently one day), a host will declare itself unsynchronized and provide this information to local application programs.</p>
+               <p>In many cases the purchase of one or more radio clocks is justified, in which cases good engineering practice is to use the configurations described above anyway and connect the radio clock to one of the local servers. This server is then encouraged to participate in a special primary-server subnetwork in which each radio-equipped server peers with several other similarly equipped servers. In this way the radio-equipped server may provide synchronization, as well as receive synchronization, should the local or remote radio clock(s) fail or become faulty. <tt>ntpd</tt> treats attached radio clock(s) in the same way as other servers and applies the same criteria and algorithms to the time indications, so can detect when the radio fails or becomes faulty and switch to alternate sources of synchronization. It is strongly advised, and in practice for most primary servers today, to employ the authentication or access-control features of the NTP specification in order to protect against hostile intruders and possible destabilization of the time service. Using this or similar strategies, the remaining hosts in the same administrative domain can be synchronized to the three (or more) selected time servers. Assuming these servers are synchronized directly to stratum-1 sources and operate normally as stratum-2, the next level away from the primary source of synchronization, for instance various campus file servers, will operate at stratum 3 and dependent workstations at stratum 4. Engineered correctly, such a subnet will survive all but the most exotic failures or even hostile penetrations of the various, distributed timekeeping resources.</p>
+               <p>The above arrangement should provide very good, robust time service with a minimum of traffic to distant servers and with manageable loads on the local servers. While it is theoretically possible to extend the synchronization subnet to even higher strata, this is seldom justified and can make the maintenance of configuration files unmanageable. Serving time to a higher stratum peer is very inexpensive in terms of the load on the lower stratum server if the latter is located on the same concatenated LAN. When justified by the accuracy expectations, NTP can be operated in broadcast and multicast modes, so that clients need only listen for periodic broadcasts and do not need to send anything.</p>
+               <p>When planning your network you might, beyond this, keep in mind a few generic don'ts, in particular:</p>
+               <ul>
+                       <li>Don't synchronize a local time server to another peer at the same stratum, unless the latter is receiving time from lower stratum sources the former doesn't talk to directly. This minimizes the occurrence of common points of failure, but does not eliminate them in cases where the usual chain of associations to the primary sources of synchronization are disrupted due to failures.
+                       <li style="list-style: none"><br>
+                       <li>Don't configure peer associations with higher stratum servers. Let the higher strata configure lower stratum servers, but not the reverse. This greatly simplifies configuration file maintenance, since there is usually much greater configuration churn in the high stratum clients such as personal workstations.
+                       <li style="list-style: none"><br>
+                       <li>Don't synchronize more than one time server in a particular administrative domain to the same time server outside that domain. Such a practice invites common points of failure, as well as raises the possibility of massive abuse, should the configuration file be automatically distributed do a large number of clients.
+               </ul>
+               There are many useful exceptions to these rules. When in doubt, however, follow them.
+               <h4>Configuring Your Server or Client</h4>
+               <p>As mentioned previously, the configuration file is usually called /etc/ntp.conf. This is an ASCII file conforming to the usual comment and whitespace conventions. A working configuration file might look like (in this and other examples, do not copy this directly):</p>
+               <pre>
+     # peer configuration for host whimsy
+     # (expected to operate at stratum 2)
+
+     server rackety.udel.edu
+     server umd1.umd.edu
+     server lilben.tn.cornell.edu
+
+     driftfile /etc/ntp.drift
+</pre>
+               (Note the use of host names, although host addresses in dotted-quad notation can also be used. It is always preferable to use names rather than addresses, since over time the addresses can change, while the names seldom change.)
+               <p>This particular host is expected to operate as a client at stratum 2 by virtue of the <tt>server</tt> keyword and the fact that two of the three servers declared (the first two) have radio clocks and usually run at stratum 1. The third server in the list has no radio clock, but is known to maintain associations with a number of stratum 1 peers and usually operates at stratum 2. Of particular importance with the last host is that it maintains associations with peers besides the two stratum 1 peers mentioned. This can be verified using the <tt>ntpq</tt> program mentioned above. When configured using the <tt>server</tt> keyword, this host can receive synchronization from any of the listed servers, but can never provide synchronization to them.</p>
+               <p>Unless restricted using facilities described later, this host can provide synchronization to dependent clients, which do not have to be listed in the configuration file. Associations maintained for these clients are transitory and result in no persistent state in the host. These clients are normally not visible using the <tt>ntpq</tt> program included in the distribution; however, <tt>ntpd</tt> includes a monitoring feature (described later) which caches a minimal amount of client information useful for debugging administrative purposes.</p>
+               <p>A time server expected to both receive synchronization from another server, as well as to provide synchronization to it, is declared using the <tt>peer</tt> keyword instead of the <tt>server</tt> keyword. In all other aspects the server operates the same in either mode and can provide synchronization to dependent clients or other peers. If a local source of UTC time is available, it is considered good engineering practice to declare time servers outside the administrative domain as <tt>peer</tt> and those inside as <tt>server</tt> in order to provide redundancy in the global Internet, while minimizing the possibility of instability within the domain itself. A time server in one domain can in principle heal another domain temporarily isolated from all other sources of synchronization. However, it is probably unwise for a casual workstation to bridge fragments of the local domain which have become temporarily isolated.</p>
+               <p>Note the inclusion of a <tt>driftfile</tt> declaration. One of the things the NTP daemon does when it is first started is to compute the error in the intrinsic frequency of the clock on the computer it is running on. It usually takes about a day or so after the daemon is started to compute a good estimate of this (and it needs a good estimate to synchronize closely to its server). Once the initial value is computed, it will change only by relatively small amounts during the course of continued operation. The <tt>driftfile</tt> declaration indicates to the daemon the name of a file where it may store the current value of the frequency error so that, if the daemon is stopped and restarted, it can reinitialize itself to the previous estimate and avoid the day's worth of time it will take to recompute the frequency estimate. Since this is a desirable feature, a <tt>driftfile</tt> declaration should always be included in the configuration file.</p>
+               <p>An implication in the above is that, should <tt>ntpd</tt> be stopped for some reason, the local platform time will diverge from UTC by an amount that depends on the intrinsic error of the clock oscillator and the time since last synchronized. In view of the length of time necessary to refine the frequency estimate, every effort should be made to operate the daemon on a continuous basis and minimize the intervals when for some reason it is not running.</p>
+               <h4>Configuring NTP with NetInfo</h4>
+               If NetInfo support is compiled into NTP, you can opt to configure NTP in your NetInfo domain. NTP will look in the NetInfo directory <tt>/locations/ntp</tt> for property/value pairs which are equivalent to the lines in the configuration file described above. Each configuration keyword may have a corresponding property in NetInfo. Each value for a given property is treated as arguments to that property, similar to a line in the configuration file.
+               <p>For example, the configuration shown in the configuration file above can be duplicated in NetInfo by adding a property &quot;<tt>server</tt>&quot; with values &quot;<tt>rackety.udel.edu</tt>&quot;, &quot;<tt>umd1.umd.edu</tt>&quot;, and &quot;<tt>lilben.tn.cornell.edu</tt>&quot;; and a property &quot;<tt>driftfile</tt>&quot; with the single value &quot;<tt>/etc/ntp.drift</tt>&quot;.</p>
+               <p>Values may contain multiple tokens similar to the arguments available in the configuration file. For example, to use <tt>mimsy.mil</tt> as an NTP version 1 time server, you would add a value &quot;<tt>mimsy.mil version 1</tt>&quot; to the &quot;<tt>server</tt>&quot; property.</p>
+               <h4>Ntp4 Versus Previous Versions</h4>
+               There are several items of note when dealing with a mixture of <tt>ntp4</tt> and previous distributions of NTP Version 2 (<tt>ntpd</tt>) and NTP Version 1 (<tt>ntp3.4</tt>). The <tt>ntp4</tt> implementation conforms to the NTP Version 3 specification RFC-1305 and, in addition, contains additional features documented in the <a href="release.html">Release Notes</a> page. As such, by default when no additional information is available concerning the preferences of the peer, <tt>ntpd</tt> claims to be version 4 in the packets that it sends from configured associations. The <tt>version</tt> subcommand of the <tt>server</tt>, <tt>peer</tt>, <tt>broadcast</tt> and <tt>manycastclient</tt> command can be used to change the default. In unconfigured (ephemeral) associaitons, the daemon always replies in the same version as the request.
+               <p>An NTP implementation conforming to a previous version specification ordinarily discards packets from a later version. However, in most respects documented in RFC-1305, The version 2 implementation is compatible with the version 3 algorithms and protocol. The version 1 implementation contains most of the version 2 algorithms, but without important features for clock selection and robustness. Nevertheless, in most respects the NTP versions are backwards compatible. The sticky part here is that, when a previous version implementation receives a packet claiming to be from a version 4 server, it discards it without further processing. Hence there is a danger that in some situations synchronization with previous versions will fail.</p>
+               <p>The trouble occurs when an previous version is to be included in an <tt>ntpd</tt> configuration file. With no further indication, <tt>ntpd</tt> will send packets claiming to be version 4 when it polls. To get around this, <tt>ntpd</tt> allows a qualifier to be added to configuration entries to indicate which version to use when polling. Hence the entries</p>
+               <pre>
+     # specify NTP version 1
+
+     server mimsy.mil version
+1     # server running ntpd version 1
+     server apple.com version
+2     # server running ntpd version 2
+</pre>
+               will cause version 1 packets to be sent to the host mimsy.mil and version 2 packets to be sent to apple.com. If you are testing <tt>ntpd</tt> against previous version servers you will need to be careful about this. Note that, as indicated in the RFC-1305 specification, there is no longer support for the original NTP specification, once called NTP Version 0.
+               <h4>Traffic Monitoring</h4>
+               <tt>ntpd</tt> handles peers whose stratum is higher than the stratum of the local server and polls using client mode by a fast path which minimizes the work done in responding to their polls, and normally retains no memory of these pollers. Sometimes, however, it is interesting to be able to determine who is polling the server, and how often, as well as who has been sending other types of queries to the server.
+               <p>To allow this, <tt>ntpd</tt> implements a traffic monitoring facility which records the source address and a minimal amount of other information from each packet which is received by the server. This feature is normally enabled, but can be disabled if desired using the configuration file entry:</p>
+               <pre>
+     # disable monitoring feature
+     disable monitor
+</pre>
+               The recorded information can be displayed using the <tt>ntpdc</tt> query program, described briefly below.
+               <h4>Address-and-Mask Restrictions</h4>
+               The address-and-mask configuration facility supported by <tt>ntpd</tt> is quite flexible and general, but is not an integral part of the NTP Version 3 specification. The major drawback is that, while the internal implementation is very nice, the user interface is not. For this reason it is probably worth doing an example here. Briefly, the facility works as follows. There is an internal list, each entry of which holds an address, a mask and a set of flags. On receipt of a packet, the source address of the packet is compared to each entry in the list, with a match being posted when the following is true:
+               <pre>
+     (source_addr &amp; mask) == (address &amp;
+mask)
+</pre>
+               A particular source address may match several list entries. In this case the entry with the most one bits in the mask is chosen. The flags associated with this entry are used to control the access.
+               <p>In the current implementation the flags always add restrictions. In effect, an entry with no flags set leaves matching hosts unrestricted. An entry can be added to the internal list using a <tt>restrict</tt> declaration. The flags associated with the entry are specified textually. For example, the <tt>notrust</tt> flag indicates that hosts matching this entry, while treated normally in other respects, shouldn't be trusted to provide synchronization even if otherwise so enabled. The <tt>nomodify</tt> flag indicates that hosts matching this entry should not be allowed to do run-time configuration. There are many more flags, see the <a href="ntpd.html"><tt>ntpd</tt></a> page.</p>
+               <p>Now the example. Suppose you are running the server on a host whose address is 128.100.100.7. You would like to ensure that run time reconfiguration requests can only be made from the local host and that the server only ever synchronizes to one of a pair of off-campus servers or, failing that, a time source on net 128.100. The following entries in the configuration file would implement this policy:</p>
+               <pre>
+     # by default, don't trust and don't allow
+modifications
+
+     restrict default notrust nomodify
+
+     # these guys are trusted for time, but no
+modifications allowed
+
+     restrict 128.100.0.0 mask 255.255.0.0 nomodify
+     restrict 128.8.10.1 nomodify
+     restrict 192.35.82.50 nomodify
+
+     # the local addresses are unrestricted
+
+     restrict 128.100.100.7
+     restrict 127.0.0.1
+</pre>
+               The first entry is the default entry, which all hosts match and hence which provides the default set of flags. The next three entries indicate that matching hosts will only have the <tt>nomodify</tt> flag set and hence will be trusted for time. If the mask isn't specified in the <tt>restrict</tt> keyword, it defaults to 255.255.255.255. Note that the address 128.100.100.7 matches three entries in the table, the default entry (mask 0.0.0.0), the entry for net 128.100 (mask 255.255.0.0) and the entry for the host itself (mask 255.255.255.255). As expected, the flags for the host are derived from the last entry since the mask has the most bits set.
+               <p>The only other thing worth mentioning is that the <tt>restrict</tt> declarations apply to packets from all hosts, including those that are configured elsewhere in the configuration file and even including your clock pseudopeer(s), if any. Hence, if you specify a default set of restrictions which you don't wish to be applied to your configured peers, you must remove those restrictions for the configured peers with additional <tt>restrict</tt> declarations mentioning each peer separately.</p>
+               <h4>Authentication</h4>
+               <tt>ntpd</tt> supports the optional authentication procedure specified in the NTP Version 2 and 3 specifications. Briefly, when an association runs in authenticated mode, each packet transmitted has appended to it a 32-bit key ID and a 64/128-bit cryptographic checksum of the packet contents computed using either the Data Encryption Standard (DES) or Message Digest (MD5) algorithms. Note that, while either of these algorithms provide sufficient protection from message- modification attacks, distribution of the former algorithm implementation is restricted to the U.S. and Canada, while the latter presently is free from such restrictions. For this reason, the DES algorithm is not included in the current distribution. Directions for obtaining it in other countries is in the <a href="build/build.html">Building and Installing the Distribution</a> page. With either algorithm the receiving peer recomputes the checksum and compares it with the one included in the packet. For this to work, the peers must share at least one encryption key and, furthermore, must associate the shared key with the same key ID.
+               <p>This facility requires some minor modifications to the basic packet processing procedures, as required by the specification. These modifications are enabled by the <tt>enable auth</tt> configuration declaration, which is currently the default. In authenticated mode, peers which send unauthenticated packets, peers which send authenticated packets which the local server is unable to decrypt and peers which send authenticated packets encrypted using a key we don't trust are all marked untrustworthy and unsuitable for synchronization. Note that, while the server may know many keys (identified by many key IDs), it is possible to declare only a subset of these as trusted. This allows the server to share keys with a client which requires authenticated time and which trusts the server, but which is not trusted by the server. Also, some additional configuration language is required to specify the key ID to be used to authenticate each configured peer association. Hence, for a server running in authenticated mode, the configuration file might look similar to the following:</p>
+               <pre>
+     # peer configuration for 128.100.100.7
+     # (expected to operate at stratum 2)
+     # fully authenticated this time
+
+     peer 128.100.49.105 key 22 #
+suzuki.ccie.utoronto.ca
+     peer 128.8.10.1 key 4    #
+umd1.umd.edu
+     peer 192.35.82.50 key 6  #
+lilben.tn.cornell.edu
+
+     keys /usr/local/etc/ntp.keys  # path for
+key file
+     trustedkey 1 2 14 15     #
+define trusted keys
+     requestkey
+15            #
+key (7) for accessing server variables
+     controlkey
+15            #
+key (6) for accessing server variables
+
+     authdelay
+0.000094       # authentication delay
+(Sun4c/50 IPX)
+</pre>
+               There are a couple of previously unmentioned things in here. The <tt>keys</tt> line specifies the path to the keys file (see below and the <tt>ntpd</tt> document page for details of the file format). The <tt>trustedkey</tt> declaration identifies those keys that are known to be uncompromised; the remainder presumably represent the expired or possibly compromised keys. Both sets of keys must be declared by key identifier in the <tt>ntp.keys</tt> file described below. This provides a way to retire old keys while minimizing the frequency of delicate key-distribution procedures. The <tt>requestkey</tt> line establishes the key to be used for mode-6 control messages as specified in RFC-1305 and used by the <tt>ntpq</tt> utility program, while the <tt>controlkey</tt> line establishes the key to be used for mode-7 private control messages used by the <tt>ntpdc</tt> utility program. These keys are used to prevent unauthorized modification of daemon variables.
+               <p>Ordinarily, the authentication delay; that is, the processing time taken between the freezing of a transmit timestamp and the actual transmission of the packet when authentication is enabled (i.e. more or less the time it takes for the DES or MD5 routine to encrypt a single block) is computed automatically by the daemon. If necessary, the delay can be overridden by the <tt>authdelay</tt> line, which is used as a correction for the transmit timestamp.</p>
+               Additional utility programs included in the <tt>./authstuff</tt> directory can be used to generate random keys, certify implementation correctness and display sample keys. As a general rule, keys should be chosen randomly, except possibly the request and control keys, which must be entered by the user as a password.
+               <p>The <tt>ntp.keys</tt> file contains the list of keys and associated key IDs the server knows about (for obvious reasons this file is better left unreadable by anyone except root). The contents of this file might look like:</p>
+               <pre>
+     # ntp keys file (ntp.keys)
+     1    N   
+29233E0461ECD6AE    # DES key in NTP format
+     2    M   
+RIrop8KPPvQvYotM    # md5 key as an ASCII random string
+     14   M   
+sundial           
+;  # md5 key as an ASCII string
+     15   A   
+sundial           
+;  # DES key as an ASCII string
+
+     # the following 3 keys are identical
+
+     10   A    SeCReT
+     10   N   
+d3e54352e5548080
+     10   S   
+a7cb86a4cba80101
+</pre>
+               In the keys file the first token on each line indicates the key ID, the second token the format of the key and the third the key itself. There are four key formats. An <tt>A</tt> indicates a DES key written as a 1- to-8 character string in 7-bit ASCII representation, with each character standing for a key octet (like a Unix password). An <tt>S</tt> indicates a DES key written as a hex number in the DES standard format, with the low order bit (LSB) of each octet being the (odd) parity bit. An <tt>N</tt> indicates a DES key again written as a hex number, but in NTP standard format with the high order bit of each octet being the (odd) parity bit (confusing enough?). An <tt>M</tt> indicates an MD5 key written as a 1-to-31 character ASCII string in the <tt>A</tt> format. Note that, because of the simple tokenizing routine, the characters <tt>' ', '#', '\t', '\n'</tt> and <tt>'\0'</tt> can't be used in either a DES or MD5 ASCII key. Everything else is fair game, though. Key 0 (zero) is used for special purposes and should not appear in this file.
+               <p>The big trouble with the authentication facility is the keys file. It is a maintenance headache and a security problem. This should be fixed some day. Presumably, this whole bag of worms goes away if/when a generic security regime for the Internet is established. An alternative with NTP Version 4 is the autokey feature, which uses random session keys and public-key cryptography and avoids the key file entirely. While this feature is not completely finished yet, details can be found in the <a href="release.html">Release Notes</a> page.</p>
+               <h4>Query Programs</h4>
+               Three utility query programs are included with the distribution, <tt>ntpq</tt>, <tt>ntptrace</tt> and <tt>ntpdc</tt>. <tt>ntpq</tt> is a handy program which sends queries and receives responses using NTP standard mode-6 control messages. Since it uses the standard control protocol specified in RFC- 1305, it may be used with NTP Version 2 and Version 3 implementations for both Unix and Fuzzball, but not Version 1 implementations. It is most useful to query remote NTP implementations to assess timekeeping accuracy and expose bugs in configuration or operation.
+               <p><tt>ntptrace</tt> can be used to display the current synchronization path from a selected host through possibly intervening servers to the primary source of synchronization, usually a radio clock. It works with both version 2 and version 3 servers, but not version 1.</p>
+               <p><tt>ntpdc</tt> is a horrid program which uses NTP private mode-7 control messages to query local or remote servers. The format and contents of these messages are specific to this version of <tt>ntpd</tt> and some older versions. The program does allow inspection of a wide variety of internal counters and other state data, and hence does make a pretty good debugging tool, even if it is frustrating to use. The other thing of note about <tt>ntpdc</tt> is that it provides a user interface to the run time reconfiguration facility. See the respective document pages for details on the use of these programs.</p>
+               <h4>Run-Time Reconfiguration</h4>
+               <tt>ntpd</tt> was written specifically to allow its configuration to be fully modifiable at run time. Indeed, the only way to configure the server is at run time. The configuration file is read only after the rest of the server has been initialized into a running default-configured state. This facility was included not so much for the benefit of Unix, where it is handy but not strictly essential, but rather for dedicated platforms where the feature is more important for maintenance. Nevertheless, run time configuration works very nicely for Unix servers as well.
+               <p>Nearly all of the things it is possible to configure in the configuration file may be altered via NTP mode-7 messages using the <tt>ntpdc</tt> program. Mode-6 messages may also provide some limited configuration functionality (though the only thing you can currently do with mode-6 messages is set the leap-second warning bits) and the <tt>ntpq</tt> program provides generic support for the latter. The leap bits that can be set in the <tt>leap_warning</tt> variable (up to one month ahead) and in the <tt>leap_indication</tt> variable have a slightly different encoding than the usual interpretation:</p>
+               <pre>
+       
+Value           Action
+
+        
+00            
+p; The daemon passes the leap bits of its
+            
+           
+synchronisation source (usual mode of operation)
+
+        01/10   A leap
+second is added/deleted
+
+        
+11            
+p; Leap information from the synchronization source
+            
+            is
+ignored (thus LEAP_NOWARNING is passed on)
+</pre>
+               Mode-6 and mode-7 messages which would modify the configuration of the server are required to be authenticated using standard NTP authentication. To enable the facilities one must, in addition to specifying the location of a keys file, indicate in the configuration file the key IDs to be used for authenticating reconfiguration commands. Hence the following fragment might be added to a configuration file to enable the mode-6 (ntpq) and mode-7 (ntpdc) facilities in the daemon:
+               <pre>
+     # specify mode-6 and mode-7 trusted keys
+
+     requestkey 65535    # for mode-7
+requests
+     controlkey 65534    # for mode-6
+requests
+</pre>
+               If the <tt>requestkey</tt> and/or the <tt>controlkey</tt> configuration declarations are omitted from the configuration file, the corresponding run-time reconfiguration facility is disabled.
+               <p>The query programs require the user to specify a key ID and a key to use for authenticating requests to be sent. The key ID provided should be the same as the one mentioned in the configuration file, while the key should match that corresponding to the key ID in the keys file. As the query programs prompt for the key as a password, it is useful to make the request and control authentication keys typeable (in ASCII format) from the keyboard.</p>
+               <h4>Name Resolution</h4>
+               <tt>ntpd</tt> includes the capability to specify host names requiring resolution in <tt>peer</tt> and <tt>server</tt> declarations in the configuration file. However, in some outposts of the Internet, name resolution is unreliable and the interface to the Unix resolver routines is synchronous. The hangups and delays resulting from name-resolver clanking can be unacceptable once the NTP server is running (and remember it is up and running before the configuration file is read). However, it is advantageous to resolve time server names, since their addresses are occasionally changed.
+               <p>In order to prevent configuration delays due to the name resolver, the daemon runs the name resolution process in parallel with the main daemon code. When the daemon comes across a <tt>peer</tt> or <tt>server</tt> entry with a non-numeric host address, it records the relevant information in a temporary file and continues on. When the end of the configuration file has been reached and one or more entries requiring name resolution have been found, the server runs the name resolver from the temporary file. The server then continues on normally but with the offending peers/servers omitted from its configuration.</p>
+               <p>As each name is resolved, it configures the associated entry into the server using the same mode-7 run time reconfiguration facility that <tt>ntpdc</tt> uses. If temporary resolver failures occur, the resolver will periodically retry the requests until a definite response is received. The program will continue to run until all entries have been resolved.</p>
+               <h4>Dealing with Frequency Tolerance Violations (<tt>tickadj</tt> and Friends)</h4>
+               The NTP Version 3 specification RFC-1305 calls for a maximum oscillator frequency tolerance of +-100 parts-per-million (PPM), which is representative of those components suitable for use in relatively inexpensive workstation platforms. For those platforms meeting this tolerance, NTP will automatically compensate for the frequency errors of the individual oscillator and no further adjustments are required, either to the configuration file or to various kernel variables. For the NTP Version 4 release, this tolerance has been increased to +-500 PPM.
+               <p>However, in the case of certain notorious platforms, in particular Sun 4.1.1 systems, the performance can be improved by adjusting the values of certain kernel variables; in particular, <tt>tick</tt> and <tt>tickadj</tt>. The variable <tt>tick</tt> is the increment in microseconds added to the system time on each interval- timer interrupt, while the variable <tt>tickadj</tt> is used by the time adjustment code as a slew rate, in microseconds per tick. When the time is being adjusted via a call to the system routine <tt>adjtime()</tt>, the kernel increases or reduces tick by <tt>tickadj</tt> microseconds per tick until the specified adjustment has been completed. Unfortunately, in most Unix implementations the tick increment must be either zero or plus/minus exactly <tt>tickadj</tt> microseconds, meaning that adjustments are truncated to be an integral multiple of <tt>tickadj</tt> (this latter behaviour is a misfeature, and is the only reason the <tt>tickadj</tt> code needs to concern itself with the internal implementation of <tt>tickadj</tt> at all). In addition, the stock Unix implementation considers it an error to request another adjustment before a prior one has completed.</p>
+               <p>Thus, to make very sure it avoids problems related to the roundoff, the <tt>tickadj</tt> program can be used to adjust the values of <tt>tick</tt> and <tt>tickadj</tt>. This ensures that all adjustments given to <tt>adjtime()</tt> are an even multiple of <tt>tickadj</tt> microseconds and computes the largest adjustment that can be completed in the adjustment interval (using both the value of <tt>tick</tt> and the value of <tt>tickadj</tt>) so it can avoid exceeding this limit. It is important to note that not all systems will allow inspection or modification of kernel variables other than at system build time. It is also important to know that, with the current NTP tolerances, it is rarely necessary to make these changes, but in many cases they will substantially improve the general accuracy of the time service.</p>
+               <p>Unfortunately, the value of <tt>tickadj</tt> set by default is almost always too large for <tt>ntpd</tt>. NTP operates by continuously making small adjustments to the clock, usually at one-second intervals. If <tt>tickadj</tt> is set too large, the adjustments will disappear in the roundoff; while, if <tt>tickadj</tt> is too small, NTP will have difficulty if it needs to make an occasional large adjustment. While the daemon itself will read the kernel's values of these variables, it will not change the values, even if they are unsuitable. You must do this yourself before the daemon is started using the <tt>tickadj</tt> program included in the <tt>./util</tt> directory of the distribution. Note that the latter program will also compute an optimal value of <tt>tickadj</tt> for NTP use based on the kernel's value of <tt>tick</tt>.</p>
+               <p>The <tt>tickadj</tt> program can reset several other kernel variables if asked. It can change the value of <tt>tick</tt> if asked. This is handy to compensate for kernel bugs which cause the clock to run with a very large frequency error, as with SunOS 4.1.1 systems. It can also be used to set the value of the kernel <tt>dosynctodr</tt> variable to zero. This variable controls whether to synchronize the system clock to the time-of-day clock, something you really don't want to be happen when <tt>ntpd</tt> is trying to keep it under control. In some systems, such as recent Sun Solaris kernels, the <tt>dosynctodr</tt> variable is the only one that can be changed by the <tt>tickadj</tt> program. In this and other modern kernels, it is not necessary to change the other variables in any case.</p>
+               <p>We have a report that says starting with Solaris 2.6 we should leave <i>dosynctodr</i> alone.</p>
+               <p>In order to maintain reasonable correctness bounds, as well as reasonably good accuracy with acceptable polling intervals, <tt>ntpd</tt> will complain if the frequency error is greater than 500 PPM. For machines with a value of <tt>tick</tt> in the 10-ms range, a change of one in the value of <tt>tick</tt> will change the frequency by about 100 PPM. In order to determine the value of <tt>tick</tt> for a particular CPU, disconnect the machine from all sources of time (<tt>dosynctodr</tt> = 0) and record its actual time compared to an outside source (eyeball-and-wristwatch will do) over a day or more. Multiply the time change over the day by 0.116 and add or subtract the result to tick, depending on whether the CPU is fast or slow. An example call to <tt>tickadj</tt> useful on SunOS 4.1.1 is:</p>
+               <pre>
+     <tt>tickadj</tt> -t 9999 -a 5 -s
+</pre>
+               which sets tick 100 PPM fast, <tt>tickadj</tt> to 5 microseconds and turns off the clock/calendar chip fiddle. This line can be added to the <tt>rc.local</tt> configuration file to automatically set the kernel variables at boot time.
+               <p>All this stuff about diddling kernel variables so the NTP daemon will work is really silly. If vendors would ship machines with clocks that kept reasonable time and would make their <tt>adjtime()</tt> system call apply the slew it is given exactly, independent of the value of <tt>tickadj</tt>, all this could go away. This is in fact the case on many current Unix systems.</p>
+               <h4>Tuning Your Subnet</h4>
+               There are several parameters available for tuning the NTP subnet for maximum accuracy and minimum jitter. One of these is the <tt>prefer</tt> configuration declaration described in <a href="prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a> documentation page. When more than one eligible server exists, the NTP clock-selection and combining algorithms act to winnow out all except the &quot;best&quot; set of servers using several criteria based on differences between the readings of different servers and between successive readings of the same server. The result is usually a set of surviving servers that are apparently statistically equivalent in accuracy, jitter and stability. The population of survivors remaining in this set depends on the individual server characteristics measured during the selection process and may vary from time to time as the result of normal statistical variations. In LANs with high speed RISC-based time servers, the population can become somewhat unstable, with individual servers popping in and out of the surviving population, generally resulting in a regime called <i>clockhopping</i>.
+               <p>When only the smallest residual jitter can be tolerated, it may be convenient to elect one of the servers at each stratum level as the preferred one using the keyword <tt>prefer</tt> on the configuration declaration for the selected server:</p>
+               <pre>
+     # preferred server declaration
+
+     peer rackety.udel.edu prefer   
+# preferred server
+</pre>
+               The preferred server will always be included in the surviving population, regardless of its characteristics and as long as it survives preliminary sanity checks and validation procedures.
+               <p>The most useful application of the <tt>prefer</tt> keyword is in high speed LANs equipped with precision radio clocks, such as a GPS receiver. In order to insure robustness, the hosts need to include outside peers as well as the GPS-equipped server; however, as long as that server is running, the synchronization preference should be that server. The keyword should normally be used in all cases in order to prefer an attached radio clock. It is probably inadvisable to use this keyword for peers outside the LAN, since it interferes with the carefully crafted judgement of the selection and combining algorithms.</p>
+               <h4>Provisions for Leap Seconds and Accuracy Metrics</h4>
+               <tt>ntpd</tt> understands leap seconds and will attempt to take appropriate action when one occurs. In principle, every host running ntpd will insert a leap second in the local timescale in precise synchronization with UTC. This requires that the leap-warning bits be activated some time prior to the occurrence of a leap second at the primary (stratum 1) servers. Subsequently, these bits are propagated throughout the subnet depending on these servers by the NTP protocol itself and automatically implemented by <tt>ntpd</tt> and the time- conversion routines of each host. The implementation is independent of the idiosyncrasies of the particular radio clock, which vary widely among the various devices, as long as the idiosyncratic behavior does not last for more than about 20 minutes following the leap. Provisions are included to modify the behavior in cases where this cannot be guaranteed. While provisions for leap seconds have been carefully crafted so that correct timekeeping immediately before, during and after the occurrence of a leap second is scrupulously correct, stock Unix systems are mostly inept in responding to the available information. This caveat goes also for the maximum-error and statistical-error bounds carefully calculated for all clients and servers, which could be very useful for application programs needing to calibrate the delays and offsets to achieve a near- simultaneous commit procedure, for example. While this information is maintained in the <tt>ntpd</tt> data structures, there is at present no way for application programs to access it. This may be a topic for further development.
+               <h4>Clock Support Overview</h4>
+               <tt>ntpd</tt> was designed to support radio (and other external) clocks and does some parts of this function with utmost care. Clocks are treated by the protocol as ordinary NTP peers, even to the point of referring to them with an (invalid) IP host address. Clock addresses are of the form 127.127.<i>t.u</i>, where <i>t</i> specifies the particular type of clock (i.e., refers to a particular clock driver) and <i>u</i> is a unit number whose interpretation is clock-driver dependent. This is analogous to the use of major and minor device numbers by Unix and permits multiple instantiations of clocks of the same type on the same server, should such magnificent redundancy be required.
+               <p>Because clocks look much like peers, both configuration file syntax and run time reconfiguration commands can be used to control clocks in the same way as ordinary peers. Clocks are configured via <tt>server</tt> declarations in the configuration file, can be started and stopped using ntpdc and are subject to address-and-mask restrictions much like a normal peer, should this stretch of imagination ever be useful. As a concession to the need to sometimes transmit additional information to clock drivers, an additional configuration file is available: the <tt>fudge</tt> statement. This enables one to specify the values of two time quantities, two integral values and two flags, the use of which is dependent on the particular clock driver. For example, to configure a PST radio clock which can be accessed through the serial device <tt>/dev/pst1</tt>, with propagation delays to WWV and WWVH of 7.5 and 26.5 milliseconds, respectively, on a machine with an imprecise system clock and with the driver set to disbelieve the radio clock once it has gone 30 minutes without an update, one might use the following configuration file entries:</p>
+               <pre>
+     # radio clock fudge fiddles
+     server 127.127.3.1
+     fudge 127.127.3.1 time1 0.0075 time2 0.0265
+     fudge 127.127.3.1 value2 30 flag1 1
+</pre>
+               Additional information on the interpretation of these data with respect to various radio clock drivers is given in the <a href="refclock.html">Reference Clock Drivers</a> document page and in the individual driver documents accessible via that page.
+               <h4>Towards the Ultimate Tick</h4>
+               This section considers issues in providing precision time synchronization in NTP subnets which need the highest quality time available in the present technology. These issues are important in subnets supporting real-time services such as distributed multimedia conferencing and wide-area experiment control and monitoring.
+               <p>In the Internet of today synchronization paths often span continents and oceans with moderate to high variations in delay due to traffic spasms. NTP is specifically designed to minimize timekeeping jitter due to delay variations using intricately crafted filtering and selection algorithms; however, in cases where these variations are as much as a second or more, the residual jitter following these algorithms may still be excessive. Sometimes, as in the case of some isolated NTP subnets where a local source of precision time is available, such as a PPS signal produced by a calibrated cesium clock, it is possible to remove the jitter and retime the local clock oscillator of the NTP server. This has turned out to be a useful feature to improve the synchronization quality of time distributed in remote places where radio clocks are not available. In these cases special features of the distribution are used together with the PPS signal to provide a jitter-free timing signal, while NTP itself is used to provide the coarse timing and resolve the seconds numbering.</p>
+               <p>Most available radio clocks can provide time to an accuracy in the order of milliseconds, depending on propagation conditions, local noise levels and so forth. However, as a practical matter, all clocks can occasionally display errors significantly exceeding nominal specifications. Usually, the algorithms used by NTP for ordinary network peers, as well as radio clock peers will detect and discard these errors as discrepancies between the disciplined local clock oscillator and the decoded time message produced by the radio clock. Some radio clocks can produce a special PPS signal which can be interfaced to the server platform in a number of ways and used to substantially improve the (disciplined) clock oscillator jitter and wander characteristics by at least an order of magnitude. Using these features it is possible to achieve accuracies in the order of a few tens of microseconds with a fast RISC- based platform.</p>
+               <p>There are three ways to implement PPS support, depending on the radio clock model, platform model and serial line interface. These are described in detail in the application notes mentioned in the <a href="index.html">The Network Time Protocol (NTP) Distribution</a> document page. Each of these requires circuitry to convert the TTL signal produced by most clocks to the EIA levels used by most serial interfaces. The <a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page describes a device designed to do this. Besides being useful for this purpose, this device includes an inexpensive modem designed for use with the Canadian CHU time/frequency radio station.</p>
+               <p>In order to select the appropriate implementation, it is important to understand the underlying PPS mechanism used by ntpd. The PPS support depends on a continuous source of PPS pulses used to calculate an offset within +-500 milliseconds relative to the local clock. The serial timecode produced by the radio or the time determined by NTP in absence of the radio is used to adjust the local clock within +-128 milliseconds of the actual time. As long as the local clock is within this interval the PPS support is used to discipline the local clock and the timecode used only to verify that the local clock is in fact within the interval. Outside this interval the PPS support is disabled and the timecode used directly to control the local clock.</p>
+               <h4>Parting Shots</h4>
+               There are several undocumented programs which can be useful in unusual cases. They can be found in the <tt>./clockstuff</tt> and <tt>./authstuff</tt> directories of the distribution. One of these is the <tt>propdelay</tt> program, which can compute high frequency radio propagation delays between any two points whose latitude and longitude are known. The program understands something about the phenomena which allow high frequency radio propagation to occur, and will generally provide a better estimate than a calculation based on the great circle distance. Other programs of interest include <tt>clktest</tt>, which allows one to exercise the generic clock line discipline, and <tt>chutest</tt>, which runs the basic reduction algorithms used by the daemon on data received from a serial port.&nbsp;
+               <hr>
+               <center>
+                       <img src="pic/pogo1a.gif" alt="gif"></center>
+               <br>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/ntp_conf.html b/html/ntp_conf.html
new file mode 100644 (file)
index 0000000..520ce45
--- /dev/null
@@ -0,0 +1,173 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Configuration File Definition (Advanced)</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Configuration File Definition (Advanced)</h3>
+               <img src="pic/bustardfly.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+               <p>A typical NTP monitoring packet</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">19:46</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="223">Friday, June 16, 2006</csobj></p>
+               <br clear="left">
+               <hr>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#synopsis">Synopsis</a><br>
+                       <li class="inline"><a href="#files">Files</a>
+                       <li class="inline"><a href="#high-level">High-Level Description</a>
+                       <li class="inline"><a href="#detailed">Detailed Description</a>
+                       <li class="inline"><a href="#guidelines">Guidelines for Adding Configuration Commands </a>
+               </ul>
+               <h4 id="synopsis">Synopsis</h4>
+               <p>The NTP configuration process is driven by a phrase-structure grammar which is used to specify the format of the configuration commands and the actions needed to build an abstract syntax tree (AST). The grammar is fed to a parser generator (Bison) which produces a parser for the configuration file.</p>
+               <p>The generated parser is used to parse an NTP configuration file and check it for syntax and semantic errors. The result of the parse is an AST, which contains a representation of the various commands and options. This AST is then traversed to set up the NTP daemon to the correct configuration.</p>
+               <p>This document is intended for developers who wish to modify the configuration code and/or add configuration commands and options. It contains a description of the files used in the configuration process as well as guidelines on how to construct them.</p>
+               <h4 id="files">Files</h4>
+               <p>A brief description of the files used by the configuration code is given below:</p>
+               <table border="1">
+                       <tbody>
+                               <tr>
+                                       <th width="179">File</th>
+                                       <th width="537">Description</th>
+                               </tr>
+                               <tr>
+                                       <td valign="top"><b>ntp_config.y</b></td>
+                                       <td>This file is a Bison source file that contains the phrase-structure grammar and the actions that need to be performed to generate an AST.</td>
+                               </tr>
+                               <tr>
+                                       <td valign="top"><b>ntp_config.c</b></td>
+                                       <td>This file contains the major chunk of the configuration code. It contains all the functions that are called for building the AST as well as the functions that are needed for traversing the AST.</td>
+                               </tr>
+                               <tr>
+                                       <td valign="top"><b>ntp_config.h</b></td>
+                                       <td>This file is the header file for <b>ntp_config.c</b>. It mainly contains the structure definitions needed to build the AST. </td>
+                               </tr>
+                               <tr>
+                                       <td valign="top"><b>ntp_scanner.c</b></td>
+                                       <td>This file contains the code for a simple lexical analyzer. This file is directly included into the <b>ntp_config.c</b> file since this code is only used by the configuration code. The most important function in this file is <tt>yylex</tt>, which is called by the generated parser to get the next token on the input line.</td>
+                               </tr>
+                               <tr>
+                                       <td valign="top"><b>ntp_data_structures.c</b></td>
+                                       <td>This file contains a generic implementation of a priority queue and a simple queue. This code can be used to create a queue for any structure.</td>
+                               </tr>
+                               <tr>
+                                       <td valign="top"><b>ntp_data_structures.h</b></td>
+                                       <td>This header file contains the structure declarations and function prototypes needed to use the data structures defined in <b>ntp_data_structures.c</b>. This file forms the public interface of the data structures.</td>
+                               </tr>
+                               <tr>
+                                       <td valign="top"><b>ntp_config.tab.c</b></td>
+                                       <td>This file is generated by Bison from the <b>ntp_config.y</b> file. This file is also included directly into the configuration code.</td>
+                               </tr>
+                       </tbody>
+               </table>
+               <h4 id="high-level">High-Level Description</h4>
+               <p>A high-level description of the configuration process showing where all the files fit in is given below:</p>
+               <p><img src="pic/description.jpg" alt="JPEG" border="0"></p>
+               <p>The scanner reads in an NTP configuration file and converts it into tokens. The Bison generated parser reads these tokens and converts them into an AST. The AST traverser consists of a set of functions that configure parts of NTP on the basis of what is on the tree. A more detailed description of these parts and the files used is given below:</p>
+               <h4 id="detailed">Detailed Description</h4>
+               <dl>
+                       <dt><b>ntp_scanner.c</b>
+                       <dd>This file contains the scanner. The scanner is a small program that converts an input NTP configuration file into a set of <b>tokens</b> that correspond to <b>lexemes</b> in the input. Lexemes are strings in the input, delimited by whitespace and/or special characters. Tokens are basically unique integers that represent these lexemes. A different token is generated for each reserved word and special character in the input. There are two main functions in the public interface of this file:
+                       <dt><tt>int yylex</tt>()
+                       <dd>This function is called <tt>yylex</tt> for historical reasons; <tt>lex</tt> is a program that takes a set of regular expressions and generates a scanner that returns tokens corresponding to those regular expressions. The name of the generated function is called <tt>yylex</tt>. We aren't using<b> </b><tt>lex</tt><b> </b>because it requires linking against an external library and we didn't want to increase the compile-time requirements of NTP.
+                       <dd>History lessons aside, this function basically checks to see if the next input character is a special character as defined in the array <tt>char special_char[]</tt>. (The function <tt>int is_special(char ch)</tt>, can be used for this.) If yes, the special character is returned as the token. If not, a set of characters is read until the next whitespace or special character is encountered. This set of characters forms the lexeme; <tt>yylex</tt> then checks whether this lexeme is an integer, a double, an IP address or a reserved word. If yes, the corresponding token is returned. If not, a token for a string is returned as the default token.
+                       <dt><tt>struct state *create_keyword_scanner(struct key_tok *<i>keyword_list</i>)</tt>
+                       <dd>This function takes a list of (<i>keyword, token</i>) pairs and converts them into a trie that can recognize the keywords (reserved words). Every time the scanner reads a lexeme, it compares it against the list of reserved words. If it finds a match, it returns the corresponding token for that keyword.
+                       <dt><b>ntp_data_structures.c</b>
+                       <dd>This file contains an implementation of a generic priority queue and FIFO queue. By generic, we mean that these queues can hold element of any type (integers, user-defined structs, etc.), provided that these elements are allocated on the heap using the function <tt>void</tt> *<tt>get_node(size_t size)</tt>. Note that the prototype for this function is exactly the same as that of <tt>malloc</tt> and that it can be used in the exact same way. Behind the scenes, <tt>get_node</tt> calls <tt>malloc</tt> to allocate <i>size</i> plus some extra memory needed for bookkeeping. The allocated memory can be freed using the function <tt>void free_node (void *<i>my_node</i>)</tt>. In addition to these two functions, the public interface of this file contains the following functions:
+                       <dt><tt>queue *create_priority_queue(int (*get_order)(void *, void*))</tt>
+                       <dd>This function creates a priority queue in which the order of the elements is determined by the <tt>get_order</tt><b> </b>function that is passed as input to the priority queue. The <tt>get_order</tt><b> </b>function should return positive if the priority of the first element is less than the priority of the second element.
+                       <dt><tt>queue *create_queue(void)</tt>
+                       <dd>This function creates a FIFO queue. It basically calls the <tt>create_priority_queue</tt> function with the <tt>get_fifo_order</tt><b> </b>function as its argument.
+                       <dt><tt>void destroy_queue(queue *<i>my_queue</i>)</tt>
+                       <dd>This function deletes <tt><i>my_queue</i></tt><b> </b>and frees up all the memory allocated to it an its elements.
+                       <dt><tt>int empty(queue *</tt><i><tt>my_queue</tt></i><tt>)</tt>
+                       <dd>This function checks to see if <i><tt>my_queue</tt></i> is empty. Returns <tt>true</tt> if <tt><i>my_queue</i></tt> does not have any elements, else it returns false.
+                       <dt><tt>queue *enqueue(queue *<i>my_queue</i>, void *<i>my_node</i>)</tt>
+                       <dd>This function adds an element, <i><tt>my_node</tt></i>, to a queue, <i><tt>my_queue</tt></i>. <i><tt>my_node</tt></i> must be allocated on the heap using the <tt>get_node</tt> function instead of <tt>malloc</tt>.
+                       <dt><tt>void *dequeue(queue *<i>my_queue</i>)</tt>
+                       <dd>This function returns the element at the front of the queue. This element will be element with the highest priority.
+                       <dt><tt>int get_no_of_elements(queue *<i>my_queue</i>)</tt>
+                       <dd>This function returns the number of elements in <tt><i>my_queue</i></tt>.
+                       <dt><tt>void append_queue(queue *<i>q</i>1, queue *<i>q</i>2)</tt>
+                       <dd>This function adds all the elements of <tt><i>q</i>2</tt> to <tt><i>q</i>1</tt>. The queue <tt><i>q</i>2</tt> is destroyed in the process.
+                       <dt><b>ntp_config.y</b>
+                       <dd>This file is structured as a standard Bison file and consists of three main parts, separated by <tt>%%</tt>:
+               </dl>
+               <ol>
+                       <li>The prologue and bison declarations: This section contains a list of the terminal symbols, the non-terminal symbols and the types of these symbols.<li>The rules section: This section contains a description of the actual phrase-structure rules that are used to parse the configuration commands. Each rule consists of a left-hand side (LHS), a right-hand side (RHS) and an optional action. As is standard with phrase-structure grammars, the LHS consists of a single non-terminal symbol. The RHS can contain both terminal and non-terminal symbols, while the optional action can consist of any arbitrary C code.
+                       <li>The epilogue: This section is left empty on purpose. It is traditionally used to code the support functions needed to build the ASTs Since, we have moved all the support functions to <b>ntp_config.c</b>, this section is left empty. 
+               </ol>
+               <h4>Prologue and Bison Declarations</h4>
+               <p>All the terminal symbols (also known as tokens) have to be declared in the prologue section. Note that terminals and non-terminals may have values associated with them and these values have types. (More on this later). An unnamed union has to be declared with all the possible types at the start of the prologue section. For example, we declare the following union at the start of the <b>ntp_config.y</b> file:</p>
+                       <p class="style1"><tt>%union {<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;char *String;<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;double Double;<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;int Integer;<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;void *VoidPtr;<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;queue *Queue;<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;struct attr_val *Attr_val;<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;struct address_node *Address_node;<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;struct setvar_node *Set_var;<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;/* Simulation types */<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;server_info *Sim_server;<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;script_info *Sim_script;<br>
+                                               }</tt></p>
+               <p>Some tokens may not have any types. For example, tokens that correspond to reserved words do not usually have types as they simply indicate that a reserved word has been read in the input file. Such tokens have to be declared as follows:</p>
+                       <p><tt>%token T_Discard<br>
+                                               %token T_Dispersion</tt></p>
+               <p>Other tokens do have types. For example, a <tt>T_Double</tt> token is returned by the scanner whenever it sees a floating-point double in the configuration file. The value associated with the token is the actual number that was read in the configuration file and its type (after conversion) is double. Hence, the token <tt>T_Double</tt> will have to be declared as follows in the prologue of <b>ntp_config.y</b> file:</p>
+                       <p><tt>%token &lt;Double&gt; T_Double </tt></p>
+               <p>Note that the declaration given in the angled brackets is not <tt>double</tt> but <tt>Double</tt>, which is the name of the variable given in the <tt>%union {}</tt> declaration above.</p>
+               <p>Finally, non-terminal symbols may also have values associated with them, which have types. This is because Bison allows non-terminal symbols to have actions associated with them. Actions may be thought of as small functions which get executed whenever the RHS of a non-terminal is detected. The return values of these functions are the values associated with the non-terminals. The types of the non-terminals are specified with a <tt>%type</tt> declaration as shown below:</p>
+                       <p><tt>%type &lt;Queue&gt; address_list<br>
+                                       %type &lt;Integer&gt; boolean</tt></p>
+               <p>The <tt>%type</tt> declaration may be omitted for non-terminals that do not return any value and do not have type information associated with them.</p>
+               <h4>The Rules Section </h4>
+               <p>The rule section only consists of phrase-structure grammar rules. Each rule typically has the following format:</p>
+                       <p><tt>LHS : RHS [{ Actions }]<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;;</tt></p>
+               <p>where LHS consists of a single non-terminal symbol and the RHS consists of one or more terminal and non-terminal symbols. The <tt>Actions</tt> are optional and may consist of any number of arbitrary C statements. Note that Bison can only process LALR(1) grammars, which imposes additional restrictions on the kind of rules that can be specified. Examples of rules are shown below:</p>
+                       <p><tt>orphan_mode_command<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;: T_Tos tos_option_list<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;{ append_queue(my_config.orphan_cmds, $2); }<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;;</tt></p>
+                       <p><tt>tos_option_list<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;: tos_option_list tos_option { $$ = enqueue($1, $2); }<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;| tos_option { $$ = enqueue_in_new_queue($1); }<br>
+                                       &nbsp;&nbsp;&nbsp;&nbsp;;</tt></p>
+               <p>The <tt>$n</tt> notation, where <tt>n</tt> is an integer, is used to refer to the value of a terminal or non-terminal symbol. All terminals and non-terminal symbols within a particular rule are numbered (starting from 1) according to the order in which they appear within the RHS of a rule. <tt>$$</tt> is used to refer to the value of the LHS terminal symbol - it is used to return a value for the non-terminal symbol specified in the LHS of the rule.</p>
+               <h4>Invoking Bison </h4>
+               <p>Bison needs to be invoked in order to convert the <b>ntp_config.y</b> file into a C source file. To invoke Bison, simply enter the command:</p>
+               <p><tt>bison ntp_config.y</tt></p>
+               <p>at the command prompt. If no errors are detected, an <b>ntp_config.tab.c</b> file will be generated by default. This generated file can be directly included into the <b>ntp_config.c</b> file.</p>
+               <p>If Bison report shift-reduce errors or reduce-reduce errors, it means that the grammar specified using the rules in not LALR(1). To debug such a grammar, invoke Bison with a <tt>-v</tt> switch, as shown below. This will generate a <b>ntp_config.output</b> file, which will contain a description of the generated state machine, together with a list of states that have shift-reduce/reduce-reduce conflicts. You can then change the rules to remove such conflicts.</p>
+               <p><tt>bison -v ntp_config.y</tt></p>
+               <p>For more information, refer to the <a href="http://www.gnu.org/software/bison/manual/html_mono/bison.html">Bison manual</a>.</p>
+               <p><b>ntp_config.c</b></p>
+               <p>This file contains the major chunk of the configuration code including all the support functions needed for building and traversing the ASTs. As such, most of the functions in this file can be divided into two groups:</p>
+               <ol>
+                       <li>Functions that have a <tt>create_</tt> prefix. These functions are used to build a node of the AST. 
+                       <li>Functions that have a <tt>config_</tt> prefix. These functions are used to traverse the AST and configure NTP according to the nodes present on the tree. 
+               </ol>
+               <h4>Guidelines for Adding Configuration Commands</h4>
+               <p>The following steps may be used to add a new configuration command to the NTP reference implementation:</p>
+               <ol>
+                       <li>Write phrase-structure grammar rules for the syntax of the new command. Add these rules to the rules section of the <b>ntp_config.y</b> file. 
+                       <li>Write the action to be performed on recognizing the rules. These actions will be used to build the AST.
+                       <li>If new reserved words are needed, add these to the <tt>struct key_tok keyword_list[]</tt>structure in the <b>ntp_config.c </b>file. This will allow the scanner to recognize these reserved words and generate the desired tokens on recognizing them. 
+                       <li>Specify the types of all the terminals and non-terminal symbols in the prologue section of the <b>ntp_config.c</b> file. 
+                       <li>Write a function with a <tt>config_</tt> prefix that will   be executed for this new command. Make sure this function is called in the <tt>config_ntpd()</tt>function. 
+               </ol>
+               <hr>
+               <address><a href="mailto:skamboj@udel.edu">Sachin Kamboj</a></address>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/ntpd.html b/html/ntpd.html
new file mode 100644 (file)
index 0000000..3b70694
--- /dev/null
@@ -0,0 +1,185 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>ntpd - Network Time Protocol (NTP) daemon</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</h3>
+               <img src="pic/alice47.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>The mushroom knows all the command line options.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:44</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#synop">Synopsis</a><br>
+                       <li class="inline"><a href="#descr">Description</a><br>
+                       <li class="inline"><a href="#op">How NTP Operates</a><br>
+                       <li class="inline"><a href="#freq">Frequency Discipline</a><br>
+                       <li class="inline"><a href="#modes">Operating Modes</a><br>
+                       <li class="inline"><a href="#poll">Poll Interval Control</a><br>
+                       <li class="inline"><a href="#poll">Poll Interval Control</a><br>
+                       <li class="inline"><a href="#notes">Notes</a><br>
+                       <li class="inline"><a href="#cmd">Command Line Options</a><br>
+                       <li class="inline"><a href="#cfg">The Configuration File</a><br>
+                       <li class="inline"><a href="#opt">Configuration Options</a><br>
+                       <li class="inline"><a href="#files">Files</a>
+               </ul>
+               <hr>
+               <h4 id="synop">Synopsis</h4>
+               <tt>ntpd [ -46aAbdDgLmnNqx ] [ -c <i>conffile</i> ] [ -f <i>driftfile</i> ] [ -i <i>jaildir</i> ] [ -k <i>keyfile</i> ] [ -l <i>logfile</i> ] [ -p <i>pidfile</i> ] [ -P <i>priority</i> ] [ -r <i>broadcastdelay</i> ] [ -s <i>statsdir</i> ] [ -t <i>key</i> ] [ -u <i>user</i>[:<i>group</i>] ] [ -U <i>interface_update_interval</i> ] [ -v <i>variable</i> ] [ -V <i>variable</i> ]</tt>
+               <h4 id="descr">Description</h4>
+               <p>The <tt>ntpd</tt> program is an operating system daemon which sets and maintains the system time of day in synchronism with Internet standard time servers. It is a complete implementation of the Network Time Protocol (NTP) version 4, but also retains compatibility with version 3, as defined by RFC-1305, and version 1 and 2, as defined by RFC-1059 and RFC-1119, respectively. <tt>ntpd</tt> does most computations in 64-bit floating point arithmetic and does relatively clumsy 64-bit fixed point operations only when necessary to preserve the ultimate precision, about 232 picoseconds. While the ultimate precision is not achievable with ordinary workstations and networks of today, it may be required with future gigahertz CPU clocks and gigabit LANs.</p>
+               <h4 id="op">How NTP Operates</h4>
+               <p>The <tt>ntpd</tt> program operates by exchanging messages with one or more configured servers at designated poll intervals. When started, whether for the first or subsequent times, the program requires several exchanges from the majority of these servers so the signal processing and mitigation algorithms can accumulate and groom the data and set the clock. In order to protect the network from bursts, the initial poll interval for each server is delayed an interval randomized over a few seconds. At the default initial poll interval of 64s, several minutes can elapse before the clock is set. The initial delay to set the clock can be reduced using the <tt>iburst</tt> keyword with the <tt>server</tt> configuration command, as described on the <a href="confopt.html">Configuration Options</a> page.</p>
+               <p>Most operating systems and hardware of today incorporate a time-of-year (TOY) chip to maintain the time during periods when the power is off. When the machine is booted, the chip is used to initialize the operating system time. After the machine has synchronized to a NTP server, the operating system corrects the chip from time to time. In case there is no TOY chip or for some reason its time is more than 1000s from the server time, <tt>ntpd</tt> assumes something must be terribly wrong and the only reliable action is for the operator to intervene and set the clock by hand. This causes <tt>ntpd</tt> to exit with a panic message to the system log. The <tt>-g</tt> option overrides this check and the clock will be set to the server time regardless of the chip time. However, and to protect against broken hardware, such as when the CMOS battery fails or the clock counter becomes defective, once the clock has been set, an error greater than 1000s will cause <tt>ntpd</tt> to exit anyway.</p>
+               <p>Under ordinary conditions, <tt>ntpd</tt> adjusts the clock in small steps so that the timescale is effectively continuous and without discontinuities. Under conditions of extreme network congestion, the roundtrip delay jitter can exceed three seconds and the synchronization distance, which is equal to one-half the roundtrip delay plus error budget terms, can become very large. The <tt>ntpd</tt> algorithms discard sample offsets exceeding 128 ms, unless the interval during which no sample offset is less than 128 ms exceeds 900s. The first sample after that, no matter what the offset, steps the clock to the indicated time. In practice this reduces the false alarm rate where the clock is stepped in error to a vanishingly low incidence.</p>
+               <p>As the result of this behavior, once the clock has been set, it very rarely strays more than 128 ms, even under extreme cases of network path congestion and jitter. Sometimes, in particular when <tt>ntpd</tt> is first started, the error might exceed 128 ms. This may on occasion cause the clock to be set backwards if the local clock time is more than 128 s in the future relative to the server. In some applications, this behavior may be unacceptable. If the <tt>-x</tt> option is included on the command line, the clock will never be stepped and only slew corrections will be used.</p>
+               <p>The issues should be carefully explored before deciding to use the <tt>-x</tt> option. The maximum slew rate possible is limited to 500 parts-per-million (PPM) as a consequence of the correctness principles on which the NTP protocol and algorithm design are based. As a result, the local clock can take a long time to converge to an acceptable offset, about 2,000 s for each second the clock is outside the acceptable range. During this interval the local clock will not be consistent with any other network clock and the system cannot be used for distributed applications that require correctly synchronized network time.</p>
+               <p>In spite of the above precautions, sometimes when large frequency errors are present the resulting time offsets stray outside the 128-ms range and an eventual step or slew time correction is required. If following such a correction the frequency error is so large that the first sample is outside the acceptable range, <tt>ntpd</tt> enters the same state as when the <tt>ntp.drift</tt> file is not present. The intent of this behavior is to quickly correct the frequency and restore operation to the normal tracking mode. In the most extreme cases (<tt>time.ien.it</tt> comes to mind), there may be occasional step/slew corrections and subsequent frequency corrections. It helps in these cases to use the <tt>burst</tt> keyword when configuring the server.</p>
+               <h4 id="freq">Frequency Discipline</h4>
+               <p>The <tt>ntpd</tt> behavior at startup depends on whether the frequency file, usually <tt>ntp.drift</tt>, exists. This file contains the latest estimate of clock frequency error. When the <tt>ntpd</tt> is started and the file does not exist, the <tt>ntpd</tt> enters a special mode designed to quickly adapt to the particular system clock oscillator time and frequency error. This takes approximately 15 minutes, after which the time and frequency are set to nominal values and the <tt>ntpd</tt> enters normal mode, where the time and frequency are continuously tracked relative to the server. After one hour the frequency file is created and the current frequency offset written to it. When the <tt>ntpd</tt> is started and the file does exist, the <tt>ntpd</tt> frequency is initialized from the file and enters normal mode immediately. After that the current frequency offset is written to the file at hourly intervals.</p>
+               <h4 id="modes">Operating Modes</h4>
+               <p><tt>ntpd</tt> can operate in any of several modes, including symmetric active/passive, client/server broadcast/multicast and manycast, as described in the <a href="assoc.html">Association Management</a> page. It normally operates continuously while monitoring for small changes in frequency and trimming the clock for the ultimate precision. However, it can operate in a one-time mode where the time is set from an external server and frequency is set from a previously recorded frequency file. A broadcast/multicast or manycast client can discover remote servers, compute server-client propagation delay correction factors and configure itself automatically. This makes it possible to deploy a fleet of workstations without specifying configuration details specific to the local environment.</p>
+               <p>By default, <tt>ntpd</tt> runs in continuous mode where each of possibly several external servers is polled at intervals determined by an intricate state machine. The state machine measures the incidental roundtrip delay jitter and oscillator frequency wander and determines the best poll interval using a heuristic algorithm. Ordinarily, and in most operating environments, the state machine will start with 64s intervals and eventually increase in steps to 1024s. A small amount of random variation is introduced in order to avoid bunching at the servers. In addition, should a server become unreachable for some time, the poll interval is increased in steps to 1024s in order to reduce network overhead.</p>
+               <p>In some cases it may not be practical for <tt>ntpd</tt> to run continuously. A common workaround has been to run the <tt>ntpdate</tt> program from a <tt>cron</tt> job at designated times. However, this program does not have the crafted signal processing, error checking and mitigation algorithms of <tt>ntpd</tt>. The <tt>-q</tt> option is intended for this purpose. Setting this option will cause <tt>ntpd</tt> to exit just after setting the clock for the first time. The procedure for initially setting the clock is the same as in continuous mode; most applications will probably want to specify the <tt>iburst</tt> keyword with the <tt>server</tt> configuration command. With this keyword a volley of messages are exchanged to groom the data and the clock is set in about 10 s. If nothing is heard after a couple of minutes, the daemon times out and exits. After a suitable period of mourning, the <tt>ntpdate</tt> program may be retired.</p>
+               <p>When kernel support is available to discipline the clock frequency, which is the case for stock Solaris, Tru64, Linux and FreeBSD, a useful feature is available to discipline the clock frequency. First, <tt>ntpd</tt> is run in continuous mode with selected servers in order to measure and record the intrinsic clock frequency offset in the frequency file. It may take some hours for the frequency and offset to settle down. Then the <tt>ntpd</tt> is stopped and run in one-time mode as required. At each startup, the frequency is read from the file and initializes the kernel frequency.</p>
+               <h4 id="poll">Poll Interval Control</h4>
+               <p>This version of NTP includes an intricate state machine to reduce the network load while maintaining a quality of synchronization consistent with the observed jitter and wander. There are a number of ways to tailor the operation in order enhance accuracy by reducing the interval or to reduce network overhead by increasing it. However, the user is advised to carefully consider the consequences of changing the poll adjustment range from the default minimum of 64 s to the default maximum of 1,024 s. The default minimum can be changed with the <tt>tinker minpoll</tt> command to a value not less than 16 s. This value is used for all configured associations, unless overridden by the <tt>minpoll</tt> option on the configuration command. Note that most device drivers will not operate properly if the poll interval is less than 64 s and that the broadcast server and manycast client associations will also use the default, unless overridden.</p>
+               <p>In some cases involving dial up or toll services, it may be useful to increase the minimum interval to a few tens of minutes and maximum interval to a day or so. Under normal operation conditions, once the clock discipline loop has stabilized the interval will be increased in steps from the minimum to the maximum. However, this assumes the intrinsic clock frequency error is small enough for the discipline loop correct it. The capture range of the loop is 500 PPM at an interval of 64s decreasing by a factor of two for each doubling of interval. At a minimum of 1,024 s, for example, the capture range is only 31 PPM. If the intrinsic error is greater than this, the drift file <tt>ntp.drift</tt> will have to be specially tailored to reduce the residual error below this limit. Once this is done, the drift file is automatically updated once per hour and is available to initialize the frequency on subsequent daemon restarts.</p>
+               <h4 id="huff">The huff-n'-puff Filter</h4>
+               <p>In scenarios where a considerable amount of data are to be downloaded or uploaded over telephone modems, timekeeping quality can be seriously degraded. This occurs because the differential delays on the two directions of transmission can be quite large. In many cases the apparent time errors are so large as to exceed the step threshold and a step correction can occur during and after the data transfer is in progress.</p>
+               <p>The huff-n'-puff filter is designed to correct the apparent time offset in these cases. It depends on knowledge of the propagation delay when no other traffic is present. In common scenarios this occurs during other than work hours. The filter maintains a shift register that remembers the minimum delay over the most recent interval measured usually in hours. Under conditions of severe delay, the filter corrects the apparent offset using the sign of the offset and the difference between the apparent delay and minimum delay. The name of the filter reflects the negative (huff) and positive (puff) correction, which depends on the sign of the offset.</p>
+               <p>The filter is activated by the <tt>tinker</tt> command and <tt>huffpuff</tt> keyword, as described in the <a href="miscopt.html">Miscellaneous Options</a> page.</p>
+               <h4 id="notes">Notes</h4>
+               <p>If NetInfo support is built into <tt>ntpd</tt>, then <tt>ntpd</tt> will attempt to read its configuration from the NetInfo if the default ntp.conf file cannot be read and no file is specified by the <tt>-c</tt> option.</p>
+               <p>In contexts where a host name is expected, a <tt>-4</tt> qualifier preceding the host name forces DNS resolution to the IPv4 namespace, while a <tt>-6</tt> qualifier forces DNS resolution to the IPv6 namespace.</p>
+               <p>Various internal <tt>ntpd</tt> variables can be displayed and configuration options altered while the <tt>ntpd</tt> is running using the <tt><a href="ntpq.html">ntpq</a></tt> and <tt><a href="ntpdc.html">ntpdc</a></tt> utility programs.</p>
+               <p>When <tt>ntpd</tt> starts it looks at the value of <tt>umask</tt>, and if zero <tt>ntpd</tt> will set the <tt>umask</tt> to <tt>022</tt>.</p>
+               <h4 id="cmd">Command Line Options</h4>
+               <dl>
+                       <dt><tt>-a</tt>
+                       <dd>Require cryptographic authentication for broadcast client, multicast client and symmetric passive associations. This is the default.
+                       <dt><tt>-A</tt>
+                       <dd>Do not require cryptographic authentication for broadcast client, multicast client and symmetric passive associations. This is almost never a good idea.
+                       <dt><tt>-b</tt>
+                       <dd>Enable the client to synchronize to broadcast servers.
+                       <dt><tt>-c <i>conffile</i></tt>
+                       <dd>Specify the name and path of the configuration file, default <tt>/etc/ntp.conf</tt>.
+                       <dt><tt>-d</tt>
+                       <dd>Specify debugging mode. This option may occur more than once, with each occurrence indicating greater detail of display.
+                       <dt><tt>-D <i>level</i></tt>
+                       <dd>Specify debugging level directly.
+                       <dt><tt>-f <i>driftfile</i></tt>
+                       <dd>Specify the name and path of the frequency file, default <tt>/etc/ntp.drift</tt>. This is the same operation as the <tt>driftfile <i>driftfile</i></tt> configuration command.
+                       <dt><tt>-g</tt>
+                       <dd>Normally, <tt>ntpd</tt> exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows the time to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that, <tt>ntpd</tt> will exit with a message to the system log. This option can be used with the <tt>-q</tt> and <tt>-x</tt> options. See the <tt>tinker</tt> command for other options.
+                       <dt><tt>-i <i>jaildir</i></tt>
+                       <dd>Chroot the server to the directory <i>jaildir</i>. This option also implies that the server attempts to drop root privileges at startup (otherwise, chroot gives very little additional security), and it is only available if the OS supports to run the server without full root privileges. You may need to also specify a <tt>-u</tt> option.
+                       <dt><tt>-k <i>keyfile</i></tt>
+                       <dd>Specify the name and path of the symmetric key file, default <tt>/etc/ntp.keys</tt>. This is the same operation as the <tt>keys <i>keyfile</i></tt> configuration command.
+                       <dt><tt>-l <i>logfile</i></tt>
+                       <dd>Specify the name and path of the log file. The default is the system log file. This is the same operation as the <tt>logfile <i>logfile</i></tt> configuration command.
+                       <dt><tt>-L</tt>
+                       <dd>Do not listen to virtual IPs. The default is to listen.
+                       <dt><tt>-n</tt>
+                       <dd>Don't fork.
+                       <dt><tt>-N</tt>
+                       <dd>To the extent permitted by the operating system, run the <tt>ntpd</tt> at the highest priority.
+                       <dt><tt>-p <i>pidfile</i></tt>
+                       <dd>Specify the name and path of the file used to record the <tt>ntpd</tt> process ID. This is the same operation as the <tt>pidfile <i>pidfile</i></tt> configuration command.
+                       <dt><tt>-P <i>priority</i></tt>
+                       <dd>To the extent permitted by the operating system, run the <tt>ntpd</tt> at the specified priority.
+                       <dt><tt>-q</tt>
+                       <dd>Exit the <tt>ntpd</tt> just after the first time the clock is set. This behavior mimics that of the <tt>ntpdate</tt> program, which is to be retired. The <tt>-g</tt> and <tt>-x</tt> options can be used with this option. Note:&nbsp;The kernel time discipline is disabled with this option.
+                       <dt><tt>-r <i>broadcastdelay</i></tt>
+                       <dd>Specify the default propagation delay from the broadcast/multicast server to this client. This is necessary only if the delay cannot be computed automatically by the protocol.
+                       <dt><tt>-s <i>statsdir</i></tt>
+                       <dd>Specify the directory path for files created by the statistics facility. This is the same operation as the <tt>statsdir <i>statsdir</i></tt> configuration command.
+                       <dt><tt>-t <i>key</i></tt>
+                       <dd>Add a key number to the trusted key list. This option can occur more than once.
+                       <dt><tt>-u <i>user[:group]</i> </tt>
+                       <dd>Specify a user, and optionally a group, to switch to. This option is only available if the OS supports to run the server without full root privileges. Currently, this option is supported under NetBSD (configure with --enable-clockctl) and Linux (configure with --enable-linuxcaps).
+                       <dt><tt>-U <i>interface update interval</i></tt>
+                       <dd>Number of seconds to wait between interface list scans to pick up new and delete network interface. Set to 0 to disable dynamic interface list updating. The default is to scan every 5 minutes.</dd>
+                       <dt><tt>-v <i>variable</i></tt>
+                       <dt><tt>-V <i>variable</i></tt>
+                       <dd>Add a system variable listed by default.
+                       <dt><tt>-x</tt>
+                       <dd>Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold. This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually. Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s. Thus, an adjustment as much as 600 s will take almost 14 days to complete. This option can be used with the <tt>-g</tt> and <tt>-q</tt> options. See the <tt>tinker</tt> command for other options. Note:&nbsp;The kernel time discipline is disabled with this option.
+               </dl>
+               <h4 id="cfg">The Configuration File</h4>
+               <p>Ordinarily, <tt>ntpd</tt> reads the <tt>ntp.conf</tt> configuration file at startup time in order to determine the synchronization sources and operating modes. It is also possible to specify a working, although limited, configuration entirely on the command line, obviating the need for a configuration file. This may be particularly useful when the local host is to be configured as a broadcast/multicast client, with all peers being determined by listening to broadcasts at run time.</p>
+               <p>Usually, the configuration file is installed in the <tt>/etc</tt> directory, but could be installed elsewhere (see the <tt>-c <i>conffile</i></tt> command line option). The file format is similar to other Unix configuration files - comments begin with a <tt>#</tt> character and extend to the end of the line; blank lines are ignored.</p>
+               <p>Configuration commands consist of an initial keyword followed by a list of arguments, some of which may be optional, separated by whitespace. Commands may not be continued over multiple lines. Arguments may be host names, host addresses written in numeric, dotted-quad form, integers, floating point numbers (when specifying times in seconds) and text strings. Optional arguments are delimited by <tt>[ ]</tt> in the following descriptions, while alternatives are separated by <tt>|</tt>. The notation <tt>[ ... ]</tt> means an optional, indefinite repetition of the last item before the <tt>[ ... ]</tt>.</p>
+               <h4 id="opt">Configuration Options</h4>
+               <p><a href="confopt.html">Server Options</a><br>
+                       <a href="authopt.html">Authentication Options</a><br>
+                       <a href="monopt.html">Monitoring Options</a><br>
+                       <a href="accopt.html">Access Control Options</a><br>
+                       <a href="manyopt.html">Automatic NTP Configuration Options</a><br>
+                       <a href="clockopt.html">Reference Clock Options</a><br>
+                       <a href="miscopt.html">Miscellaneous Options</a></p>
+               <h4 id="files">Files</h4>
+               <table width="100%" border="1">
+                       <tr>
+                               <td width="30%">File</td>
+                               <td width="30%">Default</td>
+                               <td width="20%">Option</td>
+                               <td width="20%">Command</td>
+                       </tr>
+                       <tr>
+                               <td width="30%">configuration file</td>
+                               <td width="30%"><tt>/etc/ntp.conf</tt></td>
+                               <td width="20%"><tt>-c</tt></td>
+                               <td width="20%">none</td>
+                       </tr>
+                       <tr>
+                               <td width="30%">frequency file</td>
+                               <td width="30%"><tt>/etc/ntp.drift</tt></td>
+                               <td width="20%"><tt>-f</tt></td>
+                               <td width="20%"><tt>driftfile</tt></td>
+                       </tr>
+                       <tr>
+                               <td width="30%">process ID file</td>
+                               <td width="30%">none</td>
+                               <td width="20%"><tt>-p</tt></td>
+                               <td width="20%"><tt>pidfile</tt></td>
+                       </tr>
+                       <tr>
+                               <td width="30%">log file</td>
+                               <td width="30%">system log</td>
+                               <td width="20%"><tt>-l</tt></td>
+                               <td width="20%"><tt>logfile</tt></td>
+                       </tr>
+                       <tr>
+                               <td width="30%">include file</td>
+                               <td width="30%">none</td>
+                               <td width="20%">none</td>
+                               <td width="20%"><tt>includefile</tt></td>
+                       </tr>
+                       <tr>
+                               <td width="30%">statistics path</td>
+                               <td width="30%"><tt>/var/NTP</tt></td>
+                               <td width="20%"><tt>-s</tt></td>
+                               <td width="20%"><tt>statsdir</tt></td>
+                       </tr>
+                       <tr>
+                               <td width="30%">keys path</td>
+                               <td width="30%"><tt>/usr/local/etc</tt></td>
+                               <td width="20%"><tt>-k</tt></td>
+                               <td width="20%"><tt>keysdir</tt></td>
+                       </tr>
+               </table>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/ntpdate.html b/html/ntpdate.html
new file mode 100644 (file)
index 0000000..30d8cad
--- /dev/null
@@ -0,0 +1,72 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>ntpdate - set the date and time via NTP</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3><tt>ntpdate</tt> - set the date and time via NTP</h3>
+               <img src="pic/rabbit.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>I told you it was eyeball and wristwatch.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:44</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <hr>
+               <p>Disclaimer: The functionality of this program is now available in the <tt>ntpd</tt> program. See the <tt>-q</tt> command line option in the <a href="ntpd.html"><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</a> page. After a suitable period of mourning, the <tt>ntpdate</tt> program is to be retired from this distribution</p>
+               <h4>Synopsis</h4>
+               <tt>ntpdate [ -bBdoqsuv ] [ -a <i>key</i> ] [ -e <i>authdelay</i> ] [ -k <i>keyfile</i> ] [ -o <i>version</i> ] [ -p <i>samples</i> ] [ -t <i>timeout</i> ] <i>server</i> [ ... ]</tt>
+               <h4>Description</h4>
+               <tt>ntpdate</tt> sets the local date and time by polling the Network Time Protocol (NTP) server(s) given as the <i>server</i> arguments to determine the correct time. It must be run as root on the local host. A number of samples are obtained from each of the servers specified and a subset of the NTP clock filter and selection algorithms are applied to select the best of these. Note that the accuracy and reliability of <tt>ntpdate</tt> depends on the number of servers, the number of polls each time it is run and the interval between runs.
+               <p><tt>ntpdate</tt> can be run manually as necessary to set the host clock, or it can be run from the host startup script to set the clock at boot time. This is useful in some cases to set the clock initially before starting the NTP daemon <tt>ntpd</tt>. It is also possible to run <tt>ntpdate</tt> from a <tt>cron</tt> script. However, it is important to note that <tt>ntpdate</tt> with contrived <tt>cron</tt> scripts is no substitute for the NTP daemon, which uses sophisticated algorithms to maximize accuracy and reliability while minimizing resource use. Finally, since <tt>ntpdate</tt> does not discipline the host clock frequency as does <tt>ntpd</tt>, the accuracy using <tt>ntpdate</tt> is limited.</p>
+               <p>Time adjustments are made by <tt>ntpdate</tt> in one of two ways. If <tt>ntpdate</tt> determines the clock is in error more than 0.5 second it will simply step the time by calling the system <tt>settimeofday()</tt> routine. If the error is less than 0.5 seconds, it will slew the time by calling the system <tt>adjtime()</tt> routine. The latter technique is less disruptive and more accurate when the error is small, and works quite well when <tt>ntpdate</tt> is run by <tt>cron</tt> every hour or two.</p>
+               <p><tt>ntpdate</tt> will decline to set the date if an NTP server daemon (e.g., <tt>ntpd</tt>) is running on the same host. When running <tt>ntpdate</tt> on a regular basis from <tt>cron</tt> as an alternative to running a daemon, doing so once every hour or two will result in precise enough timekeeping to avoid stepping the clock.</p>
+               <p>Note that in contexts where a host name is expected, a <tt>-4</tt> qualifier preceding the host name forces DNS resolution to the IPv4 namespace, while a <tt>-6</tt> qualifier forces DNS resolution to the IPv6 namespace.</p>
+               <p>If NetInfo support is compiled into <tt>ntpdate</tt>, then the <tt>server</tt> argument is optional if <tt>ntpdate</tt> can find a time server in the NetInfo configuration for <tt>ntpd</tt>.</p>
+               <h4>Command Line Options</h4>
+               <dl>
+                       <dt><tt>-4</tt>
+                       <dd>Force DNS resolution of following host names on the command line to the IPv4 namespace.
+                       <dt><tt>-6</tt>
+                       <dd>Force DNS resolution of following host names on the command line to the IPv6 namespace.
+                       <dt><tt>-a <i>key</i></tt>
+                       <dd>Enable the authentication function and specify the key identifier to be used for authentication as the argument <i>key</i><tt>ntpdate</tt>. The keys and key identifiers must match in both the client and server key files. The default is to disable the authentication function.
+                       <dt><tt>-B</tt>
+                       <dd>Force the time to always be slewed using the adjtime() system call, even if the measured offset is greater than +-128 ms. The default is to step the time using settimeofday() if the offset is greater than +-128 ms. Note that, if the offset is much greater than +-128 ms in this case, that it can take a long time (hours) to slew the clock to the correct value. During this time. the host should not be used to synchronize clients.
+                       <dt><tt>-b</tt>
+                       <dd>Force the time to be stepped using the settimeofday() system call, rather than slewed (default) using the adjtime() system call. This option should be used when called from a startup file at boot time.
+                       <dt><tt>-d</tt>
+                       <dd>Enable the debugging mode, in which <tt>ntpdate</tt> will go through all the steps, but not adjust the local clock. Information useful for general debugging will also be printed.
+                       <dt><tt>-e <i>authdelay</i></tt>
+                       <dd>Specify the processing delay to perform an authentication function as the value <i>authdelay</i>, in seconds and fraction (see <tt>ntpd</tt> for details). This number is usually small enough to be negligible for most purposes, though specifying a value may improve timekeeping on very slow CPU's.
+                       <dt><tt>-k <i>keyfile</i></tt>
+                       <dd>Specify the path for the authentication key file as the string <i>keyfile</i>. The default is <tt>/etc/ntp.keys</tt>. This file should be in the format described in <tt>ntpd</tt>.
+                       <dt><tt>-o <i>version</i></tt>
+                       <dd>Specify the NTP version for outgoing packets as the integer <i>version</i>, which can be 1 or 2. The default is 3. This allows <tt>ntpdate</tt> to be used with older NTP versions.
+                       <dt><tt>-p <i>samples</i></tt>
+                       <dd>Specify the number of samples to be acquired from each server as the integer <i>samples</i>, with values from 1 to 8 inclusive. The default is 4.
+                       <dt><i><tt>-q</tt></i>
+                       <dd>Query only - don't set the clock.
+                       <dt><tt>-s</tt>
+                       <dd>Divert logging output from the standard output (default) to the system <tt>syslog</tt> facility. This is designed primarily for convenience of <tt>cron</tt> scripts.
+                       <dt><tt>-t <i>timeout</i></tt>
+                       <dd>Specify the maximum time waiting for a server response as the value <i>timeout</i>, in seconds and fraction. The value is is rounded to a multiple of 0.2 seconds. The default is 1 second, a value suitable for polling across a LAN.
+                       <dt><tt>-u</tt>
+                       <dd>Direct <tt>ntpdate</tt> to use an unprivileged port or outgoing packets. This is most useful when behind a firewall that blocks incoming traffic to privileged ports, and you want to synchronise with hosts beyond the firewall. Note that the <tt>-d</tt> option always uses unprivileged ports.
+                       <dt><tt>-<i>v</i></tt>
+                       <dd>Be verbose. This option will cause <tt>ntpdate</tt>'s version identification string to be logged.
+               </dl>
+               <h4>Diagnostics</h4>
+               <tt>ntpdate</tt>'s exit status is zero if it finds a server and updates the clock, and nonzero otherwise.
+               <h4>Files</h4>
+               <tt>/etc/ntp.keys</tt> - encryption keys used by <tt>ntpdate</tt>.
+               <h4>Bugs</h4>
+               The slew adjustment is actually 50% larger than the measured offset, since this (it is argued) will tend to keep a badly drifting clock more accurate. This is probably not a good idea and may cause a troubling hunt for some values of the kernel variables <tt>tick</tt> and <tt>tickadj</tt>.&nbsp;
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/ntpdc.html b/html/ntpdc.html
new file mode 100644 (file)
index 0000000..92fde1d
--- /dev/null
@@ -0,0 +1,215 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>ntpdc - special NTP query program</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3><tt>ntpdc</tt> - special NTP query program</h3>
+               <img src="pic/alice31.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>This program is a big puppy.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="99">04:11 AM</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="294">Monday, November 27, 2006</csobj></p>
+               <br clear="left">
+               <h4>More Help</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links12.txt"></script>
+               <hr>
+               <h4>Synopsis</h4>
+               <tt>ntpdc [ -ilnps ] [ -c <i>command</i> ] [ <i>host</i> ] [ ... ]</tt>
+               <h4>Description</h4>
+               <tt>ntpdc</tt> is used to query the <tt>ntpd</tt> daemon about its current state and to request changes in that state. The program may be run either in interactive mode or controlled using command line arguments. Extensive state and statistics information is available through the <tt>ntpdc</tt> interface. In addition, nearly all the configuration options which can be specified at startup using ntpd's configuration file may also be specified at run time using <tt>ntpdc</tt>.
+               <p>If one or more request options are included on the command line when <tt>ntpdc</tt> is executed, each of the requests will be sent to the NTP servers running on each of the hosts given as command line arguments, or on localhost by default. If no request options are given, <tt>ntpdc</tt> will attempt to read commands from the standard input and execute these on the NTP server running on the first host given on the command line, again defaulting to localhost when no other host is specified. <tt>ntpdc</tt> will prompt for commands if the standard input is a terminal device.</p>
+               <p><tt>ntpdc</tt> uses NTP mode 7 packets to communicate with the NTP server, and hence can be used to query any compatible server on the network which permits it. Note that since NTP is a UDP protocol this communication will be somewhat unreliable, especially over large distances in terms of network topology. <tt>ntpdc</tt> makes no attempt to retransmit requests, and will time requests out if the remote host is not heard from within a suitable timeout time.</p>
+               <p>The operation of <tt>ntpdc</tt> are specific to the particular implementation of the <tt>ntpd</tt> daemon and can be expected to work only with this and maybe some previous versions of the daemon. Requests from a remote <tt>ntpdc</tt> program which affect the state of the local server must be authenticated, which requires both the remote program and local server share a common key and key identifier.</p>
+               <p>Note that in contexts where a host name is expected, a <tt>-4</tt> qualifier preceding the host name forces DNS resolution to the IPv4 namespace, while a <tt>-6</tt> qualifier forces DNS resolution to the IPv6 namespace.</p>
+               <h4>Command Line Options</h4>
+               <p>Specifying a command line option other than <tt>-i</tt> or <tt>-n</tt> will cause the specified query (queries) to be sent to the indicated host(s) immediately. Otherwise, <tt>ntpdc</tt> will attempt to read interactive format commands from the standard input.</p>
+               <dl>
+                       <dt><tt>-4</tt>
+                       <dd>Force DNS resolution of following host names on the command line to the IPv4 namespace.
+                       <dt><tt>-6</tt>
+                       <dd>Force DNS resolution of following host names on the command line to the IPv6 namespace.
+                       <dt><tt>-c <i>command</i></tt>
+                       <dd>The following argument is interpreted as an interactive format command and is added to the list of commands to be executed on the specified host(s). Multiple -c options may be given.
+                       <dt><tt>-i</tt>
+                       <dd>Force <tt>ntpdc</tt> to operate in interactive mode. Prompts will be written to the standard output and commands read from the standard input.
+                       <dt><tt>-l</tt>
+                       <dd>Obtain a list of peers which are known to the server(s). This switch is equivalent to <tt>-c listpeers</tt>.
+                       <dt><tt>-n</tt>
+                       <dd>Output all host addresses in dotted-quad numeric format rather than converting to the canonical host names.
+                       <dt><tt>-p</tt>
+                       <dd>Print a list of the peers known to the server as well as a summary of their state. This is equivalent to <tt>-c peers</tt>.
+                       <dt><tt>-s</tt>
+                       <dd>Print a list of the peers known to the server as well as a summary of their state, but in a slightly different format than the -p switch. This is equivalent to <tt>-c dmpeers</tt>.
+               </dl>
+               <h4>Interactive Commands</h4>
+               <p>Interactive format commands consist of a keyword followed by zero to four arguments. Only enough characters of the full keyword to uniquely identify the command need be typed. The output of a command is normally sent to the standard output, but optionally the output of individual commands may be sent to a file by appending a <tt>&lt;</tt>, followed by a file name, to the command line.</p>
+               <p>A number of interactive format commands are executed entirely within the <tt>ntpdc</tt> program itself and do not result in NTP mode 7 requests being sent to a server. These are described following.</p>
+               <dl>
+                       <dt><tt>? [ <i>command_keyword</i> ]</tt><br>
+                               <tt>help [ <i>command_keyword</i> ]</tt>
+                       <dd>A <tt>?</tt> by itself will print a list of all the command keywords known to this incarnation of <tt>ntpq</tt>. A <tt>?</tt> followed by a command keyword will print function and usage information about the command. This command is probably a better source of information about <tt>ntpq</tt> than this manual page.
+                       <dt><tt>delay <i>milliseconds</i></tt>
+                       <dd>Specify a time interval to be added to timestamps included in requests which require authentication. This is used to enable (unreliable) server reconfiguration over long delay network paths or between machines whose clocks are unsynchronized. Actually the server does not now require timestamps in authenticated requests, so this command may be obsolete.
+                       <dt><tt>host <i>hostname</i></tt>
+                       <dd>Set the host to which future queries will be sent. Hostname may be either a host name or a numeric address.
+                       <dt><tt>hostnames [ yes | no ]</tt>
+                       <dd>If <tt>yes</tt> is specified, host names are printed in information displays. If <tt>no</tt> is specified, numeric addresses are printed instead. The default is <tt>yes</tt>, unless modified using the command line <tt>-n</tt> switch.
+                       <dt><tt>keyid <i>keyid</i></tt>
+                       <dd>This command allows the specification of a
+               key number to be used to authenticate configuration
+               requests from ntpdc to the host(s). This must
+               correspond to a key number which the host/server has
+               been configured to use for this purpose (server
+               options: <tt>trustedkey</tt>, and
+               <tt>requestkey</tt>).  If authentication is not
+               enabled on the host(s) for ntpdc
+               commands, the command
+               <tt>"keyid 0"</tt> should be given; otherwise the
+               <i>keyid</i> of the next subsequent <tt>addpeer/addserver/broadcast
+                       </tt> command will
+                       be used.  
+                       <dt><tt>quit</tt>
+                       <dd>Exit <tt>ntpdc</tt>.
+                       <dt><tt>passwd</tt>
+                       <dd>This command prompts you to type in a password (which will not be echoed) which will be used to authenticate configuration requests. The password must correspond to the key configured for use by the NTP server for this purpose if such requests are to be successful.
+                       <dt><tt>timeout <i>milliseconds</i></tt>
+                       <dd>Specify a timeout period for responses to server queries. The default is about 8000 milliseconds. Note that since <tt>ntpdc</tt> retries each query once after a timeout, the total waiting time for a timeout will be twice the timeout value set.
+               </dl>
+               <h4>Control Message Commands</h4>
+               <p>Query commands result in NTP mode 7 packets containing requests for information being sent to the server. These are read-only commands in that they make no modification of the server configuration state.</p>
+               <dl>
+                       <dt><tt>listpeers</tt>
+                       <dd>Obtains and prints a brief list of the peers for which the server is maintaining state. These should include all configured peer associations as well as those peers whose stratum is such that they are considered by the server to be possible future synchronization candidates.
+                       <dt><tt>peers</tt>
+                       <dd>Obtains a list of peers for which the server is maintaining state, along with a summary of that state. Summary information includes the address of the remote peer, the local interface address (0.0.0.0 if a local address has yet to be determined), the stratum of the remote peer (a stratum of 16 indicates the remote peer is unsynchronized), the polling interval, in seconds, the reachability register, in octal, and the current estimated delay, offset and dispersion of the peer, all in seconds.
+                               <p>The character in the left margin indicates the mode this peer entry is operating in. A <tt>+</tt> denotes symmetric active, a <tt>-</tt> indicates symmetric passive, a <tt>=</tt> means the remote server is being polled in client mode, a <tt>^</tt> indicates that the server is broadcasting to this address, a <tt>~</tt> denotes that the remote peer is sending broadcasts and a <tt>*</tt> marks the peer the server is currently synchronizing to.</p>
+                               <p>The contents of the host field may be one of four forms. It may be a host name, an IP address, a reference clock implementation name with its parameter or <tt>REFCLK(<i>implementation number</i>, <i>parameter</i>)</tt>. On <tt>hostnames no</tt> only IP-addresses will be displayed.</p>
+                       <dt><tt>dmpeers</tt>
+                       <dd>A slightly different peer summary list. Identical to the output of the <tt>peers</tt> command, except for the character in the leftmost column. Characters only appear beside peers which were included in the final stage of the clock selection algorithm. A <tt>.</tt> indicates that this peer was cast off in the falseticker detection, while a <tt>+</tt> indicates that the peer made it through. A <tt>*</tt> denotes the peer the server is currently synchronizing with.
+                       <dt><tt>showpeer <i>peer_address</i> [...]</tt>
+                       <dd>Shows a detailed display of the current peer variables for one or more peers. Most of these values are described in the NTP Version 2 specification.
+                       <dt><tt>pstats <i>peer_address</i> [...]</tt>
+                       <dd>Show per-peer statistic counters associated with the specified peer(s).
+                       <dt><tt>clockinfo <i>clock_peer_address</i> [...]</tt>
+                       <dd>Obtain and print information concerning a peer clock. The values obtained provide information on the setting of fudge factors and other clock performance information.
+                       <dt><tt>kerninfo</tt>
+                       <dd>Obtain and print kernel phase-lock loop operating parameters. This information is available only if the kernel has been specially modified for a precision timekeeping function.
+                       <dt><tt>loopinfo [ oneline | multiline ]</tt>
+                       <dd>Print the values of selected loop filter variables. The loop filter is the part of NTP which deals with adjusting the local system clock. The <tt>offset</tt> is the last offset given to the loop filter by the packet processing code. The <tt>frequency</tt> is the frequency error of the local clock in parts-per-million (ppm). The <tt>time_const</tt> controls the stiffness of the phase-lock loop and thus the speed at which it can adapt to oscillator drift. The <tt>watchdog timer</tt> value is the number of seconds which have elapsed since the last sample offset was given to the loop filter. The <tt>oneline</tt> and <tt>multiline</tt> options specify the format in which this information is to be printed, with <tt>multiline</tt> as the default.
+                       <dt><tt>sysinfo</tt>
+                       <dd>Print a variety of system state variables, i.e., state related to the local server. All except the last four lines are described in the NTP Version 3 specification, RFC-1305.
+                               <p>The <tt>system flags</tt> show various system flags, some of which can be set and cleared by the <tt>enable</tt> and <tt>disable</tt> configuration commands, respectively. These are the <tt>auth</tt>, <tt>bclient</tt>, <tt>monitor</tt>, <tt>pll</tt>, <tt>pps</tt> and <tt>stats</tt> flags. See the <tt>ntpd</tt> documentation for the meaning of these flags. There are two additional flags which are read only, the <tt>kernel_pll</tt> and <tt>kernel_pps</tt>. These flags indicate the synchronization status when the precision time kernel modifications are in use. The <tt>kernel_pll</tt> indicates that the local clock is being disciplined by the kernel, while the kernel_pps indicates the kernel discipline is provided by the PPS signal.</p>
+                               <p>The <tt>stability</tt> is the residual frequency error remaining after the system frequency correction is applied and is intended for maintenance and debugging. In most architectures, this value will initially decrease from as high as 500 ppm to a nominal value in the range .01 to 0.1 ppm. If it remains high for some time after starting the daemon, something may be wrong with the local clock, or the value of the kernel variable <tt>tick</tt> may be incorrect.</p>
+                               <p>The <tt>broadcastdelay</tt> shows the default broadcast delay, as set by the <tt>broadcastdelay</tt> configuration command.</p>
+                               <p>The <tt>authdelay</tt> shows the default authentication delay, as set by the <tt>authdelay</tt> configuration command.</p>
+                       <dt><tt>sysstats</tt>
+                       <dd>Print statistics counters maintained in the protocol module.
+                       <dt><tt>memstats</tt>
+                       <dd>Print statistics counters related to memory allocation code.
+                       <dt><tt>iostats</tt>
+                       <dd>Print statistics counters maintained in the input-output module.
+                       <dt><tt>timerstats</tt>
+                       <dd>Print statistics counters maintained in the timer/event queue support code.
+                       <dt><tt>reslist</tt>
+                       <dd>Obtain and print the server's restriction list. This list is (usually) printed in sorted order and may help to understand how the restrictions are applied.
+                       <dt><tt>ifstats</tt>
+                       <dd>List interface statistics for interfaces used by ntpd for network communication.</dd>
+                       <dt><tt>ifreload</tt>
+                       <dd>Force rescan of current system interfaces. Outputs interface statistics for interfaces that could possibly change. Marks unchanged interfaces with <b>.</b>, added interfaces with <b>+</b> and deleted interfaces with <b>-</b>.</dd>
+                       <dt><tt>monlist [ <i>version</i> ]</tt>
+                       <dd>Obtain and print traffic counts collected and maintained by the monitor facility. The version number should not normally need to be specified.
+                       <dt><tt>clkbug <i>clock_peer_address</i> [...]</tt>
+                       <dd>Obtain debugging information for a reference clock driver. This information is provided only by some clock drivers and is mostly undecodable without a copy of the driver source in hand.
+               </dl>
+               <h4>Runtime Configuration Requests</h4>
+               <p>All requests which cause state changes in the server are authenticated by the server using a configured NTP key (the facility can also be disabled by the server by not configuring a key). The key number and the corresponding key must also be made known to <tt>ntpdc</tt>. This can be done using the keyid and passwd commands, the latter of which will prompt at the terminal for a password to use as the encryption key. You will also be prompted automatically for both the key number and password the first time a command which would result in an authenticated request to the server is given. Authentication not only provides verification that the requester has permission to make such changes, but also gives an extra degree of protection again transmission errors.</p>
+               <p>Authenticated requests always include a timestamp in the packet data, which is included in the computation of the authentication code. This timestamp is compared by the server to its receive time stamp. If they differ by more than a small amount the request is rejected. This is done for two reasons. First, it makes simple replay attacks on the server, by someone who might be able to overhear traffic on your LAN, much more difficult. Second, it makes it more difficult to request configuration changes to your server from topologically remote hosts. While the reconfiguration facility will work well with a server on the local host, and may work adequately between time-synchronized hosts on the same LAN, it will work very poorly for more distant hosts. As such, if reasonable passwords are chosen, care is taken in the distribution and protection of keys and appropriate source address restrictions are applied, the run time reconfiguration facility should provide an adequate level of security.</p>
+               <p>The following commands all make authenticated requests.</p>
+               <dl>
+               <dt><tt>addpeer <i>peer_address</i> [
+               <i>keyid</i> ] [ <i>version</i> ] [
+               <tt>minpoll# | prefer | iburst  | burst | minpoll
+               <i>N</i> | <tt>maxpoll</tt> <i>N</i> [...] ]</tt>
+               <dt><tt>addpeer <i>peer_address</i> [
+               <tt>prefer | iburst | burst | minpoll
+               <i>N</i> | <tt>maxpoll</tt> <i>N</i> | <tt>keyid</tt>
+                       <i>N</i> | <tt>version</tt> <i>N</i> [...] ]</tt>
+                       <dd>Add a configured peer association at the
+                       given address and operating in symmetric
+                       active mode. Note that an existing association
+                       with the same peer may be deleted when this
+                       command is executed, or may simply be
+                       converted to conform to the new configuration,
+                       as appropriate. If the <tt>keyid</tt>
+                       is nonzero, all outgoing packets to
+                       the remote server will have an authentication
+                       field attached encrypted with this key. If the
+                       value is 0 (or not given) no authentication
+                       will be done. If ntpdc's key number has not
+                       yet been set (<i>e.g.,</i> by the keyid
+                       command), it will be set to this value.
+                       The <tt>version#</tt> can be 1 through 4 and defaults to 3.  The remaining
+                       options are either a numeric value for <tt>minpoll</tt> or
+                       literals <tt>prefer</tt>, <tt>iburst</tt>, 
+                       <tt>burst</tt>, <tt>minpoll  </tt><i>N</i>,
+                       <tt>keyid </tt><i>N</i>, <tt>version </tt> <i>N</i>, or
+                       <tt>maxpoll  </tt><i>N</i> (where <i>N</i> is a numeric value), and have the action as specified in the
+                       <tt>peer</tt> configuration file command of
+                       ntpd.  See the <a href="confopt.html">Server Options</a> page for further information.
+                       Each flag (or its absence) replaces the
+                       previous setting. The <tt>prefer</tt> keyword indicates a preferred peer (and thus will be used primarily for clock synchronisation if possible). The preferred peer also determines the validity of the PPS signal - if the preferred peer is suitable for synchronisation so is the PPS signal.
+                       <dt><tt>addserver <i>peer_address</i> [
+               <i>keyid</i> ] [ <i>version</i> ] [
+               <tt>minpoll# | prefer | iburst  | burst | minpoll
+               <i>N</i> | <tt>maxpoll</tt> <i>N</i> [...] ]</tt>
+               <dt><tt>addserver <i>peer_address</i> [
+               <tt>prefer | iburst | burst | minpoll
+               <i>N</i> | <tt>maxpoll</tt> <i>N</i> | <tt>keyid</tt>
+                       <i>N</i> | <tt>version</tt> <i>N</i> [...] ]</tt>
+                       <dd>Identical to the addpeer command, except that the operating mode is client.
+                       <dt><tt>broadcast <i>peer_address</i> [
+                       <i>keyid</i> ] [ <i>version</i> ] [ <i>prefer</i> ]</tt>
+                       <dd>Identical to the addpeer command, except
+                       that the operating mode is broadcast. In this
+                       case a valid non-zero key identifier and key are required. The <tt>peer_address</tt> parameter can be the broadcast address of the local network or a multicast group address assigned to NTP. If a multicast address, a multicast-capable kernel is required.
+                       <dt><tt>unconfig <i>peer_address</i> [...]</tt>
+                       <dd>This command causes the configured bit to be removed from the specified peer(s). In many cases this will cause the peer association to be deleted. When appropriate, however, the association may persist in an unconfigured mode if the remote peer is willing to continue on in this fashion.
+                       <dt><tt>fudge <i>peer_address</i> [ <i>time1</i> ] [ <i>time2</i> ] [ <i>stratum</i> ] [ <i>refid</i> ]</tt>
+                       <dd>This command provides a way to set certain data for a reference clock. See the source listing for further information.
+                       <dt><tt>enable [ auth | bclient | calibrate | kernel | monitor | ntp | pps | stats]</tt><br>
+                               <tt>disable [ auth | bclient | calibrate | kernel | monitor | ntp | pps | stats]</tt>
+                       <dd>These commands operate in the same way as the <tt>enable</tt> and <tt>disable</tt> configuration file commands of <tt>ntpd</tt>. See the <a href="miscopt.html">Miscellaneous Options</a> page for further information.
+                       <dt><tt>restrict <i>address mask flag</i> [ <i>flag</i> ]</tt>
+                       <dd>This command operates in the same way as the <tt>restrict</tt> configuration file commands of <tt>ntpd</tt>.
+                       <dt><tt>unrestrict <i>address mask flag</i> [ <i>flag</i> ]</tt>
+                       <dd>Unrestrict the matching entry from the restrict list.
+                       <dt><tt>delrestrict <i>address mask [ ntpport ]</i></tt>
+                       <dd>Delete the matching entry from the restrict list.
+                       <dt><tt>readkeys</tt>
+                       <dd>Causes the current set of authentication keys to be purged and a new set to be obtained by rereading the keys file (which must have been specified in the <tt>ntpd</tt> configuration file). This allows encryption keys to be changed without restarting the server.
+                       <dt><tt>trustedkey <i>keyid</i> [...]</tt>
+                       <dt><tt>untrustedkey <i>keyid</i> [...]</tt>
+                       <dd>These commands operate in the same way as the <tt>trustedkey</tt> and <tt>untrustedkey</tt> configuration file commands of <tt>ntpd</tt>.
+                       <dt><tt>authinfo</tt>
+                       <dd>Returns information concerning the authentication module, including known keys and counts of encryptions and decryptions which have been done.
+                       <dt><tt>traps</tt>
+                       <dd>Display the traps set in the server. See the source listing for further information.
+                       <dt><tt>addtrap [ <i>address</i> [ <i>port</i> ] [ <i>interface</i> ]</tt>
+                       <dd>Set a trap for asynchronous messages. See the source listing for further information.
+                       <dt><tt>clrtrap [ <i>address</i> [ <i>port</i> ] [ <i>interface</i>]</tt>
+                       <dd>Clear a trap for asynchronous messages. See the source listing for further information.
+                       <dt><tt>reset</tt>
+                       <dd>Clear the statistics counters in various modules of the server. See the source listing for further information.
+               </dl>
+               <h4>Bugs</h4>
+               <p><tt>ntpdc</tt> is a crude hack. Much of the information it shows is deadly boring and could only be loved by its implementer. The program was designed so that new (and temporary) features were easy to hack in, at great expense to the program's ease of use. Despite this, the program is occasionally useful.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/ntpdsim.html b/html/ntpdsim.html
new file mode 100644 (file)
index 0000000..31eccf8
--- /dev/null
@@ -0,0 +1,73 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>ntpdsim - Network Time Protocol (NTP) simulator</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3><tt>ntpdsim</tt> - Network Time Protocol (NTP) simulator</h3>
+               <img src="pic/alice47.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>The mushroom knows all the command line options.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">20:07</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="223">Friday, June 16, 2006</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#synop">Synopsis</a><br>
+                       <li class="inline"><a href="#descr">Description</a><br>
+                       <li class="inline"><a href="#cmd">Command Line Oprionts</a>
+                       <li class="inline"><a href="#files">Files</a>
+               </ul>
+               <hr>
+               <h4 id="synop">Synopsis</h4>
+               <tt>ntpdsim [ -B <i>bdly</i> ] [ -C <i>snse</i> ] [ -O <i>clk_time</i> ] [ -S <i>sim_time</i> ] [ -T <i>ferr</i> ] [ -W <i>fsne</i> ] [ -Y </tt><i><tt>ndly</tt></i><tt> ] [ -X </tt><i><tt>pdly</tt></i><tt> ]</tt>
+               <h4 id="descr">Description</h4>
+               <p>The <tt>ntpdsim</tt> program is an adaptation of the <tt>ntpd</tt> operating system daemon. The program operates as a discrete time simulator using specified systematic and random driving sources. It includes all the mitigation and discipline algorithms of the actual daemon, but with the packet I/O and system clock algorithms driven by simulation. Most functions of the real <tt>ntpd</tt> remain intact, including the monitoring, statistics recording, trace and host name resolution features. Further information on the simulator is on the <a href="http://www.eecis.udel.edu/%7emills/ntpsim.html">NTP Discrete Event Simulator</a> page.</p>
+               <p>The simulator is most useful to study NTP behavior in response to time and/or frequency transients under specific conditions of network jitter and oscillator wander. For this purpose the daemon can be driven by pseudorandom jitter and wander sample sequences characteristic of real networks and oscillators. The jitter generator produces samples from a Poisson distribution, while the wander generator produces samples from a Guassian distribution.</p>
+               <p>The easiest way to use this program is to create a <tt>ntpstats</tt> directory, configuration file <tt>ntp.conf</tt> and frequency file <tt>ntp.drift</tt> and test shell <tt>test.sh</tt> in the base directory. The <tt>ntp.drift</tt> file and <tt>ntpstats</tt> directory can be empty to start. The <tt>test.sh</tt> script can contain something like</p>
+               <pre>rm ./ntpstats/*
+ntpdsim -O 0.1 -C .001 -T 400 -W 1 -c ./ntp.conf,
+</pre>
+               <p>which starts the simulator with a time offset 100 ms, network jitter 1 ms, frequency offset 400 PPM and oscillator wander 1 PPM/s. These parameters represent typical conditions with modern workstations on a Ethernet LAN. The ntp.conf file should contain something like</p>
+               <pre>disable kernel
+server pogo
+driftfile ./ntp.drift
+statsdir ./ntpstats/
+filegen loopstats type day enable
+filegen peerstats type day enable
+</pre>
+               <h4 id="cmd">Command Line Options</h4>
+               <dl>
+                       <dt>Note:&nbsp;The NTP&nbsp;development team is moving to the use of a syntax-directed configuration file design. When complete these options will be replaced by a <a href="ntpdsim_new.html">new one</a>. Most of the <tt>ntpd</tt> command line options apply also to <tt>ntpdsim</tt>. In addition, the following command line options apply to <tt>ntpdsim.</tt>
+                       <dt><tt>-B <i>bdly</i></tt>
+                       <dd>Specify beep delay (3600) s.
+                       <dt><tt>-C <i>snse</i></tt>
+                       <dd>Specify network jitter parameter (0) s.
+                       <dt><tt>-O <i>clk_time</i></tt>
+                       <dd>Specify initial time offset (0) s.
+                       <dt><tt>-S <i>sim_time</i></tt>
+                       <dd>Specify simulation duration (86400) s.
+                       <dt><tt>-T <i>ferr</i></tt>
+                       <dd>Specify initial frequency offset (0) PPM.
+                       <dt><tt>-W <i>fnse</i></tt>
+                       <dd>Specify oscillator wander parameter (0) PPM/s.
+                       <dt><tt>-Y <i>ndly</i></tt>
+                       <dd>Specify network propagation delay (.001) s.
+                       <dt><tt>-Z <i>pdly</i></tt>
+                       <dd>Specify server processing delay (.001) s.
+               </dl>
+               <h4 id="files">Files</h4>
+               <tt>/etc/ntp.conf</tt> - the default name of the configuration file<br>
+               <tt>/etc/ntp.drift</tt> - the default name of the drift file<br>
+               <tt>/etc/ntp.keys</tt> - the default name of the key file
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/ntpdsim_new.html b/html/ntpdsim_new.html
new file mode 100644 (file)
index 0000000..47c226a
--- /dev/null
@@ -0,0 +1,102 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>ntpdsim - Network Time Protocol (NTP) simulator</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3><tt>ntpdsim</tt> - Network Time Protocol (NTP) simulator</h3>
+               <img src="pic/alice47.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>The mushroom knows all the command line options.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">21:32</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="223">Friday, June 16, 2006</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links7.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li><a href="#description">Description</a><br>
+                       <li><a href="#configuration">Configuration</a>
+                       <li><a href="#sample">Sample Configuration File</a>
+               </ul>
+               <h4 id="description">Description</h4>
+               <p>The ntpdsim program is used to simulate and study the behavior of an NTP daemon that derives its time from a number of different simulated time sources (servers). Each simulated server can be configured to have a different time offset, frequency offset, propagation delay, processing delay, network jitter and oscillator wander.</p>
+               <p>The ntpdsim program runs all the same selection, mitigation, and discipline algorithms as the actual ntpd daemon at the client. (It actually uses the same code). However, the input/output routines and servers are simulated. That is, instead of sending the client messages over the network to the actual servers, the client messages are intercepted by the ntpdsim program, which then generates the replies to those messages. The reply messages are carefully "inserted" into the input queue of the client at the right time according to the specified server properties (like propagation delay).</p>
+               <p>Each simulated server runs according to a specified script that describes the server properties at a particular time. Each script consists of a series of consecutive acts. Each act runs for a particular duration and specifies the frequency offset, propagation delay, processing delay, network jitter and oscillator wander of the server for that duration. Once the duration of an act expires, the simulated server reconfigures itself according to the properties specified in the next act.</p>
+               <h4 id="configuration">Configuration</h4>
+               <p>The ntpdsim program is configured by providing a configuration file at startup. The crux of the simulator configuration is specified using a <tt>simulate</tt> command, the syntax of which is given below. Note that all time quantities are in seconds and all frequency quantities are in parts per million (PPM):</p>
+               <p>&lt;<i>simulate_command</i>&gt; ::= <tt>simulate</tt> { &lt;<i>init_statement_list</i>&gt; &lt;<i>server_list</i>&gt; }<br>
+               &lt;<i>init_statement_list</i>&gt; ::= &lt;init_statement_list&gt; &lt;init_statement&gt; | &lt;init_statement&gt;<br>
+               &lt;<i>init_statement</i>&gt; ::= <tt>beep_delay</tt> = &lt;number&gt; | <tt>simulation_duration</tt> = &lt;number&gt;<br>
+               &lt;<i>server_list</i>&gt; ::= &lt;<i>server_list</i>&gt; &lt;server&gt; | &lt;server&gt;<br>
+               &lt;<i>server_list</i>&gt; ::= <tt>server</tt> = &lt;address&gt; { <tt>server_offset</tt> = &lt;number&gt; &lt;act_list&gt; }<br>
+               &lt;<i>act_list</i>&gt; ::= &lt;<i>act_list</i>&gt; &lt;<i>act</i>&gt; | &lt;<i>act</i>&gt;<br>
+               &lt;<i>act</i>&gt; ::= <tt>duration</tt> = &lt;number&gt; { &lt;<i>act_stmt_list</i>&gt; }<br>
+               &lt;<i>act_stmt_list</i>&gt; ::= &lt;<i>act_stmt_list</i>&gt; &lt;<i>act_stmt</i>&gt; | &lt;<i>act_stmt</i>&gt;<br>
+               &lt;<i>act_stmt</i>&gt; ::= <tt>freq_offset</tt> = &lt;number&gt; | <tt>wander</tt> = &lt;number&gt; | <tt>jitter</tt> = &lt;number&gt; | <tt>prop_delay</tt> = &lt;number&gt; | <tt>proc_delay</tt> = &lt;number&gt;</p>
+               <p>In addition to the simulate command, other standard NTP configuration commands can be specified. These commands have the same meaning as in the ntpd configuration. Note that newlines are <b>not</b> significant within the simulate command even though they are used to mark the end of a normal NTP configuration command.</p>
+               <h4 id="sample">Sample Configuration File</h4>
+               <p>A sample ntpdsim configuration file is given below. It specifies two simulated servers, each of which has two acts.</p>
+       <pre>
+    # Client configuration 
+    disable kernel
+    server pogo
+    driftfile ./ntp.drift
+    statsdir ./ntpstats/
+    filegen loopstats type day enable
+    filegen peerstats type day enable
+
+    # Simulation configuration
+    simulate {
+        simulation_duration = 86400
+        beep_delay = 3600
+
+        # Server 1
+       server = louie.udel.edu {
+           server_offset = 0 
+            duration = 50000 {
+               freq_offset = 400
+               wander = 1.0
+               jitter = 0.001
+               prop_delay = 0.001
+               proc_delay = 0.001
+           }
+            duration = 6400 {
+               freq_offset = 200
+               wander = 1.0
+               jitter = 0.001
+               prop_delay = 0.001
+               proc_delay = 0.001
+           }
+       }
+
+        # Server 2
+       server = baldwin.udel.edu {
+           server_offset = 0.02
+           duration = 10000 {
+               freq_offset = 400
+               wander = 1.0
+               jitter = 0.001
+               prop_delay = 0.5
+               proc_delay = 0.001
+           }
+           duration = 60000 {
+               freq_offset = 200
+               wander = 1.0
+               jitter = 0.05
+               prop_delay = 0.005
+               proc_delay = 0.001
+           }
+       }
+    }
+  </pre>
+               <hr>
+               <address><a href="mailto:skamboj@udel.edu">Sachin Kamboj</a></address>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
diff --git a/html/ntpq.html b/html/ntpq.html
new file mode 100644 (file)
index 0000000..4c077e2
--- /dev/null
@@ -0,0 +1,264 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>ntpq - standard NTP query program</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3><tt>ntpq</tt> - standard NTP query program</h3>
+               <img src="pic/bustardfly.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+               <p>A typical NTP monitoring packet</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:45</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>More Help</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links12.txt"></script>
+               <hr>
+               <h4>Synopsis</h4>
+               <tt>ntpq [-inp] [-c <i>command</i>] [<i>host</i>] [...]</tt>
+               <h4>Description</h4>
+               <p>The <tt>ntpq</tt> utility program is used to monitor NTP daemon <tt>ntpd</tt> operations and determine performance. It uses the standard NTP mode 6 control message formats defined in Appendix B of the NTPv3 specification RFC1305. The same formats are used in NTPv4, although some of the variables have changed and new ones added. The description on this page is for the NTPv4 variables.</p>
+               <p>The program can be run either in interactive mode or controlled using command line arguments. Requests to read and write arbitrary variables can be assembled, with raw and pretty-printed output options being available. The <tt>ntpq</tt> can also obtain and print a list of peers in a common format by sending multiple queries to the server.</p>
+               <p>If one or more request options is included on the command line when <tt>ntpq</tt> is executed, each of the requests will be sent to the NTP servers running on each of the hosts given as command line arguments, or on localhost by default. If no request options are given, <tt>ntpq</tt> will attempt to read commands from the standard input and execute these on the NTP server running on the first host given on the command line, again defaulting to localhost when no other host is specified. <tt>ntpq</tt>will prompt for commands if the standard input is a terminal device.</p>
+               <p><tt>ntpq</tt> uses NTP mode 6 packets to communicate with the NTP server, and hence can be used to query any compatible server on the network which permits it. Note that since NTP is a UDP protocol this communication will be somewhat unreliable, especially over large distances in terms of network topology. <tt>ntpq</tt> makes one attempt to retransmit requests, and will time requests out if the remote host is not heard from within a suitable timeout time.</p>
+               <p>Note that in contexts where a host name is expected, a <tt>-4</tt> qualifier preceding the host name forces DNS resolution to the IPv4 namespace, while a <tt>-6</tt> qualifier forces DNS resolution to the IPv6 namespace.</p>
+               <p>For examples and usage, see the <a href="debug.html">NTP Debugging Techniques</a> page.</p>
+               <p>Command line options are described following. Specifying a command line option other than <tt>-i</tt> or <tt>-n</tt> will cause the specified query (queries) to be sent to the indicated host(s) immediately. Otherwise, <tt>ntpq</tt> will attempt to read interactive format commands from the standard input.</p>
+               <dl>
+                       <dt><tt>-4</tt>
+                       <dd>Force DNS resolution of following host names on the command line to the IPv4 namespace.
+                       <dt><tt>-6</tt>
+                       <dd>Force DNS resolution of following host names on the command line to the IPv6 namespace.
+                       <dt><tt>-c</tt>
+                       <dd>The following argument is interpreted as an interactive format command and is added to the list of commands to be executed on the specified host(s). Multiple <tt>-c</tt> options may be given.
+                       <dt><tt>-d</tt>
+                       <dd>Turn on debugging mode.
+                       <dt><tt>-i</tt>
+                       <dd>Force <tt>ntpq</tt> to operate in interactive mode. Prompts will be written to the standard output and commands read from the standard input.
+                       <dt><tt>-n</tt>
+                       <dd>Output all host addresses in dotted-quad numeric format rather than converting to the canonical host names.
+                       <dt><tt>-p</tt>
+                       <dd>Print a list of the peers known to the server as well as a summary of their state. This is equivalent to the <tt>peers</tt> interactive command.
+               </dl>
+               <h4>Internal Commands</h4>
+               <p>Interactive format commands consist of a keyword followed by zero to four arguments. Only enough characters of the full keyword to uniquely identify the command need be typed. The output of a command is normally sent to the standard output, but optionally the output of individual commands may be sent to a file by appending a <tt>&gt;</tt>, followed by a file name, to the command line. A number of interactive format commands are executed entirely within the <tt>ntpq</tt> program itself and do not result in NTP mode 6 requests being sent to a server. These are described following.</p>
+               <dl>
+                       <dt><tt>? [<i>command_keyword</i>]</tt><br>
+                               <tt>helpl [<i>command_keyword</i>]</tt>
+                       <dd>A <tt>?</tt> by itself will print a list of all the command keywords known to this incarnation of <tt>ntpq</tt>. A <tt>?</tt> followed by a command keyword will print function and usage information about the command. This command is probably a better source of information about <tt>ntpq</tt> than this manual page.
+                       <dt><tt>addvars <i>variable_name</i> [ = <i>value</i>] [...]</tt><br>
+                               <tt>rmvars <i>variable_name</i> [...]</tt><br>
+                               <tt>clearvars</tt>
+                       <dd>The data carried by NTP mode 6 messages consists of a list of items of the form <tt><i>variable_name</i> = <i>value</i></tt>, where the <tt>= <i>value</i></tt> is ignored, and can be omitted, in requests to the server to read variables. <tt>ntpq</tt> maintains an internal list in which data to be included in control messages can be assembled, and sent using the <tt>readlist</tt> and <tt>writelist</tt> commands described below. The <tt>addvars</tt> command allows variables and their optional values to be added to the list. If more than one variable is to be added, the list should be comma-separated and not contain white space. The <tt>rmvars</tt> command can be used to remove individual variables from the list, while the <tt>clearlist</tt> command removes all variables from the list.
+                       <dt><tt>cooked</tt>
+                       <dd>Causes output from query commands to be &quot;cooked&quot;, so that variables which are recognized by <tt>ntpq</tt> will have their values reformatted for human consumption. Variables which <tt>ntpq</tt> thinks should have a decodable value but didn't are marked with a trailing <tt>?</tt>.
+                       <dt><tt>debug more | less | off</tt>
+                       <dd>Turns internal query program debugging on and off.
+                       <dt><tt>delay <i>milliseconds</i></tt>
+                       <dd>Specify a time interval to be added to timestamps included in requests which require authentication. This is used to enable (unreliable) server reconfiguration over long delay network paths or between machines whose clocks are unsynchronized. Actually the server does not now require timestamps in authenticated requests, so this command may be obsolete.
+                       <dt><tt>host <i>hostname</i></tt>
+                       <dd>Set the host to which future queries will be sent. Hostname may be either a host name or a numeric address.
+                       <dt><tt>hostnames [yes | no]</tt>
+                       <dd>If <tt>yes</tt> is specified, host names are printed in information displays. If <tt>no</tt> is specified, numeric addresses are printed instead. The default is <tt>yes</tt>, unless modified using the command line <tt>-n</tt> switch.
+                       <dt><tt>keyid <i>keyid</i></tt>
+                       <dd>This command specifies the key number to be used to authenticate configuration requests. This must correspond to a key number the server has been configured to use for this purpose.
+                       <dt><tt>ntpversion 1 | 2 | 3 | 4</tt>
+                       <dd>Sets the NTP version number which <tt>ntpq</tt> claims in packets. Defaults to 2, Note that mode 6 control messages (and modes, for that matter) didn't exist in NTP version 1.
+                       <dt><tt>passwd</tt>
+                       <dd>This command prompts for a password (which will not be echoed) which will be used to authenticate configuration requests. The password must correspond to the key configured for NTP server for this purpose.
+                       <dt><tt>quit</tt>
+                       <dd>Exit <tt>ntpq</tt>.
+                       <dt><tt>raw</tt>
+                       <dd>Causes all output from query commands is printed as received from the remote server. The only formating/interpretation done on the data is to transform nonascii data into a printable (but barely understandable) form.
+                       <dt><tt>timeout <i>millseconds</i></tt>
+                       <dd>Specify a timeout period for responses to server queries. The default is about 5000 milliseconds. Note that since <tt>ntpq</tt> retries each query once after a timeout, the total waiting time for a timeout will be twice the timeout value set.
+               </dl>
+               <h4>Control Message Commands</h4>
+               <p>Each association known to an NTP server has a 16 bit integer association identifier. NTP control messages which carry peer variables must identify the peer the values correspond to by including its association ID. An association ID of 0 is special, and indicates the variables are system variables, whose names are drawn from a separate name space.</p>
+               <p>Control message commands result in one or more NTP mode 6 messages being sent to the server, and cause the data returned to be printed in some format. Most commands currently implemented send a single message and expect a single response. The current exceptions are the peers command, which will send a preprogrammed series of messages to obtain the data it needs, and the mreadlist and mreadvar commands, which will iterate over a range of associations.</p>
+               <dl>
+                       <dt><tt>associations</tt>
+                       <dd>Obtains and prints a list of association identifiers and peer statuses for in-spec peers of the server being queried. The list is printed in columns. The first of these is an index numbering the associations from 1 for internal use, the second the actual association identifier returned by the server and the third the status word for the peer. This is followed by a number of columns containing data decoded from the status word. See the peers command for a decode of the <tt>condition</tt> field. Note that the data returned by the <tt>associations</tt> command is cached internally in <tt>ntpq</tt>. The index is then of use when dealing with stupid servers which use association identifiers which are hard for humans to type, in that for any subsequent commands which require an association identifier as an argument, the form &amp;index may be used as an alternative.
+                       <dt><tt>clockvar [<i>assocID</i>] [<i>variable_name</i> [ = <i>value</i> [...]] [...]</tt>
+                       <dt><tt>cv [<i>assocID</i>] [<i>variable_name</i> [ = <i>value</i> [...] ][...]</tt>
+                       <dd>Requests that a list of the server's clock variables be sent. Servers which have a radio clock or other external synchronization will respond positively to this. If the association identifier is omitted or zero the request is for the variables of the <tt>system clock</tt> and will generally get a positive response from all servers with a clock. If the server treats clocks as pseudo-peers, and hence can possibly have more than one clock connected at once, referencing the appropriate peer association ID will show the variables of a particular clock. Omitting the variable list will cause the server to return a default variable display.
+                       <dt><tt>lassociations</tt>
+                       <dd>Obtains and prints a list of association identifiers and peer statuses for all associations for which the server is maintaining state. This command differs from the <tt>associations</tt> command only for servers which retain state for out-of-spec client associations (i.e., fuzzballs). Such associations are normally omitted from the display when the <tt>associations</tt> command is used, but are included in the output of <tt>lassociations</tt>.
+                       <dt><tt>lpassociations</tt>
+                       <dd>Print data for all associations, including out-of-spec client associations, from the internally cached list of associations. This command differs from <tt>passociations</tt> only when dealing with fuzzballs.
+                       <dt><tt>lpeers</tt>
+                       <dd>Like R peers, except a summary of all associations for which the server is maintaining state is printed. This can produce a much longer list of peers from fuzzball servers.
+                       <dt><tt>mreadlist <i>assocID</i> <i>assocID</i></tt><br>
+                               <tt>mrl <i>assocID</i> <i>assocID</i></tt>
+                       <dd>Like the <tt>readlist</tt> command, except the query is done for each of a range of (nonzero) association IDs. This range is determined from the association list cached by the most recent <tt>associations</tt> command.
+                       <dt><tt>mreadvar <i>assocID</i> <i>assocID</i> [ <i>variable_name</i> [ = <i>value</i>[ ... ]</tt><br>
+                               <tt>mrv <i>assocID</i> <i>assocID</i> [ <i>variable_name</i> [ = <i>value</i>[ ... ]</tt>
+                       <dd>Like the <tt>readvar</tt> command, except the query is done for each of a range of (nonzero) association IDs. This range is determined from the association list cached by the most recent <tt>associations</tt> command.
+                       <dt><tt>opeers</tt>
+                       <dd>An old form of the <tt>peers</tt> command with the reference ID replaced by the local interface address.
+                       <dt><tt>passociations</tt>
+                       <dd>Displays association data concerning in-spec peers from the internally cached list of associations. This command performs identically to the <tt>associations</tt> except that it displays the internally stored data rather than making a new query.
+                       <dt><tt>peers</tt>
+                       <dd>Obtains a current list peers of the server, along with a summary of each peer's state. Summary information includes the address of the remote peer, the reference ID (0.0.0.0 if this is unknown), the stratum of the remote peer, the type of the peer (local, unicast, multicast or broadcast), when the last packet was received, the polling interval, in seconds, the reachability register, in octal, and the current estimated delay, offset and dispersion of the peer, all in milliseconds. The character at the left margin of each line shows the synchronization status of the association and is a valuable diagnostic tool. The encoding and meaning of this character, called the tally code, is given later in this page.
+                       <dt><tt>pstatus <i>assocID</i></tt>
+                       <dd>Sends a read status request to the server for the given association. The names and values of the peer variables returned will be printed. Note that the status word from the header is displayed preceding the variables, both in hexadecimal and in pidgeon English.
+                       <dt><tt>readlist [ <i>assocID</i> ]</tt><br>
+                               <tt>rl [ <i>assocID</i> ]</tt>
+                       <dd>Requests that the values of the variables in the internal variable list be returned by the server. If the association ID is omitted or is 0 the variables are assumed to be system variables. Otherwise they are treated as peer variables. If the internal variable list is empty a request is sent without data, which should induce the remote server to return a default display.
+                       <dt><tt>readvar <i>assocID</i> <i>variable_name</i> [ = <i>value</i> ] [ ...]</tt><br>
+                               <tt>rv <i>assocID</i> [ <i>variable_name</i> [ = <i>value</i> ] [...]</tt>
+                       <dd>Requests that the values of the specified variables be returned by the server by sending a read variables request. If the association ID is omitted or is given as zero the variables are system variables, otherwise they are peer variables and the values returned will be those of the corresponding peer. Omitting the variable list will send a request with no data which should induce the server to return a default display. The encoding and meaning of the variables derived from NTPv3 is given in RFC-1305; the encoding and meaning of the additional NTPv4 variables are given later in this page.
+                       <dt><tt>writevar <i>assocID</i> <i>variable_name</i> [ = <i>value</i> [ ...]</tt>
+                       <dd>Like the readvar request, except the specified variables are written instead of read.
+                       <dt><tt>writelist [ <i>assocID</i> ]</tt>
+                       <dd>Like the readlist request, except the internal list variables are written instead of read.
+               </dl>
+               <h4>Tally Codes</h4>
+               <p>The character in the left margin in the <tt>peers</tt> billboard, called the tally code, shows the fate of each association in the clock selection process. Following is a list of these characters, the pigeon used in the <tt>rv</tt> command, and a short explanation of the condition revealed.</p>
+               <dl>
+                       <dt><tt>space reject</tt>
+                       <dd>The peer is discarded as unreachable, synchronized to this server (synch loop) or outrageous synchronization distance.
+                       <dt><tt>x&nbsp;&nbsp;falsetick</tt>
+                       <dd>The peer is discarded by the intersection algorithm as a falseticker.
+                       <dt><tt>.&nbsp;&nbsp;excess</tt>
+                       <dd>The peer is discarded as not among the first ten peers sorted by synchronization distance and so is probably a poor candidate for further consideration.
+                       <dt><tt>-&nbsp;&nbsp;outlyer</tt>
+                       <dd>The peer is discarded by the clustering algorithm as an outlyer.
+                       <dt><tt>+&nbsp;&nbsp;candidat</tt>
+                       <dd>The peer is a survivor and a candidate for the combining algorithm.
+                       <dt><tt>#&nbsp;&nbsp;selected</tt>
+                       <dd>The peer is a survivor, but not among the first six peers sorted by synchronization distance. If the association is ephemeral, it may be demobilized to conserve resources.
+                       <dt><tt>*&nbsp;&nbsp;sys.peer</tt>
+                       <dd>The peer has been declared the system peer and lends its variables to the system variables.
+                       <dt><tt>o&nbsp;&nbsp;pps.peer</tt>
+                       <dd>The peer has been declared the system peer and lends its variables to thesystem variables. However, the actual system synchronization is derived from a pulse-per-second (PPS) signal, either indirectly via the PPS reference clock driver or directly via kernel interface.
+               </dl>
+               <h4>System Variables</h4>
+               <p>The <tt>status, leap, stratum, precision, rootdelay, rootdispersion, refid, reftime, poll, offset, and frequency</tt> variables are described in RFC-1305 specification. Additional NTPv4 system variables include the following.</p>
+               <dl>
+                       <dt><tt>version</tt>
+                       <dd>Everything you might need to know about the software version and generation time.
+                       <dt><tt>processor</tt>
+                       <dd>The processor and kernel identification string.
+                       <dt><tt>system</tt>
+                       <dd>The operating system version and release identifier.
+                       <dt><tt>state</tt>
+                       <dd>The state of the clock discipline state machine. The values are described in the architecture briefing on the NTP Project page linked from www.ntp.org.
+                       <dt><tt>peer</tt>
+                       <dd>The internal integer used to identify the association currently designated the system peer.
+                       <dt><tt>jitter</tt>
+                       <dd>The estimated time error of the system clock measured as an exponential average of RMS time differences.
+                       <dt><tt>stability</tt>
+                       <dd>The estimated frequency stability of the system clock measured as an exponential average of RMS frequency differences.
+               </dl>
+               <p>When the NTPv4 daemon is compiled with the OpenSSL software library, additional system variables are displayed, including some or all of the following, depending on the particular dance:</p>
+               <dl>
+                       <dt><tt>flags</tt>
+                       <dd>The current flags word bits and message digest algorithm identifier (NID) in hex format. The high order 16 bits of the four-byte word contain the NID from the OpenSSL ligrary, while the low-order bits are interpreted as follows:
+                       <dd>
+                               <dl>
+                                       <dt><tt>0x01</tt>
+                                       <dd>autokey enabled
+                                       <dt><tt>0x02</tt>
+                                       <dd>NIST leapseconds file loaded
+                                       <dt><tt>0x10</tt>
+                                       <dd>PC identity scheme
+                                       <dt><tt>0x20</tt>
+                                       <dd>IFF identity scheme
+                                       <dt><tt>0x40</tt>
+                                       <dd>GQ identity scheme
+                               </dl>
+                       <dt><tt>hostname</tt>
+                       <dd>The name of the host as returned by the Unix <tt>gethostname()</tt> library function.
+                       <dt><tt>hostkey</tt>
+                       <dd>The NTP filestamp of the host key file.
+                       <dt><tt>cert</tt>
+                       <dd>A list of certificates held by the host. Each entry includes the subject, issuer, flags and NTP filestamp in order. The bits are interpreted as follows:
+                       <dd>
+                               <dl>
+                                       <dt><tt>0x01</tt>
+                                       <dd>certificate has been signed by the server
+                                       <dt><tt>0x02</tt>
+                                       <dd>certificate is trusted
+                                       <dt><tt>0x04</tt>
+                                       <dd>certificate is private
+                                       <dt><tt>0x08</tt>
+                                       <dd>certificate contains errors and should not be trusted
+                               </dl>
+                       <dt><tt>leapseconds</tt>
+                       <dd>The NTP filestamp of the NIST leapseconds file.
+                       <dt><tt>refresh</tt>
+                       <dd>The NTP timestamp when the host public cryptographic values were refreshed and signed.
+                       <dt><tt>signature</tt>
+                       <dd>The host digest/signature scheme name from the OpenSSL library.
+                       <dt><tt>tai</tt>
+                       <dd>The TAI-UTC offset in seconds obtained from the NIST leapseconds table.
+               </dl>
+               <h4>Peer Variables</h4>
+               <p>The <tt>status, srcadr, srcport, dstadr, dstport, leap, stratum, precision, rootdelay, rootdispersion, readh, hmode, pmode, hpoll, ppoll, offset, delay, dspersion, reftime</tt> variables are described in the RFC-1305 specification, as are the timestamps <tt>org, rec and xmt</tt>. Additional NTPv4 system variables include the following.</p>
+               <dl>
+                       <dt><tt>flash</tt>
+                       <dd>The flash code for the most recent packet received. The encoding and meaning of these codes is given later in this page.
+                       <dt><tt>jitter</tt>
+                       <dd>The estimated time error of the peer clock measured as an exponential average of RMS time differences.
+                       <dt><tt>unreach</tt>
+                       <dd>The value of the counter which records the number of poll intervals since the last valid packet was received.
+               </dl>
+               <p>When the NTPv4 daemon is compiled with the OpenSSL software library, additional peer variables are displayed, including the following:</p>
+               <dl>
+                       <dt><tt>flags</tt>
+                       <dd>The current flag bits. This word is the server host status word with additional bits used by the Autokey state machine. See the source code for the bit encoding.
+                       <dt><tt>hostname</tt>
+                       <dd>The server host name.
+                       <dt><tt>initkey <i>key</i></tt>
+                       <dd>The initial key used by the key list generator in the Autokey protocol.
+                       <dt><tt>initsequence <i>index</i></tt>
+                       <dd>The initial index used by the key list generator in the Autokey protocol.
+                       <dt><tt>signature</tt>
+                       <dd>The server message digest/signature scheme name from the OpenSSL software library.
+                       <dt><tt>timestamp <i>time</i></tt>
+                       <dd>The NTP timestamp when the last Autokey key list was generated and signed.
+               </dl>
+               <h4>Flash Codes</h4>
+               <p>The <tt>flash</tt> code is a valuable debugging aid displayed in the peer variables list. It shows the results of the original sanity checks defined in the NTP specification RFC-1305 and additional ones added in NTPv4. There are 12 tests designated <tt>TEST1</tt> through <tt>TEST12</tt>. The tests are performed in a certain order designed to gain maximum diagnostic information while protecting against accidental or malicious errors. The <tt>flash</tt> variable is initialized to zero as each packet is received. If after each set of tests one or more bits are set, the packet is discarded.</p>
+               <p>Tests <tt>TEST1</tt> through <tt>TEST3</tt> check the packet timestamps from which the offset and delay are calculated. If any bits are set, the packet is discarded; otherwise, the packet header variables are saved. <tt>TEST4</tt> and <tt>TEST5</tt> are associated with access control and cryptographic authentication. If any bits are set, the packet is discarded immediately with nothing changed.</p>
+               <p>Tests <tt>TEST6</tt> through <tt>TEST8</tt> check the health of the server. If any bits are set, the packet is discarded; otherwise, the offset and delay relative to the server are calculated and saved. <tt>TEST9</tt> checks the health of the association itself. If any bits are set, the packet is discarded; otherwise, the saved variables are passed to the clock filter and mitigation algorithms.</p>
+               <p>Tests <tt>TEST10</tt> through <tt>TEST12</tt> check the authentication state using Autokey public-key cryptography, as described in the <a href="authopt.html">Authentication Options</a> page. If any bits are set and the association has previously been marked reachable, the packet is discarded; otherwise, the originate and receive timestamps are saved, as required by the NTP protocol, and processing continues.</p>
+               <p>The <tt>flash</tt> bits for each test are defined as follows.</p>
+               <dl>
+                       <dt><tt>0x001 TEST1</tt>
+                       <dd>Duplicate packet. The packet is at best a casual retransmission and at worst a malicious replay.
+                       <dt><tt>0x002 TEST2</tt>
+                       <dd>Bogus packet. The packet is not a reply to a message previously sent. This can happen when the NTP daemon is restarted and before somebody else notices.
+                       <dt><tt>0x004 TEST3</tt>
+                       <dd>Unsynchronized. One or more timestamp fields are invalid. This normally happens when the first packet from a peer is received.
+                       <dt><tt>0x008 TEST4</tt>
+                       <dd>Access is denied. See the <a href="accopt.html">Access Control Options</a> page.
+                       <dt><tt>0x010 TEST5</tt>
+                       <dd>Cryptographic authentication fails. See the <a href="authopt.html">Authentication Options</a> page.
+                       <dt><tt>0x020TEST6</tt>
+                       <dd>The server is unsynchronized. Wind up its clock first.
+                       <dt><tt>0x040 TEST7</tt>
+                       <dd>The server stratum is at the maximum than 15. It is probably unsynchronized and its clock needs to be wound up.
+                       <dt><tt>0x080 TEST8</tt>
+                       <dd>Either the root delay or dispersion is greater than one second, which is highly unlikely unless the peer is unsynchronized to Mars.
+                       <dt><tt>0x100 TEST9</tt>
+                       <dd>Either the peer delay or dispersion is greater than one second, which is higly unlikely unless the peer is on Mars.
+                       <dt><tt>0x200 TEST10</tt>
+                       <dd>The autokey protocol has detected an authentication failure. See the <a href="authopt.html">Authentication Options</a> page.
+                       <dt><tt>0x400 TEST11</tt>
+                       <dd>The autokey protocol has not verified the server or peer is proventic and has valid public key credentials. See the <a href="authopt.html">Authentication Options</a> page.
+                       <dt><tt>0x800 TEST12</tt>
+                       <dd>A protocol or configuration error has occurred in the public key algorithms or a possible intrusion event has been detected. See the <a href="authopt.html">Authentication Options</a> page.
+               </dl>
+               <h4>Bugs</h4>
+               <p>The peers command is non-atomic and may occasionally result in spurious error messages about invalid associations occurring and terminating the command. The timeout time is a fixed constant, which means you wait a long time for timeouts since it assumes sort of a worst case. The program should improve the timeout estimate as it sends queries to a particular host, but doesn't.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/ntptime.html b/html/ntptime.html
new file mode 100644 (file)
index 0000000..a9ea33b
--- /dev/null
@@ -0,0 +1,48 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>ntptime - read kernel time variables</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3><tt>ntptime</tt> - read kernel time variables</h3>
+               <img src="pic/pogo5.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Pogo</i>, Walt Kelly</a>
+               <p>The turtle has been swimming in the kernel.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:46</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <hr>
+               <h4>Synopsis</h4>
+               <tt>ntptime [ -chr ] [ -e <i>est_error</i> ] [ -f <i>frequency</i> ] [ -m <i>max_error</i> ] [ -o <i>offset</i> ] [ -s <i>status</i> ] [ -t <i>time_constant</i>]</tt>
+               <h4>Description</h4>
+               <p>This program is useful only with special kernels described in the <a href="kern.html">A Kernel Model for Precision Timekeeping</a> page. It reads and displays time-related kernel variables using the <tt>ntp_gettime()</tt> system call. A similar display can be obtained using the <tt>ntpdc</tt> program and <tt>kerninfo</tt> command.</p>
+               <h4>Options</h4>
+               <dl>
+                       <dt><tt>-c</tt>
+                       <dd>Display the execution time of <tt>ntptime</tt> itself.
+                       <dt><tt>-e <i>est_error</i></tt>
+                       <dd>Specify estimated error, in microseconds.
+                       <dt><tt>-f <i>frequency</i></tt>
+                       <dd>Specify frequency offset, in parts per million.
+                       <dt><tt>-h</tt>
+                       <dd>Display help information.
+                       <dt><tt>-m <i>max_error</i></tt>
+                       <dd>Specify max possible errors, in microseconds.
+                       <dt><tt>-o <i>offset</i></tt>
+                       <dd>Specify clock offset, in microseconds.
+                       <dt><tt>-r</tt>
+                       <dd>Display Unix and NTP times in raw format.
+                       <dt><tt>-s <i>status</i></tt>
+                       <dd>Specify clock status. Better know what you are doing.
+                       <dt><tt>-t <i>time_constant</i></tt>
+                       <dd>Specify time constant, an integer in the range 0-10.
+               </dl>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/ntptrace.html b/html/ntptrace.html
new file mode 100644 (file)
index 0000000..3b533f9
--- /dev/null
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>ntptrace - trace a chain of NTP servers back to the primary source</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3><tt>ntptrace</tt> - trace a chain of NTP servers back to the primary source</h3>
+               <img src="pic/alice13.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>The rabbit knows the way back.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:47</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <hr>
+               <h4>Synopsis</h4>
+               <tt>ntptrace [ -vdn ] [ -r <i>retries</i> ] [ -t <i>timeout</i> ] [ <i>server</i> ]</tt>
+               <h4>Description</h4>
+               <p><tt>ntptrace</tt> determines where a given Network Time Protocol (NTP) server gets its time from, and follows the chain of NTP servers back to their master time source. If given no arguments, it starts with <tt>localhost</tt>. Here is an example of the output from <tt>ntptrace</tt>:</p>
+               <pre>
+% ntptrace
+localhost: stratum 4, offset 0.0019529, synch distance 0.144135
+server2ozo.com: stratum 2, offset 0.0124263, synch distance 0.115784
+usndh.edu: stratum 1, offset 0.0019298, synch distance 0.011993, refid 'WWVB'
+</pre>
+               <p>On each line, the fields are (left to right): the host name, the host stratum, the time offset between that host and the local host (as measured by <tt>ntptrace</tt>; this is why it is not always zero for &quot;<tt>localhost</tt>&quot;), the host synchronization distance, and (only for stratum-1 servers) the reference clock ID. All times are given in seconds. Note that the stratum is the server hop count to the primary source, while the synchronization distance is the estimated error relative to the primary source. These terms are precisely defined in RFC-1305.</p>
+               <h4>Options</h4>
+               <dl>
+                       <dt><tt>-d</tt>
+                       <dd>Turns on some debugging output.
+                       <dt><tt>-n</tt>
+                       <dd>Turns off the printing of host names; instead, host IP addresses are given. This may be useful if a nameserver is down.
+                       <dt><tt>-r <i>retries</i></tt>
+                       <dd>Sets the number of retransmission attempts for each host (default = 5).
+                       <dt><tt>-t <i>timeout</i></tt>
+                       <dd>Sets the retransmission timeout (in seconds) (default = 2).
+                       <dt><tt>-v</tt>
+                       <dd>Prints verbose information about the NTP servers.
+               </dl>
+               <h4>Bugs</h4>
+               <p>This program makes no attempt to improve accuracy by doing multiple samples.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/parsedata.html b/html/parsedata.html
new file mode 100644 (file)
index 0000000..301d8e7
--- /dev/null
@@ -0,0 +1,349 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>NTP PARSE clock data formats</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>NTP PARSE clock data formats</h3>
+               <p>The parse driver currently supports several clocks with different query mechanisms. In order for you to find a sample that might be similar to a clock you might want to integrate into parse I'll sum up the major features of the clocks (this information is distributed in the parse/clk_*.c and ntpd/refclock_parse.c files).</p>
+               <hr>
+               <h4>Meinberg clocks</h4>
+               <pre>
+Meinberg: start=&lt;STX&gt;, end=&lt;ETX&gt;, sync on start
+      pattern=&quot;\2D:  .  .  ;T: ;U:  .  .  ;    \3&quot;
+      pattern=&quot;\2  .  .  ;  ;   :  :  ;        \3&quot;
+      pattern=&quot;\2  .  .  ;  ;   :  :  ;    :  ;        ;   .         .       &quot;
+</pre>
+               <p>Meinberg is a German manufacturer of time code receivers. Those clocks have a pretty common output format in the stock version. In order to support NTP Meinberg was so kind to produce some special versions of the firmware for the use with NTP. So, if you are going to use a Meinberg clock please ask whether there is a special Uni Erlangen version. You can reach <a href="http://www.meinberg.de/">Meinberg</a> via the Web. Information can also be ordered via eMail from <a href="mailto:%20info@meinberg.de">info@meinberg.de</a></p>
+               <p>General characteristics:<br>
+                       Meinberg clocks primarily output pulse per second and a describing ASCII string. This string can be produced in two modes: either upon the reception of a question mark or every second. NTP uses the latter mechanism. DCF77 AM clocks have a limited accuracy of a few milliseconds. The DCF77 PZF5xx variants provide higher accuracy and have a pretty good relationship between RS232 time code and the PPS signal. Except for early versions of the old GPS166 receiver type, Meinberg GPS receivers have a very good timing relationship between the datagram and the pulse. The beginning of the start bit of the first character has basically the same accuracy as the PPS signal, plus a jitter of up to 1 bit time depending on the selected baud rate, i.e. 52 &mu;s @ 19200. PPS support should always be used, if possible, in order to yield the highest possible accuracy.</p>
+               <p>The preferred tty setting for Meinberg DCF77 receivers is 9600/7E2:</p>
+               <pre>
+               CFLAG           (B9600|CS7|PARENB|CREAD|HUPCL)
+               IFLAG           (IGNBRK|IGNPAR|ISTRIP)
+               OFLAG           0
+               LFLAG           0
+        </pre>
+               <p>The tty setting for Meinberg GPS16x/17x receivers is 19200/8N1:</p>
+               <pre>
+               CFLAG           (B19200|CS8|PARENB|CREAD|HUPCL)
+               IFLAG           (IGNBRK|IGNPAR|ISTRIP)
+               OFLAG           0
+               LFLAG           0
+        </pre>
+               <p>All clocks should be run at datagram once per second.<br><br></p>
+               <p>Format of the Meinberg standard time string:</p>
+<pre>
+        <b><i>&lt;STX&gt;</i>D:<i>dd.mm.yy</i>;T:<i>w</i>;U:<i>hh.mm.ss</i>;<i>uvxy</i><i>&lt;ETX&gt;</i></b>
+    pos:  0  000000001111111111222222222233  3
+          1  234567890123456789012345678901  2
+
+    <i>&lt;STX&gt;</i>         = start-of-text, ASCII code 0x02
+    <i>dd.mm.yy</i>      = day of month, month, year of the century, separated by dots
+    <i>w</i>             = day of week (1..7, Monday = 1)
+    <i>hh:mm:ss</i>      = hour, minute, second, separated by dots
+    <i>u</i>             = '#' for GPS receivers: time is <b>not</b> synchronized
+                           '#' for older PZF5xx receivers: no correlation, not synchronized
+                           '#' for other devices: never sync'ed since powerup
+                           ' ' if nothing of the above applies
+    <i>v</i>             = '*' for GPS receivers: position has <b>not</b> been verified
+                           '*' for other devices: freewheeling based on internal quartz
+                           ' ' if nothing of the above applies
+    <i>x</i>             = 'U' if UTC time is transmitted
+                           'S' if daylight saving time is active
+                           ' ' if nothing of the above applies
+    <i>y</i>             = '!' during the hour preceding start or end of daylight saving time
+                           'A' during the hour preceding a leap second
+                           ' ' if nothing of the above applies
+    <i>&lt;ETX&gt;</i>         = end-of-text, ASCII code 0x03
+</pre>
+               <p>Format of the Uni Erlangen time string for PZF5xx receivers:</p>
+<pre>
+        <b><i>&lt;STX&gt;</i><i>dd.mm.yy</i>; <i>w</i>; <i>hh:mm:ss</i>; <i>tuvxyza</i><i>&lt;ETX&gt;</i></b>
+    pos:  0  000000001111111111222222222233  3
+          1  234567890123456789012345678901  2
+
+    <i>&lt;STX&gt;</i>         = start-of-text, ASCII code 0x02
+    <i>dd.mm.yy</i>      = day of month, month, year of the century, separated by dots
+    <i>w</i>             = day of week (1..7, Monday = 1)
+    <i>hh:mm:ss</i>      = hour, minute, second, separated by colons
+
+    <i>t</i>             = 'U' if UTC time is transmitted, else ' '
+    <i>u</i>             = '#' for older PZF5xx receivers: no correlation, not synchronized
+                           '#' for PZF511 and newer: never sync'ed since powerup
+                           ' ' if nothing of the above applies
+    <i>v</i>             = '*' if freewheeling based on internal quartz, else ' '
+    <i>x</i>             = 'S' if daylight saving time is active, else ' '
+    <i>y</i>             = '!' during the hour preceding start or end of daylight saving time, else ' '
+    <i>z</i>             = 'A' during the hour preceding a leap second, else ' '
+    <i>a</i>             = 'R' alternate antenna (reminiscent of PZF5xx), usually ' ' for GPS receivers
+    <i>&lt;ETX&gt;</i>         = end-of-text, ASCII code 0x03
+</pre>
+               <p>Format of the Uni Erlangen time string for GPS16x/GPS17x receivers:</p>
+<pre>
+        <b><i>&lt;STX&gt;</i><i>dd.mm.yy</i>; <i>w</i>; <i>hh:mm:ss</i>; <i>+uu:uu</i>; <i>uvxyzab</i>; <i>ll.lllln</i> <i>lll.lllle</i> <i>hhhh</i>m<i>&lt;ETX&gt;</i></b>
+    pos:  0  0000000011111111112222222222333333333344444444445555555555666666  6
+          1  2345678901234567890123456789012345678901234567890123456789012345  6
+
+    <i>&lt;STX&gt;</i>         = start-of-text, ASCII code 0x02
+    <i>dd.mm.yy</i>      = day of month, month, year of the century, separated by dots
+    <i>w</i>             = day of week (1..7, Monday = 1)
+    <i>hh:mm:ss</i>      = hour, minute, second, separated by colons
+    <i>+uu:uu</i>        = offset to UTC in hours and minutes, preceded by + or -
+    <i>u</i>             = '#' if time is <b>not</b> synchronized, else ' '
+    <i>v</i>             = '*' if position has <b>not</b> been verified, else ' '
+    <i>x</i>             = 'S' if daylight saving time is active, else ' '
+    <i>y</i>             = '!' during the hour preceding start or end of daylight saving time, else ' '
+    <i>z</i>             = 'A' during the hour preceding a leap second, else ' '
+    <i>a</i>             = 'R' alternate antenna (reminiscent of PZF5xx), usually ' ' for GPS receivers
+    <i>b</i>             = 'L' during a leap second, i.e. if the seconds field is 60, else ' '
+    <i>ll.lllln</i>      = position latitude in degrees, 'n' can actually be 'N' or 'S', i.e. North or South
+    <i>lll.lllle</i>     = position longitude in degrees, 'e' can actually be 'E' or 'W', i.e. East or West
+    <i>hhhh</i>          = position altitude in meters, always followed by 'm'
+    <i>&lt;ETX&gt;</i>         = end-of-text, ASCII code 0x03
+</pre>
+               <p>Examples for Uni Erlangen strings from GPS receivers:</p>
+<pre>
+        \x02 09.07.93; 5; 08:48:26; +00:00;        ; 49.5736N  11.0280E  373m \x03
+        \x02 08.11.06; 3; 14:39:39; +00:00;        ; 51.9828N   9.2258E  176m \x03
+</pre>
+               <p>The Uni Erlangen formats should be used preferably. Newer Meinberg GPS receivers can be configured to transmit that format, for older devices there may be a special firmware version available.</p>
+               <p>For the Meinberg parse look into clk_meinberg.c<br><br></p>
+               <hr>
+               <h4>Raw DCF77 Data via serial line</h4>
+               <p>RAWDCF: end=TIMEOUT&gt;1.5s, sync each char (any char),generate psuedo time codes, fixed format</p>
+               <p>direct DCF77 code input</p>
+               <p>In Europe it is relatively easy/cheap the receive the german time code transmitter DCF77. The simplest version to process its signal is to feed the 100/200ms pulse of the demodulated AM signal via a level converter to an RS232 port at 50Baud. parse/clk_rawdcf.c holds all necessary decoding logic for the time code which is transmitted each minute for one minute. A bit of the time code is sent once a second.</p>
+               <pre>
+       The preferred tty setting is:
+               CFLAG           (B50|CS8|CREAD|CLOCAL)
+               IFLAG           0
+               OFLAG           0
+               LFLAG           0
+</pre>
+               <h4>DCF77 raw time code</h4>
+               <p>From &quot;Zur Zeit&quot;, Physikalisch-Technische Bundesanstalt (PTB), Braunschweig und Berlin, M&auml;rz 1989<br>
+               </p>
+               <p>Timecode transmission:</p>
+               <pre>
+       AM:
+
+       time marks are send every second except for the second before the
+       next minute mark
+       time marks consist of a reduction of transmitter power to 25%
+       of the nominal level
+       the falling edge is the time indication (on time)
+       time marks of a 100ms duration constitute a logical 0
+       time marks of a 200ms duration constitute a logical 1
+</pre>
+               <p>see the spec. (basically a (non-)inverted psuedo random phase shift) encoding:</p>
+               <pre>
+       FM:
+
+       Second  Contents
+       0  - 10 AM: free, FM: 0
+       11 - 14 free
+       15              R     - alternate antenna
+       16              A1    - expect zone change (1 hour before)
+       17 - 18 Z1,Z2 - time zone
+                0  0 illegal
+                0  1 MEZ  (MET)
+                1  0 MESZ (MED, MET DST)
+                1  1 illegal
+       19      A2    - expect leap insertion/deletion (1 hour before)
+       20      S     - start of time code (1)
+       21 - 24 M1    - BCD (lsb first) Minutes
+       25 - 27 M10   - BCD (lsb first) 10 Minutes
+       28      P1    - Minute Parity (even)
+       29 - 32 H1    - BCD (lsb first) Hours
+       33 - 34 H10   - BCD (lsb first) 10 Hours
+       35      P2    - Hour Parity (even)
+       36 - 39 D1    - BCD (lsb first) Days
+       40 - 41 D10   - BCD (lsb first) 10 Days
+       42 - 44 DW    - BCD (lsb first) day of week (1: Monday -&gt; 7: Sunday)
+       45 - 49 MO1   - BCD (lsb first) Month
+       50      MO10  - 10 Months
+       51 - 53 Y1    - BCD (lsb first) Years
+       54 - 57 Y10   - BCD (lsb first) 10 Years
+       58      P3    - Date Parity (even)
+       59            - usually missing (minute indication), except for leap insertion
+</pre>
+               <hr>
+               <h4>Schmid clock</h4>
+               <p>Schmid clock: needs poll, binary input, end='\xFC', sync start</p>
+               <p>The Schmid clock is a DCF77 receiver that sends a binary time code at the reception of a flag byte. The contents if the flag byte determined the time code format. The binary time code is delimited by the byte 0xFC.</p>
+               <pre>
+       TTY setup is:
+               CFLAG           (B1200|CS8|CREAD|CLOCAL)
+               IFLAG           0
+               OFLAG           0
+               LFLAG           0
+
+</pre>
+               <p>The command to Schmid's DCF77 clock is a single byte; each bit allows the user to select some part of the time string, as follows (the output for the lsb is sent first).</p>
+               <pre>
+       Bit 0:  time in MEZ, 4 bytes *binary, not BCD*; hh.mm.ss.tenths
+       Bit 1:  date 3 bytes *binary, not BCD: dd.mm.yy
+       Bit 2:  week day, 1 byte (unused here)
+       Bit 3:  time zone, 1 byte, 0=MET, 1=MEST. (unused here)
+       Bit 4:  clock status, 1 byte,   0=time invalid,
+                                       1=time from crystal backup,
+                                       3=time from DCF77
+       Bit 5:  transmitter status, 1 byte,
+                                       bit 0: backup antenna
+                                       bit 1: time zone change within 1h
+                                       bit 3,2: TZ 01=MEST, 10=MET
+                                       bit 4: leap second will be
+                                               added within one hour
+                                       bits 5-7: Zero
+       Bit 6:  time in backup mode, units of 5 minutes (unused here)
+</pre>
+               <hr>
+               <h4>Trimble SV6 ASCII time code (TAIP)</h4>
+               <p>Trimble SV6: needs poll, ascii timecode, start='&gt;', end='&lt;', query='&gt;QTM&lt;', eol='&lt;'</p>
+               <p>Trimble SV6 is a GPS receiver with PPS output. It needs to be polled. It also need a special tty mode setup (EOL='&lt;').</p>
+               <pre>
+       TTY setup is:
+               CFLAG            (B4800|CS8|CREAD)
+               IFLAG            (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON)
+               OFLAG            (OPOST|ONLCR)
+               LFLAG            (ICANON|ECHOK)
+</pre>
+               <p>Special flags are:</p>
+               <pre>           PARSE_F_PPSPPS      - use CIOGETEV for PPS time stamping
+               PARSE_F_PPSONSECOND - the time code is not related to
+                                     the PPS pulse (so use the time code
+                                     only for the second epoch)
+
+       Timecode
+       0000000000111111111122222222223333333   / char
+       0123456789012345678901234567890123456   \ posn
+       &gt;RTMhhmmssdddDDMMYYYYoodnnvrrrrr;*xx&lt;     Actual
+       ----33445566600112222BB7__-_____--99-   Parse
+       &gt;RTM                      1     ;*  &lt;     Check
+</pre>
+               <hr>
+               <h4>ELV DCF7000</h4>
+               <p>ELV DCF7000: end='\r', pattern=&quot; - - - - - - - \r&quot;</p>
+               <p>The ELV DCF7000 is a cheap DCF77 receiver sending each second a time code (though not very precise!) delimited by '`r'</p>
+               <pre>
+       Timecode
+         YY-MM-DD-HH-MM-SS-FF\r
+
+               FF&amp;0x1      - DST
+               FF&amp;0x2      - DST switch warning
+               FF&amp;0x4  - unsynchronised
+</pre>
+               <hr>
+               <h4>HOPF 6021 und Kompatible</h4>
+               <p>HOPF Funkuhr 6021 mit serieller Schnittstelle Created by F.Schnekenbuehl &lt;frank@comsys.dofn.de&gt; from clk_rcc8000.c Nortel DASA Network Systems GmbH, Department: ND250 A Joint venture of Daimler-Benz Aerospace and Nortel.</p>
+               <pre>
+ hopf Funkuhr 6021 
+      used with 9600,8N1,
+      UTC via serial line
+      &quot;Sekundenvorlauf&quot; ON
+      ETX zum Sekundenvorlauf ON
+      dataformat 6021
+      output time and date
+      transmit with control characters
+      transmit evry second
+ </pre>
+               <p>Type 6021 Serial Output format</p>
+               <pre>
+      000000000011111111 / char
+      012345678901234567 \ position
+      sABHHMMSSDDMMYYnre  Actual
+       C4110046231195     Parse
+      s              enr  Check
+
+  s = STX (0x02), e = ETX (0x03)
+  n = NL  (0x0A), r = CR  (0x0D)
+
+  A B - Status and weekday
+  A - Status
+
+      8 4 2 1
+      x x x 0  - no announcement
+      x x x 1  - Summertime - wintertime - summertime announcement
+      x x 0 x  - Wintertime
+      x x 1 x  - Summertime
+      0 0 x x  - Time/Date invalid
+      0 1 x x  - Internal clock used 
+      1 0 x x  - Radio clock
+      1 1 x x  - Radio clock highprecision
+
+  B - 8 4 2 1
+      0 x x x  - MESZ/MEZ
+      1 x x x  - UTC
+      x 0 0 1  - Monday
+      x 0 1 0  - Tuesday
+      x 0 1 1  - Wednesday
+      x 1 0 0  - Thursday
+      x 1 0 1  - Friday
+      x 1 1 0  - Saturday
+      x 1 1 1  - Sunday
+</pre>
+               <hr>
+               <h4>Diem Computime Clock</h4>
+               <p>The Computime receiver sends a datagram in the following format every minute</p>
+               <pre>   
+   Timestamp   T:YY:MM:MD:WD:HH:MM:SSCRLF 
+   Pos          0123456789012345678901 2 3
+               0000000000111111111122 2 2
+   Parse        T:  :  :  :  :  :  :  \r\n
+   
+   T   Startcharacter &quot;T&quot; specifies start of the timestamp 
+   YY  Year MM Month 1-12 
+   MD  Day of the month 
+   WD  Day of week 
+   HH  Hour 
+   MM   Minute 
+   SS   Second
+   CR   Carriage return 
+   LF   Linefeed
+</pre>
+               <hr>
+               <h4>WHARTON 400A Series Clock with a 404.2 Serial interface</h4>
+               <p>The WHARTON 400A Series clock is able to send date/time serial messages in 7 output formats. We use format 1 here because it is the shortest. We set up the clock to send a datagram every second. For use with this driver, the WHARTON 400A Series clock must be set-up as follows :</p>
+               <pre>
+                                       Programmable    Selected
+                                       Option No       Option
+       BST or CET display              3               9 or 11
+       No external controller          7               0
+       Serial Output Format 1          9               1
+       Baud rate 9600 bps              10              96
+       Bit length 8 bits               11              8
+       Parity even                     12              E
+</pre>
+               <p>WHARTON 400A Series output format 1 is as follows :</p>
+               <pre>
+   Timestamp   STXssmmhhDDMMYYSETX
+   Pos         0  12345678901234
+               0  00000000011111
+  
+   STX start transmission (ASCII 0x02)
+   ETX end transmission (ASCII 0x03)
+   ss  Second expressed in reversed decimal (units then tens)
+   mm  Minute expressed in reversed decimal
+   hh  Hour expressed in reversed decimal
+   DD  Day of month expressed in reversed decimal
+   MM  Month expressed in reversed decimal (January is 1)
+   YY  Year (without century) expressed in reversed decimal
+   S   Status byte : 0x30 +
+               bit 0   0 = MSF source          1 = DCF source
+               bit 1   0 = Winter time         1 = Summer time
+               bit 2   0 = not synchronised    1 = synchronised
+               bit 3   0 = no early warning    1 = early warning
+</pre>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/parsenew.html b/html/parsenew.html
new file mode 100644 (file)
index 0000000..4f11a46
--- /dev/null
@@ -0,0 +1,198 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Making PARSE Clocks</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>How to build new PARSE clocks</h3>
+               <p>Here is an attempt to sketch out what you need to do in order to add another clock to the parse driver: Currently the implementation is being cleaned up - so not all information in here is completely correct. Refer to the included code where in doubt.</p>
+               <p>Prerequisites:</p>
+               <ul>
+                       <li>Does the system you want the clock connect to have the include files termio.h or termios.h ? (You need that for the parse driver)
+               </ul>
+               <p>What to do:</p>
+               <p>Make a conversion module (libparse/clk_*.c)</p>
+               <ol>
+                       <li>What ist the time code format ?
+                               <ul>
+                                       <li>find year, month, day, hour, minute, second, status (synchronised or not), possibly time zone information (you need to give the offset to UTC) You will have to convert the data from a string into a struct clocktime:
+                                               <pre>
+      struct clocktime                /* clock time broken up from time code */
+      {
+       long day;
+       long month;
+       long year;
+       long hour;
+       long minute;
+       long second;
+       long usecond;
+       long utcoffset;       /* in seconds */
+       time_t utcoffset;     /* true utc time instead of date/time */
+       long flags;           /* current clock status */
+      };
+</pre>
+                                               <p>Conversion is usually simple and straight forward. For the flags following values can be OR'ed together:</p>
+                                               <pre>
+     PARSEB_ANNOUNCE           switch time zone warning (informational only)
+     PARSEB_POWERUP            no synchronisation - clock confused (must set then)
+     PARSEB_NOSYNC             timecode currently not confirmed (must set then)
+                               usually on reception error when there is still a
+                               chance the the generated time is still ok.
+
+     PARSEB_DST                DST in effect (informational only)
+     PARSEB_UTC                timecode contains UTC time (informational only)
+     PARSEB_LEAPADD            LEAP addition warning (prior to leap happening - must set when imminent)
+                              also used for time code that do not encode the
+                              direction (as this is currently the default).
+     PARSEB_LEAPDEL            LEAP deletion warning (prior to leap happening - must set when imminent)
+     PARSEB_ALTERNATE          backup transmitter (informational only)
+     PARSEB_POSITION           geographic position available (informational only)
+     PARSEB_LEAPSECOND         actual leap second (this time code is the leap
+                               second - informational only)
+</pre>
+                                               <p>These are feature flags denoting items that are supported by the clock:</p>
+                                               <pre>
+     PARSEB_S_LEAP             supports LEAP - might set PARSEB_LEAP
+     PARSEB_S_ANTENNA          supports ANTENNA - might set PARSEB_ALTERNATE
+     PARSEB_S_PPS              supports PPS time stamping
+     PARSEB_S_POSITION         supports position information (GPS)
+   </pre>
+                                               <p>If the utctime field is non zero this value will be take as time code value. This allows for conversion routines that already have the utc time value. The utctime field gives the seconds since Jan 1st 1970, 0:00:00. The useconds field gives the respective usec value. The fields for date and time (down to second resolution) will be ignored.</p>
+                                               <p>Conversion is done in the cvt_* routine in parse/clk_*.c files. look in them for examples. The basic structure is:</p>
+                                               <pre>
+     struct clockformat &lt;yourclock&gt;_format = {
+       lots of fields for you to fill out (see below)
+     };
+
+     static cvt_&lt;yourclock&gt;()
+       ...
+     {
+       if (&lt;I do not recognize my time code&gt;) {
+         return CVT_NONE;
+       } else {
+         if (&lt;conversion into clockformat is ok&gt;) {
+           &lt;set all necessary flags&gt;;
+           return CVT_OK;
+         } else {
+           return CVT_FAIL|CVT_BADFMT;
+         }
+       }
+</pre>
+                                               <p>The struct clockformat is the interface to the rest of the parse driver - it holds all information necessary for finding the clock message and doing the appropriate time stamping.</p>
+                                               <pre>
+struct clockformat
+{
+  u_long (*input)();
+  /* input routine - your routine - cvt_&lt;yourclock&gt; */
+  u_long (*convert)();
+  /* conversion routine - your routine - cvt_&lt;yourclock&gt; */
+  /* routine for handling RS232 sync events (time stamps) - usually sync_simple */
+  u_long (*syncpps)(); 
+  /* PPS input routine - usually pps_one */
+  void           *data;
+  /* local parameters - any parameters/data/configuration info your conversion
+     routine might need */
+  char           *name;
+  /* clock format name - Name of the time code */
+  unsigned short  length;
+  /* maximum length of data packet for your clock format */
+  u_long   flags;
+ /* information for the parser what to look for */
+};
+</pre>
+                                               <p>The above should have given you some hints on how to build a clk_*.c file with the time code conversion. See the examples and pick a clock closest to yours and tweak the code to match your clock.</p>
+                                               <p>In order to make your clk_*.c file usable a reference to the clockformat structure must be put into parse_conf.c.</p>
+                               </ul>
+                       <li>TTY setup and initialisation/configuration will be done in ntpd/refclock_parse.c.
+                               <ul>
+                                       <li>Find out the exact tty settings for your clock (baud rate, parity, stop bits, character size, ...) and note them in terms of termio*.h c_cflag macros.
+                                       <li>in ntpd/refclock_parse.c fill out a new the struct clockinfo element (that allocates a new &quot;IP&quot; address - see comments) (see all the other clocks for example)
+                                               <pre>
+   struct clockinfo
+     {
+      u_long  cl_flags;             /* operation flags (io modes) */
+        PARSE_F_PPSPPS       use loopfilter PPS code (CIOGETEV)
+        PARSE_F_PPSONSECOND  PPS pulses are on second
+        usually flags stay 0 as they are used only for special setups
+
+    void  (*cl_poll)();           /* active poll routine */
+         The routine to call when the clock needs data sent to it in order to
+         get a time code from the clock (e.g. Trimble clock)
+
+    int   (*cl_init)();           /* active poll init routine */
+         The routine to call for very special initializations.
+
+    void  (*cl_event)();          /* special event handling (e.g. reset clock) */
+         What to do, when an event happens - used to re-initialize clocks on timeout.
+
+    void  (*cl_end)();            /* active poll end routine */
+         The routine to call to undo any special initialisation (free memory/timers)
+
+    void   *cl_data;              /* local data area for &quot;poll&quot; mechanism */
+         local data for polling routines
+
+    u_fp    cl_rootdelay;         /* rootdelay */
+         NTP rootdelay estimate (usually 0)
+
+            u_long  cl_basedelay;         /* current offset - unsigned l_fp
+                                              fractional part (fraction) by
+                                              which the RS232 time code is
+                                              delayed from the actual time. */
+
+    u_long  cl_ppsdelay;          /* current PPS offset - unsigned l_fp fractional
+         time (fraction) by which the PPS time stamp is delayed (usually 0)
+   part */
+
+    char   *cl_id;                /* ID code (usually &quot;DCF&quot;) */
+         Refclock id - (max 4 chars)
+
+    char   *cl_description;       /* device name */
+         Name of this device.
+
+    char   *cl_format;            /* fixed format */
+         If the data format cann not ne detected automatically this is the name
+        as in clk_*.c clockformat.
+
+    u_char  cl_type;              /* clock type (ntp control) */
+         Type if clock as in clock status word (ntp control messages) - usually 0
+        
+    u_long  cl_maxunsync;         /* time to trust oscillator after losing synch
+  */
+         seconds a clock can be trusted after losing synchronisation.
+
+    u_long  cl_speed;             /* terminal input &amp; output baudrate */
+    u_long  cl_cflag;             /* terminal io flags */
+    u_long  cl_iflag;             /* terminal io flags */
+    u_long  cl_oflag;             /* terminal io flags */
+    u_long  cl_lflag;             /* terminal io flags */
+         termio*.h tty modes.
+
+    u_long  cl_samples;           /* samples for median filter */
+    u_long  cl_keep;              /* samples for median filter to keep */
+         median filter parameters - smoothing and rejection of bad samples
+  } clockinfo[] = {
+  ...,&lt;other clocks&gt;,...
+  { &lt; your parameters&gt; },
+  };
+
+</pre>
+                               </ul>
+               </ol>
+               <p>Well, this is very sketchy, i know. But I hope it helps a little bit. The best way is to look which clock comes closest to your and tweak that code.</p>
+               <p>Two sorts of clocks are used with parse. Clocks that automatically send their time code (once a second) do not need entries in the poll routines because they send the data all the time. The second sort are the clocks that need a command sent to them in order to reply with a time code (like the Trimble clock).</p>
+               <p>For questions: <a href="mailto:%20kardel <AT> acm.org">kardel 
+                               <AT>
+                               acm.org</a>.</p>
+               <p>Please include an exact description on how your clock works. (initialisation, TTY modes, strings to be sent to it, responses received from the clock).</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+       <body></body>
+
+</html>
\ No newline at end of file
diff --git a/html/pic/9400n.jpg b/html/pic/9400n.jpg
new file mode 100644 (file)
index 0000000..9209b90
Binary files /dev/null and b/html/pic/9400n.jpg differ
diff --git a/html/pic/alice11.gif b/html/pic/alice11.gif
new file mode 100644 (file)
index 0000000..62d0c9b
Binary files /dev/null and b/html/pic/alice11.gif differ
diff --git a/html/pic/alice13.gif b/html/pic/alice13.gif
new file mode 100644 (file)
index 0000000..c928ff7
Binary files /dev/null and b/html/pic/alice13.gif differ
diff --git a/html/pic/alice23.gif b/html/pic/alice23.gif
new file mode 100644 (file)
index 0000000..bc258a0
Binary files /dev/null and b/html/pic/alice23.gif differ
diff --git a/html/pic/alice31.gif b/html/pic/alice31.gif
new file mode 100644 (file)
index 0000000..ea3d20c
Binary files /dev/null and b/html/pic/alice31.gif differ
diff --git a/html/pic/alice32.gif b/html/pic/alice32.gif
new file mode 100644 (file)
index 0000000..db7cc40
Binary files /dev/null and b/html/pic/alice32.gif differ
diff --git a/html/pic/alice35.gif b/html/pic/alice35.gif
new file mode 100644 (file)
index 0000000..aa0ca43
Binary files /dev/null and b/html/pic/alice35.gif differ
diff --git a/html/pic/alice38.gif b/html/pic/alice38.gif
new file mode 100644 (file)
index 0000000..e40adba
Binary files /dev/null and b/html/pic/alice38.gif differ
diff --git a/html/pic/alice44.gif b/html/pic/alice44.gif
new file mode 100644 (file)
index 0000000..953387e
Binary files /dev/null and b/html/pic/alice44.gif differ
diff --git a/html/pic/alice47.gif b/html/pic/alice47.gif
new file mode 100644 (file)
index 0000000..6b27160
Binary files /dev/null and b/html/pic/alice47.gif differ
diff --git a/html/pic/alice51.gif b/html/pic/alice51.gif
new file mode 100644 (file)
index 0000000..1e9082a
Binary files /dev/null and b/html/pic/alice51.gif differ
diff --git a/html/pic/alice61.gif b/html/pic/alice61.gif
new file mode 100644 (file)
index 0000000..5687c38
Binary files /dev/null and b/html/pic/alice61.gif differ
diff --git a/html/pic/barnstable.gif b/html/pic/barnstable.gif
new file mode 100644 (file)
index 0000000..17d9cdd
Binary files /dev/null and b/html/pic/barnstable.gif differ
diff --git a/html/pic/beaver.gif b/html/pic/beaver.gif
new file mode 100644 (file)
index 0000000..3d0c8eb
Binary files /dev/null and b/html/pic/beaver.gif differ
diff --git a/html/pic/boom3.gif b/html/pic/boom3.gif
new file mode 100644 (file)
index 0000000..1a95d40
Binary files /dev/null and b/html/pic/boom3.gif differ
diff --git a/html/pic/boom3a.gif b/html/pic/boom3a.gif
new file mode 100644 (file)
index 0000000..14bfe5b
Binary files /dev/null and b/html/pic/boom3a.gif differ
diff --git a/html/pic/bustardfly.gif b/html/pic/bustardfly.gif
new file mode 100644 (file)
index 0000000..b5c6e91
Binary files /dev/null and b/html/pic/bustardfly.gif differ
diff --git a/html/pic/c51.jpg b/html/pic/c51.jpg
new file mode 100644 (file)
index 0000000..d90ad55
Binary files /dev/null and b/html/pic/c51.jpg differ
diff --git a/html/pic/dogsnake.gif b/html/pic/dogsnake.gif
new file mode 100644 (file)
index 0000000..1f9755d
Binary files /dev/null and b/html/pic/dogsnake.gif differ
diff --git a/html/pic/driver29.gif b/html/pic/driver29.gif
new file mode 100644 (file)
index 0000000..b0415ae
Binary files /dev/null and b/html/pic/driver29.gif differ
diff --git a/html/pic/driver43_1.gif b/html/pic/driver43_1.gif
new file mode 100644 (file)
index 0000000..f1ff7c7
Binary files /dev/null and b/html/pic/driver43_1.gif differ
diff --git a/html/pic/driver43_2.jpg b/html/pic/driver43_2.jpg
new file mode 100644 (file)
index 0000000..c53639c
Binary files /dev/null and b/html/pic/driver43_2.jpg differ
diff --git a/html/pic/fg6021.gif b/html/pic/fg6021.gif
new file mode 100644 (file)
index 0000000..e6e3071
Binary files /dev/null and b/html/pic/fg6021.gif differ
diff --git a/html/pic/fg6039.jpg b/html/pic/fg6039.jpg
new file mode 100644 (file)
index 0000000..25fc7c4
Binary files /dev/null and b/html/pic/fg6039.jpg differ
diff --git a/html/pic/gadget.jpg b/html/pic/gadget.jpg
new file mode 100644 (file)
index 0000000..6289911
Binary files /dev/null and b/html/pic/gadget.jpg differ
diff --git a/html/pic/gps167.jpg b/html/pic/gps167.jpg
new file mode 100644 (file)
index 0000000..8a87a75
Binary files /dev/null and b/html/pic/gps167.jpg differ
diff --git a/html/pic/hornraba.gif b/html/pic/hornraba.gif
new file mode 100644 (file)
index 0000000..3077d75
Binary files /dev/null and b/html/pic/hornraba.gif differ
diff --git a/html/pic/igclock.gif b/html/pic/igclock.gif
new file mode 100644 (file)
index 0000000..940f330
Binary files /dev/null and b/html/pic/igclock.gif differ
diff --git a/html/pic/neoclock4x.gif b/html/pic/neoclock4x.gif
new file mode 100755 (executable)
index 0000000..4df95af
Binary files /dev/null and b/html/pic/neoclock4x.gif differ
diff --git a/html/pic/oncore_evalbig.gif b/html/pic/oncore_evalbig.gif
new file mode 100644 (file)
index 0000000..931a7f1
Binary files /dev/null and b/html/pic/oncore_evalbig.gif differ
diff --git a/html/pic/oncore_remoteant.jpg b/html/pic/oncore_remoteant.jpg
new file mode 100644 (file)
index 0000000..0f1d048
Binary files /dev/null and b/html/pic/oncore_remoteant.jpg differ
diff --git a/html/pic/oncore_utplusbig.gif b/html/pic/oncore_utplusbig.gif
new file mode 100644 (file)
index 0000000..dec7e71
Binary files /dev/null and b/html/pic/oncore_utplusbig.gif differ
diff --git a/html/pic/oz2.gif b/html/pic/oz2.gif
new file mode 100644 (file)
index 0000000..d4982f0
Binary files /dev/null and b/html/pic/oz2.gif differ
diff --git a/html/pic/panda.gif b/html/pic/panda.gif
new file mode 100644 (file)
index 0000000..6feb743
Binary files /dev/null and b/html/pic/panda.gif differ
diff --git a/html/pic/pd_om006.gif b/html/pic/pd_om006.gif
new file mode 100644 (file)
index 0000000..3266285
Binary files /dev/null and b/html/pic/pd_om006.gif differ
diff --git a/html/pic/pd_om011.gif b/html/pic/pd_om011.gif
new file mode 100644 (file)
index 0000000..06566b9
Binary files /dev/null and b/html/pic/pd_om011.gif differ
diff --git a/html/pic/pogo.gif b/html/pic/pogo.gif
new file mode 100644 (file)
index 0000000..68dacbe
Binary files /dev/null and b/html/pic/pogo.gif differ
diff --git a/html/pic/pogo1a.gif b/html/pic/pogo1a.gif
new file mode 100644 (file)
index 0000000..433e467
Binary files /dev/null and b/html/pic/pogo1a.gif differ
diff --git a/html/pic/pogo3a.gif b/html/pic/pogo3a.gif
new file mode 100644 (file)
index 0000000..49f1359
Binary files /dev/null and b/html/pic/pogo3a.gif differ
diff --git a/html/pic/pogo4.gif b/html/pic/pogo4.gif
new file mode 100644 (file)
index 0000000..e0a3b17
Binary files /dev/null and b/html/pic/pogo4.gif differ
diff --git a/html/pic/pogo5.gif b/html/pic/pogo5.gif
new file mode 100644 (file)
index 0000000..87ad8e4
Binary files /dev/null and b/html/pic/pogo5.gif differ
diff --git a/html/pic/pogo6.gif b/html/pic/pogo6.gif
new file mode 100644 (file)
index 0000000..3f98c52
Binary files /dev/null and b/html/pic/pogo6.gif differ
diff --git a/html/pic/pogo8.gif b/html/pic/pogo8.gif
new file mode 100644 (file)
index 0000000..6860efb
Binary files /dev/null and b/html/pic/pogo8.gif differ
diff --git a/html/pic/pzf511.jpg b/html/pic/pzf511.jpg
new file mode 100644 (file)
index 0000000..c470af2
Binary files /dev/null and b/html/pic/pzf511.jpg differ
diff --git a/html/pic/rabbit.gif b/html/pic/rabbit.gif
new file mode 100644 (file)
index 0000000..ab6ec5f
Binary files /dev/null and b/html/pic/rabbit.gif differ
diff --git a/html/pic/radio2.jpg b/html/pic/radio2.jpg
new file mode 100644 (file)
index 0000000..ceb7c76
Binary files /dev/null and b/html/pic/radio2.jpg differ
diff --git a/html/pic/sheepb.jpg b/html/pic/sheepb.jpg
new file mode 100644 (file)
index 0000000..1b3323e
Binary files /dev/null and b/html/pic/sheepb.jpg differ
diff --git a/html/pic/stack1a.jpg b/html/pic/stack1a.jpg
new file mode 100644 (file)
index 0000000..1e023cb
Binary files /dev/null and b/html/pic/stack1a.jpg differ
diff --git a/html/pic/tonea.gif b/html/pic/tonea.gif
new file mode 100644 (file)
index 0000000..17f48fc
Binary files /dev/null and b/html/pic/tonea.gif differ
diff --git a/html/pic/wingdorothy.gif b/html/pic/wingdorothy.gif
new file mode 100644 (file)
index 0000000..bb0d19d
Binary files /dev/null and b/html/pic/wingdorothy.gif differ
diff --git a/html/pps.html b/html/pps.html
new file mode 100644 (file)
index 0000000..b9fcd7f
--- /dev/null
@@ -0,0 +1,41 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Pulse-per-second (PPS) Signal Interfacing</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Pulse-per-second (PPS) Signal Interfacing</h3>
+               <img src="pic/alice32.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>Alice is trying to find the PPS signal connector.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:48</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links11.txt"></script>
+               <hr>
+               <p>Some radio clocks and related timekeeping gear have a pulse-per-second (PPS) signal that can be used to discipline the system clock to a high degree of precision, typically to the order less than 10 <font face="Symbol">m</font>s in time and 0.01 parts-per-million (PPM) in frequency. This page describes the hardware and software necessar for NTP to use this signal.</p>
+               <img src="pic/gadget.jpg" alt="gif" align="left">A Gadget Box built by Chuck Hanavin<br clear="left">
+               <h4>Gadget Box</h4>
+               <p>The PPS signal can be connected in either of two ways: via the data carrier detector (DCD) pin of a serial port or via the acknowledge (ACK) pin of a parallel port, depending on the hardware and operating system. Note that NTP no longer supports connection via the data leads of a serial port. However, the PPS signal levels are usually incompatible with serial port levels. The gadget box consists of a handful of electronic components assembled in a small aluminum box. It includes level converters and a optional modem designed to decode the radio timecode signals transmitted by Canadian time and frequency station CHU. This can be used with the <a href="drivers/driver7.html">Radio CHU Audio Demodulator/Decoder</a>. A complete set of schematics, PCB artwork and drill templates can be obrtained via the web at <a href="ftp://ftp.udel.edu/pub/ntp/hardware/gadget.tar.Z">gadget.tar.Z</a>.</p>
+               <h4>Operating System Support&nbsp;</h4>
+               <p>Both the serial and parallel port connection require operating system support, which is available in only a few operating systems, including FreeBSD, Linux (with PPSkit patch) and Solaris. Support on an experimental basis is available for several other systems, including SunOS and HP/Compaq/Digital Tru64. The PPSAPI application program interface defined in [1] is the only interface currently supported. Older PPS interfaces based on the <tt>ppsclock</tt> and <tt>tty_clk</tt> streams modules are no longer supported. As the PPSAPI is expected to become an IETF cross-platform standard, it should be used by new applications.</p>
+               <p>The entire PPS interface functionality is currently provided by inline code in the <tt>timepps.h</tt> header file. While not all implementations support the full PPSAPI specification, they do support all the functions required for the PPS driver described next. The FreeBSD, Linux and Solaris implementations can be used with the stock kernels provided with those systems; however, the Tru64 and SunOS kernels require additional functions not provided in the stock kernels. Solaris users are cautioned that these functions operate improperly in Solaris versions prior to 2.8 with patch Generic_108528-02. Header files for other systems can be found via the web at <a href="ftp://ftp.udel.edu/pub/ntp/software/nanokernel.tar.gz">nanokernel.tar.gz</a>.</p>
+               <h4>PPS Driver</h4>
+               <p>In the preferred mode of operation, PPS signals are processed by the <a href="drivers/driver22.html">PPS Clock Discipline</a> driver and other clock drivers which might be involved need not know or care about them. In some cases where there is no other driver, time might be obtained from remote NTP servers via the network and local PPS signals, for instance from a calibrated cesium oscillator, used to stabilize the frequency and remove network jitter. Note that the <tt>pps</tt> configuration command has been obsoleted by this driver.</p>
+               <p>The PPS driver operates in conjunction with a preferred peer, as described in the <a href="prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a> page. One of the drivers described in the <a href="refclock.html">Reference Clock Drivers</a> page or another NTP server furnishes the coarse timing and disambiguates the seconds numbering of the PPS signal itself. The NTP daemon mitigates between the clock driver or NTP server and the PPS driver as described in that page in order to provide the most accurate time, while respecting the various types of equipment failures that could happen.</p>
+               <p>Some Unix system kernels support a PPS signal directly, as described in the <a href="kern.html">A Kernel Model for Precision Timekeeping</a> page. Specifically, the PPS driver can be used to direct the PPS signal to the kernel for use as a discipline source for both time and frequency. The presence of the kernel support is automatically detected during the NTP build process and supporting code automatically compiled. Note that the PPS driver does not normally enable the PPS kernel code, since performance is generally better without it. However, this code can be enabled by a driver fudge flag if necessary.</p>
+               <p>Some configurations may include multiple radio clocks with individual PPS outputs. In some PPSAPI designs multiple PPS signals can be connected to multiple instances of the PPS driver. In such cases the NTP mitigation and grooming algorithms operate with all the radio timecodes and PPS signals to develop the highest degree of redundancy and survivability.</p>
+               <h4>Reference</h4>
+               <ol>
+                       <li>Mogul, J., D. Mills, J. Brittenson, J. Stone and U. Windl. Pulse-per-second API for Unix-like operating systems, version 1. Request for Comments RFC-2783, Internet Engineering Task Force, March 2000, 31 pp. <a href="http://www.eecis.udel.edu/mills/database/rfc/rfc2783.txt">ASCII</a>
+               </ol>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/prefer.html b/html/prefer.html
new file mode 100644 (file)
index 0000000..00225d1
--- /dev/null
@@ -0,0 +1,72 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Mitigation Rules and the prefer Keyword</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Mitigation Rules and the <tt>prefer</tt> Keyword</h3>
+               <img src="pic/alice11.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html"> from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>Listen carefully to what I say; it is very complicated.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:49</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links10.txt"></script>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#intro">Introduction</a>
+                       <li class="inline"><a href="#prefer">The <tt>prefer</tt> Peer</a>
+                       <li class="inline"><a href="#peer">Peer Classification</a>
+                       <li class="inline"><a href="#miti">Mitigation Rules</a>
+                       <li class="inline"><a href="#pps">Using the Pulse-per-Second (PPS) Signal</a>
+               </ul>
+               <hr>
+               <h4 id="intro">Introduction</h4>
+               <p>The mechanics of the NTP algorithms which select the best data sample from each available server and the best subset of the server population have been finely crafted to resist network jitter, faults in the network or server operations, and to deliver the best possible accuracy. Most of the time these algorithms do a good job without requiring explicit manual tailoring of the configuration file. However, there are times when the accuracy can be improved by some careful tailoring. The following sections explain how to do this using explicit configuration items and special signals, when available, that are generated by some radio clocks and laboratory instruments.</p>
+               <p>In order to provide robust backup sources, primary (stratum-1) servers are usually operated in a diversity configuration, in which the server operates with a number of remote servers in addition to one or more radio or modem clocks. In these configurations the suite of algorithms used in NTP to refine the data from each peer separately and to select and combine the data from a number of servers and clocks. As the result of these algorithms, a set of <i>survivors</i> are identified which can presumably provide the most reliable and accurate time. Ordinarily, the individual clock offsets of the survivors are combined on a weighted average basis to produce an offset used to control the system clock.</p>
+               <p>However, because of small but significant systematic time offsets between the survivors, it is in general not possible to achieve the lowest jitter and highest stability in these configurations. This happens because the selection algorithm tends to <i>clockhop</i> between survivors of substantially the same quality, but showing small systematic offsets between them. In addition, there are a number of configurations involving pulse-per-second (PPS) signals, modem backup services and other special cases, so that a set of mitigation rules becomes necessary to select a single peer from among the survivors. These rules are based on a set of special characteristics of the various remote servers and reference clock drivers specified in the configuration file.</p>
+               <h4 id="prefer">The <tt>prefer</tt> Peer</h4>
+               <p>The mitigation rules are designed to provide an intelligent selection between various sources of substantially the same statistical quality without compromising the normal operation of the NTP algorithms. While they have been implemented in NTP Version 4 and will be incorporated in the NTP Version 4 specification when published, they are not in the NTP Version 3 specification RFC-1305. The rules are based on the concept of <i>prefer peer</i>, which is specified by including the <tt>prefer</tt> keyword with the associated <tt>server</tt> or <tt>peer</tt> command in the configuration file. This keyword can be used with any server or peer, but is most commonly used with a radio clock. While the rules do not forbid it, it does not seem useful to designate more than one peer as preferred, since the additional complexities to mitigate among them do not seem justified from on-air experience.</p>
+               <p>The prefer scheme works on the set of peers that have survived the sanity checks and intersection algorithms of the clock selection procedures. Ordinarily, the members of this set can be considered <i>truechimers</i> and any one of them could in principle provide correct time; however, due to various error contributions, not all can provide the most accurate and stable time. The job of the clustering algorithm, which is invoked at this point, is to select the best subset of the survivors providing the least variance in the combined ensemble average, compared to the variance in each member of the subset separately. The detailed operation of the clustering algorithm, which is given in RFC-1305, is beyond the scope of discussion here. It operates in rounds, where a survivor, presumably the worst of the lot, is discarded in each round until one of several termination conditions is met. An example terminating condition is when the number of survivors is about to be reduced below three.</p>
+               <p>In the prefer scheme the clustering algorithm is modified so that the prefer peer is never discarded; on the contrary, its potential removal becomes a termination condition. If the original algorithm were about to toss out the prefer peer, the algorithm terminates immediately. The prefer peer can still be discarded by the sanity checks and intersection algorithm, of course, but it will always survive the clustering algorithm. If it does not survive or for some reason it fails to provide updates, it will eventually become unreachable and the clock selection will remitigate to select the next best source.</p>
+               <p>Along with this behavior, the clock selection procedures are modified so that the combining algorithm is not used when a prefer peer is present. Instead, the offset of the prefer peer is used exclusively as the synchronization source. In the usual case involving a radio clock and a flock of remote stratum-1 peers, and with the radio clock designated a prefer peer, the result is that the high quality radio time disciplines the server clock as long as the radio itself remains operational and with valid time, as determined from the remote peers, sanity checks and intersection algorithm.</p>
+               <h4 id="peer">Peer Classification</h4>
+               <p>In order to understand the effects of the various intricate schemes involved, it is necessary to understand some arcane details on how the algorithms decide on a synchronization source when more than one source is available. This is done on the basis of a set of explicit mitigation rules, which define special classes of remote serves and local radio clocks as a function of configuration declarations and clock driver type:</p>
+               <ol>
+                       <li>The prefer peer is designated using the <tt>prefer</tt> keyword with the <tt>server</tt> or <tt>peer</tt> commands. All other things being equal, this peer will be selected for synchronization over all other survivors of the clock selection procedures.
+                       <li>When a PPS signal is connected via the PPS Clock Discipline driver (type 22), this is called the <i>PPS peer</i>. This driver provides precision clock corrections only within one second, so is always operated in conjunction with another server or radio clock driver, which provides the seconds numbering. The PPS peer is active only under conditions explained below.
+                       <li>When the Undisciplined Local Clock driver (type 1) is configured, this is called the <i>local clock peer</i>. This is used either as a backup reference source (stratum greater than zero), should all other synchronization sources fail, or as the primary reference source (stratum zero) in cases where the kernel time is disciplined by some other means of synchronization, such as the NIST <tt>lockclock</tt> scheme, or another synchronization protocol, such as the Digital Time Synchronization Service (DTSS).
+                       <li>When a modem driver such as the Automated Computer Time Service driver (type 18) is configured, this is called the <i>modem peer</i>. This is used either as a backup reference source, should all other primary sources fail, or as the (only) primary reference source.
+                       <li>Where support is available, the PPS signal may be processed directly by the kernel, as described in the <a href="kern.html">A Kernel Model for Precision Timekeeping</a> page. This is called the <i>kernel discipline</i>. The PPS signal can discipline the kernel in both frequency and time. The frequency discipline is active as long as the PPS interface device and signal itself is operating correctly, as determined by the kernel algorithms. The time discipline is active only under conditions explained below.
+               </ol>
+               <p>Reference clock drivers operate in the manner described in the <a href="refclock.html">Reference Clock Drivers</a> page and its dependencies. The drivers are ordinarily operated at stratum zero, so that as the result of ordinary NTP operations, the server itself operates at stratum one, as required by the NTP specification. In some cases described below, the driver is intentionally operated at an elevated stratum, so that it will be selected only if no other survivor is present with a lower stratum. In the case of the PPS peer or kernel time discipline, these sources appear active only if the prefer peer has survived the intersection and clustering algorithms, as described below, and its clock offset relative to the current local clock is less than a specified value, currently 128 ms.</p>
+               <p>The modem clock drivers are a special case. Ordinarily, the update interval between modem calls to synchronize the system clock is many times longer than the interval between polls of either a remote server or local radio clock. In order to provide the best stability, the operation of the clock discipline algorithm changes gradually from a phase-lock mode at the shorter update intervals to a frequency-lock mode at the longer update intervals. If remote servers or local radio clocks together with a modem peer operate in the same client, the following things can happen.</p>
+               <p>First the clock selection algorithm can select one or more remote servers or local radio clocks and the clock discipline algorithm will optimize for the shorter update intervals. Then, the selection algorithm can select the modem peer, which requires a much different optimization. The intent in the design is to allow the modem peer to control the system clock either when no other source is available or, if the modem peer happens to be marked as prefer, then it always controls the clock, as long as it passes the sanity checks and intersection algorithm. There still is room for suboptimal operation in this scheme, since a noise spike can still cause a clockhop either way. Nevertheless, the optimization function is slow to adapt, so that a clockhop or two does not cause much harm.</p>
+               <p>The local clock driver is another special case. Normally, this driver is eligible for selection only if no other source is available. When selected, vernier adjustments introduced via the configuration file or remotely using the <tt><a href="ntpdc.html">ntpdc</a> </tt>program can be used to trim the local clock frequency and time. However, if the local clock driver is designated the prefer peer, this driver is always selected and all other sources are ignored. This behavior is intended for use when the kernel time is controlled by some means external to NTP, such as the NIST <tt>lockclock</tt> algorithm or another time synchronization protocol such as DTSS. In this case the only way to disable the local clock driver is to mark it unsynchronized using the leap indicator bits. In the case of modified kernels with the <tt>ntp_adjtime()</tt> system call, this can be done automatically if the external synchronization protocol uses it to discipline the kernel time.</p>
+               <h4 id="miti">Mitigation Rules</h4>
+               <p>The mitigation rules apply in the intersection and clustering algorithms described in the NTP specification. The intersection algorithm first scans all peers with a persistent association and includes only those that satisfy specified sanity checks. In addition to the checks required by the specification, the mitigation rules require either the local-clock peer or modem peer to be included only if marked as the prefer peer. The intersection algorithm operates on the included population to select only those peers believed to represent the correct time. If one or more peers survive the algorithm, processing continues in the clustering algorithm. Otherwise, if there is a modem peer, it is declared the only survivor; otherwise, if there is a local-clock peer, it is declared the only survivor. Processing then continues in the clustering algorithm.</p>
+               <p>The clustering algorithm repeatedly discards outlyers in order to reduce the residual jitter in the survivor population. As required by the NTP specification, these operations continue until either a specified minimum number of survivors remain or the minimum select dispersion of the population is greater than the maximum peer dispersion of any member. The mitigation rules require an additional terminating condition which stops these operations at the point where the prefer peer is about to be discarded.</p>
+               <p>The mitigation rules establish the choice of <i>system peer</i>, which determines the stratum, reference identifier and several other system variables which are visible to clients of the server. In addition, they establish which source or combination of sources control the local clock.</p>
+               <ol>
+                       <li>If there is a prefer peer and it is the local-clock peer or the modem peer; or, if there is a prefer peer and the kernel time discipline is active, choose the prefer peer as the system peer and its offset as the system clock offset. If the prefer peer is the local-clock peer, an offset can be calculated by the driver to produce a frequency offset in order to correct for systematic frequency errors. In case a source other than NTP is controlling the system clock, corrections determined by NTP can be ignored by using the <tt>disable pll</tt> in the configuration file. If the prefer peer is the modem peer, it must be the primary source for the reasons noted above. If the kernel time discipline is active, the system clock offset is ignored and the corrections handled directly by the kernel.
+                       <li>If the above is not the case and there is a PPS peer, then choose it as the system peer and its offset as the system clock offset.
+                       <li>If the above is not the case and there is a prefer peer (not the local-clock or modem peer in this case), then choose it as the system peer and its offset as the system clock offset.
+                       <li>If the above is not the case and the peer previously chosen as the system peer is in the surviving population, then choose it as the system peer and average its offset along with the other survivors to determine the system clock offset. This behavior is designed to avoid excess jitter due to clockhopping, when switching the system peer would not materially improve the time accuracy.
+                       <li>If the above is not the case, then choose the first candidate in the list of survivors ranked in order of synchronization distance and average its offset along with the other survivors to determine the system clock offset. This is the default case and the only case considered in the current NTP specification.
+               </ol>
+               <h4 id="pps">Using the Pulse-per-Second (PPS) Signal</h4>
+               <p>Most radio clocks are connected using a serial port operating at speeds of 9600 bps or higher. The accuracy using typical timecode formats, where the on-time epoch is indicated by a designated ASCII character, like carriage-return <tt>&lt;cr&gt;</tt>, is limited to a millisecond or two. However, some radios produce a PPS signal which can be used to improve the accuracy with typical workstation servers to the order of microseconds. The details of how this can be accomplished are discussed in the <a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page. The following paragraphs discuss how the PPS signal is affected by the mitigation rules.</p>
+               <p>First, it should be pointed out that the PPS signal is inherently ambiguous, in that it provides a precise seconds epoch, but does not provide a way to number the seconds. In principle and most commonly, another source of synchronization, either the timecode from an associated radio clock, or even one or more remote NTP servers, is available to perform that function. In all cases, a specific, configured peer or server must be designated as associated with the PPS signal. This is done using the <tt>prefer</tt> keyword as described previously. The PPS signal can be associated in this way with any peer, but is most commonly used with the radio clock generating the PPS signal.</p>
+               <p>The PPS signal can be used in two ways to discipline the local clock, one using a special PPS driver described in the <a href="drivers/driver22.html">PPS Clock Discipline</a> page, the other using PPS signal support in the kernel, as described in the <a href="kern.html">A Kernel Model for Precision Timekeeping</a> page. In either case, the signal must be present and within nominal jitter and wander error tolerances. In addition, the associated prefer peer must have survived the sanity checks and intersection algorithms and the dispersion settled below 1 s. This insures that the radio clock hardware is operating correctly and that, presumably, the PPS signal is operating correctly as well. Second, the absolute offset of the local clock from that peer must be less than 128 ms, or well within the 0.5-s unambiguous range of the PPS signal itself. In the case of the PPS driver, the time offsets generated from the PPS signal are propagated via the clock filter to the clock selection procedures just like any other peer. Should these pass the sanity checks and intersection algorithms, they will show up along with the offsets of the prefer peer itself. Note that, unlike the prefer peer, the PPS peer samples are not protected from discard by the clustering algorithm. These complicated procedures insure that the PPS offsets developed in this way are the most accurate, reliable available for synchronization.</p>
+               <p>The PPS peer remains active as long as it survives the intersection algorithm and the prefer peer is reachable; however, like any other clock driver, it runs a reachability algorithm on the PPS signal itself. If for some reason the signal fails or displays gross errors, the PPS peer will either become unreachable or stray out of the survivor population. In this case the clock selection remitigates as described above.</p>
+               <p>When kernel support for the PPS signal is available, the PPS signal is interfaced to the kernel serial driver code via a modem control lead. As the PPS signal is derived from external equipment, cables, etc., which sometimes fail, a good deal of error checking is done in the kernel to detect signal failure and excessive noise. The way in which the mitigation rules affect the kernel discipline is as follows.</p>
+               <p>PPS support requires the PPS driver (type 22) and PPSAPI interface described in the <a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page. In order to operate, the prefer peer must be designated and the kernel support enabled by the <tt>enable pps</tt> command in the configuration file and the signal must be present and within nominal jitter and wander error tolerances. In the NTP daemon, the PPS discipline is active only when the prefer peer is among the survivors of the clustering algorithm, and its absolute offset is within 128 ms, as determined by the PPS driver. Under these conditions the kernel disregards updates produced by the NTP daemon and uses its internal PPS source instead. The kernel maintains a watchdog timer for the PPS signal; if the signal has not been heard or is out of tolerance for more than some interval, currently two minutes, the kernel discipline is declared inoperable and operation continues as if it were not present.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/rdebug.html b/html/rdebug.html
new file mode 100644 (file)
index 0000000..d49514d
--- /dev/null
@@ -0,0 +1,32 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Debugging Reference Clock Drivers</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Debugging Reference Clock Drivers</h3>
+               <img src="pic/oz2.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>The Wizard of Oz</i>, L. Frank Baum</a>
+               <p>Call the girls and the'll sweep your bugs.</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:49</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links10.txt"></script>
+               <h4>More Help</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links12.txt"></script>
+               <hr>
+               <p>The <a href="ntpq.html"><tt>ntpq</tt></a> and <a href="ntpdc.html"><tt>ntpdc</tt></a> utility programs can be used to debug reference clocks, either on the server itself or from another machine elsewhere in the network. The server is compiled, installed and started using the configuration file described in the <a href="ntpd.html"><tt>ntpd</tt></a> page and its dependencies. If the clock appears in the <tt>ntpq</tt> utility and <tt>pe</tt> command, no errors have occurred and the daemon has started, opened the devices specified and waiting for peers and radios to come up. If not, the first thing to look for are error messages on the system log. These are usually due to improper configuration, missing links or multiple instances of the daemon.</p>
+               <p>It normally takes a minute or so for evidence to appear that the clock is running and the driver is operating correctly. The first indication is a nonzero value in the <tt>reach</tt> column in the <tt>pe</tt> billboard. If nothing appears after a few minutes, the next step is to be sure the RS232 messages, if used, are getting to and from the clock. The most reliable way to do this is with an RS232 tester and to look for data flashes as the driver polls the clock and/or as data arrive from the clock. Our experience is that the overwhelming fraction of problems occurring during installation are due to problems such as miswired connectors or improperly configured device links at this stage.</p>
+               <p>If RS232 messages are getting to and from the clock, the variables of interest can be inspected using the <tt>ntpq</tt> program and various commands described on the documentation page. First, use the <tt>pe</tt> and <tt>as</tt> commands to display billboards showing the peer configuration and association IDs for all peers, including the radio clock. The assigned clock address should appear in the <tt>pe</tt> billboard and the association ID for it at the same relative line position in the <tt>as</tt> billboard.</p>
+               <p>Additional information is available with the <tt>rv</tt> and <tt>clockvar</tt> commands, which take as argument the association ID shown in the <tt>as</tt> billboard. The <tt>rv</tt> command with no argument shows the system variables, while the <tt>rv</tt> command with association ID argument shows the peer variables for the clock, as well as other peers of interest. The <tt>clockvar</tt> command with argument shows the peer variables specific to reference clock peers, including the clock status, device name, last received timecode (if relevant), and various event counters. In addition, a subset of the <tt>fudge</tt> parameters is included. The poll and error counters in the <tt>clockvar</tt> billboard are useful debugging aids. The <tt>poll</tt> counts the poll messages sent to the clock, while the <tt>noreply</tt>, <tt>badformat</tt> and <tt>baddate</tt> count various errors. Check the timecode to be sure it matches what the driver expects. This may require consulting the clock hardware reference manual, which is probably pretty dusty at this stage.</p>
+               <p>The <tt>ntpdc</tt> utility program can be used for detailed inspection of the clock driver status. The most useful are the <tt>clockstat</tt> and <tt>clkbug</tt> commands described in the document page. While these commands permit getting quite personal with the particular driver involved, their use is seldom necessary, unless an implementation bug shows up. If all else fails, turn on the debugging trace using two <tt>-d</tt> flags in the <tt>ntpd</tt> startup command line. Most drivers will dump status at every received message in this case. While the displayed trace can be intimidating, this provides the most detailed and revealing indicator of how the driver and clock are performing and where bugs might lurk.</p>
+               <p>Most drivers write a message to the <tt>clockstats</tt> file as each timecode or surrogate is received from the radio clock. By convention, this is the last ASCII timecode (or ASCII gloss of a binary-coded one) received from the radio clock. This file is managed by the <tt>filegen</tt> facility described in the <tt>ntpd</tt> page and requires specific commands in the configuration file. This forms a highly useful record to discover anomalies during regular operation of the clock. The scripts included in the <tt>./scripts/stats</tt> directory can be run from a <tt>cron</tt> job to collect and summarize these data on a daily or weekly basis. The summary files have proven inspirational to detect infrequent misbehavior due to clock implementation bugs in some radios.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/refclock.html b/html/refclock.html
new file mode 100644 (file)
index 0000000..733b7bf
--- /dev/null
@@ -0,0 +1,103 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>Reference Clock Drivers</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Reference Clock Drivers</h3>
+               <img src="pic/stack1a.jpg" alt="gif" align="left">Master Time Facility at the <a href="http://www.eecis.udel.edu/%7emills/lab.html">UDel Internet Research Laboratory</a>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">13:06</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="298">Wednesday, August 10, 2005</csobj></p>
+               <br clear="left">
+               <h4>Related Links</h4>
+               <script type="text/javascript" language="javascript" src="scripts/links10.txt"></script>
+               <h4>Pulse-Per-Second Interfacing Links</h4>
+               <p>
+                       <script type="text/javascript" language="javascript" src="scripts/links11.txt"></script>
+               </p>
+               <h4>Audio Driver Links</h4>
+               <p>
+                       <script type="text/javascript" language="javascript" src="scripts/links8.txt"></script>
+               </p>
+               <h4>Table of Contents</h4>
+               <ul>
+                       <li class="inline"><a href="#clock">Reference Clock Drivers</a>
+                       <li class="inline"><a href="#cal">Driver Calibration</a>
+                       <li class="inline"><a href="#perf">Performance Enhancements</a>
+                       <li class="inline"><a href="#list">Comprehensive List of Clock Drivers</a>
+               </ul>
+               <hr>
+               <h4 id="clock">Reference Clock Drivers</h4>
+               <p>Support for most of the commonly available radio and modem reference clocks is included in the default configuration of the NTP daemon for Unix <tt>ntpd</tt>. Individual clocks can be activated by configuration file commands, specifically the <tt>server</tt> and <tt>fudge</tt> commands described in the <a href="ntpd.html"><tt>ntpd</tt> program manual page</a>. The following discussion presents Information on how to select and configure the device drivers in a running Unix system.</p>
+               <p>Many radio reference clocks can be set to display local time as adjusted for timezone and daylight saving mode. For use with NTP the clock must be set for Coordinated Universal Time (UTC) only. Ordinarily, these adjustments are performed by the kernel, so the fact that the clock runs on UTC will be transparent to the user.</p>
+               <p>Radio and modem clocks by convention have addresses in the form 127.127.<i>t.u</i>, where <i>t</i> is the clock type and <i>u</i> is a unit number in the range 0-3 used to distinguish multiple instances of clocks of the same type. Most of these clocks require support in the form of a serial port or special bus peripheral, but some can work directly from the audio codec found in some workstations. The particular device is normally specified by adding a soft link <tt>/dev/device<i>u</i></tt> to the particular hardware device involved, where <i><tt>u</tt></i> correspond to the unit number above.</p>
+               <p>Most clock drivers communicate with the reference clock using a serial port, usually at 9600 bps. There are several application program interfaces (API) used in the various Unix and NT systems, most of which can be detected at configuration time. Thus, it is important that the NTP daemon and utilities be compiled on the target system or clone. In some cases special features are available, such as timestamping in the kernel or pulse-per-second (PPS) interface. In most cases these features can be detected at configuration time as well; however, the kernel may have to be recompiled in order for them to work.</p>
+               <p>The audio drivers are a special case. These include support for the NIST time/frequency stations WWV and WWVH, the Canadian time/frequency station CHU and generic IRIG signals. Currently, support for the Solaris and SunOS audio API is included in the distribution. It is left to the volunteer corps to extend this support to other systems. Further information on hookup, debugging and monitoring is given in the <a href="audio.html">Audio Drivers</a> page.</p>
+               <p>The local clock driver is also a special case. A server configured with this driver can operate as a primary server to synchronize other clients when no other external synchronization sources are available. If the server is connected directly or indirectly to the public Internet, there is some danger that it can adversely affect the operation of unrelated clients. Carefully read the <a href="drivers/driver1.html">Undisciplined Local Clock</a> page and respect the stratum limit.</p>
+               <p>The local clock driver also supports an external synchronization source such as a high resolution counter disciplined by a GPS receiver, for example. Further information is on the <a href="extern.html">External Clock Discipline and the Local Clock Driver</a> page.</p>
+               <h4 id="cal">Driver Calibration</h4>
+               <p>Some drivers depending on longwave and shortwave radio services need to know the radio propagation time from the transmitter to the receiver, which can amount to some tens of milliseconds. This must be calculated for each specific receiver location and requires the geographic coordinates of both the transmitter and receiver. The transmitter coordinates for various radio services are given in the <a href="http://www.eecis.udel.edu/%7emills/ntp/qth.html">Time and Frequency Standard Station Information</a> page. Receiver coordinates can be obtained or estimated from various sources. The actual calculations are beyond the scope of this document.</p>
+               <p>When more than one clock driver is supported, it is often the case that each shows small systematic offset differences relative to the rest. To reduce the effects of jitter when switching from one driver to the another, it is useful to calibrate the drivers to a common ensemble offset. The <tt>enable calibrate</tt> configuration command in the <a href="miscopt.html">Miscellaneous Options</a> page is useful for this purpose. The calibration function can also be enabled and disabled using the <tt>ntpdc</tt> program utility.</p>
+               <p>Most clock drivers use the <tt>time1</tt> value specified in the <tt>fudge</tt> configuration command to provide the calibration correction when this cannot be provided by the clock or interface. When the calibration function is enabled, the <tt>time1</tt> value is automatically adjusted to match the offset of the remote server or local clock driver selected for synchronization. Ordinarily, the NTP selection algorithm chooses the best from among all sources, usually the best radio clock determined on the basis of stratum, synchronization distance and jitter. The calibration function adjusts the <tt>time1</tt> values for all clock drivers except this source so that their indicated offsets tend to zero. If the selected source is the kernel PPS discipline, the <tt>fudge time1</tt> values for all clock drivers are adjusted.</p>
+               <p>The adjustment function is an exponential average designed to improve accuracy, so the function takes some time to converge. The recommended procedure is to enable the function, let it run for an hour or so, then edit the configuration file using the <tt>time1</tt> values displayed by the <tt>ntpq</tt> utility and <tt>clockvar</tt> command. Finally, disable the calibration function to avoid possible future disruptions due to misbehaving clocks or drivers.</p>
+               <h4 id="perf">Performance Enhancements</h4>
+               <p>In general, performance can be improved, especially when more than one clock driver is supported, to use the prefer peer function described in the <a href="prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a> page. The prefer peer is ordinarily designated the remote peer or local clock driver which provides the best quality time. All other things equal, only the prefer peer source is used to discipline the system clock and jitter-producing &quot;clockhopping&quot; between sources is avoided. This is valuable when more than one clock driver is present and especially valuable when the PPS clock driver (type 22) is used. Support for PPS signals is summarized in the <a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page.</p>
+               <p>Where the highest performance is required, generally better than one millisecond, additional hardware and/or software functions may be required. Kernel modifications for precision time are described in the <a href="kern.html">A Kernel Model for Precision Timekeeping</a> page. Special line discipline and streams modules for use in capturing precision timestamps are described in the <a href="ldisc.html">Line Disciplines and Streams Drivers</a> page.</p>
+               <h4 id="list">Comprehensive List of Clock Drivers</h4>
+               <p>Following is a list showing the type and title of each driver currently implemented. The compile-time identifier for each is shown in parentheses. Click on a selected type for specific description and configuration documentation, including the clock address, reference ID, driver ID, device name and serial line speed, and features (line disciplines, etc.). For those drivers without specific documentation, please contact the author listed in the <a href="copyright.html">Copyright Notice</a> page.</p>
+               <ul>
+                       <li class="inline"><a href="drivers/driver1.html">Type 1</a> Undisciplined Local Clock (<tt>LOCAL</tt>)
+                       <li class="inline"><a href="drivers/driver2.html">Type 2</a> Trak 8820 GPS Receiver (<tt>GPS_TRAK</tt>)
+                       <li class="inline"><a href="drivers/driver3.html">Type 3</a> PSTI/Traconex 1020 WWV/WWVH Receiver (<tt>WWV_PST</tt>)
+                       <li class="inline"><a href="drivers/driver4.html">Type 4</a> Spectracom WWVB and GPS Receivers (<tt>WWVB_SPEC</tt>)
+                       <li class="inline"><a href="drivers/driver5.html">Type 5</a> TrueTime GPS/GOES/OMEGA Receivers (<tt>TRUETIME</tt>)
+                       <li class="inline"><a href="drivers/driver6.html">Type 6</a> IRIG Audio Decoder (<tt>IRIG_AUDIO</tt>)
+                       <li class="inline"><a href="drivers/driver7.html">Type 7</a> Radio CHU Audio Demodulator/Decoder (<tt>CHU</tt>)
+                       <li class="inline"><a href="drivers/driver8.html">Type 8</a> Generic Reference Driver (<tt>PARSE</tt>)
+                       <li class="inline"><a href="drivers/driver9.html">Type 9</a> Magnavox MX4200 GPS Receiver (<tt>GPS_MX4200</tt>)
+                       <li class="inline"><a href="drivers/driver10.html">Type 10</a> Austron 2200A/2201A GPS Receivers (<tt>GPS_AS2201</tt>)
+                       <li class="inline"><a href="drivers/driver11.html">Type 11</a> Arbiter 1088A/B GPS Receiver (<tt>GPS_ARBITER</tt>)
+                       <li class="inline"><a href="drivers/driver12.html">Type 12</a> KSI/Odetics TPRO/S IRIG Interface (<tt>IRIG_TPRO</tt>)
+                       <li class="inline">Type 13 Leitch CSD 5300 Master Clock Controller (<tt>ATOM_LEITCH</tt>)
+                       <li class="inline">Type 14 EES M201 MSF Receiver (<tt>MSF_EES</tt>)
+                       <li class="inline">Type 15 reserved
+                       <li class="inline"><a href="drivers/driver16.html">Type 16</a> Bancomm GPS/IRIG Receiver (<tt>GPS_BANCOMM</tt>)
+                       <li class="inline">Type 17 Datum Precision Time System (<tt>GPS_DATUM</tt>)
+                       <li class="inline"><a href="drivers/driver18.html">Type 18</a> Automated Computer Time Service (<tt>ACTS_MODEM</tt>)
+                       <li class="inline"><a href="drivers/driver19.html">Type 19</a> Heath WWV/WWVH Receiver (<tt>WWV_HEATH</tt>)
+                       <li class="inline"><a href="drivers/driver20.html">Type 20</a> Generic NMEA GPS Receiver (<tt>NMEA</tt>)
+                       <li class="inline">Type 21 TrueTime GPS-VME Interface (<tt>GPS_VME</tt>)
+                       <li class="inline"><a href="drivers/driver22.html">Type 22</a> PPS Clock Discipline (<tt>PPS</tt>)
+                       <li class="inline">Type 23 reserved
+                       <li class="inline">Type 24 reserved
+                       <li class="inline">Type 25 reserved
+                       <li class="inline"><a href="drivers/driver26.html">Type 26</a> Hewlett Packard 58503A GPS Receiver (<tt>GPS_HP</tt>)
+                       <li class="inline"><a href="drivers/driver27.html">Type 27</a> Arcron MSF Receiver (<tt>MSF_ARCRON</tt>)
+                       <li class="inline"><a href="drivers/driver28.html">Type 28</a> Shared Memory Driver (<tt>SHM</tt>)
+                       <li class="inline"><a href="drivers/driver29.html">Type 29</a> Trimble Navigation Palisade GPS (<tt>GPS_PALISADE</tt>)
+                       <li class="inline"><a href="drivers/driver30.html">Type 30</a> Motorola UT Oncore GPS <tt>GPS_ONCORE</tt>)
+                       <li class="inline"><a href="drivers/driver31.html">Type 31</a> Rockwell Jupiter GPS (<tt>GPS_JUPITER</tt>)
+                       <li class="inline"><a href="drivers/driver32.html">Type 32</a> Chrono-log K-series WWVB receiver (<tt>CHRONOLOG</tt>)
+                       <li class="inline"><a href="drivers/driver33.html">Type 33</a> Dumb Clock (<tt>DUMBCLOCK</tt>)
+                       <li class="inline"><a href="drivers/driver34.html">Type 34</a> Ultralink WWVB Receivers (<tt>ULINK</tt>)
+                       <li class="inline"><a href="drivers/driver35.html">Type 35</a> Conrad Parallel Port Radio Clock (<tt>PCF</tt>)
+                       <li class="inline"><a href="drivers/driver36.html">Type 36</a> Radio WWV/H Audio Demodulator/Decoder (<tt>WWV</tt>)
+                       <li class="inline"><a href="drivers/driver37.html">Type 37</a> Forum Graphic GPS Dating station (<tt>FG</tt>)
+                       <li class="inline"><a href="drivers/driver38.html">Type 38</a> hopf GPS/DCF77 6021/komp for Serial Line (<tt>HOPF_S</tt>)
+                       <li class="inline"><a href="drivers/driver39.html">Type 39</a> hopf GPS/DCF77 6039 for PCI-Bus (<tt>HOPF_P</tt>)
+                       <li class="inline"><a href="drivers/driver40.html">Type 40</a> JJY Receivers (<tt>JJY</tt>)
+                       <li class="inline">Type 41 TrueTime 560 IRIG-B Decoder
+                       <li class="inline"><a href="drivers/driver42.html">Type 42</a> Zyfer GPStarplus Receiver
+                       <li class="inline"><a href="drivers/driver43.html">Type 43</a> RIPE NCC interface for Trimble Palisade
+                       <li class="inline"><a href="drivers/driver44.html">Type 44</a> NeoClock4X - DCF77 / TDF serial line
+               </ul>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/release.html b/html/release.html
new file mode 100644 (file)
index 0000000..b2f4d05
--- /dev/null
@@ -0,0 +1,70 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>NTP Version 4 Release Notes</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>NTP Version 4 Release Notes</h3>
+               <img src="pic/hornraba.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/%7emills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>The rabbit toots to make sure you read this</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">19:17</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="270">Monday, October 10, 2005</csobj></p>
+               .<br clear="left">
+               <hr>
+               <h4>NTP Version 4 Release Notes</h4>
+               <p>This release of the NTP Version 4 (NTPv4) daemon for Unix, VMS and Windows incorporates new features and refinements to the NTP Version 3 (NTPv3) algorithms. However, it continues the tradition of retaining backwards compatibility with older versions, including NTPv3 and NTPv2, but not NTPv1. Support for NTPv1 has been discontinued because of certain security vulnerabilities. The NTPv4 version has been under development for quite a while and isn't finished yet. In fact, quite a number of NTPv4 features have already been retrofitted in the older NTPv3, although this version is not actively maintained by the NTPv4 developer corps.</p>
+               <p>The code compiles and runs properly in all test host configurations available to the developer corps, including Sun Microsystems, Digital/Compaq, Hewlett Packard, FreeBSD and Linux. Other volunteers have verified it works in IRIX and Windows NT and XP. We invite comments and corrections about the various architectures, operating systems and hardware complement that can't be verified by the developer corps. Of particular interest are other Windows versions, VMS and various reference clock drivers. As always, corrections and bugfixes are warmly received, especially in the form of context diffs sent to <a href="mailto:bugs@ntp.org">bugs@ntp.org</a>.</p>
+               <p>This release has been compiled and tested on many systems, including SunOS 4.1.3, Solaris 2.5.1-2.10, Alpha Tru64 4.0-5.1, Ultrix 4.4, Linux 2.4.2, FreeBSD 4.5-5.3 and HP-UX 10.02. It has been compiled and tested by others on Windows NT4, 2000 and XP, but not yet on other Windows versions or for VMS. There are several new features apparently incompatible with Linux systems, including some modes used with the Autokey protocol. The developer corps looks for help elsewhere to resolve these differences.</p>
+               <p>This note summarizes the differences between this software release of NTPv4, called ntp-4.x.x, and the previous NTPv3 version, called xntp3-5.x.x. Additional information on protocol compatibility details is on the <a href="http://www.eecis.udel.edu/%7emills/biblio.html">Protocol Conformance Statement</a> page.</p>
+               <h4>New Features</h4>
+               <ol>
+                       <li>Support for the IPv6 addressing family is included in this distribution. If the Basic Socket Interface Extensions for IPv6 (RFC-2553) is detected, support for the IPv6 address family is generated in addition to the default support for the IPv4 address family. Combination IPv6 and IPv4 configurations have been successfully tested in all protocol modes supported by NTP and using both symmetric and public key (Autokey) cryptography. However, users should note that IPv6 support is new and we have not had a lot of experience with it in various operational scenarios and local infrastructure environments. As always, feedback is welcome.
+                       <li>Most calculations are now done using 64-bit floating double format, rather than 64-bit fixed point format. The motivation for this is to reduce size, improve speed and avoid messy bounds checking. Workstations of today are much faster than when the original NTP version was designed in the early 1980s, and it is rare to find a processor architecture that does not support floating double. The fixed point format is still used with raw timestamps, in order to retain the full precision of about 212 picoseconds. However, the algorithms which process raw timestamps all produce fixed point differences before converting to floating double. The differences are ordinarily quite small so can be expressed without loss of accuracy in this format.
+                       
+                       <li>The clock discipline algorithm has been redesigned to improve accuracy, reduce the impact of network jitter and allow increased in poll intervals to well over one day with only moderate sacrifice in accuracy.
+               </ol>
+               <ul>
+                       <ul>
+                               <li>A new feature called <i>huffpuff</i> maximizes accuracy in cases of highly asymmetric network delays typical of ISDN and modem access circuits.
+                               <li>The NTPv4 design allows clients to increase the poll intervals even when synchronized directly to the server. In NTPv3 the poll interval in such cases was clamped to the minimum, usually 64 s. For those servers with hundreds of clients, the new design can dramatically reduce the network load, especially when large numbers of potential clients, as in national laboratory services.
+                               <li>A scheme designed to reduce &quot;clockhopping&quot; when the choice of servers changes frequently as the result of comparatively insignificant quality changes.
+                       </ul>
+               </ul>
+               <ol>
+                       <li>This release includes support for the <a href="ftp://ftp.udel.edu/usa/ftp/pub/ntp/software/"><i>nanokernel</i></a> precision time kernel support, which is now in stock FreeBSD and optional Linux kernels. If a precision time source such as a GPS timing receiver or cesium clock is available, kernel timekeeping can be improved to the order of one microsecond. The older <i>microtime</i> kernel for Digital/Compaq/HP Tru64, Digital Ultrix, as well as Sun Microsystems SunOS and Solaris, continues to be supported.
+                       <li>This release includes support for Autokey public-key cryptography, which is the preferred scheme for authenticating servers to clients. Autokey Version 2 uses NTP header extension fields and protocols as described on the NTP project page linked from www.ntp.org. This release includes support for additional message digest and digital signature schemes supported by the OpenSSL software library, as well as new identity schemes based on cryptographic challenge/responce algorithms. The new design greatly simplifies key generation and distribution and provides orderly key refreshment. Security procedures and media formats are consistent with industry standard X.509 Version 3 certificates and authority procedures. Specific improvements to the protocol include a reduction in the number of messages required and a method to protect the cookie used in client/server mode against disclosure. Additional information about Autokey cryptography is contained in the <a href="authopt.html">Authentication Options</a> page and links from there. See also the new <tt>cryptostats</tt> monitoring statistics file in the <a href="monopt.html">Monitoring Options</a> page.
+                       <li>This release includes support for a discrete event simulator (DES), which allows the NTP&nbsp;algorithms to be tested in an embedded environment with systematic and pseudorandom network delay and oscillator wander distributions. This has been used to verify correct operation under conditions of extreme error and misconfiguration. See the <a href="ntpdsim.html"><tt>ntpdsim</tt> - Network Time Protocol (NTP) simulator</a> page.
+                       <li>NTPv4 includes two new association modes which in most applications can avoid per-host configuration altogether. Both of these are based on IP multicast technology and Autokey cryptography. They provide automatic discovery, configuration and authentication of servers and clients without identifying servers or clients in advance. In multicast mode a server sends a message at fixed intervals using specified multicast group addresses, while clients listen on these addresses.
+                               <p>Upon receiving the the first message, a client exchanges several messages with the server in order to calibrate the multicast propagation delay between the client and server and run the authentication protocol. In manycast mode a client sends a message to a specified multicast group address and expects one or more servers to reply. Using engineered algorithms, the client selects an appropriate subset of servers from the messages received and continues an ordinary client/server campaign. The manycast scheme can provide somewhat better accuracy than the multicast scheme at the price of additional network overhead. See the <a href="manyopt.html">Automatic NTP Configuration Options</a> page for further information.</p>
+                       <li>This release includes support for the orphan mode, which replaces the local clock driver for most configurations. The local clock driver provides a synchronization source for networks not connected to the public Internet or reference clock driver. However, it does not opperate with multiple sources nor multiple failures. The orphan mode provides an automatic, subnet-wide synchronization feature with multiple sources. It can be used in isolated networks or in Internet subnets where the servers or Internet connection have failed. See the <a href="manyopt.html">Automatic NTP Configuration Options</a> page for further information.<li>This release includes support for preemptable servers, which are provisionally mobilized in manycast mode or by participants in the pool scheme. Manycast mode is described in these notes. In the pool scheme multiple client associations are mobilized for a designated DNS&nbsp;name such as pool.ntp.org. The DNS resolver randomizes replies over a set of volunteer service providers. The NTP&nbsp;mitigation algorithms select the best three from among the set and demobilizes the excess. See the <a href="manyopt.html">Automatic NTP Configuration Options</a> page for further information.<li>There are two burst mode features available where special conditions apply. One of these is enabled by the <tt>iburst</tt> keyword in the <tt>server</tt> configuration command. It is intended for cases where it is important to set the clock quickly when an association is first mobilized. The other is enabled by the <tt>burst</tt> keyword in the <tt>server</tt> configuration command. It is intended for cases where the network attachment requires an initial calling or training procedure. See the <a href="assoc.html">Association Management</a> page for further information.
+                       <li>The reference clock driver interface is smaller, more rational and more accurate. Support for pulse-per-second (PPS) signals has been extended to all drivers as an intrinsic function. Most of the drivers in NTPv3 have been converted to the NTPv4 interface and continue to operate as before. New drivers have been added for several GPS receivers now on the market for a total of 44 drivers. Audio drivers for the Canadian standard time and frequency station CHU, the US standard time and frequency stations WWV/H and for IRIG signals have been updated and capabilities added to allow direct connection of these signals to a Sun or FreeBSD audio port. See the <a href="audio.html">Reference Clock Audio Drivers</a> page for further information.
+                       <li>In all except a very few cases, all timing intervals are randomized, so that the tendency for NTPv3 to self-synchronize and bunch messages, especially with a large number of configured associations, is minimized.
+                       <li>In NTPv3 a large number of weeds and useless code had grown over the years since the original NTPv1 code was implemented almost twenty years ago. Using a powerful weedwacker, much of the shrubbery has been removed, with effect a substantial reduction in size of almost 40 percent.
+                       <li>The entire distribution has been converted to gnu <tt>automake</tt>, which should greatly ease the task of porting to new and different programming environments, as well as reduce the incidence of bugs due to improper handling of idiosyncratic kernel functions. Version control is provided by <tt>Bitkeeper</tt> using an online repository at www.ntp.org.
+                       <li>Several new options have been added for the <tt>ntpd</tt> command line. For the inveterate knob twiddlers several of the more important performance variables can be changed to fit actual or perceived special conditions. In particular, the tos command can be used to limit the accepted stratum range, specify minimum dispersion increment and maximum selection theshold, and activate orphan mode.
+                       <li>The <tt>ntpd</tt> daemon can be operated in a one-time mode similar to <tt>ntpdate</tt>, which program is headed for retirement. See the <a href="ntpd.html"><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</a> page for the new features.
+               </ol>
+               <h4>Nasty Surprises</h4>
+               <p>There are a few things different about this release that have changed since the latest NTP Version 3 release. Following are a few things to worry about:</p>
+               <ol>
+                       <li>When both IPv4 and IPv6 address families are in use, the host's resolver library may not choose the intended address family if a server has an IPv4 and IPv6 address associated with the same DNS name. The solution is to use the IPv4 or IPv6 address directly in such cases or use another DNS name that resolves to the intended address family. Older versions of <tt>ntpdc</tt> will only show the IPv4 associations with the <tt>peers</tt> and other simular commands. Older versions of <tt>ntpq</tt> will show 0.0.0.0 for IPv6 associations with the <tt>peers</tt> and other simular commands.
+                       <li>There is a minor change to the reference ID field of the NTP packet header when operating with IPv6 associations. In IPv4 associations this field contains the 32-bit IPv4 address of the server, in order to detect and avoid loops. In IPv6 associations this field contains the first 32-bits of a MD5 hash formed from the address (IPv4 or IPv6) each of the configured associations. Normally, this detail would not be of concern; however, the <tt>ntptrace</tt> program originally depended on that field in order to display a server traceback to the primary reference source. This program has now been replaced by a script that does the same function, but does not depend on the reference ID field. The <tt>ntpdc</tt> utility now uses a special version number to communicate with the <tt>ntpd</tt> server. The server uses this version number to select which address family to used in reply packets. The <tt>ntpdc</tt> program falls back to the older version behavior when communicating with older NTP versions.
+                       <li>As required by Defense Trade Regulations (DTR), the cryptographic routines supporting the Data Encryption Standard (DES) have been removed from the base distribution of NTPv3. For NTPv4 a new interface has been implemented for the OpenSSL cryptographic library, which is widely available on the web at www.openssl.org. This library replaces the library formerly available from RSA Laboratories. Besides being somewhat faster and more widely available, the OpenSSL library supports many additional cryptographic algorithms, which are now selectable at run time. Directions for using OpenSSL are in the <a href="build/build.html">Building and Installing the Distribution</a> page.
+                       <li>As the result of the above, the <tt>./authstuff</tt> directory, intended as a development and testing aid for porting cryptographic routines to exotic architectures, has been removed. Testing and conformance validation tools are in the OpenSSL software distrbution.
+                       <li>The NTPv4 enable and disable commands have a few changes in the arguments. See the <tt>ntpd</tt> <a href="miscopt.html">Miscellaneous Options</a> page for details. Note that the <tt>authenticate</tt> command has been removed.
+                       <li>To help reduce the level of spurious network traffic due to obsolete configuration files, a special control message called the <i>kiss-o'-death</i> packet has been implemented. If enabled and a packet is denied service or exceeds the client limits, a compliant server will send this message to the client. A compliant client will cease further transmission and send a message to the system log. See the <a href="accopt.html">Authentication Options</a> page for further information.
+                       <li>The <tt>tty_clk</tt> and <tt>ppsclock</tt> pulse-per-second (PPS) line discipline/streams modules are no longer supported. The PPS function is now handled by the <a href="drivers/driver22.html">PPS Clock Discipline</a> driver, which uses the new PPSAPI application program interface adopted by the IETF. Note that the <tt>pps</tt> configuration file command has been obsoleted by the driver. See the <a href="pps.html">Pulse-per-second (PPS) Signal Interfacing</a> page for further information.
+                       <li>Support for the NTPv1 symmetric mode has been discontinued, since it hasn't worked for years. Support continues for the NTPv1 client mode, which is used in some SNTP clients.
+                       <li>The precision time support in stock Solaris 2.6 has bugs that were fixed in 2.7. A patch is available that fixes the 2.6 bugs. The 2.6 PPS kernel discipline has been disabled by default. For testing, the kernel can be enabled using the <tt>enable kernel</tt> command either in the configuration file or via <tt>ntpdc</tt>.
+                       <li>The HTML documentation has been partially updated. However, most of the NTPv3 documentation continues to apply to NTPv4. Until a comprehensive update happens, what you see is what you get. We are always happy to accept comments, corrections and bug reports. However, we are most thrilled upon receipt of patches to fix the dang bugs. <b>Please send bug reports to <a href="mailto:bugs@ntp.org">bugs@ntp.org</a>, not the individual members on the team</b>.
+               </ol>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/scripts/footer.txt b/html/scripts/footer.txt
new file mode 100644 (file)
index 0000000..7fc6dd8
--- /dev/null
@@ -0,0 +1,7 @@
+document.write("\\r
+<table><tr>\\r
+<td width='50%' ><img src='icons/home.gif' align='middle' alt='gif'>\\r
+<a href='index.html'>Home Page</a></td>\\r
+<td width='50%' ><img src='icons/mail2.gif' align='middle' alt='gif'>\\r
+<a href='http://www.ntp.org/contact.html'>Contacts</a></i></td>\
+</tr></table>")
\ No newline at end of file
diff --git a/html/scripts/links10.txt b/html/scripts/links10.txt
new file mode 100644 (file)
index 0000000..880e379
--- /dev/null
@@ -0,0 +1,5 @@
+document.write("<ul>\\r
+<li class='inline'><a href='refclock.html'>Reference Clock Drivers</a><br>\\r
+<li class='inline'><a href='prefer.html'>Mitigation Rules and the <tt>prefer</tt> Keyword</a><br>\\r
+<li class='inline'><a href='howto.html'>How to Write a Reference Clock Driver</a><br>\\r
+</ul>")
\ No newline at end of file
diff --git a/html/scripts/links11.txt b/html/scripts/links11.txt
new file mode 100644 (file)
index 0000000..59e7017
--- /dev/null
@@ -0,0 +1,7 @@
+document.write("<ul>\\r
+<li class='inline'><a href='refclock.html'>Reference Clock Drivers</a><br>\\r
+<li class='inline'><a href='pps.html'>Pulse-per-second (PPS) Signal Interfacing</a><br>\\r
+<li class='inline'><a href='ldisc.html'>Line Disciplines and Streams Modules</a><br>\\r
+<li class='inline'><a href='kernpps.html'>PPSAPI Interface for Precision Time Signals</a><br>\
+<li class='inline'><a href='gadget.html'>Gadget Box PPS Level Converter and CHU Modem</a><br>\
+</ul>")
\ No newline at end of file
diff --git a/html/scripts/links12.txt b/html/scripts/links12.txt
new file mode 100644 (file)
index 0000000..7ca9249
--- /dev/null
@@ -0,0 +1,5 @@
+document.write("<ul>\\r
+<li class='inline'><a href='debug.html'>NTP Debugging Techniques</a><br>\\r
+<li class='inline'><a href='rdebug.html'>Debugging Reference Clock Drivers</a><br>\\r
+<li class='inline'><a href='msyslog.html'><tt>ntpd</tt> System Log Messages</a><br>\\r
+</ul>")
\ No newline at end of file
diff --git a/html/scripts/links7.txt b/html/scripts/links7.txt
new file mode 100644 (file)
index 0000000..0d33473
--- /dev/null
@@ -0,0 +1,6 @@
+document.write("<ul>\\r
+<li class='inline'><a href='confopt.html'>Server Options</a><br>\\r
+<li class='inline'><a href='authopt.html'>Authentication Options</a><br>\\r
+<li class='inline'><a href='monopt.html'>Monitoring Options</a><br>\\r
+<li class='inline'><a href='ntp_conf.html'>Configuration File Definition (Advanced)</a><br>\
+</ul>")
\ No newline at end of file
diff --git a/html/scripts/links8.txt b/html/scripts/links8.txt
new file mode 100644 (file)
index 0000000..135310c
--- /dev/null
@@ -0,0 +1,6 @@
+document.write("<ul>\\r
+<li class='inline'><a href='refclock.html'>Reference Clock Drivers</a><br>\\r
+<li class='inline'><a href='drivers/driver7.html'>Radio CHU Audio Demodulator/Decoder</a><br>\
+<li class='inline'><a href='drivers/driver36.html'>Radio WWV/H Audio Demodulator/Decoder</a><br>\
+<li class='inline'><a href='drivers/driver6.html'>IRIG Audio Decoder</a>\
+</ul>")
\ No newline at end of file
diff --git a/html/scripts/links9.txt b/html/scripts/links9.txt
new file mode 100644 (file)
index 0000000..6ea32f0
--- /dev/null
@@ -0,0 +1,8 @@
+document.write("<ul>\\r
+<li class='inline'><a href='authopt.html'>Authentication Options</a><br>\\r
+<li class='inline'><a href='manyopt.html'>Automatic NTP Configuration Options</a><br>\\r
+<li class='inline'><a href='confopt.html'>Server Options</a><br>\\r
+<li class='inline'><a href='groups.html'>Trusted Hosts and Groups</a><br>\
+<li class='inline'><a href='keygen.html'><tt>ntp-keygen</tt> - generate public and private keys</a>\
+<li class='inline'><a href='http://www.eecis.udel.edu/~mills/autokey.html'>Autonomous Authentication</a>\\r
+</ul>")
\ No newline at end of file
diff --git a/html/scripts/style.css b/html/scripts/style.css
new file mode 100644 (file)
index 0000000..7d7b276
--- /dev/null
@@ -0,0 +1,64 @@
+body {background: #FDF1E1;\r
+      color: #006600;\r
+      font-family: "verdana", sans-serif;
+      text-align: justify;\r
+      margin-left: 5px;}\r
+\r
+p, h4, hr, li {margin-top: .6em; margin-bottom: .6em}\r
+li.inline {text-align: left; margin-top: 0; margin-bottom: 0}\r
+\r
+ul, dl, ol, {margin-top: .6em; margin-bottom: .6em; margin-left 5em}\r
+\r
+dt {margin-top: .6em}\r
+dd {margin-bottom: .6em}\r
+\r
+div.header {text-align: center;\r
+            font-style: italic;}\r
+\r
+div.footer {text-align: center;         \r
+            font-size: 60%;}\r
+\r
+img.cell {align: left;}\r
+\r
+td.sidebar {width: 40px; align: center; valign: top;}\r
+img.sidebar {align: center; margin-top: 5px;}\r
+h4.sidebar {align: center;}\r
+\r
+p.top {background: #FDF1E1;\r
+       color: #006600;\r
+       position: absolute;\r
+       margin-left: -90px;\r
+       text-align: center;}\r
+\r
+a:link.sidebar {background: transparent;\r
+                color: #990033;\r
+                font-weight: bold;}\r
+\r
+a:visited.sidebar {background: transparent;\r
+                   color: #990033;\r
+                   font-weight: bold;}\r
+\r
+a:hover.sidebar {background: #FDF1E1;\r
+                 color: #006600;}\r
+\r
+img {margin: 5px;}\r
+\r
+div {text-align: center;}\r
+\r
+h1 {text-align: center;\r
+    font-size: 250%;}\r
+\r
+caption {background: #EEEEEE;\r
+         color: #339999;}\r
+         \r
+tx {text-align: center;}\r
+\r
+th {background: #FFFFCC;\r
+    color: #006600;\r
+    text-align: center;\r
+    text-decoration: underline;\r
+    padding-top: 5px;}\r
+\r
+th.caption {background: #EEEEEE;\r
+            color: #006600;\r
+            text-align: center;}
\ No newline at end of file
diff --git a/html/sntp.html b/html/sntp.html
new file mode 100644 (file)
index 0000000..839271e
--- /dev/null
@@ -0,0 +1,57 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <title>Simple Network Time Protocol (SNTP) Client</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3>Simple Network Time Protocol (SNTP) Client</h3>
+               <img src="pic/dogsnake.gif" alt="gif" align="left"><a href="http://www.eecis.udel.edu/~mills/pictures.html">from <i>Alice's Adventures in Wonderland</i>, Lewis Carroll</a>
+               <p>S is for snakeoil</p>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:50</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <br clear="left">
+               <hr>
+               <h4>Synopsis</h4>
+               <tt>sntp [{-h --help -?}][{ -v -V -W }][{-r -a}][-P <i>prompt</i>][-e <i>minerr</i>][-E <i>maxerr</i>][-c <i>count</i>][-d <i>delay</i>][address(es)]</tt>
+               <h4>Description</h4>
+               <p>This program is a Simple Network Time Protocol (SNTP) client that can be used to query a Network TIme Protocol (NTP) server and display the time offset of the system clock relative to the server clock. Run as root it can correct the system clock to this offset as well. It can be run as an interactive command or from a script by a <tt>cron</tt> job. The program implements the SNTP protocol defined in RFC-2030, which is a subset of the NTP&nbsp;protocol defined in RFC-1305, but does not provide the sanity checks, access controls, security functions and mitigation algorithms as in the full NTP implementation.</p>
+               <p>While this program can do other things, including operation as a primitive server, some of these things are truly dangerous in a ubiquitous public time server network. A full disclosure is in the man page in the <tt>./sntp</tt> directory, but be truly advised RFC-2030 specifically <b>forbids</b> a SNTP client to operate as a server for other NTP or SNTP&nbsp;clients. If such operation is contemplated, do <b>not</b>&nbsp;allow access by clients on the public Internet.</p>
+               <p>By default, <tt>sntp</tt> writes the local date and time (i.e., not UTC) to the standard output in the format</p>
+               <p><tt>1996 Oct 15 20:17:25.123 + 4.567 +/- 0.089 secs</tt>,</p>
+               <p>where the <tt>+ 4.567 +/- 0.089 secs</tt> indicates the time offset and error bound of the system clock relative to the server clock.</p>
+               <p>If a NTP&nbsp;server <i>address</i> is explicitly specified, the program sends a single message to the server and waits up to <i>delay</i> seconds for a unicast server message. Otherwise, it sends no message and waits up to <i>delay</i> seconds for a broadcast server message.</p>
+               <h4>Options</h4>
+               <p><tt>sntp</tt> recognizes the following options:</p>
+               <dl>
+                       <dt><tt>-h, --help</tt>
+                       <dd>displays usage information.
+                       <dt><tt>-v</tt>
+                       <dd>writes diagnostic messages and a limited amount of tracing to standard error. The <tt>-v, -V</tt> and <tt>-W</tt> give increasing levels of detail.
+                       <dt><tt>-r</tt>
+                       <dd>steps the system clock to the correct time by the Unix <tt>settimeofday</tt> system call. Requires root priviledge.
+                       <dt><tt>-a</tt>
+                       <dd>slews the system clock to the correct time by the Unix <tt>adjtime</tt> system call. Requires root priviledge.
+                       <dt><tt>-e <i>minerr</i></tt>
+                       <dd>sets the minimum offset to <tt><i>minerr</i></tt> seconds. Measured offsets less than this are ignored. Acceptable values are from 0.001 to 1 with default 0.1 if unicast mode and 0.5 for broadcast mode.
+                       <dt><tt>-E <i>maxerr</i></tt>
+                       <dd>sets the maximum offset to <tt><i>maxerr</i></tt> seconds. Measured offsets greater than this are ignored. Acceptable values are from 1 to 60 with default 5.
+                       <dt><tt>-P <i>prompt</i></tt>
+                       <dd>sets the maximum automatic offset to <tt><i>maxerr</i></tt> seconds. Acceptable values are from 1 to 3600 or <tt>no</tt>, with default 30. If the program is being run interactively, measured offsets greater than this will prompt the user for confirmation. Specifying <tt>no</tt> will disable this and the correction will be made regardless.
+                       <dt><tt>-c <i>count</i></tt>
+                       <dd>sets the maximum number of NTP packets required to <i>count</i>. Acceptable values are from 1 to 25 in unicast mode and 5 to 25 in broadcast mode. The default is 5 in either mode.
+                       <dt><tt>-d <i>delay</i></tt>
+                       <dd>sets the maximum waiting time in broadcast mode to <i>delay</i> seconds. Acceptable values are from 1 to 3600, with default 15 in unicast mode and 300 in broadcast mode.
+               </dl>
+               <h4>Return Value</h4>
+               <p>The program returns an exit status of zero for success and non-zero otherwise.</p>
+               <h4>Author</h4>
+               <p><tt>sntp</tt> was developed by N.M. Maclaren of the University of Cambridge Computing Service.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/html/tickadj.html b/html/tickadj.html
new file mode 100644 (file)
index 0000000..14559ed
--- /dev/null
@@ -0,0 +1,49 @@
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
+
+<html>
+
+       <head>
+               <meta http-equiv="content-type" content="text/html;charset=iso-8859-1">
+               <meta name="generator" content="HTML Tidy, see www.w3.org">
+               <title>tickadj - set time-related kernel variables</title>
+               <link href="scripts/style.css" type="text/css" rel="stylesheet">
+       </head>
+
+       <body>
+               <h3><tt>tickadj</tt> - set time-related kernel variables</h3>
+               <p>Last update: <csobj format="ShortTime" h="25" locale="00000409" region="0" t="DateTime" w="61">18:50</csobj> UTC <csobj format="LongDate" h="25" locale="00000409" region="0" t="DateTime" w="246">Thursday, July 28, 2005</csobj></p>
+               <hr>
+               <h4>Synopsis</h4>
+               <tt>tickadj [ -Aqs ] [ -a <i>tickadj</i> ] [ -t <i>tick</i> ]</tt>
+               <h4>Description</h4>
+               <p>The <tt>tickadj</tt> program reads, and optionally modifies, several timekeeping-related variables in older kernels that do not have support for precision ttimekeeping, including HP-UX, SunOS, Ultrix, SGI and probably others. Those machines provide means to patch the kernel <tt>/dev/kmem</tt>. Newer machines with precision time support, including Solaris, Tru64, FreeBSD and Linux (with PPSkit patch) should NOT use the program. The particular variables that can be changed with <tt>tickadj</tt> include <tt>tick</tt>, which is the number of microseconds added to the system time for a clock interrupt, <tt>tickadj</tt>, which sets the slew rate and resolution used by the <tt>adjtime</tt> system call, and <tt>dosynctodr</tt>, which indicates to the kernels on some machines whether they should internally adjust the system clock to keep it in line with time-of-day clock or not.</p>
+               <p>By default, with no arguments, <tt>tickadj</tt> reads the variables of interest in the kernel and displays them. At the same time, it determines an &quot;optimal&quot; value for the value of the <tt>tickadj</tt> variable if the intent is to run the <tt>ntpd</tt> Network Time Protocol (NTP) daemon, and prints this as well. Since the operation of <tt>tickadj</tt> when reading the kernel mimics the operation of similar parts of the <tt>ntpd</tt> program fairly closely, this can be useful when debugging problems with <tt>ntpd</tt>.</p>
+               <p>Note that <tt>tickadj</tt> should be run with some caution when being used for the first time on different types of machines. The operations which <tt>tickadj</tt> tries to perform are not guaranteed to work on all Unix machines and may in rare cases cause the kernel to crash.</p>
+               <h4>Command Line Options</h4>
+               <dl>
+                       <dt><tt>-a <i>tickadj</i></tt>
+                       <dd>Set the kernel variable <tt>tickadj</tt> to the value <i><tt>tickadj</tt></i>specified.
+                       <dt><tt>-A</tt>
+                       <dd>Set the kernel variable <tt>tickadj</tt> to an internally computed &quot;optimal&quot; value.
+                       <dt><tt>-t <i>tick</i></tt>
+                       <dd>Set the kernel variable <tt>tick</tt> to the value <i><tt>tick</tt></i> specified.
+                       <dt><tt>-s</tt>
+                       <dd>Set the kernel variable <tt>dosynctodr</tt> to zero, which disables the hardware time-of-year clock, a prerequisite for running the <tt>ntpd</tt> daemon under SunOS4.
+                       <dt><tt>-q</tt>
+                       <dd>Normally, <tt>tickadj</tt> is quite verbose about what it is doing. The <tt>-q</tt> flag tells it to shut up about everything except errors.
+               </dl>
+               <h4>Files</h4>
+               <pre>
+/vmunix
+
+/unix
+
+/dev/kmem
+</pre>
+               <h4>Bugs</h4>
+               Fiddling with kernel variables at run time as a part of ordinary operations is a hideous practice which is only necessary to make up for deficiencies in the implementation of <tt>adjtime</tt> in many kernels and/or brokenness of the system clock in some vendors' kernels. It would be much better if the kernels were fixed and the <tt>tickadj</tt> program went away.
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+
+</html>
\ No newline at end of file
diff --git a/include/Makefile.am b/include/Makefile.am
new file mode 100644 (file)
index 0000000..1fbe6fc
--- /dev/null
@@ -0,0 +1,63 @@
+#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+ETAGS_ARGS = $(srcdir)/Makefile.am
+EXTRA_DIST = autogen-version.def copyright.def debug-opt.def homerc.def version.def
+
+SUBDIRS = isc
+
+noinst_HEADERS = \
+       adjtime.h \
+       audio.h \
+       ascii.h \
+       audio.h \
+       binio.h \
+       global.h \
+       gps.h \
+       hopf6039.h \
+       icom.h \
+       ieee754io.h \
+       iosignal.h \
+       l_stdlib.h \
+       mbg_gps166.h \
+       mx4200.h \
+       ntif.h \
+       ntp.h \
+       ntp_calendar.h \
+       ntp_cmdargs.h \
+       ntp_config.h \
+       ntp_control.h \
+       ntp_crypto.h \
+       ntp_datum.h \
+       ntp_debug.h \
+       ntp_filegen.h \
+       ntp_fp.h \
+       ntp_if.h \
+       ntp_io.h \
+       ntp_machine.h \
+       ntp_malloc.h \
+       ntp_md5.h \
+       ntp_proto.h \
+       ntp_random.h \
+       ntp_refclock.h \
+       ntp_request.h \
+       ntp_rfc2553.h \
+       ntp_select.h \
+       ntp_sprintf.h \
+       ntp_stdlib.h \
+       ntp_string.h \
+       ntp_syscall.h \
+       ntp_syslog.h \
+       ntp_tty.h \
+       ntp_types.h \
+       ntp_unixtime.h \
+       ntpd.h \
+       ntpsim.h \
+       parse.h \
+       parse_conf.h \
+       recvbuff.h \
+       rsa_md5.h \
+       timepps-SCO.h   \
+       timepps-Solaris.h       \
+       timepps-SunOS.h \
+       trimble.h
+
diff --git a/include/Makefile.in b/include/Makefile.in
new file mode 100644 (file)
index 0000000..70b0330
--- /dev/null
@@ -0,0 +1,641 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = include
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+       html-recursive info-recursive install-data-recursive \
+       install-dvi-recursive install-exec-recursive \
+       install-html-recursive install-info-recursive \
+       install-pdf-recursive install-ps-recursive install-recursive \
+       installcheck-recursive installdirs-recursive pdf-recursive \
+       ps-recursive uninstall-recursive
+HEADERS = $(noinst_HEADERS)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+       $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+       distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+ETAGS_ARGS = $(srcdir)/Makefile.am
+EXTRA_DIST = autogen-version.def copyright.def debug-opt.def homerc.def version.def
+SUBDIRS = isc
+noinst_HEADERS = \
+       adjtime.h \
+       audio.h \
+       ascii.h \
+       audio.h \
+       binio.h \
+       global.h \
+       gps.h \
+       hopf6039.h \
+       icom.h \
+       ieee754io.h \
+       iosignal.h \
+       l_stdlib.h \
+       mbg_gps166.h \
+       mx4200.h \
+       ntif.h \
+       ntp.h \
+       ntp_calendar.h \
+       ntp_cmdargs.h \
+       ntp_config.h \
+       ntp_control.h \
+       ntp_crypto.h \
+       ntp_datum.h \
+       ntp_debug.h \
+       ntp_filegen.h \
+       ntp_fp.h \
+       ntp_if.h \
+       ntp_io.h \
+       ntp_machine.h \
+       ntp_malloc.h \
+       ntp_md5.h \
+       ntp_proto.h \
+       ntp_random.h \
+       ntp_refclock.h \
+       ntp_request.h \
+       ntp_rfc2553.h \
+       ntp_select.h \
+       ntp_sprintf.h \
+       ntp_stdlib.h \
+       ntp_string.h \
+       ntp_syscall.h \
+       ntp_syslog.h \
+       ntp_tty.h \
+       ntp_types.h \
+       ntp_unixtime.h \
+       ntpd.h \
+       ntpsim.h \
+       parse.h \
+       parse_conf.h \
+       recvbuff.h \
+       rsa_md5.h \
+       timepps-SCO.h   \
+       timepps-Solaris.h       \
+       timepps-SunOS.h \
+       trimble.h
+
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign include/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       rev=''; for subdir in $$list; do \
+         if test "$$subdir" = "."; then :; else \
+           rev="$$subdir $$rev"; \
+         fi; \
+       done; \
+       rev="$$rev ."; \
+       target=`echo $@ | sed s/-recursive//`; \
+       for subdir in $$rev; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done && test -z "$$fail"
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+ctags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+       done
+
+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: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test -d "$(distdir)/$$subdir" \
+           || $(MKDIR_P) "$(distdir)/$$subdir" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-recursive
+all-am: Makefile $(HEADERS)
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+       install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+       all all-am check check-am clean clean-generic clean-libtool \
+       ctags ctags-recursive distclean 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 installdirs-am maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-generic \
+       mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+       uninstall uninstall-am
+
+
+# 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.
+.NOEXPORT:
diff --git a/include/README b/include/README
new file mode 100644 (file)
index 0000000..5d818dc
--- /dev/null
@@ -0,0 +1,4 @@
+README file for directory ./include of the NTP Version 4 distribution
+
+This directory contains the include files used by most programs in this
+distribution.
diff --git a/include/adjtime.h b/include/adjtime.h
new file mode 100644 (file)
index 0000000..74d91eb
--- /dev/null
@@ -0,0 +1,63 @@
+/*************************************************************************/
+/* (c) Copyright Tai Jin, 1988.  All Rights Reserved.                    */
+/*     Hewlett-Packard Laboratories.                                     */
+/*                                                                       */
+/* Permission is hereby granted for unlimited modification, use, and     */
+/* distribution.  This software is made available with no warranty of    */
+/* any kind, express or implied.  This copyright notice must remain      */
+/* intact in all versions of this software.                              */
+/*                                                                       */
+/* The author would appreciate it if any bug fixes and enhancements were */
+/* to be sent back to him for incorporation into future versions of this */
+/* software.  Please send changes to tai@iag.hp.com or ken@sdd.hp.com.   */
+/*************************************************************************/
+
+/* "adjtime.h,v 3.1 1993/07/06 01:04:43 jbj Exp" */
+/* adjtime.h,v
+ * Revision 3.1  1993/07/06  01:04:43  jbj
+ * NTP release 3.1
+ *
+ *
+ * Revision 1.5  90/02/07  15:34:18  15:34:18  src (Source Hacker)
+ * CHANGED KEY !!!
+ * 
+ * Revision 1.4  89/02/09  12:26:35  12:26:35  tai (Tai Jin (Guest))
+ * *** empty log message ***
+ * 
+ * Revision 1.4  89/02/09  12:26:35  12:26:35  tai (Tai Jin)
+ * added comment
+ * 
+ * Revision 1.3  88/08/30  01:08:29  01:08:29  tai (Tai Jin)
+ * fix copyright notice again
+ * 
+ * Revision 1.2  88/08/30  00:51:55  00:51:55  tai (Tai Jin)
+ * fix copyright notice
+ * 
+ * Revision 1.1  88/04/02  14:56:54  14:56:54  tai (Tai Jin)
+ * Initial revision
+ *  */
+
+#include "ntp_types.h"
+
+#define KEY    659847L
+
+typedef union {
+  struct msgbuf msgp;
+  struct {
+    long mtype;
+    int code;
+    struct timeval tv;
+  } msgb;
+} MsgBuf;
+
+#define MSGSIZE        (sizeof(int) + sizeof(struct timeval))
+/*
+ * mtype values
+ */
+#define CLIENT 1L
+#define SERVER 2L
+/*
+ * code values
+ */
+#define DELTA1 0
+#define DELTA2 1
diff --git a/include/ascii.h b/include/ascii.h
new file mode 100644 (file)
index 0000000..a789091
--- /dev/null
@@ -0,0 +1,96 @@
+/*
+ * /src/NTP/ntp4-dev/include/ascii.h,v 4.4 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * ascii.h,v 4.4 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * $Created: Sun Jul 20 11:42:53 1997 $
+ *
+ * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+#ifndef ASCII_H
+#define ASCII_H
+
+/*
+ * just name the common ASCII control codes
+ */
+#define NUL      0
+#define SOH      1
+#define STX      2
+#define ETX      3
+#define EOT      4
+#define ENQ      5
+#define ACK      6
+#define BEL      7
+#define BS       8
+#define HT       9
+#define NL      10
+#define VT      11
+#define NP      12
+#define CR      13
+#define SO      14
+#define SI      15
+#define DLE     16
+#define DC1     17
+#define DC2     18
+#define DC3     19
+#define DC4     20
+#define NAK     21
+#define SYN     22
+#define ETB     23
+#define CAN     24
+#define EM      25
+#define SUB     26
+#define ESC     27
+#define FS      28
+#define GS      29
+#define RS      30
+#define US      31
+#define SP      32
+#define DEL    127
+
+#endif
+/*
+ * History:
+ *
+ * ascii.h,v
+ * Revision 4.4  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.3  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.1  1998/07/11 10:05:22  kardel
+ * Release 4.0.73d reconcilation
+ *
+ * Revision 4.0  1998/04/10 19:50:38  kardel
+ * Start 4.0 release version numbering
+ *
+ * Revision 4.0  1998/04/10 19:50:38  kardel
+ * Start 4.0 release version numbering
+ *
+ */
diff --git a/include/audio.h b/include/audio.h
new file mode 100644 (file)
index 0000000..6d16347
--- /dev/null
@@ -0,0 +1,14 @@
+/*
+ * Header file for audio drivers
+ */
+#include "ntp_types.h"
+
+#define MAXGAIN                255     /* max codec gain */
+#define        MONGAIN         127     /* codec monitor gain */
+
+/*
+ * Function prototypes
+ */
+int    audio_init              P((char *, int, int));
+int    audio_gain              P((int, int, int));
+void   audio_show              P((void));
diff --git a/include/autogen-version.def b/include/autogen-version.def
new file mode 100644 (file)
index 0000000..8943983
--- /dev/null
@@ -0,0 +1,2 @@
+#assert (version-compare >= autogen-version "5.9.1")
+guard-option-names;
diff --git a/include/binio.h b/include/binio.h
new file mode 100644 (file)
index 0000000..56e671f
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * /src/NTP/ntp4-dev/include/binio.h,v 4.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * binio.h,v 4.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * $Created: Sun Jul 20 13:03:05 1997 $
+ *
+ * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+#ifndef BINIO_H
+#define BINIO_H
+
+#include "ntp_stdlib.h"
+
+long get_lsb_short P((unsigned char **));
+void put_lsb_short P((unsigned char **, long));
+long get_lsb_long P((unsigned char **));
+void put_lsb_long P((unsigned char **, long));
+
+long get_msb_short P((unsigned char **));
+void put_msb_short P((unsigned char **, long));
+long get_msb_long P((unsigned char **));
+void put_msb_long P((unsigned char **, long));
+
+#endif
+/*
+ * History:
+ *
+ * binio.h,v
+ * Revision 4.5  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.4  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.2  1998/06/28 16:52:15  kardel
+ * added binio MSB prototypes for {get,put}_msb_{short,long}
+ *
+ * Revision 4.1  1998/06/12 15:07:40  kardel
+ * fixed prototyping
+ *
+ * Revision 4.0  1998/04/10 19:50:38  kardel
+ * Start 4.0 release version numbering
+ *
+ * Revision 1.1  1998/04/10 19:27:32  kardel
+ * initial NTP VERSION 4 integration of PARSE with GPS166 binary support
+ *
+ * Revision 1.1  1997/10/06 20:55:37  kardel
+ * new parse structure
+ *
+ */
diff --git a/include/copyright.def b/include/copyright.def
new file mode 100644 (file)
index 0000000..ccc3e91
--- /dev/null
@@ -0,0 +1,18 @@
+/* -*- Mode: Text -*- */
+
+copyright = {
+    date  = "1970-2009";
+    owner = "David L. Mills and/or others";
+    eaddr = "http://bugs.ntp.org, bugs@ntp.org";
+    type  = note;
+    text  = "see html/copyright.html";
+};
+
+long-opts;
+config-header  = config.h;
+environrc;
+
+version         = `
+eval VERSION=\`sed -e 's/.*,\\[//' -e 's/\\].*//' < ../version.m4\`
+[ -z "${VERSION}" ] && echo "Cannot determine VERSION" && kill -TERM $AG_pid
+echo $VERSION`;
diff --git a/include/debug-opt.def b/include/debug-opt.def
new file mode 100644 (file)
index 0000000..2c3da2a
--- /dev/null
@@ -0,0 +1,34 @@
+
+include        = <<- _EOF_
+       #ifdef __windows
+         extern int atoi(const char*);
+       #else
+       # include <stdlib.h>
+       #endif
+       _EOF_;
+
+flag = {
+    name      = debug-level;
+    value     = d;
+    max       = NOLIMIT;
+    ifdef     = DEBUG;
+    nopreset;
+    descrip   = "Increase output debug message level";
+    doc = <<-  _EndOfDoc_
+       Increase the debugging message output level.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = set-debug-level;
+    value     = D;
+    max       = NOLIMIT;
+    ifdef     = DEBUG;
+    descrip   = "Set the output debug message level";
+    arg-type  = string;
+    flag-code = 'DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );';
+    doc = <<-  _EndOfDoc_
+       Set the output debugging level.  Can be supplied multiple times,
+       but each overrides the previous value(s).
+       _EndOfDoc_;
+};
diff --git a/include/global.h b/include/global.h
new file mode 100644 (file)
index 0000000..742f84c
--- /dev/null
@@ -0,0 +1,54 @@
+/* GLOBAL.H - RSAREF types and constants */
+
+/* Copyright (C) RSA Laboratories, a division of RSA Data Security,
+     Inc., created 1991. All rights reserved.
+ */
+
+/*
+ * Note: the modifications are necessary for little-endian machines
+ */
+#include "ntp_types.h"                 /* local modification */
+
+#ifndef _GLOBAL_H_
+#define _GLOBAL_H_ 1
+
+/* PROTOTYPES should be set to one if and only if the compiler supports
+     function argument prototyping.
+   The following makes PROTOTYPES default to 1 if it has not already been
+     defined as 0 with C compiler flags.
+ */
+#ifdef HAVE_PROTOTYPES
+#define PROTOTYPES 1
+#endif
+
+/* POINTER defines a generic pointer type */
+typedef unsigned char *POINTER;
+
+/* UINT2 defines a two byte word */
+typedef unsigned short int UINT2;
+
+/* UINT4 defines a four byte word */
+typedef u_int32 UINT4;                 /* local modification */
+
+/* BYTE defines a unsigned character */
+typedef unsigned char BYTE;            /* local modification for RSAEuro */
+
+#ifndef NULL_PTR
+#define NULL_PTR ((POINTER)0)
+#endif
+
+#ifndef UNUSED_ARG
+#define UNUSED_ARG(x) x = *(&x);
+#endif
+
+/* PROTO_LIST is defined depending on how PROTOTYPES is defined above.
+   If using PROTOTYPES, then PROTO_LIST returns the list, otherwise it
+     returns an empty list.  
+ */
+#if PROTOTYPES
+#define PROTO_LIST(list) list
+#else
+#define PROTO_LIST(list) ()
+#endif
+
+#endif /* end _GLOBAL_H_ */
diff --git a/include/gps.h b/include/gps.h
new file mode 100644 (file)
index 0000000..d4f2dbc
--- /dev/null
@@ -0,0 +1,53 @@
+/****************************************************************************/
+/*      gps.h                                                            */     
+/*      TrueTime GPS-VME and VME-SG                                     */
+/*      VME controller hardware commands and parameters.                */
+/*      created 010694 res                                              */
+/*      History:        revised for 747i 3/94                           */
+/****************************************************************************/
+
+
+#define GPS_VME "/dev/vme2"    /* the device file for the GPS board */
+                               /* change it to whatever yours is */
+#define PRIO    120               /* set the realtime priority */
+#define NREGS 7                   /* number of registers we will use */
+
+#define GFRZ1   0x0020          /* freeze cmd addr gen reg. 1 */
+#define GREG1A  0x0021  /* Gen reg. 1 Word A (units microsec to 0.001 sec) */
+#define GREG1B  0x0040  /* Gen reg. 1 Word B (units 0.01 sec to tens sec ) */
+#define GREG1C  0x0041  /* Gen reg  1 Word C (units mins and hours) */
+#define GREG1D  0x0042  /* Gen reg. 1 Word D (units days and status) */
+#define GREG1E  0x0043  /* Gen reg. 1 Word E (units Years ) */
+#define GUFRZ1  0x0022  /* unfreeze cmd addr gen reg 1 */
+
+#define MASKDAY 0x0FFF  /* mask for units days */
+#define MASKHI  0xFF00
+#define MASKLO  0x00FF
+/* Use the following ASCII hex values: N(0x004e),S(0x0053),E(0x0045),
+        W(0x0057), +(0x002B), - (0x002D)   */
+
+#define LAT1    0x0048  /* Lat (degrees) */
+#define LAT2    0x0049  /* Lat (min, sec) */
+#define LAT3    0x004A  /* Lat (N/S, tenths sec) */
+#define LON1    0x004B  /* Lon (degrees) */
+#define LON2    0x004C  /* Lon (min, sec) */
+#define LON3    0x004D  /* Lon (E/W, tenths sec) */
+#define ELV1    0x004E  /* Elev. (sign, 10,000 and 1000 ) */
+#define ELV2    0x004F  /* Elev. (100, 10s, units, and .1) */
+
+#define CFREG1  0x0050  /* config. register 1 */
+#define CFREG2  0x00A0  /* config. register 2 */
+#define PMODE   0x00A4  /* Position mode */
+#define LOCAL   0x0051  /* Local hours offset */
+#define RATE    0x0054  /* Pulse rate output select */
+#define DAC     0x0055  /* OSC Control (DAC) select */
+
+#define PUMS    0x0056  /* Gen. preset register unit millisec */
+#define PMS     0x0057  /* Gen. preset register units hundreds and tens ms */
+#define PSEC    0x0058  /* Gen. preset register units tens and unit seconds */
+#define PMIN    0x0059  /* Gen. preset register units tens and unit minutes */
+#define PHRS    0x005A  /* Gen. preset register units tens and unit hours */
+#define PDYS1   0x005B  /* Gen. preset register units tens and unit days */
+#define PDYS2   0x005C  /* Gen. preset register units hundreds days */
+#define PYRS1   0x005D  /* Gen. preset register units tens and unit years */
+#define PYRS2   0x005E  /* Gen. preset reg. units thousands and hundreds yrs */
diff --git a/include/homerc.def b/include/homerc.def
new file mode 100644 (file)
index 0000000..18b4dcb
--- /dev/null
@@ -0,0 +1,9 @@
+/* -*- Mode: Text -*- */
+
+#ifndef __windows__
+rcfile         = ".ntprc";
+#else
+rcfile         = "ntp.ini";
+#endif
+
+homerc         =  $HOME, ".";
diff --git a/include/hopf6039.h b/include/hopf6039.h
new file mode 100644 (file)
index 0000000..8532099
--- /dev/null
@@ -0,0 +1,144 @@
+/****************************************************************************/
+/*      hopf6039.h                                                          */     
+/*      hopf Elektronik 6039 PCI radio clock header                         */
+/*      (c) 1999, 2000 Bernd Altmeier    <altmeier@ATLSoft.de>              */
+/*      Rev. 1.00 Date 25.03.2000                                           */
+/*      History:                                                            */
+/****************************************************************************/
+
+#ifndef _hopf6039_H_
+#define _hopf6039_H_
+
+#define HOPF_MAXVERSION                        8
+#define        HOPF_CNTR_MEM_LEN               0x7f
+#define        HOPF_DATA_MEM_LEN               0x3ff   /* this is our memory size */
+
+/* macros and definition for 32 to 16 to 8 bit conversion */
+
+typedef unsigned long       DWORD;
+typedef unsigned char       BYTE;
+typedef unsigned short      WORD;
+
+#define LOWORD(l)     ((WORD)(l))
+#define HIWORD(l)     ((WORD)(((DWORD)(l) >> 16) & 0xFFFF))
+#define LOBYTE(w)     ((BYTE)(w))
+#define HIBYTE(w)     ((BYTE)(((WORD)(w) >> 8) & 0xFF))
+
+/* iocntl codes for driver access */
+
+#define HOPF_CLOCK_CMD_MASK 0xff000
+
+#define HOPF_CLOCK_GET_LOCAL           0x10000 
+#define HOPF_CLOCK_GET_UTC             0x20000
+#define HOPF_CLOCK_GET_ANTENNA         0x30000
+#define HOPF_CLOCK_GET_DIFFERENCE      0x40000
+#define HOPF_CLOCK_GET_VERSION         0x50000
+#define HOPF_CLOCK_GET_POSITION                0x60000
+#define HOPF_CLOCK_GET_SATDATA         0x70000
+#define HOPF_CLOCK_GET_SYSTEMBYTE      0x80000
+#define HOPF_CLOCK_GET_IRIG            0x90000
+
+#define HOPF_CLOCK_SET_DIFFERENCE      0x01000
+#define HOPF_CLOCK_SET_ANTENNA         0x02000
+#define HOPF_CLOCK_SET_TIME            0x03000
+#define HOPF_CLOCK_SET_POSITION                0x04000
+#define HOPF_CLOCK_SET_SATMODE         0x05000
+#define HOPF_CLOCK_SET_SYSTEMBYTE      0x06000
+#define HOPF_CLOCK_SET_RESET           0x07000
+#define HOPF_CLOCK_SET_IRIG            0x08000
+
+/* clock command codes */
+
+#define HOPF_CLOCK_HARDRESET           0x00008000
+#define HOPF_CLOCK_SOFTRESET           0x00004000
+
+/* sat-information */
+
+typedef struct SatStat{    
+       BYTE wVisible;    
+       BYTE wMode;
+       BYTE wSat0;
+       BYTE wRat0;
+       BYTE wSat1;
+       BYTE wRat1;
+       BYTE wSat2;
+       BYTE wRat2;
+       BYTE wSat3;
+       BYTE wRat3;
+       BYTE wSat4;
+       BYTE wRat4;
+       BYTE wSat5;
+       BYTE wRat5;
+       BYTE wSat6;
+       BYTE wRat6;
+       BYTE wSat7;
+       BYTE wRat7;
+} SatStat;
+
+/* GPS position */
+
+typedef struct GPSPos {  /* Position */
+       long wAltitude;   
+       long wLongitude;   
+       long wLatitude;    
+} GPSPos;
+
+/* clock hardware version */
+
+typedef struct ClockVersion {    
+       char cVersion[255];  /* Hardware Version like " DCF-RECEIVER,   VERSION 01.01, DAT: 23.NOV.1999" */
+       char dVersion[255];  /* Driver Version */
+} ClockVersion;
+
+/* hopftime what you think */
+
+typedef struct HOPFTIME { 
+    unsigned int wYear; 
+    unsigned int wMonth; 
+    unsigned int wDayOfWeek; 
+    unsigned int wDay; 
+    unsigned int wHour; 
+    unsigned int wMinute; 
+    unsigned int wSecond; 
+    unsigned int wMilliseconds; 
+    unsigned int wStatus; 
+} HOPFTIME; 
+
+/* DCF77 antenna alignment */
+
+typedef struct DcfAntenne {    
+       BYTE bStatus;    
+       BYTE bStatus1;    
+       WORD wAntValue;    
+} DcfAntenne;
+
+/* hopf PCI clock */
+
+typedef struct hopfCard {
+       char name[32];
+       unsigned irq;
+       unsigned long membase; /* without mmap */
+       unsigned int port;
+
+       int versionlen;
+       char versionbuf[1024];
+       char *version[HOPF_MAXVERSION];
+       char cardname[32];
+       int interrupt;
+       void *mbase;               /* this will be our memory base address */
+
+} hopfCard;
+
+typedef struct cardparams {
+       unsigned int port;
+       unsigned irq;
+       int cardtype;
+       int cardnr;
+       unsigned int membase;
+} cardparams;
+
+
+#define WRITE_REGISTER         0x00
+#define READ_REGISTER          0x01
+
+#endif /* _hopf6039_H_ */
diff --git a/include/icom.h b/include/icom.h
new file mode 100644 (file)
index 0000000..aac62c8
--- /dev/null
@@ -0,0 +1,87 @@
+/*
+ * Header file for ICOM radios
+ */
+#include "ntp_types.h"
+
+/*
+ * Common definitions
+ */
+#define P_ERMSG        0x1             /* trace bus error messages */
+#define P_TRACE 0x2            /* trace CI-V messges */
+#define RETRY  3               /* max packet retries */
+#define IBAUD  B1200           /* autotune port speed */
+
+/*
+ * Radio identifier codes
+ */
+#define IC1271 0x24
+#define IC1275 0x18
+#define IC271  0x20
+#define IC275  0x10
+#define IC375  0x12
+#define IC471  0x22
+#define IC475  0x14
+#define IC575  0x16
+#define IC725  0x28
+#define IC726  0x30
+#define IC735  0x04
+#define IC751  0x1c
+#define IC761  0x1e
+#define IC765  0x2c
+#define IC775  0x46
+#define IC781  0x26
+#define IC970  0x2e
+#define R7000  0x08
+#define R71    0x1a
+#define R7100  0x34
+#define R72    0x32
+#define R8500  0x4a
+#define R9000  0x2a
+
+/*
+ * CI-V frame codes
+ */
+#define PR     0xfe            /* preamble */
+#define TX     0xe0            /* controller address */
+#define FI     0xfd            /* end of message */
+#define ACK    0xfb            /* controller normal reply */
+#define NAK    0xfa            /* controller error reply */
+#define PAD    0xff            /* transmit padding */
+
+/*
+ * CI-V controller commands
+ */
+#define V_FREQT        0x00            /* freq set (transceive) */
+#define V_MODET        0x01            /* set mode (transceive) */
+#define V_RBAND        0x02            /* read band edge */
+#define V_RFREQ        0x03            /* read frequency */
+#define V_RMODE        0x04            /* read mode */
+#define V_SFREQ        0x05            /* set frequency */
+#define V_SMODE        0x06            /* set mode */
+#define V_SVFO 0x07            /* select vfo */
+#define V_SMEM 0x08            /* select channel/bank */
+#define V_WRITE        0x09            /* write channel */
+#define V_VFOM 0x0a            /* memory -> vfo */
+#define V_CLEAR        0x0b            /* clear channel */
+#define V_ROFFS        0x0c            /* read tx offset */
+#define V_SOFFS        0x0d            /* write tx offset */
+#define V_SCAN 0x0e            /* scan control */
+#define V_SPLIT        0x0f            /* split control */
+#define V_DIAL 0x10            /* set dial tuning step */
+#define V_ATTEN        0x11            /* set attenuator */
+#define V_SANT 0x12            /* select antenna */
+#define V_ANNC 0x13            /* announce control */
+#define V_WRCTL        0x14            /* write controls */
+#define V_RDCTL        0x15            /* read controls */
+#define V_TOGL 0x16            /* set switches */
+#define V_ASCII        0x17            /* send CW message */
+#define V_POWER        0x18            /* power control */
+#define V_RDID 0x19            /* read model ID */
+#define V_SETW 0x1a            /* read/write channel/bank data */
+#define V_CTRL 0x7f            /* miscellaneous control */
+
+/*
+ * Function prototypes
+ */
+int    icom_init               P((char *, int, int));
+int    icom_freq               P((int, int, double));
diff --git a/include/ieee754io.h b/include/ieee754io.h
new file mode 100644 (file)
index 0000000..6906731
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * /src/NTP/ntp4-dev/include/ieee754io.h,v 4.3 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * ieee754io.h,v 4.3 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * $Created: Sun Jul 13 12:22:11 1997 $
+ *
+ * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+#ifndef IEEE754IO_H
+#define IEEE754IO_H
+
+#define IEEE_SINGLE 1
+#define IEEE_DOUBLE 2
+
+#define IEEE_MSB 1
+#define IEEE_LSB 2
+
+#define IEEE_OK          0     /* conversion ok */
+#define IEEE_BADCALL     1     /* bad call parameters */
+#define IEEE_NAN         2     /* found an NaN */
+#define IEEE_POSINFINITY 3     /* positive infinity */
+#define IEEE_NEGINFINITY 4     /* negative infinity */
+#define IEEE_POSOVERFLOW 5     /* positive overflow */
+#define IEEE_NEGOVERFLOW 6     /* negative overflow */
+
+#define IEEE_OFFSETS     8     /* number of byte positions */
+typedef unsigned char offsets_t[IEEE_OFFSETS];
+
+int fetch_ieee754 P((unsigned char **bufp, int size, l_fp *lfpp, offsets_t offsets));
+int put_ieee754 P((unsigned char **bufpp, int size, l_fp *lfpp, offsets_t offsets));
+
+#endif
+/*
+ * History:
+ *
+ * ieee754io.h,v
+ * Revision 4.3  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.2  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.0  1998/04/10 19:50:40  kardel
+ * Start 4.0 release version numbering
+ *
+ * Revision 1.1  1998/04/10 19:27:33  kardel
+ * initial NTP VERSION 4 integration of PARSE with GPS166 binary support
+ *
+ * Revision 1.1  1997/10/06 20:55:37  kardel
+ * new parse structure
+ *
+ */
diff --git a/include/iosignal.h b/include/iosignal.h
new file mode 100644 (file)
index 0000000..bd74e09
--- /dev/null
@@ -0,0 +1,23 @@
+#if !defined _ntp_iosignaled_h
+#define _ntp_iosignaled_h
+
+#include "ntp_refclock.h"
+
+#if defined(HAVE_SIGNALED_IO)
+extern void                    block_sigio     P((void));
+extern void                    unblock_sigio   P((void));
+extern int                     init_clock_sig  P((struct refclockio *));
+extern void                    init_socket_sig P((int));
+extern void                    set_signal              P((void));
+RETSIGTYPE     sigio_handler   P((int));
+
+# define BLOCKIO()      ((void) block_sigio())
+# define UNBLOCKIO() ((void) unblock_sigio())
+
+#else
+
+# define BLOCKIO()
+# define UNBLOCKIO()
+#endif /* HAVE_SIGNALED_IO */
+
+#endif
diff --git a/include/isc/Makefile.am b/include/isc/Makefile.am
new file mode 100644 (file)
index 0000000..3d8c2a4
--- /dev/null
@@ -0,0 +1,37 @@
+#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+ETAGS_ARGS = $(srcdir)/Makefile.am
+#EXTRA_DIST = TAGS
+
+noinst_HEADERS = \
+       app.h \
+       assertions.h \
+       boolean.h \
+       buffer.h \
+       error.h \
+       formatcheck.h \
+       int.h \
+       interfaceiter.h \
+       ipv6.h \
+       lang.h \
+       lib.h \
+       list.h \
+       magic.h \
+       mem.h \
+       msgcat.h \
+       msgs.h \
+       mutex.h \
+       net.h \
+       netaddr.h \
+       netscope.h \
+       offset.h \
+       once.h \
+       platform.h \
+       print.h \
+       result.h \
+       region.h \
+       sockaddr.h \
+       strerror.h \
+       string.h \
+       types.h \
+       util.h
diff --git a/include/isc/Makefile.in b/include/isc/Makefile.in
new file mode 100644 (file)
index 0000000..531da09
--- /dev/null
@@ -0,0 +1,465 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = include/isc
+DIST_COMMON = $(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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+ETAGS_ARGS = $(srcdir)/Makefile.am
+#EXTRA_DIST = TAGS
+noinst_HEADERS = \
+       app.h \
+       assertions.h \
+       boolean.h \
+       buffer.h \
+       error.h \
+       formatcheck.h \
+       int.h \
+       interfaceiter.h \
+       ipv6.h \
+       lang.h \
+       lib.h \
+       list.h \
+       magic.h \
+       mem.h \
+       msgcat.h \
+       msgs.h \
+       mutex.h \
+       net.h \
+       netaddr.h \
+       netscope.h \
+       offset.h \
+       once.h \
+       platform.h \
+       print.h \
+       result.h \
+       region.h \
+       sockaddr.h \
+       strerror.h \
+       string.h \
+       types.h \
+       util.h
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign include/isc/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign include/isc/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+       clean-libtool ctags distclean 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-generic \
+       mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+       uninstall-am
+
+
+# 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.
+.NOEXPORT:
diff --git a/include/isc/app.h b/include/isc/app.h
new file mode 100644 (file)
index 0000000..5aa3d23
--- /dev/null
@@ -0,0 +1,212 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: app.h,v 1.1 2001/07/06 19:50:03 gson Exp $ */
+
+#ifndef ISC_APP_H
+#define ISC_APP_H 1
+
+/*****
+ ***** Module Info
+ *****/
+
+/*
+ * ISC Application Support
+ *
+ * Dealing with program termination can be difficult, especially in a
+ * multithreaded program.  The routines in this module help coordinate
+ * the shutdown process.  They are used as follows by the initial (main)
+ * thread of the application:
+ *
+ *             isc_app_start();        Call very early in main(), before
+ *                                     any other threads have been created.
+ *
+ *             isc_app_run();          This will post any on-run events,
+ *                                     and then block until application
+ *                                     shutdown is requested.  A shutdown
+ *                                     request is made by calling
+ *                                     isc_app_shutdown(), or by sending
+ *                                     SIGINT or SIGTERM to the process.
+ *                                     After isc_app_run() returns, the
+ *                                     application should shutdown itself.
+ *
+ *             isc_app_finish();       Call very late in main().
+ *
+ * Applications that want to use SIGHUP/isc_app_reload() to trigger reloading
+ * should check the result of isc_app_run() and call the reload routine if
+ * the result is ISC_R_RELOAD.  They should then call isc_app_run() again
+ * to resume waiting for reload or termination.
+ *
+ * Use of this module is not required.  In particular, isc_app_start() is
+ * NOT an ISC library initialization routine.
+ *
+ * MP:
+ *     Clients must ensure that isc_app_start(), isc_app_run(), and
+ *     isc_app_finish() are called at most once.  isc_app_shutdown()
+ *     is safe to use by any thread (provided isc_app_start() has been
+ *     called previously).
+ *
+ * Reliability:
+ *     No anticipated impact.
+ *
+ * Resources:
+ *     None.
+ *
+ * Security:
+ *     No anticipated impact.
+ *
+ * Standards:
+ *     None.
+ */
+
+#include <isc/eventclass.h>
+#include <isc/lang.h>
+#include <isc/result.h>
+
+typedef isc_event_t isc_appevent_t;
+
+#define ISC_APPEVENT_FIRSTEVENT                (ISC_EVENTCLASS_APP + 0)
+#define ISC_APPEVENT_SHUTDOWN          (ISC_EVENTCLASS_APP + 1)
+#define ISC_APPEVENT_LASTEVENT         (ISC_EVENTCLASS_APP + 65535)
+
+ISC_LANG_BEGINDECLS
+
+isc_result_t
+isc_app_start(void);
+/*
+ * Start an ISC library application.
+ *
+ * Notes:
+ *     This call should be made before any other ISC library call, and as
+ *     close to the beginning of the application as possible.
+ */
+
+isc_result_t
+isc_app_onrun(isc_mem_t *mctx, isc_task_t *task, isc_taskaction_t action,
+             void *arg);
+/*
+ * Request delivery of an event when the application is run.
+ *
+ * Requires:
+ *     isc_app_start() has been called.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS
+ *     ISC_R_NOMEMORY
+ */
+
+isc_result_t
+isc_app_run(void);
+/*
+ * Run an ISC library application.
+ *
+ * Notes:
+ *     The caller (typically the initial thread of an application) will
+ *     block until shutdown is requested.  When the call returns, the
+ *     caller should start shutting down the application.
+ *
+ * Requires:
+ *     isc_app_start() has been called.
+ *
+ * Ensures:
+ *     Any events requested via isc_app_onrun() will have been posted (in
+ *     FIFO order) before isc_app_run() blocks.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS                   Shutdown has been requested.
+ *     ISC_R_RELOAD                    Reload has been requested.
+ */
+
+isc_result_t
+isc_app_shutdown(void);
+/*
+ * Request application shutdown.
+ *
+ * Notes:
+ *     It is safe to call isc_app_shutdown() multiple times.  Shutdown will
+ *     only be triggered once.
+ *
+ * Requires:
+ *     isc_app_run() has been called.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS
+ *     ISC_R_UNEXPECTED
+ */
+
+isc_result_t
+isc_app_reload(void);
+/*
+ * Request application reload.
+ *
+ * Requires:
+ *     isc_app_run() has been called.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS
+ *     ISC_R_UNEXPECTED
+ */
+
+void
+isc_app_finish(void);
+/*
+ * Finish an ISC library application.
+ *
+ * Notes:
+ *     This call should be made at or near the end of main().
+ *
+ * Requires:
+ *     isc_app_start() has been called.
+ *
+ * Ensures:
+ *     Any resources allocated by isc_app_start() have been released.
+ */
+
+void
+isc_app_block(void);
+/*
+ * Indicate that a blocking operation will be performed.
+ *
+ * Notes:
+ *     If a blocking operation is in process, a call to isc_app_shutdown()
+ *     or an external signal will abort the program, rather than allowing
+ *     clean shutdown.  This is primarily useful for reading user input.
+ *
+ * Requires:
+ *     isc_app_start() has been called.
+ *     No other blocking operations are in progress.
+ */
+
+void
+isc_app_unblock(void);
+/*
+ * Indicate that a blocking operation is complete.
+ *
+ * Notes:
+ *     When a blocking operation has completed, return the program to a
+ *     state where a call to isc_app_shutdown() or an external signal will
+ *     shutdown normally.
+ *
+ * Requires:
+ *     isc_app_start() has been called.
+ *     isc_app_block() has been called by the same thread.
+ */
+
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_APP_H */
diff --git a/include/isc/assertions.h b/include/isc/assertions.h
new file mode 100644 (file)
index 0000000..45855c6
--- /dev/null
@@ -0,0 +1,120 @@
+/*
+ * Copyright (C) 1997-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/*
+ * $Id: assertions.h,v 1.17 2001/07/12 05:58:21 mayer Exp $
+ */
+
+#ifndef ISC_ASSERTIONS_H
+#define ISC_ASSERTIONS_H 1
+
+#include <isc/lang.h>
+#include <isc/platform.h>
+
+ISC_LANG_BEGINDECLS
+
+typedef enum {
+       isc_assertiontype_require,
+       isc_assertiontype_ensure,
+       isc_assertiontype_insist,
+       isc_assertiontype_invariant
+} isc_assertiontype_t;
+
+typedef void (*isc_assertioncallback_t)(const char *, int, isc_assertiontype_t,
+                                       const char *);
+
+LIBISC_EXTERNAL_DATA extern isc_assertioncallback_t isc_assertion_failed;
+
+void
+isc_assertion_setcallback(isc_assertioncallback_t);
+
+const char *
+isc_assertion_typetotext(isc_assertiontype_t type);
+
+#ifdef ISC_CHECK_ALL
+#define ISC_CHECK_REQUIRE              1
+#define ISC_CHECK_ENSURE               1
+#define ISC_CHECK_INSIST               1
+#define ISC_CHECK_INVARIANT            1
+#endif
+
+#ifdef ISC_CHECK_NONE
+#define ISC_CHECK_REQUIRE              0
+#define ISC_CHECK_ENSURE               0
+#define ISC_CHECK_INSIST               0
+#define ISC_CHECK_INVARIANT            0
+#endif
+
+#ifndef ISC_CHECK_REQUIRE
+#define ISC_CHECK_REQUIRE              1
+#endif
+
+#ifndef ISC_CHECK_ENSURE
+#define ISC_CHECK_ENSURE               1
+#endif
+
+#ifndef ISC_CHECK_INSIST
+#define ISC_CHECK_INSIST               1
+#endif
+
+#ifndef ISC_CHECK_INVARIANT
+#define ISC_CHECK_INVARIANT            1
+#endif
+
+#if ISC_CHECK_REQUIRE != 0
+#define ISC_REQUIRE(cond) \
+       ((void) ((cond) || \
+                ((isc_assertion_failed)(__FILE__, __LINE__, \
+                                        isc_assertiontype_require, \
+                                        #cond), 0)))
+#else
+#define ISC_REQUIRE(cond)      ((void) 0)
+#endif /* ISC_CHECK_REQUIRE */
+
+#if ISC_CHECK_ENSURE != 0
+#define ISC_ENSURE(cond) \
+       ((void) ((cond) || \
+                ((isc_assertion_failed)(__FILE__, __LINE__, \
+                                        isc_assertiontype_ensure, \
+                                        #cond), 0)))
+#else
+#define ISC_ENSURE(cond)       ((void) 0)
+#endif /* ISC_CHECK_ENSURE */
+
+#if ISC_CHECK_INSIST != 0
+#define ISC_INSIST(cond) \
+       ((void) ((cond) || \
+                ((isc_assertion_failed)(__FILE__, __LINE__, \
+                                        isc_assertiontype_insist, \
+                                        #cond), 0)))
+#else
+#define ISC_INSIST(cond)       ((void) 0)
+#endif /* ISC_CHECK_INSIST */
+
+#if ISC_CHECK_INVARIANT != 0
+#define ISC_INVARIANT(cond) \
+       ((void) ((cond) || \
+                ((isc_assertion_failed)(__FILE__, __LINE__, \
+                                        isc_assertiontype_invariant, \
+                                        #cond), 0)))
+#else
+#define ISC_INVARIANT(cond)    ((void) 0)
+#endif /* ISC_CHECK_INVARIANT */
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_ASSERTIONS_H */
diff --git a/include/isc/boolean.h b/include/isc/boolean.h
new file mode 100644 (file)
index 0000000..d10007b
--- /dev/null
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 1998-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: boolean.h,v 1.12 2001/01/09 21:56:45 bwelling Exp $ */
+
+#ifndef ISC_BOOLEAN_H
+#define ISC_BOOLEAN_H 1
+
+typedef enum { isc_boolean_false = 0, isc_boolean_true = 1 } isc_boolean_t;
+
+#define ISC_FALSE isc_boolean_false
+#define ISC_TRUE isc_boolean_true
+#define ISC_TF(x) ((x) ? ISC_TRUE : ISC_FALSE)
+
+#endif /* ISC_BOOLEAN_H */
diff --git a/include/isc/buffer.h b/include/isc/buffer.h
new file mode 100644 (file)
index 0000000..47c8f0c
--- /dev/null
@@ -0,0 +1,800 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1998-2002  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: buffer.h,v 1.39.12.2 2004/03/08 09:04:51 marka Exp $ */
+
+#ifndef ISC_BUFFER_H
+#define ISC_BUFFER_H 1
+
+/*****
+ ***** Module Info
+ *****/
+
+/*
+ * Buffers
+ *
+ * A buffer is a region of memory, together with a set of related subregions.
+ * Buffers are used for parsing and I/O operations.
+ *
+ * The 'used region' and the 'available' region are disjoint, and their
+ * union is the buffer's region.  The used region extends from the beginning
+ * of the buffer region to the last used byte.  The available region
+ * extends from one byte greater than the last used byte to the end of the
+ * buffer's region.  The size of the used region can be changed using various
+ * buffer commands.  Initially, the used region is empty.
+ *
+ * The used region is further subdivided into two disjoint regions: the
+ * 'consumed region' and the 'remaining region'.  The union of these two
+ * regions is the used region.  The consumed region extends from the beginning
+ * of the used region to the byte before the 'current' offset (if any).  The
+ * 'remaining' region the current pointer to the end of the used
+ * region.  The size of the consumed region can be changed using various
+ * buffer commands.  Initially, the consumed region is empty.
+ *
+ * The 'active region' is an (optional) subregion of the remaining region.
+ * It extends from the current offset to an offset in the remaining region
+ * that is selected with isc_buffer_setactive().  Initially, the active region
+ * is empty.  If the current offset advances beyond the chosen offset, the
+ * active region will also be empty.
+ *
+ *  /------------entire length---------------\
+ *  /----- used region -----\/-- available --\
+ *  +----------------------------------------+
+ *  | consumed  | remaining |                |
+ *  +----------------------------------------+
+ *  a           b     c     d                e
+ *
+ * a == base of buffer.
+ * b == current pointer.  Can be anywhere between a and d.
+ * c == active pointer.  Meaningful between b and d.
+ * d == used pointer.
+ * e == length of buffer.
+ *
+ * a-e == entire length of buffer.
+ * a-d == used region.
+ * a-b == consumed region.
+ * b-d == remaining region.
+ * b-c == optional active region.
+ *
+ * The following invariants are maintained by all routines:
+ *
+ *     length > 0
+ *
+ *     base is a valid pointer to length bytes of memory
+ *
+ *     0 <= used <= length
+ *
+ *     0 <= current <= used
+ *
+ *     0 <= active <= used
+ *     (although active < current implies empty active region)
+ *
+ * MP:
+ *     Buffers have no synchronization.  Clients must ensure exclusive
+ *     access.
+ *
+ * Reliability:
+ *     No anticipated impact.
+ *
+ * Resources:
+ *     Memory: 1 pointer + 6 unsigned integers per buffer.
+ *
+ * Security:
+ *     No anticipated impact.
+ *
+ * Standards:
+ *     None.
+ */
+
+/***
+ *** Imports
+ ***/
+
+#include <isc/lang.h>
+#include <isc/magic.h>
+#include <isc/types.h>
+
+/*
+ * To make many functions be inline macros (via #define) define this.
+ * If it is undefined, a function will be used.
+ */
+#define ISC_BUFFER_USEINLINE 
+
+ISC_LANG_BEGINDECLS
+
+/***
+ *** Magic numbers
+ ***/
+#define ISC_BUFFER_MAGIC               0x42756621U     /* Buf!. */
+#define ISC_BUFFER_VALID(b)            ISC_MAGIC_VALID(b, ISC_BUFFER_MAGIC)
+
+/*
+ * The following macros MUST be used only on valid buffers.  It is the
+ * caller's responsibility to ensure this by using the ISC_BUFFER_VALID
+ * check above, or by calling another isc_buffer_*() function (rather than
+ * another macro.)
+ */
+
+/*
+ * Fundamental buffer elements.  (A through E in the introductory comment.)
+ */
+#define isc_buffer_base(b)    ((void *)(b)->base)                        /*a*/
+#define isc_buffer_current(b) \
+               ((void *)((unsigned char *)(b)->base + (b)->current))     /*b*/
+#define isc_buffer_active(b)  \
+               ((void *)((unsigned char *)(b)->base + (b)->active))      /*c*/
+#define isc_buffer_used(b)    \
+               ((void *)((unsigned char *)(b)->base + (b)->used))        /*d*/
+#define isc_buffer_length(b)  ((b)->length)                              /*e*/
+
+/*
+ * Derived lengths.  (Described in the introductory comment.)
+ */
+#define isc_buffer_usedlength(b)       ((b)->used)                   /* d-a */
+#define isc_buffer_consumedlength(b)   ((b)->current)                /* b-a */
+#define isc_buffer_remaininglength(b)  ((b)->used - (b)->current)    /* d-b */
+#define isc_buffer_activelength(b)     ((b)->active - (b)->current)  /* c-b */
+#define isc_buffer_availablelength(b)  ((b)->length - (b)->used)     /* e-d */
+
+/*
+ * Note that the buffer structure is public.  This is principally so buffer
+ * operations can be implemented using macros.  Applications are strongly
+ * discouraged from directly manipulating the structure.
+ */
+
+struct isc_buffer {
+       unsigned int            magic;
+       void                   *base;
+       /* The following integers are byte offsets from 'base'. */
+       unsigned int            length;
+       unsigned int            used;
+       unsigned int            current;
+       unsigned int            active;
+       /* linkable */
+       ISC_LINK(isc_buffer_t)  link;
+       /* private internal elements */
+       isc_mem_t              *mctx;
+};
+
+/***
+ *** Functions
+ ***/
+
+isc_result_t
+isc_buffer_allocate(isc_mem_t *mctx, isc_buffer_t **dynbuffer,
+                   unsigned int length);
+/*
+ * Allocate a dynamic linkable buffer which has "length" bytes in the
+ * data region.
+ *
+ * Requires:
+ *     "mctx" is valid.
+ *
+ *     "dynbuffer" is non-NULL, and "*dynbuffer" is NULL.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS           - success
+ *     ISC_R_NOMEMORY          - no memory available
+ *
+ * Note:
+ *     Changing the buffer's length field is not permitted.
+ */
+
+void
+isc_buffer_free(isc_buffer_t **dynbuffer);
+/*
+ * Release resources allocated for a dynamic buffer.
+ *
+ * Requires:
+ *     "dynbuffer" is not NULL.
+ *
+ *     "*dynbuffer" is a valid dynamic buffer.
+ *
+ * Ensures:
+ *     "*dynbuffer" will be NULL on return, and all memory associated with
+ *     the dynamic buffer is returned to the memory context used in
+ *     isc_buffer_allocate().
+ */
+
+void
+isc__buffer_init(isc_buffer_t *b, const void *base, unsigned int length);
+/*
+ * Make 'b' refer to the 'length'-byte region starting at base.
+ *
+ * Requires:
+ *
+ *     'length' > 0
+ *
+ *     'base' is a pointer to a sequence of 'length' bytes.
+ *
+ */
+
+void
+isc__buffer_invalidate(isc_buffer_t *b);
+/*
+ * Make 'b' an invalid buffer.
+ *
+ * Requires:
+ *     'b' is a valid buffer.
+ *
+ * Ensures:
+ *     If assertion checking is enabled, future attempts to use 'b' without
+ *     calling isc_buffer_init() on it will cause an assertion failure.
+ */
+
+void
+isc__buffer_region(isc_buffer_t *b, isc_region_t *r);
+/*
+ * Make 'r' refer to the region of 'b'.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer.
+ *
+ *     'r' points to a region structure.
+ */
+
+void
+isc__buffer_usedregion(isc_buffer_t *b, isc_region_t *r);
+/*
+ * Make 'r' refer to the used region of 'b'.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer.
+ *
+ *     'r' points to a region structure.
+ */
+
+void
+isc__buffer_availableregion(isc_buffer_t *b, isc_region_t *r);
+/*
+ * Make 'r' refer to the available region of 'b'.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer.
+ *
+ *     'r' points to a region structure.
+ */
+
+void
+isc__buffer_add(isc_buffer_t *b, unsigned int n);
+/*
+ * Increase the 'used' region of 'b' by 'n' bytes.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer
+ *
+ *     used + n <= length
+ *
+ */
+
+void
+isc__buffer_subtract(isc_buffer_t *b, unsigned int n);
+/*
+ * Decrease the 'used' region of 'b' by 'n' bytes.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer
+ *
+ *     used >= n
+ *
+ */
+
+void
+isc__buffer_clear(isc_buffer_t *b);
+/*
+ * Make the used region empty.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer
+ *
+ * Ensures:
+ *
+ *     used = 0
+ *
+ */
+
+void
+isc__buffer_consumedregion(isc_buffer_t *b, isc_region_t *r);
+/*
+ * Make 'r' refer to the consumed region of 'b'.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer.
+ *
+ *     'r' points to a region structure.
+ */
+
+void
+isc__buffer_remainingregion(isc_buffer_t *b, isc_region_t *r);
+/*
+ * Make 'r' refer to the remaining region of 'b'.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer.
+ *
+ *     'r' points to a region structure.
+ */
+
+void
+isc__buffer_activeregion(isc_buffer_t *b, isc_region_t *r);
+/*
+ * Make 'r' refer to the active region of 'b'.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer.
+ *
+ *     'r' points to a region structure.
+ */
+
+void
+isc__buffer_setactive(isc_buffer_t *b, unsigned int n);
+/*
+ * Sets the end of the active region 'n' bytes after current.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer.
+ *
+ *     current + n <= used
+ */
+
+void
+isc__buffer_first(isc_buffer_t *b);
+/*
+ * Make the consumed region empty.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer
+ *
+ * Ensures:
+ *
+ *     current == 0
+ *
+ */
+
+void
+isc__buffer_forward(isc_buffer_t *b, unsigned int n);
+/*
+ * Increase the 'consumed' region of 'b' by 'n' bytes.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer
+ *
+ *     current + n <= used
+ *
+ */
+
+void
+isc__buffer_back(isc_buffer_t *b, unsigned int n);
+/*
+ * Decrease the 'consumed' region of 'b' by 'n' bytes.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer
+ *
+ *     n <= current
+ *
+ */
+
+void
+isc_buffer_compact(isc_buffer_t *b);
+/*
+ * Compact the used region by moving the remaining region so it occurs
+ * at the start of the buffer.  The used region is shrunk by the size of
+ * the consumed region, and the consumed region is then made empty.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer
+ *
+ * Ensures:
+ *
+ *     current == 0
+ *
+ *     The size of the used region is now equal to the size of the remaining
+ *     region (as it was before the call).  The contents of the used region
+ *     are those of the remaining region (as it was before the call).
+ */
+
+isc_uint8_t
+isc_buffer_getuint8(isc_buffer_t *b);
+/*
+ * Read an unsigned 8-bit integer from 'b' and return it.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer.
+ *
+ *     The length of the available region of 'b' is at least 1.
+ *
+ * Ensures:
+ *
+ *     The current pointer in 'b' is advanced by 1.
+ *
+ * Returns:
+ *
+ *     A 8-bit unsigned integer.
+ */
+
+void
+isc__buffer_putuint8(isc_buffer_t *b, isc_uint8_t val);
+/*
+ * Store an unsigned 8-bit integer from 'val' into 'b'.
+ *
+ * Requires:
+ *     'b' is a valid buffer.
+ *
+ *     The length of the unused region of 'b' is at least 1.
+ *
+ * Ensures:
+ *     The used pointer in 'b' is advanced by 1.
+ */
+
+isc_uint16_t
+isc_buffer_getuint16(isc_buffer_t *b);
+/*
+ * Read an unsigned 16-bit integer in network byte order from 'b', convert
+ * it to host byte order, and return it.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer.
+ *
+ *     The length of the available region of 'b' is at least 2.
+ *
+ * Ensures:
+ *
+ *     The current pointer in 'b' is advanced by 2.
+ *
+ * Returns:
+ *
+ *     A 16-bit unsigned integer.
+ */
+
+void
+isc__buffer_putuint16(isc_buffer_t *b, isc_uint16_t val);
+/*
+ * Store an unsigned 16-bit integer in host byte order from 'val'
+ * into 'b' in network byte order.
+ *
+ * Requires:
+ *     'b' is a valid buffer.
+ *
+ *     The length of the unused region of 'b' is at least 2.
+ *
+ * Ensures:
+ *     The used pointer in 'b' is advanced by 2.
+ */
+
+isc_uint32_t
+isc_buffer_getuint32(isc_buffer_t *b);
+/*
+ * Read an unsigned 32-bit integer in network byte order from 'b', convert
+ * it to host byte order, and return it.
+ *
+ * Requires:
+ *
+ *     'b' is a valid buffer.
+ *
+ *     The length of the available region of 'b' is at least 4.
+ *
+ * Ensures:
+ *
+ *     The current pointer in 'b' is advanced by 4.
+ *
+ * Returns:
+ *
+ *     A 32-bit unsigned integer.
+ */
+
+void
+isc__buffer_putuint32(isc_buffer_t *b, isc_uint32_t val);
+/*
+ * Store an unsigned 32-bit integer in host byte order from 'val'
+ * into 'b' in network byte order.
+ *
+ * Requires:
+ *     'b' is a valid buffer.
+ *
+ *     The length of the unused region of 'b' is at least 4.
+ *
+ * Ensures:
+ *     The used pointer in 'b' is advanced by 4.
+ */
+
+void
+isc__buffer_putmem(isc_buffer_t *b, const unsigned char *base,
+                  unsigned int length);
+/*
+ * Copy 'length' bytes of memory at 'base' into 'b'.
+ *
+ * Requires:
+ *     'b' is a valid buffer.
+ *
+ *     'base' points to 'length' bytes of valid memory.
+ *
+ */
+
+void
+isc__buffer_putstr(isc_buffer_t *b, const char *source);
+/*
+ * Copy 'source' into 'b', not including terminating NUL.
+ *
+ * Requires:
+ *     'b' is a valid buffer.
+ *
+ *     'source' to be a valid NULL terminated string.
+ *
+ *     strlen(source) <= isc_buffer_available(b)
+ */
+
+isc_result_t
+isc_buffer_copyregion(isc_buffer_t *b, const isc_region_t *r);
+/*
+ * Copy the contents of 'r' into 'b'.
+ *
+ * Requires:
+ *     'b' is a valid buffer.
+ *
+ *     'r' is a valid region.
+ *
+ * Returns:
+ *
+ *     ISC_R_SUCCESS
+ *     ISC_R_NOSPACE                   The available region of 'b' is not
+ *                                     big enough.
+ */
+
+ISC_LANG_ENDDECLS
+
+/*
+ * Inline macro versions of the functions.  These should never be called
+ * directly by an application, but will be used by the functions within
+ * buffer.c.  The callers should always use "isc_buffer_*()" names, never
+ * ones beginning with "isc__"
+ */
+
+/*
+ * XXXDCL Something more could be done with initializing buffers that
+ * point to const data.  For example, a new function, isc_buffer_initconst,
+ * could be used, and a new boolean flag in the buffer structure could
+ * indicate whether the buffer was initialized with that function.
+ * (isc_bufer_init itself would be reprototyped to *not* have its "base"
+ * parameter be const.)  Then if the boolean were true, the isc_buffer_put*
+ * functions could assert a contractual requirement for a non-const buffer.
+ * One drawback is that the isc_buffer_* functions (macros) that return
+ * pointers would still need to return non-const pointers to avoid compiler
+ * warnings, so it would be up to code that uses them to have to deal
+ * with the possibility that the buffer was initialized as const --
+ * a problem that they *already* have to deal with but have absolutely
+ * no ability to.  With a new isc_buffer_isconst() function returning
+ * true/false, they could at least assert a contractual requirement for
+ * non-const buffers when needed.
+ */
+#define ISC__BUFFER_INIT(_b, _base, _length) \
+       do { \
+               union { \
+                       const void *    konst; \
+                       void *          var; \
+               } _u; \
+               _u.konst = (_base); \
+               (_b)->base = _u.var; \
+               (_b)->length = (_length); \
+               (_b)->used = 0; \
+               (_b)->current = 0; \
+               (_b)->active = 0; \
+               (_b)->mctx = NULL; \
+               ISC_LINK_INIT(_b, link); \
+               (_b)->magic = ISC_BUFFER_MAGIC; \
+       } while (0)
+
+#define ISC__BUFFER_INVALIDATE(_b) \
+       do { \
+               (_b)->magic = 0; \
+               (_b)->base = NULL; \
+               (_b)->length = 0; \
+               (_b)->used = 0; \
+               (_b)->current = 0; \
+               (_b)->active = 0; \
+       } while (0)
+
+#define ISC__BUFFER_REGION(_b, _r) \
+       do { \
+               (_r)->base = (_b)->base; \
+               (_r)->length = (_b)->length; \
+       } while (0)
+
+#define ISC__BUFFER_USEDREGION(_b, _r) \
+       do { \
+               (_r)->base = (_b)->base; \
+               (_r)->length = (_b)->used; \
+       } while (0)
+
+#define ISC__BUFFER_AVAILABLEREGION(_b, _r) \
+       do { \
+               (_r)->base = isc_buffer_used(_b); \
+               (_r)->length = isc_buffer_availablelength(_b); \
+       } while (0)
+
+#define ISC__BUFFER_ADD(_b, _n) \
+       do { \
+               (_b)->used += (_n); \
+       } while (0)
+
+#define ISC__BUFFER_SUBTRACT(_b, _n) \
+       do { \
+               (_b)->used -= (_n); \
+               if ((_b)->current > (_b)->used) \
+                       (_b)->current = (_b)->used; \
+               if ((_b)->active > (_b)->used) \
+                       (_b)->active = (_b)->used; \
+       } while (0)
+
+#define ISC__BUFFER_CLEAR(_b) \
+       do { \
+               (_b)->used = 0; \
+               (_b)->current = 0; \
+               (_b)->active = 0; \
+       } while (0)
+
+#define ISC__BUFFER_CONSUMEDREGION(_b, _r) \
+       do { \
+               (_r)->base = (_b)->base; \
+               (_r)->length = (_b)->current; \
+       } while (0)
+
+#define ISC__BUFFER_REMAININGREGION(_b, _r) \
+       do { \
+               (_r)->base = isc_buffer_current(_b); \
+               (_r)->length = isc_buffer_remaininglength(_b); \
+       } while (0)
+
+#define ISC__BUFFER_ACTIVEREGION(_b, _r) \
+       do { \
+               if ((_b)->current < (_b)->active) { \
+                       (_r)->base = isc_buffer_current(_b); \
+                       (_r)->length = isc_buffer_activelength(_b); \
+               } else { \
+                       (_r)->base = NULL; \
+                       (_r)->length = 0; \
+               } \
+       } while (0)
+
+#define ISC__BUFFER_SETACTIVE(_b, _n) \
+       do { \
+               (_b)->active = (_b)->current + (_n); \
+       } while (0)
+
+#define ISC__BUFFER_FIRST(_b) \
+       do { \
+               (_b)->current = 0; \
+       } while (0)
+
+#define ISC__BUFFER_FORWARD(_b, _n) \
+       do { \
+               (_b)->current += (_n); \
+       } while (0)
+
+#define ISC__BUFFER_BACK(_b, _n) \
+       do { \
+               (_b)->current -= (_n); \
+       } while (0)
+
+#define ISC__BUFFER_PUTMEM(_b, _base, _length) \
+       do { \
+               memcpy(isc_buffer_used(_b), (_base), (_length)); \
+               (_b)->used += (_length); \
+       } while (0)
+
+#define ISC__BUFFER_PUTSTR(_b, _source) \
+       do { \
+               unsigned int _length; \
+               unsigned char *_cp; \
+               _length = strlen(_source); \
+               _cp = isc_buffer_used(_b); \
+               memcpy(_cp, (_source), _length); \
+               (_b)->used += (_length); \
+       } while (0)
+
+#define ISC__BUFFER_PUTUINT8(_b, _val) \
+       do { \
+               unsigned char *_cp; \
+               isc_uint8_t _val2 = (_val); \
+               _cp = isc_buffer_used(_b); \
+               (_b)->used++; \
+               _cp[0] = _val2 & 0x00ff; \
+       } while (0)
+
+#define ISC__BUFFER_PUTUINT16(_b, _val) \
+       do { \
+               unsigned char *_cp; \
+               isc_uint16_t _val2 = (_val); \
+               _cp = isc_buffer_used(_b); \
+               (_b)->used += 2; \
+               _cp[0] = (unsigned char)((_val2 & 0xff00U) >> 8); \
+               _cp[1] = (unsigned char)(_val2 & 0x00ffU); \
+       } while (0)
+
+#define ISC__BUFFER_PUTUINT32(_b, _val) \
+       do { \
+               unsigned char *_cp; \
+               isc_uint32_t _val2 = (_val); \
+               _cp = isc_buffer_used(_b); \
+               (_b)->used += 4; \
+               _cp[0] = (unsigned char)((_val2 & 0xff000000) >> 24); \
+               _cp[1] = (unsigned char)((_val2 & 0x00ff0000) >> 16); \
+               _cp[2] = (unsigned char)((_val2 & 0x0000ff00) >> 8); \
+               _cp[3] = (unsigned char)((_val2 & 0x000000ff)); \
+       } while (0)
+
+#if defined(ISC_BUFFER_USEINLINE)
+#define isc_buffer_init                        ISC__BUFFER_INIT
+#define isc_buffer_invalidate          ISC__BUFFER_INVALIDATE
+#define isc_buffer_region              ISC__BUFFER_REGION
+#define isc_buffer_usedregion          ISC__BUFFER_USEDREGION
+#define isc_buffer_availableregion     ISC__BUFFER_AVAILABLEREGION
+#define isc_buffer_add                 ISC__BUFFER_ADD
+#define isc_buffer_subtract            ISC__BUFFER_SUBTRACT
+#define isc_buffer_clear               ISC__BUFFER_CLEAR
+#define isc_buffer_consumedregion      ISC__BUFFER_CONSUMEDREGION
+#define isc_buffer_remainingregion     ISC__BUFFER_REMAININGREGION
+#define isc_buffer_activeregion                ISC__BUFFER_ACTIVEREGION
+#define isc_buffer_setactive           ISC__BUFFER_SETACTIVE
+#define isc_buffer_first               ISC__BUFFER_FIRST
+#define isc_buffer_forward             ISC__BUFFER_FORWARD
+#define isc_buffer_back                        ISC__BUFFER_BACK
+#define isc_buffer_putmem              ISC__BUFFER_PUTMEM
+#define isc_buffer_putstr              ISC__BUFFER_PUTSTR
+#define isc_buffer_putuint8            ISC__BUFFER_PUTUINT8
+#define isc_buffer_putuint16           ISC__BUFFER_PUTUINT16
+#define isc_buffer_putuint32           ISC__BUFFER_PUTUINT32
+#else
+#define isc_buffer_init                        isc__buffer_init
+#define isc_buffer_invalidate          isc__buffer_invalidate
+#define isc_buffer_region              isc__buffer_region
+#define isc_buffer_usedregion          isc__buffer_usedregion
+#define isc_buffer_availableregion     isc__buffer_availableregion
+#define isc_buffer_add                 isc__buffer_add
+#define isc_buffer_subtract            isc__buffer_subtract
+#define isc_buffer_clear               isc__buffer_clear
+#define isc_buffer_consumedregion      isc__buffer_consumedregion
+#define isc_buffer_remainingregion     isc__buffer_remainingregion
+#define isc_buffer_activeregion                isc__buffer_activeregion
+#define isc_buffer_setactive           isc__buffer_setactive
+#define isc_buffer_first               isc__buffer_first
+#define isc_buffer_forward             isc__buffer_forward
+#define isc_buffer_back                        isc__buffer_back
+#define isc_buffer_putmem              isc__buffer_putmem
+#define isc_buffer_putstr              isc__buffer_putstr
+#define isc_buffer_putuint8            isc__buffer_putuint8
+#define isc_buffer_putuint16           isc__buffer_putuint16
+#define isc_buffer_putuint32           isc__buffer_putuint32
+#endif
+
+#endif /* ISC_BUFFER_H */
diff --git a/include/isc/error.h b/include/isc/error.h
new file mode 100644 (file)
index 0000000..1dc0774
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 1998-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: error.h,v 1.13 2001/01/09 21:56:51 bwelling Exp $ */
+
+#ifndef ISC_ERROR_H
+#define ISC_ERROR_H 1
+
+#include <stdarg.h>
+
+#include <isc/formatcheck.h>
+#include <isc/lang.h>
+
+ISC_LANG_BEGINDECLS
+
+typedef void (*isc_errorcallback_t)(const char *, int, const char *, va_list);
+
+void
+isc_error_setunexpected(isc_errorcallback_t);
+
+void
+isc_error_setfatal(isc_errorcallback_t);
+
+void
+isc_error_unexpected(const char *, int, const char *, ...)
+     ISC_FORMAT_PRINTF(3, 4);
+
+void
+isc_error_fatal(const char *, int, const char *, ...)
+     ISC_FORMAT_PRINTF(3, 4);
+
+void
+isc_error_runtimecheck(const char *, int, const char *);
+
+#define ISC_ERROR_RUNTIMECHECK(cond) \
+       ((void) ((cond) || \
+                ((isc_error_runtimecheck)(__FILE__, __LINE__, #cond), 0)))
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_ERROR_H */
diff --git a/include/isc/formatcheck.h b/include/isc/formatcheck.h
new file mode 100644 (file)
index 0000000..e9b9169
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Copyright (C) 2000, 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: formatcheck.h,v 1.6 2001/01/09 21:56:55 bwelling Exp $ */
+
+#ifndef ISC_FORMATCHECK_H
+#define ISC_FORMATCHECK_H 1
+
+/*
+ * fmt is the location of the format string parameter.
+ * args is the location of the first argument (or 0 for no argument checking).
+ * Note: the first parameter is 1, not 0.
+ */
+#ifdef __GNUC__
+#define ISC_FORMAT_PRINTF(fmt, args) __attribute__((__format__(__printf__, fmt, args)))
+#else
+#define ISC_FORMAT_PRINTF(fmt, args)
+#endif
+
+#endif /* ISC_FORMATCHECK_H */
diff --git a/include/isc/int.h b/include/isc/int.h
new file mode 100644 (file)
index 0000000..d30e6dc
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: int.h,v 1.11 2001/01/09 21:58:39 bwelling Exp $ */
+
+#ifndef ISC_INT_H
+#define ISC_INT_H 1
+
+typedef char                           isc_int8_t;
+typedef unsigned char                  isc_uint8_t;
+typedef short                          isc_int16_t;
+typedef unsigned short                 isc_uint16_t;
+typedef int                            isc_int32_t;
+typedef unsigned int                   isc_uint32_t;
+typedef long long                      isc_int64_t;
+typedef unsigned long long             isc_uint64_t;
+
+#define ISC_INT8_MIN   -128
+#define ISC_INT8_MAX   127
+#define ISC_UINT8_MAX  255
+
+#define ISC_INT16_MIN  -32768
+#define ISC_INT16_MAX  32767
+#define ISC_UINT16_MAX 65535
+
+/*
+ * Note that "int" is 32 bits on all currently supported Unix-like operating
+ * systems, but "long" can be either 32 bits or 64 bits, thus the 32 bit
+ * constants are not qualified with "L".
+ */
+#define ISC_INT32_MIN  -2147483648
+#define ISC_INT32_MAX  2147483647
+#define ISC_UINT32_MAX 4294967295U
+
+#define ISC_INT64_MIN  -9223372036854775808LL
+#define ISC_INT64_MAX  9223372036854775807LL
+#define ISC_UINT64_MAX 18446744073709551615ULL
+
+#endif /* ISC_INT_H */
diff --git a/include/isc/interfaceiter.h b/include/isc/interfaceiter.h
new file mode 100644 (file)
index 0000000..f2d11ba
--- /dev/null
@@ -0,0 +1,139 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: interfaceiter.h,v 1.10 2001/01/09 21:57:01 bwelling Exp $ */
+
+#ifndef ISC_INTERFACEITER_H
+#define ISC_INTERFACEITER_H 1
+
+/*****
+ ***** Module Info
+ *****/
+
+/*
+ * Interface iterator
+ *
+ * Iterate over the list of network interfaces.
+ *
+ * Interfaces whose address family is not supported are ignored and never
+ * returned by the iterator.  Interfaces whose netmask, interface flags,
+ * or similar cannot be obtained are also ignored, and the failure is logged.
+ *
+ * Standards:
+ *     The API for scanning varies greatly among operating systems.
+ *     This module attempts to hide the differences.
+ */
+
+/***
+ *** Imports
+ ***/
+
+#include <isc/lang.h>
+#include <isc/netaddr.h>
+#include <isc/types.h>
+
+/*
+ * Public structure describing a network interface.
+ */
+
+struct isc_interface {
+       char name[32];                  /* Interface name, null-terminated. */
+       unsigned int af;                /* Address family. */
+       isc_netaddr_t address;          /* Local address. */
+       isc_netaddr_t netmask;          /* Network mask. */
+       isc_netaddr_t broadcast;        /* Broadcast address. */
+       isc_netaddr_t dstaddress;       /* Destination address
+                                          (point-to-point only). */
+       isc_uint32_t flags;             /* Flags; see below. */
+       unsigned int ifindex;           /* Interface Index */
+       unsigned int scopeid;           /* Scope id for Multicasting */
+};
+
+/* Interface flags. */
+
+#define INTERFACE_F_UP                 0x00000001U /* Interface is up */
+#define INTERFACE_F_POINTTOPOINT       0x00000002U /*this is point-to-point interface*/
+#define INTERFACE_F_LOOPBACK           0x00000004U /* this is loopback interface */
+#define INTERFACE_F_BROADCAST          0x00000008U /* Broadcast is  supported */
+#define INTERFACE_F_MULTICAST          0x00000010U /* multicast is supported */
+
+/***
+ *** Functions
+ ***/
+
+ISC_LANG_BEGINDECLS
+
+isc_result_t
+isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp);
+/*
+ * Create an iterator for traversing the operating system's list
+ * of network interfaces.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS
+ *     ISC_R_NOMEMORY
+ *     Various network-related errors
+ */
+
+isc_result_t
+isc_interfaceiter_first(isc_interfaceiter_t *iter);
+/*
+ * Position the iterator on the first interface.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS           Success.
+ *     ISC_R_NOMORE            There are no interfaces.
+ */
+
+isc_result_t
+isc_interfaceiter_current(isc_interfaceiter_t *iter,
+                         isc_interface_t *ifdata);
+/*
+ * Get information about the interface the iterator is currently
+ * positioned at and store it at *ifdata.
+ *
+ * Requires:
+ *     The iterator has been successfully positioned using
+ *     isc_interface_iter_first() / isc_interface_iter_next().
+ *
+ * Returns:
+ *     ISC_R_SUCCESS           Success.
+ */
+
+isc_result_t
+isc_interfaceiter_next(isc_interfaceiter_t *iter);
+/*
+ * Position the iterator on the next interface.
+ *
+ * Requires:
+ *     The iterator has been successfully positioned using
+ *     isc_interface_iter_first() / isc_interface_iter_next().
+ *
+ * Returns:
+ *     ISC_R_SUCCESS           Success.
+ *     ISC_R_NOMORE            There are no more interfaces.
+ */
+
+void
+isc_interfaceiter_destroy(isc_interfaceiter_t **iterp);
+/*
+ * Destroy the iterator.
+ */
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_INTERFACEITER_H */
diff --git a/include/isc/ipv6.h b/include/isc/ipv6.h
new file mode 100644 (file)
index 0000000..007de7c
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2002  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: ipv6.h,v 1.17.12.4 2004/03/09 05:21:09 marka Exp $ */
+
+#ifndef ISC_IPV6_H
+#define ISC_IPV6_H 1
+
+/*
+ * Also define LWRES_IPV6_H to keep it from being included if liblwres is
+ * being used, or redefinition errors will occur.
+ */
+#define LWRES_IPV6_H 1
+
+/*****
+ ***** Module Info
+ *****/
+
+/*
+ * IPv6 definitions for systems which do not support IPv6.
+ *
+ * MP:
+ *     No impact.
+ *
+ * Reliability:
+ *     No anticipated impact.
+ *
+ * Resources:
+ *     N/A.
+ *
+ * Security:
+ *     No anticipated impact.
+ *
+ * Standards:
+ *     RFC 2553.
+ */
+
+/***
+ *** Imports.
+ ***/
+
+#include <isc/int.h>
+#include <isc/platform.h>
+
+/*
+ * We probably don't need this on NTP
+ */
+#ifdef ISC_ONLY_IPV6 
+/***
+ *** Types.
+ ***/
+
+struct in6_addr {
+        union {
+               isc_uint8_t     _S6_u8[16];
+               isc_uint16_t    _S6_u16[8];
+               isc_uint32_t    _S6_u32[4];
+        } _S6_un;
+};
+#define s6_addr                _S6_un._S6_u8
+#define s6_addr8       _S6_un._S6_u8
+#define s6_addr16      _S6_un._S6_u16
+#define s6_addr32      _S6_un._S6_u32
+
+#define IN6ADDR_ANY_INIT       {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}
+#define IN6ADDR_LOOPBACK_INIT  {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}
+
+LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_any;
+LIBISC_EXTERNAL_DATA extern const struct in6_addr in6addr_loopback;
+
+struct sockaddr_in6 {
+#ifdef ISC_PLATFORM_HAVESALEN
+       isc_uint8_t             sin6_len;
+       isc_uint8_t             sin6_family;
+#else
+       isc_uint16_t            sin6_family;
+#endif
+       isc_uint16_t            sin6_port;
+       isc_uint32_t            sin6_flowinfo;
+       struct in6_addr         sin6_addr;
+       isc_uint32_t            sin6_scope_id;
+};
+
+#ifdef ISC_PLATFORM_HAVESALEN
+#define SIN6_LEN 1
+#endif
+
+/*
+ * Unspecified
+ */
+#ifndef IN6_IS_ADDR_UNSPECIFIED
+#define IN6_IS_ADDR_UNSPECIFIED(a)      \
+        (((a)->s6_addr32[0] == 0) &&    \
+         ((a)->s6_addr32[1] == 0) &&    \
+         ((a)->s6_addr32[2] == 0) &&    \
+         ((a)->s6_addr32[3] == 0))
+#endif
+/*
+ * Loopback
+ */
+#define IN6_IS_ADDR_LOOPBACK(a)         \
+        (((a)->s6_addr32[0] == 0) &&    \
+         ((a)->s6_addr32[1] == 0) &&    \
+         ((a)->s6_addr32[2] == 0) &&    \
+         ((a)->s6_addr32[3] == htonl(1)))
+
+/*
+ * IPv4 compatible
+ */
+#define IN6_IS_ADDR_V4COMPAT(a)         \
+        (((a)->s6_addr32[0] == 0) &&    \
+         ((a)->s6_addr32[1] == 0) &&    \
+         ((a)->s6_addr32[2] == 0) &&    \
+         ((a)->s6_addr32[3] != 0) &&    \
+         ((a)->s6_addr32[3] != htonl(1)))
+
+/*
+ * Mapped
+ */
+#define IN6_IS_ADDR_V4MAPPED(a)               \
+        (((a)->s6_addr32[0] == 0) &&          \
+         ((a)->s6_addr32[1] == 0) &&          \
+         ((a)->s6_addr32[2] == htonl(0x0000ffff)))
+
+/*
+ * Multicast
+ */
+#ifndef IN6_IS_ADDR_MULTICAST
+#define IN6_IS_ADDR_MULTICAST(a)       \
+       ((a)->s6_addr8[0] == 0xffU)
+#endif
+/*
+ * Unicast link / site local.
+ */
+#define IN6_IS_ADDR_LINKLOCAL(a)       \
+       (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
+#define IN6_IS_ADDR_SITELOCAL(a)       \
+       (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
+
+#endif /* ISC_ONLY_IPV6 */
+#endif /* ISC_IPV6_H */
diff --git a/include/isc/lang.h b/include/isc/lang.h
new file mode 100644 (file)
index 0000000..b3ba590
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: lang.h,v 1.6 2001/01/09 21:57:03 bwelling Exp $ */
+
+#ifndef ISC_LANG_H
+#define ISC_LANG_H 1
+
+#ifdef __cplusplus
+#define ISC_LANG_BEGINDECLS    extern "C" {
+#define ISC_LANG_ENDDECLS      }
+#else
+#define ISC_LANG_BEGINDECLS
+#define ISC_LANG_ENDDECLS
+#endif
+
+#endif /* ISC_LANG_H */
diff --git a/include/isc/lib.h b/include/isc/lib.h
new file mode 100644 (file)
index 0000000..7feef43
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: lib.h,v 1.7 2001/11/19 03:08:25 mayer Exp $ */
+
+#ifndef ISC_LIB_H
+#define ISC_LIB_H 1
+
+#include <isc/types.h>
+#include <isc/lang.h>
+
+ISC_LANG_BEGINDECLS
+
+LIBISC_EXTERNAL_DATA extern isc_msgcat_t *isc_msgcat;
+
+void
+isc_lib_initmsgcat(void);
+/*
+ * Initialize the ISC library's message catalog, isc_msgcat, if it
+ * has not already been initialized.
+ */
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_LIB_H */
diff --git a/include/isc/list.h b/include/isc/list.h
new file mode 100644 (file)
index 0000000..d0ae7a9
--- /dev/null
@@ -0,0 +1,180 @@
+/*
+ * Copyright (C) 1997-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: list.h,v 1.19 2002/05/09 07:09:30 marka Exp $ */
+
+#ifndef ISC_LIST_H
+#define ISC_LIST_H 1
+#include <isc/boolean.h>
+#include <isc/assertions.h>
+
+#ifdef ISC_LIST_CHECKINIT
+#define ISC_LINK_INSIST(x) ISC_INSIST(x)
+#else
+#define ISC_LINK_INSIST(x)
+#endif
+
+#define ISC_LIST(type) struct { type *head, *tail; }
+#define ISC_LIST_INIT(list) \
+       do { (list).head = NULL; (list).tail = NULL; } while (0)
+
+#define ISC_LINK(type) struct { type *prev, *next; }
+#define ISC_LINK_INIT_TYPE(elt, link, type) \
+       do { \
+               (elt)->link.prev = (type *)(-1); \
+               (elt)->link.next = (type *)(-1); \
+       } while (0)
+#define ISC_LINK_INIT(elt, link) \
+       ISC_LINK_INIT_TYPE(elt, link, void)
+#define ISC_LINK_LINKED(elt, link) ((void *)((elt)->link.prev) != (void *)(-1))
+
+#define ISC_LIST_HEAD(list) ((list).head)
+#define ISC_LIST_TAIL(list) ((list).tail)
+#define ISC_LIST_EMPTY(list) ISC_TF((list).head == NULL)
+
+#define __ISC_LIST_PREPENDUNSAFE(list, elt, link) \
+       do { \
+               if ((list).head != NULL) \
+                       (list).head->link.prev = (elt); \
+               else \
+                       (list).tail = (elt); \
+               (elt)->link.prev = NULL; \
+               (elt)->link.next = (list).head; \
+               (list).head = (elt); \
+       } while (0)
+
+#define ISC_LIST_PREPEND(list, elt, link) \
+       do { \
+               ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \
+               __ISC_LIST_PREPENDUNSAFE(list, elt, link); \
+       } while (0)
+
+#define ISC_LIST_INITANDPREPEND(list, elt, link) \
+               __ISC_LIST_PREPENDUNSAFE(list, elt, link)
+
+#define __ISC_LIST_APPENDUNSAFE(list, elt, link) \
+       do { \
+               if ((list).tail != NULL) \
+                       (list).tail->link.next = (elt); \
+               else \
+                       (list).head = (elt); \
+               (elt)->link.prev = (list).tail; \
+               (elt)->link.next = NULL; \
+               (list).tail = (elt); \
+       } while (0)
+
+#define ISC_LIST_APPEND(list, elt, link) \
+       do { \
+               ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \
+               __ISC_LIST_APPENDUNSAFE(list, elt, link); \
+       } while (0)
+
+#define ISC_LIST_INITANDAPPEND(list, elt, link) \
+               __ISC_LIST_APPENDUNSAFE(list, elt, link)
+
+#define __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, type) \
+       do { \
+               if ((elt)->link.next != NULL) \
+                       (elt)->link.next->link.prev = (elt)->link.prev; \
+               else \
+                       (list).tail = (elt)->link.prev; \
+               if ((elt)->link.prev != NULL) \
+                       (elt)->link.prev->link.next = (elt)->link.next; \
+               else \
+                       (list).head = (elt)->link.next; \
+               (elt)->link.prev = (type *)(-1); \
+               (elt)->link.next = (type *)(-1); \
+       } while (0)
+
+#define __ISC_LIST_UNLINKUNSAFE(list, elt, link) \
+       __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, void)
+
+#define ISC_LIST_UNLINK_TYPE(list, elt, link, type) \
+       do { \
+               ISC_LINK_INSIST(ISC_LINK_LINKED(elt, link)); \
+               __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, type); \
+       } while (0)
+#define ISC_LIST_UNLINK(list, elt, link) \
+       ISC_LIST_UNLINK_TYPE(list, elt, link, void)
+
+#define ISC_LIST_PREV(elt, link) ((elt)->link.prev)
+#define ISC_LIST_NEXT(elt, link) ((elt)->link.next)
+
+#define __ISC_LIST_INSERTBEFOREUNSAFE(list, before, elt, link) \
+       do { \
+               if ((before)->link.prev == NULL) \
+                       ISC_LIST_PREPEND(list, elt, link); \
+               else { \
+                       (elt)->link.prev = (before)->link.prev; \
+                       (before)->link.prev = (elt); \
+                       (elt)->link.prev->link.next = (elt); \
+                       (elt)->link.next = (before); \
+               } \
+       } while (0)
+
+#define ISC_LIST_INSERTBEFORE(list, before, elt, link) \
+       do { \
+               ISC_LINK_INSIST(ISC_LINK_LINKED(before, link)); \
+               ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \
+               __ISC_LIST_INSERTBEFOREUNSAFE(list, before, elt, link); \
+       } while (0)
+
+#define __ISC_LIST_INSERTAFTERUNSAFE(list, after, elt, link) \
+       do { \
+               if ((after)->link.next == NULL) \
+                       ISC_LIST_APPEND(list, elt, link); \
+               else { \
+                       (elt)->link.next = (after)->link.next; \
+                       (after)->link.next = (elt); \
+                       (elt)->link.next->link.prev = (elt); \
+                       (elt)->link.prev = (after); \
+               } \
+       } while (0)
+
+#define ISC_LIST_INSERTAFTER(list, after, elt, link) \
+       do { \
+               ISC_LINK_INSIST(ISC_LINK_LINKED(after, link)); \
+               ISC_LINK_INSIST(!ISC_LINK_LINKED(elt, link)); \
+               __ISC_LIST_INSERTAFTERUNSAFE(list, after, elt, link); \
+       } while (0)
+
+#define ISC_LIST_APPENDLIST(list1, list2, link) \
+       do { \
+               if (ISC_LIST_EMPTY(list1)) \
+                       (list1) = (list2); \
+               else if (!ISC_LIST_EMPTY(list2)) { \
+                       (list1).tail->link.next = (list2).head; \
+                       (list2).head->link.prev = (list1).tail; \
+                       (list1).tail = (list2).tail; \
+               } \
+               (list2).head = NULL; \
+               (list2).tail = NULL; \
+       } while (0)
+
+#define ISC_LIST_ENQUEUE(list, elt, link) ISC_LIST_APPEND(list, elt, link)
+#define __ISC_LIST_ENQUEUEUNSAFE(list, elt, link) \
+       __ISC_LIST_APPENDUNSAFE(list, elt, link)
+#define ISC_LIST_DEQUEUE(list, elt, link) \
+        ISC_LIST_UNLINK_TYPE(list, elt, link, void)
+#define ISC_LIST_DEQUEUE_TYPE(list, elt, link, type) \
+        ISC_LIST_UNLINK_TYPE(list, elt, link, type)
+#define __ISC_LIST_DEQUEUEUNSAFE(list, elt, link) \
+       __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, void)
+#define __ISC_LIST_DEQUEUEUNSAFE_TYPE(list, elt, link, type) \
+       __ISC_LIST_UNLINKUNSAFE_TYPE(list, elt, link, type)
+
+#endif /* ISC_LIST_H */
diff --git a/include/isc/magic.h b/include/isc/magic.h
new file mode 100644 (file)
index 0000000..ff3df24
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: magic.h,v 1.11 2001/01/09 21:57:10 bwelling Exp $ */
+
+#ifndef ISC_MAGIC_H
+#define ISC_MAGIC_H 1
+
+typedef struct {
+       unsigned int magic;
+} isc__magic_t;
+
+
+/*
+ * To use this macro the magic number MUST be the first thing in the
+ * structure, and MUST be of type "unsigned int".
+ *
+ * The intent of this is to allow magic numbers to be checked even though
+ * the object is otherwise opaque.
+ */
+#define ISC_MAGIC_VALID(a,b)   (((a) != NULL) && \
+                                (((const isc__magic_t *)(a))->magic == (b)))
+
+#define ISC_MAGIC(a, b, c, d)  ((a) << 24 | (b) << 16 | (c) << 8 | (d))
+
+#endif /* ISC_MAGIC_H */
diff --git a/include/isc/mem.h b/include/isc/mem.h
new file mode 100644 (file)
index 0000000..f8e73d0
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * Copyright (C) 1997-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: mem.h,v 1.58 2001/09/07 00:51:51 marka Exp $ */
+
+#ifndef ISC_MEM_H
+#define ISC_MEM_H 1
+
+#include <stdio.h>
+#include <isc/types.h>
+
+void *         
+isc_mem_get(isc_mem_t *, size_t);
+void           
+isc_mem_put(isc_mem_t *, void *, size_t);
+
+#endif /* ISC_MEM_H */
diff --git a/include/isc/msgcat.h b/include/isc/msgcat.h
new file mode 100644 (file)
index 0000000..d2bf1e1
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: msgcat.h,v 1.8 2001/01/09 21:57:13 bwelling Exp $ */
+
+#ifndef ISC_MSGCAT_H
+#define ISC_MSGCAT_H 1
+
+/*****
+ ***** Module Info
+ *****/
+
+/*
+ * ISC Message Catalog
+ *
+ * Message catalogs aid internationalization of applications by allowing
+ * messages to be retrieved from locale-specific files instead of
+ * hardwiring them into the application.  This allows translations of
+ * messages appropriate to the locale to be supplied without recompiling
+ * the application.
+ *
+ * Notes:
+ *     It's very important that message catalogs work, even if only the
+ *     default_text can be used.
+ *
+ * MP:
+ *     The caller must ensure appropriate synchronization of
+ *     isc_msgcat_open() and isc_msgcat_close().  isc_msgcat_get()
+ *     ensures appropriate synchronization.
+ *
+ * Reliability:
+ *     No anticipated impact.
+ *
+ * Resources:
+ *     <TBS>
+ *
+ * Security:
+ *     No anticipated impact.
+ *
+ * Standards:
+ *     None.
+ */
+
+/*****
+ ***** Imports
+ *****/
+
+#include <isc/lang.h>
+#include <isc/types.h>
+
+ISC_LANG_BEGINDECLS
+
+/*****
+ ***** Methods
+ *****/
+
+void
+isc_msgcat_open(const char *name, isc_msgcat_t **msgcatp);
+/*
+ * Open a message catalog.
+ *
+ * Notes:
+ *
+ *     If memory cannot be allocated or other failures occur, *msgcatp
+ *     will be set to NULL.  If a NULL msgcat is given to isc_msgcat_get(),
+ *     the default_text will be returned, ensuring that some message text
+ *     will be available, no matter what's going wrong.
+ *
+ * Requires:
+ *
+ *     'name' is a valid string.
+ *
+ *     msgcatp != NULL && *msgcatp == NULL
+ */
+
+void
+isc_msgcat_close(isc_msgcat_t **msgcatp);
+/*
+ * Close a message catalog.
+ *
+ * Notes:
+ *
+ *     Any string pointers returned by prior calls to isc_msgcat_get() are
+ *     invalid after isc_msgcat_close() has been called and must not be
+ *     used.
+ *
+ * Requires:
+ *
+ *     *msgcatp is a valid message catalog or is NULL.
+ *
+ * Ensures:
+ *
+ *     All resources associated with the message catalog are released.
+ *
+ *     *msgcatp == NULL
+ */
+
+const char *
+isc_msgcat_get(isc_msgcat_t *msgcat, int set, int message,
+              const char *default_text);
+/*
+ * Get message 'message' from message set 'set' in 'msgcat'.  If it
+ * is not available, use 'default_text'.
+ *
+ * Requires:
+ *
+ *     'msgcat' is a valid message catalog or is NULL.
+ *
+ *     set > 0
+ *
+ *     message > 0
+ *
+ *     'default_text' is a valid string.
+ */
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_MSGCAT_H */
diff --git a/include/isc/msgs.h b/include/isc/msgs.h
new file mode 100644 (file)
index 0000000..967005b
--- /dev/null
@@ -0,0 +1,183 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2000-2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: msgs.h,v 1.5.2.2.8.3 2004/03/06 08:14:44 marka Exp $ */
+
+#ifndef ISC_MSGS_H
+#define ISC_MSGS_H 1
+
+#include <isc/lib.h>           /* Provide isc_msgcat global variable. */
+#include <isc/msgcat.h>                /* Provide isc_msgcat_*() functions. */
+
+/*
+ * Message sets, named per source file, excepting "GENERAL".
+ * IMPORTANT: The original list is alphabetical, but any new sets must
+ * be added to the end.
+ */
+#define ISC_MSGSET_GENERAL     1
+/*     ISC_RESULT_RESULTSET    2 */     /* XXX */
+/*     ISC_RESULT_UNAVAILABLESET 3 */   /* XXX */
+#define ISC_MSGSET_APP         4
+#define ISC_MSGSET_COMMANDLINE 5
+#define ISC_MSGSET_ENTROPY     6
+#define ISC_MSGSET_IFITERIOCTL 7
+#define ISC_MSGSET_IFITERSYSCTL        8
+#define ISC_MSGSET_LEX         9
+#define ISC_MSGSET_LOG         10
+#define ISC_MSGSET_MEM         11
+#define ISC_MSGSET_NETADDR     12
+#define ISC_MSGSET_PRINT       13
+#define ISC_MSGSET_RESULT      14
+#define ISC_MSGSET_RWLOCK      15
+#define ISC_MSGSET_SOCKADDR    16
+#define ISC_MSGSET_SOCKET      17
+#define ISC_MSGSET_TASK                18
+#define ISC_MSGSET_TIMER       19
+#define ISC_MSGSET_UTIL                20
+#define ISC_MSGSET_IFITERGETIFADDRS 21
+
+/*
+ * Message numbers.  They are only required to be unique per message set,
+ * but are unique throughout the entire catalog to not be as confusing when
+ * debugging.
+ *
+ * The initial numbering was done by multiply by 100 the set number the
+ * message appears in then adding the incremental message number.
+ */
+#define ISC_MSG_FAILED         101 /* "failed" */
+#define ISC_MSG_SUCCEEDED      102 /* Compatible with "failed" */
+#define ISC_MSG_SUCCESS                103 /* More usual way to say "success" */
+#define ISC_MSG_STARTING       104 /* As in "daemon: starting" */
+#define ISC_MSG_STOPING                105 /* As in "daemon: stopping" */
+#define ISC_MSG_ENTERING       106 /* As in "some_subr: entering" */
+#define ISC_MSG_EXITING                107 /* As in "some_subr: exiting" */
+#define ISC_MSG_CALLING                108 /* As in "calling some_subr()" */
+#define ISC_MSG_RETURNED       109 /* As in "some_subr: returned <foo>" */
+#define ISC_MSG_FATALERROR     110 /* "fatal error" */
+#define ISC_MSG_SHUTTINGDOWN   111 /* "shutting down" */
+#define ISC_MSG_RUNNING                112 /* "running" */
+#define ISC_MSG_WAIT           113 /* "wait" */
+#define ISC_MSG_WAITUNTIL      114 /* "waituntil" */
+
+#define ISC_MSG_SIGNALSETUP    201 /* "handle_signal() %d setup: %s" */
+
+#define ISC_MSG_ILLEGALOPT     301 /* "illegal option" */
+#define ISC_MSG_OPTNEEDARG     302 /* "option requires an argument" */
+
+#define ISC_MSG_ENTROPYSTATS   401 /* "Entropy pool %p:  refcnt %u ..." */
+
+#define ISC_MSG_MAKESCANSOCKET 501 /* "making interface scan socket: %s" */
+#define ISC_MSG_GETIFCONFIG    502 /* "get interface configuration: %s" */
+#define ISC_MSG_BUFFERMAX      503 /* "... maximum buffer size exceeded" */
+#define ISC_MSG_GETDESTADDR    504 /* "%s: getting destination address: %s" */
+#define ISC_MSG_GETNETMASK     505 /* "%s: getting netmask: %s" */
+
+#define ISC_MSG_GETIFLISTSIZE  601 /* "getting interface list size: ..." */
+#define ISC_MSG_GETIFLIST      602 /* "getting interface list: ..." */
+#define ISC_MSG_UNEXPECTEDTYPE 603 /* "... unexpected ... message type" */
+
+#define ISC_MSG_UNEXPECTEDSTATE        701 /* "Unexpected state %d" */
+
+#define ISC_MSG_BADTIME                801 /* "Bad 00 99:99:99.999 " */
+#define ISC_MSG_LEVEL          802 /* "level %d: " */
+
+#define ISC_MSG_ADDTRACE       901 /* "add %p size %u " */
+#define ISC_MSG_DELTRACE       902 /* "del %p size %u " */
+#define ISC_MSG_POOLSTATS      903 /* "[Pool statistics]\n" */
+#define ISC_MSG_POOLNAME       904 /* "name" */
+#define ISC_MSG_POOLSIZE       905 /* "size" */
+#define ISC_MSG_POOLMAXALLOC   906 /* "maxalloc" */
+#define ISC_MSG_POOLALLOCATED  907 /* "allocated" */
+#define ISC_MSG_POOLFREECOUNT  908 /* "freecount" */
+#define ISC_MSG_POOLFREEMAX    909 /* "freemax" */
+#define ISC_MSG_POOLFILLCOUNT  910 /* "fillcount" */
+#define ISC_MSG_POOLGETS       911 /* "gets" */
+#define ISC_MSG_DUMPALLOC      912 /* "DUMP OF ALL OUTSTANDING MEMORY ..." */
+#define ISC_MSG_NONE           913 /* "\tNone.\n" */
+#define ISC_MSG_PTRFILELINE    914 /* "\tptr %p file %s line %u\n" */
+
+#define ISC_MSG_UNKNOWNADDR    1001 /* "<unknown address, family %u>" */
+
+#define ISC_MSG_NOLONGDBL      1104 /* "long doubles are not supported" */
+
+#define ISC_MSG_PRINTLOCK      1201 /* "rwlock %p thread %lu ..." */
+#define ISC_MSG_READ          1202 /* "read" */
+#define ISC_MSG_WRITE         1203 /* "write" */
+#define ISC_MSG_READING               1204 /* "reading" */
+#define ISC_MSG_WRITING               1205 /* "writing" */
+#define ISC_MSG_PRELOCK               1206 /* "prelock" */
+#define ISC_MSG_POSTLOCK       1207 /* "postlock" */
+#define ISC_MSG_PREUNLOCK      1208 /* "preunlock" */
+#define ISC_MSG_POSTUNLOCK     1209 /* "postunlock" */
+
+#define ISC_MSG_UNKNOWNFAMILY  1301 /* "unknown address family: %d" */
+
+#define ISC_MSG_WRITEFAILED    1401 /* "write() failed during watcher ..." */
+#define ISC_MSG_READFAILED     1402 /* "read() failed during watcher ... " */
+#define ISC_MSG_PROCESSCMSG    1403 /* "processing cmsg %p" */
+#define ISC_MSG_IFRECEIVED     1404 /* "interface received on ifindex %u" */
+#define ISC_MSG_SENDTODATA     1405 /* "sendto pktinfo data, ifindex %u" */
+#define ISC_MSG_DOIORECV       1406 /* "doio_recv: recvmsg(%d) %d bytes ..." */
+#define ISC_MSG_PKTRECV               1407 /* "packet received correctly" */
+#define ISC_MSG_DESTROYING     1408 /* "destroying" */
+#define ISC_MSG_CREATED               1409 /* "created" */
+#define ISC_MSG_ACCEPTLOCK     1410 /* "internal_accept called, locked ..." */
+#define ISC_MSG_ACCEPTEDCXN    1411 /* "accepted connection, new socket %p" */
+#define ISC_MSG_INTERNALRECV   1412 /* "internal_recv: task %p got event %p" */
+#define ISC_MSG_INTERNALSEND   1413 /* "internal_send: task %p got event %p" */
+#define ISC_MSG_WATCHERMSG     1414 /* "watcher got message %d" */
+#define ISC_MSG_SOCKETSREMAIN  1415 /* "sockets exist" */
+#define ISC_MSG_PKTINFOPROVIDED        1416 /* "pktinfo structure provided, ..." */
+#define ISC_MSG_BOUND         1417 /* "bound" */
+#define ISC_MSG_ACCEPTRETURNED 1418 /* accept() returned %d/%s */
+#define ISC_MSG_TOOMANYFDS     1419 /* %s: too many open file descriptors */
+#define ISC_MSG_ZEROPORT       1420 /* dropping source port zero packet */
+#define ISC_MSG_FILTER        1420 /* setsockopt(SO_ACCEPTFILTER): %s */
+
+#define ISC_MSG_AWAKE         1502 /* "awake" */
+#define ISC_MSG_WORKING               1503 /* "working" */
+#define ISC_MSG_EXECUTE               1504 /* "execute action" */
+#define ISC_MSG_EMPTY         1505 /* "empty" */
+#define ISC_MSG_DONE          1506 /* "done" */
+#define ISC_MSG_QUANTUM               1507 /* "quantum" */
+
+#define ISC_MSG_SCHEDULE       1601 /* "schedule" */
+#define ISC_MSG_SIGNALSCHED    1602 /* "signal (schedule)" */
+#define ISC_MSG_SIGNALDESCHED  1603 /* "signal (deschedule)" */
+#define ISC_MSG_SIGNALDESTROY  1604 /* "signal (destroy)" */
+#define ISC_MSG_IDLERESCHED    1605 /* "idle reschedule" */
+#define ISC_MSG_EVENTNOTALLOC  1606 /* "couldn't allocate event" */
+#define ISC_MSG_SCHEDFAIL      1607 /* "couldn't schedule timer: %u" */
+#define ISC_MSG_POSTING               1608 /* "posting" */
+#define ISC_MSG_WAKEUP        1609 /* "wakeup" */
+
+#define ISC_MSG_LOCK          1701 /* "LOCK" */
+#define ISC_MSG_LOCKING               1702 /* "LOCKING" */
+#define ISC_MSG_LOCKED        1703 /* "LOCKED" */
+#define ISC_MSG_UNLOCKED       1704 /* "UNLOCKED" */
+#define ISC_MSG_RWLOCK        1705 /* "RWLOCK" */
+#define ISC_MSG_RWLOCKED       1706 /* "RWLOCKED" */
+#define ISC_MSG_RWUNLOCK       1707 /* "RWUNLOCK" */
+#define ISC_MSG_BROADCAST      1708 /* "BROADCAST" */
+#define ISC_MSG_SIGNAL        1709 /* "SIGNAL" */
+#define ISC_MSG_UTILWAIT       1710 /* "WAIT" */
+#define ISC_MSG_WAITED        1711 /* "WAITED" */
+
+#define ISC_MSG_GETIFADDRS     1801 /* "getting interface addresses: ..." */
+
+
+#endif /* ISC_MSGS_H */
diff --git a/include/isc/mutex.h b/include/isc/mutex.h
new file mode 100644 (file)
index 0000000..fd6f3ec
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * Copyright (C) 2000, 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: mutex.h,v 1.3 2001/01/09 21:57:55 bwelling Exp $ */
+
+#ifndef ISC_MUTEX_H
+#define ISC_MUTEX_H 1
+
+#include <isc/result.h>                /* for ISC_R_ codes */
+
+typedef int isc_mutex_t;
+
+#define isc_mutex_init(mp) \
+       (*(mp) = 0, ISC_R_SUCCESS)
+#define isc_mutex_lock(mp) \
+       ((*(mp))++ == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
+#define isc_mutex_unlock(mp) \
+       (--(*(mp)) == 0 ? ISC_R_SUCCESS : ISC_R_UNEXPECTED)
+#define isc_mutex_trylock(mp) \
+       (*(mp) == 0 ? ((*(mp))++, ISC_R_SUCCESS) : ISC_R_LOCKBUSY)
+#define isc_mutex_destroy(mp) \
+       (*(mp) == 0 ? (*(mp) = -1, ISC_R_SUCCESS) : ISC_R_UNEXPECTED)
+#define isc_mutex_stats(fp)
+
+#endif /* ISC_MUTEX_H */
diff --git a/include/isc/net.h b/include/isc/net.h
new file mode 100644 (file)
index 0000000..dae5978
--- /dev/null
@@ -0,0 +1,329 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: net.h,v 1.31.2.2.10.8 2004/04/29 01:31:23 marka Exp $ */
+
+#ifndef ISC_NET_H
+#define ISC_NET_H 1
+
+/*****
+ ***** Module Info
+ *****/
+
+/*
+ * Basic Networking Types
+ *
+ * This module is responsible for defining the following basic networking
+ * types:
+ *
+ *             struct in_addr
+ *             struct in6_addr
+ *             struct in6_pktinfo
+ *             struct sockaddr
+ *             struct sockaddr_in
+ *             struct sockaddr_in6
+ *             in_port_t
+ *
+ * It ensures that the AF_ and PF_ macros are defined.
+ *
+ * It declares ntoh[sl]() and hton[sl]().
+ *
+ * It declares inet_aton(), inet_ntop(), and inet_pton().
+ *
+ * It ensures that INADDR_LOOPBACK, INADDR_ANY, IN6ADDR_ANY_INIT,
+ * in6addr_any, and in6addr_loopback are available.
+ *
+ * It ensures that IN_MULTICAST() is available to check for multicast
+ * addresses.
+ *
+ * MP:
+ *     No impact.
+ *
+ * Reliability:
+ *     No anticipated impact.
+ *
+ * Resources:
+ *     N/A.
+ *
+ * Security:
+ *     No anticipated impact.
+ *
+ * Standards:
+ *     BSD Socket API
+ *     RFC 2553
+ */
+
+/***
+ *** Imports.
+ ***/
+#include <isc/platform.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>                /* Contractual promise. */
+
+#include <net/if.h>
+
+#include <netinet/in.h>                /* Contractual promise. */
+#include <arpa/inet.h>         /* Contractual promise. */
+#ifdef ISC_PLATFORM_NEEDNETINETIN6H
+#include <netinet/in6.h>       /* Required on UnixWare. */
+#endif
+#ifdef ISC_PLATFORM_NEEDNETINET6IN6H
+#include <netinet6/in6.h>      /* Required on BSD/OS for in6_pktinfo. */
+#endif
+
+#ifndef ISC_PLATFORM_HAVEIPV6
+#include <isc/ipv6.h>          /* Contractual promise. */
+#endif
+
+#include <isc/lang.h>
+#include <isc/types.h>
+
+#ifdef ISC_PLATFORM_HAVEINADDR6
+#define in6_addr in_addr6      /* Required for pre RFC2133 implementations. */
+#endif
+
+#ifdef ISC_PLATFORM_HAVEIPV6
+/*
+ * Required for some pre RFC2133 implementations.
+ * IN6ADDR_ANY_INIT and IN6ADDR_LOOPBACK_INIT were added in
+ * draft-ietf-ipngwg-bsd-api-04.txt or draft-ietf-ipngwg-bsd-api-05.txt.  
+ * If 's6_addr' is defined then assume that there is a union and three
+ * levels otherwise assume two levels required.
+ */
+#ifndef IN6ADDR_ANY_INIT
+#ifdef s6_addr
+#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } }
+#else
+#define IN6ADDR_ANY_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } }
+#endif
+#endif
+
+#ifndef IN6ADDR_LOOPBACK_INIT
+#ifdef s6_addr
+#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } }
+#else
+#define IN6ADDR_LOOPBACK_INIT { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } }
+#endif
+#endif
+
+#ifndef IN6_IS_ADDR_V4MAPPED
+#define IN6_IS_ADDR_V4MAPPED(x) \
+        (memcmp((x)->s6_addr, in6addr_any.s6_addr, 10) == 0 && \
+         (x)->s6_addr[10] == 0xff && (x)->s6_addr[11] == 0xff)
+#endif
+
+#ifndef IN6_IS_ADDR_V4COMPAT
+#define IN6_IS_ADDR_V4COMPAT(x) \
+        (memcmp((x)->s6_addr, in6addr_any.s6_addr, 12) == 0 && \
+        ((x)->s6_addr[12] != 0 || (x)->s6_addr[13] != 0 || \
+         (x)->s6_addr[14] != 0 || \
+         ((x)->s6_addr[15] != 0 && (x)->s6_addr[15] != 1)))
+#endif
+
+#ifndef IN6_IS_ADDR_MULTICAST
+#define IN6_IS_ADDR_MULTICAST(a)        ((a)->s6_addr[0] == 0xff)
+#endif
+
+#ifndef IN6_IS_ADDR_LINKLOCAL
+#define IN6_IS_ADDR_LINKLOCAL(a) \
+       (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0x80))
+#endif
+
+#ifndef IN6_IS_ADDR_SITELOCAL
+#define IN6_IS_ADDR_SITELOCAL(a) \
+       (((a)->s6_addr[0] == 0xfe) && (((a)->s6_addr[1] & 0xc0) == 0xc0))
+#endif
+
+
+#ifndef IN6_IS_ADDR_LOOPBACK
+#define IN6_IS_ADDR_LOOPBACK(x) \
+       (memcmp((x)->s6_addr, in6addr_loopback.s6_addr, 16) == 0)
+#endif
+#endif
+
+#ifndef AF_INET6
+#define AF_INET6 99
+#endif
+
+#ifndef PF_INET6
+#define PF_INET6 AF_INET6
+#endif
+
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK 0x7f000001UL
+#endif
+
+#if 0
+#ifndef ISC_PLATFORM_HAVEIN6PKTINFO
+struct in6_pktinfo {
+       struct in6_addr ipi6_addr;    /* src/dst IPv6 address */
+       unsigned int    ipi6_ifindex; /* send/recv interface index */
+};
+#endif
+#endif
+
+/*
+ * Cope with a missing in6addr_any and in6addr_loopback.
+ */
+#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY)
+extern const struct in6_addr isc_net_in6addrany;
+#define in6addr_any isc_net_in6addrany
+#endif
+
+#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
+extern const struct in6_addr isc_net_in6addrloop;
+#define in6addr_loopback isc_net_in6addrloop
+#endif
+
+/*
+ * Fix UnixWare 7.1.1's broken IN6_IS_ADDR_* definitions.
+ */
+#ifdef ISC_PLATFORM_FIXIN6ISADDR
+#undef  IN6_IS_ADDR_GEOGRAPHIC
+#define IN6_IS_ADDR_GEOGRAPHIC(a) (((a)->S6_un.S6_l[0] & 0xE0) == 0x80)
+#undef  IN6_IS_ADDR_IPX
+#define IN6_IS_ADDR_IPX(a)        (((a)->S6_un.S6_l[0] & 0xFE) == 0x04)
+#undef  IN6_IS_ADDR_LINKLOCAL
+#define IN6_IS_ADDR_LINKLOCAL(a)  (((a)->S6_un.S6_l[0] & 0xC0FF) == 0x80FE)
+#undef  IN6_IS_ADDR_MULTICAST
+#define IN6_IS_ADDR_MULTICAST(a)  (((a)->S6_un.S6_l[0] & 0xFF) == 0xFF)
+#undef  IN6_IS_ADDR_NSAP
+#define IN6_IS_ADDR_NSAP(a)       (((a)->S6_un.S6_l[0] & 0xFE) == 0x02)
+#undef  IN6_IS_ADDR_PROVIDER
+#define IN6_IS_ADDR_PROVIDER(a)   (((a)->S6_un.S6_l[0] & 0xE0) == 0x40)
+#undef  IN6_IS_ADDR_SITELOCAL
+#define IN6_IS_ADDR_SITELOCAL(a)  (((a)->S6_un.S6_l[0] & 0xC0FF) == 0xC0FE)
+#endif /* ISC_PLATFORM_FIXIN6ISADDR */
+
+/*
+ * Ensure type in_port_t is defined.
+ */
+#ifdef ISC_PLATFORM_NEEDPORTT
+typedef isc_uint16_t in_port_t;
+#endif
+
+/*
+ * If this system does not have MSG_TRUNC (as returned from recvmsg())
+ * ISC_PLATFORM_RECVOVERFLOW will be defined.  This will enable the MSG_TRUNC
+ * faking code in socket.c.
+ */
+#ifndef MSG_TRUNC
+#define ISC_PLATFORM_RECVOVERFLOW
+#endif
+
+#define ISC__IPADDR(x) ((isc_uint32_t)htonl((isc_uint32_t)(x)))
+
+#define ISC_IPADDR_ISMULTICAST(i) \
+               (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \
+                == ISC__IPADDR(0xe0000000))
+
+#define ISC_IPADDR_ISEXPERIMENTAL(i) \
+               (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \
+                == ISC__IPADDR(0xf0000000))
+
+/***
+ *** Functions.
+ ***/
+
+ISC_LANG_BEGINDECLS
+
+isc_result_t
+isc_net_probeipv4(void);
+/*
+ * Check if the system's kernel supports IPv4.
+ *
+ * Returns:
+ *
+ *     ISC_R_SUCCESS           IPv4 is supported.
+ *     ISC_R_NOTFOUND          IPv4 is not supported.
+ *     ISC_R_DISABLED          IPv4 is disabled.
+ *     ISC_R_UNEXPECTED
+ */
+
+isc_result_t
+isc_net_probeipv6(void);
+/*
+ * Check if the system's kernel supports IPv6.
+ *
+ * Returns:
+ *
+ *     ISC_R_SUCCESS           IPv6 is supported.
+ *     ISC_R_NOTFOUND          IPv6 is not supported.
+ *     ISC_R_DISABLED          IPv6 is disabled.
+ *     ISC_R_UNEXPECTED
+ */
+
+isc_result_t
+isc_net_probe_ipv6only(void);
+/*
+ * Check if the system's kernel supports the IPV6_V6ONLY socket option.
+ *
+ * Returns:
+ *
+ *     ISC_R_SUCCESS           the option is supported for both TCP and UDP.
+ *     ISC_R_NOTFOUND          IPv6 itself or the option is not supported.
+ *     ISC_R_UNEXPECTED
+ */
+
+isc_result_t
+isc_net_probe_ipv6pktinfo(void);
+/*
+ * Check if the system's kernel supports the IPV6_(RECV)PKTINFO socket option
+ * for UDP sockets.
+ *
+ * Returns:
+ *
+ *     ISC_R_SUCCESS           the option is supported.
+ *     ISC_R_NOTFOUND          IPv6 itself or the option is not supported.
+ *     ISC_R_UNEXPECTED
+ */
+
+void
+isc_net_disableipv4(void);
+
+void
+isc_net_disableipv6(void);
+
+void
+isc_net_enableipv4(void);
+
+void
+isc_net_enableipv6(void);
+
+#ifdef ISC_PLATFORM_NEEDNTOP
+const char *
+isc_net_ntop(int af, const void *src, char *dst, size_t size);
+#define inet_ntop isc_net_ntop
+#endif
+
+#ifdef ISC_PLATFORM_NEEDPTON
+int
+isc_net_pton(int af, const char *src, void *dst);
+#undef inet_pton
+#define inet_pton isc_net_pton
+#endif
+
+#ifdef ISC_PLATFORM_NEEDATON
+int
+isc_net_aton(const char *cp, struct in_addr *addr);
+#define inet_aton isc_net_aton
+#endif
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_NET_H */
diff --git a/include/isc/netaddr.h b/include/isc/netaddr.h
new file mode 100644 (file)
index 0000000..e209a9f
--- /dev/null
@@ -0,0 +1,149 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1998-2002  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: netaddr.h,v 1.18.12.7 2004/03/08 09:04:52 marka Exp $ */
+
+#ifndef ISC_NETADDR_H
+#define ISC_NETADDR_H 1
+
+#include <isc/lang.h>
+#include <isc/net.h>
+#include <isc/types.h>
+
+ISC_LANG_BEGINDECLS
+
+struct isc_netaddr {
+       unsigned int family;
+       union {
+               struct in_addr in;
+               struct in6_addr in6;
+       } type;
+       isc_uint32_t zone;
+};
+
+isc_boolean_t
+isc_netaddr_equal(const isc_netaddr_t *a, const isc_netaddr_t *b);
+
+isc_boolean_t
+isc_netaddr_eqprefix(const isc_netaddr_t *a, const isc_netaddr_t *b,
+                    unsigned int prefixlen);
+/*
+ * Compare the 'prefixlen' most significant bits of the network
+ * addresses 'a' and 'b'.  Return ISC_TRUE if they are equal,
+ * ISC_FALSE if not.
+ */
+
+isc_result_t
+isc_netaddr_masktoprefixlen(const isc_netaddr_t *s, unsigned int *lenp);
+/*
+ * Convert a netmask in 's' into a prefix length in '*lenp'.
+ * The mask should consist of zero or more '1' bits in the most
+ * most significant part of the address, followed by '0' bits.
+ * If this is not the case, ISC_R_MASKNONCONTIG is returned.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS
+ *     ISC_R_MASKNONCONTIG
+ */
+
+isc_result_t
+isc_netaddr_totext(const isc_netaddr_t *netaddr, isc_buffer_t *target);
+/*
+ * Append a text representation of 'sockaddr' to the buffer 'target'.
+ * The text is NOT null terminated.  Handles IPv4 and IPv6 addresses.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS
+ *     ISC_R_NOSPACE   The text or the null termination did not fit.
+ *     ISC_R_FAILURE   Unspecified failure
+ */
+
+void
+isc_netaddr_format(const isc_netaddr_t *na, char *array, unsigned int size);
+/*
+ * Format a human-readable representation of the network address '*na'
+ * into the character array 'array', which is of size 'size'.
+ * The resulting string is guaranteed to be null-terminated.
+ */
+
+#define ISC_NETADDR_FORMATSIZE \
+       sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX")
+/*
+ * Minimum size of array to pass to isc_netaddr_format().
+ */
+
+void
+isc_netaddr_fromsockaddr(isc_netaddr_t *netaddr, const isc_sockaddr_t *source);
+
+void
+isc_netaddr_fromin(isc_netaddr_t *netaddr, const struct in_addr *ina);
+
+void
+isc_netaddr_fromin6(isc_netaddr_t *netaddr, const struct in6_addr *ina6);
+
+void
+isc_netaddr_setzone(isc_netaddr_t *netaddr, isc_uint32_t zone);
+
+isc_uint32_t
+isc_netaddr_getzone(const isc_netaddr_t *netaddr);
+
+void
+isc_netaddr_any(isc_netaddr_t *netaddr);
+/*
+ * Return the IPv4 wildcard address.
+ */
+
+void
+isc_netaddr_any6(isc_netaddr_t *netaddr);
+/*
+ * Return the IPv6 wildcard address.
+ */
+
+isc_boolean_t
+isc_netaddr_ismulticast(isc_netaddr_t *na);
+/*
+ * Returns ISC_TRUE if the address is a multicast address.
+ */
+
+isc_boolean_t
+isc_netaddr_isexperimental(isc_netaddr_t *na);
+/*
+ * Returns ISC_TRUE if the address is a experimental (CLASS E) address.
+ */
+
+isc_boolean_t
+isc_netaddr_islinklocal(isc_netaddr_t *na);
+/*
+ * Returns ISC_TRUE if the address is a link local address.
+ */
+
+isc_boolean_t
+isc_netaddr_issitelocal(isc_netaddr_t *na);
+/*
+ * Returns ISC_TRUE if the address is a site local address.
+ */
+
+void
+isc_netaddr_fromv4mapped(isc_netaddr_t *t, const isc_netaddr_t *s);
+/*
+ * Convert an IPv6 v4mapped address into an IPv4 address.
+ */
+
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_NETADDR_H */
diff --git a/include/isc/netscope.h b/include/isc/netscope.h
new file mode 100644 (file)
index 0000000..7cc0f18
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2002  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: netscope.h,v 1.4.142.5 2004/03/08 09:04:52 marka Exp $ */
+
+#ifndef ISC_NETSCOPE_H
+#define ISC_NETSCOPE_H 1
+
+ISC_LANG_BEGINDECLS
+
+/*
+ * Convert a string of an IPv6 scope zone to zone index.  If the conversion
+ * succeeds, 'zoneid' will store the index value.
+ * XXXJT: when a standard interface for this purpose is defined,
+ * we should use it.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS: conversion succeeds
+ *     ISC_R_FAILURE: conversion fails
+ */
+isc_result_t
+isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid);
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_NETADDR_H */
diff --git a/include/isc/offset.h b/include/isc/offset.h
new file mode 100644 (file)
index 0000000..709bde4
--- /dev/null
@@ -0,0 +1,44 @@
+/*
+ * Copyright (C) 2000, 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: offset.h,v 1.10 2001/01/09 21:58:43 bwelling Exp $ */
+
+#ifndef ISC_OFFSET_H
+#define ISC_OFFSET_H 1
+
+/*
+ * File offsets are operating-system dependent.
+ */
+#include <limits.h>             /* Required for CHAR_BIT. */
+#include <sys/types.h>
+
+typedef off_t isc_offset_t;
+
+/*
+ * POSIX says "Additionally, blkcnt_t and off_t are extended signed integral
+ * types", so the maximum value is all 1s except for the high bit.
+ * This definition is more complex than it really needs to be because it was
+ * crafted to keep both the SunOS 5.6 and the HP/UX 11 compilers quiet about
+ * integer overflow.  For example, though this is equivalent to just left
+ * shifting 1 to the high bit and then inverting the bits, the SunOS compiler
+ * is unhappy about shifting a positive "1" to negative in a signed integer.
+ */
+#define ISC_OFFSET_MAXIMUM \
+       (~(((off_t)-1 >> (sizeof(off_t) * CHAR_BIT - 1)) \
+                     << (sizeof(off_t) * CHAR_BIT - 1)))
+
+#endif /* ISC_OFFSET_H */
diff --git a/include/isc/once.h b/include/isc/once.h
new file mode 100644 (file)
index 0000000..f57d621
--- /dev/null
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2000, 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: once.h,v 1.3 2001/01/09 21:57:56 bwelling Exp $ */
+
+#ifndef ISC_ONCE_H
+#define ISC_ONCE_H 1
+
+#include <isc/result.h>
+
+typedef isc_boolean_t isc_once_t;
+
+#define ISC_ONCE_INIT ISC_FALSE
+
+#define isc_once_do(op, f) \
+       (!*(op) ? (f(), *(op) = ISC_TRUE, ISC_R_SUCCESS) : ISC_R_SUCCESS)
+
+#endif /* ISC_ONCE_H */
diff --git a/include/isc/platform.h b/include/isc/platform.h
new file mode 100644 (file)
index 0000000..bd11a25
--- /dev/null
@@ -0,0 +1,40 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: platform.h.in,v 1.28 2001/11/19 03:08:26 mayer Exp $ */
+
+#ifndef ISC_PLATFORM_H
+#define ISC_PLATFORM_H 1
+
+
+#ifndef ISC_PLATFORM_USEDECLSPEC
+#define LIBISC_EXTERNAL_DATA
+#define LIBDNS_EXTERNAL_DATA
+#define LIBISCCC_EXTERNAL_DATA
+#define LIBISCCFG_EXTERNAL_DATA
+#define LIBBIND9_EXTERNAL_DATA
+#endif /* ISC_PLATFORM_USEDECLSPEC */
+
+/*
+ * Tell emacs to use C mode for this file.
+ *
+ * Local Variables:
+ * mode: c
+ * End:
+ */
+
+#endif /* ISC_PLATFORM_H */
diff --git a/include/isc/print.h b/include/isc/print.h
new file mode 100644 (file)
index 0000000..7a1bc83
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: print.h,v 1.17 2001/02/27 02:19:33 gson Exp $ */
+
+#ifndef ISC_PRINT_H
+#define ISC_PRINT_H 1
+
+/***
+ *** Imports
+ ***/
+
+#include <isc/formatcheck.h>    /* Required for ISC_FORMAT_PRINTF() macro. */
+#include <isc/lang.h>
+#include <isc/platform.h>
+
+/*
+ * This block allows lib/isc/print.c to be cleanly compiled even if
+ * the platform does not need it.  The standard Makefile will still
+ * not compile print.c or archive print.o, so this is just to make test
+ * compilation ("make print.o") easier.
+ */
+#if !defined(ISC_PLATFORM_NEEDVSNPRINTF) && defined(ISC__PRINT_SOURCE)
+#define ISC_PLATFORM_NEEDVSNPRINTF
+#endif
+
+/***
+ *** Macros
+ ***/
+#define ISC_PRINT_QUADFORMAT ISC_PLATFORM_QUADFORMAT
+
+/***
+ *** Functions
+ ***/
+
+#ifdef ISC_PLATFORM_NEEDVSNPRINTF
+#include <stdarg.h>
+#include <stddef.h>
+
+ISC_LANG_BEGINDECLS
+
+int
+isc_print_vsnprintf(char *str, size_t size, const char *format, va_list ap)
+     ISC_FORMAT_PRINTF(3, 0);
+#define vsnprintf isc_print_vsnprintf
+
+int
+isc_print_snprintf(char *str, size_t size, const char *format, ...)
+     ISC_FORMAT_PRINTF(3, 4);
+#define snprintf isc_print_snprintf
+
+ISC_LANG_ENDDECLS
+#endif /* ISC_PLATFORM_NEEDVSNPRINTF */
+
+#endif /* ISC_PRINT_H */
diff --git a/include/isc/region.h b/include/isc/region.h
new file mode 100644 (file)
index 0000000..5622394
--- /dev/null
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1998-2002  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: region.h,v 1.16.12.3 2004/03/08 09:04:53 marka Exp $ */
+
+#ifndef ISC_REGION_H
+#define ISC_REGION_H 1
+
+#include <isc/types.h>
+
+struct isc_region {
+       unsigned char * base;
+       unsigned int    length;
+};
+
+struct isc_textregion {
+       char *          base;
+       unsigned int    length;
+};
+
+/* XXXDCL questionable ... bears discussion.  we have been putting off
+ * discussing the region api.
+ */
+struct isc_constregion {
+       const void *    base;
+       unsigned int    length;
+};
+
+struct isc_consttextregion {
+       const char *    base;
+       unsigned int    length;
+};
+
+/*
+ * The region structure is not opaque, and is usually directly manipulated.
+ * Some macros are defined below for convenience.
+ */
+
+#define isc_region_consume(r,l) \
+       do { \
+               isc_region_t *_r = (r); \
+               unsigned int _l = (l); \
+               INSIST(_r->length >= _l); \
+               _r->base += _l; \
+               _r->length -= _l; \
+       } while (0)
+
+#define isc_textregion_consume(r,l) \
+       do { \
+               isc_textregion_t *_r = (r); \
+               unsigned int _l = (l); \
+               INSIST(_r->length >= _l); \
+               _r->base += _l; \
+               _r->length -= _l; \
+       } while (0)
+
+#define isc_constregion_consume(r,l) \
+       do { \
+               isc_constregion_t *_r = (r); \
+               unsigned int _l = (l); \
+               INSIST(_r->length >= _l); \
+               _r->base += _l; \
+               _r->length -= _l; \
+       } while (0)
+
+int
+isc_region_compare(isc_region_t *r1, isc_region_t *r2);
+/*
+ * Compares the contents of two regions 
+ *
+ * Requires: 
+ *     'r1' is a valid region
+ *     'r2' is a valid region
+ *
+ * Returns:
+ *      < 0 if r1 is lexicographically less than r2
+ *      = 0 if r1 is lexicographically identical to r2
+ *      > 0 if r1 is lexicographically greater than r2
+ */
+
+#endif /* ISC_REGION_H */
diff --git a/include/isc/result.h b/include/isc/result.h
new file mode 100644 (file)
index 0000000..93f7cef
--- /dev/null
@@ -0,0 +1,106 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1998-2001, 2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: result.h,v 1.57.2.2.8.5 2004/05/15 03:46:13 jinmei Exp $ */
+
+#ifndef ISC_RESULT_H
+#define ISC_RESULT_H 1
+
+#include <isc/lang.h>
+#include <isc/types.h>
+
+#define ISC_R_SUCCESS                  0       /* success */
+#define ISC_R_NOMEMORY                 1       /* out of memory */
+#define ISC_R_TIMEDOUT                 2       /* timed out */
+#define ISC_R_NOTHREADS                        3       /* no available threads */
+#define ISC_R_ADDRNOTAVAIL             4       /* address not available */
+#define ISC_R_ADDRINUSE                        5       /* address in use */
+#define ISC_R_NOPERM                   6       /* permission denied */
+#define ISC_R_NOCONN                   7       /* no pending connections */
+#define ISC_R_NETUNREACH               8       /* network unreachable */
+#define ISC_R_HOSTUNREACH              9       /* host unreachable */
+#define ISC_R_NETDOWN                  10      /* network down */
+#define ISC_R_HOSTDOWN                 11      /* host down */
+#define ISC_R_CONNREFUSED              12      /* connection refused */
+#define ISC_R_NORESOURCES              13      /* not enough free resources */
+#define ISC_R_EOF                      14      /* end of file */
+#define ISC_R_BOUND                    15      /* socket already bound */
+#define ISC_R_RELOAD                   16      /* reload */
+#define ISC_R_LOCKBUSY                 17      /* lock busy */
+#define ISC_R_EXISTS                   18      /* already exists */
+#define ISC_R_NOSPACE                  19      /* ran out of space */
+#define ISC_R_CANCELED                 20      /* operation canceled */
+#define ISC_R_NOTBOUND                 21      /* socket is not bound */
+#define ISC_R_SHUTTINGDOWN             22      /* shutting down */
+#define ISC_R_NOTFOUND                 23      /* not found */
+#define ISC_R_UNEXPECTEDEND            24      /* unexpected end of input */
+#define ISC_R_FAILURE                  25      /* generic failure */
+#define ISC_R_IOERROR                  26      /* I/O error */
+#define ISC_R_NOTIMPLEMENTED           27      /* not implemented */
+#define ISC_R_UNBALANCED               28      /* unbalanced parentheses */
+#define ISC_R_NOMORE                   29      /* no more */
+#define ISC_R_INVALIDFILE              30      /* invalid file */
+#define ISC_R_BADBASE64                        31      /* bad base64 encoding */
+#define ISC_R_UNEXPECTEDTOKEN          32      /* unexpected token */
+#define ISC_R_QUOTA                    33      /* quota reached */
+#define ISC_R_UNEXPECTED               34      /* unexpected error */
+#define ISC_R_ALREADYRUNNING           35      /* already running */
+#define ISC_R_IGNORE                   36      /* ignore */
+#define ISC_R_MASKNONCONTIG             37     /* addr mask not contiguous */
+#define ISC_R_FILENOTFOUND             38      /* file not found */
+#define ISC_R_FILEEXISTS               39      /* file already exists */
+#define ISC_R_NOTCONNECTED             40      /* socket is not connected */
+#define ISC_R_RANGE                    41      /* out of range */
+#define ISC_R_NOENTROPY                        42      /* out of entropy */
+#define ISC_R_MULTICAST                        43      /* invalid use of multicast */
+#define ISC_R_NOTFILE                  44      /* not a file */
+#define ISC_R_NOTDIRECTORY             45      /* not a directory */
+#define ISC_R_QUEUEFULL                        46      /* queue is full */
+#define ISC_R_FAMILYMISMATCH           47      /* address family mismatch */
+#define ISC_R_FAMILYNOSUPPORT          48      /* AF not supported */
+#define ISC_R_BADHEX                   49      /* bad hex encoding */
+#define ISC_R_TOOMANYOPENFILES         50      /* too many open files */
+#define ISC_R_NOTBLOCKING              51      /* not blocking */
+#define ISC_R_UNBALANCEDQUOTES         52      /* unbalanced quotes */
+#define ISC_R_INPROGRESS               53      /* operation in progress */
+#define ISC_R_CONNECTIONRESET          54      /* connection reset */
+#define ISC_R_SOFTQUOTA                        55      /* soft quota reached */
+#define ISC_R_BADNUMBER                        56      /* not a valid number */
+#define ISC_R_DISABLED                 57      /* disabled */
+#define ISC_R_MAXSIZE                  58      /* max size */
+#define ISC_R_BADADDRESSFORM           59      /* invalid address format */
+
+/*
+ * Not a result code: the number of results.
+ */
+#define ISC_R_NRESULTS                         60
+
+ISC_LANG_BEGINDECLS
+
+const char *
+isc_result_totext(isc_result_t);
+/*
+ * Convert an isc_result_t into a string message describing the result.
+ */
+
+isc_result_t
+isc_result_register(unsigned int base, unsigned int nresults,
+                   const char **text, isc_msgcat_t *msgcat, int set);
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_RESULT_H */
diff --git a/include/isc/sockaddr.h b/include/isc/sockaddr.h
new file mode 100644 (file)
index 0000000..635af38
--- /dev/null
@@ -0,0 +1,202 @@
+/*
+ * Copyright (C) 1998-2002  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: sockaddr.h,v 1.39 2002/04/03 06:38:36 marka Exp $ */
+
+#ifndef ISC_SOCKADDR_H
+#define ISC_SOCKADDR_H 1
+
+#include <isc/lang.h>
+#include <isc/net.h>
+#include <isc/types.h>
+
+struct isc_sockaddr {
+       union {
+               struct sockaddr         sa;
+               struct sockaddr_in      sin;
+               struct sockaddr_in6     sin6;
+       }                               type;
+       unsigned int                    length;         /* XXXRTH beginning? */
+       ISC_LINK(struct isc_sockaddr)   link;
+};
+
+typedef ISC_LIST(struct isc_sockaddr)  isc_sockaddrlist_t;
+
+ISC_LANG_BEGINDECLS
+
+isc_boolean_t
+isc_sockaddr_equal(const isc_sockaddr_t *a, const isc_sockaddr_t *b);
+/*
+ * Return ISC_TRUE iff the socket addresses 'a' and 'b' are equal.
+ */
+
+isc_boolean_t
+isc_sockaddr_eqaddr(const isc_sockaddr_t *a, const isc_sockaddr_t *b);
+/*
+ * Return ISC_TRUE iff the address parts of the socket addresses
+ * 'a' and 'b' are equal, ignoring the ports.
+ */
+
+isc_boolean_t
+isc_sockaddr_eqaddrprefix(const isc_sockaddr_t *a, const isc_sockaddr_t *b,
+                         unsigned int prefixlen);
+/*
+ * Return ISC_TRUE iff the most significant 'prefixlen' bits of the
+ * socket addresses 'a' and 'b' are equal, ignoring the ports.
+ */
+
+unsigned int
+isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, isc_boolean_t address_only);
+/*
+ * Return a hash value for the socket address 'sockaddr'.  If 'address_only'
+ * is ISC_TRUE, the hash value will not depend on the port.
+ *
+ * IPv6 addresses containing mapped IPv4 addresses generate the same hash
+ * value as the equivalent IPv4 address.
+ */
+
+void
+isc_sockaddr_any(isc_sockaddr_t *sockaddr);
+/*
+ * Return the IPv4 wildcard address.
+ */
+
+void
+isc_sockaddr_any6(isc_sockaddr_t *sockaddr);
+/*
+ * Return the IPv6 wildcard address.
+ */
+
+void
+isc_sockaddr_anyofpf(isc_sockaddr_t *sockaddr, int family);
+/*
+ * Set '*sockaddr' to the wildcard address of protocol family
+ * 'family'.
+ *
+ * Requires:
+ *     'family' is AF_INET or AF_INET6.
+ */
+
+void
+isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
+                   in_port_t port);
+/*
+ * Construct an isc_sockaddr_t from an IPv4 address and port.
+ */
+
+void
+isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, const struct in6_addr *ina6,
+                    in_port_t port);
+/*
+ * Construct an isc_sockaddr_t from an IPv6 address and port.
+ */
+
+void
+isc_sockaddr_v6fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
+                     in_port_t port);
+/*
+ * Construct an IPv6 isc_sockaddr_t representing a mapped IPv4 address.
+ */
+
+void
+isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na,
+                        in_port_t port);
+/*
+ * Construct an isc_sockaddr_t from an isc_netaddr_t and port.
+ */
+
+int
+isc_sockaddr_pf(const isc_sockaddr_t *sockaddr);
+/*
+ * Get the protocol family of 'sockaddr'.
+ *
+ * Requires:
+ *
+ *     'sockaddr' is a valid sockaddr with an address family of AF_INET
+ *     or AF_INET6.
+ *
+ * Returns:
+ *
+ *     The protocol family of 'sockaddr', e.g. PF_INET or PF_INET6.
+ */
+
+void
+isc_sockaddr_setport(isc_sockaddr_t *sockaddr, in_port_t port);
+/*
+ * Set the port of 'sockaddr' to 'port'.
+ */
+
+in_port_t
+isc_sockaddr_getport(isc_sockaddr_t *sockaddr);
+/*
+ * Get the port stored in 'sockaddr'.
+ */
+
+isc_result_t
+isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target);
+/*
+ * Append a text representation of 'sockaddr' to the buffer 'target'.
+ * The text will include both the IP address (v4 or v6) and the port.
+ * The text is null terminated, but the terminating null is not
+ * part of the buffer's used region.
+ *
+ * Returns:
+ *     ISC_R_SUCCESS
+ *     ISC_R_NOSPACE   The text or the null termination did not fit.
+ */
+
+void
+isc_sockaddr_format(const isc_sockaddr_t *sa, char *array, unsigned int size);
+/*
+ * Format a human-readable representation of the socket address '*sa'
+ * into the character array 'array', which is of size 'size'.
+ * The resulting string is guaranteed to be null-terminated.
+ */
+
+isc_boolean_t
+isc_sockaddr_ismulticast(isc_sockaddr_t *sa);
+/*
+ * Returns ISC_TRUE if the address is a multicast address.
+ */
+
+isc_boolean_t
+isc_sockaddr_isexperimental(isc_sockaddr_t *sa);
+/*
+ * Returns ISC_TRUE if the address is a experimental (CLASS E) address.
+ */
+
+isc_boolean_t
+isc_sockaddr_islinklocal(isc_sockaddr_t *sa);
+/*
+ * Returns ISC_TRUE if the address is a link local addresss.
+ */
+
+isc_boolean_t
+isc_sockaddr_issitelocal(isc_sockaddr_t *sa);
+/*
+ * Returns ISC_TRUE if the address is a sitelocal address.
+ */
+
+#define ISC_SOCKADDR_FORMATSIZE \
+       sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:XXX.XXX.XXX.XXX#YYYYY")
+/*
+ * Minimum size of array to pass to isc_sockaddr_format().
+ */
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_SOCKADDR_H */
diff --git a/include/isc/strerror.h b/include/isc/strerror.h
new file mode 100644 (file)
index 0000000..ca428af
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: strerror.h,v 1.3 2001/11/20 01:45:47 gson Exp $ */
+
+#ifndef ISC_STRERROR_H
+#define ISC_STRERROR_H
+
+#include <sys/types.h>
+
+#include <isc/lang.h>
+
+ISC_LANG_BEGINDECLS
+
+#define ISC_STRERRORSIZE 128
+
+/*
+ * Provide a thread safe wrapper to strerrror().
+ *
+ * Requires:
+ *     'buf' to be non NULL.
+ */
+void
+isc__strerror(int num, char *buf, size_t bufsize);
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_STRERROR_H */
diff --git a/include/isc/string.h b/include/isc/string.h
new file mode 100644 (file)
index 0000000..e16219f
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 2000, 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: string.h,v 1.9 2001/01/09 21:57:37 bwelling Exp $ */
+
+#ifndef ISC_STRING_H
+#define ISC_STRING_H 1
+
+#include <string.h>
+
+#include <isc/int.h>
+#include <isc/lang.h>
+#include <isc/platform.h>
+
+ISC_LANG_BEGINDECLS
+
+isc_uint64_t
+isc_string_touint64(char *source, char **endp, int base);
+/*
+ * Convert the string pointed to by 'source' to isc_uint64_t.
+ *
+ * On successful conversion 'endp' points to the first character
+ * after conversion is complete.
+ *
+ * 'base': 0 or 2..36
+ *
+ * If base is 0 the base is computed from the string type.
+ *
+ * On error 'endp' points to 'source'.
+ */
+
+
+char *
+isc_string_separate(char **stringp, const char *delim);
+
+#ifdef ISC_PLATFORM_NEEDSTRSEP
+#define strsep isc_string_separate
+#endif
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_STRING_H */
diff --git a/include/isc/types.h b/include/isc/types.h
new file mode 100644 (file)
index 0000000..b30f55e
--- /dev/null
@@ -0,0 +1,102 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: types.h,v 1.33 2002/07/19 03:39:44 marka Exp $ */
+
+#ifndef ISC_TYPES_H
+#define ISC_TYPES_H 1
+
+/*
+ * OS-specific types, from the OS-specific include directories.
+ */
+#include <isc/int.h>
+#include <isc/offset.h>
+
+/*
+ * XXXDCL should isc_boolean_t be moved here, requiring an explicit include
+ * of <isc/boolean.h> when ISC_TRUE/ISC_FALSE/ISC_TF() are desired?
+ */
+#include <isc/boolean.h>
+/*
+ * XXXDCL This is just for ISC_LIST and ISC_LINK, but gets all of the other
+ * list macros too.
+ */
+#include <isc/list.h>
+
+/***
+ *** Core Types.  Alphabetized by defined type.
+ ***/
+
+typedef struct isc_bitstring           isc_bitstring_t;
+typedef struct isc_buffer              isc_buffer_t;
+typedef ISC_LIST(isc_buffer_t)         isc_bufferlist_t;
+typedef struct isc_constregion         isc_constregion_t;
+typedef struct isc_consttextregion     isc_consttextregion_t;
+typedef struct isc_entropy             isc_entropy_t;
+typedef struct isc_entropysource       isc_entropysource_t;
+typedef struct isc_event               isc_event_t;
+typedef ISC_LIST(isc_event_t)          isc_eventlist_t;
+typedef unsigned int                   isc_eventtype_t;
+typedef isc_uint32_t                   isc_fsaccess_t;
+typedef struct isc_interface           isc_interface_t;
+typedef struct isc_interfaceiter       isc_interfaceiter_t;
+typedef struct isc_interval            isc_interval_t;
+typedef struct isc_lex                 isc_lex_t;
+typedef struct isc_log                         isc_log_t;
+typedef struct isc_logcategory         isc_logcategory_t;
+typedef struct isc_logconfig           isc_logconfig_t;
+typedef struct isc_logmodule           isc_logmodule_t;
+typedef struct isc_mem                 isc_mem_t;
+typedef struct isc_mempool             isc_mempool_t;
+typedef struct isc_msgcat              isc_msgcat_t;
+typedef struct isc_ondestroy           isc_ondestroy_t;
+typedef struct isc_netaddr             isc_netaddr_t;
+typedef struct isc_quota               isc_quota_t;
+typedef struct isc_random              isc_random_t;
+typedef struct isc_ratelimiter         isc_ratelimiter_t;
+typedef struct isc_region              isc_region_t;
+typedef isc_uint64_t                   isc_resourcevalue_t;
+typedef unsigned int                   isc_result_t;
+typedef struct isc_rwlock              isc_rwlock_t;
+typedef struct isc_sockaddr            isc_sockaddr_t;
+typedef struct isc_socket              isc_socket_t;
+typedef struct isc_socketevent         isc_socketevent_t;
+typedef struct isc_socketmgr           isc_socketmgr_t;
+typedef struct isc_symtab              isc_symtab_t;
+typedef struct isc_task                        isc_task_t;
+typedef ISC_LIST(isc_task_t)           isc_tasklist_t;
+typedef struct isc_taskmgr             isc_taskmgr_t;
+typedef struct isc_textregion          isc_textregion_t;
+typedef struct isc_time                        isc_time_t;
+typedef struct isc_timer               isc_timer_t;
+typedef struct isc_timermgr            isc_timermgr_t;
+
+typedef void (*isc_taskaction_t)(isc_task_t *, isc_event_t *);
+
+typedef enum {
+       isc_resource_coresize = 1,
+       isc_resource_cputime,
+       isc_resource_datasize,
+       isc_resource_filesize,
+       isc_resource_lockedmemory,
+       isc_resource_openfiles,
+       isc_resource_processes,
+       isc_resource_residentsize,
+       isc_resource_stacksize
+} isc_resource_t;
+
+#endif /* ISC_TYPES_H */
diff --git a/include/isc/util.h b/include/isc/util.h
new file mode 100644 (file)
index 0000000..6144e11
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 1998-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: util.h,v 1.23 2001/11/30 01:59:38 gson Exp $ */
+
+#ifndef ISC_UTIL_H
+#define ISC_UTIL_H 1
+
+/*
+ * NOTE:
+ *
+ * This file is not to be included from any <isc/???.h> (or other) library
+ * files.
+ *
+ * Including this file puts several macros in your name space that are
+ * not protected (as all the other ISC functions/macros do) by prepending
+ * ISC_ or isc_ to the name.
+ */
+
+/***
+ *** General Macros.
+ ***/
+
+/*
+ * Use this to hide unused function arguments.
+ *
+ * int
+ * foo(char *bar)
+ * {
+ *     UNUSED(bar);
+ * }
+ */
+#define UNUSED(x)      (void)(x)
+
+#define ISC_MAX(a, b)  ((a) > (b) ? (a) : (b))
+#define ISC_MIN(a, b)  ((a) < (b) ? (a) : (b))
+
+/*
+ * Use this to remove the const qualifier of a variable to assign it to
+ * a non-const variable or pass it as a non-const function argument ...
+ * but only when you are sure it won't then be changed!
+ * This is necessary to sometimes shut up some compilers
+ * (as with gcc -Wcast-qual) when there is just no other good way to avoid the
+ * situation.
+ */
+#define DE_CONST(konst, var) \
+       do { \
+               union { const void *k; void *v; } _u; \
+               _u.k = konst; \
+               var = _u.v; \
+       } while (0)
+
+/*
+ * Use this in translation units that would otherwise be empty, to
+ * suppress compiler warnings.
+ */
+#define EMPTY_TRANSLATION_UNIT static void isc__empty(void) { isc__empty(); }
+
+/*
+ * We use macros instead of calling the routines directly because
+ * the capital letters make the locking stand out.
+ *
+ * We RUNTIME_CHECK for success since in general there's no way
+ * for us to continue if they fail.
+ */
+
+#ifdef ISC_UTIL_TRACEON
+#define ISC_UTIL_TRACE(a) a
+#include <stdio.h>             /* Required for fprintf/stderr when tracing. */
+#include <isc/msgs.h>          /* Required for isc_msgcat when tracing. */
+#else
+#define ISC_UTIL_TRACE(a)
+#endif
+
+#include <isc/result.h>                /* Contractual promise. */
+
+#define LOCK(lp) do { \
+       ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_LOCKING, "LOCKING"), \
+                              (lp), __FILE__, __LINE__)); \
+       RUNTIME_CHECK(isc_mutex_lock((lp)) == ISC_R_SUCCESS); \
+       ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_LOCKED, "LOCKED"), \
+                              (lp), __FILE__, __LINE__)); \
+       } while (0)
+#define UNLOCK(lp) do { \
+       RUNTIME_CHECK(isc_mutex_unlock((lp)) == ISC_R_SUCCESS); \
+       ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_UNLOCKED, "UNLOCKED"), \
+                              (lp), __FILE__, __LINE__)); \
+       } while (0)
+#define ISLOCKED(lp) (1)
+#define DESTROYLOCK(lp) \
+       RUNTIME_CHECK(isc_mutex_destroy((lp)) == ISC_R_SUCCESS)
+
+
+#define BROADCAST(cvp) do { \
+       ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_BROADCAST, "BROADCAST"),\
+                              (cvp), __FILE__, __LINE__)); \
+       RUNTIME_CHECK(isc_condition_broadcast((cvp)) == ISC_R_SUCCESS); \
+       } while (0)
+#define SIGNAL(cvp) do { \
+       ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %d\n", \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_SIGNAL, "SIGNAL"), \
+                              (cvp), __FILE__, __LINE__)); \
+       RUNTIME_CHECK(isc_condition_signal((cvp)) == ISC_R_SUCCESS); \
+       } while (0)
+#define WAIT(cvp, lp) do { \
+       ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %p %s %d\n", \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_UTILWAIT, "WAIT"), \
+                              (cvp), \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_LOCK, "LOCK"), \
+                              (lp), __FILE__, __LINE__)); \
+       RUNTIME_CHECK(isc_condition_wait((cvp), (lp)) == ISC_R_SUCCESS); \
+       ISC_UTIL_TRACE(fprintf(stderr, "%s %p %s %p %s %d\n", \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_WAITED, "WAITED"), \
+                              (cvp), \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_LOCKED, "LOCKED"), \
+                              (lp), __FILE__, __LINE__)); \
+       } while (0)
+
+/*
+ * isc_condition_waituntil can return ISC_R_TIMEDOUT, so we
+ * don't RUNTIME_CHECK the result.
+ *
+ *  XXX Also, can't really debug this then...
+ */
+
+#define WAITUNTIL(cvp, lp, tp) \
+       isc_condition_waituntil((cvp), (lp), (tp))
+
+#define RWLOCK(lp, t) do { \
+       ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_RWLOCK, "RWLOCK"), \
+                              (lp), (t), __FILE__, __LINE__)); \
+       RUNTIME_CHECK(isc_rwlock_lock((lp), (t)) == ISC_R_SUCCESS); \
+       ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_RWLOCKED, "RWLOCKED"), \
+                              (lp), (t), __FILE__, __LINE__)); \
+       } while (0)
+#define RWUNLOCK(lp, t) do { \
+       ISC_UTIL_TRACE(fprintf(stderr, "%s %p, %d %s %d\n", \
+                              isc_msgcat_get(isc_msgcat, ISC_MSGSET_UTIL, \
+                                             ISC_MSG_RWUNLOCK, "RWUNLOCK"), \
+                              (lp), (t), __FILE__, __LINE__)); \
+       RUNTIME_CHECK(isc_rwlock_unlock((lp), (t)) == ISC_R_SUCCESS); \
+       } while (0)
+
+#define DESTROYMUTEXBLOCK(bp, n) \
+       RUNTIME_CHECK(isc_mutexblock_destroy((bp), (n)) == ISC_R_SUCCESS)
+
+/*
+ * List Macros.
+ */
+#include <isc/list.h>          /* Contractual promise. */
+
+#define LIST(type)                     ISC_LIST(type)
+#define INIT_LIST(type)                        ISC_LIST_INIT(type)
+#define LINK(type)                     ISC_LINK(type)
+#define INIT_LINK(elt, link)           ISC_LINK_INIT(elt, link)
+#define HEAD(list)                     ISC_LIST_HEAD(list)
+#define TAIL(list)                     ISC_LIST_TAIL(list)
+#define EMPTY(list)                    ISC_LIST_EMPTY(list)
+#define PREV(elt, link)                        ISC_LIST_PREV(elt, link)
+#define NEXT(elt, link)                        ISC_LIST_NEXT(elt, link)
+#define APPEND(list, elt, link)                ISC_LIST_APPEND(list, elt, link)
+#define PREPEND(list, elt, link)       ISC_LIST_PREPEND(list, elt, link)
+#define UNLINK(list, elt, link)                ISC_LIST_UNLINK(list, elt, link)
+#define ENQUEUE(list, elt, link)       ISC_LIST_APPEND(list, elt, link)
+#define DEQUEUE(list, elt, link)       ISC_LIST_UNLINK(list, elt, link)
+#define INSERTBEFORE(li, b, e, ln)     ISC_LIST_INSERTBEFORE(li, b, e, ln)
+#define INSERTAFTER(li, a, e, ln)      ISC_LIST_INSERTAFTER(li, a, e, ln)
+#define APPENDLIST(list1, list2, link) ISC_LIST_APPENDLIST(list1, list2, link)
+
+/*
+ * Assertions
+ */
+#include <isc/assertions.h>    /* Contractual promise. */
+
+#define REQUIRE(e)                     ISC_REQUIRE(e)
+#define ENSURE(e)                      ISC_ENSURE(e)
+#define INSIST(e)                      ISC_INSIST(e)
+#define INVARIANT(e)                   ISC_INVARIANT(e)
+
+/*
+ * Errors
+ */
+#include <isc/error.h>         /* Contractual promise. */
+
+#define UNEXPECTED_ERROR               isc_error_unexpected
+#define FATAL_ERROR                    isc_error_fatal
+#define RUNTIME_CHECK(cond)            ISC_ERROR_RUNTIMECHECK(cond)
+
+/*
+ * Time
+ */
+#define TIME_NOW(tp)   RUNTIME_CHECK(isc_time_now((tp)) == ISC_R_SUCCESS)
+
+#endif /* ISC_UTIL_H */
diff --git a/include/l_stdlib.h b/include/l_stdlib.h
new file mode 100644 (file)
index 0000000..58bbeed
--- /dev/null
@@ -0,0 +1,506 @@
+/*
+ * Proto types for machines that are not ANSI and POSIX         compliant.
+ * This is optional
+ */
+
+#ifndef _l_stdlib_h
+#define _l_stdlib_h
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#endif
+
+#if defined(__STDC__) || defined(HAVE_STDARG_H)
+# include <stdarg.h>
+#else
+# include <varargs.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+
+/* Needed for speed_t. */
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+
+#ifdef HAVE_ERRNO_H
+# include <errno.h>
+#endif
+
+#include "ntp_types.h"
+#include "ntp_proto.h"
+
+/* Let's try to keep this more or less alphabetized... */
+
+#ifdef DECL_ADJTIME_0
+struct timeval;
+extern int     adjtime         P((struct timeval *, struct timeval *));
+#endif
+
+#ifdef DECL_BCOPY_0
+#ifndef bcopy
+extern void    bcopy           P((const char *, char *, int));
+#endif
+#endif
+
+#ifdef DECL_BZERO_0
+#ifndef bzero
+extern void    bzero           P((char *, int));
+#endif
+#endif
+
+#ifdef DECL_CFSETISPEED_0
+struct termios;
+extern int     cfsetispeed     P((struct termios *, speed_t));
+extern int     cfsetospeed     P((struct termios *, speed_t));
+#endif
+
+extern char *  getpass         P((const char *));
+
+#ifdef DECL_HSTRERROR_0
+extern const char * hstrerror  P((int));
+#endif
+
+#ifdef DECL_INET_NTOA_0
+struct in_addr;
+extern char *  inet_ntoa       P((struct in_addr));
+#endif
+
+#ifdef DECL_IOCTL_0
+extern int     ioctl           P((int, u_long, char *));
+#endif
+
+#ifdef DECL_IPC_0
+struct sockaddr;
+extern int     bind            P((int, struct sockaddr *, int));
+extern int     connect         P((int, struct sockaddr *, int));
+extern int     recv            P((int, char *, int, int));
+extern int     recvfrom        P((int, char *, int, int, struct sockaddr *, int *));
+extern int     send            P((int, char *, int, int));
+extern int     sendto          P((int, char *, int, int, struct sockaddr *, int));
+extern int     setsockopt      P((int, int, int, char *, int));
+extern int     socket          P((int, int, int));
+#endif
+
+#ifdef DECL_MEMMOVE_0
+extern void *  memmove         P((void *, const void *, size_t));
+#endif
+
+#ifdef DECL_MEMSET_0
+extern char *  memset          P((char *, int, int));
+#endif
+
+#ifdef DECL_MKSTEMP_0
+extern int     mkstemp         P((char *));
+#endif
+
+#ifdef DECL_MKTEMP_0
+extern char   *mktemp          P((char *));    
+#endif
+
+#ifdef DECL_NLIST_0
+struct nlist;
+extern int     nlist           P((const char *, struct nlist *));
+#endif
+
+#ifdef DECL_PLOCK_0
+extern int     plock           P((int));
+#endif
+
+#ifdef DECL_RENAME_0
+extern int     rename          P((const char *, const char *));
+#endif
+
+#ifdef DECL_SELECT_0
+#ifdef _ntp_select_h
+extern int     select          P((int, fd_set *, fd_set *, fd_set *, struct timeval *));
+#endif
+#endif
+
+#ifdef DECL_SETITIMER_0
+struct itimerval;
+extern int     setitimer       P((int , struct itimerval *, struct itimerval *));
+#endif
+
+#ifdef PRIO_PROCESS
+#ifdef DECL_SETPRIORITY_0
+extern int     setpriority     P((int, int, int));
+#endif
+#ifdef DECL_SETPRIORITY_1
+extern int     setpriority     P((int, id_t, int));
+#endif
+#endif
+
+#ifdef DECL_SIGVEC_0
+struct sigvec;
+extern int     sigvec          P((int, struct sigvec *, struct sigvec *));
+#endif
+
+#ifndef HAVE_SNPRINTF
+/* PRINTFLIKE3 */
+extern int     snprintf        P((char *, size_t, const char *, ...));
+#endif
+
+/* HMS: does this need further protection? */
+#ifndef HAVE_VSNPRINTF
+extern int     vsnprintf       P((char *, size_t, const char *, va_list));
+#endif
+
+#ifdef DECL_STDIO_0
+#if defined(FILE) || defined(BUFSIZ)
+extern int     _flsbuf         P((int, FILE *));
+extern int     _filbuf         P((FILE *));
+extern int     fclose          P((FILE *));
+extern int     fflush          P((FILE *));
+extern int     fprintf         P((FILE *, const char *, ...));
+extern int     fscanf          P((FILE *, const char *, ...));
+extern int     fputs           P((const char *, FILE *));
+extern int     fputc           P((int, FILE *));
+extern int     fread           P((char *, int, int, FILE *));
+extern void    perror          P((const char *));
+extern int     printf          P((const char *, ...));
+extern int     setbuf          P((FILE *, char *));
+# ifdef HAVE_SETLINEBUF
+extern int     setlinebuf      P((FILE *));
+# endif
+extern int     setvbuf         P((FILE *, char *, int, int));
+extern int     scanf           P((const char *, ...));
+extern int     sscanf          P((const char *, const char *, ...));
+extern int     vfprintf        P((FILE *, const char *, ...));
+extern int     vsprintf        P((char *, const char *, ...));
+#endif
+#endif
+
+#ifdef DECL_STIME_0
+extern int     stime           P((const time_t *));
+#endif
+
+#ifdef DECL_STIME_1
+extern int     stime           P((long *));
+#endif
+
+#ifdef DECL_STRERROR_0
+extern char *  strerror                P((int errnum));
+#endif
+
+#ifdef DECL_STRTOL_0
+extern long    strtol          P((const char *, char **, int));
+#endif
+
+#ifdef DECL_SYSCALL
+extern int     syscall         P((int, ...));
+#endif
+
+#ifdef DECL_SYSLOG_0
+extern void    closelog        P((void));
+#ifndef LOG_DAEMON
+extern void    openlog         P((const char *, int));
+#else
+extern void    openlog         P((const char *, int, int));
+#endif
+extern int     setlogmask      P((int));
+extern void    syslog          P((int, const char *, ...));
+#endif
+
+#ifdef DECL_TIME_0
+extern time_t  time            P((time_t *));
+#endif
+
+#ifdef DECL_TIMEOFDAY_0
+#ifdef SYSV_TIMEOFDAY
+extern int     gettimeofday    P((struct timeval *));
+extern int     settimeofday    P((struct timeval *));
+#else /* not SYSV_TIMEOFDAY */
+struct timezone;
+extern int     gettimeofday    P((struct timeval *, struct timezone *));
+extern int     settimeofday    P((struct timeval *, void *));
+#endif /* not SYSV_TIMEOFDAY */
+#endif
+
+#ifdef DECL_TOLOWER_0
+extern int     tolower         P((int));
+#endif
+
+#ifdef DECL_TOUPPER_0
+extern int     toupper         P((int));
+#endif
+
+/*
+ * Necessary variable declarations.
+ */
+#ifdef DECL_ERRNO
+extern int     errno;
+#endif
+
+#if defined(DECL_H_ERRNO) && !defined(h_errno)
+extern int     h_errno;
+#endif
+
+/*******************************************************/
+
+#if 0
+/*
+ * Unprotoyped library functions for SunOS 4.x.x
+ */
+#ifdef SYS_SUNOS4
+extern void    closelog        P((void));
+extern void    openlog         P((char *, int, int));
+extern void    syslog          P((int, char *, ...));
+extern int     setlogmask      P((int));
+
+extern char *  getpass         P((char *));
+
+extern int     setpriority     P((int ,int ,int));
+
+extern long    strtol          P((char *, char **, int));
+
+#if !defined(NTP_POSIX_SOURCE)
+extern int     atoi            P((char *));
+extern int     dup2            P((int, int));
+extern int     execve          P((char *, char **,char **));
+extern int     fork            P((void));
+extern int     getdtablesize   P((void));
+extern int     qsort           (void *, int , int,
+                                  int P((*compar)(void *, void *)));
+extern int     setpgrp         P((int, int));
+extern void    bcopy           P((const char *, char *, int));
+#endif
+
+#ifndef bzero                  /* XXX macro prototyping clash */
+extern void    bzero           P((char *, int));
+extern int     bcmp            P((char *, char *, int));
+extern void    bcopy           P((const char *, char *, int));
+#endif
+extern char   *mktemp          P((char *));    
+
+extern int     tolower         P((int));
+
+extern int     isatty          P((int));
+
+extern unsigned sleep          P((unsigned ));
+extern unsigned int alarm      P((unsigned int));
+extern int     pause           P((void));
+
+extern int     getpid          P((void));
+extern int     getppid         P((void));
+
+extern int     close           P((int));
+extern int     ioctl           P((int, int, char *));
+extern int     rename          P((char *, char *));
+#if    0
+extern int     read            P((int, void *, size_t));
+extern int     write           P((int, const void *, size_t));
+#endif
+extern int     unlink          P((const char *));
+extern int     link            P((const char *, const char *));
+
+#ifdef FILE
+extern int     fclose          P((FILE *));
+extern int     fflush          P((FILE *));
+extern int     fprintf         P((FILE *, char *, ...));
+extern int     fscanf          P((FILE *, char *, ...));
+extern int     fputs           P((char *, FILE *));
+extern int     fputc           P((char, FILE *));
+extern int     fread           P((char *, int, int, FILE *));
+extern int     printf          P((char *, ...));
+extern int     setbuf          P((FILE *, char *));
+extern int     setvbuf         P((FILE *, char *, int, int));
+extern int     scanf           P((char *, ...));
+extern int     sscanf          P((char *, char *, ...));
+extern int     vsprintf        P((char *, char *, ...));
+extern int     _flsbuf         P((int, FILE *));
+extern int     _filbuf         P((FILE *));
+extern void    perror          P((char *));
+#ifdef HAVE_SETLINEBUF
+extern int     setlinebuf      P((FILE *));
+#endif
+#endif
+
+#ifdef _ntp_string_h
+#ifdef NTP_POSIX_SOURCE        /* these are builtins */
+#ifndef NTP_NEED_BOPS          /* but may be emulated by bops */
+extern char    *memcpy P(());
+extern char    *memset P(());
+extern int     memcmp P(());
+#endif
+#endif
+#endif
+
+#ifdef _sys_socket_h
+extern int     bind            P((int, struct sockaddr *, int));
+extern int     connect         P((int,  struct sockaddr *, int));
+extern int     sendto          P((int, char *, int, int, struct sockaddr *, int));
+extern int     setsockopt      P((int, int, int, char *, int));
+extern int     socket          P((int, int, int));
+extern int     recvfrom        P((int, char *, int, int, struct sockaddr *, int *));
+#endif /* _sys_socket_h */
+
+#ifdef _ntp_select_h
+extern int     select          P((int, fd_set *, fd_set *, fd_set *, struct timeval *));
+#endif
+
+#ifdef _sys_time_h
+extern int     adjtime         P((struct timeval *, struct timeval *));
+extern int     setitimer       P((int , struct itimerval *, struct itimerval *));
+#ifdef SYSV_TIMEOFDAY
+extern int     gettimeofday    P((struct timeval *));
+extern int     settimeofday    P((struct timeval *));
+#else /* ! SYSV_TIMEOFDAY */
+extern int     gettimeofday    P((struct timeval *, struct timezone *));
+extern int     settimeofday    P((struct timeval *, struct timezone *));
+#endif /* SYSV_TIMEOFDAY */
+#endif /* _sys_time_h */
+
+#ifdef __time_h
+extern time_t  time            P((time_t *));
+#endif
+
+#ifdef __setjmp_h
+extern int     setjmp          P((jmp_buf));
+extern void    longjmp         P((jmp_buf, int));
+#endif
+
+#ifdef _sys_resource_h
+extern int     getrusage       P((int, struct rusage *));
+#endif
+
+#ifdef _nlist_h
+extern int     nlist           P((char *, struct nlist *));
+#endif
+
+#endif /* SYS_SUNOS4 */
+
+/*
+ * Unprototyped library functions for DEC OSF/1
+ */
+#ifdef SYS_DECOSF1
+#ifndef _MACHINE_ENDIAN_H_
+#define _MACHINE_ENDIAN_H_
+extern u_short htons           P((u_short));
+extern u_short ntohs           P((u_short));
+extern u_int32 htonl           P((u_int32));
+extern u_int32 ntohl           P((u_int32));
+#endif /* _MACHINE_ENDIAN_H_ */
+
+/*
+extern char *  getpass         P((char *));
+*/
+extern char *  mktemp          P((char *));
+#ifndef SYS_IX86OSF1
+extern int     ioctl           P((int, u_long, char *));
+extern void    bzero           P((char *, int));
+#endif
+
+#ifdef SOCK_DGRAM
+extern int     bind            P((int, const struct sockaddr *, int));
+extern int     connect         P((int, const struct sockaddr *, int));
+extern int     socket          P((int, int, int));
+extern int     sendto          P((int, const void *, int, int, const struct sockaddr *, int));
+extern int     setsockopt      P((int, int, int, const void *, int));
+extern int     recvfrom        P((int, void *, int, int, struct sockaddr *, int *));
+#endif /* SOCK_STREAM */
+
+#ifdef _ntp_select_h
+extern int     select          P((int, fd_set *, fd_set *, fd_set *, struct timeval *));
+#endif
+
+#endif /* DECOSF1 */
+
+/*
+ * Unprototyped library functions for Ultrix
+ */
+#ifdef SYS_ULTRIX
+extern int     close           P((int));
+extern char *  getpass         P((char *));
+extern int     getpid          P((void));
+extern int     ioctl           P((int, int, char *));
+extern char   *mktemp          P((char *));    
+extern int     unlink          P((const char *));
+extern int     link            P((const char *, const char *));
+
+extern void    closelog        P((void));
+extern void    syslog          P((int, char *, ...));
+#ifndef LOG_DAEMON
+extern void    openlog         P((char *, int));
+#else
+extern void    openlog         P((char *, int, int));
+#endif
+
+extern int     setpriority     P((int ,int ,int ));
+
+#ifdef SOCK_DGRAM
+extern int     bind            P((int, struct sockaddr *, int));
+extern int     connect         P((int,  struct sockaddr *, int));
+extern int     socket          P((int, int, int));
+extern int     sendto          P((int, char *, int, int, struct sockaddr *, int));
+extern int     setsockopt      P((int, int, int, char *, int));
+extern int     recvfrom        P((int, char *, int, int, struct sockaddr *, int *));
+#endif /* SOCK_STREAM */
+
+#ifdef _TIME_H_
+extern int     gettimeofday    P((struct timeval *, struct timezone *));
+extern int     settimeofday    P((struct timeval *, struct timezone *));
+extern int     adjtime         P((struct timeval *, struct timeval *));
+extern int     select          P((int, fd_set *, fd_set *, fd_set *, struct timeval *));
+extern int     setitimer       P((int , struct itimerval *, struct itimerval *));
+#endif /* _TIME_H_ */
+
+#ifdef N_UNDF
+extern int     nlist           P((char *, struct nlist *));
+#endif
+
+#ifndef bzero                  /* XXX macro prototyping clash */
+extern void    bzero           P((char *, int));
+extern int     bcmp            P((char *, char *, int));
+extern void    bcopy           P((const char *, char *, int));
+#endif
+
+#ifndef NTP_POSIX_SOURCE
+extern int     atoi            P((char *));
+extern void    bzero           P((char *, int));
+extern int     bcmp            P((char *, char *, int));
+extern void    bcopy           P((const char *, char *, int));
+extern int     execve          P((char *, char **,char **));
+extern int     fork            P((void));
+extern int     getdtablesize   P((void));
+extern int     ran             P((void));
+#ifdef _TIME_H_
+extern int     gettimeofday    P((struct timeval *, struct timezone *));
+extern int     settimeofday    P((struct timeval *, struct timezone *));
+#endif
+#endif
+
+#ifdef _RESOURCE_H_
+extern int     getrusage       P((int, struct rusage *));
+#endif
+
+#endif /* SYS_ULTRIX */
+
+#if defined(__convex__)
+extern char *  getpass         P((char *));
+#endif
+
+#ifdef SYS_IRIX4
+extern char *  getpass         P((char *));
+#endif /* IRIX4 */
+
+#ifdef SYS_VAX
+extern char *  getpass         P((char *));
+#endif /* VAX */
+
+#ifdef SYS_DOMAINOS
+extern char *  getpass         P((char *));
+#endif /* SYS_DOMAINOS */
+
+#ifdef SYS_BSD
+#define           IN_CLASSD(i)            (((long)(i) & 0xf0000000) == 0xe0000000)
+#endif
+
+#endif /* 0 */
+#endif /* l_stdlib_h */
diff --git a/include/mbg_gps166.h b/include/mbg_gps166.h
new file mode 100644 (file)
index 0000000..edaae9d
--- /dev/null
@@ -0,0 +1,582 @@
+/*
+ * /src/NTP/REPOSITORY/ntp4-dev/include/mbg_gps166.h,v 4.7 2006/06/22 18:41:43 kardel RELEASE_20060622_A
+ *
+ * mbg_gps166.h,v 4.7 2006/06/22 18:41:43 kardel RELEASE_20060622_A
+ *
+ * $Created: Sun Jul 20 09:20:50 1997 $
+ *
+ * File GPSSERIO.H Copyright (c) by Meinberg Funkuhren (www.meinberg.de)
+ *
+ * Linkage to PARSE:
+ * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+#ifndef MBG_GPS166_H
+#define MBG_GPS166_H
+
+
+/***************************************************************************/
+/*                                                                         */
+/*   File:         GPSSERIO.H                    4.1                       */
+/*                                                                         */
+/*   Project:      Common C Library                                        */
+/*                                                                         */
+/*   Compiler:     Borland C++                                             */
+/*                                                                         */
+/*   Author:       M. Burnicki,  Meinberg Funkuhren                        */
+/*                                                                         */
+/*                                                                         */
+/*   Description:                                                          */
+/*     This file defines structures and codes to be used to access GPS166  */
+/*     via its serial interface COM0. COM0 should be set to a high baud    */
+/*     rate, default is 19200.                                             */
+/*                                                                         */
+/*     Standard GPS166 serial operation is to send a time string that is   */
+/*     compatible with Meinberg UA31 or PZF535 DCF77 radio remote clocks.  */
+/*     That string can be transmitted automatically once per second, once  */
+/*     per minute or on request per ASCII '?'.                             */
+/*                                                                         */
+/*     Parameter setup or parameter readout works using blocks of binary   */
+/*     data which have to be isolated from the standard string. A block of */
+/*     data starts with a SOH code (ASCII Start Of Header, 0x01) followed  */
+/*     by a message header with constant length and a data portion with    */
+/*     variable length. The first field (cmd) of the message header holds  */
+/*     the command code rsp. the type of data to be transmitted. The next  */
+/*     field (len) gives the number of data bytes that are transmitted     */
+/*     after the header. This number ranges from 0 to sizeof( MSG_DATA ).  */
+/*     The third field (data_csum) holds a checksum of all data bytes and  */
+/*     the last field of the header finally holds the checksum of the.     */
+/*     header.                                                             */
+/*                                                                         */
+/***************************************************************************/
+
+/* the control codes defined below are to be or'ed with a command/type code */
+
+#define GPS_REQACK    0x8000   /* to GPS166: request acknowledge */
+#define GPS_ACK       0x4000   /* from GPS166: acknowledge a command */
+#define GPS_NACK      0x2000   /* from GPS166: error receiving command */
+
+#define GPS_CTRL_MSK  0xF000   /* masks control code from command */
+
+
+/* The codes below specify commands/types of data to be supplied to GPS166: */
+
+/*                            GPS166 auto-message to host            */
+/*                            Ã¾   host request, GPS166 response      */
+/*                            Ã¾   Ã¾   host download to GPS166        */
+/*                            Ã¾   Ã¾   Ã¾                              */
+enum {  /*                    Ã¾   Ã¾   Ã¾                              */
+  /* system data */
+  GPS_AUTO_ON = 0x000,   /* Ã¾   Ã¾   Ã¾ X Ã¾ enable auto-messages from GPS166 */
+  GPS_AUTO_OFF,          /* Ã¾   Ã¾   Ã¾ X Ã¾ disable auto-messages from GPS166 */
+  GPS_SW_REV,            /* Ã¾   Ã¾ X Ã¾   Ã¾ request software revision */
+  GPS_STAT,              /* Ã¾   Ã¾ X Ã¾   Ã¾ request status of buffered variables */
+  GPS_TIME,              /* Ã¾ X Ã¾   Ã¾ X Ã¾ current time or capture or init board time */
+  GPS_POS_XYZ,           /* Ã¾   Ã¾ X Ã¾ X Ã¾ current position in ECEF coords */
+  GPS_POS_LLA,           /* Ã¾   Ã¾ X Ã¾ X Ã¾ current position in geographic coords */
+  GPS_TZDL,              /* Ã¾   Ã¾ X Ã¾ X Ã¾ time zone / daylight saving */
+  GPS_PORT_PARM,         /* Ã¾   Ã¾ X Ã¾ X Ã¾ parameters of the serial ports */
+  GPS_SYNTH,             /* Ã¾   Ã¾ X Ã¾ X Ã¾ synthesizer's frequency and phase */
+  GPS_ANT_INFO,          /* Ã¾ X Ã¾ X Ã¾   Ã¾ time diff after antenna disconnect */
+  GPS_UCAP,              /* Ã¾ X Ã¾ X Ã¾   Ã¾ user capture */
+
+  /* GPS data */
+  GPS_CFGH = 0x100,      /* Ã¾   Ã¾ X Ã¾ X Ã¾ SVs' configuration and health codes */
+  GPS_ALM,               /* Ã¾   Ã¾ X Ã¾ X Ã¾ one SV's almanac */
+  GPS_EPH,               /* Ã¾   Ã¾ X Ã¾ X Ã¾ one SV's ephemeris */
+  GPS_UTC,               /* Ã¾   Ã¾ X Ã¾ X Ã¾ UTC correction parameters */
+  GPS_IONO,              /* Ã¾   Ã¾ X Ã¾ X Ã¾ ionospheric correction parameters */
+  GPS_ASCII_MSG          /* Ã¾   Ã¾ X Ã¾   Ã¾ the GPS ASCII message */
+};
+
+/*
+ * modelled after GPSDEFS.H Revision 1.5
+ */
+/***************************************************************************/
+/*                                                                         */
+/*   File:         GPSDEFS.H                     4.1          */
+/*                                                                         */
+/*   Project:      Common C Library                                        */
+/*                                                                         */
+/*   Compiler:     Borland C++                                             */
+/*                                                                         */
+/*   Author:       M. Burnicki,  Meinberg Funkuhren                        */
+/*                                                                         */
+/*                                                                         */
+/*   Description:                                                          */
+/*     General definitions to be used with GPS166                          */
+/*     GPS166 Rev. 1.23 or above                                           */
+/*                                                                         */
+/*   Modifications: see file GPSLIB.TXT                                    */
+/*                                                                         */
+/***************************************************************************/
+#define _GPSDEFS_H
+/* the type of various checksums */
+
+#ifndef _CSUM_DEFINED
+  typedef unsigned short CSUM;
+#  define _CSUM_DEFINED
+#endif
+
+/* the message header */
+
+typedef struct {
+  unsigned short gps_cmd;
+  unsigned short gps_len;
+  unsigned short gps_data_csum;
+  unsigned short gps_hdr_csum;
+} GPS_MSG_HDR;
+
+/* a struct used to hold the software revision information */
+
+typedef struct {
+  unsigned short code;       /* e.g. 0x0120 means rev. 1.20 */
+  unsigned char name[17];     /* used to identify customized versions */
+} SW_REV;
+
+/* GPS ASCII message */
+
+typedef struct {
+  CSUM csum;       /* checksum of the remaining bytes */
+  short valid;     /* flag data are valid */
+  char s[23];      /* 22 chars GPS ASCII message plus trailing zero */
+} ASCII_MSG;
+
+#define MIN_SVNO         1                  /* min. SV number */
+#define MAX_SVNO        32                  /* max. SV number */
+#define N_SVNO ( MAX_SVNO - MIN_SVNO + 1)   /* number of possibly active SVs */
+
+
+typedef short          SVNO;     /* the number of a SV */
+typedef unsigned short HEALTH;  /* a SV's health code */
+typedef unsigned short CFG;     /* a SV's configuration code */
+typedef unsigned short IOD;     /* Issue-Of-Data code */
+
+/* Date and time referred to the linear time scale defined by GPS. */
+/* GPS time is defined by the number of weeks since midnight from */
+/* January 5, 1980 to January 6, 1980 plus the number of seconds of */
+/* the current week plus fractions of a second. GPS time differs from */
+/* UTC because UTC is corrected with leap seconds while GPS time scale */
+/* is continuous. */
+
+typedef struct {
+  unsigned short wn;     /* the week number since GPS has been installed */
+  unsigned long sec;     /* the second of that week */
+  unsigned long tick;    /* fractions of a second; scale: 1E-7 */
+} T_GPS;
+
+
+/* Local date and time computed from GPS time. The current number */
+/* of leap seconds have to be added to get UTC from GPS time. */
+/* Additional corrections could have been made according to the */
+/* time zone/daylight saving parameters (TZDL, see below) defined */
+/* by the user. The status field can be checked to see which corrections */
+/* have been applied. */
+
+#ifndef _TM_DEFINED
+  typedef struct {
+    short year;          /* 0..9999 */
+    char month;          /* 1..12 */
+    char mday;           /* 1..31 */
+    short yday;          /* 1..366 */
+    char wday;           /* 0..6 == Sun..Sat */
+    char hour;           /* 0..23 */
+    char minute;         /* 0..59 */
+    char second;         /* 0..59 */
+    long frac;           /* fractions of a second, scale 1E-7 */
+    long offs_from_utc;  /* local time's offset from UTC */
+    unsigned short status;       /* flags */
+  } TM;
+
+  /* status flags used with conversion from GPS time to local time */
+
+#  define TM_UTC        0x01   /* UTC correction has been made */
+#  define TM_LOCAL      0x02   /* UTC has been converted to local time */
+#  define TM_DL_ANN     0x04   /* state of daylight saving is going to change */
+#  define TM_DL_ENB     0x08   /* daylight saving is enabled */
+#  define TM_LS_ANN     0x10   /* leap second will be inserted */
+#  define TM_LS_ENB     0x20   /* current second is leap second */
+
+#  define _TM_DEFINED
+#endif
+
+
+/* the status flags below are defined starting with rev. 1.32 */
+
+#define TM_ANT_DISCONN  0x1000  /* antenna currently disconnected */
+#define TM_SYN_FLAG     0x2000  /* TIME_SYN output is low */
+#define TM_NO_SYNC      0x4000  /* not sync'ed after reset */
+#define TM_NO_POS       0x8000  /* position not computed after reset, */
+                                /*   LOCK LED off */
+
+/* a struct used to transmit information on date and time */
+
+typedef struct {
+  short channel;        /* -1: the current time; 0, 1: capture 0, 1 */
+  T_GPS t;              /* time in GPS format */
+  TM tm;                /* that time converted to local time */
+} TTM;
+
+
+
+/* Two types of variables used to store a position. Type XYZ is */
+/* used with a position in earth centered, earth fixed (ECEF) */
+/* coordinates whereas type LLA holds such a position converted */
+/* to geographic coordinates as defined by WGS84 (World Geodetic */
+/* System from 1984). */
+
+#ifndef _XYZ_DEFINED
+  /* sequence and number of components of a cartesian position */
+  enum { XP, YP, ZP, N_XYZ };
+
+  /* a type of array holding a cartesian position */
+  typedef l_fp XYZ[N_XYZ];      /* values are in [m] */
+
+#  define _XYZ_DEFINED
+#endif
+
+
+#ifndef _LLA_DEFINED
+  /* sequence and number of components of a geographic position */
+  enum { LAT, LON, ALT, N_LLA };  /* latitude, longitude, altitude */
+
+  /* a type of array holding a geographic position */
+  typedef l_fp LLA[N_LLA];      /* lon, lat in [rad], alt in [m] */
+
+#  define _LLA_DEFINED
+#endif
+
+/* Synthesizer parameters. Synthesizer frequency is expressed as a */
+/* four digit decimal number (freq) to be multiplied by 0.1 Hz and an */
+/* base 10 exponent (range). If the effective frequency is less than */
+/* 10 kHz its phase is synchronized corresponding to the variable phase. */
+/* Phase may be in a range from -360° to +360° with a resolution of 0.1°, */
+/* so the resulting numbers to be stored are in a range of -3600 to +3600. */
+
+/* Example: */
+/* Assume the value of freq is 2345 (decimal) and the value of phase is 900. */
+/* If range == 0 the effective frequency is 234.5 Hz with a phase of +90°. */
+/* If range == 1 the synthesizer will generate a 2345 Hz output frequency */
+/* and so on. */
+
+/* Limitations: */
+/* If freq == 0 the synthesizer is disabled. If range == 0 the least */
+/* significant digit of freq is limited to 0, 3, 5 or 6. The resulting */
+/* frequency is shown in the examples below: */
+/*     freq == 1230  -->  123.0 Hz */
+/*     freq == 1233  -->  123 1/3 Hz (real 1/3 Hz, NOT 123.3 Hz) */
+/*     freq == 1235  -->  123.5 Hz */
+/*     freq == 1236  -->  123 2/3 Hz (real 2/3 Hz, NOT 123.6 Hz) */
+
+/* If range == MAX_RANGE the value of freq must not exceed 1200, so the */
+/* output frequency is limited to 12 MHz. */
+
+/* Phase will be ignored if the resulting frequency is greater or equal */
+/* to 10 kHz. */
+
+#define MAX_SYNTH_FREQ   1200    /* if range == MAX_SYNTH_RANGE */
+#define MIN_SYNTH_RANGE     0
+#define MAX_SYNTH_RANGE     5
+#define MAX_SYNTH_PHASE  3600
+
+typedef struct {
+  short freq;      /* four digits used; scale: 0.1; e.g. 1234 -> 123.4 Hz */
+  short range;     /* scale factor for freq; 0..MAX_SYNTH_RANGE */
+  short phase;     /* -MAX_SYNTH_PHASE..+MAX_SYNTH_PHASE; >0 -> pulses later */
+} SYNTH;
+
+
+
+/* Time zone/daylight saving parameters. */
+
+/* the name of a time zone, 5 characters plus trailing zero */
+typedef char TZ_NAME[6];
+
+typedef struct {
+  long offs;         /* offset from UTC to local time [sec] */
+  long offs_dl;      /* additional offset if daylight saving enabled [sec] */
+  TM tm_on;          /* date/time when daylight saving starts */
+  TM tm_off;         /* date/time when daylight saving ends */
+  TZ_NAME name[2];   /* names without and with daylight saving enabled */
+} TZDL;
+
+/* The constant below is defined beginning with software rev. 1.29. */
+/* If the year in tzdl.tmon and tzdl.tm_off is or'ed with that constant, */
+/* the receiver automatically generates daylight saving year by year. */
+/* See GPSLIB.TXT for more information. */
+
+#define DL_AUTO_FLAG  0x8000
+
+/* Example: */
+/* for automatic daylight saving enable/disable in Central Europe, */
+/* the variables are to be set as shown below: */
+/*   offs = 3600L           one hour from UTC */
+/*   offs_dl = 3600L        one additional hour if daylight saving enabled */
+/*   tm_on = first Sunday from March 25, 02:00:00h ( year |= DL_AUTO_FLAG ) */
+/*   tm_off = first Sunday from Sept 24, 03:00:00h ( year |= DL_AUTO_FLAG ) */
+/*   name[0] == "MEZ  "     name if daylight saving not enabled */
+/*   name[1] == "MESZ "     name if daylight saving is enabled */
+
+
+
+
+/* the structure below was defined in rev. 1.31. It reflects the status */
+/* of the antenna, the times of last disconnect/reconnect and the boards */
+/* clock offset after the phase of disconnection. */
+
+typedef struct {
+  short status;    /* current status of antenna */
+  TM tm_disconn;   /* time of antenna disconnect */
+  TM tm_reconn;    /* time of antenna reconnect */
+  long delta_t;    /* clock offset at reconnect time, units: TICKS_PER_SEC */
+} ANT_INFO;
+
+
+/* the status field may be set to one of the values below: */
+
+enum {
+  ANT_INVALID,   /* struct not set yet because ant. has not been disconn. */
+  ANT_DISCONN,   /* ant. now disconn., tm_reconn and delta_t not set */
+  ANT_RECONN     /* ant. has been disconn. and reconn., all fields valid */
+};
+
+
+/* Summary of configuration and health data of all SVs. */
+
+typedef struct {
+  CSUM csum;               /* checksum of the remaining bytes */
+  short valid;             /* flag data are valid */
+
+  T_GPS tot_51;            /* time of transmission, page 51 */
+  T_GPS tot_63;            /* time of transmission, page 63 */
+  T_GPS t0a;               /* complete reference time almanac */
+
+  CFG cfg[N_SVNO];         /* SV configuration from page 63 */
+  HEALTH health[N_SVNO];   /* SV health from pages 51, 63 */
+} CFGH;
+
+
+
+/* UTC correction parameters */
+
+typedef struct {
+  CSUM csum;       /*    checksum of the remaining bytes                  */
+  short valid;     /*    flag data are valid                              */
+
+  T_GPS t0t;       /*    Reference Time UTC Parameters              [sec] */
+  l_fp A0;         /*  Â± Clock Correction Coefficient 0             [sec] */
+  l_fp A1;         /*  Â± Clock Correction Coefficient 1         [sec/sec] */
+
+  ushort WNlsf;    /*  week number of nearest leap second                 */
+  short DNt;       /*  the day number at the end of which LS is inserted  */
+  char delta_tls;  /*                                                     */
+  char delta_tlsf; /*                                                     */
+
+} UTC;
+
+/* a struct used to hold the settings of a serial port */
+
+#ifndef _COM_PARM_DEFINED
+  typedef long BAUD_RATE;
+
+  /* indices used to identify a parameter in the framing string */
+  enum { F_DBITS, F_PRTY, F_STBITS };
+
+  /* types of handshake */
+  enum { HS_NONE, HS_XONXOFF, HS_RTSCTS };
+
+  typedef struct {
+    BAUD_RATE baud_rate;    /* e.g. 19200L */
+    char framing[4];        /* e.g. "8N1" */
+    short handshake;        /* a numeric value, only HS_NONE supported yet */
+  } COM_PARM;
+
+#define _COM_PARM_DEFINED
+#endif
+
+
+
+/* the codes below define what has to comes out of the serial ports */
+
+enum { STR_ON_REQ, STR_PER_SEC,
+       STR_PER_MIN, N_STR_MODE_0,      /* COM0 and COM1 */
+       STR_UCAP = N_STR_MODE_0,
+       STR_UCAP_REQ, N_STR_MODE_1      /* COM1 only */
+     };
+
+
+#define N_COM   2  /* the number of serial ports */
+
+/* the structure used to store the modes of both serial ports */
+
+typedef struct {
+  COM_PARM com[N_COM];    /* COM0 and COM1 settings */
+  u_char mode[N_COM];      /* COM0 and COM1 output mode */
+} PORT_PARM;
+
+/* Ephemeris parameters of one specific SV. Needed to compute the position */
+/* of a satellite at a given time with high precision. Valid for an */
+/* interval of 4 to 6 hours from start of transmission. */
+
+typedef struct {
+  CSUM csum;       /*    checksum of the remaining bytes                  */
+  short valid;     /*    flag data are valid                              */
+
+  HEALTH health;   /*    health indication of transmitting SV      [---]  */
+  IOD IODC;        /*    Issue Of Data, Clock                             */
+  IOD IODE2;       /*    Issue of Data, Ephemeris (Subframe 2)            */
+  IOD IODE3;       /*    Issue of Data, Ephemeris (Subframe 3)            */
+  T_GPS tt;        /*    time of transmission                             */
+  T_GPS t0c;       /*    Reference Time Clock                      [---]  */
+  T_GPS t0e;       /*    Reference Time Ephemeris                  [---]  */
+
+  l_fp   sqrt_A;   /*    Square Root of semi-major Axis        [sqrt(m)]  */
+  l_fp   e;        /*    Eccentricity                              [---]  */
+  l_fp   M0;       /*  Â± Mean Anomaly at Ref. Time                 [rad]  */
+  l_fp   omega;    /*  Â± Argument of Perigee                       [rad]  */
+  l_fp   OMEGA0;   /*  Â± Longit. of Asc. Node of orbit plane       [rad]  */
+  l_fp   OMEGADOT; /*  Â± Rate of Right Ascension               [rad/sec]  */
+  l_fp   deltan;   /*  Â± Mean Motion Diff. from computed value [rad/sec]  */
+  l_fp   i0;       /*  Â± Inclination Angle                         [rad]  */
+  l_fp   idot;     /*  Â± Rate of Inclination Angle             [rad/sec]  */
+  l_fp   crc;      /*  Â± Cosine Corr. Term to Orbit Radius           [m]  */
+  l_fp   crs;      /*  Â± Sine Corr. Term to Orbit Radius             [m]  */
+  l_fp   cuc;      /*  Â± Cosine Corr. Term to Arg. of Latitude     [rad]  */
+  l_fp   cus;      /*  Â± Sine Corr. Term to Arg. of Latitude       [rad]  */
+  l_fp   cic;      /*  Â± Cosine Corr. Term to Inclination Angle    [rad]  */
+  l_fp   cis;      /*  Â± Sine Corr. Term to Inclination Angle      [rad]  */
+
+  l_fp   af0;      /*  Â± Clock Correction Coefficient 0            [sec]  */
+  l_fp   af1;      /*  Â± Clock Correction Coefficient 1        [sec/sec]  */
+  l_fp   af2;      /*  Â± Clock Correction Coefficient 2       [sec/sec²]  */
+  l_fp   tgd;      /*  Â± estimated group delay differential        [sec]  */
+
+  u_short URA;      /*    predicted User Range Accuracy                    */
+
+  u_char L2code;    /*    code on L2 channel                         [---] */
+  u_char L2flag;    /*    L2 P data flag                             [---] */
+
+} EPH;
+
+/* Almanac parameters of one specific SV. A reduced precision set of */
+/* parameters used to check if a satellite is in view at a given time. */
+/* Valid for an interval of more than 7 days from start of transmission. */
+
+typedef struct {
+  CSUM csum;       /*    checksum of the remaining bytes                  */
+  short valid;     /*    flag data are valid                              */
+
+  HEALTH health;   /*                                               [---] */
+  T_GPS t0a;       /*    Reference Time Almanac                     [sec] */
+
+  l_fp   sqrt_A;   /*    Square Root of semi-major Axis         [sqrt(m)] */
+  l_fp   e;        /*    Eccentricity                               [---] */
+
+  l_fp   M0;       /*  Â± Mean Anomaly at Ref. Time                  [rad] */
+  l_fp   omega;    /*  Â± Argument of Perigee                        [rad] */
+  l_fp   OMEGA0;   /*  Â± Longit. of Asc. Node of orbit plane        [rad] */
+  l_fp   OMEGADOT; /*  Â± Rate of Right Ascension                [rad/sec] */
+  l_fp   deltai;   /*  Â±                                            [rad] */
+  l_fp   af0;      /*  Â± Clock Correction Coefficient 0             [sec] */
+  l_fp   af1;      /*  Â± Clock Correction Coefficient 1         [sec/sec] */
+} ALM;
+
+
+/* ionospheric correction parameters */
+
+typedef struct {
+  CSUM csum;       /*    checksum of the remaining bytes                  */
+  short valid;     /*    flag data are valid                              */
+
+  l_fp   alpha_0;  /*    Ionosph. Corr. Coeff. Alpha 0              [sec] */
+  l_fp   alpha_1;  /*    Ionosph. Corr. Coeff. Alpha 1          [sec/deg] */
+  l_fp   alpha_2;  /*    Ionosph. Corr. Coeff. Alpha 2        [sec/deg^2] */
+  l_fp   alpha_3;  /*    Ionosph. Corr. Coeff. Alpha 3        [sec/deg^3] */
+
+  l_fp   beta_0;   /*    Ionosph. Corr. Coeff. Beta 0               [sec] */
+  l_fp   beta_1;   /*    Ionosph. Corr. Coeff. Beta 1           [sec/deg] */
+  l_fp   beta_2;   /*    Ionosph. Corr. Coeff. Beta 2         [sec/deg^2] */
+  l_fp   beta_3;   /*    Ionosph. Corr. Coeff. Beta 3         [sec/deg^3] */
+
+} IONO;
+
+void mbg_tm_str P((char **, TM *, int));
+void mbg_tgps_str P((char **, T_GPS *, int));
+void get_mbg_header P((unsigned char **, GPS_MSG_HDR *));
+void put_mbg_header P((unsigned char **, GPS_MSG_HDR *));
+void get_mbg_sw_rev P((unsigned char **, SW_REV *));
+void get_mbg_ascii_msg P((unsigned char **, ASCII_MSG *));
+void get_mbg_svno P((unsigned char **, SVNO *));
+void get_mbg_health P((unsigned char **, HEALTH *));
+void get_mbg_cfg P((unsigned char **, CFG *));
+void get_mbg_tgps P((unsigned char **, T_GPS *));
+void get_mbg_tm P((unsigned char **, TM *));
+void get_mbg_ttm P((unsigned char **, TTM *));
+void get_mbg_synth P((unsigned char **, SYNTH *));
+void get_mbg_tzdl P((unsigned char **, TZDL *));
+void get_mbg_antinfo P((unsigned char **, ANT_INFO *));
+void get_mbg_cfgh P((unsigned char **, CFGH *));
+void get_mbg_utc P((unsigned char **, UTC *));
+void get_mbg_lla P((unsigned char **, LLA));
+void get_mbg_xyz P((unsigned char **, XYZ));
+void get_mbg_portparam P((unsigned char **, PORT_PARM *));
+void get_mbg_eph P((unsigned char **, EPH *));
+void get_mbg_alm P((unsigned char **, ALM *));
+void get_mbg_iono P((unsigned char **, IONO *));
+
+unsigned long mbg_csum P((unsigned char *, unsigned int));
+
+#endif
+/*
+ * History:
+ *
+ * mbg_gps166.h,v
+ * Revision 4.7  2006/06/22 18:41:43  kardel
+ * clean up signedness (gcc 4)
+ *
+ * Revision 4.6  2005/10/07 22:11:56  kardel
+ * bounded buffer implementation
+ *
+ * Revision 4.5.2.1  2005/09/25 10:23:48  kardel
+ * support bounded buffers
+ *
+ * Revision 4.5  2005/06/25 10:58:45  kardel
+ * add missing log keywords
+ *
+ * Revision 4.1  1998/06/12 15:07:30  kardel
+ * fixed prototyping
+ *
+ * Revision 4.0  1998/04/10 19:50:42  kardel
+ * Start 4.0 release version numbering
+ *
+ * Revision 1.1  1998/04/10 19:27:34  kardel
+ * initial NTP VERSION 4 integration of PARSE with GPS166 binary support
+ *
+ * Revision 1.1  1997/10/06 20:55:38  kardel
+ * new parse structure
+ *
+ */
diff --git a/include/mx4200.h b/include/mx4200.h
new file mode 100644 (file)
index 0000000..6ea2c60
--- /dev/null
@@ -0,0 +1,40 @@
+
+/* records transmitted from extern CDU to MX 4200 */
+#define PMVXG_S_INITMODEA      0       /* initialization/mode part A */
+#define PMVXG_S_INITMODEB      1       /* initialization/mode part B*/
+#define PMVXG_S_SATHEALTH      2       /* satellite health control */
+#define PMVXG_S_DIFFNAV                3       /* differential navigation control */
+#define PMVXG_S_PORTCONF       7       /* control port configuration */
+#define PMVXG_S_GETSELFTEST    13      /* self test (request results) */
+#define PMVXG_S_RTCMCONF       16      /* RTCM port configuration */
+#define PMVXG_S_PASSTHRU       17      /* equipment port pass-thru config */
+#define PMVXG_S_RESTART                18      /* restart control */
+#define PMVXG_S_OSCPARAM       19      /* oscillator parameter */
+#define PMVXG_S_DOSELFTEST     20      /* self test (activate a test) */
+#define PMVXG_S_TRECOVCONF     23      /* time recovery configuration */
+#define PMVXG_S_RAWDATASEL     24      /* raw data port data selection */
+#define PMVXG_S_EQUIPCONF      26      /* equipment port configuration */
+#define PMVXG_S_RAWDATACONF    27      /* raw data port configuration */
+
+/* records transmitted from MX 4200 to external CDU */
+#define PMVXG_D_STATUS         0       /* status */
+#define PMVXG_D_POSITION       1       /* position */
+#define PMVXG_D_OPDOPS         3       /* (optimum) DOPs */
+#define PMVXG_D_MODEDATA       4       /* mode data */
+#define PMVXG_D_SATPRED                5       /* satellite predictions */
+#define PMVXG_D_SATHEALTH      6       /* satellite health status */
+#define PMVXG_D_UNRECOG                7       /* unrecognized request response */
+#define PMVXG_D_SIGSTRLOC      8       /* sig strength & location (sats 1-4) */
+#define PMVXG_D_SPEEDHEAD      11      /* speed/heading data */
+#define PMVXG_D_OSELFTEST      12      /* (old) self-test results */
+#define PMVXG_D_SIGSTRLOC2     18      /* sig strength & location (sats 5-8) */
+#define PMVXG_D_OSCPARAM       19      /* oscillator parameter */
+#define PMVXG_D_SELFTEST       20      /* self test results */
+#define PMVXG_D_PHV            21      /* position, height & velocity */
+#define PMVXG_D_DOPS           22      /* DOPs */
+#define PMVXG_D_SOFTCONF       30      /* software configuration */
+#define PMVXG_D_DIFFGPSMODE    503     /* differential gps moding */
+#define PMVXG_D_TRECOVUSEAGE   523     /* time recovery usage */
+#define PMVXG_D_RAWDATAOUT     524     /* raw data port data output */
+#define PMVXG_D_TRECOVRESULT   828     /* time recovery results */
+#define PMVXG_D_TRECOVOUT      830     /* time recovery output message */
diff --git a/include/ntif.h b/include/ntif.h
new file mode 100644 (file)
index 0000000..8377852
--- /dev/null
@@ -0,0 +1,98 @@
+/* this is a hacked version of if.h from unix to contain the stuff we need only to build named (bind) with
+   the minimal amount of changes... by l. kahn */
+
+   /*
+ * Copyright (c) 1982, 1986 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef        _NET_IF_H
+#define        _NET_IF_H
+
+
+/* #pragma ident       "@(#)if.h       1.3     93/06/30 SMI"
+/* if.h 1.26 90/05/29 SMI; from UCB 7.1 6/4/86         */
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*
+ * Structures defining a network interface, providing a packet
+ * transport mechanism (ala level 0 of the PUP protocols).
+ *
+ * Each interface accepts output datagrams of a specified maximum
+ * length, and provides higher level routines with input datagrams
+ * received from its medium.
+ *
+ * Output occurs when the routine if_output is called, with three parameters:
+ *     (*ifp->if_output)(ifp, m, dst)
+ * Here m is the mbuf chain to be sent and dst is the destination address.
+ * The output routine encapsulates the supplied datagram if necessary,
+ * and then transmits it on its medium.
+ *
+ * On input, each interface unwraps the data received by it, and either
+ * places it on the input queue of a internetwork datagram routine
+ * and posts the associated software interrupt, or passes the datagram to a raw
+ * packet input routine.
+ *
+ * Routines exist for locating interfaces by their addresses
+ * or for locating a interface on a certain network, as well as more general
+ * routing and gateway routines maintaining information used to locate
+ * interfaces.  These routines live in the files if.c and route.c
+ */
+
+/*
+ * Structure defining a queue for a network interface.
+ *
+ * (Would like to call this struct ``if'', but C isn't PL/1.)
+ */
+/*
+ * Interface request structure used for socket
+ * ioctl's.  All interface ioctl's must have parameter
+ * definitions which begin with ifr_name.  The
+ * remainder may be interface specific.
+ */
+#ifdef FD_SETSIZE
+#undef FD_SETSIZE
+#endif
+#define FD_SETSIZE 512
+#include <winsock.h>
+typedef char *caddr_t;
+
+int get_winnt_interfaces();
+
+struct ifreq {
+#define        IFNAMSIZ        16
+       char    ifr_name[IFNAMSIZ];             /* if name, e.g. "en0" */
+       struct  sockaddr ifru_addr;
+    char    nt_mask[IFNAMSIZ];      /* new field to store mask returned from nt lookup l. kahn */
+
+#define        ifr_addr        ifru_addr       /* address */
+#define        ifr_mask        nt_mask     /* nt mask in character form */
+
+};
+
+/*
+ * Structure used in SIOCGIFCONF request.
+ * Used to retrieve interface configuration
+ * for machine (useful for programs which
+ * must know all networks accessible).
+ */
+struct ifconf {
+       int     ifc_len;                /* size of associated buffer */
+       union {
+               caddr_t ifcu_buf;
+               struct  ifreq *ifcu_req;
+       } ifc_ifcu;
+#define        ifc_buf ifc_ifcu.ifcu_buf       /* buffer address */
+#define        ifc_req ifc_ifcu.ifcu_req       /* array of structures returned */
+};
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _NET_IF_H */
+
diff --git a/include/ntp.h b/include/ntp.h
new file mode 100644 (file)
index 0000000..dad9de1
--- /dev/null
@@ -0,0 +1,907 @@
+/*
+ * ntp.h - NTP definitions for the masses
+ */
+#ifndef NTP_H
+#define NTP_H
+
+#include "ntp_types.h"
+#include <math.h>
+#ifdef OPENSSL
+#include "ntp_crypto.h"
+#endif /* OPENSSL */
+#include <ntp_random.h>
+
+#include <isc/boolean.h>
+#include <isc/list.h>
+
+/*
+ * Calendar arithmetic - contributed by G. Healton
+ */
+#define YEAR_BREAK 500         /* years < this are tm_year values:
+                                * Break < AnyFourDigitYear && Break >
+                                * Anytm_yearYear */
+
+#define YEAR_PIVOT 98          /* 97/98: years < this are year 2000+
+                                * FYI: official UNIX pivot year is
+                                * 68/69 */
+
+/*
+ * Number of Days since 1 BC Gregorian to 1 January of given year
+ */
+#define julian0(year)  (((year) * 365 ) + ((year) > 0 ? (((year) + 3) \
+                           / 4 - ((year - 1) / 100) + ((year - 1) / \
+                           400)) : 0))
+
+/*
+ * Number of days since start of NTP time to 1 January of given year
+ */
+#define ntp0(year)     (julian0(year) - julian0(1900))
+
+/*
+ * Number of days since start of UNIX time to 1 January of given year
+ */
+#define unix0(year)    (julian0(year) - julian0(1970))
+
+/*
+ * LEAP YEAR test for full 4-digit years (e.g, 1999, 2010)
+ */
+#define isleap_4(y)    ((y) % 4 == 0 && !((y) % 100 == 0 && !(y % \
+                           400 == 0)))
+
+/*
+ * LEAP YEAR test for tm_year (struct tm) years (e.g, 99, 110)
+ */
+#define isleap_tm(y)   ((y) % 4 == 0 && !((y) % 100 == 0 && !(((y) \
+                           + 1900) % 400 == 0)))
+
+/*
+ * to convert simple two-digit years to tm_year style years:
+ *
+ *     if (year < YEAR_PIVOT)
+ *             year += 100;
+ *
+ * to convert either two-digit OR tm_year years to four-digit years:
+ *
+ *     if (year < YEAR_PIVOT)
+ *             year += 100;
+ *
+ *     if (year < YEAR_BREAK)
+ *             year += 1900;
+ */
+
+/*
+ * How to get signed characters.  On machines where signed char works,
+ * use it. On machines where signed char doesn't work, char had better
+ * be signed.
+ */
+#ifdef NEED_S_CHAR_TYPEDEF
+# if SIZEOF_SIGNED_CHAR
+typedef signed char s_char;
+# else
+typedef char s_char;
+# endif
+  /* XXX: Why is this sequent bit INSIDE this test? */
+# ifdef sequent
+#  undef SO_RCVBUF
+#  undef SO_SNDBUF
+# endif
+#endif
+#ifndef TRUE
+# define TRUE 1
+#endif /* TRUE */
+#ifndef FALSE
+# define FALSE 0
+#endif /* FALSE */
+
+/*
+ * NTP protocol parameters.  See section 3.2.6 of the specification.
+ */
+#define        NTP_VERSION     ((u_char)4) /* current version number */
+#define        NTP_OLDVERSION  ((u_char)1) /* oldest credible version */
+#define        NTP_PORT        123     /* included for non-unix machines */
+
+/*
+ * Poll interval parameters
+ */
+#define NTP_UNREACH    24      /* poll unreach threshold */
+#define        NTP_MINPOLL     4       /* log2 min poll interval (16 s) */
+#define NTP_MINDPOLL   6       /* log2 default min poll (64 s) */
+#define NTP_MAXDPOLL   10      /* log2 default max poll (~17 m) */
+#define        NTP_MAXPOLL     17      /* log2 max poll interval (~36 h) */
+#define NTP_BURST      8       /* packets in burst */
+#define BURST_DELAY    2       /* interburst delay (s) */
+#define        RESP_DELAY      1       /* crypto response delay (s) */
+
+/*
+ * Clock filter algorithm tuning parameters
+ */
+#define MAXDISPERSE    16.     /* max dispersion */
+#define        NTP_SHIFT       8       /* clock filter stages */
+#define NTP_FWEIGHT    .5      /* clock filter weight */
+
+/*
+ * Selection algorithm tuning parameters
+ */
+#define        NTP_MINCLOCK    3       /* min survivors */
+#define        NTP_MAXCLOCK    10      /* max candidates */
+#define        NTP_MAXASSOC    50      /* max associations */
+#define MINDISPERSE    .005    /* min dispersion increment */
+#define MAXDISTANCE    1.      /* max root distance (select threshold) */
+#define CLOCK_SGATE    3.      /* popcorn spike gate */
+#define HUFFPUFF       900     /* huff-n'-puff sample interval (s) */
+#define MAXHOP         2       /* anti-clockhop threshold */
+#define MAX_TTL                8       /* max ttl mapping vector size */
+#define        BEACON          7200    /* manycast beacon interval */
+#define NTP_MAXEXTEN   1024    /* max extension field size */
+
+/*
+ * Miscellaneous stuff
+ */
+#define NTP_MAXKEY     65535   /* max authentication key number */
+
+/*
+ * Limits of things
+ */
+#define        MAXFILENAME     128     /* max length of file name */
+#define MAXHOSTNAME    512     /* max length of host/node name */
+#define NTP_MAXSTRLEN  256     /* max string length */
+
+/*
+ * Operations for jitter calculations (these use doubles).
+ *
+ * Note that we carefully separate the jitter component from the
+ * dispersion component (frequency error plus precision). The frequency
+ * error component is computed as CLOCK_PHI times the difference between
+ * the epoch of the time measurement and the reference time. The
+ * precision componen is computed as the square root of the mean of the
+ * squares of a zero-mean, uniform distribution of unit maximum
+ * amplitude. Whether this makes statistical sense may be arguable.
+ */
+#define SQUARE(x) ((x) * (x))
+#define SQRT(x) (sqrt(x))
+#define DIFF(x, y) (SQUARE((x) - (y)))
+#define LOGTOD(a)      ((a) < 0 ? 1. / (1L << -(a)) : \
+                           1L << (int)(a)) /* log2 to double */
+#define UNIVAR(x)      (SQUARE(.28867513 * LOGTOD(x))) /* std uniform distr */
+#define ULOGTOD(a)     (1L << (int)(a)) /* ulog2 to double */
+
+#define        EVENT_TIMEOUT   0       /* one second, that is */
+
+/*
+ * The interface structure is used to hold the addresses and socket
+ * numbers of each of the interfaces we are using.
+ */
+struct interface {
+       SOCKET fd;                      /* socket this is opened on */
+       SOCKET bfd;                     /* socket for receiving broadcasts */
+       struct sockaddr_storage sin;    /* interface address */
+       struct sockaddr_storage bcast;  /* broadcast address */
+       struct sockaddr_storage mask;   /* interface mask */
+       char name[32];                  /* name of interface */
+       short  family;                  /* Address family */
+       int flags;                      /* interface flags */
+       int last_ttl;                   /* last TTL specified */
+       u_int32 addr_refid;             /* IPv4 addr or IPv6 hash */
+       int num_mcast;                  /* No. of IP addresses in multicast socket */
+       u_long starttime;               /* current_time as of creation of interface structure */
+       volatile long received;         /* number of incoming packets */
+       long sent;                      /* number of outgoing packets */
+       long notsent;                   /* number of send failures */
+       u_int scopeid;                  /* Scope used for Multicasting */
+       u_int ifindex;                  /* interface index */
+       u_int ifnum;                    /* sequential interface instance count */
+        u_char phase;                  /* phase in update cycle */
+       isc_boolean_t ignore_packets;   /* Specify whether the packet should be ignored */
+        ISC_LIST(struct peer) peers;    /* list of peers for the interface */
+        u_int peercnt;                 /* number of peers referencinf this interface - informational only */
+        ISC_LINK(struct interface) link;     /* interface list */
+};
+
+/*
+ * Flags for interfaces
+ */
+#define INT_UP         0x001   /* Interface is up */
+#define        INT_PPP         0x002   /* Point-to-point interface */
+#define        INT_LOOPBACK    0x004   /* the loopback interface */
+#define        INT_BROADCAST   0x008   /* can broadcast out this interface */
+#define INT_MULTICAST  0x010   /* can multicast out this interface */
+#define        INT_BCASTOPEN   0x020   /* broadcast socket is open */
+#define INT_MCASTOPEN  0x040   /* multicasting enabled */
+#define INT_WILDCARD    0x080   /* wildcard interface - usually skipped */
+#define INT_MCASTIF     0x100  /* bound directly to MCAST address */
+/*
+ * Define flasher bits (tests 1 through 11 in packet procedure)
+ * These reveal the state at the last grumble from the peer and are
+ * most handy for diagnosing problems, even if not strictly a state
+ * variable in the spec. These are recorded in the peer structure.
+ *
+ * Packet errors
+ */
+#define TEST1          0X0001  /* duplicate packet */
+#define TEST2          0x0002  /* bogus packet */
+#define TEST3          0x0004  /* protocol unsynchronized */
+#define TEST4          0x0008  /* access denied */
+#define TEST5          0x0010  /* authentication error */
+#define TEST6          0x0020  /* bad synch or stratum */
+#define TEST7          0x0040  /* bad header data */
+#define TEST8          0x0080  /* autokey error */
+#define TEST9          0x0100  /* crypto error */
+#define        PKT_TEST_MASK   (TEST1 | TEST2 | TEST3 | TEST4 | TEST5 |\
+                       TEST6 | TEST7 | TEST8 | TEST9)
+/*
+ * Peer errors
+ */
+#define TEST10         0x0200  /* peer bad synch or stratum */
+#define        TEST11          0x0400  /* peer distance exceeded */
+#define TEST12         0x0800  /* peer synchronization loop */
+#define TEST13         0x1000  /* peer unreacable */
+#define        PEER_TEST_MASK  (TEST10 | TEST11 | TEST12 | TEST13)
+
+/*
+ * Authentication codes
+ */
+#define        AUTH_NONE       0       /* no authentication */
+#define        AUTH_OK         1       /* authentication OK */
+#define        AUTH_ERROR      2       /* authentication error */
+#define        AUTH_CRYPTO     3       /* crypto-NAK */
+
+/*
+ * The peer structure. Holds state information relating to the guys
+ * we are peering with. Most of this stuff is from section 3.2 of the
+ * spec.
+ */
+struct peer {
+       struct peer *next;      /* pointer to next association */
+       struct peer *ass_next;  /* link pointer in associd hash */
+       struct sockaddr_storage srcadr; /* address of remote host */
+       struct interface *dstadr; /* pointer to address on local host */
+        ISC_LINK(struct peer) ilink; /* interface link list */
+       associd_t associd;      /* association ID */
+       u_char  version;        /* version number */
+       u_char  hmode;          /* local association mode */
+       u_char  hpoll;          /* local poll interval */
+       u_char  minpoll;        /* min poll interval */
+       u_char  maxpoll;        /* max poll interval */
+       u_int   flags;          /* association flags */
+       u_char  cast_flags;     /* additional flags */
+       u_int   flash;          /* protocol error test tally bits */
+       u_char  last_event;     /* last peer error code */
+       u_char  num_events;     /* number of error events */
+       u_char  ttl;            /* ttl/refclock mode */
+
+       /*
+        * Variables used by reference clock support
+        */
+#ifdef REFCLOCK
+       struct refclockproc *procptr; /* refclock structure pointer */
+       u_char  refclktype;     /* reference clock type */
+       u_char  refclkunit;     /* reference clock unit number */
+       u_char  sstclktype;     /* clock type for system status word */
+#endif /* REFCLOCK */
+
+       /*
+        * Variables set by received packet
+        */
+       u_char  leap;           /* local leap indicator */
+       u_char  pmode;          /* remote association mode */
+       u_char  stratum;        /* remote stratum */
+       u_char  ppoll;          /* remote poll interval */
+       s_char  precision;      /* remote clock precision */
+       double  rootdelay;      /* roundtrip delay to primary clock */
+       double  rootdispersion; /* dispersion to primary clock */
+       u_int32 refid;          /* remote reference ID */
+       l_fp    reftime;        /* update epoch */
+
+       /*
+        * Variables used by authenticated client
+        */
+       keyid_t keyid;          /* current key ID */
+#ifdef OPENSSL
+#define clear_to_zero assoc
+       associd_t assoc;        /* peer association ID */
+       u_int32 crypto;         /* peer status word */
+       EVP_PKEY *pkey;         /* public key */
+       const EVP_MD *digest;   /* message digest algorithm */
+       char    *subject;       /* certificate subject name */
+       char    *issuer;        /* certificate issuer name */
+       keyid_t pkeyid;         /* previous key ID */
+       keyid_t pcookie;        /* peer cookie */
+       EVP_PKEY *ident_pkey;   /* identity key */
+       tstamp_t fstamp;        /* identity filestamp */
+       BIGNUM  *iffval;        /* IFF/GQ challenge */
+       BIGNUM  *grpkey;        /* GQ group key */
+       struct value cookval;   /* cookie values */
+       struct value recval;    /* receive autokey values */
+       struct exten *cmmd;     /* extension pointer */
+
+       /*
+        * Variables used by authenticated server
+        */
+       keyid_t *keylist;       /* session key ID list */
+       int     keynumber;      /* current key number */
+       struct value encrypt;   /* send encrypt values */
+       struct value sndval;    /* send autokey values */
+       struct value tai_leap;  /* send leapsecond table */
+#else /* OPENSSL */
+#define clear_to_zero status
+#endif /* OPENSSL */
+
+       /*
+        * Ephemeral state variables
+        */
+       u_char  status;         /* peer status */
+       u_char  reach;          /* reachability register */
+       u_long  epoch;          /* reference epoch */
+       u_int   burst;          /* packets remaining in burst */
+       u_int   filter_nextpt;  /* index into filter shift register */
+       double  filter_delay[NTP_SHIFT]; /* delay shift register */
+       double  filter_offset[NTP_SHIFT]; /* offset shift register */
+       double  filter_disp[NTP_SHIFT]; /* dispersion shift register */
+       u_long  filter_epoch[NTP_SHIFT]; /* epoch shift register */
+       u_char  filter_order[NTP_SHIFT]; /* filter sort index */
+       l_fp    org;            /* originate time stamp */
+       l_fp    rec;            /* receive time stamp */
+       l_fp    xmt;            /* transmit time stamp */
+       double  offset;         /* peer clock offset */
+       double  delay;          /* peer roundtrip delay */
+       double  jitter;         /* peer jitter (squares) */
+       double  disp;           /* peer dispersion */
+       double  estbdelay;      /* clock offset to broadcast server */
+
+       /*
+        * End of clear-to-zero area
+        */
+       u_long  update;         /* receive epoch */
+       u_int   unreach;        /* unreachable count */
+#define end_clear_to_zero unreach
+       u_long  outdate;        /* send time last packet */
+       u_long  nextdate;       /* send time next packet */
+       u_long  nextaction;     /* peer local activity timeout (refclocks) */
+       void (*action) P((struct peer *)); /* action timeout function */
+
+       /*
+        * Statistic counters
+        */
+       u_long  timereset;      /* time stat counters were reset */
+       u_long  timereceived;   /* last packet received time */
+       u_long  timereachable;  /* last reachable/unreachable time */
+
+       u_long  sent;           /* packets sent */
+       u_long  received;       /* packets received */
+       u_long  processed;      /* packets processed by the protocol */
+       u_long  badauth;        /* packets cryptosum failed */
+       u_long  bogusorg;       /* packets bogus origin */
+       u_long  oldpkt;         /* packets duplicate packet */
+       u_long  seldisptoolarge; /* packets dispersion too large */
+       u_long  selbroken;      /* not used */
+};
+
+/*
+ * Values for peer.leap, sys_leap
+ */
+#define        LEAP_NOWARNING  0x0     /* normal, no leap second warning */
+#define        LEAP_ADDSECOND  0x1     /* last minute of day has 61 seconds */
+#define        LEAP_DELSECOND  0x2     /* last minute of day has 59 seconds */
+#define        LEAP_NOTINSYNC  0x3     /* overload, clock is free running */
+
+/*
+ * Values for peer mode and packet mode. Only the modes through
+ * MODE_BROADCAST and MODE_BCLIENT appear in the transition
+ * function. MODE_CONTROL and MODE_PRIVATE can appear in packets,
+ * but those never survive to the transition function.
+ * is a
+ */
+#define        MODE_UNSPEC     0       /* unspecified (old version) */
+#define        MODE_ACTIVE     1       /* symmetric active mode */
+#define        MODE_PASSIVE    2       /* symmetric passive mode */
+#define        MODE_CLIENT     3       /* client mode */
+#define        MODE_SERVER     4       /* server mode */
+#define        MODE_BROADCAST  5       /* broadcast mode */
+/*
+ * These can appear in packets
+ */
+#define        MODE_CONTROL    6       /* control mode */
+#define        MODE_PRIVATE    7       /* private mode */
+/*
+ * This is a madeup mode for broadcast client.
+ */
+#define        MODE_BCLIENT    6       /* broadcast client mode */
+
+/*
+ * Values for peer.stratum, sys_stratum
+ */
+#define        STRATUM_REFCLOCK ((u_char)0) /* default stratum */
+/* A stratum of 0 in the packet is mapped to 16 internally */
+#define        STRATUM_PKT_UNSPEC ((u_char)0) /* unspecified in packet */
+#define        STRATUM_UNSPEC  ((u_char)16) /* unspecified */
+
+/*
+ * Values for peer.flags
+ */
+#define        FLAG_CONFIG     0x0001  /* association was configured */
+#define        FLAG_AUTHENABLE 0x0002  /* authentication required */
+#define        FLAG_AUTHENTIC  0x0004  /* last message was authentic */
+#define FLAG_SKEY      0x0008  /* autokey authentication */
+#define FLAG_MCAST     0x0010  /* multicast client mode */
+#define        FLAG_REFCLOCK   0x0020  /* this is actually a reference clock */
+#define        FLAG_SYSPEER    0x0040  /* this is one of the selected peers */
+#define FLAG_PREFER    0x0080  /* this is the preferred peer */
+#define FLAG_BURST     0x0100  /* burst mode */
+#define FLAG_IBURST    0x0200  /* initial burst mode */
+#define FLAG_NOSELECT  0x0400  /* never select */
+#define FLAG_ASSOC     0x0800  /* autokey request */
+#define FLAG_FIXPOLL   0x1000  /* stick at minpoll */
+#define FLAG_TRUE      0x2000  /* select truechimer */
+#define        FLAG_PREEMPT    0x4000  /* preemptable association */
+
+/*
+ * Definitions for the clear() routine.  We use memset() to clear
+ * the parts of the peer structure which go to zero.  These are
+ * used to calculate the start address and length of the area.
+ */
+#define        CLEAR_TO_ZERO(p)        ((char *)&((p)->clear_to_zero))
+#define        END_CLEAR_TO_ZERO(p)    ((char *)&((p)->end_clear_to_zero))
+#define        LEN_CLEAR_TO_ZERO       (END_CLEAR_TO_ZERO((struct peer *)0) \
+                                   - CLEAR_TO_ZERO((struct peer *)0))
+#define CRYPTO_TO_ZERO(p)      ((char *)&((p)->clear_to_zero))
+#define END_CRYPTO_TO_ZERO(p)  ((char *)&((p)->end_clear_to_zero))
+#define LEN_CRYPTO_TO_ZERO     (END_CRYPTO_TO_ZERO((struct peer *)0) \
+                                   - CRYPTO_TO_ZERO((struct peer *)0))
+
+/*
+ * Reference clock identifiers (for pps signal)
+ */
+#define PPSREFID (u_int32)"PPS "       /* used when pps controls stratum>1 */
+
+/*
+ * Reference clock types.  Added as necessary.
+ */
+#define        REFCLK_NONE             0       /* unknown or missing */
+#define        REFCLK_LOCALCLOCK       1       /* external (e.g., lockclock) */
+#define        REFCLK_GPS_TRAK         2       /* TRAK 8810 GPS Receiver */
+#define        REFCLK_WWV_PST          3       /* PST/Traconex 1020 WWV/H */
+#define        REFCLK_SPECTRACOM       4       /* Spectracom (generic) Receivers */
+#define        REFCLK_TRUETIME         5       /* TrueTime (generic) Receivers */
+#define REFCLK_IRIG_AUDIO      6       /* IRIG-B/W audio decoder */
+#define        REFCLK_CHU_AUDIO        7       /* CHU audio demodulator/decoder */
+#define REFCLK_PARSE           8       /* generic driver (usually DCF77,GPS,MSF) */
+#define        REFCLK_GPS_MX4200       9       /* Magnavox MX4200 GPS */
+#define REFCLK_GPS_AS2201      10      /* Austron 2201A GPS */
+#define        REFCLK_GPS_ARBITER      11      /* Arbiter 1088A/B/ GPS */
+#define REFCLK_IRIG_TPRO       12      /* KSI/Odetics TPRO-S IRIG */
+#define REFCLK_ATOM_LEITCH     13      /* Leitch CSD 5300 Master Clock */
+#define REFCLK_MSF_EES         14      /* EES M201 MSF Receiver */
+#define        REFCLK_GPSTM_TRUE       15      /* OLD TrueTime GPS/TM-TMD Receiver */
+#define REFCLK_IRIG_BANCOMM    16      /* Bancomm GPS/IRIG Interface */
+#define REFCLK_GPS_DATUM       17      /* Datum Programmable Time System */
+#define REFCLK_ACTS            18      /* Generic Auto Computer Time Service */
+#define REFCLK_WWV_HEATH       19      /* Heath GC1000 WWV/WWVH Receiver */
+#define REFCLK_GPS_NMEA                20      /* NMEA based GPS clock */
+#define REFCLK_GPS_VME         21      /* TrueTime GPS-VME Interface */
+#define REFCLK_ATOM_PPS                22      /* 1-PPS Clock Discipline */
+#define REFCLK_PTB_ACTS                23      /* replaced by REFCLK_ACTS */
+#define REFCLK_USNO            24      /* replaced by REFCLK_ACTS */
+#define REFCLK_GPS_HP          26      /* HP 58503A Time/Frequency Receiver */
+#define REFCLK_ARCRON_MSF      27      /* ARCRON MSF radio clock. */
+#define REFCLK_SHM             28      /* clock attached thru shared memory */
+#define REFCLK_PALISADE                29      /* Trimble Navigation Palisade GPS */
+#define REFCLK_ONCORE          30      /* Motorola UT Oncore GPS */
+#define REFCLK_GPS_JUPITER     31      /* Rockwell Jupiter GPS receiver */
+#define REFCLK_CHRONOLOG       32      /* Chrono-log K WWVB receiver */
+#define REFCLK_DUMBCLOCK       33      /* Dumb localtime clock */
+#define REFCLK_ULINK           34      /* Ultralink M320 WWVB receiver */
+#define REFCLK_PCF             35      /* Conrad parallel port radio clock */
+#define REFCLK_WWV_AUDIO       36      /* WWV/H audio demodulator/decoder */
+#define REFCLK_FG              37      /* Forum Graphic GPS */
+#define REFCLK_HOPF_SERIAL     38      /* hopf DCF77/GPS serial receiver  */
+#define REFCLK_HOPF_PCI                39      /* hopf DCF77/GPS PCI receiver  */
+#define REFCLK_JJY             40      /* JJY receiver  */
+#define        REFCLK_TT560            41      /* TrueTime 560 IRIG-B decoder */
+#define REFCLK_ZYFER           42      /* Zyfer GPStarplus receiver  */
+#define REFCLK_RIPENCC         43      /* RIPE NCC Trimble driver */
+#define REFCLK_NEOCLOCK4X      44      /* NeoClock4X DCF77 or TDF receiver */
+#define REFCLK_MAX             44      /* NeoClock4X DCF77 or TDF receiver */
+
+ /*
+ * Macro for sockaddr_storage structures operations
+ */
+#define SOCKCMP(sock1, sock2) \
+       (((struct sockaddr_storage *)sock1)->ss_family \
+           == ((struct sockaddr_storage *)sock2)->ss_family ? \
+       ((struct sockaddr_storage *)sock1)->ss_family == AF_INET ? \
+       memcmp(&((struct sockaddr_in *)sock1)->sin_addr, \
+           &((struct sockaddr_in *)sock2)->sin_addr, \
+           sizeof(struct in_addr)) == 0 : \
+       memcmp(&((struct sockaddr_in6 *)sock1)->sin6_addr, \
+           &((struct sockaddr_in6 *)sock2)->sin6_addr, \
+           sizeof(struct in6_addr)) == 0 : \
+       0)
+
+#define SOCKNUL(sock1) \
+       (((struct sockaddr_storage *)sock1)->ss_family == AF_INET ? \
+       (((struct sockaddr_in *)sock1)->sin_addr.s_addr == 0) : \
+       (IN6_IS_ADDR_UNSPECIFIED(&((struct sockaddr_in6 *)sock1)->sin6_addr)))
+
+#define SOCKLEN(sock) \
+       (((struct sockaddr_storage *)sock)->ss_family == AF_INET ? \
+       (sizeof(struct sockaddr_in)) : (sizeof(struct sockaddr_in6)))
+
+#define ANYSOCK(sock) \
+       memset(((struct sockaddr_storage *)sock), 0, \
+           sizeof(struct sockaddr_storage))
+
+#define ANY_INTERFACE_CHOOSE(sock) \
+       (((struct sockaddr_storage *)sock)->ss_family == AF_INET ? \
+       any_interface : any6_interface)
+
+/*
+ * We tell reference clocks from real peers by giving the reference
+ * clocks an address of the form 127.127.t.u, where t is the type and
+ * u is the unit number.  We define some of this here since we will need
+ * some sanity checks to make sure this address isn't interpretted as
+ * that of a normal peer.
+ */
+#define        REFCLOCK_ADDR   0x7f7f0000      /* 127.127.0.0 */
+#define        REFCLOCK_MASK   0xffff0000      /* 255.255.0.0 */
+
+#define        ISREFCLOCKADR(srcadr)   ((SRCADR(srcadr) & REFCLOCK_MASK) \
+                                       == REFCLOCK_ADDR)
+
+/*
+ * Macro for checking for invalid addresses.  This is really, really
+ * gross, but is needed so no one configures a host on net 127 now that
+ * we're encouraging it the the configuration file.
+ */
+#define        LOOPBACKADR     0x7f000001
+#define        LOOPNETMASK     0xff000000
+
+#define        ISBADADR(srcadr)        (((SRCADR(srcadr) & LOOPNETMASK) \
+                                   == (LOOPBACKADR & LOOPNETMASK)) \
+                                   && (SRCADR(srcadr) != LOOPBACKADR))
+
+/*
+ * Utilities for manipulating addresses and port numbers
+ */
+#define        NSRCADR(src)    (((struct sockaddr_in *)src)->sin_addr.s_addr) /* address in net byte order */
+#define        NSRCPORT(src)   (((struct sockaddr_in *)src)->sin_port) /* port in net byte order */
+#define        SRCADR(src)     (ntohl(NSRCADR((src)))) /* address in host byte order */
+#define        SRCPORT(src)    (ntohs(NSRCPORT((src))))        /* host port */
+
+#define CAST_V4(src)   ((struct sockaddr_in *)&(src))
+#define CAST_V6(src)   ((struct sockaddr_in6 *)&(src))
+#define GET_INADDR(src)  (CAST_V4(src)->sin_addr.s_addr)
+#define GET_INADDR6(src) (CAST_V6(src)->sin6_addr)
+
+#define SET_HOSTMASK(addr, family)     \
+       do { \
+               memset((char *)(addr), 0, sizeof(struct sockaddr_storage)); \
+               (addr)->ss_family = (family); \
+               if ((family) == AF_INET) \
+                       GET_INADDR(*(addr)) = 0xffffffff; \
+               else \
+                       memset(&GET_INADDR6(*(addr)), 0xff, \
+                           sizeof(struct in6_addr)); \
+       } while(0)
+
+/*
+ * NTP packet format.  The mac field is optional.  It isn't really
+ * an l_fp either, but for now declaring it that way is convenient.
+ * See Appendix A in the specification.
+ *
+ * Note that all u_fp and l_fp values arrive in network byte order
+ * and must be converted (except the mac, which isn't, really).
+ */
+struct pkt {
+       u_char  li_vn_mode;     /* leap indicator, version and mode */
+       u_char  stratum;        /* peer stratum */
+       u_char  ppoll;          /* peer poll interval */
+       s_char  precision;      /* peer clock precision */
+       u_fp    rootdelay;      /* distance to primary clock */
+       u_fp    rootdispersion; /* clock dispersion */
+       u_int32 refid;          /* reference clock ID */
+       l_fp    reftime;        /* time peer clock was last updated */
+       l_fp    org;            /* originate time stamp */
+       l_fp    rec;            /* receive time stamp */
+       l_fp    xmt;            /* transmit time stamp */
+
+#define        LEN_PKT_NOMAC   12 * sizeof(u_int32) /* min header length */
+#define        LEN_PKT_MAC     LEN_PKT_NOMAC +  sizeof(u_int32)
+#define MIN_MAC_LEN    3 * sizeof(u_int32)     /* DES */
+#define MAX_MAC_LEN    5 * sizeof(u_int32)     /* MD5 */
+
+       /*
+        * The length of the packet less MAC must be a multiple of 64
+        * with an RSA modulus and Diffie-Hellman prime of 64 octets
+        * and maximum host name of 128 octets, the maximum autokey
+        * command is 152 octets and maximum autokey response is 460
+        * octets. A packet can contain no more than one command and one
+        * response, so the maximum total extension field length is 672
+        * octets. But, to handle humungus certificates, the bank must
+        * be broke.
+        */
+#ifdef OPENSSL
+       u_int32 exten[NTP_MAXEXTEN / 4]; /* max extension field */
+#else /* OPENSSL */
+       u_int32 exten[1];       /* misused */
+#endif /* OPENSSL */
+       u_char  mac[MAX_MAC_LEN]; /* mac */
+};
+
+/*
+ * Stuff for extracting things from li_vn_mode
+ */
+#define        PKT_MODE(li_vn_mode)    ((u_char)((li_vn_mode) & 0x7))
+#define        PKT_VERSION(li_vn_mode) ((u_char)(((li_vn_mode) >> 3) & 0x7))
+#define        PKT_LEAP(li_vn_mode)    ((u_char)(((li_vn_mode) >> 6) & 0x3))
+
+/*
+ * Stuff for putting things back into li_vn_mode
+ */
+#define        PKT_LI_VN_MODE(li, vn, md) \
+       ((u_char)((((li) << 6) & 0xc0) | (((vn) << 3) & 0x38) | ((md) & 0x7)))
+
+
+/*
+ * Dealing with stratum.  0 gets mapped to 16 incoming, and back to 0
+ * on output.
+ */
+#define        PKT_TO_STRATUM(s)       ((u_char)(((s) == (STRATUM_PKT_UNSPEC)) ?\
+                               (STRATUM_UNSPEC) : (s)))
+
+#define        STRATUM_TO_PKT(s)       ((u_char)(((s) == (STRATUM_UNSPEC)) ?\
+                               (STRATUM_PKT_UNSPEC) : (s)))
+
+/*
+ * Event codes. Used for reporting errors/events to the control module
+ */
+#define        PEER_EVENT      0x080   /* this is a peer event */
+#define CRPT_EVENT     0x100   /* this is a crypto event */
+
+/*
+ * System event codes
+ */
+#define        EVNT_UNSPEC     0       /* unspecified */
+#define        EVNT_SYSRESTART 1       /* system restart */
+#define        EVNT_SYSFAULT   2       /* wsystem or hardware fault */
+#define        EVNT_SYNCCHG    3       /* new leap or synch change */
+#define        EVNT_PEERSTCHG  4       /* new source or stratum */
+#define        EVNT_CLOCKRESET 5       /* clock reset */
+#define        EVNT_BADDATETIM 6       /* invalid time or date */
+#define        EVNT_CLOCKEXCPT 7       /* reference clock exception */
+
+/*
+ * Peer event codes
+ */
+#define        EVNT_PEERIPERR  (1 | PEER_EVENT) /* IP error */
+#define        EVNT_PEERAUTH   (2 | PEER_EVENT) /* authentication failure */
+#define        EVNT_UNREACH    (3 | PEER_EVENT) /* change to unreachable */
+#define        EVNT_REACH      (4 | PEER_EVENT) /* change to reachable */
+#define        EVNT_PEERCLOCK  (5 | PEER_EVENT) /* clock exception */
+
+/*
+ * Clock event codes
+ */
+#define        CEVNT_NOMINAL   0       /* unspecified */
+#define        CEVNT_TIMEOUT   1       /* poll timeout */
+#define        CEVNT_BADREPLY  2       /* bad reply format */
+#define        CEVNT_FAULT     3       /* hardware or software fault */
+#define        CEVNT_PROP      4       /* propagation failure */
+#define        CEVNT_BADDATE   5       /* bad date format or value */
+#define        CEVNT_BADTIME   6       /* bad time format or value */
+#define CEVNT_MAX      CEVNT_BADTIME
+
+/*
+ * Very misplaced value.  Default port through which we send traps.
+ */
+#define        TRAPPORT        18447
+
+
+/*
+ * To speed lookups, peers are hashed by the low order bits of the
+ * remote IP address. These definitions relate to that.
+ */
+#define        NTP_HASH_SIZE   128
+#define        NTP_HASH_MASK   (NTP_HASH_SIZE-1)
+#define        NTP_HASH_ADDR(src)      sock_hash(src)
+
+/*
+ * How we randomize polls.  The poll interval is a power of two. We chose
+ * a random interval which is this value plus-minus one second.
+ */
+#define RANDPOLL(x)    ((1 << (x)) - 1 + (ntp_random() & 0x3))
+
+/*
+ * min, min3 and max.  Makes it easier to transliterate the spec without
+ * thinking about it.
+ */
+#define        min(a,b)        (((a) < (b)) ? (a) : (b))
+#define        max(a,b)        (((a) > (b)) ? (a) : (b))
+#define        min3(a,b,c)     min(min((a),(b)), (c))
+
+
+/*
+ * Configuration items.  These are for the protocol module (proto_config())
+ */
+#define        PROTO_BROADCLIENT       1
+#define        PROTO_PRECISION         2       /* (not used) */
+#define        PROTO_AUTHENTICATE      3
+#define        PROTO_BROADDELAY        4
+#define        PROTO_AUTHDELAY         5       /* (not used) */
+#define PROTO_MULTICAST_ADD    6
+#define PROTO_MULTICAST_DEL    7
+#define PROTO_NTP              8
+#define PROTO_KERNEL           9
+#define PROTO_MONITOR          10
+#define PROTO_FILEGEN          11
+#define        PROTO_PPS               12
+#define PROTO_CAL              13
+#define PROTO_MINCLOCK         14
+#define        PROTO_MAXCLOCK          15
+#define PROTO_MINSANE          16
+#define PROTO_FLOOR            17
+#define PROTO_CEILING          18
+#define PROTO_COHORT           19
+#define PROTO_CALLDELAY                20
+#define PROTO_MINDISP          21
+#define PROTO_MAXDIST          22
+#define PROTO_ADJ              23
+#define        PROTO_MAXHOP            24
+#define        PROTO_BEACON            25
+#define        PROTO_ORPHAN            26
+
+/*
+ * Configuration items for the loop filter
+ */
+#define        LOOP_DRIFTINIT          1       /* set initial frequency offset */
+#define LOOP_DRIFTCOMP         2       /* set frequency offset */
+#define LOOP_MAX               3       /* set step offset */
+#define LOOP_PANIC             4       /* set panic offseet */
+#define LOOP_PHI               5       /* set dispersion rate */
+#define LOOP_MINSTEP           6       /* set step timeout */
+#define LOOP_MINPOLL           7       /* set min poll interval (log2 s) */
+#define LOOP_ALLAN             8       /* set minimum Allan intercept */
+#define LOOP_HUFFPUFF          9       /* set huff-n'-puff filter length */
+#define LOOP_FREQ              10      /* set initial frequency */
+#define LOOP_KERN_CLEAR                11      /* reset kernel pll parameters */
+
+/*
+ * Configuration items for the stats printer
+ */
+#define        STATS_FREQ_FILE         1       /* configure drift file */
+#define STATS_STATSDIR         2       /* directory prefix for stats files */
+#define        STATS_PID_FILE          3       /* configure ntpd PID file */
+
+#define MJD_1900               15020   /* MJD for 1 Jan 1900 */
+
+/*
+ * Default parameters.  We use these in the absence of something better.
+ */
+#define        DEFBROADDELAY   4e-3            /* default broadcast offset */
+#define INADDR_NTP     0xe0000101      /* NTP multicast address 224.0.1.1 */
+
+/*
+ * Structure used optionally for monitoring when this is turned on.
+ */
+struct mon_data {
+       struct mon_data *hash_next;     /* next structure in hash list */
+       struct mon_data *mru_next;      /* next structure in MRU list */
+       struct mon_data *mru_prev;      /* previous structure in MRU list */
+       u_long drop_count;              /* dropped due RESLIMIT*/
+       double avg_interval;            /* average interpacket interval */
+       u_long lasttime;                /* interval since last packet */
+       u_long count;                   /* total packet count */
+       struct sockaddr_storage rmtadr; /* address of remote host */
+       struct interface *interface;    /* interface on which this arrived */
+       u_short rmtport;                /* remote port last came from */
+       u_char mode;                    /* mode of incoming packet */
+       u_char version;                 /* version of incoming packet */
+       u_char cast_flags;              /* flags MDF_?CAST */
+};
+
+/*
+ * Values for cast_flags
+ */
+#define        MDF_UCAST       0x01            /* unicast */
+#define        MDF_MCAST       0x02            /* multicast */
+#define        MDF_BCAST       0x04            /* broadcast */
+#define        MDF_LCAST       0x08            /* localcast */
+#define MDF_ACAST      0x10            /* manycast */
+#define        MDF_BCLNT       0x20            /* broadcast client */
+#define MDF_ACLNT      0x40            /* manycast client */
+
+/*
+ * Values used with mon_enabled to indicate reason for enabling monitoring
+ */
+#define MON_OFF    0x00                        /* no monitoring */
+#define MON_ON     0x01                        /* monitoring explicitly enabled */
+#define MON_RES    0x02                        /* implicit monitoring for RES_LIMITED */
+/*
+ * Structure used for restrictlist entries
+ */
+struct restrictlist {
+       struct restrictlist *next;      /* link to next entry */
+       u_int32 addr;                   /* Ipv4 host address (host byte order) */
+       u_int32 mask;                   /* Ipv4 mask for address (host byte order) */
+       u_long count;                   /* number of packets matched */
+       u_short flags;                  /* accesslist flags */
+       u_short mflags;                 /* match flags */
+};
+
+struct restrictlist6 {
+       struct restrictlist6 *next;     /* link to next entry */
+       struct in6_addr addr6;          /* Ipv6 host address */
+       struct in6_addr mask6;          /* Ipv6 mask address */
+       u_long count;                   /* number of packets matched */
+       u_short flags;                  /* accesslist flags */
+       u_short mflags;                 /* match flags */
+};
+
+
+/*
+ * Access flags
+ */
+#define        RES_IGNORE              0x001   /* ignore packet */
+#define        RES_DONTSERVE           0x002   /* access denied */
+#define        RES_DONTTRUST           0x004   /* authentication required */
+#define        RES_VERSION             0x008   /* version mismatch */
+#define        RES_NOPEER              0x010   /* new association denied */
+#define RES_LIMITED            0x020   /* packet rate exceeded */
+
+#define RES_FLAGS              (RES_IGNORE | RES_DONTSERVE |\
+                                   RES_DONTTRUST | RES_VERSION |\
+                                   RES_NOPEER | RES_LIMITED)
+
+#define        RES_NOQUERY             0x040   /* mode 6/7 packet denied */
+#define        RES_NOMODIFY            0x080   /* mode 6/7 modify denied */
+#define        RES_NOTRAP              0x100   /* mode 6/7 set trap denied */
+#define        RES_LPTRAP              0x200   /* mode 6/7 low priority trap */
+
+#define RES_DEMOBILIZE         0x400   /* send kiss of death packet */
+#define RES_TIMEOUT            0x800   /* timeout this entry */
+
+#define        RES_ALLFLAGS            (RES_FLAGS | RES_NOQUERY |\
+                                   RES_NOMODIFY | RES_NOTRAP |\
+                                   RES_LPTRAP | RES_DEMOBILIZE |\
+                                   RES_TIMEOUT)
+
+/*
+ * Match flags
+ */
+#define        RESM_INTERFACE          0x1     /* this is an interface */
+#define        RESM_NTPONLY            0x2     /* match ntp port only */
+
+/*
+ * Restriction configuration ops
+ */
+#define        RESTRICT_FLAGS          1       /* add flags to restrict entry */
+#define        RESTRICT_UNFLAG         2       /* remove flags from restrict entry */
+#define        RESTRICT_REMOVE         3       /* remove a restrict entry */
+#define        RESTRICT_REMOVEIF       4       /* remove an interface restrict entry */
+
+/*
+ * Endpoint structure for the select algorithm
+ */
+struct endpoint {
+       double  val;                    /* offset of endpoint */
+       int     type;                   /* interval entry/exit */
+};
+
+/*
+ * Association matching AM[] return codes
+ */
+#define AM_ERR         -1              /* error */
+#define AM_NOMATCH     0               /* no match */
+#define AM_PROCPKT     1               /* server/symmetric packet */   
+#define AM_BCST                2               /* broadcast packet */  
+#define AM_FXMIT       3               /* client packet */
+#define AM_MANYCAST    4               /* manycast packet */
+#define AM_NEWPASS     5               /* new passive */
+#define AM_NEWBCL      6               /* new broadcast */
+#define        AM_POSSBCL      7               /* discard broadcast */
+
+/* NetInfo configuration locations */
+#ifdef HAVE_NETINFO
+#define NETINFO_CONFIG_DIR "/config/ntp"
+#endif
+
+#endif /* NTP_H */
diff --git a/include/ntp_calendar.h b/include/ntp_calendar.h
new file mode 100644 (file)
index 0000000..95e2c12
--- /dev/null
@@ -0,0 +1,112 @@
+/*
+ * ntp_calendar.h - definitions for the calendar time-of-day routine
+ */
+#ifndef NTP_CALENDAR_H
+#define NTP_CALENDAR_H
+
+#include "ntp_types.h"
+
+struct calendar {
+       u_short year;   /* year (A.D.) */
+       u_short yearday;        /* day of year, 1 = January 1 */
+       u_char month;   /* month, 1 = January */
+       u_char monthday;        /* day of month */
+       u_char hour;    /* hour of day, midnight = 0 */
+       u_char minute;  /* minute of hour */
+       u_char second;  /* second of minute */
+};
+
+/*
+ * Days in each month.  30 days hath September...
+ */
+#define        JAN     31
+#define        FEB     28
+#define        FEBLEAP 29
+#define        MAR     31
+#define        APR     30
+#define        MAY     31
+#define        JUN     30
+#define        JUL     31
+#define        AUG     31
+#define        SEP     30
+#define        OCT     31
+#define        NOV     30
+#define        DEC     31
+
+/*
+ * We deal in a 4 year cycle starting at March 1, 1900.  We assume
+ * we will only want to deal with dates since then, and not to exceed
+ * the rollover day in 2036.
+ */
+#define        SECSPERMIN      (60)                    /* seconds per minute */
+#define        MINSPERHR       (60)                    /* minutes per hour */
+#define        HRSPERDAY       (24)                    /* hours per day */
+#define        DAYSPERYEAR     (365)                   /* days per year */
+
+#define        SECSPERDAY      (SECSPERMIN*MINSPERHR*HRSPERDAY)
+#define SECSPERYEAR    (365 * SECSPERDAY)      /* regular year */
+#define        SECSPERLEAPYEAR (366 * SECSPERDAY)      /* leap year */
+
+#define        MAR1900         ((JAN+FEB) * SECSPERDAY) /* no leap year in 1900 */
+#define        DAYSPERCYCLE    (365+365+365+366)       /* 3 normal years plus leap */
+#define        SECSPERCYCLE    (DAYSPERCYCLE*SECSPERDAY)
+#define        YEARSPERCYCLE   4
+
+/*
+ * Gross hacks.  I have illicit knowlege that there won't be overflows
+ * here, the compiler often can't tell this.
+ */
+#define TIMES60(val)   ((((val)<<4) - (val))<<2)       /* *(16 - 1) * 4 */
+#define        TIMES24(val)    (((val)<<4) + ((val)<<3))       /* *16 + *8 */
+#define        TIMES7(val)     (((val)<<3) - (val))            /* *8  - *1 */
+#define        TIMESDPERC(val) (((val)<<10) + ((val)<<8) \
+                       + ((val)<<7) + ((val)<<5) \
+                       + ((val)<<4) + ((val)<<2) + (val))      /* *big* hack */
+
+/*
+ * Another big hack.  Cycle 22 started on March 1, 1988.  This is
+ * STARTCYCLE22 seconds after the start of cycle 0.
+ */
+#define        CYCLE22         (22)
+#define        STARTCYCLE22    (u_long)(0xa586b500)    /* 2777068800 */
+#define        MAR1988         (u_long)(STARTCYCLE22 + (u_long)MAR1900)
+
+/*
+ * The length of January + February in leap and non-leap years.
+ */
+#define        JANFEBNOLEAP    ((JAN+FEB) * SECSPERDAY)
+#define        JANFEBLEAP      ((JAN+FEBLEAP) * SECSPERDAY)
+
+
+extern void    caljulian       P((u_long, struct calendar *));
+extern u_long  caltontp        P((const struct calendar *));
+
+/*
+ * Additional support stuff for Ed Rheingold's calendrical calculations
+ */
+
+/*
+ * Start day of NTP time as days past the imaginary date 12/1/1 BC.
+ * P((This is the beginning of the Christian Era, or BCE.))
+ */
+#define DAY_NTP_STARTS 693596
+/*
+ * The Gregorian calendar is based on a 400 year cycle.  This is the number
+ * of days in each cycle.
+ */
+#define GREGORIAN_CYCLE_DAYS 146097
+
+/*
+ * Days in a normal 100 year leap year calendar.  We lose a leap year day
+ * in years evenly divisible by 100 but not by 400.
+ */
+#define GREGORIAN_NORMAL_CENTURY_DAYS 36524
+
+/*
+ * Days in a normal 4 year leap year calendar cycle.
+ */
+#define GREGORIAN_NORMAL_LEAP_CYCLE_DAYS 1461
+
+#define is_leapyear(y) (y%4 == 0 && !(y%100 == 0 && !(y%400 == 0)))
+
+#endif
diff --git a/include/ntp_cmdargs.h b/include/ntp_cmdargs.h
new file mode 100644 (file)
index 0000000..e9ab9b1
--- /dev/null
@@ -0,0 +1,4 @@
+#include "ntp_types.h"
+
+extern void    getstartup      P((int, char **));
+extern void    getCmdOpts      P((int, char **));
diff --git a/include/ntp_config.h b/include/ntp_config.h
new file mode 100644 (file)
index 0000000..66d4f9f
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * Configuration file name
+ */
+#ifndef CONFIG_FILE
+# ifndef SYS_WINNT
+#  define      CONFIG_FILE "/etc/ntp.conf"
+# else /* SYS_WINNT */
+#  define      CONFIG_FILE     "%windir%\\system32\\drivers\\etc\\ntp.conf"
+#  define      ALT_CONFIG_FILE "%windir%\\ntp.conf"
+#  define      NTP_KEYSDIR     "%windir%\\system32\\drivers\\etc"
+# endif /* SYS_WINNT */
+#endif /* not CONFIG_FILE */
+
+/*
+ * Types of entries we understand.
+ */
+#define CONFIG_UNKNOWN         0
+
+/*
+ * Command keywords
+ */
+#define CONFIG_PEER            1
+#define CONFIG_SERVER          2
+#define CONFIG_AUTOMAX         3
+#define CONFIG_DRIFTFILE       4
+#define CONFIG_BROADCAST       5
+#define CONFIG_BROADCASTCLIENT 6
+#define CONFIG_AUTHENTICATE    7
+#define CONFIG_KEYS            8
+#define CONFIG_REVOKE          9
+#define CONFIG_CDELAY          10
+#define CONFIG_RESTRICT                11
+#define CONFIG_BDELAY          12
+#define CONFIG_TRUSTEDKEY      13
+#define CONFIG_REQUESTKEY      14
+#define CONFIG_CONTROLKEY      15
+#define CONFIG_TRAP            16
+#define CONFIG_FUDGE           17
+#define CONFIG_TINKER          18
+#define CONFIG_STATSDIR                19
+#define CONFIG_FILEGEN         20
+#define CONFIG_STATISTICS      21
+#define CONFIG_PIDFILE         22
+#define CONFIG_SETVAR          23
+#define CONFIG_DISCARD         24
+#define CONFIG_ADJ             25
+#define CONFIG_MULTICASTCLIENT 26
+#define CONFIG_ENABLE          27
+#define CONFIG_DISABLE         28
+#define CONFIG_PHONE           29
+#define CONFIG_LOGFILE         30
+#define CONFIG_LOGCONFIG       31
+#define CONFIG_MANYCASTCLIENT  32
+#define CONFIG_MANYCASTSERVER  33
+#define CONFIG_TOS             34
+#define CONFIG_TTL             35
+#define CONFIG_INCLUDEFILE      36
+#define CONFIG_KEYSDIR         37
+#define CONFIG_END             38
+#ifdef OPENSSL
+#define CONFIG_CRYPTO          39
+#endif /* OPENSSL */
+
+/*
+ * "peer", "server", "broadcast" modifier keywords
+ */
+#define CONF_MOD_VERSION       1
+#define CONF_MOD_KEY           2
+#define CONF_MOD_MINPOLL       3
+#define CONF_MOD_MAXPOLL       4
+#define CONF_MOD_PREFER                5
+#define CONF_MOD_BURST         6
+#define CONF_MOD_IBURST                7
+#define CONF_MOD_SKEY          8
+#define CONF_MOD_TTL           9
+#define CONF_MOD_MODE          10
+#define CONF_MOD_NOSELECT      11
+#define CONF_MOD_TRUE          12
+#define        CONF_MOD_PREEMPT        13
+#define CONF_MOD_DYNAMIC       14
+
+/*
+ * "restrict" modifier keywords
+ */
+#define CONF_RES_MASK          1
+#define CONF_RES_IGNORE                2
+#define CONF_RES_NOSERVE       3
+#define CONF_RES_NOTRUST       4
+#define CONF_RES_NOQUERY       5
+#define CONF_RES_NOMODIFY      6
+#define CONF_RES_NOPEER                7
+#define CONF_RES_NOTRAP                8
+#define CONF_RES_LPTRAP                9
+#define CONF_RES_NTPPORT       10
+#define CONF_RES_LIMITED       11
+#define CONF_RES_VERSION       12
+#define CONF_RES_DEMOBILIZE    13
+
+/*
+ * "trap" modifier keywords
+ */
+#define CONF_TRAP_PORT         1
+#define CONF_TRAP_INTERFACE    2
+
+/*
+ * "fudge" modifier keywords
+ */
+#define CONF_FDG_TIME1         1
+#define CONF_FDG_TIME2         2
+#define CONF_FDG_STRATUM       3
+#define CONF_FDG_REFID         4
+#define CONF_FDG_FLAG1         5
+#define CONF_FDG_FLAG2         6
+#define CONF_FDG_FLAG3         7
+#define CONF_FDG_FLAG4         8
+
+/*
+ * "filegen" modifier keywords
+ */
+#define CONF_FGEN_FILE         1
+#define CONF_FGEN_TYPE         2
+#define CONF_FGEN_FLAG_LINK    3
+#define CONF_FGEN_FLAG_NOLINK  4
+#define CONF_FGEN_FLAG_ENABLE  5
+#define CONF_FGEN_FLAG_DISABLE 6
+
+/*
+ * "discard" modifier keywords
+ */
+#define CONF_DISCARD_AVERAGE   1
+#define CONF_DISCARD_MINIMUM   2
+#define        CONF_DISCARD_MONITOR    3
+
+/*
+ * "tinker" modifier keywords
+ */
+#define CONF_CLOCK_MAX         1
+#define CONF_CLOCK_PANIC       2
+#define CONF_CLOCK_PHI         3
+#define CONF_CLOCK_MINSTEP     4
+#define CONF_CLOCK_ALLAN       5
+#define CONF_CLOCK_HUFFPUFF    6
+#define CONF_CLOCK_FREQ                7
+
+/*
+ * "tos" modifier keywords
+ */
+#define CONF_TOS_MINCLOCK      1
+#define        CONF_TOS_MAXCLOCK       2
+#define CONF_TOS_MINSANE       3
+#define CONF_TOS_FLOOR         4
+#define CONF_TOS_CEILING       5
+#define CONF_TOS_COHORT                6
+#define CONF_TOS_MINDISP       7
+#define CONF_TOS_MAXDIST       8
+#define        CONF_TOS_MAXHOP         9
+#define        CONF_TOS_BEACON         10
+#define        CONF_TOS_ORPHAN         11
+
+#ifdef OPENSSL
+/*
+ * "crypto" modifier keywords
+ */
+#define        CONF_CRYPTO_RSA         1       
+#define        CONF_CRYPTO_SIGN        2
+#define CONF_CRYPTO_LEAP       3
+#define CONF_CRYPTO_CERT       4
+#define CONF_CRYPTO_RAND       5
+#define CONF_CRYPTO_KEYS       6
+#define        CONF_CRYPTO_IDENT       7
+#define        CONF_CRYPTO_IFFPAR      8
+#define CONF_CRYPTO_GQPAR      9
+#define CONF_CRYPTO_MVPAR      10
+#define CONF_CRYPTO_PW         11
+#endif /* OPENSSL */
+
+/*
+ * Address selection, IPv4 or IPv6
+ */
+#define        CONF_ADDR_IPV4          1
+#define        CONF_ADDR_IPV6          2
diff --git a/include/ntp_control.h b/include/ntp_control.h
new file mode 100644 (file)
index 0000000..c299794
--- /dev/null
@@ -0,0 +1,287 @@
+/*
+ * ntp_control.h - definitions related to NTP mode 6 control messages
+ */
+
+#include "ntp_types.h"
+
+struct ntp_control {
+       u_char li_vn_mode;              /* leap, version, mode */
+       u_char r_m_e_op;                /* response, more, error, opcode */
+       u_short sequence;               /* sequence number of request */
+       u_short status;                 /* status word for association */
+       associd_t associd;              /* association ID */
+       u_short offset;                 /* offset of this batch of data */
+       u_short count;                  /* count of data in this packet */
+       u_char data[(480 + MAX_MAC_LEN)]; /* data + auth */
+};
+
+/*
+ * Length of the control header, in octets
+ */
+#define        CTL_HEADER_LEN          12
+#define        CTL_MAX_DATA_LEN        468
+
+
+/*
+ * Limits and things
+ */
+#define        CTL_MAXTRAPS    3               /* maximum number of traps we allow */
+#define        CTL_TRAPTIME    (60*60)         /* time out traps in 1 hour */
+#define        CTL_MAXAUTHSIZE 64              /* maximum size of an authen'ed req */
+
+/*
+ * Decoding for the r_m_e_op field
+ */
+#define        CTL_RESPONSE    0x80
+#define        CTL_ERROR       0x40
+#define        CTL_MORE        0x20
+#define        CTL_OP_MASK     0x1f
+
+#define        CTL_ISRESPONSE(r_m_e_op)        (((r_m_e_op) & 0x80) != 0)
+#define        CTL_ISMORE(r_m_e_op)    (((r_m_e_op) & 0x20) != 0)
+#define        CTL_ISERROR(r_m_e_op)   (((r_m_e_op) & 0x40) != 0)
+#define        CTL_OP(r_m_e_op)        ((r_m_e_op) & CTL_OP_MASK)
+
+/*
+ * Opcodes
+ */
+#define        CTL_OP_UNSPEC           0
+#define        CTL_OP_READSTAT         1
+#define        CTL_OP_READVAR          2
+#define        CTL_OP_WRITEVAR         3
+#define        CTL_OP_READCLOCK        4
+#define        CTL_OP_WRITECLOCK       5
+#define        CTL_OP_SETTRAP          6
+#define        CTL_OP_ASYNCMSG         7
+#define        CTL_OP_UNSETTRAP        31
+
+/*
+ * {En,De}coding of the system status word
+ */
+#define        CTL_SST_TS_UNSPEC       0       /* time source unspecified */
+#define        CTL_SST_TS_ATOM         1       /* time source calibrated atomic */
+#define        CTL_SST_TS_LF           2       /* time source VLF or LF radio */
+#define        CTL_SST_TS_HF           3       /* time source HF radio */
+#define        CTL_SST_TS_UHF          4       /* time source UHF radio */
+#define        CTL_SST_TS_LOCAL        5       /* time source LOCAL */
+#define        CTL_SST_TS_NTP          6       /* time source NTP */
+#define        CTL_SST_TS_UDPTIME      7       /* time source UDP/TIME */
+#define        CTL_SST_TS_WRSTWTCH     8       /* time source is wristwatch */
+#define        CTL_SST_TS_TELEPHONE    9       /* time source is telephone modem */
+#define CTL_SST_TS_PPS         0x20    /* time source is PPS signal */
+
+#define        CTL_SYS_MAXEVENTS       15
+
+#define        CTL_SYS_STATUS(li, source, nevnt, evnt) \
+               (((((unsigned short)(li))<< 14)&0xc000) | \
+               (((source)<<8)&0x3f00) | \
+               (((nevnt)<<4)&0x00f0) | \
+               ((evnt)&0x000f))
+
+#define        CTL_SYS_LI(status)      (((status)>>14) & 0x3)
+#define        CTL_SYS_SOURCE(status)  (((status)>>8) & 0x3f)
+#define        CTL_SYS_NEVNT(status)   (((status)>>4) & 0xf)
+#define        CTL_SYS_EVENT(status)   ((status) & 0xf)
+
+/*
+ * {En,De}coding of the peer status word
+ */
+#define        CTL_PST_CONFIG          0x80
+#define        CTL_PST_AUTHENABLE      0x40
+#define        CTL_PST_AUTHENTIC       0x20
+#define        CTL_PST_REACH           0x10
+#define        CTL_PST_UNSPEC          0x08
+
+#define        CTL_PST_SEL_REJECT      0       /*   reject */
+#define        CTL_PST_SEL_SANE        1       /* x falsetick */
+#define        CTL_PST_SEL_CORRECT     2       /* . excess */
+#define        CTL_PST_SEL_SELCAND     3       /* - outlyer */
+#define        CTL_PST_SEL_SYNCCAND    4       /* + candidat */
+#define        CTL_PST_SEL_DISTSYSPEER 5       /* # selected */
+#define        CTL_PST_SEL_SYSPEER     6       /* * sys.peer */
+#define        CTL_PST_SEL_PPS         7       /* o pps.peer */
+
+#define        CTL_PEER_MAXEVENTS      15
+
+#define        CTL_PEER_STATUS(status, nevnt, evnt) \
+               ((((status)<<8) & 0xff00) | \
+               (((nevnt)<<4) & 0x00f0) | \
+               ((evnt) & 0x000f))
+
+#define        CTL_PEER_STATVAL(status)(((status)>>8) & 0xff)
+#define        CTL_PEER_NEVNT(status)  (((status)>>4) & 0xf)
+#define        CTL_PEER_EVENT(status)  ((status) & 0xf)
+
+/*
+ * {En,De}coding of the clock status word
+ */
+#define        CTL_CLK_OKAY            0
+#define        CTL_CLK_NOREPLY         1
+#define        CTL_CLK_BADFORMAT       2
+#define        CTL_CLK_FAULT           3
+#define        CTL_CLK_PROPAGATION     4
+#define        CTL_CLK_BADDATE         5
+#define        CTL_CLK_BADTIME         6
+
+#define        CTL_CLK_STATUS(status, event) \
+               ((((status)<<8) & 0xff00) | \
+               ((event) & 0x00ff))
+
+/*
+ * Error code responses returned when the E bit is set.
+ */
+#define        CERR_UNSPEC     0
+#define        CERR_PERMISSION 1
+#define        CERR_BADFMT     2
+#define        CERR_BADOP      3
+#define        CERR_BADASSOC   4
+#define        CERR_UNKNOWNVAR 5
+#define        CERR_BADVALUE   6
+#define        CERR_RESTRICT   7
+
+#define        CERR_NORESOURCE CERR_PERMISSION /* wish there was a different code */
+
+
+/*
+ * System variables we understand
+ */
+#define        CS_LEAP         1
+#define        CS_STRATUM      2
+#define        CS_PRECISION    3
+#define        CS_ROOTDELAY    4
+#define        CS_ROOTDISPERSION       5
+#define        CS_REFID        6
+#define        CS_REFTIME      7
+#define        CS_POLL         8
+#define        CS_PEERID       9
+#define CS_STATE       10
+#define        CS_OFFSET       11
+#define        CS_DRIFT        12
+#define CS_JITTER      13
+#define CS_ERROR       14
+#define        CS_CLOCK        15
+#define        CS_PROCESSOR    16
+#define        CS_SYSTEM       17
+#define CS_VERSION     18
+#define        CS_STABIL       19
+#define CS_VARLIST     20
+#ifdef OPENSSL
+#define CS_FLAGS       21
+#define CS_HOST                22
+#define CS_PUBLIC      23
+#define        CS_CERTIF       24
+#define        CS_REVTIME      25
+#define CS_LEAPTAB     26
+#define CS_TAI         27
+#define        CS_DIGEST       28
+#define CS_IDENT       29
+#define        CS_REVOKE       30
+#define        CS_MAXCODE      CS_REVOKE
+#else
+#define        CS_MAXCODE      CS_VARLIST
+#endif /* OPENSSL */
+
+/*
+ * Peer variables we understand
+ */
+#define        CP_CONFIG       1
+#define        CP_AUTHENABLE   2
+#define        CP_AUTHENTIC    3
+#define        CP_SRCADR       4
+#define        CP_SRCPORT      5
+#define        CP_DSTADR       6
+#define        CP_DSTPORT      7
+#define        CP_LEAP         8
+#define        CP_HMODE        9
+#define        CP_STRATUM      10
+#define        CP_PPOLL        11
+#define        CP_HPOLL        12
+#define        CP_PRECISION    13
+#define        CP_ROOTDELAY    14
+#define        CP_ROOTDISPERSION       15
+#define        CP_REFID        16
+#define        CP_REFTIME      17
+#define        CP_ORG          18
+#define        CP_REC          19
+#define        CP_XMT          20
+#define        CP_REACH        21
+#define        CP_UNREACH      22
+#define        CP_TIMER        23
+#define        CP_DELAY        24
+#define        CP_OFFSET       25
+#define CP_JITTER      26
+#define        CP_DISPERSION   27
+#define        CP_KEYID        28
+#define        CP_FILTDELAY    29
+#define        CP_FILTOFFSET   30
+#define        CP_PMODE        31
+#define        CP_RECEIVED     32
+#define        CP_SENT         33
+#define        CP_FILTERROR    34
+#define        CP_FLASH        35
+#define CP_TTL         36
+#define CP_VARLIST     37
+#ifdef OPENSSL
+#define CP_FLAGS       38
+#define CP_HOST                39
+#define CP_VALID       40
+#define        CP_INITSEQ      41
+#define        CP_INITKEY      42
+#define        CP_INITTSP      43
+#define        CP_DIGEST       44
+#define CP_IDENT       45
+#define        CP_MAXCODE      CP_IDENT
+#else
+#define        CP_MAXCODE      CP_VARLIST
+#endif /* OPENSSL */
+
+/*
+ * Clock variables we understand
+ */
+#define        CC_TYPE         1
+#define        CC_TIMECODE     2
+#define        CC_POLL         3
+#define        CC_NOREPLY      4
+#define        CC_BADFORMAT    5
+#define        CC_BADDATA      6
+#define        CC_FUDGETIME1   7
+#define        CC_FUDGETIME2   8
+#define        CC_FUDGEVAL1    9
+#define        CC_FUDGEVAL2    10
+#define        CC_FLAGS        11
+#define        CC_DEVICE       12
+#define CC_VARLIST     13
+
+#define        CC_MAXCODE      CC_VARLIST
+
+/*
+ * Definition of the structure used internally to hold trap information.
+ * ntp_request.c wants to see this.
+ */
+struct ctl_trap {
+       struct sockaddr_storage tr_addr;/* address of trap recipient */
+       struct interface *tr_localaddr; /* interface to send this through */
+       u_long tr_settime;              /* time trap was set */
+       u_long tr_count;                /* async messages sent to this guy */
+       u_long tr_origtime;             /* time trap was originally set */
+       u_long tr_resets;               /* count of resets for this trap */
+       u_short tr_sequence;            /* trap sequence id */
+       u_char tr_flags;                /* trap flags */
+       u_char tr_version;              /* version number of trapper */
+};
+extern struct ctl_trap ctl_trap[];
+
+/*
+ * Flag bits
+ */
+#define        TRAP_INUSE      0x1             /* this trap is active */
+#define        TRAP_NONPRIO    0x2             /* this trap is non-priority */
+#define        TRAP_CONFIGURED 0x4             /* this trap was configured */
+
+/*
+ * Types of things we may deal with
+ * shared between ntpq and library
+ */
+#define        TYPE_SYS        1
+#define        TYPE_PEER       2
+#define        TYPE_CLOCK      3
diff --git a/include/ntp_crypto.h b/include/ntp_crypto.h
new file mode 100644 (file)
index 0000000..14795e7
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * ntp_crypto.h - definitions for cryptographic operations
+ */
+#ifdef OPENSSL
+#include "openssl/evp.h"
+/*
+ * The following bits are set by the CRYPTO_ASSOC message from
+ * the server and are not modified by the client.
+ */
+#define CRYPTO_FLAG_ENAB  0x0001 /* crypto enable */
+#define CRYPTO_FLAG_TAI   0x0002 /* leapseconds table */
+
+#define CRYPTO_FLAG_PRIV  0x0010 /* PC identity scheme */
+#define CRYPTO_FLAG_IFF   0x0020 /* IFF identity scheme */
+#define CRYPTO_FLAG_GQ   0x0040 /* GQ identity scheme */
+#define        CRYPTO_FLAG_MV    0x0080 /* MV identity scheme */
+#define CRYPTO_FLAG_MASK  0x00f0 /* identity scheme mask */
+       
+/*
+ * The following bits are used by the client during the protocol
+ * exchange.
+ */
+#define CRYPTO_FLAG_VALID 0x0100 /* public key verified */
+#define CRYPTO_FLAG_VRFY  0x0200 /* identity verified */
+#define CRYPTO_FLAG_PROV  0x0400 /* signature verified */
+#define CRYPTO_FLAG_AGREE 0x0800 /* cookie verifed */
+#define CRYPTO_FLAG_AUTO  0x1000 /* autokey verified */
+#define CRYPTO_FLAG_SIGN  0x2000 /* certificate signed */
+#define CRYPTO_FLAG_LEAP  0x4000 /* leapseconds table verified */
+
+/*
+ * Flags used for certificate management
+ */
+#define        CERT_TRUST      0x01    /* certificate is trusted */
+#define CERT_SIGN      0x02    /* certificate is signed */
+#define CERT_VALID     0x04    /* certificate is valid */
+#define CERT_PRIV      0x08    /* certificate is private */
+#define CERT_ERROR     0x80    /* certificate has errors */
+
+/*
+ * Extension field definitions
+ */
+#define        CRYPTO_MAXLEN   1024    /* max extension field length */
+#define CRYPTO_VN      2       /* current protocol version number */
+#define CRYPTO_CMD(x)  (((CRYPTO_VN << 8) | (x)) << 16)
+#define CRYPTO_NULL    CRYPTO_CMD(0) /* no operation */
+#define CRYPTO_ASSOC   CRYPTO_CMD(1) /* association */
+#define CRYPTO_CERT    CRYPTO_CMD(2) /* certificate */
+#define CRYPTO_COOK    CRYPTO_CMD(3) /* cookie value */
+#define CRYPTO_AUTO    CRYPTO_CMD(4) /* autokey values */
+#define CRYPTO_TAI     CRYPTO_CMD(5) /* leapseconds table */
+#define        CRYPTO_SIGN     CRYPTO_CMD(6) /* certificate sign */
+#define CRYPTO_IFF     CRYPTO_CMD(7) /* IFF identity scheme */
+#define CRYPTO_GQ      CRYPTO_CMD(8) /* GQ identity scheme */
+#define        CRYPTO_MV       CRYPTO_CMD(9) /* MV identity scheme */
+#define CRYPTO_RESP    0x80000000 /* response */
+#define CRYPTO_ERROR   0x40000000 /* error */
+
+/*
+ * Autokey event codes
+ */
+#define XEVNT_CMD(x)   (CRPT_EVENT | (x))
+#define XEVNT_OK       XEVNT_CMD(0) /* success */
+#define XEVNT_LEN      XEVNT_CMD(1) /* bad field format or length */
+#define XEVNT_TSP      XEVNT_CMD(2) /* bad timestamp */
+#define XEVNT_FSP      XEVNT_CMD(3) /* bad filestamp */
+#define XEVNT_PUB      XEVNT_CMD(4) /* bad or missing public key */
+#define XEVNT_MD       XEVNT_CMD(5) /* unsupported digest type */
+#define XEVNT_KEY      XEVNT_CMD(6) /* unsupported identity type */
+#define XEVNT_SGL      XEVNT_CMD(7) /* bad signature length */
+#define XEVNT_SIG      XEVNT_CMD(8) /* signature not verified */
+#define XEVNT_VFY      XEVNT_CMD(9) /* certificate not verified */
+#define XEVNT_PER      XEVNT_CMD(10) /* host certificate expired */
+#define XEVNT_CKY      XEVNT_CMD(11) /* bad or missing cookie */
+#define XEVNT_DAT      XEVNT_CMD(12) /* bad or missing leapseconds table */
+#define XEVNT_CRT      XEVNT_CMD(13) /* bad or missing certificate */
+#define XEVNT_ID       XEVNT_CMD(14) /* bad or missing group key */
+#define        XEVNT_ERR       XEVNT_CMD(15) /* protocol error */
+#define        XEVNT_SRV       XEVNT_CMD(16) /* server certificate expired */
+
+/*
+ * Configuration codes
+ */
+#define CRYPTO_CONF_NONE  0    /* nothing doing */
+#define CRYPTO_CONF_PRIV  1    /* host keys file name */
+#define CRYPTO_CONF_SIGN  2    /* signature keys file name */
+#define CRYPTO_CONF_LEAP  3    /* leapseconds table file name */
+#define CRYPTO_CONF_KEYS  4    /* keys directory path */
+#define CRYPTO_CONF_CERT  5    /* certificate file name */
+#define CRYPTO_CONF_RAND  6    /* random seed file name */
+#define        CRYPTO_CONF_TRST  7     /* specify trust */
+#define CRYPTO_CONF_IFFPAR 8   /* IFF parameters file name */
+#define CRYPTO_CONF_GQPAR 9    /* GQ parameters file name */
+#define        CRYPTO_CONF_MVPAR 10    /* GQ parameters file name */
+#define CRYPTO_CONF_PW   11    /* private key password */
+#define        CRYPTO_CONF_IDENT 12    /* specify identity scheme */
+
+/*
+ * Miscellaneous crypto stuff
+ */
+#define NTP_MAXSESSION 100     /* maximum session key list entries */
+#define NTP_AUTOMAX    13      /* log2 default max session key life */
+#define KEY_REVOKE     16      /* log2 default key revoke timeout */
+#define NTP_MAXEXTEN   1024    /* maximum extension field size */
+#define        TAI_1972        10      /* initial TAI offset (s) */
+
+/*
+ * The autokey structure holds the values used to authenticate key IDs.
+ */
+struct autokey {               /* network byte order */
+       keyid_t key;            /* key ID */
+       int32   seq;            /* key number */
+};
+
+/*
+ * The value structure holds variable length data such as public
+ * key, agreement parameters, public valule and leapsecond table.
+ * They are in network byte order.
+ */
+struct value {                 /* network byte order */
+       tstamp_t tstamp;        /* timestamp */
+       tstamp_t fstamp;        /* filestamp */
+       u_int32 vallen;         /* value length */
+       u_char  *ptr;           /* data pointer (various) */
+       u_int32 siglen;         /* signature length */
+       u_char  *sig;           /* signature */
+};
+
+/*
+ * The packet extension field structures are used to hold values
+ * and signatures in network byte order.
+ */
+struct exten {
+       u_int32 opcode;         /* opcode */
+       u_int32 associd;        /* association ID */
+       u_int32 tstamp;         /* timestamp */
+       u_int32 fstamp;         /* filestamp */
+       u_int32 vallen;         /* value length */
+       u_int32 pkt[1];         /* start of value field */
+};
+
+/*
+ * The certificate info/value structure
+ */
+struct cert_info {
+       struct cert_info *link; /* forward link */
+       u_int   flags;          /* flags that wave */
+       EVP_PKEY *pkey;         /* generic key */
+       long    version;        /* X509 version */
+       int     nid;            /* signature/digest ID */
+       const EVP_MD *digest;   /* message digest algorithm */
+       u_long  serial;         /* serial number */
+       tstamp_t first;         /* not valid before */
+       tstamp_t last;          /* not valid after */
+       char    *subject;       /* subject common name */
+       char    *issuer;        /* issuer common name */
+       u_char  *grpkey;        /* GQ group key */
+       u_int   grplen;         /* GQ group key length */
+       struct value cert;      /* certificate/value */
+};
+
+/*
+ * Cryptographic values
+ */
+extern char    *keysdir;       /* crypto keys directory */
+extern u_int   crypto_flags;   /* status word */
+extern struct value hostval;   /* host name/value */
+extern struct cert_info *cinfo; /* host certificate information */
+extern struct value tai_leap;  /* leapseconds table */
+#endif /* OPENSSL */
diff --git a/include/ntp_datum.h b/include/ntp_datum.h
new file mode 100644 (file)
index 0000000..2aa2cb7
--- /dev/null
@@ -0,0 +1,30 @@
+struct btfp_time                /* Structure for reading 5 time words   */
+                                /* in one ioctl(2) operation.           */
+{
+  unsigned short btfp_time[5];  /* Time words 0,1,2,3, and 4. (16bit)*/
+};
+
+/***** Simple ioctl commands *****/
+
+#define RUNLOCK   _IO('X',19)                   /* Release Capture Lockout */
+#define RCR0      _IOR('X',22,unsigned int)     /* Read control register */
+#define WCR0      _IOW('X',23,unsigned int)     /* Write control register */
+
+/***** Compound ioctl commands *****/
+
+/* Read all 5 time words in one call.   */
+#define READTIME        _IOR('X',32,struct btfp_time)
+#define VMEFD "/dev/btfp0"
+
+ struct vmedate {               /* structure returned by get_vmetime.c */
+         unsigned short year;
+         unsigned short doy;
+         unsigned short hr;
+         unsigned short mn;
+         unsigned short sec;
+         unsigned long frac;
+         unsigned short status;
+         };
+
+#define PRIO    120               /* set the realtime priority */
+#define NREGS 7                    /* number of registers we will use */
diff --git a/include/ntp_debug.h b/include/ntp_debug.h
new file mode 100644 (file)
index 0000000..55b2e1a
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * $Header$
+ *
+ * $Created: Sat Aug 20 14:23:01 2005 $
+ *
+ * Copyright (C) 2005 by Frank Kardel
+ */
+#ifndef NTP_DEBUG_H
+#define NTP_DEBUG_H
+
+/*
+ * macros for debugging output - cut down on #ifdef pollution in the code
+ */
+
+#ifdef DEBUG
+#define DPRINTF(_lvl_, _arg_)                          \
+       do {                                            \
+               if (debug >= (_lvl_))                   \
+                       printf _arg_;                   \
+       } while (0)
+#else
+#define DPRINTF(_lvl_, _arg_)  do {} while (0)
+#endif
+
+#endif
+/*
+ * $Log$
+ */
diff --git a/include/ntp_filegen.h b/include/ntp_filegen.h
new file mode 100644 (file)
index 0000000..836ec04
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * ntp_filegen.h,v 3.9 1996/12/01 16:02:45 kardel Exp
+ *
+ * definitions for NTP file generations support
+ *
+ *
+ * Copyright (C) 1992, 1996 by Rainer Pruy
+ * Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * This code may be modified and used freely
+ * provided the credits remain intact.
+ */
+
+#include "ntp_types.h"
+
+/*
+ * supported file generation types
+ */
+
+#define FILEGEN_NONE   255     /* no generations - use plain file name */
+#define FILEGEN_PID    1       /* one filegen per process incarnation */
+#define FILEGEN_DAY    2       /* one filegen per day */
+#define FILEGEN_WEEK   3       /* one filegen per week */
+#define FILEGEN_MONTH  4       /* one filegen per month */
+#define FILEGEN_YEAR   5       /* one filegen per year */
+#define FILEGEN_AGE     6      /* change filegen each FG_AGE_SECS */
+
+/*
+ * supported file generation flags
+ */
+
+#define FGEN_FLAG_LINK         0x01 /* make a link to base name */
+
+#define FGEN_FLAG_ENABLED      0x80 /* set this to really create files   */
+                                    /* without this, open is suppressed */
+
+typedef struct FILEGEN
+        {
+         FILE   *fp;           /* file referring to current generation */
+         char   *prefix;       /* filename prefix and basename to be used*/
+         char   *basename;     /* for constructing filename of generation file */
+                               /* WARNING: must be malloced !!! will be fed to free()*/
+         u_long  id;           /* id of current generation */
+         u_char  type;         /* type of file generation */
+         u_char  flag;         /* flags modifying processing of file generation */
+       }       FILEGEN;
+
+extern void    filegen_setup   P((FILEGEN *, u_long));
+extern void    filegen_config  P((FILEGEN *, char *, u_int, u_int));
+extern FILEGEN *filegen_get    P((char *));
+extern void    filegen_register P((char *, const char *, FILEGEN *));
diff --git a/include/ntp_fp.h b/include/ntp_fp.h
new file mode 100644 (file)
index 0000000..307ab10
--- /dev/null
@@ -0,0 +1,379 @@
+/*
+ * ntp_fp.h - definitions for NTP fixed/floating-point arithmetic
+ */
+
+#ifndef NTP_FP_H
+#define NTP_FP_H
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include "ntp_rfc2553.h"
+
+#include "ntp_types.h"
+
+/*
+ * NTP uses two fixed point formats.  The first (l_fp) is the "long"
+ * format and is 64 bits long with the decimal between bits 31 and 32.
+ * This is used for time stamps in the NTP packet header (in network
+ * byte order) and for internal computations of offsets (in local host
+ * byte order). We use the same structure for both signed and unsigned
+ * values, which is a big hack but saves rewriting all the operators
+ * twice. Just to confuse this, we also sometimes just carry the
+ * fractional part in calculations, in both signed and unsigned forms.
+ * Anyway, an l_fp looks like:
+ *
+ *    0                          1                   2                   3
+ *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                        Integral Part                         |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                        Fractional Part                       |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ */
+typedef struct {
+       union {
+               u_int32 Xl_ui;
+               int32 Xl_i;
+       } Ul_i;
+       union {
+               u_int32 Xl_uf;
+               int32 Xl_f;
+       } Ul_f;
+} l_fp;
+
+#define l_ui   Ul_i.Xl_ui              /* unsigned integral part */
+#define        l_i     Ul_i.Xl_i               /* signed integral part */
+#define        l_uf    Ul_f.Xl_uf              /* unsigned fractional part */
+#define        l_f     Ul_f.Xl_f               /* signed fractional part */
+
+/*
+ * Fractional precision (of an l_fp) is actually the number of
+ * bits in a long.
+ */
+#define        FRACTION_PREC   (32)
+
+
+/*
+ * The second fixed point format is 32 bits, with the decimal between
+ * bits 15 and 16.  There is a signed version (s_fp) and an unsigned
+ * version (u_fp).  This is used to represent synchronizing distance
+ * and synchronizing dispersion in the NTP packet header (again, in
+ * network byte order) and internally to hold both distance and
+ * dispersion values (in local byte order).  In network byte order
+ * it looks like:
+ *
+ *    0                          1                   2                   3
+ *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |           Integer Part       |     Fraction Part             |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ */
+typedef int32 s_fp;
+typedef u_int32 u_fp;
+
+/*
+ * A unit second in fp format.  Actually 2**(half_the_bits_in_a_long)
+ */
+#define        FP_SECOND       (0x10000)
+
+/*
+ * Byte order conversions
+ */
+#define        HTONS_FP(x)     (htonl(x))
+#define        HTONL_FP(h, n)  do { (n)->l_ui = htonl((h)->l_ui); \
+                            (n)->l_uf = htonl((h)->l_uf); } while (0)
+#define        NTOHS_FP(x)     (ntohl(x))
+#define        NTOHL_FP(n, h)  do { (h)->l_ui = ntohl((n)->l_ui); \
+                            (h)->l_uf = ntohl((n)->l_uf); } while (0)
+#define        NTOHL_MFP(ni, nf, hi, hf) \
+       do { (hi) = ntohl(ni); (hf) = ntohl(nf); } while (0)
+#define        HTONL_MFP(hi, hf, ni, nf) \
+       do { (ni) = ntohl(hi); (nf) = ntohl(hf); } while (0)
+
+/* funny ones.  Converts ts fractions to net order ts */
+#define        HTONL_UF(uf, nts) \
+       do { (nts)->l_ui = 0; (nts)->l_uf = htonl(uf); } while (0)
+#define        HTONL_F(f, nts) do { (nts)->l_uf = htonl(f); \
+                               if ((f) & 0x80000000) \
+                                       (nts)->l_i = -1; \
+                               else \
+                                       (nts)->l_i = 0; \
+                       } while (0)
+
+/*
+ * Conversions between the two fixed point types
+ */
+#define        MFPTOFP(x_i, x_f)       (((x_i) >= 0x00010000) ? 0x7fffffff : \
+                               (((x_i) <= -0x00010000) ? 0x80000000 : \
+                               (((x_i)<<16) | (((x_f)>>16)&0xffff))))
+#define        LFPTOFP(v)              MFPTOFP((v)->l_i, (v)->l_f)
+
+#define UFPTOLFP(x, v) ((v)->l_ui = (u_fp)(x)>>16, (v)->l_uf = (x)<<16)
+#define FPTOLFP(x, v)  (UFPTOLFP((x), (v)), (x) < 0 ? (v)->l_ui -= 0x10000 : 0)
+
+#define MAXLFP(v) ((v)->l_ui = 0x7fffffff, (v)->l_uf = 0xffffffff)
+#define MINLFP(v) ((v)->l_ui = 0x80000000, (v)->l_uf = 0)
+
+/*
+ * Primitive operations on long fixed point values.  If these are
+ * reminiscent of assembler op codes it's only because some may
+ * be replaced by inline assembler for particular machines someday.
+ * These are the (kind of inefficient) run-anywhere versions.
+ */
+#define        M_NEG(v_i, v_f)         /* v = -v */ \
+       do { \
+               if ((v_f) == 0) \
+                       (v_i) = -((s_fp)(v_i)); \
+               else { \
+                       (v_f) = -((s_fp)(v_f)); \
+                       (v_i) = ~(v_i); \
+               } \
+       } while(0)
+
+#define        M_NEGM(r_i, r_f, a_i, a_f)      /* r = -a */ \
+       do { \
+               if ((a_f) == 0) { \
+                       (r_f) = 0; \
+                       (r_i) = -(a_i); \
+               } else { \
+                       (r_f) = -(a_f); \
+                       (r_i) = ~(a_i); \
+               } \
+       } while(0)
+
+#define M_ADD(r_i, r_f, a_i, a_f)      /* r += a */ \
+       do { \
+               register u_int32 lo_tmp; \
+               register u_int32 hi_tmp; \
+               \
+               lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \
+               hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \
+               if (lo_tmp & 0x10000) \
+                       hi_tmp++; \
+               (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
+               \
+               (r_i) += (a_i); \
+               if (hi_tmp & 0x10000) \
+                       (r_i)++; \
+       } while (0)
+
+#define M_ADD3(r_ovr, r_i, r_f, a_ovr, a_i, a_f) /* r += a, three word */ \
+       do { \
+               register u_int32 lo_tmp; \
+               register u_int32 hi_tmp; \
+               \
+               lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \
+               hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \
+               if (lo_tmp & 0x10000) \
+                       hi_tmp++; \
+               (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
+               \
+               lo_tmp = ((r_i) & 0xffff) + ((a_i) & 0xffff); \
+               if (hi_tmp & 0x10000) \
+                       lo_tmp++; \
+               hi_tmp = (((r_i) >> 16) & 0xffff) + (((a_i) >> 16) & 0xffff); \
+               if (lo_tmp & 0x10000) \
+                       hi_tmp++; \
+               (r_i) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
+               \
+               (r_ovr) += (a_ovr); \
+               if (hi_tmp & 0x10000) \
+                       (r_ovr)++; \
+       } while (0)
+
+#define M_SUB(r_i, r_f, a_i, a_f)      /* r -= a */ \
+       do { \
+               register u_int32 lo_tmp; \
+               register u_int32 hi_tmp; \
+               \
+               if ((a_f) == 0) { \
+                       (r_i) -= (a_i); \
+               } else { \
+                       lo_tmp = ((r_f) & 0xffff) + ((-((s_fp)(a_f))) & 0xffff); \
+                       hi_tmp = (((r_f) >> 16) & 0xffff) \
+                           + (((-((s_fp)(a_f))) >> 16) & 0xffff); \
+                       if (lo_tmp & 0x10000) \
+                               hi_tmp++; \
+                       (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
+                       \
+                       (r_i) += ~(a_i); \
+                       if (hi_tmp & 0x10000) \
+                               (r_i)++; \
+               } \
+       } while (0)
+
+#define        M_RSHIFTU(v_i, v_f)             /* v >>= 1, v is unsigned */ \
+       do { \
+               (v_f) = (u_int32)(v_f) >> 1; \
+               if ((v_i) & 01) \
+                       (v_f) |= 0x80000000; \
+               (v_i) = (u_int32)(v_i) >> 1; \
+       } while (0)
+
+#define        M_RSHIFT(v_i, v_f)              /* v >>= 1, v is signed */ \
+       do { \
+               (v_f) = (u_int32)(v_f) >> 1; \
+               if ((v_i) & 01) \
+                       (v_f) |= 0x80000000; \
+               if ((v_i) & 0x80000000) \
+                       (v_i) = ((v_i) >> 1) | 0x80000000; \
+               else \
+                       (v_i) = (v_i) >> 1; \
+       } while (0)
+
+#define        M_LSHIFT(v_i, v_f)              /* v <<= 1 */ \
+       do { \
+               (v_i) <<= 1; \
+               if ((v_f) & 0x80000000) \
+                       (v_i) |= 0x1; \
+               (v_f) <<= 1; \
+       } while (0)
+
+#define        M_LSHIFT3(v_ovr, v_i, v_f)      /* v <<= 1, with overflow */ \
+       do { \
+               (v_ovr) <<= 1; \
+               if ((v_i) & 0x80000000) \
+                       (v_ovr) |= 0x1; \
+               (v_i) <<= 1; \
+               if ((v_f) & 0x80000000) \
+                       (v_i) |= 0x1; \
+               (v_f) <<= 1; \
+       } while (0)
+
+#define        M_ADDUF(r_i, r_f, uf)           /* r += uf, uf is u_int32 fraction */ \
+       M_ADD((r_i), (r_f), 0, (uf))    /* let optimizer worry about it */
+
+#define        M_SUBUF(r_i, r_f, uf)           /* r -= uf, uf is u_int32 fraction */ \
+       M_SUB((r_i), (r_f), 0, (uf))    /* let optimizer worry about it */
+
+#define        M_ADDF(r_i, r_f, f)             /* r += f, f is a int32 fraction */ \
+       do { \
+               if ((f) > 0) \
+                       M_ADD((r_i), (r_f), 0, (f)); \
+               else if ((f) < 0) \
+                       M_ADD((r_i), (r_f), (-1), (f));\
+       } while(0)
+
+#define        M_ISNEG(v_i, v_f)               /* v < 0 */ \
+       (((v_i) & 0x80000000) != 0)
+
+#define        M_ISHIS(a_i, a_f, b_i, b_f)     /* a >= b unsigned */ \
+       (((u_int32)(a_i)) > ((u_int32)(b_i)) || \
+         ((a_i) == (b_i) && ((u_int32)(a_f)) >= ((u_int32)(b_f))))
+
+#define        M_ISGEQ(a_i, a_f, b_i, b_f)     /* a >= b signed */ \
+       (((int32)(a_i)) > ((int32)(b_i)) || \
+         ((a_i) == (b_i) && ((u_int32)(a_f)) >= ((u_int32)(b_f))))
+
+#define        M_ISEQU(a_i, a_f, b_i, b_f)     /* a == b unsigned */ \
+       ((a_i) == (b_i) && (a_f) == (b_f))
+
+/*
+ * Operations on the long fp format
+ */
+#define        L_ADD(r, a)     M_ADD((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
+#define        L_SUB(r, a)     M_SUB((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
+#define        L_NEG(v)        M_NEG((v)->l_ui, (v)->l_uf)
+#define L_ADDUF(r, uf) M_ADDUF((r)->l_ui, (r)->l_uf, (uf))
+#define L_SUBUF(r, uf) M_SUBUF((r)->l_ui, (r)->l_uf, (uf))
+#define        L_ADDF(r, f)    M_ADDF((r)->l_ui, (r)->l_uf, (f))
+#define        L_RSHIFT(v)     M_RSHIFT((v)->l_i, (v)->l_uf)
+#define        L_RSHIFTU(v)    M_RSHIFTU((v)->l_ui, (v)->l_uf)
+#define        L_LSHIFT(v)     M_LSHIFT((v)->l_ui, (v)->l_uf)
+#define        L_CLR(v)        ((v)->l_ui = (v)->l_uf = 0)
+
+#define        L_ISNEG(v)      (((v)->l_ui & 0x80000000) != 0)
+#define L_ISZERO(v)    ((v)->l_ui == 0 && (v)->l_uf == 0)
+#define        L_ISHIS(a, b)   ((a)->l_ui > (b)->l_ui || \
+                         ((a)->l_ui == (b)->l_ui && (a)->l_uf >= (b)->l_uf))
+#define        L_ISGEQ(a, b)   ((a)->l_i > (b)->l_i || \
+                         ((a)->l_i == (b)->l_i && (a)->l_uf >= (b)->l_uf))
+#define        L_ISEQU(a, b)   M_ISEQU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
+
+/*
+ * s_fp/double and u_fp/double conversions
+ */
+#define FRIC           65536.                  /* 2^16 as a double */
+#define DTOFP(r)       ((s_fp)((r) * FRIC))
+#define DTOUFP(r)      ((u_fp)((r) * FRIC))
+#define FPTOD(r)       ((double)(r) / FRIC)
+
+/*
+ * l_fp/double conversions
+ */
+#define FRAC           4294967296.             /* 2^32 as a double */
+#define M_DTOLFP(d, r_i, r_uf)                         /* double to l_fp */ \
+       do { \
+               register double d_tmp; \
+               \
+               d_tmp = (d); \
+               if (d_tmp < 0) { \
+                       d_tmp = -d_tmp; \
+                       (r_i) = (int32)(d_tmp); \
+                       (r_uf) = (u_int32)(((d_tmp) - (double)(r_i)) * FRAC); \
+                       M_NEG((r_i), (r_uf)); \
+               } else { \
+                       (r_i) = (int32)(d_tmp); \
+                       (r_uf) = (u_int32)(((d_tmp) - (double)(r_i)) * FRAC); \
+               } \
+       } while (0)
+#define M_LFPTOD(r_i, r_uf, d)                         /* l_fp to double */ \
+       do { \
+               register l_fp l_tmp; \
+               \
+               l_tmp.l_i = (r_i); \
+               l_tmp.l_f = (r_uf); \
+               if (l_tmp.l_i < 0) { \
+                       M_NEG(l_tmp.l_i, l_tmp.l_uf); \
+                       (d) = -((double)l_tmp.l_i + ((double)l_tmp.l_uf) / FRAC); \
+               } else { \
+                       (d) = (double)l_tmp.l_i + ((double)l_tmp.l_uf) / FRAC; \
+               } \
+       } while (0)
+#define DTOLFP(d, v)   M_DTOLFP((d), (v)->l_ui, (v)->l_uf)
+#define LFPTOD(v, d)   M_LFPTOD((v)->l_ui, (v)->l_uf, (d))
+
+/*
+ * Prototypes
+ */
+extern char *  dofptoa         P((u_fp, int, short, int));
+extern char *  dolfptoa        P((u_long, u_long, int, short, int));
+
+extern int     atolfp          P((const char *, l_fp *));
+extern int     buftvtots       P((const char *, l_fp *));
+extern char *  fptoa           P((s_fp, short));
+extern char *  fptoms          P((s_fp, short));
+extern int     hextolfp        P((const char *, l_fp *));
+extern  void    gpstolfp        P((int, int, unsigned long, l_fp *));
+extern int     mstolfp         P((const char *, l_fp *));
+extern char *  prettydate      P((l_fp *));
+extern char *  gmprettydate    P((l_fp *));
+extern char *  uglydate        P((l_fp *));
+extern  void    mfp_mul         P((int32 *, u_int32 *, int32, u_int32, int32, u_int32));
+
+extern void    get_systime     P((l_fp *));
+extern int     step_systime    P((double));
+extern int     adj_systime     P((double));
+
+extern struct tm * ntp2unix_tm P((u_long ntp, int local));
+
+#define        lfptoa(_fpv, _ndec)     mfptoa((_fpv)->l_ui, (_fpv)->l_uf, (_ndec))
+#define        lfptoms(_fpv, _ndec)    mfptoms((_fpv)->l_ui, (_fpv)->l_uf, (_ndec))
+
+#define stoa(_sin)     socktoa((_sin))
+#define stohost(_sin)  socktohost((_sin))
+
+#define        ntoa(_sin)      stoa(_sin)
+#define        ntohost(_sin)   stohost(_sin)
+
+#define        ufptoa(_fpv, _ndec)     dofptoa((_fpv), 0, (_ndec), 0)
+#define        ufptoms(_fpv, _ndec)    dofptoa((_fpv), 0, (_ndec), 1)
+#define        ulfptoa(_fpv, _ndec)    dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 0)
+#define        ulfptoms(_fpv, _ndec)   dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 1)
+#define        umfptoa(_fpi, _fpf, _ndec) dolfptoa((_fpi), (_fpf), 0, (_ndec), 0)
+
+#endif /* NTP_FP_H */
diff --git a/include/ntp_if.h b/include/ntp_if.h
new file mode 100644 (file)
index 0000000..3af5865
--- /dev/null
@@ -0,0 +1,27 @@
+/*
+ * Sockets are not standard.
+ * So hide uglyness in include file.
+ */
+/* was: defined(SYS_CONVEXOS9) */
+#if defined(HAVE__SYS_SYNC_QUEUE_H) && defined(HAVE__SYS_SYNC_SEMA_H)
+# include "/sys/sync/queue.h"
+# include "/sys/sync/sema.h"
+#endif
+
+/* was: (defined(SYS_SOLARIS) && !defined(bsd)) || defined(SYS_SUNOS4) */
+/* was: defined(SYS_UNIXWARE1) */
+#ifdef HAVE_SYS_SOCKIO_H
+# include <sys/sockio.h>
+#endif
+
+/* was: #if defined(SYS_PTX) || defined(SYS_SINIXM) */
+#ifdef HAVE_SYS_STREAM_H
+# include <sys/stream.h>
+#endif
+#ifdef HAVE_SYS_STROPTS_H
+# include <sys/stropts.h>
+#endif
+
+#ifdef HAVE_NET_IF_H
+# include <net/if.h>
+#endif /* HAVE_NET_IF_H */
diff --git a/include/ntp_io.h b/include/ntp_io.h
new file mode 100644 (file)
index 0000000..983c6c7
--- /dev/null
@@ -0,0 +1,50 @@
+#if !defined _NTP_IO_H
+#define _NTP_IO_H
+/*
+ * POSIX says use <fnct.h> to get O_* symbols and 
+ * SEEK_SET symbol form <unistd.h>.
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <stdio.h>
+#ifdef HAVE_SYS_FILE_H
+# include <sys/file.h>
+#endif
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#if !defined(SEEK_SET) && defined(L_SET)
+# define SEEK_SET L_SET
+#endif
+
+#ifdef SYS_WINNT
+# include <io.h>
+# include "win32_io.h"
+#endif
+
+/*
+ * Define FNDELAY and FASYNC using O_NONBLOCK and O_ASYNC if we need
+ * to (and can).  This is here initially for QNX, but may help for
+ * others as well...
+ */
+#ifndef FNDELAY
+# ifdef O_NONBLOCK
+#  define FNDELAY O_NONBLOCK
+# endif
+#endif
+
+#ifndef FASYNC
+# ifdef O_ASYNC
+#  define FASYNC O_ASYNC
+# endif
+#endif
+
+#endif
diff --git a/include/ntp_machine.h b/include/ntp_machine.h
new file mode 100644 (file)
index 0000000..2a3b6e6
--- /dev/null
@@ -0,0 +1,590 @@
+/*
+ * Collect all machine dependent idiosyncrasies in one place.
+ */
+
+#ifndef __ntp_machine
+#define __ntp_machine
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef TIME_WITH_SYS_TIME
+# include <sys/time.h>
+# include <time.h>
+#else
+# ifdef HAVE_SYS_TIME_H
+#  include <sys/time.h>
+# else
+#  include <time.h>
+# endif
+#endif
+
+#include "ntp_proto.h"
+
+/*
+
+                        HEY!  CHECK THIS OUT!
+
+  The first half of this file is obsolete, and is only there to help
+  reconcile "what went before" with "current behavior".
+
+  The per-system SYS_* #defins ARE NO LONGER USED, with the temporary
+  exception of SYS_WINNT.
+
+  If you find a hunk of code that is bracketed by a SYS_* macro and you
+  *know* that it is still needed, please let us know.  In many cases the
+  code fragment is now handled somewhere else by autoconf choices.
+
+*/
+
+/*
+
+INFO ON NEW KERNEL PLL SYS CALLS
+
+  NTP_SYSCALLS_STD     - use the "normal" ones
+  NTP_SYSCALL_GET      - SYS_ntp_gettime id
+  NTP_SYSCALL_ADJ      - SYS_ntp_adjtime id
+  NTP_SYSCALLS_LIBC - ntp_adjtime() and ntp_gettime() are in libc.
+
+HOW TO GET IP INTERFACE INFORMATION
+
+  Some UNIX V.4 machines implement a sockets library on top of
+  streams. For these systems, you must use send the SIOCGIFCONF down
+  the stream in an I_STR ioctl. This ususally also implies
+  USE_STREAMS_DEVICE FOR IF_CONFIG. Dell UNIX is a notable exception.
+
+WHAT DOES IOCTL(SIOCGIFCONF) RETURN IN THE BUFFER
+
+  UNIX V.4 machines implement a sockets library on top of streams.
+  When requesting the IP interface configuration with an ioctl(2) calll,
+  an array of ifreq structures are placed in the provided buffer.  Some
+  implementations also place the length of the buffer information in
+  the first integer position of the buffer.
+
+  SIZE_RETURNED_IN_BUFFER - size integer is in the buffer
+
+WILL IOCTL(SIOCGIFCONF) WORK ON A SOCKET
+
+  Some UNIX V.4 machines do not appear to support ioctl() requests for the
+  IP interface configuration on a socket.  They appear to require the use
+  of the streams device instead.
+
+  USE_STREAMS_DEVICE_FOR_IF_CONFIG - use the /dev/ip device for configuration
+
+MISC
+
+  HAVE_PROTOTYPES      - Prototype functions
+  DOSYNCTODR           - Resync TODR clock  every hour.
+  RETSIGTYPE           - Define signal function type.
+  NO_SIGNED_CHAR_DECL - No "signed char" see include/ntp.h
+  LOCK_PROCESS         - Have plock.
+*/
+
+/*
+ * Set up for prototyping (duplicated from ntp_types.h)
+ */
+#ifndef P
+#if defined(__STDC__) || defined(HAVE_PROTOTYPES)
+#define P(x)    x
+#else /* not __STDC__ and not HAVE_PROTOTYPES */
+#define P(x)    ()
+#endif /* not __STDC__ and not HAVE_PROTOTYPES */
+#endif /* P */
+
+#if !defined(HAVE_NTP_ADJTIME) && defined(HAVE___ADJTIMEX)
+# define ntp_adjtime __adjtimex
+#endif
+
+#if 0
+
+/*
+ * IRIX 4.X and IRIX 5.x
+ */
+#if defined(SYS_IRIX4)||defined(SYS_IRIX5)
+# define ADJTIME_IS_ACCURATE
+# define LOCK_PROCESS
+#endif
+
+/*
+ * Ultrix
+ * Note: posix version has NTP_POSIX_SOURCE and HAVE_SIGNALED_IO
+ */
+#if defined(SYS_ULTRIX)
+# define S_CHAR_DEFINED
+# define NTP_SYSCALLS_STD
+# define HAVE_MODEM_CONTROL
+#endif
+
+/*
+ * AUX
+ */
+#if defined(SYS_AUX2) || defined(SYS_AUX3)
+# define NO_SIGNED_CHAR_DECL
+# define LOCK_PROCESS
+# define NTP_POSIX_SOURCE
+/*
+ * This requires that _POSIX_SOURCE be forced on the
+ * compiler command flag. We can't do it here since this
+ * file is included _after_ the system header files and we
+ * need to let _them_ know we're POSIX. We do this in
+ * compilers/aux3.gcc...
+ */
+# define LOG_NTP LOG_LOCAL1
+#endif
+
+/*
+ * HPUX
+ */
+#if defined(SYS_HPUX)
+# define getdtablesize() sysconf(_SC_OPEN_MAX)
+# define setlinebuf(f) setvbuf(f, NULL, _IOLBF, 0)
+# define NO_SIGNED_CHAR_DECL
+# define LOCK_PROCESS
+#endif
+
+/*
+ * BSD/OS 2.0 and above
+ */
+#if defined(SYS_BSDI)
+# define USE_FSETOWNCTTY       /* this funny system demands a CTTY for FSETOWN */
+#endif
+
+/*
+ * FreeBSD 2.0 and above
+ */
+#ifdef SYS_FREEBSD
+# define KERNEL_PLL
+#endif
+
+/*
+ * Linux
+ */
+#if defined(SYS_LINUX)
+# define ntp_adjtime __adjtimex
+#endif
+
+/*
+ * PTX
+ */
+#if defined(SYS_PTX)
+# define LOCK_PROCESS
+struct timezone { int __0; };  /* unused placebo */
+/*
+ * no comment !@!
+ */
+typedef unsigned int u_int;
+# ifndef       _NETINET_IN_SYSTM_INCLUDED      /* i am about to comment... */
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned long u_long;
+# endif
+#endif
+
+/*
+ * UNIX V.4 on and NCR 3000
+ */
+#if defined(SYS_SVR4)
+# define STREAM
+# define LOCK_PROCESS
+# define SIZE_RETURNED_IN_BUFFER
+#endif
+
+/*
+ * (Univel/Novell) Unixware1 SVR4 on intel x86 processor
+ */
+#if defined(SYS_UNIXWARE1)
+/* #define _POSIX_SOURCE */
+# define STREAM
+# define STREAMS
+# undef STEP_SLEW              /* TWO step */
+# define LOCK_PROCESS
+# define SIZE_RETURNED_IN_BUFFER
+# include <sys/sockio.h>
+# include <sys/types.h>
+# include <netinet/in_systm.h>
+#endif
+
+/*
+ * DomainOS
+ */
+#if defined(SYS_DOMAINOS)
+# define NTP_SYSCALLS_STD
+/* older versions of domain/os don't have class D */
+# ifndef IN_CLASSD
+#  define IN_CLASSD(i)         (((long)(i) & 0xf0000000) == 0xe0000000)
+#  define IN_CLASSD_NET        0xf0000000
+#  define IN_CLASSD_NSHIFT     28
+#  define IN_CLASSD_HOST       0xfffffff
+#  define IN_MULTICAST(i)      IN_CLASSD(i)
+# endif
+#endif
+
+/*
+ * Fujitsu UXP/V
+ */
+#if defined(SYS_UXPV)
+# define LOCK_PROCESS
+# define SIZE_RETURNED_IN_BUFFER
+#endif
+
+
+#endif /* 0 */
+
+/*
+ * Define these here for non-Windows NT systems
+ * SOCKET and INVALID_SOCKET are native macros
+ * on Windows NT and since they have different
+ * requirements we use them in the code and
+ * make them macros for everyone else
+ */
+#ifndef SYS_WINNT
+# define SOCKET        int
+# define INVALID_SOCKET        -1
+# define SOCKET_ERROR  -1
+# define closesocket close
+#endif
+/*
+ * Windows NT
+ */
+#if defined(SYS_WINNT)
+# if !defined(HAVE_CONFIG_H)  || !defined(__config)
+# include <config.h>
+# endif /* HAVE_CONFIG_H) */
+# include <windows.h>
+# include <ws2tcpip.h>
+# include <winsock2.h>
+
+# define ifreq _INTERFACE_INFO
+# define ifr_flags iiFlags
+# define ifr_addr iiAddress.AddressIn
+# define ifr_broadaddr iiBroadcastAddress.AddressIn
+# define ifr_mask iiNetmask.AddressIn
+# define zz_family sin_family
+
+# define S_IFREG _S_IFREG
+# define stat _stat
+# define isascii __isascii
+# define isatty _isatty
+# define mktemp _mktemp
+# define unlink _unlink
+# define fileno _fileno
+# define write _write
+#ifndef close
+# define close _close
+#endif
+# undef interface
+# include <process.h>
+#define getpid _getpid
+/*
+ * Defining registers are not a good idea on Windows
+ * This gets rid of the usage
+ */
+#ifndef register
+# define register
+#endif
+ typedef char *caddr_t;
+# define vsnprintf _vsnprintf
+#endif /* SYS_WINNT */
+
+int ntp_set_tod P((struct timeval *tvp, void *tzp));
+
+#if defined (SYS_CYGWIN32)
+#include <windows.h>
+#define __int64 long long
+#endif
+
+/*casey Tue May 27 15:45:25 SAT 1997*/
+#ifdef SYS_VXWORKS
+
+/* casey's new defines */
+#define NO_MAIN_ALLOWED        1
+#define NO_NETDB                       1
+#define NO_RENAME                      1
+
+/* in vxWorks we use FIONBIO, but the others are defined for old systems, so
+ * all hell breaks loose if we leave them defined we define USE_FIONBIO to
+ * undefine O_NONBLOCK FNDELAY O_NDELAY where necessary.
+ */
+#define USE_FIONBIO            1
+/* end my new defines */
+
+#define TIMEOFDAY              0x0     /* system wide realtime clock */
+#define HAVE_GETCLOCK          1       /* configure does not set this ... */
+#define HAVE_NO_NICE           1       /* configure does not set this ... */
+#define HAVE_RANDOM            1       /* configure does not set this ...  */
+#define HAVE_SRANDOM           1       /* configure does not set this ... */
+
+#define NODETACH               1
+
+/* vxWorks specific additions to take care of its
+ * unix (non)complicance
+ */
+
+#include "vxWorks.h"
+#include "ioLib.h"
+#include "taskLib.h"
+#include "time.h"
+
+extern int sysClkRateGet P(());
+
+/* usrtime.h
+ * Bob Herlien's excellent time code find it at:
+ * ftp://ftp.atd.ucar.edu/pub/vxworks/vx/usrTime.shar
+ * I would recommend this instead of clock_[g|s]ettime() plus you get
+ * adjtime() too ... casey
+ */
+/*
+extern int       gettimeofday P(( struct timeval *tp, struct timezone *tzp ));
+extern int       settimeofday P((struct timeval *, struct timezone *));
+extern int       adjtime P(( struct timeval *delta, struct timeval *olddelta ));
+ */
+
+/* in  machines.c */
+extern void sleep P((int seconds));
+extern void alarm P((int seconds));
+/* machines.c */
+
+
+/*             this is really this     */
+#define getpid         taskIdSelf
+#define getclock       clock_gettime
+#define fcntl          ioctl
+#define _getch         getchar
+
+/* define this away for vxWorks */
+#define openlog(x,y)
+/* use local defines for these */
+#undef min
+#undef max
+
+#endif /* SYS_VXWORKS */
+
+#ifdef NO_NETDB
+/* These structures are needed for gethostbyname() etc... */
+/* structures used by netdb.h */
+struct hostent {
+       char    *h_name;                                /* official name of host */
+       char    **h_aliases;                    /* alias list */
+       int h_addrtype;                                 /* host address type */
+       int h_length;                                   /* length of address */
+       char    **h_addr_list;                  /* list of addresses from name server */
+#define        h_addr h_addr_list[0]   /* address, for backward compatibility */
+};
+
+struct servent {
+       char    *s_name;                                /* official service name */
+       char    **s_aliases;                    /* alias list */
+       int s_port;                                     /* port # */
+       char    *s_proto;                               /* protocol to use */
+};
+extern int h_errno;
+
+#define TRY_AGAIN      2
+
+struct hostent *gethostbyname P((char * netnum));
+struct hostent *gethostbyaddr P((char * netnum, int size, int addr_type));
+/* type is the protocol */
+struct servent *getservbyname P((char *name, char *type));
+#endif /* NO_NETDB */
+
+#ifdef NO_MAIN_ALLOWED
+/* we have no main routines so lets make a plan */
+#define CALL(callname, progname, callmain) \
+       extern int callmain (int,char**); \
+       void callname (a0,a1,a2,a3,a4,a5,a6,a7,a8,a9,a10) \
+               char *a0;  \
+               char *a1;  \
+               char *a2;  \
+               char *a3;  \
+               char *a4;  \
+               char *a5;  \
+               char *a6;  \
+               char *a7;  \
+               char *a8;  \
+               char *a9;  \
+               char *a10; \
+       { \
+         char *x[11]; \
+         int argc; \
+         char *argv[] = {progname,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL,NULL}; \
+         int i; \
+         for (i=0;i<11;i++) \
+          x[i] = NULL; \
+         x[0] = a0; \
+         x[1] = a1; \
+         x[2] = a2; \
+         x[3] = a3; \
+         x[4] = a4; \
+         x[5] = a5; \
+         x[6] = a6; \
+         x[7] = a7; \
+         x[8] = a8; \
+         x[9] = a9; \
+         x[10] = a10; \
+         argc=1; \
+         for (i=0; i<11;i++) \
+               if (x[i]) \
+               { \
+                 argv[argc++] = x[i];  \
+               } \
+        callmain(argc,argv);  \
+       }
+#endif /* NO_MAIN_ALLOWED */
+/*casey Tue May 27 15:45:25 SAT 1997*/
+
+/*
+ * Here's where autoconfig starts to take over
+ */
+#ifdef HAVE_SYS_STROPTS_H
+# ifdef HAVE_SYS_STREAM_H
+#  define STREAM
+# endif
+#endif
+
+#ifndef RETSIGTYPE
+# if defined(NTP_POSIX_SOURCE)
+#  define      RETSIGTYPE      void
+# else
+#  define      RETSIGTYPE      int
+# endif
+#endif
+
+#ifdef NTP_SYSCALLS_STD
+# ifndef       NTP_SYSCALL_GET
+#  define      NTP_SYSCALL_GET 235
+# endif
+# ifndef       NTP_SYSCALL_ADJ
+#  define      NTP_SYSCALL_ADJ 236
+# endif
+#endif /* NTP_SYSCALLS_STD */
+
+#ifdef MPE
+# include <sys/types.h>
+# include <netinet/in.h>
+# include <stdio.h>
+# include <time.h>
+
+/* missing functions that are easily renamed */
+
+# define _getch getchar
+
+/* special functions that require MPE-specific wrappers */
+
+# define bind  __ntp_mpe_bind
+# define fcntl __ntp_mpe_fcntl
+
+/* standard macros missing from MPE include files */
+
+# define IN_CLASSD(i)  ((((long)(i))&0xf0000000)==0xe0000000)
+# define IN_MULTICAST IN_CLASSD
+# define ITIMER_REAL 0
+# define MAXHOSTNAMELEN 64
+
+/* standard structures missing from MPE include files */
+
+struct itimerval { 
+        struct timeval it_interval;    /* timer interval */
+        struct timeval it_value;       /* current value */
+};
+
+/* various declarations to make gcc stop complaining */
+
+extern int __filbuf(FILE *);
+extern int __flsbuf(int, FILE *);
+extern int gethostname(char *, int);
+extern unsigned long inet_addr(char *);
+extern char *strdup(const char *);
+
+/* miscellaneous NTP macros */
+
+# define HAVE_NO_NICE
+#endif /* MPE */
+
+#ifdef HAVE_RTPRIO
+# define HAVE_NO_NICE
+#else
+# ifdef HAVE_SETPRIORITY
+#  define HAVE_BSD_NICE
+# else
+#  ifdef HAVE_NICE
+#      define HAVE_ATT_NICE
+#  endif
+# endif
+#endif
+
+#if !defined(HAVE_ATT_NICE) \
+       && !defined(HAVE_BSD_NICE) \
+       && !defined(HAVE_NO_NICE) \
+       && !defined(SYS_WINNT)
+#include "ERROR: You must define one of the HAVE_xx_NICE defines!"
+#endif
+
+/*
+ * use only one tty model - no use in initialising
+ * a tty in three ways
+ * HAVE_TERMIOS is preferred over HAVE_SYSV_TTYS over HAVE_BSD_TTYS
+ */
+
+#ifdef HAVE_TERMIOS_H
+# define HAVE_TERMIOS
+#else
+# ifdef HAVE_TERMIO_H
+#  define HAVE_SYSV_TTYS
+# else
+#  ifdef HAVE_SGTTY_H
+#      define HAVE_BSD_TTYS
+#  endif
+# endif
+#endif
+
+#ifdef HAVE_TERMIOS
+# undef HAVE_BSD_TTYS
+# undef HAVE_SYSV_TTYS
+#endif
+
+#ifndef HAVE_TIMEGM
+extern time_t  timegm          P((struct tm *));
+#endif
+
+#ifdef HAVE_SYSV_TTYS
+# undef HAVE_BSD_TTYS
+#endif
+
+#if !defined(SYS_WINNT) && !defined(VMS) && !defined(SYS_VXWORKS)
+# if   !defined(HAVE_SYSV_TTYS) \
+       && !defined(HAVE_BSD_TTYS) \
+       && !defined(HAVE_TERMIOS)
+#include "ERROR: no tty type defined!"
+# endif
+#endif /* SYS_WINNT || VMS     || SYS_VXWORKS*/
+
+#ifdef WORDS_BIGENDIAN
+# define       XNTP_BIG_ENDIAN 1
+#else
+# define       XNTP_LITTLE_ENDIAN      1
+#endif
+
+/*
+ * Byte order woes.
+ * This used to be resolved by calling ntohl() and htonl() to swap things
+ * around, but this turned out to be quite costly on Vaxes where those
+ * things are actual functions.  The code now straightens out byte
+ * order troubles on its own, with no performance penalty for little
+ * end first machines, but at great expense to cleanliness.
+ */
+#if !defined(XNTP_BIG_ENDIAN) && !defined(XNTP_LITTLE_ENDIAN)
+       /*
+        * Pick one or the other.
+        */
+       BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
+#endif
+
+#if defined(XNTP_BIG_ENDIAN) && defined(XNTP_LITTLE_ENDIAN)
+       /*
+        * Pick one or the other.
+        */
+       BYTE_ORDER_NOT_DEFINED_FOR_AUTHENTICATION
+#endif
+
+#endif /* __ntp_machine */
diff --git a/include/ntp_malloc.h b/include/ntp_malloc.h
new file mode 100644 (file)
index 0000000..099c83e
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Define malloc and friends.
+ */
+#ifndef  _ntp_malloc_h
+#define  _ntp_malloc_h
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_STDLIB_H
+# include <stdlib.h>
+#else /* HAVE_STDLIB_H */
+# ifdef HAVE_MALLOC_H
+#  include <malloc.h>
+# endif
+#endif /* HAVE_STDLIB_H */
+
+#endif /* _ntp_malloc_h */
diff --git a/include/ntp_md5.h b/include/ntp_md5.h
new file mode 100644 (file)
index 0000000..bb6985a
--- /dev/null
@@ -0,0 +1,9 @@
+/*
+ * ntp_md5.h: deal with md5.h headers
+ */
+
+#ifdef HAVE_MD5_H
+# include <md5.h>
+#else
+# include "rsa_md5.h"
+#endif
diff --git a/include/ntp_proto.h b/include/ntp_proto.h
new file mode 100644 (file)
index 0000000..e6e7855
--- /dev/null
@@ -0,0 +1,10 @@
+#ifndef __ntp_proto_h
+#define __ntp_proto_h
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#define NTP_MAXFREQ    500e-6
+#endif /* __ntp_proto_h */
diff --git a/include/ntp_random.h b/include/ntp_random.h
new file mode 100644 (file)
index 0000000..766dcc3
--- /dev/null
@@ -0,0 +1,14 @@
+
+#include <ntp_types.h>
+
+long ntp_random P((void));
+void ntp_srandom P((unsigned long));
+void ntp_srandomdev P((void));
+char * ntp_initstate P((unsigned long,         /* seed for R.N.G. */
+                       char *,         /* pointer to state array */
+                       long            /* # bytes of state info */
+                       ));
+char * ntp_setstate P((char *));       /* pointer to state array */
+
+
+
diff --git a/include/ntp_refclock.h b/include/ntp_refclock.h
new file mode 100644 (file)
index 0000000..d63f3af
--- /dev/null
@@ -0,0 +1,273 @@
+/*
+ * ntp_refclock.h - definitions for reference clock support
+ */
+
+#ifndef NTP_REFCLOCK_H
+#define NTP_REFCLOCK_H
+
+#include "ntp_types.h"
+
+#if defined(HAVE_BSD_TTYS)
+#include <sgtty.h>
+#endif /* HAVE_BSD_TTYS */
+
+#if defined(HAVE_SYSV_TTYS)
+#include <termio.h>
+#endif /* HAVE_SYSV_TTYS */
+
+#if defined(HAVE_TERMIOS)
+# ifdef TERMIOS_NEEDS__SVID3
+#  define _SVID3
+# endif
+# include <termios.h>
+# ifdef TERMIOS_NEEDS__SVID3
+#  undef _SVID3
+# endif
+#endif
+
+#if defined(HAVE_SYS_MODEM_H)
+#include <sys/modem.h>
+#endif
+
+#if 0 /* If you need that, include ntp_io.h instead */
+#if defined(STREAM)
+#include <stropts.h>
+#if defined(CLK) /* This is never defined, except perhaps by a system header file */
+#include <sys/clkdefs.h>
+#endif /* CLK */
+#endif /* STREAM */
+#endif
+
+#include "recvbuff.h"
+
+#if !defined(SYSV_TTYS) && !defined(STREAM) & !defined(BSD_TTYS)
+#define BSD_TTYS
+#endif /* SYSV_TTYS STREAM BSD_TTYS */
+
+#define SAMPLE(x)      pp->coderecv = (pp->coderecv + 1) % MAXSTAGE; \
+                       pp->filter[pp->coderecv] = (x); \
+                       if (pp->coderecv == pp->codeproc) \
+                               pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
+
+/*
+ * Macros to determine the clock type and unit numbers from a
+ * 127.127.t.u address
+ */
+#define        REFCLOCKTYPE(srcadr)    ((SRCADR(srcadr) >> 8) & 0xff)
+#define REFCLOCKUNIT(srcadr)   (SRCADR(srcadr) & 0xff)
+
+/*
+ * List of reference clock names and descriptions. These must agree with
+ * lib/clocktypes.c and ntpd/refclock_conf.c.
+ */
+struct clktype {
+       int code;               /* driver "major" number */
+       const char *clocktype;  /* long description */
+       const char *abbrev;     /* short description */
+};
+extern struct clktype clktypes[];
+
+/*
+ * Configuration flag values
+ */
+#define        CLK_HAVETIME1   0x1
+#define        CLK_HAVETIME2   0x2
+#define        CLK_HAVEVAL1    0x4
+#define        CLK_HAVEVAL2    0x8
+
+#define        CLK_FLAG1       0x1
+#define        CLK_FLAG2       0x2
+#define        CLK_FLAG3       0x4
+#define        CLK_FLAG4       0x8
+
+#define        CLK_HAVEFLAG1   0x10
+#define        CLK_HAVEFLAG2   0x20
+#define        CLK_HAVEFLAG3   0x40
+#define        CLK_HAVEFLAG4   0x80
+
+/*
+ * Constant for disabling event reporting in
+ * refclock_receive. ORed in leap
+ * parameter
+ */
+#define REFCLOCK_OWN_STATES    0x80
+
+/*
+ * Structure for returning clock status
+ */
+struct refclockstat {
+       u_char  type;           /* clock type */
+       u_char  flags;          /* clock flags */
+       u_char  haveflags;      /* bit array of valid flags */
+       u_short lencode;        /* length of last timecode */
+       const char *p_lastcode; /* last timecode received */
+       u_int32 polls;          /* transmit polls */
+       u_int32 noresponse;     /* no response to poll */
+       u_int32 badformat;      /* bad format timecode received */
+       u_int32 baddata;        /* invalid data timecode received */
+       u_int32 timereset;      /* driver resets */
+       const char *clockdesc;  /* ASCII description */
+       double  fudgetime1;     /* configure fudge time1 */
+       double  fudgetime2;     /* configure fudge time2 */
+       int32   fudgeval1;      /* configure fudge value1 */
+       int32   fudgeval2;      /* configure fudge value2 */
+       u_char  currentstatus;  /* clock status */
+       u_char  lastevent;      /* last exception event */
+       u_char  leap;           /* leap bits */
+       struct  ctl_var *kv_list; /* additional variables */
+};
+
+/*
+ * Reference clock I/O structure.  Used to provide an interface between
+ * the reference clock drivers and the I/O module.
+ */
+struct refclockio {
+       struct  refclockio *next; /* link to next structure */
+       void    (*clock_recv) P((struct recvbuf *)); /* completion routine */
+       int     (*io_input)   P((struct recvbuf *)); /* input routine -
+                               to avoid excessive buffer use
+                               due to small bursts
+                               of refclock input data */
+       caddr_t srcclock;       /* pointer to clock structure */
+       int     datalen;        /* lenth of data */
+       SOCKET  fd;             /* file descriptor */
+       u_long  recvcount;      /* count of receive completions */
+};
+
+/*
+ * Structure for returning debugging info
+ */
+#define        NCLKBUGVALUES   16
+#define        NCLKBUGTIMES    32
+
+struct refclockbug {
+       u_char  nvalues;        /* values following */
+       u_char  ntimes;         /* times following */
+       u_short svalues;        /* values format sign array */
+       u_int32 stimes;         /* times format sign array */
+       u_int32 values[NCLKBUGVALUES]; /* real values */
+       l_fp    times[NCLKBUGTIMES]; /* real times */
+};
+
+/*
+ * Structure interface between the reference clock support
+ * ntp_refclock.c and the driver utility routines
+ */
+#define MAXSTAGE       60      /* max median filter stages  */
+#define NSTAGE         5       /* default median filter stages */
+#define BMAX           128     /* max timecode length */
+#define GMT            0       /* I hope nobody sees this */
+#define MAXDIAL                60      /* max length of modem dial strings */
+
+/*
+ * Line discipline flags. These require line discipline or streams
+ * modules to be installed/loaded in the kernel. If specified, but not
+ * installed, the code runs as if unspecified.
+ */
+#define LDISC_STD      0x00    /* standard */
+#define LDISC_CLK      0x01    /* tty_clk \n intercept */
+#define LDISC_CLKPPS   0x02    /* tty_clk \377 intercept */
+#define LDISC_ACTS     0x04    /* tty_clk #* intercept */
+#define LDISC_CHU      0x08    /* depredated */
+#define LDISC_PPS      0x10    /* ppsclock, ppsapi */
+#define LDISC_RAW      0x20    /* raw binary */
+#define LDISC_ECHO     0x40    /* enable echo */
+#define        LDISC_REMOTE    0x80    /* remote mode */
+#define        LDISC_7O1      0x100    /* 7-bit, odd parity for Z3801A */
+
+struct refclockproc {
+       struct  refclockio io;  /* I/O handler structure */
+       caddr_t unitptr;        /* pointer to unit structure */
+       u_char  leap;           /* leap/synchronization code */
+       u_char  currentstatus;  /* clock status */
+       u_char  lastevent;      /* last exception event */
+       u_char  type;           /* clock type */
+       const char *clockdesc;  /* clock description */
+
+       char    a_lastcode[BMAX]; /* last timecode received */
+       u_short lencode;        /* length of last timecode */
+
+       int     year;           /* year of eternity */
+       int     day;            /* day of year */
+       int     hour;           /* hour of day */
+       int     minute;         /* minute of hour */
+       int     second;         /* second of minute */
+       long    nsec;           /* nanosecond of second */
+       u_long  yearstart;      /* beginning of year */
+       int     coderecv;       /* put pointer */
+       int     codeproc;       /* get pointer */
+       l_fp    lastref;        /* reference timestamp */
+       l_fp    lastrec;        /* receive timestamp */
+       double  offset;         /* mean offset */
+       double  disp;           /* sample dispersion */
+       double  jitter;         /* jitter (mean squares) */
+       double  filter[MAXSTAGE]; /* median filter */
+
+       /*
+        * Configuration data
+        */
+       double  fudgetime1;     /* fudge time1 */
+       double  fudgetime2;     /* fudge time2 */
+       u_char  stratum;        /* server stratum */
+       u_int32 refid;          /* reference identifier */
+       u_char  sloppyclockflag; /* fudge flags */
+
+       /*
+        * Status tallies
+        */
+       u_long  timestarted;    /* time we started this */
+       u_long  polls;          /* polls sent */
+       u_long  noreply;        /* no replies to polls */
+       u_long  badformat;      /* bad format reply */
+       u_long  baddata;        /* bad data reply */
+};
+
+/*
+ * Structure interface between the reference clock support
+ * ntp_refclock.c and particular clock drivers. This must agree with the
+ * structure defined in the driver.
+ */
+#define        noentry 0               /* flag for null routine */
+#define        NOFLAGS 0               /* flag for null flags */
+
+struct refclock {
+       int (*clock_start)      P((int, struct peer *));
+       void (*clock_shutdown)  P((int, struct peer *));
+       void (*clock_poll)      P((int, struct peer *));
+       void (*clock_control)   P((int, struct refclockstat *,
+                                   struct refclockstat *, struct peer *));
+       void (*clock_init)      P((void));
+       void (*clock_buginfo)   P((int, struct refclockbug *, struct peer *));
+       void (*clock_timer)     P((int, struct peer *));
+};
+
+/*
+ * Function prototypes
+ */
+/*
+ * auxiliary PPS interface (implemented by refclock_atom())
+ */
+extern int     pps_sample P((l_fp *));
+extern int     io_addclock_simple P((struct refclockio *));
+extern int     io_addclock     P((struct refclockio *));
+extern void    io_closeclock   P((struct refclockio *));
+
+#ifdef REFCLOCK
+extern void    refclock_buginfo P((struct sockaddr_storage *,
+                                   struct refclockbug *));
+extern void    refclock_control P((struct sockaddr_storage *,
+                                   struct refclockstat *,
+                                   struct refclockstat *));
+extern int     refclock_open   P((char *, u_int, u_int));
+extern int     refclock_setup  P((int, u_int, u_int));
+extern void    refclock_timer  P((struct peer *));
+extern void    refclock_transmit P((struct peer *));
+extern int     refclock_ioctl  P((int, u_int));
+extern         int     refclock_process P((struct refclockproc *));
+extern         void    refclock_process_offset P((struct refclockproc *, l_fp, l_fp, double));
+extern void    refclock_report P((struct peer *, int));
+extern int     refclock_gtlin  P((struct recvbuf *, char *, int, l_fp *));
+extern int     refclock_gtraw  P((struct recvbuf *, char *, int, l_fp *));
+#endif /* REFCLOCK */
+
+#endif /* NTP_REFCLOCK_H */
diff --git a/include/ntp_request.h b/include/ntp_request.h
new file mode 100644 (file)
index 0000000..eb13fad
--- /dev/null
@@ -0,0 +1,926 @@
+/*
+ * ntp_request.h - definitions for the ntpd remote query facility
+ */
+
+#ifndef _NTP_REQUEST_H
+#define _NTP_REQUEST_H
+
+#include "ntp_types.h"
+
+/*
+ * A mode 7 packet is used exchanging data between an NTP server
+ * and a client for purposes other than time synchronization, e.g.
+ * monitoring, statistics gathering and configuration.  A mode 7
+ * packet has the following format:
+ *
+ *    0                          1                   2                   3
+ *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |R|M| VN  | Mode|A|  Sequence   | Implementation|   Req Code    |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |  Err  | Number of data items  |  MBZ  |   Size of data item   |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                                                              |
+ *   |            Data (Minimum 0 octets, maximum 500 octets)        |
+ *   |                                                              |
+ *                            [...]
+ *   |                                                              |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |               Encryption Keyid (when A bit set)               |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                                                              |
+ *   |          Message Authentication Code (when A bit set)         |
+ *   |                                                              |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ * where the fields are (note that the client sends requests, the server
+ * responses):
+ *
+ * Response Bit:  This packet is a response (if clear, packet is a request).
+ *
+ * More Bit:   Set for all packets but the last in a response which
+ *             requires more than one packet.
+ *
+ * Version Number: 2 for current version
+ *
+ * Mode:       Always 7
+ *
+ * Authenticated bit: If set, this packet is authenticated.
+ *
+ * Sequence number: For a multipacket response, contains the sequence
+ *             number of this packet.  0 is the first in the sequence,
+ *             127 (or less) is the last.  The More Bit must be set in
+ *             all packets but the last.
+ *
+ * Implementation number: The number of the implementation this request code
+ *             is defined by.  An implementation number of zero is used
+ *             for requst codes/data formats which all implementations
+ *             agree on.  Implementation number 255 is reserved (for
+ *             extensions, in case we run out).
+ *
+ * Request code: An implementation-specific code which specifies the
+ *             operation to be (which has been) performed and/or the
+ *             format and semantics of the data included in the packet.
+ *
+ * Err:                Must be 0 for a request.  For a response, holds an error
+ *             code relating to the request.  If nonzero, the operation
+ *             requested wasn't performed.
+ *
+ *             0 - no error
+ *             1 - incompatable implementation number
+ *             2 - unimplemented request code
+ *             3 - format error (wrong data items, data size, packet size etc.)
+ *             4 - no data available (e.g. request for details on unknown peer)
+ *             5-6 I don't know
+ *             7 - authentication failure (i.e. permission denied)
+ *
+ * Number of data items: number of data items in packet.  0 to 500
+ *
+ * MBZ:                A reserved data field, must be zero in requests and responses.
+ *
+ * Size of data item: size of each data item in packet.  0 to 500
+ *
+ * Data:       Variable sized area containing request/response data.  For
+ *             requests and responses the size in octets must be greater
+ *             than or equal to the product of the number of data items
+ *             and the size of a data item.  For requests the data area
+ *             must be exactly 40 octets in length.  For responses the
+ *             data area may be any length between 0 and 500 octets
+ *             inclusive.
+ *
+ * Message Authentication Code: Same as NTP spec, in definition and function.
+ *             May optionally be included in requests which require
+ *             authentication, is never included in responses.
+ *
+ * The version number, mode and keyid have the same function and are
+ * in the same location as a standard NTP packet.  The request packet
+ * is the same size as a standard NTP packet to ease receive buffer
+ * management, and to allow the same encryption procedure to be used
+ * both on mode 7 and standard NTP packets.  The mac is included when
+ * it is required that a request be authenticated, the keyid should be
+ * zero in requests in which the mac is not included.
+ *
+ * The data format depends on the implementation number/request code pair
+ * and whether the packet is a request or a response.  The only requirement
+ * is that data items start in the octet immediately following the size
+ * word and that data items be concatenated without padding between (i.e.
+ * if the data area is larger than data_items*size, all padding is at
+ * the end).  Padding is ignored, other than for encryption purposes.
+ * Implementations using encryption might want to include a time stamp
+ * or other data in the request packet padding.  The key used for requests
+ * is implementation defined, but key 15 is suggested as a default.
+ */
+
+/*
+ * union of raw addresses to save space
+ */
+union addrun
+{
+       struct in6_addr addr6;
+       struct in_addr  addr;
+};
+
+/*
+ * A request packet.  These are almost a fixed length.
+ */
+struct req_pkt {
+       u_char rm_vn_mode;              /* response, more, version, mode */
+       u_char auth_seq;                /* key, sequence number */
+       u_char implementation;          /* implementation number */
+       u_char request;                 /* request number */
+       u_short err_nitems;             /* error code/number of data items */
+       u_short mbz_itemsize;           /* item size */
+       char data[MAXFILENAME + 48];    /* data area [32 prev](176 byte max) */
+                                       /* struct conf_peer must fit */
+       l_fp tstamp;                    /* time stamp, for authentication */
+       keyid_t keyid;                  /* encryption key */
+       char mac[MAX_MAC_LEN-sizeof(u_int32)]; /* (optional) 8 byte auth code */
+};
+
+/*
+ * The req_pkt_tail structure is used by ntpd to adjust for different
+ * packet sizes that may arrive.
+ */
+struct req_pkt_tail {
+       l_fp tstamp;                    /* time stamp, for authentication */
+       keyid_t keyid;                  /* encryption key */
+       char mac[MAX_MAC_LEN-sizeof(u_int32)]; /* (optional) 8 byte auth code */
+};
+
+/*
+ * Input packet lengths.  One with the mac, one without.
+ */
+#define        REQ_LEN_HDR     8       /* 4 * u_char + 2 * u_short */
+#define        REQ_LEN_MAC     (sizeof(struct req_pkt))
+#define        REQ_LEN_NOMAC   (sizeof(struct req_pkt) - MAX_MAC_LEN)
+
+/*
+ * A response packet.  The length here is variable, this is a
+ * maximally sized one.  Note that this implementation doesn't
+ * authenticate responses.
+ */
+#define        RESP_HEADER_SIZE        (8)
+#define        RESP_DATA_SIZE          (500)
+
+struct resp_pkt {
+       u_char rm_vn_mode;              /* response, more, version, mode */
+       u_char auth_seq;                /* key, sequence number */
+       u_char implementation;          /* implementation number */
+       u_char request;                 /* request number */
+       u_short err_nitems;             /* error code/number of data items */
+       u_short mbz_itemsize;           /* item size */
+       char data[RESP_DATA_SIZE];      /* data area */
+};
+
+
+/*
+ * Information error codes
+ */
+#define        INFO_OKAY       0
+#define        INFO_ERR_IMPL   1       /* incompatable implementation */
+#define        INFO_ERR_REQ    2       /* unknown request code */
+#define        INFO_ERR_FMT    3       /* format error */
+#define        INFO_ERR_NODATA 4       /* no data for this request */
+#define        INFO_ERR_AUTH   7       /* authentication failure */
+
+/*
+ * Maximum sequence number.
+ */
+#define        MAXSEQ  127
+
+
+/*
+ * Bit setting macros for multifield items.
+ */
+#define        RESP_BIT        0x80
+#define        MORE_BIT        0x40
+
+#define        ISRESPONSE(rm_vn_mode)  (((rm_vn_mode)&RESP_BIT)!=0)
+#define        ISMORE(rm_vn_mode)      (((rm_vn_mode)&MORE_BIT)!=0)
+#define INFO_VERSION(rm_vn_mode) ((u_char)(((rm_vn_mode)>>3)&0x7))
+#define        INFO_MODE(rm_vn_mode)   ((rm_vn_mode)&0x7)
+
+#define        RM_VN_MODE(resp, more, version)         \
+                               ((u_char)(((resp)?RESP_BIT:0)\
+                               |((more)?MORE_BIT:0)\
+                               |((version?version:(NTP_OLDVERSION+1))<<3)\
+                               |(MODE_PRIVATE)))
+
+#define        INFO_IS_AUTH(auth_seq)  (((auth_seq) & 0x80) != 0)
+#define        INFO_SEQ(auth_seq)      ((auth_seq)&0x7f)
+#define        AUTH_SEQ(auth, seq)     ((u_char)((((auth)!=0)?0x80:0)|((seq)&0x7f)))
+
+#define        INFO_ERR(err_nitems)    ((u_short)((ntohs(err_nitems)>>12)&0xf))
+#define        INFO_NITEMS(err_nitems) ((u_short)(ntohs(err_nitems)&0xfff))
+#define        ERR_NITEMS(err, nitems) (htons((u_short)((((u_short)(err)<<12)&0xf000)\
+                               |((u_short)(nitems)&0xfff))))
+
+#define        INFO_MBZ(mbz_itemsize)  ((ntohs(mbz_itemsize)>>12)&0xf)
+#define        INFO_ITEMSIZE(mbz_itemsize)     ((u_short)(ntohs(mbz_itemsize)&0xfff))
+#define        MBZ_ITEMSIZE(itemsize)  (htons((u_short)(itemsize)))
+
+
+/*
+ * Implementation numbers.  One for universal use and one for ntpd.
+ */
+#define        IMPL_UNIV       0
+#define        IMPL_XNTPD_OLD  2       /* Used by pre ipv6 ntpdc */
+#define        IMPL_XNTPD      3       /* Used by post ipv6 ntpdc */
+
+/*
+ * Some limits related to authentication.  Frames which are
+ * authenticated must include a time stamp which differs from
+ * the receive time stamp by no more than 10 seconds.
+ */
+#define        INFO_TS_MAXSKEW 10.
+
+/*
+ * Universal request codes go here.  There aren't any.
+ */
+
+/*
+ * NTPD request codes go here.
+ */
+#define        REQ_PEER_LIST           0       /* return list of peers */
+#define        REQ_PEER_LIST_SUM       1       /* return summary info for all peers */
+#define        REQ_PEER_INFO           2       /* get standard information on peer */
+#define        REQ_PEER_STATS          3       /* get statistics for peer */
+#define        REQ_SYS_INFO            4       /* get system information */
+#define        REQ_SYS_STATS           5       /* get system stats */
+#define        REQ_IO_STATS            6       /* get I/O stats */
+#define REQ_MEM_STATS          7       /* stats related to peer list maint */
+#define        REQ_LOOP_INFO           8       /* info from the loop filter */
+#define        REQ_TIMER_STATS         9       /* get timer stats */
+#define        REQ_CONFIG              10      /* configure a new peer */
+#define        REQ_UNCONFIG            11      /* unconfigure an existing peer */
+#define        REQ_SET_SYS_FLAG        12      /* set system flags */
+#define        REQ_CLR_SYS_FLAG        13      /* clear system flags */
+#define        REQ_MONITOR             14      /* (not used) */
+#define        REQ_NOMONITOR           15      /* (not used) */
+#define        REQ_GET_RESTRICT        16      /* return restrict list */
+#define        REQ_RESADDFLAGS         17      /* add flags to restrict list */
+#define        REQ_RESSUBFLAGS         18      /* remove flags from restrict list */
+#define        REQ_UNRESTRICT          19      /* remove entry from restrict list */
+#define        REQ_MON_GETLIST         20      /* return data collected by monitor */
+#define        REQ_RESET_STATS         21      /* reset stat counters */
+#define        REQ_RESET_PEER          22      /* reset peer stat counters */
+#define        REQ_REREAD_KEYS         23      /* reread the encryption key file */
+#define        REQ_DO_DIRTY_HACK       24      /* (not used) */
+#define        REQ_DONT_DIRTY_HACK     25      /* (not used) */
+#define        REQ_TRUSTKEY            26      /* add a trusted key */
+#define        REQ_UNTRUSTKEY          27      /* remove a trusted key */
+#define        REQ_AUTHINFO            28      /* return authentication info */
+#define REQ_TRAPS              29      /* return currently set traps */
+#define        REQ_ADD_TRAP            30      /* add a trap */
+#define        REQ_CLR_TRAP            31      /* clear a trap */
+#define        REQ_REQUEST_KEY         32      /* define a new request keyid */
+#define        REQ_CONTROL_KEY         33      /* define a new control keyid */
+#define        REQ_GET_CTLSTATS        34      /* get stats from the control module */
+#define        REQ_GET_LEAPINFO        35      /* (not used) */
+#define        REQ_GET_CLOCKINFO       36      /* get clock information */
+#define        REQ_SET_CLKFUDGE        37      /* set clock fudge factors */
+#define REQ_GET_KERNEL         38      /* get kernel pll/pps information */
+#define        REQ_GET_CLKBUGINFO      39      /* get clock debugging info */
+#define        REQ_SET_PRECISION       41      /* (not used) */
+#define        REQ_MON_GETLIST_1       42      /* return collected v1 monitor data */
+#define        REQ_HOSTNAME_ASSOCID    43      /* Here is a hostname + assoc_id */
+#define REQ_IF_STATS           44      /* get interface statistics */
+#define REQ_IF_RELOAD          45      /* reload interface list */
+
+/* Determine size of pre-v6 version of structures */
+#define v4sizeof(type)         offsetof(type, v6_flag)
+
+/*
+ * Flags in the peer information returns
+ */
+#define        INFO_FLAG_CONFIG        0x1
+#define        INFO_FLAG_SYSPEER       0x2
+#define INFO_FLAG_BURST                0x4
+#define        INFO_FLAG_REFCLOCK      0x8
+#define        INFO_FLAG_PREFER        0x10
+#define        INFO_FLAG_AUTHENABLE    0x20
+#define        INFO_FLAG_SEL_CANDIDATE 0x40
+#define        INFO_FLAG_SHORTLIST     0x80
+#define        INFO_FLAG_IBURST        0x100
+
+/*
+ * Flags in the system information returns
+ */
+#define INFO_FLAG_BCLIENT      0x1
+#define INFO_FLAG_AUTHENTICATE 0x2
+#define INFO_FLAG_NTP          0x4
+#define INFO_FLAG_KERNEL       0x8
+#define INFO_FLAG_MONITOR      0x40
+#define INFO_FLAG_FILEGEN      0x80
+#define INFO_FLAG_CAL          0x10
+#define INFO_FLAG_PPS_SYNC     0x20
+
+/*
+ * Peer list structure.  Used to return raw lists of peers.  It goes
+ * without saying that everything returned is in network byte order.
+ * Well, it *would* have gone without saying, but somebody said it.
+ */
+struct info_peer_list {
+       u_int32 addr;           /* address of peer */
+       u_short port;           /* port number of peer */
+       u_char hmode;           /* mode for this peer */
+       u_char flags;           /* flags (from above) */
+       u_int v6_flag;          /* is this v6 or not */
+       u_int unused1;          /* (unused) padding for addr6 */
+       struct in6_addr addr6;  /* v6 address of peer */
+};
+
+
+/*
+ * Peer summary structure.  Sort of the info that ntpdc returns by default.
+ */
+struct info_peer_summary {
+       u_int32 dstadr;         /* local address (zero for undetermined) */
+       u_int32 srcadr;         /* source address */
+       u_short srcport;        /* source port */
+       u_char stratum;         /* stratum of peer */
+       s_char hpoll;           /* host polling interval */
+       s_char ppoll;           /* peer polling interval */
+       u_char reach;           /* reachability register */
+       u_char flags;           /* flags, from above */
+       u_char hmode;           /* peer mode */
+       s_fp delay;             /* peer.estdelay */
+       l_fp offset;            /* peer.estoffset */
+       u_fp dispersion;        /* peer.estdisp */
+       u_int v6_flag;                  /* is this v6 or not */
+       u_int unused1;                  /* (unused) padding for dstadr6 */
+       struct in6_addr dstadr6;        /* local address (v6) */
+       struct in6_addr srcadr6;        /* source address (v6) */
+};
+
+
+/*
+ * Peer information structure.
+ */
+struct info_peer {
+       u_int32 dstadr;         /* local address */
+       u_int32 srcadr;         /* source address */
+       u_short srcport;        /* remote port */
+       u_char flags;           /* peer flags */
+       u_char leap;            /* peer.leap */
+       u_char hmode;           /* peer.hmode */
+       u_char pmode;           /* peer.pmode */
+       u_char stratum;         /* peer.stratum */
+       u_char ppoll;           /* peer.ppoll */
+       u_char hpoll;           /* peer.hpoll */
+       s_char precision;       /* peer.precision */
+       u_char version;         /* peer.version */
+       u_char unused8;
+       u_char reach;           /* peer.reach */
+       u_char unreach;         /* peer.unreach */
+       u_char flash;           /* old peer.flash */
+       u_char ttl;             /* peer.ttl */
+       u_short flash2;         /* new peer.flash */
+       associd_t associd;      /* association ID */
+       keyid_t keyid;          /* peer.keyid */
+       u_int32 pkeyid;         /* unused */
+       u_int32 refid;          /* peer.refid */
+       u_int32 timer;          /* peer.timer */
+       s_fp rootdelay;         /* peer.distance */
+       u_fp rootdispersion;    /* peer.dispersion */
+       l_fp reftime;           /* peer.reftime */
+       l_fp org;               /* peer.org */
+       l_fp rec;               /* peer.rec */
+       l_fp xmt;               /* peer.xmt */
+       s_fp filtdelay[NTP_SHIFT];      /* delay shift register */
+       l_fp filtoffset[NTP_SHIFT];     /* offset shift register */
+       u_char order[NTP_SHIFT];        /* order of peers from last filter */
+       s_fp delay;             /* peer.estdelay */
+       u_fp dispersion;        /* peer.estdisp */
+       l_fp offset;            /* peer.estoffset */
+       u_fp selectdisp;        /* peer select dispersion */
+       int32 unused1;          /* (obsolete) */
+       int32 unused2;
+       int32 unused3;
+       int32 unused4;
+       int32 unused5;
+       int32 unused6;
+       int32 unused7;
+       s_fp estbdelay;         /* broadcast offset */
+       u_int v6_flag;                  /* is this v6 or not */
+       u_int unused9;                  /* (unused) padding for dstadr6 */
+       struct in6_addr dstadr6;        /* local address (v6-like) */
+       struct in6_addr srcadr6;        /* sources address (v6-like) */
+};
+
+
+/*
+ * Peer statistics structure
+ */
+struct info_peer_stats {
+       u_int32 dstadr;         /* local address */
+       u_int32 srcadr;         /* remote address */
+       u_short srcport;        /* remote port */
+       u_short flags;          /* peer flags */
+       u_int32 timereset;      /* time counters were reset */
+       u_int32 timereceived;   /* time since a packet received */
+       u_int32 timetosend;     /* time until a packet sent */
+       u_int32 timereachable;  /* time peer has been reachable */
+       u_int32 sent;           /* number sent */
+       u_int32 unused1;        /* (unused) */
+       u_int32 processed;      /* number processed */
+       u_int32 unused2;        /* (unused) */
+       u_int32 badauth;        /* bad authentication */
+       u_int32 bogusorg;       /* bogus origin */
+       u_int32 oldpkt;         /* duplicate */
+       u_int32 unused3;        /* (unused) */
+       u_int32 unused4;        /* (unused) */
+       u_int32 seldisp;        /* bad dispersion */
+       u_int32 selbroken;      /* bad reference time */
+       u_int32 unused5;        /* (unused) */
+       u_char candidate;       /* select order */
+       u_char unused6;         /* (unused) */
+       u_char unused7;         /* (unused) */
+       u_char unused8;         /* (unused) */
+       u_int v6_flag;                  /* is this v6 or not */
+       u_int unused9;                  /* (unused) padding for dstadr6 */
+       struct in6_addr dstadr6;        /* local address */
+       struct in6_addr srcadr6;        /* remote address */
+};
+
+
+/*
+ * Loop filter variables
+ */
+struct info_loop {
+       l_fp last_offset;
+       l_fp drift_comp;
+       u_int32 compliance;
+       u_int32 watchdog_timer;
+};
+
+
+/*
+ * System info.  Mostly the sys.* variables, plus a few unique to
+ * the implementation.
+ */
+struct info_sys {
+       u_int32 peer;           /* system peer address (v4) */
+       u_char peer_mode;       /* mode we are syncing to peer in */
+       u_char leap;            /* system leap bits */
+       u_char stratum;         /* our stratum */
+       s_char precision;       /* local clock precision */
+       s_fp rootdelay;         /* distance from sync source */
+       u_fp rootdispersion;    /* dispersion from sync source */
+       u_int32 refid;          /* reference ID of sync source */
+       l_fp reftime;           /* system reference time */
+       u_int32 poll;           /* system poll interval */
+       u_char flags;           /* system flags */
+       u_char unused1;         /* unused */
+       u_char unused2;         /* unused */
+       u_char unused3;         /* unused */
+       s_fp bdelay;            /* default broadcast offset */
+       s_fp frequency;         /* frequency residual (scaled ppm)  */
+       l_fp authdelay;         /* default authentication delay */
+       u_fp stability;         /* clock stability (scaled ppm) */
+       u_int v6_flag;          /* is this v6 or not */
+       u_int unused4;          /* unused, padding for peer6 */
+       struct in6_addr peer6;  /* system peer address (v6) */
+};
+
+
+/*
+ * System stats.  These are collected in the protocol module
+ */
+struct info_sys_stats {
+       u_int32 timeup;         /* time since restart */
+       u_int32 timereset;      /* time since reset */
+       u_int32 denied;         /* access denied */
+       u_int32 oldversionpkt;  /* recent version */
+       u_int32 newversionpkt;  /* current version */
+       u_int32 unknownversion; /* bad version */
+       u_int32 badlength;      /* bad length or format */
+       u_int32 processed;      /* packets processed */
+       u_int32 badauth;        /* bad authentication */
+       u_int32 received;       /* packets received */
+       u_int32 limitrejected;  /* rate exceeded */
+};
+
+
+/*
+ * System stats - old version
+ */
+struct old_info_sys_stats {
+       u_int32 timeup;         /* time since restart */
+       u_int32 timereset;      /* time since reset */
+       u_int32 denied;         /* access denied */
+       u_int32 oldversionpkt;  /* recent version */
+       u_int32 newversionpkt;  /* current version */
+       u_int32 unknownversion; /* bad version */
+       u_int32 badlength;      /* bad length or format */
+       u_int32 processed;      /* packets processed */
+       u_int32 badauth;        /* bad authentication */
+       u_int32 wanderhold;     /* (not used) */
+};
+
+
+/*
+ * Peer memory statistics.  Collected in the peer module.
+ */
+struct info_mem_stats {
+       u_int32 timereset;      /* time since reset */
+       u_short totalpeermem;
+       u_short freepeermem;
+       u_int32 findpeer_calls;
+       u_int32 allocations;
+       u_int32 demobilizations;
+       u_char hashcount[NTP_HASH_SIZE];
+};
+
+
+/*
+ * I/O statistics.  Collected in the I/O module
+ */
+struct info_io_stats {
+       u_int32 timereset;      /* time since reset */
+       u_short totalrecvbufs;  /* total receive bufs */
+       u_short freerecvbufs;   /* free buffers */
+       u_short fullrecvbufs;   /* full buffers */
+       u_short lowwater;       /* number of times we've added buffers */
+       u_int32 dropped;        /* dropped packets */
+       u_int32 ignored;        /* ignored packets */
+       u_int32 received;       /* received packets */
+       u_int32 sent;           /* packets sent */
+       u_int32 notsent;        /* packets not sent */
+       u_int32 interrupts;     /* interrupts we've handled */
+       u_int32 int_received;   /* received by interrupt handler */
+};
+
+
+/*
+ * Timer stats.  Guess where from.
+ */
+struct info_timer_stats {
+       u_int32 timereset;      /* time since reset */
+       u_int32 alarms;         /* alarms we've handled */
+       u_int32 overflows;      /* timer overflows */
+       u_int32 xmtcalls;       /* calls to xmit */
+};
+
+
+/*
+ * Structure for passing peer configuration information
+ */
+struct old_conf_peer {
+       u_int32 peeraddr;       /* address to poll */
+       u_char hmode;           /* mode, either broadcast, active or client */
+       u_char version;         /* version number to poll with */
+       u_char minpoll;         /* min host poll interval */
+       u_char maxpoll;         /* max host poll interval */
+       u_char flags;           /* flags for this request */
+       u_char ttl;             /* time to live (multicast) or refclock mode */
+       u_short unused;         /* unused */
+       keyid_t keyid;          /* key to use for this association */
+};
+
+struct conf_peer {
+       u_int32 peeraddr;       /* address to poll */
+       u_char hmode;           /* mode, either broadcast, active or client */
+       u_char version;         /* version number to poll with */
+       u_char minpoll;         /* min host poll interval */
+       u_char maxpoll;         /* max host poll interval */
+       u_char flags;           /* flags for this request */
+       u_char ttl;             /* time to live (multicast) or refclock mode */
+       u_short unused1;        /* unused */
+       keyid_t keyid;          /* key to use for this association */
+       char keystr[MAXFILENAME]; /* public key file name*/
+       u_int v6_flag;          /* is this v6 or not */
+       u_int unused2;                  /* unused, padding for peeraddr6 */
+       struct in6_addr peeraddr6;      /* ipv6 address to poll */
+};
+
+#define        CONF_FLAG_AUTHENABLE    0x01
+#define CONF_FLAG_PREFER       0x02
+#define CONF_FLAG_BURST                0x04
+#define CONF_FLAG_IBURST       0x08
+#define CONF_FLAG_NOSELECT     0x10
+#define CONF_FLAG_SKEY         0x20
+
+/*
+ * Structure for passing peer deletion information.  Currently
+ * we only pass the address and delete all configured peers with
+ * this addess.
+ */
+struct conf_unpeer {
+       u_int32 peeraddr;               /* address of peer */
+       u_int v6_flag;                  /* is this v6 or not */
+       struct in6_addr peeraddr6;      /* address of peer (v6) */
+};
+
+/*
+ * Structure for carrying system flags.
+ */
+struct conf_sys_flags {
+       u_int32 flags;
+};
+
+/*
+ * System flags we can set/clear
+ */
+#define        SYS_FLAG_BCLIENT        0x01
+#define        SYS_FLAG_PPS            0x02
+#define SYS_FLAG_NTP           0x04
+#define SYS_FLAG_KERNEL                0x08
+#define SYS_FLAG_MONITOR       0x10
+#define SYS_FLAG_FILEGEN       0x20
+#define SYS_FLAG_AUTH          0x40
+#define SYS_FLAG_CAL           0x80
+
+/*
+ * Structure used for returning restrict entries
+ */
+struct info_restrict {
+       u_int32 addr;           /* match address */
+       u_int32 mask;           /* match mask */
+       u_int32 count;          /* number of packets matched */
+       u_short flags;          /* restrict flags */
+       u_short mflags;         /* match flags */
+       u_int v6_flag;          /* is this v6 or not */
+       u_int unused1;          /* unused, padding for addr6 */
+       struct in6_addr addr6;  /* match address (v6) */
+       struct in6_addr mask6;  /* match mask (v6) */
+};
+
+
+/*
+ * Structure used for specifying restrict entries
+ */
+struct conf_restrict {
+       u_int32 addr;           /* match address */
+       u_int32 mask;           /* match mask */
+       u_short flags;          /* restrict flags */
+       u_short mflags;         /* match flags */
+       u_int v6_flag;          /* is this v6 or not */
+       struct in6_addr addr6;  /* match address (v6) */
+       struct in6_addr mask6;  /* match mask (v6) */
+};
+
+
+/*
+ * Structure used for returning monitor data
+ */
+struct info_monitor_1 {        
+       u_int32 lasttime;       /* last packet from this host */
+       u_int32 firsttime;      /* first time we received a packet */
+       u_int32 lastdrop;        /* last time we rejected a packet due to client limitation policy */
+       u_int32 count;          /* count of packets received */
+       u_int32 addr;           /* host address V4 style */
+       u_int32 daddr;          /* destination host address */
+       u_int32 flags;          /* flags about destination */
+       u_short port;           /* port number of last reception */
+       u_char mode;            /* mode of last packet */
+       u_char version;         /* version number of last packet */
+       u_int v6_flag;          /* is this v6 or not */
+       u_int unused1;          /* unused, padding for addr6 */
+       struct in6_addr addr6;  /* host address V6 style */
+       struct in6_addr daddr6; /* host address V6 style */
+};
+
+
+/*
+ * Structure used for returning monitor data
+ */
+struct info_monitor {  
+       u_int32 lasttime;       /* last packet from this host */
+       u_int32 firsttime;      /* first time we received a packet */
+       u_int32 lastdrop;       /* last time we rejected a packet due to client limitation policy */
+       u_int32 count;          /* count of packets received */
+       u_int32 addr;           /* host address */
+       u_short port;           /* port number of last reception */
+       u_char mode;            /* mode of last packet */
+       u_char version;         /* version number of last packet */
+       u_int v6_flag;          /* is this v6 or not */
+       u_int unused1;          /* unused, padding for addr6 */
+       struct in6_addr addr6;  /* host v6 address */
+};
+
+/*
+ * Structure used for returning monitor data (old format
+ */
+struct old_info_monitor {      
+       u_int32 lasttime;       /* last packet from this host */
+       u_int32 firsttime;      /* first time we received a packet */
+       u_int32 count;          /* count of packets received */
+       u_int32 addr;           /* host address */
+       u_short port;           /* port number of last reception */
+       u_char mode;            /* mode of last packet */
+       u_char version;         /* version number of last packet */
+       u_int v6_flag;          /* is this v6 or not */
+       struct in6_addr addr6;  /* host address  (v6)*/
+};
+
+/*
+ * Structure used for passing indication of flags to clear
+ */
+struct reset_flags {
+       u_int32 flags;
+};
+
+#define        RESET_FLAG_ALLPEERS     0x01
+#define        RESET_FLAG_IO           0x02
+#define        RESET_FLAG_SYS          0x04
+#define        RESET_FLAG_MEM          0x08
+#define        RESET_FLAG_TIMER        0x10
+#define        RESET_FLAG_AUTH         0x20
+#define        RESET_FLAG_CTL          0x40
+
+#define        RESET_ALLFLAGS \
+       (RESET_FLAG_ALLPEERS|RESET_FLAG_IO|RESET_FLAG_SYS \
+       |RESET_FLAG_MEM|RESET_FLAG_TIMER|RESET_FLAG_AUTH|RESET_FLAG_CTL)
+
+/*
+ * Structure used to return information concerning the authentication
+ * module.
+ */
+struct info_auth {
+       u_int32 timereset;      /* time counters were reset */
+       u_int32 numkeys;        /* number of keys we know */
+       u_int32 numfreekeys;    /* number of free keys */
+       u_int32 keylookups;     /* calls to authhavekey() */
+       u_int32 keynotfound;    /* requested key unknown */
+       u_int32 encryptions;    /* number of encryptions */
+       u_int32 decryptions;    /* number of decryptions */
+       u_int32 expired;        /* number of expired keys */
+       u_int32 keyuncached;    /* calls to encrypt/decrypt with uncached key */
+};
+
+
+/*
+ * Structure used to pass trap information to the client
+ */
+struct info_trap {
+       u_int32 local_address;  /* local interface addres (v4) */
+       u_int32 trap_address;   /* remote client's addres (v4) */
+       u_short trap_port;      /* remote port number */
+       u_short sequence;       /* sequence number */
+       u_int32 settime;        /* time trap last set */
+       u_int32 origtime;       /* time trap originally set */
+       u_int32 resets;         /* number of resets on this trap */
+       u_int32 flags;          /* trap flags, as defined in ntp_control.h */
+       u_int v6_flag;                  /* is this v6 or not */
+       struct in6_addr local_address6; /* local interface address (v6) */
+       struct in6_addr trap_address6;  /* remote client's address (v6) */
+};
+
+/*
+ * Structure used to pass add/clear trap information to the client
+ */
+struct conf_trap {
+       u_int32 local_address;  /* remote client's address */
+       u_int32 trap_address;   /* local interface address */
+       u_short trap_port;      /* remote client's port */
+       u_short unused;         /* (unused) */
+       u_int v6_flag;                  /* is this v6 or not */
+       struct in6_addr local_address6; /* local interface address (v6) */
+       struct in6_addr trap_address6;  /* remote client's address (v6) */
+};
+
+
+/*
+ * Structure used to return statistics from the control module
+ */
+struct info_control {
+       u_int32 ctltimereset;
+       u_int32 numctlreq;      /* number of requests we've received */
+       u_int32 numctlbadpkts;  /* number of bad control packets */
+       u_int32 numctlresponses;        /* # resp packets sent */
+       u_int32 numctlfrags;    /* # of fragments sent */
+       u_int32 numctlerrors;   /* number of error responses sent */
+       u_int32 numctltooshort; /* number of too short input packets */
+       u_int32 numctlinputresp;        /* number of responses on input */
+       u_int32 numctlinputfrag;        /* number of fragments on input */
+       u_int32 numctlinputerr; /* # input pkts with err bit set */
+       u_int32 numctlbadoffset;        /* # input pkts with nonzero offset */
+       u_int32 numctlbadversion;       /* # input pkts with unknown version */
+       u_int32 numctldatatooshort;     /* data too short for count */
+       u_int32 numctlbadop;    /* bad op code found in packet */
+       u_int32 numasyncmsgs;           /* # async messages we've sent */
+};
+
+
+/*
+ * Structure used to return clock information
+ */
+struct info_clock {
+       u_int32 clockadr;
+       u_char type;
+       u_char flags;
+       u_char lastevent;
+       u_char currentstatus;
+       u_int32 polls;
+       u_int32 noresponse;
+       u_int32 badformat;
+       u_int32 baddata;
+       u_int32 timestarted;
+       l_fp fudgetime1;
+       l_fp fudgetime2;
+       int32 fudgeval1;
+       int32 fudgeval2;
+};
+
+
+/*
+ * Structure used for setting clock fudge factors
+ */
+struct conf_fudge {
+       u_int32 clockadr;
+       u_int32 which;
+       l_fp fudgetime;
+       int32 fudgeval_flags;
+};
+
+#define        FUDGE_TIME1     1
+#define        FUDGE_TIME2     2
+#define        FUDGE_VAL1      3
+#define        FUDGE_VAL2      4
+#define        FUDGE_FLAGS     5
+
+
+/*
+ * Structure used for returning clock debugging info
+ */
+#define        NUMCBUGVALUES   16
+#define        NUMCBUGTIMES    32
+
+struct info_clkbug {
+       u_int32 clockadr;
+       u_char nvalues;
+       u_char ntimes;
+       u_short svalues;
+       u_int32 stimes;
+       u_int32 values[NUMCBUGVALUES];
+       l_fp times[NUMCBUGTIMES];
+};
+
+/*
+ * Structure used for returning kernel pll/PPS information
+ */
+struct info_kernel {
+       int32 offset;
+       int32 freq;
+       int32 maxerror;
+       int32 esterror;
+       u_short status;
+       u_short shift;
+       int32 constant;
+       int32 precision;
+       int32 tolerance;
+
+/*
+ * Variables used only if PPS signal discipline is implemented
+ */
+       int32 ppsfreq;
+       int32 jitter;
+       int32 stabil;
+       int32 jitcnt;
+       int32 calcnt;
+       int32 errcnt;
+       int32 stbcnt;
+};
+
+/*
+ * interface statistics
+ */
+struct info_if_stats {
+       union addrun unaddr;            /* address */
+        union addrun unbcast;          /* broadcast */
+       union addrun unmask;            /* mask */
+       u_int32 v6_flag;                /* is this v6 */
+       char name[32];                  /* name of interface */
+       int32 flags;                    /* interface flags */
+       int32 last_ttl;                 /* last TTL specified */
+       int32 num_mcast;                /* No. of IP addresses in multicast socket */
+        int32 received;                        /* number of incoming packets */
+       int32 sent;                     /* number of outgoing packets */
+       int32 notsent;                  /* number of send failures */
+       int32 uptime;                   /* number of seconds this interface was active */
+       u_int32 scopeid;                /* Scope used for Multicasting */
+       u_int32 ifindex;                /* interface index - from system */
+       u_int32 ifnum;                  /* sequential interface number */
+        u_int32 peercnt;               /* number of peers referencinf this interface - informational only */
+       u_short family;                 /* Address family */
+       u_char ignore_packets;          /* Specify whether the packet should be ignored */
+        u_char action;                 /* reason the item is listed */
+       int32 _filler0;                 /* pad to a 64 bit size boundary */
+};
+
+#define IFS_EXISTS     1       /* just exists */
+#define IFS_CREATED    2       /* was just created */
+#define IFS_DELETED    3       /* was just delete */
+
+/*
+ * Info returned with IP -> hostname lookup
+ */
+/* 144 might need to become 32, matching data[] member of req_pkt */
+#define NTP_MAXHOSTNAME (32 - sizeof(u_int32) - sizeof(u_short))
+struct info_dns_assoc {
+       u_int32 peeraddr;       /* peer address (HMS: being careful...) */
+       associd_t associd;      /* association ID */
+       char hostname[NTP_MAXHOSTNAME]; /* hostname */
+};
+#endif /* NTP_REQUEST_H */
diff --git a/include/ntp_rfc2553.h b/include/ntp_rfc2553.h
new file mode 100644 (file)
index 0000000..662b118
--- /dev/null
@@ -0,0 +1,292 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 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.
+ *
+ *     @(#)in.h        8.3 (Berkeley) 1/3/94
+ */
+
+/*
+ * Compatability shims with the rfc2553 API to simplify ntp.
+ */
+#ifndef _NTP_RFC2553_H_
+#define _NTP_RFC2553_H_
+
+/*
+ * Ensure that we include the configuration file before we check
+ * for IPV6
+ */
+#include <config.h>
+
+#include <netdb.h>
+
+#include "ntp_types.h"
+
+/*
+ * Don't include any additional IPv6 definitions
+ * We are defining our own here.
+ */
+#define ISC_IPV6_H 1
+
+ /*
+ * If various macros are not defined we need to define them
+ */
+
+#ifndef AF_INET6
+#define AF_INET6       AF_MAX
+#define PF_INET6       AF_INET6
+#endif
+
+#if !defined(_SS_MAXSIZE) && !defined(_SS_ALIGNSIZE)
+
+#define        _SS_MAXSIZE     128
+#define        _SS_ALIGNSIZE   (sizeof(ntp_uint64_t))
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+#define        _SS_PAD1SIZE    (_SS_ALIGNSIZE - sizeof(u_char) - sizeof(ntp_u_int8_t))
+#define        _SS_PAD2SIZE    (_SS_MAXSIZE - sizeof(u_char) - sizeof(ntp_u_int8_t) - \
+                               _SS_PAD1SIZE - _SS_ALIGNSIZE)
+#else
+#define        _SS_PAD1SIZE    (_SS_ALIGNSIZE - sizeof(short))
+#define        _SS_PAD2SIZE    (_SS_MAXSIZE - sizeof(short) - \
+                               _SS_PAD1SIZE - _SS_ALIGNSIZE)
+#endif /* HAVE_SA_LEN_IN_STRUCT_SOCKADDR */
+#endif
+
+/*
+ * If we don't have the sockaddr_storage structure
+ * we need to define it
+ */
+
+#ifndef HAVE_STRUCT_SOCKADDR_STORAGE
+struct sockaddr_storage {
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+       ntp_u_int8_t    ss_len;         /* address length */
+       ntp_u_int8_t    ss_family;      /* address family */
+#else
+       short           ss_family;      /* address family */
+#endif
+       char            __ss_pad1[_SS_PAD1SIZE];
+       ntp_uint64_t    __ss_align;     /* force desired structure storage alignment */
+       char            __ss_pad2[_SS_PAD2SIZE];
+};
+#endif
+
+/*
+ * Finally if the platform doesn't support IPv6 we need some
+ * additional definitions
+ */
+
+/*
+ * Flag values for getaddrinfo()
+ */
+#ifndef AI_NUMERICHOST
+#define        AI_PASSIVE      0x00000001 /* get address to use bind() */
+#define        AI_CANONNAME    0x00000002 /* fill ai_canonname */
+#define        AI_NUMERICHOST  0x00000004 /* prevent name resolution */
+/* valid flags for addrinfo */
+#define AI_MASK \
+    (AI_PASSIVE | AI_CANONNAME | AI_NUMERICHOST | AI_ADDRCONFIG)
+
+#define        AI_ADDRCONFIG   0x00000400 /* only if any address is assigned */
+#endif
+
+#ifndef ISC_PLATFORM_HAVEIPV6
+/*
+ * Definition of some useful macros to handle IP6 addresses
+ */
+#ifdef ISC_PLATFORM_NEEDIN6ADDRANY
+#ifdef SYS_WINNT
+#define IN6ADDR_ANY_INIT       {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}
+#else
+#define IN6ADDR_ANY_INIT \
+       {{{ 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, \
+           0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }}}
+#endif
+#endif
+
+
+/*
+ * IPv6 address
+ */
+#ifdef SYS_WINNT
+#define in6_addr in_addr6
+#else
+
+struct in6_addr {
+       union {
+               ntp_u_int8_t   __u6_addr8[16];
+               ntp_u_int16_t  __u6_addr16[8];
+               ntp_u_int32_t  __u6_addr32[4];
+       } __u6_addr;                    /* 128-bit IP6 address */
+};
+
+#define s6_addr   __u6_addr.__u6_addr8
+#endif
+
+#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY)
+extern const struct in6_addr in6addr_any;
+#endif
+
+#define SIN6_LEN
+#ifndef HAVE_SOCKADDR_IN6
+struct sockaddr_in6 {
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+       ntp_u_int8_t    sin6_len;       /* length of this struct(sa_family_t)*/
+       ntp_u_int8_t    sin6_family;    /* AF_INET6 (sa_family_t) */
+#else
+       short           sin6_family;    /* AF_INET6 (sa_family_t) */
+#endif
+       ntp_u_int16_t   sin6_port;      /* Transport layer port # (in_port_t)*/
+       ntp_u_int32_t   sin6_flowinfo;  /* IP6 flow information */
+       struct in6_addr sin6_addr;      /* IP6 address */
+       ntp_u_int32_t   sin6_scope_id;  /* scope zone index */
+};
+#endif
+
+/*
+ * Unspecified
+ */
+#ifndef IN6_IS_ADDR_UNSPECIFIED
+#define IN6_IS_ADDR_UNSPECIFIED(a)     \
+       ((*(const ntp_u_int32_t *)(const void *)(&(a)->s6_addr[0]) == 0) &&     \
+        (*(const ntp_u_int32_t *)(const void *)(&(a)->s6_addr[4]) == 0) &&     \
+        (*(const ntp_u_int32_t *)(const void *)(&(a)->s6_addr[8]) == 0) &&     \
+        (*(const ntp_u_int32_t *)(const void *)(&(a)->s6_addr[12]) == 0))
+#endif
+/*
+ * Multicast
+ */
+#ifndef IN6_IS_ADDR_MULTICAST
+#define IN6_IS_ADDR_MULTICAST(a)       ((a)->s6_addr[0] == 0xff)
+#endif
+/*
+ * Unicast link / site local.
+ */
+#ifndef IN6_IS_ADDR_LINKLOCAL
+#define IN6_IS_ADDR_LINKLOCAL(a)       (\
+(*((u_long *)((a)->s6_addr)    ) == 0xfe) && \
+((*((u_long *)((a)->s6_addr) + 1) & 0xc0) == 0x80))
+#endif
+
+#ifndef IN6_IS_ADDR_SITELOCAL
+#define IN6_IS_ADDR_SITELOCAL(a)       (\
+(*((u_long *)((a)->s6_addr)    ) == 0xfe) && \
+((*((u_long *)((a)->s6_addr) + 1) & 0xc0) == 0xc0))
+#endif
+
+struct addrinfo {
+       int     ai_flags;       /* AI_PASSIVE, AI_CANONNAME, AI_NUMERICHOST */
+       int     ai_family;      /* PF_xxx */
+       int     ai_socktype;    /* SOCK_xxx */
+       int     ai_protocol;    /* 0 or IPPROTO_xxx for IPv4 and IPv6 */
+       size_t  ai_addrlen;     /* length of ai_addr */
+       char    *ai_canonname;  /* canonical name for hostname */
+       struct  sockaddr *ai_addr;      /* binary address */
+       struct  addrinfo *ai_next;      /* next structure in linked list */
+};
+
+/*
+ * Error return codes from getaddrinfo()
+ */
+#define        EAI_ADDRFAMILY   1      /* address family for hostname not supported */
+#define        EAI_AGAIN        2      /* temporary failure in name resolution */
+#define        EAI_BADFLAGS     3      /* invalid value for ai_flags */
+#define        EAI_FAIL         4      /* non-recoverable failure in name resolution */
+#define        EAI_FAMILY       5      /* ai_family not supported */
+#define        EAI_MEMORY       6      /* memory allocation failure */
+#define        EAI_NODATA       7      /* no address associated with hostname */
+#define        EAI_NONAME       8      /* hostname nor servname provided, or not known */
+#define        EAI_SERVICE      9      /* servname not supported for ai_socktype */
+#define        EAI_SOCKTYPE    10      /* ai_socktype not supported */
+#define        EAI_SYSTEM      11      /* system error returned in errno */
+#define        EAI_BADHINTS    12
+#define        EAI_PROTOCOL    13
+#define        EAI_MAX         14
+
+
+int    getaddrinfo P((const char *, const char *,
+                        const struct addrinfo *, struct addrinfo **));
+int    getnameinfo P((const struct sockaddr *, u_int, char *,
+                        size_t, char *, size_t, int));
+void   freeaddrinfo P((struct addrinfo *));
+char   *gai_strerror P((int));
+
+/*
+ * Constants for getnameinfo()
+ */
+#ifndef NI_MAXHOST
+#define        NI_MAXHOST      1025
+#define        NI_MAXSERV      32
+#endif
+
+/*
+ * Flag values for getnameinfo()
+ */
+#ifndef NI_NUMERICHOST
+#define        NI_NOFQDN       0x00000001
+#define        NI_NUMERICHOST  0x00000002
+#define        NI_NAMEREQD     0x00000004
+#define        NI_NUMERICSERV  0x00000008
+#define        NI_DGRAM        0x00000010
+#define NI_WITHSCOPEID 0x00000020
+#endif
+
+#endif /* ISC_PLATFORM_HAVEIPV6 */
+
+#endif /* !_NTP_RFC2553_H_ */
diff --git a/include/ntp_select.h b/include/ntp_select.h
new file mode 100644 (file)
index 0000000..79c0fc0
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Not all machines define FD_SET in sys/types.h
+ */ 
+#ifndef _ntp_select_h
+#define _ntp_select_h
+
+/* Was: (defined(RS6000)||defined(SYS_PTX))&&!defined(_BSD) */
+/* Could say: !defined(FD_SET) && defined(HAVE_SYS_SELECT_H) */
+#if defined(HAVE_SYS_SELECT_H) && !defined(_BSD)
+#ifndef SYS_VXWORKS
+#include <sys/select.h>
+#else
+#include <sockLib.h>
+extern int  select P((int width, fd_set *pReadFds, fd_set *pWriteFds,
+            fd_set *pExceptFds, struct timeval *pTimeOut));
+
+#endif
+#endif
+
+#if !defined(FD_SET) && !defined(SYS_WINNT)
+#define NFDBITS         32
+#define FD_SETSIZE      32
+#define FD_SET(n, p)    ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
+#define FD_CLR(n, p)    ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
+#define FD_ISSET(n, p)  ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
+#define FD_ZERO(p)      memset((char *)(p), 0, sizeof(*(p)))
+#endif
+
+#if defined(VMS)
+typedef struct {
+    unsigned int fds_bits[1];
+} fd_set;
+#endif
+
+#endif /* _ntp_select_h */
diff --git a/include/ntp_sprintf.h b/include/ntp_sprintf.h
new file mode 100644 (file)
index 0000000..a456a89
--- /dev/null
@@ -0,0 +1,13 @@
+/*
+ * Handle ancient char* *s*printf*() systems
+ */
+
+#ifdef SPRINTF_CHAR
+# define SPRINTF(x)    strlen(sprintf/**/x)
+# define SNPRINTF(x)   strlen(snprintf/**/x)
+# define VSNPRINTF(x)  strlen(vsnprintf/**/x)
+#else
+# define SPRINTF(x)    ((size_t)sprintf x)
+# define SNPRINTF(x)   ((size_t)snprintf x)
+# define VSNPRINTF(x)  ((size_t)vsnprintf x)
+#endif
diff --git a/include/ntp_stdlib.h b/include/ntp_stdlib.h
new file mode 100644 (file)
index 0000000..c389d1e
--- /dev/null
@@ -0,0 +1,150 @@
+/*
+ * ntp_stdlib.h - Prototypes for NTP lib.
+ */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include "ntp_rfc2553.h"
+
+#include "ntp_types.h"
+#include "ntp_string.h"
+#include "l_stdlib.h"
+
+/*
+ * Handle gcc __attribute__ if available.
+ */
+#ifndef __attribute__
+/* This feature is available in gcc versions 2.5 and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) || (defined(__STRICT_ANSI__))
+#  define __attribute__(Spec) /* empty */
+# endif
+/* The __-protected variants of `format' and `printf' attributes
+   are accepted by gcc versions 2.6.4 (effectively 2.7) and later.  */
+# if __GNUC__ < 2 || (__GNUC__ == 2 && __GNUC_MINOR__ < 7)
+#  define __format__ format
+#  define __printf__ printf
+# endif
+#endif
+
+#if defined(__STDC__) || defined(HAVE_STDARG_H)
+# include <stdarg.h>
+extern void    msyslog         P((int, const char *, ...))
+                               __attribute__((__format__(__printf__, 2, 3)));
+extern void    netsyslog       P((int, const char *, ...))
+                               __attribute__((__format__(__printf__, 2, 3)));
+#else
+# include <varargs.h>
+extern void msyslog            P(());
+extern void netsyslog          P(());
+#endif
+
+extern void    auth_delkeys    P((void));
+extern int     auth_havekey    P((keyid_t));
+extern int     authdecrypt     P((keyid_t, u_int32 *, int, int));
+extern int     authencrypt     P((keyid_t, u_int32 *, int));
+extern int     authhavekey     P((keyid_t));
+extern int     authistrusted   P((keyid_t));
+extern int     authreadkeys    P((const char *));
+extern void    authtrust       P((keyid_t, u_long));
+extern int     authusekey      P((keyid_t, int, const u_char *));
+
+extern u_long  calyearstart    P((u_long));
+extern const char *clockname   P((int));
+extern int     clocktime       P((int, int, int, int, int, u_long, u_long *, u_int32 *));
+#if defined SYS_WINNT && defined DEBUG
+# define emalloc(_c) debug_emalloc(_c, __FILE__, __LINE__)
+extern void *  debug_emalloc           P((u_int, char *, int));
+#else
+extern void *  emalloc         P((u_int));
+#endif
+extern int     ntp_getopt      P((int, char **, const char *));
+extern void    init_auth       P((void));
+extern void    init_lib        P((void));
+extern struct savekey *auth_findkey P((keyid_t));
+extern int     auth_moremem    P((void));
+extern int     ymd2yd          P((int, int, int));
+
+extern int     MD5authdecrypt  P((u_char *, u_int32 *, int, int));
+extern int     MD5authencrypt  P((u_char *, u_int32 *, int));
+extern void    MD5auth_setkey  P((keyid_t, const u_char *, const int));
+extern u_int32 addr2refid      P((struct sockaddr_storage *));
+
+extern int     atoint          P((const char *, long *));
+extern int     atouint         P((const char *, u_long *));
+extern int     hextoint        P((const char *, u_long *));
+extern char *  humandate       P((u_long));
+extern char *  humanlogtime    P((void));
+extern char *  inttoa          P((long));
+extern char *  mfptoa          P((u_long, u_long, short));
+extern char *  mfptoms         P((u_long, u_long, short));
+extern const char * modetoa    P((int));
+extern  const char * eventstr   P((int));
+extern  const char * ceventstr  P((int));
+extern char *  statustoa       P((int, int));
+extern  const char * sysstatstr P((int));
+extern  const char * peerstatstr P((int));
+extern  const char * clockstatstr P((int));
+extern struct sockaddr_storage* netof P((struct sockaddr_storage*));
+extern char *  numtoa          P((u_int32));
+extern char *  numtohost       P((u_int32));
+extern char * socktoa           P((struct sockaddr_storage *));
+extern char * socktohost        P((struct sockaddr_storage *));
+extern int     octtoint        P((const char *, u_long *));
+extern u_long  ranp2           P((int));
+extern char *  refnumtoa       P((struct sockaddr_storage *));
+extern int     tsftomsu        P((u_long, int));
+extern char *  uinttoa         P((u_long));
+
+extern int     decodenetnum    P((const char *, struct sockaddr_storage *));
+
+extern const char *    FindConfig      P((const char *));
+
+extern void    signal_no_reset P((int, RETSIGTYPE (*func)(int)));
+
+extern void    getauthkeys     P((const char *));
+extern void    auth_agekeys    P((void));
+extern void    rereadkeys      P((void));
+
+/*
+ * Variable declarations for libntp.
+ */
+
+/*
+ * Defined by any program.
+ */
+extern volatile int debug;             /* debugging flag */
+
+/* authkeys.c */
+extern u_long  authkeynotfound;        /* keys not found */
+extern u_long  authkeylookups;         /* calls to lookup keys */
+extern u_long  authnumkeys;            /* number of active keys */
+extern u_long  authkeyexpired;         /* key lifetime expirations */
+extern u_long  authkeyuncached;        /* cache misses */
+extern u_long  authencryptions;        /* calls to encrypt */
+extern u_long  authdecryptions;        /* calls to decrypt */
+
+extern int     authnumfreekeys;
+
+/*
+ * The key cache. We cache the last key we looked at here.
+ */
+extern keyid_t cache_keyid;            /* key identifier */
+extern u_char *        cache_key;              /* key pointer */
+extern u_int   cache_keylen;           /* key length */
+
+/* getopt.c */
+extern char *  ntp_optarg;             /* global argument pointer */
+extern int     ntp_optind;             /* global argv index */
+
+/* machines.c */
+extern const char *set_tod_using;
+
+/* mexit.c */
+#if defined SYS_WINNT || defined SYS_CYGWIN32
+extern HANDLE  hServDoneEvent;
+#endif
+
+/* systime.c */
+extern double  sys_tick;               /* adjtime() resolution */
+
+/* version.c */
+extern const char *Version;            /* version declaration */
diff --git a/include/ntp_string.h b/include/ntp_string.h
new file mode 100644 (file)
index 0000000..f7f0092
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Define string ops: strchr strrchr memcmp memmove memset 
+ */
+
+#ifndef  _ntp_string_h
+#define  _ntp_string_h
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_MEMORY_H
+# include <memory.h>
+#endif
+
+#ifdef HAVE_STRING_H
+# include <string.h>
+#endif
+
+#ifdef HAVE_BSTRING_H
+# include <bstring.h>
+#endif
+
+#ifndef STDC_HEADERS
+# ifndef HAVE_STRCHR
+#  include <strings.h>
+#  define strchr index
+#  define strrchr rindex
+# endif
+# ifndef __GNUC__
+char *strchr(), *strrchr();
+# endif
+# ifndef HAVE_MEMCPY
+#  define NTP_NEED_BOPS
+# endif
+#endif /* STDC_HEADERS */
+
+#ifdef NTP_NEED_BOPS
+# define memcmp(a,b,c) bcmp(a,b,(int)c)
+# define memmove(t,f,c) bcopy(f,t,(int)c)
+# define memcpy(t,f,c) bcopy(f,t,(int)c)
+# define memset(a,x,c) if (x == 0x00) bzero(a,(int)c); else ntp_memset((char*)a,x,c)
+
+void ntp_memset P((char *, int, int));
+
+#endif /*  NTP_NEED_BOPS */
+
+#endif /* _ntp_string_h */
diff --git a/include/ntp_syscall.h b/include/ntp_syscall.h
new file mode 100644 (file)
index 0000000..521e753
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * ntp_syscall.h - various ways to perform the ntp_adjtime() and ntp_gettime()
+ *                system calls.
+ */
+
+#ifndef NTP_SYSCALL_H
+#define NTP_SYSCALL_H
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef HAVE_SYS_TIMEX_H
+# include <sys/timex.h>
+#endif
+
+#ifndef NTP_SYSCALLS_LIBC
+#ifdef NTP_SYSCALLS_STD
+# define ntp_adjtime(t)                syscall(SYS_ntp_adjtime, (t))
+# define ntp_gettime(t)                syscall(SYS_ntp_gettime, (t))
+#else /* !NTP_SYSCALLS_STD */
+# ifdef HAVE___ADJTIMEX
+extern int     __adjtimex      P((struct timex *));
+
+#  define ntp_adjtime(t)       __adjtimex((t))
+
+static inline int
+ntp_gettime(
+       struct ntptimeval *ntv
+       )
+{
+       struct timex tntx;
+       int result;
+
+       tntx.modes = 0;
+       result = __adjtimex (&tntx);
+       ntv->time = tntx.time;
+       ntv->maxerror = tntx.maxerror;
+       ntv->esterror = tntx.esterror;
+#ifdef NTP_API
+# if NTP_API > 3
+       ntv->tai = tntx.tai;
+# endif
+#endif
+       return(result);
+}
+# else /* !HAVE__ADJTIMEX */
+#  ifdef HAVE___NTP_GETTIME
+#   define ntp_gettime(t)      __ntp_gettime((t))
+#  endif
+# endif /* !HAVE_ADJTIMEX */
+#endif /* !NTP_SYSCALLS_STD */
+#endif /* !NTP_SYSCALLS_LIBC */
+
+#endif /* NTP_SYSCALL_H */
diff --git a/include/ntp_syslog.h b/include/ntp_syslog.h
new file mode 100644 (file)
index 0000000..38021e2
--- /dev/null
@@ -0,0 +1,70 @@
+/*
+ * A hack for platforms which require specially built syslog facilities
+ */
+
+#ifndef NTP_SYSLOG_H
+#define NTP_SYSLOG_H
+
+# ifdef VMS
+extern void msyslog();
+# else
+#   ifndef SYS_VXWORKS
+#   include <syslog.h>
+#   endif
+# endif /* VMS */
+# include <stdio.h>
+
+extern int syslogit;
+extern FILE *syslog_file;
+
+#if defined(VMS) || defined (SYS_VXWORKS)
+#define        LOG_EMERG       0       /* system is unusable */
+#define        LOG_ALERT       1       /* action must be taken immediately */
+#define        LOG_CRIT        2       /* critical conditions */
+#define        LOG_ERR         3       /* error conditions */
+#define        LOG_WARNING     4       /* warning conditions */
+#define        LOG_NOTICE      5       /* normal but signification condition */
+#define        LOG_INFO        6       /* informational */
+#define        LOG_DEBUG       7       /* debug-level messages */
+#endif /* VMS || VXWORKS */
+
+/*
+ * syslog output control
+ */
+#define NLOG_INFO              0x00000001
+#define NLOG_EVENT             0x00000002
+#define NLOG_STATUS            0x00000004
+#define NLOG_STATIST           0x00000008
+
+#define NLOG_OSYS                       0 /* offset for system flags */
+#define NLOG_SYSMASK           0x0000000F /* system log events */
+#define NLOG_SYSINFO           0x00000001 /* system info log events */
+#define NLOG_SYSEVENT          0x00000002 /* system events */
+#define NLOG_SYSSTATUS         0x00000004 /* system status (sync/unsync) */
+#define NLOG_SYSSTATIST                0x00000008 /* system statistics output */
+
+#define NLOG_OPEER                      4 /* offset for peer flags */
+#define NLOG_PEERMASK          0x000000F0 /* peer log events */
+#define NLOG_PEERINFO          0x00000010 /* peer info log events */
+#define NLOG_PEEREVENT         0x00000020 /* peer events */
+#define NLOG_PEERSTATUS                0x00000040 /* peer status (sync/unsync) */
+#define NLOG_PEERSTATIST       0x00000080 /* peer statistics output */
+
+#define NLOG_OCLOCK                     8 /* offset for clock flags */
+#define NLOG_CLOCKMASK         0x00000F00 /* clock log events */
+#define NLOG_CLOCKINFO         0x00000100 /* clock info log events */
+#define NLOG_CLOCKEVENT                0x00000200 /* clock events */
+#define NLOG_CLOCKSTATUS       0x00000400 /* clock status (sync/unsync) */
+#define NLOG_CLOCKSTATIST      0x00000800 /* clock statistics output */
+
+#define NLOG_OSYNC                     12 /* offset for sync flags */
+#define NLOG_SYNCMASK          0x0000F000 /* sync log events */
+#define NLOG_SYNCINFO          0x00001000 /* sync info log events */
+#define NLOG_SYNCEVENT         0x00002000 /* sync events */
+#define NLOG_SYNCSTATUS                0x00004000 /* sync status (sync/unsync) */
+#define NLOG_SYNCSTATIST       0x00008000 /* sync statistics output */
+
+extern unsigned long ntp_syslogmask;
+#define NLOG(_X_)      if (ntp_syslogmask & (_X_))
+
+#endif /* NTP_SYSLOG_H */
diff --git a/include/ntp_tty.h b/include/ntp_tty.h
new file mode 100644 (file)
index 0000000..9833119
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * ntp_tty.h - header file for serial lines handling
+ */
+
+#ifndef NTP_TTY_H
+#define NTP_TTY_H
+
+#if defined(HAVE_BSD_TTYS)
+#include <sgtty.h>
+#define TTY    struct sgttyb
+#endif /* HAVE_BSD_TTYS */
+
+#if defined(HAVE_SYSV_TTYS)
+#include <termio.h>
+#define TTY    struct termio
+#ifndef tcsetattr
+#define tcsetattr(fd, cmd, arg) ioctl(fd, cmd, arg)
+#endif
+#ifndef TCSANOW
+#define TCSANOW        TCSETA
+#endif
+#ifndef TCIFLUSH
+#define TCIFLUSH 0
+#endif
+#ifndef TCOFLUSH
+#define TCOFLUSH 1
+#endif
+#ifndef TCIOFLUSH
+#define TCIOFLUSH 2
+#endif
+#ifndef tcflush
+#define tcflush(fd, arg) ioctl(fd, TCFLSH, arg)
+#endif
+#endif /* HAVE_SYSV_TTYS */
+
+#if defined(HAVE_TERMIOS)
+# ifdef TERMIOS_NEEDS__SVID3
+#  define _SVID3
+# endif
+# include <termios.h>
+# ifdef TERMIOS_NEEDS__SVID3
+#  undef _SVID3
+# endif
+#define TTY    struct termios
+#endif
+
+#if defined(HAVE_SYS_MODEM_H)
+#include <sys/modem.h>
+#endif
+
+#if !defined(SYSV_TTYS) && !defined(STREAM) & !defined(BSD_TTYS)
+#define BSD_TTYS
+#endif /* SYSV_TTYS STREAM BSD_TTYS */
+
+#endif /* NTP_TTY_H */
diff --git a/include/ntp_types.h b/include/ntp_types.h
new file mode 100644 (file)
index 0000000..0b575c8
--- /dev/null
@@ -0,0 +1,80 @@
+/*
+ *  ntp_types.h - defines how int32 and u_int32 are treated.
+ *  For 64 bit systems like the DEC Alpha, they have to be defined
+ *  as int and u_int.
+ *  For 32 bit systems, define them as long and u_long
+ */
+#include <sys/types.h>
+#include "ntp_machine.h"
+
+#ifndef _NTP_TYPES_
+#define _NTP_TYPES_
+
+/*
+ * This is another naming conflict.
+ * On NetBSD for MAC the macro "mac" is defined as 1
+ * this is fun for us as a packet structure contains an
+ * optional "mac" member - severe confusion results 8-)
+ * As we hopefully do not have to rely on that macro we
+ * just undefine that.
+ */
+#ifdef mac
+#undef mac
+#endif
+
+/*
+ * Set up for prototyping
+ */
+#ifndef P
+#if defined(__STDC__) || defined(HAVE_PROTOTYPES)
+#define        P(x)    x
+#else /* not __STDC__ and not HAVE_PROTOTYPES */
+#define P(x)   ()
+#endif /* not __STDC__ and HAVE_PROTOTYPES */
+#endif /* P */
+
+/*
+ * VMS DECC (v4.1), {u_char,u_short,u_long} are only in SOCKET.H,
+ *                     and u_int isn't defined anywhere
+ */
+#if defined(VMS)
+#include <socket.h>
+typedef unsigned int u_int;
+/*
+ * Note: VMS DECC has  long == int  (even on __alpha),
+ *      so the distinction below doesn't matter
+ */
+#endif /* VMS */
+
+#if (SIZEOF_INT == 4)
+# ifndef int32
+#  define int32 int
+# endif
+# ifndef u_int32
+#  define u_int32 unsigned int
+# endif
+#else /* not sizeof(int) == 4 */
+# if (SIZEOF_LONG == 4)
+# else /* not sizeof(long) == 4 */
+#  ifndef int32
+#   define int32 long
+#  endif
+#  ifndef u_int32
+#   define u_int32 unsigned long
+#  endif
+# endif /* not sizeof(long) == 4 */
+# include "Bletch: what's 32 bits on this machine?"
+#endif /* not sizeof(int) == 4 */
+
+typedef u_char         ntp_u_int8_t;
+typedef u_short                ntp_u_int16_t;
+typedef u_int32                ntp_u_int32_t;
+
+typedef struct ntp_uint64_t { u_int32 val[2]; } ntp_uint64_t;
+
+typedef unsigned short associd_t; /* association ID */
+typedef u_int32 keyid_t;       /* cryptographic key ID */
+typedef u_int32 tstamp_t;      /* NTP seconds timestamp */
+
+#endif /* _NTP_TYPES_ */
+
diff --git a/include/ntp_unixtime.h b/include/ntp_unixtime.h
new file mode 100644 (file)
index 0000000..ce96980
--- /dev/null
@@ -0,0 +1,141 @@
+/*
+ * ntp_unixtime.h - contains constants and macros for converting between
+ *                 NTP time stamps (l_fp) and Unix times (struct timeval)
+ */
+
+#include "ntp_types.h"
+
+#ifdef SIM
+#include "ntpsim.h"
+#endif
+
+#ifdef SIM
+#   define GETTIMEOFDAY(a, b) (node_gettime(&ntp_node, a))
+#   define SETTIMEOFDAY(a, b) (node_settime(&ntp_node, a))
+#   define ADJTIMEOFDAY(a, b) (node_adjtime(&ntp_node, a, b))
+#else
+#   define ADJTIMEOFDAY(a, b) (adjtime(a, b))
+/* gettimeofday() takes two args in BSD and only one in SYSV */
+# if defined(HAVE_SYS_TIMERS_H) && defined(HAVE_GETCLOCK)
+#  include <sys/timers.h>
+int getclock (int clock_type, struct timespec *tp);
+/* Don't #define GETTIMEOFDAY because we shouldn't be using it in this case. */
+#   define SETTIMEOFDAY(a, b) (settimeofday(a, b))
+# else /* not (HAVE_SYS_TIMERS_H && HAVE_GETCLOCK) */
+#  ifdef SYSV_TIMEOFDAY
+#   define GETTIMEOFDAY(a, b) (gettimeofday(a))
+#   define SETTIMEOFDAY(a, b) (settimeofday(a))
+#  else /* ! SYSV_TIMEOFDAY */
+#if defined SYS_CYGWIN32
+#   define GETTIMEOFDAY(a, b) (gettimeofday(a, b))
+#   define SETTIMEOFDAY(a, b) (settimeofday_NT(a))
+#else
+#   define GETTIMEOFDAY(a, b) (gettimeofday(a, b))
+#   define SETTIMEOFDAY(a, b) (settimeofday(a, b))
+#endif
+#  endif /* SYSV_TIMEOFDAY */
+# endif /* not (HAVE_SYS_TIMERS_H && HAVE_GETCLOCK) */
+#endif /* SIM */
+
+/*
+ * Time of day conversion constant.  Ntp's time scale starts in 1900,
+ * Unix in 1970.
+ */
+#define        JAN_1970        0x83aa7e80      /* 2208988800 1970 - 1900 in seconds */
+
+/*
+ * These constants are used to round the time stamps computed from
+ * a struct timeval to the microsecond (more or less).  This keeps
+ * things neat.
+ */
+#define        TS_MASK         0xfffff000      /* mask to usec, for time stamps */
+#define        TS_ROUNDBIT     0x00000800      /* round at this bit */
+
+
+/*
+ * Convert usec to a time stamp fraction.  If you use this the program
+ * must include the following declarations:
+ */
+extern u_long ustotslo[];
+extern u_long ustotsmid[];
+extern u_long ustotshi[];
+
+#define        TVUTOTSF(tvu, tsf) \
+       (tsf) = ustotslo[(tvu) & 0xff] \
+           + ustotsmid[((tvu) >> 8) & 0xff] \
+           + ustotshi[((tvu) >> 16) & 0xf]
+
+/*
+ * Convert a struct timeval to a time stamp.
+ */
+#define TVTOTS(tv, ts) \
+       do { \
+               (ts)->l_ui = (u_long)(tv)->tv_sec; \
+               TVUTOTSF((tv)->tv_usec, (ts)->l_uf); \
+       } while(0)
+
+#define sTVTOTS(tv, ts) \
+       do { \
+               int isneg = 0; \
+               long usec; \
+               (ts)->l_ui = (tv)->tv_sec; \
+               usec = (tv)->tv_usec; \
+               if (((tv)->tv_sec < 0) || ((tv)->tv_usec < 0)) { \
+                       usec = -usec; \
+                       (ts)->l_ui = -(ts)->l_ui; \
+                       isneg = 1; \
+               } \
+               TVUTOTSF(usec, (ts)->l_uf); \
+               if (isneg) { \
+                       L_NEG((ts)); \
+               } \
+       } while(0)
+
+/*
+ * TV_SHIFT is used to turn the table result into a usec value.  To round,
+ * add in TV_ROUNDBIT before shifting
+ */
+#define        TV_SHIFT        3
+#define        TV_ROUNDBIT     0x4
+
+
+/*
+ * Convert a time stamp fraction to microseconds.  The time stamp
+ * fraction is assumed to be unsigned.  To use this in a program, declare:
+ */
+extern long tstouslo[];
+extern long tstousmid[];
+extern long tstoushi[];
+
+#define        TSFTOTVU(tsf, tvu) \
+       (tvu) = (tstoushi[((tsf) >> 24) & 0xff] \
+           + tstousmid[((tsf) >> 16) & 0xff] \
+           + tstouslo[((tsf) >> 9) & 0x7f] \
+           + TV_ROUNDBIT) >> TV_SHIFT
+/*
+ * Convert a time stamp to a struct timeval.  The time stamp
+ * has to be positive.
+ */
+#define        TSTOTV(ts, tv) \
+       do { \
+               (tv)->tv_sec = (ts)->l_ui; \
+               TSFTOTVU((ts)->l_uf, (tv)->tv_usec); \
+               if ((tv)->tv_usec == 1000000) { \
+                       (tv)->tv_sec++; \
+                       (tv)->tv_usec = 0; \
+               } \
+       } while (0)
+
+/*
+ * Convert milliseconds to a time stamp fraction.  This shouldn't be
+ * here, but it is convenient since the guys who use the definition will
+ * often be including this file anyway.
+ */
+extern u_long msutotsflo[];
+extern u_long msutotsfhi[];
+
+#define        MSUTOTSF(msu, tsf) \
+       (tsf) = msutotsfhi[((msu) >> 5) & 0x1f] + msutotsflo[(msu) & 0x1f]
+
+extern char *  tvtoa           P((const struct timeval *));
+extern char *  utvtoa          P((const struct timeval *));
diff --git a/include/ntpd.h b/include/ntpd.h
new file mode 100644 (file)
index 0000000..d095719
--- /dev/null
@@ -0,0 +1,472 @@
+/*
+ * ntpd.h - Prototypes for ntpd.
+ */
+
+#include "ntp_syslog.h"
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntp_debug.h"
+#include "ntp_select.h"
+#include "ntp_malloc.h"
+#include "ntp_refclock.h"
+#include "recvbuff.h"
+
+
+/* ntp_config.c */
+extern void    getconfig       P((int, char **));
+
+/* ntp_config.c */
+extern void    ctl_clr_stats   P((void));
+extern int     ctlclrtrap      P((struct sockaddr_storage *, struct interface *, int));
+extern u_short ctlpeerstatus   P((struct peer *));
+extern int     ctlsettrap      P((struct sockaddr_storage *, struct interface *, int, int));
+extern u_short ctlsysstatus    P((void));
+extern void    init_control    P((void));
+extern void    process_control P((struct recvbuf *, int));
+extern void    report_event    P((int, struct peer *));
+
+extern double  fabs            P((double));
+extern double  sqrt            P((double));
+
+/* ntp_control.c */
+/*
+ * Structure for translation tables between internal system
+ * variable indices and text format.
+ */
+struct ctl_var {
+       u_short code;
+       u_short flags;
+       char *text;
+};
+/*
+ * Flag values
+ */
+#define        CAN_READ        0x01
+#define        CAN_WRITE       0x02
+
+#define DEF            0x20
+#define        PADDING         0x40
+#define        EOV             0x80
+
+#define        RO      (CAN_READ)
+#define        WO      (CAN_WRITE)
+#define        RW      (CAN_READ|CAN_WRITE)
+
+extern  char *  add_var P((struct ctl_var **, u_long, u_short));
+extern  void    free_varlist P((struct ctl_var *));
+extern  void    set_var P((struct ctl_var **, const char *, u_long, u_short));
+extern  void    set_sys_var P((const char *, u_long, u_short));
+
+/* ntp_intres.c */
+extern void    ntp_res_name    P((struct sockaddr_storage, u_short));
+extern void    ntp_res_recv    P((void));
+extern void    ntp_intres      P((void));
+
+/* ntp_io.c */
+typedef struct interface_info {
+       struct interface *interface;
+       u_char       action;
+} interface_info_t;
+
+typedef void (*interface_receiver_t)(void *, interface_info_t *);
+
+extern  volatile int disable_dynamic_updates;
+
+extern  void    interface_enumerate P((interface_receiver_t, void *));
+extern struct interface *findinterface P((struct sockaddr_storage *));
+extern  struct interface *findbcastinter P((struct sockaddr_storage *));
+extern  void   enable_broadcast P((struct interface *, struct sockaddr_storage *));
+extern  void   enable_multicast_if P((struct interface *, struct sockaddr_storage *));
+extern void    interface_dump   P((struct interface *));
+
+extern  void    interface_update P((interface_receiver_t, void *));
+extern void    init_io         P((void));
+extern void    input_handler   P((l_fp *));
+extern void    io_clr_stats    P((void));
+extern void    io_setbclient   P((void));
+extern void    io_unsetbclient P((void));
+extern void    io_multicast_add P((struct sockaddr_storage));
+extern void    io_multicast_del P((struct sockaddr_storage));
+extern void    kill_asyncio     P((int));
+extern void    sendpkt         P((struct sockaddr_storage *, struct interface *, int, struct pkt *, int));
+#ifdef DEBUG
+extern  void    collect_timing  P((struct recvbuf *, const char *, int, l_fp *));
+#endif
+#ifdef HAVE_SIGNALED_IO
+extern void    wait_for_signal P((void));
+extern void    unblock_io_and_alarm P((void));
+extern void    block_io_and_alarm P((void));
+#define UNBLOCK_IO_AND_ALARM() unblock_io_and_alarm()
+#define BLOCK_IO_AND_ALARM() block_io_and_alarm()
+#else
+#define UNBLOCK_IO_AND_ALARM()
+#define BLOCK_IO_AND_ALARM()
+#endif
+
+/* ntp_leap.c */
+extern void    init_leap       P((void));
+extern void    leap_process    P((void));
+extern int     leap_setleap    P((int, int));
+/*
+ * there seems to be a bug in the IRIX 4 compiler which prevents
+ * u_char from beeing used in prototyped functions.
+ * This is also true AIX compiler.
+ * So give up and define it to be int. WLJ
+ */
+extern int     leap_actual P((int));
+
+/* ntp_loopfilter.c */
+extern void    init_loopfilter P((void));
+extern int     local_clock P((struct peer *, double));
+extern void    adj_host_clock  P((void));
+extern void    loop_config P((int, double));
+extern void    huffpuff        P((void));
+extern u_long  sys_clocktime;
+extern u_long  sys_tai;
+
+/* ntp_monitor.c */
+extern void    init_mon        P((void));
+extern void    mon_start       P((int));
+extern void    mon_stop        P((int));
+extern int     ntp_monitor     P((struct recvbuf *));
+extern  void    ntp_monclearinterface P((struct interface *interface));
+
+/* ntp_peer.c */
+extern void    init_peer       P((void));
+extern struct peer *findexistingpeer P((struct sockaddr_storage *, struct peer *, int));
+extern struct peer *findpeer   P((struct sockaddr_storage *, struct interface *, int, int *));
+extern struct peer *findpeerbyassoc P((u_int));
+extern  void         set_peerdstadr       P((struct peer *peer, struct interface *interface));
+extern struct peer *newpeer    P((struct sockaddr_storage *, struct interface *, int, int, int, int, u_int, u_char, int, keyid_t));
+extern void    peer_all_reset  P((void));
+extern void    peer_clr_stats  P((void));
+extern struct peer *peer_config P((struct sockaddr_storage *, struct interface *, int, int, int, int, u_int, int, keyid_t, u_char *));
+extern void    peer_reset      P((struct peer *));
+extern int     peer_unconfig   P((struct sockaddr_storage *, struct interface *, int));
+extern  void    refresh_all_peerinterfaces P((void));
+extern void    unpeer          P((struct peer *));
+extern void    clear_all       P((void));
+
+#ifdef OPENSSL
+extern void    expire_all      P((void));
+#endif /* OPENSSL */
+extern struct  peer *findmanycastpeer  P((struct recvbuf *));
+
+/* ntp_crypto.c */
+#ifdef OPENSSL
+extern int     crypto_recv     P((struct peer *, struct recvbuf *));
+extern int     crypto_xmit     P((struct pkt *, struct sockaddr_storage *, int, struct exten *, keyid_t));
+extern keyid_t session_key     P((struct sockaddr_storage *, struct sockaddr_storage *, keyid_t, keyid_t, u_long));
+extern int     make_keylist    P((struct peer *, struct interface *));
+extern void    key_expire      P((struct peer *));
+extern void    crypto_update   P((void));
+extern void    crypto_config   P((int, char *));
+extern void    crypto_setup    P((void));
+extern u_int   crypto_ident    P((struct peer *));
+extern struct exten *crypto_args P((struct peer *, u_int, char *));
+extern int     crypto_public   P((struct peer *, u_char *, u_int));
+extern void    value_free      P((struct value *));
+extern char    *iffpar_file;
+extern EVP_PKEY *iffpar_pkey;
+extern char    *gqpar_file;
+extern EVP_PKEY *gqpar_pkey;
+extern char    *mvpar_file;
+extern EVP_PKEY *mvpar_pkey;
+extern struct value tai_leap;
+#endif /* OPENSSL */
+
+/* ntp_proto.c */
+extern void    transmit        P((struct peer *));
+extern void    receive         P((struct recvbuf *));
+extern  void    peer_crypto_clear P((struct peer *peer));
+extern void    peer_clear      P((struct peer *, char *));
+extern void    process_packet  P((struct peer *, struct pkt *));
+extern void    clock_select    P((void));
+extern void    kod_proto       P((void));
+
+/*
+ * there seems to be a bug in the IRIX 4 compiler which prevents
+ * u_char from beeing used in prototyped functions.
+ * This is also true AIX compiler.
+ * So give up and define it to be int. WLJ
+ */
+extern void    poll_update P((struct peer *, int));
+
+extern void    clear           P((struct peer *));
+extern void    clock_filter    P((struct peer *, double, double, double));
+extern void    init_proto      P((void));
+extern void    proto_config    P((int, u_long, double, struct sockaddr_storage*));
+extern void    proto_clr_stats P((void));
+
+#ifdef REFCLOCK
+/* ntp_refclock.c */
+extern int     refclock_newpeer P((struct peer *));
+extern void    refclock_unpeer P((struct peer *));
+extern void    refclock_receive P((struct peer *));
+extern void    refclock_transmit P((struct peer *));
+extern void    init_refclock   P((void));
+#endif /* REFCLOCK */
+
+/* ntp_request.c */
+extern void    init_request    P((void));
+extern void    process_private P((struct recvbuf *, int));
+
+/* ntp_restrict.c */
+extern void    init_restrict   P((void));
+extern int     restrictions    P((struct sockaddr_storage *, int));
+extern void    hack_restrict   P((int, struct sockaddr_storage *, struct sockaddr_storage *, int, int));
+
+/* ntp_timer.c */
+extern void    init_timer      P((void));
+extern void    reinit_timer    P((void));
+extern void    timer           P((void));
+extern void    timer_clr_stats P((void));
+extern  void    timer_interfacetimeout P((u_long));
+extern  volatile int interface_interval;
+
+#ifdef OPENSSL
+extern char    *sys_hostname;
+extern l_fp    sys_revoketime;
+#endif /* OPENSSL */
+
+/* ntp_util.c */
+extern void    init_util       P((void));
+extern void    write_stats     P((void));
+extern void    stats_config    P((int, const char *));
+extern void    record_peer_stats P((struct sockaddr_storage *, int, double, double, double, double));
+extern void    record_loop_stats P((double, double, double, double, int));
+extern void    record_clock_stats P((struct sockaddr_storage *, const char *));
+extern void    record_raw_stats P((struct sockaddr_storage *, struct sockaddr_storage *, l_fp *, l_fp *, l_fp *, l_fp *));
+extern void    record_sys_stats P((void));
+extern void    record_crypto_stats P((struct sockaddr_storage *, const char *));
+#ifdef DEBUG
+extern void    record_timing_stats P((const char *));
+#endif
+extern  int    sock_hash P((struct sockaddr_storage *));
+extern double  old_drift;
+
+/*
+ * Variable declarations for ntpd.
+ */
+
+/* ntp_config.c */
+extern char const *    progname;
+extern char    *sys_phone[];           /* ACTS phone numbers */
+#if defined(HAVE_SCHED_SETSCHEDULER)
+extern int     config_priority_override;
+extern int     config_priority;
+#endif
+
+/* ntp_control.c */
+extern int     num_ctl_traps;
+extern keyid_t ctl_auth_keyid;         /* keyid used for authenticating write requests */
+
+/*
+ * Statistic counters to keep track of requests and responses.
+ */
+extern u_long  ctltimereset;           /* time stats reset */
+extern u_long  numctlreq;              /* number of requests we've received */
+extern u_long  numctlbadpkts;          /* number of bad control packets */
+extern u_long  numctlresponses;        /* number of resp packets sent with data */
+extern u_long  numctlfrags;            /* number of fragments sent */
+extern u_long  numctlerrors;           /* number of error responses sent */
+extern u_long  numctltooshort;         /* number of too short input packets */
+extern u_long  numctlinputresp;        /* number of responses on input */
+extern u_long  numctlinputfrag;        /* number of fragments on input */
+extern u_long  numctlinputerr;         /* number of input pkts with err bit set */
+extern u_long  numctlbadoffset;        /* number of input pkts with nonzero offset */
+extern u_long  numctlbadversion;       /* number of input pkts with unknown version */
+extern u_long  numctldatatooshort;     /* data too short for count */
+extern u_long  numctlbadop;            /* bad op code found in packet */
+extern u_long  numasyncmsgs;           /* number of async messages we've sent */
+
+/* ntp_intres.c */
+extern keyid_t req_keyid;              /* request keyid */
+extern char *  req_file;               /* name of the file with configuration info */
+#ifdef SYS_WINNT
+extern HANDLE ResolverEventHandle;
+#else
+extern int resolver_pipe_fd[2];  /* used to let the resolver process alert the parent process */
+#endif /* SYS_WINNT */
+
+/*
+ * Other statistics of possible interest
+ */
+extern volatile u_long packets_dropped;        /* total number of packets dropped on reception */
+extern volatile u_long packets_ignored;        /* packets received on wild card interface */
+extern volatile u_long packets_received;/* total number of packets received */
+extern u_long  packets_sent;           /* total number of packets sent */
+extern u_long  packets_notsent;        /* total number of packets which couldn't be sent */
+
+extern volatile u_long handler_calls;  /* number of calls to interrupt handler */
+extern volatile u_long handler_pkts;   /* number of pkts received by handler */
+extern u_long  io_timereset;           /* time counters were reset */
+
+/*
+ * Interface stuff
+ */
+extern struct interface *any_interface;        /* default ipv4 interface */
+extern struct interface *any6_interface;/* default ipv6 interface */
+extern struct interface *loopback_interface; /* loopback interface */
+
+/*
+ * File descriptor masks etc. for call to select
+ */
+extern fd_set  activefds;
+extern int     maxactivefd;
+
+/* ntp_loopfilter.c */
+extern double  drift_comp;             /* clock frequency (s/s) */
+extern double  clock_stability;        /* clock stability (s/s) */
+extern double  clock_max;              /* max offset before step (s) */
+extern double  clock_panic;            /* max offset before panic (s) */
+extern double  clock_phi;              /* dispersion rate (s/s) */
+extern double  clock_minstep;          /* step timeout (s) */
+extern u_long  pps_control;            /* last pps sample time */
+#ifdef KERNEL_PLL
+extern int     pll_status;             /* status bits for kernel pll */
+#endif /* KERNEL_PLL */
+
+/*
+ * Clock state machine control flags
+ */
+extern int     ntp_enable;             /* clock discipline enabled */
+extern int     pll_control;            /* kernel support available */
+extern int     kern_enable;            /* kernel support enabled */
+extern int     pps_enable;             /* kernel PPS discipline enabled */
+extern int     ext_enable;             /* external clock enabled */
+extern int     cal_enable;             /* refclock calibrate enable */
+extern int     allow_panic;            /* allow panic correction */
+extern int     mode_ntpdate;           /* exit on first clock set */
+extern int     peer_ntpdate;           /* count of ntpdate peers */
+
+/*
+ * Clock state machine variables
+ */
+extern u_char  sys_poll;               /* system poll interval (log2 s) */
+extern int     state;                  /* clock discipline state */
+extern int     tc_counter;             /* poll-adjust counter */
+extern u_long  last_time;              /* time of last clock update (s) */
+extern double  last_offset;            /* last clock offset (s) */
+extern double  allan_xpt;              /* Allan intercept (s) */
+extern double  clock_jitter;           /* clock jitter (s) */
+extern double  sys_jitter;             /* system jitter (s) */
+
+/* ntp_monitor.c */
+extern struct mon_data mon_mru_list;
+extern struct mon_data mon_fifo_list;
+extern int     mon_enabled;
+
+/* ntp_peer.c */
+extern struct peer *peer_hash[];       /* peer hash table */
+extern int     peer_hash_count[];      /* count of peers in each bucket */
+extern struct peer *assoc_hash[];      /* association ID hash table */
+extern int     assoc_hash_count[];
+extern int     peer_free_count;
+
+/*
+ * Miscellaneous statistic counters which may be queried.
+ */
+extern u_long  peer_timereset;         /* time stat counters were zeroed */
+extern u_long  findpeer_calls;         /* number of calls to findpeer */
+extern u_long  assocpeer_calls;        /* number of calls to findpeerbyassoc */
+extern u_long  peer_allocations;       /* number of allocations from the free list */
+extern u_long  peer_demobilizations;   /* number of structs freed to free list */
+extern int     total_peer_structs;     /* number of peer structs in circulation */
+extern int     peer_associations;      /* mobilized associations */
+extern int     peer_preempt;           /* preemptable associations */
+/* ntp_proto.c */
+/*
+ * System variables are declared here. See Section 3.2 of the
+ * specification.
+ */
+extern u_char  sys_leap;               /* system leap indicator */
+extern u_char  sys_stratum;            /* stratum of system */
+extern s_char  sys_precision;          /* local clock precision */
+extern double  sys_rootdelay;          /* distance to current sync source */
+extern double  sys_rootdispersion;     /* dispersion of system clock */
+extern u_int32 sys_refid;              /* reference source for local clock */
+extern l_fp    sys_reftime;            /* time we were last updated */
+extern struct peer *sys_peer;          /* our current peer */
+extern struct peer *sys_pps;           /* our current PPS peer */
+extern struct peer *sys_prefer;                /* our cherished peer */
+extern u_long  sys_automax;            /* maximum session key lifetime */
+
+/*
+ * Nonspecified system state variables.
+ */
+extern int     sys_bclient;            /* we set our time to broadcasts */
+extern double  sys_bdelay;             /* broadcast client default delay */
+extern int     sys_authenticate;       /* requre authentication for config */
+extern l_fp    sys_authdelay;          /* authentication delay */
+extern keyid_t sys_private;            /* private value for session seed */
+extern int     sys_manycastserver;     /* respond to manycast client pkts */
+extern int     sys_minclock;           /* minimum survivors */
+extern int     sys_minsane;            /* minimum candidates */
+extern int     sys_floor;              /* cluster stratum floor */
+extern int     sys_ceiling;            /* cluster stratum ceiling */
+extern u_char  sys_ttl[];              /* ttl mapping vector */
+extern int     sys_ttlmax;             /* max ttl mapping vector index */
+extern int     leap_next;              /* leap consensus */
+
+/*
+ * Statistics counters
+ */
+extern u_long  sys_stattime;           /* time when we started recording */
+extern u_long  sys_restricted;         /* restricted packets */
+extern u_long  sys_oldversionpkt;      /* old version packets */
+extern u_long  sys_newversionpkt;      /* new version packets  */
+extern u_long  sys_unknownversion;     /* don't know version packets */
+extern u_long  sys_badlength;          /* bad length or format */
+extern u_long  sys_processed;          /* packets processed */
+extern u_long  sys_badauth;            /* bad authentication */
+extern u_long  sys_limitrejected;      /* rate limit exceeded */
+extern u_long  sys_received;           /* packets received */
+
+/* ntp_refclock.c */
+#ifdef REFCLOCK
+#ifdef PPS
+extern int     fdpps;                  /* pps file descriptor */
+#endif /* PPS */
+#endif
+
+/* ntp_request.c */
+extern keyid_t info_auth_keyid;        /* keyid used to authenticate requests */
+
+/* ntp_restrict.c */
+extern struct restrictlist *restrictlist; /* the ipv4 restriction list */
+extern struct restrictlist6 *restrictlist6; /* the ipv6 restriction list */
+extern u_long  res_min_interval;
+extern u_long  res_avg_interval;
+extern u_long  mon_age;                /* monitor preempt age */
+
+/* ntp_timer.c */
+extern volatile int alarm_flag;                /* alarm flag */
+extern u_char  sys_revoke;             /* keys revoke timeout (log2 s) */
+extern volatile u_long alarm_overflow;
+extern u_long  current_time;           /* current time (s) */
+extern u_long  timer_timereset;
+extern u_long  timer_overflows;
+extern u_long  timer_xmtcalls;
+
+/* ntp_util.c */
+extern int     stats_control;          /* write stats to fileset? */
+extern int     stats_write_period;     /* # of seconds between writes. */
+extern double  stats_write_tolerance;
+
+/* ntpd.c */
+extern volatile int debug;             /* debugging flag */
+extern int     nofork;                 /* no-fork flag */
+extern int     initializing;           /* initializing flag */
+#ifdef HAVE_DROPROOT
+extern int droproot;                   /* flag: try to drop root privileges after startup */
+extern char *user;                     /* user to switch to */
+extern char *group;                    /* group to switch to */
+extern char *chrootdir;                        /* directory to chroot to */
+#endif
+
+/* refclock_conf.c */
+#ifdef REFCLOCK
+extern struct refclock *refclock_conf[]; /* refclock configuration table */
+extern u_char  num_refclock_conf;
+#endif
diff --git a/include/ntpsim.h b/include/ntpsim.h
new file mode 100644 (file)
index 0000000..c48dc59
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * ntpsim.h - Prototypes for ntpsim
+ */
+
+#ifndef __ntpsim_h
+#define __ntpsim_h
+
+#include <stdio.h>
+#include <math.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include "ntp_syslog.h"
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntp_select.h"
+#include "ntp_malloc.h"
+#include "ntp_refclock.h"
+#include "recvbuff.h"
+#include "ntp_io.h"
+#include "ntp_stdlib.h"
+
+#define PI 3.1415926535
+
+/*
+ * ntpsim declarations
+ */
+typedef enum {
+        BEEP, CLOCK, TIMER, PACKET
+} funcTkn;
+
+typedef struct {
+        double time;
+        union {
+                struct pkt evnt_pkt;
+               struct recvbuf evnt_buf;
+        } buffer;
+#define ntp_pkt buffer.evnt_pkt
+#define rcv_buf buffer.evnt_buf
+        funcTkn function;
+} Event;
+
+typedef struct List {
+        Event event;
+        struct List *next;
+} *Queue;
+
+typedef struct nde {
+        double time;                   /* simulation time */
+       double  sim_time;               /* end simulation time */
+       double  ntp_time;               /* client disciplined time */
+       double  adj;                    /* remaining time correction */
+       double  slew;                   /* correction slew rate */
+
+       double  clk_time;               /* server time */
+       double  ferr;                   /* frequency errort */
+       double  fnse;                   /* random walk noise */
+       double  ndly;                   /* network delay */
+       double  snse;                   /* phase noise */
+       double  pdly;                   /* processing delay */
+       double  bdly;                   /* beep interval */
+
+       double  last_time;              /* last clock read time */
+        Queue  events;                 /* Node Event Queue */
+       struct recvbuf *rbuflist;       /* Node Receive Buffer */
+} Node;
+
+/*
+ * Function prototypes
+ */
+int    ntpsim          P((int argc, char *argv[]));
+Event  event           P((double, funcTkn));
+Queue  queue           P((Event, Queue ));
+Node   node            P((void));
+void   push            P((Event, Queue *));
+Event  pop             P((Queue *));
+void   ndbeep          P((Node *, Event));
+void   ndeclk          P((Node *, Event));
+void   ntptmr          P((Node *, Event));
+void   netpkt          P((Node *, Event));
+int    srvr_rply       P((Node *, struct sockaddr_storage *,
+                           struct interface *, struct pkt *));
+double gauss           P((double, double));
+double poisson         P((double, double));
+int    node_clock      P((Node *, double));
+void   abortsim        P((char *));
+
+/*
+ * The global Node
+ */
+Node ntp_node;
+
+#endif
+
diff --git a/include/parse.h b/include/parse.h
new file mode 100644 (file)
index 0000000..8b4edcf
--- /dev/null
@@ -0,0 +1,421 @@
+/*
+ * /src/NTP/REPOSITORY/ntp4-dev/include/parse.h,v 4.12 2007/01/14 08:36:03 kardel RELEASE_20070114_A
+ *
+ * parse.h,v 4.12 2007/01/14 08:36:03 kardel RELEASE_20070114_A
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifndef __PARSE_H__
+#define __PARSE_H__
+#if    !(defined(lint) || defined(__GNUC__))
+  static char parsehrcsid[]="parse.h,v 4.12 2007/01/14 08:36:03 kardel RELEASE_20070114_A";
+#endif
+
+#include "ntp_types.h"
+
+#include "parse_conf.h"
+
+/*
+ * we use the following datastructures in two modes
+ * either in the NTP itself where we use NTP time stamps at some places
+ * or in the kernel, where only struct timeval will be used.
+ */
+#undef PARSEKERNEL
+#if defined(KERNEL) || defined(_KERNEL)
+#ifndef PARSESTREAM
+#define PARSESTREAM
+#endif
+#endif
+#if defined(PARSESTREAM) && defined(HAVE_SYS_STREAM_H)
+#define PARSEKERNEL
+#endif
+#ifdef PARSEKERNEL
+#ifndef _KERNEL
+extern caddr_t kmem_alloc P((unsigned int));
+extern caddr_t kmem_free P((caddr_t, unsigned int));
+extern unsigned int splx P((unsigned int));
+extern unsigned int splhigh P((void));
+extern unsigned int splclock P((void));
+#define MALLOC(_X_) (char *)kmem_alloc(_X_)
+#define FREE(_X_, _Y_) kmem_free((caddr_t)_X_, _Y_)
+#else
+#include <sys/kmem.h>
+#define MALLOC(_X_) (char *)kmem_alloc(_X_, KM_SLEEP)
+#define FREE(_X_, _Y_) kmem_free((caddr_t)_X_, _Y_)
+#endif
+#else
+#define MALLOC(_X_) malloc(_X_)
+#define FREE(_X_, _Y_) free(_X_)
+#endif
+
+#if defined(PARSESTREAM) && defined(HAVE_SYS_STREAM_H)
+#include <sys/stream.h>
+#include <sys/stropts.h>
+#else  /* STREAM */
+#include <stdio.h>
+#include "ntp_syslog.h"
+#ifdef DEBUG
+#define DD_PARSE 5
+#define DD_RAWDCF 4
+#define parseprintf(LEVEL, ARGS) if (debug > LEVEL) printf ARGS
+#else  /* DEBUG */
+#define parseprintf(LEVEL, ARGS)
+#endif /* DEBUG */
+#endif /* PARSESTREAM */
+
+#if defined(timercmp) && defined(__GNUC__)
+#undef timercmp
+#endif
+
+#if !defined(timercmp)
+#define        timercmp(tvp, uvp, cmp) \
+       ((tvp)->tv_sec cmp (uvp)->tv_sec || \
+        ((tvp)->tv_sec == (uvp)->tv_sec && (tvp)->tv_usec cmp (uvp)->tv_usec))
+#endif
+
+#ifndef TIMES10
+#define TIMES10(_X_)   (((_X_) << 3) + ((_X_) << 1))
+#endif
+
+/*
+ * state flags
+ */
+#define PARSEB_POWERUP            0x00000001 /* no synchronisation */
+#define PARSEB_NOSYNC             0x00000002 /* timecode currently not confirmed */
+
+/*
+ * time zone information
+ */
+#define PARSEB_ANNOUNCE           0x00000010 /* switch time zone warning (DST switch) */
+#define PARSEB_DST                0x00000020 /* DST in effect */
+#define PARSEB_UTC               0x00000040 /* UTC time */
+
+/*
+ * leap information
+ */
+#define PARSEB_LEAPDEL           0x00000100 /* LEAP deletion warning */
+#define PARSEB_LEAPADD           0x00000200 /* LEAP addition warning */
+#define PARSEB_LEAPS             0x00000300 /* LEAP warnings */
+#define PARSEB_LEAPSECOND        0x00000400 /* actual leap second */
+/*
+ * optional status information
+ */
+#define PARSEB_ALTERNATE         0x00001000 /* alternate antenna used */
+#define PARSEB_POSITION                  0x00002000 /* position available */
+#define PARSEB_MESSAGE            0x00004000 /* addtitional message data */
+/*
+ * feature information
+ */
+#define PARSEB_S_LEAP            0x00010000 /* supports LEAP */
+#define PARSEB_S_ANTENNA         0x00020000 /* supports antenna information */
+#define PARSEB_S_PPS             0x00040000 /* supports PPS time stamping */
+#define PARSEB_S_POSITION        0x00080000 /* supports position information (GPS) */
+
+/*
+ * time stamp availability
+ */
+#define PARSEB_TIMECODE                  0x10000000 /* valid time code sample */
+#define PARSEB_PPS               0x20000000 /* valid PPS sample */
+
+#define PARSE_TCINFO           (PARSEB_ANNOUNCE|PARSEB_POWERUP|PARSEB_NOSYNC|PARSEB_DST|\
+                                PARSEB_UTC|PARSEB_LEAPS|PARSEB_ALTERNATE|PARSEB_S_LEAP|\
+                                PARSEB_S_LOCATION|PARSEB_TIMECODE|PARSEB_MESSAGE)
+
+#define PARSE_POWERUP(x)        ((x) & PARSEB_POWERUP)
+#define PARSE_NOSYNC(x)         (((x) & (PARSEB_POWERUP|PARSEB_NOSYNC)) == PARSEB_NOSYNC)
+#define PARSE_SYNC(x)           (((x) & (PARSEB_POWERUP|PARSEB_NOSYNC)) == 0)
+#define PARSE_ANNOUNCE(x)       ((x) & PARSEB_ANNOUNCE)
+#define PARSE_DST(x)            ((x) & PARSEB_DST)
+#define PARSE_UTC(x)           ((x) & PARSEB_UTC)
+#define PARSE_LEAPADD(x)       (PARSE_SYNC(x) && (((x) & PARSEB_LEAPS) == PARSEB_LEAPADD))
+#define PARSE_LEAPDEL(x)       (PARSE_SYNC(x) && (((x) & PARSEB_LEAPS) == PARSEB_LEAPDEL))
+#define PARSE_ALTERNATE(x)     ((x) & PARSEB_ALTERNATE)
+#define PARSE_LEAPSECOND(x)    (PARSE_SYNC(x) && ((x) & PARSEB_LEAP_SECOND))
+
+#define PARSE_S_LEAP(x)                ((x) & PARSEB_S_LEAP)
+#define PARSE_S_ANTENNA(x)     ((x) & PARSEB_S_ANTENNA)
+#define PARSE_S_PPS(x)         ((x) & PARSEB_S_PPS)
+#define PARSE_S_POSITION(x)    ((x) & PARSEB_S_POSITION)
+
+#define PARSE_TIMECODE(x)      ((x) & PARSEB_TIMECODE)
+#define PARSE_PPS(x)           ((x) & PARSEB_PPS)
+#define PARSE_POSITION(x)      ((x) & PARSEB_POSITION)
+#define PARSE_MESSAGE(x)       ((x) & PARSEB_MESSAGE)
+
+/*
+ * operation flags - lower nibble contains fudge flags
+ */
+#define PARSE_TRUSTTIME     CLK_FLAG1  /* use flag1 to indicate the time2 references mean the trust time */
+#define PARSE_CLEAR         CLK_FLAG2  /* use flag2 to control pps on assert */
+#define PARSE_PPSKERNEL     CLK_FLAG3  /* use flag3 to bind PPS to kernel */
+#define PARSE_LEAP_DELETE   CLK_FLAG4  /* use flag4 to force leap deletion - only necessary when earth slows down */
+
+#define PARSE_FIXED_FMT     0x10  /* fixed format */
+#define PARSE_PPSCLOCK      0x20  /* try to get PPS time stamp via ppsclock ioctl */
+
+/*
+ * size of buffers
+ */
+#define PARSE_TCMAX        400   /* maximum addition data size */
+
+typedef union
+{
+  struct timeval tv;           /* timeval - kernel view */
+  l_fp           fp;           /* fixed point - ntp view */
+} timestamp_t;
+
+/*
+ * standard time stamp structure
+ */
+struct parsetime
+{
+  u_long  parse_status;        /* data status - CVT_OK, CVT_NONE, CVT_FAIL ... */
+  timestamp_t   parse_time;    /* PARSE timestamp */
+  timestamp_t   parse_stime;   /* telegram sample timestamp */
+  timestamp_t   parse_ptime;   /* PPS time stamp */
+  long           parse_usecerror;      /* sampled usec error */
+  u_long        parse_state;   /* current receiver state */
+  unsigned short parse_format; /* format code */
+  unsigned short parse_msglen; /* length of message */
+  unsigned char  parse_msg[PARSE_TCMAX]; /* original messages */
+};
+
+typedef struct parsetime parsetime_t;
+
+/*---------- STREAMS interface ----------*/
+
+#ifdef HAVE_SYS_STREAM_H
+/*
+ * ioctls
+ */
+#define PARSEIOC_ENABLE                (('D'<<8) + 'E')
+#define PARSEIOC_DISABLE       (('D'<<8) + 'D')
+#define PARSEIOC_SETFMT         (('D'<<8) + 'f')
+#define PARSEIOC_GETFMT                (('D'<<8) + 'F')
+#define PARSEIOC_SETCS         (('D'<<8) + 'C')
+#define PARSEIOC_TIMECODE      (('D'<<8) + 'T')
+
+#endif
+
+/*------ IO handling flags (sorry) ------*/
+
+#define PARSE_IO_CSIZE 0x00000003
+#define PARSE_IO_CS5   0x00000000
+#define PARSE_IO_CS6   0x00000001
+#define PARSE_IO_CS7   0x00000002 
+#define PARSE_IO_CS8   0x00000003 
+
+/*
+ * ioctl structure
+ */
+union parsectl 
+{
+  struct parsegettc
+    {
+      u_long         parse_state;      /* last state */
+      u_long         parse_badformat; /* number of bad packets since last query */
+      unsigned short parse_format;/* last decoded format */
+      unsigned short parse_count;      /* count of valid time code bytes */
+      char           parse_buffer[PARSE_TCMAX+1]; /* timecode buffer */
+    } parsegettc;
+
+  struct parseformat
+    {
+      unsigned short parse_format;/* number of examined format */
+      unsigned short parse_count;      /* count of valid string bytes */
+      char           parse_buffer[PARSE_TCMAX+1]; /* format code string */
+    } parseformat;
+
+  struct parsesetcs
+    {
+      u_long         parse_cs; /* character size (needed for stripping) */
+    } parsesetcs;
+};
+  
+typedef union parsectl parsectl_t;
+
+/*------ for conversion routines --------*/
+
+struct parse                   /* parse module local data */
+{
+  int            parse_flags;  /* operation and current status flags */
+  
+  int           parse_ioflags;    /* io handling flags (5-8 Bit control currently) */
+
+  /*
+   * private data - fixed format only
+   */
+  unsigned short parse_plen;   /* length of private data */
+  void          *parse_pdata;  /* private data pointer */
+
+  /*
+   * time code input buffer (from RS232 or PPS)
+   */
+  unsigned short parse_index;  /* current buffer index */
+  char          *parse_data;    /* data buffer */
+  unsigned short parse_dsize;  /* size of data buffer */
+  unsigned short parse_lformat;        /* last format used */
+  u_long         parse_lstate; /* last state code */
+  char          *parse_ldata;  /* last data buffer */
+  unsigned short parse_ldsize; /* last data buffer length */
+  u_long         parse_badformat;      /* number of unparsable pakets */
+  
+  timestamp_t    parse_lastchar; /* last time a character was received */
+  parsetime_t    parse_dtime;  /* external data prototype */
+};
+
+typedef struct parse parse_t;
+
+struct clocktime               /* clock time broken up from time code */
+{
+  long day;
+  long month;
+  long year;
+  long hour;
+  long minute;
+  long second;
+  long usecond;
+  long utcoffset;      /* in seconds */
+  time_t utctime;      /* the actual time - alternative to date/time */
+  u_long flags;                /* current clock status */
+};
+
+typedef struct clocktime clocktime_t;
+
+/*
+ * parser related return/error codes
+ */
+#define CVT_MASK        (unsigned)0x0000000F /* conversion exit code */
+#define   CVT_NONE      (unsigned)0x00000001 /* format not applicable */
+#define   CVT_FAIL      (unsigned)0x00000002 /* conversion failed - error code returned */
+#define   CVT_OK        (unsigned)0x00000004 /* conversion succeeded */
+#define   CVT_SKIP      (unsigned)0x00000008 /* conversion succeeded */
+#define CVT_ADDITIONAL   (unsigned)0x00000010 /* additional data is available */
+#define CVT_BADFMT      (unsigned)0x00000100 /* general format error - (unparsable) */
+#define CVT_BADDATE      (unsigned)0x00000200 /* date field incorrect */
+#define CVT_BADTIME     (unsigned)0x00000400 /* time field incorrect */
+
+/*
+ * return codes used by special input parsers
+ */
+#define PARSE_INP_SKIP  0x00   /* discard data - may have been consumed */
+#define PARSE_INP_TIME  0x01   /* time code assembled */
+#define PARSE_INP_PARSE 0x02   /* parse data using normal algorithm */
+#define PARSE_INP_DATA  0x04   /* additional data to pass up */
+#define PARSE_INP_SYNTH 0x08   /* just pass up synthesized time */
+
+/*
+ * PPS edge info
+ */
+#define SYNC_ZERO      0x00
+#define SYNC_ONE       0x01
+
+struct clockformat
+{
+  /* special input protocol - implies fixed format */
+  u_long       (*input)   P((parse_t *, unsigned int, timestamp_t *));
+  /* conversion routine */
+  u_long        (*convert) P((unsigned char *, int, struct format *, clocktime_t *, void *));
+  /* routine for handling RS232 sync events (time stamps) */
+  /* PPS input routine */
+  u_long        (*syncpps) P((parse_t *, int, timestamp_t *));
+  /* time code synthesizer */
+
+  void           *data;                /* local parameters */
+  const char     *name;                /* clock format name */
+  unsigned short  length;      /* maximum length of data packet */
+  unsigned short  plen;                /* length of private data - implies fixed format */
+};
+
+typedef struct clockformat clockformat_t;
+
+/*
+ * parse interface
+ */
+extern int  parse_ioinit P((parse_t *));
+extern void parse_ioend P((parse_t *));
+extern int  parse_ioread P((parse_t *, unsigned int, timestamp_t *));
+extern int  parse_iopps P((parse_t *, int, timestamp_t *));
+extern void parse_iodone P((parse_t *));
+extern int  parse_timecode P((parsectl_t *, parse_t *));
+extern int  parse_getfmt P((parsectl_t *, parse_t *));
+extern int  parse_setfmt P((parsectl_t *, parse_t *));
+extern int  parse_setcs P((parsectl_t *, parse_t *));
+
+extern unsigned int parse_restart P((parse_t *, unsigned int));
+extern unsigned int parse_addchar P((parse_t *, unsigned int));
+extern unsigned int parse_end P((parse_t *));
+
+extern int Strok P((const unsigned char *, const unsigned char *));
+extern int Stoi P((const unsigned char *, long *, int));
+
+extern time_t parse_to_unixtime P((clocktime_t *, u_long *));
+extern u_long updatetimeinfo P((parse_t *, u_long));
+extern void syn_simple P((parse_t *, timestamp_t *, struct format *, u_long));
+extern u_long pps_simple P((parse_t *, int, timestamp_t *));
+extern u_long pps_one P((parse_t *, int, timestamp_t *));
+extern u_long pps_zero P((parse_t *, int, timestamp_t *));
+extern int parse_timedout P((parse_t *, timestamp_t *, struct timeval *));
+
+#endif
+
+/*
+ * History:
+ *
+ * parse.h,v
+ * Revision 4.12  2007/01/14 08:36:03  kardel
+ * make timestamp union anonymous to avoid conflicts with
+ * some OSes that choose to create a nameing conflic here.
+ *
+ * Revision 4.11  2005/06/25 10:58:45  kardel
+ * add missing log keywords
+ *
+ * Revision 4.5  1998/08/09 22:23:32  kardel
+ * 4.0.73e2 adjustments
+ *
+ * Revision 4.4  1998/06/14 21:09:27  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.3  1998/06/13 11:49:25  kardel
+ * STREAM macro gone in favor of HAVE_SYS_STREAM_H
+ *
+ * Revision 4.2  1998/06/12 15:14:25  kardel
+ * fixed prototypes
+ *
+ * Revision 4.1  1998/05/24 10:07:59  kardel
+ * removed old data structure cruft (new input model)
+ * new PARSE_INP* macros for input handling
+ * removed old SYNC_* macros from old input model
+ * (struct clockformat): removed old parse functions in favor of the
+ * new input model
+ * updated prototypes
+ *
+ * form V3 3.31 - log info deleted 1998/04/11 kardel
+ */
diff --git a/include/parse_conf.h b/include/parse_conf.h
new file mode 100644 (file)
index 0000000..319dd54
--- /dev/null
@@ -0,0 +1,83 @@
+/*
+ * /src/NTP/ntp4-dev/include/parse_conf.h,v 4.7 2005/06/25 10:58:45 kardel RELEASE_20050625_A
+ *
+ * parse_conf.h,v 4.7 2005/06/25 10:58:45 kardel RELEASE_20050625_A
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifndef __PARSE_CONF_H__
+#define __PARSE_CONF_H__
+#if    !(defined(lint) || defined(__GNUC__))
+  static char prshrcsid[] = "parse_conf.h,v 4.7 2005/06/25 10:58:45 kardel RELEASE_20050625_A";
+#endif
+
+/*
+ * field location structure
+ */
+#define O_DAY  0
+#define O_MONTH 1
+#define O_YEAR 2
+#define O_HOUR 3
+#define O_MIN  4
+#define        O_SEC   5
+#define O_WDAY 6
+#define O_FLAGS 7
+#define O_ZONE  8
+#define O_UTCHOFFSET 9
+#define O_UTCMOFFSET 10
+#define O_UTCSOFFSET 11
+#define O_COUNT (O_UTCSOFFSET+1)
+
+#define MBG_EXTENDED   0x00000001
+
+/*
+ * see below for field offsets
+ */
+
+struct format
+{
+  struct foff
+    {
+      unsigned short offset;           /* offset into buffer */
+      unsigned short length;           /* length of field */
+    }         field_offsets[O_COUNT];
+  const unsigned char *fixed_string;           /* string with must be chars (blanks = wildcards) */
+  u_long      flags;
+};
+#endif
+
+/*
+ * History:
+ *
+ * parse_conf.h,v
+ * Revision 4.7  2005/06/25 10:58:45  kardel
+ * add missing log keywords
+ *
+ */
diff --git a/include/recvbuff.h b/include/recvbuff.h
new file mode 100644 (file)
index 0000000..771b90b
--- /dev/null
@@ -0,0 +1,123 @@
+#if !defined __recvbuff_h
+#define __recvbuff_h
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntp.h"
+#include "ntp_fp.h"
+#include "ntp_types.h"
+
+#include <isc/list.h>
+#include <isc/result.h>
+
+/*
+ * recvbuf memory management
+ */
+#define RECV_INIT      10      /* 10 buffers initially */
+#define RECV_LOWAT     3       /* when we're down to three buffers get more */
+#define RECV_INC       5       /* get 5 more at a time */
+#define RECV_TOOMANY   40      /* this is way too many buffers */
+
+#if defined HAVE_IO_COMPLETION_PORT
+# include "ntp_iocompletionport.h"
+#include "ntp_timer.h"
+
+# define RECV_BLOCK_IO()       EnterCriticalSection(&RecvCritSection)
+# define RECV_UNBLOCK_IO()     LeaveCriticalSection(&RecvCritSection)
+
+/*  Return the event which is set when items are added to the full list
+ */
+extern HANDLE  get_recv_buff_event P((void));
+#else
+# define RECV_BLOCK_IO()       
+# define RECV_UNBLOCK_IO()     
+#endif
+
+
+/*
+ * Format of a recvbuf.  These are used by the asynchronous receive
+ * routine to store incoming packets and related information.
+ */
+
+/*
+ *  the maximum length NTP packet contains the NTP header, one Autokey
+ *  request, one Autokey response and the MAC. Assuming certificates don't
+ *  get too big, the maximum packet length is set arbitrarily at 1000.
+ */   
+#define        RX_BUFF_SIZE    1000            /* hail Mary */
+
+
+typedef struct recvbuf recvbuf_t;
+
+struct recvbuf {
+       ISC_LINK(recvbuf_t)     link;
+       union {
+               struct sockaddr_storage X_recv_srcadr;
+               caddr_t X_recv_srcclock;
+               struct peer *X_recv_peer;
+       } X_from_where;
+#define recv_srcadr    X_from_where.X_recv_srcadr
+#define        recv_srcclock   X_from_where.X_recv_srcclock
+#define recv_peer      X_from_where.X_recv_peer
+#if defined HAVE_IO_COMPLETION_PORT
+       WSABUF          wsabuff;
+#else
+       struct sockaddr_storage srcadr; /* where packet came from */
+#endif
+       int src_addr_len;               /* source address length */
+       struct interface *dstadr;       /* interface datagram arrived thru */
+       SOCKET  fd;                     /* fd on which it was received */
+       int msg_flags;                  /* Flags received about the packet */
+       l_fp recv_time;                 /* time of arrival */
+       void (*receiver) P((struct recvbuf *)); /* routine to receive buffer */
+       int recv_length;                /* number of octets received */
+       union {
+               struct pkt X_recv_pkt;
+               u_char X_recv_buffer[RX_BUFF_SIZE];
+       } recv_space;
+       int used;
+#define        recv_pkt        recv_space.X_recv_pkt
+#define        recv_buffer     recv_space.X_recv_buffer
+};
+
+extern void    init_recvbuff   P((int));
+
+/* freerecvbuf - make a single recvbuf available for reuse
+ */
+extern void    freerecvbuf P((struct recvbuf *));
+
+/*  Get a free buffer (typically used so an async
+ *  read can directly place data into the buffer
+ *
+ *  The buffer is removed from the free list. Make sure
+ *  you put it back with freerecvbuf() or 
+ */
+extern struct recvbuf *get_free_recv_buffer P((void)); /* signal safe - no malloc */
+extern struct recvbuf *get_free_recv_buffer_alloc P((void)); /* signal unsafe - may malloc */
+
+/*   Add a buffer to the full list
+ */
+extern void    add_full_recv_buffer     P((struct recvbuf *));
+
+/*extern       void    process_recv_buffers     P((void)); */
+
+/* number of recvbufs on freelist */
+extern u_long free_recvbuffs P((void));                
+extern u_long full_recvbuffs P((void));                
+extern u_long total_recvbuffs P((void));
+extern u_long lowater_additions P((void));
+               
+/*  Returns the next buffer in the full list.
+ *
+ */
+extern struct recvbuf *get_full_recv_buffer P((void));
+
+/*
+ * Checks to see if there are buffers to process
+ */
+extern isc_boolean_t has_full_recv_buffer P((void));
+
+#endif /* defined __recvbuff_h */
+
diff --git a/include/rsa_md5.h b/include/rsa_md5.h
new file mode 100644 (file)
index 0000000..8241647
--- /dev/null
@@ -0,0 +1,51 @@
+/* MD5.H - header file for MD5C.C
+ */
+
+/* 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.  
+ */
+
+#ifndef _MD5_H_
+#define _MD5_H_ 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/*#include "global.h"  */
+
+/* MD5 context. */
+typedef struct {
+  UINT4 state[4];                                   /* state (ABCD) */
+  UINT4 count[2];        /* number of bits, modulo 2^64 (lsb first) */
+  unsigned char buffer[64];                         /* input buffer */
+} MD5_CTX;
+
+void MD5Init PROTO_LIST ((MD5_CTX *));
+void MD5Update PROTO_LIST
+  ((MD5_CTX *, unsigned char *, unsigned int));
+void MD5Final PROTO_LIST ((unsigned char [16], MD5_CTX *));
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/include/timepps-SCO.h b/include/timepps-SCO.h
new file mode 100644 (file)
index 0000000..130a153
--- /dev/null
@@ -0,0 +1,503 @@
+/***********************************************************************
+ *                                                                    *
+ * Copyright (c) David L. Mills 1999-2000                             *
+ *                                                                    *
+ * Permission to use, copy, modify, and distribute this software and   *
+ * its documentation for any purpose and without fee is hereby        *
+ * granted, provided that the above copyright notice appears in all    *
+ * copies and that both the copyright notice and this permission       *
+ * notice appear in supporting documentation, and that the name        *
+ * University of Delaware not be used in advertising or publicity      *
+ * pertaining to distribution of the software without specific,        *
+ * written prior permission. The University of Delaware makes no       *
+ * representations about the suitability this software for any        *
+ * purpose. It is provided "as is" without express or implied          *
+ * warranty.                                                          *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * This header file complies with "Pulse-Per-Second API for UNIX-like  *
+ * Operating Systems, Version 1.0", rfc2783. Credit is due Jeff Mogul  *
+ * and Marc Brett, from whom much of this code was shamelessly stolen. *
+ *                                                                    *
+ * this modified timepps.h can be used to provide a PPSAPI interface   *
+ * to a machine running SCO Unix.                                     *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * A full PPSAPI interface to the SCO Unix kernel would be better, but *
+ * this at least removes the necessity for special coding from the NTP *
+ * NTP drivers.                                                       *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * Some of this include file                                          *
+ * Copyright (c) 1999 by Ulrich Windl,                                *
+ *     based on code by Reg Clemens <reg@dwf.com>                     *
+ *             based on code by Poul-Henning Kamp <phk@FreeBSD.org>   *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * "THE BEER-WARE LICENSE" (Revision 42):                              *
+ * <phk@FreeBSD.org> wrote this file.  As long as you retain this      *
+ * notice you can do whatever you want with this stuff. If we meet some*
+ * day, and you think this stuff is worth it, you can buy me a beer    *
+ * in return.  Poul-Henning Kamp                                      *
+ *                                                                    *
+ **********************************************************************/
+
+/*SCO UNIX version, TIOCDCDTIMESTAMP assumed to exist. */
+
+#ifndef _SYS_TIMEPPS_H_
+#define _SYS_TIMEPPS_H_
+
+#include <termios.h>   /* to get TIOCDCDTIMESTAMP */
+
+/* Implementation note: the logical states ``assert'' and ``clear''
+ * are implemented in terms of the UART register, i.e. ``assert''
+ * means the bit is set.
+ */
+
+/*
+ * The following definitions are architecture independent
+ */
+
+#define PPS_API_VERS_1 1               /* API version number */
+#define PPS_JAN_1970   2208988800UL    /* 1970 - 1900 in seconds */
+#define PPS_NANOSECOND 1000000000L     /* one nanosecond in decimal */
+#define PPS_FRAC       4294967296.     /* 2^32 as a double */
+
+#define PPS_NORMALIZE(x)       /* normalize timespec */ \
+       do { \
+               if ((x).tv_nsec >= PPS_NANOSECOND) { \
+                       (x).tv_nsec -= PPS_NANOSECOND; \
+                       (x).tv_sec++; \
+               } else if ((x).tv_nsec < 0) { \
+                       (x).tv_nsec += PPS_NANOSECOND; \
+                       (x).tv_sec--; \
+               } \
+       } while (0)
+
+#define PPS_TSPECTONTP(x)      /* convert timespec to l_fp */ \
+       do { \
+               double d_temp; \
+       \
+               (x).integral += (unsigned int)PPS_JAN_1970; \
+               d_temp = (x).fractional * PPS_FRAC / PPS_NANOSECOND; \
+               if (d_temp >= PPS_FRAC) \
+                       (x).integral++; \
+               (x).fractional = (unsigned int)d_temp; \
+       } while (0)
+
+/*
+ * Device/implementation parameters (mode)
+ */
+
+#define PPS_CAPTUREASSERT      0x01    /* capture assert events */
+#define PPS_CAPTURECLEAR       0x02    /* capture clear events */
+#define PPS_CAPTUREBOTH        0x03    /* capture assert and clear events */
+
+#define PPS_OFFSETASSERT       0x10    /* apply compensation for assert ev. */
+#define PPS_OFFSETCLEAR        0x20    /* apply compensation for clear ev. */
+#define PPS_OFFSETBOTH         0x30    /* apply compensation for both */
+
+#define PPS_CANWAIT            0x100   /* Can we wait for an event? */
+#define PPS_CANPOLL            0x200   /* "This bit is reserved for */
+
+/*
+ * Kernel actions (mode)
+ */
+
+#define PPS_ECHOASSERT         0x40    /* feed back assert event to output */
+#define PPS_ECHOCLEAR          0x80    /* feed back clear event to output */
+
+/*
+ * Timestamp formats (tsformat)
+ */
+
+#define PPS_TSFMT_TSPEC        0x1000  /* select timespec format */
+#define PPS_TSFMT_NTPFP        0x2000  /* select NTP format */
+
+/*
+ * Kernel discipline actions (not used in Solaris)
+ */
+
+#define PPS_KC_HARDPPS         0       /* enable kernel consumer */
+#define PPS_KC_HARDPPS_PLL     1       /* phase-lock mode */
+#define PPS_KC_HARDPPS_FLL     2       /* frequency-lock mode */
+
+/*
+ * Type definitions
+ */
+
+typedef unsigned long pps_seq_t;       /* sequence number */
+
+typedef struct ntp_fp {
+       unsigned int    integral;
+       unsigned int    fractional;
+} ntp_fp_t;                            /* NTP-compatible time stamp */
+
+typedef union pps_timeu {              /* timestamp format */
+       struct timespec tspec;
+       ntp_fp_t        ntpfp;
+       unsigned long   longpad[3];
+} pps_timeu_t;                         /* generic data type to represent time stamps */
+
+/*
+ * Timestamp information structure
+ */
+
+typedef struct pps_info {
+       pps_seq_t       assert_sequence;        /* seq. num. of assert event */
+       pps_seq_t       clear_sequence;         /* seq. num. of clear event */
+       pps_timeu_t     assert_tu;              /* time of assert event */
+       pps_timeu_t     clear_tu;               /* time of clear event */
+       int             current_mode;           /* current mode bits */
+} pps_info_t;
+
+#define assert_timestamp       assert_tu.tspec
+#define clear_timestamp        clear_tu.tspec
+
+#define assert_timestamp_ntpfp assert_tu.ntpfp
+#define clear_timestamp_ntpfp  clear_tu.ntpfp
+
+/*
+ * Parameter structure
+ */
+
+typedef struct pps_params {
+       int             api_version;    /* API version # */
+       int             mode;           /* mode bits */
+       pps_timeu_t assert_off_tu;      /* offset compensation for assert */
+       pps_timeu_t clear_off_tu;       /* offset compensation for clear */
+} pps_params_t;
+
+#define assert_offset          assert_off_tu.tspec
+#define clear_offset           clear_off_tu.tspec
+
+#define assert_offset_ntpfp    assert_off_tu.ntpfp
+#define clear_offset_ntpfp     clear_off_tu.ntpfp
+
+/*
+ * The following definitions are architecture-dependent
+ */
+
+#define PPS_CAP (PPS_CAPTUREASSERT | PPS_OFFSETASSERT | PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)
+#define PPS_RO (PPS_CANWAIT | PPS_CANPOLL | PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)
+
+typedef struct {
+       int filedes;            /* file descriptor */
+       pps_params_t params;    /* PPS parameters set by user */
+       struct timeval  tv_save;
+       pps_seq_t serial;
+} pps_unit_t;
+
+typedef pps_unit_t* pps_handle_t; /* pps handlebars */
+
+/*
+ *------ Here begins the implementation-specific part! ------
+ */
+
+#include <errno.h>
+
+/*
+ * create PPS handle from file descriptor
+ */
+
+static inline int
+time_pps_create(
+       int filedes,            /* file descriptor */
+       pps_handle_t *handle    /* returned handle */
+       )
+{
+       int one = 1;
+
+       /*
+        * Check for valid arguments and attach PPS signal.
+        */
+
+       if (!handle) {
+               errno = EFAULT;
+               return (-1);    /* null pointer */
+       }
+
+       /*
+        * Allocate and initialize default unit structure.
+        */
+
+       *handle = malloc(sizeof(pps_unit_t));
+       if (!(*handle)) {
+               errno = EBADF;
+               return (-1);    /* what, no memory? */
+       }
+
+       memset(*handle, 0, sizeof(pps_unit_t));
+       (*handle)->filedes = filedes;
+       (*handle)->params.api_version = PPS_API_VERS_1;
+       (*handle)->params.mode = PPS_CAPTUREASSERT | PPS_TSFMT_TSPEC;
+       return (0);
+}
+
+/*
+ * release PPS handle
+ */
+
+static inline int
+time_pps_destroy(
+       pps_handle_t handle
+       )
+{
+       /*
+        * Check for valid arguments and detach PPS signal.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+       free(handle);
+       return (0);
+}
+
+/*
+ * set parameters for handle
+ */
+
+static inline int
+time_pps_setparams(
+       pps_handle_t handle,
+       const pps_params_t *params
+       )
+{
+       int     mode, mode_in;
+       /*
+        * Check for valid arguments and set parameters.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!params) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+
+       /*
+        * There was no reasonable consensu in the API working group.
+        * I require `api_version' to be set!
+        */
+
+       if (params->api_version != PPS_API_VERS_1) {
+               errno = EINVAL;
+               return(-1);
+       }
+
+       /*
+        * only settable modes are PPS_CAPTUREASSERT and PPS_OFFSETASSERT
+        */
+
+       mode_in = params->mode;
+
+       /* turn off read-only bits */
+
+       mode_in &= ~PPS_RO;
+
+       /* test remaining bits, should only have captureassert and/or offsetassert */
+
+       if (mode_in & ~(PPS_CAPTUREASSERT | PPS_OFFSETASSERT)) {
+               errno = EOPNOTSUPP;
+               return(-1);
+       }
+
+       /*
+        * ok, ready to go.
+        */
+
+       mode = handle->params.mode;
+       memcpy(&handle->params, params, sizeof(pps_params_t));
+       handle->params.api_version = PPS_API_VERS_1;
+       handle->params.mode = mode | mode_in;
+       return (0);
+}
+
+/*
+ * get parameters for handle
+ */
+
+static inline int
+time_pps_getparams(
+       pps_handle_t handle,
+       pps_params_t *params
+       )
+{
+       /*
+        * Check for valid arguments and get parameters.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!params) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+
+       memcpy(params, &handle->params, sizeof(pps_params_t));
+       return (0);
+}
+
+/* (
+ * get capabilities for handle
+ */
+
+static inline int
+time_pps_getcap(
+       pps_handle_t handle,
+       int *mode
+       )
+{
+       /*
+        * Check for valid arguments and get capabilities.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!mode) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+       *mode = PPS_CAP;
+       return (0);
+}
+
+/*
+ * Fetch timestamps
+ */
+
+static inline int
+time_pps_fetch(
+       pps_handle_t handle,
+       const int tsformat,
+       pps_info_t *ppsinfo,
+       const struct timespec *timeout
+       )
+{
+       struct timeval tv;
+       pps_info_t infobuf;
+
+       /*
+        * Check for valid arguments and fetch timestamps
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!ppsinfo) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+
+       /*
+        * nb. PPS_CANWAIT is NOT set by the implementation, we can totally
+        * ignore the timeout variable.
+        */
+
+       memset(&infobuf, 0, sizeof(infobuf));
+
+       /*
+        * if not captureassert, nothing to return.
+        */
+
+       if (!handle->params.mode & PPS_CAPTUREASSERT) {
+               memcpy(ppsinfo, &infobuf, sizeof(pps_info_t));
+               return (0);
+       }
+
+       if (ioctl(instance->filedes, TIOCDCDTIMESTAMP, &tv) < 0) {
+               perror("time_pps_fetch:");
+               errno = EOPNOTSUPP;
+               return(-1);
+       }
+
+       /*
+        * fake serial here
+        */
+
+       if (tv.tv_sec != handle->tv_save.tv_sec || tv.tv_usec != handle->tv_save.tv_usec) {
+               handle->tv_save = tv;
+               handle->serial++;
+       }
+
+       /*
+        * Apply offsets as specified. Note that only assert timestamps
+        * are captured by this interface.
+        */
+
+       infobuf.assert_sequence = handle->serial;
+       infobuf.assert_timestamp.tv_sec = tv.tv_sec;
+       infobuf.assert_timestamp.tv_nsec = tv.tv_usec * 1000;
+
+       if (handle->params.mode & PPS_OFFSETASSERT) {
+               infobuf.assert_timestamp.tv_sec  += handle->params.assert_offset.tv_sec;
+               infobuf.assert_timestamp.tv_nsec += handle->params.assert_offset.tv_nsec;
+               PPS_NORMALIZE(infobuf.assert_timestamp);
+       }
+
+       /*
+        * Translate to specified format
+        */
+
+       switch (tsformat) {
+       case PPS_TSFMT_TSPEC:
+               break;           /* timespec format requires no translation */
+
+       case PPS_TSFMT_NTPFP:   /* NTP format requires conversion to fraction form */
+               PPS_TSPECTONTP(infobuf.assert_timestamp_ntpfp);
+               break;
+
+       default:
+               errno = EINVAL;
+               return (-1);
+       }
+
+       infobuf.current_mode = handle->params.mode;
+       memcpy(ppsinfo, &infobuf, sizeof(pps_info_t));
+       return (0);
+}
+
+/*
+ * specify kernel consumer
+ */
+
+static inline int
+time_pps_kcbind(
+       pps_handle_t handle,
+       const int kernel_consumer,
+       const int edge, const int tsformat
+       )
+{
+       /*
+        * Check for valid arguments and bind kernel consumer
+        */
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+       if (geteuid() != 0) {
+               errno = EPERM;
+               return (-1);    /* must be superuser */
+       }
+       errno = EOPNOTSUPP;
+       return(-1);
+}
+
+#endif /* _SYS_TIMEPPS_H_ */
diff --git a/include/timepps-Solaris.h b/include/timepps-Solaris.h
new file mode 100644 (file)
index 0000000..da8fd94
--- /dev/null
@@ -0,0 +1,501 @@
+/***********************************************************************
+ *                                                                    *
+ * Copyright (c) David L. Mills 1999-2000                             *
+ *                                                                    *
+ * Permission to use, copy, modify, and distribute this software and   *
+ * its documentation for any purpose and without fee is hereby        *
+ * granted, provided that the above copyright notice appears in all    *
+ * copies and that both the copyright notice and this permission       *
+ * notice appear in supporting documentation, and that the name        *
+ * University of Delaware not be used in advertising or publicity      *
+ * pertaining to distribution of the software without specific,        *
+ * written prior permission. The University of Delaware makes no       *
+ * representations about the suitability this software for any        *
+ * purpose. It is provided "as is" without express or implied          *
+ * warranty.                                                          *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * This header file complies with "Pulse-Per-Second API for UNIX-like  *
+ * Operating Systems, Version 1.0", rfc2783. Credit is due Jeff Mogul  *
+ * and Marc Brett, from whom much of this code was shamelessly stolen. *
+ *                                                                    *
+ * this modified timepps.h can be used to provide a PPSAPI interface   *
+ * to a machine running Solaris (2.6 and above).                      *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * A full PPSAPI interface to the Solaris kernel would be better, but  *
+ * this at least removes the necessity for special coding from the NTP *
+ * NTP drivers.                                                       *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * Some of this include file                                          *
+ * Copyright (c) 1999 by Ulrich Windl,                                *
+ *     based on code by Reg Clemens <reg@dwf.com>                     *
+ *             based on code by Poul-Henning Kamp <phk@FreeBSD.org>   *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * "THE BEER-WARE LICENSE" (Revision 42):                              *
+ * <phk@FreeBSD.org> wrote this file.  As long as you retain this      *
+ * notice you can do whatever you want with this stuff. If we meet some*
+ * day, and you think this stuff is worth it, you can buy me a beer    *
+ * in return.  Poul-Henning Kamp                                      *
+ *                                                                    *
+ **********************************************************************/
+
+/* Solaris version, TIOCGPPSEV and TIOCSPPS assumed to exist. */
+
+#ifndef _SYS_TIMEPPS_H_
+#define _SYS_TIMEPPS_H_
+
+#include <termios.h>   /* to get TOCGPPSEV and TIOCSPPS */
+
+/* Implementation note: the logical states ``assert'' and ``clear''
+ * are implemented in terms of the UART register, i.e. ``assert''
+ * means the bit is set.
+ */
+
+/*
+ * The following definitions are architecture independent
+ */
+
+#define PPS_API_VERS_1 1               /* API version number */
+#define PPS_JAN_1970   2208988800UL    /* 1970 - 1900 in seconds */
+#define PPS_NANOSECOND 1000000000L     /* one nanosecond in decimal */
+#define PPS_FRAC       4294967296.     /* 2^32 as a double */
+
+#define PPS_NORMALIZE(x)       /* normalize timespec */ \
+       do { \
+               if ((x).tv_nsec >= PPS_NANOSECOND) { \
+                       (x).tv_nsec -= PPS_NANOSECOND; \
+                       (x).tv_sec++; \
+               } else if ((x).tv_nsec < 0) { \
+                       (x).tv_nsec += PPS_NANOSECOND; \
+                       (x).tv_sec--; \
+               } \
+       } while (0)
+
+#define PPS_TSPECTONTP(x)      /* convert timespec to l_fp */ \
+       do { \
+               double d_temp; \
+       \
+               (x).integral += (unsigned int)PPS_JAN_1970; \
+               d_temp = (x).fractional * PPS_FRAC / PPS_NANOSECOND; \
+               if (d_temp >= PPS_FRAC) \
+                       (x).integral++; \
+               (x).fractional = (unsigned int)d_temp; \
+       } while (0)
+
+/*
+ * Device/implementation parameters (mode)
+ */
+
+#define PPS_CAPTUREASSERT      0x01    /* capture assert events */
+#define PPS_CAPTURECLEAR       0x02    /* capture clear events */
+#define PPS_CAPTUREBOTH        0x03    /* capture assert and clear events */
+
+#define PPS_OFFSETASSERT       0x10    /* apply compensation for assert ev. */
+#define PPS_OFFSETCLEAR        0x20    /* apply compensation for clear ev. */
+#define PPS_OFFSETBOTH         0x30    /* apply compensation for both */
+
+#define PPS_CANWAIT            0x100   /* Can we wait for an event? */
+#define PPS_CANPOLL            0x200   /* "This bit is reserved for */
+
+/*
+ * Kernel actions (mode)
+ */
+
+#define PPS_ECHOASSERT         0x40    /* feed back assert event to output */
+#define PPS_ECHOCLEAR          0x80    /* feed back clear event to output */
+
+/*
+ * Timestamp formats (tsformat)
+ */
+
+#define PPS_TSFMT_TSPEC        0x1000  /* select timespec format */
+#define PPS_TSFMT_NTPFP        0x2000  /* select NTP format */
+
+/*
+ * Kernel discipline actions (not used in Solaris)
+ */
+
+#define PPS_KC_HARDPPS         0       /* enable kernel consumer */
+#define PPS_KC_HARDPPS_PLL     1       /* phase-lock mode */
+#define PPS_KC_HARDPPS_FLL     2       /* frequency-lock mode */
+
+/*
+ * Type definitions
+ */
+
+typedef unsigned long pps_seq_t;       /* sequence number */
+
+typedef struct ntp_fp {
+       unsigned int    integral;
+       unsigned int    fractional;
+} ntp_fp_t;                            /* NTP-compatible time stamp */
+
+typedef union pps_timeu {              /* timestamp format */
+       struct timespec tspec;
+       ntp_fp_t        ntpfp;
+       unsigned long   longpad[3];
+} pps_timeu_t;                         /* generic data type to represent time stamps */
+
+/*
+ * Timestamp information structure
+ */
+
+typedef struct pps_info {
+       pps_seq_t       assert_sequence;        /* seq. num. of assert event */
+       pps_seq_t       clear_sequence;         /* seq. num. of clear event */
+       pps_timeu_t     assert_tu;              /* time of assert event */
+       pps_timeu_t     clear_tu;               /* time of clear event */
+       int             current_mode;           /* current mode bits */
+} pps_info_t;
+
+#define assert_timestamp       assert_tu.tspec
+#define clear_timestamp        clear_tu.tspec
+
+#define assert_timestamp_ntpfp assert_tu.ntpfp
+#define clear_timestamp_ntpfp  clear_tu.ntpfp
+
+/*
+ * Parameter structure
+ */
+
+typedef struct pps_params {
+       int             api_version;    /* API version # */
+       int             mode;           /* mode bits */
+       pps_timeu_t assert_off_tu;      /* offset compensation for assert */
+       pps_timeu_t clear_off_tu;       /* offset compensation for clear */
+} pps_params_t;
+
+#define assert_offset          assert_off_tu.tspec
+#define clear_offset           clear_off_tu.tspec
+
+#define assert_offset_ntpfp    assert_off_tu.ntpfp
+#define clear_offset_ntpfp     clear_off_tu.ntpfp
+
+/*
+ * The following definitions are architecture-dependent
+ */
+
+#define PPS_CAP (PPS_CAPTUREASSERT | PPS_OFFSETASSERT | PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)
+#define PPS_RO (PPS_CANWAIT | PPS_CANPOLL | PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)
+
+typedef struct {
+       int filedes;            /* file descriptor */
+       pps_params_t params;    /* PPS parameters set by user */
+} pps_unit_t;
+
+typedef pps_unit_t* pps_handle_t; /* pps handlebars */
+
+/*
+ *------ Here begins the implementation-specific part! ------
+ */
+
+#include <errno.h>
+
+/*
+ * create PPS handle from file descriptor
+ */
+
+static inline int
+time_pps_create(
+       int filedes,            /* file descriptor */
+       pps_handle_t *handle    /* returned handle */
+       )
+{
+       int one = 1;
+
+       /*
+        * Check for valid arguments and attach PPS signal.
+        */
+
+       if (!handle) {
+               errno = EFAULT;
+               return (-1);    /* null pointer */
+       }
+
+       if (ioctl(filedes, TIOCSPPS, &one) < 0) {
+               perror("refclock_ioctl: TIOCSPPS failed:");
+               return (-1);
+       }
+
+       /*
+        * Allocate and initialize default unit structure.
+        */
+
+       *handle = malloc(sizeof(pps_unit_t));
+       if (!(*handle)) {
+               errno = EBADF;
+               return (-1);    /* what, no memory? */
+       }
+
+       memset(*handle, 0, sizeof(pps_unit_t));
+       (*handle)->filedes = filedes;
+       (*handle)->params.api_version = PPS_API_VERS_1;
+       (*handle)->params.mode = PPS_CAPTUREASSERT | PPS_TSFMT_TSPEC;
+       return (0);
+}
+
+/*
+ * release PPS handle
+ */
+
+static inline int
+time_pps_destroy(
+       pps_handle_t handle
+       )
+{
+       /*
+        * Check for valid arguments and detach PPS signal.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+       free(handle);
+       return (0);
+}
+
+/*
+ * set parameters for handle
+ */
+
+static inline int
+time_pps_setparams(
+       pps_handle_t handle,
+       const pps_params_t *params
+       )
+{
+       int     mode, mode_in;
+       /*
+        * Check for valid arguments and set parameters.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!params) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+
+       /*
+        * There was no reasonable consensu in the API working group.
+        * I require `api_version' to be set!
+        */
+
+       if (params->api_version != PPS_API_VERS_1) {
+               errno = EINVAL;
+               return(-1);
+       }
+
+       /*
+        * only settable modes are PPS_CAPTUREASSERT and PPS_OFFSETASSERT
+        */
+
+       mode_in = params->mode;
+
+       /* turn off read-only bits */
+
+       mode_in &= ~PPS_RO;
+
+       /* test remaining bits, should only have captureassert and/or offsetassert */
+
+       if (mode_in & ~(PPS_CAPTUREASSERT | PPS_OFFSETASSERT)) {
+               errno = EOPNOTSUPP;
+               return(-1);
+       }
+
+       /*
+        * ok, ready to go.
+        */
+
+       mode = handle->params.mode;
+       memcpy(&handle->params, params, sizeof(pps_params_t));
+       handle->params.api_version = PPS_API_VERS_1;
+       handle->params.mode = mode | mode_in;
+       return (0);
+}
+
+/*
+ * get parameters for handle
+ */
+
+static inline int
+time_pps_getparams(
+       pps_handle_t handle,
+       pps_params_t *params
+       )
+{
+       /*
+        * Check for valid arguments and get parameters.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!params) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+
+       memcpy(params, &handle->params, sizeof(pps_params_t));
+       return (0);
+}
+
+/* (
+ * get capabilities for handle
+ */
+
+static inline int
+time_pps_getcap(
+       pps_handle_t handle,
+       int *mode
+       )
+{
+       /*
+        * Check for valid arguments and get capabilities.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!mode) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+       *mode = PPS_CAP;
+       return (0);
+}
+
+/*
+ * Fetch timestamps
+ */
+
+static inline int
+time_pps_fetch(
+       pps_handle_t handle,
+       const int tsformat,
+       pps_info_t *ppsinfo,
+       const struct timespec *timeout
+       )
+{
+       struct ppsclockev {
+               struct timeval tv;
+               u_int serial;
+       } ev;
+
+       pps_info_t infobuf;
+
+       /*
+        * Check for valid arguments and fetch timestamps
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!ppsinfo) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+
+       /*
+        * nb. PPS_CANWAIT is NOT set by the implementation, we can totally
+        * ignore the timeout variable.
+        */
+
+       memset(&infobuf, 0, sizeof(infobuf));
+
+       /*
+        * if not captureassert, nothing to return.
+        */
+
+       if (!handle->params.mode & PPS_CAPTUREASSERT) {
+               memcpy(ppsinfo, &infobuf, sizeof(pps_info_t));
+               return (0);
+       }
+
+       if (ioctl(handle->filedes, TIOCGPPSEV, (caddr_t) &ev) < 0) {
+               perror("time_pps_fetch:");
+               errno = EOPNOTSUPP;
+               return(-1);
+       }
+
+       /*
+        * Apply offsets as specified. Note that only assert timestamps
+        * are captured by this interface.
+        */
+
+       infobuf.assert_sequence = ev.serial;
+       infobuf.assert_timestamp.tv_sec = ev.tv.tv_sec;
+       infobuf.assert_timestamp.tv_nsec = ev.tv.tv_usec * 1000;
+
+       if (handle->params.mode & PPS_OFFSETASSERT) {
+               infobuf.assert_timestamp.tv_sec  += handle->params.assert_offset.tv_sec;
+               infobuf.assert_timestamp.tv_nsec += handle->params.assert_offset.tv_nsec;
+               PPS_NORMALIZE(infobuf.assert_timestamp);
+       }
+
+       /*
+        * Translate to specified format
+        */
+
+       switch (tsformat) {
+       case PPS_TSFMT_TSPEC:
+               break;           /* timespec format requires no translation */
+
+       case PPS_TSFMT_NTPFP:   /* NTP format requires conversion to fraction form */
+               PPS_TSPECTONTP(infobuf.assert_timestamp_ntpfp);
+               break;
+
+       default:
+               errno = EINVAL;
+               return (-1);
+       }
+
+       infobuf.current_mode = handle->params.mode;
+       memcpy(ppsinfo, &infobuf, sizeof(pps_info_t));
+       return (0);
+}
+
+/*
+ * specify kernel consumer
+ */
+
+static inline int
+time_pps_kcbind(
+       pps_handle_t handle,
+       const int kernel_consumer,
+       const int edge, const int tsformat
+       )
+{
+       /*
+        * Check for valid arguments and bind kernel consumer
+        */
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+       if (geteuid() != 0) {
+               errno = EPERM;
+               return (-1);    /* must be superuser */
+       }
+       errno = EOPNOTSUPP;
+       return(-1);
+}
+
+#endif /* _SYS_TIMEPPS_H_ */
diff --git a/include/timepps-SunOS.h b/include/timepps-SunOS.h
new file mode 100644 (file)
index 0000000..6cd166e
--- /dev/null
@@ -0,0 +1,504 @@
+/***********************************************************************
+ *                                                                    *
+ * Copyright (c) David L. Mills 1999-2000                             *
+ *                                                                    *
+ * Permission to use, copy, modify, and distribute this software and   *
+ * its documentation for any purpose and without fee is hereby        *
+ * granted, provided that the above copyright notice appears in all    *
+ * copies and that both the copyright notice and this permission       *
+ * notice appear in supporting documentation, and that the name        *
+ * University of Delaware not be used in advertising or publicity      *
+ * pertaining to distribution of the software without specific,        *
+ * written prior permission. The University of Delaware makes no       *
+ * representations about the suitability this software for any        *
+ * purpose. It is provided "as is" without express or implied          *
+ * warranty.                                                          *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * This header file complies with "Pulse-Per-Second API for UNIX-like  *
+ * Operating Systems, Version 1.0", rfc2783. Credit is due Jeff Mogul  *
+ * and Marc Brett, from whom much of this code was shamelessly stolen. *
+ *                                                                    *
+ * this modified timepps.h can be used to provide a PPSAPI interface   *
+ * to a machine running SunOS.                                        *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * A full PPSAPI interface to the SunOS kernel would be better, but    *
+ * this at least removes the necessity for special coding from the NTP *
+ * NTP drivers.                                                       *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * Some of this include file                                          *
+ * Copyright (c) 1999 by Ulrich Windl,                                *
+ *     based on code by Reg Clemens <reg@dwf.com>                     *
+ *             based on code by Poul-Henning Kamp <phk@FreeBSD.org>   *
+ *                                                                    *
+ ***********************************************************************
+ *                                                                    *
+ * "THE BEER-WARE LICENSE" (Revision 42):                              *
+ * <phk@FreeBSD.org> wrote this file.  As long as you retain this      *
+ * notice you can do whatever you want with this stuff. If we meet some*
+ * day, and you think this stuff is worth it, you can buy me a beer    *
+ * in return.  Poul-Henning Kamp                                      *
+ *                                                                    *
+ **********************************************************************/
+
+/* SunOS version, CIOGETEV assumed to exist for SunOS */
+
+#ifndef _SYS_TIMEPPS_H_
+#define _SYS_TIMEPPS_H_
+
+#include <termios.h>   /* to get CIOGETEV */
+
+/* Implementation note: the logical states ``assert'' and ``clear''
+ * are implemented in terms of the UART register, i.e. ``assert''
+ * means the bit is set.
+ */
+
+/*
+ * The following definitions are architecture independent
+ */
+
+#define PPS_API_VERS_1 1               /* API version number */
+#define PPS_JAN_1970   2208988800UL    /* 1970 - 1900 in seconds */
+#define PPS_NANOSECOND 1000000000L     /* one nanosecond in decimal */
+#define PPS_FRAC       4294967296.     /* 2^32 as a double */
+
+#define PPS_NORMALIZE(x)       /* normalize timespec */ \
+       do { \
+               if ((x).tv_nsec >= PPS_NANOSECOND) { \
+                       (x).tv_nsec -= PPS_NANOSECOND; \
+                       (x).tv_sec++; \
+               } else if ((x).tv_nsec < 0) { \
+                       (x).tv_nsec += PPS_NANOSECOND; \
+                       (x).tv_sec--; \
+               } \
+       } while (0)
+
+#define PPS_TSPECTONTP(x)      /* convert timespec to l_fp */ \
+       do { \
+               double d_temp; \
+       \
+               (x).integral += (unsigned int)PPS_JAN_1970; \
+               d_temp = (x).fractional * PPS_FRAC / PPS_NANOSECOND; \
+               if (d_temp >= PPS_FRAC) \
+                       (x).integral++; \
+               (x).fractional = (unsigned int)d_temp; \
+       } while (0)
+
+/*
+ * Device/implementation parameters (mode)
+ */
+
+#define PPS_CAPTUREASSERT      0x01    /* capture assert events */
+#define PPS_CAPTURECLEAR       0x02    /* capture clear events */
+#define PPS_CAPTUREBOTH        0x03    /* capture assert and clear events */
+
+#define PPS_OFFSETASSERT       0x10    /* apply compensation for assert ev. */
+#define PPS_OFFSETCLEAR        0x20    /* apply compensation for clear ev. */
+#define PPS_OFFSETBOTH         0x30    /* apply compensation for both */
+
+#define PPS_CANWAIT            0x100   /* Can we wait for an event? */
+#define PPS_CANPOLL            0x200   /* "This bit is reserved for */
+
+/*
+ * Kernel actions (mode)
+ */
+
+#define PPS_ECHOASSERT         0x40    /* feed back assert event to output */
+#define PPS_ECHOCLEAR          0x80    /* feed back clear event to output */
+
+/*
+ * Timestamp formats (tsformat)
+ */
+
+#define PPS_TSFMT_TSPEC        0x1000  /* select timespec format */
+#define PPS_TSFMT_NTPFP        0x2000  /* select NTP format */
+
+/*
+ * Kernel discipline actions (not used in SunOS)
+ */
+
+#define PPS_KC_HARDPPS         0       /* enable kernel consumer */
+#define PPS_KC_HARDPPS_PLL     1       /* phase-lock mode */
+#define PPS_KC_HARDPPS_FLL     2       /* frequency-lock mode */
+
+/*
+ * Type definitions
+ */
+
+typedef unsigned long pps_seq_t;       /* sequence number */
+
+typedef struct ntp_fp {
+       unsigned int    integral;
+       unsigned int    fractional;
+} ntp_fp_t;                            /* NTP-compatible time stamp */
+
+typedef union pps_timeu {              /* timestamp format */
+       struct timespec tspec;
+       ntp_fp_t        ntpfp;
+       unsigned long   longpad[3];
+} pps_timeu_t;                         /* generic data type to represent time stamps */
+
+/*
+ * Timestamp information structure
+ */
+
+typedef struct pps_info {
+       pps_seq_t       assert_sequence;        /* seq. num. of assert event */
+       pps_seq_t       clear_sequence;         /* seq. num. of clear event */
+       pps_timeu_t     assert_tu;              /* time of assert event */
+       pps_timeu_t     clear_tu;               /* time of clear event */
+       int             current_mode;           /* current mode bits */
+} pps_info_t;
+
+#define assert_timestamp       assert_tu.tspec
+#define clear_timestamp        clear_tu.tspec
+
+#define assert_timestamp_ntpfp assert_tu.ntpfp
+#define clear_timestamp_ntpfp  clear_tu.ntpfp
+
+/*
+ * Parameter structure
+ */
+
+typedef struct pps_params {
+       int             api_version;    /* API version # */
+       int             mode;           /* mode bits */
+       pps_timeu_t assert_off_tu;      /* offset compensation for assert */
+       pps_timeu_t clear_off_tu;       /* offset compensation for clear */
+} pps_params_t;
+
+#define assert_offset          assert_off_tu.tspec
+#define clear_offset           clear_off_tu.tspec
+
+#define assert_offset_ntpfp    assert_off_tu.ntpfp
+#define clear_offset_ntpfp     clear_off_tu.ntpfp
+
+/*
+ * The following definitions are architecture-dependent
+ */
+
+#define PPS_CAP (PPS_CAPTUREASSERT | PPS_OFFSETASSERT | PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)
+#define PPS_RO (PPS_CANWAIT | PPS_CANPOLL | PPS_TSFMT_TSPEC | PPS_TSFMT_NTPFP)
+
+typedef struct {
+       int filedes;            /* file descriptor */
+       pps_params_t params;    /* PPS parameters set by user */
+} pps_unit_t;
+
+typedef pps_unit_t* pps_handle_t; /* pps handlebars */
+
+/*
+ *------ Here begins the implementation-specific part! ------
+ */
+
+#include <errno.h>
+
+/*
+ * create PPS handle from file descriptor
+ */
+
+static inline int
+time_pps_create(
+       int filedes,            /* file descriptor */
+       pps_handle_t *handle    /* returned handle */
+       )
+{
+       /*
+        * Check for valid arguments and attach PPS signal.
+        */
+
+       if (!handle) {
+               errno = EFAULT;
+               return (-1);    /* null pointer */
+       }
+
+       if (ioctl(filedes, I_PUSH, "ppsclock") < 0) {
+               perror("time_pps_create: I_PUSH ppsclock failed");
+               return (-1);
+       }
+
+       /*
+        * Allocate and initialize default unit structure.
+        */
+
+       *handle = malloc(sizeof(pps_unit_t));
+       if (!(*handle)) {
+               errno = EBADF;
+               return (-1);    /* what, no memory? */
+       }
+
+       memset(*handle, 0, sizeof(pps_unit_t));
+       (*handle)->filedes = filedes;
+       (*handle)->params.api_version = PPS_API_VERS_1;
+       (*handle)->params.mode = PPS_CAPTUREASSERT | PPS_TSFMT_TSPEC;
+       return (0);
+}
+
+/*
+ * release PPS handle
+ */
+
+static inline int
+time_pps_destroy(
+       pps_handle_t handle
+       )
+{
+       /*
+        * Check for valid arguments and detach PPS signal.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+       free(handle);
+       return (0);
+}
+
+/*
+ * set parameters for handle
+ */
+
+static inline int
+time_pps_setparams(
+       pps_handle_t handle,
+       const pps_params_t *params
+       )
+{
+       int     mode, mode_in;
+       /*
+        * Check for valid arguments and set parameters.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!params) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+
+       /*
+        * There was no reasonable consensu in the API working group.
+        * I require `api_version' to be set!
+        */
+
+       if (params->api_version != PPS_API_VERS_1) {
+               errno = EINVAL;
+               return(-1);
+       }
+
+       /*
+        * only settable modes are PPS_CAPTUREASSERT and PPS_OFFSETASSERT
+        */
+
+       mode_in = params->mode;
+
+       /* turn off read-only bits */
+
+       mode_in &= ~PPS_RO;
+
+       /* test remaining bits, should only have captureassert and/or offsetassert */
+
+       if (mode_in & ~(PPS_CAPTUREASSERT | PPS_OFFSETASSERT)) {
+               errno = EOPNOTSUPP;
+               return(-1);
+       }
+
+       /*
+        * ok, ready to go.
+        */
+
+       mode = handle->params.mode;
+       memcpy(&handle->params, params, sizeof(pps_params_t));
+       handle->params.api_version = PPS_API_VERS_1;
+       handle->params.mode = mode | mode_in;
+       return (0);
+}
+
+/*
+ * get parameters for handle
+ */
+
+static inline int
+time_pps_getparams(
+       pps_handle_t handle,
+       pps_params_t *params
+       )
+{
+       /*
+        * Check for valid arguments and get parameters.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!params) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+
+       memcpy(params, &handle->params, sizeof(pps_params_t));
+       return (0);
+}
+
+/* (
+ * get capabilities for handle
+ */
+
+static inline int
+time_pps_getcap(
+       pps_handle_t handle,
+       int *mode
+       )
+{
+       /*
+        * Check for valid arguments and get capabilities.
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!mode) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+       *mode = PPS_CAP;
+       return (0);
+}
+
+/*
+ * Fetch timestamps
+ */
+
+static inline int
+time_pps_fetch(
+       pps_handle_t handle,
+       const int tsformat,
+       pps_info_t *ppsinfo,
+       const struct timespec *timeout
+       )
+{
+       struct ppsclockev {
+               struct timeval tv;
+               u_int serial;
+       } ev;
+       pps_info_t infobuf;
+
+       /*
+        * Check for valid arguments and fetch timestamps
+        */
+
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+
+       if (!ppsinfo) {
+               errno = EFAULT;
+               return (-1);    /* bad argument */
+       }
+
+       /*
+        * nb. PPS_CANWAIT is NOT set by the implementation, we can totally
+        * ignore the timeout variable.
+        */
+
+       memset(&infobuf, 0, sizeof(infobuf));
+
+       /*
+        * if not captureassert, nothing to return.
+        */
+
+       if (!handle->params.mode & PPS_CAPTUREASSERT) {
+               memcpy(ppsinfo, &infobuf, sizeof(pps_info_t));
+               return (0);
+       }
+
+#if defined(__STDC__)
+#define CIOGETEV       _IOR('C', 0, struct ppsclockev) /* get last pps event */
+#else
+#define CIOGETEV       _IOR(C, 0, struct ppsclockev)   /* get last pps event */
+#endif
+
+       if (ioctl(handle->filedes, CIOGETEV, (caddr_t) &ev) < 0) {
+               perror("time_pps_fetch:");
+               errno = EOPNOTSUPP;
+               return(-1);
+       }
+
+       /*
+        * Apply offsets as specified. Note that only assert timestamps
+        * are captured by this interface.
+        */
+
+       infobuf.assert_sequence = ev.serial;
+       infobuf.assert_timestamp.tv_sec = ev.tv.tv_sec;
+       infobuf.assert_timestamp.tv_nsec = ev.tv.tv_usec * 1000;
+
+       if (handle->params.mode & PPS_OFFSETASSERT) {
+               infobuf.assert_timestamp.tv_sec  += handle->params.assert_offset.tv_sec;
+               infobuf.assert_timestamp.tv_nsec += handle->params.assert_offset.tv_nsec;
+               PPS_NORMALIZE(infobuf.assert_timestamp);
+       }
+
+       /*
+        * Translate to specified format
+        */
+
+       switch (tsformat) {
+       case PPS_TSFMT_TSPEC:
+               break;           /* timespec format requires no translation */
+
+       case PPS_TSFMT_NTPFP:   /* NTP format requires conversion to fraction form */
+               PPS_TSPECTONTP(infobuf.assert_timestamp_ntpfp);
+               break;
+
+       default:
+               errno = EINVAL;
+               return (-1);
+       }
+
+       infobuf.current_mode = handle->params.mode;
+       memcpy(ppsinfo, &infobuf, sizeof(pps_info_t));
+       return (0);
+}
+
+/*
+ * specify kernel consumer
+ */
+
+static inline int
+time_pps_kcbind(
+       pps_handle_t handle,
+       const int kernel_consumer,
+       const int edge, const int tsformat
+       )
+{
+       /*
+        * Check for valid arguments and bind kernel consumer
+        */
+       if (!handle) {
+               errno = EBADF;
+               return (-1);    /* bad handle */
+       }
+       if (geteuid() != 0) {
+               errno = EPERM;
+               return (-1);    /* must be superuser */
+       }
+       errno = EOPNOTSUPP;
+       return(-1);
+}
+
+#endif /* _SYS_TIMEPPS_H_ */
diff --git a/include/trimble.h b/include/trimble.h
new file mode 100644 (file)
index 0000000..0387639
--- /dev/null
@@ -0,0 +1,160 @@
+/*
+ * /src/NTP/ntp4-dev/include/trimble.h,v 4.6 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * trimble.h,v 4.6 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * $Created: Sun Aug  2 16:16:49 1998 $
+ *
+ * Copyright (c) 1998-2005 by Frank Kardel <kardel <AT> ntp.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+#ifndef TRIMBLE_H
+#define TRIMBLE_H
+
+/*
+ * Trimble packet command codes - commands being sent/received
+ * keep comments formatted as shown - they are used to generate
+ * translation tables
+ */
+#define CMD_CCLROSC    0x1D    /* clear oscillator offset */
+#define CMD_CCLRRST    0x1E    /* clear battery backup and RESET */
+#define CMD_CVERSION   0x1F    /* return software version */
+#define CMD_CALMANAC   0x20    /* almanac */
+#define CMD_CCURTIME   0x21    /* current time */
+#define CMD_CMODESEL   0x22    /* mode select (2-d, 3-D, auto) */
+#define CMD_CINITPOS   0x23    /* initial position */
+#define        CMD_CRECVPOS    0x24    /* receiver position fix mode */
+#define CMD_CRESET     0x25    /* soft reset & selftest */
+#define CMD_CRECVHEALTH        0x26    /* receiver health */
+#define CMD_CSIGNALLV  0x27    /* signal levels */
+#define CMD_CMESSAGE   0x28    /* GPS system message */
+#define CMD_CALMAHEALTH        0x29    /* almanac healt page */
+#define CMD_C2DALTITUDE        0x2A    /* altitude for 2-D mode */
+#define CMD_CINITPOSLLA        0x2B    /* initial position LLA */
+#define CMD_COPERPARAM 0x2C    /* operating parameters */
+#define CMD_COSCOFFSET 0x2D    /* oscillator offset */
+#define CMD_CSETGPSTIME        0x2E    /* set GPS time */
+#define CMD_CUTCPARAM  0x2F    /* UTC parameters */
+#define CMD_CACCPOSXYZ 0x31    /* accurate initial position (XYZ/ECEF) */
+#define CMD_CACCPOS    0x32    /* accurate initial position */
+#define CMD_CANALOGDIG 0x33    /* analog to digital */
+#define CMD_CSAT1SAT   0x34    /* satellite for 1-Sat mode */
+#define CMD_CIOOPTIONS 0x35    /* I/O options */
+#define CMD_CVELOCAID  0x36    /* velocity aiding of acquisition */
+#define CMD_CSTATLSTPOS        0x37    /* status and values of last pos. and vel. */
+#define CMD_CLOADSSATDT        0x38    /* load satellite system data */
+#define CMD_CSATDISABLE        0x39    /* satellite disable */
+#define CMD_CLASTRAW   0x3A    /* last raw measurement */
+#define CMD_CSTATSATEPH        0x3B    /* satellite ephemeris status */
+#define CMD_CSTATTRACK 0x3C    /* tracking status */
+#define CMD_CCHANADGPS 0x3D    /* configure channel A for differential GPS */
+#define CMD_CADDITFIX  0x3E    /* additional fix data */
+#define CMD_CDGPSFIXMD 0x62    /* set/request differential GPS position fix mode */
+#define CMD_CDGPSCORR  0x65    /* differential correction status */
+#define CMD_CPOSFILT   0x71    /* position filter parameters */
+#define CMD_CHEIGHTFILT        0x73    /* height filter control */
+#define CMD_CHIGH8CNT  0x75    /* high-8 (best 4) / high-6 (overdetermined) control */
+#define CMD_CMAXDGPSCOR        0x77    /* maximum rate of DGPS corrections */
+#define CMD_CSUPER     0x8E    /* super paket */
+
+#define CMD_RDATAA     0x3D    /* data channel A configuration:trimble_channelA:RO */
+#define CMD_RALMANAC   0x40    /* almanac data for sat:gps_almanac:RO */
+#define CMD_RCURTIME   0x41    /* GPS time:gps_time:RO */
+#define CMD_RSPOSXYZ   0x42    /* single precision XYZ position:gps_position(XYZ):RO|DEF */
+#define CMD_RVELOXYZ   0x43    /* velocity fix (XYZ ECEF):gps_velocity(XYZ):RO|DEF */
+#define        CMD_RBEST4      0x44    /* best 4 satellite selection:trimble_best4:RO|DEF */
+#define CMD_RVERSION   0x45    /* software version:trimble_version:RO|DEF */
+#define CMD_RRECVHEALTH        0x46    /* receiver health:trimble_receiver_health:RO|DEF */
+#define CMD_RSIGNALLV  0x47    /* signal levels of all satellites:trimble_signal_levels:RO */
+#define CMD_RMESSAGE   0x48    /* GPS system message:gps-message:RO|DEF */
+#define CMD_RALMAHEALTH        0x49    /* almanac health page for all satellites:gps_almanac_health:RO */
+#define CMD_RSLLAPOS   0x4A    /* single LLA position:gps_position(LLA):RO|DEF */
+#define CMD_RMACHSTAT  0x4B    /* machine code / status:trimble_status:RO|DEF */
+#define CMD_ROPERPARAM 0x4C    /* operating parameters:trimble_opparam:RO */
+#define CMD_ROSCOFFSET 0x4D    /* oscillator offset:trimble_oscoffset:RO */
+#define CMD_RSETGPSTIME        0x4E    /* response to set GPS time:trimble_setgpstime:RO */
+#define CMD_RUTCPARAM  0x4F    /* UTC parameters:gps_utc_correction:RO|DEF */
+#define CMD_RANALOGDIG 0x53    /* analog to digital:trimble_analogdigital:RO */
+#define CMD_RSAT1BIAS  0x54    /* one-satellite bias & bias rate:trimble_sat1bias:RO */
+#define CMD_RIOOPTIONS 0x55    /* I/O options:trimble_iooptions:RO */
+#define CMD_RVELOCFIX  0x56    /* velocity fix (ENU):trimble_velocfix */
+#define CMD_RSTATLSTFIX        0x57    /* status and values of last pos. and vel.:trimble_status_lastpos:RO */
+#define CMD_RLOADSSATDT        0x58    /* response to load satellite system data:trimble_loaddata:RO */
+#define CMD_RSATDISABLE        0x59    /* satellite disable:trimble_satdisble:RO */
+#define CMD_RLASTRAW   0x5A    /* last raw measurement:trimble_lastraw:RO */
+#define CMD_RSTATSATEPH        0x5B    /* satellite ephemeris status:trimble_ephstatus:RO */
+#define CMD_RSTATTRACK 0x5C    /* tracking status:trimble_tracking_status:RO|DEF */
+#define CMD_RADDITFIX  0x5E    /* additional fix data:trimble_addfix:RO */
+#define CMD_RALLINVIEW 0x6D    /* all in view satellite selection:trimble_satview:RO|DEF */
+#define CMD_RPOSFILT   0x72    /* position filter parameters:trimble_posfilt:RO */
+#define CMD_RHEIGHTFILT        0x74    /* height filter control:trimble_heightfilt:RO */
+#define CMD_RHIGH8CNT  0x76    /* high-8 (best 4) / high-6 (overdetermined) control:trimble_high8control:RO */
+#define CMD_RMAXAGE    0x78    /* DC MaxAge:trimble_dgpsmaxage:RO */
+#define CMD_RDGPSFIX   0x82    /* differential position fix mode:trimble_dgpsfixmode:RO */
+#define CMD_RDOUBLEXYZ 0x83    /* double precision XYZ:gps_position_ext(XYZ):RO|DEF */
+#define CMD_RDOUBLELLA 0x84    /* double precision LLA:gps_position_ext(LLA):RO|DEF */
+#define CMD_RDGPSSTAT  0x85    /* differential correction status:trimble_dgpsstatus:RO */
+#define CMD_RSUPER     0x8F    /* super paket::0 */
+
+typedef struct cmd_info
+{
+  unsigned char cmd;           /* command code */
+  const char   *cmdname;       /* command name */
+  const char   *cmddesc;       /* command description */
+  const char   *varname;       /* name of variable */
+  int           varmode;       /* mode of variable */
+} cmd_info_t;
+
+extern cmd_info_t trimble_rcmds[];
+extern cmd_info_t trimble_scmds[];
+
+extern cmd_info_t *trimble_convert P((unsigned int cmd, cmd_info_t *tbl));
+
+#endif
+/*
+ * History:
+ *
+ * trimble.h,v
+ * Revision 4.6  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.5  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.4  1999/02/28 11:41:11  kardel
+ * (CMD_RUTCPARAM): control variable name unification
+ *
+ * Revision 4.3  1998/12/20 23:45:25  kardel
+ * fix types and warnings
+ *
+ * Revision 4.2  1998/08/16 18:45:05  kardel
+ * (CMD_RSTATTRACK): renamed mode 6 variable name
+ *
+ * Revision 4.1  1998/08/09 22:24:35  kardel
+ * Trimble TSIP support
+ *
+ */
diff --git a/include/version.def b/include/version.def
new file mode 100644 (file)
index 0000000..f0dc444
--- /dev/null
@@ -0,0 +1 @@
+version = '4.2.4p8';
diff --git a/install-sh b/install-sh
new file mode 100755 (executable)
index 0000000..4d4a951
--- /dev/null
@@ -0,0 +1,323 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2005-05-14.22
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+chmodcmd="$chmodprog 0755"
+chowncmd=
+chgrpcmd=
+stripcmd=
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=
+dst=
+dir_arg=
+dstarg=
+no_target_directory=
+
+usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+-c         (ignored)
+-d         create directories instead of installing files.
+-g GROUP   $chgrpprog installed files to GROUP.
+-m MODE    $chmodprog installed files to MODE.
+-o USER    $chownprog installed files to USER.
+-s         $stripprog installed files.
+-t DIRECTORY  install into DIRECTORY.
+-T         report an error if DSTFILE is a directory.
+--help     display this help and exit.
+--version  display version info and exit.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
+"
+
+while test -n "$1"; do
+  case $1 in
+    -c) shift
+        continue;;
+
+    -d) dir_arg=true
+        shift
+        continue;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+        shift
+        shift
+        continue;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) chmodcmd="$chmodprog $2"
+        shift
+        shift
+        continue;;
+
+    -o) chowncmd="$chownprog $2"
+        shift
+        shift
+        continue;;
+
+    -s) stripcmd=$stripprog
+        shift
+        continue;;
+
+    -t) dstarg=$2
+       shift
+       shift
+       continue;;
+
+    -T) no_target_directory=true
+       shift
+       continue;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    *)  # When -d is used, all remaining arguments are directories to create.
+       # When -t is used, the destination is already specified.
+       test -n "$dir_arg$dstarg" && break
+        # Otherwise, the last argument is the destination.  Remove it from $@.
+       for arg
+       do
+          if test -n "$dstarg"; then
+           # $@ is not empty: it contains at least $arg.
+           set fnord "$@" "$dstarg"
+           shift # fnord
+         fi
+         shift # arg
+         dstarg=$arg
+       done
+       break;;
+  esac
+done
+
+if test -z "$1"; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src ;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    src=
+
+    if test -d "$dst"; then
+      mkdircmd=:
+      chmodcmd=
+    else
+      mkdircmd=$mkdirprog
+    fi
+  else
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dstarg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dstarg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst ;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+       echo "$0: $dstarg: Is a directory" >&2
+       exit 1
+      fi
+      dst=$dst/`basename "$src"`
+    fi
+  fi
+
+  # This sed command emulates the dirname command.
+  dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
+
+  # Make sure that the destination directory exists.
+
+  # Skip lots of stat calls in the usual case.
+  if test ! -d "$dstdir"; then
+    defaultIFS='
+        '
+    IFS="${IFS-$defaultIFS}"
+
+    oIFS=$IFS
+    # Some sh's can't handle IFS=/ for some reason.
+    IFS='%'
+    set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+    shift
+    IFS=$oIFS
+
+    pathcomp=
+
+    while test $# -ne 0 ; do
+      pathcomp=$pathcomp$1
+      shift
+      if test ! -d "$pathcomp"; then
+        $mkdirprog "$pathcomp"
+       # mkdir can fail with a `File exist' error in case several
+       # install-sh are creating the directory concurrently.  This
+       # is OK.
+       test -d "$pathcomp" || exit
+      fi
+      pathcomp=$pathcomp/
+    done
+  fi
+
+  if test -n "$dir_arg"; then
+    $doit $mkdircmd "$dst" \
+      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
+      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
+      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
+      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
+
+  else
+    dstfile=`basename "$dst"`
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+    trap '(exit $?); exit' 1 2 13 15
+
+    # Copy the file name to the temp name.
+    $doit $cpprog "$src" "$dsttmp" &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
+      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
+      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
+      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
+
+    # Now rename the file to the real destination.
+    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
+      || {
+          # The rename failed, perhaps because mv can't rename something else
+          # to itself, or perhaps because mv is so ancient that it does not
+          # support -f.
+
+          # Now remove or move aside any old file at destination location.
+          # We try this two ways since rm can't unlink itself on some
+          # systems and the destination file might be busy for other
+          # reasons.  In this case, the final cleanup might fail but the new
+          # file should still install successfully.
+          {
+            if test -f "$dstdir/$dstfile"; then
+              $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
+              || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
+              || {
+                echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+                (exit 1); exit 1
+              }
+            else
+              :
+            fi
+          } &&
+
+          # Now rename the file to the real destination.
+          $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+        }
+    }
+  fi || { (exit 1); exit 1; }
+done
+
+# The final little trick to "correctly" pass the exit status to the exit trap.
+{
+  (exit 0); exit 0
+}
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/kernel/Makefile.am b/kernel/Makefile.am
new file mode 100644 (file)
index 0000000..b3cfc9d
--- /dev/null
@@ -0,0 +1,5 @@
+#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+SUBDIRS = sys
+ETAGS_ARGS = Makefile.am
+EXTRA_DIST = chuinit.c clkinit.c tty_chu.c tty_chu_STREAMS.c tty_clk.c tty_clk_STREAMS.c
diff --git a/kernel/Makefile.in b/kernel/Makefile.in
new file mode 100644 (file)
index 0000000..b00e41a
--- /dev/null
@@ -0,0 +1,582 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = kernel
+DIST_COMMON = README $(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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+       html-recursive info-recursive install-data-recursive \
+       install-dvi-recursive install-exec-recursive \
+       install-html-recursive install-info-recursive \
+       install-pdf-recursive install-ps-recursive install-recursive \
+       installcheck-recursive installdirs-recursive pdf-recursive \
+       ps-recursive uninstall-recursive
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+       $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+       distdir
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = $(SUBDIRS)
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+SUBDIRS = sys
+ETAGS_ARGS = Makefile.am
+EXTRA_DIST = chuinit.c clkinit.c tty_chu.c tty_chu_STREAMS.c tty_clk.c tty_clk_STREAMS.c
+all: all-recursive
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign kernel/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign kernel/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       rev=''; for subdir in $$list; do \
+         if test "$$subdir" = "."; then :; else \
+           rev="$$subdir $$rev"; \
+         fi; \
+       done; \
+       rev="$$rev ."; \
+       target=`echo $@ | sed s/-recursive//`; \
+       for subdir in $$rev; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done && test -z "$$fail"
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+ctags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+       done
+
+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: tags-recursive $(HEADERS) $(SOURCES)  $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test -d "$(distdir)/$$subdir" \
+           || $(MKDIR_P) "$(distdir)/$$subdir" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-recursive
+all-am: Makefile
+installdirs: installdirs-recursive
+installdirs-am:
+install: install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-recursive
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) ctags-recursive \
+       install-am install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+       all all-am check check-am clean clean-generic clean-libtool \
+       ctags ctags-recursive distclean 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 installdirs-am maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-generic \
+       mostlyclean-libtool pdf pdf-am ps ps-am tags tags-recursive \
+       uninstall uninstall-am
+
+
+# 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.
+.NOEXPORT:
diff --git a/kernel/README b/kernel/README
new file mode 100644 (file)
index 0000000..253d04e
--- /dev/null
@@ -0,0 +1,200 @@
+Installing Line Disciplines and Streams Modules
+
+Description
+
+Most radio and modem clocks used for a primary (stratum-1) NTP server
+utilize serial ports operating at speeds of 9600 baud or greater. The
+timing jitter contributed by the serial port hardware and software
+discipline can accumulate to several milliseconds on a typical Unix
+workstation. In order to reduce these errors, a set of special line
+disciplines can be configured in the operating system process. These
+disciplines intercept special characters or signals provided by the
+radio or modem clock and save a local timestamp for later processing.
+
+The disciplines can be compiled in the kernel in older BSD-derived
+systems, or installed as System V streams modules and either compiled in
+the kernel or dynamically loaded when required. In either case, they
+require reconfiguration of the Unix kernel and provisions in the NTP
+daemon xntpd. The streams modules can be pushed and popped from the
+streams stack using conventional System V streams program primitives.
+Note that not all Unix kernels support line disciplines and of those
+that do, not all support System V streams. The disciplines here are
+known to work correctly with SunOS 4.x kernels, but have not been tested
+for other kernels.
+
+There are two line disciplines included in the distribution. Support for
+each is enabled by adding flags to the DEFS_LOCAL line of the build
+configuration file ./Config.local. This can be done automatically by the
+autoconfiguration build procedures, or can be inserted/deleted after the
+process has completed.
+
+tty_clk (CLK)
+
+     This discipline intercepts characters received from the serial port
+     and passes unchanged all except a set of designated characters to
+     the generic serial port discipline. For each of the exception
+     characters, the character is inserted in the receiver buffer
+     followed by a timestamp in Unix timeval format. Both select() and
+     SIGIO are supported by the discipline. The -DCLK flag is used to
+     compile support for this disipline in the NTP daemon. This flag is
+     included if the clkdefs.h file is found in the /sys/sys directory,
+     or it can be added (or deleted) manually.
+
+tty_chu (CHU)
+
+     This discipline is a special purpose line discipline for receiving
+     a special timecode broadcast by Canadian time and frequency
+     standard station CHU. The radio signal is first demodulated by the
+     300-baud modem included in the gadget box, then processed by the
+     discipline and finally processed by the Scratchbuilt CHU Receiver
+     discipline (type 7). This discipline should be used in raw mode.
+     The -DCHU flag is used to compile support for this disipline in the
+     NTP daemon. This flag is included if the chudefs.h file is found in
+     the /sys/sys directory, or it can be added (or deleted) manually.
+
+There are two sets of line disciplines. The tty_clk.c and chu_clk.c are
+designed for use with older BSD systems and are compiled in the kernel.
+The tty_clk_STREAMS.c and chu_clk_STREAMS.c are designed for use with
+System V streams, in which case they can be either compiled in the
+kernel or dynamically loaded. Since these disciplines are small,
+unobtrusive, and to nothing unless specifically enabled by an
+application program, it probably doesn't matter which method is choosen.
+
+Compiling with the Kernel
+
+The following procedures are for the tty_clk line discipline; for the
+chu_clk, change "tty" to "chu".
+1.   Copy tty_clk.c into /sys/os and clkdefs.h into /sys/sys.
+
+2.   For SunOS 4.x systems, edit /sys/os/tty_conf.c using some facsimile
+     of the following lines:
+
+     #include "clk.h"
+     ...
+     #if NCLK > 0
+     int  clkopen(), clkclose(), clkwrite(), clkinput(), clkioctl();
+     #endif
+     ...
+     #if NCLK > 0
+          { clkopen, clkclose, ttread, clkwrite, clkioctl,
+            clkinput, nodev, nulldev, ttstart, nullmodem, /* 10 CLK */
+            ttselect },
+     #else
+          { nodev, nodev, nodev, nodev, nodev,
+            nodev, nodev, nodev, nodev, nodev,
+            nodev },
+     #endif
+
+     For Ultrix 4.x systems, edit /sys/data/tty_conf_data.c using some
+     facsimile of the following lines:
+
+     #include "clk.h"
+     ...
+     #if NCLK > 0
+     int  clkopen(), clkclose(), clkwrite(), clkinput(), clkioctl();
+     #endif
+     ...
+     #if NCLK > 0
+          clkopen, clkclose, ttread, clkwrite, clkioctl, /* 10 CLK */
+          clkinput, nodev, nulldev, ttstart, nulldev,
+     #else
+          nodev, nodev, nodev, nodev, nodev,
+          nodev, nodev, nodev, nodev, nodev,
+     #endif
+
+     If the kernel doesn't include the ??select() entry in the structure
+     (i.e., there are only ten entry points in the structure) just leave
+     it out. Also note that the number you give the line discipline (10
+     in most kernels) will be specific to that kernel and will depend on
+     what is in there already. The entries sould be in order with no
+     missing space; that is, if there are only seven disciplines already
+     defined and you want to use 10 for good reason, you should define a
+     dummy 9th entry like this:
+
+     nodev, nodev, nodev, nodev, nodev, /* 9 CLK */
+     nodev, nodev, nodev, nodev, nodev,
+
+3.   Edit /sys/h/ioctl.h and include a line somewhere near where other
+     line disciplines are defined like:
+
+     #define  CLKLDISC  10        /* clock line discipline */
+
+     The "10" should match what you used as the number in the preceding
+     step.
+
+4.   Edit /sys/conf/files and add a line which looks like:
+
+     sys/tty_clk.c     optional clk
+
+5.   Edit the kernel configuration file to include the following:
+
+     pseudo-device  tty 4  # TTY clock support
+6.   Run config, then make clean, then make depend, then make vmunix,
+     then reboot the new kernel.
+
+Installing as a streams module
+
+The following procedures are for the tty_clk_STREAMS line discipline;
+for the tty_chu_STREAMS, change "clk" to "chu".
+
+1.   Copy your choice to /sys/os, removing the "_STREAMS" in the
+     filename.
+
+2.   Copy the clkdefs.h file to /usr/include/sys, then construct a soft
+     link to /sys/sys.
+
+3.   Append to /sys/conf.common/files.cmn:
+
+     os/tty_tty.c  optional tty
+
+4.   Edit /sys/sun/str_conf.c. You'll want to add lines in three places.
+     It'll be sort of clear where when you see the file.
+
+     #include "tty.h"
+     ...
+     #if NTTY > 0
+     extern struct streamtab ttyinfo;
+     #endif
+     ...
+     #if NTTY > 0
+          { "tty", &ttyinfo },
+     #endif
+
+5.   Edit /sys/[arch]/conf/[k-name] (substituting the architecture and
+     kernel name) to stick in:
+
+     pseudo-device  tty 4  # TTY clock support
+
+     You can change "4" to anything you like. It will limit the number
+     of instantiations of the tty discipline you can use at the same
+     time.
+
+6.   Run config, then make clean, then make depend, then make vmunix,
+     then reboot the new kernel.
+
+Both disciplines can be dynamically loaded using streams procedures
+specific to the kernel. Before using the chu_clk discipline, all other
+streams modules that may already be on the stack should be popped, then
+the discipline should be pushed on the stack.
+
+How to Use the tty_clk Line Discipline
+
+The tty_clk line discipline defines a new ioctl(), CLK_SETSTR, which
+takes a pointer to a string of no more than CLK_MAXSTRSIZE characters.
+Until the first CLK_SETSTR is performed, the discipline will simply pass
+through characters. Once it is passed a string by CLK_SETSTR, any
+character in that string will be immediately followed by a timestamp in
+Unix timeval format. You can change the string whenever you want by
+doing another CLK_SETSTR. The character must be an exact, 8 bit match.
+The character '\000' cannot, unfortunately, be used, as it is the string
+terminator. Passing an empty string to CLK_SETSTR turns off stamping.
+Passing NULL will produce undefined results.
+
+How to Use the tty_chu Line Discipline
+The tty_chu line discipline translates data received from the CHU modem
+and returns chucode structures, as defined in chudefs.h, and expected by
+the Scratchbuilt CHU Receiver reference clock  driver. Depending on the
+settings of PEDANTIC and ANAL_RETENTIVE used when compiling the kernel,
+some checking of the data may or may not be necessary.
+
+David L. Mills (mills@udel.edu)
diff --git a/kernel/chuinit.c b/kernel/chuinit.c
new file mode 100644 (file)
index 0000000..270c3d5
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+**     dynamically loadable chu driver
+**
+**     william robertson <rob@agate.berkeley.edu>  
+*/
+
+#include <sys/types.h>
+#include <sys/conf.h>
+#include <sys/errno.h>
+#include <sys/stream.h>
+#include <sys/syslog.h>
+
+#include <sun/openprom.h>
+#include <sun/vddrv.h>
+
+extern int findmod();          /* os/str_io.c */
+
+extern struct streamtab chuinfo;
+
+struct vdldrv vd = {
+     VDMAGIC_USER,
+     "chu"
+  };
+
+
+int
+xxxinit(function_code, vdp, vdi, vds)
+unsigned int function_code;
+struct vddrv *vdp;
+addr_t vdi;
+struct vdstat *vds;
+{
+     register int i = 0;
+     register int j;
+
+     switch (function_code) {
+       case VDLOAD:
+
+         if (findmod("chu") >= 0) {
+              log(LOG_ERR, "chu stream module already loaded\n");
+              return (EADDRINUSE);
+         }
+         i = findmod("\0");
+
+         if (i == -1 || fmodsw[i].f_name[0] != '\0') 
+           return(-1);
+
+         for (j = 0; vd.Drv_name[j] != '\0'; j++)      /* XXX check bounds */
+           fmodsw[i].f_name[j] = vd.Drv_name[j];
+
+         fmodsw[i].f_name[j] = '\0';
+         fmodsw[i].f_str = &chuinfo;
+
+         vdp->vdd_vdtab = (struct vdlinkage *)  &vd;
+
+         return(0);
+
+       case VDUNLOAD:
+         if ((i = findmod(vd.Drv_name)) == -1)
+           return(-1);
+
+         fmodsw[i].f_name[0] = '\0';
+         fmodsw[i].f_str = 0;
+
+         return(0);
+     
+       case VDSTAT:
+         return(0);
+
+       default:
+         return(EIO);
+     }
+}
diff --git a/kernel/clkinit.c b/kernel/clkinit.c
new file mode 100644 (file)
index 0000000..716ca81
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+**     dynamically loadable clk driver
+**
+**     william robertson <rob@agate.berkeley.edu>  
+*/
+
+#include <sys/types.h>
+#include <sys/conf.h>
+#include <sys/errno.h>
+#include <sys/stream.h>
+#include <sys/syslog.h>
+
+#include <sun/openprom.h>
+#include <sun/vddrv.h>
+
+extern int findmod();          /* os/str_io.c */
+
+extern struct streamtab clkinfo;
+
+struct vdldrv vd = {
+     VDMAGIC_USER,
+     "clk"
+  };
+
+
+int
+xxxinit(function_code, vdp, vdi, vds)
+unsigned int function_code;
+struct vddrv *vdp;
+addr_t vdi;
+struct vdstat *vds;
+{
+     register int i = 0;
+     register int j;
+
+     switch (function_code) {
+       case VDLOAD:
+
+         if (findmod("clk") >= 0) {
+              log(LOG_ERR, "clk stream module already loaded\n");
+              return (EADDRINUSE);
+         }
+         i = findmod("\0");
+
+         if (i == -1 || fmodsw[i].f_name[0] != '\0') 
+           return(-1);
+
+         for (j = 0; vd.Drv_name[j] != '\0'; j++)      /* XXX check bounds */
+           fmodsw[i].f_name[j] = vd.Drv_name[j];
+
+         fmodsw[i].f_name[j] = '\0';
+         fmodsw[i].f_str = &clkinfo;
+
+         vdp->vdd_vdtab = (struct vdlinkage *)  &vd;
+
+         return(0);
+
+       case VDUNLOAD:
+         if ((i = findmod(vd.Drv_name)) == -1)
+           return(-1);
+
+         fmodsw[i].f_name[0] = '\0';
+         fmodsw[i].f_str = 0;
+
+         return(0);
+     
+       case VDSTAT:
+         return(0);
+
+       default:
+         return(EIO);
+     }
+}
diff --git a/kernel/sys/Makefile.am b/kernel/sys/Makefile.am
new file mode 100644 (file)
index 0000000..e8465d9
--- /dev/null
@@ -0,0 +1,8 @@
+#AUTOMAKE_OPTIONS = ../../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../../util/ansi2knr
+noinst_HEADERS = bsd_audioirig.h chudefs.h clkdefs.h i8253.h parsestreams.h \
+ pcl720.h ppsclock.h timex.h tpro.h tt560_api.h
+#EXTRA_DIST= TAGS
+# HMS: Avoid bug in automake 
+#ETAGS_ARGS = ""
+ETAGS_ARGS = Makefile.am
diff --git a/kernel/sys/Makefile.in b/kernel/sys/Makefile.in
new file mode 100644 (file)
index 0000000..4565a2e
--- /dev/null
@@ -0,0 +1,437 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = kernel/sys
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+SOURCES =
+DIST_SOURCES =
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#AUTOMAKE_OPTIONS = ../../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../../util/ansi2knr
+noinst_HEADERS = bsd_audioirig.h chudefs.h clkdefs.h i8253.h parsestreams.h \
+ pcl720.h ppsclock.h timex.h tpro.h tt560_api.h
+
+#EXTRA_DIST= TAGS
+# HMS: Avoid bug in automake 
+#ETAGS_ARGS = ""
+ETAGS_ARGS = Makefile.am
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign kernel/sys/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign kernel/sys/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+       clean-libtool ctags distclean 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-generic \
+       mostlyclean-libtool pdf pdf-am ps ps-am tags uninstall \
+       uninstall-am
+
+
+# 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.
+.NOEXPORT:
diff --git a/kernel/sys/README b/kernel/sys/README
new file mode 100644 (file)
index 0000000..b9d95d9
--- /dev/null
@@ -0,0 +1,11 @@
+README file for directory ./kernel/sys of the NTP Version 3 distribution
+
+This directory contains system header files used by the clock discipline
+and STREAMS modules in the .. (./kernel) directory.
+
+If the precision-time kernel (KERNEL_PLL define) is configured, the
+installation process requires the header file /usr/include/sys/timex.h
+for the particular architecture to be in place. The file timex.h included
+in this distribution is for Suns; the files for other systems can be
+found in the kernel distributions available from the manufacturer's
+representatives.
diff --git a/kernel/sys/bsd_audioirig.h b/kernel/sys/bsd_audioirig.h
new file mode 100644 (file)
index 0000000..9b7c690
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ *     $Header: bsd_audioirig.h,v 1.0 93/08/02 12:42:00
+ */
+
+#ifndef _BSD_AUDIOIRIG_H_
+#define _BSD_AUDIOIRIG_H_
+
+#include <sys/time.h>
+
+/********************************************************************/
+/* user interface */
+
+/*
+ * irig ioctls
+ */
+#if defined(__STDC__) || (!defined(sun) && !defined(ibm032) && !defined(__GNUC))
+#define AUDIO_IRIG_OPEN         _IO('A', 50)
+#define AUDIO_IRIG_CLOSE        _IO('A', 51)
+#define AUDIO_IRIG_SETFORMAT    _IOWR('A', 52, int)
+#else
+#define AUDIO_IRIG_OPEN         _IO(A, 50)
+#define AUDIO_IRIG_CLOSE        _IO(A, 51)
+#define AUDIO_IRIG_SETFORMAT    _IOWR(A, 52, int)
+#endif
+
+/*
+ * irig error codes
+ */
+#define AUDIO_IRIG_BADSIGNAL   0x01
+#define AUDIO_IRIG_BADDATA     0x02
+#define AUDIO_IRIG_BADSYNC     0x04
+#define AUDIO_IRIG_BADCLOCK    0x08
+#define AUDIO_IRIG_OLDDATA     0x10
+
+/********************************************************************/
+
+/*
+ * auib definitions
+ */
+#define AUIB_SIZE      (0x0040)
+#define AUIB_INC       (0x0008)
+#define AUIB_MOD(k)    ((k) & 0x0038)
+#define AUIB_INIT(ib)  ((ib)->ib_head = (ib)->ib_tail = (ib)->ib_lock = \
+                        (ib)->phase = (ib)->shi = (ib)->slo = (ib)->high = \
+                        (ib)->level0 = (ib)->level1 = \
+                        (ib)->shift[0] = (ib)->shift[1] = (ib)->shift[2] = \
+                        (ib)->shift[3] = (ib)->sdata[0] = (ib)->sdata[1] = \
+                        (ib)->sdata[2] = (ib)->sdata[3] = (ib)->err = 0)
+#define AUIB_EMPTY(ib) ((ib)->ib_head == (ib)->ib_tail)
+#define AUIB_LEN(ib)   (AUIB_MOD((ib)->ib_tail - (ib)->ib_head))
+#define AUIB_LEFT(ib)  (AUIB_MOD((ib)->ib_head - (ib)->ib_tail - 1))
+#define IRIGDELAY 3
+#define IRIGLEVEL 1355
+
+#ifndef LOCORE
+/*
+ * irig_time holds IRIG data for one second
+ */
+struct irig_time {
+        struct timeval  stamp;          /* timestamp */
+        u_char  bits[13];               /* 100 irig data bits */
+       u_char  status;                 /* status byte */
+        char    time[14];               /* time string */
+};
+
+/*
+ * auib's are used for IRIG data communication between the trap
+ * handler and the software interrupt.
+ */
+struct auib {
+       /* driver variables */
+       u_short active;                 /* 0=inactive, else=active */
+       u_short format;                 /* time output format */
+       struct  irig_time timestr;      /* time structure */
+       char    buffer[14];             /* output formation buffer */
+
+       /* hardware interrupt variables */
+       struct  timeval tv1,tv2,tv3;    /* time stamps (median filter) */
+       int     level0,level1;          /* lo/hi input levels */
+       int     level;                  /* decision level */
+       int     high;                   /* recent largest sample */
+       int     sl0,sl1;                /* recent sample levels */
+       int     lasts;                  /* last sample value */
+       u_short scount;                 /* sample count */
+       u_long  eacc;                   /* 10-bit element accumulator */
+       u_long  ebit;                   /* current bit in element */
+       u_char  r_level,mmr1;           /* recording level 0-255 */
+       int     shi,slo,phase;          /* AGC variables */
+       u_long  err;                    /* error status bits */
+       int     ecount;                 /* count of elements this second */
+       long    shift[4];               /* shift register of pos ident */
+       long    sdata[4];               /* shift register of symbols */
+
+       int     ib_head;                /* queue head */
+       int     ib_tail;                /* queue tail */
+       u_short ib_lock;                /* queue head lock */
+       u_long  ib_data[AUIB_SIZE];     /* data buffer */
+};
+#endif
+
+#endif /* _BSD_AUDIOIRIG_H_ */
diff --git a/kernel/sys/chudefs.h b/kernel/sys/chudefs.h
new file mode 100644 (file)
index 0000000..f5549f5
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * Definitions for the CHU line discipline v2.0
+ */
+
+/*
+ * The CHU time code consists of 10 BCD digits and is repeated
+ * twice for a total of 10 characters.  A time is taken after
+ * the arrival of each character.  The following structure is
+ * used to return this stuff.
+ */
+#define        NCHUCHARS       (10)
+
+struct chucode {
+       u_char codechars[NCHUCHARS];    /* code characters */
+       u_char ncodechars;              /* number of code characters */
+       u_char chutype;                 /* packet type */
+       struct timeval codetimes[NCHUCHARS];    /* arrival times */
+};
+
+#define CHU_TIME 0             /* second half is equal to first half */
+#define CHU_YEAR 1             /* second half is one's complement */
+
diff --git a/kernel/sys/clkdefs.h b/kernel/sys/clkdefs.h
new file mode 100644 (file)
index 0000000..afbc77a
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Defines for the "clk" timestamping STREAMS module
+ */
+
+#if defined(sun)
+#include <sys/ioccom.h>
+#else
+#include <sys/ioctl.h>
+#endif
+
+/*
+ * First, we need to define the maximum size of the set of
+ * characters to timestamp. 32 is MORE than enough.
+ */
+
+#define CLK_MAXSTRSIZE 32
+struct clk_tstamp_charset {            /* XXX to use _IOW not _IOWN */
+       char    val[CLK_MAXSTRSIZE];
+};
+
+/*
+ * ioctl(fd, CLK_SETSTR, (char*)c );
+ *
+ * will tell the driver that any char in the null-terminated
+ * string c should be timestamped. It is possible, though
+ * unlikely that this ioctl number could collide with an
+ * existing one on your system. If so, change the 'K'
+ * to some other letter. However, once you've compiled
+ * the kernel with this include file, you should NOT
+ * change this file.
+ */
+
+#if defined(__STDC__)                  /* XXX avoid __STDC__=0 on SOLARIS */
+#define CLK_SETSTR _IOW('K', 01, struct clk_tstamp_charset)
+#else
+#define CLK_SETSTR _IOW(K, 01, struct clk_tstamp_charset)
+#endif
+
diff --git a/kernel/sys/i8253.h b/kernel/sys/i8253.h
new file mode 100644 (file)
index 0000000..7096593
--- /dev/null
@@ -0,0 +1,48 @@
+/* Copyright (c) 1995 Vixie Enterprises
+ *
+ * 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, and that
+ * the name of Vixie Enterprises not be used in advertising or publicity
+ * pertaining to distribution of the document or software without specific,
+ * written prior permission.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS" AND VIXIE ENTERPRISES DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL VIXIE ENTERPRISES
+ * 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.
+ */
+
+#ifndef _I8253_DEFINED
+#define _I8253_DEFINED
+
+typedef union {
+       unsigned char   i;
+       struct {
+               unsigned int    bcd     : 1;
+#define                                i8253_binary    0
+#define                                i8253_bcd       1
+               unsigned int    mode    : 3;
+#define                                i8253_termcnt   0
+#define                                i8253_oneshot   1
+#define                                i8253_rategen   2
+#define                                i8253_sqrwave   3
+#define                                i8253_softstb   4
+#define                                i8253_hardstb   5
+               unsigned int    rl      : 2;
+#define                                i8253_latch     0
+#define                                i8253_lsb       1
+#define                                i8253_msb       2
+#define                                i8253_lmb       3
+               unsigned int    cntr    : 2;
+#define                                i8253_cntr_0    0
+#define                                i8253_cntr_1    1
+#define                                i8253_cntr_2    2
+       } s;
+} i8253_ctrl;
+
+#endif /*_I8253_DEFINED*/
diff --git a/kernel/sys/parsestreams.h b/kernel/sys/parsestreams.h
new file mode 100644 (file)
index 0000000..e784f9e
--- /dev/null
@@ -0,0 +1,133 @@
+/*
+ * /src/NTP/ntp4-dev/kernel/sys/parsestreams.h,v 4.5 2005/06/25 10:52:47 kardel RELEASE_20050625_A
+ *
+ * parsestreams.h,v 4.5 2005/06/25 10:52:47 kardel RELEASE_20050625_A
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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(lint) || defined(__GNUC__))
+  static char sysparsehrcsid[] = "parsestreams.h,v 4.5 2005/06/25 10:52:47 kardel RELEASE_20050625_A";
+#endif
+
+#undef PARSEKERNEL
+#if defined(KERNEL) || defined(_KERNEL)
+#ifndef PARSESTREAM
+#define PARSESTREAM
+#endif
+#endif
+#if defined(PARSESTREAM) && defined(HAVE_SYS_STREAM_H)
+#define PARSEKERNEL
+
+#ifdef HAVE_SYS_TERMIOS_H
+#include <sys/termios.h>
+#endif
+
+#include <sys/ppsclock.h>
+
+#ifndef NTP_NEED_BOPS
+#define NTP_NEED_BOPS
+#endif
+
+#if defined(PARSESTREAM) && (defined(_sun) || defined(__sun)) && defined(HAVE_SYS_STREAM_H)
+/*
+ * Sorry, but in SunOS 4.x AND Solaris 2.x kernels there are no
+ * mem* operations. I don't want them - bcopy, bzero
+ * are fine in the kernel
+ */
+#undef HAVE_STRING_H   /* don't include that at kernel level - prototype mismatch in Solaris 2.6 */
+#include "ntp_string.h"
+#else
+#include <stdio.h>
+#endif
+
+struct parsestream             /* parse module local data */
+{
+  queue_t       *parse_queue;  /* read stream for this channel */
+  queue_t      *parse_dqueue;  /* driver queue entry (PPS support) */
+  unsigned long  parse_status;  /* operation flags */
+  void          *parse_data;   /* local data space (PPS support) */
+  parse_t       parse_io;      /* io structure */
+  struct ppsclockev parse_ppsclockev; /* copy of last pps event */
+};
+
+typedef struct parsestream parsestream_t;
+
+#define PARSE_ENABLE   0x0001
+
+/*--------------- debugging support ---------------------------------*/
+
+#define DD_OPEN    0x00000001
+#define DD_CLOSE   0x00000002
+#define DD_RPUT    0x00000004
+#define DD_WPUT    0x00000008
+#define DD_RSVC    0x00000010
+#define DD_PARSE   0x00000020
+#define DD_INSTALL 0x00000040
+#define DD_ISR     0x00000080
+#define DD_RAWDCF  0x00000100
+
+extern int parsedebug;
+
+#ifdef DEBUG_PARSE
+
+#define parseprintf(X, Y) if ((X) & parsedebug) printf Y
+
+#else
+
+#define parseprintf(X, Y)
+
+#endif
+#endif
+
+/*
+ * History:
+ *
+ * parsestreams.h,v
+ * Revision 4.5  2005/06/25 10:52:47  kardel
+ * fix version id / add version log
+ *
+ * Revision 4.4  1998/06/14 21:09:32  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.3  1998/06/13 18:14:32  kardel
+ * make mem*() to b*() mapping magic work on Solaris too
+ *
+ * Revision 4.2  1998/06/13 15:16:22  kardel
+ * fix mem*() to b*() function macro emulation
+ *
+ * Revision 4.1  1998/06/13 11:50:37  kardel
+ * STREAM macro gone in favor of HAVE_SYS_STREAM_H
+ *
+ * Revision 4.0  1998/04/10 19:51:30  kardel
+ * Start 4.0 release version numbering
+ *
+ * Revision 1.2  1998/04/10 19:27:42  kardel
+ * initial NTP VERSION 4 integration of PARSE with GPS166 binary support
+ *
+ */
diff --git a/kernel/sys/pcl720.h b/kernel/sys/pcl720.h
new file mode 100644 (file)
index 0000000..cf4eccd
--- /dev/null
@@ -0,0 +1,95 @@
+/* Copyright (c) 1995 Vixie Enterprises
+ *
+ * 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, and that
+ * the name of Vixie Enterprises not be used in advertising or publicity
+ * pertaining to distribution of the document or software without specific,
+ * written prior permission.
+ * 
+ * THE SOFTWARE IS PROVIDED "AS IS" AND VIXIE ENTERPRISES DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL VIXIE ENTERPRISES
+ * 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.
+ */
+
+#ifndef _PCL720_DEFINED
+#define _PCL720_DEFINED
+
+#define        pcl720_data(base,bit)   (base+(bit>>3))
+#define pcl720_data_0_7(base)  (base+0)
+#define pcl720_data_8_15(base) (base+1)
+#define pcl720_data_16_23(base)        (base+2)
+#define pcl720_data_24_31(base)        (base+3)
+#define pcl720_cntr(base,cntr) (base+4+cntr)   /* cntr: 0..2 */
+#define pcl720_cntr_0(base)    (base+4)
+#define pcl720_cntr_1(base)    (base+5)
+#define pcl720_cntr_2(base)    (base+6)
+#define pcl720_ctrl(base)      (base+7)
+
+#ifndef DEBUG_PCL720
+#define        pcl720_inb(x)           inb(x)
+#define        pcl720_outb(x,y)        outb(x,y)
+#else
+static unsigned char pcl720_inb(int addr) {
+       unsigned char x = inb(addr);
+       fprintf(DEBUG_PCL720, "inb(0x%x) -> 0x%x\n", addr, x);
+       return (x);
+}
+static void pcl720_outb(int addr, unsigned char x) {
+       outb(addr, x);
+       fprintf(DEBUG_PCL720, "outb(0x%x, 0x%x)\n", addr, x);
+}
+#endif
+
+#define        pcl720_load(Base,Cntr,Mode,Val) \
+       ({      register unsigned int   b = Base, c = Cntr, v = Val; \
+               i8253_ctrl ctrl; \
+               \
+               ctrl.s.bcd = i8253_binary; \
+               ctrl.s.mode = Mode; \
+               ctrl.s.rl = i8253_lmb; \
+               ctrl.s.cntr = c; \
+               pcl720_outb(pcl720_ctrl(b), ctrl.i); \
+               pcl720_outb(pcl720_cntr(b,c), v); \
+               pcl720_outb(pcl720_cntr(b,c), v >> 8); \
+               v; \
+       })
+
+#define        pcl720_read(Base,Cntr) \
+       ({      register unsigned int   b = Base, v; \
+               i8253_ctrl ctrl; \
+               \
+               ctrl.s.rl = i8253_latch; \
+               ctrl.s.cntr = i8253_cntr_0; \
+               pcl720_outb(pcl720_ctrl(b), ctrl.i); \
+               v = pcl720_inb(pcl720_cntr_0(b)); \
+               v |= (pcl720_inb(pcl720_cntr_0(b)) << 8); \
+               v; \
+       })
+
+#define        pcl720_input(Base) \
+       ({      register unsigned int   b = Base, v; \
+               \
+               v = pcl720_inb(pcl720_data_0_7(b)); \
+               v |= (pcl720_inb(pcl720_data_8_15(b)) << 8); \
+               v |= (pcl720_inb(pcl720_data_16_23(b)) << 16); \
+               v |= (pcl720_inb(pcl720_data_24_31(b)) << 24); \
+               v; \
+       })
+
+#define        pcl720_output(Base,Value) \
+       ({      register unsigned int   b = Base, v = Value; \
+               \
+               pcl720_outb(pcl720_data_0_7(b), v); \
+               pcl720_outb(pcl720_data_8_15(b), v << 8); \
+               pcl720_outb(pcl720_data_16_23(b), v << 16); \
+               pcl720_outb(pcl720_data_24_31(b), v << 24); \
+               v; \
+       })
+
+#endif /*_PCL720_DEFINED*/
diff --git a/kernel/sys/ppsclock.h b/kernel/sys/ppsclock.h
new file mode 100644 (file)
index 0000000..b0fe407
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66.
+ *
+ * Copyright (c) 1992 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 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, Lawrence Berkeley Laboratory.
+ * 4. The name of the University may not 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.
+ */
+
+#ifndef TIOCGPPSEV
+#define PPSCLOCKSTR    "ppsclock"
+
+#ifndef HAVE_STRUCT_PPSCLOCKEV
+struct ppsclockev {
+       struct timeval tv;
+       u_int serial;
+};
+#endif
+
+#if defined(__STDC__) || defined(SYS_HPUX)
+#ifdef _IOR
+#define CIOGETEV        _IOR('C', 0, struct ppsclockev)        /* get last pps event */
+#else  /* XXX SOLARIS is different */
+#define        CIO     ('C'<<8)
+#define CIOGETEV        (CIO|0)                /* get last pps event */
+#endif /* _IOR */
+#else  /* __STDC__ */
+#ifdef _IOR
+#define CIOGETEV        _IOR(C, 0, struct ppsclockev)  /* get last pps event */
+#else  /* XXX SOLARIS is different */
+#define        CIO     ('C'<<8)
+#define CIOGETEV        (CIO|0)                /* get last pps event */
+#endif /* _IOR */
+#endif /* __STDC__ */
+#else
+#define CIOGETEV TIOCGPPSEV
+#endif
diff --git a/kernel/sys/timex.h b/kernel/sys/timex.h
new file mode 100644 (file)
index 0000000..d42ec08
--- /dev/null
@@ -0,0 +1,309 @@
+/******************************************************************************
+ *                                                                            *
+ * Copyright (c) David L. Mills 1993, 1994                                    *
+ *                                                                            *
+ * Permission to use, copy, modify, and distribute this software and its      *
+ * documentation for any purpose and without fee is hereby granted, provided  *
+ * that the above copyright notice appears in all copies and that both the    *
+ * copyright notice and this permission notice appear in supporting           *
+ * documentation, and that the name University of Delaware not be used in     *
+ * advertising or publicity pertaining to distribution of the software        *
+ * without specific, written prior permission.  The University of Delaware    *
+ * makes no representations about the suitability this software for any       *
+ * purpose.  It is provided "as is" without express or implied warranty.      *
+ *                                                                            *
+ ******************************************************************************/
+
+/*
+ * Modification history timex.h
+ *
+ * 26 Sep 94   David L. Mills
+ *     Added defines for hybrid phase/frequency-lock loop.
+ *
+ * 19 Mar 94   David L. Mills
+ *     Moved defines from kernel routines to header file and added new
+ *     defines for PPS phase-lock loop.
+ *
+ * 20 Feb 94   David L. Mills
+ *     Revised status codes and structures for external clock and PPS
+ *     signal discipline.
+ *
+ * 28 Nov 93   David L. Mills
+ *     Adjusted parameters to improve stability and increase poll
+ *     interval.
+ *
+ * 17 Sep 93    David L. Mills
+ *      Created file
+ */
+/*
+ * This header file defines the Network Time Protocol (NTP) interfaces
+ * for user and daemon application programs. These are implemented using
+ * private syscalls and data structures and require specific kernel
+ * support.
+ *
+ * NAME
+ *     ntp_gettime - NTP user application interface
+ *
+ * SYNOPSIS
+ *     #include <sys/timex.h>
+ *
+ *     int syscall(SYS_ntp_gettime, tptr)
+ *
+ *     int SYS_ntp_gettime             defined in syscall.h header file
+ *     struct ntptimeval *tptr         pointer to ntptimeval structure
+ *
+ * NAME
+ *     ntp_adjtime - NTP daemon application interface
+ *
+ * SYNOPSIS
+ *     #include <sys/timex.h>
+ *
+ *     int syscall(SYS_ntp_adjtime, mode, tptr)
+ *
+ *     int SYS_ntp_adjtime             defined in syscall.h header file
+ *     struct timex *tptr              pointer to timex structure
+ *
+ */
+#ifndef _SYS_TIMEX_H_
+#define _SYS_TIMEX_H_ 1
+
+#ifndef MSDOS                  /* Microsoft specific */
+#include <sys/syscall.h>
+#endif /* MSDOS */
+
+/*
+ * The following defines establish the engineering parameters of the
+ * phase-lock loop (PLL) model used in the kernel implementation. These
+ * parameters have been carefully chosen by analysis for good stability
+ * and wide dynamic range.
+ *
+ * The hz variable is defined in the kernel build environment. It
+ * establishes the timer interrupt frequency, 100 Hz for the SunOS
+ * kernel, 256 Hz for the Ultrix kernel and 1024 Hz for the OSF/1
+ * kernel. SHIFT_HZ expresses the same value as the nearest power of two
+ * in order to avoid hardware multiply operations.
+ *
+ * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
+ * for a slightly underdamped convergence characteristic. SHIFT_KH
+ * establishes the damping of the FLL and is chosen by wisdom and black
+ * art.
+ *
+ * MAXTC establishes the maximum time constant of the PLL. With the
+ * SHIFT_KG and SHIFT_KF values given and a time constant range from
+ * zero to MAXTC, the PLL will converge in 15 minutes to 16 hours,
+ * respectively.
+ */
+#define SHIFT_HZ 7             /* log2(hz) */
+#define SHIFT_KG 6             /* phase factor (shift) */
+#define SHIFT_KF 16            /* PLL frequency factor (shift) */
+#define SHIFT_KH 2             /* FLL frequency factor (shift) */
+#define MAXTC 6                        /* maximum time constant (shift) */
+
+/*
+ * The following defines establish the scaling of the various variables
+ * used by the PLL. They are chosen to allow the greatest precision
+ * possible without overflow of a 32-bit word.
+ *
+ * SHIFT_SCALE defines the scaling (shift) of the time_phase variable,
+ * which serves as a an extension to the low-order bits of the system
+ * clock variable time.tv_usec.
+ *
+ * SHIFT_UPDATE defines the scaling (shift) of the time_offset variable,
+ * which represents the current time offset with respect to standard
+ * time.
+ *
+ * SHIFT_USEC defines the scaling (shift) of the time_freq and
+ * time_tolerance variables, which represent the current frequency
+ * offset and maximum frequency tolerance.
+ *
+ * FINEUSEC is 1 us in SHIFT_UPDATE units of the time_phase variable.
+ */
+#define SHIFT_SCALE 22         /* phase scale (shift) */
+#define SHIFT_UPDATE (SHIFT_KG + MAXTC) /* time offset scale (shift) */
+#define SHIFT_USEC 16          /* frequency offset scale (shift) */
+#define FINEUSEC (1L << SHIFT_SCALE) /* 1 us in phase units */
+
+/*
+ * The following defines establish the performance envelope of the PLL.
+ * They insure it operates within predefined limits, in order to satisfy
+ * correctness assertions. An excursion which exceeds these bounds is
+ * clamped to the bound and operation proceeds accordingly. In practice,
+ * this can occur only if something has failed or is operating out of
+ * tolerance, but otherwise the PLL continues to operate in a stable
+ * mode.
+ *
+ * MAXPHASE must be set greater than or equal to CLOCK.MAX (128 ms), as
+ * defined in the NTP specification. CLOCK.MAX establishes the maximum
+ * time offset allowed before the system time is reset, rather than
+ * incrementally adjusted. Here, the maximum offset is clamped to
+ * MAXPHASE only in order to prevent overflow errors due to defective
+ * protocol implementations.
+ *
+ * MAXFREQ is the maximum frequency tolerance of the CPU clock
+ * oscillator plus the maximum slew rate allowed by the protocol. It
+ * should be set to at least the frequency tolerance of the oscillator
+ * plus 100 ppm for vernier frequency adjustments. If the kernel
+ * PPS discipline code is configured (PPS_SYNC), the oscillator time and
+ * frequency are disciplined to an external source, presumably with
+ * negligible time and frequency error relative to UTC, and MAXFREQ can
+ * be reduced.
+ *
+ * MAXTIME is the maximum jitter tolerance of the PPS signal if the
+ * kernel PPS discipline code is configured (PPS_SYNC).
+ *
+ * MINSEC and MAXSEC define the lower and upper bounds on the interval
+ * between protocol updates.
+ */
+#define MAXPHASE 512000L       /* max phase error (us) */
+#ifdef PPS_SYNC
+#define MAXFREQ (512L << SHIFT_USEC) /* max freq error (100 ppm) */
+#define MAXTIME (200L << PPS_AVG) /* max PPS error (jitter) (200 us) */
+#else
+#define MAXFREQ (512L << SHIFT_USEC) /* max freq error (200 ppm) */
+#endif /* PPS_SYNC */
+#define MINSEC 16L             /* min interval between updates (s) */
+#define MAXSEC 1200L           /* max interval between updates (s) */
+
+#ifdef PPS_SYNC
+/*
+ * The following defines are used only if a pulse-per-second (PPS)
+ * signal is available and connected via a modem control lead, such as
+ * produced by the optional ppsclock feature incorporated in the Sun
+ * asynch driver. They establish the design parameters of the frequency-
+ * lock loop used to discipline the CPU clock oscillator to the PPS
+ * signal.
+ *
+ * PPS_AVG is the averaging factor for the frequency loop, as well as
+ * the time and frequency dispersion.
+ *
+ * PPS_SHIFT and PPS_SHIFTMAX specify the minimum and maximum
+ * calibration intervals, respectively, in seconds as a power of two.
+ *
+ * PPS_VALID is the maximum interval before the PPS signal is considered
+ * invalid and protocol updates used directly instead.
+ *
+ * MAXGLITCH is the maximum interval before a time offset of more than
+ * MAXTIME is believed.
+ */
+#define PPS_AVG 2              /* pps averaging constant (shift) */
+#define PPS_SHIFT 2            /* min interval duration (s) (shift) */
+#define PPS_SHIFTMAX 8         /* max interval duration (s) (shift) */
+#define PPS_VALID 120          /* pps signal watchdog max (s) */
+#define MAXGLITCH 30           /* pps signal glitch max (s) */
+#endif /* PPS_SYNC */
+
+/*
+ * The following defines and structures define the user interface for
+ * the ntp_gettime() and ntp_adjtime() system calls.
+ *
+ * Control mode codes (timex.modes)
+ */
+#define MOD_OFFSET     0x0001  /* set time offset */
+#define MOD_FREQUENCY  0x0002  /* set frequency offset */
+#define MOD_MAXERROR   0x0004  /* set maximum time error */
+#define MOD_ESTERROR   0x0008  /* set estimated time error */
+#define MOD_STATUS     0x0010  /* set clock status bits */
+#define MOD_TIMECONST  0x0020  /* set pll time constant */
+#define MOD_CANSCALE   0x0040  /* kernel can scale offset field */
+#define MOD_DOSCALE    0x0080  /* userland wants to scale offset field */
+
+/*
+ * Status codes (timex.status)
+ */
+#define STA_PLL                0x0001  /* enable PLL updates (rw) */
+#define STA_PPSFREQ    0x0002  /* enable PPS freq discipline (rw) */
+#define STA_PPSTIME    0x0004  /* enable PPS time discipline (rw) */
+#define STA_FLL                0x0008  /* select frequency-lock mode (rw) */
+
+#define STA_INS                0x0010  /* insert leap (rw) */
+#define STA_DEL                0x0020  /* delete leap (rw) */
+#define STA_UNSYNC     0x0040  /* clock unsynchronized (rw) */
+#define STA_FREQHOLD   0x0080  /* hold frequency (rw) */
+
+#define STA_PPSSIGNAL  0x0100  /* PPS signal present (ro) */
+#define STA_PPSJITTER  0x0200  /* PPS signal jitter exceeded (ro) */
+#define STA_PPSWANDER  0x0400  /* PPS signal wander exceeded (ro) */
+#define STA_PPSERROR   0x0800  /* PPS signal calibration error (ro) */
+
+#define STA_CLOCKERR   0x1000  /* clock hardware fault (ro) */
+
+#define STA_RONLY (STA_PPSSIGNAL | STA_PPSJITTER | STA_PPSWANDER | \
+    STA_PPSERROR | STA_CLOCKERR) /* read-only bits */
+
+/*
+ * Clock states (time_state)
+ */
+#define TIME_OK                0       /* no leap second warning */
+#define TIME_INS       1       /* insert leap second warning */
+#define TIME_DEL       2       /* delete leap second warning */
+#define TIME_OOP       3       /* leap second in progress */
+#define TIME_WAIT      4       /* leap second has occurred */
+#define TIME_ERROR     5       /* clock not synchronized */
+
+/*
+ * NTP user interface (ntp_gettime()) - used to read kernel clock values
+ *
+ * Note: maximum error = NTP synch distance = dispersion + delay / 2;
+ * estimated error = NTP dispersion.
+ */
+struct ntptimeval {
+       struct timeval time;    /* current time (ro) */
+       long maxerror;          /* maximum error (us) (ro) */
+       long esterror;          /* estimated error (us) (ro) */
+};
+
+/*
+ * NTP daemon interface - (ntp_adjtime()) used to discipline CPU clock
+ * oscillator
+ */
+struct timex {
+       unsigned int modes;     /* clock mode bits (wo) */
+       long offset;            /* time offset (us) (rw) */
+       long freq;              /* frequency offset (scaled ppm) (rw) */
+       long maxerror;          /* maximum error (us) (rw) */
+       long esterror;          /* estimated error (us) (rw) */
+       int status;             /* clock status bits (rw) */
+       long constant;          /* pll time constant (rw) */
+       long precision;         /* clock precision (us) (ro) */
+       long tolerance;         /* clock frequency tolerance (scaled
+                                * ppm) (ro) */
+       /*
+        * The following read-only structure members are implemented
+        * only if the PPS signal discipline is configured in the
+        * kernel.
+        */
+       long ppsfreq;           /* pps frequency (scaled ppm) (ro) */
+       long jitter;            /* pps jitter (us) (ro) */
+       int shift;              /* interval duration (s) (shift) (ro) */
+       long stabil;            /* pps stability (scaled ppm) (ro) */
+       long jitcnt;            /* jitter limit exceeded (ro) */
+       long calcnt;            /* calibration intervals (ro) */
+       long errcnt;            /* calibration errors (ro) */
+       long stbcnt;            /* stability limit exceeded (ro) */
+
+};
+#ifdef __FreeBSD__
+
+/*
+ * sysctl identifiers underneath kern.ntp_pll
+ */
+#define NTP_PLL_GETTIME        1       /* used by ntp_gettime() */
+#define NTP_PLL_MAXID  2       /* number of valid ids */
+
+#define NTP_PLL_NAMES { \
+                         { 0, 0 }, \
+                         { "gettime", CTLTYPE_STRUCT }, \
+                     }
+
+#ifndef KERNEL
+#include <sys/cdefs.h>
+
+__BEGIN_DECLS
+extern int ntp_gettime        __P((struct ntptimeval *));
+extern int ntp_adjtime        __P((struct timex *));
+__END_DECLS
+
+#endif /* not KERNEL */
+
+#endif /* __FreeBSD__ */
+#endif /* _SYS_TIMEX_H_ */
diff --git a/kernel/sys/tpro.h b/kernel/sys/tpro.h
new file mode 100644 (file)
index 0000000..f276f81
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * Structure for the KSI/Odetics TPRO-S data returned in reponse to a
+ * read() call. Note that these are driver-specific and not dependent on
+ * 32/64-bit architecture.
+ */
+struct tproval {
+       u_short day100;         /* days * 100 */
+       u_short day10;          /* days * 10 */
+       u_short day1;           /* days * 1 */
+       u_short hour10;         /* hours * 10 */
+       u_short hour1;          /* hours * 1 */
+       u_short min10;          /* minutes * 10 */
+       u_short min1;           /* minutes * 1 */
+       u_short sec10;          /* seconds * 10 */
+       u_short sec1;           /* seconds * 1*/
+       u_short ms100;          /* milliseconds * 100 */
+       u_short ms10;           /* milliseconds * 10 */
+       u_short ms1;            /* milliseconds * 1 */
+       u_short usec100;        /* microseconds * 100 */
+       u_short usec10;         /* microseconds * 10 */
+       u_short usec1;          /* microseconds * 1 */
+       long tv_sec;            /* seconds */
+       long tv_usec;           /* microseconds */
+       u_short status;         /* status register */
+};
+
+/*
+ * Status register bits
+ */
+#define        TIMEAVAIL 0x0001        /* time available */
+#define NOSIGNAL 0x0002                /* insufficient IRIG-B signal */
+#define NOSYNC 0x0004          /* local oscillator not synchronized */
+
+/* end of tpro.h */
diff --git a/kernel/sys/tt560_api.h b/kernel/sys/tt560_api.h
new file mode 100644 (file)
index 0000000..c87a7b1
--- /dev/null
@@ -0,0 +1,489 @@
+/***********************************************************************
+ *
+ *  Module:  ttime_api.h
+ *
+ *  Author:  SIS  1998
+ *           LM NE&SS 2001
+ *
+ *  Description
+ *
+ *      This header file contains data necessary for the API to the
+ *      True Time board. This contains all of the structure definitions
+ *      for the individual registers.
+ *
+ ***********************************************************************/
+#ifndef TTIME_API_H
+#define TTIME_API_H
+
+#ifdef CPP
+extern "C" {
+#endif
+
+#include <time.h>
+
+typedef struct
+{
+    unsigned int       micro_sec;
+    unsigned int       milli_sec;
+    struct tm          gps_tm;
+} gps_time_t;
+
+typedef struct 
+{
+    unsigned char reserved_1;
+    unsigned unit_ms           : 4;
+    unsigned filler_0          : 4;
+    unsigned hun_ms            : 4;
+    unsigned tens_ms           : 4;
+    unsigned tens_sec          : 4;
+    unsigned unit_sec          : 4;
+
+    unsigned tens_min          : 4;
+    unsigned unit_min          : 4;
+    unsigned tens_hour         : 4;
+    unsigned unit_hour         : 4;
+    unsigned tens_day          : 4;
+    unsigned unit_day          : 4;
+    unsigned filler_1          : 4;
+    unsigned hun_day           : 4;
+
+    unsigned tens_year         : 4;
+    unsigned unit_year         : 4;
+    unsigned thou_year         : 4;
+    unsigned hun_year          : 4;
+    unsigned char reserved_2[2];
+} preset_time_reg_t;
+
+typedef struct
+{
+    unsigned n_d0                      : 2;
+    unsigned antenna_short_stat                : 1; /* 0 = fault */
+    unsigned antenna_open_stat         : 1; /* 0 = fault */
+    unsigned n_d1                      : 1;
+    unsigned rate_gen_pulse_stat       : 1;
+    unsigned time_cmp_pulse_stat       : 1;
+    unsigned ext_event_stat            : 1;
+
+} hw_stat_reg_t;
+
+typedef struct 
+{
+    unsigned tens_us           : 4;
+    unsigned unit_us           : 4;
+    unsigned unit_ms           : 4;
+    unsigned hun_us            : 4;
+    unsigned char hw_stat;     /* hw_stat_reg_t hw_stat; */
+    unsigned char reserved_3;
+
+    unsigned hun_ms            : 4;
+    unsigned tens_ms           : 4;
+    unsigned tens_sec          : 4;
+    unsigned unit_sec          : 4;
+    unsigned tens_min          : 4;
+    unsigned unit_min          : 4;
+    unsigned tens_hour         : 4;
+    unsigned unit_hour         : 4;
+
+    unsigned tens_day          : 4;
+    unsigned unit_day          : 4;
+    unsigned status            : 4;
+    unsigned hun_day           : 4;
+    unsigned tens_year         : 4;
+    unsigned unit_year         : 4;
+    unsigned thou_year         : 4;
+    unsigned hun_year          : 4;
+} time_freeze_reg_t;
+
+typedef struct
+{
+    unsigned char off_low;
+    unsigned char off_high;
+    unsigned char reserved_4[2];
+} sync_gen_off_reg_t;
+
+typedef struct
+{
+    unsigned tens_min          : 4;
+    unsigned unit_min          : 4;
+    unsigned tens_hour         : 4;
+    unsigned unit_hour         : 4;
+    unsigned char sign_ascii;  /* '+' or '-' */
+    unsigned char reserved_5;
+} local_off_t;
+
+/*
+ *  This structure can be used for both the position freeze
+ *  and position preset registers.
+ */
+typedef struct
+{
+    unsigned lat_tens_degee            : 4;
+    unsigned lat_unit_degee            : 4;
+    unsigned filler_0                  : 4;
+    unsigned lat_hun_degree            : 4;
+    unsigned lat_tens_min              : 4;
+    unsigned lat_unit_min              : 4;
+    unsigned char lat_north_south;     /* 'N' or 'S' */
+
+    unsigned filler_1                  : 4;
+    unsigned lat_tenth_sec             : 4;
+    unsigned lat_tens_sec              : 4;
+    unsigned lat_unit_sec              : 4;
+    unsigned long_tens_degree          : 4;
+    unsigned long_unit_degree          : 4;
+    unsigned filler_2                  : 4;
+    unsigned long_hun_degree           : 4;
+
+    unsigned long_tens_min             : 4;
+    unsigned long_unit_min             : 4;
+    unsigned char long_east_west;      /* 'E' or 'W' */
+    unsigned filler_3                  : 4;
+    unsigned long_tenth_sec            : 4;
+    unsigned long_tens_sec             : 4;
+    unsigned long_unit_sec             : 4;
+
+    unsigned elv_tens_km               : 4;
+    unsigned elv_unit_km               : 4;
+    unsigned char elv_sign;            /* '+' or '-' */
+    unsigned elv_unit_m                        : 4;
+    unsigned elv_tenth_m               : 4;
+    unsigned elv_hun_m                 : 4;
+    unsigned elv_tens_m                        : 4;
+} pos_reg_t;
+
+typedef struct
+{
+    unsigned char prn1_tens_units;
+    unsigned char prn1_reserved;
+    unsigned char lvl1_tenths_hundredths;
+    unsigned char lvl1_tens_units;
+
+    unsigned char prn2_tens_units;
+    unsigned char prn2_reserved;
+    unsigned char lvl2_tenths_hundredths;
+    unsigned char lvl2_tens_units;
+
+    unsigned char prn3_tens_units;
+    unsigned char prn3_reserved;
+    unsigned char lvl3_tenths_hundredths;
+    unsigned char lvl3_tens_units;
+
+    unsigned char prn4_tens_units;
+    unsigned char prn4_reserved;
+    unsigned char lvl4_tenths_hundredths;
+    unsigned char lvl4_tens_units;
+
+    unsigned char prn5_tens_units;
+    unsigned char prn5_reserved;
+    unsigned char lvl5_tenths_hundredths;
+    unsigned char lvl5_tens_units;
+
+    unsigned char prn6_tens_units;
+    unsigned char prn6_reserved;
+    unsigned char lvl6_tenths_hundredths;
+    unsigned char lvl6_tens_units;
+
+    unsigned char flag;
+    unsigned char reserved[3];
+} sig_levels_t;
+
+typedef struct
+{
+    unsigned tens_us           : 4;
+    unsigned unit_us           : 4;
+    unsigned unit_ms           : 4;
+    unsigned hun_us            : 4;
+    unsigned hun_ms            : 4;
+    unsigned tens_ms           : 4;
+    unsigned tens_sec          : 4;
+    unsigned unit_sec          : 4;
+
+    unsigned tens_min          : 4;
+    unsigned unit_min          : 4;
+    unsigned tens_hour         : 4;
+    unsigned unit_hour         : 4;
+    unsigned tens_day          : 4;
+    unsigned unit_day          : 4;
+    unsigned stat              : 4;
+    unsigned hun_day           : 4;
+
+    unsigned tens_year         : 4;
+    unsigned unit_year         : 4;
+    unsigned thou_year         : 4;
+    unsigned hun_year          : 4;
+    unsigned char reserved_5[2]; 
+} ext_time_event_reg_t;
+
+typedef struct
+{
+    unsigned tens_us   : 4;
+    unsigned unit_us   : 4;
+    unsigned unit_ms   : 4;
+    unsigned hun_us    : 4;
+    unsigned hun_ms    : 4;
+    unsigned tens_ms   : 4;
+    unsigned tens_sec  : 4;
+    unsigned unit_sec  : 4;
+
+    unsigned tens_min  : 4;
+    unsigned unit_min  : 4;
+    unsigned tens_hour : 4;
+    unsigned unit_hour : 4;
+    unsigned tens_day  : 4;
+    unsigned unit_day  : 4;
+    unsigned mask      : 4;
+    unsigned hun_day   : 4;
+} time_cmp_reg_t;
+
+typedef struct
+{
+    unsigned char err_stat;
+    unsigned char no_def;
+    unsigned char oscillator_stat[2];
+} diag_reg_t;
+
+typedef struct
+{
+    unsigned res               :2;
+    unsigned rate_int_mask     :1;
+    unsigned cmp_int_mask      :1;
+    unsigned ext_int_mask      :1;
+    unsigned rate_stat_clr     :1;
+    unsigned cmp_stat_clr      :1;
+    unsigned ext_stat_clr      :1;
+    unsigned char reserved[3];
+} hw_ctl_reg_t;
+
+typedef struct
+{
+    unsigned  preset_pos_rdy   :1;
+    unsigned  sel_pps_ref      :1;
+    unsigned  sel_gps_ref      :1;
+    unsigned  sel_time_code    :1;
+    unsigned  gen_stp_run      :1;
+    unsigned  preset_time_rdy  :1;
+    unsigned  dst              :1;
+    unsigned  mode_sel         :1;
+
+    unsigned  ctl_am_dc                :1;
+    unsigned  reserved         :3;
+    unsigned  input_code       :4;
+
+    unsigned char rate_reserved;
+
+    unsigned  rate_flag                :4;
+    unsigned  rate_reserved1   :4;
+} conf_reg_t;
+
+typedef struct
+{
+     unsigned char     mem_reserved[0xf8];
+
+     hw_ctl_reg_t      hw_ctl_reg;
+
+     time_freeze_reg_t  time_freeze_reg;
+
+     pos_reg_t         pos_freeze_reg;
+
+     conf_reg_t                conf_reg;
+
+     diag_reg_t                diag_reg;
+
+     local_off_t       local_offset;
+
+     sync_gen_off_reg_t sync_gen_offset;
+
+     unsigned char     reserved[4];
+
+     unsigned char     config_reg2_ctl;
+
+     unsigned char      reserved2[11];
+
+     time_cmp_reg_t    time_compare_reg;
+
+     unsigned char     reserved3[24];
+
+     preset_time_reg_t preset_time_reg;
+
+     pos_reg_t         preset_pos_reg;
+
+     ext_time_event_reg_t extern_time_event_reg;
+
+     unsigned char     reserved4[24];
+
+     sig_levels_t      signal_levels_reg;
+
+     unsigned char     reserved5[12];
+} tt_mem_space_t;
+
+#define TTIME_MEMORY_SIZE 0x200
+
+/*
+ *  Defines for register offsets
+ */
+#define HW_CTL_REG             0x0f8
+#define TIME_FREEZE_REG                0x0fc
+#define HW_STAT_REG            0x0fe
+#define POS_FREEZE_REG         0x108
+#define CONFIG_REG_1           0x118
+#define DIAG_REG               0x11c
+#define LOCAL_OFF_REG          0x120
+#define SYNC_GEN_OFF_REG       0x124
+#define CONFIG_REG_2           0x12c
+#define TIME_CMP_REG           0x138
+#define PRESET_TIME_REG                0x158
+#define PRESET_POS_REG         0x164
+#define EXT_EVENT_REG          0x174
+#define SIG_LVL_PRN1           0x198
+#define SIG_LVL_PRN2           0x19c
+#define SIG_LVL_PRN3           0x1a0
+#define SIG_LVL_PRN4           0x1a4
+#define SIG_LVL_PRN5           0x1a8
+#define SIG_LVL_PRN6           0x1ac
+#define SIG_LVL_FLAG           0x1b0
+
+/*
+ *  Defines for accessing the hardware status register.
+ */
+#define HW_STAT_ANTENNA_SHORT          0       /* access the antenna short bit */
+#define HW_STAT_ANTENNA_OPEN           1       /* access the antenna open bit */
+#define HW_STAT_RATE_GEN_PULSE_STAT    2       /* access the rate gen pulse bit */
+#define HW_STAT_TIME_CMP_PULSE_STAT    3       /* access the time cmp bit */
+#define HW_STAT_EXT_EVENT_STAT         4       /* access the external event bit */
+
+/*
+ *  Defines for accessing the hardware control register
+ */
+
+#define HW_CTL_RATE_INT_MASK           0       /* access rate generator int mask */
+#define HW_CTL_CMP_INT_MASK            1       /* access compare interrupt mask */
+#define HW_CTL_EXT_INT_MASK            2       /* access external event interrupt mask */
+#define HW_CTL_RATE_GEN_INT_CLEAR      3       /* access rate gen. interrupt clear field */
+#define HW_CTL_TIME_CMP_INT_CLEAR      4       /* access time cmp interrupt clear field */
+#define HW_CTL_EXT_EVENT_INT_CLEAR     5       /* access external event int clear field */
+
+/*
+ *  Defines for configuration register bit fields.
+ */
+#define PRESET_POS_RDY_BIT             0       /* access the preset pos. rdy. bit */
+#define SEL_1_PPS_REF_BIT              1       /* access the select 1 pps reference bit */
+#define SEL_GPS_REF_BIT                        2       /* access the select gps reference bit */
+#define SEL_TIME_CODE_REF_BIT          3       /* access the select time code reference bit */
+#define GEN_STOP_BIT                   4       /* access the generator start/stop bit */
+#define PRESET_TIME_RDY_BIT            5       /* access the preset time ready bit */
+#define DST_BIT                                6       /* access the DST bit */
+#define MODE_SEL_BIT                   7       /* access the mode select bit */
+#define AM_DC_BIT                      8       /* access the code bits AM/DC bit */
+#define IN_CODE_SEL_BIT                        9       /* access the input code select bit */
+#define FLAG_BIT                       10      /* access the flag bit */
+
+/*
+ * The following defines are used to set modes in the 
+ * configuration register.
+ */
+
+#define CONF_SET_AM                    0       /* Set code to AM   */
+#define CONF_SET_DC                    1       /* Set code to DC   */
+#define CONF_SET_IRIG_B                        0       /* Set code IRIG B  */
+#define CONF_SET_IRIG_A                        1       /* Set code IRIG A  */
+
+#define CONF_FLAG_DISABLE              0       /* Disable pulse        */
+#define CONF_FLAG_10K_PPS              1       /* Set rate to 10k PPS  */
+#define CONF_FLAG_1K_PPS               2       /* Set rate to 1k PPS   */
+#define CONF_FLAG_100_PPS              3       /* Set rate to 100 PPS  */
+#define CONF_FLAG_10_PPS               4       /* Set rate to 10 PPS   */
+#define CONF_FLAG_1_PPS                        5       /* Set rate to 1 PPS    */
+
+/*
+ *  Defines for read commands
+ */
+
+#define TT_RD_FREEZE_REG       0x01
+#define TT_RD_HW_CTL_REG       0x02
+#define TT_RD_CNFG_REG         0x03
+#define TT_RD_DIAG_REG         0x04
+#define TT_RD_LCL_OFFSET       0x05
+#define TT_RD_SYNC_GEN_OFF     0x06
+#define TT_RD_CNFG_REG_2       0x07
+#define TT_RD_TIME_CMP_REG     0x08
+#define TT_RD_PRESET_REG       0x09
+#define TT_RD_EXT_EVNT_REG     0x0a
+#define TT_RD_SIG_LVL_REG      0x0b
+
+/*
+ *  Defines for write commands
+ */
+#define TT_WRT_FREEZE_REG      0x0c
+#define TT_WRT_HW_CTL_REG      0x0d
+#define TT_WRT_CNFG_REG                0x0e
+#define TT_WRT_DIAG_REG                0x0f
+#define TT_WRT_LCL_OFFSET      0x10
+#define TT_WRT_SYNC_GEN_OFF    0x11
+#define TT_WRT_CNFG_REG_2      0x12
+#define TT_WRT_TIME_CMP_REG    0x13
+#define TT_WRT_PRESET_REG      0x14
+#define TT_WRT_EXT_EVNT_REG    0x15
+#define TT_WRT_SIG_LVL_REG     0x16
+
+/*
+ *  Define the length of the buffers to move (in 32 bit words).
+ */
+
+#define HW_CTL_REG_LEN         1
+#define CNFG_REG_1_LEN         1
+#define DIAG_REG_LEN           1
+#define LCL_OFFSET_LEN         1
+#define SYNC_GEN_OFF_LEN       1
+#define CNFG_REG_2_LEN         1
+
+#define TIME_CMP_REG_LEN       2
+#define PRESET_TIME_REG_LEN    3
+#define PRESET_POS_REG_LEN     4
+#define PRESET_REG_LEN         (PRESET_TIME_REG_LEN+PRESET_POS_REG_LEN)
+#define TIME_FREEZE_REG_LEN    3
+#define POSN_FREEZE_REG_LEN    4
+#define FREEZE_REG_LEN         (TIME_FREEZE_REG_LEN+POSN_FREEZE_REG_LEN)
+#define EXT_EVNT_REG_LEN       3
+#define        SIG_LVL_REG_LEN         7
+#define        GPS_TIME_LEN            7
+
+/*
+ * Define BCD - INT - BCD macros.
+ */
+
+#define BCDTOI(a)      ( ( ( ( (a) & 0xf0 ) >> 4 ) * 10 )  + ( (a) & 0x0f ) )
+#define ITOBCD(a)      ( ( ( (           (a) ) / 10) << 4 ) + ( (           (a) ) % 10) )
+#define LTOBCD(a)      ( ( ( ( (uint64_t)(a) ) / 10) << 4 ) + ( ( (uint64_t)(a) ) % 10) )
+
+extern int  init_560                  (                      );
+extern void close_560                 (                      );
+extern int  write_hw_ctl_reg          (hw_ctl_reg_t         *);
+extern int  write_hw_ctl_reg_bitfield (int, int              );
+extern int  read_conf_reg             (conf_reg_t           *);
+extern int  read_conf_reg_bitfield    (int                   );
+extern int  write_conf_reg            (conf_reg_t           *);
+extern int  write_conf_reg_bitfield   (int, unsigned char    );
+extern int  read_hw_stat_reg_bitfield (int                   );
+extern int  read_local_offset_reg     (local_off_t          *);
+extern int  write_local_offset_reg    (local_off_t          *);
+extern int  read_sync_offset_reg      (sync_gen_off_reg_t   *);
+extern int  write_sync_offset_reg     (sync_gen_off_reg_t   *);
+extern int  read_time_cmp_reg         (time_cmp_reg_t       *);
+extern int  write_time_cmp_reg        (time_cmp_reg_t       *);
+extern int  read_preset_time_reg      (preset_time_reg_t    *);
+extern int  write_preset_time_reg     (preset_time_reg_t    *);
+extern int  reset_time                (                      );
+extern int  set_new_time              (preset_time_reg_t    *);
+extern int  read_preset_position_reg  (pos_reg_t            *);
+extern int  write_preset_position_reg (pos_reg_t            *);
+extern int  read_external_event_reg   (ext_time_event_reg_t *);
+extern int  read_signal_level_reg     (sig_levels_t         *);
+extern int  freeze_time               (                      );
+extern int  snapshot_time             (time_freeze_reg_t    *);
+extern int  read_position_freeze_reg  (pos_reg_t            *);
+extern int  read_diag_reg             (diag_reg_t           *);
+
+#ifdef CPP
+}
+#endif
+#endif
diff --git a/kernel/tty_chu.c b/kernel/tty_chu.c
new file mode 100644 (file)
index 0000000..4615875
--- /dev/null
@@ -0,0 +1,276 @@
+/* tty_chu.c,v 3.1 1993/07/06 01:07:30 jbj Exp
+ * tty_chu.c - CHU line driver
+ */
+
+#include "chu.h"
+#if NCHU > 0
+
+#include "../h/param.h"
+#include "../h/types.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/ioctl.h"
+#include "../h/tty.h"
+#include "../h/proc.h"
+#include "../h/file.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+#include "../h/uio.h"
+
+#include "../h/chudefs.h"
+
+/*
+ * Line discipline for receiving CHU time codes.
+ * Does elementary noise elimination, takes time stamps after
+ * the arrival of each character, returns a buffer full of the
+ * received 10 character code and the associated time stamps.
+ */
+#define        NUMCHUBUFS      3
+
+struct chudata {
+       u_char used;            /* Set to 1 when structure in use */
+       u_char lastindex;       /* least recently used buffer */
+       u_char curindex;        /* buffer to use */
+       u_char sleeping;        /* set to 1 when we're sleeping on a buffer */
+       struct chucode chubuf[NUMCHUBUFS];
+} chu_data[NCHU];
+
+/*
+ * Number of microseconds we allow between
+ * character arrivals.  The speed is 300 baud
+ * so this should be somewhat more than 30 msec
+ */
+#define        CHUMAXUSEC      (50*1000)       /* 50 msec */
+
+int chu_debug = 0;
+
+/*
+ * Open as CHU time discipline.  Called when discipline changed
+ * with ioctl, and changes the interpretation of the information
+ * in the tty structure.
+ */
+/*ARGSUSED*/
+chuopen(dev, tp)
+       dev_t dev;
+       register struct tty *tp;
+{
+       register struct chudata *chu;
+
+       /*
+        * Don't allow multiple opens.  This will also protect us
+        * from someone opening /dev/tty
+        */
+       if (tp->t_line == CHULDISC)
+               return (EBUSY);
+       ttywflush(tp);
+       for (chu = chu_data; chu < &chu_data[NCHU]; chu++)
+               if (!chu->used)
+                       break;
+       if (chu >= &chu[NCHU])
+               return (EBUSY);
+       chu->used++;
+       chu->lastindex = chu->curindex = 0;
+       chu->sleeping = 0;
+       chu->chubuf[0].ncodechars = 0;
+       tp->T_LINEP = (caddr_t) chu;
+       return (0);
+}
+
+/*
+ * Break down... called when discipline changed or from device
+ * close routine.
+ */
+chuclose(tp)
+       register struct tty *tp;
+{
+       register int s = spl5();
+
+       ((struct chudata *) tp->T_LINEP)->used = 0;
+       tp->t_cp = 0;
+       tp->t_inbuf = 0;
+       tp->t_rawq.c_cc = 0;            /* clear queues -- paranoid */
+       tp->t_canq.c_cc = 0;
+       tp->t_line = 0;                 /* paranoid: avoid races */
+       splx(s);
+}
+
+/*
+ * Read a CHU buffer.  Sleep on the current buffer
+ */
+churead(tp, uio)
+       register struct tty *tp;
+       struct uio *uio;
+{
+       register struct chudata *chu;
+       register struct chucode *chucode;
+       register int s;
+
+       if ((tp->t_state&TS_CARR_ON)==0)
+               return (EIO);
+
+       chu = (struct chudata *) (tp->T_LINEP);
+
+       s = spl5();
+       chucode = &(chu->chubuf[chu->lastindex]);
+       while (chu->curindex == chu->lastindex) {
+               chu->sleeping = 1;
+               sleep((caddr_t)chucode, TTIPRI);
+       }
+       chu->sleeping = 0;
+       if (++(chu->lastindex) >= NUMCHUBUFS)
+               chu->lastindex = 0;
+       splx(s);
+
+       return (uiomove((caddr_t)chucode, sizeof(*chucode), UIO_READ, uio));
+}
+
+/*
+ * Low level character input routine.
+ * If the character looks okay, grab a time stamp.  If the stuff in
+ * the buffer is too old, dump it and start fresh.  If the character is
+ * non-BCDish, everything in the buffer too.
+ */
+chuinput(c, tp)
+       register int c;
+       register struct tty *tp;
+{
+       register struct chudata *chu = (struct chudata *) tp->T_LINEP;
+       register struct chucode *chuc;
+       register int i;
+       long sec, usec;
+       struct timeval tv;
+
+       /*
+        * Do a check on the BSDness of the character.  This delays
+        * the time stamp a bit but saves a fair amount of overhead
+        * when the static is bad.
+        */
+       if (((c) & 0xf) > 9 || (((c)>>4) & 0xf) > 9) {
+               chuc = &(chu->chubuf[chu->curindex]);
+               chuc->ncodechars = 0;   /* blow all previous away */
+               return;
+       }
+
+       /*
+        * Call microtime() to get the current time of day
+        */
+       microtime(&tv);
+
+       /*
+        * Compute the difference in this character's time stamp
+        * and the last.  If it exceeds the margin, blow away all
+        * the characters currently in the buffer.
+        */
+       chuc = &(chu->chubuf[chu->curindex]);
+       i = (int)chuc->ncodechars;
+       if (i > 0) {
+               sec = tv.tv_sec - chuc->codetimes[i-1].tv_sec;
+               usec = tv.tv_usec - chuc->codetimes[i-1].tv_usec;
+               if (usec < 0) {
+                       sec -= 1;
+                       usec += 1000000;
+               }
+               if (sec != 0 || usec > CHUMAXUSEC) {
+                       i = 0;
+                       chuc->ncodechars = 0;
+               }
+       }
+
+       /*
+        * Store the character.  If we're done, have to tell someone
+        */
+       chuc->codechars[i] = (u_char)c;
+       chuc->codetimes[i] = tv;
+
+       if (++i < NCHUCHARS) {
+               /*
+                * Not much to do here.  Save the count and wait
+                * for another character.
+                */
+               chuc->ncodechars = (u_char)i;
+       } else {
+               /*
+                * Mark this buffer full and point at next.  If the
+                * next buffer is full we overwrite it by bumping the
+                * next pointer.
+                */
+               chuc->ncodechars = NCHUCHARS;
+               if (++(chu->curindex) >= NUMCHUBUFS)
+                       chu->curindex = 0;
+               if (chu->curindex == chu->lastindex)
+                       if (++(chu->lastindex) >= NUMCHUBUFS)
+                               chu->lastindex = 0;
+               chu->chubuf[chu->curindex].ncodechars = 0;
+
+               /*
+                * Wake up anyone sleeping on this.  Also wake up
+                * selectors and/or deliver a SIGIO as required.
+                */
+               if (tp->t_rsel) {
+                       selwakeup(tp->t_rsel, tp->t_state&TS_RCOLL);
+                       tp->t_state &= ~TS_RCOLL;
+                       tp->t_rsel = 0;
+               }
+               if (tp->t_state & TS_ASYNC)
+                       gsignal(tp->t_pgrp, SIGIO);
+               if (chu->sleeping)
+                       (void) wakeup((caddr_t)chuc);
+       }
+}
+
+/*
+ * Handle ioctls.  We reject all tty-style except those that
+ * change the line discipline.
+ */
+chuioctl(tp, cmd, data, flag)
+       struct tty *tp;
+       int cmd;
+       caddr_t data;
+       int flag;
+{
+
+       if ((cmd>>8) != 't')
+               return (-1);
+       switch (cmd) {
+       case TIOCSETD:
+       case TIOCGETD:
+       case TIOCGETP:
+       case TIOCGETC:
+               return (-1);
+       }
+       return (ENOTTY);        /* not quite appropriate */
+}
+
+
+chuselect(dev, rw)
+       dev_t dev;
+       int rw;
+{
+       register struct tty *tp = &cdevsw[major(dev)].d_ttys[minor(dev)];
+       struct chudata *chu;
+       int s = spl5();
+
+       chu = (struct chudata *) (tp->T_LINEP);
+
+       switch (rw) {
+
+       case FREAD:
+               if (chu->curindex != chu->lastindex)
+                       goto win;
+               if (tp->t_rsel && tp->t_rsel->p_wchan == (caddr_t)&selwait)
+                       tp->t_state |= TS_RCOLL;
+               else
+                       tp->t_rsel = u.u_procp;
+               break;
+
+       case FWRITE:
+               goto win;
+       }
+       splx(s);
+       return (0);
+win:
+       splx(s);
+       return (1);
+}
+#endif NCHU
diff --git a/kernel/tty_chu_STREAMS.c b/kernel/tty_chu_STREAMS.c
new file mode 100644 (file)
index 0000000..f46e25d
--- /dev/null
@@ -0,0 +1,603 @@
+/*
+ * CHU STREAMS module for SunOS
+ *
+ * Version 2.6
+ *
+ * Copyright 1991-1994, Nick Sayer
+ *
+ * Special thanks to Greg Onufer for his debug assists.
+ * Special thanks to Matthias Urlichs for the 4.1.x loadable driver support
+ *   code.
+ * Special wet-noodle whippings to Sun for not properly documenting
+ *   ANYTHING that makes this stuff at all possible.
+ *
+ * Should be PUSHed directly on top of a serial I/O channel.
+ * Provides complete chucode structures to user space.
+ *
+ * COMPILATION:
+ *
+ *
+ * To make a SunOS 4.1.x compatable loadable module (from the ntp kernel
+ * directory):
+ *
+ * % cc -c -I../include -DLOADABLE tty_chu_STREAMS.c
+ *
+ * The resulting .o file is the loadable module. Modload it
+ * thusly:
+ *
+ * % modload tty_chu_STREAMS.o -entry _chuinit
+ *
+ * When none of the instances are pushed in a STREAM, you can
+ * modunload the driver in the usual manner if you wish.
+ *
+ * As an alternative to loading it dynamically you can compile it
+ * directly into the kernel by hacking str_conf.c. See the README
+ * file for more details on doing it the old fashioned way.
+ *
+ *
+ * To make a Solaris 2.x compatable module (from the ntp kernel
+ * directory):
+ *
+ * % {gcc,cc} -c -I../include -DSOLARIS2 tty_chu_STREAMS.c
+ * % ld -r -o /usr/kernel/strmod/chu tty_chu_STREAMS.o
+ * % chmod 755 /usr/kernel/strmod/chu
+ *
+ * The OS will load it for you automagically when it is first pushed.
+ *
+ * If you get syntax errors from <sys/timer.h> (really references
+ * to types that weren't typedef'd in gcc's version of types.h),
+ * add -D_SYS_TIMER_H to blot out the miscreants.
+ *
+ * Under Solaris 2.2 and previous, do not attempt to modunload the
+ * module unless you're SURE it's not in use. I haven't tried it, but
+ * I've been told it won't do the right thing. Under Solaris 2.3 (and
+ * presumably future revs) an attempt to unload the module when it's in
+ * use will properly refuse with a "busy" message.
+ *
+ *
+ * HISTORY:
+ *
+ * v2.6 - Mutexed the per-instance chucode just to be safe.
+ * v2.5 - Fixed show-stopper bug in Solaris 2.x - qprocson().
+ * v2.4 - Added dynamic allocation support for Solaris 2.x.
+ * v2.3 - Added support for Solaris 2.x.
+ * v2.2 - Added SERVICE IMMEDIATE hack.
+ * v2.1 - Added 'sixth byte' heuristics.
+ * v2.0 - first version with an actual version number.
+ *        Added support for new CHU 'second 31' data format.
+ *        Deleted PEDANTIC and ANAL_RETENTIVE.
+ *
+ */
+
+#ifdef SOLARIS2
+# ifndef NCHU
+#  define NCHU 1
+# endif
+# define _KERNEL
+#elif defined(LOADABLE)
+# ifndef NCHU
+#  define NCHU 3
+#  define KERNEL
+# endif
+#else
+# include "chu.h"
+#endif
+
+#if NCHU > 0
+
+/*
+ * Number of microseconds we allow between
+ * character arrivals.  The speed is 300 baud
+ * so this should be somewhat more than 30 msec
+ */
+#define        CHUMAXUSEC      (60*1000)       /* 60 msec */
+
+#include <sys/types.h>
+#include <sys/stream.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/errno.h>
+#include <sys/user.h>
+#include <syslog.h>
+#include <sys/tty.h>
+
+#include <sys/chudefs.h>
+
+#ifdef SOLARIS2
+
+#include <sys/ksynch.h>
+#include <sys/kmem.h>
+#include <sys/cmn_err.h>
+#include <sys/conf.h>
+#include <sys/strtty.h>
+#include <sys/modctl.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+
+#endif
+
+#ifdef LOADABLE
+
+#include <sys/kernel.h>
+#include <sys/conf.h>
+#include <sys/buf.h>
+#include <sundev/mbvar.h>
+#include <sun/autoconf.h>
+#include <sun/vddrv.h>
+
+#endif
+
+
+static struct module_info rminfo = { 0, "chu", 0, INFPSZ, 0, 0 };
+static struct module_info wminfo = { 0, "chu", 0, INFPSZ, 0, 0 };
+static int chuopen(), churput(), chuwput(), chuclose();
+
+static struct qinit rinit = { churput, NULL, chuopen, chuclose, NULL,
+       &rminfo, NULL };
+
+static struct qinit winit = { chuwput, NULL, NULL, NULL, NULL,
+       &wminfo, NULL };
+
+struct streamtab chuinfo = { &rinit, &winit, NULL, NULL };
+
+/*
+ * Here's our private data type and structs
+ */
+struct priv_data 
+{
+#ifdef SOLARIS2
+  kmutex_t chucode_mutex;
+#else
+  char in_use;
+#endif
+  struct chucode chu_struct;
+};
+
+#ifndef SOLARIS2
+struct priv_data our_priv_data[NCHU];
+#endif
+
+#ifdef SOLARIS2
+
+static struct fmodsw fsw =
+{
+  "chu",
+  &chuinfo,
+  D_NEW | D_MP
+};
+
+extern struct mod_ops mod_strmodops;
+
+static struct modlstrmod modlstrmod =
+{
+  &mod_strmodops,
+  "CHU timecode decoder v2.6",
+  &fsw
+};
+
+static struct modlinkage modlinkage =
+{
+  MODREV_1,
+  (void*) &modlstrmod,
+  NULL
+};
+
+int _init()
+{
+  return mod_install(&modlinkage);
+}
+
+int _info(foo)
+struct modinfo *foo;
+{
+  return mod_info(&modlinkage,foo);
+}
+
+int _fini()
+{
+  return mod_remove(&modlinkage);
+}
+
+#endif /* SOLARIS2 */
+
+#ifdef LOADABLE
+
+# ifdef sun
+
+static struct vdldrv vd =
+{
+    VDMAGIC_PSEUDO,
+    "chu",
+    NULL, NULL, NULL, 0, 0, NULL, NULL, 0, 0,
+};
+
+static struct fmodsw *chu_fmod;
+
+/*ARGSUSED*/
+chuinit (fc, vdp, vdi, vds)
+    unsigned int fc;
+    struct vddrv *vdp;
+    addr_t vdi;
+    struct vdstat *vds;
+{
+    switch (fc) {
+    case VDLOAD:
+        {
+            int dev, i;
+
+            /* Find free entry in fmodsw */
+            for (dev = 0; dev < fmodcnt; dev++) {
+                if (fmodsw[dev].f_str == NULL)
+                    break;
+            }
+            if (dev == fmodcnt)
+                return (ENODEV);
+            chu_fmod = &fmodsw[dev];
+
+           /* If you think a kernel would have strcpy() you're mistaken. */
+            for (i = 0; i <= FMNAMESZ; i++)
+                chu_fmod->f_name[i] = wminfo.mi_idname[i];
+
+            chu_fmod->f_str = &chuinfo;
+        }
+        vdp->vdd_vdtab = (struct vdlinkage *) & vd;
+
+       {
+           int i;
+
+           for (i=0; i<NCHU; i++)
+               our_priv_data[i].in_use=0;
+       }
+
+        return 0;
+    case VDUNLOAD:
+        {
+            int dev;
+
+            for (dev = 0; dev < NCHU; dev++)
+                if (our_priv_data[dev].in_use) {
+                    /* One of the modules is still open */
+                    return (EBUSY);
+                }
+        }
+        chu_fmod->f_name[0] = '\0';
+        chu_fmod->f_str = NULL;
+        return 0;
+    case VDSTAT:
+        return 0;
+    default:
+        return EIO;
+    }
+}
+
+# endif /* sun */
+
+#endif /* LOADABLE */
+
+#if !defined(LOADABLE) && !defined(SOLARIS2)
+
+char chu_first_open=1;
+
+#endif
+
+/*ARGSUSED*/
+static int chuopen(q, dev, flag, sflag)
+queue_t *q;
+dev_t dev;
+int flag;
+int sflag;
+{
+  int i;
+
+#if !defined(LOADABLE) && !defined(SOLARIS2)
+  if (chu_first_open)
+  {
+    chu_first_open=0;
+
+    for(i=0;i<NCHU;i++)
+      our_priv_data[i].in_use=0;
+  }
+#endif
+
+#ifdef SOLARIS2
+  /* According to the docs, calling with KM_SLEEP can never
+     fail */
+
+  q->q_ptr = kmem_alloc( sizeof(struct priv_data), KM_SLEEP );
+  ((struct priv_data *) q->q_ptr)->chu_struct.ncodechars = 0;
+
+  mutex_init(&((struct priv_data *) q->q_ptr)->chucode_mutex,"Chucode Mutex",MUTEX_DRIVER,NULL);
+  qprocson(q);
+
+  if (!putnextctl1(WR(q), M_CTL, MC_SERVICEIMM))
+  {
+    qprocsoff(q);
+    mutex_destroy(&((struct priv_data *)q->q_ptr)->chucode_mutex);
+    kmem_free(q->q_ptr, sizeof(struct chucode) );
+    return (EFAULT);
+  }
+
+  return 0;
+
+#else
+  for(i=0;i<NCHU;i++)
+    if (!our_priv_data[i].in_use)
+    {
+      ((struct priv_data *) (q->q_ptr))=&(our_priv_data[i]);
+      our_priv_data[i].in_use++;
+      our_priv_data[i].chu_struct.ncodechars = 0;
+      if (!putctl1(WR(q)->q_next, M_CTL, MC_SERVICEIMM))
+      {
+        our_priv_data[i].in_use=0;
+        u.u_error = EFAULT;
+       return (OPENFAIL);
+      }
+      return 0;
+    }
+
+  u.u_error = EBUSY;
+  return (OPENFAIL);
+#endif
+
+}
+
+/*ARGSUSED*/
+static int chuclose(q, flag)
+queue_t *q;
+int flag;
+{
+#ifdef SOLARIS2
+  qprocsoff(q);
+  mutex_destroy(&((struct priv_data *)q->q_ptr)->chucode_mutex);
+  kmem_free(q->q_ptr, sizeof(struct chucode) );
+#else
+  ((struct priv_data *) (q->q_ptr))->in_use=0;
+#endif
+  return (0);
+}
+
+/*
+ * Now the crux of the biscuit.
+ *
+ * We will be passed data from the man downstairs. If it's not a data
+ * packet, it must be important, so pass it along unmunged. If, however,
+ * it is a data packet, we're gonna do special stuff to it. We're going
+ * to pass each character we get to the old line discipline code we
+ * include below for just such an occasion. When the old ldisc code
+ * gets a full chucode struct, we'll hand it back upstairs.
+ *
+ * chuinput takes a single character and q (as quickly as possible).
+ * passback takes a pointer to a chucode struct and q and sends it upstream.
+ */
+
+void chuinput();
+void passback();
+
+static int churput(q, mp)
+queue_t *q;
+mblk_t *mp;
+{
+  mblk_t *bp;
+
+  switch(mp->b_datap->db_type)
+  {
+    case M_DATA:
+      for(bp=mp; bp!=NULL; bp=bp->b_cont)
+      {
+       while(bp->b_rptr < bp->b_wptr)
+         chuinput( ((u_char)*(bp->b_rptr++)) , q );
+      }
+      freemsg(mp);
+    break;
+    default:
+      putnext(q,mp);
+    break;
+  }
+
+}
+
+/*
+ * Writing to a chu device doesn't make sense, but we'll pass them
+ * through in case they're important.
+ */
+
+static int chuwput(q, mp)
+queue_t *q;
+mblk_t *mp;
+{
+  putnext(q,mp);
+}
+
+/*
+ * Take a pointer to a filled chucode struct and a queue and
+ * send the chucode stuff upstream
+ */
+
+void passback(outdata,q)
+struct chucode *outdata;
+queue_t *q;
+{
+  mblk_t *mp;
+  int j;
+
+  mp=(mblk_t*) allocb(sizeof(struct chucode),BPRI_LO);
+
+  if (mp==NULL)
+  {
+#ifdef SOLARIS2
+    cmn_err(CE_WARN,"chu module couldn't allocate message block");
+#else
+    log(LOG_ERR,"chu: cannot allocate message");
+#endif
+    return;
+  }
+
+  for(j=0;j<sizeof(struct chucode); j++)
+    *mp->b_wptr++ = *( ((char*)outdata) + j );
+
+  putnext(q,mp);
+}
+
+/*
+ * This routine was copied nearly verbatim from the old line discipline.
+ */
+void chuinput(c,q)
+register u_char c;
+queue_t *q;
+{
+  register struct chucode *chuc;
+  register int i;
+  long sec, usec;
+  struct timeval tv;
+
+  /*
+   * Quick, Batman, get a timestamp! We need to do this
+   * right away. The time between the end of the stop bit
+   * and this point is critical, and should be as nearly
+   * constant and as short as possible. (Un)fortunately,
+   * the Sun's clock granularity is so big this isn't a
+   * major problem.
+   *
+   * uniqtime() is totally undocumented, but there you are.
+   */
+  uniqtime(&tv);
+
+#ifdef SOLARIS2
+  mutex_enter(&((struct priv_data *)q->q_ptr)->chucode_mutex);
+#endif
+
+  /*
+   * Now, locate the chu struct once so we don't have to do it
+   * over and over.
+   */
+  chuc=&(((struct priv_data *) (q->q_ptr))->chu_struct);
+
+       /*
+        * Compute the difference in this character's time stamp
+        * and the last.  If it exceeds the margin, blow away all
+        * the characters currently in the buffer.
+        */
+  i = (int)chuc->ncodechars;
+  if (i > 0)
+  {
+    sec = tv.tv_sec - chuc->codetimes[i-1].tv_sec;
+    usec = tv.tv_usec - chuc->codetimes[i-1].tv_usec;
+    if (usec < 0)
+    {
+      sec -= 1;
+      usec += 1000000;
+    }
+    if (sec != 0 || usec > CHUMAXUSEC)
+    {
+      i = 0;
+      chuc->ncodechars = 0;
+    }
+  }
+
+  /*
+   * Store the character.
+   */
+  chuc->codechars[i] = (u_char)c;
+  chuc->codetimes[i] = tv;
+
+  /*
+   * Now we perform the 'sixth byte' heuristics.
+   *
+   * This is a long story.
+   *
+   * We used to be able to count on the first byte of the code
+   * having a '6' in the LSD. This prevented most code framing
+   * errors (garbage before the first byte wouldn't typically
+   * have a 6 in the LSD). That's no longer the case.
+   *
+   * We can get around this, however, by noting that the 6th byte
+   * must be either equal to or one's complement of the first.
+   * If we get a sixth byte that ISN'T like that, then it may
+   * well be that the first byte is garbage. The right thing
+   * to do is to left-shift the whole buffer one count and
+   * continue to wait for the sixth byte.
+   */
+  if (i == NCHUCHARS/2)
+  {
+    register u_char temp_byte;
+
+    temp_byte=chuc->codechars[i] ^ chuc->codechars[0];
+
+    if ( (temp_byte) && (temp_byte!=0xff) )
+    {
+      register int t;
+      /*
+       * No match. Left-shift the buffer and try again
+       */
+      for(t=0;t<=NCHUCHARS/2;t++)
+      {
+       chuc->codechars[t]=chuc->codechars[t+1];
+       chuc->codetimes[t]=chuc->codetimes[t+1];
+      }
+
+      i--; /* This is because of the ++i immediately following */
+    }
+  }
+
+  /*
+   * We done yet?
+   */
+  if (++i < NCHUCHARS)
+  {
+    /*
+     * We're not done. Not much to do here. Save the count and wait
+     * for another character.
+     */
+    chuc->ncodechars = (u_char)i;
+  }
+  else
+  {
+    /*
+     * We are done. Mark this buffer full and pass it along.
+     */
+    chuc->ncodechars = NCHUCHARS;
+
+    /*
+     * Now we have a choice. Either the front half and back half
+     * have to match, or be one's complement of each other.
+     *
+     * So let's try the first byte and see
+     */
+
+    if(chuc->codechars[0] == chuc->codechars[NCHUCHARS/2])
+    {
+      chuc->chutype = CHU_TIME;
+      for( i=0; i<(NCHUCHARS/2); i++)
+        if (chuc->codechars[i] != chuc->codechars[i+(NCHUCHARS/2)])
+        {
+          chuc->ncodechars = 0;
+#ifdef SOLARIS2
+          mutex_exit(&((struct priv_data *)q->q_ptr)->chucode_mutex);
+#endif
+          return;
+        }
+    }
+    else
+    {
+      chuc->chutype = CHU_YEAR;
+      for( i=0; i<(NCHUCHARS/2); i++)
+        if (((chuc->codechars[i] ^ chuc->codechars[i+(NCHUCHARS/2)]) & 0xff)
+         != 0xff )
+        {
+          chuc->ncodechars = 0;
+#ifdef SOLARIS2
+          mutex_exit(&((struct priv_data *)q->q_ptr)->chucode_mutex);
+#endif
+          return;
+        }
+    }
+
+    passback(chuc,q); /* We're done! */
+    chuc->ncodechars = 0; /* Start all over again! */
+  }
+#ifdef SOLARIS2
+  mutex_exit(&((struct priv_data *)q->q_ptr)->chucode_mutex);
+#endif
+}
+
+#endif /* NCHU > 0 */
diff --git a/kernel/tty_clk.c b/kernel/tty_clk.c
new file mode 100644 (file)
index 0000000..0720610
--- /dev/null
@@ -0,0 +1,317 @@
+/* tty_clk.c,v 3.1 1993/07/06 01:07:33 jbj Exp
+ * tty_clk.c - Generic line driver for receiving radio clock timecodes
+ */
+
+#include "clk.h"
+#if NCLK > 0
+
+#include "../h/param.h"
+#include "../h/types.h"
+#include "../h/systm.h"
+#include "../h/dir.h"
+#include "../h/user.h"
+#include "../h/ioctl.h"
+#include "../h/tty.h"
+#include "../h/proc.h"
+#include "../h/file.h"
+#include "../h/conf.h"
+#include "../h/buf.h"
+#include "../h/uio.h"
+#include "../h/clist.h"
+
+/*
+ * This line discipline is intended to provide well performing
+ * generic support for the reception and time stamping of radio clock
+ * timecodes.  Most radio clock devices return a string where a
+ * particular character in the code (usually a \r) is on-time
+ * synchronized with the clock.  The idea here is to collect characters
+ * until (one of) the synchronization character(s) (we allow two) is seen.
+ * When the magic character arrives we take a timestamp by calling
+ * microtime() and insert the eight bytes of struct timeval into the
+ * buffer after the magic character.  We then wake up anyone waiting
+ * for the buffer and return the whole mess on the next read.
+ *
+ * To use this the calling program is expected to first open the
+ * port, and then to set the port into raw mode with the speed
+ * set appropriately with a TIOCSETP ioctl(), with the erase and kill
+ * characters set to those to be considered magic (yes, I know this
+ * is gross, but they were so convenient).  If only one character is
+ * magic you can set then both the same, or perhaps to the alternate
+ * parity versions of said character.  After getting all this set,
+ * change the line discipline to CLKLDISC and you are on your way.
+ *
+ * The only other bit of magic we do in here is to flush the receive
+ * buffers on writes if the CRMOD flag is set (hack, hack).
+ */
+
+/*
+ * We run this very much like a raw mode terminal, with the exception
+ * that we store up characters locally until we hit one of the
+ * magic ones and then dump it into the rawq all at once.  We keep
+ * the buffered data in clists since we can then often move it to
+ * the rawq without copying.  For sanity we limit the number of
+ * characters between specials, and the total number of characters
+ * before we flush the rawq, as follows.
+ */
+#define        CLKLINESIZE     (256)
+#define        NCLKCHARS       (CLKLINESIZE*4)
+
+struct clkdata {
+       int inuse;
+       struct clist clkbuf;
+};
+#define        clk_cc  clkbuf.c_cc
+#define        clk_cf  clkbuf.c_cf
+#define        clk_cl  clkbuf.c_cl
+
+struct clkdata clk_data[NCLK];
+
+/*
+ * Routine for flushing the internal clist
+ */
+#define        clk_bflush(clk)         (ndflush(&((clk)->clkbuf), (clk)->clk_cc))
+
+int clk_debug = 0;
+
+/*ARGSUSED*/
+clkopen(dev, tp)
+       dev_t dev;
+       register struct tty *tp;
+{
+       register struct clkdata *clk;
+
+       /*
+        * Don't allow multiple opens.  This will also protect us
+        * from someone opening /dev/tty
+        */
+       if (tp->t_line == CLKLDISC)
+               return (EBUSY);
+       ttywflush(tp);
+       for (clk = clk_data; clk < &clk_data[NCLK]; clk++)
+               if (!clk->inuse)
+                       break;
+       if (clk >= &clk_data[NCLK])
+               return (EBUSY);
+       clk->inuse++;
+       clk->clk_cc = 0;
+       clk->clk_cf = clk->clk_cl = NULL;
+       tp->T_LINEP = (caddr_t) clk;
+       return (0);
+}
+
+
+/*
+ * Break down... called when discipline changed or from device
+ * close routine.
+ */
+clkclose(tp)
+       register struct tty *tp;
+{
+       register struct clkdata *clk;
+       register int s = spltty();
+
+       clk = (struct clkdata *)tp->T_LINEP;
+       if (clk->clk_cc > 0)
+               clk_bflush(clk);
+       clk->inuse = 0;
+       tp->t_line = 0;                 /* paranoid: avoid races */
+       splx(s);
+}
+
+
+/*
+ * Receive a write request.  We pass these requests on to the terminal
+ * driver, except that if the CRMOD bit is set in the flags we
+ * first flush the input queues.
+ */
+clkwrite(tp, uio)
+       register struct tty *tp;
+       struct uio *uio;
+{
+       if (tp->t_flags & CRMOD) {
+               register struct clkdata *clk;
+               int s;
+
+               s = spltty();
+               if (tp->t_rawq.c_cc > 0)
+                       ndflush(&tp->t_rawq, tp->t_rawq.c_cc);
+               clk = (struct clkdata *) tp->T_LINEP;
+               if (clk->clk_cc > 0)
+                       clk_bflush(clk);
+               (void)splx(s);
+       }
+       ttwrite(tp, uio);
+}
+
+
+/*
+ * Low level character input routine.
+ * If the character looks okay, grab a time stamp.  If the stuff in
+ * the buffer is too old, dump it and start fresh.  If the character is
+ * non-BCDish, everything in the buffer too.
+ */
+clkinput(c, tp)
+       register int c;
+       register struct tty *tp;
+{
+       register struct clkdata *clk;
+       register int i;
+       register long s;
+       struct timeval tv;
+
+       /*
+        * Check to see whether this isn't the magic character.  If not,
+        * save the character and return.
+        */
+#ifdef ultrix
+       if (c != tp->t_cc[VERASE] && c != tp->t_cc[VKILL]) {
+#else
+       if (c != tp->t_erase && c != tp->t_kill) {
+#endif
+               clk = (struct clkdata *) tp->T_LINEP;
+               if (clk->clk_cc >= CLKLINESIZE)
+                       clk_bflush(clk);
+               if (putc(c, &clk->clkbuf) == -1) {
+                       /*
+                        * Hopeless, no clists.  Flush what we have
+                        * and hope things improve.
+                        */
+                       clk_bflush(clk);
+               }
+               return;
+       }
+
+       /*
+        * Here we have a magic character.  Get a timestamp and store
+        * everything.
+        */
+       microtime(&tv);
+       clk = (struct clkdata *) tp->T_LINEP;
+
+       if (putc(c, &clk->clkbuf) == -1)
+               goto flushout;
+       
+#ifdef CLKLDISC
+       /*
+        * STREAMS people started writing timestamps this way.
+        * It's not my fault, I am just going along with the flow...
+        */
+       for (i = 0; i < sizeof(struct timeval); i++)
+               if (putc(*( ((char*)&tv) + i ), &clk->clkbuf) == -1)
+                       goto flushout;
+#else
+       /*
+        * This is a machine independant way of puting longs into
+        * the datastream.  It has fallen into disuse...
+        */
+       s = tv.tv_sec;
+       for (i = 0; i < sizeof(long); i++) {
+               if (putc((s >> 24) & 0xff, &clk->clkbuf) == -1)
+                       goto flushout;
+               s <<= 8;
+       }
+
+       s = tv.tv_usec;
+       for (i = 0; i < sizeof(long); i++) {
+               if (putc((s >> 24) & 0xff, &clk->clkbuf) == -1)
+                       goto flushout;
+               s <<= 8;
+       }
+#endif
+
+       /*
+        * If the length of the rawq exceeds our sanity limit, dump
+        * all the old crap in there before copying this in.
+        */
+       if (tp->t_rawq.c_cc > NCLKCHARS)
+               ndflush(&tp->t_rawq, tp->t_rawq.c_cc);
+       
+       /*
+        * Now copy the buffer in.  There is a special case optimization
+        * here.  If there is nothing on the rawq at present we can
+        * just copy the clists we own over.  Otherwise we must concatenate
+        * the present data on the end.
+        */
+       s = (long)spltty();
+       if (tp->t_rawq.c_cc <= 0) {
+               tp->t_rawq = clk->clkbuf;
+               clk->clk_cc = 0;
+               clk->clk_cl = clk->clk_cf = NULL;
+               (void) splx((int)s);
+       } else {
+               (void) splx((int)s);
+               catq(&clk->clkbuf, &tp->t_rawq);
+               clk_bflush(clk);
+       }
+
+       /*
+        * Tell the world
+        */
+       ttwakeup(tp);
+       return;
+
+flushout:
+       /*
+        * It would be nice if this never happened.  Flush the
+        * internal clists and hope someone else frees some of them
+        */
+       clk_bflush(clk);
+       return;
+}
+
+
+/*
+ * Handle ioctls.  We reject most tty-style except those that
+ * change the line discipline and a couple of others..
+ */
+clkioctl(tp, cmd, data, flag)
+       struct tty *tp;
+       int cmd;
+       caddr_t data;
+       int flag;
+{
+       int flags;
+       struct sgttyb *sg;
+
+       if ((cmd>>8) != 't')
+               return (-1);
+       switch (cmd) {
+       case TIOCSETD:
+       case TIOCGETD:
+       case TIOCGETP:
+       case TIOCGETC:
+       case TIOCOUTQ:
+               return (-1);
+
+       case TIOCSETP:
+               /*
+                * He likely wants to set new magic characters in.
+                * Do this part.
+                */
+               sg = (struct sgttyb *)data;
+#ifdef ultrix
+               tp->t_cc[VERASE] = sg->sg_erase;
+               tp->t_cc[VKILL] = sg->sg_kill;
+#else
+               tp->t_erase = sg->sg_erase;
+               tp->t_kill = sg->sg_kill;
+#endif
+               return (0);
+
+       case TIOCFLUSH:
+               flags = *(int *)data;
+               if (flags == 0 || (flags & FREAD)) {
+                       register struct clkdata *clk;
+
+                       clk = (struct clkdata *) tp->T_LINEP;
+                       if (clk->clk_cc > 0)
+                               clk_bflush(clk);
+               }
+               return (-1);
+       
+       default:
+               break;
+       }
+       return (ENOTTY);        /* not quite appropriate */
+}
+#endif NCLK
diff --git a/kernel/tty_clk_STREAMS.c b/kernel/tty_clk_STREAMS.c
new file mode 100644 (file)
index 0000000..13b0a25
--- /dev/null
@@ -0,0 +1,266 @@
+/* tty_clk_STREAMS.c,v 3.1 1993/07/06 01:07:34 jbj Exp
+ * Timestamp STREAMS module for SunOS 4.1
+ *
+ * Copyright 1991, Nick Sayer
+ *
+ * Special thanks to Greg Onufer for his debug assists.
+ *
+ * Should be PUSHed directly on top of a serial I/O channel.
+ * For any character in a user-designated set, adds a kernel
+ * timestamp to that character.
+ *
+ * BUGS:
+ *
+ * Only so many characters can be timestamped. This number, however,
+ * is adjustable.
+ *
+ * The null character ($00) cannot be timestamped.
+ *
+ * The M_DATA messages passed upstream will not be the same
+ * size as when they arrive from downstream, even if no
+ * timestamp character is in the message. This, however,
+ * should not affect anything.
+ *
+ */
+
+#include "clk.h"
+#if NCLK > 0
+/*
+ * How big should the messages we pass upstream be?
+ */
+#define MESSAGE_SIZE 128
+
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stream.h>
+#include <sys/param.h>
+#include <sys/time.h>
+#include <sys/kernel.h>
+#include <sys/user.h>
+#include <sys/errno.h>
+#include <sys/syslog.h>
+
+#include <sys/clkdefs.h>
+
+static struct module_info rminfo = { 0, "clk", 0, INFPSZ, 0, 0 };
+static struct module_info wminfo = { 0, "clk", 0, INFPSZ, 0, 0 };
+static int clkopen(), clkrput(), clkwput(), clkclose();
+
+static struct qinit rinit = { clkrput, NULL, clkopen, clkclose, NULL,
+       &rminfo, NULL };
+
+static struct qinit winit = { clkwput, NULL, NULL, NULL, NULL,
+       &wminfo, NULL };
+
+struct streamtab clkinfo = { &rinit, &winit, NULL, NULL };
+
+struct priv_data_type
+{
+  char in_use;
+  char string[CLK_MAXSTRSIZE];
+} priv_data[NCLK];
+
+char first_open=1;
+
+/*
+ * God only knows why, but linking with strchr() fails
+ * on my system, so here's a renamed copy.
+ */
+
+u_char *str_chr(s,c)
+u_char *s;
+int c;
+{
+  while (*s)
+    if(*s++ == c)
+      return (s-1);
+  return NULL;
+}
+
+/*ARGSUSED*/
+static int clkopen(q, dev, flag, sflag)
+queue_t *q;
+dev_t dev;
+int flag;
+int sflag;
+{
+  int i;
+
+/* Damn it! We can't even have the global data struct properly
+   initialized! So we have a mark to tell us to init the global
+   data on the first open */
+
+  if (first_open)
+  {
+    first_open=0;
+
+    for(i=0;i<NCLK;i++)
+      priv_data[i].in_use=0;
+  }
+
+  for(i=0;i<NCLK;i++)
+    if(!priv_data[i].in_use)
+    {
+      priv_data[i].in_use++;
+      ((struct priv_data_type *) (q->q_ptr))=priv_data+i;
+      priv_data[i].string[0]=0;
+      return (0);
+    }
+  u.u_error = EBUSY;
+  return (OPENFAIL);
+}
+
+/*ARGSUSED*/
+static int clkclose(q, flag)
+queue_t *q;
+int flag;
+{
+  ((struct priv_data_type *) (q->q_ptr))->in_use=0;
+
+  return (0);
+}
+
+/*
+ * Now the crux of the biscuit.
+ *
+ * If it's an M_DATA package, we take each character and pass
+ * it to clkchar.
+ */
+
+void clkchar();
+
+static int clkrput(q, mp)
+queue_t *q;
+mblk_t *mp;
+{
+  mblk_t *bp;
+
+  switch(mp->b_datap->db_type)
+  {
+    case M_DATA:
+      clkchar(0,q,2);
+      for(bp=mp; bp!=NULL; bp=bp->b_cont)
+      {
+       while(bp->b_rptr < bp->b_wptr)
+         clkchar( ((u_char)*(bp->b_rptr++)) , q , 0 );
+      }
+      clkchar(0,q,1);
+      freemsg(mp);
+    break;
+    default:
+      putnext(q,mp);
+    break;
+  }
+
+}
+
+/*
+ * If it's a matching M_IOCTL, handle it.
+ */
+
+static int clkwput(q, mp)
+queue_t *q;
+mblk_t *mp;
+{
+  struct iocblk *iocp;
+
+  switch(mp->b_datap->db_type)
+  {
+    case M_IOCTL:
+      iocp=(struct iocblk*) mp->b_rptr;
+      if (iocp->ioc_cmd==CLK_SETSTR)
+      {
+        strncpy( ((struct priv_data_type *) (RD(q)->q_ptr))->string,
+         (char *) mp->b_cont->b_rptr,CLK_MAXSTRSIZE);
+        /* make sure it's null terminated */
+       ((struct priv_data_type *) (RD(q)->q_ptr))->string[CLK_MAXSTRSIZE-1]=0;
+       mp->b_datap->db_type = M_IOCACK;
+       qreply(q,mp);
+      }
+      else
+       putnext(q,mp);
+    break;
+    default:
+      putnext(q,mp);
+    break;
+  }
+}
+
+/*
+ * Now clkchar. It takes a character, a queue pointer and an action
+ * flag and depending on the flag either:
+ *
+ * 0 - adds the character to the current message. If there's a
+ * timestamp to be done, do that too. If the message is less than
+ * 8 chars from being full, link in a new one, and set it up for
+ * the next call.
+ *
+ * 1 - sends the whole mess to Valhala.
+ *
+ * 2 - set things up.
+ *
+ * Yeah, it's an ugly hack. Complaints may be filed with /dev/null.
+ */
+
+
+void clkchar(c,q,f)
+       register u_char c;
+       queue_t *q;
+       char f;
+{
+  static char error;
+  static mblk_t *message,*mp;
+  struct timeval tv;
+
+/* Get a timestamp ASAP! */
+  uniqtime(&tv);
+
+  switch(f)
+  {
+    case 1:
+      if (!error)
+        putnext(q,message);
+    break;
+    case 2:
+      mp=message= (mblk_t*) allocb(MESSAGE_SIZE,BPRI_LO);
+      error=(message==NULL);
+      if (error)
+       log(LOG_ERR,"clk: cannot allocate message - data lost");
+    break;
+    case 0:
+      if (error) /* If we had an error, forget it. */
+       return;
+
+      *mp->b_wptr++=c; /* Put the char away first.
+
+      /* If it's in the special string, append a struct timeval */
+
+      if (str_chr( ((struct priv_data_type *) (q->q_ptr))->string ,
+        c )!=NULL)
+      {
+         int i;
+
+         for (i=0;i<sizeof(struct timeval);i++)
+           *mp->b_wptr++= *( ((char*)&tv) + i );
+      }
+
+      /* If we don't have space for a complete struct timeval, and a
+         char, it's time for a new mp block */
+
+      if (((mp->b_wptr-mp->b_rptr)+sizeof(struct timeval)+2)>MESSAGE_SIZE)
+      {
+         mp->b_cont= (mblk_t*) allocb(MESSAGE_SIZE,BPRI_LO);
+         error=(mp->b_cont==NULL);
+         if (error)
+         {
+           log(LOG_ERR,"clk: cannot allocate message - data lost");
+           freemsg(message);
+          }
+          mp=mp->b_cont;
+      }
+
+    break;
+  }
+}
+
+#endif
diff --git a/libisc/assertions.c b/libisc/assertions.c
new file mode 100644 (file)
index 0000000..08dd5f3
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * Copyright (C) 1997-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: assertions.c,v 1.16 2001/07/16 03:52:05 mayer Exp $ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <isc/assertions.h>
+#include <isc/msgs.h>
+
+/*
+ * Forward.
+ */
+
+static void
+default_callback(const char *, int, isc_assertiontype_t, const char *);
+
+/*
+ * Public.
+ */
+
+LIBISC_EXTERNAL_DATA isc_assertioncallback_t isc_assertion_failed =
+                                            default_callback;
+
+void
+isc_assertion_setcallback(isc_assertioncallback_t cb) {
+       if (cb == NULL)
+               isc_assertion_failed = default_callback;
+       else
+               isc_assertion_failed = cb;
+}
+
+const char *
+isc_assertion_typetotext(isc_assertiontype_t type) {
+       const char *result;
+
+       /*
+        * These strings have purposefully not been internationalized
+        * because they are considered to essentially be keywords of
+        * the ISC development environment.
+        */
+       switch (type) {
+       case isc_assertiontype_require:
+               result = "REQUIRE";
+               break;
+       case isc_assertiontype_ensure:
+               result = "ENSURE";
+               break;
+       case isc_assertiontype_insist:
+               result = "INSIST";
+               break;
+       case isc_assertiontype_invariant:
+               result = "INVARIANT";
+               break;
+       default:
+               result = NULL;
+       }
+       return (result);
+}
+
+/*
+ * Private.
+ */
+
+static void
+default_callback(const char *file, int line, isc_assertiontype_t type,
+                const char *cond)
+{
+       fprintf(stderr, "%s:%d: %s(%s) %s.\n",
+               file, line, isc_assertion_typetotext(type), cond,
+               isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
+                              ISC_MSG_FAILED, "failed"));
+       fflush(stderr);
+       abort();
+       /* NOTREACHED */
+}
diff --git a/libisc/error.c b/libisc/error.c
new file mode 100644 (file)
index 0000000..ed0469d
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 1998-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: error.c,v 1.16 2001/08/08 22:54:49 gson Exp $ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <isc/error.h>
+#include <isc/msgs.h>
+
+static void
+default_unexpected_callback(const char *, int, const char *, va_list)
+     ISC_FORMAT_PRINTF(3, 0);
+
+static void
+default_fatal_callback(const char *, int, const char *, va_list)
+     ISC_FORMAT_PRINTF(3, 0);
+
+static isc_errorcallback_t unexpected_callback = default_unexpected_callback;
+static isc_errorcallback_t fatal_callback = default_fatal_callback;
+
+void
+isc_error_setunexpected(isc_errorcallback_t cb) {
+       if (cb == NULL)
+               unexpected_callback = default_unexpected_callback;
+       else
+               unexpected_callback = cb;
+}
+
+void
+isc_error_setfatal(isc_errorcallback_t cb) {
+       if (cb == NULL)
+               fatal_callback = default_fatal_callback;
+       else
+               fatal_callback = cb;
+}
+
+void
+isc_error_unexpected(const char *file, int line, const char *format, ...) {
+       va_list args;
+
+       va_start(args, format);
+       (unexpected_callback)(file, line, format, args);
+       va_end(args);
+}
+
+void
+isc_error_fatal(const char *file, int line, const char *format, ...) {
+       va_list args;
+
+       va_start(args, format);
+       (fatal_callback)(file, line, format, args);
+       va_end(args);
+       abort();
+}
+
+void
+isc_error_runtimecheck(const char *file, int line, const char *expression) {
+       isc_error_fatal(file, line, "RUNTIME_CHECK(%s) %s", expression,
+                       isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
+                                      ISC_MSG_FAILED, "failed"));
+}
+
+static void
+default_unexpected_callback(const char *file, int line, const char *format,
+                           va_list args)
+{
+       fprintf(stderr, "%s:%d: ", file, line);
+       vfprintf(stderr, format, args);
+       fprintf(stderr, "\n");
+       fflush(stderr);
+}
+
+static void
+default_fatal_callback(const char *file, int line, const char *format,
+                      va_list args)
+{
+       fprintf(stderr, "%s:%d: %s: ", file, line,
+               isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
+                              ISC_MSG_FATALERROR, "fatal error"));
+       vfprintf(stderr, format, args);
+       fprintf(stderr, "\n");
+       fflush(stderr);
+}
diff --git a/libisc/ifiter_getifaddrs.c b/libisc/ifiter_getifaddrs.c
new file mode 100644 (file)
index 0000000..f20c1b3
--- /dev/null
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: ifiter_getifaddrs.c,v 1.2.68.3 2004/03/06 08:14:59 marka Exp $ */
+
+/*
+ * Obtain the list of network interfaces using the getifaddrs(3) library.
+ */
+
+#include <ifaddrs.h>
+
+#define IFITER_MAGIC           ISC_MAGIC('I', 'F', 'I', 'G')
+#define VALID_IFITER(t)                ISC_MAGIC_VALID(t, IFITER_MAGIC)
+
+struct isc_interfaceiter {
+       unsigned int            magic;          /* Magic number. */
+       isc_mem_t               *mctx;
+       void                    *buf;           /* (unused) */
+       unsigned int            bufsize;        /* (always 0) */
+       struct ifaddrs          *ifaddrs;       /* List of ifaddrs */
+       struct ifaddrs          *pos;           /* Ptr to current ifaddr */
+       isc_interface_t         current;        /* Current interface data. */
+       isc_result_t            result;         /* Last result code. */
+};
+
+isc_result_t
+isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
+       isc_interfaceiter_t *iter;
+       isc_result_t result;
+       char strbuf[ISC_STRERRORSIZE];
+
+       REQUIRE(iterp != NULL);
+       REQUIRE(*iterp == NULL);
+
+       iter = isc_mem_get(mctx, sizeof(*iter));
+       if (iter == NULL)
+               return (ISC_R_NOMEMORY);
+
+       iter->mctx = mctx;
+       iter->buf = NULL;
+       iter->bufsize = 0;
+       iter->ifaddrs = NULL;
+
+       if (getifaddrs(&iter->ifaddrs) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                isc_msgcat_get(isc_msgcat,
+                                               ISC_MSGSET_IFITERGETIFADDRS,
+                                               ISC_MSG_GETIFADDRS,
+                                               "getting interface "
+                                               "addresses: getifaddrs: %s"),
+                                strbuf);
+               result = ISC_R_UNEXPECTED;
+               goto failure;
+       }
+
+       /*
+        * A newly created iterator has an undefined position
+        * until isc_interfaceiter_first() is called.
+        */
+       iter->pos = NULL;
+       iter->result = ISC_R_FAILURE;
+
+       iter->magic = IFITER_MAGIC;
+       *iterp = iter;
+       return (ISC_R_SUCCESS);
+
+ failure:
+       if (iter->ifaddrs != NULL) /* just in case */
+               freeifaddrs(iter->ifaddrs);
+       isc_mem_put(mctx, iter, sizeof(*iter));
+       return (result);
+}
+
+/*
+ * Get information about the current interface to iter->current.
+ * If successful, return ISC_R_SUCCESS.
+ * If the interface has an unsupported address family,
+ * return ISC_R_IGNORE.
+ */
+
+static isc_result_t
+internal_current(isc_interfaceiter_t *iter) {
+       struct ifaddrs *ifa;
+       int family;
+       unsigned int namelen;
+
+       REQUIRE(VALID_IFITER(iter));
+
+       ifa = iter->pos;
+
+       INSIST(ifa != NULL);
+       INSIST(ifa->ifa_name != NULL);
+       INSIST(ifa->ifa_addr != NULL);
+
+       family = ifa->ifa_addr->sa_family;
+       if (family != AF_INET && family != AF_INET6)
+               return (ISC_R_IGNORE);
+
+       memset(&iter->current, 0, sizeof(iter->current));
+
+       namelen = strlen(ifa->ifa_name);
+       if (namelen > sizeof(iter->current.name) - 1)
+               namelen = sizeof(iter->current.name) - 1;
+
+       memset(iter->current.name, 0, sizeof(iter->current.name));
+       memcpy(iter->current.name, ifa->ifa_name, namelen);
+
+       iter->current.flags = 0;
+
+       if ((ifa->ifa_flags & IFF_UP) != 0)
+               iter->current.flags |= INTERFACE_F_UP;
+
+       if ((ifa->ifa_flags & IFF_POINTOPOINT) != 0)
+               iter->current.flags |= INTERFACE_F_POINTTOPOINT;
+
+       if ((ifa->ifa_flags & IFF_LOOPBACK) != 0)
+               iter->current.flags |= INTERFACE_F_LOOPBACK;
+
+       if ((ifa->ifa_flags & IFF_BROADCAST) != 0) {
+               iter->current.flags |= INTERFACE_F_BROADCAST;
+       }
+
+#ifdef IFF_MULTICAST
+       if ((ifa->ifa_flags & IFF_MULTICAST) != 0) {
+               iter->current.flags |= INTERFACE_F_MULTICAST;
+       }
+#endif
+       iter->current.af = family;
+
+       get_addr(family, &iter->current.address, ifa->ifa_addr, ifa->ifa_name);
+
+       if (ifa->ifa_netmask != NULL)
+               get_addr(family, &iter->current.netmask, ifa->ifa_netmask,
+                        ifa->ifa_name);
+
+       if (ifa->ifa_dstaddr != NULL &&
+           (iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0)
+               get_addr(family, &iter->current.dstaddress, ifa->ifa_dstaddr,
+                        ifa->ifa_name);
+
+       if (ifa->ifa_broadaddr != NULL &&
+           (iter->current.flags & INTERFACE_F_BROADCAST) != 0)
+               get_addr(family, &iter->current.broadcast, ifa->ifa_broadaddr,
+                        ifa->ifa_name);
+
+       return (ISC_R_SUCCESS);
+}
+
+/*
+ * Step the iterator to the next interface.  Unlike
+ * isc_interfaceiter_next(), this may leave the iterator
+ * positioned on an interface that will ultimately
+ * be ignored.  Return ISC_R_NOMORE if there are no more
+ * interfaces, otherwise ISC_R_SUCCESS.
+ */
+static isc_result_t
+internal_next(isc_interfaceiter_t *iter) {
+       iter->pos = iter->pos->ifa_next;
+
+       if (iter->pos == NULL)
+               return (ISC_R_NOMORE);
+
+       return (ISC_R_SUCCESS);
+}
+
+static void
+internal_destroy(isc_interfaceiter_t *iter) {
+       if (iter->ifaddrs)
+               freeifaddrs(iter->ifaddrs);
+       iter->ifaddrs = NULL;
+}
+
+static
+void internal_first(isc_interfaceiter_t *iter) {
+       iter->pos = iter->ifaddrs;
+}
diff --git a/libisc/ifiter_ioctl.c b/libisc/ifiter_ioctl.c
new file mode 100644 (file)
index 0000000..e069560
--- /dev/null
@@ -0,0 +1,1118 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: ifiter_ioctl.c,v 1.19.2.5.2.14 2004/06/22 04:40:23 marka Exp $ */
+
+/*
+ * Obtain the list of network interfaces using the SIOCGLIFCONF ioctl.
+ * See netintro(4).
+ */
+
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+#ifdef ISC_PLATFORM_HAVEIF_LADDRCONF
+#define lifc_len iflc_len
+#define lifc_buf iflc_buf
+#define lifc_req iflc_req
+#define LIFCONF if_laddrconf
+#else
+#define ISC_HAVE_LIFC_FAMILY 1
+#define ISC_HAVE_LIFC_FLAGS 1
+#define LIFCONF lifconf
+#endif
+
+#ifdef ISC_PLATFORM_HAVEIF_LADDRREQ
+#define lifr_addr iflr_addr
+#define lifr_name iflr_name
+#define lifr_dstaddr iflr_dstaddr
+#define lifr_broadaddr iflr_broadaddr
+#define lifr_flags iflr_flags
+#define lifr_index iflr_index
+#define ss_family sa_family
+#define LIFREQ if_laddrreq
+#else
+#define LIFREQ lifreq
+#endif
+#endif
+
+#define IFITER_MAGIC           ISC_MAGIC('I', 'F', 'I', 'T')
+#define VALID_IFITER(t)                ISC_MAGIC_VALID(t, IFITER_MAGIC)
+
+#define ISC_IF_INET6_SZ \
+    sizeof("00000000000000000000000000000001 01 80 10 80 XXXXXXloXXXXXXXX\n")
+
+struct isc_interfaceiter {
+       unsigned int            magic;          /* Magic number. */
+       isc_mem_t               *mctx;
+       int                     mode;
+       int                     socket;
+       struct ifconf           ifc;
+       void                    *buf;           /* Buffer for sysctl data. */
+       unsigned int            bufsize;        /* Bytes allocated. */
+       unsigned int            pos;            /* Current offset in
+                                                  SIOCGIFCONF data */
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+       int                     socket6;
+       struct LIFCONF          lifc;
+       void                    *buf6;          /* Buffer for sysctl data. */
+       unsigned int            bufsize6;       /* Bytes allocated. */
+       unsigned int            pos6;           /* Current offset in
+                                                  SIOCGLIFCONF data */
+       isc_result_t            result6;        /* Last result code. */
+       isc_boolean_t           first6;
+#endif
+#ifdef HAVE_TRUCLUSTER
+       int                     clua_context;   /* Cluster alias context */
+       isc_boolean_t           clua_done;
+       struct sockaddr         clua_sa;
+#endif
+#ifdef __linux
+       FILE *                  proc;
+       char                    entry[ISC_IF_INET6_SZ];
+       isc_result_t            valid;
+       isc_boolean_t           first;
+#endif
+       isc_interface_t         current;        /* Current interface data. */
+       isc_result_t            result;         /* Last result code. */
+};
+
+#ifdef HAVE_TRUCLUSTER
+#include <clua/clua.h>
+#include <sys/socket.h>
+#endif
+
+
+/*
+ * Size of buffer for SIOCGLIFCONF, in bytes.  We assume no sane system
+ * will have more than a megabyte of interface configuration data.
+ */
+#define IFCONF_BUFSIZE_INITIAL 4096
+#define IFCONF_BUFSIZE_MAX     1048576
+
+#ifdef __linux
+#ifndef IF_NAMESIZE
+# ifdef IFNAMSIZ
+#  define IF_NAMESIZE  IFNAMSIZ  
+# else
+#  define IF_NAMESIZE 16
+# endif
+#endif
+#endif
+
+static isc_result_t
+getbuf4(isc_interfaceiter_t *iter) {
+       char strbuf[ISC_STRERRORSIZE];
+
+       iter->bufsize = IFCONF_BUFSIZE_INITIAL;
+
+       for (;;) {
+               iter->buf = isc_mem_get(iter->mctx, iter->bufsize);
+               if (iter->buf == NULL)
+                       return (ISC_R_NOMEMORY);
+
+               memset(&iter->ifc.ifc_len, 0, sizeof(iter->ifc.ifc_len));
+               iter->ifc.ifc_len = iter->bufsize;
+               iter->ifc.ifc_buf = iter->buf;
+               /*
+                * Ignore the HP/UX warning about "integer overflow during
+                * conversion".  It comes from its own macro definition,
+                * and is really hard to shut up.
+                */
+               if (ioctl(iter->socket, SIOCGIFCONF, (char *)&iter->ifc)
+                   == -1) {
+                       if (errno != EINVAL) {
+                               isc__strerror(errno, strbuf, sizeof(strbuf));
+                               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                                isc_msgcat_get(isc_msgcat,
+                                                       ISC_MSGSET_IFITERIOCTL,
+                                                       ISC_MSG_GETIFCONFIG,
+                                                       "get interface "
+                                                       "configuration: %s"),
+                                                strbuf);
+                               goto unexpected;
+                       }
+                       /*
+                        * EINVAL.  Retry with a bigger buffer.
+                        */
+               } else {
+                       /*
+                        * The ioctl succeeded.
+                        * Some OS's just return what will fit rather
+                        * than set EINVAL if the buffer is too small
+                        * to fit all the interfaces in.  If
+                        * ifc.lifc_len is too near to the end of the
+                        * buffer we will grow it just in case and
+                        * retry.
+                        */
+                       if (iter->ifc.ifc_len + 2 * sizeof(struct ifreq)
+                           < iter->bufsize)
+                               break;
+               }
+               if (iter->bufsize >= IFCONF_BUFSIZE_MAX) {
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                        isc_msgcat_get(isc_msgcat,
+                                                       ISC_MSGSET_IFITERIOCTL,
+                                                       ISC_MSG_BUFFERMAX,
+                                                       "get interface "
+                                                       "configuration: "
+                                                       "maximum buffer "
+                                                       "size exceeded"));
+                       goto unexpected;
+               }
+               isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
+
+               iter->bufsize *= 2;
+       }
+       return (ISC_R_SUCCESS);
+
+ unexpected:
+       isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
+       iter->buf = NULL;
+       return (ISC_R_UNEXPECTED);
+}
+
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+static isc_result_t
+getbuf6(isc_interfaceiter_t *iter) {
+       char strbuf[ISC_STRERRORSIZE];
+       isc_result_t result;
+
+       iter->bufsize6 = IFCONF_BUFSIZE_INITIAL;
+
+       for (;;) {
+               iter->buf6 = isc_mem_get(iter->mctx, iter->bufsize6);
+               if (iter->buf6 == NULL)
+                       return (ISC_R_NOMEMORY);
+
+               memset(&iter->lifc, 0, sizeof(iter->lifc));
+#ifdef ISC_HAVE_LIFC_FAMILY
+               iter->lifc.lifc_family = AF_INET6;
+#endif
+#ifdef ISC_HAVE_LIFC_FLAGS
+               iter->lifc.lifc_flags = 0;
+#endif
+               iter->lifc.lifc_len = iter->bufsize6;
+               iter->lifc.lifc_buf = iter->buf6;
+               /*
+                * Ignore the HP/UX warning about "integer overflow during
+                * conversion".  It comes from its own macro definition,
+                * and is really hard to shut up.
+                */
+               if (ioctl(iter->socket6, SIOCGLIFCONF, (char *)&iter->lifc)
+                   == -1) {
+#ifdef __hpux
+                       /*
+                        * IPv6 interface scanning is not available on all
+                        * kernels w/ IPv6 sockets.
+                        */
+                       if (errno == ENOENT) {
+                               isc__strerror(errno, strbuf, sizeof(strbuf));
+                               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                                isc_msgcat_get(isc_msgcat,
+                                                       ISC_MSGSET_IFITERIOCTL,
+                                                       ISC_MSG_GETIFCONFIG,
+                                                       "get interface "
+                                                       "configuration: %s"),
+                                                strbuf);
+                               result = ISC_R_FAILURE;
+                               goto cleanup;
+                       }
+#endif
+                       if (errno != EINVAL) {
+                               isc__strerror(errno, strbuf, sizeof(strbuf));
+                               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                                isc_msgcat_get(isc_msgcat,
+                                                       ISC_MSGSET_IFITERIOCTL,
+                                                       ISC_MSG_GETIFCONFIG,
+                                                       "get interface "
+                                                       "configuration: %s"),
+                                                strbuf);
+                               result = ISC_R_UNEXPECTED;
+                               goto cleanup;
+                       }
+                       /*
+                        * EINVAL.  Retry with a bigger buffer.
+                        */
+               } else {
+                       /*
+                        * The ioctl succeeded.
+                        * Some OS's just return what will fit rather
+                        * than set EINVAL if the buffer is too small
+                        * to fit all the interfaces in.  If
+                        * ifc.ifc_len is too near to the end of the
+                        * buffer we will grow it just in case and
+                        * retry.
+                        */
+                       if (iter->lifc.lifc_len + 2 * sizeof(struct LIFREQ)
+                           < iter->bufsize6)
+                               break;
+               }
+               if (iter->bufsize6 >= IFCONF_BUFSIZE_MAX) {
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                        isc_msgcat_get(isc_msgcat,
+                                                       ISC_MSGSET_IFITERIOCTL,
+                                                       ISC_MSG_BUFFERMAX,
+                                                       "get interface "
+                                                       "configuration: "
+                                                       "maximum buffer "
+                                                       "size exceeded"));
+                       result = ISC_R_UNEXPECTED;
+                       goto cleanup;
+               }
+               isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
+
+               iter->bufsize6 *= 2;
+       }
+
+       if (iter->lifc.lifc_len != 0)
+               iter->mode = 6;
+       return (ISC_R_SUCCESS);
+
+ cleanup:
+       isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
+       iter->buf6 = NULL;
+       return (result);
+}
+#endif
+
+isc_result_t
+isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
+       isc_interfaceiter_t *iter;
+       isc_result_t result;
+       char strbuf[ISC_STRERRORSIZE];
+
+       REQUIRE(iterp != NULL);
+       REQUIRE(*iterp == NULL);
+
+       iter = isc_mem_get(mctx, sizeof(*iter));
+       if (iter == NULL)
+               return (ISC_R_NOMEMORY);
+
+       iter->mctx = mctx;
+       iter->mode = 4;
+       iter->buf = NULL;
+       iter->pos = (unsigned int) -1;
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+       iter->buf6 = NULL;
+       iter->pos6 = (unsigned int) -1;
+       iter->result6 = ISC_R_NOMORE;
+       iter->socket6 = -1;
+       iter->first6 = ISC_FALSE;
+#endif
+
+       /*
+        * Get the interface configuration, allocating more memory if
+        * necessary.
+        */
+
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+       result = isc_net_probeipv6();
+       if (result == ISC_R_SUCCESS) {
+               /*
+                * Create an unbound datagram socket to do the SIOCGLIFCONF
+                * ioctl on.  HP/UX requires an AF_INET6 socket for
+                * SIOCGLIFCONF to get IPv6 addresses.
+                */
+               if ((iter->socket6 = socket(AF_INET6, SOCK_DGRAM, 0)) < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                        isc_msgcat_get(isc_msgcat,
+                                                       ISC_MSGSET_IFITERIOCTL,
+                                                       ISC_MSG_MAKESCANSOCKET,
+                                                       "making interface "
+                                                       "scan socket: %s"),
+                                        strbuf);
+                       result = ISC_R_UNEXPECTED;
+                       goto socket6_failure;
+               }
+               iter->result6 = getbuf6(iter);
+               if (iter->result6 != ISC_R_NOTIMPLEMENTED &&
+                   iter->result6 != ISC_R_SUCCESS)
+                       goto ioctl6_failure;
+       }
+#endif
+       if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                isc_msgcat_get(isc_msgcat,
+                                               ISC_MSGSET_IFITERIOCTL,
+                                               ISC_MSG_MAKESCANSOCKET,
+                                               "making interface "
+                                               "scan socket: %s"),
+                                strbuf);
+               result = ISC_R_UNEXPECTED;
+               goto socket_failure;
+       }
+       result = getbuf4(iter);
+       if (result != ISC_R_SUCCESS)
+               goto ioctl_failure;
+
+       /*
+        * A newly created iterator has an undefined position
+        * until isc_interfaceiter_first() is called.
+        */
+#ifdef HAVE_TRUCLUSTER
+       iter->clua_context = -1;
+       iter->clua_done = ISC_TRUE;
+#endif
+#ifdef __linux
+       iter->proc = fopen("/proc/net/if_inet6", "r");
+       iter->valid = ISC_R_FAILURE;
+       iter->first = ISC_FALSE;
+#endif
+       iter->result = ISC_R_FAILURE;
+
+       iter->magic = IFITER_MAGIC;
+       *iterp = iter;
+       return (ISC_R_SUCCESS);
+
+ ioctl_failure:
+       if (iter->buf != NULL)
+               isc_mem_put(mctx, iter->buf, iter->bufsize);
+       (void) close(iter->socket);
+
+ socket_failure:
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+       if (iter->buf6 != NULL)
+               isc_mem_put(mctx, iter->buf6, iter->bufsize6);
+  ioctl6_failure:
+       if (iter->socket6 != -1)
+               (void) close(iter->socket6);
+  socket6_failure:
+#endif
+       isc_mem_put(mctx, iter, sizeof(*iter));
+       return (result);
+}
+
+#ifdef HAVE_TRUCLUSTER
+static void
+get_inaddr(isc_netaddr_t *dst, struct in_addr *src) {
+       dst->family = AF_INET;
+       memcpy(&dst->type.in, src, sizeof(struct in_addr));
+}
+
+static isc_result_t
+internal_current_clusteralias(isc_interfaceiter_t *iter) {
+       struct clua_info ci;
+       if (clua_getaliasinfo(&iter->clua_sa, &ci) != CLUA_SUCCESS)
+               return (ISC_R_IGNORE);
+       memset(&iter->current, 0, sizeof(iter->current));
+       iter->current.af = iter->clua_sa.sa_family;
+       memset(iter->current.name, 0, sizeof(iter->current.name));
+       sprintf(iter->current.name, "clua%d", ci.aliasid);
+       iter->current.flags = INTERFACE_F_UP;
+       get_inaddr(&iter->current.address, &ci.addr);
+       get_inaddr(&iter->current.netmask, &ci.netmask);
+       return (ISC_R_SUCCESS);
+}
+#endif
+
+#ifdef __linux
+static isc_result_t
+linux_if_inet6_next(isc_interfaceiter_t *iter) {
+       if (iter->proc != NULL &&
+           fgets(iter->entry, sizeof(iter->entry), iter->proc) != NULL)
+               iter->valid = ISC_R_SUCCESS;
+       else
+               iter->valid = ISC_R_NOMORE;
+       return (iter->valid);
+}
+
+static void
+linux_if_inet6_first(isc_interfaceiter_t *iter) {
+       if (iter->proc != NULL) {
+               rewind(iter->proc);
+               (void)linux_if_inet6_next(iter);
+       } else
+               iter->valid = ISC_R_NOMORE;
+       iter->first = ISC_FALSE;
+}
+
+static isc_result_t
+linux_if_inet6_current(isc_interfaceiter_t *iter) {
+       char address[33];
+       char name[IF_NAMESIZE+1];
+       char strbuf[ISC_STRERRORSIZE];
+       struct in6_addr addr6;
+       struct ifreq ifreq;
+       int ifindex, prefix, scope, flags;
+       int res;
+       unsigned int i;
+
+       if (iter->valid != ISC_R_SUCCESS)
+               return (iter->valid);
+       if (iter->proc == NULL) {
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                             "/proc/net/if_inet6:iter->proc == NULL");
+               return (ISC_R_FAILURE);
+       }
+
+       /*
+        * Format for /proc/net/if_inet6:
+        * (see iface_proc_info() in net/ipv6/addrconf.c)
+        * <addr6:32> <ifindex:2> <prefix:2> <scope:2> <flags:2> <name:8>
+        */
+       res = sscanf(iter->entry, "%32[a-f0-9] %x %x %x %x %16s\n",
+                    address, &ifindex, &prefix, &scope, &flags, name);
+       if (res != 6) {
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                             "/proc/net/if_inet6:sscanf() -> %d (expected 6)",
+                             res);
+               return (ISC_R_FAILURE);
+       }
+       if (strlen(address) != 32) {
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                             "/proc/net/if_inet6:strlen(%s) != 32", address);
+               return (ISC_R_FAILURE);
+       }
+       for (i = 0; i < 16; i++) {
+               unsigned char byte;
+               static const char hex[] = "0123456789abcdef";
+               byte = ((index(hex, address[i * 2]) - hex) << 4) |
+                      (index(hex, address[i * 2 + 1]) - hex);
+               addr6.s6_addr[i] = byte;
+       }
+       iter->current.af = AF_INET6;
+       /* iter->current.ifindex = ifindex; */
+       iter->current.flags = 0;
+
+       memset(&ifreq, 0, sizeof(ifreq));
+       INSIST(sizeof(ifreq.ifr_name) <= sizeof(iter->current.name));
+       strncpy(ifreq.ifr_name, name, sizeof(ifreq.ifr_name));
+
+       if (ioctl(iter->socket, SIOCGIFFLAGS, (char *) &ifreq) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "%s: getting interface flags: %s",
+                                ifreq.ifr_name, strbuf);
+               return (ISC_R_IGNORE);
+       }
+
+       if ((ifreq.ifr_flags & IFF_UP) != 0)
+               iter->current.flags |= INTERFACE_F_UP;
+#ifdef IFF_POINTOPOINT
+       if ((ifreq.ifr_flags & IFF_POINTOPOINT) != 0) 
+               iter->current.flags |= INTERFACE_F_POINTTOPOINT;
+#endif
+       if ((ifreq.ifr_flags & IFF_LOOPBACK) != 0)
+               iter->current.flags |= INTERFACE_F_LOOPBACK;
+       if ((ifreq.ifr_flags & IFF_BROADCAST) != 0)
+               iter->current.flags |= INTERFACE_F_BROADCAST;
+#ifdef IFF_MULTICAST
+       if ((ifreq.ifr_flags & IFF_MULTICAST) != 0)
+               iter->current.flags |= INTERFACE_F_MULTICAST;
+#endif
+
+       /*
+        * enable_multicast_if() requires scopeid for setsockopt,
+        * so associate address with their corresponding ifindex.
+        */
+       isc_netaddr_fromin6(&iter->current.address, &addr6);
+       isc_netaddr_setzone(&iter->current.address, (isc_uint32_t)ifindex);
+
+       for (i = 0; i < 16; i++) {
+               if (prefix > 8) {
+                       addr6.s6_addr[i] = 0xff;
+                       prefix -= 8;
+               } else {
+                       addr6.s6_addr[i] = (0xff << (8 - prefix)) & 0xff;
+                       prefix = 0;
+               }
+       }
+       isc_netaddr_fromin6(&iter->current.netmask, &addr6);
+       strncpy(iter->current.name, name, sizeof(iter->current.name));
+       return (ISC_R_SUCCESS);
+}
+#endif
+
+/*
+ * Get information about the current interface to iter->current.
+ * If successful, return ISC_R_SUCCESS.
+ * If the interface has an unsupported address family, or if
+ * some operation on it fails, return ISC_R_IGNORE to make
+ * the higher-level iterator code ignore it.
+ */
+
+static isc_result_t
+internal_current4(isc_interfaceiter_t *iter) {
+       struct ifreq *ifrp;
+       struct ifreq ifreq;
+       int family;
+       char strbuf[ISC_STRERRORSIZE];
+#if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR)
+       struct lifreq lifreq;
+#else
+       char sabuf[256];
+#endif
+       int i, bits, prefixlen;
+#ifdef __linux
+       isc_result_t result;
+#endif
+
+       REQUIRE(VALID_IFITER(iter));
+       REQUIRE (iter->pos < (unsigned int) iter->ifc.ifc_len);
+
+#ifdef __linux
+       result = linux_if_inet6_current(iter);
+       if (result != ISC_R_NOMORE)
+               return (result);
+       iter->first = ISC_TRUE;
+#endif
+
+       ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos);
+
+       memset(&ifreq, 0, sizeof(ifreq));
+       memcpy(&ifreq, ifrp, sizeof(ifreq));
+
+       family = ifreq.ifr_addr.sa_family;
+#if defined(ISC_PLATFORM_HAVEIPV6)
+       if (family != AF_INET && family != AF_INET6)
+#else
+       if (family != AF_INET)
+#endif
+               return (ISC_R_IGNORE);
+
+       memset(&iter->current, 0, sizeof(iter->current));
+       iter->current.af = family;
+
+       INSIST(sizeof(ifreq.ifr_name) <= sizeof(iter->current.name));
+       memset(iter->current.name, 0, sizeof(iter->current.name));
+       memcpy(iter->current.name, ifreq.ifr_name, sizeof(ifreq.ifr_name));
+
+       get_addr(family, &iter->current.address,
+                (struct sockaddr *)&ifrp->ifr_addr, ifreq.ifr_name);
+
+       /*
+        * If the interface does not have a address ignore it.
+        */
+       switch (family) {
+       case AF_INET:
+               if (iter->current.address.type.in.s_addr == htonl(INADDR_ANY))
+                       return (ISC_R_IGNORE);
+               break;
+#ifdef ISC_PLATFORM_HAVEIPV6
+       case AF_INET6:
+               if (memcmp(&iter->current.address.type.in6, &in6addr_any,
+                          sizeof(in6addr_any)) == 0)
+                       return (ISC_R_IGNORE);
+               break;
+#endif
+       }
+
+       /*
+        * Get interface flags.
+        */
+
+       iter->current.flags = 0;
+
+       /*
+        * Ignore the HP/UX warning about "integer overflow during
+        * conversion.  It comes from its own macro definition,
+        * and is really hard to shut up.
+        */
+       if (ioctl(iter->socket, SIOCGIFFLAGS, (char *) &ifreq) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "%s: getting interface flags: %s",
+                                ifreq.ifr_name, strbuf);
+               return (ISC_R_IGNORE);
+       }
+
+       if ((ifreq.ifr_flags & IFF_UP) != 0)
+               iter->current.flags |= INTERFACE_F_UP;
+
+#ifdef IFF_POINTOPOINT
+       if ((ifreq.ifr_flags & IFF_POINTOPOINT) != 0)
+               iter->current.flags |= INTERFACE_F_POINTTOPOINT;
+#endif
+
+       if ((ifreq.ifr_flags & IFF_LOOPBACK) != 0)
+               iter->current.flags |= INTERFACE_F_LOOPBACK;
+
+       if ((ifreq.ifr_flags & IFF_BROADCAST) != 0) {
+               iter->current.flags |= INTERFACE_F_BROADCAST;
+       }
+
+#ifdef IFF_MULTICAST
+       if ((ifreq.ifr_flags & IFF_MULTICAST) != 0) {
+               iter->current.flags |= INTERFACE_F_MULTICAST;
+       }
+#endif
+
+       if (family == AF_INET)
+               goto inet;
+
+#if !defined(ISC_PLATFORM_HAVEIF_LADDRREQ) && defined(SIOCGLIFADDR)
+       memset(&lifreq, 0, sizeof(lifreq));
+       memcpy(lifreq.lifr_name, iter->current.name, sizeof(lifreq.lifr_name));
+       memcpy(&lifreq.lifr_addr, &iter->current.address.type.in6,
+              sizeof(iter->current.address.type.in6));
+
+       if (ioctl(iter->socket, SIOCGLIFADDR, &lifreq) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "%s: getting interface address: %s",
+                                ifreq.ifr_name, strbuf);
+               return (ISC_R_IGNORE);
+       }
+       prefixlen = lifreq.lifr_addrlen;
+#else
+       isc_netaddr_format(&iter->current.address, sabuf, sizeof(sabuf));
+       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                     isc_msgcat_get(isc_msgcat,
+                                    ISC_MSGSET_IFITERIOCTL,
+                                    ISC_MSG_GETIFCONFIG,
+                                    "prefix length for %s is unknown "
+                                    "(assume 128)"), sabuf);
+       prefixlen = 128;
+#endif
+
+       /*
+        * Netmask already zeroed.
+        */
+       iter->current.netmask.family = family;
+       for (i = 0; i < 16; i++) {
+               if (prefixlen > 8) {
+                       bits = 0;
+                       prefixlen -= 8;
+               } else {
+                       bits = 8 - prefixlen;
+                       prefixlen = 0;
+               }
+               iter->current.netmask.type.in6.s6_addr[i] = (~0 << bits) & 0xff;
+       }
+       return (ISC_R_SUCCESS);
+
+ inet:
+       if (family != AF_INET)
+               return (ISC_R_IGNORE);
+#ifdef IFF_POINTOPOINT
+       /*
+        * If the interface is point-to-point, get the destination address.
+        */
+       if ((iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0) {
+               /*
+                * Ignore the HP/UX warning about "integer overflow during
+                * conversion.  It comes from its own macro definition,
+                * and is really hard to shut up.
+                */
+               if (ioctl(iter->socket, SIOCGIFDSTADDR, (char *)&ifreq)
+                   < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                               isc_msgcat_get(isc_msgcat,
+                                              ISC_MSGSET_IFITERIOCTL,
+                                              ISC_MSG_GETDESTADDR,
+                                              "%s: getting "
+                                              "destination address: %s"),
+                                        ifreq.ifr_name, strbuf);
+                       return (ISC_R_IGNORE);
+               }
+               get_addr(family, &iter->current.dstaddress,
+                        (struct sockaddr *)&ifreq.ifr_dstaddr, ifreq.ifr_name);
+       }
+#endif
+       if ((iter->current.flags & INTERFACE_F_BROADCAST) != 0) {
+               /*
+                * Ignore the HP/UX warning about "integer overflow during
+                * conversion.  It comes from its own macro definition,
+                * and is really hard to shut up.
+                */
+               if (ioctl(iter->socket, SIOCGIFBRDADDR, (char *)&ifreq)
+                   < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                               isc_msgcat_get(isc_msgcat,
+                                              ISC_MSGSET_IFITERIOCTL,
+                                              ISC_MSG_GETDESTADDR,
+                                              "%s: getting "
+                                              "broadcast address: %s"),
+                                        ifreq.ifr_name, strbuf);
+                       return (ISC_R_IGNORE);
+               }
+               get_addr(family, &iter->current.broadcast,
+                        (struct sockaddr *)&ifreq.ifr_broadaddr, ifreq.ifr_name);
+       }
+
+       /*
+        * Get the network mask.
+        */
+       memset(&ifreq, 0, sizeof(ifreq));
+       memcpy(&ifreq, ifrp, sizeof(ifreq));
+       /*
+        * Ignore the HP/UX warning about "integer overflow during
+        * conversion.  It comes from its own macro definition,
+        * and is really hard to shut up.
+        */
+       if (ioctl(iter->socket, SIOCGIFNETMASK, (char *)&ifreq) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                       isc_msgcat_get(isc_msgcat,
+                                      ISC_MSGSET_IFITERIOCTL,
+                                      ISC_MSG_GETNETMASK,
+                                      "%s: getting netmask: %s"),
+                                      ifreq.ifr_name, strbuf);
+               return (ISC_R_IGNORE);
+       }
+       get_addr(family, &iter->current.netmask,
+                (struct sockaddr *)&ifreq.ifr_addr, ifreq.ifr_name);
+       return (ISC_R_SUCCESS);
+}
+
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+static isc_result_t
+internal_current6(isc_interfaceiter_t *iter) {
+       struct LIFREQ *ifrp;
+       struct LIFREQ lifreq;
+       int family;
+       char strbuf[ISC_STRERRORSIZE];
+       int fd;
+
+       REQUIRE(VALID_IFITER(iter));
+       if (iter->result6 != ISC_R_SUCCESS)
+               return (iter->result6);
+       REQUIRE(iter->pos6 < (unsigned int) iter->lifc.lifc_len);
+
+       ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6);
+
+       memset(&lifreq, 0, sizeof(lifreq));
+       memcpy(&lifreq, ifrp, sizeof(lifreq));
+
+       family = lifreq.lifr_addr.ss_family;
+#ifdef ISC_PLATFORM_HAVEIPV6
+       if (family != AF_INET && family != AF_INET6)
+#else
+       if (family != AF_INET)
+#endif
+               return (ISC_R_IGNORE);
+
+       memset(&iter->current, 0, sizeof(iter->current));
+       iter->current.af = family;
+
+       INSIST(sizeof(lifreq.lifr_name) <= sizeof(iter->current.name));
+       memset(iter->current.name, 0, sizeof(iter->current.name));
+       memcpy(iter->current.name, lifreq.lifr_name, sizeof(lifreq.lifr_name));
+
+       get_addr(family, &iter->current.address,
+                (struct sockaddr *)&lifreq.lifr_addr, lifreq.lifr_name);
+
+       /*
+        * If the interface does not have a address ignore it.
+        */
+       switch (family) {
+       case AF_INET:
+               if (iter->current.address.type.in.s_addr == htonl(INADDR_ANY))
+                       return (ISC_R_IGNORE);
+               break;
+#ifdef ISC_PLATFORM_HAVEIPV6
+       case AF_INET6:
+               if (memcmp(&iter->current.address.type.in6, &in6addr_any,
+                          sizeof(in6addr_any)) == 0)
+                       return (ISC_R_IGNORE);
+               break;
+#endif
+       }
+
+       /*
+        * Get interface flags.
+        */
+
+       iter->current.flags = 0;
+
+       if (family == AF_INET6)
+               fd = iter->socket6;
+       else
+               fd = iter->socket;
+
+       /*
+        * Ignore the HP/UX warning about "integer overflow during
+        * conversion.  It comes from its own macro definition,
+        * and is really hard to shut up.
+        */
+       if (ioctl(fd, SIOCGLIFFLAGS, (char *) &lifreq) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "%s: getting interface flags: %s",
+                                lifreq.lifr_name, strbuf);
+               return (ISC_R_IGNORE);
+       }
+
+       if ((lifreq.lifr_flags & IFF_UP) != 0)
+               iter->current.flags |= INTERFACE_F_UP;
+
+#ifdef IFF_POINTOPOINT
+       if ((lifreq.lifr_flags & IFF_POINTOPOINT) != 0)
+               iter->current.flags |= INTERFACE_F_POINTTOPOINT;
+#endif
+
+       if ((lifreq.lifr_flags & IFF_LOOPBACK) != 0)
+               iter->current.flags |= INTERFACE_F_LOOPBACK;
+
+       if ((lifreq.lifr_flags & IFF_BROADCAST) != 0) {
+               iter->current.flags |= INTERFACE_F_BROADCAST;
+       }
+
+#ifdef IFF_MULTICAST
+       if ((lifreq.lifr_flags & IFF_MULTICAST) != 0) {
+               iter->current.flags |= INTERFACE_F_MULTICAST;
+       }
+#endif
+
+#ifdef IFF_POINTOPOINT
+       /*
+        * If the interface is point-to-point, get the destination address.
+        */
+       if ((iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0) {
+               /*
+                * Ignore the HP/UX warning about "interger overflow during
+                * conversion.  It comes from its own macro definition,
+                * and is really hard to shut up.
+                */
+               if (ioctl(fd, SIOCGLIFDSTADDR, (char *)&lifreq)
+                   < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                               isc_msgcat_get(isc_msgcat,
+                                              ISC_MSGSET_IFITERIOCTL,
+                                              ISC_MSG_GETDESTADDR,
+                                              "%s: getting "
+                                              "destination address: %s"),
+                                        lifreq.lifr_name, strbuf);
+                       return (ISC_R_IGNORE);
+               }
+               get_addr(family, &iter->current.dstaddress,
+                        (struct sockaddr *)&lifreq.lifr_dstaddr,
+                        lifreq.lifr_name);
+       }
+#endif
+
+#ifdef SIOCGLIFBRDADDR
+       if ((iter->current.flags & INTERFACE_F_BROADCAST) != 0) {
+               /*
+                * Ignore the HP/UX warning about "integer overflow during
+                * conversion.  It comes from its own macro definition,
+                * and is really hard to shut up.
+                */
+               if (ioctl(iter->socket, SIOCGLIFBRDADDR, (char *)&lifreq)
+                   < 0) {
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                               isc_msgcat_get(isc_msgcat,
+                                              ISC_MSGSET_IFITERIOCTL,
+                                              ISC_MSG_GETDESTADDR,
+                                              "%s: getting "
+                                              "broadcast address: %s"),
+                                        lifreq.lifr_name, strbuf);
+                       return (ISC_R_IGNORE);
+               }
+               get_addr(family, &iter->current.broadcast,
+                        (struct sockaddr *)&lifreq.lifr_broadaddr,
+                        lifreq.lifr_name);
+       }
+#endif /* SIOCGLIFBRDADDR */
+
+       /*
+        * Get the network mask.  Netmask already zeroed.
+        */
+       memset(&lifreq, 0, sizeof(lifreq));
+       memcpy(&lifreq, ifrp, sizeof(lifreq));
+
+#ifdef lifr_addrlen
+       /*
+        * Special case: if the system provides lifr_addrlen member, the
+        * netmask of an IPv6 address can be derived from the length, since
+        * an IPv6 address always has a contiguous mask.
+        */
+       if (family == AF_INET6) {
+               int i, bits;
+
+               iter->current.netmask.family = family;
+               for (i = 0; i < lifreq.lifr_addrlen; i += 8) {
+                       bits = lifreq.lifr_addrlen - i;
+                       bits = (bits < 8) ? (8 - bits) : 0;
+                       iter->current.netmask.type.in6.s6_addr[i / 8] =
+                               (~0 << bits) & 0xff;
+               }
+
+               return (ISC_R_SUCCESS);
+       }
+#endif
+
+       /*
+        * Ignore the HP/UX warning about "integer overflow during
+        * conversion.  It comes from its own macro definition,
+        * and is really hard to shut up.
+        */
+       if (ioctl(fd, SIOCGLIFNETMASK, (char *)&lifreq) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                isc_msgcat_get(isc_msgcat,
+                                               ISC_MSGSET_IFITERIOCTL,
+                                               ISC_MSG_GETNETMASK,
+                                               "%s: getting netmask: %s"),
+                                lifreq.lifr_name, strbuf);
+               return (ISC_R_IGNORE);
+       }
+       get_addr(family, &iter->current.netmask,
+                (struct sockaddr *)&lifreq.lifr_addr, lifreq.lifr_name);
+
+       return (ISC_R_SUCCESS);
+}
+#endif
+
+static isc_result_t
+internal_current(isc_interfaceiter_t *iter) {
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+       if (iter->mode == 6) {
+               iter->result6 = internal_current6(iter);
+               if (iter->result6 != ISC_R_NOMORE)
+                       return (iter->result6);
+       }
+#endif
+#ifdef HAVE_TRUCLUSTER
+       if (!iter->clua_done)
+               return(internal_current_clusteralias(iter));
+#endif
+       return (internal_current4(iter));
+}
+
+/*
+ * Step the iterator to the next interface.  Unlike
+ * isc_interfaceiter_next(), this may leave the iterator
+ * positioned on an interface that will ultimately
+ * be ignored.  Return ISC_R_NOMORE if there are no more
+ * interfaces, otherwise ISC_R_SUCCESS.
+ */
+static isc_result_t
+internal_next4(isc_interfaceiter_t *iter) {
+       struct ifreq *ifrp;
+
+       REQUIRE (iter->pos < (unsigned int) iter->ifc.ifc_len);
+
+#ifdef __linux
+       if (linux_if_inet6_next(iter) == ISC_R_SUCCESS)
+               return (ISC_R_SUCCESS);
+       if (!iter->first)
+               return (ISC_R_SUCCESS);
+#endif
+       ifrp = (struct ifreq *)((char *) iter->ifc.ifc_req + iter->pos);
+
+#ifdef ISC_PLATFORM_HAVESALEN
+       if (ifrp->ifr_addr.sa_len > sizeof(struct sockaddr))
+               iter->pos += sizeof(ifrp->ifr_name) + ifrp->ifr_addr.sa_len;
+       else
+#endif
+               iter->pos += sizeof(*ifrp);
+
+       if (iter->pos >= (unsigned int) iter->ifc.ifc_len)
+               return (ISC_R_NOMORE);
+
+       return (ISC_R_SUCCESS);
+}
+
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+static isc_result_t
+internal_next6(isc_interfaceiter_t *iter) {
+       struct LIFREQ *ifrp;
+       
+       if (iter->result6 != ISC_R_SUCCESS && iter->result6 != ISC_R_IGNORE)
+               return (iter->result6);
+
+       REQUIRE(iter->pos6 < (unsigned int) iter->lifc.lifc_len);
+
+       ifrp = (struct LIFREQ *)((char *) iter->lifc.lifc_req + iter->pos6);
+
+#ifdef ISC_PLATFORM_HAVESALEN
+       if (ifrp->lifr_addr.sa_len > sizeof(struct sockaddr))
+               iter->pos6 += sizeof(ifrp->lifr_name) + ifrp->lifr_addr.sa_len;
+       else
+#endif
+               iter->pos6 += sizeof(*ifrp);
+
+       if (iter->pos6 >= (unsigned int) iter->lifc.lifc_len)
+               return (ISC_R_NOMORE);
+
+       return (ISC_R_SUCCESS);
+}
+#endif
+
+static isc_result_t
+internal_next(isc_interfaceiter_t *iter) {
+#ifdef HAVE_TRUCLUSTER
+       int clua_result;
+#endif
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+       if (iter->mode == 6) {
+               iter->result6 = internal_next6(iter);
+               if (iter->result6 != ISC_R_NOMORE)
+                       return (iter->result6);
+               if (iter->first6) {
+                       iter->first6 = ISC_FALSE;
+                       return (ISC_R_SUCCESS);
+               }
+       }
+#endif
+#ifdef HAVE_TRUCLUSTER
+       if (!iter->clua_done) {
+               clua_result = clua_getaliasaddress(&iter->clua_sa,
+                                                  &iter->clua_context);
+               if (clua_result != CLUA_SUCCESS)
+                       iter->clua_done = ISC_TRUE;
+               return (ISC_R_SUCCESS);
+       }
+#endif
+       return (internal_next4(iter));
+}
+
+static void
+internal_destroy(isc_interfaceiter_t *iter) {
+       (void) close(iter->socket);
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+       if (iter->socket6 != -1)
+               (void) close(iter->socket6);
+       if (iter->buf6 != NULL) {
+               isc_mem_put(iter->mctx, iter->buf6, iter->bufsize6);
+       }
+#endif
+#ifdef __linux
+       if (iter->proc != NULL)
+               fclose(iter->proc);
+#endif
+}
+
+static
+void internal_first(isc_interfaceiter_t *iter) {
+#ifdef HAVE_TRUCLUSTER
+       int clua_result;
+#endif
+       iter->pos = 0;
+#if defined(SIOCGLIFCONF) && defined(SIOCGLIFADDR)
+       iter->pos6 = 0;
+       if (iter->result6 == ISC_R_NOMORE)
+               iter->result6 = ISC_R_SUCCESS;
+       iter->first6 = ISC_TRUE;
+#endif
+#ifdef HAVE_TRUCLUSTER
+       iter->clua_context = 0;
+       clua_result = clua_getaliasaddress(&iter->clua_sa,
+                                          &iter->clua_context);
+       iter->clua_done = ISC_TF(clua_result != CLUA_SUCCESS);
+#endif
+#ifdef __linux
+       linux_if_inet6_first(iter);
+#endif
+}
diff --git a/libisc/ifiter_sysctl.c b/libisc/ifiter_sysctl.c
new file mode 100644 (file)
index 0000000..6206e6e
--- /dev/null
@@ -0,0 +1,315 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: ifiter_sysctl.c,v 1.14.12.7 2004/03/08 09:04:56 marka Exp $ */
+
+/*
+ * Obtain the list of network interfaces using sysctl.
+ * See TCP/IP Illustrated Volume 2, sections 19.8, 19.14,
+ * and 19.16.
+ */
+
+#include <sys/param.h>
+#include <sys/sysctl.h>
+
+#include <net/route.h>
+#include <net/if_dl.h>
+
+/* XXX what about Alpha? */
+#ifdef sgi
+#define ROUNDUP(a) ((a) > 0 ? \
+               (1 + (((a) - 1) | (sizeof(__uint64_t) - 1))) : \
+               sizeof(__uint64_t))
+#else
+#define ROUNDUP(a) ((a) > 0 ? (1 + (((a) - 1) | (sizeof(long) - 1))) \
+                    : sizeof(long))
+#endif
+
+#define IFITER_MAGIC           ISC_MAGIC('I', 'F', 'I', 'S')
+#define VALID_IFITER(t)                ISC_MAGIC_VALID(t, IFITER_MAGIC)
+
+struct isc_interfaceiter {
+       unsigned int            magic;          /* Magic number. */
+       isc_mem_t               *mctx;
+       void                    *buf;           /* Buffer for sysctl data. */
+       unsigned int            bufsize;        /* Bytes allocated. */
+       unsigned int            bufused;        /* Bytes used. */
+       unsigned int            pos;            /* Current offset in
+                                                  sysctl data. */
+       isc_interface_t         current;        /* Current interface data. */
+       isc_result_t            result;         /* Last result code. */
+};
+
+static int mib[6] = {
+       CTL_NET,
+       PF_ROUTE,
+        0,
+       0,                      /* Any address family. */
+        NET_RT_IFLIST,
+       0                       /* Flags. */
+};
+
+isc_result_t
+isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
+       isc_interfaceiter_t *iter;
+       isc_result_t result;
+       size_t bufsize;
+       size_t bufused;
+       char strbuf[ISC_STRERRORSIZE];
+
+       REQUIRE(iterp != NULL);
+       REQUIRE(*iterp == NULL);
+
+       iter = isc_mem_get(mctx, sizeof(*iter));
+       if (iter == NULL)
+               return (ISC_R_NOMEMORY);
+
+       iter->mctx = mctx;
+       iter->buf = 0;
+
+       /*
+        * Determine the amount of memory needed.
+        */
+       bufsize = 0;
+       if (sysctl(mib, 6, NULL, &bufsize, NULL, (size_t) 0) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                isc_msgcat_get(isc_msgcat,
+                                               ISC_MSGSET_IFITERSYSCTL,
+                                               ISC_MSG_GETIFLISTSIZE,
+                                               "getting interface "
+                                               "list size: sysctl: %s"),
+                                strbuf);
+               result = ISC_R_UNEXPECTED;
+               goto failure;
+       }
+       iter->bufsize = bufsize;
+
+       iter->buf = isc_mem_get(iter->mctx, iter->bufsize);
+       if (iter->buf == NULL) {
+               result = ISC_R_NOMEMORY;
+               goto failure;
+       }
+
+       bufused = bufsize;
+       if (sysctl(mib, 6, iter->buf, &bufused, NULL, (size_t) 0) < 0) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                isc_msgcat_get(isc_msgcat,
+                                               ISC_MSGSET_IFITERSYSCTL,
+                                               ISC_MSG_GETIFLIST,
+                                               "getting interface list: "
+                                               "sysctl: %s"),
+                                strbuf);
+               result = ISC_R_UNEXPECTED;
+               goto failure;
+       }
+       iter->bufused = bufused;
+       INSIST(iter->bufused <= iter->bufsize);
+
+       /*
+        * A newly created iterator has an undefined position
+        * until isc_interfaceiter_first() is called.
+        */
+       iter->pos = (unsigned int) -1;
+       iter->result = ISC_R_FAILURE;
+
+       iter->magic = IFITER_MAGIC;
+       *iterp = iter;
+       return (ISC_R_SUCCESS);
+
+ failure:
+       if (iter->buf != NULL)
+               isc_mem_put(mctx, iter->buf, iter->bufsize);
+       isc_mem_put(mctx, iter, sizeof(*iter));
+       return (result);
+}
+
+/*
+ * Get information about the current interface to iter->current.
+ * If successful, return ISC_R_SUCCESS.
+ * If the interface has an unsupported address family,
+ * return ISC_R_IGNORE.  In case of other failure,
+ * return ISC_R_UNEXPECTED.
+ */
+
+static isc_result_t
+internal_current(isc_interfaceiter_t *iter) {
+       struct ifa_msghdr *ifam, *ifam_end;
+
+       REQUIRE(VALID_IFITER(iter));
+       REQUIRE (iter->pos < (unsigned int) iter->bufused);
+
+       ifam = (struct ifa_msghdr *) ((char *) iter->buf + iter->pos);
+       ifam_end = (struct ifa_msghdr *) ((char *) iter->buf + iter->bufused);
+
+       if (ifam->ifam_type == RTM_IFINFO) {
+               struct if_msghdr *ifm = (struct if_msghdr *) ifam;
+               struct sockaddr_dl *sdl = (struct sockaddr_dl *) (ifm + 1);
+               unsigned int namelen;
+
+               memset(&iter->current, 0, sizeof(iter->current));
+
+               namelen = sdl->sdl_nlen;
+               if (namelen > sizeof(iter->current.name) - 1)
+                       namelen = sizeof(iter->current.name) - 1;
+
+               memset(iter->current.name, 0, sizeof(iter->current.name));
+               memcpy(iter->current.name, sdl->sdl_data, namelen);
+
+               iter->current.flags = 0;
+
+               if ((ifam->ifam_flags & IFF_UP) != 0)
+                       iter->current.flags |= INTERFACE_F_UP;
+
+               if ((ifam->ifam_flags & IFF_POINTOPOINT) != 0)
+                       iter->current.flags |= INTERFACE_F_POINTTOPOINT;
+
+               if ((ifam->ifam_flags & IFF_LOOPBACK) != 0)
+                       iter->current.flags |= INTERFACE_F_LOOPBACK;
+
+               if ((ifam->ifam_flags & IFF_BROADCAST) != 0) {
+                       iter->current.flags |= INTERFACE_F_BROADCAST;
+               }
+#ifdef IFF_MULTICAST
+               if ((ifam->ifam_flags & IFF_MULTICAST) != 0) {
+                       iter->current.flags |= INTERFACE_F_MULTICAST;
+               }
+#endif
+
+               /*
+                * This is not an interface address.
+                * Force another iteration.
+                */
+               return (ISC_R_IGNORE);
+       } else if (ifam->ifam_type == RTM_NEWADDR) {
+               int i;
+               int family;
+               struct sockaddr *mask_sa = NULL;
+               struct sockaddr *addr_sa = NULL;
+               struct sockaddr *dst_sa = NULL;
+
+               struct sockaddr *sa = (struct sockaddr *)(ifam + 1);
+               family = sa->sa_family;
+
+               for (i = 0; i < RTAX_MAX; i++)
+               {
+                       if ((ifam->ifam_addrs & (1 << i)) == 0)
+                               continue;
+
+                       INSIST(sa < (struct sockaddr *) ifam_end);
+
+                       switch (i) {
+                       case RTAX_NETMASK: /* Netmask */
+                               mask_sa = sa;
+                               break;
+                       case RTAX_IFA: /* Interface address */
+                               addr_sa = sa;
+                               break;
+                       case RTAX_BRD: /* Broadcast or destination address */
+                               dst_sa = sa;
+                               break;
+                       }
+#ifdef ISC_PLATFORM_HAVESALEN
+                       sa = (struct sockaddr *)((char*)(sa)
+                                        + ROUNDUP(sa->sa_len));
+#else
+#ifdef sgi
+                       /*
+                        * Do as the contributed SGI code does.
+                        */
+                       sa = (struct sockaddr *)((char*)(sa)
+                                        + ROUNDUP(_FAKE_SA_LEN_DST(sa)));
+#else
+                       /* XXX untested. */
+                       sa = (struct sockaddr *)((char*)(sa)
+                                        + ROUNDUP(sizeof(struct sockaddr)));
+#endif
+#endif
+               }
+
+               if (addr_sa == NULL)
+                       return (ISC_R_IGNORE);
+
+               family = addr_sa->sa_family;
+               if (family != AF_INET && family != AF_INET6)
+                       return (ISC_R_IGNORE);
+
+               iter->current.af = family;
+
+               get_addr(family, &iter->current.address, addr_sa,
+                        iter->current.name);
+
+               if (mask_sa != NULL)
+                       get_addr(family, &iter->current.netmask, mask_sa,
+                                iter->current.name);
+
+               if (dst_sa != NULL &&
+                   (iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0)
+                       get_addr(family, &iter->current.dstaddress, dst_sa,
+                                iter->current.name);
+
+               if (dst_sa != NULL &&
+                   (iter->current.flags & INTERFACE_F_BROADCAST) != 0)
+                       get_addr(family, &iter->current.broadcast, dst_sa,
+                                iter->current.name);
+
+
+               return (ISC_R_SUCCESS);
+       } else {
+               printf(isc_msgcat_get(isc_msgcat, ISC_MSGSET_IFITERSYSCTL,
+                                     ISC_MSG_UNEXPECTEDTYPE,
+                                     "warning: unexpected interface list "
+                                     "message type\n"));
+               return (ISC_R_IGNORE);
+       }
+}
+
+/*
+ * Step the iterator to the next interface.  Unlike
+ * isc_interfaceiter_next(), this may leave the iterator
+ * positioned on an interface that will ultimately
+ * be ignored.  Return ISC_R_NOMORE if there are no more
+ * interfaces, otherwise ISC_R_SUCCESS.
+ */
+static isc_result_t
+internal_next(isc_interfaceiter_t *iter) {
+       struct ifa_msghdr *ifam;
+       REQUIRE (iter->pos < (unsigned int) iter->bufused);
+
+       ifam = (struct ifa_msghdr *) ((char *) iter->buf + iter->pos);
+
+       iter->pos += ifam->ifam_msglen;
+
+       if (iter->pos >= iter->bufused)
+               return (ISC_R_NOMORE);
+
+       return (ISC_R_SUCCESS);
+}
+
+static void
+internal_destroy(isc_interfaceiter_t *iter) {
+       UNUSED(iter); /* Unused. */
+       /*
+        * Do nothing.
+        */
+}
+
+static
+void internal_first(isc_interfaceiter_t *iter) {
+       iter->pos = 0;
+}
diff --git a/libisc/inet_aton.c b/libisc/inet_aton.c
new file mode 100644 (file)
index 0000000..530b010
--- /dev/null
@@ -0,0 +1,195 @@
+/*
+ * Portions Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (C) 1996-2001  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/*
+ * Copyright (c) 1983, 1990, 1993
+ *    The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 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.
+ */
+
+/*
+ * Portions Copyright (c) 1993 by Digital Equipment Corporation.
+ *
+ * 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, and that
+ * the name of Digital Equipment Corporation not be used in advertising or
+ * publicity pertaining to distribution of the document or software without
+ * specific, written prior permission.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
+ * WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
+ * OF MERCHANTABILITY AND FITNESS.   IN NO EVENT SHALL DIGITAL EQUIPMENT
+ * CORPORATION 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char sccsid[] = "@(#)inet_addr.c        8.1 (Berkeley) 6/17/93";
+static char rcsid[] = "$Id: inet_aton.c,v 1.15.12.3 2004/03/08 09:04:49 marka Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <config.h>
+
+#include <ctype.h>
+#include <stddef.h>            /* Required for NULL. */
+
+#include <isc/types.h>
+#include <isc/net.h>
+
+/*
+ * Check whether "cp" is a valid ascii representation
+ * of an Internet address and convert to a binary address.
+ * Returns 1 if the address is valid, 0 if not.
+ * This replaces inet_addr, the return value from which
+ * cannot distinguish between failure and a local broadcast address.
+ */
+int
+isc_net_aton(const char *cp, struct in_addr *addr) {
+       unsigned long val;
+       int base, n;
+       unsigned char c;
+       isc_uint8_t parts[4];
+       isc_uint8_t *pp = parts;
+       int digit;
+
+       c = *cp;
+       for (;;) {
+               /*
+                * Collect number up to ``.''.
+                * Values are specified as for C:
+                * 0x=hex, 0=octal, isdigit=decimal.
+                */
+               if (!isdigit(c & 0xff))
+                       return (0);
+               val = 0; base = 10; digit = 0;
+               if (c == '0') {
+                       c = *++cp;
+                       if (c == 'x' || c == 'X')
+                               base = 16, c = *++cp;
+                       else {
+                               base = 8;
+                               digit = 1;
+                       }
+               }
+               for (;;) {
+                       /*
+                        * isascii() is valid for all integer values, and
+                        * when it is true, c is known to be in scope
+                        * for isdigit().  No cast necessary.  Similar
+                        * comment applies for later ctype uses.
+                        */
+                       if (isascii(c) && isdigit(c)) {
+                               if (base == 8 && (c == '8' || c == '9'))
+                                       return (0);
+                               val = (val * base) + (c - '0');
+                               c = *++cp;
+                               digit = 1;
+                       } else if (base == 16 && isascii(c) && isxdigit(c)) {
+                               val = (val << 4) |
+                                       (c + 10 - (islower(c) ? 'a' : 'A'));
+                               c = *++cp;
+                               digit = 1;
+                       } else
+                               break;
+               }
+               if (c == '.') {
+                       /*
+                        * Internet format:
+                        *      a.b.c.d
+                        *      a.b.c   (with c treated as 16 bits)
+                        *      a.b     (with b treated as 24 bits)
+                        */
+                       if (pp >= parts + 3 || val > 0xff)
+                               return (0);
+                       *pp++ = (isc_uint8_t)val;
+                       c = *++cp;
+               } else
+                       break;
+       }
+       /*
+        * Check for trailing characters.
+        */
+       if (c != '\0' && (!isascii(c) || !isspace(c)))
+               return (0);
+       /*
+        * Did we get a valid digit?
+        */
+       if (!digit)
+               return (0);
+       /*
+        * Concoct the address according to
+        * the number of parts specified.
+        */
+       n = pp - parts + 1;
+       switch (n) {
+       case 1:                         /* a -- 32 bits */
+               break;
+
+       case 2:                         /* a.b -- 8.24 bits */
+               if (val > 0xffffff)
+                       return (0);
+               val |= parts[0] << 24;
+               break;
+
+       case 3:                         /* a.b.c -- 8.8.16 bits */
+               if (val > 0xffff)
+                       return (0);
+               val |= (parts[0] << 24) | (parts[1] << 16);
+               break;
+
+       case 4:                         /* a.b.c.d -- 8.8.8.8 bits */
+               if (val > 0xff)
+                       return (0);
+               val |= (parts[0] << 24) | (parts[1] << 16) | (parts[2] << 8);
+               break;
+       }
+       if (addr != NULL)
+               addr->s_addr = htonl(val);
+
+       return (1);
+}
diff --git a/libisc/inet_ntop.c b/libisc/inet_ntop.c
new file mode 100644 (file)
index 0000000..395d0e5
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * Copyright (C) 1996-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] =
+       "$Id: inet_ntop.c,v 1.13 2001/11/27 01:56:00 gson Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <config.h>
+
+#include <errno.h>
+#include <stdio.h>
+#include <string.h>
+
+#include <isc/net.h>
+
+#include "ntp_sprintf.h"
+
+#define NS_INT16SZ      2
+#define NS_IN6ADDRSZ   16
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static const char *inet_ntop4(const unsigned char *src, char *dst,
+                             size_t size);
+
+#ifdef AF_INET6
+static const char *inet_ntop6(const unsigned char *src, char *dst,
+                             size_t size);
+#endif
+
+/* char *
+ * isc_net_ntop(af, src, dst, size)
+ *     convert a network format address to presentation format.
+ * return:
+ *     pointer to presentation format address (`dst'), or NULL (see errno).
+ * author:
+ *     Paul Vixie, 1996.
+ */
+const char *
+isc_net_ntop(int af, const void *src, char *dst, size_t size)
+{
+       switch (af) {
+       case AF_INET:
+               return (inet_ntop4(src, dst, size));
+#ifdef AF_INET6
+       case AF_INET6:
+               return (inet_ntop6(src, dst, size));
+#endif
+       default:
+               errno = EAFNOSUPPORT;
+               return (NULL);
+       }
+       /* NOTREACHED */
+}
+
+/* const char *
+ * inet_ntop4(src, dst, size)
+ *     format an IPv4 address
+ * return:
+ *     `dst' (as a const)
+ * notes:
+ *     (1) uses no statics
+ *     (2) takes a unsigned char* not an in_addr as input
+ * author:
+ *     Paul Vixie, 1996.
+ */
+static const char *
+inet_ntop4(const unsigned char *src, char *dst, size_t size)
+{
+       static const char *fmt = "%u.%u.%u.%u";
+       char tmp[sizeof("255.255.255.255")];
+
+       if (SPRINTF((tmp, fmt, src[0], src[1], src[2], src[3])) >= size)
+       {
+               errno = ENOSPC;
+               return (NULL);
+       }
+       strcpy(dst, tmp);
+
+       return (dst);
+}
+
+/* const char *
+ * isc_inet_ntop6(src, dst, size)
+ *     convert IPv6 binary address into presentation (printable) format
+ * author:
+ *     Paul Vixie, 1996.
+ */
+#ifdef AF_INET6
+static const char *
+inet_ntop6(const unsigned char *src, char *dst, size_t size)
+{
+       /*
+        * Note that int32_t and int16_t need only be "at least" large enough
+        * to contain a value of the specified size.  On some systems, like
+        * Crays, there is no such thing as an integer variable with 16 bits.
+        * Keep this in mind if you think this function should have been coded
+        * to use pointer overlays.  All the world's not a VAX.
+        */
+       char tmp[sizeof("ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255")], *tp;
+       struct { int base, len; } best, cur;
+       unsigned int words[NS_IN6ADDRSZ / NS_INT16SZ];
+       int i;
+
+       /*
+        * Preprocess:
+        *      Copy the input (bytewise) array into a wordwise array.
+        *      Find the longest run of 0x00's in src[] for :: shorthanding.
+        */
+       memset(words, '\0', sizeof(words));
+       for (i = 0; i < NS_IN6ADDRSZ; i++)
+               words[i / 2] |= (src[i] << ((1 - (i % 2)) << 3));
+       best.base = -1;
+       best.len = 0;
+       cur.base = -1;
+       cur.len = 0;
+       for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
+               if (words[i] == 0) {
+                       if (cur.base == -1)
+                               cur.base = i, cur.len = 1;
+                       else
+                               cur.len++;
+               } else {
+                       if (cur.base != -1) {
+                               if (best.base == -1 || cur.len > best.len)
+                                       best = cur;
+                               cur.base = -1;
+                       }
+               }
+       }
+       if (cur.base != -1) {
+               if (best.base == -1 || cur.len > best.len)
+                       best = cur;
+       }
+       if (best.base != -1 && best.len < 2)
+               best.base = -1;
+
+       /*
+        * Format the result.
+        */
+       tp = tmp;
+       for (i = 0; i < (NS_IN6ADDRSZ / NS_INT16SZ); i++) {
+               /* Are we inside the best run of 0x00's? */
+               if (best.base != -1 && i >= best.base &&
+                   i < (best.base + best.len)) {
+                       if (i == best.base)
+                               *tp++ = ':';
+                       continue;
+               }
+               /* Are we following an initial run of 0x00s or any real hex? */
+               if (i != 0)
+                       *tp++ = ':';
+               /* Is this address an encapsulated IPv4? */
+               if (i == 6 && best.base == 0 &&
+                   (best.len == 6 || (best.len == 5 && words[5] == 0xffff))) {
+                       if (!inet_ntop4(src+12, tp,
+                                       sizeof(tmp) - (tp - tmp)))
+                               return (NULL);
+                       tp += strlen(tp);
+                       break;
+               }
+               tp += SPRINTF((tp, "%x", words[i]));
+       }
+       /* Was it a trailing run of 0x00's? */
+       if (best.base != -1 && (best.base + best.len) ==
+           (NS_IN6ADDRSZ / NS_INT16SZ))
+               *tp++ = ':';
+       *tp++ = '\0';
+
+       /*
+        * Check for overflow, copy, and we're done.
+        */
+       if ((size_t)(tp - tmp) > size) {
+               errno = ENOSPC;
+               return (NULL);
+       }
+       strcpy(dst, tmp);
+       return (dst);
+}
+#endif /* AF_INET6 */
diff --git a/libisc/inet_pton.c b/libisc/inet_pton.c
new file mode 100644 (file)
index 0000000..afda394
--- /dev/null
@@ -0,0 +1,211 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1996-2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] =
+       "$Id: inet_pton.c,v 1.10.2.4.2.1 2004/03/06 08:14:31 marka Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <config.h>
+
+#include <errno.h>
+#include <string.h>
+
+#include <isc/net.h>
+
+#define NS_INT16SZ      2
+#define NS_INADDRSZ     4
+#define NS_IN6ADDRSZ   16
+
+/*
+ * WARNING: Don't even consider trying to compile this on a system where
+ * sizeof(int) < 4.  sizeof(int) > 4 is fine; all the world's not a VAX.
+ */
+
+static int inet_pton4(const char *src, unsigned char *dst);
+static int inet_pton6(const char *src, unsigned char *dst);
+
+/* int
+ * isc_net_pton(af, src, dst)
+ *     convert from presentation format (which usually means ASCII printable)
+ *     to network format (which is usually some kind of binary format).
+ * return:
+ *     1 if the address was valid for the specified address family
+ *     0 if the address wasn't valid (`dst' is untouched in this case)
+ *     -1 if some other error occurred (`dst' is untouched in this case, too)
+ * author:
+ *     Paul Vixie, 1996.
+ */
+int
+isc_net_pton(int af, const char *src, void *dst) {
+       switch (af) {
+       case AF_INET:
+               return (inet_pton4(src, dst));
+       case AF_INET6:
+               return (inet_pton6(src, dst));
+       default:
+               errno = EAFNOSUPPORT;
+               return (-1);
+       }
+       /* NOTREACHED */
+}
+
+/* int
+ * inet_pton4(src, dst)
+ *     like inet_aton() but without all the hexadecimal and shorthand.
+ * return:
+ *     1 if `src' is a valid dotted quad, else 0.
+ * notice:
+ *     does not touch `dst' unless it's returning 1.
+ * author:
+ *     Paul Vixie, 1996.
+ */
+static int
+inet_pton4(const char *src, unsigned char *dst) {
+       static const char digits[] = "0123456789";
+       int saw_digit, octets, ch;
+       unsigned char tmp[NS_INADDRSZ], *tp;
+
+       saw_digit = 0;
+       octets = 0;
+       *(tp = tmp) = 0;
+       while ((ch = *src++) != '\0') {
+               const char *pch;
+
+               if ((pch = strchr(digits, ch)) != NULL) {
+                       unsigned int new = *tp * 10 + (pch - digits);
+
+                       if (saw_digit && *tp == 0)
+                               return (0);
+                       if (new > 255)
+                               return (0);
+                       *tp = (unsigned char) new;
+                       if (!saw_digit) {
+                               if (++octets > 4)
+                                       return (0);
+                               saw_digit = 1;
+                       }
+               } else if (ch == '.' && saw_digit) {
+                       if (octets == 4)
+                               return (0);
+                       *++tp = 0;
+                       saw_digit = 0;
+               } else
+                       return (0);
+       }
+       if (octets < 4)
+               return (0);
+       memcpy(dst, tmp, NS_INADDRSZ);
+       return (1);
+}
+
+/* int
+ * inet_pton6(src, dst)
+ *     convert presentation level address to network order binary form.
+ * return:
+ *     1 if `src' is a valid [RFC1884 2.2] address, else 0.
+ * notice:
+ *     (1) does not touch `dst' unless it's returning 1.
+ *     (2) :: in a full address is silently ignored.
+ * credit:
+ *     inspired by Mark Andrews.
+ * author:
+ *     Paul Vixie, 1996.
+ */
+static int
+inet_pton6(const char *src, unsigned char *dst) {
+       static const char xdigits_l[] = "0123456789abcdef",
+                         xdigits_u[] = "0123456789ABCDEF";
+       unsigned char tmp[NS_IN6ADDRSZ], *tp, *endp, *colonp;
+       const char *xdigits, *curtok;
+       int ch, saw_xdigit;
+       unsigned int val;
+
+       memset((tp = tmp), '\0', NS_IN6ADDRSZ);
+       endp = tp + NS_IN6ADDRSZ;
+       colonp = NULL;
+       /* Leading :: requires some special handling. */
+       if (*src == ':')
+               if (*++src != ':')
+                       return (0);
+       curtok = src;
+       saw_xdigit = 0;
+       val = 0;
+       while ((ch = *src++) != '\0') {
+               const char *pch;
+
+               if ((pch = strchr((xdigits = xdigits_l), ch)) == NULL)
+                       pch = strchr((xdigits = xdigits_u), ch);
+               if (pch != NULL) {
+                       val <<= 4;
+                       val |= (pch - xdigits);
+                       if (val > 0xffff)
+                               return (0);
+                       saw_xdigit = 1;
+                       continue;
+               }
+               if (ch == ':') {
+                       curtok = src;
+                       if (!saw_xdigit) {
+                               if (colonp)
+                                       return (0);
+                               colonp = tp;
+                               continue;
+                       }
+                       if (tp + NS_INT16SZ > endp)
+                               return (0);
+                       *tp++ = (unsigned char) ((val >> 8) & 0xff);
+                       *tp++ = (unsigned char) (val & 0xff);
+                       saw_xdigit = 0;
+                       val = 0;
+                       continue;
+               }
+               if (ch == '.' && ((tp + NS_INADDRSZ) <= endp) &&
+                   inet_pton4(curtok, tp) > 0) {
+                       tp += NS_INADDRSZ;
+                       saw_xdigit = 0;
+                       break;  /* '\0' was seen by inet_pton4(). */
+               }
+               return (0);
+       }
+       if (saw_xdigit) {
+               if (tp + NS_INT16SZ > endp)
+                       return (0);
+               *tp++ = (unsigned char) ((val >> 8) & 0xff);
+               *tp++ = (unsigned char) (val & 0xff);
+       }
+       if (colonp != NULL) {
+               /*
+                * Since some memmove()'s erroneously fail to handle
+                * overlapping regions, we'll do the shift by hand.
+                */
+               const int n = tp - colonp;
+               int i;
+
+               if (tp == endp)
+                       return (0);
+               for (i = 1; i <= n; i++) {
+                       endp[- i] = colonp[n - i];
+                       colonp[n - i] = 0;
+               }
+               tp = endp;
+       }
+       if (tp != endp)
+               return (0);
+       memcpy(dst, tmp, NS_IN6ADDRSZ);
+       return (1);
+}
diff --git a/libisc/interfaceiter.c b/libisc/interfaceiter.c
new file mode 100644 (file)
index 0000000..7e31975
--- /dev/null
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: interfaceiter.c,v 1.22.2.1.10.14 2004/08/28 06:25:22 marka Exp $ */
+
+#include <config.h>
+
+#define ISC_ONLY_IPV6
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+#ifdef HAVE_SYS_SOCKIO_H
+#include <sys/sockio.h>                /* Required for ifiter_ioctl.c. */
+#endif
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <errno.h>
+
+#include <isc/interfaceiter.h>
+#include <isc/magic.h>
+#include <isc/mem.h>
+#include <isc/msgs.h>
+#include <isc/net.h>
+#include <isc/print.h>
+#include <isc/result.h>
+#include <isc/strerror.h>
+#include <isc/string.h>
+#include <isc/types.h>
+#include <isc/util.h>
+
+/* Must follow <isc/net.h>. */
+#ifdef HAVE_NET_IF6_H
+#include <net/if6.h>
+#endif
+
+/* Common utility functions */
+
+/*
+ * Extract the network address part from a "struct sockaddr".
+ *
+ * The address family is given explicitly
+ * instead of using src->sa_family, because the latter does not work
+ * for copying a network mask obtained by SIOCGIFNETMASK (it does
+ * not have a valid address family).
+ */
+
+static void
+get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src,
+        char *ifname)
+{
+       struct sockaddr_in6 *sa6;
+
+#if !defined(ISC_PLATFORM_HAVEIFNAMETOINDEX) || \
+    !defined(ISC_PLATFORM_HAVESCOPEID)
+       UNUSED(ifname);
+#endif
+
+       /* clear any remaining value for safety */
+       memset(dst, 0, sizeof(*dst));
+
+       dst->family = family;
+       switch (family) {
+       case AF_INET:
+               memcpy(&dst->type.in,
+                      &((struct sockaddr_in *) src)->sin_addr,
+                      sizeof(struct in_addr));
+               break;
+       case AF_INET6:
+               sa6 = (struct sockaddr_in6 *)src;
+               memcpy(&dst->type.in6, &sa6->sin6_addr,
+                      sizeof(struct in6_addr));
+#ifdef ISC_PLATFORM_HAVESCOPEID
+               if (sa6->sin6_scope_id != 0)
+                       isc_netaddr_setzone(dst, sa6->sin6_scope_id);
+               else {
+                       /*
+                        * BSD variants embed scope zone IDs in the 128bit
+                        * address as a kernel internal form.  Unfortunately,
+                        * the embedded IDs are not hidden from applications
+                        * when getting access to them by sysctl or ioctl.
+                        * We convert the internal format to the pure address
+                        * part and the zone ID part.
+                        * Since multicast addresses should not appear here
+                        * and they cannot be distinguished from netmasks,
+                        * we only consider unicast link-local addresses.
+                        */
+                       if (IN6_IS_ADDR_LINKLOCAL(&sa6->sin6_addr)) {
+                               isc_uint16_t zone16;
+
+                               memcpy(&zone16, &sa6->sin6_addr.s6_addr[2],
+                                      sizeof(zone16));
+                               zone16 = ntohs(zone16);
+                               if (zone16 != 0) {
+                                       /* the zone ID is embedded */
+                                       isc_netaddr_setzone(dst,
+                                                           (isc_uint32_t)zone16);
+                                       dst->type.in6.s6_addr[2] = 0;
+                                       dst->type.in6.s6_addr[3] = 0;
+#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
+                               } else if (ifname != NULL) {
+                                       unsigned int zone;
+
+                                       /*
+                                        * sin6_scope_id is still not provided,
+                                        * but the corresponding interface name
+                                        * is know.  Use the interface ID as
+                                        * the link ID.
+                                        */
+                                       zone = if_nametoindex(ifname);
+                                       if (zone != 0) {
+                                               isc_netaddr_setzone(dst,
+                                                                   (isc_uint32_t)zone);
+                                       }
+#endif
+                               }
+                       }
+               }
+#endif
+               break;
+       default:
+               INSIST(0);
+               break;
+       }
+}
+
+/*
+ * Include system-dependent code.
+ */
+
+#if HAVE_GETIFADDRS
+#include "ifiter_getifaddrs.c"
+#elif HAVE_IFLIST_SYSCTL
+#include "ifiter_sysctl.c"
+#else
+#include "ifiter_ioctl.c"
+#endif
+
+/*
+ * The remaining code is common to the sysctl and ioctl case.
+ */
+
+isc_result_t
+isc_interfaceiter_current(isc_interfaceiter_t *iter,
+                         isc_interface_t *ifdata)
+{
+       REQUIRE(iter->result == ISC_R_SUCCESS);
+       memcpy(ifdata, &iter->current, sizeof(*ifdata));
+       return (ISC_R_SUCCESS);
+}
+
+isc_result_t
+isc_interfaceiter_first(isc_interfaceiter_t *iter) {
+       isc_result_t result;
+
+       REQUIRE(VALID_IFITER(iter));
+
+       internal_first(iter);
+       for (;;) {
+               result = internal_current(iter);
+               if (result != ISC_R_IGNORE)
+                       break;
+               result = internal_next(iter);
+               if (result != ISC_R_SUCCESS)
+                       break;
+       }
+       iter->result = result;
+       return (result);
+}
+
+isc_result_t
+isc_interfaceiter_next(isc_interfaceiter_t *iter) {
+       isc_result_t result;
+
+       REQUIRE(VALID_IFITER(iter));
+       REQUIRE(iter->result == ISC_R_SUCCESS);
+
+       for (;;) {
+               result = internal_next(iter);
+               if (result != ISC_R_SUCCESS)
+                       break;
+               result = internal_current(iter);
+               if (result != ISC_R_IGNORE)
+                       break;
+       }
+       iter->result = result;
+       return (result);
+}
+
+void
+isc_interfaceiter_destroy(isc_interfaceiter_t **iterp)
+{
+       isc_interfaceiter_t *iter;
+       REQUIRE(iterp != NULL);
+       iter = *iterp;
+       REQUIRE(VALID_IFITER(iter));
+
+       internal_destroy(iter);
+       if (iter->buf != NULL)
+               isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
+
+       iter->magic = 0;
+       isc_mem_put(iter->mctx, iter, sizeof(*iter));
+       *iterp = NULL;
+}
diff --git a/libisc/isc_strerror.c b/libisc/isc_strerror.c
new file mode 100644 (file)
index 0000000..9ec4a2f
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: strerror.c,v 1.3 2001/11/20 01:45:45 gson Exp $ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include <isc/mutex.h>
+#include <isc/once.h>
+#include <isc/print.h>
+#include <isc/strerror.h>
+#include <isc/util.h>
+
+#include "l_stdlib.h"
+
+#ifdef HAVE_STRERROR
+/*
+ * We need to do this this way for profiled locks.
+ */
+static isc_mutex_t isc_strerror_lock;
+static void init_lock(void) {
+       RUNTIME_CHECK(isc_mutex_init(&isc_strerror_lock) == ISC_R_SUCCESS);
+}
+#else
+extern const char * const sys_errlist[];
+extern const int sys_nerr;
+#endif
+
+void
+isc__strerror(int num, char *buf, size_t size) {
+#ifdef HAVE_STRERROR
+       char *msg;
+       unsigned int unum = num;
+       static isc_once_t once = ISC_ONCE_INIT;
+
+       REQUIRE(buf != NULL);
+
+       RUNTIME_CHECK(isc_once_do(&once, init_lock) == ISC_R_SUCCESS);
+
+       LOCK(&isc_strerror_lock);
+       msg = strerror(num);
+       if (msg != NULL)
+               snprintf(buf, size, "%s", msg);
+       else
+               snprintf(buf, size, "Unknown error: %u", unum);
+       UNLOCK(&isc_strerror_lock);
+#else
+       unsigned int unum = num;
+
+       REQUIRE(buf != NULL);
+
+       if (num >= 0 && num < sys_nerr)
+               snprintf(buf, size, "%s", sys_errlist[num]);
+       else
+               snprintf(buf, size, "Unknown error: %u", unum);
+#endif
+}
diff --git a/libisc/lib.c b/libisc/lib.c
new file mode 100644 (file)
index 0000000..95dd479
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: lib.c,v 1.9 2001/11/19 03:08:23 mayer Exp $ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#include <isc/once.h>
+#include <isc/msgs.h>
+#include <isc/lib.h>
+
+/***
+ *** Globals
+ ***/
+
+LIBISC_EXTERNAL_DATA isc_msgcat_t *            isc_msgcat = NULL;
+
+
+/***
+ *** Private
+ ***/
+
+static isc_once_t              msgcat_once = ISC_ONCE_INIT;
+
+
+/***
+ *** Functions
+ ***/
+
+static void
+open_msgcat(void) {
+       isc_msgcat_open("libisc.cat", &isc_msgcat);
+}
+
+void
+isc_lib_initmsgcat(void) {
+       isc_result_t result;
+
+       /*
+        * Initialize the ISC library's message catalog, isc_msgcat, if it
+        * has not already been initialized.
+        */
+
+       result = isc_once_do(&msgcat_once, open_msgcat);
+       if (result != ISC_R_SUCCESS) {
+               /*
+                * Normally we'd use RUNTIME_CHECK() or FATAL_ERROR(), but
+                * we can't do that here, since they might call us!
+                * (Note that the catalog might be open anyway, so we might
+                * as well try to  provide an internationalized message.)
+                */
+               fprintf(stderr, "%s:%d: %s: isc_once_do() %s.\n",
+                       __FILE__, __LINE__,
+                       isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
+                                      ISC_MSG_FATALERROR, "fatal error"),
+                       isc_msgcat_get(isc_msgcat, ISC_MSGSET_GENERAL,
+                                      ISC_MSG_FAILED, "failed"));
+               abort();
+       }
+}
diff --git a/libisc/mem.c b/libisc/mem.c
new file mode 100644 (file)
index 0000000..39f1e5c
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 1997-2002  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: mem.c,v 1.113 2002/05/23 04:32:30 marka Exp $ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <stddef.h>
+
+#include <isc/mem.h>
+#include <isc/util.h>
+
+void *
+isc_mem_get(isc_mem_t *ctx, size_t size) {
+       UNUSED(ctx);
+       if(size == 0)
+               size = 1;
+       return (malloc(size));
+}
+
+void
+isc_mem_put(isc_mem_t *ctx, void *ptr, size_t size)
+{
+       UNUSED(ctx);
+       UNUSED(size);
+       free(ptr);
+}
+
diff --git a/libisc/msgcat.c b/libisc/msgcat.c
new file mode 100644 (file)
index 0000000..8253a06
--- /dev/null
@@ -0,0 +1,130 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: msgcat.c,v 1.12 2001/11/30 01:59:39 gson Exp $ */
+
+/*
+ * Principal Author: Bob Halley
+ */
+
+#include <config.h>
+
+#include <stdlib.h>
+#include <unistd.h>
+
+#include <isc/magic.h>
+#include <isc/msgcat.h>
+#include <isc/util.h>
+
+#ifdef HAVE_CATGETS
+#include <nl_types.h>          /* Required for nl_catd. */
+#endif
+
+/*
+ * Implementation Notes:
+ *
+ *     We use malloc() and free() instead of isc_mem_get() and isc_mem_put()
+ *     because we don't want to require a memory context to be specified
+ *     in order to use a message catalog.
+ */
+
+struct isc_msgcat {
+       unsigned int    magic;
+#ifdef HAVE_CATGETS
+       nl_catd         catalog;
+#endif
+};
+
+#define MSGCAT_MAGIC                   ISC_MAGIC('M', 'C', 'a', 't')
+#define VALID_MSGCAT(m)                        ISC_MAGIC_VALID(m, MSGCAT_MAGIC)
+
+void
+isc_msgcat_open(const char *name, isc_msgcat_t **msgcatp) {
+       isc_msgcat_t *msgcat;
+
+       /*
+        * Open a message catalog.
+        */
+
+       REQUIRE(name != NULL);
+       REQUIRE(msgcatp != NULL && *msgcatp == NULL);
+
+       msgcat = malloc(sizeof(*msgcat));
+       if (msgcat == NULL) {
+               *msgcatp = NULL;
+               return;
+       }
+
+#ifdef HAVE_CATGETS
+       /*
+        * We don't check if catopen() fails because we don't care.
+        * If it does fail, then when we call catgets(), it will use
+        * the default string.
+        */
+       msgcat->catalog = catopen(name, 0);
+#endif
+       msgcat->magic = MSGCAT_MAGIC;
+
+       *msgcatp = msgcat;
+}
+
+void
+isc_msgcat_close(isc_msgcat_t **msgcatp) {
+       isc_msgcat_t *msgcat;
+
+       /*
+        * Close a message catalog.
+        */
+
+       REQUIRE(msgcatp != NULL);
+       msgcat = *msgcatp;
+       REQUIRE(VALID_MSGCAT(msgcat) || msgcat == NULL);
+
+       if (msgcat != NULL) {
+#ifdef HAVE_CATGETS
+               if (msgcat->catalog != (nl_catd)(-1))
+                       (void)catclose(msgcat->catalog);
+#endif
+               msgcat->magic = 0;
+               free(msgcat);
+       }
+
+       *msgcatp = NULL;
+}
+
+const char *
+isc_msgcat_get(isc_msgcat_t *msgcat, int set, int message,
+              const char *default_text)
+{
+       /*
+        * Get message 'message' from message set 'set' in 'msgcat'.  If it
+        * is not available, use 'default'.
+        */
+
+       REQUIRE(VALID_MSGCAT(msgcat) || msgcat == NULL);
+       REQUIRE(set > 0);
+       REQUIRE(message > 0);
+       REQUIRE(default_text != NULL);
+
+#ifdef HAVE_CATGETS
+       if (msgcat == NULL)
+               return (default_text);
+       return (catgets(msgcat->catalog, set, message, default_text));
+#else
+       return (default_text);
+#endif
+}
diff --git a/libisc/net.c b/libisc/net.c
new file mode 100644 (file)
index 0000000..3d4ab66
--- /dev/null
@@ -0,0 +1,311 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: net.c,v 1.22.2.2.10.7 2004/04/29 01:31:22 marka Exp $ */
+
+#include <config.h>
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <isc/net.h>
+#include <isc/once.h>
+#include <isc/strerror.h>
+#include <isc/string.h>
+#include <isc/util.h>
+
+#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRANY)
+const struct in6_addr isc_net_in6addrany = IN6ADDR_ANY_INIT;
+#endif
+
+#if defined(ISC_PLATFORM_HAVEIPV6) && defined(ISC_PLATFORM_NEEDIN6ADDRLOOPBACK)
+const struct in6_addr isc_net_in6addrloop = IN6ADDR_LOOPBACK_INIT;
+#endif
+
+static isc_boolean_t   once = ISC_FALSE;
+static isc_once_t      once_ipv6only = ISC_ONCE_INIT;
+static isc_once_t      once_ipv6pktinfo = ISC_ONCE_INIT;
+static isc_result_t    ipv4_result = ISC_R_NOTFOUND;
+static isc_result_t    ipv6_result = ISC_R_NOTFOUND;
+static isc_result_t    ipv6only_result = ISC_R_NOTFOUND;
+static isc_result_t    ipv6pktinfo_result = ISC_R_NOTFOUND;
+
+static isc_result_t
+try_proto(int domain) {
+       int s;
+       isc_result_t result = ISC_R_SUCCESS;
+       char strbuf[ISC_STRERRORSIZE];
+
+       s = socket(domain, SOCK_STREAM, 0);
+       if (s == -1) {
+               switch (errno) {
+#ifdef EAFNOSUPPORT
+               case EAFNOSUPPORT:
+#endif
+#ifdef EPROTONOSUPPORT
+               case EPROTONOSUPPORT:
+#endif
+#ifdef EINVAL
+               case EINVAL:
+#endif
+                       return (ISC_R_NOTFOUND);
+               default:
+                       isc__strerror(errno, strbuf, sizeof(strbuf));
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                        "socket() failed: %s",
+                                        strbuf);
+                       return (ISC_R_UNEXPECTED);
+               }
+       }
+
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifdef WANT_IPV6
+#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
+       if (domain == PF_INET6) {
+               struct sockaddr_in6 sin6;
+               GETSOCKNAME_SOCKLEN_TYPE len;
+
+               /*
+                * Check to see if IPv6 is broken, as is common on Linux.
+                */
+               len = sizeof(sin6);
+               if (getsockname(s, (struct sockaddr *)&sin6, &len) < 0)
+               {
+                       result = ISC_R_NOTFOUND;
+               } else {
+                       if (len == sizeof(struct sockaddr_in6))
+                               result = ISC_R_SUCCESS;
+                       else {
+                               result = ISC_R_NOTFOUND;
+                       }
+               }
+       }
+#endif
+#endif
+#endif
+
+       (void)close(s);
+
+       return (result);
+}
+
+static void
+initialize_action(void) {
+       ipv4_result = try_proto(PF_INET);
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifdef WANT_IPV6
+#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
+       ipv6_result = try_proto(PF_INET6);
+#endif
+#endif
+#endif
+}
+
+static void
+initialize(void) {
+       if(once == ISC_FALSE) {
+               initialize_action();
+               once = ISC_TRUE;
+       }
+}
+
+isc_result_t
+isc_net_probeipv4(void) {
+       initialize();
+       return (ipv4_result);
+}
+
+isc_result_t
+isc_net_probeipv6(void) {
+       initialize();
+       return (ipv6_result);
+}
+
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifdef WANT_IPV6
+static void
+try_ipv6only(void) {
+#ifdef IPV6_V6ONLY
+       int s, on;
+       char strbuf[ISC_STRERRORSIZE];
+#endif
+       isc_result_t result;
+
+       result = isc_net_probeipv6();
+       if (result != ISC_R_SUCCESS) {
+               ipv6only_result = result;
+               return;
+       }
+
+#ifndef IPV6_V6ONLY
+       ipv6only_result = ISC_R_NOTFOUND;
+       return;
+#else
+       /* check for TCP sockets */
+       s = socket(PF_INET6, SOCK_STREAM, 0);
+       if (s == -1) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "socket() failed: %s",
+                                strbuf);
+               ipv6only_result = ISC_R_UNEXPECTED;
+               return;
+       }
+
+       on = 1;
+       if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) {
+               ipv6only_result = ISC_R_NOTFOUND;
+               goto close;
+       }
+
+       close(s);
+
+       /* check for UDP sockets */
+       s = socket(PF_INET6, SOCK_DGRAM, 0);
+       if (s == -1) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "socket() failed: %s",
+                                strbuf);
+               ipv6only_result = ISC_R_UNEXPECTED;
+               return;
+       }
+
+       on = 1;
+       if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) {
+               ipv6only_result = ISC_R_NOTFOUND;
+               goto close;
+       }
+
+       close(s);
+
+       ipv6only_result = ISC_R_SUCCESS;
+
+close:
+       close(s);
+       return;
+#endif /* IPV6_V6ONLY */
+}
+
+static void
+initialize_ipv6only(void) {
+       RUNTIME_CHECK(isc_once_do(&once_ipv6only,
+                                 try_ipv6only) == ISC_R_SUCCESS);
+}
+
+static void
+try_ipv6pktinfo(void) {
+       int s, on;
+       char strbuf[ISC_STRERRORSIZE];
+       isc_result_t result;
+       int optname;
+
+       result = isc_net_probeipv6();
+       if (result != ISC_R_SUCCESS) {
+               ipv6pktinfo_result = result;
+               return;
+       }
+
+       /* we only use this for UDP sockets */
+       s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+       if (s == -1) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "socket() failed: %s",
+                                strbuf);
+               ipv6pktinfo_result = ISC_R_UNEXPECTED;
+               return;
+       }
+
+#ifdef IPV6_RECVPKTINFO
+       optname = IPV6_RECVPKTINFO;
+#else
+       optname = IPV6_PKTINFO;
+#endif
+       on = 1;
+       if (setsockopt(s, IPPROTO_IPV6, optname, &on, sizeof(on)) < 0) {
+               ipv6pktinfo_result = ISC_R_NOTFOUND;
+               goto close;
+       }
+
+       close(s);
+       ipv6pktinfo_result = ISC_R_SUCCESS;
+
+close:
+       close(s);
+       return;
+}
+
+static void
+initialize_ipv6pktinfo(void) {
+       RUNTIME_CHECK(isc_once_do(&once_ipv6pktinfo,
+                                 try_ipv6pktinfo) == ISC_R_SUCCESS);
+}
+#endif /* WANT_IPV6 */
+#endif /* ISC_PLATFORM_HAVEIPV6 */
+
+isc_result_t
+isc_net_probe_ipv6only(void) {
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifdef WANT_IPV6
+       initialize_ipv6only();
+#else
+       ipv6only_result = ISC_R_NOTFOUND;
+#endif
+#endif
+       return (ipv6only_result);
+}
+
+isc_result_t
+isc_net_probe_ipv6pktinfo(void) {
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifdef WANT_IPV6
+       initialize_ipv6pktinfo();
+#else
+       ipv6pktinfo_result = ISC_R_NOTFOUND;
+#endif
+#endif
+       return (ipv6pktinfo_result);
+}
+
+void
+isc_net_disableipv4(void) {
+       initialize();
+       if (ipv4_result == ISC_R_SUCCESS)
+               ipv4_result = ISC_R_DISABLED;
+}
+
+void
+isc_net_disableipv6(void) {
+       initialize();
+       if (ipv6_result == ISC_R_SUCCESS)
+               ipv6_result = ISC_R_DISABLED;
+}
+
+void
+isc_net_enableipv4(void) {
+       initialize();
+       if (ipv4_result == ISC_R_DISABLED)
+               ipv4_result = ISC_R_SUCCESS;
+}
+
+void
+isc_net_enableipv6(void) {
+       initialize();
+       if (ipv6_result == ISC_R_DISABLED)
+               ipv6_result = ISC_R_SUCCESS;
+}
diff --git a/libisc/netaddr.c b/libisc/netaddr.c
new file mode 100644 (file)
index 0000000..1fcd102
--- /dev/null
@@ -0,0 +1,363 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2002  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: netaddr.c,v 1.18.12.9 2004/05/15 03:46:12 jinmei Exp $ */
+
+#include <config.h>
+
+#define ISC_ONLY_IPV6
+
+#include <stdio.h>
+
+#include <isc/buffer.h>
+#include <isc/msgs.h>
+#include <isc/net.h>
+#include <isc/netaddr.h>
+#include <isc/print.h>
+#include <isc/sockaddr.h>
+#include <isc/string.h>
+#include <isc/util.h>
+
+isc_boolean_t
+isc_netaddr_equal(const isc_netaddr_t *a, const isc_netaddr_t *b) {
+       REQUIRE(a != NULL && b != NULL);
+
+       if (a->family != b->family)
+               return (ISC_FALSE);
+
+       if (a->zone != b->zone)
+               return (ISC_FALSE);
+
+       switch (a->family) {
+       case AF_INET:
+               if (a->type.in.s_addr != b->type.in.s_addr)
+                       return (ISC_FALSE);
+               break;
+       case AF_INET6:
+               if (memcmp(&a->type.in6, &b->type.in6,
+                          sizeof(a->type.in6)) != 0 ||
+                   a->zone != b->zone)
+                       return (ISC_FALSE);
+               break;
+       default:
+               return (ISC_FALSE);
+       }
+       return (ISC_TRUE);
+}
+
+isc_boolean_t
+isc_netaddr_eqprefix(const isc_netaddr_t *a, const isc_netaddr_t *b,
+                    unsigned int prefixlen)
+{
+       const unsigned char *pa, *pb;
+       unsigned int ipabytes; /* Length of whole IP address in bytes */
+       unsigned int nbytes;   /* Number of significant whole bytes */
+       unsigned int nbits;    /* Number of significant leftover bits */
+
+       REQUIRE(a != NULL && b != NULL);
+
+       if (a->family != b->family)
+               return (ISC_FALSE);
+
+       if (a->zone != b->zone)
+               return (ISC_FALSE);
+
+       switch (a->family) {
+       case AF_INET:
+               pa = (const unsigned char *) &a->type.in;
+               pb = (const unsigned char *) &b->type.in;
+               ipabytes = 4;
+               break;
+       case AF_INET6:
+               pa = (const unsigned char *) &a->type.in6;
+               pb = (const unsigned char *) &b->type.in6;
+               ipabytes = 16;
+               break;
+       default:
+               pa = pb = NULL; /* Avoid silly compiler warning. */
+               ipabytes = 0; /* Ditto. */
+               return (ISC_FALSE);
+       }
+
+       /*
+        * Don't crash if we get a pattern like 10.0.0.1/9999999.
+        */
+       if (prefixlen > ipabytes * 8)
+               prefixlen = ipabytes * 8;
+
+       nbytes = prefixlen / 8;
+       nbits = prefixlen % 8;
+
+       if (nbytes > 0) {
+               if (memcmp(pa, pb, nbytes) != 0)
+                       return (ISC_FALSE);
+       }
+       if (nbits > 0) {
+               unsigned int bytea, byteb, mask;
+               INSIST(nbytes < ipabytes);
+               INSIST(nbits < 8);
+               bytea = pa[nbytes];
+               byteb = pb[nbytes];
+               mask = (0xFF << (8-nbits)) & 0xFF;
+               if ((bytea & mask) != (byteb & mask))
+                       return (ISC_FALSE);
+       }
+       return (ISC_TRUE);
+}
+
+isc_result_t
+isc_netaddr_totext(const isc_netaddr_t *netaddr, isc_buffer_t *target) {
+       char abuf[sizeof("xxxx:xxxx:xxxx:xxxx:xxxx:xxxx:255.255.255.255")];
+       char zbuf[sizeof("%4294967295")];
+       unsigned int alen;
+       int zlen;
+       const char *r;
+       const void *type;
+
+       REQUIRE(netaddr != NULL);
+
+       switch (netaddr->family) {
+       case AF_INET:
+               type = &netaddr->type.in;
+               break;
+       case AF_INET6:
+               type = &netaddr->type.in6;
+               break;
+       default:
+               return (ISC_R_FAILURE);
+       }
+       r = inet_ntop(netaddr->family, type, abuf, sizeof(abuf));
+       if (r == NULL)
+               return (ISC_R_FAILURE);
+
+       alen = strlen(abuf);
+       INSIST(alen < sizeof(abuf));
+
+       zlen = 0;
+       if (netaddr->family == AF_INET6 && netaddr->zone != 0) {
+               zlen = snprintf(zbuf, sizeof(zbuf), "%%%u", netaddr->zone);
+               if (zlen < 0)
+                       return (ISC_R_FAILURE);
+               INSIST((unsigned int)zlen < sizeof(zbuf));
+       }
+
+       if (alen + zlen > isc_buffer_availablelength(target))
+               return (ISC_R_NOSPACE);
+
+       isc_buffer_putmem(target, (unsigned char *)abuf, alen);
+       isc_buffer_putmem(target, (unsigned char *)zbuf, zlen);
+
+       return (ISC_R_SUCCESS);
+}
+
+void
+isc_netaddr_format(const isc_netaddr_t *na, char *array, unsigned int size) {
+       isc_result_t result;
+       isc_buffer_t buf;
+
+       isc_buffer_init(&buf, array, size);
+       result = isc_netaddr_totext(na, &buf);
+
+       /*
+        * Null terminate.
+        */
+       if (result == ISC_R_SUCCESS) {
+               if (isc_buffer_availablelength(&buf) >= 1)
+                       isc_buffer_putuint8(&buf, 0);
+               else
+                       result = ISC_R_NOSPACE;
+       }
+
+       if (result != ISC_R_SUCCESS) {
+               snprintf(array, size,
+                        isc_msgcat_get(isc_msgcat, ISC_MSGSET_NETADDR,
+                                       ISC_MSG_UNKNOWNADDR,
+                                       "<unknown address, family %u>"),
+                        na->family);
+               array[size - 1] = '\0';
+       }
+}
+
+isc_result_t
+isc_netaddr_masktoprefixlen(const isc_netaddr_t *s, unsigned int *lenp) {
+       unsigned int nbits, nbytes, ipbytes, i;
+       const unsigned char *p;
+
+       switch (s->family) {
+       case AF_INET:
+               p = (const unsigned char *) &s->type.in;
+               ipbytes = 4;
+               break;
+       case AF_INET6:
+               p = (const unsigned char *) &s->type.in6;
+               ipbytes = 16;
+               break;
+       default:
+               ipbytes = 0;
+               return (ISC_R_NOTIMPLEMENTED);
+       }
+       nbytes = nbits = 0;
+       for (i = 0; i < ipbytes; i++) {
+               if (p[i] != 0xFF)
+                       break;
+       }
+       nbytes = i;
+       if (i < ipbytes) {
+               unsigned int c = p[nbytes];
+               while ((c & 0x80) != 0 && nbits < 8) {
+                       c <<= 1; nbits++;
+               }
+               if ((c & 0xFF) != 0)
+                       return (ISC_R_MASKNONCONTIG);
+               i++;
+       }
+       for (; i < ipbytes; i++) {
+               if (p[i] != 0)
+                       return (ISC_R_MASKNONCONTIG);
+               i++;
+       }
+       *lenp = nbytes * 8 + nbits;
+       return (ISC_R_SUCCESS);
+}
+
+void
+isc_netaddr_fromin(isc_netaddr_t *netaddr, const struct in_addr *ina) {
+       memset(netaddr, 0, sizeof(*netaddr));
+       netaddr->family = AF_INET;
+       netaddr->type.in = *ina;
+}
+
+void
+isc_netaddr_fromin6(isc_netaddr_t *netaddr, const struct in6_addr *ina6) {
+       memset(netaddr, 0, sizeof(*netaddr));
+       netaddr->family = AF_INET6;
+       netaddr->type.in6 = *ina6;
+}
+
+void
+isc_netaddr_setzone(isc_netaddr_t *netaddr, isc_uint32_t zone) {
+       /* we currently only support AF_INET6. */
+       REQUIRE(netaddr->family == AF_INET6);
+
+       netaddr->zone = zone;
+}
+
+isc_uint32_t
+isc_netaddr_getzone(const isc_netaddr_t *netaddr) {
+       return (netaddr->zone);
+}
+
+void
+isc_netaddr_fromsockaddr(isc_netaddr_t *t, const isc_sockaddr_t *s) {
+       int family = s->type.sa.sa_family;
+       t->family = family;
+       switch (family) {
+       case AF_INET:
+               t->type.in = s->type.sin.sin_addr;
+               t->zone = 0;
+               break;
+       case AF_INET6:
+               memcpy(&t->type.in6, &s->type.sin6.sin6_addr, 16);
+#ifdef ISC_PLATFORM_HAVESCOPEID
+               t->zone = s->type.sin6.sin6_scope_id;
+#else
+               t->zone = 0;
+#endif
+               break;
+       default:
+               INSIST(0);
+       }
+}
+
+void
+isc_netaddr_any(isc_netaddr_t *netaddr) {
+       memset(netaddr, 0, sizeof(*netaddr));
+       netaddr->family = AF_INET;
+       netaddr->type.in.s_addr = INADDR_ANY;
+}
+
+#ifdef ISC_PLATFORM_HAVEIPV6
+void
+isc_netaddr_any6(isc_netaddr_t *netaddr) {
+       memset(netaddr, 0, sizeof(*netaddr));
+       netaddr->family = AF_INET6;
+       netaddr->type.in6 = in6addr_any;
+}
+#endif
+
+isc_boolean_t
+isc_netaddr_ismulticast(isc_netaddr_t *na) {
+       switch (na->family) {
+       case AF_INET:
+               return (ISC_TF(ISC_IPADDR_ISMULTICAST(na->type.in.s_addr)));
+       case AF_INET6:
+               return (ISC_TF(IN6_IS_ADDR_MULTICAST(&na->type.in6)));
+       default:
+               return (ISC_FALSE);  /* XXXMLG ? */
+       }
+}
+
+isc_boolean_t
+isc_netaddr_isexperimental(isc_netaddr_t *na) {
+       switch (na->family) {
+       case AF_INET:
+               return (ISC_TF(ISC_IPADDR_ISEXPERIMENTAL(na->type.in.s_addr)));
+       default:
+               return (ISC_FALSE);  /* XXXMLG ? */
+       }
+}
+
+isc_boolean_t
+isc_netaddr_islinklocal(isc_netaddr_t *na) {
+       switch (na->family) {
+       case AF_INET:
+               return (ISC_FALSE);
+       case AF_INET6:
+               return (ISC_TF(IN6_IS_ADDR_LINKLOCAL(&na->type.in6)));
+       default:
+               return (ISC_FALSE);
+       }
+}
+
+isc_boolean_t
+isc_netaddr_issitelocal(isc_netaddr_t *na) {
+       switch (na->family) {
+       case AF_INET:
+               return (ISC_FALSE);
+       case AF_INET6:
+               return (ISC_TF(IN6_IS_ADDR_SITELOCAL(&na->type.in6)));
+       default:
+               return (ISC_FALSE);
+       }
+}
+
+#ifdef ISC_PLATFORM_HAVEIPV6
+void
+isc_netaddr_fromv4mapped(isc_netaddr_t *t, const isc_netaddr_t *s) {
+       isc_netaddr_t *src;
+
+       DE_CONST(s, src);       /* Must come before IN6_IS_ADDR_V4MAPPED. */
+
+       REQUIRE(s->family == AF_INET6);
+       REQUIRE(IN6_IS_ADDR_V4MAPPED(&src->type.in6));
+
+       memset(t, 0, sizeof(*t));
+       t->family = AF_INET;
+       memcpy(&t->type.in, (char *)&src->type.in6 + 12, 4);
+       return;
+}
+#endif
diff --git a/libisc/netscope.c b/libisc/netscope.c
new file mode 100644 (file)
index 0000000..f0bffc4
--- /dev/null
@@ -0,0 +1,74 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2002  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static char rcsid[] =
+       "$Id: netscope.c,v 1.5.142.7 2004/03/12 10:31:26 marka Exp $";
+#endif /* LIBC_SCCS and not lint */
+
+#include <config.h>
+
+#include <isc/string.h>
+#include <isc/net.h>
+#include <isc/netscope.h>
+#include <isc/result.h>
+
+isc_result_t
+isc_netscope_pton(int af, char *scopename, void *addr, isc_uint32_t *zoneid) {
+       char *ep;
+#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
+       unsigned int ifid;
+#endif
+       struct in6_addr *in6;
+       isc_uint32_t zone;
+       isc_uint64_t llz;
+
+       /* at this moment, we only support AF_INET6 */
+       if (af != AF_INET6)
+               return (ISC_R_FAILURE);
+
+       in6 = (struct in6_addr *)addr;
+
+       /*
+        * Basically, "names" are more stable than numeric IDs in terms of
+        * renumbering, and are more preferred.  However, since there is no
+        * standard naming convention and APIs to deal with the names.  Thus,
+        * we only handle the case of link-local addresses, for which we use
+        * interface names as link names, assuming one to one mapping between
+        * interfaces and links.
+        */
+#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
+       if (IN6_IS_ADDR_LINKLOCAL(in6) &&
+           (ifid = if_nametoindex((const char *)scopename)) != 0)
+               zone = (isc_uint32_t)ifid;
+       else {
+#endif
+               llz = isc_string_touint64(scopename, &ep, 10);
+               if (ep == scopename)
+                       return (ISC_R_FAILURE);
+
+               /* check overflow */
+               zone = (isc_uint32_t)(llz & 0xffffffffUL);
+               if (zone != llz)
+                       return (ISC_R_FAILURE);
+#ifdef ISC_PLATFORM_HAVEIFNAMETOINDEX
+       }
+#endif
+
+       *zoneid = zone;
+       return (ISC_R_SUCCESS);
+}
diff --git a/libisc/sockaddr.c b/libisc/sockaddr.c
new file mode 100644 (file)
index 0000000..33d7a1b
--- /dev/null
@@ -0,0 +1,480 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: sockaddr.c,v 1.48.2.1.2.10 2004/05/15 03:46:12 jinmei Exp $ */
+
+#include <config.h>
+
+#define ISC_ONLY_IPV6
+
+#include <stdio.h>
+
+#include <isc/buffer.h>
+/*
+ * We currently don't need hashing here
+ */
+#if 0
+#include <isc/hash.h>
+#endif
+
+#include <isc/msgs.h>
+#include <isc/netaddr.h>
+#include <isc/print.h>
+#include <isc/region.h>
+#include <isc/sockaddr.h>
+#include <isc/string.h>
+#include <isc/util.h>
+
+isc_boolean_t
+isc_sockaddr_equal(const isc_sockaddr_t *a, const isc_sockaddr_t *b) {
+       REQUIRE(a != NULL && b != NULL);
+
+       if (a->length != b->length)
+               return (ISC_FALSE);
+
+       /*
+        * We don't just memcmp because the sin_zero field isn't always
+        * zero.
+        */
+
+       if (a->type.sa.sa_family != b->type.sa.sa_family)
+               return (ISC_FALSE);
+       switch (a->type.sa.sa_family) {
+       case AF_INET:
+               if (memcmp(&a->type.sin.sin_addr, &b->type.sin.sin_addr,
+                          sizeof(a->type.sin.sin_addr)) != 0)
+                       return (ISC_FALSE);
+               if (a->type.sin.sin_port != b->type.sin.sin_port)
+                       return (ISC_FALSE);
+               break;
+       case AF_INET6:
+               if (memcmp(&a->type.sin6.sin6_addr, &b->type.sin6.sin6_addr,
+                          sizeof(a->type.sin6.sin6_addr)) != 0)
+                       return (ISC_FALSE);
+#ifdef ISC_PLATFORM_HAVESCOPEID
+               if (a->type.sin6.sin6_scope_id != b->type.sin6.sin6_scope_id)
+                       return (ISC_FALSE);
+#endif
+               if (a->type.sin6.sin6_port != b->type.sin6.sin6_port)
+                       return (ISC_FALSE);
+               break;
+       default:
+               if (memcmp(&a->type, &b->type, a->length) != 0)
+                       return (ISC_FALSE);
+       }
+       return (ISC_TRUE);
+}
+
+isc_boolean_t
+isc_sockaddr_eqaddr(const isc_sockaddr_t *a, const isc_sockaddr_t *b) {
+       REQUIRE(a != NULL && b != NULL);
+
+       if (a->length != b->length)
+               return (ISC_FALSE);
+
+       if (a->type.sa.sa_family != b->type.sa.sa_family)
+               return (ISC_FALSE);
+       switch (a->type.sa.sa_family) {
+       case AF_INET:
+               if (memcmp(&a->type.sin.sin_addr, &b->type.sin.sin_addr,
+                          sizeof(a->type.sin.sin_addr)) != 0)
+                       return (ISC_FALSE);
+               break;
+       case AF_INET6:
+               if (memcmp(&a->type.sin6.sin6_addr, &b->type.sin6.sin6_addr,
+                          sizeof(a->type.sin6.sin6_addr)) != 0)
+                       return (ISC_FALSE);
+#ifdef ISC_PLATFORM_HAVESCOPEID
+               if (a->type.sin6.sin6_scope_id != b->type.sin6.sin6_scope_id)
+                       return (ISC_FALSE);
+#endif
+               break;
+       default:
+               if (memcmp(&a->type, &b->type, a->length) != 0)
+                       return (ISC_FALSE);
+       }
+       return (ISC_TRUE);
+}
+
+isc_boolean_t
+isc_sockaddr_eqaddrprefix(const isc_sockaddr_t *a, const isc_sockaddr_t *b,
+                         unsigned int prefixlen)
+{
+       isc_netaddr_t na, nb;
+       isc_netaddr_fromsockaddr(&na, a);
+       isc_netaddr_fromsockaddr(&nb, b);
+       return (isc_netaddr_eqprefix(&na, &nb, prefixlen));
+}
+
+isc_result_t
+isc_sockaddr_totext(const isc_sockaddr_t *sockaddr, isc_buffer_t *target) {
+       isc_result_t result;
+       isc_netaddr_t netaddr;
+       char pbuf[sizeof("65000")];
+       unsigned int plen;
+       isc_region_t avail;
+
+       REQUIRE(sockaddr != NULL);
+
+       /*
+        * Do the port first, giving us the opportunity to check for
+        * unsupported address families before calling
+        * isc_netaddr_fromsockaddr().
+        */
+       switch (sockaddr->type.sa.sa_family) {
+       case AF_INET:
+               snprintf(pbuf, sizeof(pbuf), "%u", ntohs(sockaddr->type.sin.sin_port));
+               break;
+       case AF_INET6:
+               snprintf(pbuf, sizeof(pbuf), "%u", ntohs(sockaddr->type.sin6.sin6_port));
+               break;
+       default:
+               return (ISC_R_FAILURE);
+       }
+
+       plen = strlen(pbuf);
+       INSIST(plen < sizeof(pbuf));
+
+       isc_netaddr_fromsockaddr(&netaddr, sockaddr);
+       result = isc_netaddr_totext(&netaddr, target);
+       if (result != ISC_R_SUCCESS)
+               return (result);
+
+       if (1 + plen + 1 > isc_buffer_availablelength(target))
+               return (ISC_R_NOSPACE);
+
+       isc_buffer_putmem(target, (const unsigned char *)"#", 1);
+       isc_buffer_putmem(target, (const unsigned char *)pbuf, plen);
+
+       /*
+        * Null terminate after used region.
+        */
+       isc_buffer_availableregion(target, &avail);
+       INSIST(avail.length >= 1);
+       avail.base[0] = '\0';
+
+       return (ISC_R_SUCCESS);
+}
+
+void
+isc_sockaddr_format(const isc_sockaddr_t *sa, char *array, unsigned int size) {
+       isc_result_t result;
+       isc_buffer_t buf;
+
+       isc_buffer_init(&buf, array, size);
+       result = isc_sockaddr_totext(sa, &buf);
+       if (result != ISC_R_SUCCESS) {
+               /*
+                * The message is the same as in netaddr.c.
+                */
+               snprintf(array, size,
+                        isc_msgcat_get(isc_msgcat, ISC_MSGSET_NETADDR,
+                                       ISC_MSG_UNKNOWNADDR,
+                                       "<unknown address, family %u>"),
+                        sa->type.sa.sa_family);
+               array[size - 1] = '\0';
+       }
+}
+
+#if 0
+/*
+ * We currently don't need hashing here
+ */
+unsigned int
+isc_sockaddr_hash(const isc_sockaddr_t *sockaddr, isc_boolean_t address_only) {
+       unsigned int length = 0;
+       const unsigned char *s = NULL;
+       unsigned int h = 0;
+       unsigned int g;
+       unsigned int p = 0;
+       const struct in6_addr *in6;
+
+       REQUIRE(sockaddr != NULL);
+
+       switch (sockaddr->type.sa.sa_family) {
+       case AF_INET:
+               s = (const unsigned char *)&sockaddr->type.sin.sin_addr;
+               p = ntohs(sockaddr->type.sin.sin_port);
+               length = sizeof(sockaddr->type.sin.sin_addr.s_addr);
+               break;
+#if ISC_PLATFORM_HAVEIPV6
+       case AF_INET6:
+               in6 = &sockaddr->type.sin6.sin6_addr;
+               if (IN6_IS_ADDR_V4MAPPED(in6)) {
+                       s = (const unsigned char *)&in6[12];
+                       length = sizeof(sockaddr->type.sin.sin_addr.s_addr);
+               } else {
+                       s = (const unsigned char *)in6;
+                       length = sizeof(sockaddr->type.sin6.sin6_addr);
+               }
+               p = ntohs(sockaddr->type.sin6.sin6_port);
+               break;
+#endif
+       default:
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                isc_msgcat_get(isc_msgcat,
+                                               ISC_MSGSET_SOCKADDR,
+                                               ISC_MSG_UNKNOWNFAMILY,
+                                               "unknown address family: %d"),
+                                            (int)sockaddr->type.sa.sa_family);
+               s = (const unsigned char *)&sockaddr->type;
+               length = sockaddr->length;
+               p = 0;
+       }
+
+       h = isc_hash_calc(s, length, ISC_TRUE);
+       if (!address_only) {
+               g = isc_hash_calc((const unsigned char *)&p, sizeof(p),
+                                 ISC_TRUE);
+               h = h ^ g; /* XXX: we should concatenate h and p first */
+       }
+
+       return (h);
+}
+#endif
+
+void
+isc_sockaddr_any(isc_sockaddr_t *sockaddr)
+{
+       memset(sockaddr, 0, sizeof(*sockaddr));
+       sockaddr->type.sin.sin_family = AF_INET;
+#ifdef ISC_PLATFORM_HAVESALEN
+       sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
+#endif
+       sockaddr->type.sin.sin_addr.s_addr = INADDR_ANY;
+       sockaddr->type.sin.sin_port = 0;
+       sockaddr->length = sizeof(sockaddr->type.sin);
+       ISC_LINK_INIT(sockaddr, link);
+}
+
+void
+isc_sockaddr_any6(isc_sockaddr_t *sockaddr)
+{
+#ifdef ISC_PLATFORM_HAVEIPV6
+       memset(sockaddr, 0, sizeof(*sockaddr));
+       sockaddr->type.sin6.sin6_family = AF_INET6;
+#ifdef ISC_PLATFORM_HAVESALEN
+       sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
+#endif
+       sockaddr->type.sin6.sin6_addr = in6addr_any;
+       sockaddr->type.sin6.sin6_port = 0;
+       sockaddr->length = sizeof(sockaddr->type.sin6);
+       ISC_LINK_INIT(sockaddr, link);
+#endif
+}
+
+void
+isc_sockaddr_fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
+                   in_port_t port)
+{
+       memset(sockaddr, 0, sizeof(*sockaddr));
+       sockaddr->type.sin.sin_family = AF_INET;
+#ifdef ISC_PLATFORM_HAVESALEN
+       sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
+#endif
+       sockaddr->type.sin.sin_addr = *ina;
+       sockaddr->type.sin.sin_port = htons(port);
+       sockaddr->length = sizeof(sockaddr->type.sin);
+       ISC_LINK_INIT(sockaddr, link);
+}
+
+void
+isc_sockaddr_anyofpf(isc_sockaddr_t *sockaddr, int pf) {
+     switch (pf) {
+     case AF_INET:
+            isc_sockaddr_any(sockaddr);
+            break;
+     case AF_INET6:
+            isc_sockaddr_any6(sockaddr);
+            break;
+     default:
+            INSIST(0);
+     }
+}
+
+void
+isc_sockaddr_fromin6(isc_sockaddr_t *sockaddr, const struct in6_addr *ina6,
+                    in_port_t port)
+{
+       memset(sockaddr, 0, sizeof(*sockaddr));
+       sockaddr->type.sin6.sin6_family = AF_INET6;
+#ifdef ISC_PLATFORM_HAVESALEN
+       sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
+#endif
+       sockaddr->type.sin6.sin6_addr = *ina6;
+       sockaddr->type.sin6.sin6_port = htons(port);
+       sockaddr->length = sizeof(sockaddr->type.sin6);
+       ISC_LINK_INIT(sockaddr, link);
+}
+
+void
+isc_sockaddr_v6fromin(isc_sockaddr_t *sockaddr, const struct in_addr *ina,
+                     in_port_t port)
+{
+       memset(sockaddr, 0, sizeof(*sockaddr));
+       sockaddr->type.sin6.sin6_family = AF_INET6;
+#ifdef ISC_PLATFORM_HAVESALEN
+       sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
+#endif
+       sockaddr->type.sin6.sin6_addr.s6_addr[10] = 0xff;
+       sockaddr->type.sin6.sin6_addr.s6_addr[11] = 0xff;
+       memcpy(&sockaddr->type.sin6.sin6_addr.s6_addr[12], ina, 4);
+       sockaddr->type.sin6.sin6_port = htons(port);
+       sockaddr->length = sizeof(sockaddr->type.sin6);
+       ISC_LINK_INIT(sockaddr, link);
+}
+
+int
+isc_sockaddr_pf(const isc_sockaddr_t *sockaddr) {
+
+       /*
+        * Get the protocol family of 'sockaddr'.
+        */
+
+#if (AF_INET == PF_INET && AF_INET6 == PF_INET6)
+       /*
+        * Assume that PF_xxx == AF_xxx for all AF and PF.
+        */
+       return (sockaddr->type.sa.sa_family);
+#else
+       switch (sockaddr->type.sa.sa_family) {
+       case AF_INET:
+               return (PF_INET);
+       case AF_INET6:
+               return (PF_INET6);
+       default:
+               FATAL_ERROR(__FILE__, __LINE__,
+                           isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKADDR,
+                                          ISC_MSG_UNKNOWNFAMILY,
+                                          "unknown address family: %d"),
+                           (int)sockaddr->type.sa.sa_family);
+       }
+#endif
+}
+
+void
+isc_sockaddr_fromnetaddr(isc_sockaddr_t *sockaddr, const isc_netaddr_t *na,
+                   in_port_t port)
+{
+       memset(sockaddr, 0, sizeof(*sockaddr));
+       sockaddr->type.sin.sin_family = na->family;
+       switch (na->family) {
+       case AF_INET:
+               sockaddr->length = sizeof(sockaddr->type.sin);
+#ifdef ISC_PLATFORM_HAVESALEN
+               sockaddr->type.sin.sin_len = sizeof(sockaddr->type.sin);
+#endif
+               sockaddr->type.sin.sin_addr = na->type.in;
+               sockaddr->type.sin.sin_port = htons(port);
+               break;
+       case AF_INET6:
+               sockaddr->length = sizeof(sockaddr->type.sin6);
+#ifdef ISC_PLATFORM_HAVESALEN
+               sockaddr->type.sin6.sin6_len = sizeof(sockaddr->type.sin6);
+#endif
+               memcpy(&sockaddr->type.sin6.sin6_addr, &na->type.in6, 16);
+#ifdef ISC_PLATFORM_HAVESCOPEID
+               sockaddr->type.sin6.sin6_scope_id = isc_netaddr_getzone(na);
+#endif
+               sockaddr->type.sin6.sin6_port = htons(port);
+               break;
+        default:
+                INSIST(0);
+       }
+       ISC_LINK_INIT(sockaddr, link);
+}
+
+void
+isc_sockaddr_setport(isc_sockaddr_t *sockaddr, in_port_t port) {
+       switch (sockaddr->type.sa.sa_family) {
+       case AF_INET:
+               sockaddr->type.sin.sin_port = htons(port);
+               break;
+       case AF_INET6:
+               sockaddr->type.sin6.sin6_port = htons(port);
+               break;
+       default:
+               FATAL_ERROR(__FILE__, __LINE__,
+                           isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKADDR,
+                                          ISC_MSG_UNKNOWNFAMILY,
+                                          "unknown address family: %d"),
+                           (int)sockaddr->type.sa.sa_family);
+       }
+}
+
+in_port_t
+isc_sockaddr_getport(isc_sockaddr_t *sockaddr) {
+       in_port_t port = 0;
+
+       switch (sockaddr->type.sa.sa_family) {
+       case AF_INET:
+               port = ntohs(sockaddr->type.sin.sin_port);
+               break;
+       case AF_INET6:
+               port = ntohs(sockaddr->type.sin6.sin6_port);
+               break;
+       default:
+               FATAL_ERROR(__FILE__, __LINE__,
+                           isc_msgcat_get(isc_msgcat, ISC_MSGSET_SOCKADDR,
+                                          ISC_MSG_UNKNOWNFAMILY,
+                                          "unknown address family: %d"),
+                           (int)sockaddr->type.sa.sa_family);
+       }
+
+       return (port);
+}
+
+isc_boolean_t
+isc_sockaddr_ismulticast(isc_sockaddr_t *sockaddr) {
+       isc_netaddr_t netaddr;
+
+       isc_netaddr_fromsockaddr(&netaddr, sockaddr);
+       return (isc_netaddr_ismulticast(&netaddr));
+}
+
+isc_boolean_t
+isc_sockaddr_isexperimental(isc_sockaddr_t *sockaddr) {
+       isc_netaddr_t netaddr;
+
+       if (sockaddr->type.sa.sa_family == AF_INET) {
+               isc_netaddr_fromsockaddr(&netaddr, sockaddr);
+               return (isc_netaddr_isexperimental(&netaddr));
+       }
+       return (ISC_FALSE);
+}
+
+isc_boolean_t
+isc_sockaddr_issitelocal(isc_sockaddr_t *sockaddr) {
+       isc_netaddr_t netaddr;
+
+       if (sockaddr->type.sa.sa_family == AF_INET6) {
+               isc_netaddr_fromsockaddr(&netaddr, sockaddr);
+               return (isc_netaddr_issitelocal(&netaddr));
+       }
+       return (ISC_FALSE);
+}
+
+isc_boolean_t
+isc_sockaddr_islinklocal(isc_sockaddr_t *sockaddr) {
+       isc_netaddr_t netaddr;
+
+       if (sockaddr->type.sa.sa_family == AF_INET6) {
+               isc_netaddr_fromsockaddr(&netaddr, sockaddr);
+               return (isc_netaddr_islinklocal(&netaddr));
+       }
+       return (ISC_FALSE);
+}
diff --git a/libisc/strerror.c b/libisc/strerror.c
new file mode 100644 (file)
index 0000000..4a0f8d8
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: strerror.c,v 1.3 2001/11/20 01:45:45 gson Exp $ */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include <isc/mutex.h>
+#include <isc/once.h>
+#include <isc/print.h>
+#include <isc/strerror.h>
+#include <isc/util.h>
+
+#ifdef HAVE_STRERROR
+/*
+ * We need to do this this way for profiled locks.
+ */
+static isc_mutex_t isc_strerror_lock;
+static void init_lock(void) {
+       RUNTIME_CHECK(isc_mutex_init(&isc_strerror_lock) == ISC_R_SUCCESS);
+}
+#else
+extern const char * const sys_errlist[];
+extern const int sys_nerr;
+#endif
+
+void
+isc__strerror(int num, char *buf, size_t size) {
+#ifdef HAVE_STRERROR
+       char *msg;
+       unsigned int unum = num;
+       static isc_once_t once = ISC_ONCE_INIT;
+
+       REQUIRE(buf != NULL);
+
+       RUNTIME_CHECK(isc_once_do(&once, init_lock) == ISC_R_SUCCESS);
+
+       LOCK(&isc_strerror_lock);
+       msg = strerror(num);
+       if (msg != NULL)
+               snprintf(buf, size, "%s", msg);
+       else
+               snprintf(buf, size, "Unknown error: %u", unum);
+       UNLOCK(&isc_strerror_lock);
+#else
+       unsigned int unum = num;
+
+       REQUIRE(buf != NULL);
+
+       if (num >= 0 && num < sys_nerr)
+               snprintf(buf, size, "%s", sys_errlist[num]);
+       else
+               snprintf(buf, size, "Unknown error: %u", unum);
+#endif
+}
diff --git a/libntp/Makefile.am b/libntp/Makefile.am
new file mode 100644 (file)
index 0000000..932f87b
--- /dev/null
@@ -0,0 +1,38 @@
+#AUTOMAKE_OPTIONS = ../ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+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
+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 
+
+../include/des.h:
+       touch ../include/des.h
+
+EXTRA_DIST = README
+
diff --git a/libntp/Makefile.in b/libntp/Makefile.in
new file mode 100644 (file)
index 0000000..e91e0a3
--- /dev/null
@@ -0,0 +1,1222 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+ANSI2KNR = ../util/ansi2knr
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+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)
+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)
+libntpsim_a_OBJECTS = $(am_libntpsim_a_OBJECTS)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+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)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+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
+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
+
+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 
+EXTRA_DIST = README
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       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*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(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
+
+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@
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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@
+@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`
+
+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@
+@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
+
+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)
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(HEADERS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+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
+
+# 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.
+.NOEXPORT:
diff --git a/libntp/README b/libntp/README
new file mode 100644 (file)
index 0000000..fac7185
--- /dev/null
@@ -0,0 +1,5 @@
+README file for directory ./libntp of the NTP Version 4 distribution
+
+This directory contains the sources for the NTP library used by most
+programs in this distribution. See the README and RELNOTES files in the
+parent directory for directions on how to make this library.
diff --git a/libntp/a_md5encrypt.c b/libntp/a_md5encrypt.c
new file mode 100644 (file)
index 0000000..e1ea37c
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ *     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.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#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"
+
+/*
+ * MD5authencrypt - generate MD5 message authenticator
+ *
+ * Returns length of authenticator field.
+ */
+int
+MD5authencrypt(
+       u_char *key,            /* key pointer */
+       u_int32 *pkt,           /* packet pointer */
+       int length              /* packet length */
+       )
+{
+       MD5_CTX md5;
+       u_char digest[16];
+
+       /*
+        * MD5 with key identifier concatenated with packet.
+        */
+       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);
+}
+
+
+/*
+ * MD5authdecrypt - verify MD5 message authenticator
+ *
+ * Returns one if authenticator valid, zero if invalid.
+ */
+int
+MD5authdecrypt(
+       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];
+
+       /*
+        * MD5 with key identifier concatenated with packet.
+        */
+       MD5Init(&md5);
+       MD5Update(&md5, key, (u_int)cache_keylen);
+       MD5Update(&md5, (u_char *)pkt, (u_int)length);
+       MD5Final(digest, &md5);
+       if (size != 16 + 4)
+               return (0);
+       return (!memcmp(digest, (char *)pkt + length + 4, 16));
+}
+
+/*
+ * 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.
+ */
+u_int32
+addr2refid(struct sockaddr_storage *addr)
+{
+       MD5_CTX md5;
+       u_char digest[16];
+       u_int32 addr_refid;
+
+       if (addr->ss_family == AF_INET)
+               return (GET_INADDR(*addr));
+
+       MD5Init(&md5);
+       MD5Update(&md5, (u_char *)&GET_INADDR6(*addr),
+           sizeof(struct in6_addr));
+       MD5Final(digest, &md5);
+       memcpy(&addr_refid, digest, 4);
+       return (addr_refid);
+}
diff --git a/libntp/adjtime.c b/libntp/adjtime.c
new file mode 100644 (file)
index 0000000..a8e6580
--- /dev/null
@@ -0,0 +1,386 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef MPE 
+/*
+ * MPE lacks adjtime(), so we define our own.  But note that time slewing has
+ * a sub-second accuracy bug documented in SR 5003462838 which prevents ntpd
+ * from being able to maintain clock synch.  Because of the bug, this adjtime()
+ * implementation as used by ntpd has a side-effect of screwing up the hardware
+ * PDC clock, which will need to be reset with a reboot.
+ *
+ * This problem affects all versions of MPE at the time of this writing (when
+ * MPE/iX 7.0 is the most current).  It only causes bad things to happen when
+ * doing continuous clock synchronization with ntpd; note that you CAN run ntpd
+ * with "disable ntp" in ntp.conf if you wish to provide a time server.
+ *
+ * The one-time clock adjustment functionality of ntpdate and ntp_timeset can
+ * be used without screwing up the PDC clock.
+ * 
+ */
+#include <time.h>
+
+int adjtime(struct timeval *delta, struct timeval *olddelta);
+
+int adjtime(struct timeval *delta, struct timeval *olddelta)
+
+{
+/* Documented, supported MPE system intrinsics. */
+
+extern void GETPRIVMODE(void);
+extern void GETUSERMODE(void);
+
+/* Undocumented, unsupported MPE internal functions. */
+
+extern long long current_correction_usecs(void);
+extern long long get_time(void);
+extern void get_time_change_info(long long *, char *, char *);
+extern long long pdc_time(int *);
+extern void set_time_correction(long long, int, int);
+extern long long ticks_to_micro(long long);
+
+long long big_sec, big_usec, new_correction = 0LL;
+long long prev_correction;
+
+if (delta != NULL) {
+  /* Adjustment required.  Convert delta to 64-bit microseconds. */
+  big_sec = (long)delta->tv_sec;
+  big_usec = delta->tv_usec;
+  new_correction = (big_sec * 1000000LL) + big_usec;
+}
+
+GETPRIVMODE();
+
+/* Determine how much of a previous correction (if any) we're interrupting. */
+prev_correction = current_correction_usecs();
+
+if (delta != NULL) {
+  /* Adjustment required. */
+
+#if 0
+  /* Speculative code disabled until bug SR 5003462838 is fixed.  This bug
+     prevents accurate time slewing, and indeed renders ntpd inoperable. */
+
+  if (prev_correction != 0LL) {
+    /* A previous adjustment did not complete.  Since the PDC UTC clock was
+    immediately jumped at the start of the previous adjustment, we must
+    explicitly reset it to the value of the MPE local time clock minus the
+    time zone offset. */
+
+    char pwf_since_boot, recover_pwf_time;
+    long long offset_ticks, offset_usecs, pdc_usecs_current, pdc_usecs_wanted;
+    int hpe_status;
+
+    get_time_change_info(&offset_ticks, &pwf_since_boot, &recover_pwf_time);
+    offset_usecs = ticks_to_micro(offset_ticks);
+    pdc_usecs_wanted = get_time() - offset_usecs;
+    pdc_usecs_current = pdc_time(&hpe_status);
+    if (hpe_status == 0) 
+      /* Force new PDC time by starting an extra correction. */
+      set_time_correction(pdc_usecs_wanted - pdc_usecs_current,0,1);
+  }
+#endif /* 0 */
+    
+  /* Immediately jump the PDC time to the new value, and then initiate a 
+     gradual MPE time correction slew. */
+  set_time_correction(new_correction,0,1);
+}
+
+GETUSERMODE();
+
+if (olddelta != NULL) {
+  /* Caller wants to know remaining amount of previous correction. */
+  (long)olddelta->tv_sec = prev_correction / 1000000LL;
+  olddelta->tv_usec = prev_correction % 1000000LL;
+}
+
+return 0;
+}
+#endif /* MPE */
+
+#ifdef NEED_HPUX_ADJTIME
+/*************************************************************************/
+/* (c) Copyright Tai Jin, 1988.  All Rights Reserved.                    */
+/*     Hewlett-Packard Laboratories.                                     */
+/*                                                                       */
+/* Permission is hereby granted for unlimited modification, use, and     */
+/* distribution.  This software is made available with no warranty of    */
+/* any kind, express or implied.  This copyright notice must remain      */
+/* intact in all versions of this software.                              */
+/*                                                                       */
+/* The author would appreciate it if any bug fixes and enhancements were */
+/* to be sent back to him for incorporation into future versions of this */
+/* software.  Please send changes to tai@iag.hp.com or ken@sdd.hp.com.   */
+/*************************************************************************/
+
+/*
+ * Revision history
+ *
+ * 9 Jul 94    David L. Mills, Unibergity of Delabunch
+ *             Implemented variable threshold to limit age of
+ *             corrections; reformatted code for readability.
+ */
+
+#ifndef lint
+static char RCSid[] = "adjtime.c,v 3.1 1993/07/06 01:04:42 jbj Exp";
+#endif
+
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/msg.h>
+#include <time.h>
+#include <signal.h>
+#include "adjtime.h"
+
+#define abs(x)  ((x) < 0 ? -(x) : (x))
+
+/*
+ * The following paramters are appropriate for an NTP adjustment
+ * interval of one second.
+ */
+#define ADJ_THRESH 200         /* initial threshold */
+#define ADJ_DELTA 4            /* threshold decrement */
+
+static long adjthresh;         /* adjustment threshold */
+static long saveup;            /* corrections accumulator */
+
+/*
+ * clear_adjtime - reset accumulator and threshold variables
+ */
+void
+_clear_adjtime(void)
+{
+       saveup = 0;
+       adjthresh = ADJ_THRESH;
+}
+
+/*
+ * adjtime - hp-ux copout of the standard Unix adjtime() system call
+ */
+int
+adjtime(
+       register struct timeval *delta,
+       register struct timeval *olddelta
+       )
+{
+       struct timeval newdelta;
+
+       /*
+        * Corrections greater than one second are done immediately.
+        */
+       if (delta->tv_sec) {
+               adjthresh = ADJ_THRESH;
+               saveup = 0;
+               return(_adjtime(delta, olddelta));
+       }
+
+       /*
+        * Corrections less than one second are accumulated until
+        * tripping a threshold, which is initially set at ADJ_THESH and
+        * reduced in ADJ_DELTA steps to zero. The idea here is to
+        * introduce large corrections quickly, while making sure that
+        * small corrections are introduced without excessive delay. The
+        * idea comes from the ARPAnet routing update algorithm.
+        */
+       saveup += delta->tv_usec;
+       if (abs(saveup) >= adjthresh) {
+               adjthresh = ADJ_THRESH;
+               newdelta.tv_sec = 0;
+               newdelta.tv_usec = saveup;
+               saveup = 0;
+               return(_adjtime(&newdelta, olddelta));
+       } else {
+               adjthresh -= ADJ_DELTA;
+       }
+
+       /*
+        * While nobody uses it, return the residual before correction,
+        * as per Unix convention.
+        */
+       if (olddelta)
+           olddelta->tv_sec = olddelta->tv_usec = 0;
+       return(0);
+}
+
+/*
+ * _adjtime - does the actual work
+ */
+int
+_adjtime(
+       register struct timeval *delta,
+       register struct timeval *olddelta
+       )
+{
+       register int mqid;
+       MsgBuf msg;
+       register MsgBuf *msgp = &msg;
+
+       /*
+        * Get the key to the adjtime message queue (note that we must
+        * get it every time because the queue might have been removed
+        * and recreated)
+        */
+       if ((mqid = msgget(KEY, 0)) == -1)
+           return (-1);
+       msgp->msgb.mtype = CLIENT;
+       msgp->msgb.tv = *delta;
+       if (olddelta)
+           msgp->msgb.code = DELTA2;
+       else
+           msgp->msgb.code = DELTA1;
+
+       /*
+        * Tickle adjtimed and snatch residual, if indicated. Lots of
+        * fanatic error checking here.
+        */
+       if (msgsnd(mqid, &msgp->msgp, MSGSIZE, 0) == -1)
+           return (-1);
+       if (olddelta) {
+               if (msgrcv(mqid, &msgp->msgp, MSGSIZE, SERVER, 0) == -1)
+                   return (-1);
+               *olddelta = msgp->msgb.tv;
+       }
+       return (0);
+}
+
+#else
+# if NEED_QNX_ADJTIME
+/*
+ * Emulate adjtime() using QNX ClockAdjust().
+ * Chris Burghart <burghart@atd.ucar.edu>, 11/2001
+ * Miroslaw Pabich <miroslaw_pabich@o2.pl>, 09/2005
+ *
+ * This is an implementation of adjtime() for QNX.  
+ * ClockAdjust() is used to tweak the system clock for about
+ * 1 second period until the desired delta is achieved.
+ * Time correction slew is limited to reasonable value.
+ * Internal rounding and relative errors are reduced.
+ */
+# include <sys/neutrino.h>
+# include <sys/time.h>
+
+# include <ntp_stdlib.h>
+
+/*
+ * Time correction slew limit. QNX is a hard real-time system,
+ * so don't adjust system clock too fast.
+ */
+#define CORR_SLEW_LIMIT     0.02  /* [s/s] */
+
+/*
+ * Period of system clock adjustment. It should be equal to adjtime
+ * execution period (1s). If slightly less than 1s (0.95-0.99), then olddelta
+ * residual error (introduced by execution period jitter) will be reduced.
+ */
+#define ADJUST_PERIOD       0.97  /* [s] */
+
+int 
+adjtime (struct timeval *delta, struct timeval *olddelta)
+{
+    double delta_nsec;
+    double delta_nsec_old;
+    struct _clockadjust adj;
+    struct _clockadjust oldadj;
+
+    /*
+     * How many nanoseconds are we adjusting?
+     */
+    if (delta != NULL)
+       delta_nsec = 1e9 * (long)delta->tv_sec + 1e3 * delta->tv_usec;
+    else
+       delta_nsec = 0;
+
+    /*
+     * Build the adjust structure and call ClockAdjust()
+     */
+    if (delta_nsec != 0)
+    {
+       struct _clockperiod period;
+       long count;
+       long increment;
+       long increment_limit;
+       int isneg = 0;
+
+       /*
+        * Convert to absolute value for future processing
+        */
+       if (delta_nsec < 0)
+       {
+           isneg = 1;
+           delta_nsec = -delta_nsec;
+       }
+
+       /*
+        * Get the current clock period (nanoseconds)
+        */
+       if (ClockPeriod (CLOCK_REALTIME, 0, &period, 0) < 0)
+           return -1;
+
+       /*
+        * Compute count and nanoseconds increment
+        */
+       count = 1e9 * ADJUST_PERIOD / period.nsec;
+       increment = delta_nsec / count + .5;
+       /* Reduce relative error */
+       if (count > increment + 1)
+       {
+           increment = 1 + (long)((delta_nsec - 1) / count);
+           count = delta_nsec / increment + .5;
+       }
+
+       /*
+        * Limit the adjust increment to appropriate value
+        */
+       increment_limit = CORR_SLEW_LIMIT * period.nsec;
+       if (increment > increment_limit)
+       {
+           increment = increment_limit;
+           count = delta_nsec / increment + .5;
+           /* Reduce relative error */
+           if (increment > count + 1)
+           {
+               count =  1 + (long)((delta_nsec - 1) / increment);
+               increment = delta_nsec / count + .5;
+           }
+       }
+
+       adj.tick_nsec_inc = isneg ? -increment : increment;
+       adj.tick_count = count;
+    }
+    else
+    {
+       adj.tick_nsec_inc = 0;
+       adj.tick_count = 0;
+    }
+
+    if (ClockAdjust (CLOCK_REALTIME, &adj, &oldadj) < 0)
+       return -1;
+
+    /*
+     * Build olddelta
+     */
+    delta_nsec_old = (double)oldadj.tick_count * oldadj.tick_nsec_inc;
+    if (olddelta != NULL)
+    {
+       if (delta_nsec_old != 0)
+       {
+           /* Reduce rounding error */
+           delta_nsec_old += (delta_nsec_old < 0) ? -500 : 500;
+           olddelta->tv_sec = delta_nsec_old / 1e9;
+           olddelta->tv_usec = (long)(delta_nsec_old - 1e9
+                                * (long)olddelta->tv_sec) / 1000;
+       }
+       else
+       {
+           olddelta->tv_sec = 0;
+           olddelta->tv_usec = 0;
+       }
+    }
+
+    return 0;
+}
+# else /* no special adjtime() needed */
+int adjtime_bs;
+# endif
+#endif
diff --git a/libntp/adjtimex.c b/libntp/adjtimex.c
new file mode 100644 (file)
index 0000000..03e9d79
--- /dev/null
@@ -0,0 +1,15 @@
+/*
+ * Copyright (c) 1983 Regents of the University of California.
+ * All rights reserved.  The Berkeley software License Agreement
+ * specifies the terms and conditions for redistribution.
+ */
+
+#ifndef lint
+_sccsid:.asciz  "11/19/91       ULTRIX  @(#)adjtime.c   6.1"
+#endif not lint
+
+#include "SYS.h"
+
+SYSCALL(adjtimex)
+        ret
+
diff --git a/libntp/atoint.c b/libntp/atoint.c
new file mode 100644 (file)
index 0000000..46cd96d
--- /dev/null
@@ -0,0 +1,50 @@
+/*
+ * atoint - convert an ascii string to a signed long, with error checking
+ */
+#include <sys/types.h>
+#include <ctype.h>
+
+#include "ntp_types.h"
+#include "ntp_stdlib.h"
+
+int
+atoint(
+       const char *str,
+       long *ival
+       )
+{
+       register long u;
+       register const char *cp;
+       register int isneg;
+       register int oflow_digit;
+
+       cp = str;
+
+       if (*cp == '-') {
+               cp++;
+               isneg = 1;
+               oflow_digit = '8';
+       } else {
+               isneg = 0;
+               oflow_digit = '7';
+       }
+
+       if (*cp == '\0')
+           return 0;
+
+       u = 0;
+       while (*cp != '\0') {
+               if (!isdigit((int)*cp))
+                   return 0;
+               if (u > 214748364 || (u == 214748364 && *cp > oflow_digit))
+                   return 0;   /* overflow */
+               u = (u << 3) + (u << 1);
+               u += *cp++ - '0';       /* ascii dependent */
+       }
+
+       if (isneg)
+           *ival = -u;
+       else 
+           *ival = u;
+       return 1;
+}
diff --git a/libntp/atolfp.c b/libntp/atolfp.c
new file mode 100644 (file)
index 0000000..ff50947
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * atolfp - convert an ascii string to an l_fp number
+ */
+#include <stdio.h>
+#include <ctype.h>
+
+#include "ntp_fp.h"
+#include "ntp_string.h"
+
+/*
+ * Powers of 10
+ */
+static u_long ten_to_the_n[10] = {
+       0,
+       10,
+       100,
+       1000,
+       10000,
+       100000,
+       1000000,
+       10000000,
+       100000000,
+       1000000000,
+};
+
+
+int
+atolfp(
+       const char *str,
+       l_fp *lfp
+       )
+{
+       register const char *cp;
+       register u_long dec_i;
+       register u_long dec_f;
+       char *ind;
+       int ndec;
+       int isneg;
+       static const char *digits = "0123456789";
+
+       isneg = 0;
+       dec_i = dec_f = 0;
+       ndec = 0;
+       cp = str;
+
+       /*
+        * We understand numbers of the form:
+        *
+        * [spaces][-|+][digits][.][digits][spaces|\n|\0]
+        */
+       while (isspace((int)*cp))
+           cp++;
+       
+       if (*cp == '-') {
+               cp++;
+               isneg = 1;
+       }
+       
+       if (*cp == '+')
+           cp++;
+
+       if (*cp != '.' && !isdigit((int)*cp))
+           return 0;
+
+       while (*cp != '\0' && (ind = strchr(digits, *cp)) != NULL) {
+               dec_i = (dec_i << 3) + (dec_i << 1);    /* multiply by 10 */
+               dec_i += (ind - digits);
+               cp++;
+       }
+
+       if (*cp != '\0' && !isspace((int)*cp)) {
+               if (*cp++ != '.')
+                   return 0;
+       
+               while (ndec < 9 && *cp != '\0'
+                      && (ind = strchr(digits, *cp)) != NULL) {
+                       ndec++;
+                       dec_f = (dec_f << 3) + (dec_f << 1);    /* *10 */
+                       dec_f += (ind - digits);
+                       cp++;
+               }
+
+               while (isdigit((int)*cp))
+                   cp++;
+               
+               if (*cp != '\0' && !isspace((int)*cp))
+                   return 0;
+       }
+
+       if (ndec > 0) {
+               register u_long tmp;
+               register u_long bit;
+               register u_long ten_fact;
+
+               ten_fact = ten_to_the_n[ndec];
+
+               tmp = 0;
+               bit = 0x80000000;
+               while (bit != 0) {
+                       dec_f <<= 1;
+                       if (dec_f >= ten_fact) {
+                               tmp |= bit;
+                               dec_f -= ten_fact;
+                       }
+                       bit >>= 1;
+               }
+               if ((dec_f << 1) > ten_fact)
+                   tmp++;
+               dec_f = tmp;
+       }
+
+       if (isneg)
+           M_NEG(dec_i, dec_f);
+       
+       lfp->l_ui = dec_i;
+       lfp->l_uf = dec_f;
+       return 1;
+}
diff --git a/libntp/atouint.c b/libntp/atouint.c
new file mode 100644 (file)
index 0000000..c25e3a0
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * atouint - convert an ascii string to an unsigned long, with error checking
+ */
+#include <sys/types.h>
+#include <ctype.h>
+
+#include "ntp_types.h"
+#include "ntp_stdlib.h"
+
+int
+atouint(
+       const char *str,
+       u_long *uval
+       )
+{
+       register u_long u;
+       register const char *cp;
+
+       cp = str;
+       if (*cp == '\0')
+           return 0;
+
+       u = 0;
+       while (*cp != '\0') {
+               if (!isdigit((int)*cp))
+                   return 0;
+               if (u > 429496729 || (u == 429496729 && *cp >= '6'))
+                   return 0;   /* overflow */
+               u = (u << 3) + (u << 1);
+               u += *cp++ - '0';       /* ascii dependent */
+       }
+
+       *uval = u;
+       return 1;
+}
diff --git a/libntp/audio.c b/libntp/audio.c
new file mode 100644 (file)
index 0000000..8d2f7c2
--- /dev/null
@@ -0,0 +1,496 @@
+/*
+ * audio.c - audio interface for reference clock audio drivers
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(HAVE_SYS_AUDIOIO_H) || defined(HAVE_SUN_AUDIOIO_H) || \
+    defined(HAVE_SYS_SOUNDCARD_H) || defined(HAVE_MACHINE_SOUNDCARD_H)
+
+#include "audio.h"
+#include "ntp_stdlib.h"
+#include "ntp_syslog.h"
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <stdio.h>
+#include "ntp_string.h"
+
+#ifdef HAVE_SYS_AUDIOIO_H
+# include <sys/audioio.h>
+#endif /* HAVE_SYS_AUDIOIO_H */
+
+#ifdef HAVE_SUN_AUDIOIO_H
+# include <sys/ioccom.h>
+# include <sun/audioio.h>
+#endif /* HAVE_SUN_AUDIOIO_H */
+
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif /* HAVE_SYS_IOCTL_H */
+
+#include <fcntl.h>
+
+#ifdef HAVE_MACHINE_SOUNDCARD_H
+# include <machine/soundcard.h>
+# define PCM_STYLE_SOUND
+#else
+# ifdef HAVE_SYS_SOUNDCARD_H
+#  include <sys/soundcard.h>
+#  define PCM_STYLE_SOUND
+# endif
+#endif
+
+#ifdef PCM_STYLE_SOUND
+# include <ctype.h>
+#endif
+
+/*
+ * Global variables
+ */
+#ifdef HAVE_SYS_AUDIOIO_H
+static struct audio_device device; /* audio device ident */
+#endif /* HAVE_SYS_AUDIOIO_H */
+#ifdef PCM_STYLE_SOUND
+# define INIT_FILE "/etc/ntp.audio"
+int agc =      SOUND_MIXER_WRITE_RECLEV; /* or IGAIN or LINE */
+int monitor =  SOUND_MIXER_WRITE_VOLUME; /* or OGAIN */
+int devmask = 0;
+int recmask = 0;
+char cf_c_dev[100], cf_i_dev[100], cf_agc[100], cf_monitor[100];
+
+const char *m_names[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES;
+#else /* not PCM_STYLE_SOUND */
+static struct audio_info info; /* audio device info */
+#endif /* not PCM_STYLE_SOUND */
+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));
+
+
+int
+mixer_name(
+       const char *m_name,
+       int m_mask
+       )
+{
+       int i;
+
+       for (i = 0; i < SOUND_MIXER_NRDEVICES; ++i)
+               if (((1 << i) & m_mask)
+                   && !strcmp(m_names[i], m_name))
+                       break;
+
+       return (SOUND_MIXER_NRDEVICES == i)
+           ? -1
+           : i
+           ;
+}
+
+
+/*
+ * Check:
+ *
+ * /etc/ntp.audio#     where # is the unit number
+ * /etc/ntp.audio.#    where # is the unit number
+ * /etc/ntp.audio
+ *
+ * for contents of the form:
+ *
+ * idev /dev/input_device
+ * cdev /dev/control_device
+ * agc pcm_input_device {igain,line,line1,...}
+ * monitor pcm_monitor_device {ogain,...}
+ *
+ * The device names for the "agc" and "monitor" keywords
+ * can be found by running either the "mixer" program or the
+ * util/audio-pcm program.
+ *
+ * Great hunks of this subroutine were swiped from refclock_oncore.c
+ */
+static void
+audio_config_read(
+       int unit,
+       char **c_dev,   /* Control device */
+       char **i_dev    /* input device */
+       )
+{
+       FILE *fd;
+       char device[20], line[100], ab[100];
+
+       sprintf(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);
+               if ((fd = fopen(device, "r")) == NULL) {
+                       printf("audio_config_read: <%s> NO\n", device);
+                       sprintf(device, "%s.%d", INIT_FILE, unit);
+                       if ((fd = fopen(device, "r")) == NULL) {
+                               printf("audio_config_read: <%s> NO\n", device);
+                               return;
+                       }
+               }
+       }
+       printf("audio_config_read: reading <%s>\n", device);
+       while (fgets(line, sizeof line, fd)) {
+               char *cp, *cc, *ca;
+               int i;
+
+               /* Remove comments */
+               if ((cp = strchr(line, '#')))
+                       *cp = '\0';
+
+               /* Remove any trailing spaces */
+               for (i = strlen(line);
+                    i > 0 && isascii((int)line[i - 1]) && isspace((int)line[i - 1]);
+                       )
+                       line[--i] = '\0';
+
+               /* Remove leading space */
+               for (cc = line; *cc && isascii((int)*cc) && isspace((int)*cc); cc++)
+                       continue;
+
+               /* Stop if nothing left */
+               if (!*cc)
+                       continue;
+
+               /* 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 == '='))
+                                       break;
+                       }
+               }
+
+               /* Remove space (and possible =) leading the arg */
+               for (; *ca && isascii((int)*ca) && (isspace((int)*ca) || (*ca == '=')); ca++)
+                       continue;
+
+               if (!strncmp(cc, "IDEV", (size_t) 4)) {
+                       sscanf(ca, "%s", ab);
+                       strcpy(cf_i_dev, ab);
+                       printf("idev <%s>\n", ab);
+               } else if (!strncmp(cc, "CDEV", (size_t) 4)) {
+                       sscanf(ca, "%s", ab);
+                       strcpy(cf_c_dev, ab);
+                       printf("cdev <%s>\n", ab);
+               } else if (!strncmp(cc, "AGC", (size_t) 3)) {
+                       sscanf(ca, "%s", ab);
+                       strcpy(cf_agc, ab);
+                       printf("agc <%s> %d\n", ab, i);
+               } else if (!strncmp(cc, "MONITOR", (size_t) 7)) {
+                       sscanf(ca, "%s", ab);
+                       strcpy(cf_monitor, ab);
+                       printf("monitor <%s> %d\n", ab, mixer_name(ab, -1));
+               }
+       }
+       fclose(fd);
+       return;
+}
+#endif /* PCM_STYLE_SOUND */
+
+/*
+ * audio_init - open and initialize audio device
+ *
+ * This code works with SunOS 4.x, Solaris 2.x, and PCM; however, it is
+ * believed generic and applicable to other systems with a minor twid
+ * or two. All it does is open the device, set the buffer size (Solaris
+ * only), preset the gain and set the input port. It assumes that the
+ * codec sample rate (8000 Hz), precision (8 bits), number of channels
+ * (1) and encoding (ITU-T G.711 mu-law companded) have been set by
+ * default.
+ */
+int
+audio_init(
+       char    *dname,         /* device name */
+       int     bufsiz,         /* buffer size */
+       int     unit            /* device unit (0-3) */
+       )
+{
+#ifdef PCM_STYLE_SOUND
+# define ACTL_DEV      "/dev/mixer%d"
+       char actl_dev[30];
+# ifdef HAVE_STRUCT_SND_SIZE
+       struct snd_size s_size;
+# endif
+# ifdef AIOGFMT
+       snd_chan_param s_c_p;
+# endif
+#endif
+       int fd;
+       int rval;
+       char *actl =
+#ifdef PCM_STYLE_SOUND
+               actl_dev
+#else
+               "/dev/audioctl"
+#endif
+               ;
+
+#ifdef PCM_STYLE_SOUND
+       (void)sprintf(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. */
+       if (*cf_c_dev)
+               actl = cf_c_dev;
+       if (*cf_i_dev)
+               dname = cf_i_dev;
+#endif
+
+       /*
+        * Open audio device. Do not complain if not there.
+        */
+       fd = open(dname, O_RDWR | O_NONBLOCK, 0777);
+       if (fd < 0)
+               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);
+               close(fd);
+               return(ctl_fd);
+       }
+
+       /*
+        * Set audio device parameters.
+        */
+#ifdef PCM_STYLE_SOUND
+       printf("audio_init: <%s> bufsiz %d\n", dname, bufsiz);
+       rval = fd;
+
+# ifdef HAVE_STRUCT_SND_SIZE
+       if (ioctl(fd, AIOGSIZE, &s_size) == -1)
+           printf("audio_init: AIOGSIZE: %s\n", strerror(errno));
+       else
+           printf("audio_init: orig: play_size %d, rec_size %d\n",
+               s_size.play_size, s_size.rec_size);
+
+       s_size.play_size = s_size.rec_size = bufsiz;
+       printf("audio_init: want: play_size %d, rec_size %d\n",
+              s_size.play_size, s_size.rec_size);
+
+       if (ioctl(fd, AIOSSIZE, &s_size) == -1)
+           printf("audio_init: AIOSSIZE: %s\n", strerror(errno));
+       else
+           printf("audio_init: set:  play_size %d, rec_size %d\n",
+               s_size.play_size, s_size.rec_size);
+# endif /* HAVE_STRUCT_SND_SIZE */
+
+# ifdef SNDCTL_DSP_SETFRAGMENT
+       {
+               int tmp = (16 << 16) + 6; /* 16 fragments, each 2^6 bytes */
+               if (ioctl(fd, SNDCTL_DSP_SETFRAGMENT, &tmp) == -1)
+                   printf("audio_init: SNDCTL_DSP_SETFRAGMENT: %s\n",
+                          strerror(errno));
+       }
+# endif /* SNDCTL_DSP_SETFRAGMENT */
+
+# ifdef AIOGFMT
+       if (ioctl(fd, AIOGFMT, &s_c_p) == -1)
+           printf("audio_init: AIOGFMT: %s\n", strerror(errno));
+       else
+           printf("audio_init: play_rate %lu, rec_rate %lu, play_format %#lx, rec_format %#lx\n",
+               s_c_p.play_rate, s_c_p.rec_rate, s_c_p.play_format, s_c_p.rec_format);
+# endif
+
+       /* Grab the device and record masks */
+
+       if (ioctl(ctl_fd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1)
+           printf("SOUND_MIXER_READ_DEVMASK: %s\n", strerror(errno));
+       if (ioctl(ctl_fd, SOUND_MIXER_READ_RECMASK, &recmask) == -1)
+           printf("SOUND_MIXER_READ_RECMASK: %s\n", strerror(errno));
+
+       /* validate and set any specified config file stuff */
+       if (*cf_agc) {
+               int i;
+
+               i = mixer_name(cf_agc, devmask);
+               if (i >= 0)
+                       agc = MIXER_WRITE(i);
+               else
+                       printf("input %s not in recmask %#x\n",
+                              cf_agc, recmask);
+       }
+
+       if (*cf_monitor) {
+               int i;
+
+               /* devmask */
+               i = mixer_name(cf_monitor, devmask);
+               if (i >= 0)
+                       monitor = MIXER_WRITE(i);
+               else
+                       printf("monitor %s not in devmask %#x\n",
+                              cf_monitor, devmask);
+       }
+
+#else /* not PCM_STYLE_SOUND */
+       AUDIO_INITINFO(&info);
+       info.play.gain = AUDIO_MAX_GAIN;
+       info.play.port = AUDIO_SPEAKER;
+# ifdef HAVE_SYS_AUDIOIO_H
+       info.record.buffer_size = bufsiz;
+# 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");
+               close(ctl_fd);
+               close(fd);
+               return(rval);
+       }
+       rval = fd;
+#endif /* not PCM_STYLE_SOUND */
+       return (rval);
+}
+
+
+/*
+ * audio_gain - adjust codec gains and port
+ */
+int
+audio_gain(
+       int gain,               /* volume level (gain) 0-255 */
+       int mongain,            /* input to output mix (monitor gain) 0-255 */
+       int port                /* selected I/O port: 1 mic/2 line in */
+       )
+{
+       int rval;
+       static int o_mongain = -1;
+       static int o_port = -1;
+
+#ifdef PCM_STYLE_SOUND
+       int l, r;
+
+       rval = 0;
+
+       r = l = 100 * gain / 255;       /* Normalize to 0-100 */
+# ifdef DEBUG
+       if (debug > 1)
+               printf("audio_gain: gain %d/%d\n", gain, l);
+# endif
+       /* figure out what channel(s) to use. just nuke right for now. */
+       r = 0 ; /* setting to zero nicely mutes the channel */
+
+       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) {
+               printf("audio_gain: agc write: %s\n", strerror(errno));
+               return (rval);
+       }
+
+       if (o_mongain != mongain) {
+               r = l = 100 * mongain / 255;    /* Normalize to 0-100 */
+# ifdef DEBUG
+               if (debug > 1)
+                       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) {
+                       printf("audio_gain: mongain write: %s\n",
+                              strerror(errno));
+                       return (rval);
+               }
+               o_mongain = mongain;
+       }
+
+       if (o_port != port) {
+# ifdef DEBUG
+               if (debug > 1)
+                       printf("audio_gain: port %d\n", port);
+# endif
+               l = (1 << ((port == 2) ? SOUND_MIXER_LINE : SOUND_MIXER_MIC));
+               rval = ioctl(ctl_fd, SOUND_MIXER_WRITE_RECSRC, &l);
+               if (rval == -1) {
+                       printf("SOUND_MIXER_WRITE_RECSRC: %s\n",
+                              strerror(errno));
+                       return (rval);
+               }
+# ifdef DEBUG
+               if (debug > 1) {
+                       if (ioctl(ctl_fd, SOUND_MIXER_READ_RECSRC, &l) == -1)
+                               printf("SOUND_MIXER_WRITE_RECSRC: %s\n",
+                                      strerror(errno));
+                       else
+                               printf("audio_gain: recsrc is %d\n", l);
+               }
+# endif
+               o_port = port;
+       }
+#else /* not PCM_STYLE_SOUND */
+       ioctl(ctl_fd, (int)AUDIO_GETINFO, (char *)&info);
+       info.record.encoding = AUDIO_ENCODING_ULAW;
+       info.record.error = 0;
+       info.record.gain = gain;
+       if (o_mongain != mongain)
+               o_mongain = info.monitor_gain = mongain;
+       if (o_port != port)
+               o_port = info.record.port = port;
+       rval = ioctl(ctl_fd, (int)AUDIO_SETINFO, (char *)&info);
+       if (rval < 0) {
+               msyslog(LOG_ERR, "audio_gain: %m");
+               return (rval);
+       }
+       rval = info.record.error;
+#endif /* not PCM_STYLE_SOUND */
+       return (rval);
+}
+
+
+/*
+ * audio_show - display audio parameters
+ *
+ * This code doesn't really do anything, except satisfy curiousity and
+ * verify the ioctl's work.
+ */
+void
+audio_show(void)
+{
+#ifdef PCM_STYLE_SOUND
+       int recsrc = 0;
+
+       printf("audio_show: ctl_fd %d\n", ctl_fd);
+       if (ioctl(ctl_fd, SOUND_MIXER_READ_RECSRC, &recsrc) == -1)
+           printf("SOUND_MIXER_READ_RECSRC: %s\n", strerror(errno));
+
+#else /* not PCM_STYLE_SOUND */
+# ifdef HAVE_SYS_AUDIOIO_H
+       ioctl(ctl_fd, (int)AUDIO_GETDEV, &device);
+       printf("audio: name %s, version %s, config %s\n",
+           device.name, device.version, device.config);
+# endif /* HAVE_SYS_AUDIOIO_H */
+       ioctl(ctl_fd, (int)AUDIO_GETINFO, (char *)&info);
+       printf(
+           "audio: rate %d, chan %d, prec %d, code %d, gain %d, mon %d, port %d\n",
+           info.record.sample_rate, info.record.channels,
+           info.record.precision, info.record.encoding,
+           info.record.gain, info.monitor_gain, info.record.port);
+       printf(
+           "audio: samples %d, eof %d, pause %d, error %d, waiting %d, balance %d\n",
+           info.record.samples, info.record.eof,
+           info.record.pause, info.record.error,
+           info.record.waiting, info.record.balance);
+#endif /* not PCM_STYLE_SOUND */
+}
+#else
+int audio_bs;
+#endif /* HAVE_{SYS_AUDIOIO,SUN_AUDIOIO,MACHINE_SOUNDCARD,SYS_SOUNDCARD}_H */
diff --git a/libntp/authkeys.c b/libntp/authkeys.c
new file mode 100644 (file)
index 0000000..1c95444
--- /dev/null
@@ -0,0 +1,488 @@
+/*
+ * authkeys.c - routines to manage the storage of authentication keys
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+
+#include "ntp_types.h"
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntpd.h"
+#include "ntp_string.h"
+#include "ntp_malloc.h"
+#include "ntp_stdlib.h"
+
+/*
+ * Structure to store keys in in the hash table.
+ */
+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 */
+};
+
+#define        KEY_TRUSTED     0x001   /* this key is trusted */
+#define        KEY_MD5         0x200   /* this is a MD5 type key */
+
+/*
+ * 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)
+
+struct savekey *key_hash[HASHSIZE];
+
+u_long authkeynotfound;                /* keys not found */
+u_long authkeylookups;         /* calls to lookup keys */
+u_long authnumkeys;            /* number of active keys */
+u_long authkeyexpired;         /* key lifetime expirations */
+u_long authkeyuncached;                /* cache misses */
+u_long authnokey;              /* calls to encrypt with no key */
+u_long authencryptions;                /* calls to encrypt */
+u_long authdecryptions;                /* calls to decrypt */
+
+/*
+ * Storage for free key structures.  We malloc() such things but
+ * never free them.
+ */
+struct savekey *authfreekeys;
+int authnumfreekeys;
+
+#define        MEMINC  12              /* 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_short cache_flags;           /* flags that wave */
+
+
+/*
+ * init_auth - initialize internal data
+ */
+void
+init_auth(void)
+{
+       /*
+        * Initialize hash table and free list
+        */
+       memset((char *)key_hash, 0, sizeof key_hash);
+}
+
+
+/*
+ * auth_findkey - find a key in the hash table
+ */
+struct savekey *
+auth_findkey(
+       keyid_t keyno
+       )
+{
+       struct savekey *sk;
+
+       sk = key_hash[KEYHASH(keyno)];
+       while (sk != 0) {
+               if (keyno == sk->keyid)
+                       return (sk);
+
+               sk = sk->next;
+       }
+       return (0);
+}
+
+
+/*
+ * auth_havekey - return one if the key is known
+ */
+int
+auth_havekey(
+       keyid_t keyno
+       )
+{
+       struct savekey *sk;
+
+       if (keyno == 0 || (keyno == cache_keyid))
+               return (1);
+
+       sk = key_hash[KEYHASH(keyno)];
+       while (sk != 0) {
+               if (keyno == sk->keyid)
+                       return (1);
+
+               sk = sk->next;
+       }
+       return (0);
+}
+
+
+/*
+ * authhavekey - return one and cache the key, if known and trusted.
+ */
+int
+authhavekey(
+       keyid_t keyno
+       )
+{
+       struct savekey *sk;
+
+       authkeylookups++;
+       if (keyno == 0 || keyno == cache_keyid)
+               return (1);
+
+       authkeyuncached++;
+       sk = key_hash[KEYHASH(keyno)];
+       while (sk != 0) {
+               if (keyno == sk->keyid)
+                   break;
+               sk = sk->next;
+       }
+       if (sk == 0) {
+               authkeynotfound++;
+               return (0);
+       } else if (!(sk->flags & KEY_TRUSTED)) {
+               authnokey++;
+               return (0);
+       }
+       cache_keyid = sk->keyid;
+       cache_flags = sk->flags;
+       if (sk->flags & KEY_MD5) {
+               cache_key = sk->k.MD5_key;
+               cache_keylen = sk->keylen;
+               return (1);
+       }
+       return (0);
+}
+
+
+/*
+ * 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);
+}
+
+
+/*
+ * authtrust - declare a key to be trusted/untrusted
+ */
+void
+authtrust(
+       keyid_t keyno,
+       u_long trust
+       )
+{
+       struct savekey *sk;
+
+#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;
+       }
+
+       if (sk == 0 && !trust)
+               return;
+       
+       if (sk != 0) {
+               if (cache_keyid == keyno) {
+                       cache_flags = 0;
+                       cache_keyid = 0;
+               }
+
+               if (trust > 0) {
+                       sk->flags |= KEY_TRUSTED;
+                       if (trust > 1)
+                               sk->lifetime = current_time + trust;
+                       else
+                               sk->lifetime = 0;
+                       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++;
+               }
+               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;
+}
+
+
+/*
+ * authistrusted - determine whether a key is trusted
+ */
+int
+authistrusted(
+       keyid_t keyno
+       )
+{
+       struct savekey *sk;
+
+       if (keyno == cache_keyid)
+           return ((cache_flags & KEY_TRUSTED) != 0);
+
+       authkeyuncached++;
+       sk = key_hash[KEYHASH(keyno)];
+       while (sk != 0) {
+               if (keyno == sk->keyid)
+                   break;
+               sk = sk->next;
+       }
+       if (sk == 0) {
+               authkeynotfound++;
+               return (0);
+       } else if (!(sk->flags & KEY_TRUSTED)) {
+               authkeynotfound++;
+               return (0);
+       }
+       return (1);
+}
+
+
+void
+MD5auth_setkey(
+       keyid_t keyno,
+       const u_char *key,
+       const int len
+       )
+{
+       struct savekey *sk;
+       
+       /*
+        * See if we already have the key.  If so just stick in the
+        * new value.
+        */
+       sk = key_hash[KEYHASH(keyno)];
+       while (sk != 0) {
+               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;
+                       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--;
+
+       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)
+ */
+void
+auth_delkeys(void)
+{
+       struct savekey *sk;
+       struct savekey **skp;
+       int i;
+
+       for (i = 0; i < HASHSIZE; i++) {
+               skp = &(key_hash[i]);
+               sk = key_hash[i];
+               /*
+                * Leave autokey keys alone.
+                */
+               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;
+                       }
+               }
+       }
+}
+
+/*
+ * 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;
+               }
+       }
+#ifdef DEBUG
+       if (debug)
+               printf("auth_agekeys: at %lu keys %lu expired %lu\n",
+                   current_time, authnumkeys, authkeyexpired);
+#endif
+}
+
+/*
+ * authencrypt - generate message authenticator
+ *
+ * Returns length of authenticator field, zero if key not found.
+ */
+int
+authencrypt(
+       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
+        * consists of a single word with value zero.
+        */
+       authencryptions++;
+       pkt[length / 4] = htonl(keyno);
+       if (keyno == 0) {
+               return (4);
+       }
+       if (!authhavekey(keyno))
+               return (0);
+
+       if (cache_flags & KEY_MD5)
+               return (MD5authencrypt(cache_key, pkt, length));
+
+       return (0);
+}
+
+/*
+ * authdecrypt - verify message authenticator
+ *
+ * Returns one if authenticator valid, zero if invalid or key not found.
+ */
+int
+authdecrypt(
+       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.
+        */
+       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));
+
+       return (0);
+}
diff --git a/libntp/authreadkeys.c b/libntp/authreadkeys.c
new file mode 100644 (file)
index 0000000..22020f3
--- /dev/null
@@ -0,0 +1,162 @@
+/*
+ * authreadkeys.c - routines to support the reading of the key file
+ */
+#include <stdio.h>
+#include <ctype.h>
+
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntp_syslog.h"
+#include "ntp_stdlib.h"
+
+/*
+ *  Arbitrary long string of ASCII characters.
+ */
+#define        KEY_TYPE_MD5    4
+
+/* Forwards */
+static char *nexttok P((char **));
+
+/*
+ * nexttok - basic internal tokenizing routine
+ */
+static char *
+nexttok(
+       char **str
+       )
+{
+       register char *cp;
+       char *starttok;
+
+       cp = *str;
+
+       /*
+        * Space past white space
+        */
+       while (*cp == ' ' || *cp == '\t')
+           cp++;
+       
+       /*
+        * Save this and space to end of token
+        */
+       starttok = cp;
+       while (*cp != '\0' && *cp != '\n' && *cp != ' '
+              && *cp != '\t' && *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;
+       
+       if (*cp == ' ' || *cp == '\t')
+           *cp++ = '\0';
+       else
+           *cp = '\0';
+       
+       *str = cp;
+       return starttok;
+}
+
+
+/*
+ * authreadkeys - (re)read keys from a file.
+ */
+int
+authreadkeys(
+       const char *file
+       )
+{
+       FILE *fp;
+       char *line;
+       char *token;
+       u_long keyno;
+       int keytype;
+       char buf[512];          /* lots of room for line */
+
+       /*
+        * 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;
+       }
+
+       /*
+        * Remove all existing keys
+        */
+       auth_delkeys();
+
+       /*
+        * Now read lines from the file, looking for key entries
+        */
+       while ((line = fgets(buf, sizeof buf, fp)) != NULL) {
+               token = nexttok(&line);
+               if (token == 0)
+                   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);
+                       continue;
+               }
+
+               if (keyno > NTP_MAXKEY) {
+                       msyslog(LOG_ERR,
+                               "keyid's > %d reserved for autokey, key entry `%s' ignored",
+                               NTP_MAXKEY, token);
+                       continue;
+               }
+
+               /*
+                * 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);
+                       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);
+                       continue;
+               }
+
+               /*
+                * Finally, get key and insert it
+                */
+               token = nexttok(&line);
+               if (token == 0) {
+                       msyslog(LOG_ERR,
+                               "no key for number %ld entry, entry ignored",
+                               keyno);
+               } 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;
+                       }
+               }
+       }
+       (void) fclose(fp);
+       return 1;
+}
diff --git a/libntp/authusekey.c b/libntp/authusekey.c
new file mode 100644 (file)
index 0000000..40dd373
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * authusekey - decode a key from ascii and use it
+ */
+#include <stdio.h>
+#include <ctype.h>
+
+#include "ntp_types.h"
+#include "ntp_string.h"
+#include "ntp_stdlib.h"
+
+/*
+ * Types of ascii representations for keys.  "Standard" means a 64 bit
+ * hex number in NBS format, i.e. with the low order bit of each byte
+ * a parity bit.  "NTP" means a 64 bit key in NTP format, with the
+ * 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,
+       int keytype,
+       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 */
+               return 0;
+       }
+
+       return 1;
+}
diff --git a/libntp/buftvtots.c b/libntp/buftvtots.c
new file mode 100644 (file)
index 0000000..bfceb35
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * buftvtots - pull a Unix-format (struct timeval) time stamp out of
+ *            an octet stream and convert it to a l_fp time stamp.
+ *            This is useful when using the clock line discipline.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+#include "ntp_fp.h"
+#include "ntp_string.h"
+#include "ntp_unixtime.h"
+
+int
+buftvtots(
+       const char *bufp,
+       l_fp *ts
+       )
+{
+       struct timeval tv;
+
+       /*
+        * copy to adhere to alignment restrictions
+        */
+       memcpy(&tv, bufp, sizeof(tv));
+
+       /*
+        * 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;
+}
diff --git a/libntp/caljulian.c b/libntp/caljulian.c
new file mode 100644 (file)
index 0000000..71123df
--- /dev/null
@@ -0,0 +1,146 @@
+/*
+ * caljulian - determine the Julian date from an NTP time.
+ */
+#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
+};
+
+void
+caljulian(
+       u_long                          ntptime,
+       register 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 */
+
+       /*
+        * Do the easy stuff first: take care of hh:mm:ss, ignoring leap
+        * seconds
+        */
+       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! */
+}
+#endif
diff --git a/libntp/caltontp.c b/libntp/caltontp.c
new file mode 100644 (file)
index 0000000..9ec1064
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * caltontp - convert a date to an NTP time
+ */
+#include <sys/types.h>
+
+#include "ntp_types.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+u_long
+caltontp(
+       register 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 */
+
+    /*
+     * Subtract out 1/1/1900, the beginning of the NTP epoch
+     */
+    ntp_days = ace_days - DAY_NTP_STARTS;
+
+    /*
+     * Do the obvious:
+     */
+    ntp_time = 
+       ntp_days*SECSPERDAY+SECSPERMIN*(MINSPERHR*jt->hour + jt->minute);
+
+    return ntp_time;
+}
diff --git a/libntp/calyearstart.c b/libntp/calyearstart.c
new file mode 100644 (file)
index 0000000..0f7ca4f
--- /dev/null
@@ -0,0 +1,22 @@
+/*
+ * calyearstart - determine the NTP time at midnight of January 1 in
+ *               the year of the given date.
+ */
+#include <sys/types.h>
+
+#include "ntp_types.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+u_long
+calyearstart(u_long ntp_time)
+{
+    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);
+}
diff --git a/libntp/clocktime.c b/libntp/clocktime.c
new file mode 100644 (file)
index 0000000..371859c
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * clocktime - compute the NTP date from a day of year, hour, minute
+ *            and second.
+ */
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+/*
+ * Hacks to avoid excercising the multiplier.  I have no pride.
+ */
+#define        MULBY10(x)      (((x)<<3) + ((x)<<1))
+#define        MULBY60(x)      (((x)<<6) - ((x)<<2))   /* watch overflow */
+#define        MULBY24(x)      (((x)<<4) + ((x)<<3))
+
+/*
+ * Two days, in seconds.
+ */
+#define        TWODAYS         (2*24*60*60)
+
+/*
+ * 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.
+ */
+#define        CLOSETIME       (4*60*60)
+
+
+int
+clocktime(
+       int yday,
+       int hour,
+       int minute,
+       int second,
+       int tzoff,
+       u_long rec_ui,
+       u_long *yearstart,
+       u_int32 *ts_ui
+       )
+{
+       register long tmp;
+       register u_long date;
+       register u_long yst;
+
+       /*
+        * 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;
+
+       /*
+        * Initialize yearstart, if necessary.
+        */
+       yst = *yearstart;
+       if (yst == 0) {
+               yst = calyearstart(rec_ui);
+               *yearstart = yst;
+       }
+
+       /*
+        * 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.
+        */
+       date = (u_long)(tmp + (long)yst);
+       if (date < (rec_ui + CLOSETIME) &&
+           date > (rec_ui - CLOSETIME)) {
+               *ts_ui = date;
+               return 1;
+       }
+
+       /*
+        * 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;
+               }
+       }
+
+       /*
+        * 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;
+                       }
+               }
+       }
+
+       /*
+        * 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;
+               }
+       }
+
+       /*
+        * Give it up.
+        */
+       return 0;
+}
diff --git a/libntp/clocktypes.c b/libntp/clocktypes.c
new file mode 100644 (file)
index 0000000..d7dc4ee
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * Data for pretty printing clock types
+ */
+#include <stdio.h>
+
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "lib_strbuf.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+struct clktype clktypes[] = {
+       { REFCLK_NONE,          "unspecified type (0)",
+         "UNKNOWN" },
+       { REFCLK_LOCALCLOCK,    "Undisciplined local clock (1)",
+         "LOCAL" },
+       { REFCLK_GPS_TRAK,      "TRAK 8810 GPS Receiver (2)",
+         "GPS_TRAK" },
+       { REFCLK_WWV_PST,       "PSTI/Traconex WWV/WWVH Receiver (3)",
+         "WWV_PST" },
+       { REFCLK_SPECTRACOM,    "Spectracom (generic) Receivers (4)",
+         "SPECTRACOM" },
+       { REFCLK_TRUETIME,      "TrueTime (generic) Receivers (5)",
+         "TRUETIME" },
+       { REFCLK_IRIG_AUDIO,    "IRIG Audio Decoder (6)",
+         "IRIG_AUDIO" },
+       { REFCLK_CHU_AUDIO,     "CHU Audio Demodulator/Decoder (7)",
+         "CHU_AUDIO" },
+       { REFCLK_PARSE,         "Generic reference clock driver (8)",
+         "GENERIC" },
+       { REFCLK_GPS_MX4200,    "Magnavox MX4200 GPS Receiver (9)",
+         "GPS_MX4200" },
+       { REFCLK_GPS_AS2201,    "Austron 2201A GPS Receiver (10)",
+         "GPS_AS2201" },
+       { REFCLK_GPS_ARBITER,   "Arbiter 1088A/B GPS Receiver (11)",
+         "GPS_ARBITER" },
+       { REFCLK_IRIG_TPRO,     "KSI/Odetics TPRO/S IRIG Interface (12)",
+         "IRIG_TPRO" },
+       { REFCLK_ATOM_LEITCH,   "Leitch CSD 5300 Master Clock Controller (13)",
+         "ATOM_LEITCH" },
+       { REFCLK_MSF_EES,       "EES M201 MSF Receiver (14)",
+         "MSF_EES" },
+       { REFCLK_NONE,          "not used (15)",
+         "NOT_USED" },
+       { REFCLK_IRIG_BANCOMM,  "Bancomm GPS/IRIG Receiver (16)",
+         "GPS_BANC" },
+       { REFCLK_GPS_DATUM,     "Datum Precision Time System (17)",
+         "GPS_DATUM" },
+       { REFCLK_ACTS,          "Automated Computer Time Service (18)",
+         "ACTS_MODEM" },
+       { REFCLK_WWV_HEATH,     "Heath WWV/WWVH Receiver (19)",
+         "WWV_HEATH" },
+       { REFCLK_GPS_NMEA,      "Generic NMEA GPS Receiver (20)",
+         "GPS_NMEA" },
+       { REFCLK_GPS_VME,       "TrueTime GPS-VME Interface (21)",
+         "GPS_VME" },
+       { REFCLK_ATOM_PPS,      "PPS Clock Discipline (22)",
+         "PPS" },
+       { REFCLK_NONE,          "not used (23)",
+         "NOT_USED" },
+       { REFCLK_NONE,          "not used (24)",
+         "NOT_USED" },
+       { REFCLK_NONE,          "not used (25)",
+         "NOT_USED" },
+       { REFCLK_GPS_HP,        "HP 58503A GPS Time & Frequency Receiver (26)",
+         "GPS_HP" },
+       { REFCLK_ARCRON_MSF,    "ARCRON MSF (and DCF77) Receiver (27)",
+         "MSF_ARCRON" },
+       { REFCLK_SHM,           "Clock attached thru shared Memory (28)",
+         "SHM" },
+        { 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)",
+         "GPS_JUPITER" },
+       { REFCLK_CHRONOLOG,     "Chrono-log K (32)",
+         "CHRONOLOG" },
+       { REFCLK_DUMBCLOCK,     "Dumb generic hh:mm:ss local clock (33)",
+         "DUMBCLOCK" },
+       { REFCLK_ULINK,         "Ultralink M320 WWVB receiver (34)",
+         "ULINK_M320"},
+       { REFCLK_PCF,           "Conrad parallel port radio clock (35)",
+         "PCF"},
+       { REFCLK_WWV_AUDIO,     "WWV/H Audio Demodulator/Decoder (36)",
+         "WWV_AUDIO"},
+       { REFCLK_FG,            "Forum Graphic GPS Dating Station (37)",
+         "GPS_FG"},
+       { REFCLK_HOPF_SERIAL,   "hopf Elektronic serial line receiver (38)",
+         "HOPF_S"},
+       { REFCLK_HOPF_PCI,      "hopf Elektronic PCI receiver (39)",
+         "HOPF_P"},
+       { REFCLK_JJY,           "JJY receiver (40)",
+         "JJY"},
+       { REFCLK_TT560,         "TrueTime 560 IRIG-B decoder (41)",
+         "TT_IRIG"},
+       { REFCLK_ZYFER,         "Zyfer GPStarplus receiver (42)",
+         "GPS_ZYFER" },
+       { REFCLK_RIPENCC,       "RIPE NCC Trimble driver (43)",
+         "GPS_RIPENCC" },
+       { REFCLK_NEOCLOCK4X,    "NeoClock4X DCF77 / TDF receiver (44)",
+         "NEOCLK4X"},
+       { -1,                   "", "" }
+};
+
+const char *
+clockname(
+       int num
+       )
+{
+       register struct clktype *clk;
+  
+       for (clk = clktypes; clk->code != -1; clk++) {
+               if (num == clk->code)
+                   return (clk->abbrev);
+       }
+       return (NULL);
+}
diff --git a/libntp/decodenetnum.c b/libntp/decodenetnum.c
new file mode 100644 (file)
index 0000000..746c855
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * decodenetnum - return a net number (this is crude, but careful)
+ */
+#include <sys/types.h>
+#include <ctype.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include "ntp_stdlib.h"
+
+int
+decodenetnum(
+       const char *num,
+       struct sockaddr_storage *netnum
+       )
+{
+       struct addrinfo hints, *ai = NULL;
+       register int err, i;
+       register const char *cp;
+       char name[80];
+
+       cp = num;
+
+       if (*cp == '[') {
+               cp++;
+               for (i = 0; *cp != ']'; cp++, i++)
+                       name[i] = *cp;
+       name[i] = '\0';
+       num = name; 
+       }
+       memset(&hints, 0, sizeof(struct addrinfo));
+       hints.ai_flags = AI_NUMERICHOST;
+       err = getaddrinfo(num, NULL, &hints, &ai);
+       if (err != 0)
+               return 0;
+       memcpy(netnum, (struct sockaddr_storage *)ai->ai_addr, ai->ai_addrlen); 
+       freeaddrinfo(ai);
+       return 1;
+}
diff --git a/libntp/dofptoa.c b/libntp/dofptoa.c
new file mode 100644 (file)
index 0000000..0f96909
--- /dev/null
@@ -0,0 +1,118 @@
+/*
+ * dofptoa - do the grunge work to convert an fp number to ascii
+ */
+#include <stdio.h>
+
+#include "ntp_fp.h"
+#include "lib_strbuf.h"
+#include "ntp_string.h"
+#include "ntp_stdlib.h"
+
+char *
+dofptoa(
+       u_fp fpv,
+       int neg,
+       short ndec,
+       int msec
+       )
+{
+       register u_char *cp, *cpend;
+       register u_long val;
+       register short dec;
+       u_char cbuf[12];
+       u_char *cpdec;
+       char *buf;
+       char *bp;
+
+       /*
+        * Get a string buffer before starting
+        */
+       LIB_GETBUF(buf);
+
+       /*
+        * Zero out the buffer
+        */
+       memset((char *)cbuf, 0, sizeof cbuf);
+
+       /*
+        * Set the pointers to point at the first
+        * decimal place.  Get a local copy of the value.
+        */
+       cp = cpend = &cbuf[5];
+       val = fpv;
+
+       /*
+        * If we have to, decode the integral part
+        */
+       if (!(val & 0xffff0000))
+           cp--;
+       else {
+               register u_short sv = (u_short)(val >> 16);
+               register u_short tmp;
+               register u_short ten = 10;
+
+               do {
+                       tmp = sv;
+                       sv = (u_short) (sv/ten);
+                       *(--cp) = (u_char)(tmp - ((sv<<3) + (sv<<1)));
+               } while (sv != 0);
+       }
+
+       /*
+        * Figure out how much of the fraction to do
+        */
+       if (msec) {
+               dec = (short)(ndec + 3);
+               if (dec < 3)
+                   dec = 3;
+               cpdec = &cbuf[8];
+       } else {
+               dec = ndec;
+               cpdec = cpend;
+       }
+
+       if (dec > 6)
+           dec = 6;
+       
+       if (dec > 0) {
+               do {
+                       val &= 0xffff;
+                       val = (val << 3) + (val << 1);
+                       *cpend++ = (u_char)(val >> 16);
+               } while (--dec > 0);
+       }
+
+       if (val & 0x8000) {
+               register u_char *tp;
+               /*
+                * Round it. Ick.
+                */
+               tp = cpend;
+               *(--tp) += 1;
+               while (*tp >= 10) {
+                       *tp = 0;
+                       *(--tp) += 1;
+               }
+       }
+
+       /*
+        * Remove leading zeroes if necessary
+        */
+       while (cp < (cpdec -1) && *cp == 0)
+           cp++;
+       
+       /*
+        * Copy it into the buffer, asciizing as we go.
+        */
+       bp = buf;
+       if (neg)
+           *bp++ = '-';
+       
+       while (cp < cpend) {
+               if (cp == cpdec)
+                   *bp++ = '.';
+               *bp++ = (char)(*cp++ + '0');
+       }
+       *bp = '\0';
+       return buf;
+}
diff --git a/libntp/dolfptoa.c b/libntp/dolfptoa.c
new file mode 100644 (file)
index 0000000..f68679c
--- /dev/null
@@ -0,0 +1,173 @@
+/*
+ * dolfptoa - do the grunge work of converting an l_fp number to decimal
+ */
+#include <stdio.h>
+
+#include "ntp_fp.h"
+#include "lib_strbuf.h"
+#include "ntp_string.h"
+#include "ntp_stdlib.h"
+
+char *
+dolfptoa(
+       u_long fpi,
+       u_long fpv,
+       int neg,
+       short ndec,
+       int msec
+       )
+{
+       register u_char *cp, *cpend;
+       register u_long lwork;
+       register int dec;
+       u_char cbuf[24];
+       u_char *cpdec;
+       char *buf;
+       char *bp;
+
+       /*
+        * Get a string buffer before starting
+        */
+       LIB_GETBUF(buf);
+
+       /*
+        * Zero the character buffer
+        */
+       memset((char *) cbuf, 0, sizeof(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.
+        */
+       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);
+       }
+
+       /*
+        * Done that, now deal with the problem of the fraction.  First
+        * determine the number of decimal places.
+        */
+       if (msec) {
+               dec = ndec + 3;
+               if (dec < 3)
+                   dec = 3;
+               cpdec = &cbuf[13];
+       } else {
+               dec = ndec;
+               if (dec < 0)
+                   dec = 0;
+               cpdec = &cbuf[10];
+       }
+       if (dec > 12)
+           dec = 12;
+       
+       /*
+        * 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 */
+               }
+
+               /*
+                * Rounding is rotten
+                */
+               if (work.l_uf & 0x80000000) {
+                       register u_char *tp = cpend;
+
+                       *(--tp) += 1;
+                       while (*tp >= 10) {
+                               *tp = 0;
+                               *(--tp) += 1;
+                       };
+                       if (tp < cp)
+                           cp = tp;
+               }
+       }
+       cpend += dec;
+
+
+       /*
+        * We've now got the fraction in cbuf[], with cp pointing at
+        * the first character, cpend pointing past the last, and
+        * cpdec pointing at the first character past the decimal.
+        * Remove leading zeros, then format the number into the
+        * buffer.
+        */
+       while (cp < cpdec) {
+               if (*cp != 0)
+                   break;
+               cp++;
+       }
+       if (cp == cpdec)
+           --cp;
+
+       bp = buf;
+       if (neg)
+           *bp++ = '-';
+       while (cp < cpend) {
+               if (cp == cpdec)
+                   *bp++ = '.';
+               *bp++ = (char)(*cp++ + '0');    /* ascii dependent? */
+       }
+       *bp = '\0';
+
+       /*
+        * Done!
+        */
+       return buf;
+}
diff --git a/libntp/emalloc.c b/libntp/emalloc.c
new file mode 100644 (file)
index 0000000..2fe4c38
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * emalloc - return new memory obtained from the system.  Belch if none.
+ */
+#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
+
+void *
+debug_emalloc(
+       u_int size,
+       char *filename,
+       int line
+       )
+{
+       char *mem;
+
+       if ((mem = (char *)_malloc_dbg(size, _NORMAL_BLOCK, filename, line)) == 0) {
+               msyslog(LOG_ERR, "Exiting: No more memory!");
+               exit(1);
+       }
+       return mem;
+}
+
+#else
+
+void *
+emalloc(
+       u_int size
+       )
+{
+       char *mem;
+
+       if ((mem = (char *)malloc(size)) == 0) {
+               msyslog(LOG_ERR, "Exiting: No more memory!");
+               exit(1);
+       }
+       return mem;
+}
+
+
+#endif
diff --git a/libntp/findconfig.c b/libntp/findconfig.c
new file mode 100644 (file)
index 0000000..ecf6a4b
--- /dev/null
@@ -0,0 +1,72 @@
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef NEED_HPUX_FINDCONFIG
+#include <string.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/utsname.h>
+#include <unistd.h>
+
+const char *
+FindConfig(
+       const char *base
+       )
+{
+       static char result[BUFSIZ];
+       char hostname[BUFSIZ], *cp;
+       struct stat sbuf; 
+       struct utsname unamebuf; 
+
+       /* All keyed by initial target being a directory */
+       (void) strcpy(result, base);
+       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);
+                               if (stat(result, &sbuf) == 0) {
+                                       goto outahere;
+                               } else {
+
+                                       /* Second choice is of form default.835 */
+                                       (void) uname(&unamebuf);
+                                       if (strncmp(unamebuf.machine, "9000/", 5) == 0)
+                                           cp = unamebuf.machine + 5;
+                                       else
+                                           cp = unamebuf.machine;
+                                       (void) sprintf(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);
+                                               if (stat(result, &sbuf) == 0) {
+                                                       goto outahere;
+                                               } else {
+                                                       (void) strcpy(result, "/not/found");
+                                               }
+                                       }
+                               }
+                       } 
+               } 
+       }
+    outahere:
+       return(result);
+}
+#else
+#include "ntp_stdlib.h"
+
+const char *
+FindConfig(
+       const char *base
+       )
+{
+       return base;
+}
+#endif
diff --git a/libntp/fptoa.c b/libntp/fptoa.c
new file mode 100644 (file)
index 0000000..025ad21
--- /dev/null
@@ -0,0 +1,25 @@
+/*
+ * 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/libntp/fptoms.c b/libntp/fptoms.c
new file mode 100644 (file)
index 0000000..0bfca55
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * 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/libntp/getopt.c b/libntp/getopt.c
new file mode 100644 (file)
index 0000000..7b344f0
--- /dev/null
@@ -0,0 +1,107 @@
+/*
+ * getopt - get option letter from argv
+ *
+ * This is a version of the public domain getopt() implementation by
+ * Henry Spencer, changed for 4.3BSD compatibility (in addition to System V).
+ * It allows rescanning of an option list by setting optind to 0 before
+ * calling, which is why we use it even if the system has its own (in fact,
+ * this one has a unique name so as not to conflict with the system's).
+ * Thanks to Dennis Ferguson for the appropriate modifications.
+ *
+ * This file is in the Public Domain.
+ */
+
+/*LINTLIBRARY*/
+
+#include <stdio.h>
+
+#include "ntp_stdlib.h"
+
+#ifdef lint
+#undef putc
+#define        putc    fputc
+#endif /* lint */
+
+char   *ntp_optarg;    /* Global argument pointer. */
+int    ntp_optind = 0; /* Global argv index. */
+int    ntp_opterr = 1; /* for compatibility, should error be printed? */
+int    ntp_optopt;     /* for compatibility, option character checked */
+
+static char    *scan = NULL;   /* Private scan pointer. */
+static const char      *prog = "amnesia";
+
+/*
+ * Print message about a bad option.
+ */
+static int
+badopt(
+       const char *mess,
+       int ch
+       )
+{
+       if (ntp_opterr) {
+               fputs(prog, stderr);
+               fputs(mess, stderr);
+               (void) putc(ch, stderr);
+               (void) putc('\n', stderr);
+       }
+       return ('?');
+}
+
+int
+ntp_getopt(
+       int argc,
+       char *argv[],
+       const char *optstring
+       )
+{
+       register char c;
+       register const char *place;
+
+       prog = argv[0];
+       ntp_optarg = NULL;
+
+       if (ntp_optind == 0) {
+               scan = NULL;
+               ntp_optind++;
+       }
+       
+       if (scan == NULL || *scan == '\0') {
+               if (ntp_optind >= argc
+                   || argv[ntp_optind][0] != '-'
+                   || argv[ntp_optind][1] == '\0') {
+                       return (EOF);
+               }
+               if (argv[ntp_optind][1] == '-'
+                   && argv[ntp_optind][2] == '\0') {
+                       ntp_optind++;
+                       return (EOF);
+               }
+       
+               scan = argv[ntp_optind++]+1;
+       }
+
+       c = *scan++;
+       ntp_optopt = c & 0377;
+       for (place = optstring; place != NULL && *place != '\0'; ++place)
+           if (*place == c)
+               break;
+
+       if (place == NULL || *place == '\0' || c == ':' || c == '?') {
+               return (badopt(": unknown option -", c));
+       }
+
+       place++;
+       if (*place == ':') {
+               if (*scan != '\0') {
+                       ntp_optarg = scan;
+                       scan = NULL;
+               } else if (ntp_optind >= argc) {
+                       return (badopt(": option requires argument -", c));
+               } else {
+                       ntp_optarg = argv[ntp_optind++];
+               }
+       }
+
+       return (c & 0377);
+}
diff --git a/libntp/hextoint.c b/libntp/hextoint.c
new file mode 100644 (file)
index 0000000..0d774eb
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * hextoint - convert an ascii string in hex to an unsigned
+ *           long, with error checking
+ */
+#include <ctype.h>
+
+#include "ntp_stdlib.h"
+
+int
+hextoint(
+       const char *str,
+       u_long *ival
+       )
+{
+       register u_long u;
+       register const char *cp;
+
+       cp = str;
+
+       if (*cp == '\0')
+           return 0;
+
+       u = 0;
+       while (*cp != '\0') {
+               if (!isxdigit((int)*cp))
+                   return 0;
+               if (u >= 0x10000000)
+                   return 0;   /* overflow */
+               u <<= 4;
+               if (*cp <= '9')         /* very ascii dependent */
+                   u += *cp++ - '0';
+               else if (*cp >= 'a')
+                   u += *cp++ - 'a' + 10;
+               else
+                   u += *cp++ - 'A' + 10;
+       }
+       *ival = u;
+       return 1;
+}
diff --git a/libntp/hextolfp.c b/libntp/hextolfp.c
new file mode 100644 (file)
index 0000000..d0b6243
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * hextolfp - convert an ascii hex string to an l_fp number
+ */
+#include <stdio.h>
+#include <ctype.h>
+
+#include "ntp_fp.h"
+#include "ntp_string.h"
+#include "ntp_stdlib.h"
+
+int
+hextolfp(
+       const char *str,
+       l_fp *lfp
+       )
+{
+       register const char *cp;
+       register const char *cpstart;
+       register u_long dec_i;
+       register u_long dec_f;
+       char *ind = NULL;
+       static const char *digits = "0123456789abcdefABCDEF";
+
+       dec_i = dec_f = 0;
+       cp = str;
+
+       /*
+        * We understand numbers of the form:
+        *
+        * [spaces]8_hex_digits[.]8_hex_digits[spaces|\n|\0]
+        */
+       while (isspace((int)*cp))
+           cp++;
+       
+       cpstart = cp;
+       while (*cp != '\0' && (cp - cpstart) < 8 &&
+              (ind = strchr(digits, *cp)) != NULL) {
+               dec_i = dec_i << 4;     /* multiply by 16 */
+               dec_i += ((ind - digits) > 15) ? (ind - digits) - 6
+                       : (ind - digits);
+               cp++;
+       }
+
+       if ((cp - cpstart) < 8 || ind == NULL)
+           return 0;
+       if (*cp == '.')
+           cp++;
+
+       cpstart = cp;
+       while (*cp != '\0' && (cp - cpstart) < 8 &&
+              (ind = strchr(digits, *cp)) != NULL) {
+               dec_f = dec_f << 4;     /* multiply by 16 */
+               dec_f += ((ind - digits) > 15) ? (ind - digits) - 6
+                       : (ind - digits);
+               cp++;
+       }
+
+       if ((cp - cpstart) < 8 || ind == NULL)
+           return 0;
+       
+       if (*cp != '\0' && !isspace((int)*cp))
+           return 0;
+
+       lfp->l_ui = dec_i;
+       lfp->l_uf = dec_f;
+       return 1;
+}
diff --git a/libntp/humandate.c b/libntp/humandate.c
new file mode 100644 (file)
index 0000000..630c871
--- /dev/null
@@ -0,0 +1,62 @@
+/*
+ * humandate - convert an NTP (or the current) time to something readable
+ */
+#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);
+
+       if (!tm)
+               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);
+       
+       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)
+{
+       char *bp;
+       time_t cursec = time((time_t *) 0);
+       struct tm *tm;
+       
+       tm = localtime(&cursec);
+       if (!tm)
+               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);
+               
+       return bp;
+}
diff --git a/libntp/icom.c b/libntp/icom.c
new file mode 100644 (file)
index 0000000..280667e
--- /dev/null
@@ -0,0 +1,325 @@
+/*
+ * Program to control ICOM radios
+ *
+ * This is a ripoff of the utility routines in the ICOM software
+ * distribution. The only function provided is to load the radio
+ * frequency. All other parameters must be manually set before use.
+ */
+#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 */
+
+/*
+ * FSA definitions
+ */
+#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
+ */
+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));
+
+/*
+ * Local variables
+ */
+static int flags;              /* trace flags */
+static int state;              /* fsa state */
+
+
+/*
+ * icom_freq(fd, ident, freq) - load radio frequency
+ */
+int
+icom_freq(                     /* returns 0 (ok), EIO (error) */
+       int fd,                 /* file descriptor */
+       int ident,              /* ICOM radio identifier */
+       double freq             /* frequency (MHz) */
+       )
+{
+       u_char cmd[BMAX], rsp[BMAX];
+       int temp;
+       cmd[0] = V_SFREQ;
+       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, y, len) - double to ICOM frequency with padding
+ */
+static void
+doublefreq(                    /* returns void */
+       double freq,            /* frequency */
+       u_char *x,              /* radio frequency */
+       int len                 /* length (octets) */
+       )
+{
+       int i;
+       char s1[11];
+       char *y;
+
+       sprintf(s1, " %10.0f", freq);
+       y = s1 + 10;
+       i = 0;
+       while (*y != ' ') {
+               x[i] = *y-- & 0x0f;
+               x[i] = x[i] | ((*y-- & 0x0f) << 4);
+               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
+ *
+ * This routine opens the serial interface for raw transmission; that
+ * is, character-at-a-time, no stripping, checking or monkeying with the
+ * bits. For Unix, an input operation ends either with the receipt of a
+ * character or a 0.5-s timeout.
+ */
+int
+icom_init(
+       char *device,           /* device name/link */
+       int speed,              /* line speed */
+       int trace               /* trace flags */       )
+{
+       TTY ttyb;
+       int fd;
+
+       flags = trace;
+       fd = open(device, O_RDWR, 0777);
+       if (fd < 0)
+               return (fd);
+
+       tcgetattr(fd, &ttyb);
+       ttyb.c_iflag = 0;       /* input modes */
+       ttyb.c_oflag = 0;       /* output modes */
+       ttyb.c_cflag = IBAUD|CS8|CREAD|CLOCAL;  /* control modes */
+       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);
+               }
+       }
+       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);
+}
+
+/* end program */
diff --git a/libntp/inttoa.c b/libntp/inttoa.c
new file mode 100644 (file)
index 0000000..f270733
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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/libntp/iosignal.c b/libntp/iosignal.c
new file mode 100644 (file)
index 0000000..19a6e96
--- /dev/null
@@ -0,0 +1,557 @@
+/*
+ * iosignal.c - input/output routines for ntpd.        The socket-opening code
+ *                was shamelessly stolen from ntpd.
+ */
+
+/*
+ * [Bug 158]
+ * Do the #includes differently, as under some versions of Linux
+ * sys/param.h has a #undef CONFIG_PHONE line in it.
+ *
+ * As we have ~40 CONFIG_ variables, I don't feel like renaming them
+ * every time somebody adds a new macro to some system header.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <signal.h>
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif /* HAVE_SYS_PARAM_H */
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+
+#include <arpa/inet.h>
+
+#if _BSDI_VERSION >= 199510
+# include <ifaddrs.h>
+#endif
+
+# ifdef __QNXNTO__
+#  include <fcntl.h>
+#  include <unix.h>
+#  define FNDELAY O_NDELAY
+# endif
+
+#include "ntp_machine.h"
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_if.h"
+#include "ntp_stdlib.h"
+#include "iosignal.h"
+
+#if defined(HAVE_SIGNALED_IO)
+static int sigio_block_count = 0;
+# if defined(HAVE_SIGACTION)
+/*
+ * If sigaction() is used for signal handling and a signal is
+ * pending then the kernel blocks the signal before it calls
+ * the signal handler.
+ *
+ * The variable below is used to take care that the SIGIO signal
+ * is not unintentionally unblocked inside the sigio_handler()
+ * if the handler executes a piece of code that is normally
+ * bracketed by BLOCKIO()/UNBLOCKIO() calls.
+ */
+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 */
+
+
+/*
+ * TTY initialization routines.
+ */
+int
+init_clock_sig(
+       struct refclockio *rio
+       )
+{
+# ifdef USE_TTY_SIGPOLL
+       {
+               /* DO NOT ATTEMPT TO MAKE CLOCK-FD A CTTY: not portable, unreliable */
+               if (ioctl(rio->fd, I_SETSIG, S_INPUT) < 0)
+               {
+                       msyslog(LOG_ERR,
+                               "init_clock_sig: ioctl(I_SETSIG, S_INPUT) failed: %m");
+                       return 1;
+               }
+               return 0;
+       }
+# else
+       /*
+        * Special cases first!
+        */
+       /* Was: defined(SYS_HPUX) */
+#  if defined(FIOSSAIOOWN) && defined(FIOSNBIO) && defined(FIOSSAIOSTAT)
+#define CLOCK_DONE
+       {
+               int pgrp, on = 1;
+
+               /* DO NOT ATTEMPT TO MAKE CLOCK-FD A CTTY: not portable, unreliable */
+               pgrp = getpid();
+               if (ioctl(rio->fd, FIOSSAIOOWN, (char *)&pgrp) == -1)
+               {
+                       msyslog(LOG_ERR, "ioctl(FIOSSAIOOWN) fails for clock I/O: %m");
+                       exit(1);
+                       /*NOTREACHED*/
+               }
+
+               /*
+                * set non-blocking, async I/O on the descriptor
+                */
+               if (ioctl(rio->fd, FIOSNBIO, (char *)&on) == -1)
+               {
+                       msyslog(LOG_ERR, "ioctl(FIOSNBIO) fails for clock I/O: %m");
+                       exit(1);
+                       /*NOTREACHED*/
+               }
+
+               if (ioctl(rio->fd, FIOSSAIOSTAT, (char *)&on) == -1)
+               {
+                       msyslog(LOG_ERR, "ioctl(FIOSSAIOSTAT) fails for clock I/O: %m");
+                       exit(1);
+                       /*NOTREACHED*/
+               }
+               return 0;
+       }
+#  endif /* SYS_HPUX: FIOSSAIOOWN && FIOSNBIO && FIOSSAIOSTAT */
+       /* Was: defined(SYS_AIX) && !defined(_BSD) */
+#  if !defined(_BSD) && defined(_AIX) && defined(FIOASYNC) && defined(FIOSETOWN)
+       /*
+        * SYSV compatibility mode under AIX.
+        */
+#define CLOCK_DONE
+       {
+               int pgrp, on = 1;
+
+               /* DO NOT ATTEMPT TO MAKE CLOCK-FD A CTTY: not portable, unreliable */
+               if (ioctl(rio->fd, FIOASYNC, (char *)&on) == -1)
+               {
+                       msyslog(LOG_ERR, "ioctl(FIOASYNC) fails for clock I/O: %m");
+                       return 1;
+               }
+               pgrp = -getpid();
+               if (ioctl(rio->fd, FIOSETOWN, (char*)&pgrp) == -1)
+               {
+                       msyslog(LOG_ERR, "ioctl(FIOSETOWN) fails for clock I/O: %m");
+                       return 1;
+               }
+
+               if (fcntl(rio->fd, F_SETFL, FNDELAY|FASYNC) < 0)
+               {
+                       msyslog(LOG_ERR, "fcntl(FNDELAY|FASYNC) fails for clock I/O: %m");
+                       return 1;
+               }
+               return 0;
+       }
+#  endif /* AIX && !BSD: !_BSD && FIOASYNC && FIOSETOWN */
+#  ifndef  CLOCK_DONE
+       {
+               /* DO NOT ATTEMPT TO MAKE CLOCK-FD A CTTY: not portable, unreliable */
+#      if defined(TIOCSCTTY) && defined(USE_FSETOWNCTTY)
+               /*
+                * there are, however, always exceptions to the rules
+                * one is, that OSF accepts SETOWN on TTY fd's only, iff they are
+                * CTTYs. SunOS and HPUX do not semm to have this restriction.
+                * another question is: how can you do multiple SIGIO from several
+                * ttys (as they all should be CTTYs), wondering...
+                *
+                * kd 95-07-16
+                */
+               if (ioctl(rio->fd, TIOCSCTTY, 0) == -1)
+               {
+                       msyslog(LOG_ERR, "ioctl(TIOCSCTTY, 0) fails for clock I/O: %m");
+                       return 1;
+               }
+#      endif /* TIOCSCTTY && USE_FSETOWNCTTY */
+
+               if (fcntl(rio->fd, F_SETOWN, getpid()) == -1)
+               {
+                       msyslog(LOG_ERR, "fcntl(F_SETOWN) fails for clock I/O: %m");
+                       return 1;
+               }
+
+               if (fcntl(rio->fd, F_SETFL, FNDELAY|FASYNC) < 0)
+               {
+                       msyslog(LOG_ERR,
+                               "fcntl(FNDELAY|FASYNC) fails for clock I/O: %m");
+                       return 1;
+               }
+               return 0;
+       }
+#  endif /* CLOCK_DONE */
+# endif /* !USE_TTY_SIGPOLL  */
+}
+
+
+
+void
+init_socket_sig(
+       int fd
+       )
+{
+# ifdef USE_UDP_SIGPOLL
+       {
+               if (ioctl(fd, I_SETSIG, S_INPUT) < 0)
+               {
+                       msyslog(LOG_ERR,
+                               "init_socket_sig: ioctl(I_SETSIG, S_INPUT) failed: %m");
+                       exit(1);
+               }
+       }
+# else /* USE_UDP_SIGPOLL */
+       {
+               int pgrp;
+# ifdef FIOASYNC
+               int on = 1;
+# endif
+
+#  if defined(FIOASYNC)
+               if (ioctl(fd, FIOASYNC, (char *)&on) == -1)
+               {
+                       msyslog(LOG_ERR, "ioctl(FIOASYNC) fails: %m");
+                       exit(1);
+                       /*NOTREACHED*/
+               }
+#  elif defined(FASYNC)
+               {
+                       int flags;
+
+                       if ((flags = fcntl(fd, F_GETFL, 0)) == -1)
+                       {
+                               msyslog(LOG_ERR, "fcntl(F_GETFL) fails: %m");
+                               exit(1);
+                               /*NOTREACHED*/
+                       }
+                       if (fcntl(fd, F_SETFL, flags|FASYNC) < 0)
+                       {
+                               msyslog(LOG_ERR, "fcntl(...|FASYNC) fails: %m");
+                               exit(1);
+                               /*NOTREACHED*/
+                       }
+               }
+#  else
+#      include "Bletch: Need asynchronous I/O!"
+#  endif
+
+#  ifdef UDP_BACKWARDS_SETOWN
+               pgrp = -getpid();
+#  else
+               pgrp = getpid();
+#  endif
+
+#  if defined(SIOCSPGRP)
+               if (ioctl(fd, SIOCSPGRP, (char *)&pgrp) == -1)
+               {
+                       msyslog(LOG_ERR, "ioctl(SIOCSPGRP) fails: %m");
+                       exit(1);
+                       /*NOTREACHED*/
+               }
+#  elif defined(FIOSETOWN)
+               if (ioctl(fd, FIOSETOWN, (char*)&pgrp) == -1)
+               {
+                       msyslog(LOG_ERR, "ioctl(FIOSETOWN) fails: %m");
+                       exit(1);
+                       /*NOTREACHED*/
+               }
+#  elif defined(F_SETOWN)
+               if (fcntl(fd, F_SETOWN, pgrp) == -1)
+               {
+                       msyslog(LOG_ERR, "fcntl(F_SETOWN) fails: %m");
+                       exit(1);
+                       /*NOTREACHED*/
+               }
+#  else
+#      include "Bletch: Need to set process(group) to receive SIG(IO|POLL)"
+#  endif
+       }
+# endif /* USE_UDP_SIGPOLL */
+}
+
+RETSIGTYPE
+sigio_handler(
+       int sig
+       )
+{
+       int saved_errno = errno;
+       l_fp ts;
+
+       get_systime(&ts);
+
+# if defined(HAVE_SIGACTION)
+       sigio_handler_active++;
+       if (sigio_handler_active != 1)  /* This should never happen! */
+           msyslog(LOG_ERR, "sigio_handler: sigio_handler_active != 1");
+# endif
+
+       (void)input_handler(&ts);
+
+# if defined(HAVE_SIGACTION)
+       sigio_handler_active--;
+       if (sigio_handler_active != 0)  /* This should never happen! */
+           msyslog(LOG_ERR, "sigio_handler: sigio_handler_active != 0");
+# endif
+
+       errno = saved_errno;
+}
+
+/*
+ * Signal support routines.
+ */
+# ifdef HAVE_SIGACTION
+void
+set_signal(void)
+{
+#  ifdef USE_SIGIO
+       (void) signal_no_reset(SIGIO, sigio_handler);
+# endif
+#  ifdef USE_SIGPOLL
+       (void) signal_no_reset(SIGPOLL, sigio_handler);
+# endif
+}
+
+void
+block_io_and_alarm(void)
+{
+       sigset_t set;
+
+       if (sigemptyset(&set))
+           msyslog(LOG_ERR, "block_io_and_alarm: sigemptyset() failed: %m");
+#  if defined(USE_SIGIO)
+       if (sigaddset(&set, SIGIO))
+           msyslog(LOG_ERR, "block_io_and_alarm: sigaddset(SIGIO) failed: %m");
+#  endif
+#  if defined(USE_SIGPOLL)
+       if (sigaddset(&set, SIGPOLL))
+           msyslog(LOG_ERR, "block_io_and_alarm: sigaddset(SIGPOLL) failed: %m");
+#  endif
+       if (sigaddset(&set, SIGALRM))
+           msyslog(LOG_ERR, "block_io_and_alarm: sigaddset(SIGALRM) failed: %m");
+
+       if (sigprocmask(SIG_BLOCK, &set, NULL))
+           msyslog(LOG_ERR, "block_io_and_alarm: sigprocmask() failed: %m");
+}
+
+void
+block_sigio(void)
+{
+       if ( sigio_handler_active == 0 )  /* not called from within signal handler */
+       {
+               sigset_t set;
+
+               ++sigio_block_count;
+               if (sigio_block_count > 1)
+                   msyslog(LOG_INFO, "block_sigio: sigio_block_count > 1");
+               if (sigio_block_count < 1)
+                   msyslog(LOG_INFO, "block_sigio: sigio_block_count < 1");
+
+               if (sigemptyset(&set))
+                   msyslog(LOG_ERR, "block_sigio: sigemptyset() failed: %m");
+#      if defined(USE_SIGIO)
+               if (sigaddset(&set, SIGIO))
+                   msyslog(LOG_ERR, "block_sigio: sigaddset(SIGIO) failed: %m");
+#      endif
+#      if defined(USE_SIGPOLL)
+               if (sigaddset(&set, SIGPOLL))
+                   msyslog(LOG_ERR, "block_sigio: sigaddset(SIGPOLL) failed: %m");
+#      endif
+
+               if (sigprocmask(SIG_BLOCK, &set, NULL))
+                   msyslog(LOG_ERR, "block_sigio: sigprocmask() failed: %m");
+       }
+}
+
+void
+unblock_io_and_alarm(void)
+{
+       sigset_t unset;
+
+       if (sigemptyset(&unset))
+           msyslog(LOG_ERR, "unblock_io_and_alarm: sigemptyset() failed: %m");
+
+#  if defined(USE_SIGIO)
+       if (sigaddset(&unset, SIGIO))
+           msyslog(LOG_ERR, "unblock_io_and_alarm: sigaddset(SIGIO) failed: %m");
+#  endif
+#  if defined(USE_SIGPOLL)
+       if (sigaddset(&unset, SIGPOLL))
+           msyslog(LOG_ERR, "unblock_io_and_alarm: sigaddset(SIGPOLL) failed: %m");
+#  endif
+       if (sigaddset(&unset, SIGALRM))
+           msyslog(LOG_ERR, "unblock_io_and_alarm: sigaddset(SIGALRM) failed: %m");
+
+       if (sigprocmask(SIG_UNBLOCK, &unset, NULL))
+           msyslog(LOG_ERR, "unblock_io_and_alarm: sigprocmask() failed: %m");
+}
+
+void
+unblock_sigio(void)
+{
+       if ( sigio_handler_active == 0 )  /* not called from within signal handler */
+       {
+               sigset_t unset;
+
+               --sigio_block_count;
+               if (sigio_block_count > 0)
+                   msyslog(LOG_INFO, "unblock_sigio: sigio_block_count > 0");
+               if (sigio_block_count < 0)
+                   msyslog(LOG_INFO, "unblock_sigio: sigio_block_count < 0");
+
+               if (sigemptyset(&unset))
+                   msyslog(LOG_ERR, "unblock_sigio: sigemptyset() failed: %m");
+
+#      if defined(USE_SIGIO)
+               if (sigaddset(&unset, SIGIO))
+                   msyslog(LOG_ERR, "unblock_sigio: sigaddset(SIGIO) failed: %m");
+#      endif
+#      if defined(USE_SIGPOLL)
+               if (sigaddset(&unset, SIGPOLL))
+                   msyslog(LOG_ERR, "unblock_sigio: sigaddset(SIGPOLL) failed: %m");
+#      endif
+
+               if (sigprocmask(SIG_UNBLOCK, &unset, NULL))
+                   msyslog(LOG_ERR, "unblock_sigio: sigprocmask() failed: %m");
+       }
+}
+
+void
+wait_for_signal(void)
+{
+       sigset_t old;
+
+       if (sigprocmask(SIG_UNBLOCK, NULL, &old))
+           msyslog(LOG_ERR, "wait_for_signal: sigprocmask() failed: %m");
+
+#  if defined(USE_SIGIO)
+       if (sigdelset(&old, SIGIO))
+           msyslog(LOG_ERR, "wait_for_signal: sigdelset(SIGIO) failed: %m");
+#  endif
+#  if defined(USE_SIGPOLL)
+       if (sigdelset(&old, SIGPOLL))
+           msyslog(LOG_ERR, "wait_for_signal: sigdelset(SIGPOLL) failed: %m");
+#  endif
+       if (sigdelset(&old, SIGALRM))
+           msyslog(LOG_ERR, "wait_for_signal: sigdelset(SIGALRM) failed: %m");
+
+       if (sigsuspend(&old) && (errno != EINTR))
+           msyslog(LOG_ERR, "wait_for_signal: sigsuspend() failed: %m");
+}
+
+# else /* !HAVE_SIGACTION */
+/*
+ * Must be an old bsd system.
+ * We assume there is no SIGPOLL.
+ */
+
+void
+block_io_and_alarm(void)
+{
+       int mask;
+
+       mask = sigmask(SIGIO) | sigmask(SIGALRM);
+       if (sigblock(mask))
+           msyslog(LOG_ERR, "block_io_and_alarm: sigblock() failed: %m");
+}
+
+void
+block_sigio(void)
+{
+       int mask;
+
+       ++sigio_block_count;
+       if (sigio_block_count > 1)
+           msyslog(LOG_INFO, "block_sigio: sigio_block_count > 1");
+       if (sigio_block_count < 1)
+           msyslog(LOG_INFO, "block_sigio: sigio_block_count < 1");
+
+       mask = sigmask(SIGIO);
+       if (sigblock(mask))
+           msyslog(LOG_ERR, "block_sigio: sigblock() failed: %m");
+}
+
+void
+set_signal(void)
+{
+       (void) signal_no_reset(SIGIO, sigio_handler);
+}
+
+void
+unblock_io_and_alarm(void)
+{
+       int mask, omask;
+
+       mask = sigmask(SIGIO) | sigmask(SIGALRM);
+       omask = sigblock(0);
+       omask &= ~mask;
+       (void) sigsetmask(omask);
+}
+
+void
+unblock_sigio(void)
+{
+       int mask, omask;
+
+       --sigio_block_count;
+       if (sigio_block_count > 0)
+           msyslog(LOG_INFO, "unblock_sigio: sigio_block_count > 0");
+       if (sigio_block_count < 0)
+           msyslog(LOG_INFO, "unblock_sigio: sigio_block_count < 0");
+       mask = sigmask(SIGIO);
+       omask = sigblock(0);
+       omask &= ~mask;
+       (void) sigsetmask(omask);
+}
+
+void
+wait_for_signal(void)
+{
+       int mask, omask;
+
+       mask = sigmask(SIGIO) | sigmask(SIGALRM);
+       omask = sigblock(0);
+       omask &= ~mask;
+       if (sigpause(omask) && (errno != EINTR))
+           msyslog(LOG_ERR, "wait_for_signal: sigspause() failed: %m");
+}
+
+# endif /* HAVE_SIGACTION */
+#else
+int  NotAnEmptyCompilationUnit;
+#endif 
diff --git a/libntp/lib_strbuf.c b/libntp/lib_strbuf.c
new file mode 100644 (file)
index 0000000..315070f
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * lib_strbuf - library string storage
+ */
+
+#include "ntp_stdlib.h"
+#include "lib_strbuf.h"
+
+/*
+ * Storage declarations
+ */
+char lib_stringbuf[LIB_NUMBUFS][LIB_BUFLENGTH];
+int lib_nextbuf;
+int lib_inited = 0;
+
+/*
+ * initialization routine.  Might be needed if the code is ROMized.
+ */
+void
+init_lib(void)
+{
+       lib_nextbuf = 0;
+       lib_inited = 1;
+}
diff --git a/libntp/lib_strbuf.h b/libntp/lib_strbuf.h
new file mode 100644 (file)
index 0000000..5aa0eb0
--- /dev/null
@@ -0,0 +1,28 @@
+/*
+ * 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/libntp/machines.c b/libntp/machines.c
new file mode 100644 (file)
index 0000000..c8e4e07
--- /dev/null
@@ -0,0 +1,527 @@
+/* machines.c - provide special support for peculiar architectures
+ *
+ * Real bummers unite !
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ntp_machine.h"
+#include "ntp_syslog.h"
+#include "ntp_stdlib.h"
+#include "ntp_unixtime.h"
+
+#ifdef HAVE_UNISTD_H
+#include <unistd.h>
+#endif
+
+#ifdef SYS_WINNT
+int _getch(void);      /* Declare the one function rather than include conio.h */
+#else
+
+#ifdef SYS_VXWORKS
+#include "taskLib.h"
+#include "sysLib.h"
+#include "time.h"
+#include "ntp_syslog.h"
+
+/*     some translations to the world of vxWorkings -casey */
+/* first some netdb type things */
+#include "ioLib.h"
+#include <socket.h>
+int h_errno;
+
+struct hostent *gethostbyname(char *name)
+       {
+       struct hostent *host1;
+       h_errno = 0;                                    /* we are always successful!!! */
+       host1 = (struct hostent *) malloc (sizeof(struct hostent));
+       host1->h_name = name;
+       host1->h_addrtype = AF_INET;
+       host1->h_aliases = name;
+       host1->h_length = 4;
+       host1->h_addr_list[0] = (char *)hostGetByName (name);
+       host1->h_addr_list[1] = NULL;
+       return host1;
+       }
+
+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->h_name = name;
+       host1->h_addrtype = AF_INET;
+       host1->h_aliases = name;
+       host1->h_length = 4;
+       host1->h_addr_list = NULL;
+       return host1;
+       }
+
+struct servent *getservbyname (char *name, char *type)
+       {
+       struct servent *serv1;
+       serv1 = (struct servent *) malloc (sizeof(struct servent));
+       serv1->s_name = "ntp";      /* official service name */
+       serv1->s_aliases = NULL;        /* alias list */
+       serv1->s_port = 123;            /* port # */
+       serv1->s_proto = "udp";     /* protocol to use */
+       return serv1;
+       }
+
+/* second
+ * vxworks thinks it has insomnia
+ * we have to sleep for number of seconds
+ */
+
+#define CLKRATE        sysClkRateGet()
+
+/* I am not sure how valid the granularity is - it is from G. Eger's port */
+#define CLK_GRANULARITY  1             /* Granularity of system clock in usec  */
+                                                               /* Used to round down # usecs/tick              */
+                                                               /* On a VCOM-100, PIT gets 8 MHz clk,   */
+                                                               /*      & it prescales by 32, thus 4 usec       */
+                                                               /* on mv167, granularity is 1usec anyway*/
+                                                               /* To defeat rounding, set to 1                 */
+#define USECS_PER_SEC          MILLION         /* Microseconds per second      */
+#define TICK (((USECS_PER_SEC / CLKRATE) / CLK_GRANULARITY) * CLK_GRANULARITY)
+
+/* emulate unix sleep
+ * casey
+ */
+void sleep(int seconds)
+       {
+       taskDelay(seconds*TICK);
+       }
+/* emulate unix alarm
+ * that pauses and calls SIGALRM after the seconds are up...
+ * so ... taskDelay() fudged for seconds should amount to the same thing.
+ * casey
+ */
+void alarm (int seconds)
+       {
+       sleep(seconds);
+       }
+
+#endif /* SYS_VXWORKS */
+
+#ifdef SYS_PTX                 /* Does PTX still need this? */
+/*#include <sys/types.h>       */
+#include <sys/procstats.h>
+
+int
+gettimeofday(
+       struct timeval *tvp
+       )
+{
+       /*
+        * hi, this is Sequents sneak path to get to a clock
+        * this is also the most logical syscall for such a function
+        */
+       return (get_process_stats(tvp, PS_SELF, (struct procstats *) 0,
+                                 (struct procstats *) 0));
+}
+#endif /* SYS_PTX */
+
+#ifdef MPE
+/* This is a substitute for bind() that if called for an AF_INET socket
+port less than 1024, GETPRIVMODE() and GETUSERMODE() calls will be done. */
+
+#undef bind
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <sys/un.h>
+
+extern void GETPRIVMODE(void);
+extern void GETUSERMODE(void);
+
+int __ntp_mpe_bind(int s, void *addr, int addrlen);
+
+int __ntp_mpe_bind(int s, void *addr, int addrlen) {
+       int priv = 0;
+       int result;
+
+if (addrlen == sizeof(struct sockaddr_in)) { /* AF_INET */
+       if (((struct sockaddr_in *)addr)->sin_port > 0 &&
+           ((struct sockaddr_in *)addr)->sin_port < 1024) {
+               priv = 1;
+               GETPRIVMODE();
+       }
+/*     ((struct sockaddr_in *)addr)->sin_addr.s_addr = 0; */
+       result = bind(s,addr,addrlen);
+       if (priv == 1) GETUSERMODE();
+} else /* AF_UNIX */
+       result = bind(s,addr,addrlen);
+
+return result;
+}
+
+/*
+ * MPE stupidly requires sfcntl() to be used on sockets instead of fcntl(),
+ * so we define a wrapper to analyze the file descriptor and call the correct
+ * function.
+ */
+
+#undef fcntl
+#include <errno.h>
+#include <fcntl.h>
+
+int __ntp_mpe_fcntl(int fd, int cmd, int arg);
+
+int __ntp_mpe_fcntl(int fd, int cmd, int arg) {
+       int len;
+       struct sockaddr sa;
+
+       extern int sfcntl(int, int, int);
+
+       len = sizeof sa;
+       if (getsockname(fd, &sa, &len) == -1) {
+               if (errno == EAFNOSUPPORT) /* AF_UNIX socket */
+                       return sfcntl(fd, cmd, arg);
+               if (errno == ENOTSOCK) /* file or pipe */
+                       return fcntl(fd, cmd, arg);
+               return (-1); /* unknown getsockname() failure */
+       } else /* AF_INET socket */
+               return sfcntl(fd, cmd, arg);
+}
+
+/*
+ * Setitimer emulation support.  Note that we implement this using alarm(),
+ * and since alarm() only delivers one signal, we must re-enable the alarm
+ * by enabling our own SIGALRM setitimer_mpe_handler routine to be called
+ * before the real handler routine and re-enable the alarm at that time.
+ *
+ * Note that this solution assumes that sigaction(SIGALRM) is called before
+ * calling setitimer().  If it should ever to become necessary to support
+ * sigaction(SIGALRM) after calling setitimer(), it will be necessary to trap
+ * those sigaction() calls.
+ */
+
+#include <limits.h>
+#include <signal.h>
+
+/*
+ * Some global data that needs to be shared between setitimer() and
+ * setitimer_mpe_handler().
+ */
+
+struct {
+       unsigned long current_msec;     /* current alarm() value in effect */
+       unsigned long interval_msec;    /* next alarm() value from setitimer */
+       unsigned long value_msec;       /* first alarm() value from setitimer */
+       struct itimerval current_itimerval; /* current itimerval in effect */
+       struct sigaction oldact;        /* SIGALRM state saved by setitimer */
+} setitimer_mpe_ctx = { 0, 0, 0 };
+
+/*
+ * Undocumented, unsupported function to do alarm() in milliseconds.
+ */
+
+extern unsigned int px_alarm(unsigned long, int *);
+
+/*
+ * The SIGALRM handler routine enabled by setitimer().  Re-enable the alarm or
+ * restore the original SIGALRM setting if no more alarms are needed.  Then
+ * call the original SIGALRM handler (if any).
+ */
+
+static RETSIGTYPE setitimer_mpe_handler(int sig)
+{
+int alarm_hpe_status;
+
+/* Update the new current alarm value */
+
+setitimer_mpe_ctx.current_msec = setitimer_mpe_ctx.interval_msec;
+
+if (setitimer_mpe_ctx.interval_msec > 0) {
+  /* Additional intervals needed; re-arm the alarm timer */
+  px_alarm(setitimer_mpe_ctx.interval_msec,&alarm_hpe_status);
+} else {
+  /* No more intervals, so restore previous original SIGALRM handler */
+  sigaction(SIGALRM, &setitimer_mpe_ctx.oldact, NULL);
+}
+
+/* Call the original SIGALRM handler if it is a function and not just a flag */
+
+if (setitimer_mpe_ctx.oldact.sa_handler != SIG_DFL &&
+    setitimer_mpe_ctx.oldact.sa_handler != SIG_ERR &&
+    setitimer_mpe_ctx.oldact.sa_handler != SIG_IGN)
+  (*setitimer_mpe_ctx.oldact.sa_handler)(SIGALRM);
+
+}
+
+/*
+ * Our implementation of setitimer().
+ */
+
+int
+setitimer(int which, struct itimerval *value,
+           struct itimerval *ovalue)
+{
+
+int alarm_hpe_status;
+unsigned long remaining_msec, value_msec, interval_msec;
+struct sigaction newact;
+
+/* 
+ * Convert the initial interval to milliseconds
+ */
+
+if (value->it_value.tv_sec > (UINT_MAX / 1000))
+  value_msec = UINT_MAX;
+else
+  value_msec = value->it_value.tv_sec * 1000;
+
+value_msec += value->it_value.tv_usec / 1000;
+
+/*
+ * Convert the reset interval to milliseconds
+ */
+
+if (value->it_interval.tv_sec > (UINT_MAX / 1000))
+  interval_msec = UINT_MAX;
+else
+  interval_msec = value->it_interval.tv_sec * 1000;
+
+interval_msec += value->it_interval.tv_usec / 1000;
+
+if (value_msec > 0 && interval_msec > 0) {
+  /*
+   * We'll be starting an interval timer that will be repeating, so we need to
+   * insert our own SIGALRM signal handler to schedule the repeats.
+   */
+
+  /* Read the current SIGALRM action */
+
+  if (sigaction(SIGALRM, NULL, &setitimer_mpe_ctx.oldact) < 0) {
+    fprintf(stderr,"MPE setitimer old handler failed, errno=%d\n",errno);
+    return -1;
+  }
+
+  /* Initialize the new action to call our SIGALRM handler instead */
+
+  newact.sa_handler = &setitimer_mpe_handler;
+  newact.sa_mask = setitimer_mpe_ctx.oldact.sa_mask;
+  newact.sa_flags = setitimer_mpe_ctx.oldact.sa_flags;
+  if (sigaction(SIGALRM, &newact, NULL) < 0) {
+    fprintf(stderr,"MPE setitimer new handler failed, errno=%d\n",errno);
+    return -1;
+  }
+}
+
+/*
+ * Return previous itimerval if desired
+ */
+
+if (ovalue != NULL) *ovalue = setitimer_mpe_ctx.current_itimerval;
+
+/*
+ * Save current parameters for later usage
+ */
+
+setitimer_mpe_ctx.current_itimerval = *value;
+setitimer_mpe_ctx.current_msec = value_msec;
+setitimer_mpe_ctx.value_msec = value_msec;
+setitimer_mpe_ctx.interval_msec = interval_msec;
+
+/*
+ * Schedule the first alarm
+ */
+
+remaining_msec = px_alarm(value_msec, &alarm_hpe_status);
+if (alarm_hpe_status == 0)
+  return (0);
+else
+  return (-1);
+}
+
+/* 
+ * MPE lacks gettimeofday(), so we define our own.
+ */
+
+int gettimeofday(struct timeval *tvp)
+
+{
+/* Documented, supported MPE functions. */
+extern void GETPRIVMODE(void);
+extern void GETUSERMODE(void);
+
+/* Undocumented, unsupported MPE functions. */
+extern long long get_time(void);
+extern void get_time_change_info(long long *, char *, char *);
+extern long long ticks_to_micro(long long);
+
+char pwf_since_boot, recover_pwf_time;
+long long mpetime, offset_ticks, offset_usec;
+
+GETPRIVMODE();
+mpetime = get_time(); /* MPE local time usecs since Jan 1 1970 */
+get_time_change_info(&offset_ticks, &pwf_since_boot, &recover_pwf_time);
+offset_usec = ticks_to_micro(offset_ticks);  /* UTC offset usecs */
+GETUSERMODE();
+
+mpetime = mpetime - offset_usec;  /* Convert from local time to UTC */
+tvp->tv_sec = mpetime / 1000000LL;
+tvp->tv_usec = mpetime % 1000000LL;
+
+return 0;
+}
+
+/* 
+ * MPE lacks settimeofday(), so we define our own.
+ */
+
+#define HAVE_SETTIMEOFDAY
+
+int settimeofday(struct timeval *tvp)
+
+{
+/* Documented, supported MPE functions. */
+extern void GETPRIVMODE(void);
+extern void GETUSERMODE(void);
+
+/* Undocumented, unsupported MPE functions. */
+extern void get_time_change_info(long long *, char *, char *);
+extern void initialize_system_time(long long, int);
+extern void set_time_correction(long long, int, int);
+extern long long ticks_to_micro(long long);
+
+char pwf_since_boot, recover_pwf_time;
+long long big_sec, big_usec, mpetime, offset_ticks, offset_usec;
+
+big_sec = tvp->tv_sec;
+big_usec = tvp->tv_usec;
+mpetime = (big_sec * 1000000LL) + big_usec;  /* Desired UTC microseconds */
+
+GETPRIVMODE();
+set_time_correction(0LL,0,0); /* Cancel previous time correction, if any */
+get_time_change_info(&offset_ticks, &pwf_since_boot, &recover_pwf_time);
+offset_usec = ticks_to_micro(offset_ticks); /* UTC offset microseconds */
+mpetime = mpetime + offset_usec; /* Convert from UTC to local time */
+initialize_system_time(mpetime,1);
+GETUSERMODE();
+
+return 0;
+}
+#endif /* MPE */
+
+const char *set_tod_using = "UNKNOWN";
+
+int
+ntp_set_tod(
+       struct timeval *tvp,
+       void *tzp
+       )
+{
+       int rc = -1;
+
+#ifdef DEBUG
+       if (debug)
+           printf("In ntp_set_tod\n");
+#endif
+
+#ifdef HAVE_CLOCK_SETTIME
+       if (rc) {
+               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
+       }
+#endif /* HAVE_CLOCK_SETTIME */
+#ifdef HAVE_SETTIMEOFDAY
+       if (rc) {
+               struct timeval adjtv;
+
+               set_tod_using = "settimeofday";
+               /*
+                * Some broken systems don't reset adjtime() when the
+                * clock is stepped.
+                */
+               adjtv.tv_sec = adjtv.tv_usec = 0;
+               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
+       }
+#endif /* HAVE_SETTIMEOFDAY */
+#ifdef HAVE_STIME
+       if (rc) {
+               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
+       }
+#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));
+       }
+#endif
+       return rc;
+}
+
+#endif /* not SYS_WINNT */
+
+#if defined (SYS_WINNT) || defined (SYS_VXWORKS) || defined(MPE)
+/* getpass is used in ntpq.c and ntpdc.c */
+
+char *
+getpass(const char * prompt)
+{
+       int c, i;
+       static char password[32];
+
+       fprintf(stderr, "%s", prompt);
+       fflush(stderr);
+
+       for (i=0; i<sizeof(password)-1 && ((c=_getch())!='\n' && c!='\r'); i++) {
+               password[i] = (char) c;
+       }
+       password[i] = '\0';
+
+       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/libntp/md5c.c b/libntp/md5c.c
new file mode 100644 (file)
index 0000000..07eec6c
--- /dev/null
@@ -0,0 +1,354 @@
+/* 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/libntp/memmove.c b/libntp/memmove.c
new file mode 100644 (file)
index 0000000..8ccc4b1
--- /dev/null
@@ -0,0 +1,140 @@
+/*-
+ * 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/libntp/mfptoa.c b/libntp/mfptoa.c
new file mode 100644 (file)
index 0000000..6450b2c
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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/libntp/mfptoms.c b/libntp/mfptoms.c
new file mode 100644 (file)
index 0000000..d2bfd71
--- /dev/null
@@ -0,0 +1,23 @@
+/*
+ * 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/libntp/mktime.c b/libntp/mktime.c
new file mode 100644 (file)
index 0000000..91be600
--- /dev/null
@@ -0,0 +1,303 @@
+/*
+ * Copyright (c) 1987, 1989 Regents of the University of California.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to Berkeley by
+ * Arthur David Olson of the National Cancer Institute.
+ *
+ * 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.  */
+
+/*static char *sccsid = "from: @(#)ctime.c     5.26 (Berkeley) 2/23/91";*/
+
+/*
+ * This implementation of mktime is lifted straight from the NetBSD (BSD 4.4)
+ * version.  I modified it slightly to divorce it from the internals of the
+ * ctime library.  Thus this version can't use details of the internal
+ * timezone state file to figure out strange unnormalized struct tm values,
+ * as might result from someone doing date math on the tm struct then passing
+ * it to mktime.
+ *
+ * It just does as well as it can at normalizing the tm input, then does a
+ * binary search of the time space using the system's localtime() function.
+ *
+ * The original binary search was defective in that it didn't consider the
+ * setting of tm_isdst when comparing tm values, causing the search to be
+ * flubbed for times near the dst/standard time changeover.  The original
+ * code seems to make up for this by grubbing through the timezone info
+ * whenever the binary search barfed.  Since I don't have that luxury in
+ * portable code, I have to take care of tm_isdst in the comparison routine.
+ * This requires knowing how many minutes offset dst is from standard time.
+ *
+ * So, if you live somewhere in the world where dst is not 60 minutes offset,
+ * and your vendor doesn't supply mktime(), you'll have to edit this variable
+ * by hand.  Sorry about that.
+ */
+
+#include "ntp_machine.h"
+
+#if !defined(HAVE_MKTIME) || !defined(HAVE_TIMEGM)
+
+#ifndef DSTMINUTES
+#define DSTMINUTES 60
+#endif
+
+#define FALSE 0
+#define TRUE 1
+
+/* some constants from tzfile.h */
+#define SECSPERMIN      60
+#define MINSPERHOUR     60
+#define HOURSPERDAY     24
+#define DAYSPERWEEK     7
+#define DAYSPERNYEAR    365
+#define DAYSPERLYEAR    366
+#define SECSPERHOUR     (SECSPERMIN * MINSPERHOUR)
+#define SECSPERDAY      ((long) SECSPERHOUR * HOURSPERDAY)
+#define MONSPERYEAR     12
+#define TM_YEAR_BASE    1900
+#define isleap(y) ((((y) % 4) == 0 && ((y) % 100) != 0) || ((y) % 400) == 0)
+
+static int     mon_lengths[2][MONSPERYEAR] = {
+       { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
+       { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
+};
+
+static int     year_lengths[2] = {
+       DAYSPERNYEAR, DAYSPERLYEAR
+};
+
+/*
+** Adapted from code provided by Robert Elz, who writes:
+**     The "best" way to do mktime I think is based on an idea of Bob
+**     Kridle's (so its said...) from a long time ago. (mtxinu!kridle now).
+**     It does a binary search of the time_t space.  Since time_t's are
+**     just 32 bits, its a max of 32 iterations (even at 64 bits it
+**     would still be very reasonable).
+*/
+
+#ifndef WRONG
+#define WRONG  (-1)
+#endif /* !defined WRONG */
+
+static void
+normalize(
+       int * tensptr,
+       int * unitsptr,
+       int     base
+       )
+{
+       if (*unitsptr >= base) {
+               *tensptr += *unitsptr / base;
+               *unitsptr %= base;
+       } else if (*unitsptr < 0) {
+               --*tensptr;
+               *unitsptr += base;
+               if (*unitsptr < 0) {
+                       *tensptr -= 1 + (-*unitsptr) / base;
+                       *unitsptr = base - (-*unitsptr) % base;
+               }
+       }
+}
+
+static struct tm *
+mkdst(
+       struct tm *     tmp
+       )
+{
+    /* jds */
+    static struct tm tmbuf;
+
+    tmbuf = *tmp;
+    tmbuf.tm_isdst = 1;
+    tmbuf.tm_min += DSTMINUTES;
+    normalize(&tmbuf.tm_hour, &tmbuf.tm_min, MINSPERHOUR);
+    return &tmbuf;
+}
+
+static int
+tmcomp(
+       register struct tm * atmp,
+       register struct tm * btmp
+       )
+{
+       register int    result;
+
+       /* compare down to the same day */
+
+       if ((result = (atmp->tm_year - btmp->tm_year)) == 0 &&
+           (result = (atmp->tm_mon - btmp->tm_mon)) == 0)
+           result = (atmp->tm_mday - btmp->tm_mday);
+
+       if(result != 0)
+           return result;
+
+       /* get rid of one-sided dst bias */
+
+       if(atmp->tm_isdst == 1 && !btmp->tm_isdst)
+           btmp = mkdst(btmp);
+       else if(btmp->tm_isdst == 1 && !atmp->tm_isdst)
+           atmp = mkdst(atmp);
+
+       /* compare the rest of the way */
+
+       if ((result = (atmp->tm_hour - btmp->tm_hour)) == 0 &&
+           (result = (atmp->tm_min - btmp->tm_min)) == 0)
+           result = atmp->tm_sec - btmp->tm_sec;
+       return result;
+}
+
+
+static time_t
+time2(
+       struct tm *     tmp,
+       int *           okayp,
+       int             usezn
+       )
+{
+       register int                    dir;
+       register int                    bits;
+       register int                    i;
+       register int                    saved_seconds;
+       time_t                          t;
+       struct tm                       yourtm, mytm;
+
+       *okayp = FALSE;
+       yourtm = *tmp;
+       if (yourtm.tm_sec >= SECSPERMIN + 2 || yourtm.tm_sec < 0)
+               normalize(&yourtm.tm_min, &yourtm.tm_sec, SECSPERMIN);
+       normalize(&yourtm.tm_hour, &yourtm.tm_min, MINSPERHOUR);
+       normalize(&yourtm.tm_mday, &yourtm.tm_hour, HOURSPERDAY);
+       normalize(&yourtm.tm_year, &yourtm.tm_mon, MONSPERYEAR);
+       while (yourtm.tm_mday <= 0) {
+               --yourtm.tm_year;
+               yourtm.tm_mday +=
+                       year_lengths[isleap(yourtm.tm_year + TM_YEAR_BASE)];
+       }
+       for ( ; ; ) {
+               i = mon_lengths[isleap(yourtm.tm_year +
+                       TM_YEAR_BASE)][yourtm.tm_mon];
+               if (yourtm.tm_mday <= i)
+                       break;
+               yourtm.tm_mday -= i;
+               if (++yourtm.tm_mon >= MONSPERYEAR) {
+                       yourtm.tm_mon = 0;
+                       ++yourtm.tm_year;
+               }
+       }
+       saved_seconds = yourtm.tm_sec;
+       yourtm.tm_sec = 0;
+       /*
+       ** Calculate the number of magnitude bits in a time_t
+       ** (this works regardless of whether time_t is
+       ** signed or unsigned, though lint complains if unsigned).
+       */
+       for (bits = 0, t = 1; t > 0; ++bits, t <<= 1)
+               ;
+       /*
+       ** If time_t is signed, then 0 is the median value,
+       ** if time_t is unsigned, then 1 << bits is median.
+       */
+       t = (t < 0) ? 0 : ((time_t) 1 << bits);
+       for ( ; ; ) {
+               if (usezn)
+                       mytm = *localtime(&t);
+               else
+                       mytm = *gmtime(&t);
+               dir = tmcomp(&mytm, &yourtm);
+               if (dir != 0) {
+                       if (bits-- < 0)
+                               return WRONG;
+                       if (bits < 0)
+                               --t;
+                       else if (dir > 0)
+                               t -= (time_t) 1 << bits;
+                       else    t += (time_t) 1 << bits;
+                       continue;
+               }
+               if (yourtm.tm_isdst < 0 || mytm.tm_isdst == yourtm.tm_isdst)
+                       break;
+
+               return WRONG;
+       }
+       t += saved_seconds;
+       if (usezn)
+               *tmp = *localtime(&t);
+       else
+               *tmp = *gmtime(&t);
+       *okayp = TRUE;
+       return t;
+}
+#else
+int mktime_bs;
+#endif /* !HAVE_MKTIME || !HAVE_TIMEGM */
+
+#ifndef HAVE_MKTIME
+static time_t
+time1(
+       struct tm * tmp
+       )
+{
+       register time_t                 t;
+       int                             okay;
+
+       if (tmp->tm_isdst > 1)
+               tmp->tm_isdst = 1;
+       t = time2(tmp, &okay, 1);
+       if (okay || tmp->tm_isdst < 0)
+               return t;
+
+       return WRONG;
+}
+
+time_t
+mktime(
+       struct tm * tmp
+       )
+{
+       return time1(tmp);
+}
+#endif /* !HAVE_MKTIME */
+
+#ifndef HAVE_TIMEGM
+time_t
+timegm(
+       struct tm * tmp
+       )
+{
+       register time_t                 t;
+       int                             okay;
+
+       tmp->tm_isdst = 0;
+       t = time2(tmp, &okay, 0);
+       if (okay || tmp->tm_isdst < 0)
+               return t;
+
+       return WRONG;
+}
+#endif /* !HAVE_TIMEGM */
diff --git a/libntp/modetoa.c b/libntp/modetoa.c
new file mode 100644 (file)
index 0000000..405aef8
--- /dev/null
@@ -0,0 +1,34 @@
+/*
+ * modetoa - return an asciized mode
+ */
+#include <stdio.h>
+
+#include "lib_strbuf.h"
+#include "ntp_stdlib.h"
+
+const char *
+modetoa(
+       int mode
+       )
+{
+       char *bp;
+       static const char *modestrings[] = {
+               "unspec",
+               "sym_active",
+               "sym_passive",
+               "client",
+               "server",
+               "broadcast",
+               "control",
+               "private",
+               "bclient",
+       };
+
+       if (mode < 0 || mode >= (sizeof modestrings)/sizeof(char *)) {
+               LIB_GETBUF(bp);
+               (void)sprintf(bp, "mode#%d", mode);
+               return bp;
+       }
+
+       return modestrings[mode];
+}
diff --git a/libntp/mstolfp.c b/libntp/mstolfp.c
new file mode 100644 (file)
index 0000000..e4e909d
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+ * mstolfp - convert an ascii string in milliseconds to an l_fp number
+ */
+#include <stdio.h>
+#include <ctype.h>
+
+#include "ntp_fp.h"
+#include "ntp_stdlib.h"
+
+int
+mstolfp(
+       const char *str,
+       l_fp *lfp
+       )
+{
+       register const char *cp;
+       register char *bp;
+       register const char *cpdec;
+       char buf[100];
+
+       /*
+        * We understand numbers of the form:
+        *
+        * [spaces][-][digits][.][digits][spaces|\n|\0]
+        *
+        * This is one enormous hack.  Since I didn't feel like
+        * rewriting the decoding routine for milliseconds, what
+        * is essentially done here is to make a copy of the string
+        * with the decimal moved over three places so the seconds
+        * decoding routine can be used.
+        */
+       bp = buf;
+       cp = str;
+       while (isspace((int)*cp))
+           cp++;
+       
+       if (*cp == '-') {
+               *bp++ = '-';
+               cp++;
+       }
+
+       if (*cp != '.' && !isdigit((int)*cp))
+           return 0;
+
+
+       /*
+        * Search forward for the decimal point or the end of the string.
+        */
+       cpdec = cp;
+       while (isdigit((int)*cpdec))
+           cpdec++;
+
+       /*
+        * Found something.  If we have more than three digits copy the
+        * excess over, else insert a leading 0.
+        */
+       if ((cpdec - cp) > 3) {
+               do {
+                       *bp++ = (char)*cp++;
+               } while ((cpdec - cp) > 3);
+       } else {
+               *bp++ = '0';
+       }
+
+       /*
+        * Stick the decimal in.  If we've got less than three digits in
+        * front of the millisecond decimal we insert the appropriate number
+        * of zeros.
+        */
+       *bp++ = '.';
+       if ((cpdec - cp) < 3) {
+               register int i = 3 - (cpdec - cp);
+
+               do {
+                       *bp++ = '0';
+               } while (--i > 0);
+       }
+
+       /*
+        * Copy the remainder up to the millisecond decimal.  If cpdec
+        * is pointing at a decimal point, copy in the trailing number too.
+        */
+       while (cp < cpdec)
+           *bp++ = (char)*cp++;
+       
+       if (*cp == '.') {
+               cp++;
+               while (isdigit((int)*cp))
+                   *bp++ = (char)*cp++;
+       }
+       *bp = '\0';
+
+       /*
+        * Check to make sure the string is properly terminated.  If
+        * so, give the buffer to the decoding routine.
+        */
+       if (*cp != '\0' && !isspace((int)*cp))
+           return 0;
+       return atolfp(buf, lfp);
+}
diff --git a/libntp/msutotsf.c b/libntp/msutotsf.c
new file mode 100644 (file)
index 0000000..eb3babe
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * 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/libntp/msyslog.c b/libntp/msyslog.c
new file mode 100644 (file)
index 0000000..fe4d979
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * msyslog - either send a message to the terminal or print it on
+ *          the standard output.
+ *
+ * Converted to use varargs, much better ... jks
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <stdio.h>
+
+#include "ntp_types.h"
+#include "ntp_string.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;
+
+u_long ntp_syslogmask =  ~ (u_long) 0;
+
+#ifdef SYS_WINNT
+static char separator = '\\';
+#else
+static char separator = '/';
+#endif /* SYS_WINNT */
+extern char *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;
+
+#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
+}
+void
+format_errmsg(char *nfmt, int lennfmt, const char *fmt, int errval)
+{
+       register char c;
+       register char *n;
+       register const char *f;
+
+       char *err;
+
+       n = nfmt;
+       f = fmt;
+       while ((c = *f++) != '\0' && n < (nfmt+lennfmt - 2)) {
+               if (c != '%') {
+                       *n++ = c;
+                       continue;
+               }
+               if ((c = *f++) != 'm') {
+                       *n++ = '%';
+                       *n++ = c;
+                       continue;
+               }
+               err = 0;
+               err = strerror(errval);
+               /* Make sure we have enough space for the error message */
+               if ((n + strlen(err)) < (nfmt + lennfmt -2)) {
+                       strcpy(n, err);
+                       n += strlen(err);
+               }
+       }
+#if !defined(VMS)
+       if (!syslogit)
+#endif /* VMS */
+           *n++ = '\n';
+       *n = '\0';
+}
+
+/*
+ * 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.
+ */
+
+#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) */
+{
+#if defined(__STDC__) || defined(HAVE_STDARG_H)
+#else
+       int level;
+       const char *fmt;
+#endif
+       va_list ap;
+       char buf[1025], nfmt[256];
+
+       /*
+        * Save the error value as soon as possible
+        */
+#ifdef SYS_WINNT
+       int errval = GetLastError();
+#else
+       int errval = errno;
+#endif
+
+#if defined(__STDC__) || defined(HAVE_STDARG_H)
+       va_start(ap, fmt);
+#else
+       va_start(ap);
+
+       level = va_arg(ap, int);
+       fmt = va_arg(ap, char *);
+#endif
+       format_errmsg(nfmt, sizeof(nfmt), fmt, errval);
+
+       vsnprintf(buf, sizeof(buf), nfmt, ap);
+       addto_syslog(level, buf);
+       va_end(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) */
+{
+#if defined(__STDC__) || defined(HAVE_STDARG_H)
+#else
+       int level;
+       const char *fmt;
+#endif
+       va_list ap;
+       char buf[1025], nfmt[256];
+
+       /*
+        * Save the error value as soon as possible
+        */
+#ifdef SYS_WINNT
+       int errval = WSAGetLastError();
+#else
+       int errval = errno;
+#endif
+
+#if defined(__STDC__) || defined(HAVE_STDARG_H)
+       va_start(ap, fmt);
+#else
+       va_start(ap);
+
+       level = va_arg(ap, int);
+       fmt = va_arg(ap, char *);
+#endif
+       format_errmsg(nfmt, sizeof(nfmt), fmt, errval);
+
+       vsnprintf(buf, sizeof(buf), nfmt, ap);
+       addto_syslog(level, buf);
+       va_end(ap);
+}
diff --git a/libntp/netof.c b/libntp/netof.c
new file mode 100644 (file)
index 0000000..fd57568
--- /dev/null
@@ -0,0 +1,48 @@
+/* 
+ * netof - return the net address part of an ip address in a sockaddr_storage structure
+ *         (zero out host part)
+ */
+#include <stdio.h>
+
+#include "ntp_fp.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*
+netof(
+        struct sockaddr_storage* hostaddr
+       )
+{
+       register u_int32 netnum;
+        struct sockaddr_storage *netaddr;
+
+       netaddr = &ssbuf[next_ssbuf++];
+       if (next_ssbuf == NUM_NETOF_BUFS)
+               next_ssbuf = 0;
+        memcpy(netaddr, hostaddr, sizeof(struct sockaddr_storage));
+
+        if(netaddr->ss_family == AF_INET) {
+                netnum = ((struct sockaddr_in*)netaddr)->sin_addr.s_addr;
+
+               /*
+                * 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;
+               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;
+}
diff --git a/libntp/ntp_random.c b/libntp/ntp_random.c
new file mode 100644 (file)
index 0000000..700b4ee
--- /dev/null
@@ -0,0 +1,485 @@
+/*
+ * Copyright (c) 1983, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 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.
+ *
+ * $FreeBSD: src/lib/libc/stdlib/random.c,v 1.4.2.2 1999/09/05 11:16:45 peter Exp $
+ *
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+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
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <stdio.h>
+
+#include <ntp_types.h>
+#include <ntp_random.h>
+#include <ntp_unixtime.h>
+
+/*
+ * random.c:
+ *
+ * An improved random number generation package.  In addition to the standard
+ * rand()/srand() like interface, this package also has a special state info
+ * interface.  The initstate() routine is called with a seed, an array of
+ * bytes, and a count of how many bytes are being passed in; this array is
+ * then initialized to contain information for random number generation with
+ * that much state information.  Good sizes for the amount of state
+ * information are 32, 64, 128, and 256 bytes.  The state can be switched by
+ * calling the setstate() routine with the same array as was initiallized
+ * with initstate().  By default, the package runs with 128 bytes of state
+ * information and generates far better random numbers than a linear
+ * congruential generator.  If the amount of state information is less than
+ * 32 bytes, a simple linear congruential R.N.G. is used.
+ *
+ * Internally, the state information is treated as an array of longs; the
+ * zeroeth element of the array is the type of R.N.G. being used (small
+ * integer); the remainder of the array is the state information for the
+ * R.N.G.  Thus, 32 bytes of state information will give 7 longs worth of
+ * state information, which will allow a degree seven polynomial.  (Note:
+ * the zeroeth word of state information also has some other information
+ * stored in it -- see setstate() for details).
+ *
+ * The random number generation technique is a linear feedback shift register
+ * approach, employing trinomials (since there are fewer terms to sum up that
+ * way).  In this approach, the least significant bit of all the numbers in
+ * the state table will act as a linear feedback shift register, and will
+ * have period 2^deg - 1 (where deg is the degree of the polynomial being
+ * used, assuming that the polynomial is irreducible and primitive).  The
+ * higher order bits will have longer periods, since their values are also
+ * influenced by pseudo-random carries out of the lower bits.  The total
+ * period of the generator is approximately deg*(2**deg - 1); thus doubling
+ * the amount of state information has a vast influence on the period of the
+ * generator.  Note: the deg*(2**deg - 1) is an approximation only good for
+ * large deg, when the period of the shift register is the dominant factor.
+ * With deg equal to seven, the period is actually much longer than the
+ * 7*(2**7 - 1) predicted by this formula.
+ *
+ * Modified 28 December 1994 by Jacob S. Rosenberg.
+ * The following changes have been made:
+ * All references to the type u_int have been changed to unsigned long.
+ * All references to type int have been changed to type long.  Other
+ * cleanups have been made as well.  A warning for both initstate and
+ * setstate has been inserted to the effect that on Sparc platforms
+ * the 'arg_state' variable must be forced to begin on word boundaries.
+ * This can be easily done by casting a long integer array to char *.
+ * The overall logic has been left STRICTLY alone.  This software was
+ * tested on both a VAX and Sun SpacsStation with exactly the same
+ * results.  The new version and the original give IDENTICAL results.
+ * The new version is somewhat faster than the original.  As the
+ * documentation says:  "By default, the package runs with 128 bytes of
+ * state information and generates far better random numbers than a linear
+ * congruential generator.  If the amount of state information is less than
+ * 32 bytes, a simple linear congruential R.N.G. is used."  For a buffer of
+ * 128 bytes, this new version runs about 19 percent faster and for a 16
+ * byte buffer it is about 5 percent faster.
+ */
+
+/*
+ * For each of the currently supported random number generators, we have a
+ * break value on the amount of state information (you need at least this
+ * many bytes of state info to support this random number generator), a degree
+ * for the polynomial (actually a trinomial) that the R.N.G. is based on, and
+ * the separation between the two lower order coefficients of the trinomial.
+ */
+#define        TYPE_0          0               /* linear congruential */
+#define        BREAK_0         8
+#define        DEG_0           0
+#define        SEP_0           0
+
+#define        TYPE_1          1               /* x**7 + x**3 + 1 */
+#define        BREAK_1         32
+#define        DEG_1           7
+#define        SEP_1           3
+
+#define        TYPE_2          2               /* x**15 + x + 1 */
+#define        BREAK_2         64
+#define        DEG_2           15
+#define        SEP_2           1
+
+#define        TYPE_3          3               /* x**31 + x**3 + 1 */
+#define        BREAK_3         128
+#define        DEG_3           31
+#define        SEP_3           3
+
+#define        TYPE_4          4               /* x**63 + x + 1 */
+#define        BREAK_4         256
+#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:
+ *
+ *     initstate(1, randtbl, 128);
+ *
+ * Note that this initialization takes advantage of the fact that srandom()
+ * advances the front and rear pointers 10*rand_deg times, and hence the
+ * rear pointer which starts at 0 will also end up at zero; thus the zeroeth
+ * element of the state information, which contains info about the current
+ * position of the rear pointer is just
+ *
+ *     MAX_TYPES * (rptr - state) + TYPE_3 == TYPE_3.
+ */
+
+static long randtbl[DEG_3 + 1] = {
+       TYPE_3,
+#ifdef  USE_WEAK_SEEDING
+/* Historic implementation compatibility */
+/* The random sequences do not vary much with the seed */
+       0x9a319039, 0x32d9c024, 0x9b663182, 0x5da1f342, 0xde3b81e0, 0xdf0a6fb5,
+       0xf103bc02, 0x48f340fb, 0x7449e56b, 0xbeb1dbb0, 0xab5c5918, 0x946554fd,
+       0x8c2e680f, 0xeb3d799f, 0xb11ee0b7, 0x2d436b86, 0xda672e2a, 0x1588ca88,
+       0xe369735d, 0x904f35f7, 0xd7158fd6, 0x6fa6f051, 0x616e6b96, 0xac94efdc,
+       0x36413f93, 0xc622c298, 0xf5a42ab8, 0x8a88d77b, 0xf5ad9d0e, 0x8999220b,
+       0x27fb47b9,
+#else   /* !USE_WEAK_SEEDING */
+       0x991539b1, 0x16a5bce3, 0x6774a4cd, 0x3e01511e, 0x4e508aaa, 0x61048c05,
+       0xf5500617, 0x846b7115, 0x6a19892c, 0x896a97af, 0xdb48f936, 0x14898454,
+       0x37ffd106, 0xb58bff9c, 0x59e17104, 0xcf918a49, 0x09378c83, 0x52c7a471,
+       0x8d293ea9, 0x1f4fc301, 0xc3db71be, 0x39b44e1c, 0xf8a44ef9, 0x4c8b80b1,
+       0x19edc328, 0x87bf4bdd, 0xc9b240e5, 0xe9ee4b1b, 0x4382aee7, 0x535b6b41,
+       0xf3bec5da
+#endif  /* !USE_WEAK_SEEDING */
+};
+
+/*
+ * fptr and rptr are two pointers into the state info, a front and a rear
+ * pointer.  These two pointers are always rand_sep places aparts, as they
+ * cycle cyclically through the state information.  (Yes, this does mean we
+ * could get away with just one pointer, but the code for random() is more
+ * efficient this way).  The pointers are left positioned as they would be
+ * from the call
+ *
+ *     initstate(1, randtbl, 128);
+ *
+ * (The position of the rear pointer, rptr, is really 0 (as explained above
+ * 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];
+
+/*
+ * The following things are the pointer to the state information table, the
+ * type of the current generator, the degree of the current polynomial being
+ * used, and the separation between the two pointers.  Note that for efficiency
+ * of random(), we remember the first location of the state information, not
+ * the zeroeth.  Hence it is valid to access state[-1], which is used to
+ * store the type of the R.N.G.  Also, we remember the last location, since
+ * 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 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 inline long good_rand P((long));
+
+static inline long
+good_rand (
+       register long x
+       )
+{
+#ifdef  USE_WEAK_SEEDING
+/*
+ * Historic implementation compatibility.
+ * The random sequences do not vary much with the seed,
+ * even with overflowing.
+ */
+       return (1103515245 * x + 12345);
+#else   /* !USE_WEAK_SEEDING */
+/*
+ * Compute x = (7^5 * x) mod (2^31 - 1)
+ * wihout overflowing 31 bits:
+ *      (2^31 - 1) = 127773 * (7^5) + 2836
+ * From "Random number generators: good ones are hard to find",
+ * Park and Miller, Communications of the ACM, vol. 31, no. 10,
+ * October 1988, p. 1195.
+ */
+       register long hi, lo;
+
+       hi = x / 127773;
+       lo = x % 127773;
+       x = 16807 * lo - 2836 * hi;
+       if (x <= 0)
+               x += 0x7fffffff;
+       return (x);
+#endif  /* !USE_WEAK_SEEDING */
+}
+
+/*
+ * srandom:
+ *
+ * Initialize the random number generator based on the given seed.  If the
+ * type is the trivial no-state-information type, just remember the seed.
+ * Otherwise, initializes state[] based on the given "seed" via a linear
+ * congruential generator.  Then, the pointers are set to known locations
+ * that are exactly rand_sep places apart.  Lastly, it cycles the state
+ * information a given number of times to get rid of any initial dependencies
+ * introduced by the L.C.R.N.G.  Note that the initialization of randtbl[]
+ * for default usage relies on values produced by this routine.
+ */
+void
+ntp_srandom(
+       unsigned long x
+       )
+{
+       register long i;
+
+       if (rand_type == TYPE_0)
+               state[0] = x;
+       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();
+       }
+}
+
+/*
+ * srandomdev:
+ *
+ * Many programs choose the seed value in a totally predictable manner.
+ * This often causes problems.  We seed the generator using the much more
+ * secure urandom(4) interface.  Note that this particular seeding
+ * procedure can generate states which are impossible to reproduce by
+ * calling srandom() with any value, since the succeeding terms in the
+ * state buffer are no longer derived from the LC algorithm applied to
+ * a fixed seed.
+ */
+#ifdef NEED_SRANDOMDEV
+void
+ntp_srandomdev( void )
+{
+       struct timeval tv;
+       unsigned long junk;     /* Purposely used uninitialized */
+
+       GETTIMEOFDAY(&tv, NULL);
+       ntp_srandom(getpid() ^ tv.tv_sec ^ tv.tv_usec ^ junk);
+       return;
+}
+#endif
+
+/*
+ * initstate:
+ *
+ * Initialize the state information in the given array of n bytes for future
+ * random number generation.  Based on the number of bytes we are given, and
+ * the break values for the different R.N.G.'s, we choose the best (largest)
+ * one we can and set things up for it.  srandom() is then called to
+ * initialize the state information.
+ *
+ * Note that on return from srandom(), we set state[-1] to be the type
+ * multiplexed with the current value of the rear pointer; this is so
+ * successive calls to initstate() won't lose this information and will be
+ * able to restart with setstate().
+ *
+ * Note: the first thing we do is save the current state, if any, just like
+ * setstate() so that it doesn't matter when initstate is called.
+ *
+ * Returns a pointer to the old state.
+ *
+ * Note: The Sparc platform requires that arg_state begin on a long
+ * word boundary; otherwise a bus error will occur. Even so, lint will
+ * complain about mis-alignment, but you should disregard these messages.
+ */
+char *
+ntp_initstate(
+       unsigned long seed,             /* seed for R.N.G. */
+       char *arg_state,                /* pointer to state array */
+       long n                          /* # bytes of state info */
+       )
+{
+       register char *ostate = (char *)(&state[-1]);
+       register long *long_arg_state = (long *) arg_state;
+
+       if (rand_type == TYPE_0)
+               state[-1] = rand_type;
+       else
+               state[-1] = MAX_TYPES * (rptr - state) + rand_type;
+       if (n < BREAK_0) {
+               (void)fprintf(stderr,
+                   "random: not enough state (%ld bytes); ignored.\n", n);
+               return(0);
+       }
+       if (n < BREAK_1) {
+               rand_type = TYPE_0;
+               rand_deg = DEG_0;
+               rand_sep = SEP_0;
+       } else if (n < BREAK_2) {
+               rand_type = TYPE_1;
+               rand_deg = DEG_1;
+               rand_sep = SEP_1;
+       } else if (n < BREAK_3) {
+               rand_type = TYPE_2;
+               rand_deg = DEG_2;
+               rand_sep = SEP_2;
+       } else if (n < BREAK_4) {
+               rand_type = TYPE_3;
+               rand_deg = DEG_3;
+               rand_sep = SEP_3;
+       } else {
+               rand_type = TYPE_4;
+               rand_deg = DEG_4;
+               rand_sep = SEP_4;
+       }
+       state = (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)
+               long_arg_state[0] = rand_type;
+       else
+               long_arg_state[0] = MAX_TYPES * (rptr - state) + rand_type;
+       return(ostate);
+}
+
+/*
+ * setstate:
+ *
+ * Restore the state from the given state array.
+ *
+ * Note: it is important that we also remember the locations of the pointers
+ * in the current state information, and restore the locations of the pointers
+ * from the old state information.  This is done by multiplexing the pointer
+ * location into the zeroeth word of the state information.
+ *
+ * Note that due to the order in which things are done, it is OK to call
+ * setstate() with the same state as the current state.
+ *
+ * Returns a pointer to the old state information.
+ *
+ * Note: The Sparc platform requires that arg_state begin on a long
+ * word boundary; otherwise a bus error will occur. Even so, lint will
+ * complain about mis-alignment, but you should disregard these messages.
+ */
+char *
+ntp_setstate(
+       char *arg_state                 /* pointer to state array */
+       )
+{
+       register long *new_state = (long *) arg_state;
+       register long type = new_state[0] % MAX_TYPES;
+       register long rear = new_state[0] / MAX_TYPES;
+       char *ostate = (char *)(&state[-1]);
+
+       if (rand_type == TYPE_0)
+               state[-1] = rand_type;
+       else
+               state[-1] = MAX_TYPES * (rptr - state) + rand_type;
+       switch(type) {
+       case TYPE_0:
+       case TYPE_1:
+       case TYPE_2:
+       case TYPE_3:
+       case TYPE_4:
+               rand_type = type;
+               rand_deg = degrees[type];
+               rand_sep = seps[type];
+               break;
+       default:
+               (void)fprintf(stderr,
+                   "random: state info corrupted; not changed.\n");
+       }
+       state = (long *) (new_state + 1);
+       if (rand_type != TYPE_0) {
+               rptr = &state[rear];
+               fptr = &state[(rear + rand_sep) % rand_deg];
+       }
+       end_ptr = &state[rand_deg];             /* set end_ptr too */
+       return(ostate);
+}
+
+/*
+ * random:
+ *
+ * If we are using the trivial TYPE_0 R.N.G., just do the old linear
+ * congruential bit.  Otherwise, we do our fancy trinomial stuff, which is
+ * the same in all the other cases due to all the global variables that have
+ * been set up.  The basic operation is to add the number at the rear pointer
+ * into the one at the front pointer.  Then both pointers are advanced to
+ * the next location cyclically in the table.  The value returned is the sum
+ * generated, reduced to 31 bits by throwing away the "least random" low bit.
+ *
+ * Note: the code takes advantage of the fact that both the front and
+ * rear pointers can't wrap on the same call by not testing the rear
+ * pointer if the front one has wrapped.
+ *
+ * Returns a 31-bit random number.
+ */
+long
+ntp_random( void )
+{
+       register long i;
+       register long *f, *r;
+
+       if (rand_type == TYPE_0) {
+               i = state[0];
+               state[0] = i = (good_rand(i)) & 0x7fffffff;
+       } else {
+               /*
+                * Use local variables rather than static variables for speed.
+                */
+               f = fptr; r = rptr;
+               *f += *r;
+               i = (*f >> 1) & 0x7fffffff;     /* chucking least random bit */
+               if (++f >= end_ptr) {
+                       f = state;
+                       ++r;
+               }
+               else if (++r >= end_ptr) {
+                       r = state;
+               }
+
+               fptr = f; rptr = r;
+       }
+       return(i);
+}
diff --git a/libntp/ntp_rfc2553.c b/libntp/ntp_rfc2553.c
new file mode 100644 (file)
index 0000000..017ef83
--- /dev/null
@@ -0,0 +1,443 @@
+/*
+ * Copyright (C) 1995, 1996, 1997, and 1998 WIDE Project.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the project 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 PROJECT 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 PROJECT 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.
+ */
+
+/*
+ * Copyright (c) 1982, 1986, 1990, 1993
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 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.
+ *
+ */
+
+/*
+ * Compatability shims with the rfc2553 API to simplify ntp.
+ */
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <ctype.h>
+#include <sys/socket.h>
+#include <isc/net.h>
+#ifdef HAVE_NETINET_IN_H
+#include <netinet/in.h>
+#endif
+#include "ntp_rfc2553.h"
+
+#include "ntpd.h"
+#include "ntp_malloc.h"
+#include "ntp_stdlib.h"
+#include "ntp_string.h"
+
+#ifndef ISC_PLATFORM_HAVEIPV6
+
+static char *ai_errlist[] = {
+       "Success",
+       "Address family for hostname not supported",    /* EAI_ADDRFAMILY */
+       "Temporary failure in name resolution",         /* EAI_AGAIN      */
+       "Invalid value for ai_flags",                   /* EAI_BADFLAGS   */
+       "Non-recoverable failure in name resolution",   /* EAI_FAIL       */
+       "ai_family not supported",                      /* EAI_FAMILY     */
+       "Memory allocation failure",                    /* EAI_MEMORY     */
+       "No address associated with hostname",          /* EAI_NODATA     */
+       "hostname nor servname provided, or not known", /* EAI_NONAME     */
+       "servname not supported for ai_socktype",       /* EAI_SERVICE    */
+       "ai_socktype not supported",                    /* EAI_SOCKTYPE   */
+       "System error returned in errno",               /* EAI_SYSTEM     */
+       "Invalid value for hints",                      /* EAI_BADHINTS   */
+       "Resolved protocol is unknown",                 /* EAI_PROTOCOL   */
+       "Unknown error",                                /* EAI_MAX        */
+};
+
+/*
+ * Local declaration
+ */
+int
+DNSlookup_name(
+       const char *name,
+       int ai_family,
+       struct hostent **Addresses
+);
+
+#ifndef SYS_WINNT
+/*
+ * Encapsulate gethostbyname to control the error code
+ */
+int
+DNSlookup_name(
+       const char *name,
+       int ai_family,
+       struct hostent **Addresses
+)
+{
+       *Addresses = gethostbyname(name);
+       return (h_errno);
+}
+#endif
+
+static int do_nodename P((const char *nodename, struct addrinfo *ai,
+    const struct addrinfo *hints));
+
+int
+getaddrinfo (const char *nodename, const char *servname,
+       const struct addrinfo *hints, struct addrinfo **res)
+{
+       int rval;
+       struct servent *sp;
+       struct addrinfo *ai = NULL;
+       int port;
+       const char *proto = NULL;
+       int family, socktype, flags, protocol;
+
+
+       /*
+        * If no name is provide just return an error
+        */
+       if (nodename == NULL && servname == NULL)
+               return (EAI_NONAME);
+       
+       ai = calloc(sizeof(struct addrinfo), 1);
+       if (ai == NULL)
+               return (EAI_MEMORY);
+
+       /*
+        * Copy default values from hints, if available
+        */
+       if (hints != NULL) {
+               ai->ai_flags = hints->ai_flags;
+               ai->ai_family = hints->ai_family;
+               ai->ai_socktype = hints->ai_socktype;
+               ai->ai_protocol = hints->ai_protocol;
+
+               family = hints->ai_family;
+               socktype = hints->ai_socktype;
+               protocol = hints->ai_protocol;
+               flags = hints->ai_flags;
+
+               switch (family) {
+               case AF_UNSPEC:
+                       switch (hints->ai_socktype) {
+                       case SOCK_STREAM:
+                               proto = "tcp";
+                               break;
+                       case SOCK_DGRAM:
+                               proto = "udp";
+                               break;
+                       }
+                       break;
+               case AF_INET:
+               case AF_INET6:
+                       switch (hints->ai_socktype) {
+                       case 0:
+                               break;
+                       case SOCK_STREAM:
+                               proto = "tcp";
+                               break;
+                       case SOCK_DGRAM:
+                               proto = "udp";
+                               break;
+                       case SOCK_RAW:
+                               break;
+                       default:
+                               return (EAI_SOCKTYPE);
+                       }
+                       break;
+#ifdef AF_LOCAL
+               case AF_LOCAL:
+                       switch (hints->ai_socktype) {
+                       case 0:
+                               break;
+                       case SOCK_STREAM:
+                               break;
+                       case SOCK_DGRAM:
+                               break;
+                       default:
+                               return (EAI_SOCKTYPE);
+                       }
+                       break;
+#endif
+               default:
+                       return (EAI_FAMILY);
+               }
+       } else {
+               protocol = 0;
+               family = 0;
+               socktype = 0;
+               flags = 0;
+       }
+
+       rval = do_nodename(nodename, ai, hints);
+       if (rval != 0) {
+               freeaddrinfo(ai);
+               return (rval);
+       }
+
+       /*
+        * First, look up the service name (port) if it was
+        * requested.  If the socket type wasn't specified, then
+        * try and figure it out.
+        */
+       if (servname != NULL) {
+               char *e;
+
+               port = strtol(servname, &e, 10);
+               if (*e == '\0') {
+                       if (socktype == 0)
+                               return (EAI_SOCKTYPE);
+                       if (port < 0 || port > 65535)
+                               return (EAI_SERVICE);
+                       port = htons((unsigned short) port);
+               } else {
+                       sp = getservbyname(servname, proto);
+                       if (sp == NULL)
+                               return (EAI_SERVICE);
+                       port = sp->s_port;
+                       if (socktype == 0) {
+                               if (strcmp(sp->s_proto, "tcp") == 0)
+                                       socktype = SOCK_STREAM;
+                               else if (strcmp(sp->s_proto, "udp") == 0)
+                                       socktype = SOCK_DGRAM;
+                       }
+               }
+       } else
+               port = 0;
+
+       /*
+        *
+        * Set up the port number
+        */
+       if (ai->ai_family == AF_INET)
+               ((struct sockaddr_in *)ai->ai_addr)->sin_port = (unsigned short) port;
+       else if (ai->ai_family == AF_INET6)
+               ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port = (unsigned short) port;
+       *res = ai;
+       return (0);
+}
+
+void
+freeaddrinfo(struct addrinfo *ai)
+{
+       if (ai->ai_canonname != NULL)
+       {
+               free(ai->ai_canonname);
+               ai->ai_canonname = NULL;
+       }
+       if (ai->ai_addr != NULL)
+       {
+               free(ai->ai_addr);
+               ai->ai_addr = NULL;
+       }
+       free(ai);
+       ai = NULL;
+}
+
+int
+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);
+       hp = gethostbyaddr(
+           (const char *)&((const struct sockaddr_in *)sa)->sin_addr,
+           4, AF_INET);
+       if (hp == NULL) {
+               if (h_errno == TRY_AGAIN)
+                       return (EAI_AGAIN);
+               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';
+               }
+       }
+       return (0);
+}
+
+char *
+gai_strerror(int ecode)
+{
+       if (ecode < 0 || ecode > EAI_MAX)
+               ecode = EAI_MAX;
+       return ai_errlist[ecode];
+}
+
+static int
+do_nodename(
+       const char *nodename,
+       struct addrinfo *ai,
+       const struct addrinfo *hints)
+{
+       struct hostent *hp = NULL;
+       struct sockaddr_in *sockin;
+       struct sockaddr_in6 *sockin6;
+       int errval;
+
+       ai->ai_addr = calloc(sizeof(struct sockaddr_storage), 1);
+       if (ai->ai_addr == NULL)
+               return (EAI_MEMORY);
+
+       /*
+        * For an empty node name just use the wildcard.
+        * NOTE: We need to assume that the address family is
+        * set elsewhere so that we can set the appropriate wildcard
+        */
+       if (nodename == NULL) {
+               ai->ai_addrlen = sizeof(struct sockaddr_storage);
+               if (ai->ai_family == AF_INET)
+               {
+                       sockin = (struct sockaddr_in *)ai->ai_addr;
+                       sockin->sin_family = (short) ai->ai_family;
+                       sockin->sin_addr.s_addr = htonl(INADDR_ANY);
+               }
+               else
+               {
+                       sockin6 = (struct sockaddr_in6 *)ai->ai_addr;
+                       sockin6->sin6_family = (short) ai->ai_family;
+                       /*
+                        * we have already zeroed out the address
+                        * so we don't actually need to do this
+                        * This assignment is causing problems so
+                        * we don't do what this would do.
+                        sockin6->sin6_addr = in6addr_any;
+                        */
+               }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               ai->ai_addr->sa_len = SOCKLEN(ai->ai_addr);
+#endif
+
+               return (0);
+       }
+
+       /*
+        * See if we have an IPv6 address
+        */
+       if(strchr(nodename, ':') != NULL) {
+               if (inet_pton(AF_INET6, nodename,
+                   &((struct sockaddr_in6 *)ai->ai_addr)->sin6_addr) == 1) {
+                       ((struct sockaddr_in6 *)ai->ai_addr)->sin6_family = AF_INET6;
+                       ai->ai_family = AF_INET6;
+                       ai->ai_addrlen = sizeof(struct sockaddr_in6);
+                       return (0);
+               }
+       }
+
+       /*
+        * See if we have an IPv4 address
+        */
+       if (inet_pton(AF_INET, nodename,
+           &((struct sockaddr_in *)ai->ai_addr)->sin_addr) == 1) {
+               ((struct sockaddr *)ai->ai_addr)->sa_family = AF_INET;
+               ai->ai_family = AF_INET;
+               ai->ai_addrlen = sizeof(struct sockaddr_in);
+               return (0);
+       }
+
+       /*
+        * If the numeric host flag is set, don't attempt resolution
+        */
+       if (hints != NULL && (hints->ai_flags & AI_NUMERICHOST))
+               return (EAI_NONAME);
+
+       /*
+        * Look for a name
+        */
+
+       errval = DNSlookup_name(nodename, AF_INET, &hp);
+
+       if (hp == NULL) {
+               if (errval == TRY_AGAIN || errval == EAI_AGAIN)
+                       return (EAI_AGAIN);
+               else if (errval == EAI_NONAME) {
+                       if (inet_pton(AF_INET, nodename,
+                           &((struct sockaddr_in *)ai->ai_addr)->sin_addr) == 1) {
+                               ((struct sockaddr *)ai->ai_addr)->sa_family = AF_INET;
+                               ai->ai_family = AF_INET;
+                               ai->ai_addrlen = sizeof(struct sockaddr_in);
+                               return (0);
+                       }
+                       return (errval);
+               }
+               else
+               {
+                       return (errval);
+               }
+       }
+       ai->ai_family = hp->h_addrtype;
+       ai->ai_addrlen = sizeof(struct sockaddr);
+       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
+       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);
+       }
+       return (0);
+}
+
+#endif /* !ISC_PLATFORM_HAVEIPV6 */
diff --git a/libntp/numtoa.c b/libntp/numtoa.c
new file mode 100644 (file)
index 0000000..de95118
--- /dev/null
@@ -0,0 +1,24 @@
+/*
+ * numtoa - return asciized network numbers store in local array space
+ */
+#include <stdio.h>
+
+#include "ntp_fp.h"
+#include "lib_strbuf.h"
+#include "ntp_stdlib.h"
+
+char *
+numtoa(
+       u_int32 num
+       )
+{
+       register u_int32 netnum;
+       register char *buf;
+
+       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);
+       return buf;
+}
diff --git a/libntp/numtohost.c b/libntp/numtohost.c
new file mode 100644 (file)
index 0000000..dd51c5d
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * numtohost - convert network number to host name.
+ */
+
+#include "ntp_fp.h"
+#include "ntp_stdlib.h"
+#include "lib_strbuf.h"
+
+#define        LOOPBACKNET     0x7f000000
+#define        LOOPBACKHOST    0x7f000001
+#define        LOOPBACKNETMASK 0xff000000
+
+char *
+numtohost(
+       u_int32 netnum
+       )
+{
+       char *bp;
+       struct hostent *hp;
+
+       /*
+        * This is really gross, but saves lots of hanging looking for
+        * hostnames for the radio clocks.  Don't bother looking up
+        * addresses on the loopback network except for the loopback
+        * host itself.
+        */
+       if ((((ntohl(netnum) & LOOPBACKNETMASK) == LOOPBACKNET)
+            && (ntohl(netnum) != LOOPBACKHOST))
+           || ((hp = gethostbyaddr((char *)&netnum, sizeof netnum, AF_INET))
+               == 0))
+           return numtoa(netnum);
+       
+       LIB_GETBUF(bp);
+       
+       bp[LIB_BUFLENGTH-1] = '\0';
+       (void) strncpy(bp, hp->h_name, LIB_BUFLENGTH-1);
+       return bp;
+}
diff --git a/libntp/octtoint.c b/libntp/octtoint.c
new file mode 100644 (file)
index 0000000..f792b2b
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * octtoint - convert an ascii string in octal to an unsigned
+ *           long, with error checking
+ */
+#include <stdio.h>
+#include <ctype.h>
+
+#include "ntp_stdlib.h"
+
+int
+octtoint(
+       const char *str,
+       u_long *ival
+       )
+{
+       register u_long u;
+       register const char *cp;
+
+       cp = str;
+
+       if (*cp == '\0')
+           return 0;
+
+       u = 0;
+       while (*cp != '\0') {
+               if (!isdigit((int)*cp) || *cp == '8' || *cp == '9')
+                   return 0;
+               if (u >= 0x20000000)
+                   return 0;   /* overflow */
+               u <<= 3;
+               u += *cp++ - '0';       /* ascii dependent */
+       }
+       *ival = u;
+       return 1;
+}
diff --git a/libntp/prettydate.c b/libntp/prettydate.c
new file mode 100644 (file)
index 0000000..55adf64
--- /dev/null
@@ -0,0 +1,132 @@
+/*
+ * prettydate - convert a time stamp to something readable
+ */
+#include <stdio.h>
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"      /* includes <sys/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"
+};
+
+/* Helper function to handle possible wraparound of the ntp epoch.
+
+   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
+       )
+{
+       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;
+
+       curr_year = 1900 + tm->tm_year;
+
+       /* Convert the ntp timestamp to a unix utc seconds count: */
+       t = (time_t) ntp - JAN_1970;
+
+       /* Check that the ntp timestamp is not before a 136 year window centered
+          around the current year:
+
+          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);
+
+#if SIZEOF_TIME_T < 4
+# include "Bletch: sizeof(time_t) < 4!"
+#endif
+
+#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;
+
+               /* Epoch wraparound: Add 2^32 seconds! */
+               t += (time_t) 65536 << 16;
+#endif /* SIZEOF_TIME_T > 4 */
+       }
+       return tm;
+}
+
+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;
+}
+
+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) */
+
+       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;
+}
diff --git a/libntp/recvbuff.c b/libntp/recvbuff.c
new file mode 100644 (file)
index 0000000..6665686
--- /dev/null
@@ -0,0 +1,246 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include "ntp_machine.h"
+#include "ntp_fp.h"
+#include "ntp_syslog.h"
+#include "ntp_stdlib.h"
+#include "ntp_io.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 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 */
+
+static ISC_LIST(recvbuf_t)     full_recv_list; /* Currently used recv buffers */
+static ISC_LIST(recvbuf_t)     free_recv_list; /* Currently unused buffers */
+       
+#if defined(SYS_WINNT)
+
+/*
+ * For Windows we need to set up a lock to manipulate the
+ * recv buffers to prevent corruption. We keep it lock for as
+ * short a time as possible
+ */
+static CRITICAL_SECTION RecvLock;
+# define LOCK()                EnterCriticalSection(&RecvLock)
+# define UNLOCK()      LeaveCriticalSection(&RecvLock)
+#else
+# define LOCK()        
+# define UNLOCK()      
+#endif
+
+u_long
+free_recvbuffs (void)
+{
+       return free_recvbufs;
+}
+
+u_long
+full_recvbuffs (void)
+{
+       return full_recvbufs;
+}
+
+u_long
+total_recvbuffs (void)
+{
+       return total_recvbufs;
+}
+
+u_long
+lowater_additions(void)
+{
+       return lowater_adds;
+}
+
+static 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
+}
+
+static void
+create_buffers(int nbufs)
+{
+       register recvbuf_t *bufp;
+       int i, abuf;
+
+       abuf = nbufs + buffer_shortfall;
+       buffer_shortfall = 0;
+
+       bufp = (recvbuf_t *) emalloc(abuf*sizeof(recvbuf_t));
+
+       for (i = 0; i < abuf; i++)
+       {
+               memset((char *) bufp, 0, sizeof(recvbuf_t));
+               ISC_LIST_APPEND(free_recv_list, bufp, link);
+               bufp++;
+               free_recvbufs++;
+               total_recvbufs++;
+       }
+       lowater_adds++;
+}
+
+void
+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;
+
+       create_buffers(nbufs);
+
+#if defined(SYS_WINNT)
+       InitializeCriticalSection(&RecvLock);
+#endif
+
+}
+
+/*
+ * freerecvbuf - make a single recvbuf available for reuse
+ */
+void
+freerecvbuf(recvbuf_t *rb)
+{
+       if (rb == NULL) {
+               msyslog(LOG_ERR, "freerecvbuff received NULL buffer");
+               return;
+       }
+
+       LOCK();
+       (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
+       free_recvbufs++;
+       UNLOCK();
+}
+
+       
+void
+add_full_recv_buffer(recvbuf_t *rb)
+{
+       if (rb == NULL) {
+               msyslog(LOG_ERR, "add_full_recv_buffer received NULL buffer");
+               return;
+       }
+       LOCK();
+       ISC_LIST_APPEND(full_recv_list, rb, link);
+       full_recvbufs++;
+       UNLOCK();
+}
+
+recvbuf_t *
+get_free_recv_buffer(void)
+{
+       recvbuf_t * buffer = NULL;
+       LOCK();
+       buffer = ISC_LIST_HEAD(free_recv_list);
+       if (buffer != NULL)
+       {
+               ISC_LIST_DEQUEUE(free_recv_list, buffer, link);
+               free_recvbufs--;
+               initialise_buffer(buffer);
+               (buffer->used)++;
+       }
+       else
+       {
+               buffer_shortfall++;
+       }
+       UNLOCK();
+       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)
+       {
+               create_buffers(RECV_INC);
+               buffer = get_free_recv_buffer();
+       }
+       return (buffer);
+}
+#endif
+
+recvbuf_t *
+get_full_recv_buffer(void)
+{
+       recvbuf_t *rbuf;
+       LOCK();
+       
+#ifdef HAVE_SIGNALED_IO
+       /*
+        * make sure there are free buffers when we
+        * wander off to do lengthy paket 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) {
+               /*
+                * try to get us some more buffers
+                */
+               create_buffers(RECV_INC);
+       }
+#endif
+
+       /*
+        * try to grab a full buffer
+        */
+       rbuf = ISC_LIST_HEAD(full_recv_list);
+       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;
+       }
+       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)
+               return (ISC_TRUE);
+       else
+               return (ISC_FALSE);
+}
diff --git a/libntp/refnumtoa.c b/libntp/refnumtoa.c
new file mode 100644 (file)
index 0000000..7c5d96e
--- /dev/null
@@ -0,0 +1,36 @@
+/*
+ * refnumtoa - return asciized refclock addresses stored in local array space
+ */
+#include <stdio.h>
+
+#include "ntp_fp.h"
+#include "lib_strbuf.h"
+#include "ntp_stdlib.h"
+
+char *
+refnumtoa(
+       struct sockaddr_storage* num
+       )
+{
+       register u_int32 netnum;
+       register char *buf;
+       register const char *rclock;
+
+       LIB_GETBUF(buf);
+
+       if(num->ss_family == AF_INET) {
+               netnum = ntohl(((struct sockaddr_in*)num)->sin_addr.s_addr);
+               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);
+
+       }
+       else {
+               (void)sprintf(buf, "refclock address type not implemented yet, use IPv4 refclock address.");
+       }
+       return buf;
+}
diff --git a/libntp/snprintf.c b/libntp/snprintf.c
new file mode 100644 (file)
index 0000000..7588b84
--- /dev/null
@@ -0,0 +1,62 @@
+#include <config.h>
+
+#if !HAVE_SNPRINTF
+#include <sys/types.h>
+
+#ifdef __STDC__
+#include <stdarg.h>
+#else
+#include <varargs.h>
+#endif
+#include <stdio.h>
+
+#include "l_stdlib.h"
+
+#ifdef __STDC__
+int snprintf(char *str, size_t n, const char *fmt, ...)
+#else
+int snprintf(str, n, fmt, va_alist)
+       char *str;
+       size_t n;
+       const char *fmt;
+       va_dcl
+#endif
+{
+       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);
+       va_end(ap);
+       return (strlen(rp));
+#else
+       rval = vsprintf(str, fmt, ap);
+       va_end(ap);
+       return (rval);
+#endif
+}
+
+int
+vsnprintf(
+       char *str,
+       size_t n,
+       const char *fmt,
+       va_list ap
+       )
+{
+#ifdef VSPRINTF_CHARSTAR
+       return (strlen(vsprintf(str, fmt, ap)));
+#else
+       return (vsprintf(str, fmt, ap));
+#endif
+}
+#else
+int snprintf_bs;
+#endif
diff --git a/libntp/socktoa.c b/libntp/socktoa.c
new file mode 100644 (file)
index 0000000..fb41b22
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * socktoa - return a numeric host name from a sockaddr_storage structure
+ */
+
+#include <config.h>
+
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <arpa/inet.h>
+
+#ifdef ISC_PLATFORM_NEEDNTOP
+#include <isc/net.h>
+#endif
+
+#include <stdio.h>
+
+#include "ntp_fp.h"
+#include "lib_strbuf.h"
+#include "ntp_stdlib.h"
+#include "ntp.h"
+
+char *
+socktoa(
+       struct sockaddr_storage* sock
+       )
+{
+       register char *buffer;
+
+       LIB_GETBUF(buffer);
+
+       if (sock == NULL)
+               strcpy(buffer, "null");
+       else
+       {
+
+               switch(sock->ss_family) {
+
+               default:
+               case AF_INET :
+                       inet_ntop(AF_INET, &GET_INADDR(*sock), buffer,
+                           LIB_BUFLENGTH);
+                       break;
+
+               case AF_INET6 :
+                       inet_ntop(AF_INET6, &GET_INADDR6(*sock), buffer,
+                           LIB_BUFLENGTH);
+#if 0
+               default:
+                       strcpy(buffer, "unknown");
+#endif
+               }
+       }
+       return buffer;
+}
diff --git a/libntp/socktohost.c b/libntp/socktohost.c
new file mode 100644 (file)
index 0000000..7aafdc7
--- /dev/null
@@ -0,0 +1,31 @@
+/*
+ * socktoa - return a numeric host name from a sockaddr_storage structure
+ */
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+
+#include <arpa/inet.h>
+
+#include <stdio.h>
+
+#include "ntp_fp.h"
+#include "lib_strbuf.h"
+#include "ntp_stdlib.h"
+#include "ntp.h"
+
+
+char *
+socktohost(
+       struct sockaddr_storage* sock
+       )
+{
+       register char *buffer;
+
+       LIB_GETBUF(buffer);
+       if (getnameinfo((struct sockaddr *)sock, SOCKLEN(sock), buffer,
+           LIB_BUFLENGTH /* NI_MAXHOST*/, NULL, 0, 0))
+               return stoa(sock);
+
+       return buffer;
+}
diff --git a/libntp/statestr.c b/libntp/statestr.c
new file mode 100644 (file)
index 0000000..85552b3
--- /dev/null
@@ -0,0 +1,305 @@
+/*
+ * pretty printing of status information
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+#include <stdio.h>
+#include "ntp_stdlib.h"
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "lib_strbuf.h"
+#include "ntp_refclock.h"
+#include "ntp_control.h"
+#include "ntp_string.h"
+
+/*
+ * Structure for turning various constants into a readable string.
+ */
+struct codestring {
+       int code;
+       const char *string;
+};
+
+/*
+ * Leap values
+ */
+static
+struct codestring leap_codes[] = {
+       { LEAP_NOWARNING,       "leap_none" },
+       { LEAP_ADDSECOND,       "leap_add_sec" },
+       { LEAP_DELSECOND,       "leap_del_sec" },
+       { LEAP_NOTINSYNC,       "sync_alarm" },
+       { -1,   "leap" }
+};
+
+/*
+ * Clock source
+ */
+static
+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_NTP,       "sync_ntp" },
+       { CTL_SST_TS_UDPTIME,   "sync_udp/time" },
+       { CTL_SST_TS_WRSTWTCH,  "sync_wristwatch" },
+       { CTL_SST_TS_TELEPHONE, "sync_telephone" },
+       { -1,                   "sync" }
+};
+
+
+/*
+ * Peer selection
+ */
+static
+struct codestring select_codes[] = {
+       { CTL_PST_SEL_REJECT,   "selreject" },
+       { 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_SYSPEER,  "sel_sys.peer" },
+       { CTL_PST_SEL_PPS,      "sel_pps.peer" },
+       { -1,                   "sel" }
+};
+
+
+/*
+ * Clock status
+ */
+static
+struct codestring clock_codes[] = {
+       { CTL_CLK_OKAY,         "clk_okay" },
+       { CTL_CLK_NOREPLY,      "clk_noreply" },
+       { CTL_CLK_BADFORMAT,    "clk_badformat" },
+       { CTL_CLK_FAULT,        "clk_fault" },
+       { CTL_CLK_PROPAGATION,  "clk_badsignal" },
+       { CTL_CLK_BADDATE,      "clk_baddate" },
+       { CTL_CLK_BADTIME,      "clk_badtime" },
+       { -1,                   "clk" }
+};
+
+
+/*
+ * System Events
+ */
+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" }
+};
+
+/*
+ * Peer events
+ */
+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" }
+};
+
+#ifdef OPENSSL
+/*
+ * Crypto events
+ */
+static
+struct codestring crypto_codes[] = {
+       { XEVNT_OK & ~CRPT_EVENT,       "success" },
+       { XEVNT_LEN & ~CRPT_EVENT,      "bad_field_format_or_length" },
+       { XEVNT_TSP & ~CRPT_EVENT,      "bad_timestamp" },
+       { XEVNT_FSP & ~CRPT_EVENT,      "bad_filestamp" },
+       { XEVNT_PUB & ~CRPT_EVENT,      "bad_or_missing_public_key" },
+       { XEVNT_MD & ~CRPT_EVENT,       "unsupported_digest_type" },
+       { XEVNT_KEY & ~CRPT_EVENT,      "unsupported_identity_type" },
+       { 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_CKY & ~CRPT_EVENT,      "bad_or_missing_cookie" },
+       { XEVNT_DAT & ~CRPT_EVENT,      "bad_or_missing_leapsecond_table" },
+       { XEVNT_CRT & ~CRPT_EVENT,      "bad_or_missing_certificate" }, 
+       { XEVNT_ID & ~CRPT_EVENT,       "bad_or_missing_group_key" },
+       { XEVNT_ERR & ~CRPT_EVENT,      "protocol_error" },
+       { XEVNT_SRV & ~CRPT_EVENT,      "server certificate expired" },
+       { -1,                           "crypto" }
+};
+#endif /* OPENSSL */
+
+/* Forwards */
+static const char *getcode P((int, struct codestring *));
+static const char *getevents P((int));
+
+/*
+ * getcode - return string corresponding to code
+ */
+static const char *
+getcode(
+       int code,
+       struct codestring *codetab
+       )
+{
+       static char buf[30];
+
+       while (codetab->code != -1) {
+               if (codetab->code == code)
+                   return codetab->string;
+               codetab++;
+       }
+       (void) sprintf(buf, "%s_%d", codetab->string, code);
+       return buf;
+}
+
+/*
+ * getevents - return a descriptive string for the event count
+ */
+static const char *
+getevents(
+       int cnt
+       )
+{
+       static char buf[20];
+
+       if (cnt == 0)
+           return "no events";
+       (void) sprintf(buf, "%d event%s", cnt, (cnt==1) ? "" : "s");
+       return buf;
+}
+
+/*
+ * statustoa - return a descriptive string for a peer status
+ */
+char *
+statustoa(
+       int type,
+       int st
+       )
+{
+       char *cb;
+       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));
+               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)));
+               if (CTL_PEER_EVENT(st) != EVNT_UNSPEC) {
+                       (void)strcat(cb, ", ");
+                       (void)strcat(cb, 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));
+               break;
+       }
+       return cb;
+}
+
+const char *
+eventstr(
+       int num
+       )
+{
+       if (num & PEER_EVENT)
+               return (getcode(num & ~PEER_EVENT, peer_codes));
+#ifdef OPENSSL
+       else if (num & CRPT_EVENT)
+               return (getcode(num & ~CRPT_EVENT, crypto_codes));
+#endif /* OPENSSL */
+       else
+               return (getcode(num, sys_codes));
+}
+
+const char *
+ceventstr(
+       int num
+       )
+{
+       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/libntp/strdup.c b/libntp/strdup.c
new file mode 100644 (file)
index 0000000..2e26ba7
--- /dev/null
@@ -0,0 +1,28 @@
+#include "ntp_malloc.h"
+
+#if !HAVE_STRDUP
+
+#define NULL 0
+
+char *strdup(const char *s);
+
+char *
+strdup(
+       const char *s
+       )
+{
+        char *cp;
+
+        if (s) {
+                cp = (char *) malloc((unsigned) (strlen(s)+1));
+                if (cp) {
+                        (void) strcpy(cp, s);
+               }
+        } else {
+                cp = (char *) NULL;
+       }
+        return(cp);
+}
+#else
+int strdup_bs;
+#endif
diff --git a/libntp/strerror.c b/libntp/strerror.c
new file mode 100644 (file)
index 0000000..9d8ae8e
--- /dev/null
@@ -0,0 +1,48 @@
+#include <config.h>
+
+#if !HAVE_STRERROR
+/*
+ * Copyright (c) 1988 Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms are permitted
+ * provided that the above copyright notice and this paragraph are
+ * duplicated in all such forms and that any documentation,
+ * advertising materials, and other materials related to such
+ * distribution and use acknowledge that the software was developed
+ * by the University of California, Berkeley.  The name of the
+ * University may not be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
+ * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
+ * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ */
+
+#if defined(LIBC_SCCS) && !defined(lint)
+static const char sccsid[] = "@(#)strerror.c   5.1 (Berkeley) 4/9/89";
+#endif /* LIBC_SCCS and not lint */
+
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <string.h>
+
+#include "l_stdlib.h"
+
+char *
+strerror(
+       int errnum
+       )
+{
+       extern int sys_nerr;
+       extern char *sys_errlist[];
+       static char ebuf[20];
+
+       if ((unsigned int)errnum < sys_nerr)
+               return(sys_errlist[errnum]);
+       (void)sprintf(ebuf, "Unknown error: %d", errnum);
+       return(ebuf);
+}
+#else
+int strerror_bs;
+#endif
diff --git a/libntp/strstr.c b/libntp/strstr.c
new file mode 100644 (file)
index 0000000..a4deb87
--- /dev/null
@@ -0,0 +1,52 @@
+#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/libntp/syssignal.c b/libntp/syssignal.c
new file mode 100644 (file)
index 0000000..6ec4c4c
--- /dev/null
@@ -0,0 +1,133 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <signal.h>
+
+#include "ntp_syslog.h"
+#include "ntp_stdlib.h"
+
+#ifdef HAVE_SIGACTION
+
+void
+signal_no_reset(
+#if defined(__STDC__) || defined(HAVE_STDARG_H)
+       int sig,
+       void (*func) (int)
+#else
+       sig, func
+#endif
+       )
+#if defined(__STDC__) || defined(HAVE_STDARG_H)
+#else
+        int sig;
+        void (*func) P((int));
+#endif
+{
+       int n;
+       struct sigaction vec;
+
+       vec.sa_handler = func;
+       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
+
+#ifdef SA_RESTART
+/* Added for PPS clocks on Solaris 7 which get EINTR errors */
+# ifdef SIGPOLL
+       if (sig == SIGPOLL) vec.sa_flags = SA_RESTART;
+# endif
+# ifdef SIGIO
+       if (sig == SIGIO)   vec.sa_flags = SA_RESTART;
+# endif
+#endif
+
+       while (1)
+       {
+               struct sigaction ovec;
+
+               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) {
+               perror("sigaction");
+               exit(1);
+       }
+}
+
+#elif  HAVE_SIGVEC
+
+void
+signal_no_reset(
+       int sig,
+       RETSIGTYPE (*func) (int)
+       )
+{
+       struct sigvec sv;
+       int n;
+
+       bzero((char *) &sv, sizeof(sv));
+       sv.sv_handler = func;
+       n = sigvec(sig, &sv, (struct sigvec *)NULL);
+       if (n == -1) {
+               perror("sigvec");
+               exit(1);
+       }
+}
+
+#elif  HAVE_SIGSET
+
+void
+signal_no_reset(
+       int sig,
+       RETSIGTYPE (*func) (int)
+       )
+{
+       int n;
+
+       n = sigset(sig, func);
+       if (n == -1) {
+               perror("sigset");
+               exit(1);
+       }
+}
+
+#else
+
+/* Beware!     This implementation resets the signal to SIG_DFL */
+void
+signal_no_reset(
+       int sig,
+       RETSIGTYPE (*func) (int)
+       )
+{
+#ifdef SIG_ERR
+       if (SIG_ERR == signal(sig, func)) {
+#else
+       int n;
+       n = signal(sig, func);
+       if (n == -1) {
+#endif
+               perror("signal");
+               exit(1);
+       }
+}
+
+#endif
diff --git a/libntp/systime.c b/libntp/systime.c
new file mode 100644 (file)
index 0000000..4539b5f
--- /dev/null
@@ -0,0 +1,542 @@
+/*
+ * systime -- routines to fiddle a UNIX clock.
+ *
+ * ATTENTION: Get approval from Dave Mills on all changes to this file!
+ *
+ */
+#include "ntp_machine.h"
+#include "ntp_fp.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 */
+
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+#ifdef HAVE_UTMP_H
+# include <utmp.h>
+#endif /* HAVE_UTMP_H */
+#ifdef HAVE_UTMPX_H
+# include <utmpx.h>
+#endif /* HAVE_UTMPX_H */
+
+/*
+ * 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.
+ *
+ * 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.
+ */
+#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_residual = 0;       /* adjustment residue (s) */
+
+#ifndef SIM
+
+/*
+ * get_systime - return system time in NTP timestamp format.
+ */
+void
+get_systime(
+       l_fp *now               /* system time */
+       )
+{
+       double dtemp;
+
+#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK)
+       struct timespec ts;     /* seconds and nanoseconds */
+
+       /*
+        * 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...
+        */
+# 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;
+
+#else /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
+       struct timeval tv;      /* seconds and microseconds */
+
+       /*
+        * Convert Unix clock from seconds and microseconds to seconds.
+        * Add in unbiased random fuzz beneath the microsecond.
+        */
+       GETTIMEOFDAY(&tv, NULL);
+       now->l_i = tv.tv_sec + JAN_1970;
+       dtemp = tv.tv_usec / 1e6;
+
+#endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
+
+       /*
+        * ntp_random() produces 31 bits (always nonnegative).
+        * This bit is done only after the precision 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--;
+       }
+       dtemp *= FRAC;
+       now->l_uf = (u_int32)dtemp;
+}
+
+
+/*
+ * adj_systime - adjust system time by the argument.
+ */
+#if !defined SYS_WINNT
+int                            /* 0 okay, 1 error */
+adj_systime(
+       double now              /* adjustment (s) */
+       )
+{
+       struct timeval adjtv;   /* new adjustment */
+       struct timeval oadjtv;  /* residual 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;
+       }
+       if (adjtv.tv_sec != 0 || adjtv.tv_usec != 0) {
+               if (adjtime(&adjtv, &oadjtv) < 0) {
+                       msyslog(LOG_ERR, "adj_systime: %m");
+                       return (0);
+               }
+       }
+       return (1);
+}
+#endif
+
+
+/*
+ * step_systime - step the system clock.
+ */
+int
+step_systime(
+       double now
+       )
+{
+       struct timeval timetv, adjtv, oldtimetv;
+       int isneg = 0;
+       double dtemp;
+#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK)
+       struct timespec ts;
+#endif
+
+       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);
+       } else {
+               adjtv.tv_sec = (int32)dtemp;
+               adjtv.tv_usec = (u_int32)((dtemp -
+                   (double)adjtv.tv_sec) * 1e6 + .5);
+       }
+#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);
+#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;
+               }
+       }
+       if (ntp_set_tod(&timetv, NULL) != 0) {
+               msyslog(LOG_ERR, "step-systime: %m");
+               return (0);
+       }
+       sys_residual = 0;
+
+#ifdef NEED_HPUX_ADJTIME
+       /*
+        * CHECKME: is this correct when called by ntpdate?????
+        */
+       _clear_adjtime();
+#endif
+
+       /*
+        * FreeBSD, for example, has:
+        * struct utmp {
+        *         char    ut_line[UT_LINESIZE];
+        *         char    ut_name[UT_NAMESIZE];
+        *         char    ut_host[UT_HOSTSIZE];
+        *         long    ut_time;
+        * };
+        * and appends line="|", name="date", host="", time for the OLD
+        * and appends line="{", name="date", host="", time for the NEW
+        * to _PATH_WTMP .
+        *
+        * Some OSes have utmp, some have utmpx.
+        */
+
+       /*
+        * Write old and new time entries in utmp and wtmp if step
+        * adjustment is greater than one second.
+        *
+        * This might become even Uglier...
+        */
+       if (oldtimetv.tv_sec != timetv.tv_sec)
+       {
+#ifdef HAVE_UTMP_H
+               struct utmp ut;
+#endif
+#ifdef HAVE_UTMPX_H
+               struct utmpx utx;
+#endif
+
+#ifdef HAVE_UTMP_H
+               memset((char *)&ut, 0, sizeof(ut));
+#endif
+#ifdef HAVE_UTMPX_H
+               memset((char *)&utx, 0, sizeof(utx));
+#endif
+
+               /* UTMP */
+
+#ifdef UPDATE_UTMP
+# ifdef HAVE_PUTUTLINE
+               ut.ut_type = OLD_TIME;
+               (void)strcpy(ut.ut_line, OTIME_MSG);
+               ut.ut_time = oldtimetv.tv_sec;
+               pututline(&ut);
+               setutent();
+               ut.ut_type = NEW_TIME;
+               (void)strcpy(ut.ut_line, NTIME_MSG);
+               ut.ut_time = timetv.tv_sec;
+               pututline(&ut);
+               endutent();
+# else /* not HAVE_PUTUTLINE */
+# endif /* not HAVE_PUTUTLINE */
+#endif /* UPDATE_UTMP */
+
+               /* UTMPX */
+
+#ifdef UPDATE_UTMPX
+# ifdef HAVE_PUTUTXLINE
+               utx.ut_type = OLD_TIME;
+               (void)strcpy(utx.ut_line, OTIME_MSG);
+               utx.ut_tv = oldtimetv;
+               pututxline(&utx);
+               setutxent();
+               utx.ut_type = NEW_TIME;
+               (void)strcpy(utx.ut_line, NTIME_MSG);
+               utx.ut_tv = timetv;
+               pututxline(&utx);
+               endutxent();
+# else /* not HAVE_PUTUTXLINE */
+# endif /* not HAVE_PUTUTXLINE */
+#endif /* UPDATE_UTMPX */
+
+               /* WTMP */
+
+#ifdef UPDATE_WTMP
+# ifdef HAVE_PUTUTLINE
+               utmpname(WTMP_FILE);
+               ut.ut_type = OLD_TIME;
+               (void)strcpy(ut.ut_line, OTIME_MSG);
+               ut.ut_time = oldtimetv.tv_sec;
+               pututline(&ut);
+               ut.ut_type = NEW_TIME;
+               (void)strcpy(ut.ut_line, NTIME_MSG);
+               ut.ut_time = timetv.tv_sec;
+               pututline(&ut);
+               endutent();
+# else /* not HAVE_PUTUTLINE */
+# endif /* not HAVE_PUTUTLINE */
+#endif /* UPDATE_WTMP */
+
+               /* WTMPX */
+
+#ifdef UPDATE_WTMPX
+# ifdef HAVE_PUTUTXLINE
+               utx.ut_type = OLD_TIME;
+               utx.ut_tv = oldtimetv;
+               (void)strcpy(utx.ut_line, OTIME_MSG);
+#  ifdef HAVE_UPDWTMPX
+               updwtmpx(WTMPX_FILE, &utx);
+#  else /* not HAVE_UPDWTMPX */
+#  endif /* not HAVE_UPDWTMPX */
+# else /* not HAVE_PUTUTXLINE */
+# endif /* not HAVE_PUTUTXLINE */
+# ifdef HAVE_PUTUTXLINE
+               utx.ut_type = NEW_TIME;
+               utx.ut_tv = timetv;
+               (void)strcpy(utx.ut_line, NTIME_MSG);
+#  ifdef HAVE_UPDWTMPX
+               updwtmpx(WTMPX_FILE, &utx);
+#  else /* not HAVE_UPDWTMPX */
+#  endif /* not HAVE_UPDWTMPX */
+# else /* not HAVE_PUTUTXLINE */
+# endif /* not HAVE_PUTUTXLINE */
+#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));
+}
+
+/*
+ * 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 */
diff --git a/libntp/systime_s.c b/libntp/systime_s.c
new file mode 100644 (file)
index 0000000..8762122
--- /dev/null
@@ -0,0 +1,2 @@
+#define SIM
+#include "systime.c"
diff --git a/libntp/tsftomsu.c b/libntp/tsftomsu.c
new file mode 100644 (file)
index 0000000..5926aab
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * 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/libntp/tstotv.c b/libntp/tstotv.c
new file mode 100644 (file)
index 0000000..be4bdd4
--- /dev/null
@@ -0,0 +1,135 @@
+/*
+ * 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/libntp/tvtoa.c b/libntp/tvtoa.c
new file mode 100644 (file)
index 0000000..19d4a94
--- /dev/null
@@ -0,0 +1,39 @@
+/*
+ * 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/libntp/tvtots.c b/libntp/tvtots.c
new file mode 100644 (file)
index 0000000..0bd2b69
--- /dev/null
@@ -0,0 +1,159 @@
+/*
+ * 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/libntp/uglydate.c b/libntp/uglydate.c
new file mode 100644 (file)
index 0000000..676a5fd
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * uglydate - convert a time stamp to something barely readable
+ *           The string returned is 37 characters long.
+ */
+#include <stdio.h>
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "lib_strbuf.h"
+#include "ntp_stdlib.h"
+
+
+char *
+uglydate(
+       l_fp *ts
+       )
+{
+       char *bp;
+       char *timep;
+       struct tm *tm;
+       time_t sec;
+       long msec;
+       int year;
+
+       timep = ulfptoa(ts, 6);         /* returns max 17 characters */
+       LIB_GETBUF(bp);
+       sec = ts->l_ui - JAN_1970;
+       msec = ts->l_uf / 4294967;      /* fract / (2**32/1000) */
+       tm = gmtime(&sec);
+       if (ts->l_ui == 0) {
+               /*
+                * Probably not a real good thing to do.  Oh, well.
+                */
+               year = 0;
+               tm->tm_yday = 0;
+               tm->tm_hour = 0;
+               tm->tm_min = 0;
+               tm->tm_sec = 0;
+       } else {
+               year = tm->tm_year;
+               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);
+       return bp;
+}
diff --git a/libntp/uinttoa.c b/libntp/uinttoa.c
new file mode 100644 (file)
index 0000000..be48ea5
--- /dev/null
@@ -0,0 +1,20 @@
+/*
+ * 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/libntp/utvtoa.c b/libntp/utvtoa.c
new file mode 100644 (file)
index 0000000..a441c49
--- /dev/null
@@ -0,0 +1,26 @@
+/*
+ * 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/libntp/ymd2yd.c b/libntp/ymd2yd.c
new file mode 100644 (file)
index 0000000..796ce40
--- /dev/null
@@ -0,0 +1,37 @@
+/*
+ * ymd2yd - compute the date in the year from y/m/d
+ */
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.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};
+
+int
+ymd2yd(
+       int y,
+       int m,
+       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;
+}
diff --git a/libopts/COPYING.lgpl b/libopts/COPYING.lgpl
new file mode 100644 (file)
index 0000000..129c5de
--- /dev/null
@@ -0,0 +1,502 @@
+                 GNU LESSER GENERAL PUBLIC LICENSE
+                      Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                 GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/libopts/COPYING.mbsd b/libopts/COPYING.mbsd
new file mode 100644 (file)
index 0000000..8a70427
--- /dev/null
@@ -0,0 +1,26 @@
+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. The name of the author may not be used to endorse or promote
+       products derived from this software without specific prior
+       written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/libopts/MakeDefs.inc b/libopts/MakeDefs.inc
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/libopts/Makefile.am b/libopts/Makefile.am
new file mode 100644 (file)
index 0000000..5f13861
--- /dev/null
@@ -0,0 +1,24 @@
+## LIBOPTS Makefile
+MAINTAINERCLEANFILES    = Makefile.in
+if INSTALL_LIBOPTS
+lib_LTLIBRARIES         = libopts.la
+else
+noinst_LTLIBRARIES      = libopts.la
+endif
+libopts_la_SOURCES      = libopts.c
+libopts_la_CPPFLAGS     = -I$(top_srcdir)
+libopts_la_LDFLAGS      = -version-info  29:0:4
+EXTRA_DIST              = \
+    COPYING.lgpl            COPYING.mbsd            MakeDefs.inc  \
+    README                  autoopts/options.h      autoopts/usage-txt.h  \
+    autoopts.c              autoopts.h              boolean.c  \
+    compat/windows-config.h compat/compat.h         compat/pathfind.c  \
+    compat/snprintf.c       compat/strdup.c         compat/strchr.c  \
+    configfile.c            cook.c                  enumeration.c  \
+    environment.c           genshell.c              genshell.h  \
+    load.c                  m4/libopts.m4           m4/liboptschk.m4  \
+    makeshell.c             nested.c                numeric.c  \
+    pgusage.c               proto.h                 putshell.c  \
+    restore.c               save.c                  sort.c  \
+    stack.c                 streqvcmp.c             text_mmap.c  \
+    tokenize.c              usage.c                 version.c
diff --git a/libopts/Makefile.in b/libopts/Makefile.in
new file mode 100644 (file)
index 0000000..6a4d03e
--- /dev/null
@@ -0,0 +1,579 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = libopts
+DIST_COMMON = README $(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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(libdir)"
+LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
+libopts_la_LIBADD =
+am_libopts_la_OBJECTS = libopts_la-libopts.lo
+libopts_la_OBJECTS = $(am_libopts_la_OBJECTS)
+libopts_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(libopts_la_LDFLAGS) $(LDFLAGS) -o $@
+@INSTALL_LIBOPTS_FALSE@am_libopts_la_rpath =
+@INSTALL_LIBOPTS_TRUE@am_libopts_la_rpath = -rpath $(libdir)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(libopts_la_SOURCES)
+DIST_SOURCES = $(libopts_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+MAINTAINERCLEANFILES = Makefile.in
+@INSTALL_LIBOPTS_TRUE@lib_LTLIBRARIES = libopts.la
+@INSTALL_LIBOPTS_FALSE@noinst_LTLIBRARIES = libopts.la
+libopts_la_SOURCES = libopts.c
+libopts_la_CPPFLAGS = -I$(top_srcdir)
+libopts_la_LDFLAGS = -version-info  29:0:4
+EXTRA_DIST = \
+    COPYING.lgpl            COPYING.mbsd            MakeDefs.inc  \
+    README                  autoopts/options.h      autoopts/usage-txt.h  \
+    autoopts.c              autoopts.h              boolean.c  \
+    compat/windows-config.h compat/compat.h         compat/pathfind.c  \
+    compat/snprintf.c       compat/strdup.c         compat/strchr.c  \
+    configfile.c            cook.c                  enumeration.c  \
+    environment.c           genshell.c              genshell.h  \
+    load.c                  m4/libopts.m4           m4/liboptschk.m4  \
+    makeshell.c             nested.c                numeric.c  \
+    pgusage.c               proto.h                 putshell.c  \
+    restore.c               save.c                  sort.c  \
+    stack.c                 streqvcmp.c             text_mmap.c  \
+    tokenize.c              usage.c                 version.c
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libopts/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign libopts/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+       @$(NORMAL_INSTALL)
+       test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+       @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+       list2=; for p in $$list; do \
+         if test -f $$p; then \
+           list2="$$list2 $$p"; \
+         else :; fi; \
+       done; \
+       test -z "$$list2" || { \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+       }
+
+uninstall-libLTLIBRARIES:
+       @$(NORMAL_UNINSTALL)
+       @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+       for p in $$list; do \
+         $(am__strip_dir) \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+       done
+
+clean-libLTLIBRARIES:
+       -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+       @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+         test "$$dir" != "$$p" || dir=.; \
+         echo "rm -f \"$${dir}/so_locations\""; \
+         rm -f "$${dir}/so_locations"; \
+       done
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+         test "$$dir" != "$$p" || dir=.; \
+         echo "rm -f \"$${dir}/so_locations\""; \
+         rm -f "$${dir}/so_locations"; \
+       done
+libopts.la: $(libopts_la_OBJECTS) $(libopts_la_DEPENDENCIES) 
+       $(libopts_la_LINK) $(am_libopts_la_rpath) $(libopts_la_OBJECTS) $(libopts_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libopts_la-libopts.Plo@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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+libopts_la-libopts.lo: libopts.c
+@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libopts_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libopts_la-libopts.lo -MD -MP -MF $(DEPDIR)/libopts_la-libopts.Tpo -c -o libopts_la-libopts.lo `test -f 'libopts.c' || echo '$(srcdir)/'`libopts.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libopts_la-libopts.Tpo $(DEPDIR)/libopts_la-libopts.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='libopts.c' object='libopts_la-libopts.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libopts_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libopts_la-libopts.lo `test -f 'libopts.c' || echo '$(srcdir)/'`libopts.c
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+       for dir in "$(DESTDIR)$(libdir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+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 "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+       clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-libLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+       clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \
+       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-libLTLIBRARIES 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 uninstall uninstall-am uninstall-libLTLIBRARIES
+
+
+# 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.
+.NOEXPORT:
diff --git a/libopts/README b/libopts/README
new file mode 100644 (file)
index 0000000..7cbe0b0
--- /dev/null
@@ -0,0 +1,93 @@
+        THIS TARBALL IS NOT A FULL DISTRIBUTION.
+
+The contents of this tarball is designed to be incorporated into
+software packages that utilize the AutoOpts option automation
+package and are intended to be installed on systems that may not
+have libopts installed.  It is redistributable under the terms
+of either the LGPL (see COPYING.lgpl) or under the terms of
+the advertising clause free BSD license (see COPYING.mbsd).
+
+Usage Instructions for autoconf/automake/libtoolized projects:
+
+1. Install the unrolled tarball into your package source tree,
+   copying ``libopts.m4'' to your autoconf macro directory.
+
+   In your bootstrap (pre-configure) script, you can do this:
+
+      rm -rf libopts libopts-*
+      gunzip -c `autoopts-config libsrc` | tar -xvf -
+      mv -f libopts-*.*.* libopts
+      cp -fp libopts/m4/*.m4 m4/.
+
+   I tend to put my configure auxiliary files in "m4".
+   Whatever directory you choose, if it is not ".", then
+   be sure to tell autoconf about it with:
+
+      AC_CONFIG_AUX_DIR(m4)
+
+   This is one macro where you *MUST* remember to *NOT* quote
+   the argument.  If you do, automake will get lost.
+
+2. Add the following to your ``configure.ac'' file:
+
+      LIBOPTS_CHECK
+
+   or:
+
+      LIBOPTS_CHECK([relative/path/to/libopts])
+
+   This macro will automatically invoke
+
+      AC_CONFIG_FILES( [relative/path/to/libopts/Makefile] )
+
+   The default ``relative/path/to/libopts'' is simply
+   ``libopts''.
+
+3. Add the following to your top level ``Makefile.am'' file:
+
+      if NEED_LIBOPTS
+         SUBDIRS += $(LIBOPTS_DIR)
+      endif
+
+   where ``<...>'' can be whatever other files or directories
+   you may need.  The SUBDIRS must be properly ordered.
+   *PLEASE NOTE* it is crucial that the SUBDIRS be set under the
+   control of an automake conditional.  To work correctly,
+   automake has to know the range of possible values of SUBDIRS.
+   It's a magical name with magical properties.  ``NEED_LIBOPTS''
+   will be correctly set by the ``LIBOPTS_CHECK'' macro, above.
+
+4. Add ``$(LIBOPTS_CFLAGS)'' to relevant compiler flags and
+   ``$(LIBOPTS_LDADD)'' to relevant link options whereever
+   you need them in your build tree.
+
+5. Make sure your object files explicitly depend upon the
+   generated options header file.  e.g.:
+
+     $(prog_OBJECTS) : prog-opts.h
+     prog-opts.h : prog-opts.c
+     prog-opts.c : prog-opts.def
+         autogen prog-opts.def
+
+6. *OPTIONAL* --
+   If you are creating man pages and texi documentation from
+   the program options, you will need these rules somewhere, too:
+
+     man_MANS = prog.1
+     prog.1 : prog-opts.def
+         autogen -Tagman1.tpl -bprog prog-opts.def
+
+     prog-invoke.texi : prog-opts.def
+         autogen -Taginfo.tpl -bprog-invoke prog-opts.def
+
+If your package does not utilize the auto* tools, then you
+will need to hand craft the rules for building the library.
+
+LICENSING:
+
+This material is copyright 1993-2007 by Bruce Korb.
+You are licensed to use this under the terms of either
+the GNU Lesser General Public License (see: COPYING.lgpl), or,
+at your option, the modified Berkeley Software Distribution
+License (see:  COPYING.mbsd).  Both of these files should be
+included with this tarball.
diff --git a/libopts/autoopts.c b/libopts/autoopts.c
new file mode 100644 (file)
index 0000000..139841b
--- /dev/null
@@ -0,0 +1,1120 @@
+
+/*
+ *  $Id: autoopts.c,v 4.25 2007/04/15 19:01:18 bkorb Exp $
+ *  Time-stamp:      "2007-04-15 11:10:40 bkorb"
+ *
+ *  This file contains all of the routines that must be linked into
+ *  an executable to use the generated option processing.  The optional
+ *  routines are in separately compiled modules so that they will not
+ *  necessarily be linked in.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+static char const zNil[] = "";
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static tSuccess
+findOptDesc( tOptions* pOpts, tOptState* pOptState );
+
+static tSuccess
+nextOption( tOptions* pOpts, tOptState* pOptState );
+
+static tSuccess
+doPresets( tOptions* pOpts );
+
+static int
+checkConsistency( tOptions* pOpts );
+/* = = = END-STATIC-FORWARD = = = */
+
+LOCAL void *
+ao_malloc( size_t sz )
+{
+    void * res = malloc(sz);
+    if (res == NULL) {
+        fprintf( stderr, "malloc of %d bytes failed\n", (int)sz );
+        exit( EXIT_FAILURE );
+    }
+    return res;
+}
+#undef  malloc
+#define malloc(_s) ao_malloc(_s)
+
+LOCAL void *
+ao_realloc( void *p, size_t sz )
+{
+    void * res = realloc(p, sz);
+    if (res == NULL) {
+        fprintf( stderr, "realloc of %d bytes at 0x%p failed\n", (int)sz, p );
+        exit( EXIT_FAILURE );
+    }
+    return res;
+}
+#undef  realloc
+#define realloc(_p,_s) ao_realloc(_p,_s)
+
+
+LOCAL void
+ao_free( void *p )
+{
+    if (p != NULL)
+        free(p);
+}
+#undef  free
+#define free(_p) ao_free(_p)
+
+
+LOCAL char *
+ao_strdup( char const *str )
+{
+    char * res = strdup(str);
+    if (res == NULL) {
+        fprintf( stderr, "strdup of %d byte string failed\n", (int)strlen(str) );
+        exit( EXIT_FAILURE );
+    }
+    return res;
+}
+#undef  strdup
+#define strdup(_p) ao_strdup(_p)
+
+#ifndef HAVE_PATHFIND
+#  include "compat/pathfind.c"
+#endif
+
+#ifndef HAVE_SNPRINTF
+#  include "compat/snprintf.c"
+#endif
+
+#ifndef HAVE_STRDUP
+#  include "compat/strdup.c"
+#endif
+
+#ifndef HAVE_STRCHR
+#  include "compat/strchr.c"
+#endif
+
+/*
+ *  handleOption
+ *
+ *  This routine handles equivalencing, sets the option state flags and
+ *  invokes the handler procedure, if any.
+ */
+LOCAL tSuccess
+handleOption( tOptions* pOpts, tOptState* pOptState )
+{
+    /*
+     *  Save a copy of the option procedure pointer.
+     *  If this is an equivalence class option, we still want this proc.
+     */
+    tOptDesc* pOD = pOptState->pOD;
+    tOptProc* pOP = pOD->pOptProc;
+    if (pOD->fOptState & OPTST_ALLOC_ARG)
+        AGFREE(pOD->optArg.argString);
+
+    pOD->optArg.argString = pOptState->pzOptArg;
+
+    /*
+     *  IF we are presetting options, then we will ignore any un-presettable
+     *  options.  They are the ones either marked as such.
+     */
+    if (  ((pOpts->fOptSet & OPTPROC_PRESETTING) != 0)
+       && ((pOD->fOptState & OPTST_NO_INIT) != 0)
+       )
+        return PROBLEM;
+
+    /*
+     *  IF this is an equivalence class option,
+     *  THEN
+     *      Save the option value that got us to this option
+     *      entry.  (It may not be pOD->optChar[0], if this is an
+     *      equivalence entry.)
+     *      set the pointer to the equivalence class base
+     */
+    if (pOD->optEquivIndex != NO_EQUIVALENT) {
+        tOptDesc* p = pOpts->pOptDesc + pOD->optEquivIndex;
+
+        /*
+         * IF the current option state has not been defined (set on the
+         *    command line), THEN we will allow continued resetting of
+         *    the value.  Once "defined", then it must not change.
+         */
+        if ((pOD->fOptState & OPTST_DEFINED) != 0) {
+            /*
+             *  The equivalenced-to option has been found on the command
+             *  line before.  Make sure new occurrences are the same type.
+             *
+             *  IF this option has been previously equivalenced and
+             *     it was not the same equivalenced-to option,
+             *  THEN we have a usage problem.
+             */
+            if (p->optActualIndex != pOD->optIndex) {
+                fprintf( stderr, (char*)zMultiEquiv, p->pz_Name, pOD->pz_Name,
+                         (pOpts->pOptDesc + p->optActualIndex)->pz_Name);
+                return FAILURE;
+            }
+        } else {
+            /*
+             *  Set the equivalenced-to actual option index to no-equivalent
+             *  so that we set all the entries below.  This option may either
+             *  never have been selected before, or else it was selected by
+             *  some sort of "presetting" mechanism.
+             */
+            p->optActualIndex = NO_EQUIVALENT;
+        }
+
+        if (p->optActualIndex != pOD->optIndex) {
+            /*
+             *  First time through, copy over the state
+             *  and add in the equivalence flag
+             */
+            p->optActualValue = pOD->optValue;
+            p->optActualIndex = pOD->optIndex;
+            pOptState->flags |= OPTST_EQUIVALENCE;
+        }
+
+        /*
+         *  Copy the most recent option argument.  set membership state
+         *  is kept in ``p->optCookie''.  Do not overwrite.
+         */
+        p->optArg.argString = pOD->optArg.argString;
+        pOD = p;
+
+    } else {
+        pOD->optActualValue = pOD->optValue;
+        pOD->optActualIndex = pOD->optIndex;
+    }
+
+    pOD->fOptState &= OPTST_PERSISTENT_MASK;
+    pOD->fOptState |= (pOptState->flags & ~OPTST_PERSISTENT_MASK);
+
+    /*
+     *  Keep track of count only for DEFINED (command line) options.
+     *  IF we have too many, build up an error message and bail.
+     */
+    if (  (pOD->fOptState & OPTST_DEFINED)
+       && (++pOD->optOccCt > pOD->optMaxCt)  )  {
+
+        if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+            char const * pzEqv =
+                (pOD->optEquivIndex != NO_EQUIVALENT) ? zEquiv : zNil;
+
+            fputs( zErrOnly, stderr );
+
+            if (pOD->optMaxCt > 1)
+                fprintf(stderr, zAtMost, pOD->optMaxCt, pOD->pz_Name, pzEqv);
+            else
+                fprintf(stderr, zOnlyOne, pOD->pz_Name, pzEqv);
+        }
+
+        return FAILURE;
+    }
+
+    /*
+     *  If provided a procedure to call, call it
+     */
+    if (pOP != (tpOptProc)NULL)
+        (*pOP)( pOpts, pOD );
+
+    return SUCCESS;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  HUNT FOR OPTIONS IN THE ARGUMENT LIST
+ *
+ *  The next four procedures are "private" to nextOption().
+ *  nextOption() uses findOptDesc() to find the next descriptor and it, in
+ *  turn, uses longOptionFind() and shortOptionFind() to actually do the hunt.
+ *
+ *  longOptionFind
+ *
+ *  Find the long option descriptor for the current option
+ */
+LOCAL tSuccess
+longOptionFind( tOptions* pOpts, char* pzOptName, tOptState* pOptState )
+{
+    ag_bool    disable  = AG_FALSE;
+    char*      pzEq     = strchr( pzOptName, '=' );
+    tOptDesc*  pOD      = pOpts->pOptDesc;
+    int        idx      = 0;
+    int        idxLim   = pOpts->optCt;
+    int        matchCt  = 0;
+    int        matchIdx = 0;
+    int        nameLen;
+
+    /*
+     *  IF the value is attached to the name,
+     *  THEN clip it off.
+     *  Either way, figure out how long our name is
+     */
+    if (pzEq != NULL) {
+        nameLen = (int)(pzEq - pzOptName);
+        *pzEq = NUL;
+    } else nameLen = strlen( pzOptName );
+
+    do  {
+        if (SKIP_OPT(pOD))
+            continue;
+
+        if (strneqvcmp( pzOptName, pOD->pz_Name, nameLen ) == 0) {
+            /*
+             *  IF we have a complete match
+             *  THEN it takes priority over any already located partial
+             */
+            if (pOD->pz_Name[ nameLen ] == NUL) {
+                matchCt  = 1;
+                matchIdx = idx;
+                break;
+            }
+        }
+
+        /*
+         *  IF       there is a disable name
+         *     *AND* no argument value has been supplied
+         *              (disabled options may have no argument)
+         *     *AND* the option name matches the disable name
+         *  THEN ...
+         */
+        else if (  (pOD->pz_DisableName != NULL)
+                && (strneqvcmp(pzOptName, pOD->pz_DisableName, nameLen) == 0)
+                )  {
+            disable  = AG_TRUE;
+
+            /*
+             *  IF we have a complete match
+             *  THEN it takes priority over any already located partial
+             */
+            if (pOD->pz_DisableName[ nameLen ] == NUL) {
+                matchCt  = 1;
+                matchIdx = idx;
+                break;
+            }
+        }
+
+        else
+            continue;
+
+        /*
+         *  We found a partial match, either regular or disabling.
+         *  Remember the index for later.
+         */
+        matchIdx = idx;
+
+        if (++matchCt > 1)
+            break;
+
+    } while (pOD++, (++idx < idxLim));
+
+    if (pzEq != NULL)
+        *(pzEq++) = '=';
+
+    /*
+     *  Make sure we either found an exact match or found only one partial
+     */
+    if (matchCt == 1) {
+        /*
+         *  IF we found a disablement name,
+         *  THEN set the bit in the callers' flag word
+         */
+        if (disable)
+            pOptState->flags |= OPTST_DISABLED;
+
+        pOptState->pOD      = pOpts->pOptDesc + matchIdx;
+        pOptState->pzOptArg = pzEq;
+        pOptState->optType  = TOPT_LONG;
+        return SUCCESS;
+    }
+
+    /*
+     *  IF there is no equal sign
+     *     *AND* we are using named arguments
+     *     *AND* there is a default named option,
+     *  THEN return that option.
+     */
+    if (  (pzEq == NULL)
+       && NAMED_OPTS(pOpts)
+       && (pOpts->specOptIdx.default_opt != NO_EQUIVALENT)) {
+        pOptState->pOD = pOpts->pOptDesc + pOpts->specOptIdx.default_opt;
+
+        pOptState->pzOptArg = pzOptName;
+        pOptState->optType  = TOPT_DEFAULT;
+        return SUCCESS;
+    }
+
+    /*
+     *  IF we are to stop on errors (the default, actually)
+     *  THEN call the usage procedure.
+     */
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+        fprintf( stderr, zIllOptStr, pOpts->pzProgPath,
+                 (matchCt == 0) ? zIllegal : zAmbiguous, pzOptName );
+        (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+    }
+
+    return FAILURE;
+}
+
+
+/*
+ *  shortOptionFind
+ *
+ *  Find the short option descriptor for the current option
+ */
+LOCAL tSuccess
+shortOptionFind( tOptions* pOpts, uint_t optValue, tOptState* pOptState )
+{
+    tOptDesc*  pRes = pOpts->pOptDesc;
+    int        ct   = pOpts->optCt;
+
+    /*
+     *  Search the option list
+     */
+    for (;;) {
+        /*
+         *  IF the values match,
+         *  THEN we stop here
+         */
+        if ((! SKIP_OPT(pRes)) && (optValue == pRes->optValue)) {
+            pOptState->pOD     = pRes;
+            pOptState->optType = TOPT_SHORT;
+            return SUCCESS;
+        }
+
+        /*
+         *  Advance to next option description
+         */
+        pRes++;
+
+        /*
+         *  IF we have searched everything, ...
+         */
+        if (--ct <= 0)
+            break;
+    }
+
+    /*
+     *  IF    the character value is a digit
+     *    AND there is a special number option ("-n")
+     *  THEN the result is the "option" itself and the
+     *       option is the specially marked "number" option.
+     */
+    if (  isdigit( optValue )
+       && (pOpts->specOptIdx.number_option != NO_EQUIVALENT) ) {
+        pOptState->pOD = \
+        pRes           = pOpts->pOptDesc + pOpts->specOptIdx.number_option;
+        (pOpts->pzCurOpt)--;
+        pOptState->optType = TOPT_SHORT;
+        return SUCCESS;
+    }
+
+    /*
+     *  IF we are to stop on errors (the default, actually)
+     *  THEN call the usage procedure.
+     */
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+        fprintf( stderr, zIllOptChr, pOpts->pzProgPath, optValue );
+        (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+    }
+
+    return FAILURE;
+}
+
+
+/*
+ *  findOptDesc
+ *
+ *  Find the option descriptor for the current option
+ */
+static tSuccess
+findOptDesc( tOptions* pOpts, tOptState* pOptState )
+{
+    /*
+     *  IF we are continuing a short option list (e.g. -xyz...)
+     *  THEN continue a single flag option.
+     *  OTHERWISE see if there is room to advance and then do so.
+     */
+    if ((pOpts->pzCurOpt != NULL) && (*pOpts->pzCurOpt != NUL))
+        return shortOptionFind( pOpts, (tAoUC)*(pOpts->pzCurOpt), pOptState );
+
+    if (pOpts->curOptIdx >= pOpts->origArgCt)
+        return PROBLEM; /* NORMAL COMPLETION */
+
+    pOpts->pzCurOpt = pOpts->origArgVect[ pOpts->curOptIdx ];
+
+    /*
+     *  IF all arguments must be named options, ...
+     */
+    if (NAMED_OPTS(pOpts)) {
+        char* pz = pOpts->pzCurOpt;
+        pOpts->curOptIdx++;
+
+        /*
+         *  Skip over any flag/option markers.
+         *  In this mode, they are not required.
+         */
+        while (*pz == '-') pz++;
+
+        return longOptionFind( pOpts, pz, pOptState );
+    }
+
+    /*
+     *  Note the kind of flag/option marker
+     */
+    if (*((pOpts->pzCurOpt)++) != '-')
+        return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */
+
+    /*
+     *  Special hack for a hyphen by itself
+     */
+    if (*(pOpts->pzCurOpt) == NUL)
+        return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */
+
+    /*
+     *  The current argument is to be processed as an option argument
+     */
+    pOpts->curOptIdx++;
+
+    /*
+     *  We have an option marker.
+     *  Test the next character for long option indication
+     */
+    if (pOpts->pzCurOpt[0] == '-') {
+        if (*++(pOpts->pzCurOpt) == NUL)
+            /*
+             *  NORMAL COMPLETION - NOT this arg, but rest are operands
+             */
+            return PROBLEM;
+
+        /*
+         *  We do not allow the hyphen to be used as a flag value.
+         *  Therefore, if long options are not to be accepted, we punt.
+         */
+        if ((pOpts->fOptSet & OPTPROC_LONGOPT) == 0) {
+            fprintf( stderr, zIllOptStr, pOpts->pzProgPath,
+                     zIllegal, pOpts->pzCurOpt-2 );
+            return FAILURE;
+        }
+
+        return longOptionFind( pOpts, pOpts->pzCurOpt, pOptState );
+    }
+
+    /*
+     *  If short options are not allowed, then do long
+     *  option processing.  Otherwise the character must be a
+     *  short (i.e. single character) option.
+     */
+    if ((pOpts->fOptSet & OPTPROC_SHORTOPT) != 0)
+        return shortOptionFind( pOpts, (tAoUC)*(pOpts->pzCurOpt), pOptState );
+
+    return longOptionFind( pOpts, pOpts->pzCurOpt, pOptState );
+}
+
+
+/*
+ *  nextOption
+ *
+ *  Find the option descriptor and option argument (if any) for the
+ *  next command line argument.  DO NOT modify the descriptor.  Put
+ *  all the state in the state argument so that the option can be skipped
+ *  without consequence (side effect).
+ */
+static tSuccess
+nextOption( tOptions* pOpts, tOptState* pOptState )
+{
+    tSuccess res;
+    enum { ARG_NONE, ARG_MAY, ARG_MUST } arg_type = ARG_NONE;
+    teOptArgType at;
+
+    res = findOptDesc( pOpts, pOptState );
+    if (! SUCCESSFUL( res ))
+        return res;
+    pOptState->flags |= (pOptState->pOD->fOptState & OPTST_PERSISTENT_MASK);
+    at = OPTST_GET_ARGTYPE(pOptState->flags);
+
+    /*
+     *  Figure out what to do about option arguments.  An argument may be
+     *  required, not associated with the option, or be optional.  We detect the
+     *  latter by examining for an option marker on the next possible argument.
+     *  Disabled mode option selection also disables option arguments.
+     */
+    if ((pOptState->flags & OPTST_DISABLED) != 0)
+        arg_type = ARG_NONE;
+    else if (at == OPARG_TYPE_NONE)
+        arg_type = ARG_NONE;
+    else if (pOptState->flags & OPTST_ARG_OPTIONAL)
+        arg_type = ARG_MAY;
+    else
+        arg_type = ARG_MUST;
+
+    switch (arg_type) {
+    case ARG_MUST:
+        /*
+         *  An option argument is required.  Long options can either have
+         *  a separate command line argument, or an argument attached by
+         *  the '=' character.  Figure out which.
+         */
+        switch (pOptState->optType) {
+        case TOPT_SHORT:
+            /*
+             *  See if an arg string follows the flag character
+             */
+            if (*++(pOpts->pzCurOpt) == NUL)
+                pOpts->pzCurOpt = pOpts->origArgVect[ pOpts->curOptIdx++ ];
+            pOptState->pzOptArg = pOpts->pzCurOpt;
+            break;
+
+        case TOPT_LONG:
+            /*
+             *  See if an arg string has already been assigned (glued on
+             *  with an `=' character)
+             */
+            if (pOptState->pzOptArg == NULL)
+                pOptState->pzOptArg = pOpts->origArgVect[ pOpts->curOptIdx++ ];
+            break;
+
+        default:
+#ifdef DEBUG
+            fputs( "AutoOpts lib error: option type not selected\n",
+                   stderr );
+            exit( EXIT_FAILURE );
+#endif
+
+        case TOPT_DEFAULT:
+            /*
+             *  The option was selected by default.  The current token is
+             *  the option argument.
+             */
+            break;
+        }
+
+        /*
+         *  Make sure we did not overflow the argument list.
+         */
+        if (pOpts->curOptIdx > pOpts->origArgCt) {
+            fprintf( stderr, zMisArg, pOpts->pzProgPath,
+                     pOptState->pOD->pz_Name );
+            return FAILURE;
+        }
+
+        pOpts->pzCurOpt = NULL;  /* next time advance to next arg */
+        break;
+
+    case ARG_MAY:
+        /*
+         *  An option argument is optional.
+         */
+        switch (pOptState->optType) {
+        case TOPT_SHORT:
+            if (*++pOpts->pzCurOpt != NUL)
+                pOptState->pzOptArg = pOpts->pzCurOpt;
+            else {
+                char* pzLA = pOpts->origArgVect[ pOpts->curOptIdx ];
+
+                /*
+                 *  BECAUSE it is optional, we must make sure
+                 *  we did not find another flag and that there
+                 *  is such an argument.
+                 */
+                if ((pzLA == NULL) || (*pzLA == '-'))
+                    pOptState->pzOptArg = NULL;
+                else {
+                    pOpts->curOptIdx++; /* argument found */
+                    pOptState->pzOptArg = pzLA;
+                }
+            }
+            break;
+
+        case TOPT_LONG:
+            /*
+             *  Look for an argument if we don't already have one (glued on
+             *  with a `=' character) *AND* we are not in named argument mode
+             */
+            if (  (pOptState->pzOptArg == NULL)
+               && (! NAMED_OPTS(pOpts))) {
+                char* pzLA = pOpts->origArgVect[ pOpts->curOptIdx ];
+
+                /*
+                 *  BECAUSE it is optional, we must make sure
+                 *  we did not find another flag and that there
+                 *  is such an argument.
+                 */
+                if ((pzLA == NULL) || (*pzLA == '-'))
+                    pOptState->pzOptArg = NULL;
+                else {
+                    pOpts->curOptIdx++; /* argument found */
+                    pOptState->pzOptArg = pzLA;
+                }
+            }
+            break;
+
+        default:
+        case TOPT_DEFAULT:
+            fputs( "AutoOpts lib error: defaulted to option with optional arg\n",
+                   stderr );
+            exit( EX_SOFTWARE );
+        }
+
+        /*
+         *  After an option with an optional argument, we will
+         *  *always* start with the next option because if there
+         *  were any characters following the option name/flag,
+         *  they would be interpreted as the argument.
+         */
+        pOpts->pzCurOpt = NULL;
+        break;
+
+    default: /* CANNOT */
+        /*
+         *  No option argument.  Make sure next time around we find
+         *  the correct option flag character for short options
+         */
+        if (pOptState->optType == TOPT_SHORT)
+            (pOpts->pzCurOpt)++;
+
+        /*
+         *  It is a long option.  Make sure there was no ``=xxx'' argument
+         */
+        else if (pOptState->pzOptArg != NULL) {
+            fprintf( stderr, zNoArg, pOpts->pzProgPath,
+                     pOptState->pOD->pz_Name );
+            return FAILURE;
+        }
+
+        /*
+         *  It is a long option.  Advance to next command line argument.
+         */
+        else
+            pOpts->pzCurOpt = NULL;
+    }
+
+    return SUCCESS;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  DO PRESETS
+ *
+ *  The next several routines do the immediate action pass on the command
+ *  line options, then the environment variables, then the config files in
+ *  reverse order.  Once done with that, the order is reversed and all
+ *  the config files and environment variables are processed again, this
+ *  time only processing the non-immediate action options.  doPresets()
+ *  will then return for optionProcess() to do the final pass on the command
+ *  line arguments.
+ */
+
+/*
+ *  doImmediateOpts - scan the command line for immediate action options
+ */
+LOCAL tSuccess
+doImmediateOpts( tOptions* pOpts )
+{
+    pOpts->curOptIdx = 1;     /* start by skipping program name */
+    pOpts->pzCurOpt  = NULL;
+
+    /*
+     *  Examine all the options from the start.  We process any options that
+     *  are marked for immediate processing.
+     */
+    for (;;) {
+        tOptState optState = OPTSTATE_INITIALIZER(PRESET);
+
+        switch (nextOption( pOpts, &optState )) {
+        case FAILURE: goto optionsDone;
+        case PROBLEM: return SUCCESS; /* no more args */
+        case SUCCESS: break;
+        }
+
+        /*
+         *  IF this *is* an immediate-attribute option, then do it.
+         */
+        if (! DO_IMMEDIATELY(optState.flags))
+            continue;
+
+        if (! SUCCESSFUL( handleOption( pOpts, &optState )))
+            break;
+    } optionsDone:;
+
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
+        (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+    return FAILURE;
+}
+
+
+LOCAL tSuccess
+doRegularOpts( tOptions* pOpts )
+{
+    /*
+     *  Now, process all the options from our current position onward.
+     *  (This allows interspersed options and arguments for the few
+     *  non-standard programs that require it.)
+     */
+    for (;;) {
+        tOptState optState = OPTSTATE_INITIALIZER(DEFINED);
+
+        switch (nextOption( pOpts, &optState )) {
+        case FAILURE: goto optionsDone;
+        case PROBLEM: return SUCCESS; /* no more args */
+        case SUCCESS: break;
+        }
+
+        /*
+         *  IF this is not being processed normally (i.e. is immediate action)
+         *  THEN skip it (unless we are supposed to do it a second time).
+         */
+        if (! DO_NORMALLY(optState.flags)) {
+            if (! DO_SECOND_TIME(optState.flags))
+                continue;
+            optState.pOD->optOccCt--; /* don't count last time */
+        }
+
+        if (! SUCCESSFUL( handleOption( pOpts, &optState )))
+            break;
+    } optionsDone:;
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
+        (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+    return FAILURE;
+}
+
+
+/*
+ *  doPresets - check for preset values from a config file or the envrionment
+ */
+static tSuccess
+doPresets( tOptions* pOpts )
+{
+    tOptDesc * pOD = NULL;
+
+    if (! SUCCESSFUL( doImmediateOpts( pOpts )))
+        return FAILURE;
+
+    /*
+     *  IF this option set has a --save-opts option, then it also
+     *  has a --load-opts option.  See if a command line option has disabled
+     *  option presetting.
+     */
+    if (pOpts->specOptIdx.save_opts != 0) {
+        pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
+        if (DISABLED_OPT(pOD))
+            return SUCCESS;
+    }
+
+    /*
+     *  Until we return from this procedure, disable non-presettable opts
+     */
+    pOpts->fOptSet |= OPTPROC_PRESETTING;
+    /*
+     *  IF there are no config files,
+     *  THEN do any environment presets and leave.
+     */
+    if (pOpts->papzHomeList == NULL) {
+        doEnvPresets( pOpts, ENV_ALL );
+    }
+    else {
+        doEnvPresets( pOpts, ENV_IMM );
+
+        /*
+         *  Check to see if environment variables have disabled presetting.
+         */
+        if ((pOD != NULL) && ! DISABLED_OPT(pOD))
+            internalFileLoad( pOpts );
+
+        /*
+         *  ${PROGRAM_LOAD_OPTS} value of "no" cannot disable other environment
+         *  variable options.  Only the loading of .rc files.
+         */
+        doEnvPresets( pOpts, ENV_NON_IMM );
+    }
+    pOpts->fOptSet &= ~OPTPROC_PRESETTING;
+
+    return SUCCESS;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  VERIFY OPTION CONSISTENCY
+ *
+ *  Make sure that the argument list passes our consistency tests.
+ */
+static int
+checkConsistency( tOptions* pOpts )
+{
+    int        errCt = 0;
+    tOptDesc*  pOD   = pOpts->pOptDesc;
+    int        oCt   = pOpts->presetOptCt;
+
+    /*
+     *  FOR each of "oCt" options, ...
+     */
+    for (;;) {
+        const int*  pMust = pOD->pOptMust;
+        const int*  pCant = pOD->pOptCant;
+
+        /*
+         *  IF the current option was provided on the command line
+         *  THEN ensure that any "MUST" requirements are not
+         *       "DEFAULT" (unspecified) *AND* ensure that any
+         *       "CANT" options have not been SET or DEFINED.
+         */
+        if (SELECTED_OPT(pOD)) {
+            if (pMust != NULL) for (;;) {
+                tOptDesc*  p = pOpts->pOptDesc + *(pMust++);
+                if (UNUSED_OPT(p)) {
+                    const tOptDesc* pN = pOpts->pOptDesc + pMust[-1];
+                    errCt++;
+                    fprintf( stderr, zReqFmt, pOD->pz_Name, pN->pz_Name );
+                }
+
+                if (*pMust == NO_EQUIVALENT)
+                    break;
+            }
+
+            if (pCant != NULL) for (;;) {
+                tOptDesc*  p = pOpts->pOptDesc + *(pCant++);
+                if (SELECTED_OPT(p)) {
+                    const tOptDesc* pN = pOpts->pOptDesc + pCant[-1];
+                    errCt++;
+                    fprintf( stderr, zCantFmt, pOD->pz_Name, pN->pz_Name );
+                }
+
+                if (*pCant == NO_EQUIVALENT)
+                    break;
+            }
+        }
+
+        /*
+         *  IF       this option is not equivalenced to another,
+         *        OR it is equivalenced to itself (is the equiv. root)
+         *  THEN we need to make sure it occurs often enough.
+         */
+        if (  (pOD->optEquivIndex == NO_EQUIVALENT)
+           || (pOD->optEquivIndex == pOD->optIndex) )   do {
+            /*
+             *  IF the occurrence counts have been satisfied,
+             *  THEN there is no problem.
+             */
+            if (pOD->optOccCt >= pOD->optMinCt)
+                break;
+
+            /*
+             *  IF MUST_SET means SET and PRESET are okay,
+             *  so min occurrence count doesn't count
+             */
+            if (  (pOD->fOptState & OPTST_MUST_SET)
+               && (pOD->fOptState & (OPTST_PRESET | OPTST_SET)) )
+                break;
+
+            errCt++;
+            if (pOD->optMinCt > 1)
+                 fprintf( stderr, zNotEnough, pOD->pz_Name, pOD->optMinCt );
+            else fprintf( stderr, zNeedOne, pOD->pz_Name );
+        } while (0);
+
+        if (--oCt <= 0)
+            break;
+        pOD++;
+    }
+
+    /*
+     *  IF we are stopping on errors, check to see if any remaining
+     *  arguments are required to be there or prohibited from being there.
+     */
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+
+        /*
+         *  Check for prohibition
+         */
+        if ((pOpts->fOptSet & OPTPROC_NO_ARGS) != 0) {
+            if (pOpts->origArgCt > pOpts->curOptIdx) {
+                fprintf( stderr, zNoArgs, pOpts->pzProgName );
+                ++errCt;
+            }
+        }
+
+        /*
+         *  ELSE not prohibited, check for being required
+         */
+        else if ((pOpts->fOptSet & OPTPROC_ARGS_REQ) != 0) {
+            if (pOpts->origArgCt <= pOpts->curOptIdx) {
+                fprintf( stderr, zArgsMust, pOpts->pzProgName );
+                ++errCt;
+            }
+        }
+    }
+
+    return errCt;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  THESE ROUTINES ARE CALLABLE FROM THE GENERATED OPTION PROCESSING CODE
+ */
+/*=--subblock=arg=arg_type,arg_name,arg_desc =*/
+/*=*
+ * library:  opts
+ * header:   your-opts.h
+ *
+ * lib_description:
+ *
+ *  These are the routines that libopts users may call directly from their
+ *  code.  There are several other routines that can be called by code
+ *  generated by the libopts option templates, but they are not to be
+ *  called from any other user code.  The @file{options.h} header is
+ *  fairly clear about this, too.
+=*/
+
+/*=export_func optionProcess
+ *
+ * what: this is the main option processing routine
+ *
+ * arg:  + tOptions* + pOpts + program options descriptor +
+ * arg:  + int       + argc  + program arg count  +
+ * arg:  + char**    + argv  + program arg vector +
+ *
+ * ret_type:  int
+ * ret_desc:  the count of the arguments processed
+ *
+ * doc:
+ *
+ * This is the main entry point for processing options.  It is intended
+ * that this procedure be called once at the beginning of the execution of
+ * a program.  Depending on options selected earlier, it is sometimes
+ * necessary to stop and restart option processing, or to select completely
+ * different sets of options.  This can be done easily, but you generally
+ * do not want to do this.
+ *
+ * The number of arguments processed always includes the program name.
+ * If one of the arguments is "--", then it is counted and the processing
+ * stops.  If an error was encountered and errors are to be tolerated, then
+ * the returned value is the index of the argument causing the error.
+ * A hyphen by itself ("-") will also cause processing to stop and will
+ * @emph{not} be counted among the processed arguments.  A hyphen by itself
+ * is treated as an operand.  Encountering an operand stops option
+ * processing.
+ *
+ * err:  Errors will cause diagnostics to be printed.  @code{exit(3)} may
+ *       or may not be called.  It depends upon whether or not the options
+ *       were generated with the "allow-errors" attribute, or if the
+ *       ERRSKIP_OPTERR or ERRSTOP_OPTERR macros were invoked.
+=*/
+int
+optionProcess(
+    tOptions*  pOpts,
+    int        argCt,
+    char**     argVect )
+{
+    if (! SUCCESSFUL( validateOptionsStruct( pOpts, argVect[0] )))
+        exit( EX_SOFTWARE );
+
+    /*
+     *  Establish the real program name, the program full path,
+     *  and do all the presetting the first time thru only.
+     */
+    if ((pOpts->fOptSet & OPTPROC_INITDONE) == 0) {
+        pOpts->origArgCt   = argCt;
+        pOpts->origArgVect = argVect;
+        pOpts->fOptSet    |= OPTPROC_INITDONE;
+
+        if (! SUCCESSFUL( doPresets( pOpts )))
+            return 0;
+
+        if ((pOpts->fOptSet & OPTPROC_REORDER) != 0)
+            optionSort( pOpts );
+
+        pOpts->curOptIdx   = 1;
+        pOpts->pzCurOpt    = NULL;
+    }
+
+    /*
+     *  IF we are (re)starting,
+     *  THEN reset option location
+     */
+    else if (pOpts->curOptIdx <= 0) {
+        pOpts->curOptIdx = 1;
+        pOpts->pzCurOpt  = NULL;
+    }
+
+    if (! SUCCESSFUL( doRegularOpts( pOpts )))
+        return pOpts->origArgCt;
+
+    /*
+     *  IF    there were no errors
+     *    AND we have RC/INI files
+     *    AND there is a request to save the files
+     *  THEN do that now before testing for conflicts.
+     *       (conflicts are ignored in preset options)
+     */
+    if (pOpts->specOptIdx.save_opts != 0) {
+        tOptDesc*  pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts;
+
+        if (SELECTED_OPT( pOD )) {
+            optionSaveFile( pOpts );
+            exit( EXIT_SUCCESS );
+        }
+    }
+
+    /*
+     *  IF we are checking for errors,
+     *  THEN look for too few occurrences of required options
+     */
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+        if (checkConsistency( pOpts ) != 0)
+            (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+    }
+
+    return pOpts->curOptIdx;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/autoopts.c */
diff --git a/libopts/autoopts.h b/libopts/autoopts.h
new file mode 100644 (file)
index 0000000..2645757
--- /dev/null
@@ -0,0 +1,387 @@
+
+/*
+ *  Time-stamp:      "2007-04-15 09:59:39 bkorb"
+ *
+ *  autoopts.h  $Id: autoopts.h,v 4.23 2007/04/15 19:01:18 bkorb Exp $
+ *  Time-stamp:      "2005-02-14 05:59:50 bkorb"
+ *
+ *  This file defines all the global structures and special values
+ *  used in the automated option processing library.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+#ifndef AUTOGEN_AUTOOPTS_H
+#define AUTOGEN_AUTOOPTS_H
+
+#include "compat/compat.h"
+
+#define AO_NAME_LIMIT           127
+#define AO_NAME_SIZE            ((size_t)(AO_NAME_LIMIT + 1))
+
+#ifndef AG_PATH_MAX
+#  ifdef PATH_MAX
+#    define AG_PATH_MAX         ((size_t)PATH_MAX)
+#  else
+#    define AG_PATH_MAX         ((size_t)4096)
+#  endif
+#else
+#  if defined(PATH_MAX) && (PATH_MAX > MAXPATHLEN)
+#     undef  AG_PATH_MAX
+#     define AG_PATH_MAX        ((size_t)PATH_MAX)
+#  endif
+#endif
+
+#undef  EXPORT
+#define EXPORT
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# define DIRCH                  '\\'
+#else
+# define DIRCH                  '/'
+#endif
+
+#ifndef EX_NOINPUT
+#  define EX_NOINPUT            66
+#endif
+#ifndef EX_SOFTWARE
+#  define EX_SOFTWARE           70
+#endif
+#ifndef EX_CONFIG
+#  define EX_CONFIG             78
+#endif
+
+/*
+ *  Convert the number to a list usable in a printf call
+ */
+#define NUM_TO_VER(n)           ((n) >> 12), ((n) >> 7) & 0x001F, (n) & 0x007F
+
+#define NAMED_OPTS(po) \
+        (((po)->fOptSet & (OPTPROC_SHORTOPT | OPTPROC_LONGOPT)) == 0)
+
+#define SKIP_OPT(p)  (((p)->fOptState & (OPTST_DOCUMENT|OPTST_OMITTED)) != 0)
+
+typedef int tDirection;
+#define DIRECTION_PRESET        -1
+#define DIRECTION_PROCESS       1
+#define DIRECTION_CALLED        0
+
+#define PROCESSING(d)           ((d)>0)
+#define PRESETTING(d)           ((d)<0)
+
+#define ISNAMECHAR( c )         (isalnum(c) || ((c) == '_') || ((c) == '-'))
+
+/*
+ *  Procedure success codes
+ *
+ *  USAGE:  define procedures to return "tSuccess".  Test their results
+ *          with the SUCCEEDED, FAILED and HADGLITCH macros.
+ *
+ *  Microsoft sticks its nose into user space here, so for Windows' sake,
+ *  make sure all of these are undefined.
+ */
+#undef  SUCCESS
+#undef  FAILURE
+#undef  PROBLEM
+#undef  SUCCEEDED
+#undef  SUCCESSFUL
+#undef  FAILED
+#undef  HADGLITCH
+
+#define SUCCESS                 ((tSuccess) 0)
+#define FAILURE                 ((tSuccess)-1)
+#define PROBLEM                 ((tSuccess) 1)
+
+typedef int tSuccess;
+
+#define SUCCEEDED( p )          ((p) == SUCCESS)
+#define SUCCESSFUL( p )         SUCCEEDED( p )
+#define FAILED( p )             ((p) <  SUCCESS)
+#define HADGLITCH( p )          ((p) >  SUCCESS)
+
+/*
+ *  When loading a line (or block) of text as an option, the value can
+ *  be processed in any of several modes:
+ *
+ *  @table @samp
+ *  @item keep
+ *  Every part of the value between the delimiters is saved.
+ *
+ *  @item uncooked
+ *  Even if the value begins with quote characters, do not do quote processing.
+ *
+ *  @item cooked
+ *  If the value looks like a quoted string, then process it.
+ *  Double quoted strings are processed the way strings are in "C" programs,
+ *  except they are treated as regular characters if the following character
+ *  is not a well-established escape sequence.
+ *  Single quoted strings (quoted with apostrophies) are handled the way
+ *  strings are handled in shell scripts, *except* that backslash escapes
+ *  are honored before backslash escapes and apostrophies.
+ *  @end table
+ */
+typedef enum {
+    OPTION_LOAD_COOKED,
+    OPTION_LOAD_UNCOOKED,
+    OPTION_LOAD_KEEP
+} tOptionLoadMode;
+
+extern tOptionLoadMode option_load_mode;
+
+/*
+ *  The pager state is used by optionPagedUsage() procedure.
+ *  When it runs, it sets itself up to be called again on exit.
+ *  If, however, a routine needs a child process to do some work
+ *  before it is done, then 'pagerState' must be set to
+ *  'PAGER_STATE_CHILD' so that optionPagedUsage() will not try
+ *  to run the pager program before its time.
+ */
+typedef enum {
+    PAGER_STATE_INITIAL,
+    PAGER_STATE_READY,
+    PAGER_STATE_CHILD
+} tePagerState;
+
+extern tePagerState pagerState;
+
+typedef enum {
+    ENV_ALL,
+    ENV_IMM,
+    ENV_NON_IMM
+} teEnvPresetType;
+
+typedef enum {
+    TOPT_UNDEFINED = 0,
+    TOPT_SHORT,
+    TOPT_LONG,
+    TOPT_DEFAULT
+} teOptType;
+
+typedef struct {
+    tOptDesc*  pOD;
+    tCC*       pzOptArg;
+    tAoUL      flags;
+    teOptType  optType;
+} tOptState;
+#define OPTSTATE_INITIALIZER(st) \
+    { NULL, NULL, OPTST_ ## st, TOPT_UNDEFINED }
+
+#define TEXTTO_TABLE \
+        _TT_( LONGUSAGE ) \
+        _TT_( USAGE ) \
+        _TT_( VERSION )
+#define _TT_(n) \
+        TT_ ## n ,
+
+typedef enum { TEXTTO_TABLE COUNT_TT } teTextTo;
+
+#undef _TT_
+
+typedef struct {
+    tCC*    pzStr;
+    tCC*    pzReq;
+    tCC*    pzNum;
+    tCC*    pzKey;
+    tCC*    pzKeyL;
+    tCC*    pzBool;
+    tCC*    pzNest;
+    tCC*    pzOpt;
+    tCC*    pzNo;
+    tCC*    pzBrk;
+    tCC*    pzNoF;
+    tCC*    pzSpc;
+    tCC*    pzOptFmt;
+} arg_types_t;
+
+#define AGALOC( c, w )          ao_malloc((size_t)c)
+#define AGREALOC( p, c, w )     ao_realloc((void*)p, (size_t)c)
+#define AGFREE( p )             ao_free((void*)p)
+#define AGDUPSTR( p, s, w )     (p = ao_strdup(s))
+
+static void *
+ao_malloc( size_t sz );
+
+static void *
+ao_realloc( void *p, size_t sz );
+
+static void
+ao_free( void *p );
+
+static char *
+ao_strdup( char const *str );
+
+#define TAGMEM( m, t )
+
+/*
+ *  DO option handling?
+ *
+ *  Options are examined at two times:  at immediate handling time and at
+ *  normal handling time.  If an option is disabled, the timing may be
+ *  different from the handling of the undisabled option.  The OPTST_DIABLED
+ *  bit indicates the state of the currently discovered option.
+ *  So, here's how it works:
+ *
+ *  A) handling at "immediate" time, either 1 or 2:
+ *
+ *  1.  OPTST_DISABLED is not set:
+ *      IMM           must be set
+ *      DISABLE_IMM   don't care
+ *      TWICE         don't care
+ *      DISABLE_TWICE don't care
+ *      0 -and-  1 x x x
+ *
+ *  2.  OPTST_DISABLED is set:
+ *      IMM           don't care
+ *      DISABLE_IMM   must be set
+ *      TWICE         don't care
+ *      DISABLE_TWICE don't care
+ *      1 -and-  x 1 x x
+ */
+#define DO_IMMEDIATELY(_flg) \
+    (  (((_flg) & (OPTST_DISABLED|OPTST_IMM)) == OPTST_IMM) \
+    || (   ((_flg) & (OPTST_DISABLED|OPTST_DISABLE_IMM))    \
+        == (OPTST_DISABLED|OPTST_DISABLE_IMM)  ))
+
+/*  B) handling at "regular" time because it was not immediate
+ *
+ *  1.  OPTST_DISABLED is not set:
+ *      IMM           must *NOT* be set
+ *      DISABLE_IMM   don't care
+ *      TWICE         don't care
+ *      DISABLE_TWICE don't care
+ *      0 -and-  0 x x x
+ *
+ *  2.  OPTST_DISABLED is set:
+ *      IMM           don't care
+ *      DISABLE_IMM   don't care
+ *      TWICE         must be set
+ *      DISABLE_TWICE don't care
+ *      1 -and-  x x 1 x
+ */
+#define DO_NORMALLY(_flg) ( \
+       (((_flg) & (OPTST_DISABLED|OPTST_IMM))            == 0)  \
+    || (((_flg) & (OPTST_DISABLED|OPTST_DISABLE_IMM))    ==     \
+                  OPTST_DISABLED)  )
+
+/*  C)  handling at "regular" time because it is to be handled twice.
+ *      The immediate bit was already tested and found to be set:
+ *
+ *  3.  OPTST_DISABLED is not set:
+ *      IMM           is set (but don't care)
+ *      DISABLE_IMM   don't care
+ *      TWICE         must be set
+ *      DISABLE_TWICE don't care
+ *      0 -and-  ? x 1 x
+ *
+ *  4.  OPTST_DISABLED is set:
+ *      IMM           don't care
+ *      DISABLE_IMM   is set (but don't care)
+ *      TWICE         don't care
+ *      DISABLE_TWICE must be set
+ *      1 -and-  x ? x 1
+ */
+#define DO_SECOND_TIME(_flg) ( \
+       (((_flg) & (OPTST_DISABLED|OPTST_TWICE))          ==     \
+                  OPTST_TWICE)                                  \
+    || (((_flg) & (OPTST_DISABLED|OPTST_DISABLE_TWICE))  ==     \
+                  (OPTST_DISABLED|OPTST_DISABLE_TWICE)  ))
+
+/*
+ *  text_mmap structure.  Only active on platforms with mmap(2).
+ */
+#ifdef HAVE_SYS_MMAN_H
+#  include <sys/mman.h>
+#else
+#  ifndef  PROT_READ
+#   define PROT_READ            0x01
+#  endif
+#  ifndef  PROT_WRITE
+#   define PROT_WRITE           0x02
+#  endif
+#  ifndef  MAP_SHARED
+#   define MAP_SHARED           0x01
+#  endif
+#  ifndef  MAP_PRIVATE
+#   define MAP_PRIVATE          0x02
+#  endif
+#endif
+
+#ifndef MAP_FAILED
+#  define  MAP_FAILED           ((void*)-1)
+#endif
+
+#ifndef  _SC_PAGESIZE
+# ifdef  _SC_PAGE_SIZE
+#  define _SC_PAGESIZE          _SC_PAGE_SIZE
+# endif
+#endif
+
+#ifndef HAVE_STRCHR
+extern char* strchr( char const *s, int c);
+extern char* strrchr( char const *s, int c);
+#endif
+
+/*
+ *  Define and initialize all the user visible strings.
+ *  We do not do translations.  If translations are to be done, then
+ *  the client will provide a callback for that purpose.
+ */
+#undef DO_TRANSLATIONS
+#include "autoopts/usage-txt.h"
+
+/*
+ *  File pointer for usage output
+ */
+extern FILE* option_usage_fp;
+
+extern tOptProc optionPrintVersion, optionPagedUsage, optionLoadOpt;
+
+#endif /* AUTOGEN_AUTOOPTS_H */
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/autoopts.h */
diff --git a/libopts/autoopts/options.h b/libopts/autoopts/options.h
new file mode 100644 (file)
index 0000000..c2ceeb3
--- /dev/null
@@ -0,0 +1,977 @@
+/*   -*- buffer-read-only: t -*- vi: set ro:
+ *  
+ *  DO NOT EDIT THIS FILE   (options.h)
+ *  
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:34 PM PDT
+ *  From the definitions    funcs.def
+ *  and the template file   options_h
+ *
+ *  This file defines all the global structures and special values
+ *  used in the automated option processing library.
+ *
+ *  Automated Options copyright 1992-Y Bruce Korb
+ *
+ *  AutoOpts is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *  
+ *  AutoOpts is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with AutoOpts.  If not, write to:
+ *     The Free Software Foundation, Inc.,
+ *     51 Franklin Street, Fifth Floor
+ *     Boston, MA  02110-1301, USA.
+ */
+#ifndef AUTOOPTS_OPTIONS_H_GUARD
+#define AUTOOPTS_OPTIONS_H_GUARD
+#include <sys/types.h>
+
+#if defined(HAVE_STDINT_H)
+# include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+# include <inttypes.h>
+#endif /* HAVE_STDINT/INTTYPES_H */
+
+#if defined(HAVE_LIMITS_H)
+# include <limits.h>
+#elif defined(HAVE_SYS_LIMITS_H)
+# include <sys/limits.h>
+#endif /* HAVE_LIMITS/SYS_LIMITS_H */
+
+#if defined(HAVE_SYSEXITS_H)
+#  include <sysexits.h>
+#endif /* HAVE_SYSEXITS_H */
+
+#ifndef EX_USAGE
+#  define EX_USAGE              64
+#endif
+
+/*
+ *  PUBLIC DEFINES
+ *
+ *  The following defines may be used in applications that need to test the
+ *  state of an option.  To test against these masks and values, a pointer
+ *  to an option descriptor must be obtained.  There are two ways:
+ *
+ *  1. inside an option processing procedure, it is the second argument,
+ *  conventionally "tOptDesc* pOD".
+ *
+ *  2.  Outside of an option procedure (or to reference a different option
+ *  descriptor), use either "&DESC( opt_name )" or "&pfx_DESC( opt_name )".
+ *
+ *  See the relevant generated header file to determine which and what
+ *  values for "opt_name" are available.
+ */
+
+#define  OPTIONS_STRUCT_VERSION  118784
+#define  OPTIONS_VERSION_STRING  "29:0:4"
+#define  OPTIONS_MINIMUM_VERSION 102400
+#define  OPTIONS_MIN_VER_STRING  "25:0:0"
+
+typedef enum {
+    OPARG_TYPE_NONE             = 0,
+    OPARG_TYPE_STRING           = 1,    /* default type/ vanilla string      */
+    OPARG_TYPE_ENUMERATION      = 2,    /* opt arg is an enum (keyword list) */
+    OPARG_TYPE_BOOLEAN          = 3,    /* opt arg is boolean-valued         */
+    OPARG_TYPE_MEMBERSHIP       = 4,    /* opt arg sets set membership bits  */
+    OPARG_TYPE_NUMERIC          = 5,    /* opt arg has numeric value         */
+    OPARG_TYPE_HIERARCHY        = 6     /* option arg is hierarchical value  */
+} teOptArgType;
+
+typedef struct optionValue {
+    teOptArgType        valType;
+    char*               pzName;
+    union {
+        char            strVal[1];      /* OPARG_TYPE_STRING      */
+        unsigned int    enumVal;        /* OPARG_TYPE_ENUMERATION */
+        unsigned int    boolVal;        /* OPARG_TYPE_BOOLEAN     */
+        unsigned long   setVal;         /* OPARG_TYPE_MEMBERSHIP  */
+        long            longVal;        /* OPARG_TYPE_NUMERIC     */
+        void*           nestVal;        /* OPARG_TYPE_HIERARCHY   */
+    } v;
+} tOptionValue;
+
+/*
+ *  Bits in the fOptState option descriptor field.
+ */
+typedef enum {
+    OPTST_SET_ID             =   0, /* Set via the "SET_OPT()" macro */
+    OPTST_PRESET_ID          =   1, /* Set via an RC/INI file        */
+    OPTST_DEFINED_ID         =   2, /* Set via a command line option */
+    OPTST_EQUIVALENCE_ID     =   4, /* selected by equiv'ed option   */
+    OPTST_DISABLED_ID        =   5, /* option is in disabled state   */
+    OPTST_ALLOC_ARG_ID       =   6, /* pzOptArg was allocated        */
+    OPTST_NO_INIT_ID         =   8, /* option cannot be preset       */
+    OPTST_NUMBER_OPT_ID      =   9, /* opt value (flag) is any digit */
+    OPTST_STACKED_ID         =  10, /* opt uses optionStackArg proc  */
+    OPTST_INITENABLED_ID     =  11, /* option defaults to enabled    */
+    OPTST_ARG_TYPE_1_ID      =  12, /* bit 1 of arg type enum        */
+    OPTST_ARG_TYPE_2_ID      =  13, /* bit 2 of arg type enum        */
+    OPTST_ARG_TYPE_3_ID      =  14, /* bit 3 of arg type enum        */
+    OPTST_ARG_TYPE_4_ID      =  15, /* bit 4 of arg type enum        */
+    OPTST_ARG_OPTIONAL_ID    =  16, /* the option arg not required   */
+    OPTST_IMM_ID             =  17, /* process opt on first pass     */
+    OPTST_DISABLE_IMM_ID     =  18, /* process disablement immed.    */
+    OPTST_OMITTED_ID         =  19, /* compiled out of program       */
+    OPTST_MUST_SET_ID        =  20, /* must be set or pre-set        */
+    OPTST_DOCUMENT_ID        =  21, /* opt is for doc only           */
+    OPTST_TWICE_ID           =  22, /* process opt twice - imm + reg */
+    OPTST_DISABLE_TWICE_ID   =  23  /* process disabled option twice */
+} opt_state_enum_t;
+
+#define OPTST_INIT           0U
+#define OPTST_SET            (1U << OPTST_SET_ID)
+#define OPTST_PRESET         (1U << OPTST_PRESET_ID)
+#define OPTST_DEFINED        (1U << OPTST_DEFINED_ID)
+#define OPTST_EQUIVALENCE    (1U << OPTST_EQUIVALENCE_ID)
+#define OPTST_DISABLED       (1U << OPTST_DISABLED_ID)
+#define OPTST_ALLOC_ARG      (1U << OPTST_ALLOC_ARG_ID)
+#define OPTST_NO_INIT        (1U << OPTST_NO_INIT_ID)
+#define OPTST_NUMBER_OPT     (1U << OPTST_NUMBER_OPT_ID)
+#define OPTST_STACKED        (1U << OPTST_STACKED_ID)
+#define OPTST_INITENABLED    (1U << OPTST_INITENABLED_ID)
+#define OPTST_ARG_TYPE_1     (1U << OPTST_ARG_TYPE_1_ID)
+#define OPTST_ARG_TYPE_2     (1U << OPTST_ARG_TYPE_2_ID)
+#define OPTST_ARG_TYPE_3     (1U << OPTST_ARG_TYPE_3_ID)
+#define OPTST_ARG_TYPE_4     (1U << OPTST_ARG_TYPE_4_ID)
+#define OPTST_ARG_OPTIONAL   (1U << OPTST_ARG_OPTIONAL_ID)
+#define OPTST_IMM            (1U << OPTST_IMM_ID)
+#define OPTST_DISABLE_IMM    (1U << OPTST_DISABLE_IMM_ID)
+#define OPTST_OMITTED        (1U << OPTST_OMITTED_ID)
+#define OPTST_MUST_SET       (1U << OPTST_MUST_SET_ID)
+#define OPTST_DOCUMENT       (1U << OPTST_DOCUMENT_ID)
+#define OPTST_TWICE          (1U << OPTST_TWICE_ID)
+#define OPTST_DISABLE_TWICE  (1U << OPTST_DISABLE_TWICE_ID)
+#define OPT_STATE_MASK       0x00FFFF77U
+
+#define OPTST_SET_MASK       (  \
+        OPTST_SET | \
+        OPTST_PRESET | \
+        OPTST_DEFINED )
+
+#define OPTST_MUTABLE_MASK   (  \
+        OPTST_SET | \
+        OPTST_PRESET | \
+        OPTST_DEFINED | \
+        OPTST_EQUIVALENCE | \
+        OPTST_DISABLED | \
+        OPTST_ALLOC_ARG )
+
+#define OPTST_SELECTED_MASK  (  \
+        OPTST_SET | \
+        OPTST_DEFINED )
+
+#define OPTST_ARG_TYPE_MASK  (  \
+        OPTST_ARG_TYPE_1 | \
+        OPTST_ARG_TYPE_2 | \
+        OPTST_ARG_TYPE_3 | \
+        OPTST_ARG_TYPE_4 )
+
+#ifdef NO_OPTIONAL_OPT_ARGS
+# undef  OPTST_ARG_OPTIONAL
+# define OPTST_ARG_OPTIONAL   0
+#endif
+
+#define OPTST_PERSISTENT_MASK (~OPTST_MUTABLE_MASK)
+
+#define SELECTED_OPT( pod )   ((pod)->fOptState  & OPTST_SELECTED_MASK)
+#define UNUSED_OPT(   pod )   (((pod)->fOptState & OPTST_SET_MASK) == 0)
+#define DISABLED_OPT( pod )   ((pod)->fOptState  & OPTST_DISABLED)
+#define OPTION_STATE( pod )   ((pod)->fOptState)
+
+#define OPTST_SET_ARGTYPE(n)  ((n) << OPTST_ARG_TYPE_1_ID)
+#define OPTST_GET_ARGTYPE(f)  (((f) & OPTST_ARG_TYPE_MASK)>>OPTST_ARG_TYPE_1_ID)
+
+/*
+ *  PRIVATE INTERFACES
+ *
+ *  The following values are used in the generated code to communicate
+ *  with the option library procedures.  They are not for public use
+ *  and may be subject to change.
+ */
+
+/*
+ *  Define the processing state flags
+ */
+typedef enum {
+    OPTPROC_LONGOPT_ID       =   0, /* Process long style options      */
+    OPTPROC_SHORTOPT_ID      =   1, /* Process short style "flags"     */
+    OPTPROC_ERRSTOP_ID       =   2, /* Stop on argument errors         */
+    OPTPROC_DISABLEDOPT_ID   =   3, /* Current option is disabled      */
+    OPTPROC_NO_REQ_OPT_ID    =   4, /* no options are required         */
+    OPTPROC_NUM_OPT_ID       =   5, /* there is a number option        */
+    OPTPROC_INITDONE_ID      =   6, /* have initializations been done? */
+    OPTPROC_NEGATIONS_ID     =   7, /* any negation options?           */
+    OPTPROC_ENVIRON_ID       =   8, /* check environment?              */
+    OPTPROC_NO_ARGS_ID       =   9, /* Disallow remaining arguments    */
+    OPTPROC_ARGS_REQ_ID      =  10, /* Require arguments after options */
+    OPTPROC_REORDER_ID       =  11, /* reorder operands after options  */
+    OPTPROC_GNUUSAGE_ID      =  12, /* emit usage in GNU style         */
+    OPTPROC_TRANSLATE_ID     =  13, /* Translate strings in tOptions   */
+    OPTPROC_HAS_IMMED_ID     =  14, /* program defines immed options   */
+    OPTPROC_PRESETTING_ID    =  19  /* opt processing in preset state  */
+} optproc_state_enum_t;
+
+#define OPTPROC_NONE         0U
+#define OPTPROC_LONGOPT      (1U << OPTPROC_LONGOPT_ID)
+#define OPTPROC_SHORTOPT     (1U << OPTPROC_SHORTOPT_ID)
+#define OPTPROC_ERRSTOP      (1U << OPTPROC_ERRSTOP_ID)
+#define OPTPROC_DISABLEDOPT  (1U << OPTPROC_DISABLEDOPT_ID)
+#define OPTPROC_NO_REQ_OPT   (1U << OPTPROC_NO_REQ_OPT_ID)
+#define OPTPROC_NUM_OPT      (1U << OPTPROC_NUM_OPT_ID)
+#define OPTPROC_INITDONE     (1U << OPTPROC_INITDONE_ID)
+#define OPTPROC_NEGATIONS    (1U << OPTPROC_NEGATIONS_ID)
+#define OPTPROC_ENVIRON      (1U << OPTPROC_ENVIRON_ID)
+#define OPTPROC_NO_ARGS      (1U << OPTPROC_NO_ARGS_ID)
+#define OPTPROC_ARGS_REQ     (1U << OPTPROC_ARGS_REQ_ID)
+#define OPTPROC_REORDER      (1U << OPTPROC_REORDER_ID)
+#define OPTPROC_GNUUSAGE     (1U << OPTPROC_GNUUSAGE_ID)
+#define OPTPROC_TRANSLATE    (1U << OPTPROC_TRANSLATE_ID)
+#define OPTPROC_HAS_IMMED    (1U << OPTPROC_HAS_IMMED_ID)
+#define OPTPROC_PRESETTING   (1U << OPTPROC_PRESETTING_ID)
+#define OPTPROC_STATE_MASK   0x00087FFFU
+
+#define STMTS(s)  do { s; } while (0)
+
+/*
+ *  The following must be #defined instead of typedef-ed
+ *  because "static const" cannot both be applied to a type,
+ *  tho each individually can...so they all are
+ */
+#define tSCC        static char const
+#define tCC         char const
+#define tAoSC       static char
+#define tAoUC       unsigned char
+#define tAoUI       unsigned int
+#define tAoUL       unsigned long
+#define tAoUS       unsigned short
+
+/*
+ *  It is so disgusting that there must be so many ways
+ *  of specifying TRUE and FALSE.
+ */
+typedef enum { AG_FALSE = 0, AG_TRUE } ag_bool;
+
+/*
+ *  Define a structure that describes each option and
+ *  a pointer to the procedure that handles it.
+ *  The argument is the count of this flag previously seen.
+ */
+typedef struct options  tOptions;
+typedef struct optDesc  tOptDesc;
+typedef struct optNames tOptNames;
+
+/*
+ *  The option procedures do the special processing for each
+ *  option flag that needs it.
+ */
+typedef void (tOptProc)( tOptions*  pOpts, tOptDesc* pOptDesc );
+typedef tOptProc*  tpOptProc;
+
+/*
+ *  The usage procedure will never return.  It calls "exit(2)"
+ *  with the "exitCode" argument passed to it.
+ */
+typedef void (tUsageProc)( tOptions* pOpts, int exitCode );
+typedef tUsageProc* tpUsageProc;
+
+/*
+ *  Special definitions.  "NOLIMIT" is the 'max' value to use when
+ *  a flag may appear multiple times without limit.  "NO_EQUIVALENT"
+ *  is an illegal value for 'optIndex' (option description index).
+ */
+#define NOLIMIT          USHRT_MAX
+#define OPTION_LIMIT     SHRT_MAX
+#define NO_EQUIVALENT    (OPTION_LIMIT+1)
+
+/*
+ *  Special values for optValue.  It must not be generatable from the
+ *  computation "optIndex +96".  Since "optIndex" is limited to 100, ...
+ */
+#define NUMBER_OPTION    '#'
+
+typedef struct argList tArgList;
+#define MIN_ARG_ALLOC_CT   6
+#define INCR_ARG_ALLOC_CT  8
+struct argList {
+    int             useCt;
+    int             allocCt;
+    tCC*            apzArgs[ MIN_ARG_ALLOC_CT ];
+};
+
+typedef union {
+    char const *    argString;
+    uintptr_t       argEnum;
+    uintptr_t       argIntptr;
+    long            argInt;
+    unsigned long   argUint;
+    unsigned int    argBool;
+} optArgBucket_t;
+
+/*
+ *  Descriptor structure for each option.
+ *  Only the fields marked "PUBLIC" are for public use.
+ */
+struct optDesc {
+    tAoUS const     optIndex;         /* PUBLIC */
+    tAoUS const     optValue;         /* PUBLIC */
+    tAoUS           optActualIndex;   /* PUBLIC */
+    tAoUS           optActualValue;   /* PUBLIC */
+
+    tAoUS const     optEquivIndex;    /* PUBLIC */
+    tAoUS const     optMinCt;
+    tAoUS const     optMaxCt;
+    tAoUS           optOccCt;         /* PUBLIC */
+
+    tAoUI           fOptState;        /* PUBLIC */
+    tAoUI           reserved;
+    optArgBucket_t  optArg;           /* PUBLIC */
+#   define          pzLastArg   optArg.argString
+    void*           optCookie;        /* PUBLIC */
+
+    const int *     pOptMust;
+    const int *     pOptCant;
+    tpOptProc       pOptProc;
+    char const*     pzText;
+
+    char const*     pz_NAME;
+    char const*     pz_Name;
+    char const*     pz_DisableName;
+    char const*     pz_DisablePfx;
+};
+
+/*
+ *  Some options need special processing, so we store their
+ *  indexes in a known place:
+ */
+typedef struct optSpecIndex tOptSpecIndex;
+struct optSpecIndex {
+    const tAoUS         more_help;
+    const tAoUS         save_opts;
+    const tAoUS         number_option;
+    const tAoUS         default_opt;
+};
+
+/*
+ *  The procedure generated for translating option text
+ */
+typedef void (tOptionXlateProc)(void);
+
+struct options {
+    int const           structVersion;
+    int                 origArgCt;
+    char**              origArgVect;
+    unsigned int        fOptSet;
+    unsigned int        curOptIdx;
+    char*               pzCurOpt;
+
+    char const*         pzProgPath;
+    char const*         pzProgName;
+    char const* const   pzPROGNAME;
+    char const* const   pzRcName;
+    char const* const   pzCopyright;
+    char const* const   pzCopyNotice;
+    char const* const   pzFullVersion;
+    char const* const* const papzHomeList;
+    char const* const   pzUsageTitle;
+    char const* const   pzExplain;
+    char const* const   pzDetail;
+    tOptDesc*   const   pOptDesc;
+    char const* const   pzBugAddr;
+
+    void*               pExtensions;
+    void*               pSavedState;
+
+    tpUsageProc         pUsageProc;
+    tOptionXlateProc*   pTransProc;
+
+    tOptSpecIndex       specOptIdx;
+    int const           optCt;
+    int const           presetOptCt;
+};
+
+/*
+ *  "token list" structure returned by "string_tokenize()"
+ */
+typedef struct {
+    unsigned long   tkn_ct;
+    unsigned char*  tkn_list[1];
+} token_list_t;
+
+/*
+ *  Hide the interface - it pollutes a POSIX claim, but leave it for
+ *  anyone #include-ing this header
+ */
+#define strneqvcmp      option_strneqvcmp
+#define streqvcmp       option_streqvcmp
+#define streqvmap       option_streqvmap
+#define strequate       option_strequate
+#define strtransform    option_strtransform
+
+/*
+ *  This is an output only structure used by text_mmap and text_munmap.
+ *  Clients must not alter the contents and must provide it to both
+ *  the text_mmap and text_munmap procedures.  BE ADVISED: if you are
+ *  mapping the file with PROT_WRITE the NUL byte at the end MIGHT NOT
+ *  BE WRITABLE.  In any event, that byte is not be written back
+ *  to the source file.  ALSO: if "txt_data" is valid and "txt_errno"
+ *  is not zero, then there *may* not be a terminating NUL.
+ */
+typedef struct {
+    void*       txt_data;      /* text file data   */
+    size_t      txt_size;      /* actual file size */
+    size_t      txt_full_size; /* mmaped mem size  */
+    int         txt_fd;        /* file descriptor  */
+    int         txt_zero_fd;   /* fd for /dev/zero */
+    int         txt_errno;     /* warning code     */
+    int         txt_prot;      /* "prot" flags     */
+    int         txt_flags;     /* mapping type     */
+    int         txt_alloc;     /* if we malloced memory */
+} tmap_info_t;
+
+#define TEXT_MMAP_FAILED_ADDR(a)  ((void*)(a) ==  (void*)MAP_FAILED)
+
+#ifdef  __cplusplus
+extern "C" {
+#define CPLUSPLUS_CLOSER }
+#else
+#define CPLUSPLUS_CLOSER
+#endif
+
+/*
+ *  The following routines may be coded into AutoOpts client code:
+ */
+
+/* From: tokenize.c line 115
+ *
+ * ao_string_tokenize - tokenize an input string
+ *
+ * Arguments:
+ *   string       string to be tokenized
+ *
+ * Returns: token_list_t* - pointer to a structure that lists each token
+ *
+ *  This function will convert one input string into a list of strings.
+ *  The list of strings is derived by separating the input based on
+ *  white space separation.  However, if the input contains either single
+ *  or double quote characters, then the text after that character up to
+ *  a matching quote will become the string in the list.
+ *  
+ *  The returned pointer should be deallocated with @code{free(3C)} when
+ *  are done using the data.  The data are placed in a single block of
+ *  allocated memory.  Do not deallocate individual token/strings.
+ *  
+ *  The structure pointed to will contain at least these two fields:
+ *  @table @samp
+ *  @item tkn_ct
+ *  The number of tokens found in the input string.
+ *  @item tok_list
+ *  An array of @code{tkn_ct + 1} pointers to substring tokens, with
+ *  the last pointer set to NULL.
+ *  @end table
+ *  
+ *  There are two types of quoted strings: single quoted (@code{'}) and
+ *  double quoted (@code{"}).  Singly quoted strings are fairly raw in that
+ *  escape characters (@code{\\}) are simply another character, except when
+ *  preceding the following characters:
+ *  @example
+ *  @code{\\}  double backslashes reduce to one
+ *  @code{'}   incorporates the single quote into the string
+ *  @code{\n}  suppresses both the backslash and newline character
+ *  @end example
+ *  
+ *  Double quote strings are formed according to the rules of string
+ *  constants in ANSI-C programs.
+ */
+extern token_list_t* ao_string_tokenize( char const* );
+
+
+/* From: configfile.c line 113
+ *
+ * configFileLoad - parse a configuration file
+ *
+ * Arguments:
+ *   pzFile       the file to load
+ *
+ * Returns: const tOptionValue* - An allocated, compound value structure
+ *
+ *  This routine will load a named configuration file and parse the
+ *  text as a hierarchically valued option.  The option descriptor
+ *  created from an option definition file is not used via this interface.
+ *  The returned value is "named" with the input file name and is of
+ *  type "@code{OPARG_TYPE_HIERARCHY}".  It may be used in calls to
+ *  @code{optionGetValue()}, @code{optionNextValue()} and
+ *  @code{optionUnloadNested()}.
+ */
+extern const tOptionValue* configFileLoad( char const* );
+
+
+/* From: configfile.c line 883
+ *
+ * optionFileLoad - Load the locatable config files, in order
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *   pzProg       program name
+ *
+ * Returns: int - 0 -> SUCCESS, -1 -> FAILURE
+ *
+ *  This function looks in all the specified directories for a configuration
+ *  file ("rc" file or "ini" file) and processes any found twice.  The first
+ *  time through, they are processed in reverse order (last file first).  At
+ *  that time, only "immediate action" configurables are processed.  For
+ *  example, if the last named file specifies not processing any more
+ *  configuration files, then no more configuration files will be processed.
+ *  Such an option in the @strong{first} named directory will have no effect.
+ *  
+ *  Once the immediate action configurables have been handled, then the
+ *  directories are handled in normal, forward order.  In that way, later
+ *  config files can override the settings of earlier config files.
+ *  
+ *  See the AutoOpts documentation for a thorough discussion of the
+ *  config file format.
+ *  
+ *  Configuration files not found or not decipherable are simply ignored.
+ */
+extern int optionFileLoad( tOptions*, char const* );
+
+
+/* From: configfile.c line 245
+ *
+ * optionFindNextValue - find a hierarcicaly valued option instance
+ *
+ * Arguments:
+ *   pOptDesc     an option with a nested arg type
+ *   pPrevVal     the last entry
+ *   name         name of value to find
+ *   value        the matching value
+ *
+ * Returns: const tOptionValue* - a compound value structure
+ *
+ *  This routine will find the next entry in a nested value option or
+ *  configurable.  It will search through the list and return the next entry
+ *  that matches the criteria.
+ */
+extern const tOptionValue* optionFindNextValue( const tOptDesc*, const tOptionValue*, char const*, char const* );
+
+
+/* From: configfile.c line 171
+ *
+ * optionFindValue - find a hierarcicaly valued option instance
+ *
+ * Arguments:
+ *   pOptDesc     an option with a nested arg type
+ *   name         name of value to find
+ *   value        the matching value
+ *
+ * Returns: const tOptionValue* - a compound value structure
+ *
+ *  This routine will find an entry in a nested value option or configurable.
+ *  It will search through the list and return a matching entry.
+ */
+extern const tOptionValue* optionFindValue( const tOptDesc*, char const*, char const* );
+
+
+/* From: restore.c line 188
+ *
+ * optionFree - free allocated option processing memory
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *
+ *  AutoOpts sometimes allocates memory and puts pointers to it in the
+ *  option state structures.  This routine deallocates all such memory.
+ */
+extern void optionFree( tOptions* );
+
+
+/* From: configfile.c line 314
+ *
+ * optionGetValue - get a specific value from a hierarcical list
+ *
+ * Arguments:
+ *   pOptValue    a hierarchcal value
+ *   valueName    name of value to get
+ *
+ * Returns: const tOptionValue* - a compound value structure
+ *
+ *  This routine will find an entry in a nested value option or configurable.
+ *  If "valueName" is NULL, then the first entry is returned.  Otherwise,
+ *  the first entry with a name that exactly matches the argument will be
+ *  returned.
+ */
+extern const tOptionValue* optionGetValue( const tOptionValue*, char const* );
+
+
+/* From: load.c line 521
+ *
+ * optionLoadLine - process a string for an option name and value
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *   pzLine       NUL-terminated text
+ *
+ *  This is a client program callable routine for setting options from, for
+ *  example, the contents of a file that they read in.  Only one option may
+ *  appear in the text.  It will be treated as a normal (non-preset) option.
+ *  
+ *  When passed a pointer to the option struct and a string, it will find
+ *  the option named by the first token on the string and set the option
+ *  argument to the remainder of the string.  The caller must NUL terminate
+ *  the string.  Any embedded new lines will be included in the option
+ *  argument.  If the input looks like one or more quoted strings, then the
+ *  input will be "cooked".  The "cooking" is identical to the string
+ *  formation used in AutoGen definition files (@pxref{basic expression}),
+ *  except that you may not use backquotes.
+ */
+extern void optionLoadLine( tOptions*, char const* );
+
+
+/* From: configfile.c line 373
+ *
+ * optionNextValue - get the next value from a hierarchical list
+ *
+ * Arguments:
+ *   pOptValue    a hierarchcal list value
+ *   pOldValue    a value from this list
+ *
+ * Returns: const tOptionValue* - a compound value structure
+ *
+ *  This routine will return the next entry after the entry passed in.  At the
+ *  end of the list, NULL will be returned.  If the entry is not found on the
+ *  list, NULL will be returned and "@var{errno}" will be set to EINVAL.
+ *  The "@var{pOldValue}" must have been gotten from a prior call to this
+ *  routine or to "@code{opitonGetValue()}".
+ */
+extern const tOptionValue* optionNextValue( const tOptionValue*, const tOptionValue* );
+
+
+/* From: usage.c line 128
+ *
+ * optionOnlyUsage - Print usage text for just the options
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *   ex_code      exit code for calling exit(3)
+ *
+ *  This routine will print only the usage for each option.
+ *  This function may be used when the emitted usage must incorporate
+ *  information not available to AutoOpts.
+ */
+extern void optionOnlyUsage( tOptions*, int );
+
+
+/* From: autoopts.c line 1012
+ *
+ * optionProcess - this is the main option processing routine
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *   argc         program arg count
+ *   argv         program arg vector
+ *
+ * Returns: int - the count of the arguments processed
+ *
+ *  This is the main entry point for processing options.  It is intended
+ *  that this procedure be called once at the beginning of the execution of
+ *  a program.  Depending on options selected earlier, it is sometimes
+ *  necessary to stop and restart option processing, or to select completely
+ *  different sets of options.  This can be done easily, but you generally
+ *  do not want to do this.
+ *  
+ *  The number of arguments processed always includes the program name.
+ *  If one of the arguments is "--", then it is counted and the processing
+ *  stops.  If an error was encountered and errors are to be tolerated, then
+ *  the returned value is the index of the argument causing the error.
+ *  A hyphen by itself ("-") will also cause processing to stop and will
+ *  @emph{not} be counted among the processed arguments.  A hyphen by itself
+ *  is treated as an operand.  Encountering an operand stops option
+ *  processing.
+ */
+extern int optionProcess( tOptions*, int, char** );
+
+
+/* From: restore.c line 145
+ *
+ * optionRestore - restore option state from memory copy
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *
+ *  Copy back the option state from saved memory.
+ *  The allocated memory is left intact, so this routine can be
+ *  called repeatedly without having to call optionSaveState again.
+ *  If you are restoring a state that was saved before the first call
+ *  to optionProcess(3AO), then you may change the contents of the
+ *  argc/argv parameters to optionProcess.
+ */
+extern void optionRestore( tOptions* );
+
+
+/* From: save.c line 334
+ *
+ * optionSaveFile - saves the option state to a file
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *
+ *  This routine will save the state of option processing to a file.  The name
+ *  of that file can be specified with the argument to the @code{--save-opts}
+ *  option, or by appending the @code{rcfile} attribute to the last
+ *  @code{homerc} attribute.  If no @code{rcfile} attribute was specified, it
+ *  will default to @code{.@i{programname}rc}.  If you wish to specify another
+ *  file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro.
+ */
+extern void optionSaveFile( tOptions* );
+
+
+/* From: restore.c line 93
+ *
+ * optionSaveState - saves the option state to memory
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *
+ *  This routine will allocate enough memory to save the current option
+ *  processing state.  If this routine has been called before, that memory
+ *  will be reused.  You may only save one copy of the option state.  This
+ *  routine may be called before optionProcess(3AO).  If you do call it
+ *  before the first call to optionProcess, then you may also change the
+ *  contents of argc/argv after you call optionRestore(3AO)
+ *  
+ *  In fact, more strongly put: it is safest to only use this function
+ *  before having processed any options.  In particular, the saving and
+ *  restoring of stacked string arguments and hierarchical values is
+ *  disabled.  The values are not saved.
+ */
+extern void optionSaveState( tOptions* );
+
+
+/* From: nested.c line 559
+ *
+ * optionUnloadNested - Deallocate the memory for a nested value
+ *
+ * Arguments:
+ *   pOptVal      the hierarchical value
+ *
+ *  A nested value needs to be deallocated.  The pointer passed in should
+ *  have been gotten from a call to @code{configFileLoad()} (See
+ *  @pxref{libopts-configFileLoad}).
+ */
+extern void optionUnloadNested( tOptionValue const * );
+
+
+/* From: version.c line 58
+ *
+ * optionVersion - return the compiled AutoOpts version number
+ *
+ * Returns: char const* - the version string in constant memory
+ *
+ *  Returns the full version string compiled into the library.
+ *  The returned string cannot be modified.
+ */
+extern char const* optionVersion( void );
+
+
+/* From: ../compat/pathfind.c line 34
+ *
+ * pathfind - fild a file in a list of directories
+ *
+ * Arguments:
+ *   path         colon separated list of search directories
+ *   file         the name of the file to look for
+ *   mode         the mode bits that must be set to match
+ *
+ * Returns: char* - the path to the located file
+ *
+ * the pathfind function is available only if HAVE_PATHFIND is not defined
+ *
+ *  pathfind looks for a a file with name "FILE" and "MODE" access
+ *  along colon delimited "PATH", and returns the full pathname as a
+ *  string, or NULL if not found.  If "FILE" contains a slash, then
+ *  it is treated as a relative or absolute path and "PATH" is ignored.
+ *  
+ *  @strong{NOTE}: this function is compiled into @file{libopts} only if
+ *  it is not natively supplied.
+ *  
+ *  The "MODE" argument is a string of option letters chosen from the
+ *  list below:
+ *  @example
+ *  Letter    Meaning
+ *  r         readable
+ *  w         writable
+ *  x         executable
+ *  f         normal file       (NOT IMPLEMENTED)
+ *  b         block special     (NOT IMPLEMENTED)
+ *  c         character special (NOT IMPLEMENTED)
+ *  d         directory         (NOT IMPLEMENTED)
+ *  p         FIFO (pipe)       (NOT IMPLEMENTED)
+ *  u         set user ID bit   (NOT IMPLEMENTED)
+ *  g         set group ID bit  (NOT IMPLEMENTED)
+ *  k         sticky bit        (NOT IMPLEMENTED)
+ *  s         size nonzero      (NOT IMPLEMENTED)
+ *  @end example
+ */
+#ifndef HAVE_PATHFIND
+extern char* pathfind( char const*, char const*, char const* );
+#endif /* HAVE_PATHFIND */
+
+
+/* From: streqvcmp.c line 233
+ *
+ * strequate - map a list of characters to the same value
+ *
+ * Arguments:
+ *   ch_list      characters to equivalence
+ *
+ *  Each character in the input string get mapped to the first character
+ *  in the string.
+ *  This function name is mapped to option_strequate so as to not conflict
+ *  with the POSIX name space.
+ */
+extern void strequate( char const* );
+
+
+/* From: streqvcmp.c line 143
+ *
+ * streqvcmp - compare two strings with an equivalence mapping
+ *
+ * Arguments:
+ *   str1         first string
+ *   str2         second string
+ *
+ * Returns: int - the difference between two differing characters
+ *
+ *  Using a character mapping, two strings are compared for "equivalence".
+ *  Each input character is mapped to a comparison character and the
+ *  mapped-to characters are compared for the two NUL terminated input strings.
+ *  This function name is mapped to option_streqvcmp so as to not conflict
+ *  with the POSIX name space.
+ */
+extern int streqvcmp( char const*, char const* );
+
+
+/* From: streqvcmp.c line 180
+ *
+ * streqvmap - Set the character mappings for the streqv functions
+ *
+ * Arguments:
+ *   From         Input character
+ *   To           Mapped-to character
+ *   ct           compare length
+ *
+ *  Set the character mapping.  If the count (@code{ct}) is set to zero, then
+ *  the map is cleared by setting all entries in the map to their index
+ *  value.  Otherwise, the "@code{From}" character is mapped to the "@code{To}"
+ *  character.  If @code{ct} is greater than 1, then @code{From} and @code{To}
+ *  are incremented and the process repeated until @code{ct} entries have been
+ *  set. For example,
+ *  @example
+ *  streqvmap( 'a', 'A', 26 );
+ *  @end example
+ *  @noindent
+ *  will alter the mapping so that all English lower case letters
+ *  will map to upper case.
+ *  
+ *  This function name is mapped to option_streqvmap so as to not conflict
+ *  with the POSIX name space.
+ */
+extern void streqvmap( char, char, int );
+
+
+/* From: streqvcmp.c line 102
+ *
+ * strneqvcmp - compare two strings with an equivalence mapping
+ *
+ * Arguments:
+ *   str1         first string
+ *   str2         second string
+ *   ct           compare length
+ *
+ * Returns: int - the difference between two differing characters
+ *
+ *  Using a character mapping, two strings are compared for "equivalence".
+ *  Each input character is mapped to a comparison character and the
+ *  mapped-to characters are compared for the two NUL terminated input strings.
+ *  The comparison is limited to @code{ct} bytes.
+ *  This function name is mapped to option_strneqvcmp so as to not conflict
+ *  with the POSIX name space.
+ */
+extern int strneqvcmp( char const*, char const*, int );
+
+
+/* From: streqvcmp.c line 259
+ *
+ * strtransform - convert a string into its mapped-to value
+ *
+ * Arguments:
+ *   dest         output string
+ *   src          input string
+ *
+ *  Each character in the input string is mapped and the mapped-to
+ *  character is put into the output.
+ *  This function name is mapped to option_strtransform so as to not conflict
+ *  with the POSIX name space.
+ */
+extern void strtransform( char*, char const* );
+
+/*  AutoOpts PRIVATE FUNCTIONS:  */
+tOptProc optionStackArg, optionUnstackArg, optionBooleanVal, optionNumericVal;
+
+extern char* ao_string_cook( char*, int* );
+
+extern unsigned int ao_string_cook_escape_char( char const*, char*, unsigned int );
+
+extern void export_options_to_guile( tOptions* );
+
+extern void genshelloptUsage( tOptions*, int );
+
+extern void optionBooleanVal( tOptions*, tOptDesc* );
+
+extern uintptr_t optionEnumerationVal( tOptions*, tOptDesc*, char const * const *, unsigned int );
+
+extern char const* optionKeywordName( tOptDesc*, unsigned int );
+
+extern void optionLoadOpt( tOptions*, tOptDesc* );
+
+extern ag_bool optionMakePath( char*, int, char const*, char const* );
+
+extern void optionNestedVal( tOptions*, tOptDesc* );
+
+extern void optionNumericVal( tOptions*, tOptDesc* );
+
+extern void optionPagedUsage( tOptions*, tOptDesc* );
+
+extern void optionParseShell( tOptions* );
+
+extern void optionPrintVersion( tOptions*, tOptDesc* );
+
+extern void optionPutShell( tOptions* );
+
+extern void optionSetMembers( tOptions*, tOptDesc*, char const * const *, unsigned int );
+
+extern void optionStackArg( tOptions*, tOptDesc* );
+
+extern void optionUnstackArg( tOptions*, tOptDesc* );
+
+extern void optionUsage( tOptions*, int );
+
+extern void optionVersionStderr( tOptions*, tOptDesc* );
+
+extern void* text_mmap( char const*, int, int, tmap_info_t* );
+
+extern int text_munmap( tmap_info_t* );
+
+CPLUSPLUS_CLOSER
+#endif /* AUTOOPTS_OPTIONS_H_GUARD */
+/*
+ * Local Variables:
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * options.h ends here */
diff --git a/libopts/autoopts/usage-txt.h b/libopts/autoopts/usage-txt.h
new file mode 100644 (file)
index 0000000..5aaaa01
--- /dev/null
@@ -0,0 +1,355 @@
+/*   -*- buffer-read-only: t -*- vi: set ro:
+ *  
+ *  DO NOT EDIT THIS FILE   (usage-txt.h)
+ *  
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:33 PM PDT
+ *  From the definitions    usage-txt.def
+ *  and the template file   usage-txt.tpl
+ *
+ *  This file handles all the bookkeeping required for tracking all the little
+ *  tiny strings used by the AutoOpts library.  There are 113
+ *  of them.  This is not versioned because it is entirely internal to the
+ *  library and accessed by client code only in a very well-controlled way:
+ *  they may substitute translated strings using a procedure that steps through
+ *  all the string pointers.
+ *
+ *  AutoOpts is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *  
+ *  AutoOpts is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with AutoOpts.  If not, write to:
+ *     The Free Software Foundation, Inc.,
+ *     51 Franklin Street, Fifth Floor
+ *     Boston, MA  02110-1301, USA.
+ */
+#ifndef AUTOOPTS_USAGE_TXT_H_GUARD
+#define AUTOOPTS_USAGE_TXT_H_GUARD
+
+#undef  cch_t
+#define cch_t char const
+
+/*
+ *  One structure to hold all the pointers to all the stringlets.
+ */
+typedef struct {
+  int       field_ct;
+  char*     utpz_GnuBoolArg;
+  char*     utpz_GnuKeyArg;
+  char*     utpz_GnuKeyLArg;
+  char*     utpz_GnuNumArg;
+  char*     utpz_GnuStrArg;
+  cch_t*    apz_str[ 108 ];
+} usage_text_t;
+
+/*
+ *  Declare the global structure with all the pointers to translated
+ *  strings.  This is then used by the usage generation procedure.
+ */
+extern usage_text_t option_usage_text;
+
+#if defined(AUTOOPTS_INTERNAL) /* DEFINE ALL THE STRINGS = = = = = */
+/*
+ *  Provide a mapping from a short name to fields in this structure.
+ */
+#define zAO_Bad               (option_usage_text.apz_str[  0])
+#define zAO_Big               (option_usage_text.apz_str[  1])
+#define zAO_Err               (option_usage_text.apz_str[  2])
+#define zAO_Sml               (option_usage_text.apz_str[  3])
+#define zAll                  (option_usage_text.apz_str[  4])
+#define zAlt                  (option_usage_text.apz_str[  5])
+#define zAmbigKey             (option_usage_text.apz_str[  6])
+#define zAmbiguous            (option_usage_text.apz_str[  7])
+#define zArgsMust             (option_usage_text.apz_str[  8])
+#define zAtMost               (option_usage_text.apz_str[  9])
+#define zAuto                 (option_usage_text.apz_str[ 10])
+#define zBadPipe              (option_usage_text.apz_str[ 11])
+#define zBadVerArg            (option_usage_text.apz_str[ 12])
+#define zCantFmt              (option_usage_text.apz_str[ 13])
+#define zCantSave             (option_usage_text.apz_str[ 14])
+#define zDefaultOpt           (option_usage_text.apz_str[ 15])
+#define zDis                  (option_usage_text.apz_str[ 16])
+#define zEnab                 (option_usage_text.apz_str[ 17])
+#define zEquiv                (option_usage_text.apz_str[ 18])
+#define zErrOnly              (option_usage_text.apz_str[ 19])
+#define zExamineFmt           (option_usage_text.apz_str[ 20])
+#define zFiveSpaces           (option_usage_text.apz_str[ 21])
+#define zFlagOkay             (option_usage_text.apz_str[ 22])
+#define zFmtFmt               (option_usage_text.apz_str[ 23])
+#define zForkFail             (option_usage_text.apz_str[ 24])
+#define zFSErrOptLoad         (option_usage_text.apz_str[ 25])
+#define zFSErrReadFile        (option_usage_text.apz_str[ 26])
+#define zGenshell             (option_usage_text.apz_str[ 27])
+#define zGnuBoolArg           (option_usage_text.utpz_GnuBoolArg)
+#define zGnuBreak             (option_usage_text.apz_str[ 28])
+#define zGnuKeyArg            (option_usage_text.utpz_GnuKeyArg)
+#define zGnuKeyLArg           (option_usage_text.utpz_GnuKeyLArg)
+#define zGnuNestArg           (option_usage_text.apz_str[ 29])
+#define zGnuNumArg            (option_usage_text.utpz_GnuNumArg)
+#define zGnuOptArg            (option_usage_text.apz_str[ 30])
+#define zGnuOptFmt            (option_usage_text.apz_str[ 31])
+#define zGnuStrArg            (option_usage_text.utpz_GnuStrArg)
+#define zIllOptChr            (option_usage_text.apz_str[ 32])
+#define zIllOptStr            (option_usage_text.apz_str[ 33])
+#define zIllegal              (option_usage_text.apz_str[ 34])
+#define zInvalOptDesc         (option_usage_text.apz_str[ 35])
+#define zKeyWords             (option_usage_text.apz_str[ 36])
+#define zLoadCooked           (option_usage_text.apz_str[ 37])
+#define zLoadKeep             (option_usage_text.apz_str[ 38])
+#define zLoadType             (option_usage_text.apz_str[ 39])
+#define zLoadUncooked         (option_usage_text.apz_str[ 40])
+#define zLtypeInteger         (option_usage_text.apz_str[ 41])
+#define zLtypeNest            (option_usage_text.apz_str[ 42])
+#define zLtypeString          (option_usage_text.apz_str[ 43])
+#define zLtypeBool            (option_usage_text.apz_str[ 44])
+#define zLtypeKeyword         (option_usage_text.apz_str[ 45])
+#define zLtypeSetMembership   (option_usage_text.apz_str[ 46])
+#define zMembers              (option_usage_text.apz_str[ 47])
+#define zMisArg               (option_usage_text.apz_str[ 48])
+#define zMultiEquiv           (option_usage_text.apz_str[ 49])
+#define zMust                 (option_usage_text.apz_str[ 50])
+#define zNeedOne              (option_usage_text.apz_str[ 51])
+#define zNoArg                (option_usage_text.apz_str[ 52])
+#define zNoArgs               (option_usage_text.apz_str[ 53])
+#define zNoCreat              (option_usage_text.apz_str[ 54])
+#define zNoFlags              (option_usage_text.apz_str[ 55])
+#define zNoKey                (option_usage_text.apz_str[ 56])
+#define zNoLim                (option_usage_text.apz_str[ 57])
+#define zNoPreset             (option_usage_text.apz_str[ 58])
+#define zNoRq_NoShrtTtl       (option_usage_text.apz_str[ 59])
+#define zNoRq_ShrtTtl         (option_usage_text.apz_str[ 60])
+#define zNoStat               (option_usage_text.apz_str[ 61])
+#define zNoState              (option_usage_text.apz_str[ 62])
+#define zNone                 (option_usage_text.apz_str[ 63])
+#define zNotDef               (option_usage_text.apz_str[ 64])
+#define zNotEnough            (option_usage_text.apz_str[ 65])
+#define zNotFile              (option_usage_text.apz_str[ 66])
+#define zNotNumber            (option_usage_text.apz_str[ 67])
+#define zNrmOptFmt            (option_usage_text.apz_str[ 68])
+#define zNumberOpt            (option_usage_text.apz_str[ 69])
+#define zOneSpace             (option_usage_text.apz_str[ 70])
+#define zOnlyOne              (option_usage_text.apz_str[ 71])
+#define zOptsOnly             (option_usage_text.apz_str[ 72])
+#define zPathFmt              (option_usage_text.apz_str[ 73])
+#define zPlsSendBugs          (option_usage_text.apz_str[ 74])
+#define zPreset               (option_usage_text.apz_str[ 75])
+#define zPresetFile           (option_usage_text.apz_str[ 76])
+#define zPresetIntro          (option_usage_text.apz_str[ 77])
+#define zProg                 (option_usage_text.apz_str[ 78])
+#define zProhib               (option_usage_text.apz_str[ 79])
+#define zReorder              (option_usage_text.apz_str[ 80])
+#define zReqFmt               (option_usage_text.apz_str[ 81])
+#define zReqOptFmt            (option_usage_text.apz_str[ 82])
+#define zReqThese             (option_usage_text.apz_str[ 83])
+#define zReq_NoShrtTtl        (option_usage_text.apz_str[ 84])
+#define zReq_ShrtTtl          (option_usage_text.apz_str[ 85])
+#define zSepChars             (option_usage_text.apz_str[ 86])
+#define zSetMembers           (option_usage_text.apz_str[ 87])
+#define zSetMemberSettings    (option_usage_text.apz_str[ 88])
+#define zShrtGnuOptFmt        (option_usage_text.apz_str[ 89])
+#define zSixSpaces            (option_usage_text.apz_str[ 90])
+#define zStdBoolArg           (option_usage_text.apz_str[ 91])
+#define zStdBreak             (option_usage_text.apz_str[ 92])
+#define zStdKeyArg            (option_usage_text.apz_str[ 93])
+#define zStdKeyLArg           (option_usage_text.apz_str[ 94])
+#define zStdNestArg           (option_usage_text.apz_str[ 95])
+#define zStdNoArg             (option_usage_text.apz_str[ 96])
+#define zStdNumArg            (option_usage_text.apz_str[ 97])
+#define zStdOptArg            (option_usage_text.apz_str[ 98])
+#define zStdReqArg            (option_usage_text.apz_str[ 99])
+#define zStdStrArg            (option_usage_text.apz_str[100])
+#define zTabHyp               (option_usage_text.apz_str[101])
+#define zTabHypAnd            (option_usage_text.apz_str[102])
+#define zTabout               (option_usage_text.apz_str[103])
+#define zThreeSpaces          (option_usage_text.apz_str[104])
+#define zTwoSpaces            (option_usage_text.apz_str[105])
+#define zUpTo                 (option_usage_text.apz_str[106])
+#define zValidKeys            (option_usage_text.apz_str[107])
+
+  /*
+   *  First, set up the strings.  Some of these are writable.  These are all in
+   *  English.  This gets compiled into libopts and is distributed here so that
+   *  xgettext (or equivalents) can extract these strings for translation.
+   */
+
+  static char    eng_zGnuBoolArg[] = "=T/F";
+  static char    eng_zGnuKeyArg[] = "=KWd";
+  static char    eng_zGnuKeyLArg[] = "=Mbr";
+  static char    eng_zGnuNumArg[] = "=num";
+  static char    eng_zGnuStrArg[] = "=str";
+static char const usage_txt[3208] =
+    "AutoOpts function called without option descriptor\n\0"
+    "\tThis exceeds the compiled library version:  \0"
+    "Automated Options Processing Error!\n"
+    "\t%s called AutoOpts function with structure version %d:%d:%d.\n\0"
+    "\tThis is less than the minimum library version:  \0"
+    "all\0"
+    "\t\t\t\t- an alternate for %s\n\0"
+    "%s error:  the keyword `%s' is ambiguous for %s\n\0"
+    "ambiguous\0"
+    "%s: Command line arguments required\n\0"
+    "%d %s%s options allowed\n\0"
+    "version and help options:\0"
+    "Error %d (%s) from the pipe(2) syscall\n\0"
+    "ERROR: version option argument '%c' invalid.  Use:\n"
+    "\t'v' - version only\n"
+    "\t'c' - version and copyright\n"
+    "\t'n' - version and copyright notice\n\0"
+    "ERROR:  %s option conflicts with the %s option\n\0"
+    "%s(optionSaveState): error: cannot allocate %d bytes\n\0"
+    "\t\t\t\t- default option for unnamed options\n\0"
+    "\t\t\t\t- disabled as --%s\n\0"
+    "\t\t\t\t- enabled by default\n\0"
+    "-equivalence\0"
+    "ERROR:  only \0"
+    " - examining environment variables named %s_*\n\0"
+    "     \0"
+    "Options are specified by doubled hyphens and their name\n"
+    "or by a single hyphen and the flag character.\n\0"
+    "%%-%ds %%s\n\0"
+    "fs error %d (%s) on fork - cannot obtain %s usage\n\0"
+    "File error %d (%s) opening %s for loading options\n\0"
+    "fs error %d (%s) reading file %s\n\0"
+    "\n"
+    "= = = = = = = =\n\n"
+    "This incarnation of genshell will produce\n"
+    "a shell script to parse the options for %s:\n\n\0"
+    "\n"
+    "%s\n\n\0"
+    "=Cplx\0"
+    "[=arg]\0"
+    "--%2$s%1$s\0"
+    "%s: illegal option -- %c\n\0"
+    "%s: %s option -- %s\n\0"
+    "illegal\0"
+    "AutoOpts ERROR:  invalid option descriptor for %s\n\0"
+    "words=\0"
+    "cooked\0"
+    "keep\0"
+    "type=\0"
+    "uncooked\0"
+    "integer\0"
+    "nested\0"
+    "string\0"
+    "bool\0"
+    "keyword\0"
+    "set\0"
+    "\t\t\t\t- is a set membership option\n\0"
+    "%s: option `%s' requires an argument\n\0"
+    "Equivalenced option '%s' was equivalenced to both\n"
+    "\t'%s' and '%s'\0"
+    "\t\t\t\t- must appear between %d and %d times\n\0"
+    "ERROR:  The %s option is required\n\0"
+    "%s: option `%s' cannot have an argument\n\0"
+    "%s: Command line arguments not allowed\n\0"
+    "error %d (%s) creating %s\n\0"
+    "Options are specified by single or double hyphens and their name.\n\0"
+    "%s error:  `%s' does not match any %s keywords\n\0"
+    "\t\t\t\t- may appear multiple times\n\0"
+    "\t\t\t\t- may not be preset\n\0"
+    "   Arg Option-Name    Description\n\0"
+    "  Flg Arg Option-Name    Description\n\0"
+    "error %d (%s) stat-ing %s\n\0"
+    "%s(optionRestore): error: no saved option state\n\0"
+    "none\0"
+    "'%s' not defined\n\0"
+    "ERROR:  The %s option must appear %d times\n\0"
+    "error:  cannot load options from non-regular file %s\n\0"
+    "%s error:  `%s' is not a recognizable number\n\0"
+    " %3s %s\0"
+    "The '-#<number>' option may omit the hash char\n\0"
+    " \0"
+    "one %s%s option allowed\n\0"
+    "All arguments are named options.\n\0"
+    " - reading file %s\0"
+    "\n"
+    "please send bug reports to:  %s\n\0"
+    "\t\t\t\t- may NOT appear - preset only\n\0"
+    "#  preset/initialization file\n"
+    "#  %s#\n\0"
+    "\n"
+    "The following option preset mechanisms are supported:\n\0"
+    "program\0"
+    "prohibits these options:\n\0"
+    "Operands and options may be intermixed.  They will be reordered.\n\0"
+    "ERROR:  %s option requires the %s option\n\0"
+    " %3s %-14s %s\0"
+    "requires these options:\n\0"
+    "   Arg Option-Name   Req?  Description\n\0"
+    "  Flg Arg Option-Name   Req?  Description\n\0"
+    "-_^\0"
+    "members=\0"
+    "or you may use a numeric representation.  Preceding these with a '!' will\n"
+    "clear the bits, specifying 'none' will clear all bits, and 'all' will set them\n"
+    "all.  Multiple entries may be passed as an option argument list.\n\0"
+    "%s\0"
+    "      \0"
+    "T/F\0"
+    "\n"
+    "%s\n\n"
+    "%s\0"
+    "KWd\0"
+    "Mbr\0"
+    "Cpx\0"
+    "no \0"
+    "Num\0"
+    "opt\0"
+    "YES\0"
+    "Str\0"
+    "\t\t\t\t- \0"
+    "\t\t\t\t-- and \0"
+    "\t\t\t\t%s\n\0"
+    "   \0"
+    "  \0"
+    "\t\t\t\t- may appear up to %d times\n\0"
+    "The valid \"%s\" option keywords are:\n\0";
+
+
+  /*
+   *  Now, define (and initialize) the structure that contains
+   *  the pointers to all these strings.
+   *  Aren't you glad you don't maintain this by hand?
+   */
+  usage_text_t option_usage_text = {
+    113,
+    eng_zGnuBoolArg, eng_zGnuKeyArg,  eng_zGnuKeyLArg, eng_zGnuNumArg,
+    eng_zGnuStrArg,
+    {
+      usage_txt +   0, usage_txt +  52, usage_txt +  98, usage_txt + 197,
+      usage_txt + 247, usage_txt + 251, usage_txt + 278, usage_txt + 327,
+      usage_txt + 337, usage_txt + 374, usage_txt + 399, usage_txt + 425,
+      usage_txt + 465, usage_txt + 602, usage_txt + 650, usage_txt + 704,
+      usage_txt + 746, usage_txt + 770, usage_txt + 796, usage_txt + 809,
+      usage_txt + 823, usage_txt + 870, usage_txt + 876, usage_txt + 979,
+      usage_txt + 991, usage_txt +1042, usage_txt +1093, usage_txt +1127,
+      usage_txt +1233, usage_txt +1239, usage_txt +1245, usage_txt +1252,
+      usage_txt +1263, usage_txt +1289, usage_txt +1310, usage_txt +1318,
+      usage_txt +1369, usage_txt +1376, usage_txt +1383, usage_txt +1388,
+      usage_txt +1394, usage_txt +1403, usage_txt +1411, usage_txt +1418,
+      usage_txt +1425, usage_txt +1430, usage_txt +1438, usage_txt +1442,
+      usage_txt +1476, usage_txt +1514, usage_txt +1579, usage_txt +1622,
+      usage_txt +1657, usage_txt +1698, usage_txt +1738, usage_txt +1765,
+      usage_txt +1832, usage_txt +1880, usage_txt +1913, usage_txt +1938,
+      usage_txt +1973, usage_txt +2011, usage_txt +2038, usage_txt +2087,
+      usage_txt +2092, usage_txt +2110, usage_txt +2154, usage_txt +2208,
+      usage_txt +2254, usage_txt +2262, usage_txt +2310, usage_txt +2312,
+      usage_txt +2337, usage_txt +2371, usage_txt +2390, usage_txt +2424,
+      usage_txt +2460, usage_txt +2498, usage_txt +2554, usage_txt +2562,
+      usage_txt +2588, usage_txt +2654, usage_txt +2696, usage_txt +2710,
+      usage_txt +2735, usage_txt +2775, usage_txt +2818, usage_txt +2822,
+      usage_txt +2831, usage_txt +3050, usage_txt +3053, usage_txt +3060,
+      usage_txt +3064, usage_txt +3072, usage_txt +3076, usage_txt +3080,
+      usage_txt +3084, usage_txt +3088, usage_txt +3092, usage_txt +3096,
+      usage_txt +3100, usage_txt +3104, usage_txt +3111, usage_txt +3123,
+      usage_txt +3131, usage_txt +3135, usage_txt +3138, usage_txt +3171
+    }
+  };
+
+#endif /* DO_TRANSLATIONS */
+#endif /* AUTOOPTS_USAGE_TXT_H_GUARD */
diff --git a/libopts/boolean.c b/libopts/boolean.c
new file mode 100644 (file)
index 0000000..37148a9
--- /dev/null
@@ -0,0 +1,106 @@
+
+/*
+ *  $Id: boolean.c,v 4.10 2007/02/04 17:44:12 bkorb Exp $
+ * Time-stamp:      "2007-01-13 10:10:39 bkorb"
+ *
+ *   Automated Options Paged Usage module.
+ *
+ *  This routine will run run-on options through a pager so the
+ *  user may examine, print or edit them at their leisure.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/*=export_func  optionBooleanVal
+ * private:
+ *
+ * what:  Decipher a boolean value
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Decipher a true or false value for a boolean valued option argument.
+ *  The value is true, unless it starts with 'n' or 'f' or "#f" or
+ *  it is an empty string or it is a number that evaluates to zero.
+=*/
+void
+optionBooleanVal( tOptions* pOpts, tOptDesc* pOD )
+{
+    char* pz;
+    ag_bool  res = AG_TRUE;
+
+    switch (*(pOD->optArg.argString)) {
+    case '0':
+    {
+        long  val = strtol( pOD->optArg.argString, &pz, 0 );
+        if ((val != 0) || (*pz != NUL))
+            break;
+        /* FALLTHROUGH */
+    }
+    case 'N':
+    case 'n':
+    case 'F':
+    case 'f':
+    case NUL:
+        res = AG_FALSE;
+        break;
+    case '#':
+        if (pOD->optArg.argString[1] != 'f')
+            break;
+        res = AG_FALSE;
+    }
+
+    if (pOD->fOptState & OPTST_ALLOC_ARG) {
+        AGFREE(pOD->optArg.argString);
+        pOD->fOptState &= ~OPTST_ALLOC_ARG;
+    }
+    pOD->optArg.argBool = res;
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/boolean.c */
diff --git a/libopts/compat/compat.h b/libopts/compat/compat.h
new file mode 100644 (file)
index 0000000..b3bd58f
--- /dev/null
@@ -0,0 +1,319 @@
+/*  -*- Mode: C -*-  */
+
+/* --- fake the preprocessor into handlng portability */
+/*
+ *  Time-stamp:      "2007-02-03 17:41:06 bkorb"
+ *
+ * Author:           Gary V Vaughan <gvaughan@oranda.demon.co.uk>
+ * Created:          Mon Jun 30 15:54:46 1997
+ *
+ * $Id: compat.h,v 4.16 2007/04/27 01:10:47 bkorb Exp $
+ */
+#ifndef COMPAT_H_GUARD
+#define COMPAT_H_GUARD 1
+
+#if defined(HAVE_CONFIG_H)
+#  include <config.h>
+
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+#  include "windows-config.h"
+
+#else
+#  error "compat.h" requires "config.h"
+   choke me.
+#endif
+
+
+#ifndef HAVE_STRSIGNAL
+   char * strsignal( int signo );
+#endif
+
+#define  _GNU_SOURCE    1 /* for strsignal in GNU's libc */
+#define  __USE_GNU      1 /* exact same thing as above   */
+#define  __EXTENSIONS__ 1 /* and another way to call for it */
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  SYSTEM HEADERS:
+ */
+#include <sys/types.h>
+#ifdef HAVE_SYS_MMAN_H
+#  include <sys/mman.h>
+#endif
+#include <sys/param.h>
+#if HAVE_SYS_PROCSET_H
+#  include <sys/procset.h>
+#endif
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#if defined( HAVE_SOLARIS_SYSINFO )
+#  include <sys/systeminfo.h>
+#elif defined( HAVE_UNAME_SYSCALL )
+#  include <sys/utsname.h>
+#endif
+
+#ifdef DAEMON_ENABLED
+#  if HAVE_SYS_STROPTS_H
+#  include <sys/stropts.h>
+#  endif
+
+#  if HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+#  endif
+
+#  if ! defined(HAVE_SYS_POLL_H) && ! defined(HAVE_SYS_SELECT_H)
+#    error This system cannot support daemon processing
+     Choke Me.
+#  endif
+
+#  if HAVE_SYS_POLL_H
+#  include <sys/poll.h>
+#  endif
+
+#  if HAVE_SYS_SELECT_H
+#  include <sys/select.h>
+#  endif
+
+#  if HAVE_NETINET_IN_H
+#  include <netinet/in.h>
+#  endif
+
+#  if HAVE_SYS_UN_H
+#  include <sys/un.h>
+#  endif
+#endif
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  USER HEADERS:
+ */
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+
+/*
+ *  Directory opening stuff:
+ */
+# if defined (_POSIX_SOURCE)
+/* Posix does not require that the d_ino field be present, and some
+   systems do not provide it. */
+#    define REAL_DIR_ENTRY(dp) 1
+# else /* !_POSIX_SOURCE */
+#    define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
+# endif /* !_POSIX_SOURCE */
+
+# if defined (HAVE_DIRENT_H)
+#   include <dirent.h>
+#   define D_NAMLEN(dirent) strlen((dirent)->d_name)
+# else /* !HAVE_DIRENT_H */
+#   define dirent direct
+#   define D_NAMLEN(dirent) (dirent)->d_namlen
+#   if defined (HAVE_SYS_NDIR_H)
+#     include <sys/ndir.h>
+#   endif /* HAVE_SYS_NDIR_H */
+#   if defined (HAVE_SYS_DIR_H)
+#     include <sys/dir.h>
+#   endif /* HAVE_SYS_DIR_H */
+#   if defined (HAVE_NDIR_H)
+#     include <ndir.h>
+#   endif /* HAVE_NDIR_H */
+# endif /* !HAVE_DIRENT_H */
+
+#include <errno.h>
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#ifndef O_NONBLOCK
+# define O_NONBLOCK FNDELAY
+#endif
+
+#if defined(HAVE_LIBGEN) && defined(HAVE_LIBGEN_H)
+#  include <libgen.h>
+#endif
+
+#if defined(HAVE_LIMITS_H)  /* this is also in options.h */
+#  include <limits.h>
+#elif defined(HAVE_SYS_LIMITS_H)
+#  include <sys/limits.h>
+#endif /* HAVE_LIMITS/SYS_LIMITS_H */
+
+#include <memory.h>
+#include <setjmp.h>
+#include <signal.h>
+
+#if defined( HAVE_STDINT_H )
+#  include <stdint.h>
+#elif defined( HAVE_INTTYPES_H )
+#  include <inttypes.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <time.h>
+
+#ifdef HAVE_UTIME_H
+#  include <utime.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  FIXUPS and CONVIENCE STUFF:
+ */
+#ifdef __cplusplus
+#   define EXTERN extern "C"
+#else
+#   define EXTERN extern
+#endif
+
+/* some systems #def errno! and others do not declare it!! */
+#ifndef errno
+   extern int errno;
+#endif
+
+/* Some machines forget this! */
+
+# ifndef EXIT_FAILURE
+#   define EXIT_SUCCESS 0
+#   define EXIT_FAILURE 1
+# endif
+
+#ifndef NUL
+#  define NUL '\0'
+#endif
+
+#ifndef NULL
+#  define NULL 0
+#endif
+
+#if !defined (MAXPATHLEN) && defined (HAVE_SYS_PARAM_H)
+#  include <sys/param.h>
+#endif /* !MAXPATHLEN && HAVE_SYS_PARAM_H */
+
+#if !defined (MAXPATHLEN) && defined (PATH_MAX)
+#  define MAXPATHLEN PATH_MAX
+#endif /* !MAXPATHLEN && PATH_MAX */
+
+#if !defined (MAXPATHLEN) && defined(_MAX_PATH)
+#  define PATH_MAX _MAX_PATH
+#  define MAXPATHLEN _MAX_PATH
+#endif
+
+#if !defined (MAXPATHLEN)
+#  define MAXPATHLEN ((size_t)4096)
+#endif /* MAXPATHLEN */
+
+#define AG_PATH_MAX  ((size_t)MAXPATHLEN)
+
+#ifndef LONG_MAX
+#  define LONG_MAX      ~(1L << (8*sizeof(long) -1))
+#  define INT_MAX       ~(1 << (8*sizeof(int) -1))
+#endif
+
+#ifndef ULONG_MAX
+#  define ULONG_MAX     ~(OUL)
+#  define UINT_MAX      ~(OU)
+#endif
+
+#ifndef SHORT_MAX
+#  define SHORT_MAX     ~(1 << (8*sizeof(short) -1))
+#else
+#  define USHORT_MAX    ~(OUS)
+#endif
+
+#ifndef HAVE_INT8_T
+  typedef signed char       int8_t;
+#endif
+#ifndef HAVE_UINT8_T
+  typedef unsigned char     uint8_t;
+#endif
+#ifndef HAVE_INT16_T
+  typedef signed short      int16_t;
+#endif
+#ifndef HAVE_UINT16_T
+  typedef unsigned short    uint16_t;
+#endif
+#ifndef HAVE_UINT_T
+  typedef unsigned int      uint_t;
+#endif
+
+#ifndef HAVE_INT32_T
+# if SIZEOF_INT == 4
+        typedef signed int      int32_t;
+# elif SIZEOF_LONG == 4
+        typedef signed long     int32_t;
+# endif
+#endif
+
+#ifndef HAVE_UINT32_T
+# if SIZEOF_INT == 4
+        typedef unsigned int    uint32_t;
+# elif SIZEOF_LONG == 4
+        typedef unsigned long   uint32_t;
+# else
+#   error Cannot create a uint32_t type.
+    Choke Me.
+# endif
+#endif
+
+#ifndef HAVE_INTPTR_T
+  typedef signed long   intptr_t;
+#endif
+#ifndef HAVE_UINTPTR_T
+  typedef unsigned long uintptr_t;
+#endif
+
+/* redefine these for BSD style string libraries */
+#ifndef HAVE_STRCHR
+#  define strchr        index
+#  define strrchr       rindex
+#endif
+
+#ifdef USE_FOPEN_BINARY
+#  ifndef FOPEN_BINARY_FLAG
+#    define FOPEN_BINARY_FLAG   "b"
+#  endif
+#  ifndef FOPEN_TEXT_FLAG
+#    define FOPEN_TEXT_FLAG     "t"
+#  endif
+#else
+#  ifndef FOPEN_BINARY_FLAG
+#    define FOPEN_BINARY_FLAG
+#  endif
+#  ifndef FOPEN_TEXT_FLAG
+#    define FOPEN_TEXT_FLAG
+#  endif
+#endif
+
+#ifndef STR
+#  define _STR(s) #s
+#  define STR(s)  _STR(s)
+#endif
+
+/* ##### Pointer sized word ##### */
+
+/* FIXME:  the MAX stuff in here is broken! */
+#if SIZEOF_CHARP > SIZEOF_INT
+   typedef long t_word;
+   #define WORD_MAX  LONG_MAX
+   #define WORD_MIN  LONG_MIN
+#else /* SIZEOF_CHARP <= SIZEOF_INT */
+   typedef int t_word;
+   #define WORD_MAX  INT_MAX
+   #define WORD_MIN  INT_MIN
+#endif
+
+#endif /* COMPAT_H_GUARD */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of compat/compat.h */
diff --git a/libopts/compat/pathfind.c b/libopts/compat/pathfind.c
new file mode 100644 (file)
index 0000000..96eb771
--- /dev/null
@@ -0,0 +1,339 @@
+/*  -*- Mode: C -*-  */
+
+/* pathfind.c --- find a FILE  MODE along PATH */
+
+/*
+ * Author:           Gary V Vaughan <gvaughan@oranda.demon.co.uk>
+ * Time-stamp:       "2006-09-23 19:46:16 bkorb"
+ * Created:          Tue Jun 24 15:07:31 1997
+ * Last Modified:    $Date: 2006/11/27 01:52:23 $
+ *            by: bkorb
+ *
+ * $Id: pathfind.c,v 4.10 2006/11/27 01:52:23 bkorb Exp $
+ */
+
+/* Code: */
+
+#include "compat.h"
+#ifndef HAVE_PATHFIND
+#if defined(__windows__) && !defined(__CYGWIN__)
+char*
+pathfind( char const*  path,
+          char const*  fileName,
+          char const*  mode )
+{
+    return NULL;
+}
+#else
+
+static char* make_absolute( char const *string, char const *dot_path );
+static char* canonicalize_pathname( char *path );
+static char* extract_colon_unit( char* dir, char const *string, int *p_index );
+
+
+/*=export_func pathfind
+ *
+ * what: fild a file in a list of directories
+ *
+ * ifndef: HAVE_PATHFIND
+ *
+ * arg:  + char const* + path + colon separated list of search directories +
+ * arg:  + char const* + file + the name of the file to look for +
+ * arg:  + char const* + mode + the mode bits that must be set to match +
+ *
+ * ret_type:  char*
+ * ret_desc:  the path to the located file
+ *
+ * doc:
+ *
+ * pathfind looks for a a file with name "FILE" and "MODE" access
+ * along colon delimited "PATH", and returns the full pathname as a
+ * string, or NULL if not found.  If "FILE" contains a slash, then
+ * it is treated as a relative or absolute path and "PATH" is ignored.
+ *
+ * @strong{NOTE}: this function is compiled into @file{libopts} only if
+ * it is not natively supplied.
+ *
+ * The "MODE" argument is a string of option letters chosen from the
+ * list below:
+ * @example
+ *          Letter    Meaning
+ *          r         readable
+ *          w         writable
+ *          x         executable
+ *          f         normal file       (NOT IMPLEMENTED)
+ *          b         block special     (NOT IMPLEMENTED)
+ *          c         character special (NOT IMPLEMENTED)
+ *          d         directory         (NOT IMPLEMENTED)
+ *          p         FIFO (pipe)       (NOT IMPLEMENTED)
+ *          u         set user ID bit   (NOT IMPLEMENTED)
+ *          g         set group ID bit  (NOT IMPLEMENTED)
+ *          k         sticky bit        (NOT IMPLEMENTED)
+ *          s         size nonzero      (NOT IMPLEMENTED)
+ * @end example
+ *
+ * example:
+ * To find the "ls" command using the "PATH" environment variable:
+ * @example
+ *    #include <stdlib.h>
+ *    char* pz_ls = pathfind( getenv("PATH"), "ls", "rx" );
+ *    <<do whatever with pz_ls>>
+ *    free( pz_ls );
+ * @end example
+ * The path is allocated with @code{malloc(3C)}, so you must @code{free(3C)}
+ * the result.  Also, do not use unimplemented file modes.  :-)
+ *
+ * err:  returns NULL if the file is not found.
+=*/
+char*
+pathfind( char const*  path,
+          char const*  fileName,
+          char const*  mode )
+{
+    int   p_index   = 0;
+    int   mode_bits = 0;
+    char* pathName  = NULL;
+    char  zPath[ AG_PATH_MAX + 1 ];
+
+    if (strchr( mode, 'r' )) mode_bits |= R_OK;
+    if (strchr( mode, 'w' )) mode_bits |= W_OK;
+    if (strchr( mode, 'x' )) mode_bits |= X_OK;
+
+    /*
+     *  FOR each non-null entry in the colon-separated path, DO ...
+     */
+    for (;;) {
+        DIR*  dirP;
+        char* colon_unit = extract_colon_unit( zPath, path, &p_index );
+
+        /*
+         *  IF no more entries, THEN quit
+         */
+        if (colon_unit == NULL)
+            break;
+
+        dirP = opendir( colon_unit );
+
+        /*
+         *  IF the directory is inaccessable, THEN next directory
+         */
+        if (dirP == NULL)
+            continue;
+
+        /*
+         *  FOR every entry in the given directory, ...
+         */
+        for (;;) {
+            struct dirent *entP = readdir( dirP );
+
+            if (entP == (struct dirent*)NULL)
+                break;
+
+            /*
+             *  IF the file name matches the one we are looking for, ...
+             */
+            if (strcmp( entP->d_name, fileName ) == 0) {
+                char* pzFullName = make_absolute( fileName, colon_unit);
+
+                /*
+                 *  Make sure we can access it in the way we want
+                 */
+                if (access( pzFullName, mode_bits ) >= 0) {
+                    /*
+                     *  We can, so normalize the name and return it below
+                     */
+                    pathName = canonicalize_pathname( pzFullName );
+                }
+
+                free( (void*)pzFullName );
+                break;
+            }
+        }
+
+        closedir( dirP );
+
+        if (pathName != NULL)
+            break;
+    }
+
+    return pathName;
+}
+
+/*
+ * Turn STRING  (a pathname) into an  absolute  pathname, assuming  that
+ * DOT_PATH contains the symbolic location of  `.'.  This always returns
+ * a new string, even if STRING was an absolute pathname to begin with.
+ */
+static char*
+make_absolute( char const *string, char const *dot_path )
+{
+    char *result;
+    int result_len;
+
+    if (!dot_path || *string == '/') {
+        result = strdup( string );
+    } else {
+        if (dot_path && dot_path[0]) {
+            result = malloc( 2 + strlen( dot_path ) + strlen( string ) );
+            strcpy( result, dot_path );
+            result_len = strlen( result );
+            if (result[result_len - 1] != '/') {
+                result[result_len++] = '/';
+                result[result_len] = '\0';
+            }
+        } else {
+            result = malloc( 3 + strlen( string ) );
+            result[0] = '.'; result[1] = '/'; result[2] = '\0';
+            result_len = 2;
+        }
+
+        strcpy( result + result_len, string );
+    }
+
+    return result;
+}
+
+/*
+ * Canonicalize PATH, and return a  new path.  The new path differs from
+ * PATH in that:
+ *
+ *    Multiple `/'s     are collapsed to a single `/'.
+ *    Leading `./'s     are removed.
+ *    Trailing `/.'s    are removed.
+ *    Trailing `/'s     are removed.
+ *    Non-leading `../'s and trailing `..'s are handled by removing
+ *                    portions of the path.
+ */
+static char*
+canonicalize_pathname( char *path )
+{
+    int i, start;
+    char stub_char, *result;
+
+    /* The result cannot be larger than the input PATH. */
+    result = strdup( path );
+
+    stub_char = (*path == '/') ? '/' : '.';
+
+    /* Walk along RESULT looking for things to compact. */
+    i = 0;
+    while (result[i]) {
+        while (result[i] != '\0' && result[i] != '/')
+            i++;
+
+        start = i++;
+
+        /* If we didn't find any  slashes, then there is nothing left to
+         * do.
+         */
+        if (!result[start])
+            break;
+
+        /* Handle multiple `/'s in a row. */
+        while (result[i] == '/')
+            i++;
+
+#if !defined (apollo)
+        if ((start + 1) != i)
+#else
+        if ((start + 1) != i && (start != 0 || i != 2))
+#endif /* apollo */
+        {
+            strcpy( result + start + 1, result + i );
+            i = start + 1;
+        }
+
+        /* Handle backquoted `/'. */
+        if (start > 0 && result[start - 1] == '\\')
+            continue;
+
+        /* Check for trailing `/', and `.' by itself. */
+        if ((start && !result[i])
+            || (result[i] == '.' && !result[i+1])) {
+            result[--i] = '\0';
+            break;
+        }
+
+        /* Check for `../', `./' or trailing `.' by itself. */
+        if (result[i] == '.') {
+            /* Handle `./'. */
+            if (result[i + 1] == '/') {
+                strcpy( result + i, result + i + 1 );
+                i = (start < 0) ? 0 : start;
+                continue;
+            }
+
+            /* Handle `../' or trailing `..' by itself. */
+            if (result[i + 1] == '.' &&
+                (result[i + 2] == '/' || !result[i + 2])) {
+                while (--start > -1 && result[start] != '/')
+                    ;
+                strcpy( result + start + 1, result + i + 2 );
+                i = (start < 0) ? 0 : start;
+                continue;
+            }
+        }
+    }
+
+    if (!*result) {
+        *result = stub_char;
+        result[1] = '\0';
+    }
+
+    return result;
+}
+
+/*
+ * Given a  string containing units of information separated  by colons,
+ * return the next one  pointed to by (P_INDEX), or NULL if there are no
+ * more.  Advance (P_INDEX) to the character after the colon.
+ */
+static char*
+extract_colon_unit( char* pzDir, char const *string, int *p_index )
+{
+    char*  pzDest = pzDir;
+    int    ix     = *p_index;
+
+    if (string == NULL)
+        return NULL;
+
+    if ((unsigned)ix >= strlen( string ))
+        return NULL;
+
+    {
+        char const* pzSrc = string + ix;
+
+        while (*pzSrc == ':')  pzSrc++;
+
+        for (;;) {
+            char ch = (*(pzDest++) = *(pzSrc++));
+            switch (ch) {
+            case ':':
+                pzDest[-1] = NUL;
+            case NUL:
+                goto copy_done;
+            }
+
+            if ((pzDest - pzDir) >= AG_PATH_MAX)
+                break;
+        } copy_done:;
+
+        ix = pzSrc - string;
+    }
+
+    if (*pzDir == NUL)
+        return NULL;
+
+    *p_index = ix;
+    return pzDir;
+}
+#endif /* __windows__ / __CYGWIN__ */
+#endif /* HAVE_PATHFIND */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of compat/pathfind.c */
diff --git a/libopts/compat/snprintf.c b/libopts/compat/snprintf.c
new file mode 100644 (file)
index 0000000..fc91d63
--- /dev/null
@@ -0,0 +1,60 @@
+
+#ifndef HAVE_VPRINTF
+#include "choke-me: no vprintf and no snprintf"
+#endif
+
+#if defined(HAVE_STDARG_H)
+#  include <stdarg.h>
+#  ifndef   VA_START
+#    define VA_START(a, f)  va_start(a, f)
+#    define VA_END(a)       va_end(a)
+#  endif /* VA_START */
+#  define SNV_USING_STDARG_H
+
+#elif defined(HAVE_VARARGS_H)
+#  include <varargs.h>
+#  ifndef   VA_START
+#    define VA_START(a, f) va_start(a)
+#    define VA_END(a)    va_end(a)
+#  endif /* VA_START */
+#  undef  SNV_USING_STDARG_H
+
+#else
+#  include "must-have-stdarg-or-varargs"
+#endif
+
+static int
+snprintf(char *str, size_t n, char const *fmt, ...)
+{
+    va_list ap;
+    int rval;
+
+#ifdef VSPRINTF_CHARSTAR
+    char *rp;
+    VA_START(ap, fmt);
+    rp = vsprintf(str, fmt, ap);
+    VA_END(ap);
+    rval = strlen(rp);
+
+#else
+    VA_START(ap, fmt);
+    rval = vsprintf(str, fmt, ap);
+    VA_END(ap);
+#endif
+
+    if (rval > n) {
+        fprintf(stderr, "snprintf buffer overrun %d > %d\n", rval, (int)n);
+        abort();
+    }
+    return rval;
+}
+
+static int
+vsnprintf( char *str, size_t n, char const *fmt, va_list ap )
+{
+#ifdef VSPRINTF_CHARSTAR
+    return (strlen(vsprintf(str, fmt, ap)));
+#else
+    return (vsprintf(str, fmt, ap));
+#endif
+}
diff --git a/libopts/compat/strchr.c b/libopts/compat/strchr.c
new file mode 100644 (file)
index 0000000..413f999
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+   SYNOPSIS
+       #include <string.h>
+
+       char *strchr(char const *s, int c);
+
+       char *strrchr(char const *s, int c);
+
+   DESCRIPTION
+       The  strchr() function returns a pointer to the first occurrence of the
+       character c in the string s.
+
+       The strrchr() function returns a pointer to the last occurrence of  the
+       character c in the string s.
+
+       Here  "character"  means "byte" - these functions do not work with wide
+       or multi-byte characters.
+
+   RETURN VALUE
+       The strchr() and strrchr() functions return a pointer  to  the  matched
+       character or NULL if the character is not found.
+
+   CONFORMING TO
+       SVID 3, POSIX, BSD 4.3, ISO 9899
+*/
+
+char*
+strchr( char const *s, int c)
+{
+    do {
+        if ((unsigned)*s == (unsigned)c)
+            return s;
+
+    } while (*(++s) != NUL);
+
+    return NULL;
+}
+
+char*
+strrchr( char const *s, int c)
+{
+    char const *e = s + strlen(s);
+
+    for (;;) {
+        if (--e < s)
+            break;
+
+        if ((unsigned)*e == (unsigned)c)
+            return e;
+    }
+    return NULL;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of compat/strsignal.c */
diff --git a/libopts/compat/strdup.c b/libopts/compat/strdup.c
new file mode 100644 (file)
index 0000000..e2933a8
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Platforms without strdup ?!?!?!
+ */
+
+static char *
+strdup( char const *s )
+{
+    char *cp;
+
+    if (s == NULL)
+        return NULL;
+
+    cp = (char *) AGALOC((unsigned) (strlen(s)+1), "strdup");
+
+    if (cp != NULL)
+        (void) strcpy(cp, s);
+
+    return cp;
+}
diff --git a/libopts/compat/windows-config.h b/libopts/compat/windows-config.h
new file mode 100644 (file)
index 0000000..2612980
--- /dev/null
@@ -0,0 +1,130 @@
+
+/*
+ * Time-stamp:        "2006-10-14 14:55:09 bkorb"
+ *             by: bkorb
+ * Last Committed:    $Date: 2007/04/28 22:19:23 $
+ */
+#ifndef WINDOWS_CONFIG_HACKERY
+#define WINDOWS_CONFIG_HACKERY 1
+
+/*
+ * The definitions below have been stolen from NTP's config.h for Windows.
+ * However, they may be kept here in order to keep libopts independent from
+ * the NTP project.
+ */
+#ifndef __windows__
+#  define __windows__ 4
+#endif
+
+/*
+ * Miscellaneous functions that Microsoft maps
+ * to other names
+ *
+ * #define inline __inline
+ * #define vsnprintf _vsnprintf
+ */
+#define snprintf _snprintf
+/*
+ * #define stricmp _stricmp
+ * #define strcasecmp _stricmp
+ * #define isascii __isascii
+ * #define finite _finite
+ * #define random      rand
+ * #define srandom     srand
+ */
+
+#define SIZEOF_INT   4
+#define SIZEOF_CHARP 4
+#define SIZEOF_LONG  4
+#define SIZEOF_SHORT 2
+
+typedef unsigned long uintptr_t;
+
+/*
+ * # define HAVE_NET_IF_H
+ * # define QSORT_USES_VOID_P
+ * # define HAVE_SETVBUF
+ * # define HAVE_VSPRINTF
+ * # define HAVE_SNPRINTF
+ * # define HAVE_VSNPRINTF
+ * # define HAVE_PROTOTYPES             /* from ntpq.mak * /
+ * # define HAVE_MEMMOVE
+ * # define HAVE_TERMIOS_H
+ * # define HAVE_ERRNO_H
+ * # define HAVE_STDARG_H
+ * # define HAVE_NO_NICE
+ * # define HAVE_MKTIME
+ * # define TIME_WITH_SYS_TIME
+ * # define HAVE_IO_COMPLETION_PORT
+ * # define ISC_PLATFORM_NEEDNTOP
+ * # define ISC_PLATFORM_NEEDPTON
+ * # define NEED_S_CHAR_TYPEDEF
+ * # define USE_PROTOTYPES              /* for ntp_types.h * /
+ *
+ * #define ULONG_CONST(a) a ## UL
+ */
+
+#define HAVE_LIMITS_H   1
+#define HAVE_STRDUP     1
+#define HAVE_STRCHR     1
+#define HAVE_FCNTL_H    1
+
+/*
+ * VS.NET's version of wspiapi.h has a bug in it
+ * where it assigns a value to a variable inside
+ * an if statement. It should be comparing them.
+ * We prevent inclusion since we are not using this
+ * code so we don't have to see the warning messages
+ */
+#ifndef _WSPIAPI_H_
+#define _WSPIAPI_H_
+#endif
+
+/* Prevent inclusion of winsock.h in windows.h */
+#ifndef _WINSOCKAPI_
+#define _WINSOCKAPI_
+#endif
+
+#ifndef __RPCASYNC_H__
+#define __RPCASYNC_H__
+#endif
+
+/* Include Windows headers */
+#include <windows.h>
+#include <winsock2.h>
+#include <limits.h>
+
+/*
+ * Compatibility declarations for Windows, assuming SYS_WINNT
+ * has been defined.
+ */
+#define strdup  _strdup
+#define stat    _stat       /* struct stat from <sys/stat.h> */
+#define unlink  _unlink
+#define fchmod( _x, _y );
+#define ssize_t SSIZE_T
+
+#include <io.h>
+#define open    _open
+#define close   _close
+#define read    _read
+#define write   _write
+#define lseek   _lseek
+#define pipe    _pipe
+#define dup2    _dup2
+
+#define O_RDWR     _O_RDWR
+#define O_RDONLY   _O_RDONLY
+#define O_EXCL     _O_EXCL
+
+#ifndef S_ISREG
+#  define S_IFREG _S_IFREG
+#  define       S_ISREG(mode)   (((mode) & S_IFREG) == S_IFREG)
+#endif
+
+#ifndef S_ISDIR
+#  define S_IFDIR _S_IFDIR
+#  define       S_ISDIR(mode)   (((mode) & S_IFDIR) == S_IFDIR)
+#endif
+
+#endif /* WINDOWS_CONFIG_HACKERY */
diff --git a/libopts/configfile.c b/libopts/configfile.c
new file mode 100644 (file)
index 0000000..e0b8a74
--- /dev/null
@@ -0,0 +1,1290 @@
+/*
+ *  $Id: configfile.c,v 1.21 2007/04/15 19:01:18 bkorb Exp $
+ *  Time-stamp:      "2007-04-15 11:22:46 bkorb"
+ *
+ *  configuration/rc/ini file handling.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+filePreset(
+    tOptions*     pOpts,
+    char const*   pzFileName,
+    int           direction );
+
+static char*
+handleComment( char* pzText );
+
+static char*
+handleConfig(
+    tOptions*     pOpts,
+    tOptState*    pOS,
+    char*         pzText,
+    int           direction );
+
+static char*
+handleDirective(
+    tOptions*     pOpts,
+    char*         pzText );
+
+static char*
+handleProgramSection(
+    tOptions*     pOpts,
+    char*         pzText );
+
+static char*
+handleStructure(
+    tOptions*     pOpts,
+    tOptState*    pOS,
+    char*         pzText,
+    int           direction );
+
+static char*
+parseKeyWordType(
+    tOptions*     pOpts,
+    char*         pzText,
+    tOptionValue* pType );
+
+static char*
+parseLoadMode(
+    char*               pzText,
+    tOptionLoadMode*    pMode );
+
+static char*
+parseSetMemType(
+    tOptions*     pOpts,
+    char*         pzText,
+    tOptionValue* pType );
+
+static char*
+parseValueType(
+    char*         pzText,
+    tOptionValue* pType );
+
+static char*
+skipUnknown( char* pzText );
+/* = = = END-STATIC-FORWARD = = = */
+
+
+/*=export_func  configFileLoad
+ *
+ * what:  parse a configuration file
+ * arg:   + char const*     + pzFile + the file to load +
+ *
+ * ret_type:  const tOptionValue*
+ * ret_desc:  An allocated, compound value structure
+ *
+ * doc:
+ *  This routine will load a named configuration file and parse the
+ *  text as a hierarchically valued option.  The option descriptor
+ *  created from an option definition file is not used via this interface.
+ *  The returned value is "named" with the input file name and is of
+ *  type "@code{OPARG_TYPE_HIERARCHY}".  It may be used in calls to
+ *  @code{optionGetValue()}, @code{optionNextValue()} and
+ *  @code{optionUnloadNested()}.
+ *
+ * err:
+ *  If the file cannot be loaded or processed, @code{NULL} is returned and
+ *  @var{errno} is set.  It may be set by a call to either @code{open(2)}
+ *  @code{mmap(2)} or other file system calls, or it may be:
+ *  @itemize @bullet
+ *  @item
+ *  @code{ENOENT} - the file was empty.
+ *  @item
+ *  @code{EINVAL} - the file contents are invalid -- not properly formed.
+ *  @item
+ *  @code{ENOMEM} - not enough memory to allocate the needed structures.
+ *  @end itemize
+=*/
+const tOptionValue*
+configFileLoad( char const* pzFile )
+{
+    tmap_info_t   cfgfile;
+    tOptionValue* pRes = NULL;
+    tOptionLoadMode save_mode = option_load_mode;
+
+    char* pzText =
+        text_mmap( pzFile, PROT_READ, MAP_PRIVATE, &cfgfile );
+
+    if (TEXT_MMAP_FAILED_ADDR(pzText))
+        return NULL; /* errno is set */
+
+    option_load_mode = OPTION_LOAD_COOKED;
+    pRes = optionLoadNested(pzText, pzFile, strlen(pzFile));
+
+    if (pRes == NULL) {
+        int err = errno;
+        text_munmap( &cfgfile );
+        errno = err;
+    } else
+        text_munmap( &cfgfile );
+
+    option_load_mode = save_mode;
+    return pRes;
+}
+
+
+/*=export_func  optionFindValue
+ *
+ * what:  find a hierarcicaly valued option instance
+ * arg:   + const tOptDesc* + pOptDesc + an option with a nested arg type +
+ * arg:   + char const*     + name     + name of value to find +
+ * arg:   + char const*     + value    + the matching value    +
+ *
+ * ret_type:  const tOptionValue*
+ * ret_desc:  a compound value structure
+ *
+ * doc:
+ *  This routine will find an entry in a nested value option or configurable.
+ *  It will search through the list and return a matching entry.
+ *
+ * err:
+ *  The returned result is NULL and errno is set:
+ *  @itemize @bullet
+ *  @item
+ *  @code{EINVAL} - the @code{pOptValue} does not point to a valid
+ *  hierarchical option value.
+ *  @item
+ *  @code{ENOENT} - no entry matched the given name.
+ *  @end itemize
+=*/
+const tOptionValue*
+optionFindValue( const tOptDesc* pOptDesc,
+                 char const* pzName, char const* pzVal )
+{
+    const tOptionValue* pRes = NULL;
+
+    if (  (pOptDesc == NULL)
+       || (OPTST_GET_ARGTYPE(pOptDesc->fOptState) != OPARG_TYPE_HIERARCHY))  {
+        errno = EINVAL;
+    }
+
+    else if (pOptDesc->optCookie == NULL) {
+        errno = ENOENT;
+    }
+
+    else do {
+        tArgList* pAL = pOptDesc->optCookie;
+        int    ct   = pAL->useCt;
+        void** ppOV = (void**)(pAL->apzArgs);
+
+        if (ct == 0) {
+            errno = ENOENT;
+            break;
+        }
+
+        if (pzName == NULL) {
+            pRes = (tOptionValue*)*ppOV;
+            break;
+        }
+
+        while (--ct >= 0) {
+            const tOptionValue* pOV = *(ppOV++);
+            const tOptionValue* pRV = optionGetValue( pOV, pzName );
+
+            if (pRV == NULL)
+                continue;
+
+            if (pzVal == NULL) {
+                pRes = pOV;
+                break;
+            }
+        }
+        if (pRes == NULL)
+            errno = ENOENT;
+    } while (0);
+
+    return pRes;
+}
+
+
+/*=export_func  optionFindNextValue
+ *
+ * what:  find a hierarcicaly valued option instance
+ * arg:   + const tOptDesc* + pOptDesc + an option with a nested arg type +
+ * arg:   + const tOptionValue* + pPrevVal + the last entry +
+ * arg:   + char const*     + name     + name of value to find +
+ * arg:   + char const*     + value    + the matching value    +
+ *
+ * ret_type:  const tOptionValue*
+ * ret_desc:  a compound value structure
+ *
+ * doc:
+ *  This routine will find the next entry in a nested value option or
+ *  configurable.  It will search through the list and return the next entry
+ *  that matches the criteria.
+ *
+ * err:
+ *  The returned result is NULL and errno is set:
+ *  @itemize @bullet
+ *  @item
+ *  @code{EINVAL} - the @code{pOptValue} does not point to a valid
+ *  hierarchical option value.
+ *  @item
+ *  @code{ENOENT} - no entry matched the given name.
+ *  @end itemize
+=*/
+const tOptionValue*
+optionFindNextValue( const tOptDesc* pOptDesc, const tOptionValue* pPrevVal,
+                 char const* pzName, char const* pzVal )
+{
+    int foundOldVal = 0;
+    tOptionValue* pRes = NULL;
+
+    if (  (pOptDesc == NULL)
+       || (OPTST_GET_ARGTYPE(pOptDesc->fOptState) != OPARG_TYPE_HIERARCHY))  {
+        errno = EINVAL;
+    }
+
+    else if (pOptDesc->optCookie == NULL) {
+        errno = ENOENT;
+    }
+
+    else do {
+        tArgList* pAL = pOptDesc->optCookie;
+        int    ct   = pAL->useCt;
+        void** ppOV = (void**)pAL->apzArgs;
+
+        if (ct == 0) {
+            errno = ENOENT;
+            break;
+        }
+
+        while (--ct >= 0) {
+            tOptionValue* pOV = *(ppOV++);
+            if (foundOldVal) {
+                pRes = pOV;
+                break;
+            }
+            if (pOV == pPrevVal)
+                foundOldVal = 1;
+        }
+        if (pRes == NULL)
+            errno = ENOENT;
+    } while (0);
+
+    return pRes;
+}
+
+
+/*=export_func  optionGetValue
+ *
+ * what:  get a specific value from a hierarcical list
+ * arg:   + const tOptionValue* + pOptValue + a hierarchcal value +
+ * arg:   + char const*   + valueName + name of value to get +
+ *
+ * ret_type:  const tOptionValue*
+ * ret_desc:  a compound value structure
+ *
+ * doc:
+ *  This routine will find an entry in a nested value option or configurable.
+ *  If "valueName" is NULL, then the first entry is returned.  Otherwise,
+ *  the first entry with a name that exactly matches the argument will be
+ *  returned.
+ *
+ * err:
+ *  The returned result is NULL and errno is set:
+ *  @itemize @bullet
+ *  @item
+ *  @code{EINVAL} - the @code{pOptValue} does not point to a valid
+ *  hierarchical option value.
+ *  @item
+ *  @code{ENOENT} - no entry matched the given name.
+ *  @end itemize
+=*/
+const tOptionValue*
+optionGetValue( const tOptionValue* pOld, char const* pzValName )
+{
+    tArgList*     pAL;
+    tOptionValue* pRes = NULL;
+
+    if ((pOld == NULL) || (pOld->valType != OPARG_TYPE_HIERARCHY)) {
+        errno = EINVAL;
+        return NULL;
+    }
+    pAL = pOld->v.nestVal;
+
+    if (pAL->useCt > 0) {
+        int    ct    = pAL->useCt;
+        void** papOV = (void**)(pAL->apzArgs);
+
+        if (pzValName == NULL) {
+            pRes = (tOptionValue*)*papOV;
+        }
+
+        else do {
+            tOptionValue* pOV = *(papOV++);
+            if (strcmp( pOV->pzName, pzValName ) == 0) {
+                pRes = pOV;
+                break;
+            }
+        } while (--ct > 0);
+    }
+    if (pRes == NULL)
+        errno = ENOENT;
+    return pRes;
+}
+
+
+/*=export_func  optionNextValue
+ *
+ * what:  get the next value from a hierarchical list
+ * arg:   + const tOptionValue* + pOptValue + a hierarchcal list value +
+ * arg:   + const tOptionValue* + pOldValue + a value from this list   +
+ *
+ * ret_type:  const tOptionValue*
+ * ret_desc:  a compound value structure
+ *
+ * doc:
+ *  This routine will return the next entry after the entry passed in.  At the
+ *  end of the list, NULL will be returned.  If the entry is not found on the
+ *  list, NULL will be returned and "@var{errno}" will be set to EINVAL.
+ *  The "@var{pOldValue}" must have been gotten from a prior call to this
+ *  routine or to "@code{opitonGetValue()}".
+ *
+ * err:
+ *  The returned result is NULL and errno is set:
+ *  @itemize @bullet
+ *  @item
+ *  @code{EINVAL} - the @code{pOptValue} does not point to a valid
+ *  hierarchical option value or @code{pOldValue} does not point to a
+ *  member of that option value.
+ *  @item
+ *  @code{ENOENT} - the supplied @code{pOldValue} pointed to the last entry.
+ *  @end itemize
+=*/
+tOptionValue const *
+optionNextValue(tOptionValue const * pOVList,tOptionValue const * pOldOV )
+{
+    tArgList*     pAL;
+    tOptionValue* pRes = NULL;
+    int           err  = EINVAL;
+
+    if ((pOVList == NULL) || (pOVList->valType != OPARG_TYPE_HIERARCHY)) {
+        errno = EINVAL;
+        return NULL;
+    }
+    pAL = pOVList->v.nestVal;
+    {
+        int    ct    = pAL->useCt;
+        void** papNV = (void**)(pAL->apzArgs);
+
+        while (ct-- > 0) {
+            tOptionValue* pNV = *(papNV++);
+            if (pNV == pOldOV) {
+                if (ct == 0) {
+                    err = ENOENT;
+
+                } else {
+                    err  = 0;
+                    pRes = (tOptionValue*)*papNV;
+                }
+                break;
+            }
+        }
+    }
+    if (err != 0)
+        errno = err;
+    return pRes;
+}
+
+
+/*  filePreset
+ *
+ *  Load a file containing presetting information (a configuration file).
+ */
+static void
+filePreset(
+    tOptions*     pOpts,
+    char const*   pzFileName,
+    int           direction )
+{
+    tmap_info_t   cfgfile;
+    tOptState     st = OPTSTATE_INITIALIZER(PRESET);
+    char*         pzFileText =
+        text_mmap( pzFileName, PROT_READ|PROT_WRITE, MAP_PRIVATE, &cfgfile );
+
+    if (TEXT_MMAP_FAILED_ADDR(pzFileText))
+        return;
+
+    if (direction == DIRECTION_CALLED) {
+        st.flags  = OPTST_DEFINED;
+        direction = DIRECTION_PROCESS;
+    }
+
+    /*
+     *  IF this is called via "optionProcess", then we are presetting.
+     *  This is the default and the PRESETTING bit will be set.
+     *  If this is called via "optionFileLoad", then the bit is not set
+     *  and we consider stuff set herein to be "set" by the client program.
+     */
+    if ((pOpts->fOptSet & OPTPROC_PRESETTING) == 0)
+        st.flags = OPTST_SET;
+
+    do  {
+        while (isspace( (int)*pzFileText ))  pzFileText++;
+
+        if (isalpha( (int)*pzFileText )) {
+            pzFileText = handleConfig( pOpts, &st, pzFileText, direction );
+
+        } else switch (*pzFileText) {
+        case '<':
+            if (isalpha( (int)pzFileText[1] ))
+                pzFileText = handleStructure(pOpts, &st, pzFileText, direction);
+
+            else switch (pzFileText[1]) {
+            case '?':
+                pzFileText = handleDirective( pOpts, pzFileText );
+                break;
+
+            case '!':
+                pzFileText = handleComment( pzFileText );
+                break;
+
+            case '/':
+                pzFileText = strchr( pzFileText+2, '>' );
+                if (pzFileText++ != NULL)
+                    break;
+
+            default:
+                goto all_done;
+            }
+            break;
+
+        case '[':
+            pzFileText = handleProgramSection( pOpts, pzFileText );
+            break;
+
+        case '#':
+            pzFileText = strchr( pzFileText+1, '\n' );
+            break;
+
+        default:
+            goto all_done; /* invalid format */
+        }
+    } while (pzFileText != NULL);
+
+ all_done:
+    text_munmap( &cfgfile );
+}
+
+
+/*  handleComment
+ *
+ *  "pzText" points to a "<!" sequence.
+ *  Theoretically, we should ensure that it begins with "<!--",
+ *  but actually I don't care that much.  It ends with "-->".
+ */
+static char*
+handleComment( char* pzText )
+{
+    char* pz = strstr( pzText, "-->" );
+    if (pz != NULL)
+        pz += 3;
+    return pz;
+}
+
+
+/*  handleConfig
+ *
+ *  "pzText" points to the start of some value name.
+ *  The end of the entry is the end of the line that is not preceded by
+ *  a backslash escape character.  The string value is always processed
+ *  in "cooked" mode.
+ */
+static char*
+handleConfig(
+    tOptions*     pOpts,
+    tOptState*    pOS,
+    char*         pzText,
+    int           direction )
+{
+    char* pzName = pzText++;
+    char* pzEnd  = strchr( pzText, '\n' );
+
+    if (pzEnd == NULL)
+        return pzText + strlen(pzText);
+
+    while (ISNAMECHAR( (int)*pzText ))  pzText++;
+    while (isspace( (int)*pzText )) pzText++;
+    if (pzText > pzEnd) {
+    name_only:
+        *pzEnd++ = NUL;
+        loadOptionLine( pOpts, pOS, pzName, direction, OPTION_LOAD_UNCOOKED );
+        return pzEnd;
+    }
+
+    /*
+     *  Either the first character after the name is a ':' or '=',
+     *  or else we must have skipped over white space.  Anything else
+     *  is an invalid format and we give up parsing the text.
+     */
+    if ((*pzText == '=') || (*pzText == ':')) {
+        while (isspace( (int)*++pzText ))   ;
+        if (pzText > pzEnd)
+            goto name_only;
+    } else if (! isspace((int)pzText[-1]))
+        return NULL;
+
+    /*
+     *  IF the value is continued, remove the backslash escape and push "pzEnd"
+     *  on to a newline *not* preceded by a backslash.
+     */
+    if (pzEnd[-1] == '\\') {
+        char* pcD = pzEnd-1;
+        char* pcS = pzEnd;
+
+        for (;;) {
+            char ch = *(pcS++);
+            switch (ch) {
+            case NUL:
+                pcS = NULL;
+
+            case '\n':
+                *pcD = NUL;
+                pzEnd = pcS;
+                goto copy_done;
+
+            case '\\':
+                if (*pcS == '\n') {
+                    ch = *(pcS++);
+                }
+                /* FALLTHROUGH */
+            default:
+                *(pcD++) = ch;
+            }
+        } copy_done:;
+
+    } else {
+        /*
+         *  The newline was not preceded by a backslash.  NUL it out
+         */
+        *(pzEnd++) = NUL;
+    }
+
+    /*
+     *  "pzName" points to what looks like text for one option/configurable.
+     *  It is NUL terminated.  Process it.
+     */
+    loadOptionLine( pOpts, pOS, pzName, direction, OPTION_LOAD_UNCOOKED );
+
+    return pzEnd;
+}
+
+
+/*  handleDirective
+ *
+ *  "pzText" points to a "<?" sequence.
+ *  For the moment, we only handle "<?program" directives.
+ */
+static char*
+handleDirective(
+    tOptions*     pOpts,
+    char*         pzText )
+{
+    char   ztitle[32] = "<?";
+    size_t title_len = strlen( zProg );
+    size_t name_len;
+
+    if (  (strncmp( pzText+2, zProg, title_len ) != 0)
+       || (! isspace( (int)pzText[title_len+2] )) )  {
+        pzText = strchr( pzText+2, '>' );
+        if (pzText != NULL)
+            pzText++;
+        return pzText;
+    }
+
+    name_len = strlen( pOpts->pzProgName );
+    strcpy( ztitle+2, zProg );
+    title_len += 2;
+
+    do  {
+        pzText += title_len;
+
+        if (isspace((int)*pzText)) {
+            while (isspace((int)*pzText))  pzText++;
+            if (  (strneqvcmp( pzText, pOpts->pzProgName, (int)name_len) == 0)
+               && (pzText[name_len] == '>'))  {
+                pzText += name_len + 1;
+                break;
+            }
+        }
+
+        pzText = strstr( pzText, ztitle );
+    } while (pzText != NULL);
+
+    return pzText;
+}
+
+
+/*  handleProgramSection
+ *
+ *  "pzText" points to a '[' character.
+ *  The "traditional" [PROG_NAME] segmentation of the config file.
+ *  Do not ever mix with the "<?program prog-name>" variation.
+ */
+static char*
+handleProgramSection(
+    tOptions*     pOpts,
+    char*         pzText )
+{
+    size_t len = strlen( pOpts->pzPROGNAME );
+    if (   (strncmp( pzText+1, pOpts->pzPROGNAME, len ) == 0)
+        && (pzText[len+1] == ']'))
+        return strchr( pzText + len + 2, '\n' );
+
+    if (len > 16)
+        return NULL;
+
+    {
+        char z[24];
+        sprintf( z, "[%s]", pOpts->pzPROGNAME );
+        pzText = strstr( pzText, z );
+    }
+
+    if (pzText != NULL)
+        pzText = strchr( pzText, '\n' );
+    return pzText;
+}
+
+
+/*  handleStructure
+ *
+ *  "pzText" points to a '<' character, followed by an alpha.
+ *  The end of the entry is either the "/>" following the name, or else a
+ *  "</name>" string.
+ */
+static char*
+handleStructure(
+    tOptions*     pOpts,
+    tOptState*    pOS,
+    char*         pzText,
+    int           direction )
+{
+    tOptionLoadMode mode = option_load_mode;
+    tOptionValue     valu;
+
+    char* pzName = ++pzText;
+    char* pzData;
+    char* pcNulPoint;
+
+    while (ISNAMECHAR( *pzText ))  pzText++;
+    pcNulPoint = pzText;
+    valu.valType = OPARG_TYPE_STRING;
+
+    switch (*pzText) {
+    case ' ':
+    case '\t':
+        pzText = parseAttributes( pOpts, pzText, &mode, &valu );
+        if (*pzText == '>')
+            break;
+        if (*pzText != '/')
+            return NULL;
+        /* FALLTHROUGH */
+
+    case '/':
+        if (pzText[1] != '>')
+            return NULL;
+        *pzText = NUL;
+        pzText += 2;
+        loadOptionLine( pOpts, pOS, pzName, direction, mode );
+        return pzText;
+
+    case '>':
+        break;
+
+    default:
+        pzText = strchr( pzText, '>');
+        if (pzText != NULL)
+            pzText++;
+        return pzText;
+    }
+
+    /*
+     *  If we are here, we have a value.  "pzText" points to a closing angle
+     *  bracket.  Separate the name from the value for a moment.
+     */
+    *pcNulPoint = NUL;
+    pzData = ++pzText;
+
+    /*
+     *  Find the end of the option text and NUL terminate it
+     */
+    {
+        char   z[64], *pz = z;
+        size_t len = strlen(pzName) + 4;
+        if (len > sizeof(z))
+            pz = AGALOC(len, "scan name");
+
+        sprintf( pz, "</%s>", pzName );
+        *pzText = ' ';
+        pzText = strstr( pzText, pz );
+        if (pz != z) AGFREE(pz);
+
+        if (pzText == NULL)
+            return pzText;
+
+        *pzText = NUL;
+
+        pzText += len-1;
+    }
+
+    /*
+     *  Rejoin the name and value for parsing by "loadOptionLine()".
+     *  Erase any attributes parsed by "parseAttributes()".
+     */
+    memset(pcNulPoint, ' ', pzData - pcNulPoint);
+
+    /*
+     *  "pzName" points to what looks like text for one option/configurable.
+     *  It is NUL terminated.  Process it.
+     */
+    loadOptionLine( pOpts, pOS, pzName, direction, mode );
+
+    return pzText;
+}
+
+
+/*  internalFileLoad
+ *
+ *  Load a configuration file.  This may be invoked either from
+ *  scanning the "homerc" list, or from a specific file request.
+ *  (see "optionFileLoad()", the implementation for --load-opts)
+ */
+LOCAL void
+internalFileLoad( tOptions* pOpts )
+{
+    int     idx;
+    int     inc = DIRECTION_PRESET;
+    char    zFileName[ AG_PATH_MAX+1 ];
+
+    if (pOpts->papzHomeList == NULL)
+        return;
+
+    /*
+     *  Find the last RC entry (highest priority entry)
+     */
+    for (idx = 0; pOpts->papzHomeList[ idx+1 ] != NULL; ++idx)  ;
+
+    /*
+     *  For every path in the home list, ...  *TWICE* We start at the last
+     *  (highest priority) entry, work our way down to the lowest priority,
+     *  handling the immediate options.
+     *  Then we go back up, doing the normal options.
+     */
+    for (;;) {
+        struct stat StatBuf;
+        cch_t*  pzPath;
+
+        /*
+         *  IF we've reached the bottom end, change direction
+         */
+        if (idx < 0) {
+            inc = DIRECTION_PROCESS;
+            idx = 0;
+        }
+
+        pzPath = pOpts->papzHomeList[ idx ];
+
+        /*
+         *  IF we've reached the top end, bail out
+         */
+        if (pzPath == NULL)
+            break;
+
+        idx += inc;
+
+        if (! optionMakePath( zFileName, (int)sizeof(zFileName),
+                              pzPath, pOpts->pzProgPath ))
+            continue;
+
+        /*
+         *  IF the file name we constructed is a directory,
+         *  THEN append the Resource Configuration file name
+         *  ELSE we must have the complete file name
+         */
+        if (stat( zFileName, &StatBuf ) != 0)
+            continue; /* bogus name - skip the home list entry */
+
+        if (S_ISDIR( StatBuf.st_mode )) {
+            size_t len = strlen( zFileName );
+            char* pz;
+
+            if (len + 1 + strlen( pOpts->pzRcName ) >= sizeof( zFileName ))
+                continue;
+
+            pz = zFileName + len;
+            if (pz[-1] != DIRCH)
+                *(pz++) = DIRCH;
+            strcpy( pz, pOpts->pzRcName );
+        }
+
+        filePreset( pOpts, zFileName, inc );
+
+        /*
+         *  IF we are now to skip config files AND we are presetting,
+         *  THEN change direction.  We must go the other way.
+         */
+        {
+            tOptDesc * pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts+1;
+            if (DISABLED_OPT(pOD) && PRESETTING(inc)) {
+                idx -= inc;  /* go back and reprocess current file */
+                inc =  DIRECTION_PROCESS;
+            }
+        }
+    } /* twice for every path in the home list, ... */
+}
+
+
+/*=export_func optionFileLoad
+ *
+ * what: Load the locatable config files, in order
+ *
+ * arg:  + tOptions*   + pOpts  + program options descriptor +
+ * arg:  + char const* + pzProg + program name +
+ *
+ * ret_type:  int
+ * ret_desc:  0 -> SUCCESS, -1 -> FAILURE
+ *
+ * doc:
+ *
+ * This function looks in all the specified directories for a configuration
+ * file ("rc" file or "ini" file) and processes any found twice.  The first
+ * time through, they are processed in reverse order (last file first).  At
+ * that time, only "immediate action" configurables are processed.  For
+ * example, if the last named file specifies not processing any more
+ * configuration files, then no more configuration files will be processed.
+ * Such an option in the @strong{first} named directory will have no effect.
+ *
+ * Once the immediate action configurables have been handled, then the
+ * directories are handled in normal, forward order.  In that way, later
+ * config files can override the settings of earlier config files.
+ *
+ * See the AutoOpts documentation for a thorough discussion of the
+ * config file format.
+ *
+ * Configuration files not found or not decipherable are simply ignored.
+ *
+ * err:  Returns the value, "-1" if the program options descriptor
+ *       is out of date or indecipherable.  Otherwise, the value "0" will
+ *       always be returned.
+=*/
+int
+optionFileLoad( tOptions* pOpts, char const* pzProgram )
+{
+    if (! SUCCESSFUL( validateOptionsStruct( pOpts, pzProgram )))
+        return -1;
+
+    pOpts->pzProgName = pzProgram;
+    internalFileLoad( pOpts );
+    return 0;
+}
+
+
+/*=export_func  optionLoadOpt
+ * private:
+ *
+ * what:  Load an option rc/ini file
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Processes the options found in the file named with
+ *  pOptDesc->optArg.argString.
+=*/
+void
+optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc )
+{
+    /*
+     *  IF the option is not being disabled, THEN load the file.  There must
+     *  be a file.  (If it is being disabled, then the disablement processing
+     *  already took place.  It must be done to suppress preloading of ini/rc
+     *  files.)
+     */
+    if (! DISABLED_OPT( pOptDesc )) {
+        struct stat sb;
+        if (stat( pOptDesc->optArg.argString, &sb ) != 0) {
+            if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0)
+                return;
+
+            fprintf( stderr, zFSErrOptLoad, errno, strerror( errno ),
+                     pOptDesc->optArg.argString );
+            exit(EX_NOINPUT);
+            /* NOT REACHED */
+        }
+
+        if (! S_ISREG( sb.st_mode )) {
+            if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0)
+                return;
+
+            fprintf( stderr, zNotFile, pOptDesc->optArg.argString );
+            exit(EX_NOINPUT);
+            /* NOT REACHED */
+        }
+
+        filePreset(pOpts, pOptDesc->optArg.argString, DIRECTION_CALLED);
+    }
+}
+
+
+/*  parseAttributes
+ *
+ *  Parse the various attributes of an XML-styled config file entry
+ */
+LOCAL char*
+parseAttributes(
+    tOptions*           pOpts,
+    char*               pzText,
+    tOptionLoadMode*    pMode,
+    tOptionValue*       pType )
+{
+    size_t lenLoadType = strlen( zLoadType );
+    size_t lenKeyWords = strlen( zKeyWords );
+    size_t lenSetMem   = strlen( zSetMembers );
+
+    do  {
+        switch (*pzText) {
+        case '/': pType->valType = OPARG_TYPE_NONE;
+        case '>': return pzText;
+
+        default:
+        case NUL: return NULL;
+
+        case ' ':
+        case '\t':
+        case '\n':
+        case '\f':
+        case '\r':
+        case '\v':
+            break;
+        }
+
+        while (isspace( (int)*++pzText ))   ;
+
+        if (strncmp( pzText, zLoadType, lenLoadType ) == 0) {
+            pzText = parseValueType( pzText+lenLoadType, pType );
+            continue;
+        }
+
+        if (strncmp( pzText, zKeyWords, lenKeyWords ) == 0) {
+            pzText = parseKeyWordType( pOpts, pzText+lenKeyWords, pType );
+            continue;
+        }
+
+        if (strncmp( pzText, zSetMembers, lenSetMem ) == 0) {
+            pzText = parseSetMemType( pOpts, pzText+lenSetMem, pType );
+            continue;
+        }
+
+        pzText = parseLoadMode( pzText, pMode );
+    } while (pzText != NULL);
+
+    return pzText;
+}
+
+
+/*  parseKeyWordType
+ *
+ *  "pzText" points to the character after "words=".
+ *  What should follow is a name of a keyword (enumeration) list.
+ */
+static char*
+parseKeyWordType(
+    tOptions*     pOpts,
+    char*         pzText,
+    tOptionValue* pType )
+{
+    return skipUnknown( pzText );
+}
+
+
+/*  parseLoadMode
+ *
+ *  "pzText" points to some name character.  We check for "cooked" or
+ *  "uncooked" or "keep".  This function should handle any attribute
+ *  that does not have an associated value.
+ */
+static char*
+parseLoadMode(
+    char*               pzText,
+    tOptionLoadMode*    pMode )
+{
+    {
+        size_t len = strlen(zLoadCooked);
+        if (strncmp( pzText, zLoadCooked, len ) == 0) {
+            if (  (pzText[len] == '>')
+               || (pzText[len] == '/')
+               || isspace((int)pzText[len])) {
+                *pMode = OPTION_LOAD_COOKED;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLoadUncooked);
+        if (strncmp( pzText, zLoadUncooked, len ) == 0) {
+            if (  (pzText[len] == '>')
+               || (pzText[len] == '/')
+               || isspace((int)pzText[len])) {
+                *pMode = OPTION_LOAD_UNCOOKED;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLoadKeep);
+        if (strncmp( pzText, zLoadKeep, len ) == 0) {
+            if (  (pzText[len] == '>')
+               || (pzText[len] == '/')
+               || isspace((int)pzText[len])) {
+                *pMode = OPTION_LOAD_KEEP;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+  unknown:
+    return skipUnknown( pzText );
+}
+
+
+/*  parseSetMemType
+ *
+ *  "pzText" points to the character after "members="
+ *  What should follow is a name of a "set membership".
+ *  A collection of bit flags.
+ */
+static char*
+parseSetMemType(
+    tOptions*     pOpts,
+    char*         pzText,
+    tOptionValue* pType )
+{
+    return skipUnknown( pzText );
+}
+
+
+/*  parseValueType
+ *
+ *  "pzText" points to the character after "type="
+ */
+static char*
+parseValueType(
+    char*         pzText,
+    tOptionValue* pType )
+{
+    {
+        size_t len = strlen(zLtypeString);
+        if (strncmp( pzText, zLtypeString, len ) == 0) {
+            if ((pzText[len] == '>') || isspace((int)pzText[len])) {
+                pType->valType = OPARG_TYPE_STRING;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLtypeInteger);
+        if (strncmp( pzText, zLtypeInteger, len ) == 0) {
+            if ((pzText[len] == '>') || isspace((int)pzText[len])) {
+                pType->valType = OPARG_TYPE_NUMERIC;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLtypeBool);
+        if (strncmp( pzText, zLtypeBool, len ) == 0) {
+            if ((pzText[len] == '>') || isspace(pzText[len])) {
+                pType->valType = OPARG_TYPE_BOOLEAN;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLtypeKeyword);
+        if (strncmp( pzText, zLtypeKeyword, len ) == 0) {
+            if ((pzText[len] == '>') || isspace((int)pzText[len])) {
+                pType->valType = OPARG_TYPE_ENUMERATION;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLtypeSetMembership);
+        if (strncmp( pzText, zLtypeSetMembership, len ) == 0) {
+            if ((pzText[len] == '>') || isspace((int)pzText[len])) {
+                pType->valType = OPARG_TYPE_MEMBERSHIP;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLtypeNest);
+        if (strncmp( pzText, zLtypeNest, len ) == 0) {
+            if ((pzText[len] == '>') || isspace((int)pzText[len])) {
+                pType->valType = OPARG_TYPE_HIERARCHY;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+  unknown:
+    pType->valType = OPARG_TYPE_NONE;
+    return skipUnknown( pzText );
+}
+
+
+/*  skipUnknown
+ *
+ *  Skip over some unknown attribute
+ */
+static char*
+skipUnknown( char* pzText )
+{
+    for (;; pzText++) {
+        if (isspace( (int)*pzText ))  return pzText;
+        switch (*pzText) {
+        case NUL: return NULL;
+        case '/':
+        case '>': return pzText;
+        }
+    }
+}
+
+
+/*  validateOptionsStruct
+ *
+ *  Make sure the option descriptor is there and that we understand it.
+ *  This should be called from any user entry point where one needs to
+ *  worry about validity.  (Some entry points are free to assume that
+ *  the call is not the first to the library and, thus, that this has
+ *  already been called.)
+ */
+LOCAL tSuccess
+validateOptionsStruct( tOptions* pOpts, char const* pzProgram )
+{
+    if (pOpts == NULL) {
+        fputs( zAO_Bad, stderr );
+        exit( EX_CONFIG );
+    }
+
+    /*
+     *  IF the client has enabled translation and the translation procedure
+     *  is available, then go do it.
+     */
+    if (  ((pOpts->fOptSet & OPTPROC_TRANSLATE) != 0)
+       && (pOpts->pTransProc != 0) ) {
+        (*pOpts->pTransProc)();
+        pOpts->fOptSet &= ~OPTPROC_TRANSLATE;
+    }
+
+    /*
+     *  IF the struct version is not the current, and also
+     *     either too large (?!) or too small,
+     *  THEN emit error message and fail-exit
+     */
+    if (  ( pOpts->structVersion  != OPTIONS_STRUCT_VERSION  )
+       && (  (pOpts->structVersion > OPTIONS_STRUCT_VERSION  )
+          || (pOpts->structVersion < OPTIONS_MINIMUM_VERSION )
+       )  )  {
+
+        fprintf( stderr, zAO_Err, pOpts->origArgVect[0],
+                 NUM_TO_VER( pOpts->structVersion ));
+        if (pOpts->structVersion > OPTIONS_STRUCT_VERSION )
+            fputs( zAO_Big, stderr );
+        else
+            fputs( zAO_Sml, stderr );
+
+        return FAILURE;
+    }
+
+    /*
+     *  If the program name hasn't been set, then set the name and the path
+     *  and the set of equivalent characters.
+     */
+    if (pOpts->pzProgName == NULL) {
+        char const* pz = strrchr( pzProgram, DIRCH );
+
+        if (pz == NULL)
+             pOpts->pzProgName = pzProgram;
+        else pOpts->pzProgName = pz+1;
+
+        pOpts->pzProgPath = pzProgram;
+
+        /*
+         *  when comparing long names, these are equivalent
+         */
+        strequate( zSepChars );
+    }
+
+    return SUCCESS;
+}
+
+
+/**
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/configfile.c */
diff --git a/libopts/cook.c b/libopts/cook.c
new file mode 100644 (file)
index 0000000..bebd123
--- /dev/null
@@ -0,0 +1,354 @@
+
+/*
+ *  $Id: cook.c,v 4.10 2007/02/04 17:44:12 bkorb Exp $
+ *  Time-stamp:      "2006-09-24 15:21:02 bkorb"
+ *
+ *  This file contains the routines that deal with processing quoted strings
+ *  into an internal format.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+/* = = = END-STATIC-FORWARD = = = */
+
+/*=export_func  ao_string_cook_escape_char
+ * private:
+ *
+ * what:  escape-process a string fragment
+ * arg:   + char const*  + pzScan  + points to character after the escape +
+ * arg:   + char*        + pRes    + Where to put the result byte +
+ * arg:   + unsigned int + nl_ch   + replacement char if scanned char is \n +
+ *
+ * ret-type: unsigned int
+ * ret-desc: The number of bytes consumed processing the escaped character.
+ *
+ * doc:
+ *
+ *  This function converts "t" into "\t" and all your other favorite
+ *  escapes, including numeric ones:  hex and ocatal, too.
+ *  The returned result tells the caller how far to advance the
+ *  scan pointer (passed in).  The default is to just pass through the
+ *  escaped character and advance the scan by one.
+ *
+ *  Some applications need to keep an escaped newline, others need to
+ *  suppress it.  This is accomplished by supplying a '\n' replacement
+ *  character that is different from \n, if need be.  For example, use
+ *  0x7F and never emit a 0x7F.
+ *
+ * err:  @code{NULL} is returned if the string is mal-formed.
+=*/
+unsigned int
+ao_string_cook_escape_char( char const* pzIn, char* pRes, u_int nl )
+{
+    unsigned int  res = 1;
+
+    switch (*pRes = *pzIn++) {
+    case NUL:         /* NUL - end of input string */
+        return 0;
+    case '\r':
+        if (*pzIn != '\n')
+            return 1;
+        res++;
+        /* FALLTHROUGH */
+    case '\n':        /* NL  - emit newline        */
+        *pRes = (char)nl;
+        return res;
+
+    case 'a': *pRes = '\a'; break;
+    case 'b': *pRes = '\b'; break;
+    case 'f': *pRes = '\f'; break;
+    case 'n': *pRes = '\n'; break;
+    case 'r': *pRes = '\r'; break;
+    case 't': *pRes = '\t'; break;
+    case 'v': *pRes = '\v'; break;
+
+    case 'x':         /* HEX Escape       */
+        if (isxdigit( (int)*pzIn ))  {
+            unsigned int  val;
+            unsigned char ch = *pzIn++;
+
+            if ((ch >= 'A') && (ch <= 'F'))
+                val = 10 + (ch - 'A');
+            else if ((ch >= 'a') && (ch <= 'f'))
+                val = 10 + (ch - 'a');
+            else val = ch - '0';
+
+            ch = *pzIn;
+
+            if (! isxdigit( ch )) {
+                *pRes = val;
+                res   = 2;
+                break;
+            }
+            val <<= 4;
+            if ((ch >= 'A') && (ch <= 'F'))
+                val += 10 + (ch - 'A');
+            else if ((ch >= 'a') && (ch <= 'f'))
+                val += 10 + (ch - 'a');
+            else val += ch - '0';
+
+            res = 3;
+            *pRes = val;
+        }
+        break;
+
+    default:
+        /*
+         *  IF the character copied was an octal digit,
+         *  THEN set the output character to an octal value
+         */
+        if (isdigit( (int)*pRes ) && (*pRes < '8'))  {
+            unsigned int  val = *pRes - '0';
+            unsigned char ch  = *pzIn++;
+
+            /*
+             *  IF the second character is *not* an octal digit,
+             *  THEN save the value and bail
+             */
+            if ((ch < '0') || (ch > '7')) {
+                *pRes = val;
+                break;
+            }
+
+            val = (val<<3) + (ch - '0');
+            ch  = *pzIn;
+            res = 2;
+
+            /*
+             *  IF the THIRD character is *not* an octal digit,
+             *  THEN save the value and bail
+             */
+            if ((ch < '0') || (ch > '7')) {
+                *pRes = val;
+                break;
+            }
+
+            /*
+             *  IF the new value would not be too large,
+             *  THEN add on the third and last character value
+             */
+            if ((val<<3) < 0xFF) {
+                val = (val<<3) + (ch - '0');
+                res = 3;
+            }
+
+            *pRes = val;
+            break;
+        }
+    }
+
+    return res;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  A quoted string has been found.
+ *  Find the end of it and compress any escape sequences.
+ */
+/*=export_func  ao_string_cook
+ * private:
+ *
+ * what:  concatenate and escape-process strings
+ * arg:   + char* + pzScan     + The *MODIFIABLE* input buffer +
+ * arg:   + int*  + pLineCt    + The (possibly NULL) pointer to a line count +
+ *
+ * ret-type: char*
+ * ret-desc: The address of the text following the processed strings.
+ *           The return value is NULL if the strings are ill-formed.
+ *
+ * doc:
+ *
+ *  A series of one or more quoted strings are concatenated together.
+ *  If they are quoted with double quotes (@code{"}), then backslash
+ *  escapes are processed per the C programming language.  If they are
+ *  single quote strings, then the backslashes are honored only when they
+ *  precede another backslash or a single quote character.
+ *
+ * err:  @code{NULL} is returned if the string(s) is/are mal-formed.
+=*/
+char*
+ao_string_cook( char* pzScan, int* pLineCt )
+{
+    int   l = 0;
+    char  q = *pzScan;
+
+    /*
+     *  It is a quoted string.  Process the escape sequence characters
+     *  (in the set "abfnrtv") and make sure we find a closing quote.
+     */
+    char* pzD = pzScan++;
+    char* pzS = pzScan;
+
+    if (pLineCt == NULL)
+        pLineCt = &l;
+
+    for (;;) {
+        /*
+         *  IF the next character is the quote character, THEN we may end the
+         *  string.  We end it unless the next non-blank character *after* the
+         *  string happens to also be a quote.  If it is, then we will change
+         *  our quote character to the new quote character and continue
+         *  condensing text.
+         */
+        while (*pzS == q) {
+            *pzD = NUL; /* This is probably the end of the line */
+            pzS++;
+
+        scan_for_quote:
+            while (isspace((int)*pzS))
+                if (*(pzS++) == '\n')
+                    (*pLineCt)++;
+
+            /*
+             *  IF the next character is a quote character,
+             *  THEN we will concatenate the strings.
+             */
+            switch (*pzS) {
+            case '"':
+            case '\'':
+                break;
+
+            case '/':
+                /*
+                 *  Allow for a comment embedded in the concatenated string.
+                 */
+                switch (pzS[1]) {
+                default:  return NULL;
+                case '/':
+                    /*
+                     *  Skip to end of line
+                     */
+                    pzS = strchr( pzS, '\n' );
+                    if (pzS == NULL)
+                        return NULL;
+                    (*pLineCt)++;
+                    break;
+
+                case '*':
+                {
+                    char* p = strstr( pzS+2, "*/" );
+                    /*
+                     *  Skip to terminating star slash
+                     */
+                    if (p == NULL)
+                        return NULL;
+                    while (pzS < p) {
+                        if (*(pzS++) == '\n')
+                            (*pLineCt)++;
+                    }
+
+                    pzS = p + 2;
+                }
+                }
+                goto scan_for_quote;
+
+            default:
+                /*
+                 *  The next non-whitespace character is not a quote.
+                 *  The series of quoted strings has come to an end.
+                 */
+                return pzS;
+            }
+
+            q = *(pzS++);  /* assign new quote character and advance scan */
+        }
+
+        /*
+         *  We are inside a quoted string.  Copy text.
+         */
+        switch (*(pzD++) = *(pzS++)) {
+        case NUL:
+            return NULL;
+
+        case '\n':
+            (*pLineCt)++;
+            break;
+
+        case '\\':
+            /*
+             *  IF we are escaping a new line,
+             *  THEN drop both the escape and the newline from
+             *       the result string.
+             */
+            if (*pzS == '\n') {
+                pzS++;
+                pzD--;
+                (*pLineCt)++;
+            }
+
+            /*
+             *  ELSE IF the quote character is '"' or '`',
+             *  THEN we do the full escape character processing
+             */
+            else if (q != '\'') {
+                int ct = ao_string_cook_escape_char( pzS, pzD-1, (u_int)'\n' );
+                if (ct == 0)
+                    return NULL;
+
+                pzS += ct;
+            }     /* if (q != '\'')                  */
+
+            /*
+             *  OTHERWISE, we only process "\\", "\'" and "\#" sequences.
+             *  The latter only to easily hide preprocessing directives.
+             */
+            else switch (*pzS) {
+            case '\\':
+            case '\'':
+            case '#':
+                pzD[-1] = *pzS++;
+            }
+        }     /* switch (*(pzD++) = *(pzS++))    */
+    }         /* for (;;)                        */
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/cook.c */
diff --git a/libopts/enumeration.c b/libopts/enumeration.c
new file mode 100644 (file)
index 0000000..67dd4f4
--- /dev/null
@@ -0,0 +1,498 @@
+
+/*
+ *  $Id: enumeration.c,v 4.17 2007/02/04 17:44:12 bkorb Exp $
+ * Time-stamp:      "2007-01-13 10:22:35 bkorb"
+ *
+ *   Automated Options Paged Usage module.
+ *
+ *  This routine will run run-on options through a pager so the
+ *  user may examine, print or edit them at their leisure.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+tSCC*  pz_enum_err_fmt;
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+enumError(
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC* const *  paz_names,
+    int           name_ct );
+
+static uintptr_t
+findName(
+    tCC*          pzName,
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC* const *  paz_names,
+    unsigned int  name_ct );
+/* = = = END-STATIC-FORWARD = = = */
+
+static void
+enumError(
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC* const *  paz_names,
+    int           name_ct )
+{
+    size_t max_len = 0;
+    size_t ttl_len = 0;
+
+    if (pOpts != NULL)
+        fprintf( option_usage_fp, pz_enum_err_fmt, pOpts->pzProgName,
+                 pOD->optArg.argString, pOD->pz_Name );
+
+    fprintf( option_usage_fp, zValidKeys, pOD->pz_Name );
+
+    if (**paz_names == 0x7F) {
+        paz_names++;
+        name_ct--;
+    }
+
+    /*
+     *  Figure out the maximum length of any name, plus the total length
+     *  of all the names.
+     */
+    {
+        tCC * const * paz = paz_names;
+        int   ct  = name_ct;
+
+        do  {
+            size_t len = strlen( *(paz++) ) + 1;
+            if (len > max_len)
+                max_len = len;
+            ttl_len += len;
+        } while (--ct > 0);
+    }
+
+    /*
+     *  IF any one entry is about 1/2 line or longer, print one per line
+     */
+    if (max_len > 35) {
+        do  {
+            fprintf( option_usage_fp, "  %s\n", *(paz_names++) );
+        } while (--name_ct > 0);
+    }
+
+    /*
+     *  ELSE IF they all fit on one line, then do so.
+     */
+    else if (ttl_len < 76) {
+        fputc( ' ', option_usage_fp );
+        do  {
+            fputc( ' ', option_usage_fp );
+            fputs( *(paz_names++), option_usage_fp );
+        } while (--name_ct > 0);
+        fputc( '\n', option_usage_fp );
+    }
+
+    /*
+     *  Otherwise, columnize the output
+     */
+    else {
+        int   ent_no = 0;
+        char  zFmt[16];  /* format for all-but-last entries on a line */
+
+        sprintf( zFmt, "%%-%ds", (int)max_len );
+        max_len = 78 / max_len; /* max_len is now max entries on a line */
+        fputs( "  ", option_usage_fp );
+
+        /*
+         *  Loop through all but the last entry
+         */
+        while (--name_ct > 0) {
+            if (++ent_no == max_len) {
+                /*
+                 *  Last entry on a line.  Start next line, too.
+                 */
+                fprintf( option_usage_fp, "%s\n  ", *(paz_names++) );
+                ent_no = 0;
+            }
+
+            else
+                fprintf( option_usage_fp, zFmt, *(paz_names++) );
+        }
+        fprintf( option_usage_fp, "%s\n", *paz_names );
+    }
+
+    /*
+     *  IF we do not have a pOpts pointer, then this output is being requested
+     *  by the usage procedure.  Let's not re-invoke it recursively.
+     */
+    if (pOpts != NULL)
+        (*(pOpts->pUsageProc))( pOpts, EXIT_FAILURE );
+    if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP)
+        fputs( zSetMemberSettings, option_usage_fp );
+}
+
+
+static uintptr_t
+findName(
+    tCC*          pzName,
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC* const *  paz_names,
+    unsigned int  name_ct )
+{
+    uintptr_t     res = name_ct;
+    size_t        len = strlen( (char*)pzName );
+    uintptr_t     idx;
+    /*
+     *  Look for an exact match, but remember any partial matches.
+     *  Multiple partial matches means we have an ambiguous match.
+     */
+    for (idx = 0; idx < name_ct; idx++) {
+        if (strncmp( (char*)paz_names[idx], (char*)pzName, len) == 0) {
+            if (paz_names[idx][len] == NUL)
+                return idx;  /* full match */
+
+            if (res != name_ct) {
+                pz_enum_err_fmt = zAmbigKey;
+                option_usage_fp = stderr;
+                enumError( pOpts, pOD, paz_names, (int)name_ct );
+            }
+            res = idx; /* save partial match */
+        }
+    }
+
+    /*
+     *  no partial match -> error
+     */
+    if (res == name_ct) {
+        pz_enum_err_fmt = zNoKey;
+        option_usage_fp = stderr;
+        enumError( pOpts, pOD, paz_names, (int)name_ct );
+    }
+
+    /*
+     *  Return the matching index as a char* pointer.
+     *  The result gets stashed in a char* pointer, so it will have to fit.
+     */
+    return res;
+}
+
+
+/*=export_func  optionKeywordName
+ * what:  Convert between enumeration values and strings
+ * private:
+ *
+ * arg:   tOptDesc*,     pOD,       enumeration option description
+ * arg:   unsigned int,  enum_val,  the enumeration value to map
+ *
+ * ret_type:  char const*
+ * ret_desc:  the enumeration name from const memory
+ *
+ * doc:   This converts an enumeration value into the matching string.
+=*/
+char const*
+optionKeywordName(
+    tOptDesc*     pOD,
+    unsigned int  enum_val )
+{
+    tOptDesc od;
+
+    od.optArg.argEnum = enum_val;
+    (*(pOD->pOptProc))( (void*)(2UL), &od );
+    return od.optArg.argString;
+}
+
+
+/*=export_func  optionEnumerationVal
+ * what:  Convert from a string to an enumeration value
+ * private:
+ *
+ * arg:   tOptions*,     pOpts,     the program options descriptor
+ * arg:   tOptDesc*,     pOD,       enumeration option description
+ * arg:   char const * const *,  paz_names, list of enumeration names
+ * arg:   unsigned int,  name_ct,   number of names in list
+ *
+ * ret_type:  uintptr_t
+ * ret_desc:  the enumeration value
+ *
+ * doc:   This converts the optArg.argString string from the option description
+ *        into the index corresponding to an entry in the name list.
+ *        This will match the generated enumeration value.
+ *        Full matches are always accepted.  Partial matches are accepted
+ *        if there is only one partial match.
+=*/
+uintptr_t
+optionEnumerationVal(
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC * const * paz_names,
+    unsigned int  name_ct )
+{
+    uintptr_t res = 0UL;
+
+    /*
+     *  IF the program option descriptor pointer is invalid,
+     *  then it is some sort of special request.
+     */
+    switch ((uintptr_t)pOpts) {
+    case 0UL:
+        /*
+         *  print the list of enumeration names.
+         */
+        enumError( pOpts, pOD, paz_names, (int)name_ct );
+        break;
+
+    case 1UL:
+    {
+        unsigned int ix = pOD->optArg.argEnum;
+        /*
+         *  print the name string.
+         */
+        if (ix >= name_ct)
+            printf( "INVALID-%d", ix );
+        else
+            fputs( paz_names[ ix ], stdout );
+
+        break;
+    }
+
+    case 2UL:
+    {
+        tSCC zInval[] = "*INVALID*";
+        unsigned int ix = pOD->optArg.argEnum;
+        /*
+         *  Replace the enumeration value with the name string.
+         */
+        if (ix >= name_ct)
+            return (uintptr_t)zInval;
+
+        res = (uintptr_t)paz_names[ ix ];
+        break;
+    }
+
+    default:
+        res = findName( pOD->optArg.argString, pOpts, pOD, paz_names, name_ct );
+
+        if (pOD->fOptState & OPTST_ALLOC_ARG) {
+            AGFREE(pOD->optArg.argString);
+            pOD->fOptState &= ~OPTST_ALLOC_ARG;
+            pOD->optArg.argString = NULL;
+        }
+    }
+
+    return res;
+}
+
+
+/*=export_func  optionSetMembers
+ * what:  Convert between bit flag values and strings
+ * private:
+ *
+ * arg:   tOptions*,     pOpts,     the program options descriptor
+ * arg:   tOptDesc*,     pOD,       enumeration option description
+ * arg:   char const * const *,
+ *                       paz_names, list of enumeration names
+ * arg:   unsigned int,  name_ct,   number of names in list
+ *
+ * doc:   This converts the optArg.argString string from the option description
+ *        into the index corresponding to an entry in the name list.
+ *        This will match the generated enumeration value.
+ *        Full matches are always accepted.  Partial matches are accepted
+ *        if there is only one partial match.
+=*/
+void
+optionSetMembers(
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC* const *  paz_names,
+    unsigned int  name_ct )
+{
+    /*
+     *  IF the program option descriptor pointer is invalid,
+     *  then it is some sort of special request.
+     */
+    switch ((uintptr_t)pOpts) {
+    case 0UL:
+        /*
+         *  print the list of enumeration names.
+         */
+        enumError( pOpts, pOD, paz_names, (int)name_ct );
+        return;
+
+    case 1UL:
+    {
+        /*
+         *  print the name string.
+         */
+        uintptr_t bits = (uintptr_t)pOD->optCookie;
+        uintptr_t res  = 0;
+        size_t    len  = 0;
+
+        while (bits != 0) {
+            if (bits & 1) {
+                if (len++ > 0) fputs( " | ", stdout );
+                fputs( paz_names[ res ], stdout );
+            }
+            if (++res >= name_ct) break;
+            bits >>= 1;
+        }
+        return;
+    }
+
+    case 2UL:
+    {
+        char*     pz;
+        uintptr_t bits = (uintptr_t)pOD->optCookie;
+        uintptr_t res  = 0;
+        size_t    len  = 0;
+
+        /*
+         *  Replace the enumeration value with the name string.
+         *  First, determine the needed length, then allocate and fill in.
+         */
+        while (bits != 0) {
+            if (bits & 1)
+                len += strlen( paz_names[ res ]) + 8;
+            if (++res >= name_ct) break;
+            bits >>= 1;
+        }
+
+        pOD->optArg.argString = pz = AGALOC( len, "enum name" );
+
+        /*
+         *  Start by clearing all the bits.  We want to turn off any defaults
+         *  because we will be restoring to current state, not adding to
+         *  the default set of bits.
+         */
+        strcpy( pz, "none" );
+        pz += 4;
+        bits = (uintptr_t)pOD->optCookie;
+        res = 0;
+        while (bits != 0) {
+            if (bits & 1) {
+                strcpy( pz, " + " );
+                strcpy( pz+3, paz_names[ res ]);
+                pz += strlen( paz_names[ res ]) + 3;
+            }
+            if (++res >= name_ct) break;
+            bits >>= 1;
+        }
+        return;
+    }
+
+    default:
+        break;
+    }
+
+    {
+        tCC*      pzArg = pOD->optArg.argString;
+        uintptr_t res;
+        if ((pzArg == NULL) || (*pzArg == NUL)) {
+            pOD->optCookie = (void*)0;
+            return;
+        }
+
+        res = (uintptr_t)pOD->optCookie;
+        for (;;) {
+            tSCC zSpn[] = " ,|+\t\r\f\n";
+            int  iv, len;
+
+            pzArg += strspn( pzArg, zSpn );
+            iv = (*pzArg == '!');
+            if (iv)
+                pzArg += strspn( pzArg+1, zSpn ) + 1;
+
+            len = strcspn( pzArg, zSpn );
+            if (len == 0)
+                break;
+
+            if ((len == 3) && (strncmp(pzArg, zAll, (size_t)3) == 0)) {
+                if (iv)
+                     res = 0;
+                else res = ~0UL;
+            }
+            else if ((len == 4) && (strncmp(pzArg, zNone, (size_t)4) == 0)) {
+                if (! iv)
+                    res = 0;
+            }
+            else do {
+                char* pz;
+                uintptr_t bit = strtoul( pzArg, &pz, 0 );
+
+                if (pz != pzArg + len) {
+                    char z[ AO_NAME_SIZE ];
+                    tCC* p;
+                    if (*pz != NUL) {
+                        if (len >= AO_NAME_LIMIT)
+                            break;
+                        strncpy( z, pzArg, (size_t)len );
+                        z[len] = NUL;
+                        p = z;
+                    } else {
+                        p = pzArg;
+                    }
+
+                    bit = 1UL << findName(p, pOpts, pOD, paz_names, name_ct);
+                }
+                if (iv)
+                     res &= ~bit;
+                else res |= bit;
+            } while (0);
+
+            if (pzArg[len] == NUL)
+                break;
+            pzArg += len + 1;
+        }
+        if (name_ct < (8 * sizeof( uintptr_t ))) {
+            res &= (1UL << name_ct) - 1UL;
+        }
+
+        pOD->optCookie = (void*)res;
+    }
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/enumeration.c */
diff --git a/libopts/environment.c b/libopts/environment.c
new file mode 100644 (file)
index 0000000..9fb1550
--- /dev/null
@@ -0,0 +1,279 @@
+
+/*
+ *  $Id: environment.c,v 4.13 2007/04/15 19:01:18 bkorb Exp $
+ * Time-stamp:      "2007-04-15 11:50:35 bkorb"
+ *
+ *  This file contains all of the routines that must be linked into
+ *  an executable to use the generated option processing.  The optional
+ *  routines are in separately compiled modules so that they will not
+ *  necessarily be linked in.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+checkEnvOpt(tOptState * os, char * env_name,
+            tOptions* pOpts, teEnvPresetType type);
+/* = = = END-STATIC-FORWARD = = = */
+
+/*
+ *  doPrognameEnv - check for preset values from the ${PROGNAME}
+ *  environment variable.  This is accomplished by parsing the text into
+ *  tokens, temporarily replacing the arg vector and calling
+ *  doImmediateOpts and/or doRegularOpts.
+ */
+LOCAL void
+doPrognameEnv( tOptions* pOpts, teEnvPresetType type )
+{
+    char const*   pczOptStr = getenv( pOpts->pzPROGNAME );
+    token_list_t* pTL;
+    int           sv_argc;
+    tAoUI         sv_flag;
+    char**        sv_argv;
+
+    /*
+     *  IF there is no such environment variable
+     *   *or* there is, but we are doing immediate opts and there are
+     *        no immediate opts to do (--help inside $PROGNAME is silly,
+     *        but --no-load-defs is not, so that is marked)
+     *  THEN bail out now.  (
+     */
+    if (  (pczOptStr == NULL)
+       || (  (type == ENV_IMM)
+          && ((pOpts->fOptSet & OPTPROC_HAS_IMMED) == 0)  )  )
+        return;
+
+    /*
+     *  Tokenize the string.  If there's nothing of interest, we'll bail
+     *  here immediately.
+     */
+    pTL = ao_string_tokenize( pczOptStr );
+    if (pTL == NULL)
+        return;
+
+    /*
+     *  Substitute our $PROGNAME argument list for the real one
+     */
+    sv_argc = pOpts->origArgCt;
+    sv_argv = pOpts->origArgVect;
+    sv_flag = pOpts->fOptSet;
+
+    /*
+     *  We add a bogus pointer to the start of the list.  The program name
+     *  has already been pulled from "argv", so it won't get dereferenced.
+     *  The option scanning code will skip the "program name" at the start
+     *  of this list of tokens, so we accommodate this way ....
+     */
+    pOpts->origArgVect = (char**)(pTL->tkn_list - 1);
+    pOpts->origArgCt   = pTL->tkn_ct   + 1;
+    pOpts->fOptSet    &= ~OPTPROC_ERRSTOP;
+
+    pOpts->curOptIdx   = 1;
+    pOpts->pzCurOpt    = NULL;
+
+    switch (type) {
+    case ENV_IMM:
+        /*
+         *  We know the OPTPROC_HAS_IMMED bit is set.
+         */
+        (void)doImmediateOpts( pOpts );
+        break;
+
+    case ENV_NON_IMM:
+        (void)doRegularOpts( pOpts );
+        break;
+
+    default:
+        /*
+         *  Only to immediate opts if the OPTPROC_HAS_IMMED bit is set.
+         */
+        if (pOpts->fOptSet & OPTPROC_HAS_IMMED) {
+            (void)doImmediateOpts( pOpts );
+            pOpts->curOptIdx = 1;
+            pOpts->pzCurOpt  = NULL;
+        }
+        (void)doRegularOpts( pOpts );
+        break;
+    }
+
+    /*
+     *  Free up the temporary arg vector and restore the original program args.
+     */
+    free( pTL );
+    pOpts->origArgVect = sv_argv;
+    pOpts->origArgCt   = sv_argc;
+    pOpts->fOptSet     = sv_flag;
+}
+
+static void
+checkEnvOpt(tOptState * os, char * env_name,
+            tOptions* pOpts, teEnvPresetType type)
+{
+    os->pzOptArg = getenv( env_name );
+    if (os->pzOptArg == NULL)
+        return;
+
+    os->flags    = OPTST_PRESET | OPTST_ALLOC_ARG | os->pOD->fOptState;
+    os->optType  = TOPT_UNDEFINED;
+
+    if (  (os->pOD->pz_DisablePfx != NULL)
+       && (streqvcmp( os->pzOptArg, os->pOD->pz_DisablePfx ) == 0)) {
+        os->flags |= OPTST_DISABLED;
+        os->pzOptArg = NULL;
+    }
+
+    switch (type) {
+    case ENV_IMM:
+        /*
+         *  Process only immediate actions
+         */
+        if (DO_IMMEDIATELY(os->flags))
+            break;
+        return;
+
+    case ENV_NON_IMM:
+        /*
+         *  Process only NON immediate actions
+         */
+        if (DO_NORMALLY(os->flags) || DO_SECOND_TIME(os->flags))
+            break;
+        return;
+
+    default: /* process everything */
+        break;
+    }
+
+    /*
+     *  Make sure the option value string is persistent and consistent.
+     *
+     *  The interpretation of the option value depends
+     *  on the type of value argument the option takes
+     */
+    if (os->pzOptArg != NULL) {
+        if (OPTST_GET_ARGTYPE(os->pOD->fOptState) == OPARG_TYPE_NONE) {
+            os->pzOptArg = NULL;
+        } else if (  (os->pOD->fOptState & OPTST_ARG_OPTIONAL)
+                     && (*os->pzOptArg == NUL)) {
+            os->pzOptArg = NULL;
+        } else if (*os->pzOptArg == NUL) {
+            os->pzOptArg = zNil;
+        } else {
+            AGDUPSTR( os->pzOptArg, os->pzOptArg, "option argument" );
+            os->flags |= OPTST_ALLOC_ARG;
+        }
+    }
+
+    handleOption( pOpts, os );
+}
+
+/*
+ *  doEnvPresets - check for preset values from the envrionment
+ *  This routine should process in all, immediate or normal modes....
+ */
+LOCAL void
+doEnvPresets( tOptions* pOpts, teEnvPresetType type )
+{
+    int        ct;
+    tOptState  st;
+    char*      pzFlagName;
+    size_t     spaceLeft;
+    char       zEnvName[ AO_NAME_SIZE ];
+
+    /*
+     *  Finally, see if we are to look at the environment
+     *  variables for initial values.
+     */
+    if ((pOpts->fOptSet & OPTPROC_ENVIRON) == 0)
+        return;
+
+    doPrognameEnv( pOpts, type );
+
+    ct  = pOpts->presetOptCt;
+    st.pOD = pOpts->pOptDesc;
+
+    pzFlagName = zEnvName
+        + snprintf( zEnvName, sizeof( zEnvName ), "%s_", pOpts->pzPROGNAME );
+    spaceLeft = AO_NAME_SIZE - (pzFlagName - zEnvName) - 1;
+
+    for (;ct-- > 0; st.pOD++) {
+        /*
+         *  If presetting is disallowed, then skip this entry
+         */
+        if (  ((st.pOD->fOptState & OPTST_NO_INIT) != 0)
+           || (st.pOD->optEquivIndex != NO_EQUIVALENT)  )
+            continue;
+
+        /*
+         *  IF there is no such environment variable,
+         *  THEN skip this entry, too.
+         */
+        if (strlen( st.pOD->pz_NAME ) >= spaceLeft)
+            continue;
+
+        /*
+         *  Set up the option state
+         */
+        strcpy( pzFlagName, st.pOD->pz_NAME );
+        checkEnvOpt(&st, zEnvName, pOpts, type);
+    }
+
+    /*
+     *  Special handling for ${PROGNAME_LOAD_OPTS}
+     */
+    if (pOpts->specOptIdx.save_opts != 0) {
+        st.pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
+        strcpy( pzFlagName, st.pOD->pz_NAME );
+        checkEnvOpt(&st, zEnvName, pOpts, type);
+    }
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/environment.c */
diff --git a/libopts/genshell.c b/libopts/genshell.c
new file mode 100644 (file)
index 0000000..de098a5
--- /dev/null
@@ -0,0 +1,354 @@
+/*   -*- buffer-read-only: t -*- vi: set ro:
+ *  
+ *  DO NOT EDIT THIS FILE   (genshell.c)
+ *  
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:35 PM PDT
+ *  From the definitions    genshell.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This source file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  genshellopt author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved
+ *
+ * genshellopt is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * genshellopt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with genshellopt.  If not, write to:
+ *     The Free Software Foundation, Inc.,
+ *     51 Franklin Street, Fifth Floor
+ *     Boston, MA  02110-1301, USA.
+ */
+
+
+#include <limits.h>
+
+#define OPTION_CODE_COMPILE 1
+#include "genshell.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+tSCC zCopyright[] =
+       "genshellopt copyright (c) 1999-2007 Bruce Korb, all rights reserved";
+tSCC zCopyrightNotice[] =
+       "genshellopt is free software; you can redistribute it and/or\n\
+modify it under the terms of the GNU Lesser General Public\n\
+License as published by the Free Software Foundation; either\n\
+version 2.1 of the License, or (at your option) any later version.\n\n\
+genshellopt is distributed in the hope that it will be useful,\n\
+but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n\
+Lesser General Public License for more details.\n\n\
+You should have received a copy of the GNU Lesser General Public\n\
+License along with genshellopt.  If not, write to:\n\
+\tThe Free Software Foundation, Inc.,\n\
+\t51 Franklin Street, Fifth Floor\n\
+\tBoston, MA  02110-1301, USA.";
+extern tUsageProc genshelloptUsage;
+
+#ifndef NULL
+#  define NULL 0
+#endif
+#ifndef EXIT_SUCCESS
+#  define  EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#  define  EXIT_FAILURE 1
+#endif
+/*
+ *  Script option description:
+ */
+tSCC    zScriptText[] =
+        "Output Script File";
+tSCC    zScript_NAME[]             = "SCRIPT";
+tSCC    zScript_Name[]             = "script";
+#define SCRIPT_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Shell option description:
+ */
+tSCC    zShellText[] =
+        "Shell name (follows \"#!\" magic)";
+tSCC    zShell_NAME[]              = "SHELL";
+tSCC    zNotShell_Name[]           = "no-shell";
+tSCC    zNotShell_Pfx[]            = "no";
+#define zShell_Name                  (zNotShell_Name + 3)
+#define SHELL_FLAGS       (OPTST_INITENABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Help/More_Help/Version option descriptions:
+ */
+tSCC zHelpText[]       = "Display usage information and exit";
+tSCC zHelp_Name[]      = "help";
+
+tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
+tSCC zMore_Help_Name[] = "more-help";
+
+tSCC zVersionText[]    = "Output version information and exit";
+tSCC zVersion_Name[]   = "version";
+/*
+ *  Declare option callback procedures
+ */
+extern tOptProc
+    optionPagedUsage, optionPrintVersion;
+static tOptProc
+    doUsageOpt;
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Genshellopt Option Descriptions.
+ */
+static tOptDesc optDesc[ OPTION_CT ] = {
+  {  /* entry idx, value */ 0, VALUE_OPT_SCRIPT,
+     /* equiv idx, value */ 0, VALUE_OPT_SCRIPT,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SCRIPT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zScriptText, zScript_NAME, zScript_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 1, VALUE_OPT_SHELL,
+     /* equiv idx, value */ 1, VALUE_OPT_SHELL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SHELL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zShellText, zShell_NAME, zShell_Name,
+     /* disablement strs */ zNotShell_Name, zNotShell_Pfx },
+
+#ifdef NO_OPTIONAL_OPT_ARGS
+#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
+#else
+#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
+                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
+#endif
+
+  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionPrintVersion,
+     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
+     /* disablement strs */ NULL, NULL },
+
+#undef VERSION_OPT_FLAGS
+
+
+  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doUsageOpt,
+     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ optionPagedUsage,
+     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
+     /* disablement strs */ NULL, NULL }
+};
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Genshellopt Option Environment
+ */
+tSCC   zPROGNAME[]   = "GENSHELLOPT";
+tSCC   zUsageTitle[] =
+"genshellopt - Generate Shell Option Processing Script - Ver. 1\n\
+USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
+#define zRcName     NULL
+#define apzHomeList NULL
+
+tSCC   zBugsAddr[]    = "autogen-users@lists.sourceforge.net";
+tSCC   zExplain[]     = "\n\
+Note that `shell' is only useful if the output file does not already\n\
+exist.  If it does, then the shell name and optional first argument\n\
+will be extracted from the script file.\n";
+tSCC    zDetail[]     = "\n\
+If the script file already exists and contains Automated Option Processing\n\
+text, the second line of the file through the ending tag will be replaced\n\
+by the newly generated text.  The first `#!' line will be regenerated.\n";
+tSCC    zFullVersion[] = GENSHELLOPT_FULL_VERSION;
+/* extracted from optcode.tpl near line 408 */
+
+#if defined(ENABLE_NLS)
+# define OPTPROC_BASE OPTPROC_TRANSLATE
+  static tOptionXlateProc translate_option_strings;
+#else
+# define OPTPROC_BASE OPTPROC_NONE
+# define translate_option_strings NULL
+#endif /* ENABLE_NLS */
+
+tOptions genshelloptOptions = {
+    OPTIONS_STRUCT_VERSION,
+    0, NULL,                    /* original argc + argv    */
+    ( OPTPROC_BASE
+    + OPTPROC_ERRSTOP
+    + OPTPROC_SHORTOPT
+    + OPTPROC_LONGOPT
+    + OPTPROC_NO_REQ_OPT
+    + OPTPROC_NEGATIONS
+    + OPTPROC_NO_ARGS ),
+    0, NULL,                    /* current option index, current option */
+    NULL,         NULL,         zPROGNAME,
+    zRcName,      zCopyright,   zCopyrightNotice,
+    zFullVersion, apzHomeList,  zUsageTitle,
+    zExplain,     zDetail,      optDesc,
+    zBugsAddr,                  /* address to send bugs to */
+    NULL, NULL,                 /* extensions/saved state  */
+    genshelloptUsage,       /* usage procedure */
+    translate_option_strings,   /* translation procedure */
+    /*
+     *  Indexes to special options
+     */
+    { INDEX_OPT_MORE_HELP,
+       0 /* no option state saving */,
+      NO_EQUIVALENT /* index of '-#' option */,
+      NO_EQUIVALENT /* index of default opt */
+    },
+    5 /* full option count */, 2 /* user option count */
+};
+
+/*
+ *  Create the static procedure(s) declared above.
+ */
+static void
+doUsageOpt(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    USAGE( EXIT_SUCCESS );
+}
+/* extracted from optcode.tpl near line 514 */
+
+#if ENABLE_NLS
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <autoopts/usage-txt.h>
+
+static char* AO_gettext( char const* pz );
+static void  coerce_it(void** s);
+
+static char*
+AO_gettext( char const* pz )
+{
+    char* pzRes;
+    if (pz == NULL)
+        return NULL;
+    pzRes = _(pz);
+    if (pzRes == pz)
+        return pzRes;
+    pzRes = strdup( pzRes );
+    if (pzRes == NULL) {
+        fputs( _("No memory for duping translated strings\n"), stderr );
+        exit( EXIT_FAILURE );
+    }
+    return pzRes;
+}
+
+static void coerce_it(void** s) { *s = AO_gettext(*s); }
+#define COERSION(_f) \
+  coerce_it((void*)&(genshelloptOptions._f))
+
+/*
+ *  This invokes the translation code (e.g. gettext(3)).
+ */
+static void
+translate_option_strings( void )
+{
+    /*
+     *  Guard against re-translation.  It won't work.  The strings will have
+     *  been changed by the first pass through this code.  One shot only.
+     */
+    if (option_usage_text.field_ct == 0)
+        return;
+    /*
+     *  Do the translations.  The first pointer follows the field count field.
+     *  The field count field is the size of a pointer.
+     */
+    {
+        char** ppz = (char**)(void*)&(option_usage_text);
+        int    ix  = option_usage_text.field_ct;
+
+        do {
+            ppz++;
+            *ppz = AO_gettext(*ppz);
+        } while (--ix > 0);
+    }
+    option_usage_text.field_ct = 0;
+
+    {
+        tOptDesc* pOD = genshelloptOptions.pOptDesc;
+        int       ix  = genshelloptOptions.optCt;
+
+        for (;;) {
+            pOD->pzText           = AO_gettext(pOD->pzText);
+            pOD->pz_NAME          = AO_gettext(pOD->pz_NAME);
+            pOD->pz_Name          = AO_gettext(pOD->pz_Name);
+            pOD->pz_DisableName   = AO_gettext(pOD->pz_DisableName);
+            pOD->pz_DisablePfx    = AO_gettext(pOD->pz_DisablePfx);
+            if (--ix <= 0)
+                break;
+            pOD++;
+        }
+    }
+    COERSION(pzCopyright);
+    COERSION(pzCopyNotice);
+    COERSION(pzFullVersion);
+    COERSION(pzUsageTitle);
+    COERSION(pzExplain);
+    COERSION(pzDetail);
+}
+
+#endif /* ENABLE_NLS */
+
+#ifdef  __cplusplus
+}
+#endif
+/* genshell.c ends here */
diff --git a/libopts/genshell.h b/libopts/genshell.h
new file mode 100644 (file)
index 0000000..b57677d
--- /dev/null
@@ -0,0 +1,149 @@
+/*   -*- buffer-read-only: t -*- vi: set ro:
+ *  
+ *  DO NOT EDIT THIS FILE   (genshell.h)
+ *  
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:35 PM PDT
+ *  From the definitions    genshell.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This header file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  genshellopt author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved
+ *
+ * genshellopt is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * genshellopt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with genshellopt.  If not, write to:
+ *     The Free Software Foundation, Inc.,
+ *     51 Franklin Street, Fifth Floor
+ *     Boston, MA  02110-1301, USA.
+ */
+/*
+ *  This file contains the programmatic interface to the Automated
+ *  Options generated for the genshellopt program.
+ *  These macros are documented in the AutoGen info file in the
+ *  "AutoOpts" chapter.  Please refer to that doc for usage help.
+ */
+#ifndef AUTOOPTS_GENSHELL_H_GUARD
+#define AUTOOPTS_GENSHELL_H_GUARD
+#include <autoopts/options.h>
+
+/*
+ *  Ensure that the library used for compiling this generated header is at
+ *  least as new as the version current when the header template was released
+ *  (not counting patch version increments).  Also ensure that the oldest
+ *  tolerable version is at least as old as what was current when the header
+ *  template was released.
+ */
+#define AO_TEMPLATE_VERSION 118784
+#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
+ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
+# error option template version mismatches autoopts/options.h header
+  Choke Me.
+#endif
+
+/*
+ *  Enumeration of each option:
+ */
+typedef enum {
+        INDEX_OPT_SCRIPT           =  0,
+        INDEX_OPT_SHELL            =  1,
+        INDEX_OPT_VERSION          = 2,
+        INDEX_OPT_HELP             = 3,
+        INDEX_OPT_MORE_HELP        = 4
+} teOptIndex;
+
+#define OPTION_CT    5
+#define GENSHELLOPT_VERSION       "1"
+#define GENSHELLOPT_FULL_VERSION  "genshellopt - Generate Shell Option Processing Script - Ver. 1"
+
+/*
+ *  Interface defines for all options.  Replace "n" with the UPPER_CASED
+ *  option name (as in the teOptIndex enumeration above).
+ *  e.g. HAVE_OPT( SCRIPT )
+ */
+#define         DESC(n) (genshelloptOptions.pOptDesc[INDEX_OPT_## n])
+#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
+#define      OPT_ARG(n) (DESC(n).optArg.argString)
+#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
+#define    COUNT_OPT(n) (DESC(n).optOccCt)
+#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
+#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
+#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
+#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
+#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
+#define    CLEAR_OPT(n) STMTS( \
+                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
+                if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
+                    DESC(n).fOptState |= OPTST_DISABLED; \
+                DESC(n).optCookie = NULL )
+
+/*
+ *  Interface defines for specific options.
+ */
+#define VALUE_OPT_SCRIPT         'o'
+#define VALUE_OPT_SHELL          's'
+
+#define VALUE_OPT_VERSION       'v'
+#define VALUE_OPT_HELP          '?'
+#define VALUE_OPT_MORE_HELP     '!'
+/*
+ *  Interface defines not associated with particular options
+ */
+#define ERRSKIP_OPTERR  STMTS( genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP )
+#define ERRSTOP_OPTERR  STMTS( genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP )
+#define RESTART_OPT(n)  STMTS( \
+                genshelloptOptions.curOptIdx = (n); \
+                genshelloptOptions.pzCurOpt  = NULL )
+#define START_OPT       RESTART_OPT(1)
+#define USAGE(c)        (*genshelloptOptions.pUsageProc)( &genshelloptOptions, c )
+/* extracted from opthead.tpl near line 360 */
+
+/* * * * * *
+ *
+ *  Declare the genshellopt option descriptor.
+ */
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+extern tOptions   genshelloptOptions;
+
+#ifndef _
+#  if ENABLE_NLS
+#    include <stdio.h>
+     static inline char* aoGetsText( char const* pz ) {
+         if (pz == NULL) return NULL;
+         return (char*)gettext( pz );
+     }
+#    define _(s)  aoGetsText(s)
+#  else  /* ENABLE_NLS */
+#    define _(s)  s
+#  endif /* ENABLE_NLS */
+#endif
+
+#ifdef  __cplusplus
+}
+#endif
+#endif /* AUTOOPTS_GENSHELL_H_GUARD */
+/* genshell.h ends here */
diff --git a/libopts/libopts.c b/libopts/libopts.c
new file mode 100644 (file)
index 0000000..feb7557
--- /dev/null
@@ -0,0 +1,30 @@
+#define AUTOOPTS_INTERNAL
+#include "compat/compat.h"
+#define LOCAL static
+#include "autoopts/options.h"
+#include "autoopts/usage-txt.h"
+#include "genshell.h"
+#include "autoopts.h"
+#include "proto.h"
+#include "autoopts.c"
+#include "boolean.c"
+#include "configfile.c"
+#include "cook.c"
+#include "enumeration.c"
+#include "environment.c"
+#include "genshell.c"
+#include "load.c"
+#include "makeshell.c"
+#include "nested.c"
+#include "numeric.c"
+#include "pgusage.c"
+#include "putshell.c"
+#include "restore.c"
+#include "save.c"
+#include "sort.c"
+#include "stack.c"
+#include "streqvcmp.c"
+#include "text_mmap.c"
+#include "tokenize.c"
+#include "usage.c"
+#include "version.c"
diff --git a/libopts/load.c b/libopts/load.c
new file mode 100644 (file)
index 0000000..eeeb125
--- /dev/null
@@ -0,0 +1,563 @@
+
+/*
+ *  $Id: load.c,v 4.20 2007/02/04 22:17:39 bkorb Exp $
+ *  Time-stamp:      "2007-02-04 11:54:57 bkorb"
+ *
+ *  This file contains the routines that deal with processing text strings
+ *  for options, either from a NUL-terminated string passed in or from an
+ *  rc/ini file.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+tOptionLoadMode option_load_mode = OPTION_LOAD_UNCOOKED;
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static ag_bool
+insertProgramPath(
+    char*   pzBuf,
+    int     bufSize,
+    tCC*    pzName,
+    tCC*    pzProgPath );
+
+static ag_bool
+insertEnvVal(
+    char*   pzBuf,
+    int     bufSize,
+    tCC*    pzName,
+    tCC*    pzProgPath );
+
+static char*
+assembleArgValue( char* pzTxt, tOptionLoadMode mode );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*=export_func  optionMakePath
+ * private:
+ *
+ * what:  translate and construct a path
+ * arg:   + char*       + pzBuf      + The result buffer +
+ * arg:   + int         + bufSize    + The size of this buffer +
+ * arg:   + char const* + pzName     + The input name +
+ * arg:   + char const* + pzProgPath + The full path of the current program +
+ *
+ * ret-type: ag_bool
+ * ret-desc: AG_TRUE if the name was handled, otherwise AG_FALSE.
+ *           If the name does not start with ``$'', then it is handled
+ *           simply by copying the input name to the output buffer and
+ *           resolving the name with either @code{canonicalize_file_name(3GLIBC)}
+ *           or @code{realpath(3C)}.
+ *
+ * doc:
+ *
+ *  This routine will copy the @code{pzName} input name into the @code{pzBuf}
+ *  output buffer, carefully not exceeding @code{bufSize} bytes.  If the
+ *  first character of the input name is a @code{'$'} character, then there
+ *  is special handling:
+ *  @*
+ *  @code{$$} is replaced with the directory name of the @code{pzProgPath},
+ *  searching @code{$PATH} if necessary.
+ *  @*
+ *  @code{$@} is replaced with the AutoGen package data installation directory
+ *  (aka @code{pkgdatadir}).
+ *  @*
+ *  @code{$NAME} is replaced by the contents of the @code{NAME} environment
+ *  variable.  If not found, the search fails.
+ *
+ *  Please note: both @code{$$} and @code{$NAME} must be at the start of the
+ *     @code{pzName} string and must either be the entire string or be followed
+ *     by the @code{'/'} (backslash on windows) character.
+ *
+ * err:  @code{AG_FALSE} is returned if:
+ *       @*
+ *       @bullet{} The input name exceeds @code{bufSize} bytes.
+ *       @*
+ *       @bullet{} @code{$$}, @code{$@@} or @code{$NAME} is not the full string
+ *                 and the next character is not '/'.
+ *       @*
+ *       @bullet{} libopts was built without PKGDATADIR defined and @code{$@@}
+ *                 was specified.
+ *       @*
+ *       @bullet{} @code{NAME} is not a known environment variable
+ *       @*
+ *       @bullet{} @code{canonicalize_file_name} or @code{realpath} return
+ *                 errors (cannot resolve the resulting path).
+=*/
+ag_bool
+optionMakePath(
+    char*   pzBuf,
+    int     bufSize,
+    tCC*    pzName,
+    tCC*    pzProgPath )
+{
+    size_t  name_len = strlen( pzName );
+
+#   ifndef PKGDATADIR
+#     define PKGDATADIR ""
+#   endif
+
+    tSCC    pkgdatadir[] = PKGDATADIR;
+
+    ag_bool res = AG_TRUE;
+
+    if (bufSize <= name_len)
+        return AG_FALSE;
+
+    /*
+     *  IF not an environment variable, just copy the data
+     */
+    if (*pzName != '$') {
+        tCC*  pzS = pzName;
+        char* pzD = pzBuf;
+        int   ct  = bufSize;
+
+        for (;;) {
+            if ( (*(pzD++) = *(pzS++)) == NUL)
+                break;
+            if (--ct <= 0)
+                return AG_FALSE;
+        }
+    }
+
+    /*
+     *  IF the name starts with "$$", then it must be "$$" or
+     *  it must start with "$$/".  In either event, replace the "$$"
+     *  with the path to the executable and append a "/" character.
+     */
+    else switch (pzName[1]) {
+    case NUL:
+        return AG_FALSE;
+
+    case '$':
+        res = insertProgramPath( pzBuf, bufSize, pzName, pzProgPath );
+        break;
+
+    case '@':
+        if (pkgdatadir[0] == NUL)
+            return AG_FALSE;
+
+        if (name_len + sizeof (pkgdatadir) > bufSize)
+            return AG_FALSE;
+
+        strcpy(pzBuf, pkgdatadir);
+        strcpy(pzBuf + sizeof(pkgdatadir) - 1, pzName + 2);
+        break;
+
+    default:
+        res = insertEnvVal( pzBuf, bufSize, pzName, pzProgPath );
+    }
+
+    if (! res)
+        return AG_FALSE;
+
+#if defined(HAVE_CANONICALIZE_FILE_NAME)
+    {
+        char* pz = canonicalize_file_name(pzBuf);
+        if (pz == NULL)
+            return AG_FALSE;
+        if (strlen(pz) < bufSize)
+            strcpy(pzBuf, pz);
+        free(pz);
+    }
+
+#elif defined(HAVE_REALPATH)
+    {
+        char z[ PATH_MAX+1 ];
+
+        if (realpath( pzBuf, z ) == NULL)
+            return AG_FALSE;
+
+        if (strlen(z) < bufSize)
+            strcpy( pzBuf, z );
+    }
+#endif
+
+    return AG_TRUE;
+}
+
+
+static ag_bool
+insertProgramPath(
+    char*   pzBuf,
+    int     bufSize,
+    tCC*    pzName,
+    tCC*    pzProgPath )
+{
+    tCC*    pzPath;
+    tCC*    pz;
+    int     skip = 2;
+
+    switch (pzName[2]) {
+    case DIRCH:
+        skip = 3;
+    case NUL:
+        break;
+    default:
+        return AG_FALSE;
+    }
+
+    /*
+     *  See if the path is included in the program name.
+     *  If it is, we're done.  Otherwise, we have to hunt
+     *  for the program using "pathfind".
+     */
+    if (strchr( pzProgPath, DIRCH ) != NULL)
+        pzPath = pzProgPath;
+    else {
+        pzPath = pathfind( getenv( "PATH" ), (char*)pzProgPath, "rx" );
+
+        if (pzPath == NULL)
+            return AG_FALSE;
+    }
+
+    pz = strrchr( pzPath, DIRCH );
+
+    /*
+     *  IF we cannot find a directory name separator,
+     *  THEN we do not have a path name to our executable file.
+     */
+    if (pz == NULL)
+        return AG_FALSE;
+
+    pzName += skip;
+
+    /*
+     *  Concatenate the file name to the end of the executable path.
+     *  The result may be either a file or a directory.
+     */
+    if ((pz - pzPath)+1 + strlen(pzName) >= bufSize)
+        return AG_FALSE;
+
+    memcpy( pzBuf, pzPath, (size_t)((pz - pzPath)+1) );
+    strcpy( pzBuf + (pz - pzPath) + 1, pzName );
+
+    /*
+     *  If the "pzPath" path was gotten from "pathfind()", then it was
+     *  allocated and we need to deallocate it.
+     */
+    if (pzPath != pzProgPath)
+        free( (void*)pzPath );
+    return AG_TRUE;
+}
+
+
+static ag_bool
+insertEnvVal(
+    char*   pzBuf,
+    int     bufSize,
+    tCC*    pzName,
+    tCC*    pzProgPath )
+{
+    char* pzDir = pzBuf;
+
+    for (;;) {
+        int ch = (int)*++pzName;
+        if (! ISNAMECHAR( ch ))
+            break;
+        *(pzDir++) = (char)ch;
+    }
+
+    if (pzDir == pzBuf)
+        return AG_FALSE;
+
+    *pzDir = NUL;
+
+    pzDir = getenv( pzBuf );
+
+    /*
+     *  Environment value not found -- skip the home list entry
+     */
+    if (pzDir == NULL)
+        return AG_FALSE;
+
+    if (strlen( pzDir ) + 1 + strlen( pzName ) >= bufSize)
+        return AG_FALSE;
+
+    sprintf( pzBuf, "%s%s", pzDir, pzName );
+    return AG_TRUE;
+}
+
+
+LOCAL void
+mungeString( char* pzTxt, tOptionLoadMode mode )
+{
+    char* pzE;
+
+    if (mode == OPTION_LOAD_KEEP)
+        return;
+
+    if (isspace( (int)*pzTxt )) {
+        char* pzS = pzTxt;
+        char* pzD = pzTxt;
+        while (isspace( (int)*++pzS ))  ;
+        while ((*(pzD++) = *(pzS++)) != NUL)   ;
+        pzE = pzD-1;
+    } else
+        pzE = pzTxt + strlen( pzTxt );
+
+    while ((pzE > pzTxt) && isspace( (int)pzE[-1] ))  pzE--;
+    *pzE = NUL;
+
+    if (mode == OPTION_LOAD_UNCOOKED)
+        return;
+
+    switch (*pzTxt) {
+    default: return;
+    case '"':
+    case '\'': break;
+    }
+
+    switch (pzE[-1]) {
+    default: return;
+    case '"':
+    case '\'': break;
+    }
+
+    (void)ao_string_cook( pzTxt, NULL );
+}
+
+
+static char*
+assembleArgValue( char* pzTxt, tOptionLoadMode mode )
+{
+    tSCC zBrk[] = " \t:=";
+    char* pzEnd = strpbrk( pzTxt, zBrk );
+    int   space_break;
+
+    /*
+     *  Not having an argument to a configurable name is okay.
+     */
+    if (pzEnd == NULL)
+        return pzTxt + strlen(pzTxt);
+
+    /*
+     *  If we are keeping all whitespace, then the  modevalue starts with the
+     *  character that follows the end of the configurable name, regardless
+     *  of which character caused it.
+     */
+    if (mode == OPTION_LOAD_KEEP) {
+        *(pzEnd++) = NUL;
+        return pzEnd;
+    }
+
+    /*
+     *  If the name ended on a white space character, remember that
+     *  because we'll have to skip over an immediately following ':' or '='
+     *  (and the white space following *that*).
+     */
+    space_break = isspace((int)*pzEnd);
+    *(pzEnd++) = NUL;
+    while (isspace((int)*pzEnd))  pzEnd++;
+    if (space_break && ((*pzEnd == ':') || (*pzEnd == '=')))
+        while (isspace((int)*++pzEnd))  ;
+
+    return pzEnd;
+}
+
+
+/*
+ *  Load an option from a block of text.  The text must start with the
+ *  configurable/option name and be followed by its associated value.
+ *  That value may be processed in any of several ways.  See "tOptionLoadMode"
+ *  in autoopts.h.
+ */
+LOCAL void
+loadOptionLine(
+    tOptions*   pOpts,
+    tOptState*  pOS,
+    char*       pzLine,
+    tDirection  direction,
+    tOptionLoadMode   load_mode )
+{
+    while (isspace( (int)*pzLine ))  pzLine++;
+
+    {
+        char* pzArg = assembleArgValue( pzLine, load_mode );
+
+        if (! SUCCESSFUL( longOptionFind( pOpts, pzLine, pOS )))
+            return;
+        if (pOS->flags & OPTST_NO_INIT)
+            return;
+        pOS->pzOptArg = pzArg;
+    }
+
+    switch (pOS->flags & (OPTST_IMM|OPTST_DISABLE_IMM)) {
+    case 0:
+        /*
+         *  The selected option has no immediate action.
+         *  THEREFORE, if the direction is PRESETTING
+         *  THEN we skip this option.
+         */
+        if (PRESETTING(direction))
+            return;
+        break;
+
+    case OPTST_IMM:
+        if (PRESETTING(direction)) {
+            /*
+             *  We are in the presetting direction with an option we handle
+             *  immediately for enablement, but normally for disablement.
+             *  Therefore, skip if disabled.
+             */
+            if ((pOS->flags & OPTST_DISABLED) == 0)
+                return;
+        } else {
+            /*
+             *  We are in the processing direction with an option we handle
+             *  immediately for enablement, but normally for disablement.
+             *  Therefore, skip if NOT disabled.
+             */
+            if ((pOS->flags & OPTST_DISABLED) != 0)
+                return;
+        }
+        break;
+
+    case OPTST_DISABLE_IMM:
+        if (PRESETTING(direction)) {
+            /*
+             *  We are in the presetting direction with an option we handle
+             *  immediately for disablement, but normally for disablement.
+             *  Therefore, skip if NOT disabled.
+             */
+            if ((pOS->flags & OPTST_DISABLED) != 0)
+                return;
+        } else {
+            /*
+             *  We are in the processing direction with an option we handle
+             *  immediately for disablement, but normally for disablement.
+             *  Therefore, skip if disabled.
+             */
+            if ((pOS->flags & OPTST_DISABLED) == 0)
+                return;
+        }
+        break;
+
+    case OPTST_IMM|OPTST_DISABLE_IMM:
+        /*
+         *  The selected option is always for immediate action.
+         *  THEREFORE, if the direction is PROCESSING
+         *  THEN we skip this option.
+         */
+        if (PROCESSING(direction))
+            return;
+        break;
+    }
+
+    /*
+     *  Fix up the args.
+     */
+    if (OPTST_GET_ARGTYPE(pOS->pOD->fOptState) == OPARG_TYPE_NONE) {
+        if (*pOS->pzOptArg != NUL)
+            return;
+        pOS->pzOptArg = NULL;
+
+    } else if (pOS->pOD->fOptState & OPTST_ARG_OPTIONAL) {
+        if (*pOS->pzOptArg == NUL)
+             pOS->pzOptArg = NULL;
+        else {
+            AGDUPSTR( pOS->pzOptArg, pOS->pzOptArg, "option argument" );
+            pOS->flags |= OPTST_ALLOC_ARG;
+        }
+
+    } else {
+        if (*pOS->pzOptArg == NUL)
+             pOS->pzOptArg = zNil;
+        else {
+            AGDUPSTR( pOS->pzOptArg, pOS->pzOptArg, "option argument" );
+            pOS->flags |= OPTST_ALLOC_ARG;
+        }
+    }
+
+    {
+        tOptionLoadMode sv = option_load_mode;
+        option_load_mode = load_mode;
+        handleOption( pOpts, pOS );
+        option_load_mode = sv;
+    }
+}
+
+
+/*=export_func  optionLoadLine
+ *
+ * what:  process a string for an option name and value
+ *
+ * arg:   tOptions*,   pOpts,  program options descriptor
+ * arg:   char const*, pzLine, NUL-terminated text
+ *
+ * doc:
+ *
+ *  This is a client program callable routine for setting options from, for
+ *  example, the contents of a file that they read in.  Only one option may
+ *  appear in the text.  It will be treated as a normal (non-preset) option.
+ *
+ *  When passed a pointer to the option struct and a string, it will find
+ *  the option named by the first token on the string and set the option
+ *  argument to the remainder of the string.  The caller must NUL terminate
+ *  the string.  Any embedded new lines will be included in the option
+ *  argument.  If the input looks like one or more quoted strings, then the
+ *  input will be "cooked".  The "cooking" is identical to the string
+ *  formation used in AutoGen definition files (@pxref{basic expression}),
+ *  except that you may not use backquotes.
+ *
+ * err:   Invalid options are silently ignored.  Invalid option arguments
+ *        will cause a warning to print, but the function should return.
+=*/
+void
+optionLoadLine(
+    tOptions*  pOpts,
+    tCC*       pzLine )
+{
+    tOptState st = OPTSTATE_INITIALIZER(SET);
+    char* pz;
+    AGDUPSTR( pz, pzLine, "user option line" );
+    loadOptionLine( pOpts, &st, pz, DIRECTION_PROCESS, OPTION_LOAD_COOKED );
+    AGFREE( pz );
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/load.c */
diff --git a/libopts/m4/libopts.m4 b/libopts/m4/libopts.m4
new file mode 100644 (file)
index 0000000..adc3235
--- /dev/null
@@ -0,0 +1,509 @@
+dnl  -*- buffer-read-only: t -*- vi: set ro:
+dnl 
+dnl DO NOT EDIT THIS FILE   (libopts.m4)
+dnl 
+dnl It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:37 PM PDT
+dnl From the definitions    libopts.def
+dnl and the template file   conftest.tpl
+dnl
+dnl do always before generated macros:
+dnl
+AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
+[if test X${INVOKE_LIBOPTS_MACROS_FIRST_done} != Xyes ; then]
+  # =================
+  # AC_HEADER_STDC
+  # =================
+  AC_HEADER_STDC
+  # =================
+  # AC_HEADER_DIRENT
+  # =================
+  AC_HEADER_DIRENT
+  
+  # =================
+  # AC_CHECK_HEADERS
+  # =================
+  AC_CHECK_HEADERS(dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \
+    setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \
+    sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h    \
+    utime.h sysexits.h)
+  
+  # --------------------------------------------
+  # Verify certain entries from AC_CHECK_HEADERS
+  # --------------------------------------------
+  [for f in sys_types sys_mman sys_param sys_stat sys_wait \
+           string errno stdlib memory setjmp
+  do eval as_ac_var=\${ac_cv_header_${f}_h+set}
+     test "${as_ac_var}" = set] || \
+       AC_MSG_ERROR([You must have ${f}.h on your system])
+  done
+  
+  # ================================================
+  # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise
+  # if varargs.h is present define HAVE_VARARGS_H.
+  # ================================================
+  AC_CHECK_HEADERS(stdarg.h varargs.h, break)
+  [if test `eval echo '${'$as_ac_Header'}'` != yes; then]
+    AC_MSG_ERROR([You must have stdarg.h or varargs.h on your system])
+  fi
+  
+  # ================================================
+  # Similarly for the string.h and strings.h headers
+  # ================================================
+  AC_CHECK_HEADERS(string.h strings.h, break)
+  [if test `eval echo '${'$as_ac_Header'}'` != yes; then]
+    AC_MSG_ERROR([You must have string.h or strings.h on your system])
+  fi
+  
+  # =====================
+  # ...and limits headers
+  # =====================
+  AC_CHECK_HEADERS(limits.h sys/limits.h values.h, break)
+  [if test `eval echo '${'$as_ac_Header'}'` != yes; then]
+    AC_MSG_ERROR([You must have one of limits.h, sys/limits.h or values.h])
+  fi
+  
+  # ========================
+  # ...and int types headers
+  # ========================
+  AC_CHECK_HEADERS(stdint.h inttypes.h, break)
+  AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
+     intptr_t, uint_t])
+  
+  # ====================
+  # uintptr type & sizes
+  # ====================
+  AC_CHECK_TYPES([uintptr_t], ,
+         [AC_DEFINE([uintptr_t], unsigned long,
+                    [Alternate uintptr_t for systems without it.])])
+  AC_CHECK_SIZEOF(char*, 4)
+  AC_CHECK_SIZEOF(int,   4)
+  AC_CHECK_SIZEOF(long,  4)
+  AC_CHECK_SIZEOF(short, 2)
+  
+  # ----------------------------------------------------------------------
+  # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind.
+  # ----------------------------------------------------------------------
+  AC_CHECK_LIB(gen, pathfind)
+  AC_FUNC_VPRINTF
+  AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr strrchr])
+[  INVOKE_LIBOPTS_MACROS_FIRST_done=yes
+fi]])
+
+dnl
+dnl @synopsis  INVOKE_LIBOPTS_MACROS
+dnl
+dnl  This macro will invoke the AutoConf macros specified in libopts.def
+dnl  that have not been disabled with "omit-invocation".
+dnl
+AC_DEFUN([LIBOPTS_WITH_REGEX_HEADER],[
+  AC_ARG_WITH([regex-header],
+    AC_HELP_STRING([--with-regex-header], [a reg expr header is specified]),
+    [libopts_cv_with_regex_header=${with_regex_header}],
+    AC_CACHE_CHECK([whether a reg expr header is specified], libopts_cv_with_regex_header,
+      libopts_cv_with_regex_header=no)
+  ) # end of AC_ARG_WITH
+
+  if test "X${libopts_cv_with_regex_header}" != Xno
+  then
+    AC_DEFINE_UNQUOTED([REGEX_HEADER],[<${libopts_cv_with_regex_header}>])
+  else
+    AC_DEFINE([REGEX_HEADER],[<regex.h>],[name of regex header file])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_WITH_REGEX_HEADER
+
+
+AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[
+  AC_ARG_WITH([libregex],
+    AC_HELP_STRING([--with-libregex], [libregex installation prefix]),
+    [libopts_cv_with_libregex_root=${with_libregex}],
+    AC_CACHE_CHECK([whether with-libregex was specified], libopts_cv_with_libregex_root,
+      libopts_cv_with_libregex_root=no)
+  ) # end of AC_ARG_WITH libregex
+
+  if test "${with_libguile+set}" = set && \
+     test "${withval}" = no
+  then ## disabled by request
+    libopts_cv_with_libregex_root=no
+    libopts_cv_with_libregex_cflags=no
+    libopts_cv_with_libregex_libs=no
+  else
+
+  AC_ARG_WITH([libregex-cflags],
+    AC_HELP_STRING([--with-libregex-cflags], [libregex compile flags]),
+    [libopts_cv_with_libregex_cflags=${with_regex_cflags}],
+    AC_CACHE_CHECK([whether with-libregex-cflags was specified], libopts_cv_with_libregex_cflags,
+      libopts_cv_with_libregex_cflags=no)
+  ) # end of AC_ARG_WITH libregex-cflags
+
+  AC_ARG_WITH([libregex-libs],
+    AC_HELP_STRING([--with-libregex-libs], [libregex link command arguments]),
+    [libopts_cv_with_libregex_libs=${with_regex_libs}],
+    AC_CACHE_CHECK([whether with-libregex-libs was specified], libopts_cv_with_libregex_libs,
+      libopts_cv_with_libregex_libs=no)
+  ) # end of AC_ARG_WITH libregex-libs
+
+  case "X${libopts_cv_with_libregex_cflags}" in
+  Xyes|Xno|X )
+    case "X${libopts_cv_with_libregex_root}" in
+    Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
+    * )        libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
+    esac
+  esac
+  case "X${libopts_cv_with_libregex_libs}" in
+  Xyes|Xno|X )
+    case "X${libopts_cv_with_libregex_root}" in
+    Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
+    * )        libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex";;
+    esac
+  esac
+  libopts_save_CPPFLAGS="${CPPFLAGS}"
+  libopts_save_LIBS="${LIBS}"
+  fi ## disabled by request
+
+  case "X${libopts_cv_with_libregex_cflags}" in
+  Xyes|Xno|X )
+    libopts_cv_with_libregex_cflags="" ;;
+  * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
+  esac
+  case "X${libopts_cv_with_libregex_libs}" in
+  Xyes|Xno|X )
+    libopts_cv_with_libregex_libs="" ;;
+  * )
+    LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
+  esac
+  LIBREGEX_CFLAGS=""
+  LIBREGEX_LIBS=""
+  AC_MSG_CHECKING([whether libregex functions properly])
+  AC_CACHE_VAL([libopts_cv_with_libregex],[
+  AC_TRY_RUN([@%:@include <stdio.h>
+@%:@include <stdlib.h>
+@%:@include <sys/types.h>
+@%:@include REGEX_HEADER
+static regex_t re;
+void comp_re( char const* pzPat ) {
+  int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
+  if (res == 0) return;
+  exit( res ); }
+int main() {
+  regmatch_t m@<:@2@:>@;
+  comp_re( "^.*\@S|@"   );
+  comp_re( "()|no.*" );
+  comp_re( "."       );
+  if (regexec( &re, "X", 2, m, 0 ) != 0)  return 1;
+  if ((m@<:@0@:>@.rm_so != 0) || (m@<:@0@:>@.rm_eo != 1)) {
+    fputs( "error: regex -->.<-- did not match\n", stderr );
+    return 1;
+  }
+  return 0; }],
+    [libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
+    [libopts_cv_with_libregex=no]) # end of AC_TRY_RUN 
+  ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
+  AC_MSG_RESULT([${libopts_cv_with_libregex}])
+
+  if test "X${libopts_cv_with_libregex}" != Xno
+  then
+    AC_DEFINE([WITH_LIBREGEX],[1],
+        [Define this if a working libregex can be found])
+  else
+    CPPFLAGS="${libopts_save_CPPFLAGS}"
+    LIBS="${libopts_save_LIBS}"
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_WITHLIB_REGEX
+
+
+AC_DEFUN([LIBOPTS_RUN_PATHFIND],[
+  AC_MSG_CHECKING([whether pathfind(3) works])
+  AC_CACHE_VAL([libopts_cv_run_pathfind],[
+  AC_TRY_RUN([@%:@include <string.h>
+@%:@include <stdlib.h>
+int main (int argc, char** argv) {
+   char* pz = pathfind( getenv( "PATH" ), "sh", "x" );
+   return (pz == 0) ? 1 : 0;
+}],
+    [libopts_cv_run_pathfind=yes],[libopts_cv_run_pathfind=no],[libopts_cv_run_pathfind=no]
+  ) # end of TRY_RUN
+  ]) # end of AC_CACHE_VAL for libopts_cv_run_pathfind
+  AC_MSG_RESULT([${libopts_cv_run_pathfind}])
+
+  if test "X${libopts_cv_run_pathfind}" != Xno
+  then
+    AC_DEFINE([HAVE_PATHFIND],[1],
+        [Define this if pathfind(3) works])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_RUN_PATHFIND
+
+
+AC_DEFUN([LIBOPTS_TEST_DEV_ZERO],[
+  AC_MSG_CHECKING([whether /dev/zero is readable device])
+  AC_CACHE_VAL([libopts_cv_test_dev_zero],[
+    libopts_cv_test_dev_zero=`exec 2> /dev/null
+dzero=\`ls -lL /dev/zero | egrep ^c......r\`
+test -z "${dzero}" && exit 1
+echo ${dzero}`
+    if test $? -ne 0
+    then libopts_cv_test_dev_zero=no
+    elif test -z "$libopts_cv_test_dev_zero"
+    then libopts_cv_test_dev_zero=no
+    fi
+  ]) # end of CACHE_VAL of libopts_cv_test_dev_zero
+  AC_MSG_RESULT([${libopts_cv_test_dev_zero}])
+
+  if test "X${libopts_cv_test_dev_zero}" != Xno
+  then
+    AC_DEFINE([HAVE_DEV_ZERO],[1],
+        [Define this if /dev/zero is readable device])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_TEST_DEV_ZERO
+
+
+AC_DEFUN([LIBOPTS_RUN_REALPATH],[
+  AC_MSG_CHECKING([whether we have a functional realpath(3C)])
+  AC_CACHE_VAL([libopts_cv_run_realpath],[
+  AC_TRY_RUN([@%:@include <limits.h>
+@%:@include <stdlib.h>
+int main (int argc, char** argv) {
+@%:@ifndef PATH_MAX
+choke me!!
+@%:@else
+   char zPath@<:@PATH_MAX+1@:>@;
+@%:@endif
+   char *pz = realpath(argv@<:@0@:>@, zPath);
+   return (pz == zPath) ? 0 : 1;
+}],
+    [libopts_cv_run_realpath=yes],[libopts_cv_run_realpath=no],[libopts_cv_run_realpath=no]
+  ) # end of TRY_RUN
+  ]) # end of AC_CACHE_VAL for libopts_cv_run_realpath
+  AC_MSG_RESULT([${libopts_cv_run_realpath}])
+
+  if test "X${libopts_cv_run_realpath}" != Xno
+  then
+    AC_DEFINE([HAVE_REALPATH],[1],
+        [Define this if we have a functional realpath(3C)])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_RUN_REALPATH
+
+
+AC_DEFUN([LIBOPTS_RUN_STRFTIME],[
+  AC_MSG_CHECKING([whether strftime() works])
+  AC_CACHE_VAL([libopts_cv_run_strftime],[
+  AC_TRY_RUN([@%:@include <time.h>
+@%:@include <string.h>
+char t_buf@<:@ 64 @:>@;
+int main() {
+  static char const z@<:@@:>@ = "Thursday Aug 28 240";
+  struct tm tm;
+  tm.tm_sec   = 36;  /* seconds after the minute @<:@0, 61@:>@  */
+  tm.tm_min   = 44;  /* minutes after the hour @<:@0, 59@:>@ */
+  tm.tm_hour  = 12;  /* hour since midnight @<:@0, 23@:>@ */
+  tm.tm_mday  = 28;  /* day of the month @<:@1, 31@:>@ */
+  tm.tm_mon   =  7;  /* months since January @<:@0, 11@:>@ */
+  tm.tm_year  = 86;  /* years since 1900 */
+  tm.tm_wday  =  4;  /* days since Sunday @<:@0, 6@:>@ */
+  tm.tm_yday  = 239; /* days since January 1 @<:@0, 365@:>@ */
+  tm.tm_isdst =  1;  /* flag for daylight savings time */
+  strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
+  return (strcmp( t_buf, z ) != 0); }],
+    [libopts_cv_run_strftime=yes],[libopts_cv_run_strftime=no],[libopts_cv_run_strftime=no]
+  ) # end of TRY_RUN
+  ]) # end of AC_CACHE_VAL for libopts_cv_run_strftime
+  AC_MSG_RESULT([${libopts_cv_run_strftime}])
+
+  if test "X${libopts_cv_run_strftime}" != Xno
+  then
+    AC_DEFINE([HAVE_STRFTIME],[1],
+        [Define this if strftime() works])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_RUN_STRFTIME
+
+
+AC_DEFUN([LIBOPTS_RUN_FOPEN_BINARY],[
+  AC_MSG_CHECKING([whether fopen accepts "b" mode])
+  AC_CACHE_VAL([libopts_cv_run_fopen_binary],[
+  AC_TRY_RUN([@%:@include <stdio.h>
+int main (int argc, char** argv) {
+FILE* fp = fopen("conftest.@S|@ac_ext", "rb");
+return (fp == NULL) ? 1 : fclose(fp); }],
+    [libopts_cv_run_fopen_binary=yes],[libopts_cv_run_fopen_binary=no],[libopts_cv_run_fopen_binary=no]
+  ) # end of TRY_RUN
+  ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
+  AC_MSG_RESULT([${libopts_cv_run_fopen_binary}])
+
+  if test "X${libopts_cv_run_fopen_binary}" != Xno
+  then
+    AC_DEFINE([FOPEN_BINARY_FLAG],"b",
+       [fopen(3) accepts a 'b' in the mode flag])
+  else
+    AC_DEFINE([FOPEN_BINARY_FLAG],"",
+       [fopen(3) accepts a 'b' in the mode flag])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_BINARY
+
+
+AC_DEFUN([LIBOPTS_RUN_FOPEN_TEXT],[
+  AC_MSG_CHECKING([whether fopen accepts "t" mode])
+  AC_CACHE_VAL([libopts_cv_run_fopen_text],[
+  AC_TRY_RUN([@%:@include <stdio.h>
+int main (int argc, char** argv) {
+FILE* fp = fopen("conftest.@S|@ac_ext", "rt");
+return (fp == NULL) ? 1 : fclose(fp); }],
+    [libopts_cv_run_fopen_text=yes],[libopts_cv_run_fopen_text=no],[libopts_cv_run_fopen_text=no]
+  ) # end of TRY_RUN
+  ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
+  AC_MSG_RESULT([${libopts_cv_run_fopen_text}])
+
+  if test "X${libopts_cv_run_fopen_text}" != Xno
+  then
+    AC_DEFINE([FOPEN_TEXT_FLAG],"t",
+       [fopen(3) accepts a 't' in the mode flag])
+  else
+    AC_DEFINE([FOPEN_TEXT_FLAG],"",
+       [fopen(3) accepts a 't' in the mode flag])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT
+
+
+AC_DEFUN([LIBOPTS_DISABLE_OPTIONAL_ARGS],[
+  AC_ARG_ENABLE([optional-args],
+    AC_HELP_STRING([--disable-optional-args], [not wanting optional option args]),
+    [libopts_cv_enable_optional_args=${enable_optional_args}],
+    AC_CACHE_CHECK([whether not wanting optional option args], libopts_cv_enable_optional_args,
+      libopts_cv_enable_optional_args=yes)
+  ) # end of AC_ARG_ENABLE
+
+  if test "X${libopts_cv_enable_optional_args}" = Xno
+  then
+    AC_DEFINE([NO_OPTIONAL_OPT_ARGS], [1],
+          [Define this if optional arguments are disallowed])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_DISABLE_OPTIONAL_ARGS
+
+
+AC_DEFUN([INVOKE_LIBOPTS_MACROS],[
+  INVOKE_LIBOPTS_MACROS_FIRST
+  # Check to see if a reg expr header is specified.
+  LIBOPTS_WITH_REGEX_HEADER
+
+  # Check to see if a working libregex can be found.
+  LIBOPTS_WITHLIB_REGEX
+
+  # Check to see if pathfind(3) works.
+  LIBOPTS_RUN_PATHFIND
+
+  # Check to see if /dev/zero is readable device.
+  LIBOPTS_TEST_DEV_ZERO
+
+  # Check to see if we have a functional realpath(3C).
+  LIBOPTS_RUN_REALPATH
+
+  # Check to see if strftime() works.
+  LIBOPTS_RUN_STRFTIME
+
+  # Check to see if fopen accepts "b" mode.
+  LIBOPTS_RUN_FOPEN_BINARY
+
+  # Check to see if fopen accepts "t" mode.
+  LIBOPTS_RUN_FOPEN_TEXT
+
+  # Check to see if not wanting optional option args.
+  LIBOPTS_DISABLE_OPTIONAL_ARGS
+
+]) # end AC_DEFUN of INVOKE_LIBOPTS_MACROS
+
+dnl @synopsis  LIBOPTS_CHECK
+dnl
+dnl Time-stamp:        "2006-09-23 19:36:24 bkorb"
+dnl Last Committed:    $Date: 2006/09/24 02:59:00 $
+dnl
+dnl If autoopts-config works, add the linking information to LIBS.
+dnl Otherwise, add ``libopts-${ao_rev}'' to SUBDIRS and run all
+dnl the config tests that the library needs.  Invoke the
+dnl "INVOKE_LIBOPTS_MACROS" macro iff we are building libopts.
+dnl
+dnl Default to system libopts
+dnl
+AC_DEFUN([LIBOPTS_CHECK],[
+  [NEED_LIBOPTS_DIR='']
+  m4_pushdef([AO_Libopts_Dir],
+           [ifelse($1, , [libopts], [$1])])
+  AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir)
+  AC_ARG_ENABLE([local-libopts],
+    AC_HELP_STRING([--enable-local-libopts],
+       [Force using the supplied libopts tearoff code]),[
+    if test x$enableval = xyes ; then
+       AC_MSG_NOTICE([Using supplied libopts tearoff])
+       LIBOPTS_LDADD='$(top_builddir)/AO_Libopts_Dir/libopts.la'
+       LIBOPTS_CFLAGS='-I$(top_srcdir)/AO_Libopts_Dir'
+       NEED_LIBOPTS_DIR=true
+    fi])
+
+  AC_ARG_ENABLE([libopts-install],
+    AC_HELP_STRING([--disable-libopts-install],
+       [Do not install libopts with client installation]))
+  AM_CONDITIONAL([INSTALL_LIBOPTS],[test "X${enable_libopts_install}" != Xno])
+
+  [if test -z "${NEED_LIBOPTS_DIR}" ; then]
+     AC_MSG_CHECKING([whether autoopts-config can be found])
+     AC_ARG_WITH([autoopts-config],
+        AC_HELP_STRING([--with-autoopts-config],
+             [specify the config-info script]),
+        [lo_cv_with_autoopts_config=${with_autoopts_config}],
+        AC_CACHE_CHECK([whether autoopts-config is specified],
+             [lo_cv_with_autoopts_config],
+             [if autoopts-config --help 2>/dev/null 1>&2
+        then lo_cv_with_autoopts_config=autoopts-config
+        elif libopts-config --help 2>/dev/null 1>&2
+        then lo_cv_with_autoopts_config=libopts-config
+        else lo_cv_with_autoopts_config=no ; fi])
+     ) # end of AC_ARG_WITH
+
+     AC_CACHE_VAL([lo_cv_test_autoopts],[
+        if test -z "${lo_cv_with_autoopts_config}" \
+                -o X"${lo_cv_with_autoopts_config}" = Xno
+        then
+           if autoopts-config --help 2>/dev/null 1>&2
+           then lo_cv_with_autoopts_config=autoopts-config
+           elif libopts-config --help 2>/dev/null 1>&2
+           then lo_cv_with_autoopts_config=libopts-config
+           else lo_cv_with_autoopts_config=false ; fi
+        fi
+        lo_cv_test_autoopts=`
+            ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
+        if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
+        then lo_cv_test_autoopts=no ; fi
+     ]) # end of CACHE_VAL
+     AC_MSG_RESULT([${lo_cv_test_autoopts}])
+
+     [if test "X${lo_cv_test_autoopts}" != Xno
+     then
+        LIBOPTS_LDADD="${lo_cv_test_autoopts}"
+        LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
+     else
+        LIBOPTS_LDADD='$(top_builddir)/]AO_Libopts_Dir[/libopts.la'
+        LIBOPTS_CFLAGS='-I$(top_srcdir)/]AO_Libopts_Dir['
+        NEED_LIBOPTS_DIR=true
+     fi
+  fi # end of if test -z "${NEED_LIBOPTS_DIR}"]
+
+  AM_CONDITIONAL([NEED_LIBOPTS], [test -n "${NEED_LIBOPTS_DIR}"])
+  AC_SUBST(LIBOPTS_LDADD)
+  AC_SUBST(LIBOPTS_CFLAGS)
+  AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir)
+  AC_CONFIG_FILES(AO_Libopts_Dir/Makefile)
+  m4_popdef([AO_Libopts_Dir])
+
+  [if test -n "${NEED_LIBOPTS_DIR}" ; then]
+    INVOKE_LIBOPTS_MACROS
+  else
+    INVOKE_LIBOPTS_MACROS_FIRST
+  [fi
+# end of AC_DEFUN of LIBOPTS_CHECK]
+])
diff --git a/libopts/m4/liboptschk.m4 b/libopts/m4/liboptschk.m4
new file mode 100644 (file)
index 0000000..14e7f27
--- /dev/null
@@ -0,0 +1,42 @@
+# liboptschk.m4 serial 1 (autogen - 5.7.3)
+dnl Copyright (C) 2005 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Time-stamp:        "2006-09-23 19:42:31 bkorb"
+dnl Last Committed:    $Date: 2006/09/24 02:59:00 $
+
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
+
+AC_PREREQ(2.50)
+
+AC_DEFUN([ag_FIND_LIBOPTS],
+    [if test "X${ac_cv_header_autoopts_options_h}" == Xno
+    then
+      :
+    else
+      f=`autoopts-config cflags` 2>/dev/null
+      test X"${f}" = X && f=`libopts-config cflags` 2>/dev/null
+      if test X"${f}" = X
+      then
+        :
+      else
+        AC_DEFINE([HAVE_LIBOPTS],[1],[define if we can find libopts])
+        CFLAGS="${CFLAGS} ${f}"
+        f=`autoopts-config ldflags` 2>/dev/null
+        test X"${f}" = X && f=`libopts-config ldflags` 2>/dev/null
+        LIBS="${LIBS} ${f}"
+      fi
+    fi])
diff --git a/libopts/makeshell.c b/libopts/makeshell.c
new file mode 100644 (file)
index 0000000..8447d45
--- /dev/null
@@ -0,0 +1,1122 @@
+
+/*
+ *  $Id: makeshell.c,v 4.20 2007/02/04 17:44:12 bkorb Exp $
+ * Time-stamp:      "2007-01-27 06:05:45 bkorb"
+ *
+ *  This module will interpret the options set in the tOptions
+ *  structure and create a Bourne shell script capable of parsing them.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+tOptions*  pShellParseOptions = NULL;
+
+/* * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Setup Format Strings
+ */
+tSCC zStartMarker[] =
+"# # # # # # # # # # -- do not modify this marker --\n#\n"
+"#  DO NOT EDIT THIS SECTION";
+
+tSCC zPreamble[] =
+"%s OF %s\n#\n"
+"#  From here to the next `-- do not modify this marker --',\n"
+"#  the text has been generated %s\n";
+
+tSCC zEndPreamble[] =
+"#  From the %s option definitions\n#\n";
+
+tSCC zMultiDef[] = "\n"
+"if test -z \"${%1$s_%2$s}\"\n"
+"then\n"
+"  %1$s_%2$s_CT=0\n"
+"else\n"
+"  %1$s_%2$s_CT=1\n"
+"  %1$s_%2$s_1=\"${%1$s_%2$s}\"\n"
+"fi\n"
+"export %1$s_%2$s_CT";
+
+tSCC zSingleDef[] = "\n"
+"%1$s_%2$s=\"${%1$s_%2$s-'%3$s'}\"\n"
+"%1$s_%2$s_set=false\n"
+"export %1$s_%2$s\n";
+
+tSCC zSingleNoDef[] = "\n"
+"%1$s_%2$s=\"${%1$s_%2$s}\"\n"
+"%1$s_%2$s_set=false\n"
+"export %1$s_%2$s\n";
+
+/* * * * * * * * * * * * * * * * * * * * *
+ *
+ *  LOOP START
+ *
+ *  The loop may run in either of two modes:
+ *  all options are named options (loop only)
+ *  regular, marked option processing.
+ */
+tSCC zLoopCase[] = "\n"
+"OPT_PROCESS=true\n"
+"OPT_ARG=\"$1\"\n\n"
+"while ${OPT_PROCESS} && [ $# -gt 0 ]\ndo\n"
+"    OPT_ELEMENT=''\n"
+"    OPT_ARG_VAL=''\n\n"
+     /*
+      *  'OPT_ARG' may or may not match the current $1
+      */
+"    case \"${OPT_ARG}\" in\n"
+"    -- )\n"
+"        OPT_PROCESS=false\n"
+"        shift\n"
+"        ;;\n\n";
+
+tSCC zLoopOnly[] = "\n"
+"OPT_ARG=\"$1\"\n\n"
+"while [ $# -gt 0 ]\ndo\n"
+"    OPT_ELEMENT=''\n"
+"    OPT_ARG_VAL=''\n\n"
+"    OPT_ARG=\"${1}\"\n";
+
+/* * * * * * * * * * * * * * * *
+ *
+ *  CASE SELECTORS
+ *
+ *  If the loop runs as a regular option loop,
+ *  then we must have selectors for each acceptable option
+ *  type (long option, flag character and non-option)
+ */
+tSCC zLongSelection[] =
+"    --* )\n";
+
+tSCC zFlagSelection[] =
+"    -* )\n";
+
+tSCC zEndSelection[] =
+"        ;;\n\n";
+
+tSCC zNoSelection[] =
+"    * )\n"
+"         OPT_PROCESS=false\n"
+"         ;;\n"
+"    esac\n\n";
+
+/* * * * * * * * * * * * * * * *
+ *
+ *  LOOP END
+ */
+tSCC zLoopEnd[] =
+"    if [ -n \"${OPT_ARG_VAL}\" ]\n"
+"    then\n"
+"        eval %1$s_${OPT_NAME}${OPT_ELEMENT}=\"'${OPT_ARG_VAL}'\"\n"
+"        export %1$s_${OPT_NAME}${OPT_ELEMENT}\n"
+"    fi\n"
+"done\n\n"
+"unset OPT_PROCESS || :\n"
+"unset OPT_ELEMENT || :\n"
+"unset OPT_ARG || :\n"
+"unset OPT_ARG_NEEDED || :\n"
+"unset OPT_NAME || :\n"
+"unset OPT_CODE || :\n"
+"unset OPT_ARG_VAL || :\n%2$s";
+
+tSCC zTrailerMarker[] = "\n"
+"# # # # # # # # # #\n#\n"
+"#  END OF AUTOMATED OPTION PROCESSING\n"
+"#\n# # # # # # # # # # -- do not modify this marker --\n";
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  OPTION SELECTION
+ */
+tSCC zOptionCase[] =
+"        case \"${OPT_CODE}\" in\n";
+
+tSCC zOptionPartName[] =
+"        '%s' | \\\n";
+
+tSCC zOptionFullName[] =
+"        '%s' )\n";
+
+tSCC zOptionFlag[] =
+"        '%c' )\n";
+
+tSCC zOptionEndSelect[] =
+"            ;;\n\n";
+
+tSCC zOptionUnknown[] =
+"        * )\n"
+"            echo Unknown %s: \"${OPT_CODE}\" >&2\n"
+"            echo \"$%s_USAGE_TEXT\"\n"
+"            exit 1\n"
+"            ;;\n"
+"        esac\n\n";
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  OPTION PROCESSING
+ *
+ *  Formats for emitting the text for handling particular options
+ */
+tSCC zTextExit[] =
+"            echo \"$%s_%s_TEXT\"\n"
+"            exit 0\n";
+
+tSCC zPagedUsageExit[] =
+"            echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
+"            exit 0\n";
+
+tSCC zCmdFmt[] =
+"            %s\n";
+
+tSCC zCountTest[] =
+"            if [ $%1$s_%2$s_CT -ge %3$d ] ; then\n"
+"                echo Error:  more than %3$d %2$s options >&2\n"
+"                echo \"$%1$s_USAGE_TEXT\"\n"
+"                exit 1 ; fi\n";
+
+tSCC zMultiArg[] =
+"            %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n"
+"            OPT_ELEMENT=\"_${%1$s_%2$s_CT}\"\n"
+"            OPT_NAME='%2$s'\n";
+
+tSCC zSingleArg[] =
+"            if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
+"                echo Error:  duplicate %2$s option >&2\n"
+"                echo \"$%1$s_USAGE_TEXT\"\n"
+"                exit 1 ; fi\n"
+"            %1$s_%2$s_set=true\n"
+"            OPT_NAME='%2$s'\n";
+
+tSCC zNoMultiArg[] =
+"            %1$s_%2$s_CT=0\n"
+"            OPT_ELEMENT=''\n"
+"            %1$s_%2$s='%3$s'\n"
+"            export %1$s_%2$s\n"
+"            OPT_NAME='%2$s'\n";
+
+tSCC zNoSingleArg[] =
+"            if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
+"                echo Error:  duplicate %2$s option >&2\n"
+"                echo \"$%1$s_USAGE_TEXT\"\n"
+"                exit 1 ; fi\n"
+"            %1$s_%2$s_set=true\n"
+"            %1$s_%2$s='%3$s'\n"
+"            export %1$s_%2$s\n"
+"            OPT_NAME='%2$s'\n";
+
+tSCC zMayArg[]  =
+"            eval %1$s_%2$s${OPT_ELEMENT}=true\n"
+"            export %1$s_%2$s${OPT_ELEMENT}\n"
+"            OPT_ARG_NEEDED=OK\n";
+
+tSCC zMustArg[] =
+"            OPT_ARG_NEEDED=YES\n";
+
+tSCC zCantArg[] =
+"            eval %1$s_%2$s${OPT_ELEMENT}=true\n"
+"            export %1$s_%2$s${OPT_ELEMENT}\n"
+"            OPT_ARG_NEEDED=NO\n";
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  LONG OPTION PROCESSING
+ *
+ *  Formats for emitting the text for handling long option types
+ */
+tSCC zLongOptInit[] =
+"        OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n"
+"        shift\n"
+"        OPT_ARG=\"$1\"\n\n"
+"        case \"${OPT_CODE}\" in *=* )\n"
+"            OPT_ARG_VAL=`echo \"${OPT_CODE}\"|sed 's/^[^=]*=//'`\n"
+"            OPT_CODE=`echo \"${OPT_CODE}\"|sed 's/=.*$//'` ;; esac\n\n";
+
+tSCC zLongOptArg[] =
+"        case \"${OPT_ARG_NEEDED}\" in\n"
+"        NO )\n"
+"            OPT_ARG_VAL=''\n"
+"            ;;\n\n"
+"        YES )\n"
+"            if [ -z \"${OPT_ARG_VAL}\" ]\n"
+"            then\n"
+"                if [ $# -eq 0 ]\n"
+"                then\n"
+"                    echo No argument provided for ${OPT_NAME} option >&2\n"
+"                    echo \"$%s_USAGE_TEXT\"\n"
+"                    exit 1\n"
+"                fi\n\n"
+"                OPT_ARG_VAL=\"${OPT_ARG}\"\n"
+"                shift\n"
+"                OPT_ARG=\"$1\"\n"
+"            fi\n"
+"            ;;\n\n"
+"        OK )\n"
+"            if [ -z \"${OPT_ARG_VAL}\" ] && [ $# -gt 0 ]\n"
+"            then\n"
+"                case \"${OPT_ARG}\" in -* ) ;; * )\n"
+"                    OPT_ARG_VAL=\"${OPT_ARG}\"\n"
+"                    shift\n"
+"                    OPT_ARG=\"$1\" ;; esac\n"
+"            fi\n"
+"            ;;\n"
+"        esac\n";
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  FLAG OPTION PROCESSING
+ *
+ *  Formats for emitting the text for handling flag option types
+ */
+tSCC zFlagOptInit[] =
+"        OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
+"        OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\n";
+
+tSCC zFlagOptArg[] =
+"        case \"${OPT_ARG_NEEDED}\" in\n"
+"        NO )\n"
+"            if [ -n \"${OPT_ARG}\" ]\n"
+"            then\n"
+"                OPT_ARG=-\"${OPT_ARG}\"\n"
+"            else\n"
+"                shift\n"
+"                OPT_ARG=\"$1\"\n"
+"            fi\n"
+"            ;;\n\n"
+"        YES )\n"
+"            if [ -n \"${OPT_ARG}\" ]\n"
+"            then\n"
+"                OPT_ARG_VAL=\"${OPT_ARG}\"\n\n"
+"            else\n"
+"                if [ $# -eq 0 ]\n"
+"                then\n"
+"                    echo No argument provided for ${OPT_NAME} option >&2\n"
+"                    echo \"$%s_USAGE_TEXT\"\n"
+"                    exit 1\n"
+"                fi\n"
+"                shift\n"
+"                OPT_ARG_VAL=\"$1\"\n"
+"            fi\n\n"
+"            shift\n"
+"            OPT_ARG=\"$1\"\n"
+"            ;;\n\n"
+"        OK )\n"
+"            if [ -n \"${OPT_ARG}\" ]\n"
+"            then\n"
+"                OPT_ARG_VAL=\"${OPT_ARG}\"\n"
+"                shift\n"
+"                OPT_ARG=\"$1\"\n\n"
+"            else\n"
+"                shift\n"
+"                if [ $# -gt 0 ]\n"
+"                then\n"
+"                    case \"$1\" in -* ) ;; * )\n"
+"                        OPT_ARG_VAL=\"$1\"\n"
+"                        shift ;; esac\n"
+"                    OPT_ARG=\"$1\"\n"
+"                fi\n"
+"            fi\n"
+"            ;;\n"
+"        esac\n";
+
+tSCC* pzShell = NULL;
+static char*  pzLeader  = NULL;
+static char*  pzTrailer = NULL;
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD );
+
+static void
+emitUsage( tOptions* pOpts );
+
+static void
+emitSetup( tOptions* pOpts );
+
+static void
+printOptionAction( tOptions* pOpts, tOptDesc* pOptDesc );
+
+static void
+printOptionInaction( tOptions* pOpts, tOptDesc* pOptDesc );
+
+static void
+emitFlag( tOptions* pOpts );
+
+static void
+emitMatchExpr( tCC* pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts );
+
+static void
+emitLong( tOptions* pOpts );
+
+static void
+openOutput( char const* pzFile );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*=export_func  optionParseShell
+ * private:
+ *
+ * what:  Decipher a boolean value
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ *
+ * doc:
+ *  Emit a shell script that will parse the command line options.
+=*/
+void
+optionParseShell( tOptions* pOpts )
+{
+    /*
+     *  Check for our SHELL option now.
+     *  IF the output file contains the "#!" magic marker,
+     *  it will override anything we do here.
+     */
+    if (HAVE_OPT( SHELL ))
+        pzShell = OPT_ARG( SHELL );
+
+    else if (! ENABLED_OPT( SHELL ))
+        pzShell = NULL;
+
+    else if ((pzShell = getenv( "SHELL" )),
+             pzShell == NULL)
+
+        pzShell = "/bin/sh";
+
+    /*
+     *  Check for a specified output file
+     */
+    if (HAVE_OPT( SCRIPT ))
+        openOutput( OPT_ARG( SCRIPT ));
+
+    emitUsage( pOpts );
+    emitSetup( pOpts );
+
+    /*
+     *  There are four modes of option processing.
+     */
+    switch (pOpts->fOptSet & (OPTPROC_LONGOPT|OPTPROC_SHORTOPT)) {
+    case OPTPROC_LONGOPT:
+        fputs( zLoopCase,        stdout );
+
+        fputs( zLongSelection,   stdout );
+        fputs( zLongOptInit,     stdout );
+        emitLong( pOpts );
+        printf( zLongOptArg,     pOpts->pzPROGNAME );
+        fputs( zEndSelection,    stdout );
+
+        fputs( zNoSelection,     stdout );
+        break;
+
+    case 0:
+        fputs( zLoopOnly,        stdout );
+        fputs( zLongOptInit,     stdout );
+        emitLong( pOpts );
+        printf( zLongOptArg,     pOpts->pzPROGNAME );
+        break;
+
+    case OPTPROC_SHORTOPT:
+        fputs( zLoopCase,        stdout );
+
+        fputs( zFlagSelection,   stdout );
+        fputs( zFlagOptInit,     stdout );
+        emitFlag( pOpts );
+        printf( zFlagOptArg,     pOpts->pzPROGNAME );
+        fputs( zEndSelection,    stdout );
+
+        fputs( zNoSelection,     stdout );
+        break;
+
+    case OPTPROC_LONGOPT|OPTPROC_SHORTOPT:
+        fputs( zLoopCase,        stdout );
+
+        fputs( zLongSelection,   stdout );
+        fputs( zLongOptInit,     stdout );
+        emitLong( pOpts );
+        printf( zLongOptArg,     pOpts->pzPROGNAME );
+        fputs( zEndSelection,    stdout );
+
+        fputs( zFlagSelection,   stdout );
+        fputs( zFlagOptInit,     stdout );
+        emitFlag( pOpts );
+        printf( zFlagOptArg,     pOpts->pzPROGNAME );
+        fputs( zEndSelection,    stdout );
+
+        fputs( zNoSelection,     stdout );
+        break;
+    }
+
+    printf( zLoopEnd, pOpts->pzPROGNAME, zTrailerMarker );
+    if ((pzTrailer != NULL) && (*pzTrailer != '\0'))
+        fputs( pzTrailer, stdout );
+    else if (ENABLED_OPT( SHELL ))
+        printf( "\nenv | grep '^%s_'\n", pOpts->pzPROGNAME );
+
+    fflush( stdout );
+    fchmod( STDOUT_FILENO, 0755 );
+    fclose( stdout );
+}
+
+
+static void
+textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD )
+{
+#   define _TT_(n) tSCC z ## n [] = #n;
+    TEXTTO_TABLE
+#   undef _TT_
+#   define _TT_(n) z ## n ,
+      static char const*  apzTTNames[] = { TEXTTO_TABLE };
+#   undef _TT_
+
+#if defined(__windows__) && !defined(__CYGWIN__)
+    printf( "%1$s_%2$s_TEXT='no %2$s text'\n",
+            pOpts->pzPROGNAME, apzTTNames[ whichVar ]);
+#else
+    int  nlHoldCt = 0;
+    int  pipeFd[2];
+    FILE* fp;
+
+    printf( "%s_%s_TEXT='", pOpts->pzPROGNAME, apzTTNames[ whichVar ]);
+    fflush( stdout );
+
+    if (pipe( pipeFd ) != 0) {
+        fprintf( stderr, zBadPipe, errno, strerror( errno ));
+        exit( EXIT_FAILURE );
+    }
+
+    switch (fork()) {
+    case -1:
+        fprintf( stderr, zForkFail, errno, strerror(errno), pOpts->pzProgName);
+        exit( EXIT_FAILURE );
+        break;
+
+    case 0:
+        dup2( pipeFd[1], STDERR_FILENO );
+        dup2( pipeFd[1], STDOUT_FILENO );
+        close( pipeFd[0] );
+
+        switch (whichVar) {
+        case TT_LONGUSAGE:
+            (*(pOpts->pUsageProc))( pOpts, EXIT_SUCCESS );
+            /* NOTREACHED */
+            exit( EXIT_FAILURE );
+
+        case TT_USAGE:
+            (*(pOpts->pUsageProc))( pOpts, EXIT_FAILURE );
+            /* NOTREACHED */
+            exit( EXIT_FAILURE );
+
+        case TT_VERSION:
+            if (pOD->fOptState & OPTST_ALLOC_ARG) {
+                AGFREE(pOD->optArg.argString);
+                pOD->fOptState &= ~OPTST_ALLOC_ARG;
+            }
+            pOD->optArg.argString = "c";
+            optionPrintVersion( pOpts, pOD );
+            /* NOTREACHED */
+
+        default:
+            exit( EXIT_FAILURE );
+        }
+
+    default:
+        close( pipeFd[1] );
+        fp = fdopen( pipeFd[0], "r" FOPEN_BINARY_FLAG );
+    }
+
+    for (;;) {
+        int  ch = fgetc( fp );
+        switch (ch) {
+
+        case '\n':
+            nlHoldCt++;
+            break;
+
+        case '\'':
+            while (nlHoldCt > 0) {
+                fputc( '\n', stdout );
+                nlHoldCt--;
+            }
+            fputs( "'\\''", stdout );
+            break;
+
+        case EOF:
+            goto endCharLoop;
+
+        default:
+            while (nlHoldCt > 0) {
+                fputc( '\n', stdout );
+                nlHoldCt--;
+            }
+            fputc( ch, stdout );
+            break;
+        }
+    } endCharLoop:;
+
+    fputs( "'\n\n", stdout );
+    close( pipeFd[0] );
+#endif
+}
+
+
+static void
+emitUsage( tOptions* pOpts )
+{
+    char     zTimeBuf[ AO_NAME_SIZE ];
+
+    /*
+     *  First, switch stdout to the output file name.
+     *  Then, change the program name to the one defined
+     *  by the definitions (rather than the current
+     *  executable name).  Down case the upper cased name.
+     */
+    if (pzLeader != NULL)
+        fputs( pzLeader, stdout );
+
+    {
+        tSCC    zStdout[] = "stdout";
+        tCC*    pzOutName;
+
+        {
+            time_t    curTime = time( NULL );
+            struct tm*  pTime = localtime( &curTime );
+            strftime(zTimeBuf, AO_NAME_SIZE, "%A %B %e, %Y at %r %Z", pTime );
+        }
+
+        if (HAVE_OPT( SCRIPT ))
+             pzOutName = OPT_ARG( SCRIPT );
+        else pzOutName = zStdout;
+
+        if ((pzLeader == NULL) && (pzShell != NULL))
+            printf( "#! %s\n", pzShell );
+
+        printf( zPreamble, zStartMarker, pzOutName, zTimeBuf );
+    }
+
+    /*
+     *  Get a copy of the original program name in lower case
+     */
+    {
+        char* pzPN = zTimeBuf;
+        tCC*  pz   = pOpts->pzPROGNAME;
+        for (;;) {
+            if ((*pzPN++ = tolower( *pz++ )) == '\0')
+                break;
+        }
+    }
+
+    printf( zEndPreamble, pOpts->pzPROGNAME );
+
+    pOpts->pzProgPath = pOpts->pzProgName = zTimeBuf;
+    textToVariable( pOpts, TT_LONGUSAGE, NULL );
+    textToVariable( pOpts, TT_USAGE,     NULL );
+
+    {
+        tOptDesc* pOptDesc = pOpts->pOptDesc;
+        int       optionCt = pOpts->optCt;
+
+        for (;;) {
+            if (pOptDesc->pOptProc == optionPrintVersion) {
+                textToVariable( pOpts, TT_VERSION, pOptDesc );
+                break;
+            }
+
+            if (--optionCt <= 0)
+                break;
+            pOptDesc++;
+        }
+    }
+}
+
+
+static void
+emitSetup( tOptions* pOpts )
+{
+    tOptDesc* pOptDesc = pOpts->pOptDesc;
+    int       optionCt = pOpts->presetOptCt;
+    char const* pzFmt;
+    char const* pzDefault;
+
+    for (;optionCt > 0; pOptDesc++, --optionCt) {
+        char zVal[16];
+
+        /*
+         *  Options that are either usage documentation or are compiled out
+         *  are not to be processed.
+         */
+        if (SKIP_OPT(pOptDesc) || (pOptDesc->pz_NAME == NULL))
+            continue;
+
+        if (pOptDesc->optMaxCt > 1)
+             pzFmt = zMultiDef;
+        else pzFmt = zSingleDef;
+
+        /*
+         *  IF this is an enumeration/bitmask option, then convert the value
+         *  to a string before printing the default value.
+         */
+        switch (OPTST_GET_ARGTYPE(pOptDesc->fOptState)) {
+        case OPARG_TYPE_ENUMERATION:
+            (*(pOptDesc->pOptProc))( (tOptions*)2UL, pOptDesc );
+            pzDefault = pOptDesc->optArg.argString;
+            break;
+
+        /*
+         *  Numeric and membership bit options are just printed as a number.
+         */
+        case OPARG_TYPE_NUMERIC:
+            snprintf( zVal, sizeof( zVal ), "%d",
+                      (int)pOptDesc->optArg.argInt );
+            pzDefault = zVal;
+            break;
+
+        case OPARG_TYPE_MEMBERSHIP:
+            snprintf( zVal, sizeof( zVal ), "%lu",
+                      (unsigned long)pOptDesc->optArg.argIntptr );
+            pzDefault = zVal;
+            break;
+
+        case OPARG_TYPE_BOOLEAN:
+            pzDefault = (pOptDesc->optArg.argBool) ? "true" : "false";
+            break;
+
+        default:
+            if (pOptDesc->optArg.argString == NULL) {
+                if (pzFmt == zSingleDef)
+                    pzFmt = zSingleNoDef;
+                pzDefault = NULL;
+            }
+            else
+                pzDefault = pOptDesc->optArg.argString;
+        }
+
+        printf( pzFmt, pOpts->pzPROGNAME, pOptDesc->pz_NAME, pzDefault );
+    }
+}
+
+
+static void
+printOptionAction( tOptions* pOpts, tOptDesc* pOptDesc )
+{
+    if (pOptDesc->pOptProc == optionPrintVersion)
+        printf( zTextExit, pOpts->pzPROGNAME, "VERSION" );
+
+    else if (pOptDesc->pOptProc == optionPagedUsage)
+        printf( zPagedUsageExit, pOpts->pzPROGNAME );
+
+    else if (pOptDesc->pOptProc == optionLoadOpt) {
+        printf( zCmdFmt, "echo 'Warning:  Cannot load options files' >&2" );
+        printf( zCmdFmt, "OPT_ARG_NEEDED=YES" );
+
+    } else if (pOptDesc->pz_NAME == NULL) {
+
+        if (pOptDesc->pOptProc == NULL) {
+            printf( zCmdFmt, "echo 'Warning:  Cannot save options files' "
+                    ">&2" );
+            printf( zCmdFmt, "OPT_ARG_NEEDED=OK" );
+        } else
+            printf( zTextExit, pOpts->pzPROGNAME, "LONGUSAGE" );
+
+    } else {
+        if (pOptDesc->optMaxCt == 1)
+            printf( zSingleArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME );
+        else {
+            if ((unsigned)pOptDesc->optMaxCt < NOLIMIT)
+                printf( zCountTest, pOpts->pzPROGNAME,
+                        pOptDesc->pz_NAME, pOptDesc->optMaxCt );
+
+            printf( zMultiArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME );
+        }
+
+        /*
+         *  Fix up the args.
+         */
+        if (OPTST_GET_ARGTYPE(pOptDesc->fOptState) == OPARG_TYPE_NONE) {
+            printf( zCantArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME );
+
+        } else if (pOptDesc->fOptState & OPTST_ARG_OPTIONAL) {
+            printf( zMayArg,  pOpts->pzPROGNAME, pOptDesc->pz_NAME );
+
+        } else {
+            fputs( zMustArg, stdout );
+        }
+    }
+    fputs( zOptionEndSelect, stdout );
+}
+
+
+static void
+printOptionInaction( tOptions* pOpts, tOptDesc* pOptDesc )
+{
+    if (pOptDesc->pOptProc == optionLoadOpt) {
+        printf( zCmdFmt, "echo 'Warning:  Cannot suppress the loading of "
+                "options files' >&2" );
+
+    } else if (pOptDesc->optMaxCt == 1)
+        printf( zNoSingleArg, pOpts->pzPROGNAME,
+                pOptDesc->pz_NAME, pOptDesc->pz_DisablePfx );
+    else
+        printf( zNoMultiArg, pOpts->pzPROGNAME,
+                pOptDesc->pz_NAME, pOptDesc->pz_DisablePfx );
+
+    printf( zCmdFmt, "OPT_ARG_NEEDED=NO" );
+    fputs( zOptionEndSelect, stdout );
+}
+
+
+static void
+emitFlag( tOptions* pOpts )
+{
+    tOptDesc* pOptDesc = pOpts->pOptDesc;
+    int       optionCt = pOpts->optCt;
+
+    fputs( zOptionCase, stdout );
+
+    for (;optionCt > 0; pOptDesc++, --optionCt) {
+
+        if (SKIP_OPT(pOptDesc))
+            continue;
+
+        if (isprint( pOptDesc->optValue )) {
+            printf( zOptionFlag, pOptDesc->optValue );
+            printOptionAction( pOpts, pOptDesc );
+        }
+    }
+    printf( zOptionUnknown, "flag", pOpts->pzPROGNAME );
+}
+
+
+/*
+ *  Emit the match text for a long option
+ */
+static void
+emitMatchExpr( tCC* pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts )
+{
+    tOptDesc* pOD = pOpts->pOptDesc;
+    int       oCt = pOpts->optCt;
+    int       min = 1;
+    char      zName[ 256 ];
+    char*     pz  = zName;
+
+    for (;;) {
+        int matchCt = 0;
+
+        /*
+         *  Omit the current option, Documentation opts and compiled out opts.
+         */
+        if ((pOD == pCurOpt) || SKIP_OPT(pOD)){
+            if (--oCt <= 0)
+                break;
+            pOD++;
+            continue;
+        }
+
+        /*
+         *  Check each character of the name case insensitively.
+         *  They must not be the same.  They cannot be, because it would
+         *  not compile correctly if they were.
+         */
+        while (  toupper( pOD->pz_Name[matchCt] )
+              == toupper( pzMatchName[matchCt] ))
+            matchCt++;
+
+        if (matchCt > min)
+            min = matchCt;
+
+        /*
+         *  Check the disablement name, too.
+         */
+        if (pOD->pz_DisableName != NULL) {
+            matchCt = 0;
+            while (  toupper( pOD->pz_DisableName[matchCt] )
+                  == toupper( pzMatchName[matchCt] ))
+                matchCt++;
+            if (matchCt > min)
+                min = matchCt;
+        }
+        if (--oCt <= 0)
+            break;
+        pOD++;
+    }
+
+    /*
+     *  IF the 'min' is all or one short of the name length,
+     *  THEN the entire string must be matched.
+     */
+    if (  (pzMatchName[min  ] == NUL)
+       || (pzMatchName[min+1] == NUL) )
+        printf( zOptionFullName, pzMatchName );
+
+    else {
+        int matchCt = 0;
+        for (; matchCt <= min; matchCt++)
+            *pz++ = pzMatchName[matchCt];
+
+        for (;;) {
+            *pz = NUL;
+            printf( zOptionPartName, zName );
+            *pz++ = pzMatchName[matchCt++];
+            if (pzMatchName[matchCt] == NUL) {
+                *pz = NUL;
+                printf( zOptionFullName, zName );
+                break;
+            }
+        }
+    }
+}
+
+
+/*
+ *  Emit GNU-standard long option handling code
+ */
+static void
+emitLong( tOptions* pOpts )
+{
+    tOptDesc* pOD = pOpts->pOptDesc;
+    int       ct  = pOpts->optCt;
+
+    fputs( zOptionCase, stdout );
+
+    /*
+     *  do each option, ...
+     */
+    do  {
+        /*
+         *  Documentation & compiled-out options
+         */
+        if (SKIP_OPT(pOD))
+            continue;
+
+        emitMatchExpr( pOD->pz_Name, pOD, pOpts );
+        printOptionAction( pOpts, pOD );
+
+        /*
+         *  Now, do the same thing for the disablement version of the option.
+         */
+        if (pOD->pz_DisableName != NULL) {
+            emitMatchExpr( pOD->pz_DisableName, pOD, pOpts );
+            printOptionInaction( pOpts, pOD );
+        }
+    } while (pOD++, --ct > 0);
+
+    printf( zOptionUnknown, "option", pOpts->pzPROGNAME );
+}
+
+
+static void
+openOutput( char const* pzFile )
+{
+    FILE* fp;
+    char* pzData = NULL;
+    struct stat stbf;
+
+    do  {
+        char*    pzScan;
+        size_t sizeLeft;
+
+        /*
+         *  IF we cannot stat the file,
+         *  THEN assume we are creating a new file.
+         *       Skip the loading of the old data.
+         */
+        if (stat( pzFile, &stbf ) != 0)
+            break;
+
+        /*
+         *  The file must be a regular file
+         */
+        if (! S_ISREG( stbf.st_mode )) {
+            fprintf( stderr, zNotFile, pzFile );
+            exit( EXIT_FAILURE );
+        }
+
+        pzData = AGALOC(stbf.st_size + 1, "file data");
+        fp = fopen( pzFile, "r" FOPEN_BINARY_FLAG );
+
+        sizeLeft = (unsigned)stbf.st_size;
+        pzScan   = pzData;
+
+        /*
+         *  Read in all the data as fast as our OS will let us.
+         */
+        for (;;) {
+            int inct = fread( (void*)pzScan, (size_t)1, sizeLeft, fp);
+            if (inct == 0)
+                break;
+
+            pzScan   += inct;
+            sizeLeft -= inct;
+
+            if (sizeLeft == 0)
+                break;
+        }
+
+        /*
+         *  NUL-terminate the leader and look for the trailer
+         */
+        *pzScan = '\0';
+        fclose( fp );
+        pzScan  = strstr( pzData, zStartMarker );
+        if (pzScan == NULL) {
+            pzTrailer = pzData;
+            break;
+        }
+
+        *(pzScan++) = NUL;
+        pzScan  = strstr( pzScan, zTrailerMarker );
+        if (pzScan == NULL) {
+            pzTrailer = pzData;
+            break;
+        }
+
+        /*
+         *  Check to see if the data contains
+         *  our marker.  If it does, then we will skip over it
+         */
+        pzTrailer = pzScan + sizeof( zTrailerMarker ) - 1;
+        pzLeader  = pzData;
+    } while (AG_FALSE);
+
+    freopen( pzFile, "w" FOPEN_BINARY_FLAG, stdout );
+}
+
+
+/*=export_func genshelloptUsage
+ * private:
+ * what: The usage function for the genshellopt generated program
+ *
+ * arg:  + tOptions* + pOpts    + program options descriptor +
+ * arg:  + int       + exitCode + usage text type to produce +
+ *
+ * doc:
+ *  This function is used to create the usage strings for the option
+ *  processing shell script code.  Two child processes are spawned
+ *  each emitting the usage text in either the short (error exit)
+ *  style or the long style.  The generated program will capture this
+ *  and create shell script variables containing the two types of text.
+=*/
+void
+genshelloptUsage( tOptions*  pOpts, int exitCode )
+{
+#if defined(__windows__) && !defined(__CYGWIN__)
+    optionUsage( pOpts, exitCode );
+#else
+    /*
+     *  IF not EXIT_SUCCESS,
+     *  THEN emit the short form of usage.
+     */
+    if (exitCode != EXIT_SUCCESS)
+        optionUsage( pOpts, exitCode );
+    fflush( stderr );
+    fflush( stdout );
+
+    option_usage_fp = stdout;
+
+    /*
+     *  First, print our usage
+     */
+    switch (fork()) {
+    case -1:
+        optionUsage( pOpts, EXIT_FAILURE );
+        /*NOTREACHED*/
+        _exit( EXIT_FAILURE );
+
+    case 0:
+        pagerState = PAGER_STATE_CHILD;
+        optionUsage( pOpts, EXIT_SUCCESS );
+        /*NOTREACHED*/
+        _exit( EXIT_FAILURE );
+
+    default:
+    {
+        int  sts;
+        wait( &sts );
+    }
+    }
+
+    /*
+     *  Generate the pzProgName, since optionProcess() normally
+     *  gets it from the command line
+     */
+    {
+        char* pz;
+        AGDUPSTR( pz, pShellParseOptions->pzPROGNAME, "program name" );
+        pShellParseOptions->pzProgName = pz;
+        while (*pz != NUL) {
+            *pz = tolower( *pz );
+            pz++;
+        }
+    }
+
+    /*
+     *  Separate the makeshell usage from the client usage
+     */
+    fprintf( option_usage_fp, zGenshell, pShellParseOptions->pzProgName );
+    fflush( option_usage_fp );
+
+    /*
+     *  Now, print the client usage.
+     */
+    switch (fork()) {
+    case 0:
+        pagerState = PAGER_STATE_CHILD;
+        /*FALLTHROUGH*/
+    case -1:
+        optionUsage( pShellParseOptions, EXIT_FAILURE );
+
+    default:
+    {
+        int  sts;
+        wait( &sts );
+    }
+    }
+
+    exit( EXIT_SUCCESS );
+#endif
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/makeshell.c */
diff --git a/libopts/nested.c b/libopts/nested.c
new file mode 100644 (file)
index 0000000..b39f8d1
--- /dev/null
@@ -0,0 +1,733 @@
+
+/*
+ *  $Id: nested.c,v 4.14 2007/02/04 17:44:12 bkorb Exp $
+ *  Time-stamp:      "2007-01-26 11:04:35 bkorb"
+ *
+ *   Automated Options Nested Values module.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+removeBackslashes( char* pzSrc );
+
+static char const*
+scanQuotedString( char const* pzTxt );
+
+static tOptionValue*
+addStringValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen );
+
+static tOptionValue*
+addBoolValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen );
+
+static tOptionValue*
+addNumberValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen );
+
+static tOptionValue*
+addNestedValue( void** pp, char const* pzName, size_t nameLen,
+                char* pzValue, size_t dataLen );
+
+static char const*
+scanNameEntry(char const* pzName, tOptionValue* pRes);
+
+static char const*
+scanXmlEntry( char const* pzName, tOptionValue* pRes );
+
+static void
+unloadNestedArglist( tArgList* pAL );
+
+static void
+sortNestedList( tArgList* pAL );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*  removeBackslashes
+ *
+ *  This function assumes that all newline characters were preceeded by
+ *  backslashes that need removal.
+ */
+static void
+removeBackslashes( char* pzSrc )
+{
+    char* pzD = strchr(pzSrc, '\n');
+
+    if (pzD == NULL)
+        return;
+    *--pzD = '\n';
+
+    for (;;) {
+        char ch = ((*pzD++) = *(pzSrc++));
+        switch (ch) {
+        case '\n': *--pzD = ch; break;
+        case NUL:  return;
+        default:
+            ;
+        }
+    }
+}
+
+
+/*  scanQuotedString
+ *
+ *  Find the end of a quoted string, skipping escaped quote characters.
+ */
+static char const*
+scanQuotedString( char const* pzTxt )
+{
+    char q = *(pzTxt++); /* remember the type of quote */
+
+    for (;;) {
+        char ch = *(pzTxt++);
+        if (ch == NUL)
+            return pzTxt-1;
+
+        if (ch == q)
+            return pzTxt;
+
+        if (ch == '\\') {
+            ch = *(pzTxt++);
+            /*
+             *  IF the next character is NUL, drop the backslash, too.
+             */
+            if (ch == NUL)
+                return pzTxt - 2;
+
+            /*
+             *  IF the quote character or the escape character were escaped,
+             *  then skip both, as long as the string does not end.
+             */
+            if ((ch == q) || (ch == '\\')) {
+                if (*(pzTxt++) == NUL)
+                    return pzTxt-1;
+            }
+        }
+    }
+}
+
+
+/*  addStringValue
+ *
+ *  Associate a name with either a string or no value.
+ */
+static tOptionValue*
+addStringValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen )
+{
+    tOptionValue* pNV;
+    size_t sz = nameLen + dataLen + sizeof(*pNV);
+
+    pNV = AGALOC( sz, "option name/str value pair" );
+    if (pNV == NULL)
+        return NULL;
+
+    if (pzValue == NULL) {
+        pNV->valType = OPARG_TYPE_NONE;
+        pNV->pzName = pNV->v.strVal;
+
+    } else {
+        pNV->valType = OPARG_TYPE_STRING;
+        if (dataLen > 0)
+            memcpy( pNV->v.strVal, pzValue, dataLen );
+        pNV->v.strVal[dataLen] = NUL;
+        pNV->pzName = pNV->v.strVal + dataLen + 1;
+    }
+
+    memcpy( pNV->pzName, pzName, nameLen );
+    pNV->pzName[ nameLen ] = NUL;
+    addArgListEntry( pp, pNV );
+    return pNV;
+}
+
+
+/*  addBoolValue
+ *
+ *  Associate a name with either a string or no value.
+ */
+static tOptionValue*
+addBoolValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen )
+{
+    tOptionValue* pNV;
+    size_t sz = nameLen + sizeof(*pNV) + 1;
+
+    pNV = AGALOC( sz, "option name/bool value pair" );
+    if (pNV == NULL)
+        return NULL;
+    while (isspace( (int)*pzValue ) && (dataLen > 0)) {
+        dataLen--; pzValue++;
+    }
+    if (dataLen == 0)
+        pNV->v.boolVal = 0;
+    else if (isdigit( (int)*pzValue ))
+        pNV->v.boolVal = atoi( pzValue );
+    else switch (*pzValue) {
+    case 'f':
+    case 'F':
+    case 'n':
+    case 'N':
+        pNV->v.boolVal = 0; break;
+    default:
+        pNV->v.boolVal = 1;
+    }
+
+    pNV->valType = OPARG_TYPE_BOOLEAN;
+    pNV->pzName = (char*)(pNV + 1);
+    memcpy( pNV->pzName, pzName, nameLen );
+    pNV->pzName[ nameLen ] = NUL;
+    addArgListEntry( pp, pNV );
+    return pNV;
+}
+
+
+/*  addNumberValue
+ *
+ *  Associate a name with either a string or no value.
+ */
+static tOptionValue*
+addNumberValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen )
+{
+    tOptionValue* pNV;
+    size_t sz = nameLen + sizeof(*pNV) + 1;
+
+    pNV = AGALOC( sz, "option name/bool value pair" );
+    if (pNV == NULL)
+        return NULL;
+    while (isspace( (int)*pzValue ) && (dataLen > 0)) {
+        dataLen--; pzValue++;
+    }
+    if (dataLen == 0)
+        pNV->v.boolVal = 0;
+    else
+        pNV->v.boolVal = atoi( pzValue );
+
+    pNV->valType = OPARG_TYPE_NUMERIC;
+    pNV->pzName = (char*)(pNV + 1);
+    memcpy( pNV->pzName, pzName, nameLen );
+    pNV->pzName[ nameLen ] = NUL;
+    addArgListEntry( pp, pNV );
+    return pNV;
+}
+
+
+/*  addNestedValue
+ *
+ *  Associate a name with either a string or no value.
+ */
+static tOptionValue*
+addNestedValue( void** pp, char const* pzName, size_t nameLen,
+                char* pzValue, size_t dataLen )
+{
+    tOptionValue* pNV;
+
+    if (dataLen == 0) {
+        size_t sz = nameLen + sizeof(*pNV) + 1;
+        pNV = AGALOC( sz, "empty nested value pair" );
+        if (pNV == NULL)
+            return NULL;
+        pNV->v.nestVal = NULL;
+        pNV->valType = OPARG_TYPE_HIERARCHY;
+        pNV->pzName = (char*)(pNV + 1);
+        memcpy( pNV->pzName, pzName, nameLen );
+        pNV->pzName[ nameLen ] = NUL;
+
+    } else {
+        pNV = optionLoadNested( pzValue, pzName, nameLen );
+    }
+
+    if (pNV != NULL)
+        addArgListEntry( pp, pNV );
+
+    return pNV;
+}
+
+
+/*  scanNameEntry
+ *
+ *  We have an entry that starts with a name.  Find the end of it, cook it
+ *  (if called for) and create the name/value association.
+ */
+static char const*
+scanNameEntry(char const* pzName, tOptionValue* pRes)
+{
+    tOptionValue* pNV;
+    char const * pzScan = pzName+1;
+    char const * pzVal;
+    size_t       nameLen = 1;
+    size_t       dataLen = 0;
+
+    while (ISNAMECHAR( (int)*pzScan ))  { pzScan++; nameLen++; }
+
+    while (isspace( (int)*pzScan )) {
+        char ch = *(pzScan++);
+        if ((ch == '\n') || (ch == ',')) {
+            addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL,(size_t)0);
+            return pzScan - 1;
+        }
+    }
+
+    switch (*pzScan) {
+    case '=':
+    case ':':
+        while (isspace( (int)*++pzScan ))  ;
+        switch (*pzScan) {
+        case ',':  goto comma_char;
+        case '"':
+        case '\'': goto quote_char;
+        case NUL:  goto nul_byte;
+        default:   goto default_char;
+        }
+
+    case ',':
+    comma_char:
+        pzScan++;
+        /* FALLTHROUGH */
+
+    case NUL:
+    nul_byte:
+        addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
+        break;
+
+    case '"':
+    case '\'':
+    quote_char:
+        pzVal = pzScan;
+        pzScan = scanQuotedString( pzScan );
+        dataLen = pzScan - pzVal;
+        pNV = addStringValue( &(pRes->v.nestVal), pzName, nameLen, pzVal,
+                              dataLen );
+        if ((pNV != NULL) && (option_load_mode == OPTION_LOAD_COOKED))
+            ao_string_cook( pNV->v.strVal, NULL );
+        break;
+
+    default:
+    default_char:
+        /*
+         *  We have found some strange text value.  It ends with a newline
+         *  or a comma.
+         */
+        pzVal = pzScan;
+        for (;;) {
+            char ch = *(pzScan++);
+            switch (ch) {
+            case NUL:
+                pzScan--;
+                dataLen = pzScan - pzVal;
+                goto string_done;
+                /* FALLTHROUGH */
+
+            case '\n':
+                if (   (pzScan > pzVal + 2)
+                    && (pzScan[-2] == '\\')
+                    && (pzScan[ 0] != NUL))
+                    continue;
+                /* FALLTHROUGH */
+
+            case ',':
+                dataLen = (pzScan - pzVal) - 1;
+            string_done:
+                pNV = addStringValue( &(pRes->v.nestVal), pzName, nameLen,
+                                      pzVal, dataLen );
+                if (pNV != NULL)
+                    removeBackslashes( pNV->v.strVal );
+                goto leave_scan_name;
+            }
+        }
+        break;
+    } leave_scan_name:;
+
+    return pzScan;
+}
+
+
+/*  scanXmlEntry
+ *
+ *  We've found a '<' character.  We ignore this if it is a comment or a
+ *  directive.  If it is something else, then whatever it is we are looking
+ *  at is bogus.  Returning NULL stops processing.
+ */
+static char const*
+scanXmlEntry( char const* pzName, tOptionValue* pRes )
+{
+    size_t nameLen = 1, valLen = 0;
+    char const*   pzScan = ++pzName;
+    char const*   pzVal;
+    tOptionValue  valu;
+    tOptionValue* pNewVal;
+    tOptionLoadMode save_mode = option_load_mode;
+
+    if (! isalpha((int)*pzName)) {
+        switch (*pzName) {
+        default:
+            pzName = NULL;
+            break;
+
+        case '!':
+            pzName = strstr( pzName, "-->" );
+            if (pzName != NULL)
+                pzName += 3;
+            break;
+
+        case '?':
+            pzName = strchr( pzName, '>' );
+            if (pzName != NULL)
+                pzName++;
+            break;
+        }
+        return pzName;
+    }
+
+    while (isalpha( (int)*++pzScan ))  nameLen++;
+    if (nameLen > 64)
+        return NULL;
+    valu.valType = OPARG_TYPE_STRING;
+
+    switch (*pzScan) {
+    case ' ':
+    case '\t':
+        pzScan = parseAttributes(
+            NULL, (char*)pzScan, &option_load_mode, &valu );
+        if (*pzScan == '>') {
+            pzScan++;
+            break;
+        }
+
+        if (*pzScan != '/') {
+            option_load_mode = save_mode;
+            return NULL;
+        }
+        /* FALLTHROUGH */
+
+    case '/':
+        if (*++pzScan != '>') {
+            option_load_mode = save_mode;
+            return NULL;
+        }
+        addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
+        option_load_mode = save_mode;
+        return pzScan+2;
+
+    default:
+        option_load_mode = save_mode;
+        return NULL;
+
+    case '>':
+        pzScan++;
+        break;
+    }
+
+    pzVal = pzScan;
+
+    {
+        char z[68];
+        char* pzD = z;
+        int  ct = nameLen;
+        char const* pzS = pzName;
+
+        *(pzD++) = '<';
+        *(pzD++) = '/';
+
+        do  {
+            *(pzD++) = *(pzS++);
+        } while (--ct > 0);
+        *(pzD++) = '>';
+        *pzD = NUL;
+
+        pzScan = strstr( pzScan, z );
+        if (pzScan == NULL) {
+            option_load_mode = save_mode;
+            return NULL;
+        }
+        valLen = (pzScan - pzVal);
+        pzScan += nameLen + 3;
+        while (isspace(  (int)*pzScan ))  pzScan++;
+    }
+
+    switch (valu.valType) {
+    case OPARG_TYPE_NONE:
+        addStringValue( &(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
+        break;
+
+    case OPARG_TYPE_STRING:
+        pNewVal = addStringValue(
+            &(pRes->v.nestVal), pzName, nameLen, pzVal, valLen);
+
+        if (option_load_mode == OPTION_LOAD_KEEP)
+            break;
+        mungeString( pNewVal->v.strVal, option_load_mode );
+        break;
+
+    case OPARG_TYPE_BOOLEAN:
+        addBoolValue( &(pRes->v.nestVal), pzName, nameLen, pzVal, valLen );
+        break;
+
+    case OPARG_TYPE_NUMERIC:
+        addNumberValue( &(pRes->v.nestVal), pzName, nameLen, pzVal, valLen );
+        break;
+
+    case OPARG_TYPE_HIERARCHY:
+    {
+        char* pz = AGALOC( valLen+1, "hierarchical scan" );
+        if (pz == NULL)
+            break;
+        memcpy( pz, pzVal, valLen );
+        pz[valLen] = NUL;
+        addNestedValue( &(pRes->v.nestVal), pzName, nameLen, pz, valLen );
+        AGFREE(pz);
+        break;
+    }
+
+    case OPARG_TYPE_ENUMERATION:
+    case OPARG_TYPE_MEMBERSHIP:
+    default:
+        break;
+    }
+
+    option_load_mode = save_mode;
+    return pzScan;
+}
+
+
+/*  unloadNestedArglist
+ *
+ *  Deallocate a list of option arguments.  This must have been gotten from
+ *  a hierarchical option argument, not a stacked list of strings.  It is
+ *  an internal call, so it is not validated.  The caller is responsible for
+ *  knowing what they are doing.
+ */
+static void
+unloadNestedArglist( tArgList* pAL )
+{
+    int ct = pAL->useCt;
+    tCC** ppNV = pAL->apzArgs;
+
+    while (ct-- > 0) {
+        tOptionValue* pNV = (tOptionValue*)(void*)*(ppNV++);
+        if (pNV->valType == OPARG_TYPE_HIERARCHY)
+            unloadNestedArglist( pNV->v.nestVal );
+        AGFREE( pNV );
+    }
+
+    AGFREE( (void*)pAL );
+}
+
+
+/*=export_func  optionUnloadNested
+ *
+ * what:  Deallocate the memory for a nested value
+ * arg:   + tOptionValue const * + pOptVal + the hierarchical value +
+ *
+ * doc:
+ *  A nested value needs to be deallocated.  The pointer passed in should
+ *  have been gotten from a call to @code{configFileLoad()} (See
+ *  @pxref{libopts-configFileLoad}).
+=*/
+void
+optionUnloadNested( tOptionValue const * pOV )
+{
+    if (pOV == NULL) return;
+    if (pOV->valType != OPARG_TYPE_HIERARCHY) {
+        errno = EINVAL;
+        return;
+    }
+
+    unloadNestedArglist( pOV->v.nestVal );
+
+    AGFREE( (void*)pOV );
+}
+
+
+/*  sortNestedList
+ *
+ *  This is a _stable_ sort.  The entries are sorted alphabetically,
+ *  but within entries of the same name the ordering is unchanged.
+ *  Typically, we also hope the input is sorted.
+ */
+static void
+sortNestedList( tArgList* pAL )
+{
+    int ix;
+    int lm = pAL->useCt;
+
+    /*
+     *  This loop iterates "useCt" - 1 times.
+     */
+    for (ix = 0; ++ix < lm;) {
+        int iy = ix-1;
+        tOptionValue* pNewNV = (tOptionValue*)(void*)(pAL->apzArgs[ix]);
+        tOptionValue* pOldNV = (tOptionValue*)(void*)(pAL->apzArgs[iy]);
+
+        /*
+         *  For as long as the new entry precedes the "old" entry,
+         *  move the old pointer.  Stop before trying to extract the
+         *  "-1" entry.
+         */
+        while (strcmp( pOldNV->pzName, pNewNV->pzName ) > 0) {
+            pAL->apzArgs[iy+1] = (void*)pOldNV;
+            pOldNV = (tOptionValue*)(void*)(pAL->apzArgs[--iy]);
+            if (iy < 0)
+                break;
+        }
+
+        /*
+         *  Always store the pointer.  Sometimes it is redundant,
+         *  but the redundancy is cheaper than a test and branch sequence.
+         */
+        pAL->apzArgs[iy+1] = (void*)pNewNV;
+    }
+}
+
+
+/* optionLoadNested
+ * private:
+ *
+ * what:  parse a hierarchical option argument
+ * arg:   + char const*     + pzTxt   + the text to scan +
+ * arg:   + char const*     + pzName  + the name for the text +
+ * arg:   + size_t          + nameLen + the length of "name"  +
+ *
+ * ret_type:  tOptionValue*
+ * ret_desc:  An allocated, compound value structure
+ *
+ * doc:
+ *  A block of text represents a series of values.  It may be an
+ *  entire configuration file, or it may be an argument to an
+ *  option that takes a hierarchical value.
+ */
+LOCAL tOptionValue*
+optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen)
+{
+    tOptionValue* pRes;
+    tArgList*     pAL;
+
+    /*
+     *  Make sure we have some data and we have space to put what we find.
+     */
+    if (pzTxt == NULL) {
+        errno = EINVAL;
+        return NULL;
+    }
+    while (isspace( (int)*pzTxt ))  pzTxt++;
+    if (*pzTxt == NUL) {
+        errno = ENOENT;
+        return NULL;
+    }
+    pRes = AGALOC( sizeof(*pRes) + nameLen + 1, "nested args" );
+    if (pRes == NULL) {
+        errno = ENOMEM;
+        return NULL;
+    }
+    pRes->valType   = OPARG_TYPE_HIERARCHY;
+    pRes->pzName    = (char*)(pRes + 1);
+    memcpy( pRes->pzName, pzName, nameLen );
+    pRes->pzName[ nameLen ] = NUL;
+
+    pAL = AGALOC( sizeof(*pAL), "nested arg list" );
+    if (pAL == NULL) {
+        AGFREE( pRes );
+        return NULL;
+    }
+    pRes->v.nestVal = pAL;
+    pAL->useCt   = 0;
+    pAL->allocCt = MIN_ARG_ALLOC_CT;
+
+    /*
+     *  Scan until we hit a NUL.
+     */
+    do  {
+        while (isspace( (int)*pzTxt ))  pzTxt++;
+        if (isalpha( (int)*pzTxt )) {
+            pzTxt = scanNameEntry( pzTxt, pRes );
+        }
+        else switch (*pzTxt) {
+        case NUL: goto scan_done;
+        case '<': pzTxt = scanXmlEntry( pzTxt, pRes );
+                  if (*pzTxt == ',') pzTxt++;     break;
+        case '#': pzTxt = strchr( pzTxt, '\n' );  break;
+        default:  goto woops;
+        }
+    } while (pzTxt != NULL); scan_done:;
+
+    pAL = pRes->v.nestVal;
+    if (pAL->useCt != 0) {
+        sortNestedList( pAL );
+        return pRes;
+    }
+
+ woops:
+    AGFREE( pRes->v.nestVal );
+    AGFREE( pRes );
+    return NULL;
+}
+
+
+/*=export_func  optionNestedVal
+ * private:
+ *
+ * what:  parse a hierarchical option argument
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Nested value was found on the command line
+=*/
+void
+optionNestedVal( tOptions* pOpts, tOptDesc* pOD )
+{
+    tOptionValue* pOV = optionLoadNested(
+        pOD->optArg.argString, pOD->pz_Name, strlen(pOD->pz_Name));
+
+    if (pOV != NULL)
+        addArgListEntry( &(pOD->optCookie), (void*)pOV );
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/nested.c */
diff --git a/libopts/numeric.c b/libopts/numeric.c
new file mode 100644 (file)
index 0000000..05ee9b5
--- /dev/null
@@ -0,0 +1,93 @@
+
+/*
+ *  $Id: numeric.c,v 4.11 2007/02/04 17:44:12 bkorb Exp $
+ *  Time-stamp:      "2007-01-13 10:28:20 bkorb"
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/*=export_func  optionNumericVal
+ * private:
+ *
+ * what:  Decipher a boolean value
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Decipher a numeric value.
+=*/
+void
+optionNumericVal( tOptions* pOpts, tOptDesc* pOD )
+{
+    char* pz;
+    long  val;
+
+    /*
+     *  Numeric options may have a range associated with it.
+     *  If it does, the usage procedure requests that it be
+     *  emitted by passing a NULL pOD pointer.
+     */
+    if ((pOD == NULL) || (pOD->optArg.argString == NULL))
+        return;
+
+    val = strtol( pOD->optArg.argString, &pz, 0 );
+    if (*pz != NUL) {
+        fprintf( stderr, zNotNumber, pOpts->pzProgName, pOD->optArg.argString );
+        (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
+    }
+
+    if (pOD->fOptState & OPTST_ALLOC_ARG) {
+        AGFREE(pOD->optArg.argString);
+        pOD->fOptState &= ~OPTST_ALLOC_ARG;
+    }
+
+    pOD->optArg.argInt = val;
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/numeric.c */
diff --git a/libopts/pgusage.c b/libopts/pgusage.c
new file mode 100644 (file)
index 0000000..c417c63
--- /dev/null
@@ -0,0 +1,157 @@
+
+/*
+ *  $Id: pgusage.c,v 4.12 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2006-07-16 08:13:26 bkorb"
+ *
+ *   Automated Options Paged Usage module.
+ *
+ *  This routine will run run-on options through a pager so the
+ *  user may examine, print or edit them at their leisure.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+tePagerState pagerState = PAGER_STATE_INITIAL;
+
+/*=export_func  optionPagedUsage
+ * private:
+ *
+ * what:  Decipher a boolean value
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Run the usage output through a pager.
+ *  This is very handy if it is very long.
+=*/
+void
+optionPagedUsage( tOptions* pOptions, tOptDesc* pOD )
+{
+#if defined(__windows__) && !defined(__CYGWIN__)
+    (*pOptions->pUsageProc)( pOptions, EXIT_SUCCESS );
+#else
+    static pid_t     my_pid;
+    char zPageUsage[ 1024 ];
+
+    /*
+     *  IF we are being called after the usage proc is done
+     *     (and thus has called "exit(2)")
+     *  THEN invoke the pager to page through the usage file we created.
+     */
+    switch (pagerState) {
+    case PAGER_STATE_INITIAL:
+    {
+        my_pid  = getpid();
+#ifdef HAVE_SNPRINTF
+        snprintf(zPageUsage, sizeof(zPageUsage), "/tmp/use.%lu", (tAoUL)my_pid);
+#else
+        sprintf( zPageUsage, "/tmp/use.%lu", (tAoUL)my_pid );
+#endif
+        unlink( zPageUsage );
+
+        /*
+         *  Set usage output to this temporary file
+         */
+        option_usage_fp = fopen( zPageUsage, "w" FOPEN_BINARY_FLAG );
+        if (option_usage_fp == NULL)
+            _exit( EXIT_FAILURE );
+
+        pagerState = PAGER_STATE_READY;
+
+        /*
+         *  Set up so this routine gets called during the exit logic
+         */
+        atexit( (void(*)(void))optionPagedUsage );
+
+        /*
+         *  The usage procedure will now put the usage information into
+         *  the temporary file we created above.
+         */
+        (*pOptions->pUsageProc)( pOptions, EXIT_SUCCESS );
+
+        /*NOTREACHED*/
+        _exit( EXIT_FAILURE );
+    }
+
+    case PAGER_STATE_READY:
+    {
+        tSCC zPage[]  = "%1$s /tmp/use.%2$lu ; rm -f /tmp/use.%2$lu";
+        tCC* pzPager  = (tCC*)getenv( "PAGER" );
+
+        /*
+         *  Use the "more(1)" program if "PAGER" has not been defined
+         */
+        if (pzPager == NULL)
+            pzPager = "more";
+
+        /*
+         *  Page the file and remove it when done.
+         */
+#ifdef HAVE_SNPRINTF
+        snprintf(zPageUsage, sizeof(zPageUsage), zPage, pzPager, (tAoUL)my_pid);
+#else
+        sprintf( zPageUsage, zPage, pzPager, (tAoUL)my_pid );
+#endif
+        fclose( stderr );
+        dup2( STDOUT_FILENO, STDERR_FILENO );
+
+        (void)system( zPageUsage );
+    }
+
+    case PAGER_STATE_CHILD:
+        /*
+         *  This is a child process used in creating shell script usage.
+         */
+        break;
+    }
+#endif
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/pgusage.c */
diff --git a/libopts/proto.h b/libopts/proto.h
new file mode 100644 (file)
index 0000000..e87ab87
--- /dev/null
@@ -0,0 +1,91 @@
+/* -*- buffer-read-only: t -*- vi: set ro:
+ *
+ * Prototypes for autoopts
+ * Generated Sat May  5 12:02:36 PDT 2007
+ */
+#ifndef AUTOOPTS_PROTO_H_GUARD
+#define AUTOOPTS_PROTO_H_GUARD 1
+#ifndef LOCAL
+#  define LOCAL extern
+#  define REDEF_LOCAL 1
+#else
+#  undef  REDEF_LOCAL
+#endif
+/*\n *  Extracted from autoopts.c\n */
+LOCAL void *
+ao_malloc( size_t sz );
+
+LOCAL void *
+ao_realloc( void *p, size_t sz );
+
+LOCAL void
+ao_free( void *p );
+
+LOCAL char *
+ao_strdup( char const *str );
+
+LOCAL tSuccess
+handleOption( tOptions* pOpts, tOptState* pOptState );
+
+LOCAL tSuccess
+longOptionFind( tOptions* pOpts, char* pzOptName, tOptState* pOptState );
+
+LOCAL tSuccess
+shortOptionFind( tOptions* pOpts, uint_t optValue, tOptState* pOptState );
+
+LOCAL tSuccess
+doImmediateOpts( tOptions* pOpts );
+
+LOCAL tSuccess
+doRegularOpts( tOptions* pOpts );
+
+/*\n *  Extracted from configfile.c\n */
+LOCAL void
+internalFileLoad( tOptions* pOpts );
+
+LOCAL char*
+parseAttributes(
+    tOptions*           pOpts,
+    char*               pzText,
+    tOptionLoadMode*    pMode,
+    tOptionValue*       pType );
+
+LOCAL tSuccess
+validateOptionsStruct( tOptions* pOpts, char const* pzProgram );
+
+/*\n *  Extracted from environment.c\n */
+LOCAL void
+doPrognameEnv( tOptions* pOpts, teEnvPresetType type );
+
+LOCAL void
+doEnvPresets( tOptions* pOpts, teEnvPresetType type );
+
+/*\n *  Extracted from load.c\n */
+LOCAL void
+mungeString( char* pzTxt, tOptionLoadMode mode );
+
+LOCAL void
+loadOptionLine(
+    tOptions*   pOpts,
+    tOptState*  pOS,
+    char*       pzLine,
+    tDirection  direction,
+    tOptionLoadMode   load_mode );
+
+/*\n *  Extracted from nested.c\n */
+LOCAL tOptionValue*
+optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen);
+
+/*\n *  Extracted from sort.c\n */
+LOCAL void
+optionSort( tOptions* pOpts );
+
+/*\n *  Extracted from stack.c\n */
+LOCAL void
+addArgListEntry( void** ppAL, void* entry );
+
+#ifdef REDEF_LOCAL
+#  undef LOCAL
+#  define LOCAL
+#endif
+#endif /* AUTOOPTS_PROTO_H_GUARD */
diff --git a/libopts/putshell.c b/libopts/putshell.c
new file mode 100644 (file)
index 0000000..93d9ef5
--- /dev/null
@@ -0,0 +1,335 @@
+
+/*
+ *  $Id: putshell.c,v 4.18 2007/02/04 17:44:12 bkorb Exp $
+ * Time-stamp:      "2007-01-13 10:29:39 bkorb"
+ *
+ *  This module will interpret the options set in the tOptions
+ *  structure and print them to standard out in a fashion that
+ *  will allow them to be interpreted by the Bourne or Korn shells.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+putQuotedStr( tCC* pzStr );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*
+ *  Make sure embedded single quotes come out okay.  The initial quote has
+ *  been emitted and the closing quote will be upon return.
+ */
+static void
+putQuotedStr( tCC* pzStr )
+{
+    /*
+     *  Handle empty strings to make the rest of the logic simpler.
+     */
+    if ((pzStr == NULL) || (*pzStr == NUL)) {
+        fputs( "''", stdout );
+        return;
+    }
+
+    /*
+     *  Emit any single quotes/apostrophes at the start of the string and
+     *  bail if that is all we need to do.
+     */
+    while (*pzStr == '\'') {
+        fputs( "\\'", stdout );
+        pzStr++;
+    }
+    if (*pzStr == NUL)
+        return;
+
+    /*
+     *  Start the single quote string
+     */
+    fputc( '\'', stdout );
+    for (;;) {
+        tCC* pz = strchr( pzStr, '\'' );
+        if (pz == NULL)
+            break;
+
+        /*
+         *  Emit the string up to the single quote (apostrophe) we just found.
+         */
+        (void)fwrite( pzStr, (size_t)(pz - pzStr), (size_t)1, stdout );
+        fputc( '\'', stdout );
+        pzStr = pz;
+
+        /*
+         *  Emit an escaped apostrophe for every one we find.
+         *  If that ends the string, do not re-open the single quotes.
+         */
+        while (*++pzStr == '\'')   fputs( "\\'", stdout );
+        if (*pzStr == NUL)
+            return;
+
+        fputc( '\'', stdout );
+    }
+
+    /*
+     *  If we broke out of the loop, we must still emit the remaining text
+     *  and then close the single quote string.
+     */
+    fputs( pzStr, stdout );
+    fputc( '\'', stdout );
+}
+
+
+/*=export_func  optionPutShell
+ * what:  write a portable shell script to parse options
+ * private:
+ * arg:   tOptions*, pOpts, the program options descriptor
+ * doc:   This routine will emit portable shell script text for parsing
+ *        the options described in the option definitions.
+=*/
+void
+optionPutShell( tOptions* pOpts )
+{
+    int  optIx = 0;
+    tSCC zOptCtFmt[]  = "OPTION_CT=%d\nexport OPTION_CT\n";
+    tSCC zOptNumFmt[] = "%1$s_%2$s=%3$d # 0x%3$X\nexport %1$s_%2$s\n";
+    tSCC zOptDisabl[] = "%1$s_%2$s=%3$s\nexport %1$s_%2$s\n";
+    tSCC zOptValFmt[] = "%s_%s=";
+    tSCC zOptEnd[]    = "\nexport %s_%s\n";
+    tSCC zFullOptFmt[]= "%1$s_%2$s='%3$s'\nexport %1$s_%2$s\n";
+    tSCC zEquivMode[] = "%1$s_%2$s_MODE='%3$s'\nexport %1$s_%2$s_MODE\n";
+
+    printf( zOptCtFmt, pOpts->curOptIdx-1 );
+
+    do  {
+        tOptDesc* pOD = pOpts->pOptDesc + optIx;
+
+        if (SKIP_OPT(pOD))
+            continue;
+
+        /*
+         *  Equivalence classes are hard to deal with.  Where the
+         *  option data wind up kind of squishes around.  For the purposes
+         *  of emitting shell state, they are not recommended, but we'll
+         *  do something.  I guess we'll emit the equivalenced-to option
+         *  at the point in time when the base option is found.
+         */
+        if (pOD->optEquivIndex != NO_EQUIVALENT)
+            continue; /* equivalence to a different option */
+
+        /*
+         *  Equivalenced to a different option.  Process the current option
+         *  as the equivalenced-to option.  Keep the persistent state bits,
+         *  but copy over the set-state bits.
+         */
+        if (pOD->optActualIndex != optIx) {
+            tOptDesc* p   = pOpts->pOptDesc + pOD->optActualIndex;
+            p->optArg     = pOD->optArg;
+            p->fOptState &= OPTST_PERSISTENT_MASK;
+            p->fOptState |= pOD->fOptState & ~OPTST_PERSISTENT_MASK;
+            printf( zEquivMode, pOpts->pzPROGNAME, pOD->pz_NAME, p->pz_NAME );
+            pOD = p;
+        }
+
+        /*
+         *  If the argument type is a set membership bitmask, then we always
+         *  emit the thing.  We do this because it will always have some sort
+         *  of bitmask value and we need to emit the bit values.
+         */
+        if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP) {
+            char const * pz;
+            uintptr_t val = 1;
+            printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
+                    (int)(uintptr_t)(pOD->optCookie) );
+            pOD->optCookie = (void*)(uintptr_t)~0UL;
+            (*(pOD->pOptProc))( (tOptions*)2UL, pOD );
+
+            /*
+             *  We are building the typeset list.  The list returned starts with
+             *  'none + ' for use by option saving stuff.  We must ignore that.
+             */
+            pz = pOD->optArg.argString + 7;
+            while (*pz != NUL) {
+                printf( "typeset -x -i %s_", pOD->pz_NAME );
+                pz += strspn( pz, " +\t\n\f" );
+                for (;;) {
+                    int ch = *(pz++);
+                         if (islower( ch ))  fputc( toupper( ch ), stdout );
+                    else if (isalnum( ch ))  fputc( ch, stdout );
+                    else if (isspace( ch )
+                          || (ch == '+'))    goto name_done;
+                    else if (ch == NUL)      { pz--; goto name_done; }
+                    else fputc( '_', stdout );
+                } name_done:;
+                printf( "=%1$lu # 0x%1$lX\n", (unsigned long)val );
+                val <<= 1;
+            }
+
+            AGFREE(pOD->optArg.argString);
+            pOD->optArg.argString = NULL;
+            pOD->fOptState &= ~OPTST_ALLOC_ARG;
+            continue;
+        }
+
+        /*
+         *  IF the option was either specified or it wakes up enabled,
+         *  then we will emit information.  Otherwise, skip it.
+         *  The idea is that if someone defines an option to initialize
+         *  enabled, we should tell our shell script that it is enabled.
+         */
+        if (UNUSED_OPT( pOD ) && DISABLED_OPT( pOD ))
+            continue;
+
+        /*
+         *  Handle stacked arguments
+         */
+        if (  (pOD->fOptState & OPTST_STACKED)
+           && (pOD->optCookie != NULL) )  {
+            tSCC zOptCookieCt[] = "%1$s_%2$s_CT=%3$d\nexport %1$s_%2$s_CT\n";
+
+            tArgList*    pAL = (tArgList*)pOD->optCookie;
+            tCC**        ppz = pAL->apzArgs;
+            int          ct  = pAL->useCt;
+
+            printf( zOptCookieCt, pOpts->pzPROGNAME, pOD->pz_NAME, ct );
+
+            while (--ct >= 0) {
+                tSCC numarg_z[] = "%s_%s_%d=";
+                tSCC end_z[]    = "\nexport %s_%s_%d\n";
+
+                printf( numarg_z, pOpts->pzPROGNAME, pOD->pz_NAME,
+                        pAL->useCt - ct );
+                putQuotedStr( *(ppz++) );
+                printf( end_z, pOpts->pzPROGNAME, pOD->pz_NAME,
+                        pAL->useCt - ct );
+            }
+        }
+
+        /*
+         *  If the argument has been disabled,
+         *  Then set its value to the disablement string
+         */
+        else if ((pOD->fOptState & OPTST_DISABLED) != 0)
+            printf( zOptDisabl, pOpts->pzPROGNAME, pOD->pz_NAME,
+                    (pOD->pz_DisablePfx != NULL)
+                    ? pOD->pz_DisablePfx : "false" );
+
+        /*
+         *  If the argument type is numeric, the last arg pointer
+         *  is really the VALUE of the string that was pointed to.
+         */
+        else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NUMERIC)
+            printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
+                    (int)pOD->optArg.argInt );
+
+        /*
+         *  If the argument type is an enumeration, then it is much
+         *  like a text value, except we call the callback function
+         *  to emit the value corresponding to the "optArg" number.
+         */
+        else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_ENUMERATION) {
+            printf( zOptValFmt, pOpts->pzPROGNAME, pOD->pz_NAME );
+            fputc( '\'', stdout );
+            (*(pOD->pOptProc))( (tOptions*)1UL, pOD );
+            fputc( '\'', stdout );
+            printf( zOptEnd, pOpts->pzPROGNAME, pOD->pz_NAME );
+        }
+
+        /*
+         *  If the argument type is numeric, the last arg pointer
+         *  is really the VALUE of the string that was pointed to.
+         */
+        else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_BOOLEAN)
+            printf( zFullOptFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
+                    (pOD->optArg.argBool == 0) ? "false" : "true" );
+
+        /*
+         *  IF the option has an empty value,
+         *  THEN we set the argument to the occurrence count.
+         */
+        else if (  (pOD->optArg.argString == NULL)
+                || (pOD->optArg.argString[0] == NUL) )
+
+            printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
+                    pOD->optOccCt );
+
+        /*
+         *  This option has a text value
+         */
+        else {
+            printf( zOptValFmt, pOpts->pzPROGNAME, pOD->pz_NAME );
+            putQuotedStr( pOD->optArg.argString );
+            printf( zOptEnd, pOpts->pzPROGNAME, pOD->pz_NAME );
+        }
+    } while (++optIx < pOpts->presetOptCt );
+
+    if (  ((pOpts->fOptSet & OPTPROC_REORDER) != 0)
+       && (pOpts->curOptIdx < pOpts->origArgCt)) {
+        fputs( "set --", stdout );
+        for (optIx = pOpts->curOptIdx; optIx < pOpts->origArgCt; optIx++) {
+            char* pzArg = pOpts->origArgVect[ optIx ];
+            if (strchr( pzArg, '\'' ) == NULL)
+                printf( " '%s'", pzArg );
+            else {
+                fputs( " '", stdout );
+                for (;;) {
+                    char ch = *(pzArg++);
+                    switch (ch) {
+                    case '\'':  fputs( "'\\''", stdout ); break;
+                    case NUL:   goto arg_done;
+                    default:    fputc( ch, stdout ); break;
+                    }
+                } arg_done:;
+                fputc( '\'', stdout );
+            }
+        }
+        fputs( "\nOPTION_CT=0\n", stdout );
+    }
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/putshell.c */
diff --git a/libopts/restore.c b/libopts/restore.c
new file mode 100644 (file)
index 0000000..91eac08
--- /dev/null
@@ -0,0 +1,250 @@
+
+/*
+ *  restore.c  $Id: restore.c,v 4.10 2007/02/04 17:44:12 bkorb Exp $
+ * Time-stamp:      "2007-01-13 14:13:17 bkorb"
+ *
+ *  This module's routines will save the current option state to memory
+ *  and restore it.  If saved prior to the initial optionProcess call,
+ *  then the initial state will be restored.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/*
+ *  optionFixupSavedOpts  Really, it just wipes out option state for
+ *  options that are troublesome to copy.  viz., stacked strings and
+ *  hierarcicaly valued option args.  We do duplicate string args that
+ *  have been marked as allocated though.
+ */
+static void
+fixupSavedOptionArgs(tOptions* pOpts)
+{
+    tOptions* p   = pOpts->pSavedState;
+    tOptDesc* pOD = pOpts->pOptDesc;
+    int       ct  = pOpts->optCt;
+
+    /*
+     *  Make sure that allocated stuff is only referenced in the
+     *  archived copy of the data.
+     */
+    for (; ct-- > 0; pOD++)  {
+        switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+        case OPARG_TYPE_STRING:
+            if (pOD->fOptState & OPTST_STACKED) {
+                tOptDesc* q = p->pOptDesc + (pOD - pOpts->pOptDesc);
+                q->optCookie = NULL;
+            }
+            if (pOD->fOptState & OPTST_ALLOC_ARG) {
+                tOptDesc* q = p->pOptDesc + (pOD - pOpts->pOptDesc);
+                AGDUPSTR(q->optArg.argString, pOD->optArg.argString, "arg");
+            }
+            break;
+
+        case OPARG_TYPE_HIERARCHY:
+        {
+            tOptDesc* q = p->pOptDesc + (pOD - pOpts->pOptDesc);
+            q->optCookie = NULL;
+        }
+        }
+    }
+}
+
+/*=export_func optionSaveState
+ *
+ * what:  saves the option state to memory
+ * arg:   tOptions*, pOpts, program options descriptor
+ *
+ * doc:
+ *
+ *  This routine will allocate enough memory to save the current option
+ *  processing state.  If this routine has been called before, that memory
+ *  will be reused.  You may only save one copy of the option state.  This
+ *  routine may be called before optionProcess(3AO).  If you do call it
+ *  before the first call to optionProcess, then you may also change the
+ *  contents of argc/argv after you call optionRestore(3AO)
+ *
+ *  In fact, more strongly put: it is safest to only use this function
+ *  before having processed any options.  In particular, the saving and
+ *  restoring of stacked string arguments and hierarchical values is
+ *  disabled.  The values are not saved.
+ *
+ * err:   If it fails to allocate the memory,
+ *        it will print a message to stderr and exit.
+ *        Otherwise, it will always succeed.
+=*/
+void
+optionSaveState(tOptions* pOpts)
+{
+    tOptions* p = (tOptions*)pOpts->pSavedState;
+
+    if (p == NULL) {
+        size_t sz = sizeof( *pOpts ) + (pOpts->optCt * sizeof( tOptDesc ));
+        p = AGALOC( sz, "saved option state" );
+        if (p == NULL) {
+            tCC* pzName = pOpts->pzProgName;
+            if (pzName == NULL) {
+                pzName = pOpts->pzPROGNAME;
+                if (pzName == NULL)
+                    pzName = zNil;
+            }
+            fprintf( stderr, zCantSave, pzName, sz );
+            exit( EXIT_FAILURE );
+        }
+
+        pOpts->pSavedState = p;
+    }
+
+    memcpy( p, pOpts, sizeof( *p ));
+    memcpy( p + 1, pOpts->pOptDesc, p->optCt * sizeof( tOptDesc ));
+
+    fixupSavedOptionArgs(pOpts);
+}
+
+
+/*=export_func optionRestore
+ *
+ * what:  restore option state from memory copy
+ * arg:   tOptions*, pOpts, program options descriptor
+ *
+ * doc:  Copy back the option state from saved memory.
+ *       The allocated memory is left intact, so this routine can be
+ *       called repeatedly without having to call optionSaveState again.
+ *       If you are restoring a state that was saved before the first call
+ *       to optionProcess(3AO), then you may change the contents of the
+ *       argc/argv parameters to optionProcess.
+ *
+ * err:  If you have not called @code{optionSaveState} before, a diagnostic is
+ *       printed to @code{stderr} and exit is called.
+=*/
+void
+optionRestore( tOptions* pOpts )
+{
+    tOptions* p = (tOptions*)pOpts->pSavedState;
+
+    if (p == NULL) {
+        tCC* pzName = pOpts->pzProgName;
+        if (pzName == NULL) {
+            pzName = pOpts->pzPROGNAME;
+            if (pzName == NULL)
+                pzName = zNil;
+        }
+        fprintf( stderr, zNoState, pzName );
+        exit( EXIT_FAILURE );
+    }
+
+    pOpts->pSavedState = NULL;
+    optionFree(pOpts);
+
+    memcpy( pOpts, p, sizeof( *p ));
+    memcpy( pOpts->pOptDesc, p+1, p->optCt * sizeof( tOptDesc ));
+    pOpts->pSavedState = p;
+
+    fixupSavedOptionArgs(pOpts);
+}
+
+/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
+
+/*=export_func optionFree
+ *
+ * what:  free allocated option processing memory
+ * arg:   tOptions*, pOpts, program options descriptor
+ *
+ * doc:   AutoOpts sometimes allocates memory and puts pointers to it in the
+ *        option state structures.  This routine deallocates all such memory.
+ *
+ * err:   As long as memory has not been corrupted,
+ *        this routine is always successful.
+=*/
+void
+optionFree( tOptions* pOpts )
+{
+ free_saved_state:
+    {
+        tOptDesc* p = pOpts->pOptDesc;
+        int ct = pOpts->optCt;
+        do  {
+            if (p->fOptState & OPTST_ALLOC_ARG) {
+                AGFREE(p->optArg.argString);
+                p->optArg.argString = NULL;
+                p->fOptState &= ~OPTST_ALLOC_ARG;
+            }
+
+            switch (OPTST_GET_ARGTYPE(p->fOptState)) {
+            case OPARG_TYPE_STRING:
+#ifdef WITH_LIBREGEX
+                if (  (p->fOptState & OPTST_STACKED)
+                   && (p->optCookie != NULL)) {
+                    p->optArg.argString = ".*";
+                    optionUnstackArg(pOpts, p);
+                }
+#else
+                /* leak memory */;
+#endif
+                break;
+
+            case OPARG_TYPE_HIERARCHY:
+                if (p->optCookie != NULL)
+                    unloadNestedArglist(p->optCookie);
+                break;
+            }
+
+            p->optCookie = NULL;
+        } while (p++, --ct > 0);
+    }
+    if (pOpts->pSavedState != NULL) {
+        tOptions * p = (tOptions*)pOpts->pSavedState;
+        memcpy( pOpts, p, sizeof( *p ));
+        memcpy( pOpts->pOptDesc, p+1, p->optCt * sizeof( tOptDesc ));
+        AGFREE( pOpts->pSavedState );
+        pOpts->pSavedState = NULL;
+        goto free_saved_state;
+    }
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/restore.c */
diff --git a/libopts/save.c b/libopts/save.c
new file mode 100644 (file)
index 0000000..c889520
--- /dev/null
@@ -0,0 +1,521 @@
+
+/*
+ *  save.c  $Id: save.c,v 4.18 2007/04/15 19:01:18 bkorb Exp $
+ * Time-stamp:      "2007-04-15 11:11:10 bkorb"
+ *
+ *  This module's routines will take the currently set options and
+ *  store them into an ".rc" file for re-interpretation the next
+ *  time the invoking program is run.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+tSCC  zWarn[] = "%s WARNING:  cannot save options - ";
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static tCC*
+findDirName( tOptions* pOpts, int* p_free );
+
+static tCC*
+findFileName( tOptions* pOpts, int* p_free_name );
+
+static void
+printEntry(
+    FILE *     fp,
+    tOptDesc * p,
+    tCC*       pzLA );
+/* = = = END-STATIC-FORWARD = = = */
+
+static tCC*
+findDirName( tOptions* pOpts, int* p_free )
+{
+    tCC*  pzDir;
+
+    if (pOpts->specOptIdx.save_opts == 0)
+        return NULL;
+
+    pzDir = pOpts->pOptDesc[ pOpts->specOptIdx.save_opts ].optArg.argString;
+    if ((pzDir != NULL) && (*pzDir != NUL))
+        return pzDir;
+
+    /*
+     *  This function only works if there is a directory where
+     *  we can stash the RC (INI) file.
+     */
+    {
+        tCC* const* papz = pOpts->papzHomeList;
+        if (papz == NULL)
+            return NULL;
+
+        while (papz[1] != NULL) papz++;
+        pzDir = *papz;
+    }
+
+    /*
+     *  IF it does not require deciphering an env value, then just copy it
+     */
+    if (*pzDir != '$')
+        return pzDir;
+
+    {
+        tCC*  pzEndDir = strchr( ++pzDir, DIRCH );
+        char* pzFileName;
+        char* pzEnv;
+
+        if (pzEndDir != NULL) {
+            char z[ AO_NAME_SIZE ];
+            if ((pzEndDir - pzDir) > AO_NAME_LIMIT )
+                return NULL;
+            strncpy( z, pzDir, (size_t)(pzEndDir - pzDir) );
+            z[ (pzEndDir - pzDir) ] = NUL;
+            pzEnv = getenv( z );
+        } else {
+
+            /*
+             *  Make sure we can get the env value (after stripping off
+             *  any trailing directory or file names)
+             */
+            pzEnv = getenv( pzDir );
+        }
+
+        if (pzEnv == NULL) {
+            fprintf( stderr, zWarn, pOpts->pzProgName );
+            fprintf( stderr, zNotDef, pzDir );
+            return NULL;
+        }
+
+        if (pzEndDir == NULL)
+            return pzEnv;
+
+        {
+            size_t sz = strlen( pzEnv ) + strlen( pzEndDir ) + 2;
+            pzFileName = (char*)AGALOC( sz, "dir name" );
+        }
+
+        if (pzFileName == NULL)
+            return NULL;
+
+        *p_free = 1;
+        /*
+         *  Glue together the full name into the allocated memory.
+         *  FIXME: We lose track of this memory.
+         */
+        sprintf( pzFileName, "%s/%s", pzEnv, pzEndDir );
+        return pzFileName;
+    }
+}
+
+
+static tCC*
+findFileName( tOptions* pOpts, int* p_free_name )
+{
+    tCC*   pzDir;
+    struct stat stBuf;
+    int    free_dir_name = 0;
+
+    pzDir = findDirName( pOpts, &free_dir_name );
+    if (pzDir == NULL)
+        return NULL;
+
+    /*
+     *  See if we can find the specified directory.  We use a once-only loop
+     *  structure so we can bail out early.
+     */
+    if (stat( pzDir, &stBuf ) != 0) do {
+
+        /*
+         *  IF we could not, check to see if we got a full
+         *  path to a file name that has not been created yet.
+         */
+        if (errno == ENOENT) {
+            char z[AG_PATH_MAX];
+
+            /*
+             *  Strip off the last component, stat the remaining string and
+             *  that string must name a directory
+             */
+            char* pzDirCh = strrchr( pzDir, DIRCH );
+            if (pzDirCh == NULL) {
+                stBuf.st_mode = S_IFREG;
+                continue;  /* bail out of error condition */
+            }
+
+            strncpy( z, pzDir, (size_t)(pzDirCh - pzDir));
+            z[ pzDirCh - pzDir ] = NUL;
+
+            if (  (stat( z, &stBuf ) == 0)
+               && S_ISDIR( stBuf.st_mode )) {
+
+                /*
+                 *  We found the directory.  Restore the file name and
+                 *  mark the full name as a regular file
+                 */
+                stBuf.st_mode = S_IFREG;
+                continue;  /* bail out of error condition */
+            }
+        }
+
+        /*
+         *  We got a bogus name.
+         */
+        fprintf( stderr, zWarn, pOpts->pzProgName );
+        fprintf( stderr, zNoStat, errno, strerror( errno ), pzDir );
+        if (free_dir_name)
+            AGFREE( (void*)pzDir );
+        return NULL;
+    } while (0);
+
+    /*
+     *  IF what we found was a directory,
+     *  THEN tack on the config file name
+     */
+    if (S_ISDIR( stBuf.st_mode )) {
+        size_t sz = strlen( pzDir ) + strlen( pOpts->pzRcName ) + 2;
+
+        {
+            char*  pzPath = (char*)AGALOC( sz, "file name" );
+#ifdef HAVE_SNPRINTF
+            snprintf( pzPath, sz, "%s/%s", pzDir, pOpts->pzRcName );
+#else
+            sprintf( pzPath, "%s/%s", pzDir, pOpts->pzRcName );
+#endif
+            if (free_dir_name)
+                AGFREE( (void*)pzDir );
+            pzDir = pzPath;
+            free_dir_name = 1;
+        }
+
+        /*
+         *  IF we cannot stat the object for any reason other than
+         *     it does not exist, then we bail out
+         */
+        if (stat( pzDir, &stBuf ) != 0) {
+            if (errno != ENOENT) {
+                fprintf( stderr, zWarn, pOpts->pzProgName );
+                fprintf( stderr, zNoStat, errno, strerror( errno ),
+                         pzDir );
+                AGFREE( (void*)pzDir );
+                return NULL;
+            }
+
+            /*
+             *  It does not exist yet, but it will be a regular file
+             */
+            stBuf.st_mode = S_IFREG;
+        }
+    }
+
+    /*
+     *  Make sure that whatever we ultimately found, that it either is
+     *  or will soon be a file.
+     */
+    if (! S_ISREG( stBuf.st_mode )) {
+        fprintf( stderr, zWarn, pOpts->pzProgName );
+        fprintf( stderr, zNotFile, pzDir );
+        if (free_dir_name)
+            AGFREE( (void*)pzDir );
+        return NULL;
+    }
+
+    /*
+     *  Get rid of the old file
+     */
+    unlink( pzDir );
+    *p_free_name = free_dir_name;
+    return pzDir;
+}
+
+
+static void
+printEntry(
+    FILE *     fp,
+    tOptDesc * p,
+    tCC*       pzLA )
+{
+    /*
+     *  There is an argument.  Pad the name so values line up.
+     *  Not disabled *OR* this got equivalenced to another opt,
+     *  then use current option name.
+     *  Otherwise, there must be a disablement name.
+     */
+    {
+        char const * pz;
+        if (! DISABLED_OPT(p) || (p->optEquivIndex != NO_EQUIVALENT))
+            pz = p->pz_Name;
+        else
+            pz = p->pz_DisableName;
+
+        fprintf(fp, "%-18s", pz);
+    }
+    /*
+     *  IF the option is numeric only,
+     *  THEN the char pointer is really the number
+     */
+    if (OPTST_GET_ARGTYPE(p->fOptState) == OPARG_TYPE_NUMERIC)
+        fprintf( fp, "  %d\n", (int)(t_word)pzLA );
+
+    /*
+     *  OTHERWISE, FOR each line of the value text, ...
+     */
+    else if (pzLA == NULL)
+        fputc( '\n', fp );
+
+    else {
+        fputc( ' ', fp ); fputc( ' ', fp );
+        for (;;) {
+            tCC* pzNl = strchr( pzLA, '\n' );
+
+            /*
+             *  IF this is the last line
+             *  THEN bail and print it
+             */
+            if (pzNl == NULL)
+                break;
+
+            /*
+             *  Print the continuation and the text from the current line
+             */
+            (void)fwrite( pzLA, (size_t)(pzNl - pzLA), (size_t)1, fp );
+            pzLA = pzNl+1; /* advance the Last Arg pointer */
+            fputs( "\\\n", fp );
+        }
+
+        /*
+         *  Terminate the entry
+         */
+        fputs( pzLA, fp );
+        fputc( '\n', fp );
+    }
+}
+
+
+/*=export_func  optionSaveFile
+ *
+ * what:  saves the option state to a file
+ *
+ * arg:   tOptions*,   pOpts,  program options descriptor
+ *
+ * doc:
+ *
+ * This routine will save the state of option processing to a file.  The name
+ * of that file can be specified with the argument to the @code{--save-opts}
+ * option, or by appending the @code{rcfile} attribute to the last
+ * @code{homerc} attribute.  If no @code{rcfile} attribute was specified, it
+ * will default to @code{.@i{programname}rc}.  If you wish to specify another
+ * file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro.
+ *
+ * err:
+ *
+ * If no @code{homerc} file was specified, this routine will silently return
+ * and do nothing.  If the output file cannot be created or updated, a message
+ * will be printed to @code{stderr} and the routine will return.
+=*/
+void
+optionSaveFile( tOptions* pOpts )
+{
+    tOptDesc* pOD;
+    int       ct;
+    FILE*     fp;
+
+    {
+        int   free_name = 0;
+        tCC*  pzFName = findFileName( pOpts, &free_name );
+        if (pzFName == NULL)
+            return;
+
+        fp = fopen( pzFName, "w" FOPEN_BINARY_FLAG );
+        if (fp == NULL) {
+            fprintf( stderr, zWarn, pOpts->pzProgName );
+            fprintf( stderr, zNoCreat, errno, strerror( errno ), pzFName );
+            if (free_name)
+                AGFREE((void*) pzFName );
+            return;
+        }
+
+        if (free_name)
+            AGFREE( (void*)pzFName );
+    }
+
+    {
+        char const*  pz = pOpts->pzUsageTitle;
+        fputs( "#  ", fp );
+        do { fputc( *pz, fp ); } while (*(pz++) != '\n');
+    }
+
+    {
+        time_t  timeVal = time( NULL );
+        char*   pzTime  = ctime( &timeVal );
+
+        fprintf( fp, zPresetFile, pzTime );
+#ifdef HAVE_ALLOCATED_CTIME
+        /*
+         *  The return values for ctime(), localtime(), and gmtime()
+         *  normally point to static data that is overwritten by each call.
+         *  The test to detect allocated ctime, so we leak the memory.
+         */
+        AGFREE( (void*)pzTime );
+#endif
+    }
+
+    /*
+     *  FOR each of the defined options, ...
+     */
+    ct  = pOpts->presetOptCt;
+    pOD = pOpts->pOptDesc;
+    do  {
+        int arg_state;
+        tOptDesc*  p;
+
+        /*
+         *  IF    the option has not been defined
+         *     OR it does not take an initialization value
+         *     OR it is equivalenced to another option
+         *  THEN continue (ignore it)
+         */
+        if (UNUSED_OPT( pOD ))
+            continue;
+
+        if ((pOD->fOptState & (OPTST_NO_INIT|OPTST_DOCUMENT|OPTST_OMITTED))
+            != 0)
+            continue;
+
+        if (  (pOD->optEquivIndex != NO_EQUIVALENT)
+              && (pOD->optEquivIndex != pOD->optIndex))
+            continue;
+
+        /*
+         *  Set a temporary pointer to the real option description
+         *  (i.e. account for equivalencing)
+         */
+        p = ((pOD->fOptState & OPTST_EQUIVALENCE) != 0)
+            ? (pOpts->pOptDesc + pOD->optActualIndex) : pOD;
+
+        /*
+         *  IF    no arguments are allowed
+         *  THEN just print the name and continue
+         */
+        if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NONE) {
+            char const * pznm =
+                (DISABLED_OPT( p )) ? p->pz_DisableName : p->pz_Name;
+            /*
+             *  If the option was disabled and the disablement name is NULL,
+             *  then the disablement was caused by aliasing.
+             *  Use the name as the string to emit.
+             */
+            if (pznm == NULL)
+                pznm = p->pz_Name;
+
+            fprintf(fp, "%s\n", pznm);
+            continue;
+        }
+
+        arg_state = OPTST_GET_ARGTYPE(p->fOptState);
+        switch (arg_state) {
+        case 0:
+        case OPARG_TYPE_NUMERIC:
+            printEntry( fp, p, (void*)(p->optArg.argInt));
+            break;
+
+        case OPARG_TYPE_STRING:
+            if (p->fOptState & OPTST_STACKED) {
+                tArgList*  pAL = (tArgList*)p->optCookie;
+                int        uct = pAL->useCt;
+                tCC**      ppz = pAL->apzArgs;
+
+                /*
+                 *  Disallow multiple copies of disabled options.
+                 */
+                if (uct > 1)
+                    p->fOptState &= ~OPTST_DISABLED;
+
+                while (uct-- > 0)
+                    printEntry( fp, p, *(ppz++) );
+            } else {
+                printEntry( fp, p, p->optArg.argString );
+            }
+            break;
+
+        case OPARG_TYPE_ENUMERATION:
+        case OPARG_TYPE_MEMBERSHIP:
+        {
+            uintptr_t val = p->optArg.argEnum;
+            /*
+             *  This is a magic incantation that will convert the
+             *  bit flag values back into a string suitable for printing.
+             */
+            (*(p->pOptProc))( (tOptions*)2UL, p );
+            printEntry( fp, p, (void*)(p->optArg.argString));
+
+            if (  (p->optArg.argString != NULL)
+               && (arg_state != OPARG_TYPE_ENUMERATION)) {
+                /*
+                 *  set membership strings get allocated
+                 */
+                AGFREE( (void*)p->optArg.argString );
+                p->fOptState &= ~OPTST_ALLOC_ARG;
+            }
+
+            p->optArg.argEnum = val;
+            break;
+        }
+
+        case OPARG_TYPE_BOOLEAN:
+            printEntry( fp, p, p->optArg.argBool ? "true" : "false" );
+            break;
+
+        default:
+            break; /* cannot handle - skip it */
+        }
+    } while ( (pOD++), (--ct > 0));
+
+    fclose( fp );
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/save.c */
diff --git a/libopts/sort.c b/libopts/sort.c
new file mode 100644 (file)
index 0000000..ead7133
--- /dev/null
@@ -0,0 +1,359 @@
+
+/*
+ *  sort.c  $Id: sort.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2006-10-18 11:29:04 bkorb"
+ *
+ *  This module implements argument sorting.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static tSuccess
+mustHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS,
+               char** ppzOpts, int* pOptsIdx );
+
+static tSuccess
+mayHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS,
+              char** ppzOpts, int* pOptsIdx );
+
+static tSuccess
+checkShortOpts( tOptions* pOpts, char* pzArg, tOptState* pOS,
+                char** ppzOpts, int* pOptsIdx );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*
+ *  "mustHandleArg" and "mayHandleArg" are really similar.  The biggest
+ *  difference is that "may" will consume the next argument only if it
+ *  does not start with a hyphen and "must" will consume it, hyphen or not.
+ */
+static tSuccess
+mustHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS,
+               char** ppzOpts, int* pOptsIdx )
+{
+    /*
+     *  An option argument is required.  Long options can either have
+     *  a separate command line argument, or an argument attached by
+     *  the '=' character.  Figure out which.
+     */
+    switch (pOS->optType) {
+    case TOPT_SHORT:
+        /*
+         *  See if an arg string follows the flag character.  If not,
+         *  the next arg must be the option argument.
+         */
+        if (*pzArg != NUL)
+            return SUCCESS;
+        break;
+
+    case TOPT_LONG:
+        /*
+         *  See if an arg string has already been assigned (glued on
+         *  with an `=' character).  If not, the next is the opt arg.
+         */
+        if (pOS->pzOptArg != NULL)
+            return SUCCESS;
+        break;
+
+    default:
+        return FAILURE;
+    }
+    if (pOpts->curOptIdx >= pOpts->origArgCt)
+        return FAILURE;
+
+    ppzOpts[ (*pOptsIdx)++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+    return SUCCESS;
+}
+
+static tSuccess
+mayHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS,
+              char** ppzOpts, int* pOptsIdx )
+{
+    /*
+     *  An option argument is optional.
+     */
+    switch (pOS->optType) {
+    case TOPT_SHORT:
+        /*
+         *  IF nothing is glued on after the current flag character,
+         *  THEN see if there is another argument.  If so and if it
+         *  does *NOT* start with a hyphen, then it is the option arg.
+         */
+        if (*pzArg != NUL)
+            return SUCCESS;
+        break;
+
+    case TOPT_LONG:
+        /*
+         *  Look for an argument if we don't already have one (glued on
+         *  with a `=' character)
+         */
+        if (pOS->pzOptArg != NULL)
+            return SUCCESS;
+        break;
+
+    default:
+        return FAILURE;
+    }
+    if (pOpts->curOptIdx >= pOpts->origArgCt)
+        return PROBLEM;
+
+    pzArg = pOpts->origArgVect[ pOpts->curOptIdx ];
+    if (*pzArg != '-')
+        ppzOpts[ (*pOptsIdx)++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+    return SUCCESS;
+}
+
+/*
+ *  Process a string of short options glued together.  If the last one
+ *  does or may take an argument, the do the argument processing and leave.
+ */
+static tSuccess
+checkShortOpts( tOptions* pOpts, char* pzArg, tOptState* pOS,
+                char** ppzOpts, int* pOptsIdx )
+{
+    while (*pzArg != NUL) {
+        if (FAILED( shortOptionFind( pOpts, (tAoUC)*pzArg, pOS )))
+            return FAILURE;
+
+        /*
+         *  See if we can have an arg.
+         */
+        if (OPTST_GET_ARGTYPE(pOS->pOD->fOptState) == OPARG_TYPE_NONE) {
+            pzArg++;
+
+        } else if (pOS->pOD->fOptState & OPTST_ARG_OPTIONAL) {
+            /*
+             *  Take an argument if it is not attached and it does not
+             *  start with a hyphen.
+             */
+            if (pzArg[1] != NUL)
+                return SUCCESS;
+
+            pzArg = pOpts->origArgVect[ pOpts->curOptIdx ];
+            if (*pzArg != '-')
+                ppzOpts[ (*pOptsIdx)++ ] =
+                    pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+            return SUCCESS;
+
+        } else {
+            /*
+             *  IF we need another argument, be sure it is there and
+             *  take it.
+             */
+            if (pzArg[1] == NUL) {
+                if (pOpts->curOptIdx >= pOpts->origArgCt)
+                    return FAILURE;
+                ppzOpts[ (*pOptsIdx)++ ] =
+                    pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+            }
+            return SUCCESS;
+        }
+    }
+    return SUCCESS;
+}
+
+/*
+ *  If the program wants sorted options (separated operands and options),
+ *  then this routine will to the trick.
+ */
+LOCAL void
+optionSort( tOptions* pOpts )
+{
+    char** ppzOpts;
+    char** ppzOpds;
+    int    optsIdx = 0;
+    int    opdsIdx = 0;
+
+    tOptState os = OPTSTATE_INITIALIZER(DEFINED);
+
+    /*
+     *  Disable for POSIX conformance, or if there are no operands.
+     */
+    if (  (getenv( "POSIXLY_CORRECT" ) != NULL)
+       || NAMED_OPTS(pOpts))
+        return;
+
+    /*
+     *  Make sure we can allocate two full-sized arg vectors.
+     */
+    ppzOpts = malloc( pOpts->origArgCt * sizeof( char* ));
+    if (ppzOpts == NULL)
+        goto exit_no_mem;
+
+    ppzOpds = malloc( pOpts->origArgCt * sizeof( char* ));
+    if (ppzOpds == NULL) {
+        free( ppzOpts );
+        goto exit_no_mem;
+    }
+
+    pOpts->curOptIdx = 1;
+    pOpts->pzCurOpt  = NULL;
+
+    /*
+     *  Now, process all the options from our current position onward.
+     *  (This allows interspersed options and arguments for the few
+     *  non-standard programs that require it.)
+     */
+    for (;;) {
+        char* pzArg;
+        tSuccess res;
+
+        /*
+         *  If we're out of arguments, we're done.  Join the option and
+         *  operand lists into the original argument vector.
+         */
+        if (pOpts->curOptIdx >= pOpts->origArgCt) {
+            errno = 0;
+            goto joinLists;
+        }
+
+        pzArg = pOpts->origArgVect[ pOpts->curOptIdx ];
+        if (*pzArg != '-') {
+            ppzOpds[ opdsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+            continue;
+        }
+
+        switch (pzArg[1]) {
+        case NUL:
+            /*
+             *  A single hyphen is an operand.
+             */
+            ppzOpds[ opdsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+            continue;
+
+        case '-':
+            /*
+             *  Two consecutive hypens.  Put them on the options list and then
+             *  _always_ force the remainder of the arguments to be operands.
+             */
+            if (pzArg[2] == NUL) {
+                ppzOpts[ optsIdx++ ] =
+                    pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+                goto restOperands;
+            }
+            res = longOptionFind( pOpts, pzArg+2, &os );
+            break;
+
+        default:
+            /*
+             *  If short options are not allowed, then do long
+             *  option processing.  Otherwise the character must be a
+             *  short (i.e. single character) option.
+             */
+            if ((pOpts->fOptSet & OPTPROC_SHORTOPT) == 0) {
+                res = longOptionFind( pOpts, pzArg+1, &os );
+            } else {
+                res = shortOptionFind( pOpts, (tAoUC)pzArg[1], &os );
+            }
+            break;
+        }
+        if (FAILED( res )) {
+            errno = EINVAL;
+            goto freeTemps;
+        }
+
+        /*
+         *  We've found an option.  Add the argument to the option list.
+         *  Next, we have to see if we need to pull another argument to be
+         *  used as the option argument.
+         */
+        ppzOpts[ optsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+
+        if (OPTST_GET_ARGTYPE(os.pOD->fOptState) == OPARG_TYPE_NONE) {
+            /*
+             *  No option argument.  If we have a short option here,
+             *  then scan for short options until we get to the end
+             *  of the argument string.
+             */
+            if (  (os.optType == TOPT_SHORT)
+               && FAILED( checkShortOpts( pOpts, pzArg+2, &os,
+                                          ppzOpts, &optsIdx )) )  {
+                errno = EINVAL;
+                goto freeTemps;
+            }
+
+        } else if (os.pOD->fOptState & OPTST_ARG_OPTIONAL) {
+            switch (mayHandleArg( pOpts, pzArg+2, &os, ppzOpts, &optsIdx )) {
+            case FAILURE: errno = EIO; goto freeTemps;
+            case PROBLEM: errno = 0;   goto joinLists;
+            }
+
+        } else {
+            switch (mustHandleArg( pOpts, pzArg+2, &os, ppzOpts, &optsIdx )) {
+            case PROBLEM:
+            case FAILURE: errno = EIO; goto freeTemps;
+            }
+        }
+    } /* for (;;) */
+
+ restOperands:
+    while (pOpts->curOptIdx < pOpts->origArgCt)
+        ppzOpds[ opdsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+
+ joinLists:
+    if (optsIdx > 0)
+        memcpy( pOpts->origArgVect + 1, ppzOpts, optsIdx * sizeof( char* ));
+    if (opdsIdx > 0)
+        memcpy( pOpts->origArgVect + 1 + optsIdx,
+                ppzOpds, opdsIdx * sizeof( char* ));
+
+ freeTemps:
+    free( ppzOpts );
+    free( ppzOpds );
+    return;
+
+ exit_no_mem:
+    errno = ENOMEM;
+    return;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/sort.c */
diff --git a/libopts/stack.c b/libopts/stack.c
new file mode 100644 (file)
index 0000000..6d77f72
--- /dev/null
@@ -0,0 +1,269 @@
+
+/*
+ *  stack.c
+ *  $Id: stack.c,v 4.13 2007/02/04 17:44:12 bkorb Exp $
+ *  Time-stamp:      "2007-01-13 10:43:21 bkorb"
+ *
+ *  This is a special option processing routine that will save the
+ *  argument to an option in a FIFO queue.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+#ifdef WITH_LIBREGEX
+#  include REGEX_HEADER
+#endif
+
+/*=export_func  optionUnstackArg
+ * private:
+ *
+ * what:  Remove option args from a stack
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Invoked for options that are equivalenced to stacked options.
+=*/
+void
+optionUnstackArg(
+    tOptions*  pOpts,
+    tOptDesc*  pOptDesc )
+{
+    int       res;
+
+    tArgList* pAL = (tArgList*)pOptDesc->optCookie;
+    /*
+     *  IF we don't have any stacked options,
+     *  THEN indicate that we don't have any of these options
+     */
+    if (pAL == NULL) {
+        pOptDesc->fOptState &= OPTST_PERSISTENT_MASK;
+        if ( (pOptDesc->fOptState & OPTST_INITENABLED) == 0)
+            pOptDesc->fOptState |= OPTST_DISABLED;
+        return;
+    }
+
+#ifdef WITH_LIBREGEX
+    {
+        regex_t   re;
+        int       i, ct, dIdx;
+
+        if (regcomp( &re, pOptDesc->optArg.argString, REG_NOSUB ) != 0)
+            return;
+
+        /*
+         *  search the list for the entry(s) to remove.  Entries that
+         *  are removed are *not* copied into the result.  The source
+         *  index is incremented every time.  The destination only when
+         *  we are keeping a define.
+         */
+        for (i = 0, dIdx = 0, ct = pAL->useCt; --ct >= 0; i++) {
+            tCC*      pzSrc = pAL->apzArgs[ i ];
+            char*     pzEq  = strchr( pzSrc, '=' );
+
+            if (pzEq != NULL)
+                *pzEq = NUL;
+
+            res = regexec( &re, pzSrc, (size_t)0, NULL, 0 );
+            switch (res) {
+            case 0:
+                /*
+                 *  Remove this entry by reducing the in-use count
+                 *  and *not* putting the string pointer back into
+                 *  the list.
+                 */
+                AGFREE(pzSrc);
+                pAL->useCt--;
+                break;
+
+            default:
+            case REG_NOMATCH:
+                if (pzEq != NULL)
+                    *pzEq = '=';
+
+                /*
+                 *  IF we have dropped an entry
+                 *  THEN we have to move the current one.
+                 */
+                if (dIdx != i)
+                    pAL->apzArgs[ dIdx ] = pzSrc;
+                dIdx++;
+            }
+        }
+
+        regfree( &re );
+    }
+#else  /* not WITH_LIBREGEX */
+    {
+        int i, ct, dIdx;
+
+        /*
+         *  search the list for the entry(s) to remove.  Entries that
+         *  are removed are *not* copied into the result.  The source
+         *  index is incremented every time.  The destination only when
+         *  we are keeping a define.
+         */
+        for (i = 0, dIdx = 0, ct = pAL->useCt; --ct >= 0; i++) {
+            tCC*      pzSrc = pAL->apzArgs[ i ];
+            char*     pzEq  = strchr( pzSrc, '=' );
+
+            if (pzEq != NULL)
+                *pzEq = NUL;
+
+            if (strcmp( pzSrc, pOptDesc->optArg.argString ) == 0) {
+                /*
+                 *  Remove this entry by reducing the in-use count
+                 *  and *not* putting the string pointer back into
+                 *  the list.
+                 */
+                AGFREE(pzSrc);
+                pAL->useCt--;
+            } else {
+                if (pzEq != NULL)
+                    *pzEq = '=';
+
+                /*
+                 *  IF we have dropped an entry
+                 *  THEN we have to move the current one.
+                 */
+                if (dIdx != i)
+                    pAL->apzArgs[ dIdx ] = pzSrc;
+                dIdx++;
+            }
+        }
+    }
+#endif /* WITH_LIBREGEX */
+    /*
+     *  IF we have unstacked everything,
+     *  THEN indicate that we don't have any of these options
+     */
+    if (pAL->useCt == 0) {
+        pOptDesc->fOptState &= OPTST_PERSISTENT_MASK;
+        if ( (pOptDesc->fOptState & OPTST_INITENABLED) == 0)
+            pOptDesc->fOptState |= OPTST_DISABLED;
+        AGFREE( (void*)pAL );
+        pOptDesc->optCookie = NULL;
+    }
+}
+
+
+/*
+ *  Put an entry into an argument list.  The first argument points to
+ *  a pointer to the argument list structure.  It gets passed around
+ *  as an opaque address.
+ */
+LOCAL void
+addArgListEntry( void** ppAL, void* entry )
+{
+    tArgList* pAL = *(void**)ppAL;
+
+    /*
+     *  IF we have never allocated one of these,
+     *  THEN allocate one now
+     */
+    if (pAL == NULL) {
+        pAL = (tArgList*)AGALOC( sizeof( *pAL ), "new option arg stack" );
+        if (pAL == NULL)
+            return;
+        pAL->useCt   = 0;
+        pAL->allocCt = MIN_ARG_ALLOC_CT;
+        *ppAL = (void*)pAL;
+    }
+
+    /*
+     *  ELSE if we are out of room
+     *  THEN make it bigger
+     */
+    else if (pAL->useCt >= pAL->allocCt) {
+        size_t sz = sizeof( *pAL );
+        pAL->allocCt += INCR_ARG_ALLOC_CT;
+
+        /*
+         *  The base structure contains space for MIN_ARG_ALLOC_CT
+         *  pointers.  We subtract it off to find our augment size.
+         */
+        sz += sizeof(char*) * (pAL->allocCt - MIN_ARG_ALLOC_CT);
+        pAL = (tArgList*)AGREALOC( (void*)pAL, sz, "expanded opt arg stack" );
+        if (pAL == NULL)
+            return;
+        *ppAL = (void*)pAL;
+    }
+
+    /*
+     *  Insert the new argument into the list
+     */
+    pAL->apzArgs[ (pAL->useCt)++ ] = entry;
+}
+
+
+/*=export_func  optionStackArg
+ * private:
+ *
+ * what:  put option args on a stack
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Keep an entry-ordered list of option arguments.
+=*/
+void
+optionStackArg(
+    tOptions*  pOpts,
+    tOptDesc*  pOD )
+{
+    char * pz;
+
+    if (pOD->optArg.argString == NULL)
+        return;
+
+    AGDUPSTR(pz, pOD->optArg.argString, "stack arg");
+    addArgListEntry( &(pOD->optCookie), (void*)pz );
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/stack.c */
diff --git a/libopts/streqvcmp.c b/libopts/streqvcmp.c
new file mode 100644 (file)
index 0000000..8249794
--- /dev/null
@@ -0,0 +1,289 @@
+
+/*
+ *  $Id: streqvcmp.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2006-07-26 18:25:53 bkorb"
+ *
+ *  String Equivalence Comparison
+ *
+ *  These routines allow any character to be mapped to any other
+ *  character before comparison.  In processing long option names,
+ *  the characters "-", "_" and "^" all need to be equivalent
+ *  (because they are treated so by different development environments).
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/*
+ * This array is designed for mapping upper and lower case letter
+ * together for a case independent comparison.  The mappings are
+ * based upon ascii character sequences.
+ */
+static unsigned char charmap[] = {
+    0x00, 0x01, 0x02, 0x03,  0x04, 0x05, 0x06, '\a',
+    '\b', '\t', '\n', '\v',  '\f', '\r', 0x0E, 0x0F,
+    0x10, 0x11, 0x12, 0x13,  0x14, 0x15, 0x16, 0x17,
+    0x18, 0x19, 0x1A, 0x1B,  0x1C, 0x1D, 0x1E, 0x1F,
+
+    ' ',  '!',  '"',  '#',   '$',  '%',  '&',  '\'',
+    '(',  ')',  '*',  '+',   ',',  '-',  '.',  '/',
+    '0',  '1',  '2',  '3',   '4',  '5',  '6',  '7',
+    '8',  '9',  ':',  ';',   '<',  '=',  '>',  '?',
+
+    '@',  'a',  'b',  'c',   'd',  'e',  'f',  'g',
+    'h',  'i',  'j',  'k',   'l',  'm',  'n',  'o',
+    'p',  'q',  'r',  's',   't',  'u',  'v',  'w',
+    'x',  'y',  'z',  '[',   '\\', ']',  '^',  '_',
+    '`',  'a',  'b',  'c',   'd',  'e',  'f',  'g',
+    'h',  'i',  'j',  'k',   'l',  'm',  'n',  'o',
+    'p',  'q',  'r',  's',   't',  'u',  'v',  'w',
+    'x',  'y',  'z',  '{',   '|',  '}',  '~',  0x7f,
+
+    0x80, 0x81, 0x82, 0x83,  0x84, 0x85, 0x86, 0x87,
+    0x88, 0x89, 0x8A, 0x8B,  0x8C, 0x8D, 0x8E, 0x8F,
+    0x90, 0x91, 0x92, 0x93,  0x94, 0x95, 0x96, 0x97,
+    0x98, 0x99, 0x9A, 0x9B,  0x9C, 0x9D, 0x9E, 0x9F,
+    0xA0, 0xA1, 0xA2, 0xA3,  0xA4, 0xA5, 0xA6, 0xA7,
+    0xA8, 0xA9, 0xAA, 0xAB,  0xAC, 0xAD, 0xAE, 0xAF,
+    0xB0, 0xB1, 0xB2, 0xB3,  0xB4, 0xB5, 0xB6, 0xB7,
+    0xB8, 0xB9, 0xBA, 0xBB,  0xBC, 0xBD, 0xBE, 0xBF,
+
+    0xC0, 0xC1, 0xC2, 0xC3,  0xC4, 0xC5, 0xC6, 0xC7,
+    0xC8, 0xC9, 0xCA, 0xCB,  0xCC, 0xCD, 0xCE, 0xCF,
+    0xD0, 0xD1, 0xD2, 0xD3,  0xD4, 0xD5, 0xD6, 0xD7,
+    0xD8, 0xD9, 0xDA, 0xDB,  0xDC, 0xDD, 0xDE, 0xDF,
+    0xE0, 0xE1, 0xE2, 0xE3,  0xE4, 0xE5, 0xE6, 0xE7,
+    0xE8, 0xE9, 0xEA, 0xEB,  0xEC, 0xED, 0xEE, 0xEF,
+    0xF0, 0xF1, 0xF2, 0xF3,  0xF4, 0xF5, 0xF6, 0xF7,
+    0xF8, 0xF9, 0xFA, 0xFB,  0xFC, 0xFD, 0xFE, 0xFF,
+};
+
+
+/*=export_func strneqvcmp
+ *
+ * what: compare two strings with an equivalence mapping
+ *
+ * arg:  + char const* + str1 + first string +
+ * arg:  + char const* + str2 + second string +
+ * arg:  + int         + ct   + compare length +
+ *
+ * ret_type:  int
+ * ret_desc:  the difference between two differing characters
+ *
+ * doc:
+ *
+ * Using a character mapping, two strings are compared for "equivalence".
+ * Each input character is mapped to a comparison character and the
+ * mapped-to characters are compared for the two NUL terminated input strings.
+ * The comparison is limited to @code{ct} bytes.
+ * This function name is mapped to option_strneqvcmp so as to not conflict
+ * with the POSIX name space.
+ *
+ * err:  none checked.  Caller responsible for seg faults.
+=*/
+int
+strneqvcmp( tCC* s1, tCC* s2, int ct )
+{
+    for (; ct > 0; --ct) {
+        unsigned char u1 = (unsigned char) *s1++;
+        unsigned char u2 = (unsigned char) *s2++;
+        int dif = charmap[ u1 ] - charmap[ u2 ];
+
+        if (dif != 0)
+            return dif;
+
+        if (u1 == NUL)
+            return 0;
+    }
+
+    return 0;
+}
+
+
+/*=export_func streqvcmp
+ *
+ * what: compare two strings with an equivalence mapping
+ *
+ * arg:  + char const* + str1 + first string +
+ * arg:  + char const* + str2 + second string +
+ *
+ * ret_type:  int
+ * ret_desc:  the difference between two differing characters
+ *
+ * doc:
+ *
+ * Using a character mapping, two strings are compared for "equivalence".
+ * Each input character is mapped to a comparison character and the
+ * mapped-to characters are compared for the two NUL terminated input strings.
+ * This function name is mapped to option_streqvcmp so as to not conflict
+ * with the POSIX name space.
+ *
+ * err:  none checked.  Caller responsible for seg faults.
+=*/
+int
+streqvcmp( tCC* s1, tCC* s2 )
+{
+    for (;;) {
+        unsigned char u1 = (unsigned char) *s1++;
+        unsigned char u2 = (unsigned char) *s2++;
+        int dif = charmap[ u1 ] - charmap[ u2 ];
+
+        if (dif != 0)
+            return dif;
+
+        if (u1 == NUL)
+            return 0;
+    }
+}
+
+
+/*=export_func streqvmap
+ *
+ * what: Set the character mappings for the streqv functions
+ *
+ * arg:  + char + From + Input character +
+ * arg:  + char + To   + Mapped-to character +
+ * arg:  + int  + ct   + compare length +
+ *
+ * doc:
+ *
+ * Set the character mapping.  If the count (@code{ct}) is set to zero, then
+ * the map is cleared by setting all entries in the map to their index
+ * value.  Otherwise, the "@code{From}" character is mapped to the "@code{To}"
+ * character.  If @code{ct} is greater than 1, then @code{From} and @code{To}
+ * are incremented and the process repeated until @code{ct} entries have been
+ * set. For example,
+ * @example
+ *    streqvmap( 'a', 'A', 26 );
+ * @end example
+ * @noindent
+ * will alter the mapping so that all English lower case letters
+ * will map to upper case.
+ *
+ * This function name is mapped to option_streqvmap so as to not conflict
+ * with the POSIX name space.
+ *
+ * err:  none.
+=*/
+void
+streqvmap( char From, char To, int ct )
+{
+    if (ct == 0) {
+        ct = sizeof( charmap ) - 1;
+        do  {
+            charmap[ ct ] = ct;
+        } while (--ct >= 0);
+    }
+
+    else {
+        int  chTo   = (int)To   & 0xFF;
+        int  chFrom = (int)From & 0xFF;
+
+        do  {
+            charmap[ chFrom ] = (unsigned)chTo;
+            chFrom++;
+            chTo++;
+            if ((chFrom >= sizeof( charmap )) || (chTo >= sizeof( charmap )))
+                break;
+        } while (--ct > 0);
+    }
+}
+
+
+/*=export_func strequate
+ *
+ * what: map a list of characters to the same value
+ *
+ * arg:  + char const* + ch_list + characters to equivalence +
+ *
+ * doc:
+ *
+ * Each character in the input string get mapped to the first character
+ * in the string.
+ * This function name is mapped to option_strequate so as to not conflict
+ * with the POSIX name space.
+ *
+ * err:  none.
+=*/
+void
+strequate( char const* s )
+{
+    if ((s != NULL) && (*s != NUL)) {
+        unsigned char equiv = (unsigned)*s;
+        while (*s != NUL)
+            charmap[ (unsigned)*(s++) ] = equiv;
+    }
+}
+
+
+/*=export_func strtransform
+ *
+ * what: convert a string into its mapped-to value
+ *
+ * arg:  + char*       + dest + output string +
+ * arg:  + char const* + src  + input string +
+ *
+ * doc:
+ *
+ * Each character in the input string is mapped and the mapped-to
+ * character is put into the output.
+ * This function name is mapped to option_strtransform so as to not conflict
+ * with the POSIX name space.
+ *
+ * err:  none.
+=*/
+void
+strtransform( char* d, char const* s )
+{
+    do  {
+        *(d++) = (char)charmap[ (unsigned)*s ];
+    } while (*(s++) != NUL);
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/streqvcmp.c */
diff --git a/libopts/text_mmap.c b/libopts/text_mmap.c
new file mode 100644 (file)
index 0000000..ced2977
--- /dev/null
@@ -0,0 +1,363 @@
+/*
+ * $Id: text_mmap.c,v 4.15 2006/11/27 01:52:23 bkorb Exp $
+ *
+ * Time-stamp:      "2006-09-10 14:50:04 bkorb"
+ */
+
+#ifndef MAP_ANONYMOUS
+#  ifdef   MAP_ANON
+#  define  MAP_ANONYMOUS   MAP_ANON
+#  endif
+#endif
+
+/*
+ *  Some weird systems require that a specifically invalid FD number
+ *  get passed in as an argument value.  Which value is that?  Well,
+ *  as everybody knows, if open(2) fails, it returns -1, so that must
+ *  be the value.  :)
+ */
+#define AO_INVALID_FD  -1
+
+#define FILE_WRITABLE(_prt,_flg) \
+        (   (_prt & PROT_WRITE) \
+         && ((_flg & (MAP_SHARED|MAP_PRIVATE)) == MAP_SHARED))
+#define MAP_FAILED_PTR ((void*)MAP_FAILED)
+
+/*=export_func  text_mmap
+ * private:
+ *
+ * what:  map a text file with terminating NUL
+ *
+ * arg:   char const*,  pzFile,  name of the file to map
+ * arg:   int,          prot,    mmap protections (see mmap(2))
+ * arg:   int,          flags,   mmap flags (see mmap(2))
+ * arg:   tmap_info_t*, mapinfo, returned info about the mapping
+ *
+ * ret-type:   void*
+ * ret-desc:   The mmaped data address
+ *
+ * doc:
+ *
+ * This routine will mmap a file into memory ensuring that there is at least
+ * one @file{NUL} character following the file data.  It will return the
+ * address where the file contents have been mapped into memory.  If there is a
+ * problem, then it will return @code{MAP_FAILED} and set @file{errno}
+ * appropriately.
+ *
+ * The named file does not exist, @code{stat(2)} will set @file{errno} as it
+ * will.  If the file is not a regular file, @file{errno} will be
+ * @code{EINVAL}.  At that point, @code{open(2)} is attempted with the access
+ * bits set appropriately for the requested @code{mmap(2)} protections and flag
+ * bits.  On failure, @file{errno} will be set according to the documentation
+ * for @code{open(2)}.  If @code{mmap(2)} fails, @file{errno} will be set as
+ * that routine sets it.  If @code{text_mmap} works to this point, a valid
+ * address will be returned, but there may still be ``issues''.
+ *
+ * If the file size is not an even multiple of the system page size, then
+ * @code{text_map} will return at this point and @file{errno} will be zero.
+ * Otherwise, an anonymous map is attempted.  If not available, then an attempt
+ * is made to @code{mmap(2)} @file{/dev/zero}.  If any of these fail, the
+ * address of the file's data is returned, bug @code{no} @file{NUL} characters
+ * are mapped after the end of the data.
+ *
+ * see: mmap(2), open(2), stat(2)
+ *
+ * err: Any error code issued by mmap(2), open(2), stat(2) is possible.
+ *      Additionally, if the specified file is not a regular file, then
+ *      errno will be set to @code{EINVAL}.
+ *
+ * example:
+ * #include <mylib.h>
+ * tmap_info_t mi;
+ * int no_nul;
+ * void* data = text_mmap( "file", PROT_WRITE, MAP_PRIVATE, &mi );
+ * if (data == MAP_FAILED) return;
+ * no_nul = (mi.txt_size == mi.txt_full_size);
+ * << use the data >>
+ * text_munmap( &mi );
+=*/
+void*
+text_mmap( char const* pzFile, int prot, int flags, tmap_info_t* pMI )
+{
+    memset( pMI, 0, sizeof(*pMI) );
+#ifdef HAVE_MMAP
+    pMI->txt_zero_fd = -1;
+#endif
+    pMI->txt_fd = -1;
+
+    /*
+     *  Make sure we can stat the regular file.  Save the file size.
+     */
+    {
+        struct stat sb;
+        if (stat( pzFile, &sb ) != 0) {
+            pMI->txt_errno = errno;
+            return MAP_FAILED_PTR;
+        }
+
+        if (! S_ISREG( sb.st_mode )) {
+            pMI->txt_errno = errno = EINVAL;
+            return MAP_FAILED_PTR;
+        }
+
+        pMI->txt_size = sb.st_size;
+    }
+
+    /*
+     *  Map mmap flags and protections into open flags and do the open.
+     */
+    {
+        int o_flag;
+        /*
+         *  See if we will be updating the file.  If we can alter the memory
+         *  and if we share the data and we are *not* copy-on-writing the data,
+         *  then our updates will show in the file, so we must open with
+         *  write access.
+         */
+        if (FILE_WRITABLE(prot,flags))
+            o_flag = O_RDWR;
+        else
+            o_flag = O_RDONLY;
+
+        /*
+         *  If you're not sharing the file and you are writing to it,
+         *  then don't let anyone else have access to the file.
+         */
+        if (((flags & MAP_SHARED) == 0) && (prot & PROT_WRITE))
+            o_flag |= O_EXCL;
+
+        pMI->txt_fd = open( pzFile, o_flag );
+    }
+
+    if (pMI->txt_fd == AO_INVALID_FD) {
+        pMI->txt_errno = errno;
+        return MAP_FAILED_PTR;
+    }
+
+#ifdef HAVE_MMAP /* * * * * WITH MMAP * * * * * */
+    /*
+     *  do the mmap.  If we fail, then preserve errno, close the file and
+     *  return the failure.
+     */
+    pMI->txt_data =
+        mmap(NULL, pMI->txt_size+1, prot, flags, pMI->txt_fd, (size_t)0);
+    if (pMI->txt_data == MAP_FAILED_PTR) {
+        pMI->txt_errno = errno;
+        goto fail_return;
+    }
+
+    /*
+     *  Most likely, everything will turn out fine now.  The only difficult
+     *  part at this point is coping with files with sizes that are a multiple
+     *  of the page size.  Handling that is what this whole thing is about.
+     */
+    pMI->txt_zero_fd = -1;
+    pMI->txt_errno   = 0;
+
+    {
+        void* pNuls;
+#ifdef _SC_PAGESIZE
+        size_t pgsz = sysconf(_SC_PAGESIZE);
+#else
+        size_t pgsz = getpagesize();
+#endif
+        /*
+         *  Compute the pagesize rounded mapped memory size.
+         *  IF this is not the same as the file size, then there are NUL's
+         *  at the end of the file mapping and all is okay.
+         */
+        pMI->txt_full_size = (pMI->txt_size + (pgsz - 1)) & ~(pgsz - 1);
+        if (pMI->txt_size != pMI->txt_full_size)
+            return pMI->txt_data;
+
+        /*
+         *  Still here?  We have to remap the trailing inaccessible page
+         *  either anonymously or to /dev/zero.
+         */
+        pMI->txt_full_size += pgsz;
+#if defined(MAP_ANONYMOUS)
+        pNuls = mmap(
+                (void*)(((char*)pMI->txt_data) + pMI->txt_size),
+                pgsz, PROT_READ|PROT_WRITE,
+                MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE, AO_INVALID_FD, (size_t)0);
+
+        if (pNuls != MAP_FAILED_PTR)
+            return pMI->txt_data;
+
+        pMI->txt_errno = errno;
+
+#elif defined(HAVE_DEV_ZERO)
+        pMI->txt_zero_fd = open( "/dev/zero", O_RDONLY );
+
+        if (pMI->txt_zero_fd == AO_INVALID_FD) {
+            pMI->txt_errno = errno;
+
+        } else {
+            pNuls = mmap(
+                    (void*)(((char*)pMI->txt_data) + pMI->txt_size), pgsz,
+                    PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
+                    pMI->txt_zero_fd, 0 );
+
+            if (pNuls != MAP_FAILED_PTR)
+                return pMI->txt_data;
+
+            pMI->txt_errno = errno;
+            close( pMI->txt_zero_fd );
+            pMI->txt_zero_fd = -1;
+        }
+#endif
+
+        pMI->txt_full_size = pMI->txt_size;
+    }
+
+    {
+        void* p = AGALOC( pMI->txt_size+1, "file text" );
+        memcpy( p, pMI->txt_data, pMI->txt_size );
+        ((char*)p)[pMI->txt_size] = NUL;
+        munmap(pMI->txt_data, pMI->txt_size );
+        pMI->txt_data = p;
+    }
+    pMI->txt_alloc = 1;
+    return pMI->txt_data;
+
+#else /* * * * * * no HAVE_MMAP * * * * * */
+
+    pMI->txt_data = AGALOC( pMI->txt_size+1, "file text" );
+    if (pMI->txt_data == NULL) {
+        pMI->txt_errno = ENOMEM;
+        goto fail_return;
+    }
+
+    {
+        size_t sz = pMI->txt_size;
+        char*  pz = pMI->txt_data;
+
+        while (sz > 0) {
+            ssize_t rdct = read( pMI->txt_fd, pz, sz );
+            if (rdct <= 0) {
+                pMI->txt_errno = errno;
+                fprintf( stderr, zFSErrReadFile,
+                         errno, strerror( errno ), pzFile );
+                free( pMI->txt_data );
+                goto fail_return;
+            }
+
+            pz += rdct;
+            sz -= rdct;
+        }
+
+        *pz = NUL;
+    }
+
+    /*
+     *  We never need a dummy page mapped in
+     */
+    pMI->txt_zero_fd = -1;
+    pMI->txt_errno   = 0;
+
+    return pMI->txt_data;
+
+#endif /* * * * * * no HAVE_MMAP * * * * * */
+
+ fail_return:
+    if (pMI->txt_fd >= 0) {
+        close( pMI->txt_fd );
+        pMI->txt_fd = -1;
+    }
+    errno = pMI->txt_errno;
+    pMI->txt_data = MAP_FAILED_PTR;
+    return pMI->txt_data;
+}
+
+
+/*=export_func  text_munmap
+ * private:
+ *
+ * what:  unmap the data mapped in by text_mmap
+ *
+ * arg:   tmap_info_t*, mapinfo, info about the mapping
+ *
+ * ret-type:   int
+ * ret-desc:   -1 or 0.  @file{errno} will have the error code.
+ *
+ * doc:
+ *
+ * This routine will unmap the data mapped in with @code{text_mmap} and close
+ * the associated file descriptors opened by that function.
+ *
+ * see: munmap(2), close(2)
+ *
+ * err: Any error code issued by munmap(2) or close(2) is possible.
+=*/
+int
+text_munmap( tmap_info_t* pMI )
+{
+#ifdef HAVE_MMAP
+    int res = 0;
+    if (pMI->txt_alloc) {
+        /*
+         *  IF the user has write permission and the text is not mapped private,
+         *  then write back any changes.  Hopefully, nobody else has modified
+         *  the file in the mean time.
+         */
+        if (   ((pMI->txt_prot & PROT_WRITE) != 0)
+            && ((pMI->txt_flags & MAP_PRIVATE) == 0))  {
+
+            if (lseek(pMI->txt_fd, (size_t)0, SEEK_SET) != 0)
+                goto error_return;
+
+            res = (write( pMI->txt_fd, pMI->txt_data, pMI->txt_size ) < 0)
+                ? errno : 0;
+        }
+
+        AGFREE( pMI->txt_data );
+        errno = res;
+    } else {
+        res = munmap( pMI->txt_data, pMI->txt_full_size );
+    }
+    if (res != 0)
+        goto error_return;
+
+    res = close( pMI->txt_fd );
+    if (res != 0)
+        goto error_return;
+
+    pMI->txt_fd = -1;
+    errno = 0;
+    if (pMI->txt_zero_fd != -1) {
+        res = close( pMI->txt_zero_fd );
+        pMI->txt_zero_fd = -1;
+    }
+
+ error_return:
+    pMI->txt_errno = errno;
+    return res;
+#else  /* HAVE_MMAP */
+
+    errno = 0;
+    /*
+     *  IF the memory is writable *AND* it is not private (copy-on-write)
+     *     *AND* the memory is "sharable" (seen by other processes)
+     *  THEN rewrite the data.
+     */
+    if (   FILE_WRITABLE(pMI->txt_prot, pMI->txt_flags)
+        && (lseek( pMI->txt_fd, 0, SEEK_SET ) >= 0) ) {
+        write( pMI->txt_fd, pMI->txt_data, pMI->txt_size );
+    }
+
+    close( pMI->txt_fd );
+    pMI->txt_fd = -1;
+    pMI->txt_errno = errno;
+    free( pMI->txt_data );
+
+    return pMI->txt_errno;
+#endif /* HAVE_MMAP */
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/text_mmap.c */
diff --git a/libopts/tokenize.c b/libopts/tokenize.c
new file mode 100644 (file)
index 0000000..0e576ce
--- /dev/null
@@ -0,0 +1,321 @@
+/*
+ *  This file defines the string_tokenize interface
+ * Time-stamp:      "2006-06-24 15:27:49 bkorb"
+ *
+ *  string_tokenize copyright 2005 Bruce Korb
+ *
+ *  string_tokenize is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  string_tokenize is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with string_tokenize; if not, write to:
+ *             The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ */
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#define cc_t   const unsigned char
+#define ch_t   unsigned char
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+copy_cooked( ch_t** ppDest, char const ** ppSrc );
+
+static void
+copy_raw( ch_t** ppDest, char const ** ppSrc );
+/* = = = END-STATIC-FORWARD = = = */
+
+static void
+copy_cooked( ch_t** ppDest, char const ** ppSrc )
+{
+    ch_t* pDest = (ch_t*)*ppDest;
+    const ch_t* pSrc  = (const ch_t*)(*ppSrc + 1);
+
+    for (;;) {
+        ch_t ch = *(pSrc++);
+        switch (ch) {
+        case NUL:   *ppSrc = NULL; return;
+        case '"':   goto done;
+        case '\\':
+            pSrc += ao_string_cook_escape_char( (char*)pSrc, (char*)&ch, 0x7F );
+            if (ch == 0x7F)
+                break;
+            /* FALLTHROUGH */
+
+        default:
+            *(pDest++) = ch;
+        }
+    }
+
+ done:
+    *ppDest = (ch_t*)pDest; /* next spot for storing character */
+    *ppSrc  = (char const *)pSrc;  /* char following closing quote    */
+}
+
+
+static void
+copy_raw( ch_t** ppDest, char const ** ppSrc )
+{
+    ch_t* pDest = *ppDest;
+    cc_t* pSrc  = (cc_t*) (*ppSrc + 1);
+
+    for (;;) {
+        ch_t ch = *(pSrc++);
+        switch (ch) {
+        case NUL:   *ppSrc = NULL; return;
+        case '\'':  goto done;
+        case '\\':
+            /*
+             *  *Four* escapes are handled:  newline removal, escape char
+             *  quoting and apostrophe quoting
+             */
+            switch (*pSrc) {
+            case NUL:   *ppSrc = NULL; return;
+            case '\r':
+                if (*(++pSrc) == '\n')
+                    ++pSrc;
+                continue;
+
+            case '\n':
+                ++pSrc;
+                continue;
+
+            case '\'':
+                ch = '\'';
+                /* FALLTHROUGH */
+
+            case '\\':
+                ++pSrc;
+                break;
+            }
+            /* FALLTHROUGH */
+
+        default:
+            *(pDest++) = ch;
+        }
+    }
+
+ done:
+    *ppDest = pDest; /* next spot for storing character */
+    *ppSrc  = (char const *) pSrc;  /* char following closing quote    */
+}
+
+
+/*=export_func ao_string_tokenize
+ *
+ * what: tokenize an input string
+ *
+ * arg:  + char const* + string + string to be tokenized +
+ *
+ * ret_type:  token_list_t*
+ * ret_desc:  pointer to a structure that lists each token
+ *
+ * doc:
+ *
+ * This function will convert one input string into a list of strings.
+ * The list of strings is derived by separating the input based on
+ * white space separation.  However, if the input contains either single
+ * or double quote characters, then the text after that character up to
+ * a matching quote will become the string in the list.
+ *
+ *  The returned pointer should be deallocated with @code{free(3C)} when
+ *  are done using the data.  The data are placed in a single block of
+ *  allocated memory.  Do not deallocate individual token/strings.
+ *
+ *  The structure pointed to will contain at least these two fields:
+ *  @table @samp
+ *  @item tkn_ct
+ *  The number of tokens found in the input string.
+ *  @item tok_list
+ *  An array of @code{tkn_ct + 1} pointers to substring tokens, with
+ *  the last pointer set to NULL.
+ *  @end table
+ *
+ * There are two types of quoted strings: single quoted (@code{'}) and
+ * double quoted (@code{"}).  Singly quoted strings are fairly raw in that
+ * escape characters (@code{\\}) are simply another character, except when
+ * preceding the following characters:
+ * @example
+ * @code{\\}  double backslashes reduce to one
+ * @code{'}   incorporates the single quote into the string
+ * @code{\n}  suppresses both the backslash and newline character
+ * @end example
+ *
+ * Double quote strings are formed according to the rules of string
+ * constants in ANSI-C programs.
+ *
+ * example:
+ * @example
+ *    #include <stdlib.h>
+ *    int ix;
+ *    token_list_t* ptl = ao_string_tokenize( some_string )
+ *    for (ix = 0; ix < ptl->tkn_ct; ix++)
+ *       do_something_with_tkn( ptl->tkn_list[ix] );
+ *    free( ptl );
+ * @end example
+ * Note that everything is freed with the one call to @code{free(3C)}.
+ *
+ * err:
+ *  NULL is returned and @code{errno} will be set to indicate the problem:
+ *  @itemize @bullet
+ *  @item
+ *  @code{EINVAL} - There was an unterminated quoted string.
+ *  @item
+ *  @code{ENOENT} - The input string was empty.
+ *  @item
+ *  @code{ENOMEM} - There is not enough memory.
+ *  @end itemize
+=*/
+token_list_t*
+ao_string_tokenize( char const* str )
+{
+    int max_token_ct = 1; /* allow for trailing NUL on string */
+    token_list_t* res;
+
+    if (str == NULL)  goto bogus_str;
+
+    /*
+     *  Trim leading white space.  Use "ENOENT" and a NULL return to indicate
+     *  an empty string was passed.
+     */
+    while (isspace( (ch_t)*str ))  str++;
+    if (*str == NUL) {
+    bogus_str:
+        errno = ENOENT;
+        return NULL;
+    }
+
+    /*
+     *  Take an approximate count of tokens.  If no quoted strings are used,
+     *  it will be accurate.  If quoted strings are used, it will be a little
+     *  high and we'll squander the space for a few extra pointers.
+     */
+    {
+        cc_t* pz = (cc_t*)str;
+
+        do {
+            max_token_ct++;
+            while (! isspace( *++pz ))
+                if (*pz == NUL) goto found_nul;
+            while (isspace( *pz ))  pz++;
+        } while (*pz != NUL);
+
+    found_nul:
+        ;
+    }
+
+    res = malloc( sizeof(*res) + strlen(str) + (max_token_ct * sizeof(ch_t*)) );
+    if (res == NULL) {
+        errno = ENOMEM;
+        return res;
+    }
+
+    /*
+     *  Now copy each token into the output buffer.
+     */
+    {
+        ch_t* pzDest = (ch_t*)(res->tkn_list + (max_token_ct + 1));
+        res->tkn_ct  = 0;
+
+        do  {
+            res->tkn_list[ res->tkn_ct++ ] = pzDest;
+            for (;;) {
+                int ch = (ch_t)*str;
+                if (isspace( ch )) {
+                found_white_space:
+                    while (isspace( (ch_t)*++str ))  ;
+                    break;
+                }
+
+                switch (ch) {
+                case '"':
+                    copy_cooked( &pzDest, &str );
+                    if (str == NULL) {
+                        free(res);
+                        errno = EINVAL;
+                        return NULL;
+                    }
+                    if (isspace( (ch_t)*str ))
+                        goto found_white_space;
+                    break;
+
+                case '\'':
+                    copy_raw( &pzDest, &str );
+                    if (str == NULL) {
+                        free(res);
+                        errno = EINVAL;
+                        return NULL;
+                    }
+                    if (isspace( (ch_t)*str ))
+                        goto found_white_space;
+                    break;
+
+                case NUL:
+                    goto copy_done;
+
+                default:
+                    str++;
+                    *(pzDest++) = ch;
+                }
+            } copy_done:;
+
+            /*
+             * NUL terminate the last token and see if we have any more tokens.
+             */
+            *(pzDest++) = NUL;
+        } while (*str != NUL);
+
+        res->tkn_list[ res->tkn_ct ] = NULL;
+    }
+
+    return res;
+}
+
+#ifdef TEST
+#include <stdio.h>
+#include <string.h>
+
+int
+main( int argc, char** argv )
+{
+    if (argc == 1) {
+        printf("USAGE:  %s arg [ ... ]\n", *argv);
+        return 1;
+    }
+    while (--argc > 0) {
+        char* arg = *(++argv);
+        token_list_t* p = ao_string_tokenize( arg );
+        if (p == NULL) {
+            printf( "Parsing string ``%s'' failed:\n\terrno %d (%s)\n",
+                    arg, errno, strerror( errno ));
+        } else {
+            int ix = 0;
+            printf( "Parsed string ``%s''\ninto %d tokens:\n", arg, p->tkn_ct );
+            do {
+                printf( " %3d:  ``%s''\n", ix+1, p->tkn_list[ix] );
+            } while (++ix < p->tkn_ct);
+            free(p);
+        }
+    }
+    return 0;
+}
+#endif
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/tokenize.c */
diff --git a/libopts/usage.c b/libopts/usage.c
new file mode 100644 (file)
index 0000000..960339b
--- /dev/null
@@ -0,0 +1,740 @@
+
+/*
+ *  usage.c  $Id: usage.c,v 4.15 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2007-04-15 11:02:46 bkorb"
+ *
+ *  This module implements the default usage procedure for
+ *  Automated Options.  It may be overridden, of course.
+ *
+ *  Sort options:
+    --start=END-[S]TATIC-FORWARD --patt='^/\*($|[^:])' \
+    --out=xx.c key='^[a-zA-Z0-9_]+\(' --trail='^/\*:' \
+    --spac=2 --input=usage.c
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+#define OPTPROC_L_N_S  (OPTPROC_LONGOPT | OPTPROC_SHORTOPT)
+
+static arg_types_t argTypes;
+
+FILE* option_usage_fp = NULL;
+static char    zOptFmtLine[ 16 ];
+static ag_bool displayEnum;
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static ag_bool
+checkGNUUsage( tOptions* pOpts );
+
+static void
+printExtendedUsage(
+    tOptions*     pOptions,
+    tOptDesc*     pOD,
+    arg_types_t*  pAT );
+
+static void
+printInitList(
+    tCC* const* papz,
+    ag_bool*    pInitIntro,
+    tCC*        pzRc,
+    tCC*        pzPN );
+
+static void
+printOneUsage(
+    tOptions*     pOptions,
+    tOptDesc*     pOD,
+    arg_types_t*  pAT );
+
+static void
+printOptionUsage(
+    tOptions* pOpts,
+    int       ex_code,
+    tCC*      pOptTitle );
+
+static void
+printProgramDetails( tOptions* pOptions );
+
+static int
+setGnuOptFmts( tOptions* pOpts, tCC** ppT );
+
+static int
+setStdOptFmts( tOptions* pOpts, tCC** ppT );
+/* = = = END-STATIC-FORWARD = = = */
+
+
+/*
+ *  Figure out if we should try to format usage text sort-of like
+ *  the way many GNU programs do.
+ */
+static ag_bool
+checkGNUUsage( tOptions* pOpts )
+{
+    char* pz = getenv( "AUTOOPTS_USAGE" );
+    if (pz == NULL)
+        ;
+
+    else if (streqvcmp( pz, "gnu" ) == 0)
+        pOpts->fOptSet |= OPTPROC_GNUUSAGE;
+
+    else if (streqvcmp( pz, "autoopts" ) == 0)
+        pOpts->fOptSet &= ~OPTPROC_GNUUSAGE;
+
+    return (pOpts->fOptSet & OPTPROC_GNUUSAGE) ? AG_TRUE : AG_FALSE;
+}
+
+
+/*=export_func  optionOnlyUsage
+ *
+ * what:  Print usage text for just the options
+ * arg:   + tOptions*   + pOpts    + program options descriptor +
+ * arg:   + int         + ex_code  + exit code for calling exit(3) +
+ *
+ * doc:
+ *  This routine will print only the usage for each option.
+ *  This function may be used when the emitted usage must incorporate
+ *  information not available to AutoOpts.
+=*/
+void
+optionOnlyUsage(
+    tOptions* pOpts,
+    int       ex_code )
+{
+    tCC* pOptTitle = NULL;
+
+    /*
+     *  Determine which header and which option formatting strings to use
+     */
+    if (checkGNUUsage(pOpts)) {
+        (void)setGnuOptFmts( pOpts, &pOptTitle );
+    }
+    else {
+        (void)setStdOptFmts( pOpts, &pOptTitle );
+    }
+
+    printOptionUsage( pOpts, ex_code, pOptTitle );
+}
+
+
+/*=export_func  optionUsage
+ * private:
+ *
+ * what:  Print usage text
+ * arg:   + tOptions* + pOptions + program options descriptor +
+ * arg:   + int       + exitCode + exit code for calling exit(3) +
+ *
+ * doc:
+ *  This routine will print usage in both GNU-standard and AutoOpts-expanded
+ *  formats.  The descriptor specifies the default, but AUTOOPTS_USAGE will
+ *  over-ride this, providing the value of it is set to either "gnu" or
+ *  "autoopts".  This routine will @strong{not} return.
+ *
+ *  If "exitCode" is "EX_USAGE" (normally 64), then output will to to stdout
+ *  and the actual exit code will be "EXIT_SUCCESS".
+=*/
+void
+optionUsage(
+    tOptions* pOptions,
+    int       usage_exit_code )
+{
+    int actual_exit_code =
+        (usage_exit_code == EX_USAGE) ? EXIT_SUCCESS : usage_exit_code;
+
+    displayEnum = AG_FALSE;
+
+    /*
+     *  Paged usage will preset option_usage_fp to an output file.
+     *  If it hasn't already been set, then set it to standard output
+     *  on successful exit (help was requested), otherwise error out.
+     */
+    if (option_usage_fp == NULL)
+        option_usage_fp = (actual_exit_code != EXIT_SUCCESS) ? stderr : stdout;
+
+    fprintf( option_usage_fp, pOptions->pzUsageTitle, pOptions->pzProgName );
+
+    {
+        tCC* pOptTitle = NULL;
+
+        /*
+         *  Determine which header and which option formatting strings to use
+         */
+        if (checkGNUUsage(pOptions)) {
+            int flen = setGnuOptFmts( pOptions, &pOptTitle );
+            sprintf( zOptFmtLine, zFmtFmt, flen );
+            fputc( '\n', option_usage_fp );
+        }
+        else {
+            int flen = setStdOptFmts( pOptions, &pOptTitle );
+            sprintf( zOptFmtLine, zFmtFmt, flen );
+
+            /*
+             *  When we exit with EXIT_SUCCESS and the first option is a doc
+             *  option, we do *NOT* want to emit the column headers.
+             *  Otherwise, we do.
+             */
+            if (  (usage_exit_code != EXIT_SUCCESS)
+               || ((pOptions->pOptDesc->fOptState & OPTST_DOCUMENT) == 0) )
+
+                fputs( pOptTitle, option_usage_fp );
+        }
+
+        printOptionUsage( pOptions, usage_exit_code, pOptTitle );
+    }
+
+    /*
+     *  Describe the mechanics of denoting the options
+     */
+    switch (pOptions->fOptSet & OPTPROC_L_N_S) {
+    case OPTPROC_L_N_S:     fputs( zFlagOkay, option_usage_fp ); break;
+    case OPTPROC_SHORTOPT:  break;
+    case OPTPROC_LONGOPT:   fputs( zNoFlags,  option_usage_fp ); break;
+    case 0:                 fputs( zOptsOnly, option_usage_fp ); break;
+    }
+
+    if ((pOptions->fOptSet & OPTPROC_NUM_OPT) != 0) {
+        fputs( zNumberOpt, option_usage_fp );
+    }
+
+    if ((pOptions->fOptSet & OPTPROC_REORDER) != 0) {
+        fputs( zReorder, option_usage_fp );
+    }
+
+    if (pOptions->pzExplain != NULL)
+        fputs( pOptions->pzExplain, option_usage_fp );
+
+    /*
+     *  IF the user is asking for help (thus exiting with SUCCESS),
+     *  THEN see what additional information we can provide.
+     */
+    if (usage_exit_code == EXIT_SUCCESS)
+        printProgramDetails( pOptions );
+
+    if (pOptions->pzBugAddr != NULL)
+        fprintf( option_usage_fp, zPlsSendBugs, pOptions->pzBugAddr );
+    fflush( option_usage_fp );
+
+    exit( actual_exit_code );
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *   PER OPTION TYPE USAGE INFORMATION
+ */
+static void
+printExtendedUsage(
+    tOptions*     pOptions,
+    tOptDesc*     pOD,
+    arg_types_t*  pAT )
+{
+    /*
+     *  IF there are option conflicts or dependencies,
+     *  THEN print them here.
+     */
+    if (  (pOD->pOptMust != NULL)
+       || (pOD->pOptCant != NULL) ) {
+
+        fputs( zTabHyp, option_usage_fp );
+
+        /*
+         *  DEPENDENCIES:
+         */
+        if (pOD->pOptMust != NULL) {
+            const int* pOptNo = pOD->pOptMust;
+
+            fputs( zReqThese, option_usage_fp );
+            for (;;) {
+                fprintf( option_usage_fp, zTabout, pOptions->pOptDesc[
+                             *pOptNo ].pz_Name );
+                if (*++pOptNo == NO_EQUIVALENT)
+                    break;
+            }
+
+            if (pOD->pOptCant != NULL)
+                fputs( zTabHypAnd, option_usage_fp );
+        }
+
+        /*
+         *  CONFLICTS:
+         */
+        if (pOD->pOptCant != NULL) {
+            const int* pOptNo = pOD->pOptCant;
+
+            fputs( zProhib, option_usage_fp );
+            for (;;) {
+                fprintf( option_usage_fp, zTabout, pOptions->pOptDesc[
+                             *pOptNo ].pz_Name );
+                if (*++pOptNo == NO_EQUIVALENT)
+                    break;
+            }
+        }
+    }
+
+    /*
+     *  IF there is a disablement string
+     *  THEN print the disablement info
+     */
+    if (pOD->pz_DisableName != NULL )
+        fprintf( option_usage_fp, zDis, pOD->pz_DisableName );
+
+    /*
+     *  IF the numeric option has a special callback,
+     *  THEN call it, requesting the range or other special info
+     */
+    if (  (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NUMERIC)
+       && (pOD->pOptProc != NULL)
+       && (pOD->pOptProc != optionNumericVal) ) {
+        (*(pOD->pOptProc))( pOptions, NULL );
+    }
+
+    /*
+     *  IF the option defaults to being enabled,
+     *  THEN print that out
+     */
+    if (pOD->fOptState & OPTST_INITENABLED)
+        fputs( zEnab, option_usage_fp );
+
+    /*
+     *  IF  the option is in an equivalence class
+     *        AND not the designated lead
+     *  THEN print equivalence and leave it at that.
+     */
+    if (  (pOD->optEquivIndex != NO_EQUIVALENT)
+       && (pOD->optEquivIndex != pOD->optActualIndex )  )  {
+        fprintf( option_usage_fp, zAlt,
+                 pOptions->pOptDesc[ pOD->optEquivIndex ].pz_Name );
+        return;
+    }
+
+    /*
+     *  IF this particular option can NOT be preset
+     *    AND some form of presetting IS allowed,
+     *    AND it is not an auto-managed option (e.g. --help, et al.)
+     *  THEN advise that this option may not be preset.
+     */
+    if (  ((pOD->fOptState & OPTST_NO_INIT) != 0)
+       && (  (pOptions->papzHomeList != NULL)
+          || (pOptions->pzPROGNAME != NULL)
+          )
+       && (pOD->optIndex < pOptions->presetOptCt)
+       )
+
+        fputs( zNoPreset, option_usage_fp );
+
+    /*
+     *  Print the appearance requirements.
+     */
+    if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP)
+        fputs( zMembers, option_usage_fp );
+
+    else switch (pOD->optMinCt) {
+    case 1:
+    case 0:
+        switch (pOD->optMaxCt) {
+        case 0:       fputs( zPreset, option_usage_fp ); break;
+        case NOLIMIT: fputs( zNoLim, option_usage_fp );  break;
+        case 1:       break;
+            /*
+             * IF the max is more than one but limited, print "UP TO" message
+             */
+        default:      fprintf( option_usage_fp, zUpTo, pOD->optMaxCt );  break;
+        }
+        break;
+
+    default:
+        /*
+         *  More than one is required.  Print the range.
+         */
+        fprintf( option_usage_fp, zMust, pOD->optMinCt, pOD->optMaxCt );
+    }
+
+    if (  NAMED_OPTS( pOptions )
+       && (pOptions->specOptIdx.default_opt == pOD->optIndex))
+        fputs( zDefaultOpt, option_usage_fp );
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *   Figure out where all the initialization files might live.
+ *   This requires translating some environment variables and
+ *   testing to see if a name is a directory or a file.  It's
+ *   squishy, but important to tell users how to find these files.
+ */
+static void
+printInitList(
+    tCC* const* papz,
+    ag_bool*    pInitIntro,
+    tCC*        pzRc,
+    tCC*        pzPN )
+{
+    char zPath[ AG_PATH_MAX+1 ];
+
+    if (papz == NULL)
+        return;
+
+    fputs( zPresetIntro, option_usage_fp );
+    *pInitIntro = AG_FALSE;
+
+    for (;;) {
+        char const* pzPath = *(papz++);
+
+        if (pzPath == NULL)
+            break;
+
+        if (optionMakePath(zPath, (int)sizeof( zPath ), pzPath, pzPN))
+            pzPath = zPath;
+
+        /*
+         *  Print the name of the "homerc" file.  If the "rcfile" name is
+         *  not empty, we may or may not print that, too...
+         */
+        fprintf( option_usage_fp, zPathFmt, pzPath );
+        if (*pzRc != NUL) {
+            struct stat sb;
+
+            /*
+             *  IF the "homerc" file is a directory,
+             *  then append the "rcfile" name.
+             */
+            if (  (stat( pzPath, &sb ) == 0)
+              &&  S_ISDIR( sb.st_mode ) ) {
+                fputc( DIRCH, option_usage_fp );
+                fputs( pzRc, option_usage_fp );
+            }
+        }
+
+        fputc( '\n', option_usage_fp );
+    }
+}
+
+
+/*
+ *  Print the usage information for a single option.
+ */
+static void
+printOneUsage(
+    tOptions*     pOptions,
+    tOptDesc*     pOD,
+    arg_types_t*  pAT )
+{
+    /*
+     *  Flag prefix: IF no flags at all, then omit it.  If not printable
+     *  (not allowed for this option), then blank, else print it.
+     *  Follow it with a comma if we are doing GNU usage and long
+     *  opts are to be printed too.
+     */
+    if ((pOptions->fOptSet & OPTPROC_SHORTOPT) == 0)
+        fputs( pAT->pzSpc, option_usage_fp );
+    else if (! isgraph( pOD->optValue)) {
+        if (  (pOptions->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
+           == (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
+            fputc( ' ', option_usage_fp );
+        fputs( pAT->pzNoF, option_usage_fp );
+    } else {
+        fprintf( option_usage_fp, "   -%c", pOD->optValue );
+        if (  (pOptions->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
+           == (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
+            fputs( ", ", option_usage_fp );
+    }
+
+    {
+        char  z[ 80 ];
+        tCC*  pzArgType;
+        /*
+         *  Determine the argument type string first on its usage, then,
+         *  when the option argument is required, base the type string on the
+         *  argument type.
+         */
+        if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NONE) {
+            pzArgType = pAT->pzNo;
+
+        } else if (pOD->fOptState & OPTST_ARG_OPTIONAL) {
+            pzArgType = pAT->pzOpt;
+
+        } else switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+        case OPARG_TYPE_ENUMERATION: pzArgType = pAT->pzKey;  break;
+        case OPARG_TYPE_MEMBERSHIP:  pzArgType = pAT->pzKeyL; break;
+        case OPARG_TYPE_BOOLEAN:     pzArgType = pAT->pzBool; break;
+        case OPARG_TYPE_NUMERIC:     pzArgType = pAT->pzNum;  break;
+        case OPARG_TYPE_HIERARCHY:   pzArgType = pAT->pzNest; break;
+        case OPARG_TYPE_STRING:      pzArgType = pAT->pzStr;  break;
+        default:                     goto bogus_desc;         break;
+        }
+
+        snprintf( z, sizeof(z), pAT->pzOptFmt, pzArgType, pOD->pz_Name,
+                  (pOD->optMinCt != 0) ? pAT->pzReq : pAT->pzOpt );
+
+        fprintf( option_usage_fp, zOptFmtLine, z, pOD->pzText );
+
+        switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+        case OPARG_TYPE_ENUMERATION:
+        case OPARG_TYPE_MEMBERSHIP:
+            displayEnum = (pOD->pOptProc != NULL) ? AG_TRUE : displayEnum;
+        }
+    }
+    return;
+
+ bogus_desc:
+    fprintf( stderr, zInvalOptDesc, pOD->pz_Name );
+    exit( EX_SOFTWARE );
+}
+
+
+/*
+ *  Print out the usage information for just the options.
+ */
+static void
+printOptionUsage(
+    tOptions* pOpts,
+    int       ex_code,
+    tCC*      pOptTitle )
+{
+    int        ct     = pOpts->optCt;
+    int        optNo  = 0;
+    tOptDesc*  pOD    = pOpts->pOptDesc;
+    int        docCt  = 0;
+
+    do  {
+        if ((pOD->fOptState & OPTST_OMITTED) != 0)
+            continue;
+
+        if ((pOD->fOptState & OPTST_DOCUMENT) != 0) {
+            if (ex_code == EXIT_SUCCESS) {
+                fprintf(option_usage_fp, argTypes.pzBrk, pOD->pzText,
+                        pOptTitle);
+                docCt++;
+            }
+
+            continue;
+        }
+
+        /*
+         *  IF       this is the first auto-opt maintained option
+         *    *AND*  we are doing a full help
+         *    *AND*  there are documentation options
+         *    *AND*  the last one was not a doc option,
+         *  THEN document that the remaining options are not user opts
+         */
+        if (  (pOpts->presetOptCt == optNo)
+              && (ex_code == EXIT_SUCCESS)
+              && (docCt > 0)
+              && ((pOD[-1].fOptState & OPTST_DOCUMENT) == 0) )
+            fprintf( option_usage_fp, argTypes.pzBrk, zAuto, pOptTitle );
+
+        printOneUsage( pOpts, pOD, &argTypes );
+
+        /*
+         *  IF we were invoked because of the --help option,
+         *  THEN print all the extra info
+         */
+        if (ex_code == EXIT_SUCCESS)
+            printExtendedUsage( pOpts, pOD, &argTypes );
+
+    }  while (pOD++, optNo++, (--ct > 0));
+
+    fputc( '\n', option_usage_fp );
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *   PROGRAM DETAILS
+ */
+static void
+printProgramDetails( tOptions* pOptions )
+{
+    ag_bool  initIntro = AG_TRUE;
+
+    /*
+     *  Display all the places we look for config files
+     */
+    printInitList( pOptions->papzHomeList, &initIntro,
+                   pOptions->pzRcName, pOptions->pzProgPath );
+
+    /*
+     *  Let the user know about environment variable settings
+     */
+    if ((pOptions->fOptSet & OPTPROC_ENVIRON) != 0) {
+        if (initIntro)
+            fputs( zPresetIntro, option_usage_fp );
+
+        fprintf( option_usage_fp, zExamineFmt, pOptions->pzPROGNAME );
+    }
+
+    /*
+     *  IF we found an enumeration,
+     *  THEN hunt for it again.  Call the handler proc with a NULL
+     *       option struct pointer.  That tells it to display the keywords.
+     */
+    if (displayEnum) {
+        int        ct     = pOptions->optCt;
+        int        optNo  = 0;
+        tOptDesc*  pOD    = pOptions->pOptDesc;
+
+        fputc( '\n', option_usage_fp );
+        fflush( option_usage_fp );
+        do  {
+            switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+            case OPARG_TYPE_ENUMERATION:
+            case OPARG_TYPE_MEMBERSHIP:
+                (*(pOD->pOptProc))( NULL, pOD );
+            }
+        }  while (pOD++, optNo++, (--ct > 0));
+    }
+
+    /*
+     *  If there is a detail string, now is the time for that.
+     */
+    if (pOptions->pzDetail != NULL)
+        fputs( pOptions->pzDetail, option_usage_fp );
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *   OPTION LINE FORMATTING SETUP
+ *
+ *  The "OptFmt" formats receive three arguments:
+ *  1.  the type of the option's argument
+ *  2.  the long name of the option
+ *  3.  "YES" or "no ", depending on whether or not the option must appear
+ *      on the command line.
+ *  These formats are used immediately after the option flag (if used) has
+ *  been printed.
+ *
+ *  Set up the formatting for GNU-style output
+ */
+static int
+setGnuOptFmts( tOptions* pOpts, tCC** ppT )
+{
+    int  flen = 22;
+    *ppT = zNoRq_ShrtTtl;
+
+    argTypes.pzStr  = zGnuStrArg;
+    argTypes.pzReq  = zOneSpace;
+    argTypes.pzNum  = zGnuNumArg;
+    argTypes.pzKey  = zGnuKeyArg;
+    argTypes.pzKeyL = zGnuKeyLArg;
+    argTypes.pzBool = zGnuBoolArg;
+    argTypes.pzNest = zGnuNestArg;
+    argTypes.pzOpt  = zGnuOptArg;
+    argTypes.pzNo   = zOneSpace;
+    argTypes.pzBrk  = zGnuBreak;
+    argTypes.pzNoF  = zSixSpaces;
+    argTypes.pzSpc  = zThreeSpaces;
+
+    switch (pOpts->fOptSet & OPTPROC_L_N_S) {
+    case OPTPROC_L_N_S:    argTypes.pzOptFmt = zGnuOptFmt;     break;
+    case OPTPROC_LONGOPT:  argTypes.pzOptFmt = zGnuOptFmt;     break;
+    case 0:                argTypes.pzOptFmt = zGnuOptFmt + 2; break;
+    case OPTPROC_SHORTOPT:
+        argTypes.pzOptFmt = zShrtGnuOptFmt;
+        zGnuStrArg[0] = zGnuNumArg[0] = zGnuKeyArg[0] = zGnuBoolArg[0] = ' ';
+        argTypes.pzOpt = " [arg]";
+        flen = 8;
+        break;
+    }
+
+    return flen;
+}
+
+
+/*
+ *  Standard (AutoOpts normal) option line formatting
+ */
+static int
+setStdOptFmts( tOptions* pOpts, tCC** ppT )
+{
+    int  flen = 0;
+
+    argTypes.pzStr  = zStdStrArg;
+    argTypes.pzReq  = zStdReqArg;
+    argTypes.pzNum  = zStdNumArg;
+    argTypes.pzKey  = zStdKeyArg;
+    argTypes.pzKeyL = zStdKeyLArg;
+    argTypes.pzBool = zStdBoolArg;
+    argTypes.pzNest = zStdNestArg;
+    argTypes.pzOpt  = zStdOptArg;
+    argTypes.pzNo   = zStdNoArg;
+    argTypes.pzBrk  = zStdBreak;
+    argTypes.pzNoF  = zFiveSpaces;
+    argTypes.pzSpc  = zTwoSpaces;
+
+    switch (pOpts->fOptSet & (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT)) {
+    case (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT):
+        *ppT = zNoRq_ShrtTtl;
+        argTypes.pzOptFmt = zNrmOptFmt;
+        flen = 19;
+        break;
+
+    case OPTPROC_NO_REQ_OPT:
+        *ppT = zNoRq_NoShrtTtl;
+        argTypes.pzOptFmt = zNrmOptFmt;
+        flen = 19;
+        break;
+
+    case OPTPROC_SHORTOPT:
+        *ppT = zReq_ShrtTtl;
+        argTypes.pzOptFmt = zReqOptFmt;
+        flen = 24;
+        break;
+
+    case 0:
+        *ppT = zReq_NoShrtTtl;
+        argTypes.pzOptFmt = zReqOptFmt;
+        flen = 24;
+    }
+
+    return flen;
+}
+
+
+/*:
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/usage.c */
diff --git a/libopts/version.c b/libopts/version.c
new file mode 100644 (file)
index 0000000..85949d5
--- /dev/null
@@ -0,0 +1,178 @@
+
+/*  $Id: version.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2007-04-28 10:08:34 bkorb"
+ *
+ *  This module implements the default usage procedure for
+ *  Automated Options.  It may be overridden, of course.
+ */
+
+static char const zAOV[] =
+    "Automated Options version %s, copyright (c) 1999-2007 Bruce Korb\n";
+
+/*  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*=export_func  optionVersion
+ *
+ * what:     return the compiled AutoOpts version number
+ * ret_type: char const*
+ * ret_desc: the version string in constant memory
+ * doc:
+ *  Returns the full version string compiled into the library.
+ *  The returned string cannot be modified.
+=*/
+char const*
+optionVersion( void )
+{
+    static char const zVersion[] =
+        STR( AO_CURRENT.AO_REVISION );
+
+    return zVersion;
+}
+
+
+static void
+printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp )
+{
+    char swCh;
+
+    /*
+     *  IF the optional argument flag is off, or the argument is not provided,
+     *  then just print the version.
+     */
+    if (  ((pOD->fOptState & OPTST_ARG_OPTIONAL) == 0)
+       || (pOD->optArg.argString == NULL))
+         swCh = 'v';
+    else swCh = tolower(pOD->optArg.argString[0]);
+
+    if (pOpts->pzFullVersion != NULL) {
+        fputs( pOpts->pzFullVersion, fp );
+        fputc( '\n', fp );
+
+    } else {
+        char const *pz = pOpts->pzUsageTitle;
+        do { fputc(*pz, fp); } while (*(pz++) != '\n');
+    }
+
+    switch (swCh) {
+    case NUL: /* arg provided, but empty */
+    case 'v':
+        break;
+
+    case 'c':
+        if (pOpts->pzCopyright != NULL) {
+            fputs( pOpts->pzCopyright, fp );
+            fputc( '\n', fp );
+        }
+        fprintf( fp, zAOV, optionVersion() );
+        if (pOpts->pzBugAddr != NULL)
+            fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr );
+        break;
+
+    case 'n':
+        if (pOpts->pzCopyright != NULL) {
+            fputs( pOpts->pzCopyright, fp );
+            fputc( '\n', fp );
+            fputc( '\n', fp );
+        }
+
+        if (pOpts->pzCopyNotice != NULL) {
+            fputs( pOpts->pzCopyNotice, fp );
+            fputc( '\n', fp );
+        }
+
+        fprintf( fp, zAOV, optionVersion() );
+        if (pOpts->pzBugAddr != NULL)
+            fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr );
+        break;
+
+    default:
+        fprintf( stderr, zBadVerArg, swCh );
+        exit( EXIT_FAILURE );
+    }
+
+    exit( EXIT_SUCCESS );
+}
+
+/*=export_func  optionPrintVersion
+ * private:
+ *
+ * what:  Print the program version
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  This routine will print the version to stdout.
+=*/
+void
+optionPrintVersion( tOptions*  pOpts, tOptDesc*  pOD )
+{
+    printVersion( pOpts, pOD, stdout );
+}
+
+/*=export_func  optionVersionStderr
+ * private:
+ *
+ * what:  Print the program version to stderr
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  This routine will print the version to stderr.
+=*/
+void
+optionVersionStderr( tOptions*  pOpts, tOptDesc*  pOD )
+{
+    printVersion( pOpts, pOD, stderr );
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/version.c */
diff --git a/libparse/Makefile.am b/libparse/Makefile.am
new file mode 100644 (file)
index 0000000..8e21463
--- /dev/null
@@ -0,0 +1,168 @@
+#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+noinst_LIBRARIES = @MAKE_LIBPARSE@ @MAKE_LIBPARSE_KERNEL@
+EXTRA_LIBRARIES = libparse.a libparse_kernel.a
+EXTRA_PROGRAMS = parsestreams parsesolaris
+noinst_PROGRAMS = @MAKE_PARSEKMODULE@
+CLEANFILES = libparse.a libparse_kernel.a
+
+K_CFLAGS = -DPARSESTREAM -DNTP_NEED_BOPS
+
+libparse_a_SOURCES = parse.c \
+                     parse_conf.c \
+                     clk_meinberg.c \
+                     clk_schmid.c \
+                    clk_rawdcf.c \
+                    clk_trimtsip.c \
+                    clk_dcf7000.c \
+                     clk_trimtaip.c \
+                     clk_rcc8000.c \
+                     clk_hopf6021.c \
+                    clk_computime.c \
+                    clk_wharton.c \
+                    clk_varitext.c \
+                     data_mbg.c \
+                    info_trimble.c \
+                    trim_info.c \
+                    binio.c \
+                    ieee754io.c \
+                    mfp_mul.c \
+                    gpstolfp.c
+
+libparse_kernel_a_SOURCES = 
+libparse_kernel_a_LIBADD = kparse$U.o \
+                           kparse_conf$U.o \
+                           kclk_computime$U.o \
+                           kclk_dcf7000$U.o \
+                           kclk_hopf6021$U.o \
+                           kclk_meinberg$U.o \
+                           kclk_rawdcf$U.o \
+                           kclk_rcc8000$U.o \
+                           kclk_schmid$U.o \
+                           kclk_trimtaip$U.o \
+                           kclk_trimtsip$U.o \
+                           kclk_varitext$U.o \
+                           kclk_wharton$U.o \
+                           kbinio$U.o \
+                           kieee754io$U.o \
+                           kmfp_mul$U.o \
+                           kgpstolfp$U.o
+
+
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/kernel
+ETAGS_ARGS = Makefile.am
+
+EXTRA_DIST = parsesolaris.c parsestreams.c mkinfo_scmd.sed mkinfo_rcmd.sed info_trimble.c
+
+#
+# create info_trimble.c
+#
+info_trimble.c: $(top_srcdir)/include/trimble.h mkinfo_rcmd.sed mkinfo_scmd.sed
+       @rm -f info_trimble.c
+       sed -n -f $(srcdir)/mkinfo_scmd.sed $(top_srcdir)/include/trimble.h  > info_trimble.c || rm -f info_trimble.c
+       sed -n -f $(srcdir)/mkinfo_rcmd.sed $(top_srcdir)/include/trimble.h >> info_trimble.c || rm -f info_trimble.c
+
+kieee754io.o: ieee754io.c
+        $(COMPILE) $(K_CFLAGS) -c $(srcdir)/ieee754io.c -o $@
+
+kmfp_mul.o: mfp_mul.c
+        $(COMPILE) $(K_CFLAGS) -c $(srcdir)/mfp_mul.c -o $@
+
+kgpstolfp.o: gpstolfp.c
+        $(COMPILE) $(K_CFLAGS) -c $(srcdir)/gpstolfp.c -o $@
+
+kbinio.o: binio.c
+        $(COMPILE) $(K_CFLAGS) -c $(srcdir)/binio.c -o $@
+
+kclk_computime.o: clk_computime.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_computime.c -o $@
+
+kclk_computime_.o: clk_computime_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_computime_.c -o $@
+
+kclk_dcf7000.o: clk_dcf7000.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_dcf7000.c -o $@
+
+kclk_dcf7000_.o: clk_dcf7000_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_dcf7000_.c -o $@
+
+kclk_hopf6021.o: clk_hopf6021.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_hopf6021.c -o $@
+
+kclk_hopf6021_.o: clk_hopf6021_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_hopf6021_.c -o $@
+
+kclk_meinberg.o: clk_meinberg.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_meinberg.c -o $@
+
+kclk_meinberg_.o: clk_meinberg_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_meinberg_.c -o $@
+
+kclk_rawdcf.o: clk_rawdcf.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_rawdcf.c -o $@
+
+kclk_rawdcf_.o: clk_rawdcf_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_rawdcf_.c -o $@
+
+kclk_rcc8000.o: clk_rcc8000.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_rcc8000.c -o $@
+
+kclk_rcc8000_.o: clk_rcc8000_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_rcc8000_.c -o $@
+
+kclk_schmid.o: clk_schmid.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_schmid.c -o $@
+
+kclk_schmid_.o: clk_schmid_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_schmid_.c -o $@
+
+kclk_trimtaip.o: clk_trimtaip.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_trimtaip.c -o $@
+
+kclk_trimtaip_.o: clk_trimtaip_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_trimtaip_.c -o $@
+
+kclk_trimtsip.o: clk_trimtsip.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_trimtsip.c -o $@
+
+kclk_trimtsip_.o: clk_trimtsip_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_trimtsip_.c -o $@
+
+kclk_varitext.o: clk_varitext.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_varitext.c -o $@
+
+kclk_varitext_.o: clk_varitext_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_varitext_.c -o $@
+
+kclk_wharton.o: clk_wharton.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_wharton.c -o $@
+
+kclk_wharton_.o: clk_wharton_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_wharton_.c -o $@
+
+kparse.o: parse.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/parse.c -o $@
+
+kparse_.o: parse_.c
+       $(COMPILE) $(K_CFLAGS) -c parse_.c -o $@
+
+kparse_conf.o: parse_conf.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/parse_conf.c -o $@
+
+kparse_conf_.o: parse_conf_.c
+       $(COMPILE) $(K_CFLAGS) -c parse_conf_.c -o $@
+
+parsestreams.loadable_module.o: $(parsestreams_OBJECTS) libparse_kernel.a ../libntp/libntp.a
+       $(LD) -r -o $@ $(parsestreams_OBJECTS) libparse_kernel.a ../libntp/libntp.a
+
+parse: $(parsesolaris_OBJECTS) libparse_kernel.a ../libntp/libntp.a
+       $(LD) -r -o $@ $(parsesolaris_OBJECTS) libparse_kernel.a ../libntp/libntp.a
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE)
+
+parsesolaris.o: sys/systm.h
+
+sys/systm.h:
+       mkdir sys && \
+       sed -e '/ffs(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
diff --git a/libparse/Makefile.in b/libparse/Makefile.in
new file mode 100644 (file)
index 0000000..4b42f74
--- /dev/null
@@ -0,0 +1,785 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+ANSI2KNR = ../util/ansi2knr
+EXTRA_PROGRAMS = parsestreams$(EXEEXT) parsesolaris$(EXEEXT)
+subdir = libparse
+DIST_COMMON = README $(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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libparse_a_AR = $(AR) $(ARFLAGS)
+libparse_a_LIBADD =
+am_libparse_a_OBJECTS = parse$U.$(OBJEXT) parse_conf$U.$(OBJEXT) \
+       clk_meinberg$U.$(OBJEXT) clk_schmid$U.$(OBJEXT) \
+       clk_rawdcf$U.$(OBJEXT) clk_trimtsip$U.$(OBJEXT) \
+       clk_dcf7000$U.$(OBJEXT) clk_trimtaip$U.$(OBJEXT) \
+       clk_rcc8000$U.$(OBJEXT) clk_hopf6021$U.$(OBJEXT) \
+       clk_computime$U.$(OBJEXT) clk_wharton$U.$(OBJEXT) \
+       clk_varitext$U.$(OBJEXT) data_mbg$U.$(OBJEXT) \
+       info_trimble$U.$(OBJEXT) trim_info$U.$(OBJEXT) \
+       binio$U.$(OBJEXT) ieee754io$U.$(OBJEXT) mfp_mul$U.$(OBJEXT) \
+       gpstolfp$U.$(OBJEXT)
+libparse_a_OBJECTS = $(am_libparse_a_OBJECTS)
+libparse_kernel_a_AR = $(AR) $(ARFLAGS)
+libparse_kernel_a_DEPENDENCIES = kparse$U.o kparse_conf$U.o \
+       kclk_computime$U.o kclk_dcf7000$U.o kclk_hopf6021$U.o \
+       kclk_meinberg$U.o kclk_rawdcf$U.o kclk_rcc8000$U.o \
+       kclk_schmid$U.o kclk_trimtaip$U.o kclk_trimtsip$U.o \
+       kclk_varitext$U.o kclk_wharton$U.o kbinio$U.o kieee754io$U.o \
+       kmfp_mul$U.o kgpstolfp$U.o
+am_libparse_kernel_a_OBJECTS =
+libparse_kernel_a_OBJECTS = $(am_libparse_kernel_a_OBJECTS)
+PROGRAMS = $(noinst_PROGRAMS)
+parsesolaris_SOURCES = parsesolaris.c
+parsesolaris_OBJECTS = parsesolaris$U.$(OBJEXT)
+parsesolaris_LDADD = $(LDADD)
+parsestreams_SOURCES = parsestreams.c
+parsestreams_OBJECTS = parsestreams$U.$(OBJEXT)
+parsestreams_LDADD = $(LDADD)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(libparse_a_SOURCES) $(libparse_kernel_a_SOURCES) \
+       parsesolaris.c parsestreams.c
+DIST_SOURCES = $(libparse_a_SOURCES) $(libparse_kernel_a_SOURCES) \
+       parsesolaris.c parsestreams.c
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+noinst_LIBRARIES = @MAKE_LIBPARSE@ @MAKE_LIBPARSE_KERNEL@
+EXTRA_LIBRARIES = libparse.a libparse_kernel.a
+noinst_PROGRAMS = @MAKE_PARSEKMODULE@
+CLEANFILES = libparse.a libparse_kernel.a
+K_CFLAGS = -DPARSESTREAM -DNTP_NEED_BOPS
+libparse_a_SOURCES = parse.c \
+                     parse_conf.c \
+                     clk_meinberg.c \
+                     clk_schmid.c \
+                    clk_rawdcf.c \
+                    clk_trimtsip.c \
+                    clk_dcf7000.c \
+                     clk_trimtaip.c \
+                     clk_rcc8000.c \
+                     clk_hopf6021.c \
+                    clk_computime.c \
+                    clk_wharton.c \
+                    clk_varitext.c \
+                     data_mbg.c \
+                    info_trimble.c \
+                    trim_info.c \
+                    binio.c \
+                    ieee754io.c \
+                    mfp_mul.c \
+                    gpstolfp.c
+
+libparse_kernel_a_SOURCES = 
+libparse_kernel_a_LIBADD = kparse$U.o \
+                           kparse_conf$U.o \
+                           kclk_computime$U.o \
+                           kclk_dcf7000$U.o \
+                           kclk_hopf6021$U.o \
+                           kclk_meinberg$U.o \
+                           kclk_rawdcf$U.o \
+                           kclk_rcc8000$U.o \
+                           kclk_schmid$U.o \
+                           kclk_trimtaip$U.o \
+                           kclk_trimtsip$U.o \
+                           kclk_varitext$U.o \
+                           kclk_wharton$U.o \
+                           kbinio$U.o \
+                           kieee754io$U.o \
+                           kmfp_mul$U.o \
+                           kgpstolfp$U.o
+
+INCLUDES = -I$(top_srcdir)/include -I$(top_srcdir)/kernel
+ETAGS_ARGS = Makefile.am
+EXTRA_DIST = parsesolaris.c parsestreams.c mkinfo_scmd.sed mkinfo_rcmd.sed info_trimble.c
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign libparse/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign libparse/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+       -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libparse.a: $(libparse_a_OBJECTS) $(libparse_a_DEPENDENCIES) 
+       -rm -f libparse.a
+       $(libparse_a_AR) libparse.a $(libparse_a_OBJECTS) $(libparse_a_LIBADD)
+       $(RANLIB) libparse.a
+libparse_kernel.a: $(libparse_kernel_a_OBJECTS) $(libparse_kernel_a_DEPENDENCIES) 
+       -rm -f libparse_kernel.a
+       $(libparse_kernel_a_AR) libparse_kernel.a $(libparse_kernel_a_OBJECTS) $(libparse_kernel_a_LIBADD)
+       $(RANLIB) libparse_kernel.a
+
+clean-noinstPROGRAMS:
+       @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+parsesolaris$(EXEEXT): $(parsesolaris_OBJECTS) $(parsesolaris_DEPENDENCIES) 
+       @rm -f parsesolaris$(EXEEXT)
+       $(LINK) $(parsesolaris_OBJECTS) $(parsesolaris_LDADD) $(LIBS)
+parsestreams$(EXEEXT): $(parsestreams_OBJECTS) $(parsestreams_DEPENDENCIES) 
+       @rm -f parsestreams$(EXEEXT)
+       $(LINK) $(parsestreams_OBJECTS) $(parsestreams_LDADD) $(LIBS)
+
+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)/binio$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_computime$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_dcf7000$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_hopf6021$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_meinberg$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_rawdcf$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_rcc8000$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_schmid$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_trimtaip$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_trimtsip$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_varitext$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/clk_wharton$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/data_mbg$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/gpstolfp$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ieee754io$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/info_trimble$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mfp_mul$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parse_conf$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parsesolaris$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/parsestreams$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/trim_info$U.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+binio_.c: binio.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/binio.c; then echo $(srcdir)/binio.c; else echo binio.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_computime_.c: clk_computime.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_computime.c; then echo $(srcdir)/clk_computime.c; else echo clk_computime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_dcf7000_.c: clk_dcf7000.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_dcf7000.c; then echo $(srcdir)/clk_dcf7000.c; else echo clk_dcf7000.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_hopf6021_.c: clk_hopf6021.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_hopf6021.c; then echo $(srcdir)/clk_hopf6021.c; else echo clk_hopf6021.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_meinberg_.c: clk_meinberg.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_meinberg.c; then echo $(srcdir)/clk_meinberg.c; else echo clk_meinberg.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_rawdcf_.c: clk_rawdcf.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_rawdcf.c; then echo $(srcdir)/clk_rawdcf.c; else echo clk_rawdcf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_rcc8000_.c: clk_rcc8000.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_rcc8000.c; then echo $(srcdir)/clk_rcc8000.c; else echo clk_rcc8000.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_schmid_.c: clk_schmid.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_schmid.c; then echo $(srcdir)/clk_schmid.c; else echo clk_schmid.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_trimtaip_.c: clk_trimtaip.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_trimtaip.c; then echo $(srcdir)/clk_trimtaip.c; else echo clk_trimtaip.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_trimtsip_.c: clk_trimtsip.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_trimtsip.c; then echo $(srcdir)/clk_trimtsip.c; else echo clk_trimtsip.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_varitext_.c: clk_varitext.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_varitext.c; then echo $(srcdir)/clk_varitext.c; else echo clk_varitext.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+clk_wharton_.c: clk_wharton.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/clk_wharton.c; then echo $(srcdir)/clk_wharton.c; else echo clk_wharton.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+data_mbg_.c: data_mbg.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/data_mbg.c; then echo $(srcdir)/data_mbg.c; else echo data_mbg.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+gpstolfp_.c: gpstolfp.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/gpstolfp.c; then echo $(srcdir)/gpstolfp.c; else echo gpstolfp.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ieee754io_.c: ieee754io.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ieee754io.c; then echo $(srcdir)/ieee754io.c; else echo ieee754io.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+info_trimble_.c: info_trimble.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/info_trimble.c; then echo $(srcdir)/info_trimble.c; else echo info_trimble.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+mfp_mul_.c: mfp_mul.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/mfp_mul.c; then echo $(srcdir)/mfp_mul.c; else echo mfp_mul.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+parse_.c: parse.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/parse.c; then echo $(srcdir)/parse.c; else echo parse.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+parse_conf_.c: parse_conf.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/parse_conf.c; then echo $(srcdir)/parse_conf.c; else echo parse_conf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+parsesolaris_.c: parsesolaris.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/parsesolaris.c; then echo $(srcdir)/parsesolaris.c; else echo parsesolaris.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+parsestreams_.c: parsestreams.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/parsestreams.c; then echo $(srcdir)/parsestreams.c; else echo parsestreams.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+trim_info_.c: trim_info.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/trim_info.c; then echo $(srcdir)/trim_info.c; else echo trim_info.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+binio_.$(OBJEXT) binio_.lo clk_computime_.$(OBJEXT) clk_computime_.lo \
+clk_dcf7000_.$(OBJEXT) clk_dcf7000_.lo clk_hopf6021_.$(OBJEXT) \
+clk_hopf6021_.lo clk_meinberg_.$(OBJEXT) clk_meinberg_.lo \
+clk_rawdcf_.$(OBJEXT) clk_rawdcf_.lo clk_rcc8000_.$(OBJEXT) \
+clk_rcc8000_.lo clk_schmid_.$(OBJEXT) clk_schmid_.lo \
+clk_trimtaip_.$(OBJEXT) clk_trimtaip_.lo clk_trimtsip_.$(OBJEXT) \
+clk_trimtsip_.lo clk_varitext_.$(OBJEXT) clk_varitext_.lo \
+clk_wharton_.$(OBJEXT) clk_wharton_.lo data_mbg_.$(OBJEXT) \
+data_mbg_.lo gpstolfp_.$(OBJEXT) gpstolfp_.lo ieee754io_.$(OBJEXT) \
+ieee754io_.lo info_trimble_.$(OBJEXT) info_trimble_.lo \
+mfp_mul_.$(OBJEXT) mfp_mul_.lo parse_.$(OBJEXT) parse_.lo \
+parse_conf_.$(OBJEXT) parse_conf_.lo parsesolaris_.$(OBJEXT) \
+parsesolaris_.lo parsestreams_.$(OBJEXT) parsestreams_.lo \
+trim_info_.$(OBJEXT) trim_info_.lo : $(ANSI2KNR)
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+       -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstLIBRARIES \
+       clean-noinstPROGRAMS mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+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 clean-noinstPROGRAMS 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
+
+
+#
+# create info_trimble.c
+#
+info_trimble.c: $(top_srcdir)/include/trimble.h mkinfo_rcmd.sed mkinfo_scmd.sed
+       @rm -f info_trimble.c
+       sed -n -f $(srcdir)/mkinfo_scmd.sed $(top_srcdir)/include/trimble.h  > info_trimble.c || rm -f info_trimble.c
+       sed -n -f $(srcdir)/mkinfo_rcmd.sed $(top_srcdir)/include/trimble.h >> info_trimble.c || rm -f info_trimble.c
+
+kieee754io.o: ieee754io.c
+        $(COMPILE) $(K_CFLAGS) -c $(srcdir)/ieee754io.c -o $@
+
+kmfp_mul.o: mfp_mul.c
+        $(COMPILE) $(K_CFLAGS) -c $(srcdir)/mfp_mul.c -o $@
+
+kgpstolfp.o: gpstolfp.c
+        $(COMPILE) $(K_CFLAGS) -c $(srcdir)/gpstolfp.c -o $@
+
+kbinio.o: binio.c
+        $(COMPILE) $(K_CFLAGS) -c $(srcdir)/binio.c -o $@
+
+kclk_computime.o: clk_computime.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_computime.c -o $@
+
+kclk_computime_.o: clk_computime_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_computime_.c -o $@
+
+kclk_dcf7000.o: clk_dcf7000.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_dcf7000.c -o $@
+
+kclk_dcf7000_.o: clk_dcf7000_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_dcf7000_.c -o $@
+
+kclk_hopf6021.o: clk_hopf6021.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_hopf6021.c -o $@
+
+kclk_hopf6021_.o: clk_hopf6021_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_hopf6021_.c -o $@
+
+kclk_meinberg.o: clk_meinberg.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_meinberg.c -o $@
+
+kclk_meinberg_.o: clk_meinberg_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_meinberg_.c -o $@
+
+kclk_rawdcf.o: clk_rawdcf.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_rawdcf.c -o $@
+
+kclk_rawdcf_.o: clk_rawdcf_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_rawdcf_.c -o $@
+
+kclk_rcc8000.o: clk_rcc8000.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_rcc8000.c -o $@
+
+kclk_rcc8000_.o: clk_rcc8000_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_rcc8000_.c -o $@
+
+kclk_schmid.o: clk_schmid.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_schmid.c -o $@
+
+kclk_schmid_.o: clk_schmid_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_schmid_.c -o $@
+
+kclk_trimtaip.o: clk_trimtaip.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_trimtaip.c -o $@
+
+kclk_trimtaip_.o: clk_trimtaip_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_trimtaip_.c -o $@
+
+kclk_trimtsip.o: clk_trimtsip.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_trimtsip.c -o $@
+
+kclk_trimtsip_.o: clk_trimtsip_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_trimtsip_.c -o $@
+
+kclk_varitext.o: clk_varitext.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_varitext.c -o $@
+
+kclk_varitext_.o: clk_varitext_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_varitext_.c -o $@
+
+kclk_wharton.o: clk_wharton.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/clk_wharton.c -o $@
+
+kclk_wharton_.o: clk_wharton_.c
+       $(COMPILE) $(K_CFLAGS) -c clk_wharton_.c -o $@
+
+kparse.o: parse.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/parse.c -o $@
+
+kparse_.o: parse_.c
+       $(COMPILE) $(K_CFLAGS) -c parse_.c -o $@
+
+kparse_conf.o: parse_conf.c
+       $(COMPILE) $(K_CFLAGS) -c $(srcdir)/parse_conf.c -o $@
+
+kparse_conf_.o: parse_conf_.c
+       $(COMPILE) $(K_CFLAGS) -c parse_conf_.c -o $@
+
+parsestreams.loadable_module.o: $(parsestreams_OBJECTS) libparse_kernel.a ../libntp/libntp.a
+       $(LD) -r -o $@ $(parsestreams_OBJECTS) libparse_kernel.a ../libntp/libntp.a
+
+parse: $(parsesolaris_OBJECTS) libparse_kernel.a ../libntp/libntp.a
+       $(LD) -r -o $@ $(parsesolaris_OBJECTS) libparse_kernel.a ../libntp/libntp.a
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE)
+
+parsesolaris.o: sys/systm.h
+
+sys/systm.h:
+       mkdir sys && \
+       sed -e '/ffs(.*)/d' < /usr/include/sys/systm.h > sys/systm.h
+
+# 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.
+.NOEXPORT:
diff --git a/libparse/README b/libparse/README
new file mode 100644 (file)
index 0000000..ac77054
--- /dev/null
@@ -0,0 +1,96 @@
+PARSE reference clock driver:
+
+This directory contains the files making up the parser for
+the parse refclock driver. For reasonably sane clocks this refclock
+drivers allows a refclock implementation by just providing a
+conversion routine and the appropriate NTP parameters. Refclock
+support can run as low a 3k code with the parse refclock driver.
+
+The modules in here are designed to live in two worlds. In userlevel
+as part of the xntp daemon and in kernel land as part of a STREAMS module
+or, if someone gets to it, as part of a line discipline. Currently only
+SunOS4.x/SunOS5.x STREAMS are supported (volunteers for other vendors like HP?).
+This structure means, that refclock_parse can work with or without kernel
+support. Kernelsupport increases accuracy tremendingly. The current restriction
+of the parse driver is that it only supports SYSV type ttys and that kernel
+support is only available for Suns right now.
+
+Three kernel modules are part of this directory. These work only on
+SunOS (SunOS4 and SunOS5).
+
+       SunOS4 (aka Solaris 1.x):
+               parsestreams.loadable_module.o  - standard parse module for SunOS 4
+
+               Both modules can be loaded via modload <modulename>.
+
+       SunOS5 (aka Solaris 2.x):
+               parse           - auto loadable streams module
+
+               To install just drop "parse" into /kernel/strmod and
+               start the daemon (SunOS5 will do the rest).
+
+The structure of the parse reference clock driver is as follows:
+
+       ntpd    - contains NTP implementation and calls a reference clock
+                 127.127.8.x which is implemented by
+                 refclock_parse.c
+                 - which contains several refclock decriptions. These are
+                   selected by the x part of the refclock address.
+                   The lower two bits specify the device to use. Thus the
+                   value (x % 4) determines the device to open
+                   (/dev/refclock-0 - /dev/refclock-3).
+
+                   The kind of clock is selected by the mode parameter. This parameter
+                   selects the clock type which deterimines how I/O is done,
+                   the tty parameters and the NTP parameters.
+
+                   refclock_parse operates on an abstract reference clock
+                   that delivers time stamps and stati. Offsets and sychron-
+                   isation information is derived from this data and passed
+                   on to refclock_receive of xntp which uses that data for
+                   syncronisation.
+
+                   The abstract reference clock is generated by the parse*
+                   routines. They parse the incoming data stream from the
+                   clock and convert it to the appropriate time stamps.
+                   The data is also mapped int the abstract clock states
+                       POWERUP - clock has no valid phase and time code
+                                 information
+
+                       NOSYNC  - Time code is not confirmed, phase is probably
+                                 ok.
+                       SYNC    - Time code and phase are correct.
+
+                   A clock is trusted for a certain time (type parameter) when
+                   it leaves the SYNC state. This is derived from the
+                   observation that quite a few clocks can still generate good
+                   time code information when losing contact to their
+                   synchronisation source. When the clock does not reagain
+                   synchronisation in that trust period it will be deemed
+                   unsynchronised until it regains synchronisation. The same
+                   will happen if xntp sees the clock unsynchronised at
+                   startup.
+
+                   The upper bit of x specifies that all samples delivered
+                   from the clock should be used to discipline the NTP
+                   loopfilter. For clock with accurate once a second time
+                   information this means big improvements for time keeping.
+                   A prerequisite for passing on the time stamps to
+                   the loopfilter is, that the clock is in synchronised state.
+
+          parse.c  These are the general routines to parse the incoming data
+                   stream. Usually these routines should not require
+                   modification.
+
+          clk_*.c  These files hole the conversion code for the time stamps
+                   and the description how the time code can be parsed and
+                   where the time stamps are to be taken.
+                   If you want to add a new clock type this is the file
+                   you need to write in addition to mention it in
+                   parse_conf.c and setting up the NTP and TTY parameters
+                   in refclock_parse.c.
+
+Further information can be found in parse/README.parse and the various source
+files.
+
+Frank Kardel
diff --git a/libparse/binio.c b/libparse/binio.c
new file mode 100644 (file)
index 0000000..2f8546b
--- /dev/null
@@ -0,0 +1,155 @@
+/*
+ * /src/NTP/ntp4-dev/libntp/binio.c,v 4.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * binio.c,v 4.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * $Created: Sun Jul 20 12:55:33 1997 $
+ *
+ * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#include "binio.h"
+
+long
+get_lsb_short(
+       unsigned char **bufpp
+       )
+{
+  long retval;
+
+  retval  = *((*bufpp)++);
+  retval |= *((*bufpp)++) << 8;
+
+  return (retval & 0x8000) ? (~0xFFFF | retval) : retval;
+}
+
+void
+put_lsb_short(
+       unsigned char **bufpp,
+       long val
+       )
+{
+  *((*bufpp)++) = (unsigned char) (val        & 0xFF);
+  *((*bufpp)++) = (unsigned char) ((val >> 8) & 0xFF);
+}
+
+long
+get_lsb_long(
+       unsigned char **bufpp
+       )
+{
+  long retval;
+
+  retval  = *((*bufpp)++);
+  retval |= *((*bufpp)++) << 8;
+  retval |= *((*bufpp)++) << 16;
+  retval |= *((*bufpp)++) << 24;
+
+  return retval;
+}
+
+void
+put_lsb_long(
+       unsigned char **bufpp,
+       long val
+       )
+{
+  *((*bufpp)++) = (unsigned char)(val         & 0xFF);
+  *((*bufpp)++) = (unsigned char)((val >> 8)  & 0xFF);
+  *((*bufpp)++) = (unsigned char)((val >> 16) & 0xFF);
+  *((*bufpp)++) = (unsigned char)((val >> 24) & 0xFF);
+}
+
+long
+get_msb_short(
+       unsigned char **bufpp
+       )
+{
+  long retval;
+
+  retval  = *((*bufpp)++) << 8;
+  retval |= *((*bufpp)++);
+
+  return (retval & 0x8000) ? (~0xFFFF | retval) : retval;
+}
+
+void
+put_msb_short(
+       unsigned char **bufpp,
+       long val
+       )
+{
+  *((*bufpp)++) = (unsigned char)((val >> 8) & 0xFF);
+  *((*bufpp)++) = (unsigned char)( val       & 0xFF);
+}
+
+long
+get_msb_long(
+       unsigned char **bufpp
+       )
+{
+  long retval;
+
+  retval  = *((*bufpp)++) << 24;
+  retval |= *((*bufpp)++) << 16;
+  retval |= *((*bufpp)++) << 8;
+  retval |= *((*bufpp)++);
+
+  return retval;
+}
+
+void
+put_msb_long(
+       unsigned char **bufpp,
+       long val
+       )
+{
+  *((*bufpp)++) = (unsigned char)((val >> 24) & 0xFF);
+  *((*bufpp)++) = (unsigned char)((val >> 16) & 0xFF);
+  *((*bufpp)++) = (unsigned char)((val >> 8 ) & 0xFF);
+  *((*bufpp)++) = (unsigned char)( val        & 0xFF);
+}
+
+/*
+ * binio.c,v
+ * Revision 4.2  1999/02/21 12:17:34  kardel
+ * 4.91f reconcilation
+ *
+ * Revision 4.1  1998/06/28 16:47:50  kardel
+ * added {get,put}_msb_{short,long} functions
+ *
+ * Revision 4.0  1998/04/10 19:46:16  kardel
+ * Start 4.0 release version numbering
+ *
+ * Revision 1.1  1998/04/10 19:27:46  kardel
+ * initial NTP VERSION 4 integration of PARSE with GPS166 binary support
+ *
+ * Revision 1.1  1997/10/06 21:05:46  kardel
+ * new parse structure
+ *
+ */
diff --git a/libparse/clk_computime.c b/libparse/clk_computime.c
new file mode 100644 (file)
index 0000000..d0db6a9
--- /dev/null
@@ -0,0 +1,219 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_COMPUTIME)
+/*
+ * /src/NTP/ntp4-dev/libparse/clk_computime.c,v 4.10 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * clk_computime.c,v 4.10 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ * 
+ * Supports Diem's Computime Radio Clock
+ * 
+ * Used the Meinberg clock as a template for Diem's Computime Radio Clock
+ *
+ * adapted by Alois Camenzind <alois.camenzind@ubs.ch>
+ * 
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+#include "parse.h"
+
+#ifndef PARSESTREAM
+#include <stdio.h>
+#else
+#include "sys/parsestreams.h"
+extern void printf P((const char *, ...));
+#endif
+
+/*
+ * The Computime receiver sends a datagram in the following format every minute
+ * 
+ * Timestamp   T:YY:MM:MD:WD:HH:MM:SSCRLF 
+ * Pos          0123456789012345678901 2 3
+ *              0000000000111111111122 2 2
+ * Parse        T:  :  :  :  :  :  :  rn
+ * 
+ * T   Startcharacter "T" specifies start of the timestamp 
+ * YY  Year MM Month 1-12 
+ * MD  Day of the month 
+ * WD  Day of week 
+ * HH  Hour 
+ * MM   Minute 
+ * SS   Second
+ * CR   Carriage return 
+ * LF   Linefeed
+ * 
+ */
+
+static struct format computime_fmt =
+{
+       {
+               {8, 2},  {5,  2}, {2,  2},      /* day, month, year */
+               {14, 2}, {17, 2}, {20, 2},      /* hour, minute, second */
+               {11, 2},                        /* dayofweek,  */
+       },
+       (const unsigned char *)"T:  :  :  :  :  :  :  \r\n",
+       0
+};
+
+static u_long cvt_computime P((unsigned char *, int, struct format *, clocktime_t *, void *));
+static unsigned long inp_computime P((parse_t *, unsigned int, timestamp_t *));
+
+clockformat_t   clock_computime =
+{
+       inp_computime,          /* Computime input handling */
+       cvt_computime,          /* Computime conversion */
+       0,                      /* no PPS monitoring */
+       (void *)&computime_fmt, /* conversion configuration */
+       "Diem's Computime Radio Clock", /* Computime Radio Clock */
+       24,                     /* string buffer */
+       0                       /* no private data (complete pakets) */
+};
+
+/*
+ * cvt_computime
+ * 
+ * convert simple type format
+ */
+static          u_long
+cvt_computime(
+       unsigned char *buffer,
+       int            size,
+       struct format *format,
+       clocktime_t   *clock_time,
+       void          *local
+       )
+{
+
+       if (!Strok(buffer, format->fixed_string)) { 
+               return CVT_NONE;
+       } else {
+               if (Stoi(&buffer[format->field_offsets[O_DAY].offset], &clock_time->day,
+                        format->field_offsets[O_DAY].length) ||
+                   Stoi(&buffer[format->field_offsets[O_MONTH].offset], &clock_time->month,
+                        format->field_offsets[O_MONTH].length) ||
+                   Stoi(&buffer[format->field_offsets[O_YEAR].offset], &clock_time->year,
+                        format->field_offsets[O_YEAR].length) ||
+                   Stoi(&buffer[format->field_offsets[O_HOUR].offset], &clock_time->hour,
+                        format->field_offsets[O_HOUR].length) ||
+                   Stoi(&buffer[format->field_offsets[O_MIN].offset], &clock_time->minute,
+                        format->field_offsets[O_MIN].length) ||
+                   Stoi(&buffer[format->field_offsets[O_SEC].offset], &clock_time->second,
+                        format->field_offsets[O_SEC].length)) { 
+                       return CVT_FAIL | CVT_BADFMT;
+               } else {
+
+                       clock_time->flags = 0;
+                       clock_time->utcoffset = 0;      /* We have UTC time */
+
+                       return CVT_OK;
+               }
+       }
+}
+
+/*
+ * inp_computime
+ *
+ * grep data from input stream
+ */
+static u_long
+inp_computime(
+             parse_t      *parseio,
+             unsigned int  ch,
+             timestamp_t  *tstamp
+             )
+{
+       unsigned int rtc;
+       
+       parseprintf(DD_PARSE, ("inp_computime(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+       
+       switch (ch)
+       {
+       case 'T':
+               parseprintf(DD_PARSE, ("inp_computime: START seen\n"));
+               
+               parseio->parse_index = 1;
+               parseio->parse_data[0] = ch;
+               parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
+               return PARSE_INP_SKIP;
+         
+       case '\n':
+               parseprintf(DD_PARSE, ("inp_computime: END seen\n"));
+               if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
+                       return parse_end(parseio);
+               else
+                       return rtc;
+
+       default:
+               return parse_addchar(parseio, ch);
+       }
+}
+
+#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_COMPUTIME) */
+int clk_computime_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_COMPUTIME) */
+
+/*
+ * clk_computime.c,v
+ * Revision 4.10  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.9  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.6  1999/11/28 09:13:49  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.5  1998/06/14 21:09:34  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.4  1998/06/13 12:00:38  kardel
+ * fix SYSV clock name clash
+ *
+ * Revision 4.3  1998/06/12 15:22:26  kardel
+ * fix prototypes
+ *
+ * Revision 4.2  1998/06/12 09:13:24  kardel
+ * conditional compile macros fixed
+ * printf prototype
+ *
+ * Revision 4.1  1998/05/24 09:39:51  kardel
+ * implementation of the new IO handling model
+ *
+ * Revision 4.0  1998/04/10 19:45:27  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 1.8 log info deleted 1998/04/11 kardel
+ */
diff --git a/libparse/clk_dcf7000.c b/libparse/clk_dcf7000.c
new file mode 100644 (file)
index 0000000..e481731
--- /dev/null
@@ -0,0 +1,214 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/clk_dcf7000.c,v 4.10 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *  
+ * clk_dcf7000.c,v 4.10 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * ELV DCF7000 module
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_DCF7000)
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
+#ifndef PARSESTREAM
+#include "ntp_stdlib.h"
+#include <stdio.h>
+#else
+#include "sys/parsestreams.h"
+extern void printf P((const char *, ...));
+#endif
+
+static struct format dcf7000_fmt =
+{                              /* ELV DCF7000 */
+       {
+               {  6, 2}, {  3, 2}, {  0, 2},
+               { 12, 2}, { 15, 2}, { 18, 2},
+               {  9, 2}, { 21, 2},
+       },
+       (const unsigned char *)"  -  -  -  -  -  -  -  \r",
+       0
+};    
+static u_long cvt_dcf7000 P((unsigned char *, int, struct format *, clocktime_t *, void *));
+static unsigned long inp_dcf7000 P((parse_t *, unsigned int, timestamp_t *));
+
+clockformat_t clock_dcf7000 =
+{
+  inp_dcf7000,                 /* DCF7000 input handling */
+  cvt_dcf7000,                 /* ELV DCF77 conversion */
+  0,                           /* no direct PPS monitoring */
+  (void *)&dcf7000_fmt,                /* conversion configuration */
+  "ELV DCF7000",               /* ELV clock */
+  24,                          /* string buffer */
+  0                            /* no private data (complete pakets) */
+};
+
+/*
+ * cvt_dcf7000
+ *
+ * convert dcf7000 type format
+ */
+static u_long
+cvt_dcf7000(
+           unsigned char *buffer,
+           int            size,
+           struct format *format,
+           clocktime_t   *clock_time,
+           void          *local
+           )
+{
+       if (!Strok(buffer, format->fixed_string))
+       {
+               return CVT_NONE;
+       }
+       else
+       {
+               if (Stoi(&buffer[format->field_offsets[O_DAY].offset], &clock_time->day,
+                        format->field_offsets[O_DAY].length) ||
+                   Stoi(&buffer[format->field_offsets[O_MONTH].offset], &clock_time->month,
+                        format->field_offsets[O_MONTH].length) ||
+                   Stoi(&buffer[format->field_offsets[O_YEAR].offset], &clock_time->year,
+                        format->field_offsets[O_YEAR].length) ||
+                   Stoi(&buffer[format->field_offsets[O_HOUR].offset], &clock_time->hour,
+                        format->field_offsets[O_HOUR].length) ||
+                   Stoi(&buffer[format->field_offsets[O_MIN].offset], &clock_time->minute,
+                        format->field_offsets[O_MIN].length) ||
+                   Stoi(&buffer[format->field_offsets[O_SEC].offset], &clock_time->second,
+                        format->field_offsets[O_SEC].length))
+               {
+                       return CVT_FAIL|CVT_BADFMT;
+               }
+               else
+               {
+                       unsigned char *f = &buffer[format->field_offsets[O_FLAGS].offset];
+                       long flags;
+         
+                       clock_time->flags = 0;
+                       clock_time->usecond = 0;
+
+                       if (Stoi(f, &flags, format->field_offsets[O_FLAGS].length))
+                       {
+                               return CVT_FAIL|CVT_BADFMT;
+                       }
+                       else
+                       {
+                               if (flags & 0x1)
+                                   clock_time->utcoffset = -2*60*60;
+                               else
+                                   clock_time->utcoffset = -1*60*60;
+
+                               if (flags & 0x2)
+                                   clock_time->flags |= PARSEB_ANNOUNCE;
+
+                               if (flags & 0x4)
+                                   clock_time->flags |= PARSEB_NOSYNC;
+                       }
+                       return CVT_OK;
+               }
+       }
+}
+
+/*
+ * inp_dcf700
+ *
+ * grep data from input stream
+ */
+static u_long
+inp_dcf7000(
+         parse_t      *parseio,
+         unsigned int  ch,
+         timestamp_t  *tstamp
+         )
+{
+       unsigned int rtc;
+       
+       parseprintf(DD_PARSE, ("inp_dcf7000(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+       
+       switch (ch)
+       {
+       case '\r':
+               parseprintf(DD_PARSE, ("inp_dcf7000: EOL seen\n"));
+               parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
+               if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
+                       return parse_end(parseio);
+               else
+                       return rtc;
+
+       default:
+               return parse_addchar(parseio, ch);
+       }
+}
+
+#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_DCF7000) */
+int clk_dcf7000_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_DCF7000) */
+
+/*
+ * History:
+ *
+ * clk_dcf7000.c,v
+ * Revision 4.10  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.9  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.6  1999/11/28 09:13:49  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.5  1998/06/14 21:09:34  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.4  1998/06/13 12:01:59  kardel
+ * fix SYSV clock name clash
+ *
+ * Revision 4.3  1998/06/12 15:22:27  kardel
+ * fix prototypes
+ *
+ * Revision 4.2  1998/06/12 09:13:24  kardel
+ * conditional compile macros fixed
+ * printf prototype
+ *
+ * Revision 4.1  1998/05/24 09:39:51  kardel
+ * implementation of the new IO handling model
+ *
+ * Revision 4.0  1998/04/10 19:45:28  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 3.18 log info deleted 1998/04/11 kardel
+ */
diff --git a/libparse/clk_hopf6021.c b/libparse/clk_hopf6021.c
new file mode 100644 (file)
index 0000000..426ea48
--- /dev/null
@@ -0,0 +1,283 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/clk_hopf6021.c,v 4.10 2004/11/14 15:29:41 kardel RELEASE_20050508_A
+ *
+ * clk_hopf6021.c,v 4.10 2004/11/14 15:29:41 kardel RELEASE_20050508_A
+ *
+ * Radiocode Clocks HOPF Funkuhr 6021 mit serieller Schnittstelle
+ * base code version from 24th Nov 1995 - history at end
+ *
+ * Created by F.Schnekenbuehl <frank@comsys.dofn.de> from clk_rcc8000.c
+ * Nortel DASA Network Systems GmbH, Department: ND250
+ * A Joint venture of Daimler-Benz Aerospace and Nortel
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_HOPF6021)
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+#include "ascii.h"
+
+#include "parse.h"
+
+#ifndef PARSESTREAM
+#include "ntp_stdlib.h"
+#include <stdio.h>
+#else
+#include "sys/parsestreams.h"
+extern void printf P((const char *, ...));
+#endif
+
+/* 
+ * hopf Funkuhr 6021 
+ *      used with 9600,8N1,
+ *      UTC ueber serielle Schnittstelle 
+ *      Sekundenvorlauf ON
+ *      ETX zum Sekundenvorlauf ON
+ *      Datenstring 6021
+ *      Ausgabe Uhrzeit und Datum
+ *      Senden mit Steuerzeichen
+ *      Senden sekuendlich
+ */
+
+/*
+ *  Type 6021 Serial Output format
+ *
+ *      000000000011111111 / char
+ *      012345678901234567 \ position
+ *      sABHHMMSSDDMMYYnre  Actual
+ *       C4110046231195     Parse
+ *      s              enr  Check
+ *
+ *  s = STX (0x02), e = ETX (0x03)
+ *  n = NL  (0x0A), r = CR  (0x0D)
+ *
+ *  A B - Status and weekday
+ *
+ *  A - Status
+ *
+ *      8 4 2 1
+ *      x x x 0  - no announcement
+ *      x x x 1  - Summertime - wintertime - summertime announcement
+ *      x x 0 x  - Wintertime
+ *      x x 1 x  - Summertime
+ *      0 0 x x  - Time/Date invalid
+ *      0 1 x x  - Internal clock used 
+ *      1 0 x x  - Radio clock
+ *      1 1 x x  - Radio clock highprecision
+ *
+ *  B - 8 4 2 1
+ *      0 x x x  - MESZ/MEZ
+ *      1 x x x  - UTC
+ *      x 0 0 1  - Monday
+ *      x 0 1 0  - Tuesday
+ *      x 0 1 1  - Wednesday
+ *      x 1 0 0  - Thursday
+ *      x 1 0 1  - Friday
+ *      x 1 1 0  - Saturday
+ *      x 1 1 1  - Sunday
+ */
+
+#define HOPF_DSTWARN   0x01    /* DST switch warning */
+#define HOPF_DST       0x02    /* DST in effect */
+
+#define HOPF_MODE      0x0C    /* operation mode mask */       
+#define  HOPF_INVALID  0x00    /* no time code available */
+#define  HOPF_INTERNAL 0x04    /* internal clock */
+#define  HOPF_RADIO    0x08    /* radio clock */       
+#define  HOPF_RADIOHP  0x0C    /* high precision radio clock */
+
+#define HOPF_UTC       0x08    /* time code in UTC */
+#define HOPF_WMASK     0x07    /* mask for weekday code */
+
+static struct format hopf6021_fmt =
+{
+       {
+               {  9, 2 }, {11, 2}, { 13, 2}, /* Day, Month, Year */ 
+               {  3, 2 }, { 5, 2}, {  7, 2}, /* Hour, Minute, Second */ 
+               {  2, 1 }, { 1, 1}, {  0, 0}, /* Weekday, Flags, Zone */
+               /* ... */
+       },
+       (const unsigned char *)"\002              \n\r\003",
+       0 
+};
+
+#define OFFS(x) format->field_offsets[(x)].offset
+#define STOI(x, y) Stoi(&buffer[OFFS(x)], y, format->field_offsets[(x)].length)
+#define hexval(x) (('0' <= (x) && (x) <= '9') ? (x) - '0' : \
+                  ('a' <= (x) && (x) <= 'f') ? (x) - 'a' + 10 : \
+                  ('A' <= (x) && (x) <= 'F') ? (x) - 'A' + 10 : \
+                  -1)
+
+static unsigned long cvt_hopf6021 P((unsigned char *, int, struct format *, clocktime_t *, void *));
+static unsigned long inp_hopf6021 P((parse_t *, unsigned int, timestamp_t *));
+
+clockformat_t clock_hopf6021 =
+{
+  inp_hopf6021,                        /* HOPF 6021 input handling */
+  cvt_hopf6021,                 /* Radiocode clock conversion */
+  0,                           /* no direct PPS monitoring */
+  (void *)&hopf6021_fmt,        /* conversion configuration */
+  "hopf Funkuhr 6021",          /* clock format name */
+  19,                           /* string buffer */
+  0                            /* private data length, no private data */
+};
+
+static unsigned long
+cvt_hopf6021(
+            unsigned char *buffer,
+            int            size,
+            struct format *format,
+            clocktime_t   *clock_time,
+            void          *local
+            )
+{
+       unsigned char status,weekday;
+
+       if (!Strok(buffer, format->fixed_string))
+       {
+               return CVT_NONE;
+       }
+
+       if (  STOI(O_DAY,   &clock_time->day)    ||
+             STOI(O_MONTH, &clock_time->month)  ||
+             STOI(O_YEAR,  &clock_time->year)   ||
+             STOI(O_HOUR,  &clock_time->hour)   ||
+             STOI(O_MIN,   &clock_time->minute) ||
+             STOI(O_SEC,   &clock_time->second)
+             )
+       {
+               return CVT_FAIL|CVT_BADFMT;
+       }
+
+       clock_time->usecond   = 0;
+       clock_time->utcoffset = 0;
+
+       status = hexval(buffer[OFFS(O_FLAGS)]);
+       weekday= hexval(buffer[OFFS(O_WDAY)]);
+
+       if ((status == 0xFF) || (weekday == 0xFF))
+       {
+               return CVT_FAIL|CVT_BADFMT;
+       }
+
+       clock_time->flags  = 0;
+
+       if (weekday & HOPF_UTC)
+       {
+               clock_time->flags |= PARSEB_UTC;
+       }
+       else
+       {
+               if (status & HOPF_DST)
+               {
+                       clock_time->flags     |= PARSEB_DST;
+                       clock_time->utcoffset  = -2*60*60; /* MET DST */
+               }
+               else
+               {
+                       clock_time->utcoffset  = -1*60*60; /* MET */
+               }
+       }
+
+       clock_time->flags |= (status & HOPF_DSTWARN)  ? PARSEB_ANNOUNCE : 0;
+
+       switch (status & HOPF_MODE)
+       {
+           case HOPF_INVALID:  /* Time/Date invalid */
+               clock_time->flags |= PARSEB_POWERUP;
+               break;
+
+           case HOPF_INTERNAL: /* internal clock */
+               clock_time->flags |= PARSEB_NOSYNC;
+               break;
+
+           case HOPF_RADIO:    /* Radio clock */
+           case HOPF_RADIOHP:  /* Radio clock high precision */
+               break;
+
+           default:
+               return CVT_FAIL|CVT_BADFMT;
+       }
+
+       return CVT_OK;
+}
+
+/*
+ * inp_hopf6021
+ *
+ * grep data from input stream
+ */
+static u_long
+inp_hopf6021(
+            parse_t      *parseio,
+            unsigned int  ch,
+            timestamp_t  *tstamp
+         )
+{
+       unsigned int rtc;
+       
+       parseprintf(DD_PARSE, ("inp_hopf6021(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+       
+       switch (ch)
+       {
+       case ETX:
+               parseprintf(DD_PARSE, ("inp_hopf6021: EOL seen\n"));
+               parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
+               if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
+                       return parse_end(parseio);
+               else
+                       return rtc;
+
+       default:
+               return parse_addchar(parseio, ch);
+       }
+}
+
+#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_HOPF6021) */
+int clk_hopf6021_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_HOPF6021) */
+
+/*
+ * History:
+ *
+ * clk_hopf6021.c,v
+ * Revision 4.10  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.7  1999/11/28 09:13:49  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.6  1998/11/15 20:27:57  kardel
+ * Release 4.0.73e13 reconcilation
+ *
+ * Revision 4.5  1998/06/14 21:09:35  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.4  1998/06/13 12:02:38  kardel
+ * fix SYSV clock name clash
+ *
+ * Revision 4.3  1998/06/12 15:22:27  kardel
+ * fix prototypes
+ *
+ * Revision 4.2  1998/06/12 09:13:25  kardel
+ * conditional compile macros fixed
+ * printf prototype
+ *
+ * Revision 4.1  1998/05/24 09:39:52  kardel
+ * implementation of the new IO handling model
+ *
+ * Revision 4.0  1998/04/10 19:45:29  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 3.6 log info deleted 1998/04/11 kardel
+ */
diff --git a/libparse/clk_meinberg.c b/libparse/clk_meinberg.c
new file mode 100644 (file)
index 0000000..90bb886
--- /dev/null
@@ -0,0 +1,776 @@
+/*
+ * /src/NTP/REPOSITORY/ntp4-dev/libparse/clk_meinberg.c,v 4.12.2.1 2005/09/25 10:22:35 kardel RELEASE_20050925_A
+ *  
+ * clk_meinberg.c,v 4.12.2.1 2005/09/25 10:22:35 kardel RELEASE_20050925_A
+ *
+ * Meinberg clock support
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_MEINBERG)
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "ntp_machine.h"
+
+#include "parse.h"
+
+#ifndef PARSESTREAM
+#include <stdio.h>
+#else
+#include "sys/parsestreams.h"
+#endif
+
+#include "ntp_stdlib.h"
+
+#include "ntp_stdlib.h"
+
+#include "mbg_gps166.h"
+#include "binio.h"
+#include "ascii.h"
+
+/*
+ * The Meinberg receiver every second sends a datagram of the following form
+ * (Standard Format)
+ * 
+ *     <STX>D:<dd>.<mm>.<yy>;T:<w>;U:<hh>:<mm>:<ss>;<S><F><D><A><ETX>
+ * pos:  0  00 00 0 00 0 11 111 1 111 12 2 22 2 22 2 2  2  3  3   3
+ *       1  23 45 6 78 9 01 234 5 678 90 1 23 4 56 7 8  9  0  1   2
+ * <STX>           = '\002' ASCII start of text
+ * <ETX>           = '\003' ASCII end of text
+ * <dd>,<mm>,<yy>  = day, month, year(2 digits!!)
+ * <w>             = day of week (sunday= 0)
+ * <hh>,<mm>,<ss>  = hour, minute, second
+ * <S>             = '#' if never synced since powerup for DCF C51
+ *                 = '#' if not PZF sychronisation available for PZF 535/509
+ *                 = ' ' if ok
+ * <F>             = '*' if time comes from internal quartz
+ *                 = ' ' if completely synched
+ * <D>             = 'S' if daylight saving time is active
+ *                 = 'U' if time is represented in UTC
+ *                 = ' ' if no special condition exists
+ * <A>             = '!' during the hour preceeding an daylight saving time
+ *                       start/end change
+ *                 = 'A' leap second insert warning
+ *                 = ' ' if no special condition exists
+ *
+ * Extended data format (PZFUERL for PZF type clocks)
+ *
+ *     <STX><dd>.<mm>.<yy>; <w>; <hh>:<mm>:<ss>; <U><S><F><D><A><L><R><ETX>
+ * pos:  0   00 0 00 0 00 11 1 11 11 1 11 2 22 22 2  2  2  2  2  3  3   3
+ *       1   23 4 56 7 89 01 2 34 56 7 89 0 12 34 5  6  7  8  9  0  1   2
+ * <STX>           = '\002' ASCII start of text
+ * <ETX>           = '\003' ASCII end of text
+ * <dd>,<mm>,<yy>  = day, month, year(2 digits!!)
+ * <w>             = day of week (sunday= 0)
+ * <hh>,<mm>,<ss>  = hour, minute, second
+ * <U>             = 'U' UTC time display
+ * <S>             = '#' if never synced since powerup else ' ' for DCF C51
+ *                   '#' if not PZF sychronisation available else ' ' for PZF 535/509
+ * <F>             = '*' if time comes from internal quartz else ' '
+ * <D>             = 'S' if daylight saving time is active else ' '
+ * <A>             = '!' during the hour preceeding an daylight saving time
+ *                       start/end change
+ * <L>             = 'A' LEAP second announcement
+ * <R>             = 'R' alternate antenna
+ *
+ * Meinberg GPS166 receiver
+ *
+ * You must get the Uni-Erlangen firmware for the GPS receiver support
+ * to work to full satisfaction !
+ *
+ *     <STX><dd>.<mm>.<yy>; <w>; <hh>:<mm>:<ss>; <+/-><00:00>; <U><S><F><D><A><L><R><L>; <position...><ETX>
+ *
+ *        000000000111111111122222222223333333333444444444455555555556666666
+ *        123456789012345678901234567890123456789012345678901234567890123456
+ *     \x0209.07.93; 5; 08:48:26; +00:00; #*S!A L; 49.5736N  11.0280E  373m\x03
+ *
+ * 
+ * <STX>           = '\002' ASCII start of text
+ * <ETX>           = '\003' ASCII end of text
+ * <dd>,<mm>,<yy>  = day, month, year(2 digits!!)
+ * <w>             = day of week (sunday= 0)
+ * <hh>,<mm>,<ss>  = hour, minute, second
+ * <+/->,<00:00>   = offset to UTC
+ * <S>             = '#' if never synced since powerup else ' '
+ * <F>             = '*' if position is not confirmed else ' '
+ * <D>             = 'S' if daylight saving time is active else ' '
+ * <A>             = '!' during the hour preceeding an daylight saving time
+ *                       start/end change
+ * <L>             = 'A' LEAP second announcement
+ * <R>             = 'R' alternate antenna (reminiscent of PZF535) usually ' '
+ * <L>            = 'L' on 23:59:60
+ *
+ * Binary messages have a lead in for a fixed header of SOH
+ */
+
+/*--------------------------------------------------------------*/
+/* Name:         csum()                                         */
+/*                                                              */
+/* Purpose:      Compute a checksum about a number of bytes     */
+/*                                                              */
+/* Input:        uchar *p    address of the first byte          */
+/*               short n     the number of bytes                */
+/*                                                              */
+/* Output:       --                                             */
+/*                                                              */
+/* Ret val:      the checksum                                   */
+/*+-------------------------------------------------------------*/
+
+unsigned long
+mbg_csum(
+        unsigned char *p,
+        unsigned int n
+        )
+{
+  unsigned long sum = 0;
+  short i;
+  
+  for ( i = 0; i < n; i++ )
+    sum += *p++;
+  
+  return( sum );
+}  /* csum */
+
+void
+get_mbg_header(
+              unsigned char **bufpp,
+              GPS_MSG_HDR *headerp
+              )
+{
+  headerp->gps_cmd = get_lsb_short(bufpp);
+  headerp->gps_len = get_lsb_short(bufpp);
+  headerp->gps_data_csum = get_lsb_short(bufpp);
+  headerp->gps_hdr_csum  = get_lsb_short(bufpp);
+}
+
+static struct format meinberg_fmt[] =
+{
+       {
+               {
+                       { 3, 2},  {  6, 2}, {  9, 2},
+                       { 18, 2}, { 21, 2}, { 24, 2},
+                       { 14, 1}, { 27, 4}, { 29, 1},
+               },
+               (const unsigned char *)"\2D:  .  .  ;T: ;U:  .  .  ;    \3",
+               0
+       },
+       {                       /* special extended FAU Erlangen extended format */
+               {
+                       { 1, 2},  { 4,  2}, {  7, 2},
+                       { 14, 2}, { 17, 2}, { 20, 2},
+                       { 11, 1}, { 25, 4}, { 27, 1},
+               },
+               (const unsigned char *)"\2  .  .  ;  ;   :  :  ;        \3",
+               MBG_EXTENDED
+       },
+       {                       /* special extended FAU Erlangen GPS format */
+               {
+                       { 1,  2}, {  4, 2}, {  7, 2},
+                       { 14, 2}, { 17, 2}, { 20, 2},
+                       { 11, 1}, { 32, 7}, { 35, 1},
+                       { 25, 2}, { 28, 2}, { 24, 1}
+               },
+               (const unsigned char *)"\2  .  .  ;  ;   :  :  ;    :  ;        ;   .         .       ",
+               0
+       }
+};
+
+static u_long cvt_meinberg P((unsigned char *, int, struct format *, clocktime_t *, void *));
+static u_long cvt_mgps     P((unsigned char *, int, struct format *, clocktime_t *, void *));
+static u_long mbg_input    P((parse_t *, unsigned int, timestamp_t *));
+static u_long gps_input    P((parse_t *, unsigned int, timestamp_t *));
+
+struct msg_buf
+{
+  unsigned short len;          /* len to fill */
+  unsigned short phase;                /* current input phase */
+};
+
+#define MBG_NONE       0       /* no data input */
+#define MBG_HEADER     1       /* receiving header */
+#define MBG_DATA       2       /* receiving data */
+#define MBG_STRING      3      /* receiving standard data message */
+  
+clockformat_t clock_meinberg[] =
+{
+       {
+               mbg_input,      /* normal input handling */
+               cvt_meinberg,   /* Meinberg conversion */
+               pps_one,        /* easy PPS monitoring */
+               0,              /* conversion configuration */
+               "Meinberg Standard", /* Meinberg simple format - beware */
+               32,                             /* string buffer */
+               0               /* no private data (complete pakets) */
+       },
+       {
+               mbg_input,      /* normal input handling */
+               cvt_meinberg,   /* Meinberg conversion */
+               pps_one,        /* easy PPS monitoring */
+               0,              /* conversion configuration */
+               "Meinberg Extended", /* Meinberg enhanced format */
+               32,             /* string buffer */
+               0               /* no private data (complete pakets) */
+       },
+       {
+               gps_input,      /* no input handling */
+               cvt_mgps,       /* Meinberg GPS166 conversion */
+               pps_one,        /* easy PPS monitoring */
+               (void *)&meinberg_fmt[2], /* conversion configuration */
+               "Meinberg GPS Extended", /* Meinberg FAU GPS format */
+               512,            /* string buffer */
+               sizeof(struct msg_buf)  /* no private data (complete pakets) */
+       }
+};
+
+/*
+ * cvt_meinberg
+ *
+ * convert simple type format
+ */
+static u_long
+cvt_meinberg(
+            unsigned char *buffer,
+            int            size,
+            struct format *unused,
+            clocktime_t   *clock_time,
+            void          *local
+            )
+{
+       struct format *format;
+       
+       /*
+        * select automagically correct data format
+        */
+       if (Strok(buffer, meinberg_fmt[0].fixed_string))
+       {
+               format = &meinberg_fmt[0];
+       }
+       else
+       {
+               if (Strok(buffer, meinberg_fmt[1].fixed_string))
+               {
+                       format = &meinberg_fmt[1];
+               }
+               else
+               {
+                       return CVT_FAIL|CVT_BADFMT;
+               }
+       }
+
+       /*
+        * collect data
+        */
+       if (Stoi(&buffer[format->field_offsets[O_DAY].offset], &clock_time->day,
+                format->field_offsets[O_DAY].length) ||
+           Stoi(&buffer[format->field_offsets[O_MONTH].offset], &clock_time->month,
+                format->field_offsets[O_MONTH].length) ||
+           Stoi(&buffer[format->field_offsets[O_YEAR].offset], &clock_time->year,
+                format->field_offsets[O_YEAR].length) ||
+           Stoi(&buffer[format->field_offsets[O_HOUR].offset], &clock_time->hour,
+                format->field_offsets[O_HOUR].length) ||
+           Stoi(&buffer[format->field_offsets[O_MIN].offset], &clock_time->minute,
+                format->field_offsets[O_MIN].length) ||
+           Stoi(&buffer[format->field_offsets[O_SEC].offset], &clock_time->second,
+                format->field_offsets[O_SEC].length))
+       {
+               return CVT_FAIL|CVT_BADFMT;
+       }
+       else
+       {
+               unsigned char *f = &buffer[format->field_offsets[O_FLAGS].offset];
+               
+               clock_time->usecond = 0;
+               clock_time->flags   = PARSEB_S_LEAP;
+
+               if (clock_time->second == 60)
+                       clock_time->flags |= PARSEB_LEAPSECOND;
+
+               /*
+                * in the extended timecode format we have also the
+                * indication that the timecode is in UTC
+                * for compatibilty reasons we start at the USUAL
+                * offset (POWERUP flag) and know that the UTC indication
+                * is the character before the powerup flag
+                */
+               if ((format->flags & MBG_EXTENDED) && (f[-1] == 'U'))
+               {
+                       /*
+                        * timecode is in UTC
+                        */
+                       clock_time->utcoffset = 0; /* UTC */
+                       clock_time->flags    |= PARSEB_UTC;
+               }
+               else
+               {
+                       /*
+                        * only calculate UTC offset if MET/MED is in time code
+                        * or we have the old time code format, where we do not
+                        * know whether it is UTC time or MET/MED
+                        * pray that nobody switches to UTC in the *old* standard time code
+                        * ROMS !!!! The new ROMS have 'U' at the ZONE field - good.
+                        */
+                       switch (buffer[format->field_offsets[O_ZONE].offset])
+                       {
+                       case ' ':
+                               clock_time->utcoffset = -1*60*60; /* MET */
+                               break;
+                               
+                       case 'S':
+                               clock_time->utcoffset = -2*60*60; /* MED */
+                               break;
+
+                       case 'U':
+                               /*
+                                * timecode is in UTC
+                                */
+                               clock_time->utcoffset = 0;        /* UTC */
+                               clock_time->flags    |= PARSEB_UTC;
+                               break;
+                               
+                       default:
+                               return CVT_FAIL|CVT_BADFMT;
+                       }
+               }
+               
+               /*
+                * gather status flags
+                */
+               if (buffer[format->field_offsets[O_ZONE].offset] == 'S')
+                       clock_time->flags    |= PARSEB_DST;
+               
+               if (f[0] == '#')
+                       clock_time->flags |= PARSEB_POWERUP;
+               
+               if (f[1] == '*')
+                       clock_time->flags |= PARSEB_NOSYNC;
+               
+               if (f[3] == '!')
+                       clock_time->flags |= PARSEB_ANNOUNCE;
+               
+               /*
+                * oncoming leap second
+                * 'a' code not confirmed - earth is not
+                * expected to speed up
+                */
+               if (f[3] == 'A')
+                       clock_time->flags |= PARSEB_LEAPADD;
+               
+               if (f[3] == 'a')
+                       clock_time->flags |= PARSEB_LEAPDEL;
+               
+               
+               if (format->flags & MBG_EXTENDED)
+               {
+                       clock_time->flags |= PARSEB_S_ANTENNA;
+                       
+                       /*
+                        * DCF77 does not encode the direction -
+                        * so we take the current default -
+                        * earth slowing down
+                        */
+                       clock_time->flags &= ~PARSEB_LEAPDEL;
+                       
+                       if (f[4] == 'A')
+                               clock_time->flags |= PARSEB_LEAPADD;
+                       
+                       if (f[5] == 'R')
+                               clock_time->flags |= PARSEB_ALTERNATE;
+               }
+               return CVT_OK;
+       }
+}
+
+
+/*
+ * mbg_input
+ *
+ * grep data from input stream
+ */
+static u_long
+mbg_input(
+         parse_t      *parseio,
+         unsigned int  ch,
+         timestamp_t  *tstamp
+         )
+{
+       unsigned int rtc;
+       
+       parseprintf(DD_PARSE, ("mbg_input(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+       
+       switch (ch)
+       {
+       case STX:
+               parseprintf(DD_PARSE, ("mbg_input: STX seen\n"));
+               
+               parseio->parse_index = 1;
+               parseio->parse_data[0] = ch;
+               parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
+               return PARSE_INP_SKIP;
+         
+       case ETX:
+               parseprintf(DD_PARSE, ("mbg_input: ETX seen\n"));
+               if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
+                       return parse_end(parseio);
+               else
+                       return rtc;
+
+       default:
+               return parse_addchar(parseio, ch);
+       }
+}
+
+
+/*
+ * cvt_mgps
+ *
+ * convert Meinberg GPS format
+ */
+static u_long
+cvt_mgps(
+        unsigned char *buffer,
+        int            size,
+        struct format *format,
+        clocktime_t   *clock_time,
+        void          *local
+       )
+{
+       if (!Strok(buffer, format->fixed_string))
+       {
+               return cvt_meinberg(buffer, size, format, clock_time, local);
+       }
+       else
+       {
+               if (Stoi(&buffer[format->field_offsets[O_DAY].offset], &clock_time->day,
+                        format->field_offsets[O_DAY].length) ||
+                   Stoi(&buffer[format->field_offsets[O_MONTH].offset], &clock_time->month,
+                        format->field_offsets[O_MONTH].length) ||
+                   Stoi(&buffer[format->field_offsets[O_YEAR].offset], &clock_time->year,
+                        format->field_offsets[O_YEAR].length) ||
+                   Stoi(&buffer[format->field_offsets[O_HOUR].offset], &clock_time->hour,
+                        format->field_offsets[O_HOUR].length) ||
+                   Stoi(&buffer[format->field_offsets[O_MIN].offset], &clock_time->minute,
+                        format->field_offsets[O_MIN].length) ||
+                   Stoi(&buffer[format->field_offsets[O_SEC].offset], &clock_time->second,
+                        format->field_offsets[O_SEC].length))
+               {
+                       return CVT_FAIL|CVT_BADFMT;
+               }
+               else
+               {
+                       long h;
+                       unsigned char *f = &buffer[format->field_offsets[O_FLAGS].offset];
+         
+                       clock_time->flags = PARSEB_S_LEAP|PARSEB_S_POSITION;
+             
+                       clock_time->usecond = 0;
+
+                       /*
+                        * calculate UTC offset
+                        */
+                       if (Stoi(&buffer[format->field_offsets[O_UTCHOFFSET].offset], &h,
+                                format->field_offsets[O_UTCHOFFSET].length))
+                       {
+                               return CVT_FAIL|CVT_BADFMT;
+                       }
+                       else
+                       {
+                               if (Stoi(&buffer[format->field_offsets[O_UTCMOFFSET].offset], &clock_time->utcoffset,
+                                        format->field_offsets[O_UTCMOFFSET].length))
+                               {
+                                       return CVT_FAIL|CVT_BADFMT;
+                               }
+
+                               clock_time->utcoffset += TIMES60(h);
+                               clock_time->utcoffset  = TIMES60(clock_time->utcoffset);
+
+                               if (buffer[format->field_offsets[O_UTCSOFFSET].offset] != '-')
+                               {
+                                       clock_time->utcoffset = -clock_time->utcoffset;
+                               }
+                       }
+         
+                       /*
+                        * gather status flags
+                        */
+                       if (buffer[format->field_offsets[O_ZONE].offset] == 'S')
+                           clock_time->flags    |= PARSEB_DST;
+         
+                       if (clock_time->utcoffset == 0)
+                           clock_time->flags |= PARSEB_UTC;
+         
+                       /*
+                        * no sv's seen - no time & position
+                        */
+                       if (f[0] == '#')
+                           clock_time->flags |= PARSEB_POWERUP;
+         
+                       /*
+                        * at least one sv seen - time (for last position)
+                        */
+                       if (f[1] == '*')
+                           clock_time->flags |= PARSEB_NOSYNC;
+                       else
+                           if (!(clock_time->flags & PARSEB_POWERUP))
+                               clock_time->flags |= PARSEB_POSITION;
+         
+                       /*
+                        * oncoming zone switch
+                        */
+                       if (f[3] == '!')
+                           clock_time->flags |= PARSEB_ANNOUNCE;
+         
+                       /*
+                        * oncoming leap second
+                        * 'a' code not confirmed - earth is not
+                        * expected to speed up
+                        */
+                       if (f[4] == 'A')
+                           clock_time->flags |= PARSEB_LEAPADD;
+         
+                       if (f[4] == 'a')
+                           clock_time->flags |= PARSEB_LEAPDEL;
+
+                       /*
+                        * f[5] == ' '
+                        */
+         
+                       /*
+                        * this is the leap second
+                        */
+                       if ((f[6] == 'L') || (clock_time->second == 60))
+                           clock_time->flags |= PARSEB_LEAPSECOND;
+
+                       return CVT_OK;
+               }
+       }
+}
+
+/*
+ * gps_input
+ *
+ * grep binary data from input stream
+ */
+static u_long
+gps_input(
+         parse_t      *parseio,
+         unsigned int  ch,
+         timestamp_t  *tstamp
+         )
+{
+  CSUM calc_csum;                    /* used to compare the incoming csums */
+  GPS_MSG_HDR header;
+  struct msg_buf *msg_buf;
+  
+  msg_buf = (struct msg_buf *)parseio->parse_pdata;
+
+  parseprintf(DD_PARSE, ("gps_input(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+
+  if (!msg_buf)
+    return PARSE_INP_SKIP;
+  
+  if ( msg_buf->phase == MBG_NONE )
+    {                  /* not receiving yet */
+      switch (ch)
+       {
+       case SOH:
+         parseprintf(DD_PARSE, ("gps_input: SOH seen\n"));
+         
+         msg_buf->len = sizeof( header ); /* prepare to receive msg header */
+         msg_buf->phase = MBG_HEADER; /* receiving header */
+         break;
+
+       case STX:
+         parseprintf(DD_PARSE, ("gps_input: STX seen\n"));
+
+         msg_buf->len = 0;
+         msg_buf->phase = MBG_STRING; /* prepare to receive ASCII ETX delimited message */
+         parseio->parse_index = 1;
+         parseio->parse_data[0] = ch;
+         break;
+         
+       default:
+         return PARSE_INP_SKIP;        /* keep searching */
+       }
+
+      parseio->parse_dtime.parse_msglen = 1; /* reset buffer pointer */
+      parseio->parse_dtime.parse_msg[0] = ch; /* fill in first character */
+      parseio->parse_dtime.parse_stime  = *tstamp; /* collect timestamp */
+      return PARSE_INP_SKIP;
+    }
+
+  /* SOH/STX has already been received */
+
+  /* save incoming character in both buffers if needbe */
+  if ((msg_buf->phase == MBG_STRING) &&
+      (parseio->parse_index < parseio->parse_dsize))
+    parseio->parse_data[parseio->parse_index++] = ch;
+  
+  parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = ch;
+
+  if (parseio->parse_dtime.parse_msglen > sizeof(parseio->parse_dtime.parse_msg))
+    {
+      msg_buf->phase = MBG_NONE; /* buffer overflow - discard */
+      parseio->parse_data[parseio->parse_index] = '\0';
+      memcpy(parseio->parse_ldata, parseio->parse_data, (unsigned)(parseio->parse_index+1));
+      parseio->parse_ldsize = parseio->parse_index;
+      return PARSE_INP_DATA;
+    }
+  
+  switch (msg_buf->phase)
+    {
+    case MBG_HEADER:
+    case MBG_DATA:
+      msg_buf->len--;
+
+      if ( msg_buf->len )               /* transfer not complete */
+       return PARSE_INP_SKIP;
+
+      parseprintf(DD_PARSE, ("gps_input: %s complete\n", (msg_buf->phase == MBG_DATA) ? "data" : "header"));
+
+      break;
+
+    case MBG_STRING:
+      if ((ch == ETX) || (parseio->parse_index >= parseio->parse_dsize))
+       {
+         msg_buf->phase = MBG_NONE;
+         parseprintf(DD_PARSE, ("gps_input: string complete\n"));
+         parseio->parse_data[parseio->parse_index] = '\0';
+         memcpy(parseio->parse_ldata, parseio->parse_data, (unsigned)(parseio->parse_index+1));
+         parseio->parse_ldsize = parseio->parse_index;
+         parseio->parse_index = 0;
+         return PARSE_INP_TIME;
+       }
+      else
+       {
+         return PARSE_INP_SKIP;
+       }
+    }
+
+  /* cnt == 0, so the header or the whole message is complete */
+
+  if ( msg_buf->phase == MBG_HEADER )
+    {         /* header complete now */
+      unsigned char *datap = parseio->parse_dtime.parse_msg + 1;
+      
+      get_mbg_header(&datap, &header);
+      
+      parseprintf(DD_PARSE, ("gps_input: header: cmd 0x%x, len %d, dcsum 0x%x, hcsum 0x%x\n",
+                            (int)header.gps_cmd, (int)header.gps_len, (int)header.gps_data_csum,
+                            (int)header.gps_hdr_csum));
+      
+
+      calc_csum = mbg_csum( (unsigned char *) parseio->parse_dtime.parse_msg + 1, (unsigned short)6 );
+
+      if ( calc_csum != header.gps_hdr_csum )
+       {
+         parseprintf(DD_PARSE, ("gps_input: header checksum mismatch expected 0x%x, got 0x%x\n",
+                                (int)calc_csum, (int)mbg_csum( (unsigned char *) parseio->parse_dtime.parse_msg, (unsigned short)6 )));
+         
+         msg_buf->phase = MBG_NONE;  /* back to hunting mode */
+         return PARSE_INP_DATA;      /* invalid header checksum received - pass up for detection */
+       }
+
+      if ((header.gps_len == 0)  ||       /* no data to wait for */
+         (header.gps_len >= (sizeof (parseio->parse_dtime.parse_msg) - sizeof(header) - 1)))   /* blows anything we have space for */
+       {
+         msg_buf->phase = MBG_NONE;  /* back to hunting mode */
+         return (header.gps_len == 0) ? PARSE_INP_DATA : PARSE_INP_SKIP; /* message complete/throwaway */
+       }
+    
+      parseprintf(DD_PARSE, ("gps_input: expecting %d bytes of data message\n", (int)header.gps_len));
+      
+      msg_buf->len   = header.gps_len;/* save number of bytes to wait for */
+      msg_buf->phase = MBG_DATA;      /* flag header already complete */
+      return PARSE_INP_SKIP;
+    }
+
+  parseprintf(DD_PARSE, ("gps_input: message data complete\n"));
+  
+  /* Header and data have been received. The header checksum has been */
+  /* checked */
+
+  msg_buf->phase = MBG_NONE;         /* back to hunting mode */
+  return PARSE_INP_DATA;              /* message complete, must be evaluated */
+}
+
+#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_MEINBERG) */
+int clk_meinberg_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_MEINBERG) */
+
+/*
+ * History:
+ *
+ * clk_meinberg.c,v
+ * Revision 4.12.2.1  2005/09/25 10:22:35  kardel
+ * cleanup buffer bounds
+ *
+ * Revision 4.12  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.11  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.8  1999/11/28 09:13:50  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.7  1999/02/21 11:09:14  kardel
+ * cleanup
+ *
+ * Revision 4.6  1998/06/14 21:09:36  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.5  1998/06/13 15:18:54  kardel
+ * fix mem*() to b*() function macro emulation
+ *
+ * Revision 4.4  1998/06/13 12:03:23  kardel
+ * fix SYSV clock name clash
+ *
+ * Revision 4.3  1998/06/12 15:22:28  kardel
+ * fix prototypes
+ *
+ * Revision 4.2  1998/05/24 16:14:42  kardel
+ * support current Meinberg standard data formats
+ *
+ * Revision 4.1  1998/05/24 09:39:52  kardel
+ * implementation of the new IO handling model
+ *
+ * Revision 4.0  1998/04/10 19:45:29  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 3.23 - log info deleted 1998/04/11 kardel
+ *
+ */
diff --git a/libparse/clk_rawdcf.c b/libparse/clk_rawdcf.c
new file mode 100644 (file)
index 0000000..3ef36c4
--- /dev/null
@@ -0,0 +1,658 @@
+/*
+ * /src/NTP/REPOSITORY/ntp4-dev/libparse/clk_rawdcf.c,v 4.18 2006/06/22 18:40:01 kardel RELEASE_20060622_A
+ *  
+ * clk_rawdcf.c,v 4.18 2006/06/22 18:40:01 kardel RELEASE_20060622_A
+ *
+ * Raw DCF77 pulse clock support
+ *
+ * Copyright (c) 1995-2006 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_RAWDCF)
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+#ifdef PARSESTREAM
+# include <sys/parsestreams.h>
+#endif
+
+#ifndef PARSEKERNEL
+# include "ntp_stdlib.h"
+#endif
+
+/*
+ * DCF77 raw time code
+ *
+ * From "Zur Zeit", Physikalisch-Technische Bundesanstalt (PTB), Braunschweig
+ * und Berlin, Maerz 1989
+ *
+ * Timecode transmission:
+ * AM:
+ *     time marks are send every second except for the second before the
+ *     next minute mark
+ *     time marks consist of a reduction of transmitter power to 25%
+ *     of the nominal level
+ *     the falling edge is the time indication (on time)
+ *     time marks of a 100ms duration constitute a logical 0
+ *     time marks of a 200ms duration constitute a logical 1
+ * FM:
+ *     see the spec. (basically a (non-)inverted psuedo random phase shift)
+ *
+ * Encoding:
+ * Second      Contents
+ * 0  - 10     AM: free, FM: 0
+ * 11 - 14     free
+ * 15          R     - alternate antenna
+ * 16          A1    - expect zone change (1 hour before)
+ * 17 - 18     Z1,Z2 - time zone
+ *              0  0 illegal
+ *              0  1 MEZ  (MET)
+ *              1  0 MESZ (MED, MET DST)
+ *              1  1 illegal
+ * 19          A2    - expect leap insertion/deletion (1 hour before)
+ * 20          S     - start of time code (1)
+ * 21 - 24     M1    - BCD (lsb first) Minutes
+ * 25 - 27     M10   - BCD (lsb first) 10 Minutes
+ * 28          P1    - Minute Parity (even)
+ * 29 - 32     H1    - BCD (lsb first) Hours
+ * 33 - 34      H10   - BCD (lsb first) 10 Hours
+ * 35          P2    - Hour Parity (even)
+ * 36 - 39     D1    - BCD (lsb first) Days
+ * 40 - 41     D10   - BCD (lsb first) 10 Days
+ * 42 - 44     DW    - BCD (lsb first) day of week (1: Monday -> 7: Sunday)
+ * 45 - 49     MO    - BCD (lsb first) Month
+ * 50           MO0   - 10 Months
+ * 51 - 53     Y1    - BCD (lsb first) Years
+ * 54 - 57     Y10   - BCD (lsb first) 10 Years
+ * 58          P3    - Date Parity (even)
+ * 59                - usually missing (minute indication), except for leap insertion
+ */
+
+static u_long pps_rawdcf P((parse_t *, int, timestamp_t *));
+static u_long cvt_rawdcf P((unsigned char *, int, struct format *, clocktime_t *, void *));
+static u_long inp_rawdcf P((parse_t *, unsigned int, timestamp_t  *));
+
+typedef struct last_tcode {
+       time_t tcode;   /* last converted time code */
+} last_tcode_t;
+
+#define BUFFER_MAX     61
+
+clockformat_t clock_rawdcf =
+{
+  inp_rawdcf,                  /* DCF77 input handling */
+  cvt_rawdcf,                  /* raw dcf input conversion */
+  pps_rawdcf,                  /* examining PPS information */
+  0,                           /* no private configuration data */
+  "RAW DCF77 Timecode",                /* direct decoding / time synthesis */
+
+  BUFFER_MAX,                  /* bit buffer */
+  sizeof(last_tcode_t)
+};
+
+static struct dcfparam
+{
+       unsigned char *onebits;
+       unsigned char *zerobits;
+} dcfparameter = 
+{
+       (unsigned char *)"###############RADMLS1248124P124812P1248121241248112481248P??", /* 'ONE' representation */
+       (unsigned char *)"--------------------s-------p------p----------------------p__"  /* 'ZERO' representation */
+};
+
+static struct rawdcfcode 
+{
+       char offset;                    /* start bit */
+} rawdcfcode[] =
+{
+       {  0 }, { 15 }, { 16 }, { 17 }, { 19 }, { 20 }, { 21 }, { 25 }, { 28 }, { 29 },
+       { 33 }, { 35 }, { 36 }, { 40 }, { 42 }, { 45 }, { 49 }, { 50 }, { 54 }, { 58 }, { 59 }
+};
+
+#define DCF_M  0
+#define DCF_R  1
+#define DCF_A1 2
+#define DCF_Z  3
+#define DCF_A2 4
+#define DCF_S  5
+#define DCF_M1 6
+#define DCF_M10        7
+#define DCF_P1 8
+#define DCF_H1 9
+#define DCF_H10        10
+#define DCF_P2 11
+#define DCF_D1 12
+#define DCF_D10        13
+#define DCF_DW 14
+#define DCF_MO 15
+#define DCF_MO0        16
+#define DCF_Y1 17
+#define DCF_Y10        18
+#define DCF_P3 19
+
+static struct partab
+{
+       char offset;                    /* start bit of parity field */
+} partab[] =
+{
+       { 21 }, { 29 }, { 36 }, { 59 }
+};
+
+#define DCF_P_P1       0
+#define DCF_P_P2       1
+#define DCF_P_P3       2
+
+#define DCF_Z_MET 0x2
+#define DCF_Z_MED 0x1
+
+static u_long
+ext_bf(
+       unsigned char *buf,
+       int   idx,
+       unsigned char *zero
+       )
+{
+       u_long sum = 0;
+       int i, first;
+
+       first = rawdcfcode[idx].offset;
+  
+       for (i = rawdcfcode[idx+1].offset - 1; i >= first; i--)
+       {
+               sum <<= 1;
+               sum |= (buf[i] != zero[i]);
+       }
+       return sum;
+}
+
+static unsigned
+pcheck(
+       unsigned char *buf,
+       int   idx,
+       unsigned char *zero
+       )
+{
+       int i,last;
+       unsigned psum = 1;
+
+       last = partab[idx+1].offset;
+
+       for (i = partab[idx].offset; i < last; i++)
+           psum ^= (buf[i] != zero[i]);
+
+       return psum;
+}
+
+static u_long
+convert_rawdcf(
+              unsigned char   *buffer,
+              int              size,
+              struct dcfparam *dcfprm,
+              clocktime_t     *clock_time
+              )
+{
+       unsigned char *s = buffer;
+       unsigned char *b = dcfprm->onebits;
+       unsigned char *c = dcfprm->zerobits;
+       int i;
+
+       parseprintf(DD_RAWDCF,("parse: convert_rawdcf: \"%s\"\n", buffer));
+
+       if (size < 57)
+       {
+#ifndef PARSEKERNEL
+               msyslog(LOG_ERR, "parse: convert_rawdcf: INCOMPLETE DATA - time code only has %d bits\n", size);
+#endif
+               return CVT_NONE;
+       }
+  
+       for (i = 0; i < size; i++)
+       {
+               if ((*s != *b) && (*s != *c))
+               {
+                       /*
+                        * we only have two types of bytes (ones and zeros)
+                        */
+#ifndef PARSEKERNEL
+                       msyslog(LOG_ERR, "parse: convert_rawdcf: BAD DATA - no conversion");
+#endif
+                       return CVT_NONE;
+               }
+               if (*b) b++;
+               if (*c) c++;
+               s++;
+       }
+
+       /*
+        * check Start and Parity bits
+        */
+       if ((ext_bf(buffer, DCF_S, dcfprm->zerobits) == 1) &&
+           pcheck(buffer, DCF_P_P1, dcfprm->zerobits) &&
+           pcheck(buffer, DCF_P_P2, dcfprm->zerobits) &&
+           pcheck(buffer, DCF_P_P3, dcfprm->zerobits))
+       {
+               /*
+                * buffer OK
+                */
+               parseprintf(DD_RAWDCF,("parse: convert_rawdcf: parity check passed\n"));
+
+               clock_time->flags  = PARSEB_S_ANTENNA|PARSEB_S_LEAP;
+               clock_time->utctime= 0;
+               clock_time->usecond= 0;
+               clock_time->second = 0;
+               clock_time->minute = ext_bf(buffer, DCF_M10, dcfprm->zerobits);
+               clock_time->minute = TIMES10(clock_time->minute) + ext_bf(buffer, DCF_M1, dcfprm->zerobits);
+               clock_time->hour   = ext_bf(buffer, DCF_H10, dcfprm->zerobits);
+               clock_time->hour   = TIMES10(clock_time->hour) + ext_bf(buffer, DCF_H1, dcfprm->zerobits);
+               clock_time->day    = ext_bf(buffer, DCF_D10, dcfprm->zerobits);
+               clock_time->day    = TIMES10(clock_time->day) + ext_bf(buffer, DCF_D1, dcfprm->zerobits);
+               clock_time->month  = ext_bf(buffer, DCF_MO0, dcfprm->zerobits);
+               clock_time->month  = TIMES10(clock_time->month) + ext_bf(buffer, DCF_MO, dcfprm->zerobits);
+               clock_time->year   = ext_bf(buffer, DCF_Y10, dcfprm->zerobits);
+               clock_time->year   = TIMES10(clock_time->year) + ext_bf(buffer, DCF_Y1, dcfprm->zerobits);
+
+               switch (ext_bf(buffer, DCF_Z, dcfprm->zerobits))
+               {
+                   case DCF_Z_MET:
+                       clock_time->utcoffset = -1*60*60;
+                       break;
+
+                   case DCF_Z_MED:
+                       clock_time->flags     |= PARSEB_DST;
+                       clock_time->utcoffset  = -2*60*60;
+                       break;
+
+                   default:
+                       parseprintf(DD_RAWDCF,("parse: convert_rawdcf: BAD TIME ZONE\n"));
+                       return CVT_FAIL|CVT_BADFMT;
+               }
+
+               if (ext_bf(buffer, DCF_A1, dcfprm->zerobits))
+                   clock_time->flags |= PARSEB_ANNOUNCE;
+
+               if (ext_bf(buffer, DCF_A2, dcfprm->zerobits))
+                   clock_time->flags |= PARSEB_LEAPADD; /* default: DCF77 data format deficiency */
+
+               if (ext_bf(buffer, DCF_R, dcfprm->zerobits))
+                   clock_time->flags |= PARSEB_ALTERNATE;
+
+               parseprintf(DD_RAWDCF,("parse: convert_rawdcf: TIME CODE OK: %d:%d, %d.%d.%d, flags 0x%lx\n",
+                                      (int)clock_time->hour, (int)clock_time->minute, (int)clock_time->day, (int)clock_time->month,(int) clock_time->year,
+                                      (u_long)clock_time->flags));
+               return CVT_OK;
+       }
+       else
+       {
+               /*
+                * bad format - not for us
+                */
+#ifndef PARSEKERNEL
+               msyslog(LOG_ERR, "parse: convert_rawdcf: parity check FAILED for \"%s\"\n", buffer);
+#endif
+               return CVT_FAIL|CVT_BADFMT;
+       }
+}
+
+/*
+ * raw dcf input routine - needs to fix up 50 baud
+ * characters for 1/0 decision
+ */
+static u_long
+cvt_rawdcf(
+          unsigned char   *buffer,
+          int              size,
+          struct format   *param,
+          clocktime_t     *clock_time,
+          void            *local
+          )
+{
+       last_tcode_t  *t = (last_tcode_t *)local;
+       unsigned char *s = (unsigned char *)buffer;
+       unsigned char *e = s + size;
+       unsigned char *b = dcfparameter.onebits;
+       unsigned char *c = dcfparameter.zerobits;
+       u_long       rtc = CVT_NONE;
+       unsigned int i, lowmax, highmax, cutoff, span;
+#define BITS 9
+       unsigned char     histbuf[BITS];
+       /*
+        * the input buffer contains characters with runs of consecutive
+        * bits set. These set bits are an indication of the DCF77 pulse
+        * length. We assume that we receive the pulse at 50 Baud. Thus
+        * a 100ms pulse would generate a 4 bit train (20ms per bit and
+        * start bit)
+        * a 200ms pulse would create all zeroes (and probably a frame error)
+        */
+
+       for (i = 0; i < BITS; i++)
+       {
+               histbuf[i] = 0;
+       }
+
+       cutoff = 0;
+       lowmax = 0;
+
+       while (s < e)
+       {
+               unsigned int ch = *s ^ 0xFF;
+               /*
+                * these lines are left as an excercise to the reader 8-)
+                */
+               if (!((ch+1) & ch) || !*s)
+               {
+
+                       for (i = 0; ch; i++)
+                       {
+                               ch >>= 1;
+                       }
+
+                       *s = i;
+                       histbuf[i]++;
+                       cutoff += i;
+                       lowmax++;
+               }
+               else
+               {
+                       parseprintf(DD_RAWDCF,("parse: cvt_rawdcf: character check for 0x%x@%d FAILED\n", *s, (int)(s - (unsigned char *)buffer)));
+                       *s = (unsigned char)~0;
+                       rtc = CVT_FAIL|CVT_BADFMT;
+               }
+               s++;
+       }
+
+       if (lowmax)
+       {
+               cutoff /= lowmax;
+       }
+       else
+       {
+               cutoff = 4;     /* doesn't really matter - it'll fail anyway, but gives error output */
+       }
+
+       parseprintf(DD_RAWDCF,("parse: cvt_rawdcf: average bit count: %d\n", cutoff));
+
+       lowmax = 0;
+       highmax = 0;
+
+       parseprintf(DD_RAWDCF,("parse: cvt_rawdcf: histogram:"));
+       for (i = 0; i <= cutoff; i++)
+       {
+               lowmax+=histbuf[i] * i;
+               highmax += histbuf[i];
+               parseprintf(DD_RAWDCF,(" %d", histbuf[i]));
+       }
+       parseprintf(DD_RAWDCF, (" <M>"));
+
+       lowmax += highmax / 2;
+
+       if (highmax)
+       {
+               lowmax /= highmax;
+       }
+       else
+       {
+               lowmax = 0;
+       }
+
+       highmax = 0;
+       cutoff = 0;
+
+       for (; i < BITS; i++)
+       {
+               highmax+=histbuf[i] * i;
+               cutoff +=histbuf[i];
+               parseprintf(DD_RAWDCF,(" %d", histbuf[i]));
+       }
+       parseprintf(DD_RAWDCF,("\n"));
+
+       if (cutoff)
+       {
+               highmax /= cutoff;
+       }
+       else
+       {
+               highmax = BITS-1;
+       }
+
+       span = cutoff = lowmax;
+       for (i = lowmax; i <= highmax; i++)
+       {
+               if (histbuf[cutoff] > histbuf[i])
+               {
+                       cutoff = i;
+                       span = i;
+               }
+               else
+                   if (histbuf[cutoff] == histbuf[i])
+                   {
+                           span = i;
+                   }
+       }
+
+       cutoff = (cutoff + span) / 2;
+
+       parseprintf(DD_RAWDCF,("parse: cvt_rawdcf: lower maximum %d, higher maximum %d, cutoff %d\n", lowmax, highmax, cutoff));
+
+       s = (unsigned char *)buffer;
+       while (s < e)
+       {
+               if (*s == (unsigned char)~0)
+               {
+                       *s = '?';
+               }
+               else
+               {
+                       *s = (*s >= cutoff) ? *b : *c;
+               }
+               s++;
+               if (*b) b++;
+               if (*c) c++;
+       }
+
+        if (rtc == CVT_NONE)
+        {
+              rtc = convert_rawdcf(buffer, size, &dcfparameter, clock_time);
+              if (rtc == CVT_OK)
+              {
+                       time_t newtime;
+
+                       newtime = parse_to_unixtime(clock_time, &rtc);
+                       if ((rtc == CVT_OK) && t)
+                       {
+                               if ((newtime - t->tcode) == 60) /* guard against multi bit errors */
+                               {
+                                       clock_time->utctime = newtime;
+                               }
+                               else
+                               {
+                                       rtc = CVT_FAIL|CVT_BADTIME;
+                               }
+                               t->tcode            = newtime;
+                       }
+              }
+        }
+        
+       return rtc;
+}
+
+/*
+ * pps_rawdcf
+ *
+ * currently a very stupid version - should be extended to decode
+ * also ones and zeros (which is easy)
+ */
+/*ARGSUSED*/
+static u_long
+pps_rawdcf(
+       parse_t *parseio,
+       int status,
+       timestamp_t *ptime
+       )
+{
+       if (!status)            /* negative edge for simpler wiring (Rx->DCD) */
+       {
+               parseio->parse_dtime.parse_ptime  = *ptime;
+               parseio->parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
+       }
+
+       return CVT_NONE;
+}
+
+static u_long
+snt_rawdcf(
+       parse_t *parseio,
+       timestamp_t *ptime
+       )
+{
+       if ((parseio->parse_dtime.parse_status & CVT_MASK) == CVT_OK)
+       {
+               parseio->parse_dtime.parse_stime = *ptime;
+
+#ifdef PARSEKERNEL
+               parseio->parse_dtime.parse_time.tv.tv_sec++;
+#else
+               parseio->parse_dtime.parse_time.fp.l_ui++;
+#endif
+               
+               parseprintf(DD_RAWDCF,("parse: snt_rawdcf: time stamp synthesized offset %d seconds\n", parseio->parse_index - 1));
+               
+               return updatetimeinfo(parseio, parseio->parse_lstate);
+       }
+       return CVT_NONE;
+}
+
+/*
+ * inp_rawdcf
+ *
+ * grab DCF77 data from input stream
+ */
+static u_long
+inp_rawdcf(
+         parse_t      *parseio,
+         unsigned int  ch,
+         timestamp_t  *tstamp
+         )
+{
+       static struct timeval timeout = { 1, 500000 }; /* 1.5 secongs denote second #60 */
+       
+       parseprintf(DD_PARSE, ("inp_rawdcf(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+       
+       parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
+
+       if (parse_timedout(parseio, tstamp, &timeout))
+       {
+               parseprintf(DD_PARSE, ("inp_rawdcf: time out seen\n"));
+
+               (void) parse_end(parseio);
+               (void) parse_addchar(parseio, ch);
+               return PARSE_INP_TIME;
+       }
+       else
+       {
+               unsigned int rtc;
+               
+               rtc = parse_addchar(parseio, ch);
+               if (rtc == PARSE_INP_SKIP)
+               {
+                       if (snt_rawdcf(parseio, tstamp) == CVT_OK)
+                               return PARSE_INP_SYNTH;
+               }
+               return rtc;
+       }
+}
+
+#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_RAWDCF) */
+int clk_rawdcf_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_RAWDCF) */
+
+/*
+ * History:
+ *
+ * clk_rawdcf.c,v
+ * Revision 4.18  2006/06/22 18:40:01  kardel
+ * clean up signedness (gcc 4)
+ *
+ * Revision 4.17  2006/01/22 16:01:55  kardel
+ * update version information
+ *
+ * Revision 4.16  2006/01/22 15:51:22  kardel
+ * generate reasonable timecode output on invalid input
+ *
+ * Revision 4.15  2005/08/06 19:17:06  kardel
+ * clean log output
+ *
+ * Revision 4.14  2005/08/06 17:39:40  kardel
+ * cleanup size handling wrt/ to buffer boundaries
+ *
+ * Revision 4.13  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.12  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.9  1999/12/06 13:42:23  kardel
+ * transfer correctly converted time codes always into tcode
+ *
+ * Revision 4.8  1999/11/28 09:13:50  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.7  1999/04/01 20:07:20  kardel
+ * added checking for minutie increment of timestamps in clk_rawdcf.c
+ *
+ * Revision 4.6  1998/06/14 21:09:37  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.5  1998/06/13 12:04:16  kardel
+ * fix SYSV clock name clash
+ *
+ * Revision 4.4  1998/06/12 15:22:28  kardel
+ * fix prototypes
+ *
+ * Revision 4.3  1998/06/06 18:33:36  kardel
+ * simplified condidional compile expression
+ *
+ * Revision 4.2  1998/05/24 11:04:18  kardel
+ * triggering PPS on negative edge for simpler wiring (Rx->DCD)
+ *
+ * Revision 4.1  1998/05/24 09:39:53  kardel
+ * implementation of the new IO handling model
+ *
+ * Revision 4.0  1998/04/10 19:45:30  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 3.24 log info deleted 1998/04/11 kardel
+ *
+ */
diff --git a/libparse/clk_rcc8000.c b/libparse/clk_rcc8000.c
new file mode 100644 (file)
index 0000000..9ce270d
--- /dev/null
@@ -0,0 +1,198 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/clk_rcc8000.c,v 4.9 2004/11/14 15:29:41 kardel RELEASE_20050508_A
+ *  
+ * clk_rcc8000.c,v 4.9 2004/11/14 15:29:41 kardel RELEASE_20050508_A
+ *
+ * Radiocode Clocks Ltd RCC 8000 Intelligent Off-Air Master Clock support
+ *
+ * Created by R.E.Broughton from clk_trimtaip.c
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_RCC8000)
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
+#ifndef PARSESTREAM
+#include "ntp_stdlib.h"
+#include <stdio.h>
+#else
+#include "sys/parsestreams.h"
+extern void printf P((const char *, ...));
+#endif
+
+/* Type II Serial Output format
+ *
+ *     0000000000111111111122222222223 / char
+ *     0123456789012345678901234567890 \ posn
+ *     HH:MM:SS.XYZ DD/MM/YY DDD W Prn   Actual
+ *      33 44 55 666 00 11 22       7     Parse
+ *        :  :  .      /  /          rn   Check
+ *     "15:50:36.534 30/09/94 273 5 A\x0d\x0a"
+ *
+ * DDD - Day of year number
+ *   W - Day of week number (Sunday is 0)
+ * P is the Status. See comment below for details.
+ */
+
+#define        O_USEC          O_WDAY
+static struct format rcc8000_fmt =
+{ { { 13, 2 }, {16, 2}, { 19, 2}, /* Day, Month, Year */ 
+    {  0, 2 }, { 3, 2}, {  6, 2}, /* Hour, Minute, Second */ 
+    {  9, 3 }, {28, 1}, {  0, 0}, /* uSec, Status (Valid,Reject,BST,Leapyear) */  },
+  (const unsigned char *)"  :  :  .      /  /          \r\n", 
+  /*"15:50:36.534 30/09/94 273 5 A\x0d\x0a" */
+  0 
+};
+
+static unsigned long cvt_rcc8000 P((unsigned char *, int, struct format *, clocktime_t *, void *));
+static unsigned long inp_rcc8000 P((parse_t *, unsigned int, timestamp_t *));
+
+clockformat_t clock_rcc8000 =
+{
+  inp_rcc8000,                 /* no input handling */
+  cvt_rcc8000,                 /* Radiocode clock conversion */
+  0,                           /* no direct PPS monitoring */
+  (void *)&rcc8000_fmt,                /* conversion configuration */
+  "Radiocode RCC8000",
+  31,                          /* string buffer */
+  0                            /* no private data */
+};
+
+static unsigned long
+cvt_rcc8000(
+           unsigned char *buffer,
+           int            size,
+           struct format *format,
+           clocktime_t   *clock_time,
+           void          *local
+           )
+{
+       if (!Strok(buffer, format->fixed_string)) return CVT_NONE;
+#define        OFFS(x) format->field_offsets[(x)].offset
+#define STOI(x, y) Stoi(&buffer[OFFS(x)], y, format->field_offsets[(x)].length)
+       if (    STOI(O_DAY,     &clock_time->day)       ||
+               STOI(O_MONTH,   &clock_time->month)     ||
+               STOI(O_YEAR,    &clock_time->year)      ||
+               STOI(O_HOUR,    &clock_time->hour)      ||
+               STOI(O_MIN,     &clock_time->minute)    ||
+               STOI(O_SEC,     &clock_time->second)    ||
+               STOI(O_USEC,    &clock_time->usecond)
+               ) return CVT_FAIL|CVT_BADFMT;
+       clock_time->usecond *= 1000;
+
+       clock_time->utcoffset = 0;
+
+#define RCCP buffer[28]
+       /*
+        * buffer[28] is the ASCII representation of a hex character ( 0 through F )
+        *      The four bits correspond to:
+        *      8 - Valid Time
+        *      4 - Reject Code
+        *      2 - British Summer Time (receiver set to emit GMT all year.)
+        *      1 - Leap year
+        */
+#define RCC8000_VALID  0x8
+#define RCC8000_REJECT 0x4
+#define RCC8000_BST    0x2
+#define RCC8000_LEAPY  0x1
+
+       clock_time->flags = 0;
+
+       if ( (RCCP >= '0' && RCCP <= '9') || (RCCP >= 'A' && RCCP <= 'F') )
+       {
+               register int flag;
+
+               flag = (RCCP >= '0' && RCCP <= '9' ) ?  RCCP - '0' : RCCP - 'A' + 10;
+
+               if (!(flag & RCC8000_VALID))
+                   clock_time->flags |= PARSEB_POWERUP;
+
+               clock_time->flags |= PARSEB_UTC; /* British special - guess why 8-) */
+    
+               /* other flags not used */
+       }
+       return CVT_OK;
+}
+/*
+ * inp_rcc8000
+ *
+ * grep data from input stream
+ */
+static u_long
+inp_rcc8000(
+           parse_t      *parseio,
+           unsigned int  ch,
+           timestamp_t  *tstamp
+         )
+{
+       unsigned int rtc;
+       
+       parseprintf(DD_PARSE, ("inp_rcc8000(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+       
+       switch (ch)
+       {
+       case '\n':
+               parseprintf(DD_PARSE, ("inp_rcc8000: EOL seen\n"));
+               if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
+                       return parse_end(parseio);
+               else
+                       return rtc;
+               
+
+       default:
+               if (parseio->parse_index == 0) /* take sample at start of message */
+               {
+                       parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
+               }
+               return parse_addchar(parseio, ch);
+       }
+}
+
+#else  /* not (REFCLOCK && CLOCK_PARSE && CLOCK_RCC8000) */
+int clk_rcc8000_bs;
+#endif  /* not (REFCLOCK && CLOCK_PARSE && CLOCK_RCC8000) */
+
+/*
+ * History:
+ *
+ * clk_rcc8000.c,v
+ * Revision 4.9  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.6  1999/11/28 09:13:51  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.5  1998/06/14 21:09:38  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.4  1998/06/13 12:05:02  kardel
+ * fix SYSV clock name clash
+ *
+ * Revision 4.3  1998/06/12 15:22:29  kardel
+ * fix prototypes
+ *
+ * Revision 4.2  1998/06/12 09:13:25  kardel
+ * conditional compile macros fixed
+ * printf prototype
+ *
+ * Revision 4.1  1998/05/24 09:39:53  kardel
+ * implementation of the new IO handling model
+ *
+ * Revision 4.0  1998/04/10 19:45:30  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 3.5 log info deleted 1998/04/11 kardel
+ */
diff --git a/libparse/clk_schmid.c b/libparse/clk_schmid.c
new file mode 100644 (file)
index 0000000..4f48201
--- /dev/null
@@ -0,0 +1,258 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/clk_schmid.c,v 4.9 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *  
+ * clk_schmid.c,v 4.9 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * Schmid clock support
+ * based on information and testing from Adam W. Feigin et. al (Swisstime iis.ethz.ch)
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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 HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_SCHMID)
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
+#ifndef PARSESTREAM
+#include "ntp_stdlib.h"
+#include <stdio.h>
+#else
+#include "sys/parsestreams.h"
+extern void printf P((const char *, ...));
+#endif
+
+/*
+ * Description courtesy of Adam W. Feigin et. al (Swisstime iis.ethz.ch)
+ *
+ * The command to Schmid's DCF77 clock is a single byte; each bit
+ * allows the user to select some part of the time string, as follows (the
+ * output for the lsb is sent first).
+ * 
+ * Bit 0:      time in MEZ, 4 bytes *binary, not BCD*; hh.mm.ss.tenths
+ * Bit 1:      date 3 bytes *binary, not BCD: dd.mm.yy
+ * Bit 2:      week day, 1 byte (unused here)
+ * Bit 3:      time zone, 1 byte, 0=MET, 1=MEST. (unused here)
+ * Bit 4:      clock status, 1 byte,   0=time invalid,
+ *                                     1=time from crystal backup,
+ *                                     3=time from DCF77
+ * Bit 5:      transmitter status, 1 byte,
+ *                                     bit 0: backup antenna
+ *                                     bit 1: time zone change within 1h
+ *                                     bit 3,2: TZ 01=MEST, 10=MET
+ *                                     bit 4: leap second will be
+ *                                             added within one hour
+ *                                     bits 5-7: Zero
+ * Bit 6:      time in backup mode, units of 5 minutes (unused here)
+ *
+ */
+#define WS_TIME                0x01
+#define WS_SIGNAL      0x02
+
+#define WS_ALTERNATE   0x01
+#define WS_ANNOUNCE    0x02
+#define WS_TZ          0x0c
+#define   WS_MET       0x08
+#define   WS_MEST      0x04
+#define WS_LEAP                0x10
+
+static u_long cvt_schmid P((unsigned char *, int, struct format *, clocktime_t *, void *));
+static unsigned long inp_schmid P((parse_t *, unsigned int, timestamp_t *));
+
+clockformat_t clock_schmid =
+{
+  inp_schmid,                  /* no input handling */
+  cvt_schmid,                  /* Schmid conversion */
+  0,                           /* not direct PPS monitoring */
+  0,                           /* conversion configuration */
+  "Schmid",                    /* Schmid receiver */
+  12,                          /* binary data buffer */
+  0,                           /* no private data (complete messages) */
+};
+
+
+static u_long
+cvt_schmid(
+          unsigned char *buffer,
+          int            size,
+          struct format *format,
+          clocktime_t   *clock_time,
+          void          *local
+       )
+{
+       if ((size != 11) || (buffer[10] != (unsigned char)'\375'))
+       {
+               return CVT_NONE;
+       }
+       else
+       {
+               if (buffer[0] > 23 || buffer[1] > 59 || buffer[2] > 59 || buffer[3] >  9) /* Time */
+               {
+                       return CVT_FAIL|CVT_BADTIME;
+               }
+               else
+                   if (buffer[4] <  1 || buffer[4] > 31 || buffer[5] <  1 || buffer[5] > 12
+                       ||  buffer[6] > 99)
+                   {
+                           return CVT_FAIL|CVT_BADDATE;
+                   }
+                   else
+                   {
+                           clock_time->hour    = buffer[0];
+                           clock_time->minute  = buffer[1];
+                           clock_time->second  = buffer[2];
+                           clock_time->usecond = buffer[3] * 100000;
+                           clock_time->day     = buffer[4];
+                           clock_time->month   = buffer[5];
+                           clock_time->year    = buffer[6];
+
+                           clock_time->flags   = 0;
+
+                           switch (buffer[8] & WS_TZ)
+                           {
+                               case WS_MET:
+                                   clock_time->utcoffset = -1*60*60;
+                                   break;
+
+                               case WS_MEST:
+                                   clock_time->utcoffset = -2*60*60;
+                                   clock_time->flags    |= PARSEB_DST;
+                                   break;
+
+                               default:
+                                   return CVT_FAIL|CVT_BADFMT;
+                           }
+         
+                           if (!(buffer[7] & WS_TIME))
+                           {
+                                   clock_time->flags |= PARSEB_POWERUP;
+                           }
+
+                           if (!(buffer[7] & WS_SIGNAL))
+                           {
+                                   clock_time->flags |= PARSEB_NOSYNC;
+                           }
+
+                           if (buffer[7] & WS_SIGNAL)
+                           {
+                                   if (buffer[8] & WS_ALTERNATE)
+                                   {
+                                           clock_time->flags |= PARSEB_ALTERNATE;
+                                   }
+
+                                   if (buffer[8] & WS_ANNOUNCE)
+                                   {
+                                           clock_time->flags |= PARSEB_ANNOUNCE;
+                                   }
+
+                                   if (buffer[8] & WS_LEAP)
+                                   {
+                                           clock_time->flags |= PARSEB_LEAPADD; /* default: DCF77 data format deficiency */
+                                   }
+                           }
+
+                           clock_time->flags |= PARSEB_S_LEAP|PARSEB_S_ANTENNA;
+         
+                           return CVT_OK;
+                   }
+       }
+}
+
+/*
+ * inp_schmid
+ *
+ * grep data from input stream
+ */
+static u_long
+inp_schmid(
+         parse_t      *parseio,
+         unsigned int  ch,
+         timestamp_t  *tstamp
+         )
+{
+       unsigned int rtc;
+       
+       parseprintf(DD_PARSE, ("inp_schmid(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+       
+       switch (ch)
+       {
+       case 0xFD:              /*  */
+               parseprintf(DD_PARSE, ("mbg_input: ETX seen\n"));
+               if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
+                       return parse_end(parseio);
+               else
+                       return rtc;
+
+       default:
+               return parse_addchar(parseio, ch);
+       }
+}
+
+#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_SCHMID) */
+int clk_schmid_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_SCHMID) */
+
+/*
+ * History:
+ *
+ * clk_schmid.c,v
+ * Revision 4.9  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.8  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.5  1999/11/28 09:13:51  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.4  1998/06/13 12:06:03  kardel
+ * fix SYSV clock name clash
+ *
+ * Revision 4.3  1998/06/12 15:22:29  kardel
+ * fix prototypes
+ *
+ * Revision 4.2  1998/06/12 09:13:26  kardel
+ * conditional compile macros fixed
+ * printf prototype
+ *
+ * Revision 4.1  1998/05/24 09:39:53  kardel
+ * implementation of the new IO handling model
+ *
+ * Revision 4.0  1998/04/10 19:45:31  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 3.22 log info deleted 1998/04/11 kardel
+ */
diff --git a/libparse/clk_trimtaip.c b/libparse/clk_trimtaip.c
new file mode 100644 (file)
index 0000000..67db471
--- /dev/null
@@ -0,0 +1,223 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/clk_trimtaip.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * clk_trimtaip.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * Trimble SV6 clock support - several collected codepieces
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_TRIMTAIP)
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
+#ifndef PARSESTREAM
+#include "ntp_stdlib.h"
+#include <stdio.h>
+#else
+#include "sys/parsestreams.h"
+extern void printf P((const char *, ...));
+#endif
+
+/*     0000000000111111111122222222223333333   / char
+ *     0123456789012345678901234567890123456   \ posn
+ *     >RTMhhmmssdddDDMMYYYYoodnnvrrrrr;*xx<   Actual
+ *     ----33445566600112222BB7__-_____--99-   Parse
+ *     >RTM                      1     ;*  <", Check
+ */
+
+#define        hexval(x) (('0' <= (x) && (x) <= '9') ? (x) - '0' : \
+                  ('a' <= (x) && (x) <= 'f') ? (x) - 'a' + 10 : \
+                  ('A' <= (x) && (x) <= 'F') ? (x) - 'A' + 10 : \
+                  -1)
+#define        O_USEC          O_WDAY
+#define        O_GPSFIX        O_FLAGS
+#define        O_CHKSUM        O_UTCHOFFSET
+     static struct format trimsv6_fmt =
+{ { { 13, 2 }, {15, 2}, { 17, 4}, /* Day, Month, Year */
+    {  4, 2 }, { 6, 2}, {  8, 2}, /* Hour, Minute, Second */
+    { 10, 3 }, {23, 1}, {  0, 0}, /* uSec, FIXes (WeekDAY, FLAGS, ZONE) */
+    { 34, 2 }, { 0, 0}, { 21, 2}, /* cksum, -, utcS (UTC[HMS]OFFSET) */
+},
+  (const unsigned char *)">RTM                      1     ;*  <",
+  0
+};
+
+static unsigned long cvt_trimtaip P((unsigned char *, int, struct format *, clocktime_t *, void *));
+static unsigned long inp_trimtaip P((parse_t *, unsigned int, timestamp_t *));
+
+clockformat_t clock_trimtaip =
+{
+  inp_trimtaip,                        /* no input handling */
+  cvt_trimtaip,                        /* Trimble conversion */
+  pps_one,                     /* easy PPS monitoring */
+  (void *)&trimsv6_fmt,                /* conversion configuration */
+  "Trimble TAIP",
+  37,                          /* string buffer */
+  0                            /* no private data */
+};
+
+static unsigned long
+cvt_trimtaip(
+            unsigned char *buffer,
+            int            size,
+            struct format *format,
+            clocktime_t   *clock_time,
+            void          *local
+            )
+{
+       long gpsfix;
+       u_char calc_csum = 0;
+       long   recv_csum;
+       int      i;
+
+       if (!Strok(buffer, format->fixed_string)) return CVT_NONE;
+#define        OFFS(x) format->field_offsets[(x)].offset
+#define        STOI(x, y) \
+       Stoi(&buffer[OFFS(x)], y, \
+            format->field_offsets[(x)].length)
+               if (    STOI(O_DAY,     &clock_time->day)       ||
+                       STOI(O_MONTH,   &clock_time->month)     ||
+                       STOI(O_YEAR,    &clock_time->year)      ||
+                       STOI(O_HOUR,    &clock_time->hour)      ||
+                       STOI(O_MIN,     &clock_time->minute)    ||
+                       STOI(O_SEC,     &clock_time->second)    ||
+                       STOI(O_USEC,    &clock_time->usecond)||
+                       STOI(O_GPSFIX,  &gpsfix)
+                       ) return CVT_FAIL|CVT_BADFMT;
+
+       clock_time->usecond *= 1000;
+       /* Check that the checksum is right */
+       for (i=OFFS(O_CHKSUM)-1; i >= 0; i--) calc_csum ^= buffer[i];
+       recv_csum =     (hexval(buffer[OFFS(O_CHKSUM)]) << 4) |
+               hexval(buffer[OFFS(O_CHKSUM)+1]);
+       if (recv_csum < 0) return CVT_FAIL|CVT_BADTIME;
+       if (((u_char) recv_csum) != calc_csum) return CVT_FAIL|CVT_BADTIME;
+
+       clock_time->utcoffset = 0;
+
+       /* What should flags be set to ? */
+       clock_time->flags = PARSEB_UTC;
+
+       /* if the current GPS fix is 9 (unknown), reject */
+       if (0 > gpsfix || gpsfix > 9) clock_time->flags |= PARSEB_POWERUP;
+
+       return CVT_OK;
+}
+
+/*
+ * inp_trimtaip
+ *
+ * grep data from input stream
+ */
+static u_long
+inp_trimtaip(
+            parse_t      *parseio,
+            unsigned int  ch,
+            timestamp_t  *tstamp
+         )
+{
+       unsigned int rtc;
+       
+       parseprintf(DD_PARSE, ("inp_trimtaip(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+       
+       switch (ch)
+       {
+       case '>':
+               parseprintf(DD_PARSE, ("inp_trimptaip: START seen\n"));
+               
+               parseio->parse_index = 1;
+               parseio->parse_data[0] = ch;
+               parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
+               return PARSE_INP_SKIP;
+         
+       case '<':
+               parseprintf(DD_PARSE, ("inp_trimtaip: END seen\n"));
+               if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
+                       return parse_end(parseio);
+               else
+                       return rtc;
+
+
+       default:
+               return parse_addchar(parseio, ch);
+       }
+}
+
+#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_TRIMTAIP) */
+int clk_trimtaip_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_TRIMTAIP) */
+
+/*
+ * History:
+ *
+ * clk_trimtaip.c,v
+ * Revision 4.11  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.10  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.7  1999/11/28 09:13:51  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.6  1998/08/16 18:46:27  kardel
+ * (clock_trimtaip =): changed format name
+ *
+ * Revision 4.5  1998/06/14 21:09:38  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.4  1998/06/13 12:06:57  kardel
+ * fix SYSV clock name clash
+ *
+ * Revision 4.3  1998/06/12 15:22:29  kardel
+ * fix prototypes
+ *
+ * Revision 4.2  1998/06/12 09:13:26  kardel
+ * conditional compile macros fixed
+ * printf prototype
+ *
+ * Revision 4.1  1998/05/24 09:39:54  kardel
+ * implementation of the new IO handling model
+ *
+ * Revision 4.0  1998/04/10 19:45:31  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 1.4 log info deleted 1998/04/11 kardel
+ */
+
diff --git a/libparse/clk_trimtsip.c b/libparse/clk_trimtsip.c
new file mode 100644 (file)
index 0000000..be97b74
--- /dev/null
@@ -0,0 +1,456 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/clk_trimtsip.c,v 4.17 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * clk_trimtsip.c,v 4.17 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * Trimble TSIP support
+ * Thanks to Sven Dietrich for providing test hardware
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_TRIMTSIP)
+
+#include "ntp_syslog.h"
+#include "ntp_types.h"
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+#include "ntp_machine.h"
+#include "ntp_stdlib.h"
+
+#include "parse.h"
+
+#ifndef PARSESTREAM
+# include <stdio.h>
+#else
+# include "sys/parsestreams.h"
+#endif
+
+#include "ascii.h"
+#include "binio.h"
+#include "ieee754io.h"
+#include "trimble.h"
+
+/*
+ * Trimble low level TSIP parser / time converter
+ *
+ * The receiver uses a serial message protocol called Trimble Standard
+ * Interface Protocol (it can support others but this driver only supports
+ * TSIP). Messages in this protocol have the following form:
+ *
+ * <DLE><id> ... <data> ... <DLE><ETX>
+ *
+ * Any bytes within the <data> portion of value 10 hex (<DLE>) are doubled
+ * on transmission and compressed back to one on reception. Otherwise
+ * the values of data bytes can be anything. The serial interface is RS-422
+ * asynchronous using 9600 baud, 8 data bits with odd party (**note** 9 bits
+ * in total!), and 1 stop bit. The protocol supports byte, integer, single,
+ * and double datatypes. Integers are two bytes, sent most significant first.
+ * Singles are IEEE754 single precision floating point numbers (4 byte) sent
+ * sign & exponent first. Doubles are IEEE754 double precision floating point
+ * numbers (8 byte) sent sign & exponent first.
+ * The receiver supports a large set of messages, only a very small subset of
+ * which is used here.
+ *
+ * From this module the following are recognised:
+ *
+ *  ID    Description
+ *
+ *  41    GPS Time
+ *  46    Receiver health
+ *  4F    UTC correction data (used to get leap second warnings)
+ *
+ * All others are accepted but ignored for time conversion - they are passed up to higher layers.
+ *
+ */
+
+static offsets_t trim_offsets = { 0, 1, 2, 3, 4, 5, 6, 7 };
+
+struct trimble
+{
+       u_char  t_in_pkt;       /* first DLE received */
+       u_char  t_dle;          /* subsequent DLE received */
+       u_short t_week;         /* GPS week */
+       u_short t_weekleap;     /* GPS week of next/last week */
+       u_short t_dayleap;      /* day in week */
+       u_short t_gpsutc;       /* GPS - UTC offset */
+       u_short t_gpsutcleap;   /* offset at next/last leap */
+       u_char  t_operable;     /* receiver feels OK */
+       u_char  t_mode;         /* actual operating mode */
+       u_char  t_leap;         /* possible leap warning */
+        u_char  t_utcknown;    /* utc offset known */
+};
+
+#define STATUS_BAD    0                /* BAD or UNINITIALIZED receiver status */
+#define STATUS_UNSAFE 1                /* not enough receivers for full precision */
+#define STATUS_SYNC   2                /* enough information for good operation */
+
+static unsigned long inp_tsip P((parse_t *, unsigned int, timestamp_t *));
+static unsigned long cvt_trimtsip P((unsigned char *, int, struct format *, clocktime_t *, void *));
+
+struct clockformat clock_trimtsip =
+{
+       inp_tsip,               /* Trimble TSIP input handler */
+       cvt_trimtsip,           /* Trimble TSIP conversion */
+       pps_one,                /* easy PPS monitoring */
+       0,                      /* no configuration data */
+       "Trimble TSIP",
+       400,                    /* input buffer */
+       sizeof(struct trimble)  /* private data */
+};
+
+#define ADDSECOND      0x01
+#define DELSECOND      0x02
+
+static unsigned long
+inp_tsip(
+        parse_t      *parseio,
+        unsigned int ch,
+        timestamp_t  *tstamp
+       )
+{
+       struct trimble *t = (struct trimble *)parseio->parse_pdata;
+
+       if (!t)
+           return PARSE_INP_SKIP;              /* local data not allocated - sigh! */
+
+       if (!t->t_in_pkt && ch != DLE) {
+               /* wait for start of packet */
+               return PARSE_INP_SKIP;
+       }
+
+       if ((parseio->parse_index >= (parseio->parse_dsize - 2)) ||
+           (parseio->parse_dtime.parse_msglen >= (sizeof(parseio->parse_dtime.parse_msg) - 2)))
+               {               /* OVERFLOW - DROP! */
+                       t->t_in_pkt = t->t_dle = 0;
+                       parseio->parse_index = 0;
+                       parseio->parse_dtime.parse_msglen = 0;
+               return PARSE_INP_SKIP;
+       }
+
+       switch (ch) {
+           case DLE:
+               if (!t->t_in_pkt) {
+                       t->t_dle = 0;
+                       t->t_in_pkt = 1;
+                       parseio->parse_index = 0;
+                       parseio->parse_data[parseio->parse_index++] = ch;
+                       parseio->parse_dtime.parse_msglen = 0;
+                       parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = ch;
+                       parseio->parse_dtime.parse_stime = *tstamp; /* pick up time stamp at packet start */
+               } else if (t->t_dle) {
+                       /* Double DLE -> insert a DLE */
+                       t->t_dle = 0;
+                       parseio->parse_data[parseio->parse_index++] = DLE;
+                       parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = DLE;
+               } else
+                   t->t_dle = 1;
+               break;
+
+           case ETX:
+               if (t->t_dle) {
+                       /* DLE,ETX -> end of packet */
+                       parseio->parse_data[parseio->parse_index++] = DLE;
+                       parseio->parse_data[parseio->parse_index] = ch;
+                       parseio->parse_ldsize = parseio->parse_index+1;
+                       memcpy(parseio->parse_ldata, parseio->parse_data, parseio->parse_ldsize);
+                       parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = DLE;
+                       parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = ch;
+                       t->t_in_pkt = t->t_dle = 0;
+                       return PARSE_INP_TIME|PARSE_INP_DATA;
+               }
+
+           default:            /* collect data */
+               t->t_dle = 0;
+               parseio->parse_data[parseio->parse_index++] = ch;
+               parseio->parse_dtime.parse_msg[parseio->parse_dtime.parse_msglen++] = ch;
+       }
+
+  return PARSE_INP_SKIP;
+}
+     
+static int
+getshort(
+        unsigned char *p
+        )
+{
+       return get_msb_short(&p);
+}
+
+/*
+ * cvt_trimtsip
+ *
+ * convert TSIP type format
+ */
+static unsigned long
+cvt_trimtsip(
+            unsigned char *buffer,
+            int            size,
+            struct format *format,
+            clocktime_t   *clock_time,
+            void          *local
+            )
+{
+        register struct trimble *t = (struct trimble *)local; /* get local data space */
+#define mb(_X_) (buffer[2+(_X_)]) /* shortcut for buffer access */
+       register u_char cmd;
+
+       clock_time->flags = 0;
+
+       if (!t) {
+               return CVT_NONE;                /* local data not allocated - sigh! */
+       }
+
+       if ((size < 4) ||
+           (buffer[0]      != DLE) ||
+           (buffer[size-1] != ETX) ||
+           (buffer[size-2] != DLE))
+       {
+               printf("TRIMBLE BAD packet, size %d:\n", size);
+               return CVT_NONE;
+       }
+       else
+       {
+               unsigned char *bp;
+               cmd = buffer[1];
+      
+                   switch(cmd)
+                   {
+                   case CMD_RCURTIME:
+                           {                   /* GPS time */
+                                   l_fp secs;
+                                   int   week = getshort((unsigned char *)&mb(4));
+                                   l_fp utcoffset;
+                                   l_fp gpstime;
+
+                                   bp = &mb(0);
+                                   if (fetch_ieee754(&bp, IEEE_SINGLE, &secs, trim_offsets) != IEEE_OK)
+                                           return CVT_FAIL|CVT_BADFMT;
+                                   
+                                   if ((secs.l_i <= 0) ||
+                                       (t->t_utcknown == 0))
+                                   {
+                                           clock_time->flags = PARSEB_POWERUP;
+                                           return CVT_OK;
+                                   }
+                                   if (week < 990) {
+                                           week += 1024;
+                                   }
+
+                                   /* time OK */
+
+                                   /* fetch UTC offset */
+                                   bp = &mb(6);
+                                   if (fetch_ieee754(&bp, IEEE_SINGLE, &utcoffset, trim_offsets) != IEEE_OK)
+                                           return CVT_FAIL|CVT_BADFMT;
+                                   
+                                   L_SUB(&secs, &utcoffset); /* adjust GPS time to UTC time */
+
+                                   gpstolfp((unsigned short)week, (unsigned short)0,
+                                            secs.l_ui, &gpstime);
+
+                                   gpstime.l_uf = secs.l_uf;
+
+                                   clock_time->utctime = gpstime.l_ui - JAN_1970;
+
+                                   TSFTOTVU(gpstime.l_uf, clock_time->usecond);
+
+                                   if (t->t_leap == ADDSECOND)
+                                       clock_time->flags |= PARSEB_LEAPADD;
+                     
+                                   if (t->t_leap == DELSECOND)
+                                       clock_time->flags |= PARSEB_LEAPDEL;
+       
+                                   switch (t->t_operable)
+                                     {
+                                     case STATUS_SYNC:
+                                       clock_time->flags &= ~(PARSEB_POWERUP|PARSEB_NOSYNC);
+                                       break;
+
+                                     case STATUS_UNSAFE:
+                                       clock_time->flags |= PARSEB_NOSYNC;
+                                       break;
+
+                                     case STATUS_BAD:
+                                       clock_time->flags |= PARSEB_NOSYNC|PARSEB_POWERUP;
+                                       break;
+                                     }
+                                       
+                                   if (t->t_mode == 0)
+                                           clock_time->flags |= PARSEB_POSITION;
+                                   
+                                   clock_time->flags |= PARSEB_S_LEAP|PARSEB_S_POSITION;
+                                   
+                                   return CVT_OK;
+
+                           } /* case 0x41 */
+
+                   case CMD_RRECVHEALTH:
+                           {
+                                   /* TRIMBLE health */
+                                   u_char status = mb(0);
+
+                                   switch (status)
+                                   {
+                                     case 0x00: /* position fixes */
+                                       t->t_operable = STATUS_SYNC;
+                                       break;
+
+                                     case 0x09: /* 1 satellite */
+                                     case 0x0A: /* 2 satellites */
+                                     case 0x0B: /* 3 satellites */
+                                       t->t_operable = STATUS_UNSAFE;
+                                       break;
+
+                                     default:
+                                       t->t_operable = STATUS_BAD;
+                                       break;
+                                   }
+                                   t->t_mode = status;
+                           }
+                           break;
+
+                   case CMD_RUTCPARAM:
+                           {
+                                   l_fp t0t;
+                                   unsigned char *lbp;
+                                   
+                                   /* UTC correction data - derive a leap warning */
+                                   int tls   = t->t_gpsutc     = getshort((unsigned char *)&mb(12)); /* current leap correction (GPS-UTC) */
+                                   int tlsf  = t->t_gpsutcleap = getshort((unsigned char *)&mb(24)); /* new leap correction */
+
+                                   t->t_weekleap   = getshort((unsigned char *)&mb(20)); /* week no of leap correction */
+                                   if (t->t_weekleap < 990)
+                                     t->t_weekleap += 1024;
+
+                                   t->t_dayleap    = getshort((unsigned char *)&mb(22)); /* day in week of leap correction */
+                                   t->t_week = getshort((unsigned char *)&mb(18)); /* current week no */
+                                   if (t->t_week < 990)
+                                     t->t_week += 1024;
+                                   
+                                   lbp = (unsigned char *)&mb(14); /* last update time */
+                                   if (fetch_ieee754(&lbp, IEEE_SINGLE, &t0t, trim_offsets) != IEEE_OK)
+                                           return CVT_FAIL|CVT_BADFMT;
+
+                                   t->t_utcknown = t0t.l_ui != 0;
+                                     
+                                   if ((t->t_utcknown) && /* got UTC information */
+                                       (tlsf != tls)   && /* something will change */
+                                       ((t->t_weekleap - t->t_week) < 5)) /* and close in the future */
+                                   {
+                                           /* generate a leap warning */
+                                           if (tlsf > tls)
+                                               t->t_leap = ADDSECOND;
+                                           else
+                                               t->t_leap = DELSECOND;
+                                   }
+                                   else
+                                   {
+                                           t->t_leap = 0;
+                                   }
+                           }
+                           break;
+
+                   default:
+                           /* it's validly formed, but we don't care about it! */
+                           break;
+               }
+       }
+       return CVT_SKIP;
+}
+
+#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_TRIMTSIP && !PARSESTREAM) */
+int clk_trimtsip_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_TRIMTSIP && !PARSESTREAM) */
+
+/*
+ * History:
+ *
+ * clk_trimtsip.c,v
+ * Revision 4.17  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.16  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.13  1999/11/28 09:13:51  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.12  1999/02/28 13:00:08  kardel
+ * *** empty log message ***
+ *
+ * Revision 4.11  1999/02/28 11:47:54  kardel
+ * (struct trimble): new member t_utcknown
+ * (cvt_trimtsip): fixed status monitoring, bad receiver states are
+ * now recognized
+ *
+ * Revision 4.10  1999/02/27 15:57:15  kardel
+ * use mmemcpy instead of bcopy
+ *
+ * Revision 4.9  1999/02/21 12:17:42  kardel
+ * 4.91f reconcilation
+ *
+ * Revision 4.8  1998/11/15 20:27:58  kardel
+ * Release 4.0.73e13 reconcilation
+ *
+ * Revision 4.7  1998/08/16 18:49:20  kardel
+ * (cvt_trimtsip): initial kernel capable version (no more floats)
+ * (clock_trimtsip =): new format name
+ *
+ * Revision 4.6  1998/08/09 22:26:05  kardel
+ * Trimble TSIP support
+ *
+ * Revision 4.5  1998/08/02 10:37:05  kardel
+ * working TSIP parser
+ *
+ * Revision 4.4  1998/06/28 16:50:40  kardel
+ * (getflt): fixed ENDIAN issue
+ * (getdbl): fixed ENDIAN issue
+ * (getint): use get_msb_short()
+ * (cvt_trimtsip): use gpstolfp() for conversion
+ *
+ * Revision 4.3  1998/06/13 12:07:31  kardel
+ * fix SYSV clock name clash
+ *
+ * Revision 4.2  1998/06/12 15:22:30  kardel
+ * fix prototypes
+ *
+ * Revision 4.1  1998/05/24 09:39:54  kardel
+ * implementation of the new IO handling model
+ *
+ * Revision 4.0  1998/04/10 19:45:32  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 1.8 loginfo deleted 1998/04/11 kardel
+ */
diff --git a/libparse/clk_varitext.c b/libparse/clk_varitext.c
new file mode 100644 (file)
index 0000000..01b8719
--- /dev/null
@@ -0,0 +1,271 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_VARITEXT)
+/*
+ * /src/NTP/ntp4-dev/libparse/clk_varitext.c,v 1.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * clk_varitext.c,v 1.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * Varitext code variant by A.McConnell 1997/01/19
+ * 
+ * Supports Varitext's Radio Clock
+ * 
+ * Used the Meinberg/Computime clock as a template for Varitext Radio Clock
+ *
+ * Codebase:
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
+#ifndef PARSESTREAM
+# include "ntp_stdlib.h"
+# include <stdio.h>
+#else
+# include "sys/parsestreams.h"
+extern void printf P((const char *, ...));
+#endif
+
+static const u_char VT_INITIALISED      = 0x01;
+static const u_char VT_SYNCHRONISED     = 0x02;
+static const u_char VT_ALARM_STATE      = 0x04;
+static const u_char VT_BST              = 0x08;
+static const u_char VT_SEASON_CHANGE    = 0x10;
+static const u_char VT_LAST_TELEGRAM_OK = 0x20;
+
+/*
+ * The Varitext receiver sends a datagram in the following format every minute
+ * 
+ * Timestamp   T:YY:MM:MD:WD:HH:MM:SSCRLFSTXXX 
+ * Pos          0123456789012345678901 2 3 4567
+ *              0000000000111111111122 2 2 2222
+ * Parse        T:  :  :  :  :  :  :  \r\n    
+ * 
+ * T   Startcharacter "T" specifies start of the timestamp 
+ * YY  Year MM Month 1-12 
+ * MD  Day of the month 
+ * WD  Day of week 
+ * HH  Hour 
+ * MM   Minute 
+ * SS   Second
+ * CR   Carriage return 
+ * LF   Linefeed
+ * ST  Status character
+ *     Bit 0 - Set= Initialised; Reset=Time Invalid (DO NOT USE)
+ *     Bit 1 - Set= Synchronised; Reset= Unsynchronised 
+ *     Bit 2 - Set= Alarm state; Reset= No alarm
+ *     Bit 3 - Set= BST; Reset= GMT
+ *     Bit 4 - Set= Seasonal change in approx hour; Reset= No seasonal change expected
+ *     Bit 5 - Set= Last MSF telegram was OK; Reset= Last telegram was in error;
+ *     Bit 6 - Always set
+ *     Bit 7 - Unused
+ * XXX Checksum calculated using Fletcher's method (ignored for now). 
+ */
+
+static struct format varitext_fmt =
+{
+  {
+    {8, 2},  {5,  2}, {2,  2}, /* day, month, year */
+    {14, 2}, {17, 2}, {20, 2}, /* hour, minute, second */
+    {11, 2}, {24, 1}           /* dayofweek, status */
+  },
+  (const unsigned char*)"T:  :  :  :  :  :  :  \r\n    ",
+  0
+};
+
+static u_long   cvt_varitext P((unsigned char *, int, struct format *, clocktime_t *, void *));
+static u_long   inp_varitext P((parse_t *, unsigned int, timestamp_t *));
+
+struct varitext {
+  unsigned char start_found;
+  unsigned char end_found;
+  unsigned char end_count;
+  unsigned char previous_ch;
+  timestamp_t   tstamp;
+};
+
+clockformat_t   clock_varitext =
+{
+  inp_varitext,                        /* Because of the strange format we need to parse it ourselves */
+  cvt_varitext,                        /* Varitext conversion */
+  0,                           /* no PPS monitoring */
+  (void *)&varitext_fmt,       /* conversion configuration */
+  "Varitext Radio Clock",      /* Varitext Radio Clock */
+  30,                          /* string buffer */
+  sizeof(struct varitext),     /* Private data size required to hold current parse state */
+};
+
+/*
+ * cvt_varitext
+ * 
+ * convert simple type format
+ */
+static          u_long
+cvt_varitext(
+            unsigned char      *buffer,
+            int                size,
+            struct format      *format,
+            clocktime_t        *clock_time,
+            void               *local
+            )
+{
+
+  if (!Strok(buffer, format->fixed_string)) { 
+    return CVT_NONE;
+  } else {
+    if (Stoi(&buffer[format->field_offsets[O_DAY].offset], &clock_time->day,
+            format->field_offsets[O_DAY].length) ||
+       Stoi(&buffer[format->field_offsets[O_MONTH].offset], &clock_time->month,
+            format->field_offsets[O_MONTH].length) ||
+       Stoi(&buffer[format->field_offsets[O_YEAR].offset], &clock_time->year,
+            format->field_offsets[O_YEAR].length) ||
+       Stoi(&buffer[format->field_offsets[O_HOUR].offset], &clock_time->hour,
+            format->field_offsets[O_HOUR].length) ||
+       Stoi(&buffer[format->field_offsets[O_MIN].offset], &clock_time->minute,
+            format->field_offsets[O_MIN].length) ||
+       Stoi(&buffer[format->field_offsets[O_SEC].offset], &clock_time->second,
+            format->field_offsets[O_SEC].length)) { 
+      return CVT_FAIL | CVT_BADFMT;
+    } else {
+      u_char *f = (u_char*) &buffer[format->field_offsets[O_FLAGS].offset];
+
+      clock_time->flags = 0;
+      clock_time->utcoffset = 0;
+
+      if (((*f) & VT_BST))     /* BST flag is set so set to indicate daylight saving time is active and utc offset */
+       {
+         clock_time->utcoffset = -1*60*60;
+         clock_time->flags |= PARSEB_DST;
+       }
+      /*
+        if (!((*f) & VT_INITIALISED))  Clock not initialised 
+        clock_time->flags |= PARSEB_POWERUP;
+        
+        if (!((*f) & VT_SYNCHRONISED))   Clock not synchronised 
+        clock_time->flags |= PARSEB_NOSYNC;
+        
+        if (((*f) & VT_SEASON_CHANGE))  Seasonal change expected in the next hour 
+        clock_time->flags |= PARSEB_ANNOUNCE;
+        */
+      return CVT_OK; 
+    }
+  }
+}
+
+static u_long 
+inp_varitext(
+            parse_t     *parseio,
+            unsigned int ch,
+            timestamp_t *tstamp
+            )
+{
+  struct varitext *t = (struct varitext *)parseio->parse_pdata;
+  int    rtc;
+
+  parseprintf(DD_PARSE, ("inp_varitext(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+
+  if (!t) 
+    return PARSE_INP_SKIP;     /* local data not allocated - sigh! */
+
+  if (ch == 'T') 
+    t->tstamp = *tstamp;
+
+  if ((t->previous_ch == 'T') && (ch == ':'))
+    {
+      parseprintf(DD_PARSE, ("inp_varitext: START seen\n"));
+
+      parseio->parse_data[0] = 'T';
+      parseio->parse_index=1;
+      parseio->parse_dtime.parse_stime = t->tstamp; /* Time stamp at packet start */
+      t->start_found = 1;
+      t->end_found = 0;
+      t->end_count = 0;
+    }
+
+  if (t->start_found)
+    {
+      if ((rtc = parse_addchar(parseio, ch)) != PARSE_INP_SKIP)
+       {
+         parseprintf(DD_PARSE, ("inp_varitext: ABORTED due to too many characters\n"));
+
+         memset(t, 0, sizeof(struct varitext));
+         return rtc;
+       }
+
+      if (t->end_found) 
+       {
+         if (++(t->end_count) == 4) /* Finally found the end of the message */
+           {
+             parseprintf(DD_PARSE, ("inp_varitext: END seen\n"));
+
+             memset(t, 0, sizeof(struct varitext));
+             if ((rtc = parse_addchar(parseio, 0)) == PARSE_INP_SKIP)
+               return parse_end(parseio);
+             else
+               return rtc;
+           }   
+       }
+
+      if ((t->previous_ch == '\r') && (ch == '\n')) 
+       {
+         t->end_found = 1;
+       }
+
+    }
+  t->previous_ch = ch;
+
+  return PARSE_INP_SKIP;
+}
+
+#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_VARITEXT) */
+int clk_varitext_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_VARITEXT) */
+
+/*
+ * History:
+ *
+ * clk_varitext.c,v
+ * Revision 1.5  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 1.4  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ *
+ * Revision 1.0  1997/06/02 13:16:30  McConnell
+ * File created
+ *
+ */
diff --git a/libparse/clk_wharton.c b/libparse/clk_wharton.c
new file mode 100644 (file)
index 0000000..b4332fb
--- /dev/null
@@ -0,0 +1,181 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/clk_wharton.c,v 4.2 2004/11/14 15:29:41 kardel RELEASE_20050508_A
+ *  
+ * clk_wharton.c,v 4.2 2004/11/14 15:29:41 kardel RELEASE_20050508_A
+ *
+ * From Philippe De Muyter <phdm@macqel.be>, 1999
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE) && defined(CLOCK_WHARTON_400A)
+/*
+ * Support for WHARTON 400A Series clock + 404.2 serial interface.
+ *
+ * Copyright (C) 1999, 2000 by Philippe De Muyter <phdm@macqel.be>
+ * 
+ * This program is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.
+ * 
+ */
+
+#include "ntp_fp.h"
+#include "ascii.h"
+#include "parse.h"
+
+#ifndef PARSESTREAM
+#include "ntp_stdlib.h"
+#include <stdio.h>
+#else
+#include "sys/parsestreams.h"
+extern void printf P((const char *, ...));
+#endif
+
+/*
+ * In private e-mail alastair@wharton.co.uk said :
+ * "If you are going to use the 400A and 404.2 system [for ntp] I recommend
+ * that you set the 400A to output the message every second.  The start of
+ * transmission of the first byte of the message is synchronised to the
+ * second edge."
+ * The WHARTON 400A Series is able to send date/time serial messages
+ * in 7 output formats.  We use format 1 here because it is the shortest.
+ * For use with this driver, the WHARTON 400A Series clock must be set-up
+ * as follows :
+ *                                     Programmable    Selected
+ *                                     Option No       Option
+ *     BST or CET display              3               9 or 11
+ *     No external controller          7               0
+ *     Serial Output Format 1          9               1
+ *     Baud rate 9600 bps              10              96
+ *     Bit length 8 bits               11              8
+ *     Parity even                     12              E
+ *
+ * WHARTON 400A Series output format 1 is as follows :
+ * 
+ * Timestamp   STXssmmhhDDMMYYSETX
+ * Pos         0  12345678901234
+ *             0  00000000011111
+ *
+ *     STX     start transmission (ASCII 0x02)
+ *     ETX     end transmission (ASCII 0x03)
+ *     ss      Second expressed in reversed decimal (units then tens)
+ *     mm      Minute expressed in reversed decimal
+ *     hh      Hour expressed in reversed decimal
+ *     DD      Day of month expressed in reversed decimal
+ *     MM      Month expressed in reversed decimal (January is 1)
+ *     YY      Year (without century) expressed in reversed decimal
+ *     S       Status byte : 0x30 +
+ *                     bit 0   0 = MSF source          1 = DCF source
+ *                     bit 1   0 = Winter time         1 = Summer time
+ *                     bit 2   0 = not synchronised    1 = synchronised
+ *                     bit 3   0 = no early warning    1 = early warning
+ * 
+ */
+
+/*
+ * cvt_wharton_400a
+ * 
+ * convert simple type format
+ */
+static          u_long
+cvt_wharton_400a(
+       unsigned char *buffer,
+       int            size,
+       struct format *format,
+       clocktime_t   *clock_time,
+       void          *local
+       )
+{
+       int     i;
+
+       /* The given `size' includes a terminating null-character. */
+       if (size != 16 || buffer[0] != STX || buffer[14] != ETX
+           || buffer[13] < '0' || buffer[13] > ('0' + 0xf))
+               return CVT_NONE;
+       for (i = 1; i < 13; i += 1)
+               if (buffer[i] < '0' || buffer[i] > '9')
+                       return CVT_NONE;
+       clock_time->second = (buffer[2] - '0') * 10 + buffer[1] - '0';
+       clock_time->minute = (buffer[4] - '0') * 10 + buffer[3] - '0';
+       clock_time->hour   = (buffer[6] - '0') * 10 + buffer[5] - '0';
+       clock_time->day    = (buffer[8] - '0') * 10 + buffer[7] - '0';
+       clock_time->month  = (buffer[10] - '0') * 10 + buffer[9] - '0';
+       clock_time->year   = (buffer[12] - '0') * 10 + buffer[11] - '0';
+       clock_time->usecond = 0;
+       if (buffer[13] & 0x1) /* We have CET time */
+               clock_time->utcoffset = -1*60*60;
+       else            /* We have BST time */
+               clock_time->utcoffset = 0;
+       if (buffer[13] & 0x2) {
+               clock_time->flags |= PARSEB_DST;
+               clock_time->utcoffset += -1*60*60;
+       }
+       if (!(buffer[13] & 0x4))
+               clock_time->flags |= PARSEB_NOSYNC;
+       if (buffer[13] & 0x8)
+               clock_time->flags |= PARSEB_ANNOUNCE;
+
+       return CVT_OK;
+}
+
+/*
+ * inp_wharton_400a
+ *
+ * grep data from input stream
+ */
+static u_long
+inp_wharton_400a(
+             parse_t      *parseio,
+             unsigned int  ch,
+             timestamp_t  *tstamp
+             )
+{
+       unsigned int rtc;
+       
+       parseprintf(DD_PARSE, ("inp_wharton_400a(0x%lx, 0x%x, ...)\n", (long)parseio, ch));
+       
+       switch (ch)
+       {
+       case STX:
+               parseprintf(DD_PARSE, ("inp_wharton_400a: STX seen\n"));
+               
+               parseio->parse_index = 1;
+               parseio->parse_data[0] = ch;
+               parseio->parse_dtime.parse_stime = *tstamp; /* collect timestamp */
+               return PARSE_INP_SKIP;
+         
+       case ETX:
+               parseprintf(DD_PARSE, ("inp_wharton_400a: ETX seen\n"));
+               if ((rtc = parse_addchar(parseio, ch)) == PARSE_INP_SKIP)
+                       return parse_end(parseio);
+               else
+                       return rtc;
+
+       default:
+               return parse_addchar(parseio, ch);
+       }
+}
+
+clockformat_t   clock_wharton_400a =
+{
+       inp_wharton_400a,       /* input handling function */
+       cvt_wharton_400a,       /* conversion function */
+       0,                      /* no PPS monitoring */
+       0,                      /* conversion configuration */
+       "WHARTON 400A Series clock Output Format 1",    /* String format name */
+       15,                     /* string buffer */
+       0                       /* no private data (complete pakets) */
+};
+
+#else /* not (REFCLOCK && CLOCK_PARSE && CLOCK_WHARTON_400A) */
+int clk_wharton_400a_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE && CLOCK_WHARTON_400A) */
+
+/*
+ * clk_wharton.c,v
+ * Revision 4.1  1999/02/28 15:27:24  kardel
+ * wharton clock integration
+ *
+ */
diff --git a/libparse/data_mbg.c b/libparse/data_mbg.c
new file mode 100644 (file)
index 0000000..9b6f1aa
--- /dev/null
@@ -0,0 +1,538 @@
+/*
+ * /src/NTP/REPOSITORY/ntp4-dev/libparse/data_mbg.c,v 4.8 2006/06/22 18:40:01 kardel RELEASE_20060622_A
+ *
+ * data_mbg.c,v 4.8 2006/06/22 18:40:01 kardel RELEASE_20060622_A
+ *
+ * $Created: Sun Jul 20 12:08:14 1997 $
+ *
+ * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef PARSESTREAM
+#define NEED_BOPS
+#include "ntp_string.h"
+#else
+#include <stdio.h>
+#endif
+#include "ntp_types.h"
+#include "ntp_stdlib.h"
+#include "ntp_fp.h"
+#include "mbg_gps166.h"
+#include "binio.h"
+#include "ieee754io.h"
+
+static void get_mbg_tzname P((unsigned char **, char *));
+static void mbg_time_status_str P((char **, unsigned int, int));
+
+#if 0                          /* no actual floats on Meinberg binary interface */
+static offsets_t mbg_float  = { 1, 0, 3, 2, 0, 0, 0, 0 }; /* byte order for meinberg floats */
+#endif
+static offsets_t mbg_double = { 1, 0, 3, 2, 5, 4, 7, 6 }; /* byte order for meinberg doubles */
+static int32   rad2deg_i = 57;
+static u_int32 rad2deg_f = 0x4BB834C7; /* 57.2957795131 == 180/PI */
+
+void
+put_mbg_header(
+       unsigned char **bufpp,
+       GPS_MSG_HDR *headerp
+       )
+{
+  put_lsb_short(bufpp, headerp->gps_cmd);
+  put_lsb_short(bufpp, headerp->gps_len);
+  put_lsb_short(bufpp, headerp->gps_data_csum);
+  put_lsb_short(bufpp, headerp->gps_hdr_csum);
+}
+
+void
+get_mbg_sw_rev(
+       unsigned char **bufpp,
+       SW_REV *sw_revp
+       )
+{
+  sw_revp->code = get_lsb_short(bufpp);
+  memcpy(sw_revp->name, *bufpp, sizeof(sw_revp->name));
+  *bufpp += sizeof(sw_revp->name);
+}
+
+void
+get_mbg_ascii_msg(
+       unsigned char **bufpp,
+       ASCII_MSG *ascii_msgp
+       )
+{
+  ascii_msgp->csum  = get_lsb_short(bufpp);
+  ascii_msgp->valid = get_lsb_short(bufpp);
+  memcpy(ascii_msgp->s, *bufpp, sizeof(ascii_msgp->s));
+  *bufpp += sizeof(ascii_msgp->s);
+}
+
+void
+get_mbg_svno(
+       unsigned char **bufpp,
+       SVNO *svnop
+       )
+{
+  *svnop = get_lsb_short(bufpp);
+}
+
+void
+get_mbg_health(
+       unsigned char **bufpp,
+       HEALTH *healthp
+       )
+{
+  *healthp = get_lsb_short(bufpp);
+}
+
+void
+get_mbg_cfg(
+       unsigned char **bufpp,
+       CFG *cfgp
+       )
+{
+  *cfgp = get_lsb_short(bufpp);
+}
+
+void
+get_mbg_tgps(
+       unsigned char **bufpp,
+       T_GPS *tgpsp
+       )
+{
+  tgpsp->wn = get_lsb_short(bufpp);
+  tgpsp->sec = get_lsb_long(bufpp);
+  tgpsp->tick = get_lsb_long(bufpp);
+}
+
+void
+get_mbg_tm(
+       unsigned char **buffpp,
+       TM *tmp
+       )
+{
+  tmp->year = get_lsb_short(buffpp);
+  tmp->month = *(*buffpp)++;
+  tmp->mday  = *(*buffpp)++;
+  tmp->yday  = get_lsb_short(buffpp);
+  tmp->wday  = *(*buffpp)++;
+  tmp->hour  = *(*buffpp)++;
+  tmp->minute = *(*buffpp)++;
+  tmp->second = *(*buffpp)++;
+  tmp->frac  = get_lsb_long(buffpp);
+  tmp->offs_from_utc = get_lsb_long(buffpp);
+  tmp->status= get_lsb_short(buffpp);
+}
+
+void
+get_mbg_ttm(
+       unsigned char **buffpp,
+       TTM *ttmp
+       )
+{
+  ttmp->channel = get_lsb_short(buffpp);
+  get_mbg_tgps(buffpp, &ttmp->t);
+  get_mbg_tm(buffpp, &ttmp->tm);
+}
+
+void
+get_mbg_synth(
+       unsigned char **buffpp,
+       SYNTH *synthp
+       )
+{
+  synthp->freq  = get_lsb_short(buffpp);
+  synthp->range = get_lsb_short(buffpp);
+  synthp->phase = get_lsb_short(buffpp);
+}
+
+static void
+get_mbg_tzname(
+       unsigned char **buffpp,
+       char *tznamep
+       )
+{
+  strncpy(tznamep, (char *)*buffpp, sizeof(TZ_NAME));
+  *buffpp += sizeof(TZ_NAME);
+}
+
+void
+get_mbg_tzdl(
+       unsigned char **buffpp,
+       TZDL *tzdlp
+       )
+{
+  tzdlp->offs = get_lsb_long(buffpp);
+  tzdlp->offs_dl = get_lsb_long(buffpp);
+  get_mbg_tm(buffpp, &tzdlp->tm_on);
+  get_mbg_tm(buffpp, &tzdlp->tm_off);
+  get_mbg_tzname(buffpp, (char *)tzdlp->name[0]);
+  get_mbg_tzname(buffpp, (char *)tzdlp->name[1]);
+}
+
+void
+get_mbg_antinfo(
+       unsigned char **buffpp,
+       ANT_INFO *antinfop
+       )
+{
+  antinfop->status = get_lsb_short(buffpp);
+  get_mbg_tm(buffpp, &antinfop->tm_disconn);
+  get_mbg_tm(buffpp, &antinfop->tm_reconn);
+  antinfop->delta_t = get_lsb_long(buffpp);
+}
+
+static void
+mbg_time_status_str(
+       char **buffpp,
+       unsigned int status,
+       int size
+       )
+{
+       static struct state
+       {
+               int         flag;               /* bit flag */
+               const char *string;     /* bit name */
+       } states[] =
+                 {
+                         { TM_UTC,    "UTC CORR" },
+                         { TM_LOCAL,  "LOCAL TIME" },
+                         { TM_DL_ANN, "DST WARN" },
+                         { TM_DL_ENB, "DST" },
+                         { TM_LS_ANN, "LEAP WARN" },
+                         { TM_LS_ENB, "LEAP SEC" },
+                         { 0, "" }
+                 };
+
+       if (status)
+       {
+               char *start, *p;
+               struct state *s;
+       
+               start = p = *buffpp;
+
+               for (s = states; s->flag; s++)
+               {
+                       if (s->flag & status)
+                       {
+                               if (p != *buffpp)
+                               {
+                                       strncpy(p, ", ", size - (p - start));
+                                       p += 2;
+                               }
+                               strncpy(p, s->string, size - (p - start));
+                               p += strlen(p);
+                       }
+               }
+               *buffpp = p;
+       }
+}
+      
+void
+mbg_tm_str(
+       char **buffpp,
+       TM *tmp,
+       int size
+       )
+{
+       char *s = *buffpp;
+
+       snprintf(*buffpp, size, "%04d-%02d-%02d %02d:%02d:%02d.%07ld (%c%02d%02d) ",
+                tmp->year, tmp->month, tmp->mday,
+                tmp->hour, tmp->minute, tmp->second, tmp->frac,
+                (tmp->offs_from_utc < 0) ? '-' : '+',
+                abs(tmp->offs_from_utc) / 3600,
+                (abs(tmp->offs_from_utc) / 60) % 60);
+       *buffpp += strlen(*buffpp);
+
+       mbg_time_status_str(buffpp, tmp->status, size - (*buffpp - s));
+}
+
+void
+mbg_tgps_str(
+       char **buffpp,
+       T_GPS *tgpsp,
+       int size
+       )
+{
+       snprintf(*buffpp, size, "week %d + %ld days + %ld.%07ld sec",
+                tgpsp->wn, tgpsp->sec / 86400,
+                tgpsp->sec % 86400, tgpsp->tick);
+       *buffpp += strlen(*buffpp);
+}
+
+void
+get_mbg_cfgh(
+       unsigned char **buffpp,
+       CFGH *cfghp
+       )
+{
+  int i;
+  
+  cfghp->csum = get_lsb_short(buffpp);
+  cfghp->valid = get_lsb_short(buffpp);
+  get_mbg_tgps(buffpp, &cfghp->tot_51);
+  get_mbg_tgps(buffpp, &cfghp->tot_63);
+  get_mbg_tgps(buffpp, &cfghp->t0a);
+
+  for (i = MIN_SVNO; i <= MAX_SVNO; i++)
+    {
+      get_mbg_cfg(buffpp, &cfghp->cfg[i]);
+    }
+  
+  for (i = MIN_SVNO; i <= MAX_SVNO; i++)
+    {
+      get_mbg_health(buffpp, &cfghp->health[i]);
+    }
+}
+
+void
+get_mbg_utc(
+       unsigned char **buffpp,
+       UTC *utcp
+       )
+{
+  utcp->csum  = get_lsb_short(buffpp);
+  utcp->valid = get_lsb_short(buffpp);
+
+  get_mbg_tgps(buffpp, &utcp->t0t);
+  
+  if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A0, mbg_double) != IEEE_OK)
+    {
+      L_CLR(&utcp->A0);
+    }
+  
+  if (fetch_ieee754(buffpp, IEEE_DOUBLE, &utcp->A1, mbg_double) != IEEE_OK)
+    {
+      L_CLR(&utcp->A1);
+    }
+
+  utcp->WNlsf      = get_lsb_short(buffpp);
+  utcp->DNt        = get_lsb_short(buffpp);
+  utcp->delta_tls  = *(*buffpp)++;
+  utcp->delta_tlsf = *(*buffpp)++;
+}
+
+void
+get_mbg_lla(
+       unsigned char **buffpp,
+       LLA lla
+       )
+{
+  int i;
+  
+  for (i = LAT; i <= ALT; i++)
+    {
+      if  (fetch_ieee754(buffpp, IEEE_DOUBLE, &lla[i], mbg_double) != IEEE_OK)
+       {
+         L_CLR(&lla[i]);
+       }
+      else
+       if (i != ALT)
+         {                     /* convert to degrees (* 180/PI) */
+           mfp_mul(&lla[i].l_i, &lla[i].l_uf, lla[i].l_i, lla[i].l_uf, rad2deg_i, rad2deg_f);
+         }
+    }
+}
+
+void
+get_mbg_xyz(
+       unsigned char **buffpp,
+       XYZ xyz
+       )
+{
+  int i;
+  
+  for (i = XP; i <= ZP; i++)
+    {
+      if  (fetch_ieee754(buffpp, IEEE_DOUBLE, &xyz[i], mbg_double) != IEEE_OK)
+       {
+         L_CLR(&xyz[i]);
+       }
+    }
+}
+
+static void
+get_mbg_comparam(
+       unsigned char **buffpp,
+       COM_PARM *comparamp
+       )
+{
+  int i;
+  
+  comparamp->baud_rate = get_lsb_long(buffpp);
+  for (i = 0; i < sizeof(comparamp->framing); i++)
+    {
+      comparamp->framing[i] = *(*buffpp)++;
+    }
+  comparamp->handshake = get_lsb_short(buffpp);
+}
+
+void
+get_mbg_portparam(
+       unsigned char **buffpp,
+       PORT_PARM *portparamp
+       )
+{
+  int i;
+  
+  for (i = 0; i < N_COM; i++)
+    {
+      get_mbg_comparam(buffpp, &portparamp->com[i]);
+    }
+  for (i = 0; i < N_COM; i++)
+    {
+      portparamp->mode[i] = *(*buffpp)++;
+    }
+}
+
+#define FETCH_DOUBLE(src, addr)                                                        \
+       if  (fetch_ieee754(src, IEEE_DOUBLE, addr, mbg_double) != IEEE_OK)      \
+       {                                                                       \
+         L_CLR(addr);                                                          \
+       }
+       
+void
+get_mbg_eph(
+       unsigned char ** buffpp,
+       EPH *ephp
+       )
+{
+  ephp->csum   = get_lsb_short(buffpp);
+  ephp->valid  = get_lsb_short(buffpp);
+  
+  ephp->health = get_lsb_short(buffpp);
+  ephp->IODC   = get_lsb_short(buffpp);
+  ephp->IODE2  = get_lsb_short(buffpp);
+  ephp->IODE3  = get_lsb_short(buffpp);
+
+  get_mbg_tgps(buffpp, &ephp->tt);
+  get_mbg_tgps(buffpp, &ephp->t0c);
+  get_mbg_tgps(buffpp, &ephp->t0e);
+
+  FETCH_DOUBLE(buffpp, &ephp->sqrt_A);
+  FETCH_DOUBLE(buffpp, &ephp->e);
+  FETCH_DOUBLE(buffpp, &ephp->M0);
+  FETCH_DOUBLE(buffpp, &ephp->omega);
+  FETCH_DOUBLE(buffpp, &ephp->OMEGA0);
+  FETCH_DOUBLE(buffpp, &ephp->OMEGADOT);
+  FETCH_DOUBLE(buffpp, &ephp->deltan);
+  FETCH_DOUBLE(buffpp, &ephp->i0);
+  FETCH_DOUBLE(buffpp, &ephp->idot);
+  FETCH_DOUBLE(buffpp, &ephp->crc);
+  FETCH_DOUBLE(buffpp, &ephp->crs);
+  FETCH_DOUBLE(buffpp, &ephp->cuc);
+  FETCH_DOUBLE(buffpp, &ephp->cus);
+  FETCH_DOUBLE(buffpp, &ephp->cic);
+  FETCH_DOUBLE(buffpp, &ephp->cis);
+
+  FETCH_DOUBLE(buffpp, &ephp->af0);
+  FETCH_DOUBLE(buffpp, &ephp->af1);
+  FETCH_DOUBLE(buffpp, &ephp->af2);
+  FETCH_DOUBLE(buffpp, &ephp->tgd);
+
+  ephp->URA = get_lsb_short(buffpp);
+
+  ephp->L2code = *(*buffpp)++;
+  ephp->L2flag = *(*buffpp)++;
+}
+
+void
+get_mbg_alm(
+       unsigned char **buffpp,
+       ALM *almp
+       )
+{
+  almp->csum   = get_lsb_short(buffpp);
+  almp->valid  = get_lsb_short(buffpp);
+  
+  almp->health = get_lsb_short(buffpp);
+  get_mbg_tgps(buffpp, &almp->t0a);
+
+
+  FETCH_DOUBLE(buffpp, &almp->sqrt_A);
+  FETCH_DOUBLE(buffpp, &almp->e);
+
+  FETCH_DOUBLE(buffpp, &almp->M0);
+  FETCH_DOUBLE(buffpp, &almp->omega);
+  FETCH_DOUBLE(buffpp, &almp->OMEGA0);
+  FETCH_DOUBLE(buffpp, &almp->OMEGADOT);
+  FETCH_DOUBLE(buffpp, &almp->deltai);
+  FETCH_DOUBLE(buffpp, &almp->af0);
+  FETCH_DOUBLE(buffpp, &almp->af1);
+}
+
+void
+get_mbg_iono(
+       unsigned char **buffpp,
+       IONO *ionop
+       )
+{
+  ionop->csum   = get_lsb_short(buffpp);
+  ionop->valid  = get_lsb_short(buffpp);
+
+  FETCH_DOUBLE(buffpp, &ionop->alpha_0);
+  FETCH_DOUBLE(buffpp, &ionop->alpha_1);
+  FETCH_DOUBLE(buffpp, &ionop->alpha_2);
+  FETCH_DOUBLE(buffpp, &ionop->alpha_3);
+
+  FETCH_DOUBLE(buffpp, &ionop->beta_0);
+  FETCH_DOUBLE(buffpp, &ionop->beta_1);
+  FETCH_DOUBLE(buffpp, &ionop->beta_2);
+  FETCH_DOUBLE(buffpp, &ionop->beta_3);
+}
+
+/*
+ * data_mbg.c,v
+ * Revision 4.8  2006/06/22 18:40:01  kardel
+ * clean up signedness (gcc 4)
+ *
+ * Revision 4.7  2005/10/07 22:11:10  kardel
+ * bounded buffer implementation
+ *
+ * Revision 4.6.2.1  2005/09/25 10:23:06  kardel
+ * support bounded buffers
+ *
+ * Revision 4.6  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.5  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.3  1999/02/21 12:17:42  kardel
+ * 4.91f reconcilation
+ *
+ * Revision 4.2  1998/06/14 21:09:39  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.1  1998/05/24 08:02:06  kardel
+ * trimmed version log
+ *
+ * Revision 4.0  1998/04/10 19:45:33  kardel
+ * Start 4.0 release version numbering
+ */
+
diff --git a/libparse/gpstolfp.c b/libparse/gpstolfp.c
new file mode 100644 (file)
index 0000000..fd7be31
--- /dev/null
@@ -0,0 +1,76 @@
+/*
+ * /src/NTP/ntp4-dev/libntp/gpstolfp.c,v 4.8 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * gpstolfp.c,v 4.8 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * $Created: Sun Jun 28 16:30:38 1998 $
+ *
+ * Copyright (c) 1998-2005 by Frank Kardel <kardel <AT> ntp.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+#include "ntp_fp.h"
+
+#define GPSORIGIN      ULONG_CONST(2524953600) /* NTP origin - GPS origin in seconds */
+#define SECSPERWEEK    (unsigned)(604800)      /* seconds per week - GPS tells us about weeks */
+#define GPSWRAP                990     /* assume week count less than this in the previous epoch */
+
+void
+gpstolfp(
+        int weeks,
+        int days,
+        unsigned long  seconds,
+        l_fp * lfp
+        )
+{
+  if (weeks < GPSWRAP)
+    {
+      weeks += 1024;
+    }
+
+  lfp->l_ui = weeks * SECSPERWEEK + days * 86400 + seconds + GPSORIGIN; /* convert to NTP time */
+  lfp->l_uf = 0;
+}
+
+/*
+ * History:
+ *
+ * gpstolfp.c,v
+ * Revision 4.8  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.7  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.3  1999/02/28 11:42:44  kardel
+ * (GPSWRAP): update GPS rollover to 990 weeks
+ *
+ * Revision 4.2  1998/07/11 10:05:25  kardel
+ * Release 4.0.73d reconcilation
+ *
+ * Revision 4.1  1998/06/28 16:47:15  kardel
+ * added gpstolfp() function
+ */
diff --git a/libparse/ieee754io.c b/libparse/ieee754io.c
new file mode 100644 (file)
index 0000000..27c6525
--- /dev/null
@@ -0,0 +1,610 @@
+/*
+ * /src/NTP/ntp4-dev/libntp/ieee754io.c,v 4.12 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * ieee754io.c,v 4.12 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * $Created: Sun Jul 13 09:12:02 1997 $
+ *
+ * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include <stdio.h>
+#include "l_stdlib.h"
+#include "ntp_stdlib.h"
+#include "ntp_fp.h"
+#include "ieee754io.h"
+
+static unsigned char get_byte P((unsigned char *, offsets_t, int *));
+#ifdef __not_yet__
+static void put_byte P((unsigned char *, offsets_t, int *, unsigned char));
+#endif
+
+#ifdef LIBDEBUG
+
+#include "lib_strbuf.h"
+
+static char *
+fmt_blong(
+         unsigned long val,
+         int cnt
+         )
+{
+  char *buf, *s;
+  int i = cnt;
+
+  val <<= 32 - cnt;
+  LIB_GETBUF(buf);
+  s = buf;
+  
+  while (i--)
+    {
+      if (val & 0x80000000)
+       {
+         *s++ = '1';
+       }
+      else
+       {
+         *s++ = '0';
+       }
+      val <<= 1;
+    }
+  *s = '\0';
+  return buf;
+}
+
+static char *
+fmt_flt(
+       unsigned int sign,
+       unsigned long mh,
+       unsigned long ml,
+       unsigned long ch
+       )
+{
+  char *buf;
+
+  LIB_GETBUF(buf);
+  sprintf(buf, "%c %s %s %s", sign ? '-' : '+',
+         fmt_blong(ch, 11),
+         fmt_blong(mh, 20),
+         fmt_blong(ml, 32));
+  return buf;
+}
+
+static char *
+fmt_hex(
+       unsigned char *bufp,
+       int length
+       )
+{
+  char *buf;
+  int i;
+
+  LIB_GETBUF(buf);
+  for (i = 0; i < length; i++)
+    {
+      sprintf(buf+i*2, "%02x", bufp[i]);
+    }
+  return buf;
+}
+
+#endif
+
+static unsigned char
+get_byte(
+        unsigned char *bufp,
+        offsets_t offset,
+        int *fieldindex
+        )
+{
+  unsigned char val;
+
+  val     = *(bufp + offset[*fieldindex]);
+#ifdef LIBDEBUG
+  if (debug > 4)
+    printf("fetchieee754: getbyte(0x%08x, %d) = 0x%02x\n", (unsigned int)(bufp)+offset[*fieldindex], *fieldindex, val);
+#endif
+  (*fieldindex)++;
+  return val;
+}
+
+#ifdef __not_yet__
+static void
+put_byte(
+        unsigned char *bufp,
+        offsets_t offsets,
+        int *fieldindex,
+        unsigned char val
+        )
+{
+  *(bufp + offsets[*fieldindex]) = val;
+  (*fieldindex)++;
+}
+#endif
+
+/*
+ * make conversions to and from external IEEE754 formats and internal
+ * NTP FP format.
+ */
+int
+fetch_ieee754(
+             unsigned char **buffpp,
+             int size,
+             l_fp *lfpp,
+             offsets_t offsets
+             )
+{
+  unsigned char *bufp = *buffpp;
+  unsigned int sign;
+  unsigned int bias;
+  unsigned int maxexp;
+  int mbits;
+  u_long mantissa_low;
+  u_long mantissa_high;
+  u_long characteristic;
+  long exponent;
+#ifdef LIBDEBUG
+  int length;
+#endif
+  unsigned char val;
+  int fieldindex = 0;
+  
+  switch (size)
+    {
+    case IEEE_DOUBLE:
+#ifdef LIBDEBUG
+      length = 8;
+#endif
+      mbits  = 52;
+      bias   = 1023;
+      maxexp = 2047;
+      break;
+
+    case IEEE_SINGLE:
+#ifdef LIBDEBUG
+      length = 4;
+#endif
+      mbits  = 23;
+      bias   = 127;
+      maxexp = 255;
+      break;
+
+    default:
+      return IEEE_BADCALL;
+    }
+  
+  val = get_byte(bufp, offsets, &fieldindex); /* fetch sign byte & first part of characteristic */
+  
+  sign     = (val & 0x80) != 0;
+  characteristic = (val & 0x7F);
+
+  val = get_byte(bufp, offsets, &fieldindex); /* fetch rest of characteristic and start of mantissa */
+  
+  switch (size)
+    {
+    case IEEE_SINGLE:
+      characteristic <<= 1;
+      characteristic  |= (val & 0x80) != 0; /* grab last characteristic bit */
+
+      mantissa_high  = 0;
+
+      mantissa_low   = (val &0x7F) << 16;
+      mantissa_low  |= get_byte(bufp, offsets, &fieldindex) << 8;
+      mantissa_low  |= get_byte(bufp, offsets, &fieldindex);
+      break;
+      
+    case IEEE_DOUBLE:
+      characteristic <<= 4;
+      characteristic  |= (val & 0xF0) >> 4; /* grab lower characteristic bits */
+
+      mantissa_high  = (val & 0x0F) << 16;
+      mantissa_high |= get_byte(bufp, offsets, &fieldindex) << 8;
+      mantissa_high |= get_byte(bufp, offsets, &fieldindex);
+
+      mantissa_low   = get_byte(bufp, offsets, &fieldindex) << 24;
+      mantissa_low  |= get_byte(bufp, offsets, &fieldindex) << 16;
+      mantissa_low  |= get_byte(bufp, offsets, &fieldindex) << 8;
+      mantissa_low  |= get_byte(bufp, offsets, &fieldindex);
+      break;
+      
+    default:
+      return IEEE_BADCALL;
+    }
+#ifdef LIBDEBUG
+  if (debug > 4)
+  {
+    double d;
+    float f;
+
+    if (size == IEEE_SINGLE)
+      {
+       int i;
+
+       for (i = 0; i < length; i++)
+         {
+           *((unsigned char *)(&f)+i) = *(*buffpp + offsets[i]);
+         }
+       d = f;
+      }
+    else
+      {
+       int i;
+
+       for (i = 0; i < length; i++)
+         {
+           *((unsigned char *)(&d)+i) = *(*buffpp + offsets[i]);
+         }
+      }
+    
+    printf("fetchieee754: FP: %s -> %s -> %e(=%s)\n", fmt_hex(*buffpp, length),
+          fmt_flt(sign, mantissa_high, mantissa_low, characteristic),
+          d, fmt_hex((unsigned char *)&d, length));
+  }
+#endif
+
+  *buffpp += fieldindex;
+  
+  /*
+   * detect funny numbers
+   */
+  if (characteristic == maxexp)
+    {
+      /*
+       * NaN or Infinity
+       */
+      if (mantissa_low || mantissa_high)
+       {
+         /*
+          * NaN
+          */
+         return IEEE_NAN;
+       }
+      else
+       {
+         /*
+          * +Inf or -Inf
+          */
+         return sign ? IEEE_NEGINFINITY : IEEE_POSINFINITY;
+       }
+    }
+  else
+    {
+      /*
+       * collect real numbers
+       */
+
+      L_CLR(lfpp);
+
+      /*
+       * check for overflows
+       */
+      exponent = characteristic - bias;
+
+      if (exponent > 31)       /* sorry - hardcoded */
+       {
+         /*
+          * overflow only in respect to NTP-FP representation
+          */
+         return sign ? IEEE_NEGOVERFLOW : IEEE_POSOVERFLOW;
+       }
+      else
+       {
+         int frac_offset;      /* where the fraction starts */
+         
+         frac_offset = mbits - exponent;
+
+         if (characteristic == 0) 
+           {
+             /*
+              * de-normalized or tiny number - fits only as 0
+              */
+             return IEEE_OK;
+           }
+         else
+           {
+             /*
+              * adjust for implied 1
+              */
+             if (mbits > 31)
+               mantissa_high |= 1 << (mbits - 32);
+             else
+               mantissa_low  |= 1 << mbits;
+
+             /*
+              * take mantissa apart - if only all machine would support
+              * 64 bit operations 8-(
+              */
+             if (frac_offset > mbits)
+               {
+                 lfpp->l_ui = 0; /* only fractional number */
+                 frac_offset -= mbits + 1; /* will now contain right shift count - 1*/
+                 if (mbits > 31)
+                   {
+                     lfpp->l_uf   = mantissa_high << (63 - mbits);
+                     lfpp->l_uf  |= mantissa_low  >> (mbits - 33);
+                     lfpp->l_uf >>= frac_offset;
+                   }
+                 else
+                   {
+                     lfpp->l_uf = mantissa_low >> frac_offset;
+                   }
+               }
+             else
+               {
+                 if (frac_offset > 32)
+                   {
+                     /*
+                      * must split in high word
+                      */
+                     lfpp->l_ui  =  mantissa_high >> (frac_offset - 32);
+                     lfpp->l_uf  = (mantissa_high & ((1 << (frac_offset - 32)) - 1)) << (64 - frac_offset);
+                     lfpp->l_uf |=  mantissa_low  >> (frac_offset - 32);
+                   }
+                 else
+                   {
+                     /*
+                      * must split in low word
+                      */
+                     lfpp->l_ui  =  mantissa_high << (32 - frac_offset);
+                     lfpp->l_ui |= (mantissa_low >> frac_offset) & ((1 << (32 - frac_offset)) - 1);
+                     lfpp->l_uf  = (mantissa_low & ((1 << frac_offset) - 1)) << (32 - frac_offset);
+                   }
+               }
+             
+             /*
+              * adjust for sign
+              */
+             if (sign)
+               {
+                 L_NEG(lfpp);
+               }
+             
+             return IEEE_OK;
+           }
+       }
+    }
+}
+  
+int
+put_ieee754(
+           unsigned char **bufpp,
+           int size,
+           l_fp *lfpp,
+           offsets_t offsets
+           )
+{
+  l_fp outlfp;
+#ifdef LIBDEBUG
+  unsigned int sign;
+  unsigned int bias;
+#endif
+/*unsigned int maxexp;*/
+  int mbits;
+  int msb;
+  u_long mantissa_low = 0;
+  u_long mantissa_high = 0;
+#ifdef LIBDEBUG
+  u_long characteristic = 0;
+  long exponent;
+#endif
+/*int length;*/
+  unsigned long mask;
+  
+  outlfp = *lfpp;
+
+  switch (size)
+    {
+    case IEEE_DOUBLE:
+    /*length = 8;*/
+      mbits  = 52;
+#ifdef LIBDEBUG
+      bias   = 1023;
+#endif
+    /*maxexp = 2047;*/
+      break;
+
+    case IEEE_SINGLE:
+    /*length = 4;*/
+      mbits  = 23;
+#ifdef LIBDEBUG
+      bias   = 127;
+#endif
+    /*maxexp = 255;*/
+      break;
+
+    default:
+      return IEEE_BADCALL;
+    }
+  
+  /*
+   * find sign
+   */
+  if (L_ISNEG(&outlfp))
+    {
+      L_NEG(&outlfp);
+#ifdef LIBDEBUG
+      sign = 1;
+#endif
+    }
+  else
+    {
+#ifdef LIBDEBUG
+      sign = 0;
+#endif
+    }
+
+  if (L_ISZERO(&outlfp))
+    {
+#ifdef LIBDEBUG
+      exponent = mantissa_high = mantissa_low = 0; /* true zero */
+#endif
+    }
+  else
+    {
+      /*
+       * find number of significant integer bits
+       */
+      mask = 0x80000000;
+      if (outlfp.l_ui)
+       {
+         msb = 63;
+         while (mask && ((outlfp.l_ui & mask) == 0))
+           {
+             mask >>= 1;
+             msb--;
+           }
+       }
+      else
+       {
+         msb = 31;
+         while (mask && ((outlfp.l_uf & mask) == 0))
+           {
+             mask >>= 1;
+             msb--;
+           }
+       }
+  
+      switch (size)
+       {
+       case IEEE_SINGLE:
+         mantissa_high = 0;
+         if (msb >= 32)
+           {
+             mantissa_low  = (outlfp.l_ui & ((1 << (msb - 32)) - 1)) << (mbits - (msb - 32));
+             mantissa_low |=  outlfp.l_uf >> (mbits - (msb - 32));
+           }
+         else
+           {
+             mantissa_low  = (outlfp.l_uf << (mbits - msb)) & ((1 << mbits) - 1);
+           }
+         break;
+         
+       case IEEE_DOUBLE:
+         if (msb >= 32)
+           {
+             mantissa_high  = (outlfp.l_ui << (mbits - msb)) & ((1 << (mbits - 32)) - 1);
+             mantissa_high |=  outlfp.l_uf >> (32 - (mbits - msb));
+             mantissa_low   = (outlfp.l_ui & ((1 << (msb - mbits)) - 1)) << (32 - (msb - mbits));
+             mantissa_low  |=  outlfp.l_uf >> (msb - mbits);
+           }
+         else
+           {
+             mantissa_high  = outlfp.l_uf << (mbits - 32 - msb);
+             mantissa_low   = outlfp.l_uf << (mbits - 32);
+           }
+       }
+
+#ifdef LIBDEBUG
+      exponent = msb - 32;
+      characteristic = exponent + bias;
+
+      if (debug > 4)
+       printf("FP: %s\n", fmt_flt(sign, mantissa_high, mantissa_low, characteristic));
+#endif
+    }
+  return IEEE_OK;
+}
+
+
+#if defined(DEBUG) && defined(LIBDEBUG)
+int main(
+        int argc,
+        char **argv
+        )
+{
+  static offsets_t native_off = { 0, 1, 2, 3, 4, 5, 6, 7 };
+  double f = 1.0;
+  double *f_p = &f;
+  l_fp fp;
+  
+  if (argc == 2)
+    {
+      if (sscanf(argv[1], "%lf", &f) != 1)
+       {
+         printf("cannot convert %s to a float\n", argv[1]);
+         return 1;
+       }
+    }
+  
+  printf("double: %s %s\n", fmt_blong(*(unsigned long *)&f, 32), fmt_blong(*(unsigned long *)((char *)(&f)+4), 32));
+  printf("fetch from %f = %d\n", f, fetch_ieee754((void *)&f_p, IEEE_DOUBLE, &fp, native_off));
+  printf("fp [%s %s] = %s\n", fmt_blong(fp.l_ui, 32), fmt_blong(fp.l_uf, 32), mfptoa(fp.l_ui, fp.l_uf, 15));
+  f_p = &f;
+  put_ieee754((void *)&f_p, IEEE_DOUBLE, &fp, native_off);
+  
+  return 0;
+}
+
+#endif
+/*
+ * History:
+ *
+ * ieee754io.c,v
+ * Revision 4.12  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.11  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.8  1999/02/21 12:17:36  kardel
+ * 4.91f reconcilation
+ *
+ * Revision 4.7  1999/02/21 11:26:03  kardel
+ * renamed index to fieldindex to avoid index() name clash
+ *
+ * Revision 4.6  1998/11/15 20:27:52  kardel
+ * Release 4.0.73e13 reconcilation
+ *
+ * Revision 4.5  1998/08/16 19:01:51  kardel
+ * debug information only compile for LIBDEBUG case
+ *
+ * Revision 4.4  1998/08/09 09:39:28  kardel
+ * Release 4.0.73e2 reconcilation
+ *
+ * Revision 4.3  1998/06/13 11:56:19  kardel
+ * disabled putbute() for the time being
+ *
+ * Revision 4.2  1998/06/12 15:16:58  kardel
+ * ansi2knr compatibility
+ *
+ * Revision 4.1  1998/05/24 07:59:56  kardel
+ * conditional debug support
+ *
+ * Revision 4.0  1998/04/10 19:46:29  kardel
+ * Start 4.0 release version numbering
+ *
+ * Revision 1.1  1998/04/10 19:27:46  kardel
+ * initial NTP VERSION 4 integration of PARSE with GPS166 binary support
+ *
+ * Revision 1.1  1997/10/06 21:05:45  kardel
+ * new parse structure
+ *
+ */
diff --git a/libparse/info_trimble.c b/libparse/info_trimble.c
new file mode 100644 (file)
index 0000000..eea6cbd
--- /dev/null
@@ -0,0 +1,94 @@
+/*
+ * Automatically generated - do not modify
+ */
+
+#include "ntp_types.h"
+#include "ntpd.h"
+#include "trimble.h"
+
+cmd_info_t trimble_scmds[] = {
+       { CMD_CCLROSC, "CMD_CCLROSC", "clear oscillator offset (0x1D)", "", 0 },
+       { CMD_CCLRRST, "CMD_CCLRRST", "clear battery backup and RESET (0x1E)", "", 0 },
+       { CMD_CVERSION, "CMD_CVERSION", "return software version (0x1F)", "", 0 },
+       { CMD_CALMANAC, "CMD_CALMANAC", "almanac (0x20)", "", 0 },
+       { CMD_CCURTIME, "CMD_CCURTIME", "current time (0x21)", "", 0 },
+       { CMD_CMODESEL, "CMD_CMODESEL", "mode select (2-d, 3-D, auto) (0x22)", "", 0 },
+       { CMD_CINITPOS, "CMD_CINITPOS", "initial position (0x23)", "", 0 },
+       { CMD_CRECVPOS, "CMD_CRECVPOS", "receiver position fix mode (0x24)", "", 0 },
+       { CMD_CRESET, "CMD_CRESET", "soft reset & selftest (0x25)", "", 0 },
+       { CMD_CRECVHEALTH, "CMD_CRECVHEALTH", "receiver health (0x26)", "", 0 },
+       { CMD_CSIGNALLV, "CMD_CSIGNALLV", "signal levels (0x27)", "", 0 },
+       { CMD_CMESSAGE, "CMD_CMESSAGE", "GPS system message (0x28)", "", 0 },
+       { CMD_CALMAHEALTH, "CMD_CALMAHEALTH", "almanac healt page (0x29)", "", 0 },
+       { CMD_C2DALTITUDE, "CMD_C2DALTITUDE", "altitude for 2-D mode (0x2A)", "", 0 },
+       { CMD_CINITPOSLLA, "CMD_CINITPOSLLA", "initial position LLA (0x2B)", "", 0 },
+       { CMD_COPERPARAM, "CMD_COPERPARAM", "operating parameters (0x2C)", "", 0 },
+       { CMD_COSCOFFSET, "CMD_COSCOFFSET", "oscillator offset (0x2D)", "", 0 },
+       { CMD_CSETGPSTIME, "CMD_CSETGPSTIME", "set GPS time (0x2E)", "", 0 },
+       { CMD_CUTCPARAM, "CMD_CUTCPARAM", "UTC parameters (0x2F)", "", 0 },
+       { CMD_CACCPOSXYZ, "CMD_CACCPOSXYZ", "accurate initial position (XYZ/ECEF) (0x31)", "", 0 },
+       { CMD_CACCPOS, "CMD_CACCPOS", "accurate initial position (0x32)", "", 0 },
+       { CMD_CANALOGDIG, "CMD_CANALOGDIG", "analog to digital (0x33)", "", 0 },
+       { CMD_CSAT1SAT, "CMD_CSAT1SAT", "satellite for 1-Sat mode (0x34)", "", 0 },
+       { CMD_CIOOPTIONS, "CMD_CIOOPTIONS", "I/O options (0x35)", "", 0 },
+       { CMD_CVELOCAID, "CMD_CVELOCAID", "velocity aiding of acquisition (0x36)", "", 0 },
+       { CMD_CSTATLSTPOS, "CMD_CSTATLSTPOS", "status and values of last pos. and vel. (0x37)", "", 0 },
+       { CMD_CLOADSSATDT, "CMD_CLOADSSATDT", "load satellite system data (0x38)", "", 0 },
+       { CMD_CSATDISABLE, "CMD_CSATDISABLE", "satellite disable (0x39)", "", 0 },
+       { CMD_CLASTRAW, "CMD_CLASTRAW", "last raw measurement (0x3A)", "", 0 },
+       { CMD_CSTATSATEPH, "CMD_CSTATSATEPH", "satellite ephemeris status (0x3B)", "", 0 },
+       { CMD_CSTATTRACK, "CMD_CSTATTRACK", "tracking status (0x3C)", "", 0 },
+       { CMD_CCHANADGPS, "CMD_CCHANADGPS", "configure channel A for differential GPS (0x3D)", "", 0 },
+       { CMD_CADDITFIX, "CMD_CADDITFIX", "additional fix data (0x3E)", "", 0 },
+       { CMD_CDGPSFIXMD, "CMD_CDGPSFIXMD", "set/request differential GPS position fix mode (0x62)", "", 0 },
+       { CMD_CDGPSCORR, "CMD_CDGPSCORR", "differential correction status (0x65)", "", 0 },
+       { CMD_CPOSFILT, "CMD_CPOSFILT", "position filter parameters (0x71)", "", 0 },
+       { CMD_CHEIGHTFILT, "CMD_CHEIGHTFILT", "height filter control (0x73)", "", 0 },
+       { CMD_CHIGH8CNT, "CMD_CHIGH8CNT", "high-8 (best 4) / high-6 (overdetermined) control (0x75)", "", 0 },
+       { CMD_CMAXDGPSCOR, "CMD_CMAXDGPSCOR", "maximum rate of DGPS corrections (0x77)", "", 0 },
+       { CMD_CSUPER, "CMD_CSUPER", "super paket (0x8E)", "", 0 },
+       { 0xFF, "", "" }
+};
+
+
+cmd_info_t trimble_rcmds[] = {
+       { CMD_RDATAA, "CMD_RDATAA", "data channel A configuration (0x3D)", "trimble_channelA", RO },
+       { CMD_RALMANAC, "CMD_RALMANAC", "almanac data for sat (0x40)", "gps_almanac", RO },
+       { CMD_RCURTIME, "CMD_RCURTIME", "GPS time (0x41)", "gps_time", RO },
+       { CMD_RSPOSXYZ, "CMD_RSPOSXYZ", "single precision XYZ position (0x42)", "gps_position(XYZ)", RO|DEF },
+       { CMD_RVELOXYZ, "CMD_RVELOXYZ", "velocity fix (XYZ ECEF) (0x43)", "gps_velocity(XYZ)", RO|DEF },
+       { CMD_RBEST4, "CMD_RBEST4", "best 4 satellite selection (0x44)", "trimble_best4", RO|DEF },
+       { CMD_RVERSION, "CMD_RVERSION", "software version (0x45)", "trimble_version", RO|DEF },
+       { CMD_RRECVHEALTH, "CMD_RRECVHEALTH", "receiver health (0x46)", "trimble_receiver_health", RO|DEF },
+       { CMD_RSIGNALLV, "CMD_RSIGNALLV", "signal levels of all satellites (0x47)", "trimble_signal_levels", RO },
+       { CMD_RMESSAGE, "CMD_RMESSAGE", "GPS system message (0x48)", "gps-message", RO|DEF },
+       { CMD_RALMAHEALTH, "CMD_RALMAHEALTH", "almanac health page for all satellites (0x49)", "gps_almanac_health", RO },
+       { CMD_RSLLAPOS, "CMD_RSLLAPOS", "single LLA position (0x4A)", "gps_position(LLA)", RO|DEF },
+       { CMD_RMACHSTAT, "CMD_RMACHSTAT", "machine code / status (0x4B)", "trimble_status", RO|DEF },
+       { CMD_ROPERPARAM, "CMD_ROPERPARAM", "operating parameters (0x4C)", "trimble_opparam", RO },
+       { CMD_ROSCOFFSET, "CMD_ROSCOFFSET", "oscillator offset (0x4D)", "trimble_oscoffset", RO },
+       { CMD_RSETGPSTIME, "CMD_RSETGPSTIME", "response to set GPS time (0x4E)", "trimble_setgpstime", RO },
+       { CMD_RUTCPARAM, "CMD_RUTCPARAM", "UTC parameters (0x4F)", "gps_utc_correction", RO|DEF },
+       { CMD_RANALOGDIG, "CMD_RANALOGDIG", "analog to digital (0x53)", "trimble_analogdigital", RO },
+       { CMD_RSAT1BIAS, "CMD_RSAT1BIAS", "one-satellite bias & bias rate (0x54)", "trimble_sat1bias", RO },
+       { CMD_RIOOPTIONS, "CMD_RIOOPTIONS", "I/O options (0x55)", "trimble_iooptions", RO },
+       { CMD_RSTATLSTFIX, "CMD_RSTATLSTFIX", "status and values of last pos. and vel. (0x57)", "trimble_status_lastpos", RO },
+       { CMD_RLOADSSATDT, "CMD_RLOADSSATDT", "response to load satellite system data (0x58)", "trimble_loaddata", RO },
+       { CMD_RSATDISABLE, "CMD_RSATDISABLE", "satellite disable (0x59)", "trimble_satdisble", RO },
+       { CMD_RLASTRAW, "CMD_RLASTRAW", "last raw measurement (0x5A)", "trimble_lastraw", RO },
+       { CMD_RSTATSATEPH, "CMD_RSTATSATEPH", "satellite ephemeris status (0x5B)", "trimble_ephstatus", RO },
+       { CMD_RSTATTRACK, "CMD_RSTATTRACK", "tracking status (0x5C)", "trimble_tracking_status", RO|DEF },
+       { CMD_RADDITFIX, "CMD_RADDITFIX", "additional fix data (0x5E)", "trimble_addfix", RO },
+       { CMD_RALLINVIEW, "CMD_RALLINVIEW", "all in view satellite selection (0x6D)", "trimble_satview", RO|DEF },
+       { CMD_RPOSFILT, "CMD_RPOSFILT", "position filter parameters (0x72)", "trimble_posfilt", RO },
+       { CMD_RHEIGHTFILT, "CMD_RHEIGHTFILT", "height filter control (0x74)", "trimble_heightfilt", RO },
+       { CMD_RHIGH8CNT, "CMD_RHIGH8CNT", "high-8 (best 4) / high-6 (overdetermined) control (0x76)", "trimble_high8control", RO },
+       { CMD_RMAXAGE, "CMD_RMAXAGE", "DC MaxAge (0x78)", "trimble_dgpsmaxage", RO },
+       { CMD_RDGPSFIX, "CMD_RDGPSFIX", "differential position fix mode (0x82)", "trimble_dgpsfixmode", RO },
+       { CMD_RDOUBLEXYZ, "CMD_RDOUBLEXYZ", "double precision XYZ (0x83)", "gps_position_ext(XYZ)", RO|DEF },
+       { CMD_RDOUBLELLA, "CMD_RDOUBLELLA", "double precision LLA (0x84)", "gps_position_ext(LLA)", RO|DEF },
+       { CMD_RDGPSSTAT, "CMD_RDGPSSTAT", "differential correction status (0x85)", "trimble_dgpsstatus", RO },
+       { CMD_RSUPER, "CMD_RSUPER", "super paket (0x8F)", "", 0 },
+       { 0xFF, "", "" }
+};
+
diff --git a/libparse/mfp_mul.c b/libparse/mfp_mul.c
new file mode 100644 (file)
index 0000000..677ed18
--- /dev/null
@@ -0,0 +1,206 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/mfp_mul.c,v 4.9 2005/07/17 20:34:40 kardel RELEASE_20050717_A
+ *
+ * mfp_mul.c,v 4.9 2005/07/17 20:34:40 kardel RELEASE_20050717_A
+ *
+ * $Created: Sat Aug 16 20:35:08 1997 $
+ *
+ * Copyright (c) 1997-2005 by Frank Kardel <kardel <AT> ntp.org>
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+#include <stdio.h>
+#include "ntp_stdlib.h"
+#include "ntp_types.h"
+#include "ntp_fp.h"
+
+#define LOW_MASK  (u_int32)((1<<(FRACTION_PREC/2))-1)
+#define HIGH_MASK (u_int32)(LOW_MASK << (FRACTION_PREC/2))
+
+/*
+ * for those who worry about overflows (possibly triggered by static analysis tools):
+ *
+ * Largest value of a 2^n bit number is 2^n-1.
+ * Thus the result is: (2^n-1)*(2^n-1) = 2^2n - 2^n - 2^n + 1 < 2^2n
+ * Here overflow can not happen for 2 reasons:
+ * 1) the code actually multiplies the absolute values of two signed
+ *    64bit quantities.thus effectively multiplying 2 63bit quantities.
+ * 2) Carry propagation is from low to high, building principle is
+ *    addition, so no storage for the 2^2n term from above is needed.
+ */
+
+void
+mfp_mul(
+       int32   *o_i,
+       u_int32 *o_f,
+       int32    a_i,
+       u_int32  a_f,
+       int32    b_i,
+       u_int32  b_f
+       )
+{
+  int32 i, j;
+  u_int32  f;
+  u_long a[4];                 /* operand a */
+  u_long b[4];                 /* operand b */
+  u_long c[5];                 /* result c - 5 items for performance - see below */
+  u_long carry;
+  
+  int neg = 0;
+
+  if (a_i < 0)                 /* examine sign situation */
+    {
+      neg = 1;
+      M_NEG(a_i, a_f);
+    }
+
+  if (b_i < 0)                 /* examine sign situation */
+    {
+      neg = !neg;
+      M_NEG(b_i, b_f);
+    }
+  
+  a[0] = a_f & LOW_MASK;       /* prepare a operand */
+  a[1] = (a_f & HIGH_MASK) >> (FRACTION_PREC/2);
+  a[2] = a_i & LOW_MASK;
+  a[3] = (a_i & HIGH_MASK) >> (FRACTION_PREC/2);
+  
+  b[0] = b_f & LOW_MASK;       /* prepare b operand */
+  b[1] = (b_f & HIGH_MASK) >> (FRACTION_PREC/2);
+  b[2] = b_i & LOW_MASK;
+  b[3] = (b_i & HIGH_MASK) >> (FRACTION_PREC/2);
+
+  c[0] = c[1] = c[2] = c[3] = c[4] = 0;
+
+  for (i = 0; i < 4; i++)      /* we do assume 32 * 32 = 64 bit multiplication */
+    for (j = 0; j < 4; j++)
+      {
+       u_long result_low, result_high;
+       int low_index = (i+j)/2;      /* formal [0..3]  - index for low long word */
+       int mid_index = 1+low_index;  /* formal [1..4]! - index for high long word
+                                        will generate unecessary add of 0 to c[4]
+                                        but save 15 'if (result_high) expressions' */
+       int high_index = 1+mid_index; /* formal [2..5]! - index for high word overflow
+                                        - only assigned on overflow (limits range to 2..3) */
+
+       result_low = (u_long)a[i] * (u_long)b[j];       /* partial product */
+
+       if ((i+j) & 1)          /* splits across two result registers */
+         {
+           result_high   = result_low >> (FRACTION_PREC/2);
+           result_low  <<= FRACTION_PREC/2;
+           carry         = (unsigned)1<<(FRACTION_PREC/2);
+         }
+       else
+         {                     /* stays in a result register - except for overflows */
+           result_high = 0;
+           carry       = 1;
+         }
+
+       if (((c[low_index] >> 1) + (result_low >> 1) + ((c[low_index] & result_low & carry) != 0)) &
+           (u_int32)((unsigned)1<<(FRACTION_PREC - 1))) {
+         result_high++;        /* propagate overflows */
+        }
+
+       c[low_index]   += result_low; /* add up partial products */
+
+       if (((c[mid_index] >> 1) + (result_high >> 1) + ((c[mid_index] & result_high & 1) != 0)) &
+           (u_int32)((unsigned)1<<(FRACTION_PREC - 1))) {
+         c[high_index]++;              /* propagate overflows of high word sum */
+        }
+
+       c[mid_index] += result_high;  /* will add a 0 to c[4] once but saves 15 if conditions */
+      }
+
+#ifdef DEBUG
+  if (debug > 6)
+    printf("mfp_mul: 0x%04lx%04lx%04lx%04lx * 0x%04lx%04lx%04lx%04lx = 0x%08lx%08lx%08lx%08lx\n",
+        a[3], a[2], a[1], a[0], b[3], b[2], b[1], b[0], c[3], c[2], c[1], c[0]);
+#endif
+
+  if (c[3])                    /* overflow */
+    {
+      i = ((unsigned)1 << (FRACTION_PREC-1)) - 1;
+      f = ~(unsigned)0;
+    }
+  else
+    {                          /* take produkt - discarding extra precision */
+      i = c[2];
+      f = c[1];
+    }
+  
+  if (neg)                     /* recover sign */
+    {
+      M_NEG(i, f);
+    }
+
+  *o_i = i;
+  *o_f = f;
+
+#ifdef DEBUG
+  if (debug > 6)
+    printf("mfp_mul: %s * %s => %s\n",
+          mfptoa((u_long)a_i, a_f, 6),
+          mfptoa((u_long)b_i, b_f, 6),
+          mfptoa((u_long)i, f, 6));
+#endif
+}
+
+/*
+ * History:
+ *
+ * mfp_mul.c,v
+ * Revision 4.9  2005/07/17 20:34:40  kardel
+ * correct carry propagation implementation
+ *
+ * Revision 4.8  2005/07/12 16:17:26  kardel
+ * add explanation why we do not write into c[4]
+ *
+ * Revision 4.7  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.6  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.3  1999/02/21 12:17:37  kardel
+ * 4.91f reconcilation
+ *
+ * Revision 4.2  1998/12/20 23:45:28  kardel
+ * fix types and warnings
+ *
+ * Revision 4.1  1998/05/24 07:59:57  kardel
+ * conditional debug support
+ *
+ * Revision 4.0  1998/04/10 19:46:38  kardel
+ * Start 4.0 release version numbering
+ *
+ * Revision 1.1  1998/04/10 19:27:47  kardel
+ * initial NTP VERSION 4 integration of PARSE with GPS166 binary support
+ *
+ * Revision 1.1  1997/10/06 21:05:46  kardel
+ * new parse structure
+ *
+ */
diff --git a/libparse/mkinfo_rcmd.sed b/libparse/mkinfo_rcmd.sed
new file mode 100644 (file)
index 0000000..570c7a0
--- /dev/null
@@ -0,0 +1,8 @@
+1i\
+\
+cmd_info_t trimble_rcmds[] = {
+s!^#define[    ][      ]*\(CMD_R[^     ]*\)[   ][      ]*\([^  ]*\)[   ][      ]*/\*[  ][      ]*\(.*\)[       ]*:\([^:]*\):\([^:]*\)[         ][      ]*\*/!  { \1, "\1", "\3 (\2)", "\4", \5 },!p
+$a\
+       { 0xFF, "", "" }\
+};\
+
diff --git a/libparse/mkinfo_scmd.sed b/libparse/mkinfo_scmd.sed
new file mode 100644 (file)
index 0000000..cabe065
--- /dev/null
@@ -0,0 +1,16 @@
+1i\
+/*\
+ * Automatically generated - do not modify\
+ */\
+\
+#include "ntp_types.h"\
+#include "ntpd.h"\
+#include "trimble.h"\
+\
+cmd_info_t trimble_scmds[] = {
+s!^#define[    ][      ]*\(CMD_C[^     ]*\)[   ][      ]*\([^  ]*\)[   ][      ]*/\*[  ][      ]*\(.*\)[       ][      ]*\*/!  { \1, "\1", "\3 (\2)", "", 0 },!p
+$a\
+       { 0xFF, "", "" }\
+};\
+
+
diff --git a/libparse/parse.c b/libparse/parse.c
new file mode 100644 (file)
index 0000000..dfbbaa6
--- /dev/null
@@ -0,0 +1,949 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/parse.c,v 4.20 2005/08/06 17:39:40 kardel RELEASE_20050806_A
+ *  
+ * parse.c,v 4.20 2005/08/06 17:39:40 kardel RELEASE_20050806_A
+ *
+ * Parser module for reference clock
+ *
+ * PARSEKERNEL define switches between two personalities of the module
+ * if PARSEKERNEL is defined this module can be used
+ * as kernel module. In this case the time stamps will be
+ * a struct timeval.
+ * when PARSEKERNEL is not defined NTP time stamps will be used.
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE)
+
+#if    !(defined(lint) || defined(__GNUC__))
+static char rcsid[] = "parse.c,v 4.20 2005/08/06 17:39:40 kardel RELEASE_20050806_A";
+#endif
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+#include "ntp_machine.h"
+#include "ntp.h"               /* (get Y2KFixes definitions)   Y2KFixes */
+
+#include "parse.h"
+
+#ifndef PARSESTREAM
+# include <stdio.h>
+#else
+# include "sys/parsestreams.h"
+#endif
+
+extern clockformat_t *clockformats[];
+extern unsigned short nformats;
+
+static u_long timepacket P((parse_t *));
+
+/*
+ * strings support usually not in kernel - duplicated, but what the heck
+ */
+static int
+Strlen(
+       register const char *s
+       )
+{
+       register int c;
+
+       c = 0;
+       if (s)
+       {
+               while (*s++)
+               {
+                       c++;
+               }
+       }
+       return c;
+}
+
+static int
+Strcmp(
+       register const char *s,
+       register const char *t
+       )
+{
+       register int c = 0;
+
+       if (!s || !t || (s == t))
+       {
+               return 0;
+       }
+
+       while (!(c = *s++ - *t++) && *s && *t)
+           /* empty loop */;
+  
+       return c;
+}
+
+int
+parse_timedout(
+              parse_t *parseio,
+              timestamp_t *tstamp,
+              struct timeval *del
+              )
+{
+       struct timeval delta;
+
+#ifdef PARSEKERNEL
+       delta.tv_sec = tstamp->tv.tv_sec - parseio->parse_lastchar.tv.tv_sec;
+       delta.tv_usec = tstamp->tv.tv_usec - parseio->parse_lastchar.tv.tv_usec;
+       if (delta.tv_usec < 0)
+       {
+               delta.tv_sec  -= 1;
+               delta.tv_usec += 1000000;
+       }
+#else
+       extern long tstouslo[];
+       extern long tstousmid[];
+       extern long tstoushi[];
+
+       l_fp delt;
+
+       delt = tstamp->fp;
+       L_SUB(&delt, &parseio->parse_lastchar.fp);
+       TSTOTV(&delt, &delta);
+#endif
+
+       if (timercmp(&delta, del, >))
+       {
+               parseprintf(DD_PARSE, ("parse: timedout: TRUE\n"));
+               return 1;
+       }
+       else
+       {
+               parseprintf(DD_PARSE, ("parse: timedout: FALSE\n"));
+               return 0;
+       }
+}
+
+/*ARGSUSED*/
+int
+parse_ioinit(
+       register parse_t *parseio
+       )
+{
+       parseprintf(DD_PARSE, ("parse_iostart\n"));
+  
+       parseio->parse_plen = 0;
+       parseio->parse_pdata = (void *)0;
+  
+       parseio->parse_data = 0;
+       parseio->parse_ldata = 0;
+       parseio->parse_dsize = 0;
+
+       parseio->parse_badformat = 0;
+       parseio->parse_ioflags   = PARSE_IO_CS7;        /* usual unix default */
+       parseio->parse_index     = 0;
+       parseio->parse_ldsize    = 0;
+  
+       return 1;
+}
+
+/*ARGSUSED*/
+void
+parse_ioend(
+       register parse_t *parseio
+       )
+{
+       parseprintf(DD_PARSE, ("parse_ioend\n"));
+
+       if (parseio->parse_pdata)
+           FREE(parseio->parse_pdata, parseio->parse_plen);
+
+       if (parseio->parse_data)
+           FREE(parseio->parse_data, (unsigned)(parseio->parse_dsize * 2 + 2));
+}
+
+unsigned int
+parse_restart(
+             parse_t *parseio,
+             unsigned int ch
+             )
+{
+       unsigned int updated = PARSE_INP_SKIP;
+       
+       /*
+        * re-start packet - timeout - overflow - start symbol
+        */
+       
+       if (parseio->parse_index)
+       {
+               /*
+                * filled buffer - thus not end character found
+                * do processing now
+                */
+               parseio->parse_data[parseio->parse_index] = '\0';
+               memcpy(parseio->parse_ldata, parseio->parse_data, (unsigned)(parseio->parse_index+1));
+               parseio->parse_ldsize = parseio->parse_index;
+               updated = PARSE_INP_TIME;
+       }
+               
+       parseio->parse_index = 1;
+       parseio->parse_data[0] = ch;
+       parseprintf(DD_PARSE, ("parse: parse_restart: buffer start (updated = %x)\n", updated));
+       return updated;
+}
+       
+unsigned int
+parse_addchar(
+             parse_t *parseio,
+             unsigned int ch
+             )
+{
+       /*
+        * add to buffer
+        */
+       if (parseio->parse_index < parseio->parse_dsize)
+       {
+               /*
+                * collect into buffer
+                */
+               parseprintf(DD_PARSE, ("parse: parse_addchar: buffer[%d] = 0x%x\n", parseio->parse_index, ch));
+               parseio->parse_data[parseio->parse_index++] = ch;
+               return PARSE_INP_SKIP;
+       }
+       else
+               /*
+                * buffer overflow - attempt to make the best of it
+                */
+               return parse_restart(parseio, ch);
+}
+       
+unsigned int
+parse_end(
+         parse_t *parseio
+         )
+{
+       /*
+        * message complete processing
+        */
+       parseio->parse_data[parseio->parse_index] = '\0';
+       memcpy(parseio->parse_ldata, parseio->parse_data, (unsigned)(parseio->parse_index+1));
+       parseio->parse_ldsize = parseio->parse_index;
+       parseio->parse_index = 0;
+       parseprintf(DD_PARSE, ("parse: parse_end: buffer end\n"));
+       return PARSE_INP_TIME;
+}
+
+/*ARGSUSED*/
+int
+parse_ioread(
+       register parse_t *parseio,
+       register unsigned int ch,
+       register timestamp_t *tstamp
+       )
+{
+       register unsigned updated = CVT_NONE;
+       /*
+        * within STREAMS CSx (x < 8) chars still have the upper bits set
+        * so we normalize the characters by masking unecessary bits off.
+        */
+       switch (parseio->parse_ioflags & PARSE_IO_CSIZE)
+       {
+           case PARSE_IO_CS5:
+               ch &= 0x1F;
+               break;
+
+           case PARSE_IO_CS6:
+               ch &= 0x3F;
+               break;
+
+           case PARSE_IO_CS7:
+               ch &= 0x7F;
+               break;
+      
+           case PARSE_IO_CS8:
+               ch &= 0xFF;
+               break;
+       }
+
+       parseprintf(DD_PARSE, ("parse_ioread(0x%lx, char=0x%x, ..., ...)\n", (unsigned long)parseio, ch & 0xFF));
+
+       if (!clockformats[parseio->parse_lformat]->convert)
+       {
+               parseprintf(DD_PARSE, ("parse_ioread: input dropped.\n"));
+               return CVT_NONE;
+       }
+
+       if (clockformats[parseio->parse_lformat]->input)
+       {
+               unsigned long input_status;
+
+               input_status = clockformats[parseio->parse_lformat]->input(parseio, ch, tstamp);
+
+               if (input_status & PARSE_INP_SYNTH)
+               {
+                       updated = CVT_OK;
+               }
+               
+               if (input_status & PARSE_INP_TIME)      /* time sample is available */
+               {
+                       updated = timepacket(parseio);
+               }
+                 
+               if (input_status & PARSE_INP_DATA) /* got additional data */
+               {
+                       updated |= CVT_ADDITIONAL;
+               }
+       }
+       
+
+       /*
+        * remember last character time
+        */
+       parseio->parse_lastchar = *tstamp;
+
+#ifdef DEBUG
+       if ((updated & CVT_MASK) != CVT_NONE)
+       {
+               parseprintf(DD_PARSE, ("parse_ioread: time sample accumulated (status=0x%x)\n", updated));
+       }
+#endif
+
+       parseio->parse_dtime.parse_status = updated;
+
+       return (((updated & CVT_MASK) != CVT_NONE) ||
+               ((updated & CVT_ADDITIONAL) != 0));
+}
+
+/*
+ * parse_iopps
+ *
+ * take status line indication and derive synchronisation information
+ * from it.
+ * It can also be used to decode a serial serial data format (such as the
+ * ONE, ZERO, MINUTE sync data stream from DCF77)
+ */
+/*ARGSUSED*/
+int
+parse_iopps(
+       register parse_t *parseio,
+       register int status,
+       register timestamp_t *ptime
+       )
+{
+       register unsigned updated = CVT_NONE;
+
+       /*
+        * PPS pulse information will only be delivered to ONE clock format
+        * this is either the last successful conversion module with a ppssync
+        * routine, or a fixed format with a ppssync routine
+        */
+       parseprintf(DD_PARSE, ("parse_iopps: STATUS %s\n", (status == SYNC_ONE) ? "ONE" : "ZERO"));
+
+       if (clockformats[parseio->parse_lformat]->syncpps)
+       {
+               updated = clockformats[parseio->parse_lformat]->syncpps(parseio, status == SYNC_ONE, ptime);
+               parseprintf(DD_PARSE, ("parse_iopps: updated = 0x%x\n", updated));
+       }
+
+       return (updated & CVT_MASK) != CVT_NONE;
+}
+
+/*
+ * parse_iodone
+ *
+ * clean up internal status for new round
+ */
+/*ARGSUSED*/
+void
+parse_iodone(
+       register parse_t *parseio
+       )
+{
+       /*
+        * we need to clean up certain flags for the next round
+        */
+       parseprintf(DD_PARSE, ("parse_iodone: DONE\n"));
+       parseio->parse_dtime.parse_state = 0; /* no problems with ISRs */
+}
+
+/*---------- conversion implementation --------------------*/
+
+/*
+ * convert a struct clock to UTC since Jan, 1st 1970 0:00 (the UNIX EPOCH)
+ */
+#define days_per_year(x)       ((x) % 4 ? 365 : ((x % 400) ? ((x % 100) ? 366 : 365) : 366))
+
+time_t
+parse_to_unixtime(
+       register clocktime_t   *clock_time,
+       register u_long *cvtrtc
+       )
+{
+#define SETRTC(_X_)    { if (cvtrtc) *cvtrtc = (_X_); }
+       static int days_of_month[] = 
+       {
+               0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+       };
+       register int i;
+       time_t t;
+  
+       if (clock_time->utctime)
+           return clock_time->utctime; /* if the conversion routine gets it right away - why not */
+
+       if ( clock_time->year < YEAR_PIVOT )                    /* Y2KFixes [ */
+           clock_time->year += 100;    /* convert 20xx%100 to 20xx-1900 */
+       if ( clock_time->year < YEAR_BREAK )    /* expand to full four-digits */
+           clock_time->year += 1900;
+
+       if (clock_time->year < 1970 )                           /* Y2KFixes ] */
+       {
+               SETRTC(CVT_FAIL|CVT_BADDATE);
+               return -1;
+       }
+  
+       /*
+        * sorry, slow section here - but it's not time critical anyway
+        */
+       t = julian0(clock_time->year) - julian0(1970);          /* Y2kFixes */
+                               /* month */
+       if (clock_time->month <= 0 || clock_time->month > 12)
+       {
+               SETRTC(CVT_FAIL|CVT_BADDATE);
+               return -1;              /* bad month */
+       }
+
+#if 0                                                          /* Y2KFixes */
+                               /* adjust leap year */
+       if (clock_time->month < 3 && days_per_year(clock_time->year) == 366)
+           t--;
+#else                                                          /* Y2KFixes [ */
+       if ( clock_time->month >= 3  &&  isleap_4(clock_time->year) )
+           t++;                /* add one more if within leap year */
+#endif                                                         /* Y2KFixes ] */
+
+       for (i = 1; i < clock_time->month; i++)
+       {
+               t += days_of_month[i];
+       }
+                               /* day */
+       if (clock_time->day < 1 || ((clock_time->month == 2 && days_per_year(clock_time->year) == 366) ?
+                              clock_time->day > 29 : clock_time->day > days_of_month[clock_time->month]))
+       {
+               SETRTC(CVT_FAIL|CVT_BADDATE);
+               return -1;              /* bad day */
+       }
+
+       t += clock_time->day - 1;
+                               /* hour */
+       if (clock_time->hour < 0 || clock_time->hour >= 24)
+       {
+               SETRTC(CVT_FAIL|CVT_BADTIME);
+               return -1;              /* bad hour */
+       }
+
+       t = TIMES24(t) + clock_time->hour;
+
+                               /* min */
+       if (clock_time->minute < 0 || clock_time->minute > 59)
+       {
+               SETRTC(CVT_FAIL|CVT_BADTIME);
+               return -1;              /* bad min */
+       }
+
+       t = TIMES60(t) + clock_time->minute;
+                               /* sec */
+  
+       if (clock_time->second < 0 || clock_time->second > 60)  /* allow for LEAPs */
+       {
+               SETRTC(CVT_FAIL|CVT_BADTIME);
+               return -1;              /* bad sec */
+       }
+
+       t  = TIMES60(t) + clock_time->second;
+
+       t += clock_time->utcoffset;     /* warp to UTC */
+
+                               /* done */
+
+       clock_time->utctime = t;                /* documentray only */
+
+       return t;
+}
+
+/*--------------- format conversion -----------------------------------*/
+
+int
+Stoi(
+       const unsigned char *s,
+       long *zp,
+       int cnt
+       )
+{
+       char unsigned const *b = s;
+       int f,z,v;
+       char unsigned c;
+
+       f=z=v=0;
+
+       while(*s == ' ')
+           s++;
+  
+       if (*s == '-')
+       {
+               s++;
+               v = 1;
+       }
+       else
+           if (*s == '+')
+               s++;
+  
+       for(;;)
+       {
+               c = *s++;
+               if (c == '\0' || c < '0' || c > '9' || (cnt && ((s-b) > cnt)))
+               {
+                       if (f == 0)
+                       {
+                               return(-1);
+                       }
+                       if (v)
+                           z = -z;
+                       *zp = z;
+                       return(0);
+               }
+               z = (z << 3) + (z << 1) + ( c - '0' );
+               f=1;
+       }
+}
+
+int
+Strok(
+       const unsigned char *s,
+       const unsigned char *m
+       )
+{
+       if (!s || !m)
+           return 0;
+
+       while(*s && *m)
+       {
+               if ((*m == ' ') ? 1 : (*s == *m))
+               {
+                       s++;
+                       m++;
+               }
+               else
+               {
+                       return 0;
+               }
+       }
+       return !*m;
+}
+
+u_long
+updatetimeinfo(
+              register parse_t *parseio,
+              register u_long   flags
+              )
+{
+#ifdef PARSEKERNEL
+       {
+               int s = splhigh();
+#endif
+  
+               parseio->parse_lstate          = parseio->parse_dtime.parse_state | flags | PARSEB_TIMECODE;
+    
+               parseio->parse_dtime.parse_state = parseio->parse_lstate;
+
+#ifdef PARSEKERNEL
+               (void)splx((unsigned int)s);
+       }
+#endif
+  
+
+#ifdef PARSEKERNEL
+       parseprintf(DD_PARSE, ("updatetimeinfo status=0x%x, time=%x\n", parseio->parse_dtime.parse_state,
+                              parseio->parse_dtime.parse_time.tv.tv_sec));
+#else
+       parseprintf(DD_PARSE, ("updatetimeinfo status=0x%lx, time=%x\n", (long)parseio->parse_dtime.parse_state,
+                              parseio->parse_dtime.parse_time.fp.l_ui));
+#endif
+       
+       return CVT_OK;          /* everything fine and dandy... */
+}
+
+
+/*
+ * syn_simple
+ *
+ * handle a sync time stamp
+ */
+/*ARGSUSED*/
+void
+syn_simple(
+       register parse_t *parseio,
+       register timestamp_t *ts,
+       register struct format *format,
+       register u_long why
+       )
+{
+       parseio->parse_dtime.parse_stime = *ts;
+}
+
+/*
+ * pps_simple
+ *
+ * handle a pps time stamp
+ */
+/*ARGSUSED*/
+u_long
+pps_simple(
+       register parse_t *parseio,
+       register int status,
+       register timestamp_t *ptime
+       )
+{
+       parseio->parse_dtime.parse_ptime  = *ptime;
+       parseio->parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
+  
+       return CVT_NONE;
+}
+
+/*
+ * pps_one
+ *
+ * handle a pps time stamp in ONE edge
+ */
+/*ARGSUSED*/
+u_long
+pps_one(
+       register parse_t *parseio,
+       register int status,
+       register timestamp_t *ptime
+       )
+{
+       if (status)
+               return pps_simple(parseio, status, ptime);
+       
+       return CVT_NONE;
+}
+
+/*
+ * pps_zero
+ *
+ * handle a pps time stamp in ZERO edge
+ */
+/*ARGSUSED*/
+u_long
+pps_zero(
+       register parse_t *parseio,
+       register int status,
+       register timestamp_t *ptime
+       )
+{
+       if (!status)
+               return pps_simple(parseio, status, ptime);
+       
+       return CVT_NONE;
+}
+
+/*
+ * timepacket
+ *
+ * process a data packet
+ */
+static u_long
+timepacket(
+       register parse_t *parseio
+       )
+{
+       register unsigned short format;
+       register time_t t;
+       u_long cvtrtc;          /* current conversion result */
+       clocktime_t clock_time;
+  
+       memset((char *)&clock_time, 0, sizeof clock_time);
+       format = parseio->parse_lformat;
+
+       if (format == (unsigned short)~0)
+               return CVT_NONE;
+       
+       switch ((cvtrtc = clockformats[format]->convert ?
+                clockformats[format]->convert((unsigned char *)parseio->parse_ldata, parseio->parse_ldsize, (struct format *)(clockformats[format]->data), &clock_time, parseio->parse_pdata) :
+                CVT_NONE) & CVT_MASK)
+       {
+       case CVT_FAIL:
+               parseio->parse_badformat++;
+               break;
+               
+       case CVT_NONE:
+               /*
+                * too bad - pretend bad format
+                */
+               parseio->parse_badformat++;
+               break;
+               
+       case CVT_OK:
+               break;
+               
+       case CVT_SKIP:
+               return CVT_NONE;
+
+       default:
+               /* shouldn't happen */
+#ifndef PARSEKERNEL
+               msyslog(LOG_WARNING, "parse: INTERNAL error: bad return code of convert routine \"%s\"\n", clockformats[format]->name);
+#endif   
+               return CVT_FAIL|cvtrtc;
+       }
+
+       if ((t = parse_to_unixtime(&clock_time, &cvtrtc)) == -1)
+       {
+               return CVT_FAIL|cvtrtc;
+       }
+  
+       /*
+        * time stamp
+        */
+#ifdef PARSEKERNEL
+       parseio->parse_dtime.parse_time.tv.tv_sec  = t;
+       parseio->parse_dtime.parse_time.tv.tv_usec = clock_time.usecond;
+#else
+       parseio->parse_dtime.parse_time.fp.l_ui = t + JAN_1970;
+       TVUTOTSF(clock_time.usecond, parseio->parse_dtime.parse_time.fp.l_uf);
+#endif
+
+       parseio->parse_dtime.parse_format       = format;
+
+       return updatetimeinfo(parseio, clock_time.flags);
+}
+
+/*ARGSUSED*/
+int
+parse_timecode(
+       parsectl_t *dct,
+       parse_t    *parse
+       )
+{
+       dct->parsegettc.parse_state  = parse->parse_lstate;
+       dct->parsegettc.parse_format = parse->parse_lformat;
+       /*
+        * move out current bad packet count
+        * user program is expected to sum these up
+        * this is not a problem, as "parse" module are
+        * exclusive open only
+        */
+       dct->parsegettc.parse_badformat = parse->parse_badformat;
+       parse->parse_badformat = 0;
+                 
+       if (parse->parse_ldsize <= PARSE_TCMAX)
+       {
+               dct->parsegettc.parse_count = parse->parse_ldsize;
+               memcpy(dct->parsegettc.parse_buffer, parse->parse_ldata, dct->parsegettc.parse_count);
+               return 1;
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+                 
+/*ARGSUSED*/
+int
+parse_setfmt(
+       parsectl_t *dct,
+       parse_t    *parse
+       )
+{
+       if (dct->parseformat.parse_count <= PARSE_TCMAX)
+       {
+               if (dct->parseformat.parse_count)
+               {
+                       register unsigned short i;
+
+                       for (i = 0; i < nformats; i++)
+                       {
+                               if (!Strcmp(dct->parseformat.parse_buffer, clockformats[i]->name))
+                               {
+                                       if (parse->parse_pdata)
+                                               FREE(parse->parse_pdata, parse->parse_plen);
+                                       parse->parse_pdata = 0;
+                                       
+                                       parse->parse_plen = clockformats[i]->plen;
+
+                                       if (parse->parse_plen)
+                                       {
+                                               parse->parse_pdata = MALLOC(parse->parse_plen);
+                                               if (!parse->parse_pdata)
+                                               {
+                                                       parseprintf(DD_PARSE, ("set format failed: malloc for private data area failed\n"));
+                                                       return 0;
+                                               }
+                                               memset((char *)parse->parse_pdata, 0, parse->parse_plen);
+                                       }
+
+                                       if (parse->parse_data)
+                                               FREE(parse->parse_data, (unsigned)(parse->parse_dsize * 2 + 2));
+                                       parse->parse_ldata = parse->parse_data = 0;
+                                       
+                                       parse->parse_dsize = clockformats[i]->length;
+                                       
+                                       if (parse->parse_dsize)
+                                       {
+                                               parse->parse_data = (char*)MALLOC((unsigned)(parse->parse_dsize * 2 + 2));
+                                               if (!parse->parse_data)
+                                               {
+                                                       if (parse->parse_pdata)
+                                                               FREE(parse->parse_pdata, parse->parse_plen);
+                                                       parse->parse_pdata = 0;
+                                                       
+                                                       parseprintf(DD_PARSE, ("init failed: malloc for data area failed\n"));
+                                                       return 0;
+                                               }
+                                       }
+                                       
+
+                                       /*
+                                        * leave room for '\0'
+                                        */
+                                       parse->parse_ldata     = parse->parse_data + parse->parse_dsize + 1;
+                                       
+                                       parse->parse_lformat  = i;
+                                       
+                                       return 1;
+                               }
+                       }
+               }
+       }
+       return 0;
+}
+
+/*ARGSUSED*/
+int
+parse_getfmt(
+       parsectl_t *dct,
+       parse_t    *parse
+       )
+{
+       if (dct->parseformat.parse_format < nformats &&
+           Strlen(clockformats[dct->parseformat.parse_format]->name) <= PARSE_TCMAX)
+       {
+               dct->parseformat.parse_count = Strlen(clockformats[dct->parseformat.parse_format]->name)+1;
+               memcpy(dct->parseformat.parse_buffer, clockformats[dct->parseformat.parse_format]->name, dct->parseformat.parse_count);
+               return 1;
+       }
+       else
+       {
+               return 0;
+       }
+}
+
+/*ARGSUSED*/
+int
+parse_setcs(
+       parsectl_t *dct,
+       parse_t    *parse
+       )
+{
+       parse->parse_ioflags &= ~PARSE_IO_CSIZE;
+       parse->parse_ioflags |= dct->parsesetcs.parse_cs & PARSE_IO_CSIZE;
+       return 1;
+}
+
+#else /* not (REFCLOCK && CLOCK_PARSE) */
+int parse_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE) */
+
+/*
+ * History:
+ *
+ * parse.c,v
+ * Revision 4.20  2005/08/06 17:39:40  kardel
+ * cleanup size handling wrt/ to buffer boundaries
+ *
+ * Revision 4.19  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.18  2004/11/14 16:11:05  kardel
+ * update Id tags
+ *
+ * Revision 4.17  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.14  1999/11/28 09:13:52  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.13  1999/02/28 11:50:20  kardel
+ * (timepacket): removed unecessary code
+ *
+ * Revision 4.12  1999/02/21 12:17:44  kardel
+ * 4.91f reconcilation
+ *
+ * Revision 4.11  1999/02/21 11:09:47  kardel
+ * unified debug output
+ *
+ * Revision 4.10  1998/12/20 23:45:30  kardel
+ * fix types and warnings
+ *
+ * Revision 4.9  1998/08/09 22:26:06  kardel
+ * Trimble TSIP support
+ *
+ * Revision 4.8  1998/06/14 21:09:39  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.7  1998/06/13 15:19:13  kardel
+ * fix mem*() to b*() function macro emulation
+ *
+ * Revision 4.6  1998/06/13 13:24:13  kardel
+ * printf fmt
+ *
+ * Revision 4.5  1998/06/13 13:01:10  kardel
+ * printf fmt
+ *
+ * Revision 4.4  1998/06/13 12:12:10  kardel
+ * bcopy/memcpy cleanup
+ * fix SVSV name clash
+ *
+ * Revision 4.3  1998/06/12 15:22:30  kardel
+ * fix prototypes
+ *
+ * Revision 4.2  1998/06/12 09:13:27  kardel
+ * conditional compile macros fixed
+ * printf prototype
+ *
+ * Revision 4.1  1998/05/24 09:39:55  kardel
+ * implementation of the new IO handling model
+ *
+ * Revision 4.0  1998/04/10 19:45:36  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 3.46 log info deleted 1998/04/11 kardel
+ */
diff --git a/libparse/parse_conf.c b/libparse/parse_conf.c
new file mode 100644 (file)
index 0000000..b5451cf
--- /dev/null
@@ -0,0 +1,175 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/parse_conf.c,v 4.9 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *  
+ * parse_conf.c,v 4.9 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * Parser configuration module for reference clocks
+ *
+ * STREAM define switches between two personalities of the module
+ * if STREAM is defined this module can be used with dcf77sync.c as
+ * a STREAMS kernel module. In this case the time stamps will be
+ * a struct timeval.
+ * when STREAM is not defined NTP time stamps will be used.
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE)
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include "parse.h"
+
+#ifdef CLOCK_SCHMID
+extern clockformat_t clock_schmid;
+#endif
+
+#ifdef CLOCK_DCF7000
+extern clockformat_t clock_dcf7000;
+#endif
+
+#ifdef CLOCK_MEINBERG
+extern clockformat_t clock_meinberg[];
+#endif
+
+#ifdef CLOCK_RAWDCF
+extern clockformat_t clock_rawdcf;
+#endif
+
+#ifdef CLOCK_TRIMTAIP
+extern clockformat_t clock_trimtaip;
+#endif
+
+#ifdef CLOCK_TRIMTSIP
+extern clockformat_t clock_trimtsip;
+#endif
+
+#ifdef CLOCK_RCC8000
+extern clockformat_t clock_rcc8000;
+#endif
+
+#ifdef CLOCK_HOPF6021
+extern clockformat_t clock_hopf6021;
+#endif
+
+#ifdef CLOCK_COMPUTIME
+extern clockformat_t clock_computime;
+#endif
+
+#ifdef CLOCK_WHARTON_400A
+extern clockformat_t clock_wharton_400a;
+#endif
+
+#ifdef CLOCK_VARITEXT
+extern clockformat_t clock_varitext;
+#endif
+
+/*
+ * format definitions
+ */
+clockformat_t *clockformats[] =
+{
+#ifdef CLOCK_MEINBERG
+       &clock_meinberg[0],
+       &clock_meinberg[1],
+       &clock_meinberg[2],
+#endif
+#ifdef CLOCK_DCF7000
+       &clock_dcf7000,
+#endif
+#ifdef CLOCK_SCHMID
+       &clock_schmid,
+#endif
+#ifdef CLOCK_RAWDCF
+       &clock_rawdcf,
+#endif
+#ifdef CLOCK_TRIMTAIP
+       &clock_trimtaip,
+#endif
+#ifdef CLOCK_TRIMTSIP
+       &clock_trimtsip,
+#endif
+#ifdef CLOCK_RCC8000
+       &clock_rcc8000,
+#endif
+#ifdef CLOCK_HOPF6021
+       &clock_hopf6021,
+#endif
+#ifdef CLOCK_COMPUTIME
+       &clock_computime,
+#endif
+#ifdef CLOCK_WHARTON_400A
+       &clock_wharton_400a,
+#endif
+#ifdef CLOCK_VARITEXT
+        &clock_varitext,
+#endif
+       0};
+
+unsigned short nformats = sizeof(clockformats) / sizeof(clockformats[0]) - 1;
+
+#else /* not (REFCLOCK && CLOCK_PARSE) */
+int parse_conf_bs;
+#endif /* not (REFCLOCK && CLOCK_PARSE) */
+
+/*
+ * History:
+ *
+ * parse_conf.c,v
+ * Revision 4.9  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.8  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.5  1999/11/28 09:13:53  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.4  1999/02/28 15:27:25  kardel
+ * wharton clock integration
+ *
+ * Revision 4.3  1998/08/16 18:52:15  kardel
+ * (clockformats): Trimble TSIP driver now also
+ * available for kernel operation
+ *
+ * Revision 4.2  1998/06/12 09:13:48  kardel
+ * conditional compile macros fixed
+ *
+ * Revision 4.1  1998/05/24 09:40:49  kardel
+ * adjustments of log messages
+ *
+ *
+ * from V3 3.24 log info deleted 1998/04/11 kardel
+ */
diff --git a/libparse/parsesolaris.c b/libparse/parsesolaris.c
new file mode 100644 (file)
index 0000000..c023ad8
--- /dev/null
@@ -0,0 +1,1200 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/parsesolaris.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *  
+ * parsesolaris.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * STREAMS module for reference clocks
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#define _KERNEL                        /* it is a _KERNEL module */
+
+#ifndef lint
+static char rcsid[] = "parsesolaris.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A";
+#endif
+
+#include <sys/types.h>
+#include <sys/conf.h>
+#include <sys/errno.h>
+#include <sys/time.h>
+#include <sys/termios.h>
+#include <sys/stream.h>
+#include <sys/strtty.h>
+#include <sys/stropts.h>
+#include <sys/modctl.h>
+#include <sys/ddi.h>
+#include <sys/sunddi.h>
+#ifdef __GNUC__ /* makes it compile on Solaris 2.6 - acc doesn't like it -- GREAT! */
+#include <stdarg.h>
+#endif
+
+#include "ntp_fp.h"
+#include "parse.h"
+#include <sys/parsestreams.h>
+
+/*--------------- loadable driver section -----------------------------*/
+
+static struct streamtab parseinfo;
+
+static struct fmodsw fmod_templ =
+{
+       "parse",                        /* module name */
+       &parseinfo,                     /* module information */
+       D_NEW|D_MP|D_MTQPAIR,           /* exclusive for q pair */
+       /* lock ptr */
+};
+
+extern struct mod_ops mod_strmodops;
+
+static struct modlstrmod modlstrmod = 
+{
+       &mod_strmodops,         /* a STREAMS module */
+       "PARSE      - NTP reference",   /* name this baby - keep room for revision number */
+       &fmod_templ
+};
+
+static struct modlinkage modlinkage =
+{
+       MODREV_1,
+       {
+               &modlstrmod,
+               NULL
+       }
+};
+
+/*
+ * module management routines
+ */
+/*ARGSUSED*/
+int
+_init(
+     void
+     )
+{
+       static char revision[] = "4.6";
+       char *s, *S; 
+       char *t;
+  
+#ifndef lint
+       t = rcsid;
+#endif
+       
+       /*
+        * copy RCS revision into Drv_name
+        *
+        * are we forcing RCS here to do things it was not built for ?
+        */
+       s = revision;
+       if (*s == '$')
+       {
+               /*
+                * skip "$Revision: "
+                * if present. - not necessary on a -kv co (cvs export)
+                */
+               while (*s && (*s != ' '))
+               {
+                       s++;
+               }
+               if (*s == ' ') s++;
+       }
+         
+       t = modlstrmod.strmod_linkinfo; 
+       while (*t && (*t != ' '))
+       {
+               t++;
+       }
+       if (*t == ' ') t++;
+         
+       S = s;
+       while (*S && (((*S >= '0') && (*S <= '9')) || (*S == '.')))
+       {
+               S++;
+       }
+         
+       if (*s && *t && (S > s))
+       {
+               if (strlen(t) >= (S - s))
+               {
+                       (void) strncpy(t, s, (unsigned)(S - s));
+               }
+       }
+       return (mod_install(&modlinkage));
+}
+
+/*ARGSUSED*/
+int
+_info(
+      struct modinfo *modinfop
+      )
+{
+       return (mod_info(&modlinkage, modinfop));
+}
+
+/*ARGSUSED*/
+int
+_fini(
+      void
+      )
+{
+       if (mod_remove(&modlinkage) != DDI_SUCCESS)
+       {
+               return EBUSY;
+       }
+       else
+           return DDI_SUCCESS;
+}
+
+/*--------------- stream module definition ----------------------------*/
+
+static int parseopen  P((queue_t *, dev_t *, int, int, cred_t *));
+static int parseclose P((queue_t *, int));
+static int parsewput  P((queue_t *, mblk_t *));
+static int parserput  P((queue_t *, mblk_t *));
+static int parsersvc  P((queue_t *));
+
+static struct module_info driverinfo =
+{
+       0,                              /* module ID number */
+       fmod_templ.f_name,              /* module name - why repeated here ? compat ?*/
+       0,                              /* minimum accepted packet size */
+       INFPSZ,                         /* maximum accepted packet size */
+       1,                              /* high water mark - flow control */
+       0                               /* low water mark - flow control */
+};
+
+static struct qinit rinit =    /* read queue definition */
+{
+       parserput,                      /* put procedure */
+       parsersvc,                      /* service procedure */
+       parseopen,                      /* open procedure */
+       parseclose,                     /* close procedure */
+       NULL,                           /* admin procedure - NOT USED FOR NOW */
+       &driverinfo,                    /* information structure */
+       NULL                            /* statistics */
+};
+
+static struct qinit winit =    /* write queue definition */
+{
+       parsewput,                      /* put procedure */
+       NULL,                           /* service procedure */
+       NULL,                           /* open procedure */
+       NULL,                           /* close procedure */
+       NULL,                           /* admin procedure - NOT USED FOR NOW */
+       &driverinfo,                    /* information structure */
+       NULL                            /* statistics */
+};
+
+static struct streamtab parseinfo =    /* stream info element for parse driver */
+{
+       &rinit,                 /* read queue */
+       &winit,                 /* write queue */
+       NULL,                           /* read mux */
+       NULL                            /* write mux */
+};
+
+/*--------------- driver data structures ----------------------------*/
+
+/*
+ * we usually have an inverted signal - but you
+ * can change this to suit your needs
+ */
+int cd_invert = 1;             /* invert status of CD line - PPS support via CD input */
+
+#ifdef PARSEDEBUG
+int parsedebug = ~0;
+#else
+int parsedebug = 0;
+#endif
+
+/*--------------- module implementation -----------------------------*/
+
+#define TIMEVAL_USADD(_X_, _US_) do {\
+       (_X_)->tv_usec += (_US_);\
+       if ((_X_)->tv_usec >= 1000000)\
+       {\
+           (_X_)->tv_sec++;\
+           (_X_)->tv_usec -= 1000000;\
+       }\
+     } while (0)
+
+static int init_linemon P((queue_t *));
+static void close_linemon P((queue_t *, queue_t *));
+
+#define M_PARSE                0x0001
+#define M_NOPARSE      0x0002
+
+void
+ntp_memset(
+       char *a,
+       int x,
+       int c
+       )
+{
+       while (c-- > 0)
+           *a++ = x;
+}
+
+static void
+pprintf(
+       int lev,
+       const char *form,
+       ...
+       )
+{
+       va_list ap;
+
+       va_start(ap, form);
+
+       if (lev & parsedebug)
+           vcmn_err(CE_CONT, (char *)form, ap);
+
+       va_end(ap);
+}
+
+static int
+setup_stream(
+            queue_t *q,
+            int mode
+            )
+{
+       register mblk_t *mp;
+
+       pprintf(DD_OPEN,"parse: SETUP_STREAM - setting up stream for q=%x\n", q);
+
+       mp = allocb(sizeof(struct stroptions), BPRI_MED);
+       if (mp)
+       {
+               struct stroptions *str = (struct stroptions *)mp->b_wptr;
+
+               str->so_flags   = SO_READOPT|SO_HIWAT|SO_LOWAT|SO_ISNTTY;
+               str->so_readopt = (mode == M_PARSE) ? RMSGD : RNORM;
+               str->so_hiwat   = (mode == M_PARSE) ? sizeof(parsetime_t) : 256;
+               str->so_lowat   = 0;
+               mp->b_datap->db_type = M_SETOPTS;
+               mp->b_wptr     += sizeof(struct stroptions);
+               if (!q)
+                   panic("NULL q - strange");
+               putnext(q, mp);
+               return putctl1(WR(q)->q_next, M_CTL, (mode == M_PARSE) ? MC_SERVICEIMM :
+                              MC_SERVICEDEF);
+       }
+       else
+       {
+               pprintf(DD_OPEN, "parse: setup_stream - FAILED - no MEMORY for allocb\n"); 
+               return 0;
+       }
+}
+
+/*ARGSUSED*/
+static int
+parseopen(
+         queue_t *q,
+         dev_t *dev,
+         int flag,
+         int sflag,
+         cred_t *credp
+         )
+{
+       register parsestream_t *parse;
+       static int notice = 0;
+  
+       pprintf(DD_OPEN, "parse: OPEN - q=%x\n", q); 
+  
+       if (sflag != MODOPEN)
+       {                       /* open only for modules */
+               pprintf(DD_OPEN, "parse: OPEN - FAILED - not MODOPEN\n"); 
+               return EIO;
+       }
+
+       if (q->q_ptr != (caddr_t)NULL)
+       {
+               pprintf(DD_OPEN, "parse: OPEN - FAILED - EXCLUSIVE ONLY\n"); 
+               return EBUSY;
+       }
+
+       q->q_ptr = (caddr_t)kmem_alloc(sizeof(parsestream_t), KM_SLEEP);
+       if (q->q_ptr == (caddr_t)0)
+       {
+               return ENOMEM;
+       }
+
+       pprintf(DD_OPEN, "parse: OPEN - parse area q=%x, q->q_ptr=%x\n", q, q->q_ptr); 
+       WR(q)->q_ptr = q->q_ptr;
+       pprintf(DD_OPEN, "parse: OPEN - WQ parse area q=%x, q->q_ptr=%x\n", WR(q), WR(q)->q_ptr); 
+  
+       parse = (parsestream_t *) q->q_ptr;
+       bzero((caddr_t)parse, sizeof(*parse));
+       parse->parse_queue     = q;
+       parse->parse_status    = PARSE_ENABLE;
+       parse->parse_ppsclockev.tv.tv_sec  = 0;
+       parse->parse_ppsclockev.tv.tv_usec = 0;
+       parse->parse_ppsclockev.serial     = 0;
+
+       qprocson(q);
+
+       pprintf(DD_OPEN, "parse: OPEN - initializing io subsystem q=%x\n", q); 
+
+       if (!parse_ioinit(&parse->parse_io))
+       {
+               /*
+                * ok guys - beat it
+                */
+               qprocsoff(q);
+
+               kmem_free((caddr_t)parse, sizeof(parsestream_t));
+
+               return EIO;
+       }
+
+       pprintf(DD_OPEN, "parse: OPEN - initializing stream q=%x\n", q); 
+
+       if (setup_stream(q, M_PARSE))
+       {
+               (void) init_linemon(q); /* hook up PPS ISR routines if possible */
+               pprintf(DD_OPEN, "parse: OPEN - SUCCEEDED\n"); 
+
+               /*
+                * I know that you know the delete key, but you didn't write this
+                * code, did you ? - So, keep the message in here.
+                */
+               if (!notice)
+               {
+                 cmn_err(CE_CONT, "?%s: Copyright (c) 1993-2005, Frank Kardel\n", modlstrmod.strmod_linkinfo);
+                       notice = 1;
+               }
+
+               return 0;
+       }
+       else
+       {
+               qprocsoff(q);
+
+               kmem_free((caddr_t)parse, sizeof(parsestream_t));
+
+               return EIO;
+       }
+}
+
+/*ARGSUSED*/
+static int
+parseclose(
+          queue_t *q,
+          int flags
+          )
+{
+       register parsestream_t *parse = (parsestream_t *)q->q_ptr;
+       register unsigned long s;
+  
+       pprintf(DD_CLOSE, "parse: CLOSE\n");
+  
+       qprocsoff(q);
+
+       s = splhigh();
+  
+       if (parse->parse_dqueue)
+           close_linemon(parse->parse_dqueue, q);
+       parse->parse_dqueue = (queue_t *)0;
+
+       (void) splx(s);
+      
+       parse_ioend(&parse->parse_io);
+
+       kmem_free((caddr_t)parse, sizeof(parsestream_t));
+
+       q->q_ptr = (caddr_t)NULL;
+       WR(q)->q_ptr = (caddr_t)NULL;
+
+       return 0;
+}
+
+/*
+ * move unrecognized stuff upward
+ */
+static int
+parsersvc(
+         queue_t *q
+         )
+{
+       mblk_t *mp;
+  
+       while ((mp = getq(q)))
+       {
+               if (canputnext(q) || (mp->b_datap->db_type > QPCTL))
+               {
+                       putnext(q, mp);
+                       pprintf(DD_RSVC, "parse: RSVC - putnext\n");
+               }
+               else
+               {
+                       putbq(q, mp);
+                       pprintf(DD_RSVC, "parse: RSVC - flow control wait\n");
+                       break;
+               }
+       }
+       return 0;
+}
+
+/*
+ * do ioctls and
+ * send stuff down - dont care about
+ * flow control
+ */
+static int
+parsewput(
+         queue_t *q,
+         mblk_t *mp
+         )
+{
+       register int ok = 1;
+       register mblk_t *datap;
+       register struct iocblk *iocp;
+       parsestream_t         *parse = (parsestream_t *)q->q_ptr;
+  
+       pprintf(DD_WPUT, "parse: parsewput\n");
+  
+       switch (mp->b_datap->db_type)
+       {
+           default:
+               putnext(q, mp);
+               break;
+      
+           case M_IOCTL:
+               iocp = (struct iocblk *)mp->b_rptr;
+               switch (iocp->ioc_cmd)
+               {
+                   default:
+                       pprintf(DD_WPUT, "parse: parsewput - forward M_IOCTL\n");
+                       putnext(q, mp);
+                       break;
+
+                   case CIOGETEV:
+                       /*
+                        * taken from Craig Leres ppsclock module (and modified)
+                        */
+                       datap = allocb(sizeof(struct ppsclockev), BPRI_MED);
+                       if (datap == NULL || mp->b_cont)
+                       {
+                               mp->b_datap->db_type = M_IOCNAK;
+                               iocp->ioc_error = (datap == NULL) ? ENOMEM : EINVAL;
+                               if (datap != NULL)
+                                   freeb(datap);
+                               qreply(q, mp);
+                               break;
+                       }
+
+                       mp->b_cont = datap;
+                       *(struct ppsclockev *)datap->b_wptr = parse->parse_ppsclockev;
+                       datap->b_wptr +=
+                               sizeof(struct ppsclockev) / sizeof(*datap->b_wptr);
+                       mp->b_datap->db_type = M_IOCACK;
+                       iocp->ioc_count = sizeof(struct ppsclockev);
+                       qreply(q, mp);
+                       break;
+         
+                   case PARSEIOC_ENABLE:
+                   case PARSEIOC_DISABLE:
+                           {
+                                   parse->parse_status = (parse->parse_status & (unsigned)~PARSE_ENABLE) |
+                                           (iocp->ioc_cmd == PARSEIOC_ENABLE) ?
+                                           PARSE_ENABLE : 0;
+                                   if (!setup_stream(RD(q), (parse->parse_status & PARSE_ENABLE) ?
+                                                     M_PARSE : M_NOPARSE))
+                                   {
+                                           mp->b_datap->db_type = M_IOCNAK;
+                                   }
+                                   else
+                                   {
+                                           mp->b_datap->db_type = M_IOCACK;
+                                   }
+                                   qreply(q, mp);
+                                   break;
+                           }       
+
+                   case PARSEIOC_TIMECODE:
+                   case PARSEIOC_SETFMT:
+                   case PARSEIOC_GETFMT:
+                   case PARSEIOC_SETCS:
+                       if (iocp->ioc_count == sizeof(parsectl_t))
+                       {
+                               parsectl_t *dct = (parsectl_t *)mp->b_cont->b_rptr;
+
+                               switch (iocp->ioc_cmd)
+                               {
+                                   case PARSEIOC_TIMECODE:
+                                       pprintf(DD_WPUT, "parse: parsewput - PARSEIOC_TIMECODE\n");
+                                       ok = parse_timecode(dct, &parse->parse_io);
+                                       break;
+                 
+                                   case PARSEIOC_SETFMT:
+                                       pprintf(DD_WPUT, "parse: parsewput - PARSEIOC_SETFMT\n");
+                                       ok = parse_setfmt(dct, &parse->parse_io);
+                                       break;
+
+                                   case PARSEIOC_GETFMT:
+                                       pprintf(DD_WPUT, "parse: parsewput - PARSEIOC_GETFMT\n");
+                                       ok = parse_getfmt(dct, &parse->parse_io);
+                                       break;
+
+                                   case PARSEIOC_SETCS:
+                                       pprintf(DD_WPUT, "parse: parsewput - PARSEIOC_SETCS\n");
+                                       ok = parse_setcs(dct, &parse->parse_io);
+                                       break;
+                               }
+                               mp->b_datap->db_type = ok ? M_IOCACK : M_IOCNAK;
+                       }
+                       else
+                       {
+                               mp->b_datap->db_type = M_IOCNAK;
+                       }
+                       pprintf(DD_WPUT, "parse: parsewput qreply - %s\n", (mp->b_datap->db_type == M_IOCNAK) ? "M_IOCNAK" : "M_IOCACK");
+                       qreply(q, mp);
+                       break;
+               }
+       }
+       return 0;
+}
+
+/*
+ * read characters from streams buffers
+ */
+static unsigned long
+rdchar(
+       mblk_t **mp
+       )
+{
+       while (*mp != (mblk_t *)NULL)
+       {
+               if ((*mp)->b_wptr - (*mp)->b_rptr)
+               {
+                       return (unsigned long)(*(unsigned char *)((*mp)->b_rptr++));
+               }
+               else
+               {
+                       register mblk_t *mmp = *mp;
+         
+                       *mp = (*mp)->b_cont;
+                       freeb(mmp);
+               }
+       }
+       return (unsigned long)~0;
+}
+
+/*
+ * convert incoming data
+ */
+static int
+parserput(
+         queue_t *q,
+         mblk_t *imp
+         )
+{
+       register unsigned char type;
+       mblk_t *mp = imp;
+  
+       switch (type = mp->b_datap->db_type)
+       {
+           default:
+               /*
+                * anything we don't know will be put on queue
+                * the service routine will move it to the next one
+                */
+               pprintf(DD_RPUT, "parse: parserput - forward type 0x%x\n", type);
+
+               if (canputnext(q) || (mp->b_datap->db_type > QPCTL))
+               {
+                       putnext(q, mp);
+               }
+               else
+                   putq(q, mp);
+               break;
+      
+           case M_BREAK:
+           case M_DATA:
+                   {
+                           register parsestream_t * parse = (parsestream_t *)q->q_ptr;
+                           register mblk_t *nmp;
+                           register unsigned long ch;
+                           timestamp_t ctime;
+                           timespec_t hres_time;
+
+                           /*
+                            * get time on packet delivery
+                            */
+                           gethrestime(&hres_time);
+                           ctime.tv.tv_sec  = hres_time.tv_sec;
+                           ctime.tv.tv_usec = hres_time.tv_nsec / 1000;
+
+                           if (!(parse->parse_status & PARSE_ENABLE))
+                           {
+                                   pprintf(DD_RPUT, "parse: parserput - parser disabled - forward type 0x%x\n", type);
+                                   if (canputnext(q) || (mp->b_datap->db_type > QPCTL))
+                                   {
+                                           putnext(q, mp);
+                                   }
+                                   else
+                                       putq(q, mp);
+                           }
+                           else
+                           {
+                                   pprintf(DD_RPUT, "parse: parserput - M_%s\n", (type == M_DATA) ? "DATA" : "BREAK");
+                                   if (type == M_DATA)
+                                   {
+                                           /*
+                                            * parse packet looking for start an end characters
+                                            */
+                                           while (mp != (mblk_t *)NULL)
+                                           {
+                                                   ch = rdchar(&mp);
+                                                   if (ch != ~0 && parse_ioread(&parse->parse_io, (unsigned int)ch, &ctime))
+                                                   {
+                                                           /*
+                                                            * up up and away (hopefully ...)
+                                                            * don't press it if resources are tight or nobody wants it
+                                                            */
+                                                           nmp = (mblk_t *)NULL;
+                                                           if (canputnext(parse->parse_queue) && (nmp = allocb(sizeof(parsetime_t), BPRI_MED)))
+                                                           {
+                                                                   bcopy((caddr_t)&parse->parse_io.parse_dtime, (caddr_t)nmp->b_rptr, sizeof(parsetime_t));
+                                                                   nmp->b_wptr += sizeof(parsetime_t);
+                                                                   putnext(parse->parse_queue, nmp);
+                                                           }
+                                                           else
+                                                               if (nmp) freemsg(nmp);
+                                                           parse_iodone(&parse->parse_io);
+                                                   }
+                                           }   
+                                   }
+                                   else
+                                   {
+                                           if (parse_ioread(&parse->parse_io, (unsigned int)0, &ctime))
+                                           {
+                                                   /*
+                                                    * up up and away (hopefully ...)
+                                                    * don't press it if resources are tight or nobody wants it
+                                                    */
+                                                   nmp = (mblk_t *)NULL;
+                                                   if (canputnext(parse->parse_queue) && (nmp = allocb(sizeof(parsetime_t), BPRI_MED)))
+                                                   {
+                                                           bcopy((caddr_t)&parse->parse_io.parse_dtime, (caddr_t)nmp->b_rptr, sizeof(parsetime_t));
+                                                           nmp->b_wptr += sizeof(parsetime_t);
+                                                           putnext(parse->parse_queue, nmp);
+                                                   }
+                                                   else
+                                                       if (nmp) freemsg(nmp);
+                                                   parse_iodone(&parse->parse_io);
+                                           }
+                                           freemsg(mp);
+                                   }
+                                   break;
+                           }
+                   }
+
+                   /*
+                    * CD PPS support for non direct ISR hack
+                    */
+           case M_HANGUP:
+           case M_UNHANGUP:
+                   {
+                           register parsestream_t * parse = (parsestream_t *)q->q_ptr;
+                           timestamp_t ctime;
+                           timespec_t hres_time;
+                           register mblk_t *nmp;
+                           register int status = cd_invert ^ (type == M_UNHANGUP);
+
+                           gethrestime(&hres_time);
+                           ctime.tv.tv_sec  = hres_time.tv_sec;
+                           ctime.tv.tv_usec = hres_time.tv_nsec / 1000;
+       
+                           pprintf(DD_RPUT, "parse: parserput - M_%sHANGUP\n", (type == M_HANGUP) ? "" : "UN");
+
+                           if ((parse->parse_status & PARSE_ENABLE) &&
+                               parse_iopps(&parse->parse_io, status ? SYNC_ONE : SYNC_ZERO, &ctime))
+                           {
+                                   nmp = (mblk_t *)NULL;
+                                   if (canputnext(parse->parse_queue) && (nmp = allocb(sizeof(parsetime_t), BPRI_MED)))
+                                   {
+                                           bcopy((caddr_t)&parse->parse_io.parse_dtime, (caddr_t)nmp->b_rptr, sizeof(parsetime_t));
+                                           nmp->b_wptr += sizeof(parsetime_t);
+                                           putnext(parse->parse_queue, nmp);
+                                   }
+                                   else
+                                       if (nmp) freemsg(nmp);
+                                   parse_iodone(&parse->parse_io);
+                                   freemsg(mp);
+                           }
+                           else
+                               if (canputnext(q) || (mp->b_datap->db_type > QPCTL))
+                               {
+                                       putnext(q, mp);
+                               }
+                               else
+                                   putq(q, mp);
+       
+                           if (status)
+                           {
+                                   parse->parse_ppsclockev.tv = ctime.tv;
+                                   ++(parse->parse_ppsclockev.serial);
+                           }
+                   }
+       }
+       return 0;
+}
+
+static int  init_zs_linemon  P((queue_t *, queue_t *));        /* handle line monitor for "zs" driver */
+static void close_zs_linemon P((queue_t *, queue_t *));
+
+/*-------------------- CD isr status monitor ---------------*/
+
+static int
+init_linemon(
+            queue_t *q
+            )
+{
+       register queue_t *dq;
+  
+       dq = WR(q);
+       /*
+        * we ARE doing very bad things down here (basically stealing ISR
+        * hooks)
+        *
+        * so we chase down the STREAMS stack searching for the driver
+        * and if this is a known driver we insert our ISR routine for
+        * status changes in to the ExternalStatus handling hook
+        */
+       while (dq->q_next)
+       {
+               dq = dq->q_next;                /* skip down to driver */
+       }
+
+       /*
+        * find appropriate driver dependent routine
+        */
+       if (dq->q_qinfo && dq->q_qinfo->qi_minfo)
+       {
+               register char *dname = dq->q_qinfo->qi_minfo->mi_idname;
+
+               pprintf(DD_INSTALL, "init_linemon: driver is \"%s\"\n", dname);
+
+#ifdef sun
+               if (dname && !strcmp(dname, "zs"))
+               {
+                       return init_zs_linemon(dq, q);
+               }
+               else
+#endif
+               {
+                       pprintf(DD_INSTALL, "init_linemon: driver \"%s\" not suitable for CD monitoring\n", dname);
+                       return 0;
+               }
+       }
+       pprintf(DD_INSTALL, "init_linemon: cannot find driver\n");
+       return 0;
+}
+
+static void
+close_linemon(
+             queue_t *q,
+             queue_t *my_q
+             )
+{
+       /*
+        * find appropriate driver dependent routine
+        */
+       if (q->q_qinfo && q->q_qinfo->qi_minfo)
+       {
+               register char *dname = q->q_qinfo->qi_minfo->mi_idname;
+
+#ifdef sun
+               if (dname && !strcmp(dname, "zs"))
+               {
+                       close_zs_linemon(q, my_q);
+                       return;
+               }
+               pprintf(DD_INSTALL, "close_linemon: cannot find driver close routine for \"%s\"\n", dname);
+#endif
+       }
+       pprintf(DD_INSTALL, "close_linemon: cannot find driver name\n");
+}
+
+#ifdef sun
+#include <sys/tty.h>
+#include <sys/zsdev.h>
+#include <sys/ser_async.h>
+#include <sys/ser_zscc.h>
+
+static void zs_xsisr         P((struct zscom *));      /* zs external status interupt handler */
+
+/*
+ * there should be some docs telling how to get to
+ * sz:zs_usec_delay and zs:initzsops()
+ */
+#define zs_usec_delay 5
+
+struct savedzsops
+{
+       struct zsops  zsops;
+       struct zsops *oldzsops;
+};
+
+static struct zsops   *emergencyzs;
+
+static int
+init_zs_linemon(
+               queue_t *q,
+               queue_t *my_q
+               )
+{
+       register struct zscom *zs;
+       register struct savedzsops *szs;
+       register parsestream_t  *parsestream = (parsestream_t *)my_q->q_ptr;
+       /*
+        * we expect the zsaline pointer in the q_data pointer
+        * from there on we insert our on EXTERNAL/STATUS ISR routine
+        * into the interrupt path, before the standard handler
+        */
+       zs = ((struct asyncline *)q->q_ptr)->za_common;
+       if (!zs)
+       {
+               /*
+                * well - not found on startup - just say no (shouldn't happen though)
+                */
+               return 0;
+       }
+       else
+       {
+               /*
+                * we do a direct replacement, in case others fiddle also
+                * if somebody else grabs our hook and we disconnect
+                * we are in DEEP trouble - panic is likely to be next, sorry
+                */
+               szs = (struct savedzsops *) kmem_alloc(sizeof(struct savedzsops), KM_SLEEP);
+
+               if (szs == (struct savedzsops *)0)
+               {
+                       pprintf(DD_INSTALL, "init_zs_linemon: CD monitor NOT installed - no memory\n");
+
+                       return 0;
+               }
+               else
+               {
+                       parsestream->parse_data   = (void *)szs;
+
+                       mutex_enter(zs->zs_excl);
+
+                       parsestream->parse_dqueue = q; /* remember driver */
+
+                       szs->zsops            = *zs->zs_ops;
+                       szs->zsops.zsop_xsint = (void (*) P((struct zscom *)))zs_xsisr; /* place our bastard */
+                       szs->oldzsops         = zs->zs_ops;
+                       emergencyzs           = zs->zs_ops;
+         
+                       zs->zs_ops = &szs->zsops; /* hook it up */
+                       /*
+                        * XXX: this is usually done via zsopinit() 
+                        * - have yet to find a way to call that routine
+                        */
+                       zs->zs_xsint          = (void (*) P((struct zscom *)))zs_xsisr;
+         
+                       mutex_exit(zs->zs_excl);
+
+                       pprintf(DD_INSTALL, "init_zs_linemon: CD monitor installed\n");
+
+                       return 1;
+               }
+       }
+}
+
+/*
+ * unregister our ISR routine - must call under splhigh() (or 
+ * whatever block ZS status interrupts)
+ */
+static void
+close_zs_linemon(
+                queue_t *q,
+                queue_t *my_q
+                )
+{
+       register struct zscom *zs;
+       register parsestream_t  *parsestream = (parsestream_t *)my_q->q_ptr;
+
+       zs = ((struct asyncline *)q->q_ptr)->za_common;
+       if (!zs)
+       {
+               /*
+                * well - not found on startup - just say no (shouldn't happen though)
+                */
+               return;
+       }
+       else
+       {
+               register struct savedzsops *szs = (struct savedzsops *)parsestream->parse_data;
+
+               mutex_enter(zs->zs_excl);
+
+               zs->zs_ops = szs->oldzsops; /* reset to previous handler functions */
+               /*
+                * XXX: revert xsint (usually done via zsopinit() - have still to find
+                * a way to call that bugger
+                */
+               zs->zs_xsint = zs->zs_ops->zsop_xsint;
+
+               mutex_exit(zs->zs_excl);
+
+               kmem_free((caddr_t)szs, sizeof (struct savedzsops));
+      
+               pprintf(DD_INSTALL, "close_zs_linemon: CD monitor deleted\n");
+               return;
+       }
+}
+
+#define ZSRR0_IGNORE   (ZSRR0_CD|ZSRR0_SYNC|ZSRR0_CTS)
+
+#define MAXDEPTH 50            /* maximum allowed stream crawl */
+
+/*
+ * take external status interrupt (only CD interests us)
+ */
+static void
+zs_xsisr(
+        struct zscom *zs
+        )
+{
+       register struct asyncline *za = (struct asyncline *)zs->zs_priv;
+       register queue_t *q;
+       register unsigned char zsstatus;
+       register int loopcheck;
+       register unsigned char cdstate;
+       register const char *dname = "-UNKNOWN-";
+       timespec_t hres_time;
+
+       /*
+        * pick up current state
+        */
+       zsstatus = SCC_READ0();
+
+       if (za->za_rr0 ^ (cdstate = zsstatus & ZSRR0_CD))
+       {
+               timestamp_t cdevent;
+               register int status;
+      
+               /*
+                * time stamp
+                */
+               gethrestime(&hres_time);
+               cdevent.tv.tv_sec  = hres_time.tv_sec;
+               cdevent.tv.tv_usec = hres_time.tv_nsec / 1000;
+
+               q = za->za_ttycommon.t_readq;
+
+               /*
+                * logical state
+                */
+               status = cd_invert ? cdstate == 0 : cdstate != 0;
+
+               /*
+                * ok - now the hard part - find ourself
+                */
+               loopcheck = MAXDEPTH;
+      
+               while (q)
+               {
+                       if (q->q_qinfo && q->q_qinfo->qi_minfo)
+                       {
+                               dname = q->q_qinfo->qi_minfo->mi_idname;
+
+                               if (!strcmp(dname, parseinfo.st_rdinit->qi_minfo->mi_idname))
+                               {
+                                       /*
+                                        * back home - phew (hopping along stream queues might
+                                        * prove dangerous to your health)
+                                        */
+
+                                       if ((((parsestream_t *)q->q_ptr)->parse_status & PARSE_ENABLE) &&
+                                           parse_iopps(&((parsestream_t *)q->q_ptr)->parse_io, status ? SYNC_ONE : SYNC_ZERO, &cdevent))
+                                       {
+                                               /*
+                                                * XXX - currently we do not pass up the message, as
+                                                * we should.
+                                                * for a correct behaviour wee need to block out
+                                                * processing until parse_iodone has been posted via
+                                                * a softcall-ed routine which does the message pass-up
+                                                * right now PPS information relies on input being
+                                                * received
+                                                */
+                                               parse_iodone(&((parsestream_t *)q->q_ptr)->parse_io);
+                                       }
+                 
+                                       if (status)
+                                       {
+                                               ((parsestream_t *)q->q_ptr)->parse_ppsclockev.tv = cdevent.tv;
+                                               ++(((parsestream_t *)q->q_ptr)->parse_ppsclockev.serial);
+                                       }
+
+                                       pprintf(DD_ISR, "zs_xsisr: CD event %s has been posted for \"%s\"\n", status ? "ONE" : "ZERO", dname);
+                                       break;
+                               }
+                       }
+
+                       q = q->q_next;
+
+                       if (!loopcheck--)
+                       {
+                               panic("zs_xsisr: STREAMS Queue corrupted - CD event");
+                       }
+               }
+
+               if (cdstate)    /* fake CARRIER status - XXX currently not coordinated */
+                 za->za_flags |= ZAS_CARR_ON;
+               else
+                 za->za_flags &= ~ZAS_CARR_ON;
+
+               /*
+                * only pretend that CD and ignored transistion (SYNC,CTS)
+                * have been handled
+                */
+               za->za_rr0 = (za->za_rr0 & ~ZSRR0_IGNORE) | (zsstatus & ZSRR0_IGNORE);
+
+               if (((za->za_rr0 ^ zsstatus) & ~ZSRR0_IGNORE) == 0)
+               {
+                       /*
+                        * all done - kill status indication and return
+                        */
+                       SCC_WRITE0(ZSWR0_RESET_STATUS); /* might kill other conditions here */
+                       return;
+               }
+       }      
+
+       pprintf(DD_ISR, "zs_xsisr: non CD event 0x%x for \"%s\"\n", 
+               (za->za_rr0 ^ zsstatus) & ~ZSRR0_CD,dname);
+       /*
+        * we are now gathered here to process some unusual external status
+        * interrupts.
+        * any CD events have also been handled and shouldn't be processed
+        * by the original routine (unless we have a VERY busy port pin)
+        * some initializations are done here, which could have been done before for
+        * both code paths but have been avioded for minimum path length to
+        * the uniq_time routine
+        */
+       dname = (char *) 0;
+       q = za->za_ttycommon.t_readq;
+
+       loopcheck = MAXDEPTH;
+      
+       /*
+        * the real thing for everything else ...
+        */
+       while (q)
+       {
+               if (q->q_qinfo && q->q_qinfo->qi_minfo)
+               {
+                       dname = q->q_qinfo->qi_minfo->mi_idname;
+                       if (!strcmp(dname, parseinfo.st_rdinit->qi_minfo->mi_idname))
+                       {
+                               register void (*zsisr) P((struct zscom *));
+                 
+                               /*
+                                * back home - phew (hopping along stream queues might
+                                * prove dangerous to your health)
+                                */
+                               if ((zsisr = ((struct savedzsops *)((parsestream_t *)q->q_ptr)->parse_data)->oldzsops->zsop_xsint))
+                                   zsisr(zs);
+                               else
+                                   panic("zs_xsisr: unable to locate original ISR");
+                 
+                               pprintf(DD_ISR, "zs_xsisr: non CD event was processed for \"%s\"\n", dname);
+                               /*
+                                * now back to our program ...
+                                */
+                               return;
+                       }
+               }
+
+               q = q->q_next;
+
+               if (!loopcheck--)
+               {
+                       panic("zs_xsisr: STREAMS Queue corrupted - non CD event");
+               }
+       }
+
+       /*
+        * last resort - shouldn't even come here as it indicates
+        * corrupted TTY structures
+        */
+       printf("zs_zsisr: looking for \"%s\" - found \"%s\" - taking EMERGENCY path\n", parseinfo.st_rdinit->qi_minfo->mi_idname, dname ? dname : "-NIL-");
+      
+       if (emergencyzs && emergencyzs->zsop_xsint)
+           emergencyzs->zsop_xsint(zs);
+       else
+           panic("zs_xsisr: no emergency ISR handler");
+}
+#endif                         /* sun */
+
+/*
+ * History:
+ *
+ * parsesolaris.c,v
+ * Revision 4.11  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.10  2004/11/14 16:06:08  kardel
+ * update Id tags
+ *
+ * Revision 4.9  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.6  1998/11/15 21:56:08  kardel
+ * ntp_memset not necessary
+ *
+ * Revision 4.5  1998/11/15 21:23:37  kardel
+ * ntp_memset() replicated in Sun kernel files
+ *
+ * Revision 4.4  1998/06/14 21:09:40  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.3  1998/06/13 12:14:59  kardel
+ * more prototypes
+ * fix name clashes
+ * allow for ansi2knr
+ *
+ * Revision 4.2  1998/06/12 15:23:08  kardel
+ * fix prototypes
+ * adjust for ansi2knr
+ *
+ * Revision 4.1  1998/05/24 09:38:46  kardel
+ * streams initiated iopps calls (M_xHANGUP) are now consistent with the
+ * respective calls from zs_xsisr()
+ * simulation of CARRIER status to avoid unecessary M_xHANGUP messages
+ *
+ * Revision 4.0  1998/04/10 19:45:38  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 3.28 log info deleted 1998/04/11 kardel
+ */
diff --git a/libparse/parsestreams.c b/libparse/parsestreams.c
new file mode 100644 (file)
index 0000000..7df3542
--- /dev/null
@@ -0,0 +1,1367 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/parsestreams.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *  
+ * parsestreams.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * STREAMS module for reference clocks
+ * (SunOS4.x)
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#define KERNEL                 /* MUST */
+#define VDDRV                  /* SHOULD */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#ifndef lint
+static char rcsid[] = "parsestreams.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A";
+#endif
+
+#ifndef KERNEL
+#include "Bletch: MUST COMPILE WITH KERNEL DEFINE"
+#endif
+
+#include <sys/types.h>
+#include <sys/conf.h>
+#include <sys/buf.h>
+#include <sys/param.h>
+#include <sys/sysmacros.h>
+#include <sys/time.h>
+#include <sundev/mbvar.h>
+#include <sun/autoconf.h>
+#include <sys/stream.h>
+#include <sys/stropts.h>
+#include <sys/dir.h>
+#include <sys/signal.h>
+#include <sys/termios.h>
+#include <sys/termio.h>
+#include <sys/ttold.h>
+#include <sys/user.h>
+#include <sys/tty.h>
+
+#ifdef VDDRV
+#include <sun/vddrv.h>
+#endif
+
+#include "ntp_stdlib.h"
+#include "ntp_fp.h"
+/*
+ * just make checking compilers more silent
+ */
+extern int printf      P((const char *, ...));
+extern int putctl1     P((queue_t *, int, int));
+extern int canput      P((queue_t *));
+extern void putbq      P((queue_t *, mblk_t *));
+extern void freeb      P((mblk_t *));
+extern void qreply     P((queue_t *, mblk_t *));
+extern void freemsg    P((mblk_t *));
+extern void panic      P((const char *, ...));
+extern void usec_delay P((int));
+
+#include "parse.h"
+#include "sys/parsestreams.h"
+
+/*
+ * use microtime instead of uniqtime if advised to
+ */
+#ifdef MICROTIME
+#define uniqtime microtime
+#endif
+
+#ifdef VDDRV
+static unsigned int parsebusy = 0;
+
+/*--------------- loadable driver section -----------------------------*/
+
+extern struct streamtab parseinfo;
+
+
+#ifdef PPS_SYNC
+static char mnam[] = "PARSEPPS     ";  /* name this baby - keep room for revision number */
+#else
+static char mnam[] = "PARSE        ";  /* name this baby - keep room for revision number */
+#endif
+struct vdldrv parsesync_vd = 
+{
+       VDMAGIC_PSEUDO,         /* nothing like a real driver - a STREAMS module */
+       mnam,
+};
+
+/*
+ * strings support usually not in kernel
+ */
+static int
+Strlen(
+       register const char *s
+       )
+{
+       register int c;
+
+       c = 0;
+       if (s)
+       {
+               while (*s++)
+               {
+                       c++;
+               }
+       }
+       return c;
+}
+
+static void
+Strncpy(
+       register char *t,
+       register char *s,
+       register int   c
+       )
+{
+       if (s && t)
+       {
+               while ((c-- > 0) && (*t++ = *s++))
+                   ;
+       }
+}
+
+static int
+Strcmp(
+       register const char *s,
+       register const char *t
+       )
+{
+       register int c = 0;
+
+       if (!s || !t || (s == t))
+       {
+               return 0;
+       }
+
+       while (!(c = *s++ - *t++) && *s && *t)
+           /* empty loop */;
+  
+       return c;
+}
+
+static int
+Strncmp(
+       register char *s,
+       register char *t,
+       register int n
+       )
+{
+       register int c = 0;
+
+       if (!s || !t || (s == t))
+       {
+               return 0;
+       }
+
+       while (n-- && !(c = *s++ - *t++) && *s && *t)
+           /* empty loop */;
+  
+       return c;
+}
+void
+ntp_memset(
+       char *a,
+       int x,
+       int c
+       )
+{
+       while (c-- > 0)
+           *a++ = x;
+}
+
+/*
+ * driver init routine
+ * since no mechanism gets us into and out of the fmodsw, we have to
+ * do it ourselves
+ */
+/*ARGSUSED*/
+int
+xxxinit(
+       unsigned int fc,
+       struct vddrv *vdp,
+       addr_t vdin,
+       struct vdstat *vds
+       )
+{
+       extern struct fmodsw fmodsw[];
+       extern int fmodcnt;
+  
+       struct fmodsw *fm    = fmodsw;
+       struct fmodsw *fmend = &fmodsw[fmodcnt];
+       struct fmodsw *ifm   = (struct fmodsw *)0;
+       char *mname          = parseinfo.st_rdinit->qi_minfo->mi_idname;
+  
+       switch (fc)
+       {
+           case VDLOAD:
+               vdp->vdd_vdtab = (struct vdlinkage *)&parsesync_vd;
+               /*
+                * now, jog along fmodsw scanning for an empty slot
+                * and deposit our name there
+                */
+               while (fm <= fmend)
+               {
+         if (!Strncmp(fm->f_name, mname, FMNAMESZ))
+                       {
+                               printf("vddrinit[%s]: STREAMS module already loaded.\n", mname);
+                               return(EBUSY);
+                       }
+                       else
+                           if ((ifm == (struct fmodsw *)0) && 
+                               (fm->f_name[0] == '\0') &&
+                               (fm->f_str == (struct streamtab *)0))
+                           {
+                                   /*
+                                    * got one - so move in
+                                    */
+                                   ifm = fm;
+                                   break;
+                           }
+                       fm++;
+               }
+
+               if (ifm == (struct fmodsw *)0)
+               {
+                       printf("vddrinit[%s]: no slot free for STREAMS module\n", mname);
+                       return (ENOSPC);
+               }
+               else
+               {
+                       static char revision[] = "4.7";
+                       char *s, *S, *t;
+         
+                       s = rcsid;              /* NOOP - keep compilers happy */
+
+                       Strncpy(ifm->f_name, mname, FMNAMESZ);
+                       ifm->f_name[FMNAMESZ] = '\0';
+                       ifm->f_str = &parseinfo;
+                       /*
+                        * copy RCS revision into Drv_name
+                        *
+                        * are we forcing RCS here to do things it was not built for ?
+                        */
+                       s = revision;
+                       if (*s == '$')
+                       {
+                               /*
+                                * skip "$Revision: "
+                                * if present. - not necessary on a -kv co (cvs export)
+                                */
+                               while (*s && (*s != ' '))
+                               {
+                                       s++;
+                               }
+                               if (*s == ' ') s++;
+                       }
+         
+                       t = parsesync_vd.Drv_name; 
+                       while (*t && (*t != ' '))
+                       {
+                               t++;
+                       }
+                       if (*t == ' ') t++;
+         
+                       S = s;
+                       while (*S && (((*S >= '0') && (*S <= '9')) || (*S == '.')))
+                       {
+                               S++;
+                       }
+         
+                       if (*s && *t && (S > s))
+                       {
+                               if (Strlen(t) >= (S - s))
+                               {
+                                       (void) Strncpy(t, s, S - s);
+                               }
+                       }
+                       return (0);
+               } 
+               break;
+      
+           case VDUNLOAD:
+               if (parsebusy > 0)
+               {
+                       printf("vddrinit[%s]: STREAMS module has still %d instances active.\n", mname, parsebusy);
+                       return (EBUSY);
+               }
+               else
+               {
+                       while (fm <= fmend)
+                       {
+                               if (!Strncmp(fm->f_name, mname, FMNAMESZ))
+                               {
+                                       /*
+                                        * got it - kill entry
+                                        */
+                                       fm->f_name[0] = '\0';
+                                       fm->f_str = (struct streamtab *)0;
+                                       fm++;
+                 
+                                       break;
+                               }
+                               fm++;
+                       }
+                       if (fm > fmend)
+                       {
+                               printf("vddrinit[%s]: cannot find entry for STREAMS module\n", mname);
+                               return (ENXIO);
+                       }
+                       else
+                           return (0);
+               }
+      
+
+           case VDSTAT:
+               return (0);
+
+           default:
+               return (EIO);
+      
+       }
+       return EIO;
+}
+
+#endif
+
+/*--------------- stream module definition ----------------------------*/
+
+static int parseopen  P((queue_t *, dev_t, int, int));
+static int parseclose P((queue_t *, int));
+static int parsewput  P((queue_t *, mblk_t *));
+static int parserput  P((queue_t *, mblk_t *));
+static int parsersvc  P((queue_t *));
+
+static char mn[] = "parse";
+
+static struct module_info driverinfo =
+{
+       0,                              /* module ID number */
+       mn,                     /* module name */
+       0,                              /* minimum accepted packet size */
+       INFPSZ,                 /* maximum accepted packet size */
+       1,                              /* high water mark - flow control */
+       0                               /* low water mark - flow control */
+};
+
+static struct qinit rinit =    /* read queue definition */
+{
+       parserput,                      /* put procedure */
+       parsersvc,                      /* service procedure */
+       parseopen,                      /* open procedure */
+       parseclose,                     /* close procedure */
+       NULL,                           /* admin procedure - NOT USED FOR NOW */
+       &driverinfo,                    /* information structure */
+       NULL                            /* statistics */
+};
+
+static struct qinit winit =    /* write queue definition */
+{
+       parsewput,                      /* put procedure */
+       NULL,                           /* service procedure */
+       NULL,                           /* open procedure */
+       NULL,                           /* close procedure */
+       NULL,                           /* admin procedure - NOT USED FOR NOW */
+       &driverinfo,                    /* information structure */
+       NULL                            /* statistics */
+};
+
+struct streamtab parseinfo =   /* stream info element for dpr driver */
+{
+       &rinit,                 /* read queue */
+       &winit,                 /* write queue */
+       NULL,                           /* read mux */
+       NULL,                           /* write mux */
+       NULL                            /* module auto push */
+};
+
+/*--------------- driver data structures ----------------------------*/
+
+/*
+ * we usually have an inverted signal - but you
+ * can change this to suit your needs
+ */
+int cd_invert = 1;             /* invert status of CD line - PPS support via CD input */
+
+int parsedebug = ~0;
+
+extern void uniqtime P((struct timeval *));
+
+/*--------------- module implementation -----------------------------*/
+
+#define TIMEVAL_USADD(_X_, _US_) {\
+                                   (_X_)->tv_usec += (_US_);\
+                                  if ((_X_)->tv_usec >= 1000000)\
+                                     {\
+                                       (_X_)->tv_sec++;\
+                                      (_X_)->tv_usec -= 1000000;\
+                                     }\
+                                } while (0)
+
+static int init_linemon P((queue_t *));
+static void close_linemon P((queue_t *, queue_t *));
+
+#define M_PARSE                0x0001
+#define M_NOPARSE      0x0002
+
+static int
+setup_stream(
+            queue_t *q,
+            int mode
+            )
+{
+       mblk_t *mp;
+
+       mp = allocb(sizeof(struct stroptions), BPRI_MED);
+       if (mp)
+       {
+               struct stroptions *str = (struct stroptions *)(void *)mp->b_rptr;
+
+               str->so_flags   = SO_READOPT|SO_HIWAT|SO_LOWAT;
+               str->so_readopt = (mode == M_PARSE) ? RMSGD : RNORM;
+               str->so_hiwat   = (mode == M_PARSE) ? sizeof(parsetime_t) : 256;
+               str->so_lowat   = 0;
+               mp->b_datap->db_type = M_SETOPTS;
+               mp->b_wptr += sizeof(struct stroptions);
+               putnext(q, mp);
+               return putctl1(WR(q)->q_next, M_CTL, (mode == M_PARSE) ? MC_SERVICEIMM :
+                              MC_SERVICEDEF);
+       }
+       else
+       {
+               parseprintf(DD_OPEN,("parse: setup_stream - FAILED - no MEMORY for allocb\n")); 
+               return 0;
+       }
+}
+
+/*ARGSUSED*/
+static int
+parseopen(
+       queue_t *q,
+       dev_t dev,
+       int flag,
+       int sflag
+       )
+{
+       register parsestream_t *parse;
+       static int notice = 0;
+  
+       parseprintf(DD_OPEN,("parse: OPEN\n")); 
+  
+       if (sflag != MODOPEN)
+       {                       /* open only for modules */
+               parseprintf(DD_OPEN,("parse: OPEN - FAILED - not MODOPEN\n")); 
+               return OPENFAIL;
+       }
+
+       if (q->q_ptr != (caddr_t)NULL)
+       {
+               u.u_error = EBUSY;
+               parseprintf(DD_OPEN,("parse: OPEN - FAILED - EXCLUSIVE ONLY\n")); 
+               return OPENFAIL;
+       }
+
+#ifdef VDDRV
+       parsebusy++;
+#endif
+  
+       q->q_ptr = (caddr_t)kmem_alloc(sizeof(parsestream_t));
+       if (q->q_ptr == (caddr_t)0)
+       {
+               parseprintf(DD_OPEN,("parse: OPEN - FAILED - no memory\n")); 
+#ifdef VDDRV
+               parsebusy--;
+#endif
+               return OPENFAIL;
+       }
+       WR(q)->q_ptr = q->q_ptr;
+  
+       parse = (parsestream_t *)(void *)q->q_ptr;
+       bzero((caddr_t)parse, sizeof(*parse));
+       parse->parse_queue     = q;
+       parse->parse_status    = PARSE_ENABLE;
+       parse->parse_ppsclockev.tv.tv_sec  = 0;
+       parse->parse_ppsclockev.tv.tv_usec = 0;
+       parse->parse_ppsclockev.serial     = 0;
+
+       if (!parse_ioinit(&parse->parse_io))
+       {
+               /*
+                * ok guys - beat it
+                */
+               kmem_free((caddr_t)parse, sizeof(parsestream_t));
+#ifdef VDDRV
+               parsebusy--;
+#endif
+               return OPENFAIL;
+       }
+
+       if (setup_stream(q, M_PARSE))
+       {
+               (void) init_linemon(q); /* hook up PPS ISR routines if possible */
+
+               parseprintf(DD_OPEN,("parse: OPEN - SUCCEEDED\n")); 
+
+               /*
+                * I know that you know the delete key, but you didn't write this
+                * code, did you ? - So, keep the message in here.
+                */
+               if (!notice)
+               {
+#ifdef VDDRV
+                       printf("%s: Copyright (C) 1991-2005, Frank Kardel\n", parsesync_vd.Drv_name);
+#else
+                       printf("%s: Copyright (C) 1991-2005, Frank Kardel\n", "parsestreams.c,v 4.11 2005/04/16 17:32:10 kardel RELEASE_20050508_A");
+#endif
+                       notice = 1;
+               }
+
+               return MODOPEN;
+       }
+       else
+       {
+               kmem_free((caddr_t)parse, sizeof(parsestream_t));
+
+#ifdef VDDRV
+               parsebusy--;
+#endif
+               return OPENFAIL;
+       }
+}
+
+/*ARGSUSED*/
+static int
+parseclose(
+       queue_t *q,
+       int flags
+       )
+{
+       register parsestream_t *parse = (parsestream_t *)(void *)q->q_ptr;
+       register unsigned long s;
+  
+       parseprintf(DD_CLOSE,("parse: CLOSE\n"));
+  
+       s = splhigh();
+  
+       if (parse->parse_dqueue)
+           close_linemon(parse->parse_dqueue, q);
+       parse->parse_dqueue = (queue_t *)0;
+
+       (void) splx(s);
+      
+       parse_ioend(&parse->parse_io);
+
+       kmem_free((caddr_t)parse, sizeof(parsestream_t));
+
+       q->q_ptr = (caddr_t)NULL;
+       WR(q)->q_ptr = (caddr_t)NULL;
+
+#ifdef VDDRV
+       parsebusy--;
+#endif
+       return 0;
+}
+
+/*
+ * move unrecognized stuff upward
+ */
+static int
+parsersvc(
+       queue_t *q
+       )
+{
+       mblk_t *mp;
+  
+       while ((mp = getq(q)))
+       {
+               if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
+               {
+                       putnext(q, mp);
+                       parseprintf(DD_RSVC,("parse: RSVC - putnext\n"));
+               }
+               else
+               {
+                       putbq(q, mp);
+                       parseprintf(DD_RSVC,("parse: RSVC - flow control wait\n"));
+                       break;
+               }
+       }
+       return 0;
+}
+
+/*
+ * do ioctls and
+ * send stuff down - dont care about
+ * flow control
+ */
+static int
+parsewput(
+       queue_t *q,
+       register mblk_t *mp
+       )
+{
+       register int ok = 1;
+       register mblk_t *datap;
+       register struct iocblk *iocp;
+       parsestream_t         *parse = (parsestream_t *)(void *)q->q_ptr;
+  
+       parseprintf(DD_WPUT,("parse: parsewput\n"));
+  
+       switch (mp->b_datap->db_type)
+       {
+           default:
+               putnext(q, mp);
+               break;
+      
+           case M_IOCTL:
+                   iocp = (struct iocblk *)(void *)mp->b_rptr;
+               switch (iocp->ioc_cmd)
+               {
+                   default:
+                       parseprintf(DD_WPUT,("parse: parsewput - forward M_IOCTL\n"));
+                       putnext(q, mp);
+                       break;
+
+                   case CIOGETEV:
+                       /*
+                        * taken from Craig Leres ppsclock module (and modified)
+                        */
+                       datap = allocb(sizeof(struct ppsclockev), BPRI_MED);
+                       if (datap == NULL || mp->b_cont)
+                       {
+                               mp->b_datap->db_type = M_IOCNAK;
+                               iocp->ioc_error = (datap == NULL) ? ENOMEM : EINVAL;
+                               if (datap != NULL)
+                                   freeb(datap);
+                               qreply(q, mp);
+                               break;
+                       }
+
+                       mp->b_cont = datap;
+                       *(struct ppsclockev *)(void *)datap->b_wptr = parse->parse_ppsclockev;
+                       datap->b_wptr +=
+                               sizeof(struct ppsclockev) / sizeof(*datap->b_wptr);
+                       mp->b_datap->db_type = M_IOCACK;
+                       iocp->ioc_count = sizeof(struct ppsclockev);
+                       qreply(q, mp);
+                       break;
+         
+                   case PARSEIOC_ENABLE:
+                   case PARSEIOC_DISABLE:
+                           {
+                                   parse->parse_status = (parse->parse_status & (unsigned)~PARSE_ENABLE) |
+                                           (iocp->ioc_cmd == PARSEIOC_ENABLE) ?
+                                           PARSE_ENABLE : 0;
+                                   if (!setup_stream(RD(q), (parse->parse_status & PARSE_ENABLE) ?
+                                                     M_PARSE : M_NOPARSE))
+                                   {
+                                           mp->b_datap->db_type = M_IOCNAK;
+                                   }
+                                   else
+                                   {
+                                           mp->b_datap->db_type = M_IOCACK;
+                                   }
+                                   qreply(q, mp);
+                                   break;
+                           }       
+
+                   case PARSEIOC_TIMECODE:
+                   case PARSEIOC_SETFMT:
+                   case PARSEIOC_GETFMT:
+                   case PARSEIOC_SETCS:
+                       if (iocp->ioc_count == sizeof(parsectl_t))
+                       {
+                               parsectl_t *dct = (parsectl_t *)(void *)mp->b_cont->b_rptr;
+
+                               switch (iocp->ioc_cmd)
+                               {
+                                   case PARSEIOC_TIMECODE:
+                                       parseprintf(DD_WPUT,("parse: parsewput - PARSEIOC_TIMECODE\n"));
+                                       ok = parse_timecode(dct, &parse->parse_io);
+                                       break;
+                 
+                                   case PARSEIOC_SETFMT:
+                                       parseprintf(DD_WPUT,("parse: parsewput - PARSEIOC_SETFMT\n"));
+                                       ok = parse_setfmt(dct, &parse->parse_io);
+                                       break;
+
+                                   case PARSEIOC_GETFMT:
+                                       parseprintf(DD_WPUT,("parse: parsewput - PARSEIOC_GETFMT\n"));
+                                       ok = parse_getfmt(dct, &parse->parse_io);
+                                       break;
+
+                                   case PARSEIOC_SETCS:
+                                       parseprintf(DD_WPUT,("parse: parsewput - PARSEIOC_SETCS\n"));
+                                       ok = parse_setcs(dct, &parse->parse_io);
+                                       break;
+                               }
+                               mp->b_datap->db_type = ok ? M_IOCACK : M_IOCNAK;
+                       }
+                       else
+                       {
+                               mp->b_datap->db_type = M_IOCNAK;
+                       }
+                       parseprintf(DD_WPUT,("parse: parsewput qreply - %s\n", (mp->b_datap->db_type == M_IOCNAK) ? "M_IOCNAK" : "M_IOCACK"));
+                       qreply(q, mp);
+                       break;
+               }
+       }
+       return 0;
+}
+
+/*
+ * read characters from streams buffers
+ */
+static unsigned long
+rdchar(
+       register mblk_t **mp
+       )
+{
+       while (*mp != (mblk_t *)NULL)
+       {
+               if ((*mp)->b_wptr - (*mp)->b_rptr)
+               {
+                       return (unsigned long)(*(unsigned char *)((*mp)->b_rptr++));
+               }
+               else
+               {
+                       register mblk_t *mmp = *mp;
+         
+                       *mp = (*mp)->b_cont;
+                       freeb(mmp);
+               }
+       }
+       return (unsigned)~0;
+}
+
+/*
+ * convert incoming data
+ */
+static int
+parserput(
+       queue_t *q,
+       mblk_t *mp
+       )
+{
+       unsigned char type;
+  
+       switch (type = mp->b_datap->db_type)
+       {
+           default:
+               /*
+                * anything we don't know will be put on queue
+                * the service routine will move it to the next one
+                */
+               parseprintf(DD_RPUT,("parse: parserput - forward type 0x%x\n", type));
+               if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
+               {
+                       putnext(q, mp);
+               }
+               else
+                   putq(q, mp);
+               break;
+      
+           case M_BREAK:
+           case M_DATA:
+                   {
+                           register parsestream_t * parse = (parsestream_t *)(void *)q->q_ptr;
+                           register mblk_t *nmp;
+                           register unsigned long ch;
+                           timestamp_t ctime;
+
+                           /*
+                            * get time on packet delivery
+                            */
+                           uniqtime(&ctime.tv);
+
+                           if (!(parse->parse_status & PARSE_ENABLE))
+                           {
+                                   parseprintf(DD_RPUT,("parse: parserput - parser disabled - forward type 0x%x\n", type));
+                                   if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
+                                   {
+                                           putnext(q, mp);
+                                   }
+                                   else
+                                       putq(q, mp);
+                           }
+                           else
+                           {
+                                   parseprintf(DD_RPUT,("parse: parserput - M_%s\n", (type == M_DATA) ? "DATA" : "BREAK"));
+
+                                   if (type == M_DATA)
+                                   {
+                                           /*
+                                            * parse packet looking for start an end characters
+                                            */
+                                           while (mp != (mblk_t *)NULL)
+                                           {
+                                                   ch = rdchar(&mp);
+                                                   if (ch != ~0 && parse_ioread(&parse->parse_io, (unsigned int)ch, &ctime))
+                                                   {
+                                                           /*
+                                                            * up up and away (hopefully ...)
+                                                            * don't press it if resources are tight or nobody wants it
+                                                            */
+                                                           nmp = (mblk_t *)NULL;
+                                                           if (canput(parse->parse_queue->q_next) && (nmp = allocb(sizeof(parsetime_t), BPRI_MED)))
+                                                           {
+                                                                   bcopy((caddr_t)&parse->parse_io.parse_dtime, (caddr_t)nmp->b_rptr, sizeof(parsetime_t));
+                                                                   nmp->b_wptr += sizeof(parsetime_t);
+                                                                   putnext(parse->parse_queue, nmp);
+                                                           }
+                                                           else
+                                                               if (nmp) freemsg(nmp);
+                                                           parse_iodone(&parse->parse_io);
+                                                   }
+                                           }   
+                                   }
+                                   else
+                                   {
+                                           if (parse_ioread(&parse->parse_io, (unsigned int)0, &ctime))
+                                           {
+                                                   /*
+                                                    * up up and away (hopefully ...)
+                                                    * don't press it if resources are tight or nobody wants it
+                                                    */
+                                                   nmp = (mblk_t *)NULL;
+                                                   if (canput(parse->parse_queue->q_next) && (nmp = allocb(sizeof(parsetime_t), BPRI_MED)))
+                                                   {
+                                                           bcopy((caddr_t)&parse->parse_io.parse_dtime, (caddr_t)nmp->b_rptr, sizeof(parsetime_t));
+                                                           nmp->b_wptr += sizeof(parsetime_t);
+                                                           putnext(parse->parse_queue, nmp);
+                                                   }
+                                                   else
+                                                       if (nmp) freemsg(nmp);
+                                                   parse_iodone(&parse->parse_io);
+                                           }
+                                           freemsg(mp);
+                                   }
+                                   break;
+                           }
+                   }
+
+                   /*
+                    * CD PPS support for non direct ISR hack
+                    */
+           case M_HANGUP:
+           case M_UNHANGUP:
+                   {
+                           register parsestream_t * parse = (parsestream_t *)(void *)q->q_ptr;
+                           timestamp_t ctime;
+                           register mblk_t *nmp;
+                           register int status = cd_invert ^ (type == M_UNHANGUP);
+
+                           uniqtime(&ctime.tv);
+       
+                           parseprintf(DD_RPUT,("parse: parserput - M_%sHANGUP\n", (type == M_HANGUP) ? "" : "UN"));
+
+                           if ((parse->parse_status & PARSE_ENABLE) &&
+                               parse_iopps(&parse->parse_io, (int)(status ? SYNC_ONE : SYNC_ZERO), &ctime))
+                           {
+                                   nmp = (mblk_t *)NULL;
+                                   if (canput(parse->parse_queue->q_next) && (nmp = allocb(sizeof(parsetime_t), BPRI_MED)))
+                                   {
+                                           bcopy((caddr_t)&parse->parse_io.parse_dtime, (caddr_t)nmp->b_rptr, sizeof(parsetime_t));
+                                           nmp->b_wptr += sizeof(parsetime_t);
+                                           putnext(parse->parse_queue, nmp);
+                                   }
+                                   else
+                                       if (nmp) freemsg(nmp);
+                                   parse_iodone(&parse->parse_io);
+                                   freemsg(mp);
+                           }
+                           else
+                               if (canput(q->q_next) || (mp->b_datap->db_type > QPCTL))
+                               {
+                                       putnext(q, mp);
+                               }
+                               else
+                                   putq(q, mp);
+       
+                           if (status)
+                           {
+                                   parse->parse_ppsclockev.tv = ctime.tv;
+                                   ++(parse->parse_ppsclockev.serial);
+                           }
+                   }
+       }
+       return 0;
+}
+
+static int  init_zs_linemon  P((queue_t *, queue_t *));        /* handle line monitor for "zs" driver */
+static void close_zs_linemon P((queue_t *, queue_t *));
+
+/*-------------------- CD isr status monitor ---------------*/
+
+static int
+init_linemon(
+       register queue_t *q
+       )
+{
+       register queue_t *dq;
+  
+       dq = WR(q);
+       /*
+        * we ARE doing very bad things down here (basically stealing ISR
+        * hooks)
+        *
+        * so we chase down the STREAMS stack searching for the driver
+        * and if this is a known driver we insert our ISR routine for
+        * status changes in to the ExternalStatus handling hook
+        */
+       while (dq->q_next)
+       {
+               dq = dq->q_next;                /* skip down to driver */
+       }
+
+       /*
+        * find appropriate driver dependent routine
+        */
+       if (dq->q_qinfo && dq->q_qinfo->qi_minfo)
+       {
+               register char *dname = dq->q_qinfo->qi_minfo->mi_idname;
+
+               parseprintf(DD_INSTALL, ("init_linemon: driver is \"%s\"\n", dname));
+
+#ifdef sun
+               if (dname && !Strcmp(dname, "zs"))
+               {
+                       return init_zs_linemon(dq, q);
+               }
+               else
+#endif
+               {
+                       parseprintf(DD_INSTALL, ("init_linemon: driver \"%s\" not suitable for CD monitoring\n", dname));
+                       return 0;
+               }
+       }
+       parseprintf(DD_INSTALL, ("init_linemon: cannot find driver\n"));
+       return 0;
+}
+
+static void
+close_linemon(
+       register queue_t *q,
+       register queue_t *my_q
+       )
+{
+       /*
+        * find appropriate driver dependent routine
+        */
+       if (q->q_qinfo && q->q_qinfo->qi_minfo)
+       {
+               register char *dname = q->q_qinfo->qi_minfo->mi_idname;
+
+#ifdef sun
+               if (dname && !Strcmp(dname, "zs"))
+               {
+                       close_zs_linemon(q, my_q);
+                       return;
+               }
+               parseprintf(DD_INSTALL, ("close_linemon: cannot find driver close routine for \"%s\"\n", dname));
+#endif
+       }
+       parseprintf(DD_INSTALL, ("close_linemon: cannot find driver name\n"));
+}
+
+#ifdef sun
+
+#include <sundev/zsreg.h>
+#include <sundev/zscom.h>
+#include <sundev/zsvar.h>
+
+static unsigned long cdmask  = ZSRR0_CD;
+
+struct savedzsops
+{
+       struct zsops  zsops;
+       struct zsops *oldzsops;
+};
+
+struct zsops   *emergencyzs;
+extern void zsopinit   P((struct zscom *, struct zsops *));
+static int  zs_xsisr   P((struct zscom *));    /* zs external status interupt handler */
+
+static int
+init_zs_linemon(
+       register queue_t *q,
+       register queue_t *my_q
+       )
+{
+       register struct zscom *zs;
+       register struct savedzsops *szs;
+       register parsestream_t  *parsestream = (parsestream_t *)(void *)my_q->q_ptr;
+       /*
+        * we expect the zsaline pointer in the q_data pointer
+        * from there on we insert our on EXTERNAL/STATUS ISR routine
+        * into the interrupt path, before the standard handler
+        */
+       zs = ((struct zsaline *)(void *)q->q_ptr)->za_common;
+       if (!zs)
+       {
+               /*
+                * well - not found on startup - just say no (shouldn't happen though)
+                */
+               return 0;
+       }
+       else
+       {
+               unsigned long s;
+      
+               /*
+                * we do a direct replacement, in case others fiddle also
+                * if somebody else grabs our hook and we disconnect
+                * we are in DEEP trouble - panic is likely to be next, sorry
+                */
+               szs = (struct savedzsops *)(void *)kmem_alloc(sizeof(struct savedzsops));
+
+               if (szs == (struct savedzsops *)0)
+               {
+                       parseprintf(DD_INSTALL, ("init_zs_linemon: CD monitor NOT installed - no memory\n"));
+
+                       return 0;
+               }
+               else
+               {
+                       parsestream->parse_data   = (void *)szs;
+
+                       s = splhigh();
+
+                       parsestream->parse_dqueue = q; /* remember driver */
+
+                       szs->zsops            = *zs->zs_ops;
+                       szs->zsops.zsop_xsint = zs_xsisr; /* place our bastard */
+                       szs->oldzsops         = zs->zs_ops;
+                       emergencyzs           = zs->zs_ops;
+         
+                       zsopinit(zs, &szs->zsops); /* hook it up */
+         
+                       (void) splx(s);
+
+                       parseprintf(DD_INSTALL, ("init_zs_linemon: CD monitor installed\n"));
+
+                       return 1;
+               }
+       }
+}
+
+/*
+ * unregister our ISR routine - must call under splhigh()
+ */
+static void
+close_zs_linemon(
+       register queue_t *q,
+       register queue_t *my_q
+       )
+{
+       register struct zscom *zs;
+       register parsestream_t  *parsestream = (parsestream_t *)(void *)my_q->q_ptr;
+
+       zs = ((struct zsaline *)(void *)q->q_ptr)->za_common;
+       if (!zs)
+       {
+               /*
+                * well - not found on startup - just say no (shouldn't happen though)
+                */
+               return;
+       }
+       else
+       {
+               register struct savedzsops *szs = (struct savedzsops *)parsestream->parse_data;
+      
+               zsopinit(zs, szs->oldzsops); /* reset to previous handler functions */
+
+               kmem_free((caddr_t)szs, sizeof (struct savedzsops));
+      
+               parseprintf(DD_INSTALL, ("close_zs_linemon: CD monitor deleted\n"));
+               return;
+       }
+}
+
+#define MAXDEPTH 50            /* maximum allowed stream crawl */
+
+#ifdef PPS_SYNC
+extern void hardpps P((struct timeval *, long));
+#ifdef PPS_NEW
+extern struct timeval timestamp;
+#else
+extern struct timeval pps_time;
+#endif
+#endif
+
+/*
+ * take external status interrupt (only CD interests us)
+ */
+static int
+zs_xsisr(
+        struct zscom *zs
+       )
+{
+       register struct zsaline *za = (struct zsaline *)(void *)zs->zs_priv;
+       register struct zscc_device *zsaddr = zs->zs_addr;
+       register queue_t *q;
+       register unsigned char zsstatus;
+       register int loopcheck;
+       register char *dname;
+#ifdef PPS_SYNC
+       register unsigned int s;
+       register long usec;
+#endif
+
+       /*
+        * pick up current state
+        */
+       zsstatus = zsaddr->zscc_control;
+
+       if ((za->za_rr0 ^ zsstatus) & (cdmask))
+       {
+               timestamp_t cdevent;
+               register int status;
+      
+               za->za_rr0 = (za->za_rr0 & ~(cdmask)) | (zsstatus & (cdmask));
+
+#ifdef PPS_SYNC
+               s = splclock();
+#ifdef PPS_NEW
+               usec = timestamp.tv_usec;
+#else
+               usec = pps_time.tv_usec;
+#endif
+#endif
+               /*
+                * time stamp
+                */
+               uniqtime(&cdevent.tv);
+      
+#ifdef PPS_SYNC
+               (void)splx(s);
+#endif
+
+               /*
+                * logical state
+                */
+               status = cd_invert ? (zsstatus & cdmask) == 0 : (zsstatus & cdmask) != 0;
+
+#ifdef PPS_SYNC
+               if (status)
+               {
+                       usec = cdevent.tv.tv_usec - usec;
+                       if (usec < 0)
+                           usec += 1000000;
+
+                       hardpps(&cdevent.tv, usec);
+               }
+#endif
+
+               q = za->za_ttycommon.t_readq;
+
+               /*
+                * ok - now the hard part - find ourself
+                */
+               loopcheck = MAXDEPTH;
+      
+               while (q)
+               {
+                       if (q->q_qinfo && q->q_qinfo->qi_minfo)
+                       {
+                               dname = q->q_qinfo->qi_minfo->mi_idname;
+
+                               if (!Strcmp(dname, parseinfo.st_rdinit->qi_minfo->mi_idname))
+                               {
+                                       /*
+                                        * back home - phew (hopping along stream queues might
+                                        * prove dangerous to your health)
+                                        */
+
+                                       if ((((parsestream_t *)(void *)q->q_ptr)->parse_status & PARSE_ENABLE) &&
+                                           parse_iopps(&((parsestream_t *)(void *)q->q_ptr)->parse_io, (int)(status ? SYNC_ONE : SYNC_ZERO), &cdevent))
+                                       {
+                                               /*
+                                                * XXX - currently we do not pass up the message, as
+                                                * we should.
+                                                * for a correct behaviour wee need to block out
+                                                * processing until parse_iodone has been posted via
+                                                * a softcall-ed routine which does the message pass-up
+                                                * right now PPS information relies on input being
+                                                * received
+                                                */
+                                               parse_iodone(&((parsestream_t *)(void *)q->q_ptr)->parse_io);
+                                       }
+                 
+                                       if (status)
+                                       {
+                                               ((parsestream_t *)(void *)q->q_ptr)->parse_ppsclockev.tv = cdevent.tv;
+                                               ++(((parsestream_t *)(void *)q->q_ptr)->parse_ppsclockev.serial);
+                                       }
+
+                                       parseprintf(DD_ISR, ("zs_xsisr: CD event %s has been posted for \"%s\"\n", status ? "ONE" : "ZERO", dname));
+                                       break;
+                               }
+                       }
+
+                       q = q->q_next;
+
+                       if (!loopcheck--)
+                       {
+                               panic("zs_xsisr: STREAMS Queue corrupted - CD event");
+                       }
+               }
+
+               /*
+                * only pretend that CD has been handled
+                */
+               ZSDELAY(2);
+
+               if (!((za->za_rr0 ^ zsstatus) & ~(cdmask)))
+               {
+                       /*
+                        * all done - kill status indication and return
+                        */
+                       zsaddr->zscc_control = ZSWR0_RESET_STATUS; /* might kill other conditions here */
+                       return 0;
+               }
+       }      
+
+       if (zsstatus & cdmask)  /* fake CARRIER status */
+               za->za_flags |= ZAS_CARR_ON;
+       else
+               za->za_flags &= ~ZAS_CARR_ON;
+       
+       /*
+        * we are now gathered here to process some unusual external status
+        * interrupts.
+        * any CD events have also been handled and shouldn't be processed
+        * by the original routine (unless we have a VERY busy port pin)
+        * some initializations are done here, which could have been done before for
+        * both code paths but have been avoided for minimum path length to
+        * the uniq_time routine
+        */
+       dname = (char *) 0;
+       q = za->za_ttycommon.t_readq;
+
+       loopcheck = MAXDEPTH;
+      
+       /*
+        * the real thing for everything else ...
+        */
+       while (q)
+       {
+               if (q->q_qinfo && q->q_qinfo->qi_minfo)
+               {
+                       dname = q->q_qinfo->qi_minfo->mi_idname;
+                       if (!Strcmp(dname, parseinfo.st_rdinit->qi_minfo->mi_idname))
+                       {
+                               register int (*zsisr) P((struct zscom *));
+                 
+                               /*
+                                * back home - phew (hopping along stream queues might
+                                * prove dangerous to your health)
+                                */
+                               if ((zsisr = ((struct savedzsops *)((parsestream_t *)(void *)q->q_ptr)->parse_data)->oldzsops->zsop_xsint))
+                                       return zsisr(zs);
+                               else
+                                   panic("zs_xsisr: unable to locate original ISR");
+                 
+                               parseprintf(DD_ISR, ("zs_xsisr: non CD event was processed for \"%s\"\n", dname));
+                               /*
+                                * now back to our program ...
+                                */
+                               return 0;
+                       }
+               }
+
+               q = q->q_next;
+
+               if (!loopcheck--)
+               {
+                       panic("zs_xsisr: STREAMS Queue corrupted - non CD event");
+               }
+       }
+
+       /*
+        * last resort - shouldn't even come here as it indicates
+        * corrupted TTY structures
+        */
+       printf("zs_zsisr: looking for \"%s\" - found \"%s\" - taking EMERGENCY path\n", parseinfo.st_rdinit->qi_minfo->mi_idname, dname ? dname : "-NIL-");
+      
+       if (emergencyzs && emergencyzs->zsop_xsint)
+           emergencyzs->zsop_xsint(zs);
+       else
+           panic("zs_xsisr: no emergency ISR handler");
+       return 0;
+}
+#endif                         /* sun */
+
+/*
+ * History:
+ *
+ * parsestreams.c,v
+ * Revision 4.11  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.10  2004/11/14 16:06:08  kardel
+ * update Id tags
+ *
+ * Revision 4.9  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.7  1999/11/28 09:13:53  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.6  1998/12/20 23:45:31  kardel
+ * fix types and warnings
+ *
+ * Revision 4.5  1998/11/15 21:23:38  kardel
+ * ntp_memset() replicated in Sun kernel files
+ *
+ * Revision 4.4  1998/06/13 12:15:59  kardel
+ * superfluous variable removed
+ *
+ * Revision 4.3  1998/06/12 15:23:08  kardel
+ * fix prototypes
+ * adjust for ansi2knr
+ *
+ * Revision 4.2  1998/05/24 18:16:22  kardel
+ * moved copy of shadow status to the beginning
+ *
+ * Revision 4.1  1998/05/24 09:38:47  kardel
+ * streams initiated iopps calls (M_xHANGUP) are now consistent with the
+ * respective calls from zs_xsisr()
+ * simulation of CARRIER status to avoid unecessary M_xHANGUP messages
+ *
+ * Revision 4.0  1998/04/10 19:45:38  kardel
+ * Start 4.0 release version numbering
+ *
+ * from V3 3.37 log info deleted 1998/04/11 kardel
+ */
diff --git a/libparse/trim_info.c b/libparse/trim_info.c
new file mode 100644 (file)
index 0000000..8fdc4f6
--- /dev/null
@@ -0,0 +1,69 @@
+/*
+ * /src/NTP/ntp4-dev/libparse/trim_info.c,v 4.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * trim_info.c,v 4.5 2005/04/16 17:32:10 kardel RELEASE_20050508_A
+ *
+ * $Created: Sun Aug  2 20:20:34 1998 $
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+#include "ntp_types.h"
+#include "trimble.h"
+
+cmd_info_t *
+trimble_convert(
+               unsigned int cmd,
+               cmd_info_t   *tbl
+               )
+{
+  int i;
+
+  for (i = 0; tbl[i].cmd != 0xFF; i++)
+    {
+      if (tbl[i].cmd == cmd)
+       return &tbl[i];
+    }
+  return 0;
+}
+
+/*
+ * trim_info.c,v
+ * Revision 4.5  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.4  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.2  1998/12/20 23:45:31  kardel
+ * fix types and warnings
+ *
+ * Revision 4.1  1998/08/09 22:27:48  kardel
+ * Trimble TSIP support
+ *
+ */
diff --git a/ltmain.sh b/ltmain.sh
new file mode 100644 (file)
index 0000000..06823e0
--- /dev/null
+++ b/ltmain.sh
@@ -0,0 +1,6863 @@
+# ltmain.sh - Provide generalized library-building support services.
+# NOTE: Changing this file will not affect anything until you rerun configure.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+basename="s,^.*/,,g"
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+# The name of this program:
+progname=`echo "$progpath" | $SED $basename`
+modename="$progname"
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=1.5.22
+TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes.
+if test -n "${ZSH_VERSION+set}" ; then
+  setopt NO_GLOB_SUBST
+fi
+
+# Check that we have a working $echo.
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell, and then maybe $echo will work.
+  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit $EXIT_SUCCESS
+fi
+
+default_mode=
+help="Try \`$progname --help' for more information."
+magic="%%%MAGIC variable%%%"
+mkdir="mkdir"
+mv="mv -f"
+rm="rm -f"
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  SP2NL='tr \040 \012'
+  NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  SP2NL='tr \100 \n'
+  NL2SP='tr \r\n \100\100'
+  ;;
+esac
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+# We save the old values to restore during execute mode.
+if test "${LC_ALL+set}" = set; then
+  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
+fi
+if test "${LANG+set}" = set; then
+  save_LANG="$LANG"; LANG=C; export LANG
+fi
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS="  $lt_nl"
+
+if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+  $echo "$modename: not configured to build any kind of library" 1>&2
+  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+  exit $EXIT_FAILURE
+fi
+
+# Global variables.
+mode=$default_mode
+nonopt=
+prev=
+prevopt=
+run=
+show="$echo"
+show_help=
+execute_dlfiles=
+duplicate_deps=no
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+
+#####################################
+# Shell function definitions:
+# This seems to be the best place for them
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible.  If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+    my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+    if test "$run" = ":"; then
+      # Return a directory name, but don't create it in dry-run mode
+      my_tmpdir="${my_template}-$$"
+    else
+
+      # If mktemp works, use that first and foremost
+      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+      if test ! -d "$my_tmpdir"; then
+       # Failing that, at least try and use $RANDOM to avoid a race
+       my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+       save_mktempdir_umask=`umask`
+       umask 0077
+       $mkdir "$my_tmpdir"
+       umask $save_mktempdir_umask
+      fi
+
+      # If we're not in dry-run mode, bomb out on failure
+      test -d "$my_tmpdir" || {
+        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
+       exit $EXIT_FAILURE
+      }
+    fi
+
+    $echo "X$my_tmpdir" | $Xsed
+}
+
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+func_win32_libid ()
+{
+  win32_libid_type="unknown"
+  win32_fileres=`file -L $1 2>/dev/null`
+  case $win32_fileres in
+  *ar\ archive\ import\ library*) # definitely import
+    win32_libid_type="x86 archive import"
+    ;;
+  *ar\ archive*) # could be an import, or static
+    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
+      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+      win32_nmres=`eval $NM -f posix -A $1 | \
+       $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
+      case $win32_nmres in
+      import*)  win32_libid_type="x86 archive import";;
+      *)        win32_libid_type="x86 archive static";;
+      esac
+    fi
+    ;;
+  *DLL*)
+    win32_libid_type="x86 DLL"
+    ;;
+  *executable*) # but shell scripts are "executable" too...
+    case $win32_fileres in
+    *MS\ Windows\ PE\ Intel*)
+      win32_libid_type="x86 DLL"
+      ;;
+    esac
+    ;;
+  esac
+  $echo $win32_libid_type
+}
+
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+    if test -n "$available_tags" && test -z "$tagname"; then
+      CC_quoted=
+      for arg in $CC; do
+       case $arg in
+         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+         arg="\"$arg\""
+         ;;
+       esac
+       CC_quoted="$CC_quoted $arg"
+      done
+      case $@ in
+      # Blanks in the command may have been stripped by the calling shell,
+      # but not from the CC environment variable when configure was run.
+      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
+      # Blanks at the start of $base_compile will cause this to fail
+      # if we don't check for them as well.
+      *)
+       for z in $available_tags; do
+         if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+           # Evaluate the configuration.
+           eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+           CC_quoted=
+           for arg in $CC; do
+           # Double-quote args containing other shell metacharacters.
+           case $arg in
+             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
+             arg="\"$arg\""
+             ;;
+           esac
+           CC_quoted="$CC_quoted $arg"
+         done
+           case "$@ " in
+             " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
+             # The compiler in the base compile command matches
+             # the one in the tagged configuration.
+             # Assume this is the tagged configuration we want.
+             tagname=$z
+             break
+             ;;
+           esac
+         fi
+       done
+       # If $tagname still isn't set, then no tagged configuration
+       # was found and let the user know that the "--tag" command
+       # line option must be used.
+       if test -z "$tagname"; then
+         $echo "$modename: unable to infer tagged configuration"
+         $echo "$modename: specify a tag with \`--tag'" 1>&2
+         exit $EXIT_FAILURE
+#        else
+#          $echo "$modename: using $tagname tagged configuration"
+       fi
+       ;;
+      esac
+    fi
+}
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+    f_ex_an_ar_dir="$1"; shift
+    f_ex_an_ar_oldlib="$1"
+
+    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
+    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
+    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
+      exit $EXIT_FAILURE
+    fi
+}
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+    my_gentop="$1"; shift
+    my_oldlibs=${1+"$@"}
+    my_oldobjs=""
+    my_xlib=""
+    my_xabs=""
+    my_xdir=""
+    my_status=""
+
+    $show "${rm}r $my_gentop"
+    $run ${rm}r "$my_gentop"
+    $show "$mkdir $my_gentop"
+    $run $mkdir "$my_gentop"
+    my_status=$?
+    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
+      exit $my_status
+    fi
+
+    for my_xlib in $my_oldlibs; do
+      # Extract the objects.
+      case $my_xlib in
+       [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+       *) my_xabs=`pwd`"/$my_xlib" ;;
+      esac
+      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
+      my_xdir="$my_gentop/$my_xlib"
+
+      $show "${rm}r $my_xdir"
+      $run ${rm}r "$my_xdir"
+      $show "$mkdir $my_xdir"
+      $run $mkdir "$my_xdir"
+      exit_status=$?
+      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
+       exit $exit_status
+      fi
+      case $host in
+      *-darwin*)
+       $show "Extracting $my_xabs"
+       # Do not bother doing anything if just a dry run
+       if test -z "$run"; then
+         darwin_orig_dir=`pwd`
+         cd $my_xdir || exit $?
+         darwin_archive=$my_xabs
+         darwin_curdir=`pwd`
+         darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
+         darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
+         if test -n "$darwin_arches"; then 
+           darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
+           darwin_arch=
+           $show "$darwin_base_archive has multiple architectures $darwin_arches"
+           for darwin_arch in  $darwin_arches ; do
+             mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+             lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+             cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+             func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+             cd "$darwin_curdir"
+             $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+           done # $darwin_arches
+      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
+           darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
+           darwin_file=
+           darwin_files=
+           for darwin_file in $darwin_filelist; do
+             darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
+             lipo -create -output "$darwin_file" $darwin_files
+           done # $darwin_filelist
+           ${rm}r unfat-$$
+           cd "$darwin_orig_dir"
+         else
+           cd "$darwin_orig_dir"
+           func_extract_an_archive "$my_xdir" "$my_xabs"
+         fi # $darwin_arches
+       fi # $run
+       ;;
+      *)
+        func_extract_an_archive "$my_xdir" "$my_xabs"
+        ;;
+      esac
+      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+    done
+    func_extract_archives_result="$my_oldobjs"
+}
+# End of Shell function definitions
+#####################################
+
+# Darwin sucks
+eval std_shrext=\"$shrext_cmds\"
+
+disable_libs=no
+
+# Parse our command line options once, thoroughly.
+while test "$#" -gt 0
+do
+  arg="$1"
+  shift
+
+  case $arg in
+  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) optarg= ;;
+  esac
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$prev"; then
+    case $prev in
+    execute_dlfiles)
+      execute_dlfiles="$execute_dlfiles $arg"
+      ;;
+    tag)
+      tagname="$arg"
+      preserve_args="${preserve_args}=$arg"
+
+      # Check whether tagname contains only valid characters
+      case $tagname in
+      *[!-_A-Za-z0-9,/]*)
+       $echo "$progname: invalid tag name: $tagname" 1>&2
+       exit $EXIT_FAILURE
+       ;;
+      esac
+
+      case $tagname in
+      CC)
+       # Don't test for the "default" C tag, as we know, it's there, but
+       # not specially marked.
+       ;;
+      *)
+       if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
+         taglist="$taglist $tagname"
+         # Evaluate the configuration.
+         eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
+       else
+         $echo "$progname: ignoring unknown tag $tagname" 1>&2
+       fi
+       ;;
+      esac
+      ;;
+    *)
+      eval "$prev=\$arg"
+      ;;
+    esac
+
+    prev=
+    prevopt=
+    continue
+  fi
+
+  # Have we seen a non-optional argument yet?
+  case $arg in
+  --help)
+    show_help=yes
+    ;;
+
+  --version)
+    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
+    $echo
+    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
+    $echo "This is free software; see the source for copying conditions.  There is NO"
+    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+    exit $?
+    ;;
+
+  --config)
+    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
+    # Now print the configurations for the tags.
+    for tagname in $taglist; do
+      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
+    done
+    exit $?
+    ;;
+
+  --debug)
+    $echo "$progname: enabling shell trace mode"
+    set -x
+    preserve_args="$preserve_args $arg"
+    ;;
+
+  --dry-run | -n)
+    run=:
+    ;;
+
+  --features)
+    $echo "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      $echo "enable shared libraries"
+    else
+      $echo "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      $echo "enable static libraries"
+    else
+      $echo "disable static libraries"
+    fi
+    exit $?
+    ;;
+
+  --finish) mode="finish" ;;
+
+  --mode) prevopt="--mode" prev=mode ;;
+  --mode=*) mode="$optarg" ;;
+
+  --preserve-dup-deps) duplicate_deps="yes" ;;
+
+  --quiet | --silent)
+    show=:
+    preserve_args="$preserve_args $arg"
+    ;;
+
+  --tag)
+    prevopt="--tag"
+    prev=tag
+    preserve_args="$preserve_args --tag"
+    ;;
+  --tag=*)
+    set tag "$optarg" ${1+"$@"}
+    shift
+    prev=tag
+    preserve_args="$preserve_args --tag"
+    ;;
+
+  -dlopen)
+    prevopt="-dlopen"
+    prev=execute_dlfiles
+    ;;
+
+  -*)
+    $echo "$modename: unrecognized option \`$arg'" 1>&2
+    $echo "$help" 1>&2
+    exit $EXIT_FAILURE
+    ;;
+
+  *)
+    nonopt="$arg"
+    break
+    ;;
+  esac
+done
+
+if test -n "$prevopt"; then
+  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
+  $echo "$help" 1>&2
+  exit $EXIT_FAILURE
+fi
+
+case $disable_libs in
+no) 
+  ;;
+shared)
+  build_libtool_libs=no
+  build_old_libs=yes
+  ;;
+static)
+  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+  ;;
+esac
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+if test -z "$show_help"; then
+
+  # Infer the operation mode.
+  if test -z "$mode"; then
+    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
+    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
+    case $nonopt in
+    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
+      mode=link
+      for arg
+      do
+       case $arg in
+       -c)
+          mode=compile
+          break
+          ;;
+       esac
+      done
+      ;;
+    *db | *dbx | *strace | *truss)
+      mode=execute
+      ;;
+    *install*|cp|mv)
+      mode=install
+      ;;
+    *rm)
+      mode=uninstall
+      ;;
+    *)
+      # If we have no mode, but dlfiles were specified, then do execute mode.
+      test -n "$execute_dlfiles" && mode=execute
+
+      # Just use the default operation mode.
+      if test -z "$mode"; then
+       if test -n "$nonopt"; then
+         $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
+       else
+         $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
+       fi
+      fi
+      ;;
+    esac
+  fi
+
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
+    $echo "$help" 1>&2
+    exit $EXIT_FAILURE
+  fi
+
+  # Change the help message to a mode-specific one.
+  generic_help="$help"
+  help="Try \`$modename --help --mode=$mode' for more information."
+
+  # These modes are in order of execution frequency so that they run quickly.
+  case $mode in
+  # libtool compile mode
+  compile)
+    modename="$modename: compile"
+    # Get the compilation command and the source file.
+    base_compile=
+    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    suppress_opt=yes
+    suppress_output=
+    arg_mode=normal
+    libobj=
+    later=
+
+    for arg
+    do
+      case $arg_mode in
+      arg  )
+       # do not "continue".  Instead, add this to base_compile
+       lastarg="$arg"
+       arg_mode=normal
+       ;;
+
+      target )
+       libobj="$arg"
+       arg_mode=normal
+       continue
+       ;;
+
+      normal )
+       # Accept any command-line options.
+       case $arg in
+       -o)
+         if test -n "$libobj" ; then
+           $echo "$modename: you cannot specify \`-o' more than once" 1>&2
+           exit $EXIT_FAILURE
+         fi
+         arg_mode=target
+         continue
+         ;;
+
+       -static | -prefer-pic | -prefer-non-pic)
+         later="$later $arg"
+         continue
+         ;;
+
+       -no-suppress)
+         suppress_opt=no
+         continue
+         ;;
+
+       -Xcompiler)
+         arg_mode=arg  #  the next one goes into the "base_compile" arg list
+         continue      #  The current "srcfile" will either be retained or
+         ;;            #  replaced later.  I would guess that would be a bug.
+
+       -Wc,*)
+         args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
+         lastarg=
+         save_ifs="$IFS"; IFS=','
+         for arg in $args; do
+           IFS="$save_ifs"
+
+           # Double-quote args containing other shell metacharacters.
+           # Many Bourne shells cannot handle close brackets correctly
+           # in scan sets, so we specify it separately.
+           case $arg in
+             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
+             arg="\"$arg\""
+             ;;
+           esac
+           lastarg="$lastarg $arg"
+         done
+         IFS="$save_ifs"
+         lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
+
+         # Add the arguments to base_compile.
+         base_compile="$base_compile $lastarg"
+         continue
+         ;;
+
+       * )
+         # Accept the current argument as the source file.
+         # The previous "srcfile" becomes the current argument.
+         #
+         lastarg="$srcfile"
+         srcfile="$arg"
+         ;;
+       esac  #  case $arg
+       ;;
+      esac    #  case $arg_mode
+
+      # Aesthetically quote the previous argument.
+      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
+
+      case $lastarg in
+      # Double-quote args containing other shell metacharacters.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, and some SunOS ksh mistreat backslash-escaping
+      # in scan sets (worked around with variable expansion),
+      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
+      # at all, so we specify them separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+       lastarg="\"$lastarg\""
+       ;;
+      esac
+
+      base_compile="$base_compile $lastarg"
+    done # for arg
+
+    case $arg_mode in
+    arg)
+      $echo "$modename: you must specify an argument for -Xcompile"
+      exit $EXIT_FAILURE
+      ;;
+    target)
+      $echo "$modename: you must specify a target with \`-o'" 1>&2
+      exit $EXIT_FAILURE
+      ;;
+    *)
+      # Get the name of the library object.
+      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    xform='[cCFSifmso]'
+    case $libobj in
+    *.ada) xform=ada ;;
+    *.adb) xform=adb ;;
+    *.ads) xform=ads ;;
+    *.asm) xform=asm ;;
+    *.c++) xform=c++ ;;
+    *.cc) xform=cc ;;
+    *.ii) xform=ii ;;
+    *.class) xform=class ;;
+    *.cpp) xform=cpp ;;
+    *.cxx) xform=cxx ;;
+    *.f90) xform=f90 ;;
+    *.for) xform=for ;;
+    *.java) xform=java ;;
+    esac
+
+    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
+
+    case $libobj in
+    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
+    *)
+      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
+      exit $EXIT_FAILURE
+      ;;
+    esac
+
+    func_infer_tag $base_compile
+
+    for arg in $later; do
+      case $arg in
+      -static)
+       build_old_libs=yes
+       continue
+       ;;
+
+      -prefer-pic)
+       pic_mode=yes
+       continue
+       ;;
+
+      -prefer-non-pic)
+       pic_mode=no
+       continue
+       ;;
+      esac
+    done
+
+    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
+    case $qlibobj in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+       qlibobj="\"$qlibobj\"" ;;
+    esac
+    test "X$libobj" != "X$qlibobj" \
+       && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"'  &()|`$[]' \
+       && $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
+    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+    if test "X$xdir" = "X$obj"; then
+      xdir=
+    else
+      xdir=$xdir/
+    fi
+    lobj=${xdir}$objdir/$objname
+
+    if test -z "$base_compile"; then
+      $echo "$modename: you must specify a compilation command" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $lobj $libobj ${libobj}T"
+    else
+      removelist="$lobj $libobj ${libobj}T"
+    fi
+
+    $run $rm $removelist
+    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
+
+    # On Cygwin there's no "real" PIC flag so we must build both object types
+    case $host_os in
+    cygwin* | mingw* | pw32* | os2*)
+      pic_mode=default
+      ;;
+    esac
+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+      # non-PIC code in shared libraries is not supported
+      pic_mode=default
+    fi
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+      removelist="$removelist $output_obj $lockfile"
+      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
+    else
+      output_obj=
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
+       $show "Waiting for $lockfile to be removed"
+       sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+       $echo "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit $EXIT_FAILURE
+      fi
+      $echo "$srcfile" > "$lockfile"
+    fi
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
+    case $qsrcfile in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+      qsrcfile="\"$qsrcfile\"" ;;
+    esac
+
+    $run $rm "$libobj" "${libobj}T"
+
+    # Create a libtool object file (analogous to a ".la" file),
+    # but don't create it if we're doing a dry run.
+    test -z "$run" && cat > ${libobj}T <<EOF
+# $libobj - a libtool object file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+EOF
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      if test "$pic_mode" != no; then
+       command="$base_compile $qsrcfile $pic_flag"
+      else
+       # Don't build PIC code
+       command="$base_compile $qsrcfile"
+      fi
+
+      if test ! -d "${xdir}$objdir"; then
+       $show "$mkdir ${xdir}$objdir"
+       $run $mkdir ${xdir}$objdir
+       exit_status=$?
+       if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
+         exit $exit_status
+       fi
+      fi
+
+      if test -z "$output_obj"; then
+       # Place PIC objects in $objdir
+       command="$command -o $lobj"
+      fi
+
+      $run $rm "$lobj" "$output_obj"
+
+      $show "$command"
+      if $run eval "$command"; then :
+      else
+       test -n "$output_obj" && $run $rm $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      if test "$need_locks" = warn &&
+        test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+       $echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+       $show "$mv $output_obj $lobj"
+       if $run $mv $output_obj $lobj; then :
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
+      fi
+
+      # Append the name of the PIC object to the libtool object file.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+pic_object='$objdir/$objname'
+
+EOF
+
+      # Allow error messages only from the first compilation.
+      if test "$suppress_opt" = yes; then
+        suppress_output=' >/dev/null 2>&1'
+      fi
+    else
+      # No PIC object so indicate it doesn't exist in the libtool
+      # object file.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+pic_object=none
+
+EOF
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      if test "$pic_mode" != yes; then
+       # Don't build PIC code
+       command="$base_compile $qsrcfile"
+      else
+       command="$base_compile $qsrcfile $pic_flag"
+      fi
+      if test "$compiler_c_o" = yes; then
+       command="$command -o $obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      $run $rm "$obj" "$output_obj"
+      $show "$command"
+      if $run eval "$command"; then :
+      else
+       $run $rm $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      if test "$need_locks" = warn &&
+        test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+       $echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed
+      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+       $show "$mv $output_obj $obj"
+       if $run $mv $output_obj $obj; then :
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
+      fi
+
+      # Append the name of the non-PIC object the libtool object file.
+      # Only append if the libtool object file exists.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+# Name of the non-PIC object.
+non_pic_object='$objname'
+
+EOF
+    else
+      # Append the name of the non-PIC object the libtool object file.
+      # Only append if the libtool object file exists.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+# Name of the non-PIC object.
+non_pic_object=none
+
+EOF
+    fi
+
+    $run $mv "${libobj}T" "${libobj}"
+
+    # Unlock the critical section if it was locked
+    if test "$need_locks" != no; then
+      $run $rm "$lockfile"
+    fi
+
+    exit $EXIT_SUCCESS
+    ;;
+
+  # libtool link mode
+  link | relink)
+    modename="$modename: link"
+    case $host in
+    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invocation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    libtool_args="$nonopt"
+    base_compile="$nonopt $@"
+    compile_command="$nonopt"
+    finalize_command="$nonopt"
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    old_deplibs=
+    compiler_flags=
+    linker_flags=
+    dllsearchpath=
+    lib_search_path=`pwd`
+    inst_prefix_dir=
+
+    avoid_version=no
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    ltlibs=
+    module=no
+    no_install=no
+    objs=
+    non_pic_objects=
+    notinst_path= # paths that contain not-installed libtool libraries
+    precious_files_regex=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+    vinfo_number=no
+
+    func_infer_tag $base_compile
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case $arg in
+      -all-static | -static)
+       if test "X$arg" = "X-all-static"; then
+         if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+           $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
+         fi
+         if test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+         prefer_static_libs=yes
+       else
+         if test -z "$pic_flag" && test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+         prefer_static_libs=built
+       fi
+       build_libtool_libs=no
+       build_old_libs=yes
+       break
+       ;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test "$#" -gt 0; do
+      arg="$1"
+      shift
+      case $arg in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+       qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
+       ;;
+      *) qarg=$arg ;;
+      esac
+      libtool_args="$libtool_args $qarg"
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+       case $prev in
+       output)
+         compile_command="$compile_command @OUTPUT@"
+         finalize_command="$finalize_command @OUTPUT@"
+         ;;
+       esac
+
+       case $prev in
+       dlfiles|dlprefiles)
+         if test "$preload" = no; then
+           # Add the symbol object into the linking commands.
+           compile_command="$compile_command @SYMFILE@"
+           finalize_command="$finalize_command @SYMFILE@"
+           preload=yes
+         fi
+         case $arg in
+         *.la | *.lo) ;;  # We handle these cases below.
+         force)
+           if test "$dlself" = no; then
+             dlself=needless
+             export_dynamic=yes
+           fi
+           prev=
+           continue
+           ;;
+         self)
+           if test "$prev" = dlprefiles; then
+             dlself=yes
+           elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+             dlself=yes
+           else
+             dlself=needless
+             export_dynamic=yes
+           fi
+           prev=
+           continue
+           ;;
+         *)
+           if test "$prev" = dlfiles; then
+             dlfiles="$dlfiles $arg"
+           else
+             dlprefiles="$dlprefiles $arg"
+           fi
+           prev=
+           continue
+           ;;
+         esac
+         ;;
+       expsyms)
+         export_symbols="$arg"
+         if test ! -f "$arg"; then
+           $echo "$modename: symbol file \`$arg' does not exist"
+           exit $EXIT_FAILURE
+         fi
+         prev=
+         continue
+         ;;
+       expsyms_regex)
+         export_symbols_regex="$arg"
+         prev=
+         continue
+         ;;
+       inst_prefix)
+         inst_prefix_dir="$arg"
+         prev=
+         continue
+         ;;
+       precious_regex)
+         precious_files_regex="$arg"
+         prev=
+         continue
+         ;;
+       release)
+         release="-$arg"
+         prev=
+         continue
+         ;;
+       objectlist)
+         if test -f "$arg"; then
+           save_arg=$arg
+           moreargs=
+           for fil in `cat $save_arg`
+           do
+#            moreargs="$moreargs $fil"
+             arg=$fil
+             # A libtool-controlled object.
+
+             # Check to see that this really is a libtool object.
+             if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+               pic_object=
+               non_pic_object=
+
+               # Read the .lo file
+               # If there is no directory component, then add one.
+               case $arg in
+               */* | *\\*) . $arg ;;
+               *) . ./$arg ;;
+               esac
+
+               if test -z "$pic_object" || \
+                  test -z "$non_pic_object" ||
+                  test "$pic_object" = none && \
+                  test "$non_pic_object" = none; then
+                 $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+                 exit $EXIT_FAILURE
+               fi
+
+               # Extract subdirectory from the argument.
+               xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+               if test "X$xdir" = "X$arg"; then
+                 xdir=
+               else
+                 xdir="$xdir/"
+               fi
+
+               if test "$pic_object" != none; then
+                 # Prepend the subdirectory the object is found in.
+                 pic_object="$xdir$pic_object"
+
+                 if test "$prev" = dlfiles; then
+                   if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+                     dlfiles="$dlfiles $pic_object"
+                     prev=
+                     continue
+                   else
+                     # If libtool objects are unsupported, then we need to preload.
+                     prev=dlprefiles
+                   fi
+                 fi
+
+                 # CHECK ME:  I think I busted this.  -Ossama
+                 if test "$prev" = dlprefiles; then
+                   # Preload the old-style object.
+                   dlprefiles="$dlprefiles $pic_object"
+                   prev=
+                 fi
+
+                 # A PIC object.
+                 libobjs="$libobjs $pic_object"
+                 arg="$pic_object"
+               fi
+
+               # Non-PIC object.
+               if test "$non_pic_object" != none; then
+                 # Prepend the subdirectory the object is found in.
+                 non_pic_object="$xdir$non_pic_object"
+
+                 # A standard non-PIC object
+                 non_pic_objects="$non_pic_objects $non_pic_object"
+                 if test -z "$pic_object" || test "$pic_object" = none ; then
+                   arg="$non_pic_object"
+                 fi
+               else
+                 # If the PIC object exists, use it instead.
+                 # $xdir was prepended to $pic_object above.
+                 non_pic_object="$pic_object"
+                 non_pic_objects="$non_pic_objects $non_pic_object"
+               fi
+             else
+               # Only an error if not doing a dry-run.
+               if test -z "$run"; then
+                 $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+                 exit $EXIT_FAILURE
+               else
+                 # Dry-run case.
+
+                 # Extract subdirectory from the argument.
+                 xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+                 if test "X$xdir" = "X$arg"; then
+                   xdir=
+                 else
+                   xdir="$xdir/"
+                 fi
+
+                 pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+                 non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+                 libobjs="$libobjs $pic_object"
+                 non_pic_objects="$non_pic_objects $non_pic_object"
+               fi
+             fi
+           done
+         else
+           $echo "$modename: link input file \`$save_arg' does not exist"
+           exit $EXIT_FAILURE
+         fi
+         arg=$save_arg
+         prev=
+         continue
+         ;;
+       rpath | xrpath)
+         # We need an absolute path.
+         case $arg in
+         [\\/]* | [A-Za-z]:[\\/]*) ;;
+         *)
+           $echo "$modename: only absolute run-paths are allowed" 1>&2
+           exit $EXIT_FAILURE
+           ;;
+         esac
+         if test "$prev" = rpath; then
+           case "$rpath " in
+           *" $arg "*) ;;
+           *) rpath="$rpath $arg" ;;
+           esac
+         else
+           case "$xrpath " in
+           *" $arg "*) ;;
+           *) xrpath="$xrpath $arg" ;;
+           esac
+         fi
+         prev=
+         continue
+         ;;
+       xcompiler)
+         compiler_flags="$compiler_flags $qarg"
+         prev=
+         compile_command="$compile_command $qarg"
+         finalize_command="$finalize_command $qarg"
+         continue
+         ;;
+       xlinker)
+         linker_flags="$linker_flags $qarg"
+         compiler_flags="$compiler_flags $wl$qarg"
+         prev=
+         compile_command="$compile_command $wl$qarg"
+         finalize_command="$finalize_command $wl$qarg"
+         continue
+         ;;
+       xcclinker)
+         linker_flags="$linker_flags $qarg"
+         compiler_flags="$compiler_flags $qarg"
+         prev=
+         compile_command="$compile_command $qarg"
+         finalize_command="$finalize_command $qarg"
+         continue
+         ;;
+       shrext)
+         shrext_cmds="$arg"
+         prev=
+         continue
+         ;;
+       darwin_framework|darwin_framework_skip)
+         test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
+         compile_command="$compile_command $arg"
+         finalize_command="$finalize_command $arg"
+         prev=
+         continue
+         ;;
+       *)
+         eval "$prev=\"\$arg\""
+         prev=
+         continue
+         ;;
+       esac
+      fi # test -n "$prev"
+
+      prevarg="$arg"
+
+      case $arg in
+      -all-static)
+       if test -n "$link_static_flag"; then
+         compile_command="$compile_command $link_static_flag"
+         finalize_command="$finalize_command $link_static_flag"
+       fi
+       continue
+       ;;
+
+      -allow-undefined)
+       # FIXME: remove this flag sometime in the future.
+       $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
+       continue
+       ;;
+
+      -avoid-version)
+       avoid_version=yes
+       continue
+       ;;
+
+      -dlopen)
+       prev=dlfiles
+       continue
+       ;;
+
+      -dlpreopen)
+       prev=dlprefiles
+       continue
+       ;;
+
+      -export-dynamic)
+       export_dynamic=yes
+       continue
+       ;;
+
+      -export-symbols | -export-symbols-regex)
+       if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+         $echo "$modename: more than one -exported-symbols argument is not allowed"
+         exit $EXIT_FAILURE
+       fi
+       if test "X$arg" = "X-export-symbols"; then
+         prev=expsyms
+       else
+         prev=expsyms_regex
+       fi
+       continue
+       ;;
+
+      -framework|-arch|-isysroot)
+       case " $CC " in
+         *" ${arg} ${1} "* | *" ${arg} ${1} "*) 
+               prev=darwin_framework_skip ;;
+         *) compiler_flags="$compiler_flags $arg"
+            prev=darwin_framework ;;
+       esac
+       compile_command="$compile_command $arg"
+       finalize_command="$finalize_command $arg"
+       continue
+       ;;
+
+      -inst-prefix-dir)
+       prev=inst_prefix
+       continue
+       ;;
+
+      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+      # so, if we see these flags be careful not to treat them like -L
+      -L[A-Z][A-Z]*:*)
+       case $with_gcc/$host in
+       no/*-*-irix* | /*-*-irix*)
+         compile_command="$compile_command $arg"
+         finalize_command="$finalize_command $arg"
+         ;;
+       esac
+       continue
+       ;;
+
+      -L*)
+       dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
+       # We need an absolute path.
+       case $dir in
+       [\\/]* | [A-Za-z]:[\\/]*) ;;
+       *)
+         absdir=`cd "$dir" && pwd`
+         if test -z "$absdir"; then
+           $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
+           absdir="$dir"
+           notinst_path="$notinst_path $dir"
+         fi
+         dir="$absdir"
+         ;;
+       esac
+       case "$deplibs " in
+       *" -L$dir "*) ;;
+       *)
+         deplibs="$deplibs -L$dir"
+         lib_search_path="$lib_search_path $dir"
+         ;;
+       esac
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+         testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
+         case :$dllsearchpath: in
+         *":$dir:"*) ;;
+         *) dllsearchpath="$dllsearchpath:$dir";;
+         esac
+         case :$dllsearchpath: in
+         *":$testbindir:"*) ;;
+         *) dllsearchpath="$dllsearchpath:$testbindir";;
+         esac
+         ;;
+       esac
+       continue
+       ;;
+
+      -l*)
+       if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+         case $host in
+         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
+           # These systems don't actually have a C or math library (as such)
+           continue
+           ;;
+         *-*-os2*)
+           # These systems don't actually have a C library (as such)
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+           # Do not include libc due to us having libc/libc_r.
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-rhapsody* | *-*-darwin1.[012])
+           # Rhapsody C and math libraries are in the System framework
+           deplibs="$deplibs -framework System"
+           continue
+           ;;
+         *-*-sco3.2v5* | *-*-sco5v6*)
+           # Causes problems with __ctype
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+           # Compiler inserts libc in the correct place for threads to work
+           test "X$arg" = "X-lc" && continue
+           ;;
+         esac
+       elif test "X$arg" = "X-lc_r"; then
+        case $host in
+        *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+          # Do not include libc_r directly, use -pthread flag.
+          continue
+          ;;
+        esac
+       fi
+       deplibs="$deplibs $arg"
+       continue
+       ;;
+
+      # Tru64 UNIX uses -model [arg] to determine the layout of C++
+      # classes, name mangling, and exception handling.
+      -model)
+       compile_command="$compile_command $arg"
+       compiler_flags="$compiler_flags $arg"
+       finalize_command="$finalize_command $arg"
+       prev=xcompiler
+       continue
+       ;;
+
+     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
+       compiler_flags="$compiler_flags $arg"
+       compile_command="$compile_command $arg"
+       finalize_command="$finalize_command $arg"
+       continue
+       ;;
+
+      -module)
+       module=yes
+       continue
+       ;;
+
+      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
+      # -r[0-9][0-9]* specifies the processor on the SGI compiler
+      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
+      # +DA*, +DD* enable 64-bit mode on the HP compiler
+      # -q* pass through compiler args for the IBM compiler
+      # -m* pass through architecture-specific compiler args for GCC
+      # -m*, -t[45]*, -txscale* pass through architecture-specific
+      # compiler args for GCC
+      # -pg pass through profiling flag for GCC
+      # @file GCC response files
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
+      -t[45]*|-txscale*|@*)
+
+       # Unknown arguments in both finalize_command and compile_command need
+       # to be aesthetically quoted because they are evaled later.
+       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+       case $arg in
+       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
+         arg="\"$arg\""
+         ;;
+       esac
+        compile_command="$compile_command $arg"
+        finalize_command="$finalize_command $arg"
+        compiler_flags="$compiler_flags $arg"
+        continue
+        ;;
+
+      -shrext)
+       prev=shrext
+       continue
+       ;;
+
+      -no-fast-install)
+       fast_install=no
+       continue
+       ;;
+
+      -no-install)
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+         # The PATH hackery in wrapper scripts is required on Windows
+         # in order for the loader to find any dlls it needs.
+         $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
+         $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
+         fast_install=no
+         ;;
+       *) no_install=yes ;;
+       esac
+       continue
+       ;;
+
+      -no-undefined)
+       allow_undefined=no
+       continue
+       ;;
+
+      -objectlist)
+       prev=objectlist
+       continue
+       ;;
+
+      -o) prev=output ;;
+
+      -precious-files-regex)
+       prev=precious_regex
+       continue
+       ;;
+
+      -release)
+       prev=release
+       continue
+       ;;
+
+      -rpath)
+       prev=rpath
+       continue
+       ;;
+
+      -R)
+       prev=xrpath
+       continue
+       ;;
+
+      -R*)
+       dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
+       # We need an absolute path.
+       case $dir in
+       [\\/]* | [A-Za-z]:[\\/]*) ;;
+       *)
+         $echo "$modename: only absolute run-paths are allowed" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+       case "$xrpath " in
+       *" $dir "*) ;;
+       *) xrpath="$xrpath $dir" ;;
+       esac
+       continue
+       ;;
+
+      -static)
+       # The effects of -static are defined in a previous loop.
+       # We used to do the same as -all-static on platforms that
+       # didn't have a PIC flag, but the assumption that the effects
+       # would be equivalent was wrong.  It would break on at least
+       # Digital Unix and AIX.
+       continue
+       ;;
+
+      -thread-safe)
+       thread_safe=yes
+       continue
+       ;;
+
+      -version-info)
+       prev=vinfo
+       continue
+       ;;
+      -version-number)
+       prev=vinfo
+       vinfo_number=yes
+       continue
+       ;;
+
+      -Wc,*)
+       args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
+       arg=
+       save_ifs="$IFS"; IFS=','
+       for flag in $args; do
+         IFS="$save_ifs"
+         case $flag in
+           *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
+           flag="\"$flag\""
+           ;;
+         esac
+         arg="$arg $wl$flag"
+         compiler_flags="$compiler_flags $flag"
+       done
+       IFS="$save_ifs"
+       arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
+       ;;
+
+      -Wl,*)
+       args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
+       arg=
+       save_ifs="$IFS"; IFS=','
+       for flag in $args; do
+         IFS="$save_ifs"
+         case $flag in
+           *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
+           flag="\"$flag\""
+           ;;
+         esac
+         arg="$arg $wl$flag"
+         compiler_flags="$compiler_flags $wl$flag"
+         linker_flags="$linker_flags $flag"
+       done
+       IFS="$save_ifs"
+       arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
+       ;;
+
+      -Xcompiler)
+       prev=xcompiler
+       continue
+       ;;
+
+      -Xlinker)
+       prev=xlinker
+       continue
+       ;;
+
+      -XCClinker)
+       prev=xcclinker
+       continue
+       ;;
+
+      # Some other compiler flag.
+      -* | +*)
+       # Unknown arguments in both finalize_command and compile_command need
+       # to be aesthetically quoted because they are evaled later.
+       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+       case $arg in
+       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
+         arg="\"$arg\""
+         ;;
+       esac
+       ;;
+
+      *.$objext)
+       # A standard object.
+       objs="$objs $arg"
+       ;;
+
+      *.lo)
+       # A libtool-controlled object.
+
+       # Check to see that this really is a libtool object.
+       if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+         pic_object=
+         non_pic_object=
+
+         # Read the .lo file
+         # If there is no directory component, then add one.
+         case $arg in
+         */* | *\\*) . $arg ;;
+         *) . ./$arg ;;
+         esac
+
+         if test -z "$pic_object" || \
+            test -z "$non_pic_object" ||
+            test "$pic_object" = none && \
+            test "$non_pic_object" = none; then
+           $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+           exit $EXIT_FAILURE
+         fi
+
+         # Extract subdirectory from the argument.
+         xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+         if test "X$xdir" = "X$arg"; then
+           xdir=
+         else
+           xdir="$xdir/"
+         fi
+
+         if test "$pic_object" != none; then
+           # Prepend the subdirectory the object is found in.
+           pic_object="$xdir$pic_object"
+
+           if test "$prev" = dlfiles; then
+             if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+               dlfiles="$dlfiles $pic_object"
+               prev=
+               continue
+             else
+               # If libtool objects are unsupported, then we need to preload.
+               prev=dlprefiles
+             fi
+           fi
+
+           # CHECK ME:  I think I busted this.  -Ossama
+           if test "$prev" = dlprefiles; then
+             # Preload the old-style object.
+             dlprefiles="$dlprefiles $pic_object"
+             prev=
+           fi
+
+           # A PIC object.
+           libobjs="$libobjs $pic_object"
+           arg="$pic_object"
+         fi
+
+         # Non-PIC object.
+         if test "$non_pic_object" != none; then
+           # Prepend the subdirectory the object is found in.
+           non_pic_object="$xdir$non_pic_object"
+
+           # A standard non-PIC object
+           non_pic_objects="$non_pic_objects $non_pic_object"
+           if test -z "$pic_object" || test "$pic_object" = none ; then
+             arg="$non_pic_object"
+           fi
+         else
+           # If the PIC object exists, use it instead.
+           # $xdir was prepended to $pic_object above.
+           non_pic_object="$pic_object"
+           non_pic_objects="$non_pic_objects $non_pic_object"
+         fi
+       else
+         # Only an error if not doing a dry-run.
+         if test -z "$run"; then
+           $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+           exit $EXIT_FAILURE
+         else
+           # Dry-run case.
+
+           # Extract subdirectory from the argument.
+           xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+           if test "X$xdir" = "X$arg"; then
+             xdir=
+           else
+             xdir="$xdir/"
+           fi
+
+           pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+           non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+           libobjs="$libobjs $pic_object"
+           non_pic_objects="$non_pic_objects $non_pic_object"
+         fi
+       fi
+       ;;
+
+      *.$libext)
+       # An archive.
+       deplibs="$deplibs $arg"
+       old_deplibs="$old_deplibs $arg"
+       continue
+       ;;
+
+      *.la)
+       # A libtool-controlled library.
+
+       if test "$prev" = dlfiles; then
+         # This library was specified with -dlopen.
+         dlfiles="$dlfiles $arg"
+         prev=
+       elif test "$prev" = dlprefiles; then
+         # The library was specified with -dlpreopen.
+         dlprefiles="$dlprefiles $arg"
+         prev=
+       else
+         deplibs="$deplibs $arg"
+       fi
+       continue
+       ;;
+
+      # Some other compiler argument.
+      *)
+       # Unknown arguments in both finalize_command and compile_command need
+       # to be aesthetically quoted because they are evaled later.
+       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+       case $arg in
+       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
+         arg="\"$arg\""
+         ;;
+       esac
+       ;;
+      esac # arg
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+       compile_command="$compile_command $arg"
+       finalize_command="$finalize_command $arg"
+      fi
+    done # argument parsing loop
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      compile_command="$compile_command $arg"
+      finalize_command="$finalize_command $arg"
+    fi
+
+    oldlibs=
+    # calculate the name of the file, without its directory
+    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
+    libobjs_save="$libobjs"
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+    else
+      shlib_search_path=
+    fi
+    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+    if test "X$output_objdir" = "X$output"; then
+      output_objdir="$objdir"
+    else
+      output_objdir="$output_objdir/$objdir"
+    fi
+    # Create the object directory.
+    if test ! -d "$output_objdir"; then
+      $show "$mkdir $output_objdir"
+      $run $mkdir $output_objdir
+      exit_status=$?
+      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
+       exit $exit_status
+      fi
+    fi
+
+    # Determine the type of output
+    case $output in
+    "")
+      $echo "$modename: you must specify an output file" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+      ;;
+    *.$libext) linkmode=oldlib ;;
+    *.lo | *.$objext) linkmode=obj ;;
+    *.la) linkmode=lib ;;
+    *) linkmode=prog ;; # Anything else should be a program.
+    esac
+
+    case $host in
+    *cygwin* | *mingw* | *pw32*)
+      # don't eliminate duplications in $postdeps and $predeps
+      duplicate_compiler_generated_deps=yes
+      ;;
+    *)
+      duplicate_compiler_generated_deps=$duplicate_deps
+      ;;
+    esac
+    specialdeplibs=
+
+    libs=
+    # Find all interdependent deplibs by searching for libraries
+    # that are linked more than once (e.g. -la -lb -la)
+    for deplib in $deplibs; do
+      if test "X$duplicate_deps" = "Xyes" ; then
+       case "$libs " in
+       *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+       esac
+      fi
+      libs="$libs $deplib"
+    done
+
+    if test "$linkmode" = lib; then
+      libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+      # Compute libraries that are listed more than once in $predeps
+      # $postdeps and mark them as special (i.e., whose duplicates are
+      # not to be eliminated).
+      pre_post_deps=
+      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
+       for pre_post_dep in $predeps $postdeps; do
+         case "$pre_post_deps " in
+         *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+         esac
+         pre_post_deps="$pre_post_deps $pre_post_dep"
+       done
+      fi
+      pre_post_deps=
+    fi
+
+    deplibs=
+    newdependency_libs=
+    newlib_search_path=
+    need_relink=no # whether we're linking any uninstalled libtool libraries
+    notinst_deplibs= # not-installed libtool libraries
+    case $linkmode in
+    lib)
+       passes="conv link"
+       for file in $dlfiles $dlprefiles; do
+         case $file in
+         *.la) ;;
+         *)
+           $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
+           exit $EXIT_FAILURE
+           ;;
+         esac
+       done
+       ;;
+    prog)
+       compile_deplibs=
+       finalize_deplibs=
+       alldeplibs=no
+       newdlfiles=
+       newdlprefiles=
+       passes="conv scan dlopen dlpreopen link"
+       ;;
+    *)  passes="conv"
+       ;;
+    esac
+    for pass in $passes; do
+      if test "$linkmode,$pass" = "lib,link" ||
+        test "$linkmode,$pass" = "prog,scan"; then
+       libs="$deplibs"
+       deplibs=
+      fi
+      if test "$linkmode" = prog; then
+       case $pass in
+       dlopen) libs="$dlfiles" ;;
+       dlpreopen) libs="$dlprefiles" ;;
+       link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+       esac
+      fi
+      if test "$pass" = dlopen; then
+       # Collect dlpreopened libraries
+       save_deplibs="$deplibs"
+       deplibs=
+      fi
+      for deplib in $libs; do
+       lib=
+       found=no
+       case $deplib in
+       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
+         if test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$deplib $compile_deplibs"
+           finalize_deplibs="$deplib $finalize_deplibs"
+         else
+           compiler_flags="$compiler_flags $deplib"
+         fi
+         continue
+         ;;
+       -l*)
+         if test "$linkmode" != lib && test "$linkmode" != prog; then
+           $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
+           continue
+         fi
+         name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
+         for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
+           for search_ext in .la $std_shrext .so .a; do
+             # Search the libtool library
+             lib="$searchdir/lib${name}${search_ext}"
+             if test -f "$lib"; then
+               if test "$search_ext" = ".la"; then
+                 found=yes
+               else
+                 found=no
+               fi
+               break 2
+             fi
+           done
+         done
+         if test "$found" != yes; then
+           # deplib doesn't seem to be a libtool library
+           if test "$linkmode,$pass" = "prog,link"; then
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           else
+             deplibs="$deplib $deplibs"
+             test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+           fi
+           continue
+         else # deplib is a libtool library
+           # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+           # We need to do some special things here, and not later.
+           if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+             case " $predeps $postdeps " in
+             *" $deplib "*)
+               if (${SED} -e '2q' $lib |
+                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+                 library_names=
+                 old_library=
+                 case $lib in
+                 */* | *\\*) . $lib ;;
+                 *) . ./$lib ;;
+                 esac
+                 for l in $old_library $library_names; do
+                   ll="$l"
+                 done
+                 if test "X$ll" = "X$old_library" ; then # only static version available
+                   found=no
+                   ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+                   test "X$ladir" = "X$lib" && ladir="."
+                   lib=$ladir/$old_library
+                   if test "$linkmode,$pass" = "prog,link"; then
+                     compile_deplibs="$deplib $compile_deplibs"
+                     finalize_deplibs="$deplib $finalize_deplibs"
+                   else
+                     deplibs="$deplib $deplibs"
+                     test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+                   fi
+                   continue
+                 fi
+               fi
+               ;;
+             *) ;;
+             esac
+           fi
+         fi
+         ;; # -l
+       -L*)
+         case $linkmode in
+         lib)
+           deplibs="$deplib $deplibs"
+           test "$pass" = conv && continue
+           newdependency_libs="$deplib $newdependency_libs"
+           newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+           ;;
+         prog)
+           if test "$pass" = conv; then
+             deplibs="$deplib $deplibs"
+             continue
+           fi
+           if test "$pass" = scan; then
+             deplibs="$deplib $deplibs"
+           else
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           fi
+           newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+           ;;
+         *)
+           $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
+           ;;
+         esac # linkmode
+         continue
+         ;; # -L
+       -R*)
+         if test "$pass" = link; then
+           dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
+           # Make sure the xrpath contains only unique directories.
+           case "$xrpath " in
+           *" $dir "*) ;;
+           *) xrpath="$xrpath $dir" ;;
+           esac
+         fi
+         deplibs="$deplib $deplibs"
+         continue
+         ;;
+       *.la) lib="$deplib" ;;
+       *.$libext)
+         if test "$pass" = conv; then
+           deplibs="$deplib $deplibs"
+           continue
+         fi
+         case $linkmode in
+         lib)
+           valid_a_lib=no
+           case $deplibs_check_method in
+             match_pattern*)
+               set dummy $deplibs_check_method
+               match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+               if eval $echo \"$deplib\" 2>/dev/null \
+                   | $SED 10q \
+                   | $EGREP "$match_pattern_regex" > /dev/null; then
+                 valid_a_lib=yes
+               fi
+               ;;
+             pass_all)
+               valid_a_lib=yes
+               ;;
+            esac
+           if test "$valid_a_lib" != yes; then
+             $echo
+             $echo "*** Warning: Trying to link with static lib archive $deplib."
+             $echo "*** I have the capability to make that library automatically link in when"
+             $echo "*** you link to this library.  But I can only do this if you have a"
+             $echo "*** shared version of the library, which you do not appear to have"
+             $echo "*** because the file extensions .$libext of this argument makes me believe"
+             $echo "*** that it is just a static archive that I should not used here."
+           else
+             $echo
+             $echo "*** Warning: Linking the shared library $output against the"
+             $echo "*** static library $deplib is not portable!"
+             deplibs="$deplib $deplibs"
+           fi
+           continue
+           ;;
+         prog)
+           if test "$pass" != link; then
+             deplibs="$deplib $deplibs"
+           else
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           fi
+           continue
+           ;;
+         esac # linkmode
+         ;; # *.$libext
+       *.lo | *.$objext)
+         if test "$pass" = conv; then
+           deplibs="$deplib $deplibs"
+         elif test "$linkmode" = prog; then
+           if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+             # If there is no dlopen support or we're linking statically,
+             # we need to preload.
+             newdlprefiles="$newdlprefiles $deplib"
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           else
+             newdlfiles="$newdlfiles $deplib"
+           fi
+         fi
+         continue
+         ;;
+       %DEPLIBS%)
+         alldeplibs=yes
+         continue
+         ;;
+       esac # case $deplib
+       if test "$found" = yes || test -f "$lib"; then :
+       else
+         $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       # Check to see that this really is a libtool archive.
+       if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       else
+         $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+       test "X$ladir" = "X$lib" && ladir="."
+
+       dlname=
+       dlopen=
+       dlpreopen=
+       libdir=
+       library_names=
+       old_library=
+       # If the library was installed with an old release of libtool,
+       # it will not redefine variables installed, or shouldnotlink
+       installed=yes
+       shouldnotlink=no
+       avoidtemprpath=
+
+
+       # Read the .la file
+       case $lib in
+       */* | *\\*) . $lib ;;
+       *) . ./$lib ;;
+       esac
+
+       if test "$linkmode,$pass" = "lib,link" ||
+          test "$linkmode,$pass" = "prog,scan" ||
+          { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+         test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+         test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+       fi
+
+       if test "$pass" = conv; then
+         # Only check for convenience libraries
+         deplibs="$lib $deplibs"
+         if test -z "$libdir"; then
+           if test -z "$old_library"; then
+             $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
+             exit $EXIT_FAILURE
+           fi
+           # It is a libtool convenience library, so add in its objects.
+           convenience="$convenience $ladir/$objdir/$old_library"
+           old_convenience="$old_convenience $ladir/$objdir/$old_library"
+           tmp_libs=
+           for deplib in $dependency_libs; do
+             deplibs="$deplib $deplibs"
+              if test "X$duplicate_deps" = "Xyes" ; then
+               case "$tmp_libs " in
+               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+               esac
+              fi
+             tmp_libs="$tmp_libs $deplib"
+           done
+         elif test "$linkmode" != prog && test "$linkmode" != lib; then
+           $echo "$modename: \`$lib' is not a convenience library" 1>&2
+           exit $EXIT_FAILURE
+         fi
+         continue
+       fi # $pass = conv
+
+
+       # Get the name of the library we link against.
+       linklib=
+       for l in $old_library $library_names; do
+         linklib="$l"
+       done
+       if test -z "$linklib"; then
+         $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       # This library was specified with -dlopen.
+       if test "$pass" = dlopen; then
+         if test -z "$libdir"; then
+           $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
+           exit $EXIT_FAILURE
+         fi
+         if test -z "$dlname" ||
+            test "$dlopen_support" != yes ||
+            test "$build_libtool_libs" = no; then
+           # If there is no dlname, no dlopen support or we're linking
+           # statically, we need to preload.  We also need to preload any
+           # dependent libraries so libltdl's deplib preloader doesn't
+           # bomb out in the load deplibs phase.
+           dlprefiles="$dlprefiles $lib $dependency_libs"
+         else
+           newdlfiles="$newdlfiles $lib"
+         fi
+         continue
+       fi # $pass = dlopen
+
+       # We need an absolute path.
+       case $ladir in
+       [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+       *)
+         abs_ladir=`cd "$ladir" && pwd`
+         if test -z "$abs_ladir"; then
+           $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
+           $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
+           abs_ladir="$ladir"
+         fi
+         ;;
+       esac
+       laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+
+       # Find the relevant object directory and library name.
+       if test "X$installed" = Xyes; then
+         if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+           $echo "$modename: warning: library \`$lib' was moved." 1>&2
+           dir="$ladir"
+           absdir="$abs_ladir"
+           libdir="$abs_ladir"
+         else
+           dir="$libdir"
+           absdir="$libdir"
+         fi
+         test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+       else
+         if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+           dir="$ladir"
+           absdir="$abs_ladir"
+           # Remove this search path later
+           notinst_path="$notinst_path $abs_ladir"
+         else
+           dir="$ladir/$objdir"
+           absdir="$abs_ladir/$objdir"
+           # Remove this search path later
+           notinst_path="$notinst_path $abs_ladir"
+         fi
+       fi # $installed = yes
+       name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+
+       # This library was specified with -dlpreopen.
+       if test "$pass" = dlpreopen; then
+         if test -z "$libdir"; then
+           $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
+           exit $EXIT_FAILURE
+         fi
+         # Prefer using a static library (so that no silly _DYNAMIC symbols
+         # are required to link).
+         if test -n "$old_library"; then
+           newdlprefiles="$newdlprefiles $dir/$old_library"
+         # Otherwise, use the dlname, so that lt_dlopen finds it.
+         elif test -n "$dlname"; then
+           newdlprefiles="$newdlprefiles $dir/$dlname"
+         else
+           newdlprefiles="$newdlprefiles $dir/$linklib"
+         fi
+       fi # $pass = dlpreopen
+
+       if test -z "$libdir"; then
+         # Link the convenience library
+         if test "$linkmode" = lib; then
+           deplibs="$dir/$old_library $deplibs"
+         elif test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$dir/$old_library $compile_deplibs"
+           finalize_deplibs="$dir/$old_library $finalize_deplibs"
+         else
+           deplibs="$lib $deplibs" # used for prog,scan pass
+         fi
+         continue
+       fi
+
+
+       if test "$linkmode" = prog && test "$pass" != link; then
+         newlib_search_path="$newlib_search_path $ladir"
+         deplibs="$lib $deplibs"
+
+         linkalldeplibs=no
+         if test "$link_all_deplibs" != no || test -z "$library_names" ||
+            test "$build_libtool_libs" = no; then
+           linkalldeplibs=yes
+         fi
+
+         tmp_libs=
+         for deplib in $dependency_libs; do
+           case $deplib in
+           -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
+           esac
+           # Need to link against all dependency_libs?
+           if test "$linkalldeplibs" = yes; then
+             deplibs="$deplib $deplibs"
+           else
+             # Need to hardcode shared library paths
+             # or/and link against static libraries
+             newdependency_libs="$deplib $newdependency_libs"
+           fi
+           if test "X$duplicate_deps" = "Xyes" ; then
+             case "$tmp_libs " in
+             *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+             esac
+           fi
+           tmp_libs="$tmp_libs $deplib"
+         done # for deplib
+         continue
+       fi # $linkmode = prog...
+
+       if test "$linkmode,$pass" = "prog,link"; then
+         if test -n "$library_names" &&
+            { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+           # We need to hardcode the library path
+           if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+             # Make sure the rpath contains only unique directories.
+             case "$temp_rpath " in
+             *" $dir "*) ;;
+             *" $absdir "*) ;;
+             *) temp_rpath="$temp_rpath $absdir" ;;
+             esac
+           fi
+
+           # Hardcode the library path.
+           # Skip directories that are in the system default run-time
+           # search path.
+           case " $sys_lib_dlsearch_path " in
+           *" $absdir "*) ;;
+           *)
+             case "$compile_rpath " in
+             *" $absdir "*) ;;
+             *) compile_rpath="$compile_rpath $absdir"
+             esac
+             ;;
+           esac
+           case " $sys_lib_dlsearch_path " in
+           *" $libdir "*) ;;
+           *)
+             case "$finalize_rpath " in
+             *" $libdir "*) ;;
+             *) finalize_rpath="$finalize_rpath $libdir"
+             esac
+             ;;
+           esac
+         fi # $linkmode,$pass = prog,link...
+
+         if test "$alldeplibs" = yes &&
+            { test "$deplibs_check_method" = pass_all ||
+              { test "$build_libtool_libs" = yes &&
+                test -n "$library_names"; }; }; then
+           # We only need to search for static libraries
+           continue
+         fi
+       fi
+
+       link_static=no # Whether the deplib will be linked statically
+       use_static_libs=$prefer_static_libs
+       if test "$use_static_libs" = built && test "$installed" = yes ; then
+         use_static_libs=no
+       fi
+       if test -n "$library_names" &&
+          { test "$use_static_libs" = no || test -z "$old_library"; }; then
+         if test "$installed" = no; then
+           notinst_deplibs="$notinst_deplibs $lib"
+           need_relink=yes
+         fi
+         # This is a shared library
+
+         # Warn about portability, can't link against -module's on
+         # some systems (darwin)
+         if test "$shouldnotlink" = yes && test "$pass" = link ; then
+           $echo
+           if test "$linkmode" = prog; then
+             $echo "*** Warning: Linking the executable $output against the loadable module"
+           else
+             $echo "*** Warning: Linking the shared library $output against the loadable module"
+           fi
+           $echo "*** $linklib is not portable!"
+         fi
+         if test "$linkmode" = lib &&
+            test "$hardcode_into_libs" = yes; then
+           # Hardcode the library path.
+           # Skip directories that are in the system default run-time
+           # search path.
+           case " $sys_lib_dlsearch_path " in
+           *" $absdir "*) ;;
+           *)
+             case "$compile_rpath " in
+             *" $absdir "*) ;;
+             *) compile_rpath="$compile_rpath $absdir"
+             esac
+             ;;
+           esac
+           case " $sys_lib_dlsearch_path " in
+           *" $libdir "*) ;;
+           *)
+             case "$finalize_rpath " in
+             *" $libdir "*) ;;
+             *) finalize_rpath="$finalize_rpath $libdir"
+             esac
+             ;;
+           esac
+         fi
+
+         if test -n "$old_archive_from_expsyms_cmds"; then
+           # figure out the soname
+           set dummy $library_names
+           realname="$2"
+           shift; shift
+           libname=`eval \\$echo \"$libname_spec\"`
+           # use dlname if we got it. it's perfectly good, no?
+           if test -n "$dlname"; then
+             soname="$dlname"
+           elif test -n "$soname_spec"; then
+             # bleh windows
+             case $host in
+             *cygwin* | mingw*)
+               major=`expr $current - $age`
+               versuffix="-$major"
+               ;;
+             esac
+             eval soname=\"$soname_spec\"
+           else
+             soname="$realname"
+           fi
+
+           # Make a new name for the extract_expsyms_cmds to use
+           soroot="$soname"
+           soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
+           newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
+
+           # If the library has no export list, then create one now
+           if test -f "$output_objdir/$soname-def"; then :
+           else
+             $show "extracting exported symbol list from \`$soname'"
+             save_ifs="$IFS"; IFS='~'
+             cmds=$extract_expsyms_cmds
+             for cmd in $cmds; do
+               IFS="$save_ifs"
+               eval cmd=\"$cmd\"
+               $show "$cmd"
+               $run eval "$cmd" || exit $?
+             done
+             IFS="$save_ifs"
+           fi
+
+           # Create $newlib
+           if test -f "$output_objdir/$newlib"; then :; else
+             $show "generating import library for \`$soname'"
+             save_ifs="$IFS"; IFS='~'
+             cmds=$old_archive_from_expsyms_cmds
+             for cmd in $cmds; do
+               IFS="$save_ifs"
+               eval cmd=\"$cmd\"
+               $show "$cmd"
+               $run eval "$cmd" || exit $?
+             done
+             IFS="$save_ifs"
+           fi
+           # make sure the library variables are pointing to the new library
+           dir=$output_objdir
+           linklib=$newlib
+         fi # test -n "$old_archive_from_expsyms_cmds"
+
+         if test "$linkmode" = prog || test "$mode" != relink; then
+           add_shlibpath=
+           add_dir=
+           add=
+           lib_linked=yes
+           case $hardcode_action in
+           immediate | unsupported)
+             if test "$hardcode_direct" = no; then
+               add="$dir/$linklib"
+               case $host in
+                 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+                 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+                 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+                   *-*-unixware7*) add_dir="-L$dir" ;;
+                 *-*-darwin* )
+                   # if the lib is a module then we can not link against
+                   # it, someone is ignoring the new warnings I added
+                   if /usr/bin/file -L $add 2> /dev/null |
+                      $EGREP ": [^:]* bundle" >/dev/null ; then
+                     $echo "** Warning, lib $linklib is a module, not a shared library"
+                     if test -z "$old_library" ; then
+                       $echo
+                       $echo "** And there doesn't seem to be a static archive available"
+                       $echo "** The link will probably fail, sorry"
+                     else
+                       add="$dir/$old_library"
+                     fi
+                   fi
+               esac
+             elif test "$hardcode_minus_L" = no; then
+               case $host in
+               *-*-sunos*) add_shlibpath="$dir" ;;
+               esac
+               add_dir="-L$dir"
+               add="-l$name"
+             elif test "$hardcode_shlibpath_var" = no; then
+               add_shlibpath="$dir"
+               add="-l$name"
+             else
+               lib_linked=no
+             fi
+             ;;
+           relink)
+             if test "$hardcode_direct" = yes; then
+               add="$dir/$linklib"
+             elif test "$hardcode_minus_L" = yes; then
+               add_dir="-L$dir"
+               # Try looking first in the location we're being installed to.
+               if test -n "$inst_prefix_dir"; then
+                 case $libdir in
+                   [\\/]*)
+                     add_dir="$add_dir -L$inst_prefix_dir$libdir"
+                     ;;
+                 esac
+               fi
+               add="-l$name"
+             elif test "$hardcode_shlibpath_var" = yes; then
+               add_shlibpath="$dir"
+               add="-l$name"
+             else
+               lib_linked=no
+             fi
+             ;;
+           *) lib_linked=no ;;
+           esac
+
+           if test "$lib_linked" != yes; then
+             $echo "$modename: configuration error: unsupported hardcode properties"
+             exit $EXIT_FAILURE
+           fi
+
+           if test -n "$add_shlibpath"; then
+             case :$compile_shlibpath: in
+             *":$add_shlibpath:"*) ;;
+             *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+             esac
+           fi
+           if test "$linkmode" = prog; then
+             test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+             test -n "$add" && compile_deplibs="$add $compile_deplibs"
+           else
+             test -n "$add_dir" && deplibs="$add_dir $deplibs"
+             test -n "$add" && deplibs="$add $deplibs"
+             if test "$hardcode_direct" != yes && \
+                test "$hardcode_minus_L" != yes && \
+                test "$hardcode_shlibpath_var" = yes; then
+               case :$finalize_shlibpath: in
+               *":$libdir:"*) ;;
+               *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+               esac
+             fi
+           fi
+         fi
+
+         if test "$linkmode" = prog || test "$mode" = relink; then
+           add_shlibpath=
+           add_dir=
+           add=
+           # Finalize command for both is simple: just hardcode it.
+           if test "$hardcode_direct" = yes; then
+             add="$libdir/$linklib"
+           elif test "$hardcode_minus_L" = yes; then
+             add_dir="-L$libdir"
+             add="-l$name"
+           elif test "$hardcode_shlibpath_var" = yes; then
+             case :$finalize_shlibpath: in
+             *":$libdir:"*) ;;
+             *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+             esac
+             add="-l$name"
+           elif test "$hardcode_automatic" = yes; then
+             if test -n "$inst_prefix_dir" &&
+                test -f "$inst_prefix_dir$libdir/$linklib" ; then
+               add="$inst_prefix_dir$libdir/$linklib"
+             else
+               add="$libdir/$linklib"
+             fi
+           else
+             # We cannot seem to hardcode it, guess we'll fake it.
+             add_dir="-L$libdir"
+             # Try looking first in the location we're being installed to.
+             if test -n "$inst_prefix_dir"; then
+               case $libdir in
+                 [\\/]*)
+                   add_dir="$add_dir -L$inst_prefix_dir$libdir"
+                   ;;
+               esac
+             fi
+             add="-l$name"
+           fi
+
+           if test "$linkmode" = prog; then
+             test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+             test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+           else
+             test -n "$add_dir" && deplibs="$add_dir $deplibs"
+             test -n "$add" && deplibs="$add $deplibs"
+           fi
+         fi
+       elif test "$linkmode" = prog; then
+         # Here we assume that one of hardcode_direct or hardcode_minus_L
+         # is not unsupported.  This is valid on all known static and
+         # shared platforms.
+         if test "$hardcode_direct" != unsupported; then
+           test -n "$old_library" && linklib="$old_library"
+           compile_deplibs="$dir/$linklib $compile_deplibs"
+           finalize_deplibs="$dir/$linklib $finalize_deplibs"
+         else
+           compile_deplibs="-l$name -L$dir $compile_deplibs"
+           finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+         fi
+       elif test "$build_libtool_libs" = yes; then
+         # Not a shared library
+         if test "$deplibs_check_method" != pass_all; then
+           # We're trying link a shared library against a static one
+           # but the system doesn't support it.
+
+           # Just print a warning and add the library to dependency_libs so
+           # that the program can be linked against the static library.
+           $echo
+           $echo "*** Warning: This system can not link to static lib archive $lib."
+           $echo "*** I have the capability to make that library automatically link in when"
+           $echo "*** you link to this library.  But I can only do this if you have a"
+           $echo "*** shared version of the library, which you do not appear to have."
+           if test "$module" = yes; then
+             $echo "*** But as you try to build a module library, libtool will still create "
+             $echo "*** a static module, that should work as long as the dlopening application"
+             $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
+             if test -z "$global_symbol_pipe"; then
+               $echo
+               $echo "*** However, this would only work if libtool was able to extract symbol"
+               $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+               $echo "*** not find such a program.  So, this module is probably useless."
+               $echo "*** \`nm' from GNU binutils and a full rebuild may help."
+             fi
+             if test "$build_old_libs" = no; then
+               build_libtool_libs=module
+               build_old_libs=yes
+             else
+               build_libtool_libs=no
+             fi
+           fi
+         else
+           deplibs="$dir/$old_library $deplibs"
+           link_static=yes
+         fi
+       fi # link shared/static library?
+
+       if test "$linkmode" = lib; then
+         if test -n "$dependency_libs" &&
+            { test "$hardcode_into_libs" != yes ||
+              test "$build_old_libs" = yes ||
+              test "$link_static" = yes; }; then
+           # Extract -R from dependency_libs
+           temp_deplibs=
+           for libdir in $dependency_libs; do
+             case $libdir in
+             -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
+                  case " $xrpath " in
+                  *" $temp_xrpath "*) ;;
+                  *) xrpath="$xrpath $temp_xrpath";;
+                  esac;;
+             *) temp_deplibs="$temp_deplibs $libdir";;
+             esac
+           done
+           dependency_libs="$temp_deplibs"
+         fi
+
+         newlib_search_path="$newlib_search_path $absdir"
+         # Link against this library
+         test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+         # ... and its dependency_libs
+         tmp_libs=
+         for deplib in $dependency_libs; do
+           newdependency_libs="$deplib $newdependency_libs"
+           if test "X$duplicate_deps" = "Xyes" ; then
+             case "$tmp_libs " in
+             *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+             esac
+           fi
+           tmp_libs="$tmp_libs $deplib"
+         done
+
+         if test "$link_all_deplibs" != no; then
+           # Add the search paths of all dependency libraries
+           for deplib in $dependency_libs; do
+             case $deplib in
+             -L*) path="$deplib" ;;
+             *.la)
+               dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
+               test "X$dir" = "X$deplib" && dir="."
+               # We need an absolute path.
+               case $dir in
+               [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+               *)
+                 absdir=`cd "$dir" && pwd`
+                 if test -z "$absdir"; then
+                   $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
+                   absdir="$dir"
+                 fi
+                 ;;
+               esac
+               if grep "^installed=no" $deplib > /dev/null; then
+                 path="$absdir/$objdir"
+               else
+                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+                 if test -z "$libdir"; then
+                   $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
+                   exit $EXIT_FAILURE
+                 fi
+                 if test "$absdir" != "$libdir"; then
+                   $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
+                 fi
+                 path="$absdir"
+               fi
+               depdepl=
+               case $host in
+               *-*-darwin*)
+                 # we do not want to link against static libs,
+                 # but need to link against shared
+                 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+                 if test -n "$deplibrary_names" ; then
+                   for tmp in $deplibrary_names ; do
+                     depdepl=$tmp
+                   done
+                   if test -f "$path/$depdepl" ; then
+                     depdepl="$path/$depdepl"
+                   fi
+                   # do not add paths which are already there
+                   case " $newlib_search_path " in
+                   *" $path "*) ;;
+                   *) newlib_search_path="$newlib_search_path $path";;
+                   esac
+                 fi
+                 path=""
+                 ;;
+               *)
+                 path="-L$path"
+                 ;;
+               esac
+               ;;
+             -l*)
+               case $host in
+               *-*-darwin*)
+                 # Again, we only want to link against shared libraries
+                 eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
+                 for tmp in $newlib_search_path ; do
+                   if test -f "$tmp/lib$tmp_libs.dylib" ; then
+                     eval depdepl="$tmp/lib$tmp_libs.dylib"
+                     break
+                   fi
+                 done
+                 path=""
+                 ;;
+               *) continue ;;
+               esac
+               ;;
+             *) continue ;;
+             esac
+             case " $deplibs " in
+             *" $path "*) ;;
+             *) deplibs="$path $deplibs" ;;
+             esac
+             case " $deplibs " in
+             *" $depdepl "*) ;;
+             *) deplibs="$depdepl $deplibs" ;;
+             esac
+           done
+         fi # link_all_deplibs != no
+       fi # linkmode = lib
+      done # for deplib in $libs
+      dependency_libs="$newdependency_libs"
+      if test "$pass" = dlpreopen; then
+       # Link the dlpreopened libraries before other libraries
+       for deplib in $save_deplibs; do
+         deplibs="$deplib $deplibs"
+       done
+      fi
+      if test "$pass" != dlopen; then
+       if test "$pass" != conv; then
+         # Make sure lib_search_path contains only unique directories.
+         lib_search_path=
+         for dir in $newlib_search_path; do
+           case "$lib_search_path " in
+           *" $dir "*) ;;
+           *) lib_search_path="$lib_search_path $dir" ;;
+           esac
+         done
+         newlib_search_path=
+       fi
+
+       if test "$linkmode,$pass" != "prog,link"; then
+         vars="deplibs"
+       else
+         vars="compile_deplibs finalize_deplibs"
+       fi
+       for var in $vars dependency_libs; do
+         # Add libraries to $var in reverse order
+         eval tmp_libs=\"\$$var\"
+         new_libs=
+         for deplib in $tmp_libs; do
+           # FIXME: Pedantically, this is the right thing to do, so
+           #        that some nasty dependency loop isn't accidentally
+           #        broken:
+           #new_libs="$deplib $new_libs"
+           # Pragmatically, this seems to cause very few problems in
+           # practice:
+           case $deplib in
+           -L*) new_libs="$deplib $new_libs" ;;
+           -R*) ;;
+           *)
+             # And here is the reason: when a library appears more
+             # than once as an explicit dependence of a library, or
+             # is implicitly linked in more than once by the
+             # compiler, it is considered special, and multiple
+             # occurrences thereof are not removed.  Compare this
+             # with having the same library being listed as a
+             # dependency of multiple other libraries: in this case,
+             # we know (pedantically, we assume) the library does not
+             # need to be listed more than once, so we keep only the
+             # last copy.  This is not always right, but it is rare
+             # enough that we require users that really mean to play
+             # such unportable linking tricks to link the library
+             # using -Wl,-lname, so that libtool does not consider it
+             # for duplicate removal.
+             case " $specialdeplibs " in
+             *" $deplib "*) new_libs="$deplib $new_libs" ;;
+             *)
+               case " $new_libs " in
+               *" $deplib "*) ;;
+               *) new_libs="$deplib $new_libs" ;;
+               esac
+               ;;
+             esac
+             ;;
+           esac
+         done
+         tmp_libs=
+         for deplib in $new_libs; do
+           case $deplib in
+           -L*)
+             case " $tmp_libs " in
+             *" $deplib "*) ;;
+             *) tmp_libs="$tmp_libs $deplib" ;;
+             esac
+             ;;
+           *) tmp_libs="$tmp_libs $deplib" ;;
+           esac
+         done
+         eval $var=\"$tmp_libs\"
+       done # for var
+      fi
+      # Last step: remove runtime libs from dependency_libs
+      # (they stay in deplibs)
+      tmp_libs=
+      for i in $dependency_libs ; do
+       case " $predeps $postdeps $compiler_lib_search_path " in
+       *" $i "*)
+         i=""
+         ;;
+       esac
+       if test -n "$i" ; then
+         tmp_libs="$tmp_libs $i"
+       fi
+      done
+      dependency_libs=$tmp_libs
+    done # for pass
+    if test "$linkmode" = prog; then
+      dlfiles="$newdlfiles"
+      dlprefiles="$newdlprefiles"
+    fi
+
+    case $linkmode in
+    oldlib)
+      if test -n "$deplibs"; then
+       $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$rpath"; then
+       $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$xrpath"; then
+       $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$vinfo"; then
+       $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$release"; then
+       $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+       $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
+      fi
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      objs="$objs$old_deplibs"
+      ;;
+
+    lib)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case $outputname in
+      lib*)
+       name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+       eval shared_ext=\"$shrext_cmds\"
+       eval libname=\"$libname_spec\"
+       ;;
+      *)
+       if test "$module" = no; then
+         $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+       fi
+       if test "$need_lib_prefix" != no; then
+         # Add the "lib" prefix for modules if required
+         name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+         eval shared_ext=\"$shrext_cmds\"
+         eval libname=\"$libname_spec\"
+       else
+         libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+       fi
+       ;;
+      esac
+
+      if test -n "$objs"; then
+       if test "$deplibs_check_method" != pass_all; then
+         $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
+         exit $EXIT_FAILURE
+       else
+         $echo
+         $echo "*** Warning: Linking the shared library $output against the non-libtool"
+         $echo "*** objects $objs is not portable!"
+         libobjs="$libobjs $objs"
+       fi
+      fi
+
+      if test "$dlself" != no; then
+       $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
+      fi
+
+      set dummy $rpath
+      if test "$#" -gt 2; then
+       $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
+      fi
+      install_libdir="$2"
+
+      oldlibs=
+      if test -z "$rpath"; then
+       if test "$build_libtool_libs" = yes; then
+         # Building a libtool convenience library.
+         # Some compilers have problems with a `.al' extension so
+         # convenience libraries should have the same extension an
+         # archive normally would.
+         oldlibs="$output_objdir/$libname.$libext $oldlibs"
+         build_libtool_libs=convenience
+         build_old_libs=yes
+       fi
+
+       if test -n "$vinfo"; then
+         $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
+       fi
+
+       if test -n "$release"; then
+         $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
+       fi
+      else
+
+       # Parse the version information argument.
+       save_ifs="$IFS"; IFS=':'
+       set dummy $vinfo 0 0 0
+       IFS="$save_ifs"
+
+       if test -n "$8"; then
+         $echo "$modename: too many parameters to \`-version-info'" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       # convert absolute version numbers to libtool ages
+       # this retains compatibility with .la files and attempts
+       # to make the code below a bit more comprehensible
+
+       case $vinfo_number in
+       yes)
+         number_major="$2"
+         number_minor="$3"
+         number_revision="$4"
+         #
+         # There are really only two kinds -- those that
+         # use the current revision as the major version
+         # and those that subtract age and use age as
+         # a minor version.  But, then there is irix
+         # which has an extra 1 added just for fun
+         #
+         case $version_type in
+         darwin|linux|osf|windows)
+           current=`expr $number_major + $number_minor`
+           age="$number_minor"
+           revision="$number_revision"
+           ;;
+         freebsd-aout|freebsd-elf|sunos)
+           current="$number_major"
+           revision="$number_minor"
+           age="0"
+           ;;
+         irix|nonstopux)
+           current=`expr $number_major + $number_minor - 1`
+           age="$number_minor"
+           revision="$number_minor"
+           ;;
+         esac
+         ;;
+       no)
+         current="$2"
+         revision="$3"
+         age="$4"
+         ;;
+       esac
+
+       # Check that each of the things are valid numbers.
+       case $current in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+
+       case $revision in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+
+       case $age in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+
+       if test "$age" -gt "$current"; then
+         $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       # Calculate the version variables.
+       major=
+       versuffix=
+       verstring=
+       case $version_type in
+       none) ;;
+
+       darwin)
+         # Like Linux, but with the current version available in
+         # verstring for coding it into the library header
+         major=.`expr $current - $age`
+         versuffix="$major.$age.$revision"
+         # Darwin ld doesn't like 0 for these options...
+         minor_current=`expr $current + 1`
+         verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+         ;;
+
+       freebsd-aout)
+         major=".$current"
+         versuffix=".$current.$revision";
+         ;;
+
+       freebsd-elf)
+         major=".$current"
+         versuffix=".$current";
+         ;;
+
+       irix | nonstopux)
+         major=`expr $current - $age + 1`
+
+         case $version_type in
+           nonstopux) verstring_prefix=nonstopux ;;
+           *)         verstring_prefix=sgi ;;
+         esac
+         verstring="$verstring_prefix$major.$revision"
+
+         # Add in all the interfaces that we are compatible with.
+         loop=$revision
+         while test "$loop" -ne 0; do
+           iface=`expr $revision - $loop`
+           loop=`expr $loop - 1`
+           verstring="$verstring_prefix$major.$iface:$verstring"
+         done
+
+         # Before this point, $major must not contain `.'.
+         major=.$major
+         versuffix="$major.$revision"
+         ;;
+
+       linux)
+         major=.`expr $current - $age`
+         versuffix="$major.$age.$revision"
+         ;;
+
+       osf)
+         major=.`expr $current - $age`
+         versuffix=".$current.$age.$revision"
+         verstring="$current.$age.$revision"
+
+         # Add in all the interfaces that we are compatible with.
+         loop=$age
+         while test "$loop" -ne 0; do
+           iface=`expr $current - $loop`
+           loop=`expr $loop - 1`
+           verstring="$verstring:${iface}.0"
+         done
+
+         # Make executables depend on our current version.
+         verstring="$verstring:${current}.0"
+         ;;
+
+       sunos)
+         major=".$current"
+         versuffix=".$current.$revision"
+         ;;
+
+       windows)
+         # Use '-' rather than '.', since we only want one
+         # extension on DOS 8.3 filesystems.
+         major=`expr $current - $age`
+         versuffix="-$major"
+         ;;
+
+       *)
+         $echo "$modename: unknown library version type \`$version_type'" 1>&2
+         $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+
+       # Clear the version info if we defaulted, and they specified a release.
+       if test -z "$vinfo" && test -n "$release"; then
+         major=
+         case $version_type in
+         darwin)
+           # we can't check for "0.0" in archive_cmds due to quoting
+           # problems, so we reset it completely
+           verstring=
+           ;;
+         *)
+           verstring="0.0"
+           ;;
+         esac
+         if test "$need_version" = no; then
+           versuffix=
+         else
+           versuffix=".0.0"
+         fi
+       fi
+
+       # Remove version info from name if versioning should be avoided
+       if test "$avoid_version" = yes && test "$need_version" = no; then
+         major=
+         versuffix=
+         verstring=""
+       fi
+
+       # Check to see if the archive will have undefined symbols.
+       if test "$allow_undefined" = yes; then
+         if test "$allow_undefined_flag" = unsupported; then
+           $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
+           build_libtool_libs=no
+           build_old_libs=yes
+         fi
+       else
+         # Don't allow undefined symbols.
+         allow_undefined_flag="$no_undefined_flag"
+       fi
+      fi
+
+      if test "$mode" != relink; then
+       # Remove our outputs, but don't remove object files since they
+       # may have been created when compiling PIC objects.
+       removelist=
+       tempremovelist=`$echo "$output_objdir/*"`
+       for p in $tempremovelist; do
+         case $p in
+           *.$objext)
+              ;;
+           $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+              if test "X$precious_files_regex" != "X"; then
+                if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+                then
+                  continue
+                fi
+              fi
+              removelist="$removelist $p"
+              ;;
+           *) ;;
+         esac
+       done
+       if test -n "$removelist"; then
+         $show "${rm}r $removelist"
+         $run ${rm}r $removelist
+       fi
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+       oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+       # Transform .lo files to .o files.
+       oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+      fi
+
+      # Eliminate all temporary directories.
+      for path in $notinst_path; do
+       lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
+       deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
+       dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
+      done
+
+      if test -n "$xrpath"; then
+       # If the user specified any rpath flags, then add them.
+       temp_xrpath=
+       for libdir in $xrpath; do
+         temp_xrpath="$temp_xrpath -R$libdir"
+         case "$finalize_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_rpath="$finalize_rpath $libdir" ;;
+         esac
+       done
+       if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+         dependency_libs="$temp_xrpath $dependency_libs"
+       fi
+      fi
+
+      # Make sure dlfiles contains only unique files that won't be dlpreopened
+      old_dlfiles="$dlfiles"
+      dlfiles=
+      for lib in $old_dlfiles; do
+       case " $dlprefiles $dlfiles " in
+       *" $lib "*) ;;
+       *) dlfiles="$dlfiles $lib" ;;
+       esac
+      done
+
+      # Make sure dlprefiles contains only unique files
+      old_dlprefiles="$dlprefiles"
+      dlprefiles=
+      for lib in $old_dlprefiles; do
+       case "$dlprefiles " in
+       *" $lib "*) ;;
+       *) dlprefiles="$dlprefiles $lib" ;;
+       esac
+      done
+
+      if test "$build_libtool_libs" = yes; then
+       if test -n "$rpath"; then
+         case $host in
+         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
+           # these systems don't actually have a c library (as such)!
+           ;;
+         *-*-rhapsody* | *-*-darwin1.[012])
+           # Rhapsody C library is in the System framework
+           deplibs="$deplibs -framework System"
+           ;;
+         *-*-netbsd*)
+           # Don't link with libc until the a.out ld.so is fixed.
+           ;;
+         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+           # Do not include libc due to us having libc/libc_r.
+           ;;
+         *-*-sco3.2v5* | *-*-sco5v6*)
+           # Causes problems with __ctype
+           ;;
+         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+           # Compiler inserts libc in the correct place for threads to work
+           ;;
+         *)
+           # Add libc to deplibs on all other systems if necessary.
+           if test "$build_libtool_need_lc" = "yes"; then
+             deplibs="$deplibs -lc"
+           fi
+           ;;
+         esac
+       fi
+
+       # Transform deplibs into only deplibs that can be linked in shared.
+       name_save=$name
+       libname_save=$libname
+       release_save=$release
+       versuffix_save=$versuffix
+       major_save=$major
+       # I'm not sure if I'm treating the release correctly.  I think
+       # release should show up in the -l (ie -lgmp5) so we don't want to
+       # add it in twice.  Is that correct?
+       release=""
+       versuffix=""
+       major=""
+       newdeplibs=
+       droppeddeps=no
+       case $deplibs_check_method in
+       pass_all)
+         # Don't check for shared/static.  Everything works.
+         # This might be a little naive.  We might want to check
+         # whether the library exists or not.  But this is on
+         # osf3 & osf4 and I'm not really sure... Just
+         # implementing what was already the behavior.
+         newdeplibs=$deplibs
+         ;;
+       test_compile)
+         # This code stresses the "libraries are programs" paradigm to its
+         # limits. Maybe even breaks it.  We compile a program, linking it
+         # against the deplibs as a proxy for the library.  Then we can check
+         # whether they linked in statically or dynamically with ldd.
+         $rm conftest.c
+         cat > conftest.c <<EOF
+         int main() { return 0; }
+EOF
+         $rm conftest
+         $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
+         if test "$?" -eq 0 ; then
+           ldd_output=`ldd conftest`
+           for i in $deplibs; do
+             name=`expr $i : '-l\(.*\)'`
+             # If $name is empty we are operating on a -L argument.
+              if test "$name" != "" && test "$name" -ne "0"; then
+               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+                 case " $predeps $postdeps " in
+                 *" $i "*)
+                   newdeplibs="$newdeplibs $i"
+                   i=""
+                   ;;
+                 esac
+               fi
+               if test -n "$i" ; then
+                 libname=`eval \\$echo \"$libname_spec\"`
+                 deplib_matches=`eval \\$echo \"$library_names_spec\"`
+                 set dummy $deplib_matches
+                 deplib_match=$2
+                 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                   newdeplibs="$newdeplibs $i"
+                 else
+                   droppeddeps=yes
+                   $echo
+                   $echo "*** Warning: dynamic linker does not accept needed library $i."
+                   $echo "*** I have the capability to make that library automatically link in when"
+                   $echo "*** you link to this library.  But I can only do this if you have a"
+                   $echo "*** shared version of the library, which I believe you do not have"
+                   $echo "*** because a test_compile did reveal that the linker did not use it for"
+                   $echo "*** its dynamic dependency list that programs get resolved with at runtime."
+                 fi
+               fi
+             else
+               newdeplibs="$newdeplibs $i"
+             fi
+           done
+         else
+           # Error occurred in the first compile.  Let's try to salvage
+           # the situation: Compile a separate program for each library.
+           for i in $deplibs; do
+             name=`expr $i : '-l\(.*\)'`
+             # If $name is empty we are operating on a -L argument.
+              if test "$name" != "" && test "$name" != "0"; then
+               $rm conftest
+               $LTCC $LTCFLAGS -o conftest conftest.c $i
+               # Did it work?
+               if test "$?" -eq 0 ; then
+                 ldd_output=`ldd conftest`
+                 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+                   case " $predeps $postdeps " in
+                   *" $i "*)
+                     newdeplibs="$newdeplibs $i"
+                     i=""
+                     ;;
+                   esac
+                 fi
+                 if test -n "$i" ; then
+                   libname=`eval \\$echo \"$libname_spec\"`
+                   deplib_matches=`eval \\$echo \"$library_names_spec\"`
+                   set dummy $deplib_matches
+                   deplib_match=$2
+                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                     newdeplibs="$newdeplibs $i"
+                   else
+                     droppeddeps=yes
+                     $echo
+                     $echo "*** Warning: dynamic linker does not accept needed library $i."
+                     $echo "*** I have the capability to make that library automatically link in when"
+                     $echo "*** you link to this library.  But I can only do this if you have a"
+                     $echo "*** shared version of the library, which you do not appear to have"
+                     $echo "*** because a test_compile did reveal that the linker did not use this one"
+                     $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
+                   fi
+                 fi
+               else
+                 droppeddeps=yes
+                 $echo
+                 $echo "*** Warning!  Library $i is needed by this library but I was not able to"
+                 $echo "***  make it link in!  You will probably need to install it or some"
+                 $echo "*** library that it depends on before this library will be fully"
+                 $echo "*** functional.  Installing it before continuing would be even better."
+               fi
+             else
+               newdeplibs="$newdeplibs $i"
+             fi
+           done
+         fi
+         ;;
+       file_magic*)
+         set dummy $deplibs_check_method
+         file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+         for a_deplib in $deplibs; do
+           name=`expr $a_deplib : '-l\(.*\)'`
+           # If $name is empty we are operating on a -L argument.
+            if test "$name" != "" && test  "$name" != "0"; then
+             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+               case " $predeps $postdeps " in
+               *" $a_deplib "*)
+                 newdeplibs="$newdeplibs $a_deplib"
+                 a_deplib=""
+                 ;;
+               esac
+             fi
+             if test -n "$a_deplib" ; then
+               libname=`eval \\$echo \"$libname_spec\"`
+               for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+                 for potent_lib in $potential_libs; do
+                     # Follow soft links.
+                     if ls -lLd "$potent_lib" 2>/dev/null \
+                        | grep " -> " >/dev/null; then
+                       continue
+                     fi
+                     # The statement above tries to avoid entering an
+                     # endless loop below, in case of cyclic links.
+                     # We might still enter an endless loop, since a link
+                     # loop can be closed while we follow links,
+                     # but so what?
+                     potlib="$potent_lib"
+                     while test -h "$potlib" 2>/dev/null; do
+                       potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+                       case $potliblink in
+                       [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+                       *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+                       esac
+                     done
+                     if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
+                        | ${SED} 10q \
+                        | $EGREP "$file_magic_regex" > /dev/null; then
+                       newdeplibs="$newdeplibs $a_deplib"
+                       a_deplib=""
+                       break 2
+                     fi
+                 done
+               done
+             fi
+             if test -n "$a_deplib" ; then
+               droppeddeps=yes
+               $echo
+               $echo "*** Warning: linker path does not have real file for library $a_deplib."
+               $echo "*** I have the capability to make that library automatically link in when"
+               $echo "*** you link to this library.  But I can only do this if you have a"
+               $echo "*** shared version of the library, which you do not appear to have"
+               $echo "*** because I did check the linker path looking for a file starting"
+               if test -z "$potlib" ; then
+                 $echo "*** with $libname but no candidates were found. (...for file magic test)"
+               else
+                 $echo "*** with $libname and none of the candidates passed a file format test"
+                 $echo "*** using a file magic. Last file checked: $potlib"
+               fi
+             fi
+           else
+             # Add a -L argument.
+             newdeplibs="$newdeplibs $a_deplib"
+           fi
+         done # Gone through all deplibs.
+         ;;
+       match_pattern*)
+         set dummy $deplibs_check_method
+         match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+         for a_deplib in $deplibs; do
+           name=`expr $a_deplib : '-l\(.*\)'`
+           # If $name is empty we are operating on a -L argument.
+           if test -n "$name" && test "$name" != "0"; then
+             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+               case " $predeps $postdeps " in
+               *" $a_deplib "*)
+                 newdeplibs="$newdeplibs $a_deplib"
+                 a_deplib=""
+                 ;;
+               esac
+             fi
+             if test -n "$a_deplib" ; then
+               libname=`eval \\$echo \"$libname_spec\"`
+               for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+                 for potent_lib in $potential_libs; do
+                   potlib="$potent_lib" # see symlink-check above in file_magic test
+                   if eval $echo \"$potent_lib\" 2>/dev/null \
+                       | ${SED} 10q \
+                       | $EGREP "$match_pattern_regex" > /dev/null; then
+                     newdeplibs="$newdeplibs $a_deplib"
+                     a_deplib=""
+                     break 2
+                   fi
+                 done
+               done
+             fi
+             if test -n "$a_deplib" ; then
+               droppeddeps=yes
+               $echo
+               $echo "*** Warning: linker path does not have real file for library $a_deplib."
+               $echo "*** I have the capability to make that library automatically link in when"
+               $echo "*** you link to this library.  But I can only do this if you have a"
+               $echo "*** shared version of the library, which you do not appear to have"
+               $echo "*** because I did check the linker path looking for a file starting"
+               if test -z "$potlib" ; then
+                 $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
+               else
+                 $echo "*** with $libname and none of the candidates passed a file format test"
+                 $echo "*** using a regex pattern. Last file checked: $potlib"
+               fi
+             fi
+           else
+             # Add a -L argument.
+             newdeplibs="$newdeplibs $a_deplib"
+           fi
+         done # Gone through all deplibs.
+         ;;
+       none | unknown | *)
+         newdeplibs=""
+         tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
+           -e 's/ -[LR][^ ]*//g'`
+         if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+           for i in $predeps $postdeps ; do
+             # can't use Xsed below, because $i might contain '/'
+             tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
+           done
+         fi
+         if $echo "X $tmp_deplibs" | $Xsed -e 's/[     ]//g' \
+           | grep . >/dev/null; then
+           $echo
+           if test "X$deplibs_check_method" = "Xnone"; then
+             $echo "*** Warning: inter-library dependencies are not supported in this platform."
+           else
+             $echo "*** Warning: inter-library dependencies are not known to be supported."
+           fi
+           $echo "*** All declared inter-library dependencies are being dropped."
+           droppeddeps=yes
+         fi
+         ;;
+       esac
+       versuffix=$versuffix_save
+       major=$major_save
+       release=$release_save
+       libname=$libname_save
+       name=$name_save
+
+       case $host in
+       *-*-rhapsody* | *-*-darwin1.[012])
+         # On Rhapsody replace the C library is the System framework
+         newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
+         ;;
+       esac
+
+       if test "$droppeddeps" = yes; then
+         if test "$module" = yes; then
+           $echo
+           $echo "*** Warning: libtool could not satisfy all declared inter-library"
+           $echo "*** dependencies of module $libname.  Therefore, libtool will create"
+           $echo "*** a static module, that should work as long as the dlopening"
+           $echo "*** application is linked with the -dlopen flag."
+           if test -z "$global_symbol_pipe"; then
+             $echo
+             $echo "*** However, this would only work if libtool was able to extract symbol"
+             $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+             $echo "*** not find such a program.  So, this module is probably useless."
+             $echo "*** \`nm' from GNU binutils and a full rebuild may help."
+           fi
+           if test "$build_old_libs" = no; then
+             oldlibs="$output_objdir/$libname.$libext"
+             build_libtool_libs=module
+             build_old_libs=yes
+           else
+             build_libtool_libs=no
+           fi
+         else
+           $echo "*** The inter-library dependencies that have been dropped here will be"
+           $echo "*** automatically added whenever a program is linked with this library"
+           $echo "*** or is declared to -dlopen it."
+
+           if test "$allow_undefined" = no; then
+             $echo
+             $echo "*** Since this library must not contain undefined symbols,"
+             $echo "*** because either the platform does not support them or"
+             $echo "*** it was explicitly requested with -no-undefined,"
+             $echo "*** libtool will only create a static version of it."
+             if test "$build_old_libs" = no; then
+               oldlibs="$output_objdir/$libname.$libext"
+               build_libtool_libs=module
+               build_old_libs=yes
+             else
+               build_libtool_libs=no
+             fi
+           fi
+         fi
+       fi
+       # Done checking deplibs!
+       deplibs=$newdeplibs
+      fi
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+       case " $new_libs " in
+       *" -L$path/$objdir "*) ;;
+       *)
+         case " $deplibs " in
+         *" -L$path/$objdir "*)
+           new_libs="$new_libs -L$path/$objdir" ;;
+         esac
+         ;;
+       esac
+      done
+      for deplib in $deplibs; do
+       case $deplib in
+       -L*)
+         case " $new_libs " in
+         *" $deplib "*) ;;
+         *) new_libs="$new_libs $deplib" ;;
+         esac
+         ;;
+       *) new_libs="$new_libs $deplib" ;;
+       esac
+      done
+      deplibs="$new_libs"
+
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+       if test "$hardcode_into_libs" = yes; then
+         # Hardcode the library paths
+         hardcode_libdirs=
+         dep_rpath=
+         rpath="$finalize_rpath"
+         test "$mode" != relink && rpath="$compile_rpath$rpath"
+         for libdir in $rpath; do
+           if test -n "$hardcode_libdir_flag_spec"; then
+             if test -n "$hardcode_libdir_separator"; then
+               if test -z "$hardcode_libdirs"; then
+                 hardcode_libdirs="$libdir"
+               else
+                 # Just accumulate the unique libdirs.
+                 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+                 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+                   ;;
+                 *)
+                   hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+                   ;;
+                 esac
+               fi
+             else
+               eval flag=\"$hardcode_libdir_flag_spec\"
+               dep_rpath="$dep_rpath $flag"
+             fi
+           elif test -n "$runpath_var"; then
+             case "$perm_rpath " in
+             *" $libdir "*) ;;
+             *) perm_rpath="$perm_rpath $libdir" ;;
+             esac
+           fi
+         done
+         # Substitute the hardcoded libdirs into the rpath.
+         if test -n "$hardcode_libdir_separator" &&
+            test -n "$hardcode_libdirs"; then
+           libdir="$hardcode_libdirs"
+           if test -n "$hardcode_libdir_flag_spec_ld"; then
+             eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+           else
+             eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+           fi
+         fi
+         if test -n "$runpath_var" && test -n "$perm_rpath"; then
+           # We should set the runpath_var.
+           rpath=
+           for dir in $perm_rpath; do
+             rpath="$rpath$dir:"
+           done
+           eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+         fi
+         test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+       fi
+
+       shlibpath="$finalize_shlibpath"
+       test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+       if test -n "$shlibpath"; then
+         eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+       fi
+
+       # Get the real and link names of the library.
+       eval shared_ext=\"$shrext_cmds\"
+       eval library_names=\"$library_names_spec\"
+       set dummy $library_names
+       realname="$2"
+       shift; shift
+
+       if test -n "$soname_spec"; then
+         eval soname=\"$soname_spec\"
+       else
+         soname="$realname"
+       fi
+       if test -z "$dlname"; then
+         dlname=$soname
+       fi
+
+       lib="$output_objdir/$realname"
+       linknames=
+       for link
+       do
+         linknames="$linknames $link"
+       done
+
+       # Use standard objects if they are pic
+       test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+
+       # Prepare the list of exported symbols
+       if test -z "$export_symbols"; then
+         if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+           $show "generating symbol list for \`$libname.la'"
+           export_symbols="$output_objdir/$libname.exp"
+           $run $rm $export_symbols
+           cmds=$export_symbols_cmds
+           save_ifs="$IFS"; IFS='~'
+           for cmd in $cmds; do
+             IFS="$save_ifs"
+             eval cmd=\"$cmd\"
+             if len=`expr "X$cmd" : ".*"` &&
+              test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+               $show "$cmd"
+               $run eval "$cmd" || exit $?
+               skipped_export=false
+             else
+               # The command line is too long to execute in one step.
+               $show "using reloadable object file for export list..."
+               skipped_export=:
+               # Break out early, otherwise skipped_export may be
+               # set to false by a later but shorter cmd.
+               break
+             fi
+           done
+           IFS="$save_ifs"
+           if test -n "$export_symbols_regex"; then
+             $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
+             $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+             $show "$mv \"${export_symbols}T\" \"$export_symbols\""
+             $run eval '$mv "${export_symbols}T" "$export_symbols"'
+           fi
+         fi
+       fi
+
+       if test -n "$export_symbols" && test -n "$include_expsyms"; then
+         $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
+       fi
+
+       tmp_deplibs=
+       for test_deplib in $deplibs; do
+               case " $convenience " in
+               *" $test_deplib "*) ;;
+               *)
+                       tmp_deplibs="$tmp_deplibs $test_deplib"
+                       ;;
+               esac
+       done
+       deplibs="$tmp_deplibs"
+
+       if test -n "$convenience"; then
+         if test -n "$whole_archive_flag_spec"; then
+           save_libobjs=$libobjs
+           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+         else
+           gentop="$output_objdir/${outputname}x"
+           generated="$generated $gentop"
+
+           func_extract_archives $gentop $convenience
+           libobjs="$libobjs $func_extract_archives_result"
+         fi
+       fi
+       
+       if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+         eval flag=\"$thread_safe_flag_spec\"
+         linker_flags="$linker_flags $flag"
+       fi
+
+       # Make a backup of the uninstalled library when relinking
+       if test "$mode" = relink; then
+         $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
+       fi
+
+       # Do each of the archive commands.
+       if test "$module" = yes && test -n "$module_cmds" ; then
+         if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+           eval test_cmds=\"$module_expsym_cmds\"
+           cmds=$module_expsym_cmds
+         else
+           eval test_cmds=\"$module_cmds\"
+           cmds=$module_cmds
+         fi
+       else
+       if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+         eval test_cmds=\"$archive_expsym_cmds\"
+         cmds=$archive_expsym_cmds
+       else
+         eval test_cmds=\"$archive_cmds\"
+         cmds=$archive_cmds
+         fi
+       fi
+
+       if test "X$skipped_export" != "X:" &&
+          len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+          test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+         :
+       else
+         # The command line is too long to link in one step, link piecewise.
+         $echo "creating reloadable object files..."
+
+         # Save the value of $output and $libobjs because we want to
+         # use them later.  If we have whole_archive_flag_spec, we
+         # want to use save_libobjs as it was before
+         # whole_archive_flag_spec was expanded, because we can't
+         # assume the linker understands whole_archive_flag_spec.
+         # This may have to be revisited, in case too many
+         # convenience libraries get linked in and end up exceeding
+         # the spec.
+         if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+           save_libobjs=$libobjs
+         fi
+         save_output=$output
+         output_la=`$echo "X$output" | $Xsed -e "$basename"`
+
+         # Clear the reloadable object creation command queue and
+         # initialize k to one.
+         test_cmds=
+         concat_cmds=
+         objlist=
+         delfiles=
+         last_robj=
+         k=1
+         output=$output_objdir/$output_la-${k}.$objext
+         # Loop over the list of objects to be linked.
+         for obj in $save_libobjs
+         do
+           eval test_cmds=\"$reload_cmds $objlist $last_robj\"
+           if test "X$objlist" = X ||
+              { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+                test "$len" -le "$max_cmd_len"; }; then
+             objlist="$objlist $obj"
+           else
+             # The command $test_cmds is almost too long, add a
+             # command to the queue.
+             if test "$k" -eq 1 ; then
+               # The first file doesn't have a previous command to add.
+               eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+             else
+               # All subsequent reloadable object files will link in
+               # the last one created.
+               eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
+             fi
+             last_robj=$output_objdir/$output_la-${k}.$objext
+             k=`expr $k + 1`
+             output=$output_objdir/$output_la-${k}.$objext
+             objlist=$obj
+             len=1
+           fi
+         done
+         # Handle the remaining objects by creating one last
+         # reloadable object file.  All subsequent reloadable object
+         # files will link in the last one created.
+         test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+         eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+
+         if ${skipped_export-false}; then
+           $show "generating symbol list for \`$libname.la'"
+           export_symbols="$output_objdir/$libname.exp"
+           $run $rm $export_symbols
+           libobjs=$output
+           # Append the command to create the export file.
+           eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
+          fi
+
+         # Set up a command to remove the reloadable object files
+         # after they are used.
+         i=0
+         while test "$i" -lt "$k"
+         do
+           i=`expr $i + 1`
+           delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
+         done
+
+         $echo "creating a temporary reloadable object file: $output"
+
+         # Loop through the commands generated above and execute them.
+         save_ifs="$IFS"; IFS='~'
+         for cmd in $concat_cmds; do
+           IFS="$save_ifs"
+           $show "$cmd"
+           $run eval "$cmd" || exit $?
+         done
+         IFS="$save_ifs"
+
+         libobjs=$output
+         # Restore the value of output.
+         output=$save_output
+
+         if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+         fi
+         # Expand the library linking commands again to reset the
+         # value of $libobjs for piecewise linking.
+
+         # Do each of the archive commands.
+         if test "$module" = yes && test -n "$module_cmds" ; then
+           if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+             cmds=$module_expsym_cmds
+           else
+             cmds=$module_cmds
+           fi
+         else
+         if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+           cmds=$archive_expsym_cmds
+         else
+           cmds=$archive_cmds
+           fi
+         fi
+
+         # Append the command to remove the reloadable object files
+         # to the just-reset $cmds.
+         eval cmds=\"\$cmds~\$rm $delfiles\"
+       fi
+       save_ifs="$IFS"; IFS='~'
+       for cmd in $cmds; do
+         IFS="$save_ifs"
+         eval cmd=\"$cmd\"
+         $show "$cmd"
+         $run eval "$cmd" || {
+           lt_exit=$?
+
+           # Restore the uninstalled library and exit
+           if test "$mode" = relink; then
+             $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
+           fi
+
+           exit $lt_exit
+         }
+       done
+       IFS="$save_ifs"
+
+       # Restore the uninstalled library and exit
+       if test "$mode" = relink; then
+         $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
+
+         if test -n "$convenience"; then
+           if test -z "$whole_archive_flag_spec"; then
+             $show "${rm}r $gentop"
+             $run ${rm}r "$gentop"
+           fi
+         fi
+
+         exit $EXIT_SUCCESS
+       fi
+
+       # Create links to the real library.
+       for linkname in $linknames; do
+         if test "$realname" != "$linkname"; then
+           $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
+           $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
+         fi
+       done
+
+       # If -module or -export-dynamic was specified, set the dlname.
+       if test "$module" = yes || test "$export_dynamic" = yes; then
+         # On all known operating systems, these are identical.
+         dlname="$soname"
+       fi
+      fi
+      ;;
+
+    obj)
+      if test -n "$deplibs"; then
+       $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$rpath"; then
+       $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$xrpath"; then
+       $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$vinfo"; then
+       $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$release"; then
+       $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
+      fi
+
+      case $output in
+      *.lo)
+       if test -n "$objs$old_deplibs"; then
+         $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
+         exit $EXIT_FAILURE
+       fi
+       libobj="$output"
+       obj=`$echo "X$output" | $Xsed -e "$lo2o"`
+       ;;
+      *)
+       libobj=
+       obj="$output"
+       ;;
+      esac
+
+      # Delete the old objects.
+      $run $rm $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec
+      wl=
+
+      if test -n "$convenience"; then
+       if test -n "$whole_archive_flag_spec"; then
+         eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
+       else
+         gentop="$output_objdir/${obj}x"
+         generated="$generated $gentop"
+
+         func_extract_archives $gentop $convenience
+         reload_conv_objs="$reload_objs $func_extract_archives_result"
+       fi
+      fi
+
+      # Create the old-style object.
+      reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+      output="$obj"
+      cmds=$reload_cmds
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+       IFS="$save_ifs"
+       eval cmd=\"$cmd\"
+       $show "$cmd"
+       $run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+       if test -n "$gentop"; then
+         $show "${rm}r $gentop"
+         $run ${rm}r $gentop
+       fi
+
+       exit $EXIT_SUCCESS
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+       if test -n "$gentop"; then
+         $show "${rm}r $gentop"
+         $run ${rm}r $gentop
+       fi
+
+       # Create an invalid libtool object if no PIC, so that we don't
+       # accidentally link it into a program.
+       # $show "echo timestamp > $libobj"
+       # $run eval "echo timestamp > $libobj" || exit $?
+       exit $EXIT_SUCCESS
+      fi
+
+      if test -n "$pic_flag" || test "$pic_mode" != default; then
+       # Only do commands if we really have different PIC objects.
+       reload_objs="$libobjs $reload_conv_objs"
+       output="$libobj"
+       cmds=$reload_cmds
+       save_ifs="$IFS"; IFS='~'
+       for cmd in $cmds; do
+         IFS="$save_ifs"
+         eval cmd=\"$cmd\"
+         $show "$cmd"
+         $run eval "$cmd" || exit $?
+       done
+       IFS="$save_ifs"
+      fi
+
+      if test -n "$gentop"; then
+       $show "${rm}r $gentop"
+       $run ${rm}r $gentop
+      fi
+
+      exit $EXIT_SUCCESS
+      ;;
+
+    prog)
+      case $host in
+       *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
+      esac
+      if test -n "$vinfo"; then
+       $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
+      fi
+
+      if test -n "$release"; then
+       $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
+      fi
+
+      if test "$preload" = yes; then
+       if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
+          test "$dlopen_self_static" = unknown; then
+         $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
+       fi
+      fi
+
+      case $host in
+      *-*-rhapsody* | *-*-darwin1.[012])
+       # On Rhapsody replace the C library is the System framework
+       compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+       finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+       ;;
+      esac
+
+      case $host in
+      *darwin*)
+        # Don't allow lazy linking, it breaks C++ global constructors
+        if test "$tagname" = CXX ; then
+        compile_command="$compile_command ${wl}-bind_at_load"
+        finalize_command="$finalize_command ${wl}-bind_at_load"
+        fi
+        ;;
+      esac
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+       case " $new_libs " in
+       *" -L$path/$objdir "*) ;;
+       *)
+         case " $compile_deplibs " in
+         *" -L$path/$objdir "*)
+           new_libs="$new_libs -L$path/$objdir" ;;
+         esac
+         ;;
+       esac
+      done
+      for deplib in $compile_deplibs; do
+       case $deplib in
+       -L*)
+         case " $new_libs " in
+         *" $deplib "*) ;;
+         *) new_libs="$new_libs $deplib" ;;
+         esac
+         ;;
+       *) new_libs="$new_libs $deplib" ;;
+       esac
+      done
+      compile_deplibs="$new_libs"
+
+
+      compile_command="$compile_command $compile_deplibs"
+      finalize_command="$finalize_command $finalize_deplibs"
+
+      if test -n "$rpath$xrpath"; then
+       # If the user specified any rpath flags, then add them.
+       for libdir in $rpath $xrpath; do
+         # This is the magic to use -rpath.
+         case "$finalize_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_rpath="$finalize_rpath $libdir" ;;
+         esac
+       done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+       if test -n "$hardcode_libdir_flag_spec"; then
+         if test -n "$hardcode_libdir_separator"; then
+           if test -z "$hardcode_libdirs"; then
+             hardcode_libdirs="$libdir"
+           else
+             # Just accumulate the unique libdirs.
+             case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+             *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+               ;;
+             *)
+               hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+               ;;
+             esac
+           fi
+         else
+           eval flag=\"$hardcode_libdir_flag_spec\"
+           rpath="$rpath $flag"
+         fi
+       elif test -n "$runpath_var"; then
+         case "$perm_rpath " in
+         *" $libdir "*) ;;
+         *) perm_rpath="$perm_rpath $libdir" ;;
+         esac
+       fi
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+         testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
+         case :$dllsearchpath: in
+         *":$libdir:"*) ;;
+         *) dllsearchpath="$dllsearchpath:$libdir";;
+         esac
+         case :$dllsearchpath: in
+         *":$testbindir:"*) ;;
+         *) dllsearchpath="$dllsearchpath:$testbindir";;
+         esac
+         ;;
+       esac
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+        test -n "$hardcode_libdirs"; then
+       libdir="$hardcode_libdirs"
+       eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+       if test -n "$hardcode_libdir_flag_spec"; then
+         if test -n "$hardcode_libdir_separator"; then
+           if test -z "$hardcode_libdirs"; then
+             hardcode_libdirs="$libdir"
+           else
+             # Just accumulate the unique libdirs.
+             case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+             *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+               ;;
+             *)
+               hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+               ;;
+             esac
+           fi
+         else
+           eval flag=\"$hardcode_libdir_flag_spec\"
+           rpath="$rpath $flag"
+         fi
+       elif test -n "$runpath_var"; then
+         case "$finalize_perm_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+         esac
+       fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+        test -n "$hardcode_libdirs"; then
+       libdir="$hardcode_libdirs"
+       eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+       # Transform all the library objects into standard objects.
+       compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+       finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+      fi
+
+      dlsyms=
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       if test -n "$NM" && test -n "$global_symbol_pipe"; then
+         dlsyms="${outputname}S.c"
+       else
+         $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
+       fi
+      fi
+
+      if test -n "$dlsyms"; then
+       case $dlsyms in
+       "") ;;
+       *.c)
+         # Discover the nlist of each of the dlfiles.
+         nlist="$output_objdir/${outputname}.nm"
+
+         $show "$rm $nlist ${nlist}S ${nlist}T"
+         $run $rm "$nlist" "${nlist}S" "${nlist}T"
+
+         # Parse the name list into a source file.
+         $show "creating $output_objdir/$dlsyms"
+
+         test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
+/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
+/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* Prevent the only kind of declaration conflicts we can make. */
+#define lt_preloaded_symbols some_other_symbol
+
+/* External symbol declarations for the compiler. */\
+"
+
+         if test "$dlself" = yes; then
+           $show "generating symbol list for \`$output'"
+
+           test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
+
+           # Add our own program objects to the symbol list.
+           progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+           for arg in $progfiles; do
+             $show "extracting global C symbols from \`$arg'"
+             $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+           done
+
+           if test -n "$exclude_expsyms"; then
+             $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+             $run eval '$mv "$nlist"T "$nlist"'
+           fi
+
+           if test -n "$export_symbols_regex"; then
+             $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+             $run eval '$mv "$nlist"T "$nlist"'
+           fi
+
+           # Prepare the list of exported symbols
+           if test -z "$export_symbols"; then
+             export_symbols="$output_objdir/$outputname.exp"
+             $run $rm $export_symbols
+             $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+              case $host in
+              *cygwin* | *mingw* )
+               $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+               $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+                ;;
+              esac
+           else
+             $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+             $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+             $run eval 'mv "$nlist"T "$nlist"'
+              case $host in
+              *cygwin* | *mingw* )
+               $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+               $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+                ;;
+              esac
+           fi
+         fi
+
+         for arg in $dlprefiles; do
+           $show "extracting global C symbols from \`$arg'"
+           name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
+           $run eval '$echo ": $name " >> "$nlist"'
+           $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+         done
+
+         if test -z "$run"; then
+           # Make sure we have at least an empty file.
+           test -f "$nlist" || : > "$nlist"
+
+           if test -n "$exclude_expsyms"; then
+             $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+             $mv "$nlist"T "$nlist"
+           fi
+
+           # Try sorting and uniquifying the output.
+           if grep -v "^: " < "$nlist" |
+               if sort -k 3 </dev/null >/dev/null 2>&1; then
+                 sort -k 3
+               else
+                 sort +2
+               fi |
+               uniq > "$nlist"S; then
+             :
+           else
+             grep -v "^: " < "$nlist" > "$nlist"S
+           fi
+
+           if test -f "$nlist"S; then
+             eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
+           else
+             $echo '/* NONE */' >> "$output_objdir/$dlsyms"
+           fi
+
+           $echo >> "$output_objdir/$dlsyms" "\
+
+#undef lt_preloaded_symbols
+
+#if defined (__STDC__) && __STDC__
+# define lt_ptr void *
+#else
+# define lt_ptr char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+"
+
+           case $host in
+           *cygwin* | *mingw* )
+         $echo >> "$output_objdir/$dlsyms" "\
+/* DATA imports from DLLs on WIN32 can't be const, because
+   runtime relocations are performed -- see ld's documentation
+   on pseudo-relocs */
+struct {
+"
+             ;;
+           * )
+         $echo >> "$output_objdir/$dlsyms" "\
+const struct {
+"
+             ;;
+           esac
+
+
+         $echo >> "$output_objdir/$dlsyms" "\
+  const char *name;
+  lt_ptr address;
+}
+lt_preloaded_symbols[] =
+{\
+"
+
+           eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
+
+           $echo >> "$output_objdir/$dlsyms" "\
+  {0, (lt_ptr) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+         fi
+
+         pic_flag_for_symtable=
+         case $host in
+         # compiling the symbol table file with pic_flag works around
+         # a FreeBSD bug that causes programs to crash when -lm is
+         # linked before any other PIC object.  But we must not use
+         # pic_flag when linking with -static.  The problem exists in
+         # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+         *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+           case "$compile_command " in
+           *" -static "*) ;;
+           *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
+           esac;;
+         *-*-hpux*)
+           case "$compile_command " in
+           *" -static "*) ;;
+           *) pic_flag_for_symtable=" $pic_flag";;
+           esac
+         esac
+
+         # Now compile the dynamic symbol file.
+         $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+         $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+
+         # Clean up the generated files.
+         $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
+         $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
+
+         # Transform the symbol file into the correct name.
+          case $host in
+          *cygwin* | *mingw* )
+            if test -f "$output_objdir/${outputname}.def" ; then
+              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
+              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
+            else
+              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+             fi
+            ;;
+          * )
+            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+            ;;
+          esac
+         ;;
+       *)
+         $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+      else
+       # We keep going just in case the user didn't refer to
+       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+       # really was required.
+
+       # Nullify the symbol file.
+       compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+       finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+      fi
+
+      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+       # Replace the output file specification.
+       compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+       link_command="$compile_command$compile_rpath"
+
+       # We have no uninstalled library dependencies, so finalize right now.
+       $show "$link_command"
+       $run eval "$link_command"
+       exit_status=$?
+
+       # Delete the generated files.
+       if test -n "$dlsyms"; then
+         $show "$rm $output_objdir/${outputname}S.${objext}"
+         $run $rm "$output_objdir/${outputname}S.${objext}"
+       fi
+
+       exit $exit_status
+      fi
+
+      if test -n "$shlibpath_var"; then
+       # We should set the shlibpath_var
+       rpath=
+       for dir in $temp_rpath; do
+         case $dir in
+         [\\/]* | [A-Za-z]:[\\/]*)
+           # Absolute path.
+           rpath="$rpath$dir:"
+           ;;
+         *)
+           # Relative path: add a thisdir entry.
+           rpath="$rpath\$thisdir/$dir:"
+           ;;
+         esac
+       done
+       temp_rpath="$rpath"
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+       compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+       finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+       if test -n "$perm_rpath"; then
+         # We should set the runpath_var.
+         rpath=
+         for dir in $perm_rpath; do
+           rpath="$rpath$dir:"
+         done
+         compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+       fi
+       if test -n "$finalize_perm_rpath"; then
+         # We should set the runpath_var.
+         rpath=
+         for dir in $finalize_perm_rpath; do
+           rpath="$rpath$dir:"
+         done
+         finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+       fi
+      fi
+
+      if test "$no_install" = yes; then
+       # We don't need to create a wrapper script.
+       link_command="$compile_var$compile_command$compile_rpath"
+       # Replace the output file specification.
+       link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+       # Delete the old output file.
+       $run $rm $output
+       # Link the executable and exit
+       $show "$link_command"
+       $run eval "$link_command" || exit $?
+       exit $EXIT_SUCCESS
+      fi
+
+      if test "$hardcode_action" = relink; then
+       # Fast installation is not supported
+       link_command="$compile_var$compile_command$compile_rpath"
+       relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+       $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
+       $echo "$modename: \`$output' will be relinked during installation" 1>&2
+      else
+       if test "$fast_install" != no; then
+         link_command="$finalize_var$compile_command$finalize_rpath"
+         if test "$fast_install" = yes; then
+           relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+         else
+           # fast_install is set to needless
+           relink_command=
+         fi
+       else
+         link_command="$compile_var$compile_command$compile_rpath"
+         relink_command="$finalize_var$finalize_command$finalize_rpath"
+       fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+      # Delete the old output files.
+      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      $show "$link_command"
+      $run eval "$link_command" || exit $?
+
+      # Now create the wrapper script.
+      $show "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+       # Preserve any variables that may affect compiler behavior
+       for var in $variables_saved_for_relink; do
+         if eval test -z \"\${$var+set}\"; then
+           relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
+         elif eval var_value=\$$var; test -z "$var_value"; then
+           relink_command="$var=; export $var; $relink_command"
+         else
+           var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
+           relink_command="$var=\"$var_value\"; export $var; $relink_command"
+         fi
+       done
+       relink_command="(cd `pwd`; $relink_command)"
+       relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Quote $echo for shipping.
+      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
+       case $progpath in
+       [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
+       *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
+       esac
+       qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
+      else
+       qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if our run command is non-null.
+      if test -z "$run"; then
+       # win32 will think the script is a binary if it has
+       # a .exe suffix, so we strip it off here.
+       case $output in
+         *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
+       esac
+       # test for cygwin because mv fails w/o .exe extensions
+       case $host in
+         *cygwin*)
+           exeext=.exe
+           outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
+         *) exeext= ;;
+       esac
+       case $host in
+         *cygwin* | *mingw* )
+            output_name=`basename $output`
+            output_path=`dirname $output`
+            cwrappersource="$output_path/$objdir/lt-$output_name.c"
+            cwrapper="$output_path/$output_name.exe"
+            $rm $cwrappersource $cwrapper
+            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+           cat > $cwrappersource <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+
+   The $output program cannot be directly executed until all the libtool
+   libraries that it depends on are installed.
+
+   This wrapper executable should never be moved out of the build directory.
+   If it is, it will not operate correctly.
+
+   Currently, it simply execs the wrapper *script* "/bin/sh $output",
+   but could eventually absorb all of the scripts functionality and
+   exec $objdir/$outputname directly.
+*/
+EOF
+           cat >> $cwrappersource<<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/stat.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+  defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# ifndef DIR_SEPARATOR_2
+#  define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+#  define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+  if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+/* -DDEBUG is fairly common in CFLAGS.  */
+#undef DEBUG
+#if defined DEBUGWRAPPER
+# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
+#else
+# define DEBUG(format, ...)
+#endif
+
+const char *program_name = NULL;
+
+void * xmalloc (size_t num);
+char * xstrdup (const char *string);
+const char * base_name (const char *name);
+char * find_executable(const char *wrapper);
+int    check_executable(const char *path);
+char * strendzap(char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+
+int
+main (int argc, char *argv[])
+{
+  char **newargz;
+  int i;
+
+  program_name = (char *) xstrdup (base_name (argv[0]));
+  DEBUG("(main) argv[0]      : %s\n",argv[0]);
+  DEBUG("(main) program_name : %s\n",program_name);
+  newargz = XMALLOC(char *, argc+2);
+EOF
+
+            cat >> $cwrappersource <<EOF
+  newargz[0] = (char *) xstrdup("$SHELL");
+EOF
+
+            cat >> $cwrappersource <<"EOF"
+  newargz[1] = find_executable(argv[0]);
+  if (newargz[1] == NULL)
+    lt_fatal("Couldn't find %s", argv[0]);
+  DEBUG("(main) found exe at : %s\n",newargz[1]);
+  /* we know the script has the same name, without the .exe */
+  /* so make sure newargz[1] doesn't end in .exe */
+  strendzap(newargz[1],".exe");
+  for (i = 1; i < argc; i++)
+    newargz[i+1] = xstrdup(argv[i]);
+  newargz[argc+1] = NULL;
+
+  for (i=0; i<argc+1; i++)
+  {
+    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
+    ;
+  }
+
+EOF
+
+            case $host_os in
+              mingw*)
+                cat >> $cwrappersource <<EOF
+  execv("$SHELL",(char const **)newargz);
+EOF
+              ;;
+              *)
+                cat >> $cwrappersource <<EOF
+  execv("$SHELL",newargz);
+EOF
+              ;;
+            esac
+
+            cat >> $cwrappersource <<"EOF"
+  return 127;
+}
+
+void *
+xmalloc (size_t num)
+{
+  void * p = (void *) malloc (num);
+  if (!p)
+    lt_fatal ("Memory exhausted");
+
+  return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
+;
+}
+
+const char *
+base_name (const char *name)
+{
+  const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  /* Skip over the disk name in MSDOS pathnames. */
+  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
+    name += 2;
+#endif
+
+  for (base = name; *name; name++)
+    if (IS_DIR_SEPARATOR (*name))
+      base = name + 1;
+  return base;
+}
+
+int
+check_executable(const char * path)
+{
+  struct stat st;
+
+  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
+  if ((!path) || (!*path))
+    return 0;
+
+  if ((stat (path, &st) >= 0) &&
+      (
+        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
+#if defined (S_IXOTH)
+       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
+#endif
+#if defined (S_IXGRP)
+       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
+#endif
+       ((st.st_mode & S_IXUSR) == S_IXUSR))
+      )
+    return 1;
+  else
+    return 0;
+}
+
+/* Searches for the full path of the wrapper.  Returns
+   newly allocated full path name if found, NULL otherwise */
+char *
+find_executable (const char* wrapper)
+{
+  int has_slash = 0;
+  const char* p;
+  const char* p_next;
+  /* static buffer for getcwd */
+  char tmp[LT_PATHMAX + 1];
+  int tmp_len;
+  char* concat_name;
+
+  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
+
+  if ((wrapper == NULL) || (*wrapper == '\0'))
+    return NULL;
+
+  /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
+  {
+    concat_name = xstrdup (wrapper);
+    if (check_executable(concat_name))
+      return concat_name;
+    XFREE(concat_name);
+  }
+  else
+  {
+#endif
+    if (IS_DIR_SEPARATOR (wrapper[0]))
+    {
+      concat_name = xstrdup (wrapper);
+      if (check_executable(concat_name))
+        return concat_name;
+      XFREE(concat_name);
+    }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  }
+#endif
+
+  for (p = wrapper; *p; p++)
+    if (*p == '/')
+    {
+      has_slash = 1;
+      break;
+    }
+  if (!has_slash)
+  {
+    /* no slashes; search PATH */
+    const char* path = getenv ("PATH");
+    if (path != NULL)
+    {
+      for (p = path; *p; p = p_next)
+      {
+        const char* q;
+        size_t p_len;
+        for (q = p; *q; q++)
+          if (IS_PATH_SEPARATOR(*q))
+            break;
+        p_len = q - p;
+        p_next = (*q == '\0' ? q : q + 1);
+        if (p_len == 0)
+        {
+          /* empty path: current directory */
+          if (getcwd (tmp, LT_PATHMAX) == NULL)
+            lt_fatal ("getcwd failed");
+          tmp_len = strlen(tmp);
+          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
+          memcpy (concat_name, tmp, tmp_len);
+          concat_name[tmp_len] = '/';
+          strcpy (concat_name + tmp_len + 1, wrapper);
+        }
+        else
+        {
+          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
+          memcpy (concat_name, p, p_len);
+          concat_name[p_len] = '/';
+          strcpy (concat_name + p_len + 1, wrapper);
+        }
+        if (check_executable(concat_name))
+          return concat_name;
+        XFREE(concat_name);
+      }
+    }
+    /* not found in PATH; assume curdir */
+  }
+  /* Relative path | not found in path: prepend cwd */
+  if (getcwd (tmp, LT_PATHMAX) == NULL)
+    lt_fatal ("getcwd failed");
+  tmp_len = strlen(tmp);
+  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
+  memcpy (concat_name, tmp, tmp_len);
+  concat_name[tmp_len] = '/';
+  strcpy (concat_name + tmp_len + 1, wrapper);
+
+  if (check_executable(concat_name))
+    return concat_name;
+  XFREE(concat_name);
+  return NULL;
+}
+
+char *
+strendzap(char *str, const char *pat)
+{
+  size_t len, patlen;
+
+  assert(str != NULL);
+  assert(pat != NULL);
+
+  len = strlen(str);
+  patlen = strlen(pat);
+
+  if (patlen <= len)
+  {
+    str += len - patlen;
+    if (strcmp(str, pat) == 0)
+      *str = '\0';
+  }
+  return str;
+}
+
+static void
+lt_error_core (int exit_status, const char * mode,
+          const char * message, va_list ap)
+{
+  fprintf (stderr, "%s: %s: ", program_name, mode);
+  vfprintf (stderr, message, ap);
+  fprintf (stderr, ".\n");
+
+  if (exit_status >= 0)
+    exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+  va_end (ap);
+}
+EOF
+          # we should really use a build-platform specific compiler
+          # here, but OTOH, the wrappers (shell script and this C one)
+          # are only useful if you want to execute the "real" binary.
+          # Since the "real" binary is built for $host, then this
+          # wrapper might as well be built for $host, too.
+          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
+          ;;
+        esac
+        $rm $output
+        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
+
+       $echo > $output "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variable:
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$echo are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    echo=\"$qecho\"
+    file=\"\$0\"
+    # Make sure echo works.
+    if test \"X\$1\" = X--no-reexec; then
+      # Discard the --no-reexec flag, and continue.
+      shift
+    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
+      # Yippee, \$echo works!
+      :
+    else
+      # Restart under the correct shell, and then maybe \$echo will work.
+      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+    fi
+  fi\
+"
+       $echo >> $output "\
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
+  done
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+       if test "$fast_install" = yes; then
+         $echo >> $output "\
+  program=lt-'$outputname'$exeext
+  progdir=\"\$thisdir/$objdir\"
+
+  if test ! -f \"\$progdir/\$program\" || \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $mkdir \"\$progdir\"
+    else
+      $rm \"\$progdir/\$file\"
+    fi"
+
+         $echo >> $output "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+      else
+       $echo \"\$relink_command_output\" >&2
+       $rm \"\$progdir/\$file\"
+       exit $EXIT_FAILURE
+      fi
+    fi
+
+    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $rm \"\$progdir/\$program\";
+      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $rm \"\$progdir/\$file\"
+  fi"
+       else
+         $echo >> $output "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+       fi
+
+       $echo >> $output "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+       # Export our shlibpath_var if we have one.
+       if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+         $echo >> $output "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+       fi
+
+       # fixup the dll searchpath if we need to.
+       if test -n "$dllsearchpath"; then
+         $echo >> $output "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+       fi
+
+       $echo >> $output "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+"
+       case $host in
+       # Backslashes separate directories on plain windows
+       *-*-mingw | *-*-os2*)
+         $echo >> $output "\
+      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+         ;;
+
+       *)
+         $echo >> $output "\
+      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+         ;;
+       esac
+       $echo >> $output "\
+      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
+      exit $EXIT_FAILURE
+    fi
+  else
+    # The program doesn't exist.
+    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$echo \"This script is just a wrapper for \$program.\" 1>&2
+    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit $EXIT_FAILURE
+  fi
+fi\
+"
+       chmod +x $output
+      fi
+      exit $EXIT_SUCCESS
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+       oldobjs="$libobjs_save"
+       addlibs="$convenience"
+       build_libtool_libs=no
+      else
+       if test "$build_libtool_libs" = module; then
+         oldobjs="$libobjs_save"
+         build_libtool_libs=no
+       else
+         oldobjs="$old_deplibs $non_pic_objects"
+       fi
+       addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+       gentop="$output_objdir/${outputname}x"
+       generated="$generated $gentop"
+
+       func_extract_archives $gentop $addlibs
+       oldobjs="$oldobjs $func_extract_archives_result"
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+       cmds=$old_archive_from_new_cmds
+      else
+       # POSIX demands no paths to be encoded in archives.  We have
+       # to avoid creating archives with duplicate basenames if we
+       # might have to extract them afterwards, e.g., when creating a
+       # static archive out of a convenience library, or when linking
+       # the entirety of a libtool archive into another (currently
+       # not supported by libtool).
+       if (for obj in $oldobjs
+           do
+             $echo "X$obj" | $Xsed -e 's%^.*/%%'
+           done | sort | sort -uc >/dev/null 2>&1); then
+         :
+       else
+         $echo "copying selected object files to avoid basename conflicts..."
+
+         if test -z "$gentop"; then
+           gentop="$output_objdir/${outputname}x"
+           generated="$generated $gentop"
+
+           $show "${rm}r $gentop"
+           $run ${rm}r "$gentop"
+           $show "$mkdir $gentop"
+           $run $mkdir "$gentop"
+           exit_status=$?
+           if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
+             exit $exit_status
+           fi
+         fi
+
+         save_oldobjs=$oldobjs
+         oldobjs=
+         counter=1
+         for obj in $save_oldobjs
+         do
+           objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+           case " $oldobjs " in
+           " ") oldobjs=$obj ;;
+           *[\ /]"$objbase "*)
+             while :; do
+               # Make sure we don't pick an alternate name that also
+               # overlaps.
+               newobj=lt$counter-$objbase
+               counter=`expr $counter + 1`
+               case " $oldobjs " in
+               *[\ /]"$newobj "*) ;;
+               *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+               esac
+             done
+             $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+             $run ln "$obj" "$gentop/$newobj" ||
+             $run cp "$obj" "$gentop/$newobj"
+             oldobjs="$oldobjs $gentop/$newobj"
+             ;;
+           *) oldobjs="$oldobjs $obj" ;;
+           esac
+         done
+       fi
+
+       eval cmds=\"$old_archive_cmds\"
+
+       if len=`expr "X$cmds" : ".*"` &&
+            test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+         cmds=$old_archive_cmds
+       else
+         # the command line is too long to link in one step, link in parts
+         $echo "using piecewise archive linking..."
+         save_RANLIB=$RANLIB
+         RANLIB=:
+         objlist=
+         concat_cmds=
+         save_oldobjs=$oldobjs
+
+         # Is there a better way of finding the last object in the list?
+         for obj in $save_oldobjs
+         do
+           last_oldobj=$obj
+         done
+         for obj in $save_oldobjs
+         do
+           oldobjs="$objlist $obj"
+           objlist="$objlist $obj"
+           eval test_cmds=\"$old_archive_cmds\"
+           if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+              test "$len" -le "$max_cmd_len"; then
+             :
+           else
+             # the above command should be used before it gets too long
+             oldobjs=$objlist
+             if test "$obj" = "$last_oldobj" ; then
+               RANLIB=$save_RANLIB
+             fi
+             test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+             eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+             objlist=
+           fi
+         done
+         RANLIB=$save_RANLIB
+         oldobjs=$objlist
+         if test "X$oldobjs" = "X" ; then
+           eval cmds=\"\$concat_cmds\"
+         else
+           eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+         fi
+       fi
+      fi
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+        eval cmd=\"$cmd\"
+       IFS="$save_ifs"
+       $show "$cmd"
+       $run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+    done
+
+    if test -n "$generated"; then
+      $show "${rm}r$generated"
+      $run ${rm}r$generated
+    fi
+
+    # Now create the libtool archive.
+    case $output in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      $show "creating $output"
+
+      # Preserve any variables that may affect compiler behavior
+      for var in $variables_saved_for_relink; do
+       if eval test -z \"\${$var+set}\"; then
+         relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
+       elif eval var_value=\$$var; test -z "$var_value"; then
+         relink_command="$var=; export $var; $relink_command"
+       else
+         var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
+         relink_command="$var=\"$var_value\"; export $var; $relink_command"
+       fi
+      done
+      # Quote the link command for shipping.
+      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      if test "$hardcode_automatic" = yes ; then
+       relink_command=
+      fi
+
+
+      # Only create the output if not a dry run.
+      if test -z "$run"; then
+       for installed in no yes; do
+         if test "$installed" = yes; then
+           if test -z "$install_libdir"; then
+             break
+           fi
+           output="$output_objdir/$outputname"i
+           # Replace all uninstalled libtool libraries with the installed ones
+           newdependency_libs=
+           for deplib in $dependency_libs; do
+             case $deplib in
+             *.la)
+               name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
+               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+               if test -z "$libdir"; then
+                 $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
+                 exit $EXIT_FAILURE
+               fi
+               newdependency_libs="$newdependency_libs $libdir/$name"
+               ;;
+             *) newdependency_libs="$newdependency_libs $deplib" ;;
+             esac
+           done
+           dependency_libs="$newdependency_libs"
+           newdlfiles=
+           for lib in $dlfiles; do
+             name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+             eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+             if test -z "$libdir"; then
+               $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+               exit $EXIT_FAILURE
+             fi
+             newdlfiles="$newdlfiles $libdir/$name"
+           done
+           dlfiles="$newdlfiles"
+           newdlprefiles=
+           for lib in $dlprefiles; do
+             name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+             eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+             if test -z "$libdir"; then
+               $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+               exit $EXIT_FAILURE
+             fi
+             newdlprefiles="$newdlprefiles $libdir/$name"
+           done
+           dlprefiles="$newdlprefiles"
+         else
+           newdlfiles=
+           for lib in $dlfiles; do
+             case $lib in
+               [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+               *) abs=`pwd`"/$lib" ;;
+             esac
+             newdlfiles="$newdlfiles $abs"
+           done
+           dlfiles="$newdlfiles"
+           newdlprefiles=
+           for lib in $dlprefiles; do
+             case $lib in
+               [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+               *) abs=`pwd`"/$lib" ;;
+             esac
+             newdlprefiles="$newdlprefiles $abs"
+           done
+           dlprefiles="$newdlprefiles"
+         fi
+         $rm $output
+         # place dlname in correct position for cygwin
+         tdlname=$dlname
+         case $host,$output,$installed,$module,$dlname in
+           *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+         esac
+         $echo > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+         if test "$installed" = no && test "$need_relink" = yes; then
+           $echo >> $output "\
+relink_command=\"$relink_command\""
+         fi
+       done
+      fi
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
+      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
+      ;;
+    esac
+    exit $EXIT_SUCCESS
+    ;;
+
+  # libtool install mode
+  install)
+    modename="$modename: install"
+
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+       # Allow the use of GNU shtool's install command.
+       $echo "X$nonopt" | grep shtool > /dev/null; then
+      # Aesthetically quote it.
+      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
+      case $arg in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+       arg="\"$arg\""
+       ;;
+      esac
+      install_prog="$arg "
+      arg="$1"
+      shift
+    else
+      install_prog=
+      arg=$nonopt
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+    case $arg in
+    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \      ]*|*]*|"")
+      arg="\"$arg\""
+      ;;
+    esac
+    install_prog="$install_prog$arg"
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    for arg
+    do
+      if test -n "$dest"; then
+       files="$files $dest"
+       dest=$arg
+       continue
+      fi
+
+      case $arg in
+      -d) isdir=yes ;;
+      -f) 
+       case " $install_prog " in
+       *[\\\ /]cp\ *) ;;
+       *) prev=$arg ;;
+       esac
+       ;;
+      -g | -m | -o) prev=$arg ;;
+      -s)
+       stripme=" -s"
+       continue
+       ;;
+      -*)
+       ;;
+      *)
+       # If the previous option needed an argument, then skip it.
+       if test -n "$prev"; then
+         prev=
+       else
+         dest=$arg
+         continue
+       fi
+       ;;
+      esac
+
+      # Aesthetically quote the argument.
+      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+      case $arg in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+       arg="\"$arg\""
+       ;;
+      esac
+      install_prog="$install_prog $arg"
+    done
+
+    if test -z "$install_prog"; then
+      $echo "$modename: you must specify an install program" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prev' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+       $echo "$modename: no file or destination specified" 1>&2
+      else
+       $echo "$modename: you must specify a destination" 1>&2
+      fi
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    # Strip any trailing slash from the destination.
+    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
+      test "X$destdir" = "X$dest" && destdir=.
+      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files
+      if test "$#" -gt 2; then
+       $echo "$modename: \`$dest' is not a directory" 1>&2
+       $echo "$help" 1>&2
+       exit $EXIT_FAILURE
+      fi
+    fi
+    case $destdir in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+       case $file in
+       *.lo) ;;
+       *)
+         $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case $file in
+      *.$libext)
+       # Do the static libraries later.
+       staticlibs="$staticlibs $file"
+       ;;
+
+      *.la)
+       # Check to see that this really is a libtool archive.
+       if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       else
+         $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       library_names=
+       old_library=
+       relink_command=
+       # If there is no directory component, then add one.
+       case $file in
+       */* | *\\*) . $file ;;
+       *) . ./$file ;;
+       esac
+
+       # Add the libdir to current_libdirs if it is the destination.
+       if test "X$destdir" = "X$libdir"; then
+         case "$current_libdirs " in
+         *" $libdir "*) ;;
+         *) current_libdirs="$current_libdirs $libdir" ;;
+         esac
+       else
+         # Note the libdir as a future libdir.
+         case "$future_libdirs " in
+         *" $libdir "*) ;;
+         *) future_libdirs="$future_libdirs $libdir" ;;
+         esac
+       fi
+
+       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
+       test "X$dir" = "X$file/" && dir=
+       dir="$dir$objdir"
+
+       if test -n "$relink_command"; then
+         # Determine the prefix the user has applied to our future dir.
+         inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
+
+         # Don't allow the user to place us outside of our expected
+         # location b/c this prevents finding dependent libraries that
+         # are installed to the same prefix.
+         # At present, this check doesn't affect windows .dll's that
+         # are installed into $libdir/../bin (currently, that works fine)
+         # but it's something to keep an eye on.
+         if test "$inst_prefix_dir" = "$destdir"; then
+           $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+           exit $EXIT_FAILURE
+         fi
+
+         if test -n "$inst_prefix_dir"; then
+           # Stick the inst_prefix_dir data into the link command.
+           relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+         else
+           relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+         fi
+
+         $echo "$modename: warning: relinking \`$file'" 1>&2
+         $show "$relink_command"
+         if $run eval "$relink_command"; then :
+         else
+           $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+           exit $EXIT_FAILURE
+         fi
+       fi
+
+       # See the names of the shared library.
+       set dummy $library_names
+       if test -n "$2"; then
+         realname="$2"
+         shift
+         shift
+
+         srcname="$realname"
+         test -n "$relink_command" && srcname="$realname"T
+
+         # Install the shared library and build the symlinks.
+         $show "$install_prog $dir/$srcname $destdir/$realname"
+         $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
+         if test -n "$stripme" && test -n "$striplib"; then
+           $show "$striplib $destdir/$realname"
+           $run eval "$striplib $destdir/$realname" || exit $?
+         fi
+
+         if test "$#" -gt 0; then
+           # Delete the old symlinks, and create new ones.
+           # Try `ln -sf' first, because the `ln' binary might depend on
+           # the symlink we replace!  Solaris /bin/ln does not understand -f,
+           # so we also need to try rm && ln -s.
+           for linkname
+           do
+             if test "$linkname" != "$realname"; then
+                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
+                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
+             fi
+           done
+         fi
+
+         # Do each command in the postinstall commands.
+         lib="$destdir/$realname"
+         cmds=$postinstall_cmds
+         save_ifs="$IFS"; IFS='~'
+         for cmd in $cmds; do
+           IFS="$save_ifs"
+           eval cmd=\"$cmd\"
+           $show "$cmd"
+           $run eval "$cmd" || {
+             lt_exit=$?
+
+             # Restore the uninstalled library and exit
+             if test "$mode" = relink; then
+               $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
+             fi
+
+             exit $lt_exit
+           }
+         done
+         IFS="$save_ifs"
+       fi
+
+       # Install the pseudo-library for information purposes.
+       name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+       instname="$dir/$name"i
+       $show "$install_prog $instname $destdir/$name"
+       $run eval "$install_prog $instname $destdir/$name" || exit $?
+
+       # Maybe install the static library, too.
+       test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+       ;;
+
+      *.lo)
+       # Install (i.e. copy) a libtool object.
+
+       # Figure out destination file name, if it wasn't already specified.
+       if test -n "$destname"; then
+         destfile="$destdir/$destname"
+       else
+         destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+         destfile="$destdir/$destfile"
+       fi
+
+       # Deduce the name of the destination old-style object file.
+       case $destfile in
+       *.lo)
+         staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
+         ;;
+       *.$objext)
+         staticdest="$destfile"
+         destfile=
+         ;;
+       *)
+         $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+
+       # Install the libtool object if requested.
+       if test -n "$destfile"; then
+         $show "$install_prog $file $destfile"
+         $run eval "$install_prog $file $destfile" || exit $?
+       fi
+
+       # Install the old object if enabled.
+       if test "$build_old_libs" = yes; then
+         # Deduce the name of the old-style object file.
+         staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
+
+         $show "$install_prog $staticobj $staticdest"
+         $run eval "$install_prog \$staticobj \$staticdest" || exit $?
+       fi
+       exit $EXIT_SUCCESS
+       ;;
+
+      *)
+       # Figure out destination file name, if it wasn't already specified.
+       if test -n "$destname"; then
+         destfile="$destdir/$destname"
+       else
+         destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+         destfile="$destdir/$destfile"
+       fi
+
+       # If the file is missing, and there is a .exe on the end, strip it
+       # because it is most likely a libtool script we actually want to
+       # install
+       stripped_ext=""
+       case $file in
+         *.exe)
+           if test ! -f "$file"; then
+             file=`$echo $file|${SED} 's,.exe$,,'`
+             stripped_ext=".exe"
+           fi
+           ;;
+       esac
+
+       # Do a test to see if this is really a libtool program.
+       case $host in
+       *cygwin*|*mingw*)
+           wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
+           ;;
+       *)
+           wrapper=$file
+           ;;
+       esac
+       if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
+         notinst_deplibs=
+         relink_command=
+
+         # Note that it is not necessary on cygwin/mingw to append a dot to
+         # foo even if both foo and FILE.exe exist: automatic-append-.exe
+         # behavior happens only for exec(3), not for open(2)!  Also, sourcing
+         # `FILE.' does not work on cygwin managed mounts.
+         #
+         # If there is no directory component, then add one.
+         case $wrapper in
+         */* | *\\*) . ${wrapper} ;;
+         *) . ./${wrapper} ;;
+         esac
+
+         # Check the variables that should have been set.
+         if test -z "$notinst_deplibs"; then
+           $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
+           exit $EXIT_FAILURE
+         fi
+
+         finalize=yes
+         for lib in $notinst_deplibs; do
+           # Check to see that each library is installed.
+           libdir=
+           if test -f "$lib"; then
+             # If there is no directory component, then add one.
+             case $lib in
+             */* | *\\*) . $lib ;;
+             *) . ./$lib ;;
+             esac
+           fi
+           libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+           if test -n "$libdir" && test ! -f "$libfile"; then
+             $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
+             finalize=no
+           fi
+         done
+
+         relink_command=
+         # Note that it is not necessary on cygwin/mingw to append a dot to
+         # foo even if both foo and FILE.exe exist: automatic-append-.exe
+         # behavior happens only for exec(3), not for open(2)!  Also, sourcing
+         # `FILE.' does not work on cygwin managed mounts.
+         #
+         # If there is no directory component, then add one.
+         case $wrapper in
+         */* | *\\*) . ${wrapper} ;;
+         *) . ./${wrapper} ;;
+         esac
+
+         outputname=
+         if test "$fast_install" = no && test -n "$relink_command"; then
+           if test "$finalize" = yes && test -z "$run"; then
+             tmpdir=`func_mktempdir`
+             file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
+             outputname="$tmpdir/$file"
+             # Replace the output file specification.
+             relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+             $show "$relink_command"
+             if $run eval "$relink_command"; then :
+             else
+               $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+               ${rm}r "$tmpdir"
+               continue
+             fi
+             file="$outputname"
+           else
+             $echo "$modename: warning: cannot relink \`$file'" 1>&2
+           fi
+         else
+           # Install the binary that we compiled earlier.
+           file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+         fi
+       fi
+
+       # remove .exe since cygwin /usr/bin/install will append another
+       # one anyway 
+       case $install_prog,$host in
+       */usr/bin/install*,*cygwin*)
+         case $file:$destfile in
+         *.exe:*.exe)
+           # this is ok
+           ;;
+         *.exe:*)
+           destfile=$destfile.exe
+           ;;
+         *:*.exe)
+           destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
+           ;;
+         esac
+         ;;
+       esac
+       $show "$install_prog$stripme $file $destfile"
+       $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
+       test -n "$outputname" && ${rm}r "$tmpdir"
+       ;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+
+      $show "$install_prog $file $oldlib"
+      $run eval "$install_prog \$file \$oldlib" || exit $?
+
+      if test -n "$stripme" && test -n "$old_striplib"; then
+       $show "$old_striplib $oldlib"
+       $run eval "$old_striplib $oldlib" || exit $?
+      fi
+
+      # Do each command in the postinstall commands.
+      cmds=$old_postinstall_cmds
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+       IFS="$save_ifs"
+       eval cmd=\"$cmd\"
+       $show "$cmd"
+       $run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+    done
+
+    if test -n "$future_libdirs"; then
+      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
+    fi
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      test -n "$run" && current_libdirs=" -n$current_libdirs"
+      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+    else
+      exit $EXIT_SUCCESS
+    fi
+    ;;
+
+  # libtool finish mode
+  finish)
+    modename="$modename: finish"
+    libdirs="$nonopt"
+    admincmds=
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for dir
+      do
+       libdirs="$libdirs $dir"
+      done
+
+      for libdir in $libdirs; do
+       if test -n "$finish_cmds"; then
+         # Do each command in the finish commands.
+         cmds=$finish_cmds
+         save_ifs="$IFS"; IFS='~'
+         for cmd in $cmds; do
+           IFS="$save_ifs"
+           eval cmd=\"$cmd\"
+           $show "$cmd"
+           $run eval "$cmd" || admincmds="$admincmds
+       $cmd"
+         done
+         IFS="$save_ifs"
+       fi
+       if test -n "$finish_eval"; then
+         # Do the single finish_eval.
+         eval cmds=\"$finish_eval\"
+         $run eval "$cmds" || admincmds="$admincmds
+       $cmds"
+       fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    test "$show" = : && exit $EXIT_SUCCESS
+
+    $echo "X----------------------------------------------------------------------" | $Xsed
+    $echo "Libraries have been installed in:"
+    for libdir in $libdirs; do
+      $echo "   $libdir"
+    done
+    $echo
+    $echo "If you ever happen to want to link against installed libraries"
+    $echo "in a given directory, LIBDIR, you must either use libtool, and"
+    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+    $echo "flag during linking and do at least one of the following:"
+    if test -n "$shlibpath_var"; then
+      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+      $echo "     during execution"
+    fi
+    if test -n "$runpath_var"; then
+      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+      $echo "     during linking"
+    fi
+    if test -n "$hardcode_libdir_flag_spec"; then
+      libdir=LIBDIR
+      eval flag=\"$hardcode_libdir_flag_spec\"
+
+      $echo "   - use the \`$flag' linker flag"
+    fi
+    if test -n "$admincmds"; then
+      $echo "   - have your system administrator run these commands:$admincmds"
+    fi
+    if test -f /etc/ld.so.conf; then
+      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+    fi
+    $echo
+    $echo "See any operating system documentation about shared libraries for"
+    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
+    $echo "X----------------------------------------------------------------------" | $Xsed
+    exit $EXIT_SUCCESS
+    ;;
+
+  # libtool execute mode
+  execute)
+    modename="$modename: execute"
+
+    # The first argument is the command name.
+    cmd="$nonopt"
+    if test -z "$cmd"; then
+      $echo "$modename: you must specify a COMMAND" 1>&2
+      $echo "$help"
+      exit $EXIT_FAILURE
+    fi
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      if test ! -f "$file"; then
+       $echo "$modename: \`$file' is not a file" 1>&2
+       $echo "$help" 1>&2
+       exit $EXIT_FAILURE
+      fi
+
+      dir=
+      case $file in
+      *.la)
+       # Check to see that this really is a libtool archive.
+       if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       else
+         $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       # Read the libtool library.
+       dlname=
+       library_names=
+
+       # If there is no directory component, then add one.
+       case $file in
+       */* | *\\*) . $file ;;
+       *) . ./$file ;;
+       esac
+
+       # Skip this library if it cannot be dlopened.
+       if test -z "$dlname"; then
+         # Warn if it was a shared library.
+         test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
+         continue
+       fi
+
+       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+       test "X$dir" = "X$file" && dir=.
+
+       if test -f "$dir/$objdir/$dlname"; then
+         dir="$dir/$objdir"
+       else
+         $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+         exit $EXIT_FAILURE
+       fi
+       ;;
+
+      *.lo)
+       # Just add the directory containing the .lo file.
+       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+       test "X$dir" = "X$file" && dir=.
+       ;;
+
+      *)
+       $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
+       continue
+       ;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+       eval "$shlibpath_var=\"\$dir\""
+      else
+       eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case $file in
+      -*) ;;
+      *)
+       # Do a test to see if this is really a libtool program.
+       if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+         # If there is no directory component, then add one.
+         case $file in
+         */* | *\\*) . $file ;;
+         *) . ./$file ;;
+         esac
+
+         # Transform arg to wrapped name.
+         file="$progdir/$program"
+       fi
+       ;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
+      args="$args \"$file\""
+    done
+
+    if test -z "$run"; then
+      if test -n "$shlibpath_var"; then
+       # Export the shlibpath_var.
+       eval "export $shlibpath_var"
+      fi
+
+      # Restore saved environment variables
+      if test "${save_LC_ALL+set}" = set; then
+       LC_ALL="$save_LC_ALL"; export LC_ALL
+      fi
+      if test "${save_LANG+set}" = set; then
+       LANG="$save_LANG"; export LANG
+      fi
+
+      # Now prepare to actually exec the command.
+      exec_cmd="\$cmd$args"
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+       eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
+       $echo "export $shlibpath_var"
+      fi
+      $echo "$cmd$args"
+      exit $EXIT_SUCCESS
+    fi
+    ;;
+
+  # libtool clean and uninstall mode
+  clean | uninstall)
+    modename="$modename: $mode"
+    rm="$nonopt"
+    files=
+    rmforce=
+    exit_status=0
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    for arg
+    do
+      case $arg in
+      -f) rm="$rm $arg"; rmforce=yes ;;
+      -*) rm="$rm $arg" ;;
+      *) files="$files $arg" ;;
+      esac
+    done
+
+    if test -z "$rm"; then
+      $echo "$modename: you must specify an RM program" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    rmdirs=
+
+    origobjdir="$objdir"
+    for file in $files; do
+      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+      if test "X$dir" = "X$file"; then
+       dir=.
+       objdir="$origobjdir"
+      else
+       objdir="$dir/$origobjdir"
+      fi
+      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+      test "$mode" = uninstall && objdir="$dir"
+
+      # Remember objdir for removal later, being careful to avoid duplicates
+      if test "$mode" = clean; then
+       case " $rmdirs " in
+         *" $objdir "*) ;;
+         *) rmdirs="$rmdirs $objdir" ;;
+       esac
+      fi
+
+      # Don't error if the file doesn't exist and rm -f was used.
+      if (test -L "$file") >/dev/null 2>&1 \
+       || (test -h "$file") >/dev/null 2>&1 \
+       || test -f "$file"; then
+       :
+      elif test -d "$file"; then
+       exit_status=1
+       continue
+      elif test "$rmforce" = yes; then
+       continue
+      fi
+
+      rmfiles="$file"
+
+      case $name in
+      *.la)
+       # Possibly a libtool archive, so verify it.
+       if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+         . $dir/$name
+
+         # Delete the libtool libraries and symlinks.
+         for n in $library_names; do
+           rmfiles="$rmfiles $objdir/$n"
+         done
+         test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+
+         case "$mode" in
+         clean)
+           case "  $library_names " in
+           # "  " in the beginning catches empty $dlname
+           *" $dlname "*) ;;
+           *) rmfiles="$rmfiles $objdir/$dlname" ;;
+           esac
+            test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+           ;;
+         uninstall)
+           if test -n "$library_names"; then
+             # Do each command in the postuninstall commands.
+             cmds=$postuninstall_cmds
+             save_ifs="$IFS"; IFS='~'
+             for cmd in $cmds; do
+               IFS="$save_ifs"
+               eval cmd=\"$cmd\"
+               $show "$cmd"
+               $run eval "$cmd"
+               if test "$?" -ne 0 && test "$rmforce" != yes; then
+                 exit_status=1
+               fi
+             done
+             IFS="$save_ifs"
+           fi
+
+           if test -n "$old_library"; then
+             # Do each command in the old_postuninstall commands.
+             cmds=$old_postuninstall_cmds
+             save_ifs="$IFS"; IFS='~'
+             for cmd in $cmds; do
+               IFS="$save_ifs"
+               eval cmd=\"$cmd\"
+               $show "$cmd"
+               $run eval "$cmd"
+               if test "$?" -ne 0 && test "$rmforce" != yes; then
+                 exit_status=1
+               fi
+             done
+             IFS="$save_ifs"
+           fi
+           # FIXME: should reinstall the best remaining shared library.
+           ;;
+         esac
+       fi
+       ;;
+
+      *.lo)
+       # Possibly a libtool object, so verify it.
+       if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+
+         # Read the .lo file
+         . $dir/$name
+
+         # Add PIC object to the list of files to remove.
+         if test -n "$pic_object" \
+            && test "$pic_object" != none; then
+           rmfiles="$rmfiles $dir/$pic_object"
+         fi
+
+         # Add non-PIC object to the list of files to remove.
+         if test -n "$non_pic_object" \
+            && test "$non_pic_object" != none; then
+           rmfiles="$rmfiles $dir/$non_pic_object"
+         fi
+       fi
+       ;;
+
+      *)
+       if test "$mode" = clean ; then
+         noexename=$name
+         case $file in
+         *.exe)
+           file=`$echo $file|${SED} 's,.exe$,,'`
+           noexename=`$echo $name|${SED} 's,.exe$,,'`
+           # $file with .exe has already been added to rmfiles,
+           # add $file without .exe
+           rmfiles="$rmfiles $file"
+           ;;
+         esac
+         # Do a test to see if this is a libtool program.
+         if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+           relink_command=
+           . $dir/$noexename
+
+           # note $name still contains .exe if it was in $file originally
+           # as does the version of $file that was added into $rmfiles
+           rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+           if test "$fast_install" = yes && test -n "$relink_command"; then
+             rmfiles="$rmfiles $objdir/lt-$name"
+           fi
+           if test "X$noexename" != "X$name" ; then
+             rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+           fi
+         fi
+       fi
+       ;;
+      esac
+      $show "$rm $rmfiles"
+      $run $rm $rmfiles || exit_status=1
+    done
+    objdir="$origobjdir"
+
+    # Try to remove the ${objdir}s in the directories where we deleted files
+    for dir in $rmdirs; do
+      if test -d "$dir"; then
+       $show "rmdir $dir"
+       $run rmdir $dir >/dev/null 2>&1
+      fi
+    done
+
+    exit $exit_status
+    ;;
+
+  "")
+    $echo "$modename: you must specify a MODE" 1>&2
+    $echo "$generic_help" 1>&2
+    exit $EXIT_FAILURE
+    ;;
+  esac
+
+  if test -z "$exec_cmd"; then
+    $echo "$modename: invalid operation mode \`$mode'" 1>&2
+    $echo "$generic_help" 1>&2
+    exit $EXIT_FAILURE
+  fi
+fi # test -z "$show_help"
+
+if test -n "$exec_cmd"; then
+  eval exec $exec_cmd
+  exit $EXIT_FAILURE
+fi
+
+# We need to display help for each of the modes.
+case $mode in
+"") $echo \
+"Usage: $modename [OPTION]... [MODE-ARG]...
+
+Provide generalized library-building support services.
+
+    --config          show all configuration variables
+    --debug           enable verbose shell tracing
+-n, --dry-run         display commands without modifying any files
+    --features        display basic configuration information and exit
+    --finish          same as \`--mode=finish'
+    --help            display this help message and exit
+    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
+    --quiet           same as \`--silent'
+    --silent          don't print informational messages
+    --tag=TAG         use configuration variables from tag TAG
+    --version         print version information
+
+MODE must be one of the following:
+
+      clean           remove files from the build directory
+      compile         compile a source file into a libtool object
+      execute         automatically set library path, then run a program
+      finish          complete the installation of libtool libraries
+      install         install libraries or executables
+      link            create a library or an executable
+      uninstall       remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
+a more detailed description of MODE.
+
+Report bugs to <bug-libtool@gnu.org>."
+  exit $EXIT_SUCCESS
+  ;;
+
+clean)
+  $echo \
+"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+  ;;
+
+compile)
+  $echo \
+"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -prefer-pic       try to building PIC objects only
+  -prefer-non-pic   try to building non-PIC objects only
+  -static           always build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+  ;;
+
+execute)
+  $echo \
+"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+  ;;
+
+finish)
+  $echo \
+"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+  ;;
+
+install)
+  $echo \
+"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+  ;;
+
+link)
+  $echo \
+"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+                   try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+                   try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-fast-install  disable the fast-install mode
+  -no-install       link a not-installable executable
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -precious-files-regex REGEX
+                    don't remove output files matching REGEX
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -static           do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+                   specify library version info [each variable defaults to 0]
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+  ;;
+
+uninstall)
+  $echo \
+"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+  ;;
+
+*)
+  $echo "$modename: invalid operation mode \`$mode'" 1>&2
+  $echo "$help" 1>&2
+  exit $EXIT_FAILURE
+  ;;
+esac
+
+$echo
+$echo "Try \`$modename --help' for more information about other modes."
+
+exit $?
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries.  Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them.  This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration.  But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+disable_libs=shared
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+disable_libs=static
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
diff --git a/m4/define_dir.m4 b/m4/define_dir.m4
new file mode 100644 (file)
index 0000000..4877176
--- /dev/null
@@ -0,0 +1,26 @@
+dnl @synopsis AC_DEFINE_DIR(VARNAME, DIR [, DESCRIPTION])
+dnl
+dnl This macro defines (with AC_DEFINE) VARNAME to the expansion of the DIR
+dnl variable, taking care of fixing up ${prefix} and such.
+dnl
+dnl Note that the 3 argument form is only supported with autoconf 2.13 and
+dnl later (i.e. only where AC_DEFINE supports 3 arguments).
+dnl
+dnl Examples:
+dnl
+dnl    AC_DEFINE_DIR(DATADIR, datadir)
+dnl    AC_DEFINE_DIR(PROG_PATH, bindir, [Location of installed binaries])
+dnl
+dnl @version $Id: acinclude.m4,v 1.3 2000/08/04 03:26:22 stenn Exp $
+dnl @author Alexandre Oliva <oliva@lsd.ic.unicamp.br>
+
+AC_DEFUN([AC_DEFINE_DIR], [
+       ac_expanded=`(
+           test "x$prefix" = xNONE && prefix="$ac_default_prefix"
+           test "x$exec_prefix" = xNONE && exec_prefix="${prefix}"
+           eval echo \""[$]$2"\"
+        )`
+       ifelse($3, ,
+         AC_DEFINE_UNQUOTED($1, "$ac_expanded"),
+         AC_DEFINE_UNQUOTED($1, "$ac_expanded", $3))
+])
diff --git a/m4/hs_ulong_const.m4 b/m4/hs_ulong_const.m4
new file mode 100644 (file)
index 0000000..b137cfd
--- /dev/null
@@ -0,0 +1,11 @@
+AC_DEFUN([hs_ULONG_CONST],
+[ AH_TEMPLATE(ULONG_CONST, [How do we create unsigned long constants?])
+AC_EGREP_CPP(Circus,
+ [#define ACAT(a,b)a ## b
+ACAT(Cir,cus)
+], AC_DEFINE([ULONG_CONST(a)], [a ## UL]),
+    AC_EGREP_CPP(Reiser,
+[#define RCAT(a,b)a/**/b
+RCAT(Rei,ser)
+], AC_DEFINE([ULONG_CONST(a)], [a/**/L]),
+    AC_MSG_ERROR([How do we create an unsigned long constant?])))])
diff --git a/m4/os_cflags.m4 b/m4/os_cflags.m4
new file mode 100644 (file)
index 0000000..35efa44
--- /dev/null
@@ -0,0 +1,87 @@
+dnl ######################################################################
+dnl Specify additional compile options based on the OS and the compiler
+dnl From Erez Zadok <ezk@cs.sunysb.edu>, http://www.am-utils.org
+AC_DEFUN([AMU_OS_CFLAGS],
+[
+AC_CACHE_CHECK(additional compiler flags,
+ac_cv_os_cflags,
+[
+case "${host_os}" in
+       irix6* )
+               case "${CC}" in
+                       cc )
+                               # do not use 64-bit compiler
+                               ac_cv_os_cflags="-n32 -mips3 -Wl,-woff,84"
+                               ;;
+               esac
+               ;;
+# HMS: am-utils needed this but we don't (apparently)
+#      osf[[1-3]]* )
+#              # get the right version of struct sockaddr
+#              case "${CC}" in
+#                      cc )
+#                              ac_cv_os_cflags="-std -D_SOCKADDR_LEN -D_NO_PROTO"
+#                              ;;
+#                      * )
+#                              ac_cv_os_cflags="-D_SOCKADDR_LEN -D_NO_PROTO"
+#                              ;;
+#              esac
+#              ;;
+#      osf* )
+#              # get the right version of struct sockaddr
+#              case "${CC}" in
+#                      cc )
+#                              ac_cv_os_cflags="-std -D_SOCKADDR_LEN"
+#                              ;;
+#                      * )
+#                              ac_cv_os_cflags="-D_SOCKADDR_LEN"
+#                              ;;
+#              esac
+#              ;;
+       aix[[1-3]]* )
+               ac_cv_os_cflags="" ;;
+       aix4.[[0-2]]* )
+               # turn on additional headers
+               ac_cv_os_cflags="-D_XOPEN_EXTENDED_SOURCE"
+               ;;
+       aix* )
+               # avoid circular dependencies in yp headers
+               ac_cv_os_cflags="-DHAVE_BAD_HEADERS -D_XOPEN_EXTENDED_SOURCE"
+               ;;
+       OFF-sunos4* )
+               # make sure passing whole structures is handled in gcc
+               case "${CC}" in
+                       gcc )
+                               ac_cv_os_cflags="-fpcc-struct-return"
+                               ;;
+               esac
+               ;;
+       sunos[[34]]* | solaris1* | solaris2.[[0-5]]* | sunos5.[[0-5]]* )
+               ac_cv_os_cflags="" ;;
+       solaris* | sunos* )
+               # turn on 64-bit file offset interface
+               case "${CC}" in
+                       * )
+                               ac_cv_os_cflags="-D_LARGEFILE64_SOURCE"
+                               ;;
+               esac
+               ;;
+       hpux* )
+               # use Ansi compiler on HPUX
+               case "${CC}" in
+                       cc )
+                               ac_cv_os_cflags="-Ae"
+                               ;;
+               esac
+               ;;
+       darwin* | rhapsody* )
+               ac_cv_os_cflags="-D_P1003_1B_VISIBLE"
+               ;;
+       * )
+               ac_cv_os_cflags=""
+               ;;
+esac
+])
+CFLAGS="$CFLAGS $ac_cv_os_cflags"
+])
+dnl ======================================================================
diff --git a/missing b/missing
new file mode 100755 (executable)
index 0000000..894e786
--- /dev/null
+++ b/missing
@@ -0,0 +1,360 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2005-06-08.21
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
+#   Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case "$1" in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).
+case "$1" in
+  lex|yacc)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case "$1" in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case "$f" in
+      *:*) touch_files="$touch_files "`echo "$f" |
+                                      sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+          sed 's/\.am$/.in/' |
+          while read f; do touch "$f"; done
+    ;;
+
+  autom4te)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+    if test -f "$file"; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo "#! /bin/sh"
+       echo "# Created by GNU Automake missing as a replacement of"
+       echo "#  $ $@"
+       echo "exit 0"
+       chmod +x $file
+       exit 1
+    fi
+    ;;
+
+  bison|yacc)
+    echo 1>&2 "\
+WARNING: \`$1' $msg.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+       case "$LASTARG" in
+       *.y)
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" y.tab.c
+           fi
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" y.tab.h
+           fi
+         ;;
+       esac
+    fi
+    if [ ! -f y.tab.h ]; then
+       echo >y.tab.h
+    fi
+    if [ ! -f y.tab.c ]; then
+       echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+       case "$LASTARG" in
+       *.l)
+           SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" lex.yy.c
+           fi
+         ;;
+       esac
+    fi
+    if [ ! -f lex.yy.c ]; then
+       echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+        you modified a dependency of a manual page.  You may need the
+        \`Help2man' package in order for those modifications to take
+        effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+       file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+    fi
+    if [ -f "$file" ]; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo ".ab help2man is required to generate this page"
+       exit 1
+    fi
+    ;;
+
+  makeinfo)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar)
+    shift
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+       case "$firstarg" in
+       *o*)
+           firstarg=`echo "$firstarg" | sed s/o//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+       case "$firstarg" in
+       *h*)
+           firstarg=`echo "$firstarg" | sed s/h//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequisites for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/ntpd/Makefile.am b/ntpd/Makefile.am
new file mode 100644 (file)
index 0000000..6896b45
--- /dev/null
@@ -0,0 +1,108 @@
+AUTOMAKE_OPTIONS= ../util/ansi2knr
+
+bindir=        ${exec_prefix}/${BINSUBDIR}
+
+bin_PROGRAMS=  ntpd @MAKE_NTPDSIM@
+
+noinst_LIBRARIES=      libntpd.a
+
+AM_CPPFLAGS= -I$(top_srcdir)/include -I../include $(LIBOPTS_CFLAGS)
+# LDADD might need RESLIB and ADJLIB.
+LDADD= version.o libntpd.a @LIBPARSE@
+
+BUILT_SOURCES= ntpd-opts.c ntpd-opts.h ntpd.1 ntpd-opts.texi ntpd-opts.menu
+man_MANS=      ntpd.1
+
+BUILT_SOURCES+=        ntpdsim-opts.c ntpdsim-opts.h ntpdsim.1 ntpdsim-opts.texi ntpdsim-opts.menu
+man_MANS+=     ntpdsim.1
+
+# ntpd may need:
+# log10                               refclock_wwv.o
+# sqrt                                ntp_control.o
+# floor                               refclock_wwv.o
+# which are (usually) provided by -lm.
+ntpd_LDADD = $(LDADD) -lm @LCRYPTO@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+ntpdsim_LDADD = $(LDADD) ../libntp/libntpsim.a -lm @LCRYPTO@ $(LIBOPTS_LDADD)
+ntpdsim_CFLAGS = $(CFLAGS) -DSIM
+check_y2k_LDADD = $(LDADD) ../libntp/libntp.a
+DISTCLEANFILES = .version version.c
+EXTRA_DIST = ntpd-opts.def ntpdbase-opts.def ntpdsim-opts.def  \
+       refclock_msfees.c       \
+       refclock_trak.c         \
+       $(BUILT_SOURCES)
+ETAGS_ARGS = Makefile.am
+###                                                    Y2Kfixes
+check_PROGRAMS = @MAKE_CHECK_Y2K@
+EXTRA_PROGRAMS = check_y2k ntpdsim
+run_ag = cd $(srcdir) && autogen -L ../include --writable
+std_def_list=  $(top_srcdir)/include/debug-opt.def             \
+               $(top_srcdir)/include/autogen-version.def       \
+               $(top_srcdir)/include/copyright.def             \
+               $(top_srcdir)/include/version.def
+
+check-local: @MAKE_CHECK_Y2K@
+       test -z "@MAKE_CHECK_Y2K@" || ./@MAKE_CHECK_Y2K@
+
+# SIM: cmd_args.c ntp_config.c ntp_io.c ntpd.c + ntpsim.c (include/ntpsim.h)
+# ntp_resolver.c is presently unused...
+ntpd_SOURCES = cmd_args.c ntp_config.c ntp_io.c ntpd.c ntpd-opts.c ntpd-opts.h
+ntpdsim_SOURCES = $(ntpd_SOURCES) ntpsim.c ntpdsim-opts.c ntpdsim-opts.h
+libntpd_a_SOURCES = jupiter.h ntp_control.c \
+       ntp_crypto.c ntp_filegen.c \
+       ntp_intres.c ntp_loopfilter.c ntp_monitor.c ntp_peer.c \
+       ntp_proto.c ntp_refclock.c ntp_request.c \
+       ntp_restrict.c ntp_timer.c ntp_util.c \
+       ppsapi_timepps.h \
+       refclock_acts.c refclock_arbiter.c refclock_arc.c refclock_as2201.c \
+       refclock_atom.c refclock_bancomm.c refclock_chronolog.c \
+       refclock_chu.c refclock_conf.c refclock_datum.c refclock_dumbclock.c \
+       refclock_fg.c refclock_gpsvme.c refclock_heath.c refclock_hopfser.c \
+       refclock_hopfpci.c refclock_hpgps.c refclock_irig.c refclock_jjy.c \
+       refclock_jupiter.c refclock_leitch.c refclock_local.c \
+       refclock_mx4200.c refclock_neoclock4x.c \
+       refclock_nmea.c refclock_oncore.c refclock_palisade.c \
+       refclock_palisade.h refclock_parse.c \
+       refclock_pcf.c refclock_pst.c refclock_ripencc.c refclock_shm.c \
+       refclock_tpro.c refclock_true.c refclock_tt560.c \
+       refclock_ulink.c refclock_wwv.c refclock_wwvb.c \
+       refclock_zyfer.c
+
+$(srcdir)/ntpd-opts.h: $(srcdir)/ntpd-opts.c
+$(srcdir)/ntpd-opts.c: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
+       $(run_ag) ntpd-opts.def
+
+$(srcdir)/ntpd.1: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
+       $(run_ag) -Tagman1.tpl -bntpd ntpd-opts.def
+
+$(srcdir)/ntpd-opts.texi $(srcdir)/ntpd-opts.menu: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
+       $(run_ag) -Taginfo.tpl -DLEVEL=section ntpd-opts.def
+
+$(srcdir)/ntpdsim-opts.h: $(srcdir)/ntpdsim-opts.c
+$(srcdir)/ntpdsim-opts.c: $(srcdir)/ntpdsim-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list) $(top_srcdir)/include/homerc.def
+       $(run_ag) ntpdsim-opts.def
+
+$(srcdir)/ntpdsim.1: $(srcdir)/ntpdsim-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list) $(top_srcdir)/include/homerc.def
+       $(run_ag) -Tagman1.tpl -bntpdsim ntpdsim-opts.def
+
+$(srcdir)/ntpdsim-opts.texi $(srcdir)/ntpdsim-opts.menu: $(srcdir)/ntpdsim-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list) $(top_srcdir)/include/homerc.def
+       $(run_ag) -Taginfo.tpl -DLEVEL=section ntpdsim-opts.def
+
+$(PROGRAMS): $(LDADD)
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE) libntp.a
+
+../libntp/libntpsim.a:
+       cd ../libntp && $(MAKE) libntpsim.a
+
+../libparse/libparse.a:
+       cd ../libparse && $(MAKE)
+
+$(top_srcdir)/version :
+       cd $(top_srcdir) && $(MAKE) version
+
+version.o: $(ntpd_OBJECTS) ../libntp/libntp.a @LIBPARSE@ Makefile $(top_srcdir)/version
+       env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpd
+       $(COMPILE) -c version.c
+
+include ../bincheck.mf
diff --git a/ntpd/Makefile.in b/ntpd/Makefile.in
new file mode 100644 (file)
index 0000000..f92b31f
--- /dev/null
@@ -0,0 +1,1141 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# we traditionally installed software in bindir, while it should have gone
+# in sbindir.  Now that we offer a choice, look in the "other" installation
+# subdir to warn folks if there is another version there.
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+ANSI2KNR = ../util/ansi2knr
+bin_PROGRAMS = ntpd$(EXEEXT) @MAKE_NTPDSIM@
+EXTRA_PROGRAMS = check_y2k$(EXEEXT) ntpdsim$(EXEEXT)
+DIST_COMMON = $(srcdir)/../bincheck.mf $(srcdir)/Makefile.am \
+       $(srcdir)/Makefile.in
+subdir = ntpd
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+LIBRARIES = $(noinst_LIBRARIES)
+ARFLAGS = cru
+libntpd_a_AR = $(AR) $(ARFLAGS)
+libntpd_a_LIBADD =
+am_libntpd_a_OBJECTS = ntp_control$U.$(OBJEXT) ntp_crypto$U.$(OBJEXT) \
+       ntp_filegen$U.$(OBJEXT) ntp_intres$U.$(OBJEXT) \
+       ntp_loopfilter$U.$(OBJEXT) ntp_monitor$U.$(OBJEXT) \
+       ntp_peer$U.$(OBJEXT) ntp_proto$U.$(OBJEXT) \
+       ntp_refclock$U.$(OBJEXT) ntp_request$U.$(OBJEXT) \
+       ntp_restrict$U.$(OBJEXT) ntp_timer$U.$(OBJEXT) \
+       ntp_util$U.$(OBJEXT) refclock_acts$U.$(OBJEXT) \
+       refclock_arbiter$U.$(OBJEXT) refclock_arc$U.$(OBJEXT) \
+       refclock_as2201$U.$(OBJEXT) refclock_atom$U.$(OBJEXT) \
+       refclock_bancomm$U.$(OBJEXT) refclock_chronolog$U.$(OBJEXT) \
+       refclock_chu$U.$(OBJEXT) refclock_conf$U.$(OBJEXT) \
+       refclock_datum$U.$(OBJEXT) refclock_dumbclock$U.$(OBJEXT) \
+       refclock_fg$U.$(OBJEXT) refclock_gpsvme$U.$(OBJEXT) \
+       refclock_heath$U.$(OBJEXT) refclock_hopfser$U.$(OBJEXT) \
+       refclock_hopfpci$U.$(OBJEXT) refclock_hpgps$U.$(OBJEXT) \
+       refclock_irig$U.$(OBJEXT) refclock_jjy$U.$(OBJEXT) \
+       refclock_jupiter$U.$(OBJEXT) refclock_leitch$U.$(OBJEXT) \
+       refclock_local$U.$(OBJEXT) refclock_mx4200$U.$(OBJEXT) \
+       refclock_neoclock4x$U.$(OBJEXT) refclock_nmea$U.$(OBJEXT) \
+       refclock_oncore$U.$(OBJEXT) refclock_palisade$U.$(OBJEXT) \
+       refclock_parse$U.$(OBJEXT) refclock_pcf$U.$(OBJEXT) \
+       refclock_pst$U.$(OBJEXT) refclock_ripencc$U.$(OBJEXT) \
+       refclock_shm$U.$(OBJEXT) refclock_tpro$U.$(OBJEXT) \
+       refclock_true$U.$(OBJEXT) refclock_tt560$U.$(OBJEXT) \
+       refclock_ulink$U.$(OBJEXT) refclock_wwv$U.$(OBJEXT) \
+       refclock_wwvb$U.$(OBJEXT) refclock_zyfer$U.$(OBJEXT)
+libntpd_a_OBJECTS = $(am_libntpd_a_OBJECTS)
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
+PROGRAMS = $(bin_PROGRAMS)
+check_y2k_SOURCES = check_y2k.c
+check_y2k_OBJECTS = check_y2k$U.$(OBJEXT)
+am__DEPENDENCIES_1 = version.o libntpd.a
+check_y2k_DEPENDENCIES = $(am__DEPENDENCIES_1) ../libntp/libntp.a
+am_ntpd_OBJECTS = cmd_args$U.$(OBJEXT) ntp_config$U.$(OBJEXT) \
+       ntp_io$U.$(OBJEXT) ntpd$U.$(OBJEXT) ntpd-opts$U.$(OBJEXT)
+ntpd_OBJECTS = $(am_ntpd_OBJECTS)
+am__DEPENDENCIES_2 =
+ntpd_DEPENDENCIES = $(am__DEPENDENCIES_1) $(am__DEPENDENCIES_2) \
+       ../libntp/libntp.a
+am__objects_1 = ntpdsim-cmd_args$U.$(OBJEXT) \
+       ntpdsim-ntp_config$U.$(OBJEXT) ntpdsim-ntp_io$U.$(OBJEXT) \
+       ntpdsim-ntpd$U.$(OBJEXT) ntpdsim-ntpd-opts$U.$(OBJEXT)
+am_ntpdsim_OBJECTS = $(am__objects_1) ntpdsim-ntpsim$U.$(OBJEXT) \
+       ntpdsim-ntpdsim-opts$U.$(OBJEXT)
+ntpdsim_OBJECTS = $(am_ntpdsim_OBJECTS)
+ntpdsim_DEPENDENCIES = $(am__DEPENDENCIES_1) ../libntp/libntpsim.a \
+       $(am__DEPENDENCIES_2)
+ntpdsim_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(ntpdsim_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(libntpd_a_SOURCES) check_y2k.c $(ntpd_SOURCES) \
+       $(ntpdsim_SOURCES)
+DIST_SOURCES = $(libntpd_a_SOURCES) check_y2k.c $(ntpd_SOURCES) \
+       $(ntpdsim_SOURCES)
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+man1dir = $(mandir)/man1
+NROFF = nroff
+MANS = $(man_MANS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = ${exec_prefix}/${BINSUBDIR}
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+noinst_LIBRARIES = libntpd.a
+AM_CPPFLAGS = -I$(top_srcdir)/include -I../include $(LIBOPTS_CFLAGS)
+# LDADD might need RESLIB and ADJLIB.
+LDADD = version.o libntpd.a @LIBPARSE@
+BUILT_SOURCES = ntpd-opts.c ntpd-opts.h ntpd.1 ntpd-opts.texi \
+       ntpd-opts.menu ntpdsim-opts.c ntpdsim-opts.h ntpdsim.1 \
+       ntpdsim-opts.texi ntpdsim-opts.menu
+man_MANS = ntpd.1 ntpdsim.1
+
+# ntpd may need:
+# log10                               refclock_wwv.o
+# sqrt                                ntp_control.o
+# floor                               refclock_wwv.o
+# which are (usually) provided by -lm.
+ntpd_LDADD = $(LDADD) -lm @LCRYPTO@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+ntpdsim_LDADD = $(LDADD) ../libntp/libntpsim.a -lm @LCRYPTO@ $(LIBOPTS_LDADD)
+ntpdsim_CFLAGS = $(CFLAGS) -DSIM
+check_y2k_LDADD = $(LDADD) ../libntp/libntp.a
+DISTCLEANFILES = .version version.c
+EXTRA_DIST = ntpd-opts.def ntpdbase-opts.def ntpdsim-opts.def  \
+       refclock_msfees.c       \
+       refclock_trak.c         \
+       $(BUILT_SOURCES)
+
+ETAGS_ARGS = Makefile.am
+###                                                    Y2Kfixes
+check_PROGRAMS = @MAKE_CHECK_Y2K@
+run_ag = cd $(srcdir) && autogen -L ../include --writable
+std_def_list = $(top_srcdir)/include/debug-opt.def             \
+               $(top_srcdir)/include/autogen-version.def       \
+               $(top_srcdir)/include/copyright.def             \
+               $(top_srcdir)/include/version.def
+
+
+# SIM: cmd_args.c ntp_config.c ntp_io.c ntpd.c + ntpsim.c (include/ntpsim.h)
+# ntp_resolver.c is presently unused...
+ntpd_SOURCES = cmd_args.c ntp_config.c ntp_io.c ntpd.c ntpd-opts.c ntpd-opts.h
+ntpdsim_SOURCES = $(ntpd_SOURCES) ntpsim.c ntpdsim-opts.c ntpdsim-opts.h
+libntpd_a_SOURCES = jupiter.h ntp_control.c \
+       ntp_crypto.c ntp_filegen.c \
+       ntp_intres.c ntp_loopfilter.c ntp_monitor.c ntp_peer.c \
+       ntp_proto.c ntp_refclock.c ntp_request.c \
+       ntp_restrict.c ntp_timer.c ntp_util.c \
+       ppsapi_timepps.h \
+       refclock_acts.c refclock_arbiter.c refclock_arc.c refclock_as2201.c \
+       refclock_atom.c refclock_bancomm.c refclock_chronolog.c \
+       refclock_chu.c refclock_conf.c refclock_datum.c refclock_dumbclock.c \
+       refclock_fg.c refclock_gpsvme.c refclock_heath.c refclock_hopfser.c \
+       refclock_hopfpci.c refclock_hpgps.c refclock_irig.c refclock_jjy.c \
+       refclock_jupiter.c refclock_leitch.c refclock_local.c \
+       refclock_mx4200.c refclock_neoclock4x.c \
+       refclock_nmea.c refclock_oncore.c refclock_palisade.c \
+       refclock_palisade.h refclock_parse.c \
+       refclock_pcf.c refclock_pst.c refclock_ripencc.c refclock_shm.c \
+       refclock_tpro.c refclock_true.c refclock_tt560.c \
+       refclock_ulink.c refclock_wwv.c refclock_wwvb.c \
+       refclock_zyfer.c
+
+all: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../bincheck.mf $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ntpd/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign ntpd/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstLIBRARIES:
+       -test -z "$(noinst_LIBRARIES)" || rm -f $(noinst_LIBRARIES)
+libntpd.a: $(libntpd_a_OBJECTS) $(libntpd_a_DEPENDENCIES) 
+       -rm -f libntpd.a
+       $(libntpd_a_AR) libntpd.a $(libntpd_a_OBJECTS) $(libntpd_a_LIBADD)
+       $(RANLIB) libntpd.a
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p || test -f $$p1; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+           echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+           $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+       @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+
+clean-checkPROGRAMS:
+       @list='$(check_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+check_y2k$(EXEEXT): $(check_y2k_OBJECTS) $(check_y2k_DEPENDENCIES) 
+       @rm -f check_y2k$(EXEEXT)
+       $(LINK) $(check_y2k_OBJECTS) $(check_y2k_LDADD) $(LIBS)
+ntpd$(EXEEXT): $(ntpd_OBJECTS) $(ntpd_DEPENDENCIES) 
+       @rm -f ntpd$(EXEEXT)
+       $(LINK) $(ntpd_OBJECTS) $(ntpd_LDADD) $(LIBS)
+ntpdsim$(EXEEXT): $(ntpdsim_OBJECTS) $(ntpdsim_DEPENDENCIES) 
+       @rm -f ntpdsim$(EXEEXT)
+       $(ntpdsim_LINK) $(ntpdsim_OBJECTS) $(ntpdsim_LDADD) $(LIBS)
+
+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)/check_y2k$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cmd_args$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_config$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_control$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_crypto$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_filegen$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_intres$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_io$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_loopfilter$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_monitor$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_peer$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_proto$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_refclock$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_request$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_restrict$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_timer$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp_util$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpd$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpd-opts$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdsim-cmd_args$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdsim-ntp_config$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdsim-ntp_io$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdsim-ntpd$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdsim-ntpd-opts$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdsim-ntpdsim-opts$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdsim-ntpsim$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_acts$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_arbiter$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_arc$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_as2201$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_atom$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_bancomm$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_chronolog$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_chu$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_conf$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_datum$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_dumbclock$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_fg$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_gpsvme$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_heath$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_hopfpci$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_hopfser$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_hpgps$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_irig$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_jjy$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_jupiter$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_leitch$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_local$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_mx4200$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_neoclock4x$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_nmea$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_oncore$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_palisade$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_parse$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_pcf$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_pst$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_ripencc$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_shm$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_tpro$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_true$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_tt560$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_ulink$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_wwv$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_wwvb$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/refclock_zyfer$U.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+ntpdsim-cmd_args$U.o: cmd_args$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-cmd_args$U.o -MD -MP -MF $(DEPDIR)/ntpdsim-cmd_args$U.Tpo -c -o ntpdsim-cmd_args$U.o `test -f 'cmd_args$U.c' || echo '$(srcdir)/'`cmd_args$U.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-cmd_args$U.Tpo $(DEPDIR)/ntpdsim-cmd_args$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='cmd_args$U.c' object='ntpdsim-cmd_args$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-cmd_args$U.o `test -f 'cmd_args$U.c' || echo '$(srcdir)/'`cmd_args$U.c
+
+ntpdsim-cmd_args$U.obj: cmd_args$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-cmd_args$U.obj -MD -MP -MF $(DEPDIR)/ntpdsim-cmd_args$U.Tpo -c -o ntpdsim-cmd_args$U.obj `if test -f 'cmd_args$U.c'; then $(CYGPATH_W) 'cmd_args$U.c'; else $(CYGPATH_W) '$(srcdir)/cmd_args$U.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-cmd_args$U.Tpo $(DEPDIR)/ntpdsim-cmd_args$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='cmd_args$U.c' object='ntpdsim-cmd_args$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-cmd_args$U.obj `if test -f 'cmd_args$U.c'; then $(CYGPATH_W) 'cmd_args$U.c'; else $(CYGPATH_W) '$(srcdir)/cmd_args$U.c'; fi`
+
+ntpdsim-ntp_config$U.o: ntp_config$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_config$U.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_config$U.Tpo -c -o ntpdsim-ntp_config$U.o `test -f 'ntp_config$U.c' || echo '$(srcdir)/'`ntp_config$U.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntp_config$U.Tpo $(DEPDIR)/ntpdsim-ntp_config$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntp_config$U.c' object='ntpdsim-ntp_config$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_config$U.o `test -f 'ntp_config$U.c' || echo '$(srcdir)/'`ntp_config$U.c
+
+ntpdsim-ntp_config$U.obj: ntp_config$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_config$U.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_config$U.Tpo -c -o ntpdsim-ntp_config$U.obj `if test -f 'ntp_config$U.c'; then $(CYGPATH_W) 'ntp_config$U.c'; else $(CYGPATH_W) '$(srcdir)/ntp_config$U.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntp_config$U.Tpo $(DEPDIR)/ntpdsim-ntp_config$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntp_config$U.c' object='ntpdsim-ntp_config$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_config$U.obj `if test -f 'ntp_config$U.c'; then $(CYGPATH_W) 'ntp_config$U.c'; else $(CYGPATH_W) '$(srcdir)/ntp_config$U.c'; fi`
+
+ntpdsim-ntp_io$U.o: ntp_io$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_io$U.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_io$U.Tpo -c -o ntpdsim-ntp_io$U.o `test -f 'ntp_io$U.c' || echo '$(srcdir)/'`ntp_io$U.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntp_io$U.Tpo $(DEPDIR)/ntpdsim-ntp_io$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntp_io$U.c' object='ntpdsim-ntp_io$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_io$U.o `test -f 'ntp_io$U.c' || echo '$(srcdir)/'`ntp_io$U.c
+
+ntpdsim-ntp_io$U.obj: ntp_io$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntp_io$U.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntp_io$U.Tpo -c -o ntpdsim-ntp_io$U.obj `if test -f 'ntp_io$U.c'; then $(CYGPATH_W) 'ntp_io$U.c'; else $(CYGPATH_W) '$(srcdir)/ntp_io$U.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntp_io$U.Tpo $(DEPDIR)/ntpdsim-ntp_io$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntp_io$U.c' object='ntpdsim-ntp_io$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntp_io$U.obj `if test -f 'ntp_io$U.c'; then $(CYGPATH_W) 'ntp_io$U.c'; else $(CYGPATH_W) '$(srcdir)/ntp_io$U.c'; fi`
+
+ntpdsim-ntpd$U.o: ntpd$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpd$U.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntpd$U.Tpo -c -o ntpdsim-ntpd$U.o `test -f 'ntpd$U.c' || echo '$(srcdir)/'`ntpd$U.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntpd$U.Tpo $(DEPDIR)/ntpdsim-ntpd$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntpd$U.c' object='ntpdsim-ntpd$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd$U.o `test -f 'ntpd$U.c' || echo '$(srcdir)/'`ntpd$U.c
+
+ntpdsim-ntpd$U.obj: ntpd$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpd$U.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntpd$U.Tpo -c -o ntpdsim-ntpd$U.obj `if test -f 'ntpd$U.c'; then $(CYGPATH_W) 'ntpd$U.c'; else $(CYGPATH_W) '$(srcdir)/ntpd$U.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntpd$U.Tpo $(DEPDIR)/ntpdsim-ntpd$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntpd$U.c' object='ntpdsim-ntpd$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd$U.obj `if test -f 'ntpd$U.c'; then $(CYGPATH_W) 'ntpd$U.c'; else $(CYGPATH_W) '$(srcdir)/ntpd$U.c'; fi`
+
+ntpdsim-ntpd-opts$U.o: ntpd-opts$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpd-opts$U.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntpd-opts$U.Tpo -c -o ntpdsim-ntpd-opts$U.o `test -f 'ntpd-opts$U.c' || echo '$(srcdir)/'`ntpd-opts$U.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntpd-opts$U.Tpo $(DEPDIR)/ntpdsim-ntpd-opts$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntpd-opts$U.c' object='ntpdsim-ntpd-opts$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd-opts$U.o `test -f 'ntpd-opts$U.c' || echo '$(srcdir)/'`ntpd-opts$U.c
+
+ntpdsim-ntpd-opts$U.obj: ntpd-opts$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpd-opts$U.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntpd-opts$U.Tpo -c -o ntpdsim-ntpd-opts$U.obj `if test -f 'ntpd-opts$U.c'; then $(CYGPATH_W) 'ntpd-opts$U.c'; else $(CYGPATH_W) '$(srcdir)/ntpd-opts$U.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntpd-opts$U.Tpo $(DEPDIR)/ntpdsim-ntpd-opts$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntpd-opts$U.c' object='ntpdsim-ntpd-opts$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpd-opts$U.obj `if test -f 'ntpd-opts$U.c'; then $(CYGPATH_W) 'ntpd-opts$U.c'; else $(CYGPATH_W) '$(srcdir)/ntpd-opts$U.c'; fi`
+
+ntpdsim-ntpsim$U.o: ntpsim$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpsim$U.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntpsim$U.Tpo -c -o ntpdsim-ntpsim$U.o `test -f 'ntpsim$U.c' || echo '$(srcdir)/'`ntpsim$U.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntpsim$U.Tpo $(DEPDIR)/ntpdsim-ntpsim$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntpsim$U.c' object='ntpdsim-ntpsim$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpsim$U.o `test -f 'ntpsim$U.c' || echo '$(srcdir)/'`ntpsim$U.c
+
+ntpdsim-ntpsim$U.obj: ntpsim$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpsim$U.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntpsim$U.Tpo -c -o ntpdsim-ntpsim$U.obj `if test -f 'ntpsim$U.c'; then $(CYGPATH_W) 'ntpsim$U.c'; else $(CYGPATH_W) '$(srcdir)/ntpsim$U.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntpsim$U.Tpo $(DEPDIR)/ntpdsim-ntpsim$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntpsim$U.c' object='ntpdsim-ntpsim$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpsim$U.obj `if test -f 'ntpsim$U.c'; then $(CYGPATH_W) 'ntpsim$U.c'; else $(CYGPATH_W) '$(srcdir)/ntpsim$U.c'; fi`
+
+ntpdsim-ntpdsim-opts$U.o: ntpdsim-opts$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpdsim-opts$U.o -MD -MP -MF $(DEPDIR)/ntpdsim-ntpdsim-opts$U.Tpo -c -o ntpdsim-ntpdsim-opts$U.o `test -f 'ntpdsim-opts$U.c' || echo '$(srcdir)/'`ntpdsim-opts$U.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntpdsim-opts$U.Tpo $(DEPDIR)/ntpdsim-ntpdsim-opts$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntpdsim-opts$U.c' object='ntpdsim-ntpdsim-opts$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpdsim-opts$U.o `test -f 'ntpdsim-opts$U.c' || echo '$(srcdir)/'`ntpdsim-opts$U.c
+
+ntpdsim-ntpdsim-opts$U.obj: ntpdsim-opts$U.c
+@am__fastdepCC_TRUE@   $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(ntpdsim_CFLAGS) $(CFLAGS) -MT ntpdsim-ntpdsim-opts$U.obj -MD -MP -MF $(DEPDIR)/ntpdsim-ntpdsim-opts$U.Tpo -c -o ntpdsim-ntpdsim-opts$U.obj `if test -f 'ntpdsim-opts$U.c'; then $(CYGPATH_W) 'ntpdsim-opts$U.c'; else $(CYGPATH_W) '$(srcdir)/ntpdsim-opts$U.c'; fi`
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/ntpdsim-ntpdsim-opts$U.Tpo $(DEPDIR)/ntpdsim-ntpdsim-opts$U.Po
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='ntpdsim-opts$U.c' object='ntpdsim-ntpdsim-opts$U.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) $(ntpdsim_CFLAGS) $(CFLAGS) -c -o ntpdsim-ntpdsim-opts$U.obj `if test -f 'ntpdsim-opts$U.c'; then $(CYGPATH_W) 'ntpdsim-opts$U.c'; else $(CYGPATH_W) '$(srcdir)/ntpdsim-opts$U.c'; fi`
+check_y2k_.c: check_y2k.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/check_y2k.c; then echo $(srcdir)/check_y2k.c; else echo check_y2k.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+cmd_args_.c: cmd_args.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/cmd_args.c; then echo $(srcdir)/cmd_args.c; else echo cmd_args.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_config_.c: ntp_config.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_config.c; then echo $(srcdir)/ntp_config.c; else echo ntp_config.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_control_.c: ntp_control.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_control.c; then echo $(srcdir)/ntp_control.c; else echo ntp_control.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_crypto_.c: ntp_crypto.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_crypto.c; then echo $(srcdir)/ntp_crypto.c; else echo ntp_crypto.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_filegen_.c: ntp_filegen.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_filegen.c; then echo $(srcdir)/ntp_filegen.c; else echo ntp_filegen.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_intres_.c: ntp_intres.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_intres.c; then echo $(srcdir)/ntp_intres.c; else echo ntp_intres.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_io_.c: ntp_io.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_io.c; then echo $(srcdir)/ntp_io.c; else echo ntp_io.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_loopfilter_.c: ntp_loopfilter.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_loopfilter.c; then echo $(srcdir)/ntp_loopfilter.c; else echo ntp_loopfilter.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_monitor_.c: ntp_monitor.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_monitor.c; then echo $(srcdir)/ntp_monitor.c; else echo ntp_monitor.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_peer_.c: ntp_peer.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_peer.c; then echo $(srcdir)/ntp_peer.c; else echo ntp_peer.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_proto_.c: ntp_proto.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_proto.c; then echo $(srcdir)/ntp_proto.c; else echo ntp_proto.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_refclock_.c: ntp_refclock.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_refclock.c; then echo $(srcdir)/ntp_refclock.c; else echo ntp_refclock.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_request_.c: ntp_request.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_request.c; then echo $(srcdir)/ntp_request.c; else echo ntp_request.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_restrict_.c: ntp_restrict.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_restrict.c; then echo $(srcdir)/ntp_restrict.c; else echo ntp_restrict.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_timer_.c: ntp_timer.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_timer.c; then echo $(srcdir)/ntp_timer.c; else echo ntp_timer.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp_util_.c: ntp_util.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp_util.c; then echo $(srcdir)/ntp_util.c; else echo ntp_util.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpd_.c: ntpd.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpd.c; then echo $(srcdir)/ntpd.c; else echo ntpd.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpd-opts_.c: ntpd-opts.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpd-opts.c; then echo $(srcdir)/ntpd-opts.c; else echo ntpd-opts.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpdsim-opts_.c: ntpdsim-opts.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpdsim-opts.c; then echo $(srcdir)/ntpdsim-opts.c; else echo ntpdsim-opts.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpsim_.c: ntpsim.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpsim.c; then echo $(srcdir)/ntpsim.c; else echo ntpsim.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_acts_.c: refclock_acts.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_acts.c; then echo $(srcdir)/refclock_acts.c; else echo refclock_acts.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_arbiter_.c: refclock_arbiter.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_arbiter.c; then echo $(srcdir)/refclock_arbiter.c; else echo refclock_arbiter.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_arc_.c: refclock_arc.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_arc.c; then echo $(srcdir)/refclock_arc.c; else echo refclock_arc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_as2201_.c: refclock_as2201.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_as2201.c; then echo $(srcdir)/refclock_as2201.c; else echo refclock_as2201.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_atom_.c: refclock_atom.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_atom.c; then echo $(srcdir)/refclock_atom.c; else echo refclock_atom.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_bancomm_.c: refclock_bancomm.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_bancomm.c; then echo $(srcdir)/refclock_bancomm.c; else echo refclock_bancomm.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_chronolog_.c: refclock_chronolog.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_chronolog.c; then echo $(srcdir)/refclock_chronolog.c; else echo refclock_chronolog.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_chu_.c: refclock_chu.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_chu.c; then echo $(srcdir)/refclock_chu.c; else echo refclock_chu.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_conf_.c: refclock_conf.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_conf.c; then echo $(srcdir)/refclock_conf.c; else echo refclock_conf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_datum_.c: refclock_datum.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_datum.c; then echo $(srcdir)/refclock_datum.c; else echo refclock_datum.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_dumbclock_.c: refclock_dumbclock.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_dumbclock.c; then echo $(srcdir)/refclock_dumbclock.c; else echo refclock_dumbclock.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_fg_.c: refclock_fg.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_fg.c; then echo $(srcdir)/refclock_fg.c; else echo refclock_fg.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_gpsvme_.c: refclock_gpsvme.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_gpsvme.c; then echo $(srcdir)/refclock_gpsvme.c; else echo refclock_gpsvme.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_heath_.c: refclock_heath.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_heath.c; then echo $(srcdir)/refclock_heath.c; else echo refclock_heath.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_hopfpci_.c: refclock_hopfpci.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_hopfpci.c; then echo $(srcdir)/refclock_hopfpci.c; else echo refclock_hopfpci.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_hopfser_.c: refclock_hopfser.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_hopfser.c; then echo $(srcdir)/refclock_hopfser.c; else echo refclock_hopfser.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_hpgps_.c: refclock_hpgps.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_hpgps.c; then echo $(srcdir)/refclock_hpgps.c; else echo refclock_hpgps.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_irig_.c: refclock_irig.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_irig.c; then echo $(srcdir)/refclock_irig.c; else echo refclock_irig.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_jjy_.c: refclock_jjy.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_jjy.c; then echo $(srcdir)/refclock_jjy.c; else echo refclock_jjy.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_jupiter_.c: refclock_jupiter.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_jupiter.c; then echo $(srcdir)/refclock_jupiter.c; else echo refclock_jupiter.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_leitch_.c: refclock_leitch.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_leitch.c; then echo $(srcdir)/refclock_leitch.c; else echo refclock_leitch.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_local_.c: refclock_local.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_local.c; then echo $(srcdir)/refclock_local.c; else echo refclock_local.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_mx4200_.c: refclock_mx4200.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_mx4200.c; then echo $(srcdir)/refclock_mx4200.c; else echo refclock_mx4200.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_neoclock4x_.c: refclock_neoclock4x.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_neoclock4x.c; then echo $(srcdir)/refclock_neoclock4x.c; else echo refclock_neoclock4x.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_nmea_.c: refclock_nmea.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_nmea.c; then echo $(srcdir)/refclock_nmea.c; else echo refclock_nmea.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_oncore_.c: refclock_oncore.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_oncore.c; then echo $(srcdir)/refclock_oncore.c; else echo refclock_oncore.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_palisade_.c: refclock_palisade.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_palisade.c; then echo $(srcdir)/refclock_palisade.c; else echo refclock_palisade.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_parse_.c: refclock_parse.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_parse.c; then echo $(srcdir)/refclock_parse.c; else echo refclock_parse.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_pcf_.c: refclock_pcf.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_pcf.c; then echo $(srcdir)/refclock_pcf.c; else echo refclock_pcf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_pst_.c: refclock_pst.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_pst.c; then echo $(srcdir)/refclock_pst.c; else echo refclock_pst.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_ripencc_.c: refclock_ripencc.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_ripencc.c; then echo $(srcdir)/refclock_ripencc.c; else echo refclock_ripencc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_shm_.c: refclock_shm.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_shm.c; then echo $(srcdir)/refclock_shm.c; else echo refclock_shm.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_tpro_.c: refclock_tpro.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_tpro.c; then echo $(srcdir)/refclock_tpro.c; else echo refclock_tpro.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_true_.c: refclock_true.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_true.c; then echo $(srcdir)/refclock_true.c; else echo refclock_true.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_tt560_.c: refclock_tt560.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_tt560.c; then echo $(srcdir)/refclock_tt560.c; else echo refclock_tt560.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_ulink_.c: refclock_ulink.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_ulink.c; then echo $(srcdir)/refclock_ulink.c; else echo refclock_ulink.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_wwv_.c: refclock_wwv.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_wwv.c; then echo $(srcdir)/refclock_wwv.c; else echo refclock_wwv.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_wwvb_.c: refclock_wwvb.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_wwvb.c; then echo $(srcdir)/refclock_wwvb.c; else echo refclock_wwvb.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+refclock_zyfer_.c: refclock_zyfer.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/refclock_zyfer.c; then echo $(srcdir)/refclock_zyfer.c; else echo refclock_zyfer.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+check_y2k_.$(OBJEXT) check_y2k_.lo cmd_args_.$(OBJEXT) cmd_args_.lo \
+ntp_config_.$(OBJEXT) ntp_config_.lo ntp_control_.$(OBJEXT) \
+ntp_control_.lo ntp_crypto_.$(OBJEXT) ntp_crypto_.lo \
+ntp_filegen_.$(OBJEXT) ntp_filegen_.lo ntp_intres_.$(OBJEXT) \
+ntp_intres_.lo ntp_io_.$(OBJEXT) ntp_io_.lo ntp_loopfilter_.$(OBJEXT) \
+ntp_loopfilter_.lo ntp_monitor_.$(OBJEXT) ntp_monitor_.lo \
+ntp_peer_.$(OBJEXT) ntp_peer_.lo ntp_proto_.$(OBJEXT) ntp_proto_.lo \
+ntp_refclock_.$(OBJEXT) ntp_refclock_.lo ntp_request_.$(OBJEXT) \
+ntp_request_.lo ntp_restrict_.$(OBJEXT) ntp_restrict_.lo \
+ntp_timer_.$(OBJEXT) ntp_timer_.lo ntp_util_.$(OBJEXT) ntp_util_.lo \
+ntpd_.$(OBJEXT) ntpd_.lo ntpd-opts_.$(OBJEXT) ntpd-opts_.lo \
+ntpdsim-opts_.$(OBJEXT) ntpdsim-opts_.lo ntpsim_.$(OBJEXT) ntpsim_.lo \
+refclock_acts_.$(OBJEXT) refclock_acts_.lo refclock_arbiter_.$(OBJEXT) \
+refclock_arbiter_.lo refclock_arc_.$(OBJEXT) refclock_arc_.lo \
+refclock_as2201_.$(OBJEXT) refclock_as2201_.lo \
+refclock_atom_.$(OBJEXT) refclock_atom_.lo refclock_bancomm_.$(OBJEXT) \
+refclock_bancomm_.lo refclock_chronolog_.$(OBJEXT) \
+refclock_chronolog_.lo refclock_chu_.$(OBJEXT) refclock_chu_.lo \
+refclock_conf_.$(OBJEXT) refclock_conf_.lo refclock_datum_.$(OBJEXT) \
+refclock_datum_.lo refclock_dumbclock_.$(OBJEXT) \
+refclock_dumbclock_.lo refclock_fg_.$(OBJEXT) refclock_fg_.lo \
+refclock_gpsvme_.$(OBJEXT) refclock_gpsvme_.lo \
+refclock_heath_.$(OBJEXT) refclock_heath_.lo \
+refclock_hopfpci_.$(OBJEXT) refclock_hopfpci_.lo \
+refclock_hopfser_.$(OBJEXT) refclock_hopfser_.lo \
+refclock_hpgps_.$(OBJEXT) refclock_hpgps_.lo refclock_irig_.$(OBJEXT) \
+refclock_irig_.lo refclock_jjy_.$(OBJEXT) refclock_jjy_.lo \
+refclock_jupiter_.$(OBJEXT) refclock_jupiter_.lo \
+refclock_leitch_.$(OBJEXT) refclock_leitch_.lo \
+refclock_local_.$(OBJEXT) refclock_local_.lo \
+refclock_mx4200_.$(OBJEXT) refclock_mx4200_.lo \
+refclock_neoclock4x_.$(OBJEXT) refclock_neoclock4x_.lo \
+refclock_nmea_.$(OBJEXT) refclock_nmea_.lo refclock_oncore_.$(OBJEXT) \
+refclock_oncore_.lo refclock_palisade_.$(OBJEXT) refclock_palisade_.lo \
+refclock_parse_.$(OBJEXT) refclock_parse_.lo refclock_pcf_.$(OBJEXT) \
+refclock_pcf_.lo refclock_pst_.$(OBJEXT) refclock_pst_.lo \
+refclock_ripencc_.$(OBJEXT) refclock_ripencc_.lo \
+refclock_shm_.$(OBJEXT) refclock_shm_.lo refclock_tpro_.$(OBJEXT) \
+refclock_tpro_.lo refclock_true_.$(OBJEXT) refclock_true_.lo \
+refclock_tt560_.$(OBJEXT) refclock_tt560_.lo refclock_ulink_.$(OBJEXT) \
+refclock_ulink_.lo refclock_wwv_.$(OBJEXT) refclock_wwv_.lo \
+refclock_wwvb_.$(OBJEXT) refclock_wwvb_.lo refclock_zyfer_.$(OBJEXT) \
+refclock_zyfer_.lo : $(ANSI2KNR)
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-man1: $(man_MANS)
+       @$(NORMAL_INSTALL)
+       test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+       @list=''; test -n "$(man1dir)" || exit 0; \
+       { for i in $$list; do echo "$$i"; done; \
+       l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.1[a-z]*$$/p'; \
+       } | while read p; do \
+         if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; echo "$$p"; \
+       done | \
+       sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+       sed 'N;N;s,\n, ,g' | { \
+       list=; while read file base inst; do \
+         if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+         fi; \
+       done; \
+       for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+       while read files; do \
+         test -z "$$files" || { \
+           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+           $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+       done; }
+
+uninstall-man1:
+       @$(NORMAL_UNINSTALL)
+       @list=''; test -n "$(man1dir)" || exit 0; \
+       files=`{ for i in $$list; do echo "$$i"; done; \
+       l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.1[a-z]*$$/p'; \
+       } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @list='$(MANS)'; if test -n "$$list"; then \
+         list=`for p in $$list; do \
+           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+           if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+         if test -n "$$list" && \
+           grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+           echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+           grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/         /' >&2; \
+           echo "       to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+           echo "       typically \`make maintainer-clean' will remove them" >&2; \
+           exit 1; \
+         else :; fi; \
+       else :; fi
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+       $(MAKE) $(AM_MAKEFLAGS) $(check_PROGRAMS)
+       $(MAKE) $(AM_MAKEFLAGS) check-local
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(LIBRARIES) $(PROGRAMS) $(MANS)
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+       -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+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-binPROGRAMS clean-checkPROGRAMS clean-generic \
+       clean-libtool clean-noinstLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+       @$(NORMAL_INSTALL)
+       $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man1
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-man
+
+uninstall-man: uninstall-man1
+
+.MAKE: ../util/ansi2knr all check check-am install install-am \
+       install-exec-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am check-local clean \
+       clean-binPROGRAMS clean-checkPROGRAMS 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-binPROGRAMS install-data \
+       install-data-am install-dvi install-dvi-am install-exec \
+       install-exec-am install-exec-hook install-html install-html-am \
+       install-info install-info-am install-man install-man1 \
+       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 uninstall-binPROGRAMS uninstall-man \
+       uninstall-man1
+
+
+check-local: @MAKE_CHECK_Y2K@
+       test -z "@MAKE_CHECK_Y2K@" || ./@MAKE_CHECK_Y2K@
+
+$(srcdir)/ntpd-opts.h: $(srcdir)/ntpd-opts.c
+$(srcdir)/ntpd-opts.c: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
+       $(run_ag) ntpd-opts.def
+
+$(srcdir)/ntpd.1: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
+       $(run_ag) -Tagman1.tpl -bntpd ntpd-opts.def
+
+$(srcdir)/ntpd-opts.texi $(srcdir)/ntpd-opts.menu: $(srcdir)/ntpd-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list)
+       $(run_ag) -Taginfo.tpl -DLEVEL=section ntpd-opts.def
+
+$(srcdir)/ntpdsim-opts.h: $(srcdir)/ntpdsim-opts.c
+$(srcdir)/ntpdsim-opts.c: $(srcdir)/ntpdsim-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list) $(top_srcdir)/include/homerc.def
+       $(run_ag) ntpdsim-opts.def
+
+$(srcdir)/ntpdsim.1: $(srcdir)/ntpdsim-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list) $(top_srcdir)/include/homerc.def
+       $(run_ag) -Tagman1.tpl -bntpdsim ntpdsim-opts.def
+
+$(srcdir)/ntpdsim-opts.texi $(srcdir)/ntpdsim-opts.menu: $(srcdir)/ntpdsim-opts.def $(srcdir)/ntpdbase-opts.def $(std_def_list) $(top_srcdir)/include/homerc.def
+       $(run_ag) -Taginfo.tpl -DLEVEL=section ntpdsim-opts.def
+
+$(PROGRAMS): $(LDADD)
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE) libntp.a
+
+../libntp/libntpsim.a:
+       cd ../libntp && $(MAKE) libntpsim.a
+
+../libparse/libparse.a:
+       cd ../libparse && $(MAKE)
+
+$(top_srcdir)/version :
+       cd $(top_srcdir) && $(MAKE) version
+
+version.o: $(ntpd_OBJECTS) ../libntp/libntp.a @LIBPARSE@ Makefile $(top_srcdir)/version
+       env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpd
+       $(COMPILE) -c version.c
+
+install-exec-hook:
+       @case ${BINSUBDIR} in                                   \
+        bin) ODIR=${exec_prefix}/sbin ;;                       \
+        sbin) ODIR=${exec_prefix}/bin ;;                       \
+       esac;                                                   \
+       test -z "${bin_PROGRAMS}${bin_SCRIPTS}"                 \
+       || for i in ${bin_PROGRAMS} ${bin_SCRIPTS} " "; do              \
+          test ! -f $$ODIR/$$i || echo "*** $$i is also in $$ODIR!";   \
+       done
+
+#
+
+# 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.
+.NOEXPORT:
diff --git a/ntpd/check_y2k.c b/ntpd/check_y2k.c
new file mode 100644 (file)
index 0000000..6b83115
--- /dev/null
@@ -0,0 +1,627 @@
+/* check_y2k.c -- test ntp code constructs for Y2K correctness         Y2KFixes [*/
+
+  /*
+       Code invoked by `make check`. Not part of ntpd and not to be
+       installed.
+
+       On any code I even wonder about, I've cut and pasted the code
+       here and ran it as a test case just to be sure.
+
+       For code not in "ntpd" proper, we have tried to call most 
+       repaired functions from herein to properly test them
+       (something never done before!). This has found several bugs,
+       not normal Y2K bugs, that will strike in Y2K so repair them
+       we did.
+
+       Program exits with 0 on success, 1 on Y2K failure (stdout messages).
+       Exit of 2 indicates internal logic bug detected OR failure of
+       what should be our correct formulas.
+
+       While "make check" should only check logic for source within that
+       specific directory, this check goes outside the scope of the local
+       directory.  It's not a perfect world (besides, there is a lot of
+       interdependence here, and it really needs to be tested in
+       a controled order).
+   */
+
+/* { definitions lifted from ntpd.c to allow us to complie with 
+     "#include ntp.h".  I have not taken the time to reduce the clutter. */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntpd.h"
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#include <stdio.h>
+#include <errno.h>
+#ifndef SYS_WINNT
+# if !defined(VMS)     /*wjm*/
+#  include <sys/param.h>
+# endif /* VMS */
+# if HAVE_SYS_SIGNAL_H
+#  include <sys/signal.h>
+# endif /* HAVE_SYS_SIGNAL_H */
+# include <sys/signal.h>
+# ifdef HAVE_SYS_IOCTL_H
+#  include <sys/ioctl.h>
+# endif /* HAVE_SYS_IOCTL_H */
+# if !defined(VMS)     /*wjm*/
+#  include <sys/resource.h>
+# endif /* VMS */
+#else
+# include <signal.h>
+# include <process.h>
+# include <io.h>
+# include "../libntp/log.h"
+#endif /* SYS_WINNT */
+#if defined(HAVE_RTPRIO)
+# ifdef HAVE_SYS_RESOURCE_H
+#  include <sys/resource.h>
+# endif
+# ifdef HAVE_SYS_LOCK_H
+#  include <sys/lock.h>
+# endif
+# include <sys/rtprio.h>
+#else
+# ifdef HAVE_PLOCK
+#  ifdef HAVE_SYS_LOCK_H
+#      include <sys/lock.h>
+#  endif
+# endif
+#endif
+#if defined(HAVE_SCHED_SETSCHEDULER)
+# ifdef HAVE_SCHED_H
+#  include <sched.h>
+# else
+#  ifdef HAVE_SYS_SCHED_H
+#   include <sys/sched.h>
+#  endif
+# endif
+#endif
+#if defined(HAVE_SYS_MMAN_H)
+# include <sys/mman.h>
+#endif
+
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+
+#ifdef SYS_DOMAINOS
+# include <apollo/base.h>
+#endif /* SYS_DOMAINOS */
+
+/* } end definitions lifted from ntpd.c */
+
+#include "ntp_calendar.h"
+#include "parse.h"
+
+#define GoodLeap(Year) (((Year)%4 || (!((Year)%100) && (Year)%400)) ? 0 : 13 )
+
+volatile int debug = 0;                /* debugging requests for parse stuff */
+char const *progname = "check_y2k";
+
+long
+Days ( int Year )              /* return number of days since year "0" */
+{
+    long  Return;
+               /* this is a known to be good algorithm */
+    Return = Year * 365;       /* first aproximation to the value */
+    if ( Year >= 1 )
+    {          /* see notes in libparse/parse.c if you want a PROPER
+                * **generic algorithm. */
+       Return += (Year+3) / 4;         /* add in (too many) leap days */
+       Return -= (Year-1) / 100;       /* reduce by (too many) centurys */
+       Return += (Year-1) / 400;       /* get final answer */
+    }
+
+    return Return;
+}
+
+static int  year0 = 1900;      /* sarting year for NTP time */
+static int  yearend;           /* ending year we test for NTP time.
+                                   * 32-bit systems: through 2036, the
+                                     **year in which NTP time overflows.
+                                   * 64-bit systems: a reasonable upper
+                                     **limit (well, maybe somewhat beyond
+                                     **reasonable, but well before the
+                                     **max time, by which time the earth
+                                     **will be dead.) */
+static time_t Time;
+static struct tm LocalTime;
+
+#define Error(year) if ( (year)>=2036 && LocalTime.tm_year < 110 ) \
+       Warnings++; else Fatals++
+
+int
+main( void )
+{
+    int Fatals;
+    int Warnings;
+    int  year;
+
+    Time = time( (time_t *)NULL )
+#ifdef TESTTIMEOFFSET
+               + test_time_offset
+#endif
+       ;
+    LocalTime = *localtime( &Time );
+
+    year = ( sizeof( u_long ) > 4 )    /* save max span using year as temp */
+               ? ( 400 * 3 )           /* three greater gregorian cycles */
+               : ((int)(0x7FFFFFFF / 365.242 / 24/60/60)* 2 ); /*32-bit limit*/
+                       /* NOTE: will automacially expand test years on
+                        * 64 bit machines.... this may cause some of the
+                        * existing ntp logic to fail for years beyond
+                        * 2036 (the current 32-bit limit). If all checks
+                        * fail ONLY beyond year 2036 you may ignore such
+                        * errors, at least for a decade or so. */
+    yearend = year0 + year;
+
+    puts( " internal self check" );
+  {            /* verify our own logic used to verify repairs */
+    unsigned long days;
+
+    if ( year0 >= yearend )
+    {
+       fprintf( stdout, "year0=%d NOT LESS THAN yearend=%d  (span=%d)\n",
+               (int)year0, (int)yearend, (int)year );
+       exit(2);
+    }
+
+   {
+    int  save_year;
+
+    save_year = LocalTime.tm_year;     /* save current year */
+
+    year = 1980;
+    LocalTime.tm_year = year - 1900;
+    Fatals = Warnings = 0;
+    Error(year);               /* should increment Fatals */
+    if ( Fatals == 0 ) 
+    {
+       fprintf( stdout, 
+           "%4d: %s(%d): FATAL DID NOT INCREMENT  (Fatals=%d Warnings=%d)\n",
+           (int)year, __FILE__, __LINE__, (int)Fatals, (int)Warnings );
+       exit(2);
+    }
+
+    year = 2100;               /* test year > limit but CURRENT year < limit */
+    Fatals = Warnings = 0;
+    Error(year);               /* should increment Fatals */
+    if ( Warnings == 0 ) 
+    {
+       fprintf( stdout, 
+           "%4d: %s(%d): WARNING DID NOT INCREMENT  (Fatals=%d Warnings=%d)\n",
+           (int)year, __FILE__, __LINE__, (int)Fatals, (int)Warnings );
+       exit(2);
+    }
+    Fatals = Warnings = 0;
+    LocalTime.tm_year = year - 1900;   /* everything > limit */
+    Error(1980);               /* should increment Fatals */
+    if ( Fatals == 0 ) 
+    {
+       fprintf( stdout, 
+           "%4d: %s(%d): FATALS DID NOT INCREMENT  (Fatals=%d Warnings=%d)\n",
+           (int)year, __FILE__, __LINE__, (int)Fatals, (int)Warnings );
+       exit(2);
+    }
+
+    LocalTime.tm_year = save_year;
+   }
+
+    days = 365+1;              /* days in year 0 + 1 more day */
+    for ( year = 1; year <= 2500; year++ )
+    {
+       long   Test;
+       Test = Days( year );
+       if ( days != Test )
+       {
+           fprintf( stdout, "%04d: Days() DAY COUNT ERROR: s/b=%ld was=%ld\n", 
+               year, (long)days, (long)Test );
+           exit(2);            /* would throw off many other tests */
+       }
+
+       Test = julian0(year);           /* compare with julian0() macro */
+       if ( days != Test )
+       {
+           fprintf( stdout, "%04d: julian0() DAY COUNT ERROR: s/b=%ld was=%ld\n", 
+               year, (long)days, (long)Test );
+           exit(2);            /* would throw off many other tests */
+       }
+
+       days += 365;
+       if ( isleap_4(year) ) days++;
+    }
+
+    if ( isleap_4(1999) )
+    {
+       fprintf( stdout, "isleap_4(1999) REPORTED TRUE\n" );
+       exit(2);
+    }
+    if ( !isleap_4(2000) )
+    {
+       fprintf( stdout, "isleap_4(2000) REPORTED FALSE\n" );
+       exit(2);
+    }
+    if ( isleap_4(2001) )
+    {
+       fprintf( stdout, "isleap_4(1999) REPORTED TRUE\n" );
+       exit(2);
+    }
+
+    if ( !isleap_tm(2000-1900) )
+    {
+       fprintf( stdout, "isleap_tm(100) REPORTED FALSE\n" );
+       exit(2);
+    }
+  }
+
+    Fatals = Warnings = 0;
+
+    puts( " include/ntp.h" );
+  {            /* test our new isleap_*() #define "functions" */
+    
+    for ( year = 1400; year <= 2200; year++ )
+    {
+       int  LeapSw;
+       int  IsLeapSw;
+
+       LeapSw = GoodLeap(year);
+       IsLeapSw = isleap_4(year);
+
+       if ( !!LeapSw != !!IsLeapSw )
+       {
+           Error(year);
+           fprintf( stdout, 
+               "  %4d %2d %3d *** ERROR\n", year, LeapSw, IsLeapSw );
+           break;
+       }
+
+       IsLeapSw = isleap_tm(year-1900);
+
+       if ( !!LeapSw != !!IsLeapSw )
+       {
+           Error(year);
+           fprintf( stdout, 
+               "  %4d %2d %3d *** ERROR\n", year, LeapSw, IsLeapSw );
+           break;
+       }
+    }
+  }
+
+    puts( " include/ntp_calendar.h" );
+  {            /* I belive this is good, but just to be sure... */
+
+       /* we are testing this #define */
+#define is_leapyear(y) (y%4 == 0 && !(y%100 == 0 && !(y%400 == 0)))
+
+    for ( year = 1400; year <= 2200; year++ )
+    {
+       int  LeapSw;
+
+       LeapSw = GoodLeap(year);
+
+       if ( !(!LeapSw) != !(!is_leapyear(year)) )
+       {
+           Error(year);
+           fprintf( stdout, 
+               "  %4d %2d *** ERROR\n", year, LeapSw );
+           break;
+       }
+    }
+  }   
+
+
+    puts( " libparse/parse.c" );
+  { 
+    long Days1970;     /* days from 1900 to 1970 */
+
+    struct ParseTime   /* womp up a test structure to all cut/paste code */
+    {
+       int   year;
+    } Clock_Time, *clock_time;
+
+    clock_time = &Clock_Time;
+
+       /* first test this #define */
+#define days_per_year(x)  ((x) % 4 ? 365 : ((x % 400) ? ((x % 100) ? 366 : 365) : 366))
+
+    for ( year = 1400; year <= 2200; year++ )
+    {
+       int  LeapSw;
+       int  DayCnt;
+
+       LeapSw = GoodLeap(year);
+       DayCnt = (int)days_per_year(year);
+
+       if ( ( LeapSw ? 366 : 365 ) != DayCnt )
+       {
+           Error(year);
+           fprintf( stdout, 
+                   "  days_per_year() %4d %2d %3d *** ERROR\n", 
+                   year, LeapSw, DayCnt );
+           break;
+       }
+    }
+
+    /* test (what is now julian0) calculations */
+
+    Days1970 = Days( 1970 );   /* get days since 1970 using a known good */
+
+    for ( year = 1970; year < yearend; year++ )
+    {                          
+       unsigned long t;
+       long DaysYear ;
+
+       clock_time->year = year;
+
+       /* here is the code we are testing, cut and pasted out of the source */
+#if 0          /* old BUGGY code that has Y2K (and many other) failures */
+           /* ghealton: this logic FAILED with great frequency when run
+            * over a period of time, including for year 2000. True, it
+            * had more successes than failures, but that's not really good
+            * enough for critical time distribution software.
+            * It is so awful I wonder if it has had a history of failure 
+            * and fixes? */
+        t =  (clock_time->year - 1970) * 365;
+        t += (clock_time->year >> 2) - (1970 >> 2);
+        t -= clock_time->year / 100 - 1970 / 100;
+        t += clock_time->year / 400 - 1970 / 400;
+
+               /* (immediate feare of rounding errors on integer
+                * **divisions proved well founded) */
+
+#else
+       /* my replacement, based on Days() above */
+       t = julian0(year) - julian0(1970);
+#endif
+
+       /* compare result in t against trusted calculations */
+       DaysYear = Days( year );        /* get days to this year */
+       if ( t != DaysYear - Days1970 )
+       {
+           Error(year);
+           fprintf( stdout, 
+               "  %4d 1970=%-8ld %4d=%-8ld %-3ld  t=%-8ld  *** ERROR ***\n",
+                 year,      (long)Days1970,
+                                year,
+                                    (long)DaysYear,
+                                          (long)(DaysYear - Days1970),
+                                                  (long)t );
+       }
+    }
+
+#if 1          /* { */
+   {
+    debug = 1;                 /* enable debugging */
+    for ( year = 1970; year < yearend; year++ )
+    {          /* (limited by theory unix 2038 related bug lives by, but
+                * ends in yearend) */
+       clocktime_t  ct;
+       time_t       Observed;
+       time_t       Expected;
+       u_long       Flag;
+       unsigned long t;
+
+       ct.day = 1;
+       ct.month = 1;
+       ct.year = year;
+       ct.hour = ct.minute = ct.second = ct.usecond = 0;
+       ct.utcoffset = 0;
+       ct.utctime = 0;
+       ct.flags = 0;
+
+       Flag = 0;
+       Observed = parse_to_unixtime( &ct, &Flag );
+       if ( ct.year != year )
+       {
+           fprintf( stdout, 
+              "%04d: parse_to_unixtime(,%d) CORRUPTED ct.year: was %d\n",
+              (int)year, (int)Flag, (int)ct.year );
+           Error(year);
+           break;
+       }
+       t = julian0(year) - julian0(1970);      /* Julian day from 1970 */
+       Expected = t * 24 * 60 * 60;
+       if ( Observed != Expected  ||  Flag )
+       {   /* time difference */
+           fprintf( stdout, 
+              "%04d: parse_to_unixtime(,%d) FAILURE: was=%lu s/b=%lu  (%ld)\n",
+              year, (int)Flag, 
+              (unsigned long)Observed, (unsigned long)Expected,
+              ((long)Observed - (long)Expected) );
+           Error(year);
+           break;
+       }
+
+       if ( year >= YEAR_PIVOT+1900 )
+       {
+           /* check year % 100 code we put into parse_to_unixtime() */
+           ct.utctime = 0;
+           ct.year = year % 100;
+           Flag = 0;
+
+           Observed = parse_to_unixtime( &ct, &Flag );
+
+           if ( Observed != Expected  ||  Flag )
+           {   /* time difference */
+               fprintf( stdout, 
+"%04d: parse_to_unixtime(%d,%d) FAILURE: was=%lu s/b=%lu  (%ld)\n",
+                  year, (int)ct.year, (int)Flag, 
+                  (unsigned long)Observed, (unsigned long)Expected,
+                  ((long)Observed - (long)Expected) );
+               Error(year);
+               break;
+           }
+
+           /* check year - 1900 code we put into parse_to_unixtime() */
+           ct.utctime = 0;
+           ct.year = year - 1900;
+           Flag = 0;
+
+           Observed = parse_to_unixtime( &ct, &Flag );
+
+           if ( Observed != Expected  ||  Flag )
+           {   /* time difference */
+               fprintf( stdout, 
+"%04d: parse_to_unixtime(%d,%d) FAILURE: was=%lu s/b=%lu  (%ld)\n",
+                  year, (int)ct.year, (int)Flag, 
+                  (unsigned long)Observed, (unsigned long)Expected,
+                  ((long)Observed - (long)Expected) );
+               Error(year);
+               break;
+           }
+
+
+       }
+    }
+#endif         /* } */
+   }
+  }
+
+    puts( " libntp/caljulian.c" );
+  {            /* test caljulian() */
+    struct     calendar  ot;
+    u_long ntp_time;           /* NTP time */
+
+    year = year0;              /* calculate the basic year */
+    printf( "  starting year %04d\n", (int)year0 );
+    printf( "  ending year   %04d\n", (int)yearend );
+
+
+    ntp_time = julian0( year0 );               /* NTP starts in 1900-01-01 */
+#if DAY_NTP_STARTS == 693596
+    ntp_time -= 365;           /* BIAS required for successful test */
+#endif
+    if ( DAY_NTP_STARTS != ntp_time )
+    {
+       Error(year);
+       fprintf( stdout, 
+               "%04d: DAY_NTP_STARTS (%ld) NOT TRUE VALUE OF %ld (%ld)\n",
+               (int)year0,
+               (long)DAY_NTP_STARTS,  (long)ntp_time,
+               (long)DAY_NTP_STARTS - (long)ntp_time );
+    }
+
+    for ( ; year < yearend; year++ )
+    {
+       
+       /* 01-01 for the current year */
+       ntp_time = Days( year ) - Days( year0 );  /* days into NTP time */
+       ntp_time *= 24 * 60 * 60;       /* convert into seconds */
+       caljulian( ntp_time, &ot );     /* convert January 1 */
+       if ( ot.year  != year
+         || ot.month != 1
+         || ot.monthday != 1 )
+       {
+           Error(year);
+           fprintf( stdout, "%lu: EXPECTED %04d-01-01: FOUND %04d-%02d-%02d\n",
+                       (unsigned long)ntp_time,
+                       year, 
+                       (int)ot.year, (int)ot.month, (int)ot.monthday );
+           break;
+       }
+
+       ntp_time += (31 + 28-1) * ( 24 * 60 * 60 );     /* advance to 02-28 */
+       caljulian( ntp_time, &ot );     /* convert Feb 28 */
+       if ( ot.year  != year
+         || ot.month != 2
+         || ot.monthday != 28 )
+       {
+           Error(year);
+           fprintf( stdout, "%lu: EXPECTED %04d-02-28: FOUND %04d-%02d-%02d\n",
+                       (unsigned long)ntp_time,
+                       year, 
+                       (int)ot.year, (int)ot.month, (int)ot.monthday );
+           break;
+       }
+
+      {
+       int    m;               /* expected month */
+       int    d;               /* expected day */
+
+       m = isleap_4(year) ?  2 : 3;
+       d = isleap_4(year) ? 29 : 1;
+
+       ntp_time += ( 24 * 60 * 60 );   /* advance to the next day */
+       caljulian( ntp_time, &ot );     /* convert this day */
+       if ( ot.year  != year
+         || ot.month != m
+         || ot.monthday != d )
+       {
+           Error(year);
+           fprintf( stdout, "%lu: EXPECTED %04d-%02d-%02d: FOUND %04d-%02d-%02d\n",
+                       (unsigned long)ntp_time,
+                       year, m, d, 
+                       (int)ot.year, (int)ot.month, (int)ot.monthday );
+           break;
+       }
+
+      }
+    }
+  }
+
+    puts( " libntp/caltontp.c" );
+  {            /* test caltontp() */
+    struct     calendar  ot;
+    u_long      ntp_time;              /* NTP time */
+
+    year = year0;              /* calculate the basic year */
+    printf( "  starting year %04d\n", (int)year0 );
+    printf( "  ending year   %04d\n", (int)yearend );
+
+
+    for ( ; year < yearend; year++ )
+    {
+       u_long  ObservedNtp;
+       
+       /* 01-01 for the current year */
+       ot.year = year;
+       ot.month = ot.monthday = 1;     /* unused, but set anyway JIC */
+       ot.yearday = 1;         /* this is the magic value used by caltontp() */
+       ot.hour = ot.minute = ot.second = 0;
+
+       ntp_time = Days( year ) - Days( year0 );  /* days into NTP time */
+       ntp_time *= 24 * 60 * 60;       /* convert into seconds */
+       ObservedNtp = caltontp( &ot );
+       if ( ntp_time != ObservedNtp )
+       {
+           Error(year);
+           fprintf( stdout, "%d: EXPECTED %lu: FOUND %lu (%ld)\n",
+                       (int)year,
+                       (unsigned long)ntp_time, (unsigned long)ObservedNtp ,
+                       (long)ntp_time - (long)ObservedNtp );
+
+           break;
+       }
+
+       /* now call caljulian as a type of failsafe supercheck */
+       caljulian( ObservedNtp, &ot );  /* convert January 1 */
+       if ( ot.year  != year
+         || ot.month != 1
+         || ot.monthday != 1 )
+       {
+           Error(year);
+           fprintf( stdout, "%lu: caljulian FAILSAFE EXPECTED %04d-01-01: FOUND %04d-%02d-%02d\n",
+                       (unsigned long)ObservedNtp,
+                       year, 
+                       (int)ot.year, (int)ot.month, (int)ot.monthday );
+           break;
+       }
+    }
+  }
+
+   if ( Warnings > 0 )
+       fprintf( stdout, "%d WARNINGS\n",  Warnings );
+   if ( Fatals > 0 )
+       fprintf( stdout, "%d FATAL ERRORS\n",  Fatals );
+   return Fatals ? 1 : 0;
+}
+                                                       /* Y2KFixes ] */
diff --git a/ntpd/cmd_args.c b/ntpd/cmd_args.c
new file mode 100644 (file)
index 0000000..7843bc3
--- /dev/null
@@ -0,0 +1,252 @@
+/*
+ * cmd_args.c = command-line argument processing
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_stdlib.h"
+#include "ntp_cmdargs.h"
+
+#ifdef SIM
+# include "ntpsim.h"
+# include "ntpdsim-opts.h"
+# define OPTSTRUCT     ntpdsimOptions
+#else
+# include "ntpd-opts.h"
+# define OPTSTRUCT     ntpdOptions
+#endif /* SIM */
+
+/*
+ * Definitions of things either imported from or exported to outside
+ */
+extern char const *progname;
+extern const char *specific_interface;
+extern short default_ai_family;
+
+#ifdef HAVE_NETINFO
+extern int     check_netinfo;
+#endif
+
+
+/*
+ * getCmdOpts - get command line options
+ */
+void
+getCmdOpts(
+       int argc,
+       char *argv[]
+       )
+{
+       extern const char *config_file;
+       int errflg;
+       tOptions *myOptions = &OPTSTRUCT;
+
+       /*
+        * Initialize, initialize
+        */
+       errflg = 0;
+
+       switch (WHICH_IDX_IPV4) {
+           case INDEX_OPT_IPV4:
+               default_ai_family = AF_INET;
+               break;
+           case INDEX_OPT_IPV6:
+               default_ai_family = AF_INET6;
+               break;
+           default:
+               /* ai_fam_templ = ai_fam_default;       */
+               break;
+       }
+
+       if (HAVE_OPT( AUTHREQ ))
+               proto_config(PROTO_AUTHENTICATE, 1, 0., NULL);
+
+       if (HAVE_OPT( AUTHNOREQ ))
+               proto_config(PROTO_AUTHENTICATE, 0, 0., NULL);
+
+       if (HAVE_OPT( BCASTSYNC ))
+               proto_config(PROTO_BROADCLIENT, 1, 0., NULL);
+
+       if (HAVE_OPT( CONFIGFILE )) {
+               config_file = OPT_ARG( CONFIGFILE );
+#ifdef HAVE_NETINFO
+               check_netinfo = 0;
+#endif
+       }
+
+       if (HAVE_OPT( DRIFTFILE ))
+               stats_config(STATS_FREQ_FILE, OPT_ARG( DRIFTFILE ));
+
+       if (HAVE_OPT( PANICGATE ))
+               allow_panic = TRUE;
+
+       if (HAVE_OPT( JAILDIR )) {
+#ifdef HAVE_DROPROOT
+                       droproot = 1;
+                       chrootdir = OPT_ARG( JAILDIR );
+#else
+                       fprintf(stderr, 
+                               "command line -i option (jaildir) is not supported by this binary"
+# ifndef SYS_WINNT
+                               ",\n" "can not drop root privileges.  See configure options\n"
+                               "--enable-clockctl and --enable-linuxcaps.\n");
+# else
+                               ".\n");
+# endif
+                       msyslog(LOG_ERR, 
+                               "command line -i option (jaildir) is not supported by this binary.");
+                       errflg++;
+#endif
+       }
+
+       if (HAVE_OPT( KEYFILE ))
+               getauthkeys(OPT_ARG( KEYFILE ));
+
+       if (HAVE_OPT( PIDFILE ))
+               stats_config(STATS_PID_FILE, OPT_ARG( PIDFILE ));
+
+       if (HAVE_OPT( QUIT ))
+               mode_ntpdate = TRUE;
+
+       if (HAVE_OPT( PROPAGATIONDELAY ))
+               do {
+                       double tmp;
+                       const char *my_ntp_optarg = OPT_ARG( PROPAGATIONDELAY );
+
+                       if (sscanf(my_ntp_optarg, "%lf", &tmp) != 1) {
+                               msyslog(LOG_ERR,
+                                       "command line broadcast delay value %s undecodable",
+                                       my_ntp_optarg);
+                       } else {
+                               proto_config(PROTO_BROADDELAY, 0, tmp, NULL);
+                       }
+               } while (0);
+
+       if (HAVE_OPT( STATSDIR ))
+               stats_config(STATS_STATSDIR, OPT_ARG( STATSDIR ));
+
+       if (HAVE_OPT( TRUSTEDKEY )) {
+               int             ct = STACKCT_OPT(  TRUSTEDKEY );
+               const char**    pp = STACKLST_OPT( TRUSTEDKEY );
+
+               do  {
+                       u_long tkey;
+                       const char* p = *pp++;
+
+                       tkey = (int)atol(p);
+                       if (tkey == 0 || tkey > NTP_MAXKEY) {
+                               msyslog(LOG_ERR,
+                                   "command line trusted key %s is invalid",
+                                   p);
+                       } else {
+                               authtrust(tkey, 1);
+                       }
+               } while (--ct > 0);
+       }
+
+       if (HAVE_OPT( USER )) {
+#ifdef HAVE_DROPROOT
+               char *ntp_optarg = OPT_ARG( USER );
+
+               droproot = 1;
+               user = emalloc(strlen(ntp_optarg) + 1);
+               (void)strncpy(user, ntp_optarg, strlen(ntp_optarg) + 1);
+               group = rindex(user, ':');
+               if (group)
+                       *group++ = '\0'; /* get rid of the ':' */
+#else
+               fprintf(stderr, 
+                       "command line -u/--user option is not supported by this binary"
+# ifndef SYS_WINNT
+                       ",\n" "can not drop root privileges.  See configure options\n"
+                       "--enable-clockctl and --enable-linuxcaps.\n");
+# else
+                       ".\n");
+# endif
+               msyslog(LOG_ERR, 
+                       "command line -u/--user option is not supported by this binary.");
+               errflg++;
+#endif
+       }
+
+       if (HAVE_OPT( VAR )) {
+               int             ct = STACKCT_OPT(  VAR );
+               const char**    pp = STACKLST_OPT( VAR );
+
+               do  {
+                       const char* my_ntp_optarg = *pp++;
+
+                       set_sys_var(my_ntp_optarg, strlen(my_ntp_optarg)+1,
+                           (u_short) (RW));
+               } while (--ct > 0);
+       }
+
+       if (HAVE_OPT( DVAR )) {
+               int             ct = STACKCT_OPT(  DVAR );
+               const char**    pp = STACKLST_OPT( DVAR );
+
+               do  {
+                       const char* my_ntp_optarg = *pp++;
+
+                       set_sys_var(my_ntp_optarg, strlen(my_ntp_optarg)+1,
+                           (u_short) (RW | DEF));
+               } while (--ct > 0);
+       }
+
+       if (HAVE_OPT( SLEW ))
+               clock_max = 600;
+
+       if (HAVE_OPT( UPDATEINTERVAL )) {
+               long val = OPT_VALUE_UPDATEINTERVAL;
+                         
+               if (val >= 0)
+                       interface_interval = val;
+               else {
+                       fprintf(stderr, 
+                               "command line interface update interval %ld must not be negative\n",
+                               val);
+                       msyslog(LOG_ERR, 
+                               "command line interface update interval %ld must not be negative",
+                               val);
+                       errflg++;
+               }
+       }
+#ifdef SIM
+       if (HAVE_OPT( SIMBROADCASTDELAY ))
+               sscanf(OPT_ARG( SIMBROADCASTDELAY ), "%lf", &ntp_node.bdly);
+
+       if (HAVE_OPT( PHASENOISE ))
+               sscanf(OPT_ARG( PHASENOISE ), "%lf", &ntp_node.snse);
+
+       if (HAVE_OPT( SIMSLEW ))
+               sscanf(OPT_ARG( SIMSLEW ), "%lf", &ntp_node.slew);
+
+       if (HAVE_OPT( SERVERTIME ))
+               sscanf(OPT_ARG( SERVERTIME ), "%lf", &ntp_node.clk_time);
+
+       if (HAVE_OPT( ENDSIMTIME ))
+               sscanf(OPT_ARG( ENDSIMTIME ), "%lf", &ntp_node.sim_time);
+
+       if (HAVE_OPT( FREQERR ))
+               sscanf(OPT_ARG( FREQERR ), "%lf", &ntp_node.ferr);
+
+       if (HAVE_OPT( WALKNOISE ))
+               sscanf(OPT_ARG( WALKNOISE ), "%lf", &ntp_node.fnse);
+
+       if (HAVE_OPT( NDELAY ))
+               sscanf(OPT_ARG( NDELAY ), "%lf", &ntp_node.ndly);
+
+       if (HAVE_OPT( PDELAY ))
+               sscanf(OPT_ARG( PDELAY ), "%lf", &ntp_node.pdly);
+
+#endif /* SIM */
+
+       if (errflg || argc) {
+               if (argc)
+                       fprintf(stderr, "argc after processing is <%d>\n", argc);
+               optionUsage(myOptions, 2);
+       }
+       return;
+}
diff --git a/ntpd/jupiter.h b/ntpd/jupiter.h
new file mode 100644 (file)
index 0000000..ed80b0c
--- /dev/null
@@ -0,0 +1,255 @@
+/* @(#) $Header$ (LBL) */
+
+/*
+ * Rockwell Jupiter GPS receiver definitions
+ *
+ * This is all based on the "Zodiac GPS Receiver Family Designer's
+ * Guide" (dated 12/96)
+ */
+
+#define JUPITER_SYNC           0x81ff  /* sync word (book says 0xff81 !?!?) */
+#define JUPITER_ALL            0xffff  /* disable all output messages */
+
+/* Output messages (sent by the Jupiter board) */
+#define JUPITER_O_GPOS         1000    /* geodetic position status */
+#define JUPITER_O_EPOS         1001    /* ECEF position status */
+#define JUPITER_O_CHAN         1002    /* channel summary */
+#define JUPITER_O_VIS          1003    /* visible satellites */
+#define JUPITER_O_DGPS         1005    /* differential GPS status */
+#define JUPITER_O_MEAS         1007    /* channel measurement */
+#define JUPITER_O_ID           1011    /* receiver id */
+#define JUPITER_O_USER         1012    /* user-settings output */
+#define JUPITER_O_TEST         1100    /* built-in test results */
+#define JUPITER_O_MARK         1102    /* measurement time mark */
+#define JUPITER_O_PULSE                1108    /* UTC time mark pulse output */
+#define JUPITER_O_PORT         1130    /* serial port com parameters in use */
+#define JUPITER_O_EUP          1135    /* EEPROM update */
+#define JUPITER_O_ESTAT                1136    /* EEPROM status */
+
+/* Input messages (sent to the Jupiter board) */
+#define JUPITER_I_PVTINIT      1200    /* geodetic position and velocity */
+#define JUPITER_I_USER         1210    /* user-defined datum */
+#define JUPITER_I_MAPSEL       1211    /* map datum select */
+#define JUPITER_I_ELEV         1212    /* satellite elevation mask control */
+#define JUPITER_I_CAND         1213    /* satellite candidate select */
+#define JUPITER_I_DGPS         1214    /* differential GPS control */
+#define JUPITER_I_COLD         1216    /* cold start control */
+#define JUPITER_I_VALID                1217    /* solution validity criteria */
+#define JUPITER_I_ALT          1219    /* user-entered altitude input */
+#define JUPITER_I_PLAT         1220    /* application platform control */
+#define JUPITER_I_NAV          1221    /* nav configuration */
+#define JUPITER_I_TEST         1300    /* preform built-in test command */
+#define JUPITER_I_RESTART      1303    /* restart command */
+#define JUPITER_I_PORT         1330    /* serial port com parameters */
+#define JUPITER_I_PROTO                1331    /* message protocol control */
+#define JUPITER_I_RDGPS                1351    /* raw DGPS RTCM SC-104 data */
+
+struct jheader {
+       u_short sync;           /* (JUPITER_SYNC) */
+       u_short id;             /* message id */
+       u_short len;            /* number of data short wordss (w/o cksum) */
+       u_char reqid;           /* JUPITER_REQID_MASK bits available as id */
+       u_char flags;           /* flags */
+       u_short hsum;           /* header cksum */
+};
+
+#define JUPITER_REQID_MASK     0x3f    /* bits available as id */
+#define JUPITER_FLAG_NAK       0x01    /* negative acknowledgement */
+#define JUPITER_FLAG_ACK       0x02    /* acknowledgement */
+#define JUPITER_FLAG_REQUEST   0x04    /* request ACK or NAK */
+#define JUPITER_FLAG_QUERY     0x08    /* request one shot output message */
+#define JUPITER_FLAG_LOG       0x20    /* request periodic output message */
+#define JUPITER_FLAG_CONN      0x40    /* enable periodic message */
+#define JUPITER_FLAG_DISC      0x80    /* disable periodic message */
+
+#define JUPITER_H_FLAG_BITS \
+    "\020\1NAK\2ACK\3REQUEST\4QUERY\5MBZ\6LOG\7CONN\10DISC"
+
+/* Log request messages (data payload when using JUPITER_FLAG_LOG) */
+struct jrequest {
+       u_short trigger;                /* if 0, trigger on time trigger on
+                                          update (e.g. new almanac) */
+       u_short interval;               /* frequency in seconds */
+       u_short offset;                 /* offset into minute */
+       u_short dsum;                   /* checksum */
+};
+
+/* JUPITER_O_GPOS (1000) */
+struct jgpos {
+       u_short stime[2];               /* set time (10 ms ticks) */
+       u_short seq;                    /* sequence number */
+       u_short sseq;                   /* sat measurement sequence number */
+       u_short navval;                 /* navigation soltuion validity */
+       u_short navtype;                /* navigation solution type */
+       u_short nmeas;                  /* # of measurements used in solution */
+       u_short polar;                  /* if 1 then polar navigation */
+       u_short gweek;                  /* GPS week number */
+       u_short sweek[2];               /* GPS seconds into week */
+       u_short nsweek[2];              /* GPS nanoseconds into second */
+       u_short utcday;                 /* 1 to 31 */
+       u_short utcmon;                 /* 1 to 12 */
+       u_short utcyear;                /* 1980 to 2079 */
+       u_short utchour;                /* 0 to 23 */
+       u_short utcmin;                 /* 0 to 59 */
+       u_short utcsec;                 /* 0 to 59 */
+       u_short utcnsec[2];             /* 0 to 999999999 */
+       u_short lat[2];                 /* latitude (radians) */
+       u_short lon[2];                 /* longitude (radians) */
+       u_short height[2];              /* height (meters) */
+       u_short gsep;                   /* geoidal separation */
+       u_short speed[2];               /* ground speed (meters/sec) */
+       u_short course;                 /* true course (radians) */
+       u_short mvar;
+       u_short climb;
+       u_short mapd;
+       u_short herr[2];
+       u_short verr[2];
+       u_short terr[2];
+       u_short hverr;
+       u_short bias[2];
+       u_short biassd[2];
+       u_short drift[2];
+       u_short driftsd[2];
+       u_short dsum;                   /* checksum */
+};
+#define JUPITER_O_GPOS_NAV_NOALT       0x01    /* altitude used */
+#define JUPITER_O_GPOS_NAV_NODGPS      0x02    /* no differential GPS */
+#define JUPITER_O_GPOS_NAV_NOSAT       0x04    /* not enough satellites */
+#define JUPITER_O_GPOS_NAV_MAXH                0x08    /* exceeded max EHPE */
+#define JUPITER_O_GPOS_NAV_MAXV                0x10    /* exceeded max EVPE */
+
+/* JUPITER_O_CHAN (1002) */
+struct jchan {
+       u_short stime[2];               /* set time (10 ms ticks) */
+       u_short seq;                    /* sequence number */
+       u_short sseq;                   /* sat measurement sequence number */
+       u_short gweek;                  /* GPS week number */
+       u_short sweek[2];               /* GPS seconds into week */
+       u_short gpsns[2];               /* GPS nanoseconds from epoch */
+       struct jchan2 {
+               u_short flags;          /* flags */
+               u_short prn;            /* satellite PRN */
+               u_short chan;           /* channel number */
+       } sat[12];
+       u_short dsum;
+};
+
+/* JUPITER_O_VIS (1003) */
+struct jvis {
+       u_short stime[2];               /* set time (10 ms ticks) */
+       u_short seq;                    /* sequence number */
+       u_short gdop;                   /* best possible GDOP */
+       u_short pdop;                   /* best possible PDOP */
+       u_short hdop;                   /* best possible HDOP */
+       u_short vdop;                   /* best possible VDOP */
+       u_short tdop;                   /* best possible TDOP */
+       u_short nvis;                   /* number of visible satellites */
+       struct jvis2 {
+               u_short prn;            /* satellite PRN */
+               u_short azi;            /* satellite azimuth (radians) */
+               u_short elev;           /* satellite elevation (radians) */
+       } sat[12];
+       u_short dsum;                   /* checksum */
+};
+
+/* JUPITER_O_ID (1011) */
+struct jid {
+       u_short stime[2];               /* set time (10 ms ticks) */
+       u_short seq;                    /* sequence number */
+       char chans[20];                 /* number of channels (ascii) */
+       char vers[20];                  /* software version (ascii) */
+       char date[20];                  /* software date (ascii) */
+       char opts[20];                  /* software options (ascii) */
+       char reserved[20];
+       u_short dsum;                   /* checksum */
+};
+
+/* JUPITER_O_USER (1012) */
+struct juser {
+       u_short stime[2];               /* set time (10 ms ticks) */
+       u_short seq;                    /* sequence number */
+       u_short status;                 /* operatinoal status */
+       u_short coldtmo;                /* cold start time-out */
+       u_short dgpstmo;                /* DGPS correction time-out*/
+       u_short emask;                  /* elevation mask */
+       u_short selcand[2];             /* selected candidate */
+       u_short solflags;               /* solution validity criteria */
+       u_short nsat;                   /* number of satellites in track */
+       u_short herr[2];                /* minimum expected horizontal error */
+       u_short verr[2];                /* minimum expected vertical error */
+       u_short platform;               /* application platform */
+       u_short dsum;                   /* checksum */
+};
+
+/* JUPITER_O_PULSE (1108) */
+struct jpulse {
+       u_short stime[2];               /* set time (10 ms ticks) */
+       u_short seq;                    /* sequence number */
+       u_short reserved[5];
+       u_short sweek[2];               /* GPS seconds into week */
+       short offs;                     /* GPS to UTC time offset (seconds) */
+       u_short offns[2];               /* GPS to UTC offset (nanoseconds) */
+       u_short flags;                  /* flags */
+       u_short dsum;                   /* checksum */
+};
+#define JUPITER_O_PULSE_VALID          0x1     /* time mark validity */
+#define JUPITER_O_PULSE_UTC            0x2     /* GPS/UTC sync */
+
+/* JUPITER_O_EUP (1135) */
+struct jeup {
+       u_short stime[2];               /* set time (10 ms ticks) */
+       u_short seq;                    /* sequence number */
+       u_char dataid;                  /* data id */
+       u_char prn;                     /* satellite PRN */
+       u_short dsum;                   /* checksum */
+};
+
+/* JUPITER_I_RESTART (1303) */
+struct jrestart {
+       u_short seq;                    /* sequence number */
+       u_short flags;
+       u_short dsum;                   /* checksum */
+};
+#define JUPITER_I_RESTART_INVRAM       0x01
+#define JUPITER_I_RESTART_INVEEPROM    0x02
+#define JUPITER_I_RESTART_INVRTC       0x04
+#define JUPITER_I_RESTART_COLD         0x80
+
+/* JUPITER_I_PVTINIT (1200) */
+struct jpvtinit {
+       u_short flags;
+       u_short gweek;                  /* GPS week number */
+       u_short sweek[2];               /* GPS seconds into week */
+       u_short utcday;                 /* 1 to 31 */
+       u_short utcmon;                 /* 1 to 12 */
+       u_short utcyear;                /* 1980 to 2079 */
+       u_short utchour;                /* 0 to 23 */
+       u_short utcmin;                 /* 0 to 59 */
+       u_short utcsec;                 /* 0 to 59 */
+       u_short lat[2];                 /* latitude (radians) */
+       u_short lon[2];                 /* longitude (radians) */
+       u_short height[2];              /* height (meters) */
+       u_short speed[2];               /* ground speed (meters/sec) */
+       u_short course;                 /* true course (radians) */
+       u_short climb;
+       u_short dsum;
+};
+#define JUPITER_I_PVTINIT_FORCE                0x01
+#define JUPITER_I_PVTINIT_GPSVAL       0x02
+#define JUPITER_I_PVTINIT_UTCVAL       0x04
+#define JUPITER_I_PVTINIT_POSVAL       0x08
+#define JUPITER_I_PVTINIT_ALTVAL       0x10
+#define JUPITER_I_PVTINIT_SPDVAL       0x12
+#define JUPITER_I_PVTINIT_MAGVAL       0x14
+#define JUPITER_I_PVTINIT_CLIMBVAL     0x18
+
+/* JUPITER_I_PLAT (1220) */
+struct jplat {
+       u_short seq;                    /* sequence number */
+       u_short platform;               /* application platform */
+       u_short dsum;
+};
+#define JUPITER_I_PLAT_DEFAULT         0       /* default dynamics */
+#define JUPITER_I_PLAT_LOW             2       /* pedestrian */
+#define JUPITER_I_PLAT_MED             5       /* land (e.g. automobile) */
+#define JUPITER_I_PLAT_HIGH            6       /* air */
diff --git a/ntpd/ntp_config.c b/ntpd/ntp_config.c
new file mode 100644 (file)
index 0000000..beb4c48
--- /dev/null
@@ -0,0 +1,2579 @@
+/*
+ * ntp_config.c - read and apply configuration information
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_NETINFO
+# include <netinfo/ni.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_unixtime.h"
+#include "ntp_refclock.h"
+#include "ntp_filegen.h"
+#include "ntp_stdlib.h"
+#include <ntp_random.h>
+#include <isc/net.h>
+#include <isc/result.h>
+
+#include <stdio.h>
+#include <ctype.h>
+#ifdef HAVE_SYS_PARAM_H
+#include <sys/param.h>
+#endif
+#include <signal.h>
+#ifndef SIGCHLD
+# define SIGCHLD SIGCLD
+#endif
+#if !defined(VMS)
+# ifdef HAVE_SYS_WAIT_H
+#  include <sys/wait.h>
+# endif
+#endif /* VMS */
+
+#ifdef SYS_WINNT
+# include <io.h>
+static HANDLE ResolverThreadHandle = NULL;
+HANDLE ResolverEventHandle;
+#else
+int resolver_pipe_fd[2];  /* used to let the resolver process alert the parent process */
+#endif /* SYS_WINNT */
+
+/*
+ * [Bug 467]: Some linux headers collide with CONFIG_PHONE and CONFIG_KEYS
+ * so #include these later.
+ */
+
+#include "ntp_config.h"
+#include "ntp_cmdargs.h"
+
+extern int priority_done;
+
+/*
+ * These routines are used to read the configuration file at
+ * startup time.  An entry in the file must fit on a single line.
+ * Entries are processed as multiple tokens separated by white space
+ * Lines are considered terminated when a '#' is encountered.  Blank
+ * lines are ignored.
+ */
+/*
+ * Translation table - keywords to function index
+ */
+struct keyword {
+       const char *text;
+       int keytype;
+};
+
+/*
+ * Command keywords
+ */
+static struct keyword keywords[] = {
+       { "automax",            CONFIG_AUTOMAX },
+       { "broadcast",          CONFIG_BROADCAST },
+       { "broadcastclient",    CONFIG_BROADCASTCLIENT },
+       { "broadcastdelay",     CONFIG_BDELAY },
+       { "calldelay",          CONFIG_CDELAY},
+#ifdef OPENSSL
+       { "crypto",             CONFIG_CRYPTO },
+#endif /* OPENSSL */
+       { "controlkey",         CONFIG_CONTROLKEY },
+       { "disable",            CONFIG_DISABLE },
+       { "driftfile",          CONFIG_DRIFTFILE },
+       { "enable",             CONFIG_ENABLE },
+       { "end",                CONFIG_END },
+       { "filegen",            CONFIG_FILEGEN },
+       { "fudge",              CONFIG_FUDGE },
+       { "includefile",        CONFIG_INCLUDEFILE },
+       { "keys",               CONFIG_KEYS },
+       { "keysdir",            CONFIG_KEYSDIR },
+       { "logconfig",          CONFIG_LOGCONFIG },
+       { "logfile",            CONFIG_LOGFILE },
+       { "manycastclient",     CONFIG_MANYCASTCLIENT },
+       { "manycastserver",     CONFIG_MANYCASTSERVER },
+       { "multicastclient",    CONFIG_MULTICASTCLIENT },
+       { "peer",               CONFIG_PEER },
+       { "phone",              CONFIG_PHONE },
+       { "pidfile",            CONFIG_PIDFILE },
+       { "discard",            CONFIG_DISCARD },
+       { "requestkey",         CONFIG_REQUESTKEY },
+       { "restrict",           CONFIG_RESTRICT },
+       { "revoke",             CONFIG_REVOKE },
+       { "server",             CONFIG_SERVER },
+       { "setvar",             CONFIG_SETVAR },
+       { "statistics",         CONFIG_STATISTICS },
+       { "statsdir",           CONFIG_STATSDIR },
+       { "tick",               CONFIG_ADJ },
+       { "tinker",             CONFIG_TINKER },
+       { "tos",                CONFIG_TOS },
+       { "trap",               CONFIG_TRAP },
+       { "trustedkey",         CONFIG_TRUSTEDKEY },
+       { "ttl",                CONFIG_TTL },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+/*
+ * "peer", "server", "broadcast" modifier keywords
+ */
+static struct keyword mod_keywords[] = {
+       { "autokey",            CONF_MOD_SKEY },
+       { "burst",              CONF_MOD_BURST },
+       { "iburst",             CONF_MOD_IBURST },
+       { "key",                CONF_MOD_KEY },
+       { "maxpoll",            CONF_MOD_MAXPOLL },
+       { "minpoll",            CONF_MOD_MINPOLL },
+       { "mode",               CONF_MOD_MODE },    /* refclocks */
+       { "noselect",           CONF_MOD_NOSELECT },
+       { "preempt",            CONF_MOD_PREEMPT },
+       { "true",               CONF_MOD_TRUE },
+       { "prefer",             CONF_MOD_PREFER },
+       { "ttl",                CONF_MOD_TTL },     /* NTP peers */
+       { "version",            CONF_MOD_VERSION },
+       { "dynamic",            CONF_MOD_DYNAMIC },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+/*
+ * "restrict" modifier keywords
+ */
+static struct keyword res_keywords[] = {
+       { "ignore",             CONF_RES_IGNORE },
+       { "limited",            CONF_RES_LIMITED },
+       { "kod",                CONF_RES_DEMOBILIZE },
+       { "lowpriotrap",        CONF_RES_LPTRAP },
+       { "mask",               CONF_RES_MASK },
+       { "nomodify",           CONF_RES_NOMODIFY },
+       { "nopeer",             CONF_RES_NOPEER },
+       { "noquery",            CONF_RES_NOQUERY },
+       { "noserve",            CONF_RES_NOSERVE },
+       { "notrap",             CONF_RES_NOTRAP },
+       { "notrust",            CONF_RES_NOTRUST },
+       { "ntpport",            CONF_RES_NTPPORT },
+       { "version",            CONF_RES_VERSION },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+/*
+ * "trap" modifier keywords
+ */
+static struct keyword trap_keywords[] = {
+       { "port",               CONF_TRAP_PORT },
+       { "interface",          CONF_TRAP_INTERFACE },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+/*
+ * "fudge" modifier keywords
+ */
+static struct keyword fudge_keywords[] = {
+       { "flag1",              CONF_FDG_FLAG1 },
+       { "flag2",              CONF_FDG_FLAG2 },
+       { "flag3",              CONF_FDG_FLAG3 },
+       { "flag4",              CONF_FDG_FLAG4 },
+       { "refid",              CONF_FDG_REFID }, /* this mapping should be cleaned up (endianness, \0) - kd 20041031 */
+       { "stratum",            CONF_FDG_STRATUM },
+       { "time1",              CONF_FDG_TIME1 },
+       { "time2",              CONF_FDG_TIME2 },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+/*
+ * "filegen" modifier keywords
+ */
+static struct keyword filegen_keywords[] = {
+       { "disable",            CONF_FGEN_FLAG_DISABLE },
+       { "enable",             CONF_FGEN_FLAG_ENABLE },
+       { "file",               CONF_FGEN_FILE },
+       { "link",               CONF_FGEN_FLAG_LINK },
+       { "nolink",             CONF_FGEN_FLAG_NOLINK },
+       { "type",               CONF_FGEN_TYPE },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+/*
+ * "type" modifier keywords
+ */
+static struct keyword fgen_types[] = {
+       { "age",                FILEGEN_AGE   },
+       { "day",                FILEGEN_DAY   },
+       { "month",              FILEGEN_MONTH },
+       { "none",               FILEGEN_NONE  },
+       { "pid",                FILEGEN_PID   },
+       { "week",               FILEGEN_WEEK  },
+       { "year",               FILEGEN_YEAR  },
+       { "",                   CONFIG_UNKNOWN}
+};
+
+/*
+ * "enable", "disable" modifier keywords
+ */
+static struct keyword flags_keywords[] = {
+       { "auth",               PROTO_AUTHENTICATE },
+       { "bclient",            PROTO_BROADCLIENT },
+       { "calibrate",          PROTO_CAL },
+       { "kernel",             PROTO_KERNEL },
+       { "monitor",            PROTO_MONITOR },
+       { "ntp",                PROTO_NTP },
+       { "stats",              PROTO_FILEGEN },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+/*
+ * "discard" modifier keywords
+ */
+static struct keyword discard_keywords[] = {
+       { "average",            CONF_DISCARD_AVERAGE },
+       { "minimum",            CONF_DISCARD_MINIMUM },
+       { "monitor",            CONF_DISCARD_MONITOR },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+/*
+ * "tinker" modifier keywords
+ */
+static struct keyword tinker_keywords[] = {
+       { "step",               CONF_CLOCK_MAX },
+       { "panic",              CONF_CLOCK_PANIC },
+       { "dispersion",         CONF_CLOCK_PHI },
+       { "stepout",            CONF_CLOCK_MINSTEP },
+       { "allan",              CONF_CLOCK_ALLAN },
+       { "huffpuff",           CONF_CLOCK_HUFFPUFF },
+       { "freq",               CONF_CLOCK_FREQ },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+/*
+ * "tos" modifier keywords
+ */
+static struct keyword tos_keywords[] = {
+       { "minclock",           CONF_TOS_MINCLOCK },
+       { "maxclock",           CONF_TOS_MAXCLOCK },
+       { "minsane",            CONF_TOS_MINSANE },
+       { "floor",              CONF_TOS_FLOOR },
+       { "ceiling",            CONF_TOS_CEILING },
+       { "cohort",             CONF_TOS_COHORT },
+       { "mindist",            CONF_TOS_MINDISP },
+       { "maxdist",            CONF_TOS_MAXDIST },
+       { "maxhop",             CONF_TOS_MAXHOP },
+       { "beacon",             CONF_TOS_BEACON },
+       { "orphan",             CONF_TOS_ORPHAN },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+#ifdef OPENSSL
+/*
+ * "crypto" modifier keywords
+ */
+static struct keyword crypto_keywords[] = {
+       { "cert",               CONF_CRYPTO_CERT },
+       { "gqpar",              CONF_CRYPTO_GQPAR },
+       { "host",               CONF_CRYPTO_RSA },
+       { "ident",              CONF_CRYPTO_IDENT },
+       { "iffpar",             CONF_CRYPTO_IFFPAR },
+       { "leap",               CONF_CRYPTO_LEAP },
+       { "mvpar",              CONF_CRYPTO_MVPAR },
+       { "pw",                 CONF_CRYPTO_PW },
+       { "randfile",           CONF_CRYPTO_RAND },
+       { "sign",               CONF_CRYPTO_SIGN },
+       { "",                   CONFIG_UNKNOWN }
+};
+#endif /* OPENSSL */
+
+/*
+ * Address type selection, IPv4 or IPv4.
+ * Used on various lines.
+ */
+static struct keyword addr_type[] = {
+       { "-4",                 CONF_ADDR_IPV4 },
+       { "-6",                 CONF_ADDR_IPV6 },
+       { "",                   CONFIG_UNKNOWN }
+};
+
+/*
+ * "logconfig" building blocks
+ */
+struct masks {
+       const char        *name;
+       unsigned long mask;
+};
+
+static struct masks logcfg_class[] = {
+       { "clock",              NLOG_OCLOCK },
+       { "peer",               NLOG_OPEER },
+       { "sync",               NLOG_OSYNC },
+       { "sys",                NLOG_OSYS },
+       { (char *)0,    0 }
+};
+
+static struct masks logcfg_item[] = {
+       { "info",               NLOG_INFO },
+       { "allinfo",            NLOG_SYSINFO|NLOG_PEERINFO|NLOG_CLOCKINFO|NLOG_SYNCINFO },
+       { "events",             NLOG_EVENT },
+       { "allevents",          NLOG_SYSEVENT|NLOG_PEEREVENT|NLOG_CLOCKEVENT|NLOG_SYNCEVENT },
+       { "status",             NLOG_STATUS },
+       { "allstatus",          NLOG_SYSSTATUS|NLOG_PEERSTATUS|NLOG_CLOCKSTATUS|NLOG_SYNCSTATUS },
+       { "statistics",         NLOG_STATIST },
+       { "allstatistics",      NLOG_SYSSTATIST|NLOG_PEERSTATIST|NLOG_CLOCKSTATIST|NLOG_SYNCSTATIST },
+       { "allclock",           (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OCLOCK },
+       { "allpeer",            (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OPEER },
+       { "allsys",             (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OSYS },
+       { "allsync",            (NLOG_INFO|NLOG_STATIST|NLOG_EVENT|NLOG_STATUS)<<NLOG_OSYNC },
+       { "all",                NLOG_SYSMASK|NLOG_PEERMASK|NLOG_CLOCKMASK|NLOG_SYNCMASK },
+       { (char *)0,    0 }
+};
+
+/*
+ * Limits on things
+ */
+#define MAXTOKENS      20      /* 20 tokens on line */
+#define MAXLINE                1024    /* maximum length of line */
+#define MAXPHONE       10      /* maximum number of phone strings */
+#define MAXPPS         20      /* maximum length of PPS device string */
+#define MAXINCLUDELEVEL        5       /* maximum include file levels */
+
+/*
+ * Miscellaneous macros
+ */
+#define STRSAME(s1, s2)        (*(s1) == *(s2) && strcmp((s1), (s2)) == 0)
+#define ISEOL(c)       ((c) == '#' || (c) == '\n' || (c) == '\0')
+#define ISSPACE(c)     ((c) == ' ' || (c) == '\t')
+#define STREQ(a, b)    (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+#define KEY_TYPE_MD5   4
+
+/*
+ * File descriptor used by the resolver save routines, and temporary file
+ * name.
+ */
+int call_resolver = 1;         /* ntp-genkeys sets this to 0, for example */
+static FILE *res_fp;
+#ifndef SYS_WINNT
+static char res_file[20];      /* enough for /tmp/ntpXXXXXX\0 */
+#define RES_TEMPFILE   "/tmp/ntpXXXXXX"
+#else
+static char res_file[MAX_PATH];
+#endif /* SYS_WINNT */
+
+/*
+ * Definitions of things either imported from or exported to outside
+ */
+
+short default_ai_family = AF_UNSPEC;   /* Default either IPv4 or IPv6 */
+char   *sys_phone[MAXPHONE] = {NULL}; /* ACTS phone numbers */
+char   *keysdir = NTP_KEYSDIR; /* crypto keys directory */
+#if defined(HAVE_SCHED_SETSCHEDULER)
+int    config_priority_override = 0;
+int    config_priority;
+#endif
+
+const char *config_file;
+#ifdef HAVE_NETINFO
+ struct netinfo_config_state *config_netinfo = NULL;
+ int check_netinfo = 1;
+#endif /* HAVE_NETINFO */
+#ifdef SYS_WINNT
+ char *alt_config_file;
+ LPTSTR temp;
+ char config_file_storage[MAX_PATH];
+ char alt_config_file_storage[MAX_PATH];
+#endif /* SYS_WINNT */
+
+#ifdef HAVE_NETINFO
+/*
+ * NetInfo configuration state
+ */
+struct netinfo_config_state {
+       void *domain;           /* domain with config */
+       ni_id config_dir;       /* ID config dir      */
+       int prop_index;         /* current property   */
+       int val_index;          /* current value      */
+       char **val_list;        /* value list         */
+};
+#endif
+
+/*
+ * Function prototypes
+ */
+static unsigned long get_pfxmatch P((char **, struct masks *));
+static unsigned long get_match P((char *, struct masks *));
+static unsigned long get_logmask P((char *));
+#ifdef HAVE_NETINFO
+static struct netinfo_config_state *get_netinfo_config P((void));
+static void free_netinfo_config P((struct netinfo_config_state *));
+static int gettokens_netinfo P((struct netinfo_config_state *, char **, int *));
+#endif
+static int gettokens P((FILE *, char *, char **, int *));
+static int matchkey P((char *, struct keyword *, int));
+enum gnn_type {
+       t_UNK,          /* Unknown */
+       t_REF,          /* Refclock */
+       t_MSK           /* Network Mask */
+       };
+static int getnetnum P((const char *, struct sockaddr_storage *, int,
+                        enum gnn_type));
+static void save_resolve P((char *, int, int, int, int, u_int, int,
+    keyid_t, u_char *));
+static void do_resolve_internal P((void));
+static void abort_resolve P((void));
+#if !defined(VMS) && !defined(SYS_WINNT)
+static RETSIGTYPE catchchild P((int));
+#endif /* VMS */
+
+/*
+ * get_pfxmatch - find value for prefixmatch
+ * and update char * accordingly
+ */
+static unsigned long
+get_pfxmatch(
+       char ** s,
+       struct masks *m
+       )
+{
+       while (m->name) {
+               if (strncmp(*s, m->name, strlen(m->name)) == 0) {
+                       *s += strlen(m->name);
+                       return m->mask;
+               } else {
+                       m++;
+               }
+       }
+       return 0;
+}
+
+/*
+ * get_match - find logmask value
+ */
+static unsigned long
+get_match(
+       char *s,
+       struct masks *m
+       )
+{
+       while (m->name) {
+               if (strcmp(s, m->name) == 0) {
+                       return m->mask;
+               } else {
+                       m++;
+               }
+       }
+       return 0;
+}
+
+/*
+ * get_logmask - build bitmask for ntp_syslogmask
+ */
+static unsigned long
+get_logmask(
+       char *s
+       )
+{
+       char *t;
+       unsigned long offset;
+       unsigned long mask;
+
+       t = s;
+       offset = get_pfxmatch(&t, logcfg_class);
+       mask   = get_match(t, logcfg_item);
+
+       if (mask)
+               return mask << offset;
+       else
+               msyslog(LOG_ERR, "logconfig: illegal argument %s - ignored", s);
+
+       return 0;
+}
+
+
+/*
+ * getconfig - get command line options and read the configuration file
+ */
+void
+getconfig(
+       int argc,
+       char *argv[]
+       )
+{
+       register int i;
+       int c;
+       int errflg;
+       int status;
+       int istart;
+       int peerversion;
+       int minpoll;
+       int maxpoll;
+       int ttl;
+       long stratum;
+       unsigned long ul;
+       keyid_t peerkey;
+       u_char *peerkeystr;
+       u_long fudgeflag;
+       u_int peerflags;
+       int hmode;
+       struct sockaddr_storage peeraddr;
+       struct sockaddr_storage maskaddr;
+       FILE *fp[MAXINCLUDELEVEL+1];
+       FILE *includefile;
+       int includelevel = 0;
+       char line[MAXLINE];
+       char *(tokens[MAXTOKENS]);
+       int ntokens = 0;
+       int tok = CONFIG_UNKNOWN;
+       struct interface *localaddr;
+       struct refclockstat clock_stat;
+       FILEGEN *filegen;
+
+       /*
+        * Initialize, initialize
+        */
+       errflg = 0;
+       
+#ifndef SYS_WINNT
+       config_file = CONFIG_FILE;
+#else
+       temp = CONFIG_FILE;
+       if (!ExpandEnvironmentStrings((LPCTSTR)temp, (LPTSTR)config_file_storage, (DWORD)sizeof(config_file_storage))) {
+               msyslog(LOG_ERR, "ExpandEnvironmentStrings CONFIG_FILE failed: %m\n");
+               exit(1);
+       }
+       config_file = config_file_storage;
+
+       temp = ALT_CONFIG_FILE;
+       if (!ExpandEnvironmentStrings((LPCTSTR)temp, (LPTSTR)alt_config_file_storage, (DWORD)sizeof(alt_config_file_storage))) {
+               msyslog(LOG_ERR, "ExpandEnvironmentStrings ALT_CONFIG_FILE failed: %m\n");
+               exit(1);
+       }
+       alt_config_file = alt_config_file_storage;
+
+#endif /* SYS_WINNT */
+       res_fp = NULL;
+       ntp_syslogmask = NLOG_SYNCMASK; /* set more via logconfig */
+
+       /*
+        * install a non default variable with this daemon version
+        */
+       (void) sprintf(line, "daemon_version=\"%s\"", Version);
+       set_sys_var(line, strlen(line)+1, RO);
+
+       /*
+        * Say how we're setting the time of day
+        */
+       (void) sprintf(line, "settimeofday=\"%s\"", set_tod_using);
+       set_sys_var(line, strlen(line)+1, RO);
+
+       /*
+        * Initialize the loop.
+        */
+       loop_config(LOOP_DRIFTINIT, 0.);
+
+       getCmdOpts(argc, argv);
+
+       if (
+           (fp[0] = fopen(FindConfig(config_file), "r")) == NULL
+#ifdef HAVE_NETINFO
+           /* If there is no config_file, try NetInfo. */
+           && check_netinfo && !(config_netinfo = get_netinfo_config())
+#endif /* HAVE_NETINFO */
+           ) {
+               fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig(config_file));
+               msyslog(LOG_INFO, "getconfig: Couldn't open <%s>", FindConfig(config_file));
+#ifdef SYS_WINNT
+               /* Under WinNT try alternate_config_file name, first NTP.CONF, then NTP.INI */
+
+               if ((fp[0] = fopen(FindConfig(alt_config_file), "r")) == NULL) {
+
+                       /*
+                        * Broadcast clients can sometimes run without
+                        * a configuration file.
+                        */
+
+                       fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig(alt_config_file));
+                       msyslog(LOG_INFO, "getconfig: Couldn't open <%s>", FindConfig(alt_config_file));
+                       return;
+               }
+#else  /* not SYS_WINNT */
+               return;
+#endif /* not SYS_WINNT */
+       }
+
+       for (;;) {
+               if (tok == CONFIG_END) 
+                       break;
+               if (fp[includelevel])
+                       tok = gettokens(fp[includelevel], line, tokens, &ntokens);
+#ifdef HAVE_NETINFO
+               else
+                       tok = gettokens_netinfo(config_netinfo, tokens, &ntokens);
+#endif /* HAVE_NETINFO */
+
+               if (tok == CONFIG_UNKNOWN) {
+                   if (includelevel > 0) {
+                       fclose(fp[includelevel--]);
+                       continue;
+                   } else {
+                       break;
+                   }
+               }
+
+               switch(tok) {
+                   case CONFIG_PEER:
+                   case CONFIG_SERVER:
+                   case CONFIG_MANYCASTCLIENT:
+                   case CONFIG_BROADCAST:
+                       if (tok == CONFIG_PEER)
+                           hmode = MODE_ACTIVE;
+                       else if (tok == CONFIG_SERVER)
+                           hmode = MODE_CLIENT;
+                       else if (tok == CONFIG_MANYCASTCLIENT)
+                           hmode = MODE_CLIENT;
+                       else
+                           hmode = MODE_BROADCAST;
+
+                       if (ntokens < 2) {
+                               msyslog(LOG_ERR,
+                                       "No address for %s, line ignored",
+                                       tokens[0]);
+                               break;
+                       }
+
+                       istart = 1;
+                       memset((char *)&peeraddr, 0, sizeof(peeraddr));
+                       peeraddr.ss_family = default_ai_family;
+                       switch (matchkey(tokens[istart], addr_type, 0)) {
+                       case CONF_ADDR_IPV4:
+                               peeraddr.ss_family = AF_INET;
+                               istart++;
+                               break;
+                       case CONF_ADDR_IPV6:
+                               peeraddr.ss_family = AF_INET6;
+                               istart++;
+                               break;
+                       }
+
+                       status = getnetnum(tokens[istart], &peeraddr, 0, t_UNK);
+                       if (status == -1)
+                               break;          /* Found IPv6 address */
+                       if(status != 1) {
+                               errflg = -1;
+                       } else {
+                               errflg = 0;
+
+                               if (
+#ifdef REFCLOCK
+                                       !ISREFCLOCKADR(&peeraddr) &&
+#endif
+                                       ISBADADR(&peeraddr)) {
+                                       msyslog(LOG_ERR,
+                                               "attempt to configure invalid address %s",
+                                               stoa(&peeraddr));
+                                       break;
+                               }
+                               /*
+                                * Shouldn't be able to specify multicast
+                                * address for server/peer!
+                                * and unicast address for manycastclient!
+                                */
+                               if (peeraddr.ss_family == AF_INET) {
+                                       if (((tok == CONFIG_SERVER) ||
+                                       (tok == CONFIG_PEER)) &&
+#ifdef REFCLOCK
+                                       !ISREFCLOCKADR(&peeraddr) &&
+#endif
+                                       IN_CLASSD(ntohl(((struct sockaddr_in*)&peeraddr)->sin_addr.s_addr))) {
+                                               msyslog(LOG_ERR,
+                                                       "attempt to configure invalid address %s",
+                                                       stoa(&peeraddr));
+                                               break;
+                                       }
+                                       if ((tok == CONFIG_MANYCASTCLIENT) &&
+                                       !IN_CLASSD(ntohl(((struct sockaddr_in*)&peeraddr)->sin_addr.s_addr))) {
+                                               msyslog(LOG_ERR,
+                                                       "attempt to configure invalid address %s",
+                                                       stoa(&peeraddr));
+                                               break;
+                                       }
+                               }
+                               else if(peeraddr.ss_family == AF_INET6) {
+                                if (((tok == CONFIG_SERVER) ||
+                                     (tok == CONFIG_PEER)) &&
+#ifdef REFCLOCK
+                                    !ISREFCLOCKADR(&peeraddr) &&
+#endif
+                                        IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)&peeraddr)->sin6_addr)) {
+                                                msyslog(LOG_ERR,
+                                                        "attempt to configure in valid address %s",
+                                                        stoa(&peeraddr));
+                                                break;
+                                        }
+                                        if ((tok == CONFIG_MANYCASTCLIENT) &&
+                                            !IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)&peeraddr)->sin6_addr)) {
+                                                        msyslog(LOG_ERR,
+                                                        "attempt to configure in valid address %s",
+                                                        stoa(&peeraddr));
+                                                break;
+                                       }
+                               }
+                       }
+                       if (peeraddr.ss_family == AF_INET6 &&
+                           isc_net_probeipv6() != ISC_R_SUCCESS)
+                               break;
+
+                       peerversion = NTP_VERSION;
+                       minpoll = NTP_MINDPOLL;
+                       maxpoll = NTP_MAXDPOLL;
+                       peerkey = 0;
+                       peerkeystr = (u_char *)"*";
+                       peerflags = 0;
+                       ttl = 0;
+                       istart++;
+                       for (i = istart; i < ntokens; i++)
+                           switch (matchkey(tokens[i], mod_keywords, 1)) {
+                               case CONF_MOD_VERSION:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "peer/server version requires an argument");
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   peerversion = atoi(tokens[++i]);
+                                   if ((u_char)peerversion > NTP_VERSION
+                                       || (u_char)peerversion < NTP_OLDVERSION) {
+                                           msyslog(LOG_ERR,
+                                                   "inappropriate version number %s, line ignored",
+                                                   tokens[i]);
+                                           errflg = 1;
+                                   }
+                                   break;
+                                       
+                               case CONF_MOD_KEY:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "key: argument required");
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   peerkey = (int)atol(tokens[++i]);
+                                   peerflags |= FLAG_AUTHENABLE;
+                                   break;
+
+                               case CONF_MOD_MINPOLL:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "minpoll: argument required");
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   minpoll = atoi(tokens[++i]);
+                                   if (minpoll < NTP_MINPOLL) {
+                                           msyslog(LOG_INFO,
+                                                   "minpoll: provided value (%d) is below minimum (%d)",
+                                                   minpoll, NTP_MINPOLL);
+                                       minpoll = NTP_MINPOLL;
+                                   }
+                                   break;
+
+                               case CONF_MOD_MAXPOLL:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "maxpoll: argument required"
+                                                   );
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   maxpoll = atoi(tokens[++i]);
+                                   if (maxpoll > NTP_MAXPOLL) {
+                                           msyslog(LOG_INFO,
+                                                   "maxpoll: provided value (%d) is above maximum (%d)",
+                                                   maxpoll, NTP_MAXPOLL);
+                                       maxpoll = NTP_MAXPOLL;
+                                   }
+                                   break;
+
+                               case CONF_MOD_PREFER:
+                                   peerflags |= FLAG_PREFER;
+                                   break;
+
+                               case CONF_MOD_PREEMPT:
+                                   peerflags |= FLAG_PREEMPT;
+                                   break;
+
+                               case CONF_MOD_NOSELECT:
+                                   peerflags |= FLAG_NOSELECT;
+                                   break;
+
+                               case CONF_MOD_TRUE:
+                                   peerflags |= FLAG_TRUE;
+
+                               case CONF_MOD_BURST:
+                                   peerflags |= FLAG_BURST;
+                                   break;
+
+                               case CONF_MOD_IBURST:
+                                   peerflags |= FLAG_IBURST;
+                                   break;
+
+                               case CONF_MOD_DYNAMIC:
+                                   msyslog(LOG_WARNING, 
+                                       "Warning: the \"dynamic\" keyword has been obsoleted"
+                                       " and will be removed in the next release\n");
+                                   break;
+
+#ifdef OPENSSL
+                               case CONF_MOD_SKEY:
+                                   peerflags |= FLAG_SKEY |
+                                       FLAG_AUTHENABLE;
+                                   break;
+#endif /* OPENSSL */
+
+                               case CONF_MOD_TTL:
+                                   if (i >= ntokens-1) {
+                                       msyslog(LOG_ERR,
+                                           "ttl: argument required");
+                                       errflg = 1;
+                                       break;
+                                   }
+                                   ttl = atoi(tokens[++i]);
+                                   if (ttl >= MAX_TTL) {
+                                       msyslog(LOG_ERR,
+                                           "ttl: invalid argument");
+                                       errflg = 1;
+                                   }
+                                   break;
+
+                               case CONF_MOD_MODE:
+                                   if (i >= ntokens-1) {
+                                       msyslog(LOG_ERR,
+                                           "mode: argument required");
+                                       errflg = 1;
+                                       break;
+                                   }
+                                   ttl = atoi(tokens[++i]);
+                                   break;
+
+                               case CONFIG_UNKNOWN:
+                                   errflg = 1;
+                                   break;
+                           }
+                       if (minpoll > maxpoll) {
+                               msyslog(LOG_ERR,
+                                   "config error: minpoll > maxpoll");
+                               errflg = 1;
+                       }
+                       if (errflg == 0) {
+                           if (peer_config(&peeraddr,
+                               ANY_INTERFACE_CHOOSE(&peeraddr), hmode,
+                               peerversion, minpoll, maxpoll, peerflags,
+                               ttl, peerkey, peerkeystr) == 0) {
+                                       msyslog(LOG_ERR,
+                                               "configuration of %s failed",
+                                               stoa(&peeraddr));
+                           }
+                       } else if (errflg == -1) {
+                               save_resolve(tokens[1], hmode, peerversion,
+                                   minpoll, maxpoll, peerflags, ttl,
+                                   peerkey, peerkeystr);
+                       }
+                       break;
+
+                   case CONFIG_DRIFTFILE:
+                       if (ntokens >= 2)
+                           stats_config(STATS_FREQ_FILE, tokens[1]);
+                       else
+                           stats_config(STATS_FREQ_FILE, (char *)0);
+                       stats_write_period = stats_write_tolerance = 0;
+                       if (ntokens >= 3)
+                            stats_write_period = 60 * atol(tokens[2]);
+                       if (stats_write_period <= 0)
+                            stats_write_period = 3600;
+                       if (ntokens >= 4) {
+                            double ftemp;
+                            sscanf(tokens[3], "%lf", &ftemp);
+                            stats_write_tolerance = ftemp / 100;
+                       }
+                       break;
+       
+                   case CONFIG_PIDFILE:
+                       if (ntokens >= 2)
+                           stats_config(STATS_PID_FILE, tokens[1]);
+                       else
+                           stats_config(STATS_PID_FILE, (char *)0);
+                       break;
+
+                   case CONFIG_END:
+                       for ( i = 0; i <= includelevel; i++ ) {
+                               fclose(fp[i]);
+                       }
+                       break;
+                       
+                   case CONFIG_INCLUDEFILE:
+                       if (ntokens < 2) {
+                           msyslog(LOG_ERR, "includefile needs one argument");
+                           break;
+                       }
+                       if (includelevel >= MAXINCLUDELEVEL) {
+                           fprintf(stderr, "getconfig: Maximum include file level exceeded.\n");
+                           msyslog(LOG_INFO, "getconfig: Maximum include file level exceeded.");
+                           break;
+                       }
+                       includefile = fopen(FindConfig(tokens[1]), "r");
+                       if (includefile == NULL) {
+                           fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig(tokens[1]));
+                           msyslog(LOG_INFO, "getconfig: Couldn't open <%s>", FindConfig(tokens[1]));
+                           break;
+                       }
+                       fp[++includelevel] = includefile;
+                       break;
+
+                   case CONFIG_LOGFILE:
+                       if (ntokens >= 2) {
+                               FILE *new_file;
+
+                               new_file = fopen(tokens[1], "a");
+                               if (new_file != NULL) {
+                                       NLOG(NLOG_SYSINFO) /* conditional if clause for conditional syslog */
+                                           msyslog(LOG_NOTICE, "logging to file %s", tokens[1]);
+                                       if (syslog_file != NULL &&
+                                           fileno(syslog_file) != fileno(new_file))
+                                           (void)fclose(syslog_file);
+
+                                       syslog_file = new_file;
+                                       syslogit = 0;
+                               }
+                               else
+                                   msyslog(LOG_ERR,
+                                           "Cannot open log file %s",
+                                           tokens[1]);
+                       }
+                       else
+                           msyslog(LOG_ERR, "logfile needs one argument");
+                       break;
+
+                   case CONFIG_LOGCONFIG:
+                       for (i = 1; i < ntokens; i++)
+                       {
+                               int add = 1;
+                               int equals = 0;
+                               char * s = &tokens[i][0];
+
+                               switch (*s) {
+                                   case '+':
+                                   case '-':
+                                   case '=':
+                                       add = *s == '+';
+                                       equals = *s == '=';
+                                       s++;
+                                       break;
+
+                                   default:
+                                       break;
+                               }
+                               if (equals) {
+                                       ntp_syslogmask = get_logmask(s);
+                               } else {                                
+                                       if (add) {
+                                               ntp_syslogmask |= get_logmask(s);
+                                       } else {
+                                               ntp_syslogmask &= ~get_logmask(s);
+                                       }
+                               }
+#ifdef DEBUG
+                               if (debug)
+                                   printf("ntp_syslogmask = 0x%08lx (%s)\n", ntp_syslogmask, tokens[i]);
+#endif
+                       }
+                       break;
+
+                   case CONFIG_BROADCASTCLIENT:
+                       if (ntokens == 1) {
+                               proto_config(PROTO_BROADCLIENT, 1, 0., NULL);
+                       } else {
+                               proto_config(PROTO_BROADCLIENT, 2, 0., NULL);
+                       }
+                       break;
+
+                   case CONFIG_MULTICASTCLIENT:
+                   case CONFIG_MANYCASTSERVER:
+                       if (ntokens > 1) {
+                               istart = 1;
+                               memset((char *)&peeraddr, 0, sizeof(peeraddr));
+                               peeraddr.ss_family = default_ai_family;
+                               switch (matchkey(tokens[istart],
+                                   addr_type, 0)) {
+                               case CONF_ADDR_IPV4:
+                                       peeraddr.ss_family = AF_INET;
+                                       istart++;
+                                       break;
+                               case CONF_ADDR_IPV6:
+                                       peeraddr.ss_family = AF_INET6;
+                                       istart++;
+                                       break;
+                               }
+                               /*
+                                * Abuse maskaddr to store the prefered ip
+                                * version.
+                                */
+                               memset((char *)&maskaddr, 0, sizeof(maskaddr));
+                               maskaddr.ss_family = peeraddr.ss_family;
+
+                               for (i = istart; i < ntokens; i++) {
+                                       memset((char *)&peeraddr, 0,
+                                           sizeof(peeraddr));
+                                       peeraddr.ss_family = maskaddr.ss_family;
+                                       if (getnetnum(tokens[i], &peeraddr, 1,
+                                                     t_UNK)  == 1)
+                                           proto_config(PROTO_MULTICAST_ADD,
+                                                        0, 0., &peeraddr);
+                               }
+                       } else
+                           proto_config(PROTO_MULTICAST_ADD,
+                                        0, 0., NULL);
+                       if (tok == CONFIG_MULTICASTCLIENT)
+                               proto_config(PROTO_MULTICAST_ADD, 1, 0., NULL);
+                       else if (tok == CONFIG_MANYCASTSERVER)
+                               sys_manycastserver = 1;
+                       break;
+
+                   case CONFIG_KEYS:
+                       if (ntokens >= 2) {
+                               getauthkeys(tokens[1]);
+                       }
+                       break;
+
+                   case CONFIG_KEYSDIR:
+                       if (ntokens < 2) {
+                           msyslog(LOG_ERR,
+                               "Keys directory name required");
+                           break;
+                       }
+                       keysdir = (char *)emalloc(strlen(tokens[1]) + 1);
+                       strcpy(keysdir, tokens[1]);
+                       break;
+
+                   case CONFIG_TINKER:
+                       for (i = 1; i < ntokens; i++) {
+                           int temp;
+                           double ftemp;
+
+                           temp = matchkey(tokens[i++], tinker_keywords, 1);
+                           if (i > ntokens - 1) {
+                               msyslog(LOG_ERR,
+                                   "tinker: missing argument");
+                               errflg++;
+                               break;
+                           }
+                           sscanf(tokens[i], "%lf", &ftemp);
+                           switch(temp) {
+
+                           case CONF_CLOCK_MAX:
+                                loop_config(LOOP_MAX, ftemp);
+                               break;
+
+                           case CONF_CLOCK_PANIC:
+                               loop_config(LOOP_PANIC, ftemp);
+                               break;
+
+                           case CONF_CLOCK_PHI:
+                               loop_config(LOOP_PHI, ftemp);
+                               break;
+
+                           case CONF_CLOCK_MINSTEP:
+                               loop_config(LOOP_MINSTEP, ftemp);
+                               break;
+
+                           case CONF_CLOCK_ALLAN:
+                               loop_config(LOOP_ALLAN, ftemp);
+                               break;
+
+                           case CONF_CLOCK_HUFFPUFF:
+                               loop_config(LOOP_HUFFPUFF, ftemp);
+                               break;
+
+                           case CONF_CLOCK_FREQ:
+                               loop_config(LOOP_FREQ, ftemp);
+                               break;  
+                           }
+                       }
+                       break;
+
+                   case CONFIG_TOS:
+                       for (i = 1; i < ntokens; i++) {
+                           int temp;
+                           double ftemp;
+
+                           temp = matchkey(tokens[i++], tos_keywords, 1);
+                           if (i > ntokens - 1) {
+                               msyslog(LOG_ERR,
+                                   "tos: missing argument");
+                               errflg++;
+                               break;
+                           }
+                           sscanf(tokens[i], "%lf", &ftemp);
+                           switch(temp) {
+
+                           case CONF_TOS_MINCLOCK:
+                               proto_config(PROTO_MINCLOCK, 0, ftemp, NULL);
+                               break;
+
+                           case CONF_TOS_MAXCLOCK:
+                               proto_config(PROTO_MAXCLOCK, 0, ftemp, NULL);
+                               break;
+
+                           case CONF_TOS_MINSANE:
+                               proto_config(PROTO_MINSANE, 0, ftemp, NULL);
+                               break;
+
+                           case CONF_TOS_FLOOR:
+                               proto_config(PROTO_FLOOR, 0, ftemp, NULL);
+                               break;
+
+                           case CONF_TOS_CEILING:
+                               proto_config(PROTO_CEILING, 0, ftemp, NULL);
+                               break;
+
+                           case CONF_TOS_COHORT:
+                               proto_config(PROTO_COHORT, 0, ftemp, NULL);
+                               break;
+
+                           case CONF_TOS_MINDISP:
+                               proto_config(PROTO_MINDISP, 0, ftemp, NULL);
+                               break;
+
+                           case CONF_TOS_MAXDIST:
+                               proto_config(PROTO_MAXDIST, 0, ftemp, NULL);
+                               break;
+
+                           case CONF_TOS_MAXHOP:
+                               proto_config(PROTO_MAXHOP, 0, ftemp, NULL);
+                               break;
+
+                           case CONF_TOS_ORPHAN:
+                               proto_config(PROTO_ORPHAN, 0, ftemp, NULL);
+                               break;
+
+                           case CONF_TOS_BEACON:
+                               proto_config(PROTO_BEACON, 0, ftemp, NULL);
+                               break;
+                           }
+                       }
+                       break;
+
+                   case CONFIG_TTL:
+                       for (i = 1; i < ntokens && i < MAX_TTL; i++) {
+                           sys_ttl[i - 1] = (u_char) atoi(tokens[i]);
+                           sys_ttlmax = i - 1;
+                       }
+                       break;
+
+                   case CONFIG_DISCARD:
+                       for (i = 1; i < ntokens; i++) {
+                           int temp;
+
+                           temp = matchkey(tokens[i++],
+                               discard_keywords, 1);
+                           if (i > ntokens - 1) {
+                               msyslog(LOG_ERR,
+                                   "discard: missing argument");
+                               errflg++;
+                               break;
+                           }
+                           switch(temp) {
+                           case CONF_DISCARD_AVERAGE:
+                               res_avg_interval = atoi(tokens[i]);
+                               break;
+
+                           case CONF_DISCARD_MINIMUM:
+                               res_min_interval = atoi(tokens[i]);
+                               break;
+
+                           case CONF_DISCARD_MONITOR:
+                               mon_age = atoi(tokens[i]);
+                               break;
+
+                           default:
+                               msyslog(LOG_ERR,
+                                   "discard: unknown keyword");
+                               break;
+                           }
+                       }
+                       break;
+
+#ifdef OPENSSL
+                   case CONFIG_REVOKE:
+                       if (ntokens >= 2)
+                           sys_revoke = (u_char) max(atoi(tokens[1]), KEY_REVOKE);
+                       break;
+
+                   case CONFIG_AUTOMAX:
+                       if (ntokens >= 2)
+                           sys_automax = 1 << max(atoi(tokens[1]), 10);
+                       break;
+
+                   case CONFIG_CRYPTO:
+                       if (ntokens == 1) {
+                               crypto_config(CRYPTO_CONF_NONE, NULL);
+                               break;
+                       }
+                       for (i = 1; i < ntokens; i++) {
+                           int temp;
+
+                           temp = matchkey(tokens[i++],
+                                crypto_keywords, 1);
+                           if (i > ntokens - 1) {
+                               msyslog(LOG_ERR,
+                                   "crypto: missing argument");
+                               errflg++;
+                               break;
+                           }
+                           switch(temp) {
+
+                           case CONF_CRYPTO_CERT:
+                               crypto_config(CRYPTO_CONF_CERT,
+                                   tokens[i]);
+                               break;
+
+                           case CONF_CRYPTO_RSA:
+                               crypto_config(CRYPTO_CONF_PRIV,
+                                   tokens[i]);
+                               break;
+
+                           case CONF_CRYPTO_IDENT:
+                               crypto_config(CRYPTO_CONF_IDENT,
+                                   tokens[i]);
+                               break;
+
+                           case CONF_CRYPTO_IFFPAR:
+                               crypto_config(CRYPTO_CONF_IFFPAR,
+                                   tokens[i]);
+                               break;
+
+                           case CONF_CRYPTO_GQPAR:
+                               crypto_config(CRYPTO_CONF_GQPAR,
+                                   tokens[i]);
+                               break;
+
+                           case CONF_CRYPTO_MVPAR:
+                               crypto_config(CRYPTO_CONF_MVPAR,
+                                   tokens[i]);
+                               break;
+
+                           case CONF_CRYPTO_LEAP:
+                               crypto_config(CRYPTO_CONF_LEAP,
+                                   tokens[i]);
+                               break;
+
+                           case CONF_CRYPTO_PW:
+                               crypto_config(CRYPTO_CONF_PW,
+                                   tokens[i]);
+                               break;
+
+                           case CONF_CRYPTO_RAND:
+                               crypto_config(CRYPTO_CONF_RAND,
+                                   tokens[i]);
+                               break;
+
+                           case CONF_CRYPTO_SIGN:
+                               crypto_config(CRYPTO_CONF_SIGN,
+                                   tokens[i]);
+                               break;
+
+                           default:
+                               msyslog(LOG_ERR,
+                                   "crypto: unknown keyword");
+                               break;
+                           }
+                       }
+                       break;
+#endif /* OPENSSL */
+
+                   case CONFIG_RESTRICT:
+                       if (ntokens < 2) {
+                               msyslog(LOG_ERR, "restrict requires an address");
+                               break;
+                       }
+                       istart = 1;
+                       memset((char *)&peeraddr, 0, sizeof(peeraddr));
+                       peeraddr.ss_family = default_ai_family;
+                       switch (matchkey(tokens[istart], addr_type, 0)) {
+                       case CONF_ADDR_IPV4:
+                               peeraddr.ss_family = AF_INET;
+                               istart++;
+                               break;
+                       case CONF_ADDR_IPV6:
+                               peeraddr.ss_family = AF_INET6;
+                               istart++;
+                               break;
+                       }
+
+                       /*
+                        * Assume default means an IPv4 address, except
+                        * if forced by a -4 or -6.
+                        */
+                       if (STREQ(tokens[istart], "default")) {
+                               if (peeraddr.ss_family == 0)
+                                       peeraddr.ss_family = AF_INET;
+                       } else if (getnetnum(tokens[istart], &peeraddr, 1,
+                                             t_UNK) != 1)
+                               break;
+
+                       /*
+                        * Use peerversion as flags, peerkey as mflags.  Ick.
+                        */
+                       peerversion = 0;
+                       peerkey = 0;
+                       errflg = 0;
+                       SET_HOSTMASK(&maskaddr, peeraddr.ss_family);
+                       istart++;
+                       for (i = istart; i < ntokens; i++) {
+                               switch (matchkey(tokens[i], res_keywords, 1)) {
+                                   case CONF_RES_MASK:
+                                       if (i >= ntokens-1) {
+                                               msyslog(LOG_ERR,
+                                                       "mask keyword needs argument");
+                                               errflg++;
+                                               break;
+                                       }
+                                       i++;
+                                       if (getnetnum(tokens[i], &maskaddr, 1,
+                                                      t_MSK) != 1)
+                                           errflg++;
+                                       break;
+
+                                   case CONF_RES_IGNORE:
+                                       peerversion |= RES_IGNORE;
+                                       break;
+
+                                   case CONF_RES_NOSERVE:
+                                       peerversion |= RES_DONTSERVE;
+                                       break;
+
+                                   case CONF_RES_NOTRUST:
+                                       peerversion |= RES_DONTTRUST;
+                                       break;
+
+                                   case CONF_RES_NOQUERY:
+                                       peerversion |= RES_NOQUERY;
+                                       break;
+
+                                   case CONF_RES_NOMODIFY:
+                                       peerversion |= RES_NOMODIFY;
+                                       break;
+
+                                   case CONF_RES_NOPEER:
+                                       peerversion |= RES_NOPEER;
+                                       break;
+
+                                   case CONF_RES_NOTRAP:
+                                       peerversion |= RES_NOTRAP;
+                                       break;
+
+                                   case CONF_RES_LPTRAP:
+                                       peerversion |= RES_LPTRAP;
+                                       break;
+
+                                   case CONF_RES_NTPPORT:
+                                       peerkey |= RESM_NTPONLY;
+                                       break;
+
+                                   case CONF_RES_VERSION:
+                                       peerversion |= RES_VERSION;
+                                       break;
+
+                                   case CONF_RES_DEMOBILIZE:
+                                       peerversion |= RES_DEMOBILIZE;
+                                       break;
+
+                                   case CONF_RES_LIMITED:
+                                       peerversion |= RES_LIMITED;
+                                       break;
+
+                                   case CONFIG_UNKNOWN:
+                                       errflg++;
+                                       break;
+                               }
+                       }
+                       if (SOCKNUL(&peeraddr))
+                           ANYSOCK(&maskaddr);
+                       if (!errflg)
+                           hack_restrict(RESTRICT_FLAGS, &peeraddr, &maskaddr,
+                                         (int)peerkey, peerversion);
+                       break;
+
+                   case CONFIG_BDELAY:
+                       if (ntokens >= 2) {
+                               double tmp;
+
+                               if (sscanf(tokens[1], "%lf", &tmp) != 1) {
+                                       msyslog(LOG_ERR,
+                                               "broadcastdelay value %s undecodable",
+                                               tokens[1]);
+                               } else {
+                                       proto_config(PROTO_BROADDELAY, 0, tmp, NULL);
+                               }
+                       }
+                       break;
+
+                   case CONFIG_CDELAY:
+                        if (ntokens >= 2) {
+                                u_long ui;
+
+                               if (sscanf(tokens[1], "%ld", &ui) != 1)
+                                       msyslog(LOG_ERR,
+                                           "illegal value - line ignored");
+                               else
+                                       proto_config(PROTO_CALLDELAY, ui, 0, NULL);
+                       }
+                       break;
+
+                   case CONFIG_TRUSTEDKEY:
+                       for (i = 1; i < ntokens; i++) {
+                               keyid_t tkey;
+
+                               tkey = atol(tokens[i]);
+                               if (tkey == 0) {
+                                       msyslog(LOG_ERR,
+                                               "trusted key %s unlikely",
+                                               tokens[i]);
+                               } else {
+                                       authtrust(tkey, 1);
+                               }
+                       }
+                       break;
+
+                   case CONFIG_REQUESTKEY:
+                       if (ntokens >= 2) {
+                               if (!atouint(tokens[1], &ul)) {
+                                       msyslog(LOG_ERR,
+                                               "%s is undecodable as request key",
+                                               tokens[1]);
+                               } else if (ul == 0) {
+                                       msyslog(LOG_ERR,
+                                               "%s makes a poor request keyid",
+                                               tokens[1]);
+                               } else {
+#ifdef DEBUG
+                                       if (debug > 3)
+                                           printf(
+                                                   "set info_auth_key to %08lx\n", ul);
+#endif
+                                       info_auth_keyid = (keyid_t)ul;
+                               }
+                       }
+                       break;
+
+                   case CONFIG_CONTROLKEY:
+                       if (ntokens >= 2) {
+                               keyid_t ckey;
+
+                               ckey = atol(tokens[1]);
+                               if (ckey == 0) {
+                                       msyslog(LOG_ERR,
+                                               "%s makes a poor control keyid",
+                                               tokens[1]);
+                               } else {
+                                       ctl_auth_keyid = ckey;
+                               }
+                       }
+                       break;
+
+                   case CONFIG_TRAP:
+                       if (ntokens < 2) {
+                               msyslog(LOG_ERR,
+                                       "no address for trap command, line ignored");
+                               break;
+                       }
+                       istart = 1;
+                       memset((char *)&peeraddr, 0, sizeof(peeraddr));
+                       peeraddr.ss_family = default_ai_family;
+                       switch (matchkey(tokens[istart], addr_type, 0)) {
+                       case CONF_ADDR_IPV4:
+                               peeraddr.ss_family = AF_INET;
+                               istart++;
+                               break;
+                       case CONF_ADDR_IPV6:
+                               peeraddr.ss_family = AF_INET6;
+                               istart++;
+                               break;
+                       }
+
+                       if (getnetnum(tokens[istart], &peeraddr, 1, t_UNK) != 1)
+                           break;
+
+                       /*
+                        * Use peerversion for port number.  Barf.
+                        */
+                       errflg = 0;
+                       peerversion = 0;
+                       localaddr = 0;
+                       istart++;
+                       for (i = istart; i < ntokens-1; i++)
+                           switch (matchkey(tokens[i], trap_keywords, 1)) {
+                               case CONF_TRAP_PORT:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "trap port requires an argument");
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   peerversion = atoi(tokens[++i]);
+                                   if (peerversion <= 0
+                                       || peerversion > 32767) {
+                                           msyslog(LOG_ERR,
+                                                   "invalid port number %s, trap ignored",
+                                                   tokens[i]);
+                                           errflg = 1;
+                                   }
+                                   break;
+
+                               case CONF_TRAP_INTERFACE:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "trap interface requires an argument");
+                                           errflg = 1;
+                                           break;
+                                   }
+
+                                   memset((char *)&maskaddr, 0,
+                                       sizeof(maskaddr));
+                                   maskaddr.ss_family = peeraddr.ss_family;
+                                   if (getnetnum(tokens[++i],
+                                                  &maskaddr, 1, t_UNK) != 1) {
+                                           errflg = 1;
+                                           break;
+                                   }
+
+                                   localaddr = findinterface(&maskaddr);
+                                   if (localaddr == NULL) {
+                                           msyslog(LOG_ERR,
+                                                   "can't find interface with address %s",
+                                                   stoa(&maskaddr));
+                                           errflg = 1;
+                                   }
+                                   break;
+
+                               case CONFIG_UNKNOWN:
+                                   errflg++;
+                                   break;
+                           }
+
+                       if (!errflg) {
+                               if (peerversion != 0)
+                                   ((struct sockaddr_in6*)&peeraddr)->sin6_port = htons( (u_short) peerversion);
+                               else
+                                   ((struct sockaddr_in6*)&peeraddr)->sin6_port = htons(TRAPPORT);
+                               if (localaddr == NULL)
+                                   localaddr = ANY_INTERFACE_CHOOSE(&peeraddr);
+                               if (!ctlsettrap(&peeraddr, localaddr, 0,
+                                               NTP_VERSION))
+                                   msyslog(LOG_ERR,
+                                           "can't set trap for %s, no resources",
+                                           stoa(&peeraddr));
+                       }
+                       break;
+
+                   case CONFIG_FUDGE:
+                       if (ntokens < 2) {
+                               msyslog(LOG_ERR,
+                                       "no address for fudge command, line ignored");
+                               break;
+                       }
+                       memset((char *)&peeraddr, 0, sizeof(peeraddr));
+                       if (getnetnum(tokens[1], &peeraddr, 1, t_REF) != 1)
+                           break;
+
+                       if (!ISREFCLOCKADR(&peeraddr)) {
+                               msyslog(LOG_ERR,
+                                       "%s is inappropriate address for the fudge command, line ignored",
+                                       stoa(&peeraddr));
+                               break;
+                       }
+
+                       memset((void *)&clock_stat, 0, sizeof clock_stat);
+                       fudgeflag = 0;
+                       errflg = 0;
+                       for (i = 2; i < ntokens-1; i++) {
+                               switch (c = matchkey(tokens[i],
+                                   fudge_keywords, 1)) {
+                                   case CONF_FDG_TIME1:
+                                       if (sscanf(tokens[++i], "%lf",
+                                                  &clock_stat.fudgetime1) != 1) {
+                                               msyslog(LOG_ERR,
+                                                       "fudge %s time1 value in error",
+                                                       stoa(&peeraddr));
+                                               errflg = i;
+                                               break;
+                                       }
+                                       clock_stat.haveflags |= CLK_HAVETIME1;
+                                       break;
+
+                                   case CONF_FDG_TIME2:
+                                       if (sscanf(tokens[++i], "%lf",
+                                                  &clock_stat.fudgetime2) != 1) {
+                                               msyslog(LOG_ERR,
+                                                       "fudge %s time2 value in error",
+                                                       stoa(&peeraddr));
+                                               errflg = i;
+                                               break;
+                                       }
+                                       clock_stat.haveflags |= CLK_HAVETIME2;
+                                       break;
+
+
+                                   case CONF_FDG_STRATUM:
+                                     if (!atoint(tokens[++i], &stratum))
+                                       {
+                                               msyslog(LOG_ERR,
+                                                       "fudge %s stratum value in error",
+                                                       stoa(&peeraddr));
+                                               errflg = i;
+                                               break;
+                                       }
+                                       clock_stat.fudgeval1 = stratum;
+                                       clock_stat.haveflags |= CLK_HAVEVAL1;
+                                       break;
+
+                                   case CONF_FDG_REFID:
+                                       i++;
+                                       memcpy(&clock_stat.fudgeval2,
+                                           tokens[i], min(strlen(tokens[i]),
+                                           4));
+                                       clock_stat.haveflags |= CLK_HAVEVAL2;
+                                       break;
+
+                                   case CONF_FDG_FLAG1:
+                                   case CONF_FDG_FLAG2:
+                                   case CONF_FDG_FLAG3:
+                                   case CONF_FDG_FLAG4:
+                                       if (!atouint(tokens[++i], &fudgeflag)
+                                           || fudgeflag > 1) {
+                                               msyslog(LOG_ERR,
+                                                       "fudge %s flag value in error",
+                                                       stoa(&peeraddr));
+                                               errflg = i;
+                                               break;
+                                       }
+                                       switch(c) {
+                                           case CONF_FDG_FLAG1:
+                                               c = CLK_FLAG1;
+                                               clock_stat.haveflags|=CLK_HAVEFLAG1;
+                                               break;
+                                           case CONF_FDG_FLAG2:
+                                               c = CLK_FLAG2;
+                                               clock_stat.haveflags|=CLK_HAVEFLAG2;
+                                               break;
+                                           case CONF_FDG_FLAG3:
+                                               c = CLK_FLAG3;
+                                               clock_stat.haveflags|=CLK_HAVEFLAG3;
+                                               break;
+                                           case CONF_FDG_FLAG4:
+                                               c = CLK_FLAG4;
+                                               clock_stat.haveflags|=CLK_HAVEFLAG4;
+                                               break;
+                                       }
+                                       if (fudgeflag == 0)
+                                           clock_stat.flags &= ~c;
+                                       else
+                                           clock_stat.flags |= c;
+                                       break;
+
+                                   case CONFIG_UNKNOWN:
+                                       errflg = -1;
+                                       break;
+                               }
+                       }
+
+#ifdef REFCLOCK
+                       /*
+                        * If reference clock support isn't defined the
+                        * fudge line will still be accepted and syntax
+                        * checked, but will essentially do nothing.
+                        */
+                       if (!errflg) {
+                               refclock_control(&peeraddr, &clock_stat,
+                                   (struct refclockstat *)0);
+                       }
+#endif
+                       break;
+
+                   case CONFIG_STATSDIR:
+                       if (ntokens >= 2)
+                               stats_config(STATS_STATSDIR,tokens[1]);
+                       break;
+
+                   case CONFIG_STATISTICS:
+                       for (i = 1; i < ntokens; i++) {
+                               filegen = filegen_get(tokens[i]);
+
+                               if (filegen == NULL) {
+                                       msyslog(LOG_ERR,
+                                               "no statistics named %s available",
+                                               tokens[i]);
+                                       continue;
+                               }
+#ifdef DEBUG
+                               if (debug > 3)
+                                   printf("enabling filegen for %s statistics \"%s%s\"\n",
+                                          tokens[i], filegen->prefix, filegen->basename);
+#endif
+                               filegen->flag |= FGEN_FLAG_ENABLED;
+                       }
+                       break;
+
+                   case CONFIG_FILEGEN:
+                       if (ntokens < 2) {
+                               msyslog(LOG_ERR,
+                                       "no id for filegen command, line ignored");
+                               break;
+                       }
+
+                       filegen = filegen_get(tokens[1]);
+                       if (filegen == NULL) {
+                               msyslog(LOG_ERR,
+                                       "unknown filegen \"%s\" ignored",
+                                       tokens[1]);
+                               break;
+                       }
+                       /*
+                        * peerversion is (ab)used for filegen file (index)
+                        * peerkey         is (ab)used for filegen type
+                        * peerflags   is (ab)used for filegen flags
+                        */
+                       peerversion = 0;
+                       peerkey =         filegen->type;
+                       peerflags =   filegen->flag;
+                       errflg = 0;
+
+                       for (i = 2; i < ntokens; i++) {
+                               switch (matchkey(tokens[i],
+                                   filegen_keywords, 1)) {
+                                   case CONF_FGEN_FILE:
+                                       if (i >= ntokens - 1) {
+                                               msyslog(LOG_ERR,
+                                                       "filegen %s file requires argument",
+                                                       tokens[1]);
+                                               errflg = i;
+                                               break;
+                                       }
+                                       peerversion = ++i;
+                                       break;
+                                   case CONF_FGEN_TYPE:
+                                       if (i >= ntokens -1) {
+                                               msyslog(LOG_ERR,
+                                                       "filegen %s type requires argument",
+                                                       tokens[1]);
+                                               errflg = i;
+                                               break;
+                                       }
+                                       peerkey = matchkey(tokens[++i],
+                                           fgen_types, 1);
+                                       if (peerkey == CONFIG_UNKNOWN) {
+                                               msyslog(LOG_ERR,
+                                                       "filegen %s unknown type \"%s\"",
+                                                       tokens[1], tokens[i]);
+                                               errflg = i;
+                                               break;
+                                       }
+                                       break;
+
+                                   case CONF_FGEN_FLAG_LINK:
+                                       peerflags |= FGEN_FLAG_LINK;
+                                       break;
+
+                                   case CONF_FGEN_FLAG_NOLINK:
+                                       peerflags &= ~FGEN_FLAG_LINK;
+                                       break;
+
+                                   case CONF_FGEN_FLAG_ENABLE:
+                                       peerflags |= FGEN_FLAG_ENABLED;
+                                       break;
+
+                                   case CONF_FGEN_FLAG_DISABLE:
+                                       peerflags &= ~FGEN_FLAG_ENABLED;
+                                       break;
+                               }
+                       }
+                       if (!errflg)
+                               filegen_config(filegen, tokens[peerversion],
+                                  (u_char)peerkey, (u_char)peerflags);
+                       break;
+
+                   case CONFIG_SETVAR:
+                       if (ntokens < 2) {
+                               msyslog(LOG_ERR,
+                                       "no value for setvar command - line ignored");
+                       } else {
+                               set_sys_var(tokens[1], strlen(tokens[1])+1,
+                                           (u_short) (RW |
+                                           ((((ntokens > 2)
+                                              && !strcmp(tokens[2],
+                                                         "default")))
+                                            ? DEF
+                                            : 0)));
+                       }
+                       break;
+
+                   case CONFIG_ENABLE:
+                       for (i = 1; i < ntokens; i++) {
+                               int flag;
+
+                               flag = matchkey(tokens[i], flags_keywords, 1);
+                               if (flag == CONFIG_UNKNOWN) {
+                                       msyslog(LOG_ERR,
+                                               "enable unknown flag %s",
+                                               tokens[i]);
+                                       errflg = 1;
+                                       break;
+                               }
+                               proto_config(flag, 1, 0., NULL);
+                       }
+                       break;
+
+                   case CONFIG_DISABLE:
+                       for (i = 1; i < ntokens; i++) {
+                               int flag;
+
+                               flag = matchkey(tokens[i], flags_keywords, 1);
+                               if (flag == CONFIG_UNKNOWN) {
+                                       msyslog(LOG_ERR,
+                                               "disable unknown flag %s",
+                                               tokens[i]);
+                                       errflg = 1;
+                                       break;
+                               }
+                               proto_config(flag, 0, 0., NULL);
+                       }
+                       break;
+
+                   case CONFIG_PHONE:
+                       for (i = 1; i < ntokens && i < MAXPHONE - 1; i++) {
+                               sys_phone[i - 1] =
+                                   emalloc(strlen(tokens[i]) + 1);
+                               strcpy(sys_phone[i - 1], tokens[i]);
+                       }
+                       sys_phone[i] = NULL;
+                       break;
+
+                   case CONFIG_ADJ: {
+                           double ftemp;
+
+                           sscanf(tokens[1], "%lf", &ftemp);
+                           proto_config(PROTO_ADJ, 0, ftemp, NULL);
+                       }
+                       break;
+
+               }
+       }
+       if (fp[0])
+               (void)fclose(fp[0]);
+
+#ifdef HAVE_NETINFO
+       if (config_netinfo)
+               free_netinfo_config(config_netinfo);
+#endif /* HAVE_NETINFO */
+
+#if !defined(VMS) && !defined(SYS_VXWORKS)
+       /* find a keyid */
+       if (info_auth_keyid == 0)
+               req_keyid = 65535;
+       else
+               req_keyid = info_auth_keyid;
+
+       /* if doesn't exist, make up one at random */
+       if (!authhavekey(req_keyid)) {
+               char rankey[9];
+               int j;
+
+               for (i = 0; i < 8; i++)
+                       for (j = 1; j < 100; ++j) {
+                               rankey[i] = (char) (ntp_random() & 0xff);
+                               if (rankey[i] != 0) break;
+                       }
+               rankey[8] = 0;
+               authusekey(req_keyid, KEY_TYPE_MD5, (u_char *)rankey);
+               authtrust(req_keyid, 1);
+               if (!authhavekey(req_keyid)) {
+                       msyslog(LOG_ERR, "getconfig: Couldn't generate a valid random key!");
+                       /* HMS: Should this be fatal? */
+               }
+       }
+
+       /* save keyid so we will accept config requests with it */
+       info_auth_keyid = req_keyid;
+#endif /* !defined(VMS) && !defined(SYS_VXWORKS) */
+
+       if (res_fp != NULL) {
+               if (call_resolver) {
+                       /*
+                        * Need name resolution
+                        */
+                       do_resolve_internal();
+               }
+       }
+}
+
+
+#ifdef HAVE_NETINFO
+
+/* 
+ * get_netinfo_config - find the nearest NetInfo domain with an ntp
+ * configuration and initialize the configuration state.
+ */
+static struct netinfo_config_state *
+get_netinfo_config()
+{
+       ni_status status;
+       void *domain;
+       ni_id config_dir;
+               struct netinfo_config_state *config;
+
+       if (ni_open(NULL, ".", &domain) != NI_OK) return NULL;
+
+       while ((status = ni_pathsearch(domain, &config_dir, NETINFO_CONFIG_DIR)) == NI_NODIR) {
+               void *next_domain;
+               if (ni_open(domain, "..", &next_domain) != NI_OK) {
+                       ni_free(next_domain);
+                       break;
+               }
+               ni_free(domain);
+               domain = next_domain;
+       }
+       if (status != NI_OK) {
+               ni_free(domain);
+               return NULL;
+       }
+
+               config = (struct netinfo_config_state *)malloc(sizeof(struct netinfo_config_state));
+               config->domain = domain;
+               config->config_dir = config_dir;
+               config->prop_index = 0;
+               config->val_index = 0;
+               config->val_list = NULL;
+
+       return config;
+}
+
+
+
+/*
+ * free_netinfo_config - release NetInfo configuration state
+ */
+static void
+free_netinfo_config(struct netinfo_config_state *config)
+{
+       ni_free(config->domain);
+       free(config);
+}
+
+
+
+/*
+ * gettokens_netinfo - return tokens from NetInfo
+ */
+static int
+gettokens_netinfo (
+       struct netinfo_config_state *config,
+       char **tokenlist,
+       int *ntokens
+       )
+{
+       int prop_index = config->prop_index;
+       int val_index = config->val_index;
+       char **val_list = config->val_list;
+
+       /*
+        * Iterate through each keyword and look for a property that matches it.
+        */
+       again:
+       if (!val_list) {
+               for (; prop_index < (sizeof(keywords)/sizeof(keywords[0])); prop_index++)
+               {
+                       ni_namelist namelist;
+                       struct keyword current_prop = keywords[prop_index];
+
+                       /*
+                        * For each value associated in the property, we're going to return
+                        * a separate line. We squirrel away the values in the config state
+                        * so the next time through, we don't need to do this lookup.
+                        */
+                       NI_INIT(&namelist);
+                       if (ni_lookupprop(config->domain, &config->config_dir, current_prop.text, &namelist) == NI_OK) {
+                               ni_index index;
+
+                               /* Found the property, but it has no values */
+                               if (namelist.ni_namelist_len == 0) continue;
+
+                               if (! (val_list = config->val_list = (char**)malloc(sizeof(char*) * (namelist.ni_namelist_len + 1))))
+                                       { msyslog(LOG_ERR, "out of memory while configuring"); break; }
+
+                               for (index = 0; index < namelist.ni_namelist_len; index++) {
+                                       char *value = namelist.ni_namelist_val[index];
+
+                                       if (! (val_list[index] = (char*)malloc(strlen(value)+1)))
+                                               { msyslog(LOG_ERR, "out of memory while configuring"); break; }
+
+                                       strcpy(val_list[index], value);
+                               }
+                               val_list[index] = NULL;
+
+                               break;
+                       }
+                       ni_namelist_free(&namelist);
+               }
+               config->prop_index = prop_index;
+       }
+
+       /* No list; we're done here. */
+               if (!val_list) return CONFIG_UNKNOWN;
+
+       /*
+        * We have a list of values for the current property.
+        * Iterate through them and return each in order.
+        */
+       if (val_list[val_index])
+       {
+               int ntok = 1;
+               int quoted = 0;
+               char *tokens = val_list[val_index];
+
+               msyslog(LOG_INFO, "%s %s", keywords[prop_index].text, val_list[val_index]);
+
+               (const char*)tokenlist[0] = keywords[prop_index].text;
+               for (ntok = 1; ntok < MAXTOKENS; ntok++) {
+                       tokenlist[ntok] = tokens;
+                       while (!ISEOL(*tokens) && (!ISSPACE(*tokens) || quoted))
+                               quoted ^= (*tokens++ == '"');
+
+                       if (ISEOL(*tokens)) {
+                               *tokens = '\0';
+                               break;
+                       } else {                /* must be space */
+                               *tokens++ = '\0';
+                               while (ISSPACE(*tokens)) tokens++;
+                               if (ISEOL(*tokens)) break;
+                       }
+               }
+
+               if (ntok == MAXTOKENS) {
+                       /* HMS: chomp it to lose the EOL? */
+                       msyslog(LOG_ERR,
+                           "gettokens_netinfo: too many tokens.  Ignoring: %s",
+                           tokens);
+               } else {
+                       *ntokens = ntok + 1;
+               }
+
+               config->val_index++;    /* HMS: Should this be in the 'else'? */
+
+               return keywords[prop_index].keytype;
+       }
+
+       /* We're done with the current property. */
+       prop_index = ++config->prop_index;
+
+       /* Free val_list and reset counters. */
+       for (val_index = 0; val_list[val_index]; val_index++)
+               free(val_list[val_index]);
+               free(val_list); val_list = config->val_list = NULL; val_index = config->val_index = 0;
+
+       goto again;
+}
+
+#endif /* HAVE_NETINFO */
+
+
+/*
+ * gettokens - read a line and return tokens
+ */
+static int
+gettokens (
+       FILE *fp,
+       char *line,
+       char **tokenlist,
+       int *ntokens
+       )
+{
+       register char *cp;
+       register int ntok;
+       register int quoted = 0;
+
+       /*
+        * Find start of first token
+        */
+       again:
+       while ((cp = fgets(line, MAXLINE, fp)) != NULL) {
+               cp = line;
+               while (ISSPACE(*cp))
+                       cp++;
+               if (!ISEOL(*cp))
+                       break;
+       }
+       if (cp == NULL) {
+               *ntokens = 0;
+               return CONFIG_UNKNOWN;  /* hack.  Is recognized as EOF */
+       }
+
+       /*
+        * Now separate out the tokens
+        */
+       for (ntok = 0; ntok < MAXTOKENS; ntok++) {
+               tokenlist[ntok] = cp;
+               while (!ISEOL(*cp) && (!ISSPACE(*cp) || quoted))
+                       quoted ^= (*cp++ == '"');
+
+               if (ISEOL(*cp)) {
+                       *cp = '\0';
+                       break;
+               } else {                /* must be space */
+                       *cp++ = '\0';
+                       while (ISSPACE(*cp))
+                               cp++;
+                       if (ISEOL(*cp))
+                               break;
+               }
+       }
+
+     /* Heiko: Remove leading and trailing quotes around tokens */
+     {
+            int i,j = 0;
+           
+               
+                       for (i = 0; i < ntok; i++) {        
+                                       /* Now check if the first char is a quote and remove that */
+                                       if ( tokenlist[ntok][0] == '"' )
+                                                       tokenlist[ntok]++;
+
+                                       /* Now check the last char ... */
+                                       j = strlen(tokenlist[ntok])-1;
+                                       if ( tokenlist[ntok][j] == '"' )
+                                                       tokenlist[ntok][j] = '\0';
+                       }
+                                                       
+    }
+
+       if (ntok == MAXTOKENS) {
+               --ntok;
+               /* HMS: chomp it to lose the EOL? */
+               msyslog(LOG_ERR,
+                   "gettokens: too many tokens on the line. Ignoring %s",
+                   cp);
+       } else {
+               /*
+                * Return the match
+                */
+               *ntokens = ntok + 1;
+               ntok = matchkey(tokenlist[0], keywords, 1);
+               if (ntok == CONFIG_UNKNOWN)
+                       goto again;
+       }
+
+       return ntok;
+}
+
+
+
+/*
+ * matchkey - match a keyword to a list
+ */
+static int
+matchkey(
+       register char *word,
+       register struct keyword *keys,
+       int complain
+       )
+{
+       for (;;) {
+               if (keys->keytype == CONFIG_UNKNOWN) {
+                       if (complain)
+                               msyslog(LOG_ERR,
+                                   "configure: keyword \"%s\" unknown, line ignored",
+                                   word);
+                       return CONFIG_UNKNOWN;
+               }
+               if (STRSAME(word, keys->text))
+                       return keys->keytype;
+               keys++;
+       }
+}
+
+
+/*
+ * getnetnum - return a net number (this is crude, but careful)
+ */
+static int
+getnetnum(
+       const char *num,
+       struct sockaddr_storage *addr,
+       int complain,
+       enum gnn_type a_type
+       )
+{
+       struct addrinfo hints;
+       struct addrinfo *ptr;
+       int retval;
+
+#if 0
+       printf("getnetnum: <%s> is a %s (%d)\n",
+               num,
+               (a_type == t_UNK)
+               ? "t_UNK"
+               : (a_type == t_REF)
+                 ? "t_REF"
+                 : (a_type == t_MSK)
+                   ? "t_MSK"
+                   : "???",
+               a_type);
+#endif
+
+       /* Get host address. Looking for UDP datagram connection */
+       memset(&hints, 0, sizeof (hints));
+       if (addr->ss_family == AF_INET || addr->ss_family == AF_INET6)
+           hints.ai_family = addr->ss_family;
+       else
+           hints.ai_family = AF_UNSPEC;
+       /*
+        * If we don't have an IPv6 stack, just look up IPv4 addresses
+        */
+       if (isc_net_probeipv6() != ISC_R_SUCCESS)
+               hints.ai_family = AF_INET;
+
+       hints.ai_socktype = SOCK_DGRAM;
+
+       if (a_type != t_UNK) {
+               hints.ai_flags = AI_NUMERICHOST;
+       }
+
+#ifdef DEBUG
+       if (debug > 3)
+               printf("getnetnum: calling getaddrinfo(%s,...)\n", num);
+#endif
+       retval = getaddrinfo(num, "ntp", &hints, &ptr);
+       if (retval != 0 ||
+          (ptr->ai_family == AF_INET6 && isc_net_probeipv6() != ISC_R_SUCCESS)) {
+               if (complain)
+                       msyslog(LOG_ERR,
+                               "getaddrinfo: \"%s\" invalid host address, ignored",
+                               num);
+#ifdef DEBUG
+               if (debug > 0)
+                       printf(
+                               "getaddrinfo: \"%s\" invalid host address%s.\n",
+                               num, (complain)
+                               ? ", ignored"
+                               : "");
+#endif
+               if (retval == 0 && 
+                   ptr->ai_family == AF_INET6 && 
+                   isc_net_probeipv6() != ISC_R_SUCCESS) 
+               {
+                       return -1;
+               }
+               else {
+                       return 0;
+               }
+       }
+
+       memcpy(addr, ptr->ai_addr, ptr->ai_addrlen);
+#ifdef DEBUG
+       if (debug > 1)
+               printf("getnetnum given %s, got %s (%s/%d)\n",
+                  num, stoa(addr),
+                       (a_type == t_UNK)
+                       ? "t_UNK"
+                       : (a_type == t_REF)
+                         ? "t_REF"
+                         : (a_type == t_MSK)
+                           ? "t_MSK"
+                           : "???",
+                       a_type);
+#endif
+        freeaddrinfo(ptr);
+       return 1;
+}
+
+
+#if !defined(VMS) && !defined(SYS_WINNT)
+/*
+ * catchchild - receive the resolver's exit status
+ */
+static RETSIGTYPE
+catchchild(
+       int sig
+       )
+{
+       /*
+        * We only start up one child, and if we're here
+        * it should have already exited.  Hence the following
+        * shouldn't hang.  If it does, please tell me.
+        */
+#if !defined (SYS_WINNT) && !defined(SYS_VXWORKS)
+       (void) wait(0);
+#endif /* SYS_WINNT  && VXWORKS*/
+}
+#endif /* VMS */
+
+
+/*
+ * save_resolve - save configuration info into a file for later name resolution
+ */
+static void
+save_resolve(
+       char *name,
+       int mode,
+       int version,
+       int minpoll,
+       int maxpoll,
+       u_int flags,
+       int ttl,
+       keyid_t keyid,
+       u_char *keystr
+       )
+{
+#ifndef SYS_VXWORKS
+       if (res_fp == NULL) {
+#ifndef SYS_WINNT
+               (void) strcpy(res_file, RES_TEMPFILE);
+#else
+               /* no /tmp directory under NT */
+               {
+                       if(!(GetTempPath((DWORD)MAX_PATH, (LPTSTR)res_file))) {
+                               msyslog(LOG_ERR, "cannot get pathname for temporary directory: %m");
+                               return;
+                       }
+                       (void) strcat(res_file, "ntpdXXXXXX");
+               }
+#endif /* SYS_WINNT */
+#ifdef HAVE_MKSTEMP
+               {
+                       int fd;
+
+                       res_fp = NULL;
+                       if ((fd = mkstemp(res_file)) != -1)
+                               res_fp = fdopen(fd, "r+");
+               }
+#else
+               (void) mktemp(res_file);
+               res_fp = fopen(res_file, "w");
+#endif
+               if (res_fp == NULL) {
+                       msyslog(LOG_ERR, "open failed for %s: %m", res_file);
+                       return;
+               }
+       }
+#ifdef DEBUG
+       if (debug) {
+               printf("resolving %s\n", name);
+       }
+#endif
+
+       (void)fprintf(res_fp, "%s %d %d %d %d %d %d %u %s\n", name,
+           mode, version, minpoll, maxpoll, flags, ttl, keyid, keystr);
+#ifdef DEBUG
+       if (debug > 1)
+               printf("config: %s %d %d %d %d %x %d %u %s\n", name, mode,
+                   version, minpoll, maxpoll, flags, ttl, keyid, keystr);
+#endif
+
+#else  /* SYS_VXWORKS */
+       /* save resolve info to a struct */
+#endif /* SYS_VXWORKS */
+}
+
+
+/*
+ * abort_resolve - terminate the resolver stuff and delete the file
+ */
+static void
+abort_resolve(void)
+{
+       /*
+        * In an ideal world we would might reread the file and
+        * log the hosts which aren't getting configured.  Since
+        * this is too much work, however, just close and delete
+        * the temp file.
+        */
+       if (res_fp != NULL)
+               (void) fclose(res_fp);
+       res_fp = NULL;
+
+#ifndef SYS_VXWORKS            /* we don't open the file to begin with */
+#if !defined(VMS)
+       (void) unlink(res_file);
+#else
+       (void) delete(res_file);
+#endif /* VMS */
+#endif /* SYS_VXWORKS */
+}
+
+
+/*
+ * do_resolve_internal - start up the resolver function (not program)
+ */
+/*
+ * On VMS, this routine will simply refuse to resolve anything.
+ *
+ * Possible implementation: keep `res_file' in memory, do async
+ * name resolution via QIO, update from within completion AST.
+ * I'm unlikely to find the time for doing this, though. -wjm
+ */
+static void
+do_resolve_internal(void)
+{
+       int i;
+
+       if (res_fp == NULL) {
+               /* belch */
+               msyslog(LOG_ERR,
+                       "do_resolve_internal: Fatal: res_fp == NULL");
+               exit(1);
+       }
+
+       /* we are done with this now */
+       (void) fclose(res_fp);
+       res_fp = NULL;
+
+#if !defined(VMS) && !defined (SYS_VXWORKS)
+       req_file = res_file;    /* set up pointer to res file */
+#ifndef SYS_WINNT
+       (void) signal_no_reset(SIGCHLD, catchchild);
+
+#ifndef SYS_VXWORKS
+       /* the parent process will write to the pipe
+        * in order to wake up to child process
+        * which may be waiting in a select() call
+        * on the read fd */
+       if (pipe(resolver_pipe_fd) < 0) {
+               msyslog(LOG_ERR,
+                       "unable to open resolver pipe");
+               exit(1);
+       }
+
+       i = fork();
+       /* Shouldn't the code below be re-ordered?
+        * I.e. first check if the fork() returned an error, then
+        * check whether we're parent or child.
+        *     Martin Burnicki
+        */
+       if (i == 0) {
+               /*
+                * this used to close everything
+                * I don't think this is necessary
+                */
+               /*
+                * To the unknown commenter above:
+                * Well, I think it's better to clean up
+                * after oneself. I have had problems with
+                * refclock-io when intres was running - things
+                * where fine again when ntpintres was gone.
+                * So some systems react erratic at least.
+                *
+                *                      Frank Kardel
+                *
+                * 94-11-16:
+                * Further debugging has proven that the above is
+                * absolutely harmful. The internal resolver
+                * is still in the SIGIO process group and the lingering
+                * async io information causes it to process requests from
+                * all file decriptor causing a race between the NTP daemon
+                * and the resolver. which then eats data when it wins 8-(.
+                * It is absolutly necessary to kill any IO associations
+                * shared with the NTP daemon.
+                *
+                * We also block SIGIO (currently no ports means to
+                * disable the signal handle for IO).
+                *
+                * Thanks to wgstuken@informatik.uni-erlangen.de to notice
+                * that it is the ntp-resolver child running into trouble.
+                *
+                * THUS:
+                */
+
+               /* This is the child process who will read the pipe,
+                * so we close the write fd */
+               close(resolver_pipe_fd[1]);
+               closelog();
+               kill_asyncio(0);
+
+               (void) signal_no_reset(SIGCHLD, SIG_DFL);
+
+#ifdef DEBUG
+               if (0)
+                   debug = 2;
+#endif
+
+# ifndef LOG_DAEMON
+               openlog("ntpd_initres", LOG_PID);
+# else /* LOG_DAEMON */
+
+#  ifndef LOG_NTP
+#   define     LOG_NTP LOG_DAEMON
+#  endif
+               openlog("ntpd_initres", LOG_PID | LOG_NDELAY, LOG_NTP);
+#ifndef SYS_CYGWIN32
+#  ifdef DEBUG
+               if (debug)
+                   setlogmask(LOG_UPTO(LOG_DEBUG));
+               else
+#  endif /* DEBUG */
+                   setlogmask(LOG_UPTO(LOG_DEBUG)); /* @@@ was INFO */
+# endif /* LOG_DAEMON */
+#endif
+
+               ntp_intres();
+
+               /*
+                * If we got here, the intres code screwed up.
+                * Print something so we don't die without complaint
+                */
+               msyslog(LOG_ERR, "call to ntp_intres lost");
+               abort_resolve();
+               exit(1);
+       }
+#else
+        /* vxWorks spawns a thread... -casey */
+        i = sp (ntp_intres);
+        /*i = taskSpawn("ntp_intres",100,VX_FP_TASK,20000,ntp_intres);*/
+#endif
+       if (i == -1) {
+               msyslog(LOG_ERR, "fork() failed, can't start ntp_intres: %m");
+               (void) signal_no_reset(SIGCHLD, SIG_DFL);
+               abort_resolve();
+       }
+       else {
+               /* This is the parent process who will write to the pipe,
+                * so we close the read fd */
+               close(resolver_pipe_fd[0]);
+       }
+#else /* SYS_WINNT */
+       {
+               /* NT's equivalent of fork() is _spawn(), but the start point
+                * of the new process is an executable filename rather than
+                * a function name as desired here.
+                */
+               DWORD dwThreadId;
+               fflush(stdout);
+               ResolverEventHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
+               if (ResolverEventHandle == NULL) {
+                       msyslog(LOG_ERR, "Unable to create resolver event object, can't start ntp_intres");
+                       abort_resolve();
+               }
+               ResolverThreadHandle = CreateThread(
+                       NULL,                            /* no security attributes      */
+                       0,                               /* use default stack size      */
+                       (LPTHREAD_START_ROUTINE) ntp_intres, /* thread function         */
+                       NULL,                            /* argument to thread function   */
+                       0,                               /* use default creation flags    */
+                       &dwThreadId);                    /* returns the thread identifier */
+               if (ResolverThreadHandle == NULL) {
+                       msyslog(LOG_ERR, "CreateThread() failed, can't start ntp_intres");
+                       CloseHandle(ResolverEventHandle);
+                       ResolverEventHandle = NULL;
+                       abort_resolve();
+               }
+       }
+#endif /* SYS_WINNT */
+#else /* VMS  VX_WORKS */
+       msyslog(LOG_ERR,
+               "Name resolution not implemented for VMS - use numeric addresses");
+       abort_resolve();
+#endif /* VMS VX_WORKS */
+}
diff --git a/ntpd/ntp_control.c b/ntpd/ntp_control.c
new file mode 100644 (file)
index 0000000..64603d3
--- /dev/null
@@ -0,0 +1,2996 @@
+/*
+ * ntp_control.c - respond to control messages and send async traps
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_control.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+/*
+ * Structure to hold request procedure information
+ */
+#define NOAUTH 0
+#define AUTH   1
+
+#define NO_REQUEST     (-1)
+
+struct ctl_proc {
+       short control_code;             /* defined request code */
+       u_short flags;                  /* flags word */
+       void (*handler) P((struct recvbuf *, int)); /* handle request */
+};
+
+/*
+ * Only one flag.  Authentication required or not.
+ */
+#define NOAUTH 0
+#define AUTH   1
+
+/*
+ * Request processing routines
+ */
+static void    ctl_error       P((int));
+#ifdef REFCLOCK
+static u_short ctlclkstatus    P((struct refclockstat *));
+#endif
+static void    ctl_flushpkt    P((int));
+static void    ctl_putdata     P((const char *, unsigned int, int));
+static void    ctl_putstr      P((const char *, const char *,
+                                   unsigned int));
+static void    ctl_putdbl      P((const char *, double));
+static void    ctl_putuint     P((const char *, u_long));
+static void    ctl_puthex      P((const char *, u_long));
+static void    ctl_putint      P((const char *, long));
+static void    ctl_putts       P((const char *, l_fp *));
+static void    ctl_putadr      P((const char *, u_int32, struct sockaddr_storage*));
+static void    ctl_putid       P((const char *, char *));
+static void    ctl_putarray    P((const char *, double *, int));
+static void    ctl_putsys      P((int));
+static void    ctl_putpeer     P((int, struct peer *));
+#ifdef OPENSSL
+static void    ctl_putfs       P((const char *, tstamp_t));
+#endif
+#ifdef REFCLOCK
+static void    ctl_putclock    P((int, struct refclockstat *, int));
+#endif /* REFCLOCK */
+static struct ctl_var *ctl_getitem P((struct ctl_var *, char **));
+static u_long count_var        P((struct ctl_var *));
+static void    control_unspec  P((struct recvbuf *, int));
+static void    read_status     P((struct recvbuf *, int));
+static void    read_variables  P((struct recvbuf *, int));
+static void    write_variables P((struct recvbuf *, int));
+static void    read_clock_status P((struct recvbuf *, int));
+static void    write_clock_status P((struct recvbuf *, int));
+static void    set_trap        P((struct recvbuf *, int));
+static void    unset_trap      P((struct recvbuf *, int));
+static struct ctl_trap *ctlfindtrap P((struct sockaddr_storage *,
+                                   struct interface *));
+
+static struct ctl_proc control_codes[] = {
+       { CTL_OP_UNSPEC,        NOAUTH, control_unspec },
+       { CTL_OP_READSTAT,      NOAUTH, read_status },
+       { CTL_OP_READVAR,       NOAUTH, read_variables },
+       { CTL_OP_WRITEVAR,      AUTH,   write_variables },
+       { CTL_OP_READCLOCK,     NOAUTH, read_clock_status },
+       { CTL_OP_WRITECLOCK,    NOAUTH, write_clock_status },
+       { CTL_OP_SETTRAP,       NOAUTH, set_trap },
+       { CTL_OP_UNSETTRAP,     NOAUTH, unset_trap },
+       { NO_REQUEST,           0 }
+};
+
+/*
+ * System variable values. The array can be indexed by the variable
+ * index to find the textual name.
+ */
+static struct ctl_var sys_var[] = {
+       { 0,            PADDING, "" },          /* 0 */
+       { CS_LEAP,      RW, "leap" },           /* 1 */
+       { CS_STRATUM,   RO, "stratum" },        /* 2 */
+       { CS_PRECISION, RO, "precision" },      /* 3 */
+       { CS_ROOTDELAY, RO, "rootdelay" },      /* 4 */
+       { CS_ROOTDISPERSION, RO, "rootdispersion" }, /* 5 */
+       { CS_REFID,     RO, "refid" },          /* 6 */
+       { CS_REFTIME,   RO, "reftime" },        /* 7 */
+       { CS_POLL,      RO, "poll" },           /* 8 */
+       { CS_PEERID,    RO, "peer" },           /* 9 */
+       { CS_STATE,     RO, "state" },          /* 10 */
+       { CS_OFFSET,    RO, "offset" },         /* 11 */
+       { CS_DRIFT,     RO, "frequency" },      /* 12 */
+       { CS_JITTER,    RO, "jitter" },         /* 13 */
+       { CS_ERROR,     RO, "noise" },          /* 14 */
+       { CS_CLOCK,     RO, "clock" },          /* 15 */
+       { CS_PROCESSOR, RO, "processor" },      /* 16 */
+       { CS_SYSTEM,    RO, "system" },         /* 17 */
+       { CS_VERSION,   RO, "version" },        /* 18 */
+       { CS_STABIL,    RO, "stability" },      /* 19 */
+       { CS_VARLIST,   RO, "sys_var_list" },   /* 20 */
+#ifdef OPENSSL
+       { CS_FLAGS,     RO, "flags" },          /* 21 */
+       { CS_HOST,      RO, "hostname" },       /* 22 */
+       { CS_PUBLIC,    RO, "update" },         /* 23 */
+       { CS_CERTIF,    RO, "cert" },           /* 24 */
+       { CS_REVTIME,   RO, "expire" },         /* 25 */
+       { CS_LEAPTAB,   RO, "leapsec" },        /* 26 */
+       { CS_TAI,       RO, "tai" },            /* 27 */
+       { CS_DIGEST,    RO, "signature" },      /* 28 */
+       { CS_IDENT,     RO, "ident" },          /* 29 */
+       { CS_REVOKE,    RO, "expire" },         /* 30 */
+#endif /* OPENSSL */
+       { 0,            EOV, "" }               /* 21/31 */
+};
+
+static struct ctl_var *ext_sys_var = (struct ctl_var *)0;
+
+/*
+ * System variables we print by default (in fuzzball order,
+ * more-or-less)
+ */
+static u_char def_sys_var[] = {
+       CS_VERSION,
+       CS_PROCESSOR,
+       CS_SYSTEM,
+       CS_LEAP,
+       CS_STRATUM,
+       CS_PRECISION,
+       CS_ROOTDELAY,
+       CS_ROOTDISPERSION,
+       CS_PEERID,
+       CS_REFID,
+       CS_REFTIME,
+       CS_POLL,
+       CS_CLOCK,
+       CS_STATE,
+       CS_OFFSET,
+       CS_DRIFT,
+       CS_JITTER,
+       CS_ERROR,
+       CS_STABIL,
+#ifdef OPENSSL
+       CS_HOST,
+       CS_DIGEST,
+       CS_FLAGS,
+       CS_PUBLIC,
+       CS_IDENT,
+       CS_LEAPTAB,
+       CS_TAI,
+       CS_CERTIF,
+#endif /* OPENSSL */
+       0
+};
+
+
+/*
+ * Peer variable list
+ */
+static struct ctl_var peer_var[] = {
+       { 0,            PADDING, "" },          /* 0 */
+       { CP_CONFIG,    RO, "config" },         /* 1 */
+       { CP_AUTHENABLE, RO,    "authenable" }, /* 2 */
+       { CP_AUTHENTIC, RO, "authentic" },      /* 3 */
+       { CP_SRCADR,    RO, "srcadr" },         /* 4 */
+       { CP_SRCPORT,   RO, "srcport" },        /* 5 */
+       { CP_DSTADR,    RO, "dstadr" },         /* 6 */
+       { CP_DSTPORT,   RO, "dstport" },        /* 7 */
+       { CP_LEAP,      RO, "leap" },           /* 8 */
+       { CP_HMODE,     RO, "hmode" },          /* 9 */
+       { CP_STRATUM,   RO, "stratum" },        /* 10 */
+       { CP_PPOLL,     RO, "ppoll" },          /* 11 */
+       { CP_HPOLL,     RO, "hpoll" },          /* 12 */
+       { CP_PRECISION, RO, "precision" },      /* 13 */
+       { CP_ROOTDELAY, RO, "rootdelay" },      /* 14 */
+       { CP_ROOTDISPERSION, RO, "rootdispersion" }, /* 15 */
+       { CP_REFID,     RO, "refid" },          /* 16 */
+       { CP_REFTIME,   RO, "reftime" },        /* 17 */
+       { CP_ORG,       RO, "org" },            /* 18 */
+       { CP_REC,       RO, "rec" },            /* 19 */
+       { CP_XMT,       RO, "xmt" },            /* 20 */
+       { CP_REACH,     RO, "reach" },          /* 21 */
+       { CP_UNREACH,   RO, "unreach" },        /* 22 */
+       { CP_TIMER,     RO, "timer" },          /* 23 */
+       { CP_DELAY,     RO, "delay" },          /* 24 */
+       { CP_OFFSET,    RO, "offset" },         /* 25 */
+       { CP_JITTER,    RO, "jitter" },         /* 26 */
+       { CP_DISPERSION, RO, "dispersion" },    /* 27 */
+       { CP_KEYID,     RO, "keyid" },          /* 28 */
+       { CP_FILTDELAY, RO, "filtdelay=" },     /* 29 */
+       { CP_FILTOFFSET, RO, "filtoffset=" },   /* 30 */
+       { CP_PMODE,     RO, "pmode" },          /* 31 */
+       { CP_RECEIVED,  RO, "received"},        /* 32 */
+       { CP_SENT,      RO, "sent" },           /* 33 */
+       { CP_FILTERROR, RO, "filtdisp=" },      /* 34 */
+       { CP_FLASH,     RO, "flash" },          /* 35 */
+       { CP_TTL,       RO, "ttl" },            /* 36 */
+       { CP_VARLIST,   RO, "peer_var_list" },  /* 37 */
+#ifdef OPENSSL
+       { CP_FLAGS,     RO, "flags" },          /* 38 */
+       { CP_HOST,      RO, "hostname" },       /* 39 */
+       { CP_VALID,     RO, "valid" },          /* 40 */
+       { CP_INITSEQ,   RO, "initsequence" },   /* 41 */
+       { CP_INITKEY,   RO, "initkey" },        /* 42 */
+       { CP_INITTSP,   RO, "timestamp" },      /* 43 */
+       { CP_DIGEST,    RO, "signature" },      /* 44 */
+       { CP_IDENT,     RO, "trust" },          /* 45 */
+#endif /* OPENSSL */
+       { 0,            EOV, "" }               /* 38/46 */
+};
+
+
+/*
+ * Peer variables we print by default
+ */
+static u_char def_peer_var[] = {
+       CP_SRCADR,
+       CP_SRCPORT,
+       CP_DSTADR,
+       CP_DSTPORT,
+       CP_LEAP,
+       CP_STRATUM,
+       CP_PRECISION,
+       CP_ROOTDELAY,
+       CP_ROOTDISPERSION,
+       CP_REFID,
+       CP_REACH,
+       CP_UNREACH,
+       CP_HMODE,
+       CP_PMODE,
+       CP_HPOLL,
+       CP_PPOLL,
+       CP_FLASH,
+       CP_KEYID,
+       CP_TTL,
+       CP_OFFSET,
+       CP_DELAY,
+       CP_DISPERSION,
+       CP_JITTER,
+       CP_REFTIME,
+       CP_ORG,
+       CP_REC,
+       CP_XMT,
+       CP_FILTDELAY,
+       CP_FILTOFFSET,
+       CP_FILTERROR,
+#ifdef OPENSSL
+       CP_HOST,
+       CP_DIGEST,
+       CP_VALID,
+       CP_FLAGS,
+       CP_IDENT,
+       CP_INITSEQ,
+#endif /* OPENSSL */
+       0
+};
+
+
+#ifdef REFCLOCK
+/*
+ * Clock variable list
+ */
+static struct ctl_var clock_var[] = {
+       { 0,            PADDING, "" },          /* 0 */
+       { CC_TYPE,      RO, "type" },           /* 1 */
+       { CC_TIMECODE,  RO, "timecode" },       /* 2 */
+       { CC_POLL,      RO, "poll" },           /* 3 */
+       { CC_NOREPLY,   RO, "noreply" },        /* 4 */
+       { CC_BADFORMAT, RO, "badformat" },      /* 5 */
+       { CC_BADDATA,   RO, "baddata" },        /* 6 */
+       { CC_FUDGETIME1, RO, "fudgetime1" },    /* 7 */
+       { CC_FUDGETIME2, RO, "fudgetime2" },    /* 8 */
+       { CC_FUDGEVAL1, RO, "stratum" },        /* 9 */
+       { CC_FUDGEVAL2, RO, "refid" },          /* 10 */
+       { CC_FLAGS,     RO, "flags" },          /* 11 */
+       { CC_DEVICE,    RO, "device" },         /* 12 */
+       { CC_VARLIST,   RO, "clock_var_list" }, /* 13 */
+       { 0,            EOV, ""  }              /* 14 */
+};
+
+
+/*
+ * Clock variables printed by default
+ */
+static u_char def_clock_var[] = {
+       CC_DEVICE,
+       CC_TYPE,        /* won't be output if device = known */
+       CC_TIMECODE,
+       CC_POLL,
+       CC_NOREPLY,
+       CC_BADFORMAT,
+       CC_BADDATA,
+       CC_FUDGETIME1,
+       CC_FUDGETIME2,
+       CC_FUDGEVAL1,
+       CC_FUDGEVAL2,
+       CC_FLAGS,
+       0
+};
+#endif
+
+
+/*
+ * System and processor definitions.
+ */
+#ifndef HAVE_UNAME
+# ifndef STR_SYSTEM
+#  define              STR_SYSTEM      "UNIX"
+# endif
+# ifndef STR_PROCESSOR
+#      define          STR_PROCESSOR   "unknown"
+# endif
+
+static char str_system[] = STR_SYSTEM;
+static char str_processor[] = STR_PROCESSOR;
+#else
+# include <sys/utsname.h>
+static struct utsname utsnamebuf;
+#endif /* HAVE_UNAME */
+
+/*
+ * Trap structures. We only allow a few of these, and send a copy of
+ * each async message to each live one. Traps time out after an hour, it
+ * is up to the trap receipient to keep resetting it to avoid being
+ * timed out.
+ */
+/* ntp_request.c */
+struct ctl_trap ctl_trap[CTL_MAXTRAPS];
+int num_ctl_traps;
+
+/*
+ * Type bits, for ctlsettrap() call.
+ */
+#define TRAP_TYPE_CONFIG       0       /* used by configuration code */
+#define TRAP_TYPE_PRIO         1       /* priority trap */
+#define TRAP_TYPE_NONPRIO      2       /* nonpriority trap */
+
+
+/*
+ * List relating reference clock types to control message time sources.
+ * Index by the reference clock type. This list will only be used iff
+ * the reference clock driver doesn't set peer->sstclktype to something
+ * different than CTL_SST_TS_UNSPEC.
+ */
+static u_char clocktypes[] = {
+       CTL_SST_TS_NTP,         /* REFCLK_NONE (0) */
+       CTL_SST_TS_LOCAL,       /* REFCLK_LOCALCLOCK (1) */
+       CTL_SST_TS_UHF,         /* deprecated REFCLK_GPS_TRAK (2) */
+       CTL_SST_TS_HF,          /* REFCLK_WWV_PST (3) */
+       CTL_SST_TS_LF,          /* REFCLK_WWVB_SPECTRACOM (4) */
+       CTL_SST_TS_UHF,         /* REFCLK_TRUETIME (5) */
+       CTL_SST_TS_UHF,         /* REFCLK_GOES_TRAK (6) IRIG_AUDIO? */
+       CTL_SST_TS_HF,          /* REFCLK_CHU (7) */
+       CTL_SST_TS_LF,          /* REFCLOCK_PARSE (default) (8) */
+       CTL_SST_TS_LF,          /* REFCLK_GPS_MX4200 (9) */
+       CTL_SST_TS_UHF,         /* REFCLK_GPS_AS2201 (10) */
+       CTL_SST_TS_UHF,         /* REFCLK_GPS_ARBITER (11) */
+       CTL_SST_TS_UHF,         /* REFCLK_IRIG_TPRO (12) */
+       CTL_SST_TS_ATOM,        /* REFCLK_ATOM_LEITCH (13) */
+       CTL_SST_TS_LF,          /* deprecated REFCLK_MSF_EES (14) */
+       CTL_SST_TS_NTP,         /* not used (15) */
+       CTL_SST_TS_UHF,         /* REFCLK_IRIG_BANCOMM (16) */
+       CTL_SST_TS_UHF,         /* REFCLK_GPS_DATU (17) */
+       CTL_SST_TS_TELEPHONE,   /* REFCLK_NIST_ACTS (18) */
+       CTL_SST_TS_HF,          /* REFCLK_WWV_HEATH (19) */
+       CTL_SST_TS_UHF,         /* REFCLK_GPS_NMEA (20) */
+       CTL_SST_TS_UHF,         /* REFCLK_GPS_VME (21) */
+       CTL_SST_TS_ATOM,        /* REFCLK_ATOM_PPS (22) */
+       CTL_SST_TS_NTP,         /* not used (23) */
+       CTL_SST_TS_NTP,         /* not used (24) */
+       CTL_SST_TS_NTP,         /* not used (25) */
+       CTL_SST_TS_UHF,         /* REFCLK_GPS_HP (26) */
+       CTL_SST_TS_TELEPHONE,   /* REFCLK_ARCRON_MSF (27) */
+       CTL_SST_TS_TELEPHONE,   /* REFCLK_SHM (28) */
+       CTL_SST_TS_UHF,         /* REFCLK_PALISADE (29) */
+       CTL_SST_TS_UHF,         /* REFCLK_ONCORE (30) */
+       CTL_SST_TS_UHF,         /* REFCLK_JUPITER (31) */
+       CTL_SST_TS_LF,          /* REFCLK_CHRONOLOG (32) */
+       CTL_SST_TS_LF,          /* REFCLK_DUMBCLOCK (33) */
+       CTL_SST_TS_LF,          /* REFCLK_ULINK (34) */
+       CTL_SST_TS_LF,          /* REFCLK_PCF (35) */
+       CTL_SST_TS_LF,          /* REFCLK_WWV (36) */
+       CTL_SST_TS_LF,          /* REFCLK_FG (37) */
+       CTL_SST_TS_UHF,         /* REFCLK_HOPF_SERIAL (38) */
+       CTL_SST_TS_UHF,         /* REFCLK_HOPF_PCI (39) */
+       CTL_SST_TS_LF,          /* REFCLK_JJY (40) */
+       CTL_SST_TS_UHF,         /* REFCLK_TT560 (41) */
+       CTL_SST_TS_UHF,         /* REFCLK_ZYFER (42) */
+       CTL_SST_TS_UHF,         /* REFCLK_RIPENCC (43) */
+       CTL_SST_TS_UHF,         /* REFCLK_NEOCLOCK4X (44) */
+};
+
+
+/*
+ * Keyid used for authenticating write requests.
+ */
+keyid_t ctl_auth_keyid;
+
+/*
+ * We keep track of the last error reported by the system internally
+ */
+static u_char ctl_sys_last_event;
+static u_char ctl_sys_num_events;
+
+
+/*
+ * Statistic counters to keep track of requests and responses.
+ */
+u_long ctltimereset;           /* time stats reset */
+u_long numctlreq;              /* number of requests we've received */
+u_long numctlbadpkts;          /* number of bad control packets */
+u_long numctlresponses;        /* number of resp packets sent with data */
+u_long numctlfrags;            /* number of fragments sent */
+u_long numctlerrors;           /* number of error responses sent */
+u_long numctltooshort;         /* number of too short input packets */
+u_long numctlinputresp;        /* number of responses on input */
+u_long numctlinputfrag;        /* number of fragments on input */
+u_long numctlinputerr;         /* number of input pkts with err bit set */
+u_long numctlbadoffset;        /* number of input pkts with nonzero offset */
+u_long numctlbadversion;       /* number of input pkts with unknown version */
+u_long numctldatatooshort;     /* data too short for count */
+u_long numctlbadop;            /* bad op code found in packet */
+u_long numasyncmsgs;           /* number of async messages we've sent */
+
+/*
+ * Response packet used by these routines. Also some state information
+ * so that we can handle packet formatting within a common set of
+ * subroutines.  Note we try to enter data in place whenever possible,
+ * but the need to set the more bit correctly means we occasionally
+ * use the extra buffer and copy.
+ */
+static struct ntp_control rpkt;
+static u_char  res_version;
+static u_char  res_opcode;
+static associd_t res_associd;
+static int     res_offset;
+static u_char * datapt;
+static u_char * dataend;
+static int     datalinelen;
+static int     datanotbinflag;
+static struct sockaddr_storage *rmt_addr;
+static struct interface *lcl_inter;
+
+static u_char  res_authenticate;
+static u_char  res_authokay;
+static keyid_t res_keyid;
+
+#define MAXDATALINELEN (72)
+
+static u_char  res_async;      /* set to 1 if this is async trap response */
+
+/*
+ * Pointers for saving state when decoding request packets
+ */
+static char *reqpt;
+static char *reqend;
+
+/*
+ * init_control - initialize request data
+ */
+void
+init_control(void)
+{
+       int i;
+
+#ifdef HAVE_UNAME
+       uname(&utsnamebuf);
+#endif /* HAVE_UNAME */
+
+       ctl_clr_stats();
+
+       ctl_auth_keyid = 0;
+       ctl_sys_last_event = EVNT_UNSPEC;
+       ctl_sys_num_events = 0;
+
+       num_ctl_traps = 0;
+       for (i = 0; i < CTL_MAXTRAPS; i++)
+               ctl_trap[i].tr_flags = 0;
+}
+
+
+/*
+ * ctl_error - send an error response for the current request
+ */
+static void
+ctl_error(
+       int errcode
+       )
+{
+#ifdef DEBUG
+       if (debug >= 4)
+               printf("sending control error %d\n", errcode);
+#endif
+       /*
+        * Fill in the fields. We assume rpkt.sequence and rpkt.associd
+        * have already been filled in.
+        */
+       rpkt.r_m_e_op = (u_char) (CTL_RESPONSE|CTL_ERROR|(res_opcode &
+           CTL_OP_MASK));
+       rpkt.status = htons((u_short) ((errcode<<8) & 0xff00));
+       rpkt.count = 0;
+
+       /*
+        * send packet and bump counters
+        */
+       if (res_authenticate && sys_authenticate) {
+               int maclen;
+
+               *(u_int32 *)((u_char *)&rpkt + CTL_HEADER_LEN) =
+                   htonl(res_keyid);
+               maclen = authencrypt(res_keyid, (u_int32 *)&rpkt,
+                   CTL_HEADER_LEN);
+               sendpkt(rmt_addr, lcl_inter, -2, (struct pkt *)&rpkt,
+                   CTL_HEADER_LEN + maclen);
+       } else {
+               sendpkt(rmt_addr, lcl_inter, -3, (struct pkt *)&rpkt,
+                   CTL_HEADER_LEN);
+       }
+       numctlerrors++;
+}
+
+
+/*
+ * process_control - process an incoming control message
+ */
+void
+process_control(
+       struct recvbuf *rbufp,
+       int restrict_mask
+       )
+{
+       register struct ntp_control *pkt;
+       register int req_count;
+       register int req_data;
+       register struct ctl_proc *cc;
+       int properlen;
+       int maclen;
+
+#ifdef DEBUG
+       if (debug > 2)
+               printf("in process_control()\n");
+#endif
+
+       /*
+        * Save the addresses for error responses
+        */
+       numctlreq++;
+       rmt_addr = &rbufp->recv_srcadr;
+       lcl_inter = rbufp->dstadr;
+       pkt = (struct ntp_control *)&rbufp->recv_pkt;
+
+       /*
+        * If the length is less than required for the header, or
+        * it is a response or a fragment, ignore this.
+        */
+       if (rbufp->recv_length < CTL_HEADER_LEN
+           || pkt->r_m_e_op & (CTL_RESPONSE|CTL_MORE|CTL_ERROR)
+           || pkt->offset != 0) {
+#ifdef DEBUG
+               if (debug)
+                       printf("invalid format in control packet\n");
+#endif
+               if (rbufp->recv_length < CTL_HEADER_LEN)
+                       numctltooshort++;
+               if (pkt->r_m_e_op & CTL_RESPONSE)
+                       numctlinputresp++;
+               if (pkt->r_m_e_op & CTL_MORE)
+                       numctlinputfrag++;
+               if (pkt->r_m_e_op & CTL_ERROR)
+                       numctlinputerr++;
+               if (pkt->offset != 0)
+                       numctlbadoffset++;
+               return;
+       }
+       res_version = PKT_VERSION(pkt->li_vn_mode);
+       if (res_version > NTP_VERSION || res_version < NTP_OLDVERSION) {
+#ifdef DEBUG
+               if (debug)
+                       printf("unknown version %d in control packet\n",
+                          res_version);
+#endif
+               numctlbadversion++;
+               return;
+       }
+
+       /*
+        * Pull enough data from the packet to make intelligent
+        * responses
+        */
+       rpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap, res_version,
+           MODE_CONTROL);
+       res_opcode = pkt->r_m_e_op;
+       rpkt.sequence = pkt->sequence;
+       rpkt.associd = pkt->associd;
+       rpkt.status = 0;
+       res_offset = 0;
+       res_associd = htons(pkt->associd);
+       res_async = 0;
+       res_authenticate = 0;
+       res_keyid = 0;
+       res_authokay = 0;
+       req_count = (int)htons(pkt->count);
+       datanotbinflag = 0;
+       datalinelen = 0;
+       datapt = rpkt.data;
+       dataend = &(rpkt.data[CTL_MAX_DATA_LEN]);
+
+       /*
+        * We're set up now. Make sure we've got at least enough
+        * incoming data space to match the count.
+        */
+       req_data = rbufp->recv_length - CTL_HEADER_LEN;
+       if (req_data < req_count || rbufp->recv_length & 0x3) {
+               ctl_error(CERR_BADFMT);
+               numctldatatooshort++;
+               return;
+       }
+
+       properlen = req_count + CTL_HEADER_LEN;
+#ifdef DEBUG
+       if (debug > 2 && (rbufp->recv_length & 0x3) != 0)
+               printf("Packet length %d unrounded\n",
+                   rbufp->recv_length);
+#endif
+       /* round up proper len to a 8 octet boundary */
+
+       properlen = (properlen + 7) & ~7;
+       maclen = rbufp->recv_length - properlen;
+       if ((rbufp->recv_length & (sizeof(u_long) - 1)) == 0 &&
+           maclen >= MIN_MAC_LEN && maclen <= MAX_MAC_LEN &&
+           sys_authenticate) {
+               res_authenticate = 1;
+               res_keyid = ntohl(*(u_int32 *)((u_char *)pkt +
+                   properlen));
+
+#ifdef DEBUG
+               if (debug > 2)
+                       printf(
+                           "recv_len %d, properlen %d, wants auth with keyid %08x, MAC length=%d\n",
+                           rbufp->recv_length, properlen, res_keyid, maclen);
+#endif
+               if (!authistrusted(res_keyid)) {
+#ifdef DEBUG
+                       if (debug > 2)
+                               printf("invalid keyid %08x\n",
+                                   res_keyid);
+#endif
+               } else if (authdecrypt(res_keyid, (u_int32 *)pkt,
+                   rbufp->recv_length - maclen, maclen)) {
+#ifdef DEBUG
+                       if (debug > 2)
+                               printf("authenticated okay\n");
+#endif
+                       res_authokay = 1;
+               } else {
+#ifdef DEBUG
+                       if (debug > 2)
+                               printf("authentication failed\n");
+#endif
+                       res_keyid = 0;
+               }
+       }
+
+       /*
+        * Set up translate pointers
+        */
+       reqpt = (char *)pkt->data;
+       reqend = reqpt + req_count;
+
+       /*
+        * Look for the opcode processor
+        */
+       for (cc = control_codes; cc->control_code != NO_REQUEST; cc++) {
+               if (cc->control_code == res_opcode) {
+#ifdef DEBUG
+                       if (debug > 2)
+                               printf("opcode %d, found command handler\n",
+                                   res_opcode);
+#endif
+                       if (cc->flags == AUTH && (!res_authokay ||
+                           res_keyid != ctl_auth_keyid)) {
+                               ctl_error(CERR_PERMISSION);
+                               return;
+                       }
+                       (cc->handler)(rbufp, restrict_mask);
+                       return;
+               }
+       }
+
+       /*
+        * Can't find this one, return an error.
+        */
+       numctlbadop++;
+       ctl_error(CERR_BADOP);
+       return;
+}
+
+
+/*
+ * ctlpeerstatus - return a status word for this peer
+ */
+u_short
+ctlpeerstatus(
+       register struct peer *peer
+       )
+{
+       register u_short status;
+
+       status = peer->status;
+       if (peer->flags & FLAG_CONFIG)
+               status |= CTL_PST_CONFIG;
+       if (peer->flags & FLAG_AUTHENABLE)
+               status |= CTL_PST_AUTHENABLE;
+       if (peer->flags & FLAG_AUTHENTIC)
+               status |= CTL_PST_AUTHENTIC;
+       if (peer->reach != 0)
+               status |= CTL_PST_REACH;
+       return (u_short)CTL_PEER_STATUS(status, peer->num_events,
+           peer->last_event);
+}
+
+
+/*
+ * ctlclkstatus - return a status word for this clock
+ */
+#ifdef REFCLOCK
+static u_short
+ctlclkstatus(
+       struct refclockstat *this_clock
+       )
+{
+       return ((u_short)(((this_clock->currentstatus) << 8) |
+           (this_clock->lastevent)));
+}
+#endif
+
+
+/*
+ * ctlsysstatus - return the system status word
+ */
+u_short
+ctlsysstatus(void)
+{
+       register u_char this_clock;
+
+       this_clock = CTL_SST_TS_UNSPEC;
+#ifdef REFCLOCK
+       if (sys_peer != 0) {
+               if (sys_peer->sstclktype != CTL_SST_TS_UNSPEC) {
+                       this_clock = sys_peer->sstclktype;
+                       if (pps_control)
+                               this_clock |= CTL_SST_TS_PPS;
+               } else {
+                       if (sys_peer->refclktype < sizeof(clocktypes))
+                               this_clock =
+                                   clocktypes[sys_peer->refclktype];
+                       if (pps_control)
+                               this_clock |= CTL_SST_TS_PPS;
+               }
+       }
+#endif /* REFCLOCK */
+       return (u_short)CTL_SYS_STATUS(sys_leap, this_clock,
+           ctl_sys_num_events, ctl_sys_last_event);
+}
+
+
+/*
+ * ctl_flushpkt - write out the current packet and prepare
+ *               another if necessary.
+ */
+static void
+ctl_flushpkt(
+       int more
+       )
+{
+       int dlen;
+       int sendlen;
+
+       if (!more && datanotbinflag) {
+               /*
+                * Big hack, output a trailing \r\n
+                */
+               *datapt++ = '\r';
+               *datapt++ = '\n';
+       }
+       dlen = datapt - (u_char *)rpkt.data;
+       sendlen = dlen + CTL_HEADER_LEN;
+
+       /*
+        * Pad to a multiple of 32 bits
+        */
+       while (sendlen & 0x3) {
+               *datapt++ = '\0';
+               sendlen++;
+       }
+
+       /*
+        * Fill in the packet with the current info
+        */
+       rpkt.r_m_e_op = (u_char)(CTL_RESPONSE|more|(res_opcode &
+           CTL_OP_MASK));
+       rpkt.count = htons((u_short) dlen);
+       rpkt.offset = htons( (u_short) res_offset);
+       if (res_async) {
+               register int i;
+
+               for (i = 0; i < CTL_MAXTRAPS; i++) {
+                       if (ctl_trap[i].tr_flags & TRAP_INUSE) {
+                               rpkt.li_vn_mode =
+                                   PKT_LI_VN_MODE(sys_leap,
+                                   ctl_trap[i].tr_version,
+                                   MODE_CONTROL);
+                               rpkt.sequence =
+                                   htons(ctl_trap[i].tr_sequence);
+                               sendpkt(&ctl_trap[i].tr_addr,
+                                       ctl_trap[i].tr_localaddr, -4,
+                                       (struct pkt *)&rpkt, sendlen);
+                               if (!more)
+                                       ctl_trap[i].tr_sequence++;
+                               numasyncmsgs++;
+                       }
+               }
+       } else {
+               if (res_authenticate && sys_authenticate) {
+                       int maclen;
+                       int totlen = sendlen;
+                       keyid_t keyid = htonl(res_keyid);
+
+                       /*
+                        * If we are going to authenticate, then there
+                        * is an additional requirement that the MAC
+                        * begin on a 64 bit boundary.
+                        */
+                       while (totlen & 7) {
+                               *datapt++ = '\0';
+                               totlen++;
+                       }
+                       memcpy(datapt, &keyid, sizeof keyid);
+                       maclen = authencrypt(res_keyid,
+                           (u_int32 *)&rpkt, totlen);
+                       sendpkt(rmt_addr, lcl_inter, -5,
+                           (struct pkt *)&rpkt, totlen + maclen);
+               } else {
+                       sendpkt(rmt_addr, lcl_inter, -6,
+                           (struct pkt *)&rpkt, sendlen);
+               }
+               if (more)
+                       numctlfrags++;
+               else
+                       numctlresponses++;
+       }
+
+       /*
+        * Set us up for another go around.
+        */
+       res_offset += dlen;
+       datapt = (u_char *)rpkt.data;
+}
+
+
+/*
+ * ctl_putdata - write data into the packet, fragmenting and starting
+ * another if this one is full.
+ */
+static void
+ctl_putdata(
+       const char *dp,
+       unsigned int dlen,
+       int bin                 /* set to 1 when data is binary */
+       )
+{
+       int overhead;
+
+       overhead = 0;
+       if (!bin) {
+               datanotbinflag = 1;
+               overhead = 3;
+               if (datapt != rpkt.data) {
+                       *datapt++ = ',';
+                       datalinelen++;
+                       if ((dlen + datalinelen + 1) >= MAXDATALINELEN)
+                           {
+                               *datapt++ = '\r';
+                               *datapt++ = '\n';
+                               datalinelen = 0;
+                       } else {
+                               *datapt++ = ' ';
+                               datalinelen++;
+                       }
+               }
+       }
+
+       /*
+        * Save room for trailing junk
+        */
+       if (dlen + overhead + datapt > dataend) {
+               /*
+                * Not enough room in this one, flush it out.
+                */
+               ctl_flushpkt(CTL_MORE);
+       }
+       memmove((char *)datapt, dp, (unsigned)dlen);
+       datapt += dlen;
+       datalinelen += dlen;
+}
+
+
+/*
+ * ctl_putstr - write a tagged string into the response packet
+ */
+static void
+ctl_putstr(
+       const char *tag,
+       const char *data,
+       unsigned int len
+       )
+{
+       register char *cp;
+       register const char *cq;
+       char buffer[400];
+
+       cp = buffer;
+       cq = tag;
+       while (*cq != '\0')
+               *cp++ = *cq++;
+       if (len > 0) {
+               *cp++ = '=';
+               *cp++ = '"';
+               if (len > (int) (sizeof(buffer) - (cp - buffer) - 1))
+                       len = sizeof(buffer) - (cp - buffer) - 1;
+               memmove(cp, data, (unsigned)len);
+               cp += len;
+               *cp++ = '"';
+       }
+       ctl_putdata(buffer, (unsigned)( cp - buffer ), 0);
+}
+
+
+/*
+ * ctl_putdbl - write a tagged, signed double into the response packet
+ */
+static void
+ctl_putdbl(
+       const char *tag,
+       double ts
+       )
+{
+       register char *cp;
+       register const char *cq;
+       char buffer[200];
+
+       cp = buffer;
+       cq = tag;
+       while (*cq != '\0')
+               *cp++ = *cq++;
+       *cp++ = '=';
+       (void)sprintf(cp, "%.3f", ts);
+       while (*cp != '\0')
+               cp++;
+       ctl_putdata(buffer, (unsigned)( cp - buffer ), 0);
+}
+
+/*
+ * ctl_putuint - write a tagged unsigned integer into the response
+ */
+static void
+ctl_putuint(
+       const char *tag,
+       u_long uval
+       )
+{
+       register char *cp;
+       register const char *cq;
+       char buffer[200];
+
+       cp = buffer;
+       cq = tag;
+       while (*cq != '\0')
+               *cp++ = *cq++;
+
+       *cp++ = '=';
+       (void) sprintf(cp, "%lu", uval);
+       while (*cp != '\0')
+               cp++;
+       ctl_putdata(buffer, (unsigned)( cp - buffer ), 0);
+}
+
+/*
+ * ctl_putfs - write a decoded filestamp into the response
+ */
+#ifdef OPENSSL
+static void
+ctl_putfs(
+       const char *tag,
+       tstamp_t uval
+       )
+{
+       register char *cp;
+       register const char *cq;
+       char buffer[200];
+       struct tm *tm = NULL;
+       time_t fstamp;
+
+       cp = buffer;
+       cq = tag;
+       while (*cq != '\0')
+               *cp++ = *cq++;
+
+       *cp++ = '=';
+       fstamp = uval - JAN_1970;
+       tm = gmtime(&fstamp);
+       if (tm == NULL)
+               return;
+
+       sprintf(cp, "%04d%02d%02d%02d%02d", tm->tm_year + 1900,
+           tm->tm_mon + 1, tm->tm_mday, tm->tm_hour, tm->tm_min);
+       while (*cp != '\0')
+               cp++;
+       ctl_putdata(buffer, (unsigned)( cp - buffer ), 0);
+}
+#endif
+
+
+/*
+ * ctl_puthex - write a tagged unsigned integer, in hex, into the response
+ */
+static void
+ctl_puthex(
+       const char *tag,
+       u_long uval
+       )
+{
+       register char *cp;
+       register const char *cq;
+       char buffer[200];
+
+       cp = buffer;
+       cq = tag;
+       while (*cq != '\0')
+               *cp++ = *cq++;
+
+       *cp++ = '=';
+       (void) sprintf(cp, "0x%lx", uval);
+       while (*cp != '\0')
+               cp++;
+       ctl_putdata(buffer,(unsigned)( cp - buffer ), 0);
+}
+
+
+/*
+ * ctl_putint - write a tagged signed integer into the response
+ */
+static void
+ctl_putint(
+       const char *tag,
+       long ival
+       )
+{
+       register char *cp;
+       register const char *cq;
+       char buffer[200];
+
+       cp = buffer;
+       cq = tag;
+       while (*cq != '\0')
+               *cp++ = *cq++;
+
+       *cp++ = '=';
+       (void) sprintf(cp, "%ld", ival);
+       while (*cp != '\0')
+               cp++;
+       ctl_putdata(buffer, (unsigned)( cp - buffer ), 0);
+}
+
+
+/*
+ * ctl_putts - write a tagged timestamp, in hex, into the response
+ */
+static void
+ctl_putts(
+       const char *tag,
+       l_fp *ts
+       )
+{
+       register char *cp;
+       register const char *cq;
+       char buffer[200];
+
+       cp = buffer;
+       cq = tag;
+       while (*cq != '\0')
+               *cp++ = *cq++;
+
+       *cp++ = '=';
+       (void) sprintf(cp, "0x%08lx.%08lx",
+                          ts->l_ui & ULONG_CONST(0xffffffff),
+                          ts->l_uf & ULONG_CONST(0xffffffff));
+       while (*cp != '\0')
+               cp++;
+       ctl_putdata(buffer, (unsigned)( cp - buffer ), 0);
+}
+
+
+/*
+ * ctl_putadr - write an IP address into the response
+ */
+static void
+ctl_putadr(
+       const char *tag,
+       u_int32 addr32,
+       struct sockaddr_storage* addr
+       )
+{
+       register char *cp;
+       register const char *cq;
+       char buffer[200];
+
+       cp = buffer;
+       cq = tag;
+       while (*cq != '\0')
+               *cp++ = *cq++;
+
+       *cp++ = '=';
+       if (addr == NULL)
+               cq = numtoa(addr32);
+       else
+               cq = stoa(addr);
+       while (*cq != '\0')
+               *cp++ = *cq++;
+       ctl_putdata(buffer, (unsigned)( cp - buffer ), 0);
+}
+
+/*
+ * ctl_putid - write a tagged clock ID into the response
+ */
+static void
+ctl_putid(
+       const char *tag,
+       char *id
+       )
+{
+       register char *cp;
+       register const char *cq;
+       char buffer[200];
+
+       cp = buffer;
+       cq = tag;
+       while (*cq != '\0')
+               *cp++ = *cq++;
+
+       *cp++ = '=';
+       cq = id;
+       while (*cq != '\0' && (cq - id) < 4)
+               *cp++ = *cq++;
+       ctl_putdata(buffer, (unsigned)( cp - buffer ), 0);
+}
+
+
+/*
+ * ctl_putarray - write a tagged eight element double array into the response
+ */
+static void
+ctl_putarray(
+       const char *tag,
+       double *arr,
+       int start
+       )
+{
+       register char *cp;
+       register const char *cq;
+       char buffer[200];
+       int i;
+       cp = buffer;
+       cq = tag;
+       while (*cq != '\0')
+               *cp++ = *cq++;
+       i = start;
+       do {
+               if (i == 0)
+                       i = NTP_SHIFT;
+               i--;
+               (void)sprintf(cp, " %.2f", arr[i] * 1e3);
+               while (*cp != '\0')
+                       cp++;
+       } while(i != start);
+       ctl_putdata(buffer, (unsigned)(cp - buffer), 0);
+}
+
+
+/*
+ * ctl_putsys - output a system variable
+ */
+static void
+ctl_putsys(
+       int varid
+       )
+{
+       l_fp tmp;
+       char str[256];
+#ifdef OPENSSL
+       struct cert_info *cp;
+       char cbuf[256];
+#endif /* OPENSSL */
+
+       switch (varid) {
+
+       case CS_LEAP:
+               ctl_putuint(sys_var[CS_LEAP].text, sys_leap);
+               break;
+
+       case CS_STRATUM:
+               ctl_putuint(sys_var[CS_STRATUM].text, sys_stratum);
+               break;
+
+       case CS_PRECISION:
+               ctl_putint(sys_var[CS_PRECISION].text, sys_precision);
+               break;
+
+       case CS_ROOTDELAY:
+               ctl_putdbl(sys_var[CS_ROOTDELAY].text, sys_rootdelay *
+                   1e3);
+               break;
+
+       case CS_ROOTDISPERSION:
+               ctl_putdbl(sys_var[CS_ROOTDISPERSION].text,
+                   sys_rootdispersion * 1e3);
+               break;
+
+       case CS_REFID:
+               if (sys_stratum > 1 && sys_stratum < STRATUM_UNSPEC)
+                       ctl_putadr(sys_var[CS_REFID].text, sys_refid, NULL);
+               else
+                       ctl_putid(sys_var[CS_REFID].text,
+                           (char *)&sys_refid);
+               break;
+
+       case CS_REFTIME:
+               ctl_putts(sys_var[CS_REFTIME].text, &sys_reftime);
+               break;
+
+       case CS_POLL:
+               ctl_putuint(sys_var[CS_POLL].text, sys_poll);
+               break;
+
+       case CS_PEERID:
+               if (sys_peer == NULL)
+                       ctl_putuint(sys_var[CS_PEERID].text, 0);
+               else
+                       ctl_putuint(sys_var[CS_PEERID].text,
+                               sys_peer->associd);
+               break;
+
+       case CS_STATE:
+               ctl_putuint(sys_var[CS_STATE].text, (unsigned)state);
+               break;
+
+       case CS_OFFSET:
+               ctl_putdbl(sys_var[CS_OFFSET].text, last_offset * 1e3);
+               break;
+
+       case CS_DRIFT:
+               ctl_putdbl(sys_var[CS_DRIFT].text, drift_comp * 1e6);
+               break;
+
+       case CS_JITTER:
+               ctl_putdbl(sys_var[CS_JITTER].text, sys_jitter * 1e3);
+               break;
+
+       case CS_ERROR:
+               ctl_putdbl(sys_var[CS_ERROR].text, clock_jitter * 1e3);
+               break;
+
+       case CS_CLOCK:
+               get_systime(&tmp);
+               ctl_putts(sys_var[CS_CLOCK].text, &tmp);
+               break;
+
+       case CS_PROCESSOR:
+#ifndef HAVE_UNAME
+               ctl_putstr(sys_var[CS_PROCESSOR].text, str_processor,
+                   sizeof(str_processor) - 1);
+#else
+               ctl_putstr(sys_var[CS_PROCESSOR].text,
+                   utsnamebuf.machine, strlen(utsnamebuf.machine));
+#endif /* HAVE_UNAME */
+               break;
+
+       case CS_SYSTEM:
+#ifndef HAVE_UNAME
+               ctl_putstr(sys_var[CS_SYSTEM].text, str_system,
+                   sizeof(str_system) - 1);
+#else
+               sprintf(str, "%s/%s", utsnamebuf.sysname, utsnamebuf.release);
+               ctl_putstr(sys_var[CS_SYSTEM].text, str, strlen(str));
+#endif /* HAVE_UNAME */
+               break;
+
+       case CS_VERSION:
+               ctl_putstr(sys_var[CS_VERSION].text, Version,
+                   strlen(Version));
+               break;
+
+       case CS_STABIL:
+               ctl_putdbl(sys_var[CS_STABIL].text, clock_stability *
+                   1e6);
+               break;
+
+       case CS_VARLIST:
+               {
+                       char buf[CTL_MAX_DATA_LEN];
+                       register char *s, *t, *be;
+                       register const char *ss;
+                       register int i;
+                       register struct ctl_var *k;
+
+                       s = buf;
+                       be = buf + sizeof(buf) -
+                           strlen(sys_var[CS_VARLIST].text) - 4;
+                       if (s > be)
+                               break;  /* really long var name */
+
+                       strcpy(s, sys_var[CS_VARLIST].text);
+                       strcat(s, "=\"");
+                       s += strlen(s);
+                       t = s;
+                       for (k = sys_var; !(k->flags &EOV); k++) {
+                               if (k->flags & PADDING)
+                                       continue;
+                               i = strlen(k->text);
+                               if (s+i+1 >= be)
+                               break;
+
+                               if (s != t)
+                               *s++ = ',';
+                               strcpy(s, k->text);
+                               s += i;
+                       }
+
+                       for (k = ext_sys_var; k && !(k->flags &EOV);
+                           k++) {
+                               if (k->flags & PADDING)
+                                       continue;
+
+                               ss = k->text;
+                               if (!ss)
+                                       continue;
+
+                               while (*ss && *ss != '=')
+                                       ss++;
+                               i = ss - k->text;
+                               if (s + i + 1 >= be)
+                                       break;
+
+                               if (s != t)
+                               *s++ = ',';
+                               strncpy(s, k->text,
+                                   (unsigned)i);
+                               s += i;
+                       }
+                       if (s+2 >= be)
+                               break;
+
+                       *s++ = '"';
+                       *s = '\0';
+
+                       ctl_putdata(buf, (unsigned)( s - buf ),
+                           0);
+               }
+               break;
+
+#ifdef OPENSSL
+       case CS_FLAGS:
+               if (crypto_flags) {
+                       ctl_puthex(sys_var[CS_FLAGS].text, crypto_flags);
+               }
+               break;
+
+       case CS_DIGEST:
+               if (crypto_flags) {
+                       const EVP_MD *dp;
+
+                       dp = EVP_get_digestbynid(crypto_flags >> 16);
+                       strcpy(str, OBJ_nid2ln(EVP_MD_pkey_type(dp)));
+                       ctl_putstr(sys_var[CS_DIGEST].text, str,
+                           strlen(str));
+               }
+               break;
+
+       case CS_HOST:
+               if (sys_hostname != NULL)
+                       ctl_putstr(sys_var[CS_HOST].text, sys_hostname,
+                           strlen(sys_hostname));
+               break;
+
+       case CS_CERTIF:
+               for (cp = cinfo; cp != NULL; cp = cp->link) {
+                       sprintf(cbuf, "%s %s 0x%x", cp->subject,
+                           cp->issuer, cp->flags);
+                       ctl_putstr(sys_var[CS_CERTIF].text, cbuf,
+                           strlen(cbuf));
+                       ctl_putfs(sys_var[CS_REVOKE].text, cp->last);
+               }
+               break;
+
+       case CS_PUBLIC:
+               if (hostval.fstamp != 0)
+                       ctl_putfs(sys_var[CS_PUBLIC].text,
+                           ntohl(hostval.tstamp));
+               break;
+
+       case CS_REVTIME:
+               if (hostval.tstamp != 0)
+                       ctl_putfs(sys_var[CS_REVTIME].text,
+                           ntohl(hostval.tstamp));
+               break;
+
+       case CS_IDENT:
+               if (iffpar_pkey != NULL)
+                       ctl_putstr(sys_var[CS_IDENT].text,
+                           iffpar_file, strlen(iffpar_file));
+               if (gqpar_pkey != NULL)
+                       ctl_putstr(sys_var[CS_IDENT].text,
+                           gqpar_file, strlen(gqpar_file));
+               if (mvpar_pkey != NULL)
+                       ctl_putstr(sys_var[CS_IDENT].text,
+                           mvpar_file, strlen(mvpar_file));
+               break;
+
+       case CS_LEAPTAB:
+               if (tai_leap.fstamp != 0)
+                       ctl_putfs(sys_var[CS_LEAPTAB].text,
+                           ntohl(tai_leap.fstamp));
+               break;
+
+       case CS_TAI:
+               ctl_putuint(sys_var[CS_TAI].text, sys_tai);
+               break;
+#endif /* OPENSSL */
+       }
+}
+
+
+/*
+ * ctl_putpeer - output a peer variable
+ */
+static void
+ctl_putpeer(
+       int varid,
+       struct peer *peer
+       )
+{
+       int temp;
+#ifdef OPENSSL
+       char str[256];
+       struct autokey *ap;
+#endif /* OPENSSL */
+
+       switch (varid) {
+
+       case CP_CONFIG:
+               ctl_putuint(peer_var[CP_CONFIG].text,
+                   (unsigned)((peer->flags & FLAG_CONFIG) != 0));
+               break;
+
+       case CP_AUTHENABLE:
+               ctl_putuint(peer_var[CP_AUTHENABLE].text,
+                   (unsigned)((peer->flags & FLAG_AUTHENABLE) != 0));
+               break;
+
+       case CP_AUTHENTIC:
+               ctl_putuint(peer_var[CP_AUTHENTIC].text,
+                   (unsigned)((peer->flags & FLAG_AUTHENTIC) != 0));
+               break;
+
+       case CP_SRCADR:
+               ctl_putadr(peer_var[CP_SRCADR].text, 0,
+                   &peer->srcadr);
+               break;
+
+       case CP_SRCPORT:
+               ctl_putuint(peer_var[CP_SRCPORT].text,
+                   ntohs(((struct sockaddr_in*)&peer->srcadr)->sin_port));
+               break;
+
+       case CP_DSTADR:
+               if (peer->dstadr) {
+                       ctl_putadr(peer_var[CP_DSTADR].text, 0,
+                                  &(peer->dstadr->sin));
+               } else {
+                       ctl_putadr(peer_var[CP_DSTADR].text, 0,
+                                  NULL);
+               }
+               break;
+
+       case CP_DSTPORT:
+               ctl_putuint(peer_var[CP_DSTPORT].text,
+                   (u_long)(peer->dstadr ?
+                   ntohs(((struct sockaddr_in*)&peer->dstadr->sin)->sin_port) : 0));
+               break;
+
+       case CP_LEAP:
+               ctl_putuint(peer_var[CP_LEAP].text, peer->leap);
+               break;
+
+       case CP_HMODE:
+               ctl_putuint(peer_var[CP_HMODE].text, peer->hmode);
+               break;
+
+       case CP_STRATUM:
+               ctl_putuint(peer_var[CP_STRATUM].text, peer->stratum);
+               break;
+
+       case CP_PPOLL:
+               ctl_putuint(peer_var[CP_PPOLL].text, peer->ppoll);
+               break;
+
+       case CP_HPOLL:
+               ctl_putuint(peer_var[CP_HPOLL].text, peer->hpoll);
+               break;
+
+       case CP_PRECISION:
+               ctl_putint(peer_var[CP_PRECISION].text,
+                   peer->precision);
+               break;
+
+       case CP_ROOTDELAY:
+               ctl_putdbl(peer_var[CP_ROOTDELAY].text,
+                   peer->rootdelay * 1e3);
+               break;
+
+       case CP_ROOTDISPERSION:
+               ctl_putdbl(peer_var[CP_ROOTDISPERSION].text,
+                   peer->rootdispersion * 1e3);
+               break;
+
+       case CP_REFID:
+               if (peer->flags & FLAG_REFCLOCK) {
+                       ctl_putid(peer_var[CP_REFID].text,
+                          (char *)&peer->refid);
+               } else {
+                       if (peer->stratum > 1 && peer->stratum <
+                           STRATUM_UNSPEC)
+                               ctl_putadr(peer_var[CP_REFID].text,
+                                   peer->refid, NULL);
+                       else
+                               ctl_putid(peer_var[CP_REFID].text,
+                                   (char *)&peer->refid);
+               }
+               break;
+
+       case CP_REFTIME:
+               ctl_putts(peer_var[CP_REFTIME].text, &peer->reftime);
+               break;
+
+       case CP_ORG:
+               ctl_putts(peer_var[CP_ORG].text, &peer->org);
+               break;
+
+       case CP_REC:
+               ctl_putts(peer_var[CP_REC].text, &peer->rec);
+               break;
+
+       case CP_XMT:
+               ctl_putts(peer_var[CP_XMT].text, &peer->xmt);
+               break;
+
+       case CP_REACH:
+               ctl_puthex(peer_var[CP_REACH].text, peer->reach);
+               break;
+
+       case CP_FLASH:
+               temp = peer->flash;
+               ctl_puthex(peer_var[CP_FLASH].text, temp);
+               break;
+
+       case CP_TTL:
+               ctl_putint(peer_var[CP_TTL].text, sys_ttl[peer->ttl]);
+               break;
+
+       case CP_UNREACH:
+               ctl_putuint(peer_var[CP_UNREACH].text, peer->unreach);
+               break;
+
+       case CP_TIMER:
+               ctl_putuint(peer_var[CP_TIMER].text,
+                   peer->nextdate - current_time);
+               break;
+
+       case CP_DELAY:
+               ctl_putdbl(peer_var[CP_DELAY].text, peer->delay * 1e3);
+               break;
+
+       case CP_OFFSET:
+               ctl_putdbl(peer_var[CP_OFFSET].text, peer->offset *
+                   1e3);
+               break;
+
+       case CP_JITTER:
+               ctl_putdbl(peer_var[CP_JITTER].text, peer->jitter * 1e3);
+               break;
+
+       case CP_DISPERSION:
+               ctl_putdbl(peer_var[CP_DISPERSION].text, peer->disp *
+                   1e3);
+               break;
+
+       case CP_KEYID:
+               ctl_putuint(peer_var[CP_KEYID].text, peer->keyid);
+               break;
+
+       case CP_FILTDELAY:
+               ctl_putarray(peer_var[CP_FILTDELAY].text,
+                   peer->filter_delay, (int)peer->filter_nextpt);
+               break;
+
+       case CP_FILTOFFSET:
+               ctl_putarray(peer_var[CP_FILTOFFSET].text,
+                   peer->filter_offset, (int)peer->filter_nextpt);
+               break;
+
+       case CP_FILTERROR:
+               ctl_putarray(peer_var[CP_FILTERROR].text,
+                   peer->filter_disp, (int)peer->filter_nextpt);
+               break;
+
+       case CP_PMODE:
+               ctl_putuint(peer_var[CP_PMODE].text, peer->pmode);
+               break;
+
+       case CP_RECEIVED:
+               ctl_putuint(peer_var[CP_RECEIVED].text, peer->received);
+               break;
+
+       case CP_SENT:
+               ctl_putuint(peer_var[CP_SENT].text, peer->sent);
+               break;
+
+       case CP_VARLIST:
+               {
+                       char buf[CTL_MAX_DATA_LEN];
+                       register char *s, *t, *be;
+                       register int i;
+                       register struct ctl_var *k;
+
+                       s = buf;
+                       be = buf + sizeof(buf) -
+                           strlen(peer_var[CP_VARLIST].text) - 4;
+                       if (s > be)
+                               break;  /* really long var name */
+
+                       strcpy(s, peer_var[CP_VARLIST].text);
+                       strcat(s, "=\"");
+                       s += strlen(s);
+                       t = s;
+                       for (k = peer_var; !(k->flags &EOV); k++) {
+                               if (k->flags & PADDING)
+                                       continue;
+
+                               i = strlen(k->text);
+                               if (s + i + 1 >= be)
+                               break;
+
+                               if (s != t)
+                                       *s++ = ',';
+                               strcpy(s, k->text);
+                               s += i;
+                       }
+                       if (s+2 >= be)
+                               break;
+
+                       *s++ = '"';
+                       *s = '\0';
+                       ctl_putdata(buf, (unsigned)(s - buf), 0);
+               }
+               break;
+#ifdef OPENSSL
+       case CP_FLAGS:
+               if (peer->crypto)
+                       ctl_puthex(peer_var[CP_FLAGS].text, peer->crypto);
+               break;
+
+       case CP_DIGEST:
+               if (peer->crypto) {
+                       const EVP_MD *dp;
+
+                       dp = EVP_get_digestbynid(peer->crypto >> 16);
+                       strcpy(str, OBJ_nid2ln(EVP_MD_pkey_type(dp)));
+                       ctl_putstr(peer_var[CP_DIGEST].text, str,
+                                    strlen(str));
+               }
+               break;
+
+       case CP_HOST:
+               if (peer->subject != NULL)
+                       ctl_putstr(peer_var[CP_HOST].text,
+                           peer->subject, strlen(peer->subject));
+               break;
+
+       case CP_VALID:          /* not used */
+               break;
+
+       case CP_IDENT:
+               if (peer->issuer != NULL)
+                       ctl_putstr(peer_var[CP_IDENT].text,
+                           peer->issuer, strlen(peer->issuer));
+               break;
+
+       case CP_INITSEQ:
+               if ((ap = (struct autokey *)peer->recval.ptr) == NULL)
+                       break;
+               ctl_putint(peer_var[CP_INITSEQ].text, ap->seq);
+               ctl_puthex(peer_var[CP_INITKEY].text, ap->key);
+               ctl_putfs(peer_var[CP_INITTSP].text,
+                   ntohl(peer->recval.tstamp));
+               break;
+#endif /* OPENSSL */
+       }
+}
+
+
+#ifdef REFCLOCK
+/*
+ * ctl_putclock - output clock variables
+ */
+static void
+ctl_putclock(
+       int varid,
+       struct refclockstat *clock_stat,
+       int mustput
+       )
+{
+       switch(varid) {
+
+       case CC_TYPE:
+               if (mustput || clock_stat->clockdesc == NULL
+                       || *(clock_stat->clockdesc) == '\0') {
+                       ctl_putuint(clock_var[CC_TYPE].text, clock_stat->type);
+               }
+               break;
+       case CC_TIMECODE:
+               ctl_putstr(clock_var[CC_TIMECODE].text,
+                   clock_stat->p_lastcode,
+                   (unsigned)clock_stat->lencode);
+               break;
+
+       case CC_POLL:
+               ctl_putuint(clock_var[CC_POLL].text, clock_stat->polls);
+               break;
+
+       case CC_NOREPLY:
+               ctl_putuint(clock_var[CC_NOREPLY].text,
+                   clock_stat->noresponse);
+               break;
+
+       case CC_BADFORMAT:
+               ctl_putuint(clock_var[CC_BADFORMAT].text,
+                   clock_stat->badformat);
+               break;
+
+       case CC_BADDATA:
+               ctl_putuint(clock_var[CC_BADDATA].text,
+                   clock_stat->baddata);
+               break;
+
+       case CC_FUDGETIME1:
+               if (mustput || (clock_stat->haveflags & CLK_HAVETIME1))
+                       ctl_putdbl(clock_var[CC_FUDGETIME1].text,
+                           clock_stat->fudgetime1 * 1e3);
+               break;
+
+       case CC_FUDGETIME2:
+               if (mustput || (clock_stat->haveflags & CLK_HAVETIME2))                         ctl_putdbl(clock_var[CC_FUDGETIME2].text,
+                           clock_stat->fudgetime2 * 1e3);
+               break;
+
+       case CC_FUDGEVAL1:
+               if (mustput || (clock_stat->haveflags & CLK_HAVEVAL1))
+                       ctl_putint(clock_var[CC_FUDGEVAL1].text,
+                           clock_stat->fudgeval1);
+               break;
+
+       case CC_FUDGEVAL2:
+               if (mustput || (clock_stat->haveflags & CLK_HAVEVAL2)) {
+                       if (clock_stat->fudgeval1 > 1)
+                               ctl_putadr(clock_var[CC_FUDGEVAL2].text,
+                                   (u_int32)clock_stat->fudgeval2, NULL);
+                       else
+                               ctl_putid(clock_var[CC_FUDGEVAL2].text,
+                                   (char *)&clock_stat->fudgeval2);
+               }
+               break;
+
+       case CC_FLAGS:
+               if (mustput || (clock_stat->haveflags & (CLK_HAVEFLAG1 |
+                   CLK_HAVEFLAG2 | CLK_HAVEFLAG3 | CLK_HAVEFLAG4)))
+                       ctl_putuint(clock_var[CC_FLAGS].text,
+                           clock_stat->flags);
+               break;
+
+       case CC_DEVICE:
+               if (clock_stat->clockdesc == NULL ||
+                   *(clock_stat->clockdesc) == '\0') {
+                       if (mustput)
+                               ctl_putstr(clock_var[CC_DEVICE].text,
+                                   "", 0);
+               } else {
+                       ctl_putstr(clock_var[CC_DEVICE].text,
+                           clock_stat->clockdesc,
+                           strlen(clock_stat->clockdesc));
+               }
+               break;
+
+       case CC_VARLIST:
+               {
+                       char buf[CTL_MAX_DATA_LEN];
+                       register char *s, *t, *be;
+                       register const char *ss;
+                       register int i;
+                       register struct ctl_var *k;
+
+                       s = buf;
+                       be = buf + sizeof(buf);
+                       if (s + strlen(clock_var[CC_VARLIST].text) + 4 >
+                           be)
+                               break;  /* really long var name */
+
+                       strcpy(s, clock_var[CC_VARLIST].text);
+                       strcat(s, "=\"");
+                       s += strlen(s);
+                       t = s;
+
+                       for (k = clock_var; !(k->flags &EOV); k++) {
+                               if (k->flags & PADDING)
+                                       continue;
+
+                               i = strlen(k->text);
+                               if (s + i + 1 >= be)
+                                       break;
+
+                               if (s != t)
+                               *s++ = ',';
+                               strcpy(s, k->text);
+                               s += i;
+                       }
+
+                       for (k = clock_stat->kv_list; k && !(k->flags &
+                           EOV); k++) {
+                               if (k->flags & PADDING)
+                                       continue;
+
+                               ss = k->text;
+                               if (!ss)
+                                       continue;
+
+                               while (*ss && *ss != '=')
+                                       ss++;
+                               i = ss - k->text;
+                               if (s+i+1 >= be)
+                                       break;
+
+                               if (s != t)
+                                       *s++ = ',';
+                               strncpy(s, k->text, (unsigned)i);
+                               s += i;
+                               *s = '\0';
+                       }
+                       if (s+2 >= be)
+                               break;
+
+                       *s++ = '"';
+                       *s = '\0';
+                       ctl_putdata(buf, (unsigned)( s - buf ), 0);
+               }
+               break;
+       }
+}
+#endif
+
+
+
+/*
+ * ctl_getitem - get the next data item from the incoming packet
+ */
+static struct ctl_var *
+ctl_getitem(
+       struct ctl_var *var_list,
+       char **data
+       )
+{
+       register struct ctl_var *v;
+       register char *cp;
+       register char *tp;
+       static struct ctl_var eol = { 0, EOV, };
+       static char buf[128];
+
+       /*
+        * Delete leading commas and white space
+        */
+       while (reqpt < reqend && (*reqpt == ',' ||
+           isspace((unsigned char)*reqpt)))
+               reqpt++;
+       if (reqpt >= reqend)
+               return (0);
+
+       if (var_list == (struct ctl_var *)0)
+               return (&eol);
+
+       /*
+        * Look for a first character match on the tag.  If we find
+        * one, see if it is a full match.
+        */
+       v = var_list;
+       cp = reqpt;
+       while (!(v->flags & EOV)) {
+               if (!(v->flags & PADDING) && *cp == *(v->text)) {
+                       tp = v->text;
+                       while (*tp != '\0' && *tp != '=' && cp <
+                           reqend && *cp == *tp) {
+                               cp++;
+                               tp++;
+                       }
+                       if ((*tp == '\0') || (*tp == '=')) {
+                               while (cp < reqend && isspace((unsigned char)*cp))
+                                       cp++;
+                               if (cp == reqend || *cp == ',') {
+                                       buf[0] = '\0';
+                                       *data = buf;
+                                       if (cp < reqend)
+                                               cp++;
+                                       reqpt = cp;
+                                       return v;
+                               }
+                               if (*cp == '=') {
+                                       cp++;
+                                       tp = buf;
+                                       while (cp < reqend && isspace((unsigned char)*cp))
+                                               cp++;
+                                       while (cp < reqend && *cp != ',') {
+                                               *tp++ = *cp++;
+                                               if (tp >= buf + sizeof(buf)) {
+                                                       ctl_error(CERR_BADFMT);
+                                                       numctlbadpkts++;
+#if 0  /* Avoid possible DOS attack */
+/* If we get a smarter msyslog we can re-enable this */
+                                                       msyslog(LOG_WARNING,
+               "Possible 'ntpdx' exploit from %s:%d (possibly spoofed)\n",
+               stoa(rmt_addr), SRCPORT(rmt_addr)
+                                                               );
+#endif
+                                                       return (0);
+                                               }
+                                       }
+                                       if (cp < reqend)
+                                               cp++;
+                                       *tp-- = '\0';
+                                       while (tp >= buf) {
+                                               if (!isspace((unsigned int)(*tp)))
+                                                       break;
+                                               *tp-- = '\0';
+                                       }
+                                       reqpt = cp;
+                                       *data = buf;
+                                       return (v);
+                               }
+                       }
+                       cp = reqpt;
+               }
+               v++;
+       }
+       return v;
+}
+
+
+/*
+ * control_unspec - response to an unspecified op-code
+ */
+/*ARGSUSED*/
+static void
+control_unspec(
+       struct recvbuf *rbufp,
+       int restrict_mask
+       )
+{
+       struct peer *peer;
+
+       /*
+        * What is an appropriate response to an unspecified op-code?
+        * I return no errors and no data, unless a specified assocation
+        * doesn't exist.
+        */
+       if (res_associd != 0) {
+               if ((peer = findpeerbyassoc(res_associd)) == 0) {
+                       ctl_error(CERR_BADASSOC);
+                       return;
+               }
+               rpkt.status = htons(ctlpeerstatus(peer));
+       } else {
+               rpkt.status = htons(ctlsysstatus());
+       }
+       ctl_flushpkt(0);
+}
+
+
+/*
+ * read_status - return either a list of associd's, or a particular
+ * peer's status.
+ */
+/*ARGSUSED*/
+static void
+read_status(
+       struct recvbuf *rbufp,
+       int restrict_mask
+       )
+{
+       register int i;
+       register struct peer *peer;
+       u_short ass_stat[CTL_MAX_DATA_LEN / sizeof(u_short)];
+
+#ifdef DEBUG
+       if (debug > 2)
+               printf("read_status: ID %d\n", res_associd);
+#endif
+       /*
+        * Two choices here. If the specified association ID is
+        * zero we return all known assocation ID's.  Otherwise
+        * we return a bunch of stuff about the particular peer.
+        */
+       if (res_associd == 0) {
+               register int n;
+
+               n = 0;
+               rpkt.status = htons(ctlsysstatus());
+               for (i = 0; i < NTP_HASH_SIZE; i++) {
+                       for (peer = assoc_hash[i]; peer != 0;
+                               peer = peer->ass_next) {
+                               ass_stat[n++] = htons(peer->associd);
+                               ass_stat[n++] =
+                                   htons(ctlpeerstatus(peer));
+                               if (n ==
+                                   CTL_MAX_DATA_LEN/sizeof(u_short)) {
+                                       ctl_putdata((char *)ass_stat,
+                                           n * sizeof(u_short), 1);
+                                       n = 0;
+                               }
+                       }
+               }
+
+               if (n != 0)
+                       ctl_putdata((char *)ass_stat, n *
+                           sizeof(u_short), 1);
+               ctl_flushpkt(0);
+       } else {
+               peer = findpeerbyassoc(res_associd);
+               if (peer == 0) {
+                       ctl_error(CERR_BADASSOC);
+               } else {
+                       register u_char *cp;
+
+                       rpkt.status = htons(ctlpeerstatus(peer));
+                       if (res_authokay)
+                               peer->num_events = 0;
+                       /*
+                        * For now, output everything we know about the
+                        * peer. May be more selective later.
+                        */
+                       for (cp = def_peer_var; *cp != 0; cp++)
+                               ctl_putpeer((int)*cp, peer);
+                       ctl_flushpkt(0);
+               }
+       }
+}
+
+
+/*
+ * read_variables - return the variables the caller asks for
+ */
+/*ARGSUSED*/
+static void
+read_variables(
+       struct recvbuf *rbufp,
+       int restrict_mask
+       )
+{
+       register struct ctl_var *v;
+       register int i;
+       char *valuep;
+       u_char *wants;
+       unsigned int gotvar = (CS_MAXCODE > CP_MAXCODE) ? (CS_MAXCODE +
+           1) : (CP_MAXCODE + 1);
+       if (res_associd == 0) {
+               /*
+                * Wants system variables. Figure out which he wants
+                * and give them to him.
+                */
+               rpkt.status = htons(ctlsysstatus());
+               if (res_authokay)
+                       ctl_sys_num_events = 0;
+               gotvar += count_var(ext_sys_var);
+               wants = (u_char *)emalloc(gotvar);
+               memset((char *)wants, 0, gotvar);
+               gotvar = 0;
+               while ((v = ctl_getitem(sys_var, &valuep)) != 0) {
+                       if (v->flags & EOV) {
+                               if ((v = ctl_getitem(ext_sys_var,
+                                   &valuep)) != 0) {
+                                       if (v->flags & EOV) {
+                                               ctl_error(CERR_UNKNOWNVAR);
+                                               free((char *)wants);
+                                               return;
+                                       }
+                                       wants[CS_MAXCODE + 1 +
+                                           v->code] = 1;
+                                       gotvar = 1;
+                                       continue;
+                               } else {
+                                       break; /* shouldn't happen ! */
+                               }
+                       }
+                       wants[v->code] = 1;
+                       gotvar = 1;
+               }
+               if (gotvar) {
+                       for (i = 1; i <= CS_MAXCODE; i++)
+                               if (wants[i])
+                                       ctl_putsys(i);
+                       for (i = 0; ext_sys_var &&
+                           !(ext_sys_var[i].flags & EOV); i++)
+                               if (wants[i + CS_MAXCODE + 1])
+                                       ctl_putdata(ext_sys_var[i].text,
+                                           strlen(ext_sys_var[i].text),
+                                           0);
+               } else {
+                       register u_char *cs;
+                       register struct ctl_var *kv;
+
+                       for (cs = def_sys_var; *cs != 0; cs++)
+                               ctl_putsys((int)*cs);
+                       for (kv = ext_sys_var; kv && !(kv->flags & EOV);
+                           kv++)
+                               if (kv->flags & DEF)
+                                       ctl_putdata(kv->text,
+                                           strlen(kv->text), 0);
+               }
+               free((char *)wants);
+       } else {
+               register struct peer *peer;
+
+               /*
+                * Wants info for a particular peer. See if we know
+                * the guy.
+                */
+               peer = findpeerbyassoc(res_associd);
+               if (peer == 0) {
+                       ctl_error(CERR_BADASSOC);
+                       return;
+               }
+               rpkt.status = htons(ctlpeerstatus(peer));
+               if (res_authokay)
+                       peer->num_events = 0;
+               wants = (u_char *)emalloc(gotvar);
+               memset((char*)wants, 0, gotvar);
+               gotvar = 0;
+               while ((v = ctl_getitem(peer_var, &valuep)) != 0) {
+                       if (v->flags & EOV) {
+                               ctl_error(CERR_UNKNOWNVAR);
+                               free((char *)wants);
+                               return;
+                       }
+                       wants[v->code] = 1;
+                       gotvar = 1;
+               }
+               if (gotvar) {
+                       for (i = 1; i <= CP_MAXCODE; i++)
+                               if (wants[i])
+                                       ctl_putpeer(i, peer);
+               } else {
+                       register u_char *cp;
+
+                       for (cp = def_peer_var; *cp != 0; cp++)
+                               ctl_putpeer((int)*cp, peer);
+               }
+               free((char *)wants);
+       }
+       ctl_flushpkt(0);
+}
+
+
+/*
+ * write_variables - write into variables. We only allow leap bit
+ * writing this way.
+ */
+/*ARGSUSED*/
+static void
+write_variables(
+       struct recvbuf *rbufp,
+       int restrict_mask
+       )
+{
+       register struct ctl_var *v;
+       register int ext_var;
+       char *valuep;
+       long val = 0;
+
+       /*
+        * If he's trying to write into a peer tell him no way
+        */
+       if (res_associd != 0) {
+               ctl_error(CERR_PERMISSION);
+               return;
+       }
+
+       /*
+        * Set status
+        */
+       rpkt.status = htons(ctlsysstatus());
+
+       /*
+        * Look through the variables. Dump out at the first sign of
+        * trouble.
+        */
+       while ((v = ctl_getitem(sys_var, &valuep)) != 0) {
+               ext_var = 0;
+               if (v->flags & EOV) {
+                       if ((v = ctl_getitem(ext_sys_var, &valuep)) !=
+                           0) {
+                               if (v->flags & EOV) {
+                                       ctl_error(CERR_UNKNOWNVAR);
+                                       return;
+                               }
+                               ext_var = 1;
+                       } else {
+                               break;
+                       }
+               }
+               if (!(v->flags & CAN_WRITE)) {
+                       ctl_error(CERR_PERMISSION);
+                       return;
+               }
+               if (!ext_var && (*valuep == '\0' || !atoint(valuep,
+                   &val))) {
+                       ctl_error(CERR_BADFMT);
+                       return;
+               }
+               if (!ext_var && (val & ~LEAP_NOTINSYNC) != 0) {
+                       ctl_error(CERR_BADVALUE);
+                       return;
+               }
+
+               if (ext_var) {
+                       char *s = (char *)emalloc(strlen(v->text) +
+                           strlen(valuep) + 2);
+                       const char *t;
+                       char *tt = s;
+
+                       t = v->text;
+                       while (*t && *t != '=')
+                               *tt++ = *t++;
+
+                       *tt++ = '=';
+                       strcat(tt, valuep);
+                       set_sys_var(s, strlen(s)+1, v->flags);
+                       free(s);
+               } else {
+                       /*
+                        * This one seems sane. Save it.
+                        */
+                       switch(v->code) {
+
+                       case CS_LEAP:
+                       default:
+                               ctl_error(CERR_UNSPEC); /* really */
+                               return;
+                       }
+               }
+       }
+
+       /*
+        * If we got anything, do it. xxx nothing to do ***
+        */
+       /*
+         if (leapind != ~0 || leapwarn != ~0) {
+               if (!leap_setleap((int)leapind, (int)leapwarn)) {
+                       ctl_error(CERR_PERMISSION);
+                       return;
+               }
+         }
+       */
+       ctl_flushpkt(0);
+}
+
+
+/*
+ * read_clock_status - return clock radio status
+ */
+/*ARGSUSED*/
+static void
+read_clock_status(
+       struct recvbuf *rbufp,
+       int restrict_mask
+       )
+{
+#ifndef REFCLOCK
+       /*
+        * If no refclock support, no data to return
+        */
+       ctl_error(CERR_BADASSOC);
+#else
+       register struct ctl_var *v;
+       register int i;
+       register struct peer *peer;
+       char *valuep;
+       u_char *wants;
+       unsigned int gotvar;
+       struct refclockstat clock_stat;
+
+       if (res_associd == 0) {
+
+               /*
+                * Find a clock for this jerk.  If the system peer
+                * is a clock use it, else search the hash tables
+                * for one.
+                */
+               if (sys_peer != 0 && (sys_peer->flags & FLAG_REFCLOCK))
+                   {
+                       peer = sys_peer;
+               } else {
+                       peer = 0;
+                       for (i = 0; peer == 0 && i < NTP_HASH_SIZE; i++) {
+                               for (peer = assoc_hash[i]; peer != 0;
+                                       peer = peer->ass_next) {
+                                       if (peer->flags & FLAG_REFCLOCK)
+                                               break;
+                               }
+                       }
+                       if (peer == 0) {
+                               ctl_error(CERR_BADASSOC);
+                               return;
+                       }
+               }
+       } else {
+               peer = findpeerbyassoc(res_associd);
+               if (peer == 0 || !(peer->flags & FLAG_REFCLOCK)) {
+                       ctl_error(CERR_BADASSOC);
+                       return;
+               }
+       }
+
+       /*
+        * If we got here we have a peer which is a clock. Get his
+        * status.
+        */
+       clock_stat.kv_list = (struct ctl_var *)0;
+       refclock_control(&peer->srcadr, (struct refclockstat *)0,
+           &clock_stat);
+
+       /*
+        * Look for variables in the packet.
+        */
+       rpkt.status = htons(ctlclkstatus(&clock_stat));
+       gotvar = CC_MAXCODE + 1 + count_var(clock_stat.kv_list);
+       wants = (u_char *)emalloc(gotvar);
+       memset((char*)wants, 0, gotvar);
+       gotvar = 0;
+       while ((v = ctl_getitem(clock_var, &valuep)) != 0) {
+               if (v->flags & EOV) {
+                       if ((v = ctl_getitem(clock_stat.kv_list,
+                           &valuep)) != 0) {
+                               if (v->flags & EOV) {
+                                       ctl_error(CERR_UNKNOWNVAR);
+                                       free((char*)wants);
+                                       free_varlist(clock_stat.kv_list);
+                                       return;
+                               }
+                               wants[CC_MAXCODE + 1 + v->code] = 1;
+                               gotvar = 1;
+                               continue;
+                       } else {
+                               break; /* shouldn't happen ! */
+                       }
+               }
+               wants[v->code] = 1;
+               gotvar = 1;
+       }
+
+       if (gotvar) {
+               for (i = 1; i <= CC_MAXCODE; i++)
+                       if (wants[i])
+                       ctl_putclock(i, &clock_stat, 1);
+               for (i = 0; clock_stat.kv_list &&
+                   !(clock_stat.kv_list[i].flags & EOV); i++)
+                       if (wants[i + CC_MAXCODE + 1])
+                               ctl_putdata(clock_stat.kv_list[i].text,
+                                   strlen(clock_stat.kv_list[i].text),
+                                   0);
+       } else {
+               register u_char *cc;
+               register struct ctl_var *kv;
+
+               for (cc = def_clock_var; *cc != 0; cc++)
+                       ctl_putclock((int)*cc, &clock_stat, 0);
+               for (kv = clock_stat.kv_list; kv && !(kv->flags & EOV);
+                   kv++)
+                       if (kv->flags & DEF)
+                               ctl_putdata(kv->text, strlen(kv->text),
+                                   0);
+       }
+
+       free((char*)wants);
+       free_varlist(clock_stat.kv_list);
+
+       ctl_flushpkt(0);
+#endif
+}
+
+
+/*
+ * write_clock_status - we don't do this
+ */
+/*ARGSUSED*/
+static void
+write_clock_status(
+       struct recvbuf *rbufp,
+       int restrict_mask
+       )
+{
+       ctl_error(CERR_PERMISSION);
+}
+
+/*
+ * Trap support from here on down. We send async trap messages when the
+ * upper levels report trouble. Traps can by set either by control
+ * messages or by configuration.
+ */
+/*
+ * set_trap - set a trap in response to a control message
+ */
+static void
+set_trap(
+       struct recvbuf *rbufp,
+       int restrict_mask
+       )
+{
+       int traptype;
+
+       /*
+        * See if this guy is allowed
+        */
+       if (restrict_mask & RES_NOTRAP) {
+               ctl_error(CERR_PERMISSION);
+               return;
+       }
+
+       /*
+        * Determine his allowed trap type.
+        */
+       traptype = TRAP_TYPE_PRIO;
+       if (restrict_mask & RES_LPTRAP)
+               traptype = TRAP_TYPE_NONPRIO;
+
+       /*
+        * Call ctlsettrap() to do the work.  Return
+        * an error if it can't assign the trap.
+        */
+       if (!ctlsettrap(&rbufp->recv_srcadr, rbufp->dstadr, traptype,
+           (int)res_version))
+               ctl_error(CERR_NORESOURCE);
+       ctl_flushpkt(0);
+}
+
+
+/*
+ * unset_trap - unset a trap in response to a control message
+ */
+static void
+unset_trap(
+       struct recvbuf *rbufp,
+       int restrict_mask
+       )
+{
+       int traptype;
+
+       /*
+        * We don't prevent anyone from removing his own trap unless the
+        * trap is configured. Note we also must be aware of the
+        * possibility that restriction flags were changed since this
+        * guy last set his trap. Set the trap type based on this.
+        */
+       traptype = TRAP_TYPE_PRIO;
+       if (restrict_mask & RES_LPTRAP)
+               traptype = TRAP_TYPE_NONPRIO;
+
+       /*
+        * Call ctlclrtrap() to clear this out.
+        */
+       if (!ctlclrtrap(&rbufp->recv_srcadr, rbufp->dstadr, traptype))
+               ctl_error(CERR_BADASSOC);
+       ctl_flushpkt(0);
+}
+
+
+/*
+ * ctlsettrap - called to set a trap
+ */
+int
+ctlsettrap(
+       struct sockaddr_storage *raddr,
+       struct interface *linter,
+       int traptype,
+       int version
+       )
+{
+       register struct ctl_trap *tp;
+       register struct ctl_trap *tptouse;
+
+       /*
+        * See if we can find this trap.  If so, we only need update
+        * the flags and the time.
+        */
+       if ((tp = ctlfindtrap(raddr, linter)) != NULL) {
+               switch (traptype) {
+
+               case TRAP_TYPE_CONFIG:
+                       tp->tr_flags = TRAP_INUSE|TRAP_CONFIGURED;
+                       break;
+
+               case TRAP_TYPE_PRIO:
+                       if (tp->tr_flags & TRAP_CONFIGURED)
+                               return (1); /* don't change anything */
+                       tp->tr_flags = TRAP_INUSE;
+                       break;
+
+               case TRAP_TYPE_NONPRIO:
+                       if (tp->tr_flags & TRAP_CONFIGURED)
+                               return (1); /* don't change anything */
+                       tp->tr_flags = TRAP_INUSE|TRAP_NONPRIO;
+                       break;
+               }
+               tp->tr_settime = current_time;
+               tp->tr_resets++;
+               return (1);
+       }
+
+       /*
+        * First we heard of this guy.  Try to find a trap structure
+        * for him to use, clearing out lesser priority guys if we
+        * have to. Clear out anyone who's expired while we're at it.
+        */
+       tptouse = NULL;
+       for (tp = ctl_trap; tp < &ctl_trap[CTL_MAXTRAPS]; tp++) {
+               if ((tp->tr_flags & TRAP_INUSE) &&
+                   !(tp->tr_flags & TRAP_CONFIGURED) &&
+                   ((tp->tr_settime + CTL_TRAPTIME) > current_time)) {
+                       tp->tr_flags = 0;
+                       num_ctl_traps--;
+               }
+               if (!(tp->tr_flags & TRAP_INUSE)) {
+                       tptouse = tp;
+               } else if (!(tp->tr_flags & TRAP_CONFIGURED)) {
+                       switch (traptype) {
+
+                       case TRAP_TYPE_CONFIG:
+                               if (tptouse == NULL) {
+                                       tptouse = tp;
+                                       break;
+                               }
+                               if (tptouse->tr_flags & TRAP_NONPRIO &&
+                                   !(tp->tr_flags & TRAP_NONPRIO))
+                                       break;
+
+                               if (!(tptouse->tr_flags & TRAP_NONPRIO)
+                                   && tp->tr_flags & TRAP_NONPRIO) {
+                                       tptouse = tp;
+                                       break;
+                               }
+                               if (tptouse->tr_origtime <
+                                   tp->tr_origtime)
+                                       tptouse = tp;
+                               break;
+
+                       case TRAP_TYPE_PRIO:
+                               if (tp->tr_flags & TRAP_NONPRIO) {
+                                       if (tptouse == NULL ||
+                                           (tptouse->tr_flags &
+                                           TRAP_INUSE &&
+                                           tptouse->tr_origtime <
+                                           tp->tr_origtime))
+                                               tptouse = tp;
+                               }
+                               break;
+
+                       case TRAP_TYPE_NONPRIO:
+                               break;
+                       }
+               }
+       }
+
+       /*
+        * If we don't have room for him return an error.
+        */
+       if (tptouse == NULL)
+               return (0);
+
+       /*
+        * Set up this structure for him.
+        */
+       tptouse->tr_settime = tptouse->tr_origtime = current_time;
+       tptouse->tr_count = tptouse->tr_resets = 0;
+       tptouse->tr_sequence = 1;
+       tptouse->tr_addr = *raddr;
+       tptouse->tr_localaddr = linter;
+       tptouse->tr_version = (u_char) version;
+       tptouse->tr_flags = TRAP_INUSE;
+       if (traptype == TRAP_TYPE_CONFIG)
+               tptouse->tr_flags |= TRAP_CONFIGURED;
+       else if (traptype == TRAP_TYPE_NONPRIO)
+               tptouse->tr_flags |= TRAP_NONPRIO;
+       num_ctl_traps++;
+       return (1);
+}
+
+
+/*
+ * ctlclrtrap - called to clear a trap
+ */
+int
+ctlclrtrap(
+       struct sockaddr_storage *raddr,
+       struct interface *linter,
+       int traptype
+       )
+{
+       register struct ctl_trap *tp;
+
+       if ((tp = ctlfindtrap(raddr, linter)) == NULL)
+               return (0);
+
+       if (tp->tr_flags & TRAP_CONFIGURED
+               && traptype != TRAP_TYPE_CONFIG)
+               return (0);
+
+       tp->tr_flags = 0;
+       num_ctl_traps--;
+       return (1);
+}
+
+
+/*
+ * ctlfindtrap - find a trap given the remote and local addresses
+ */
+static struct ctl_trap *
+ctlfindtrap(
+       struct sockaddr_storage *raddr,
+       struct interface *linter
+       )
+{
+       register struct ctl_trap *tp;
+
+       for (tp = ctl_trap; tp < &ctl_trap[CTL_MAXTRAPS]; tp++) {
+               if ((tp->tr_flags & TRAP_INUSE)
+                   && (NSRCPORT(raddr) == NSRCPORT(&tp->tr_addr))
+                   && SOCKCMP(raddr, &tp->tr_addr)
+                   && (linter == tp->tr_localaddr) )
+               return (tp);
+       }
+       return (struct ctl_trap *)NULL;
+}
+
+
+/*
+ * report_event - report an event to the trappers
+ */
+void
+report_event(
+       int err,
+       struct peer *peer
+       )
+{
+       register int i;
+
+       /*
+        * Record error code in proper spots, but have mercy on the
+        * log file.
+        */
+       if (!(err & (PEER_EVENT | CRPT_EVENT))) {
+               if (ctl_sys_num_events < CTL_SYS_MAXEVENTS)
+                       ctl_sys_num_events++;
+               if (ctl_sys_last_event != (u_char)err) {
+                       NLOG(NLOG_SYSEVENT)
+                           msyslog(LOG_INFO, "system event '%s' (0x%02x) status '%s' (0x%02x)",
+                           eventstr(err), err,
+                           sysstatstr(ctlsysstatus()), ctlsysstatus());
+#ifdef DEBUG
+                       if (debug)
+                               printf("report_event: system event '%s' (0x%02x) status '%s' (0x%02x)\n",
+                                   eventstr(err), err,
+                                   sysstatstr(ctlsysstatus()),
+                                   ctlsysstatus());
+#endif
+                       ctl_sys_last_event = (u_char)err;
+               }
+       } else if (peer != 0) {
+               char *src;
+
+#ifdef REFCLOCK
+               if (ISREFCLOCKADR(&peer->srcadr))
+                       src = refnumtoa(&peer->srcadr);
+               else
+#endif
+                       src = stoa(&peer->srcadr);
+
+               peer->last_event = (u_char)(err & ~PEER_EVENT);
+               if (peer->num_events < CTL_PEER_MAXEVENTS)
+                       peer->num_events++;
+               NLOG(NLOG_PEEREVENT)
+                   msyslog(LOG_INFO, "peer %s event '%s' (0x%02x) status '%s' (0x%02x)",
+                   src, eventstr(err), err,
+                   peerstatstr(ctlpeerstatus(peer)),
+                   ctlpeerstatus(peer));
+#ifdef DEBUG
+               if (debug)
+                       printf( "peer %s event '%s' (0x%02x) status '%s' (0x%02x)\n",
+                           src, eventstr(err), err,
+                           peerstatstr(ctlpeerstatus(peer)),
+                           ctlpeerstatus(peer));
+#endif
+       } else {
+               msyslog(LOG_ERR,
+                   "report_event: err '%s' (0x%02x), no peer",
+                   eventstr(err), err);
+#ifdef DEBUG
+               printf(
+                   "report_event: peer event '%s' (0x%02x), no peer\n",
+                   eventstr(err), err);
+#endif
+               return;
+       }
+
+       /*
+        * If no trappers, return.
+        */
+       if (num_ctl_traps <= 0)
+               return;
+
+       /*
+        * Set up the outgoing packet variables
+        */
+       res_opcode = CTL_OP_ASYNCMSG;
+       res_offset = 0;
+       res_async = 1;
+       res_authenticate = 0;
+       datapt = rpkt.data;
+       dataend = &(rpkt.data[CTL_MAX_DATA_LEN]);
+       if (!(err & PEER_EVENT)) {
+               rpkt.associd = 0;
+               rpkt.status = htons(ctlsysstatus());
+
+               /*
+                * For now, put everything we know about system
+                * variables. Don't send crypto strings.
+                */
+               for (i = 1; i <= CS_MAXCODE; i++) {
+#ifdef OPENSSL
+                       if (i > CS_VARLIST)
+                               continue;
+#endif /* OPENSSL */
+                       ctl_putsys(i);
+               }
+#ifdef REFCLOCK
+               /*
+                * for clock exception events: add clock variables to
+                * reflect info on exception
+                */
+               if (err == EVNT_CLOCKEXCPT) {
+                       struct refclockstat clock_stat;
+                       struct ctl_var *kv;
+
+                       clock_stat.kv_list = (struct ctl_var *)0;
+                       refclock_control(&peer->srcadr,
+                           (struct refclockstat *)0, &clock_stat);
+                       ctl_puthex("refclockstatus",
+                           ctlclkstatus(&clock_stat));
+                       for (i = 1; i <= CC_MAXCODE; i++)
+                               ctl_putclock(i, &clock_stat, 0);
+                       for (kv = clock_stat.kv_list; kv &&
+                           !(kv->flags & EOV); kv++)
+                               if (kv->flags & DEF)
+                                       ctl_putdata(kv->text,
+                                           strlen(kv->text), 0);
+                       free_varlist(clock_stat.kv_list);
+               }
+#endif /* REFCLOCK */
+       } else {
+               rpkt.associd = htons(peer->associd);
+               rpkt.status = htons(ctlpeerstatus(peer));
+
+               /*
+                * Dump it all. Later, maybe less.
+                */
+               for (i = 1; i <= CP_MAXCODE; i++) {
+#ifdef OPENSSL
+                       if (i > CP_VARLIST)
+                               continue;
+#endif /* OPENSSL */
+                       ctl_putpeer(i, peer);
+               }
+#ifdef REFCLOCK
+               /*
+                * for clock exception events: add clock variables to
+                * reflect info on exception
+                */
+               if (err == EVNT_PEERCLOCK) {
+                       struct refclockstat clock_stat;
+                       struct ctl_var *kv;
+
+                       clock_stat.kv_list = (struct ctl_var *)0;
+                       refclock_control(&peer->srcadr,
+                           (struct refclockstat *)0, &clock_stat);
+
+                       ctl_puthex("refclockstatus",
+                           ctlclkstatus(&clock_stat));
+
+                       for (i = 1; i <= CC_MAXCODE; i++)
+                               ctl_putclock(i, &clock_stat, 0);
+                       for (kv = clock_stat.kv_list; kv &&
+                           !(kv->flags & EOV); kv++)
+                               if (kv->flags & DEF)
+                                       ctl_putdata(kv->text,
+                                           strlen(kv->text), 0);
+                       free_varlist(clock_stat.kv_list);
+               }
+#endif /* REFCLOCK */
+       }
+
+       /*
+        * We're done, return.
+        */
+       ctl_flushpkt(0);
+}
+
+
+/*
+ * ctl_clr_stats - clear stat counters
+ */
+void
+ctl_clr_stats(void)
+{
+       ctltimereset = current_time;
+       numctlreq = 0;
+       numctlbadpkts = 0;
+       numctlresponses = 0;
+       numctlfrags = 0;
+       numctlerrors = 0;
+       numctlfrags = 0;
+       numctltooshort = 0;
+       numctlinputresp = 0;
+       numctlinputfrag = 0;
+       numctlinputerr = 0;
+       numctlbadoffset = 0;
+       numctlbadversion = 0;
+       numctldatatooshort = 0;
+       numctlbadop = 0;
+       numasyncmsgs = 0;
+}
+
+static u_long
+count_var(
+       struct ctl_var *k
+       )
+{
+       register u_long c;
+
+       if (!k)
+               return (0);
+
+       c = 0;
+       while (!(k++->flags & EOV))
+               c++;
+       return (c);
+}
+
+char *
+add_var(
+       struct ctl_var **kv,
+       u_long size,
+       u_short def
+       )
+{
+       register u_long c;
+       register struct ctl_var *k;
+
+       c = count_var(*kv);
+
+       k = *kv;
+       *kv  = (struct ctl_var *)emalloc((c+2)*sizeof(struct ctl_var));
+       if (k) {
+               memmove((char *)*kv, (char *)k,
+                   sizeof(struct ctl_var)*c);
+               free((char *)k);
+       }
+       (*kv)[c].code  = (u_short) c;
+       (*kv)[c].text  = (char *)emalloc(size);
+       (*kv)[c].flags = def;
+       (*kv)[c+1].code  = 0;
+       (*kv)[c+1].text  = (char *)0;
+       (*kv)[c+1].flags = EOV;
+       return (char *)(*kv)[c].text;
+}
+
+void
+set_var(
+       struct ctl_var **kv,
+       const char *data,
+       u_long size,
+       u_short def
+       )
+{
+       register struct ctl_var *k;
+       register const char *s;
+       register const char *t;
+       char *td;
+
+       if (!data || !size)
+               return;
+
+       k = *kv;
+       if (k != NULL) {
+               while (!(k->flags & EOV)) {
+                       s = data;
+                       t = k->text;
+                       if (t)  {
+                               while (*t != '=' && *s - *t == 0) {
+                                       s++;
+                                       t++;
+                               }
+                               if (*s == *t && ((*t == '=') || !*t)) {
+                                       free((void *)k->text);
+                                       td = (char *)emalloc(size);
+                                       memmove(td, data, size);
+                                       k->text =td;
+                                       k->flags = def;
+                                       return;
+                               }
+                       } else {
+                               td = (char *)emalloc(size);
+                               memmove(td, data, size);
+                               k->text = td;
+                               k->flags = def;
+                               return;
+                       }
+                       k++;
+               }
+       }
+       td = add_var(kv, size, def);
+       memmove(td, data, size);
+}
+
+void
+set_sys_var(
+       const char *data,
+       u_long size,
+       u_short def
+       )
+{
+       set_var(&ext_sys_var, data, size, def);
+}
+
+void
+free_varlist(
+       struct ctl_var *kv
+       )
+{
+       struct ctl_var *k;
+       if (kv) {
+               for (k = kv; !(k->flags & EOV); k++)
+                       free((void *)k->text);
+               free((void *)kv);
+       }
+}
diff --git a/ntpd/ntp_crypto.c b/ntpd/ntp_crypto.c
new file mode 100644 (file)
index 0000000..cce95a8
--- /dev/null
@@ -0,0 +1,4189 @@
+/*
+ * ntp_crypto.c - NTP version 4 public key routines
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef OPENSSL
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/param.h>
+#include <unistd.h>
+#include <fcntl.h>
+
+#include "ntpd.h"
+#include "ntp_stdlib.h"
+#include "ntp_unixtime.h"
+#include "ntp_string.h"
+#include <ntp_random.h>
+
+#include "openssl/asn1_mac.h"
+#include "openssl/bn.h"
+#include "openssl/err.h"
+#include "openssl/evp.h"
+#include "openssl/pem.h"
+#include "openssl/rand.h"
+#include "openssl/x509v3.h"
+
+#ifdef KERNEL_PLL
+#include "ntp_syscall.h"
+#endif /* KERNEL_PLL */
+
+/*
+ * Extension field message format
+ *
+ * These are always signed and saved before sending in network byte
+ * order. They must be converted to and from host byte order for
+ * processing.
+ *
+ * +-------+-------+
+ * |   op  |  len  | <- extension pointer
+ * +-------+-------+
+ * |    assocID    |
+ * +---------------+
+ * |   timestamp   | <- value pointer
+ * +---------------+
+ * |   filestamp   |
+ * +---------------+
+ * |   value len   |
+ * +---------------+
+ * |               |
+ * =     value     =
+ * |               |
+ * +---------------+
+ * | signature len |
+ * +---------------+
+ * |               |
+ * =   signature   =
+ * |               |
+ * +---------------+
+ *
+ * The CRYPTO_RESP bit is set to 0 for requests, 1 for responses.
+ * Requests carry the association ID of the receiver; responses carry
+ * the association ID of the sender. Some messages include only the
+ * operation/length and association ID words and so have length 8
+ * octets. Ohers include the value structure and associated value and
+ * signature fields. These messages include the timestamp, filestamp,
+ * value and signature words and so have length at least 24 octets. The
+ * signature and/or value fields can be empty, in which case the
+ * respective length words are zero. An empty value with nonempty
+ * signature is syntactically valid, but semantically questionable.
+ *
+ * The filestamp represents the time when a cryptographic data file such
+ * as a public/private key pair is created. It follows every reference
+ * depending on that file and serves as a means to obsolete earlier data
+ * of the same type. The timestamp represents the time when the
+ * cryptographic data of the message were last signed. Creation of a
+ * cryptographic data file or signing a message can occur only when the
+ * creator or signor is synchronized to an authoritative source and
+ * proventicated to a trusted authority.
+ *
+ * Note there are four conditions required for server trust. First, the
+ * public key on the certificate must be verified, which involves a
+ * number of format, content and consistency checks. Next, the server
+ * identity must be confirmed by one of four schemes: private
+ * certificate, IFF scheme, GQ scheme or certificate trail hike to a
+ * self signed trusted certificate. Finally, the server signature must
+ * be verified.
+ */
+/*
+ * Cryptodefines
+ */
+#define TAI_1972       10      /* initial TAI offset (s) */
+#define MAX_LEAP       100     /* max UTC leapseconds (s) */
+#define VALUE_LEN      (6 * 4) /* min response field length */
+#define YEAR           (60 * 60 * 24 * 365) /* seconds in year */
+
+/*
+ * Global cryptodata in host byte order
+ */
+u_int32        crypto_flags = 0x0;     /* status word */
+
+/*
+ * Global cryptodata in network byte order
+ */
+struct cert_info *cinfo = NULL;        /* certificate info/value */
+struct value hostval;          /* host value */
+struct value pubkey;           /* public key */
+struct value tai_leap;         /* leapseconds table */
+EVP_PKEY *iffpar_pkey = NULL;  /* IFF parameters */
+EVP_PKEY *gqpar_pkey = NULL;   /* GQ parameters */
+EVP_PKEY *mvpar_pkey = NULL;   /* MV parameters */
+char   *iffpar_file = NULL; /* IFF parameters file */
+char   *gqpar_file = NULL;     /* GQ parameters file */
+char   *mvpar_file = NULL;     /* MV parameters file */
+
+/*
+ * Private cryptodata in host byte order
+ */
+static char *passwd = NULL;    /* private key password */
+static EVP_PKEY *host_pkey = NULL; /* host key */
+static EVP_PKEY *sign_pkey = NULL; /* sign key */
+static const EVP_MD *sign_digest = NULL; /* sign digest */
+static u_int sign_siglen;      /* sign key length */
+static char *rand_file = NULL; /* random seed file */
+static char *host_file = NULL; /* host key file */
+static char *sign_file = NULL; /* sign key file */
+static char *cert_file = NULL; /* certificate file */
+static char *leap_file = NULL; /* leapseconds file */
+static tstamp_t if_fstamp = 0; /* IFF filestamp */
+static tstamp_t gq_fstamp = 0; /* GQ file stamp */
+static tstamp_t mv_fstamp = 0; /* MV filestamp */
+static u_int ident_scheme = 0; /* server identity scheme */
+
+/*
+ * Cryptotypes
+ */
+static int     crypto_verify   P((struct exten *, struct value *,
+                                   struct peer *));
+static int     crypto_encrypt  P((struct exten *, struct value *,
+                                   keyid_t *));
+static int     crypto_alice    P((struct peer *, struct value *));
+static int     crypto_alice2   P((struct peer *, struct value *));
+static int     crypto_alice3   P((struct peer *, struct value *));
+static int     crypto_bob      P((struct exten *, struct value *));
+static int     crypto_bob2     P((struct exten *, struct value *));
+static int     crypto_bob3     P((struct exten *, struct value *));
+static int     crypto_iff      P((struct exten *, struct peer *));
+static int     crypto_gq       P((struct exten *, struct peer *));
+static int     crypto_mv       P((struct exten *, struct peer *));
+static u_int   crypto_send     P((struct exten *, struct value *));
+static tstamp_t crypto_time    P((void));
+static u_long  asn2ntp         P((ASN1_TIME *));
+static struct cert_info *cert_parse P((u_char *, u_int, tstamp_t));
+static int     cert_sign       P((struct exten *, struct value *));
+static int     cert_valid      P((struct cert_info *, EVP_PKEY *));
+static int     cert_install    P((struct exten *, struct peer *));
+static void    cert_free       P((struct cert_info *));
+static EVP_PKEY *crypto_key    P((char *, tstamp_t *));
+static int     bighash         P((BIGNUM *, BIGNUM *));
+static struct cert_info *crypto_cert P((char *));
+static void    crypto_tai      P((char *));
+
+#ifdef SYS_WINNT
+int
+readlink(char * link, char * file, int len) {
+       return (-1);
+}
+#endif
+
+/*
+ * session_key - generate session key
+ *
+ * This routine generates a session key from the source address,
+ * destination address, key ID and private value. The value of the
+ * session key is the MD5 hash of these values, while the next key ID is
+ * the first four octets of the hash.
+ *
+ * Returns the next key ID
+ */
+keyid_t
+session_key(
+       struct sockaddr_storage *srcadr, /* source address */
+       struct sockaddr_storage *dstadr, /* destination address */
+       keyid_t keyno,          /* key ID */
+       keyid_t private,        /* private value */
+       u_long  lifetime        /* key lifetime */
+       )
+{
+       EVP_MD_CTX ctx;         /* message digest context */
+       u_char dgst[EVP_MAX_MD_SIZE]; /* message digest */
+       keyid_t keyid;          /* key identifer */
+       u_int32 header[10];     /* data in network byte order */
+       u_int   hdlen, len;
+
+       if (!dstadr)
+               return 0;
+       
+       /*
+        * Generate the session key and key ID. If the lifetime is
+        * greater than zero, install the key and call it trusted.
+        */
+       hdlen = 0;
+       switch(srcadr->ss_family) {
+       case AF_INET:
+               header[0] = ((struct sockaddr_in *)srcadr)->sin_addr.s_addr;
+               header[1] = ((struct sockaddr_in *)dstadr)->sin_addr.s_addr;
+               header[2] = htonl(keyno);
+               header[3] = htonl(private);
+               hdlen = 4 * sizeof(u_int32);
+               break;
+
+       case AF_INET6:
+               memcpy(&header[0], &GET_INADDR6(*srcadr),
+                   sizeof(struct in6_addr));
+               memcpy(&header[4], &GET_INADDR6(*dstadr),
+                   sizeof(struct in6_addr));
+               header[8] = htonl(keyno);
+               header[9] = htonl(private);
+               hdlen = 10 * sizeof(u_int32);
+               break;
+       }
+       EVP_DigestInit(&ctx, EVP_md5());
+       EVP_DigestUpdate(&ctx, (u_char *)header, hdlen);
+       EVP_DigestFinal(&ctx, dgst, &len);
+       memcpy(&keyid, dgst, 4);
+       keyid = ntohl(keyid);
+       if (lifetime != 0) {
+               MD5auth_setkey(keyno, dgst, len);
+               authtrust(keyno, lifetime);
+       }
+#ifdef DEBUG
+       if (debug > 1)
+               printf(
+                   "session_key: %s > %s %08x %08x hash %08x life %lu\n",
+                   stoa(srcadr), stoa(dstadr), keyno,
+                   private, keyid, lifetime);
+#endif
+       return (keyid);
+}
+
+
+/*
+ * make_keylist - generate key list
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_PER   host certificate expired
+ *
+ * This routine constructs a pseudo-random sequence by repeatedly
+ * hashing the session key starting from a given source address,
+ * destination address, private value and the next key ID of the
+ * preceeding session key. The last entry on the list is saved along
+ * with its sequence number and public signature.
+ */
+int
+make_keylist(
+       struct peer *peer,      /* peer structure pointer */
+       struct interface *dstadr /* interface */
+       )
+{
+       EVP_MD_CTX ctx;         /* signature context */
+       tstamp_t tstamp;        /* NTP timestamp */
+       struct autokey *ap;     /* autokey pointer */
+       struct value *vp;       /* value pointer */
+       keyid_t keyid = 0;      /* next key ID */
+       keyid_t cookie;         /* private value */
+       u_long  lifetime;
+       u_int   len, mpoll;
+       int     i;
+
+       if (!dstadr)
+               return XEVNT_OK;
+       
+       /*
+        * Allocate the key list if necessary.
+        */
+       tstamp = crypto_time();
+       if (peer->keylist == NULL)
+               peer->keylist = emalloc(sizeof(keyid_t) *
+                   NTP_MAXSESSION);
+
+       /*
+        * Generate an initial key ID which is unique and greater than
+        * NTP_MAXKEY.
+        */
+       while (1) {
+               keyid = (ntp_random() + NTP_MAXKEY + 1) & ((1 <<
+                   sizeof(keyid_t)) - 1);
+               if (authhavekey(keyid))
+                       continue;
+               break;
+       }
+
+       /*
+        * Generate up to NTP_MAXSESSION session keys. Stop if the
+        * next one would not be unique or not a session key ID or if
+        * it would expire before the next poll. The private value
+        * included in the hash is zero if broadcast mode, the peer
+        * cookie if client mode or the host cookie if symmetric modes.
+        */
+       mpoll = 1 << min(peer->ppoll, peer->hpoll);
+       lifetime = min(sys_automax, NTP_MAXSESSION * mpoll);
+       if (peer->hmode == MODE_BROADCAST)
+               cookie = 0;
+       else
+               cookie = peer->pcookie;
+       for (i = 0; i < NTP_MAXSESSION; i++) {
+               peer->keylist[i] = keyid;
+               peer->keynumber = i;
+               keyid = session_key(&dstadr->sin, &peer->srcadr, keyid,
+                   cookie, lifetime);
+               lifetime -= mpoll;
+               if (auth_havekey(keyid) || keyid <= NTP_MAXKEY ||
+                   lifetime <= mpoll)
+                       break;
+       }
+
+       /*
+        * Save the last session key ID, sequence number and timestamp,
+        * then sign these values for later retrieval by the clients. Be
+        * careful not to use invalid key media. Use the public values
+        * timestamp as filestamp. 
+        */
+       vp = &peer->sndval;
+       if (vp->ptr == NULL)
+               vp->ptr = emalloc(sizeof(struct autokey));
+       ap = (struct autokey *)vp->ptr;
+       ap->seq = htonl(peer->keynumber);
+       ap->key = htonl(keyid);
+       vp->tstamp = htonl(tstamp);
+       vp->fstamp = hostval.tstamp;
+       vp->vallen = htonl(sizeof(struct autokey));
+       vp->siglen = 0;
+       if (tstamp != 0) {
+               if (tstamp < cinfo->first || tstamp > cinfo->last)
+                       return (XEVNT_PER);
+
+               if (vp->sig == NULL)
+                       vp->sig = emalloc(sign_siglen);
+               EVP_SignInit(&ctx, sign_digest);
+               EVP_SignUpdate(&ctx, (u_char *)vp, 12);
+               EVP_SignUpdate(&ctx, vp->ptr, sizeof(struct autokey));
+               if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
+                       vp->siglen = htonl(len);
+               else
+                       msyslog(LOG_ERR, "make_keys %s\n",
+                           ERR_error_string(ERR_get_error(), NULL));
+               peer->flags |= FLAG_ASSOC;
+       }
+#ifdef DEBUG
+       if (debug)
+               printf("make_keys: %d %08x %08x ts %u fs %u poll %d\n",
+                   ntohl(ap->seq), ntohl(ap->key), cookie,
+                   ntohl(vp->tstamp), ntohl(vp->fstamp), peer->hpoll);
+#endif
+       return (XEVNT_OK);
+}
+
+
+/*
+ * crypto_recv - parse extension fields
+ *
+ * This routine is called when the packet has been matched to an
+ * association and passed sanity, format and MAC checks. We believe the
+ * extension field values only if the field has proper format and
+ * length, the timestamp and filestamp are valid and the signature has
+ * valid length and is verified. There are a few cases where some values
+ * are believed even if the signature fails, but only if the proventic
+ * bit is not set.
+ */
+int
+crypto_recv(
+       struct peer *peer,      /* peer structure pointer */
+       struct recvbuf *rbufp   /* packet buffer pointer */
+       )
+{
+       const EVP_MD *dp;       /* message digest algorithm */
+       u_int32 *pkt;           /* receive packet pointer */
+       struct autokey *ap, *bp; /* autokey pointer */
+       struct exten *ep, *fp;  /* extension pointers */
+       int     has_mac;        /* length of MAC field */
+       int     authlen;        /* offset of MAC field */
+       associd_t associd;      /* association ID */
+       tstamp_t tstamp = 0;    /* timestamp */
+       tstamp_t fstamp = 0;    /* filestamp */
+       u_int   len;            /* extension field length */
+       u_int   code;           /* extension field opcode */
+       u_int   vallen = 0;     /* value length */
+       X509    *cert;          /* X509 certificate */
+       char    statstr[NTP_MAXSTRLEN]; /* statistics for filegen */
+       keyid_t cookie;         /* crumbles */
+       int     hismode;        /* packet mode */
+       int     rval = XEVNT_OK;
+       u_char  *ptr;
+       u_int32 temp32;
+
+       /*
+        * Initialize. Note that the packet has already been checked for
+        * valid format and extension field lengths. First extract the
+        * field length, command code and association ID in host byte
+        * order. These are used with all commands and modes. Then check
+        * the version number, which must be 2, and length, which must
+        * be at least 8 for requests and VALUE_LEN (24) for responses.
+        * Packets that fail either test sink without a trace. The
+        * association ID is saved only if nonzero.
+        */
+       authlen = LEN_PKT_NOMAC;
+       hismode = (int)PKT_MODE((&rbufp->recv_pkt)->li_vn_mode);
+       while ((has_mac = rbufp->recv_length - authlen) > MAX_MAC_LEN) {
+               pkt = (u_int32 *)&rbufp->recv_pkt + authlen / 4;
+               ep = (struct exten *)pkt;
+               code = ntohl(ep->opcode) & 0xffff0000;
+               len = ntohl(ep->opcode) & 0x0000ffff;
+               associd = (associd_t) ntohl(pkt[1]);
+               rval = XEVNT_OK;
+#ifdef DEBUG
+               if (debug)
+                       printf(
+                           "crypto_recv: flags 0x%x ext offset %d len %u code 0x%x assocID %d\n",
+                           peer->crypto, authlen, len, code >> 16,
+                           associd);
+#endif
+
+               /*
+                * Check version number and field length. If bad,
+                * quietly ignore the packet.
+                */
+               if (((code >> 24) & 0x3f) != CRYPTO_VN || len < 8) {
+                       sys_unknownversion++;
+                       code |= CRYPTO_ERROR;
+               }
+
+               /*
+                * Little vulnerability bandage here. If a perp tosses a
+                * fake association ID over the fence, we better toss it
+                * out. Only the first one counts.
+                */
+               if (code & CRYPTO_RESP) {
+                       if (peer->assoc == 0)
+                               peer->assoc = associd;
+                       else if (peer->assoc != associd)
+                               code |= CRYPTO_ERROR;
+               }
+               if (len >= VALUE_LEN) {
+                       tstamp = ntohl(ep->tstamp);
+                       fstamp = ntohl(ep->fstamp);
+                       vallen = ntohl(ep->vallen);
+               }
+               switch (code) {
+
+               /*
+                * Install status word, host name, signature scheme and
+                * association ID. In OpenSSL the signature algorithm is
+                * bound to the digest algorithm, so the NID completely
+                * defines the signature scheme. Note the request and
+                * response are identical, but neither is validated by
+                * signature. The request is processed here only in
+                * symmetric modes. The server name field might be
+                * useful to implement access controls in future.
+                */
+               case CRYPTO_ASSOC:
+
+                       /*
+                        * If the machine is running when this message
+                        * arrives, the other fellow has reset and so
+                        * must we. Otherwise, pass the extension field
+                        * to the transmit side.
+                        */
+                       if (peer->crypto) {
+                               rval = XEVNT_ERR;
+                               break;
+                       }
+                       fp = emalloc(len);
+                       memcpy(fp, ep, len);
+                       temp32 = CRYPTO_RESP;
+                       fp->opcode |= htonl(temp32);
+                       peer->cmmd = fp;
+                       /* fall through */
+
+               case CRYPTO_ASSOC | CRYPTO_RESP:
+
+                       /*
+                        * Discard the message if it has already been
+                        * stored or the message has been amputated.
+                        */
+                       if (peer->crypto)
+                               break;
+
+                       if (vallen == 0 || vallen > MAXHOSTNAME ||
+                           len < VALUE_LEN + vallen) {
+                               rval = XEVNT_LEN;
+                               break;
+                       }
+
+                       /*
+                        * Check the identity schemes are compatible. If
+                        * the client has PC, the server must have PC,
+                        * in which case the server public key and
+                        * identity are presumed valid, so we skip the
+                        * certificate and identity exchanges and move
+                        * immediately to the cookie exchange which
+                        * confirms the server signature.
+                        */
+#ifdef DEBUG
+                       if (debug)
+                               printf(
+                                   "crypto_recv: ident host 0x%x server 0x%x\n",
+                                   crypto_flags, fstamp);
+#endif
+                       temp32 = (crypto_flags | ident_scheme) &
+                           fstamp & CRYPTO_FLAG_MASK;
+                       if (crypto_flags & CRYPTO_FLAG_PRIV) {
+                               if (!(fstamp & CRYPTO_FLAG_PRIV)) {
+                                       rval = XEVNT_KEY;
+                                       break;
+
+                               } else {
+                                       fstamp |= CRYPTO_FLAG_VALID |
+                                           CRYPTO_FLAG_VRFY |
+                                           CRYPTO_FLAG_SIGN;
+                               }
+                       /*
+                        * In symmetric modes it is an error if either
+                        * peer requests identity and the other peer
+                        * does not support it.
+                        */
+                       } else if ((hismode == MODE_ACTIVE || hismode ==
+                           MODE_PASSIVE) && ((crypto_flags | fstamp) &
+                           CRYPTO_FLAG_MASK) && !temp32) {
+                               rval = XEVNT_KEY;
+                               break;
+                       /*
+                        * It is an error if the client requests
+                        * identity and the server does not support it.
+                        */
+                       } else if (hismode == MODE_CLIENT && (fstamp &
+                           CRYPTO_FLAG_MASK) && !temp32) {
+                               rval = XEVNT_KEY;
+                               break;
+                       }
+
+                       /*
+                        * Otherwise, the identity scheme(s) are those
+                        * that both client and server support.
+                        */
+                       fstamp = temp32 | (fstamp & ~CRYPTO_FLAG_MASK);
+
+                       /*
+                        * Discard the message if the signature digest
+                        * NID is not supported.
+                        */
+                       temp32 = (fstamp >> 16) & 0xffff;
+                       dp =
+                           (const EVP_MD *)EVP_get_digestbynid(temp32);
+                       if (dp == NULL) {
+                               rval = XEVNT_MD;
+                               break;
+                       }
+
+                       /*
+                        * Save status word, host name and message
+                        * digest/signature type.
+                        */
+                       peer->crypto = fstamp;
+                       peer->digest = dp;
+                       peer->subject = emalloc(vallen + 1);
+                       memcpy(peer->subject, ep->pkt, vallen);
+                       peer->subject[vallen] = '\0';
+                       peer->issuer = emalloc(vallen + 1);
+                       strcpy(peer->issuer, peer->subject);
+                       temp32 = (fstamp >> 16) & 0xffff;
+                       snprintf(statstr, NTP_MAXSTRLEN,
+                           "flags 0x%x host %s signature %s", fstamp,
+                           peer->subject, OBJ_nid2ln(temp32));
+                       record_crypto_stats(&peer->srcadr, statstr);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+
+               /*
+                * Decode X509 certificate in ASN.1 format and extract
+                * the data containing, among other things, subject
+                * name and public key. In the default identification
+                * scheme, the certificate trail is followed to a self
+                * signed trusted certificate.
+                */
+               case CRYPTO_CERT | CRYPTO_RESP:
+
+                       /*
+                        * Discard the message if invalid.
+                        */
+                       if ((rval = crypto_verify(ep, NULL, peer)) !=
+                           XEVNT_OK)
+                               break;
+
+                       /*
+                        * Scan the certificate list to delete old
+                        * versions and link the newest version first on
+                        * the list.
+                        */
+                       if ((rval = cert_install(ep, peer)) != XEVNT_OK)
+                               break;
+
+                       /*
+                        * If we snatch the certificate before the
+                        * server certificate has been signed by its
+                        * server, it will be self signed. When it is,
+                        * we chase the certificate issuer, which the
+                        * server has, and keep going until a self
+                        * signed trusted certificate is found. Be sure
+                        * to update the issuer field, since it may
+                        * change.
+                        */
+                       if (peer->issuer != NULL)
+                               free(peer->issuer);
+                       peer->issuer = emalloc(strlen(cinfo->issuer) +
+                           1);
+                       strcpy(peer->issuer, cinfo->issuer);
+
+                       /*
+                        * We plug in the public key and lifetime from
+                        * the first certificate received. However, note
+                        * that this certificate might not be signed by
+                        * the server, so we can't check the
+                        * signature/digest NID.
+                        */
+                       if (peer->pkey == NULL) {
+                               ptr = (u_char *)cinfo->cert.ptr;
+                               cert = d2i_X509(NULL, &ptr,
+                                   ntohl(cinfo->cert.vallen));
+                               peer->pkey = X509_get_pubkey(cert);
+                               X509_free(cert);
+                       }
+                       peer->flash &= ~TEST8;
+                       temp32 = cinfo->nid;
+                       snprintf(statstr, NTP_MAXSTRLEN,
+                           "cert %s 0x%x %s (%u) fs %u",
+                           cinfo->subject, cinfo->flags,
+                           OBJ_nid2ln(temp32), temp32,
+                           ntohl(ep->fstamp));
+                       record_crypto_stats(&peer->srcadr, statstr);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+
+               /*
+                * Schnorr (IFF)identity scheme. This scheme is designed
+                * for use with shared secret group keys and where the
+                * certificate may be generated by a third party. The
+                * client sends a challenge to the server, which
+                * performs a calculation and returns the result. A
+                * positive result is possible only if both client and
+                * server contain the same secret group key.
+                */
+               case CRYPTO_IFF | CRYPTO_RESP:
+
+                       /*
+                        * Discard the message if invalid or certificate
+                        * trail not trusted.
+                        */
+                       if (!(peer->crypto & CRYPTO_FLAG_VALID)) {
+                               rval = XEVNT_ERR;
+                               break;
+                       }
+                       if ((rval = crypto_verify(ep, NULL, peer)) !=
+                           XEVNT_OK)
+                               break;
+
+                       /*
+                        * If the the challenge matches the response,
+                        * the certificate public key, as well as the
+                        * server public key, signatyre and identity are
+                        * all verified at the same time. The server is
+                        * declared trusted, so we skip further
+                        * certificate stages and move immediately to
+                        * the cookie stage.
+                        */
+                       if ((rval = crypto_iff(ep, peer)) != XEVNT_OK)
+                               break;
+
+                       peer->crypto |= CRYPTO_FLAG_VRFY |
+                           CRYPTO_FLAG_PROV;
+                       peer->flash &= ~TEST8;
+                       snprintf(statstr, NTP_MAXSTRLEN, "iff fs %u",
+                           ntohl(ep->fstamp));
+                       record_crypto_stats(&peer->srcadr, statstr);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+
+               /*
+                * Guillou-Quisquater (GQ) identity scheme. This scheme
+                * is designed for use with public certificates carrying
+                * the GQ public key in an extension field. The client
+                * sends a challenge to the server, which performs a
+                * calculation and returns the result. A positive result
+                * is possible only if both client and server contain
+                * the same group key and the server has the matching GQ
+                * private key.
+                */
+               case CRYPTO_GQ | CRYPTO_RESP:
+
+                       /*
+                        * Discard the message if invalid or certificate
+                        * trail not trusted.
+                        */
+                       if (!(peer->crypto & CRYPTO_FLAG_VALID)) {
+                               rval = XEVNT_ERR;
+                               break;
+                       }
+                       if ((rval = crypto_verify(ep, NULL, peer)) !=
+                           XEVNT_OK)
+                               break;
+
+                       /*
+                        * If the the challenge matches the response,
+                        * the certificate public key, as well as the
+                        * server public key, signatyre and identity are
+                        * all verified at the same time. The server is
+                        * declared trusted, so we skip further
+                        * certificate stages and move immediately to
+                        * the cookie stage.
+                        */
+                       if ((rval = crypto_gq(ep, peer)) != XEVNT_OK)
+                               break;
+
+                       peer->crypto |= CRYPTO_FLAG_VRFY |
+                           CRYPTO_FLAG_PROV;
+                       peer->flash &= ~TEST8;
+                       snprintf(statstr, NTP_MAXSTRLEN, "gq fs %u",
+                           ntohl(ep->fstamp));
+                       record_crypto_stats(&peer->srcadr, statstr);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+
+               /*
+                * MV
+                */
+               case CRYPTO_MV | CRYPTO_RESP:
+
+                       /*
+                        * Discard the message if invalid or certificate
+                        * trail not trusted.
+                        */
+                       if (!(peer->crypto & CRYPTO_FLAG_VALID)) {
+                               rval = XEVNT_ERR;
+                               break;
+                       }
+                       if ((rval = crypto_verify(ep, NULL, peer)) !=
+                           XEVNT_OK)
+                               break;
+
+                       /*
+                        * If the the challenge matches the response,
+                        * the certificate public key, as well as the
+                        * server public key, signatyre and identity are
+                        * all verified at the same time. The server is
+                        * declared trusted, so we skip further
+                        * certificate stages and move immediately to
+                        * the cookie stage.
+                        */
+                       if ((rval = crypto_mv(ep, peer)) != XEVNT_OK)
+                               break;
+
+                       peer->crypto |= CRYPTO_FLAG_VRFY |
+                           CRYPTO_FLAG_PROV;
+                       peer->flash &= ~TEST8;
+                       snprintf(statstr, NTP_MAXSTRLEN, "mv fs %u",
+                           ntohl(ep->fstamp));
+                       record_crypto_stats(&peer->srcadr, statstr);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+
+               /*
+                * Cookie request in symmetric modes. Roll a random
+                * cookie and install in symmetric mode. Encrypt for the
+                * response, which is transmitted later.
+                */
+               case CRYPTO_COOK:
+
+                       /*
+                        * Discard the message if invalid or certificate
+                        * trail not trusted.
+                        */
+                       if (!(peer->crypto & CRYPTO_FLAG_VALID)) {
+                               rval = XEVNT_ERR;
+                               break;
+                       }
+                       if ((rval = crypto_verify(ep, NULL, peer)) !=
+                           XEVNT_OK)
+                               break;
+
+                       /*
+                        * Pass the extension field to the transmit
+                        * side. If already agreed, walk away.
+                        */
+                       fp = emalloc(len);
+                       memcpy(fp, ep, len);
+                       temp32 = CRYPTO_RESP;
+                       fp->opcode |= htonl(temp32);
+                       peer->cmmd = fp;
+                       if (peer->crypto & CRYPTO_FLAG_AGREE) {
+                               peer->flash &= ~TEST8;
+                               break;
+                       }
+
+                       /*
+                        * Install cookie values and light the cookie
+                        * bit. The transmit side will pick up and
+                        * encrypt it for the response.
+                        */
+                       key_expire(peer);
+                       peer->cookval.tstamp = ep->tstamp;
+                       peer->cookval.fstamp = ep->fstamp;
+                       RAND_bytes((u_char *)&peer->pcookie, 4);
+                       peer->crypto &= ~CRYPTO_FLAG_AUTO;
+                       peer->crypto |= CRYPTO_FLAG_AGREE;
+                       peer->flash &= ~TEST8;
+                       snprintf(statstr, NTP_MAXSTRLEN, "cook %x ts %u fs %u",
+                           peer->pcookie, ntohl(ep->tstamp),
+                           ntohl(ep->fstamp));
+                       record_crypto_stats(&peer->srcadr, statstr);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+
+               /*
+                * Cookie response in client and symmetric modes. If the
+                * cookie bit is set, the working cookie is the EXOR of
+                * the current and new values.
+                */
+               case CRYPTO_COOK | CRYPTO_RESP:
+
+                       /*
+                        * Discard the message if invalid or identity
+                        * not confirmed or signature not verified with
+                        * respect to the cookie values.
+                        */
+                       if (!(peer->crypto & CRYPTO_FLAG_VRFY)) {
+                               rval = XEVNT_ERR;
+                               break;
+                       }
+                       if ((rval = crypto_verify(ep, &peer->cookval,
+                           peer)) != XEVNT_OK)
+                               break;
+
+                       /*
+                        * Decrypt the cookie, hunting all the time for
+                        * errors.
+                        */
+                       if (vallen == (u_int) EVP_PKEY_size(host_pkey)) {
+                               RSA_private_decrypt(vallen,
+                                   (u_char *)ep->pkt,
+                                   (u_char *)&temp32,
+                                   host_pkey->pkey.rsa,
+                                   RSA_PKCS1_OAEP_PADDING);
+                               cookie = ntohl(temp32);
+                       } else {
+                               rval = XEVNT_CKY;
+                               break;
+                       }
+
+                       /*
+                        * Install cookie values and light the cookie
+                        * bit. If this is not broadcast client mode, we
+                        * are done here.
+                        */
+                       key_expire(peer);
+                       peer->cookval.tstamp = ep->tstamp;
+                       peer->cookval.fstamp = ep->fstamp;
+                       if (peer->crypto & CRYPTO_FLAG_AGREE)
+                               peer->pcookie ^= cookie;
+                       else
+                               peer->pcookie = cookie;
+                       if (peer->hmode == MODE_CLIENT &&
+                           !(peer->cast_flags & MDF_BCLNT))
+                               peer->crypto |= CRYPTO_FLAG_AUTO;
+                       else
+                               peer->crypto &= ~CRYPTO_FLAG_AUTO;
+                       peer->crypto |= CRYPTO_FLAG_AGREE;
+                       peer->flash &= ~TEST8;
+                       snprintf(statstr, NTP_MAXSTRLEN, "cook %x ts %u fs %u",
+                           peer->pcookie, ntohl(ep->tstamp),
+                           ntohl(ep->fstamp));
+                       record_crypto_stats(&peer->srcadr, statstr);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+
+               /*
+                * Install autokey values in broadcast client and
+                * symmetric modes. We have to do this every time the
+                * sever/peer cookie changes or a new keylist is
+                * rolled. Ordinarily, this is automatic as this message
+                * is piggybacked on the first NTP packet sent upon
+                * either of these events. Note that a broadcast client
+                * or symmetric peer can receive this response without a
+                * matching request.
+                */
+               case CRYPTO_AUTO | CRYPTO_RESP:
+
+                       /*
+                        * Discard the message if invalid or identity
+                        * not confirmed or signature not verified with
+                        * respect to the receive autokey values.
+                        */
+                       if (!(peer->crypto & CRYPTO_FLAG_VRFY)) {
+                               rval = XEVNT_ERR;
+                               break;
+                       }
+                       if ((rval = crypto_verify(ep, &peer->recval,
+                           peer)) != XEVNT_OK)
+                               break;
+
+                       /*
+                        * Install autokey values and light the
+                        * autokey bit. This is not hard.
+                        */
+                       if (peer->recval.ptr == NULL)
+                               peer->recval.ptr =
+                                   emalloc(sizeof(struct autokey));
+                       bp = (struct autokey *)peer->recval.ptr;
+                       peer->recval.tstamp = ep->tstamp;
+                       peer->recval.fstamp = ep->fstamp;
+                       ap = (struct autokey *)ep->pkt;
+                       bp->seq = ntohl(ap->seq);
+                       bp->key = ntohl(ap->key);
+                       peer->pkeyid = bp->key;
+                       peer->crypto |= CRYPTO_FLAG_AUTO;
+                       peer->flash &= ~TEST8;
+                       snprintf(statstr, NTP_MAXSTRLEN,
+                           "auto seq %d key %x ts %u fs %u", bp->seq,
+                           bp->key, ntohl(ep->tstamp),
+                           ntohl(ep->fstamp));
+                       record_crypto_stats(&peer->srcadr, statstr);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+       
+               /*
+                * X509 certificate sign response. Validate the
+                * certificate signed by the server and install. Later
+                * this can be provided to clients of this server in
+                * lieu of the self signed certificate in order to
+                * validate the public key.
+                */
+               case CRYPTO_SIGN | CRYPTO_RESP:
+
+                       /*
+                        * Discard the message if invalid or not
+                        * proventic.
+                        */
+                       if (!(peer->crypto & CRYPTO_FLAG_PROV)) {
+                               rval = XEVNT_ERR;
+                               break;
+                       }
+                       if ((rval = crypto_verify(ep, NULL, peer)) !=
+                           XEVNT_OK)
+                               break;
+
+                       /*
+                        * Scan the certificate list to delete old
+                        * versions and link the newest version first on
+                        * the list.
+                        */
+                       if ((rval = cert_install(ep, peer)) != XEVNT_OK)
+                               break;
+
+                       peer->crypto |= CRYPTO_FLAG_SIGN;
+                       peer->flash &= ~TEST8;
+                       temp32 = cinfo->nid;
+                       snprintf(statstr, NTP_MAXSTRLEN,
+                           "sign %s 0x%x %s (%u) fs %u",
+                           cinfo->issuer, cinfo->flags,
+                           OBJ_nid2ln(temp32), temp32,
+                           ntohl(ep->fstamp));
+                       record_crypto_stats(&peer->srcadr, statstr);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+
+               /*
+                * Install leapseconds table in symmetric modes. This
+                * table is proventicated to the NIST primary servers,
+                * either by copying the file containing the table from
+                * a NIST server to a trusted server or directly using
+                * this protocol. While the entire table is installed at
+                * the server, presently only the current TAI offset is
+                * provided via the kernel to other applications.
+                */
+               case CRYPTO_TAI:
+
+                       /*
+                        * Discard the message if invalid.
+                        */
+                       if ((rval = crypto_verify(ep, NULL, peer)) !=
+                           XEVNT_OK)
+                               break;
+
+                       /*
+                        * Pass the extension field to the transmit
+                        * side. Continue below if a leapseconds table
+                        * accompanies the message.
+                        */
+                       fp = emalloc(len);
+                       memcpy(fp, ep, len);
+                       temp32 = CRYPTO_RESP;
+                       fp->opcode |= htonl(temp32);
+                       peer->cmmd = fp;
+                       if (len <= VALUE_LEN) {
+                               peer->flash &= ~TEST8;
+                               break;
+                       }
+                       /* fall through */
+
+               case CRYPTO_TAI | CRYPTO_RESP:
+
+                       /*
+                        * If this is a response, discard the message if
+                        * signature not verified with respect to the
+                        * leapsecond table values.
+                        */
+                       if (peer->cmmd == NULL) {
+                               if ((rval = crypto_verify(ep,
+                                   &peer->tai_leap, peer)) != XEVNT_OK)
+                                       break;
+                       }
+
+                       /*
+                        * Initialize peer variables with latest update.
+                        */
+                       peer->tai_leap.tstamp = ep->tstamp;
+                       peer->tai_leap.fstamp = ep->fstamp;
+                       peer->tai_leap.vallen = ep->vallen;
+
+                       /*
+                        * Install the new table if there is no stored
+                        * table or the new table is more recent than
+                        * the stored table. Since a filestamp may have
+                        * changed, recompute the signatures.
+                        */
+                       if (ntohl(peer->tai_leap.fstamp) >
+                           ntohl(tai_leap.fstamp)) {
+                               tai_leap.fstamp = ep->fstamp;
+                               tai_leap.vallen = ep->vallen;
+                               if (tai_leap.ptr != NULL)
+                                       free(tai_leap.ptr);
+                               tai_leap.ptr = emalloc(vallen);
+                               memcpy(tai_leap.ptr, ep->pkt, vallen);
+                               crypto_update();
+                       }
+                       crypto_flags |= CRYPTO_FLAG_TAI;
+                       peer->crypto |= CRYPTO_FLAG_LEAP;
+                       peer->flash &= ~TEST8;
+                       snprintf(statstr, NTP_MAXSTRLEN,
+                           "leap %u ts %u fs %u", vallen,
+                           ntohl(ep->tstamp), ntohl(ep->fstamp));
+                       record_crypto_stats(&peer->srcadr, statstr);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+
+               /*
+                * We come here in symmetric modes for miscellaneous
+                * commands that have value fields but are processed on
+                * the transmit side. All we need do here is check for
+                * valid field length. Remaining checks are below and on
+                * the transmit side.
+                */
+               case CRYPTO_CERT:
+               case CRYPTO_IFF:
+               case CRYPTO_GQ:
+               case CRYPTO_MV:
+               case CRYPTO_SIGN:
+                       if (len < VALUE_LEN) {
+                               rval = XEVNT_LEN;
+                               break;
+                       }
+                       /* fall through */
+
+               /*
+                * We come here for miscellaneous requests and unknown
+                * requests and responses. If an unknown response or
+                * error, forget it. If a request, save the extension
+                * field for later. Unknown requests will be caught on
+                * the transmit side.
+                */
+               default:
+                       if (code & (CRYPTO_RESP | CRYPTO_ERROR)) {
+                               rval = XEVNT_ERR;
+                       } else if ((rval = crypto_verify(ep, NULL,
+                           peer)) == XEVNT_OK) {
+                               fp = emalloc(len);
+                               memcpy(fp, ep, len);
+                               temp32 = CRYPTO_RESP;
+                               fp->opcode |= htonl(temp32);
+                               peer->cmmd = fp;
+                       }
+               }
+
+               /*
+                * We don't log length/format/timestamp errors and
+                * duplicates, which are log clogging vulnerabilities.
+                * The first error found terminates the extension field
+                * scan and we return the laundry to the caller. A
+                * length/format/timestamp error on transmit is
+                * cheerfully ignored, as the message is not sent.
+                */
+               if (rval > XEVNT_TSP) {
+                       snprintf(statstr, NTP_MAXSTRLEN,
+                           "error %x opcode %x ts %u fs %u", rval,
+                           code, tstamp, fstamp);
+                       record_crypto_stats(&peer->srcadr, statstr);
+                       report_event(rval, peer);
+#ifdef DEBUG
+                       if (debug)
+                               printf("crypto_recv: %s\n", statstr);
+#endif
+                       break;
+
+               } else if (rval > XEVNT_OK && (code & CRYPTO_RESP)) {
+                       rval = XEVNT_OK;
+               }
+               authlen += len;
+       }
+       return (rval);
+}
+
+
+/*
+ * crypto_xmit - construct extension fields
+ *
+ * This routine is called both when an association is configured and
+ * when one is not. The only case where this matters is to retrieve the
+ * autokey information, in which case the caller has to provide the
+ * association ID to match the association.
+ *
+ * Returns length of extension field.
+ */
+int
+crypto_xmit(
+       struct pkt *xpkt,       /* transmit packet pointer */
+       struct sockaddr_storage *srcadr_sin,    /* active runway */
+       int     start,          /* offset to extension field */
+       struct exten *ep,       /* extension pointer */
+       keyid_t cookie          /* session cookie */
+       )
+{
+       u_int32 *pkt;           /* packet pointer */
+       struct peer *peer;      /* peer structure pointer */
+       u_int   opcode;         /* extension field opcode */
+       struct exten *fp;       /* extension pointers */
+       struct cert_info *cp, *xp; /* certificate info/value pointer */
+       char    certname[MAXHOSTNAME + 1]; /* subject name buffer */
+       char    statstr[NTP_MAXSTRLEN]; /* statistics for filegen */
+       tstamp_t tstamp;
+       u_int   vallen;
+       u_int   len;
+       struct value vtemp;
+       associd_t associd;
+       int     rval;
+       keyid_t tcookie;
+
+       /*
+        * Generate the requested extension field request code, length
+        * and association ID. If this is a response and the host is not
+        * synchronized, light the error bit and go home.
+        */
+       pkt = (u_int32 *)xpkt + start / 4;
+       fp = (struct exten *)pkt;
+       opcode = ntohl(ep->opcode);
+       associd = (associd_t) ntohl(ep->associd);
+       fp->associd = htonl(associd);
+       len = 8;
+       rval = XEVNT_OK;
+       tstamp = crypto_time();
+       switch (opcode & 0xffff0000) {
+
+       /*
+        * Send association request and response with status word and
+        * host name. Note, this message is not signed and the filestamp
+        * contains only the status word.
+        */
+       case CRYPTO_ASSOC | CRYPTO_RESP:
+               len += crypto_send(fp, &hostval);
+               fp->fstamp = htonl(crypto_flags);
+               break;
+
+       case CRYPTO_ASSOC:
+               len += crypto_send(fp, &hostval);
+               fp->fstamp = htonl(crypto_flags | ident_scheme);
+               break;
+
+       /*
+        * Send certificate request. Use the values from the extension
+        * field.
+        */
+       case CRYPTO_CERT:
+               memset(&vtemp, 0, sizeof(vtemp));
+               vtemp.tstamp = ep->tstamp;
+               vtemp.fstamp = ep->fstamp;
+               vtemp.vallen = ep->vallen;
+               vtemp.ptr = (u_char *)ep->pkt;
+               len += crypto_send(fp, &vtemp);
+               break;
+
+       /*
+        * Send certificate response or sign request. Use the values
+        * from the certificate cache. If the request contains no
+        * subject name, assume the name of this host. This is for
+        * backwards compatibility. Private certificates are never sent.
+        */
+       case CRYPTO_SIGN:
+       case CRYPTO_CERT | CRYPTO_RESP:
+               vallen = ntohl(ep->vallen);
+               if (vallen == 8) {
+                       strcpy(certname, sys_hostname);
+               } else if (vallen == 0 || vallen > MAXHOSTNAME) {
+                       rval = XEVNT_LEN;
+                       break;
+
+               } else {
+                       memcpy(certname, ep->pkt, vallen);
+                       certname[vallen] = '\0';
+               }
+
+               /*
+                * Find all certificates with matching subject. If a
+                * self-signed, trusted certificate is found, use that.
+                * If not, use the first one with matching subject. A
+                * private certificate is never divulged or signed.
+                */
+               xp = NULL;
+               for (cp = cinfo; cp != NULL; cp = cp->link) {
+                       if (cp->flags & CERT_PRIV)
+                               continue;
+
+                       if (strcmp(certname, cp->subject) == 0) {
+                               if (xp == NULL)
+                                       xp = cp;
+                               if (strcmp(certname, cp->issuer) ==
+                                   0 && cp->flags & CERT_TRUST) {
+                                       xp = cp;
+                                       break;
+                               }
+                       }
+               }
+
+               /*
+                * Be careful who you trust. If not yet synchronized,
+                * give back an empty response. If certificate not found
+                * or beyond the lifetime, return an error. This is to
+                * avoid a bad dude trying to get an expired certificate
+                * re-signed. Otherwise, send it.
+                *
+                * Note the timestamp and filestamp are taken from the
+                * certificate value structure. For all certificates the
+                * timestamp is the latest signature update time. For
+                * host and imported certificates the filestamp is the
+                * creation epoch. For signed certificates the filestamp
+                * is the creation epoch of the trusted certificate at
+                * the base of the certificate trail. In principle, this
+                * allows strong checking for signature masquerade.
+                */
+               if (tstamp == 0)
+                       break;
+
+               if (xp == NULL)
+                       rval = XEVNT_CRT;
+               else if (tstamp < xp->first || tstamp > xp->last)
+                       rval = XEVNT_SRV;
+               else
+                       len += crypto_send(fp, &xp->cert);
+               break;
+
+       /*
+        * Send challenge in Schnorr (IFF) identity scheme.
+        */
+       case CRYPTO_IFF:
+               if ((peer = findpeerbyassoc(ep->pkt[0])) == NULL) {
+                       rval = XEVNT_ERR;
+                       break;
+               }
+               if ((rval = crypto_alice(peer, &vtemp)) == XEVNT_OK) {
+                       len += crypto_send(fp, &vtemp);
+                       value_free(&vtemp);
+               }
+               break;
+
+       /*
+        * Send response in Schnorr (IFF) identity scheme.
+        */
+       case CRYPTO_IFF | CRYPTO_RESP:
+               if ((rval = crypto_bob(ep, &vtemp)) == XEVNT_OK) {
+                       len += crypto_send(fp, &vtemp);
+                       value_free(&vtemp);
+               }
+               break;
+
+       /*
+        * Send challenge in Guillou-Quisquater (GQ) identity scheme.
+        */
+       case CRYPTO_GQ:
+               if ((peer = findpeerbyassoc(ep->pkt[0])) == NULL) {
+                       rval = XEVNT_ERR;
+                       break;
+               }
+               if ((rval = crypto_alice2(peer, &vtemp)) == XEVNT_OK) {
+                       len += crypto_send(fp, &vtemp);
+                       value_free(&vtemp);
+               }
+               break;
+
+       /*
+        * Send response in Guillou-Quisquater (GQ) identity scheme.
+        */
+       case CRYPTO_GQ | CRYPTO_RESP:
+               if ((rval = crypto_bob2(ep, &vtemp)) == XEVNT_OK) {
+                       len += crypto_send(fp, &vtemp);
+                       value_free(&vtemp);
+               }
+               break;
+
+       /*
+        * Send challenge in MV identity scheme.
+        */
+       case CRYPTO_MV:
+               if ((peer = findpeerbyassoc(ep->pkt[0])) == NULL) {
+                       rval = XEVNT_ERR;
+                       break;
+               }
+               if ((rval = crypto_alice3(peer, &vtemp)) == XEVNT_OK) {
+                       len += crypto_send(fp, &vtemp);
+                       value_free(&vtemp);
+               }
+               break;
+
+       /*
+        * Send response in MV identity scheme.
+        */
+       case CRYPTO_MV | CRYPTO_RESP:
+               if ((rval = crypto_bob3(ep, &vtemp)) == XEVNT_OK) {
+                       len += crypto_send(fp, &vtemp);
+                       value_free(&vtemp);
+               }
+               break;
+
+       /*
+        * Send certificate sign response. The integrity of the request
+        * certificate has already been verified on the receive side.
+        * Sign the response using the local server key. Use the
+        * filestamp from the request and use the timestamp as the
+        * current time. Light the error bit if the certificate is
+        * invalid or contains an unverified signature.
+        */
+       case CRYPTO_SIGN | CRYPTO_RESP:
+               if ((rval = cert_sign(ep, &vtemp)) == XEVNT_OK)
+                       len += crypto_send(fp, &vtemp);
+               value_free(&vtemp);
+               break;
+
+       /*
+        * Send public key and signature. Use the values from the public
+        * key.
+        */
+       case CRYPTO_COOK:
+               len += crypto_send(fp, &pubkey);
+               break;
+
+       /*
+        * Encrypt and send cookie and signature. Light the error bit if
+        * anything goes wrong.
+        */
+       case CRYPTO_COOK | CRYPTO_RESP:
+               if ((opcode & 0xffff) < VALUE_LEN) {
+                       rval = XEVNT_LEN;
+                       break;
+               }
+               if (PKT_MODE(xpkt->li_vn_mode) == MODE_SERVER) {
+                       tcookie = cookie;
+               } else {
+                       if ((peer = findpeerbyassoc(associd)) == NULL) {
+                               rval = XEVNT_ERR;
+                               break;
+                       }
+                       tcookie = peer->pcookie;
+               }
+               if ((rval = crypto_encrypt(ep, &vtemp, &tcookie)) ==
+                   XEVNT_OK)
+                       len += crypto_send(fp, &vtemp);
+               value_free(&vtemp);
+               break;
+
+       /*
+        * Find peer and send autokey data and signature in broadcast
+        * server and symmetric modes. Use the values in the autokey
+        * structure. If no association is found, either the server has
+        * restarted with new associations or some perp has replayed an
+        * old message, in which case light the error bit.
+        */
+       case CRYPTO_AUTO | CRYPTO_RESP:
+               if ((peer = findpeerbyassoc(associd)) == NULL) {
+                       rval = XEVNT_ERR;
+                       break;
+               }
+               peer->flags &= ~FLAG_ASSOC;
+               len += crypto_send(fp, &peer->sndval);
+               break;
+
+       /*
+        * Send leapseconds table and signature. Use the values from the
+        * tai structure. If no table has been loaded, just send an
+        * empty request.
+        */
+       case CRYPTO_TAI:
+       case CRYPTO_TAI | CRYPTO_RESP:
+               if (crypto_flags & CRYPTO_FLAG_TAI)
+                       len += crypto_send(fp, &tai_leap);
+               break;
+
+       /*
+        * Default - Fall through for requests; for unknown responses,
+        * flag as error.
+        */
+       default:
+               if (opcode & CRYPTO_RESP)
+                       rval = XEVNT_ERR;
+       }
+
+       /*
+        * In case of error, flame the log. If a request, toss the
+        * puppy; if a response, return so the sender can flame, too.
+        */
+       if (rval != XEVNT_OK) {
+               opcode |= CRYPTO_ERROR;
+               snprintf(statstr, NTP_MAXSTRLEN,
+                   "error %x opcode %x", rval, opcode);
+               record_crypto_stats(srcadr_sin, statstr);
+               report_event(rval, NULL);
+#ifdef DEBUG
+               if (debug)
+                       printf("crypto_xmit: %s\n", statstr);
+#endif
+               if (!(opcode & CRYPTO_RESP))
+                       return (0);
+       }
+
+       /*
+        * Round up the field length to a multiple of 8 bytes and save
+        * the request code and length.
+        */
+       len = ((len + 7) / 8) * 8;
+       fp->opcode = htonl((opcode & 0xffff0000) | len);
+#ifdef DEBUG
+       if (debug)
+               printf(
+                   "crypto_xmit: flags 0x%x ext offset %d len %u code 0x%x assocID %d\n",
+                   crypto_flags, start, len, opcode >> 16, associd);
+#endif
+       return (len);
+}
+
+
+/*
+ * crypto_verify - parse and verify the extension field and value
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_LEN   bad field format or length
+ * XEVNT_TSP   bad timestamp
+ * XEVNT_FSP   bad filestamp
+ * XEVNT_PUB   bad or missing public key
+ * XEVNT_SGL   bad signature length
+ * XEVNT_SIG   signature not verified
+ * XEVNT_ERR   protocol error
+ */
+static int
+crypto_verify(
+       struct exten *ep,       /* extension pointer */
+       struct value *vp,       /* value pointer */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       EVP_PKEY *pkey;         /* server public key */
+       EVP_MD_CTX ctx;         /* signature context */
+       tstamp_t tstamp, tstamp1 = 0; /* timestamp */
+       tstamp_t fstamp, fstamp1 = 0; /* filestamp */
+       u_int   vallen;         /* value length */
+       u_int   siglen;         /* signature length */
+       u_int   opcode, len;
+       int     i;
+
+       /*
+        * We require valid opcode and field lengths, timestamp,
+        * filestamp, public key, digest, signature length and
+        * signature, where relevant. Note that preliminary length
+        * checks are done in the main loop.
+        */
+       len = ntohl(ep->opcode) & 0x0000ffff;
+       opcode = ntohl(ep->opcode) & 0xffff0000;
+
+       /*
+        * Check for valid operation code and protocol. The opcode must
+        * not have the error bit set. If a response, it must have a
+        * value header. If a request and does not contain a value
+        * header, no need for further checking.
+        */
+       if (opcode & CRYPTO_ERROR)
+               return (XEVNT_ERR);
+
+       if (opcode & CRYPTO_RESP) {
+               if (len < VALUE_LEN)
+                       return (XEVNT_LEN);
+       } else {
+               if (len < VALUE_LEN)
+                       return (XEVNT_OK);
+       }
+
+       /*
+        * We have a value header. Check for valid field lengths. The
+        * field length must be long enough to contain the value header,
+        * value and signature. Note both the value and signature fields
+        * are rounded up to the next word.
+        */
+       vallen = ntohl(ep->vallen);
+       i = (vallen + 3) / 4;
+       siglen = ntohl(ep->pkt[i++]);
+       if (len < VALUE_LEN + ((vallen + 3) / 4) * 4 + ((siglen + 3) /
+           4) * 4)
+               return (XEVNT_LEN);
+
+       /*
+        * Punt if this is a response with no data. Punt if this is a
+        * request and a previous response is pending. 
+        */
+       if (opcode & CRYPTO_RESP) {
+               if (vallen == 0)
+                       return (XEVNT_LEN);
+       } else {
+               if (peer->cmmd != NULL)
+                       return (XEVNT_LEN);
+       }
+
+       /*
+        * Check for valid timestamp and filestamp. If the timestamp is
+        * zero, the sender is not synchronized and signatures are
+        * disregarded. If not, the timestamp must not precede the
+        * filestamp. The timestamp and filestamp must not precede the
+        * corresponding values in the value structure, if present. Once
+        * the autokey values have been installed, the timestamp must
+        * always be later than the corresponding value in the value
+        * structure. Duplicate timestamps are illegal once the cookie
+        * has been validated.
+        */
+       tstamp = ntohl(ep->tstamp);
+       fstamp = ntohl(ep->fstamp);
+       if (tstamp == 0)
+               return (XEVNT_OK);
+
+       if (tstamp < fstamp)
+               return (XEVNT_TSP);
+
+       if (vp != NULL) {
+               tstamp1 = ntohl(vp->tstamp);
+               fstamp1 = ntohl(vp->fstamp);
+               if ((tstamp < tstamp1 || (tstamp == tstamp1 &&
+                   (peer->crypto & CRYPTO_FLAG_AUTO))))
+                       return (XEVNT_TSP);
+
+               if ((tstamp < fstamp1 || fstamp < fstamp1))
+                       return (XEVNT_FSP);
+       }
+
+       /*
+        * Check for valid signature length, public key and digest
+        * algorithm.
+        */
+       if (crypto_flags & peer->crypto & CRYPTO_FLAG_PRIV)
+               pkey = sign_pkey;
+       else
+               pkey = peer->pkey;
+       if (siglen == 0 || pkey == NULL || peer->digest == NULL)
+               return (XEVNT_OK);
+
+       if (siglen != (u_int)EVP_PKEY_size(pkey))
+               return (XEVNT_SGL);
+
+       /*
+        * Darn, I thought we would never get here. Verify the
+        * signature. If the identity exchange is verified, light the
+        * proventic bit. If no client identity scheme is specified,
+        * avoid doing the sign exchange.
+        */
+       EVP_VerifyInit(&ctx, peer->digest);
+       EVP_VerifyUpdate(&ctx, (u_char *)&ep->tstamp, vallen + 12);
+       if (EVP_VerifyFinal(&ctx, (u_char *)&ep->pkt[i], siglen, pkey) <= 0)
+               return (XEVNT_SIG);
+
+       if (peer->crypto & CRYPTO_FLAG_VRFY) {
+               peer->crypto |= CRYPTO_FLAG_PROV;
+               if (!(crypto_flags & CRYPTO_FLAG_MASK))
+                       peer->crypto |= CRYPTO_FLAG_SIGN;
+       }
+       return (XEVNT_OK);
+}
+
+
+/*
+ * crypto_encrypt - construct encrypted cookie and signature from
+ * extension field and cookie
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_PUB   bad or missing public key
+ * XEVNT_CKY   bad or missing cookie
+ * XEVNT_PER   host certificate expired
+ */
+static int
+crypto_encrypt(
+       struct exten *ep,       /* extension pointer */
+       struct value *vp,       /* value pointer */
+       keyid_t *cookie         /* server cookie */
+       )
+{
+       EVP_PKEY *pkey;         /* public key */
+       EVP_MD_CTX ctx;         /* signature context */
+       tstamp_t tstamp;        /* NTP timestamp */
+       u_int32 temp32;
+       u_int   len;
+       u_char  *ptr;
+
+       /*
+        * Extract the public key from the request.
+        */
+       len = ntohl(ep->vallen);
+       ptr = (u_char *)ep->pkt;
+       pkey = d2i_PublicKey(EVP_PKEY_RSA, NULL, &ptr, len);
+       if (pkey == NULL) {
+               msyslog(LOG_ERR, "crypto_encrypt %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (XEVNT_PUB);
+       }
+
+       /*
+        * Encrypt the cookie, encode in ASN.1 and sign.
+        */
+       tstamp = crypto_time();
+       memset(vp, 0, sizeof(struct value));
+       vp->tstamp = htonl(tstamp);
+       vp->fstamp = hostval.tstamp;
+       len = EVP_PKEY_size(pkey);
+       vp->vallen = htonl(len);
+       vp->ptr = emalloc(len);
+       temp32 = htonl(*cookie);
+       if (!RSA_public_encrypt(4, (u_char *)&temp32, vp->ptr,
+           pkey->pkey.rsa, RSA_PKCS1_OAEP_PADDING)) {
+               msyslog(LOG_ERR, "crypto_encrypt %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               EVP_PKEY_free(pkey);
+               return (XEVNT_CKY);
+       }
+       EVP_PKEY_free(pkey);
+       vp->siglen = 0;
+       if (tstamp == 0)
+               return (XEVNT_OK);
+
+       if (tstamp < cinfo->first || tstamp > cinfo->last)
+               return (XEVNT_PER);
+
+       vp->sig = emalloc(sign_siglen);
+       EVP_SignInit(&ctx, sign_digest);
+       EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
+       EVP_SignUpdate(&ctx, vp->ptr, len);
+       if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
+               vp->siglen = htonl(len);
+       return (XEVNT_OK);
+}
+
+
+/*
+ * crypto_ident - construct extension field for identity scheme
+ *
+ * This routine determines which identity scheme is in use and
+ * constructs an extension field for that scheme.
+ */
+u_int
+crypto_ident(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       char    filename[MAXFILENAME + 1];
+
+       /*
+        * If the server identity has already been verified, no further
+        * action is necessary. Otherwise, try to load the identity file
+        * of the certificate issuer. If the issuer file is not found,
+        * try the host file. If nothing found, declare a cryptobust.
+        * Note we can't get here unless the trusted certificate has
+        * been found and the CRYPTO_FLAG_VALID bit is set, so the
+        * certificate issuer is valid.
+        */
+       if (peer->ident_pkey != NULL)
+               EVP_PKEY_free(peer->ident_pkey);
+       if (peer->crypto & CRYPTO_FLAG_GQ) {
+               snprintf(filename, MAXFILENAME, "ntpkey_gq_%s",
+                   peer->issuer);
+               peer->ident_pkey = crypto_key(filename, &peer->fstamp);
+               if (peer->ident_pkey != NULL)
+                       return (CRYPTO_GQ);
+
+               snprintf(filename, MAXFILENAME, "ntpkey_gq_%s",
+                   sys_hostname);
+               peer->ident_pkey = crypto_key(filename, &peer->fstamp);
+               if (peer->ident_pkey != NULL)
+                       return (CRYPTO_GQ);
+       }
+       if (peer->crypto & CRYPTO_FLAG_IFF) {
+               snprintf(filename, MAXFILENAME, "ntpkey_iff_%s",
+                   peer->issuer);
+               peer->ident_pkey = crypto_key(filename, &peer->fstamp);
+               if (peer->ident_pkey != NULL)
+                       return (CRYPTO_IFF);
+
+               snprintf(filename, MAXFILENAME, "ntpkey_iff_%s",
+                   sys_hostname);
+               peer->ident_pkey = crypto_key(filename, &peer->fstamp);
+               if (peer->ident_pkey != NULL)
+                       return (CRYPTO_IFF);
+       }
+       if (peer->crypto & CRYPTO_FLAG_MV) {
+               snprintf(filename, MAXFILENAME, "ntpkey_mv_%s",
+                   peer->issuer);
+               peer->ident_pkey = crypto_key(filename, &peer->fstamp);
+               if (peer->ident_pkey != NULL)
+                       return (CRYPTO_MV);
+
+               snprintf(filename, MAXFILENAME, "ntpkey_mv_%s",
+                   sys_hostname);
+               peer->ident_pkey = crypto_key(filename, &peer->fstamp);
+               if (peer->ident_pkey != NULL)
+                       return (CRYPTO_MV);
+       }
+
+       /*
+        * No compatible identity scheme is available. Life is hard.
+        */
+       msyslog(LOG_INFO,
+           "crypto_ident: no compatible identity scheme found");
+       return (0);
+}
+
+
+/*
+ * crypto_args - construct extension field from arguments
+ *
+ * This routine creates an extension field with current timestamps and
+ * specified opcode, association ID and optional string. Note that the
+ * extension field is created here, but freed after the crypto_xmit()
+ * call in the protocol module.
+ *
+ * Returns extension field pointer (no errors).
+ */
+struct exten *
+crypto_args(
+       struct peer *peer,      /* peer structure pointer */
+       u_int   opcode,         /* operation code */
+       char    *str            /* argument string */
+       )
+{
+       tstamp_t tstamp;        /* NTP timestamp */
+       struct exten *ep;       /* extension field pointer */
+       u_int   len;            /* extension field length */
+
+       tstamp = crypto_time();
+       len = sizeof(struct exten);
+       if (str != NULL)
+               len += strlen(str);
+       ep = emalloc(len);
+       memset(ep, 0, len);
+       if (opcode == 0)
+               return (ep);
+
+       ep->opcode = htonl(opcode + len);
+
+       /*
+        * If a response, send our ID; if a request, send the
+        * responder's ID.
+        */
+       if (opcode & CRYPTO_RESP)
+               ep->associd = htonl(peer->associd);
+       else
+               ep->associd = htonl(peer->assoc);
+       ep->tstamp = htonl(tstamp);
+       ep->fstamp = hostval.tstamp;
+       ep->vallen = 0;
+       if (str != NULL) {
+               ep->vallen = htonl(strlen(str));
+               memcpy((char *)ep->pkt, str, strlen(str));
+       } else {
+               ep->pkt[0] = peer->associd;
+       }
+       return (ep);
+}
+
+
+/*
+ * crypto_send - construct extension field from value components
+ *
+ * Returns extension field length. Note: it is not polite to send a
+ * nonempty signature with zero timestamp or a nonzero timestamp with
+ * empty signature, but these rules are not enforced here.
+ */
+u_int
+crypto_send(
+       struct exten *ep,       /* extension field pointer */
+       struct value *vp        /* value pointer */
+       )
+{
+       u_int   len, temp32;
+       int     i;
+
+       /*
+        * Copy data. If the data field is empty or zero length, encode
+        * an empty value with length zero.
+        */
+       ep->tstamp = vp->tstamp;
+       ep->fstamp = vp->fstamp;
+       ep->vallen = vp->vallen;
+       len = 12;
+       temp32 = ntohl(vp->vallen);
+       if (temp32 > 0 && vp->ptr != NULL)
+               memcpy(ep->pkt, vp->ptr, temp32);
+
+       /*
+        * Copy signature. If the signature field is empty or zero
+        * length, encode an empty signature with length zero.
+        */
+       i = (temp32 + 3) / 4;
+       len += i * 4 + 4;
+       ep->pkt[i++] = vp->siglen;
+       temp32 = ntohl(vp->siglen);
+       if (temp32 > 0 && vp->sig != NULL)
+               memcpy(&ep->pkt[i], vp->sig, temp32);
+       len += temp32;
+       return (len);
+}
+
+
+/*
+ * crypto_update - compute new public value and sign extension fields
+ *
+ * This routine runs periodically, like once a day, and when something
+ * changes. It updates the timestamps on three value structures and one
+ * value structure list, then signs all the structures:
+ *
+ * hostval     host name (not signed)
+ * pubkey      public key
+ * cinfo       certificate info/value list
+ * tai_leap    leapseconds file
+ *
+ * Filestamps are proventicated data, so this routine is run only when
+ * the host has been synchronized to a proventicated source. Thus, the
+ * timestamp is proventicated, too, and can be used to deflect
+ * clogging attacks and even cook breakfast.
+ *
+ * Returns void (no errors)
+ */
+void
+crypto_update(void)
+{
+       EVP_MD_CTX ctx;         /* message digest context */
+       struct cert_info *cp, *cpn; /* certificate info/value */
+       char    statstr[NTP_MAXSTRLEN]; /* statistics for filegen */
+       tstamp_t tstamp;        /* NTP timestamp */
+       u_int   len;
+
+       if ((tstamp = crypto_time()) == 0)
+               return;
+
+       hostval.tstamp = htonl(tstamp);
+
+       /*
+        * Sign public key and timestamps. The filestamp is derived from
+        * the host key file extension from wherever the file was
+        * generated. 
+        */
+       if (pubkey.vallen != 0) {
+               pubkey.tstamp = hostval.tstamp;
+               pubkey.siglen = 0;
+               if (pubkey.sig == NULL)
+                       pubkey.sig = emalloc(sign_siglen);
+               EVP_SignInit(&ctx, sign_digest);
+               EVP_SignUpdate(&ctx, (u_char *)&pubkey, 12);
+               EVP_SignUpdate(&ctx, pubkey.ptr, ntohl(pubkey.vallen));
+               if (EVP_SignFinal(&ctx, pubkey.sig, &len, sign_pkey))
+                       pubkey.siglen = htonl(len);
+       }
+
+       /*
+        * Sign certificates and timestamps. The filestamp is derived
+        * from the certificate file extension from wherever the file
+        * was generated. Note we do not throw expired certificates
+        * away; they may have signed younger ones.
+        */
+       for (cp = cinfo; cp != NULL; cp = cpn) {
+               cpn = cp->link;
+               cp->cert.tstamp = hostval.tstamp;
+               cp->cert.siglen = 0;
+               if (cp->cert.sig == NULL)
+                       cp->cert.sig = emalloc(sign_siglen);
+               EVP_SignInit(&ctx, sign_digest);
+               EVP_SignUpdate(&ctx, (u_char *)&cp->cert, 12);
+               EVP_SignUpdate(&ctx, cp->cert.ptr,
+                   ntohl(cp->cert.vallen));
+               if (EVP_SignFinal(&ctx, cp->cert.sig, &len, sign_pkey))
+                       cp->cert.siglen = htonl(len);
+       }
+
+       /*
+        * Sign leapseconds table and timestamps. The filestamp is
+        * derived from the leapsecond file extension from wherever the
+        * file was generated.
+        */
+       if (tai_leap.vallen != 0) {
+               tai_leap.tstamp = hostval.tstamp;
+               tai_leap.siglen = 0;
+               if (tai_leap.sig == NULL)
+                       tai_leap.sig = emalloc(sign_siglen);
+               EVP_SignInit(&ctx, sign_digest);
+               EVP_SignUpdate(&ctx, (u_char *)&tai_leap, 12);
+               EVP_SignUpdate(&ctx, tai_leap.ptr,
+                   ntohl(tai_leap.vallen));
+               if (EVP_SignFinal(&ctx, tai_leap.sig, &len, sign_pkey))
+                       tai_leap.siglen = htonl(len);
+       }
+       snprintf(statstr, NTP_MAXSTRLEN,
+           "update ts %u", ntohl(hostval.tstamp)); 
+       record_crypto_stats(NULL, statstr);
+#ifdef DEBUG
+       if (debug)
+               printf("crypto_update: %s\n", statstr);
+#endif
+}
+
+
+/*
+ * value_free - free value structure components.
+ *
+ * Returns void (no errors)
+ */
+void
+value_free(
+       struct value *vp        /* value structure */
+       )
+{
+       if (vp->ptr != NULL)
+               free(vp->ptr);
+       if (vp->sig != NULL)
+               free(vp->sig);
+       memset(vp, 0, sizeof(struct value));
+}
+
+
+/*
+ * crypto_time - returns current NTP time in seconds.
+ */
+tstamp_t
+crypto_time()
+{
+       l_fp    tstamp;         /* NTP time */  L_CLR(&tstamp);
+
+       L_CLR(&tstamp);
+       if (sys_leap != LEAP_NOTINSYNC)
+               get_systime(&tstamp);
+       return (tstamp.l_ui);
+}
+
+
+/*
+ * asn2ntp - convert ASN1_TIME time structure to NTP time in seconds.
+ */
+u_long
+asn2ntp        (
+       ASN1_TIME *asn1time     /* pointer to ASN1_TIME structure */
+       )
+{
+       char    *v;             /* pointer to ASN1_TIME string */
+       struct  tm tm;          /* used to convert to NTP time */
+
+       /*
+        * Extract time string YYMMDDHHMMSSZ from ASN1 time structure.
+        * Note that the YY, MM, DD fields start with one, the HH, MM,
+        * SS fiels start with zero and the Z character should be 'Z'
+        * for UTC. Also note that years less than 50 map to years
+        * greater than 100. Dontcha love ASN.1? Better than MIL-188.
+        */
+       if (asn1time->length > 13)
+               return ((u_long)(~0));  /* We can't use -1 here. It's invalid */
+
+       v = (char *)asn1time->data;
+       tm.tm_year = (v[0] - '0') * 10 + v[1] - '0';
+       if (tm.tm_year < 50)
+               tm.tm_year += 100;
+       tm.tm_mon = (v[2] - '0') * 10 + v[3] - '0' - 1;
+       tm.tm_mday = (v[4] - '0') * 10 + v[5] - '0';
+       tm.tm_hour = (v[6] - '0') * 10 + v[7] - '0';
+       tm.tm_min = (v[8] - '0') * 10 + v[9] - '0';
+       tm.tm_sec = (v[10] - '0') * 10 + v[11] - '0';
+       tm.tm_wday = 0;
+       tm.tm_yday = 0;
+       tm.tm_isdst = 0;
+       return (timegm(&tm) + JAN_1970);
+}
+
+
+/*
+ * bigdig() - compute a BIGNUM MD5 hash of a BIGNUM number.
+ */
+static int
+bighash(
+       BIGNUM  *bn,            /* BIGNUM * from */
+       BIGNUM  *bk             /* BIGNUM * to */
+       )
+{
+       EVP_MD_CTX ctx;         /* message digest context */
+       u_char dgst[EVP_MAX_MD_SIZE]; /* message digest */
+       u_char  *ptr;           /* a BIGNUM as binary string */
+       u_int   len;
+
+       len = BN_num_bytes(bn);
+       ptr = emalloc(len);
+       BN_bn2bin(bn, ptr);
+       EVP_DigestInit(&ctx, EVP_md5());
+       EVP_DigestUpdate(&ctx, ptr, len);
+       EVP_DigestFinal(&ctx, dgst, &len);
+       BN_bin2bn(dgst, len, bk);
+
+       /* XXX MEMLEAK? free ptr? */
+
+       return (1);
+}
+
+
+/*
+ ***********************************************************************
+ *                                                                    *
+ * The following routines implement the Schnorr (IFF) identity scheme  *
+ *                                                                    *
+ ***********************************************************************
+ *
+ * The Schnorr (IFF) identity scheme is intended for use when
+ * the ntp-genkeys program does not generate the certificates used in
+ * the protocol and the group key cannot be conveyed in the certificate
+ * itself. For this purpose, new generations of IFF values must be
+ * securely transmitted to all members of the group before use. The
+ * scheme is self contained and independent of new generations of host
+ * keys, sign keys and certificates.
+ *
+ * The IFF identity scheme is based on DSA cryptography and algorithms
+ * described in Stinson p. 285. The IFF values hide in a DSA cuckoo
+ * structure, but only the primes and generator are used. The p is a
+ * 512-bit prime, q a 160-bit prime that divides p - 1 and is a qth root
+ * of 1 mod p; that is, g^q = 1 mod p. The TA rolls primvate random
+ * group key b disguised as a DSA structure member, then computes public
+ * key g^(q - b). These values are shared only among group members and
+ * never revealed in messages. Alice challenges Bob to confirm identity
+ * using the protocol described below.
+ *
+ * How it works
+ *
+ * The scheme goes like this. Both Alice and Bob have the public primes
+ * p, q and generator g. The TA gives private key b to Bob and public
+ * key v = g^(q - a) mod p to Alice.
+ *
+ * Alice rolls new random challenge r and sends to Bob in the IFF
+ * request message. Bob rolls new random k, then computes y = k + b r
+ * mod q and x = g^k mod p and sends (y, hash(x)) to Alice in the
+ * response message. Besides making the response shorter, the hash makes
+ * it effectivey impossible for an intruder to solve for b by observing
+ * a number of these messages.
+ * 
+ * Alice receives the response and computes g^y v^r mod p. After a bit
+ * of algebra, this simplifies to g^k. If the hash of this result
+ * matches hash(x), Alice knows that Bob has the group key b. The signed
+ * response binds this knowledge to Bob's private key and the public key
+ * previously received in his certificate.
+ *
+ * crypto_alice - construct Alice's challenge in IFF scheme
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_PUB   bad or missing public key
+ * XEVNT_ID    bad or missing group key
+ */
+static int
+crypto_alice(
+       struct peer *peer,      /* peer pointer */
+       struct value *vp        /* value pointer */
+       )
+{
+       DSA     *dsa;           /* IFF parameters */
+       BN_CTX  *bctx;          /* BIGNUM context */
+       EVP_MD_CTX ctx;         /* signature context */
+       tstamp_t tstamp;
+       u_int   len;
+
+       /*
+        * The identity parameters must have correct format and content.
+        */
+       if (peer->ident_pkey == NULL)
+               return (XEVNT_ID);
+
+       if ((dsa = peer->ident_pkey->pkey.dsa) == NULL) {
+               msyslog(LOG_INFO, "crypto_alice: defective key");
+               return (XEVNT_PUB);
+       }
+
+       /*
+        * Roll new random r (0 < r < q). The OpenSSL library has a bug
+        * omitting BN_rand_range, so we have to do it the hard way.
+        */
+       bctx = BN_CTX_new();
+       len = BN_num_bytes(dsa->q);
+       if (peer->iffval != NULL)
+               BN_free(peer->iffval);
+       peer->iffval = BN_new();
+       BN_rand(peer->iffval, len * 8, -1, 1);  /* r */
+       BN_mod(peer->iffval, peer->iffval, dsa->q, bctx);
+       BN_CTX_free(bctx);
+
+       /*
+        * Sign and send to Bob. The filestamp is from the local file.
+        */
+       tstamp = crypto_time();
+       memset(vp, 0, sizeof(struct value));
+       vp->tstamp = htonl(tstamp);
+       vp->fstamp = htonl(peer->fstamp);
+       vp->vallen = htonl(len);
+       vp->ptr = emalloc(len);
+       BN_bn2bin(peer->iffval, vp->ptr);
+       vp->siglen = 0;
+       if (tstamp == 0)
+               return (XEVNT_OK);
+
+       if (tstamp < cinfo->first || tstamp > cinfo->last)
+               return (XEVNT_PER);
+
+       vp->sig = emalloc(sign_siglen);
+       EVP_SignInit(&ctx, sign_digest);
+       EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
+       EVP_SignUpdate(&ctx, vp->ptr, len);
+       if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
+               vp->siglen = htonl(len);
+       return (XEVNT_OK);
+}
+
+
+/*
+ * crypto_bob - construct Bob's response to Alice's challenge
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_ID    bad or missing group key
+ * XEVNT_ERR   protocol error
+ * XEVNT_PER   host expired certificate
+ */
+static int
+crypto_bob(
+       struct exten *ep,       /* extension pointer */
+       struct value *vp        /* value pointer */
+       )
+{
+       DSA     *dsa;           /* IFF parameters */
+       DSA_SIG *sdsa;          /* DSA signature context fake */
+       BN_CTX  *bctx;          /* BIGNUM context */
+       EVP_MD_CTX ctx;         /* signature context */
+       tstamp_t tstamp;        /* NTP timestamp */
+       BIGNUM  *bn, *bk, *r;
+       u_char  *ptr;
+       u_int   len;
+
+       /*
+        * If the IFF parameters are not valid, something awful
+        * happened or we are being tormented.
+        */
+       if (iffpar_pkey == NULL) {
+               msyslog(LOG_INFO, "crypto_bob: scheme unavailable");
+               return (XEVNT_ID);
+       }
+       dsa = iffpar_pkey->pkey.dsa;
+
+       /*
+        * Extract r from the challenge.
+        */
+       len = ntohl(ep->vallen);
+       if ((r = BN_bin2bn((u_char *)ep->pkt, len, NULL)) == NULL) {
+               msyslog(LOG_ERR, "crypto_bob %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (XEVNT_ERR);
+       }
+
+       /*
+        * Bob rolls random k (0 < k < q), computes y = k + b r mod q
+        * and x = g^k mod p, then sends (y, hash(x)) to Alice.
+        */
+       bctx = BN_CTX_new(); bk = BN_new(); bn = BN_new();
+       sdsa = DSA_SIG_new();
+       BN_rand(bk, len * 8, -1, 1);            /* k */
+       BN_mod_mul(bn, dsa->priv_key, r, dsa->q, bctx); /* b r mod q */
+       BN_add(bn, bn, bk);
+       BN_mod(bn, bn, dsa->q, bctx);           /* k + b r mod q */
+       sdsa->r = BN_dup(bn);
+       BN_mod_exp(bk, dsa->g, bk, dsa->p, bctx); /* g^k mod p */
+       bighash(bk, bk);
+       sdsa->s = BN_dup(bk);
+       BN_CTX_free(bctx);
+       BN_free(r); BN_free(bn); BN_free(bk);
+
+       /*
+        * Encode the values in ASN.1 and sign.
+        */
+       tstamp = crypto_time();
+       memset(vp, 0, sizeof(struct value));
+       vp->tstamp = htonl(tstamp);
+       vp->fstamp = htonl(if_fstamp);
+       len = i2d_DSA_SIG(sdsa, NULL);
+       if (len <= 0) {
+               msyslog(LOG_ERR, "crypto_bob %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               DSA_SIG_free(sdsa);
+               return (XEVNT_ERR);
+       }
+       vp->vallen = htonl(len);
+       ptr = emalloc(len);
+       vp->ptr = ptr;
+       i2d_DSA_SIG(sdsa, &ptr);
+       DSA_SIG_free(sdsa);
+       vp->siglen = 0;
+       if (tstamp == 0)
+               return (XEVNT_OK);
+
+       if (tstamp < cinfo->first || tstamp > cinfo->last)
+               return (XEVNT_PER);
+
+       vp->sig = emalloc(sign_siglen);
+       EVP_SignInit(&ctx, sign_digest);
+       EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
+       EVP_SignUpdate(&ctx, vp->ptr, len);
+       if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
+               vp->siglen = htonl(len);
+       return (XEVNT_OK);
+}
+
+
+/*
+ * crypto_iff - verify Bob's response to Alice's challenge
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_PUB   bad or missing public key
+ * XEVNT_ID    bad or missing group key
+ * XEVNT_FSP   bad filestamp
+ */
+int
+crypto_iff(
+       struct exten *ep,       /* extension pointer */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       DSA     *dsa;           /* IFF parameters */
+       BN_CTX  *bctx;          /* BIGNUM context */
+       DSA_SIG *sdsa;          /* DSA parameters */
+       BIGNUM  *bn, *bk;
+       u_int   len;
+       const u_char    *ptr;
+       int     temp;
+
+       /*
+        * If the IFF parameters are not valid or no challenge was sent,
+        * something awful happened or we are being tormented.
+        */
+       if (peer->ident_pkey == NULL) {
+               msyslog(LOG_INFO, "crypto_iff: scheme unavailable");
+               return (XEVNT_ID);
+       }
+       if (ntohl(ep->fstamp) != peer->fstamp) {
+               msyslog(LOG_INFO, "crypto_iff: invalid filestamp %u",
+                   ntohl(ep->fstamp));
+               return (XEVNT_FSP);
+       }
+       if ((dsa = peer->ident_pkey->pkey.dsa) == NULL) {
+               msyslog(LOG_INFO, "crypto_iff: defective key");
+               return (XEVNT_PUB);
+       }
+       if (peer->iffval == NULL) {
+               msyslog(LOG_INFO, "crypto_iff: missing challenge");
+               return (XEVNT_ID);
+       }
+
+       /*
+        * Extract the k + b r and g^k values from the response.
+        */
+       bctx = BN_CTX_new(); bk = BN_new(); bn = BN_new();
+       len = ntohl(ep->vallen);
+       ptr = (const u_char *)ep->pkt;
+       if ((sdsa = d2i_DSA_SIG(NULL, &ptr, len)) == NULL) {
+               msyslog(LOG_ERR, "crypto_iff %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (XEVNT_ERR);
+       }
+
+       /*
+        * Compute g^(k + b r) g^(q - b)r mod p.
+        */
+       BN_mod_exp(bn, dsa->pub_key, peer->iffval, dsa->p, bctx);
+       BN_mod_exp(bk, dsa->g, sdsa->r, dsa->p, bctx);
+       BN_mod_mul(bn, bn, bk, dsa->p, bctx);
+
+       /*
+        * Verify the hash of the result matches hash(x).
+        */
+       bighash(bn, bn);
+       temp = BN_cmp(bn, sdsa->s);
+       BN_free(bn); BN_free(bk); BN_CTX_free(bctx);
+       BN_free(peer->iffval);
+       peer->iffval = NULL;
+       DSA_SIG_free(sdsa);
+       if (temp == 0)
+               return (XEVNT_OK);
+
+       else
+               return (XEVNT_ID);
+}
+
+
+/*
+ ***********************************************************************
+ *                                                                    *
+ * The following routines implement the Guillou-Quisquater (GQ)        *
+ * identity scheme                                                     *
+ *                                                                    *
+ ***********************************************************************
+ *
+ * The Guillou-Quisquater (GQ) identity scheme is intended for use when
+ * the ntp-genkeys program generates the certificates used in the
+ * protocol and the group key can be conveyed in a certificate extension
+ * field. The scheme is self contained and independent of new
+ * generations of host keys, sign keys and certificates.
+ *
+ * The GQ identity scheme is based on RSA cryptography and algorithms
+ * described in Stinson p. 300 (with errors). The GQ values hide in a
+ * RSA cuckoo structure, but only the modulus is used. The 512-bit
+ * public modulus is n = p q, where p and q are secret large primes. The
+ * TA rolls random group key b disguised as a RSA structure member.
+ * Except for the public key, these values are shared only among group
+ * members and never revealed in messages.
+ *
+ * When rolling new certificates, Bob recomputes the private and
+ * public keys. The private key u is a random roll, while the public key
+ * is the inverse obscured by the group key v = (u^-1)^b. These values
+ * replace the private and public keys normally generated by the RSA
+ * scheme. Alice challenges Bob to confirm identity using the protocol
+ * described below.
+ *
+ * How it works
+ *
+ * The scheme goes like this. Both Alice and Bob have the same modulus n
+ * and some random b as the group key. These values are computed and
+ * distributed in advance via secret means, although only the group key
+ * b is truly secret. Each has a private random private key u and public
+ * key (u^-1)^b, although not necessarily the same ones. Bob and Alice
+ * can regenerate the key pair from time to time without affecting
+ * operations. The public key is conveyed on the certificate in an
+ * extension field; the private key is never revealed.
+ *
+ * Alice rolls new random challenge r and sends to Bob in the GQ
+ * request message. Bob rolls new random k, then computes y = k u^r mod
+ * n and x = k^b mod n and sends (y, hash(x)) to Alice in the response
+ * message. Besides making the response shorter, the hash makes it
+ * effectivey impossible for an intruder to solve for b by observing
+ * a number of these messages.
+ * 
+ * Alice receives the response and computes y^b v^r mod n. After a bit
+ * of algebra, this simplifies to k^b. If the hash of this result
+ * matches hash(x), Alice knows that Bob has the group key b. The signed
+ * response binds this knowledge to Bob's private key and the public key
+ * previously received in his certificate.
+ *
+ * crypto_alice2 - construct Alice's challenge in GQ scheme
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_PUB   bad or missing public key
+ * XEVNT_ID    bad or missing group key
+ * XEVNT_PER   host certificate expired
+ */
+static int
+crypto_alice2(
+       struct peer *peer,      /* peer pointer */
+       struct value *vp        /* value pointer */
+       )
+{
+       RSA     *rsa;           /* GQ parameters */
+       BN_CTX  *bctx;          /* BIGNUM context */
+       EVP_MD_CTX ctx;         /* signature context */
+       tstamp_t tstamp;
+       u_int   len;
+
+       /*
+        * The identity parameters must have correct format and content.
+        */
+       if (peer->ident_pkey == NULL)
+               return (XEVNT_ID);
+
+       if ((rsa = peer->ident_pkey->pkey.rsa) == NULL) {
+               msyslog(LOG_INFO, "crypto_alice2: defective key");
+               return (XEVNT_PUB);
+       }
+
+       /*
+        * Roll new random r (0 < r < n). The OpenSSL library has a bug
+        * omitting BN_rand_range, so we have to do it the hard way.
+        */
+       bctx = BN_CTX_new();
+       len = BN_num_bytes(rsa->n);
+       if (peer->iffval != NULL)
+               BN_free(peer->iffval);
+       peer->iffval = BN_new();
+       BN_rand(peer->iffval, len * 8, -1, 1);  /* r mod n */
+       BN_mod(peer->iffval, peer->iffval, rsa->n, bctx);
+       BN_CTX_free(bctx);
+
+       /*
+        * Sign and send to Bob. The filestamp is from the local file.
+        */
+       tstamp = crypto_time();
+       memset(vp, 0, sizeof(struct value));
+       vp->tstamp = htonl(tstamp);
+       vp->fstamp = htonl(peer->fstamp);
+       vp->vallen = htonl(len);
+       vp->ptr = emalloc(len);
+       BN_bn2bin(peer->iffval, vp->ptr);
+       vp->siglen = 0;
+       if (tstamp == 0)
+               return (XEVNT_OK);
+
+       if (tstamp < cinfo->first || tstamp > cinfo->last)
+               return (XEVNT_PER);
+
+       vp->sig = emalloc(sign_siglen);
+       EVP_SignInit(&ctx, sign_digest);
+       EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
+       EVP_SignUpdate(&ctx, vp->ptr, len);
+       if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
+               vp->siglen = htonl(len);
+       return (XEVNT_OK);
+}
+
+
+/*
+ * crypto_bob2 - construct Bob's response to Alice's challenge
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_ID    bad or missing group key
+ * XEVNT_ERR   protocol error
+ * XEVNT_PER   host certificate expired
+ */
+static int
+crypto_bob2(
+       struct exten *ep,       /* extension pointer */
+       struct value *vp        /* value pointer */
+       )
+{
+       RSA     *rsa;           /* GQ parameters */
+       DSA_SIG *sdsa;          /* DSA parameters */
+       BN_CTX  *bctx;          /* BIGNUM context */
+       EVP_MD_CTX ctx;         /* signature context */
+       tstamp_t tstamp;        /* NTP timestamp */
+       BIGNUM  *r, *k, *g, *y;
+       u_char  *ptr;
+       u_int   len;
+
+       /*
+        * If the GQ parameters are not valid, something awful
+        * happened or we are being tormented.
+        */
+       if (gqpar_pkey == NULL) {
+               msyslog(LOG_INFO, "crypto_bob2: scheme unavailable");
+               return (XEVNT_ID);
+       }
+       rsa = gqpar_pkey->pkey.rsa;
+
+       /*
+        * Extract r from the challenge.
+        */
+       len = ntohl(ep->vallen);
+       if ((r = BN_bin2bn((u_char *)ep->pkt, len, NULL)) == NULL) {
+               msyslog(LOG_ERR, "crypto_bob2 %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (XEVNT_ERR);
+       }
+
+       /*
+        * Bob rolls random k (0 < k < n), computes y = k u^r mod n and
+        * x = k^b mod n, then sends (y, hash(x)) to Alice. 
+        */
+       bctx = BN_CTX_new(); k = BN_new(); g = BN_new(); y = BN_new();
+       sdsa = DSA_SIG_new();
+       BN_rand(k, len * 8, -1, 1);             /* k */
+       BN_mod(k, k, rsa->n, bctx);
+       BN_mod_exp(y, rsa->p, r, rsa->n, bctx); /* u^r mod n */
+       BN_mod_mul(y, k, y, rsa->n, bctx);      /* k u^r mod n */
+       sdsa->r = BN_dup(y);
+       BN_mod_exp(g, k, rsa->e, rsa->n, bctx); /* k^b mod n */
+       bighash(g, g);
+       sdsa->s = BN_dup(g);
+       BN_CTX_free(bctx);
+       BN_free(r); BN_free(k); BN_free(g); BN_free(y);
+       /*
+        * Encode the values in ASN.1 and sign.
+        */
+       tstamp = crypto_time();
+       memset(vp, 0, sizeof(struct value));
+       vp->tstamp = htonl(tstamp);
+       vp->fstamp = htonl(gq_fstamp);
+       len = i2d_DSA_SIG(sdsa, NULL);
+       if (len <= 0) {
+               msyslog(LOG_ERR, "crypto_bob2 %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               DSA_SIG_free(sdsa);
+               return (XEVNT_ERR);
+       }
+       vp->vallen = htonl(len);
+       ptr = emalloc(len);
+       vp->ptr = ptr;
+       i2d_DSA_SIG(sdsa, &ptr);
+       DSA_SIG_free(sdsa);
+       vp->siglen = 0;
+       if (tstamp == 0)
+               return (XEVNT_OK);
+
+       if (tstamp < cinfo->first || tstamp > cinfo->last)
+               return (XEVNT_PER);
+
+       vp->sig = emalloc(sign_siglen);
+       EVP_SignInit(&ctx, sign_digest);
+       EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
+       EVP_SignUpdate(&ctx, vp->ptr, len);
+       if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
+               vp->siglen = htonl(len);
+       return (XEVNT_OK);
+}
+
+
+/*
+ * crypto_gq - verify Bob's response to Alice's challenge
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_PUB   bad or missing public key
+ * XEVNT_ID    bad or missing group keys
+ * XEVNT_ERR   protocol error
+ * XEVNT_FSP   bad filestamp
+ */
+int
+crypto_gq(
+       struct exten *ep,       /* extension pointer */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       RSA     *rsa;           /* GQ parameters */
+       BN_CTX  *bctx;          /* BIGNUM context */
+       DSA_SIG *sdsa;          /* RSA signature context fake */
+       BIGNUM  *y, *v;
+       const u_char    *ptr;
+       u_int   len;
+       int     temp;
+
+       /*
+        * If the GQ parameters are not valid or no challenge was sent,
+        * something awful happened or we are being tormented.
+        */
+       if (peer->ident_pkey == NULL) {
+               msyslog(LOG_INFO, "crypto_gq: scheme unavailable");
+               return (XEVNT_ID);
+       }
+       if (ntohl(ep->fstamp) != peer->fstamp) {
+               msyslog(LOG_INFO, "crypto_gq: invalid filestamp %u",
+                   ntohl(ep->fstamp));
+               return (XEVNT_FSP);
+       }
+       if ((rsa = peer->ident_pkey->pkey.rsa) == NULL) {
+               msyslog(LOG_INFO, "crypto_gq: defective key");
+               return (XEVNT_PUB);
+       }
+       if (peer->iffval == NULL) {
+               msyslog(LOG_INFO, "crypto_gq: missing challenge");
+               return (XEVNT_ID);
+       }
+
+       /*
+        * Extract the y = k u^r and hash(x = k^b) values from the
+        * response.
+        */
+       bctx = BN_CTX_new(); y = BN_new(); v = BN_new();
+       len = ntohl(ep->vallen);
+       ptr = (const u_char *)ep->pkt;
+       if ((sdsa = d2i_DSA_SIG(NULL, &ptr, len)) == NULL) {
+               msyslog(LOG_ERR, "crypto_gq %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (XEVNT_ERR);
+       }
+
+       /*
+        * Compute v^r y^b mod n.
+        */
+       BN_mod_exp(v, peer->grpkey, peer->iffval, rsa->n, bctx);
+                                               /* v^r mod n */
+       BN_mod_exp(y, sdsa->r, rsa->e, rsa->n, bctx); /* y^b mod n */
+       BN_mod_mul(y, v, y, rsa->n, bctx);      /* v^r y^b mod n */
+
+       /*
+        * Verify the hash of the result matches hash(x).
+        */
+       bighash(y, y);
+       temp = BN_cmp(y, sdsa->s);
+       BN_CTX_free(bctx); BN_free(y); BN_free(v);
+       BN_free(peer->iffval);
+       peer->iffval = NULL;
+       DSA_SIG_free(sdsa);
+       if (temp == 0)
+               return (XEVNT_OK);
+
+       else
+               return (XEVNT_ID);
+}
+
+
+/*
+ ***********************************************************************
+ *                                                                    *
+ * The following routines implement the Mu-Varadharajan (MV) identity  *
+ * scheme                                                              *
+ *                                                                    *
+ ***********************************************************************
+ */
+/*
+ * The Mu-Varadharajan (MV) cryptosystem was originally intended when
+ * servers broadcast messages to clients, but clients never send
+ * messages to servers. There is one encryption key for the server and a
+ * separate decryption key for each client. It operated something like a
+ * pay-per-view satellite broadcasting system where the session key is
+ * encrypted by the broadcaster and the decryption keys are held in a
+ * tamperproof set-top box.
+ *
+ * The MV parameters and private encryption key hide in a DSA cuckoo
+ * structure which uses the same parameters, but generated in a
+ * different way. The values are used in an encryption scheme similar to
+ * El Gamal cryptography and a polynomial formed from the expansion of
+ * product terms (x - x[j]), as described in Mu, Y., and V.
+ * Varadharajan: Robust and Secure Broadcasting, Proc. Indocrypt 2001,
+ * 223-231. The paper has significant errors and serious omissions.
+ *
+ * Let q be the product of n distinct primes s'[j] (j = 1...n), where
+ * each s'[j] has m significant bits. Let p be a prime p = 2 * q + 1, so
+ * that q and each s'[j] divide p - 1 and p has M = n * m + 1
+ * significant bits. The elements x mod q of Zq with the elements 2 and
+ * the primes removed form a field Zq* valid for polynomial arithetic.
+ * Let g be a generator of Zp; that is, gcd(g, p - 1) = 1 and g^q = 1
+ * mod p. We expect M to be in the 500-bit range and n relatively small,
+ * like 25, so the likelihood of a randomly generated element of x mod q
+ * of Zq colliding with a factor of p - 1 is very small and can be
+ * avoided. Associated with each s'[j] is an element s[j] such that s[j]
+ * s'[j] = s'[j] mod q. We find s[j] as the quotient (q + s'[j]) /
+ * s'[j]. These are the parameters of the scheme and they are expensive
+ * to compute.
+ *
+ * We set up an instance of the scheme as follows. A set of random
+ * values x[j] mod q (j = 1...n), are generated as the zeros of a
+ * polynomial of order n. The product terms (x - x[j]) are expanded to
+ * form coefficients a[i] mod q (i = 0...n) in powers of x. These are
+ * used as exponents of the generator g mod p to generate the private
+ * encryption key A. The pair (gbar, ghat) of public server keys and the
+ * pairs (xbar[j], xhat[j]) (j = 1...n) of private client keys are used
+ * to construct the decryption keys. The devil is in the details.
+ *
+ * The distinguishing characteristic of this scheme is the capability to
+ * revoke keys. Included in the calculation of E, gbar and ghat is the
+ * product s = prod(s'[j]) (j = 1...n) above. If the factor s'[j] is
+ * subsequently removed from the product and E, gbar and ghat
+ * recomputed, the jth client will no longer be able to compute E^-1 and
+ * thus unable to decrypt the block.
+ *
+ * How it works
+ *
+ * The scheme goes like this. Bob has the server values (p, A, q, gbar,
+ * ghat) and Alice the client values (p, xbar, xhat).
+ *
+ * Alice rolls new random challenge r (0 < r < p) and sends to Bob in
+ * the MV request message. Bob rolls new random k (0 < k < q), encrypts
+ * y = A^k mod p (a permutation) and sends (hash(y), gbar^k, ghat^k) to
+ * Alice.
+ * 
+ * Alice receives the response and computes the decryption key (the
+ * inverse permutation) from previously obtained (xbar, xhat) and
+ * (gbar^k, ghat^k) in the message. She computes the inverse, which is
+ * unique by reasons explained in the ntp-keygen.c program sources. If
+ * the hash of this result matches hash(y), Alice knows that Bob has the
+ * group key b. The signed response binds this knowledge to Bob's
+ * private key and the public key previously received in his
+ * certificate.
+ *
+ * crypto_alice3 - construct Alice's challenge in MV scheme
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_PUB   bad or missing public key
+ * XEVNT_ID    bad or missing group key
+ * XEVNT_PER   host certificate expired
+ */
+static int
+crypto_alice3(
+       struct peer *peer,      /* peer pointer */
+       struct value *vp        /* value pointer */
+       )
+{
+       DSA     *dsa;           /* MV parameters */
+       BN_CTX  *bctx;          /* BIGNUM context */
+       EVP_MD_CTX ctx;         /* signature context */
+       tstamp_t tstamp;
+       u_int   len;
+
+       /*
+        * The identity parameters must have correct format and content.
+        */
+       if (peer->ident_pkey == NULL)
+               return (XEVNT_ID);
+
+       if ((dsa = peer->ident_pkey->pkey.dsa) == NULL) {
+               msyslog(LOG_INFO, "crypto_alice3: defective key");
+               return (XEVNT_PUB);
+       }
+
+       /*
+        * Roll new random r (0 < r < q). The OpenSSL library has a bug
+        * omitting BN_rand_range, so we have to do it the hard way.
+        */
+       bctx = BN_CTX_new();
+       len = BN_num_bytes(dsa->p);
+       if (peer->iffval != NULL)
+               BN_free(peer->iffval);
+       peer->iffval = BN_new();
+       BN_rand(peer->iffval, len * 8, -1, 1);  /* r */
+       BN_mod(peer->iffval, peer->iffval, dsa->p, bctx);
+       BN_CTX_free(bctx);
+
+       /*
+        * Sign and send to Bob. The filestamp is from the local file.
+        */
+       tstamp = crypto_time();
+       memset(vp, 0, sizeof(struct value));
+       vp->tstamp = htonl(tstamp);
+       vp->fstamp = htonl(peer->fstamp);
+       vp->vallen = htonl(len);
+       vp->ptr = emalloc(len);
+       BN_bn2bin(peer->iffval, vp->ptr);
+       vp->siglen = 0;
+       if (tstamp == 0)
+               return (XEVNT_OK);
+
+       if (tstamp < cinfo->first || tstamp > cinfo->last)
+               return (XEVNT_PER);
+
+       vp->sig = emalloc(sign_siglen);
+       EVP_SignInit(&ctx, sign_digest);
+       EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
+       EVP_SignUpdate(&ctx, vp->ptr, len);
+       if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
+               vp->siglen = htonl(len);
+       return (XEVNT_OK);
+}
+
+
+/*
+ * crypto_bob3 - construct Bob's response to Alice's challenge
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_ERR   protocol error
+ * XEVNT_PER   host certificate expired
+ */
+static int
+crypto_bob3(
+       struct exten *ep,       /* extension pointer */
+       struct value *vp        /* value pointer */
+       )
+{
+       DSA     *dsa;           /* MV parameters */
+       DSA     *sdsa;          /* DSA signature context fake */
+       BN_CTX  *bctx;          /* BIGNUM context */
+       EVP_MD_CTX ctx;         /* signature context */
+       tstamp_t tstamp;        /* NTP timestamp */
+       BIGNUM  *r, *k, *u;
+       u_char  *ptr;
+       u_int   len;
+
+       /*
+        * If the MV parameters are not valid, something awful
+        * happened or we are being tormented.
+        */
+       if (mvpar_pkey == NULL) {
+               msyslog(LOG_INFO, "crypto_bob3: scheme unavailable");
+               return (XEVNT_ID);
+       }
+       dsa = mvpar_pkey->pkey.dsa;
+
+       /*
+        * Extract r from the challenge.
+        */
+       len = ntohl(ep->vallen);
+       if ((r = BN_bin2bn((u_char *)ep->pkt, len, NULL)) == NULL) {
+               msyslog(LOG_ERR, "crypto_bob3 %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (XEVNT_ERR);
+       }
+
+       /*
+        * Bob rolls random k (0 < k < q), making sure it is not a
+        * factor of q. He then computes y = A^k r and sends (hash(y),
+        * gbar^k, ghat^k) to Alice.
+        */
+       bctx = BN_CTX_new(); k = BN_new(); u = BN_new();
+       sdsa = DSA_new();
+       sdsa->p = BN_new(); sdsa->q = BN_new(); sdsa->g = BN_new();
+       while (1) {
+               BN_rand(k, BN_num_bits(dsa->q), 0, 0);
+               BN_mod(k, k, dsa->q, bctx);
+               BN_gcd(u, k, dsa->q, bctx);
+               if (BN_is_one(u))
+                       break;
+       }
+       BN_mod_exp(u, dsa->g, k, dsa->p, bctx); /* A r */
+       BN_mod_mul(u, u, r, dsa->p, bctx);
+       bighash(u, sdsa->p);
+       BN_mod_exp(sdsa->q, dsa->priv_key, k, dsa->p, bctx); /* gbar */
+       BN_mod_exp(sdsa->g, dsa->pub_key, k, dsa->p, bctx); /* ghat */
+       BN_CTX_free(bctx); BN_free(k); BN_free(r); BN_free(u);
+
+       /*
+        * Encode the values in ASN.1 and sign.
+        */
+       tstamp = crypto_time();
+       memset(vp, 0, sizeof(struct value));
+       vp->tstamp = htonl(tstamp);
+       vp->fstamp = htonl(mv_fstamp);
+       len = i2d_DSAparams(sdsa, NULL);
+       if (len <= 0) {
+               msyslog(LOG_ERR, "crypto_bob3 %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               DSA_free(sdsa);
+               return (XEVNT_ERR);
+       }
+       vp->vallen = htonl(len);
+       ptr = emalloc(len);
+       vp->ptr = ptr;
+       i2d_DSAparams(sdsa, &ptr);
+       DSA_free(sdsa);
+       vp->siglen = 0;
+       if (tstamp == 0)
+               return (XEVNT_OK);
+
+       if (tstamp < cinfo->first || tstamp > cinfo->last)
+               return (XEVNT_PER);
+
+       vp->sig = emalloc(sign_siglen);
+       EVP_SignInit(&ctx, sign_digest);
+       EVP_SignUpdate(&ctx, (u_char *)&vp->tstamp, 12);
+       EVP_SignUpdate(&ctx, vp->ptr, len);
+       if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
+               vp->siglen = htonl(len);
+       return (XEVNT_OK);
+}
+
+
+/*
+ * crypto_mv - verify Bob's response to Alice's challenge
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_PUB   bad or missing public key
+ * XEVNT_ID    bad or missing group key
+ * XEVNT_ERR   protocol error
+ * XEVNT_FSP   bad filestamp
+ */
+int
+crypto_mv(
+       struct exten *ep,       /* extension pointer */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       DSA     *dsa;           /* MV parameters */
+       DSA     *sdsa;          /* DSA parameters */
+       BN_CTX  *bctx;          /* BIGNUM context */
+       BIGNUM  *k, *u, *v;
+       u_int   len;
+       const u_char    *ptr;
+       int     temp;
+
+       /*
+        * If the MV parameters are not valid or no challenge was sent,
+        * something awful happened or we are being tormented.
+        */
+       if (peer->ident_pkey == NULL) {
+               msyslog(LOG_INFO, "crypto_mv: scheme unavailable");
+               return (XEVNT_ID);
+       }
+       if (ntohl(ep->fstamp) != peer->fstamp) {
+               msyslog(LOG_INFO, "crypto_mv: invalid filestamp %u",
+                   ntohl(ep->fstamp));
+               return (XEVNT_FSP);
+       }
+       if ((dsa = peer->ident_pkey->pkey.dsa) == NULL) {
+               msyslog(LOG_INFO, "crypto_mv: defective key");
+               return (XEVNT_PUB);
+       }
+       if (peer->iffval == NULL) {
+               msyslog(LOG_INFO, "crypto_mv: missing challenge");
+               return (XEVNT_ID);
+       }
+
+       /*
+        * Extract the (hash(y), gbar, ghat) values from the response.
+        */
+       bctx = BN_CTX_new(); k = BN_new(); u = BN_new(); v = BN_new();
+       len = ntohl(ep->vallen);
+       ptr = (const u_char *)ep->pkt;
+       if ((sdsa = d2i_DSAparams(NULL, &ptr, len)) == NULL) {
+               msyslog(LOG_ERR, "crypto_mv %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (XEVNT_ERR);
+       }
+
+       /*
+        * Compute (gbar^xhat ghat^xbar)^-1 mod p.
+        */
+       BN_mod_exp(u, sdsa->q, dsa->pub_key, dsa->p, bctx);
+       BN_mod_exp(v, sdsa->g, dsa->priv_key, dsa->p, bctx);
+       BN_mod_mul(u, u, v, dsa->p, bctx);
+       BN_mod_inverse(u, u, dsa->p, bctx);
+       BN_mod_mul(v, u, peer->iffval, dsa->p, bctx);
+
+       /*
+        * The result should match the hash of r mod p.
+        */
+       bighash(v, v);
+       temp = BN_cmp(v, sdsa->p);
+       BN_CTX_free(bctx); BN_free(k); BN_free(u); BN_free(v);
+       BN_free(peer->iffval);
+       peer->iffval = NULL;
+       DSA_free(sdsa);
+       if (temp == 0)
+               return (XEVNT_OK);
+
+       else
+               return (XEVNT_ID);
+}
+
+
+/*
+ ***********************************************************************
+ *                                                                    *
+ * The following routines are used to manipulate certificates          *
+ *                                                                    *
+ ***********************************************************************
+ */
+/*
+ * cert_parse - parse x509 certificate and create info/value structures.
+ *
+ * The server certificate includes the version number, issuer name,
+ * subject name, public key and valid date interval. If the issuer name
+ * is the same as the subject name, the certificate is self signed and
+ * valid only if the server is configured as trustable. If the names are
+ * different, another issuer has signed the server certificate and
+ * vouched for it. In this case the server certificate is valid if
+ * verified by the issuer public key.
+ *
+ * Returns certificate info/value pointer if valid, NULL if not.
+ */
+struct cert_info *             /* certificate information structure */
+cert_parse(
+       u_char  *asn1cert,      /* X509 certificate */
+       u_int   len,            /* certificate length */
+       tstamp_t fstamp         /* filestamp */
+       )
+{
+       X509    *cert;          /* X509 certificate */
+       X509_EXTENSION *ext;    /* X509v3 extension */
+       struct cert_info *ret;  /* certificate info/value */
+       BIO     *bp;
+       X509V3_EXT_METHOD *method;
+       char    pathbuf[MAXFILENAME];
+       u_char  *uptr;
+       char    *ptr;
+       int     temp, cnt, i;
+
+       /*
+        * Decode ASN.1 objects and construct certificate structure.
+        */
+       uptr = asn1cert;
+       if ((cert = d2i_X509(NULL, &uptr, len)) == NULL) {
+               msyslog(LOG_ERR, "cert_parse %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (NULL);
+       }
+
+       /*
+        * Extract version, subject name and public key.
+        */
+       ret = emalloc(sizeof(struct cert_info));
+       memset(ret, 0, sizeof(struct cert_info));
+       if ((ret->pkey = X509_get_pubkey(cert)) == NULL) {
+               msyslog(LOG_ERR, "cert_parse %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               cert_free(ret);
+               X509_free(cert);
+               return (NULL);
+       }
+       ret->version = X509_get_version(cert);
+       X509_NAME_oneline(X509_get_subject_name(cert), pathbuf,
+           MAXFILENAME - 1);
+       ptr = strstr(pathbuf, "CN=");
+       if (ptr == NULL) {
+               msyslog(LOG_INFO, "cert_parse: invalid subject %s",
+                   pathbuf);
+               cert_free(ret);
+               X509_free(cert);
+               return (NULL);
+       }
+       ret->subject = emalloc(strlen(ptr) + 1);
+       strcpy(ret->subject, ptr + 3);
+
+       /*
+        * Extract remaining objects. Note that the NTP serial number is
+        * the NTP seconds at the time of signing, but this might not be
+        * the case for other authority. We don't bother to check the
+        * objects at this time, since the real crunch can happen only
+        * when the time is valid but not yet certificated.
+        */
+       ret->nid = OBJ_obj2nid(cert->cert_info->signature->algorithm);
+       ret->digest = (const EVP_MD *)EVP_get_digestbynid(ret->nid);
+       ret->serial =
+           (u_long)ASN1_INTEGER_get(X509_get_serialNumber(cert));
+       X509_NAME_oneline(X509_get_issuer_name(cert), pathbuf,
+           MAXFILENAME);
+       if ((ptr = strstr(pathbuf, "CN=")) == NULL) {
+               msyslog(LOG_INFO, "cert_parse: invalid issuer %s",
+                   pathbuf);
+               cert_free(ret);
+               X509_free(cert);
+               return (NULL);
+       }
+       ret->issuer = emalloc(strlen(ptr) + 1);
+       strcpy(ret->issuer, ptr + 3);
+       ret->first = asn2ntp(X509_get_notBefore(cert));
+       ret->last = asn2ntp(X509_get_notAfter(cert));
+
+       /*
+        * Extract extension fields. These are ad hoc ripoffs of
+        * currently assigned functions and will certainly be changed
+        * before prime time.
+        */
+       cnt = X509_get_ext_count(cert);
+       for (i = 0; i < cnt; i++) {
+               ext = X509_get_ext(cert, i);
+               method = X509V3_EXT_get(ext);
+               temp = OBJ_obj2nid(ext->object);
+               switch (temp) {
+
+               /*
+                * If a key_usage field is present, we decode whether
+                * this is a trusted or private certificate. This is
+                * dorky; all we want is to compare NIDs, but OpenSSL
+                * insists on BIO text strings.
+                */
+               case NID_ext_key_usage:
+                       bp = BIO_new(BIO_s_mem());
+                       X509V3_EXT_print(bp, ext, 0, 0);
+                       BIO_gets(bp, pathbuf, MAXFILENAME);
+                       BIO_free(bp);
+#if DEBUG
+                       if (debug)
+                               printf("cert_parse: %s: %s\n",
+                                   OBJ_nid2ln(temp), pathbuf);
+#endif
+                       if (strcmp(pathbuf, "Trust Root") == 0)
+                               ret->flags |= CERT_TRUST;
+                       else if (strcmp(pathbuf, "Private") == 0)
+                               ret->flags |= CERT_PRIV;
+                       break;
+
+               /*
+                * If a NID_subject_key_identifier field is present, it
+                * contains the GQ public key.
+                */
+               case NID_subject_key_identifier:
+                       ret->grplen = ext->value->length - 2;
+                       ret->grpkey = emalloc(ret->grplen);
+                       memcpy(ret->grpkey, &ext->value->data[2],
+                           ret->grplen);
+                       break;
+               }
+       }
+
+       /*
+        * If certificate is self signed, verify signature.
+        */
+       if (strcmp(ret->subject, ret->issuer) == 0) {
+               if (!X509_verify(cert, ret->pkey)) {
+                       msyslog(LOG_INFO,
+                           "cert_parse: signature not verified %s",
+                           pathbuf);
+                       cert_free(ret);
+                       X509_free(cert);
+                       return (NULL);
+               }
+       }
+
+       /*
+        * Verify certificate valid times. Note that certificates cannot
+        * be retroactive.
+        */
+       if (ret->first > ret->last || ret->first < fstamp) {
+               msyslog(LOG_INFO,
+                   "cert_parse: invalid certificate %s first %u last %u fstamp %u",
+                   ret->subject, ret->first, ret->last, fstamp);
+               cert_free(ret);
+               X509_free(cert);
+               return (NULL);
+       }
+
+       /*
+        * Build the value structure to sign and send later.
+        */
+       ret->cert.fstamp = htonl(fstamp);
+       ret->cert.vallen = htonl(len);
+       ret->cert.ptr = emalloc(len);
+       memcpy(ret->cert.ptr, asn1cert, len);
+#ifdef DEBUG
+       if (debug > 1)
+               X509_print_fp(stdout, cert);
+#endif
+       X509_free(cert);
+       return (ret);
+}
+
+
+/*
+ * cert_sign - sign x509 certificate equest and update value structure.
+ *
+ * The certificate request includes a copy of the host certificate,
+ * which includes the version number, subject name and public key of the
+ * host. The resulting certificate includes these values plus the
+ * serial number, issuer name and valid interval of the server. The
+ * valid interval extends from the current time to the same time one
+ * year hence. This may extend the life of the signed certificate beyond
+ * that of the signer certificate.
+ *
+ * It is convenient to use the NTP seconds of the current time as the
+ * serial number. In the value structure the timestamp is the current
+ * time and the filestamp is taken from the extension field. Note this
+ * routine is called only when the client clock is synchronized to a
+ * proventic source, so timestamp comparisons are valid.
+ *
+ * The host certificate is valid from the time it was generated for a
+ * period of one year. A signed certificate is valid from the time of
+ * signature for a period of one year, but only the host certificate (or
+ * sign certificate if used) is actually used to encrypt and decrypt
+ * signatures. The signature trail is built from the client via the
+ * intermediate servers to the trusted server. Each signature on the
+ * trail must be valid at the time of signature, but it could happen
+ * that a signer certificate expire before the signed certificate, which
+ * remains valid until its expiration. 
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_PUB   bad or missing public key
+ * XEVNT_CRT   bad or missing certificate
+ * XEVNT_VFY   certificate not verified
+ * XEVNT_PER   host certificate expired
+ */
+static int
+cert_sign(
+       struct exten *ep,       /* extension field pointer */
+       struct value *vp        /* value pointer */
+       )
+{
+       X509    *req;           /* X509 certificate request */
+       X509    *cert;          /* X509 certificate */
+       X509_EXTENSION *ext;    /* certificate extension */
+       ASN1_INTEGER *serial;   /* serial number */
+       X509_NAME *subj;        /* distinguished (common) name */
+       EVP_PKEY *pkey;         /* public key */
+       EVP_MD_CTX ctx;         /* message digest context */
+       tstamp_t tstamp;        /* NTP timestamp */
+       u_int   len;
+       u_char  *ptr;
+       int     i, temp;
+
+       /*
+        * Decode ASN.1 objects and construct certificate structure.
+        * Make sure the system clock is synchronized to a proventic
+        * source.
+        */
+       tstamp = crypto_time();
+       if (tstamp == 0)
+               return (XEVNT_TSP);
+
+       if (tstamp < cinfo->first || tstamp > cinfo->last)
+               return (XEVNT_PER);
+
+       ptr = (u_char *)ep->pkt;
+       if ((req = d2i_X509(NULL, &ptr, ntohl(ep->vallen))) == NULL) {
+               msyslog(LOG_ERR, "cert_sign %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (XEVNT_CRT);
+       }
+       /*
+        * Extract public key and check for errors.
+        */
+       if ((pkey = X509_get_pubkey(req)) == NULL) {
+               msyslog(LOG_ERR, "cert_sign %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               X509_free(req);
+               return (XEVNT_PUB);
+       }
+
+       /*
+        * Generate X509 certificate signed by this server. For this
+        * purpose the issuer name is the server name. Also copy any
+        * extensions that might be present.
+        */
+       cert = X509_new();
+       X509_set_version(cert, X509_get_version(req));
+       serial = ASN1_INTEGER_new();
+       ASN1_INTEGER_set(serial, tstamp);
+       X509_set_serialNumber(cert, serial);
+       X509_gmtime_adj(X509_get_notBefore(cert), 0L);
+       X509_gmtime_adj(X509_get_notAfter(cert), YEAR);
+       subj = X509_get_issuer_name(cert);
+       X509_NAME_add_entry_by_txt(subj, "commonName", MBSTRING_ASC,
+           (u_char *)sys_hostname, strlen(sys_hostname), -1, 0);
+       subj = X509_get_subject_name(req);
+       X509_set_subject_name(cert, subj);
+       X509_set_pubkey(cert, pkey);
+       ext = X509_get_ext(req, 0);
+       temp = X509_get_ext_count(req);
+       for (i = 0; i < temp; i++) {
+               ext = X509_get_ext(req, i);
+               X509_add_ext(cert, ext, -1);
+       }
+       X509_free(req);
+
+       /*
+        * Sign and verify the certificate.
+        */
+       X509_sign(cert, sign_pkey, sign_digest);
+       if (!X509_verify(cert, sign_pkey)) {
+               printf("cert_sign\n%s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               X509_free(cert);
+               return (XEVNT_VFY);
+       }
+       len = i2d_X509(cert, NULL);
+
+       /*
+        * Build and sign the value structure. We have to sign it here,
+        * since the response has to be returned right away. This is a
+        * clogging hazard.
+        */
+       memset(vp, 0, sizeof(struct value));
+       vp->tstamp = htonl(tstamp);
+       vp->fstamp = ep->fstamp;
+       vp->vallen = htonl(len);
+       vp->ptr = emalloc(len);
+       ptr = vp->ptr;
+       i2d_X509(cert, &ptr);
+       vp->siglen = 0;
+       vp->sig = emalloc(sign_siglen);
+       EVP_SignInit(&ctx, sign_digest);
+       EVP_SignUpdate(&ctx, (u_char *)vp, 12);
+       EVP_SignUpdate(&ctx, vp->ptr, len);
+       if (EVP_SignFinal(&ctx, vp->sig, &len, sign_pkey))
+               vp->siglen = htonl(len);
+#ifdef DEBUG
+       if (debug > 1)
+               X509_print_fp(stdout, cert);
+#endif
+       X509_free(cert);
+       return (XEVNT_OK);
+}
+
+
+/*
+ * cert_valid - verify certificate with given public key
+ *
+ * This is pretty ugly, as the certificate has to be verified in the
+ * OpenSSL X509 structure, not in the DER format in the info/value
+ * structure.
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_VFY   certificate not verified
+ */
+int
+cert_valid(
+       struct cert_info *cinf, /* certificate information structure */
+       EVP_PKEY *pkey          /* public key */
+       )
+{
+       X509    *cert;          /* X509 certificate */
+       u_char  *ptr;
+
+       if (cinf->flags & CERT_SIGN)
+               return (XEVNT_OK);
+
+       ptr = (u_char *)cinf->cert.ptr;
+       cert = d2i_X509(NULL, &ptr, ntohl(cinf->cert.vallen));
+       if (cert == NULL || !X509_verify(cert, pkey))
+               return (XEVNT_VFY);
+
+       X509_free(cert);
+       return (XEVNT_OK);
+}
+
+
+/*
+ * cert - install certificate in certificate list
+ *
+ * This routine encodes an extension field into a certificate info/value
+ * structure. It searches the certificate list for duplicates and
+ * expunges whichever is older. It then searches the list for other
+ * certificates that might be verified by this latest one. Finally, it
+ * inserts this certificate first on the list.
+ *
+ * Returns
+ * XEVNT_OK    success
+ * XEVNT_FSP   bad or missing filestamp
+ * XEVNT_CRT   bad or missing certificate 
+ */
+int
+cert_install(
+       struct exten *ep,       /* cert info/value */
+       struct peer *peer       /* peer structure */
+       )
+{
+       struct cert_info *cp, *xp, *yp, **zp;
+
+       /*
+        * Parse and validate the signed certificate. If valid,
+        * construct the info/value structure; otherwise, scamper home.
+        */
+       if ((cp = cert_parse((u_char *)ep->pkt, ntohl(ep->vallen),
+           ntohl(ep->fstamp))) == NULL)
+               return (XEVNT_CRT);
+
+       /*
+        * Scan certificate list looking for another certificate with
+        * the same subject and issuer. If another is found with the
+        * same or older filestamp, unlink it and return the goodies to
+        * the heap. If another is found with a later filestamp, discard
+        * the new one and leave the building.
+        *
+        * Make a note to study this issue again. An earlier certificate
+        * with a long lifetime might be overtaken by a later
+        * certificate with a short lifetime, thus invalidating the
+        * earlier signature. However, we gotta find a way to leak old
+        * stuff from the cache, so we do it anyway. 
+        */
+       yp = cp;
+       zp = &cinfo;
+       for (xp = cinfo; xp != NULL; xp = xp->link) {
+               if (strcmp(cp->subject, xp->subject) == 0 &&
+                   strcmp(cp->issuer, xp->issuer) == 0) {
+                       if (ntohl(cp->cert.fstamp) <=
+                           ntohl(xp->cert.fstamp)) {
+                               *zp = xp->link;;
+                               cert_free(xp);
+                       } else {
+                               cert_free(cp);
+                               return (XEVNT_FSP);
+                       }
+                       break;
+               }
+               zp = &xp->link;
+       }
+       yp->link = cinfo;
+       cinfo = yp;
+
+       /*
+        * Scan the certificate list to see if Y is signed by X. This is
+        * independent of order.
+        */
+       for (yp = cinfo; yp != NULL; yp = yp->link) {
+               for (xp = cinfo; xp != NULL; xp = xp->link) {
+
+                       /*
+                        * If the issuer of certificate Y matches the
+                        * subject of certificate X, verify the
+                        * signature of Y using the public key of X. If
+                        * so, X signs Y.
+                        */
+                       if (strcmp(yp->issuer, xp->subject) != 0 ||
+                               xp->flags & CERT_ERROR)
+                               continue;
+
+                       if (cert_valid(yp, xp->pkey) != XEVNT_OK) {
+                               yp->flags |= CERT_ERROR;
+                               continue;
+                       }
+
+                       /*
+                        * The signature Y is valid only if it begins
+                        * during the lifetime of X; however, it is not
+                        * necessarily an error, since some other
+                        * certificate might sign Y. 
+                        */
+                       if (yp->first < xp->first || yp->first >
+                           xp->last)
+                               continue;
+
+                       yp->flags |= CERT_SIGN;
+
+                       /*
+                        * If X is trusted, then Y is trusted. Note that
+                        * we might stumble over a self-signed
+                        * certificate that is not trusted, at least
+                        * temporarily. This can happen when a dude
+                        * first comes up, but has not synchronized the
+                        * clock and had its certificate signed by its
+                        * server. In case of broken certificate trail,
+                        * this might result in a loop that could
+                        * persist until timeout.
+                        */
+                       if (!(xp->flags & (CERT_TRUST | CERT_VALID)))
+                               continue;
+
+                       yp->flags |= CERT_VALID;
+
+                       /*
+                        * If subject Y matches the server subject name,
+                        * then Y has completed the certificate trail.
+                        * Save the group key and light the valid bit.
+                        */
+                       if (strcmp(yp->subject, peer->subject) != 0)
+                               continue;
+
+                       if (yp->grpkey != NULL) {
+                               if (peer->grpkey != NULL)
+                                       BN_free(peer->grpkey);
+                               peer->grpkey = BN_bin2bn(yp->grpkey,
+                                    yp->grplen, NULL);
+                       }
+                       peer->crypto |= CRYPTO_FLAG_VALID;
+
+                       /*
+                        * If the server has an an identity scheme,
+                        * fetch the identity credentials. If not, the
+                        * identity is verified only by the trusted
+                        * certificate. The next signature will set the
+                        * server proventic.
+                        */
+                       if (peer->crypto & (CRYPTO_FLAG_GQ |
+                           CRYPTO_FLAG_IFF | CRYPTO_FLAG_MV))
+                               continue;
+
+                       peer->crypto |= CRYPTO_FLAG_VRFY;
+               }
+       }
+
+       /*
+        * That was awesome. Now update the timestamps and signatures.
+        */
+       crypto_update();
+       return (XEVNT_OK);
+}
+
+
+/*
+ * cert_free - free certificate information structure
+ */
+void
+cert_free(
+       struct cert_info *cinf  /* certificate info/value structure */ 
+       )
+{
+       if (cinf->pkey != NULL)
+               EVP_PKEY_free(cinf->pkey);
+       if (cinf->subject != NULL)
+               free(cinf->subject);
+       if (cinf->issuer != NULL)
+               free(cinf->issuer);
+       if (cinf->grpkey != NULL)
+               free(cinf->grpkey);
+       value_free(&cinf->cert);
+       free(cinf);
+}
+
+
+/*
+ ***********************************************************************
+ *                                                                    *
+ * The following routines are used only at initialization time         *
+ *                                                                    *
+ ***********************************************************************
+ */
+/*
+ * crypto_key - load cryptographic parameters and keys from files
+ *
+ * This routine loads a PEM-encoded public/private key pair and extracts
+ * the filestamp from the file name.
+ *
+ * Returns public key pointer if valid, NULL if not. Side effect updates
+ * the filestamp if valid.
+ */
+static EVP_PKEY *
+crypto_key(
+       char    *cp,            /* file name */
+       tstamp_t *fstamp        /* filestamp */
+       )
+{
+       FILE    *str;           /* file handle */
+       EVP_PKEY *pkey = NULL;  /* public/private key */
+       char    filename[MAXFILENAME]; /* name of key file */
+       char    linkname[MAXFILENAME]; /* filestamp buffer) */
+       char    statstr[NTP_MAXSTRLEN]; /* statistics for filegen */
+       char    *ptr;
+
+       /*
+        * Open the key file. If the first character of the file name is
+        * not '/', prepend the keys directory string. If something goes
+        * wrong, abandon ship.
+        */
+       if (*cp == '/')
+               strcpy(filename, cp);
+       else
+               snprintf(filename, MAXFILENAME, "%s/%s", keysdir, cp);
+       str = fopen(filename, "r");
+       if (str == NULL)
+               return (NULL);
+
+       /*
+        * Read the filestamp, which is contained in the first line.
+        */
+       if ((ptr = fgets(linkname, MAXFILENAME, str)) == NULL) {
+               msyslog(LOG_ERR, "crypto_key: no data %s\n",
+                   filename);
+               (void)fclose(str);
+               return (NULL);
+       }
+       if ((ptr = strrchr(ptr, '.')) == NULL) {
+               msyslog(LOG_ERR, "crypto_key: no filestamp %s\n",
+                   filename);
+               (void)fclose(str);
+               return (NULL);
+       }
+       if (sscanf(++ptr, "%u", fstamp) != 1) {
+               msyslog(LOG_ERR, "crypto_key: invalid timestamp %s\n",
+                   filename);
+               (void)fclose(str);
+               return (NULL);
+       }
+
+       /*
+        * Read and decrypt PEM-encoded private key.
+        */
+       pkey = PEM_read_PrivateKey(str, NULL, NULL, passwd);
+       fclose(str);
+       if (pkey == NULL) {
+               msyslog(LOG_ERR, "crypto_key %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (NULL);
+       }
+
+       /*
+        * Leave tracks in the cryptostats.
+        */
+       if ((ptr = strrchr(linkname, '\n')) != NULL)
+               *ptr = '\0'; 
+       snprintf(statstr, NTP_MAXSTRLEN, "%s mod %d", &linkname[2],
+           EVP_PKEY_size(pkey) * 8);
+       record_crypto_stats(NULL, statstr);
+#ifdef DEBUG
+       if (debug)
+               printf("crypto_key: %s\n", statstr);
+       if (debug > 1) {
+               if (pkey->type == EVP_PKEY_DSA)
+                       DSA_print_fp(stdout, pkey->pkey.dsa, 0);
+               else
+                       RSA_print_fp(stdout, pkey->pkey.rsa, 0);
+       }
+#endif
+       return (pkey);
+}
+
+
+/*
+ * crypto_cert - load certificate from file
+ *
+ * This routine loads a X.509 RSA or DSA certificate from a file and
+ * constructs a info/cert value structure for this machine. The
+ * structure includes a filestamp extracted from the file name. Later
+ * the certificate can be sent to another machine by request.
+ *
+ * Returns certificate info/value pointer if valid, NULL if not.
+ */
+static struct cert_info *      /* certificate information */
+crypto_cert(
+       char    *cp             /* file name */
+       )
+{
+       struct cert_info *ret; /* certificate information */
+       FILE    *str;           /* file handle */
+       char    filename[MAXFILENAME]; /* name of certificate file */
+       char    linkname[MAXFILENAME]; /* filestamp buffer */
+       char    statstr[NTP_MAXSTRLEN]; /* statistics for filegen */
+       tstamp_t fstamp;        /* filestamp */
+       long    len;
+       char    *ptr;
+       char    *name, *header;
+       u_char  *data;
+
+       /*
+        * Open the certificate file. If the first character of the file
+        * name is not '/', prepend the keys directory string. If
+        * something goes wrong, abandon ship.
+        */
+       if (*cp == '/')
+               strcpy(filename, cp);
+       else
+               snprintf(filename, MAXFILENAME, "%s/%s", keysdir, cp);
+       str = fopen(filename, "r");
+       if (str == NULL)
+               return (NULL);
+
+       /*
+        * Read the filestamp, which is contained in the first line.
+        */
+       if ((ptr = fgets(linkname, MAXFILENAME, str)) == NULL) {
+               msyslog(LOG_ERR, "crypto_cert: no data %s\n",
+                   filename);
+               (void)fclose(str);
+               return (NULL);
+       }
+       if ((ptr = strrchr(ptr, '.')) == NULL) {
+               msyslog(LOG_ERR, "crypto_cert: no filestamp %s\n",
+                   filename);
+               (void)fclose(str);
+               return (NULL);
+       }
+       if (sscanf(++ptr, "%u", &fstamp) != 1) {
+               msyslog(LOG_ERR, "crypto_cert: invalid filestamp %s\n",
+                   filename);
+               (void)fclose(str);
+               return (NULL);
+       }
+
+       /*
+        * Read PEM-encoded certificate and install.
+        */
+       if (!PEM_read(str, &name, &header, &data, &len)) {
+               msyslog(LOG_ERR, "crypto_cert %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               (void)fclose(str);
+               return (NULL);
+       }
+       free(header);
+       if (strcmp(name, "CERTIFICATE") !=0) {
+               msyslog(LOG_INFO, "crypto_cert: wrong PEM type %s",
+                   name);
+               free(name);
+               free(data);
+               (void)fclose(str);
+               return (NULL);
+       }
+       free(name);
+
+       /*
+        * Parse certificate and generate info/value structure.
+        */
+       ret = cert_parse(data, len, fstamp);
+       free(data);
+       (void)fclose(str);
+       if (ret == NULL)
+               return (NULL);
+
+       if ((ptr = strrchr(linkname, '\n')) != NULL)
+               *ptr = '\0'; 
+       snprintf(statstr, NTP_MAXSTRLEN,
+           "%s 0x%x len %lu", &linkname[2], ret->flags, len);
+       record_crypto_stats(NULL, statstr);
+#ifdef DEBUG
+       if (debug)
+               printf("crypto_cert: %s\n", statstr);
+#endif
+       return (ret);
+}
+
+
+/*
+ * crypto_tai - load leapseconds table from file
+ *
+ * This routine loads the ERTS leapsecond file in NIST text format,
+ * converts to a value structure and extracts a filestamp from the file
+ * name. The data are used to establish the TAI offset from UTC, which
+ * is provided to the kernel if supported. Later the data can be sent to
+ * another machine on request.
+ */
+static void
+crypto_tai(
+       char    *cp             /* file name */
+       )
+{
+       FILE    *str;           /* file handle */
+       char    buf[NTP_MAXSTRLEN];     /* file line buffer */
+       u_int32 leapsec[MAX_LEAP]; /* NTP time at leaps */
+       int     offset;         /* offset at leap (s) */
+       char    filename[MAXFILENAME]; /* name of leapseconds file */
+       char    linkname[MAXFILENAME]; /* file link (for filestamp) */
+       char    statstr[NTP_MAXSTRLEN]; /* statistics for filegen */
+       tstamp_t fstamp;        /* filestamp */
+       u_int   len;
+       u_int32 *ptr;
+       char    *dp;
+       int     rval, i, j;
+
+       /*
+        * Open the file and discard comment lines. If the first
+        * character of the file name is not '/', prepend the keys
+        * directory string. If the file is not found, not to worry; it
+        * can be retrieved over the net. But, if it is found with
+        * errors, we crash and burn.
+        */
+       if (*cp == '/')
+               strcpy(filename, cp);
+       else
+               snprintf(filename, MAXFILENAME, "%s/%s", keysdir, cp);
+       if ((str = fopen(filename, "r")) == NULL)
+               return;
+
+       /*
+        * Extract filestamp if present.
+        */
+       rval = readlink(filename, linkname, MAXFILENAME - 1);
+       if (rval > 0) {
+               linkname[rval] = '\0';
+               dp = strrchr(linkname, '.');
+       } else {
+               dp = strrchr(filename, '.');
+       }
+       if (dp != NULL)
+               sscanf(++dp, "%u", &fstamp);
+       else
+               fstamp = 0;
+       tai_leap.fstamp = htonl(fstamp);
+
+       /*
+        * We are rather paranoid here, since an intruder might cause a
+        * coredump by infiltrating naughty values. Empty lines and
+        * comments are ignored. Other lines must begin with two
+        * integers followed by junk or comments. The first integer is
+        * the NTP seconds of leap insertion, the second is the offset
+        * of TAI relative to UTC after that insertion. The second word
+        * must equal the initial insertion of ten seconds on 1 January
+        * 1972 plus one second for each succeeding insertion.
+        */
+       i = 0;
+       while (i < MAX_LEAP) {
+               dp = fgets(buf, NTP_MAXSTRLEN - 1, str);
+               if (dp == NULL)
+                       break;
+
+               if (strlen(buf) < 1)
+                       continue;
+
+               if (*buf == '#')
+                       continue;
+
+               if (sscanf(buf, "%u %d", &leapsec[i], &offset) != 2)
+                       continue;
+
+               if (i != offset - TAI_1972) 
+                       break;
+
+               i++;
+       }
+       fclose(str);
+       if (dp != NULL) {
+               msyslog(LOG_INFO,
+                   "crypto_tai: leapseconds file %s error %d", cp,
+                   rval);
+               exit (-1);
+       }
+
+       /*
+        * The extension field table entries consists of the NTP seconds
+        * of leap insertion in network byte order.
+        */
+       len = i * sizeof(u_int32);
+       tai_leap.vallen = htonl(len);
+       ptr = emalloc(len);
+       tai_leap.ptr = (u_char *)ptr;
+       for (j = 0; j < i; j++)
+               *ptr++ = htonl(leapsec[j]);
+       crypto_flags |= CRYPTO_FLAG_TAI;
+       snprintf(statstr, NTP_MAXSTRLEN, "%s fs %u leap %u len %u", cp, fstamp,
+          leapsec[--j], len);
+       record_crypto_stats(NULL, statstr);
+#ifdef DEBUG
+       if (debug)
+               printf("crypto_tai: %s\n", statstr);
+#endif
+}
+
+
+/*
+ * crypto_setup - load keys, certificate and leapseconds table
+ *
+ * This routine loads the public/private host key and certificate. If
+ * available, it loads the public/private sign key, which defaults to
+ * the host key, and leapseconds table. The host key must be RSA, but
+ * the sign key can be either RSA or DSA. In either case, the public key
+ * on the certificate must agree with the sign key.
+ */
+void
+crypto_setup(void)
+{
+       EVP_PKEY *pkey;         /* private/public key pair */
+       char    filename[MAXFILENAME]; /* file name buffer */
+       l_fp    seed;           /* crypto PRNG seed as NTP timestamp */
+       tstamp_t fstamp;        /* filestamp */
+       tstamp_t sstamp;        /* sign filestamp */
+       u_int   len, bytes;
+       u_char  *ptr;
+
+       /*
+        * Initialize structures.
+        */
+       if (!crypto_flags)
+               return;
+
+       gethostname(filename, MAXFILENAME);
+       bytes = strlen(filename) + 1;
+       sys_hostname = emalloc(bytes);
+       memcpy(sys_hostname, filename, bytes);
+       if (passwd == NULL)
+               passwd = sys_hostname;
+       memset(&hostval, 0, sizeof(hostval));
+       memset(&pubkey, 0, sizeof(pubkey));
+       memset(&tai_leap, 0, sizeof(tai_leap));
+
+       /*
+        * Load required random seed file and seed the random number
+        * generator. Be default, it is found in the user home
+        * directory. The root home directory may be / or /root,
+        * depending on the system. Wiggle the contents a bit and write
+        * it back so the sequence does not repeat when we next restart.
+        */
+       ERR_load_crypto_strings();
+       if (rand_file == NULL) {
+               if ((RAND_file_name(filename, MAXFILENAME)) != NULL) {
+                       rand_file = emalloc(strlen(filename) + 1);
+                       strcpy(rand_file, filename);
+               }
+       } else if (*rand_file != '/') {
+               snprintf(filename, MAXFILENAME, "%s/%s", keysdir,
+                   rand_file);
+               free(rand_file);
+               rand_file = emalloc(strlen(filename) + 1);
+               strcpy(rand_file, filename);
+       }
+       if (rand_file == NULL) {
+               msyslog(LOG_ERR,
+                   "crypto_setup: random seed file not specified");
+               exit (-1);
+       }
+       if ((bytes = RAND_load_file(rand_file, -1)) == 0) {
+               msyslog(LOG_ERR,
+                   "crypto_setup: random seed file %s not found\n",
+                   rand_file);
+               exit (-1);
+       }
+       get_systime(&seed);
+       RAND_seed(&seed, sizeof(l_fp));
+       RAND_write_file(rand_file);
+       OpenSSL_add_all_algorithms();
+#ifdef DEBUG
+       if (debug)
+               printf(
+                   "crypto_setup: OpenSSL version %lx random seed file %s bytes read %d\n",
+                   SSLeay(), rand_file, bytes);
+#endif
+
+       /*
+        * Load required host key from file "ntpkey_host_<hostname>". It
+        * also becomes the default sign key.
+        */
+       if (host_file == NULL) {
+               snprintf(filename, MAXFILENAME, "ntpkey_host_%s",
+                   sys_hostname);
+               host_file = emalloc(strlen(filename) + 1);
+               strcpy(host_file, filename);
+       }
+       pkey = crypto_key(host_file, &fstamp);
+       if (pkey == NULL) {
+               msyslog(LOG_ERR,
+                   "crypto_setup: host key file %s not found or corrupt",
+                   host_file);
+               exit (-1);
+       }
+       host_pkey = pkey;
+       sign_pkey = pkey;
+       sstamp = fstamp;
+       hostval.fstamp = htonl(fstamp);
+       if (host_pkey->type != EVP_PKEY_RSA) {
+               msyslog(LOG_ERR,
+                   "crypto_setup: host key is not RSA key type");
+               exit (-1);
+       }
+       hostval.vallen = htonl(strlen(sys_hostname));
+       hostval.ptr = (u_char *)sys_hostname;
+       
+       /*
+        * Construct public key extension field for agreement scheme.
+        */
+       len = i2d_PublicKey(host_pkey, NULL);
+       ptr = emalloc(len);
+       pubkey.ptr = ptr;
+       i2d_PublicKey(host_pkey, &ptr);
+       pubkey.vallen = htonl(len);
+       pubkey.fstamp = hostval.fstamp;
+
+       /*
+        * Load optional sign key from file "ntpkey_sign_<hostname>". If
+        * loaded, it becomes the sign key.
+        */
+       if (sign_file == NULL) {
+               snprintf(filename, MAXFILENAME, "ntpkey_sign_%s",
+                   sys_hostname);
+               sign_file = emalloc(strlen(filename) + 1);
+               strcpy(sign_file, filename);
+       }
+       pkey = crypto_key(sign_file, &fstamp);
+       if (pkey != NULL) {
+               sign_pkey = pkey;
+               sstamp = fstamp;
+       }
+       sign_siglen = EVP_PKEY_size(sign_pkey);
+
+       /*
+        * Load optional IFF parameters from file
+        * "ntpkey_iff_<hostname>".
+        */
+       if (iffpar_file == NULL) {
+               snprintf(filename, MAXFILENAME, "ntpkey_iff_%s",
+                   sys_hostname);
+               iffpar_file = emalloc(strlen(filename) + 1);
+               strcpy(iffpar_file, filename);
+       }
+       iffpar_pkey = crypto_key(iffpar_file, &if_fstamp);
+       if (iffpar_pkey != NULL)
+               crypto_flags |= CRYPTO_FLAG_IFF;
+
+       /*
+        * Load optional GQ parameters from file "ntpkey_gq_<hostname>".
+        */
+       if (gqpar_file == NULL) {
+               snprintf(filename, MAXFILENAME, "ntpkey_gq_%s",
+                   sys_hostname);
+               gqpar_file = emalloc(strlen(filename) + 1);
+               strcpy(gqpar_file, filename);
+       }
+       gqpar_pkey = crypto_key(gqpar_file, &gq_fstamp);
+       if (gqpar_pkey != NULL)
+               crypto_flags |= CRYPTO_FLAG_GQ;
+
+       /*
+        * Load optional MV parameters from file "ntpkey_mv_<hostname>".
+        */
+       if (mvpar_file == NULL) {
+               snprintf(filename, MAXFILENAME, "ntpkey_mv_%s",
+                   sys_hostname);
+               mvpar_file = emalloc(strlen(filename) + 1);
+               strcpy(mvpar_file, filename);
+       }
+       mvpar_pkey = crypto_key(mvpar_file, &mv_fstamp);
+       if (mvpar_pkey != NULL)
+               crypto_flags |= CRYPTO_FLAG_MV;
+
+       /*
+        * Load required certificate from file "ntpkey_cert_<hostname>".
+        */
+       if (cert_file == NULL) {
+               snprintf(filename, MAXFILENAME, "ntpkey_cert_%s",
+                   sys_hostname);
+               cert_file = emalloc(strlen(filename) + 1);
+               strcpy(cert_file, filename);
+       }
+       if ((cinfo = crypto_cert(cert_file)) == NULL) {
+               msyslog(LOG_ERR,
+                   "certificate file %s not found or corrupt",
+                   cert_file);
+               exit (-1);
+       }
+
+       /*
+        * The subject name must be the same as the host name, unless
+        * the certificate is private, in which case it may have come
+        * from another host.
+        */
+       if (!(cinfo->flags & CERT_PRIV) && strcmp(cinfo->subject,
+           sys_hostname) != 0) {
+               msyslog(LOG_ERR,
+                   "crypto_setup: certificate %s not for this host",
+                   cert_file);
+               cert_free(cinfo);
+               exit (-1);
+       }
+
+       /*
+        * It the certificate is trusted, the subject must be the same
+        * as the issuer, in other words it must be self signed.
+        */
+       if (cinfo->flags & CERT_TRUST && strcmp(cinfo->subject,
+           cinfo->issuer) != 0) {
+               if (cert_valid(cinfo, sign_pkey) != XEVNT_OK) {
+                       msyslog(LOG_ERR,
+                           "crypto_setup: certificate %s is trusted, but not self signed.",
+                           cert_file);
+                       cert_free(cinfo);
+                       exit (-1);
+               }
+       }
+       sign_digest = cinfo->digest;
+       if (cinfo->flags & CERT_PRIV)
+               crypto_flags |= CRYPTO_FLAG_PRIV;
+       crypto_flags |= cinfo->nid << 16;
+
+       /*
+        * Load optional leapseconds table from file "ntpkey_leap". If
+        * the file is missing or defective, the values can later be
+        * retrieved from a server.
+        */
+       if (leap_file == NULL)
+               leap_file = "ntpkey_leap";
+       crypto_tai(leap_file);
+#ifdef DEBUG
+       if (debug)
+               printf(
+                   "crypto_setup: flags 0x%x host %s signature %s\n",
+                   crypto_flags, sys_hostname, OBJ_nid2ln(cinfo->nid));
+#endif
+}
+
+
+/*
+ * crypto_config - configure data from crypto configuration command.
+ */
+void
+crypto_config(
+       int     item,           /* configuration item */
+       char    *cp             /* file name */
+       )
+{
+       switch (item) {
+
+       /*
+        * Set random seed file name.
+        */
+       case CRYPTO_CONF_RAND:
+               rand_file = emalloc(strlen(cp) + 1);
+               strcpy(rand_file, cp);
+               break;
+
+       /*
+        * Set private key password.
+        */
+       case CRYPTO_CONF_PW:
+               passwd = emalloc(strlen(cp) + 1);
+               strcpy(passwd, cp);
+               break;
+
+       /*
+        * Set host file name.
+        */
+       case CRYPTO_CONF_PRIV:
+               host_file = emalloc(strlen(cp) + 1);
+               strcpy(host_file, cp);
+               break;
+
+       /*
+        * Set sign key file name.
+        */
+       case CRYPTO_CONF_SIGN:
+               sign_file = emalloc(strlen(cp) + 1);
+               strcpy(sign_file, cp);
+               break;
+
+       /*
+        * Set iff parameters file name.
+        */
+       case CRYPTO_CONF_IFFPAR:
+               iffpar_file = emalloc(strlen(cp) + 1);
+               strcpy(iffpar_file, cp);
+               break;
+
+       /*
+        * Set gq parameters file name.
+        */
+       case CRYPTO_CONF_GQPAR:
+               gqpar_file = emalloc(strlen(cp) + 1);
+               strcpy(gqpar_file, cp);
+               break;
+
+       /*
+        * Set mv parameters file name.
+        */
+       case CRYPTO_CONF_MVPAR:
+               mvpar_file = emalloc(strlen(cp) + 1);
+               strcpy(mvpar_file, cp);
+               break;
+
+       /*
+        * Set identity scheme.
+        */
+       case CRYPTO_CONF_IDENT:
+               if (!strcasecmp(cp, "iff"))
+                       ident_scheme |= CRYPTO_FLAG_IFF;
+               else if (!strcasecmp(cp, "gq"))
+                       ident_scheme |= CRYPTO_FLAG_GQ;
+               else if (!strcasecmp(cp, "mv"))
+                       ident_scheme |= CRYPTO_FLAG_MV;
+               break;
+
+       /*
+        * Set certificate file name.
+        */
+       case CRYPTO_CONF_CERT:
+               cert_file = emalloc(strlen(cp) + 1);
+               strcpy(cert_file, cp);
+               break;
+
+       /*
+        * Set leapseconds file name.
+        */
+       case CRYPTO_CONF_LEAP:
+               leap_file = emalloc(strlen(cp) + 1);
+               strcpy(leap_file, cp);
+               break;
+       }
+       crypto_flags |= CRYPTO_FLAG_ENAB;
+}
+# else
+int ntp_crypto_bs_pubkey;
+# endif /* OPENSSL */
diff --git a/ntpd/ntp_filegen.c b/ntpd/ntp_filegen.c
new file mode 100644 (file)
index 0000000..932d1b6
--- /dev/null
@@ -0,0 +1,576 @@
+/*
+ * ntp_filegen.c,v 3.12 1994/01/25 19:06:11 kardel Exp
+ *
+ *  implements file generations support for NTP
+ *  logfiles and statistic files
+ *
+ *
+ * Copyright (C) 1992, 1996 by Rainer Pruy
+ * Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * This code may be modified and used freely
+ * provided credits remain intact.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_string.h"
+#include "ntp_calendar.h"
+#include "ntp_filegen.h"
+#include "ntp_stdlib.h"
+
+/*
+ * NTP is intended to run long periods of time without restart.
+ * Thus log and statistic files generated by NTP will grow large.
+ *
+ * this set of routines provides a central interface 
+ * to generating files using file generations
+ *
+ * the generation of a file is changed according to file generation type
+ */
+
+
+/*
+ * redefine this if your system dislikes filename suffixes like
+ * X.19910101 or X.1992W50 or ....
+ */
+#define SUFFIX_SEP '.'
+
+/*
+ * other constants
+ */
+#define FGEN_AGE_SECS   (24*60*60) /* life time of FILEGEN_AGE in seconds */
+
+static void    filegen_open    P((FILEGEN *, u_long));
+static int     valid_fileref   P((char *, char *));
+#ifdef UNUSED
+static FILEGEN *filegen_unregister P((char *));
+#endif /* UNUSED */
+
+static void    filegen_init    P((char *, const char *, FILEGEN *));
+
+/*
+ * filegen_init
+ */
+
+static void
+filegen_init(char *prefix, const char *basename, FILEGEN *fp)
+{
+       fp->fp       = NULL;
+       fp->prefix   = prefix;          /* Yes, this is TOTALLY lame! */
+       fp->basename = (char*)emalloc(strlen(basename) + 1);
+       strcpy(fp->basename, basename);
+       fp->id       = 0;
+       fp->type     = FILEGEN_DAY;
+       fp->flag     = FGEN_FLAG_LINK; /* not yet enabled !!*/
+}
+
+
+/*
+ * open a file generation according to the current settings of gen
+ * will also provide a link to basename if requested to do so
+ */
+
+static void
+filegen_open(
+       FILEGEN *gen,
+       u_long  newid
+       )
+{
+       char *filename;
+       char *basename;
+       u_int len;
+       FILE *fp;
+       struct calendar cal;
+
+       len = strlen(gen->prefix) + strlen(gen->basename) + 1;
+       basename = (char*)emalloc(len);
+       sprintf(basename, "%s%s", gen->prefix, gen->basename);
+  
+       switch(gen->type) {
+           default:
+               msyslog(LOG_ERR, "unsupported file generations type %d for \"%s\" - reverting to FILEGEN_NONE",
+                       gen->type, basename);
+               gen->type = FILEGEN_NONE;
+      
+               /*FALLTHROUGH*/
+           case FILEGEN_NONE:
+               filename = (char*)emalloc(len);
+               sprintf(filename,"%s", basename);
+               break;
+
+           case FILEGEN_PID:
+               filename = (char*)emalloc(len + 1 + 1 + 10);
+               sprintf(filename,"%s%c#%ld", basename, SUFFIX_SEP, newid);
+               break;
+      
+           case FILEGEN_DAY:
+               /* You can argue here in favor of using MJD, but
+                * I would assume it to be easier for humans to interpret dates
+                * in a format they are used to in everyday life.
+                */
+               caljulian(newid,&cal);
+               filename = (char*)emalloc(len + 1 + 4 + 2 + 2);
+               sprintf(filename, "%s%c%04d%02d%02d",
+                       basename, SUFFIX_SEP, cal.year, cal.month, cal.monthday);
+               break;
+      
+           case FILEGEN_WEEK:
+               /*
+                * This is still a hack
+                * - the term week is not correlated to week as it is used
+                *   normally - it just refers to a period of 7 days
+                *   starting at Jan 1 - 'weeks' are counted starting from zero
+                */
+               caljulian(newid,&cal);
+               filename = (char*)emalloc(len + 1 + 4 + 1 + 2);
+               sprintf(filename, "%s%c%04dw%02d",
+                       basename, SUFFIX_SEP, cal.year, cal.yearday / 7);
+               break;
+
+           case FILEGEN_MONTH:
+               caljulian(newid,&cal);
+               filename = (char*)emalloc(len + 1 + 4 + 2);
+               sprintf(filename, "%s%c%04d%02d",
+                       basename, SUFFIX_SEP, cal.year, cal.month);
+               break;
+
+           case FILEGEN_YEAR:
+               caljulian(newid,&cal);
+               filename = (char*)emalloc(len + 1 + 4);
+               sprintf(filename, "%s%c%04d", basename, SUFFIX_SEP, cal.year);
+               break;
+
+           case FILEGEN_AGE:
+               filename = (char*)emalloc(len + 1 + 2 + 10);
+               sprintf(filename, "%s%ca%08ld", basename, SUFFIX_SEP, newid);
+               break;
+       }
+  
+       if (gen->type != FILEGEN_NONE) {
+               /*
+                * check for existence of a file with name 'basename'
+                * as we disallow such a file
+                * if FGEN_FLAG_LINK is set create a link
+                */
+               struct stat stats;
+               /*
+                * try to resolve name collisions
+                */
+               static u_long conflicts = 0;
+
+#ifndef        S_ISREG
+#define        S_ISREG(mode)   (((mode) & S_IFREG) == S_IFREG)
+#endif
+               if (stat(basename, &stats) == 0) {
+                       /* Hm, file exists... */
+                       if (S_ISREG(stats.st_mode)) {
+                               if (stats.st_nlink <= 1)        {
+                                       /*
+                                        * Oh, it is not linked - try to save it
+                                        */
+                                       char *savename = (char*)emalloc(len + 1 + 1 + 10 + 10);
+                                       sprintf(savename, "%s%c%dC%lu",
+                                               basename,
+                                               SUFFIX_SEP,
+                                               (int) getpid(),
+                                               (u_long)conflicts++);
+                                       if (rename(basename, savename) != 0)
+                                           msyslog(LOG_ERR," couldn't save %s: %m", basename);
+                                       free(savename);
+                               } else {
+                                       /*
+                                        * there is at least a second link to
+                                        * this file.
+                                        * just remove the conflicting one
+                                        */
+                                       if (
+#if !defined(VMS)
+                                               unlink(basename) != 0
+#else
+                                               delete(basename) != 0
+#endif
+                                               )
+                                           msyslog(LOG_ERR, "couldn't unlink %s: %m", basename);
+                               }
+                       } else {
+                               /*
+                                * Ehh? Not a regular file ?? strange !!!!
+                                */
+                               msyslog(LOG_ERR, "expected regular file for %s (found mode 0%lo)",
+                                       basename, (unsigned long)stats.st_mode);
+                       }
+               } else {
+                       /*
+                        * stat(..) failed, but it is absolutely correct for
+                        * 'basename' not to exist
+                        */
+                       if (errno != ENOENT)
+                           msyslog(LOG_ERR,"stat(%s) failed: %m", basename);
+               }
+       }
+
+       /*
+        * now, try to open new file generation...
+        */
+       fp = fopen(filename, "a");
+  
+#ifdef DEBUG
+       if (debug > 3)
+           printf("opening filegen (type=%d/id=%lu) \"%s\"\n",
+                  gen->type, (u_long)newid, filename);
+#endif
+
+       if (fp == NULL) {
+               /* open failed -- keep previous state
+                *
+                * If the file was open before keep the previous generation.
+                * This will cause output to end up in the 'wrong' file,
+                * but I think this is still better than losing output
+                *
+                * ignore errors due to missing directories
+                */
+
+               if (errno != ENOENT)
+                   msyslog(LOG_ERR, "can't open %s: %m", filename);
+       } else {
+               if (gen->fp != NULL) {
+                       fclose(gen->fp);
+               }
+               gen->fp = fp;
+               gen->id = newid;
+
+               if (gen->flag & FGEN_FLAG_LINK) {
+                       /*
+                        * need to link file to basename
+                        * have to use hardlink for now as I want to allow
+                        * gen->basename spanning directory levels
+                        * this would make it more complex to get the correct
+                        * filename for symlink
+                        *
+                        * Ok, it would just mean taking the part following
+                        * the last '/' in the name.... Should add it later....
+                        */
+
+                       /* Windows NT does not support file links -Greg Schueman 1/18/97 */
+
+#if defined SYS_WINNT || defined SYS_VXWORKS
+                       SetLastError(0); /* On WinNT, don't support FGEN_FLAG_LINK */
+#elif defined(VMS)
+                       errno = 0; /* On VMS, don't support FGEN_FLAG_LINK */
+#else  /* not (VMS) / VXWORKS / WINNT ; DO THE LINK) */
+                       if (link(filename, basename) != 0)
+                           if (errno != EEXIST)
+                               msyslog(LOG_ERR, "can't link(%s, %s): %m", filename, basename);
+#endif /* SYS_WINNT || VXWORKS */
+               }               /* flags & FGEN_FLAG_LINK */
+       }                       /* else fp == NULL */
+       
+       free(basename);
+       free(filename);
+       return;
+}
+
+/*
+ * this function sets up gen->fp to point to the correct
+ * generation of the file for the time specified by 'now'
+ *
+ * 'now' usually is interpreted as second part of a l_fp as is in the cal...
+ * library routines
+ */
+
+void
+filegen_setup(
+       FILEGEN *gen,
+       u_long   now
+       )
+{
+       u_long new_gen = ~ (u_long) 0;
+       struct calendar cal;
+
+       if (!(gen->flag & FGEN_FLAG_ENABLED)) {
+               if (gen->fp != NULL)
+                   fclose(gen->fp);
+               return;
+       }
+       
+       switch (gen->type) {
+           case FILEGEN_NONE:
+               if (gen->fp != NULL) return; /* file already open */
+               break;
+      
+           case FILEGEN_PID:
+               new_gen = getpid();
+               break;
+
+           case FILEGEN_DAY:
+               caljulian(now, &cal);
+               cal.hour = cal.minute = cal.second = 0;
+               new_gen = caltontp(&cal);
+               break;
+      
+           case FILEGEN_WEEK:
+               /* Would be nice to have a calweekstart() routine */
+               /* so just use a hack ... */
+               /* just round time to integral 7 day period for actual year  */
+               new_gen = now - (now - calyearstart(now)) % TIMES7(SECSPERDAY)
+                       + 60;
+               /*
+                * just to be sure -
+                * the computation above would fail in the presence of leap seconds
+                * so at least carry the date to the next day (+60 (seconds))
+                * and go back to the start of the day via calendar computations
+                */
+               caljulian(new_gen, &cal);
+               cal.hour = cal.minute = cal.second = 0;
+               new_gen = caltontp(&cal);
+               break;
+      
+           case FILEGEN_MONTH:
+               caljulian(now, &cal);
+               cal.yearday = (u_short) (cal.yearday - cal.monthday + 1);
+               cal.monthday = 1;
+               cal.hour = cal.minute = cal.second = 0;
+               new_gen = caltontp(&cal);
+               break;
+      
+           case FILEGEN_YEAR:
+               new_gen = calyearstart(now);
+               break;
+
+           case FILEGEN_AGE:
+               new_gen = current_time  - (current_time % FGEN_AGE_SECS);
+               break;
+       }
+       /*
+        * try to open file if not yet open
+        * reopen new file generation file on change of generation id
+        */
+       if (gen->fp == NULL || gen->id != new_gen) {
+#if DEBUG
+       if (debug)
+               printf("filegen  %0x %lu %lu %lu\n", gen->type, now,
+                   gen->id, new_gen); 
+#endif
+               filegen_open(gen, new_gen);
+       }
+}
+
+
+/*
+ * change settings for filegen files
+ */
+void
+filegen_config(
+       FILEGEN *gen,
+       char    *basename,
+       u_int   type,
+       u_int   flag
+       )
+{
+       /*
+        * if nothing would be changed...
+        */
+       if ((basename == gen->basename || strcmp(basename,gen->basename) == 0) &&
+           type == gen->type &&
+           flag == gen->flag)
+           return;
+  
+       /*
+        * validate parameters
+        */
+       if (!valid_fileref(gen->prefix,basename))
+           return;
+  
+       if (gen->fp != NULL)
+           fclose(gen->fp);
+
+#ifdef DEBUG
+       if (debug > 2)
+           printf("configuring filegen:\n\tprefix:\t%s\n\tbasename:\t%s -> %s\n\ttype:\t%d -> %d\n\tflag: %x -> %x\n",
+                  gen->prefix, gen->basename, basename, gen->type, type, gen->flag, flag);
+#endif
+       if (gen->basename != basename || strcmp(gen->basename, basename) != 0) {
+               free(gen->basename);
+               gen->basename = (char*)emalloc(strlen(basename) + 1);
+               strcpy(gen->basename, basename);
+       }
+       gen->type = (u_char) type;
+       gen->flag = (u_char) flag;
+
+       /*
+        * make filegen use the new settings
+        * special action is only required when a generation file
+        * is currently open
+        * otherwise the new settings will be used anyway at the next open
+        */
+       if (gen->fp != NULL) {
+               l_fp now;
+
+               get_systime(&now);
+               filegen_setup(gen, now.l_ui);
+       }
+}
+
+
+/*
+ * check whether concatenating prefix and basename
+ * yields a legal filename
+ */
+static int
+valid_fileref(
+       char *prefix,
+       char *basename
+       )
+{
+       /*
+        * prefix cannot be changed dynamically
+        * (within the context of filegen)
+        * so just reject basenames containing '..'
+        *
+        * ASSUMPTION:
+        *              file system parts 'below' prefix may be
+        *              specified without infringement of security
+        *
+        *              restricing prefix to legal values
+        *              has to be ensured by other means
+        * (however, it would be possible to perform some checks here...)
+        */
+       register char *p = basename;
+  
+       /*
+        * Just to catch, dumb errors opening up the world...
+        */
+       if (prefix == NULL || *prefix == '\0')
+           return 0;
+
+       if (basename == NULL)
+           return 0;
+  
+       for (p = basename; p; p = strchr(p, '/')) {
+               if (*p == '.' && *(p+1) == '.' && (*(p+2) == '\0' || *(p+2) == '/'))
+                   return 0;
+       }
+  
+       return 1;
+}
+
+
+/*
+ * filegen registry
+ */
+
+static struct filegen_entry {
+       char *name;
+       FILEGEN *filegen;
+       struct filegen_entry *next;
+} *filegen_registry = NULL;
+
+
+FILEGEN *
+filegen_get(
+       char *name
+       )
+{
+       struct filegen_entry *f = filegen_registry;
+
+       while(f) {
+               if (f->name == name || strcmp(name, f->name) == 0) {
+#ifdef XXX     /* this gives the Alpha compiler fits */
+                       if (debug > 3)
+                           printf("filegen_get(\"%s\") = %x\n", name,
+                                  (u_int)f->filegen);
+#endif
+                       return f->filegen;
+               }
+               f = f->next;
+       }
+#ifdef DEBUG
+       if (debug > 3)
+           printf("filegen_get(\"%s\") = NULL\n", name);
+#endif
+       return NULL;
+}
+
+void
+filegen_register(
+       char *prefix,
+       const char *name,
+       FILEGEN *filegen
+       )
+{
+       struct filegen_entry **f = &filegen_registry;
+
+#ifdef XXX             /* this gives the Alpha compiler fits */
+       if (debug > 3)
+           printf("filegen_register(\"%s\",%x)\n", name, (u_int)filegen);
+#endif
+
+       filegen_init(prefix, name, filegen);
+
+       while (*f) {
+               if ((*f)->name == name || strcmp(name, (*f)->name) == 0) {
+#ifdef XXX      /* this gives the Alpha compiler fits */
+                       if (debug > 4) {
+                               printf("replacing filegen %x\n", (u_int)(*f)->filegen);
+                       }
+#endif
+                       (*f)->filegen = filegen;
+                       return;
+               }
+               f = &((*f)->next);
+       }
+
+       *f = (struct filegen_entry *) emalloc(sizeof(struct filegen_entry));
+       if (*f) {
+               (*f)->next = NULL;
+               (*f)->name = (char*)emalloc(strlen(name) + 1);
+               strcpy((*f)->name, name);
+               (*f)->filegen = filegen;
+#ifdef DEBUG
+               if (debug > 5) {
+                       printf("adding new filegen\n");
+               }
+#endif
+       }
+       
+       return;
+}
+
+#ifdef UNUSED
+static FILEGEN *
+filegen_unregister(
+       char *name
+       )
+{
+       struct filegen_entry **f = &filegen_registry;
+  
+#ifdef DEBUG
+       if (debug > 3)
+           printf("filegen_unregister(\"%s\")\n", name);
+#endif
+
+       while (*f) {
+               if (strcmp((*f)->name,name) == 0) {
+                       struct filegen_entry *ff = *f;
+                       FILEGEN *fg;
+                       
+                       *f = (*f)->next;
+                       fg = ff->filegen;
+                       free(ff->name);
+                       free(ff);
+                       return fg;
+               }
+               f = &((*f)->next);
+       }
+       return NULL;
+}      
+#endif /* UNUSED */
diff --git a/ntpd/ntp_intres.c b/ntpd/ntp_intres.c
new file mode 100644 (file)
index 0000000..5facc85
--- /dev/null
@@ -0,0 +1,1170 @@
+/*
+ * ripped off from ../ntpres/ntpres.c by Greg Troxel 4/2/92
+ * routine callable from ntpd, rather than separate program
+ * also, key info passed in via a global, so no key file needed.
+ */
+
+/*
+ * ntpres - process configuration entries which require use of the resolver
+ *
+ * This is meant to be run by ntpd on the fly.  It is not guaranteed
+ * to work properly if run by hand.  This is actually a quick hack to
+ * stave off violence from people who hate using numbers in the
+ * configuration file (at least I hope the rest of the daemon is
+ * better than this).  Also might provide some ideas about how one
+ * might go about autoconfiguring an NTP distribution network.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntp_machine.h"
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_request.h"
+#include "ntp_stdlib.h"
+#include "ntp_syslog.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+
+/**/
+#include <netinet/in.h>
+#include <arpa/inet.h>
+/**/
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>                /* MAXHOSTNAMELEN (often) */
+#endif
+
+#include <isc/net.h>
+#include <isc/result.h>
+
+#define        STREQ(a, b)     (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+/*
+ * Each item we are to resolve and configure gets one of these
+ * structures defined for it.
+ */
+struct conf_entry {
+       struct conf_entry *ce_next;
+       char *ce_name;                  /* name we are trying to resolve */
+       struct conf_peer ce_config;     /* configuration info for peer */
+       struct sockaddr_storage peer_store; /* address info for both fams */
+};
+#define        ce_peeraddr     ce_config.peeraddr
+#define        ce_peeraddr6    ce_config.peeraddr6
+#define        ce_hmode        ce_config.hmode
+#define        ce_version      ce_config.version
+#define ce_minpoll     ce_config.minpoll
+#define ce_maxpoll     ce_config.maxpoll
+#define        ce_flags        ce_config.flags
+#define ce_ttl         ce_config.ttl
+#define        ce_keyid        ce_config.keyid
+#define ce_keystr      ce_config.keystr
+
+/*
+ * confentries is a pointer to the list of configuration entries
+ * we have left to do.
+ */
+static struct conf_entry *confentries = NULL;
+
+/*
+ * We take an interrupt every thirty seconds, at which time we decrement
+ * config_timer and resolve_timer.  The former is set to 2, so we retry
+ * unsucessful reconfigurations every minute.  The latter is set to
+ * an exponentially increasing value which starts at 2 and increases to
+ * 32.  When this expires we retry failed name resolutions.
+ *
+ * We sleep SLEEPTIME seconds before doing anything, to give the server
+ * time to arrange itself.
+ */
+#define        MINRESOLVE      2
+#define        MAXRESOLVE      32
+#define        CONFIG_TIME     2
+#define        ALARM_TIME      30
+#define        SLEEPTIME       2
+
+static volatile int config_timer = 0;
+static volatile int resolve_timer = 0;
+
+static int resolve_value;      /* next value of resolve timer */
+
+/*
+ * Big hack attack
+ */
+#define        LOCALHOST       0x7f000001      /* 127.0.0.1, in hex, of course */
+#define        SKEWTIME        0x08000000      /* 0.03125 seconds as a l_fp fraction */
+
+/*
+ * Select time out.  Set to 2 seconds.  The server is on the local machine,
+ * after all.
+ */
+#define        TIMEOUT_SEC     2
+#define        TIMEOUT_USEC    0
+
+
+/*
+ * Input processing.  The data on each line in the configuration file
+ * is supposed to consist of entries in the following order
+ */
+#define        TOK_HOSTNAME    0
+#define        TOK_HMODE       1
+#define        TOK_VERSION     2
+#define TOK_MINPOLL    3
+#define TOK_MAXPOLL    4
+#define        TOK_FLAGS       5
+#define TOK_TTL                6
+#define        TOK_KEYID       7
+#define TOK_KEYSTR     8
+#define        NUMTOK          9
+
+#define        MAXLINESIZE     512
+
+
+/*
+ * File descriptor for ntp request code.
+ */
+static SOCKET sockfd = INVALID_SOCKET; /* NT uses SOCKET */
+
+/* stuff to be filled in by caller */
+
+keyid_t req_keyid;     /* request keyid */
+char *req_file;                /* name of the file with configuration info */
+
+/* end stuff to be filled in */
+
+
+static void    checkparent     P((void));
+static void    removeentry     P((struct conf_entry *));
+static void    addentry        P((char *, int, int, int, int, u_int,
+                                  int, keyid_t, char *));
+static int     findhostaddr    P((struct conf_entry *));
+static void    openntp         P((void));
+static int     request         P((struct conf_peer *));
+static char *  nexttoken       P((char **));
+static void    readconf        P((FILE *, char *));
+static void    doconfigure     P((int));
+
+struct ntp_res_t_pkt {         /* Tagged packet: */
+       void *tag;              /* For the caller */
+       u_int32 paddr;          /* IP to look up, or 0 */
+       char name[MAXHOSTNAMELEN]; /* Name to look up (if 1st byte is not 0) */
+};
+
+struct ntp_res_c_pkt {         /* Control packet: */
+       char name[MAXHOSTNAMELEN];
+       u_int32 paddr;
+       int mode;
+       int version;
+       int minpoll;
+       int maxpoll;
+       u_int flags;
+       int ttl;
+       keyid_t keyid;
+       u_char keystr[MAXFILENAME];
+};
+
+
+static void    resolver_exit P((int));
+
+/*
+ * Call here instead of just exiting
+ */
+
+static void resolver_exit (int code)
+{
+#ifdef SYS_WINNT
+       CloseHandle(ResolverEventHandle);
+       ResolverEventHandle = NULL;
+       ExitThread(code);       /* Just to kill the thread not the process */
+#else
+       exit(code);             /* kill the forked process */
+#endif
+}
+
+/*
+ * ntp_res_recv: Process an answer from the resolver
+ */
+
+void
+ntp_res_recv(void)
+{
+       /*
+         We have data ready on our descriptor.
+         It may be an EOF, meaning the resolver process went away.
+         Otherwise, it will be an "answer".
+       */
+}
+
+
+/*
+ * ntp_intres needs;
+ *
+ *     req_key(???), req_keyid, req_file valid
+ *     syslog still open
+ */
+
+void
+ntp_intres(void)
+{
+       FILE *in;
+       struct timeval tv;
+       fd_set fdset;
+#ifdef SYS_WINNT
+       DWORD rc;
+#else
+       int rc;
+#endif
+
+#ifdef DEBUG
+       if (debug > 1) {
+               msyslog(LOG_INFO, "NTP_INTRES running");
+       }
+#endif
+
+       /* check out auth stuff */
+       if (sys_authenticate) {
+               if (!authistrusted(req_keyid)) {
+                       msyslog(LOG_ERR, "invalid request keyid %08x",
+                           req_keyid );
+                       resolver_exit(1);
+               }
+       }
+
+       /*
+        * Read the configuration info
+        * {this is bogus, since we are forked, but it is easier
+        * to keep this code - gdt}
+        */
+       if ((in = fopen(req_file, "r")) == NULL) {
+               msyslog(LOG_ERR, "can't open configuration file %s: %m",
+                       req_file);
+               resolver_exit(1);
+       }
+       readconf(in, req_file);
+       (void) fclose(in);
+
+#ifdef DEBUG
+       if (!debug )
+#endif
+               (void) unlink(req_file);
+
+       /*
+        * Set up the timers to do first shot immediately.
+        */
+       resolve_timer = 0;
+       resolve_value = MINRESOLVE;
+       config_timer = CONFIG_TIME;
+
+       for (;;) {
+               checkparent();
+
+               if (resolve_timer == 0) {
+                       /*
+                        * Sleep a little to make sure the network is completely up
+                        */
+                       sleep(SLEEPTIME);
+                       doconfigure(1);
+
+                       /* prepare retry, in case there's more work to do */
+                       resolve_timer = resolve_value;
+#ifdef DEBUG
+                       if (debug > 2)
+                               msyslog(LOG_INFO, "resolve_timer: 0->%d", resolve_timer);
+#endif
+                       if (resolve_value < MAXRESOLVE)
+                               resolve_value <<= 1;
+
+                       config_timer = CONFIG_TIME;
+               } else if (config_timer == 0) {  /* MB: in which case would this be required ? */
+                       doconfigure(0);
+                       /* MB: should we check now if we could exit, similar to the code above? */
+                       config_timer = CONFIG_TIME;
+#ifdef DEBUG
+                       if (debug > 2)
+                               msyslog(LOG_INFO, "config_timer: 0->%d", config_timer);
+#endif
+               }
+
+               if (confentries == NULL)
+                       resolver_exit(0);   /* done */
+
+#ifdef SYS_WINNT
+               rc = WaitForSingleObject(ResolverEventHandle, 1000 * ALARM_TIME);  /* in milliseconds */
+
+               if ( rc == WAIT_OBJECT_0 ) { /* signaled by the main thread */
+                       resolve_timer = 0;         /* retry resolving immediately */
+                       continue;
+               }
+
+               if ( rc != WAIT_TIMEOUT ) /* not timeout: error */
+                       resolver_exit(1);
+
+#else  /* not SYS_WINNT */
+               tv.tv_sec = ALARM_TIME;
+               tv.tv_usec = 0;
+               FD_ZERO(&fdset);
+               FD_SET(resolver_pipe_fd[0], &fdset);
+               rc = select(resolver_pipe_fd[0] + 1, &fdset, (fd_set *)0, (fd_set *)0, &tv);
+
+               if (rc > 0) {  /* parent process has written to the pipe */
+                       read(resolver_pipe_fd[0], (char *)&rc, sizeof(rc));  /* make pipe empty */
+                       resolve_timer = 0;   /* retry resolving immediately */
+                       continue;
+               }
+
+               if ( rc < 0 )  /* select() returned error */
+                       resolver_exit(1);
+#endif
+
+               /* normal timeout, keep on waiting */
+               if (config_timer > 0)
+                       config_timer--;
+               if (resolve_timer > 0)
+                       resolve_timer--;
+       }
+}
+
+
+
+/*
+ * checkparent - see if our parent process is still running
+ *
+ * No need to worry in the Windows NT environment whether the
+ * main thread is still running, because if it goes
+ * down it takes the whole process down with it (in
+ * which case we won't be running this thread either)
+ * Turn function into NOP;
+ */
+
+static void
+checkparent(void)
+{
+#if !defined (SYS_WINNT) && !defined (SYS_VXWORKS)
+
+       /*
+        * If our parent (the server) has died we will have been
+        * inherited by init.  If so, exit.
+        */
+       if (getppid() == 1) {
+               msyslog(LOG_INFO, "parent died before we finished, exiting");
+               resolver_exit(0);
+       }
+#endif /* SYS_WINNT && SYS_VXWORKS*/
+}
+
+
+
+/*
+ * removeentry - we are done with an entry, remove it from the list
+ */
+static void
+removeentry(
+       struct conf_entry *entry
+       )
+{
+       register struct conf_entry *ce;
+
+       ce = confentries;
+       if (ce == entry) {
+               confentries = ce->ce_next;
+               return;
+       }
+
+       while (ce != NULL) {
+               if (ce->ce_next == entry) {
+                       ce->ce_next = entry->ce_next;
+                       return;
+               }
+               ce = ce->ce_next;
+       }
+}
+
+
+/*
+ * addentry - add an entry to the configuration list
+ */
+static void
+addentry(
+       char *name,
+       int mode,
+       int version,
+       int minpoll,
+       int maxpoll,
+       u_int flags,
+       int ttl,
+       keyid_t keyid,
+       char *keystr
+       )
+{
+       register char *cp;
+       register struct conf_entry *ce;
+       unsigned int len;
+
+#ifdef DEBUG
+       if (debug > 1)
+               msyslog(LOG_INFO, 
+                   "intres: <%s> %d %d %d %d %x %d %x %s\n", name,
+                   mode, version, minpoll, maxpoll, flags, ttl, keyid,
+                   keystr);
+#endif
+       len = strlen(name) + 1;
+       cp = (char *)emalloc(len);
+       memmove(cp, name, len);
+
+       ce = (struct conf_entry *)emalloc(sizeof(struct conf_entry));
+       ce->ce_name = cp;
+       ce->ce_peeraddr = 0;
+#ifdef ISC_PLATFORM_HAVEIPV6
+       ce->ce_peeraddr6 = in6addr_any;
+#endif
+       ANYSOCK(&ce->peer_store);
+       ce->ce_hmode = (u_char)mode;
+       ce->ce_version = (u_char)version;
+       ce->ce_minpoll = (u_char)minpoll;
+       ce->ce_maxpoll = (u_char)maxpoll;
+       ce->ce_flags = (u_char)flags;
+       ce->ce_ttl = (u_char)ttl;
+       ce->ce_keyid = keyid;
+       strncpy((char *)ce->ce_keystr, keystr, MAXFILENAME);
+       ce->ce_next = NULL;
+
+       if (confentries == NULL) {
+               confentries = ce;
+       } else {
+               register struct conf_entry *cep;
+
+               for (cep = confentries; cep->ce_next != NULL;
+                    cep = cep->ce_next)
+                   /* nothing */;
+               cep->ce_next = ce;
+       }
+}
+
+
+/*
+ * findhostaddr - resolve a host name into an address (Or vice-versa)
+ *
+ * Given one of {ce_peeraddr,ce_name}, find the other one.
+ * It returns 1 for "success" and 0 for an uncorrectable failure.
+ * Note that "success" includes try again errors.  You can tell that you
+ *  got a "try again" since {ce_peeraddr,ce_name} will still be zero.
+ */
+static int
+findhostaddr(
+       struct conf_entry *entry
+       )
+{
+       static int eai_again_seen = 0;
+       struct addrinfo *addr;
+       struct addrinfo hints;
+       int again;
+       int error;
+
+       checkparent();          /* make sure our guy is still running */
+
+       if (entry->ce_name != NULL && !SOCKNUL(&entry->peer_store)) {
+               /* HMS: Squawk? */
+               msyslog(LOG_ERR, "findhostaddr: both ce_name and ce_peeraddr are defined...");
+               return 1;
+       }
+
+       if (entry->ce_name == NULL && SOCKNUL(&entry->peer_store)) {
+               msyslog(LOG_ERR, "findhostaddr: both ce_name and ce_peeraddr are undefined!");
+               return 0;
+       }
+
+       if (entry->ce_name) {
+               DPRINTF(2, ("findhostaddr: Resolving <%s>\n",
+                       entry->ce_name));
+
+               memset(&hints, 0, sizeof(hints));
+               hints.ai_family = AF_UNSPEC;
+               /*
+                * If the IPv6 stack is not available look only for IPv4 addresses
+                */
+               if (isc_net_probeipv6() != ISC_R_SUCCESS)
+                       hints.ai_family = AF_INET;
+
+               error = getaddrinfo(entry->ce_name, NULL, &hints, &addr);
+               if (error == 0) {
+                       entry->peer_store = *((struct sockaddr_storage*)(addr->ai_addr));
+                       if (entry->peer_store.ss_family == AF_INET) {
+                               entry->ce_peeraddr =
+                                   GET_INADDR(entry->peer_store);
+                               entry->ce_config.v6_flag = 0;
+                       } else {
+                               entry->ce_peeraddr6 =
+                                   GET_INADDR6(entry->peer_store);
+                               entry->ce_config.v6_flag = 1;
+                       }
+               }
+       } else {
+               DPRINTF(2, ("findhostaddr: Resolving <%s>\n",
+                       stoa(&entry->peer_store)));
+
+               entry->ce_name = emalloc(MAXHOSTNAMELEN);
+               error = getnameinfo((const struct sockaddr *)&entry->peer_store,
+                                  SOCKLEN(&entry->peer_store),
+                                  (char *)&entry->ce_name, MAXHOSTNAMELEN,
+                                  NULL, 0, 0);
+       }
+
+       if (0 == error) {
+
+               /* again is our return value, for success it is 1 */
+               again = 1;
+
+               DPRINTF(2, ("findhostaddr: %s resolved.\n", 
+                       (entry->ce_name) ? "name" : "address"));
+       } else {
+               /*
+                * If the resolver failed, see if the failure is
+                * temporary. If so, return success.
+                */
+               again = 0;
+
+               switch (error) {
+
+               case EAI_FAIL:
+                       again = 1;
+                       break;
+
+               case EAI_AGAIN:
+                       again = 1;
+                       eai_again_seen = 1;
+                       break;
+
+               case EAI_NONAME:
+#if defined(EAI_NODATA) && (EAI_NODATA != EAI_NONAME)
+               case EAI_NODATA:
+#endif
+                       msyslog(LOG_ERR, "host name not found%s%s: %s",
+                               (EAI_NONAME == error) ? "" : " EAI_NODATA",
+                               (eai_again_seen) ? " (permanent)" : "",
+                               entry->ce_name);
+                       again = !eai_again_seen;
+                       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;
+                       DPRINTF(1, ("intres: EAI_SYSTEM errno %d (%s) means try again, right?\n",
+                               errno, strerror(errno)));
+                       break;
+#endif
+               }
+
+               /* do this here to avoid perturbing errno earlier */
+               DPRINTF(2, ("intres: got error status of: %d\n", error));
+       }
+
+       return again;
+}
+
+
+/*
+ * openntp - open a socket to the ntp server
+ */
+static void
+openntp(void)
+{
+       const char      *localhost = "127.0.0.1";       /* Use IPv4 loopback */
+       struct addrinfo hints;
+       struct addrinfo *addr;
+       u_long          on;
+       int             err;
+
+       if (sockfd != INVALID_SOCKET)
+               return;
+
+       memset(&hints, 0, sizeof(hints));
+
+       /*
+        * For now only bother with IPv4
+        */
+       hints.ai_family = AF_INET;
+       hints.ai_socktype = SOCK_DGRAM;
+
+       err = getaddrinfo(localhost, "ntp", &hints, &addr);
+
+       if (err) {
+#ifdef EAI_SYSTEM
+               if (EAI_SYSTEM == err)
+                       msyslog(LOG_ERR, "getaddrinfo(%s) failed: %m",
+                               localhost);
+               else
+#endif
+                       msyslog(LOG_ERR, "getaddrinfo(%s) failed: %s",
+                               localhost, gai_strerror(err));
+               resolver_exit(1);
+       }
+
+       sockfd = socket(addr->ai_family, addr->ai_socktype, 0);
+
+       if (INVALID_SOCKET == sockfd) {
+               msyslog(LOG_ERR, "socket() failed: %m");
+               resolver_exit(1);
+       }
+
+#ifndef SYS_WINNT
+       /*
+        * On Windows only the count of sockets must be less than
+        * FD_SETSIZE. On Unix each descriptor's value must be less
+        * than FD_SETSIZE, as fd_set is a bit array.
+        */
+       if (sockfd >= FD_SETSIZE) {
+               msyslog(LOG_ERR, "socket fd %d too large, FD_SETSIZE %d",
+                       (int)sockfd, FD_SETSIZE);
+               resolver_exit(1);
+       }
+
+       /*
+        * Make the socket non-blocking.  We'll wait with select()
+        * Unix: fcntl(O_NONBLOCK) or fcntl(FNDELAY)
+        */
+# ifdef O_NONBLOCK
+       if (fcntl(sockfd, F_SETFL, O_NONBLOCK) == -1) {
+               msyslog(LOG_ERR, "fcntl(O_NONBLOCK) failed: %m");
+               resolver_exit(1);
+       }
+# else
+#  ifdef FNDELAY
+       if (fcntl(sockfd, F_SETFL, FNDELAY) == -1) {
+               msyslog(LOG_ERR, "fcntl(FNDELAY) failed: %m");
+               resolver_exit(1);
+       }
+#  else
+#   include "Bletch: NEED NON BLOCKING IO"
+#  endif       /* FNDDELAY */
+# endif        /* O_NONBLOCK */
+       (void)on;       /* quiet unused warning */
+#else  /* !SYS_WINNT above */
+       /*
+        * Make the socket non-blocking.  We'll wait with select()
+        * Windows: ioctlsocket(FIONBIO)
+        */
+       on = 1;
+       err = ioctlsocket(sockfd, FIONBIO, &on);
+       if (SOCKET_ERROR == err) {
+               msyslog(LOG_ERR, "ioctlsocket(FIONBIO) fails: %m");
+               resolver_exit(1);
+       }
+#endif /* SYS_WINNT */
+
+       err = connect(sockfd, addr->ai_addr, addr->ai_addrlen);
+       if (SOCKET_ERROR == err) {
+               msyslog(LOG_ERR, "openntp: connect() failed: %m");
+               resolver_exit(1);
+       }
+
+       freeaddrinfo(addr);
+}
+
+
+/*
+ * request - send a configuration request to the server, wait for a response
+ */
+static int
+request(
+       struct conf_peer *conf
+       )
+{
+       fd_set fdset;
+       struct timeval tvout;
+       struct req_pkt reqpkt;
+       l_fp ts;
+       int n;
+#ifdef SYS_WINNT
+       HANDLE hReadWriteEvent = NULL;
+       BOOL ret;
+       DWORD NumberOfBytesWritten, NumberOfBytesRead, dwWait;
+       OVERLAPPED overlap;
+#endif /* SYS_WINNT */
+
+       checkparent();          /* make sure our guy is still running */
+
+       if (sockfd == INVALID_SOCKET)
+               openntp();
+       
+#ifdef SYS_WINNT
+       hReadWriteEvent = CreateEvent(NULL, FALSE, FALSE, NULL);
+#endif /* SYS_WINNT */
+
+       /*
+        * Try to clear out any previously received traffic so it
+        * doesn't fool us.  Note the socket is nonblocking.
+        */
+       tvout.tv_sec =  0;
+       tvout.tv_usec = 0;
+       FD_ZERO(&fdset);
+       FD_SET(sockfd, &fdset);
+       while (select(sockfd + 1, &fdset, (fd_set *)0, (fd_set *)0, &tvout) >
+              0) {
+               recv(sockfd, (char *)&reqpkt, REQ_LEN_MAC, 0);
+               FD_ZERO(&fdset);
+               FD_SET(sockfd, &fdset);
+       }
+
+       /*
+        * Make up a request packet with the configuration info
+        */
+       memset((char *)&reqpkt, 0, sizeof(reqpkt));
+
+       reqpkt.rm_vn_mode = RM_VN_MODE(0, 0, 0);
+       reqpkt.auth_seq = AUTH_SEQ(1, 0);       /* authenticated, no seq */
+       reqpkt.implementation = IMPL_XNTPD;     /* local implementation */
+       reqpkt.request = REQ_CONFIG;            /* configure a new peer */
+       reqpkt.err_nitems = ERR_NITEMS(0, 1);   /* one item */
+       reqpkt.mbz_itemsize = MBZ_ITEMSIZE(sizeof(struct conf_peer));
+       /* Make sure mbz_itemsize <= sizeof reqpkt.data */
+       if (sizeof(struct conf_peer) > sizeof (reqpkt.data)) {
+               msyslog(LOG_ERR, "Bletch: conf_peer is too big for reqpkt.data!");
+               resolver_exit(1);
+       }
+       memmove(reqpkt.data, (char *)conf, sizeof(struct conf_peer));
+       reqpkt.keyid = htonl(req_keyid);
+
+       get_systime(&ts);
+       L_ADDUF(&ts, SKEWTIME);
+       HTONL_FP(&ts, &reqpkt.tstamp);
+       n = 0;
+       if (sys_authenticate)
+               n = authencrypt(req_keyid, (u_int32 *)&reqpkt, REQ_LEN_NOMAC);
+
+       /*
+        * Done.  Send it.
+        */
+#ifndef SYS_WINNT
+       n = send(sockfd, (char *)&reqpkt, (unsigned)(REQ_LEN_NOMAC + n), 0);
+       if (n < 0) {
+               msyslog(LOG_ERR, "send to NTP server failed: %m");
+               return 0;       /* maybe should exit */
+       }
+#else
+       /* In the NT world, documentation seems to indicate that there
+        * exist _write and _read routines that can be used to do blocking
+        * I/O on sockets. Problem is these routines require a socket
+        * handle obtained through the _open_osf_handle C run-time API
+        * of which there is no explanation in the documentation. We need
+        * nonblocking write's and read's anyway for our purpose here.
+        * We're therefore forced to deviate a little bit from the Unix
+        * model here and use the ReadFile and WriteFile Win32 I/O API's
+        * on the socket
+        */
+       overlap.Offset = overlap.OffsetHigh = (DWORD)0;
+       overlap.hEvent = hReadWriteEvent;
+       ret = WriteFile((HANDLE)sockfd, (char *)&reqpkt, REQ_LEN_NOMAC + n,
+                       NULL, (LPOVERLAPPED)&overlap);
+       if ((ret == FALSE) && (GetLastError() != ERROR_IO_PENDING)) {
+               msyslog(LOG_ERR, "send to NTP server failed: %m");
+               return 0;
+       }
+       dwWait = WaitForSingleObject(hReadWriteEvent, (DWORD) TIMEOUT_SEC * 1000);
+       if ((dwWait == WAIT_FAILED) || (dwWait == WAIT_TIMEOUT)) {
+               if (dwWait == WAIT_FAILED)
+                   msyslog(LOG_ERR, "WaitForSingleObject failed: %m");
+               return 0;
+       }
+       if (!GetOverlappedResult((HANDLE)sockfd, (LPOVERLAPPED)&overlap,
+                               (LPDWORD)&NumberOfBytesWritten, FALSE)) {
+               msyslog(LOG_ERR, "GetOverlappedResult for WriteFile fails: %m");
+               return 0;
+       }
+#endif /* SYS_WINNT */
+    
+
+       /*
+        * Wait for a response.  A weakness of the mode 7 protocol used
+        * is that there is no way to associate a response with a
+        * particular request, i.e. the response to this configuration
+        * request is indistinguishable from that to any other.  I should
+        * fix this some day.  In any event, the time out is fairly
+        * pessimistic to make sure that if an answer is coming back
+        * at all, we get it.
+        */
+       for (;;) {
+               FD_ZERO(&fdset);
+               FD_SET(sockfd, &fdset);
+               tvout.tv_sec = TIMEOUT_SEC;
+               tvout.tv_usec = TIMEOUT_USEC;
+
+               n = select(sockfd + 1, &fdset, (fd_set *)0,
+                          (fd_set *)0, &tvout);
+
+               if (n < 0)
+               {
+                       if (errno != EINTR)
+                           msyslog(LOG_ERR, "select() fails: %m");
+                       return 0;
+               }
+               else if (n == 0)
+               {
+#ifdef DEBUG
+                       if (debug)
+                           msyslog(LOG_INFO, "select() returned 0.");
+#endif
+                       return 0;
+               }
+
+#ifndef SYS_WINNT
+               n = recv(sockfd, (char *)&reqpkt, REQ_LEN_MAC, 0);
+               if (n <= 0) {
+                       if (n < 0) {
+                               msyslog(LOG_ERR, "recv() fails: %m");
+                               return 0;
+                       }
+                       continue;
+               }
+#else /* Overlapped I/O used on non-blocking sockets on Windows NT */
+               ret = ReadFile((HANDLE)sockfd, (char *)&reqpkt, (DWORD)REQ_LEN_MAC,
+                              NULL, (LPOVERLAPPED)&overlap);
+               if ((ret == FALSE) && (GetLastError() != ERROR_IO_PENDING)) {
+                       msyslog(LOG_ERR, "ReadFile() fails: %m");
+                       return 0;
+               }
+               dwWait = WaitForSingleObject(hReadWriteEvent, (DWORD) TIMEOUT_SEC * 1000);
+               if ((dwWait == WAIT_FAILED) || (dwWait == WAIT_TIMEOUT)) {
+                       if (dwWait == WAIT_FAILED) {
+                               msyslog(LOG_ERR, "WaitForSingleObject for ReadFile fails: %m");
+                               return 0;
+                       }
+                       continue;
+               }
+               if (!GetOverlappedResult((HANDLE)sockfd, (LPOVERLAPPED)&overlap,
+                                       (LPDWORD)&NumberOfBytesRead, FALSE)) {
+                       msyslog(LOG_ERR, "GetOverlappedResult fails: %m");
+                       return 0;
+               }
+               n = NumberOfBytesRead;
+#endif /* SYS_WINNT */
+
+               /*
+                * Got one.  Check through to make sure it is what
+                * we expect.
+                */
+               if (n < RESP_HEADER_SIZE) {
+                       msyslog(LOG_ERR, "received runt response (%d octets)",
+                               n);
+                       continue;
+               }
+
+               if (!ISRESPONSE(reqpkt.rm_vn_mode)) {
+#ifdef DEBUG
+                       if (debug > 1)
+                           msyslog(LOG_INFO, "received non-response packet");
+#endif
+                       continue;
+               }
+
+               if (ISMORE(reqpkt.rm_vn_mode)) {
+#ifdef DEBUG
+                       if (debug > 1)
+                           msyslog(LOG_INFO, "received fragmented packet");
+#endif
+                       continue;
+               }
+
+               if ( ( (INFO_VERSION(reqpkt.rm_vn_mode) < 2)
+                      || (INFO_VERSION(reqpkt.rm_vn_mode) > NTP_VERSION))
+                    || INFO_MODE(reqpkt.rm_vn_mode) != MODE_PRIVATE) {
+#ifdef DEBUG
+                       if (debug > 1)
+                           msyslog(LOG_INFO,
+                                   "version (%d/%d) or mode (%d/%d) incorrect",
+                                   INFO_VERSION(reqpkt.rm_vn_mode),
+                                   NTP_VERSION,
+                                   INFO_MODE(reqpkt.rm_vn_mode),
+                                   MODE_PRIVATE);
+#endif
+                       continue;
+               }
+
+               if (INFO_SEQ(reqpkt.auth_seq) != 0) {
+#ifdef DEBUG
+                       if (debug > 1)
+                           msyslog(LOG_INFO,
+                                   "nonzero sequence number (%d)",
+                                   INFO_SEQ(reqpkt.auth_seq));
+#endif
+                       continue;
+               }
+
+               if (reqpkt.implementation != IMPL_XNTPD ||
+                   reqpkt.request != REQ_CONFIG) {
+#ifdef DEBUG
+                       if (debug > 1)
+                           msyslog(LOG_INFO,
+                                   "implementation (%d) or request (%d) incorrect",
+                                   reqpkt.implementation, reqpkt.request);
+#endif
+                       continue;
+               }
+
+               if (INFO_NITEMS(reqpkt.err_nitems) != 0 ||
+                   INFO_MBZ(reqpkt.mbz_itemsize) != 0 ||
+                   INFO_ITEMSIZE(reqpkt.mbz_itemsize) != 0) {
+#ifdef DEBUG
+                       if (debug > 1)
+                           msyslog(LOG_INFO,
+                                   "nitems (%d) mbz (%d) or itemsize (%d) nonzero",
+                                   INFO_NITEMS(reqpkt.err_nitems),
+                                   INFO_MBZ(reqpkt.mbz_itemsize),
+                                   INFO_ITEMSIZE(reqpkt.mbz_itemsize));
+#endif
+                       continue;
+               }
+
+               n = INFO_ERR(reqpkt.err_nitems);
+               switch (n) {
+                   case INFO_OKAY:
+                       /* success */
+                       return 1;
+               
+                   case INFO_ERR_IMPL:
+                       msyslog(LOG_ERR,
+                               "ntpd reports implementation mismatch!");
+                       return 0;
+               
+                   case INFO_ERR_REQ:
+                       msyslog(LOG_ERR,
+                               "ntpd says configuration request is unknown!");
+                       return 0;
+               
+                   case INFO_ERR_FMT:
+                       msyslog(LOG_ERR,
+                               "ntpd indicates a format error occurred!");
+                       return 0;
+
+                   case INFO_ERR_NODATA:
+                       msyslog(LOG_ERR,
+                               "ntpd indicates no data available!");
+                       return 0;
+               
+                   case INFO_ERR_AUTH:
+                       msyslog(LOG_ERR,
+                               "ntpd returns a permission denied error!");
+                       return 0;
+
+                   default:
+                       msyslog(LOG_ERR,
+                               "ntpd returns unknown error code %d!", n);
+                       return 0;
+               }
+       }
+}
+
+
+/*
+ * nexttoken - return the next token from a line
+ */
+static char *
+nexttoken(
+       char **lptr
+       )
+{
+       register char *cp;
+       register char *tstart;
+
+       cp = *lptr;
+
+       /*
+        * Skip leading white space
+        */
+       while (*cp == ' ' || *cp == '\t')
+           cp++;
+       
+       /*
+        * If this is the end of the line, return nothing.
+        */
+       if (*cp == '\n' || *cp == '\0') {
+               *lptr = cp;
+               return NULL;
+       }
+       
+       /*
+        * Must be the start of a token.  Record the pointer and look
+        * for the end.
+        */
+       tstart = cp++;
+       while (*cp != ' ' && *cp != '\t' && *cp != '\n' && *cp != '\0')
+           cp++;
+       
+       /*
+        * Terminate the token with a \0.  If this isn't the end of the
+        * line, space to the next character.
+        */
+       if (*cp == '\n' || *cp == '\0')
+           *cp = '\0';
+       else
+           *cp++ = '\0';
+
+       *lptr = cp;
+       return tstart;
+}
+
+
+/*
+ * readconf - read the configuration information out of the file we
+ *           were passed.  Note that since the file is supposed to be
+ *           machine generated, we bail out at the first sign of trouble.
+ */
+static void
+readconf(
+       FILE *fp,
+       char *name
+       )
+{
+       register int i;
+       char *token[NUMTOK];
+       u_long intval[NUMTOK];
+       u_int flags;
+       char buf[MAXLINESIZE];
+       char *bp;
+
+       while (fgets(buf, MAXLINESIZE, fp) != NULL) {
+
+               bp = buf;
+               for (i = 0; i < NUMTOK; i++) {
+                       if ((token[i] = nexttoken(&bp)) == NULL) {
+                               msyslog(LOG_ERR,
+                                       "tokenizing error in file `%s', quitting",
+                                       name);
+                               resolver_exit(1);
+                       }
+               }
+
+               for (i = 1; i < NUMTOK - 1; i++) {
+                       if (!atouint(token[i], &intval[i])) {
+                               msyslog(LOG_ERR,
+                                       "format error for integer token `%s', file `%s', quitting",
+                                       token[i], name);
+                               resolver_exit(1);
+                       }
+               }
+
+               if (intval[TOK_HMODE] != MODE_ACTIVE &&
+                   intval[TOK_HMODE] != MODE_CLIENT &&
+                   intval[TOK_HMODE] != MODE_BROADCAST) {
+                       msyslog(LOG_ERR, "invalid mode (%ld) in file %s",
+                               intval[TOK_HMODE], name);
+                       resolver_exit(1);
+               }
+
+               if (intval[TOK_VERSION] > NTP_VERSION ||
+                   intval[TOK_VERSION] < NTP_OLDVERSION) {
+                       msyslog(LOG_ERR, "invalid version (%ld) in file %s",
+                               intval[TOK_VERSION], name);
+                       resolver_exit(1);
+               }
+               if (intval[TOK_MINPOLL] < NTP_MINPOLL ||
+                   intval[TOK_MINPOLL] > NTP_MAXPOLL) {
+                       msyslog(LOG_ERR, "invalid MINPOLL value (%ld) in file %s",
+                               intval[TOK_MINPOLL], name);
+                       resolver_exit(1);
+               }
+
+               if (intval[TOK_MAXPOLL] < NTP_MINPOLL ||
+                   intval[TOK_MAXPOLL] > NTP_MAXPOLL) {
+                       msyslog(LOG_ERR, "invalid MAXPOLL value (%ld) in file %s",
+                               intval[TOK_MAXPOLL], name);
+                       resolver_exit(1);
+               }
+
+               if ((intval[TOK_FLAGS] & ~(FLAG_AUTHENABLE | FLAG_PREFER |
+                   FLAG_NOSELECT | FLAG_BURST | FLAG_IBURST | FLAG_SKEY))
+                   != 0) {
+                       msyslog(LOG_ERR, "invalid flags (%ld) in file %s",
+                               intval[TOK_FLAGS], name);
+                       resolver_exit(1);
+               }
+
+               flags = 0;
+               if (intval[TOK_FLAGS] & FLAG_AUTHENABLE)
+                   flags |= CONF_FLAG_AUTHENABLE;
+               if (intval[TOK_FLAGS] & FLAG_PREFER)
+                   flags |= CONF_FLAG_PREFER;
+               if (intval[TOK_FLAGS] & FLAG_NOSELECT)
+                   flags |= CONF_FLAG_NOSELECT;
+               if (intval[TOK_FLAGS] & FLAG_BURST)
+                   flags |= CONF_FLAG_BURST;
+               if (intval[TOK_FLAGS] & FLAG_IBURST)
+                   flags |= CONF_FLAG_IBURST;
+               if (intval[TOK_FLAGS] & FLAG_SKEY)
+                   flags |= CONF_FLAG_SKEY;
+
+               /*
+                * This is as good as we can check it.  Add it in.
+                */
+               addentry(token[TOK_HOSTNAME], (int)intval[TOK_HMODE],
+                        (int)intval[TOK_VERSION], (int)intval[TOK_MINPOLL],
+                        (int)intval[TOK_MAXPOLL], flags, (int)intval[TOK_TTL],
+                        intval[TOK_KEYID], token[TOK_KEYSTR]);
+       }
+}
+
+
+/*
+ * doconfigure - attempt to resolve names and configure the server
+ */
+static void
+doconfigure(
+       int dores
+       )
+{
+       register struct conf_entry *ce;
+       register struct conf_entry *ceremove;
+
+#ifdef DEBUG
+               if (debug > 1)
+                       msyslog(LOG_INFO, "Running doconfigure %s DNS",
+                           dores ? "with" : "without" );
+#endif
+
+       ce = confentries;
+       while (ce != NULL) {
+#ifdef DEBUG
+               if (debug > 1)
+                       msyslog(LOG_INFO,
+                           "doconfigure: <%s> has peeraddr %s",
+                           ce->ce_name, stoa(&ce->peer_store));
+#endif
+               if (dores && SOCKNUL(&(ce->peer_store))) {
+                       if (!findhostaddr(ce)) {
+#ifndef IGNORE_DNS_ERRORS
+                               msyslog(LOG_ERR,
+                                       "couldn't resolve `%s', giving up on it",
+                                       ce->ce_name);
+                               ceremove = ce;
+                               ce = ceremove->ce_next;
+                               removeentry(ceremove);
+                               continue;
+#endif
+                       }
+               }
+
+               if (!SOCKNUL(&ce->peer_store)) {
+                       if (request(&ce->ce_config)) {
+                               ceremove = ce;
+                               ce = ceremove->ce_next;
+                               removeentry(ceremove);
+                               continue;
+                       }
+#ifdef DEBUG
+                       if (debug > 1) {
+                               msyslog(LOG_INFO,
+                                   "doconfigure: request() FAILED, maybe next time.");
+                       }
+#endif
+               }
+               ce = ce->ce_next;
+       }
+}
diff --git a/ntpd/ntp_io.c b/ntpd/ntp_io.c
new file mode 100644 (file)
index 0000000..5cf9f1d
--- /dev/null
@@ -0,0 +1,3983 @@
+/*
+ * ntp_io.c - input/output routines for ntpd.  The socket-opening code
+ *                was shamelessly stolen from ntpd.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntp_machine.h"
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "iosignal.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+#include "ntp_request.h"
+#include "ntp.h"
+#include "ntp_unixtime.h"
+
+/* Don't include ISC's version of IPv6 variables and structures */
+#define ISC_IPV6_H 1
+#include <isc/interfaceiter.h>
+#include <isc/list.h>
+#include <isc/result.h>
+
+#ifdef SIM
+#include "ntpsim.h"
+#endif
+
+#include <stdio.h>
+#include <signal.h>
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif /* HAVE_SYS_PARAM_H */
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+#ifdef HAVE_SYS_SOCKIO_H       /* UXPV: SIOC* #defines (Frank Vance <fvance@waii.com>) */
+# include <sys/sockio.h>
+#endif
+#ifdef HAVE_SYS_UIO_H
+# include <sys/uio.h>
+#endif
+
+/*
+ * setsockopt does not always have the same arg declaration
+ * across all platforms. If it's not defined we make it empty
+ */
+
+#ifndef SETSOCKOPT_ARG_CAST
+#define SETSOCKOPT_ARG_CAST
+#endif
+
+/* 
+ * Set up some macros to look for IPv6 and IPv6 multicast
+ */
+
+#if defined(ISC_PLATFORM_HAVEIPV6) && !defined(DISABLE_IPV6)
+
+#define INCLUDE_IPV6_SUPPORT
+
+#if defined(INCLUDE_IPV6_SUPPORT) && defined(IPV6_JOIN_GROUP) && defined(IPV6_LEAVE_GROUP)
+#define INCLUDE_IPV6_MULTICAST_SUPPORT
+
+#endif /* IPV6 Multicast Support */
+#endif  /* IPv6 Support */
+
+extern int listen_to_virtual_ips;
+extern const char *specific_interface;
+
+#if defined(SO_TIMESTAMP) && defined(SCM_TIMESTAMP)
+#if defined(CMSG_FIRSTHDR)
+#define HAVE_TIMESTAMP
+#define USE_TIMESTAMP_CMSG
+#ifndef TIMESTAMP_CTLMSGBUF_SIZE
+#define TIMESTAMP_CTLMSGBUF_SIZE 1536 /* moderate default */
+#endif
+#else
+/* fill in for old/other timestamp interfaces */
+#endif
+#endif
+
+#if defined(SYS_WINNT)
+#include <transmitbuff.h>
+#include <isc/win32os.h>
+/*
+ * Define this macro to control the behavior of connection
+ * resets on UDP sockets.  See Microsoft KnowledgeBase Article Q263823
+ * for details.
+ * NOTE: This requires that Windows 2000 systems install Service Pack 2
+ * or later.
+ */
+#ifndef SIO_UDP_CONNRESET 
+#define SIO_UDP_CONNRESET _WSAIOW(IOC_VENDOR,12) 
+#endif
+
+/*
+ * Windows C runtime ioctl() can't deal properly with sockets, 
+ * map to ioctlsocket for this source file.
+ */
+#define ioctl(fd, opt, val)  ioctlsocket((fd), (opt), (u_long *)(val))
+#endif  /* SYS_WINNT */
+
+/*
+ * We do asynchronous input using the SIGIO facility.  A number of
+ * recvbuf buffers are preallocated for input. In the signal
+ * handler we poll to see which sockets are ready and read the
+ * packets from them into the recvbuf's along with a time stamp and
+ * an indication of the source host and the interface it was received
+ * through.  This allows us to get as accurate receive time stamps
+ * as possible independent of other processing going on.
+ *
+ * We watch the number of recvbufs available to the signal handler
+ * and allocate more when this number drops below the low water
+ * mark.  If the signal handler should run out of buffers in the
+ * interim it will drop incoming frames, the idea being that it is
+ * better to drop a packet than to be inaccurate.
+ */
+
+
+/*
+ * Other statistics of possible interest
+ */
+volatile u_long packets_dropped;       /* total number of packets dropped on reception */
+volatile u_long packets_ignored;       /* packets received on wild card interface */
+volatile u_long packets_received;      /* total number of packets received */
+u_long packets_sent;   /* total number of packets sent */
+u_long packets_notsent; /* total number of packets which couldn't be sent */
+
+volatile u_long handler_calls; /* number of calls to interrupt handler */
+volatile u_long handler_pkts;  /* number of pkts received by handler */
+u_long io_timereset;           /* time counters were reset */
+
+/*
+ * Interface stuff
+ */
+struct interface *any_interface;       /* default ipv4 interface */
+struct interface *any6_interface;      /* default ipv6 interface */
+struct interface *loopback_interface;  /* loopback ipv4 interface */
+
+int ninterfaces;                       /* Total number of interfaces */
+
+volatile int disable_dynamic_updates;   /* when set to != 0 dynamic updates won't happen */
+
+#ifdef REFCLOCK
+/*
+ * Refclock stuff.     We keep a chain of structures with data concerning
+ * the guys we are doing I/O for.
+ */
+static struct refclockio *refio;
+#endif /* REFCLOCK */
+
+
+/*
+ * Define what the possible "soft" errors can be.  These are non-fatal returns
+ * of various network related functions, like recv() and so on.
+ *
+ * For some reason, BSDI (and perhaps others) will sometimes return <0
+ * from recv() but will have errno==0.  This is broken, but we have to
+ * work around it here.
+ */
+#define SOFT_ERROR(e)  ((e) == EAGAIN || \
+                        (e) == EWOULDBLOCK || \
+                        (e) == EINTR || \
+                        (e) == 0)
+
+/*
+ * File descriptor masks etc. for call to select
+ * Not needed for I/O Completion Ports
+ */
+fd_set activefds;
+int maxactivefd;
+/*
+ * bit alternating value to detect verified interfaces during an update cycle
+ */
+static  u_char          sys_interphase = 0;
+
+static  struct interface *new_interface P((struct interface *));
+static  void add_interface P((struct interface *));
+static  int update_interfaces P((u_short, interface_receiver_t, void *));
+static  void remove_interface P((struct interface *));
+static  struct interface *create_interface P((u_short, struct interface *));
+
+static int     move_fd         P((SOCKET));
+
+/*
+ * Multicast functions
+ */
+static isc_boolean_t   addr_ismulticast         P((struct sockaddr_storage *));
+/*
+ * Not all platforms support multicast
+ */
+#ifdef MCAST
+static isc_boolean_t   socket_multicast_enable  P((struct interface *, int, struct sockaddr_storage *));
+static isc_boolean_t   socket_multicast_disable P((struct interface *, struct sockaddr_storage *));
+#endif
+
+#ifdef DEBUG
+static void print_interface    P((struct interface *, char *, char *));
+#define DPRINT_INTERFACE(_LVL_, _ARGS_) do { if (debug >= (_LVL_)) { print_interface _ARGS_; } } while (0)
+#else
+#define DPRINT_INTERFACE(_LVL_, _ARGS_) do {} while (0)
+#endif
+
+typedef struct vsock vsock_t;
+enum desc_type { FD_TYPE_SOCKET, FD_TYPE_FILE };
+
+struct vsock {
+       SOCKET                          fd;
+       enum desc_type                  type;
+       ISC_LINK(vsock_t)               link;
+};
+
+#if !defined(HAVE_IO_COMPLETION_PORT) && defined(HAS_ROUTING_SOCKET)
+/*
+ * async notification processing (e. g. routing sockets)
+ */
+/*
+ * support for receiving data on fd that is not a refclock or a socket
+ * like e. g. routing sockets
+ */
+struct asyncio_reader {
+       SOCKET fd;                                  /* fd to be read */
+       void  *data;                                /* possibly local data */
+       void (*receiver)(struct asyncio_reader *);  /* input handler */
+       ISC_LINK(struct asyncio_reader) link;       /* the list this is being kept in */
+};
+
+ISC_LIST(struct asyncio_reader) asyncio_reader_list;
+
+static void delete_asyncio_reader P((struct asyncio_reader *));
+static struct asyncio_reader *new_asyncio_reader P((void));
+static void add_asyncio_reader P((struct asyncio_reader *, enum desc_type));
+static void remove_asyncio_reader P((struct asyncio_reader *));
+
+#endif /* !defined(HAVE_IO_COMPLETION_PORT) && defined(HAS_ROUTING_SOCKET) */
+
+static void init_async_notifications P((void));
+
+static int create_sockets      P((u_short));
+static SOCKET  open_socket     P((struct sockaddr_storage *, int, int, struct interface *));
+static char *  fdbits          P((int, fd_set *));
+static void    set_reuseaddr   P((int));
+static isc_boolean_t   socket_broadcast_enable  P((struct interface *, SOCKET, struct sockaddr_storage *));
+static isc_boolean_t   socket_broadcast_disable P((struct interface *, struct sockaddr_storage *));
+
+ISC_LIST(vsock_t)      fd_list;
+
+typedef struct remaddr remaddr_t;
+
+struct remaddr {
+      struct sockaddr_storage   addr;
+      struct interface               *interface;
+      ISC_LINK(remaddr_t)       link;
+};
+
+ISC_LIST(remaddr_t)       remoteaddr_list;
+
+ISC_LIST(struct interface)     inter_list;
+
+static struct interface *wildipv4 = NULL;
+static struct interface *wildipv6 = NULL;
+
+static void    add_fd_to_list  P((SOCKET, enum desc_type));
+static void    close_and_delete_fd_from_list   P((SOCKET));
+static void    add_addr_to_list        P((struct sockaddr_storage *, struct interface *));
+static void    delete_addr_from_list   P((struct sockaddr_storage *));
+static struct interface *find_addr_in_list     P((struct sockaddr_storage *));
+static struct interface *find_flagged_addr_in_list P((struct sockaddr_storage *, int));
+static void    create_wildcards        P((u_short));
+static isc_boolean_t   address_okay    P((struct interface *));
+static void            convert_isc_if          P((isc_interface_t *, struct interface *, u_short));
+static void    delete_interface_from_list      P((struct interface *));
+static struct interface *getinterface  P((struct sockaddr_storage *, int));
+static struct interface *findlocalinterface    P((struct sockaddr_storage *, int));
+static struct interface *findlocalcastinterface        P((struct sockaddr_storage *, int));
+
+/*
+ * Routines to read the ntp packets
+ */
+#if !defined(HAVE_IO_COMPLETION_PORT)
+static inline int     read_network_packet      P((SOCKET, struct interface *, l_fp));
+static inline int     read_refclock_packet     P((SOCKET, struct refclockio *, l_fp));
+#endif
+
+#ifdef SYS_WINNT
+/*
+ * Windows 2000 systems incorrectly cause UDP sockets using WASRecvFrom
+ * to not work correctly, returning a WSACONNRESET error when a WSASendTo
+ * fails with an "ICMP port unreachable" response and preventing the
+ * socket from using the WSARecvFrom in subsequent operations.
+ * The function below fixes this, but requires that Windows 2000
+ * Service Pack 2 or later be installed on the system.  NT 4.0
+ * systems are not affected by this and work correctly.
+ * See Microsoft Knowledge Base Article Q263823 for details of this.
+ */
+void
+connection_reset_fix(
+       SOCKET fd,
+       struct sockaddr_storage *addr
+       )
+{
+       DWORD dwBytesReturned = 0;
+       BOOL  bNewBehavior = FALSE;
+       DWORD status;
+
+       /*
+        * disable bad behavior using IOCTL: SIO_UDP_CONNRESET
+        * NT 4.0 has no problem
+        */
+       if (isc_win32os_majorversion() >= 5) {
+               status = WSAIoctl(fd, SIO_UDP_CONNRESET, &bNewBehavior,
+                                 sizeof(bNewBehavior), NULL, 0,
+                                 &dwBytesReturned, NULL, NULL);
+               if (SOCKET_ERROR == status)
+                       netsyslog(LOG_ERR, "connection_reset_fix() "
+                                          "failed for address %s: %m", 
+                                          stoa(addr));
+       }
+}
+#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 descriptor in the range of
+ * [0..FOPEN_MAX)
+ * in order to keep this range clean for socket
+ * file descriptors we attempt to move them above
+ * FOPEM_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
+ */
+static int move_fd(SOCKET fd)
+{
+#if !defined(SYS_WINNT) && defined(F_DUPFD)
+#ifndef FD_CHUNK
+#define FD_CHUNK       10
+#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
+
+#ifndef HAVE_GETDTABLESIZE
+/*
+ * if we have no idea about the max fd value set up things
+ * so we will start at FOPEN_MAX
+ */
+#define getdtablesize() (FOPEN_MAX+FD_CHUNK)
+#endif
+
+#ifndef FOPEN_MAX
+#define FOPEN_MAX      20      /* assume that for the lack of anything better */
+#endif
+       static SOCKET socket_boundary = -1;
+       SOCKET newfd;
+
+       /*
+        * 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)));
+#ifdef DEBUG
+               msyslog(LOG_DEBUG, "ntp_io: estimated max descriptors: %d, initial socket boundary: %d",
+                       getdtablesize(), socket_boundary);
+#endif
+       }
+
+       /*
+        * 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 */
+                               (void)close(fd);
+                               return (newfd);
+                       }
+               } else {
+                       /* outside reserved range: no work - return the original one */
+                       return (fd);
+               }
+               socket_boundary = max(0, socket_boundary - FD_CHUNK);
+#ifdef DEBUG
+               msyslog(LOG_DEBUG, "ntp_io: selecting new socket boundary: %d",
+                       socket_boundary);
+#endif
+       } while (socket_boundary > 0);
+#endif /* !defined(SYS_WINNT) && defined(F_DUPFD) */
+       return (fd);
+}
+
+#ifdef DEBUG_TIMING
+/*
+ * collect timing information for various processing
+ * paths. currently we only pass then on to the file
+ * for later processing. this could also do histogram
+ * based analysis in other to reduce the load (and skew)
+ * dur to the file output
+ */
+void
+collect_timing(struct recvbuf *rb, const char *tag, int count, l_fp *dts)
+{
+       char buf[2048];
+
+       snprintf(buf, sizeof(buf), "%s %d %s %s", 
+                (rb != NULL) ? 
+                ((rb->dstadr) ? stoa(&rb->recv_srcadr) : "-REFCLOCK-") : "-",
+                count, lfptoa(dts, 9), tag);
+       record_timing_stats(buf);
+}
+#endif
+  
+/*
+ * About dynamic interfaces, sockets, reception and more...
+ *
+ * the code solves following tasks:
+ *
+ *   - keep a current list of active interfaces in order
+ *     to bind to to the interface address on NTP_PORT so that
+ *     all wild and specific bindings for NTP_PORT are taken by ntpd
+ *     to avoid other daemons messing with the time or sockets.
+ *   - all interfaces keep a list of peers that are referencing 
+ *     the interface in order to quickly re-assign the peers to
+ *     new interface in case an interface is deleted (=> gone from system or
+ *     down)
+ *   - have a preconfigured socket ready with the right local address
+ *     for transmission and reception
+ *   - have an address list for all destination addresses used within ntpd
+ *     to find the "right" preconfigured socket.
+ *   - facilitate updating the internal interface list with respect to
+ *     the current kernel state
+ *
+ * special issues:
+ *
+ *   - mapping of multicast addresses to the interface affected is not always
+ *     one to one - especially on hosts with multiple interfaces
+ *     the code here currently allocates a separate interface entry for those
+ *     multicast addresses
+ *     iff it is able to bind to a *new* socket with the multicast address (flags |= MCASTIF)
+ *     in case of failure the multicast address is bound to an existing interface.
+ *   - on some systems it is perfectly legal to assign the same address to
+ *     multiple interfaces. Therefore this code does not keep a list of interfaces
+ *     but a list of interfaces that represent a unique address as determined by the kernel
+ *     by the procedure in findlocalinterface. Thus it is perfectly legal to see only
+ *     one representative of a group of real interfaces if they share the same address.
+ * 
+ * Frank Kardel 20050910
+ */
+
+/*
+ * init_io - initialize I/O data structures and call socket creation routine
+ */
+void
+init_io(void)
+{
+#ifdef SYS_WINNT
+       init_io_completion_port();
+
+       if (!Win32InitSockets())
+       {
+               netsyslog(LOG_ERR, "No useable winsock.dll: %m");
+               exit(1);
+       }
+       init_transmitbuff();
+#endif /* SYS_WINNT */
+
+       /*
+        * Init buffer free list and stat counters
+        */
+       init_recvbuff(RECV_INIT);
+
+       packets_dropped = packets_received = 0;
+       packets_ignored = 0;
+       packets_sent = packets_notsent = 0;
+       handler_calls = handler_pkts = 0;
+       io_timereset = 0;
+       loopback_interface = NULL;
+       any_interface = NULL;
+       any6_interface = NULL;
+
+#ifdef REFCLOCK
+       refio = NULL;
+#endif
+
+#if defined(HAVE_SIGNALED_IO)
+       (void) set_signal();
+#endif
+
+       ISC_LIST_INIT(fd_list);
+
+#if !defined(HAVE_IO_COMPLETION_PORT) && defined(HAS_ROUTING_SOCKET)
+       ISC_LIST_INIT(asyncio_reader_list);
+#endif
+
+        ISC_LIST_INIT(remoteaddr_list);
+
+       ISC_LIST_INIT(inter_list);
+
+       /*
+        * Create the sockets
+        */
+       BLOCKIO();
+       (void) create_sockets(htons(NTP_PORT));
+       UNBLOCKIO();
+
+       init_async_notifications();
+
+       DPRINTF(3, ("init_io: maxactivefd %d\n", maxactivefd));
+}
+
+#ifdef DEBUG
+/*
+ * function to dump the contents of the interface structure
+ * for debugging use only.
+ */
+void
+interface_dump(struct interface *itf)
+{
+       u_char* cp;
+       int i;
+       /* Limit the size of the sockaddr_storage hex dump */
+       int maxsize = min(32, sizeof(struct sockaddr_storage));
+
+       printf("Dumping interface: %p\n", itf);
+       printf("fd = %d\n", itf->fd);
+       printf("bfd = %d\n", itf->bfd);
+       printf("sin = %s,\n", stoa(&(itf->sin)));
+       cp = (u_char*) &(itf->sin);
+       for(i = 0; i < maxsize; i++)
+       {
+               printf("%02x", *cp++);
+               if((i+1)%4 == 0)
+                       printf(" ");
+       }
+       printf("\n");
+       printf("bcast = %s,\n", stoa(&(itf->bcast)));
+       cp = (u_char*) &(itf->bcast);
+       for(i = 0; i < maxsize; i++)
+       {
+               printf("%02x", *cp++);
+               if((i+1)%4 == 0)
+                       printf(" ");
+       }
+       printf("\n");
+       printf("mask = %s,\n", stoa(&(itf->mask)));
+       cp = (u_char*) &(itf->mask);
+       for(i = 0; i < maxsize; i++)
+       {
+               printf("%02x", *cp++);
+               if((i+1)%4 == 0)
+                       printf(" ");
+       }
+       printf("\n");
+       printf("name = %s\n", itf->name);
+       printf("flags = 0x%08x\n", itf->flags);
+       printf("last_ttl = %d\n", itf->last_ttl);
+       printf("addr_refid = %08x\n", itf->addr_refid);
+       printf("num_mcast = %d\n", itf->num_mcast);
+       printf("received = %ld\n", itf->received);
+       printf("sent = %ld\n", itf->sent);
+       printf("notsent = %ld\n", itf->notsent);
+       printf("ifindex = %u\n", itf->ifindex);
+       printf("scopeid = %u\n", itf->scopeid);
+       printf("peercnt = %u\n", itf->peercnt);
+       printf("phase = %u\n", itf->phase);
+}
+
+/*
+ * print_interface - helper to output debug information
+ */
+static void
+print_interface(struct interface *iface, char *pfx, char *sfx)
+{
+       printf("%sinterface #%d: fd=%d, bfd=%d, name=%s, flags=0x%x, scope=%d, ifindex=%d",
+              pfx,
+              iface->ifnum,
+              iface->fd,
+              iface->bfd,
+              iface->name,
+              iface->flags,
+              iface->scopeid,
+              iface->ifindex);
+       /* Leave these as three printf calls. */
+       printf(", sin=%s",
+              stoa((&iface->sin)));
+       if (iface->flags & INT_BROADCAST)
+               printf(", bcast=%s,",
+                      stoa((&iface->bcast)));
+       if (iface->family == AF_INET)
+         printf(", mask=%s",
+                stoa((&iface->mask)));
+       printf(", %s:%s", iface->ignore_packets == ISC_FALSE ? "Enabled" : "Disabled", sfx);
+       if (debug > 4)  /* in-depth debugging only */
+               interface_dump(iface);
+}
+
+#endif
+
+#if !defined(HAVE_IO_COMPLETION_PORT) && defined(HAS_ROUTING_SOCKET)
+/*
+ * create an asyncio_reader structure
+ */
+static struct asyncio_reader *
+new_asyncio_reader()
+{
+       struct asyncio_reader *reader;
+
+       reader = (struct asyncio_reader *)emalloc(sizeof(struct asyncio_reader));
+
+       memset((char *)reader, 0, sizeof(*reader));
+       ISC_LINK_INIT(reader, link);
+       reader->fd = INVALID_SOCKET;
+       return reader;
+}
+
+/*
+ * delete a reader
+ */
+static void
+delete_asyncio_reader(struct asyncio_reader *reader)
+{
+       free(reader);
+}
+
+/*
+ * add asynchio_reader
+ */
+static void
+add_asyncio_reader(struct asyncio_reader *reader, enum desc_type type)
+{
+       ISC_LIST_APPEND(asyncio_reader_list, reader, link);
+       add_fd_to_list(reader->fd, type);
+}
+       
+/*
+ * remove asynchio_reader
+ */
+static void
+remove_asyncio_reader(struct asyncio_reader *reader)
+{
+       ISC_LIST_UNLINK_TYPE(asyncio_reader_list, reader, link, struct asyncio_reader);
+
+       if (reader->fd != INVALID_SOCKET)
+               close_and_delete_fd_from_list(reader->fd);
+
+       reader->fd = INVALID_SOCKET;
+}
+#endif /* !defined(HAVE_IO_COMPLETION_PORT) && defined(HAS_ROUTING_SOCKET) */
+
+/*
+ * interface list enumerator - visitor pattern
+ */
+void
+interface_enumerate(interface_receiver_t receiver, void *data)
+{
+       interface_info_t ifi;
+        struct interface *interf;
+
+       ifi.action = IFS_EXISTS;
+       
+       for (interf = ISC_LIST_HEAD(inter_list);
+            interf != NULL;
+            interf = ISC_LIST_NEXT(interf, link)) {
+               ifi.interface = interf;
+               receiver(data, &ifi);
+       }
+}
+
+/*
+ * do standard initialization of interface structure
+ */
+static void
+init_interface(struct interface *interface)
+{
+       memset((char *)interface, 0, sizeof(struct interface));
+       ISC_LINK_INIT(interface, link);
+       ISC_LIST_INIT(interface->peers);
+       interface->fd = INVALID_SOCKET;
+       interface->bfd = INVALID_SOCKET;
+       interface->num_mcast = 0;
+       interface->received = 0;
+       interface->sent = 0;
+       interface->notsent = 0;
+       interface->peercnt = 0;
+       interface->phase = sys_interphase;
+}
+
+/*
+ * create new interface structure initialize from
+ * template structure or via standard initialization
+ * function
+ */
+static struct interface *
+new_interface(struct interface *interface)
+{
+       static u_int sys_ifnum = 0;
+
+       struct interface *iface = (struct interface *)emalloc(sizeof(struct interface));
+
+       if (interface != NULL)
+       {
+               memcpy((char*)iface, (char*)interface, sizeof(*interface));
+       }
+       else
+       {
+               init_interface(iface);
+       }
+
+       iface->ifnum = sys_ifnum++;  /* count every new instance of an interface in the system */
+       iface->starttime = current_time;
+
+       return iface;
+}
+
+/*
+ * return interface storage into free memory pool
+ */
+static void
+delete_interface(struct interface *interface)
+{
+       free(interface);
+}
+
+/*
+ * link interface into list of known interfaces
+ */
+static void
+add_interface(struct interface *interface)
+{
+       static struct interface *listhead = NULL;
+
+       /*
+        * For ntpd, the first few interfaces (wildcard, localhost)
+        * will never be removed.  This means inter_list.head is
+        * unchanging once initialized.  Take advantage of that to
+        * watch for changes and catch corruption earlier.  This
+        * helped track down corruption caused by using FD_SET with
+        * a descriptor numerically larger than FD_SETSIZE.
+        */
+       if (NULL == listhead)
+               listhead = inter_list.head;
+
+       if (listhead != inter_list.head) {
+               msyslog(LOG_ERR, "add_interface inter_list.head corrupted: was %p now %p",
+                       listhead, inter_list.head);
+               exit(1);
+       }
+       /*
+        * Calculate the address hash
+        */
+       interface->addr_refid = addr2refid(&interface->sin);
+       
+       ISC_LIST_APPEND(inter_list, interface, link);
+       ninterfaces++;
+}
+
+/*
+ * remove interface from known interface list and clean up
+ * associated resources
+ */
+static void
+remove_interface(struct interface *interface)
+{
+       struct sockaddr_storage resmask;
+
+       ISC_LIST_UNLINK_TYPE(inter_list, interface, link, struct interface);
+
+       delete_interface_from_list(interface);
+  
+       if (interface->fd != INVALID_SOCKET) 
+       {
+               msyslog(LOG_INFO, "Deleting interface #%d %s, %s#%d, interface stats: received=%ld, sent=%ld, dropped=%ld, active_time=%ld secs",
+                       interface->ifnum,
+                       interface->name,
+                       stoa((&interface->sin)),
+                       NTP_PORT,  /* XXX should extract port from sin structure */
+                       interface->received,
+                       interface->sent,
+                       interface->notsent,
+                       current_time - interface->starttime);
+
+               close_and_delete_fd_from_list(interface->fd);
+       }
+  
+       if (interface->bfd != INVALID_SOCKET) 
+       {
+               msyslog(LOG_INFO, "Deleting interface #%d %s, broadcast address %s#%d",
+                       interface->ifnum,
+                       interface->name,
+                       stoa((&interface->bcast)),
+                       (u_short) NTP_PORT);  /* XXX extract port from sin structure */
+               close_and_delete_fd_from_list(interface->bfd);
+       }
+
+       ninterfaces--;
+       ntp_monclearinterface(interface);
+
+       /* remove restrict interface entry */
+
+       /*
+        * Blacklist bound interface address
+        */
+       SET_HOSTMASK(&resmask, interface->sin.ss_family);
+       hack_restrict(RESTRICT_REMOVEIF, &interface->sin, &resmask,
+                     RESM_NTPONLY|RESM_INTERFACE, RES_IGNORE);
+}
+
+static void
+list_if_listening(struct interface *interface, u_short port)
+{
+       msyslog(LOG_INFO, "Listening on interface #%d %s, %s#%d %s",
+               interface->ifnum,
+               interface->name,
+               stoa((&interface->sin)),
+               ntohs( (u_short) port),
+               (interface->ignore_packets == ISC_FALSE) ?
+               "Enabled": "Disabled");
+}
+
+static void
+create_wildcards(u_short port) {
+       isc_boolean_t okipv4 = ISC_TRUE;
+       /*
+        * create pseudo-interface with wildcard IPv4 address
+        */
+#ifdef IPV6_V6ONLY
+       if(isc_net_probeipv4() != ISC_R_SUCCESS)
+               okipv4 = ISC_FALSE;
+#endif
+
+       if(okipv4 == ISC_TRUE) {
+               struct interface *interface = new_interface(NULL);
+
+               interface->family = AF_INET;
+               interface->sin.ss_family = AF_INET;
+               ((struct sockaddr_in*)&interface->sin)->sin_addr.s_addr = htonl(INADDR_ANY);
+               ((struct sockaddr_in*)&interface->sin)->sin_port = port;
+               (void) strncpy(interface->name, "wildcard", sizeof(interface->name));
+               interface->mask.ss_family = AF_INET;
+               ((struct sockaddr_in*)&interface->mask)->sin_addr.s_addr = htonl(~(u_int32)0);
+               interface->flags = INT_BROADCAST | INT_UP | INT_WILDCARD;
+               interface->ignore_packets = ISC_TRUE;
+#if defined(MCAST)
+               /*
+                * enable possible multicast reception on the broadcast socket
+                */
+               interface->bcast.ss_family = AF_INET;
+               ((struct sockaddr_in*)&interface->bcast)->sin_port = port;
+               ((struct sockaddr_in*)&interface->bcast)->sin_addr.s_addr = htonl(INADDR_ANY);
+#endif /* MCAST */
+               interface->fd = open_socket(&interface->sin,
+                                interface->flags, 1, interface);
+
+               if (interface->fd != INVALID_SOCKET) {
+                       wildipv4 = interface;
+                       any_interface = interface;
+                       
+                       add_addr_to_list(&interface->sin, interface);
+                       add_interface(interface);
+                       list_if_listening(interface, port);
+               } else {
+                       msyslog(LOG_ERR, "unable to bind to wildcard socket address %s - another process may be running - EXITING",
+                               stoa((&interface->sin)));
+                       exit(1);
+               }
+       }
+
+#ifdef INCLUDE_IPV6_SUPPORT
+       /*
+        * create pseudo-interface with wildcard IPv6 address
+        */
+       if (isc_net_probeipv6() == ISC_R_SUCCESS) {
+               struct interface *interface = new_interface(NULL);
+
+               interface->family = AF_INET6;
+               interface->sin.ss_family = AF_INET6;
+               ((struct sockaddr_in6*)&interface->sin)->sin6_addr = in6addr_any;
+               ((struct sockaddr_in6*)&interface->sin)->sin6_port = port;
+# ifdef ISC_PLATFORM_HAVESCOPEID
+               ((struct sockaddr_in6*)&interface->sin)->sin6_scope_id = 0;
+# endif
+               (void) strncpy(interface->name, "wildcard", sizeof(interface->name));
+               interface->mask.ss_family = AF_INET6;
+               memset(&((struct sockaddr_in6*)&interface->mask)->sin6_addr.s6_addr, 0xff, sizeof(struct in6_addr));
+               interface->flags = INT_UP | INT_WILDCARD;
+               interface->ignore_packets = ISC_TRUE;
+
+               interface->fd = open_socket(&interface->sin,
+                                interface->flags, 1, interface);
+
+               if (interface->fd != INVALID_SOCKET) {
+                       wildipv6 = interface;
+                       any6_interface = interface;
+                       add_addr_to_list(&interface->sin, interface);
+                       add_interface(interface);
+                       list_if_listening(interface, port);
+               } else {
+                       msyslog(LOG_ERR, "unable to bind to wildcard socket address %s - another process may be running - EXITING",
+                               stoa((&interface->sin)));
+                       exit(1);
+               }
+       }
+#endif
+}
+
+
+static isc_boolean_t
+address_okay(struct interface *iface) {
+
+       DPRINTF(4, ("address_okay: listen Virtual: %d, IF name: %s\n", 
+                   listen_to_virtual_ips, iface->name));
+
+       /*
+        * Always allow the loopback
+        */
+       if((iface->flags & INT_LOOPBACK) != 0) {
+               DPRINTF(4, ("address_okay: loopback - OK\n"));
+               return (ISC_TRUE);
+       }
+
+       /*
+        * Check if the interface is specified
+        */
+       if (specific_interface != NULL) {
+               if (strcasecmp(iface->name, specific_interface) == 0) {
+                       DPRINTF(4, ("address_okay: specific interface name matched - OK\n"));
+                       return (ISC_TRUE);
+               } else {
+                       DPRINTF(4, ("address_okay: specific interface name NOT matched - FAIL\n"));
+                       return (ISC_FALSE);
+               }
+       }
+       else {
+               if (listen_to_virtual_ips == 0  && 
+                   (strchr(iface->name, (int)':') != NULL)) {
+                       DPRINTF(4, ("address_okay: virtual ip/alias - FAIL\n"));
+                       return (ISC_FALSE);
+               }
+       }
+
+       DPRINTF(4, ("address_okay: OK\n"));
+       return (ISC_TRUE);
+}
+
+static void
+convert_isc_if(isc_interface_t *isc_if, struct interface *itf, u_short port)
+{
+       itf->scopeid = 0;
+       itf->family = (short) isc_if->af;
+       strcpy(itf->name, isc_if->name);
+
+       if(isc_if->af == AF_INET) {
+               itf->sin.ss_family = (u_short) isc_if->af;
+               memcpy(&(((struct sockaddr_in*)&itf->sin)->sin_addr),
+                      &(isc_if->address.type.in),
+                      sizeof(struct in_addr));
+               ((struct sockaddr_in*)&itf->sin)->sin_port = port;
+
+               if((isc_if->flags & INTERFACE_F_BROADCAST) != 0) {
+                       itf->flags |= INT_BROADCAST;
+                       itf->bcast.ss_family = itf->sin.ss_family;
+                       memcpy(&(((struct sockaddr_in*)&itf->bcast)->sin_addr),
+                              &(isc_if->broadcast.type.in),
+                                sizeof(struct in_addr));
+                       ((struct sockaddr_in*)&itf->bcast)->sin_port = port;
+               }
+
+               itf->mask.ss_family = itf->sin.ss_family;
+               memcpy(&(((struct sockaddr_in*)&itf->mask)->sin_addr),
+                      &(isc_if->netmask.type.in),
+                      sizeof(struct in_addr));
+               ((struct sockaddr_in*)&itf->mask)->sin_port = port;
+       }
+#ifdef INCLUDE_IPV6_SUPPORT
+       else if (isc_if->af == AF_INET6) {
+               itf->sin.ss_family = (u_short) isc_if->af;
+               memcpy(&(((struct sockaddr_in6 *)&itf->sin)->sin6_addr),
+                      &(isc_if->address.type.in6),
+                      sizeof(((struct sockaddr_in6 *)&itf->sin)->sin6_addr));
+               ((struct sockaddr_in6 *)&itf->sin)->sin6_port = port;
+
+#ifdef ISC_PLATFORM_HAVESCOPEID
+               ((struct sockaddr_in6 *)&itf->sin)->sin6_scope_id = isc_netaddr_getzone(&isc_if->address);
+               itf->scopeid = isc_netaddr_getzone(&isc_if->address);
+#endif
+               itf->mask.ss_family = itf->sin.ss_family;
+               memcpy(&(((struct sockaddr_in6 *)&itf->mask)->sin6_addr),
+                      &(isc_if->netmask.type.in6),
+                      sizeof(struct in6_addr));
+               ((struct sockaddr_in6 *)&itf->mask)->sin6_port = port;
+               /* Copy the interface index */
+               itf->ifindex = isc_if->ifindex;
+       }
+#endif /* INCLUDE_IPV6_SUPPORT */
+
+
+       /* Process the rest of the flags */
+
+       if((isc_if->flags & INTERFACE_F_UP) != 0)
+               itf->flags |= INT_UP;
+       if((isc_if->flags & INTERFACE_F_LOOPBACK) != 0)
+               itf->flags |= INT_LOOPBACK;
+       if((isc_if->flags & INTERFACE_F_POINTTOPOINT) != 0)
+               itf->flags |= INT_PPP;
+       if((isc_if->flags & INTERFACE_F_MULTICAST) != 0)
+               itf->flags |= INT_MULTICAST;
+
+}
+
+/*
+ * refresh_interface
+ *
+ * some OSes have been observed to keep
+ * cached routes even when more specific routes
+ * become available.
+ * this can be mitigated by re-binding
+ * the socket.
+ */
+static int
+refresh_interface(struct interface * interface)
+{
+#ifdef  OS_MISSES_SPECIFIC_ROUTE_UPDATES
+       if (interface->fd != INVALID_SOCKET)
+       {
+               close_and_delete_fd_from_list(interface->fd);
+               interface->fd = open_socket(&interface->sin,
+                                           interface->flags, 0, interface);
+                /*
+                 * reset TTL indication so TTL is is set again 
+                 * next time around
+                 */
+               interface->last_ttl = 0;
+               return interface->fd != INVALID_SOCKET;
+       }
+       else
+       {
+               return 0;       /* invalid sockets are not refreshable */
+       }
+#else /* !OS_MISSES_SPECIFIC_ROUTE_UPDATES */
+       return interface->fd != INVALID_SOCKET;
+#endif /* !OS_MISSES_SPECIFIC_ROUTE_UPDATES */
+}
+
+/*
+ * interface_update - externally callable update function
+ */
+void
+interface_update(interface_receiver_t receiver, void *data)
+{
+       if (!disable_dynamic_updates) {
+               int new_interface_found;
+
+               BLOCKIO();
+               new_interface_found = update_interfaces(htons(NTP_PORT), receiver, data);
+               UNBLOCKIO();
+
+               if (new_interface_found) {
+#ifdef DEBUG
+                       msyslog(LOG_DEBUG, "new interface(s) found: waking up resolver");
+#endif
+#ifdef SYS_WINNT
+                       /* wake up the resolver thread */
+                       if (ResolverEventHandle != NULL)
+                               SetEvent(ResolverEventHandle);
+#else
+                       /* write any single byte to the pipe to wake up the resolver process */
+                       write( resolver_pipe_fd[1], &new_interface_found, 1 );
+#endif
+               }
+       }
+}
+
+/*
+ * find out if a given interface structure contains
+ * a wildcard address
+ */
+static int
+is_wildcard_addr(struct sockaddr_storage *sas)
+{
+       if (sas->ss_family == AF_INET &&
+           ((struct sockaddr_in*)sas)->sin_addr.s_addr == htonl(INADDR_ANY))
+               return 1;
+
+#ifdef INCLUDE_IPV6_SUPPORT
+       if (sas->ss_family == AF_INET6 &&
+           memcmp(&((struct sockaddr_in6*)sas)->sin6_addr, &in6addr_any,
+                  sizeof(in6addr_any) == 0))
+               return 1;
+#endif
+
+       return 0;
+}
+
+#ifdef OS_NEEDS_REUSEADDR_FOR_IFADDRBIND
+/*
+ * enable/disable re-use of wildcard address socket
+ */
+static void
+set_wildcard_reuse(int family, int on)
+{
+       int onvalue = 1;
+       int offvalue = 0;
+       int *onoff;
+       SOCKET fd = INVALID_SOCKET;
+
+       onoff = on ? &onvalue : &offvalue;
+
+       switch (family) {
+       case AF_INET:
+               if (any_interface) {
+                       fd = any_interface->fd;
+               }
+               break;
+
+#ifdef INCLUDE_IPV6_SUPPORT
+       case AF_INET6:
+               if (any6_interface) {
+                       fd = any6_interface->fd;
+               }
+               break;
+#endif /* !INCLUDE_IPV6_SUPPORT */
+       }
+
+       if (fd != INVALID_SOCKET) {
+               if (setsockopt(fd, SOL_SOCKET,
+                              SO_REUSEADDR, (char *)onoff,
+                              sizeof(*onoff))) {
+                       netsyslog(LOG_ERR, "set_wildcard_reuse: setsockopt(SO_REUSEADDR, %s) failed: %m", *onoff ? "on" : "off");
+               }
+               DPRINTF(4, ("set SO_REUSEADDR to %s on %s\n", *onoff ? "ON" : "OFF",
+                           stoa((family == AF_INET) ?
+                                 &any_interface->sin : &any6_interface->sin)));
+       }
+}
+#endif /* OS_NEEDS_REUSEADDR_FOR_IFADDRBIND */
+
+/*
+ * update_interface strategy
+ *
+ * toggle configuration phase
+ *
+ * Phase 1:
+ * forall currently existing interfaces
+ *   if address is known:
+ *       drop socket - rebind again
+ *
+ *   if address is NOT known:
+ *     attempt to create a new interface entry
+ *
+ * Phase 2:
+ * forall currently known non MCAST and WILDCARD interfaces
+ *   if interface does not match configuration phase (not seen in phase 1):
+ *     remove interface from known interface list
+ *     forall peers associated with this interface
+ *       disconnect peer from this interface
+ *
+ * Phase 3:
+ *   attempt to re-assign interfaces to peers
+ *
+ */
+
+static int
+update_interfaces(
+       u_short port,
+       interface_receiver_t receiver,
+       void *data
+       )
+{
+       interface_info_t ifi;
+       isc_mem_t *mctx = NULL;
+       isc_interfaceiter_t *iter = NULL;
+       isc_boolean_t scan_ipv4 = ISC_FALSE;
+       isc_boolean_t scan_ipv6 = ISC_FALSE;
+       isc_result_t result;
+       int new_interface_found = 0;
+
+       DPRINTF(3, ("update_interfaces(%d)\n", ntohs( (u_short) port)));
+
+#ifdef INCLUDE_IPV6_SUPPORT
+       if (isc_net_probeipv6() == ISC_R_SUCCESS)
+               scan_ipv6 = ISC_TRUE;
+#if defined(DEBUG)
+       else
+               if (debug)
+                       netsyslog(LOG_ERR, "no IPv6 interfaces found");
+#endif
+#endif
+       if (isc_net_probeipv6() == ISC_R_SUCCESS)
+               scan_ipv6 = ISC_TRUE;
+#if defined(ISC_PLATFORM_HAVEIPV6) && defined(DEBUG)
+       else
+               if (debug)
+                       netsyslog(LOG_ERR, "no IPv6 interfaces found");
+#endif
+
+       if (isc_net_probeipv4() == ISC_R_SUCCESS)
+               scan_ipv4 = ISC_TRUE;
+#ifdef DEBUG
+       else
+               if(debug)
+                       netsyslog(LOG_ERR, "no IPv4 interfaces found");
+#endif
+       /*
+        * phase one - scan interfaces
+        * - create those that are not found
+        * - update those that are found
+        */
+
+       result = isc_interfaceiter_create(mctx, &iter);
+
+       if (result != ISC_R_SUCCESS)
+               return 0;
+
+       sys_interphase ^= 0x1;  /* toggle system phase for finding untouched (to be deleted) interfaces */
+       
+       for (result = isc_interfaceiter_first(iter);
+            result == ISC_R_SUCCESS;
+            result = isc_interfaceiter_next(iter))
+       {
+               isc_interface_t isc_if;
+               unsigned int family;
+               struct interface interface;
+               struct interface *iface;
+               
+               result = isc_interfaceiter_current(iter, &isc_if);
+
+               if (result != ISC_R_SUCCESS)
+                       break;
+
+               /* See if we have a valid family to use */
+               family = isc_if.address.family;
+               if (family != AF_INET && family != AF_INET6)
+                       continue;
+               if (scan_ipv4 == ISC_FALSE && family == AF_INET)
+                       continue;
+               if (scan_ipv6 == ISC_FALSE && family == AF_INET6)
+                       continue;
+
+               /*
+                * create prototype
+                */
+               init_interface(&interface);
+
+               convert_isc_if(&isc_if, &interface, port);
+
+               /* 
+                * Check to see if we are going to use the interface
+                * If we don't use it we mark it to drop any packet
+                * received but we still must create the socket and
+                * bind to it. This prevents other apps binding to it
+                * and potentially causing problems with more than one
+                * process fiddling with the clock
+                */
+               if (address_okay(&interface) == ISC_TRUE) {
+                       interface.ignore_packets = ISC_FALSE;
+               }
+               else {
+                       interface.ignore_packets = ISC_TRUE;
+               }
+
+               DPRINT_INTERFACE(4, (&interface, "examining ", "\n"));
+
+               if (!(interface.flags & INT_UP))  { /* interfaces must be UP to be usable */
+                       DPRINTF(4, ("skipping interface %s (%s) - DOWN\n", interface.name, stoa(&interface.sin)));
+                       continue;
+               }
+
+               /*
+                * skip any interfaces UP and bound to a wildcard
+                * address - some dhcp clients produce that in the
+                * wild
+                */
+               if (is_wildcard_addr(&interface.sin))
+                       continue;
+
+               /*
+                * map to local *address* in order
+                * to map all duplicate interfaces to an interface structure
+                * with the appropriate socket (our name space is
+                * (ip-address) - NOT (interface name, ip-address))
+                */
+               iface = getinterface(&interface.sin, INT_WILDCARD);
+               
+               if (iface && refresh_interface(iface)) 
+               {
+                       /*
+                        * found existing and up to date interface - mark present
+                        */
+
+                       iface->phase = sys_interphase;
+                       DPRINT_INTERFACE(4, (iface, "updating ", " present\n"));
+                       ifi.action = IFS_EXISTS;
+                       ifi.interface = iface;
+                       if (receiver)
+                               receiver(data, &ifi);
+               }
+               else
+               {
+                       /*
+                        * this is new or refreshing failed - add to our interface list
+                        * if refreshing failed we will delete the interface structure in
+                        * phase 2 as the interface was not marked current. We can bind to
+                        * the address as the refresh code already closed the offending socket
+                        */
+                       
+                       iface = create_interface(port, &interface);
+
+                       if (iface)
+                       {
+                               ifi.action = IFS_CREATED;
+                               ifi.interface = iface;
+                               if (receiver)
+                                       receiver(data, &ifi);
+
+                               new_interface_found = 1;
+
+                               DPRINT_INTERFACE(3, (iface, "updating ", " new - created\n"));
+                       }
+                       else
+                       {
+                               DPRINT_INTERFACE(3, (&interface, "updating ", " new - creation FAILED"));
+                       
+                               msyslog(LOG_INFO, "failed to initialize interface for address %s", stoa(&interface.sin));
+                               continue;
+                       }
+               }
+       }
+
+       isc_interfaceiter_destroy(&iter);
+
+       /*
+        * phase 2 - delete gone interfaces - reassigning peers to other interfaces
+        */
+       {
+               struct interface *interf = ISC_LIST_HEAD(inter_list);
+
+               while (interf != NULL)
+               {
+                       struct interface *next = ISC_LIST_NEXT(interf, link);
+                         
+                       if (!(interf->flags & (INT_WILDCARD|INT_MCASTIF))) {
+                               /*
+                                * if phase does not match sys_phase this interface was not
+                                * enumerated during interface scan - so it is gone and
+                                * will be deleted here unless it is solely an MCAST/WILDCARD interface
+                                */
+                               if (interf->phase != sys_interphase) {
+                                       struct peer *peer;
+                                       DPRINT_INTERFACE(3, (interf, "updating ", "GONE - deleting\n"));
+                                       remove_interface(interf);
+
+                                       ifi.action = IFS_DELETED;
+                                       ifi.interface = interf;
+                                       if (receiver)
+                                               receiver(data, &ifi);
+
+                                       peer = ISC_LIST_HEAD(interf->peers);
+                                       /*
+                                        * disconnect peer from deleted interface
+                                        */
+                                       while (peer != NULL) {
+                                               struct peer *npeer = ISC_LIST_NEXT(peer, ilink);
+                                               
+                                               /*
+                                                * this one just lost it's interface
+                                                */
+                                               set_peerdstadr(peer, NULL);
+       
+                                               peer = npeer;
+                                       }
+
+                                       /*
+                                        * update globals in case we lose 
+                                        * a loopback interface
+                                        */
+                                       if (interf == loopback_interface)
+                                               loopback_interface = NULL;
+
+                                       delete_interface(interf);
+                               }
+                       }
+                       interf = next;
+               }
+       }
+
+       /*
+        * phase 3 - re-configure as the world has changed if necessary
+        */
+       refresh_all_peerinterfaces();
+       return new_interface_found;
+}
+
+
+/*
+ * create_sockets - create a socket for each interface plus a default
+ *                     socket for when we don't know where to send
+ */
+static int
+create_sockets(
+       u_short port
+       )
+{
+#ifndef HAVE_IO_COMPLETION_PORT
+       /*
+        * I/O Completion Ports don't care about the select and FD_SET
+        */
+       maxactivefd = 0;
+       FD_ZERO(&activefds);
+#endif
+
+       DPRINTF(2, ("create_sockets(%d)\n", ntohs( (u_short) port)));
+
+       create_wildcards(port);
+
+       update_interfaces(port, NULL, NULL);
+       
+       /*
+        * Now that we have opened all the sockets, turn off the reuse
+        * flag for security.
+        */
+       set_reuseaddr(0);
+
+       DPRINTF(2, ("create_sockets: Total interfaces = %d\n", ninterfaces));
+
+       return ninterfaces;
+}
+
+/*
+ * create_interface - create a new interface for a given prototype
+ *                   binding the socket.
+ */
+static struct interface *
+create_interface(
+                u_short port,
+                struct interface *iface
+                )
+{
+       struct sockaddr_storage resmask;
+       struct interface *interface;
+
+       DPRINTF(2, ("create_interface(%s#%d)\n", stoa(&iface->sin), ntohs( (u_short) port)));
+
+       /* build an interface */
+       interface = new_interface(iface);
+       
+       /*
+        * create socket
+        */
+       interface->fd = open_socket(&interface->sin,
+                                interface->flags, 0, interface);
+
+       if (interface->fd != INVALID_SOCKET)
+               list_if_listening(interface, port);
+
+       if ((interface->flags & INT_BROADCAST) &&
+           interface->bfd != INVALID_SOCKET)
+         msyslog(LOG_INFO, "Listening on broadcast address %s#%d",
+                 stoa((&interface->bcast)),
+                 ntohs( (u_short) port));
+
+       if (interface->fd == INVALID_SOCKET &&
+           interface->bfd == INVALID_SOCKET) {
+               msyslog(LOG_ERR, "unable to create socket on %s (%d) for %s#%d",
+                       interface->name,
+                       interface->ifnum,
+                       stoa((&interface->sin)),
+                       ntohs( (u_short) port));
+               delete_interface(interface);
+               return NULL;
+       }
+       
+        /*
+        * Blacklist bound interface address
+        */
+       
+       SET_HOSTMASK(&resmask, interface->sin.ss_family);
+       hack_restrict(RESTRICT_FLAGS, &interface->sin, &resmask,
+                     RESM_NTPONLY|RESM_INTERFACE, RES_IGNORE);
+         
+       /*
+        * set globals with the first found
+        * loopback interface of the appropriate class
+        */
+       if ((loopback_interface == NULL) &&
+           (interface->family == AF_INET) &&
+           ((interface->flags & INT_LOOPBACK) != 0))
+       {
+               loopback_interface = interface;
+       }
+
+       /*
+        * put into our interface list
+        */
+       add_addr_to_list(&interface->sin, interface);
+       add_interface(interface);
+
+       DPRINT_INTERFACE(2, (interface, "created ", "\n"));
+       return interface;
+}
+
+
+#ifdef SO_EXCLUSIVEADDRUSE
+static void
+set_excladdruse(int fd)
+{
+       int one = 1;
+       int failed;
+
+       failed = setsockopt(fd, SOL_SOCKET, SO_EXCLUSIVEADDRUSE,
+                           (char *)&one, sizeof(one));
+
+       if (failed)
+               netsyslog(LOG_ERR, 
+                         "setsockopt(%d, SO_EXCLUSIVEADDRUSE, on): %m", fd);
+}
+#endif  /* SO_EXCLUSIVEADDRUSE */
+
+
+/*
+ * set_reuseaddr() - set/clear REUSEADDR on all sockets
+ *                     NB possible hole - should we be doing this on broadcast
+ *                     fd's also?
+ */
+static void
+set_reuseaddr(int flag) {
+       struct interface *interf;
+
+#ifndef SO_EXCLUSIVEADDRUSE
+
+       for (interf = ISC_LIST_HEAD(inter_list);
+            interf != NULL;
+            interf = ISC_LIST_NEXT(interf, link)) {
+
+               if (interf->flags & INT_WILDCARD)
+                       continue;
+         
+               /*
+                * if interf->fd  is INVALID_SOCKET, we might have a adapter
+                * configured but not present
+                */
+               DPRINTF(4, ("setting SO_REUSEADDR on %.16s@%s to %s\n", interf->name, stoa(&interf->sin), flag ? "on" : "off"));
+               
+               if (interf->fd != INVALID_SOCKET) {
+                       if (setsockopt(interf->fd, SOL_SOCKET,
+                                       SO_REUSEADDR, (char *)&flag,
+                                       sizeof(flag))) {
+                               netsyslog(LOG_ERR, "set_reuseaddr: setsockopt(SO_REUSEADDR, %s) failed: %m", flag ? "on" : "off");
+                       }
+               }
+       }
+#endif /* ! SO_EXCLUSIVEADDRUSE */
+}
+
+/*
+ * This is just a wrapper around an internal function so we can
+ * make other changes as necessary later on
+ */
+void
+enable_broadcast(struct interface *iface, struct sockaddr_storage *baddr)
+{
+#ifdef SO_BROADCAST
+       socket_broadcast_enable(iface, iface->fd, baddr);
+#endif
+}
+
+#ifdef OPEN_BCAST_SOCKET 
+/*
+ * Enable a broadcast address to a given socket
+ * The socket is in the inter_list all we need to do is enable
+ * broadcasting. It is not this function's job to select the socket
+ */
+static isc_boolean_t
+socket_broadcast_enable(struct interface *iface, SOCKET fd, struct sockaddr_storage *maddr)
+{
+#ifdef SO_BROADCAST
+       int on = 1;
+
+       if (maddr->ss_family == AF_INET)
+       {
+               /* if this interface can support broadcast, set SO_BROADCAST */
+               if (setsockopt(fd, SOL_SOCKET, SO_BROADCAST,
+                              (char *)&on, sizeof(on)))
+               {
+                       netsyslog(LOG_ERR, "setsockopt(SO_BROADCAST) enable failure on address %s: %m",
+                               stoa(maddr));
+               }
+#ifdef DEBUG
+               else if (debug > 1) {
+                       printf("Broadcast enabled on socket %d for address %s\n",
+                               fd, stoa(maddr));
+               }
+#endif
+       }
+       iface->flags |= INT_BCASTOPEN;
+       return ISC_TRUE;
+#else
+       return ISC_FALSE;
+#endif /* SO_BROADCAST */
+}
+
+/*
+ * Remove a broadcast address from a given socket
+ * The socket is in the inter_list all we need to do is disable
+ * broadcasting. It is not this function's job to select the socket
+ */
+static isc_boolean_t
+socket_broadcast_disable(struct interface *iface, struct sockaddr_storage *maddr)
+{
+#ifdef SO_BROADCAST
+       int off = 0;    /* This seems to be OK as an int */
+
+       if (maddr->ss_family == AF_INET)
+       {
+               if (setsockopt(iface->fd, SOL_SOCKET, SO_BROADCAST,
+                              (char *)&off, sizeof(off)))
+               {
+                       netsyslog(LOG_ERR, "setsockopt(SO_BROADCAST) disable failure on address %s: %m",
+                               stoa(maddr));
+               }
+       }
+       iface->flags &= ~INT_BCASTOPEN;
+       return ISC_TRUE;
+#else
+       return ISC_FALSE;
+#endif /* SO_BROADCAST */
+}
+
+#endif /* OPEN_BCAST_SOCKET */
+/*
+ * Check to see if the address is a multicast address
+ */
+static isc_boolean_t
+addr_ismulticast(struct sockaddr_storage *maddr)
+{
+       switch (maddr->ss_family)
+       {
+       case AF_INET :
+               if (!IN_CLASSD(ntohl(((struct sockaddr_in*)maddr)->sin_addr.s_addr))) {
+                       DPRINTF(4, ("multicast address %s not class D\n", stoa(maddr)));
+                       return (ISC_FALSE);
+               }
+               else
+               {
+                       return (ISC_TRUE);
+               }
+
+       case AF_INET6 :
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+               if (!IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)maddr)->sin6_addr)) {
+                       DPRINTF(4, ("address %s not IPv6 multicast address\n", stoa(maddr)));
+                       return (ISC_FALSE);
+               }
+               else
+               {
+                       return (ISC_TRUE);
+               }
+
+/*
+ * If we don't have IPV6 support any IPV6 address is not multicast
+ */
+#else
+               return (ISC_FALSE);
+#endif
+       /*
+        * Never valid
+        */
+       default:
+               return (ISC_FALSE);
+       }
+}
+
+/*
+ * Multicast servers need to set the appropriate Multicast interface
+ * socket option in order for it to know which interface to use for
+ * send the multicast packet.
+ */
+void
+enable_multicast_if(struct interface *iface, struct sockaddr_storage *maddr)
+{
+#ifdef MCAST
+       /*u_char*/ TYPEOF_IP_MULTICAST_LOOP off = 0;
+
+       switch (maddr->ss_family)
+       {
+       case AF_INET:
+               if (setsockopt(iface->fd, IPPROTO_IP, IP_MULTICAST_IF,
+                  (char *)&(((struct sockaddr_in*)&iface->sin)->sin_addr.s_addr),
+                   sizeof(struct in_addr)) == -1) {
+                       netsyslog(LOG_ERR,
+                       "setsockopt IP_MULTICAST_IF failure: %m on socket %d, addr %s for multicast address %s",
+                       iface->fd, stoa(&iface->sin), stoa(maddr));
+                       return;
+               }
+#ifdef IP_MULTICAST_LOOP
+               /*
+                * Don't send back to itself, but allow it to fail to set it
+                */
+               if (setsockopt(iface->fd, IPPROTO_IP, IP_MULTICAST_LOOP,
+                      SETSOCKOPT_ARG_CAST &off, sizeof(off)) == -1) {
+                       netsyslog(LOG_ERR,
+                       "setsockopt IP_MULTICAST_LOOP failure: %m on socket %d, addr %s for multicast address %s",
+                       iface->fd, stoa(&iface->sin), stoa(maddr));
+               }
+#endif
+       DPRINTF(4, ("Added IPv4 multicast interface on socket %d, addr %s for multicast address %s\n",
+                           iface->fd, stoa(&iface->sin),
+                           stoa(maddr)));
+               break;
+
+       case AF_INET6:
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+               if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_MULTICAST_IF,
+                   (char *) &iface->scopeid, sizeof(iface->scopeid)) == -1) {
+                       netsyslog(LOG_ERR,
+                       "setsockopt IPV6_MULTICAST_IF failure: %m on socket %d, addr %s, scope %d for multicast address %s",
+                       iface->fd, stoa(&iface->sin), iface->scopeid,
+                       stoa(maddr));
+                       return;
+               }
+#ifdef IPV6_MULTICAST_LOOP
+               /*
+                * Don't send back to itself, but allow it to fail to set it
+                */
+               if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_MULTICAST_LOOP,
+                      (char *) &off, sizeof(off)) == -1) {
+                       netsyslog(LOG_ERR,
+                       "setsockopt IP_MULTICAST_LOOP failure: %m on socket %d, addr %s for multicast address %s",
+                       iface->fd, stoa(&iface->sin), stoa(maddr));
+               }
+#endif
+               DPRINTF(4, ("Added IPv6 multicast interface on socket %d, addr %s, scope %d for multicast address %s\n",
+                           iface->fd,  stoa(&iface->sin), iface->scopeid,
+                           stoa(maddr)));
+               break;
+#else
+               return;
+#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
+       }
+       return;
+#endif
+}
+
+/*
+ * Add a multicast address to a given socket
+ * The socket is in the inter_list all we need to do is enable
+ * multicasting. It is not this function's job to select the socket
+ */
+static isc_boolean_t
+socket_multicast_enable(struct interface *iface, int lscope, struct sockaddr_storage *maddr)
+{
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+       struct ipv6_mreq mreq6;
+       struct in6_addr iaddr6;
+#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
+
+       struct ip_mreq mreq;
+
+       if (find_addr_in_list(maddr)) {
+               DPRINTF(4, ("socket_multicast_enable(%s): already enabled\n", stoa(maddr)));
+               return ISC_TRUE;
+       }
+
+       switch (maddr->ss_family)
+       {
+       case AF_INET:
+               memset((char *)&mreq, 0, sizeof(mreq));
+               mreq.imr_multiaddr = (((struct sockaddr_in*)maddr)->sin_addr);
+               mreq.imr_interface.s_addr = htonl(INADDR_ANY);
+               if (setsockopt(iface->fd, IPPROTO_IP, IP_ADD_MEMBERSHIP,
+                       (char *)&mreq, sizeof(mreq)) == -1) {
+                       netsyslog(LOG_ERR,
+                       "setsockopt IP_ADD_MEMBERSHIP failure: %m on socket %d, addr %s for %x / %x (%s)",
+                       iface->fd, stoa(&iface->sin),
+                       mreq.imr_multiaddr.s_addr,
+                       mreq.imr_interface.s_addr, stoa(maddr));
+                       return ISC_FALSE;
+               }
+               DPRINTF(4, ("Added IPv4 multicast membership on socket %d, addr %s for %x / %x (%s)\n",
+                           iface->fd, stoa(&iface->sin),
+                           mreq.imr_multiaddr.s_addr,
+                           mreq.imr_interface.s_addr, stoa(maddr)));
+               break;
+
+       case AF_INET6:
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+               /*
+                * Enable reception of multicast packets
+                * If the address is link-local we can get the interface index
+                * from the scope id. Don't do this for other types of multicast
+                * addresses. For now let the kernel figure it out.
+                */
+               memset((char *)&mreq6, 0, sizeof(mreq6));
+               iaddr6 = ((struct sockaddr_in6*)maddr)->sin6_addr;
+               mreq6.ipv6mr_multiaddr = iaddr6;
+               mreq6.ipv6mr_interface = lscope;
+
+               if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_JOIN_GROUP,
+                       (char *)&mreq6, sizeof(mreq6)) == -1) {
+                       netsyslog(LOG_ERR,
+                        "setsockopt IPV6_JOIN_GROUP failure: %m on socket %d, addr %s for interface %d(%s)",
+                       iface->fd, stoa(&iface->sin),
+                       mreq6.ipv6mr_interface, stoa(maddr));
+                       return ISC_FALSE;
+               }
+               DPRINTF(4, ("Added IPv6 multicast group on socket %d, addr %s for interface %d(%s)\n",
+                           iface->fd, stoa(&iface->sin),
+                           mreq6.ipv6mr_interface, stoa(maddr)));
+               break;
+#else
+               return ISC_FALSE;
+#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
+       }
+       iface->flags |= INT_MCASTOPEN;
+       iface->num_mcast++;
+       add_addr_to_list(maddr, iface);
+       return ISC_TRUE;
+}
+
+/*
+ * Remove a multicast address from a given socket
+ * The socket is in the inter_list all we need to do is disable
+ * multicasting. It is not this function's job to select the socket
+ */
+static isc_boolean_t
+socket_multicast_disable(struct interface *iface, struct sockaddr_storage *maddr)
+{
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+       struct ipv6_mreq mreq6;
+       struct in6_addr iaddr6;
+#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
+
+       struct ip_mreq mreq;
+       memset((char *)&mreq, 0, sizeof(mreq));
+
+       if (find_addr_in_list(maddr) == NULL) {
+               DPRINTF(4, ("socket_multicast_disable(%s): not enabled\n", stoa(maddr)));
+               return ISC_TRUE;
+       }
+
+       switch (maddr->ss_family)
+       {
+       case AF_INET:
+               mreq.imr_multiaddr = (((struct sockaddr_in*)&maddr)->sin_addr);
+               mreq.imr_interface.s_addr = ((struct sockaddr_in*)&iface->sin)->sin_addr.s_addr;
+               if (setsockopt(iface->fd, IPPROTO_IP, IP_DROP_MEMBERSHIP,
+                       (char *)&mreq, sizeof(mreq)) == -1) {
+                       netsyslog(LOG_ERR,
+                       "setsockopt IP_DROP_MEMBERSHIP failure: %m on socket %d, addr %s for %x / %x (%s)",
+                       iface->fd, stoa(&iface->sin),
+                       mreq.imr_multiaddr.s_addr,
+                       mreq.imr_interface.s_addr, stoa(maddr));
+                       return ISC_FALSE;
+               }
+               break;
+       case AF_INET6:
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+               /*
+                * Disable reception of multicast packets
+                * If the address is link-local we can get the interface index
+                * from the scope id. Don't do this for other types of multicast
+                * addresses. For now let the kernel figure it out.
+                */
+               iaddr6 = ((struct sockaddr_in6*)&maddr)->sin6_addr;
+               mreq6.ipv6mr_multiaddr = iaddr6;
+               mreq6.ipv6mr_interface = iface->scopeid;
+
+               if (setsockopt(iface->fd, IPPROTO_IPV6, IPV6_LEAVE_GROUP,
+                       (char *)&mreq6, sizeof(mreq6)) == -1) {
+                       netsyslog(LOG_ERR,
+                       "setsockopt IPV6_LEAVE_GROUP failure: %m on socket %d, addr %s for %d(%s)",
+                       iface->fd, stoa(&iface->sin),
+                       mreq6.ipv6mr_interface, stoa(maddr));
+                       return ISC_FALSE;
+               }
+               break;
+#else
+               return ISC_FALSE;
+#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
+
+       }
+       iface->num_mcast--;
+       if (iface->num_mcast <= 0) {
+                iface->num_mcast = 0;
+               iface->flags &= ~INT_MCASTOPEN;
+       }
+       return ISC_TRUE;
+}
+
+/*
+ * io_setbclient - open the broadcast client sockets
+ */
+void
+io_setbclient(void)
+{
+#ifdef OPEN_BCAST_SOCKET 
+        struct interface *interf;
+       int nif = 0;
+       isc_boolean_t jstatus; 
+       SOCKET fd;
+
+       set_reuseaddr(1);
+
+       for (interf = ISC_LIST_HEAD(inter_list);
+            interf != NULL;
+            interf = ISC_LIST_NEXT(interf, link)) {
+               if (interf->flags & INT_WILDCARD)
+                       continue;
+         
+               /* use only allowed addresses */
+               if (interf->ignore_packets == ISC_TRUE)
+                       continue;
+               /* Only IPv4 addresses are valid for broadcast */
+               if (interf->sin.ss_family != AF_INET)
+                       continue;
+
+               /* Is this a broadcast address? */
+               if (!(interf->flags & INT_BROADCAST))
+                       continue;
+
+               /* Skip the loopback addresses */
+               if (interf->flags & INT_LOOPBACK)
+                       continue;
+
+               /* Do we already have the broadcast address open? */
+               if (interf->flags & INT_BCASTOPEN) {
+               /* account for already open interfaces to aviod misleading warning below */
+                       nif++;
+                       continue;
+               }
+
+               /*
+                * Try to open the broadcast address
+                */
+               interf->family = AF_INET;
+               interf->bfd = open_socket(&interf->bcast,
+                                   INT_BROADCAST, 0, interf);
+
+                /*
+                * If we succeeded then we use it otherwise
+                * enable the underlying address
+                */
+               if (interf->bfd == INVALID_SOCKET) {
+                       fd = interf->fd;
+               }
+               else {
+                       fd = interf->bfd;
+               }
+
+               /* Enable Broadcast on socket */
+               jstatus = socket_broadcast_enable(interf, fd, &interf->sin);
+               if (jstatus == ISC_TRUE)
+               {
+                       nif++;
+                       netsyslog(LOG_INFO,"io_setbclient: Opened broadcast client on interface #%d %s, socket: %d",
+                                 interf->ifnum, interf->name, fd);
+                       interf->addr_refid = addr2refid(&interf->sin);
+               }
+       }
+       set_reuseaddr(0);
+#ifdef DEBUG
+       if (debug)
+               if (nif > 0)
+                       printf("io_setbclient: Opened broadcast clients\n");
+#endif
+       if (nif == 0)
+               netsyslog(LOG_ERR, "Unable to listen for broadcasts, no broadcast interfaces available");
+#else
+       netsyslog(LOG_ERR, "io_setbclient: Broadcast Client disabled by build");
+#endif
+}
+
+/*
+ * io_unsetbclient - close the broadcast client sockets
+ */
+void
+io_unsetbclient(void)
+{
+        struct interface *interf;
+       isc_boolean_t lstatus;
+
+       for (interf = ISC_LIST_HEAD(inter_list);
+            interf != NULL;
+            interf = ISC_LIST_NEXT(interf, link))
+       {
+               if (interf->flags & INT_WILDCARD)
+                   continue;
+         
+               if (!(interf->flags & INT_BCASTOPEN))
+                   continue;
+               lstatus = socket_broadcast_disable(interf, &interf->sin);
+       }
+}
+
+/*
+ * io_multicast_add() - add multicast group address
+ */
+void
+io_multicast_add(
+       struct sockaddr_storage addr
+       )
+{
+#ifdef MCAST
+       struct interface *interface;
+#ifndef MULTICAST_NONEWSOCKET
+       struct interface *iface;
+#endif
+       int lscope = 0;
+       
+       /*
+        * Check to see if this is a multicast address
+        */
+       if (addr_ismulticast(&addr) == ISC_FALSE)
+               return;
+
+       /* If we already have it we can just return */
+       if (find_flagged_addr_in_list(&addr, INT_MCASTOPEN|INT_MCASTIF) != NULL)
+       {
+               netsyslog(LOG_INFO, "Duplicate request found for multicast address %s",
+                       stoa(&addr));
+               return;
+       }
+
+#ifndef MULTICAST_NONEWSOCKET
+       interface = new_interface(NULL);
+       
+       /*
+        * Open a new socket for the multicast address
+        */
+       interface->sin.ss_family = addr.ss_family;
+       interface->family = addr.ss_family;
+
+       switch(addr.ss_family) {
+       case AF_INET:
+               memcpy(&(((struct sockaddr_in *)&interface->sin)->sin_addr),
+                      &(((struct sockaddr_in*)&addr)->sin_addr),
+                      sizeof(struct in_addr));
+               ((struct sockaddr_in*)&interface->sin)->sin_port = htons(NTP_PORT);
+               memset(&((struct sockaddr_in*)&interface->mask)->sin_addr.s_addr, 0xff, sizeof(struct in_addr));
+               break;
+       case AF_INET6:
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+               memcpy(&(((struct sockaddr_in6 *)&interface->sin)->sin6_addr),
+                      &((struct sockaddr_in6*)&addr)->sin6_addr,
+                      sizeof(struct in6_addr));
+               ((struct sockaddr_in6*)&interface->sin)->sin6_port = htons(NTP_PORT);
+#ifdef ISC_PLATFORM_HAVESCOPEID
+               ((struct sockaddr_in6*)&interface->sin)->sin6_scope_id = ((struct sockaddr_in6*)&addr)->sin6_scope_id;
+#endif
+               memset(&((struct sockaddr_in6*)&interface->mask)->sin6_addr.s6_addr, 0xff, sizeof(struct in6_addr));
+#endif
+               iface = findlocalcastinterface(&addr, INT_MULTICAST);
+               if (iface) {
+# ifdef ISC_PLATFORM_HAVESCOPEID
+                       lscope = ((struct sockaddr_in6*)&iface->sin)->sin6_scope_id;
+# endif
+                       DPRINTF(4, ("Found interface #%d %s, scope: %d for address %s\n", iface->ifnum, iface->name, lscope, stoa(&addr)));
+               }
+               break;
+       }
+               
+       set_reuseaddr(1);
+       interface->bfd = INVALID_SOCKET;
+       interface->fd = open_socket(&interface->sin,
+                           INT_MULTICAST, 0, interface);
+
+       if (interface->fd != INVALID_SOCKET)
+       {
+               interface->bfd = INVALID_SOCKET;
+               interface->ignore_packets = ISC_FALSE;
+               interface->flags |= INT_MCASTIF;
+               
+               (void) strncpy(interface->name, "multicast",
+                       sizeof(interface->name));
+               ((struct sockaddr_in*)&interface->mask)->sin_addr.s_addr =
+                                               htonl(~(u_int32)0);
+               DPRINT_INTERFACE(2, (interface, "multicast add ", "\n"));
+               /* socket_multicast_enable() will add this address to the addresslist */
+               add_interface(interface);
+               list_if_listening(interface, htons(NTP_PORT));
+       }
+       else
+       {
+               delete_interface(interface);  /* re-use existing interface */
+               interface = NULL;
+               if (addr.ss_family == AF_INET)
+                       interface = wildipv4;
+               else if (addr.ss_family == AF_INET6)
+                       interface = wildipv6;
+
+               if (interface != NULL) {
+                       /* HACK ! -- stuff in an address */
+                       interface->bcast = addr;
+                       netsyslog(LOG_ERR,
+                        "...multicast address %s using wildcard interface #%d %s",
+                                 stoa(&addr), interface->ifnum, interface->name);
+               } else {
+                       netsyslog(LOG_ERR,
+                       "No multicast socket available to use for address %s",
+                       stoa(&addr));
+                       return;
+               }
+       }
+#else
+       /*
+        * For the case where we can't use a separate socket
+        */
+       interface = findlocalcastinterface(&addr, INT_MULTICAST);
+       /*
+        * If we don't have a valid socket, just return
+        */
+       if (!interface)
+       {
+               netsyslog(LOG_ERR,
+               "Cannot add multicast address %s: Cannot find slot",
+               stoa(&addr));
+               return;
+       }
+
+#endif
+       {
+               isc_boolean_t jstatus;
+               jstatus = socket_multicast_enable(interface, lscope, &addr);
+       
+               if (jstatus == ISC_TRUE)
+                       netsyslog(LOG_INFO, "Added Multicast Listener %s on interface #%d %s\n", stoa(&addr), interface->ifnum, interface->name);
+               else
+                       netsyslog(LOG_ERR, "Failed to add Multicast Listener %s\n", stoa(&addr));
+       }
+#else /* MCAST */
+       netsyslog(LOG_ERR,
+                 "Cannot add multicast address %s: no Multicast support",
+                 stoa(&addr));
+#endif /* MCAST */
+       return;
+}
+
+/*
+ * io_multicast_del() - delete multicast group address
+ */
+void
+io_multicast_del(
+       struct sockaddr_storage addr
+       )
+{
+#ifdef MCAST
+        struct interface *interface;
+       isc_boolean_t lstatus;
+
+       /*
+        * Check to see if this is a multicast address
+        */
+       if (addr_ismulticast(&addr) == ISC_FALSE)
+       {
+               netsyslog(LOG_ERR,
+                        "invalid multicast address %s", stoa(&addr));
+               return;
+       }
+
+       switch (addr.ss_family)
+       {
+       case AF_INET :
+               /*
+                * Disable reception of multicast packets
+                */
+               interface = find_flagged_addr_in_list(&addr, INT_MCASTOPEN);
+               while ( interface != NULL) {
+                       lstatus = socket_multicast_disable(interface, &addr);
+                       interface = find_flagged_addr_in_list(&addr, INT_MCASTOPEN);
+               }
+               break;
+
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+       case AF_INET6 :
+               /*
+                * Disable reception of multicast packets
+                */
+               for (interface = ISC_LIST_HEAD(inter_list);
+                    interface != NULL;
+                    interface = ISC_LIST_NEXT(interface, link))
+               {
+                        if (interface->flags & INT_WILDCARD)
+                               continue;
+         
+                       /* Be sure it's the correct family */
+                       if (interface->sin.ss_family != AF_INET6)
+                               continue;
+                       if (!(interface->flags & INT_MCASTOPEN))
+                               continue;
+                       if (!(interface->fd < 0))
+                               continue;
+                       if (!SOCKCMP(&addr, &interface->sin))
+                               continue;
+                       lstatus = socket_multicast_disable(interface, &addr);
+               }
+               break;
+#endif /* INCLUDE_IPV6_MULTICAST_SUPPORT */
+
+       }/* switch */
+
+        delete_addr_from_list(&addr);
+
+#else /* not MCAST */
+       netsyslog(LOG_ERR, "this function requires multicast kernel");
+#endif /* not MCAST */
+}
+
+/*
+ * init_nonblocking_io() - set up descriptor to be non blocking
+ */
+static void init_nonblocking_io(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)
+       {
+               netsyslog(LOG_ERR, "fcntl(O_NONBLOCK) fails on fd #%d: %m",
+                       fd);
+               exit(1);
+               /*NOTREACHED*/
+       }
+#elif defined(FNDELAY)
+       if (fcntl(fd, F_SETFL, FNDELAY) < 0)
+       {
+               netsyslog(LOG_ERR, "fcntl(FNDELAY) fails on fd #%d: %m",
+                       fd);
+               exit(1);
+               /*NOTREACHED*/
+       }
+#elif defined(O_NDELAY) /* generally the same as FNDELAY */
+       if (fcntl(fd, F_SETFL, O_NDELAY) < 0)
+       {
+               netsyslog(LOG_ERR, "fcntl(O_NDELAY) fails on fd #%d: %m",
+                       fd);
+               exit(1);
+               /*NOTREACHED*/
+       }
+#elif defined(FIONBIO)
+       {
+               int on = 1;
+               if (ioctl(fd,FIONBIO,&on) < 0)
+               {
+                       netsyslog(LOG_ERR, "ioctl(FIONBIO) fails on fd #%d: %m",
+                               fd);
+                       exit(1);
+                       /*NOTREACHED*/
+               }
+       }
+#elif defined(FIOSNBIO)
+       if (ioctl(fd,FIOSNBIO,&on) < 0)
+       {
+               netsyslog(LOG_ERR, "ioctl(FIOSNBIO) fails on fd #%d: %m",
+                       fd);
+               exit(1);
+               /*NOTREACHED*/
+       }
+#else
+# include "Bletch: Need non-blocking I/O!"
+#endif
+}
+
+/*
+ * open_socket - open a socket, returning the file descriptor
+ */
+
+static SOCKET
+open_socket(
+       struct sockaddr_storage *addr,
+       int flags,
+       int turn_off_reuse,
+       struct interface *interf
+       )
+{
+       int errval;
+       SOCKET fd;
+       /*
+        * int is OK for REUSEADR per 
+        * http://www.kohala.com/start/mcast.api.txt
+        */
+       int on = 1;
+       int off = 0;
+
+#if defined(IPTOS_LOWDELAY) && defined(IPPROTO_IP) && defined(IP_TOS)
+       int tos;
+#endif /* IPTOS_LOWDELAY && IPPROTO_IP && IP_TOS */
+
+       if ((addr->ss_family == AF_INET6) && (isc_net_probeipv6() != ISC_R_SUCCESS))
+               return (INVALID_SOCKET);
+
+       /* create a datagram (UDP) socket */
+       fd = socket(addr->ss_family, SOCK_DGRAM, 0);
+       if (INVALID_SOCKET == fd) {
+#ifndef SYS_WINNT
+               errval = errno;
+#else
+               errval = WSAGetLastError();
+#endif
+               netsyslog(LOG_ERR, 
+                         "socket(AF_INET%s, SOCK_DGRAM, 0) failed on address %s: %m",
+                         (addr->ss_family == AF_INET6) ? "6" : "",
+                         stoa(addr));
+
+               if (errval == EPROTONOSUPPORT || 
+                   errval == EAFNOSUPPORT ||
+                   errval == EPFNOSUPPORT)
+                       return (INVALID_SOCKET);
+               msyslog(LOG_ERR, "unexpected error code %d (not PROTONOSUPPORT|AFNOSUPPORT|FPNOSUPPORT) - exiting", errval);
+               exit(1);
+               /*NOTREACHED*/
+       }
+
+#ifdef SYS_WINNT
+       connection_reset_fix(fd, addr);
+#endif
+       /*
+        * Fixup the file descriptor for some systems
+        * See bug #530 for details of the issue.
+        */
+       fd = move_fd(fd);
+
+       /*
+        * set SO_REUSEADDR since we will be binding the same port
+        * number on each interface according to turn_off_reuse.
+        * This is undesirable on Windows versions starting with
+        * Windows XP (numeric version 5.1).
+        */
+#ifdef SYS_WINNT
+       if (isc_win32os_versioncheck(5, 1, 0, 0) < 0)  /* before 5.1 */
+#endif
+               if (setsockopt(fd, SOL_SOCKET, SO_REUSEADDR,
+                              (char *)(turn_off_reuse 
+                                       ? &off 
+                                       : &on), 
+                              sizeof(on))) {
+
+                       netsyslog(LOG_ERR, "setsockopt SO_REUSEADDR %s"
+                                          " fails for address %s: %m",
+                                          turn_off_reuse 
+                                               ? "off" 
+                                               : "on", 
+                                          stoa(addr));
+                       closesocket(fd);
+                       return INVALID_SOCKET;
+               }
+#ifdef SO_EXCLUSIVEADDRUSE
+       /*
+        * setting SO_EXCLUSIVEADDRUSE on the wildcard we open
+        * first will cause more specific binds to fail.
+        */
+       if (!(interf->flags & INT_WILDCARD))
+               set_excladdruse(fd);
+#endif
+
+       /*
+        * IPv4 specific options go here
+        */
+       if (addr->ss_family == AF_INET) {
+#if defined(IPTOS_LOWDELAY) && defined(IPPROTO_IP) && defined(IP_TOS)
+       /* set IP_TOS to minimize packet delay */
+               tos = IPTOS_LOWDELAY;
+               if (setsockopt(fd, IPPROTO_IP, IP_TOS, (char *) &tos, sizeof(tos)) < 0)
+               {
+                       netsyslog(LOG_ERR, "setsockopt IPTOS_LOWDELAY on fails on address %s: %m",
+                               stoa(addr));
+               }
+#endif /* IPTOS_LOWDELAY && IPPROTO_IP && IP_TOS */
+       }
+
+       /*
+        * IPv6 specific options go here
+        */
+        if (addr->ss_family == AF_INET6) {
+#if defined(IPV6_V6ONLY)
+                if (setsockopt(fd, IPPROTO_IPV6, IPV6_V6ONLY,
+                       (char*)&on, sizeof(on)))
+                {
+                       netsyslog(LOG_ERR, "setsockopt IPV6_V6ONLY on fails on address %s: %m",
+                               stoa(addr));
+               }
+#endif /* IPV6_V6ONLY */
+#if defined(IPV6_BINDV6ONLY)
+                if (setsockopt(fd, IPPROTO_IPV6, IPV6_BINDV6ONLY,
+                       (char*)&on, sizeof(on)))
+                {
+                       netsyslog(LOG_ERR,
+                           "setsockopt IPV6_BINDV6ONLY on fails on address %s: %m",
+                           stoa(addr));
+               }
+#endif /* IPV6_BINDV6ONLY */
+       }
+
+#ifdef OS_NEEDS_REUSEADDR_FOR_IFADDRBIND
+       /*
+        * some OSes don't allow binding to more specific
+        * addresses if a wildcard address already bound
+        * to the port and SO_REUSEADDR is not set
+        */
+       if (!is_wildcard_addr(addr)) {
+               set_wildcard_reuse(addr->ss_family, 1);
+       }
+#endif
+
+       /*
+        * bind the local address.
+        */
+       errval = bind(fd, (struct sockaddr *)addr, SOCKLEN(addr));
+
+#ifdef OS_NEEDS_REUSEADDR_FOR_IFADDRBIND
+       /*
+        * some OSes don't allow binding to more specific
+        * addresses if a wildcard address already bound
+        * to the port and REUSE_ADDR is not set
+        */
+       if (!is_wildcard_addr(addr)) {
+               set_wildcard_reuse(addr->ss_family, 0);
+       }
+#endif
+
+       if (errval < 0) {
+               /*
+                * Don't log this under all conditions
+                */
+               if (turn_off_reuse == 0
+#ifdef DEBUG
+                   || debug > 1
+#endif
+                       ) {
+                       if (addr->ss_family == AF_INET)
+                               netsyslog(LOG_ERR,
+                                         "bind() fd %d, family AF_INET, port %d, addr %s, in_classd=%d flags=0x%x fails: %m",
+                                         fd, (int)ntohs(((struct sockaddr_in*)addr)->sin_port),
+                                         stoa(addr),
+                                         IN_CLASSD(ntohl(((struct sockaddr_in*)addr)->sin_addr.s_addr)), 
+                                         flags);
+#ifdef INCLUDE_IPV6_SUPPORT
+                       else if (addr->ss_family == AF_INET6)
+                               netsyslog(LOG_ERR,
+                                         "bind() fd %d, family AF_INET6, port %d, scope %d, addr %s, mcast=%d flags=0x%x fails: %m",
+                                         fd, (int)ntohs(((struct sockaddr_in6*)addr)->sin6_port),
+# ifdef ISC_PLATFORM_HAVESCOPEID
+                                         ((struct sockaddr_in6*)addr)->sin6_scope_id
+# else
+                                         -1
+# endif
+                                         , stoa(addr),
+                                         IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)addr)->sin6_addr), 
+                                         flags);
+#endif
+               }
+
+               closesocket(fd);
+               
+               return INVALID_SOCKET;
+       }
+
+#ifdef HAVE_TIMESTAMP
+       {
+               if (setsockopt(fd, SOL_SOCKET, SO_TIMESTAMP,
+                              (char*)&on, sizeof(on)))
+               {
+                       netsyslog(LOG_DEBUG,
+                                 "setsockopt SO_TIMESTAMP on fails on address %s: %m",
+                                 stoa(addr));
+               }
+#ifdef DEBUG
+               else
+               {
+                       DPRINTF(4, ("setsockopt SO_TIMESTAMP enabled on fd %d address %s\n", fd, stoa(addr)));
+               }
+#endif
+       }       
+#endif
+       DPRINTF(4, ("bind() fd %d, family %d, port %d, addr %s, flags=0x%x\n",
+                  fd,
+                  addr->ss_family,
+                  (int)ntohs(((struct sockaddr_in*)addr)->sin_port),
+                  stoa(addr),
+                  interf->flags));
+
+       init_nonblocking_io(fd);
+       
+#ifdef HAVE_SIGNALED_IO
+       init_socket_sig(fd);
+#endif /* not HAVE_SIGNALED_IO */
+
+       add_fd_to_list(fd, FD_TYPE_SOCKET);
+
+#if !defined(SYS_WINNT) && !defined(VMS)
+       DPRINTF(4, ("flags for fd %d: 0x%x\n", fd,
+                   fcntl(fd, F_GETFL, 0)));
+#endif /* SYS_WINNT || VMS */
+
+#if defined (HAVE_IO_COMPLETION_PORT)
+/*
+ * Add the socket to the completion port
+ */
+       if (io_completion_port_add_socket(fd, interf))
+       {
+               msyslog(LOG_ERR, "unable to set up io completion port - EXITING");
+               exit(1);
+       }
+#endif
+       return fd;
+}
+
+/* XXX ELIMINATE sendpkt similar in ntpq.c, ntpdc.c, ntp_io.c, ntptrace.c */
+/*
+ * sendpkt - send a packet to the specified destination. Maintain a
+ * send error cache so that only the first consecutive error for a
+ * destination is logged.
+ */
+void
+sendpkt(
+       struct sockaddr_storage *dest,
+       struct interface *inter,
+       int ttl,
+       struct pkt *pkt,
+       int len
+       )
+{
+       int cc, slot;
+
+       /*
+        * Send error caches. Empty slots have port == 0
+        * Set ERRORCACHESIZE to 0 to disable
+        */
+       struct cache {
+               u_short port;
+               struct  in_addr addr;
+       };
+
+#ifdef INCLUDE_IPV6_SUPPORT
+       struct cache6 {
+               u_short port;
+               struct in6_addr addr;
+       };
+#endif /* INCLUDE_IPV6_SUPPORT */
+
+
+#ifndef ERRORCACHESIZE
+#define ERRORCACHESIZE 8
+#endif
+#if ERRORCACHESIZE > 0
+       static struct cache badaddrs[ERRORCACHESIZE];
+#ifdef INCLUDE_IPV6_SUPPORT
+       static struct cache6 badaddrs6[ERRORCACHESIZE];
+#endif /* INCLUDE_IPV6_SUPPORT */
+#else
+#define badaddrs ((struct cache *)0)           /* Only used in empty loops! */
+#ifdef INCLUDE_IPV6_SUPPORT
+#define badaddrs6 ((struct cache6 *)0)         /* Only used in empty loops! */
+#endif /* INCLUDE_IPV6_SUPPORT */
+#endif
+#ifdef DEBUG
+       if (debug > 1)
+         {
+           if (inter != NULL) 
+             {
+               printf("%ssendpkt(fd=%d dst=%s, src=%s, ttl=%d, len=%d)\n",
+                      (ttl > 0) ? "\tMCAST\t***** " : "",
+                      inter->fd, stoa(dest),
+                      stoa(&inter->sin), ttl, len);
+             }
+           else
+             {
+               printf("%ssendpkt(dst=%s, ttl=%d, len=%d): no interface - IGNORED\n",
+                      (ttl > 0) ? "\tMCAST\t***** " : "",
+                      stoa(dest),
+                      ttl, len);
+             }
+         }
+#endif
+
+       if (inter == NULL)      /* unbound peer - drop request and wait for better network conditions */
+         return;
+       
+#ifdef MCAST
+
+       /*
+        * for the moment we use the bcast option to set multicast ttl
+        */
+       if (ttl > 0 && ttl != inter->last_ttl) {
+               
+               /*
+                * set the multicast ttl for outgoing packets
+                */
+               int rtc;
+               
+               switch (inter->sin.ss_family) {
+                       
+               case AF_INET :
+               {
+                       u_char mttl = (u_char) ttl;
+
+                       rtc = setsockopt(inter->fd, IPPROTO_IP, IP_MULTICAST_TTL,
+                                        (const void *) &mttl, sizeof(mttl));
+                       break;
+               }
+                       
+#ifdef INCLUDE_IPV6_SUPPORT
+               case AF_INET6 :
+               {
+                       u_int ittl = (u_char) ttl;
+
+                       rtc = setsockopt(inter->fd, IPPROTO_IPV6, IPV6_MULTICAST_HOPS,
+                                        (const void *) &ittl, sizeof(ittl));
+                       break;
+               }
+
+#endif /* INCLUDE_IPV6_SUPPORT */
+               default:        /* just NOP if not supported */
+                       rtc = 0;
+                       break;
+               }
+               
+               if (rtc != 0) {
+                       netsyslog(LOG_ERR, "setsockopt IP_MULTICAST_TTL/IPV6_MULTICAST_HOPS fails on address %s: %m",
+                                 stoa(&inter->sin));
+               }
+               else
+                       inter->last_ttl = ttl;
+       }
+
+#endif /* MCAST */
+
+       for (slot = ERRORCACHESIZE; --slot >= 0; )
+               if(dest->ss_family == AF_INET) {
+                       if (badaddrs[slot].port == ((struct sockaddr_in*)dest)->sin_port &&
+                               badaddrs[slot].addr.s_addr == ((struct sockaddr_in*)dest)->sin_addr.s_addr)
+                       break;
+               }
+#ifdef INCLUDE_IPV6_SUPPORT
+               else if (dest->ss_family == AF_INET6) {
+                       if (badaddrs6[slot].port == ((struct sockaddr_in6*)dest)->sin6_port &&
+                               badaddrs6[slot].addr.s6_addr == ((struct sockaddr_in6*)dest)->sin6_addr.s6_addr)
+                       break;
+               }
+#endif /* INCLUDE_IPV6_SUPPORT */
+
+#if defined(HAVE_IO_COMPLETION_PORT)
+        cc = io_completion_port_sendto(inter, pkt, len, dest);
+       if (cc != ERROR_SUCCESS)
+#else
+#ifdef SIM
+        cc = srvr_rply(&ntp_node,  dest, inter, pkt);
+#else /* SIM */
+       cc = sendto(inter->fd, (char *)pkt, (unsigned int)len, 0, (struct sockaddr *)dest,
+                   SOCKLEN(dest));
+#endif /* SIM */
+       if (cc == -1)
+#endif
+       {
+               inter->notsent++;
+               packets_notsent++;
+
+#if defined(HAVE_IO_COMPLETION_PORT)
+               if (cc != WSAEWOULDBLOCK && cc != WSAENOBUFS && slot < 0)
+#else
+               if (errno != EWOULDBLOCK && errno != ENOBUFS && slot < 0)
+#endif
+               {
+                       /*
+                        * Remember this, if there's an empty slot
+                        */
+                       switch (dest->ss_family) {
+
+                       case AF_INET :
+
+                               for (slot = ERRORCACHESIZE; --slot >= 0; )
+                                       if (badaddrs[slot].port == 0)
+                                       {
+                                               badaddrs[slot].port = SRCPORT(dest);
+                                               badaddrs[slot].addr = ((struct sockaddr_in*)dest)->sin_addr;
+                                               break;
+                                       }
+                               break;
+
+#ifdef INCLUDE_IPV6_SUPPORT
+                       case AF_INET6 :
+
+                               for (slot = ERRORCACHESIZE; --slot >= 0; )
+                                       if (badaddrs6[slot].port == 0)
+                                       {
+                                               badaddrs6[slot].port = SRCPORT(dest);
+                                               badaddrs6[slot].addr = ((struct sockaddr_in6*)dest)->sin6_addr;
+                                               break;
+                                       }
+                               break;
+#endif /* INCLUDE_IPV6_SUPPORT */
+                       default:  /* don't care if not supported */
+                               break;
+                       }
+
+                       netsyslog(LOG_ERR, "sendto(%s) (fd=%d): %m",
+                                 stoa(dest), inter->fd);
+               }
+       }
+       else
+       {
+               inter->sent++;
+               packets_sent++;
+               /*
+                * He's not bad any more
+                */
+               if (slot >= 0)
+               {
+                       netsyslog(LOG_INFO, "Connection re-established to %s", stoa(dest));
+                       switch (dest->ss_family) {
+                       case AF_INET :
+                               badaddrs[slot].port = 0;
+                               break;
+#ifdef INCLUDE_IPV6_SUPPORT
+                       case AF_INET6 :
+                               badaddrs6[slot].port = 0;
+                               break;
+#endif /* INCLUDE_IPV6_SUPPORT */
+                       default:  /* don't care if not supported */
+                               break;
+                       }
+               }
+       }
+}
+
+#if !defined(HAVE_IO_COMPLETION_PORT)
+/*
+ * fdbits - generate ascii representation of fd_set (FAU debug support)
+ * HFDF format - highest fd first.
+ */
+static char *
+fdbits(
+       int count,
+       fd_set *set
+       )
+{
+       static char buffer[256];
+       char * buf = buffer;
+
+       count = (count < 256) ? count : 255;
+
+       while (count >= 0)
+       {
+               *buf++ = FD_ISSET(count, set) ? '#' : '-';
+               count--;
+       }
+       *buf = '\0';
+
+       return buffer;
+}
+
+/*
+ * Routine to read the refclock packets for a specific interface
+ * Return the number of bytes read. That way we know if we should
+ * read it again or go on to the next one if no bytes returned
+ */
+static inline int
+read_refclock_packet(SOCKET fd, struct refclockio *rp, l_fp ts)
+{
+       int i;
+       int buflen;
+       register struct recvbuf *rb;
+
+       rb = get_free_recv_buffer();
+
+       if (rb == NULL)
+       {
+               /*
+                * No buffer space available - just drop the packet
+                */
+               char buf[RX_BUFF_SIZE];
+
+               buflen = read(fd, buf, sizeof buf);
+               packets_dropped++;
+               return (buflen);
+       }
+
+       i = (rp->datalen == 0
+           || rp->datalen > sizeof(rb->recv_space))
+           ? sizeof(rb->recv_space) : rp->datalen;
+       buflen = read(fd, (char *)&rb->recv_space, (unsigned)i);
+
+       if (buflen < 0)
+       {
+               if (errno != EINTR && errno != EAGAIN) {
+                       netsyslog(LOG_ERR, "clock read fd %d: %m", fd);
+               }
+               freerecvbuf(rb);
+               return (buflen);
+       }
+
+       /*
+        * Got one. Mark how and when it got here,
+        * put it on the full list and do bookkeeping.
+        */
+       rb->recv_length = buflen;
+       rb->recv_srcclock = rp->srcclock;
+       rb->dstadr = 0;
+       rb->fd = fd;
+       rb->recv_time = ts;
+       rb->receiver = rp->clock_recv;
+
+       if (rp->io_input)
+       {
+               /*
+                * have direct input routine for refclocks
+                */
+               if (rp->io_input(rb) == 0)
+               {
+                       /*
+                        * data was consumed - nothing to pass up
+                        * into block input machine
+                        */
+                       freerecvbuf(rb);
+                       return (buflen);
+               }
+       }
+       
+       add_full_recv_buffer(rb);
+
+       rp->recvcount++;
+       packets_received++;
+       return (buflen);
+}
+
+#ifdef HAVE_TIMESTAMP
+/*
+ * extract timestamps from control message buffer
+ */
+static l_fp
+       fetch_timestamp(struct recvbuf *rb, struct msghdr *msghdr, l_fp ts)
+{
+#ifdef USE_TIMESTAMP_CMSG
+       struct cmsghdr *cmsghdr;
+
+       cmsghdr = CMSG_FIRSTHDR(msghdr);
+       while (cmsghdr != NULL) {
+               switch (cmsghdr->cmsg_type)
+               {
+               case SCM_TIMESTAMP:
+               {
+                       struct timeval *tvp = (struct timeval *)CMSG_DATA(cmsghdr);
+                       double dtemp;
+                       l_fp nts;
+                       DPRINTF(4, ("fetch_timestamp: system network time stamp: %ld.%06ld\n", tvp->tv_sec, tvp->tv_usec));
+                       nts.l_i = tvp->tv_sec + JAN_1970;
+                       dtemp = tvp->tv_usec / 1e6;
+
+                       /* fuzz lower bits not covered by precision */
+                       if (sys_precision != 0)
+                               dtemp += (ntp_random() / FRAC - .5) / (1 <<
+                                                                      -sys_precision);
+
+                       nts.l_uf = (u_int32)(dtemp*FRAC);
+#ifdef DEBUG_TIMING
+                       {
+                               l_fp dts = ts;
+                               L_SUB(&dts, &nts);
+                               collect_timing(rb, "input processing delay", 1, &dts);
+                               DPRINTF(4, ("fetch_timestamp: timestamp delta: %s (incl. prec fuzz)\n", lfptoa(&dts, 9)));
+                       }
+#endif
+                       ts = nts;  /* network time stamp */
+                       break;
+               }
+               default:
+                       DPRINTF(4, ("fetch_timestamp: skipping control message 0x%x\n", cmsghdr->cmsg_type));
+                       break;
+               }
+               cmsghdr = CMSG_NXTHDR(msghdr, cmsghdr);
+       }
+#endif
+       return ts;
+}
+#endif
+
+/*
+ * Routine to read the network NTP packets for a specific interface
+ * Return the number of bytes read. That way we know if we should
+ * read it again or go on to the next one if no bytes returned
+ */
+static inline int
+read_network_packet(SOCKET fd, struct interface *itf, l_fp ts)
+{
+       GETSOCKNAME_SOCKLEN_TYPE fromlen;
+       int buflen;
+       register struct recvbuf *rb;
+#ifdef HAVE_TIMESTAMP
+       struct msghdr msghdr;
+       struct iovec iovec;
+       char control[TIMESTAMP_CTLMSGBUF_SIZE]; /* pick up control messages */
+#endif
+
+       /*
+        * Get a buffer and read the frame.  If we
+        * haven't got a buffer, or this is received
+        * on a disallowed socket, just dump the
+        * packet.
+        */
+
+       rb = get_free_recv_buffer();
+
+       if (rb == NULL || itf->ignore_packets == ISC_TRUE)
+       {
+               char buf[RX_BUFF_SIZE];
+               struct sockaddr_storage from;
+               if (rb != NULL)
+                       freerecvbuf(rb);
+
+               fromlen = sizeof(from);
+               buflen = recvfrom(fd, buf, sizeof(buf), 0,
+                               (struct sockaddr*)&from, &fromlen);
+               DPRINTF(4, ("%s on (%lu) fd=%d from %s\n",
+                       (itf->ignore_packets == ISC_TRUE) ? "ignore" : "drop",
+                       free_recvbuffs(), fd,
+                       stoa(&from)));
+               if (itf->ignore_packets == ISC_TRUE)
+                       packets_ignored++;
+               else
+                       packets_dropped++;
+               return (buflen);
+       }
+
+       fromlen = sizeof(struct sockaddr_storage);
+
+#ifndef HAVE_TIMESTAMP
+       rb->recv_length = recvfrom(fd,
+                         (char *)&rb->recv_space,
+                          sizeof(rb->recv_space), 0,
+                          (struct sockaddr *)&rb->recv_srcadr,
+                          &fromlen);
+#else
+       iovec.iov_base        = (void *)&rb->recv_space;
+       iovec.iov_len         = sizeof(rb->recv_space);
+       msghdr.msg_name       = (void *)&rb->recv_srcadr;
+       msghdr.msg_namelen    = sizeof(rb->recv_srcadr);
+       msghdr.msg_iov        = &iovec;
+       msghdr.msg_iovlen     = 1;
+       msghdr.msg_control    = (void *)&control;
+       msghdr.msg_controllen = sizeof(control);
+       msghdr.msg_flags      = 0;
+       rb->recv_length       = recvmsg(fd, &msghdr, 0);
+#endif
+
+       buflen = rb->recv_length;
+
+       if (buflen == 0 || (buflen == -1 && 
+           (errno==EWOULDBLOCK
+#ifdef EAGAIN
+          || errno==EAGAIN
+#endif
+        ))) {
+               freerecvbuf(rb);
+               return (buflen);
+       }
+       else if (buflen < 0)
+       {
+               netsyslog(LOG_ERR, "recvfrom(%s) fd=%d: %m",
+               stoa(&rb->recv_srcadr), fd);
+               DPRINTF(5, ("read_network_packet: fd=%d dropped (bad recvfrom)\n", fd));
+               freerecvbuf(rb);
+               return (buflen);
+       }
+
+#ifdef DEBUG
+       if (debug > 2) {
+               if(rb->recv_srcadr.ss_family == AF_INET)
+                       printf("read_network_packet: fd=%d length %d from %08lx %s\n",
+                               fd, buflen,
+                               (u_long)ntohl(((struct sockaddr_in*)&rb->recv_srcadr)->sin_addr.s_addr) &
+                               0x00000000ffffffff,
+                               stoa(&rb->recv_srcadr));
+               else
+                       printf("read_network_packet: fd=%d length %d from %s\n",
+                               fd, buflen,
+                               stoa(&rb->recv_srcadr));
+       }
+#endif
+
+       /*
+        * Got one.  Mark how and when it got here,
+        * put it on the full list and do bookkeeping.
+        */
+       rb->dstadr = itf;
+       rb->fd = fd;
+#ifdef HAVE_TIMESTAMP
+       ts = fetch_timestamp(rb, &msghdr, ts);  /* pick up a network time stamp if possible */
+#endif
+       rb->recv_time = ts;
+       rb->receiver = receive;
+
+       add_full_recv_buffer(rb);
+
+       itf->received++;
+       packets_received++;
+       return (buflen);
+}
+
+/*
+ * input_handler - receive packets asynchronously
+ */
+void
+input_handler(
+       l_fp *cts
+       )
+{
+
+       int buflen;
+       int n;
+       int doing;
+       SOCKET fd;
+       struct timeval tvzero;
+       l_fp ts;                        /* Timestamp at BOselect() gob */
+#ifdef DEBUG_TIMING
+       l_fp ts_e;                      /* Timestamp at EOselect() gob */
+#endif
+       fd_set fds;
+       int select_count = 0;
+       struct interface *interface;
+#if defined(HAS_ROUTING_SOCKET)
+       struct asyncio_reader *asyncio_reader;
+#endif
+
+       handler_calls++;
+
+       /*
+        * If we have something to do, freeze a timestamp.
+        * See below for the other cases (nothing (left) to do or error)
+        */
+       ts = *cts;
+
+       /*
+        * Do a poll to see who has data
+        */
+
+       fds = activefds;
+       tvzero.tv_sec = tvzero.tv_usec = 0;
+
+       n = select(maxactivefd+1, &fds, (fd_set *)0, (fd_set *)0, &tvzero);
+
+       /*
+        * If there are no packets waiting just return
+        */
+       if (n < 0)
+       {
+               int err = errno;
+               /*
+                * extended FAU debugging output
+                */
+               if (err != EINTR)
+                   netsyslog(LOG_ERR,
+                             "select(%d, %s, 0L, 0L, &0.0) error: %m",
+                             maxactivefd+1,
+                             fdbits(maxactivefd, &activefds));
+               if (err == EBADF) {
+                       int j, b;
+                       fds = activefds;
+                       for (j = 0; j <= maxactivefd; j++)
+                           if ((FD_ISSET(j, &fds) && (read(j, &b, 0) == -1)))
+                               netsyslog(LOG_ERR, "Bad file descriptor %d", j);
+               }
+               return;
+       }
+       else if (n == 0)
+               return;
+
+       ++handler_pkts;
+
+#ifdef REFCLOCK
+       /*
+        * Check out the reference clocks first, if any
+        */
+
+       if (refio != NULL)
+       {
+               register struct refclockio *rp;
+
+               for (rp = refio; rp != NULL; rp = rp->next)
+               {
+                       fd = rp->fd;
+
+                       if (FD_ISSET(fd, &fds))
+                       {
+                               do {
+                                       ++select_count;
+                                       buflen = read_refclock_packet(fd, rp, ts);
+                               } while (buflen > 0);
+
+                       } /* End if (FD_ISSET(fd, &fds)) */
+               } /* End for (rp = refio; rp != 0 && n > 0; rp = rp->next) */
+       } /* End if (refio != 0) */
+
+#endif /* REFCLOCK */
+
+       /*
+        * Loop through the interfaces looking for data to read.
+        */
+       for (interface = ISC_LIST_TAIL(inter_list);
+            interface != NULL;
+            interface = ISC_LIST_PREV(interface, link))
+       {
+               for (doing = 0; (doing < 2); doing++)
+               {
+                       if (doing == 0)
+                       {
+                               fd = interface->fd;
+                       }
+                       else
+                       {
+                               if (!(interface->flags & INT_BCASTOPEN))
+                                   break;
+                               fd = interface->bfd;
+                       }
+                       if (fd < 0) continue;
+                       if (FD_ISSET(fd, &fds))
+                       {
+                               do {
+                                       ++select_count;
+                                       buflen = read_network_packet(fd, interface, ts);
+                               } while (buflen > 0);
+                       }
+               /* Check more interfaces */
+               }
+       }
+
+#ifdef HAS_ROUTING_SOCKET
+       /*
+        * scan list of asyncio readers - currently only used for routing sockets
+        */
+       asyncio_reader = ISC_LIST_TAIL(asyncio_reader_list);
+
+       while (asyncio_reader != NULL)
+       {
+               struct asyncio_reader *next = ISC_LIST_PREV(asyncio_reader, link);
+               if (FD_ISSET(asyncio_reader->fd, &fds)) {
+                       ++select_count;
+                       asyncio_reader->receiver(asyncio_reader);
+               }
+               asyncio_reader = next;
+       }
+#endif /* HAS_ROUTING_SOCKET */
+       
+       /*
+        * Done everything from that select.
+        */
+
+       /*
+        * If nothing to do, just return.
+        * If an error occurred, complain and return.
+        */
+       if (select_count == 0) /* We really had nothing to do */
+       {
+#ifdef DEBUG
+               if (debug)
+                   netsyslog(LOG_DEBUG, "input_handler: select() returned 0");
+#endif
+               return;
+       }
+               /* We've done our work */
+#ifdef DEBUG_TIMING
+       get_systime(&ts_e);
+       /*
+        * (ts_e - ts) is the amount of time we spent
+        * processing this gob of file descriptors.  Log
+        * it.
+        */
+       L_SUB(&ts_e, &ts);
+       collect_timing(NULL, "input handler", 1, &ts_e);
+       if (debug > 3)
+           netsyslog(LOG_INFO, "input_handler: Processed a gob of fd's in %s msec", lfptoms(&ts_e, 6));
+#endif
+       /* just bail. */
+       return;
+}
+
+#endif
+
+/*
+ * findinterface - find local interface corresponding to address
+ */
+struct interface *
+findinterface(
+       struct sockaddr_storage *addr
+       )
+{
+       struct interface *interface;
+       
+       interface = findlocalinterface(addr, INT_WILDCARD);
+
+       if (interface == NULL)
+       {
+               DPRINTF(4, ("Found no interface for address %s - returning wildcard\n",
+                           stoa(addr)));
+
+               return (ANY_INTERFACE_CHOOSE(addr));
+       }
+       else
+       {
+               DPRINTF(4, ("Found interface #%d %s for address %s\n",
+                           interface->ifnum, interface->name, stoa(addr)));
+
+               return (interface);
+       }
+}
+
+/*
+ * findlocalinterface - find local interface index corresponding to address
+ *
+ * This code attempts to find the local sending address for an outgoing
+ * address by connecting a new socket to destinationaddress:NTP_PORT
+ * and reading the sockname of the resulting connect.
+ * the complicated sequence simulates the routing table lookup
+ * for to first hop without duplicating any of the routing logic into
+ * ntpd. preferably we would have used an API call - but its not there -
+ * so this is the best we can do here short of duplicating to entire routing
+ * logic in ntpd which would be a silly and really unportable thing to do.
+ *
+ */
+static struct interface *
+findlocalinterface(
+       struct sockaddr_storage *addr,
+       int flags
+       )
+{
+       SOCKET s;
+       int rtn;
+       struct sockaddr_storage saddr;
+       GETSOCKNAME_SOCKLEN_TYPE saddrlen = SOCKLEN(addr);
+       struct interface *iface;
+
+       DPRINTF(4, ("Finding interface for addr %s in list of addresses\n",
+                   stoa(addr)));
+
+       memset(&saddr, 0, sizeof(saddr));
+       saddr.ss_family = addr->ss_family;
+       if(addr->ss_family == AF_INET) {
+               memcpy(&((struct sockaddr_in*)&saddr)->sin_addr, &((struct sockaddr_in*)addr)->sin_addr, sizeof(struct in_addr));
+               ((struct sockaddr_in*)&saddr)->sin_port = htons(NTP_PORT);
+       }
+#ifdef INCLUDE_IPV6_SUPPORT
+       else if(addr->ss_family == AF_INET6) {
+               memcpy(&((struct sockaddr_in6*)&saddr)->sin6_addr, &((struct sockaddr_in6*)addr)->sin6_addr, sizeof(struct in6_addr));
+               ((struct sockaddr_in6*)&saddr)->sin6_port = htons(NTP_PORT);
+# ifdef ISC_PLATFORM_HAVESCOPEID
+               ((struct sockaddr_in6*)&saddr)->sin6_scope_id = ((struct sockaddr_in6*)addr)->sin6_scope_id;
+# endif
+       }
+#endif
+       
+       s = socket(addr->ss_family, SOCK_DGRAM, 0);
+       if (s == INVALID_SOCKET)
+               return NULL;
+
+       rtn = connect(s, (struct sockaddr *)&saddr, SOCKLEN(&saddr));
+#ifndef SYS_WINNT
+       if (rtn < 0)
+#else
+       if (rtn == SOCKET_ERROR)
+#endif
+       {
+               closesocket(s);
+               return NULL;
+       }
+
+       rtn = getsockname(s, (struct sockaddr *)&saddr, &saddrlen);
+       closesocket(s);
+#ifndef SYS_WINNT
+       if (rtn < 0)
+#else
+       if (rtn == SOCKET_ERROR)
+#endif
+               return NULL;
+
+       DPRINTF(4, ("findlocalinterface: kernel maps %s to %s\n", stoa(addr), stoa(&saddr)));
+       
+       iface = getinterface(&saddr, flags);
+
+       /* Don't both with ignore interfaces */
+       if (iface != NULL && iface->ignore_packets == ISC_TRUE)
+       {
+               return NULL;
+       }
+       else
+       {
+               return iface;
+       }
+}
+
+/*
+ * fetch an interface structure the matches the
+ * address is has the given flags not set
+ */
+static struct interface *
+getinterface(struct sockaddr_storage *addr, int flags)
+{
+       struct interface *interface = find_addr_in_list(addr);
+
+       if (interface != NULL && interface->flags & flags)
+       {
+               return NULL;
+       }
+       else
+       {
+               return interface;
+       }
+}
+
+/*
+ * findlocalcastinterface - find local *cast interface index corresponding to address
+ * depending on the flags passed
+ */
+static struct interface *
+findlocalcastinterface(
+       struct sockaddr_storage *addr, int flags
+       )
+{
+       struct interface *interface;
+       struct interface *nif = NULL;
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+       isc_boolean_t want_linklocal;
+#endif 
+
+       /*
+        * see how kernel maps the mcast address
+        */
+        nif = findlocalinterface(addr, 0);
+
+       if (nif) {
+               DPRINTF(2, ("findlocalcastinterface: kernel recommends interface #%d %s\n", nif->ifnum, nif->name));
+               return nif;
+       }
+
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+       want_linklocal = ISC_FALSE; 
+       if (addr_ismulticast(addr) && flags == INT_MULTICAST)
+       {
+               if (IN6_IS_ADDR_MC_LINKLOCAL(&((struct sockaddr_in6*)addr)->sin6_addr))
+               {
+                       want_linklocal = ISC_TRUE;
+               }
+               else if (IN6_IS_ADDR_MC_SITELOCAL(&((struct sockaddr_in6*)addr)->sin6_addr))
+               {
+                       want_linklocal = ISC_TRUE;
+               }
+       }
+#endif
+
+       for (interface = ISC_LIST_HEAD(inter_list);
+            interface != NULL;
+            interface = ISC_LIST_NEXT(interface, link)) 
+         {
+               /* use only allowed addresses */
+               if (interface->ignore_packets == ISC_TRUE)
+                       continue;
+
+               /* Skip the loopback and wildcard addresses */
+               if (interface->flags & (INT_LOOPBACK|INT_WILDCARD))
+                       continue;
+
+               /* Skip if different family */
+               if(interface->sin.ss_family != addr->ss_family)
+                       continue;
+
+               /* Is this it one of these based on flags? */
+               if (!(interface->flags & flags))
+                       continue;
+
+               /* for IPv6 multicast check the address for linklocal */
+#ifdef INCLUDE_IPV6_MULTICAST_SUPPORT
+               if (flags == INT_MULTICAST && interface->sin.ss_family == AF_INET6 &&
+                  (IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6*)&interface->sin)->sin6_addr))
+                  && want_linklocal == ISC_TRUE)
+               {
+                       nif = interface;
+                       break;
+               }
+               /* If we want a linklocal address and this isn't it, skip */\
+               if (want_linklocal == ISC_TRUE)
+                       continue;
+#endif
+               /* Otherwise just look for the flag */
+               if((interface->flags & flags))
+               {
+                       nif = interface;
+                       break;
+               }
+       }
+#ifdef DEBUG
+       if (debug > 2) 
+       {
+               if (nif)
+                       printf("findlocalcastinterface: found interface #%d %s\n", nif->ifnum, nif->name);
+               else
+                       printf("findlocalcastinterface: no interface found for %s flags 0x%x\n", stoa(addr), flags);
+       }
+#endif
+       return (nif);
+}
+
+/*
+ * findbcastinter - find broadcast interface corresponding to address
+ */
+struct interface *
+findbcastinter(
+       struct sockaddr_storage *addr
+       )
+{
+#if !defined(MPE) && (defined(SIOCGIFCONF) || defined(SYS_WINNT))
+        struct interface *interface;
+       
+       
+       DPRINTF(4, ("Finding broadcast/multicast interface for addr %s in list of addresses\n",
+                   stoa(addr)));
+
+       interface = findlocalinterface(addr, INT_LOOPBACK|INT_WILDCARD);
+       
+       if (interface != NULL)
+       {
+               DPRINTF(4, ("Found bcast-/mcast- interface index #%d %s\n", interface->ifnum, interface->name));
+               return interface;
+       }
+
+       /* plan B - try to find something reasonable in our lists in case kernel lookup doesn't help */
+
+       for (interface = ISC_LIST_HEAD(inter_list);
+            interface != NULL;
+            interface = ISC_LIST_NEXT(interface, link)) 
+       {
+               if (interface->flags & INT_WILDCARD)
+                       continue;
+               
+               /* Don't bother with ignored interfaces */
+               if (interface->ignore_packets == ISC_TRUE)
+                       continue;
+               
+               /*
+                * First look if this is the correct family
+                */
+               if(interface->sin.ss_family != addr->ss_family)
+                       continue;
+
+               /* Skip the loopback addresses */
+               if (interface->flags & INT_LOOPBACK)
+                       continue;
+
+               /*
+                * If we are looking to match a multicast address grab it.
+                */
+               if (addr_ismulticast(addr) == ISC_TRUE && interface->flags & INT_MULTICAST)
+               {
+#ifdef INCLUDE_IPV6_SUPPORT
+                       if(addr->ss_family == AF_INET6) {
+                               /* Only use link-local address for link-scope mcast */
+                               if(IN6_IS_ADDR_MC_LINKLOCAL(&((struct sockaddr_in6*)addr)->sin6_addr) &&
+                                 !IN6_IS_ADDR_LINKLOCAL(&((struct sockaddr_in6*)&interface->sin)->sin6_addr)) {
+                                       continue;
+                               }
+                       }
+#endif
+                       break;
+               }
+
+               /*
+                * We match only those interfaces marked as
+                * broadcastable and either the explicit broadcast
+                * address or the network portion of the IP address.
+                * Sloppy.
+                */
+               if(addr->ss_family == AF_INET) {
+                       if (SOCKCMP(&interface->bcast, addr)) {
+                               break;
+                       }
+                       if ((NSRCADR(&interface->sin) &
+                            NSRCADR(&interface->mask)) == (NSRCADR(addr) &
+                                                           NSRCADR(&interface->mask)))
+                               break;
+               }
+#ifdef INCLUDE_IPV6_SUPPORT
+               else if(addr->ss_family == AF_INET6) {
+                       if (SOCKCMP(&interface->bcast, addr)) {
+                               break;
+                       }
+                       if (SOCKCMP(netof(&interface->sin), netof(addr))) {
+                               break;
+                       }
+               }
+#endif
+       }
+#endif /* SIOCGIFCONF */
+       if (interface == NULL) {
+               DPRINTF(4, ("No bcast interface found for %s\n", stoa(addr)));
+               return ANY_INTERFACE_CHOOSE(addr);
+       } else {
+               DPRINTF(4, ("Found bcast-/mcast- interface index #%d %s\n", interface->ifnum, interface->name));
+               return interface;
+       }
+}
+
+
+/*
+ * io_clr_stats - clear I/O module statistics
+ */
+void
+io_clr_stats(void)
+{
+       packets_dropped = 0;
+       packets_ignored = 0;
+       packets_received = 0;
+       packets_sent = 0;
+       packets_notsent = 0;
+
+       handler_calls = 0;
+       handler_pkts = 0;
+       io_timereset = current_time;
+}
+
+
+#ifdef REFCLOCK
+/*
+ * io_addclock - add a reference clock to the list and arrange that we
+ *                              get SIGIO interrupts from it.
+ */
+int
+io_addclock(
+       struct refclockio *rio
+       )
+{
+       BLOCKIO();
+       /*
+        * Stuff the I/O structure in the list and mark the descriptor
+        * in use.      There is a harmless (I hope) race condition here.
+        */
+       rio->next = refio;
+
+# ifdef HAVE_SIGNALED_IO
+       if (init_clock_sig(rio))
+       {
+               UNBLOCKIO();
+               return 0;
+       }
+# elif defined(HAVE_IO_COMPLETION_PORT)
+       if (io_completion_port_add_clock_io(rio))
+       {
+               UNBLOCKIO();
+               return 0;
+       }
+# endif
+
+       /*
+        * enqueue
+        */
+       refio = rio;
+
+        /*
+        * register fd
+        */
+       add_fd_to_list(rio->fd, FD_TYPE_FILE);
+
+       UNBLOCKIO();
+       return 1;
+}
+
+/*
+ * io_closeclock - close the clock in the I/O structure given
+ */
+void
+io_closeclock(
+       struct refclockio *rio
+       )
+{
+       BLOCKIO();
+       /*
+        * Remove structure from the list
+        */
+       if (refio == rio)
+       {
+               refio = rio->next;
+       }
+       else
+       {
+               register struct refclockio *rp;
+
+               for (rp = refio; rp != NULL; rp = rp->next)
+                   if (rp->next == rio)
+                   {
+                           rp->next = rio->next;
+                           break;
+                   }
+
+               if (rp == NULL) {
+                       UNBLOCKIO();
+                       return;
+               }
+       }
+
+       /*
+        * Close the descriptor.
+        */
+       close_and_delete_fd_from_list(rio->fd);
+       UNBLOCKIO();
+}
+#endif /* REFCLOCK */
+
+/*
+ * On NT a SOCKET is an unsigned int so we cannot possibly keep it in
+ * an array. So we use one of the ISC_LIST functions to hold the
+ * socket value and use that when we want to enumerate it.
+ */
+void
+kill_asyncio(int startfd)
+{
+       vsock_t *lsock;
+       vsock_t *next;
+
+       BLOCKIO();
+
+       lsock = ISC_LIST_HEAD(fd_list);
+       while (lsock != NULL) {
+               /*
+                * careful here - list is being dismantled while
+                * we scan it - setting next here insures that
+                * we are able to correctly scan the list
+                */
+               next = ISC_LIST_NEXT(lsock, link);
+               /*
+                * will remove socket from list
+                */
+               close_and_delete_fd_from_list(lsock->fd);
+               lsock = next;
+       }
+
+       UNBLOCKIO();
+}
+
+/*
+ * Add and delete functions for the list of open sockets
+ */
+static void
+add_fd_to_list(SOCKET fd, enum desc_type type) {
+       vsock_t *lsock = (vsock_t *)emalloc(sizeof(vsock_t));
+       lsock->fd = fd;
+       lsock->type = type;
+
+       ISC_LIST_APPEND(fd_list, lsock, link);
+       /*
+        * I/O Completion Ports don't care about the select and FD_SET
+        */
+#ifndef HAVE_IO_COMPLETION_PORT
+       if (fd < 0 || fd >= FD_SETSIZE) {
+               msyslog(LOG_ERR, "Too many sockets in use, FD_SETSIZE %d exceeded",
+                       FD_SETSIZE);
+               exit(1);
+       }
+       /*
+        * keep activefds in sync
+        */
+       if (fd > maxactivefd)
+           maxactivefd = fd;
+       FD_SET( (u_int)fd, &activefds);
+#endif
+}
+
+static void
+close_and_delete_fd_from_list(SOCKET fd) {
+
+       vsock_t *next;
+       vsock_t *lsock = ISC_LIST_HEAD(fd_list);
+
+       while(lsock != NULL) {
+               next = ISC_LIST_NEXT(lsock, link);
+               if(lsock->fd == fd) {
+                       ISC_LIST_DEQUEUE_TYPE(fd_list, lsock, link, vsock_t);
+
+                       switch (lsock->type) {
+                       case FD_TYPE_SOCKET:
+#ifdef SYS_WINNT
+                               closesocket(lsock->fd);
+                               break;
+#endif
+                       case FD_TYPE_FILE:
+                               (void) close(lsock->fd);
+                               break;
+                       default:
+                               msyslog(LOG_ERR, "internal error - illegal descriptor type %d - EXITING", (int)lsock->type);
+                               exit(1);
+                       }
+
+                       free(lsock);
+                       /*
+                        * I/O Completion Ports don't care about select and fd_set
+                        */
+#ifndef HAVE_IO_COMPLETION_PORT
+                       /*
+                        * remove from activefds
+                        */
+                       FD_CLR( (u_int) fd, &activefds);
+                       
+                       if (fd == maxactivefd) {
+                               int i, newmax = 0;
+                               for (i = 0; i < maxactivefd; i++)
+                                       if (FD_ISSET(i, &activefds))
+                                               newmax = i;
+                               maxactivefd = newmax;
+                       }
+#endif
+                       break;
+               }
+               lsock = next;
+       }
+}
+
+static void
+add_addr_to_list(struct sockaddr_storage *addr, struct interface *interface){
+#ifdef DEBUG
+       if (find_addr_in_list(addr) == NULL) {
+#endif
+               /* not there yet - add to list */
+               remaddr_t *laddr = (remaddr_t *)emalloc(sizeof(remaddr_t));
+               memcpy(&laddr->addr, addr, sizeof(struct sockaddr_storage));
+               laddr->interface = interface;
+               
+               ISC_LIST_APPEND(remoteaddr_list, laddr, link);
+               
+               DPRINTF(4, ("Added addr %s to list of addresses\n",
+                           stoa(addr)));
+#ifdef DEBUG
+       } else {
+               DPRINTF(4, ("WARNING: Attempt to add duplicate addr %s to address list\n",
+                           stoa(addr)));
+       }
+#endif
+}
+
+static void
+delete_addr_from_list(struct sockaddr_storage *addr) {
+
+       remaddr_t *next;
+       remaddr_t *laddr = ISC_LIST_HEAD(remoteaddr_list);
+
+       while(laddr != NULL) {
+               next = ISC_LIST_NEXT(laddr, link);
+               if(SOCKCMP(&laddr->addr, addr)) {
+                       ISC_LIST_DEQUEUE_TYPE(remoteaddr_list, laddr, link, remaddr_t);
+                       DPRINTF(4, ("Deleted addr %s from list of addresses\n",
+                                   stoa(addr)));
+                       free(laddr);
+                       break;
+               }
+               laddr = next;
+       }
+}
+
+static void
+delete_interface_from_list(struct interface *iface) {
+       remaddr_t *next;
+       remaddr_t *laddr = ISC_LIST_HEAD(remoteaddr_list);
+
+       while(laddr != NULL) {
+               next = ISC_LIST_NEXT(laddr, link);
+               if (laddr->interface == iface) {
+                       ISC_LIST_DEQUEUE_TYPE(remoteaddr_list, laddr, link, remaddr_t);
+                       DPRINTF(4, ("Deleted addr %s for interface #%d %s from list of addresses\n",
+                                   stoa(&laddr->addr), iface->ifnum, iface->name));
+                       free(laddr);
+               }
+               laddr = next;
+       }
+}
+
+static struct interface *
+find_addr_in_list(struct sockaddr_storage *addr) {
+
+       remaddr_t *next;
+       remaddr_t *laddr = ISC_LIST_HEAD(remoteaddr_list);
+       DPRINTF(4, ("Searching for addr %s in list of addresses - ",
+                   stoa(addr)));
+
+       while(laddr != NULL) {
+               next = ISC_LIST_NEXT(laddr, link);
+               if(SOCKCMP(&laddr->addr, addr)) {
+                       DPRINTF(4, ("FOUND\n"));
+                       return laddr->interface;
+               }
+               else
+                       laddr = next;
+       }
+       DPRINTF(4, ("NOT FOUND\n"));
+       return NULL; /* Not found */
+}
+
+/*
+ * Find the given address with the associated flag in the list
+ */
+static struct interface *
+find_flagged_addr_in_list(struct sockaddr_storage *addr, int flag) {
+
+       remaddr_t *next;
+       remaddr_t *laddr = ISC_LIST_HEAD(remoteaddr_list);
+       DPRINTF(4, ("Finding addr %s in list of addresses\n",
+                   stoa(addr)));
+
+       while(laddr != NULL) {
+               next = ISC_LIST_NEXT(laddr, link);
+               if(SOCKCMP(&laddr->addr, addr) && (laddr->interface->flags & flag)) {
+                       return laddr->interface;
+                       break;
+               }
+               else
+                       laddr = next;
+       }
+       return NULL; /* Not found */
+}
+
+#ifdef HAS_ROUTING_SOCKET
+#include <net/route.h>
+
+#ifndef UPDATE_GRACE
+#define UPDATE_GRACE   2       /* wait UPDATE_GRACE seconds before scanning */
+#endif
+
+static void
+process_routing_msgs(struct asyncio_reader *reader)
+{
+       char buffer[5120];
+       char *p = buffer;
+
+       int cnt;
+       
+       if (disable_dynamic_updates) {
+               /*
+                * discard ourselves if we are not need any more
+                * usually happens when running unprivileged
+                */
+               remove_asyncio_reader(reader);
+               delete_asyncio_reader(reader);
+               return;
+       }
+
+       cnt = read(reader->fd, buffer, sizeof(buffer));
+       
+       if (cnt < 0) {
+               msyslog(LOG_ERR, "i/o error on routing socket %m - disabling");
+               remove_asyncio_reader(reader);
+               delete_asyncio_reader(reader);
+               return;
+       }
+
+       /*
+        * process routing message
+        */
+       while ((p + sizeof(struct rt_msghdr)) <= (buffer + cnt))
+       {
+               struct rt_msghdr *rtm;
+               
+               rtm = (struct rt_msghdr *)p;
+               if (rtm->rtm_version != RTM_VERSION) {
+                       msyslog(LOG_ERR, "version mismatch on routing socket %m - disabling");
+                       remove_asyncio_reader(reader);
+                       delete_asyncio_reader(reader);
+                       return;
+               }
+               
+               switch (rtm->rtm_type) {
+#ifdef RTM_NEWADDR
+               case RTM_NEWADDR:
+#endif
+#ifdef RTM_DELADDR
+               case RTM_DELADDR:
+#endif
+#ifdef RTM_ADD
+               case RTM_ADD:
+#endif
+#ifdef RTM_DELETE
+               case RTM_DELETE:
+#endif
+#ifdef RTM_REDIRECT
+               case RTM_REDIRECT:
+#endif
+#ifdef RTM_CHANGE
+               case RTM_CHANGE:
+#endif
+#ifdef RTM_LOSING
+               case RTM_LOSING:
+#endif
+#ifdef RTM_IFINFO
+               case RTM_IFINFO:
+#endif
+#ifdef RTM_IFANNOUNCE
+               case RTM_IFANNOUNCE:
+#endif
+                       /*
+                        * we are keen on new and deleted addresses and if an interface goes up and down or routing changes
+                        */
+                       DPRINTF(3, ("routing message op = %d: scheduling interface update\n", rtm->rtm_type));
+                       timer_interfacetimeout(current_time + UPDATE_GRACE);
+                       break;
+               default:
+                       /*
+                        * the rest doesn't bother us.
+                        */
+                       DPRINTF(4, ("routing message op = %d: ignored\n", rtm->rtm_type));
+                       break;
+               }
+               p += rtm->rtm_msglen;
+       }
+}
+
+/*
+ * set up routing notifications
+ */
+static void
+init_async_notifications()
+{
+       struct asyncio_reader *reader;
+       int fd = socket(PF_ROUTE, SOCK_RAW, 0);
+       
+       if (fd >= 0) {
+               fd = move_fd(fd);
+               init_nonblocking_io(fd);
+#if defined(HAVE_SIGNALED_IO)
+               init_socket_sig(fd);
+#endif /* HAVE_SIGNALED_IO */
+               
+               reader = new_asyncio_reader();
+
+               reader->fd = fd;
+               reader->receiver = process_routing_msgs;
+               
+               add_asyncio_reader(reader, FD_TYPE_SOCKET);
+               msyslog(LOG_INFO, "Listening on routing socket on fd #%d for interface updates", fd);
+       } else {
+               msyslog(LOG_ERR, "unable to open routing socket (%m) - using polled interface update");
+       }
+}
+#else
+static void
+init_async_notifications()
+{
+}
+#endif
diff --git a/ntpd/ntp_loopfilter.c b/ntpd/ntp_loopfilter.c
new file mode 100644 (file)
index 0000000..d0fa466
--- /dev/null
@@ -0,0 +1,1058 @@
+/*
+ * ntp_loopfilter.c - implements the NTP loop filter algorithm
+ *
+ * ATTENTION: Get approval from Dave Mills on all changes to this file!
+ *
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include <signal.h>
+#include <setjmp.h>
+
+#if defined(VMS) && defined(VMS_LOCALUNIT)     /*wjm*/
+#include "ntp_refclock.h"
+#endif /* VMS */
+
+#ifdef KERNEL_PLL
+#include "ntp_syscall.h"
+#endif /* KERNEL_PLL */
+
+/*
+ * This is an implementation of the clock discipline algorithm described
+ * in UDel TR 97-4-3, as amended. It operates as an adaptive parameter,
+ * hybrid phase/frequency-lock loop. A number of sanity checks are
+ * included to protect against timewarps, timespikes and general mayhem.
+ * All units are in s and s/s, unless noted otherwise.
+ */
+#define CLOCK_MAX      .128    /* default step threshold (s) */
+#define CLOCK_MINSTEP  900.    /* default stepout threshold (s) */
+#define CLOCK_PANIC    1000.   /* default panic threshold (s) */
+#define        CLOCK_PHI       15e-6   /* max frequency error (s/s) */
+#define CLOCK_PLL      16.     /* PLL loop gain (log2) */
+#define CLOCK_AVG      8.      /* parameter averaging constant */
+#define CLOCK_FLL      (NTP_MAXPOLL + CLOCK_AVG) /* FLL loop gain */
+#define        CLOCK_ALLAN     1500.   /* compromise Allan intercept (s) */
+#define CLOCK_DAY      86400.  /* one day in seconds (s) */
+#define CLOCK_JUNE     (CLOCK_DAY * 30) /* June in seconds (s) */
+#define CLOCK_LIMIT    30      /* poll-adjust threshold */
+#define CLOCK_PGATE    4.      /* poll-adjust gate */
+#define PPS_MAXAGE     120     /* kernel pps signal timeout (s) */
+
+/*
+ * Clock discipline state machine. This is used to control the
+ * synchronization behavior during initialization and following a
+ * timewarp.
+ *
+ *     State   < step          > step          Comments
+ *     ====================================================
+ *     NSET    FREQ            step, FREQ      no ntp.drift
+ *
+ *     FSET    SYNC            step, SYNC      ntp.drift
+ *
+ *     FREQ    if (mu < 900)   if (mu < 900)   set freq
+ *                 ignore          ignore
+ *             else            else
+ *                 freq, SYNC      freq, step, SYNC
+ *
+ *     SYNC    SYNC            if (mu < 900)   adjust phase/freq
+ *                                 ignore
+ *                             else
+ *                                 SPIK
+ *
+ *     SPIK    SYNC            step, SYNC      set phase
+ */
+#define S_NSET 0               /* clock never set */
+#define S_FSET 1               /* frequency set from the drift file */
+#define S_SPIK 2               /* spike detected */
+#define S_FREQ 3               /* frequency mode */
+#define S_SYNC 4               /* clock synchronized */
+
+/*
+ * Kernel PLL/PPS state machine. This is used with the kernel PLL
+ * modifications described in the README.kernel file.
+ *
+ * If kernel support for the ntp_adjtime() system call is available, the
+ * ntp_control flag is set. The ntp_enable and kern_enable flags can be
+ * set at configuration time or run time using ntpdc. If ntp_enable is
+ * false, the discipline loop is unlocked and no corrections of any kind
+ * are made. If both ntp_control and kern_enable are set, the kernel
+ * support is used as described above; if false, the kernel is bypassed
+ * entirely and the daemon discipline used instead.
+ *
+ * There have been three versions of the kernel discipline code. The
+ * first (microkernel) now in Solaris discipilnes the microseconds. The
+ * second and third (nanokernel) disciplines the clock in nanoseconds.
+ * These versions are identifed if the symbol STA_PLL is present in the
+ * header file /usr/include/sys/timex.h. The third and current version
+ * includes TAI offset and is identified by the symbol NTP_API with
+ * value 4.
+ *
+ * Each update to a prefer peer sets pps_stratum if it survives the
+ * intersection algorithm and its time is within range. The PPS time
+ * discipline is enabled (STA_PPSTIME bit set in the status word) when
+ * pps_stratum is true and the PPS frequency discipline is enabled. If
+ * the PPS time discipline is enabled and the kernel reports a PPS
+ * signal is present, the pps_control variable is set to the current
+ * time. If the current time is later than pps_control by PPS_MAXAGE
+ * (120 s), this variable is set to zero.
+ *
+ * If an external clock is present, the clock driver sets STA_CLK in the
+ * status word. When the local clock driver sees this bit, it updates
+ * via this routine, which then calls ntp_adjtime() with the STA_PLL bit
+ * set to zero, in which case the system clock is not adjusted. This is
+ * also a signal for the external clock driver to discipline the system
+ * clock.
+ */
+/*
+ * Program variables that can be tinkered.
+ */
+double clock_max = CLOCK_MAX;  /* step threshold (s) */
+double clock_minstep = CLOCK_MINSTEP; /* stepout threshold (s) */
+double clock_panic = CLOCK_PANIC; /* panic threshold (s) */
+double clock_phi = CLOCK_PHI;  /* dispersion rate (s/s) */
+double allan_xpt = CLOCK_ALLAN; /* Allan intercept (s) */
+
+/*
+ * Program variables
+ */
+static double clock_offset;    /* offset (s) */
+double clock_jitter;           /* offset jitter (s) */
+double drift_comp;             /* frequency (s/s) */
+double clock_stability;        /* frequency stability (wander) (s/s) */
+u_long sys_clocktime;          /* last system clock update */
+u_long pps_control;            /* last pps update */
+u_long sys_tai;                /* UTC offset from TAI (s) */
+static void rstclock P((int, u_long, double)); /* transition function */
+
+#ifdef KERNEL_PLL
+struct timex ntv;              /* kernel API parameters */
+int    pll_status;             /* status bits for kernel pll */
+#endif /* KERNEL_PLL */
+
+/*
+ * Clock state machine control flags
+ */
+int    ntp_enable;             /* clock discipline enabled */
+int    pll_control;            /* kernel support available */
+int    kern_enable;            /* kernel support enabled */
+int    pps_enable;             /* kernel PPS discipline enabled */
+int    ext_enable;             /* external clock enabled */
+int    pps_stratum;            /* pps stratum */
+int    allow_panic = FALSE;    /* allow panic correction */
+int    mode_ntpdate = FALSE;   /* exit on first clock set */
+
+/*
+ * Clock state machine variables
+ */
+int    state;                  /* clock discipline state */
+u_char sys_poll = NTP_MINDPOLL; /* time constant/poll (log2 s) */
+int    tc_counter;             /* jiggle counter */
+double last_offset;            /* last offset (s) */
+
+/*
+ * Huff-n'-puff filter variables
+ */
+static double *sys_huffpuff;   /* huff-n'-puff filter */
+static int sys_hufflen;                /* huff-n'-puff filter stages */
+static int sys_huffptr;                /* huff-n'-puff filter pointer */
+static double sys_mindly;      /* huff-n'-puff filter min delay */
+
+#if defined(KERNEL_PLL)
+/* Emacs cc-mode goes nuts if we split the next line... */
+#define MOD_BITS (MOD_OFFSET | MOD_MAXERROR | MOD_ESTERROR | \
+    MOD_STATUS | MOD_TIMECONST)
+#ifdef SIGSYS
+static void pll_trap P((int)); /* configuration trap */
+static struct sigaction sigsys;        /* current sigaction status */
+static struct sigaction newsigsys; /* new sigaction status */
+static sigjmp_buf env;         /* environment var. for pll_trap() */
+#endif /* SIGSYS */
+#endif /* KERNEL_PLL */
+
+/*
+ * init_loopfilter - initialize loop filter data
+ */
+void
+init_loopfilter(void)
+{
+       /*
+        * Initialize state variables. Initially, we expect no drift
+        * file, so set the state to S_NSET. If a drift file is present,
+        * it will be detected later and the state set to S_FSET.
+        */
+       rstclock(S_NSET, 0, 0);
+       clock_jitter = LOGTOD(sys_precision);
+}
+
+/*
+ * local_clock - the NTP logical clock loop filter.
+ *
+ * Return codes:
+ * -1  update ignored: exceeds panic threshold
+ * 0   update ignored: popcorn or exceeds step threshold
+ * 1   clock was slewed
+ * 2   clock was stepped
+ *
+ * LOCKCLOCK: The only thing this routine does is set the
+ * sys_rootdispersion variable equal to the peer dispersion.
+ */
+int
+local_clock(
+       struct  peer *peer,     /* synch source peer structure */
+       double  fp_offset       /* clock offset (s) */
+       )
+{
+       int     rval;           /* return code */
+       u_long  mu;             /* interval since last update (s) */
+       double  flladj;         /* FLL frequency adjustment (ppm) */
+       double  plladj;         /* PLL frequency adjustment (ppm) */
+       double  clock_frequency; /* clock frequency adjustment (ppm) */
+       double  dtemp, etemp;   /* double temps */
+#ifdef OPENSSL
+       u_int32 *tpt;
+       int     i;
+       u_int   len;
+       long    togo;
+#endif /* OPENSSL */
+
+       /*
+        * If the loop is opened or the NIST LOCKCLOCK is in use,
+        * monitor and record the offsets anyway in order to determine
+        * the open-loop response and then go home.
+        */
+#ifdef DEBUG
+       if (debug)
+               printf(
+                   "local_clock: assocID %d offset %.9f freq %.3f state %d\n",
+                   peer->associd, fp_offset, drift_comp * 1e6, state);
+#endif
+#ifdef LOCKCLOCK
+       return (0);
+
+#else /* LOCKCLOCK */
+       if (!ntp_enable) {
+               record_loop_stats(fp_offset, drift_comp, clock_jitter,
+                   clock_stability, sys_poll);
+               return (0);
+       }
+
+       /*
+        * If the clock is way off, panic is declared. The clock_panic
+        * defaults to 1000 s; if set to zero, the panic will never
+        * occur. The allow_panic defaults to FALSE, so the first panic
+        * will exit. It can be set TRUE by a command line option, in
+        * which case the clock will be set anyway and time marches on.
+        * But, allow_panic will be set FALSE when the update is less
+        * than the step threshold; so, subsequent panics will exit.
+        */
+       if (fabs(fp_offset) > clock_panic && clock_panic > 0 &&
+           !allow_panic) {
+               msyslog(LOG_ERR,
+                   "time correction of %.0f seconds exceeds sanity limit (%.0f); set clock manually to the correct UTC time.",
+                   fp_offset, clock_panic);
+               return (-1);
+       }
+
+       /*
+        * If simulating ntpdate, set the clock directly, rather than
+        * using the discipline. The clock_max defines the step
+        * threshold, above which the clock will be stepped instead of
+        * slewed. The value defaults to 128 ms, but can be set to even
+        * unreasonable values. If set to zero, the clock will never be
+        * stepped. Note that a slew will persist beyond the life of
+        * this program.
+        *
+        * Note that if ntpdate is active, the terminal does not detach,
+        * so the termination comments print directly to the console.
+        */
+       if (mode_ntpdate) {
+               if (fabs(fp_offset) > clock_max && clock_max > 0) {
+                       step_systime(fp_offset);
+                       msyslog(LOG_NOTICE, "time reset %+.6f s",
+                           fp_offset);
+                       printf("ntpd: time set %+.6fs\n", fp_offset);
+               } else {
+                       adj_systime(fp_offset);
+                       msyslog(LOG_NOTICE, "time slew %+.6f s",
+                           fp_offset);
+                       printf("ntpd: time slew %+.6fs\n", fp_offset);
+               }
+               record_loop_stats(fp_offset, drift_comp, clock_jitter,
+                   clock_stability, sys_poll);
+               exit (0);
+       }
+
+       /*
+        * The huff-n'-puff filter finds the lowest delay in the recent
+        * interval. This is used to correct the offset by one-half the
+        * difference between the sample delay and minimum delay. This
+        * is most effective if the delays are highly assymetric and
+        * clockhopping is avoided and the clock frequency wander is
+        * relatively small.
+        *
+        * Note either there is no prefer peer or this update is from
+        * the prefer peer.
+        */
+       if (sys_huffpuff != NULL && (sys_prefer == NULL || sys_prefer ==
+           peer)) {
+               if (peer->delay < sys_huffpuff[sys_huffptr])
+                       sys_huffpuff[sys_huffptr] = peer->delay;
+               if (peer->delay < sys_mindly)
+                       sys_mindly = peer->delay;
+               if (fp_offset > 0)
+                       dtemp = -(peer->delay - sys_mindly) / 2;
+               else
+                       dtemp = (peer->delay - sys_mindly) / 2;
+               fp_offset += dtemp;
+#ifdef DEBUG
+               if (debug)
+                       printf(
+                   "local_clock: size %d mindly %.6f huffpuff %.6f\n",
+                           sys_hufflen, sys_mindly, dtemp);
+#endif
+       }
+
+       /*
+        * Clock state machine transition function. This is where the
+        * action is and defines how the system reacts to large phase
+        * and frequency errors. There are two main regimes: when the
+        * offset exceeds the step threshold and when it does not.
+        * However, if the step threshold is set to zero, a step will
+        * never occur. See the instruction manual for the details how
+        * these actions interact with the command line options.
+        *
+        * Note the system poll is set to minpoll only if the clock is
+        * stepped. Note also the kernel is disabled if step is
+        * disabled or greater than 0.5 s. 
+        */
+       clock_frequency = flladj = plladj = 0;
+       mu = peer->epoch - sys_clocktime;
+       if (clock_max == 0 || clock_max > 0.5)
+               kern_enable = 0;
+       rval = 1;
+       if (fabs(fp_offset) > clock_max && clock_max > 0) {
+               switch (state) {
+
+               /*
+                * In S_SYNC state we ignore the first outlyer amd
+                * switch to S_SPIK state.
+                */
+               case S_SYNC:
+                       state = S_SPIK;
+                       return (0);
+
+               /*
+                * In S_FREQ state we ignore outlyers and inlyers. At
+                * the first outlyer after the stepout threshold,
+                * compute the apparent frequency correction and step
+                * the phase.
+                */
+               case S_FREQ:
+                       if (mu < clock_minstep)
+                               return (0);
+
+                       clock_frequency = (fp_offset - clock_offset) /
+                           mu;
+
+                       /* fall through to S_SPIK */
+
+               /*
+                * In S_SPIK state we ignore succeeding outlyers until
+                * either an inlyer is found or the stepout threshold is
+                * exceeded.
+                */
+               case S_SPIK:
+                       if (mu < clock_minstep)
+                               return (0);
+
+                       /* fall through to default */
+
+               /*
+                * We get here by default in S_NSET and S_FSET states
+                * and from above in S_FREQ or S_SPIK states.
+                *
+                * In S_NSET state an initial frequency correction is
+                * not available, usually because the frequency file has
+                * not yet been written. Since the time is outside the
+                * step threshold, the clock is stepped. The frequency
+                * will be set directly following the stepout interval.
+                *
+                * In S_FSET state the initial frequency has been set
+                * from the frequency file. Since the time is outside
+                * the step threshold, the clock is stepped immediately,
+                * rather than after the stepout interval. Guys get
+                * nervous if it takes 17 minutes to set the clock for
+                * the first time.
+                *
+                * In S_FREQ and S_SPIK states the stepout threshold has
+                * expired and the phase is still above the step
+                * threshold. Note that a single spike greater than the
+                * step threshold is always suppressed, even at the
+                * longer poll intervals.
+                */ 
+               default:
+                       step_systime(fp_offset);
+                       msyslog(LOG_NOTICE, "time reset %+.6f s",
+                           fp_offset);
+                       reinit_timer();
+                       tc_counter = 0;
+                       sys_poll = NTP_MINPOLL;
+                       sys_tai = 0;
+                       clock_jitter = LOGTOD(sys_precision);
+                       rval = 2;
+                       if (state == S_NSET) {
+                               rstclock(S_FREQ, peer->epoch, 0);
+                               return (rval);
+                       }
+                       break;
+               }
+               rstclock(S_SYNC, peer->epoch, 0);
+       } else {
+
+               /*
+                * The offset is less than the step threshold. Calculate
+                * the jitter as the exponentially weighted offset
+                * differences.
+                */
+               etemp = SQUARE(clock_jitter);
+               dtemp = SQUARE(max(fabs(fp_offset - last_offset),
+                   LOGTOD(sys_precision)));
+               clock_jitter = SQRT(etemp + (dtemp - etemp) /
+                   CLOCK_AVG);
+               switch (state) {
+
+               /*
+                * In S_NSET state this is the first update received and
+                * the frequency has not been initialized. Adjust the
+                * phase, but do not adjust the frequency until after
+                * the stepout threshold.
+                */
+               case S_NSET:
+                       rstclock(S_FREQ, peer->epoch, fp_offset);
+                       break;
+
+               /*
+                * In S_FSET state this is the first update received and
+                * the frequency has been initialized. Adjust the phase,
+                * but do not adjust the frequency until the next
+                * update.
+                */
+               case S_FSET:
+                       rstclock(S_SYNC, peer->epoch, fp_offset);
+                       break;
+
+               /*
+                * In S_FREQ state ignore updates until the stepout
+                * threshold. After that, correct the phase and
+                * frequency and switch to S_SYNC state.
+                */
+               case S_FREQ:
+                       if (mu < clock_minstep)
+                               return (0);
+
+                       clock_frequency = (fp_offset - clock_offset) /
+                           mu;
+                       rstclock(S_SYNC, peer->epoch, fp_offset);
+                       break;
+
+               /*
+                * We get here by default in S_SYNC and S_SPIK states.
+                * Here we compute the frequency update due to PLL and
+                * FLL contributions.
+                */
+               default:
+                       allow_panic = FALSE;
+
+                       /*
+                        * The FLL and PLL frequency gain constants
+                        * depend on the poll interval and Allan
+                        * intercept. The PLL is always used, but
+                        * becomes ineffective above the Allan
+                        * intercept. The FLL is not used below one-half
+                        * the Allan intercept. Above that the loop gain
+                        * increases in steps to 1 / CLOCK_AVG. 
+                        */
+                       if (ULOGTOD(sys_poll) > allan_xpt / 2) {
+                               dtemp = CLOCK_FLL - sys_poll;
+                               flladj = (fp_offset - clock_offset) /
+                                   (max(mu, allan_xpt) * dtemp);
+                       }
+
+                       /*
+                        * For the PLL the integration interval
+                        * (numerator) is the minimum of the update
+                        * interval and poll interval. This allows
+                        * oversampling, but not undersampling.
+                        */ 
+                       etemp = min(mu, (u_long)ULOGTOD(sys_poll));
+                       dtemp = 4 * CLOCK_PLL * ULOGTOD(sys_poll);
+                       plladj = fp_offset * etemp / (dtemp * dtemp);
+                       rstclock(S_SYNC, peer->epoch, fp_offset);
+                       break;
+               }
+       }
+
+#ifdef OPENSSL
+       /*
+        * Scan the loopsecond table to determine the TAI offset. If
+        * there is a scheduled leap in future, set the leap warning,
+        * but only if less than 30 days before the leap.
+        */
+       tpt = (u_int32 *)tai_leap.ptr;
+       len = ntohl(tai_leap.vallen) / sizeof(u_int32);
+       if (tpt != NULL) {
+               for (i = 0; i < len; i++) {
+                       togo = (long)ntohl(tpt[i]) -
+                           (long)peer->rec.l_ui;
+                       if (togo > 0) {
+                               if (togo < CLOCK_JUNE)
+                                       leap_next |= LEAP_ADDSECOND;
+                               break;
+                       }
+               }
+#if defined(STA_NANO) && NTP_API == 4
+               if (pll_control && kern_enable && sys_tai == 0) {
+                       memset(&ntv, 0, sizeof(ntv));
+                       ntv.modes = MOD_TAI;
+                       ntv.constant = i + TAI_1972 - 1;
+                       ntp_adjtime(&ntv);
+               }
+#endif /* STA_NANO */
+               sys_tai = i + TAI_1972 - 1;
+       }
+#endif /* OPENSSL */
+#ifdef KERNEL_PLL
+       /*
+        * This code segment works when clock adjustments are made using
+        * precision time kernel support and the ntp_adjtime() system
+        * call. This support is available in Solaris 2.6 and later,
+        * Digital Unix 4.0 and later, FreeBSD, Linux and specially
+        * modified kernels for HP-UX 9 and Ultrix 4. In the case of the
+        * DECstation 5000/240 and Alpha AXP, additional kernel
+        * modifications provide a true microsecond clock and nanosecond
+        * clock, respectively.
+        *
+        * Important note: The kernel discipline is used only if the
+        * step threshold is less than 0.5 s, as anything higher can
+        * lead to overflow problems. This might occur if some misguided
+        * lad set the step threshold to something ridiculous.
+        */
+       if (pll_control && kern_enable) {
+
+               /*
+                * We initialize the structure for the ntp_adjtime()
+                * system call. We have to convert everything to
+                * microseconds or nanoseconds first. Do not update the
+                * system variables if the ext_enable flag is set. In
+                * this case, the external clock driver will update the
+                * variables, which will be read later by the local
+                * clock driver. Afterwards, remember the time and
+                * frequency offsets for jitter and stability values and
+                * to update the frequency file.
+                */
+               memset(&ntv,  0, sizeof(ntv));
+               if (ext_enable) {
+                       ntv.modes = MOD_STATUS;
+               } else {
+                       struct tm *tm = NULL;
+                       time_t tstamp;
+
+#ifdef STA_NANO
+                       ntv.modes = MOD_BITS | MOD_NANO;
+#else /* STA_NANO */
+                       ntv.modes = MOD_BITS;
+#endif /* STA_NANO */
+                       if (clock_offset < 0)
+                               dtemp = -.5;
+                       else
+                               dtemp = .5;
+#ifdef STA_NANO
+                       ntv.offset = (int32)(clock_offset * 1e9 +
+                           dtemp);
+                       ntv.constant = sys_poll;
+#else /* STA_NANO */
+                       ntv.offset = (int32)(clock_offset * 1e6 +
+                           dtemp);
+                       ntv.constant = sys_poll - 4;
+#endif /* STA_NANO */
+
+                       /*
+                        * The frequency is set directly only if
+                        * clock_frequency is nonzero coming out of FREQ
+                        * state.
+                        */
+                       if (clock_frequency != 0) {
+                               ntv.modes |= MOD_FREQUENCY;
+                               ntv.freq = (int32)((clock_frequency +
+                                   drift_comp) * 65536e6);
+                       }
+                       ntv.esterror = (u_int32)(clock_jitter * 1e6);
+                       ntv.maxerror = (u_int32)((sys_rootdelay / 2 +
+                           sys_rootdispersion) * 1e6);
+                       ntv.status = STA_PLL;
+
+                       /*
+                        * Set the leap bits in the status word, but
+                        * only on the last day of June or December.
+                        */
+                       tstamp = peer->rec.l_ui - JAN_1970;
+                       tm = gmtime(&tstamp);
+                       if (tm != NULL) {
+                               if ((tm->tm_mon + 1 == 6 &&
+                                   tm->tm_mday == 30) || (tm->tm_mon +
+                                   1 == 12 && tm->tm_mday == 31)) {
+                                       if (leap_next & LEAP_ADDSECOND)
+                                               ntv.status |= STA_INS;
+                                       else if (leap_next &
+                                           LEAP_DELSECOND)
+                                               ntv.status |= STA_DEL;
+                               }
+                       }
+
+                       /*
+                        * If the PPS signal is up and enabled, light
+                        * the frequency bit. If the PPS driver is
+                        * working, light the phase bit as well. If not,
+                        * douse the lights, since somebody else may
+                        * have left the switch on.
+                        */
+                       if (pps_enable && pll_status & STA_PPSSIGNAL) {
+                               ntv.status |= STA_PPSFREQ;
+                               if (pps_stratum < STRATUM_UNSPEC)
+                                       ntv.status |= STA_PPSTIME;
+                       } else {
+                               ntv.status &= ~(STA_PPSFREQ |
+                                   STA_PPSTIME);
+                       }
+               }
+
+               /*
+                * Pass the stuff to the kernel. If it squeals, turn off
+                * the pig. In any case, fetch the kernel offset and
+                * frequency and pretend we did it here.
+                */
+               if (ntp_adjtime(&ntv) == TIME_ERROR) {
+                       NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                           msyslog(LOG_NOTICE,
+                           "kernel time sync error %04x", ntv.status);
+                       ntv.status &= ~(STA_PPSFREQ | STA_PPSTIME);
+               } else {
+                       if ((ntv.status ^ pll_status) & ~STA_FLL)
+                               NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                                   msyslog(LOG_NOTICE,
+                                   "kernel time sync status change %04x",
+                                   ntv.status);
+               }
+               pll_status = ntv.status;
+#ifdef STA_NANO
+               clock_offset = ntv.offset / 1e9;
+#else /* STA_NANO */
+               clock_offset = ntv.offset / 1e6;
+#endif /* STA_NANO */
+               clock_frequency = ntv.freq / 65536e6;
+               flladj = plladj = 0;
+
+               /*
+                * If the kernel PPS is lit, monitor its performance.
+                */
+               if (ntv.status & STA_PPSTIME) {
+                       pps_control = current_time;
+#ifdef STA_NANO
+                       clock_jitter = ntv.jitter / 1e9;
+#else /* STA_NANO */
+                       clock_jitter = ntv.jitter / 1e6;
+#endif /* STA_NANO */
+               }
+       } else {
+#endif /* KERNEL_PLL */
+               /*
+                * We get here if the kernel discipline is not enabled.
+                * Adjust the clock frequency as the sum of the directly
+                * computed frequency (if measured) and the PLL and FLL
+                * increments.
+                */
+               clock_frequency = drift_comp + clock_frequency +
+                   flladj + plladj;
+#ifdef KERNEL_PLL
+       }
+#endif /* KERNEL_PLL */
+
+       /*
+        * Clamp the frequency within the tolerance range and calculate
+        * the frequency change since the last update.
+        */
+       if (fabs(clock_frequency) > NTP_MAXFREQ)
+               NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                   msyslog(LOG_NOTICE,
+                   "frequency error %.0f PPM exceeds tolerance %.0f PPM",
+                   clock_frequency * 1e6, NTP_MAXFREQ * 1e6);
+       dtemp = SQUARE(clock_frequency - drift_comp);
+       if (clock_frequency > NTP_MAXFREQ)
+               drift_comp = NTP_MAXFREQ;
+       else if (clock_frequency < -NTP_MAXFREQ)
+               drift_comp = -NTP_MAXFREQ;
+       else
+               drift_comp = clock_frequency;
+
+       /*
+        * Calculate the wander as the exponentially weighted frequency
+        * differences.
+        */
+       etemp = SQUARE(clock_stability);
+       clock_stability = SQRT(etemp + (dtemp - etemp) / CLOCK_AVG);
+
+       /*
+        * Here we adjust the poll interval by comparing the current
+        * offset with the clock jitter. If the offset is less than the
+        * clock jitter times a constant, then the averaging interval is
+        * increased, otherwise it is decreased. A bit of hysteresis
+        * helps calm the dance. Works best using burst mode.
+        */
+       if (fabs(clock_offset) < CLOCK_PGATE * clock_jitter) {
+               tc_counter += sys_poll;
+               if (tc_counter > CLOCK_LIMIT) {
+                       tc_counter = CLOCK_LIMIT;
+                       if (sys_poll < peer->maxpoll) {
+                               tc_counter = 0;
+                               sys_poll++;
+                       }
+               }
+       } else {
+               tc_counter -= sys_poll << 1;
+               if (tc_counter < -CLOCK_LIMIT) {
+                       tc_counter = -CLOCK_LIMIT;
+                       if (sys_poll > peer->minpoll) {
+                               tc_counter = 0;
+                               sys_poll--;
+                       }
+               }
+       }
+
+       /*
+        * Yibbidy, yibbbidy, yibbidy; that'h all folks.
+        */
+       record_loop_stats(clock_offset, drift_comp, clock_jitter,
+           clock_stability, sys_poll);
+#ifdef DEBUG
+       if (debug)
+               printf(
+                   "local_clock: mu %lu jitr %.6f freq %.3f stab %.6f poll %d count %d\n",
+                   mu, clock_jitter, drift_comp * 1e6,
+                   clock_stability * 1e6, sys_poll, tc_counter);
+#endif /* DEBUG */
+       return (rval);
+#endif /* LOCKCLOCK */
+}
+
+
+/*
+ * adj_host_clock - Called once every second to update the local clock.
+ *
+ * LOCKCLOCK: The only thing this routine does is increment the
+ * sys_rootdispersion variable.
+ */
+void
+adj_host_clock(
+       void
+       )
+{
+       double  adjustment;
+
+       /*
+        * Update the dispersion since the last update. In contrast to
+        * NTPv3, NTPv4 does not declare unsynchronized after one day,
+        * since the dispersion check serves this function. Also,
+        * since the poll interval can exceed one day, the old test
+        * would be counterproductive. Note we do this even with
+        * external clocks, since the clock driver will recompute the
+        * maximum error and the local clock driver will pick it up and
+        * pass to the common refclock routines. Very elegant.
+        */
+       sys_rootdispersion += clock_phi;
+
+#ifndef LOCKCLOCK
+       /*
+        * If clock discipline is disabled or if the kernel is enabled,
+        * get out of Dodge quick.
+        */
+       if (!ntp_enable || mode_ntpdate || (pll_control &&
+           kern_enable))
+               return;
+
+       /*
+        * Declare PPS kernel unsync if the pps signal has not been
+        * heard for a few minutes.
+        */
+       if (pps_control && current_time - pps_control > PPS_MAXAGE) {
+               if (pps_control)
+                       NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                           msyslog(LOG_NOTICE, "pps sync disabled");
+               pps_control = 0;
+       }
+
+       /*
+        * Implement the phase and frequency adjustments. The gain
+        * factor (denominator) is not allowed to increase beyond the
+        * Allan intercept. It doesn't make sense to average phase noise
+        * beyond this point and it helps to damp residual offset at the
+        * longer poll intervals.
+        */
+       adjustment = clock_offset / (CLOCK_PLL * min(ULOGTOD(sys_poll),
+           allan_xpt));
+       clock_offset -= adjustment;
+       adj_systime(adjustment + drift_comp);
+#endif /* LOCKCLOCK */
+}
+
+
+/*
+ * Clock state machine. Enter new state and set state variables. Note we
+ * use the time of the last clock filter sample, which may be earlier
+ * than the current time.
+ */
+static void
+rstclock(
+       int     trans,          /* new state */
+       u_long  update,         /* new update time */
+       double  offset          /* new offset */
+       )
+{
+#ifdef DEBUG
+       if (debug)
+               printf("local_clock: time %lu offset %.6f freq %.3f state %d\n",
+                   update, offset, drift_comp * 1e6, trans);
+#endif
+       state = trans;
+       sys_clocktime = update;
+       last_offset = clock_offset = offset;
+}
+
+
+/*
+ * huff-n'-puff filter
+ */
+void
+huffpuff()
+{
+       int i;
+
+       if (sys_huffpuff == NULL)
+               return;
+
+       sys_huffptr = (sys_huffptr + 1) % sys_hufflen;
+       sys_huffpuff[sys_huffptr] = 1e9;
+       sys_mindly = 1e9;
+       for (i = 0; i < sys_hufflen; i++) {
+               if (sys_huffpuff[i] < sys_mindly)
+                       sys_mindly = sys_huffpuff[i];
+       }
+}
+
+
+/*
+ * loop_config - configure the loop filter
+ *
+ * LOCKCLOCK: The LOOP_DRIFTINIT and LOOP_DRIFTCOMP cases are no-ops.
+ */
+void
+loop_config(
+       int item,
+       double freq
+       )
+{
+       int i;
+
+       switch (item) {
+
+       case LOOP_DRIFTINIT:
+
+#ifndef LOCKCLOCK
+#ifdef KERNEL_PLL
+               /*
+                * Assume the kernel supports the ntp_adjtime() syscall.
+                * If that syscall works, initialize the kernel time
+                * variables. Otherwise, continue leaving no harm
+                * behind. While at it, ask to set nanosecond mode. If
+                * the kernel agrees, rejoice; othewise, it does only
+                * microseconds.
+                */
+               if (mode_ntpdate)
+                       break;
+
+               pll_control = 1;
+               memset(&ntv, 0, sizeof(ntv));
+#ifdef STA_NANO
+               ntv.modes = MOD_BITS | MOD_NANO;
+#else /* STA_NANO */
+               ntv.modes = MOD_BITS;
+#endif /* STA_NANO */
+               ntv.maxerror = MAXDISPERSE;
+               ntv.esterror = MAXDISPERSE;
+               ntv.status = STA_UNSYNC;
+#ifdef SIGSYS
+               /*
+                * Use sigsetjmp() to save state and then call
+                * ntp_adjtime(); if it fails, then siglongjmp() is used
+                * to return control
+                */
+               newsigsys.sa_handler = pll_trap;
+               newsigsys.sa_flags = 0;
+               if (sigaction(SIGSYS, &newsigsys, &sigsys)) {
+                       msyslog(LOG_ERR,
+                           "sigaction() fails to save SIGSYS trap: %m");
+                       pll_control = 0;
+               }
+               if (sigsetjmp(env, 1) == 0)
+                       ntp_adjtime(&ntv);
+               if ((sigaction(SIGSYS, &sigsys,
+                   (struct sigaction *)NULL))) {
+                       msyslog(LOG_ERR,
+                           "sigaction() fails to restore SIGSYS trap: %m");
+                       pll_control = 0;
+               }
+#else /* SIGSYS */
+               ntp_adjtime(&ntv);
+#endif /* SIGSYS */
+
+               /*
+                * Save the result status and light up an external clock
+                * if available.
+                */
+               pll_status = ntv.status;
+               if (pll_control) {
+#ifdef STA_NANO
+                       if (pll_status & STA_CLK)
+                               ext_enable = 1;
+#endif /* STA_NANO */
+                       NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                           msyslog(LOG_INFO,
+                           "kernel time sync status %04x",
+                           pll_status);
+               }
+#endif /* KERNEL_PLL */
+#endif /* LOCKCLOCK */
+               break;
+
+       case LOOP_DRIFTCOMP:
+
+#ifndef LOCKCLOCK
+               /*
+                * If the frequency value is reasonable, set the initial
+                * frequency to the given value and the state to S_FSET.
+                * Otherwise, the drift file may be missing or broken,
+                * so set the frequency to zero. This erases past
+                * history should somebody break something.
+                */
+               if (freq <= NTP_MAXFREQ && freq >= -NTP_MAXFREQ) {
+                       drift_comp = freq;
+                       rstclock(S_FSET, 0, 0);
+               } else {
+                       drift_comp = 0;
+               }
+
+#ifdef KERNEL_PLL
+               /*
+                * Sanity check. If the kernel is available, load the
+                * frequency and light up the loop. Make sure the offset
+                * is zero to cancel any previous nonsense. If you don't
+                * want this initialization, remove the ntp.drift file.
+                */
+               if (pll_control && kern_enable) {
+                       memset((char *)&ntv, 0, sizeof(ntv));
+                       ntv.modes = MOD_OFFSET | MOD_FREQUENCY;
+                       ntv.freq = (int32)(drift_comp * 65536e6);
+                       ntp_adjtime(&ntv);
+               }
+#endif /* KERNEL_PLL */
+#endif /* LOCKCLOCK */
+               break;
+
+       case LOOP_KERN_CLEAR:
+#ifndef LOCKCLOCK
+#ifdef KERNEL_PLL
+               /* Completely turn off the kernel time adjustments. */
+               if (pll_control) {
+                       memset((char *)&ntv, 0, sizeof(ntv));
+                       ntv.modes = MOD_BITS | MOD_OFFSET | MOD_FREQUENCY;
+                       ntv.status = STA_UNSYNC;
+                       ntp_adjtime(&ntv);
+                       NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                           msyslog(LOG_INFO,
+                           "kernel time sync disabled %04x",
+                           ntv.status);
+                  }
+#endif /* KERNEL_PLL */
+#endif /* LOCKCLOCK */
+               break;
+
+       /*
+        * Special tinker variables for Ulrich Windl. Very dangerous.
+        */
+       case LOOP_MAX:                  /* step threshold */
+               clock_max = freq;
+               break;
+
+       case LOOP_PANIC:                /* panic threshold */
+               clock_panic = freq;
+               break;
+
+       case LOOP_PHI:                  /* dispersion rate */
+               clock_phi = freq;
+               break;
+
+       case LOOP_MINSTEP:              /* watchdog bark */
+               clock_minstep = freq; 
+               break;
+
+       case LOOP_ALLAN:                /* Allan intercept */
+               allan_xpt = freq;
+               break;
+       
+       case LOOP_HUFFPUFF:             /* huff-n'-puff filter length */
+               if (freq < HUFFPUFF)
+                       freq = HUFFPUFF;
+               sys_hufflen = (int)(freq / HUFFPUFF);
+               sys_huffpuff = (double *)emalloc(sizeof(double) *
+                   sys_hufflen);
+               for (i = 0; i < sys_hufflen; i++)
+                       sys_huffpuff[i] = 1e9;
+               sys_mindly = 1e9;
+               break;
+
+       case LOOP_FREQ:                 /* initial frequency */ 
+               drift_comp = freq / 1e6;
+               rstclock(S_FSET, 0, 0);
+               break;
+       }
+}
+
+
+#if defined(KERNEL_PLL) && defined(SIGSYS)
+/*
+ * _trap - trap processor for undefined syscalls
+ *
+ * This nugget is called by the kernel when the SYS_ntp_adjtime()
+ * syscall bombs because the silly thing has not been implemented in
+ * the kernel. In this case the phase-lock loop is emulated by
+ * the stock adjtime() syscall and a lot of indelicate abuse.
+ */
+static RETSIGTYPE
+pll_trap(
+       int arg
+       )
+{
+       pll_control = 0;
+       siglongjmp(env, 1);
+}
+#endif /* KERNEL_PLL && SIGSYS */
diff --git a/ntpd/ntp_monitor.c b/ntpd/ntp_monitor.c
new file mode 100644 (file)
index 0000000..753fa76
--- /dev/null
@@ -0,0 +1,358 @@
+/*
+ * ntp_monitor - monitor ntpd statistics
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_if.h"
+#include "ntp_stdlib.h"
+#include <ntp_random.h>
+
+#include <stdio.h>
+#include <signal.h>
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+
+/*
+ * I'm still not sure I like what I've done here. It certainly consumes
+ * memory like it is going out of style, and also may not be as low
+ * overhead as I'd imagined.
+ *
+ * Anyway, we record statistics based on source address, mode and
+ * version (for now, anyway. Check the code).  The receive procedure
+ * calls us with the incoming rbufp before it does anything else.
+ *
+ * Each entry is doubly linked into two lists, a hash table and a
+ * most-recently-used list. When a packet arrives it is looked up in
+ * the hash table.  If found, the statistics are updated and the entry
+ * relinked at the head of the MRU list. If not found, a new entry is
+ * allocated, initialized and linked into both the hash table and at the
+ * head of the MRU list.
+ *
+ * Memory is usually allocated by grabbing a big chunk of new memory and
+ * cutting it up into littler pieces. The exception to this when we hit
+ * the memory limit. Then we free memory by grabbing entries off the
+ * tail for the MRU list, unlinking from the hash table, and
+ * reinitializing.
+ *
+ * trimmed back memory consumption ... jdg 8/94
+ */
+/*
+ * Limits on the number of structures allocated.  This limit is picked
+ * with the illicit knowlege that we can only return somewhat less
+ * than 8K bytes in a mode 7 response packet, and that each structure
+ * will require about 20 bytes of space in the response.
+ *
+ * ... I don't believe the above is true anymore ... jdg
+ */
+#ifndef MAXMONMEM
+#define        MAXMONMEM       600     /* we allocate up to 600 structures */
+#endif
+#ifndef MONMEMINC
+#define        MONMEMINC       40      /* allocate them 40 at a time */
+#endif
+
+/*
+ * Hashing stuff
+ */
+#define        MON_HASH_SIZE   128
+#define        MON_HASH_MASK   (MON_HASH_SIZE-1)
+#define        MON_HASH(addr)  sock_hash(addr)
+
+/*
+ * Pointers to the hash table, the MRU list and the count table.  Memory
+ * for the hash and count tables is only allocated if monitoring is
+ * turned on.
+ */
+static struct mon_data *mon_hash[MON_HASH_SIZE];  /* list ptrs */
+struct mon_data mon_mru_list;
+
+/*
+ * List of free structures structures, and counters of free and total
+ * structures.  The free structures are linked with the hash_next field.
+ */
+static  struct mon_data *mon_free;      /* free list or null if none */
+static int mon_total_mem;              /* total structures allocated */
+static int mon_mem_increments;         /* times called malloc() */
+
+/*
+ * Initialization state.  We may be monitoring, we may not.  If
+ * we aren't, we may not even have allocated any memory yet.
+ */
+int    mon_enabled;                    /* enable switch */
+u_long mon_age = 3000;                 /* preemption limit */
+static int mon_have_memory;
+static void    mon_getmoremem  P((void));
+static void    remove_from_hash P((struct mon_data *));
+
+/*
+ * init_mon - initialize monitoring global data
+ */
+void
+init_mon(void)
+{
+       /*
+        * Don't do much of anything here.  We don't allocate memory
+        * until someone explicitly starts us.
+        */
+       mon_enabled = MON_OFF;
+       mon_have_memory = 0;
+
+       mon_total_mem = 0;
+       mon_mem_increments = 0;
+       mon_free = NULL;
+       memset(&mon_hash[0], 0, sizeof mon_hash);
+       memset(&mon_mru_list, 0, sizeof mon_mru_list);
+}
+
+
+/*
+ * mon_start - start up the monitoring software
+ */
+void
+mon_start(
+       int mode
+       )
+{
+
+       if (mon_enabled != MON_OFF) {
+               mon_enabled |= mode;
+               return;
+       }
+       if (mode == MON_OFF)
+           return;
+       
+       if (!mon_have_memory) {
+               mon_total_mem = 0;
+               mon_mem_increments = 0;
+               mon_free = NULL;
+               mon_getmoremem();
+               mon_have_memory = 1;
+       }
+
+       mon_mru_list.mru_next = &mon_mru_list;
+       mon_mru_list.mru_prev = &mon_mru_list;
+       mon_enabled = mode;
+}
+
+
+/*
+ * mon_stop - stop the monitoring software
+ */
+void
+mon_stop(
+       int mode
+       )
+{
+       register struct mon_data *md, *md_next;
+       register int i;
+
+       if (mon_enabled == MON_OFF)
+           return;
+       if ((mon_enabled & mode) == 0 || mode == MON_OFF)
+           return;
+
+       mon_enabled &= ~mode;
+       if (mon_enabled != MON_OFF)
+           return;
+       
+       /*
+        * Put everything back on the free list
+        */
+       for (i = 0; i < MON_HASH_SIZE; i++) {
+               md = mon_hash[i];               /* get next list */
+               mon_hash[i] = NULL;             /* zero the list head */
+               while (md != NULL) {
+                       md_next = md->hash_next;
+                       md->hash_next = mon_free;
+                       mon_free = md;
+                       md = md_next;
+               }
+       }
+
+       mon_mru_list.mru_next = &mon_mru_list;
+       mon_mru_list.mru_prev = &mon_mru_list;
+}
+
+void
+ntp_monclearinterface(struct interface *interface)
+{
+        struct mon_data *md;
+
+       for (md = mon_mru_list.mru_next; md != &mon_mru_list;
+            md = md->mru_next) {
+         if (md->interface == interface) 
+           {
+             /* dequeue from mru list and put to free list */
+             md->mru_prev->mru_next = md->mru_next;
+             md->mru_next->mru_prev = md->mru_prev;
+             remove_from_hash(md);
+             md->hash_next = mon_free;
+             mon_free = md;
+           }
+       }
+}
+
+/*
+ * ntp_monitor - record stats about this packet
+ *
+ * Returns 1 if the packet is at the head of the list, 0 otherwise.
+ */
+int
+ntp_monitor(
+       struct recvbuf *rbufp
+       )
+{
+       register struct pkt *pkt;
+       register struct mon_data *md;
+        struct sockaddr_storage addr;
+       register int hash;
+       register int mode;
+
+       if (mon_enabled == MON_OFF)
+               return 0;
+
+       pkt = &rbufp->recv_pkt;
+       memset(&addr, 0, sizeof(addr));
+       memcpy(&addr, &(rbufp->recv_srcadr), sizeof(addr));
+       hash = MON_HASH(&addr);
+       mode = PKT_MODE(pkt->li_vn_mode);
+       md = mon_hash[hash];
+       while (md != NULL) {
+
+               /*
+                * Match address only to conserve MRU size.
+                */
+               if (SOCKCMP(&md->rmtadr, &addr)) {
+                       md->drop_count = current_time - md->lasttime;
+                       md->lasttime = current_time;
+                       md->count++;
+                       md->rmtport = NSRCPORT(&rbufp->recv_srcadr);
+                       md->mode = (u_char) mode;
+                       md->version = PKT_VERSION(pkt->li_vn_mode);
+
+                       /*
+                        * Shuffle to the head of the MRU list.
+                        */
+                       md->mru_next->mru_prev = md->mru_prev;
+                       md->mru_prev->mru_next = md->mru_next;
+                       md->mru_next = mon_mru_list.mru_next;
+                       md->mru_prev = &mon_mru_list;
+                       mon_mru_list.mru_next->mru_prev = md;
+                       mon_mru_list.mru_next = md;
+                       return 1;
+               }
+               md = md->hash_next;
+       }
+
+       /*
+        * If we got here, this is the first we've heard of this
+        * guy.  Get him some memory, either from the free list
+        * or from the tail of the MRU list.
+        */
+       if (mon_free == NULL && mon_total_mem >= MAXMONMEM) {
+
+               /*
+                * Preempt from the MRU list if old enough.
+                */
+               md = mon_mru_list.mru_prev;
+               /* We get 31 bits from ntp_random() */
+               if (((u_long)ntp_random()) / FRAC >
+                   (double)(current_time - md->lasttime) / mon_age)
+                       return 0;
+
+               md->mru_prev->mru_next = &mon_mru_list;
+               mon_mru_list.mru_prev = md->mru_prev;
+               remove_from_hash(md);
+       } else {
+               if (mon_free == NULL)
+                       mon_getmoremem();
+               md = mon_free;
+               mon_free = md->hash_next;
+       }
+
+       /*
+        * Got one, initialize it
+        */
+       md->avg_interval = 0;
+       md->lasttime = current_time;
+       md->count = 1;
+       md->drop_count = 0;
+       memset(&md->rmtadr, 0, sizeof(md->rmtadr));
+       memcpy(&md->rmtadr, &addr, sizeof(addr));
+       md->rmtport = NSRCPORT(&rbufp->recv_srcadr);
+       md->mode = (u_char) mode;
+       md->version = PKT_VERSION(pkt->li_vn_mode);
+       md->interface = rbufp->dstadr;
+       md->cast_flags = (u_char)(((rbufp->dstadr->flags & INT_MCASTOPEN) &&
+           rbufp->fd == md->interface->fd) ? MDF_MCAST: rbufp->fd ==
+               md->interface->bfd ? MDF_BCAST : MDF_UCAST);
+
+       /*
+        * Drop him into front of the hash table. Also put him on top of
+        * the MRU list.
+        */
+       md->hash_next = mon_hash[hash];
+       mon_hash[hash] = md;
+       md->mru_next = mon_mru_list.mru_next;
+       md->mru_prev = &mon_mru_list;
+       mon_mru_list.mru_next->mru_prev = md;
+       mon_mru_list.mru_next = md;
+       return 1;
+}
+
+
+/*
+ * mon_getmoremem - get more memory and put it on the free list
+ */
+static void
+mon_getmoremem(void)
+{
+       register struct mon_data *md;
+       register int i;
+       struct mon_data *freedata;      /* 'old' free list (null) */
+
+       md = (struct mon_data *)emalloc(MONMEMINC *
+           sizeof(struct mon_data));
+       freedata = mon_free;
+       mon_free = md;
+       for (i = 0; i < (MONMEMINC-1); i++) {
+               md->hash_next = (md + 1);
+               md++;
+       }
+
+       /*
+        * md now points at the last.  Link in the rest of the chain.
+        */
+       md->hash_next = freedata;
+       mon_total_mem += MONMEMINC;
+       mon_mem_increments++;
+}
+
+static void
+remove_from_hash(
+       struct mon_data *md
+       )
+{
+       register int hash;
+       register struct mon_data *md_prev;
+
+       hash = MON_HASH(&md->rmtadr);
+       if (mon_hash[hash] == md) {
+               mon_hash[hash] = md->hash_next;
+       } else {
+               md_prev = mon_hash[hash];
+               while (md_prev->hash_next != md) {
+                       md_prev = md_prev->hash_next;
+                       if (md_prev == NULL) {
+                               /* logic error */
+                               return;
+                       }
+               }
+               md_prev->hash_next = md->hash_next;
+       }
+}
diff --git a/ntpd/ntp_peer.c b/ntpd/ntp_peer.c
new file mode 100644 (file)
index 0000000..deeec5b
--- /dev/null
@@ -0,0 +1,1051 @@
+/*
+ * ntp_peer.c - management of data maintained for peer associations
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "ntpd.h"
+#include "ntp_stdlib.h"
+#include <ntp_random.h>
+#ifdef OPENSSL
+#include "openssl/rand.h"
+#endif /* OPENSSL */
+
+#ifdef SYS_WINNT
+extern int accept_wildcard_if_for_winnt;
+#endif
+
+/*
+ *                  Table of valid association combinations
+ *                  ---------------------------------------
+ *
+ *                             packet->mode
+ * peer->mode      | UNSPEC  ACTIVE PASSIVE  CLIENT  SERVER  BCAST
+ * ----------      | ---------------------------------------------
+ * NO_PEER         |   e       1       0       1       1       1
+ * ACTIVE          |   e       1       1       0       0       0
+ * PASSIVE         |   e       1       e       0       0       0
+ * CLIENT          |   e       0       0       0       1       1
+ * SERVER          |   e       0       0       0       0       0
+ * BCAST           |   e       0       0       0       0       0
+ * BCLIENT         |   e       0       0       0       e       1
+ *
+ * One point to note here: a packet in BCAST mode can potentially match
+ * a peer in CLIENT mode, but we that is a special case and we check for
+ * that early in the decision process.  This avoids having to keep track
+ * of what kind of associations are possible etc...  We actually
+ * circumvent that problem by requiring that the first b(m)roadcast
+ * received after the change back to BCLIENT mode sets the clock.
+ */
+#define AM_MODES       7       /* number of rows and columns */
+#define NO_PEER                0       /* action when no peer is found */
+
+int AM[AM_MODES][AM_MODES] = {
+/*     { UNSPEC,   ACTIVE,     PASSIVE,    CLIENT,     SERVER,     BCAST } */
+
+/*NONE*/{ AM_ERR, AM_NEWPASS, AM_NOMATCH, AM_FXMIT,   AM_MANYCAST, AM_NEWBCL},
+
+/*A*/  { AM_ERR, AM_PROCPKT, AM_PROCPKT, AM_NOMATCH, AM_NOMATCH,  AM_NOMATCH},
+
+/*P*/  { AM_ERR, AM_PROCPKT, AM_ERR,     AM_NOMATCH, AM_NOMATCH,  AM_NOMATCH},
+
+/*C*/  { AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_PROCPKT,  AM_POSSBCL},
+
+/*S*/  { AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH,  AM_NOMATCH},
+
+/*BCST*/{ AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH,  AM_NOMATCH},
+
+/*BCL*/ { AM_ERR, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH, AM_NOMATCH,  AM_PROCPKT},
+};
+
+#define MATCH_ASSOC(x,y)       AM[(x)][(y)]
+
+/*
+ * These routines manage the allocation of memory to peer structures
+ * and the maintenance of the peer hash table. The two main entry
+ * points are findpeer(), which looks for matching peer sturctures in
+ * the peer list, newpeer(), which allocates a new peer structure and
+ * adds it to the list, and unpeer(), which demobilizes the association
+ * and deallocates the structure.
+ */
+/*
+ * Peer hash tables
+ */
+struct peer *peer_hash[NTP_HASH_SIZE]; /* peer hash table */
+int peer_hash_count[NTP_HASH_SIZE];    /* peers in each bucket */
+struct peer *assoc_hash[NTP_HASH_SIZE];        /* association ID hash table */
+int assoc_hash_count[NTP_HASH_SIZE];   /* peers in each bucket */
+static struct peer *peer_free;         /* peer structures free list */
+int peer_free_count;                   /* count of free structures */
+
+/*
+ * Association ID.  We initialize this value randomly, then assign a new
+ * value every time the peer structure is incremented.
+ */
+static associd_t current_association_ID; /* association ID */
+
+/*
+ * Memory allocation watermarks.
+ */
+#define        INIT_PEER_ALLOC         15      /* initialize for 15 peers */
+#define        INC_PEER_ALLOC          5       /* when run out, add 5 more */
+
+/*
+ * Miscellaneous statistic counters which may be queried.
+ */
+u_long peer_timereset;                 /* time stat counters zeroed */
+u_long findpeer_calls;                 /* calls to findpeer */
+u_long assocpeer_calls;                        /* calls to findpeerbyassoc */
+u_long peer_allocations;               /* allocations from free list */
+u_long peer_demobilizations;           /* structs freed to free list */
+int total_peer_structs;                        /* peer structs */
+int peer_associations;                 /* mobilized associations */
+int peer_preempt;                      /* preemptable associations */
+static struct peer init_peer_alloc[INIT_PEER_ALLOC]; /* init alloc */
+
+static void        getmorepeermem       P((void));
+static struct interface *select_peerinterface P((struct peer *, struct sockaddr_storage *, struct interface *, u_char));
+
+/*
+ * init_peer - initialize peer data structures and counters
+ *
+ * N.B. We use the random number routine in here. It had better be
+ * initialized prior to getting here.
+ */
+void
+init_peer(void)
+{
+       register int i;
+
+       /*
+        * Clear hash table and counters.
+        */
+       for (i = 0; i < NTP_HASH_SIZE; i++) {
+               peer_hash[i] = 0;
+               peer_hash_count[i] = 0;
+               assoc_hash[i] = 0;
+               assoc_hash_count[i] = 0;
+       }
+
+       /*
+        * Clear stat counters
+        */
+       findpeer_calls = peer_allocations = 0;
+       assocpeer_calls = peer_demobilizations = 0;
+
+       /*
+        * Initialize peer memory.
+        */
+       peer_free = 0;
+       for (i = 0; i < INIT_PEER_ALLOC; i++) {
+               init_peer_alloc[i].next = peer_free;
+               peer_free = &init_peer_alloc[i];
+       }
+       total_peer_structs = INIT_PEER_ALLOC;
+       peer_free_count = INIT_PEER_ALLOC;
+
+       /*
+        * Initialize our first association ID
+        */
+       while ((current_association_ID = ntp_random() & 0xffff) == 0);
+}
+
+
+/*
+ * getmorepeermem - add more peer structures to the free list
+ */
+static void
+getmorepeermem(void)
+{
+       register int i;
+       register struct peer *peer;
+
+       peer = (struct peer *)emalloc(INC_PEER_ALLOC *
+           sizeof(struct peer));
+       for (i = 0; i < INC_PEER_ALLOC; i++) {
+               peer->next = peer_free;
+               peer_free = peer;
+               peer++;
+       }
+
+       total_peer_structs += INC_PEER_ALLOC;
+       peer_free_count += INC_PEER_ALLOC;
+}
+
+
+/*
+ * findexistingpeer - return a pointer to a peer in the hash table
+ */
+struct peer *
+findexistingpeer(
+       struct sockaddr_storage *addr,
+       struct peer *start_peer,
+       int mode
+       )
+{
+       register struct peer *peer;
+
+       /*
+        * start_peer is included so we can locate instances of the
+        * same peer through different interfaces in the hash table.
+        */
+       if (start_peer == 0)
+               peer = peer_hash[NTP_HASH_ADDR(addr)];
+       else
+               peer = start_peer->next;
+       
+       while (peer != 0) {
+               if (SOCKCMP(addr, &peer->srcadr)
+                   && NSRCPORT(addr) == NSRCPORT(&peer->srcadr)) {
+                       if (mode == -1)
+                               return (peer);
+                       else if (peer->hmode == mode)
+                               break;
+               }
+               peer = peer->next;
+       }
+       return (peer);
+}
+
+
+/*
+ * findpeer - find and return a peer in the hash table.
+ */
+struct peer *
+findpeer(
+       struct sockaddr_storage *srcadr,
+       struct interface *dstadr,
+       int     pkt_mode,
+       int     *action
+       )
+{
+       register struct peer *peer;
+       int hash;
+
+       findpeer_calls++;
+       hash = NTP_HASH_ADDR(srcadr);
+       for (peer = peer_hash[hash]; peer != NULL; peer = peer->next) {
+               if (SOCKCMP(srcadr, &peer->srcadr) &&
+                   NSRCPORT(srcadr) == NSRCPORT(&peer->srcadr)) {
+
+                       /*
+                        * if the association matching rules determine
+                        * that this is not a valid combination, then
+                        * look for the next valid peer association.
+                        */
+                       *action = MATCH_ASSOC(peer->hmode, pkt_mode);
+
+                       /*
+                        * if an error was returned, exit back right
+                        * here.
+                        */
+                       if (*action == AM_ERR)
+                               return ((struct peer *)0);
+
+                       /*
+                        * if a match is found, we stop our search.
+                        */
+                       if (*action != AM_NOMATCH)
+                               break;
+               }
+       }
+
+       /*
+        * If no matching association is found
+        */
+       if (peer == 0) {
+               *action = MATCH_ASSOC(NO_PEER, pkt_mode);
+               return ((struct peer *)0);
+       }
+
+       set_peerdstadr(peer, dstadr);
+
+       return (peer);
+}
+
+/*
+ * findpeerbyassocid - find and return a peer using his association ID
+ */
+struct peer *
+findpeerbyassoc(
+       u_int assoc
+       )
+{
+       register struct peer *peer;
+       int hash;
+
+       assocpeer_calls++;
+
+       hash = assoc & NTP_HASH_MASK;
+       for (peer = assoc_hash[hash]; peer != 0; peer =
+           peer->ass_next) {
+               if (assoc == peer->associd)
+                   return (peer);
+       }
+       return (NULL);
+}
+
+
+/*
+ * clear_all - flush all time values for all associations
+ */
+void
+clear_all(void)
+{
+       struct peer *peer, *next_peer;
+       int n;
+
+       /*
+        * This routine is called when the clock is stepped, and so all
+        * previously saved time values are untrusted.
+        */
+       for (n = 0; n < NTP_HASH_SIZE; n++) {
+               for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
+                       next_peer = peer->next;
+                       if (!(peer->cast_flags & (MDF_ACAST | MDF_MCAST |
+                           MDF_BCAST))) {
+                               peer->hpoll = peer->minpoll;
+                               peer_clear(peer, "STEP");
+                       }
+               }
+       }
+#ifdef DEBUG
+       if (debug)
+               printf("clear_all: at %lu\n", current_time);
+#endif
+}
+
+
+/*
+ * unpeer - remove peer structure from hash table and free structure
+ */
+void
+unpeer(
+       struct peer *peer_to_remove
+       )
+{
+       int hash;
+#ifdef OPENSSL
+       char    statstr[NTP_MAXSTRLEN]; /* statistics for filegen */
+
+       if (peer_to_remove->flags & FLAG_SKEY) {
+               sprintf(statstr, "unpeer %d flash %x reach %03o flags %04x",
+                   peer_to_remove->associd, peer_to_remove->flash,
+                   peer_to_remove->reach, peer_to_remove->flags);
+               record_crypto_stats(&peer_to_remove->srcadr, statstr);
+#ifdef DEBUG
+               if (debug)
+                       printf("peer: %s\n", statstr);
+#endif
+       }
+#endif /* OPENSSL */
+#ifdef DEBUG
+       if (debug)
+               printf("demobilize %u %d %d\n", peer_to_remove->associd,
+                   peer_associations, peer_preempt);
+#endif
+       set_peerdstadr(peer_to_remove, NULL);
+
+       /* XXXMEMLEAK? peer_clear->crypto allocation */
+
+       hash = NTP_HASH_ADDR(&peer_to_remove->srcadr);
+       peer_hash_count[hash]--;
+       peer_demobilizations++;
+       peer_associations--;
+       if (peer_to_remove->flags & FLAG_PREEMPT)
+               peer_preempt--;
+#ifdef REFCLOCK
+       /*
+        * If this peer is actually a clock, shut it down first
+        */
+       if (peer_to_remove->flags & FLAG_REFCLOCK)
+               refclock_unpeer(peer_to_remove);
+#endif
+       peer_to_remove->action = 0;     /* disable timeout actions */
+       if (peer_hash[hash] == peer_to_remove)
+               peer_hash[hash] = peer_to_remove->next;
+       else {
+               register struct peer *peer;
+
+               peer = peer_hash[hash];
+               while (peer != 0 && peer->next != peer_to_remove)
+                   peer = peer->next;
+               
+               if (peer == 0) {
+                       peer_hash_count[hash]++;
+                       msyslog(LOG_ERR, "peer struct for %s not in table!",
+                               stoa(&peer->srcadr));
+               } else {
+                       peer->next = peer_to_remove->next;
+               }
+       }
+
+       /*
+        * Remove him from the association hash as well.
+        */
+       hash = peer_to_remove->associd & NTP_HASH_MASK;
+       assoc_hash_count[hash]--;
+       if (assoc_hash[hash] == peer_to_remove)
+               assoc_hash[hash] = peer_to_remove->ass_next;
+       else {
+               register struct peer *peer;
+
+               peer = assoc_hash[hash];
+               while (peer != 0 && peer->ass_next != peer_to_remove)
+                   peer = peer->ass_next;
+               
+               if (peer == 0) {
+                       assoc_hash_count[hash]++;
+                       msyslog(LOG_ERR,
+                               "peer struct for %s not in association table!",
+                               stoa(&peer->srcadr));
+               } else {
+                       peer->ass_next = peer_to_remove->ass_next;
+               }
+       }
+       peer_to_remove->next = peer_free;
+       peer_free = peer_to_remove;
+       peer_free_count++;
+}
+
+
+/*
+ * peer_config - configure a new association
+ */
+struct peer *
+peer_config(
+       struct sockaddr_storage *srcadr,
+       struct interface *dstadr,
+       int hmode,
+       int version,
+       int minpoll,
+       int maxpoll,
+       u_int flags,
+       int ttl,
+       keyid_t key,
+       u_char *keystr
+       )
+{
+       register struct peer *peer;
+       u_char cast_flags;
+
+       /*
+        * First search from the beginning for an association with given
+        * remote address and mode. If an interface is given, search
+        * from there to find the association which matches that
+        * destination.  If the given interface is "any", track down
+        * the actual interface, because that's what gets put into the
+        * peer structure.
+        */
+       peer = findexistingpeer(srcadr, (struct peer *)0, hmode);
+       if (dstadr != 0) {
+               while (peer != 0) {
+                       if (peer->dstadr == dstadr)
+                               break;
+                       if (dstadr == ANY_INTERFACE_CHOOSE(srcadr) &&
+                           peer->dstadr == findinterface(srcadr))
+                            break;
+                       peer = findexistingpeer(srcadr, peer, hmode);
+               }
+       }
+
+       /*
+        * We do a dirty little jig to figure the cast flags. This is
+        * probably not the best place to do this, at least until the
+        * configure code is rebuilt. Note only one flag can be set.
+        */
+       switch (hmode) {
+
+       case MODE_BROADCAST:
+               if(srcadr->ss_family == AF_INET) {
+                       if (IN_CLASSD(ntohl(((struct sockaddr_in*)srcadr)->sin_addr.s_addr)))
+                               cast_flags = MDF_MCAST;
+                       else
+                               cast_flags = MDF_BCAST;
+                       break;
+               }
+               else {
+                        if (IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)srcadr)->sin6_addr))
+                               cast_flags = MDF_MCAST;
+                       else
+                               cast_flags = MDF_BCAST;
+                       break;
+                }
+
+       case MODE_CLIENT:
+               if(srcadr->ss_family == AF_INET) {
+                       if (IN_CLASSD(ntohl(((struct sockaddr_in*)srcadr)->sin_addr.s_addr)))
+                               cast_flags = MDF_ACAST;
+                       else
+                               cast_flags = MDF_UCAST;
+                       break;
+               }
+               else {
+                       if (IN6_IS_ADDR_MULTICAST(&((struct sockaddr_in6*)srcadr)->sin6_addr))
+                               cast_flags = MDF_ACAST;
+                       else
+                               cast_flags = MDF_UCAST;
+                       break;
+               }
+
+       default:
+               cast_flags = MDF_UCAST;
+       }
+
+       /*
+        * If the peer is already configured, some dope has a duplicate
+        * configureation entry or another dope is wiggling from afar.
+        */
+       if (peer != 0) {
+               peer->hmode = (u_char)hmode;
+               peer->version = (u_char) version;
+               peer->minpoll = (u_char) minpoll;
+               peer->maxpoll = (u_char) maxpoll;
+               peer->flags = flags | FLAG_CONFIG |
+                       (peer->flags & FLAG_REFCLOCK);
+               peer->cast_flags = cast_flags;
+               peer->ttl = (u_char) ttl;
+               peer->keyid = key;
+               peer->precision = sys_precision;
+               peer_clear(peer, "RMOT");
+               return (peer);
+       }
+
+       /*
+        * Here no match has been found, so presumably this is a new
+        * persistent association. Mobilize the thing and initialize its
+        * variables. If emulating ntpdate, force iburst.
+        */
+       if (mode_ntpdate)
+               flags |= FLAG_IBURST;
+       peer = newpeer(srcadr, dstadr, hmode, version, minpoll, maxpoll,
+           flags | FLAG_CONFIG, cast_flags, ttl, key);
+       return (peer);
+}
+
+/*
+ * setup peer dstadr field keeping it in sync with the interface structures
+ */
+void
+set_peerdstadr(struct peer *peer, struct interface *interface)
+{
+       if (peer->dstadr != interface) {
+               if (interface != NULL &&
+                   (peer->cast_flags & MDF_BCLNT) &&
+                   (interface->flags & INT_MCASTIF) &&
+                   peer->burst) {
+                       /*
+                        * don't accept updates to a true multicast reception
+                        * interface while a BCLNT peer is running it's
+                        * unicast protocol
+                        */
+                       return;
+               }
+
+               if (peer->dstadr != NULL)
+               {
+                       peer->dstadr->peercnt--;
+                       ISC_LIST_UNLINK_TYPE(peer->dstadr->peers, peer, ilink, struct peer);
+               }
+
+               DPRINTF(4, ("set_peerdstadr(%s): change interface from %s to %s\n",
+                           stoa(&peer->srcadr),
+                           (peer->dstadr != NULL) ? stoa(&peer->dstadr->sin) : "<null>",
+                           (interface != NULL) ? stoa(&interface->sin) : "<null>"));
+
+               peer->dstadr = interface;
+
+               if (peer->dstadr != NULL)
+               {
+                       ISC_LIST_APPEND(peer->dstadr->peers, peer, ilink);
+                       peer->dstadr->peercnt++;
+               }
+       }
+}
+
+/*
+ * attempt to re-rebind interface if necessary
+ */
+static void
+peer_refresh_interface(struct peer *peer)
+{
+       struct interface *niface, *piface;
+
+       niface = select_peerinterface(peer, &peer->srcadr, NULL, peer->cast_flags);
+
+#ifdef DEBUG
+       if (debug > 3)
+       {
+               printf(
+                       "peer_refresh_interface: %s->%s mode %d vers %d poll %d %d flags 0x%x 0x%x ttl %d key %08x: new interface: ",
+                       peer->dstadr == NULL ? "<null>" : stoa(&peer->dstadr->sin),
+                       stoa(&peer->srcadr),
+                       peer->hmode, peer->version, peer->minpoll,
+                       peer->maxpoll, peer->flags, peer->cast_flags,
+                       peer->ttl, peer->keyid);
+               if (niface != NULL) 
+               {
+                       printf("fd=%d, bfd=%d, name=%.16s, flags=0x%x, scope=%d, ",
+                              niface->fd,
+                              niface->bfd,
+                              niface->name,
+                              niface->flags,
+                              niface->scopeid);
+                       /* Leave these as three printf calls. */
+                       printf(", sin=%s",
+                              stoa((&niface->sin)));
+                       if (niface->flags & INT_BROADCAST)
+                               printf(", bcast=%s,",
+                                      stoa((&niface->bcast)));
+                       printf(", mask=%s\n",
+                              stoa((&niface->mask)));
+               }
+               else
+               {
+                       printf("<NONE>\n");
+               }
+       }
+#endif
+
+       piface = peer->dstadr;
+
+       set_peerdstadr(peer, niface);
+
+       if (peer->dstadr) {
+                /*
+                 * clear crypto if we change the local address
+                 */
+                if (peer->dstadr != piface && !(peer->cast_flags & MDF_BCLNT)) {
+                       peer_crypto_clear(peer);
+               }
+
+               /*
+                * Broadcast needs the socket enabled for broadcast
+                */
+               if (peer->cast_flags & MDF_BCAST) {
+                       enable_broadcast(peer->dstadr, &peer->srcadr);
+               }
+
+               /*
+                * Multicast needs the socket interface enabled for multicast
+                */
+               if (peer->cast_flags & MDF_MCAST) {
+                       enable_multicast_if(peer->dstadr, &peer->srcadr);
+               }
+       }
+}
+
+/*
+ * refresh_all_peerinterfaces - see that all interface bindings are up to date
+ */
+void
+refresh_all_peerinterfaces(void)
+{
+       struct peer *peer, *next_peer;
+       int n;
+
+       /*
+        * this is called when the interface list has changed
+        * give all peers a chance to find a better interface
+        */
+       for (n = 0; n < NTP_HASH_SIZE; n++) {
+               for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
+                       next_peer = peer->next;
+                       peer_refresh_interface(peer);
+               }
+       }
+}
+
+       
+/*
+ * find an interface suitable for the src address
+ */
+static struct interface *
+select_peerinterface(struct peer *peer, struct sockaddr_storage *srcadr, struct interface *dstadr, u_char cast_flags)
+{
+       struct interface *interface;
+  
+       /*
+        * Initialize the peer structure and dance the interface jig.
+        * Reference clocks step the loopback waltz, the others
+        * squaredance around the interface list looking for a buddy. If
+        * the dance peters out, there is always the wildcard interface.
+        * This might happen in some systems and would preclude proper
+        * operation with public key cryptography.
+        */
+       if (ISREFCLOCKADR(srcadr))
+               interface = loopback_interface;
+       else
+               if (cast_flags & (MDF_BCLNT | MDF_ACAST | MDF_MCAST | MDF_BCAST)) {
+                       interface = findbcastinter(srcadr);
+#ifdef DEBUG
+                       if (debug > 3) {
+                               if (interface != NULL)
+                                       printf("Found *-cast interface address %s, for address %s\n",
+                                              stoa(&(interface)->sin), stoa(srcadr));
+                               else
+                                       printf("No *-cast local address found for address %s\n",
+                                              stoa(srcadr));
+                       }
+#endif
+                       /*
+                        * If it was a multicast packet, findbcastinter() may not
+                        * find it, so try a little harder.
+                        */
+                       if (interface == ANY_INTERFACE_CHOOSE(srcadr))
+                               interface = findinterface(srcadr);
+               }
+               else if (dstadr != NULL && dstadr != ANY_INTERFACE_CHOOSE(srcadr))
+                       interface = dstadr;
+               else
+                       interface = findinterface(srcadr);
+
+       /*
+        * we do not bind to the wildcard interfaces for output 
+        * as our (network) source address would be undefined and
+        * crypto will not work without knowing the own transmit address
+        */
+       if (interface != NULL && interface->flags & INT_WILDCARD)
+#ifdef SYS_WINNT
+               if ( !accept_wildcard_if_for_winnt )  
+#endif
+                       interface = NULL;
+
+
+       return interface;
+}
+
+/*
+ * newpeer - initialize a new peer association
+ */
+struct peer *
+newpeer(
+       struct sockaddr_storage *srcadr,
+       struct interface *dstadr,
+       int hmode,
+       int version,
+       int minpoll,
+       int maxpoll,
+       u_int flags,
+       u_char cast_flags,
+       int ttl,
+       keyid_t key
+       )
+{
+       register struct peer *peer;
+       register int i;
+#ifdef OPENSSL
+       char    statstr[NTP_MAXSTRLEN]; /* statistics for filegen */
+#endif /* OPENSSL */
+
+       /*
+        * Allocate a new peer structure. Some dirt here, since some of
+        * the initialization requires knowlege of our system state.
+        */
+       if (peer_free_count == 0)
+               getmorepeermem();
+       peer = peer_free;
+       peer_free = peer->next;
+       peer_free_count--;
+       peer_associations++;
+       if (flags & FLAG_PREEMPT)
+               peer_preempt++;
+       memset((char *)peer, 0, sizeof(struct peer));
+
+       /*
+        * Assign an association ID and increment the system variable.
+        */
+       peer->associd = current_association_ID;
+       if (++current_association_ID == 0)
+               ++current_association_ID;
+
+       DPRINTF(3, ("newpeer: cast flags: 0x%x for address: %s\n",
+                   cast_flags, stoa(srcadr)));
+
+       ISC_LINK_INIT(peer, ilink);  /* set up interface link chain */
+       peer->srcadr = *srcadr;
+       set_peerdstadr(peer, select_peerinterface(peer, srcadr, dstadr,
+           cast_flags));
+       peer->hmode = (u_char)hmode;
+       peer->version = (u_char)version;
+       peer->minpoll = (u_char)max(NTP_MINPOLL, minpoll);
+       peer->maxpoll = (u_char)min(NTP_MAXPOLL, maxpoll);
+       peer->flags = flags;
+#ifdef DEBUG
+       if (debug > 2) {
+               if (peer->dstadr)
+                       printf("newpeer: using fd %d and our addr %s\n",
+                                   peer->dstadr->fd,
+                                   stoa(&peer->dstadr->sin));
+               else
+                       printf("newpeer: local interface currently not bound\n");
+       }
+#endif
+
+       /*
+        * Broadcast needs the socket enabled for broadcast
+        */
+       if (cast_flags & MDF_BCAST && peer->dstadr) {
+               enable_broadcast(peer->dstadr, srcadr);
+       }
+       /*
+        * Multicast needs the socket interface enabled for multicast
+        */
+       if (cast_flags & MDF_MCAST && peer->dstadr) {
+               enable_multicast_if(peer->dstadr, srcadr);
+       }
+       if (key != 0)
+               peer->flags |= FLAG_AUTHENABLE;
+       if (key > NTP_MAXKEY)
+               peer->flags |= FLAG_SKEY;
+       peer->cast_flags = cast_flags;
+       peer->ttl = (u_char)ttl;
+       peer->keyid = key;
+       peer->precision = sys_precision;
+       peer->hpoll = peer->minpoll;
+       if (cast_flags & MDF_ACAST)
+               peer_clear(peer, "ACST");
+       else if (cast_flags & MDF_MCAST)
+               peer_clear(peer, "MCST");
+       else if (cast_flags & MDF_BCAST)
+               peer_clear(peer, "BCST");
+       else
+               peer_clear(peer, "INIT");
+       if (mode_ntpdate)
+               peer_ntpdate++;
+
+       /*
+        * Note time on statistics timers.
+        */
+       peer->timereset = current_time;
+       peer->timereachable = current_time;
+       peer->timereceived = current_time;
+
+#ifdef REFCLOCK
+       if (ISREFCLOCKADR(&peer->srcadr)) {
+
+               /*
+                * We let the reference clock support do clock
+                * dependent initialization.  This includes setting
+                * the peer timer, since the clock may have requirements
+                * for this.
+                */
+               if (!refclock_newpeer(peer)) {
+                       /*
+                        * Dump it, something screwed up
+                        */
+                       set_peerdstadr(peer, NULL);
+       
+                       peer->next = peer_free;
+                       peer_free = peer;
+                       peer_free_count++;
+                       return (NULL);
+               }
+       }
+#endif
+
+       /*
+        * Put the new peer in the hash tables.
+        */
+       i = NTP_HASH_ADDR(&peer->srcadr);
+       peer->next = peer_hash[i];
+       peer_hash[i] = peer;
+       peer_hash_count[i]++;
+       i = peer->associd & NTP_HASH_MASK;
+       peer->ass_next = assoc_hash[i];
+       assoc_hash[i] = peer;
+       assoc_hash_count[i]++;
+
+#ifdef OPENSSL
+       if (peer->flags & FLAG_SKEY) {
+               sprintf(statstr, "newpeer %d", peer->associd);
+               record_crypto_stats(&peer->srcadr, statstr);
+               DPRINTF(1, ("peer: %s\n", statstr));
+       }
+#endif /* OPENSSL */
+
+       DPRINTF(1, ("newpeer: %s->%s mode %d vers %d poll %d %d flags 0x%x 0x%x ttl %d key %08x\n",
+                   peer->dstadr == NULL ? "<null>" : stoa(&peer->dstadr->sin),
+                   stoa(&peer->srcadr),
+                   peer->hmode, peer->version, peer->minpoll,
+                   peer->maxpoll, peer->flags, peer->cast_flags,
+                   peer->ttl, peer->keyid));
+
+       return (peer);
+}
+
+
+/*
+ * peer_unconfig - remove the configuration bit from a peer
+ */
+int
+peer_unconfig(
+       struct sockaddr_storage *srcadr,
+       struct interface *dstadr,
+       int mode
+       )
+{
+       register struct peer *peer;
+       int num_found;
+
+       num_found = 0;
+       peer = findexistingpeer(srcadr, (struct peer *)0, mode);
+       while (peer != 0) {
+               if (peer->flags & FLAG_CONFIG
+                   && (dstadr == 0 || peer->dstadr == dstadr)) {
+                       num_found++;
+
+                       /*
+                        * Tricky stuff here. If the peer is polling us
+                        * in active mode, turn off the configuration
+                        * bit and make the mode passive. This allows us
+                        * to avoid dumping a lot of history for peers
+                        * we might choose to keep track of in passive
+                        * mode. The protocol will eventually terminate
+                        * undesirables on its own.
+                        */
+                       if (peer->hmode == MODE_ACTIVE
+                           && peer->pmode == MODE_ACTIVE) {
+                               peer->hmode = MODE_PASSIVE;
+                               peer->flags &= ~FLAG_CONFIG;
+                       } else {
+                               unpeer(peer);
+                               peer = 0;
+                       }
+               }
+               peer = findexistingpeer(srcadr, peer, mode);
+       }
+       return (num_found);
+}
+
+/*
+ * peer_clr_stats - clear peer module stat counters
+ */
+void
+peer_clr_stats(void)
+{
+       findpeer_calls = 0;
+       assocpeer_calls = 0;
+       peer_allocations = 0;
+       peer_demobilizations = 0;
+       peer_timereset = current_time;
+}
+
+/*
+ * peer_reset - reset stat counters in a peer structure
+ */
+void
+peer_reset(
+       struct peer *peer
+       )
+{
+       if (peer == 0)
+           return;
+       peer->sent = 0;
+       peer->received = 0;
+       peer->processed = 0;
+       peer->badauth = 0;
+       peer->bogusorg = 0;
+       peer->oldpkt = 0;
+       peer->seldisptoolarge = 0;
+       peer->timereset = current_time;
+}
+
+
+/*
+ * peer_all_reset - reset all peer stat counters
+ */
+void
+peer_all_reset(void)
+{
+       struct peer *peer;
+       int hash;
+
+       for (hash = 0; hash < NTP_HASH_SIZE; hash++)
+           for (peer = peer_hash[hash]; peer != 0; peer = peer->next)
+               peer_reset(peer);
+}
+
+
+#ifdef OPENSSL
+/*
+ * expire_all - flush all crypto data and update timestamps.
+ */
+void
+expire_all(void)
+{
+       struct peer *peer, *next_peer;
+       int n;
+
+       /*
+        * This routine is called about once per day from the timer
+        * routine and when the client is first synchronized. Search the
+        * peer list for all associations and flush only the key list
+        * and cookie. If a manycast client association, flush
+        * everything. Then, recompute and sign the agreement public
+        * value, if present.
+        */
+       if (!crypto_flags)
+               return;
+
+       for (n = 0; n < NTP_HASH_SIZE; n++) {
+               for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
+                       next_peer = peer->next;
+                       if (!(peer->flags & FLAG_SKEY)) {
+                               continue;
+
+                       } else if (peer->hmode == MODE_ACTIVE ||
+                           peer->hmode == MODE_PASSIVE) {
+                               key_expire(peer);
+                               peer->crypto &= ~(CRYPTO_FLAG_AUTO |
+                                   CRYPTO_FLAG_AGREE);
+                       }
+                               
+               }
+       }
+       RAND_bytes((u_char *)&sys_private, 4);
+       crypto_update();
+}
+#endif /* OPENSSL */
+
+
+/*
+ * findmanycastpeer - find and return a manycast peer
+ */
+struct peer *
+findmanycastpeer(
+       struct recvbuf *rbufp
+       )
+{
+       register struct peer *peer;
+       struct pkt *pkt;
+       l_fp p_org;
+       int i;
+
+       /*
+        * This routine is called upon arrival of a server-mode message
+        * from a manycast client. Search the peer list for a manycast
+        * client association where the last transmit timestamp matches
+        * the originate timestamp. This assumes the transmit timestamps
+        * for possibly more than one manycast association are unique.
+        */
+       pkt = &rbufp->recv_pkt;
+       for (i = 0; i < NTP_HASH_SIZE; i++) {
+               if (peer_hash_count[i] == 0)
+                       continue;
+
+               for (peer = peer_hash[i]; peer != 0; peer =
+                   peer->next) {
+                       if (peer->cast_flags & MDF_ACAST) {
+                               NTOHL_FP(&pkt->org, &p_org);
+                               if (L_ISEQU(&peer->xmt, &p_org))
+                                       return (peer);
+                       }
+               }
+       }
+       return (NULL);
+}
diff --git a/ntpd/ntp_proto.c b/ntpd/ntp_proto.c
new file mode 100644 (file)
index 0000000..0ab2498
--- /dev/null
@@ -0,0 +1,3450 @@
+/*
+ * ntp_proto.c - NTP version 4 protocol machinery
+ *
+ * ATTENTION: Get approval from Dave Mills on all changes to this file!
+ *
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_stdlib.h"
+#include "ntp_unixtime.h"
+#include "ntp_control.h"
+#include "ntp_string.h"
+
+#include <stdio.h>
+
+#if defined(VMS) && defined(VMS_LOCALUNIT)     /*wjm*/
+#include "ntp_refclock.h"
+#endif
+
+#if defined(__FreeBSD__) && __FreeBSD__ >= 3
+#include <sys/sysctl.h>
+#endif
+
+/*
+ * This macro defines the authentication state. If x is 1 authentication
+ * is required; othewise it is optional.
+ */
+#define        AUTH(x, y)      ((x) ? (y) == AUTH_OK : (y) == AUTH_OK || \
+                           (y) == AUTH_NONE)
+
+/*
+ * System variables are declared here. See Section 3.2 of the
+ * specification.
+ */
+u_char sys_leap;               /* system leap indicator */
+u_char sys_stratum;            /* stratum of system */
+s_char sys_precision;          /* local clock precision (log2 s) */
+double sys_rootdelay;          /* roundtrip delay to primary source */
+double sys_rootdispersion;     /* dispersion to primary source */
+u_int32 sys_refid;             /* source/loop in network byte order */
+static double sys_offset;      /* current local clock offset */
+l_fp   sys_reftime;            /* time we were last updated */
+struct peer *sys_peer;         /* our current peer */
+struct peer *sys_pps;          /* our PPS peer */
+struct peer *sys_prefer;       /* our cherished peer */
+int    sys_kod;                /* kod credit */
+int    sys_kod_rate = 2;       /* max kod packets per second */
+#ifdef OPENSSL
+u_long sys_automax;            /* maximum session key lifetime */
+#endif /* OPENSSL */
+
+/*
+ * Nonspecified system state variables.
+ */
+int    sys_bclient;            /* broadcast client enable */
+double sys_bdelay;             /* broadcast client default delay */
+int    sys_calldelay;          /* modem callup delay (s) */
+int    sys_authenticate;       /* requre authentication for config */
+l_fp   sys_authdelay;          /* authentication delay */
+static u_long sys_authdly[2];  /* authentication delay shift reg */
+static double sys_mindisp = MINDISPERSE; /* min disp increment (s) */
+static double sys_maxdist = MAXDISTANCE; /* selection threshold (s) */
+double sys_jitter;             /* system jitter (s) */
+static int sys_hopper;         /* anticlockhop counter */
+static int sys_maxhop = MAXHOP; /* anticlockhop counter threshold */
+int    leap_next;              /* leap consensus */
+keyid_t        sys_private;            /* private value for session seed */
+int    sys_manycastserver;     /* respond to manycast client pkts */
+int    peer_ntpdate;           /* active peers in ntpdate mode */
+int    sys_survivors;          /* truest of the truechimers */
+#ifdef OPENSSL
+char   *sys_hostname;          /* gethostname() name */
+#endif /* OPENSSL */
+
+/*
+ * TOS and multicast mapping stuff
+ */
+int    sys_floor = 0;          /* cluster stratum floor */
+int    sys_ceiling = STRATUM_UNSPEC; /* cluster stratum ceiling */
+int    sys_minsane = 1;        /* minimum candidates */
+int    sys_minclock = NTP_MINCLOCK; /* minimum survivors */
+int    sys_maxclock = NTP_MAXCLOCK; /* maximum candidates */
+int    sys_cohort = 0;         /* cohort switch */
+int    sys_orphan = STRATUM_UNSPEC + 1; /* orphan stratum */
+double sys_orphandelay = 0;    /* orphan root delay */
+int    sys_beacon = BEACON;    /* manycast beacon interval */
+int    sys_ttlmax;             /* max ttl mapping vector index */
+u_char sys_ttl[MAX_TTL];       /* ttl mapping vector */
+
+/*
+ * Statistics counters
+ */
+u_long sys_stattime;           /* time since reset */
+u_long sys_received;           /* packets received */
+u_long sys_processed;          /* packets processed */
+u_long sys_newversionpkt;      /* current version */
+u_long sys_oldversionpkt;      /* recent version */
+u_long sys_unknownversion;     /* invalid version */
+u_long sys_restricted;         /* access denied */
+u_long sys_badlength;          /* bad length or format */
+u_long sys_badauth;            /* bad authentication */
+u_long sys_limitrejected;      /* rate exceeded */
+
+static double  root_distance   P((struct peer *));
+static void    clock_combine   P((struct peer **, int));
+static void    peer_xmit       P((struct peer *));
+static void    fast_xmit       P((struct recvbuf *, int, keyid_t,
+                                   int));
+static void    clock_update    P((void));
+static int     default_get_precision   P((void));
+static int     peer_unfit      P((struct peer *));
+
+
+/*
+ * transmit - Transmit Procedure. See Section 3.4.2 of the
+ *     specification.
+ */
+void
+transmit(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       int     hpoll;
+
+       /*
+        * The polling state machine. There are two kinds of machines,
+        * those that never expect a reply (broadcast and manycast
+        * server modes) and those that do (all other modes). The dance
+        * is intricate...
+        */
+       /*
+        * Orphan mode is active when enabled and when no servers less
+        * than the orphan statum are available. In this mode packets
+        * are sent at the orphan stratum. An orphan with no other
+        * synchronization source is an orphan parent. It assumes root
+        * delay zero and reference ID the loopback address. All others
+        * are orphan children with root delay randomized over a 1-s
+        * range. The root delay is used by the election algorithm to
+        * select the order of synchronization.
+        */
+       hpoll = peer->hpoll;
+       if (sys_orphan < STRATUM_UNSPEC && sys_peer == NULL) {
+               sys_leap = LEAP_NOWARNING;
+               sys_stratum = sys_orphan;
+               sys_refid = htonl(LOOPBACKADR);
+               sys_rootdelay = 0;
+               sys_rootdispersion = 0;
+       }
+
+       /*
+        * In broadcast mode the poll interval is never changed from
+        * minpoll.
+        */
+       if (peer->cast_flags & (MDF_BCAST | MDF_MCAST)) {
+               peer->outdate = current_time;
+               peer_xmit(peer);
+               poll_update(peer, hpoll);
+               return;
+       }
+
+       /*
+        * In manycast mode we start with unity ttl. The ttl is
+        * increased by one for each poll until either sys_maxclock
+        * servers have been found or the maximum ttl is reached. When
+        * sys_maxclock servers are found we stop polling until one or
+        * more servers have timed out or until less than minpoll
+        * associations turn up. In this case additional better servers
+        * are dragged in and preempt the existing ones.
+        */
+       if (peer->cast_flags & MDF_ACAST) {
+               peer->outdate = current_time;
+               if (peer->unreach > sys_beacon) {
+                       peer->unreach = 0;
+                       peer->ttl = 0;
+                       peer_xmit(peer);
+               } else if (sys_survivors < sys_minclock ||
+                   peer_preempt < sys_maxclock) {
+                       if (peer->ttl < sys_ttlmax)
+                               peer->ttl++;
+                       peer_xmit(peer);
+               }
+               peer->unreach++;
+               poll_update(peer, hpoll);
+               return;
+       }
+
+       /*
+        * In unicast modes the dance is much more intricate. It is
+        * desigmed to back off whenever possible to minimize network
+        * traffic.
+        */
+       if (peer->burst == 0) {
+               u_char oreach;
+
+               /*
+                * Update the reachability status. If not heard for
+                * three consecutive polls, stuff infinity in the clock
+                * filter. 
+                */
+               oreach = peer->reach;
+               peer->outdate = current_time;
+               if (peer == sys_peer)
+                       sys_hopper++;
+               peer->reach <<= 1;
+               if (!(peer->reach & 0x07))
+                       clock_filter(peer, 0., 0., MAXDISPERSE);
+               if (!peer->reach) {
+
+                       /*
+                        * Here the peer is unreachable. If it was
+                        * previously reachable, raise a trap.
+                        */
+                       if (oreach) {
+                               report_event(EVNT_UNREACH, peer);
+                               peer->timereachable = current_time;
+                       }
+
+                       /*
+                        * Send a burst if enabled, but only once after
+                        * a peer becomes unreachable. If the prempt
+                        * flag is dim, bump the unreach counter by one;
+                        * otherwise, bump it by three.
+                        */
+                       if (peer->flags & FLAG_IBURST &&
+                           peer->unreach == 0) {
+                               peer->burst = NTP_BURST;
+                       }
+                       if (!(peer->flags & FLAG_PREEMPT))      
+                               peer->unreach++;
+                       else
+                               peer->unreach += 3;
+               } else {
+
+                       /*
+                        * Here the peer is reachable. Set the poll
+                        * interval to the system poll interval. Send a
+                        * burst only if enabled and the peer is fit.
+                        *
+                        * Respond to the peer evaluation produced by
+                        * the selection algorithm. If less than the
+                        * outlyer level, up the unreach by three. If
+                        * there are excess associations, up the unreach
+                        * by two if not a candidate and by one if so.
+                        */
+                       if (!(peer->flags & FLAG_PREEMPT)) {
+                               peer->unreach = 0;
+                       } else if (peer->status < CTL_PST_SEL_SELCAND) {
+                               peer->unreach += 3;
+                       } else if (peer_preempt > sys_maxclock) {
+                               if (peer->status < CTL_PST_SEL_SYNCCAND)
+                                       peer->unreach += 2;
+                               else
+                                       peer->unreach++;
+                       } else {
+                               peer->unreach = 0;
+                       }
+                       hpoll = sys_poll;
+                       if (peer->flags & FLAG_BURST &&
+                           !peer_unfit(peer))
+                               peer->burst = NTP_BURST;
+               }
+
+               /*
+                * Watch for timeout. If ephemeral or preemptable, toss
+                * the rascal; otherwise, bump the poll interval.
+                */ 
+               if (peer->unreach >= NTP_UNREACH) {
+                       if (peer->flags & FLAG_PREEMPT ||
+                           !(peer->flags & FLAG_CONFIG)) {
+                               peer_clear(peer, "TIME");
+                               unpeer(peer);
+                               return;
+                       } else {
+                               hpoll++;
+                       }
+               }
+       } else {
+               peer->burst--;
+
+               /*
+                * If a broadcast client at this point, the burst has
+                * concluded, so we switch to client mode and purge the
+                * keylist, since no further transmissions will be made.
+                */
+               if (peer->burst == 0) {
+                       if (peer->cast_flags & MDF_BCLNT) {
+                               peer->hmode = MODE_BCLIENT;
+#ifdef OPENSSL
+                               key_expire(peer);
+#endif /* OPENSSL */
+                       }
+
+                       /*
+                        * If ntpdate mode and the clock has not been
+                        * set and all peers have completed the burst,
+                        * we declare a successful failure.
+                        */
+                       if (mode_ntpdate) {
+                               peer_ntpdate--;
+                               if (peer_ntpdate == 0) {
+                                       msyslog(LOG_NOTICE,
+                                           "no reply; clock not set");
+                                       exit (0);
+                               }
+                       }
+               }
+       }
+
+       /*
+        * Do not transmit if in broadcast client mode. 
+        */
+       if (peer->hmode != MODE_BCLIENT)
+               peer_xmit(peer);
+       poll_update(peer, hpoll);
+}
+
+
+/*
+ * receive - Receive Procedure.  See section 3.4.3 in the specification.
+ */
+void
+receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct peer *peer;     /* peer structure pointer */
+       register struct pkt *pkt;       /* receive packet pointer */
+       int     hisversion;             /* packet version */
+       int     hisleap;                /* packet leap indicator */
+       int     hismode;                /* packet mode */
+       int     hisstratum;             /* packet stratum */
+       int     restrict_mask;          /* restrict bits */
+       int     has_mac;                /* length of MAC field */
+       int     authlen;                /* offset of MAC field */
+       int     is_authentic = 0;       /* cryptosum ok */
+       keyid_t skeyid = 0;             /* key ID */
+       struct sockaddr_storage *dstadr_sin; /* active runway */
+       struct peer *peer2;             /* aux peer structure pointer */
+       l_fp    p_org;                  /* origin timestamp */
+       l_fp    p_rec;                  /* receive timestamp */
+       l_fp    p_xmt;                  /* transmit timestamp */
+#ifdef OPENSSL
+       keyid_t tkeyid = 0;             /* temporary key ID */
+       keyid_t pkeyid = 0;             /* previous key ID */
+       struct autokey *ap;             /* autokey structure pointer */
+       int     rval;                   /* cookie snatcher */
+#endif /* OPENSSL */
+       int retcode = AM_NOMATCH;
+       int     at_listhead;
+
+       /*
+        * Monitor the packet and get restrictions. Note that the packet
+        * length for control and private mode packets must be checked
+        * by the service routines. Note that no statistics counters are
+        * recorded for restrict violations, since these counters are in
+        * the restriction routine. Note the careful distinctions here
+        * between a packet with a format error and a packet that is
+        * simply discarded without prejudice. Some restrictions have to
+        * be handled later in order to generate a kiss-of-death packet.
+        */
+       /*
+        * Bogus port check is before anything, since it probably
+        * reveals a clogging attack.
+        */
+       sys_received++;
+       if (SRCPORT(&rbufp->recv_srcadr) == 0) {
+               sys_badlength++;
+               return;                         /* bogus port */
+       }
+       at_listhead = ntp_monitor(rbufp);
+       restrict_mask = restrictions(&rbufp->recv_srcadr, at_listhead);
+#ifdef DEBUG
+       if (debug > 1)
+               printf("receive: at %ld %s<-%s flags %x restrict %03x\n",
+                   current_time, stoa(&rbufp->dstadr->sin),
+                   stoa(&rbufp->recv_srcadr),
+                   rbufp->dstadr->flags, restrict_mask);
+#endif
+       if (restrict_mask & RES_IGNORE) {
+               sys_restricted++;
+               return;                         /* ignore everything */
+       }
+       pkt = &rbufp->recv_pkt;
+       hisversion = PKT_VERSION(pkt->li_vn_mode);
+       hisleap = PKT_LEAP(pkt->li_vn_mode);
+       hismode = (int)PKT_MODE(pkt->li_vn_mode);
+       hisstratum = PKT_TO_STRATUM(pkt->stratum);
+       if (hismode == MODE_PRIVATE) {
+               if (restrict_mask & RES_NOQUERY) {
+                       sys_restricted++;
+                       return;                 /* no query private */
+               }
+               process_private(rbufp, ((restrict_mask &
+                   RES_NOMODIFY) == 0));
+               return;
+       }
+       if (hismode == MODE_CONTROL) {
+               if (restrict_mask & RES_NOQUERY) {
+                       sys_restricted++;
+                       return;                 /* no query control */
+               }
+               process_control(rbufp, restrict_mask);
+               return;
+       }
+       if (restrict_mask & RES_DONTSERVE) {
+               sys_restricted++;
+               return;                         /* no time */
+       }
+       if (rbufp->recv_length < LEN_PKT_NOMAC) {
+               sys_badlength++;
+               return;                         /* runt packet */
+       }
+       
+       /*
+        * Version check must be after the query packets, since they
+        * intentionally use early version.
+        */
+       if (hisversion == NTP_VERSION) {
+               sys_newversionpkt++;            /* new version */
+       } else if (!(restrict_mask & RES_VERSION) && hisversion >=
+           NTP_OLDVERSION) {
+               sys_oldversionpkt++;            /* previous version */
+       } else {
+               sys_unknownversion++;
+               return;                         /* old version */
+       }
+
+       /*
+        * Figure out his mode and validate the packet. This has some
+        * legacy raunch that probably should be removed. In very early
+        * NTP versions mode 0 was equivalent to what later versions
+        * would interpret as client mode.
+        */
+       if (hismode == MODE_UNSPEC) {
+               if (hisversion == NTP_OLDVERSION) {
+                       hismode = MODE_CLIENT;
+               } else {
+                       sys_badlength++;
+                       return;                 /* invalid mode */
+               }
+       }
+
+       /*
+        * Parse the extension field if present. We figure out whether
+        * an extension field is present by measuring the MAC size. If
+        * the number of words following the packet header is 0, no MAC
+        * is present and the packet is not authenticated. If 1, the
+        * packet is a crypto-NAK; if 3, the packet is authenticated
+        * with DES; if 5, the packet is authenticated with MD5. If 2 or
+        * 4, the packet is a runt and discarded forthwith. If greater
+        * than 5, an extension field is present, so we subtract the
+        * length of the field and go around again.
+        */
+       authlen = LEN_PKT_NOMAC;
+       has_mac = rbufp->recv_length - authlen;
+       while (has_mac > 0) {
+               int temp;
+
+               if (has_mac % 4 != 0 || has_mac < 0) {
+                       sys_badlength++;
+                       return;                 /* bad MAC length */
+               }
+               if (has_mac == 1 * 4 || has_mac == 3 * 4 || has_mac ==
+                   MAX_MAC_LEN) {
+                       skeyid = ntohl(((u_int32 *)pkt)[authlen / 4]);
+                       break;
+
+               } else if (has_mac > MAX_MAC_LEN) {
+                       temp = ntohl(((u_int32 *)pkt)[authlen / 4]) &
+                           0xffff;
+                       if (temp < 4 || temp > NTP_MAXEXTEN || temp % 4
+                           != 0) {
+                               sys_badlength++;
+                               return;         /* bad MAC length */
+                       }
+                       authlen += temp;
+                       has_mac -= temp;
+               } else {
+                       sys_badlength++;
+                       return;                 /* bad MAC length */
+               }
+       }
+#ifdef OPENSSL
+       pkeyid = tkeyid = 0;
+#endif /* OPENSSL */
+
+       /*
+        * We have tossed out as many buggy packets as possible early in
+        * the game to reduce the exposure to a clogging attack. Now we
+        * have to burn some cycles to find the association and
+        * authenticate the packet if required. Note that we burn only
+        * MD5 cycles, again to reduce exposure. There may be no
+        * matching association and that's okay.
+        *
+        * More on the autokey mambo. Normally the local interface is
+        * found when the association was mobilized with respect to a
+        * designated remote address. We assume packets arriving from
+        * the remote address arrive via this interface and the local
+        * address used to construct the autokey is the unicast address
+        * of the interface. However, if the sender is a broadcaster,
+        * the interface broadcast address is used instead.
+        & Notwithstanding this technobabble, if the sender is a
+        * multicaster, the broadcast address is null, so we use the
+        * unicast address anyway. Don't ask.
+        */
+       peer = findpeer(&rbufp->recv_srcadr, rbufp->dstadr,  hismode,
+           &retcode);
+       dstadr_sin = &rbufp->dstadr->sin;
+       NTOHL_FP(&pkt->org, &p_org);
+       NTOHL_FP(&pkt->rec, &p_rec);
+       NTOHL_FP(&pkt->xmt, &p_xmt);
+
+       /*
+        * Authentication is conditioned by three switches:
+        *
+        * NOPEER  (RES_NOPEER) do not mobilize an association unless
+        *         authenticated
+        * NOTRUST (RES_DONTTRUST) do not allow access unless
+        *         authenticated (implies NOPEER)
+        * enable  (sys_authenticate) master NOPEER switch, by default
+        *         on
+        *
+        * The NOPEER and NOTRUST can be specified on a per-client basis
+        * using the restrict command. The enable switch if on implies
+        * NOPEER for all clients. There are four outcomes:
+        *
+        * NONE    The packet has no MAC.
+        * OK      the packet has a MAC and authentication succeeds
+        * ERROR   the packet has a MAC and authentication fails
+        * CRYPTO  crypto-NAK. The MAC has four octets only.
+        *
+        * Note: The AUTH(x, y) macro is used to filter outcomes. If x
+        * is zero, acceptable outcomes of y are NONE and OK. If x is
+        * one, the only acceptable outcome of y is OK.
+        */
+       if (has_mac == 0) {
+               is_authentic = AUTH_NONE; /* not required */
+#ifdef DEBUG
+               if (debug)
+                       printf("receive: at %ld %s<-%s mode %d code %d auth %d\n",
+                           current_time, stoa(dstadr_sin),
+                           stoa(&rbufp->recv_srcadr), hismode, retcode,
+                           is_authentic);
+#endif
+       } else if (has_mac == 4) {
+                       is_authentic = AUTH_CRYPTO; /* crypto-NAK */
+#ifdef DEBUG
+               if (debug)
+                       printf(
+                           "receive: at %ld %s<-%s mode %d code %d keyid %08x len %d mac %d auth %d\n",
+                           current_time, stoa(dstadr_sin),
+                           stoa(&rbufp->recv_srcadr), hismode, retcode,
+                           skeyid, authlen, has_mac, is_authentic);
+#endif
+       } else {
+#ifdef OPENSSL
+               /*
+                * For autokey modes, generate the session key
+                * and install in the key cache. Use the socket
+                * broadcast or unicast address as appropriate.
+                */
+               if (skeyid > NTP_MAXKEY) {
+               
+                       /*
+                        * More on the autokey dance (AKD). A cookie is
+                        * constructed from public and private values.
+                        * For broadcast packets, the cookie is public
+                        * (zero). For packets that match no
+                        * association, the cookie is hashed from the
+                        * addresses and private value. For server
+                        * packets, the cookie was previously obtained
+                        * from the server. For symmetric modes, the
+                        * cookie was previously constructed using an
+                        * agreement protocol; however, should PKI be
+                        * unavailable, we construct a fake agreement as
+                        * the EXOR of the peer and host cookies.
+                        *
+                        * hismode      ephemeral       persistent
+                        * =======================================
+                        * active       0               cookie#
+                        * passive      0%              cookie#
+                        * client       sys cookie      0%
+                        * server       0%              sys cookie
+                        * broadcast    0               0
+                        *
+                        * # if unsync, 0
+                        * % can't happen
+                        */
+                       if (hismode == MODE_BROADCAST) {
+
+                               /*
+                                * For broadcaster, use the interface
+                                * broadcast address when available;
+                                * otherwise, use the unicast address
+                                * found when the association was
+                                * mobilized. However, if this is from
+                                * the wildcard interface, game over.
+                                */
+                               if (crypto_flags && rbufp->dstadr ==
+                                   any_interface) {
+                                       sys_restricted++;
+                                       return;      /* no wildcard */
+                               }
+                               pkeyid = 0;
+                               if (!SOCKNUL(&rbufp->dstadr->bcast))
+                                       dstadr_sin =
+                                           &rbufp->dstadr->bcast;
+                       } else if (peer == NULL) {
+                               pkeyid = session_key(
+                                   &rbufp->recv_srcadr, dstadr_sin, 0,
+                                   sys_private, 0);
+                       } else {
+                               pkeyid = peer->pcookie;
+                       }
+
+                       /*
+                        * The session key includes both the public
+                        * values and cookie. In case of an extension
+                        * field, the cookie used for authentication
+                        * purposes is zero. Note the hash is saved for
+                        * use later in the autokey mambo.
+                        */
+                       if (authlen > LEN_PKT_NOMAC && pkeyid != 0) {
+                               session_key(&rbufp->recv_srcadr,
+                                   dstadr_sin, skeyid, 0, 2);
+                               tkeyid = session_key(
+                                   &rbufp->recv_srcadr, dstadr_sin,
+                                   skeyid, pkeyid, 0);
+                       } else {
+                               tkeyid = session_key(
+                                   &rbufp->recv_srcadr, dstadr_sin,
+                                   skeyid, pkeyid, 2);
+                       }
+
+               }
+#endif /* OPENSSL */
+
+               /*
+                * Compute the cryptosum. Note a clogging attack may
+                * succeed in bloating the key cache. If an autokey,
+                * purge it immediately, since we won't be needing it
+                * again. If the packet is authentic, it can mobilize an
+                * association. Note that there is no key zero.
+                */
+               if (!authdecrypt(skeyid, (u_int32 *)pkt, authlen,
+                   has_mac)) {
+                       is_authentic = AUTH_ERROR;
+                       sys_badauth++;
+               } else {
+                       is_authentic = AUTH_OK;
+               }
+#ifdef OPENSSL
+               if (skeyid > NTP_MAXKEY)
+                       authtrust(skeyid, 0);
+#endif /* OPENSSL */
+#ifdef DEBUG
+               if (debug)
+                       printf(
+                           "receive: at %ld %s<-%s mode %d code %d keyid %08x len %d mac %d auth %d\n",
+                           current_time, stoa(dstadr_sin),
+                           stoa(&rbufp->recv_srcadr), hismode, retcode,
+                           skeyid, authlen, has_mac, is_authentic);
+#endif
+       }
+
+       /*
+        * The association matching rules are implemented by a set of
+        * routines and an association table. A packet matching an
+        * association is processed by the peer process for that
+        * association. If there are no errors, an ephemeral association
+        * is mobilized: a broadcast packet mobilizes a broadcast client
+        * aassociation; a manycast server packet mobilizes a manycast
+        * client association; a symmetric active packet mobilizes a
+        * symmetric passive association.
+        */
+       switch (retcode) {
+
+       /*
+        * This is a client mode packet not matching any association. If
+        * an ordinary client, simply toss a server mode packet back
+        * over the fence. If a manycast client, we have to work a
+        * little harder.
+        */
+       case AM_FXMIT:
+
+               /*
+                * The vanilla case is when this is not a multicast
+                * interface. If authentication succeeds, return a
+                * server mode packet; if not and the key ID is nonzero,
+                * return a crypto-NAK.
+                */
+               if (!(rbufp->dstadr->flags & INT_MCASTOPEN)) {
+                       if (AUTH(restrict_mask & RES_DONTTRUST,
+                          is_authentic))
+                               fast_xmit(rbufp, MODE_SERVER, skeyid,
+                                   restrict_mask);
+                       else if (is_authentic == AUTH_ERROR)
+                               fast_xmit(rbufp, MODE_SERVER, 0,
+                                   restrict_mask);
+                       return;                 /* hooray */
+               }
+
+               /*
+                * This must be manycast. Do not respond if not
+                * configured as a manycast server.
+                */
+               if (!sys_manycastserver) {
+                       sys_restricted++;
+                       return;                 /* not enabled */
+               }
+
+               /*
+                * Do not respond if unsynchronized or stratum is below
+                * the floor or at or above the ceiling.
+                */
+               if (sys_leap == LEAP_NOTINSYNC || sys_stratum <
+                   sys_floor || sys_stratum >= sys_ceiling)
+                       return;                 /* bad stratum */
+
+               /*
+                * Do not respond if our stratum is greater than the
+                * manycaster or it has already synchronized to us.
+                */
+               if (sys_peer == NULL || hisstratum < sys_stratum ||
+                   (sys_cohort && hisstratum == sys_stratum) ||
+                   rbufp->dstadr->addr_refid == pkt->refid)
+                       return;                 /* no help */
+
+               /*
+                * Respond only if authentication succeeds. Don't do a
+                * crypto-NAK, as that would not be useful.
+                */
+               if (AUTH(restrict_mask & RES_DONTTRUST, is_authentic))
+                       fast_xmit(rbufp, MODE_SERVER, skeyid,
+                           restrict_mask);
+
+               return;                         /* hooray */
+
+       /*
+        * This is a server mode packet returned in response to a client
+        * mode packet sent to a multicast group address. The origin
+        * timestamp is a good nonce to reliably associate the reply
+        * with what was sent. If there is no match, that's curious and
+        * could be an intruder attempting to clog, so we just ignore
+        * it.
+        *
+        * If the packet is authentic and the manycast association is
+        * found, we mobilize a client association and copy pertinent
+        * variables from the manycast association to the new client
+        * association. If not, just ignore the packet.
+        *
+        * There is an implosion hazard at the manycast client, since
+        * the manycast servers send the server packet immediately. If
+        * the guy is already here, don't fire up a duplicate.
+        */
+       case AM_MANYCAST:
+               if (!AUTH(sys_authenticate | (restrict_mask &
+                   (RES_NOPEER | RES_DONTTRUST)), is_authentic))
+                       return;                 /* bad auth */
+
+               if ((peer2 = findmanycastpeer(rbufp)) == NULL) {
+                       sys_restricted++;
+                       return;                 /* not enabled */
+               }
+               if ((peer = newpeer(&rbufp->recv_srcadr,
+                   rbufp->dstadr, MODE_CLIENT,
+                   hisversion, NTP_MINDPOLL, NTP_MAXDPOLL,
+                   FLAG_IBURST | FLAG_PREEMPT, MDF_UCAST | MDF_ACLNT,
+                   0, skeyid)) == NULL)
+                       return;                 /* system error */
+
+               /*
+                * We don't need these, but it warms the billboards.
+                */
+               peer->ttl = peer2->ttl;
+               break;
+
+       /*
+        * This is the first packet received from a broadcast server. If
+        * the packet is authentic and we are enabled as broadcast
+        * client, mobilize a broadcast client association. We don't
+        * kiss any frogs here.
+        */
+       case AM_NEWBCL:
+               if (!AUTH(sys_authenticate | (restrict_mask &
+                   (RES_NOPEER | RES_DONTTRUST)), is_authentic))
+                       return;                 /* bad auth */
+
+               /*
+                * Do not respond if unsynchronized or stratum is below
+                * the floor or at or above the ceiling.
+                */
+               if (hisleap == LEAP_NOTINSYNC || hisstratum <
+                   sys_floor || hisstratum >= sys_ceiling)
+                       return;                 /* bad stratum */
+
+               switch (sys_bclient) {
+
+               /*
+                * If not enabled, just skedaddle.
+                */
+               case 0:
+                       sys_restricted++;
+                       return;                 /* not enabled */
+
+               /*
+                * Execute the initial volley in order to calibrate the
+                * propagation delay and run the Autokey protocol, if
+                * enabled.
+                */
+               case 1:
+                       if ((peer = newpeer(&rbufp->recv_srcadr,
+                           rbufp->dstadr, MODE_CLIENT, hisversion,
+                           NTP_MINDPOLL, NTP_MAXDPOLL, FLAG_MCAST |
+                           FLAG_IBURST, MDF_BCLNT, 0, skeyid)) ==
+                           NULL)
+                               return;         /* system error */
+#ifdef OPENSSL
+                       if (skeyid > NTP_MAXKEY)
+                               crypto_recv(peer, rbufp);
+#endif /* OPENSSL */
+                       return;                 /* hooray */
+
+
+               /*
+                * Do not execute the initial volley.
+                */
+               case 2:
+#ifdef OPENSSL
+                       /*
+                        * If a two-way exchange is not possible,
+                        * neither is Autokey.
+                        */
+                       if (skeyid > NTP_MAXKEY) {
+                               msyslog(LOG_INFO,
+                                   "receive: autokey requires two-way communication");
+                               return;         /* no autokey */
+                       }
+#endif /* OPENSSL */
+                       if ((peer = newpeer(&rbufp->recv_srcadr,
+                           rbufp->dstadr, MODE_BCLIENT, hisversion,
+                           NTP_MINDPOLL, NTP_MAXDPOLL, 0, MDF_BCLNT, 0,
+                           skeyid)) == NULL)
+                               return;         /* system error */
+               }
+               break;
+
+       /*
+        * This is the first packet received from a symmetric active
+        * peer. If the packet is authentic and the first he sent,
+        * mobilize a passive association. If not, kiss the frog.
+        */
+       case AM_NEWPASS:
+
+               /*
+                * If the inbound packet is correctly authenticated and
+                * enabled, a symmetric passive association is
+                * mobilized. If not but correctly authenticated, a
+                * symmetric active response is sent. If authentication
+                * fails, send a crypto-NAK packet. 
+                */
+               if (!AUTH(restrict_mask & RES_DONTTRUST, is_authentic))
+                   {
+                       if (is_authentic == AUTH_ERROR)
+                               fast_xmit(rbufp, MODE_ACTIVE, 0,
+                                   restrict_mask);
+                       return;                 /* bad auth */
+               }
+               if (!AUTH(sys_authenticate | (restrict_mask &
+                   RES_NOPEER), is_authentic)) {
+                       fast_xmit(rbufp, MODE_ACTIVE, skeyid,
+                           restrict_mask);
+                       return;                 /* hooray */
+               }
+
+               /*
+                * Do not respond if stratum is below the floor.
+                */
+               if (hisstratum < sys_floor)
+                       return;                 /* bad stratum */
+
+               if ((peer = newpeer(&rbufp->recv_srcadr,
+                   rbufp->dstadr, MODE_PASSIVE, hisversion,
+                   NTP_MINDPOLL, NTP_MAXDPOLL, 0, MDF_UCAST, 0,
+                   skeyid)) == NULL)
+                       return;                 /* system error */
+               break;
+
+       /*
+        * Process regular packet. Nothing special.
+        */
+       case AM_PROCPKT:
+               break;
+
+       /*
+        * A passive packet matches a passive association. This is
+        * usually the result of reconfiguring a client on the fly. As
+        * this association might be legitamate and this packet an
+        * attempt to deny service, just ignore it.
+        */
+       case AM_ERR:
+               return;
+
+       /*
+        * For everything else there is the bit bucket.
+        */
+       default:
+               return;
+       }
+       peer->flash &= ~PKT_TEST_MASK;
+
+       /*
+        * Next comes a rigorous schedule of timestamp checking. If the
+        * transmit timestamp is zero, the server is horribly broken.
+        */
+       if (L_ISZERO(&p_xmt)) {
+               return;                         /* read rfc1305 */
+
+       /*
+        * If the transmit timestamp duplicates a previous one, the
+        * packet is a replay. This prevents the bad guys from replaying
+        * the most recent packet, authenticated or not.
+        */
+       } else if (L_ISEQU(&peer->org, &p_xmt)) {
+               peer->flash |= TEST1;
+               peer->oldpkt++;
+               return;                         /* duplicate packet */
+       
+
+       /*
+        * If this is a broadcast mode packet, skip further checking.
+        */
+       } else if (hismode != MODE_BROADCAST) {
+               if (L_ISZERO(&p_org))
+                       peer->flash |= TEST3;   /* protocol unsynch */
+               else if (!L_ISEQU(&p_org, &peer->xmt))
+                       peer->flash |= TEST2;   /* bogus packet */
+       }
+
+       /*
+        * Update the origin and destination timestamps. If
+        * unsynchronized or bogus abandon ship. If the crypto machine
+        * breaks, light the crypto bit and plaint the log.
+        */
+       peer->org = p_xmt;
+       peer->rec = rbufp->recv_time;
+       if (peer->flash & PKT_TEST_MASK) {
+#ifdef OPENSSL
+               if (crypto_flags && (peer->flags & FLAG_SKEY)) {
+                       rval = crypto_recv(peer, rbufp);
+                       if (rval != XEVNT_OK) {
+                               peer_clear(peer, "CRYP");
+                               peer->flash |= TEST9; /* crypto error */
+                       }
+               }
+#endif /* OPENSSL */
+               return;                         /* unsynch */
+       }
+
+       /*
+        * The timestamps are valid and the receive packet matches the
+        * last one sent. If the packet is a crypto-NAK, the server
+        * might have just changed keys. We reset the association
+        * and restart the protocol.
+        */
+       if (is_authentic == AUTH_CRYPTO) {
+               peer_clear(peer, "AUTH");
+               return;                         /* crypto-NAK */
+
+       /* 
+        * If the association is authenticated, the key ID is nonzero
+        * and received packets must be authenticated. This is designed
+        * to avoid a bait-and-switch attack, which was possible in past
+        * versions. If symmetric modes, return a crypto-NAK. The peer
+        * should restart the protocol.
+        */
+       } else if (!AUTH(peer->keyid || (restrict_mask & RES_DONTTRUST),
+           is_authentic)) {
+               peer->flash |= TEST5;
+               if (hismode == MODE_ACTIVE || hismode == MODE_PASSIVE)
+                       fast_xmit(rbufp, MODE_ACTIVE, 0, restrict_mask);
+               return;                         /* bad auth */
+       }
+
+       /*
+        * That was hard and I am sweaty, but the packet is squeaky
+        * clean. Get on with real work.
+        */
+       peer->received++;
+       peer->timereceived = current_time;
+       if (is_authentic == AUTH_OK)
+               peer->flags |= FLAG_AUTHENTIC;
+       else
+               peer->flags &= ~FLAG_AUTHENTIC;
+#ifdef OPENSSL
+       /*
+        * More autokey dance. The rules of the cha-cha are as follows:
+        *
+        * 1. If there is no key or the key is not auto, do nothing.
+        *
+        * 2. If this packet is in response to the one just previously
+        *    sent or from a broadcast server, do the extension fields.
+        *    Otherwise, assume bogosity and bail out.
+        *
+        * 3. If an extension field contains a verified signature, it is
+        *    self-authenticated and we sit the dance.
+        *
+        * 4. If this is a server reply, check only to see that the
+        *    transmitted key ID matches the received key ID.
+        *
+        * 5. Check to see that one or more hashes of the current key ID
+        *    matches the previous key ID or ultimate original key ID
+        *    obtained from the broadcaster or symmetric peer. If no
+        *    match, sit the dance and wait for timeout.
+        *
+        * In case of crypto error, fire the orchestra and stop dancing.
+        * This is considered a permanant error, so light the crypto bit
+        * to suppress further requests. If preemptable or ephemeral,
+        * scuttle the ship.
+        */
+       if (crypto_flags && (peer->flags & FLAG_SKEY)) {
+               peer->flash |= TEST8;
+               rval = crypto_recv(peer, rbufp);
+               if (rval != XEVNT_OK) {
+                       peer_clear(peer, "CRYP");
+                       peer->flash |= TEST9;   /* crypto error */
+                       if (peer->flags & FLAG_PREEMPT ||
+                           !(peer->flags & FLAG_CONFIG))
+                               unpeer(peer);
+                       return;
+
+               } else if (hismode == MODE_SERVER) {
+                       if (skeyid == peer->keyid)
+                               peer->flash &= ~TEST8;
+               } else if (!(peer->flash & TEST8)) {
+                       peer->pkeyid = skeyid;
+               } else if ((ap = (struct autokey *)peer->recval.ptr) !=
+                   NULL) {
+                       int i;
+
+                       for (i = 0; ; i++) {
+                               if (tkeyid == peer->pkeyid ||
+                                   tkeyid == ap->key) {
+                                       peer->flash &= ~TEST8;
+                                       peer->pkeyid = skeyid;
+                                       break;
+                               }
+                               if (i > ap->seq)
+                                       break;
+                               tkeyid = session_key(
+                                   &rbufp->recv_srcadr, dstadr_sin,
+                                   tkeyid, pkeyid, 0);
+                       }
+               }
+               if (!(peer->crypto & CRYPTO_FLAG_PROV)) /* test 9 */
+                       peer->flash |= TEST8;   /* not proventic */
+
+               /*
+                * If the transmit queue is nonempty, clamp the host
+                * poll interval to the packet poll interval.
+                */
+               if (peer->cmmd != 0) {
+                       peer->ppoll = pkt->ppoll;
+                       poll_update(peer, peer->hpoll);
+               }
+       }
+#endif /* OPENSSL */
+
+       /*
+        * The dance is complete and the flash bits have been lit. Toss
+        * the packet over the fence for processing, which may light up
+        * more flashers.
+        */
+       process_packet(peer, pkt);
+
+       /*
+        * Well, that was nice. If TEST4 is lit, either the crypto
+        * machine jammed or a kiss-o'-death packet flew in, either of
+        * which is fatal.
+        */
+       if (peer->flash & TEST4) {
+               msyslog(LOG_INFO, "receive: fatal error %04x for %s",
+                   peer->flash, stoa(&peer->srcadr));
+               return;
+       }
+}
+
+
+/*
+ * process_packet - Packet Procedure, a la Section 3.4.4 of the
+ *     specification. Or almost, at least. If we're in here we have a
+ *     reasonable expectation that we will be having a long term
+ *     relationship with this host.
+ */
+void
+process_packet(
+       register struct peer *peer,
+       register struct pkt *pkt
+       )
+{
+       double  t34, t21;
+       double  p_offset, p_del, p_disp;
+       l_fp    p_rec, p_xmt, p_org, p_reftime;
+       l_fp    ci;
+       u_char  pmode, pleap, pstratum;
+
+       sys_processed++;
+       peer->processed++;
+       p_del = FPTOD(NTOHS_FP(pkt->rootdelay));
+       p_disp = FPTOD(NTOHS_FP(pkt->rootdispersion));
+       NTOHL_FP(&pkt->reftime, &p_reftime);
+       NTOHL_FP(&pkt->rec, &p_rec);
+       NTOHL_FP(&pkt->xmt, &p_xmt);
+       pmode = PKT_MODE(pkt->li_vn_mode);
+       pleap = PKT_LEAP(pkt->li_vn_mode);
+       if (pmode != MODE_BROADCAST)
+               NTOHL_FP(&pkt->org, &p_org);
+       else
+               p_org = peer->rec;
+       pstratum = PKT_TO_STRATUM(pkt->stratum);
+
+       /*
+        * Test for kiss-o'death packet)
+        */
+       if (pleap == LEAP_NOTINSYNC && pstratum == STRATUM_UNSPEC) {
+               if (memcmp(&pkt->refid, "DENY", 4) == 0) {
+                       peer_clear(peer, "DENY");
+                       peer->flash |= TEST4;   /* access denied */
+               }
+       }
+
+       /*
+        * Capture the header values.
+        */
+       record_raw_stats(&peer->srcadr, peer->dstadr ? &peer->dstadr->sin : NULL, &p_org,
+           &p_rec, &p_xmt, &peer->rec);
+       peer->leap = pleap;
+       peer->stratum = min(pstratum, STRATUM_UNSPEC);
+       peer->pmode = pmode;
+       peer->ppoll = pkt->ppoll;
+       peer->precision = pkt->precision;
+       peer->rootdelay = p_del;
+       peer->rootdispersion = p_disp;
+       peer->refid = pkt->refid;               /* network byte order */
+       peer->reftime = p_reftime;
+
+       /*
+        * Verify the server is synchronized; that is, the leap bits and
+        * stratum are valid, the root delay and root dispersion are
+        * valid and the reference timestamp is not later than the
+        * transmit timestamp.
+        */
+       if (pleap == LEAP_NOTINSYNC ||          /* test 6 */
+           pstratum < sys_floor || pstratum >= sys_ceiling)
+               peer->flash |= TEST6;           /* peer not synch */
+       if (p_del < 0 || p_disp < 0 || p_del /  /* test 7 */
+           2 + p_disp >= MAXDISPERSE || !L_ISHIS(&p_xmt, &p_reftime))
+               peer->flash |= TEST7;           /* bad header */
+
+       /*
+        * If any tests fail at this point, the packet is discarded.
+        * Note that some flashers may have already been set in the
+        * receive() routine.
+        */
+       if (peer->flash & PKT_TEST_MASK) {
+#ifdef DEBUG
+               if (debug)
+                       printf("packet: flash header %04x\n",
+                           peer->flash);
+#endif
+               return;
+       }
+       if (!(peer->reach)) {
+               report_event(EVNT_REACH, peer);
+               peer->timereachable = current_time;
+       }
+       poll_update(peer, peer->hpoll);
+       peer->reach |= 1;
+
+       /*
+        * For a client/server association, calculate the clock offset,
+        * roundtrip delay and dispersion. The equations are reordered
+        * from the spec for more efficient use of temporaries. For a
+        * broadcast association, offset the last measurement by the
+        * computed delay during the client/server volley. Note that
+        * org has been set to the time of last reception. Note the
+        * computation of dispersion includes the system precision plus
+        * that due to the frequency error since the origin time.
+        *
+        * It is very important to respect the hazards of overflow. The
+        * only permitted operation on raw timestamps is subtraction,
+        * where the result is a signed quantity spanning from 68 years
+        * in the past to 68 years in the future. To avoid loss of
+        * precision, these calculations are done using 64-bit integer
+        * arithmetic. However, the offset and delay calculations are
+        * sums and differences of these first-order differences, which
+        * if done using 64-bit integer arithmetic, would be valid over
+        * only half that span. Since the typical first-order
+        * differences are usually very small, they are converted to 64-
+        * bit doubles and all remaining calculations done in floating-
+        * point arithmetic. This preserves the accuracy while retaining
+        * the 68-year span.
+        *
+        * Let t1 = p_org, t2 = p_rec, t3 = p_xmt, t4 = peer->rec:
+        */
+       ci = p_xmt;                     /* t3 - t4 */
+       L_SUB(&ci, &peer->rec);
+       LFPTOD(&ci, t34);
+       ci = p_rec;                     /* t2 - t1 */
+       L_SUB(&ci, &p_org);
+       LFPTOD(&ci, t21);
+       ci = peer->rec;                 /* t4 - t1 */
+       L_SUB(&ci, &p_org);
+
+       /*
+        * If running in a broadcast association, the clock offset is
+        * (t1 - t0) corrected by the one-way delay, but we can't
+        * measure that directly. Therefore, we start up in MODE_CLIENT
+        * mode, set FLAG_MCAST and exchange eight messages to determine
+        * the clock offset. When the last message is sent, we switch to
+        * MODE_BCLIENT mode. The next broadcast message after that
+        * computes the broadcast offset and clears FLAG_MCAST.
+        */
+       if (pmode == MODE_BROADCAST) {
+               p_offset = t34;
+               if (peer->flags & FLAG_MCAST) {
+                       peer->estbdelay = peer->offset - p_offset;
+                       if (peer->hmode == MODE_CLIENT)
+                               return;
+
+                       peer->flags &= ~(FLAG_MCAST | FLAG_BURST);
+               }
+               p_offset += peer->estbdelay;
+               p_del = peer->delay;
+               p_disp = 0;
+       } else {
+               p_offset = (t21 + t34) / 2.;
+               p_del = t21 - t34;
+               LFPTOD(&ci, p_disp);
+               p_disp = LOGTOD(sys_precision) +
+                   LOGTOD(peer->precision) + clock_phi * p_disp;
+       }
+       p_del = max(p_del, LOGTOD(sys_precision));
+       clock_filter(peer, p_offset, p_del, p_disp);
+       record_peer_stats(&peer->srcadr, ctlpeerstatus(peer),
+           peer->offset, peer->delay, peer->disp, peer->jitter);
+}
+
+
+/*
+ * clock_update - Called at system process update intervals.
+ */
+static void
+clock_update(void)
+{
+       u_char  oleap;
+       u_char  ostratum;
+       double  dtemp;
+
+       /*
+        * There must be a system peer at this point. If we just changed
+        * the system peer, but have a newer sample from the old one,
+        * wait until newer data are available.
+        */
+       if (sys_poll < sys_peer->minpoll)
+               sys_poll = sys_peer->minpoll;
+       if (sys_poll > sys_peer->maxpoll)
+               sys_poll = sys_peer->maxpoll;
+       poll_update(sys_peer, sys_poll);
+       if (sys_peer->epoch <= sys_clocktime)
+               return;
+
+#ifdef DEBUG
+       if (debug)
+               printf("clock_update: at %ld assoc %d \n", current_time,
+                   peer_associations);
+#endif
+       oleap = sys_leap;
+       ostratum = sys_stratum;
+       switch (local_clock(sys_peer, sys_offset)) {
+
+       /*
+        * Clock exceeds panic threshold. Life as we know it ends.
+        */
+       case -1:
+               report_event(EVNT_SYSFAULT, NULL);
+               exit (-1);
+               /* not reached */
+
+       /*
+        * Clock was stepped. Flush all time values of all peers.
+        */
+       case 2:
+               clear_all();
+               sys_leap = LEAP_NOTINSYNC;
+               sys_stratum = STRATUM_UNSPEC;
+               sys_peer = NULL;
+               sys_rootdelay = 0;
+               sys_rootdispersion = 0;
+               memcpy(&sys_refid, "STEP", 4);
+               report_event(EVNT_CLOCKRESET, NULL);
+               break;
+
+       /*
+        * Clock was slewed. Update the system stratum, leap bits, root
+        * delay, root dispersion, reference ID and reference time. If
+        * the leap changes, we gotta reroll the keys. Except for
+        * reference clocks, the minimum dispersion increment is not
+        * less than sys_mindisp.
+        */
+       case 1:
+               sys_leap = leap_next;
+               sys_stratum = min(sys_peer->stratum + 1,
+                   STRATUM_UNSPEC);
+               sys_reftime = sys_peer->rec;
+
+               /*
+                * In orphan mode the stratum defaults to the orphan
+                * stratum. The root delay is set to a random value
+                * generated at startup. The root dispersion is set from
+                * the peer dispersion; the peer root dispersion is
+                * ignored.
+                */
+               dtemp = sys_peer->disp + clock_phi * (current_time -
+                   sys_peer->update) + sys_jitter +
+                   fabs(sys_peer->offset);
+#ifdef REFCLOCK
+               if (!(sys_peer->flags & FLAG_REFCLOCK) && dtemp <
+                   sys_mindisp)
+                       dtemp = sys_mindisp;
+#else
+               if (dtemp < sys_mindisp)
+                       dtemp = sys_mindisp;
+#endif /* REFCLOCK */
+               if (sys_stratum >= sys_orphan) {
+                       sys_stratum = sys_orphan;
+                       sys_rootdelay = sys_peer->delay;
+                       sys_rootdispersion = dtemp;
+               } else {
+                       sys_rootdelay = sys_peer->delay +
+                           sys_peer->rootdelay;
+                       sys_rootdispersion = dtemp +
+                           sys_peer->rootdispersion;
+               }
+               if (oleap == LEAP_NOTINSYNC) {
+                       report_event(EVNT_SYNCCHG, NULL);
+#ifdef OPENSSL
+                       expire_all();
+                       crypto_update();
+#endif /* OPENSSL */
+               }
+               break;
+       /*
+        * Popcorn spike or step threshold exceeded. Pretend it never
+        * happened.
+        */
+       default:
+               break;
+       }
+       if (ostratum != sys_stratum)
+               report_event(EVNT_PEERSTCHG, NULL);
+}
+
+
+/*
+ * poll_update - update peer poll interval
+ */
+void
+poll_update(
+       struct peer *peer,
+       int     mpoll
+       )
+{
+       int     hpoll;
+
+       /*
+        * This routine figures out when the next poll should be sent.
+        * That turns out to be wickedly complicated. The big problem is
+        * that sometimes the time for the next poll is in the past.
+        * Watch out for races here between the receive process and the
+        * poll process. The key assertion is that, if nextdate equals
+        * current_time, the call is from the poll process; otherwise,
+        * it is from the receive process.
+        *
+        * First, bracket the poll interval according to the type of
+        * association and options. If a fixed interval is configured,
+        * use minpoll. This primarily is for reference clocks, but
+        * works for any association.
+        */
+       if (peer->flags & FLAG_FIXPOLL) {
+               hpoll = peer->minpoll;
+
+       /*
+        * The ordinary case; clamp the poll interval between minpoll
+        * and maxpoll.
+        */
+       } else {
+               hpoll = max(min(peer->maxpoll, mpoll), peer->minpoll);
+       }
+#ifdef OPENSSL
+       /*
+        * Bit of crass arrogance at this point. If the poll interval
+        * has changed and we have a keylist, the lifetimes in the
+        * keylist are probably bogus. In this case purge the keylist
+        * and regenerate it later.
+        */
+       if (hpoll != peer->hpoll)
+               key_expire(peer);
+#endif /* OPENSSL */
+       peer->hpoll = hpoll;
+
+       /*
+        * Now we figure out if there is an override. If during the
+        * crypto protocol and a message is pending, make it wait not
+        * more than two seconds.
+        */
+#ifdef OPENSSL
+       if (peer->cmmd != NULL && (sys_leap != LEAP_NOTINSYNC ||
+           peer->crypto)) {
+               peer->nextdate = current_time + RESP_DELAY;
+
+       /*
+        * If we get called from the receive routine while a burst is
+        * pending, just slink away. If from the poll routine and a
+        * reference clock or a pending crypto response, delay for one
+        * second. If this is the first sent in a burst, wait for the
+        * modem to come up. For others in the burst, delay two seconds.
+        */
+       } else if (peer->burst > 0) {
+#else /* OPENSSL */
+       if (peer->burst > 0) {
+#endif /* OPENSSL */
+               if (peer->nextdate != current_time)
+                       return;
+#ifdef REFCLOCK
+               else if (peer->flags & FLAG_REFCLOCK)
+                       peer->nextdate += RESP_DELAY;
+#endif /* REFCLOCK */
+               else if (peer->flags & (FLAG_IBURST | FLAG_BURST) &&
+                   peer->burst == NTP_BURST)
+                       peer->nextdate += sys_calldelay;
+               else
+                       peer->nextdate += BURST_DELAY;
+       /*
+        * The ordinary case; use the minimum of the host and peer
+        * intervals, but not less than minpoll. In other words,
+        * oversampling is okay but understampling is evil.
+        */
+       } else {
+               peer->nextdate = peer->outdate +
+                   RANDPOLL(max(min(peer->ppoll, hpoll),
+                   peer->minpoll));
+       }
+
+       /*
+        * If the time for the next poll has already happened, bring it
+        * up to the next second after this one. This way the only way
+        * to get nexdate == current time is from the poll routine.
+        */
+       if (peer->nextdate <= current_time)
+               peer->nextdate = current_time + 1;
+#ifdef DEBUG
+       if (debug > 1)
+               printf("poll_update: at %lu %s flags %04x poll %d burst %d last %lu next %lu\n",
+                   current_time, ntoa(&peer->srcadr), peer->flags,
+                   peer->hpoll, peer->burst, peer->outdate,
+                   peer->nextdate);
+#endif
+}
+
+/*
+ * peer_crypto_clear - discard crypto information
+ */
+void
+peer_crypto_clear(
+                 struct peer *peer
+                 )
+{
+       /*
+        * If cryptographic credentials have been acquired, toss them to
+        * Valhalla. Note that autokeys are ephemeral, in that they are
+        * tossed immediately upon use. Therefore, the keylist can be
+        * purged anytime without needing to preserve random keys. Note
+        * that, if the peer is purged, the cryptographic variables are
+        * purged, too. This makes it much harder to sneak in some
+        * unauthenticated data in the clock filter.
+        */
+       DPRINTF(1, ("peer_crypto_clear: at %ld next %ld assoc ID %d\n",
+                   current_time, peer->nextdate, peer->associd));
+
+#ifdef OPENSSL
+       peer->assoc = 0;
+       peer->crypto = 0;
+
+       if (peer->pkey != NULL)
+               EVP_PKEY_free(peer->pkey);
+       peer->pkey = NULL;
+
+       peer->digest = NULL;    /* XXX MEMLEAK? check whether this needs to be freed in any way - never was freed */
+
+       if (peer->subject != NULL)
+               free(peer->subject);
+       peer->subject = NULL;
+
+       if (peer->issuer != NULL)
+               free(peer->issuer);
+       peer->issuer = NULL;
+
+       peer->pkeyid = 0;
+
+       peer->pcookie = 0;
+
+       if (peer->ident_pkey != NULL)
+               EVP_PKEY_free(peer->ident_pkey);
+       peer->ident_pkey = NULL;
+       
+       memset(&peer->fstamp, 0, sizeof(peer->fstamp));
+
+       if (peer->iffval != NULL)
+               BN_free(peer->iffval);
+       peer->iffval = NULL;
+
+       if (peer->grpkey != NULL)
+               BN_free(peer->grpkey);
+       peer->grpkey = NULL;
+
+       value_free(&peer->cookval);
+       value_free(&peer->recval);
+
+       if (peer->cmmd != NULL) {
+               free(peer->cmmd);
+               peer->cmmd = NULL;
+       }
+
+       key_expire(peer);
+
+       value_free(&peer->encrypt);
+#endif /* OPENSSL */
+}
+
+/*
+ * peer_clear - clear peer filter registers.  See Section 3.4.8 of the spec.
+ */
+void
+peer_clear(
+       struct peer *peer,              /* peer structure */
+       char    *ident                  /* tally lights */
+       )
+{
+       int     i;
+
+       peer_crypto_clear(peer);
+       
+       if (peer == sys_peer)
+               sys_peer = NULL;
+
+       /*
+        * Wipe the association clean and initialize the nonzero values.
+        */
+       memset(CLEAR_TO_ZERO(peer), 0, LEN_CLEAR_TO_ZERO);
+       peer->estbdelay = sys_bdelay;
+       peer->ppoll = peer->maxpoll;
+       peer->hpoll = peer->minpoll;
+       peer->disp = MAXDISPERSE;
+       peer->jitter = LOGTOD(sys_precision);
+       for (i = 0; i < NTP_SHIFT; i++) {
+               peer->filter_order[i] = i;
+               peer->filter_disp[i] = MAXDISPERSE;
+       }
+#ifdef REFCLOCK
+       if (!(peer->flags & FLAG_REFCLOCK)) {
+               peer->leap = LEAP_NOTINSYNC;
+               peer->stratum = STRATUM_UNSPEC;
+               memcpy(&peer->refid, ident, 4);
+       }
+#else
+       peer->leap = LEAP_NOTINSYNC;
+       peer->stratum = STRATUM_UNSPEC;
+       memcpy(&peer->refid, ident, 4);
+#endif /* REFCLOCK */
+
+       /*
+        * During initialization use the association count to spread out
+        * the polls at one-second intervals. Othersie, randomize over
+        * the minimum poll interval in order to avoid broadcast
+        * implosion.
+        */
+       peer->nextdate = peer->update = peer->outdate = current_time;
+       if (initializing)
+               peer->nextdate += peer_associations;
+       else if (peer->hmode == MODE_PASSIVE)
+               peer->nextdate += RESP_DELAY;
+       else
+               peer->nextdate += (ntp_random() & ((1 << NTP_MINDPOLL) -
+                   1));
+
+       DPRINTF(1, ("peer_clear: at %ld next %ld assoc ID %d refid %s\n",
+                   current_time, peer->nextdate, peer->associd, ident));
+}
+
+
+/*
+ * clock_filter - add incoming clock sample to filter register and run
+ *               the filter procedure to find the best sample.
+ */
+void
+clock_filter(
+       struct peer *peer,              /* peer structure pointer */
+       double  sample_offset,          /* clock offset */
+       double  sample_delay,           /* roundtrip delay */
+       double  sample_disp             /* dispersion */
+       )
+{
+       double  dst[NTP_SHIFT];         /* distance vector */
+       int     ord[NTP_SHIFT];         /* index vector */
+       int     i, j, k, m;
+       double  dtemp, etemp;
+
+       /*
+        * Shift the new sample into the register and discard the oldest
+        * one. The new offset and delay come directly from the
+        * timestamp calculations. The dispersion grows from the last
+        * outbound packet or reference clock update to the present time
+        * and increased by the sum of the peer precision and the system
+        * precision. The delay can sometimes swing negative due to
+        * frequency skew, so it is clamped non-negative.
+        */
+       j = peer->filter_nextpt;
+       peer->filter_offset[j] = sample_offset;
+       peer->filter_delay[j] = max(0, sample_delay);
+       peer->filter_disp[j] = sample_disp;
+       peer->filter_epoch[j] = current_time;
+       j = (j + 1) % NTP_SHIFT;
+       peer->filter_nextpt = j;
+
+       /*
+        * Update dispersions since the last update and at the same
+        * time initialize the distance and index lists. The distance
+        * list uses a compound metric. If the sample is valid and
+        * younger than the minimum Allan intercept, use delay;
+        * otherwise, use biased dispersion.
+        */
+       dtemp = clock_phi * (current_time - peer->update);
+       peer->update = current_time;
+       for (i = NTP_SHIFT - 1; i >= 0; i--) {
+               if (i != 0)
+                       peer->filter_disp[j] += dtemp;
+               if (peer->filter_disp[j] >= MAXDISPERSE) 
+                       peer->filter_disp[j] = MAXDISPERSE;
+               if (peer->filter_disp[j] >= MAXDISPERSE)
+                       dst[i] = MAXDISPERSE;
+               else if (peer->update - peer->filter_epoch[j] >
+                   allan_xpt)
+                       dst[i] = sys_maxdist + peer->filter_disp[j];
+               else
+                       dst[i] = peer->filter_delay[j];
+               ord[i] = j;
+               j++; j %= NTP_SHIFT;
+       }
+
+        /*
+        * If the clock discipline has stabilized, sort the samples in
+        * both lists by distance. Note, we do not displace a higher
+        * distance sample by a lower distance one unless lower by at
+        * least the precision.  
+        */
+       if (state == 4) {
+               for (i = 1; i < NTP_SHIFT; i++) {
+                       for (j = 0; j < i; j++) {
+                               if (dst[j] > dst[i] +
+                                   LOGTOD(sys_precision)) {
+                                       k = ord[j];
+                                       ord[j] = ord[i];
+                                       ord[i] = k;
+                                       etemp = dst[j];
+                                       dst[j] = dst[i];
+                                       dst[i] = etemp;
+                               }
+                       }
+               }
+       }
+
+       /*
+        * Copy the index list to the association structure so ntpq
+        * can see it later. Prune the distance list to samples less
+        * than max distance, but keep at least two valid samples for
+        * jitter calculation.
+        */
+       m = 0;
+       for (i = 0; i < NTP_SHIFT; i++) {
+               peer->filter_order[i] = (u_char) ord[i];
+               if (dst[i] >= MAXDISPERSE || (m >= 2 && dst[i] >=
+                   sys_maxdist))
+                       continue;
+               m++;
+       }
+       
+       /*
+        * Compute the dispersion and jitter. The dispersion is weighted
+        * exponentially by NTP_FWEIGHT (0.5) so it is normalized close
+        * to 1.0. The jitter is the RMS differences relative to the
+        * lowest delay sample. If no acceptable samples remain in the
+        * shift register, quietly tiptoe home leaving only the
+        * dispersion.
+        */
+       peer->disp = peer->jitter = 0;
+       k = ord[0];
+       for (i = NTP_SHIFT - 1; i >= 0; i--) {
+               j = ord[i];
+               peer->disp = NTP_FWEIGHT * (peer->disp +
+                   peer->filter_disp[j]);
+               if (i < m)
+                       peer->jitter += DIFF(peer->filter_offset[j],
+                           peer->filter_offset[k]);
+       }
+
+       /*
+        * If no acceptable samples remain in the shift register,
+        * quietly tiptoe home leaving only the dispersion. Otherwise,
+        * save the offset, delay and jitter. Note the jitter must not
+        * be less than the precision.
+        */
+       if (m == 0)
+               return;
+
+       etemp = fabs(peer->offset - peer->filter_offset[k]);
+       peer->offset = peer->filter_offset[k];
+       peer->delay = peer->filter_delay[k];
+       if (m > 1)
+               peer->jitter /= m - 1;
+       peer->jitter = max(SQRT(peer->jitter), LOGTOD(sys_precision));
+
+       /*
+        * A new sample is useful only if it is younger than the last
+        * one used. Note the order is FIFO if the clock discipline has
+        * not stabilized.
+        */
+       if (peer->filter_epoch[k] <= peer->epoch) {
+#ifdef DEBUG
+               if (debug)
+                       printf("clock_filter: discard %lu\n",
+                           peer->epoch - peer->filter_epoch[k]);
+#endif
+               return;
+       }
+
+       /*
+        * If the difference between the last offset and the current one
+        * exceeds the jitter by CLOCK_SGATE and the interval since the
+        * last update is less than twice the system poll interval,
+        * consider the update a popcorn spike and ignore it.
+        */
+       if (etemp > CLOCK_SGATE * peer->jitter && m > 1 &&
+           peer->filter_epoch[k] - peer->epoch < 2. *
+           ULOGTOD(sys_poll)) {
+#ifdef DEBUG
+               if (debug)
+                       printf("clock_filter: popcorn %.6f %.6f\n",
+                           etemp, dtemp);
+#endif
+               return;
+       }
+
+       /*
+        * The mitigated sample statistics are saved for later
+        * processing. If not in a burst, tickle the select.
+        */
+       peer->epoch = peer->filter_epoch[k];
+#ifdef DEBUG
+       if (debug)
+               printf(
+                   "clock_filter: n %d off %.6f del %.6f dsp %.6f jit %.6f, age %lu\n",
+                   m, peer->offset, peer->delay, peer->disp,
+                   peer->jitter, current_time - peer->epoch);
+#endif
+       if (peer->burst == 0 || sys_leap == LEAP_NOTINSYNC)
+               clock_select();
+}
+
+
+/*
+ * clock_select - find the pick-of-the-litter clock
+ *
+ * LOCKCLOCK: If the local clock is the prefer peer, it will always be
+ * enabled, even if declared falseticker, (2) only the prefer peer can
+ * be selected as the system peer, (3) if the external source is down,
+ * the system leap bits are set to 11 and the stratum set to infinity.
+ */
+void
+clock_select(void)
+{
+       struct peer *peer;
+       int     i, j, k, n;
+       int     nlist, nl3;
+
+       int     allow, osurv;
+       double  d, e, f, g;
+       double  high, low;
+       double  synch[NTP_MAXASSOC], error[NTP_MAXASSOC];
+       struct peer *osys_peer;
+       struct peer *typeacts = NULL;
+       struct peer *typelocal = NULL;
+       struct peer *typesystem = NULL;
+
+       static int list_alloc = 0;
+       static struct endpoint *endpoint = NULL;
+       static int *indx = NULL;
+       static struct peer **peer_list = NULL;
+       static u_int endpoint_size = 0;
+       static u_int indx_size = 0;
+       static u_int peer_list_size = 0;
+
+       /*
+        * Initialize and create endpoint, index and peer lists big
+        * enough to handle all associations.
+        */
+       osys_peer = sys_peer;
+       sys_peer = NULL;
+       sys_pps = NULL;
+       sys_prefer = NULL;
+       osurv = sys_survivors;
+       sys_survivors = 0;
+#ifdef LOCKCLOCK
+       sys_leap = LEAP_NOTINSYNC;
+       sys_stratum = STRATUM_UNSPEC;
+       memcpy(&sys_refid, "DOWN", 4);
+#endif /* LOCKCLOCK */
+       nlist = 0;
+       for (n = 0; n < NTP_HASH_SIZE; n++)
+               nlist += peer_hash_count[n];
+       if (nlist > list_alloc) {
+               if (list_alloc > 0) {
+                       free(endpoint);
+                       free(indx);
+                       free(peer_list);
+               }
+               while (list_alloc < nlist) {
+                       list_alloc += 5;
+                       endpoint_size += 5 * 3 * sizeof(*endpoint);
+                       indx_size += 5 * 3 * sizeof(*indx);
+                       peer_list_size += 5 * sizeof(*peer_list);
+               }
+               endpoint = (struct endpoint *)emalloc(endpoint_size);
+               indx = (int *)emalloc(indx_size);
+               peer_list = (struct peer **)emalloc(peer_list_size);
+       }
+
+       /*
+        * Initially, we populate the island with all the rifraff peers
+        * that happen to be lying around. Those with seriously
+        * defective clocks are immediately booted off the island. Then,
+        * the falsetickers are culled and put to sea. The truechimers
+        * remaining are subject to repeated rounds where the most
+        * unpopular at each round is kicked off. When the population
+        * has dwindled to sys_minclock, the survivors split a million
+        * bucks and collectively crank the chimes.
+        */
+       nlist = nl3 = 0;        /* none yet */
+       for (n = 0; n < NTP_HASH_SIZE; n++) {
+               for (peer = peer_hash[n]; peer != NULL; peer =
+                   peer->next) {
+                       peer->flags &= ~FLAG_SYSPEER;
+                       peer->status = CTL_PST_SEL_REJECT;
+
+                       /*
+                        * Leave the island immediately if the peer is
+                        * unfit to synchronize.
+                        */
+                       if (peer_unfit(peer))
+                               continue;
+
+                       /*
+                        * Don't allow the local clock or modem drivers
+                        * in the kitchen at this point, unless the
+                        * prefer peer. Do that later, but only if
+                        * nobody else is around. These guys are all
+                        * configured, so we never throw them away.
+                        */
+#ifdef REFCLOCK
+                       if (peer->refclktype == REFCLK_LOCALCLOCK
+#if defined(VMS) && defined(VMS_LOCALUNIT)
+                       /* wjm: VMS_LOCALUNIT taken seriously */
+                           && REFCLOCKUNIT(&peer->srcadr) !=
+                           VMS_LOCALUNIT
+#endif /* VMS && VMS_LOCALUNIT */
+                               ) {
+                               typelocal = peer;
+#ifndef LOCKCLOCK
+                               if (!(peer->flags & FLAG_PREFER))
+                                       continue; /* no local clock */
+#endif /* LOCKCLOCK */
+                       }
+                       if (peer->sstclktype == CTL_SST_TS_TELEPHONE) {
+                               typeacts = peer;
+                               if (!(peer->flags & FLAG_PREFER))
+                                       continue; /* no acts */
+                       }
+#endif /* REFCLOCK */
+
+                       /*
+                        * If we get this far, the peer can stay on the
+                        * island, but does not yet have the immunity
+                        * idol.
+                        */
+                       peer->status = CTL_PST_SEL_SANE;
+                       peer_list[nlist++] = peer;
+
+                       /*
+                        * Insert each interval endpoint on the sorted
+                        * list.
+                        */
+                       e = peer->offset;        /* Upper end */
+                       f = root_distance(peer);
+                       e = e + f;
+                       for (i = nl3 - 1; i >= 0; i--) {
+                               if (e >= endpoint[indx[i]].val)
+                                       break;
+
+                               indx[i + 3] = indx[i];
+                       }
+                       indx[i + 3] = nl3;
+                       endpoint[nl3].type = 1;
+                       endpoint[nl3++].val = e;
+
+                       e = e - f;              /* Center point */
+                       for (; i >= 0; i--) {
+                               if (e >= endpoint[indx[i]].val)
+                                       break;
+
+                               indx[i + 2] = indx[i];
+                       }
+                       indx[i + 2] = nl3;
+                       endpoint[nl3].type = 0;
+                       endpoint[nl3++].val = e;
+
+                       e = e - f;              /* Lower end */
+                       for (; i >= 0; i--) {
+                               if (e >= endpoint[indx[i]].val)
+                                       break;
+
+                               indx[i + 1] = indx[i];
+                       }
+                       indx[i + 1] = nl3;
+                       endpoint[nl3].type = -1;
+                       endpoint[nl3++].val = e;
+               }
+       }
+#ifdef DEBUG
+       if (debug > 2)
+               for (i = 0; i < nl3; i++)
+                       printf("select: endpoint %2d %.6f\n",
+                          endpoint[indx[i]].type,
+                          endpoint[indx[i]].val);
+#endif
+       /*
+        * This is the actual algorithm that cleaves the truechimers
+        * from the falsetickers. The original algorithm was described
+        * in Keith Marzullo's dissertation, but has been modified for
+        * better accuracy.
+        *
+        * Briefly put, we first assume there are no falsetickers, then
+        * scan the candidate list first from the low end upwards and
+        * then from the high end downwards. The scans stop when the
+        * number of intersections equals the number of candidates less
+        * the number of falsetickers. If this doesn't happen for a
+        * given number of falsetickers, we bump the number of
+        * falsetickers and try again. If the number of falsetickers
+        * becomes equal to or greater than half the number of
+        * candidates, the Albanians have won the Byzantine wars and
+        * correct synchronization is not possible.
+        *
+        * Here, nlist is the number of candidates and allow is the
+        * number of falsetickers. Upon exit, the truechimers are the
+        * susvivors with offsets not less than low and not greater than
+        * high. There may be none of them.
+        */
+       low = 1e9;
+       high = -1e9;
+       for (allow = 0; 2 * allow < nlist; allow++) {
+               int     found;
+
+               /*
+                * Bound the interval (low, high) as the largest
+                * interval containing points from presumed truechimers.
+                */
+               found = 0;
+               n = 0;
+               for (i = 0; i < nl3; i++) {
+                       low = endpoint[indx[i]].val;
+                       n -= endpoint[indx[i]].type;
+                       if (n >= nlist - allow)
+                               break;
+                       if (endpoint[indx[i]].type == 0)
+                               found++;
+               }
+               n = 0;
+               for (j = nl3 - 1; j >= 0; j--) {
+                       high = endpoint[indx[j]].val;
+                       n += endpoint[indx[j]].type;
+                       if (n >= nlist - allow)
+                               break;
+                       if (endpoint[indx[j]].type == 0)
+                               found++;
+               }
+
+               /*
+                * If the number of candidates found outside the
+                * interval is greater than the number of falsetickers,
+                * then at least one truechimer is outside the interval,
+                * so go around again. This is what makes this algorithm
+                * different than Marzullo's.
+                */
+               if (found > allow)
+                       continue;
+
+               /*
+                * If an interval containing truechimers is found, stop.
+                * If not, increase the number of falsetickers and go
+                * around again.
+                */
+               if (high > low)
+                       break;
+       }
+
+       /*
+        * Clustering algorithm. Construct candidate list in order first
+        * by stratum then by root distance, but keep only the best
+        * NTP_MAXASSOC of them. Scan the list to find falsetickers, who
+        * leave the island immediately. The TRUE peer is always a
+        * truechimer. We must leave at least one peer to collect the
+        * million bucks. If in orphan mode, rascals found with lower
+        * stratum are guaranteed a seat on the bus.
+        */
+       j = 0;
+       for (i = 0; i < nlist; i++) {
+               peer = peer_list[i];
+               if (nlist > 1 && (peer->offset <= low || peer->offset >=
+                   high) && !(peer->flags & FLAG_TRUE) &&
+                   !(sys_stratum >= sys_orphan && peer->stratum <
+                   sys_orphan))
+                       continue;
+
+               peer->status = CTL_PST_SEL_DISTSYSPEER;
+
+               /*
+                * The order metric is formed from the stratum times
+                * max distance (1.) plus the root distance. It strongly
+                * favors the lowest stratum, but a higher stratum peer
+                * can capture the clock if the low stratum dominant
+                * hasn't been heard for awhile.
+                */
+               d = root_distance(peer) + peer->stratum * sys_maxdist;
+               if (j >= NTP_MAXASSOC) {
+                       if (d >= synch[j - 1])
+                               continue;
+                       else
+                               j--;
+               }
+               for (k = j; k > 0; k--) {
+                       if (d >= synch[k - 1])
+                               break;
+
+                       peer_list[k] = peer_list[k - 1];
+                       error[k] = error[k - 1];
+                       synch[k] = synch[k - 1];
+               }
+               peer_list[k] = peer;
+               error[k] = peer->jitter;
+               synch[k] = d;
+               j++;
+       }
+       nlist = j;
+
+       /*
+        * If no survivors remain at this point, check if the local
+        * clock or modem drivers have been found. If so, nominate one
+        * of them as the only survivor. Otherwise, give up and leave
+        * the island to the rats.
+        */
+       if (nlist == 0) {
+               if (typeacts != 0) {
+                       typeacts->status = CTL_PST_SEL_DISTSYSPEER;
+                       peer_list[0] = typeacts;
+                       nlist = 1;
+               } else if (typelocal != 0) {
+                       typelocal->status = CTL_PST_SEL_DISTSYSPEER;
+                       peer_list[0] = typelocal;
+                       nlist = 1;
+               } else {
+                       if (osys_peer != NULL) {
+                               NLOG(NLOG_SYNCSTATUS)
+                                   msyslog(LOG_INFO,
+                                   "no servers reachable");
+                               report_event(EVNT_PEERSTCHG, NULL);
+                       }
+               }
+       }
+
+       /*
+        * We can only trust the survivors if the number of candidates
+        * sys_minsane is at least the number required to detect and
+        * cast out one falsticker. For the Byzantine agreement
+        * algorithm used here, that number is 4; however, the default
+        * sys_minsane is 1 to speed initial synchronization. Careful
+        * operators will tinker a higher value and use at least that
+        * number of synchronization sources.
+        */
+       if (nlist < sys_minsane)
+               return;
+
+       for (i = 0; i < nlist; i++)
+               peer_list[i]->status = CTL_PST_SEL_SELCAND;
+
+       /*
+        * Now, vote outlyers off the island by select jitter weighted
+        * by root distance. Continue voting as long as there are more
+        * than sys_minclock survivors and the minimum select jitter is
+        * greater than the maximum peer jitter. Stop if we are about to
+        * discard a TRUE or PREFER  peer, who of course has the
+        * immunity idol.
+        */
+       while (1) {
+               d = 1e9;
+               e = -1e9;
+               f = g = 0;
+               k = 0;
+               for (i = 0; i < nlist; i++) {
+                       if (error[i] < d)
+                               d = error[i];
+                       f = 0;
+                       if (nlist > 1) {
+                               for (j = 0; j < nlist; j++)
+                                       f += DIFF(peer_list[j]->offset,
+                                           peer_list[i]->offset);
+                               f = SQRT(f / (nlist - 1));
+                       }
+                       if (f * synch[i] > e) {
+                               g = f;
+                               e = f * synch[i];
+                               k = i;
+                       }
+               }
+               f = max(f, LOGTOD(sys_precision));
+               if (nlist <= sys_minclock || f <= d ||
+                   peer_list[k]->flags & (FLAG_TRUE | FLAG_PREFER))
+                       break;
+#ifdef DEBUG
+               if (debug > 2)
+                       printf(
+                           "select: drop %s select %.6f jitter %.6f\n",
+                           ntoa(&peer_list[k]->srcadr), g, d);
+#endif
+               for (j = k + 1; j < nlist; j++) {
+                       peer_list[j - 1] = peer_list[j];
+                       error[j - 1] = error[j];
+               }
+               nlist--;
+       }
+
+       /*
+        * What remains is a list usually not greater than sys_minclock
+        * peers. We want only a peer at the lowest stratum to become
+        * the system peer, although all survivors are eligible for the
+        * combining algorithm. Consider each peer in turn and OR the
+        * leap bits on the assumption that, if some of them honk
+        * nonzero bits, they must know what they are doing. Check for
+        * prefer and pps peers at any stratum. Note that the head of
+        * the list is at the lowest stratum and that unsynchronized
+        * peers cannot survive this far.
+        */
+       leap_next = 0;
+       for (i = 0; i < nlist; i++) {
+               peer = peer_list[i];
+               sys_survivors++;
+               leap_next |= peer->leap;
+               peer->status = CTL_PST_SEL_SYNCCAND;
+               if (peer->flags & FLAG_PREFER)
+                       sys_prefer = peer;
+               if (peer == osys_peer)
+                       typesystem = peer;
+#ifdef REFCLOCK
+               if (peer->refclktype == REFCLK_ATOM_PPS)
+                       sys_pps = peer;
+#endif /* REFCLOCK */
+#if DEBUG
+               if (debug > 1)
+                       printf("cluster: survivor %s metric %.6f\n",
+                           ntoa(&peer_list[i]->srcadr), synch[i]);
+#endif
+       }
+
+       /*
+        * Anticlockhop provision. Keep the current system peer if it is
+        * a survivor but not first in the list. But do that only HOPPER
+        * times.
+        */
+       if (osys_peer == NULL || typesystem == NULL || typesystem ==
+           peer_list[0] || sys_hopper > sys_maxhop) {
+               typesystem = peer_list[0];
+               sys_hopper = 0;
+       } else {
+               peer->selbroken++;
+       }
+
+       /*
+        * Mitigation rules of the game. There are several types of
+        * peers that can be selected here: (1) orphan, (2) prefer peer
+        * (flag FLAG_PREFER) (3) pps peers (type REFCLK_ATOM_PPS), (4)
+        * the existing system peer, if any, and (5) the head of the
+        * survivor list.
+        */
+       if (typesystem->stratum >= sys_orphan) {
+
+               /*
+                * If in orphan mode, choose the system peer. If the
+                * lowest distance, we are the orphan parent and the
+                * offset is zero.
+                */
+               sys_peer = typesystem;
+               sys_peer->status = CTL_PST_SEL_SYSPEER;
+               if (sys_orphandelay < sys_peer->rootdelay) {
+                       sys_offset = 0;
+                       sys_refid = htonl(LOOPBACKADR);
+               } else {
+                       sys_offset = sys_peer->offset;
+                       sys_refid = addr2refid(&sys_peer->srcadr);
+               }
+               sys_jitter = LOGTOD(sys_precision);
+#ifdef DEBUG
+               if (debug > 1)
+                       printf("select: orphan offset %.6f\n",
+                           sys_offset);
+#endif
+       } else if (sys_prefer) {
+
+               /*
+                * If a pps peer is present, choose it; otherwise,
+                * choose the prefer peer.
+                */
+               if (sys_pps) {
+                       sys_peer = sys_pps;
+                       sys_peer->status = CTL_PST_SEL_PPS;
+                       sys_offset = sys_peer->offset;
+                       if (!pps_control)
+                               NLOG(NLOG_SYSEVENT)
+                                   msyslog(LOG_INFO,
+                                   "pps sync enabled");
+                       pps_control = current_time;
+#ifdef DEBUG
+                       if (debug > 1)
+                               printf("select: pps offset %.6f\n",
+                                   sys_offset);
+#endif
+               } else {
+                       sys_peer = sys_prefer;
+                       sys_peer->status = CTL_PST_SEL_SYSPEER;
+                       sys_offset = sys_peer->offset;
+#ifdef DEBUG
+                       if (debug > 1)
+                               printf("select: prefer offset %.6f\n",
+                                   sys_offset);
+#endif
+               }
+               if (sys_peer->stratum == STRATUM_REFCLOCK ||
+                   sys_peer->stratum == STRATUM_UNSPEC)
+                       sys_refid = sys_peer->refid;
+               else
+                       sys_refid = addr2refid(&sys_peer->srcadr);
+               sys_jitter = sys_peer->jitter;
+       } else {
+
+               /*
+                * Otherwise, choose the anticlockhopper.
+                */ 
+               sys_peer = typesystem;
+               sys_peer->status = CTL_PST_SEL_SYSPEER;
+               clock_combine(peer_list, nlist);
+               if (sys_peer->stratum == STRATUM_REFCLOCK ||
+                   sys_peer->stratum == STRATUM_UNSPEC)
+                       sys_refid = sys_peer->refid;
+               else
+                       sys_refid = addr2refid(&sys_peer->srcadr);
+               sys_jitter = SQRT(SQUARE(sys_peer->jitter) +
+                   SQUARE(sys_jitter));
+#ifdef DEBUG
+               if (debug > 1)
+                       printf("select: combine offset %.6f\n",
+                          sys_offset);
+#endif
+       }
+
+       /*
+        * We have found the alpha male.
+        */
+       sys_peer->flags |= FLAG_SYSPEER;
+       if (osys_peer != sys_peer) {
+               char *src;
+
+               report_event(EVNT_PEERSTCHG, NULL);
+
+#ifdef REFCLOCK
+                if (sys_peer->flags & FLAG_REFCLOCK)
+                        src = refnumtoa(&sys_peer->srcadr);
+                else
+#endif /* REFCLOCK */
+                        src = ntoa(&sys_peer->srcadr);
+               NLOG(NLOG_SYNCSTATUS)
+                   msyslog(LOG_INFO, "synchronized to %s, stratum %d",
+                       src, sys_peer->stratum);
+       }
+       clock_update();
+}
+
+
+/*
+ * clock_combine - compute system offset and jitter from selected peers
+ */
+static void
+clock_combine(
+       struct peer **peers,            /* survivor list */
+       int     npeers                  /* number of survivors */
+       )
+{
+       int     i;
+       double  x, y, z, w;
+
+       y = z = w = 0;
+       for (i = 0; i < npeers; i++) {
+               x = root_distance(peers[i]);
+               y += 1. / x;
+               z += peers[i]->offset / x;
+               w += SQUARE(peers[i]->offset - peers[0]->offset) / x;
+       }
+       sys_offset = z / y;
+       sys_jitter = SQRT(w / y);
+}
+
+/*
+ * root_distance - compute synchronization distance from peer to root
+ */
+static double
+root_distance(
+       struct peer *peer
+       )
+{
+       double  dist;
+
+       /*
+        * Careful squeak here. The value returned must be greater than
+        * the minimum root dispersion in order to avoid clockhop with
+        * highly precise reference clocks. In orphan mode lose the peer
+        * root delay, as that is used by the election algorithm.
+        */
+       if (peer->stratum >= sys_orphan)
+               dist = 0;
+       else
+               dist = peer->rootdelay;
+       dist += max(sys_mindisp, dist + peer->delay) / 2 +
+           peer->rootdispersion + peer->disp + clock_phi *
+           (current_time - peer->update) + peer->jitter;
+       return (dist);
+}
+
+/*
+ * peer_xmit - send packet for persistent association.
+ */
+static void
+peer_xmit(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct pkt xpkt;        /* transmit packet */
+       int     sendlen, authlen;
+       keyid_t xkeyid = 0;     /* transmit key ID */
+       l_fp    xmt_tx;
+
+       if (!peer->dstadr)      /* don't bother with peers without interface */
+               return;
+
+       /*
+        * This is deliciously complicated. There are three cases.
+        *
+        * case         leap    stratum refid   delay   dispersion
+        *
+        * normal       system  system  system  system  system
+        * orphan child 00      orphan  system  orphan  system
+        * orphan parent 00     orphan  loopbk  0       0
+        */
+       /*
+        * This is a normal packet. Use the system variables.
+        */
+       if (sys_stratum < sys_orphan) {
+               xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap,
+                   peer->version, peer->hmode);
+               xpkt.stratum = STRATUM_TO_PKT(sys_stratum);
+               xpkt.refid = sys_refid;
+               xpkt.rootdelay = HTONS_FP(DTOFP(sys_rootdelay));
+               xpkt.rootdispersion =
+                   HTONS_FP(DTOUFP(sys_rootdispersion));
+
+       /*
+        * This is a orphan child packet. The host is synchronized to an
+        * orphan parent. Show leap synchronized, orphan stratum, system
+        * reference ID, orphan root delay and system root dispersion.
+        */
+       } else if (sys_peer != NULL) {
+               xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
+                   peer->version, peer->hmode);
+               xpkt.stratum = STRATUM_TO_PKT(sys_orphan);
+               xpkt.refid = htonl(LOOPBACKADR);
+               xpkt.rootdelay = HTONS_FP(DTOFP(sys_orphandelay));
+               xpkt.rootdispersion =
+                   HTONS_FP(DTOUFP(sys_rootdispersion));
+
+       /*
+        * This is an orphan parent. Show leap synchronized, orphan
+        * stratum, loopack reference ID and zero root delay and root
+        * dispersion.
+        */
+       } else {
+               xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
+                   peer->version, peer->hmode);
+               xpkt.stratum = STRATUM_TO_PKT(sys_orphan);
+               xpkt.refid = sys_refid;
+               xpkt.rootdelay = 0;
+               xpkt.rootdispersion = 0;
+       }
+       xpkt.ppoll = peer->hpoll;
+       xpkt.precision = sys_precision;
+       HTONL_FP(&sys_reftime, &xpkt.reftime);
+       HTONL_FP(&peer->org, &xpkt.org);
+       HTONL_FP(&peer->rec, &xpkt.rec);
+
+       /*
+        * If the received packet contains a MAC, the transmitted packet
+        * is authenticated and contains a MAC. If not, the transmitted
+        * packet is not authenticated.
+        *
+        * It is most important when autokey is in use that the local
+        * interface IP address be known before the first packet is
+        * sent. Otherwise, it is not possible to compute a correct MAC
+        * the recipient will accept. Thus, the I/O semantics have to do
+        * a little more work. In particular, the wildcard interface
+        * might not be usable.
+        */
+       sendlen = LEN_PKT_NOMAC;
+       if (!(peer->flags & FLAG_AUTHENABLE)) {
+               get_systime(&peer->xmt);
+               HTONL_FP(&peer->xmt, &xpkt.xmt);
+               sendpkt(&peer->srcadr, peer->dstadr, sys_ttl[peer->ttl],
+                       &xpkt, sendlen);
+               peer->sent++;
+#ifdef DEBUG
+               if (debug)
+                       printf("transmit: at %ld %s->%s mode %d\n",
+                              current_time, peer->dstadr ? stoa(&peer->dstadr->sin) : "-",
+                              stoa(&peer->srcadr), peer->hmode);
+#endif
+               return;
+       }
+
+       /*
+        * The received packet contains a MAC, so the transmitted packet
+        * must be authenticated. If autokey is enabled, fuss with the
+        * various modes; otherwise, symmetric key cryptography is used.
+        */
+#ifdef OPENSSL
+       if (crypto_flags && (peer->flags & FLAG_SKEY)) {
+               struct exten *exten;    /* extension field */
+
+               /*
+                * The Public Key Dance (PKD): Cryptographic credentials
+                * are contained in extension fields, each including a
+                * 4-octet length/code word followed by a 4-octet
+                * association ID and optional additional data. Optional
+                * data includes a 4-octet data length field followed by
+                * the data itself. Request messages are sent from a
+                * configured association; response messages can be sent
+                * from a configured association or can take the fast
+                * path without ever matching an association. Response
+                * messages have the same code as the request, but have
+                * a response bit and possibly an error bit set. In this
+                * implementation, a message may contain no more than
+                * one command and no more than one response.
+                *
+                * Cryptographic session keys include both a public and
+                * a private componet. Request and response messages
+                * using extension fields are always sent with the
+                * private component set to zero. Packets without
+                * extension fields indlude the private component when
+                * the session key is generated.
+                */
+               while (1) {
+               
+                       /*
+                        * Allocate and initialize a keylist if not
+                        * already done. Then, use the list in inverse
+                        * order, discarding keys once used. Keep the
+                        * latest key around until the next one, so
+                        * clients can use client/server packets to
+                        * compute propagation delay.
+                        *
+                        * Note that once a key is used from the list,
+                        * it is retained in the key cache until the
+                        * next key is used. This is to allow a client
+                        * to retrieve the encrypted session key
+                        * identifier to verify authenticity.
+                        *
+                        * If for some reason a key is no longer in the
+                        * key cache, a birthday has happened and the
+                        * pseudo-random sequence is probably broken. In
+                        * that case, purge the keylist and regenerate
+                        * it.
+                        */
+                       if (peer->keynumber == 0)
+                               make_keylist(peer, peer->dstadr);
+                       else
+                               peer->keynumber--;
+                       xkeyid = peer->keylist[peer->keynumber];
+                       if (authistrusted(xkeyid))
+                               break;
+                       else
+                               key_expire(peer);
+               }
+               peer->keyid = xkeyid;
+               exten = NULL;
+               switch (peer->hmode) {
+
+                       /*
+                        * In broadcast server mode the autokey values are
+                        * required by the broadcast clients. Push them when a
+                        * new keylist is generated; otherwise, push the
+                        * association message so the client can request them at
+                        * other times.
+                        */
+               case MODE_BROADCAST:
+                       if (peer->flags & FLAG_ASSOC)
+                               exten = crypto_args(peer, CRYPTO_AUTO |
+                                                   CRYPTO_RESP, NULL);
+                       else
+                               exten = crypto_args(peer, CRYPTO_ASSOC |
+                                                   CRYPTO_RESP, NULL);
+                       break;
+
+               /*
+                * In symmetric modes the digest, certificate, agreement
+                * parameters, cookie and autokey values are required.
+                * The leapsecond table is optional. But, a passive peer
+                * will not believe the active peer until the latter has
+                * synchronized, so the agreement must be postponed
+                * until then. In any case, if a new keylist is
+                * generated, the autokey values are pushed.
+                *
+                * If the crypto bit is lit, don't send requests.
+                */
+               case MODE_ACTIVE:
+               case MODE_PASSIVE:
+                       if (peer->flash & TEST9)
+                               break;
+                       /*
+                        * Parameter and certificate.
+                        */
+                       if (!peer->crypto)
+                               exten = crypto_args(peer, CRYPTO_ASSOC,
+                                                   sys_hostname);
+                       else if (!(peer->crypto & CRYPTO_FLAG_VALID))
+                               exten = crypto_args(peer, CRYPTO_CERT,
+                                                   peer->issuer);
+
+                       /*
+                        * Identity. Note we have to sign the
+                        * certificate before the cookie to avoid a
+                        * deadlock when the passive peer is walking the
+                        * certificate trail. Awesome.
+                        */
+                       else if (!(peer->crypto & CRYPTO_FLAG_VRFY))
+                               exten = crypto_args(peer,
+                                                   crypto_ident(peer), NULL);
+                       else if (sys_leap != LEAP_NOTINSYNC &&
+                                !(peer->crypto & CRYPTO_FLAG_SIGN))
+                               exten = crypto_args(peer, CRYPTO_SIGN,
+                                                   sys_hostname);
+
+                       /*
+                        * Autokey. We request the cookie only when the
+                        * server and client are synchronized and
+                        * signatures work both ways. On the other hand,
+                        * the active peer needs the autokey values
+                        * before then and when the passive peer is
+                        * waiting for the active peer to synchronize.
+                        * Any time we regenerate the key list, we offer
+                        * the autokey values without being asked.
+                        */
+                       else if (sys_leap != LEAP_NOTINSYNC &&
+                                peer->leap != LEAP_NOTINSYNC &&
+                                !(peer->crypto & CRYPTO_FLAG_AGREE))
+                               exten = crypto_args(peer, CRYPTO_COOK,
+                                                   NULL);
+                       else if (peer->flags & FLAG_ASSOC)
+                               exten = crypto_args(peer, CRYPTO_AUTO |
+                                                   CRYPTO_RESP, NULL);
+                       else if (!(peer->crypto & CRYPTO_FLAG_AUTO))
+                               exten = crypto_args(peer, CRYPTO_AUTO,
+                                                   NULL);
+
+                       /*
+                        * Postamble. We trade leapseconds only when the
+                        * server and client are synchronized.
+                        */
+                       else if (sys_leap != LEAP_NOTINSYNC &&
+                                peer->leap != LEAP_NOTINSYNC &&
+                                peer->crypto & CRYPTO_FLAG_TAI &&
+                                !(peer->crypto & CRYPTO_FLAG_LEAP))
+                               exten = crypto_args(peer, CRYPTO_TAI,
+                                                   NULL);
+                       break;
+
+               /*
+                * In client mode the digest, certificate, agreement
+                * parameters and cookie are required. The leapsecond
+                * table is optional. If broadcast client mode, the
+                * autokey values are required as well. In broadcast
+                * client mode, these values must be acquired during the
+                * client/server exchange to avoid having to wait until
+                * the next key list regeneration. Otherwise, the poor
+                * dude may die a lingering death until becoming
+                * unreachable and attempting rebirth.
+                *
+                * If neither the server or client have the agreement
+                * parameters, the protocol transmits the cookie in the
+                * clear. If the server has the parameters, the client
+                * requests them and the protocol blinds it using the
+                * agreed key. It is a protocol error if the client has
+                * the parameters but the server does not.
+                *
+                * If the crypto bit is lit, don't send requests.
+                */
+               case MODE_CLIENT:
+                       if (peer->flash & TEST9)
+                               break;
+                       /*
+                        * Parameter and certificate.
+                        */
+                       if (!peer->crypto)
+                               exten = crypto_args(peer, CRYPTO_ASSOC,
+                                                   sys_hostname);
+                       else if (!(peer->crypto & CRYPTO_FLAG_VALID))
+                               exten = crypto_args(peer, CRYPTO_CERT,
+                                                   peer->issuer);
+
+                       /*
+                        * Identity
+                        */
+                       else if (!(peer->crypto & CRYPTO_FLAG_VRFY))
+                               exten = crypto_args(peer,
+                                                   crypto_ident(peer), NULL);
+
+                       /*
+                        * Autokey
+                        */
+                       else if (!(peer->crypto & CRYPTO_FLAG_AGREE))
+                               exten = crypto_args(peer, CRYPTO_COOK,
+                                                   NULL);
+                       else if (!(peer->crypto & CRYPTO_FLAG_AUTO) &&
+                                (peer->cast_flags & MDF_BCLNT))
+                               exten = crypto_args(peer, CRYPTO_AUTO,
+                                                   NULL);
+
+                       /*
+                        * Postamble. We can sign the certificate here,
+                        * since there is no chance of deadlock.
+                        */
+                       else if (sys_leap != LEAP_NOTINSYNC &&
+                                !(peer->crypto & CRYPTO_FLAG_SIGN))
+                               exten = crypto_args(peer, CRYPTO_SIGN,
+                                                   sys_hostname);
+                       else if (sys_leap != LEAP_NOTINSYNC &&
+                                peer->crypto & CRYPTO_FLAG_TAI &&
+                                !(peer->crypto & CRYPTO_FLAG_LEAP))
+                               exten = crypto_args(peer, CRYPTO_TAI,
+                                                   NULL);
+                       break;
+               }
+
+               /*
+                * Build the extension fields as directed. A response to
+                * a request is always sent, even if an error. If an
+                * error occurs when sending a request, the crypto
+                * machinery broke or was misconfigured. In that case
+                * light the crypto bit to suppress further requests.
+                */
+               if (peer->cmmd != NULL) {
+                       peer->cmmd->associd = htonl(peer->associd);
+                       sendlen += crypto_xmit(&xpkt, &peer->srcadr,
+                                              sendlen, peer->cmmd, 0);
+                       free(peer->cmmd);
+                       peer->cmmd = NULL;
+               }
+               if (exten != NULL) {
+                       int ltemp = 0;
+
+                       if (exten->opcode != 0) {
+                               ltemp = crypto_xmit(&xpkt,
+                                                      &peer->srcadr, sendlen, exten, 0);
+                               if (ltemp == 0) {
+                                       peer->flash |= TEST9; /* crypto error */
+                                       free(exten);
+                                       return;
+                               }
+                       }
+                       sendlen += ltemp;
+                       free(exten);
+               }
+
+               /*
+                * If extension fields are present, we must use a
+                * private cookie value of zero. Don't send if the
+                * crypto bit is set and no extension field is present,
+                * but in that case give back the key. Most intricate.
+                */
+               if (sendlen > LEN_PKT_NOMAC) {
+                       session_key(&peer->dstadr->sin, &peer->srcadr,
+                           xkeyid, 0, 2);
+               } else if (peer->flash & TEST9) {
+                       authtrust(xkeyid, 0);
+                       return;
+               }
+       } 
+#endif /* OPENSSL */
+
+       /*
+        * Stash the transmit timestamp corrected for the encryption
+        * delay. If autokey, give back the key, as we use keys only
+        * once. Check for errors such as missing keys, buffer overflow,
+        * etc.
+        */
+       xkeyid = peer->keyid;
+       get_systime(&peer->xmt);
+       L_ADD(&peer->xmt, &sys_authdelay);
+       HTONL_FP(&peer->xmt, &xpkt.xmt);
+       authlen = authencrypt(xkeyid, (u_int32 *)&xpkt, sendlen);
+       if (authlen == 0) {
+               msyslog(LOG_INFO, "transmit: %s key %u not found",
+                   stoa(&peer->srcadr), xkeyid);
+               peer->flash |= TEST9;           /* no key found */
+               return;
+       }
+       sendlen += authlen;
+#ifdef OPENSSL
+       if (xkeyid > NTP_MAXKEY)
+               authtrust(xkeyid, 0);
+#endif /* OPENSSL */
+       get_systime(&xmt_tx);
+       if (sendlen > sizeof(xpkt)) {
+               msyslog(LOG_ERR, "buffer overflow %u", sendlen);
+               exit (-1);
+       }
+       sendpkt(&peer->srcadr, peer->dstadr, sys_ttl[peer->ttl], &xpkt,
+               sendlen);
+
+       /*
+        * Calculate the encryption delay. Keep the minimum over
+        * the latest two samples.
+        */
+       L_SUB(&xmt_tx, &peer->xmt);
+       L_ADD(&xmt_tx, &sys_authdelay);
+       sys_authdly[1] = sys_authdly[0];
+       sys_authdly[0] = xmt_tx.l_uf;
+       if (sys_authdly[0] < sys_authdly[1])
+               sys_authdelay.l_uf = sys_authdly[0];
+       else
+               sys_authdelay.l_uf = sys_authdly[1];
+       peer->sent++;
+#ifdef OPENSSL
+#ifdef DEBUG
+       if (debug)
+               printf(
+                       "transmit: at %ld %s->%s mode %d keyid %08x len %d mac %d index %d\n",
+                       current_time, peer->dstadr ? ntoa(&peer->dstadr->sin) : "-",
+                       ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen -
+                       authlen, authlen, peer->keynumber);
+#endif
+#else
+#ifdef DEBUG
+       if (debug)
+               printf(
+                       "transmit: at %ld %s->%s mode %d keyid %08x len %d mac %d\n",
+                       current_time, peer->dstadr ? ntoa(&peer->dstadr->sin) : "-",
+                       ntoa(&peer->srcadr), peer->hmode, xkeyid, sendlen -
+                       authlen, authlen);
+#endif
+#endif /* OPENSSL */
+}
+
+
+/*
+ * fast_xmit - Send packet for nonpersistent association. Note that
+ * neither the source or destination can be a broadcast address.
+ */
+static void
+fast_xmit(
+       struct recvbuf *rbufp,  /* receive packet pointer */
+       int     xmode,          /* transmit mode */
+       keyid_t xkeyid,         /* transmit key ID */
+       int     mask            /* restrict mask */
+       )
+{
+       struct pkt xpkt;                /* transmit packet structure */
+       struct pkt *rpkt;               /* receive packet structure */
+       l_fp    xmt_ts;                 /* timestamp */
+       l_fp    xmt_tx;                 /* timestamp after authent */
+       int     sendlen, authlen;
+#ifdef OPENSSL
+       u_int32 temp32;
+#endif
+
+       /*
+        * Initialize transmit packet header fields from the receive
+        * buffer provided. We leave some fields intact as received. If
+        * the gazinta was from a multicast address, the gazoutta must
+        * go out another way.
+        *
+        * The root delay field is special. If the system stratum is
+        * less than the orphan stratum, send the real root delay.
+        * Otherwise, if there is no system peer, send the orphan delay.
+        * Otherwise, we must be an orphan parent, so send zero.
+        */
+       rpkt = &rbufp->recv_pkt;
+       if (rbufp->dstadr->flags & INT_MCASTOPEN)
+               rbufp->dstadr = findinterface(&rbufp->recv_srcadr);
+
+       /*
+        * This is deliciously complicated. There are four cases.
+        *
+        * case         leap    stratum refid   delay   dispersion
+        *
+        * KoD          11      16      KISS    system  system
+        * normal       system  system  system  system  system
+        * orphan child 00      orphan  system  orphan  system
+        * orphan parent 00     orphan  loopbk  0       0
+        */
+       /*
+        * This is a kiss-of-death (KoD) packet. Show leap
+        * unsynchronized, stratum zero, reference ID the four-character
+        * kiss code and system root delay. Note the rate limit on these
+        * packets. Once a second initialize a bucket counter. Every
+        * packet sent decrements the counter until reaching zero. If
+        * the counter is zero, drop the kiss.
+        */
+       if (mask & RES_LIMITED) {
+               sys_limitrejected++;
+               if (sys_kod == 0 || !(mask & RES_DEMOBILIZE))
+                       return;
+
+               sys_kod--;
+               xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
+                   PKT_VERSION(rpkt->li_vn_mode), xmode);
+               xpkt.stratum = STRATUM_UNSPEC;
+               memcpy(&xpkt.refid, "RATE", 4);
+               xpkt.rootdelay = HTONS_FP(DTOFP(sys_rootdelay));
+               xpkt.rootdispersion =
+                   HTONS_FP(DTOUFP(sys_rootdispersion));
+
+       /*
+        * This is a normal packet. Use the system variables.
+        */
+       } else if (sys_stratum < sys_orphan) {
+               xpkt.li_vn_mode = PKT_LI_VN_MODE(sys_leap,
+                   PKT_VERSION(rpkt->li_vn_mode), xmode);
+               xpkt.stratum = STRATUM_TO_PKT(sys_stratum);
+               xpkt.refid = sys_refid;
+               xpkt.rootdelay = HTONS_FP(DTOFP(sys_rootdelay));
+               xpkt.rootdispersion =
+                   HTONS_FP(DTOUFP(sys_rootdispersion));
+
+       /*
+        * This is a orphan child packet. The host is synchronized to an
+        * orphan parent. Show leap synchronized, orphan stratum, system
+        * reference ID and orphan root delay.
+        */
+       } else if (sys_peer != NULL) {
+               xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
+                   PKT_VERSION(rpkt->li_vn_mode), xmode);
+               xpkt.stratum = STRATUM_TO_PKT(sys_orphan);
+               xpkt.refid = sys_refid;
+               xpkt.rootdelay = HTONS_FP(DTOFP(sys_orphandelay));
+               xpkt.rootdispersion =
+                   HTONS_FP(DTOUFP(sys_rootdispersion));
+
+       /*
+        * This is an orphan parent. Show leap synchronized, orphan
+        * stratum, loopack reference ID and zero root delay.
+        */
+       } else {
+               xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING,
+                   PKT_VERSION(rpkt->li_vn_mode), xmode);
+               xpkt.stratum = STRATUM_TO_PKT(sys_orphan);
+               xpkt.refid = htonl(LOOPBACKADR);
+               xpkt.rootdelay = HTONS_FP(DTOFP(0));
+               xpkt.rootdispersion = HTONS_FP(DTOFP(0));
+       }
+       xpkt.ppoll = rpkt->ppoll;
+       xpkt.precision = sys_precision;
+       xpkt.rootdispersion = HTONS_FP(DTOUFP(sys_rootdispersion));
+       HTONL_FP(&sys_reftime, &xpkt.reftime);
+       xpkt.org = rpkt->xmt;
+       HTONL_FP(&rbufp->recv_time, &xpkt.rec);
+
+       /*
+        * If the received packet contains a MAC, the transmitted packet
+        * is authenticated and contains a MAC. If not, the transmitted
+        * packet is not authenticated.
+        */
+       sendlen = LEN_PKT_NOMAC;
+       if (rbufp->recv_length == sendlen) {
+               get_systime(&xmt_ts);
+               HTONL_FP(&xmt_ts, &xpkt.xmt);
+               sendpkt(&rbufp->recv_srcadr, rbufp->dstadr, 0, &xpkt,
+                   sendlen);
+#ifdef DEBUG
+               if (debug)
+                       printf("transmit: at %ld %s->%s mode %d\n",
+                           current_time, stoa(&rbufp->dstadr->sin),
+                           stoa(&rbufp->recv_srcadr), xmode);
+#endif
+               return;
+       }
+
+       /*
+        * The received packet contains a MAC, so the transmitted packet
+        * must be authenticated. For symmetric key cryptography, use
+        * the predefined and trusted symmetric keys to generate the
+        * cryptosum. For autokey cryptography, use the server private
+        * value to generate the cookie, which is unique for every
+        * source-destination-key ID combination.
+        */
+#ifdef OPENSSL
+       if (xkeyid > NTP_MAXKEY) {
+               keyid_t cookie;
+
+               /*
+                * The only way to get here is a reply to a legitimate
+                * client request message, so the mode must be
+                * MODE_SERVER. If an extension field is present, there
+                * can be only one and that must be a command. Do what
+                * needs, but with private value of zero so the poor
+                * jerk can decode it. If no extension field is present,
+                * use the cookie to generate the session key.
+                */
+               cookie = session_key(&rbufp->recv_srcadr,
+                   &rbufp->dstadr->sin, 0, sys_private, 0);
+               if (rbufp->recv_length >= (int)(sendlen + MAX_MAC_LEN +
+                   2 * sizeof(u_int32))) {
+                       session_key(&rbufp->dstadr->sin,
+                           &rbufp->recv_srcadr, xkeyid, 0, 2);
+                       temp32 = CRYPTO_RESP;
+                       rpkt->exten[0] |= htonl(temp32);
+                       sendlen += crypto_xmit(&xpkt,
+                           &rbufp->recv_srcadr, sendlen,
+                           (struct exten *)rpkt->exten, cookie);
+               } else {
+                       session_key(&rbufp->dstadr->sin,
+                           &rbufp->recv_srcadr, xkeyid, cookie, 2);
+               }
+       }
+#endif /* OPENSSL */
+       get_systime(&xmt_ts);
+       L_ADD(&xmt_ts, &sys_authdelay);
+       HTONL_FP(&xmt_ts, &xpkt.xmt);
+       authlen = authencrypt(xkeyid, (u_int32 *)&xpkt, sendlen);
+       sendlen += authlen;
+#ifdef OPENSSL
+       if (xkeyid > NTP_MAXKEY)
+               authtrust(xkeyid, 0);
+#endif /* OPENSSL */
+       get_systime(&xmt_tx);
+       if (sendlen > sizeof(xpkt)) {
+               msyslog(LOG_ERR, "buffer overflow %u", sendlen);
+               exit (-1);
+       }
+       sendpkt(&rbufp->recv_srcadr, rbufp->dstadr, 0, &xpkt, sendlen);
+
+       /*
+        * Calculate the encryption delay. Keep the minimum over the
+        * latest two samples.
+        */
+       L_SUB(&xmt_tx, &xmt_ts);
+       L_ADD(&xmt_tx, &sys_authdelay);
+       sys_authdly[1] = sys_authdly[0];
+       sys_authdly[0] = xmt_tx.l_uf;
+       if (sys_authdly[0] < sys_authdly[1])
+               sys_authdelay.l_uf = sys_authdly[0];
+       else
+               sys_authdelay.l_uf = sys_authdly[1];
+#ifdef DEBUG
+       if (debug)
+               printf(
+                   "transmit: at %ld %s->%s mode %d keyid %08x len %d mac %d\n",
+                   current_time, ntoa(&rbufp->dstadr->sin),
+                   ntoa(&rbufp->recv_srcadr), xmode, xkeyid, sendlen -
+                   authlen, authlen);
+#endif
+}
+
+
+#ifdef OPENSSL
+/*
+ * key_expire - purge the key list
+ */
+void
+key_expire(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       int i;
+
+       if (peer->keylist != NULL) {
+               for (i = 0; i <= peer->keynumber; i++)
+                       authtrust(peer->keylist[i], 0);
+               free(peer->keylist);
+               peer->keylist = NULL;
+       }
+       value_free(&peer->sndval);
+       peer->keynumber = 0;
+#ifdef DEBUG
+       if (debug)
+               printf("key_expire: at %lu\n", current_time);
+#endif
+}
+#endif /* OPENSSL */
+
+
+/*
+ * Determine if the peer is unfit for synchronization
+ *
+ * A peer is unfit for synchronization if
+ * > TEST10 bad leap or stratum below floor or at or above ceiling
+ * > TEST11 root distance exceeded
+ * > TEST12 a direct or indirect synchronization loop would form
+ * > TEST13 unreachable or noselect
+ */
+int                            /* FALSE if fit, TRUE if unfit */
+peer_unfit(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       int     rval = 0;
+
+       /*
+        * A stratum error occurs if (1) the server has never been
+        * synchronized, (2) the server stratum is below the floor or
+        * greater than or equal to the ceiling, (3) the system stratum
+        * is below the orphan stratum and the server stratum is greater
+        * than or equal to the orphan stratum.
+        */
+       if (peer->leap == LEAP_NOTINSYNC || peer->stratum < sys_floor ||
+           peer->stratum >= sys_ceiling || (sys_stratum < sys_orphan &&
+           peer->stratum >= sys_orphan))
+               rval |= TEST10;         /* stratum out of bounds */
+
+       /*
+        * A distance error occurs if the root distance is greater than
+        * or equal to the distance threshold plus the increment due to
+        * one poll interval.
+        */
+       if (root_distance(peer) >= sys_maxdist + clock_phi *
+           ULOGTOD(sys_poll))
+               rval |= TEST11;         /* distance exceeded */
+
+       /*
+        * A loop error occurs if the remote peer is synchronized to the
+        * local peer of if the remote peer is synchronized to the same
+        * server as the local peer, but only if the remote peer is not
+        * the orphan parent.
+        */
+       if (peer->stratum > 1 && peer->refid != htonl(LOOPBACKADR) &&
+           ((!peer->dstadr || peer->refid == peer->dstadr->addr_refid) ||
+           peer->refid == sys_refid))
+               rval |= TEST12;         /* synch loop */
+
+       /*
+        * An unreachable error occurs if the server is unreachable or
+        * the noselect bit is set.
+        */
+       if (!peer->reach || peer->flags & FLAG_NOSELECT)
+               rval |= TEST13;         /* unreachable */
+
+       peer->flash &= ~PEER_TEST_MASK;
+       peer->flash |= rval;
+       return (rval);
+}
+
+
+/*
+ * Find the precision of this particular machine
+ */
+#define MINSTEP 100e-9         /* minimum clock increment (s) */
+#define MAXSTEP 20e-3          /* maximum clock increment (s) */
+#define MINLOOPS 5             /* minimum number of step samples */
+
+/*
+ * This routine calculates the system precision, defined as the minimum
+ * of a sequence of differences between successive readings of the
+ * system clock. However, if the system clock can be read more than once
+ * during a tick interval, the difference can be zero or one LSB unit,
+ * where the LSB corresponds to one nanosecond or one microsecond.
+ * Conceivably, if some other process preempts this one and reads the
+ * clock, the difference can be more than one LSB unit.
+ *
+ * For hardware clock frequencies of 10 MHz or less, we assume the
+ * logical clock advances only at the hardware clock tick. For higher
+ * frequencies, we assume the logical clock can advance no more than 100
+ * nanoseconds between ticks.
+ */
+int
+default_get_precision(void)
+{
+       l_fp    val;            /* current seconds fraction */
+       l_fp    last;           /* last seconds fraction */
+       l_fp    diff;           /* difference */
+       double  tick;           /* computed tick value */
+       double  dtemp;          /* scratch */
+       int     i;              /* log2 precision */
+
+       /*
+        * Loop to find tick value in nanoseconds. Toss out outlyer
+        * values less than the minimun tick value. In wacky cases, use
+        * the default maximum value.
+        */
+       get_systime(&last);
+       tick = MAXSTEP;
+       for (i = 0; i < MINLOOPS;) {
+               get_systime(&val);
+               diff = val;
+               L_SUB(&diff, &last);
+               last = val;
+               LFPTOD(&diff, dtemp);
+               if (dtemp < MINSTEP)
+                       continue;
+               i++;
+               if (dtemp < tick)
+                       tick = dtemp;
+       }
+
+       /*
+        * Find the nearest power of two.
+        */
+       NLOG(NLOG_SYSEVENT)
+           msyslog(LOG_INFO, "precision = %.3f usec", tick * 1e6);
+       for (i = 0; tick <= 1; i++)
+               tick *= 2;
+       if (tick - 1. > 1. - tick / 2)
+               i--;
+       return (-i);
+}
+
+
+/*
+ * kod_proto - called once per second to limit kiss-of-death packets
+ */
+void
+kod_proto(void)
+{
+       sys_kod = sys_kod_rate;
+}
+
+
+/*
+ * init_proto - initialize the protocol module's data
+ */
+void
+init_proto(void)
+{
+       l_fp    dummy;
+       int     i;
+
+       /*
+        * Fill in the sys_* stuff.  Default is don't listen to
+        * broadcasting, authenticate.
+        */
+       sys_leap = LEAP_NOTINSYNC;
+       sys_stratum = STRATUM_UNSPEC;
+       memcpy(&sys_refid, "INIT", 4);
+       sys_precision = (s_char)default_get_precision();
+       sys_jitter = LOGTOD(sys_precision);
+       sys_rootdelay = 0;
+       sys_orphandelay = (double)(ntp_random() & 0xffff) / 65536. *
+           sys_maxdist;
+       sys_rootdispersion = 0;
+       L_CLR(&sys_reftime);
+       sys_peer = NULL;
+       sys_survivors = 0;
+       get_systime(&dummy);
+       sys_manycastserver = 0;
+       sys_bclient = 0;
+       sys_bdelay = DEFBROADDELAY;
+       sys_calldelay = BURST_DELAY;
+       sys_authenticate = 1;
+       L_CLR(&sys_authdelay);
+       sys_authdly[0] = sys_authdly[1] = 0;
+       sys_stattime = 0;
+       proto_clr_stats();
+       for (i = 0; i < MAX_TTL; i++) {
+               sys_ttl[i] = (u_char)((i * 256) / MAX_TTL);
+               sys_ttlmax = i;
+       }
+#ifdef OPENSSL
+       sys_automax = 1 << NTP_AUTOMAX;
+#endif /* OPENSSL */
+
+       /*
+        * Default these to enable
+        */
+       ntp_enable = 1;
+#ifndef KERNEL_FLL_BUG
+       kern_enable = 1;
+#endif
+       pps_enable = 0;
+       stats_control = 1;
+}
+
+
+/*
+ * proto_config - configure the protocol module
+ */
+void
+proto_config(
+       int     item,
+       u_long  value,
+       double  dvalue,
+       struct sockaddr_storage* svalue
+       )
+{
+       /*
+        * Figure out what he wants to change, then do it
+        */
+       switch (item) {
+
+       /*
+        * Turn on/off kernel discipline.
+        */
+       case PROTO_KERNEL:
+               kern_enable = (int)value;
+               break;
+
+       /*
+        * Turn on/off clock discipline.
+        */
+       case PROTO_NTP:
+               ntp_enable = (int)value;
+               break;
+
+       /*
+        * Turn on/off monitoring.
+        */
+       case PROTO_MONITOR:
+               if (value)
+                       mon_start(MON_ON);
+               else
+                       mon_stop(MON_ON);
+               break;
+
+       /*
+        * Turn on/off statistics.
+        */
+       case PROTO_FILEGEN:
+               stats_control = (int)value;
+               break;
+
+       /*
+        * Turn on/off enable broadcasts.
+        */
+       case PROTO_BROADCLIENT:
+               sys_bclient = (int)value;
+               if (sys_bclient == 0)
+                       io_unsetbclient();
+               else
+                       io_setbclient();
+               break;
+
+       /*
+        * Turn on/off PPS discipline.
+        */
+       case PROTO_PPS:
+               pps_enable = (int)value;
+               break;
+
+       /*
+        * Add muliticast group address.
+        */
+       case PROTO_MULTICAST_ADD:
+               if (svalue)
+                   io_multicast_add(*svalue);
+               sys_bclient = 1;
+               break;
+
+       /*
+        * Delete multicast group address.
+        */
+       case PROTO_MULTICAST_DEL:
+               if (svalue)
+                   io_multicast_del(*svalue);
+               break;
+
+       /*
+        * Set default broadcast delay.
+        */
+       case PROTO_BROADDELAY:
+               sys_bdelay = dvalue;
+               break;
+
+       /*
+        * Set modem call delay.
+        */
+       case PROTO_CALLDELAY:
+               sys_calldelay = (int)value;
+               break;
+
+       /*
+        * Turn on/off authentication to mobilize ephemeral
+        * associations.
+        */
+       case PROTO_AUTHENTICATE:
+               sys_authenticate = (int)value;
+               break;
+
+       /*
+        * Set minimum number of survivors.
+        */
+       case PROTO_MINCLOCK:
+               sys_minclock = (int)dvalue;
+               break;
+
+       /*
+        * Set maximum number of preemptable associations.
+        */
+       case PROTO_MAXCLOCK:
+               sys_maxclock = (int)dvalue;
+               break;
+
+       /*
+        * Set minimum number of survivors.
+        */
+       case PROTO_MINSANE:
+               sys_minsane = (int)dvalue;
+               break;
+
+       /*
+        * Set stratum floor.
+        */
+       case PROTO_FLOOR:
+               sys_floor = (int)dvalue;
+               break;
+
+       /*
+        * Set stratum ceiling.
+        */
+       case PROTO_CEILING:
+               sys_ceiling = (int)dvalue;
+               break;
+
+       /*
+        * Set orphan stratum.
+        */
+       case PROTO_ORPHAN:
+               sys_orphan = (int)dvalue;
+               break;
+
+       /*
+        * Set cohort switch.
+        */
+       case PROTO_COHORT:
+               sys_cohort = (int)dvalue;
+               break;
+
+       /*
+        * Set minimum dispersion increment.
+        */
+       case PROTO_MINDISP:
+               sys_mindisp = dvalue;
+               break;
+
+       /*
+        * Set maximum distance (select threshold).
+        */
+       case PROTO_MAXDIST:
+               sys_maxdist = dvalue;
+               break;
+
+       /*
+        * Set anticlockhop threshold.
+        */
+       case PROTO_MAXHOP:
+               sys_maxhop = (int)dvalue;
+               break;
+
+       /*
+        * Set adjtime() resolution (s).
+        */
+       case PROTO_ADJ:
+               sys_tick = dvalue;
+               break;
+
+       /*
+        * Set manycast beacon interval.
+        */
+       case PROTO_BEACON:
+               sys_beacon = (int)dvalue;
+               break;
+
+#ifdef REFCLOCK
+       /*
+        * Turn on/off refclock calibrate
+        */
+       case PROTO_CAL:
+               cal_enable = (int)value;
+               break;
+#endif /* REFCLOCK */
+       default:
+
+               /*
+                * Log this error.
+                */
+               msyslog(LOG_INFO,
+                   "proto_config: illegal item %d, value %ld", item,
+                   value);
+       }
+}
+
+
+/*
+ * proto_clr_stats - clear protocol stat counters
+ */
+void
+proto_clr_stats(void)
+{
+       sys_stattime = current_time;
+       sys_received = 0;
+       sys_processed = 0;
+       sys_newversionpkt = 0;
+       sys_oldversionpkt = 0;
+       sys_unknownversion = 0;
+       sys_restricted = 0;
+       sys_badlength = 0;
+       sys_badauth = 0;
+       sys_limitrejected = 0;
+}
diff --git a/ntpd/ntp_refclock.c b/ntpd/ntp_refclock.c
new file mode 100644 (file)
index 0000000..a29ef08
--- /dev/null
@@ -0,0 +1,1229 @@
+/*
+ * ntp_refclock - processing support for reference clocks
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_unixtime.h"
+#include "ntp_tty.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif /* HAVE_SYS_IOCTL_H */
+
+#ifdef REFCLOCK
+
+#ifdef TTYCLK
+# ifdef HAVE_SYS_CLKDEFS_H
+#  include <sys/clkdefs.h>
+#  include <stropts.h>
+# endif
+# ifdef HAVE_SYS_SIO_H
+#  include <sys/sio.h>
+# endif
+#endif /* TTYCLK */
+
+#ifdef KERNEL_PLL
+#include "ntp_syscall.h"
+#endif /* KERNEL_PLL */
+
+/*
+ * Reference clock support is provided here by maintaining the fiction
+ * that the clock is actually a peer. As no packets are exchanged with a
+ * reference clock, however, we replace the transmit, receive and packet
+ * procedures with separate code to simulate them. Routines
+ * refclock_transmit() and refclock_receive() maintain the peer
+ * variables in a state analogous to an actual peer and pass reference
+ * clock data on through the filters. Routines refclock_peer() and
+ * refclock_unpeer() are called to initialize and terminate reference
+ * clock associations. A set of utility routines is included to open
+ * serial devices, process sample data, edit input lines to extract
+ * embedded timestamps and to peform various debugging functions.
+ *
+ * The main interface used by these routines is the refclockproc
+ * structure, which contains for most drivers the decimal equivalants of
+ * the year, day, month, hour, second and millisecond/microsecond
+ * decoded from the ASCII timecode. Additional information includes the
+ * receive timestamp, exception report, statistics tallies, etc. In
+ * addition, there may be a driver-specific unit structure used for
+ * local control of the device.
+ *
+ * The support routines are passed a pointer to the peer structure,
+ * which is used for all peer-specific processing and contains a pointer
+ * to the refclockproc structure, which in turn containes a pointer to
+ * the unit structure, if used. The peer structure is identified by an
+ * interface address in the dotted quad form 127.127.t.u (for now only
+ * IPv4 addresses are used, so we need to be sure the address is it),
+ * where t is the clock type and u the unit. Some legacy drivers derive
+ * the refclockproc structure pointer from the table
+ * typeunit[type][unit]. This interface is strongly discouraged and may
+ * be abandoned in future.
+ */
+#define MAXUNIT        4       /* max units */
+#define FUDGEFAC       .1      /* fudge correction factor */
+#define LF             0x0a    /* ASCII LF */
+
+#ifdef PPS
+int    fdpps;                  /* ppsclock legacy */
+#endif /* PPS */
+int    cal_enable;             /* enable refclock calibrate */
+
+/*
+ * Type/unit peer index. Used to find the peer structure for control and
+ * debugging. When all clock drivers have been converted to new style,
+ * this dissapears.
+ */
+static struct peer *typeunit[REFCLK_MAX + 1][MAXUNIT];
+
+/*
+ * Forward declarations
+ */
+#ifdef QSORT_USES_VOID_P
+static int refclock_cmpl_fp P((const void *, const void *));
+#else
+static int refclock_cmpl_fp P((const double *, const double *));
+#endif /* QSORT_USES_VOID_P */
+static int refclock_sample P((struct refclockproc *));
+
+
+/*
+ * refclock_report - note the occurance of an event
+ *
+ * This routine presently just remembers the report and logs it, but
+ * does nothing heroic for the trap handler. It tries to be a good
+ * citizen and bothers the system log only if things change.
+ */
+void
+refclock_report(
+       struct peer *peer,
+       int code
+       )
+{
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       if (pp == NULL)
+               return;
+
+       switch (code) {
+               case CEVNT_NOMINAL:
+                       break;
+
+               case CEVNT_TIMEOUT:
+                       pp->noreply++;
+                       break;
+
+               case CEVNT_BADREPLY:
+                       pp->badformat++;
+                       break;
+
+               case CEVNT_FAULT:
+                       break;
+
+               case CEVNT_PROP:
+                       break;
+
+               case CEVNT_BADDATE:
+               case CEVNT_BADTIME:
+                       pp->baddata++;
+                       break;
+
+               default:
+                       /* shouldn't happen */
+                       break;
+       }
+
+       if (pp->currentstatus != code) {
+               pp->currentstatus = (u_char)code;
+
+               /* RFC1305: copy only iff not CEVNT_NOMINAL */
+               if (code != CEVNT_NOMINAL)
+                       pp->lastevent = (u_char)code;
+
+               if (code == CEVNT_FAULT)
+                       msyslog(LOG_ERR,
+                           "clock %s event '%s' (0x%02x)",
+                           refnumtoa(&peer->srcadr),
+                           ceventstr(code), code);
+               else {
+                       NLOG(NLOG_CLOCKEVENT)
+                         msyslog(LOG_INFO,
+                           "clock %s event '%s' (0x%02x)",
+                           refnumtoa(&peer->srcadr),
+                           ceventstr(code), code);
+               }
+
+               /* RFC1305: post peer clock event */
+               report_event(EVNT_PEERCLOCK, peer);
+       }
+}
+
+/*
+ * init_refclock - initialize the reference clock drivers
+ *
+ * This routine calls each of the drivers in turn to initialize internal
+ * variables, if necessary. Most drivers have nothing to say at this
+ * point.
+ */
+void
+init_refclock(void)
+{
+       int i, j;
+
+       for (i = 0; i < (int)num_refclock_conf; i++) {
+               if (refclock_conf[i]->clock_init != noentry)
+                       (refclock_conf[i]->clock_init)();
+               for (j = 0; j < MAXUNIT; j++)
+                       typeunit[i][j] = 0;
+       }
+}
+
+
+/*
+ * refclock_newpeer - initialize and start a reference clock
+ *
+ * This routine allocates and initializes the interface structure which
+ * supports a reference clock in the form of an ordinary NTP peer. A
+ * driver-specific support routine completes the initialization, if
+ * used. Default peer variables which identify the clock and establish
+ * its reference ID and stratum are set here. It returns one if success
+ * and zero if the clock address is invalid or already running,
+ * insufficient resources are available or the driver declares a bum
+ * rap.
+ */
+int
+refclock_newpeer(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       u_char clktype;
+       int unit;
+
+       /*
+        * Check for valid clock address. If already running, shut it
+        * down first.
+        */
+       if (peer->srcadr.ss_family != AF_INET) {
+               msyslog(LOG_ERR,
+                      "refclock_newpeer: clock address %s invalid, address family not implemented for refclock",
+                        stoa(&peer->srcadr));
+                return (0);
+        }
+       if (!ISREFCLOCKADR(&peer->srcadr)) {
+               msyslog(LOG_ERR,
+                       "refclock_newpeer: clock address %s invalid",
+                       stoa(&peer->srcadr));
+               return (0);
+       }
+       clktype = (u_char)REFCLOCKTYPE(&peer->srcadr);
+       unit = REFCLOCKUNIT(&peer->srcadr);
+       if (clktype >= num_refclock_conf || unit >= MAXUNIT ||
+               refclock_conf[clktype]->clock_start == noentry) {
+               msyslog(LOG_ERR,
+                       "refclock_newpeer: clock type %d invalid\n",
+                       clktype);
+               return (0);
+       }
+
+       /*
+        * Allocate and initialize interface structure
+        */
+       pp = (struct refclockproc *)emalloc(sizeof(struct refclockproc));
+       if (pp == NULL)
+               return (0);
+
+       memset((char *)pp, 0, sizeof(struct refclockproc));
+       typeunit[clktype][unit] = peer;
+       peer->procptr = pp;
+
+       /*
+        * Initialize structures
+        */
+       peer->refclktype = clktype;
+       peer->refclkunit = (u_char)unit;
+       peer->flags |= FLAG_REFCLOCK | FLAG_FIXPOLL;
+       peer->leap = LEAP_NOTINSYNC;
+       peer->stratum = STRATUM_REFCLOCK;
+       peer->ppoll = peer->maxpoll;
+       pp->type = clktype;
+       pp->timestarted = current_time;
+
+       /*
+        * Set peer.pmode based on the hmode. For appearances only.
+        */
+       switch (peer->hmode) {
+       case MODE_ACTIVE:
+               peer->pmode = MODE_PASSIVE;
+               break;
+
+       default:
+               peer->pmode = MODE_SERVER;
+               break;
+       }
+
+       /*
+        * Do driver dependent initialization. The above defaults
+        * can be wiggled, then finish up for consistency.
+        */
+       if (!((refclock_conf[clktype]->clock_start)(unit, peer))) {
+               refclock_unpeer(peer);
+               return (0);
+       }
+       peer->refid = pp->refid;
+       return (1);
+}
+
+
+/*
+ * refclock_unpeer - shut down a clock
+ */
+void
+refclock_unpeer(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       u_char clktype;
+       int unit;
+
+       /*
+        * Wiggle the driver to release its resources, then give back
+        * the interface structure.
+        */
+       if (!peer->procptr)
+               return;
+
+       clktype = peer->refclktype;
+       unit = peer->refclkunit;
+       if (refclock_conf[clktype]->clock_shutdown != noentry)
+               (refclock_conf[clktype]->clock_shutdown)(unit, peer);
+       free(peer->procptr);
+       peer->procptr = 0;
+}
+
+
+/*
+ * refclock_timer - called once per second for housekeeping.
+ */
+void
+refclock_timer(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       u_char clktype;
+       int unit;
+
+       clktype = peer->refclktype;
+       unit = peer->refclkunit;
+       if (refclock_conf[clktype]->clock_timer != noentry)
+               (refclock_conf[clktype]->clock_timer)(unit, peer);
+}
+       
+
+/*
+ * refclock_transmit - simulate the transmit procedure
+ *
+ * This routine implements the NTP transmit procedure for a reference
+ * clock. This provides a mechanism to call the driver at the NTP poll
+ * interval, as well as provides a reachability mechanism to detect a
+ * broken radio or other madness.
+ */
+void
+refclock_transmit(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       u_char clktype;
+       int unit;
+
+       clktype = peer->refclktype;
+       unit = peer->refclkunit;
+       peer->sent++;
+       get_systime(&peer->xmt);
+
+       /*
+        * This is a ripoff of the peer transmit routine, but
+        * specialized for reference clocks. We do a little less
+        * protocol here and call the driver-specific transmit routine.
+        */
+       if (peer->burst == 0) {
+               u_char oreach;
+#ifdef DEBUG
+               if (debug)
+                       printf("refclock_transmit: at %ld %s\n",
+                           current_time, stoa(&(peer->srcadr)));
+#endif
+
+               /*
+                * Update reachability and poll variables like the
+                * network code.
+                */
+               oreach = peer->reach;
+               peer->reach <<= 1;
+               peer->outdate = current_time;
+               if (!peer->reach) {
+                       if (oreach) {
+                               report_event(EVNT_UNREACH, peer);
+                               peer->timereachable = current_time;
+                       }
+               } else {
+                       if (!(oreach & 0x07)) {
+                               clock_filter(peer, 0., 0., MAXDISPERSE);
+                               clock_select();
+                       }
+                       if (peer->flags & FLAG_BURST)
+                               peer->burst = NSTAGE;
+               }
+       } else {
+               peer->burst--;
+       }
+       if (refclock_conf[clktype]->clock_poll != noentry)
+               (refclock_conf[clktype]->clock_poll)(unit, peer);
+       poll_update(peer, peer->hpoll);
+}
+
+
+/*
+ * Compare two doubles - used with qsort()
+ */
+#ifdef QSORT_USES_VOID_P
+static int
+refclock_cmpl_fp(
+       const void *p1,
+       const void *p2
+       )
+{
+       const double *dp1 = (const double *)p1;
+       const double *dp2 = (const double *)p2;
+
+       if (*dp1 < *dp2)
+               return (-1);
+
+       if (*dp1 > *dp2)
+               return (1);
+
+       return (0);
+}
+
+#else
+static int
+refclock_cmpl_fp(
+       const double *dp1,
+       const double *dp2
+       )
+{
+       if (*dp1 < *dp2)
+               return (-1);
+
+       if (*dp1 > *dp2)
+               return (1);
+
+       return (0);
+}
+#endif /* QSORT_USES_VOID_P */
+
+
+/*
+ * refclock_process_offset - update median filter
+ *
+ * This routine uses the given offset and timestamps to construct a new
+ * entry in the median filter circular buffer. Samples that overflow the
+ * filter are quietly discarded.
+ */
+void
+refclock_process_offset(
+       struct refclockproc *pp,        /* refclock structure pointer */
+       l_fp lasttim,                   /* last timecode timestamp */
+       l_fp lastrec,                   /* last receive timestamp */
+       double fudge
+       )
+{
+       l_fp lftemp;
+       double doffset;
+
+       pp->lastrec = lastrec;
+       lftemp = lasttim;
+       L_SUB(&lftemp, &lastrec);
+       LFPTOD(&lftemp, doffset);
+       SAMPLE(doffset + fudge);
+}
+
+
+/*
+ * refclock_process - process a sample from the clock
+ *
+ * This routine converts the timecode in the form days, hours, minutes,
+ * seconds and milliseconds/microseconds to internal timestamp format,
+ * then constructs a new entry in the median filter circular buffer.
+ * Return success (1) if the data are correct and consistent with the
+ * converntional calendar.
+ *
+ * Important for PPS users: Normally, the pp->lastrec is set to the
+ * system time when the on-time character is received and the pp->year,
+ * ..., pp->second decoded and the seconds fraction pp->nsec in
+ * nanoseconds). When a PPS offset is available, pp->nsec is forced to
+ * zero and the fraction for pp->lastrec is set to the PPS offset.
+ */
+int
+refclock_process(
+       struct refclockproc *pp         /* refclock structure pointer */
+       )
+{
+       l_fp offset, ltemp;
+
+       /*
+        * Compute the timecode timestamp from the days, hours, minutes,
+        * seconds and milliseconds/microseconds of the timecode. Use
+        * clocktime() for the aggregate seconds and the msec/usec for
+        * the fraction, when present. Note that this code relies on the
+        * filesystem time for the years and does not use the years of
+        * the timecode.
+        */
+       if (!clocktime(pp->day, pp->hour, pp->minute, pp->second, GMT,
+               pp->lastrec.l_ui, &pp->yearstart, &offset.l_ui))
+               return (0);
+
+       offset.l_uf = 0;
+       DTOLFP(pp->nsec / 1e9, &ltemp);
+       L_ADD(&offset, &ltemp);
+       refclock_process_offset(pp, offset, pp->lastrec,
+           pp->fudgetime1);
+       return (1);
+}
+
+
+/*
+ * refclock_sample - process a pile of samples from the clock
+ *
+ * This routine implements a recursive median filter to suppress spikes
+ * in the data, as well as determine a performance statistic. It
+ * calculates the mean offset and RMS jitter. A time adjustment
+ * fudgetime1 can be added to the final offset to compensate for various
+ * systematic errors. The routine returns the number of samples
+ * processed, which could be zero.
+ */
+static int
+refclock_sample(
+       struct refclockproc *pp         /* refclock structure pointer */
+       )
+{
+       int     i, j, k, m, n;
+       double  off[MAXSTAGE];
+       double  offset;
+
+       /*
+        * Copy the raw offsets and sort into ascending order. Don't do
+        * anything if the buffer is empty.
+        */
+       n = 0;
+       while (pp->codeproc != pp->coderecv) {
+               pp->codeproc = (pp->codeproc + 1) % MAXSTAGE;
+               off[n] = pp->filter[pp->codeproc];
+               n++;
+       }
+       if (n == 0)
+               return (0);
+
+       if (n > 1)
+               qsort(
+#ifdef QSORT_USES_VOID_P
+                   (void *)
+#else
+                   (char *)
+#endif
+                   off, (size_t)n, sizeof(double), refclock_cmpl_fp);
+
+       /*
+        * Reject the furthest from the median of the samples until
+        * approximately 60 percent of the samples remain.
+        */
+       i = 0; j = n;
+       m = n - (n * 4) / 10;
+       while ((j - i) > m) {
+               offset = off[(j + i) / 2];
+               if (off[j - 1] - offset < offset - off[i])
+                       i++;    /* reject low end */
+               else
+                       j--;    /* reject high end */
+       }
+
+       /*
+        * Determine the offset and jitter.
+        */
+       pp->offset = 0;
+       pp->jitter = 0;
+       for (k = i; k < j; k++) {
+               pp->offset += off[k];
+               if (k > i)
+                       pp->jitter += SQUARE(off[k] - off[k - 1]);
+       }
+       pp->offset /= m;
+       pp->jitter = max(SQRT(pp->jitter / m), LOGTOD(sys_precision));
+#ifdef DEBUG
+       if (debug)
+               printf(
+                   "refclock_sample: n %d offset %.6f disp %.6f jitter %.6f\n",
+                   n, pp->offset, pp->disp, pp->jitter);
+#endif
+       return (n);
+}
+
+
+/*
+ * refclock_receive - simulate the receive and packet procedures
+ *
+ * This routine simulates the NTP receive and packet procedures for a
+ * reference clock. This provides a mechanism in which the ordinary NTP
+ * filter, selection and combining algorithms can be used to suppress
+ * misbehaving radios and to mitigate between them when more than one is
+ * available for backup.
+ */
+void
+refclock_receive(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+
+#ifdef DEBUG
+       if (debug)
+               printf("refclock_receive: at %lu %s\n",
+                   current_time, stoa(&peer->srcadr));
+#endif
+
+       /*
+        * Do a little sanity dance and update the peer structure. Groom
+        * the median filter samples and give the data to the clock
+        * filter.
+        */
+       pp = peer->procptr;
+       peer->leap = pp->leap;
+       if (peer->leap == LEAP_NOTINSYNC)
+               return;
+
+       peer->received++;
+       peer->timereceived = current_time;
+       if (!peer->reach) {
+               report_event(EVNT_REACH, peer);
+               peer->timereachable = current_time;
+       }
+       peer->reach |= 1;
+       peer->reftime = pp->lastref;
+       peer->org = pp->lastrec;
+       peer->rootdispersion = pp->disp;
+       get_systime(&peer->rec);
+       if (!refclock_sample(pp))
+               return;
+
+       clock_filter(peer, pp->offset, 0., pp->jitter);
+       record_peer_stats(&peer->srcadr, ctlpeerstatus(peer),
+           peer->offset, peer->delay, clock_phi * (current_time -
+           peer->epoch), peer->jitter);
+       if (cal_enable && last_offset < MINDISPERSE) {
+#ifdef KERNEL_PLL
+               if (peer != sys_peer || pll_status & STA_PPSTIME)
+#else
+               if (peer != sys_peer)
+#endif /* KERNEL_PLL */
+                       pp->fudgetime1 -= pp->offset * FUDGEFAC;
+               else
+                       pp->fudgetime1 -= pp->fudgetime1 * FUDGEFAC;
+       }
+}
+
+
+/*
+ * refclock_gtlin - groom next input line and extract timestamp
+ *
+ * This routine processes the timecode received from the clock and
+ * strips the parity bit and control characters. It returns the number
+ * of characters in the line followed by a NULL character ('\0'), which
+ * is not included in the count. In case of an empty line, the previous
+ * line is preserved.
+ */
+int
+refclock_gtlin(
+       struct recvbuf *rbufp,  /* receive buffer pointer */
+       char    *lineptr,       /* current line pointer */
+       int     bmax,           /* remaining characters in line */
+       l_fp    *tsptr          /* pointer to timestamp returned */
+       )
+{
+       char    s[BMAX];
+       char    *dpt, *dpend, *dp;
+
+       dpt = s;
+       dpend = s + refclock_gtraw(rbufp, s, BMAX - 1, tsptr);
+       if (dpend - dpt > bmax - 1)
+               dpend = dpt + bmax - 1;
+       for (dp = lineptr; dpt < dpend; dpt++) {
+               char    c;
+
+               c = *dpt & 0x7f;
+               if (c >= 0x20 && c < 0x7f)
+                       *dp++ = c;
+       }
+       if (dp == lineptr)
+               return (0);
+
+       *dp = '\0';
+       return (dp - lineptr);
+}
+
+
+/*
+ * refclock_gtraw - get next line/chunk of data
+ *
+ * This routine returns the raw data received from the clock in both
+ * canonical or raw modes. The terminal interface routines map CR to LF.
+ * In canonical mode this results in two lines, one containing data
+ * followed by LF and another containing only LF. In raw mode the
+ * interface routines can deliver arbitraty chunks of data from one
+ * character to a maximum specified by the calling routine. In either
+ * mode the routine returns the number of characters in the line
+ * followed by a NULL character ('\0'), which is not included in the
+ * count.
+ *
+ * If a timestamp is present in the timecode, as produced by the tty_clk
+ * STREAMS module, it returns that as the timestamp; otherwise, it
+ * returns the buffer timestamp.
+ */
+int
+refclock_gtraw(
+       struct recvbuf *rbufp,  /* receive buffer pointer */
+       char    *lineptr,       /* current line pointer */
+       int     bmax,           /* remaining characters in line */
+       l_fp    *tsptr          /* pointer to timestamp returned */
+       )
+{
+       char    *dpt, *dpend, *dp;
+       l_fp    trtmp, tstmp;
+       int     i;
+
+       /*
+        * Check for the presence of a timestamp left by the tty_clock
+        * module and, if present, use that instead of the buffer
+        * timestamp captured by the I/O routines. We recognize a
+        * timestamp by noting its value is earlier than the buffer
+        * timestamp, but not more than one second earlier.
+        */
+       dpt = (char *)rbufp->recv_buffer;
+       dpend = dpt + rbufp->recv_length;
+       trtmp = rbufp->recv_time;
+       if (dpend >= dpt + 8) {
+               if (buftvtots(dpend - 8, &tstmp)) {
+                       L_SUB(&trtmp, &tstmp);
+                       if (trtmp.l_ui == 0) {
+#ifdef DEBUG
+                               if (debug > 1) {
+                                       printf(
+                                           "refclock_gtlin: fd %d ldisc %s",
+                                           rbufp->fd, lfptoa(&trtmp,
+                                           6));
+                                       get_systime(&trtmp);
+                                       L_SUB(&trtmp, &tstmp);
+                                       printf(" sigio %s\n",
+                                           lfptoa(&trtmp, 6));
+                               }
+#endif
+                               dpend -= 8;
+                               trtmp = tstmp;
+                       } else
+                               trtmp = rbufp->recv_time;
+               }
+       }
+
+       /*
+        * Copy the raw buffer to the user string. The string is padded
+        * with a NULL, which is not included in the character count.
+        */
+       if (dpend - dpt > bmax - 1)
+               dpend = dpt + bmax - 1;
+       for (dp = lineptr; dpt < dpend; dpt++)
+               *dp++ = *dpt;
+       *dp = '\0';
+       i = dp - lineptr;
+#ifdef DEBUG
+       if (debug > 1)
+               printf("refclock_gtraw: fd %d time %s timecode %d %s\n",
+                   rbufp->fd, ulfptoa(&trtmp, 6), i, lineptr);
+#endif
+       *tsptr = trtmp;
+       return (i);
+}
+
+
+/*
+ * The following code does not apply to WINNT & VMS ...
+ */
+#if !defined SYS_VXWORKS && !defined SYS_WINNT
+#if defined(HAVE_TERMIOS) || defined(HAVE_SYSV_TTYS) || defined(HAVE_BSD_TTYS)
+
+/*
+ * refclock_open - open serial port for reference clock
+ *
+ * This routine opens a serial port for I/O and sets default options. It
+ * returns the file descriptor if success and zero if failure.
+ */
+int
+refclock_open(
+       char    *dev,           /* device name pointer */
+       u_int   speed,          /* serial port speed (code) */
+       u_int   lflags          /* line discipline flags */
+       )
+{
+       int     fd;
+       int     omode;
+
+       /*
+        * Open serial port and set default options
+        */
+       omode = O_RDWR;
+#ifdef O_NONBLOCK
+       omode |= O_NONBLOCK;
+#endif
+#ifdef O_NOCTTY
+       omode |= O_NOCTTY;
+#endif
+
+       fd = open(dev, omode, 0777);
+       if (fd < 0) {
+               msyslog(LOG_ERR, "refclock_open %s: %m", dev);
+               return (0);
+       }
+       if (!refclock_setup(fd, speed, lflags)) {
+               close(fd);
+               return (0);
+       }
+       if (!refclock_ioctl(fd, lflags)) {
+               close(fd);
+               return (0);
+       }
+       return (fd);
+}
+
+/*
+ * refclock_setup - initialize terminal interface structure
+ */
+int
+refclock_setup(
+       int     fd,             /* file descriptor */
+       u_int   speed,          /* serial port speed (code) */
+       u_int   lflags          /* line discipline flags */
+       )
+{
+       int     i;
+       TTY     ttyb, *ttyp;
+#ifdef PPS
+       fdpps = fd;             /* ppsclock legacy */
+#endif /* PPS */
+
+       /*
+        * By default, the serial line port is initialized in canonical
+        * (line-oriented) mode at specified line speed, 8 bits and no
+        * parity. LF ends the line and CR is mapped to LF. The break,
+        * erase and kill functions are disabled. There is a different
+        * section for each terminal interface, as selected at compile
+        * time. The flag bits can be used to set raw mode and echo.
+        */
+       ttyp = &ttyb;
+#ifdef HAVE_TERMIOS
+
+       /*
+        * POSIX serial line parameters (termios interface)
+        */
+       if (tcgetattr(fd, ttyp) < 0) {
+               msyslog(LOG_ERR,
+                       "refclock_setup fd %d tcgetattr: %m", fd);
+               return (0);
+       }
+
+       /*
+        * Set canonical mode and local connection; set specified speed,
+        * 8 bits and no parity; map CR to NL; ignore break.
+        */
+       if (speed) {
+               u_int   ltemp = 0;
+
+               ttyp->c_iflag = IGNBRK | IGNPAR | ICRNL;
+               ttyp->c_oflag = 0;
+               ttyp->c_cflag = CS8 | CLOCAL | CREAD;
+               if (lflags & LDISC_7O1) {
+                       /* HP Z3801A needs 7-bit, odd parity */
+                       ttyp->c_cflag = CS7 | PARENB | PARODD | CLOCAL | CREAD;
+               }
+               cfsetispeed(&ttyb, speed);
+               cfsetospeed(&ttyb, speed);
+               for (i = 0; i < NCCS; ++i)
+                       ttyp->c_cc[i] = '\0';
+
+#if defined(TIOCMGET) && !defined(SCO5_CLOCK)
+
+               /*
+                * If we have modem control, check to see if modem leads
+                * are active; if so, set remote connection. This is
+                * necessary for the kernel pps mods to work.
+                */
+               if (ioctl(fd, TIOCMGET, (char *)&ltemp) < 0)
+                       msyslog(LOG_ERR,
+                           "refclock_setup fd %d TIOCMGET: %m", fd);
+#ifdef DEBUG
+               if (debug)
+                       printf("refclock_setup fd %d modem status: 0x%x\n",
+                           fd, ltemp);
+#endif
+               if (ltemp & TIOCM_DSR && lflags & LDISC_REMOTE)
+                       ttyp->c_cflag &= ~CLOCAL;
+#endif /* TIOCMGET */
+       }
+
+       /*
+        * Set raw and echo modes. These can be changed on-fly.
+        */
+       ttyp->c_lflag = ICANON;
+       if (lflags & LDISC_RAW) {
+               ttyp->c_lflag = 0;
+               ttyp->c_iflag = 0;
+               ttyp->c_cc[VMIN] = 1;
+       }
+       if (lflags & LDISC_ECHO)
+               ttyp->c_lflag |= ECHO;
+       if (tcsetattr(fd, TCSANOW, ttyp) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_setup fd %d TCSANOW: %m", fd);
+               return (0);
+       }
+#endif /* HAVE_TERMIOS */
+
+#ifdef HAVE_SYSV_TTYS
+
+       /*
+        * System V serial line parameters (termio interface)
+        *
+        */
+       if (ioctl(fd, TCGETA, ttyp) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_setup fd %d TCGETA: %m", fd);
+               return (0);
+       }
+
+       /*
+        * Set canonical mode and local connection; set specified speed,
+        * 8 bits and no parity; map CR to NL; ignore break.
+        */
+       if (speed) {
+               u_int   ltemp = 0;
+
+               ttyp->c_iflag = IGNBRK | IGNPAR | ICRNL;
+               ttyp->c_oflag = 0;
+               ttyp->c_cflag = speed | CS8 | CLOCAL | CREAD;
+               for (i = 0; i < NCCS; ++i)
+                       ttyp->c_cc[i] = '\0';
+
+#if defined(TIOCMGET) && !defined(SCO5_CLOCK)
+
+               /*
+                * If we have modem control, check to see if modem leads
+                * are active; if so, set remote connection. This is
+                * necessary for the kernel pps mods to work.
+                */
+               if (ioctl(fd, TIOCMGET, (char *)&ltemp) < 0)
+                       msyslog(LOG_ERR,
+                           "refclock_setup fd %d TIOCMGET: %m", fd);
+#ifdef DEBUG
+               if (debug)
+                       printf("refclock_setup fd %d modem status: %x\n",
+                           fd, ltemp);
+#endif
+               if (ltemp & TIOCM_DSR)
+                       ttyp->c_cflag &= ~CLOCAL;
+#endif /* TIOCMGET */
+       }
+
+       /*
+        * Set raw and echo modes. These can be changed on-fly.
+        */
+       ttyp->c_lflag = ICANON;
+       if (lflags & LDISC_RAW) {
+               ttyp->c_lflag = 0;
+               ttyp->c_iflag = 0;
+               ttyp->c_cc[VMIN] = 1;
+       }
+       if (ioctl(fd, TCSETA, ttyp) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_setup fd %d TCSETA: %m", fd);
+               return (0);
+       }
+#endif /* HAVE_SYSV_TTYS */
+
+#ifdef HAVE_BSD_TTYS
+
+       /*
+        * 4.3bsd serial line parameters (sgttyb interface)
+        */
+       if (ioctl(fd, TIOCGETP, (char *)ttyp) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_setup fd %d TIOCGETP: %m", fd);
+               return (0);
+       }
+       if (speed)
+               ttyp->sg_ispeed = ttyp->sg_ospeed = speed;
+       ttyp->sg_flags = EVENP | ODDP | CRMOD;
+       if (ioctl(fd, TIOCSETP, (char *)ttyp) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_setup TIOCSETP: %m");
+               return (0);
+       }
+#endif /* HAVE_BSD_TTYS */
+       return(1);
+}
+#endif /* HAVE_TERMIOS || HAVE_SYSV_TTYS || HAVE_BSD_TTYS */
+#endif /* SYS_VXWORKS SYS_WINNT */
+
+
+/*
+ * refclock_ioctl - set serial port control functions
+ *
+ * This routine attempts to hide the internal, system-specific details
+ * of serial ports. It can handle POSIX (termios), SYSV (termio) and BSD
+ * (sgtty) interfaces with varying degrees of success. The routine sets
+ * up optional features such as tty_clk. The routine returns 1 if
+ * success and 0 if failure.
+ */
+int
+refclock_ioctl(
+       int     fd,             /* file descriptor */
+       u_int   lflags          /* line discipline flags */
+       )
+{
+       /*
+        * simply return 1 if no UNIX line discipline is supported
+        */
+#if !defined SYS_VXWORKS && !defined SYS_WINNT
+#if defined(HAVE_TERMIOS) || defined(HAVE_SYSV_TTYS) || defined(HAVE_BSD_TTYS)
+
+#ifdef DEBUG
+       if (debug)
+               printf("refclock_ioctl: fd %d flags 0x%x\n", fd,
+                   lflags);
+#endif
+#ifdef TTYCLK
+
+       /*
+        * The TTYCLK option provides timestamping at the driver level.
+        * It requires the tty_clk streams module and System V STREAMS
+        * support. If not available, don't complain.
+        */
+       if (lflags & (LDISC_CLK | LDISC_CLKPPS | LDISC_ACTS)) {
+               int rval = 0;
+
+               if (ioctl(fd, I_PUSH, "clk") < 0) {
+                       msyslog(LOG_NOTICE,
+                           "refclock_ioctl fd %d I_PUSH: %m", fd);
+                       return (0);
+#ifdef CLK_SETSTR
+               } else {
+                       char *str;
+
+                       if (lflags & LDISC_CLKPPS)
+                               str = "\377";
+                       else if (lflags & LDISC_ACTS)
+                               str = "*";
+                       else
+                               str = "\n";
+                       if (ioctl(fd, CLK_SETSTR, str) < 0) {
+                               msyslog(LOG_ERR,
+                                   "refclock_ioctl fd %d CLK_SETSTR: %m", fd);
+                               return (0);
+                       }
+#endif /*CLK_SETSTR */
+               }
+       }
+#endif /* TTYCLK */
+#endif /* HAVE_TERMIOS || HAVE_SYSV_TTYS || HAVE_BSD_TTYS */
+#endif /* SYS_VXWORKS SYS_WINNT */
+       return (1);
+}
+
+
+/*
+ * refclock_control - set and/or return clock values
+ *
+ * This routine is used mainly for debugging. It returns designated
+ * values from the interface structure that can be displayed using
+ * ntpdc and the clockstat command. It can also be used to initialize
+ * configuration variables, such as fudgetimes, fudgevalues, reference
+ * ID and stratum.
+ */
+void
+refclock_control(
+       struct sockaddr_storage *srcadr,
+       struct refclockstat *in,
+       struct refclockstat *out
+       )
+{
+       struct peer *peer;
+       struct refclockproc *pp;
+       u_char clktype;
+       int unit;
+
+       /*
+        * Check for valid address and running peer
+        */
+       if (srcadr->ss_family != AF_INET)
+               return;
+
+       if (!ISREFCLOCKADR(srcadr))
+               return;
+
+       clktype = (u_char)REFCLOCKTYPE(srcadr);
+       unit = REFCLOCKUNIT(srcadr);
+       if (clktype >= num_refclock_conf || unit >= MAXUNIT)
+               return;
+
+       peer = typeunit[clktype][unit];
+       if (peer == NULL)
+               return;
+
+       if (peer->procptr == NULL)
+               return;
+
+       pp = peer->procptr;
+
+       /*
+        * Initialize requested data
+        */
+       if (in != 0) {
+               if (in->haveflags & CLK_HAVETIME1)
+                       pp->fudgetime1 = in->fudgetime1;
+               if (in->haveflags & CLK_HAVETIME2)
+                       pp->fudgetime2 = in->fudgetime2;
+               if (in->haveflags & CLK_HAVEVAL1)
+                       peer->stratum = pp->stratum = (u_char)in->fudgeval1;
+               if (in->haveflags & CLK_HAVEVAL2)
+                       peer->refid = pp->refid = in->fudgeval2;
+               if (in->haveflags & CLK_HAVEFLAG1) {
+                       pp->sloppyclockflag &= ~CLK_FLAG1;
+                       pp->sloppyclockflag |= in->flags & CLK_FLAG1;
+               }
+               if (in->haveflags & CLK_HAVEFLAG2) {
+                       pp->sloppyclockflag &= ~CLK_FLAG2;
+                       pp->sloppyclockflag |= in->flags & CLK_FLAG2;
+               }
+               if (in->haveflags & CLK_HAVEFLAG3) {
+                       pp->sloppyclockflag &= ~CLK_FLAG3;
+                       pp->sloppyclockflag |= in->flags & CLK_FLAG3;
+               }
+               if (in->haveflags & CLK_HAVEFLAG4) {
+                       pp->sloppyclockflag &= ~CLK_FLAG4;
+                       pp->sloppyclockflag |= in->flags & CLK_FLAG4;
+               }
+       }
+
+       /*
+        * Readback requested data
+        */
+       if (out != 0) {
+               out->haveflags = CLK_HAVETIME1 | CLK_HAVEVAL1 |
+                       CLK_HAVEVAL2 | CLK_HAVEFLAG4;
+               out->fudgetime1 = pp->fudgetime1;
+               out->fudgetime2 = pp->fudgetime2;
+               out->fudgeval1 = pp->stratum;
+               out->fudgeval2 = pp->refid;
+               out->flags = (u_char) pp->sloppyclockflag;
+
+               out->timereset = current_time - pp->timestarted;
+               out->polls = pp->polls;
+               out->noresponse = pp->noreply;
+               out->badformat = pp->badformat;
+               out->baddata = pp->baddata;
+
+               out->lastevent = pp->lastevent;
+               out->currentstatus = pp->currentstatus;
+               out->type = pp->type;
+               out->clockdesc = pp->clockdesc;
+               out->lencode = pp->lencode;
+               out->p_lastcode = pp->a_lastcode;
+       }
+
+       /*
+        * Give the stuff to the clock
+        */
+       if (refclock_conf[clktype]->clock_control != noentry)
+               (refclock_conf[clktype]->clock_control)(unit, in, out, peer);
+}
+
+
+/*
+ * refclock_buginfo - return debugging info
+ *
+ * This routine is used mainly for debugging. It returns designated
+ * values from the interface structure that can be displayed using
+ * ntpdc and the clkbug command.
+ */
+void
+refclock_buginfo(
+       struct sockaddr_storage *srcadr, /* clock address */
+       struct refclockbug *bug /* output structure */
+       )
+{
+       struct peer *peer;
+       struct refclockproc *pp;
+       u_char clktype;
+       int unit;
+       int i;
+
+       /*
+        * Check for valid address and peer structure
+        */
+       if (srcadr->ss_family != AF_INET)
+               return;
+
+       if (!ISREFCLOCKADR(srcadr))
+               return;
+
+       clktype = (u_char) REFCLOCKTYPE(srcadr);
+       unit = REFCLOCKUNIT(srcadr);
+       if (clktype >= num_refclock_conf || unit >= MAXUNIT)
+               return;
+
+       peer = typeunit[clktype][unit];
+       if (peer == NULL)
+               return;
+
+       pp = peer->procptr;
+
+       /*
+        * Copy structure values
+        */
+       bug->nvalues = 8;
+       bug->svalues = 0x0000003f;
+       bug->values[0] = pp->year;
+       bug->values[1] = pp->day;
+       bug->values[2] = pp->hour;
+       bug->values[3] = pp->minute;
+       bug->values[4] = pp->second;
+       bug->values[5] = pp->nsec;
+       bug->values[6] = pp->yearstart;
+       bug->values[7] = pp->coderecv;
+       bug->stimes = 0xfffffffc;
+       bug->times[0] = pp->lastref;
+       bug->times[1] = pp->lastrec;
+       for (i = 2; i < (int)bug->ntimes; i++)
+               DTOLFP(pp->filter[i - 2], &bug->times[i]);
+
+       /*
+        * Give the stuff to the clock
+        */
+       if (refclock_conf[clktype]->clock_buginfo != noentry)
+               (refclock_conf[clktype]->clock_buginfo)(unit, bug, peer);
+}
+
+#endif /* REFCLOCK */
diff --git a/ntpd/ntp_request.c b/ntpd/ntp_request.c
new file mode 100644 (file)
index 0000000..f5eed44
--- /dev/null
@@ -0,0 +1,2913 @@
+/*
+ * ntp_request.c - respond to information requests
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_request.h"
+#include "ntp_control.h"
+#include "ntp_refclock.h"
+#include "ntp_if.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <stddef.h>
+#include <signal.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+
+#include "recvbuff.h"
+
+#ifdef KERNEL_PLL
+#include "ntp_syscall.h"
+#endif /* KERNEL_PLL */
+
+/*
+ * Structure to hold request procedure information
+ */
+#define        NOAUTH  0
+#define        AUTH    1
+
+#define        NO_REQUEST      (-1)
+/*
+ * Because we now have v6 addresses in the messages, we need to compensate
+ * for the larger size.  Therefore, we introduce the alternate size to 
+ * keep us friendly with older implementations.  A little ugly.
+ */
+static int client_v6_capable = 0;   /* the client can handle longer messages */
+
+#define v6sizeof(type) (client_v6_capable ? sizeof(type) : v4sizeof(type))
+
+struct req_proc {
+       short request_code;     /* defined request code */
+       short needs_auth;       /* true when authentication needed */
+       short sizeofitem;       /* size of request data item (older size)*/
+       short v6_sizeofitem;    /* size of request data item (new size)*/
+       void (*handler) P((struct sockaddr_storage *, struct interface *,
+                          struct req_pkt *));  /* routine to handle request */
+};
+
+/*
+ * Universal request codes
+ */
+static struct req_proc univ_codes[] = {
+       { NO_REQUEST,           NOAUTH,  0,     0 }
+};
+
+static void    req_ack P((struct sockaddr_storage *, struct interface *, struct req_pkt *, int));
+static char *  prepare_pkt     P((struct sockaddr_storage *, struct interface *, struct req_pkt *, u_int));
+static char *  more_pkt        P((void));
+static void    flush_pkt       P((void));
+static void    peer_list       P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    peer_list_sum   P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    peer_info       P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    peer_stats      P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    sys_info        P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    sys_stats       P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    mem_stats       P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    io_stats        P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    timer_stats     P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    loop_info       P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    do_conf         P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    do_unconf       P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    set_sys_flag    P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    clr_sys_flag    P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    setclr_flags    P((struct sockaddr_storage *, struct interface *, struct req_pkt *, u_long));
+static void    list_restrict   P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    do_resaddflags  P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    do_ressubflags  P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    do_unrestrict   P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    do_restrict     P((struct sockaddr_storage *, struct interface *, struct req_pkt *, int));
+static void    mon_getlist_0   P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    mon_getlist_1   P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    reset_stats     P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    reset_peer      P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    do_key_reread   P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    trust_key       P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    untrust_key     P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    do_trustkey     P((struct sockaddr_storage *, struct interface *, struct req_pkt *, u_long));
+static void    get_auth_info   P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    reset_auth_stats P((void));
+static void    req_get_traps   P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    req_set_trap    P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    req_clr_trap    P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    do_setclr_trap  P((struct sockaddr_storage *, struct interface *, struct req_pkt *, int));
+static void    set_request_keyid P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    set_control_keyid P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    get_ctl_stats   P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    get_if_stats    P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    do_if_reload    P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+#ifdef KERNEL_PLL
+static void    get_kernel_info P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+#endif /* KERNEL_PLL */
+#ifdef REFCLOCK
+static void    get_clock_info P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+static void    set_clock_fudge P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+#endif /* REFCLOCK */
+#ifdef REFCLOCK
+static void    get_clkbug_info P((struct sockaddr_storage *, struct interface *, struct req_pkt *));
+#endif /* REFCLOCK */
+
+/*
+ * ntpd request codes
+ */
+static struct req_proc ntp_codes[] = {
+       { REQ_PEER_LIST,        NOAUTH, 0, 0,   peer_list },
+       { REQ_PEER_LIST_SUM,    NOAUTH, 0, 0,   peer_list_sum },
+       { REQ_PEER_INFO,    NOAUTH, v4sizeof(struct info_peer_list),
+                               sizeof(struct info_peer_list), peer_info},
+       { REQ_PEER_STATS,   NOAUTH, v4sizeof(struct info_peer_list),
+                               sizeof(struct info_peer_list), peer_stats},
+       { REQ_SYS_INFO,         NOAUTH, 0, 0,   sys_info },
+       { REQ_SYS_STATS,        NOAUTH, 0, 0,   sys_stats },
+       { REQ_IO_STATS,         NOAUTH, 0, 0,   io_stats },
+       { REQ_MEM_STATS,        NOAUTH, 0, 0,   mem_stats },
+       { REQ_LOOP_INFO,        NOAUTH, 0, 0,   loop_info },
+       { REQ_TIMER_STATS,      NOAUTH, 0, 0,   timer_stats },
+       { REQ_CONFIG,       AUTH, v4sizeof(struct conf_peer),
+                               sizeof(struct conf_peer), do_conf },
+       { REQ_UNCONFIG,     AUTH, v4sizeof(struct conf_unpeer),
+                               sizeof(struct conf_unpeer), do_unconf },
+       { REQ_SET_SYS_FLAG, AUTH, sizeof(struct conf_sys_flags),
+                               sizeof(struct conf_sys_flags), set_sys_flag },
+       { REQ_CLR_SYS_FLAG, AUTH, sizeof(struct conf_sys_flags), 
+                               sizeof(struct conf_sys_flags),  clr_sys_flag },
+       { REQ_GET_RESTRICT,     NOAUTH, 0, 0,   list_restrict },
+       { REQ_RESADDFLAGS, AUTH, v4sizeof(struct conf_restrict),
+                               sizeof(struct conf_restrict), do_resaddflags },
+       { REQ_RESSUBFLAGS, AUTH, v4sizeof(struct conf_restrict),
+                               sizeof(struct conf_restrict), do_ressubflags },
+       { REQ_UNRESTRICT, AUTH, v4sizeof(struct conf_restrict),
+                               sizeof(struct conf_restrict), do_unrestrict },
+       { REQ_MON_GETLIST,      NOAUTH, 0, 0,   mon_getlist_0 },
+       { REQ_MON_GETLIST_1,    NOAUTH, 0, 0,   mon_getlist_1 },
+       { REQ_RESET_STATS, AUTH, sizeof(struct reset_flags), 0, reset_stats },
+       { REQ_RESET_PEER,  AUTH, v4sizeof(struct conf_unpeer),
+                               sizeof(struct conf_unpeer), reset_peer },
+       { REQ_REREAD_KEYS,      AUTH,   0, 0,   do_key_reread },
+       { REQ_TRUSTKEY,   AUTH, sizeof(u_long), sizeof(u_long), trust_key },
+       { REQ_UNTRUSTKEY, AUTH, sizeof(u_long), sizeof(u_long), untrust_key },
+       { REQ_AUTHINFO,         NOAUTH, 0, 0,   get_auth_info },
+       { REQ_TRAPS,            NOAUTH, 0, 0,   req_get_traps },
+       { REQ_ADD_TRAP, AUTH, v4sizeof(struct conf_trap),
+                               sizeof(struct conf_trap), req_set_trap },
+       { REQ_CLR_TRAP, AUTH, v4sizeof(struct conf_trap),
+                               sizeof(struct conf_trap), req_clr_trap },
+       { REQ_REQUEST_KEY, AUTH, sizeof(u_long), sizeof(u_long), 
+                               set_request_keyid },
+       { REQ_CONTROL_KEY, AUTH, sizeof(u_long), sizeof(u_long), 
+                               set_control_keyid },
+       { REQ_GET_CTLSTATS,     NOAUTH, 0, 0,   get_ctl_stats },
+#ifdef KERNEL_PLL
+       { REQ_GET_KERNEL,       NOAUTH, 0, 0,   get_kernel_info },
+#endif
+#ifdef REFCLOCK
+       { REQ_GET_CLOCKINFO, NOAUTH, sizeof(u_int32), sizeof(u_int32), 
+                               get_clock_info },
+       { REQ_SET_CLKFUDGE, AUTH, sizeof(struct conf_fudge), 
+                               sizeof(struct conf_fudge), set_clock_fudge },
+       { REQ_GET_CLKBUGINFO, NOAUTH, sizeof(u_int32), sizeof(u_int32),
+                               get_clkbug_info },
+#endif
+       { REQ_IF_STATS,         AUTH, 0, 0,     get_if_stats },
+       { REQ_IF_RELOAD,        AUTH, 0, 0,     do_if_reload },
+
+       { NO_REQUEST,           NOAUTH, 0, 0,   0 }
+};
+
+
+/*
+ * Authentication keyid used to authenticate requests.  Zero means we
+ * don't allow writing anything.
+ */
+keyid_t info_auth_keyid;
+
+/*
+ * Statistic counters to keep track of requests and responses.
+ */
+u_long numrequests;            /* number of requests we've received */
+u_long numresppkts;            /* number of resp packets sent with data */
+
+u_long errorcounter[INFO_ERR_AUTH+1];  /* lazy way to count errors, indexed */
+/* by the error code */
+
+/*
+ * A hack.  To keep the authentication module clear of ntp-ism's, we
+ * include a time reset variable for its stats here.
+ */
+static u_long auth_timereset;
+
+/*
+ * Response packet used by these routines.  Also some state information
+ * so that we can handle packet formatting within a common set of
+ * subroutines.  Note we try to enter data in place whenever possible,
+ * but the need to set the more bit correctly means we occasionally
+ * use the extra buffer and copy.
+ */
+static struct resp_pkt rpkt;
+static int reqver;
+static int seqno;
+static int nitems;
+static int itemsize;
+static int databytes;
+static char exbuf[RESP_DATA_SIZE];
+static int usingexbuf;
+static struct sockaddr_storage *toaddr;
+static struct interface *frominter;
+
+/*
+ * init_request - initialize request data
+ */
+void
+init_request (void)
+{
+       int i;
+
+       numrequests = 0;
+       numresppkts = 0;
+       auth_timereset = 0;
+       info_auth_keyid = 0;    /* by default, can't do this */
+
+       for (i = 0; i < sizeof(errorcounter)/sizeof(errorcounter[0]); i++)
+           errorcounter[i] = 0;
+}
+
+
+/*
+ * req_ack - acknowledge request with no data
+ */
+static void
+req_ack(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt,
+       int errcode
+       )
+{
+       /*
+        * fill in the fields
+        */
+       rpkt.rm_vn_mode = RM_VN_MODE(RESP_BIT, 0, reqver);
+       rpkt.auth_seq = AUTH_SEQ(0, 0);
+       rpkt.implementation = inpkt->implementation;
+       rpkt.request = inpkt->request;
+       rpkt.err_nitems = ERR_NITEMS(errcode, 0);
+       rpkt.mbz_itemsize = MBZ_ITEMSIZE(0);
+
+       /*
+        * send packet and bump counters
+        */
+       sendpkt(srcadr, inter, -1, (struct pkt *)&rpkt, RESP_HEADER_SIZE);
+       errorcounter[errcode]++;
+}
+
+
+/*
+ * prepare_pkt - prepare response packet for transmission, return pointer
+ *              to storage for data item.
+ */
+static char *
+prepare_pkt(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *pkt,
+       u_int structsize
+       )
+{
+#ifdef DEBUG
+       if (debug > 3)
+           printf("request: preparing pkt\n");
+#endif
+
+       /*
+        * Fill in the implementation, request and itemsize fields
+        * since these won't change.
+        */
+       rpkt.implementation = pkt->implementation;
+       rpkt.request = pkt->request;
+       rpkt.mbz_itemsize = MBZ_ITEMSIZE(structsize);
+
+       /*
+        * Compute the static data needed to carry on.
+        */
+       toaddr = srcadr;
+       frominter = inter;
+       seqno = 0;
+       nitems = 0;
+       itemsize = structsize;
+       databytes = 0;
+       usingexbuf = 0;
+
+       /*
+        * return the beginning of the packet buffer.
+        */
+       return &rpkt.data[0];
+}
+
+
+/*
+ * more_pkt - return a data pointer for a new item.
+ */
+static char *
+more_pkt(void)
+{
+       /*
+        * If we were using the extra buffer, send the packet.
+        */
+       if (usingexbuf) {
+#ifdef DEBUG
+               if (debug > 2)
+                   printf("request: sending pkt\n");
+#endif
+               rpkt.rm_vn_mode = RM_VN_MODE(RESP_BIT, MORE_BIT, reqver);
+               rpkt.auth_seq = AUTH_SEQ(0, seqno);
+               rpkt.err_nitems = htons((u_short)nitems);
+               sendpkt(toaddr, frominter, -1, (struct pkt *)&rpkt,
+                       RESP_HEADER_SIZE+databytes);
+               numresppkts++;
+
+               /*
+                * Copy data out of exbuf into the packet.
+                */
+               memmove(&rpkt.data[0], exbuf, (unsigned)itemsize);
+               seqno++;
+               databytes = 0;
+               nitems = 0;
+               usingexbuf = 0;
+       }
+
+       databytes += itemsize;
+       nitems++;
+       if (databytes + itemsize <= RESP_DATA_SIZE) {
+#ifdef DEBUG
+               if (debug > 3)
+                   printf("request: giving him more data\n");
+#endif
+               /*
+                * More room in packet.  Give him the
+                * next address.
+                */
+               return &rpkt.data[databytes];
+       } else {
+               /*
+                * No room in packet.  Give him the extra
+                * buffer unless this was the last in the sequence.
+                */
+#ifdef DEBUG
+               if (debug > 3)
+                   printf("request: into extra buffer\n");
+#endif
+               if (seqno == MAXSEQ)
+                   return (char *)0;
+               else {
+                       usingexbuf = 1;
+                       return exbuf;
+               }
+       }
+}
+
+
+/*
+ * flush_pkt - we're done, return remaining information.
+ */
+static void
+flush_pkt(void)
+{
+#ifdef DEBUG
+       if (debug > 2)
+           printf("request: flushing packet, %d items\n", nitems);
+#endif
+       /*
+        * Must send the last packet.  If nothing in here and nothing
+        * has been sent, send an error saying no data to be found.
+        */
+       if (seqno == 0 && nitems == 0)
+           req_ack(toaddr, frominter, (struct req_pkt *)&rpkt,
+                   INFO_ERR_NODATA);
+       else {
+               rpkt.rm_vn_mode = RM_VN_MODE(RESP_BIT, 0, reqver);
+               rpkt.auth_seq = AUTH_SEQ(0, seqno);
+               rpkt.err_nitems = htons((u_short)nitems);
+               sendpkt(toaddr, frominter, -1, (struct pkt *)&rpkt,
+                       RESP_HEADER_SIZE+databytes);
+               numresppkts++;
+       }
+}
+
+
+
+/*
+ * process_private - process private mode (7) packets
+ */
+void
+process_private(
+       struct recvbuf *rbufp,
+       int mod_okay
+       )
+{
+       static u_long quiet_until;
+       struct req_pkt *inpkt;
+       struct req_pkt_tail *tailinpkt;
+       struct sockaddr_storage *srcadr;
+       struct interface *inter;
+       struct req_proc *proc;
+       int ec;
+       short temp_size;
+
+       /*
+        * Initialize pointers, for convenience
+        */
+       inpkt = (struct req_pkt *)&rbufp->recv_pkt;
+       srcadr = &rbufp->recv_srcadr;
+       inter = rbufp->dstadr;
+
+#ifdef DEBUG
+       if (debug > 2)
+           printf("process_private: impl %d req %d\n",
+                  inpkt->implementation, inpkt->request);
+#endif
+
+       /*
+        * Do some sanity checks on the packet.  Return a format
+        * error if it fails.
+        */
+       ec = 0;
+       if (   (++ec, ISRESPONSE(inpkt->rm_vn_mode))
+           || (++ec, ISMORE(inpkt->rm_vn_mode))
+           || (++ec, INFO_VERSION(inpkt->rm_vn_mode) > NTP_VERSION)
+           || (++ec, INFO_VERSION(inpkt->rm_vn_mode) < NTP_OLDVERSION)
+           || (++ec, INFO_SEQ(inpkt->auth_seq) != 0)
+           || (++ec, INFO_ERR(inpkt->err_nitems) != 0)
+           || (++ec, INFO_MBZ(inpkt->mbz_itemsize) != 0)
+           || (++ec, rbufp->recv_length < REQ_LEN_HDR)
+               ) {
+               NLOG(NLOG_SYSEVENT)
+                       if (current_time >= quiet_until) {
+                               msyslog(LOG_ERR,
+                                       "process_private: drop test %d"
+                                       " failed, pkt from %s",
+                                       ec, stoa(srcadr));
+                               quiet_until = current_time + 60;
+                       }
+               return;
+       }
+
+       reqver = INFO_VERSION(inpkt->rm_vn_mode);
+
+       /*
+        * Get the appropriate procedure list to search.
+        */
+       if (inpkt->implementation == IMPL_UNIV)
+           proc = univ_codes;
+       else if ((inpkt->implementation == IMPL_XNTPD) ||
+                (inpkt->implementation == IMPL_XNTPD_OLD))
+           proc = ntp_codes;
+       else {
+               req_ack(srcadr, inter, inpkt, INFO_ERR_IMPL);
+               return;
+       }
+
+       /*
+        * Search the list for the request codes.  If it isn't one
+        * we know, return an error.
+        */
+       while (proc->request_code != NO_REQUEST) {
+               if (proc->request_code == (short) inpkt->request)
+                   break;
+               proc++;
+       }
+       if (proc->request_code == NO_REQUEST) {
+               req_ack(srcadr, inter, inpkt, INFO_ERR_REQ);
+               return;
+       }
+
+#ifdef DEBUG
+       if (debug > 3)
+           printf("found request in tables\n");
+#endif
+
+       /*
+        * If we need data, check to see if we have some.  If we
+        * don't, check to see that there is none (picky, picky).
+        */     
+
+       /* This part is a bit tricky, we want to be sure that the size
+        * returned is either the old or the new size.  We also can find
+        * out if the client can accept both types of messages this way. 
+        *
+        * Handle the exception of REQ_CONFIG. It can have two data sizes.
+        */
+       temp_size = INFO_ITEMSIZE(inpkt->mbz_itemsize);
+       if ((temp_size != proc->sizeofitem &&
+            temp_size != proc->v6_sizeofitem) &&
+           !(inpkt->implementation == IMPL_XNTPD &&
+             inpkt->request == REQ_CONFIG &&
+             temp_size == sizeof(struct old_conf_peer))) {
+#ifdef DEBUG
+               if (debug > 2)
+                       printf("process_private: wrong item size, received %d, should be %d or %d\n",
+                           temp_size, proc->sizeofitem, proc->v6_sizeofitem);
+#endif
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+       if ((proc->sizeofitem != 0) &&
+           ((temp_size * INFO_NITEMS(inpkt->err_nitems)) >
+           (rbufp->recv_length - REQ_LEN_HDR))) {
+#ifdef DEBUG
+               if (debug > 2)
+                       printf("process_private: not enough data\n");
+#endif
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       switch (inpkt->implementation) {
+       case IMPL_XNTPD:
+               client_v6_capable = 1;
+               break;
+       case IMPL_XNTPD_OLD:
+               client_v6_capable = 0;
+               break;
+       default:
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       /*
+        * If we need to authenticate, do so.  Note that an
+        * authenticatable packet must include a mac field, must
+        * have used key info_auth_keyid and must have included
+        * a time stamp in the appropriate field.  The time stamp
+        * must be within INFO_TS_MAXSKEW of the receive
+        * time stamp.
+        */
+       if (proc->needs_auth && sys_authenticate) {
+               l_fp ftmp;
+               double dtemp;
+       
+               if (rbufp->recv_length < (int)((REQ_LEN_HDR +
+                   (INFO_ITEMSIZE(inpkt->mbz_itemsize) *
+                   INFO_NITEMS(inpkt->err_nitems))
+                   + sizeof(struct req_pkt_tail)))) {
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               }
+               tailinpkt = (struct req_pkt_tail *)((char *)&rbufp->recv_pkt +
+                   rbufp->recv_length - sizeof(struct req_pkt_tail));
+
+               /*
+                * If this guy is restricted from doing this, don't let him
+                * If wrong key was used, or packet doesn't have mac, return.
+                */
+               if (!INFO_IS_AUTH(inpkt->auth_seq) || info_auth_keyid == 0
+                   || ntohl(tailinpkt->keyid) != info_auth_keyid) {
+#ifdef DEBUG
+                       if (debug > 4)
+                           printf("failed auth %d info_auth_keyid %lu pkt keyid %lu\n",
+                                  INFO_IS_AUTH(inpkt->auth_seq),
+                                  (u_long)info_auth_keyid,
+                                  (u_long)ntohl(tailinpkt->keyid));
+                       msyslog(LOG_DEBUG,
+                               "process_private: failed auth %d info_auth_keyid %lu pkt keyid %lu\n",
+                               INFO_IS_AUTH(inpkt->auth_seq),
+                               (u_long)info_auth_keyid,
+                               (u_long)ntohl(tailinpkt->keyid));
+#endif
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_AUTH);
+                       return;
+               }
+               if (rbufp->recv_length > REQ_LEN_MAC) {
+#ifdef DEBUG
+                       if (debug > 4)
+                           printf("bad pkt length %d\n",
+                                  rbufp->recv_length);
+#endif
+                       msyslog(LOG_ERR, "process_private: bad pkt length %d",
+                               rbufp->recv_length);
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+                       return;
+               }
+               if (!mod_okay || !authhavekey(info_auth_keyid)) {
+#ifdef DEBUG
+                       if (debug > 4)
+                           printf("failed auth mod_okay %d\n", mod_okay);
+                       msyslog(LOG_DEBUG,
+                               "process_private: failed auth mod_okay %d\n",
+                               mod_okay);
+#endif
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_AUTH);
+                       return;
+               }
+
+               /*
+                * calculate absolute time difference between xmit time stamp
+                * and receive time stamp.  If too large, too bad.
+                */
+               NTOHL_FP(&tailinpkt->tstamp, &ftmp);
+               L_SUB(&ftmp, &rbufp->recv_time);
+               LFPTOD(&ftmp, dtemp);
+               if (fabs(dtemp) >= INFO_TS_MAXSKEW) {
+                       /*
+                        * He's a loser.  Tell him.
+                        */
+#ifdef DEBUG
+                       if (debug > 4)
+                           printf("xmit/rcv timestamp delta > INFO_TS_MAXSKEW\n");
+#endif
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_AUTH);
+                       return;
+               }
+
+               /*
+                * So far so good.  See if decryption works out okay.
+                */
+               if (!authdecrypt(info_auth_keyid, (u_int32 *)inpkt,
+                   rbufp->recv_length - sizeof(struct req_pkt_tail) +
+                   REQ_LEN_HDR, sizeof(struct req_pkt_tail) - REQ_LEN_HDR)) {
+#ifdef DEBUG
+                       if (debug > 4)
+                           printf("authdecrypt failed\n");
+#endif
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_AUTH);
+                       return;
+               }
+       }
+
+#ifdef DEBUG
+       if (debug > 3)
+           printf("process_private: all okay, into handler\n");
+#endif
+
+       /*
+        * Packet is okay.  Call the handler to send him data.
+        */
+       (proc->handler)(srcadr, inter, inpkt);
+}
+
+
+/*
+ * peer_list - send a list of the peers
+ */
+static void
+peer_list(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_peer_list *ip;
+       register struct peer *pp;
+       register int i;
+       register int skip = 0;
+
+       ip = (struct info_peer_list *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_peer_list));
+       for (i = 0; i < NTP_HASH_SIZE && ip != 0; i++) {
+               pp = peer_hash[i];
+               while (pp != 0 && ip != 0) {
+                       if (pp->srcadr.ss_family == AF_INET6) {
+                               if (client_v6_capable) {
+                                       ip->addr6 = GET_INADDR6(pp->srcadr);
+                                       ip->v6_flag = 1;
+                                       skip = 0;
+                               } else {
+                                       skip = 1;
+                                       break;
+                               }
+                       } else {
+                               ip->addr = GET_INADDR(pp->srcadr);
+                               if (client_v6_capable)
+                                       ip->v6_flag = 0;
+                               skip = 0;
+                       }
+
+                       if(!skip) {
+                               ip->port = NSRCPORT(&pp->srcadr);
+                               ip->hmode = pp->hmode;
+                               ip->flags = 0;
+                               if (pp->flags & FLAG_CONFIG)
+                                   ip->flags |= INFO_FLAG_CONFIG;
+                               if (pp == sys_peer)
+                                   ip->flags |= INFO_FLAG_SYSPEER;
+                               if (pp->status == CTL_PST_SEL_SYNCCAND)
+                                   ip->flags |= INFO_FLAG_SEL_CANDIDATE;
+                               if (pp->status >= CTL_PST_SEL_SYSPEER)
+                                   ip->flags |= INFO_FLAG_SHORTLIST;
+                               ip = (struct info_peer_list *)more_pkt();
+                       }
+                       pp = pp->next; 
+               }
+       }
+       flush_pkt();
+}
+
+
+/*
+ * peer_list_sum - return extended peer list
+ */
+static void
+peer_list_sum(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_peer_summary *ips;
+       register struct peer *pp;
+       register int i;
+       l_fp ltmp;
+       register int skip;
+
+#ifdef DEBUG
+       if (debug > 2)
+           printf("wants peer list summary\n");
+#endif
+       ips = (struct info_peer_summary *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_peer_summary));
+       for (i = 0; i < NTP_HASH_SIZE && ips != 0; i++) {
+               pp = peer_hash[i];
+               while (pp != 0 && ips != 0) {
+#ifdef DEBUG
+                       if (debug > 3)
+                           printf("sum: got one\n");
+#endif
+                       /*
+                        * Be careful here not to return v6 peers when we
+                        * want only v4.
+                        */
+                       if (pp->srcadr.ss_family == AF_INET6) {
+                               if (client_v6_capable) {
+                                       ips->srcadr6 = GET_INADDR6(pp->srcadr);
+                                       ips->v6_flag = 1;
+                                       if (pp->dstadr)
+                                               ips->dstadr6 = GET_INADDR6(pp->dstadr->sin);
+                                       else
+                                               memset(&ips->dstadr6, 0, sizeof(ips->dstadr6));
+                                       skip = 0;
+                               } else {
+                                       skip = 1;
+                                       break;
+                               }
+                       } else {
+                               ips->srcadr = GET_INADDR(pp->srcadr);
+                               if (client_v6_capable)
+                                       ips->v6_flag = 0;
+/* XXX PDM This code is buggy. Need to replace with a straightforward assignment */
+                               
+                               if (pp->dstadr)
+                                       ips->dstadr = (pp->processed) ?
+                                               pp->cast_flags == MDF_BCAST ?
+                                               GET_INADDR(pp->dstadr->bcast):
+                                               pp->cast_flags ?
+                                               GET_INADDR(pp->dstadr->sin) ?
+                                               GET_INADDR(pp->dstadr->sin):
+                                               GET_INADDR(pp->dstadr->bcast):
+                                               1 : GET_INADDR(pp->dstadr->sin);
+                               else
+                                               memset(&ips->dstadr, 0, sizeof(ips->dstadr));
+
+                               skip = 0;
+                       }
+                       
+                       if (!skip){ 
+                               ips->srcport = NSRCPORT(&pp->srcadr);
+                               ips->stratum = pp->stratum;
+                               ips->hpoll = pp->hpoll;
+                               ips->ppoll = pp->ppoll;
+                               ips->reach = pp->reach;
+                               ips->flags = 0;
+                               if (pp == sys_peer)
+                                   ips->flags |= INFO_FLAG_SYSPEER;
+                               if (pp->flags & FLAG_CONFIG)
+                                   ips->flags |= INFO_FLAG_CONFIG;
+                               if (pp->flags & FLAG_REFCLOCK)
+                                   ips->flags |= INFO_FLAG_REFCLOCK;
+                               if (pp->flags & FLAG_AUTHENABLE)
+                                   ips->flags |= INFO_FLAG_AUTHENABLE;
+                               if (pp->flags & FLAG_PREFER)
+                                   ips->flags |= INFO_FLAG_PREFER;
+                               if (pp->flags & FLAG_BURST)
+                                   ips->flags |= INFO_FLAG_BURST;
+                               if (pp->status == CTL_PST_SEL_SYNCCAND)
+                                   ips->flags |= INFO_FLAG_SEL_CANDIDATE;
+                               if (pp->status >= CTL_PST_SEL_SYSPEER)
+                                   ips->flags |= INFO_FLAG_SHORTLIST;
+                               ips->hmode = pp->hmode;
+                               ips->delay = HTONS_FP(DTOFP(pp->delay));
+                               DTOLFP(pp->offset, &ltmp);
+                               HTONL_FP(&ltmp, &ips->offset);
+                               ips->dispersion = HTONS_FP(DTOUFP(SQRT(pp->disp)));
+                       }       
+                       pp = pp->next; 
+                       ips = (struct info_peer_summary *)more_pkt();
+               }
+       }
+       flush_pkt();
+}
+
+
+/*
+ * peer_info - send information for one or more peers
+ */
+static void
+peer_info (
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_peer_list *ipl;
+       register struct peer *pp;
+       register struct info_peer *ip;
+       register int items;
+       register int i, j;
+       struct sockaddr_storage addr;
+       extern struct peer *sys_peer;
+       l_fp ltmp;
+
+       memset((char *)&addr, 0, sizeof addr);
+       items = INFO_NITEMS(inpkt->err_nitems);
+       ipl = (struct info_peer_list *) inpkt->data;
+
+       ip = (struct info_peer *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_peer));
+       while (items-- > 0 && ip != 0) {
+               memset((char *)&addr, 0, sizeof(addr));
+               NSRCPORT(&addr) = ipl->port;
+               if (client_v6_capable && ipl->v6_flag != 0) {
+                       addr.ss_family = AF_INET6;
+                       GET_INADDR6(addr) = ipl->addr6;
+               } else {
+                       addr.ss_family = AF_INET;
+                       GET_INADDR(addr) = ipl->addr;
+               }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               addr.ss_len = SOCKLEN(&addr);
+#endif
+               ipl++;
+               if ((pp = findexistingpeer(&addr, (struct peer *)0, -1)) == 0)
+                   continue;
+               if (pp->srcadr.ss_family == AF_INET6) {
+                       if (pp->dstadr)
+                               ip->dstadr6 = pp->cast_flags == MDF_BCAST ?
+                                       GET_INADDR6(pp->dstadr->bcast) :
+                                       GET_INADDR6(pp->dstadr->sin);
+                       else
+                               memset(&ip->dstadr6, 0, sizeof(ip->dstadr6));
+
+                       ip->srcadr6 = GET_INADDR6(pp->srcadr);
+                       ip->v6_flag = 1;
+               } else {
+/* XXX PDM This code is buggy. Need to replace with a straightforward assignment */
+                       if (pp->dstadr)
+                               ip->dstadr = (pp->processed) ?
+                                       pp->cast_flags == MDF_BCAST ?
+                                       GET_INADDR(pp->dstadr->bcast):
+                                       pp->cast_flags ?
+                                       GET_INADDR(pp->dstadr->sin) ?
+                                       GET_INADDR(pp->dstadr->sin):
+                                       GET_INADDR(pp->dstadr->bcast):
+                                       2 : GET_INADDR(pp->dstadr->sin);
+                       else
+                               memset(&ip->dstadr, 0, sizeof(ip->dstadr));
+
+                       ip->srcadr = GET_INADDR(pp->srcadr);
+                       if (client_v6_capable)
+                               ip->v6_flag = 0;
+               }
+               ip->srcport = NSRCPORT(&pp->srcadr);
+               ip->flags = 0;
+               if (pp == sys_peer)
+                   ip->flags |= INFO_FLAG_SYSPEER;
+               if (pp->flags & FLAG_CONFIG)
+                   ip->flags |= INFO_FLAG_CONFIG;
+               if (pp->flags & FLAG_REFCLOCK)
+                   ip->flags |= INFO_FLAG_REFCLOCK;
+               if (pp->flags & FLAG_AUTHENABLE)
+                   ip->flags |= INFO_FLAG_AUTHENABLE;
+               if (pp->flags & FLAG_PREFER)
+                   ip->flags |= INFO_FLAG_PREFER;
+               if (pp->flags & FLAG_BURST)
+                   ip->flags |= INFO_FLAG_BURST;
+               if (pp->status == CTL_PST_SEL_SYNCCAND)
+                   ip->flags |= INFO_FLAG_SEL_CANDIDATE;
+               if (pp->status >= CTL_PST_SEL_SYSPEER)
+                   ip->flags |= INFO_FLAG_SHORTLIST;
+               ip->leap = pp->leap;
+               ip->hmode = pp->hmode;
+               ip->keyid = pp->keyid;
+               ip->stratum = pp->stratum;
+               ip->ppoll = pp->ppoll;
+               ip->hpoll = pp->hpoll;
+               ip->precision = pp->precision;
+               ip->version = pp->version;
+               ip->reach = pp->reach;
+               ip->unreach = (u_char) pp->unreach;
+               ip->flash = (u_char)pp->flash;
+               ip->flash2 = (u_short) pp->flash;
+               ip->estbdelay = HTONS_FP(DTOFP(pp->estbdelay));
+               ip->ttl = pp->ttl;
+               ip->associd = htons(pp->associd);
+               ip->rootdelay = HTONS_FP(DTOUFP(pp->rootdelay));
+               ip->rootdispersion = HTONS_FP(DTOUFP(pp->rootdispersion));
+               ip->refid = pp->refid;
+               HTONL_FP(&pp->reftime, &ip->reftime);
+               HTONL_FP(&pp->org, &ip->org);
+               HTONL_FP(&pp->rec, &ip->rec);
+               HTONL_FP(&pp->xmt, &ip->xmt);
+               j = pp->filter_nextpt - 1;
+               for (i = 0; i < NTP_SHIFT; i++, j--) {
+                       if (j < 0)
+                           j = NTP_SHIFT-1;
+                       ip->filtdelay[i] = HTONS_FP(DTOFP(pp->filter_delay[j]));
+                       DTOLFP(pp->filter_offset[j], &ltmp);
+                       HTONL_FP(&ltmp, &ip->filtoffset[i]);
+                       ip->order[i] = (u_char)((pp->filter_nextpt+NTP_SHIFT-1)
+                               - pp->filter_order[i]);
+                       if (ip->order[i] >= NTP_SHIFT)
+                           ip->order[i] -= NTP_SHIFT;
+               }
+               DTOLFP(pp->offset, &ltmp);
+               HTONL_FP(&ltmp, &ip->offset);
+               ip->delay = HTONS_FP(DTOFP(pp->delay));
+               ip->dispersion = HTONS_FP(DTOUFP(SQRT(pp->disp)));
+               ip->selectdisp = HTONS_FP(DTOUFP(SQRT(pp->jitter)));
+               ip = (struct info_peer *)more_pkt();
+       }
+       flush_pkt();
+}
+
+
+/*
+ * peer_stats - send statistics for one or more peers
+ */
+static void
+peer_stats (
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_peer_list *ipl;
+       register struct peer *pp;
+       register struct info_peer_stats *ip;
+       register int items;
+       struct sockaddr_storage addr;
+       extern struct peer *sys_peer;
+
+#ifdef DEBUG
+       if (debug)
+            printf("peer_stats: called\n");
+#endif
+       items = INFO_NITEMS(inpkt->err_nitems);
+       ipl = (struct info_peer_list *) inpkt->data;
+       ip = (struct info_peer_stats *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_peer_stats));
+       while (items-- > 0 && ip != 0) {
+               memset((char *)&addr, 0, sizeof(addr));
+               NSRCPORT(&addr) = ipl->port;
+               if (client_v6_capable && ipl->v6_flag) {
+                       addr.ss_family = AF_INET6;
+                       GET_INADDR6(addr) = ipl->addr6;
+               } else {
+                       addr.ss_family = AF_INET;
+                       GET_INADDR(addr) = ipl->addr;
+               }       
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               addr.ss_len = SOCKLEN(&addr);
+#endif
+#ifdef DEBUG
+               if (debug)
+                   printf("peer_stats: looking for %s, %d, %d\n", stoa(&addr),
+                   ipl->port, ((struct sockaddr_in6 *)&addr)->sin6_port);
+#endif
+               ipl = (struct info_peer_list *)((char *)ipl +
+                   INFO_ITEMSIZE(inpkt->mbz_itemsize));
+
+               if ((pp = findexistingpeer(&addr, (struct peer *)0, -1)) == 0)
+                   continue;
+#ifdef DEBUG
+               if (debug)
+                    printf("peer_stats: found %s\n", stoa(&addr));
+#endif
+               if (pp->srcadr.ss_family == AF_INET) {
+                       if (pp->dstadr)
+                               ip->dstadr = (pp->processed) ?
+                                       pp->cast_flags == MDF_BCAST ?
+                                       GET_INADDR(pp->dstadr->bcast):
+                                       pp->cast_flags ?
+                                       GET_INADDR(pp->dstadr->sin) ?
+                                       GET_INADDR(pp->dstadr->sin):
+                                       GET_INADDR(pp->dstadr->bcast):
+                                       3 : 7;
+                       else
+                               memset(&ip->dstadr, 0, sizeof(ip->dstadr));
+                       
+                       ip->srcadr = GET_INADDR(pp->srcadr);
+                       if (client_v6_capable)
+                               ip->v6_flag = 0;
+               } else {
+                       if (pp->dstadr)
+                               ip->dstadr6 = pp->cast_flags == MDF_BCAST ?
+                                       GET_INADDR6(pp->dstadr->bcast):
+                                       GET_INADDR6(pp->dstadr->sin);
+                       else
+                               memset(&ip->dstadr6, 0, sizeof(ip->dstadr6));
+                       
+                       ip->srcadr6 = GET_INADDR6(pp->srcadr);
+                       ip->v6_flag = 1;
+               }       
+               ip->srcport = NSRCPORT(&pp->srcadr);
+               ip->flags = 0;
+               if (pp == sys_peer)
+                   ip->flags |= INFO_FLAG_SYSPEER;
+               if (pp->flags & FLAG_CONFIG)
+                   ip->flags |= INFO_FLAG_CONFIG;
+               if (pp->flags & FLAG_REFCLOCK)
+                   ip->flags |= INFO_FLAG_REFCLOCK;
+               if (pp->flags & FLAG_AUTHENABLE)
+                   ip->flags |= INFO_FLAG_AUTHENABLE;
+               if (pp->flags & FLAG_PREFER)
+                   ip->flags |= INFO_FLAG_PREFER;
+               if (pp->flags & FLAG_BURST)
+                   ip->flags |= INFO_FLAG_BURST;
+               if (pp->flags & FLAG_IBURST)
+                   ip->flags |= INFO_FLAG_IBURST;
+               if (pp->status == CTL_PST_SEL_SYNCCAND)
+                   ip->flags |= INFO_FLAG_SEL_CANDIDATE;
+               if (pp->status >= CTL_PST_SEL_SYSPEER)
+                   ip->flags |= INFO_FLAG_SHORTLIST;
+               ip->flags = htons(ip->flags);
+               ip->timereceived = htonl((u_int32)(current_time - pp->timereceived));
+               ip->timetosend = htonl(pp->nextdate - current_time);
+               ip->timereachable = htonl((u_int32)(current_time - pp->timereachable));
+               ip->sent = htonl((u_int32)(pp->sent));
+               ip->processed = htonl((u_int32)(pp->processed));
+               ip->badauth = htonl((u_int32)(pp->badauth));
+               ip->bogusorg = htonl((u_int32)(pp->bogusorg));
+               ip->oldpkt = htonl((u_int32)(pp->oldpkt));
+               ip->seldisp = htonl((u_int32)(pp->seldisptoolarge));
+               ip->selbroken = htonl((u_int32)(pp->selbroken));
+               ip->candidate = pp->status;
+               ip = (struct info_peer_stats *)more_pkt();
+       }
+       flush_pkt();
+}
+
+
+/*
+ * sys_info - return system info
+ */
+static void
+sys_info(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_sys *is;
+
+       is = (struct info_sys *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_sys));
+
+       if (sys_peer != 0) {
+               if (sys_peer->srcadr.ss_family == AF_INET) {
+                       is->peer = GET_INADDR(sys_peer->srcadr);
+                       if (client_v6_capable)
+                               is->v6_flag = 0;
+               } else if (client_v6_capable) {
+                       is->peer6 = GET_INADDR6(sys_peer->srcadr);
+                       is->v6_flag = 1;
+               }
+               is->peer_mode = sys_peer->hmode;
+       } else {
+               is->peer = 0;
+               if (client_v6_capable) {
+                       is->v6_flag = 0;
+               }
+               is->peer_mode = 0;
+       }
+
+       is->leap = sys_leap;
+       is->stratum = sys_stratum;
+       is->precision = sys_precision;
+       is->rootdelay = htonl(DTOFP(sys_rootdelay));
+       is->rootdispersion = htonl(DTOUFP(sys_rootdispersion));
+       is->frequency = htonl(DTOFP(sys_jitter));
+       is->stability = htonl(DTOUFP(clock_stability));
+       is->refid = sys_refid;
+       HTONL_FP(&sys_reftime, &is->reftime);
+
+       is->poll = sys_poll;
+       
+       is->flags = 0;
+       if (sys_authenticate)
+               is->flags |= INFO_FLAG_AUTHENTICATE;
+       if (sys_bclient)
+               is->flags |= INFO_FLAG_BCLIENT;
+#ifdef REFCLOCK
+       if (cal_enable)
+               is->flags |= INFO_FLAG_CAL;
+#endif /* REFCLOCK */
+       if (kern_enable)
+               is->flags |= INFO_FLAG_KERNEL;
+       if (mon_enabled != MON_OFF)
+               is->flags |= INFO_FLAG_MONITOR;
+       if (ntp_enable)
+               is->flags |= INFO_FLAG_NTP;
+       if (pps_enable)
+               is->flags |= INFO_FLAG_PPS_SYNC;
+       if (stats_control)
+               is->flags |= INFO_FLAG_FILEGEN;
+       is->bdelay = HTONS_FP(DTOFP(sys_bdelay));
+       HTONL_UF(sys_authdelay.l_f, &is->authdelay);
+
+       (void) more_pkt();
+       flush_pkt();
+}
+
+
+/*
+ * sys_stats - return system statistics
+ */
+static void
+sys_stats(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_sys_stats *ss;
+
+       /*
+        * Importations from the protocol module
+        */
+       ss = (struct info_sys_stats *)prepare_pkt(srcadr, inter, inpkt,
+               sizeof(struct info_sys_stats));
+       ss->timeup = htonl((u_int32)current_time);
+       ss->timereset = htonl((u_int32)(current_time - sys_stattime));
+       ss->denied = htonl((u_int32)sys_restricted);
+       ss->oldversionpkt = htonl((u_int32)sys_oldversionpkt);
+       ss->newversionpkt = htonl((u_int32)sys_newversionpkt);
+       ss->unknownversion = htonl((u_int32)sys_unknownversion);
+       ss->badlength = htonl((u_int32)sys_badlength);
+       ss->processed = htonl((u_int32)sys_processed);
+       ss->badauth = htonl((u_int32)sys_badauth);
+       ss->limitrejected = htonl((u_int32)sys_limitrejected);
+       ss->received = htonl((u_int32)sys_received);
+       (void) more_pkt();
+       flush_pkt();
+}
+
+
+/*
+ * mem_stats - return memory statistics
+ */
+static void
+mem_stats(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_mem_stats *ms;
+       register int i;
+
+       /*
+        * Importations from the peer module
+        */
+       extern int peer_hash_count[NTP_HASH_SIZE];
+       extern int peer_free_count;
+       extern u_long peer_timereset;
+       extern u_long findpeer_calls;
+       extern u_long peer_allocations;
+       extern u_long peer_demobilizations;
+       extern int total_peer_structs;
+
+       ms = (struct info_mem_stats *)prepare_pkt(srcadr, inter, inpkt,
+                                                 sizeof(struct info_mem_stats));
+
+       ms->timereset = htonl((u_int32)(current_time - peer_timereset));
+       ms->totalpeermem = htons((u_short)total_peer_structs);
+       ms->freepeermem = htons((u_short)peer_free_count);
+       ms->findpeer_calls = htonl((u_int32)findpeer_calls);
+       ms->allocations = htonl((u_int32)peer_allocations);
+       ms->demobilizations = htonl((u_int32)peer_demobilizations);
+
+       for (i = 0; i < NTP_HASH_SIZE; i++) {
+               if (peer_hash_count[i] > 255)
+                   ms->hashcount[i] = 255;
+               else
+                   ms->hashcount[i] = (u_char)peer_hash_count[i];
+       }
+
+       (void) more_pkt();
+       flush_pkt();
+}
+
+
+/*
+ * io_stats - return io statistics
+ */
+static void
+io_stats(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_io_stats *io;
+
+       /*
+        * Importations from the io module
+        */
+       extern u_long io_timereset;
+       
+       io = (struct info_io_stats *)prepare_pkt(srcadr, inter, inpkt,
+                                                sizeof(struct info_io_stats));
+
+       io->timereset = htonl((u_int32)(current_time - io_timereset));
+       io->totalrecvbufs = htons((u_short) total_recvbuffs());
+       io->freerecvbufs = htons((u_short) free_recvbuffs());
+       io->fullrecvbufs = htons((u_short) full_recvbuffs());
+       io->lowwater = htons((u_short) lowater_additions());
+       io->dropped = htonl((u_int32)packets_dropped);
+       io->ignored = htonl((u_int32)packets_ignored);
+       io->received = htonl((u_int32)packets_received);
+       io->sent = htonl((u_int32)packets_sent);
+       io->notsent = htonl((u_int32)packets_notsent);
+       io->interrupts = htonl((u_int32)handler_calls);
+       io->int_received = htonl((u_int32)handler_pkts);
+
+       (void) more_pkt();
+       flush_pkt();
+}
+
+
+/*
+ * timer_stats - return timer statistics
+ */
+static void
+timer_stats(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_timer_stats *ts;
+
+       /*
+        * Importations from the timer module
+        */
+       extern u_long timer_timereset;
+       extern u_long timer_overflows;
+       extern u_long timer_xmtcalls;
+
+       ts = (struct info_timer_stats *)prepare_pkt(srcadr, inter, inpkt,
+                                                   sizeof(struct info_timer_stats));
+
+       ts->timereset = htonl((u_int32)(current_time - timer_timereset));
+       ts->alarms = htonl((u_int32)alarm_overflow);
+       ts->overflows = htonl((u_int32)timer_overflows);
+       ts->xmtcalls = htonl((u_int32)timer_xmtcalls);
+
+       (void) more_pkt();
+       flush_pkt();
+}
+
+
+/*
+ * loop_info - return the current state of the loop filter
+ */
+static void
+loop_info(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_loop *li;
+       l_fp ltmp;
+
+       /*
+        * Importations from the loop filter module
+        */
+       extern double last_offset;
+       extern double drift_comp;
+       extern int tc_counter;
+       extern u_long sys_clocktime;
+
+       li = (struct info_loop *)prepare_pkt(srcadr, inter, inpkt,
+           sizeof(struct info_loop));
+
+       DTOLFP(last_offset, &ltmp);
+       HTONL_FP(&ltmp, &li->last_offset);
+       DTOLFP(drift_comp * 1e6, &ltmp);
+       HTONL_FP(&ltmp, &li->drift_comp);
+       li->compliance = htonl((u_int32)(tc_counter));
+       li->watchdog_timer = htonl((u_int32)(current_time - sys_clocktime));
+
+       (void) more_pkt();
+       flush_pkt();
+}
+
+
+/*
+ * do_conf - add a peer to the configuration list
+ */
+static void
+do_conf(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       static u_long soonest_ifrescan_time = 0;
+       int items;
+       u_int fl;
+       struct conf_peer *cp; 
+       struct conf_peer temp_cp;
+       struct sockaddr_storage peeraddr;
+       struct sockaddr_in tmp_clock;
+
+       /*
+        * Do a check of everything to see that it looks
+        * okay.  If not, complain about it.  Note we are
+        * very picky here.
+        */
+       items = INFO_NITEMS(inpkt->err_nitems);
+       cp = (struct conf_peer *)inpkt->data;
+       memset(&temp_cp, 0, sizeof(struct conf_peer));
+       memcpy(&temp_cp, (char *)cp, INFO_ITEMSIZE(inpkt->mbz_itemsize));
+       fl = 0;
+       while (items-- > 0 && !fl) {
+               if (((temp_cp.version) > NTP_VERSION)
+                   || ((temp_cp.version) < NTP_OLDVERSION))
+                   fl = 1;
+               if (temp_cp.hmode != MODE_ACTIVE
+                   && temp_cp.hmode != MODE_CLIENT
+                   && temp_cp.hmode != MODE_BROADCAST)
+                   fl = 1;
+               if (temp_cp.flags & ~(CONF_FLAG_AUTHENABLE | CONF_FLAG_PREFER
+                                 | CONF_FLAG_BURST | CONF_FLAG_IBURST | CONF_FLAG_SKEY))
+                   fl = 1;
+               cp = (struct conf_peer *)
+                   ((char *)cp + INFO_ITEMSIZE(inpkt->mbz_itemsize));
+       }
+
+       if (fl) {
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       /*
+        * Looks okay, try it out
+        */
+       items = INFO_NITEMS(inpkt->err_nitems);
+       cp = (struct conf_peer *)inpkt->data;  
+
+       while (items-- > 0) {
+               memset(&temp_cp, 0, sizeof(struct conf_peer));
+               memcpy(&temp_cp, (char *)cp, INFO_ITEMSIZE(inpkt->mbz_itemsize));
+               memset((char *)&peeraddr, 0, sizeof(struct sockaddr_storage));
+
+               fl = 0;
+               if (temp_cp.flags & CONF_FLAG_AUTHENABLE)
+                       fl |= FLAG_AUTHENABLE;
+               if (temp_cp.flags & CONF_FLAG_PREFER)
+                       fl |= FLAG_PREFER;
+               if (temp_cp.flags & CONF_FLAG_BURST)
+                   fl |= FLAG_BURST;
+               if (temp_cp.flags & CONF_FLAG_IBURST)
+                   fl |= FLAG_IBURST;
+               if (temp_cp.flags & CONF_FLAG_SKEY)
+                       fl |= FLAG_SKEY;
+               
+               if (client_v6_capable && temp_cp.v6_flag != 0) {
+                       peeraddr.ss_family = AF_INET6;
+                       GET_INADDR6(peeraddr) = temp_cp.peeraddr6; 
+               } else {
+                       peeraddr.ss_family = AF_INET;
+                       GET_INADDR(peeraddr) = temp_cp.peeraddr;
+                       /*
+                        * Make sure the address is valid
+                        */
+                       tmp_clock = *CAST_V4(peeraddr);
+                       if (
+#ifdef REFCLOCK
+                               !ISREFCLOCKADR(&tmp_clock) &&
+#endif
+                               ISBADADR(&tmp_clock)) {
+                               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+                               return;
+                       }
+
+               }
+               NSRCPORT(&peeraddr) = htons(NTP_PORT);
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               peeraddr.ss_len = SOCKLEN(&peeraddr);
+#endif
+
+               /* XXX W2DO? minpoll/maxpoll arguments ??? */
+               if (peer_config(&peeraddr, (struct interface *)0,
+                   temp_cp.hmode, temp_cp.version, temp_cp.minpoll, 
+                   temp_cp.maxpoll, fl, temp_cp.ttl, temp_cp.keyid,
+                   NULL) == 0) {
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+                       return;
+               }
+
+               /*
+                * ntp_intres.c uses REQ_CONFIG/doconf() to add each
+                * server after its name is resolved.  If we have been
+                * disconnected from the network, it may notice the
+                * network has returned and add the first server while
+                * the relevant interface is still disabled, awaiting
+                * the next interface rescan.  To get things moving
+                * more quickly, trigger an interface scan now, except
+                * if we have done so in the last half minute.
+                */
+               if (soonest_ifrescan_time < current_time) {
+                       soonest_ifrescan_time = current_time + 30;
+                       timer_interfacetimeout(current_time);
+                       DPRINTF(1, ("do_conf triggering interface rescan\n"));
+               }
+
+               cp = (struct conf_peer *)
+                   ((char *)cp + INFO_ITEMSIZE(inpkt->mbz_itemsize));
+       }
+
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+
+#if 0
+/* XXX */
+/*
+ * dns_a - Snarf DNS info for an association ID
+ */
+static void
+dns_a(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_dns_assoc *dp;
+       register int items;
+       struct sockaddr_in peeraddr;
+
+       /*
+        * Do a check of everything to see that it looks
+        * okay.  If not, complain about it.  Note we are
+        * very picky here.
+        */
+       items = INFO_NITEMS(inpkt->err_nitems);
+       dp = (struct info_dns_assoc *)inpkt->data;
+
+       /*
+        * Looks okay, try it out
+        */
+       items = INFO_NITEMS(inpkt->err_nitems);
+       dp = (struct info_dns_assoc *)inpkt->data;
+       memset((char *)&peeraddr, 0, sizeof(struct sockaddr_in));
+       peeraddr.sin_family = AF_INET;
+       peeraddr.sin_port = htons(NTP_PORT);
+
+       /*
+        * Make sure the address is valid
+        */
+       if (
+#ifdef REFCLOCK
+               !ISREFCLOCKADR(&peeraddr) &&
+#endif
+               ISBADADR(&peeraddr)) {
+#ifdef REFCLOCK
+               msyslog(LOG_ERR, "dns_a: !ISREFCLOCK && ISBADADR");
+#else
+               msyslog(LOG_ERR, "dns_a: ISBADADR");
+#endif
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       while (items-- > 0) {
+               associd_t associd;
+               size_t hnl;
+               struct peer *peer;
+               int bogon = 0;
+
+               associd = dp->associd;
+               peer = findpeerbyassoc(associd);
+               if (peer == 0 || peer->flags & FLAG_REFCLOCK) {
+                       msyslog(LOG_ERR, "dns_a: %s",
+                               (peer == 0)
+                               ? "peer == 0"
+                               : "peer->flags & FLAG_REFCLOCK");
+                       ++bogon;
+               }
+               peeraddr.sin_addr.s_addr = dp->peeraddr;
+               for (hnl = 0; dp->hostname[hnl] && hnl < sizeof dp->hostname; ++hnl) ;
+               if (hnl >= sizeof dp->hostname) {
+                       msyslog(LOG_ERR, "dns_a: hnl (%ld) >= %ld",
+                               (long)hnl, (long)sizeof dp->hostname);
+                       ++bogon;
+               }
+
+               msyslog(LOG_INFO, "dns_a: <%s> for %s, AssocID %d, bogon %d",
+                       dp->hostname,
+                       stoa((struct sockaddr_storage *)&peeraddr), associd,
+                       bogon);
+
+               if (bogon) {
+                       /* If it didn't work */
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+                       return;
+               } else {
+#if 0
+#ifdef PUBKEY
+                       crypto_public(peer, dp->hostname);
+#endif /* PUBKEY */
+#endif
+               }
+
+               dp++;
+       }
+
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+#endif /* 0 */
+
+/*
+ * do_unconf - remove a peer from the configuration list
+ */
+static void
+do_unconf(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct conf_unpeer *cp;
+       struct conf_unpeer temp_cp;
+       register int items;
+       register struct peer *peer;
+       struct sockaddr_storage peeraddr;
+       int bad, found;
+
+       /*
+        * This is a bit unstructured, but I like to be careful.
+        * We check to see that every peer exists and is actually
+        * configured.  If so, we remove them.  If not, we return
+        * an error.
+        */
+       items = INFO_NITEMS(inpkt->err_nitems);
+       cp = (struct conf_unpeer *)inpkt->data;
+
+       bad = 0;
+       while (items-- > 0 && !bad) {
+               memset(&temp_cp, 0, sizeof(temp_cp));
+               memset(&peeraddr, 0, sizeof(peeraddr));
+               memcpy(&temp_cp, cp, INFO_ITEMSIZE(inpkt->mbz_itemsize));
+               if (client_v6_capable && temp_cp.v6_flag != 0) {
+                       peeraddr.ss_family = AF_INET6;
+                       GET_INADDR6(peeraddr) = temp_cp.peeraddr6;
+               } else {
+                       peeraddr.ss_family = AF_INET;
+                       GET_INADDR(peeraddr) = temp_cp.peeraddr;
+               }
+               NSRCPORT(&peeraddr) = htons(NTP_PORT);
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               peeraddr.ss_len = SOCKLEN(&peeraddr);
+#endif
+               found = 0;
+               peer = (struct peer *)0;
+#ifdef DEBUG
+               if (debug)
+                    printf("searching for %s\n", stoa(&peeraddr));
+#endif
+               while (!found) {
+                       peer = findexistingpeer(&peeraddr, peer, -1);
+                       if (peer == (struct peer *)0)
+                           break;
+                       if (peer->flags & FLAG_CONFIG)
+                           found = 1;
+               }
+               if (!found)
+                   bad = 1;
+               cp = (struct conf_unpeer *)
+                   ((char *)cp + INFO_ITEMSIZE(inpkt->mbz_itemsize));
+       }
+
+       if (bad) {
+               req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+               return;
+       }
+
+       /*
+        * Now do it in earnest.
+        */
+
+       items = INFO_NITEMS(inpkt->err_nitems);
+       cp = (struct conf_unpeer *)inpkt->data;
+       while (items-- > 0) {
+               memset(&temp_cp, 0, sizeof(temp_cp));
+               memset(&peeraddr, 0, sizeof(peeraddr));
+               memcpy(&temp_cp, cp, INFO_ITEMSIZE(inpkt->mbz_itemsize));
+               if (client_v6_capable && temp_cp.v6_flag != 0) {
+                       peeraddr.ss_family = AF_INET6;
+                       GET_INADDR6(peeraddr) = temp_cp.peeraddr6;
+               } else {
+                       peeraddr.ss_family = AF_INET;
+                       GET_INADDR(peeraddr) = temp_cp.peeraddr;
+               }
+               NSRCPORT(&peeraddr) = htons(NTP_PORT);
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               peeraddr.ss_len = SOCKLEN(&peeraddr);
+#endif
+               peer_unconfig(&peeraddr, (struct interface *)0, -1);
+               cp = (struct conf_unpeer *)
+                   ((char *)cp + INFO_ITEMSIZE(inpkt->mbz_itemsize));
+       }
+
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+
+
+/*
+ * set_sys_flag - set system flags
+ */
+static void
+set_sys_flag(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       setclr_flags(srcadr, inter, inpkt, 1);
+}
+
+
+/*
+ * clr_sys_flag - clear system flags
+ */
+static void
+clr_sys_flag(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       setclr_flags(srcadr, inter, inpkt, 0);
+}
+
+
+/*
+ * setclr_flags - do the grunge work of flag setting/clearing
+ */
+static void
+setclr_flags(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt,
+       u_long set
+       )
+{
+       register u_int flags;
+       int prev_kern_enable;
+
+       prev_kern_enable = kern_enable;
+       if (INFO_NITEMS(inpkt->err_nitems) > 1) {
+               msyslog(LOG_ERR, "setclr_flags: err_nitems > 1");
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       flags = ((struct conf_sys_flags *)inpkt->data)->flags;
+       flags = ntohl(flags);
+       
+       if (flags & ~(SYS_FLAG_BCLIENT | SYS_FLAG_PPS |
+                     SYS_FLAG_NTP | SYS_FLAG_KERNEL | SYS_FLAG_MONITOR |
+                     SYS_FLAG_FILEGEN | SYS_FLAG_AUTH | SYS_FLAG_CAL)) {
+               msyslog(LOG_ERR, "setclr_flags: extra flags: %#x",
+                       flags & ~(SYS_FLAG_BCLIENT | SYS_FLAG_PPS |
+                                 SYS_FLAG_NTP | SYS_FLAG_KERNEL |
+                                 SYS_FLAG_MONITOR | SYS_FLAG_FILEGEN |
+                                 SYS_FLAG_AUTH | SYS_FLAG_CAL));
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       if (flags & SYS_FLAG_BCLIENT)
+               proto_config(PROTO_BROADCLIENT, set, 0., NULL);
+       if (flags & SYS_FLAG_PPS)
+               proto_config(PROTO_PPS, set, 0., NULL);
+       if (flags & SYS_FLAG_NTP)
+               proto_config(PROTO_NTP, set, 0., NULL);
+       if (flags & SYS_FLAG_KERNEL)
+               proto_config(PROTO_KERNEL, set, 0., NULL);
+       if (flags & SYS_FLAG_MONITOR)
+               proto_config(PROTO_MONITOR, set, 0., NULL);
+       if (flags & SYS_FLAG_FILEGEN)
+               proto_config(PROTO_FILEGEN, set, 0., NULL);
+       if (flags & SYS_FLAG_AUTH)
+               proto_config(PROTO_AUTHENTICATE, set, 0., NULL);
+       if (flags & SYS_FLAG_CAL)
+               proto_config(PROTO_CAL, set, 0., NULL);
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+
+       /* Reset the kernel ntp parameters if the kernel flag changed. */
+       if (prev_kern_enable && !kern_enable)
+               loop_config(LOOP_KERN_CLEAR, 0.0);
+       if (!prev_kern_enable && kern_enable)
+               loop_config(LOOP_DRIFTCOMP, drift_comp);
+}
+
+
+/*
+ * list_restrict - return the restrict list
+ */
+static void
+list_restrict(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_restrict *ir;
+       register struct restrictlist *rl;
+       register struct restrictlist6 *rl6;
+
+#ifdef DEBUG
+       if (debug > 2)
+           printf("wants restrict list summary\n");
+#endif
+
+       ir = (struct info_restrict *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_restrict));
+       
+       for (rl = restrictlist; rl != 0 && ir != 0; rl = rl->next) {
+               ir->addr = htonl(rl->addr);
+               if (client_v6_capable) 
+                       ir->v6_flag = 0;
+               ir->mask = htonl(rl->mask);
+               ir->count = htonl((u_int32)rl->count);
+               ir->flags = htons(rl->flags);
+               ir->mflags = htons(rl->mflags);
+               ir = (struct info_restrict *)more_pkt();
+       }
+       if (client_v6_capable)
+               for (rl6 = restrictlist6; rl6 != 0 && ir != 0; rl6 = rl6->next) {
+                       ir->addr6 = rl6->addr6;
+                       ir->mask6 = rl6->mask6;
+                       ir->v6_flag = 1;
+                       ir->count = htonl((u_int32)rl6->count);
+                       ir->flags = htons(rl6->flags);
+                       ir->mflags = htons(rl6->mflags);
+                       ir = (struct info_restrict *)more_pkt();
+               }
+       flush_pkt();
+}
+
+
+
+/*
+ * do_resaddflags - add flags to a restrict entry (or create one)
+ */
+static void
+do_resaddflags(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       do_restrict(srcadr, inter, inpkt, RESTRICT_FLAGS);
+}
+
+
+
+/*
+ * do_ressubflags - remove flags from a restrict entry
+ */
+static void
+do_ressubflags(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       do_restrict(srcadr, inter, inpkt, RESTRICT_UNFLAG);
+}
+
+
+/*
+ * do_unrestrict - remove a restrict entry from the list
+ */
+static void
+do_unrestrict(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       do_restrict(srcadr, inter, inpkt, RESTRICT_REMOVE);
+}
+
+
+
+
+
+/*
+ * do_restrict - do the dirty stuff of dealing with restrictions
+ */
+static void
+do_restrict(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt,
+       int op
+       )
+{
+       register struct conf_restrict *cr;
+       register int items;
+       struct sockaddr_storage matchaddr;
+       struct sockaddr_storage matchmask;
+       int bad;
+
+       /*
+        * Do a check of the flags to make sure that only
+        * the NTPPORT flag is set, if any.  If not, complain
+        * about it.  Note we are very picky here.
+        */
+       items = INFO_NITEMS(inpkt->err_nitems);
+       cr = (struct conf_restrict *)inpkt->data;
+
+       bad = 0;
+       cr->flags = ntohs(cr->flags);
+       cr->mflags = ntohs(cr->mflags);
+       while (items-- > 0 && !bad) {
+               if (cr->mflags & ~(RESM_NTPONLY))
+                   bad |= 1;
+               if (cr->flags & ~(RES_ALLFLAGS))
+                   bad |= 2;
+               if (cr->mask != htonl(INADDR_ANY)) {
+                       if (client_v6_capable && cr->v6_flag != 0) {
+                               if (IN6_IS_ADDR_UNSPECIFIED(&cr->addr6))
+                                       bad |= 4;
+                       } else
+                               if (cr->addr == htonl(INADDR_ANY))
+                                       bad |= 8;
+               }
+               cr = (struct conf_restrict *)((char *)cr +
+                   INFO_ITEMSIZE(inpkt->mbz_itemsize));
+       }
+
+       if (bad) {
+               msyslog(LOG_ERR, "do_restrict: bad = %#x", bad);
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       /*
+        * Looks okay, try it out
+        */
+       items = INFO_NITEMS(inpkt->err_nitems);
+       cr = (struct conf_restrict *)inpkt->data;
+       memset((char *)&matchaddr, 0, sizeof(struct sockaddr_storage));
+       memset((char *)&matchmask, 0, sizeof(struct sockaddr_storage));
+
+       while (items-- > 0) {
+               if (client_v6_capable && cr->v6_flag != 0) {
+                       GET_INADDR6(matchaddr) = cr->addr6;
+                       GET_INADDR6(matchmask) = cr->mask6;
+                       matchaddr.ss_family = AF_INET6;
+                       matchmask.ss_family = AF_INET6;
+               } else {
+                       GET_INADDR(matchaddr) = cr->addr;
+                       GET_INADDR(matchmask) = cr->mask;
+                       matchaddr.ss_family = AF_INET;
+                       matchmask.ss_family = AF_INET;
+               }
+               hack_restrict(op, &matchaddr, &matchmask, cr->mflags,
+                        cr->flags);
+               cr++;
+       }
+
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+
+
+/*
+ * mon_getlist - return monitor data
+ */
+static void
+mon_getlist_0(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_monitor *im;
+       register struct mon_data *md;
+       extern struct mon_data mon_mru_list;
+       extern int mon_enabled;
+
+#ifdef DEBUG
+       if (debug > 2)
+           printf("wants monitor 0 list\n");
+#endif
+       if (!mon_enabled) {
+               req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+               return;
+       }
+       im = (struct info_monitor *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_monitor));
+       for (md = mon_mru_list.mru_next; md != &mon_mru_list && im != 0;
+            md = md->mru_next) {
+               im->lasttime = htonl((u_int32)md->avg_interval);
+               im->firsttime = htonl((u_int32)(current_time - md->lasttime));
+               im->lastdrop = htonl((u_int32)md->drop_count);
+               im->count = htonl((u_int32)(md->count));
+               if (md->rmtadr.ss_family == AF_INET6) {
+                       if (!client_v6_capable)
+                               continue;
+                       im->addr6 = GET_INADDR6(md->rmtadr);
+                       im->v6_flag = 1;
+               } else {
+                       im->addr = GET_INADDR(md->rmtadr);
+                       if (client_v6_capable)
+                               im->v6_flag = 0;
+               }
+               im->port = md->rmtport;
+               im->mode = md->mode;
+               im->version = md->version;
+               im = (struct info_monitor *)more_pkt();
+       }
+       flush_pkt();
+}
+
+/*
+ * mon_getlist - return monitor data
+ */
+static void
+mon_getlist_1(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_monitor_1 *im;
+       register struct mon_data *md;
+       extern struct mon_data mon_mru_list;
+       extern int mon_enabled;
+
+       if (!mon_enabled) {
+               req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+               return;
+       }
+       im = (struct info_monitor_1 *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_monitor_1));
+       for (md = mon_mru_list.mru_next; md != &mon_mru_list && im != 0;
+            md = md->mru_next) {
+               im->lasttime = htonl((u_int32)md->avg_interval);
+               im->firsttime = htonl((u_int32)(current_time - md->lasttime));
+               im->lastdrop = htonl((u_int32)md->drop_count);
+               im->count = htonl((u_int32)md->count);
+               if (md->rmtadr.ss_family == AF_INET6) {
+                       if (!client_v6_capable)
+                               continue;
+                       im->addr6 = GET_INADDR6(md->rmtadr);
+                       im->v6_flag = 1;
+                       im->daddr6 = GET_INADDR6(md->interface->sin);
+               } else {
+                       im->addr = GET_INADDR(md->rmtadr);
+                       if (client_v6_capable)
+                               im->v6_flag = 0;
+                       im->daddr = (md->cast_flags == MDF_BCAST)  
+                               ? GET_INADDR(md->interface->bcast) 
+                               : (md->cast_flags 
+                               ? (GET_INADDR(md->interface->sin)
+                               ? GET_INADDR(md->interface->sin)
+                               : GET_INADDR(md->interface->bcast))
+                               : 4);
+               }
+               im->flags = htonl(md->cast_flags);
+               im->port = md->rmtport;
+               im->mode = md->mode;
+               im->version = md->version;
+               im = (struct info_monitor_1 *)more_pkt();
+       }
+       flush_pkt();
+}
+
+/*
+ * Module entry points and the flags they correspond with
+ */
+struct reset_entry {
+       int flag;               /* flag this corresponds to */
+       void (*handler) P((void)); /* routine to handle request */
+};
+
+struct reset_entry reset_entries[] = {
+       { RESET_FLAG_ALLPEERS,  peer_all_reset },
+       { RESET_FLAG_IO,        io_clr_stats },
+       { RESET_FLAG_SYS,       proto_clr_stats },
+       { RESET_FLAG_MEM,       peer_clr_stats },
+       { RESET_FLAG_TIMER,     timer_clr_stats },
+       { RESET_FLAG_AUTH,      reset_auth_stats },
+       { RESET_FLAG_CTL,       ctl_clr_stats },
+       { 0,                    0 }
+};
+
+/*
+ * reset_stats - reset statistic counters here and there
+ */
+static void
+reset_stats(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       u_long flags;
+       struct reset_entry *rent;
+
+       if (INFO_NITEMS(inpkt->err_nitems) > 1) {
+               msyslog(LOG_ERR, "reset_stats: err_nitems > 1");
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       flags = ((struct reset_flags *)inpkt->data)->flags;
+       flags = ntohl(flags);
+     
+       if (flags & ~RESET_ALLFLAGS) {
+               msyslog(LOG_ERR, "reset_stats: reset leaves %#lx",
+                       flags & ~RESET_ALLFLAGS);
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       for (rent = reset_entries; rent->flag != 0; rent++) {
+               if (flags & rent->flag)
+                   (rent->handler)();
+       }
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+
+
+/*
+ * reset_peer - clear a peer's statistics
+ */
+static void
+reset_peer(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct conf_unpeer *cp;
+       register int items;
+       register struct peer *peer;
+       struct sockaddr_storage peeraddr;
+       int bad;
+
+       /*
+        * We check first to see that every peer exists.  If not,
+        * we return an error.
+        */
+
+       items = INFO_NITEMS(inpkt->err_nitems);
+       cp = (struct conf_unpeer *)inpkt->data;
+
+       bad = 0;
+       while (items-- > 0 && !bad) {
+               memset((char *)&peeraddr, 0, sizeof(peeraddr));
+               if (client_v6_capable && cp->v6_flag != 0) {
+                       GET_INADDR6(peeraddr) = cp->peeraddr6;
+                       peeraddr.ss_family = AF_INET6;
+               } else {
+                       GET_INADDR(peeraddr) = cp->peeraddr;
+                       peeraddr.ss_family = AF_INET;
+               }
+               NSRCPORT(&peeraddr) = htons(NTP_PORT);
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               peeraddr.ss_len = SOCKLEN(&peeraddr);
+#endif
+               peer = findexistingpeer(&peeraddr, (struct peer *)0, -1);
+               if (peer == (struct peer *)0)
+                   bad++;
+               cp = (struct conf_unpeer *)((char *)cp +
+                   INFO_ITEMSIZE(inpkt->mbz_itemsize));
+       }
+
+       if (bad) {
+               req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+               return;
+       }
+
+       /*
+        * Now do it in earnest.
+        */
+
+       items = INFO_NITEMS(inpkt->err_nitems);
+       cp = (struct conf_unpeer *)inpkt->data;
+       while (items-- > 0) {
+               memset((char *)&peeraddr, 0, sizeof(peeraddr));
+               if (client_v6_capable && cp->v6_flag != 0) {
+                       GET_INADDR6(peeraddr) = cp->peeraddr6;
+                       peeraddr.ss_family = AF_INET6;
+               } else {
+                       GET_INADDR(peeraddr) = cp->peeraddr;
+                       peeraddr.ss_family = AF_INET;
+               }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               peeraddr.ss_len = SOCKLEN(&peeraddr);
+#endif
+               peer = findexistingpeer(&peeraddr, (struct peer *)0, -1);
+               while (peer != 0) {
+                       peer_reset(peer);
+                       peer = findexistingpeer(&peeraddr, (struct peer *)peer, -1);
+               }
+               cp = (struct conf_unpeer *)((char *)cp +
+                   INFO_ITEMSIZE(inpkt->mbz_itemsize));
+       }
+
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+
+
+/*
+ * do_key_reread - reread the encryption key file
+ */
+static void
+do_key_reread(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       rereadkeys();
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+
+
+/*
+ * trust_key - make one or more keys trusted
+ */
+static void
+trust_key(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       do_trustkey(srcadr, inter, inpkt, 1);
+}
+
+
+/*
+ * untrust_key - make one or more keys untrusted
+ */
+static void
+untrust_key(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       do_trustkey(srcadr, inter, inpkt, 0);
+}
+
+
+/*
+ * do_trustkey - make keys either trustable or untrustable
+ */
+static void
+do_trustkey(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt,
+       u_long trust
+       )
+{
+       register u_long *kp;
+       register int items;
+
+       items = INFO_NITEMS(inpkt->err_nitems);
+       kp = (u_long *)inpkt->data;
+       while (items-- > 0) {
+               authtrust(*kp, trust);
+               kp++;
+       }
+
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+
+
+/*
+ * get_auth_info - return some stats concerning the authentication module
+ */
+static void
+get_auth_info(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_auth *ia;
+
+       /*
+        * Importations from the authentication module
+        */
+       extern u_long authnumkeys;
+       extern int authnumfreekeys;
+       extern u_long authkeylookups;
+       extern u_long authkeynotfound;
+       extern u_long authencryptions;
+       extern u_long authdecryptions;
+       extern u_long authkeyuncached;
+       extern u_long authkeyexpired;
+
+       ia = (struct info_auth *)prepare_pkt(srcadr, inter, inpkt,
+                                            sizeof(struct info_auth));
+
+       ia->numkeys = htonl((u_int32)authnumkeys);
+       ia->numfreekeys = htonl((u_int32)authnumfreekeys);
+       ia->keylookups = htonl((u_int32)authkeylookups);
+       ia->keynotfound = htonl((u_int32)authkeynotfound);
+       ia->encryptions = htonl((u_int32)authencryptions);
+       ia->decryptions = htonl((u_int32)authdecryptions);
+       ia->keyuncached = htonl((u_int32)authkeyuncached);
+       ia->expired = htonl((u_int32)authkeyexpired);
+       ia->timereset = htonl((u_int32)(current_time - auth_timereset));
+       
+       (void) more_pkt();
+       flush_pkt();
+}
+
+
+
+/*
+ * reset_auth_stats - reset the authentication stat counters.  Done here
+ *                   to keep ntp-isms out of the authentication module
+ */
+static void
+reset_auth_stats(void)
+{
+       /*
+        * Importations from the authentication module
+        */
+       extern u_long authkeylookups;
+       extern u_long authkeynotfound;
+       extern u_long authencryptions;
+       extern u_long authdecryptions;
+       extern u_long authkeyuncached;
+
+       authkeylookups = 0;
+       authkeynotfound = 0;
+       authencryptions = 0;
+       authdecryptions = 0;
+       authkeyuncached = 0;
+       auth_timereset = current_time;
+}
+
+
+/*
+ * req_get_traps - return information about current trap holders
+ */
+static void
+req_get_traps(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_trap *it;
+       register struct ctl_trap *tr;
+       register int i;
+
+       /*
+        * Imported from the control module
+        */
+       extern struct ctl_trap ctl_trap[];
+       extern int num_ctl_traps;
+
+       if (num_ctl_traps == 0) {
+               req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+               return;
+       }
+
+       it = (struct info_trap *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_trap));
+
+       for (i = 0, tr = ctl_trap; i < CTL_MAXTRAPS; i++, tr++) {
+               if (tr->tr_flags & TRAP_INUSE) {
+                       if (tr->tr_addr.ss_family == AF_INET) {
+                               if (tr->tr_localaddr == any_interface)
+                                       it->local_address = 0;
+                               else
+                                       it->local_address
+                                           = GET_INADDR(tr->tr_localaddr->sin);
+                               it->trap_address = GET_INADDR(tr->tr_addr);
+                               if (client_v6_capable)
+                                       it->v6_flag = 0;
+                       } else {
+                               if (!client_v6_capable)
+                                       continue;
+                               it->local_address6 
+                                   = GET_INADDR6(tr->tr_localaddr->sin);
+                               it->trap_address6 = GET_INADDR6(tr->tr_addr);
+                               it->v6_flag = 1;
+                       }
+                       it->trap_port = NSRCPORT(&tr->tr_addr);
+                       it->sequence = htons(tr->tr_sequence);
+                       it->settime = htonl((u_int32)(current_time - tr->tr_settime));
+                       it->origtime = htonl((u_int32)(current_time - tr->tr_origtime));
+                       it->resets = htonl((u_int32)tr->tr_resets);
+                       it->flags = htonl((u_int32)tr->tr_flags);
+                       it = (struct info_trap *)more_pkt();
+               }
+       }
+       flush_pkt();
+}
+
+
+/*
+ * req_set_trap - configure a trap
+ */
+static void
+req_set_trap(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       do_setclr_trap(srcadr, inter, inpkt, 1);
+}
+
+
+
+/*
+ * req_clr_trap - unconfigure a trap
+ */
+static void
+req_clr_trap(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       do_setclr_trap(srcadr, inter, inpkt, 0);
+}
+
+
+
+/*
+ * do_setclr_trap - do the grunge work of (un)configuring a trap
+ */
+static void
+do_setclr_trap(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt,
+       int set
+       )
+{
+       register struct conf_trap *ct;
+       register struct interface *linter;
+       int res;
+       struct sockaddr_storage laddr;
+
+       /*
+        * Prepare sockaddr_storage structure
+        */
+       memset((char *)&laddr, 0, sizeof laddr);
+       laddr.ss_family = srcadr->ss_family;
+       NSRCPORT(&laddr) = ntohs(NTP_PORT);
+
+       /*
+        * Restrict ourselves to one item only.  This eliminates
+        * the error reporting problem.
+        */
+       if (INFO_NITEMS(inpkt->err_nitems) > 1) {
+               msyslog(LOG_ERR, "do_setclr_trap: err_nitems > 1");
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+       ct = (struct conf_trap *)inpkt->data;
+
+       /*
+        * Look for the local interface.  If none, use the default.
+        */
+       if (ct->local_address == 0) {
+               linter = any_interface;
+       } else {
+               if (laddr.ss_family == AF_INET)
+                       GET_INADDR(laddr) = ct->local_address;
+               else
+                       GET_INADDR6(laddr) = ct->local_address6;
+               linter = findinterface(&laddr);
+               if (linter == NULL) {
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+                       return;
+               }
+       }
+
+       if (laddr.ss_family == AF_INET)
+               GET_INADDR(laddr) = ct->trap_address;
+       else
+               GET_INADDR6(laddr) = ct->trap_address6;
+       if (ct->trap_port != 0)
+           NSRCPORT(&laddr) = ct->trap_port;
+       else
+           NSRCPORT(&laddr) = htons(TRAPPORT);
+
+       if (set) {
+               res = ctlsettrap(&laddr, linter, 0,
+                                INFO_VERSION(inpkt->rm_vn_mode));
+       } else {
+               res = ctlclrtrap(&laddr, linter, 0);
+       }
+
+       if (!res) {
+               req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+       } else {
+               req_ack(srcadr, inter, inpkt, INFO_OKAY);
+       }
+       return;
+}
+
+
+
+/*
+ * set_request_keyid - set the keyid used to authenticate requests
+ */
+static void
+set_request_keyid(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       keyid_t keyid;
+
+       /*
+        * Restrict ourselves to one item only.
+        */
+       if (INFO_NITEMS(inpkt->err_nitems) > 1) {
+               msyslog(LOG_ERR, "set_request_keyid: err_nitems > 1");
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       keyid = ntohl(*((u_int32 *)(inpkt->data)));
+       info_auth_keyid = keyid;
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+
+
+
+/*
+ * set_control_keyid - set the keyid used to authenticate requests
+ */
+static void
+set_control_keyid(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       keyid_t keyid;
+       extern keyid_t ctl_auth_keyid;
+
+       /*
+        * Restrict ourselves to one item only.
+        */
+       if (INFO_NITEMS(inpkt->err_nitems) > 1) {
+               msyslog(LOG_ERR, "set_control_keyid: err_nitems > 1");
+               req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+               return;
+       }
+
+       keyid = ntohl(*((u_int32 *)(inpkt->data)));
+       ctl_auth_keyid = keyid;
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+
+
+
+/*
+ * get_ctl_stats - return some stats concerning the control message module
+ */
+static void
+get_ctl_stats(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_control *ic;
+
+       /*
+        * Importations from the control module
+        */
+       extern u_long ctltimereset;
+       extern u_long numctlreq;
+       extern u_long numctlbadpkts;
+       extern u_long numctlresponses;
+       extern u_long numctlfrags;
+       extern u_long numctlerrors;
+       extern u_long numctltooshort;
+       extern u_long numctlinputresp;
+       extern u_long numctlinputfrag;
+       extern u_long numctlinputerr;
+       extern u_long numctlbadoffset;
+       extern u_long numctlbadversion;
+       extern u_long numctldatatooshort;
+       extern u_long numctlbadop;
+       extern u_long numasyncmsgs;
+
+       ic = (struct info_control *)prepare_pkt(srcadr, inter, inpkt,
+                                               sizeof(struct info_control));
+
+       ic->ctltimereset = htonl((u_int32)(current_time - ctltimereset));
+       ic->numctlreq = htonl((u_int32)numctlreq);
+       ic->numctlbadpkts = htonl((u_int32)numctlbadpkts);
+       ic->numctlresponses = htonl((u_int32)numctlresponses);
+       ic->numctlfrags = htonl((u_int32)numctlfrags);
+       ic->numctlerrors = htonl((u_int32)numctlerrors);
+       ic->numctltooshort = htonl((u_int32)numctltooshort);
+       ic->numctlinputresp = htonl((u_int32)numctlinputresp);
+       ic->numctlinputfrag = htonl((u_int32)numctlinputfrag);
+       ic->numctlinputerr = htonl((u_int32)numctlinputerr);
+       ic->numctlbadoffset = htonl((u_int32)numctlbadoffset);
+       ic->numctlbadversion = htonl((u_int32)numctlbadversion);
+       ic->numctldatatooshort = htonl((u_int32)numctldatatooshort);
+       ic->numctlbadop = htonl((u_int32)numctlbadop);
+       ic->numasyncmsgs = htonl((u_int32)numasyncmsgs);
+
+       (void) more_pkt();
+       flush_pkt();
+}
+
+
+#ifdef KERNEL_PLL
+/*
+ * get_kernel_info - get kernel pll/pps information
+ */
+static void
+get_kernel_info(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_kernel *ik;
+       struct timex ntx;
+
+       if (!pll_control) {
+               req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+               return;
+       }
+
+       memset((char *)&ntx, 0, sizeof(ntx));
+       if (ntp_adjtime(&ntx) < 0)
+               msyslog(LOG_ERR, "get_kernel_info: ntp_adjtime() failed: %m");
+       ik = (struct info_kernel *)prepare_pkt(srcadr, inter, inpkt,
+           sizeof(struct info_kernel));
+
+       /*
+        * pll variables
+        */
+       ik->offset = htonl((u_int32)ntx.offset);
+       ik->freq = htonl((u_int32)ntx.freq);
+       ik->maxerror = htonl((u_int32)ntx.maxerror);
+       ik->esterror = htonl((u_int32)ntx.esterror);
+       ik->status = htons(ntx.status);
+       ik->constant = htonl((u_int32)ntx.constant);
+       ik->precision = htonl((u_int32)ntx.precision);
+       ik->tolerance = htonl((u_int32)ntx.tolerance);
+
+       /*
+        * pps variables
+        */
+       ik->ppsfreq = htonl((u_int32)ntx.ppsfreq);
+       ik->jitter = htonl((u_int32)ntx.jitter);
+       ik->shift = htons(ntx.shift);
+       ik->stabil = htonl((u_int32)ntx.stabil);
+       ik->jitcnt = htonl((u_int32)ntx.jitcnt);
+       ik->calcnt = htonl((u_int32)ntx.calcnt);
+       ik->errcnt = htonl((u_int32)ntx.errcnt);
+       ik->stbcnt = htonl((u_int32)ntx.stbcnt);
+       
+       (void) more_pkt();
+       flush_pkt();
+}
+#endif /* KERNEL_PLL */
+
+
+#ifdef REFCLOCK
+/*
+ * get_clock_info - get info about a clock
+ */
+static void
+get_clock_info(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct info_clock *ic;
+       register u_int32 *clkaddr;
+       register int items;
+       struct refclockstat clock_stat;
+       struct sockaddr_storage addr;
+       struct sockaddr_in tmp_clock;
+       l_fp ltmp;
+
+       memset((char *)&addr, 0, sizeof addr);
+       addr.ss_family = AF_INET;
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+       addr.ss_len = SOCKLEN(&addr);
+#endif
+       NSRCPORT(&addr) = htons(NTP_PORT);
+       items = INFO_NITEMS(inpkt->err_nitems);
+       clkaddr = (u_int32 *) inpkt->data;
+
+       ic = (struct info_clock *)prepare_pkt(srcadr, inter, inpkt,
+                                             sizeof(struct info_clock));
+
+       while (items-- > 0) {
+               tmp_clock.sin_addr.s_addr = *clkaddr++;
+               CAST_V4(addr)->sin_addr = tmp_clock.sin_addr;
+               if (!ISREFCLOCKADR(&tmp_clock) ||
+                   findexistingpeer(&addr, (struct peer *)0, -1) == 0) {
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+                       return;
+               }
+
+               clock_stat.kv_list = (struct ctl_var *)0;
+
+               refclock_control(&addr, (struct refclockstat *)0, &clock_stat);
+
+               ic->clockadr = tmp_clock.sin_addr.s_addr;
+               ic->type = clock_stat.type;
+               ic->flags = clock_stat.flags;
+               ic->lastevent = clock_stat.lastevent;
+               ic->currentstatus = clock_stat.currentstatus;
+               ic->polls = htonl((u_int32)clock_stat.polls);
+               ic->noresponse = htonl((u_int32)clock_stat.noresponse);
+               ic->badformat = htonl((u_int32)clock_stat.badformat);
+               ic->baddata = htonl((u_int32)clock_stat.baddata);
+               ic->timestarted = htonl((u_int32)clock_stat.timereset);
+               DTOLFP(clock_stat.fudgetime1, &ltmp);
+               HTONL_FP(&ltmp, &ic->fudgetime1);
+               DTOLFP(clock_stat.fudgetime2, &ltmp);
+               HTONL_FP(&ltmp, &ic->fudgetime2);
+               ic->fudgeval1 = htonl((u_int32)clock_stat.fudgeval1);
+               ic->fudgeval2 = htonl((u_int32)clock_stat.fudgeval2);
+
+               free_varlist(clock_stat.kv_list);
+
+               ic = (struct info_clock *)more_pkt();
+       }
+       flush_pkt();
+}
+
+
+
+/*
+ * set_clock_fudge - get a clock's fudge factors
+ */
+static void
+set_clock_fudge(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register struct conf_fudge *cf;
+       register int items;
+       struct refclockstat clock_stat;
+       struct sockaddr_storage addr;
+       struct sockaddr_in tmp_clock;
+       l_fp ltmp;
+
+       memset((char *)&addr, 0, sizeof addr);
+       memset((char *)&clock_stat, 0, sizeof clock_stat);
+       items = INFO_NITEMS(inpkt->err_nitems);
+       cf = (struct conf_fudge *) inpkt->data;
+
+       while (items-- > 0) {
+               tmp_clock.sin_addr.s_addr = cf->clockadr;
+               *CAST_V4(addr) = tmp_clock;
+               addr.ss_family = AF_INET;
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               addr.ss_len = SOCKLEN(&addr);
+#endif
+               NSRCPORT(&addr) = htons(NTP_PORT);
+               if (!ISREFCLOCKADR(&tmp_clock) ||
+                   findexistingpeer(&addr, (struct peer *)0, -1) == 0) {
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+                       return;
+               }
+
+               switch(ntohl(cf->which)) {
+                   case FUDGE_TIME1:
+                       NTOHL_FP(&cf->fudgetime, &ltmp);
+                       LFPTOD(&ltmp, clock_stat.fudgetime1);
+                       clock_stat.haveflags = CLK_HAVETIME1;
+                       break;
+                   case FUDGE_TIME2:
+                       NTOHL_FP(&cf->fudgetime, &ltmp);
+                       LFPTOD(&ltmp, clock_stat.fudgetime2);
+                       clock_stat.haveflags = CLK_HAVETIME2;
+                       break;
+                   case FUDGE_VAL1:
+                       clock_stat.fudgeval1 = ntohl(cf->fudgeval_flags);
+                       clock_stat.haveflags = CLK_HAVEVAL1;
+                       break;
+                   case FUDGE_VAL2:
+                       clock_stat.fudgeval2 = ntohl(cf->fudgeval_flags);
+                       clock_stat.haveflags = CLK_HAVEVAL2;
+                       break;
+                   case FUDGE_FLAGS:
+                       clock_stat.flags = (u_char) (ntohl(cf->fudgeval_flags) & 0xf);
+                       clock_stat.haveflags =
+                               (CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3|CLK_HAVEFLAG4);
+                       break;
+                   default:
+                       msyslog(LOG_ERR, "set_clock_fudge: default!");
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_FMT);
+                       return;
+               }
+
+               refclock_control(&addr, &clock_stat, (struct refclockstat *)0);
+       }
+
+       req_ack(srcadr, inter, inpkt, INFO_OKAY);
+}
+#endif
+
+#ifdef REFCLOCK
+/*
+ * get_clkbug_info - get debugging info about a clock
+ */
+static void
+get_clkbug_info(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       register int i;
+       register struct info_clkbug *ic;
+       register u_int32 *clkaddr;
+       register int items;
+       struct refclockbug bug;
+       struct sockaddr_storage addr;
+       struct sockaddr_in tmp_clock;
+
+       memset((char *)&addr, 0, sizeof addr);
+       addr.ss_family = AF_INET;
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+       addr.ss_len = SOCKLEN(&addr);
+#endif
+       NSRCPORT(&addr) = htons(NTP_PORT);
+       items = INFO_NITEMS(inpkt->err_nitems);
+       clkaddr = (u_int32 *) inpkt->data;
+
+       ic = (struct info_clkbug *)prepare_pkt(srcadr, inter, inpkt,
+                                              sizeof(struct info_clkbug));
+
+       while (items-- > 0) {
+               tmp_clock.sin_addr.s_addr = *clkaddr++;
+               GET_INADDR(addr) = tmp_clock.sin_addr.s_addr;
+               if (!ISREFCLOCKADR(&tmp_clock) ||
+                   findexistingpeer(&addr, (struct peer *)0, -1) == 0) {
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+                       return;
+               }
+
+               memset((char *)&bug, 0, sizeof bug);
+               refclock_buginfo(&addr, &bug);
+               if (bug.nvalues == 0 && bug.ntimes == 0) {
+                       req_ack(srcadr, inter, inpkt, INFO_ERR_NODATA);
+                       return;
+               }
+
+               ic->clockadr = tmp_clock.sin_addr.s_addr;
+               i = bug.nvalues;
+               if (i > NUMCBUGVALUES)
+                   i = NUMCBUGVALUES;
+               ic->nvalues = (u_char)i;
+               ic->svalues = htons((u_short) (bug.svalues & ((1<<i)-1)));
+               while (--i >= 0)
+                   ic->values[i] = htonl(bug.values[i]);
+
+               i = bug.ntimes;
+               if (i > NUMCBUGTIMES)
+                   i = NUMCBUGTIMES;
+               ic->ntimes = (u_char)i;
+               ic->stimes = htonl(bug.stimes);
+               while (--i >= 0) {
+                       HTONL_FP(&bug.times[i], &ic->times[i]);
+               }
+
+               ic = (struct info_clkbug *)more_pkt();
+       }
+       flush_pkt();
+}
+#endif
+
+/*
+ * receiver of interface structures
+ */
+static void
+fill_info_if_stats(void *data, interface_info_t *interface_info)
+{
+       struct info_if_stats **ifsp = (struct info_if_stats **)data;
+       struct info_if_stats *ifs = *ifsp;
+       struct interface *interface = interface_info->interface;
+       
+       memset((char*)ifs, 0, sizeof(*ifs));
+       
+       if (interface->sin.ss_family == AF_INET6) {
+               if (!client_v6_capable) {
+                       return;
+               }
+               ifs->v6_flag = 1;
+               memcpy((char *)&ifs->unaddr.addr6, (char *)&CAST_V6(interface->sin)->sin6_addr, sizeof(struct in6_addr));
+               memcpy((char *)&ifs->unbcast.addr6, (char *)&CAST_V6(interface->bcast)->sin6_addr, sizeof(struct in6_addr));
+               memcpy((char *)&ifs->unmask.addr6, (char *)&CAST_V6(interface->mask)->sin6_addr, sizeof(struct in6_addr));
+       } else {
+               ifs->v6_flag = 0;
+               memcpy((char *)&ifs->unaddr.addr, (char *)&CAST_V4(interface->sin)->sin_addr, sizeof(struct in_addr));
+               memcpy((char *)&ifs->unbcast.addr, (char *)&CAST_V4(interface->bcast)->sin_addr, sizeof(struct in_addr));
+               memcpy((char *)&ifs->unmask.addr, (char *)&CAST_V4(interface->mask)->sin_addr, sizeof(struct in_addr));
+       }
+       ifs->v6_flag = htonl(ifs->v6_flag);
+       strcpy(ifs->name, interface->name);
+       ifs->family = htons(interface->family);
+       ifs->flags = htonl(interface->flags);
+       ifs->last_ttl = htonl(interface->last_ttl);
+       ifs->num_mcast = htonl(interface->num_mcast);
+       ifs->received = htonl(interface->received);
+       ifs->sent = htonl(interface->sent);
+       ifs->notsent = htonl(interface->notsent);
+       ifs->scopeid = htonl(interface->scopeid);
+       ifs->ifindex = htonl(interface->ifindex);
+       ifs->ifnum = htonl(interface->ifnum);
+       ifs->uptime = htonl(current_time - interface->starttime);
+       ifs->ignore_packets = interface->ignore_packets;
+       ifs->peercnt = htonl(interface->peercnt);
+       ifs->action = interface_info->action;
+       
+       *ifsp = (struct info_if_stats *)more_pkt();
+}
+
+/*
+ * get_if_stats - get interface statistics
+ */
+static void
+get_if_stats(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       struct info_if_stats *ifs;
+
+       DPRINTF(3, ("wants interface statistics\n"));
+
+       ifs = (struct info_if_stats *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_if_stats));
+
+       interface_enumerate(fill_info_if_stats, &ifs);
+       
+       flush_pkt();
+}
+
+static void
+do_if_reload(
+       struct sockaddr_storage *srcadr,
+       struct interface *inter,
+       struct req_pkt *inpkt
+       )
+{
+       struct info_if_stats *ifs;
+
+       DPRINTF(3, ("wants interface reload\n"));
+
+       ifs = (struct info_if_stats *)prepare_pkt(srcadr, inter, inpkt,
+           v6sizeof(struct info_if_stats));
+
+       interface_update(fill_info_if_stats, &ifs);
+       
+       flush_pkt();
+}
+
diff --git a/ntpd/ntp_restrict.c b/ntpd/ntp_restrict.c
new file mode 100644 (file)
index 0000000..473e2ce
--- /dev/null
@@ -0,0 +1,607 @@
+/*
+ * ntp_restrict.c - determine host restrictions
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "ntpd.h"
+#include "ntp_if.h"
+#include "ntp_stdlib.h"
+
+/*
+ * This code keeps a simple address-and-mask list of hosts we want
+ * to place restrictions on (or remove them from). The restrictions
+ * are implemented as a set of flags which tell you what the host
+ * can't do. There is a subroutine entry to return the flags. The
+ * list is kept sorted to reduce the average number of comparisons
+ * and make sure you get the set of restrictions most specific to
+ * the address.
+ *
+ * The algorithm is that, when looking up a host, it is first assumed
+ * that the default set of restrictions will apply. It then searches
+ * down through the list. Whenever it finds a match it adopts the
+ * match's flags instead. When you hit the point where the sorted
+ * address is greater than the target, you return with the last set of
+ * flags you found. Because of the ordering of the list, the most
+ * specific match will provide the final set of flags.
+ *
+ * This was originally intended to restrict you from sync'ing to your
+ * own broadcasts when you are doing that, by restricting yourself from
+ * your own interfaces. It was also thought it would sometimes be useful
+ * to keep a misbehaving host or two from abusing your primary clock. It
+ * has been expanded, however, to suit the needs of those with more
+ * restrictive access policies.
+ */
+/*
+ * We will use two lists, one for IPv4 addresses and one for IPv6
+ * addresses. This is not protocol-independant but for now I can't
+ * find a way to respect this. We'll check this later... JFB 07/2001
+ */
+#define SET_IPV6_ADDR_MASK(dst, src, msk) \
+       do { \
+               int idx; \
+               for (idx = 0; idx < 16; idx++) { \
+                       (dst)->s6_addr[idx] = \
+                           (u_char) ((src)->s6_addr[idx] & (msk)->s6_addr[idx]); \
+               } \
+       } while (0)
+
+/*
+ * Memory allocation parameters.  We allocate INITRESLIST entries
+ * initially, and add INCRESLIST entries to the free list whenever
+ * we run out.
+ */
+#define        INITRESLIST     10
+#define        INCRESLIST      5
+
+#define RES_AVG                8.      /* interpacket averaging factor */
+
+/*
+ * The restriction list
+ */
+struct restrictlist *restrictlist;
+struct restrictlist6 *restrictlist6;
+static int restrictcount;      /* count of entries in the res list */
+static int restrictcount6;     /* count of entries in the res list 2*/
+
+/*
+ * The free list and associated counters.  Also some uninteresting
+ * stat counters.
+ */
+static struct restrictlist *resfree;
+static struct restrictlist6 *resfree6;
+static int numresfree;         /* number of structures on free list */
+static int numresfree6;        /* number of structures on free list 2 */
+
+static u_long res_calls;
+static u_long res_found;
+static u_long res_not_found;
+
+/*
+ * Parameters of the RES_LIMITED restriction option.
+ */
+u_long res_avg_interval = 5;   /* min average interpacket interval */
+u_long res_min_interval = 1;   /* min interpacket interval */
+
+/*
+ * Count number of restriction entries referring to RES_LIMITED controls
+ * activation/deactivation of monitoring (with respect to RES_LIMITED
+ * control)
+ */
+static u_long res_limited_refcnt;
+static u_long res_limited_refcnt6;
+
+/*
+ * Our initial allocation of lists entries.
+ */
+static struct restrictlist resinit[INITRESLIST];
+static struct restrictlist6 resinit6[INITRESLIST];
+
+/*
+ * init_restrict - initialize the restriction data structures
+ */
+void
+init_restrict(void)
+{
+       register int i;
+
+       /*
+        * Zero the list and put all but one on the free list
+        */
+       resfree = NULL;
+       memset((char *)resinit, 0, sizeof resinit);
+       resfree6 = NULL;
+       memset((char *)resinit6, 0, sizeof resinit6);
+       for (i = 1; i < INITRESLIST; i++) {
+               resinit[i].next = resfree;
+               resinit6[i].next = resfree6;
+               resfree = &resinit[i];
+               resfree6 = &resinit6[i];
+       }
+       numresfree = INITRESLIST-1;
+       numresfree6 = INITRESLIST-1;
+
+       /*
+        * Put the remaining item at the head of the list as our default
+        * entry. Everything in here should be zero for now.
+        */
+       resinit[0].addr = htonl(INADDR_ANY);
+       resinit[0].mask = 0;
+       memset(&resinit6[0].addr6, 0, sizeof(struct in6_addr)); 
+       memset(&resinit6[0].mask6, 0, sizeof(struct in6_addr)); 
+       restrictlist = &resinit[0];
+       restrictlist6 = &resinit6[0];
+       restrictcount = 1;
+       restrictcount = 2;
+
+       /*
+        * fix up stat counters
+        */
+       res_calls = 0;
+       res_found = 0;
+       res_not_found = 0;
+
+       /*
+        * set default values for RES_LIMIT functionality
+        */
+       res_limited_refcnt = 0;
+       res_limited_refcnt6 = 0;
+}
+
+
+/*
+ * restrictions - return restrictions for this host
+ */
+int
+restrictions(
+       struct sockaddr_storage *srcadr,
+       int at_listhead
+       )
+{
+       struct restrictlist *rl;
+       struct restrictlist *match = NULL;
+       struct restrictlist6 *rl6;
+       struct restrictlist6 *match6 = NULL;
+       struct in6_addr hostaddr6;
+       struct in6_addr hostservaddr6;
+       u_int32 hostaddr;
+       int     flags = 0;
+       int     isntpport;
+
+       res_calls++;
+       if (srcadr->ss_family == AF_INET) {
+               /*
+                * We need the host address in host order.  Also need to
+                * know whether this is from the ntp port or not.
+                */
+               hostaddr = SRCADR(srcadr);
+               isntpport = (SRCPORT(srcadr) == NTP_PORT);
+
+               /*
+                * Ignore any packets with a multicast source address
+                * (this should be done early in the receive process,
+                * later!)
+                */
+               if (IN_CLASSD(SRCADR(srcadr)))
+                       return (int)RES_IGNORE;
+
+               /*
+                * Set match to first entry, which is default entry.
+                * Work our way down from there.
+                */
+               match = restrictlist;
+               for (rl = match->next; rl != NULL && rl->addr <= hostaddr;
+                   rl = rl->next)
+                       if ((hostaddr & rl->mask) == rl->addr) {
+                               if ((rl->mflags & RESM_NTPONLY) &&
+                                   !isntpport)
+                                       continue;
+                               match = rl;
+                       }
+               match->count++;
+               if (match == restrictlist)
+                       res_not_found++;
+               else
+                       res_found++;
+               flags = match->flags;
+       }
+
+       /* IPv6 source address */
+       if (srcadr->ss_family == AF_INET6) {
+               /*
+                * Need to know whether this is from the ntp port or
+                * not.
+                */
+               hostaddr6 = GET_INADDR6(*srcadr);
+               isntpport = (ntohs((
+                   (struct sockaddr_in6 *)srcadr)->sin6_port) ==
+                   NTP_PORT);
+
+               /*
+                * Ignore any packets with a multicast source address
+                * (this should be done early in the receive process,
+                * later!)
+                */
+               if (IN6_IS_ADDR_MULTICAST(&hostaddr6))
+                       return (int)RES_IGNORE;
+
+               /*
+                * Set match to first entry, which is default entry.
+                *  Work our way down from there.
+                */
+               match6 = restrictlist6;
+               for (rl6 = match6->next; rl6 != NULL &&
+                   (memcmp(&(rl6->addr6), &hostaddr6,
+                   sizeof(hostaddr6)) <= 0); rl6 = rl6->next) {
+                       SET_IPV6_ADDR_MASK(&hostservaddr6, &hostaddr6,
+                           &rl6->mask6);
+                       if (memcmp(&hostservaddr6, &(rl6->addr6),
+                           sizeof(hostservaddr6)) == 0) {
+                               if ((rl6->mflags & RESM_NTPONLY) &&
+                                   !isntpport)
+                                       continue;
+                               match6 = rl6;
+                       }
+               }
+               match6->count++;
+               if (match6 == restrictlist6)
+                       res_not_found++;
+               else
+                       res_found++;
+               flags = match6->flags;
+       }
+
+       /*
+        * The following implements a generalized call gap facility.
+        * Douse the RES_LIMITED bit only if the interval since the last
+        * packet is greater than res_min_interval and the average is
+        * greater thatn res_avg_interval.
+        */
+       if (!at_listhead || mon_enabled == MON_OFF) {
+               flags &= ~RES_LIMITED;
+       } else {
+               struct mon_data *md;
+
+               /*
+                * At this poin the most recent arrival is first in the
+                * MRU list. Let the first 10 packets in for free until
+                * the average stabilizes.
+                */
+               md = mon_mru_list.mru_next;
+               if (md->avg_interval == 0)
+                       md->avg_interval = md->drop_count;
+               else
+                       md->avg_interval += (md->drop_count -
+                           md->avg_interval) / RES_AVG;
+               if (md->count < 10 || (md->drop_count >
+                   res_min_interval && md->avg_interval >
+                   res_avg_interval))
+                       flags &= ~RES_LIMITED;
+               md->drop_count = flags;
+       }
+       return (flags);
+}
+
+
+/*
+ * hack_restrict - add/subtract/manipulate entries on the restrict list
+ */
+void
+hack_restrict(
+       int op,
+       struct sockaddr_storage *resaddr,
+       struct sockaddr_storage *resmask,
+       int mflags,
+       int flags
+       )
+{
+       register u_int32 addr = 0;
+       register u_int32 mask = 0;
+       struct in6_addr addr6;
+       struct in6_addr mask6;
+       register struct restrictlist *rl = NULL;
+       register struct restrictlist *rlprev = NULL;
+       register struct restrictlist6 *rl6 = NULL;
+       register struct restrictlist6 *rlprev6 = NULL;
+       int i, addr_cmp, mask_cmp;
+       memset(&addr6, 0, sizeof(struct in6_addr)); 
+       memset(&mask6, 0, sizeof(struct in6_addr)); 
+
+       if (resaddr->ss_family == AF_INET) {
+               /*
+                * Get address and mask in host byte order
+                */
+               addr = SRCADR(resaddr);
+               mask = SRCADR(resmask);
+               addr &= mask;           /* make sure low bits zero */
+
+               /*
+                * If this is the default address, point at first on
+                * list. Else go searching for it.
+                */
+               if (addr == 0) {
+                       rlprev = NULL;
+                       rl = restrictlist;
+               } else {
+                       rlprev = restrictlist;
+                       rl = rlprev->next;
+                       while (rl != NULL) {
+                               if (rl->addr > addr) {
+                                       rl = NULL;
+                                       break;
+                               } else if (rl->addr == addr) {
+                                       if (rl->mask == mask) {
+                                               if ((mflags &
+                                                   RESM_NTPONLY) ==
+                                                   (rl->mflags &
+                                                   RESM_NTPONLY))
+                                                       break;
+
+                                               if (!(mflags &
+                                                   RESM_NTPONLY)) {
+                                                       rl = NULL;
+                                                       break;
+                                               }
+                                       } else if (rl->mask > mask) {
+                                               rl = NULL;
+                                               break;
+                                       }
+                               }
+                               rlprev = rl;
+                               rl = rl->next;
+                       }
+               }
+       }
+
+       if (resaddr->ss_family == AF_INET6) {
+               mask6 = GET_INADDR6(*resmask);
+               SET_IPV6_ADDR_MASK(&addr6,
+                   &GET_INADDR6(*resaddr), &mask6);
+               if (IN6_IS_ADDR_UNSPECIFIED(&addr6)) {
+                       rlprev6 = NULL;
+                       rl6 = restrictlist6;
+               } else {
+                       rlprev6 = restrictlist6;
+                       rl6 = rlprev6->next;
+                       while (rl6 != NULL) {
+                               addr_cmp = memcmp(&rl6->addr6, &addr6,
+                                   sizeof(addr6));
+                               if (addr_cmp > 0) {
+                                       rl6 = NULL;
+                                       break;
+                               } else if (addr_cmp == 0) {
+                                       mask_cmp = memcmp(&rl6->mask6,
+                                           &mask6, sizeof(mask6));
+                                       if (mask_cmp == 0) {
+                                               if ((mflags &
+                                                   RESM_NTPONLY) ==
+                                                   (rl6->mflags &
+                                                   RESM_NTPONLY))
+                                                       break;
+
+                                               if (!(mflags &
+                                                   RESM_NTPONLY)) {
+                                                       rl6 = NULL;
+                                                       break;
+                                               }
+                                       } else if (mask_cmp > 0) {
+                                               rl6 = NULL;
+                                               break;
+                                       }
+                               }
+                               rlprev6 = rl6;
+                               rl6 = rl6->next;
+                       }
+               }
+       }
+
+       /*
+        * In case the above wasn't clear :-), either rl now points
+        * at the entry this call refers to, or rl is zero and rlprev
+        * points to the entry prior to where this one should go in
+        * the sort.
+        */
+
+       /*
+        * Switch based on operation
+        */
+       if (resaddr->ss_family == AF_INET) {
+               switch (op) {
+               case RESTRICT_FLAGS:
+                       /*
+                        * Here we add bits to the flags. If this is a
+                        * new restriction add it.
+                        */
+                       if (rl == NULL) {
+                               if (resfree == NULL) {
+                                       rl = (struct restrictlist *)
+                                           emalloc(INCRESLIST *
+                                           sizeof(struct
+                                           restrictlist));
+                                       memset((char *)rl, 0,
+                                           INCRESLIST * sizeof(struct
+                                           restrictlist));
+                                       for (i = 0; i < INCRESLIST; i++) {
+                                               rl->next = resfree;
+                                               resfree = rl;
+                                               rl++;
+                                       }
+                                       numresfree = INCRESLIST;
+                               }
+
+                               rl = resfree;
+                               resfree = rl->next;
+                               numresfree--;
+
+                               rl->addr = addr;
+                               rl->mask = mask;
+                               rl->mflags = (u_short)mflags;
+
+                               if (rlprev == NULL) {
+                                       rl->next = restrictlist;
+                                       restrictlist = rl;
+                               } else {
+                                       rl->next = rlprev->next;
+                                       rlprev->next = rl;
+                               }
+                               restrictcount++;
+                       }
+                       if ((rl->flags ^ (u_short)flags) &
+                           RES_LIMITED) {
+                               res_limited_refcnt++;
+                               mon_start(MON_RES);
+                       }
+                       rl->flags |= (u_short)flags;
+                       break;
+
+               case RESTRICT_UNFLAG:
+                       /*
+                        * Remove some bits from the flags. If we didn't
+                        * find this one, just return.
+                        */
+                       if (rl != NULL) {
+                               if ((rl->flags ^ (u_short)flags) &
+                                   RES_LIMITED) {
+                                       res_limited_refcnt--;
+                                       if (res_limited_refcnt == 0)
+                                               mon_stop(MON_RES);
+                               }
+                               rl->flags &= (u_short)~flags;
+                       }
+                       break;
+       
+               case RESTRICT_REMOVE:
+               case RESTRICT_REMOVEIF:
+                       /*
+                        * Remove an entry from the table entirely if we
+                        * found one. Don't remove the default entry and
+                        * don't remove an interface entry.
+                        */
+                       if (rl != NULL
+                           && rl->addr != htonl(INADDR_ANY)
+                           && !(rl->mflags & RESM_INTERFACE && op != RESTRICT_REMOVEIF)) {
+                               if (rlprev != NULL) {
+                                       rlprev->next = rl->next;
+                               } else {
+                                       restrictlist = rl->next;
+                               }
+                               restrictcount--;
+                               if (rl->flags & RES_LIMITED) {
+                                       res_limited_refcnt--;
+                                       if (res_limited_refcnt == 0)
+                                               mon_stop(MON_RES);
+                               }
+                               memset((char *)rl, 0,
+                                   sizeof(struct restrictlist));
+
+                               rl->next = resfree;
+                               resfree = rl;
+                               numresfree++;
+                       }
+                       break;
+
+               default:
+                       break;
+               }
+       } else if (resaddr->ss_family == AF_INET6) {
+               switch (op) {
+               case RESTRICT_FLAGS:
+                       /*
+                        * Here we add bits to the flags. If this is a
+                        * new restriction add it.
+                        */
+                       if (rl6 == NULL) {
+                               if (resfree6 == NULL) {
+                                       rl6 = (struct
+                                           restrictlist6 *)emalloc(
+                                           INCRESLIST * sizeof(struct
+                                           restrictlist6));
+                                       memset((char *)rl6, 0,
+                                           INCRESLIST * sizeof(struct
+                                           restrictlist6));
+
+                                       for (i = 0; i < INCRESLIST;
+                                           i++) {
+                                               rl6->next = resfree6;
+                                               resfree6 = rl6;
+                                               rl6++;
+                                       }
+                                       numresfree6 = INCRESLIST;
+                               }
+                               rl6 = resfree6;
+                               resfree6 = rl6->next;
+                               numresfree6--;
+                               rl6->addr6 = addr6;
+                               rl6->mask6 = mask6;
+                               rl6->mflags = (u_short)mflags;
+                               if (rlprev6 != NULL) {
+                                       rl6->next = rlprev6->next;
+                                       rlprev6->next = rl6;
+                               } else {
+                                       rl6->next = restrictlist6;
+                                       restrictlist6 = rl6;
+                               }
+                               restrictcount6++;
+                       }
+                       if ((rl6->flags ^ (u_short)flags) &
+                           RES_LIMITED) {
+                               res_limited_refcnt6++;
+                               mon_start(MON_RES);
+                       }
+                       rl6->flags |= (u_short)flags;
+                       break;
+
+               case RESTRICT_UNFLAG:
+                       /*
+                        * Remove some bits from the flags. If we didn't
+                        * find this one, just return.
+                        */
+                       if (rl6 != NULL) {
+                               if ((rl6->flags ^ (u_short)flags) &
+                                   RES_LIMITED) {
+                                       res_limited_refcnt6--;
+                                       if (res_limited_refcnt6 == 0)
+                                               mon_stop(MON_RES);
+                               }
+                               rl6->flags &= (u_short)~flags;
+                       }
+                       break;
+
+               case RESTRICT_REMOVE:
+               case RESTRICT_REMOVEIF:
+                       /*
+                        * Remove an entry from the table entirely if we
+                        * found one. Don't remove the default entry and
+                        * don't remove an interface entry.
+                        */
+                       if (rl6 != NULL &&
+                           !IN6_IS_ADDR_UNSPECIFIED(&rl6->addr6)
+                           && !(rl6->mflags & RESM_INTERFACE && op != RESTRICT_REMOVEIF)) {
+                               if (rlprev6 != NULL) {
+                                       rlprev6->next = rl6->next;
+                               } else {
+                                       restrictlist6 = rl6->next;
+                               }
+                               restrictcount6--;
+                               if (rl6->flags & RES_LIMITED) {
+                                       res_limited_refcnt6--;
+                                       if (res_limited_refcnt6 == 0)
+                                               mon_stop(MON_RES);
+                               }
+                               memset((char *)rl6, 0,
+                                   sizeof(struct restrictlist6));
+                               rl6->next = resfree6;
+                               resfree6 = rl6;
+                               numresfree6++;
+                       }
+                       break;
+
+               default:
+                       break;
+               }
+       }
+}
diff --git a/ntpd/ntp_timer.c b/ntpd/ntp_timer.c
new file mode 100644 (file)
index 0000000..812206a
--- /dev/null
@@ -0,0 +1,407 @@
+/*
+ * ntp_timer.c - event timer support routines
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntp_machine.h"
+#include "ntpd.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <signal.h>
+#ifdef HAVE_SYS_SIGNAL_H
+# include <sys/signal.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#if defined(HAVE_IO_COMPLETION_PORT)
+# include "ntp_iocompletionport.h"
+# include "ntp_timer.h"
+#endif
+
+/*
+ * These routines provide support for the event timer. The timer is
+ * implemented by an interrupt routine which sets a flag once every
+ * 2**EVENT_TIMEOUT seconds (currently 4), and a timer routine which
+ * is called when the mainline code gets around to seeing the flag.
+ * The timer routine dispatches the clock adjustment code if its time
+ * has come, then searches the timer queue for expiries which are
+ * dispatched to the transmit procedure.  Finally, we call the hourly
+ * procedure to do cleanup and print a message.
+ */
+
+volatile int interface_interval = 300;     /* update interface every 5 minutes as default */
+         
+/*
+ * Alarm flag. The mainline code imports this.
+ */
+volatile int alarm_flag;
+
+/*
+ * The counters
+ */
+static u_long adjust_timer;            /* second timer */
+static u_long keys_timer;              /* minute timer */
+static u_long stats_timer;             /* stats timer */
+static u_long huffpuff_timer;          /* huff-n'-puff timer */
+static  u_long interface_timer;                /* interface update timer */
+#ifdef OPENSSL
+static u_long revoke_timer;            /* keys revoke timer */
+u_char sys_revoke = KEY_REVOKE;        /* keys revoke timeout (log2 s) */
+#endif /* OPENSSL */
+
+/*
+ * Statistics counter for the interested.
+ */
+volatile u_long alarm_overflow;
+
+#define MINUTE 60
+#define HOUR   (60*60)
+
+u_long current_time;
+
+/*
+ * Stats.  Number of overflows and number of calls to transmit().
+ */
+u_long timer_timereset;
+u_long timer_overflows;
+u_long timer_xmtcalls;
+
+#if defined(VMS)
+static int vmstimer[2];        /* time for next timer AST */
+static int vmsinc[2];          /* timer increment */
+#endif /* VMS */
+
+#if defined SYS_WINNT
+static HANDLE WaitableTimerHandle = NULL;
+#else
+static RETSIGTYPE alarming P((int));
+#endif /* SYS_WINNT */
+
+#if !defined(VMS)
+# if !defined SYS_WINNT || defined(SYS_CYGWIN32)
+#  ifndef HAVE_TIMER_SETTIME
+       struct itimerval itimer;
+#  else 
+       static timer_t ntpd_timerid;
+       struct itimerspec itimer;
+#  endif /* HAVE_TIMER_SETTIME */
+# endif /* SYS_WINNT */
+#endif /* VMS */
+
+/*
+ * reinit_timer - reinitialize interval timer.
+ */
+void 
+reinit_timer(void)
+{
+#if !defined(SYS_WINNT) && !defined(VMS)
+#  if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME)
+       timer_gettime(ntpd_timerid, &itimer);
+       if (itimer.it_value.tv_sec < 0 || itimer.it_value.tv_sec > (1<<EVENT_TIMEOUT)) {
+               itimer.it_value.tv_sec = (1<<EVENT_TIMEOUT);
+       }
+       if (itimer.it_value.tv_nsec < 0 ) {
+               itimer.it_value.tv_nsec = 0;
+       }
+       if (itimer.it_value.tv_sec == 0 && itimer.it_value.tv_nsec == 0) {
+               itimer.it_value.tv_sec = (1<<EVENT_TIMEOUT);
+               itimer.it_value.tv_nsec = 0;
+       }
+       itimer.it_interval.tv_sec = (1<<EVENT_TIMEOUT);
+       itimer.it_interval.tv_nsec = 0;
+       timer_settime(ntpd_timerid, 0 /*!TIMER_ABSTIME*/, &itimer, NULL);
+#  else
+       getitimer(ITIMER_REAL, &itimer);
+       if (itimer.it_value.tv_sec < 0 || itimer.it_value.tv_sec > (1<<EVENT_TIMEOUT)) {
+               itimer.it_value.tv_sec = (1<<EVENT_TIMEOUT);
+       }
+       if (itimer.it_value.tv_usec < 0 ) {
+               itimer.it_value.tv_usec = 0;
+       }
+       if (itimer.it_value.tv_sec == 0 && itimer.it_value.tv_usec == 0) {
+               itimer.it_value.tv_sec = (1<<EVENT_TIMEOUT);
+               itimer.it_value.tv_usec = 0;
+       }
+       itimer.it_interval.tv_sec = (1<<EVENT_TIMEOUT);
+       itimer.it_interval.tv_usec = 0;
+       setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
+#  endif
+# endif /* VMS */
+}
+
+/*
+ * init_timer - initialize the timer data structures
+ */
+void
+init_timer(void)
+{
+# if defined SYS_WINNT & !defined(SYS_CYGWIN32)
+       HANDLE hToken = INVALID_HANDLE_VALUE;
+       TOKEN_PRIVILEGES tkp;
+# endif /* SYS_WINNT */
+
+       /*
+        * Initialize...
+        */
+       alarm_flag = 0;
+       alarm_overflow = 0;
+       adjust_timer = 1;
+       stats_timer = 0;
+       huffpuff_timer = 0;
+       interface_timer = 0;
+       current_time = 0;
+       timer_overflows = 0;
+       timer_xmtcalls = 0;
+       timer_timereset = 0;
+
+#if !defined(SYS_WINNT)
+       /*
+        * Set up the alarm interrupt.  The first comes 2**EVENT_TIMEOUT
+        * seconds from now and they continue on every 2**EVENT_TIMEOUT
+        * seconds.
+        */
+# if !defined(VMS)
+#  if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME)
+       if (timer_create (CLOCK_REALTIME, NULL, &ntpd_timerid) ==
+#      ifdef SYS_VXWORKS
+               ERROR
+#      else
+               -1
+#      endif
+          )
+       {
+               fprintf (stderr, "timer create FAILED\n");
+               exit (0);
+       }
+       (void) signal_no_reset(SIGALRM, alarming);
+       itimer.it_interval.tv_sec = itimer.it_value.tv_sec = (1<<EVENT_TIMEOUT);
+       itimer.it_interval.tv_nsec = itimer.it_value.tv_nsec = 0;
+       timer_settime(ntpd_timerid, 0 /*!TIMER_ABSTIME*/, &itimer, NULL);
+#  else
+       (void) signal_no_reset(SIGALRM, alarming);
+       itimer.it_interval.tv_sec = itimer.it_value.tv_sec = (1<<EVENT_TIMEOUT);
+       itimer.it_interval.tv_usec = itimer.it_value.tv_usec = 0;
+       setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
+#  endif
+# else /* VMS */
+       vmsinc[0] = 10000000;           /* 1 sec */
+       vmsinc[1] = 0;
+       lib$emul(&(1<<EVENT_TIMEOUT), &vmsinc, &0, &vmsinc);
+
+       sys$gettim(&vmstimer);  /* that's "now" as abstime */
+
+       lib$addx(&vmsinc, &vmstimer, &vmstimer);
+       sys$setimr(0, &vmstimer, alarming, alarming, 0);
+# endif /* VMS */
+#else /* SYS_WINNT */
+       _tzset();
+
+       /*
+        * Get privileges needed for fiddling with the clock
+        */
+
+       /* get the current process token handle */
+       if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
+               msyslog(LOG_ERR, "OpenProcessToken failed: %m");
+               exit(1);
+       }
+       /* get the LUID for system-time privilege. */
+       LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkp.Privileges[0].Luid);
+       tkp.PrivilegeCount = 1;  /* one privilege to set */
+       tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+       /* get set-time privilege for this process. */
+       AdjustTokenPrivileges(hToken, FALSE, &tkp, 0, (PTOKEN_PRIVILEGES) NULL, 0);
+       /* cannot test return value of AdjustTokenPrivileges. */
+       if (GetLastError() != ERROR_SUCCESS) {
+               msyslog(LOG_ERR, "AdjustTokenPrivileges failed: %m");
+       }
+
+       /*
+        * Set up timer interrupts for every 2**EVENT_TIMEOUT seconds
+        * Under Windows/NT, 
+        */
+
+       WaitableTimerHandle = CreateWaitableTimer(NULL, FALSE, NULL);
+       if (WaitableTimerHandle == NULL) {
+               msyslog(LOG_ERR, "CreateWaitableTimer failed: %m");
+               exit(1);
+       }
+       else {
+               DWORD Period = (1<<EVENT_TIMEOUT) * 1000;
+               LARGE_INTEGER DueTime;
+               DueTime.QuadPart = Period * 10000i64;
+               if (!SetWaitableTimer(WaitableTimerHandle, &DueTime, Period, NULL, NULL, FALSE) != NO_ERROR) {
+                       msyslog(LOG_ERR, "SetWaitableTimer failed: %m");
+                       exit(1);
+               }
+       }
+
+#endif /* SYS_WINNT */
+}
+
+#if defined(SYS_WINNT)
+extern HANDLE 
+get_timer_handle(void)
+{
+       return WaitableTimerHandle;
+}
+#endif
+
+/*
+ * timer - dispatch anyone who needs to be
+ */
+void
+timer(void)
+{
+       register struct peer *peer, *next_peer;
+#ifdef OPENSSL
+       char    statstr[NTP_MAXSTRLEN]; /* statistics for filegen */
+#endif /* OPENSSL */
+       u_int n;
+
+       current_time += (1<<EVENT_TIMEOUT);
+
+       /*
+        * Adjustment timeout first.
+        */
+       if (adjust_timer <= current_time) {
+               adjust_timer += 1;
+               adj_host_clock();
+               kod_proto();
+#ifdef REFCLOCK
+               for (n = 0; n < NTP_HASH_SIZE; n++) {
+                       for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
+                               next_peer = peer->next;
+                               if (peer->flags & FLAG_REFCLOCK)
+                                       refclock_timer(peer);
+                       }
+               }
+#endif /* REFCLOCK */
+       }
+
+       /*
+        * Now dispatch any peers whose event timer has expired. Be careful
+        * here, since the peer structure might go away as the result of
+        * the call.
+        */
+       for (n = 0; n < NTP_HASH_SIZE; n++) {
+               for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
+                       next_peer = peer->next;
+                       if (peer->action && peer->nextaction <= current_time)
+                               peer->action(peer);
+                       if (peer->nextdate <= current_time) {
+#ifdef REFCLOCK
+                               if (peer->flags & FLAG_REFCLOCK)
+                                       refclock_transmit(peer);
+                               else
+                                       transmit(peer);
+#else /* REFCLOCK */
+                               transmit(peer);
+#endif /* REFCLOCK */
+                       }
+               }
+       }
+
+       /*
+        * Garbage collect expired keys.
+        */
+       if (keys_timer <= current_time) {
+               keys_timer += MINUTE;
+               auth_agekeys();
+       }
+
+       /*
+        * Huff-n'-puff filter
+        */
+       if (huffpuff_timer <= current_time) {
+               huffpuff_timer += HUFFPUFF;
+               huffpuff();
+       }
+
+#ifdef OPENSSL
+       /*
+        * Garbage collect old keys and generate new private value
+        */
+       if (revoke_timer <= current_time) {
+               revoke_timer += RANDPOLL(sys_revoke);
+               expire_all();
+               sprintf(statstr, "refresh ts %u", ntohl(hostval.tstamp));
+               record_crypto_stats(NULL, statstr);
+#ifdef DEBUG
+               if (debug)
+                       printf("timer: %s\n", statstr);
+#endif
+       }
+#endif /* OPENSSL */
+
+       /*
+        * interface update timer
+        */
+       if (interface_interval && interface_timer <= current_time) {
+
+               timer_interfacetimeout(current_time + interface_interval);
+               DPRINTF(1, ("timer: interface update\n"));
+               interface_update(NULL, NULL);
+       }
+       
+       /*
+        * Finally, periodically write stats.
+        */
+       if (stats_timer <= current_time) {
+            if (stats_timer != 0)
+                 write_stats();
+            stats_timer += stats_write_period;
+       }
+}
+
+
+#ifndef SYS_WINNT
+/*
+ * alarming - tell the world we've been alarmed
+ */
+static RETSIGTYPE
+alarming(
+       int sig
+       )
+{
+#if !defined(VMS)
+       if (initializing)
+               return;
+       if (alarm_flag)
+               alarm_overflow++;
+       else
+               alarm_flag++;
+#else /* VMS AST routine */
+       if (!initializing) {
+               if (alarm_flag) alarm_overflow++;
+               else alarm_flag = 1;    /* increment is no good */
+       }
+       lib$addx(&vmsinc,&vmstimer,&vmstimer);
+       sys$setimr(0,&vmstimer,alarming,alarming,0);
+#endif /* VMS */
+}
+#endif /* SYS_WINNT */
+
+void
+timer_interfacetimeout(u_long timeout)
+{
+       interface_timer = timeout;
+}
+
+
+/*
+ * timer_clr_stats - clear timer module stat counters
+ */
+void
+timer_clr_stats(void)
+{
+       timer_overflows = 0;
+       timer_xmtcalls = 0;
+       timer_timereset = current_time;
+}
+
diff --git a/ntpd/ntp_util.c b/ntpd/ntp_util.c
new file mode 100644 (file)
index 0000000..91ff8a6
--- /dev/null
@@ -0,0 +1,801 @@
+/*
+ * ntp_util.c - stuff I didn't have any other place for
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_unixtime.h"
+#include "ntp_filegen.h"
+#include "ntp_if.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <sys/types.h>
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+
+#ifdef HAVE_IEEEFP_H
+# include <ieeefp.h>
+#endif
+#ifdef HAVE_MATH_H
+# include <math.h>
+#endif
+
+#ifdef  DOSYNCTODR
+# if !defined(VMS)
+#  include <sys/resource.h>
+# endif /* VMS */
+#endif
+
+#if defined(VMS)
+# include <descrip.h>
+#endif /* VMS */
+
+/*
+ * This contains odds and ends.  Right now the only thing you'll find
+ * in here is the hourly stats printer and some code to support
+ * rereading the keys file, but I may eventually put other things in
+ * here such as code to do something with the leap bits.
+ */
+/*
+ * Name of the keys file
+ */
+static char *key_file_name;
+
+/*
+ * The name of the drift_comp file and the temporary.
+ */
+static char *stats_drift_file;
+static char *stats_temp_file;
+int stats_write_period = 3600; /* # of seconds between writes. */
+double stats_write_tolerance = 0;
+static double prev_drift_comp = 99999.;
+
+/*
+ * Statistics file stuff
+ */
+#ifndef NTP_VAR
+# ifndef SYS_WINNT
+#  define NTP_VAR "/var/NTP/"          /* NOTE the trailing '/' */
+# else
+#  define NTP_VAR "c:\\var\\ntp\\"             /* NOTE the trailing '\\' */
+# endif /* SYS_WINNT */
+#endif
+
+#ifndef MAXPATHLEN
+# define MAXPATHLEN 256
+#endif
+
+static char statsdir[MAXPATHLEN] = NTP_VAR;
+
+static FILEGEN peerstats;
+static FILEGEN loopstats;
+static FILEGEN clockstats;
+static FILEGEN rawstats;
+static FILEGEN sysstats;
+#ifdef DEBUG_TIMING
+static FILEGEN timingstats;
+#endif
+#ifdef OPENSSL
+static FILEGEN cryptostats;
+#endif /* OPENSSL */
+
+/*
+ * This controls whether stats are written to the fileset. Provided
+ * so that ntpdc can turn off stats when the file system fills up. 
+ */
+int stats_control;
+
+/*
+ * Initial frequency offset later passed to the loopfilter.
+ */
+double old_drift;
+
+/*
+ * init_util - initialize the utilities
+ */
+void
+init_util(void)
+{
+       stats_drift_file = 0;
+       stats_temp_file = 0;
+       key_file_name = 0;
+
+       filegen_register(&statsdir[0], "peerstats", &peerstats);
+
+       filegen_register(&statsdir[0], "loopstats", &loopstats);
+
+       filegen_register(&statsdir[0], "clockstats", &clockstats);
+
+       filegen_register(&statsdir[0], "rawstats", &rawstats);
+
+       filegen_register(&statsdir[0], "sysstats", &sysstats);
+
+#ifdef OPENSSL
+       filegen_register(&statsdir[0], "cryptostats", &cryptostats);
+#endif /* OPENSSL */
+
+#ifdef DEBUG_TIMING
+       filegen_register(&statsdir[0], "timingstats", &timingstats);
+#endif
+}
+
+
+/*
+ * hourly_stats - print some interesting stats
+ */
+void
+write_stats(void)
+{
+       FILE *fp;
+
+#ifdef DOSYNCTODR
+       struct timeval tv;
+#if !defined(VMS)
+       int prio_set;
+#endif
+#ifdef HAVE_GETCLOCK
+        struct timespec ts;
+#endif
+       int o_prio;
+
+       /*
+        * Sometimes having a Sun can be a drag.
+        *
+        * The kernel variable dosynctodr controls whether the system's
+        * soft clock is kept in sync with the battery clock. If it
+        * is zero, then the soft clock is not synced, and the battery
+        * clock is simply left to rot. That means that when the system
+        * reboots, the battery clock (which has probably gone wacky)
+        * sets the soft clock. That means ntpd starts off with a very
+        * confused idea of what time it is. It then takes a large
+        * amount of time to figure out just how wacky the battery clock
+        * has made things drift, etc, etc. The solution is to make the
+        * battery clock sync up to system time. The way to do THAT is
+        * to simply set the time of day to the current time of day, but
+        * as quickly as possible. This may, or may not be a sensible
+        * thing to do.
+        *
+        * CAVEAT: settimeofday() steps the sun clock by about 800 us,
+        *         so setting DOSYNCTODR seems a bad idea in the
+        *         case of us resolution
+        */
+
+#if !defined(VMS)
+       /* (prr) getpriority returns -1 on error, but -1 is also a valid
+        * return value (!), so instead we have to zero errno before the
+        * call and check it for non-zero afterwards.
+        */
+       errno = 0;
+       prio_set = 0;
+       o_prio = getpriority(PRIO_PROCESS,0); /* Save setting */
+
+       /*
+        * (prr) if getpriority succeeded, call setpriority to raise
+        * scheduling priority as high as possible.  If that succeeds
+        * as well, set the prio_set flag so we remember to reset
+        * priority to its previous value below.  Note that on Solaris
+        * 2.6 (and beyond?), both getpriority and setpriority will fail
+        * with ESRCH, because sched_setscheduler (called from main) put
+        * us in the real-time scheduling class which setpriority
+        * doesn't know about. Being in the real-time class is better
+        * than anything setpriority can do, anyhow, so this error is
+        * silently ignored.
+        */
+       if ((errno == 0) && (setpriority(PRIO_PROCESS,0,-20) == 0))
+               prio_set = 1;   /* overdrive */
+#endif /* VMS */
+#ifdef HAVE_GETCLOCK
+        (void) getclock(TIMEOFDAY, &ts);
+        tv.tv_sec = ts.tv_sec;
+        tv.tv_usec = ts.tv_nsec / 1000;
+#else /*  not HAVE_GETCLOCK */
+       GETTIMEOFDAY(&tv,(struct timezone *)NULL);
+#endif /* not HAVE_GETCLOCK */
+       if (ntp_set_tod(&tv,(struct timezone *)NULL) != 0) {
+               msyslog(LOG_ERR, "can't sync battery time: %m");
+       }
+#if !defined(VMS)
+       if (prio_set)
+               setpriority(PRIO_PROCESS, 0, o_prio); /* downshift */
+#endif /* VMS */
+#endif /* DOSYNCTODR */
+
+       NLOG(NLOG_SYSSTATIST)
+               msyslog(LOG_INFO,
+                   "offset %.6f sec freq %.3f ppm error %.6f poll %d",
+                   last_offset, drift_comp * 1e6, sys_jitter,
+                   sys_poll);
+
+       
+       record_sys_stats();
+       if ((u_long)(fabs(prev_drift_comp - drift_comp) * 1e9) <=
+           (u_long)(fabs(stats_write_tolerance * drift_comp) * 1e9)) {
+            return;
+       }
+       prev_drift_comp = drift_comp;
+       if (stats_drift_file != 0) {
+               if ((fp = fopen(stats_temp_file, "w")) == NULL) {
+                       msyslog(LOG_ERR, "can't open %s: %m",
+                           stats_temp_file);
+                       return;
+               }
+               fprintf(fp, "%.3f\n", drift_comp * 1e6);
+               (void)fclose(fp);
+               /* atomic */
+#ifdef SYS_WINNT
+               (void) _unlink(stats_drift_file); /* rename semantics differ under NT */
+#endif /* SYS_WINNT */
+
+#ifndef NO_RENAME
+               (void) rename(stats_temp_file, stats_drift_file);
+#else
+               /* we have no rename NFS of ftp in use */
+               if ((fp = fopen(stats_drift_file, "w")) == NULL) {
+                       msyslog(LOG_ERR, "can't open %s: %m",
+                           stats_drift_file);
+                       return;
+               }
+
+#endif
+
+#if defined(VMS)
+               /* PURGE */
+               {
+                       $DESCRIPTOR(oldvers,";-1");
+                       struct dsc$descriptor driftdsc = {
+                               strlen(stats_drift_file),0,0,stats_drift_file };
+
+                       while(lib$delete_file(&oldvers,&driftdsc) & 1) ;
+               }
+#endif
+       }
+}
+
+
+/*
+ * stats_config - configure the stats operation
+ */
+void
+stats_config(
+       int item,
+       const char *invalue     /* only one type so far */
+       )
+{
+       FILE *fp;
+       const char *value;
+       int len;
+
+       /*
+        * Expand environment strings under Windows NT, since the
+        * command interpreter doesn't do this, the program must.
+        */
+#ifdef SYS_WINNT
+       char newvalue[MAX_PATH], parameter[MAX_PATH];
+
+       if (!ExpandEnvironmentStrings(invalue, newvalue, MAX_PATH)) {
+               switch(item) {
+                   case STATS_FREQ_FILE:
+                       strcpy(parameter,"STATS_FREQ_FILE");
+                       break;
+                   case STATS_STATSDIR:
+                       strcpy(parameter,"STATS_STATSDIR");
+                       break;
+                   case STATS_PID_FILE:
+                       strcpy(parameter,"STATS_PID_FILE");
+                       break;
+                   default:
+                       strcpy(parameter,"UNKNOWN");
+                       break;
+               }
+               value = invalue;
+
+               msyslog(LOG_ERR,
+                   "ExpandEnvironmentStrings(%s) failed: %m\n", parameter);
+       } else {
+               value = newvalue;
+       }
+#else    
+       value = invalue;
+#endif /* SYS_WINNT */
+
+       switch(item) {
+           case STATS_FREQ_FILE:
+               if (stats_drift_file != 0) {
+                       (void) free(stats_drift_file);
+                       (void) free(stats_temp_file);
+                       stats_drift_file = 0;
+                       stats_temp_file = 0;
+               }
+
+               if (value == 0 || (len = strlen(value)) == 0)
+                   break;
+
+               stats_drift_file = (char*)emalloc((u_int)(len + 1));
+#if !defined(VMS)
+               stats_temp_file = (char*)emalloc((u_int)(len +
+                   sizeof(".TEMP")));
+#else
+               stats_temp_file = (char*)emalloc((u_int)(len +
+                   sizeof("-TEMP")));
+#endif /* VMS */
+               memmove(stats_drift_file, value, (unsigned)(len+1));
+               memmove(stats_temp_file, value, (unsigned)len);
+#if !defined(VMS)
+               memmove(stats_temp_file + len, ".TEMP",
+                   sizeof(".TEMP"));
+#else
+               memmove(stats_temp_file + len, "-TEMP",
+                   sizeof("-TEMP"));
+#endif /* VMS */
+
+               /*
+                * Open drift file and read frequency. If the file is
+                * missing or contains errors, tell the loop to reset.
+                */
+               if ((fp = fopen(stats_drift_file, "r")) == NULL) {
+                       old_drift = 1e9;
+                       break;
+               }
+               if (fscanf(fp, "%lf", &old_drift) != 1) {
+                       msyslog(LOG_ERR, "Frequency format error in %s", 
+                           stats_drift_file);
+                       old_drift = 1e9;
+                       fclose(fp);
+                       break;
+               }
+               fclose(fp);
+               prev_drift_comp = old_drift / 1e6;
+               msyslog(LOG_INFO,
+                   "frequency initialized %.3f PPM from %s",
+                       old_drift, stats_drift_file);
+               break;
+       
+           case STATS_STATSDIR:
+               if (strlen(value) >= sizeof(statsdir)) {
+                       msyslog(LOG_ERR,
+                           "value for statsdir too long (>%d, sigh)",
+                           (int)sizeof(statsdir)-1);
+               } else {
+                       l_fp now;
+
+                       get_systime(&now);
+                       strcpy(statsdir,value);
+                       if(peerstats.prefix == &statsdir[0] &&
+                           peerstats.fp != NULL) {
+                               fclose(peerstats.fp);
+                               peerstats.fp = NULL;
+                               filegen_setup(&peerstats, now.l_ui);
+                       }
+                       if(loopstats.prefix == &statsdir[0] &&
+                           loopstats.fp != NULL) {
+                               fclose(loopstats.fp);
+                               loopstats.fp = NULL;
+                               filegen_setup(&loopstats, now.l_ui);
+                       }
+                       if(clockstats.prefix == &statsdir[0] &&
+                           clockstats.fp != NULL) {
+                               fclose(clockstats.fp);
+                               clockstats.fp = NULL;
+                               filegen_setup(&clockstats, now.l_ui);
+                       }
+                       if(rawstats.prefix == &statsdir[0] &&
+                           rawstats.fp != NULL) {
+                               fclose(rawstats.fp);
+                               rawstats.fp = NULL;
+                               filegen_setup(&rawstats, now.l_ui);
+                       }
+                       if(sysstats.prefix == &statsdir[0] &&
+                           sysstats.fp != NULL) {
+                               fclose(sysstats.fp);
+                               sysstats.fp = NULL;
+                               filegen_setup(&sysstats, now.l_ui);
+                       }
+#ifdef OPENSSL
+                       if(cryptostats.prefix == &statsdir[0] &&
+                           cryptostats.fp != NULL) {
+                               fclose(cryptostats.fp);
+                               cryptostats.fp = NULL;
+                               filegen_setup(&cryptostats, now.l_ui);
+                       }
+#endif /* OPENSSL */
+               }
+               break;
+
+           case STATS_PID_FILE:
+               if ((fp = fopen(value, "w")) == NULL) {
+                       msyslog(LOG_ERR, "Can't open %s: %m", value);
+                       break;
+               }
+               fprintf(fp, "%d", (int) getpid());
+               fclose(fp);;
+               break;
+
+           default:
+               /* oh well */
+               break;
+       }
+}
+
+/*
+ * record_peer_stats - write peer statistics to file
+ *
+ * file format:
+ * day (mjd)
+ * time (s past UTC midnight)
+ * peer (ip address)
+ * peer status word (hex)
+ * peer offset (s)
+ * peer delay (s)
+ * peer error bound (s)
+ * peer error (s)
+*/
+void
+record_peer_stats(
+       struct sockaddr_storage *addr,
+       int     status,
+       double  offset,
+       double  delay,
+       double  dispersion,
+       double  skew
+       )
+{
+       l_fp    now;
+       u_long  day;
+
+       if (!stats_control)
+               return;
+
+       get_systime(&now);
+       filegen_setup(&peerstats, now.l_ui);
+       day = now.l_ui / 86400 + MJD_1900;
+       now.l_ui %= 86400;
+       if (peerstats.fp != NULL) {
+               fprintf(peerstats.fp,
+                   "%lu %s %s %x %.9f %.9f %.9f %.9f\n",
+                   day, ulfptoa(&now, 3), stoa(addr), status, offset,
+                   delay, dispersion, skew);
+               fflush(peerstats.fp);
+       }
+}
+
+/*
+ * record_loop_stats - write loop filter statistics to file
+ *
+ * file format:
+ * day (mjd)
+ * time (s past midnight)
+ * offset (s)
+ * frequency (approx ppm)
+ * time constant (log base 2)
+ */
+void
+record_loop_stats(
+       double  offset,
+       double  freq,
+       double  jitter,
+       double  stability,
+       int spoll
+       )
+{
+       l_fp    now;
+       u_long  day;
+
+       if (!stats_control)
+               return;
+
+       get_systime(&now);
+       filegen_setup(&loopstats, now.l_ui);
+       day = now.l_ui / 86400 + MJD_1900;
+       now.l_ui %= 86400;
+       if (loopstats.fp != NULL) {
+               fprintf(loopstats.fp, "%lu %s %.9f %.3f %.9f %.6f %d\n",
+                   day, ulfptoa(&now, 3), offset, freq * 1e6, jitter,
+                   stability * 1e6, spoll);
+               fflush(loopstats.fp);
+       }
+}
+
+/*
+ * record_clock_stats - write clock statistics to file
+ *
+ * file format:
+ * day (mjd)
+ * time (s past midnight)
+ * peer (ip address)
+ * text message
+ */
+void
+record_clock_stats(
+       struct sockaddr_storage *addr,
+       const char *text
+       )
+{
+       l_fp    now;
+       u_long  day;
+
+       if (!stats_control)
+               return;
+
+       get_systime(&now);
+       filegen_setup(&clockstats, now.l_ui);
+       day = now.l_ui / 86400 + MJD_1900;
+       now.l_ui %= 86400;
+       if (clockstats.fp != NULL) {
+               fprintf(clockstats.fp, "%lu %s %s %s\n",
+                   day, ulfptoa(&now, 3), stoa(addr), text);
+               fflush(clockstats.fp);
+       }
+}
+
+/*
+ * record_raw_stats - write raw timestamps to file
+ *
+ *
+ * file format
+ * time (s past midnight)
+ * peer ip address
+ * local ip address
+ * t1 t2 t3 t4 timestamps
+ */
+void
+record_raw_stats(
+        struct sockaddr_storage *srcadr,
+        struct sockaddr_storage *dstadr,
+       l_fp    *t1,
+       l_fp    *t2,
+       l_fp    *t3,
+       l_fp    *t4
+       )
+{
+       l_fp    now;
+       u_long  day;
+
+       if (!stats_control)
+               return;
+
+       get_systime(&now);
+       filegen_setup(&rawstats, now.l_ui);
+       day = now.l_ui / 86400 + MJD_1900;
+       now.l_ui %= 86400;
+       if (rawstats.fp != NULL) {
+                fprintf(rawstats.fp, "%lu %s %s %s %s %s %s %s\n",
+                       day, ulfptoa(&now, 3), stoa(srcadr), dstadr ? stoa(dstadr) : "-",
+                       ulfptoa(t1, 9), ulfptoa(t2, 9), ulfptoa(t3, 9),
+                       ulfptoa(t4, 9));
+               fflush(rawstats.fp);
+       }
+}
+
+
+/*
+ * record_sys_stats - write system statistics to file
+ *
+ * file format
+ * time (s past midnight)
+ * time since startup (hr)
+ * packets recieved
+ * packets processed
+ * current version
+ * previous version
+ * bad version
+ * access denied
+ * bad length or format
+ * bad authentication
+ * rate exceeded
+ */
+void
+record_sys_stats(void)
+{
+       l_fp    now;
+       u_long  day;
+
+       if (!stats_control)
+               return;
+
+       get_systime(&now);
+       filegen_setup(&sysstats, now.l_ui);
+       day = now.l_ui / 86400 + MJD_1900;
+       now.l_ui %= 86400;
+       if (sysstats.fp != NULL) {
+                fprintf(sysstats.fp,
+                   "%lu %s %lu %lu %lu %lu %lu %lu %lu %lu %lu %lu\n",
+                   day, ulfptoa(&now, 3), sys_stattime / 3600,
+                   sys_received, sys_processed, sys_newversionpkt,
+                   sys_oldversionpkt, sys_unknownversion,
+                   sys_restricted, sys_badlength, sys_badauth,
+                   sys_limitrejected);
+               fflush(sysstats.fp);
+               proto_clr_stats();
+       }
+}
+
+
+#ifdef OPENSSL
+/*
+ * record_crypto_stats - write crypto statistics to file
+ *
+ * file format:
+ * day (mjd)
+ * time (s past midnight)
+ * peer (ip address)
+ * text message
+ */
+void
+record_crypto_stats(
+       struct sockaddr_storage *addr,
+       const char *text
+       )
+{
+       l_fp    now;
+       u_long  day;
+
+       if (!stats_control)
+               return;
+
+       get_systime(&now);
+       filegen_setup(&cryptostats, now.l_ui);
+       day = now.l_ui / 86400 + MJD_1900;
+       now.l_ui %= 86400;
+       if (cryptostats.fp != NULL) {
+               if (addr == NULL)
+                       fprintf(cryptostats.fp, "%lu %s %s\n",
+                           day, ulfptoa(&now, 3), text);
+               else
+                       fprintf(cryptostats.fp, "%lu %s %s %s\n",
+                           day, ulfptoa(&now, 3), stoa(addr), text);
+               fflush(cryptostats.fp);
+       }
+}
+#endif /* OPENSSL */
+
+#ifdef DEBUG_TIMING
+/*
+ * record_crypto_stats - write crypto statistics to file
+ *
+ * file format:
+ * day (mjd)
+ * time (s past midnight)
+ * text message
+ */
+void
+record_timing_stats(
+       const char *text
+       )
+{
+       static unsigned int flshcnt;
+       l_fp    now;
+       u_long  day;
+
+       if (!stats_control)
+               return;
+
+       get_systime(&now);
+       filegen_setup(&timingstats, now.l_ui);
+       day = now.l_ui / 86400 + MJD_1900;
+       now.l_ui %= 86400;
+       if (timingstats.fp != NULL) {
+               fprintf(timingstats.fp, "%lu %s %s\n",
+                           day, lfptoa(&now, 3), text);
+               if (++flshcnt % 100 == 0)
+                       fflush(timingstats.fp);
+       }
+}
+#endif
+/*
+ * getauthkeys - read the authentication keys from the specified file
+ */
+void
+getauthkeys(
+       const char *keyfile
+       )
+{
+       int len;
+
+       len = strlen(keyfile);
+       if (len == 0)
+               return;
+       
+       if (key_file_name != 0) {
+               if (len > (int)strlen(key_file_name)) {
+                       (void) free(key_file_name);
+                       key_file_name = 0;
+               }
+       }
+
+       if (key_file_name == 0) {
+#ifndef SYS_WINNT
+               key_file_name = (char*)emalloc((u_int) (len + 1));
+#else
+               key_file_name = (char*)emalloc((u_int)  (MAXPATHLEN));
+#endif
+       }
+#ifndef SYS_WINNT
+       memmove(key_file_name, keyfile, (unsigned)(len+1));
+#else
+       if (!ExpandEnvironmentStrings(keyfile, key_file_name, MAXPATHLEN)) 
+       {
+               msyslog(LOG_ERR,
+                   "ExpandEnvironmentStrings(KEY_FILE) failed: %m\n");
+       }
+#endif /* SYS_WINNT */
+
+       authreadkeys(key_file_name);
+}
+
+
+/*
+ * rereadkeys - read the authentication key file over again.
+ */
+void
+rereadkeys(void)
+{
+       if (key_file_name != 0)
+           authreadkeys(key_file_name);
+}
+
+/*
+ * sock_hash - hash an sockaddr_storage structure
+ */
+int
+sock_hash(
+       struct sockaddr_storage *addr
+       )
+{
+       int hashVal;
+       int i;
+       int len;
+       char *ch;
+
+       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.
+        */
+       ch = (char *)&addr->ss_family;
+       hashVal = 37 * hashVal + (int)*ch;
+       if (sizeof(addr->ss_family) > 1) {
+               ch++;
+               hashVal = 37 * hashVal + (int)*ch;
+       }
+       switch(addr->ss_family) {
+       case AF_INET:
+               ch = (char *)&((struct sockaddr_in *)addr)->sin_addr;
+               len = sizeof(struct in_addr);
+               break;
+       case AF_INET6:
+               ch = (char *)&((struct sockaddr_in6 *)addr)->sin6_addr;
+               len = sizeof(struct in6_addr);
+               break;
+       }
+
+       for (i = 0; i < len ; i++)
+               hashVal = 37 * hashVal + (int)*(ch + i);
+
+       hashVal = hashVal % 128;  /* % MON_HASH_SIZE hardcoded */
+
+       if (hashVal < 0)
+               hashVal += 128;
+
+       return hashVal;
+}
+
+#if notyet
+/*
+ * ntp_exit - document explicitly that ntpd has exited
+ */
+void
+ntp_exit(int retval)
+{
+  msyslog(LOG_ERR, "EXITING with return code %d", retval);
+  exit(retval);
+}
+#endif
diff --git a/ntpd/ntpd-opts.c b/ntpd/ntpd-opts.c
new file mode 100644 (file)
index 0000000..4d23d66
--- /dev/null
@@ -0,0 +1,1021 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (ntpd-opts.c)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:13:10 AM EST
+ *  From the definitions    ntpd-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This source file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  ntpd author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * ntpd copyright 1970-2009 David L. Mills and/or others - all rights reserved
+ *
+ * see html/copyright.html
+ */
+
+
+#include <limits.h>
+
+#define OPTION_CODE_COMPILE 1
+#include "ntpd-opts.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+tSCC zCopyright[] =
+       "ntpd copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved";
+tSCC zCopyrightNotice[] =
+       
+/* extracted from ../include/copyright.def near line 8 */
+"see html/copyright.html";
+extern tUsageProc optionUsage;
+
+/*
+ *  global included definitions
+ */
+#ifdef __windows
+  extern int atoi(const char*);
+#else
+# include <stdlib.h>
+#endif
+
+#ifndef NULL
+#  define NULL 0
+#endif
+#ifndef EXIT_SUCCESS
+#  define  EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#  define  EXIT_FAILURE 1
+#endif
+/*
+ *  Ipv4 option description:
+ */
+tSCC    zIpv4Text[] =
+        "Force IPv4 DNS name resolution";
+tSCC    zIpv4_NAME[]               = "IPV4";
+tSCC    zIpv4_Name[]               = "ipv4";
+#define IPV4_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Ipv6 option description:
+ */
+tSCC    zIpv6Text[] =
+        "Force IPv6 DNS name resolution";
+tSCC    zIpv6_NAME[]               = "IPV6";
+tSCC    zIpv6_Name[]               = "ipv6";
+#define IPV6_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Authreq option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zAuthreqText[] =
+        "Require crypto authentication";
+tSCC    zAuthreq_NAME[]            = "AUTHREQ";
+tSCC    zAuthreq_Name[]            = "authreq";
+static const int
+    aAuthreqCantList[] = {
+    INDEX_OPT_AUTHNOREQ, NO_EQUIVALENT };
+#define AUTHREQ_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Authnoreq option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zAuthnoreqText[] =
+        "Do not require crypto authentication";
+tSCC    zAuthnoreq_NAME[]          = "AUTHNOREQ";
+tSCC    zAuthnoreq_Name[]          = "authnoreq";
+static const int
+    aAuthnoreqCantList[] = {
+    INDEX_OPT_AUTHREQ, NO_EQUIVALENT };
+#define AUTHNOREQ_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Bcastsync option description:
+ */
+tSCC    zBcastsyncText[] =
+        "Allow us to sync to broadcast servers";
+tSCC    zBcastsync_NAME[]          = "BCASTSYNC";
+tSCC    zBcastsync_Name[]          = "bcastsync";
+#define BCASTSYNC_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Configfile option description:
+ */
+tSCC    zConfigfileText[] =
+        "configuration file name";
+tSCC    zConfigfile_NAME[]         = "CONFIGFILE";
+tSCC    zConfigfile_Name[]         = "configfile";
+#define CONFIGFILE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Debug_Level option description:
+ */
+#ifdef DEBUG
+tSCC    zDebug_LevelText[] =
+        "Increase output debug message level";
+tSCC    zDebug_Level_NAME[]        = "DEBUG_LEVEL";
+tSCC    zDebug_Level_Name[]        = "debug-level";
+#define DEBUG_LEVEL_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Debug_Level */
+#define VALUE_OPT_DEBUG_LEVEL NO_EQUIVALENT
+#define DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zDebug_LevelText       NULL
+#define zDebug_Level_NAME      NULL
+#define zDebug_Level_Name      NULL
+#endif  /* DEBUG */
+
+/*
+ *  Set_Debug_Level option description:
+ */
+#ifdef DEBUG
+tSCC    zSet_Debug_LevelText[] =
+        "Set the output debug message level";
+tSCC    zSet_Debug_Level_NAME[]    = "SET_DEBUG_LEVEL";
+tSCC    zSet_Debug_Level_Name[]    = "set-debug-level";
+#define SET_DEBUG_LEVEL_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+#else   /* disable Set_Debug_Level */
+#define VALUE_OPT_SET_DEBUG_LEVEL NO_EQUIVALENT
+#define SET_DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zSet_Debug_LevelText       NULL
+#define zSet_Debug_Level_NAME      NULL
+#define zSet_Debug_Level_Name      NULL
+#endif  /* DEBUG */
+
+/*
+ *  Driftfile option description:
+ */
+tSCC    zDriftfileText[] =
+        "frequency drift file name";
+tSCC    zDriftfile_NAME[]          = "DRIFTFILE";
+tSCC    zDriftfile_Name[]          = "driftfile";
+#define DRIFTFILE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Panicgate option description:
+ */
+tSCC    zPanicgateText[] =
+        "Allow the first adjustment to be Big";
+tSCC    zPanicgate_NAME[]          = "PANICGATE";
+tSCC    zPanicgate_Name[]          = "panicgate";
+#define PANICGATE_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Jaildir option description:
+ */
+tSCC    zJaildirText[] =
+        "Jail directory";
+tSCC    zJaildir_NAME[]            = "JAILDIR";
+tSCC    zJaildir_Name[]            = "jaildir";
+#define JAILDIR_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Interface option description:
+ */
+tSCC    zInterfaceText[] =
+        "Listen on interface";
+tSCC    zInterface_NAME[]          = "INTERFACE";
+tSCC    zInterface_Name[]          = "interface";
+#define INTERFACE_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Keyfile option description:
+ */
+tSCC    zKeyfileText[] =
+        "path to symmetric keys";
+tSCC    zKeyfile_NAME[]            = "KEYFILE";
+tSCC    zKeyfile_Name[]            = "keyfile";
+#define KEYFILE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Logfile option description:
+ */
+tSCC    zLogfileText[] =
+        "path to the log file";
+tSCC    zLogfile_NAME[]            = "LOGFILE";
+tSCC    zLogfile_Name[]            = "logfile";
+#define LOGFILE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Novirtualips option description:
+ */
+tSCC    zNovirtualipsText[] =
+        "Do not listen to virtual IPs";
+tSCC    zNovirtualips_NAME[]       = "NOVIRTUALIPS";
+tSCC    zNovirtualips_Name[]       = "novirtualips";
+#define NOVIRTUALIPS_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Modifymmtimer option description:
+ */
+#ifdef SYS_WINNT
+tSCC    zModifymmtimerText[] =
+        "Modify Multimedia Timer (Windows only)";
+tSCC    zModifymmtimer_NAME[]      = "MODIFYMMTIMER";
+tSCC    zModifymmtimer_Name[]      = "modifymmtimer";
+#define MODIFYMMTIMER_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Modifymmtimer */
+#define VALUE_OPT_MODIFYMMTIMER NO_EQUIVALENT
+#define MODIFYMMTIMER_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zModifymmtimerText       NULL
+#define zModifymmtimer_NAME      NULL
+#define zModifymmtimer_Name      NULL
+#endif  /* SYS_WINNT */
+
+/*
+ *  Nofork option description:
+ */
+tSCC    zNoforkText[] =
+        "Do not fork";
+tSCC    zNofork_NAME[]             = "NOFORK";
+tSCC    zNofork_Name[]             = "nofork";
+#define NOFORK_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Nice option description:
+ */
+tSCC    zNiceText[] =
+        "Run at high priority";
+tSCC    zNice_NAME[]               = "NICE";
+tSCC    zNice_Name[]               = "nice";
+#define NICE_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Pidfile option description:
+ */
+tSCC    zPidfileText[] =
+        "path to the PID file";
+tSCC    zPidfile_NAME[]            = "PIDFILE";
+tSCC    zPidfile_Name[]            = "pidfile";
+#define PIDFILE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Priority option description:
+ */
+tSCC    zPriorityText[] =
+        "Process priority";
+tSCC    zPriority_NAME[]           = "PRIORITY";
+tSCC    zPriority_Name[]           = "priority";
+#define PRIORITY_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+
+/*
+ *  Quit option description:
+ */
+tSCC    zQuitText[] =
+        "Set the time and quit";
+tSCC    zQuit_NAME[]               = "QUIT";
+tSCC    zQuit_Name[]               = "quit";
+#define QUIT_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Propagationdelay option description:
+ */
+tSCC    zPropagationdelayText[] =
+        "Broadcast/propagation delay";
+tSCC    zPropagationdelay_NAME[]   = "PROPAGATIONDELAY";
+tSCC    zPropagationdelay_Name[]   = "propagationdelay";
+#define PROPAGATIONDELAY_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Updateinterval option description:
+ */
+tSCC    zUpdateintervalText[] =
+        "interval in seconds between scans for new or dropped interfaces";
+tSCC    zUpdateinterval_NAME[]     = "UPDATEINTERVAL";
+tSCC    zUpdateinterval_Name[]     = "updateinterval";
+#define UPDATEINTERVAL_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+
+/*
+ *  Statsdir option description:
+ */
+tSCC    zStatsdirText[] =
+        "Statistics file location";
+tSCC    zStatsdir_NAME[]           = "STATSDIR";
+tSCC    zStatsdir_Name[]           = "statsdir";
+#define STATSDIR_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Trustedkey option description:
+ */
+tSCC    zTrustedkeyText[] =
+        "Trusted key number";
+tSCC    zTrustedkey_NAME[]         = "TRUSTEDKEY";
+tSCC    zTrustedkey_Name[]         = "trustedkey";
+#define TRUSTEDKEY_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  User option description:
+ */
+tSCC    zUserText[] =
+        "Run as userid (or userid:groupid)";
+tSCC    zUser_NAME[]               = "USER";
+tSCC    zUser_Name[]               = "user";
+#define USER_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Var option description:
+ */
+tSCC    zVarText[] =
+        "make ARG an ntp variable (RW)";
+tSCC    zVar_NAME[]                = "VAR";
+tSCC    zVar_Name[]                = "var";
+#define VAR_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Dvar option description:
+ */
+tSCC    zDvarText[] =
+        "make ARG an ntp variable (RW|DEF)";
+tSCC    zDvar_NAME[]               = "DVAR";
+tSCC    zDvar_Name[]               = "dvar";
+#define DVAR_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Slew option description:
+ */
+tSCC    zSlewText[] =
+        "Slew up to 600 seconds";
+tSCC    zSlew_NAME[]               = "SLEW";
+tSCC    zSlew_Name[]               = "slew";
+#define SLEW_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Help/More_Help/Version option descriptions:
+ */
+tSCC zHelpText[]       = "Display usage information and exit";
+tSCC zHelp_Name[]      = "help";
+
+tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
+tSCC zMore_Help_Name[] = "more-help";
+
+tSCC zVersionText[]    = "Output version information and exit";
+tSCC zVersion_Name[]   = "version";
+/*
+ *  Declare option callback procedures
+ */
+#ifdef DEBUG
+  static tOptProc doOptSet_Debug_Level;
+#else /* not DEBUG */
+# define doOptSet_Debug_Level NULL
+#endif /* def/not DEBUG */
+#if defined(TEST_NTPD_OPTS)
+/*
+ *  Under test, omit argument processing, or call optionStackArg,
+ *  if multiple copies are allowed.
+ */
+extern tOptProc
+    optionNumericVal,    optionPagedUsage,    optionStackArg,
+    optionVersionStderr;
+static tOptProc
+    doUsageOpt;
+
+/*
+ *  #define map the "normal" callout procs to the test ones...
+ */
+#define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
+
+
+#else /* NOT defined TEST_NTPD_OPTS */
+/*
+ *  When not under test, there are different procs to use
+ */
+extern tOptProc
+    optionNumericVal, optionPagedUsage, optionPrintVersion, optionStackArg;
+static tOptProc
+    doUsageOpt;
+
+/*
+ *  #define map the "normal" callout procs
+ */
+#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
+
+#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
+#endif /* defined(TEST_NTPD_OPTS) */
+#ifdef TEST_NTPD_OPTS
+# define DOVERPROC optionVersionStderr
+#else
+# define DOVERPROC optionPrintVersion
+#endif /* TEST_NTPD_OPTS */
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Ntpd Option Descriptions.
+ */
+static tOptDesc optDesc[ OPTION_CT ] = {
+  {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
+     /* equiv idx, value */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IPV4_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
+     /* equiv idx, value */ NOLIMIT, NOLIMIT,
+     /* equivalenced to  */ INDEX_OPT_IPV4,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IPV6_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 2, VALUE_OPT_AUTHREQ,
+     /* equiv idx, value */ 2, VALUE_OPT_AUTHREQ,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ AUTHREQ_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aAuthreqCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zAuthreqText, zAuthreq_NAME, zAuthreq_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 3, VALUE_OPT_AUTHNOREQ,
+     /* equiv idx, value */ 3, VALUE_OPT_AUTHNOREQ,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ AUTHNOREQ_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aAuthnoreqCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zAuthnoreqText, zAuthnoreq_NAME, zAuthnoreq_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 4, VALUE_OPT_BCASTSYNC,
+     /* equiv idx, value */ 4, VALUE_OPT_BCASTSYNC,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ BCASTSYNC_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zBcastsyncText, zBcastsync_NAME, zBcastsync_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 5, VALUE_OPT_CONFIGFILE,
+     /* equiv idx, value */ 5, VALUE_OPT_CONFIGFILE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ CONFIGFILE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zConfigfileText, zConfigfile_NAME, zConfigfile_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 6, VALUE_OPT_DEBUG_LEVEL,
+     /* equiv idx, value */ 6, VALUE_OPT_DEBUG_LEVEL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ DEBUG_LEVEL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 7, VALUE_OPT_SET_DEBUG_LEVEL,
+     /* equiv idx, value */ 7, VALUE_OPT_SET_DEBUG_LEVEL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ SET_DEBUG_LEVEL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ SET_DEBUG_LEVEL_OPT_PROC,
+     /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 8, VALUE_OPT_DRIFTFILE,
+     /* equiv idx, value */ 8, VALUE_OPT_DRIFTFILE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ DRIFTFILE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zDriftfileText, zDriftfile_NAME, zDriftfile_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 9, VALUE_OPT_PANICGATE,
+     /* equiv idx, value */ 9, VALUE_OPT_PANICGATE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PANICGATE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPanicgateText, zPanicgate_NAME, zPanicgate_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 10, VALUE_OPT_JAILDIR,
+     /* equiv idx, value */ 10, VALUE_OPT_JAILDIR,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ JAILDIR_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zJaildirText, zJaildir_NAME, zJaildir_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 11, VALUE_OPT_INTERFACE,
+     /* equiv idx, value */ 11, VALUE_OPT_INTERFACE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ INTERFACE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zInterfaceText, zInterface_NAME, zInterface_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 12, VALUE_OPT_KEYFILE,
+     /* equiv idx, value */ 12, VALUE_OPT_KEYFILE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ KEYFILE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zKeyfileText, zKeyfile_NAME, zKeyfile_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 13, VALUE_OPT_LOGFILE,
+     /* equiv idx, value */ 13, VALUE_OPT_LOGFILE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ LOGFILE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zLogfileText, zLogfile_NAME, zLogfile_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 14, VALUE_OPT_NOVIRTUALIPS,
+     /* equiv idx, value */ 14, VALUE_OPT_NOVIRTUALIPS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ NOVIRTUALIPS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zNovirtualipsText, zNovirtualips_NAME, zNovirtualips_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 15, VALUE_OPT_MODIFYMMTIMER,
+     /* equiv idx, value */ 15, VALUE_OPT_MODIFYMMTIMER,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ MODIFYMMTIMER_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zModifymmtimerText, zModifymmtimer_NAME, zModifymmtimer_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 16, VALUE_OPT_NOFORK,
+     /* equiv idx, value */ 16, VALUE_OPT_NOFORK,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ NOFORK_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zNoforkText, zNofork_NAME, zNofork_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 17, VALUE_OPT_NICE,
+     /* equiv idx, value */ 17, VALUE_OPT_NICE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ NICE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zNiceText, zNice_NAME, zNice_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 18, VALUE_OPT_PIDFILE,
+     /* equiv idx, value */ 18, VALUE_OPT_PIDFILE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PIDFILE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPidfileText, zPidfile_NAME, zPidfile_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 19, VALUE_OPT_PRIORITY,
+     /* equiv idx, value */ 19, VALUE_OPT_PRIORITY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PRIORITY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionNumericVal,
+     /* desc, NAME, name */ zPriorityText, zPriority_NAME, zPriority_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 20, VALUE_OPT_QUIT,
+     /* equiv idx, value */ 20, VALUE_OPT_QUIT,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ QUIT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zQuitText, zQuit_NAME, zQuit_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 21, VALUE_OPT_PROPAGATIONDELAY,
+     /* equiv idx, value */ 21, VALUE_OPT_PROPAGATIONDELAY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PROPAGATIONDELAY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPropagationdelayText, zPropagationdelay_NAME, zPropagationdelay_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 22, VALUE_OPT_UPDATEINTERVAL,
+     /* equiv idx, value */ 22, VALUE_OPT_UPDATEINTERVAL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ UPDATEINTERVAL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionNumericVal,
+     /* desc, NAME, name */ zUpdateintervalText, zUpdateinterval_NAME, zUpdateinterval_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 23, VALUE_OPT_STATSDIR,
+     /* equiv idx, value */ 23, VALUE_OPT_STATSDIR,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ STATSDIR_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zStatsdirText, zStatsdir_NAME, zStatsdir_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 24, VALUE_OPT_TRUSTEDKEY,
+     /* equiv idx, value */ 24, VALUE_OPT_TRUSTEDKEY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ TRUSTEDKEY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zTrustedkeyText, zTrustedkey_NAME, zTrustedkey_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 25, VALUE_OPT_USER,
+     /* equiv idx, value */ 25, VALUE_OPT_USER,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ USER_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zUserText, zUser_NAME, zUser_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 26, VALUE_OPT_VAR,
+     /* equiv idx, value */ 26, VALUE_OPT_VAR,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ VAR_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zVarText, zVar_NAME, zVar_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 27, VALUE_OPT_DVAR,
+     /* equiv idx, value */ 27, VALUE_OPT_DVAR,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ DVAR_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zDvarText, zDvar_NAME, zDvar_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 28, VALUE_OPT_SLEW,
+     /* equiv idx, value */ 28, VALUE_OPT_SLEW,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SLEW_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSlewText, zSlew_NAME, zSlew_Name,
+     /* disablement strs */ NULL, NULL },
+
+#ifdef NO_OPTIONAL_OPT_ARGS
+#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
+#else
+#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
+                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
+#endif
+
+  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ DOVERPROC,
+     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
+     /* disablement strs */ NULL, NULL },
+
+#undef VERSION_OPT_FLAGS
+
+
+  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doUsageOpt,
+     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ optionPagedUsage,
+     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
+     /* disablement strs */ NULL, NULL }
+};
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Ntpd Option Environment
+ */
+tSCC   zPROGNAME[]   = "NTPD";
+tSCC   zUsageTitle[] =
+"ntpd - NTP daemon program - Ver. 4.2.4p8\n\
+USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
+#define zRcName     NULL
+#define apzHomeList NULL
+
+tSCC   zBugsAddr[]    = "http://bugs.ntp.org, bugs@ntp.org";
+#define zExplain NULL
+tSCC    zDetail[]     = "\n\n";
+tSCC    zFullVersion[] = NTPD_FULL_VERSION;
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
+
+#if defined(ENABLE_NLS)
+# define OPTPROC_BASE OPTPROC_TRANSLATE
+  static tOptionXlateProc translate_option_strings;
+#else
+# define OPTPROC_BASE OPTPROC_NONE
+# define translate_option_strings NULL
+#endif /* ENABLE_NLS */
+
+tOptions ntpdOptions = {
+    OPTIONS_STRUCT_VERSION,
+    0, NULL,                    /* original argc + argv    */
+    ( OPTPROC_BASE
+    + OPTPROC_ERRSTOP
+    + OPTPROC_SHORTOPT
+    + OPTPROC_LONGOPT
+    + OPTPROC_NO_REQ_OPT
+    + OPTPROC_ENVIRON
+    + OPTPROC_NO_ARGS ),
+    0, NULL,                    /* current option index, current option */
+    NULL,         NULL,         zPROGNAME,
+    zRcName,      zCopyright,   zCopyrightNotice,
+    zFullVersion, apzHomeList,  zUsageTitle,
+    zExplain,     zDetail,      optDesc,
+    zBugsAddr,                  /* address to send bugs to */
+    NULL, NULL,                 /* extensions/saved state  */
+    optionUsage,       /* usage procedure */
+    translate_option_strings,   /* translation procedure */
+    /*
+     *  Indexes to special options
+     */
+    { INDEX_OPT_MORE_HELP,
+       0 /* no option state saving */,
+      NO_EQUIVALENT /* index of '-#' option */,
+      NO_EQUIVALENT /* index of default opt */
+    },
+    32 /* full option count */, 29 /* user option count */
+};
+
+/*
+ *  Create the static procedure(s) declared above.
+ */
+static void
+doUsageOpt(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    USAGE( EXIT_SUCCESS );
+}
+
+#if ! defined(TEST_NTPD_OPTS)
+
+/* * * * * * *
+ *
+ *   For the set-debug-level option, when DEBUG is #define-d.
+ */
+#ifdef DEBUG
+static void
+doOptSet_Debug_Level(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    /* extracted from ../include/debug-opt.def, line 29 */
+DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
+}
+#endif /* defined DEBUG */
+
+#endif /* defined(TEST_NTPD_OPTS) */
+
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
+
+#if defined(TEST_NTPD_OPTS) /* TEST MAIN PROCEDURE: */
+
+int
+main( int argc, char** argv )
+{
+    int res = EXIT_SUCCESS;
+    (void)optionProcess( &ntpdOptions, argc, argv );
+    {
+        void optionPutShell( tOptions* );
+        optionPutShell( &ntpdOptions );
+    }
+    return res;
+}
+#endif  /* defined TEST_NTPD_OPTS */
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
+
+#if ENABLE_NLS
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <autoopts/usage-txt.h>
+
+static char* AO_gettext( char const* pz );
+static void  coerce_it(void** s);
+
+static char*
+AO_gettext( char const* pz )
+{
+    char* pzRes;
+    if (pz == NULL)
+        return NULL;
+    pzRes = _(pz);
+    if (pzRes == pz)
+        return pzRes;
+    pzRes = strdup( pzRes );
+    if (pzRes == NULL) {
+        fputs( _("No memory for duping translated strings\n"), stderr );
+        exit( EXIT_FAILURE );
+    }
+    return pzRes;
+}
+
+static void coerce_it(void** s) { *s = AO_gettext(*s); }
+#define COERSION(_f) \
+  coerce_it((void*)&(ntpdOptions._f))
+
+/*
+ *  This invokes the translation code (e.g. gettext(3)).
+ */
+static void
+translate_option_strings( void )
+{
+    /*
+     *  Guard against re-translation.  It won't work.  The strings will have
+     *  been changed by the first pass through this code.  One shot only.
+     */
+    if (option_usage_text.field_ct == 0)
+        return;
+    /*
+     *  Do the translations.  The first pointer follows the field count field.
+     *  The field count field is the size of a pointer.
+     */
+    {
+        char** ppz = (char**)(void*)&(option_usage_text);
+        int    ix  = option_usage_text.field_ct;
+
+        do {
+            ppz++;
+            *ppz = AO_gettext(*ppz);
+        } while (--ix > 0);
+    }
+    option_usage_text.field_ct = 0;
+
+    {
+        tOptDesc* pOD = ntpdOptions.pOptDesc;
+        int       ix  = ntpdOptions.optCt;
+
+        for (;;) {
+            pOD->pzText           = AO_gettext(pOD->pzText);
+            pOD->pz_NAME          = AO_gettext(pOD->pz_NAME);
+            pOD->pz_Name          = AO_gettext(pOD->pz_Name);
+            pOD->pz_DisableName   = AO_gettext(pOD->pz_DisableName);
+            pOD->pz_DisablePfx    = AO_gettext(pOD->pz_DisablePfx);
+            if (--ix <= 0)
+                break;
+            pOD++;
+        }
+    }
+    COERSION(pzCopyright);
+    COERSION(pzCopyNotice);
+    COERSION(pzFullVersion);
+    COERSION(pzUsageTitle);
+    COERSION(pzExplain);
+    COERSION(pzDetail);
+}
+
+#endif /* ENABLE_NLS */
+
+#ifdef  __cplusplus
+}
+#endif
+/* ntpd-opts.c ends here */
diff --git a/ntpd/ntpd-opts.def b/ntpd/ntpd-opts.def
new file mode 100644 (file)
index 0000000..7266e1b
--- /dev/null
@@ -0,0 +1,13 @@
+/* -*- Mode: Text -*- */
+
+autogen definitions options;
+
+#include copyright.def
+
+prog-name      = "ntpd";
+prog-title     = "NTP daemon program";
+
+#include ntpdbase-opts.def
+
+detail = <<-  _END_DETAIL
+       _END_DETAIL;
diff --git a/ntpd/ntpd-opts.h b/ntpd/ntpd-opts.h
new file mode 100644 (file)
index 0000000..0347f33
--- /dev/null
@@ -0,0 +1,351 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (ntpd-opts.h)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:13:09 AM EST
+ *  From the definitions    ntpd-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This header file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  ntpd author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * ntpd copyright 1970-2009 David L. Mills and/or others - all rights reserved
+ *
+ * see html/copyright.html
+ */
+/*
+ *  This file contains the programmatic interface to the Automated
+ *  Options generated for the ntpd program.
+ *  These macros are documented in the AutoGen info file in the
+ *  "AutoOpts" chapter.  Please refer to that doc for usage help.
+ */
+#ifndef AUTOOPTS_NTPD_OPTS_H_GUARD
+#define AUTOOPTS_NTPD_OPTS_H_GUARD
+#include "config.h"
+#include <autoopts/options.h>
+
+/*
+ *  Ensure that the library used for compiling this generated header is at
+ *  least as new as the version current when the header template was released
+ *  (not counting patch version increments).  Also ensure that the oldest
+ *  tolerable version is at least as old as what was current when the header
+ *  template was released.
+ */
+#define AO_TEMPLATE_VERSION 118784
+#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
+ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
+# error option template version mismatches autoopts/options.h header
+  Choke Me.
+#endif
+
+/*
+ *  Enumeration of each option:
+ */
+typedef enum {
+        INDEX_OPT_IPV4             =  0,
+        INDEX_OPT_IPV6             =  1,
+        INDEX_OPT_AUTHREQ          =  2,
+        INDEX_OPT_AUTHNOREQ        =  3,
+        INDEX_OPT_BCASTSYNC        =  4,
+        INDEX_OPT_CONFIGFILE       =  5,
+        INDEX_OPT_DEBUG_LEVEL      =  6,
+        INDEX_OPT_SET_DEBUG_LEVEL  =  7,
+        INDEX_OPT_DRIFTFILE        =  8,
+        INDEX_OPT_PANICGATE        =  9,
+        INDEX_OPT_JAILDIR          = 10,
+        INDEX_OPT_INTERFACE        = 11,
+        INDEX_OPT_KEYFILE          = 12,
+        INDEX_OPT_LOGFILE          = 13,
+        INDEX_OPT_NOVIRTUALIPS     = 14,
+        INDEX_OPT_MODIFYMMTIMER    = 15,
+        INDEX_OPT_NOFORK           = 16,
+        INDEX_OPT_NICE             = 17,
+        INDEX_OPT_PIDFILE          = 18,
+        INDEX_OPT_PRIORITY         = 19,
+        INDEX_OPT_QUIT             = 20,
+        INDEX_OPT_PROPAGATIONDELAY = 21,
+        INDEX_OPT_UPDATEINTERVAL   = 22,
+        INDEX_OPT_STATSDIR         = 23,
+        INDEX_OPT_TRUSTEDKEY       = 24,
+        INDEX_OPT_USER             = 25,
+        INDEX_OPT_VAR              = 26,
+        INDEX_OPT_DVAR             = 27,
+        INDEX_OPT_SLEW             = 28,
+        INDEX_OPT_VERSION          = 29,
+        INDEX_OPT_HELP             = 30,
+        INDEX_OPT_MORE_HELP        = 31
+} teOptIndex;
+
+#define OPTION_CT    32
+#define NTPD_VERSION       "4.2.4p8"
+#define NTPD_FULL_VERSION  "ntpd - NTP daemon program - Ver. 4.2.4p8"
+
+/*
+ *  Interface defines for all options.  Replace "n" with the UPPER_CASED
+ *  option name (as in the teOptIndex enumeration above).
+ *  e.g. HAVE_OPT( IPV4 )
+ */
+#define         DESC(n) (ntpdOptions.pOptDesc[INDEX_OPT_## n])
+#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
+#define      OPT_ARG(n) (DESC(n).optArg.argString)
+#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
+#define    COUNT_OPT(n) (DESC(n).optOccCt)
+#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
+#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
+#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
+#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
+#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
+#define    CLEAR_OPT(n) STMTS( \
+                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
+                if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
+                    DESC(n).fOptState |= OPTST_DISABLED; \
+                DESC(n).optCookie = NULL )
+
+/*
+ *  Make sure there are no #define name conflicts with the option names
+ */
+#ifndef     NO_OPTION_NAME_WARNINGS
+# ifdef    IPV4
+#  warning undefining IPV4 due to option name conflict
+#  undef   IPV4
+# endif
+# ifdef    IPV6
+#  warning undefining IPV6 due to option name conflict
+#  undef   IPV6
+# endif
+# ifdef    AUTHREQ
+#  warning undefining AUTHREQ due to option name conflict
+#  undef   AUTHREQ
+# endif
+# ifdef    AUTHNOREQ
+#  warning undefining AUTHNOREQ due to option name conflict
+#  undef   AUTHNOREQ
+# endif
+# ifdef    BCASTSYNC
+#  warning undefining BCASTSYNC due to option name conflict
+#  undef   BCASTSYNC
+# endif
+# ifdef    CONFIGFILE
+#  warning undefining CONFIGFILE due to option name conflict
+#  undef   CONFIGFILE
+# endif
+# ifdef    DEBUG_LEVEL
+#  warning undefining DEBUG_LEVEL due to option name conflict
+#  undef   DEBUG_LEVEL
+# endif
+# ifdef    SET_DEBUG_LEVEL
+#  warning undefining SET_DEBUG_LEVEL due to option name conflict
+#  undef   SET_DEBUG_LEVEL
+# endif
+# ifdef    DRIFTFILE
+#  warning undefining DRIFTFILE due to option name conflict
+#  undef   DRIFTFILE
+# endif
+# ifdef    PANICGATE
+#  warning undefining PANICGATE due to option name conflict
+#  undef   PANICGATE
+# endif
+# ifdef    JAILDIR
+#  warning undefining JAILDIR due to option name conflict
+#  undef   JAILDIR
+# endif
+# ifdef    INTERFACE
+#  warning undefining INTERFACE due to option name conflict
+#  undef   INTERFACE
+# endif
+# ifdef    KEYFILE
+#  warning undefining KEYFILE due to option name conflict
+#  undef   KEYFILE
+# endif
+# ifdef    LOGFILE
+#  warning undefining LOGFILE due to option name conflict
+#  undef   LOGFILE
+# endif
+# ifdef    NOVIRTUALIPS
+#  warning undefining NOVIRTUALIPS due to option name conflict
+#  undef   NOVIRTUALIPS
+# endif
+# ifdef    MODIFYMMTIMER
+#  warning undefining MODIFYMMTIMER due to option name conflict
+#  undef   MODIFYMMTIMER
+# endif
+# ifdef    NOFORK
+#  warning undefining NOFORK due to option name conflict
+#  undef   NOFORK
+# endif
+# ifdef    NICE
+#  warning undefining NICE due to option name conflict
+#  undef   NICE
+# endif
+# ifdef    PIDFILE
+#  warning undefining PIDFILE due to option name conflict
+#  undef   PIDFILE
+# endif
+# ifdef    PRIORITY
+#  warning undefining PRIORITY due to option name conflict
+#  undef   PRIORITY
+# endif
+# ifdef    QUIT
+#  warning undefining QUIT due to option name conflict
+#  undef   QUIT
+# endif
+# ifdef    PROPAGATIONDELAY
+#  warning undefining PROPAGATIONDELAY due to option name conflict
+#  undef   PROPAGATIONDELAY
+# endif
+# ifdef    UPDATEINTERVAL
+#  warning undefining UPDATEINTERVAL due to option name conflict
+#  undef   UPDATEINTERVAL
+# endif
+# ifdef    STATSDIR
+#  warning undefining STATSDIR due to option name conflict
+#  undef   STATSDIR
+# endif
+# ifdef    TRUSTEDKEY
+#  warning undefining TRUSTEDKEY due to option name conflict
+#  undef   TRUSTEDKEY
+# endif
+# ifdef    USER
+#  warning undefining USER due to option name conflict
+#  undef   USER
+# endif
+# ifdef    VAR
+#  warning undefining VAR due to option name conflict
+#  undef   VAR
+# endif
+# ifdef    DVAR
+#  warning undefining DVAR due to option name conflict
+#  undef   DVAR
+# endif
+# ifdef    SLEW
+#  warning undefining SLEW due to option name conflict
+#  undef   SLEW
+# endif
+#else  /* NO_OPTION_NAME_WARNINGS */
+# undef IPV4
+# undef IPV6
+# undef AUTHREQ
+# undef AUTHNOREQ
+# undef BCASTSYNC
+# undef CONFIGFILE
+# undef DEBUG_LEVEL
+# undef SET_DEBUG_LEVEL
+# undef DRIFTFILE
+# undef PANICGATE
+# undef JAILDIR
+# undef INTERFACE
+# undef KEYFILE
+# undef LOGFILE
+# undef NOVIRTUALIPS
+# undef MODIFYMMTIMER
+# undef NOFORK
+# undef NICE
+# undef PIDFILE
+# undef PRIORITY
+# undef QUIT
+# undef PROPAGATIONDELAY
+# undef UPDATEINTERVAL
+# undef STATSDIR
+# undef TRUSTEDKEY
+# undef USER
+# undef VAR
+# undef DVAR
+# undef SLEW
+#endif  /*  NO_OPTION_NAME_WARNINGS */
+
+/*
+ *  Interface defines for specific options.
+ */
+#define VALUE_OPT_IPV4           '4'
+#define WHICH_OPT_IPV4           (DESC(IPV4).optActualValue)
+#define WHICH_IDX_IPV4           (DESC(IPV4).optActualIndex)
+#define VALUE_OPT_IPV6           '6'
+#define VALUE_OPT_AUTHREQ        'a'
+#define VALUE_OPT_AUTHNOREQ      'A'
+#define VALUE_OPT_BCASTSYNC      'b'
+#define VALUE_OPT_CONFIGFILE     'c'
+#ifdef DEBUG
+#define VALUE_OPT_DEBUG_LEVEL    'd'
+#endif /* DEBUG */
+#ifdef DEBUG
+#define VALUE_OPT_SET_DEBUG_LEVEL 'D'
+#endif /* DEBUG */
+#define VALUE_OPT_DRIFTFILE      'f'
+#define VALUE_OPT_PANICGATE      'g'
+#define VALUE_OPT_JAILDIR        'i'
+#define VALUE_OPT_INTERFACE      'I'
+#define VALUE_OPT_KEYFILE        'k'
+#define VALUE_OPT_LOGFILE        'l'
+#define VALUE_OPT_NOVIRTUALIPS   'L'
+#ifdef SYS_WINNT
+#define VALUE_OPT_MODIFYMMTIMER  'M'
+#endif /* SYS_WINNT */
+#define VALUE_OPT_NOFORK         'n'
+#define VALUE_OPT_NICE           'N'
+#define VALUE_OPT_PIDFILE        'p'
+#define VALUE_OPT_PRIORITY       'P'
+#define OPT_VALUE_PRIORITY       (DESC(PRIORITY).optArg.argInt)
+#define VALUE_OPT_QUIT           'q'
+#define VALUE_OPT_PROPAGATIONDELAY 'r'
+#define VALUE_OPT_UPDATEINTERVAL 'U'
+#define OPT_VALUE_UPDATEINTERVAL (DESC(UPDATEINTERVAL).optArg.argInt)
+#define VALUE_OPT_STATSDIR       's'
+#define VALUE_OPT_TRUSTEDKEY     't'
+#define VALUE_OPT_USER           'u'
+#define VALUE_OPT_VAR            'v'
+#define VALUE_OPT_DVAR           'V'
+#define VALUE_OPT_SLEW           'x'
+
+#define VALUE_OPT_VERSION       'v'
+#define VALUE_OPT_HELP          '?'
+#define VALUE_OPT_MORE_HELP     '!'
+/*
+ *  Interface defines not associated with particular options
+ */
+#define ERRSKIP_OPTERR  STMTS( ntpdOptions.fOptSet &= ~OPTPROC_ERRSTOP )
+#define ERRSTOP_OPTERR  STMTS( ntpdOptions.fOptSet |= OPTPROC_ERRSTOP )
+#define RESTART_OPT(n)  STMTS( \
+                ntpdOptions.curOptIdx = (n); \
+                ntpdOptions.pzCurOpt  = NULL )
+#define START_OPT       RESTART_OPT(1)
+#define USAGE(c)        (*ntpdOptions.pUsageProc)( &ntpdOptions, c )
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/opthead.tpl near line 360 */
+
+/* * * * * *
+ *
+ *  Declare the ntpd option descriptor.
+ */
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+extern tOptions   ntpdOptions;
+
+#ifndef _
+#  if ENABLE_NLS
+#    include <stdio.h>
+     static inline char* aoGetsText( char const* pz ) {
+         if (pz == NULL) return NULL;
+         return (char*)gettext( pz );
+     }
+#    define _(s)  aoGetsText(s)
+#  else  /* ENABLE_NLS */
+#    define _(s)  s
+#  endif /* ENABLE_NLS */
+#endif
+
+#ifdef  __cplusplus
+}
+#endif
+#endif /* AUTOOPTS_NTPD_OPTS_H_GUARD */
+/* ntpd-opts.h ends here */
diff --git a/ntpd/ntpd-opts.menu b/ntpd/ntpd-opts.menu
new file mode 100644 (file)
index 0000000..3425d82
--- /dev/null
@@ -0,0 +1 @@
+* ntpd Invocation::                Invoking ntpd
diff --git a/ntpd/ntpd-opts.texi b/ntpd/ntpd-opts.texi
new file mode 100644 (file)
index 0000000..0491294
--- /dev/null
@@ -0,0 +1,496 @@
+@node ntpd Invocation
+@section Invoking ntpd
+@pindex ntpd
+@cindex NTP daemon program
+@ignore
+# 
+# EDIT THIS FILE WITH CAUTION  (ntpd-opts.texi)
+# 
+# It has been AutoGen-ed  Tuesday December  8, 2009 at 08:13:12 AM EST
+# From the definitions    ntpd-opts.def
+# and the template file   aginfo.tpl
+@end ignore
+This program has no explanation.
+
+
+
+This section was generated by @strong{AutoGen},
+the aginfo template and the option descriptions for the @command{ntpd} program.  It documents the ntpd usage text and option meanings.
+
+This software is released under a specialized copyright license.
+
+@menu
+* ntpd usage::                  ntpd usage help (-?)
+* ntpd authnoreq::              authnoreq option (-A)
+* ntpd authreq::                authreq option (-a)
+* ntpd bcastsync::              bcastsync option (-b)
+* ntpd configfile::             configfile option (-c)
+* ntpd debug-level::            debug-level option (-d)
+* ntpd driftfile::              driftfile option (-f)
+* ntpd dvar::                   dvar option (-V)
+* ntpd interface::              interface option (-I)
+* ntpd ipv4::                   ipv4 option (-4)
+* ntpd ipv6::                   ipv6 option (-6)
+* ntpd jaildir::                jaildir option (-i)
+* ntpd keyfile::                keyfile option (-k)
+* ntpd logfile::                logfile option (-l)
+* ntpd modifymmtimer::          modifymmtimer option (-M)
+* ntpd nice::                   nice option (-N)
+* ntpd nofork::                 nofork option (-n)
+* ntpd novirtualips::           novirtualips option (-L)
+* ntpd panicgate::              panicgate option (-g)
+* ntpd pidfile::                pidfile option (-p)
+* ntpd priority::               priority option (-P)
+* ntpd propagationdelay::       propagationdelay option (-r)
+* ntpd quit::                   quit option (-q)
+* ntpd set-debug-level::        set-debug-level option (-D)
+* ntpd slew::                   slew option (-x)
+* ntpd statsdir::               statsdir option (-s)
+* ntpd trustedkey::             trustedkey option (-t)
+* ntpd updateinterval::         updateinterval option (-U)
+* ntpd user::                   user option (-u)
+* ntpd var::                    var option (-v)
+@end menu
+
+@node ntpd usage
+@subsection ntpd usage help (-?)
+@cindex ntpd usage
+
+This is the automatically generated usage text for ntpd:
+
+@exampleindent 0
+@example
+ntpd - NTP daemon program - Ver. 4.2.5p247-RC
+USAGE:  ntpd [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
+  Flg Arg Option-Name    Description
+   -4 no  ipv4           Force IPv4 DNS name resolution
+                                - prohibits these options:
+                                ipv6
+   -6 no  ipv6           Force IPv6 DNS name resolution
+                                - prohibits these options:
+                                ipv4
+   -a no  authreq        Require crypto authentication
+                                - prohibits these options:
+                                authnoreq
+   -A no  authnoreq      Do not require crypto authentication
+                                - prohibits these options:
+                                authreq
+   -b no  bcastsync      Allow us to sync to broadcast servers
+   -c Str configfile     configuration file name
+   -d no  debug-level    Increase output debug message level
+                                - may appear multiple times
+   -D Str set-debug-level Set the output debug message level
+                                - may appear multiple times
+   -f Str driftfile      frequency drift file name
+   -g no  panicgate      Allow the first adjustment to be Big
+                                - may appear multiple times
+   -i --- jaildir        built without --enable-clockctl or --enable-linuxcaps
+   -I Str interface      Listen on an interface name or address
+                                - may appear multiple times
+   -k Str keyfile        path to symmetric keys
+   -l Str logfile        path to the log file
+   -L no  novirtualips   Do not listen to virtual interfaces
+   -n no  nofork         Do not fork
+   -N no  nice           Run at high priority
+   -p Str pidfile        path to the PID file
+   -P Num priority       Process priority
+   -q no  quit           Set the time and quit
+   -r Str propagationdelay Broadcast/propagation delay
+      Str saveconfigquit Save parsed configuration and quit
+   -s Str statsdir       Statistics file location
+   -t Str trustedkey     Trusted key number
+                                - may appear multiple times
+   -u --- user           built without --enable-clockctl or --enable-linuxcaps
+   -U Num updateinterval interval in seconds between scans for new or dropped interfaces
+      Str var            make ARG an ntp variable (RW)
+                                - may appear multiple times
+      Str dvar           make ARG an ntp variable (RW|DEF)
+                                - may appear multiple times
+   -x no  slew           Slew up to 600 seconds
+      opt version        Output version information and exit
+   -? no  help           Display extended usage information and exit
+   -! no  more-help      Extended usage information passed thru pager
+
+Options are specified by doubled hyphens and their name
+or by a single hyphen and the flag character.
+
+The following option preset mechanisms are supported:
+ - examining environment variables named NTPD_*
+
+
+
+please send bug reports to:  http://bugs.ntp.org, bugs@@ntp.org
+@end example
+@exampleindent 4
+
+@node ntpd ipv4
+@subsection ipv4 option (-4)
+@cindex ntpd-ipv4
+
+This is the ``force ipv4 dns name resolution'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is a member of the ipv4 class of options.
+@end itemize
+
+Force DNS resolution of following host names on the command line
+to the IPv4 namespace.
+
+@node ntpd ipv6
+@subsection ipv6 option (-6)
+@cindex ntpd-ipv6
+
+This is the ``force ipv6 dns name resolution'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is a member of the ipv4 class of options.
+@end itemize
+
+Force DNS resolution of following host names on the command line
+to the IPv6 namespace.
+
+@node ntpd authreq
+@subsection authreq option (-a)
+@cindex ntpd-authreq
+
+This is the ``require crypto authentication'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+authnoreq.
+@end itemize
+
+Require cryptographic authentication for broadcast client,
+multicast client and symmetric passive associations.
+This is the default.
+
+@node ntpd authnoreq
+@subsection authnoreq option (-A)
+@cindex ntpd-authnoreq
+
+This is the ``do not require crypto authentication'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+authreq.
+@end itemize
+
+Do not require cryptographic authentication for broadcast client,
+multicast client and symmetric passive associations.
+This is almost never a good idea.
+
+@node ntpd bcastsync
+@subsection bcastsync option (-b)
+@cindex ntpd-bcastsync
+
+This is the ``allow us to sync to broadcast servers'' option.
+
+
+@node ntpd configfile
+@subsection configfile option (-c)
+@cindex ntpd-configfile
+
+This is the ``configuration file name'' option.
+The name and path of the configuration file,
+/etc/ntp.conf
+by default.
+
+@node ntpd debug-level
+@subsection debug-level option (-d)
+@cindex ntpd-debug-level
+
+This is the ``increase output debug message level'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@item
+must be compiled in by defining @code{DEBUG} during the compilation.
+@end itemize
+
+Increase the debugging message output level.
+
+@node ntpd set-debug-level
+@subsection set-debug-level option (-D)
+@cindex ntpd-set-debug-level
+
+This is the ``set the output debug message level'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@item
+must be compiled in by defining @code{DEBUG} during the compilation.
+@end itemize
+
+Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+
+@node ntpd driftfile
+@subsection driftfile option (-f)
+@cindex ntpd-driftfile
+
+This is the ``frequency drift file name'' option.
+The name and path of the frequency file,
+/etc/ntp.drift
+by default.
+This is the same operation as the
+driftfile driftfile
+configuration specification in the 
+/etc/ntp.conf
+file.
+
+@node ntpd panicgate
+@subsection panicgate option (-g)
+@cindex ntpd-panicgate
+
+This is the ``allow the first adjustment to be big'' option.
+Normally,
+ntpd
+exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows the time to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that,
+ntpd
+will exit with a message to the system log. This option can be used with the
+-q
+and
+-x
+options.
+See the
+tinker
+configuration file directive for other options.
+
+@node ntpd jaildir
+@subsection jaildir option (-i)
+@cindex ntpd-jaildir
+
+This is the ``jail directory'' option.
+Chroot the server to the directory
+jaildir
+.
+This option also implies that the server attempts to drop root privileges at startup (otherwise, chroot gives very little additional security), and it is only available if the OS supports to run the server without full root privileges.
+You may need to also specify a
+-u
+option.
+
+@node ntpd interface
+@subsection interface option (-I)
+@cindex ntpd-interface
+
+This is the ``listen on interface'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+
+
+@node ntpd keyfile
+@subsection keyfile option (-k)
+@cindex ntpd-keyfile
+
+This is the ``path to symmetric keys'' option.
+Specify the name and path of the symmetric key file.
+/etc/ntp.keys
+is the default.
+This is the same operation as the
+keys keyfile
+configuration file directive.
+
+@node ntpd logfile
+@subsection logfile option (-l)
+@cindex ntpd-logfile
+
+This is the ``path to the log file'' option.
+Specify the name and path of the log file.
+The default is the system log file.
+This is the same operation as the
+logfile logfile
+configuration file directive.
+
+@node ntpd novirtualips
+@subsection novirtualips option (-L)
+@cindex ntpd-novirtualips
+
+This is the ``do not listen to virtual ips'' option.
+Do not listen to virtual IPs. The default is to listen.
+
+@node ntpd modifymmtimer
+@subsection modifymmtimer option (-M)
+@cindex ntpd-modifymmtimer
+
+This is the ``modify multimedia timer (windows only)'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{SYS_WINNT} during the compilation.
+@end itemize
+
+Set the Windows Multimedia Timer to highest resolution.
+
+@node ntpd nofork
+@subsection nofork option (-n)
+@cindex ntpd-nofork
+
+This is the ``do not fork'' option.
+
+
+@node ntpd nice
+@subsection nice option (-N)
+@cindex ntpd-nice
+
+This is the ``run at high priority'' option.
+To the extent permitted by the operating system, run
+ntpd
+at the highest priority.
+
+@node ntpd pidfile
+@subsection pidfile option (-p)
+@cindex ntpd-pidfile
+
+This is the ``path to the pid file'' option.
+Specify the name and path of the file used to record
+ntpd's
+process ID.
+This is the same operation as the
+pidfile pidfile
+configuration file directive.
+
+@node ntpd priority
+@subsection priority option (-P)
+@cindex ntpd-priority
+
+This is the ``process priority'' option.
+To the extent permitted by the operating system, run
+ntpd
+at the specified
+sched_setscheduler(SCHED_FIFO)
+priority.
+
+@node ntpd quit
+@subsection quit option (-q)
+@cindex ntpd-quit
+
+This is the ``set the time and quit'' option.
+ntpd
+will exit just after the first time the clock is set. This behavior mimics that of the
+ntpdate
+program, which is to be retired.
+The
+-g
+and
+-x
+options can be used with this option.
+Note: The kernel time discipline is disabled with this option.
+
+@node ntpd propagationdelay
+@subsection propagationdelay option (-r)
+@cindex ntpd-propagationdelay
+
+This is the ``broadcast/propagation delay'' option.
+Specify the default propagation delay from the broadcast/multicast server to this client. This is necessary only if the delay cannot be computed automatically by the protocol.
+
+@node ntpd updateinterval
+@subsection updateinterval option (-U)
+@cindex ntpd-updateinterval
+
+This is the ``interval in seconds between scans for new or dropped interfaces'' option.
+Give the time in seconds between two scans for new or dropped interfaces.
+For systems with routing socket support the scans will be performed shortly after the interface change
+has been detected by the system.
+Use 0 to disable scanning.
+
+@node ntpd statsdir
+@subsection statsdir option (-s)
+@cindex ntpd-statsdir
+
+This is the ``statistics file location'' option.
+Specify the directory path for files created by the statistics facility.
+This is the same operation as the
+statsdir statsdir
+configuration file directive.
+
+@node ntpd trustedkey
+@subsection trustedkey option (-t)
+@cindex ntpd-trustedkey
+
+This is the ``trusted key number'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+Add a key number to the trusted key list.
+
+@node ntpd user
+@subsection user option (-u)
+@cindex ntpd-user
+
+This is the ``run as userid (or userid:groupid)'' option.
+Specify a user, and optionally a group, to switch to.
+This option is only available if the OS supports to run the server without full root privileges.
+Currently, this option is supported under NetBSD (configure with
+--enable-clockctl
+) and Linux (configure with
+--enable-linuxcaps
+).
+
+@node ntpd var
+@subsection var option (-v)
+@cindex ntpd-var
+
+This is the ``make arg an ntp variable (rw)'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+
+
+@node ntpd dvar
+@subsection dvar option (-V)
+@cindex ntpd-dvar
+
+This is the ``make arg an ntp variable (rw|def)'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+
+
+@node ntpd slew
+@subsection slew option (-x)
+@cindex ntpd-slew
+
+This is the ``slew up to 600 seconds'' option.
+Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold.
+This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually.
+Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s.
+Thus, an adjustment as much as 600 s will take almost 14 days to complete.
+This option can be used with the
+-g
+and
+-q
+options.
+See the
+tinker
+configuration file directive for other options.
+Note: The kernel time discipline is disabled with this option.
diff --git a/ntpd/ntpd.1 b/ntpd/ntpd.1
new file mode 100644 (file)
index 0000000..ec0a0ed
--- /dev/null
@@ -0,0 +1,296 @@
+.TH NTPD 1 2009-12-08 "( 4.2.4p8)" "Programmer's Manual"
+.\"  EDIT THIS FILE WITH CAUTION  (ntpd.1)
+.\"  
+.\"  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:13:11 AM EST
+.\"  From the definitions    ntpd-opts.def
+.\"  and the template file   agman1.tpl
+.\"
+.SH NAME
+ntpd \- NTP daemon program
+.SH SYNOPSIS
+.B ntpd
+.\" Mixture of short (flag) options and long options
+.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..."
+.PP
+All arguments must be options.
+.SH "DESCRIPTION"
+This manual page documents, briefly, the \fBntpd\fP command.
+
+.SH OPTIONS
+.TP
+.BR \-4 ", " \--ipv4
+Force IPv4 DNS name resolution.
+This option is a member of the ipv4 class of options.
+.sp
+Force DNS resolution of following host names on the command line
+to the IPv4 namespace.
+.TP
+.BR \-6 ", " \--ipv6
+Force IPv6 DNS name resolution.
+This option is a member of the ipv4 class of options.
+.sp
+Force DNS resolution of following host names on the command line
+to the IPv6 namespace.
+.TP
+.BR \-a ", " \--authreq
+Require crypto authentication.
+This option must not appear in combination with any of the following options:
+authnoreq.
+.sp
+Require cryptographic authentication for broadcast client,
+multicast client and symmetric passive associations.
+This is the default.
+.TP
+.BR \-A ", " \--authnoreq
+Do not require crypto authentication.
+This option must not appear in combination with any of the following options:
+authreq.
+.sp
+Do not require cryptographic authentication for broadcast client,
+multicast client and symmetric passive associations.
+This is almost never a good idea.
+.TP
+.BR \-b ", " \--bcastsync
+Allow us to sync to broadcast servers.
+.sp
+
+.TP
+.BR \-c " \fIstring\fP, " \--configfile "=" \fIstring\fP
+configuration file name.
+.sp
+The name and path of the configuration file,
+/etc/ntp.conf
+by default.
+.TP
+.BR \-d ", " \--debug-level
+Increase output debug message level.
+This option may appear an unlimited number of times.
+.sp
+Increase the debugging message output level.
+.TP
+.BR \-D " \fIstring\fP, " \--set-debug-level "=" \fIstring\fP
+Set the output debug message level.
+This option may appear an unlimited number of times.
+.sp
+Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+.TP
+.BR \-f " \fIstring\fP, " \--driftfile "=" \fIstring\fP
+frequency drift file name.
+.sp
+The name and path of the frequency file,
+/etc/ntp.drift
+by default.
+This is the same operation as the
+driftfile driftfile
+configuration specification in the 
+/etc/ntp.conf
+file.
+.TP
+.BR \-g ", " \--panicgate
+Allow the first adjustment to be Big.
+.sp
+Normally,
+ntpd
+exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows the time to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that,
+ntpd
+will exit with a message to the system log. This option can be used with the
+-q
+and
+-x
+options.
+See the
+tinker
+configuration file directive for other options.
+.TP
+.BR \-i " \fIstring\fP, " \--jaildir "=" \fIstring\fP
+Jail directory.
+.sp
+Chroot the server to the directory
+jaildir
+.
+This option also implies that the server attempts to drop root privileges at startup (otherwise, chroot gives very little additional security), and it is only available if the OS supports to run the server without full root privileges.
+You may need to also specify a
+-u
+option.
+.TP
+.BR \-I " \fIiface\fP, " \--interface "=" \fIiface\fP
+Listen on interface.
+This option may appear an unlimited number of times.
+.sp
+
+.TP
+.BR \-k " \fIstring\fP, " \--keyfile "=" \fIstring\fP
+path to symmetric keys.
+.sp
+Specify the name and path of the symmetric key file.
+/etc/ntp.keys
+is the default.
+This is the same operation as the
+keys keyfile
+configuration file directive.
+.TP
+.BR \-l " \fIstring\fP, " \--logfile "=" \fIstring\fP
+path to the log file.
+.sp
+Specify the name and path of the log file.
+The default is the system log file.
+This is the same operation as the
+logfile logfile
+configuration file directive.
+.TP
+.BR \-L ", " \--novirtualips
+Do not listen to virtual IPs.
+.sp
+Do not listen to virtual IPs. The default is to listen.
+.TP
+.BR \-M ", " \--modifymmtimer
+Modify Multimedia Timer (Windows only).
+.sp
+Set the Windows Multimedia Timer to highest resolution.
+.TP
+.BR \-n ", " \--nofork
+Do not fork.
+.sp
+
+.TP
+.BR \-N ", " \--nice
+Run at high priority.
+.sp
+To the extent permitted by the operating system, run
+ntpd
+at the highest priority.
+.TP
+.BR \-p " \fIstring\fP, " \--pidfile "=" \fIstring\fP
+path to the PID file.
+.sp
+Specify the name and path of the file used to record
+ntpd's
+process ID.
+This is the same operation as the
+pidfile pidfile
+configuration file directive.
+.TP
+.BR \-P " \fInumber\fP, " \--priority "=" \fInumber\fP
+Process priority.
+This option takes an integer number as its argument.
+.sp
+To the extent permitted by the operating system, run
+ntpd
+at the specified
+sched_setscheduler(SCHED_FIFO)
+priority.
+.TP
+.BR \-q ", " \--quit
+Set the time and quit.
+.sp
+ntpd
+will exit just after the first time the clock is set. This behavior mimics that of the
+ntpdate
+program, which is to be retired.
+The
+-g
+and
+-x
+options can be used with this option.
+Note: The kernel time discipline is disabled with this option.
+.TP
+.BR \-r " \fIstring\fP, " \--propagationdelay "=" \fIstring\fP
+Broadcast/propagation delay.
+.sp
+Specify the default propagation delay from the broadcast/multicast server to this client. This is necessary only if the delay cannot be computed automatically by the protocol.
+.TP
+.BR \-U " \fInumber\fP, " \--updateinterval "=" \fInumber\fP
+interval in seconds between scans for new or dropped interfaces.
+This option takes an integer number as its argument.
+.sp
+Give the time in seconds between two scans for new or dropped interfaces.
+For systems with routing socket support the scans will be performed shortly after the interface change
+has been detected by the system.
+Use 0 to disable scanning.
+.TP
+.BR \-s " \fIstring\fP, " \--statsdir "=" \fIstring\fP
+Statistics file location.
+.sp
+Specify the directory path for files created by the statistics facility.
+This is the same operation as the
+statsdir statsdir
+configuration file directive.
+.TP
+.BR \-t " \fItkey\fP, " \--trustedkey "=" \fItkey\fP
+Trusted key number.
+This option may appear an unlimited number of times.
+.sp
+Add a key number to the trusted key list.
+.TP
+.BR \-u " \fIstring\fP, " \--user "=" \fIstring\fP
+Run as userid (or userid:groupid).
+.sp
+Specify a user, and optionally a group, to switch to.
+This option is only available if the OS supports to run the server without full root privileges.
+Currently, this option is supported under NetBSD (configure with
+--enable-clockctl
+) and Linux (configure with
+--enable-linuxcaps
+).
+.TP
+.BR \-v " \fInvar\fP, " \--var "=" \fInvar\fP
+make ARG an ntp variable (RW).
+This option may appear an unlimited number of times.
+.sp
+
+.TP
+.BR \-V " \fIndvar\fP, " \--dvar "=" \fIndvar\fP
+make ARG an ntp variable (RW|DEF).
+This option may appear an unlimited number of times.
+.sp
+
+.TP
+.BR \-x ", " \--slew
+Slew up to 600 seconds.
+.sp
+Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold.
+This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually.
+Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s.
+Thus, an adjustment as much as 600 s will take almost 14 days to complete.
+This option can be used with the
+-g
+and
+-q
+options.
+See the
+tinker
+configuration file directive for other options.
+Note: The kernel time discipline is disabled with this option.
+.TP
+.BR \-? , " \--help"
+Display usage information and exit.
+.TP
+.BR \-! , " \--more-help"
+Extended usage information passed thru pager.
+.TP
+.BR \-v " [{\fIv|c|n\fP}]," " \--version" "[=\fI{v|c|n}\fP]"
+Output version of program and exit.  The default mode is `v', a simple
+version.  The `c' mode will print copyright information and `n' will
+print the full copyright notice.
+.SH OPTION PRESETS
+Any option that is not marked as \fInot presettable\fP may be preset
+by loading values from environment variables named:
+.nf
+  \fBNTPD_<option-name>\fP or \fBNTPD\fP
+.fi
+.aj
+.SH AUTHOR
+David L. Mills and/or others
+.br
+Please send bug reports to:  http://bugs.ntp.org, bugs@ntp.org
+
+.PP
+.nf
+.na
+see html/copyright.html
+.fi
+.ad
+.PP
+This manual page was \fIAutoGen\fP-erated from the \fBntpd\fP
+option definitions.
diff --git a/ntpd/ntpd.c b/ntpd/ntpd.c
new file mode 100644 (file)
index 0000000..02a5198
--- /dev/null
@@ -0,0 +1,1220 @@
+/*
+ * ntpd.c - main program for the fixed point NTP daemon
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntp_machine.h"
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_stdlib.h"
+#include <ntp_random.h>
+
+#ifdef SIM
+# include "ntpsim.h"
+# include "ntpdsim-opts.h"
+#else
+# include "ntpd-opts.h"
+#endif
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#include <stdio.h>
+#if !defined(VMS)      /*wjm*/
+# ifdef HAVE_SYS_PARAM_H
+#  include <sys/param.h>
+# endif
+#endif /* VMS */
+#ifdef HAVE_SYS_SIGNAL_H
+# include <sys/signal.h>
+#else
+# include <signal.h>
+#endif
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif /* HAVE_SYS_IOCTL_H */
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif /* HAVE_SYS_RESOURCE_H */
+#if defined(HAVE_RTPRIO)
+# ifdef HAVE_SYS_RESOURCE_H
+#  include <sys/resource.h>
+# endif
+# ifdef HAVE_SYS_LOCK_H
+#  include <sys/lock.h>
+# endif
+# include <sys/rtprio.h>
+#else
+# ifdef HAVE_PLOCK
+#  ifdef HAVE_SYS_LOCK_H
+#      include <sys/lock.h>
+#  endif
+# endif
+#endif
+#if defined(HAVE_SCHED_SETSCHEDULER)
+# ifdef HAVE_SCHED_H
+#  include <sched.h>
+# else
+#  ifdef HAVE_SYS_SCHED_H
+#   include <sys/sched.h>
+#  endif
+# endif
+#endif
+#if defined(HAVE_SYS_MMAN_H)
+# include <sys/mman.h>
+#endif
+
+#ifdef HAVE_TERMIOS_H
+# include <termios.h>
+#endif
+
+#ifdef SYS_DOMAINOS
+# include <apollo/base.h>
+#endif /* SYS_DOMAINOS */
+
+#include "recvbuff.h"  
+#include "ntp_cmdargs.h"  
+
+#if 0                          /* HMS: I don't think we need this. 961223 */
+#ifdef LOCK_PROCESS
+# ifdef SYS_SOLARIS
+#  include <sys/mman.h>
+# else
+#  include <sys/lock.h>
+# endif
+#endif
+#endif
+
+#ifdef _AIX
+# include <ulimit.h>
+#endif /* _AIX */
+
+#ifdef SCO5_CLOCK
+# include <sys/ci/ciioctl.h>
+#endif
+
+#ifdef HAVE_DROPROOT
+# include <ctype.h>
+# include <grp.h>
+# include <pwd.h>
+#ifdef HAVE_LINUX_CAPABILITIES
+# include <sys/capability.h>
+# include <sys/prctl.h>
+#endif
+#endif
+
+/*
+ * Signals we catch for debugging.     If not debugging we ignore them.
+ */
+#define MOREDEBUGSIG   SIGUSR1
+#define LESSDEBUGSIG   SIGUSR2
+
+/*
+ * Signals which terminate us gracefully.
+ */
+#ifndef SYS_WINNT
+# define SIGDIE1       SIGHUP
+# define SIGDIE3       SIGQUIT
+# define SIGDIE2       SIGINT
+# define SIGDIE4       SIGTERM
+#endif /* SYS_WINNT */
+
+#ifdef HAVE_DNSREGISTRATION
+#include <dns_sd.h>
+DNSServiceRef mdns;
+#endif
+
+/*
+ * Scheduling priority we run at
+ */
+#define NTPD_PRIO      (-12)
+
+int priority_done = 2;         /* 0 - Set priority */
+                               /* 1 - priority is OK where it is */
+                               /* 2 - Don't set priority */
+                               /* 1 and 2 are pretty much the same */
+
+#ifdef DEBUG
+/*
+ * Debugging flag
+ */
+volatile int debug = 0;                /* No debugging by default */
+#endif
+
+int    listen_to_virtual_ips = 1;
+const char *specific_interface = NULL;        /* interface name or IP address to bind to */
+
+/*
+ * No-fork flag.  If set, we do not become a background daemon.
+ */
+int nofork = 0;                        /* Fork by default */
+
+#ifdef HAVE_DROPROOT
+int droproot = 0;
+char *user = NULL;             /* User to switch to */
+char *group = NULL;            /* group to switch to */
+char *chrootdir = NULL;                /* directory to chroot to */
+int sw_uid;
+int sw_gid;
+char *endp;  
+struct group *gr;
+struct passwd *pw; 
+#endif /* HAVE_DROPROOT */
+
+/*
+ * Initializing flag.  All async routines watch this and only do their
+ * thing when it is clear.
+ */
+int initializing;
+
+/*
+ * Version declaration
+ */
+extern const char *Version;
+
+char const *progname;
+
+int was_alarmed;
+
+#ifdef DECL_SYSCALL
+/*
+ * We put this here, since the argument profile is syscall-specific
+ */
+extern int syscall     P((int, ...));
+#endif /* DECL_SYSCALL */
+
+
+#ifdef SIGDIE2
+static RETSIGTYPE      finish          P((int));
+#endif /* SIGDIE2 */
+
+#ifdef DEBUG
+#ifndef SYS_WINNT
+static RETSIGTYPE      moredebug       P((int));
+static RETSIGTYPE      lessdebug       P((int));
+#endif
+#else /* not DEBUG */
+static RETSIGTYPE      no_debug        P((int));
+#endif /* not DEBUG */
+
+int            ntpdmain                P((int, char **));
+static void    set_process_priority    P((void));
+static void    init_logging            P((char const *));
+static void    setup_logfile           P((void));
+
+/*
+ * Initialize the logging
+ */
+void
+init_logging(char const *name)
+{
+       const char *cp;
+
+       /*
+        * Logging.  This may actually work on the gizmo board.  Find a name
+        * to log with by using the basename
+        */
+       cp = strrchr(name, '/');
+       if (cp == 0)
+               cp = name;
+       else
+               cp++;
+
+#if !defined(VMS)
+
+# ifndef LOG_DAEMON
+       openlog(cp, LOG_PID);
+# else /* LOG_DAEMON */
+
+#  ifndef LOG_NTP
+#      define  LOG_NTP LOG_DAEMON
+#  endif
+       openlog(cp, LOG_PID | LOG_NDELAY, LOG_NTP);
+#  ifdef DEBUG
+       if (debug)
+               setlogmask(LOG_UPTO(LOG_DEBUG));
+       else
+#  endif /* DEBUG */
+               setlogmask(LOG_UPTO(LOG_DEBUG)); /* @@@ was INFO */
+# endif /* LOG_DAEMON */
+#endif /* !SYS_WINNT && !VMS */
+
+       NLOG(NLOG_SYSINFO) /* conditional if clause for conditional syslog */
+               msyslog(LOG_NOTICE, "%s", Version);
+}
+
+
+/*
+ * See if we should redirect the logfile
+ */
+
+void
+setup_logfile(
+       void
+       )
+{
+       if (HAVE_OPT( LOGFILE )) {
+               const char *my_optarg = OPT_ARG( LOGFILE );
+               FILE *new_file;
+
+               if(strcmp(my_optarg, "stderr") == 0)
+                       new_file = stderr;
+               else if(strcmp(my_optarg, "stdout") == 0)
+                       new_file = stdout;
+               else
+                       new_file = fopen(my_optarg, "a");
+               if (new_file != NULL) {
+                       NLOG(NLOG_SYSINFO)
+                               msyslog(LOG_NOTICE, "logging to file %s", my_optarg);
+                       if (syslog_file != NULL &&
+                               fileno(syslog_file) != fileno(new_file))
+                               (void)fclose(syslog_file);
+
+                       syslog_file = new_file;
+                       syslogit = 0;
+               }
+               else
+                       msyslog(LOG_ERR,
+                               "Cannot open log file %s",
+                               my_optarg);
+       }
+}
+
+#ifdef SIM
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       return ntpsim(argc, argv);
+}
+#else /* SIM */
+#ifdef NO_MAIN_ALLOWED
+CALL(ntpd,"ntpd",ntpdmain);
+#else
+#ifndef SYS_WINNT
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       return ntpdmain(argc, argv);
+}
+#endif /* SYS_WINNT */
+#endif /* NO_MAIN_ALLOWED */
+#endif /* SIM */
+
+#ifdef _AIX
+/*
+ * OK. AIX is different than solaris in how it implements plock().
+ * If you do NOT adjust the stack limit, you will get the MAXIMUM
+ * stack size allocated and PINNED with you program. To check the 
+ * value, use ulimit -a. 
+ *
+ * To fix this, we create an automatic variable and set our stack limit 
+ * to that PLUS 32KB of extra space (we need some headroom).
+ *
+ * This subroutine gets the stack address.
+ *
+ * Grover Davidson and Matt Ladendorf
+ *
+ */
+static char *
+get_aix_stack(void)
+{
+       char ch;
+       return (&ch);
+}
+
+/*
+ * Signal handler for SIGDANGER.
+ */
+static void
+catch_danger(int signo)
+{
+       msyslog(LOG_INFO, "ntpd: setpgid(): %m");
+       /* Make the system believe we'll free something, but don't do it! */
+       return;
+}
+#endif /* _AIX */
+
+/*
+ * Set the process priority
+ */
+static void
+set_process_priority(void)
+{
+
+#ifdef DEBUG
+       if (debug > 1)
+               msyslog(LOG_DEBUG, "set_process_priority: %s: priority_done is <%d>",
+                       ((priority_done)
+                        ? "Leave priority alone"
+                        : "Attempt to set priority"
+                               ),
+                       priority_done);
+#endif /* DEBUG */
+
+#ifdef SYS_WINNT
+       priority_done += NT_set_process_priority();
+#endif
+
+#if defined(HAVE_SCHED_SETSCHEDULER)
+       if (!priority_done) {
+               extern int config_priority_override, config_priority;
+               int pmax, pmin;
+               struct sched_param sched;
+
+               pmax = sched_get_priority_max(SCHED_FIFO);
+               sched.sched_priority = pmax;
+               if ( config_priority_override ) {
+                       pmin = sched_get_priority_min(SCHED_FIFO);
+                       if ( config_priority > pmax )
+                               sched.sched_priority = pmax;
+                       else if ( config_priority < pmin )
+                               sched.sched_priority = pmin;
+                       else
+                               sched.sched_priority = config_priority;
+               }
+               if ( sched_setscheduler(0, SCHED_FIFO, &sched) == -1 )
+                       msyslog(LOG_ERR, "sched_setscheduler(): %m");
+               else
+                       ++priority_done;
+       }
+#endif /* HAVE_SCHED_SETSCHEDULER */
+#if defined(HAVE_RTPRIO)
+# ifdef RTP_SET
+       if (!priority_done) {
+               struct rtprio srtp;
+
+               srtp.type = RTP_PRIO_REALTIME;  /* was: RTP_PRIO_NORMAL */
+               srtp.prio = 0;          /* 0 (hi) -> RTP_PRIO_MAX (31,lo) */
+
+               if (rtprio(RTP_SET, getpid(), &srtp) < 0)
+                       msyslog(LOG_ERR, "rtprio() error: %m");
+               else
+                       ++priority_done;
+       }
+# else /* not RTP_SET */
+       if (!priority_done) {
+               if (rtprio(0, 120) < 0)
+                       msyslog(LOG_ERR, "rtprio() error: %m");
+               else
+                       ++priority_done;
+       }
+# endif /* not RTP_SET */
+#endif  /* HAVE_RTPRIO */
+#if defined(NTPD_PRIO) && NTPD_PRIO != 0
+# ifdef HAVE_ATT_NICE
+       if (!priority_done) {
+               errno = 0;
+               if (-1 == nice (NTPD_PRIO) && errno != 0)
+                       msyslog(LOG_ERR, "nice() error: %m");
+               else
+                       ++priority_done;
+       }
+# endif /* HAVE_ATT_NICE */
+# ifdef HAVE_BSD_NICE
+       if (!priority_done) {
+               if (-1 == setpriority(PRIO_PROCESS, 0, NTPD_PRIO))
+                       msyslog(LOG_ERR, "setpriority() error: %m");
+               else
+                       ++priority_done;
+       }
+# endif /* HAVE_BSD_NICE */
+#endif /* NTPD_PRIO && NTPD_PRIO != 0 */
+       if (!priority_done)
+               msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority");
+}
+
+
+/*
+ * Main program.  Initialize us, disconnect us from the tty if necessary,
+ * and loop waiting for I/O and/or timer expiries.
+ */
+int
+ntpdmain(
+       int argc,
+       char *argv[]
+       )
+{
+       l_fp now;
+       struct recvbuf *rbuf;
+#ifdef _AIX                    /* HMS: ifdef SIGDANGER? */
+       struct sigaction sa;
+#endif
+
+       progname = argv[0];
+
+       initializing = 1;               /* mark that we are initializing */
+
+       {
+               int optct = optionProcess(
+#ifdef SIM
+                                         &ntpdsimOptions
+#else
+                                         &ntpdOptions
+#endif
+                                         , argc, argv);
+               argc -= optct;
+               argv += optct;
+       }
+
+       /* HMS: is this lame? Should we process -l first? */
+
+       init_logging(progname);         /* Open the log file */
+
+#ifdef HAVE_UMASK
+       {
+               mode_t uv;
+
+               uv = umask(0);
+               if(uv)
+                       (void) umask(uv);
+               else
+                       (void) umask(022);
+       }
+#endif
+
+#if defined(HAVE_GETUID) && !defined(MPE) /* MPE lacks the concept of root */
+       {
+               uid_t uid;
+
+               uid = getuid();
+               if (uid)
+               {
+                       msyslog(LOG_ERR, "ntpd: must be run as root, not uid %ld", (long)uid);
+                       printf("must be run as root, not uid %ld", (long)uid);
+                       exit(1);
+               }
+       }
+#endif
+
+#ifdef OPENSSL
+       if ((SSLeay() ^ OPENSSL_VERSION_NUMBER) & ~0xff0L) {
+               msyslog(LOG_ERR,
+                   "ntpd: OpenSSL version mismatch. Built against %lx, you have %lx\n",
+                   OPENSSL_VERSION_NUMBER, SSLeay());
+               exit(1);
+       }
+#endif
+
+       /* getstartup(argc, argv); / * startup configuration, may set debug */
+
+#ifdef DEBUG
+       debug = DESC(DEBUG_LEVEL).optOccCt;
+       if (debug)
+           printf("%s\n", Version);
+#endif
+
+/*
+ * Enable the Multi-Media Timer for Windows?
+ */
+#ifdef SYS_WINNT
+       if (HAVE_OPT( MODIFYMMTIMER ))
+               set_mm_timer(MM_TIMER_HIRES);
+#endif
+
+       if (HAVE_OPT( NOFORK ) || HAVE_OPT( QUIT ))
+               nofork = 1;
+
+       if (HAVE_OPT( NOVIRTUALIPS ))
+               listen_to_virtual_ips = 0;
+
+       if (HAVE_OPT( INTERFACE )) {
+#if 0
+               int     ifacect = STACKCT_OPT( INTERFACE );
+               char**  ifaces  = STACKLST_OPT( INTERFACE );
+
+               /* malloc space for the array of names */
+               while (ifacect-- > 0) {
+                       next_iface = *ifaces++;
+               }
+#else
+               specific_interface = OPT_ARG( INTERFACE );
+#endif
+       }
+
+       if (HAVE_OPT( NICE ))
+               priority_done = 0;
+
+#if defined(HAVE_SCHED_SETSCHEDULER)
+       if (HAVE_OPT( PRIORITY )) {
+               config_priority = OPT_VALUE_PRIORITY;
+               config_priority_override = 1;
+               priority_done = 0;
+       }
+#endif
+
+#ifdef SYS_WINNT
+       /*
+        * Initialize the time structures and variables
+        */
+       init_winnt_time();
+#endif
+
+       setup_logfile();
+
+       /*
+        * Initialize random generator and public key pair
+        */
+       get_systime(&now);
+
+       ntp_srandom((int)(now.l_i * now.l_uf));
+
+#ifdef HAVE_DNSREGISTRATION
+       /* HMS: does this have to happen this early? */
+       msyslog(LOG_INFO, "Attemping to register mDNS");
+       if ( DNSServiceRegister (&mdns, 0, 0, NULL, "_ntp._udp", NULL, NULL, htons(NTP_PORT), 0, NULL, NULL, NULL) != kDNSServiceErr_NoError ) {
+               msyslog(LOG_ERR, "Unable to register mDNS");
+       }
+#endif
+
+#if !defined(VMS)
+# ifndef NODETACH
+       /*
+        * Detach us from the terminal.  May need an #ifndef GIZMO.
+        */
+       if (
+#  ifdef DEBUG
+           !debug &&
+#  endif /* DEBUG */
+           !nofork)
+       {
+#  ifndef SYS_WINNT
+#   ifdef HAVE_DAEMON
+               daemon(0, 0);
+#   else /* not HAVE_DAEMON */
+               if (fork())     /* HMS: What about a -1? */
+                       exit(0);
+
+               {
+#if !defined(F_CLOSEM)
+                       u_long s;
+                       int max_fd;
+#endif /* not F_CLOSEM */
+
+#if defined(F_CLOSEM)
+                       /*
+                        * From 'Writing Reliable AIX Daemons,' SG24-4946-00,
+                        * by Eric Agar (saves us from doing 32767 system
+                        * calls)
+                        */
+                       if (fcntl(0, F_CLOSEM, 0) == -1)
+                           msyslog(LOG_ERR, "ntpd: failed to close open files(): %m");
+#else  /* not F_CLOSEM */
+
+# if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
+                       max_fd = sysconf(_SC_OPEN_MAX);
+# else /* HAVE_SYSCONF && _SC_OPEN_MAX */
+                       max_fd = getdtablesize();
+# endif /* HAVE_SYSCONF && _SC_OPEN_MAX */
+                       for (s = 0; s < max_fd; s++)
+                               (void) close((int)s);
+#endif /* not F_CLOSEM */
+                       (void) open("/", 0);
+                       (void) dup2(0, 1);
+                       (void) dup2(0, 2);
+#ifdef SYS_DOMAINOS
+                       {
+                               uid_$t puid;
+                               status_$t st;
+
+                               proc2_$who_am_i(&puid);
+                               proc2_$make_server(&puid, &st);
+                       }
+#endif /* SYS_DOMAINOS */
+#if defined(HAVE_SETPGID) || defined(HAVE_SETSID)
+# ifdef HAVE_SETSID
+                       if (setsid() == (pid_t)-1)
+                               msyslog(LOG_ERR, "ntpd: setsid(): %m");
+# else
+                       if (setpgid(0, 0) == -1)
+                               msyslog(LOG_ERR, "ntpd: setpgid(): %m");
+# endif
+#else /* HAVE_SETPGID || HAVE_SETSID */
+                       {
+# if defined(TIOCNOTTY)
+                               int fid;
+
+                               fid = open("/dev/tty", 2);
+                               if (fid >= 0)
+                               {
+                                       (void) ioctl(fid, (u_long) TIOCNOTTY, (char *) 0);
+                                       (void) close(fid);
+                               }
+# endif /* defined(TIOCNOTTY) */
+# ifdef HAVE_SETPGRP_0
+                               (void) setpgrp();
+# else /* HAVE_SETPGRP_0 */
+                               (void) setpgrp(0, getpid());
+# endif /* HAVE_SETPGRP_0 */
+                       }
+#endif /* HAVE_SETPGID || HAVE_SETSID */
+#ifdef _AIX
+                       /* Don't get killed by low-on-memory signal. */
+                       sa.sa_handler = catch_danger;
+                       sigemptyset(&sa.sa_mask);
+                       sa.sa_flags = SA_RESTART;
+
+                       (void) sigaction(SIGDANGER, &sa, NULL);
+#endif /* _AIX */
+               }
+#   endif /* not HAVE_DAEMON */
+#  endif /* SYS_WINNT */
+       }
+# endif /* NODETACH */
+#endif /* VMS */
+
+       setup_logfile();        /* We lost any redirect when we daemonized */
+
+#ifdef SCO5_CLOCK
+       /*
+        * SCO OpenServer's system clock offers much more precise timekeeping
+        * on the base CPU than the other CPUs (for multiprocessor systems),
+        * so we must lock to the base CPU.
+        */
+       {
+           int fd = open("/dev/at1", O_RDONLY);
+           if (fd >= 0) {
+               int zero = 0;
+               if (ioctl(fd, ACPU_LOCK, &zero) < 0)
+                   msyslog(LOG_ERR, "cannot lock to base CPU: %m");
+               close( fd );
+           } /* else ...
+              *   If we can't open the device, this probably just isn't
+              *   a multiprocessor system, so we're A-OK.
+              */
+       }
+#endif
+
+#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && defined(MCL_FUTURE)
+# ifdef HAVE_SETRLIMIT
+       /*
+        * Set the stack limit to something smaller, so that we don't lock a lot
+        * of unused stack memory.
+        */
+       {
+           struct rlimit rl;
+
+           /* HMS: must make the rlim_cur amount configurable */
+           if (getrlimit(RLIMIT_STACK, &rl) != -1
+               && (rl.rlim_cur = 50 * 4096) < rl.rlim_max)
+           {
+                   if (setrlimit(RLIMIT_STACK, &rl) == -1)
+                   {
+                           msyslog(LOG_ERR,
+                               "Cannot adjust stack limit for mlockall: %m");
+                   }
+           }
+#  ifdef RLIMIT_MEMLOCK
+           /*
+            * The default RLIMIT_MEMLOCK is very low on Linux systems.
+            * Unless we increase this limit malloc calls are likely to
+            * fail if we drop root privlege.  To be useful the value
+            * has to be larger than the largest ntpd resident set size.
+            */
+           rl.rlim_cur = rl.rlim_max = 32*1024*1024;
+           if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) {
+               msyslog(LOG_ERR, "Cannot set RLIMIT_MEMLOCK: %m");
+           }
+#  endif /* RLIMIT_MEMLOCK */
+       }
+# endif /* HAVE_SETRLIMIT */
+       /*
+        * lock the process into memory
+        */
+       if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
+               msyslog(LOG_ERR, "mlockall(): %m");
+#else /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */
+# ifdef HAVE_PLOCK
+#  ifdef PROCLOCK
+#   ifdef _AIX
+       /* 
+        * set the stack limit for AIX for plock().
+        * see get_aix_stack() for more info.
+        */
+       if (ulimit(SET_STACKLIM, (get_aix_stack() - 8*4096)) < 0)
+       {
+               msyslog(LOG_ERR,"Cannot adjust stack limit for plock on AIX: %m");
+       }
+#   endif /* _AIX */
+       /*
+        * lock the process into memory
+        */
+       if (plock(PROCLOCK) < 0)
+               msyslog(LOG_ERR, "plock(PROCLOCK): %m");
+#  else /* not PROCLOCK */
+#   ifdef TXTLOCK
+       /*
+        * Lock text into ram
+        */
+       if (plock(TXTLOCK) < 0)
+               msyslog(LOG_ERR, "plock(TXTLOCK) error: %m");
+#   else /* not TXTLOCK */
+       msyslog(LOG_ERR, "plock() - don't know what to lock!");
+#   endif /* not TXTLOCK */
+#  endif /* not PROCLOCK */
+# endif /* HAVE_PLOCK */
+#endif /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */
+
+       /*
+        * Set up signals we pay attention to locally.
+        */
+#ifdef SIGDIE1
+       (void) signal_no_reset(SIGDIE1, finish);
+#endif /* SIGDIE1 */
+#ifdef SIGDIE2
+       (void) signal_no_reset(SIGDIE2, finish);
+#endif /* SIGDIE2 */
+#ifdef SIGDIE3
+       (void) signal_no_reset(SIGDIE3, finish);
+#endif /* SIGDIE3 */
+#ifdef SIGDIE4
+       (void) signal_no_reset(SIGDIE4, finish);
+#endif /* SIGDIE4 */
+
+#ifdef SIGBUS
+       (void) signal_no_reset(SIGBUS, finish);
+#endif /* SIGBUS */
+
+#if !defined(SYS_WINNT) && !defined(VMS)
+# ifdef DEBUG
+       (void) signal_no_reset(MOREDEBUGSIG, moredebug);
+       (void) signal_no_reset(LESSDEBUGSIG, lessdebug);
+# else
+       (void) signal_no_reset(MOREDEBUGSIG, no_debug);
+       (void) signal_no_reset(LESSDEBUGSIG, no_debug);
+# endif /* DEBUG */
+#endif /* !SYS_WINNT && !VMS */
+
+       /*
+        * Set up signals we should never pay attention to.
+        */
+#if defined SIGPIPE
+       (void) signal_no_reset(SIGPIPE, SIG_IGN);
+#endif /* SIGPIPE */
+
+       /*
+        * Call the init_ routines to initialize the data structures.
+        *
+        * Exactly what command-line options are we expecting here?
+        */
+       init_auth();
+       init_util();
+       init_restrict();
+       init_mon();
+       init_timer();
+       init_lib();
+       init_request();
+       init_control();
+       init_peer();
+#ifdef REFCLOCK
+       init_refclock();
+#endif
+       set_process_priority();
+       init_proto();           /* Call at high priority */
+       init_io();
+       init_loopfilter();
+       mon_start(MON_ON);      /* monitor on by default now      */
+                               /* turn off in config if unwanted */
+
+       /*
+        * Get the configuration.  This is done in a separate module
+        * since this will definitely be different for the gizmo board.
+        */
+
+       getconfig(argc, argv);
+
+       loop_config(LOOP_DRIFTCOMP, old_drift / 1e6);
+#ifdef OPENSSL
+       crypto_setup();
+#endif /* OPENSSL */
+       initializing = 0;
+
+#ifdef HAVE_DROPROOT
+       if( droproot ) {
+               /* Drop super-user privileges and chroot now if the OS supports this */
+
+#ifdef HAVE_LINUX_CAPABILITIES
+               /* set flag: keep privileges accross setuid() call (we only really need cap_sys_time): */
+               if( prctl( PR_SET_KEEPCAPS, 1L, 0L, 0L, 0L ) == -1 ) {
+                       msyslog( LOG_ERR, "prctl( PR_SET_KEEPCAPS, 1L ) failed: %m" );
+                       exit(-1);
+               }
+#else
+               /* we need a user to switch to */
+               if( user == NULL ) {
+                       msyslog(LOG_ERR, "Need user name to drop root privileges (see -u flag!)" );
+                       exit(-1);
+               }
+#endif /* HAVE_LINUX_CAPABILITIES */
+       
+               if (user != NULL) {
+                       if (isdigit((unsigned char)*user)) {
+                               sw_uid = (uid_t)strtoul(user, &endp, 0);
+                               if (*endp != '\0') 
+                                       goto getuser;
+                       } else {
+getuser:       
+                               if ((pw = getpwnam(user)) != NULL) {
+                                       sw_uid = pw->pw_uid;
+                               } else {
+                                       errno = 0;
+                                       msyslog(LOG_ERR, "Cannot find user `%s'", user);
+                                       exit (-1);
+                               }
+                       }
+               }
+               if (group != NULL) {
+                       if (isdigit((unsigned char)*group)) {
+                               sw_gid = (gid_t)strtoul(group, &endp, 0);
+                               if (*endp != '\0') 
+                                       goto getgroup;
+                       } else {
+getgroup:      
+                               if ((gr = getgrnam(group)) != NULL) {
+                                       sw_gid = gr->gr_gid;
+                               } else {
+                                       errno = 0;
+                                       msyslog(LOG_ERR, "Cannot find group `%s'", group);
+                                       exit (-1);
+                               }
+                       }
+               }
+               
+               if( chrootdir ) {
+                       /* make sure cwd is inside the jail: */
+                       if( chdir(chrootdir) ) {
+                               msyslog(LOG_ERR, "Cannot chdir() to `%s': %m", chrootdir);
+                               exit (-1);
+                       }
+                       if( chroot(chrootdir) ) {
+                               msyslog(LOG_ERR, "Cannot chroot() to `%s': %m", chrootdir);
+                               exit (-1);
+                       }
+               }
+               if (group && setgid(sw_gid)) {
+                       msyslog(LOG_ERR, "Cannot setgid() to group `%s': %m", group);
+                       exit (-1);
+               }
+               if (group && setegid(sw_gid)) {
+                       msyslog(LOG_ERR, "Cannot setegid() to group `%s': %m", group);
+                       exit (-1);
+               }
+               if (user && setuid(sw_uid)) {
+                       msyslog(LOG_ERR, "Cannot setuid() to user `%s': %m", user);
+                       exit (-1);
+               }
+               if (user && seteuid(sw_uid)) {
+                       msyslog(LOG_ERR, "Cannot seteuid() to user `%s': %m", user);
+                       exit (-1);
+               }
+       
+#ifndef HAVE_LINUX_CAPABILITIES
+               /*
+                * for now assume that the privilege to bind to privileged ports
+                * is associated with running with uid 0 - should be refined on
+                * ports that allow binding to NTP_PORT with uid != 0
+                */
+               disable_dynamic_updates |= (sw_uid != 0);  /* also notifies routing message listener */
+#endif
+
+               if (disable_dynamic_updates && interface_interval) {
+                       interface_interval = 0;
+                       msyslog(LOG_INFO, "running in unprivileged mode disables dynamic interface tracking");
+               }
+
+#ifdef HAVE_LINUX_CAPABILITIES
+               do {
+                       /*
+                        *  We may be running under non-root uid now, but we still hold full root privileges!
+                        *  We drop all of them, except for the crucial one or two: cap_sys_time and
+                        *  cap_net_bind_service if doing dynamic interface tracking.
+                        */
+                       cap_t caps;
+                       char *captext = interface_interval ?
+                               "cap_sys_time,cap_net_bind_service=ipe" :
+                               "cap_sys_time=ipe";
+                       if( ! ( caps = cap_from_text( captext ) ) ) {
+                               msyslog( LOG_ERR, "cap_from_text() failed: %m" );
+                               exit(-1);
+                       }
+                       if( cap_set_proc( caps ) == -1 ) {
+                               msyslog( LOG_ERR, "cap_set_proc() failed to drop root privileges: %m" );
+                               exit(-1);
+                       }
+                       cap_free( caps );
+               } while(0);
+#endif /* HAVE_LINUX_CAPABILITIES */
+
+       }    /* if( droproot ) */
+#endif /* HAVE_DROPROOT */
+       
+       /*
+        * Report that we're up to any trappers
+        */
+       report_event(EVNT_SYSRESTART, (struct peer *)0);
+
+       /*
+        * Use select() on all on all input fd's for unlimited
+        * time.  select() will terminate on SIGALARM or on the
+        * reception of input.  Using select() means we can't do
+        * robust signal handling and we get a potential race
+        * between checking for alarms and doing the select().
+        * Mostly harmless, I think.
+        */
+       /* On VMS, I suspect that select() can't be interrupted
+        * by a "signal" either, so I take the easy way out and
+        * have select() time out after one second.
+        * System clock updates really aren't time-critical,
+        * and - lacking a hardware reference clock - I have
+        * yet to learn about anything else that is.
+        */
+#if defined(HAVE_IO_COMPLETION_PORT)
+
+       for (;;) {
+               GetReceivedBuffers();
+#else /* normal I/O */
+
+       BLOCK_IO_AND_ALARM();
+       was_alarmed = 0;
+       for (;;)
+       {
+# if !defined(HAVE_SIGNALED_IO) 
+               extern fd_set activefds;
+               extern int maxactivefd;
+
+               fd_set rdfdes;
+               int nfound;
+# endif
+
+               if (alarm_flag)         /* alarmed? */
+               {
+                       was_alarmed = 1;
+                       alarm_flag = 0;
+               }
+
+               if (!was_alarmed && has_full_recv_buffer() == ISC_FALSE)
+               {
+                       /*
+                        * Nothing to do.  Wait for something.
+                        */
+# ifndef HAVE_SIGNALED_IO
+                       rdfdes = activefds;
+#  if defined(VMS) || defined(SYS_VXWORKS)
+                       /* make select() wake up after one second */
+                       {
+                               struct timeval t1;
+
+                               t1.tv_sec = 1; t1.tv_usec = 0;
+                               nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
+                                               (fd_set *)0, &t1);
+                       }
+#  else
+                       nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
+                                       (fd_set *)0, (struct timeval *)0);
+#  endif /* VMS */
+                       if (nfound > 0)
+                       {
+                               l_fp ts;
+
+                               get_systime(&ts);
+
+                               (void)input_handler(&ts);
+                       }
+                       else if (nfound == -1 && errno != EINTR)
+                               netsyslog(LOG_ERR, "select() error: %m");
+#  ifdef DEBUG
+                       else if (debug > 5)
+                               netsyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound);
+#  endif /* DEBUG */
+# else /* HAVE_SIGNALED_IO */
+                        
+                       wait_for_signal();
+# endif /* HAVE_SIGNALED_IO */
+                       if (alarm_flag)         /* alarmed? */
+                       {
+                               was_alarmed = 1;
+                               alarm_flag = 0;
+                       }
+               }
+
+               if (was_alarmed)
+               {
+                       UNBLOCK_IO_AND_ALARM();
+                       /*
+                        * Out here, signals are unblocked.  Call timer routine
+                        * to process expiry.
+                        */
+                       timer();
+                       was_alarmed = 0;
+                        BLOCK_IO_AND_ALARM();
+               }
+
+#endif /* HAVE_IO_COMPLETION_PORT */
+
+#ifdef DEBUG_TIMING
+               {
+                       l_fp pts;
+                       l_fp tsa, tsb;
+                       int bufcount = 0;
+                       
+                       get_systime(&pts);
+                       tsa = pts;
+#endif
+                       rbuf = get_full_recv_buffer();
+                       while (rbuf != NULL)
+                       {
+                               if (alarm_flag)
+                               {
+                                       was_alarmed = 1;
+                                       alarm_flag = 0;
+                               }
+                               UNBLOCK_IO_AND_ALARM();
+
+                               if (was_alarmed)
+                               {       /* avoid timer starvation during lengthy I/O handling */
+                                       timer();
+                                       was_alarmed = 0;
+                               }
+
+                               /*
+                                * Call the data procedure to handle each received
+                                * packet.
+                                */
+                               if (rbuf->receiver != NULL)     /* This should always be true */
+                               {
+#ifdef DEBUG_TIMING
+                                       l_fp dts = pts;
+
+                                       L_SUB(&dts, &rbuf->recv_time);
+                                       DPRINTF(2, ("processing timestamp delta %s (with prec. fuzz)\n", lfptoa(&dts, 9)));
+                                       collect_timing(rbuf, "buffer processing delay", 1, &dts);
+                                       bufcount++;
+#endif
+                                       (rbuf->receiver)(rbuf);
+                               } else {
+                                       msyslog(LOG_ERR, "receive buffer corruption - receiver found to be NULL - ABORTING");
+                                       abort();
+                               }
+
+                               BLOCK_IO_AND_ALARM();
+                               freerecvbuf(rbuf);
+                               rbuf = get_full_recv_buffer();
+                       }
+#ifdef DEBUG_TIMING
+                       get_systime(&tsb);
+                       L_SUB(&tsb, &tsa);
+                       if (bufcount) {
+                               collect_timing(NULL, "processing", bufcount, &tsb);
+                               DPRINTF(2, ("processing time for %d buffers %s\n", bufcount, lfptoa(&tsb, 9)));
+                       }
+               }
+#endif
+
+               /*
+                * Go around again
+                */
+       }
+       UNBLOCK_IO_AND_ALARM();
+       return 1;
+}
+
+
+#ifdef SIGDIE2
+/*
+ * finish - exit gracefully
+ */
+static RETSIGTYPE
+finish(
+       int sig
+       )
+{
+
+       msyslog(LOG_NOTICE, "ntpd exiting on signal %d", sig);
+       write_stats();
+#ifdef HAVE_DNSREGISTRATION
+       if (mdns != NULL)
+       DNSServiceRefDeallocate(mdns);
+#endif
+
+       switch (sig)
+       {
+# ifdef SIGBUS
+               case SIGBUS:
+               printf("\nfinish(SIGBUS)\n");
+               exit(0);
+# endif
+               case 0:                 /* Should never happen... */
+               return;
+               default:
+               exit(0);
+       }
+}
+#endif /* SIGDIE2 */
+
+
+#ifdef DEBUG
+#ifndef SYS_WINNT
+/*
+ * moredebug - increase debugging verbosity
+ */
+static RETSIGTYPE
+moredebug(
+       int sig
+       )
+{
+       int saved_errno = errno;
+
+       if (debug < 255)
+       {
+               debug++;
+               msyslog(LOG_DEBUG, "debug raised to %d", debug);
+       }
+       errno = saved_errno;
+}
+
+/*
+ * lessdebug - decrease debugging verbosity
+ */
+static RETSIGTYPE
+lessdebug(
+       int sig
+       )
+{
+       int saved_errno = errno;
+
+       if (debug > 0)
+       {
+               debug--;
+               msyslog(LOG_DEBUG, "debug lowered to %d", debug);
+       }
+       errno = saved_errno;
+}
+#endif
+#else /* not DEBUG */
+#ifndef SYS_WINNT
+/*
+ * no_debug - We don't do the debug here.
+ */
+static RETSIGTYPE
+no_debug(
+       int sig
+       )
+{
+       int saved_errno = errno;
+
+       msyslog(LOG_DEBUG, "ntpd not compiled for debugging (signal %d)", sig);
+       errno = saved_errno;
+}
+#endif  /* not SYS_WINNT */
+#endif /* not DEBUG */
diff --git a/ntpd/ntpdbase-opts.def b/ntpd/ntpdbase-opts.def
new file mode 100644 (file)
index 0000000..852af45
--- /dev/null
@@ -0,0 +1,459 @@
+#include autogen-version.def
+
+test-main;
+
+flag = {
+    name      = ipv4;
+    value     = 4;
+    equivalence = ipv4;
+    descrip   = "Force IPv4 DNS name resolution";
+    doc = <<-  _EndOfDoc_
+       Force DNS resolution of following host names on the command line
+       to the IPv4 namespace.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = ipv6;
+    value     = 6;
+    equivalence = ipv4;
+    descrip   = "Force IPv6 DNS name resolution";
+    doc = <<-  _EndOfDoc_
+       Force DNS resolution of following host names on the command line
+       to the IPv6 namespace.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = authreq;
+    value     = a;
+    descrip   = "Require crypto authentication";
+    flags-cant = authnoreq;
+    doc = <<-  _EndOfDoc_
+       Require cryptographic authentication for broadcast client,
+       multicast client and symmetric passive associations.
+       This is the default.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = authnoreq;
+    value     = A;
+    descrip   = "Do not require crypto authentication";
+    flags-cant = authreq;
+    doc = <<-  _EndOfDoc_
+       Do not require cryptographic authentication for broadcast client,
+       multicast client and symmetric passive associations.
+       This is almost never a good idea.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = bcastsync;
+    value     = b;
+    descrip   = "Allow us to sync to broadcast servers";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+
+#ifdef SIM
+flag = {
+    name      = simbroadcastdelay;
+    value     = B;
+    arg-type  = string;
+    descrip   = "Simulator broadcast delay";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+#endif
+
+flag = {
+    name      = configfile;
+    value     = c;
+    arg-type  = string;
+    descrip   = "configuration file name";
+    doc = <<-  _EndOfDoc_
+       The name and path of the configuration file,
+       /etc/ntp.conf
+       by default.
+       _EndOfDoc_;
+};
+
+#ifdef SIM
+flag = {
+    name      = phasenoise;
+    value     = C;
+    arg-type  = string;
+    descrip   = "Phase noise level";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+#endif
+
+#include debug-opt.def
+
+flag = {
+    name      = driftfile;
+    value     = f;
+    arg-type  = string;
+    descrip   = "frequency drift file name";
+    doc = <<-  _EndOfDoc_
+       The name and path of the frequency file,
+       /etc/ntp.drift
+       by default.
+       This is the same operation as the
+       driftfile driftfile
+       configuration specification in the 
+       /etc/ntp.conf
+       file.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = panicgate;
+    value     = g;
+    descrip   = "Allow the first adjustment to be Big";
+    doc = <<-  _EndOfDoc_
+       Normally,
+       ntpd
+       exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows the time to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that,
+       ntpd
+       will exit with a message to the system log. This option can be used with the
+       -q
+       and
+       -x
+       options.
+       See the
+       tinker
+       configuration file directive for other options.
+       _EndOfDoc_;
+};
+
+#ifdef SIM
+flag = {
+    name      = simslew;
+    value     = H;
+    arg-type  = string;
+    descrip   = "Simuator slew";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+#endif
+
+flag = {
+    name      = jaildir;
+    value     = i;
+    arg-type  = string;
+    descrip   = "Jail directory";
+    doc = <<-  _EndOfDoc_
+       Chroot the server to the directory
+       jaildir
+       .
+       This option also implies that the server attempts to drop root privileges at startup (otherwise, chroot gives very little additional security), and it is only available if the OS supports to run the server without full root privileges.
+       You may need to also specify a
+       -u
+       option.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = interface;
+    value     = I;
+    arg-type  = string;
+    descrip   = "Listen on interface";
+    max       = NOLIMIT;
+    arg-name  = iface;
+    stack-arg;
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = keyfile;
+    value     = k;
+    arg-type  = string;
+    descrip   = "path to symmetric keys";
+    doc = <<-  _EndOfDoc_
+       Specify the name and path of the symmetric key file.
+       /etc/ntp.keys
+       is the default.
+       This is the same operation as the
+       keys keyfile
+       configuration file directive.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = logfile;
+    value     = l;
+    arg-type  = string;
+    descrip   = "path to the log file";
+    doc = <<-  _EndOfDoc_
+       Specify the name and path of the log file.
+       The default is the system log file.
+       This is the same operation as the
+       logfile logfile
+       configuration file directive.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = novirtualips;
+    value     = L;
+    descrip   = "Do not listen to virtual IPs";
+    doc = <<-  _EndOfDoc_
+       Do not listen to virtual IPs. The default is to listen.
+       _EndOfDoc_;
+};
+
+flag = {
+    ifdef     = SYS_WINNT;
+    name      = modifymmtimer;
+    value     = M;
+    descrip   = "Modify Multimedia Timer (Windows only)";
+    doc = <<-  _EndOfDoc_
+       Set the Windows Multimedia Timer to highest resolution.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = nofork;
+    value     = n;
+    descrip   = "Do not fork";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = nice;
+    value     = N;
+    descrip   = "Run at high priority";
+    doc = <<-  _EndOfDoc_
+       To the extent permitted by the operating system, run
+       ntpd
+       at the highest priority.
+       _EndOfDoc_;
+};
+
+#ifdef SIM
+flag = {
+    name      = servertime;
+    value     = O;
+    arg-type  = string;
+    descrip   = "Server time";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+#endif
+
+flag = {
+    name      = pidfile;
+    value     = p;
+    arg-type  = string;
+    descrip   = "path to the PID file";
+    doc = <<-  _EndOfDoc_
+       Specify the name and path of the file used to record
+       ntpd's
+       process ID.
+       This is the same operation as the
+       pidfile pidfile
+       configuration file directive.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = priority;
+    value     = P;
+    arg-type  = number;
+    descrip   = "Process priority";
+    doc = <<-  _EndOfDoc_
+       To the extent permitted by the operating system, run
+       ntpd
+       at the specified
+       sched_setscheduler(SCHED_FIFO)
+       priority.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = quit;
+    value     = q;
+    descrip   = "Set the time and quit";
+    doc = <<-  _EndOfDoc_
+       ntpd
+       will exit just after the first time the clock is set. This behavior mimics that of the
+       ntpdate
+       program, which is to be retired.
+       The
+       -g
+       and
+       -x
+       options can be used with this option.
+       Note: The kernel time discipline is disabled with this option.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = propagationdelay;
+    value     = r;
+    arg-type  = string;
+    descrip   = "Broadcast/propagation delay";
+    doc = <<-  _EndOfDoc_
+       Specify the default propagation delay from the broadcast/multicast server to this client. This is necessary only if the delay cannot be computed automatically by the protocol.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = updateinterval;
+    value     = U;
+    arg-type  = number;
+    descrip   = "interval in seconds between scans for new or dropped interfaces";
+    doc = <<-  _EndOfDoc_
+       Give the time in seconds between two scans for new or dropped interfaces.
+       For systems with routing socket support the scans will be performed shortly after the interface change
+       has been detected by the system.
+       Use 0 to disable scanning.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = statsdir;
+    value     = s;
+    arg-type  = string;
+    descrip   = "Statistics file location";
+    doc = <<-  _EndOfDoc_
+       Specify the directory path for files created by the statistics facility.
+       This is the same operation as the
+       statsdir statsdir
+       configuration file directive.
+       _EndOfDoc_;
+};
+
+#ifdef SIM
+flag = {
+    name      = endsimtime;
+    value     = S;
+    arg-type  = string;
+    descrip   = "Simulation end time";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+#endif
+
+flag = {
+    name      = trustedkey;
+    value     = t;
+    arg-type  = string;
+    descrip   = "Trusted key number";
+    max       = NOLIMIT;
+    arg-name  = tkey;
+    stack-arg;
+    doc = <<-  _EndOfDoc_
+       Add a key number to the trusted key list.
+       _EndOfDoc_;
+};
+
+#ifdef SIM
+flag = {
+    name      = freqerr;
+    value     = T;
+    arg-type  = string;
+    descrip   = "Simulation frequency error";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+#endif
+
+#ifdef SIM
+flag = {
+    name      = walknoise;
+    value     = W;
+    arg-type  = string;
+    descrip   = "Simulation random walk noise";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+#endif
+
+flag = {
+    name      = user;
+    value     = u;
+    arg-type  = string;
+    descrip   = "Run as userid (or userid:groupid)";
+    doc = <<-  _EndOfDoc_
+       Specify a user, and optionally a group, to switch to.
+       This option is only available if the OS supports to run the server without full root privileges.
+       Currently, this option is supported under NetBSD (configure with
+       --enable-clockctl
+       ) and Linux (configure with
+       --enable-linuxcaps
+       ).
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = var;
+    value     = v;
+    arg-type  = string;
+    descrip   = "make ARG an ntp variable (RW)";
+    max       = NOLIMIT;
+    arg-name  = nvar;
+    stack-arg;
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = dvar;
+    value     = V;
+    arg-type  = string;
+    descrip   = "make ARG an ntp variable (RW|DEF)";
+    max       = NOLIMIT;
+    arg-name  = ndvar;
+    stack-arg;
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = slew;
+    value     = x;
+    descrip   = "Slew up to 600 seconds";
+    doc = <<-  _EndOfDoc_
+       Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold.
+       This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually.
+       Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s.
+       Thus, an adjustment as much as 600 s will take almost 14 days to complete.
+       This option can be used with the
+       -g
+       and
+       -q
+       options.
+       See the
+       tinker
+       configuration file directive for other options.
+       Note: The kernel time discipline is disabled with this option.
+       _EndOfDoc_;
+};
+
+#ifdef SIM
+flag = {
+    name      = ndelay;
+    value     = Y;
+    arg-type  = string;
+    descrip   = "Simulation network delay";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+#endif
+
+#ifdef SIM
+flag = {
+    name      = pdelay;
+    value     = Z;
+    arg-type  = string;
+    descrip   = "Simulation processing delay";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+#endif
diff --git a/ntpd/ntpdsim-opts.c b/ntpd/ntpdsim-opts.c
new file mode 100644 (file)
index 0000000..d9ef1b2
--- /dev/null
@@ -0,0 +1,1262 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (ntpdsim-opts.c)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:13:13 AM EST
+ *  From the definitions    ntpdsim-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This source file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  ntpdsim author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * ntpdsim copyright 1970-2009 David L. Mills and/or others - all rights reserved
+ *
+ * see html/copyright.html
+ */
+
+
+#include <limits.h>
+
+#define OPTION_CODE_COMPILE 1
+#include "ntpdsim-opts.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+tSCC zCopyright[] =
+       "ntpdsim copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved";
+tSCC zCopyrightNotice[] =
+       
+/* extracted from ../include/copyright.def near line 8 */
+"see html/copyright.html";
+extern tUsageProc optionUsage;
+
+/*
+ *  global included definitions
+ */
+#ifdef __windows
+  extern int atoi(const char*);
+#else
+# include <stdlib.h>
+#endif
+
+#ifndef NULL
+#  define NULL 0
+#endif
+#ifndef EXIT_SUCCESS
+#  define  EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#  define  EXIT_FAILURE 1
+#endif
+/*
+ *  Ipv4 option description:
+ */
+tSCC    zIpv4Text[] =
+        "Force IPv4 DNS name resolution";
+tSCC    zIpv4_NAME[]               = "IPV4";
+tSCC    zIpv4_Name[]               = "ipv4";
+#define IPV4_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Ipv6 option description:
+ */
+tSCC    zIpv6Text[] =
+        "Force IPv6 DNS name resolution";
+tSCC    zIpv6_NAME[]               = "IPV6";
+tSCC    zIpv6_Name[]               = "ipv6";
+#define IPV6_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Authreq option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zAuthreqText[] =
+        "Require crypto authentication";
+tSCC    zAuthreq_NAME[]            = "AUTHREQ";
+tSCC    zAuthreq_Name[]            = "authreq";
+static const int
+    aAuthreqCantList[] = {
+    INDEX_OPT_AUTHNOREQ, NO_EQUIVALENT };
+#define AUTHREQ_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Authnoreq option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zAuthnoreqText[] =
+        "Do not require crypto authentication";
+tSCC    zAuthnoreq_NAME[]          = "AUTHNOREQ";
+tSCC    zAuthnoreq_Name[]          = "authnoreq";
+static const int
+    aAuthnoreqCantList[] = {
+    INDEX_OPT_AUTHREQ, NO_EQUIVALENT };
+#define AUTHNOREQ_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Bcastsync option description:
+ */
+tSCC    zBcastsyncText[] =
+        "Allow us to sync to broadcast servers";
+tSCC    zBcastsync_NAME[]          = "BCASTSYNC";
+tSCC    zBcastsync_Name[]          = "bcastsync";
+#define BCASTSYNC_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Simbroadcastdelay option description:
+ */
+tSCC    zSimbroadcastdelayText[] =
+        "Simulator broadcast delay";
+tSCC    zSimbroadcastdelay_NAME[]  = "SIMBROADCASTDELAY";
+tSCC    zSimbroadcastdelay_Name[]  = "simbroadcastdelay";
+#define SIMBROADCASTDELAY_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Configfile option description:
+ */
+tSCC    zConfigfileText[] =
+        "configuration file name";
+tSCC    zConfigfile_NAME[]         = "CONFIGFILE";
+tSCC    zConfigfile_Name[]         = "configfile";
+#define CONFIGFILE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Phasenoise option description:
+ */
+tSCC    zPhasenoiseText[] =
+        "Phase noise level";
+tSCC    zPhasenoise_NAME[]         = "PHASENOISE";
+tSCC    zPhasenoise_Name[]         = "phasenoise";
+#define PHASENOISE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Debug_Level option description:
+ */
+#ifdef DEBUG
+tSCC    zDebug_LevelText[] =
+        "Increase output debug message level";
+tSCC    zDebug_Level_NAME[]        = "DEBUG_LEVEL";
+tSCC    zDebug_Level_Name[]        = "debug-level";
+#define DEBUG_LEVEL_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Debug_Level */
+#define VALUE_OPT_DEBUG_LEVEL NO_EQUIVALENT
+#define DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zDebug_LevelText       NULL
+#define zDebug_Level_NAME      NULL
+#define zDebug_Level_Name      NULL
+#endif  /* DEBUG */
+
+/*
+ *  Set_Debug_Level option description:
+ */
+#ifdef DEBUG
+tSCC    zSet_Debug_LevelText[] =
+        "Set the output debug message level";
+tSCC    zSet_Debug_Level_NAME[]    = "SET_DEBUG_LEVEL";
+tSCC    zSet_Debug_Level_Name[]    = "set-debug-level";
+#define SET_DEBUG_LEVEL_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+#else   /* disable Set_Debug_Level */
+#define VALUE_OPT_SET_DEBUG_LEVEL NO_EQUIVALENT
+#define SET_DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zSet_Debug_LevelText       NULL
+#define zSet_Debug_Level_NAME      NULL
+#define zSet_Debug_Level_Name      NULL
+#endif  /* DEBUG */
+
+/*
+ *  Driftfile option description:
+ */
+tSCC    zDriftfileText[] =
+        "frequency drift file name";
+tSCC    zDriftfile_NAME[]          = "DRIFTFILE";
+tSCC    zDriftfile_Name[]          = "driftfile";
+#define DRIFTFILE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Panicgate option description:
+ */
+tSCC    zPanicgateText[] =
+        "Allow the first adjustment to be Big";
+tSCC    zPanicgate_NAME[]          = "PANICGATE";
+tSCC    zPanicgate_Name[]          = "panicgate";
+#define PANICGATE_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Simslew option description:
+ */
+tSCC    zSimslewText[] =
+        "Simuator slew";
+tSCC    zSimslew_NAME[]            = "SIMSLEW";
+tSCC    zSimslew_Name[]            = "simslew";
+#define SIMSLEW_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Jaildir option description:
+ */
+tSCC    zJaildirText[] =
+        "Jail directory";
+tSCC    zJaildir_NAME[]            = "JAILDIR";
+tSCC    zJaildir_Name[]            = "jaildir";
+#define JAILDIR_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Interface option description:
+ */
+tSCC    zInterfaceText[] =
+        "Listen on interface";
+tSCC    zInterface_NAME[]          = "INTERFACE";
+tSCC    zInterface_Name[]          = "interface";
+#define INTERFACE_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Keyfile option description:
+ */
+tSCC    zKeyfileText[] =
+        "path to symmetric keys";
+tSCC    zKeyfile_NAME[]            = "KEYFILE";
+tSCC    zKeyfile_Name[]            = "keyfile";
+#define KEYFILE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Logfile option description:
+ */
+tSCC    zLogfileText[] =
+        "path to the log file";
+tSCC    zLogfile_NAME[]            = "LOGFILE";
+tSCC    zLogfile_Name[]            = "logfile";
+#define LOGFILE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Novirtualips option description:
+ */
+tSCC    zNovirtualipsText[] =
+        "Do not listen to virtual IPs";
+tSCC    zNovirtualips_NAME[]       = "NOVIRTUALIPS";
+tSCC    zNovirtualips_Name[]       = "novirtualips";
+#define NOVIRTUALIPS_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Modifymmtimer option description:
+ */
+#ifdef SYS_WINNT
+tSCC    zModifymmtimerText[] =
+        "Modify Multimedia Timer (Windows only)";
+tSCC    zModifymmtimer_NAME[]      = "MODIFYMMTIMER";
+tSCC    zModifymmtimer_Name[]      = "modifymmtimer";
+#define MODIFYMMTIMER_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Modifymmtimer */
+#define VALUE_OPT_MODIFYMMTIMER NO_EQUIVALENT
+#define MODIFYMMTIMER_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zModifymmtimerText       NULL
+#define zModifymmtimer_NAME      NULL
+#define zModifymmtimer_Name      NULL
+#endif  /* SYS_WINNT */
+
+/*
+ *  Nofork option description:
+ */
+tSCC    zNoforkText[] =
+        "Do not fork";
+tSCC    zNofork_NAME[]             = "NOFORK";
+tSCC    zNofork_Name[]             = "nofork";
+#define NOFORK_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Nice option description:
+ */
+tSCC    zNiceText[] =
+        "Run at high priority";
+tSCC    zNice_NAME[]               = "NICE";
+tSCC    zNice_Name[]               = "nice";
+#define NICE_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Servertime option description:
+ */
+tSCC    zServertimeText[] =
+        "Server time";
+tSCC    zServertime_NAME[]         = "SERVERTIME";
+tSCC    zServertime_Name[]         = "servertime";
+#define SERVERTIME_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Pidfile option description:
+ */
+tSCC    zPidfileText[] =
+        "path to the PID file";
+tSCC    zPidfile_NAME[]            = "PIDFILE";
+tSCC    zPidfile_Name[]            = "pidfile";
+#define PIDFILE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Priority option description:
+ */
+tSCC    zPriorityText[] =
+        "Process priority";
+tSCC    zPriority_NAME[]           = "PRIORITY";
+tSCC    zPriority_Name[]           = "priority";
+#define PRIORITY_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+
+/*
+ *  Quit option description:
+ */
+tSCC    zQuitText[] =
+        "Set the time and quit";
+tSCC    zQuit_NAME[]               = "QUIT";
+tSCC    zQuit_Name[]               = "quit";
+#define QUIT_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Propagationdelay option description:
+ */
+tSCC    zPropagationdelayText[] =
+        "Broadcast/propagation delay";
+tSCC    zPropagationdelay_NAME[]   = "PROPAGATIONDELAY";
+tSCC    zPropagationdelay_Name[]   = "propagationdelay";
+#define PROPAGATIONDELAY_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Updateinterval option description:
+ */
+tSCC    zUpdateintervalText[] =
+        "interval in seconds between scans for new or dropped interfaces";
+tSCC    zUpdateinterval_NAME[]     = "UPDATEINTERVAL";
+tSCC    zUpdateinterval_Name[]     = "updateinterval";
+#define UPDATEINTERVAL_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+
+/*
+ *  Statsdir option description:
+ */
+tSCC    zStatsdirText[] =
+        "Statistics file location";
+tSCC    zStatsdir_NAME[]           = "STATSDIR";
+tSCC    zStatsdir_Name[]           = "statsdir";
+#define STATSDIR_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Endsimtime option description:
+ */
+tSCC    zEndsimtimeText[] =
+        "Simulation end time";
+tSCC    zEndsimtime_NAME[]         = "ENDSIMTIME";
+tSCC    zEndsimtime_Name[]         = "endsimtime";
+#define ENDSIMTIME_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Trustedkey option description:
+ */
+tSCC    zTrustedkeyText[] =
+        "Trusted key number";
+tSCC    zTrustedkey_NAME[]         = "TRUSTEDKEY";
+tSCC    zTrustedkey_Name[]         = "trustedkey";
+#define TRUSTEDKEY_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Freqerr option description:
+ */
+tSCC    zFreqerrText[] =
+        "Simulation frequency error";
+tSCC    zFreqerr_NAME[]            = "FREQERR";
+tSCC    zFreqerr_Name[]            = "freqerr";
+#define FREQERR_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Walknoise option description:
+ */
+tSCC    zWalknoiseText[] =
+        "Simulation random walk noise";
+tSCC    zWalknoise_NAME[]          = "WALKNOISE";
+tSCC    zWalknoise_Name[]          = "walknoise";
+#define WALKNOISE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  User option description:
+ */
+tSCC    zUserText[] =
+        "Run as userid (or userid:groupid)";
+tSCC    zUser_NAME[]               = "USER";
+tSCC    zUser_Name[]               = "user";
+#define USER_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Var option description:
+ */
+tSCC    zVarText[] =
+        "make ARG an ntp variable (RW)";
+tSCC    zVar_NAME[]                = "VAR";
+tSCC    zVar_Name[]                = "var";
+#define VAR_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Dvar option description:
+ */
+tSCC    zDvarText[] =
+        "make ARG an ntp variable (RW|DEF)";
+tSCC    zDvar_NAME[]               = "DVAR";
+tSCC    zDvar_Name[]               = "dvar";
+#define DVAR_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Slew option description:
+ */
+tSCC    zSlewText[] =
+        "Slew up to 600 seconds";
+tSCC    zSlew_NAME[]               = "SLEW";
+tSCC    zSlew_Name[]               = "slew";
+#define SLEW_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Ndelay option description:
+ */
+tSCC    zNdelayText[] =
+        "Simulation network delay";
+tSCC    zNdelay_NAME[]             = "NDELAY";
+tSCC    zNdelay_Name[]             = "ndelay";
+#define NDELAY_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Pdelay option description:
+ */
+tSCC    zPdelayText[] =
+        "Simulation processing delay";
+tSCC    zPdelay_NAME[]             = "PDELAY";
+tSCC    zPdelay_Name[]             = "pdelay";
+#define PDELAY_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Help/More_Help/Version option descriptions:
+ */
+tSCC zHelpText[]       = "Display usage information and exit";
+tSCC zHelp_Name[]      = "help";
+
+tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
+tSCC zMore_Help_Name[] = "more-help";
+
+tSCC zVersionText[]    = "Output version information and exit";
+tSCC zVersion_Name[]   = "version";
+
+/*
+ *  Save/Load_Opts option description:
+ */
+tSCC zSave_OptsText[]     = "Save the option state to a config file";
+tSCC zSave_Opts_Name[]    = "save-opts";
+
+tSCC zLoad_OptsText[]     = "Load options from a config file";
+tSCC zLoad_Opts_NAME[]    = "LOAD_OPTS";
+
+tSCC zNotLoad_Opts_Name[] = "no-load-opts";
+tSCC zNotLoad_Opts_Pfx[]  = "no";
+#define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
+/*
+ *  Declare option callback procedures
+ */
+#ifdef DEBUG
+  static tOptProc doOptSet_Debug_Level;
+#else /* not DEBUG */
+# define doOptSet_Debug_Level NULL
+#endif /* def/not DEBUG */
+#if defined(TEST_NTPDSIM_OPTS)
+/*
+ *  Under test, omit argument processing, or call optionStackArg,
+ *  if multiple copies are allowed.
+ */
+extern tOptProc
+    optionNumericVal,    optionPagedUsage,    optionStackArg,
+    optionVersionStderr;
+static tOptProc
+    doUsageOpt;
+
+/*
+ *  #define map the "normal" callout procs to the test ones...
+ */
+#define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
+
+
+#else /* NOT defined TEST_NTPDSIM_OPTS */
+/*
+ *  When not under test, there are different procs to use
+ */
+extern tOptProc
+    optionNumericVal, optionPagedUsage, optionPrintVersion, optionStackArg;
+static tOptProc
+    doUsageOpt;
+
+/*
+ *  #define map the "normal" callout procs
+ */
+#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
+
+#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
+#endif /* defined(TEST_NTPDSIM_OPTS) */
+#ifdef TEST_NTPDSIM_OPTS
+# define DOVERPROC optionVersionStderr
+#else
+# define DOVERPROC optionPrintVersion
+#endif /* TEST_NTPDSIM_OPTS */
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Ntpdsim Option Descriptions.
+ */
+static tOptDesc optDesc[ OPTION_CT ] = {
+  {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
+     /* equiv idx, value */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IPV4_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
+     /* equiv idx, value */ NOLIMIT, NOLIMIT,
+     /* equivalenced to  */ INDEX_OPT_IPV4,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IPV6_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 2, VALUE_OPT_AUTHREQ,
+     /* equiv idx, value */ 2, VALUE_OPT_AUTHREQ,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ AUTHREQ_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aAuthreqCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zAuthreqText, zAuthreq_NAME, zAuthreq_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 3, VALUE_OPT_AUTHNOREQ,
+     /* equiv idx, value */ 3, VALUE_OPT_AUTHNOREQ,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ AUTHNOREQ_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aAuthnoreqCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zAuthnoreqText, zAuthnoreq_NAME, zAuthnoreq_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 4, VALUE_OPT_BCASTSYNC,
+     /* equiv idx, value */ 4, VALUE_OPT_BCASTSYNC,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ BCASTSYNC_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zBcastsyncText, zBcastsync_NAME, zBcastsync_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 5, VALUE_OPT_SIMBROADCASTDELAY,
+     /* equiv idx, value */ 5, VALUE_OPT_SIMBROADCASTDELAY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SIMBROADCASTDELAY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSimbroadcastdelayText, zSimbroadcastdelay_NAME, zSimbroadcastdelay_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 6, VALUE_OPT_CONFIGFILE,
+     /* equiv idx, value */ 6, VALUE_OPT_CONFIGFILE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ CONFIGFILE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zConfigfileText, zConfigfile_NAME, zConfigfile_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 7, VALUE_OPT_PHASENOISE,
+     /* equiv idx, value */ 7, VALUE_OPT_PHASENOISE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PHASENOISE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPhasenoiseText, zPhasenoise_NAME, zPhasenoise_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 8, VALUE_OPT_DEBUG_LEVEL,
+     /* equiv idx, value */ 8, VALUE_OPT_DEBUG_LEVEL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ DEBUG_LEVEL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 9, VALUE_OPT_SET_DEBUG_LEVEL,
+     /* equiv idx, value */ 9, VALUE_OPT_SET_DEBUG_LEVEL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ SET_DEBUG_LEVEL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ SET_DEBUG_LEVEL_OPT_PROC,
+     /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 10, VALUE_OPT_DRIFTFILE,
+     /* equiv idx, value */ 10, VALUE_OPT_DRIFTFILE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ DRIFTFILE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zDriftfileText, zDriftfile_NAME, zDriftfile_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 11, VALUE_OPT_PANICGATE,
+     /* equiv idx, value */ 11, VALUE_OPT_PANICGATE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PANICGATE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPanicgateText, zPanicgate_NAME, zPanicgate_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 12, VALUE_OPT_SIMSLEW,
+     /* equiv idx, value */ 12, VALUE_OPT_SIMSLEW,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SIMSLEW_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSimslewText, zSimslew_NAME, zSimslew_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 13, VALUE_OPT_JAILDIR,
+     /* equiv idx, value */ 13, VALUE_OPT_JAILDIR,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ JAILDIR_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zJaildirText, zJaildir_NAME, zJaildir_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 14, VALUE_OPT_INTERFACE,
+     /* equiv idx, value */ 14, VALUE_OPT_INTERFACE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ INTERFACE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zInterfaceText, zInterface_NAME, zInterface_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 15, VALUE_OPT_KEYFILE,
+     /* equiv idx, value */ 15, VALUE_OPT_KEYFILE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ KEYFILE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zKeyfileText, zKeyfile_NAME, zKeyfile_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 16, VALUE_OPT_LOGFILE,
+     /* equiv idx, value */ 16, VALUE_OPT_LOGFILE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ LOGFILE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zLogfileText, zLogfile_NAME, zLogfile_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 17, VALUE_OPT_NOVIRTUALIPS,
+     /* equiv idx, value */ 17, VALUE_OPT_NOVIRTUALIPS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ NOVIRTUALIPS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zNovirtualipsText, zNovirtualips_NAME, zNovirtualips_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 18, VALUE_OPT_MODIFYMMTIMER,
+     /* equiv idx, value */ 18, VALUE_OPT_MODIFYMMTIMER,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ MODIFYMMTIMER_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zModifymmtimerText, zModifymmtimer_NAME, zModifymmtimer_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 19, VALUE_OPT_NOFORK,
+     /* equiv idx, value */ 19, VALUE_OPT_NOFORK,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ NOFORK_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zNoforkText, zNofork_NAME, zNofork_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 20, VALUE_OPT_NICE,
+     /* equiv idx, value */ 20, VALUE_OPT_NICE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ NICE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zNiceText, zNice_NAME, zNice_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 21, VALUE_OPT_SERVERTIME,
+     /* equiv idx, value */ 21, VALUE_OPT_SERVERTIME,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SERVERTIME_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zServertimeText, zServertime_NAME, zServertime_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 22, VALUE_OPT_PIDFILE,
+     /* equiv idx, value */ 22, VALUE_OPT_PIDFILE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PIDFILE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPidfileText, zPidfile_NAME, zPidfile_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 23, VALUE_OPT_PRIORITY,
+     /* equiv idx, value */ 23, VALUE_OPT_PRIORITY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PRIORITY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionNumericVal,
+     /* desc, NAME, name */ zPriorityText, zPriority_NAME, zPriority_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 24, VALUE_OPT_QUIT,
+     /* equiv idx, value */ 24, VALUE_OPT_QUIT,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ QUIT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zQuitText, zQuit_NAME, zQuit_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 25, VALUE_OPT_PROPAGATIONDELAY,
+     /* equiv idx, value */ 25, VALUE_OPT_PROPAGATIONDELAY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PROPAGATIONDELAY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPropagationdelayText, zPropagationdelay_NAME, zPropagationdelay_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 26, VALUE_OPT_UPDATEINTERVAL,
+     /* equiv idx, value */ 26, VALUE_OPT_UPDATEINTERVAL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ UPDATEINTERVAL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionNumericVal,
+     /* desc, NAME, name */ zUpdateintervalText, zUpdateinterval_NAME, zUpdateinterval_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 27, VALUE_OPT_STATSDIR,
+     /* equiv idx, value */ 27, VALUE_OPT_STATSDIR,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ STATSDIR_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zStatsdirText, zStatsdir_NAME, zStatsdir_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 28, VALUE_OPT_ENDSIMTIME,
+     /* equiv idx, value */ 28, VALUE_OPT_ENDSIMTIME,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ ENDSIMTIME_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zEndsimtimeText, zEndsimtime_NAME, zEndsimtime_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 29, VALUE_OPT_TRUSTEDKEY,
+     /* equiv idx, value */ 29, VALUE_OPT_TRUSTEDKEY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ TRUSTEDKEY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zTrustedkeyText, zTrustedkey_NAME, zTrustedkey_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 30, VALUE_OPT_FREQERR,
+     /* equiv idx, value */ 30, VALUE_OPT_FREQERR,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ FREQERR_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zFreqerrText, zFreqerr_NAME, zFreqerr_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 31, VALUE_OPT_WALKNOISE,
+     /* equiv idx, value */ 31, VALUE_OPT_WALKNOISE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ WALKNOISE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zWalknoiseText, zWalknoise_NAME, zWalknoise_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 32, VALUE_OPT_USER,
+     /* equiv idx, value */ 32, VALUE_OPT_USER,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ USER_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zUserText, zUser_NAME, zUser_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 33, VALUE_OPT_VAR,
+     /* equiv idx, value */ 33, VALUE_OPT_VAR,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ VAR_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zVarText, zVar_NAME, zVar_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 34, VALUE_OPT_DVAR,
+     /* equiv idx, value */ 34, VALUE_OPT_DVAR,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ DVAR_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zDvarText, zDvar_NAME, zDvar_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 35, VALUE_OPT_SLEW,
+     /* equiv idx, value */ 35, VALUE_OPT_SLEW,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SLEW_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSlewText, zSlew_NAME, zSlew_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 36, VALUE_OPT_NDELAY,
+     /* equiv idx, value */ 36, VALUE_OPT_NDELAY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ NDELAY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zNdelayText, zNdelay_NAME, zNdelay_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 37, VALUE_OPT_PDELAY,
+     /* equiv idx, value */ 37, VALUE_OPT_PDELAY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PDELAY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPdelayText, zPdelay_NAME, zPdelay_Name,
+     /* disablement strs */ NULL, NULL },
+
+#ifdef NO_OPTIONAL_OPT_ARGS
+#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
+#else
+#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
+                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
+#endif
+
+  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ DOVERPROC,
+     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
+     /* disablement strs */ NULL, NULL },
+
+#undef VERSION_OPT_FLAGS
+
+
+  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doUsageOpt,
+     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ optionPagedUsage,
+     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
+                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
+                         | OPTST_DISABLE_IMM, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionLoadOpt,
+     /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
+     /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
+};
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Ntpdsim Option Environment
+ */
+tSCC   zPROGNAME[]   = "NTPDSIM";
+tSCC   zUsageTitle[] =
+"ntpdsim - NTP daemon simulation program - Ver. 4.2.4p8\n\
+USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
+tSCC   zRcName[]     = ".ntprc";
+tSCC*  apzHomeList[] = {
+       "$HOME",
+       ".",
+       NULL };
+
+tSCC   zBugsAddr[]    = "http://bugs.ntp.org, bugs@ntp.org";
+#define zExplain NULL
+tSCC    zDetail[]     = "\n\n";
+tSCC    zFullVersion[] = NTPDSIM_FULL_VERSION;
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
+
+#if defined(ENABLE_NLS)
+# define OPTPROC_BASE OPTPROC_TRANSLATE
+  static tOptionXlateProc translate_option_strings;
+#else
+# define OPTPROC_BASE OPTPROC_NONE
+# define translate_option_strings NULL
+#endif /* ENABLE_NLS */
+
+tOptions ntpdsimOptions = {
+    OPTIONS_STRUCT_VERSION,
+    0, NULL,                    /* original argc + argv    */
+    ( OPTPROC_BASE
+    + OPTPROC_ERRSTOP
+    + OPTPROC_SHORTOPT
+    + OPTPROC_LONGOPT
+    + OPTPROC_NO_REQ_OPT
+    + OPTPROC_ENVIRON
+    + OPTPROC_NO_ARGS
+    + OPTPROC_HAS_IMMED ),
+    0, NULL,                    /* current option index, current option */
+    NULL,         NULL,         zPROGNAME,
+    zRcName,      zCopyright,   zCopyrightNotice,
+    zFullVersion, apzHomeList,  zUsageTitle,
+    zExplain,     zDetail,      optDesc,
+    zBugsAddr,                  /* address to send bugs to */
+    NULL, NULL,                 /* extensions/saved state  */
+    optionUsage,       /* usage procedure */
+    translate_option_strings,   /* translation procedure */
+    /*
+     *  Indexes to special options
+     */
+    { INDEX_OPT_MORE_HELP,
+      INDEX_OPT_SAVE_OPTS,
+      NO_EQUIVALENT /* index of '-#' option */,
+      NO_EQUIVALENT /* index of default opt */
+    },
+    43 /* full option count */, 38 /* user option count */
+};
+
+/*
+ *  Create the static procedure(s) declared above.
+ */
+static void
+doUsageOpt(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    USAGE( EXIT_SUCCESS );
+}
+
+#if ! defined(TEST_NTPDSIM_OPTS)
+
+/* * * * * * *
+ *
+ *   For the set-debug-level option, when DEBUG is #define-d.
+ */
+#ifdef DEBUG
+static void
+doOptSet_Debug_Level(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    /* extracted from ../include/debug-opt.def, line 29 */
+DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
+}
+#endif /* defined DEBUG */
+
+#endif /* defined(TEST_NTPDSIM_OPTS) */
+
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
+
+#if defined(TEST_NTPDSIM_OPTS) /* TEST MAIN PROCEDURE: */
+
+int
+main( int argc, char** argv )
+{
+    int res = EXIT_SUCCESS;
+    (void)optionProcess( &ntpdsimOptions, argc, argv );
+    {
+        void optionPutShell( tOptions* );
+        optionPutShell( &ntpdsimOptions );
+    }
+    return res;
+}
+#endif  /* defined TEST_NTPDSIM_OPTS */
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
+
+#if ENABLE_NLS
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <autoopts/usage-txt.h>
+
+static char* AO_gettext( char const* pz );
+static void  coerce_it(void** s);
+
+static char*
+AO_gettext( char const* pz )
+{
+    char* pzRes;
+    if (pz == NULL)
+        return NULL;
+    pzRes = _(pz);
+    if (pzRes == pz)
+        return pzRes;
+    pzRes = strdup( pzRes );
+    if (pzRes == NULL) {
+        fputs( _("No memory for duping translated strings\n"), stderr );
+        exit( EXIT_FAILURE );
+    }
+    return pzRes;
+}
+
+static void coerce_it(void** s) { *s = AO_gettext(*s); }
+#define COERSION(_f) \
+  coerce_it((void*)&(ntpdsimOptions._f))
+
+/*
+ *  This invokes the translation code (e.g. gettext(3)).
+ */
+static void
+translate_option_strings( void )
+{
+    /*
+     *  Guard against re-translation.  It won't work.  The strings will have
+     *  been changed by the first pass through this code.  One shot only.
+     */
+    if (option_usage_text.field_ct == 0)
+        return;
+    /*
+     *  Do the translations.  The first pointer follows the field count field.
+     *  The field count field is the size of a pointer.
+     */
+    {
+        char** ppz = (char**)(void*)&(option_usage_text);
+        int    ix  = option_usage_text.field_ct;
+
+        do {
+            ppz++;
+            *ppz = AO_gettext(*ppz);
+        } while (--ix > 0);
+    }
+    option_usage_text.field_ct = 0;
+
+    {
+        tOptDesc* pOD = ntpdsimOptions.pOptDesc;
+        int       ix  = ntpdsimOptions.optCt;
+
+        for (;;) {
+            pOD->pzText           = AO_gettext(pOD->pzText);
+            pOD->pz_NAME          = AO_gettext(pOD->pz_NAME);
+            pOD->pz_Name          = AO_gettext(pOD->pz_Name);
+            pOD->pz_DisableName   = AO_gettext(pOD->pz_DisableName);
+            pOD->pz_DisablePfx    = AO_gettext(pOD->pz_DisablePfx);
+            if (--ix <= 0)
+                break;
+            pOD++;
+        }
+    }
+    COERSION(pzCopyright);
+    COERSION(pzCopyNotice);
+    COERSION(pzFullVersion);
+    COERSION(pzUsageTitle);
+    COERSION(pzExplain);
+    COERSION(pzDetail);
+}
+
+#endif /* ENABLE_NLS */
+
+#ifdef  __cplusplus
+}
+#endif
+/* ntpdsim-opts.c ends here */
diff --git a/ntpd/ntpdsim-opts.def b/ntpd/ntpdsim-opts.def
new file mode 100644 (file)
index 0000000..093c325
--- /dev/null
@@ -0,0 +1,15 @@
+/* -*- Mode: Text -*- */
+
+autogen definitions options;
+
+#include copyright.def
+#include homerc.def
+
+prog-name      = "ntpdsim";
+prog-title     = "NTP daemon simulation program";
+
+#define SIM
+#include ntpdbase-opts.def
+
+detail = <<-  _END_DETAIL
+       _END_DETAIL;
diff --git a/ntpd/ntpdsim-opts.h b/ntpd/ntpdsim-opts.h
new file mode 100644 (file)
index 0000000..3458bbf
--- /dev/null
@@ -0,0 +1,422 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (ntpdsim-opts.h)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:13:12 AM EST
+ *  From the definitions    ntpdsim-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This header file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  ntpdsim author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * ntpdsim copyright 1970-2009 David L. Mills and/or others - all rights reserved
+ *
+ * see html/copyright.html
+ */
+/*
+ *  This file contains the programmatic interface to the Automated
+ *  Options generated for the ntpdsim program.
+ *  These macros are documented in the AutoGen info file in the
+ *  "AutoOpts" chapter.  Please refer to that doc for usage help.
+ */
+#ifndef AUTOOPTS_NTPDSIM_OPTS_H_GUARD
+#define AUTOOPTS_NTPDSIM_OPTS_H_GUARD
+#include "config.h"
+#include <autoopts/options.h>
+
+/*
+ *  Ensure that the library used for compiling this generated header is at
+ *  least as new as the version current when the header template was released
+ *  (not counting patch version increments).  Also ensure that the oldest
+ *  tolerable version is at least as old as what was current when the header
+ *  template was released.
+ */
+#define AO_TEMPLATE_VERSION 118784
+#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
+ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
+# error option template version mismatches autoopts/options.h header
+  Choke Me.
+#endif
+
+/*
+ *  Enumeration of each option:
+ */
+typedef enum {
+        INDEX_OPT_IPV4             =  0,
+        INDEX_OPT_IPV6             =  1,
+        INDEX_OPT_AUTHREQ          =  2,
+        INDEX_OPT_AUTHNOREQ        =  3,
+        INDEX_OPT_BCASTSYNC        =  4,
+        INDEX_OPT_SIMBROADCASTDELAY =  5,
+        INDEX_OPT_CONFIGFILE       =  6,
+        INDEX_OPT_PHASENOISE       =  7,
+        INDEX_OPT_DEBUG_LEVEL      =  8,
+        INDEX_OPT_SET_DEBUG_LEVEL  =  9,
+        INDEX_OPT_DRIFTFILE        = 10,
+        INDEX_OPT_PANICGATE        = 11,
+        INDEX_OPT_SIMSLEW          = 12,
+        INDEX_OPT_JAILDIR          = 13,
+        INDEX_OPT_INTERFACE        = 14,
+        INDEX_OPT_KEYFILE          = 15,
+        INDEX_OPT_LOGFILE          = 16,
+        INDEX_OPT_NOVIRTUALIPS     = 17,
+        INDEX_OPT_MODIFYMMTIMER    = 18,
+        INDEX_OPT_NOFORK           = 19,
+        INDEX_OPT_NICE             = 20,
+        INDEX_OPT_SERVERTIME       = 21,
+        INDEX_OPT_PIDFILE          = 22,
+        INDEX_OPT_PRIORITY         = 23,
+        INDEX_OPT_QUIT             = 24,
+        INDEX_OPT_PROPAGATIONDELAY = 25,
+        INDEX_OPT_UPDATEINTERVAL   = 26,
+        INDEX_OPT_STATSDIR         = 27,
+        INDEX_OPT_ENDSIMTIME       = 28,
+        INDEX_OPT_TRUSTEDKEY       = 29,
+        INDEX_OPT_FREQERR          = 30,
+        INDEX_OPT_WALKNOISE        = 31,
+        INDEX_OPT_USER             = 32,
+        INDEX_OPT_VAR              = 33,
+        INDEX_OPT_DVAR             = 34,
+        INDEX_OPT_SLEW             = 35,
+        INDEX_OPT_NDELAY           = 36,
+        INDEX_OPT_PDELAY           = 37,
+        INDEX_OPT_VERSION          = 38,
+        INDEX_OPT_HELP             = 39,
+        INDEX_OPT_MORE_HELP        = 40,
+        INDEX_OPT_SAVE_OPTS        = 41,
+        INDEX_OPT_LOAD_OPTS        = 42
+} teOptIndex;
+
+#define OPTION_CT    43
+#define NTPDSIM_VERSION       "4.2.4p8"
+#define NTPDSIM_FULL_VERSION  "ntpdsim - NTP daemon simulation program - Ver. 4.2.4p8"
+
+/*
+ *  Interface defines for all options.  Replace "n" with the UPPER_CASED
+ *  option name (as in the teOptIndex enumeration above).
+ *  e.g. HAVE_OPT( IPV4 )
+ */
+#define         DESC(n) (ntpdsimOptions.pOptDesc[INDEX_OPT_## n])
+#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
+#define      OPT_ARG(n) (DESC(n).optArg.argString)
+#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
+#define    COUNT_OPT(n) (DESC(n).optOccCt)
+#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
+#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
+#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
+#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
+#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
+#define    CLEAR_OPT(n) STMTS( \
+                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
+                if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
+                    DESC(n).fOptState |= OPTST_DISABLED; \
+                DESC(n).optCookie = NULL )
+
+/*
+ *  Make sure there are no #define name conflicts with the option names
+ */
+#ifndef     NO_OPTION_NAME_WARNINGS
+# ifdef    IPV4
+#  warning undefining IPV4 due to option name conflict
+#  undef   IPV4
+# endif
+# ifdef    IPV6
+#  warning undefining IPV6 due to option name conflict
+#  undef   IPV6
+# endif
+# ifdef    AUTHREQ
+#  warning undefining AUTHREQ due to option name conflict
+#  undef   AUTHREQ
+# endif
+# ifdef    AUTHNOREQ
+#  warning undefining AUTHNOREQ due to option name conflict
+#  undef   AUTHNOREQ
+# endif
+# ifdef    BCASTSYNC
+#  warning undefining BCASTSYNC due to option name conflict
+#  undef   BCASTSYNC
+# endif
+# ifdef    SIMBROADCASTDELAY
+#  warning undefining SIMBROADCASTDELAY due to option name conflict
+#  undef   SIMBROADCASTDELAY
+# endif
+# ifdef    CONFIGFILE
+#  warning undefining CONFIGFILE due to option name conflict
+#  undef   CONFIGFILE
+# endif
+# ifdef    PHASENOISE
+#  warning undefining PHASENOISE due to option name conflict
+#  undef   PHASENOISE
+# endif
+# ifdef    DEBUG_LEVEL
+#  warning undefining DEBUG_LEVEL due to option name conflict
+#  undef   DEBUG_LEVEL
+# endif
+# ifdef    SET_DEBUG_LEVEL
+#  warning undefining SET_DEBUG_LEVEL due to option name conflict
+#  undef   SET_DEBUG_LEVEL
+# endif
+# ifdef    DRIFTFILE
+#  warning undefining DRIFTFILE due to option name conflict
+#  undef   DRIFTFILE
+# endif
+# ifdef    PANICGATE
+#  warning undefining PANICGATE due to option name conflict
+#  undef   PANICGATE
+# endif
+# ifdef    SIMSLEW
+#  warning undefining SIMSLEW due to option name conflict
+#  undef   SIMSLEW
+# endif
+# ifdef    JAILDIR
+#  warning undefining JAILDIR due to option name conflict
+#  undef   JAILDIR
+# endif
+# ifdef    INTERFACE
+#  warning undefining INTERFACE due to option name conflict
+#  undef   INTERFACE
+# endif
+# ifdef    KEYFILE
+#  warning undefining KEYFILE due to option name conflict
+#  undef   KEYFILE
+# endif
+# ifdef    LOGFILE
+#  warning undefining LOGFILE due to option name conflict
+#  undef   LOGFILE
+# endif
+# ifdef    NOVIRTUALIPS
+#  warning undefining NOVIRTUALIPS due to option name conflict
+#  undef   NOVIRTUALIPS
+# endif
+# ifdef    MODIFYMMTIMER
+#  warning undefining MODIFYMMTIMER due to option name conflict
+#  undef   MODIFYMMTIMER
+# endif
+# ifdef    NOFORK
+#  warning undefining NOFORK due to option name conflict
+#  undef   NOFORK
+# endif
+# ifdef    NICE
+#  warning undefining NICE due to option name conflict
+#  undef   NICE
+# endif
+# ifdef    SERVERTIME
+#  warning undefining SERVERTIME due to option name conflict
+#  undef   SERVERTIME
+# endif
+# ifdef    PIDFILE
+#  warning undefining PIDFILE due to option name conflict
+#  undef   PIDFILE
+# endif
+# ifdef    PRIORITY
+#  warning undefining PRIORITY due to option name conflict
+#  undef   PRIORITY
+# endif
+# ifdef    QUIT
+#  warning undefining QUIT due to option name conflict
+#  undef   QUIT
+# endif
+# ifdef    PROPAGATIONDELAY
+#  warning undefining PROPAGATIONDELAY due to option name conflict
+#  undef   PROPAGATIONDELAY
+# endif
+# ifdef    UPDATEINTERVAL
+#  warning undefining UPDATEINTERVAL due to option name conflict
+#  undef   UPDATEINTERVAL
+# endif
+# ifdef    STATSDIR
+#  warning undefining STATSDIR due to option name conflict
+#  undef   STATSDIR
+# endif
+# ifdef    ENDSIMTIME
+#  warning undefining ENDSIMTIME due to option name conflict
+#  undef   ENDSIMTIME
+# endif
+# ifdef    TRUSTEDKEY
+#  warning undefining TRUSTEDKEY due to option name conflict
+#  undef   TRUSTEDKEY
+# endif
+# ifdef    FREQERR
+#  warning undefining FREQERR due to option name conflict
+#  undef   FREQERR
+# endif
+# ifdef    WALKNOISE
+#  warning undefining WALKNOISE due to option name conflict
+#  undef   WALKNOISE
+# endif
+# ifdef    USER
+#  warning undefining USER due to option name conflict
+#  undef   USER
+# endif
+# ifdef    VAR
+#  warning undefining VAR due to option name conflict
+#  undef   VAR
+# endif
+# ifdef    DVAR
+#  warning undefining DVAR due to option name conflict
+#  undef   DVAR
+# endif
+# ifdef    SLEW
+#  warning undefining SLEW due to option name conflict
+#  undef   SLEW
+# endif
+# ifdef    NDELAY
+#  warning undefining NDELAY due to option name conflict
+#  undef   NDELAY
+# endif
+# ifdef    PDELAY
+#  warning undefining PDELAY due to option name conflict
+#  undef   PDELAY
+# endif
+#else  /* NO_OPTION_NAME_WARNINGS */
+# undef IPV4
+# undef IPV6
+# undef AUTHREQ
+# undef AUTHNOREQ
+# undef BCASTSYNC
+# undef SIMBROADCASTDELAY
+# undef CONFIGFILE
+# undef PHASENOISE
+# undef DEBUG_LEVEL
+# undef SET_DEBUG_LEVEL
+# undef DRIFTFILE
+# undef PANICGATE
+# undef SIMSLEW
+# undef JAILDIR
+# undef INTERFACE
+# undef KEYFILE
+# undef LOGFILE
+# undef NOVIRTUALIPS
+# undef MODIFYMMTIMER
+# undef NOFORK
+# undef NICE
+# undef SERVERTIME
+# undef PIDFILE
+# undef PRIORITY
+# undef QUIT
+# undef PROPAGATIONDELAY
+# undef UPDATEINTERVAL
+# undef STATSDIR
+# undef ENDSIMTIME
+# undef TRUSTEDKEY
+# undef FREQERR
+# undef WALKNOISE
+# undef USER
+# undef VAR
+# undef DVAR
+# undef SLEW
+# undef NDELAY
+# undef PDELAY
+#endif  /*  NO_OPTION_NAME_WARNINGS */
+
+/*
+ *  Interface defines for specific options.
+ */
+#define VALUE_OPT_IPV4           '4'
+#define WHICH_OPT_IPV4           (DESC(IPV4).optActualValue)
+#define WHICH_IDX_IPV4           (DESC(IPV4).optActualIndex)
+#define VALUE_OPT_IPV6           '6'
+#define VALUE_OPT_AUTHREQ        'a'
+#define VALUE_OPT_AUTHNOREQ      'A'
+#define VALUE_OPT_BCASTSYNC      'b'
+#define VALUE_OPT_SIMBROADCASTDELAY 'B'
+#define VALUE_OPT_CONFIGFILE     'c'
+#define VALUE_OPT_PHASENOISE     'C'
+#ifdef DEBUG
+#define VALUE_OPT_DEBUG_LEVEL    'd'
+#endif /* DEBUG */
+#ifdef DEBUG
+#define VALUE_OPT_SET_DEBUG_LEVEL 'D'
+#endif /* DEBUG */
+#define VALUE_OPT_DRIFTFILE      'f'
+#define VALUE_OPT_PANICGATE      'g'
+#define VALUE_OPT_SIMSLEW        'H'
+#define VALUE_OPT_JAILDIR        'i'
+#define VALUE_OPT_INTERFACE      'I'
+#define VALUE_OPT_KEYFILE        'k'
+#define VALUE_OPT_LOGFILE        'l'
+#define VALUE_OPT_NOVIRTUALIPS   'L'
+#ifdef SYS_WINNT
+#define VALUE_OPT_MODIFYMMTIMER  'M'
+#endif /* SYS_WINNT */
+#define VALUE_OPT_NOFORK         'n'
+#define VALUE_OPT_NICE           'N'
+#define VALUE_OPT_SERVERTIME     'O'
+#define VALUE_OPT_PIDFILE        'p'
+#define VALUE_OPT_PRIORITY       'P'
+#define OPT_VALUE_PRIORITY       (DESC(PRIORITY).optArg.argInt)
+#define VALUE_OPT_QUIT           'q'
+#define VALUE_OPT_PROPAGATIONDELAY 'r'
+#define VALUE_OPT_UPDATEINTERVAL 'U'
+#define OPT_VALUE_UPDATEINTERVAL (DESC(UPDATEINTERVAL).optArg.argInt)
+#define VALUE_OPT_STATSDIR       's'
+#define VALUE_OPT_ENDSIMTIME     'S'
+#define VALUE_OPT_TRUSTEDKEY     't'
+#define VALUE_OPT_FREQERR        'T'
+#define VALUE_OPT_WALKNOISE      'W'
+#define VALUE_OPT_USER           'u'
+#define VALUE_OPT_VAR            'v'
+#define VALUE_OPT_DVAR           'V'
+#define VALUE_OPT_SLEW           'x'
+#define VALUE_OPT_NDELAY         'Y'
+#define VALUE_OPT_PDELAY         'Z'
+
+#define VALUE_OPT_VERSION       'v'
+#define VALUE_OPT_HELP          '?'
+#define VALUE_OPT_MORE_HELP     '!'
+#define VALUE_OPT_SAVE_OPTS     '>'
+#define VALUE_OPT_LOAD_OPTS     '<'
+#define SET_OPT_SAVE_OPTS(a)   STMTS( \
+        DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
+        DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
+        DESC(SAVE_OPTS).optArg.argString = (char const*)(a) )
+/*
+ *  Interface defines not associated with particular options
+ */
+#define ERRSKIP_OPTERR  STMTS( ntpdsimOptions.fOptSet &= ~OPTPROC_ERRSTOP )
+#define ERRSTOP_OPTERR  STMTS( ntpdsimOptions.fOptSet |= OPTPROC_ERRSTOP )
+#define RESTART_OPT(n)  STMTS( \
+                ntpdsimOptions.curOptIdx = (n); \
+                ntpdsimOptions.pzCurOpt  = NULL )
+#define START_OPT       RESTART_OPT(1)
+#define USAGE(c)        (*ntpdsimOptions.pUsageProc)( &ntpdsimOptions, c )
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/opthead.tpl near line 360 */
+
+/* * * * * *
+ *
+ *  Declare the ntpdsim option descriptor.
+ */
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+extern tOptions   ntpdsimOptions;
+
+#ifndef _
+#  if ENABLE_NLS
+#    include <stdio.h>
+     static inline char* aoGetsText( char const* pz ) {
+         if (pz == NULL) return NULL;
+         return (char*)gettext( pz );
+     }
+#    define _(s)  aoGetsText(s)
+#  else  /* ENABLE_NLS */
+#    define _(s)  s
+#  endif /* ENABLE_NLS */
+#endif
+
+#ifdef  __cplusplus
+}
+#endif
+#endif /* AUTOOPTS_NTPDSIM_OPTS_H_GUARD */
+/* ntpdsim-opts.h ends here */
diff --git a/ntpd/ntpdsim-opts.menu b/ntpd/ntpdsim-opts.menu
new file mode 100644 (file)
index 0000000..c787458
--- /dev/null
@@ -0,0 +1 @@
+* ntpdsim Invocation::             Invoking ntpdsim
diff --git a/ntpd/ntpdsim-opts.texi b/ntpd/ntpdsim-opts.texi
new file mode 100644 (file)
index 0000000..ed52210
--- /dev/null
@@ -0,0 +1,568 @@
+@node ntpdsim Invocation
+@section Invoking ntpdsim
+@pindex ntpdsim
+@cindex NTP daemon simulation program
+@ignore
+# 
+# EDIT THIS FILE WITH CAUTION  (ntpdsim-opts.texi)
+# 
+# It has been AutoGen-ed  Tuesday December  8, 2009 at 08:13:15 AM EST
+# From the definitions    ntpdsim-opts.def
+# and the template file   aginfo.tpl
+@end ignore
+This program has no explanation.
+
+
+
+This section was generated by @strong{AutoGen},
+the aginfo template and the option descriptions for the @command{ntpdsim} program.  It documents the ntpdsim usage text and option meanings.
+
+This software is released under a specialized copyright license.
+
+@menu
+* ntpdsim usage::                  ntpdsim usage help (-?)
+* ntpdsim authnoreq::              authnoreq option (-A)
+* ntpdsim authreq::                authreq option (-a)
+* ntpdsim bcastsync::              bcastsync option (-b)
+* ntpdsim configfile::             configfile option (-c)
+* ntpdsim debug-level::            debug-level option (-d)
+* ntpdsim driftfile::              driftfile option (-f)
+* ntpdsim dvar::                   dvar option (-V)
+* ntpdsim endsimtime::             endsimtime option (-S)
+* ntpdsim freqerr::                freqerr option (-T)
+* ntpdsim interface::              interface option (-I)
+* ntpdsim ipv4::                   ipv4 option (-4)
+* ntpdsim ipv6::                   ipv6 option (-6)
+* ntpdsim jaildir::                jaildir option (-i)
+* ntpdsim keyfile::                keyfile option (-k)
+* ntpdsim logfile::                logfile option (-l)
+* ntpdsim modifymmtimer::          modifymmtimer option (-M)
+* ntpdsim ndelay::                 ndelay option (-Y)
+* ntpdsim nice::                   nice option (-N)
+* ntpdsim nofork::                 nofork option (-n)
+* ntpdsim novirtualips::           novirtualips option (-L)
+* ntpdsim panicgate::              panicgate option (-g)
+* ntpdsim pdelay::                 pdelay option (-Z)
+* ntpdsim phasenoise::             phasenoise option (-C)
+* ntpdsim pidfile::                pidfile option (-p)
+* ntpdsim priority::               priority option (-P)
+* ntpdsim propagationdelay::       propagationdelay option (-r)
+* ntpdsim quit::                   quit option (-q)
+* ntpdsim servertime::             servertime option (-O)
+* ntpdsim set-debug-level::        set-debug-level option (-D)
+* ntpdsim simbroadcastdelay::      simbroadcastdelay option (-B)
+* ntpdsim simslew::                simslew option (-H)
+* ntpdsim slew::                   slew option (-x)
+* ntpdsim statsdir::               statsdir option (-s)
+* ntpdsim trustedkey::             trustedkey option (-t)
+* ntpdsim updateinterval::         updateinterval option (-U)
+* ntpdsim user::                   user option (-u)
+* ntpdsim var::                    var option (-v)
+* ntpdsim walknoise::              walknoise option (-W)
+@end menu
+
+@node ntpdsim usage
+@subsection ntpdsim usage help (-?)
+@cindex ntpdsim usage
+
+This is the automatically generated usage text for ntpdsim:
+
+@exampleindent 0
+@example
+ntpd - NTP daemon program - Ver. 4.2.5p247-RC
+USAGE:  ntpdsim [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
+  Flg Arg Option-Name    Description
+   -4 no  ipv4           Force IPv4 DNS name resolution
+                                - prohibits these options:
+                                ipv6
+   -6 no  ipv6           Force IPv6 DNS name resolution
+                                - prohibits these options:
+                                ipv4
+   -a no  authreq        Require crypto authentication
+                                - prohibits these options:
+                                authnoreq
+   -A no  authnoreq      Do not require crypto authentication
+                                - prohibits these options:
+                                authreq
+   -b no  bcastsync      Allow us to sync to broadcast servers
+   -c Str configfile     configuration file name
+   -d no  debug-level    Increase output debug message level
+                                - may appear multiple times
+   -D Str set-debug-level Set the output debug message level
+                                - may appear multiple times
+   -f Str driftfile      frequency drift file name
+   -g no  panicgate      Allow the first adjustment to be Big
+                                - may appear multiple times
+   -i --- jaildir        built without --enable-clockctl or --enable-linuxcaps
+   -I Str interface      Listen on an interface name or address
+                                - may appear multiple times
+   -k Str keyfile        path to symmetric keys
+   -l Str logfile        path to the log file
+   -L no  novirtualips   Do not listen to virtual interfaces
+   -n no  nofork         Do not fork
+   -N no  nice           Run at high priority
+   -p Str pidfile        path to the PID file
+   -P Num priority       Process priority
+   -q no  quit           Set the time and quit
+   -r Str propagationdelay Broadcast/propagation delay
+      Str saveconfigquit Save parsed configuration and quit
+   -s Str statsdir       Statistics file location
+   -t Str trustedkey     Trusted key number
+                                - may appear multiple times
+   -u --- user           built without --enable-clockctl or --enable-linuxcaps
+   -U Num updateinterval interval in seconds between scans for new or dropped interfaces
+      Str var            make ARG an ntp variable (RW)
+                                - may appear multiple times
+      Str dvar           make ARG an ntp variable (RW|DEF)
+                                - may appear multiple times
+   -x no  slew           Slew up to 600 seconds
+      opt version        Output version information and exit
+   -? no  help           Display extended usage information and exit
+   -! no  more-help      Extended usage information passed thru pager
+
+Options are specified by doubled hyphens and their name
+or by a single hyphen and the flag character.
+
+The following option preset mechanisms are supported:
+ - examining environment variables named NTPD_*
+
+
+
+please send bug reports to:  http://bugs.ntp.org, bugs@@ntp.org
+@end example
+@exampleindent 4
+
+@node ntpdsim ipv4
+@subsection ipv4 option (-4)
+@cindex ntpdsim-ipv4
+
+This is the ``force ipv4 dns name resolution'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is a member of the ipv4 class of options.
+@end itemize
+
+Force DNS resolution of following host names on the command line
+to the IPv4 namespace.
+
+@node ntpdsim ipv6
+@subsection ipv6 option (-6)
+@cindex ntpdsim-ipv6
+
+This is the ``force ipv6 dns name resolution'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is a member of the ipv4 class of options.
+@end itemize
+
+Force DNS resolution of following host names on the command line
+to the IPv6 namespace.
+
+@node ntpdsim authreq
+@subsection authreq option (-a)
+@cindex ntpdsim-authreq
+
+This is the ``require crypto authentication'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+authnoreq.
+@end itemize
+
+Require cryptographic authentication for broadcast client,
+multicast client and symmetric passive associations.
+This is the default.
+
+@node ntpdsim authnoreq
+@subsection authnoreq option (-A)
+@cindex ntpdsim-authnoreq
+
+This is the ``do not require crypto authentication'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+authreq.
+@end itemize
+
+Do not require cryptographic authentication for broadcast client,
+multicast client and symmetric passive associations.
+This is almost never a good idea.
+
+@node ntpdsim bcastsync
+@subsection bcastsync option (-b)
+@cindex ntpdsim-bcastsync
+
+This is the ``allow us to sync to broadcast servers'' option.
+
+
+@node ntpdsim simbroadcastdelay
+@subsection simbroadcastdelay option (-B)
+@cindex ntpdsim-simbroadcastdelay
+
+This is the ``simulator broadcast delay'' option.
+
+
+@node ntpdsim configfile
+@subsection configfile option (-c)
+@cindex ntpdsim-configfile
+
+This is the ``configuration file name'' option.
+The name and path of the configuration file,
+/etc/ntp.conf
+by default.
+
+@node ntpdsim phasenoise
+@subsection phasenoise option (-C)
+@cindex ntpdsim-phasenoise
+
+This is the ``phase noise level'' option.
+
+
+@node ntpdsim debug-level
+@subsection debug-level option (-d)
+@cindex ntpdsim-debug-level
+
+This is the ``increase output debug message level'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@item
+must be compiled in by defining @code{DEBUG} during the compilation.
+@end itemize
+
+Increase the debugging message output level.
+
+@node ntpdsim set-debug-level
+@subsection set-debug-level option (-D)
+@cindex ntpdsim-set-debug-level
+
+This is the ``set the output debug message level'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@item
+must be compiled in by defining @code{DEBUG} during the compilation.
+@end itemize
+
+Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+
+@node ntpdsim driftfile
+@subsection driftfile option (-f)
+@cindex ntpdsim-driftfile
+
+This is the ``frequency drift file name'' option.
+The name and path of the frequency file,
+/etc/ntp.drift
+by default.
+This is the same operation as the
+driftfile driftfile
+configuration specification in the 
+/etc/ntp.conf
+file.
+
+@node ntpdsim panicgate
+@subsection panicgate option (-g)
+@cindex ntpdsim-panicgate
+
+This is the ``allow the first adjustment to be big'' option.
+Normally,
+ntpd
+exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows the time to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that,
+ntpd
+will exit with a message to the system log. This option can be used with the
+-q
+and
+-x
+options.
+See the
+tinker
+configuration file directive for other options.
+
+@node ntpdsim simslew
+@subsection simslew option (-H)
+@cindex ntpdsim-simslew
+
+This is the ``simuator slew'' option.
+
+
+@node ntpdsim jaildir
+@subsection jaildir option (-i)
+@cindex ntpdsim-jaildir
+
+This is the ``jail directory'' option.
+Chroot the server to the directory
+jaildir
+.
+This option also implies that the server attempts to drop root privileges at startup (otherwise, chroot gives very little additional security), and it is only available if the OS supports to run the server without full root privileges.
+You may need to also specify a
+-u
+option.
+
+@node ntpdsim interface
+@subsection interface option (-I)
+@cindex ntpdsim-interface
+
+This is the ``listen on interface'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+
+
+@node ntpdsim keyfile
+@subsection keyfile option (-k)
+@cindex ntpdsim-keyfile
+
+This is the ``path to symmetric keys'' option.
+Specify the name and path of the symmetric key file.
+/etc/ntp.keys
+is the default.
+This is the same operation as the
+keys keyfile
+configuration file directive.
+
+@node ntpdsim logfile
+@subsection logfile option (-l)
+@cindex ntpdsim-logfile
+
+This is the ``path to the log file'' option.
+Specify the name and path of the log file.
+The default is the system log file.
+This is the same operation as the
+logfile logfile
+configuration file directive.
+
+@node ntpdsim novirtualips
+@subsection novirtualips option (-L)
+@cindex ntpdsim-novirtualips
+
+This is the ``do not listen to virtual ips'' option.
+Do not listen to virtual IPs. The default is to listen.
+
+@node ntpdsim modifymmtimer
+@subsection modifymmtimer option (-M)
+@cindex ntpdsim-modifymmtimer
+
+This is the ``modify multimedia timer (windows only)'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{SYS_WINNT} during the compilation.
+@end itemize
+
+Set the Windows Multimedia Timer to highest resolution.
+
+@node ntpdsim nofork
+@subsection nofork option (-n)
+@cindex ntpdsim-nofork
+
+This is the ``do not fork'' option.
+
+
+@node ntpdsim nice
+@subsection nice option (-N)
+@cindex ntpdsim-nice
+
+This is the ``run at high priority'' option.
+To the extent permitted by the operating system, run
+ntpd
+at the highest priority.
+
+@node ntpdsim servertime
+@subsection servertime option (-O)
+@cindex ntpdsim-servertime
+
+This is the ``server time'' option.
+
+
+@node ntpdsim pidfile
+@subsection pidfile option (-p)
+@cindex ntpdsim-pidfile
+
+This is the ``path to the pid file'' option.
+Specify the name and path of the file used to record
+ntpd's
+process ID.
+This is the same operation as the
+pidfile pidfile
+configuration file directive.
+
+@node ntpdsim priority
+@subsection priority option (-P)
+@cindex ntpdsim-priority
+
+This is the ``process priority'' option.
+To the extent permitted by the operating system, run
+ntpd
+at the specified
+sched_setscheduler(SCHED_FIFO)
+priority.
+
+@node ntpdsim quit
+@subsection quit option (-q)
+@cindex ntpdsim-quit
+
+This is the ``set the time and quit'' option.
+ntpd
+will exit just after the first time the clock is set. This behavior mimics that of the
+ntpdate
+program, which is to be retired.
+The
+-g
+and
+-x
+options can be used with this option.
+Note: The kernel time discipline is disabled with this option.
+
+@node ntpdsim propagationdelay
+@subsection propagationdelay option (-r)
+@cindex ntpdsim-propagationdelay
+
+This is the ``broadcast/propagation delay'' option.
+Specify the default propagation delay from the broadcast/multicast server to this client. This is necessary only if the delay cannot be computed automatically by the protocol.
+
+@node ntpdsim updateinterval
+@subsection updateinterval option (-U)
+@cindex ntpdsim-updateinterval
+
+This is the ``interval in seconds between scans for new or dropped interfaces'' option.
+Give the time in seconds between two scans for new or dropped interfaces.
+For systems with routing socket support the scans will be performed shortly after the interface change
+has been detected by the system.
+Use 0 to disable scanning.
+
+@node ntpdsim statsdir
+@subsection statsdir option (-s)
+@cindex ntpdsim-statsdir
+
+This is the ``statistics file location'' option.
+Specify the directory path for files created by the statistics facility.
+This is the same operation as the
+statsdir statsdir
+configuration file directive.
+
+@node ntpdsim endsimtime
+@subsection endsimtime option (-S)
+@cindex ntpdsim-endsimtime
+
+This is the ``simulation end time'' option.
+
+
+@node ntpdsim trustedkey
+@subsection trustedkey option (-t)
+@cindex ntpdsim-trustedkey
+
+This is the ``trusted key number'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+Add a key number to the trusted key list.
+
+@node ntpdsim freqerr
+@subsection freqerr option (-T)
+@cindex ntpdsim-freqerr
+
+This is the ``simulation frequency error'' option.
+
+
+@node ntpdsim walknoise
+@subsection walknoise option (-W)
+@cindex ntpdsim-walknoise
+
+This is the ``simulation random walk noise'' option.
+
+
+@node ntpdsim user
+@subsection user option (-u)
+@cindex ntpdsim-user
+
+This is the ``run as userid (or userid:groupid)'' option.
+Specify a user, and optionally a group, to switch to.
+This option is only available if the OS supports to run the server without full root privileges.
+Currently, this option is supported under NetBSD (configure with
+--enable-clockctl
+) and Linux (configure with
+--enable-linuxcaps
+).
+
+@node ntpdsim var
+@subsection var option (-v)
+@cindex ntpdsim-var
+
+This is the ``make arg an ntp variable (rw)'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+
+
+@node ntpdsim dvar
+@subsection dvar option (-V)
+@cindex ntpdsim-dvar
+
+This is the ``make arg an ntp variable (rw|def)'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+
+
+@node ntpdsim slew
+@subsection slew option (-x)
+@cindex ntpdsim-slew
+
+This is the ``slew up to 600 seconds'' option.
+Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold.
+This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually.
+Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s.
+Thus, an adjustment as much as 600 s will take almost 14 days to complete.
+This option can be used with the
+-g
+and
+-q
+options.
+See the
+tinker
+configuration file directive for other options.
+Note: The kernel time discipline is disabled with this option.
+
+@node ntpdsim ndelay
+@subsection ndelay option (-Y)
+@cindex ntpdsim-ndelay
+
+This is the ``simulation network delay'' option.
+
+
+@node ntpdsim pdelay
+@subsection pdelay option (-Z)
+@cindex ntpdsim-pdelay
+
+This is the ``simulation processing delay'' option.
+
diff --git a/ntpd/ntpdsim.1 b/ntpd/ntpdsim.1
new file mode 100644 (file)
index 0000000..2028764
--- /dev/null
@@ -0,0 +1,357 @@
+.TH NTPDSIM 1 2009-12-08 "( 4.2.4p8)" "Programmer's Manual"
+.\"  EDIT THIS FILE WITH CAUTION  (ntpdsim.1)
+.\"  
+.\"  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:13:14 AM EST
+.\"  From the definitions    ntpdsim-opts.def
+.\"  and the template file   agman1.tpl
+.\"
+.SH NAME
+ntpdsim \- NTP daemon simulation program
+.SH SYNOPSIS
+.B ntpdsim
+.\" Mixture of short (flag) options and long options
+.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..."
+.PP
+All arguments must be options.
+.SH "DESCRIPTION"
+This manual page documents, briefly, the \fBntpdsim\fP command.
+
+.SH OPTIONS
+.TP
+.BR \-4 ", " \--ipv4
+Force IPv4 DNS name resolution.
+This option is a member of the ipv4 class of options.
+.sp
+Force DNS resolution of following host names on the command line
+to the IPv4 namespace.
+.TP
+.BR \-6 ", " \--ipv6
+Force IPv6 DNS name resolution.
+This option is a member of the ipv4 class of options.
+.sp
+Force DNS resolution of following host names on the command line
+to the IPv6 namespace.
+.TP
+.BR \-a ", " \--authreq
+Require crypto authentication.
+This option must not appear in combination with any of the following options:
+authnoreq.
+.sp
+Require cryptographic authentication for broadcast client,
+multicast client and symmetric passive associations.
+This is the default.
+.TP
+.BR \-A ", " \--authnoreq
+Do not require crypto authentication.
+This option must not appear in combination with any of the following options:
+authreq.
+.sp
+Do not require cryptographic authentication for broadcast client,
+multicast client and symmetric passive associations.
+This is almost never a good idea.
+.TP
+.BR \-b ", " \--bcastsync
+Allow us to sync to broadcast servers.
+.sp
+
+.TP
+.BR \-B " \fIstring\fP, " \--simbroadcastdelay "=" \fIstring\fP
+Simulator broadcast delay.
+.sp
+
+.TP
+.BR \-c " \fIstring\fP, " \--configfile "=" \fIstring\fP
+configuration file name.
+.sp
+The name and path of the configuration file,
+/etc/ntp.conf
+by default.
+.TP
+.BR \-C " \fIstring\fP, " \--phasenoise "=" \fIstring\fP
+Phase noise level.
+.sp
+
+.TP
+.BR \-d ", " \--debug-level
+Increase output debug message level.
+This option may appear an unlimited number of times.
+.sp
+Increase the debugging message output level.
+.TP
+.BR \-D " \fIstring\fP, " \--set-debug-level "=" \fIstring\fP
+Set the output debug message level.
+This option may appear an unlimited number of times.
+.sp
+Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+.TP
+.BR \-f " \fIstring\fP, " \--driftfile "=" \fIstring\fP
+frequency drift file name.
+.sp
+The name and path of the frequency file,
+/etc/ntp.drift
+by default.
+This is the same operation as the
+driftfile driftfile
+configuration specification in the 
+/etc/ntp.conf
+file.
+.TP
+.BR \-g ", " \--panicgate
+Allow the first adjustment to be Big.
+.sp
+Normally,
+ntpd
+exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows the time to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that,
+ntpd
+will exit with a message to the system log. This option can be used with the
+-q
+and
+-x
+options.
+See the
+tinker
+configuration file directive for other options.
+.TP
+.BR \-H " \fIstring\fP, " \--simslew "=" \fIstring\fP
+Simuator slew.
+.sp
+
+.TP
+.BR \-i " \fIstring\fP, " \--jaildir "=" \fIstring\fP
+Jail directory.
+.sp
+Chroot the server to the directory
+jaildir
+.
+This option also implies that the server attempts to drop root privileges at startup (otherwise, chroot gives very little additional security), and it is only available if the OS supports to run the server without full root privileges.
+You may need to also specify a
+-u
+option.
+.TP
+.BR \-I " \fIiface\fP, " \--interface "=" \fIiface\fP
+Listen on interface.
+This option may appear an unlimited number of times.
+.sp
+
+.TP
+.BR \-k " \fIstring\fP, " \--keyfile "=" \fIstring\fP
+path to symmetric keys.
+.sp
+Specify the name and path of the symmetric key file.
+/etc/ntp.keys
+is the default.
+This is the same operation as the
+keys keyfile
+configuration file directive.
+.TP
+.BR \-l " \fIstring\fP, " \--logfile "=" \fIstring\fP
+path to the log file.
+.sp
+Specify the name and path of the log file.
+The default is the system log file.
+This is the same operation as the
+logfile logfile
+configuration file directive.
+.TP
+.BR \-L ", " \--novirtualips
+Do not listen to virtual IPs.
+.sp
+Do not listen to virtual IPs. The default is to listen.
+.TP
+.BR \-M ", " \--modifymmtimer
+Modify Multimedia Timer (Windows only).
+.sp
+Set the Windows Multimedia Timer to highest resolution.
+.TP
+.BR \-n ", " \--nofork
+Do not fork.
+.sp
+
+.TP
+.BR \-N ", " \--nice
+Run at high priority.
+.sp
+To the extent permitted by the operating system, run
+ntpd
+at the highest priority.
+.TP
+.BR \-O " \fIstring\fP, " \--servertime "=" \fIstring\fP
+Server time.
+.sp
+
+.TP
+.BR \-p " \fIstring\fP, " \--pidfile "=" \fIstring\fP
+path to the PID file.
+.sp
+Specify the name and path of the file used to record
+ntpd's
+process ID.
+This is the same operation as the
+pidfile pidfile
+configuration file directive.
+.TP
+.BR \-P " \fInumber\fP, " \--priority "=" \fInumber\fP
+Process priority.
+This option takes an integer number as its argument.
+.sp
+To the extent permitted by the operating system, run
+ntpd
+at the specified
+sched_setscheduler(SCHED_FIFO)
+priority.
+.TP
+.BR \-q ", " \--quit
+Set the time and quit.
+.sp
+ntpd
+will exit just after the first time the clock is set. This behavior mimics that of the
+ntpdate
+program, which is to be retired.
+The
+-g
+and
+-x
+options can be used with this option.
+Note: The kernel time discipline is disabled with this option.
+.TP
+.BR \-r " \fIstring\fP, " \--propagationdelay "=" \fIstring\fP
+Broadcast/propagation delay.
+.sp
+Specify the default propagation delay from the broadcast/multicast server to this client. This is necessary only if the delay cannot be computed automatically by the protocol.
+.TP
+.BR \-U " \fInumber\fP, " \--updateinterval "=" \fInumber\fP
+interval in seconds between scans for new or dropped interfaces.
+This option takes an integer number as its argument.
+.sp
+Give the time in seconds between two scans for new or dropped interfaces.
+For systems with routing socket support the scans will be performed shortly after the interface change
+has been detected by the system.
+Use 0 to disable scanning.
+.TP
+.BR \-s " \fIstring\fP, " \--statsdir "=" \fIstring\fP
+Statistics file location.
+.sp
+Specify the directory path for files created by the statistics facility.
+This is the same operation as the
+statsdir statsdir
+configuration file directive.
+.TP
+.BR \-S " \fIstring\fP, " \--endsimtime "=" \fIstring\fP
+Simulation end time.
+.sp
+
+.TP
+.BR \-t " \fItkey\fP, " \--trustedkey "=" \fItkey\fP
+Trusted key number.
+This option may appear an unlimited number of times.
+.sp
+Add a key number to the trusted key list.
+.TP
+.BR \-T " \fIstring\fP, " \--freqerr "=" \fIstring\fP
+Simulation frequency error.
+.sp
+
+.TP
+.BR \-W " \fIstring\fP, " \--walknoise "=" \fIstring\fP
+Simulation random walk noise.
+.sp
+
+.TP
+.BR \-u " \fIstring\fP, " \--user "=" \fIstring\fP
+Run as userid (or userid:groupid).
+.sp
+Specify a user, and optionally a group, to switch to.
+This option is only available if the OS supports to run the server without full root privileges.
+Currently, this option is supported under NetBSD (configure with
+--enable-clockctl
+) and Linux (configure with
+--enable-linuxcaps
+).
+.TP
+.BR \-v " \fInvar\fP, " \--var "=" \fInvar\fP
+make ARG an ntp variable (RW).
+This option may appear an unlimited number of times.
+.sp
+
+.TP
+.BR \-V " \fIndvar\fP, " \--dvar "=" \fIndvar\fP
+make ARG an ntp variable (RW|DEF).
+This option may appear an unlimited number of times.
+.sp
+
+.TP
+.BR \-x ", " \--slew
+Slew up to 600 seconds.
+.sp
+Normally, the time is slewed if the offset is less than the step threshold, which is 128 ms by default, and stepped if above the threshold.
+This option sets the threshold to 600 s, which is well within the accuracy window to set the clock manually.
+Note: Since the slew rate of typical Unix kernels is limited to 0.5 ms/s, each second of adjustment requires an amortization interval of 2000 s.
+Thus, an adjustment as much as 600 s will take almost 14 days to complete.
+This option can be used with the
+-g
+and
+-q
+options.
+See the
+tinker
+configuration file directive for other options.
+Note: The kernel time discipline is disabled with this option.
+.TP
+.BR \-Y " \fIstring\fP, " \--ndelay "=" \fIstring\fP
+Simulation network delay.
+.sp
+
+.TP
+.BR \-Z " \fIstring\fP, " \--pdelay "=" \fIstring\fP
+Simulation processing delay.
+.sp
+
+.TP
+.BR \-? , " \--help"
+Display usage information and exit.
+.TP
+.BR \-! , " \--more-help"
+Extended usage information passed thru pager.
+.TP
+.BR \-> " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]"
+Save the option state to \fIrcfile\fP.  The default is the \fIlast\fP
+configuration file listed in the \fBOPTION PRESETS\fP section, below.
+.TP
+.BR \-< " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts"
+Load options from \fIrcfile\fP.
+The \fIno-load-opts\fP form will disable the loading
+of earlier RC/INI files.  \fI--no-load-opts\fP is handled early,
+out of order.
+.TP
+.BR \-v " [{\fIv|c|n\fP}]," " \--version" "[=\fI{v|c|n}\fP]"
+Output version of program and exit.  The default mode is `v', a simple
+version.  The `c' mode will print copyright information and `n' will
+print the full copyright notice.
+.SH OPTION PRESETS
+Any option that is not marked as \fInot presettable\fP may be preset
+by loading values from configuration ("RC" or ".INI") file(s) and values from
+environment variables named:
+.nf
+  \fBNTPDSIM_<option-name>\fP or \fBNTPDSIM\fP
+.fi
+.aj
+The environmental presets take precedence (are processed later than)
+the configuration files.
+The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP".
+If any of these are directories, then the file \fI.ntprc\fP
+is searched for within those directories.
+.SH AUTHOR
+David L. Mills and/or others
+.br
+Please send bug reports to:  http://bugs.ntp.org, bugs@ntp.org
+
+.PP
+.nf
+.na
+see html/copyright.html
+.fi
+.ad
+.PP
+This manual page was \fIAutoGen\fP-erated from the \fBntpdsim\fP
+option definitions.
diff --git a/ntpd/ntpsim.c b/ntpd/ntpsim.c
new file mode 100644 (file)
index 0000000..d5ed587
--- /dev/null
@@ -0,0 +1,371 @@
+/*
+ * NTP simulator engine - Harish Nair
+ * University of Delaware, 2001
+ */
+#include "ntpd.h"
+#include "ntpsim.h"
+#include "ntpdsim-opts.h"
+
+/*
+ * Defines...
+ */
+#define SIM_TIME 86400         /* end simulation time */
+#define NET_DLY .001            /* network delay */
+#define PROC_DLY .001          /* processing delay */
+#define BEEP_DLY 3600           /* beep interval (s) */
+#define        SLEW    500e-6          /* correction rate (PPM) */
+
+/*
+ * Function pointers
+ */
+void (*funcPtr[]) (Node *, Event) = {
+       &ndbeep, &ndeclk, &ntptmr, &netpkt
+};
+
+
+/*
+ * ntpsim - initialize global variables and event queue and start
+ */
+int
+ntpsim(
+       int     argc,
+       char    *argv[]
+       )
+{
+       Event   e;
+       double  maxtime;
+       struct timeval seed;
+
+       /*
+        * Initialize the global node
+        */
+       ntp_node.time = 0;              /* simulation time */
+       ntp_node.sim_time = SIM_TIME;   /* end simulation time (-S) */
+       ntp_node.ntp_time = 0;          /* client disciplined time */
+       ntp_node.adj = 0;               /* remaining time correction */
+       ntp_node.slew = SLEW;           /* correction rate (-H) */
+
+       ntp_node.clk_time = 0;          /* server time (-O) */
+       ntp_node.ferr = 0;              /* frequency error (-T) */
+       ntp_node.fnse = 0;              /* random walk noise (-W) */
+       ntp_node.ndly = NET_DLY;        /* network delay (-Y) */
+       ntp_node.snse = 0;              /* phase noise (-C) */
+       ntp_node.pdly = PROC_DLY;       /* processing delay (-Z) */
+       ntp_node.bdly = BEEP_DLY;       /* beep interval (-B) */
+
+       ntp_node.events = NULL;
+       ntp_node.rbuflist = NULL;
+
+       /*
+        * Initialize ntp variables
+        */
+       initializing = 1;
+        init_auth();
+        init_util();
+        init_restrict();
+        init_mon();
+        init_timer();
+        init_lib();
+        init_request();
+        init_control();
+        init_peer();
+        init_proto();
+        init_io();
+        init_loopfilter();
+        mon_start(MON_OFF);
+
+       {
+               int optct = optionProcess(&ntpdsimOptions, argc, argv);
+               argc -= optct;
+               argv += optct;
+       }
+
+       getconfig(argc, argv);
+
+        initializing = 0;
+       loop_config(LOOP_DRIFTCOMP, old_drift / 1e6);
+
+       /*
+        * Watch out here, we want the real time, not the silly stuff.
+        */
+       gettimeofday(&seed, NULL);
+       ntp_srandom(seed.tv_usec);
+
+       /*
+        * Push a beep and timer interrupt on the queue
+        */
+       push(event(0, BEEP), &ntp_node.events);
+       push(event(ntp_node.time + 1.0, TIMER), &ntp_node.events);
+
+       /*
+        * Pop the queue until nothing is left or time is exceeded
+        */
+       maxtime = ntp_node.time + ntp_node.sim_time;
+       while (ntp_node.time <= maxtime && ntp_node.events != NULL ) {
+               e = pop(&ntp_node.events);
+               ndeclk(&ntp_node, e);
+               funcPtr[e.function](&ntp_node, e);
+       }
+       return (0);
+}
+
+
+/*
+ * Return an event
+ */
+Event
+event(
+       double t,
+       funcTkn f
+       )
+{
+       Event e;
+
+       e.time = t;
+       e.function = f;
+       return (e);
+}
+
+/*
+ * Create an event queue
+ */
+Queue
+queue(
+       Event e,
+       Queue q
+       )
+{
+       Queue ret;
+
+       if ((ret = (Queue)malloc(sizeof(struct List))) == NULL)
+                abortsim("queue-malloc");
+       ret->event = e;
+       ret->next = q;
+       return (ret);
+}
+
+
+/*
+ * Push an event into the event queue
+ */
+void push(
+       Event e,
+       Queue *qp
+       )
+{
+       Queue *tmp = qp;
+
+       while (*tmp != NULL && ((*tmp)->event.time < e.time))
+               tmp = &((*tmp)->next);
+       *tmp = queue(e, (*tmp));
+}
+
+
+/*
+ * Pop the first event from the event queue
+ */
+Event
+pop(
+       Queue *qp
+       )
+{
+       Event ret;
+       Queue tmp;
+
+       tmp = *qp;
+       if (tmp == NULL)
+           abortsim("pop - empty queue");
+       ret = tmp->event;
+       *qp = tmp->next;
+       free(tmp);
+       return (ret);
+}
+
+
+/*
+ * Update clocks
+ */
+void
+ndeclk(
+       Node *n,
+       Event e
+       )
+{
+       node_clock(n, e.time);
+}
+
+
+/*
+ * Timer interrupt. Eventually, this results in calling the
+ * srvr_rplyi() routine below.
+ */
+void
+ntptmr(
+       Node *n,
+       Event e
+       )
+{
+       struct recvbuf *rbuf;
+
+       timer();
+
+       /*
+        * Process buffers received. They had better be in order by
+        * receive timestamp. Note that there are no additional buffers
+        * in the current implementation of ntpsim.
+        */
+       while (n->rbuflist != NULL) {
+               rbuf = n->rbuflist;
+               n->rbuflist = NULL;
+               (rbuf->receiver)(rbuf);
+               free(rbuf);
+       }
+
+       /*
+        * Arm the next timer interrupt.
+        */
+       push(event(e.time + (1 << EVENT_TIMEOUT), TIMER), &n->events);
+}
+
+
+/*
+ * srvr_rply() - send packet
+ */
+int srvr_rply(
+       Node *n,
+       struct sockaddr_storage *dest,
+       struct interface *inter, struct pkt *rpkt
+       )
+{
+       struct pkt xpkt;
+       struct recvbuf rbuf;
+       Event   xvnt;
+       double  dtemp, etemp;
+
+       /*
+        * Insert packet header values. We make this look like a
+        * stratum-1 server with a GPS clock, but nobody will ever
+        * notice that.
+        */
+       xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOWARNING, NTP_VERSION,
+           MODE_SERVER);
+       xpkt.stratum = STRATUM_TO_PKT(((u_char)1));
+       memcpy(&xpkt.refid, "GPS", 4);
+       xpkt.ppoll = rpkt->ppoll;
+        xpkt.precision = rpkt->precision;
+        xpkt.rootdelay = 0;
+        xpkt.rootdispersion = 0;
+
+       /*
+        * Insert the timestamps.
+        */
+        xpkt.org = rpkt->xmt;
+       dtemp = poisson(n->ndly, n->snse); /* client->server delay */
+       DTOLFP(dtemp + n->clk_time, &xpkt.rec);
+       dtemp += poisson(n->pdly, 0);   /* server delay */
+       DTOLFP(dtemp + n->clk_time, &xpkt.xmt);
+       xpkt.reftime = xpkt.xmt;
+       dtemp += poisson(n->ndly, n->snse); /* server->client delay */
+
+       /*
+        * Insert the I/O stuff.
+        */
+       rbuf.receiver = receive;
+        get_systime(&rbuf.recv_time);
+        rbuf.recv_length = LEN_PKT_NOMAC;
+        rbuf.recv_pkt = xpkt;
+        memcpy(&rbuf.srcadr, dest, sizeof(struct sockaddr_storage));
+        memcpy(&rbuf.recv_srcadr, dest,
+           sizeof(struct sockaddr_storage));
+        if ((rbuf.dstadr = malloc(sizeof(struct interface))) == NULL)
+               abortsim("server-malloc");
+        memcpy(rbuf.dstadr, inter, sizeof(struct interface));
+
+       /*
+        * Very carefully predict the time of arrival for the received
+        * packet. 
+        */ 
+       LFPTOD(&xpkt.org, etemp);
+       etemp += dtemp;
+       xvnt = event(etemp, PACKET);
+       xvnt.rcv_buf = rbuf;
+       push(xvnt, &n->events);
+       return (0);
+}
+
+
+/*
+ * netpkt() - receive packet
+ */
+void
+netpkt(
+       Node *n,
+       Event e
+       )
+{
+       struct recvbuf *rbuf;
+       struct recvbuf *obuf;
+
+       /*
+        * Insert the packet on the receive queue and record the arrival
+        * time.
+        */
+       if ((rbuf = malloc(sizeof(struct recvbuf))) == NULL)
+               abortsim("ntprcv-malloc");
+       memcpy(rbuf, &e.rcv_buf, sizeof(struct recvbuf));
+       rbuf->receiver = receive;
+       DTOLFP(n->ntp_time, &rbuf->recv_time);
+       obuf = n->rbuflist;
+
+       /*
+        * In the present incarnation, no more than one buffer can be on
+        * the queue; 
+        */
+       if (obuf == NULL) {
+               n->rbuflist = rbuf;
+       }
+}
+
+
+/*
+ * ndbeep() - progress indicator
+ */
+void
+ndbeep(
+       Node *n,
+       Event e
+       )
+{
+       static int first_time = 1;
+       char *dash = "-----------------";
+
+       if(n->bdly > 0) {
+               if (first_time) {
+                       printf(
+                           "\t%4c    T    %4c\t%4c  T+ERR  %3c\t%5cT+ERR+NTP\n", ' ', ' ', ' ', ' ',' ');
+                       printf("\t%s\t%s\t%s\n", dash, dash, dash);
+                       first_time = 0;
+                       push(event(n->bdly, BEEP), &n->events);  
+                       push(event(n->sim_time, BEEP), &n->events);
+                       printf("\t%16.6f\t%16.6f\t%16.6f\n",
+                            n->time, n->clk_time, n->ntp_time);
+                       return;
+               }
+               printf("\t%16.6f\t%16.6f\t%16.6f\n",
+                   n->time, n->clk_time, n->ntp_time);
+               push(event(e.time + n->bdly, BEEP), &n->events);
+       }
+}
+
+
+/*
+ * Abort simulation
+ */
+void
+abortsim(
+       char *errmsg
+       )
+{
+        perror(errmsg);
+        exit(1);
+}
diff --git a/ntpd/ppsapi_timepps.h b/ntpd/ppsapi_timepps.h
new file mode 100644 (file)
index 0000000..8adaf62
--- /dev/null
@@ -0,0 +1,26 @@
+/* ppsapi_timepps.h */
+
+/*
+ * This logic first tries to get the timepps.h file from a standard
+ * location, and then from our include/ subdirectory.
+ */
+
+#ifdef HAVE_TIMEPPS_H
+# include <timepps.h>
+#else
+# ifdef HAVE_SYS_TIMEPPS_H
+#  include <sys/timepps.h>
+# else
+#  ifdef HAVE_CIOGETEV
+#   include "timepps-SunOS.h"
+#  else
+#   ifdef HAVE_TIOCGPPSEV
+#    include "timepps-Solaris.h"
+#   else
+#    ifdef TIOCDCDTIMESTAMP
+#     include "timepps-SCO.h"
+#    endif
+#   endif
+#  endif
+# endif
+#endif
diff --git a/ntpd/refclock_acts.c b/ntpd/refclock_acts.c
new file mode 100644 (file)
index 0000000..57f2ca7
--- /dev/null
@@ -0,0 +1,931 @@
+/*
+ * refclock_acts - clock driver for the NIST/USNO/PTB/NPL Computer Time
+ *     Services
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && (defined(CLOCK_ACTS) || defined(CLOCK_PTBACTS))
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_unixtime.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+#include "ntp_control.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif /* HAVE_SYS_IOCTL_H */
+
+/*
+ * This driver supports the US (NIST, USNO) and European (PTB, NPL,
+ * etc.) modem time services, as well as Spectracom GPS and WWVB
+ * receivers connected via a modem. The driver periodically dials a
+ * number from a telephone list, receives the timecode data and
+ * calculates the local clock correction. It is designed primarily for
+ * use as backup when neither a radio clock nor connectivity to Internet
+ * time servers is available.
+ *
+ * This driver requires a modem with a Hayes-compatible command set and
+ * control over the modem data terminal ready (DTR) control line. The
+ * modem setup string is hard-coded in the driver and may require
+ * changes for nonstandard modems or special circumstances. For reasons
+ * unrelated to this driver, the data set ready (DSR) control line
+ * should not be set when this driver is first started.
+ *
+ * The calling program is initiated by setting fudge flag1, either
+ * manually or automatically. When flag1 is set, the calling program
+ * dials the first number in the phone command of the configuration
+ * file. If that call fails, the calling program dials the second number
+ * and so on. The number is specified by the Hayes ATDT prefix followed
+ * by the number itself, including the prefix and long-distance digits
+ * and delay code, if necessary. The flag1 is reset and the calling
+ * program terminated if (a) a valid clock update has been determined,
+ * (b) no more numbers remain in the list, (c) a device fault or timeout
+ * occurs or (d) fudge flag1 is reset manually.
+ *
+ * The driver is transparent to each of the modem time services and
+ * Spectracom radios. It selects the parsing algorithm depending on the
+ * message length. There is some hazard should the message be corrupted.
+ * However, the data format is checked carefully and only if all checks
+ * succeed is the message accepted. Corrupted lines are discarded
+ * without complaint.
+ *
+ * Fudge controls
+ *
+ * flag1       force a call in manual mode
+ * flag2       enable port locking (not verified)
+ * flag3       no modem; port is directly connected to device
+ * flag4       not used
+ *
+ * time1       offset adjustment (s)
+ *
+ * Ordinarily, the serial port is connected to a modem; however, it can
+ * be connected directly to a device or another computer for testing and
+ * calibration. In this case set fudge flag3 and the driver will send a
+ * single character 'T' at each poll event. In principle, fudge flag2
+ * enables port locking, allowing the modem to be shared when not in use
+ * by this driver. At least on Solaris with the current NTP I/O
+ * routines, this results only in lots of ugly error messages.
+ */
+/*
+ * National Institute of Science and Technology (NIST)
+ *
+ * Phone: (303) 494-4774 (Boulder, CO); (808) 335-4721 (Hawaii)
+ *
+ * Data Format
+ *
+ * National Institute of Standards and Technology
+ * Telephone Time Service, Generator 3B
+ * Enter question mark "?" for HELP
+ *                         D  L D
+ *  MJD  YR MO DA H  M  S  ST S UT1 msADV        <OTM>
+ * 47999 90-04-18 21:39:15 50 0 +.1 045.0 UTC(NIST) *<CR><LF>
+ * ...
+ *
+ * MJD, DST, DUT1 and UTC are not used by this driver. The "*" or "#" is
+ * the on-time markers echoed by the driver and used by NIST to measure
+ * and correct for the propagation delay.
+ *
+ * US Naval Observatory (USNO)
+ *
+ * Phone: (202) 762-1594 (Washington, DC); (719) 567-6742 (Boulder, CO)
+ *
+ * Data Format (two lines, repeating at one-second intervals)
+ *
+ * jjjjj nnn hhmmss UTC<CR><LF>
+ * *<CR><LF>
+ *
+ * jjjjj       modified Julian day number (not used)
+ * nnn         day of year
+ * hhmmss      second of day
+ * *           on-time marker for previous timecode
+ * ...
+ *
+ * USNO does not correct for the propagation delay. A fudge time1 of
+ * about .06 s is advisable.
+ *
+ * European Services (PTB, NPL, etc.)
+ *
+ * PTB: +49 531 512038 (Germany)
+ * NPL: 0906 851 6333 (UK only)
+ *
+ * Data format (see the documentation for phone numbers and formats.)
+ *
+ * 1995-01-23 20:58:51 MEZ  10402303260219950123195849740+40000500<CR><LF>
+ *
+ * Spectracom GPS and WWVB Receivers
+ *
+ * If a modem is connected to a Spectracom receiver, this driver will
+ * call it up and retrieve the time in one of two formats. As this
+ * driver does not send anything, the radio will have to either be
+ * configured in continuous mode or be polled by another local driver.
+ */
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/acts%d" /* device name and unit */
+#define        SPEED232        B9600   /* uart speed (9600 baud) */
+#define        PRECISION       (-10)   /* precision assumed (about 1 ms) */
+#define LOCKFILE       "/var/spool/locks/LCK..cua%d"
+#define DESCRIPTION    "Automated Computer Time Service" /* WRU */
+#define REFID          "NONE"  /* default reference ID */
+#define MSGCNT         20      /* max message count */
+#define SMAX           256     /* max clockstats line length */
+
+/*
+ * Calling program modes
+ */
+#define MODE_AUTO      0       /* automatic mode */
+#define MODE_BACKUP    1       /* backup mode */
+#define MODE_MANUAL    2       /* manual mode */
+
+/*
+ * Service identifiers.
+ */
+#define REFACTS                "NIST"  /* NIST reference ID */
+#define LENACTS                50      /* NIST format */
+#define REFUSNO                "USNO"  /* USNO reference ID */
+#define LENUSNO                20      /* USNO */
+#define REFPTB         "PTB\0" /* PTB/NPL reference ID */
+#define LENPTB         78      /* PTB/NPL format */
+#define REFWWVB                "WWVB"  /* WWVB reference ID */
+#define        LENWWVB0        22      /* WWVB format 0 */
+#define        LENWWVB2        24      /* WWVB format 2 */
+#define LF             0x0a    /* ASCII LF */
+
+/*
+ * Modem setup strings. These may have to be changed for some modems.
+ *
+ * AT  command prefix
+ * B1  US answer tone
+ * &C0 disable carrier detect
+ * &D2 hang up and return to command mode on DTR transition
+ * E0  modem command echo disabled
+ * l1  set modem speaker volume to low level
+ * M1  speaker enabled until carrier detect
+ * Q0  return result codes
+ * V1  return result codes as English words
+ */
+#define MODEM_SETUP    "ATB1&C0&D2E0L1M1Q0V1\r" /* modem setup */
+#define MODEM_HANGUP   "ATH\r" /* modem disconnect */
+
+/*
+ * Timeouts (all in seconds)
+ */
+#define SETUP          3       /* setup timeout */
+#define        DTR             1       /* DTR timeout */
+#define ANSWER         60      /* answer timeout */
+#define CONNECT                20      /* first valid message timeout */
+#define TIMECODE       30      /* all valid messages timeout */
+
+/*
+ * State machine codes
+ */
+#define S_IDLE         0       /* wait for poll */
+#define S_OK           1       /* wait for modem setup */
+#define S_DTR          2       /* wait for modem DTR */
+#define S_CONNECT      3       /* wait for answer*/
+#define S_FIRST                4       /* wait for first valid message */
+#define S_MSG          5       /* wait for all messages */
+#define S_CLOSE                6       /* wait after sending disconnect */
+
+/*
+ * Unit control structure
+ */
+struct actsunit {
+       int     unit;           /* unit number */
+       int     state;          /* the first one was Delaware */
+       int     timer;          /* timeout counter */
+       int     retry;          /* retry index */
+       int     msgcnt;         /* count of messages received */
+       l_fp    tstamp;         /* on-time timestamp */
+       char    *bufptr;        /* buffer pointer */
+};
+
+/*
+ * Function prototypes
+ */
+static int     acts_start      P((int, struct peer *));
+static void    acts_shutdown   P((int, struct peer *));
+static void    acts_receive    P((struct recvbuf *));
+static void    acts_message    P((struct peer *));
+static void    acts_timecode   P((struct peer *, char *));
+static void    acts_poll       P((int, struct peer *));
+static void    acts_timeout    P((struct peer *));
+static void    acts_disc       P((struct peer *));
+static void    acts_timer      P((int, struct peer *));
+
+/*
+ * Transfer vector (conditional structure name)
+ */
+struct refclock refclock_acts = {
+       acts_start,             /* start up driver */
+       acts_shutdown,          /* shut down driver */
+       acts_poll,              /* transmit poll message */
+       noentry,                /* not used */
+       noentry,                /* not used */
+       noentry,                /* not used */
+       acts_timer              /* housekeeping timer */
+};
+
+struct refclock refclock_ptb;
+
+/*
+ * Initialize data for processing
+ */
+static int
+acts_start (
+       int     unit,
+       struct peer *peer
+       )
+{
+       struct actsunit *up;
+       struct refclockproc *pp;
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       up = emalloc(sizeof(struct actsunit));
+       if (up == NULL)
+               return (0);
+
+       memset(up, 0, sizeof(struct actsunit));
+       up->unit = unit;
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t)up;
+       pp->io.clock_recv = acts_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       peer->sstclktype = CTL_SST_TS_TELEPHONE;
+       peer->flags &= ~FLAG_FIXPOLL;
+       up->bufptr = pp->a_lastcode;
+       return (1);
+}
+
+
+/*
+ * acts_shutdown - shut down the clock
+ */
+static void
+acts_shutdown (
+       int     unit,
+       struct peer *peer
+       )
+{
+       struct actsunit *up;
+       struct refclockproc *pp;
+
+       /*
+        * Warning: do this only when a call is not in progress.
+        */
+       pp = peer->procptr;
+       up = (struct actsunit *)pp->unitptr;
+       free(up);
+}
+
+
+/*
+ * acts_receive - receive data from the serial interface
+ */
+static void
+acts_receive (
+       struct recvbuf *rbufp
+       )
+{
+       struct actsunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       char    tbuf[BMAX];
+       char    *tptr;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp. Note
+        * we are in raw mode and victim of whatever the terminal
+        * interface kicks up; so, we have to reassemble messages from
+        * arbitrary fragments. Capture the timecode at the beginning of
+        * the message and at the '*' and '#' on-time characters.
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct actsunit *)pp->unitptr;
+       pp->lencode = refclock_gtraw(rbufp, tbuf, BMAX - (up->bufptr -
+           pp->a_lastcode), &pp->lastrec);
+       for (tptr = tbuf; *tptr != '\0'; tptr++) {
+               if (*tptr == LF) {
+                       if (up->bufptr == pp->a_lastcode) {
+                               up->tstamp = pp->lastrec;
+                               continue;
+
+                       } else {
+                               *up->bufptr = '\0';
+                               acts_message(peer);
+                               up->bufptr = pp->a_lastcode;
+                       }
+               } else if (!iscntrl(*tptr)) {
+                       *up->bufptr++ = *tptr;
+                       if (*tptr == '*' || *tptr == '#') {
+                               up->tstamp = pp->lastrec;
+                               write(pp->io.fd, tptr, 1);
+                       }
+               }
+       }
+}
+
+
+/*
+ * acts_message - process message
+ */
+void
+acts_message(
+       struct peer *peer
+       )
+{
+       struct actsunit *up;
+       struct refclockproc *pp;
+       int     dtr = TIOCM_DTR;
+       char    tbuf[SMAX];
+#ifdef DEBUG
+       u_int   modem;
+#endif
+
+       /*
+        * What to do depends on the state and the first token in the
+        * message. A NO token sends the message to the clockstats.
+        */
+       pp = peer->procptr;
+       up = (struct actsunit *)pp->unitptr;
+#ifdef DEBUG
+       ioctl(pp->io.fd, TIOCMGET, (char *)&modem);
+       sprintf(tbuf, "acts: %04x (%d %d) %lu %s", modem, up->state,
+           up->timer, strlen(pp->a_lastcode), pp->a_lastcode);
+       if (debug)
+               printf("%s\n", tbuf);
+#endif
+       strncpy(tbuf, pp->a_lastcode, SMAX);
+       strtok(tbuf, " ");
+       if (strcmp(tbuf, "NO") == 0)
+               record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       switch(up->state) {
+
+       /*
+        * We are waiting for the OK response to the modem setup
+        * command. When this happens, raise DTR and dial the number
+        * followed by \r.
+        */
+       case S_OK:
+               if (strcmp(tbuf, "OK") != 0) {
+                       msyslog(LOG_ERR, "acts: setup error %s",
+                           pp->a_lastcode);
+                       acts_disc(peer);
+                       return;
+               }
+               ioctl(pp->io.fd, TIOCMBIS, (char *)&dtr);
+               up->state = S_DTR;
+               up->timer = DTR;
+               return;
+
+       /*
+        * We are waiting for the call to be answered. All we care about
+        * here is token CONNECT. Send the message to the clockstats.
+        */
+       case S_CONNECT:
+               record_clock_stats(&peer->srcadr, pp->a_lastcode);
+               if (strcmp(tbuf, "CONNECT") != 0) {
+                       acts_disc(peer);
+                       return;
+               }
+               up->state = S_FIRST;
+               up->timer = CONNECT;
+               return;
+
+       /*
+        * We are waiting for a timecode. Pass it to the parser.
+        */
+       case S_FIRST:
+       case S_MSG:
+               acts_timecode(peer, pp->a_lastcode);
+               break;
+       }
+}
+
+/*
+ * acts_timecode - identify the service and parse the timecode message
+ */
+void
+acts_timecode(
+       struct peer *peer,      /* peer structure pointer */
+       char    *str            /* timecode string */
+       )
+{
+       struct actsunit *up;
+       struct refclockproc *pp;
+       int     day;            /* day of the month */
+       int     month;          /* month of the year */
+       u_long  mjd;            /* Modified Julian Day */
+       double  dut1;           /* DUT adjustment */
+
+       u_int   dst;            /* ACTS daylight/standard time */
+       u_int   leap;           /* ACTS leap indicator */
+       double  msADV;          /* ACTS transmit advance (ms) */
+       char    utc[10];        /* ACTS timescale */
+       char    flag;           /* ACTS on-time character (* or #) */
+
+       char    synchar;        /* WWVB synchronized indicator */
+       char    qualchar;       /* WWVB quality indicator */
+       char    leapchar;       /* WWVB leap indicator */
+       char    dstchar;        /* WWVB daylight/savings indicator */
+       int     tz;             /* WWVB timezone */
+
+       u_int   leapmonth;      /* PTB/NPL month of leap */
+       char    leapdir;        /* PTB/NPL leap direction */
+
+       /*
+        * The parser selects the modem format based on the message
+        * length. Since the data are checked carefully, occasional
+        * errors due noise are forgivable.
+        */
+       pp = peer->procptr;
+       up = (struct actsunit *)pp->unitptr;
+       pp->nsec = 0;
+       switch(strlen(str)) {
+
+       /*
+        * For USNO format on-time character '*', which is on a line by
+        * itself. Be sure a timecode has been received.
+        */
+       case 1:
+               if (*str == '*' && up->msgcnt > 0) 
+                       break;
+
+               return;
+       
+       /*
+        * ACTS format: "jjjjj yy-mm-dd hh:mm:ss ds l uuu aaaaa
+        * UTC(NIST) *"
+        */
+       case LENACTS:
+               if (sscanf(str,
+                   "%5ld %2d-%2d-%2d %2d:%2d:%2d %2d %1d %3lf %5lf %9s %c",
+                   &mjd, &pp->year, &month, &day, &pp->hour,
+                   &pp->minute, &pp->second, &dst, &leap, &dut1,
+                   &msADV, utc, &flag) != 13) {
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+
+               /*
+                * Wait until ACTS has calculated the roundtrip delay.
+                * We don't need to do anything, as ACTS adjusts the
+                * on-time epoch.
+                */
+               if (flag != '#')
+                       return;
+
+               pp->day = ymd2yd(pp->year, month, day);
+               pp->leap = LEAP_NOWARNING;
+               if (leap == 1)
+                       pp->leap = LEAP_ADDSECOND;
+               else if (pp->leap == 2)
+                       pp->leap = LEAP_DELSECOND;
+               memcpy(&pp->refid, REFACTS, 4);
+               if (up->msgcnt == 0)
+                       record_clock_stats(&peer->srcadr, str);
+               up->msgcnt++;
+               break;
+
+       /*
+        * USNO format: "jjjjj nnn hhmmss UTC"
+        */
+       case LENUSNO:
+               if (sscanf(str, "%5ld %3d %2d%2d%2d %3s",
+                   &mjd, &pp->day, &pp->hour, &pp->minute,
+                   &pp->second, utc) != 6) {
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+
+               /*
+                * Wait for the on-time character, which follows in a
+                * separate message. There is no provision for leap
+                * warning.
+                */
+               pp->leap = LEAP_NOWARNING;
+               memcpy(&pp->refid, REFUSNO, 4);
+               if (up->msgcnt == 0)
+                       record_clock_stats(&peer->srcadr, str);
+               up->msgcnt++;
+               return;
+
+       /*
+        * PTB/NPL format: "yyyy-mm-dd hh:mm:ss MEZ" 
+        */
+       case LENPTB:
+               if (sscanf(str,
+                   "%*4d-%*2d-%*2d %*2d:%*2d:%2d %*5c%*12c%4d%2d%2d%2d%2d%5ld%2lf%c%2d%3lf%*15c%c",
+                   &pp->second, &pp->year, &month, &day, &pp->hour,
+                   &pp->minute, &mjd, &dut1, &leapdir, &leapmonth,
+                   &msADV, &flag) != 12) {
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+               pp->leap = LEAP_NOWARNING;
+               if (leapmonth == month) {
+                       if (leapdir == '+')
+                               pp->leap = LEAP_ADDSECOND;
+                       else if (leapdir == '-')
+                               pp->leap = LEAP_DELSECOND;
+               }
+               pp->day = ymd2yd(pp->year, month, day);
+               memcpy(&pp->refid, REFPTB, 4);
+               if (up->msgcnt == 0)
+                       record_clock_stats(&peer->srcadr, str);
+               up->msgcnt++;
+               break;
+
+
+       /*
+        * WWVB format 0: "I  ddd hh:mm:ss DTZ=nn"
+        */
+       case LENWWVB0:
+               if (sscanf(str, "%c %3d %2d:%2d:%2d %cTZ=%2d",
+                   &synchar, &pp->day, &pp->hour, &pp->minute,
+                   &pp->second, &dstchar, &tz) != 7) {
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+               pp->leap = LEAP_NOWARNING;
+               if (synchar != ' ')
+                       pp->leap = LEAP_NOTINSYNC;
+               memcpy(&pp->refid, REFWWVB, 4);
+               if (up->msgcnt == 0)
+                       record_clock_stats(&peer->srcadr, str);
+               up->msgcnt++;
+               break;
+
+       /*
+        * WWVB format 2: "IQyy ddd hh:mm:ss.mmm LD"
+        */
+       case LENWWVB2:
+               if (sscanf(str, "%c%c%2d %3d %2d:%2d:%2d.%3ld%c%c%c",
+                   &synchar, &qualchar, &pp->year, &pp->day,
+                   &pp->hour, &pp->minute, &pp->second, &pp->nsec,
+                   &dstchar, &leapchar, &dstchar) != 11) {
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+               pp->nsec *= 1000000;
+               pp->leap = LEAP_NOWARNING;
+               if (synchar != ' ')
+                       pp->leap = LEAP_NOTINSYNC;
+               else if (leapchar == 'L')
+                       pp->leap = LEAP_ADDSECOND;
+               memcpy(&pp->refid, REFWWVB, 4);
+               if (up->msgcnt == 0)
+                       record_clock_stats(&peer->srcadr, str);
+               up->msgcnt++;
+               break;
+
+       /*
+        * None of the above. Just forget about it and wait for the next
+        * message or timeout.
+        */
+       default:
+               return;
+       }
+
+       /*
+        * We have a valid timecode. The fudge time1 value is added to
+        * each sample by the main line routines. Note that in current
+        * telephone networks the propatation time can be different for
+        * each call and can reach 200 ms for some calls.
+        */
+       peer->refid = pp->refid;
+       pp->lastrec = up->tstamp;
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+                       }
+       pp->lastref = pp->lastrec;
+       if (peer->disp > MAXDISTANCE)
+               refclock_receive(peer);
+       if (up->state != S_MSG) {
+               up->state = S_MSG;
+               up->timer = TIMECODE;
+       }
+}
+
+
+/*
+ * acts_poll - called by the transmit routine
+ */
+static void
+acts_poll (
+       int     unit,
+       struct peer *peer
+       )
+{
+       struct actsunit *up;
+       struct refclockproc *pp;
+
+       /*
+        * This routine is called at every system poll. All it does is
+        * set flag1 under certain conditions. The real work is done by
+        * the timeout routine and state machine.
+        */
+       pp = peer->procptr;
+       up = (struct actsunit *)pp->unitptr;
+       switch (peer->ttl) {
+
+       /*
+        * In manual mode the calling program is activated by the ntpdc
+        * program using the enable flag (fudge flag1), either manually
+        * or by a cron job.
+        */
+       case MODE_MANUAL:
+               /* fall through */
+               break;
+
+       /*
+        * In automatic mode the calling program runs continuously at
+        * intervals determined by the poll event or specified timeout.
+        */
+       case MODE_AUTO:
+               pp->sloppyclockflag |= CLK_FLAG1;
+               break;
+
+       /*
+        * In backup mode the calling program runs continuously as long
+        * as either no peers are available or this peer is selected.
+        */
+       case MODE_BACKUP:
+               if (sys_peer == NULL || sys_peer == peer)
+                       pp->sloppyclockflag |= CLK_FLAG1;
+               break;
+       }
+}
+
+
+/*
+ * acts_timer - called at one-second intervals
+ */
+static void
+acts_timer(
+       int     unit,
+       struct peer *peer
+       )
+{
+       struct actsunit *up;
+       struct refclockproc *pp;
+
+       /*
+        * This routine implments a timeout which runs for a programmed
+        * interval. The counter is initialized by the state machine and
+        * counts down to zero. Upon reaching zero, the state machine is
+        * called. If flag1 is set while in S_IDLE state, force a
+        * timeout.
+        */
+       pp = peer->procptr;
+       up = (struct actsunit *)pp->unitptr;
+       if (pp->sloppyclockflag & CLK_FLAG1 && up->state == S_IDLE) {
+               acts_timeout(peer);
+               return;
+       }
+       if (up->timer == 0)
+               return;
+
+       up->timer--;
+       if (up->timer == 0)
+               acts_timeout(peer);
+}
+
+
+/*
+ * acts_timeout - called on timeout
+ */
+static void
+acts_timeout(
+       struct peer *peer
+       )
+{
+       struct actsunit *up;
+       struct refclockproc *pp;
+       int     fd;
+       char    device[20];
+       char    lockfile[128], pidbuf[8];
+       char    tbuf[BMAX];
+
+       /*
+        * The state machine is driven by messages from the modem, when
+        * first stated and at timeout.
+        */
+       pp = peer->procptr;
+       up = (struct actsunit *)pp->unitptr;
+       pp->sloppyclockflag &= ~CLK_FLAG1;
+       if (sys_phone[up->retry] == NULL && !(pp->sloppyclockflag &
+           CLK_FLAG3)) {
+               msyslog(LOG_ERR, "acts: no phones");
+               return;
+       }
+       switch(up->state) {
+
+       /*
+        * System poll event. Lock the modem port and open the device.
+        */
+       case S_IDLE:
+
+               /*
+                * Lock the modem port. If busy, retry later. Note: if
+                * something fails between here and the close, the lock
+                * file may not be removed.
+                */
+               if (pp->sloppyclockflag & CLK_FLAG2) {
+                       sprintf(lockfile, LOCKFILE, up->unit);
+                       fd = open(lockfile, O_WRONLY | O_CREAT | O_EXCL,
+                           0644);
+                       if (fd < 0) {
+                               msyslog(LOG_ERR, "acts: port busy");
+                               return;
+                       }
+                       sprintf(pidbuf, "%d\n", (u_int)getpid());
+                       write(fd, pidbuf, strlen(pidbuf));
+                       close(fd);
+               }
+
+               /*
+                * Open the device in raw mode and link the I/O.
+                */
+               if (!pp->io.fd) {
+                       sprintf(device, DEVICE, up->unit);
+                       fd = refclock_open(device, SPEED232,
+                           LDISC_ACTS | LDISC_RAW | LDISC_REMOTE);
+                       if (fd == 0) {
+                               return;
+                       }
+                       pp->io.fd = fd;
+                       if (!io_addclock(&pp->io)) {
+                               msyslog(LOG_ERR,
+                                   "acts: addclock fails");
+                               close(fd);
+                               pp->io.fd = 0;
+                               return;
+                       }
+               }
+
+               /*
+                * If the port is directly connected to the device, skip
+                * the modem business and send 'T' for Spectrabum.
+                */
+               if (pp->sloppyclockflag & CLK_FLAG3) {
+                       if (write(pp->io.fd, "T", 1) < 0) {
+                               msyslog(LOG_ERR, "acts: write %m");
+                               return;
+                       }
+                       up->state = S_FIRST;
+                       up->timer = CONNECT;
+                       return;
+               }
+
+               /*
+                * Initialize the modem. This works with Hayes commands.
+                */
+#ifdef DEBUG
+               if (debug)
+                       printf("acts: setup %s\n", MODEM_SETUP);
+#endif
+               if (write(pp->io.fd, MODEM_SETUP, strlen(MODEM_SETUP)) <
+                   0) {
+                       msyslog(LOG_ERR, "acts: write %m");
+                       return;
+               }
+               up->state = S_OK;
+               up->timer = SETUP;
+               return;
+
+       /*
+        * In OK state the modem did not respond to setup.
+        */
+       case S_OK:
+               msyslog(LOG_ERR, "acts: no modem");
+               break;
+
+       /*
+        * In DTR state we are waiting for the modem to settle down
+        * before hammering it with a dial command.
+        */
+       case S_DTR:
+               sprintf(tbuf, "DIAL #%d %s", up->retry,
+                   sys_phone[up->retry]);
+               record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+               if (debug)
+                       printf("%s\n", tbuf);
+#endif
+               write(pp->io.fd, sys_phone[up->retry],
+                   strlen(sys_phone[up->retry]));
+               write(pp->io.fd, "\r", 1);
+               up->state = S_CONNECT;
+               up->timer = ANSWER;
+               return;
+
+       /*
+        * In CONNECT state the call did not complete.
+        */
+       case S_CONNECT:
+               msyslog(LOG_ERR, "acts: no answer");
+               break;
+
+       /*
+        * In FIRST state no messages were received.
+        */
+       case S_FIRST:
+               msyslog(LOG_ERR, "acts: no messages");
+               break;
+
+       /*
+        * In CLOSE state hangup is complete. Close the doors and
+        * windows and get some air.
+        */
+       case S_CLOSE:
+
+               /*
+                * Close the device and unlock a shared modem.
+                */
+               if (pp->io.fd) {
+                       io_closeclock(&pp->io);
+                       close(pp->io.fd);
+                       if (pp->sloppyclockflag & CLK_FLAG2) {
+                               sprintf(lockfile, LOCKFILE, up->unit);
+                               unlink(lockfile);
+                       }
+                       pp->io.fd = 0;
+               }
+
+               /*
+                * If messages were received, fold the tent and wait for
+                * the next poll. If no messages and there are more
+                * numbers to dial, retry after a short wait.
+                */
+               up->bufptr = pp->a_lastcode;
+               up->timer = 0;
+               up->state = S_IDLE;
+               if ( up->msgcnt == 0) {
+                       up->retry++;
+                       if (sys_phone[up->retry] == NULL)
+                               up->retry = 0;
+                       else
+                               up->timer = SETUP;
+               } else {
+                       up->retry = 0;
+               }
+               up->msgcnt = 0;
+               return;
+       }
+       acts_disc(peer);
+}
+
+
+/*
+ * acts_disc - disconnect the call and clean the place up.
+ */
+static void
+acts_disc (
+       struct peer *peer
+       )
+{
+       struct actsunit *up;
+       struct refclockproc *pp;
+       int     dtr = TIOCM_DTR;
+
+       /*
+        * We get here if the call terminated successfully or if an
+        * error occured. If the median filter has something in it,feed
+        * the data to the clock filter. If a modem port, drop DTR to
+        * force command mode and send modem hangup.
+        */
+       pp = peer->procptr;
+       up = (struct actsunit *)pp->unitptr;
+       if (up->msgcnt > 0)
+               refclock_receive(peer);
+       if (!(pp->sloppyclockflag & CLK_FLAG3)) {
+               ioctl(pp->io.fd, TIOCMBIC, (char *)&dtr);
+               write(pp->io.fd, MODEM_HANGUP, strlen(MODEM_HANGUP));
+       }
+       up->timer = SETUP;
+       up->state = S_CLOSE;
+}
+
+#else
+int refclock_acts_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_arbiter.c b/ntpd/refclock_arbiter.c
new file mode 100644 (file)
index 0000000..88a3225
--- /dev/null
@@ -0,0 +1,453 @@
+/*
+ * refclock_arbiter - clock driver for Arbiter 1088A/B Satellite
+ *     Controlled Clock
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_ARBITER)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+/*
+ * This driver supports the Arbiter 1088A/B Satellite Controlled Clock.
+ * The claimed accuracy of this clock is 100 ns relative to the PPS
+ * output when receiving four or more satellites.
+ *
+ * The receiver should be configured before starting the NTP daemon, in
+ * order to establish reliable position and operating conditions. It
+ * does not initiate surveying or hold mode. For use with NTP, the
+ * daylight savings time feature should be disables (D0 command) and the
+ * broadcast mode set to operate in UTC (BU command).
+ *
+ * The timecode format supported by this driver is selected by the poll
+ * sequence "B5", which initiates a line in the following format to be
+ * repeated once per second until turned off by the "B0" poll sequence.
+ *
+ * Format B5 (24 ASCII printing characters):
+ *
+ * <cr><lf>i yy ddd hh:mm:ss.000bbb  
+ *
+ *     on-time = <cr>
+ *     i = synchronization flag (' ' = locked, '?' = unlocked)
+ *     yy = year of century
+ *     ddd = day of year
+ *     hh:mm:ss = hours, minutes, seconds
+ *     .000 = fraction of second (not used)
+ *     bbb = tailing spaces for fill
+ *
+ * The alarm condition is indicated by a '?' at i, which indicates the
+ * receiver is not synchronized. In normal operation, a line consisting
+ * of the timecode followed by the time quality character (TQ) followed
+ * by the receiver status string (SR) is written to the clockstats file.
+ * The time quality character is encoded in IEEE P1344 standard:
+ *
+ * Format TQ (IEEE P1344 estimated worst-case time quality)
+ *
+ *     0       clock locked, maximum accuracy
+ *     F       clock failure, time not reliable
+ *     4       clock unlocked, accuracy < 1 us
+ *     5       clock unlocked, accuracy < 10 us
+ *     6       clock unlocked, accuracy < 100 us
+ *     7       clock unlocked, accuracy < 1 ms
+ *     8       clock unlocked, accuracy < 10 ms
+ *     9       clock unlocked, accuracy < 100 ms
+ *     A       clock unlocked, accuracy < 1 s
+ *     B       clock unlocked, accuracy < 10 s
+ *
+ * The status string is encoded as follows:
+ *
+ * Format SR (25 ASCII printing characters)
+ *
+ *     V=vv S=ss T=t P=pdop E=ee
+ *
+ *     vv = satellites visible
+ *     ss = relative signal strength
+ *     t = satellites tracked
+ *     pdop = position dilution of precision (meters)
+ *     ee = hardware errors
+ *
+ * If flag4 is set, an additional line consisting of the receiver
+ * latitude (LA), longitude (LO), elevation (LH) (meters), and data
+ * buffer (DB) is written to this file. If channel B is enabled for
+ * deviation mode and connected to a 1-PPS signal, the last two numbers
+ * on the line are the deviation and standard deviation averaged over
+ * the last 15 seconds.
+ *
+ * PPS calibration fudge time1 .001240
+ */
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/gps%d" /* device name and unit */
+#define        SPEED232        B9600   /* uart speed (9600 baud) */
+#define        PRECISION       (-20)   /* precision assumed (about 1 us) */
+#define        REFID           "GPS "  /* reference ID */
+#define        DESCRIPTION     "Arbiter 1088A/B GPS Receiver" /* WRU */
+#define        LENARB          24      /* format B5 timecode length */
+#define MAXSTA         40      /* max length of status string */
+#define MAXPOS         80      /* max length of position string */
+
+/*
+ * ARB unit control structure
+ */
+struct arbunit {
+       l_fp    laststamp;      /* last receive timestamp */
+       int     tcswitch;       /* timecode switch/counter */
+       char    qualchar;       /* IEEE P1344 quality (TQ command) */
+       char    status[MAXSTA]; /* receiver status (SR command) */
+       char    latlon[MAXPOS]; /* receiver position (lat/lon/alt) */
+};
+
+/*
+ * Function prototypes
+ */
+static int     arb_start       P((int, struct peer *));
+static void    arb_shutdown    P((int, struct peer *));
+static void    arb_receive     P((struct recvbuf *));
+static void    arb_poll        P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_arbiter = {
+       arb_start,              /* start up driver */
+       arb_shutdown,           /* shut down driver */
+       arb_poll,               /* transmit poll message */
+       noentry,                /* not used (old arb_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old arb_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * arb_start - open the devices and initialize data for processing
+ */
+static int
+arb_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct arbunit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+
+       /*
+        * Open serial port. Use CLK line discipline, if available.
+        */
+       (void)sprintf(device, DEVICE, unit);
+       if (!(fd = refclock_open(device, SPEED232, LDISC_CLK)))
+               return (0);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct arbunit *)emalloc(sizeof(struct arbunit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct arbunit));
+       pp = peer->procptr;
+       pp->io.clock_recv = arb_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       write(pp->io.fd, "B0", 2);
+       return (1);
+}
+
+
+/*
+ * arb_shutdown - shut down the clock
+ */
+static void
+arb_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct arbunit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct arbunit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * arb_receive - receive data from the serial interface
+ */
+static void
+arb_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct arbunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       l_fp trtmp;
+       int temp;
+       u_char  syncchar;               /* synch indicator */
+       char    tbuf[BMAX];             /* temp buffer */
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct arbunit *)pp->unitptr;
+       temp = refclock_gtlin(rbufp, tbuf, BMAX, &trtmp);
+
+       /*
+        * Note we get a buffer and timestamp for both a <cr> and <lf>,
+        * but only the <cr> timestamp is retained. The program first
+        * sends a TQ and expects the echo followed by the time quality
+        * character. It then sends a B5 starting the timecode broadcast
+        * and expects the echo followed some time later by the on-time
+        * character <cr> and then the <lf> beginning the timecode
+        * itself. Finally, at the <cr> beginning the next timecode at
+        * the next second, the program sends a B0 shutting down the
+        * timecode broadcast.
+        *
+        * If flag4 is set, the program snatches the latitude, longitude
+        * and elevation and writes it to the clockstats file.
+        */
+       if (temp == 0)
+               return;
+
+       pp->lastrec = up->laststamp;
+       up->laststamp = trtmp;
+       if (temp < 3)
+               return;
+
+       if (up->tcswitch == 0) {
+
+               /*
+                * Collect statistics. If nothing is recogized, just
+                * ignore; sometimes the clock doesn't stop spewing
+                * timecodes for awhile after the B0 command.
+                *
+                * If flag4 is not set, send TQ, SR, B5. If flag4 is
+                * sset, send TQ, SR, LA, LO, LH, DB, B5. When the
+                * median filter is full, send B0.
+                */
+               if (!strncmp(tbuf, "TQ", 2)) {
+                       up->qualchar = tbuf[2];
+                       write(pp->io.fd, "SR", 2);
+                       return;
+
+               } else if (!strncmp(tbuf, "SR", 2)) {
+                       strcpy(up->status, tbuf + 2);
+                       if (pp->sloppyclockflag & CLK_FLAG4)
+                               write(pp->io.fd, "LA", 2);
+                       else
+                               write(pp->io.fd, "B5", 2);
+                       return;
+
+               } else if (!strncmp(tbuf, "LA", 2)) {
+                       strcpy(up->latlon, tbuf + 2);
+                       write(pp->io.fd, "LO", 2);
+                       return;
+
+               } else if (!strncmp(tbuf, "LO", 2)) {
+                       strcat(up->latlon, " ");
+                       strcat(up->latlon, tbuf + 2);
+                       write(pp->io.fd, "LH", 2);
+                       return;
+
+               } else if (!strncmp(tbuf, "LH", 2)) {
+                       strcat(up->latlon, " ");
+                       strcat(up->latlon, tbuf + 2);
+                       write(pp->io.fd, "DB", 2);
+                       return;
+
+               } else if (!strncmp(tbuf, "DB", 2)) {
+                       strcat(up->latlon, " ");
+                       strcat(up->latlon, tbuf + 2);
+                       record_clock_stats(&peer->srcadr, up->latlon);
+#ifdef DEBUG
+                       if (debug)
+                               printf("arbiter: %s\n", up->latlon);
+#endif
+                       write(pp->io.fd, "B5", 2);
+               }
+       }
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. If the timecode has valid length, but not in
+        * proper format, we declare bad format and exit. If the
+        * timecode has invalid length, which sometimes occurs when the
+        * B0 amputates the broadcast, we just quietly steal away. Note
+        * that the time quality character and receiver status string is
+        * tacked on the end for clockstats display. 
+        */
+       up->tcswitch++;
+       if (up->tcswitch <= 1 || temp < LENARB)
+               return;
+
+       /*
+        * Timecode format B5: "i yy ddd hh:mm:ss.000   "
+        */
+       strncpy(pp->a_lastcode, tbuf, BMAX);
+       pp->a_lastcode[LENARB - 2] = up->qualchar;
+       strcat(pp->a_lastcode, up->status);
+       pp->lencode = strlen(pp->a_lastcode);
+       syncchar = ' ';
+       if (sscanf(pp->a_lastcode, "%c%2d %3d %2d:%2d:%2d",
+           &syncchar, &pp->year, &pp->day, &pp->hour,
+           &pp->minute, &pp->second) != 6) {
+               refclock_report(peer, CEVNT_BADREPLY);
+               write(pp->io.fd, "B0", 2);
+               return;
+       }
+
+       /*
+        * We decode the clock dispersion from the time quality
+        * character.
+        */
+       switch (up->qualchar) {
+
+           case '0':           /* locked, max accuracy */
+               pp->disp = 1e-7;
+               pp->lastref = pp->lastrec;
+               break;
+
+           case '4':           /* unlock accuracy < 1 us */
+               pp->disp = 1e-6;
+               break;
+
+           case '5':           /* unlock accuracy < 10 us */
+               pp->disp = 1e-5;
+               break;
+
+           case '6':           /* unlock accuracy < 100 us */
+               pp->disp = 1e-4;
+               break;
+
+           case '7':           /* unlock accuracy < 1 ms */
+               pp->disp = .001;
+               break;
+
+           case '8':           /* unlock accuracy < 10 ms */
+               pp->disp = .01;
+               break;
+
+           case '9':           /* unlock accuracy < 100 ms */
+               pp->disp = .1;
+               break;
+
+           case 'A':           /* unlock accuracy < 1 s */
+               pp->disp = 1;
+               break;
+
+           case 'B':           /* unlock accuracy < 10 s */
+               pp->disp = 10;
+               break;
+
+           case 'F':           /* clock failure */
+               pp->disp = MAXDISPERSE;
+               refclock_report(peer, CEVNT_FAULT);
+               write(pp->io.fd, "B0", 2);
+               return;
+
+           default:
+               pp->disp = MAXDISPERSE;
+               refclock_report(peer, CEVNT_BADREPLY);
+               write(pp->io.fd, "B0", 2);
+               return;
+       }
+       if (syncchar != ' ')
+               pp->leap = LEAP_NOTINSYNC;
+       else
+               pp->leap = LEAP_NOWARNING;
+
+       /*
+        * Process the new sample in the median filter and determine the
+        * timecode timestamp.
+        */
+       if (!refclock_process(pp))
+               refclock_report(peer, CEVNT_BADTIME);
+       else if (peer->disp > MAXDISTANCE)
+               refclock_receive(peer);
+
+       if (up->tcswitch >= MAXSTAGE) {
+               write(pp->io.fd, "B0", 2);
+       }
+}
+
+
+/*
+ * arb_poll - called by the transmit procedure
+ */
+static void
+arb_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct arbunit *up;
+       struct refclockproc *pp;
+
+       /*
+        * Time to poll the clock. The Arbiter clock responds to a "B5"
+        * by returning a timecode in the format specified above.
+        * Transmission occurs once per second, unless turned off by a
+        * "B0". Note there is no checking on state, since this may not
+        * be the only customer reading the clock. Only one customer
+        * need poll the clock; all others just listen in.
+        */
+       pp = peer->procptr;
+       up = (struct arbunit *)pp->unitptr;
+       pp->polls++;
+       up->tcswitch = 0;
+       if (write(pp->io.fd, "TQ", 2) != 2)
+               refclock_report(peer, CEVNT_FAULT);
+
+       /*
+        * Process median filter samples. If none received, declare a
+        * timeout and keep going.
+        */
+       if (pp->coderecv == pp->codeproc) {
+               refclock_report(peer, CEVNT_TIMEOUT);
+               return;
+       }
+       refclock_receive(peer);
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+       if (debug)
+               printf("arbiter: timecode %d %s\n",
+                  pp->lencode, pp->a_lastcode);
+#endif
+}
+
+#else
+int refclock_arbiter_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_arc.c b/ntpd/refclock_arc.c
new file mode 100644 (file)
index 0000000..af80621
--- /dev/null
@@ -0,0 +1,1569 @@
+/*
+ * refclock_arc - clock driver for ARCRON MSF/DCF/WWVB receivers
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_ARCRON_MSF)
+
+static const char arc_version[] = { "V1.3 2003/02/21" };
+
+/* define PRE_NTP420 for compatibility to previous versions of NTP (at least
+   to 4.1.0 */
+#undef PRE_NTP420
+
+#ifndef ARCRON_NOT_KEEN
+#define ARCRON_KEEN 1 /* Be keen, and trusting of the clock, if defined. */
+#endif
+
+#ifndef ARCRON_NOT_MULTIPLE_SAMPLES
+#define ARCRON_MULTIPLE_SAMPLES 1 /* Use all timestamp bytes as samples. */
+#endif
+
+#ifndef ARCRON_NOT_LEAPSECOND_KEEN
+#ifndef ARCRON_LEAPSECOND_KEEN
+#undef ARCRON_LEAPSECOND_KEEN /* Respond quickly to leap seconds: doesn't work yet. */
+#endif
+#endif
+
+/*
+Code by Derek Mulcahy, <derek@toybox.demon.co.uk>, 1997.
+Modifications by Damon Hart-Davis, <d@hd.org>, 1997.
+Modifications by Paul Alfille, <palfille@partners.org>, 2003.
+Modifications by Christopher Price, <cprice@cs-home.com>, 2003.
+Modifications by Nigel Roles <nigel@9fs.org>, 2003.
+
+
+THIS CODE IS SUPPLIED AS IS, WITH NO WARRANTY OF ANY KIND.  USE AT
+YOUR OWN RISK.
+
+Orginally developed and used with ntp3-5.85 by Derek Mulcahy.
+
+Built against ntp3-5.90 on Solaris 2.5 using gcc 2.7.2.
+
+This code may be freely copied and used and incorporated in other
+systems providing the disclaimer and notice of authorship are
+reproduced.
+
+-------------------------------------------------------------------------------
+
+Nigel's notes:
+
+1) Called tcgetattr() before modifying, so that fields correctly initialised
+   for all operating systems
+
+2) Altered parsing of timestamp line so that it copes with fields which are
+   not always ASCII digits (e.g. status field when battery low)
+
+-------------------------------------------------------------------------------
+
+Christopher's notes:
+
+MAJOR CHANGES SINCE V1.2 
+========================
+ 1) Applied patch by Andrey Bray <abuse@madhouse.demon.co.uk>
+    2001-02-17 comp.protocols.time.ntp
+
+ 2) Added WWVB support via clock mode command, localtime/UTC time configured
+    via flag1=(0=UTC, 1=localtime)
+
+ 3) Added ignore resync request via flag2=(0=resync, 1=ignore resync)
+
+ 4) Added simplified conversion from localtime to UTC with dst/bst translation
+
+ 5) Added average signal quality poll
+
+ 6) Fixed a badformat error when no code is available due to stripping 
+    \n & \r's 
+
+ 7) Fixed a badformat error when clearing lencode & memset a_lastcode in poll
+    routine
+
+ 8) Lots of code cleanup, including standardized DEBUG macros and removal 
+    of unused code 
+
+-------------------------------------------------------------------------------
+
+Author's original note:
+
+I enclose my ntp driver for the Galleon Systems Arc MSF receiver.
+
+It works (after a fashion) on both Solaris-1 and Solaris-2.
+
+I am currently using ntp3-5.85.  I have been running the code for
+about 7 months without any problems.  Even coped with the change to BST!
+
+I had to do some funky things to read from the clock because it uses the
+power from the receive lines to drive the transmit lines.  This makes the
+code look a bit stupid but it works.  I also had to put in some delays to
+allow for the turnaround time from receive to transmit.  These delays
+are between characters when requesting a time stamp so that shouldn't affect
+the results too drastically.
+
+...
+
+The bottom line is that it works but could easily be improved.  You are
+free to do what you will with the code.  I haven't been able to determine
+how good the clock is.  I think that this requires a known good clock
+to compare it against.
+
+-------------------------------------------------------------------------------
+
+Damon's notes for adjustments:
+
+MAJOR CHANGES SINCE V1.0
+========================
+ 1) Removal of pollcnt variable that made the clock go permanently
+    off-line once two time polls failed to gain responses.
+
+ 2) Avoiding (at least on Solaris-2) terminal becoming the controlling
+    terminal of the process when we do a low-level open().
+
+ 3) Additional logic (conditional on ARCRON_LEAPSECOND_KEEN being
+    defined) to try to resync quickly after a potential leap-second
+    insertion or deletion.
+
+ 4) Code significantly slimmer at run-time than V1.0.
+
+
+GENERAL
+=======
+
+ 1) The C preprocessor symbol to have the clock built has been changed
+    from ARC to ARCRON_MSF to CLOCK_ARCRON_MSF to minimise the
+    possiblity of clashes with other symbols in the future.
+
+ 2) PRECISION should be -4/-5 (63ms/31ms) for the following reasons:
+
+     a) The ARC documentation claims the internal clock is (only)
+        accurate to about 20ms relative to Rugby (plus there must be
+        noticable drift and delay in the ms range due to transmission
+        delays and changing atmospheric effects).  This clock is not
+        designed for ms accuracy as NTP has spoilt us all to expect.
+
+     b) The clock oscillator looks like a simple uncompensated quartz
+        crystal of the sort used in digital watches (ie 32768Hz) which
+        can have large temperature coefficients and drifts; it is not
+        clear if this oscillator is properly disciplined to the MSF
+        transmission, but as the default is to resync only once per
+        *day*, we can imagine that it is not, and is free-running.  We
+        can minimise drift by resyncing more often (at the cost of
+        reduced battery life), but drift/wander may still be
+        significant.
+
+     c) Note that the bit time of 3.3ms adds to the potential error in
+        the the clock timestamp, since the bit clock of the serial link
+        may effectively be free-running with respect to the host clock
+        and the MSF clock.  Actually, the error is probably 1/16th of
+        the above, since the input data is probably sampled at at least
+        16x the bit rate.
+
+    By keeping the clock marked as not very precise, it will have a
+    fairly large dispersion, and thus will tend to be used as a
+    `backup' time source and sanity checker, which this clock is
+    probably ideal for.  For an isolated network without other time
+    sources, this clock can probably be expected to provide *much*
+    better than 1s accuracy, which will be fine.
+
+    By default, PRECISION is set to -4, but experience, especially at a
+    particular geographic location with a particular clock, may allow
+    this to be altered to -5.  (Note that skews of +/- 10ms are to be
+    expected from the clock from time-to-time.)  This improvement of
+    reported precision can be instigated by setting flag3 to 1, though
+    the PRECISION will revert to the normal value while the clock
+    signal quality is unknown whatever the flag3 setting.
+
+    IN ANY CASE, BE SURE TO SET AN APPROPRIATE FUDGE FACTOR TO REMOVE
+    ANY RESIDUAL SKEW, eg:
+
+        server 127.127.27.0 # ARCRON MSF radio clock unit 0.
+        # Fudge timestamps by about 20ms.
+        fudge 127.127.27.0 time1 0.020
+
+    You will need to observe your system's behaviour, assuming you have
+    some other NTP source to compare it with, to work out what the
+    fudge factor should be.  For my Sun SS1 running SunOS 4.1.3_U1 with
+    my MSF clock with my distance from the MSF transmitter, +20ms
+    seemed about right, after some observation.
+
+ 3) REFID has been made "MSFa" to reflect the MSF time source and the
+    ARCRON receiver.
+
+ 4) DEFAULT_RESYNC_TIME is the time in seconds (by default) before
+    forcing a resync since the last attempt.  This is picked to give a
+    little less than an hour between resyncs and to try to avoid
+    clashing with any regular event at a regular time-past-the-hour
+    which might cause systematic errors.
+
+    The INITIAL_RESYNC_DELAY is to avoid bothering the clock and
+    running down its batteries unnecesarily if ntpd is going to crash
+    or be killed or reconfigured quickly.  If ARCRON_KEEN is defined
+    then this period is long enough for (with normal polling rates)
+    enough time samples to have been taken to allow ntpd to sync to
+    the clock before the interruption for the clock to resync to MSF.
+    This avoids ntpd syncing to another peer first and then
+    almost immediately hopping to the MSF clock.
+
+    The RETRY_RESYNC_TIME is used before rescheduling a resync after a
+    resync failed to reveal a statisfatory signal quality (too low or
+    unknown).
+
+ 5) The clock seems quite jittery, so I have increased the
+    median-filter size from the typical (previous) value of 3.  I
+    discard up to half the results in the filter.  It looks like maybe
+    1 sample in 10 or so (maybe less) is a spike, so allow the median
+    filter to discard at least 10% of its entries or 1 entry, whichever
+    is greater.
+
+ 6) Sleeping *before* each character sent to the unit to allow required
+    inter-character time but without introducting jitter and delay in
+    handling the response if possible.
+
+ 7) If the flag ARCRON_KEEN is defined, take time samples whenever
+    possible, even while resyncing, etc.  We rely, in this case, on the
+    clock always giving us a reasonable time or else telling us in the
+    status byte at the end of the timestamp that it failed to sync to
+    MSF---thus we should never end up syncing to completely the wrong
+    time.
+
+ 8) If the flag ARCRON_OWN_FILTER is defined, use own versions of
+    refclock median-filter routines to get round small bug in 3-5.90
+    code which does not return the median offset. XXX Removed this
+    bit due NTP Version 4 upgrade - dlm.
+
+ 9) We would appear to have a year-2000 problem with this clock since
+    it returns only the two least-significant digits of the year.  But
+    ntpd ignores the year and uses the local-system year instead, so
+    this is in fact not a problem.  Nevertheless, we attempt to do a
+    sensible thing with the dates, wrapping them into a 100-year
+    window.
+
+ 10)Logs stats information that can be used by Derek's Tcl/Tk utility
+    to show the status of the clock.
+
+ 11)The clock documentation insists that the number of bits per
+    character to be sent to the clock, and sent by it, is 11, including
+    one start bit and two stop bits.  The data format is either 7+even
+    or 8+none.
+
+
+TO-DO LIST
+==========
+
+  * Eliminate use of scanf(), and maybe sprintf().
+
+  * Allow user setting of resync interval to trade battery life for
+    accuracy; maybe could be done via fudge factor or unit number.
+
+  * Possibly note the time since the last resync of the MSF clock to
+    MSF as the age of the last reference timestamp, ie trust the
+    clock's oscillator not very much...
+
+  * Add very slow auto-adjustment up to a value of +/- time2 to correct
+    for long-term errors in the clock value (time2 defaults to 0 so the
+    correction would be disabled by default).
+
+  * Consider trying to use the tty_clk/ppsclock support.
+
+  * Possibly use average or maximum signal quality reported during
+    resync, rather than just the last one, which may be atypical.
+
+*/
+
+
+/* Notes for HKW Elektronik GmBH Radio clock driver */
+/* Author Lyndon David, Sentinet Ltd, Feb 1997      */
+/* These notes seem also to apply usefully to the ARCRON clock. */
+
+/* The HKW clock module is a radio receiver tuned into the Rugby */
+/* MSF time signal tranmitted on 60 kHz. The clock module connects */
+/* to the computer via a serial line and transmits the time encoded */
+/* in 15 bytes at 300 baud 7 bits two stop bits even parity */
+
+/* Clock communications, from the datasheet */
+/* All characters sent to the clock are echoed back to the controlling */
+/* device. */
+/* Transmit time/date information */
+/* syntax ASCII o<cr> */
+/* Character o may be replaced if neccesary by a character whose code */
+/* contains the lowest four bits f(hex) eg */
+/* syntax binary: xxxx1111 00001101 */
+
+/* DHD note:
+You have to wait for character echo + 10ms before sending next character.
+*/
+
+/* The clock replies to this command with a sequence of 15 characters */
+/* which contain the complete time and a final <cr> making 16 characters */
+/* in total. */
+/* The RC computer clock will not reply immediately to this command because */
+/* the start bit edge of the first reply character marks the beginning of */
+/* the second. So the RC Computer Clock will reply to this command at the */
+/* start of the next second */
+/* The characters have the following meaning */
+/* 1. hours tens   */
+/* 2. hours units  */
+/* 3. minutes tens */
+/* 4. minutes units */
+/* 5. seconds tens  */
+/* 6. seconds units */
+/* 7. day of week 1-monday 7-sunday */
+/* 8. day of month tens */
+/* 9. day of month units */
+/* 10. month tens */
+/* 11. month units */
+/* 12. year tens */
+/* 13. year units */
+/* 14. BST/UTC status */
+/*      bit 7   parity */
+/*      bit 6   always 0 */
+/*      bit 5   always 1 */
+/*      bit 4   always 1 */
+/*      bit 3   always 0 */
+/*      bit 2   =1 if UTC is in effect, complementary to the BST bit */
+/*      bit 1   =1 if BST is in effect, according to the BST bit     */
+/*      bit 0   BST/UTC change impending bit=1 in case of change impending */
+/* 15. status */
+/*      bit 7   parity */
+/*      bit 6   always 0 */
+/*      bit 5   always 1 */
+/*      bit 4   always 1 */
+/*      bit 3   =1 if low battery is detected */
+/*      bit 2   =1 if the very last reception attempt failed and a valid */
+/*              time information already exists (bit0=1) */
+/*              =0 if the last reception attempt was successful */
+/*      bit 1   =1 if at least one reception since 2:30 am was successful */
+/*              =0 if no reception attempt since 2:30 am was successful */
+/*      bit 0   =1 if the RC Computer Clock contains valid time information */
+/*              This bit is zero after reset and one after the first */
+/*              successful reception attempt */
+
+/* DHD note:
+Also note g<cr> command which confirms that a resync is in progress, and
+if so what signal quality (0--5) is available.
+Also note h<cr> command which starts a resync to MSF signal.
+*/
+
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#if defined(HAVE_BSD_TTYS)
+#include <sgtty.h>
+#endif /* HAVE_BSD_TTYS */
+
+#if defined(HAVE_SYSV_TTYS)
+#include <termio.h>
+#endif /* HAVE_SYSV_TTYS */
+
+#if defined(HAVE_TERMIOS)
+#include <termios.h>
+#endif
+
+/*
+ * This driver supports the ARCRON MSF/DCF/WWVB Radio Controlled Clock
+ */
+
+/*
+ * Interface definitions
+ */
+#define DEVICE          "/dev/arc%d"    /* Device name and unit. */
+#define SPEED           B300            /* UART speed (300 baud) */
+#define PRECISION       (-4)            /* Precision  (~63 ms). */
+#define HIGHPRECISION   (-5)            /* If things are going well... */
+#define REFID           "MSFa"          /* Reference ID. */
+#define REFID_MSF       "MSF"           /* Reference ID. */
+#define REFID_DCF77     "DCF"           /* Reference ID. */
+#define REFID_WWVB      "WWVB"          /* Reference ID. */
+#define DESCRIPTION     "ARCRON MSF/DCF/WWVB Receiver"
+
+#ifdef PRE_NTP420
+#define MODE ttlmax
+#else
+#define MODE ttl
+#endif
+
+#define LENARC          16              /* Format `o' timecode length. */
+
+#define BITSPERCHAR     11              /* Bits per character. */
+#define BITTIME         0x0DA740E       /* Time for 1 bit at 300bps. */
+#define CHARTIME10      0x8888888       /* Time for 10-bit char at 300bps. */
+#define CHARTIME11      0x962FC96       /* Time for 11-bit char at 300bps. */
+#define CHARTIME                        /* Time for char at 300bps. */ \
+( (BITSPERCHAR == 11) ? CHARTIME11 : ( (BITSPERCHAR == 10) ? CHARTIME10 : \
+                                      (BITSPERCHAR * BITTIME) ) )
+
+     /* Allow for UART to accept char half-way through final stop bit. */
+#define INITIALOFFSET (u_int32)(-BITTIME/2)
+
+     /*
+    charoffsets[x] is the time after the start of the second that byte
+    x (with the first byte being byte 1) is received by the UART,
+    assuming that the initial edge of the start bit of the first byte
+    is on-time.  The values are represented as the fractional part of
+    an l_fp.
+
+    We store enough values to have the offset of each byte including
+    the trailing \r, on the assumption that the bytes follow one
+    another without gaps.
+    */
+     static const u_int32 charoffsets[LENARC+1] = {
+#if BITSPERCHAR == 11 /* Usual case. */
+            /* Offsets computed as accurately as possible... */
+            0,
+            INITIALOFFSET + 0x0962fc96, /*  1 chars,  11 bits */
+            INITIALOFFSET + 0x12c5f92c, /*  2 chars,  22 bits */
+            INITIALOFFSET + 0x1c28f5c3, /*  3 chars,  33 bits */
+            INITIALOFFSET + 0x258bf259, /*  4 chars,  44 bits */
+            INITIALOFFSET + 0x2eeeeeef, /*  5 chars,  55 bits */
+            INITIALOFFSET + 0x3851eb85, /*  6 chars,  66 bits */
+            INITIALOFFSET + 0x41b4e81b, /*  7 chars,  77 bits */
+            INITIALOFFSET + 0x4b17e4b1, /*  8 chars,  88 bits */
+            INITIALOFFSET + 0x547ae148, /*  9 chars,  99 bits */
+            INITIALOFFSET + 0x5dddddde, /* 10 chars, 110 bits */
+            INITIALOFFSET + 0x6740da74, /* 11 chars, 121 bits */
+            INITIALOFFSET + 0x70a3d70a, /* 12 chars, 132 bits */
+            INITIALOFFSET + 0x7a06d3a0, /* 13 chars, 143 bits */
+            INITIALOFFSET + 0x8369d037, /* 14 chars, 154 bits */
+            INITIALOFFSET + 0x8ccccccd, /* 15 chars, 165 bits */
+            INITIALOFFSET + 0x962fc963  /* 16 chars, 176 bits */
+#else
+            /* Offsets computed with a small rounding error... */
+            0,
+            INITIALOFFSET +  1 * CHARTIME,
+            INITIALOFFSET +  2 * CHARTIME,
+            INITIALOFFSET +  3 * CHARTIME,
+            INITIALOFFSET +  4 * CHARTIME,
+            INITIALOFFSET +  5 * CHARTIME,
+            INITIALOFFSET +  6 * CHARTIME,
+            INITIALOFFSET +  7 * CHARTIME,
+            INITIALOFFSET +  8 * CHARTIME,
+            INITIALOFFSET +  9 * CHARTIME,
+            INITIALOFFSET + 10 * CHARTIME,
+            INITIALOFFSET + 11 * CHARTIME,
+            INITIALOFFSET + 12 * CHARTIME,
+            INITIALOFFSET + 13 * CHARTIME,
+            INITIALOFFSET + 14 * CHARTIME,
+            INITIALOFFSET + 15 * CHARTIME,
+            INITIALOFFSET + 16 * CHARTIME
+#endif
+     };
+
+#define DEFAULT_RESYNC_TIME  (57*60)    /* Gap between resync attempts (s). */
+#define RETRY_RESYNC_TIME    (27*60)    /* Gap to emergency resync attempt. */
+#ifdef ARCRON_KEEN
+#define INITIAL_RESYNC_DELAY 500        /* Delay before first resync. */
+#else
+#define INITIAL_RESYNC_DELAY 50         /* Delay before first resync. */
+#endif
+
+     static const int moff[12] =
+{ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 };
+/* Flags for a raw open() of the clock serial device. */
+#ifdef O_NOCTTY /* Good, we can avoid tty becoming controlling tty. */
+#define OPEN_FLAGS (O_RDWR | O_NOCTTY)
+#else           /* Oh well, it may not matter... */
+#define OPEN_FLAGS (O_RDWR)
+#endif
+
+
+/* Length of queue of command bytes to be sent. */
+#define CMDQUEUELEN 4                   /* Enough for two cmds + each \r. */
+/* Queue tick time; interval in seconds between chars taken off queue. */
+/* Must be >= 2 to allow o\r response to come back uninterrupted. */
+#define QUEUETICK   2                   /* Allow o\r reply to finish. */
+
+/*
+ * ARC unit control structure
+ */
+struct arcunit {
+       l_fp lastrec;       /* Time tag for the receive time (system). */
+       int status;         /* Clock status. */
+
+       int quality;        /* Quality of reception 0--5 for unit. */
+       /* We may also use the values -1 or 6 internally. */
+       u_long quality_stamp; /* Next time to reset quality average. */
+
+       u_long next_resync; /* Next resync time (s) compared to current_time. */
+       int resyncing;      /* Resync in progress if true. */
+
+       /* In the outgoing queue, cmdqueue[0] is next to be sent. */
+       char cmdqueue[CMDQUEUELEN+1]; /* Queue of outgoing commands + \0. */
+
+       u_long saved_flags; /* Saved fudge flags. */
+};
+
+#ifdef ARCRON_LEAPSECOND_KEEN
+/* The flag `possible_leap' is set non-zero when any MSF unit
+       thinks a leap-second may have happened.
+
+       Set whenever we receive a valid time sample in the first hour of
+       the first day of the first/seventh months.
+
+       Outside the special hour this value is unconditionally set
+       to zero by the receive routine.
+
+       On finding itself in this timeslot, as long as the value is
+       non-negative, the receive routine sets it to a positive value to
+       indicate a resync to MSF should be performed.
+
+       In the poll routine, if this value is positive and we are not
+       already resyncing (eg from a sync that started just before
+       midnight), start resyncing and set this value negative to
+       indicate that a leap-triggered resync has been started.  Having
+       set this negative prevents the receive routine setting it
+       positive and thus prevents multiple resyncs during the witching
+       hour.
+     */
+static int possible_leap = 0;       /* No resync required by default. */
+#endif
+
+#if 0
+static void dummy_event_handler P((struct peer *));
+static void   arc_event_handler P((struct peer *));
+#endif /* 0 */
+
+#define QUALITY_UNKNOWN     -1 /* Indicates unknown clock quality. */
+#define MIN_CLOCK_QUALITY    0 /* Min quality clock will return. */
+#define MIN_CLOCK_QUALITY_OK 3 /* Min quality for OK reception. */
+#define MAX_CLOCK_QUALITY    5 /* Max quality clock will return. */
+
+/*
+ * Function prototypes
+ */
+static  int     arc_start       P((int, struct peer *));
+static  void    arc_shutdown    P((int, struct peer *));
+static  void    arc_receive     P((struct recvbuf *));
+static  void    arc_poll        P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct  refclock refclock_arc = {
+       arc_start,              /* start up driver */
+       arc_shutdown,           /* shut down driver */
+       arc_poll,               /* transmit poll message */
+       noentry,                /* not used (old arc_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old arc_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+/* Queue us up for the next tick. */
+#define ENQUEUE(up) \
+       do { \
+            peer->nextaction = current_time + QUEUETICK; \
+       } while(0)
+
+/* Placeholder event handler---does nothing safely---soaks up loose tick. */
+static void
+dummy_event_handler(
+       struct peer *peer
+       )
+{
+#ifdef DEBUG
+       if(debug) { printf("arc: dummy_event_handler() called.\n"); }
+#endif
+}
+
+/*
+Normal event handler.
+
+Take first character off queue and send to clock if not a null.
+
+Shift characters down and put a null on the end.
+
+We assume that there is no parallelism so no race condition, but even
+if there is nothing bad will happen except that we might send some bad
+data to the clock once in a while.
+*/
+static void
+arc_event_handler(
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp = peer->procptr;
+       register struct arcunit *up = (struct arcunit *)pp->unitptr;
+       int i;
+       char c;
+#ifdef DEBUG
+       if(debug > 2) { printf("arc: arc_event_handler() called.\n"); }
+#endif
+
+       c = up->cmdqueue[0];       /* Next char to be sent. */
+       /* Shift down characters, shifting trailing \0 in at end. */
+       for(i = 0; i < CMDQUEUELEN; ++i)
+       { up->cmdqueue[i] = up->cmdqueue[i+1]; }
+
+       /* Don't send '\0' characters. */
+       if(c != '\0') {
+               if(write(pp->io.fd, &c, 1) != 1) {
+                       msyslog(LOG_NOTICE, "ARCRON: write to fd %d failed", pp->io.fd);
+               }
+#ifdef DEBUG
+               else if(debug) { printf("arc: sent `%2.2x', fd %d.\n", c, pp->io.fd); }
+#endif
+       }
+
+       ENQUEUE(up);
+}
+
+/*
+ * arc_start - open the devices and initialize data for processing
+ */
+static int
+arc_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct arcunit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+#ifdef HAVE_TERMIOS
+       struct termios arg;
+#endif
+
+       msyslog(LOG_NOTICE, "ARCRON: %s: opening unit %d", arc_version, unit);
+#ifdef DEBUG
+       if(debug) {
+               printf("arc: %s: attempt to open unit %d.\n", arc_version, unit);
+       }
+#endif
+
+       /* Prevent a ridiculous device number causing overflow of device[]. */
+       if((unit < 0) || (unit > 255)) { return(0); }
+
+       /*
+        * Open serial port. Use CLK line discipline, if available.
+        */
+       (void)sprintf(device, DEVICE, unit);
+       if (!(fd = refclock_open(device, SPEED, LDISC_CLK)))
+               return(0);
+#ifdef DEBUG
+       if(debug) { printf("arc: unit %d using open().\n", unit); }
+#endif
+       fd = open(device, OPEN_FLAGS);
+       if(fd < 0) {
+#ifdef DEBUG
+               if(debug) { printf("arc: failed [open()] to open %s.\n", device); }
+#endif
+               return(0);
+       }
+
+       fcntl(fd, F_SETFL, 0); /* clear the descriptor flags */
+#ifdef DEBUG
+       if(debug)
+       { printf("arc: opened RS232 port with file descriptor %d.\n", fd); }
+#endif
+
+#ifdef HAVE_TERMIOS
+
+       tcgetattr(fd, &arg);
+
+       arg.c_iflag = IGNBRK | ISTRIP;
+       arg.c_oflag = 0;
+       arg.c_cflag = B300 | CS8 | CREAD | CLOCAL | CSTOPB;
+       arg.c_lflag = 0;
+       arg.c_cc[VMIN] = 1;
+       arg.c_cc[VTIME] = 0;
+
+       tcsetattr(fd, TCSANOW, &arg);
+
+#else
+
+       msyslog(LOG_ERR, "ARCRON: termios not supported in this driver");
+       (void)close(fd);
+
+       return 0;
+
+#endif
+
+       up = (struct arcunit *) emalloc(sizeof(struct arcunit));
+       if(!up) { (void) close(fd); return(0); }
+       /* Set structure to all zeros... */
+       memset((char *)up, 0, sizeof(struct arcunit));
+       pp = peer->procptr;
+       pp->io.clock_recv = arc_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if(!io_addclock(&pp->io)) { (void) close(fd); free(up); return(0); }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       peer->stratum = 2;              /* Default to stratum 2 not 0. */
+       pp->clockdesc = DESCRIPTION;
+       if (peer->MODE > 3) {
+               msyslog(LOG_NOTICE, "ARCRON: Invalid mode %d", peer->MODE);
+               return 0;
+       }
+#ifdef DEBUG
+       if(debug) { printf("arc: mode = %d.\n", peer->MODE); }
+#endif
+       switch (peer->MODE) {
+           case 1:
+               memcpy((char *)&pp->refid, REFID_MSF, 4);
+               break;
+           case 2:
+               memcpy((char *)&pp->refid, REFID_DCF77, 4);
+               break;
+           case 3:
+               memcpy((char *)&pp->refid, REFID_WWVB, 4);
+               break;
+           default:
+               memcpy((char *)&pp->refid, REFID, 4);
+               break;
+       }
+       /* Spread out resyncs so that they should remain separated. */
+       up->next_resync = current_time + INITIAL_RESYNC_DELAY + (67*unit)%1009;
+
+#if 0 /* Not needed because of zeroing of arcunit structure... */
+       up->resyncing = 0;              /* Not resyncing yet. */
+       up->saved_flags = 0;            /* Default is all flags off. */
+       /* Clear send buffer out... */
+       {
+               int i;
+               for(i = CMDQUEUELEN; i >= 0; --i) { up->cmdqueue[i] = '\0'; }
+       }
+#endif
+
+#ifdef ARCRON_KEEN
+       up->quality = QUALITY_UNKNOWN;  /* Trust the clock immediately. */
+#else
+       up->quality = MIN_CLOCK_QUALITY;/* Don't trust the clock yet. */
+#endif
+
+       peer->action = arc_event_handler;
+
+       ENQUEUE(up);
+
+       return(1);
+}
+
+
+/*
+ * arc_shutdown - shut down the clock
+ */
+static void
+arc_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct arcunit *up;
+       struct refclockproc *pp;
+
+       peer->action = dummy_event_handler;
+
+       pp = peer->procptr;
+       up = (struct arcunit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+/*
+Compute space left in output buffer.
+*/
+static int
+space_left(
+       register struct arcunit *up
+       )
+{
+       int spaceleft;
+
+       /* Compute space left in buffer after any pending output. */
+       for(spaceleft = 0; spaceleft < CMDQUEUELEN; ++spaceleft)
+       { if(up->cmdqueue[CMDQUEUELEN - 1 - spaceleft] != '\0') { break; } }
+       return(spaceleft);
+}
+
+/*
+Send command by copying into command buffer as far forward as possible,
+after any pending output.
+
+Indicate an error by returning 0 if there is not space for the command.
+*/
+static int
+send_slow(
+       register struct arcunit *up,
+       int fd,
+       const char *s
+       )
+{
+       int sl = strlen(s);
+       int spaceleft = space_left(up);
+
+#ifdef DEBUG
+       if(debug > 1) { printf("arc: spaceleft = %d.\n", spaceleft); }
+#endif
+       if(spaceleft < sl) { /* Should not normally happen... */
+#ifdef DEBUG
+               msyslog(LOG_NOTICE, "ARCRON: send-buffer overrun (%d/%d)",
+                      sl, spaceleft);
+#endif
+               return(0);                      /* FAILED! */
+       }
+
+       /* Copy in the command to be sent. */
+       while(*s && spaceleft > 0) { up->cmdqueue[CMDQUEUELEN - spaceleft--] = *s++; }
+
+       return(1);
+}
+
+
+static int
+get2(char *p, int *val)
+{
+  if (!isdigit((int)p[0]) || !isdigit((int)p[1])) return 0;
+  *val = (p[0] - '0') * 10 + p[1] - '0';
+  return 1;
+}
+
+static int
+get1(char *p, int *val)
+{
+  if (!isdigit((int)p[0])) return 0;
+  *val = p[0] - '0';
+  return 1;
+}
+
+/* Macro indicating action we will take for different quality values. */
+#define quality_action(q) \
+(((q) == QUALITY_UNKNOWN) ?         "UNKNOWN, will use clock anyway" : \
+ (((q) < MIN_CLOCK_QUALITY_OK) ? "TOO POOR, will not use clock" : \
+  "OK, will use clock"))
+
+     /*
+ * arc_receive - receive data from the serial interface
+ */
+     static void
+arc_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct arcunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       char c;
+       int i, n, wday, month, flags, status;
+       int arc_last_offset;
+       static int quality_average = 0;
+       static int quality_sum = 0;
+       static int quality_polls = 0;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct arcunit *)pp->unitptr;
+
+
+       /*
+         If the command buffer is empty, and we are resyncing, insert a
+         g\r quality request into it to poll for signal quality again.
+       */
+       if((up->resyncing) && (space_left(up) == CMDQUEUELEN)) {
+#ifdef DEBUG
+               if(debug > 1) { printf("arc: inserting signal-quality poll.\n"); }
+#endif
+               send_slow(up, pp->io.fd, "g\r");
+       }
+
+       /*
+         The `arc_last_offset' is the offset in lastcode[] of the last byte
+         received, and which we assume actually received the input
+         timestamp.
+
+         (When we get round to using tty_clk and it is available, we
+         assume that we will receive the whole timecode with the
+         trailing \r, and that that \r will be timestamped.  But this
+         assumption also works if receive the characters one-by-one.)
+       */
+       arc_last_offset = pp->lencode+rbufp->recv_length - 1;
+
+       /*
+         We catch a timestamp iff:
+
+         * The command code is `o' for a timestamp.
+
+         * If ARCRON_MULTIPLE_SAMPLES is undefined then we must have
+         exactly char in the buffer (the command code) so that we
+         only sample the first character of the timecode as our
+         `on-time' character.
+
+         * The first character in the buffer is not the echoed `\r'
+         from the `o` command (so if we are to timestamp an `\r' it
+         must not be first in the receive buffer with lencode==1.
+         (Even if we had other characters following it, we probably
+         would have a premature timestamp on the '\r'.)
+
+         * We have received at least one character (I cannot imagine
+         how it could be otherwise, but anyway...).
+       */
+       c = rbufp->recv_buffer[0];
+       if((pp->a_lastcode[0] == 'o') &&
+#ifndef ARCRON_MULTIPLE_SAMPLES
+          (pp->lencode == 1) &&
+#endif
+          ((pp->lencode != 1) || (c != '\r')) &&
+          (arc_last_offset >= 1)) {
+               /* Note that the timestamp should be corrected if >1 char rcvd. */
+               l_fp timestamp;
+               timestamp = rbufp->recv_time;
+#ifdef DEBUG
+               if(debug) { /* Show \r as `R', other non-printing char as `?'. */
+                       printf("arc: stamp -->%c<-- (%d chars rcvd)\n",
+                              ((c == '\r') ? 'R' : (isgraph((int)c) ? c : '?')),
+                              rbufp->recv_length);
+               }
+#endif
+
+               /*
+                 Now correct timestamp by offset of last byte received---we
+                 subtract from the receive time the delay implied by the
+                 extra characters received.
+
+                 Reject the input if the resulting code is too long, but
+                 allow for the trailing \r, normally not used but a good
+                 handle for tty_clk or somesuch kernel timestamper.
+               */
+               if(arc_last_offset > LENARC) {
+#ifdef DEBUG
+                       if(debug) {
+                               printf("arc: input code too long (%d cf %d); rejected.\n",
+                                      arc_last_offset, LENARC);
+                       }
+#endif
+                       pp->lencode = 0;
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+
+               L_SUBUF(&timestamp, charoffsets[arc_last_offset]);
+#ifdef DEBUG
+               if(debug > 1) {
+                       printf(
+                               "arc: %s%d char(s) rcvd, the last for lastcode[%d]; -%sms offset applied.\n",
+                               ((rbufp->recv_length > 1) ? "*** " : ""),
+                               rbufp->recv_length,
+                               arc_last_offset,
+                               mfptoms((unsigned long)0,
+                                       charoffsets[arc_last_offset],
+                                       1));
+               }
+#endif
+
+#ifdef ARCRON_MULTIPLE_SAMPLES
+               /*
+                 If taking multiple samples, capture the current adjusted
+                 sample iff:
+
+                 * No timestamp has yet been captured (it is zero), OR
+
+                 * This adjusted timestamp is earlier than the one already
+                 captured, on the grounds that this one suffered less
+                 delay in being delivered to us and is more accurate.
+
+               */
+               if(L_ISZERO(&(up->lastrec)) ||
+                  L_ISGEQ(&(up->lastrec), &timestamp))
+#endif
+               {
+#ifdef DEBUG
+                       if(debug > 1) {
+                               printf("arc: system timestamp captured.\n");
+#ifdef ARCRON_MULTIPLE_SAMPLES
+                               if(!L_ISZERO(&(up->lastrec))) {
+                                       l_fp diff;
+                                       diff = up->lastrec;
+                                       L_SUB(&diff, &timestamp);
+                                       printf("arc: adjusted timestamp by -%sms.\n",
+                                              mfptoms(diff.l_i, diff.l_f, 3));
+                               }
+#endif
+                       }
+#endif
+                       up->lastrec = timestamp;
+               }
+
+       }
+
+       /* Just in case we still have lots of rubbish in the buffer... */
+       /* ...and to avoid the same timestamp being reused by mistake, */
+       /* eg on receipt of the \r coming in on its own after the      */
+       /* timecode.                                                   */
+       if(pp->lencode >= LENARC) {
+#ifdef DEBUG
+               if(debug && (rbufp->recv_buffer[0] != '\r'))
+               { printf("arc: rubbish in pp->a_lastcode[].\n"); }
+#endif
+               pp->lencode = 0;
+               return;
+       }
+
+       /* Append input to code buffer, avoiding overflow. */
+       for(i = 0; i < rbufp->recv_length; i++) {
+               if(pp->lencode >= LENARC) { break; } /* Avoid overflow... */
+               c = rbufp->recv_buffer[i];
+
+               /* Drop trailing '\r's and drop `h' command echo totally. */
+               if(c != '\r' && c != 'h') { pp->a_lastcode[pp->lencode++] = c; }
+
+               /*
+                 If we've just put an `o' in the lastcode[0], clear the
+                 timestamp in anticipation of a timecode arriving soon.
+
+                 We would expect to get to process this before any of the
+                 timecode arrives.
+               */
+               if((c == 'o') && (pp->lencode == 1)) {
+                       L_CLR(&(up->lastrec));
+#ifdef DEBUG
+                       if(debug > 1) { printf("arc: clearing timestamp.\n"); }
+#endif
+               }
+       }
+       if (pp->lencode == 0) return;
+
+       /* Handle a quality message. */
+       if(pp->a_lastcode[0] == 'g') {
+               int r, q;
+
+               if(pp->lencode < 3) { return; } /* Need more data... */
+               r = (pp->a_lastcode[1] & 0x7f); /* Strip parity. */
+               q = (pp->a_lastcode[2] & 0x7f); /* Strip parity. */
+               if(((q & 0x70) != 0x30) || ((q & 0xf) > MAX_CLOCK_QUALITY) ||
+                  ((r & 0x70) != 0x30)) {
+                       /* Badly formatted response. */
+#ifdef DEBUG
+                       if(debug) { printf("arc: bad `g' response %2x %2x.\n", r, q); }
+#endif
+                       return;
+               }
+               if(r == '3') { /* Only use quality value whilst sync in progress. */
+                       if (up->quality_stamp < current_time) {
+                               struct calendar cal;
+                               l_fp new_stamp;
+                       
+                               get_systime (&new_stamp);
+                               caljulian (new_stamp.l_ui, &cal);
+                               up->quality_stamp = 
+                                       current_time + 60 - cal.second + 5;
+                               quality_sum = 0;
+                               quality_polls = 0;
+                       }
+                       quality_sum += (q & 0xf);
+                       quality_polls++;
+                       quality_average = (quality_sum / quality_polls);
+#ifdef DEBUG
+                       if(debug) { printf("arc: signal quality %d (%d).\n", quality_average, (q & 0xf)); }
+#endif
+               } else if( /* (r == '2') && */ up->resyncing) {
+                       up->quality = quality_average;
+#ifdef DEBUG
+                       if(debug)
+                       {
+                               printf("arc: sync finished, signal quality %d: %s\n",
+                                      up->quality,
+                                      quality_action(up->quality));
+                       }
+#endif
+                       msyslog(LOG_NOTICE,
+                              "ARCRON: sync finished, signal quality %d: %s",
+                              up->quality,
+                              quality_action(up->quality));
+                       up->resyncing = 0; /* Resync is over. */
+                       quality_average = 0;
+                       quality_sum = 0;
+                       quality_polls = 0;
+
+#ifdef ARCRON_KEEN
+                       /* Clock quality dubious; resync earlier than usual. */
+                       if((up->quality == QUALITY_UNKNOWN) ||
+                          (up->quality < MIN_CLOCK_QUALITY_OK))
+                       { up->next_resync = current_time + RETRY_RESYNC_TIME; }
+#endif
+               }
+               pp->lencode = 0;
+               return;
+       }
+
+       /* Stop now if this is not a timecode message. */
+       if(pp->a_lastcode[0] != 'o') {
+               pp->lencode = 0;
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       /* If we don't have enough data, wait for more... */
+       if(pp->lencode < LENARC) { return; }
+
+
+       /* WE HAVE NOW COLLECTED ONE TIMESTAMP (phew)... */
+#ifdef DEBUG
+       if(debug > 1) { printf("arc: NOW HAVE TIMESTAMP...\n"); }
+#endif
+
+       /* But check that we actually captured a system timestamp on it. */
+       if(L_ISZERO(&(up->lastrec))) {
+#ifdef DEBUG
+               if(debug) { printf("arc: FAILED TO GET SYSTEM TIMESTAMP\n"); }
+#endif
+               pp->lencode = 0;
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+       /*
+         Append a mark of the clock's received signal quality for the
+         benefit of Derek Mulcahy's Tcl/Tk utility (we map the `unknown'
+         quality value to `6' for his s/w) and terminate the string for
+         sure.  This should not go off the buffer end.
+       */
+       pp->a_lastcode[pp->lencode] = ((up->quality == QUALITY_UNKNOWN) ?
+                                      '6' : ('0' + up->quality));
+       pp->a_lastcode[pp->lencode + 1] = '\0'; /* Terminate for printf(). */
+
+#ifdef PRE_NTP420
+       /* We don't use the micro-/milli- second part... */
+       pp->usec = 0;
+       pp->msec = 0;
+#else
+       /* We don't use the nano-second part... */
+       pp->nsec = 0;
+#endif 
+       /* Validate format and numbers. */
+       if (pp->a_lastcode[0] != 'o'
+               || !get2(pp->a_lastcode + 1, &pp->hour)
+               || !get2(pp->a_lastcode + 3, &pp->minute)
+               || !get2(pp->a_lastcode + 5, &pp->second)
+               || !get1(pp->a_lastcode + 7, &wday)
+               || !get2(pp->a_lastcode + 8, &pp->day)
+               || !get2(pp->a_lastcode + 10, &month)
+               || !get2(pp->a_lastcode + 12, &pp->year)) {
+#ifdef DEBUG
+               /* Would expect to have caught major problems already... */
+               if(debug) { printf("arc: badly formatted data.\n"); }
+#endif
+               pp->lencode = 0;
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+       flags = pp->a_lastcode[14];
+       status = pp->a_lastcode[15];
+#ifdef DEBUG
+       if(debug) { printf("arc: status 0x%.2x flags 0x%.2x\n", flags, status); }
+#endif
+       n = 9;
+
+       /*
+         Validate received values at least enough to prevent internal
+         array-bounds problems, etc.
+       */
+       if((pp->hour < 0) || (pp->hour > 23) ||
+          (pp->minute < 0) || (pp->minute > 59) ||
+          (pp->second < 0) || (pp->second > 60) /*Allow for leap seconds.*/ ||
+          (wday < 1) || (wday > 7) ||
+          (pp->day < 1) || (pp->day > 31) ||
+          (month < 1) || (month > 12) ||
+          (pp->year < 0) || (pp->year > 99)) {
+               /* Data out of range. */
+               pp->lencode = 0;
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+
+       if(peer->MODE == 0) { /* compatiblity to original version */
+               int bst = flags;
+               /* Check that BST/UTC bits are the complement of one another. */
+               if(!(bst & 2) == !(bst & 4)) {
+                       pp->lencode = 0;
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+       }
+       if(status & 0x8) { msyslog(LOG_NOTICE, "ARCRON: battery low"); }
+
+       /* Year-2000 alert! */
+       /* Attempt to wrap 2-digit date into sensible window. */
+       if(pp->year < YEAR_PIVOT) { pp->year += 100; }          /* Y2KFixes */
+       pp->year += 1900;       /* use full four-digit year */  /* Y2KFixes */
+       /*
+         Attempt to do the right thing by screaming that the code will
+         soon break when we get to the end of its useful life.  What a
+         hero I am...  PLEASE FIX LEAP-YEAR AND WRAP CODE IN 209X!
+       */
+       if(pp->year >= YEAR_PIVOT+2000-2 ) {                    /* Y2KFixes */
+               /*This should get attention B^> */
+               msyslog(LOG_NOTICE,
+                      "ARCRON: fix me!  EITHER YOUR DATE IS BADLY WRONG or else I will break soon!");
+       }
+#ifdef DEBUG
+       if(debug) {
+               printf("arc: n=%d %02d:%02d:%02d %02d/%02d/%04d %1d %1d\n",
+                      n,
+                      pp->hour, pp->minute, pp->second,
+                      pp->day, month, pp->year, flags, status);
+       }
+#endif
+
+       /*
+         The status value tested for is not strictly supported by the
+         clock spec since the value of bit 2 (0x4) is claimed to be
+         undefined for MSF, yet does seem to indicate if the last resync
+         was successful or not.
+       */
+       pp->leap = LEAP_NOWARNING;
+       status &= 0x7;
+       if(status == 0x3) {
+               if(status != up->status)
+               { msyslog(LOG_NOTICE, "ARCRON: signal acquired"); }
+       } else {
+               if(status != up->status) {
+                       msyslog(LOG_NOTICE, "ARCRON: signal lost");
+                       pp->leap = LEAP_NOTINSYNC; /* MSF clock is free-running. */
+                       up->status = status;
+                       pp->lencode = 0;
+                       refclock_report(peer, CEVNT_FAULT);
+                       return;
+               }
+       }
+       up->status = status;
+
+       if (peer->MODE == 0) { /* compatiblity to original version */
+               int bst = flags;
+
+               pp->day += moff[month - 1];
+
+               if(isleap_4(pp->year) && month > 2) { pp->day++; }/* Y2KFixes */
+
+               /* Convert to UTC if required */
+               if(bst & 2) {
+                       pp->hour--;
+                       if (pp->hour < 0) {
+                               pp->hour = 23;
+                               pp->day--;
+                               /* If we try to wrap round the year
+                                * (BST on 1st Jan), reject.*/
+                               if(pp->day < 0) {
+                                       pp->lencode = 0;
+                                       refclock_report(peer, CEVNT_BADTIME);
+                                       return;
+                               }
+                       }
+               }
+       }
+
+       if(peer->MODE > 0) {
+               if(pp->sloppyclockflag & CLK_FLAG1) {
+                       struct tm  local;
+                       struct tm *gmtp;
+                       time_t     unixtime;
+
+                       /*
+                        * Convert to GMT for sites that distribute localtime.
+                        * This means we have to do Y2K conversion on the
+                        * 2-digit year; otherwise, we get the time wrong.
+                        */
+          
+                       local.tm_year  = pp->year-1900;
+                       local.tm_mon   = month-1;
+                       local.tm_mday  = pp->day;
+                       local.tm_hour  = pp->hour;
+                       local.tm_min   = pp->minute;
+                       local.tm_sec   = pp->second;
+                       switch (peer->MODE) {
+                           case 1:
+                               local.tm_isdst = (flags & 2);
+                               break;
+                           case 2:
+                               local.tm_isdst = (flags & 2);
+                               break;
+                           case 3:
+                               switch (flags & 3) {
+                                   case 0: /* It is unclear exactly when the 
+                                              Arcron changes from DST->ST and 
+                                              ST->DST. Testing has shown this
+                                              to be irregular. For the time 
+                                              being, let the OS decide. */
+                                       local.tm_isdst = 0;
+#ifdef DEBUG
+                                       if (debug)
+                                           printf ("arc: DST = 00 (0)\n"); 
+#endif
+                                       break;
+                                   case 1: /* dst->st time */
+                                       local.tm_isdst = -1;
+#ifdef DEBUG
+                                       if (debug) 
+                                           printf ("arc: DST = 01 (1)\n"); 
+#endif
+                                       break;
+                                   case 2: /* st->dst time */
+                                       local.tm_isdst = -1;
+#ifdef DEBUG
+                                       if (debug) 
+                                           printf ("arc: DST = 10 (2)\n"); 
+#endif
+                                       break;
+                                   case 3: /* dst time */
+                                       local.tm_isdst = 1;
+#ifdef DEBUG
+                                       if (debug) 
+                                           printf ("arc: DST = 11 (3)\n"); 
+#endif
+                                       break;
+                               }
+                               break;
+                           default:
+                               msyslog(LOG_NOTICE, "ARCRON: Invalid mode %d",
+                                       peer->MODE);
+                               return;
+                               break;
+                       }
+                       unixtime = mktime (&local);
+                       if ((gmtp = gmtime (&unixtime)) == NULL)
+                       {
+                               pp->lencode = 0;
+                               refclock_report (peer, CEVNT_FAULT);
+                               return;
+                       }
+                       pp->year = gmtp->tm_year+1900;
+                       month = gmtp->tm_mon+1;
+                       pp->day = ymd2yd(pp->year,month,gmtp->tm_mday);
+                       /* pp->day = gmtp->tm_yday; */
+                       pp->hour = gmtp->tm_hour;
+                       pp->minute = gmtp->tm_min;
+                       pp->second = gmtp->tm_sec;
+#ifdef DEBUG
+                       if (debug)
+                       {
+                               printf ("arc: time is %04d/%02d/%02d %02d:%02d:%02d UTC\n",
+                                       pp->year,month,gmtp->tm_mday,pp->hour,pp->minute,
+                                       pp->second);
+                       }
+#endif
+               } else 
+               {
+                       /*
+                       * For more rational sites distributing UTC
+                       */
+                       pp->day    = ymd2yd(pp->year,month,pp->day);
+               }
+       }
+
+       if (peer->MODE == 0) { /* compatiblity to original version */
+                               /* If clock signal quality is 
+                                * unknown, revert to default PRECISION...*/
+               if(up->quality == QUALITY_UNKNOWN) { 
+                       peer->precision = PRECISION; 
+               } else { /* ...else improve precision if flag3 is set... */
+                       peer->precision = ((pp->sloppyclockflag & CLK_FLAG3) ?
+                                          HIGHPRECISION : PRECISION);
+               }
+       } else {
+               if ((status == 0x3) && (pp->sloppyclockflag & CLK_FLAG2)) {
+                       peer->precision = ((pp->sloppyclockflag & CLK_FLAG3) ?
+                                          HIGHPRECISION : PRECISION);
+               } else if (up->quality == QUALITY_UNKNOWN) {
+                       peer->precision = PRECISION;
+               } else {
+                       peer->precision = ((pp->sloppyclockflag & CLK_FLAG3) ?
+                                          HIGHPRECISION : PRECISION);
+               }
+       }
+
+       /* Notice and log any change (eg from initial defaults) for flags. */
+       if(up->saved_flags != pp->sloppyclockflag) {
+#ifdef DEBUG
+               msyslog(LOG_NOTICE, "ARCRON: flags enabled: %s%s%s%s",
+                      ((pp->sloppyclockflag & CLK_FLAG1) ? "1" : "."),
+                      ((pp->sloppyclockflag & CLK_FLAG2) ? "2" : "."),
+                      ((pp->sloppyclockflag & CLK_FLAG3) ? "3" : "."),
+                      ((pp->sloppyclockflag & CLK_FLAG4) ? "4" : "."));
+               /* Note effects of flags changing... */
+               if(debug) {
+                       printf("arc: PRECISION = %d.\n", peer->precision);
+               }
+#endif
+               up->saved_flags = pp->sloppyclockflag;
+       }
+
+       /* Note time of last believable timestamp. */
+       pp->lastrec = up->lastrec;
+
+#ifdef ARCRON_LEAPSECOND_KEEN
+       /* Find out if a leap-second might just have happened...
+          (ie is this the first hour of the first day of Jan or Jul?)
+       */
+       if((pp->hour == 0) &&
+          (pp->day == 1) &&
+          ((month == 1) || (month == 7))) {
+               if(possible_leap >= 0) {
+                       /* A leap may have happened, and no resync has started yet...*/
+                       possible_leap = 1;
+               }
+       } else {
+               /* Definitely not leap-second territory... */
+               possible_leap = 0;
+       }
+#endif
+
+       if (!refclock_process(pp)) {
+               pp->lencode = 0;
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       refclock_receive(peer);
+}
+
+
+/* request_time() sends a time request to the clock with given peer. */
+/* This automatically reports a fault if necessary. */
+/* No data should be sent after this until arc_poll() returns. */
+static  void    request_time    P((int, struct peer *));
+static void
+request_time(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp = peer->procptr;
+       register struct arcunit *up = (struct arcunit *)pp->unitptr;
+#ifdef DEBUG
+       if(debug) { printf("arc: unit %d: requesting time.\n", unit); }
+#endif
+       if (!send_slow(up, pp->io.fd, "o\r")) {
+#ifdef DEBUG
+               if (debug) {
+                       printf("arc: unit %d: problem sending", unit);
+               }
+#endif
+               pp->lencode = 0;
+               refclock_report(peer, CEVNT_FAULT);
+               return;
+       }
+       pp->polls++;
+}
+
+/*
+ * arc_poll - called by the transmit procedure
+ */
+static void
+arc_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct arcunit *up;
+       struct refclockproc *pp;
+       int resync_needed;              /* Should we start a resync? */
+
+       pp = peer->procptr;
+       up = (struct arcunit *)pp->unitptr;
+#if 0
+       pp->lencode = 0;
+       memset(pp->a_lastcode, 0, sizeof(pp->a_lastcode));
+#endif
+
+#if 0
+       /* Flush input. */
+       tcflush(pp->io.fd, TCIFLUSH);
+#endif
+
+       /* Resync if our next scheduled resync time is here or has passed. */
+       resync_needed = ( !(pp->sloppyclockflag & CLK_FLAG2) &&
+                         (up->next_resync <= current_time) );
+
+#ifdef ARCRON_LEAPSECOND_KEEN
+       /*
+         Try to catch a potential leap-second insertion or deletion quickly.
+
+         In addition to the normal NTP fun of clocks that don't report
+         leap-seconds spooking their hosts, this clock does not even
+         sample the radio sugnal the whole time, so may miss a
+         leap-second insertion or deletion for up to a whole sample
+         time.
+
+         To try to minimise this effect, if in the first few minutes of
+         the day immediately following a leap-second-insertion point
+         (ie in the first hour of the first day of the first and sixth
+         months), and if the last resync was in the previous day, and a
+         resync is not already in progress, resync the clock
+         immediately.
+
+       */
+       if((possible_leap > 0) &&       /* Must be 00:XX 01/0{1,7}/XXXX. */
+          (!up->resyncing)) {          /* No resync in progress yet. */
+               resync_needed = 1;
+               possible_leap = -1;          /* Prevent multiple resyncs. */
+               msyslog(LOG_NOTICE,"ARCRON: unit %d: checking for leap second",unit);
+       }
+#endif
+
+       /* Do a resync if required... */
+       if(resync_needed) {
+               /* First, reset quality value to `unknown' so we can detect */
+               /* when a quality message has been responded to by this     */
+               /* being set to some other value.                           */
+               up->quality = QUALITY_UNKNOWN;
+
+               /* Note that we are resyncing... */
+               up->resyncing = 1;
+
+               /* Now actually send the resync command and an immediate poll. */
+#ifdef DEBUG
+               if(debug) { printf("arc: sending resync command (h\\r).\n"); }
+#endif
+               msyslog(LOG_NOTICE, "ARCRON: unit %d: sending resync command", unit);
+               send_slow(up, pp->io.fd, "h\r");
+
+               /* Schedule our next resync... */
+               up->next_resync = current_time + DEFAULT_RESYNC_TIME;
+
+               /* Drop through to request time if appropriate. */
+       }
+
+       /* If clock quality is too poor to trust, indicate a fault. */
+       /* If quality is QUALITY_UNKNOWN and ARCRON_KEEN is defined,*/
+       /* we'll cross our fingers and just hope that the thing     */
+       /* synced so quickly we did not catch it---we'll            */
+       /* double-check the clock is OK elsewhere.                  */
+       if(
+#ifdef ARCRON_KEEN
+               (up->quality != QUALITY_UNKNOWN) &&
+#else
+               (up->quality == QUALITY_UNKNOWN) ||
+#endif
+               (up->quality < MIN_CLOCK_QUALITY_OK)) {
+#ifdef DEBUG
+               if(debug) {
+                       printf("arc: clock quality %d too poor.\n", up->quality);
+               }
+#endif
+               pp->lencode = 0;
+               refclock_report(peer, CEVNT_FAULT);
+               return;
+       }
+       /* This is the normal case: request a timestamp. */
+       request_time(unit, peer);
+}
+
+#else
+int refclock_arc_bs;
+#endif
diff --git a/ntpd/refclock_as2201.c b/ntpd/refclock_as2201.c
new file mode 100644 (file)
index 0000000..f04d417
--- /dev/null
@@ -0,0 +1,388 @@
+/*
+ * refclock_as2201 - clock driver for the Austron 2201A GPS
+ *     Timing Receiver
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_AS2201)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+/*
+ * This driver supports the Austron 2200A/2201A GPS Receiver with
+ * Buffered RS-232-C Interface Module. Note that the original 2200/2201
+ * receivers will not work reliably with this driver, since the older
+ * design cannot accept input commands at any reasonable data rate.
+ *
+ * The program sends a "*toc\r" to the radio and expects a response of
+ * the form "yy:ddd:hh:mm:ss.mmm\r" where yy = year of century, ddd =
+ * day of year, hh:mm:ss = second of day and mmm = millisecond of
+ * second. Then, it sends statistics commands to the radio and expects
+ * a multi-line reply showing the corresponding statistics or other
+ * selected data. Statistics commands are sent in order as determined by
+ * a vector of commands; these might have to be changed with different
+ * radio options. If flag4 of the fudge configuration command is set to
+ * 1, the statistics data are written to the clockstats file for later
+ * processing.
+ *
+ * In order for this code to work, the radio must be placed in non-
+ * interactive mode using the "off" command and with a single <cr>
+ * response using the "term cr" command. The setting of the "echo"
+ * and "df" commands does not matter. The radio should select UTC
+ * timescale using the "ts utc" command.
+ *
+ * There are two modes of operation for this driver. The first with
+ * default configuration is used with stock kernels and serial-line
+ * drivers and works with almost any machine. In this mode the driver
+ * assumes the radio captures a timestamp upon receipt of the "*" that
+ * begins the driver query. Accuracies in this mode are in the order of
+ * a millisecond or two and the receiver can be connected to only one
+ * host.
+ *
+ * The second mode of operation can be used for SunOS kernels that have
+ * been modified with the ppsclock streams module included in this
+ * distribution. The mode is enabled if flag3 of the fudge configuration
+ * command has been set to 1. In this mode a precise timestamp is
+ * available using a gadget box and 1-pps signal from the receiver. This
+ * improves the accuracy to the order of a few tens of microseconds. In
+ * addition, the serial output and 1-pps signal can be bussed to more
+ * than one hosts, but only one of them should be connected to the
+ * radio input data line. 
+ */
+
+/*
+ * GPS Definitions
+ */
+#define SMAX           200     /* statistics buffer length */
+#define        DEVICE          "/dev/gps%d" /* device name and unit */
+#define        SPEED232        B9600   /* uart speed (9600 baud) */
+#define        PRECISION       (-20)   /* precision assumed (about 1 us) */
+#define        REFID           "GPS\0" /* reference ID */
+#define        DESCRIPTION     "Austron 2201A GPS Receiver" /* WRU */
+
+#define        LENTOC          19      /* yy:ddd:hh:mm:ss.mmm timecode lngth */
+
+/*
+ * AS2201 unit control structure.
+ */
+struct as2201unit {
+       char    *lastptr;       /* statistics buffer pointer */
+       char    stats[SMAX];    /* statistics buffer */
+       int     linect;         /* count of lines remaining */
+       int     index;          /* current statistics command */
+};
+
+/*
+ * Radio commands to extract statitistics
+ *
+ * A command consists of an ASCII string terminated by a <cr> (\r). The
+ * command list consist of a sequence of commands terminated by a null
+ * string ("\0"). One command from the list is sent immediately
+ * following each received timecode (*toc\r command) and the ASCII
+ * strings received from the radio are saved along with the timecode in
+ * the clockstats file. Subsequent commands are sent at each timecode,
+ * with the last one in the list followed by the first one. The data
+ * received from the radio consist of ASCII strings, each terminated by
+ * a <cr> (\r) character. The number of strings for each command is
+ * specified as the first line of output as an ASCII-encode number. Note
+ * that the ETF command requires the Input Buffer Module and the LORAN
+ * commands require the LORAN Assist Module. However, if these modules
+ * are not installed, the radio and this driver will continue to operate
+ * successfuly, but no data will be captured for these commands.
+ */
+static char stat_command[][30] = {
+       "ITF\r",                /* internal time/frequency */
+       "ETF\r",                /* external time/frequency */
+       "LORAN ENSEMBLE\r",     /* GPS/LORAN ensemble statistics */
+       "LORAN TDATA\r",        /* LORAN signal data */
+       "ID;OPT;VER\r",         /* model; options; software version */
+
+       "ITF\r",                /* internal time/frequency */
+       "ETF\r",                /* external time/frequency */
+       "LORAN ENSEMBLE\r",     /* GPS/LORAN ensemble statistics */
+       "TRSTAT\r",             /* satellite tracking status */
+       "POS;PPS;PPSOFF\r",     /* position, pps source, offsets */
+
+       "ITF\r",                /* internal time/frequency */
+       "ETF\r",                /* external time/frequency */
+       "LORAN ENSEMBLE\r",     /* GPS/LORAN ensemble statistics */
+       "LORAN TDATA\r",        /* LORAN signal data */
+       "UTC\r",                        /* UTC leap info */
+
+       "ITF\r",                /* internal time/frequency */
+       "ETF\r",                /* external time/frequency */
+       "LORAN ENSEMBLE\r",     /* GPS/LORAN ensemble statistics */
+       "TRSTAT\r",             /* satellite tracking status */
+       "OSC;ET;TEMP\r",        /* osc type; tune volts; oven temp */
+       "\0"                    /* end of table */
+};
+
+/*
+ * Function prototypes
+ */
+static int     as2201_start    P((int, struct peer *));
+static void    as2201_shutdown P((int, struct peer *));
+static void    as2201_receive  P((struct recvbuf *));
+static void    as2201_poll     P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_as2201 = {
+       as2201_start,           /* start up driver */
+       as2201_shutdown,        /* shut down driver */
+       as2201_poll,            /* transmit poll message */
+       noentry,                /* not used (old as2201_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old as2201_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * as2201_start - open the devices and initialize data for processing
+ */
+static int
+as2201_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct as2201unit *up;
+       struct refclockproc *pp;
+       int fd;
+       char gpsdev[20];
+
+       /*
+        * Open serial port. Use CLK line discipline, if available.
+        */
+       (void)sprintf(gpsdev, DEVICE, unit);
+       if (!(fd = refclock_open(gpsdev, SPEED232, LDISC_CLK)))
+               return (0);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct as2201unit *)
+             emalloc(sizeof(struct as2201unit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct as2201unit));
+       pp = peer->procptr;
+       pp->io.clock_recv = as2201_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       peer->burst = NSTAGE;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       up->lastptr = up->stats;
+       up->index = 0;
+       return (1);
+}
+
+
+/*
+ * as2201_shutdown - shut down the clock
+ */
+static void
+as2201_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct as2201unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct as2201unit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * as2201__receive - receive data from the serial interface
+ */
+static void
+as2201_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct as2201unit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       l_fp trtmp;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp.
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct as2201unit *)pp->unitptr;
+       pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp);
+#ifdef DEBUG
+       if (debug)
+           printf("gps: timecode %d %d %s\n",
+                  up->linect, pp->lencode, pp->a_lastcode);
+#endif
+       if (pp->lencode == 0)
+           return;
+
+       /*
+        * If linect is greater than zero, we must be in the middle of a
+        * statistics operation, so simply tack the received data at the
+        * end of the statistics string. If not, we could either have
+        * just received the timecode itself or a decimal number
+        * indicating the number of following lines of the statistics
+        * reply. In the former case, write the accumulated statistics
+        * data to the clockstats file and continue onward to process
+        * the timecode; in the later case, save the number of lines and
+        * quietly return.
+        */
+       if (pp->sloppyclockflag & CLK_FLAG2)
+               pp->lastrec = trtmp;
+       if (up->linect > 0) {
+               up->linect--;
+               if ((int)(up->lastptr - up->stats + pp->lencode) > SMAX - 2)
+                   return;
+               *up->lastptr++ = ' ';
+               (void)strcpy(up->lastptr, pp->a_lastcode);
+               up->lastptr += pp->lencode;
+               return;
+       } else {
+               if (pp->lencode == 1) {
+                       up->linect = atoi(pp->a_lastcode);
+                       return;
+               } else {
+                       record_clock_stats(&peer->srcadr, up->stats);
+#ifdef DEBUG
+                       if (debug)
+                           printf("gps: stat %s\n", up->stats);
+#endif
+               }
+       }
+       up->lastptr = up->stats;
+       *up->lastptr = '\0';
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. If the timecode has invalid length or is not in
+        * proper format, we declare bad format and exit.
+        */
+       if (pp->lencode < LENTOC) {
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       /*
+        * Timecode format: "yy:ddd:hh:mm:ss.mmm"
+        */
+       if (sscanf(pp->a_lastcode, "%2d:%3d:%2d:%2d:%2d.%3ld", &pp->year,
+                  &pp->day, &pp->hour, &pp->minute, &pp->second, &pp->nsec)
+           != 6) {
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+       pp->nsec *= 1000000;
+
+       /*
+        * Test for synchronization (this is a temporary crock).
+        */
+       if (pp->a_lastcode[2] != ':')
+               pp->leap = LEAP_NOTINSYNC;
+       else
+               pp->leap = LEAP_NOWARNING;
+
+       /*
+        * Process the new sample in the median filter and determine the
+        * timecode timestamp.
+        */
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+
+       /*
+        * If CLK_FLAG4 is set, initialize the statistics buffer and
+        * send the next command. If not, simply write the timecode to
+        * the clockstats file.
+        */
+       (void)strcpy(up->lastptr, pp->a_lastcode);
+       up->lastptr += pp->lencode;
+       if (pp->sloppyclockflag & CLK_FLAG4) {
+               *up->lastptr++ = ' ';
+               (void)strcpy(up->lastptr, stat_command[up->index]);
+               up->lastptr += strlen(stat_command[up->index]);
+               up->lastptr--;
+               *up->lastptr = '\0';
+               (void)write(pp->io.fd, stat_command[up->index],
+                   strlen(stat_command[up->index]));
+               up->index++;
+               if (*stat_command[up->index] == '\0')
+                       up->index = 0;
+       }
+}
+
+
+/*
+ * as2201_poll - called by the transmit procedure
+ *
+ * We go to great pains to avoid changing state here, since there may be
+ * more than one eavesdropper receiving the same timecode.
+ */
+static void
+as2201_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+
+       /*
+        * Send a "\r*toc\r" to get things going. We go to great pains
+        * to avoid changing state, since there may be more than one
+        * eavesdropper watching the radio.
+        */
+       pp = peer->procptr;
+       if (write(pp->io.fd, "\r*toc\r", 6) != 6) {
+               refclock_report(peer, CEVNT_FAULT);
+       } else {
+               pp->polls++;
+               if (!(pp->sloppyclockflag & CLK_FLAG2))
+                       get_systime(&pp->lastrec);
+       }
+       if (peer->burst > 0)
+                return;
+        if (pp->coderecv == pp->codeproc) {
+                refclock_report(peer, CEVNT_TIMEOUT);
+                return;
+        }
+        refclock_receive(peer);
+       peer->burst = NSTAGE;
+}
+
+#else
+int refclock_as2201_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_atom.c b/ntpd/refclock_atom.c
new file mode 100644 (file)
index 0000000..2e469ec
--- /dev/null
@@ -0,0 +1,517 @@
+/*
+ * refclock_atom - clock driver for 1-pps signals
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_unixtime.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#if defined(REFCLOCK) && defined(CLOCK_ATOM)
+
+#ifdef HAVE_PPSAPI
+# include "ppsapi_timepps.h"
+#endif /* HAVE_PPSAPI */
+
+/*
+ * This driver furnishes an interface for pulse-per-second (PPS) signals
+ * produced by a cesium clock, timing receiver or related equipment. It
+ * can be used to remove accumulated jitter and retime a secondary
+ * server when synchronized to a primary server over a congested, wide-
+ * area network and before redistributing the time to local clients.
+ *
+ * Before this driver becomes active, the local clock must be set to
+ * within +-500 ms by another means, such as a radio clock or NTP
+ * itself. There are two ways to connect the PPS signal, normally at TTL
+ * levels, to the computer. One is to shift to EIA levels and connect to
+ * pin 8 (DCD) of a serial port. This requires a level converter and
+ * may require a one-shot flipflop to lengthen the pulse. The other is
+ * to connect the PPS signal directly to pin 10 (ACK) of a PC paralell
+ * port. These methods are architecture dependent.
+ *
+ * Both methods require a modified device driver and kernel interface
+ * compatible with the Pulse-per-Second API for Unix-like Operating
+ * Systems, Version 1.0, RFC-2783 (PPSAPI). Implementations are
+ * available for FreeBSD, Linux, SunOS, Solaris and Alpha. However, at
+ * present only the Alpha implementation provides the full generality of
+ * the API with multiple PPS drivers and multiple handles per driver. If
+ * the PPSAPI is normally implemented in the /usr/include/sys/timepps.h
+ * header file and kernel support specific to each operating system.
+ * However, this driver can operate without this interface if means are
+ * proviced to call the pps_sample() routine from another driver. Please
+ * note; if the PPSAPI interface is present, it must be used.
+ *
+ * In many configurations a single port is used for the radio timecode
+ * and PPS signal. In order to provide for this configuration and others
+ * involving dedicated multiple serial/parallel ports, the driver first
+ * attempts to open the device /dev/pps%d, where %d is the unit number.
+ * If this fails, the driver attempts to open the device specified by
+ * the pps configuration command. If a port is to be shared, the pps
+ * command must be placed before the radio device(s) and the radio
+ * device(s) must be placed before the PPS driver(s) in the
+ * configuration file.
+ *
+ * This driver normally uses the PLL/FLL clock discipline implemented in
+ * the ntpd code. Ordinarily, this is the most accurate means, as the
+ * median filter in the driver interface is much larger than in the
+ * kernel. However, if the systemic clock frequency error is large (tens
+ * to hundreds of PPM), it's better to used the kernel support, if
+ * available.
+ *
+ * Fudge Factors
+ *
+ * If flag2 is dim (default), the on-time epoch is the assert edge of
+ * the PPS signal; if lit, the on-time epoch is the clear edge. If flag2
+ * is lit, the assert edge is used; if flag3 is dim (default), the
+ * kernel PPS support is disabled; if lit it is enabled. The time1
+ * parameter can be used to compensate for miscellaneous device driver
+ * and OS delays.
+ */
+/*
+ * Interface definitions
+ */
+#ifdef HAVE_PPSAPI
+#define DEVICE         "/dev/pps%d" /* device name and unit */
+#endif /* HAVE_PPSAPI */
+
+#define        PRECISION       (-20)   /* precision assumed (about 1 us) */
+#define        REFID           "PPS\0" /* reference ID */
+#define        DESCRIPTION     "PPS Clock Discipline" /* WRU */
+#define NANOSECOND     1000000000 /* one second (ns) */
+#define RANGEGATE      500000  /* range gate (ns) */
+
+static struct peer *pps_peer;  /* atom driver for PPS sources */
+
+#ifdef HAVE_PPSAPI
+/*
+ * PPS unit control structure
+ */
+struct ppsunit {
+       struct timespec ts;     /* last timestamp */
+       int fddev;              /* pps device descriptor */
+       pps_params_t pps_params; /* pps parameters */
+       pps_info_t pps_info;    /* last pps data */
+       pps_handle_t handle;    /* pps handlebars */
+};
+#endif /* HAVE_PPSAPI */
+
+/*
+ * Function prototypes
+ */
+static int     atom_start      P((int, struct peer *));
+static void    atom_poll       P((int, struct peer *));
+static void    atom_shutdown   P((int, struct peer *));
+#ifdef HAVE_PPSAPI
+static void    atom_control    P((int, struct refclockstat *, struct
+                                   refclockstat *, struct peer *));
+static void    atom_timer      P((int, struct peer *));
+static int     atom_ppsapi     P((struct peer *, int));
+#endif /* HAVE_PPSAPI */
+
+/*
+ * Transfer vector
+ */
+#ifdef HAVE_PPSAPI
+struct refclock refclock_atom = {
+       atom_start,             /* start up driver */
+       atom_shutdown,          /* shut down driver */
+       atom_poll,              /* transmit poll message */
+       atom_control,           /* fudge control */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* buginfo (not used) */
+       atom_timer,             /* called once per second */
+};
+#else /* HAVE_PPSAPI */
+struct refclock refclock_atom = {
+       atom_start,             /* start up driver */
+       atom_shutdown,          /* shut down driver */
+       atom_poll,              /* transmit poll message */
+       noentry,                /* fudge control (not used) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* buginfo (not used) */
+       NOFLAGS                 /* not used */
+};
+#endif /* HAVE_PPPSAPI */
+
+
+/*
+ * atom_start - initialize data for processing
+ */
+static int
+atom_start(
+       int unit,               /* unit number (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+#ifdef HAVE_PPSAPI
+       register struct ppsunit *up;
+       char    device[80];
+       int     mode;
+#endif /* HAVE_PPSAPI */
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       pps_peer = peer;
+       pp = peer->procptr;
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       pp->stratum = STRATUM_UNSPEC;
+       memcpy((char *)&pp->refid, REFID, 4);
+#ifdef HAVE_PPSAPI
+       up = emalloc(sizeof(struct ppsunit));
+       memset(up, 0, sizeof(struct ppsunit));
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Open PPS device. This can be any serial or parallel port and
+        * not necessarily the port used for the associated radio.
+        */
+       sprintf(device, DEVICE, unit);
+       up->fddev = open(device, O_RDWR, 0777);
+       if (up->fddev <= 0) {
+               msyslog(LOG_ERR,
+                   "refclock_atom: %s: %m", device);
+               return (0);
+       }
+
+       /*
+        * Light off the PPSAPI interface.
+        */
+       if (time_pps_create(up->fddev, &up->handle) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_atom: time_pps_create failed: %m");
+               return (0);
+       }
+
+       /*
+        * If the mode is nonzero, use that for the time_pps_setparams()
+        * mode; otherwise, PPS_CAPTUREASSERT. Enable kernel PPS if
+        * flag3 is lit.
+        */
+       mode = peer->ttl;
+       if (mode == 0)
+               mode = PPS_CAPTUREASSERT;
+       return (atom_ppsapi(peer, mode));
+#else /* HAVE_PPSAPI */
+       return (1);
+#endif /* HAVE_PPSAPI */
+}
+
+
+/*
+ * atom_shutdown - shut down the clock
+ */
+static void
+atom_shutdown(
+       int unit,               /* unit number (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       register struct ppsunit *up;
+
+       pp = peer->procptr;
+       up = (struct ppsunit *)pp->unitptr;
+#ifdef HAVE_PPSAPI
+       if (up->fddev > 0)
+               close(up->fddev);
+       if (up->handle != 0)
+               time_pps_destroy(up->handle);
+#endif /* HAVE_PPSAPI */
+       if (pps_peer == peer)
+               pps_peer = NULL;
+       free(up);
+}
+
+
+#ifdef HAVE_PPSAPI
+/*
+ * atom_control - fudge control
+ */
+static void
+atom_control(
+       int unit,               /* unit (not used */
+       struct refclockstat *in, /* input parameters (not uded) */
+       struct refclockstat *out, /* output parameters (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       int     mode;
+
+       pp = peer->procptr;
+       if (peer->ttl != 0)     /* all legal modes must be nonzero */
+               return;
+
+       if (pp->sloppyclockflag & CLK_FLAG2)
+               mode = PPS_CAPTURECLEAR;
+       else
+               mode = PPS_CAPTUREASSERT;
+       atom_ppsapi(peer, mode);
+}
+
+
+/*
+ * Initialize PPSAPI
+ */
+int
+atom_ppsapi(
+       struct peer *peer,      /* peer structure pointer */
+       int mode                /* mode */
+       )
+{
+       struct refclockproc *pp;
+       register struct ppsunit *up;
+       int capability;
+
+       pp = peer->procptr;
+       up = (struct ppsunit *)pp->unitptr;
+       if (up->handle == 0)
+               return (0);
+
+       if (time_pps_getcap(up->handle, &capability) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_atom: time_pps_getcap failed: %m");
+               return (0);
+       }
+       memset(&up->pps_params, 0, sizeof(pps_params_t));
+       up->pps_params.api_version = PPS_API_VERS_1;
+       up->pps_params.mode = mode | PPS_TSFMT_TSPEC;
+       if (time_pps_setparams(up->handle, &up->pps_params) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_atom: time_pps_setparams failed: %m");
+               return (0);
+       }
+       if (pp->sloppyclockflag & CLK_FLAG3) {
+               if (time_pps_kcbind(up->handle, PPS_KC_HARDPPS,
+                   up->pps_params.mode & ~PPS_TSFMT_TSPEC,
+                   PPS_TSFMT_TSPEC) < 0) {
+                       msyslog(LOG_ERR,
+                           "refclock_atom: time_pps_kcbind failed: %m");
+                       return (0);
+               }
+               pps_enable = 1;
+       }
+#if DEBUG
+       if (debug) {
+               time_pps_getparams(up->handle, &up->pps_params);
+               printf(
+                   "refclock_ppsapi: fd %d capability 0x%x version %d mode 0x%x\n",
+                   up->fddev, capability, up->pps_params.api_version,
+                   up->pps_params.mode);
+       }
+#endif
+       return (1);
+}
+
+
+/*
+ * atom_timer - called once per second
+ *
+ * This routine is called once per second when the PPSAPI interface is
+ * present. It snatches the PPS timestamp from the kernel and saves the
+ * sign-extended fraction in a circular buffer for processing at the
+ * next poll event.
+ */
+static void
+atom_timer(
+       int     unit,           /* unit number (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       register struct ppsunit *up;
+       struct refclockproc *pp;
+       pps_info_t pps_info;
+       struct timespec timeout, ts;
+       long    sec, nsec;
+       double  dtemp;
+       char    tbuf[80];       /* monitor buffer */
+
+       /*
+        * Convert the timespec nanoseconds field to signed double and
+        * save in the median filter. for billboards. No harm is done if
+        * previous data are overwritten. If the discipline comes bum or
+        * the data grow stale, just forget it. A range gate rejects new
+        * samples if less than a jiggle time from the next second.
+        */ 
+       pp = peer->procptr;
+       up = (struct ppsunit *)pp->unitptr;
+       if (up->handle == 0)
+               return;
+
+       timeout.tv_sec = 0;
+       timeout.tv_nsec = 0;
+       memcpy(&pps_info, &up->pps_info, sizeof(pps_info_t));
+       if (time_pps_fetch(up->handle, PPS_TSFMT_TSPEC, &up->pps_info,
+           &timeout) < 0) {
+               refclock_report(peer, CEVNT_FAULT);
+               return;
+       }
+       if (up->pps_params.mode & PPS_CAPTUREASSERT) {
+               ts = up->pps_info.assert_timestamp;
+       } else if (up->pps_params.mode & PPS_CAPTURECLEAR) {
+               ts = up->pps_info.clear_timestamp;
+       } else {
+               refclock_report(peer, CEVNT_FAULT);
+               return;
+       }
+
+       /*
+        * There can be zero, one or two PPS seconds between polls. If
+        * zero, either the poll clock is slightly faster than the PPS
+        * clock or the PPS clock has died. If the PPS clock advanced
+        * once between polls, we make sure the fraction time difference
+        * since the last sample is within the range gate of 5 ms (500
+        * PPM). If the PPS clock advanced twice since the last poll,
+        * the poll bracketed more than one second and the first second
+        * was lost to a slip. Since the interval since the last sample
+        * found is now two seconds, just widen the range gate. If the
+        * PPS clock advanced three or more times, either the signal has
+        * failed for a number of seconds or we have runts, in which
+        * case just ignore them.
+        *
+        * If flag4 is lit, record each second offset to clockstats.
+        * That's so we can make awesome Allan deviation plots.
+        */
+       sec = ts.tv_sec - up->ts.tv_sec;
+       nsec = ts.tv_nsec - up->ts.tv_nsec;
+       up->ts = ts;
+       if (nsec < 0) {
+               sec --;
+               nsec += NANOSECOND;
+       } else if (nsec >= NANOSECOND) {
+               sec++;
+               nsec -= NANOSECOND;
+       }
+       if (sec * NANOSECOND + nsec > NANOSECOND + RANGEGATE)
+               return;
+
+       else if (sec * NANOSECOND + nsec < NANOSECOND - RANGEGATE)
+               return;
+
+       pp->lastrec.l_ui = ts.tv_sec + JAN_1970;
+       dtemp = ts.tv_nsec * FRAC / 1e9;
+       if (dtemp >= FRAC)
+               pp->lastrec.l_ui++;
+       pp->lastrec.l_uf = (u_int32)dtemp;
+       if (ts.tv_nsec > NANOSECOND / 2)
+               ts.tv_nsec -= NANOSECOND;
+       dtemp = -(double)ts.tv_nsec / NANOSECOND;
+       SAMPLE(dtemp + pp->fudgetime1);
+       if (pp->sloppyclockflag & CLK_FLAG4){
+               sprintf(tbuf, "%.9f", dtemp);
+               record_clock_stats(&peer->srcadr, tbuf);
+       }
+#ifdef DEBUG
+       if (debug > 1)
+               printf("atom_timer: %lu %f %f\n", current_time,
+                   dtemp, pp->fudgetime1);
+#endif
+       return;
+}
+#endif /* HAVE_PPSAPI */
+
+
+/*
+ * pps_sample - receive PPS data from some other clock driver
+ *
+ * This routine is called once per second when the external clock driver
+ * processes PPS information. It processes the PPS timestamp and saves
+ * the sign-extended fraction in a circular buffer for processing at the
+ * next poll event. This works only for a single PPS device.
+ *
+ * The routine should be used by another configured driver ONLY when
+ * this driver is configured as well and the PPSAPI is NOT in use.
+ */
+int
+pps_sample(
+          l_fp *offset         /* PPS offset */
+          )
+{
+       register struct peer *peer;
+       struct refclockproc *pp;
+       l_fp lftmp;
+       double doffset;
+
+       peer = pps_peer;
+       if (peer == NULL)
+               return (1);
+
+       pp = peer->procptr;
+
+       /*
+        * Convert the timeval to l_fp and save for billboards. Sign-
+        * extend the fraction and stash in the buffer. No harm is done
+        * if previous data are overwritten. If the discipline comes bum
+        * or the data grow stale, just forget it.
+        */ 
+       pp->lastrec = *offset;
+       L_CLR(&lftmp);
+       L_ADDF(&lftmp, pp->lastrec.l_f);
+       LFPTOD(&lftmp, doffset);
+       SAMPLE(-doffset + pp->fudgetime1);
+       return (0);
+}
+
+
+/*
+ * atom_poll - called by the transmit procedure
+ */
+static void
+atom_poll(
+       int unit,               /* unit number (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       pp = peer->procptr;
+       pp->polls++;
+
+       /*
+        * Valid time is returned only if the prefer peer has survived
+        * the intersection algorithm and within 0.4 s of local time
+        * and not too long ago. This ensures the PPS time is within
+        * 0.5 s of the local time and the seconds numbering is
+        * unambiguous. Note that the leap bits, stratum and refid are
+        * set from the prefer peer, unless overriden by a fudge
+        * command.
+        */
+       if (pp->codeproc == pp->coderecv) {
+               refclock_report(peer, CEVNT_TIMEOUT);
+               return;
+
+       } else if (sys_prefer == NULL) {
+               pp->codeproc = pp->coderecv;
+               return;
+
+       } else if (fabs(sys_prefer->offset) >= 0.4) {
+               pp->codeproc = pp->coderecv;
+               return;
+       }
+       pp->leap = sys_prefer->leap;
+       if (pp->stratum >= STRATUM_UNSPEC)
+               peer->stratum = sys_prefer->stratum;
+       else
+               peer->stratum = pp->stratum;
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+}
+#else
+int refclock_atom_bs;
+int
+pps_sample(
+          l_fp *offset         /* PPS offset */
+          )
+{
+       return (1);
+}
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_bancomm.c b/ntpd/refclock_bancomm.c
new file mode 100644 (file)
index 0000000..9fc8c82
--- /dev/null
@@ -0,0 +1,467 @@
+/* refclock_bancomm.c - clock driver for the  Datum/Bancomm bc635VME 
+ * Time and Frequency Processor. It requires the BANCOMM bc635VME/
+ * bc350VXI Time and Frequency Processor Module Driver for SunOS4.x 
+ * and SunOS5.x UNIX Systems. It has been tested on a UltraSparc 
+ * IIi-cEngine running Solaris 2.6.
+ * 
+ * Author(s):  Ganesh Ramasivan & Gary Cliff, Computing Devices Canada,
+ *             Ottawa, Canada
+ *
+ * Date:       July 1999
+ *
+ * Note(s):    The refclock type has been defined as 16.
+ *
+ *             This program has been modelled after the Bancomm driver
+ *             originally written by R. Schmidt of Time Service, U.S. 
+ *             Naval Observatory for a HP-UX machine. Since the original
+ *             authors no longer plan to maintain this code, all 
+ *             references to the HP-UX vme2 driver subsystem bave been
+ *             removed. Functions vme_report_event(), vme_receive(), 
+ *             vme_control() and vme_buginfo() have been deleted because
+ *             they are no longer being used.
+ *
+ *             The time on the bc635 TFP must be set to GMT due to the 
+ *             fact that NTP makes use of GMT for all its calculations.
+ *
+ *             Installation of the Datum/Bancomm driver creates the 
+ *             device file /dev/btfp0 
+ *
+ *     04/28/2005 Rob Neal 
+ *             Modified to add support for Symmetricom bc637PCI-U Time & 
+ *             Frequency Processor. 
+ *             Card bus type (VME/VXI or PCI) and environment are specified via the
+ *             "mode" keyword on the server command in ntp.conf.
+ *             server 127.127.16.u prefer mode m (...) 
+ *             Modes currently supported are 
+ *             1               : FreeBSD PCI 635/637.
+ *             2               : Linux or Windows PCI 635/637.
+ *             not specified, or other number: 
+ *                             : Assumed to be VME/VXI legacy Bancomm card on Solaris.
+ *             Linux and Windows platforms require Symmetricoms' proprietary driver
+ *             for the TFP card. 
+ *             Tested on FreeBSD 5.3 with a 637 card. 
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_BANC) 
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <syslog.h>
+#include <ctype.h>
+
+/*  STUFF BY RES */
+struct btfp_time                /* Structure for reading 5 time words   */
+                                /* in one ioctl(2) operation.           */
+{
+       unsigned short btfp_time[5];  /* Time words 0,1,2,3, and 4. (16bit)*/
+};
+/* SunOS5 ioctl commands definitions.*/
+#define BTFPIOC            ( 'b'<< 8 )
+#define IOCIO( l, n )      ( BTFPIOC | n )
+#define IOCIOR( l, n, s )  ( BTFPIOC | n )
+#define IOCIORN( l, n, s ) ( BTFPIOC | n )
+#define IOCIOWN( l, n, s ) ( BTFPIOC | n )
+
+/***** Simple ioctl commands *****/
+#define RUNLOCK        IOCIOR(b, 19, int )  /* Release Capture Lockout */
+#define RCR0           IOCIOR(b, 22, int )  /* Read control register zero.*/
+#define        WCR0            IOCIOWN(b, 23, int)          /* Write control register zero*/
+/***** Compound ioctl commands *****/
+
+/* Read all 5 time words in one call.   */
+#define READTIME       IOCIORN(b, 32, sizeof( struct btfp_time ))
+
+#if defined(__FreeBSD__) 
+#undef  READTIME
+#define READTIME       _IOR('u', 5, struct btfp_time )
+#endif 
+
+#define VMEFD "/dev/btfp0"
+
+struct vmedate {               /* structure returned by get_vmetime.c */
+       unsigned short year;
+       unsigned short day;
+       unsigned short hr;
+       unsigned short mn;
+       unsigned short sec;
+       long frac;
+       unsigned short status;
+};
+
+/* END OF STUFF FROM RES */
+typedef void *SYMMT_PCI_HANDLE;
+
+/*
+ * VME interface parameters. 
+ */
+#define VMEPRECISION    (-21)   /* precision assumed (1 us) */
+#define USNOREFID       "BTFP"  /* or whatever */
+#define VMEREFID        "BTFP"  /* reference id */
+#define VMEDESCRIPTION  "Bancomm bc635 TFP" /* who we are */
+#define VMEHSREFID      0x7f7f1000 /* 127.127.16.00 refid hi strata */
+/* clock type 16 is used here  */
+#define GMT            0       /* hour offset from Greenwich */
+
+/*
+ * Imported from ntp_timer module
+ */
+extern u_long current_time;     /* current time(s) */
+
+/*
+ * Imported from ntpd module
+ */
+extern volatile int debug;               /* global debug flag */
+
+/*
+ * VME unit control structure.
+ * Changes made to vmeunit structure. Most members are now available in the 
+ * new refclockproc structure in ntp_refclock.h - 07/99 - Ganesh Ramasivan
+ */
+struct vmeunit {
+       struct vmedate vmedata; /* data returned from vme read */
+       u_long lasttime;        /* last time clock heard from */
+};
+
+/*
+ * Function prototypes
+ */
+static  int     vme_start       (int, struct peer *);
+static  void    vme_shutdown    (int, struct peer *);
+static  void    vme_receive     (struct recvbuf *);
+static  void    vme_poll        (int unit, struct peer *);
+struct vmedate *get_datumtime(struct vmedate *);       
+void   tvme_fill(struct vmedate *, uint32_t btm[2]);
+/*
+ * Define the bc*() functions as weak so we can compile/link without them.
+ * Only clients with the card will have the proprietary vendor device driver
+ * and interface library needed for use on Linux/Windows platforms.
+ */
+extern uint32_t __attribute__ ((weak)) bcReadBinTime(SYMMT_PCI_HANDLE, uint32_t *, uint32_t*, uint8_t*);
+extern SYMMT_PCI_HANDLE __attribute__ ((weak)) bcStartPci(void);
+extern void __attribute__ ((weak)) bcStopPci(SYMMT_PCI_HANDLE);
+
+/*
+ * Transfer vector
+ */
+struct  refclock refclock_bancomm = {
+       vme_start,              /* start up driver */
+       vme_shutdown,           /* shut down driver */
+       vme_poll,               /* transmit poll message */
+       noentry,                /* not used (old vme_control) */
+       noentry,                /* initialize driver */ 
+       noentry,                /* not used (old vme_buginfo) */ 
+       NOFLAGS                 /* not used */
+};
+
+int fd_vme;  /* file descriptor for ioctls */
+int regvalue;
+int tfp_type;  /* mode selector, indicate platform and driver interface */
+SYMMT_PCI_HANDLE stfp_handle;
+
+
+/*
+ * vme_start - open the VME device and initialize data for processing
+ */
+static int
+vme_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct vmeunit *vme;
+       struct refclockproc *pp;
+       int dummy;
+       char vmedev[20];
+       
+       tfp_type = (int)(peer->ttl);
+       switch (tfp_type) {             
+               case 1:
+                       break;
+               case 2:
+                       stfp_handle = bcStartPci();     /* init the card in lin/win */
+                       break;
+               default:
+                       break;
+       }
+       /*
+        * Open VME device
+        */
+#ifdef DEBUG
+
+       printf("Opening DATUM VME DEVICE \n");
+#endif
+       if ( (fd_vme = open(VMEFD, O_RDWR)) < 0) {
+               msyslog(LOG_ERR, "vme_start: failed open of %s: %m", vmedev);
+               return (0);
+       }
+       else  { 
+               switch (tfp_type) {
+                       case 1: break;
+                       case 2: break;
+                       default: 
+                               /* Release capture lockout in case it was set before. */
+                               if( ioctl( fd_vme, RUNLOCK, &dummy ) )
+                               msyslog(LOG_ERR, "vme_start: RUNLOCK failed %m");
+
+                               regvalue = 0; /* More esoteric stuff to do... */
+                               if( ioctl( fd_vme, WCR0, &regvalue ) )
+                               msyslog(LOG_ERR, "vme_start: WCR0 failed %m");
+                               break;
+               }
+       }
+
+       /*
+        * Allocate unit structure
+        */
+       vme = (struct vmeunit *)emalloc(sizeof(struct vmeunit));
+       bzero((char *)vme, sizeof(struct vmeunit));
+
+
+       /*
+        * Set up the structures
+        */
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t) vme;
+       pp->timestarted = current_time;
+
+       pp->io.clock_recv = vme_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd_vme;
+
+       /*
+        * All done.  Initialize a few random peer variables, then
+        * return success. Note that root delay and root dispersion are
+        * always zero for this clock.
+        */
+       peer->precision = VMEPRECISION;
+       memcpy(&pp->refid, USNOREFID,4);
+       return (1);
+}
+
+
+/*
+ * vme_shutdown - shut down a VME clock
+ */
+static void
+vme_shutdown(
+       int unit, 
+       struct peer *peer
+       )
+{
+       register struct vmeunit *vme;
+       struct refclockproc *pp;
+
+       /*
+        * Tell the I/O module to turn us off.  We're history.
+        */
+       pp = peer->procptr;
+       vme = (struct vmeunit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       pp->unitptr = NULL;
+       free(vme);
+       if (tfp_type == 2) bcStopPci(stfp_handle); 
+}
+
+
+/*
+ * vme_receive - receive data from the VME device.
+ *
+ * Note: This interface would be interrupt-driven. We don't use that
+ * now, but include a dummy routine for possible future adventures.
+ */
+static void
+vme_receive(
+       struct recvbuf *rbufp
+       )
+{
+}
+
+
+/*
+ * vme_poll - called by the transmit procedure
+ */
+static void
+vme_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct vmedate *tptr; 
+       struct vmeunit *vme;
+       struct refclockproc *pp;
+       time_t tloc;
+       struct tm *tadr;
+        
+       pp = peer->procptr;      
+       vme = (struct vmeunit *)pp->unitptr;        /* Here is the structure */
+
+       tptr = &vme->vmedata; 
+       if ((tptr = get_datumtime(tptr)) == NULL ) {
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       get_systime(&pp->lastrec);
+       pp->polls++;
+       vme->lasttime = current_time;
+
+       /*
+        * Get VME time and convert to timestamp format. 
+        * The year must come from the system clock.
+        */
+       
+         time(&tloc);
+         tadr = gmtime(&tloc);
+         tptr->year = (unsigned short)(tadr->tm_year + 1900);
+
+       sprintf(pp->a_lastcode, 
+               "%3.3d %2.2d:%2.2d:%2.2d.%.6ld %1d",
+               tptr->day, 
+               tptr->hr, 
+               tptr->mn,
+               tptr->sec, 
+               tptr->frac, 
+               tptr->status);
+
+       pp->lencode = (u_short) strlen(pp->a_lastcode);
+
+       pp->day =  tptr->day;
+       pp->hour =   tptr->hr;
+       pp->minute =  tptr->mn;
+       pp->second =  tptr->sec;
+       pp->nsec =   tptr->frac;        
+
+#ifdef DEBUG
+       if (debug)
+           printf("pp: %3d %02d:%02d:%02d.%06ld %1x\n",
+                  pp->day, pp->hour, pp->minute, pp->second,
+                  pp->nsec, tptr->status);
+#endif
+       if (tptr->status ) {       /*  Status 0 is locked to ref., 1 is not */
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       /*
+        * Now, compute the reference time value. Use the heavy
+        * machinery for the seconds and the millisecond field for the
+        * fraction when present. If an error in conversion to internal
+        * format is found, the program declares bad data and exits.
+        * Note that this code does not yet know how to do the years and
+        * relies on the clock-calendar chip for sanity.
+        */
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+}
+
+struct vmedate *
+get_datumtime(struct vmedate *time_vme)
+{
+       char cbuf[7];
+       struct btfp_time vts;
+       uint32_t btm[2];
+       uint8_t dmy;
+       
+       if ( time_vme == (struct vmedate *)NULL) {
+         time_vme = (struct vmedate *)malloc(sizeof(struct vmedate ));
+       }
+
+       switch (tfp_type) {
+               case 1:                         /* BSD, PCI, 2 32bit time words */
+                       if (ioctl(fd_vme, READTIME, &btm)) {
+                       msyslog(LOG_ERR, "get_bc63x error: %m");
+                               return(NULL);
+                       }
+                       tvme_fill(time_vme, btm);
+                       break;
+
+               case 2:                         /* Linux/Windows, PCI, 2 32bit time words */
+                       if (bcReadBinTime(stfp_handle, &btm[1], &btm[0], &dmy) == 0) {
+                       msyslog(LOG_ERR, "get_datumtime error: %m"); 
+                               return(NULL);
+                       }
+                       tvme_fill(time_vme, btm);
+                       break;
+
+               default:                        /* legacy bancomm card */
+
+                       if (ioctl(fd_vme, READTIME, &vts)) {
+                       msyslog(LOG_ERR, "get_datumtime error: %m");
+                               return(NULL);
+                       }
+                       /* Get day */
+                       sprintf(cbuf,"%3.3x", ((vts.btfp_time[ 0 ] & 0x000f) <<8) +
+                               ((vts.btfp_time[ 1 ] & 0xff00) >> 8));  
+                       time_vme->day = (unsigned short)atoi(cbuf);
+
+                       /* Get hour */
+                       sprintf(cbuf,"%2.2x", vts.btfp_time[ 1 ] & 0x00ff);
+
+                       time_vme->hr = (unsigned short)atoi(cbuf);
+
+                       /* Get minutes */
+                       sprintf(cbuf,"%2.2x", (vts.btfp_time[ 2 ] & 0xff00) >>8);
+                       time_vme->mn = (unsigned short)atoi(cbuf);
+
+                       /* Get seconds */
+                       sprintf(cbuf,"%2.2x", vts.btfp_time[ 2 ] & 0x00ff);
+                       time_vme->sec = (unsigned short)atoi(cbuf);
+
+                       /* Get microseconds.  Yes, we ignore the 0.1 microsecond digit so
+                                we can use the TVTOTSF function  later on...*/
+
+                       sprintf(cbuf,"%4.4x%2.2x", vts.btfp_time[ 3 ],
+                       vts.btfp_time[ 4 ]>>8);
+
+                       time_vme->frac = (u_long) atoi(cbuf);
+
+                       /* Get status bit */
+                       time_vme->status = (vts.btfp_time[0] & 0x0010) >>4;
+
+                       break;
+       }
+
+       if (time_vme->status) 
+               return ((void *)NULL);
+       else
+           return (time_vme);
+}
+/* Assign values to time_vme struct. Mostly for readability */
+void
+tvme_fill(struct vmedate *time_vme, uint32_t btm[2])
+{
+       struct tm maj;
+       uint32_t dmaj, dmin;
+
+       dmaj = btm[1];                  /* syntax sugar */
+       dmin = btm[0];
+
+       gmtime_r(&dmaj, &maj);
+       time_vme->day  = maj.tm_yday+1;
+       time_vme->hr   = maj.tm_hour;
+       time_vme->mn   = maj.tm_min;
+       time_vme->sec  = maj.tm_sec;
+       time_vme->frac = (dmin & 0x000fffff) * 1000; 
+       time_vme->frac += ((dmin & 0x00f00000) >> 20) * 100;
+       time_vme->status = (dmin & 0x01000000) >> 24;
+       return;
+}
+
+#else
+int refclock_bancomm_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_chronolog.c b/ntpd/refclock_chronolog.c
new file mode 100644 (file)
index 0000000..a1d131e
--- /dev/null
@@ -0,0 +1,341 @@
+/*
+ * refclock_chronolog - clock driver for Chronolog K-series WWVB receiver.
+ */
+
+/*
+ * Must interpolate back to local time.  Very annoying.
+ */
+#define GET_LOCALTIME
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_CHRONOLOG)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+/*
+ * This driver supports the Chronolog K-series WWVB receiver.
+ *
+ * Input format:
+ *
+ *     Y YY/MM/DD<cr><lf>
+ *      Z hh:mm:ss<cr><lf>
+ *
+ * YY/MM/DD -- what you'd expect.  This arrives a few seconds before the
+ * timestamp.
+ * hh:mm:ss -- what you'd expect.  We take time on the <cr>.
+ *
+ * Our Chronolog writes time out at 2400 bps 8/N/1, but it can be configured
+ * otherwise.  The clock seems to appear every 60 seconds, which doesn't make
+ * for good statistics collection.
+ *
+ * The original source of this module was the WWVB module.
+ */
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/chronolog%d" /* device name and unit */
+#define        SPEED232        B2400   /* uart speed (2400 baud) */
+#define        PRECISION       (-13)   /* precision assumed (about 100 us) */
+#define        REFID           "chronolog"     /* reference ID */
+#define        DESCRIPTION     "Chrono-log K" /* WRU */
+
+#define MONLIN         15      /* number of monitoring lines */
+
+/*
+ * Chrono-log unit control structure
+ */
+struct chronolog_unit {
+       u_char  tcswitch;       /* timecode switch */
+       l_fp    laststamp;      /* last receive timestamp */
+       u_char  lasthour;       /* last hour (for monitor) */
+       int     year;           /* Y2K-adjusted year */
+       int     day;            /* day-of-month */
+        int    month;          /* month-of-year */
+};
+
+/*
+ * Function prototypes
+ */
+static int     chronolog_start         P((int, struct peer *));
+static void    chronolog_shutdown      P((int, struct peer *));
+static void    chronolog_receive       P((struct recvbuf *));
+static void    chronolog_poll          P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_chronolog = {
+       chronolog_start,        /* start up driver */
+       chronolog_shutdown,     /* shut down driver */
+       chronolog_poll,         /* poll the driver -- a nice fabrication */
+       noentry,                /* not used */
+       noentry,                /* not used */
+       noentry,                /* not used */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * chronolog_start - open the devices and initialize data for processing
+ */
+static int
+chronolog_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct chronolog_unit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+
+       /*
+        * Open serial port. Don't bother with CLK line discipline, since
+        * it's not available.
+        */
+       (void)sprintf(device, DEVICE, unit);
+#ifdef DEBUG
+       if (debug)
+               printf ("starting Chronolog with device %s\n",device);
+#endif
+       if (!(fd = refclock_open(device, SPEED232, 0)))
+               return (0);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct chronolog_unit *)
+             emalloc(sizeof(struct chronolog_unit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct chronolog_unit));
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t)up;
+       pp->io.clock_recv = chronolog_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       return (1);
+}
+
+
+/*
+ * chronolog_shutdown - shut down the clock
+ */
+static void
+chronolog_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct chronolog_unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct chronolog_unit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * chronolog_receive - receive data from the serial interface
+ */
+static void
+chronolog_receive(
+       struct recvbuf *rbufp
+       )
+{
+       struct chronolog_unit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+
+       l_fp         trtmp;     /* arrival timestamp */
+       int          hours;     /* hour-of-day */
+       int          minutes;   /* minutes-past-the-hour */
+       int          seconds;   /* seconds */
+       int          temp;      /* int temp */
+       int          got_good;  /* got a good time flag */
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct chronolog_unit *)pp->unitptr;
+       temp = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp);
+
+       if (temp == 0) {
+               if (up->tcswitch == 0) {
+                       up->tcswitch = 1;
+                       up->laststamp = trtmp;
+               } else
+                   up->tcswitch = 0;
+               return;
+       }
+       pp->lencode = temp;
+       pp->lastrec = up->laststamp;
+       up->laststamp = trtmp;
+       up->tcswitch = 1;
+
+#ifdef DEBUG
+       if (debug)
+               printf("chronolog: timecode %d %s\n", pp->lencode,
+                   pp->a_lastcode);
+#endif
+
+       /*
+        * We get down to business. Check the timecode format and decode
+        * its contents. This code uses the first character to see whether
+        * we're looking at a date or a time.  We store data data across
+        * calls since it is transmitted a few seconds ahead of the
+        * timestamp.
+        */
+       got_good=0;
+       if (sscanf(pp->a_lastcode, "Y %d/%d/%d", &up->year,&up->month,&up->day))
+       {
+           /*
+            * Y2K convert the 2-digit year
+            */
+           up->year = up->year >= 69 ? up->year : up->year + 100;
+           return;
+       }
+       if (sscanf(pp->a_lastcode,"Z %02d:%02d:%02d",
+                  &hours,&minutes,&seconds) == 3)
+       {
+#ifdef GET_LOCALTIME
+           struct tm  local;
+           struct tm *gmtp;
+           time_t     unixtime;
+           int        adjyear;
+           int        adjmon;
+
+           /*
+            * Convert to GMT for sites that distribute localtime.  This
+             * means we have to do Y2K conversion on the 2-digit year;
+            * otherwise, we get the time wrong.
+            */
+           
+           local.tm_year  = up->year;
+           local.tm_mon   = up->month-1;
+           local.tm_mday  = up->day;
+           local.tm_hour  = hours;
+           local.tm_min   = minutes;
+           local.tm_sec   = seconds;
+           local.tm_isdst = -1;
+
+           unixtime = mktime (&local);
+           if ((gmtp = gmtime (&unixtime)) == NULL)
+           {
+               refclock_report (peer, CEVNT_FAULT);
+               return;
+           }
+           adjyear = gmtp->tm_year+1900;
+           adjmon  = gmtp->tm_mon+1;
+           pp->day = ymd2yd (adjyear, adjmon, gmtp->tm_mday);
+           pp->hour   = gmtp->tm_hour;
+           pp->minute = gmtp->tm_min;
+           pp->second = gmtp->tm_sec;
+#ifdef DEBUG
+           if (debug)
+               printf ("time is %04d/%02d/%02d %02d:%02d:%02d UTC\n",
+                       adjyear,adjmon,gmtp->tm_mday,pp->hour,pp->minute,
+                       pp->second);
+#endif
+           
+#else
+           /*
+            * For more rational sites distributing UTC
+            */
+           pp->day    = ymd2yd(year+1900,month,day);
+           pp->hour   = hours;
+           pp->minute = minutes;
+           pp->second = seconds;
+
+#endif
+           got_good=1;
+       }
+
+       if (!got_good)
+           return;
+
+
+       /*
+        * Process the new sample in the median filter and determine the
+        * timecode timestamp.
+        */
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       up->lasthour = pp->hour;
+}
+
+
+/*
+ * chronolog_poll - called by the transmit procedure
+ */
+static void
+chronolog_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       /*
+        * Time to poll the clock. The Chrono-log clock is supposed to
+        * respond to a 'T' by returning a timecode in the format(s)
+        * specified above.  Ours does (can?) not, but this seems to be
+        * an installation-specific problem.  This code is dyked out,
+        * but may be re-enabled if anyone ever finds a Chrono-log that
+        * actually listens to this command.
+        */
+#if 0
+       register struct chronolog_unit *up;
+       struct refclockproc *pp;
+       char pollchar;
+
+       pp = peer->procptr;
+       up = (struct chronolog_unit *)pp->unitptr;
+       if (peer->burst == 0 && peer->reach == 0)
+               refclock_report(peer, CEVNT_TIMEOUT);
+       if (up->linect > 0)
+               pollchar = 'R';
+       else
+               pollchar = 'T';
+       if (write(pp->io.fd, &pollchar, 1) != 1)
+               refclock_report(peer, CEVNT_FAULT);
+       else
+               pp->polls++;
+#endif
+}
+
+#else
+int refclock_chronolog_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_chu.c b/ntpd/refclock_chu.c
new file mode 100644 (file)
index 0000000..843e9aa
--- /dev/null
@@ -0,0 +1,1687 @@
+/*
+ * refclock_chu - clock driver for Canadian CHU time/frequency station
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_CHU)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+
+#ifdef HAVE_AUDIO
+#include "audio.h"
+#endif /* HAVE_AUDIO */
+
+#define ICOM   1               /* undefine to suppress ICOM code */
+
+#ifdef ICOM
+#include "icom.h"
+#endif /* ICOM */
+
+/*
+ * Audio CHU demodulator/decoder
+ *
+ * This driver synchronizes the computer time using data encoded in
+ * radio transmissions from Canadian time/frequency station CHU in
+ * Ottawa, Ontario. Transmissions are made continuously on 3330 kHz,
+ * 7335 kHz and 14670 kHz in upper sideband, compatible AM mode. An
+ * ordinary shortwave receiver can be tuned manually to one of these
+ * frequencies or, in the case of ICOM receivers, the receiver can be
+ * tuned automatically using this program as propagation conditions
+ * change throughout the day and night.
+ *
+ * The driver receives, demodulates and decodes the radio signals when
+ * connected to the audio codec of a suported workstation hardware and
+ * operating system. These include Solaris, SunOS, FreeBSD, NetBSD and
+ * Linux. In this implementation, only one audio driver and codec can be
+ * supported on a single machine.
+ *
+ * The driver can be compiled to use a Bell 103 compatible modem or
+ * modem chip to receive the radio signal and demodulate the data.
+ * Alternatively, the driver can be compiled to use the audio codec of
+ * the Sun workstation or another with compatible audio drivers. In the
+ * latter case, the driver implements the modem using DSP routines, so
+ * the radio can be connected directly to either the microphone on line
+ * input port. In either case, the driver decodes the data using a
+ * maximum likelihood technique which exploits the considerable degree
+ * of redundancy available to maximize accuracy and minimize errors.
+ *
+ * The CHU time broadcast includes an audio signal compatible with the
+ * Bell 103 modem standard (mark = 2225 Hz, space = 2025 Hz). It consist
+ * of nine, ten-character bursts transmitted at 300 bps and beginning
+ * each second from second 31 to second 39 of the minute. Each character
+ * consists of eight data bits plus one start bit and two stop bits to
+ * encode two hex digits. The burst data consist of five characters (ten
+ * hex digits) followed by a repeat of these characters. In format A,
+ * the characters are repeated in the same polarity; in format B, the
+ * characters are repeated in the opposite polarity.
+ *
+ * Format A bursts are sent at seconds 32 through 39 of the minute in
+ * hex digits
+ *
+ *     6dddhhmmss6dddhhmmss
+ *
+ * The first ten digits encode a frame marker (6) followed by the day
+ * (ddd), hour (hh in UTC), minute (mm) and the second (ss). Since
+ * format A bursts are sent during the third decade of seconds the tens
+ * digit of ss is always 3. The driver uses this to determine correct
+ * burst synchronization. These digits are then repeated with the same
+ * polarity.
+ *
+ * Format B bursts are sent at second 31 of the minute in hex digits
+ *
+ *     xdyyyyttaaxdyyyyttaa
+ *
+ * The first ten digits encode a code (x described below) followed by
+ * the DUT1 (d in deciseconds), Gregorian year (yyyy), difference TAI -
+ * UTC (tt) and daylight time indicator (aa) peculiar to Canada. These
+ * digits are then repeated with inverted polarity.
+ *
+ * The x is coded
+ *
+ * 1 Sign of DUT (0 = +)
+ * 2 Leap second warning. One second will be added.
+ * 4 Leap second warning. One second will be subtracted.
+ * 8 Even parity bit for this nibble.
+ *
+ * By design, the last stop bit of the last character in the burst
+ * coincides with 0.5 second. Since characters have 11 bits and are
+ * transmitted at 300 bps, the last stop bit of the first character
+ * coincides with 0.5 - 10 * 11/300 = 0.133 second. Depending on the
+ * UART, character interrupts can vary somewhere between the beginning
+ * of bit 9 and end of bit 11. These eccentricities can be corrected
+ * along with the radio propagation delay using fudge time 1.
+ *
+ * Debugging aids
+ *
+ * The timecode format used for debugging and data recording includes
+ * data helpful in diagnosing problems with the radio signal and serial
+ * connections. With debugging enabled (-d on the ntpd command line),
+ * the driver produces one line for each burst in two formats
+ * corresponding to format A and B. Following is format A:
+ *
+ *     n b f s m code
+ *
+ * where n is the number of characters in the burst (0-11), b the burst
+ * distance (0-40), f the field alignment (-1, 0, 1), s the
+ * synchronization distance (0-16), m the burst number (2-9) and code
+ * the burst characters as received. Note that the hex digits in each
+ * character are reversed, so the burst
+ *
+ *     10 38 0 16 9 06851292930685129293
+ *
+ * is interpreted as containing 11 characters with burst distance 38,
+ * field alignment 0, synchronization distance 16 and burst number 9.
+ * The nibble-swapped timecode shows day 58, hour 21, minute 29 and
+ * second 39.
+ *
+ * When the audio driver is compiled, format A is preceded by
+ * the current gain (0-255) and relative signal level (0-9999). The
+ * receiver folume control should be set so that the gain is somewhere
+ * near the middle of the range 0-255, which results in a signal level
+ * near 1000.
+ *
+ * Following is format B:
+ * 
+ *     n b s code
+ *
+ * where n is the number of characters in the burst (0-11), b the burst
+ * distance (0-40), s the synchronization distance (0-40) and code the
+ * burst characters as received. Note that the hex digits in each
+ * character are reversed and the last ten digits inverted, so the burst
+ *
+ *     11 40 1091891300ef6e76ecff
+ *
+ * is interpreted as containing 11 characters with burst distance 40.
+ * The nibble-swapped timecode shows DUT1 +0.1 second, year 1998 and TAI
+ * - UTC 31 seconds.
+ *
+ * In addition to the above, the reference timecode is updated and
+ * written to the clockstats file and debug score after the last burst
+ * received in the minute. The format is
+ *
+ *     qq yyyy ddd hh:mm:ss nn dd tt
+ *
+ * where qq are the error flags, as described below, yyyy is the year,
+ * ddd the day, hh:mm:ss the time of day, nn the number of format A
+ * bursts received during the previous minute, dd the decoding distance
+ * and tt the number of timestamps. The error flags are cleared after
+ * every update.
+ *
+ * Fudge factors
+ *
+ * For accuracies better than the low millisceconds, fudge time1 can be
+ * set to the radio propagation delay from CHU to the receiver. This can
+ * be done conviently using the minimuf program.
+ *
+ * Fudge flag4 causes the dubugging output described above to be
+ * recorded in the clockstats file. When the audio driver is compiled,
+ * fudge flag2 selects the audio input port, where 0 is the mike port
+ * (default) and 1 is the line-in port. It does not seem useful to
+ * select the compact disc player port. Fudge flag3 enables audio
+ * monitoring of the input signal. For this purpose, the monitor gain is
+ * set to a default value.
+ *
+ * The audio codec code is normally compiled in the driver if the
+ * architecture supports it (HAVE_AUDIO defined), but is used only if
+ * the link /dev/chu_audio is defined and valid. The serial port code is
+ * always compiled in the driver, but is used only if the autdio codec
+ * is not available and the link /dev/chu%d is defined and valid.
+ *
+ * The ICOM code is normally compiled in the driver if selected (ICOM
+ * defined), but is used only if the link /dev/icom%d is defined and
+ * valid and the mode keyword on the server configuration command
+ * specifies a nonzero mode (ICOM ID select code). The C-IV speed is
+ * 9600 bps if the high order 0x80 bit of the mode is zero and 1200 bps
+ * if one. The C-IV trace is turned on if the debug level is greater
+ * than one.
+ */
+/*
+ * Interface definitions
+ */
+#define        SPEED232        B300    /* uart speed (300 baud) */
+#define        PRECISION       (-10)   /* precision assumed (about 1 ms) */
+#define        REFID           "CHU"   /* reference ID */
+#define        DEVICE          "/dev/chu%d" /* device name and unit */
+#define        SPEED232        B300    /* UART speed (300 baud) */
+#ifdef ICOM
+#define TUNE           .001    /* offset for narrow filter (kHz) */
+#define DWELL          5       /* minutes in a probe cycle */
+#define NCHAN          3       /* number of channels */
+#define ISTAGE         3       /* number of integrator stages */
+#endif /* ICOM */
+
+#ifdef HAVE_AUDIO
+/*
+ * Audio demodulator definitions
+ */
+#define SECOND         8000    /* nominal sample rate (Hz) */
+#define BAUD           300     /* modulation rate (bps) */
+#define OFFSET         128     /* companded sample offset */
+#define SIZE           256     /* decompanding table size */
+#define        MAXAMP          6000.   /* maximum signal level */
+#define        MAXCLP          100     /* max clips above reference per s */
+#define LIMIT          1000.   /* soft limiter threshold */
+#define AGAIN          6.      /* baseband gain */
+#define LAG            10      /* discriminator lag */
+#define        DEVICE_AUDIO    "/dev/audio" /* device name */
+#define        DESCRIPTION     "CHU Audio/Modem Receiver" /* WRU */
+#define        AUDIO_BUFSIZ    240     /* audio buffer size (30 ms) */
+#else
+#define        DESCRIPTION     "CHU Modem Receiver" /* WRU */
+#endif /* HAVE_AUDIO */
+
+/*
+ * Decoder definitions
+ */
+#define CHAR           (11. / 300.) /* character time (s) */
+#define        FUDGE           .185    /* offset to first stop bit (s) */
+#define BURST          11      /* max characters per burst */
+#define MINCHAR                9       /* min characters per burst */
+#define MINDIST                28      /* min burst distance (of 40)  */
+#define MINBURST       4       /* min bursts in minute */
+#define MINSYNC                8       /* min sync distance (of 16) */
+#define MINSTAMP       20      /* min timestamps (of 60) */
+#define METRIC         50.     /* min channel metric */
+#define PANIC          1440    /* panic timeout (m) */
+#define HOLD           30      /* reach hold (m) */
+
+/*
+ * Hex extension codes (>= 16)
+ */
+#define HEX_MISS       16      /* miss _ */
+#define HEX_SOFT       17      /* soft error * */
+#define HEX_HARD       18      /* hard error = */
+
+/*
+ * Status bits (status)
+ */
+#define RUNT           0x0001  /* runt burst */
+#define NOISE          0x0002  /* noise burst */
+#define BFRAME         0x0004  /* invalid format B frame sync */
+#define BFORMAT                0x0008  /* invalid format B data */
+#define AFRAME         0x0010  /* invalid format A frame sync */
+#define AFORMAT                0x0020  /* invalid format A data */
+#define DECODE         0x0040  /* invalid data decode */
+#define STAMP          0x0080  /* too few timestamps */
+#define AVALID         0x0100  /* valid A frame */
+#define BVALID         0x0200  /* valid B frame */
+#define INSYNC         0x0400  /* clock synchronized */
+
+/*
+ * Alarm status bits (alarm)
+ *
+ * These alarms are set at the end of a minute in which at least one
+ * burst was received. SYNERR is raised if the AFRAME or BFRAME status
+ * bits are set during the minute, FMTERR is raised if the AFORMAT or
+ * BFORMAT status bits are set, DECERR is raised if the DECODE status
+ * bit is set and TSPERR is raised if the STAMP status bit is set.
+ */
+#define SYNERR         0x01    /* frame sync error */
+#define FMTERR         0x02    /* data format error */
+#define DECERR         0x04    /* data decoding error */
+#define TSPERR         0x08    /* insufficient data */
+
+#ifdef HAVE_AUDIO
+/*
+ * Maximum likelihood UART structure. There are eight of these
+ * corresponding to the number of phases.
+ */ 
+struct surv {
+       double  shift[12];      /* mark register */
+       double  es_max, es_min; /* max/min envelope signals */
+       double  dist;           /* sample distance */
+       int     uart;           /* decoded character */
+};
+#endif /* HAVE_AUDIO */
+
+#ifdef ICOM
+/*
+ * CHU station structure. There are three of these corresponding to the
+ * three frequencies.
+ */
+struct xmtr {
+       double  integ[ISTAGE];  /* circular integrator */
+       double  metric;         /* integrator sum */
+       int     iptr;           /* integrator pointer */
+       int     probe;          /* dwells since last probe */
+};
+#endif /* ICOM */
+
+/*
+ * CHU unit control structure
+ */
+struct chuunit {
+       u_char  decode[20][16]; /* maximum likelihood decoding matrix */
+       l_fp    cstamp[BURST];  /* character timestamps */
+       l_fp    tstamp[MAXSTAGE]; /* timestamp samples */
+       l_fp    timestamp;      /* current buffer timestamp */
+       l_fp    laststamp;      /* last buffer timestamp */
+       l_fp    charstamp;      /* character time as a l_fp */
+       int     errflg;         /* error flags */
+       int     status;         /* status bits */
+       char    ident[5];       /* station ID and channel */
+#ifdef ICOM
+       int     fd_icom;        /* ICOM file descriptor */
+       int     chan;           /* data channel */
+       int     achan;          /* active channel */
+       int     dwell;          /* dwell cycle */
+       struct xmtr xmtr[NCHAN]; /* station metric */
+#endif /* ICOM */
+
+       /*
+        * Character burst variables
+        */
+       int     cbuf[BURST];    /* character buffer */
+       int     ntstamp;        /* number of timestamp samples */
+       int     ndx;            /* buffer start index */
+       int     prevsec;        /* previous burst second */
+       int     burdist;        /* burst distance */
+       int     syndist;        /* sync distance */
+       int     burstcnt;       /* format A bursts this minute */
+
+       /*
+        * Format particulars
+        */
+       int     leap;           /* leap/dut code */
+       int     dut;            /* UTC1 correction */
+       int     tai;            /* TAI - UTC correction */
+       int     dst;            /* Canadian DST code */
+
+#ifdef HAVE_AUDIO
+       /*
+        * Audio codec variables
+        */
+       int     fd_audio;       /* audio port file descriptor */
+       double  comp[SIZE];     /* decompanding table */
+       int     port;           /* codec port */
+       int     gain;           /* codec gain */
+       int     mongain;        /* codec monitor gain */
+       int     clipcnt;        /* sample clip count */
+       int     seccnt;         /* second interval counter */
+
+       /*
+        * Modem variables
+        */
+       l_fp    tick;           /* audio sample increment */
+       double  bpf[9];         /* IIR bandpass filter */
+       double  disc[LAG];      /* discriminator shift register */
+       double  lpf[27];        /* FIR lowpass filter */
+       double  monitor;        /* audio monitor */
+       double  maxsignal;      /* signal level */
+       int     discptr;        /* discriminator pointer */
+
+       /*
+        * Maximum likelihood UART variables
+        */
+       double  baud;           /* baud interval */
+       struct surv surv[8];    /* UART survivor structures */
+       int     decptr;         /* decode pointer */
+       int     dbrk;           /* holdoff counter */
+#endif /* HAVE_AUDIO */
+};
+
+/*
+ * Function prototypes
+ */
+static int     chu_start       P((int, struct peer *));
+static void    chu_shutdown    P((int, struct peer *));
+static void    chu_receive     P((struct recvbuf *));
+static void    chu_poll        P((int, struct peer *));
+
+/*
+ * More function prototypes
+ */
+static void    chu_decode      P((struct peer *, int));
+static void    chu_burst       P((struct peer *));
+static void    chu_clear       P((struct peer *));
+static void    chu_a           P((struct peer *, int));
+static void    chu_b           P((struct peer *, int));
+static int     chu_dist        P((int, int));
+static double  chu_major       P((struct peer *));
+#ifdef HAVE_AUDIO
+static void    chu_uart        P((struct surv *, double));
+static void    chu_rf          P((struct peer *, double));
+static void    chu_gain        P((struct peer *));
+static void    chu_audio_receive P((struct recvbuf *rbufp));
+#endif /* HAVE_AUDIO */
+#ifdef ICOM
+static int     chu_newchan     P((struct peer *, double));
+#endif /* ICOM */
+static void    chu_serial_receive P((struct recvbuf *rbufp));
+
+/*
+ * Global variables
+ */
+static char hexchar[] = "0123456789abcdef_*=";
+
+#ifdef ICOM
+/*
+ * Note the tuned frequencies are 1 kHz higher than the carrier. CHU
+ * transmits on USB with carrier so we can use AM and the narrow SSB
+ * filter.
+ */
+static double qsy[NCHAN] = {3.330, 7.335, 14.670}; /* freq (MHz) */
+#endif /* ICOM */
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_chu = {
+       chu_start,              /* start up driver */
+       chu_shutdown,           /* shut down driver */
+       chu_poll,               /* transmit poll message */
+       noentry,                /* not used (old chu_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old chu_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * chu_start - open the devices and initialize data for processing
+ */
+static int
+chu_start(
+       int     unit,           /* instance number (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct chuunit *up;
+       struct refclockproc *pp;
+       char device[20];        /* device name */
+       int     fd;             /* file descriptor */
+#ifdef ICOM
+       int     temp;
+#endif /* ICOM */
+#ifdef HAVE_AUDIO
+       int     fd_audio;       /* audio port file descriptor */
+       int     i;              /* index */
+       double  step;           /* codec adjustment */
+
+       /*
+        * Open audio device.
+        */
+       fd_audio = audio_init(DEVICE_AUDIO, AUDIO_BUFSIZ, unit);
+#ifdef DEBUG
+       if (fd_audio > 0 && debug)
+               audio_show();
+#endif
+
+       /*
+        * Open serial port in raw mode.
+        */
+       if (fd_audio > 0) {
+               fd = fd_audio;
+       } else {
+               sprintf(device, DEVICE, unit);
+               fd = refclock_open(device, SPEED232, LDISC_RAW);
+       }
+#else /* HAVE_AUDIO */
+
+       /*
+        * Open serial port in raw mode.
+        */
+       sprintf(device, DEVICE, unit);
+       fd = refclock_open(device, SPEED232, LDISC_RAW);
+#endif /* HAVE_AUDIO */
+       if (fd <= 0)
+               return (0);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct chuunit *)
+             emalloc(sizeof(struct chuunit)))) {
+               close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct chuunit));
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t)up;
+       pp->io.clock_recv = chu_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               close(fd);
+               free(up);
+               return (0);
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       strcpy(up->ident, "CHU");
+       memcpy(&peer->refid, up->ident, 4); 
+       DTOLFP(CHAR, &up->charstamp);
+#ifdef HAVE_AUDIO
+
+       /*
+        * The companded samples are encoded sign-magnitude. The table
+        * contains all the 256 values in the interest of speed. We do
+        * this even if the audio codec is not available. C'est la lazy.
+        */
+       up->fd_audio = fd_audio;
+       up->gain = 127;
+       up->comp[0] = up->comp[OFFSET] = 0.;
+       up->comp[1] = 1; up->comp[OFFSET + 1] = -1.;
+       up->comp[2] = 3; up->comp[OFFSET + 2] = -3.;
+       step = 2.;
+       for (i = 3; i < OFFSET; i++) {
+               up->comp[i] = up->comp[i - 1] + step;
+               up->comp[OFFSET + i] = -up->comp[i];
+                if (i % 16 == 0)
+                       step *= 2.;
+       }
+       DTOLFP(1. / SECOND, &up->tick);
+#endif /* HAVE_AUDIO */
+#ifdef ICOM
+       temp = 0;
+#ifdef DEBUG
+       if (debug > 1)
+               temp = P_TRACE;
+#endif
+       if (peer->ttl > 0) {
+               if (peer->ttl & 0x80)
+                       up->fd_icom = icom_init("/dev/icom", B1200,
+                           temp);
+               else
+                       up->fd_icom = icom_init("/dev/icom", B9600,
+                           temp);
+       }
+       if (up->fd_icom > 0) {
+               if (chu_newchan(peer, 0) != 0) {
+                       NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                           msyslog(LOG_NOTICE,
+                           "icom: radio not found");
+                       up->errflg = CEVNT_FAULT;
+                       close(up->fd_icom);
+                       up->fd_icom = 0;
+               } else {
+                       NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                           msyslog(LOG_NOTICE,
+                           "icom: autotune enabled");
+               }
+       }
+#endif /* ICOM */
+       return (1);
+}
+
+
+/*
+ * chu_shutdown - shut down the clock
+ */
+static void
+chu_shutdown(
+       int     unit,           /* instance number (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct chuunit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+       if (up == NULL)
+               return;
+
+       io_closeclock(&pp->io);
+#ifdef ICOM
+       if (up->fd_icom > 0)
+               close(up->fd_icom);
+#endif /* ICOM */
+       free(up);
+}
+
+
+/*
+ * chu_receive - receive data from the audio or serial device
+ */
+static void
+chu_receive(
+       struct recvbuf *rbufp   /* receive buffer structure pointer */
+       )
+{
+#ifdef HAVE_AUDIO
+       struct chuunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * If the audio codec is warmed up, the buffer contains codec
+        * samples which need to be demodulated and decoded into CHU
+        * characters using the software UART. Otherwise, the buffer
+        * contains CHU characters from the serial port, so the software
+        * UART is bypassed. In this case the CPU will probably run a
+        * few degrees cooler.
+        */
+       if (up->fd_audio > 0)
+               chu_audio_receive(rbufp);
+       else
+               chu_serial_receive(rbufp);
+#else
+       chu_serial_receive(rbufp);
+#endif /* HAVE_AUDIO */
+}
+
+
+#ifdef HAVE_AUDIO
+/*
+ * chu_audio_receive - receive data from the audio device
+ */
+static void
+chu_audio_receive(
+       struct recvbuf *rbufp   /* receive buffer structure pointer */
+       )
+{
+       struct chuunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+
+       double  sample;         /* codec sample */
+       u_char  *dpt;           /* buffer pointer */
+       int     bufcnt;         /* buffer counter */
+       l_fp    ltemp;          /* l_fp temp */
+
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * Main loop - read until there ain't no more. Note codec
+        * samples are bit-inverted.
+        */
+       DTOLFP((double)rbufp->recv_length / SECOND, &ltemp);
+       L_SUB(&rbufp->recv_time, &ltemp);
+       up->timestamp = rbufp->recv_time;
+       dpt = rbufp->recv_buffer;
+       for (bufcnt = 0; bufcnt < rbufp->recv_length; bufcnt++) {
+               sample = up->comp[~*dpt++ & 0xff];
+
+               /*
+                * Clip noise spikes greater than MAXAMP. If no clips,
+                * increase the gain a tad; if the clips are too high, 
+                * decrease a tad.
+                */
+               if (sample > MAXAMP) {
+                       sample = MAXAMP;
+                       up->clipcnt++;
+               } else if (sample < -MAXAMP) {
+                       sample = -MAXAMP;
+                       up->clipcnt++;
+               }
+               chu_rf(peer, sample);
+               L_ADD(&up->timestamp, &up->tick);
+
+               /*
+                * Once each second ride gain.
+                */
+               up->seccnt = (up->seccnt + 1) % SECOND;
+               if (up->seccnt == 0) {
+                       pp->second = (pp->second + 1) % 60;
+                       chu_gain(peer);
+               }
+       }
+
+       /*
+        * Set the input port and monitor gain for the next buffer.
+        */
+       if (pp->sloppyclockflag & CLK_FLAG2)
+               up->port = 2;
+       else
+               up->port = 1;
+       if (pp->sloppyclockflag & CLK_FLAG3)
+               up->mongain = MONGAIN;
+       else
+               up->mongain = 0;
+}
+
+
+/*
+ * chu_rf - filter and demodulate the FSK signal
+ *
+ * This routine implements a 300-baud Bell 103 modem with mark 2225 Hz
+ * and space 2025 Hz. It uses a bandpass filter followed by a soft
+ * limiter, FM discriminator and lowpass filter. A maximum likelihood
+ * decoder samples the baseband signal at eight times the baud rate and
+ * detects the start bit of each character.
+ *
+ * The filters are built for speed, which explains the rather clumsy
+ * code. Hopefully, the compiler will efficiently implement the move-
+ * and-muiltiply-and-add operations.
+ */
+static void
+chu_rf(
+       struct peer *peer,      /* peer structure pointer */
+       double  sample          /* analog sample */
+       )
+{
+       struct refclockproc *pp;
+       struct chuunit *up;
+       struct surv *sp;
+
+       /*
+        * Local variables
+        */
+       double  signal;         /* bandpass signal */
+       double  limit;          /* limiter signal */
+       double  disc;           /* discriminator signal */
+       double  lpf;            /* lowpass signal */
+       double  span;           /* UART signal span */
+       double  dist;           /* UART signal distance */
+       int     i, j;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * Bandpass filter. 4th-order elliptic, 500-Hz bandpass centered
+        * at 2125 Hz. Passband ripple 0.3 dB, stopband ripple 50 dB.
+        */
+       signal = (up->bpf[8] = up->bpf[7]) * 5.844676e-01;
+       signal += (up->bpf[7] = up->bpf[6]) * 4.884860e-01;
+       signal += (up->bpf[6] = up->bpf[5]) * 2.704384e+00;
+       signal += (up->bpf[5] = up->bpf[4]) * 1.645032e+00;
+       signal += (up->bpf[4] = up->bpf[3]) * 4.644557e+00;
+       signal += (up->bpf[3] = up->bpf[2]) * 1.879165e+00;
+       signal += (up->bpf[2] = up->bpf[1]) * 3.522634e+00;
+       signal += (up->bpf[1] = up->bpf[0]) * 7.315738e-01;
+       up->bpf[0] = sample - signal;
+       signal = up->bpf[0] * 6.176213e-03
+           + up->bpf[1] * 3.156599e-03
+           + up->bpf[2] * 7.567487e-03
+           + up->bpf[3] * 4.344580e-03
+           + up->bpf[4] * 1.190128e-02
+           + up->bpf[5] * 4.344580e-03
+           + up->bpf[6] * 7.567487e-03
+           + up->bpf[7] * 3.156599e-03
+           + up->bpf[8] * 6.176213e-03;
+
+       up->monitor = signal / 4.;      /* note monitor after filter */
+
+       /*
+        * Soft limiter/discriminator. The 11-sample discriminator lag
+        * interval corresponds to three cycles of 2125 Hz, which
+        * requires the sample frequency to be 2125 * 11 / 3 = 7791.7
+        * Hz. The discriminator output varies +-0.5 interval for input
+        * frequency 2025-2225 Hz. However, we don't get to sample at
+        * this frequency, so the discriminator output is biased. Life
+        * at 8000 Hz sucks.
+        */
+       limit = signal;
+       if (limit > LIMIT)
+               limit = LIMIT;
+       else if (limit < -LIMIT)
+               limit = -LIMIT;
+       disc = up->disc[up->discptr] * -limit;
+       up->disc[up->discptr] = limit;
+       up->discptr = (up->discptr + 1 ) % LAG;
+       if (disc >= 0)
+               disc = SQRT(disc);
+       else
+               disc = -SQRT(-disc);
+
+       /*
+        * Lowpass filter. Raised cosine, Ts = 1 / 300, beta = 0.1.
+        */
+       lpf = (up->lpf[26] = up->lpf[25]) * 2.538771e-02;
+       lpf += (up->lpf[25] = up->lpf[24]) * 1.084671e-01;
+       lpf += (up->lpf[24] = up->lpf[23]) * 2.003159e-01;
+       lpf += (up->lpf[23] = up->lpf[22]) * 2.985303e-01;
+       lpf += (up->lpf[22] = up->lpf[21]) * 4.003697e-01;
+       lpf += (up->lpf[21] = up->lpf[20]) * 5.028552e-01;
+       lpf += (up->lpf[20] = up->lpf[19]) * 6.028795e-01;
+       lpf += (up->lpf[19] = up->lpf[18]) * 6.973249e-01;
+       lpf += (up->lpf[18] = up->lpf[17]) * 7.831828e-01;
+       lpf += (up->lpf[17] = up->lpf[16]) * 8.576717e-01;
+       lpf += (up->lpf[16] = up->lpf[15]) * 9.183463e-01;
+       lpf += (up->lpf[15] = up->lpf[14]) * 9.631951e-01;
+       lpf += (up->lpf[14] = up->lpf[13]) * 9.907208e-01;
+       lpf += (up->lpf[13] = up->lpf[12]) * 1.000000e+00;
+       lpf += (up->lpf[12] = up->lpf[11]) * 9.907208e-01;
+       lpf += (up->lpf[11] = up->lpf[10]) * 9.631951e-01;
+       lpf += (up->lpf[10] = up->lpf[9]) * 9.183463e-01;
+       lpf += (up->lpf[9] = up->lpf[8]) * 8.576717e-01;
+       lpf += (up->lpf[8] = up->lpf[7]) * 7.831828e-01;
+       lpf += (up->lpf[7] = up->lpf[6]) * 6.973249e-01;
+       lpf += (up->lpf[6] = up->lpf[5]) * 6.028795e-01;
+       lpf += (up->lpf[5] = up->lpf[4]) * 5.028552e-01;
+       lpf += (up->lpf[4] = up->lpf[3]) * 4.003697e-01;
+       lpf += (up->lpf[3] = up->lpf[2]) * 2.985303e-01;
+       lpf += (up->lpf[2] = up->lpf[1]) * 2.003159e-01;
+       lpf += (up->lpf[1] = up->lpf[0]) * 1.084671e-01;
+       lpf += up->lpf[0] = disc * 2.538771e-02;
+
+       /*
+        * Maximum likelihood decoder. The UART updates each of the
+        * eight survivors and determines the span, slice level and
+        * tentative decoded character. Valid 11-bit characters are
+        * framed so that bit 1 and bit 11 (stop bits) are mark and bit
+        * 2 (start bit) is space. When a valid character is found, the
+        * survivor with maximum distance determines the final decoded
+        * character.
+        */
+       up->baud += 1. / SECOND;
+       if (up->baud > 1. / (BAUD * 8.)) {
+               up->baud -= 1. / (BAUD * 8.);
+               sp = &up->surv[up->decptr];
+               span = sp->es_max - sp->es_min;
+               up->maxsignal += (span - up->maxsignal) / 80.;
+               if (up->dbrk > 0) {
+                       up->dbrk--;
+               } else if ((sp->uart & 0x403) == 0x401 && span > 1000.)
+                   {
+                       dist = 0;
+                       j = 0;
+                       for (i = 0; i < 8; i++) {
+                               if (up->surv[i].dist > dist) {
+                                       dist = up->surv[i].dist;
+                                       j = i;
+                               }
+                       }
+                       chu_decode(peer, (up->surv[j].uart >> 2) &
+                           0xff);
+                       up->dbrk = 80;
+               }
+               up->decptr = (up->decptr + 1) % 8;
+               chu_uart(sp, -lpf * AGAIN);
+       }
+}
+
+
+/*
+ * chu_uart - maximum likelihood UART
+ *
+ * This routine updates a shift register holding the last 11 envelope
+ * samples. It then computes the slice level and span over these samples
+ * and determines the tentative data bits and distance. The calling
+ * program selects over the last eight survivors the one with maximum
+ * distance to determine the decoded character.
+ */
+static void
+chu_uart(
+       struct surv *sp,        /* survivor structure pointer */
+       double  sample          /* baseband signal */
+       )
+{
+       double  es_max, es_min; /* max/min envelope */
+       double  slice;          /* slice level */
+       double  dist;           /* distance */
+       double  dtemp;
+       int     i;
+
+       /*
+        * Save the sample and shift right. At the same time, measure
+        * the maximum and minimum over all eleven samples.
+        */
+       es_max = -1e6;
+       es_min = 1e6;
+       sp->shift[0] = sample;
+       for (i = 11; i > 0; i--) {
+               sp->shift[i] = sp->shift[i - 1];
+               if (sp->shift[i] > es_max)
+                       es_max = sp->shift[i];
+               if (sp->shift[i] < es_min)
+                       es_min = sp->shift[i];
+       }
+
+       /*
+        * Determine the slice level midway beteen the maximum and
+        * minimum and the span as the maximum less the minimum. Compute
+        * the distance on the assumption the first and last bits must
+        * be mark, the second space and the rest either mark or space.
+        */ 
+       slice = (es_max + es_min) / 2.;
+       dist = 0;
+       sp->uart = 0;
+       for (i = 1; i < 12; i++) {
+               sp->uart <<= 1;
+               dtemp = sp->shift[i];
+               if (dtemp > slice)
+                       sp->uart |= 0x1;
+               if (i == 1 || i == 11) {
+                       dist += dtemp - es_min;
+               } else if (i == 10) {
+                       dist += es_max - dtemp;
+               } else {
+                       if (dtemp > slice)
+                               dist += dtemp - es_min;
+                       else
+                               dist += es_max - dtemp;
+               }
+       }
+       sp->es_max = es_max;
+       sp->es_min = es_min;
+       sp->dist = dist / (11 * (es_max - es_min));
+}
+#endif /* HAVE_AUDIO */
+
+
+/*
+ * chu_serial_receive - receive data from the serial device
+ */
+static void
+chu_serial_receive(
+       struct recvbuf *rbufp   /* receive buffer structure pointer */
+       )
+{
+       struct chuunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+
+       u_char  *dpt;           /* receive buffer pointer */
+
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp.
+        */
+       up->timestamp = rbufp->recv_time;
+       dpt = (u_char *)&rbufp->recv_space;
+       chu_decode(peer, *dpt);
+}
+
+
+/*
+ * chu_decode - decode the character data
+ */
+static void
+chu_decode(
+       struct peer *peer,      /* peer structure pointer */
+       int     hexhex          /* data character */
+       )
+{
+       struct refclockproc *pp;
+       struct chuunit *up;
+
+       l_fp    tstmp;          /* timestamp temp */
+       double  dtemp;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * If the interval since the last character is greater than the
+        * longest burst, process the last burst and start a new one. If
+        * the interval is less than this but greater than two
+        * characters, consider this a noise burst and reject it.
+        */
+       tstmp = up->timestamp;
+       if (L_ISZERO(&up->laststamp))
+               up->laststamp = up->timestamp;
+       L_SUB(&tstmp, &up->laststamp);
+       up->laststamp = up->timestamp;
+       LFPTOD(&tstmp, dtemp);
+       if (dtemp > BURST * CHAR) {
+               chu_burst(peer);
+               up->ndx = 0;
+       } else if (dtemp > 2.5 * CHAR) {
+               up->ndx = 0;
+       }
+
+       /*
+        * Append the character to the current burst and append the
+        * timestamp to the timestamp list.
+        */
+       if (up->ndx < BURST) {
+               up->cbuf[up->ndx] = hexhex & 0xff;
+               up->cstamp[up->ndx] = up->timestamp;
+               up->ndx++;
+
+       }
+}
+
+
+/*
+ * chu_burst - search for valid burst format
+ */
+static void
+chu_burst(
+       struct peer *peer
+       )
+{
+       struct chuunit *up;
+       struct refclockproc *pp;
+
+       int     i;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * Correlate a block of five characters with the next block of
+        * five characters. The burst distance is defined as the number
+        * of bits that match in the two blocks for format A and that
+        * match the inverse for format B.
+        */
+       if (up->ndx < MINCHAR) {
+               up->status |= RUNT;
+               return;
+       }
+       up->burdist = 0;
+       for (i = 0; i < 5 && i < up->ndx - 5; i++)
+               up->burdist += chu_dist(up->cbuf[i], up->cbuf[i + 5]);
+
+       /*
+        * If the burst distance is at least MINDIST, this must be a
+        * format A burst; if the value is not greater than -MINDIST, it
+        * must be a format B burst. If the B burst is perfect, we
+        * believe it; otherwise, it is a noise burst and of no use to
+        * anybody.
+        */
+       if (up->burdist >= MINDIST) {
+               chu_a(peer, up->ndx);
+       } else if (up->burdist <= -MINDIST) {
+               chu_b(peer, up->ndx);
+       } else {
+               up->status |= NOISE;
+               return;
+       }
+
+       /*
+        * If this is a valid burst, wait a guard time of ten seconds to
+        * allow for more bursts, then arm the poll update routine to
+        * process the minute. Don't do this if this is called from the
+        * timer interrupt routine.
+        */
+       if (peer->outdate != current_time)
+               peer->nextdate = current_time + 10;
+}
+
+
+/*
+ * chu_b - decode format B burst
+ */
+static void
+chu_b(
+       struct peer *peer,
+       int     nchar
+       )
+{
+       struct  refclockproc *pp;
+       struct  chuunit *up;
+
+       u_char  code[11];       /* decoded timecode */
+       char    tbuf[80];       /* trace buffer */
+       l_fp    offset;         /* timestamp offset */
+       int     i;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * In a format B burst, a character is considered valid only if
+        * the first occurrence matches the last occurrence. The burst
+        * is considered valid only if all characters are valid; that
+        * is, only if the distance is 40. Note that once a valid frame
+        * has been found errors are ignored.
+        */
+       sprintf(tbuf, "chuB %04x %2d %2d ", up->status, nchar,
+           -up->burdist);
+       for (i = 0; i < nchar; i++)
+               sprintf(&tbuf[strlen(tbuf)], "%02x", up->cbuf[i]);
+       if (pp->sloppyclockflag & CLK_FLAG4)
+               record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+       if (debug)
+               printf("%s\n", tbuf);
+#endif
+       if (up->burdist > -40) {
+               up->status |= BFRAME;
+               return;
+       }
+       up->status |= BVALID;
+
+       /*
+        * Convert the burst data to internal format. If this succeeds,
+        * save the timestamps for later.
+        */
+       for (i = 0; i < 5; i++) {
+               code[2 * i] = hexchar[up->cbuf[i] & 0xf];
+               code[2 * i + 1] = hexchar[(up->cbuf[i] >>
+                   4) & 0xf];
+       }
+       if (sscanf((char *)code, "%1x%1d%4d%2d%2x", &up->leap, &up->dut,
+           &pp->year, &up->tai, &up->dst) != 5) {
+               up->status |= BFORMAT;
+               return;
+       }
+       if (up->leap & 0x8)
+               up->dut = -up->dut;
+       offset.l_ui = 31;
+       offset.l_f = 0;
+       for (i = 0; i < nchar && i < 10; i++) {
+               up->tstamp[up->ntstamp] = up->cstamp[i];
+               L_SUB(&up->tstamp[up->ntstamp], &offset);
+               L_ADD(&offset, &up->charstamp);
+               if (up->ntstamp < MAXSTAGE - 1) 
+                       up->ntstamp++;
+       }
+}
+
+
+/*
+ * chu_a - decode format A burst
+ */
+static void
+chu_a(
+       struct peer *peer,
+       int nchar
+       )
+{
+       struct refclockproc *pp;
+       struct chuunit *up;
+
+       char    tbuf[80];       /* trace buffer */
+       l_fp    offset;         /* timestamp offset */
+       int     val;            /* distance */
+       int     temp;
+       int     i, j, k;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * Determine correct burst phase. There are three cases
+        * corresponding to in-phase, one character early or one
+        * character late. These cases are distinguished by the position
+        * of the framing digits x6 at positions 0 and 5 and x3 at
+        * positions 4 and 9. The correct phase is when the distance
+        * relative to the framing digits is maximum. The burst is valid
+        * only if the maximum distance is at least MINSYNC.
+        */
+       up->syndist = k = 0;
+       val = -16;
+       for (i = -1; i < 2; i++) {
+               temp = up->cbuf[i + 4] & 0xf;
+               if (i >= 0)
+                       temp |= (up->cbuf[i] & 0xf) << 4;
+               val = chu_dist(temp, 0x63);
+               temp = (up->cbuf[i + 5] & 0xf) << 4;
+               if (i + 9 < nchar)
+                       temp |= up->cbuf[i + 9] & 0xf;
+               val += chu_dist(temp, 0x63);
+               if (val > up->syndist) {
+                       up->syndist = val;
+                       k = i;
+               }
+       }
+       temp = (up->cbuf[k + 4] >> 4) & 0xf;
+       if (temp > 9 || k + 9 >= nchar || temp != ((up->cbuf[k + 9] >>
+           4) & 0xf))
+               temp = 0;
+#ifdef HAVE_AUDIO
+       if (up->fd_audio)
+               sprintf(tbuf, "chuA %04x %4.0f %2d %2d %2d %2d %1d ",
+                   up->status, up->maxsignal, nchar, up->burdist, k,
+                   up->syndist, temp);
+       else
+               sprintf(tbuf, "chuA %04x %2d %2d %2d %2d %1d ",
+                   up->status, nchar, up->burdist, k, up->syndist,
+                   temp);
+
+#else
+       sprintf(tbuf, "chuA %04x %2d %2d %2d %2d %1d ", up->status,
+           nchar, up->burdist, k, up->syndist, temp);
+#endif /* HAVE_AUDIO */
+       for (i = 0; i < nchar; i++)
+               sprintf(&tbuf[strlen(tbuf)], "%02x",
+                   up->cbuf[i]);
+       if (pp->sloppyclockflag & CLK_FLAG4)
+               record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+       if (debug)
+               printf("%s\n", tbuf);
+#endif
+       if (up->syndist < MINSYNC) {
+               up->status |= AFRAME;
+               return;
+       }
+
+       /*
+        * A valid burst requires the first seconds number to match the
+        * last seconds number. If so, the burst timestamps are
+        * corrected to the current minute and saved for later
+        * processing. In addition, the seconds decode is advanced from
+        * the previous burst to the current one.
+        */
+       if (temp != 0) {
+               pp->second = 30 + temp;
+               offset.l_ui = 30 + temp;
+               offset.l_f = 0;
+               i = 0;
+               if (k < 0)
+                       offset = up->charstamp;
+               else if (k > 0)
+                       i = 1;
+               for (; i < nchar && i < k + 10; i++) {
+                       up->tstamp[up->ntstamp] = up->cstamp[i];
+                       L_SUB(&up->tstamp[up->ntstamp], &offset);
+                       L_ADD(&offset, &up->charstamp);
+                       if (up->ntstamp < MAXSTAGE - 1) 
+                               up->ntstamp++;
+               }
+               while (temp > up->prevsec) {
+                       for (j = 15; j > 0; j--) {
+                               up->decode[9][j] = up->decode[9][j - 1];
+                               up->decode[19][j] =
+                                   up->decode[19][j - 1];
+                       }
+                       up->decode[9][j] = up->decode[19][j] = 0;
+                       up->prevsec++;
+               }
+       }
+       i = -(2 * k);
+       for (j = 0; j < nchar; j++) {
+               if (i < 0 || i > 18) {
+                       i += 2;
+                       continue;
+               }
+               up->decode[i][up->cbuf[j] & 0xf]++;
+               i++;
+               up->decode[i][(up->cbuf[j] >> 4) & 0xf]++;
+               i++;
+       }
+       up->status |= AVALID;
+       up->burstcnt++;
+}
+
+
+/*
+ * chu_poll - called by the transmit procedure
+ */
+static void
+chu_poll(
+       int unit,
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct chuunit *up;
+       l_fp    offset;
+       char    synchar, qual, leapchar;
+       int     minset, i;
+       double  dtemp;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+       if (pp->coderecv == pp->codeproc)
+               up->errflg = CEVNT_TIMEOUT;
+       else
+               pp->polls++;
+
+       /*
+        * If once in sync and the radio has not been heard for awhile
+        * (30 m), it is no longer reachable. If not heard in a long
+        * while (one day), turn out the lights and start from scratch.
+        */
+       minset = ((current_time - peer->update) + 30) / 60;
+       if (up->status & INSYNC) {
+               if (minset > PANIC)
+                       up->status = 0;
+               else if (minset <= HOLD)
+                       peer->reach |= 1;
+       }
+
+       /*
+        * Process the last burst, if still in the burst buffer.
+        * Don't mess with anything if nothing has been heard. If the
+        * minute contains a valid A frame and valid B frame, assume
+        * synchronized; however, believe the time only if within metric
+        * threshold. Note the quality indicator is only for
+        * diagnostics; the data are used only if in sync and above
+        * metric threshold.
+        */
+       chu_burst(peer);
+       if (up->burstcnt == 0) {
+#ifdef ICOM
+               chu_newchan(peer, 0);
+#endif /* ICOM */
+               return;
+       }
+       dtemp = chu_major(peer);
+       qual = 0;
+       if (up->status & (BFRAME | AFRAME))
+               qual |= SYNERR;
+       if (up->status & (BFORMAT | AFORMAT))
+               qual |= FMTERR;
+       if (up->status & DECODE)
+               qual |= DECERR;
+       if (up->status & STAMP)
+               qual |= TSPERR;
+       if (up->status & AVALID && up->status & BVALID)
+               up->status |= INSYNC;
+       synchar = leapchar = ' ';
+       if (!(up->status & INSYNC)) {
+               pp->leap = LEAP_NOTINSYNC;
+               synchar = '?';
+       } else if (up->leap & 0x2) {
+               pp->leap = LEAP_ADDSECOND;
+               leapchar = 'L';
+       } else if (up->leap & 0x4) {
+               pp->leap = LEAP_DELSECOND;
+               leapchar = 'l';
+       } else {
+               pp->leap = LEAP_NOWARNING;
+       }
+#ifdef HAVE_AUDIO
+       if (up->fd_audio)
+               sprintf(pp->a_lastcode,
+                   "%c%1X %04d %3d %02d:%02d:%02d %c%x %+d %d %d %s %.0f %d",
+                   synchar, qual, pp->year, pp->day, pp->hour,
+                   pp->minute, pp->second, leapchar, up->dst, up->dut,
+                   minset, up->gain, up->ident, dtemp, up->ntstamp);
+       else
+               sprintf(pp->a_lastcode,
+                   "%c%1X %04d %3d %02d:%02d:%02d %c%x %+d %d %s %.0f %d",
+                   synchar, qual, pp->year, pp->day, pp->hour,
+                   pp->minute, pp->second, leapchar, up->dst, up->dut,
+                   minset, up->ident, dtemp, up->ntstamp);
+#else
+       sprintf(pp->a_lastcode,
+           "%c%1X %04d %3d %02d:%02d:%02d %c%x %+d %d %s %.0f %d",
+           synchar, qual, pp->year, pp->day, pp->hour, pp->minute,
+           pp->second, leapchar, up->dst, up->dut, minset, up->ident,
+           dtemp, up->ntstamp);
+#endif /* HAVE_AUDIO */
+       pp->lencode = strlen(pp->a_lastcode);
+
+       /*
+        * If in sync and the signal metric is above threshold, the
+        * timecode is ipso fatso valid and can be selected to
+        * discipline the clock. Be sure not to leave stray timestamps
+        * around if signals are too weak or the clock time is invalid.
+        */
+       if (up->status & INSYNC && dtemp > METRIC) {
+               if (!clocktime(pp->day, pp->hour, pp->minute, 0, GMT,
+                   up->tstamp[0].l_ui, &pp->yearstart, &offset.l_ui)) {
+                       up->errflg = CEVNT_BADTIME;
+               } else {
+                       offset.l_uf = 0;
+                       for (i = 0; i < up->ntstamp; i++)
+                               refclock_process_offset(pp, offset,
+                                   up->tstamp[i], FUDGE +
+                                   pp->fudgetime1);
+                       pp->lastref = up->timestamp;
+                       refclock_receive(peer);
+               }
+               record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       } else if (pp->sloppyclockflag & CLK_FLAG4) {
+               record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       }
+#ifdef DEBUG
+       if (debug)
+               printf("chu: timecode %d %s\n", pp->lencode,
+                   pp->a_lastcode);
+#endif
+#ifdef ICOM
+       chu_newchan(peer, dtemp);
+#endif /* ICOM */
+       chu_clear(peer);
+       if (up->errflg)
+               refclock_report(peer, up->errflg);
+       up->errflg = 0;
+}
+
+
+/*
+ * chu_major - majority decoder
+ */
+static double
+chu_major(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct chuunit *up;
+
+       u_char  code[11];       /* decoded timecode */
+       int     mindist;        /* minimum distance */
+       int     val1, val2;     /* maximum distance */
+       int     synchar;        /* stray cat */
+       int     temp;
+       int     i, j, k;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * Majority decoder. Each burst encodes two replications at each
+        * digit position in the timecode. Each row of the decoding
+        * matrix encodes the number of occurrences of each digit found
+        * at the corresponding position. The maximum over all
+        * occurrences at each position is the distance for this
+        * position and the corresponding digit is the maximum
+        * likelihood candidate. If the distance is zero, assume a miss
+        * '_'; if the distance is not more than half the total number
+        * of occurrences, assume a soft error '*'; if two different
+        * digits with the same distance are found, assume a hard error
+        * '='. These will later cause a format error when the timecode
+        * is interpreted. The decoding distance is defined as the
+        * minimum distance over the first nine digits. The tenth digit
+        * varies over the seconds, so we don't count it.
+        */
+       mindist = 16;
+       for (i = 0; i < 9; i++) {
+               val1 = val2 = 0;
+               k = 0;
+               for (j = 0; j < 16; j++) {
+                       temp = up->decode[i][j] + up->decode[i + 10][j];
+                       if (temp > val1) {
+                               val2 = val1;
+                               val1 = temp;
+                               k = j;
+                       }
+               }
+               if (val1 == 0)
+                       code[i] = HEX_MISS;
+               else if (val1 == val2)
+                       code[i] = HEX_HARD;
+               else if (val1 <= up->burstcnt)
+                       code[i] = HEX_SOFT;
+               else
+                       code[i] = k;
+               if (val1 < mindist)
+                       mindist = val1;
+               code[i] = hexchar[code[i]];
+       }
+       code[i] = 0;
+
+       /*
+        * A valid timecode requires a minimum distance at least half
+        * the total number of occurrences. A valid timecode also
+        * requires at least 20 valid timestamps.
+        */
+       if (up->burstcnt < MINBURST || mindist < up->burstcnt)
+               up->status |= DECODE;
+       if (up->ntstamp < MINSTAMP)
+               up->status |= STAMP;
+
+       /*
+        * Compute the timecode timestamp from the days, hours and
+        * minutes of the timecode. Use clocktime() for the aggregate
+        * minutes and the minute offset computed from the burst
+        * seconds. Note that this code relies on the filesystem time
+        * for the years and does not use the years of the timecode.
+        */
+       if (sscanf((char *)code, "%1x%3d%2d%2d", &synchar, &pp->day,
+           &pp->hour, &pp->minute) != 4) {
+               up->status |= AFORMAT;
+               return (0);
+       }
+       if (up->status & (DECODE | STAMP)) {
+               up->errflg = CEVNT_BADREPLY;
+               return (0);
+       }
+       return (mindist * 100. / (2. * up->burstcnt));
+}
+
+
+/*
+ * chu_clear - clear decoding matrix
+ */
+static void
+chu_clear(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct chuunit *up;
+       int     i, j;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * Clear stuff for the minute.
+        */
+       up->ndx = up->prevsec = 0;
+       up->burstcnt = up->ntstamp = 0;
+       up->status &= INSYNC;
+       for (i = 0; i < 20; i++) {
+               for (j = 0; j < 16; j++)
+                       up->decode[i][j] = 0;
+       }
+}
+
+#ifdef ICOM
+/*
+ * chu_newchan - called once per minute to find the best channel;
+ * returns zero on success, nonzero if ICOM error.
+ */
+static int
+chu_newchan(
+       struct peer *peer,
+       double  met
+       )
+{
+       struct chuunit *up;
+       struct refclockproc *pp;
+       struct xmtr *sp;
+       char    tbuf[80];       /* trace buffer */
+       int     rval;
+       double  metric;
+       int     i, j;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * The radio can be tuned to three channels: 0 (3330 kHz), 1
+        * (7335 kHz) and 2 (14670 kHz). There are five one-minute
+        * dwells in each cycle. During the first dwell the radio is
+        * tuned to one of three probe channels; during the remaining
+        * four dwells the radio is tuned to the data channel. The probe
+        * channel is selects as the least recently used. At the end of
+        * each dwell the channel metrics are measured and the highest
+        * one is selected as the data channel. 
+        */
+       if (up->fd_icom <= 0)
+               return (0);
+
+       sp = &up->xmtr[up->achan];
+       sp->metric -= sp->integ[sp->iptr];
+       sp->integ[sp->iptr] = met;
+       sp->metric += sp->integ[sp->iptr];
+       sp->iptr = (sp->iptr + 1) % ISTAGE;
+       metric = 0;
+       j = 0;
+       for (i = 0; i < NCHAN; i++) {
+               up->xmtr[i].probe++;
+               if (i == up->achan)
+                       up->xmtr[i].probe = 0;
+               if (up->xmtr[i].metric < metric)
+                       continue;
+               metric = up->xmtr[i].metric;
+               j = i;
+       }
+       if (j != up->chan && metric > 0) {
+               up->chan = j;
+               sprintf(tbuf, "chu: QSY to %.3f MHz metric %.0f",
+                   qsy[up->chan], metric);
+               if (pp->sloppyclockflag & CLK_FLAG4)
+                       record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+               if (debug)
+                       printf("%s\n", tbuf);
+#endif
+       }
+
+       /*
+        * Start the next dwell. We speed up the initial sync a little.
+        * If not in sync and no bursts were heard the previous dwell,
+        * restart the probe.
+        */
+       rval = 0;
+       if (up->burstcnt == 0 && !(up->status & INSYNC))
+               up->dwell = 0;
+#ifdef DEBUG
+       if (debug)
+               printf(
+                   "chu: at %ld dwell %d achan %d metric %.0f chan %d\n",
+                   current_time, up->dwell, up->achan, sp->metric,
+                   up->chan);
+#endif
+       if (up->dwell == 0) {
+               rval = 0;
+               for (i = 0; i < NCHAN; i++) {
+                       if (up->xmtr[i].probe < rval)
+                               continue;
+                       rval = up->xmtr[i].probe;
+                       up->achan = i;
+               }
+               rval = icom_freq(up->fd_icom, peer->ttl & 0x7f,
+                   qsy[up->achan] + TUNE);
+#ifdef DEBUG
+               if (debug)
+                       printf("chu: at %ld probe channel %d\n",
+                   current_time, up->achan);
+#endif
+       } else {
+               if (up->achan != up->chan) {
+                       rval = icom_freq(up->fd_icom, peer->ttl & 0x7f,
+                           qsy[up->chan] + TUNE);
+                       up->achan = up->chan;
+               }
+       }
+       sprintf(up->ident, "CHU%d", up->achan);
+       memcpy(&peer->refid, up->ident, 4); 
+       up->dwell = (up->dwell + 1) % DWELL;
+       return (rval);
+}
+#endif /* ICOM */
+
+/*
+ * chu_dist - determine the distance of two octet arguments
+ */
+static int
+chu_dist(
+       int     x,              /* an octet of bits */
+       int     y               /* another octet of bits */
+       )
+{
+       int     val;            /* bit count */ 
+       int     temp;
+       int     i;
+
+       /*
+        * The distance is determined as the weight of the exclusive OR
+        * of the two arguments. The weight is determined by the number
+        * of one bits in the result. Each one bit increases the weight,
+        * while each zero bit decreases it.
+        */
+       temp = x ^ y;
+       val = 0;
+       for (i = 0; i < 8; i++) {
+               if ((temp & 0x1) == 0)
+                       val++;
+               else
+                       val--;
+               temp >>= 1;
+       }
+       return (val);
+}
+
+
+#ifdef HAVE_AUDIO
+/*
+ * chu_gain - adjust codec gain
+ *
+ * This routine is called once each second. If the signal envelope
+ * amplitude is too low, the codec gain is bumped up by four units; if
+ * too high, it is bumped down. The decoder is relatively insensitive to
+ * amplitude, so this crudity works just fine. The input port is set and
+ * the error flag is cleared, mostly to be ornery.
+ */
+static void
+chu_gain(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct chuunit *up;
+
+       pp = peer->procptr;
+       up = (struct chuunit *)pp->unitptr;
+
+       /*
+        * Apparently, the codec uses only the high order bits of the
+        * gain control field. Thus, it may take awhile for changes to
+        * wiggle the hardware bits.
+        */
+       if (up->clipcnt == 0) {
+               up->gain += 4;
+               if (up->gain > MAXGAIN)
+                       up->gain = MAXGAIN;
+       } else if (up->clipcnt > MAXCLP) {
+               up->gain -= 4;
+               if (up->gain < 0)
+                       up->gain = 0;
+       }
+       audio_gain(up->gain, up->mongain, up->port);
+       up->clipcnt = 0;
+}
+#endif /* HAVE_AUDIO */
+
+
+#else
+int refclock_chu_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_conf.c b/ntpd/refclock_conf.c
new file mode 100644 (file)
index 0000000..dc29d1e
--- /dev/null
@@ -0,0 +1,319 @@
+/*
+ * refclock_conf.c - reference clock configuration
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+
+#include "ntpd.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#ifdef REFCLOCK
+
+static struct refclock refclock_none = {
+       noentry, noentry, noentry, noentry, noentry, noentry, NOFLAGS
+};
+
+#ifdef CLOCK_LOCAL
+extern struct refclock refclock_local;
+#else
+#define        refclock_local  refclock_none
+#endif
+
+#if 0 && defined(CLOCK_TRAK) && defined(PPS)
+extern struct refclock refclock_trak;
+#else
+#define        refclock_trak   refclock_none
+#endif
+
+#ifdef CLOCK_PST
+extern struct refclock refclock_pst;
+#else
+#define        refclock_pst    refclock_none
+#endif
+
+#ifdef CLOCK_CHU
+extern struct refclock refclock_chu;
+#else
+#define        refclock_chu    refclock_none
+#endif
+
+#ifdef CLOCK_WWV
+extern  struct refclock refclock_wwv;
+#else
+#define refclock_wwv    refclock_none
+#endif
+
+#ifdef CLOCK_SPECTRACOM
+extern struct refclock refclock_wwvb;
+#else
+#define        refclock_wwvb   refclock_none
+#endif
+
+#ifdef CLOCK_PARSE
+extern struct refclock refclock_parse;
+#else
+#define        refclock_parse  refclock_none
+#endif
+
+#if defined(CLOCK_MX4200) && defined(HAVE_PPSAPI)
+extern struct refclock refclock_mx4200;
+#else
+#define        refclock_mx4200 refclock_none
+#endif
+
+#ifdef CLOCK_AS2201
+extern struct refclock refclock_as2201;
+#else
+#define        refclock_as2201 refclock_none
+#endif
+
+#ifdef CLOCK_ARBITER
+extern  struct refclock refclock_arbiter;
+#else
+#define refclock_arbiter refclock_none
+#endif
+
+#ifdef CLOCK_TPRO
+extern struct refclock refclock_tpro;
+#else
+#define        refclock_tpro   refclock_none
+#endif
+
+#ifdef CLOCK_LEITCH
+extern struct refclock refclock_leitch;
+#else
+#define        refclock_leitch refclock_none
+#endif
+
+#ifdef CLOCK_IRIG
+extern struct refclock refclock_irig;
+#else
+#define refclock_irig  refclock_none
+#endif
+
+#if 0 && defined(CLOCK_MSFEES) && defined(PPS)
+extern struct refclock refclock_msfees;
+#else
+#define refclock_msfees        refclock_none
+#endif
+
+#ifdef CLOCK_BANC
+extern struct refclock refclock_bancomm;
+#else
+#define refclock_bancomm refclock_none
+#endif
+
+#ifdef CLOCK_TRUETIME
+extern struct refclock refclock_true;
+#else
+#define        refclock_true   refclock_none
+#endif
+
+#ifdef CLOCK_DATUM
+extern struct refclock refclock_datum;
+#else
+#define refclock_datum refclock_none
+#endif
+
+#ifdef CLOCK_ACTS
+extern struct refclock refclock_acts;
+#else
+#define refclock_acts  refclock_none
+#endif
+
+#ifdef CLOCK_HEATH
+extern struct refclock refclock_heath;
+#else
+#define refclock_heath refclock_none
+#endif
+
+#ifdef CLOCK_NMEA
+extern struct refclock refclock_nmea;
+#else
+#define        refclock_nmea   refclock_none
+#endif
+
+#ifdef CLOCK_ATOM
+extern struct refclock refclock_atom;
+#else
+#define refclock_atom  refclock_none
+#endif
+
+#ifdef CLOCK_HPGPS
+extern struct refclock refclock_hpgps;
+#else
+#define        refclock_hpgps  refclock_none
+#endif
+
+#ifdef CLOCK_GPSVME
+extern struct refclock refclock_gpsvme;
+#else
+#define refclock_gpsvme refclock_none
+#endif
+
+#ifdef CLOCK_ARCRON_MSF
+extern struct refclock refclock_arc;
+#else
+#define refclock_arc refclock_none
+#endif
+
+#ifdef CLOCK_SHM
+extern struct refclock refclock_shm;
+#else
+#define refclock_shm refclock_none
+#endif
+
+#ifdef CLOCK_PALISADE
+extern  struct refclock refclock_palisade;
+#else
+#define refclock_palisade refclock_none
+#endif
+
+#if defined(CLOCK_ONCORE)
+extern struct refclock refclock_oncore;
+#else
+#define refclock_oncore refclock_none
+#endif
+
+#if defined(CLOCK_JUPITER) && defined(HAVE_PPSAPI)
+extern struct refclock refclock_jupiter;
+#else
+#define refclock_jupiter refclock_none
+#endif
+
+#if defined(CLOCK_CHRONOLOG)
+extern struct refclock refclock_chronolog;
+#else
+#define refclock_chronolog refclock_none
+#endif
+
+#if defined(CLOCK_DUMBCLOCK)
+extern struct refclock refclock_dumbclock;
+#else
+#define refclock_dumbclock refclock_none
+#endif
+
+#ifdef CLOCK_ULINK
+extern struct refclock refclock_ulink;
+#else
+#define        refclock_ulink  refclock_none
+#endif
+
+#ifdef CLOCK_PCF
+extern struct refclock refclock_pcf;
+#else
+#define        refclock_pcf    refclock_none
+#endif
+
+#ifdef CLOCK_FG
+extern struct refclock refclock_fg;
+#else
+#define        refclock_fg     refclock_none
+#endif
+
+#ifdef CLOCK_HOPF_SERIAL
+extern struct refclock refclock_hopfser;
+#else
+#define        refclock_hopfser refclock_none
+#endif
+
+#ifdef CLOCK_HOPF_PCI
+extern struct refclock refclock_hopfpci;
+#else
+#define        refclock_hopfpci refclock_none
+#endif
+
+#ifdef CLOCK_JJY
+extern struct refclock refclock_jjy;
+#else
+#define        refclock_jjy refclock_none
+#endif
+
+#ifdef CLOCK_TT560
+extern struct refclock refclock_tt560;
+#else
+#define        refclock_tt560 refclock_none
+#endif
+
+#ifdef CLOCK_ZYFER
+extern struct refclock refclock_zyfer;
+#else
+#define        refclock_zyfer refclock_none
+#endif
+
+#ifdef CLOCK_RIPENCC
+extern struct refclock refclock_ripencc;
+#else
+#define refclock_ripencc refclock_none
+#endif
+
+#ifdef CLOCK_NEOCLOCK4X
+extern struct refclock refclock_neoclock4x;
+#else
+#define        refclock_neoclock4x     refclock_none
+#endif
+
+/*
+ * Order is clock_start(), clock_shutdown(), clock_poll(),
+ * clock_control(), clock_init(), clock_buginfo, clock_flags;
+ *
+ * Types are defined in ntp.h.  The index must match this.
+ */
+struct refclock *refclock_conf[] = {
+       &refclock_none,         /* 0 REFCLK_NONE */
+       &refclock_local,        /* 1 REFCLK_LOCAL */
+       &refclock_none,         /* 2 deprecated: REFCLK_GPS_TRAK */
+       &refclock_pst,          /* 3 REFCLK_WWV_PST */
+       &refclock_wwvb,         /* 4 REFCLK_SPECTRACOM */
+       &refclock_true,         /* 5 REFCLK_TRUETIME */
+       &refclock_irig,         /* 6 REFCLK_IRIG_AUDIO */
+       &refclock_chu,          /* 7 REFCLK_CHU_AUDIO */
+       &refclock_parse,        /* 8 REFCLK_PARSE */
+       &refclock_mx4200,       /* 9 REFCLK_GPS_MX4200 */
+       &refclock_as2201,       /* 10 REFCLK_GPS_AS2201 */
+       &refclock_arbiter,      /* 11 REFCLK_GPS_ARBITER */
+       &refclock_tpro,         /* 12 REFCLK_IRIG_TPRO */
+       &refclock_leitch,       /* 13 REFCLK_ATOM_LEITCH */
+       &refclock_none,         /* 14 deprecated: REFCLK_MSF_EES */
+       &refclock_none,         /* 15 not used */
+       &refclock_bancomm,      /* 16 REFCLK_IRIG_BANCOMM */
+       &refclock_datum,        /* 17 REFCLK_GPS_DATUM */
+       &refclock_acts,         /* 18 REFCLK_ACTS */
+       &refclock_heath,        /* 19 REFCLK_WWV_HEATH */
+       &refclock_nmea,         /* 20 REFCLK_GPS_NMEA */
+       &refclock_gpsvme,       /* 21 REFCLK_GPS_VME */
+       &refclock_atom,         /* 22 REFCLK_ATOM_PPS */
+       &refclock_none,         /* 23 not used */
+       &refclock_none,         /* 24 not used */
+       &refclock_none,         /* 25 not used */
+       &refclock_hpgps,        /* 26 REFCLK_GPS_HP */
+       &refclock_arc,          /* 27 REFCLK_ARCRON_MSF */
+       &refclock_shm,          /* 28 REFCLK_SHM */
+       &refclock_palisade,     /* 29 REFCLK_PALISADE */
+       &refclock_oncore,       /* 30 REFCLK_ONCORE */
+       &refclock_jupiter,      /* 31 REFCLK_GPS_JUPITER */
+       &refclock_chronolog,    /* 32 REFCLK_CHRONOLOG */
+       &refclock_dumbclock,    /* 33 REFCLK_DUMBCLOCK */
+       &refclock_ulink,        /* 34 REFCLOCK_ULINK */
+       &refclock_pcf,          /* 35 REFCLOCK_PCF */
+       &refclock_wwv,          /* 36 REFCLOCK_WWV_AUDIO */
+       &refclock_fg,           /* 37 REFCLOCK_FG */
+       &refclock_hopfser,      /* 38 REFCLK_HOPF_SERIAL */
+       &refclock_hopfpci,      /* 39 REFCLK_HOPF_PCI */
+       &refclock_jjy,          /* 40 REFCLK_JJY */
+       &refclock_tt560,        /* 41 REFCLK_TT560 */
+       &refclock_zyfer,        /* 42 REFCLK_ZYFER */
+       &refclock_ripencc,      /* 43 REFCLK_RIPENCC */
+       &refclock_neoclock4x    /* 44 REFCLK_NEOCLOCK4X */
+};
+
+u_char num_refclock_conf = sizeof(refclock_conf)/sizeof(struct refclock *);
+
+#else
+int refclock_conf_bs;
+#endif
diff --git a/ntpd/refclock_datum.c b/ntpd/refclock_datum.c
new file mode 100644 (file)
index 0000000..b26fe73
--- /dev/null
@@ -0,0 +1,877 @@
+/*
+** refclock_datum - clock driver for the Datum Programmable Time Server
+**
+** Important note: This driver assumes that you have termios. If you have
+** a system that does not have termios, you will have to modify this driver.
+**
+** Sorry, I have only tested this driver on SUN and HP platforms.
+*/
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_DATUM)
+
+/*
+** Include Files
+*/
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#if defined(HAVE_BSD_TTYS)
+#include <sgtty.h>
+#endif /* HAVE_BSD_TTYS */
+
+#if defined(HAVE_SYSV_TTYS)
+#include <termio.h>
+#endif /* HAVE_SYSV_TTYS */
+
+#if defined(HAVE_TERMIOS)
+#include <termios.h>
+#endif
+#if defined(STREAM)
+#include <stropts.h>
+#if defined(WWVBCLK)
+#include <sys/clkdefs.h>
+#endif /* WWVBCLK */
+#endif /* STREAM */
+
+#include "ntp_stdlib.h"
+
+/*
+** This driver supports the Datum Programmable Time System (PTS) clock.
+** The clock works in very straight forward manner. When it receives a
+** time code request (e.g., the ascii string "//k/mn"), it responds with
+** a seven byte BCD time code. This clock only responds with a
+** time code after it first receives the "//k/mn" message. It does not
+** periodically send time codes back at some rate once it is started.
+** the returned time code can be broken down into the following fields.
+**
+**            _______________________________
+** Bit Index | 7 | 6 | 5 | 4 | 3 | 2 | 1 | 0 |
+**            ===============================
+** byte 0:   | -   -   -   - |      H D      |
+**            ===============================
+** byte 1:   |      T D      |      U D      |
+**            ===============================
+** byte 2:   | -   - |  T H  |      U H      |
+**            ===============================
+** byte 3:   | - |    T M    |      U M      |
+**            ===============================
+** byte 4:   | - |    T S    |      U S      |
+**            ===============================
+** byte 5:   |      t S      |      h S      |
+**            ===============================
+** byte 6:   |      m S      | -   -   -   - |
+**            ===============================
+**
+** In the table above:
+**
+**     "-" means don't care
+**     "H D", "T D", and "U D" means Hundreds, Tens, and Units of Days
+**     "T H", and "UH" means Tens and Units of Hours
+**     "T M", and "U M" means Tens and Units of Minutes
+**     "T S", and "U S" means Tens and Units of Seconds
+**     "t S", "h S", and "m S" means tenths, hundredths, and thousandths
+**                             of seconds
+**
+** The Datum PTS communicates throught the RS232 port on your machine.
+** Right now, it assumes that you have termios. This driver has been tested
+** on SUN and HP workstations. The Datum PTS supports various IRIG and
+** NASA input codes. This driver assumes that the name of the device is
+** /dev/datum. You will need to make a soft link to your RS232 device or
+** create a new driver to use this refclock.
+*/
+
+/*
+** Datum PTS defines
+*/
+
+/*
+** Note that if GMT is defined, then the Datum PTS must use Greenwich
+** time. Otherwise, this driver allows the Datum PTS to use the current
+** wall clock for its time. It determines the time zone offset by minimizing
+** the error after trying several time zone offsets. If the Datum PTS
+** time is Greenwich time and GMT is not defined, everything should still
+** work since the time zone will be found to be 0. What this really means
+** is that your system time (at least to start with) must be within the
+** correct time by less than +- 30 minutes. The default is for GMT to not
+** defined. If you really want to force GMT without the funny +- 30 minute
+** stuff then you must define (uncomment) GMT below.
+*/
+
+/*
+#define GMT
+#define DEBUG_DATUM_PTC
+#define LOG_TIME_ERRORS
+*/
+
+
+#define        PRECISION       (-10)           /* precision assumed 1/1024 ms */
+#define        REFID "DATM"                    /* reference id */
+#define DATUM_DISPERSION 0             /* fixed dispersion = 0 ms */
+#define DATUM_MAX_ERROR 0.100          /* limits on sigma squared */
+#define DATUM_DEV      "/dev/datum"    /* device name */
+
+#define DATUM_MAX_ERROR2 (DATUM_MAX_ERROR*DATUM_MAX_ERROR)
+
+/*
+** The Datum PTS structure
+*/
+
+/*
+** I don't use a fixed array of MAXUNITS like everyone else just because
+** I don't like to program that way. Sorry if this bothers anyone. I assume
+** that you can use any id for your unit and I will search for it in a
+** dynamic array of units until I find it. I was worried that users might
+** enter a bad id in their configuration file (larger than MAXUNITS) and
+** besides, it is just cleaner not to have to assume that you have a fixed
+** number of anything in a program.
+*/
+
+struct datum_pts_unit {
+       struct peer *peer;              /* peer used by ntp */
+       struct refclockio io;           /* io structure used by ntp */
+       int PTS_fd;                     /* file descriptor for PTS */
+       u_int unit;                     /* id for unit */
+       u_long timestarted;             /* time started */
+       l_fp lastrec;                   /* time tag for the receive time (system) */
+       l_fp lastref;                   /* reference time (Datum time) */
+       u_long yearstart;               /* the year that this clock started */
+       int coderecv;                   /* number of time codes received */
+       int day;                        /* day */
+       int hour;                       /* hour */
+       int minute;                     /* minutes */
+       int second;                     /* seconds */
+       int msec;                       /* miliseconds */
+       int usec;                       /* miliseconds */
+       u_char leap;                    /* funny leap character code */
+       char retbuf[8];         /* returned time from the datum pts */
+       char nbytes;                    /* number of bytes received from datum pts */ 
+       double sigma2;          /* average squared error (roughly) */
+       int tzoff;                      /* time zone offest from GMT */
+};
+
+/*
+** PTS static constant variables for internal use
+*/
+
+static char TIME_REQUEST[6];   /* request message sent to datum for time */
+static int nunits;             /* number of active units */
+static struct datum_pts_unit
+**datum_pts_unit;      /* dynamic array of datum PTS structures */
+
+/*
+** Callback function prototypes that ntpd needs to know about.
+*/
+
+static int     datum_pts_start         P((int, struct peer *));
+static void    datum_pts_shutdown      P((int, struct peer *));
+static void    datum_pts_poll          P((int, struct peer *));
+static void    datum_pts_control       P((int, struct refclockstat *,
+                                          struct refclockstat *, struct peer *));
+static void    datum_pts_init          P((void));
+static void    datum_pts_buginfo       P((int, struct refclockbug *, struct peer *));
+
+/*
+** This is the call back function structure that ntpd actually uses for
+** this refclock.
+*/
+
+struct refclock refclock_datum = {
+       datum_pts_start,                /* start up a new Datum refclock */
+       datum_pts_shutdown,             /* shutdown a Datum refclock */
+       datum_pts_poll,         /* sends out the time request */
+       datum_pts_control,              /* not used */
+       datum_pts_init,         /* initialization (called first) */
+       datum_pts_buginfo,              /* not used */
+       NOFLAGS                 /* we are not setting any special flags */
+};
+
+/*
+** The datum_pts_receive callback function is handled differently from the
+** rest. It is passed to the ntpd io data structure. Basically, every
+** 64 seconds, the datum_pts_poll() routine is called. It sends out the time
+** request message to the Datum Programmable Time System. Then, ntpd
+** waits on a select() call to receive data back. The datum_pts_receive()
+** function is called as data comes back. We expect a seven byte time
+** code to be returned but the datum_pts_receive() function may only get
+** a few bytes passed to it at a time. In other words, this routine may
+** get called by the io stuff in ntpd a few times before we get all seven
+** bytes. Once the last byte is received, we process it and then pass the
+** new time measurement to ntpd for updating the system time. For now,
+** there is no 3 state filtering done on the time measurements. The
+** jitter may be a little high but at least for its current use, it is not
+** a problem. We have tried to keep things as simple as possible. This
+** clock should not jitter more than 1 or 2 mseconds at the most once
+** things settle down. It is important to get the right drift calibrated
+** in the ntpd.drift file as well as getting the right tick set up right
+** using tickadj for SUNs. Tickadj is not used for the HP but you need to
+** remember to bring up the adjtime daemon because HP does not support
+** the adjtime() call.
+*/
+
+static void    datum_pts_receive       P((struct recvbuf *));
+
+/*......................................................................*/
+/*     datum_pts_start - start up the datum PTS. This means open the   */
+/*     RS232 device and set up the data structure for my unit.         */
+/*......................................................................*/
+
+static int
+datum_pts_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct datum_pts_unit **temp_datum_pts_unit;
+       struct datum_pts_unit *datum_pts;
+       int fd;
+#ifdef HAVE_TERMIOS
+       struct termios arg;
+#endif
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("Starting Datum PTS unit %d\n", unit);
+#endif
+
+       /*
+       ** Open the Datum PTS device
+       */
+       fd = open(DATUM_DEV, O_RDWR);
+
+       if (fd < 0) {
+               msyslog(LOG_ERR, "Datum_PTS: open(\"%s\", O_RDWR) failed: %m", DATUM_DEV);
+               return 0;
+       }
+
+       /*
+       ** Create the memory for the new unit
+       */
+
+       temp_datum_pts_unit = (struct datum_pts_unit **)
+               malloc((nunits+1)*sizeof(struct datum_pts_unit *));
+       if (nunits > 0) memcpy(temp_datum_pts_unit, datum_pts_unit,
+                              nunits*sizeof(struct datum_pts_unit *));
+       free(datum_pts_unit);
+       datum_pts_unit = temp_datum_pts_unit;
+       datum_pts_unit[nunits] = (struct datum_pts_unit *)
+               malloc(sizeof(struct datum_pts_unit));
+       datum_pts = datum_pts_unit[nunits];
+
+       datum_pts->unit = unit; /* set my unit id */
+       datum_pts->yearstart = 0;       /* initialize the yearstart to 0 */
+       datum_pts->sigma2 = 0.0;        /* initialize the sigma2 to 0 */
+
+       datum_pts->PTS_fd = fd;
+
+       fcntl(datum_pts->PTS_fd, F_SETFL, 0); /* clear the descriptor flags */
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("Opening RS232 port with file descriptor %d\n",
+                  datum_pts->PTS_fd);
+#endif
+
+       /*
+       ** Set up the RS232 terminal device information. Note that we assume that
+       ** we have termios. This code has only been tested on SUNs and HPs. If your
+       ** machine does not have termios this driver cannot be initialized. You can change this
+       ** if you want by editing this source. Please give the changes back to the
+       ** ntp folks so that it can become part of their regular distribution.
+       */
+
+#ifdef HAVE_TERMIOS
+
+       arg.c_iflag = IGNBRK;
+       arg.c_oflag = 0;
+       arg.c_cflag = B9600 | CS8 | CREAD | PARENB | CLOCAL;
+       arg.c_lflag = 0;
+       arg.c_cc[VMIN] = 0;             /* start timeout timer right away (not used) */
+       arg.c_cc[VTIME] = 30;           /* 3 second timout on reads (not used) */
+
+       tcsetattr(datum_pts->PTS_fd, TCSANOW, &arg);
+
+#else
+
+       msyslog(LOG_ERR, "Datum_PTS: Termios not supported in this driver");
+       (void)close(datum_pts->PTS_fd);
+
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+
+       return 0;
+
+#endif
+
+       /*
+       ** Initialize the ntpd IO structure
+       */
+
+       datum_pts->peer = peer;
+       datum_pts->io.clock_recv = datum_pts_receive;
+       datum_pts->io.srcclock = (caddr_t)datum_pts;
+       datum_pts->io.datalen = 0;
+       datum_pts->io.fd = datum_pts->PTS_fd;
+
+       if (!io_addclock(&(datum_pts->io))) {
+
+#ifdef DEBUG_DATUM_PTC
+               if (debug)
+                   printf("Problem adding clock\n");
+#endif
+
+               msyslog(LOG_ERR, "Datum_PTS: Problem adding clock");
+               (void)close(datum_pts->PTS_fd);
+
+               return 0;
+       }
+
+       /*
+       ** Now add one to the number of units and return a successful code
+       */
+
+       nunits++;
+       return 1;
+
+}
+
+
+/*......................................................................*/
+/*     datum_pts_shutdown - this routine shuts doen the device and     */
+/*     removes the memory for the unit.                                */
+/*......................................................................*/
+
+static void
+datum_pts_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       int i,j;
+       struct datum_pts_unit **temp_datum_pts_unit;
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("Shutdown Datum PTS\n");
+#endif
+
+       msyslog(LOG_ERR, "Datum_PTS: Shutdown Datum PTS");
+
+       /*
+       ** First we have to find the right unit (i.e., the one with the same id).
+       ** We do this by looping through the dynamic array of units intil we find
+       ** it. Note, that I don't simply use an array with a maximimum number of
+       ** Datum PTS units. Everything is completely dynamic.
+       */
+
+       for (i=0; i<nunits; i++) {
+               if (datum_pts_unit[i]->unit == unit) {
+
+                       /*
+                       ** We found the unit so close the file descriptor and free up the memory used
+                       ** by the structure.
+                       */
+
+                       io_closeclock(&datum_pts_unit[i]->io);
+                       close(datum_pts_unit[i]->PTS_fd);
+                       free(datum_pts_unit[i]);
+
+                       /*
+                       ** Now clean up the datum_pts_unit dynamic array so that there are no holes.
+                       ** This may mean moving pointers around, etc., to keep things compact.
+                       */
+
+                       if (nunits > 1) {
+
+                               temp_datum_pts_unit = (struct datum_pts_unit **)
+                                       malloc((nunits-1)*sizeof(struct datum_pts_unit *));
+                               if (i!= 0) memcpy(temp_datum_pts_unit, datum_pts_unit,
+                                                 i*sizeof(struct datum_pts_unit *));
+
+                               for (j=i+1; j<nunits; j++) {
+                                       temp_datum_pts_unit[j-1] = datum_pts_unit[j];
+                               }
+
+                               free(datum_pts_unit);
+                               datum_pts_unit = temp_datum_pts_unit;
+
+                       }else{
+
+                               free(datum_pts_unit);
+                               datum_pts_unit = NULL;
+
+                       }
+
+                       return;
+
+               }
+       }
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("Error, could not shut down unit %d\n",unit);
+#endif
+
+       msyslog(LOG_ERR, "Datum_PTS: Could not shut down Datum PTS unit %d",unit);
+
+}
+
+/*......................................................................*/
+/*     datum_pts_poll - this routine sends out the time request to the */
+/*     Datum PTS device. The time will be passed back in the           */
+/*     datum_pts_receive() routine.                                    */
+/*......................................................................*/
+
+static void
+datum_pts_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       int i;
+       int unit_index;
+       int error_code;
+       struct datum_pts_unit *datum_pts;
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("Poll Datum PTS\n");
+#endif
+
+       /*
+       ** Find the right unit and send out a time request once it is found.
+       */
+
+       unit_index = -1;
+       for (i=0; i<nunits; i++) {
+               if (datum_pts_unit[i]->unit == unit) {
+                       unit_index = i;
+                       datum_pts = datum_pts_unit[i];
+                       error_code = write(datum_pts->PTS_fd, TIME_REQUEST, 6);
+                       if (error_code != 6) perror("TIME_REQUEST");
+                       datum_pts->nbytes = 0;
+                       break;
+               }
+       }
+
+       /*
+       ** Print out an error message if we could not find the right unit.
+       */
+
+       if (unit_index == -1) {
+
+#ifdef DEBUG_DATUM_PTC
+               if (debug)
+                   printf("Error, could not poll unit %d\n",unit);
+#endif
+
+               msyslog(LOG_ERR, "Datum_PTS: Could not poll unit %d",unit);
+               return;
+
+       }
+
+}
+
+
+/*......................................................................*/
+/*     datum_pts_control - not used                                    */
+/*......................................................................*/
+
+static void
+datum_pts_control(
+       int unit,
+       struct refclockstat *in,
+       struct refclockstat *out,
+       struct peer *peer
+       )
+{
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("Control Datum PTS\n");
+#endif
+
+}
+
+
+/*......................................................................*/
+/*     datum_pts_init - initializes things for all possible Datum      */
+/*     time code generators that might be used. In practice, this is   */
+/*     only called once at the beginning before anything else is       */
+/*     called.                                                         */
+/*......................................................................*/
+
+static void
+datum_pts_init(void)
+{
+
+       /*                                                                      */
+       /*...... open up the log file if we are debugging ......................*/
+       /*                                                                      */
+
+       /*
+       ** Open up the log file if we are debugging. For now, send data out to the
+       ** screen (stdout).
+       */
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("Init Datum PTS\n");
+#endif
+
+       /*
+       ** Initialize the time request command string. This is the only message
+       ** that we ever have to send to the Datum PTS (although others are defined).
+       */
+
+       memcpy(TIME_REQUEST, "//k/mn",6);
+
+       /*
+       ** Initialize the number of units to 0 and set the dynamic array of units to
+       ** NULL since there are no units defined yet.
+       */
+
+       datum_pts_unit = NULL;
+       nunits = 0;
+
+}
+
+
+/*......................................................................*/
+/*     datum_pts_buginfo - not used                                    */
+/*......................................................................*/
+
+static void
+datum_pts_buginfo(
+       int unit,
+       register struct refclockbug *bug,
+       register struct peer *peer
+       )
+{
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("Buginfo Datum PTS\n");
+#endif
+
+}
+
+
+/*......................................................................*/
+/*     datum_pts_receive - receive the time buffer that was read in    */
+/*     by the ntpd io handling routines. When 7 bytes have been        */
+/*     received (it may take several tries before all 7 bytes are      */
+/*     received), then the time code must be unpacked and sent to      */
+/*     the ntpd clock_receive() routine which causes the systems       */
+/*     clock to be updated (several layers down).                      */
+/*......................................................................*/
+
+static void
+datum_pts_receive(
+       struct recvbuf *rbufp
+       )
+{
+       int i;
+       l_fp tstmp;
+       struct datum_pts_unit *datum_pts;
+       char *dpt;
+       int dpend;
+       int tzoff;
+       int timerr;
+       double ftimerr, abserr;
+#ifdef DEBUG_DATUM_PTC
+       double dispersion;
+#endif
+       int goodtime;
+      /*double doffset;*/
+
+       /*
+       ** Get the time code (maybe partial) message out of the rbufp buffer.
+       */
+
+       datum_pts = (struct datum_pts_unit *)rbufp->recv_srcclock;
+       dpt = (char *)&rbufp->recv_space;
+       dpend = rbufp->recv_length;
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("Receive Datum PTS: %d bytes\n", dpend);
+#endif
+
+       /*                                                                      */
+       /*...... save the ntp system time when the first byte is received ......*/
+       /*                                                                      */
+
+       /*
+       ** Save the ntp system time when the first byte is received. Note that
+       ** because it may take several calls to this routine before all seven
+       ** bytes of our return message are finally received by the io handlers in
+       ** ntpd, we really do want to use the time tag when the first byte is
+       ** received to reduce the jitter.
+       */
+
+       if (datum_pts->nbytes == 0) {
+               datum_pts->lastrec = rbufp->recv_time;
+       }
+
+       /*
+       ** Increment our count to the number of bytes received so far. Return if we
+       ** haven't gotten all seven bytes yet.
+       */
+
+       for (i=0; i<dpend; i++) {
+               datum_pts->retbuf[datum_pts->nbytes+i] = dpt[i];
+       }
+
+       datum_pts->nbytes += dpend;
+
+       if (datum_pts->nbytes != 7) {
+               return;
+       }
+
+       /*
+       ** Convert the seven bytes received in our time buffer to day, hour, minute,
+       ** second, and msecond values. The usec value is not used for anything
+       ** currently. It is just the fractional part of the time stored in units
+       ** of microseconds.
+       */
+
+       datum_pts->day =        100*(datum_pts->retbuf[0] & 0x0f) +
+               10*((datum_pts->retbuf[1] & 0xf0)>>4) +
+               (datum_pts->retbuf[1] & 0x0f);
+
+       datum_pts->hour =       10*((datum_pts->retbuf[2] & 0x30)>>4) +
+               (datum_pts->retbuf[2] & 0x0f);
+
+       datum_pts->minute =     10*((datum_pts->retbuf[3] & 0x70)>>4) +
+               (datum_pts->retbuf[3] & 0x0f);
+
+       datum_pts->second =     10*((datum_pts->retbuf[4] & 0x70)>>4) +
+               (datum_pts->retbuf[4] & 0x0f);
+
+       datum_pts->msec =       100*((datum_pts->retbuf[5] & 0xf0) >> 4) + 
+               10*(datum_pts->retbuf[5] & 0x0f) +
+               ((datum_pts->retbuf[6] & 0xf0)>>4);
+
+       datum_pts->usec =       1000*datum_pts->msec;
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("day %d, hour %d, minute %d, second %d, msec %d\n",
+                  datum_pts->day,
+                  datum_pts->hour,
+                  datum_pts->minute,
+                  datum_pts->second,
+                  datum_pts->msec);
+#endif
+
+       /*
+       ** Get the GMT time zone offset. Note that GMT should be zero if the Datum
+       ** reference time is using GMT as its time base. Otherwise we have to
+       ** determine the offset if the Datum PTS is using time of day as its time
+       ** base.
+       */
+
+       goodtime = 0;           /* We are not sure about the time and offset yet */
+
+#ifdef GMT
+
+       /*
+       ** This is the case where the Datum PTS is using GMT so there is no time
+       ** zone offset.
+       */
+
+       tzoff = 0;              /* set time zone offset to 0 */
+
+#else
+
+       /*
+       ** This is the case where the Datum PTS is using regular time of day for its
+       ** time so we must compute the time zone offset. The way we do it is kind of
+       ** funny but it works. We loop through different time zones (0 to 24) and
+       ** pick the one that gives the smallest error (+- one half hour). The time
+       ** zone offset is stored in the datum_pts structure for future use. Normally,
+       ** the clocktime() routine is only called once (unless the time zone offset
+       ** changes due to daylight savings) since the goodtime flag is set when a
+       ** good time is found (with a good offset). Note that even if the Datum
+       ** PTS is using GMT, this mechanism will still work since it should come up
+       ** with a value for tzoff = 0 (assuming that your system clock is within
+       ** a half hour of the Datum time (even with time zone differences).
+       */
+
+       for (tzoff=0; tzoff<24; tzoff++) {
+               if (clocktime( datum_pts->day,
+                              datum_pts->hour,
+                              datum_pts->minute,
+                              datum_pts->second,
+                              (tzoff + datum_pts->tzoff) % 24,
+                              datum_pts->lastrec.l_ui,
+                              &datum_pts->yearstart,
+                              &datum_pts->lastref.l_ui) ) {
+
+                       datum_pts->lastref.l_uf = 0;
+                       error = datum_pts->lastref.l_ui - datum_pts->lastrec.l_ui;
+
+#ifdef DEBUG_DATUM_PTC
+                       printf("Time Zone (clocktime method) = %d, error = %d\n", tzoff, error);
+#endif
+
+                       if ((error < 1799) && (error > -1799)) {
+                               tzoff = (tzoff + datum_pts->tzoff) % 24;
+                               datum_pts->tzoff = tzoff;
+                               goodtime = 1;
+
+#ifdef DEBUG_DATUM_PTC
+                               printf("Time Zone found (clocktime method) = %d\n",tzoff);
+#endif
+
+                               break;
+                       }
+
+               }
+       }
+
+#endif
+
+       /*
+       ** Make sure that we have a good time from the Datum PTS. Clocktime() also
+       ** sets yearstart and lastref.l_ui. We will have to set astref.l_uf (i.e.,
+       ** the fraction of a second) stuff later.
+       */
+
+       if (!goodtime) {
+
+               if (!clocktime( datum_pts->day,
+                               datum_pts->hour,
+                               datum_pts->minute,
+                               datum_pts->second,
+                               tzoff,
+                               datum_pts->lastrec.l_ui,
+                               &datum_pts->yearstart,
+                               &datum_pts->lastref.l_ui) ) {
+
+#ifdef DEBUG_DATUM_PTC
+                       if (debug)
+                       {
+                               printf("Error: bad clocktime\n");
+                               printf("GMT %d, lastrec %d, yearstart %d, lastref %d\n",
+                                      tzoff,
+                                      datum_pts->lastrec.l_ui,
+                                      datum_pts->yearstart,
+                                      datum_pts->lastref.l_ui);
+                       }
+#endif
+
+                       msyslog(LOG_ERR, "Datum_PTS: Bad clocktime");
+
+                       return;
+
+               }else{
+
+#ifdef DEBUG_DATUM_PTC
+                       if (debug)
+                           printf("Good clocktime\n");
+#endif
+
+               }
+
+       }
+
+       /*
+       ** We have datum_pts->lastref.l_ui set (which is the integer part of the
+       ** time. Now set the microseconds field.
+       */
+
+       TVUTOTSF(datum_pts->usec, datum_pts->lastref.l_uf);
+
+       /*
+       ** Compute the time correction as the difference between the reference
+       ** time (i.e., the Datum time) minus the receive time (system time).
+       */
+
+       tstmp = datum_pts->lastref;             /* tstmp is the datum ntp time */
+       L_SUB(&tstmp, &datum_pts->lastrec);     /* tstmp is now the correction */
+       datum_pts->coderecv++;          /* increment a counter */
+
+#ifdef DEBUG_DATUM_PTC
+       dispersion = DATUM_DISPERSION;  /* set the dispersion to 0 */
+       ftimerr = dispersion;
+       ftimerr /= (1024.0 * 64.0);
+       if (debug)
+           printf("dispersion = %d, %f\n", dispersion, ftimerr);
+#endif
+
+       /*
+       ** Pass the new time to ntpd through the refclock_receive function. Note
+       ** that we are not trying to make any corrections due to the time it takes
+       ** for the Datum PTS to send the message back. I am (erroneously) assuming
+       ** that the time for the Datum PTS to send the time back to us is negligable.
+       ** I suspect that this time delay may be as much as 15 ms or so (but probably
+       ** less). For our needs at JPL, this kind of error is ok so it is not
+       ** necessary to use fudge factors in the ntp.conf file. Maybe later we will.
+       */
+      /*LFPTOD(&tstmp, doffset);*/
+       datum_pts->lastref = datum_pts->lastrec;
+       refclock_receive(datum_pts->peer);
+
+       /*
+       ** Compute sigma squared (not used currently). Maybe later, this could be
+       ** used for the dispersion estimate. The problem is that ntpd does not link
+       ** in the math library so sqrt() is not available. Anyway, this is useful
+       ** for debugging. Maybe later I will just use absolute values for the time
+       ** error to come up with my dispersion estimate. Anyway, for now my dispersion
+       ** is set to 0.
+       */
+
+       timerr = tstmp.l_ui<<20;
+       timerr |= (tstmp.l_uf>>12) & 0x000fffff;
+       ftimerr = timerr;
+       ftimerr /= 1024*1024;
+       abserr = ftimerr;
+       if (ftimerr < 0.0) abserr = -ftimerr;
+
+       if (datum_pts->sigma2 == 0.0) {
+               if (abserr < DATUM_MAX_ERROR) {
+                       datum_pts->sigma2 = abserr*abserr;
+               }else{
+                       datum_pts->sigma2 = DATUM_MAX_ERROR2;
+               }
+       }else{
+               if (abserr < DATUM_MAX_ERROR) {
+                       datum_pts->sigma2 = 0.95*datum_pts->sigma2 + 0.05*abserr*abserr;
+               }else{
+                       datum_pts->sigma2 = 0.95*datum_pts->sigma2 + 0.05*DATUM_MAX_ERROR2;
+               }
+       }
+
+#ifdef DEBUG_DATUM_PTC
+       if (debug)
+           printf("Time error = %f seconds\n", ftimerr);
+#endif
+
+#if defined(DEBUG_DATUM_PTC) || defined(LOG_TIME_ERRORS)
+       if (debug)
+           printf("PTS: day %d, hour %d, minute %d, second %d, msec %d, Time Error %f\n",
+                  datum_pts->day,
+                  datum_pts->hour,
+                  datum_pts->minute,
+                  datum_pts->second,
+                  datum_pts->msec,
+                  ftimerr);
+#endif
+
+}
+#else
+int refclock_datum_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_dumbclock.c b/ntpd/refclock_dumbclock.c
new file mode 100644 (file)
index 0000000..10ff2cf
--- /dev/null
@@ -0,0 +1,386 @@
+/*
+ * refclock_dumbclock - clock driver for a unknown time distribution system
+ * that only provides hh:mm:ss (in local time, yet!).
+ */
+
+/*
+ * Must interpolate back to local time.  Very annoying.
+ */
+#define GET_LOCALTIME
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_DUMBCLOCK)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef SYS_WINNT
+extern int async_write(int, const void *, unsigned int);
+#undef write
+#define write(fd, data, octets)        async_write(fd, data, octets)
+#endif
+
+/*
+ * This driver supports a generic dumb clock that only outputs hh:mm:ss,
+ * in local time, no less.
+ *
+ * Input format:
+ *
+ *      hh:mm:ss   <cr>
+ *
+ * hh:mm:ss -- what you'd expect, with a 24 hour clock.  (Heck, that's the only
+ * way it could get stupider.)  We take time on the <cr>.
+ *
+ * The original source of this module was the WWVB module.
+ */
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/dumbclock%d" /* device name and unit */
+#define        SPEED232        B9600   /* uart speed (9600 baud) */
+#define        PRECISION       (-13)   /* precision assumed (about 100 us) */
+#define        REFID           "dumbclock"     /* reference ID */
+#define        DESCRIPTION     "Dumb clock" /* WRU */
+
+
+/*
+ * Insanity check.  Since the time is local, we need to make sure that during midnight
+ * transitions, we can convert back to Unix time.  If the conversion results in some number
+ * worse than this number of seconds away, assume the next day and retry.
+ */
+#define INSANE_SECONDS 3600
+
+/*
+ * Dumb clock control structure
+ */
+struct dumbclock_unit {
+       u_char    tcswitch;                  /* timecode switch */
+       l_fp      laststamp;                 /* last receive timestamp */
+       u_char    lasthour;                  /* last hour (for monitor) */
+       u_char    linect;                    /* count ignored lines (for monitor */
+        struct tm ymd;                      /* struct tm for y/m/d only */
+};
+
+/*
+ * Function prototypes
+ */
+static int     dumbclock_start         P((int, struct peer *));
+static void    dumbclock_shutdown      P((int, struct peer *));
+static void    dumbclock_receive       P((struct recvbuf *));
+#if 0
+static void    dumbclock_poll          P((int, struct peer *));
+#endif
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_dumbclock = {
+       dumbclock_start,                     /* start up driver */
+       dumbclock_shutdown,                  /* shut down driver */
+       noentry,                             /* poll the driver -- a nice fabrication */
+       noentry,                             /* not used */
+       noentry,                             /* not used */
+       noentry,                             /* not used */
+       NOFLAGS                              /* not used */
+};
+
+
+/*
+ * dumbclock_start - open the devices and initialize data for processing
+ */
+static int
+dumbclock_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct dumbclock_unit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+       struct tm *tm_time_p;
+       time_t     now;
+
+       /*
+        * Open serial port. Don't bother with CLK line discipline, since
+        * it's not available.
+        */
+       (void)sprintf(device, DEVICE, unit);
+#ifdef DEBUG
+       if (debug)
+               printf ("starting Dumbclock with device %s\n",device);
+#endif
+       fd = refclock_open(device, SPEED232, 0);
+       if (fd < 0)
+               return (0);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       up = (struct dumbclock_unit *)emalloc(sizeof(struct dumbclock_unit));
+       if (up == NULL) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct dumbclock_unit));
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t)up;
+       pp->io.clock_recv = dumbclock_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+
+
+       time(&now);
+#ifdef GET_LOCALTIME
+       tm_time_p = localtime(&now);
+#else
+       tm_time_p = gmtime(&now);
+#endif
+       if (tm_time_p)
+       {
+           up->ymd = *tm_time_p;
+       }
+       else
+       {
+           return 0;
+       }
+           
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       return (1);
+}
+
+
+/*
+ * dumbclock_shutdown - shut down the clock
+ */
+static void
+dumbclock_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct dumbclock_unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct dumbclock_unit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * dumbclock_receive - receive data from the serial interface
+ */
+static void
+dumbclock_receive(
+       struct recvbuf *rbufp
+       )
+{
+       struct dumbclock_unit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+
+       l_fp         trtmp;     /* arrival timestamp */
+       int          hours;     /* hour-of-day */
+       int          minutes;   /* minutes-past-the-hour */
+       int          seconds;   /* seconds */
+       int          temp;      /* int temp */
+       int          got_good;  /* got a good time flag */
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct dumbclock_unit *)pp->unitptr;
+       temp = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp);
+
+       if (temp == 0) {
+               if (up->tcswitch == 0) {
+                       up->tcswitch = 1;
+                       up->laststamp = trtmp;
+               } else
+                   up->tcswitch = 0;
+               return;
+       }
+       pp->lencode = (u_short)temp;
+       pp->lastrec = up->laststamp;
+       up->laststamp = trtmp;
+       up->tcswitch = 1;
+
+#ifdef DEBUG
+       if (debug)
+               printf("dumbclock: timecode %d %s\n",
+                      pp->lencode, pp->a_lastcode);
+#endif
+
+       /*
+        * We get down to business. Check the timecode format...
+        */
+       got_good=0;
+       if (sscanf(pp->a_lastcode,"%02d:%02d:%02d",
+                  &hours,&minutes,&seconds) == 3)
+       {
+           struct tm *gmtp;
+           struct tm *lt_p;
+           time_t     asserted_time;        /* the SPM time based on the composite time+date */
+           struct tm  asserted_tm;          /* the struct tm of the same */
+           int        adjyear;
+           int        adjmon;
+           int        reality_delta;
+           time_t     now;
+
+
+           /*
+            * Convert to GMT for sites that distribute localtime.  This
+             * means we have to figure out what day it is.  Easier said
+            * than done...
+            */
+
+           asserted_tm.tm_year  = up->ymd.tm_year;
+           asserted_tm.tm_mon   = up->ymd.tm_mon;
+           asserted_tm.tm_mday  = up->ymd.tm_mday;
+           asserted_tm.tm_hour  = hours;
+           asserted_tm.tm_min   = minutes;
+           asserted_tm.tm_sec   = seconds;
+           asserted_tm.tm_isdst = -1;
+
+#ifdef GET_LOCALTIME
+           asserted_time = mktime (&asserted_tm);
+           time(&now);
+#else
+#include "GMT unsupported for dumbclock!"
+#endif
+           reality_delta = asserted_time - now;
+
+           /*
+            * We assume that if the time is grossly wrong, it's because we got the
+            * year/month/day wrong.
+            */
+           if (reality_delta > INSANE_SECONDS)
+           {
+               asserted_time -= SECSPERDAY; /* local clock behind real time */
+           }
+           else if (-reality_delta > INSANE_SECONDS)
+           {
+               asserted_time += SECSPERDAY; /* local clock ahead of real time */
+           }
+           lt_p = localtime(&asserted_time);
+           if (lt_p)
+           {
+               up->ymd = *lt_p;
+           }
+           else
+           {
+               refclock_report (peer, CEVNT_FAULT);
+               return;
+           }
+
+           if ((gmtp = gmtime (&asserted_time)) == NULL)
+           {
+               refclock_report (peer, CEVNT_FAULT);
+               return;
+           }
+           adjyear = gmtp->tm_year+1900;
+           adjmon  = gmtp->tm_mon+1;
+           pp->day = ymd2yd (adjyear, adjmon, gmtp->tm_mday);
+           pp->hour   = gmtp->tm_hour;
+           pp->minute = gmtp->tm_min;
+           pp->second = gmtp->tm_sec;
+#ifdef DEBUG
+           if (debug)
+               printf ("time is %04d/%02d/%02d %02d:%02d:%02d UTC\n",
+                       adjyear,adjmon,gmtp->tm_mday,pp->hour,pp->minute,
+                       pp->second);
+#endif
+
+           got_good=1;
+       }
+
+       if (!got_good)
+       {
+           if (up->linect > 0)
+               up->linect--;
+           else
+               refclock_report(peer, CEVNT_BADREPLY);
+           return;
+       }
+
+       /*
+        * Process the new sample in the median filter and determine the
+        * timecode timestamp.
+        */
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       up->lasthour = (u_char)pp->hour;
+}
+
+#if 0
+/*
+ * dumbclock_poll - called by the transmit procedure
+ */
+static void
+dumbclock_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct dumbclock_unit *up;
+       struct refclockproc *pp;
+       char pollchar;
+
+       /*
+        * Time to poll the clock. The Chrono-log clock is supposed to
+        * respond to a 'T' by returning a timecode in the format(s)
+        * specified above.  Ours does (can?) not, but this seems to be
+        * an installation-specific problem.  This code is dyked out,
+        * but may be re-enabled if anyone ever finds a Chrono-log that
+        * actually listens to this command.
+        */
+#if 0
+       pp = peer->procptr;
+       up = (struct dumbclock_unit *)pp->unitptr;
+       if (peer->reach == 0)
+               refclock_report(peer, CEVNT_TIMEOUT);
+       if (up->linect > 0)
+               pollchar = 'R';
+       else
+               pollchar = 'T';
+       if (write(pp->io.fd, &pollchar, 1) != 1)
+               refclock_report(peer, CEVNT_FAULT);
+       else
+               pp->polls++;
+#endif
+}
+#endif
+
+#else
+int refclock_dumbclock_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_fg.c b/ntpd/refclock_fg.c
new file mode 100644 (file)
index 0000000..ce5085a
--- /dev/null
@@ -0,0 +1,345 @@
+/*
+ * refclock_fg - clock driver for the Forum Graphic GPS datating station
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_FG)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+/*
+ * This driver supports the Forum Graphic GPS dating station.
+ * More information about FG GPS is available on http://www.forumgraphic.com
+ * Contact das@amt.ru for any question about this driver.
+ */
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/fgclock%d"
+#define        PRECISION       (-10)   /* precision assumed (about 1 ms) */
+#define REFID          "GPS"
+#define DESCRIPTION    "Forum Graphic GPS dating station"
+#define LENFG          26      /* timecode length */
+#define SPEED232        B9600   /* uart speed (9600 baud) */
+
+/*
+ * Function prototypes
+ */
+static int     fg_init                 P((int));
+static int     fg_start                P((int, struct peer *));
+static void    fg_shutdown             P((int, struct peer *));
+static void    fg_poll         P((int, struct peer *));
+static  void    fg_receive     P((struct recvbuf *));
+
+/* 
+ * Forum Graphic unit control structure
+ */
+
+struct fgunit {
+       int pollnum;    /* Use peer.poll instead? */
+       int status;     /* Hug to check status information on GPS */
+       int y2kwarn;            /* Y2K bug */
+};
+
+/* 
+ * Queries definition
+ */
+static char fginit[] = { 0x10, 0x48, 0x10, 0x0D, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0 };
+static char fgdate[] = { 0x10, 0x44, 0x10, 0x0D, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+0, 0, 0, 0, 0, 0, 0, 0, 0 };
+
+/*
+ * Transfer vector
+ */
+struct  refclock refclock_fg = {
+       fg_start,              /* start up driver */
+       fg_shutdown,           /* shut down driver */
+       fg_poll,               /* transmit poll message */
+       noentry,                /* not used */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used */
+       NOFLAGS                 /* not used */
+};
+
+/*
+ * fg_init - Initialization of FG GPS.
+ */
+
+static int
+fg_init(
+       int fd
+       )
+{
+       if (write(fd, fginit, LENFG) != LENFG)
+                return 0;
+
+       return (1);
+
+}
+
+/*
+ * fg_start - open the device and initialize data for processing
+ */
+static int
+fg_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       struct fgunit *up;
+       int fd;
+       char device[20];
+
+
+       /*
+        * Open device file for reading.
+        */
+       (void)sprintf(device, DEVICE, unit);
+
+#ifdef DEBUG
+       if (debug)
+               printf ("starting FG with device %s\n",device);
+#endif
+        if (!(fd = refclock_open(device, SPEED232, LDISC_CLK)))
+                return (0);
+       
+        /*
+         * Allocate and initialize unit structure
+         */
+
+       if (!(up = (struct fgunit *)
+              emalloc(sizeof(struct fgunit)))) {
+                (void) close(fd);
+                return (0);
+        }
+       memset((char *)up, 0, sizeof(struct fgunit));
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t)up;
+       pp->io.clock_recv = fg_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+                (void) close(fd);
+                return (0);
+        }
+
+       
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 3);
+       up->pollnum = 0;
+       
+       /* 
+        * Setup dating station to use GPS receiver.
+        * GPS receiver should work before this operation.
+         */
+       if(!fg_init(pp->io.fd))
+               refclock_report(peer, CEVNT_FAULT);
+
+       return (1);
+}
+
+
+/*
+ * fg_shutdown - shut down the clock
+ */
+static void
+fg_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       struct fgunit *up;
+       
+       pp = peer->procptr;
+       up = (struct fgunit *)pp->unitptr;
+        io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * fg_poll - called by the transmit procedure
+ */
+static void
+fg_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       
+       pp = peer->procptr;
+
+        /*
+         * Time to poll the clock. The FG clock responds to a
+         * "<DLE>D<DLE><CR>" by returning a timecode in the format specified
+         * above. If nothing is heard from the clock for two polls,
+         * declare a timeout and keep going.
+         */
+
+       if (write(pp->io.fd, fgdate, LENFG) != LENFG)
+                refclock_report(peer, CEVNT_FAULT);
+        else
+                pp->polls++;
+
+        if (peer->burst > 0)
+                return;
+       /*
+        if (pp->coderecv == pp->codeproc) {
+                refclock_report(peer, CEVNT_TIMEOUT);
+                return;
+        }
+       */
+        peer->burst = NSTAGE;
+
+        record_clock_stats(&peer->srcadr, pp->a_lastcode);
+        
+       
+       return;
+
+}
+
+/*
+ * fg_receive - receive data from the serial interface
+ */
+static void
+fg_receive(
+        struct recvbuf *rbufp
+        )
+{
+        struct refclockproc *pp;
+       struct fgunit *up;
+        struct peer *peer;
+       char *bpt;
+
+        /*
+         * Initialize pointers and read the timecode and timestamp
+        * We can't use gtlin function because we need bynary data in buf */
+
+        peer = (struct peer *)rbufp->recv_srcclock;
+        pp = peer->procptr;
+        up = (struct fgunit *)pp->unitptr;
+
+       /*
+         * Below hug to implement receiving of status information
+         */
+       if(!up->pollnum)
+       {
+               up->pollnum++;
+               return;
+       }
+
+       
+       if (rbufp->recv_length < (LENFG-2))
+       {
+               refclock_report(peer, CEVNT_BADREPLY);
+               return; /* The reply is invalid discard it. */
+       }
+
+       /* Below I trying to find a correct reply in buffer.
+        * Sometime GPS reply located in the beginnig of buffer,
+        * sometime you can find it with some offset.
+        */
+
+       bpt = (char *)rbufp->recv_space.X_recv_buffer;
+       while(*bpt != '\10')
+               bpt++;
+
+#define BP2(x) ( bpt[x] & 15 )
+#define BP1(x) (( bpt[x] & 240 ) >> 4)
+       
+        pp->year = BP1(2)*10 + BP2(2);
+       
+       if(pp->year == 94)
+       {
+               refclock_report(peer, CEVNT_BADREPLY);
+               if(!fg_init(pp->io.fd))
+                       refclock_report(peer, CEVNT_FAULT);
+               return;
+                /* GPS is just powered up. The date is invalid -
+                discarding it. Initilize GPS one more time */
+               /* Sorry - this driver will broken in 2094 ;) */
+       }       
+       
+       if (pp->year < 99)
+                pp->year += 100;
+
+        pp->year +=  1900;
+        pp->day = 100 * BP2(3) + 10 * BP1(4) + BP2(4);
+
+/*
+   After Jan, 10 2000 Forum Graphic GPS receiver had a very strange
+   benahour. It doubles day number for an hours in replys after 10:10:10 UTC
+   and doubles min every hour at HH:10:ss for a minute.
+   Hope it is a problem of my unit only and not a Y2K problem of FG GPS. 
+   Below small code to avoid such situation.
+*/
+       if(up->y2kwarn > 10)
+               pp->hour = BP1(6)*10 + BP2(6);
+       else
+               pp->hour = BP1(5)*10 + BP2(5);
+
+       if((up->y2kwarn > 10) && (pp->hour == 10))
+       {
+               pp->minute = BP1(7)*10 + BP2(7);
+               pp->second = BP1(8)*10 + BP2(8);
+               pp->nsec = (BP1(9)*10 + BP2(9)) * 1000000;
+               pp->nsec += BP1(10) * 1000;
+       } else {
+               pp->hour = BP1(5)*10 + BP2(5);
+               pp->minute = BP1(6)*10 + BP2(6);
+               pp->second = BP1(7)*10 + BP2(7);
+               pp->nsec = (BP1(8)*10 + BP2(8)) * 1000000;
+               pp->nsec += BP1(9) * 1000;
+       }
+        
+       if((pp->hour == 10) && (pp->minute == 10))
+       {
+               up->y2kwarn++;
+       }
+
+       sprintf(pp->a_lastcode, "%d %d %d %d %d", pp->year, pp->day, pp->hour, pp->minute, pp->second);
+       pp->lencode = strlen(pp->a_lastcode);
+        /*get_systime(&pp->lastrec);*/
+
+#ifdef DEBUG
+        if (debug)
+                printf ("fg: time is %04d/%03d %02d:%02d:%02d UTC\n",
+                         pp->year, pp->day, pp->hour, pp->minute, pp->second);
+#endif
+        pp->disp =  (10e-6);
+       pp->lastrec = rbufp->recv_time; /* Is it better than get_systime()? */
+       /* pp->leap = LEAP_NOWARNING; */
+
+        /*
+         * Process the new sample in the median filter and determine the
+         * timecode timestamp.
+         */
+
+        if (!refclock_process(pp))
+                refclock_report(peer, CEVNT_BADTIME);
+        pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+       return;
+}
+
+
+#else
+int refclock_fg_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_gpsvme.c b/ntpd/refclock_gpsvme.c
new file mode 100644 (file)
index 0000000..9f9e85c
--- /dev/null
@@ -0,0 +1,254 @@
+/* refclock_psc.c:  clock driver for Brandywine PCI-SyncClock32/HP-UX 11.X */
+
+#ifdef HAVE_CONFIG_H
+#include       <config.h>
+#endif /* HAVE_CONFIG_H        */
+
+#if defined(REFCLOCK) && defined(CLOCK_GPSVME)
+
+#include       "ntpd.h"
+#include       "ntp_io.h"
+#include       "ntp_refclock.h"
+#include       "ntp_unixtime.h"
+#include       "ntp_stdlib.h"
+
+#ifdef __hpux
+#include       <sys/rtprio.h>  /* may already be included above        */
+#include       <sys/lock.h>    /* NEEDED for PROCLOCK                  */
+#endif /* __hpux       */
+
+#ifdef __linux__
+#include       <sys/ioctl.h>   /* for _IOR, ioctl                      */
+#endif /* __linux__    */
+
+enum {                         /* constants    */
+    BUFSIZE                    =       32,
+    PSC_SYNC_OK                        =       0x40,   /* Sync status bit      */
+    DP_LEAPSEC_DAY10DAY1       =       0x82,   /* DP RAM address       */
+    DP_LEAPSEC_DAY1000DAY100   =       0x83,
+    DELAY                      =       1,
+    NUNIT                      =       2       /* max UNITS            */
+};
+
+/*     clock card registers    */
+struct psc_regs {
+    uint32_t           low_time;       /* card base + 0x00     */
+    uint32_t           high_time;      /* card base + 0x04     */
+    uint32_t           ext_low_time;   /* card base + 0x08     */
+    uint32_t           ext_high_time;  /* card base + 0x0C     */
+    uint8_t            device_status;  /* card base + 0x10     */
+    uint8_t            device_control; /* card base + 0x11     */
+    uint8_t            reserved0;      /* card base + 0x12     */
+    uint8_t            ext_100ns;      /* card base + 0x13     */
+    uint8_t            match_usec;     /* card base + 0x14     */
+    uint8_t            match_msec;     /* card base + 0x15     */
+    uint8_t            reserved1;      /* card base + 0x16     */
+    uint8_t            reserved2;      /* card base + 0x17     */
+    uint8_t            reserved3;      /* card base + 0x18     */
+    uint8_t            reserved4;      /* card base + 0x19     */
+    uint8_t            dp_ram_addr;    /* card base + 0x1A     */
+    uint8_t            reserved5;      /* card base + 0x1B     */
+    uint8_t            reserved6;      /* card base + 0x1C     */
+    uint8_t            reserved7;      /* card base + 0x1D     */
+    uint8_t            dp_ram_data;    /* card base + 0x1E     */
+    uint8_t            reserved8;      /* card base + 0x1F     */
+} *volatile regp[NUNIT];
+
+#define        PSC_REGS        _IOR('K', 0, long)      /* ioctl argument       */
+
+/* Macros to swap byte order and convert BCD to binary */
+#define SWAP(val) ( ((val) >> 24) | (((val) & 0x00ff0000) >> 8) | \
+(((val) & 0x0000ff00) << 8) | (((val) & 0x000000ff) << 24) )
+#define BCD2INT2(val)  ( ((val) >> 4 & 0x0f)*10 + ((val) & 0x0f) )
+#define BCD2INT3(val)  ( ((val) >> 8 & 0x0f)*100 + ((val) >> 4 & 0x0f)*10 + \
+((val) & 0x0f) )
+
+/* PSC interface definitions */
+#define PRECISION      (-20)   /* precision assumed (1 us)     */
+#define REFID          "USNO"  /* reference ID */
+#define DESCRIPTION    "Brandywine PCI-SyncClock32"
+#define DEVICE         "/dev/refclock%1d"      /* device file  */
+
+/* clock unit control structure */
+struct psc_unit {
+    short      unit;           /* NTP refclock unit number     */
+    short      last_hour;      /* last hour (monitor leap sec) */
+    int                msg_flag[2];    /* count error messages         */
+};
+int    fd[NUNIT];              /* file descriptor      */
+
+/* Local function prototypes */
+static int             psc_start(int, struct peer *);
+static void            psc_shutdown(int, struct peer *);
+static void            psc_poll(int, struct peer *);
+static void            check_leap_sec(struct refclockproc *, int);
+
+/* Transfer vector     */
+struct refclock        refclock_gpsvme = {
+    psc_start, psc_shutdown, psc_poll, noentry, noentry, noentry, NOFLAGS
+};
+
+/* psc_start:  open device and initialize data for processing */
+static int
+psc_start(
+    int                unit,
+    struct peer        *peer
+    )
+{
+    char                       buf[BUFSIZE];
+    struct refclockproc                *pp;
+    struct psc_unit            *up = emalloc(sizeof *up);
+
+    if (unit < 0 || unit > 1) {                /* support units 0 and 1        */
+       msyslog(LOG_ERR, "psc_start: bad unit: %d", unit);
+       return 0;
+    }
+
+    if (!up) {
+       msyslog(LOG_ERR, "psc_start: unit: %d, emalloc: %m", unit);
+       return 0;
+    }
+    memset(up, '\0', sizeof *up);
+
+    sprintf(buf, DEVICE, unit);                /* dev file name        */
+    fd[unit] = open(buf, O_RDONLY);    /* open device file     */
+    if (fd[unit] < 0) {
+       msyslog(LOG_ERR, "psc_start: unit: %d, open failed.  %m", unit);
+       return 0;
+    }
+     
+    /* get the address of the mapped regs      */
+    if (ioctl(fd[unit], PSC_REGS, &regp[unit]) < 0) {
+       msyslog(LOG_ERR, "psc_start: unit: %d, ioctl failed.  %m", unit);
+       return 0;
+    }
+
+    /* initialize peer variables       */
+    pp = peer->procptr;
+    pp->io.clock_recv = noentry;
+    pp->io.srcclock = (caddr_t) peer;
+    pp->io.datalen = 0;
+    pp->io.fd = -1;
+    pp->unitptr = (caddr_t) up;
+    get_systime(&pp->lastrec);
+    memcpy((char *)&pp->refid, REFID, 4);
+    peer->precision = PRECISION;
+    pp->clockdesc = DESCRIPTION;
+    up->unit = unit;
+#ifdef __hpux     
+    rtprio(0,120);             /* set real time priority       */
+    plock(PROCLOCK);           /* lock process in memory       */
+#endif /* __hpux       */     
+    return 1;
+}
+
+/* psc_shutdown:  shut down the clock */
+static void
+psc_shutdown(
+    int                unit,
+    struct peer        *peer
+    )
+{
+    free(peer->procptr->unitptr);
+    close(fd[unit]);
+}
+
+/* psc_poll:  read, decode, and record device time */
+static void
+psc_poll(
+    int                unit,
+    struct peer        *peer
+    )
+{
+    struct refclockproc        *pp = peer->procptr;
+    struct psc_unit            *up;
+    unsigned                   tlo, thi;
+    unsigned char              status;
+
+    up = (struct psc_unit *) pp->unitptr;
+    tlo = regp[unit]->low_time;                /* latch and read first 4 bytes */
+    thi = regp[unit]->high_time;       /* read 4 higher order bytes    */
+    status = regp[unit]->device_status;        /* read device status byte      */
+
+    if (!(status & PSC_SYNC_OK)) {
+       refclock_report(peer, CEVNT_BADTIME);
+       if (!up->msg_flag[unit]) {      /* write once to system log     */
+           msyslog(LOG_WARNING,
+               "SYNCHRONIZATION LOST on unit %1d, status %02x\n",
+               status, unit);
+           up->msg_flag[unit] = 1;
+       }
+       return;
+    }
+
+    get_systime(&pp->lastrec);
+    pp->polls++;
+     
+    tlo = SWAP(tlo);                   /* little to big endian swap on */
+    thi = SWAP(thi);                   /* copy of data                 */
+    /* convert the BCD time to broken down time used by refclockproc   */
+    pp->day    = BCD2INT3((thi & 0x0FFF0000) >> 16);
+    pp->hour   = BCD2INT2((thi & 0x0000FF00) >> 8);
+    pp->minute = BCD2INT2(thi & 0x000000FF);
+    pp->second = BCD2INT2(tlo >> 24);
+    /* ntp_process() in ntp_refclock.c appears to use usec as fraction of
+       second in microseconds if usec is nonzero. */
+    pp->nsec   = 1000000*BCD2INT3((tlo & 0x00FFF000) >> 12) +
+       BCD2INT3(tlo & 0x00000FFF);
+
+    sprintf(pp->a_lastcode, "%3.3d %2.2d:%2.2d:%2.2d.%09ld %02x %08x %08x",
+       pp->day, pp->hour, pp->minute, pp->second, pp->nsec, status, thi,
+       tlo);
+    pp->lencode = strlen(pp->a_lastcode);
+
+    /* compute the timecode timestamp  */
+    if (!refclock_process(pp)) {
+       refclock_report(peer, CEVNT_BADTIME);
+       return;
+    }
+    /* simulate the NTP receive and packet procedures  */
+    refclock_receive(peer);
+    /* write clock statistics to file  */
+    record_clock_stats(&peer->srcadr, pp->a_lastcode); 
+
+    /* With the first timecode beginning the day, check for a GPS
+       leap second notification.      */
+    if (pp->hour < up->last_hour) {
+       check_leap_sec(pp, unit);
+       up->msg_flag[0] = up->msg_flag[1] = 0;  /* reset flags  */
+    }
+    up->last_hour = pp->hour;
+}
+
+/* check_leap_sec:  read the Dual Port RAM leap second day registers.  The
+   onboard GPS receiver should write the hundreds digit of day of year in
+   DP_LeapSec_Day1000Day100 and the tens and ones digits in
+   DP_LeapSec_Day10Day1.  If these values are nonzero and today, we have
+   a leap second pending, so we set the pp->leap flag to LEAP_ADDSECOND.
+   If the BCD data are zero or a date other than today, set pp->leap to
+   LEAP_NOWARNING.  */
+static void
+check_leap_sec(struct refclockproc *pp, int unit)
+{
+    unsigned char      dhi, dlo;
+    int                        leap_day;
+     
+    regp[unit]->dp_ram_addr = DP_LEAPSEC_DAY10DAY1;
+    usleep(DELAY);
+    dlo = regp[unit]->dp_ram_data;
+    regp[unit]->dp_ram_addr = DP_LEAPSEC_DAY1000DAY100;
+    usleep(DELAY);
+    dhi = regp[unit]->dp_ram_data;
+    leap_day = BCD2INT2(dlo) + 100*(dhi & 0x0F);
+
+    pp->leap = LEAP_NOWARNING;                 /* default      */
+    if (leap_day && leap_day == pp->day) {
+       pp->leap = LEAP_ADDSECOND;              /* leap second today    */
+       msyslog(LOG_ERR, "LEAP_ADDSECOND flag set, day %d (%x %x).",
+           leap_day, dhi, dlo);
+    }
+}
+
+#else
+int    refclock_gpsvme_bs;
+#endif /* REFCLOCK     */
diff --git a/ntpd/refclock_heath.c b/ntpd/refclock_heath.c
new file mode 100644 (file)
index 0000000..a56b491
--- /dev/null
@@ -0,0 +1,451 @@
+/*
+ * refclock_heath - clock driver for Heath GC-1000
+ * (but no longer the GC-1001 Model II, which apparently never worked)
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_HEATH)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif /* not HAVE_SYS_IOCTL_H */
+
+/*
+ * This driver supports the Heath GC-1000 Most Accurate Clock, with
+ * RS232C Output Accessory. This is a WWV/WWVH receiver somewhat less
+ * robust than other supported receivers. Its claimed accuracy is 100 ms
+ * when actually synchronized to the broadcast signal, but this doesn't
+ * happen even most of the time, due to propagation conditions, ambient
+ * noise sources, etc. When not synchronized, the accuracy is at the
+ * whim of the internal clock oscillator, which can wander into the
+ * sunset without warning. Since the indicated precision is 100 ms,
+ * expect a host synchronized only to this thing to wander to and fro,
+ * occasionally being rudely stepped when the offset exceeds the default
+ * clock_max of 128 ms. 
+ *
+ * There were two GC-1000 versions supported by this driver. The original
+ * GC-1000 with RS-232 output first appeared in 1983, but dissapeared
+ * from the market a few years later. The GC-1001 II with RS-232 output
+ * first appeared circa 1990, but apparently is no longer manufactured.
+ * The two models differ considerably, both in interface and commands.
+ * The GC-1000 has a pseudo-bipolar timecode output triggered by a RTS
+ * transition. The timecode includes both the day of year and time of
+ * day. The GC-1001 II has a true bipolar output and a complement of
+ * single character commands. The timecode includes only the time of
+ * day.
+ *
+ * The GC-1001 II was apparently never tested and, based on a Coverity
+ * scan, apparently never worked [Bug 689].  Related code has been disabled.
+ *
+ * GC-1000
+ *
+ * The internal DIPswitches should be set to operate in MANUAL mode. The
+ * external DIPswitches should be set to GMT and 24-hour format.
+ *
+ * In MANUAL mode the clock responds to a rising edge of the request to
+ * send (RTS) modem control line by sending the timecode. Therefore, it
+ * is necessary that the operating system implement the TIOCMBIC and
+ * TIOCMBIS ioctl system calls and TIOCM_RTS control bit. Present
+ * restrictions require the use of a POSIX-compatible programming
+ * interface, although other interfaces may work as well.
+ *
+ * A simple hardware modification to the clock can be made which
+ * prevents the clock hearing the request to send (RTS) if the HI SPEC
+ * lamp is out. Route the HISPEC signal to the tone decoder board pin
+ * 19, from the display, pin 19. Isolate pin 19 of the decoder board
+ * first, but maintain connection with pin 10. Also isolate pin 38 of
+ * the CPU on the tone board, and use half an added 7400 to gate the
+ * original signal to pin 38 with that from pin 19.
+ *
+ * The clock message consists of 23 ASCII printing characters in the
+ * following format:
+ *
+ * hh:mm:ss.f AM  dd/mm/yr<cr>
+ *
+ *     hh:mm:ss.f = hours, minutes, seconds
+ *     f = deciseconds ('?' when out of spec)
+ *     AM/PM/bb = blank in 24-hour mode
+ *     dd/mm/yr = day, month, year
+ *
+ * The alarm condition is indicated by '?', rather than a digit, at f.
+ * Note that 0?:??:??.? is displayed before synchronization is first
+ * established and hh:mm:ss.? once synchronization is established and
+ * then lost again for about a day.
+ *
+ * GC-1001 II
+ *
+ * Commands consist of a single letter and are case sensitive. When
+ * enterred in lower case, a description of the action performed is
+ * displayed. When enterred in upper case the action is performed.
+ * Following is a summary of descriptions as displayed by the clock:
+ *
+ * The clock responds with a command The 'A' command returns an ASCII
+ * local time string:  HH:MM:SS.T xx<CR>, where
+ *
+ *     HH = hours
+ *     MM = minutes
+ *     SS = seconds
+ *     T = tenths-of-seconds
+ *     xx = 'AM', 'PM', or '  '
+ *     <CR> = carriage return
+ *
+ * The 'D' command returns 24 pairs of bytes containing the variable
+ * divisor value at the end of each of the previous 24 hours. This
+ * allows the timebase trimming process to be observed.  UTC hour 00 is
+ * always returned first. The first byte of each pair is the high byte
+ * of (variable divisor * 16); the second byte is the low byte of
+ * (variable divisor * 16). For example, the byte pair 3C 10 would be
+ * returned for a divisor of 03C1 hex (961 decimal).
+ *
+ * The 'I' command returns:  | TH | TL | ER | DH | DL | U1 | I1 | I2 | ,
+ * where
+ *
+ *     TH = minutes since timebase last trimmed (high byte)
+ *     TL = minutes since timebase last trimmed (low byte)
+ *     ER = last accumulated error in 1.25 ms increments
+ *     DH = high byte of (current variable divisor * 16)
+ *     DL = low byte of (current variable divisor * 16)
+ *     U1 = UT1 offset (/.1 s):  | + | 4 | 2 | 1 | 0 | 0 | 0 | 0 |
+ *     I1 = information byte 1:  | W | C | D | I | U | T | Z | 1 | ,
+ *          where
+ *
+ *             W = set by WWV(H)
+ *             C = CAPTURE LED on
+ *             D = TRIM DN LED on
+ *             I = HI SPEC LED on
+ *             U = TRIM UP LED on
+ *             T = DST switch on
+ *             Z = UTC switch on
+ *             1 = UT1 switch on
+ *
+ *     I2 = information byte 2:  | 8 | 8 | 4 | 2 | 1 | D | d | S | ,
+ *          where
+ *
+ *             8, 8, 4, 2, 1 = TIME ZONE switch settings
+ *             D = DST bit (#55) in last-received frame
+ *             d = DST bit (#2) in last-received frame
+ *             S = clock is in simulation mode
+ *
+ * The 'P' command returns 24 bytes containing the number of frames
+ * received without error during UTC hours 00 through 23, providing an
+ * indication of hourly propagation.  These bytes are updated each hour
+ * to reflect the previous 24 hour period.  UTC hour 00 is always
+ * returned first.
+ *
+ * The 'T' command returns the UTC time:  | HH | MM | SS | T0 | , where
+ *     HH = tens-of-hours and hours (packed BCD)
+ *     MM = tens-of-minutes and minutes (packed BCD)
+ *     SS = tens-of-seconds and seconds (packed BCD)
+ *     T = tenths-of-seconds (BCD)
+ *
+ * Fudge Factors
+ *
+ * A fudge time1 value of .04 s appears to center the clock offset
+ * residuals. The fudge time2 parameter is the local time offset east of
+ * Greenwich, which depends on DST. Sorry about that, but the clock
+ * gives no hint on what the DIPswitches say.
+ */
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/heath%d" /* device name and unit */
+#define        PRECISION       (-4)    /* precision assumed (about 100 ms) */
+#define        REFID           "WWV\0" /* reference ID */
+#define        DESCRIPTION     "Heath GC-1000 Most Accurate Clock" /* WRU */
+
+#define LENHEATH1      23      /* min timecode length */
+#if 0  /* BUG 689 */
+#define LENHEATH2      13      /* min timecode length */
+#endif
+
+/*
+ * Tables to compute the ddd of year form icky dd/mm 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};
+
+/*
+ * Baud rate table. The GC-1000 supports 1200, 2400 and 4800; the
+ * GC-1001 II supports only 9600.
+ */
+static int speed[] = {B1200, B2400, B4800, B9600};
+
+/*
+ * Function prototypes
+ */
+static int     heath_start     P((int, struct peer *));
+static void    heath_shutdown  P((int, struct peer *));
+static void    heath_receive   P((struct recvbuf *));
+static void    heath_poll      P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_heath = {
+       heath_start,            /* start up driver */
+       heath_shutdown,         /* shut down driver */
+       heath_poll,             /* transmit poll message */
+       noentry,                /* not used (old heath_control) */
+       noentry,                /* initialize driver */
+       noentry,                /* not used (old heath_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * heath_start - open the devices and initialize data for processing
+ */
+static int
+heath_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+
+       /*
+        * Open serial port
+        */
+       sprintf(device, DEVICE, unit);
+       if (!(fd = refclock_open(device, speed[peer->ttl & 0x3],
+           LDISC_REMOTE)))
+               return (0);
+       pp = peer->procptr;
+       pp->io.clock_recv = heath_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               return (0);
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       peer->burst = NSTAGE;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       return (1);
+}
+
+
+/*
+ * heath_shutdown - shut down the clock
+ */
+static void
+heath_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       io_closeclock(&pp->io);
+}
+
+
+/*
+ * heath_receive - receive data from the serial interface
+ */
+static void
+heath_receive(
+       struct recvbuf *rbufp
+       )
+{
+       struct refclockproc *pp;
+       struct peer *peer;
+       l_fp trtmp;
+       int month, day;
+       int i;
+       char dsec, a[5];
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX,
+           &trtmp);
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. If the timecode has invalid length or is not in
+        * proper format, we declare bad format and exit.
+        */
+       switch (pp->lencode) {
+
+       /*
+        * GC-1000 timecode format: "hh:mm:ss.f AM  mm/dd/yy"
+        * GC-1001 II timecode format: "hh:mm:ss.f   "
+        */
+       case LENHEATH1:
+               if (sscanf(pp->a_lastcode,
+                   "%2d:%2d:%2d.%c%5c%2d/%2d/%2d", &pp->hour,
+                   &pp->minute, &pp->second, &dsec, a, &month, &day,
+                   &pp->year) != 8) {
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+               break;
+
+#if 0  /* BUG 689 */
+       /*
+        * GC-1001 II timecode format: "hh:mm:ss.f   "
+        */
+       case LENHEATH2:
+               if (sscanf(pp->a_lastcode, "%2d:%2d:%2d.%c", &pp->hour,
+                   &pp->minute, &pp->second, &dsec) != 4) {
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               } else {
+                       struct tm *tm_time_p;
+                       time_t     now;
+
+                       time(&now);     /* we should grab 'now' earlier */
+                       tm_time_p = gmtime(&now);
+                       /*
+                        * There is a window of time around midnight
+                        * where this will Do The Wrong Thing.
+                        */
+                       if (tm_time_p) {
+                               month = tm_time_p->tm_mon + 1;
+                               day = tm_time_p->tm_mday;
+                       } else {
+                               refclock_report(peer, CEVNT_FAULT);
+                               return;
+                       }
+               }
+               break;
+#endif
+
+       default:
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       /*
+        * We determine the day of the year from the DIPswitches. This
+        * should be fixed, since somebody might forget to set them.
+        * Someday this hazard will be fixed by a fiendish scheme that
+        * looks at the timecode and year the radio shows, then computes
+        * the residue of the seconds mod the seconds in a leap cycle.
+        * If in the third year of that cycle and the third and later
+        * months of that year, add one to the day. Then, correct the
+        * timecode accordingly. Icky pooh. This bit of nonsense could
+        * be avoided if the engineers had been required to write a
+        * device driver before finalizing the timecode format.
+        */
+       if (month < 1 || month > 12 || day < 1) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       if (pp->year % 4) {
+               if (day > day1tab[month - 1]) {
+                       refclock_report(peer, CEVNT_BADTIME);
+                       return;
+               }
+               for (i = 0; i < month - 1; i++)
+                   day += day1tab[i];
+       } else {
+               if (day > day2tab[month - 1]) {
+                       refclock_report(peer, CEVNT_BADTIME);
+                       return;
+               }
+               for (i = 0; i < month - 1; i++)
+                   day += day2tab[i];
+       }
+       pp->day = day;
+
+       /*
+        * Determine synchronization and last update
+        */
+       if (!isdigit((int)dsec))
+               pp->leap = LEAP_NOTINSYNC;
+       else {
+               pp->nsec = (dsec - '0') * 100000000;
+               pp->leap = LEAP_NOWARNING;
+       }
+       if (!refclock_process(pp))
+               refclock_report(peer, CEVNT_BADTIME);
+}
+
+
+/*
+ * heath_poll - called by the transmit procedure
+ */
+static void
+heath_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       int bits = TIOCM_RTS;
+
+       /*
+        * At each poll we check for timeout and toggle the RTS modem
+        * control line, then take a timestamp. Presumably, this is the
+        * event the radio captures to generate the timecode.
+        * Apparently, the radio takes about a second to make up its
+        * mind to send a timecode, so the receive timestamp is
+        * worthless.
+        */
+       pp = peer->procptr;
+
+       /*
+        * We toggle the RTS modem control lead (GC-1000) and sent a T
+        * (GC-1001 II) to kick a timecode loose from the radio. This
+        * code works only for POSIX and SYSV interfaces. With bsd you
+        * are on your own. We take a timestamp between the up and down
+        * edges to lengthen the pulse, which should be about 50 usec on
+        * a Sun IPC. With hotshot CPUs, the pulse might get too short.
+        * Later.
+        *
+        * Bug 689: Even though we no longer support the GC-1001 II,
+        * I'm leaving the 'T' write in for timing purposes.
+        */
+       if (ioctl(pp->io.fd, TIOCMBIC, (char *)&bits) < 0)
+               refclock_report(peer, CEVNT_FAULT);
+       get_systime(&pp->lastrec);
+       if (write(pp->io.fd, "T", 1) != 1)
+               refclock_report(peer, CEVNT_FAULT);
+       ioctl(pp->io.fd, TIOCMBIS, (char *)&bits);
+       if (peer->burst > 0)
+               return;
+       if (pp->coderecv == pp->codeproc) {
+               refclock_report(peer, CEVNT_TIMEOUT);
+               return;
+       }
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+       if (debug)
+           printf("heath: timecode %d %s\n", pp->lencode,
+                  pp->a_lastcode);
+#endif
+       peer->burst = MAXSTAGE;
+       pp->polls++;
+}
+
+#else
+int refclock_heath_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_hopfpci.c b/ntpd/refclock_hopfpci.c
new file mode 100644 (file)
index 0000000..81c186d
--- /dev/null
@@ -0,0 +1,265 @@
+/*
+ * refclock_hopfpci.c
+ *
+ * - clock driver for hopf 6039 PCI board (GPS or DCF77)
+ * Bernd Altmeier altmeier@atlsoft.de
+ *
+ * latest source and further information can be found at:
+ * http://www.ATLSoft.de/ntp
+ *
+ * In order to run this driver you have to install and test
+ * the PCI-board driver for your system first.
+ *
+ * On Linux/UNIX
+ *
+ * The driver attempts to open the device /dev/hopf6039 .
+ * The device entry will be made by the installation process of
+ * the kernel module for the PCI-bus board. The driver sources
+ * belongs to the delivery equipment of the PCI-board.
+ *
+ * On Windows NT/2000
+ *
+ * The driver attempts to open the device by calling the function
+ * "OpenHopfDevice()". This function will be installed by the
+ * Device Driver for the PCI-bus board. The driver belongs to the
+ * delivery equipment of the PCI-board.
+ *
+ *
+ * Start   21.03.2000 Revision: 01.20
+ * changes 22.12.2000 Revision: 01.40 flag1 = 1 sync even if Quarz
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_HOPF_PCI)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#undef fileno
+#include <ctype.h>
+#undef fileno
+
+#ifndef SYS_WINNT
+# include <sys/ipc.h>
+# include <sys/ioctl.h>
+# include <assert.h>
+# include <unistd.h>
+# include <stdio.h>
+# include "hopf6039.h"
+#else
+# include "hopf_PCI_io.h"
+#endif
+
+/*
+ * hopfpci interface definitions
+ */
+#define PRECISION       (-10)    /* precision assumed (1 ms) */
+#define REFID           "hopf"   /* reference ID */
+#define DESCRIPTION     "hopf Elektronik PCI radio board"
+
+#define NSAMPLES        3       /* stages of median filter */
+#ifndef SYS_WINNT
+# define       DEVICE  "/dev/hopf6039"         /* device name inode*/
+#else
+# define       DEVICE  "hopf6039"      /* device name WinNT  */
+#endif
+
+#define LEWAPWAR       0x20    /* leap second warning bit */
+
+#define        HOPF_OPMODE     0xC0    /* operation mode mask */
+#define HOPF_INVALID   0x00    /* no time code available */
+#define HOPF_INTERNAL  0x40    /* internal clock */
+#define HOPF_RADIO     0x80    /* radio clock */
+#define HOPF_RADIOHP   0xC0    /* high precision radio clock */
+
+
+/*
+ * hopfclock unit control structure.
+ */
+struct hopfclock_unit {
+       short   unit;           /* NTP refclock unit number */
+       char    leap_status;    /* leap second flag */
+};
+int    fd;                     /* file descr. */
+
+/*
+ * Function prototypes
+ */
+static  int     hopfpci_start       (int, struct peer *);
+static  void    hopfpci_shutdown    (int, struct peer *);
+static  void    hopfpci_poll        (int unit, struct peer *);
+
+/*
+ * Transfer vector
+ */
+struct  refclock refclock_hopfpci = {
+       hopfpci_start,          /* start up driver */
+       hopfpci_shutdown,       /* shut down driver */
+       hopfpci_poll,           /* transmit poll message */
+       noentry,                /* not used */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used */
+       NOFLAGS                 /* not used */
+};
+
+/*
+ * hopfpci_start - attach to hopf PCI board 6039
+ */
+static int
+hopfpci_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       struct hopfclock_unit *up;
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       up = (struct hopfclock_unit *) emalloc(sizeof(struct hopfclock_unit));
+
+       if (!(up)) {
+                msyslog(LOG_ERR, "hopfPCIClock(%d) emalloc: %m",unit);
+#ifdef DEBUG
+                printf("hopfPCIClock(%d) emalloc\n",unit);
+#endif
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct hopfclock_unit));
+
+#ifndef SYS_WINNT
+
+       fd = open(DEVICE,O_RDWR); /* try to open hopf clock device */
+
+#else
+       if (!OpenHopfDevice()){
+               msyslog(LOG_ERR,"Start: %s unit: %d failed!",DEVICE,unit);
+               return (0);
+       }
+#endif
+
+       pp = peer->procptr;
+       pp->io.clock_recv = noentry;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = INVALID_SOCKET;
+       pp->unitptr = (caddr_t)up;
+
+       get_systime(&pp->lastrec);
+
+       /*
+        * Initialize miscellaneous peer variables
+        */
+       if (pp->unitptr!=0) {
+               memcpy((char *)&pp->refid, REFID, 4);
+               peer->precision = PRECISION;
+               pp->clockdesc = DESCRIPTION;
+               up->leap_status = 0;
+               up->unit = (short) unit;
+               return (1);
+       }
+       else {
+               return 0;
+       }
+}
+
+
+/*
+ * hopfpci_shutdown - shut down the clock
+ */
+static void
+hopfpci_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+
+#ifndef SYS_WINNT
+       close(fd);
+#else
+       CloseHopfDevice();
+#endif
+}
+
+
+/*
+ * hopfpci_poll - called by the transmit procedure
+ */
+static void
+hopfpci_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       HOPFTIME m_time;
+
+       pp = peer->procptr;
+
+#ifndef SYS_WINNT
+       ioctl(fd,HOPF_CLOCK_GET_UTC,&m_time);
+#else
+       GetHopfSystemTime(&m_time);
+#endif
+       pp->polls++;
+
+       pp->day    = ymd2yd(m_time.wYear,m_time.wMonth,m_time.wDay);
+       pp->hour   = m_time.wHour;
+       pp->minute = m_time.wMinute;
+       pp->second = m_time.wSecond;
+       pp->nsec   = m_time.wMilliseconds * 1000000;
+       if (m_time.wStatus & LEWAPWAR)
+               pp->leap = LEAP_ADDSECOND;
+       else
+               pp->leap = LEAP_NOWARNING;
+
+       sprintf(pp->a_lastcode,"ST: %02X T: %02d:%02d:%02d.%03ld D: %02d.%02d.%04d",
+               m_time.wStatus, pp->hour, pp->minute, pp->second,
+               pp->nsec / 1000000, m_time.wDay, m_time.wMonth, m_time.wYear);
+       pp->lencode = (u_short)strlen(pp->a_lastcode);
+
+       get_systime(&pp->lastrec);
+
+       /*
+        * If clock has no valid status then report error and exit
+        */
+       if ((m_time.wStatus & HOPF_OPMODE) == HOPF_INVALID) {  /* time ok? */
+               refclock_report(peer, CEVNT_BADTIME);
+               pp->leap = LEAP_NOTINSYNC;
+               return;
+       }
+
+       /*
+        * Test if time is running on internal quarz
+        * if CLK_FLAG1 is set, sychronize even if no radio operation
+        */
+
+       if ((m_time.wStatus & HOPF_OPMODE) == HOPF_INTERNAL){
+               if ((pp->sloppyclockflag & CLK_FLAG1) == 0) {
+                       refclock_report(peer, CEVNT_BADTIME);
+                       pp->leap = LEAP_NOTINSYNC;
+                       return;
+               }
+       }
+
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       return;
+}
+
+#else
+int refclock_hopfpci_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_hopfser.c b/ntpd/refclock_hopfser.c
new file mode 100644 (file)
index 0000000..9037d4a
--- /dev/null
@@ -0,0 +1,381 @@
+/*
+ *
+ * refclock_hopfser.c
+ * - clock driver for hopf serial boards (GPS or DCF77)
+ *
+ * Date: 30.03.2000 Revision: 01.10
+ *
+ * latest source and further information can be found at:
+ * http://www.ATLSoft.de/ntp
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if defined(REFCLOCK) && (defined(CLOCK_HOPF_SERIAL))
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_control.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#if defined HAVE_SYS_MODEM_H
+# include <sys/modem.h>
+# ifndef __QNXNTO__
+#  define TIOCMSET MCSETA
+#  define TIOCMGET MCGETA
+#  define TIOCM_RTS MRTS
+# endif
+#endif
+
+#ifdef HAVE_TERMIOS_H
+# ifdef TERMIOS_NEEDS__SVID3
+#  define _SVID3
+# endif
+# include <termios.h>
+# ifdef TERMIOS_NEEDS__SVID3
+#  undef _SVID3
+# endif
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+
+#ifdef SYS_WINNT
+extern int async_write(int, const void *, unsigned int);
+#undef write
+#define write(fd, data, octets)        async_write(fd, data, octets)
+#endif
+
+/*
+ * clock definitions
+ */
+#define        DESCRIPTION     "hopf Elektronik serial clock" /* Long name */
+#define        PRECISION       (-10)   /* precision assumed (about 1 ms) */
+#define        REFID           "hopf\0"        /* reference ID */
+/*
+ * I/O definitions
+ */
+#define        DEVICE          "/dev/hopfclock%d"      /* device name and unit */
+#define        SPEED232        B9600                   /* uart speed (9600 baud) */
+
+
+#define STX 0x02
+#define ETX 0x03
+#define CR  0x0c
+#define LF  0x0a
+
+/* parse states */
+#define REC_QUEUE_EMPTY       0
+#define REC_QUEUE_FULL        1
+
+#define        HOPF_OPMODE     0x0C    /* operation mode mask */
+#define HOPF_INVALID   0x00    /* no time code available */
+#define HOPF_INTERNAL  0x04    /* internal clock */
+#define HOPF_RADIO     0x08    /* radio clock */
+#define HOPF_RADIOHP   0x0C    /* high precision radio clock */
+
+/*
+ * hopfclock unit control structure.
+ */
+struct hopfclock_unit {
+       l_fp    laststamp;      /* last receive timestamp */
+       short   unit;           /* NTP refclock unit number */
+       u_long  polled;         /* flag to detect noreplies */
+       char    leap_status;    /* leap second flag */
+       int     rpt_next;
+};
+
+/*
+ * Function prototypes
+ */
+
+static int     hopfserial_start        P((int, struct peer *));
+static void    hopfserial_shutdown     P((int, struct peer *));
+static void    hopfserial_receive      P((struct recvbuf *));
+static void    hopfserial_poll         P((int, struct peer *));
+/* static  void hopfserial_io          P((struct recvbuf *)); */
+/*
+ * Transfer vector
+ */
+struct refclock refclock_hopfser = {
+       hopfserial_start,       /* start up driver */
+       hopfserial_shutdown,    /* shut down driver */
+       hopfserial_poll,        /* transmit poll message */
+       noentry,                /* not used  */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used */
+       NOFLAGS                 /* not used */
+};
+
+/*
+ * hopfserial_start - open the devices and initialize data for processing
+ */
+static int
+hopfserial_start (
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct hopfclock_unit *up;
+       struct refclockproc *pp;
+       int fd;
+       char gpsdev[20];
+
+#ifdef SYS_WINNT
+       (void) sprintf(gpsdev, "COM%d:", unit);
+#else
+       (void) sprintf(gpsdev, DEVICE, unit);
+#endif
+       /* LDISC_STD, LDISC_RAW
+        * Open serial port. Use CLK line discipline, if available.
+        */
+       fd = refclock_open(gpsdev, SPEED232, LDISC_CLK);
+       if (fd <= 0) {
+#ifdef DEBUG
+               printf("hopfSerialClock(%d) start: open %s failed\n", unit, gpsdev);
+#endif
+               return 0;
+       }
+
+       msyslog(LOG_NOTICE, "hopfSerialClock(%d) fd: %d dev: %s", unit, fd,
+               gpsdev);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       up = (struct hopfclock_unit *) emalloc(sizeof(struct hopfclock_unit));
+
+       if (!(up)) {
+                msyslog(LOG_ERR, "hopfSerialClock(%d) emalloc: %m",unit);
+#ifdef DEBUG
+                printf("hopfSerialClock(%d) emalloc\n",unit);
+#endif
+               (void) close(fd);
+               return (0);
+       }
+
+       memset((char *)up, 0, sizeof(struct hopfclock_unit));
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t)up;
+       pp->io.clock_recv = hopfserial_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+#ifdef DEBUG
+                printf("hopfSerialClock(%d) io_addclock\n",unit);
+#endif
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       pp->clockdesc = DESCRIPTION;
+       peer->precision = PRECISION;
+       peer->burst = NSTAGE;
+       memcpy((char *)&pp->refid, REFID, 4);
+
+       up->leap_status = 0;
+       up->unit = (short) unit;
+
+       return (1);
+}
+
+
+/*
+ * hopfserial_shutdown - shut down the clock
+ */
+static void
+hopfserial_shutdown (
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct hopfclock_unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct hopfclock_unit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+
+/*
+ * hopfserial_receive - receive data from the serial interface
+ */
+
+static void
+hopfserial_receive (
+       struct recvbuf *rbufp
+       )
+{
+       struct hopfclock_unit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+
+       int             synch;  /* synchhronization indicator */
+       int             DoW;    /* Dow */
+
+       int     day, month;     /* ddd conversion */
+
+       /*
+        * Initialize pointers and read the timecode and timestamp.
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct hopfclock_unit *)pp->unitptr;
+
+       if (up->rpt_next == 0 )
+               return;
+
+
+       up->rpt_next = 0; /* wait until next poll interval occur */
+
+       pp->lencode = (u_short)refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &pp->lastrec);
+
+       if (pp->lencode  == 0)
+               return;
+
+       sscanf(pp->a_lastcode,
+#if 1
+              "%1x%1x%2d%2d%2d%2d%2d%2d",   /* ...cr,lf */
+#else
+              "%*c%1x%1x%2d%2d%2d%2d%2d%2d", /* stx...cr,lf,etx */
+#endif
+              &synch,
+              &DoW,
+              &pp->hour,
+              &pp->minute,
+              &pp->second,
+              &day,
+              &month,
+              &pp->year);
+
+
+       /*
+         Validate received values at least enough to prevent internal
+         array-bounds problems, etc.
+       */
+       if((pp->hour < 0) || (pp->hour > 23) ||
+          (pp->minute < 0) || (pp->minute > 59) ||
+          (pp->second < 0) || (pp->second > 60) /*Allow for leap seconds.*/ ||
+          (day < 1) || (day > 31) ||
+          (month < 1) || (month > 12) ||
+          (pp->year < 0) || (pp->year > 99)) {
+               /* Data out of range. */
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+       /*
+         some preparations
+       */
+       pp->day    = ymd2yd(pp->year,month,day);
+       pp->leap=0;
+
+       /* Year-2000 check! */
+       /* wrap 2-digit date into 4-digit */
+
+       if(pp->year < YEAR_PIVOT) { pp->year += 100; }          /* < 98 */
+       pp->year += 1900;
+
+       /* preparation for timecode ntpq rl command ! */
+
+#if 0
+       wsprintf(pp->a_lastcode,
+                "STATUS: %1X%1X, DATE: %02d.%02d.%04d  TIME: %02d:%02d:%02d",
+                synch,
+                DoW,
+                day,
+                month,
+                pp->year,
+                pp->hour,
+                pp->minute,
+                pp->second);
+
+       pp->lencode = strlen(pp->a_lastcode);
+       if ((synch && 0xc) == 0 ){  /* time ok? */
+               refclock_report(peer, CEVNT_BADTIME);
+               pp->leap = LEAP_NOTINSYNC;
+               return;
+       }
+#endif
+       /*
+        * If clock has no valid status then report error and exit
+        */
+       if ((synch & HOPF_OPMODE) == HOPF_INVALID ){  /* time ok? */
+               refclock_report(peer, CEVNT_BADTIME);
+               pp->leap = LEAP_NOTINSYNC;
+               return;
+       }
+
+       /*
+        * Test if time is running on internal quarz
+        * if CLK_FLAG1 is set, sychronize even if no radio operation
+        */
+
+       if ((synch & HOPF_OPMODE) == HOPF_INTERNAL){
+               if ((pp->sloppyclockflag & CLK_FLAG1) == 0) {
+                       refclock_report(peer, CEVNT_BADTIME);
+                       pp->leap = LEAP_NOTINSYNC;
+                       return;
+               }
+       }
+
+
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+
+#if 0
+       msyslog(LOG_ERR, " D:%x  D:%d D:%d",synch,pp->minute,pp->second);
+#endif
+
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+
+       return;
+}
+
+
+/*
+ * hopfserial_poll - called by the transmit procedure
+ *
+ */
+static void
+hopfserial_poll (
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct hopfclock_unit *up;
+       struct refclockproc *pp;
+       pp = peer->procptr;
+
+       up = (struct hopfclock_unit *)pp->unitptr;
+
+       pp->polls++;
+       up->rpt_next = 1;
+
+#if 0
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#endif
+
+       return;
+}
+
+#else
+int refclock_hopfser_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_hpgps.c b/ntpd/refclock_hpgps.c
new file mode 100644 (file)
index 0000000..5efd19e
--- /dev/null
@@ -0,0 +1,619 @@
+/*
+ * refclock_hpgps - clock driver for HP 58503A GPS receiver
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_HPGPS)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+/* Version 0.1 April  1, 1995  
+ *         0.2 April 25, 1995
+ *             tolerant of missing timecode response prompt and sends
+ *             clear status if prompt indicates error;
+ *             can use either local time or UTC from receiver;
+ *             can get receiver status screen via flag4
+ *
+ * WARNING!: This driver is UNDER CONSTRUCTION
+ * Everything in here should be treated with suspicion.
+ * If it looks wrong, it probably is.
+ *
+ * Comments and/or questions to: Dave Vitanye
+ *                               Hewlett Packard Company
+ *                               dave@scd.hp.com
+ *                               (408) 553-2856
+ *
+ * Thanks to the author of the PST driver, which was the starting point for
+ * this one.
+ *
+ * This driver supports the HP 58503A Time and Frequency Reference Receiver.
+ * This receiver uses HP SmartClock (TM) to implement an Enhanced GPS receiver.
+ * The receiver accuracy when locked to GPS in normal operation is better
+ * than 1 usec. The accuracy when operating in holdover is typically better
+ * than 10 usec. per day.
+ *
+ * The same driver also handles the HP Z3801A which is available surplus
+ * from the cell phone industry.  It's popular with hams.
+ * It needs a different line setup: 19200 baud, 7 data bits, odd parity
+ * That is selected by adding "mode 1" to the server line in ntp.conf
+ * HP Z3801A code from Jeff Mock added by Hal Murray, Sep 2005
+ *
+ *
+ * The receiver should be operated with factory default settings.
+ * Initial driver operation: expects the receiver to be already locked
+ * to GPS, configured and able to output timecode format 2 messages.
+ *
+ * The driver uses the poll sequence :PTIME:TCODE? to get a response from
+ * the receiver. The receiver responds with a timecode string of ASCII
+ * printing characters, followed by a <cr><lf>, followed by a prompt string
+ * issued by the receiver, in the following format:
+ * T#yyyymmddhhmmssMFLRVcc<cr><lf>scpi > 
+ *
+ * The driver processes the response at the <cr> and <lf>, so what the
+ * driver sees is the prompt from the previous poll, followed by this
+ * timecode. The prompt from the current poll is (usually) left unread until
+ * the next poll. So (except on the very first poll) the driver sees this:
+ *
+ * scpi > T#yyyymmddhhmmssMFLRVcc<cr><lf>
+ *
+ * The T is the on-time character, at 980 msec. before the next 1PPS edge.
+ * The # is the timecode format type. We look for format 2.
+ * Without any of the CLK or PPS stuff, then, the receiver buffer timestamp
+ * at the <cr> is 24 characters later, which is about 25 msec. at 9600 bps,
+ * so the first approximation for fudge time1 is nominally -0.955 seconds.
+ * This number probably needs adjusting for each machine / OS type, so far:
+ *  -0.955000 on an HP 9000 Model 712/80 HP-UX 9.05
+ *  -0.953175 on an HP 9000 Model 370    HP-UX 9.10 
+ *
+ * This receiver also provides a 1PPS signal, but I haven't figured out
+ * how to deal with any of the CLK or PPS stuff yet. Stay tuned.
+ *
+ */
+
+/*
+ * Fudge Factors
+ *
+ * Fudge time1 is used to accomodate the timecode serial interface adjustment.
+ * Fudge flag4 can be set to request a receiver status screen summary, which
+ * is recorded in the clockstats file.
+ */
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/hpgps%d" /* device name and unit */
+#define        SPEED232        B9600   /* uart speed (9600 baud) */
+#define        SPEED232Z       B19200  /* uart speed (19200 baud) */
+#define        PRECISION       (-10)   /* precision assumed (about 1 ms) */
+#define        REFID           "GPS\0" /*  reference ID */
+#define        DESCRIPTION     "HP 58503A GPS Time and Frequency Reference Receiver" 
+
+#define SMAX            23*80+1 /* for :SYSTEM:PRINT? status screen response */
+
+#define MTZONE          2       /* number of fields in timezone reply */
+#define MTCODET2        12      /* number of fields in timecode format T2 */
+#define NTCODET2        21      /* number of chars to checksum in format T2 */
+
+/*
+ * 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};
+
+/*
+ * Unit control structure
+ */
+struct hpgpsunit {
+       int     pollcnt;        /* poll message counter */
+       int     tzhour;         /* timezone offset, hours */
+       int     tzminute;       /* timezone offset, minutes */
+       int     linecnt;        /* set for expected multiple line responses */
+       char    *lastptr;       /* pointer to receiver response data */
+       char    statscrn[SMAX]; /* receiver status screen buffer */
+};
+
+/*
+ * Function prototypes
+ */
+static int     hpgps_start     P((int, struct peer *));
+static void    hpgps_shutdown  P((int, struct peer *));
+static void    hpgps_receive   P((struct recvbuf *));
+static void    hpgps_poll      P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_hpgps = {
+       hpgps_start,            /* start up driver */
+       hpgps_shutdown,         /* shut down driver */
+       hpgps_poll,             /* transmit poll message */
+       noentry,                /* not used (old hpgps_control) */
+       noentry,                /* initialize driver */
+       noentry,                /* not used (old hpgps_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * hpgps_start - open the devices and initialize data for processing
+ */
+static int
+hpgps_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct hpgpsunit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+
+       /*
+        * Open serial port. Use CLK line discipline, if available.
+        * Default is HP 58503A, mode arg selects HP Z3801A
+        */
+       (void)sprintf(device, DEVICE, unit);
+       /* mode parameter to server config line shares ttl slot */
+       if ((peer->ttl == 1)) {
+               if (!(fd = refclock_open(device, SPEED232Z,
+                               LDISC_CLK | LDISC_7O1)))
+                       return (0);
+       } else {
+               if (!(fd = refclock_open(device, SPEED232, LDISC_CLK)))
+                       return (0);
+       }
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct hpgpsunit *)
+             emalloc(sizeof(struct hpgpsunit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct hpgpsunit));
+       pp = peer->procptr;
+       pp->io.clock_recv = hpgps_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       up->tzhour = 0;
+       up->tzminute = 0;
+
+       *up->statscrn = '\0';
+       up->lastptr = up->statscrn;
+       up->pollcnt = 2;
+
+       /*
+        * Get the identifier string, which is logged but otherwise ignored,
+        * and get the local timezone information
+        */
+       up->linecnt = 1;
+       if (write(pp->io.fd, "*IDN?\r:PTIME:TZONE?\r", 20) != 20)
+           refclock_report(peer, CEVNT_FAULT);
+
+       return (1);
+}
+
+
+/*
+ * hpgps_shutdown - shut down the clock
+ */
+static void
+hpgps_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct hpgpsunit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct hpgpsunit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * hpgps_receive - receive data from the serial interface
+ */
+static void
+hpgps_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct hpgpsunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       l_fp trtmp;
+       char tcodechar1;        /* identifies timecode format */
+       char tcodechar2;        /* identifies timecode format */
+       char timequal;          /* time figure of merit: 0-9 */
+       char freqqual;          /* frequency figure of merit: 0-3 */
+       char leapchar;          /* leapsecond: + or 0 or - */
+       char servchar;          /* request for service: 0 = no, 1 = yes */
+       char syncchar;          /* time info is invalid: 0 = no, 1 = yes */
+       short expectedsm;       /* expected timecode byte checksum */
+       short tcodechksm;       /* computed timecode byte checksum */
+       int i,m,n;
+       int month, day, lastday;
+       char *tcp;              /* timecode pointer (skips over the prompt) */
+       char prompt[BMAX];      /* prompt in response from receiver */
+
+       /*
+        * Initialize pointers and read the receiver response
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct hpgpsunit *)pp->unitptr;
+       *pp->a_lastcode = '\0';
+       pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp);
+
+#ifdef DEBUG
+       if (debug)
+           printf("hpgps: lencode: %d timecode:%s\n",
+                  pp->lencode, pp->a_lastcode);
+#endif
+
+       /*
+        * If there's no characters in the reply, we can quit now
+        */
+       if (pp->lencode == 0)
+           return;
+
+       /*
+        * If linecnt is greater than zero, we are getting information only,
+        * such as the receiver identification string or the receiver status
+        * screen, so put the receiver response at the end of the status
+        * screen buffer. When we have the last line, write the buffer to
+        * the clockstats file and return without further processing.
+        *
+        * If linecnt is zero, we are expecting either the timezone
+        * or a timecode. At this point, also write the response
+        * to the clockstats file, and go on to process the prompt (if any),
+        * timezone, or timecode and timestamp.
+        */
+
+
+       if (up->linecnt-- > 0) {
+               if ((int)(pp->lencode + 2) <= (SMAX - (up->lastptr - up->statscrn))) {
+                       *up->lastptr++ = '\n';
+                       (void)strcpy(up->lastptr, pp->a_lastcode);
+                       up->lastptr += pp->lencode;
+               }
+               if (up->linecnt == 0) 
+                   record_clock_stats(&peer->srcadr, up->statscrn);
+               
+               return;
+       }
+
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       pp->lastrec = trtmp;
+            
+       up->lastptr = up->statscrn;
+       *up->lastptr = '\0';
+       up->pollcnt = 2;
+
+       /*
+        * We get down to business: get a prompt if one is there, issue
+        * a clear status command if it contains an error indication.
+        * Next, check for either the timezone reply or the timecode reply
+        * and decode it.  If we don't recognize the reply, or don't get the
+        * proper number of decoded fields, or get an out of range timezone,
+        * or if the timecode checksum is bad, then we declare bad format
+        * and exit.
+        *
+        * Timezone format (including nominal prompt):
+        * scpi > -H,-M<cr><lf>
+        *
+        * Timecode format (including nominal prompt):
+        * scpi > T2yyyymmddhhmmssMFLRVcc<cr><lf>
+        *
+        */
+
+       (void)strcpy(prompt,pp->a_lastcode);
+       tcp = strrchr(pp->a_lastcode,'>');
+       if (tcp == NULL)
+           tcp = pp->a_lastcode; 
+       else
+           tcp++;
+       prompt[tcp - pp->a_lastcode] = '\0';
+       while ((*tcp == ' ') || (*tcp == '\t')) tcp++;
+
+       /*
+        * deal with an error indication in the prompt here
+        */
+       if (strrchr(prompt,'E') > strrchr(prompt,'s')){
+#ifdef DEBUG
+               if (debug)
+                   printf("hpgps: error indicated in prompt: %s\n", prompt);
+#endif
+               if (write(pp->io.fd, "*CLS\r\r", 6) != 6)
+                   refclock_report(peer, CEVNT_FAULT);
+       }
+
+       /*
+        * make sure we got a timezone or timecode format and 
+        * then process accordingly
+        */
+       m = sscanf(tcp,"%c%c", &tcodechar1, &tcodechar2);
+
+       if (m != 2){
+#ifdef DEBUG
+               if (debug)
+                   printf("hpgps: no format indicator\n");
+#endif
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       switch (tcodechar1) {
+
+           case '+':
+           case '-':
+               m = sscanf(tcp,"%d,%d", &up->tzhour, &up->tzminute);
+               if (m != MTZONE) {
+#ifdef DEBUG
+                       if (debug)
+                           printf("hpgps: only %d fields recognized in timezone\n", m);
+#endif
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+               if ((up->tzhour < -12) || (up->tzhour > 13) || 
+                   (up->tzminute < -59) || (up->tzminute > 59)){
+#ifdef DEBUG
+                       if (debug)
+                           printf("hpgps: timezone %d, %d out of range\n",
+                                  up->tzhour, up->tzminute);
+#endif
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+               return;
+
+           case 'T':
+               break;
+
+           default:
+#ifdef DEBUG
+               if (debug)
+                   printf("hpgps: unrecognized reply format %c%c\n",
+                          tcodechar1, tcodechar2);
+#endif
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       } /* end of tcodechar1 switch */
+
+
+       switch (tcodechar2) {
+
+           case '2':
+               m = sscanf(tcp,"%*c%*c%4d%2d%2d%2d%2d%2d%c%c%c%c%c%2hx",
+                          &pp->year, &month, &day, &pp->hour, &pp->minute, &pp->second,
+                          &timequal, &freqqual, &leapchar, &servchar, &syncchar,
+                          &expectedsm);
+               n = NTCODET2;
+
+               if (m != MTCODET2){
+#ifdef DEBUG
+                       if (debug)
+                           printf("hpgps: only %d fields recognized in timecode\n", m);
+#endif
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+               break;
+
+           default:
+#ifdef DEBUG
+               if (debug)
+                   printf("hpgps: unrecognized timecode format %c%c\n",
+                          tcodechar1, tcodechar2);
+#endif
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       } /* end of tcodechar2 format switch */
+           
+       /* 
+        * Compute and verify the checksum.
+        * Characters are summed starting at tcodechar1, ending at just
+        * before the expected checksum.  Bail out if incorrect.
+        */
+       tcodechksm = 0;
+       while (n-- > 0) tcodechksm += *tcp++;
+       tcodechksm &= 0x00ff;
+
+       if (tcodechksm != expectedsm) {
+#ifdef DEBUG
+               if (debug)
+                   printf("hpgps: checksum %2hX doesn't match %2hX expected\n",
+                          tcodechksm, expectedsm);
+#endif
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       /* 
+        * Compute the day of year from the yyyymmdd format.
+        */
+       if (month < 1 || month > 12 || day < 1) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+
+       if ( ! isleap_4(pp->year) ) {                           /* Y2KFixes */
+               /* not a leap year */
+               if (day > day1tab[month - 1]) {
+                       refclock_report(peer, CEVNT_BADTIME);
+                       return;
+               }
+               for (i = 0; i < month - 1; i++) day += day1tab[i];
+               lastday = 365;
+       } else {
+               /* a leap year */
+               if (day > day2tab[month - 1]) {
+                       refclock_report(peer, CEVNT_BADTIME);
+                       return;
+               }
+               for (i = 0; i < month - 1; i++) day += day2tab[i];
+               lastday = 366;
+       }
+
+       /*
+        * Deal with the timezone offset here. The receiver timecode is in
+        * local time = UTC + :PTIME:TZONE, so SUBTRACT the timezone values.
+        * For example, Pacific Standard Time is -8 hours , 0 minutes.
+        * Deal with the underflows and overflows.
+        */
+       pp->minute -= up->tzminute;
+       pp->hour -= up->tzhour;
+
+       if (pp->minute < 0) {
+               pp->minute += 60;
+               pp->hour--;
+       }
+       if (pp->minute > 59) {
+               pp->minute -= 60;
+               pp->hour++;
+       }
+       if (pp->hour < 0)  {
+               pp->hour += 24;
+               day--;
+               if (day < 1) {
+                       pp->year--;
+                       if ( isleap_4(pp->year) )               /* Y2KFixes */
+                           day = 366;
+                       else
+                           day = 365;
+               }
+       }
+
+       if (pp->hour > 23) {
+               pp->hour -= 24;
+               day++;
+               if (day > lastday) {
+                       pp->year++;
+                       day = 1;
+               }
+       }
+
+       pp->day = day;
+
+       /*
+        * Decode the MFLRV indicators.
+        * NEED TO FIGURE OUT how to deal with the request for service,
+        * time quality, and frequency quality indicators some day. 
+        */
+       if (syncchar != '0') {
+               pp->leap = LEAP_NOTINSYNC;
+       }
+       else {
+               switch (leapchar) {
+
+                   case '+':
+                       pp->leap = LEAP_ADDSECOND;
+                       break;
+                     
+                   case '0':
+                       pp->leap = LEAP_NOWARNING;
+                       break;
+                     
+                   case '-':
+                       pp->leap = LEAP_DELSECOND;
+                       break;
+                     
+                   default:
+#ifdef DEBUG
+                       if (debug)
+                           printf("hpgps: unrecognized leap indicator: %c\n",
+                                  leapchar);
+#endif
+                       refclock_report(peer, CEVNT_BADTIME);
+                       return;
+               } /* end of leapchar switch */
+       }
+
+       /*
+        * Process the new sample in the median filter and determine the
+        * reference clock offset and dispersion. We use lastrec as both
+        * the reference time and receive time in order to avoid being
+        * cute, like setting the reference time later than the receive
+        * time, which may cause a paranoid protocol module to chuck out
+        * the data.
+        */
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+
+       /*
+        * If CLK_FLAG4 is set, ask for the status screen response.
+        */
+       if (pp->sloppyclockflag & CLK_FLAG4){
+               up->linecnt = 22; 
+               if (write(pp->io.fd, ":SYSTEM:PRINT?\r", 15) != 15)
+                   refclock_report(peer, CEVNT_FAULT);
+       }
+}
+
+
+/*
+ * hpgps_poll - called by the transmit procedure
+ */
+static void
+hpgps_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct hpgpsunit *up;
+       struct refclockproc *pp;
+
+       /*
+        * Time to poll the clock. The HP 58503A responds to a
+        * ":PTIME:TCODE?" by returning a timecode in the format specified
+        * above. If nothing is heard from the clock for two polls,
+        * declare a timeout and keep going.
+        */
+       pp = peer->procptr;
+       up = (struct hpgpsunit *)pp->unitptr;
+       if (up->pollcnt == 0)
+           refclock_report(peer, CEVNT_TIMEOUT);
+       else
+           up->pollcnt--;
+       if (write(pp->io.fd, ":PTIME:TCODE?\r", 14) != 14) {
+               refclock_report(peer, CEVNT_FAULT);
+       }
+       else
+           pp->polls++;
+}
+
+#else
+int refclock_hpgps_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_irig.c b/ntpd/refclock_irig.c
new file mode 100644 (file)
index 0000000..6be09d9
--- /dev/null
@@ -0,0 +1,1048 @@
+/*
+ * refclock_irig - audio IRIG-B/E demodulator/decoder
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_IRIG)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif /* HAVE_SYS_IOCTL_H */
+
+#include "audio.h"
+
+/*
+ * Audio IRIG-B/E demodulator/decoder
+ *
+ * This driver receives, demodulates and decodes IRIG-B/E signals when
+ * connected to the audio codec /dev/audio. The IRIG signal format is an
+ * amplitude-modulated carrier with pulse-width modulated data bits. For
+ * IRIG-B, the carrier frequency is 1000 Hz and bit rate 100 b/s; for
+ * IRIG-E, the carrier frequenchy is 100 Hz and bit rate 10 b/s. The
+ * driver automatically recognizes which format is in use.
+ *
+ * The program processes 8000-Hz mu-law companded samples using separate
+ * signal filters for IRIG-B and IRIG-E, a comb filter, envelope
+ * detector and automatic threshold corrector. Cycle crossings relative
+ * to the corrected slice level determine the width of each pulse and
+ * its value - zero, one or position identifier. The data encode 20 BCD
+ * digits which determine the second, minute, hour and day of the year
+ * and sometimes the year and synchronization condition. The comb filter
+ * exponentially averages the corresponding samples of successive baud
+ * intervals in order to reliably identify the reference carrier cycle.
+ * A type-II phase-lock loop (PLL) performs additional integration and
+ * interpolation to accurately determine the zero crossing of that
+ * cycle, which determines the reference timestamp. A pulse-width
+ * discriminator demodulates the data pulses, which are then encoded as
+ * the BCD digits of the timecode.
+ *
+ * The timecode and reference timestamp are updated once each second
+ * with IRIG-B (ten seconds with IRIG-E) and local clock offset samples
+ * saved for later processing. At poll intervals of 64 s, the saved
+ * samples are processed by a trimmed-mean filter and used to update the
+ * system clock.
+ *
+ * An automatic gain control feature provides protection against
+ * overdriven or underdriven input signal amplitudes. It is designed to
+ * maintain adequate demodulator signal amplitude while avoiding
+ * occasional noise spikes. In order to assure reliable capture, the
+ * decompanded input signal amplitude must be greater than 100 units and
+ * the codec sample frequency error less than 250 PPM (.025 percent).
+ *
+ * The program performs a number of error checks to protect against
+ * overdriven or underdriven input signal levels, incorrect signal
+ * format or improper hardware configuration. Specifically, if any of
+ * the following errors occur for a time measurement, the data are
+ * rejected.
+ *
+ * o The peak carrier amplitude is less than DRPOUT (100). This usually
+ *   means dead IRIG signal source, broken cable or wrong input port.
+ *
+ * o The frequency error is greater than MAXFREQ +-250 PPM (.025%). This
+ *   usually means broken codec hardware or wrong codec configuration.
+ *
+ * o The modulation index is less than MODMIN (0.5). This usually means
+ *   overdriven IRIG signal or wrong IRIG format.
+ *
+ * o A frame synchronization error has occurred. This usually means
+ *   wrong IRIG signal format or the IRIG signal source has lost
+ *   synchronization (signature control).
+ *
+ * o A data decoding error has occurred. This usually means wrong IRIG
+ *   signal format.
+ *
+ * o The current second of the day is not exactly one greater than the
+ *   previous one. This usually means a very noisy IRIG signal or
+ *   insufficient CPU resources.
+ *
+ * o An audio codec error (overrun) occurred. This usually means
+ *   insufficient CPU resources, as sometimes happens with Sun SPARC
+ *   IPCs when doing something useful.
+ *
+ * Note that additional checks are done elsewhere in the reference clock
+ * interface routines.
+ *
+ * Debugging aids
+ *
+ * The timecode format used for debugging and data recording includes
+ * data helpful in diagnosing problems with the IRIG signal and codec
+ * connections. With debugging enabled (-d on the ntpd command line),
+ * the driver produces one line for each timecode in the following
+ * format:
+ *
+ * 00 1 98 23 19:26:52 721 143 0.694 20 0.1 66.5 3094572411.00027
+ *
+ * The most recent line is also written to the clockstats file at 64-s
+ * intervals.
+ *
+ * The first field contains the error flags in hex, where the hex bits
+ * are interpreted as below. This is followed by the IRIG status
+ * indicator, year of century, day of year and time of day. The status
+ * indicator and year are not produced by some IRIG devices. Following
+ * these fields are the signal amplitude (0-8100), codec gain (0-255),
+ * modulation index (0-1), time constant (2-20), carrier phase error
+ * (us) and carrier frequency error (PPM). The last field is the on-time
+ * timestamp in NTP format.
+ *
+ * The fraction part of the on-time timestamp is a good indicator of how
+ * well the driver is doing. Once upon a time, an UltrSPARC 30 and
+ * Solaris 2.7 kept the clock within a few tens of microseconds relative
+ * to the IRIG-B signal. Accuracy with IRIG-E was about ten times worse.
+ * Unfortunately, Sun broke the 2.7 audio driver in 2.8, which has a 10-
+ * ms sawtooth modulation. The driver attempts to remove the modulation
+ * by some clever estimation techniques which mostly work. With the
+ * "mixerctl -o" command before starting the daemon, the jitter is down
+ * to about 100 microseconds. Your experience may vary.
+ *
+ * Unlike other drivers, which can have multiple instantiations, this
+ * one supports only one. It does not seem likely that more than one
+ * audio codec would be useful in a single machine. More than one would
+ * probably chew up too much CPU time anyway.
+ *
+ * Fudge factors
+ *
+ * Fudge flag4 causes the dubugging output described above to be
+ * recorded in the clockstats file. Fudge flag2 selects the audio input
+ * port, where 0 is the mike port (default) and 1 is the line-in port.
+ * It does not seem useful to select the compact disc player port. Fudge
+ * flag3 enables audio monitoring of the input signal. For this purpose,
+ * the monitor gain is set to a default value. Fudgetime2 is used as a
+ * frequency vernier for broken codec sample frequency.
+ */
+/*
+ * Interface definitions
+ */
+#define        DEVICE_AUDIO    "/dev/audio" /* audio device name */
+#define        PRECISION       (-17)   /* precision assumed (about 10 us) */
+#define        REFID           "IRIG"  /* reference ID */
+#define        DESCRIPTION     "Generic IRIG Audio Driver" /* WRU */
+#define        AUDIO_BUFSIZ    320     /* audio buffer size (40 ms) */
+#define SECOND         8000    /* nominal sample rate (Hz) */
+#define BAUD           80      /* samples per baud interval */
+#define OFFSET         128     /* companded sample offset */
+#define SIZE           256     /* decompanding table size */
+#define CYCLE          8       /* samples per carrier cycle */
+#define SUBFLD         10      /* bits per subfield */
+#define FIELD          10      /* subfields per field */
+#define MINTC          2       /* min PLL time constant */
+#define MAXTC          20      /* max PLL time constant max */
+#define        MAXAMP          6000.   /* maximum signal level */
+#define        MAXCLP          100     /* max clips above reference per s */
+#define DRPOUT         100.    /* dropout signal level */
+#define MODMIN         0.5     /* minimum modulation index */
+#define MAXFREQ                (250e-6 * SECOND) /* freq tolerance (.025%) */
+#define PI             3.1415926535 /* the real thing */
+#ifdef IRIG_SUCKS
+#define        WIGGLE          11      /* wiggle filter length */
+#endif /* IRIG_SUCKS */
+
+/*
+ * Experimentally determined filter delays
+ */
+#define IRIG_B         .0019   /* IRIG-B filter delay */
+#define IRIG_E         .0019   /* IRIG-E filter delay */
+
+/*
+ * Data bit definitions
+ */
+#define BIT0           0       /* zero */
+#define BIT1           1       /* one */
+#define BITP           2       /* position identifier */
+
+/*
+ * Error flags (up->errflg)
+ */
+#define IRIG_ERR_AMP   0x01    /* low carrier amplitude */
+#define IRIG_ERR_FREQ  0x02    /* frequency tolerance exceeded */
+#define IRIG_ERR_MOD   0x04    /* low modulation index */
+#define IRIG_ERR_SYNCH 0x08    /* frame synch error */
+#define IRIG_ERR_DECODE        0x10    /* frame decoding error */
+#define IRIG_ERR_CHECK 0x20    /* second numbering discrepancy */
+#define IRIG_ERR_ERROR 0x40    /* codec error (overrun) */
+#define IRIG_ERR_SIGERR        0x80    /* IRIG status error (Spectracom) */
+
+/*
+ * IRIG unit control structure
+ */
+struct irigunit {
+       u_char  timecode[21];   /* timecode string */
+       l_fp    timestamp;      /* audio sample timestamp */
+       l_fp    tick;           /* audio sample increment */
+       double  integ[BAUD];    /* baud integrator */
+       double  phase, freq;    /* logical clock phase and frequency */
+       double  zxing;          /* phase detector integrator */
+       double  yxing;          /* cycle phase */
+       double  exing;          /* envelope phase */
+       double  modndx;         /* modulation index */
+       double  irig_b;         /* IRIG-B signal amplitude */
+       double  irig_e;         /* IRIG-E signal amplitude */
+       int     errflg;         /* error flags */
+       /*
+        * Audio codec variables
+        */
+       double  comp[SIZE];     /* decompanding table */
+       int     port;           /* codec port */
+       int     gain;           /* codec gain */
+       int     mongain;        /* codec monitor gain */
+       int     clipcnt;        /* sample clipped count */
+       int     seccnt;         /* second interval counter */
+
+       /*
+        * RF variables
+        */
+       double  hpf[5];         /* IRIG-B filter shift register */
+       double  lpf[5];         /* IRIG-E filter shift register */
+       double  intmin, intmax; /* integrated envelope min and max */
+       double  envmax;         /* peak amplitude */
+       double  envmin;         /* noise amplitude */
+       double  maxsignal;      /* integrated peak amplitude */
+       double  noise;          /* integrated noise amplitude */
+       double  lastenv[CYCLE]; /* last cycle amplitudes */
+       double  lastint[CYCLE]; /* last integrated cycle amplitudes */
+       double  lastsig;        /* last carrier sample */
+       double  fdelay;         /* filter delay */
+       int     decim;          /* sample decimation factor */
+       int     envphase;       /* envelope phase */
+       int     envptr;         /* envelope phase pointer */
+       int     carphase;       /* carrier phase */
+       int     envsw;          /* envelope state */
+       int     envxing;        /* envelope slice crossing */
+       int     tc;             /* time constant */
+       int     tcount;         /* time constant counter */
+       int     badcnt;         /* decimation interval counter */
+
+       /*
+        * Decoder variables
+        */
+       int     pulse;          /* cycle counter */
+       int     cycles;         /* carrier cycles */
+       int     dcycles;        /* data cycles */
+       int     xptr;           /* translate table pointer */
+       int     lastbit;        /* last code element length */
+       int     second;         /* previous second */
+       int     fieldcnt;       /* subfield count in field */
+       int     bits;           /* demodulated bits */
+       int     bitcnt;         /* bit count in subfield */
+#ifdef IRIG_SUCKS
+       l_fp    wigwag;         /* wiggle accumulator */
+       int     wp;             /* wiggle filter pointer */
+       l_fp    wiggle[WIGGLE]; /* wiggle filter */
+       l_fp    wigbot[WIGGLE]; /* wiggle bottom fisher*/
+#endif /* IRIG_SUCKS */
+       l_fp    wuggle;
+};
+
+/*
+ * Function prototypes
+ */
+static int     irig_start      P((int, struct peer *));
+static void    irig_shutdown   P((int, struct peer *));
+static void    irig_receive    P((struct recvbuf *));
+static void    irig_poll       P((int, struct peer *));
+
+/*
+ * More function prototypes
+ */
+static void    irig_base       P((struct peer *, double));
+static void    irig_rf         P((struct peer *, double));
+static void    irig_decode     P((struct peer *, int));
+static void    irig_gain       P((struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_irig = {
+       irig_start,             /* start up driver */
+       irig_shutdown,          /* shut down driver */
+       irig_poll,              /* transmit poll message */
+       noentry,                /* not used (old irig_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old irig_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+/*
+ * Global variables
+ */
+static char    hexchar[] = {   /* really quick decoding table */
+       '0', '8', '4', 'c',     /* 0000 0001 0010 0011 */
+       '2', 'a', '6', 'e',     /* 0100 0101 0110 0111 */
+       '1', '9', '5', 'd',     /* 1000 1001 1010 1011 */
+       '3', 'b', '7', 'f'      /* 1100 1101 1110 1111 */
+};
+
+
+/*
+ * irig_start - open the devices and initialize data for processing
+ */
+static int
+irig_start(
+       int     unit,           /* instance number (used for PCM) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct irigunit *up;
+
+       /*
+        * Local variables
+        */
+       int     fd;             /* file descriptor */
+       int     i;              /* index */
+       double  step;           /* codec adjustment */
+
+       /*
+        * Open audio device
+        */
+       fd = audio_init(DEVICE_AUDIO, AUDIO_BUFSIZ, unit);
+       if (fd < 0)
+               return (0);
+#ifdef DEBUG
+       if (debug)
+               audio_show();
+#endif
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct irigunit *)
+             emalloc(sizeof(struct irigunit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct irigunit));
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t)up;
+       pp->io.clock_recv = irig_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void)close(fd);
+               free(up);
+               return (0);
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       up->tc = MINTC;
+       up->decim = 1;
+       up->fdelay = IRIG_B;
+       up->gain = 127;
+
+       /*
+        * The companded samples are encoded sign-magnitude. The table
+        * contains all the 256 values in the interest of speed.
+        */
+       up->comp[0] = up->comp[OFFSET] = 0.;
+       up->comp[1] = 1; up->comp[OFFSET + 1] = -1.;
+       up->comp[2] = 3; up->comp[OFFSET + 2] = -3.;
+       step = 2.;
+       for (i = 3; i < OFFSET; i++) {
+               up->comp[i] = up->comp[i - 1] + step;
+               up->comp[OFFSET + i] = -up->comp[i];
+                if (i % 16 == 0)
+                       step *= 2.;
+       }
+       DTOLFP(1. / SECOND, &up->tick);
+       return (1);
+}
+
+
+/*
+ * irig_shutdown - shut down the clock
+ */
+static void
+irig_shutdown(
+       int     unit,           /* instance number (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct irigunit *up;
+
+       pp = peer->procptr;
+       up = (struct irigunit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * irig_receive - receive data from the audio device
+ *
+ * This routine reads input samples and adjusts the logical clock to
+ * track the irig clock by dropping or duplicating codec samples.
+ */
+static void
+irig_receive(
+       struct recvbuf *rbufp   /* receive buffer structure pointer */
+       )
+{
+       struct peer *peer;
+       struct refclockproc *pp;
+       struct irigunit *up;
+
+       /*
+        * Local variables
+        */
+       double  sample;         /* codec sample */
+       u_char  *dpt;           /* buffer pointer */
+       int     bufcnt;         /* buffer counter */
+       l_fp    ltemp;          /* l_fp temp */
+
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct irigunit *)pp->unitptr;
+
+       /*
+        * Main loop - read until there ain't no more. Note codec
+        * samples are bit-inverted.
+        */
+       DTOLFP((double)rbufp->recv_length / SECOND, &ltemp);
+       L_SUB(&rbufp->recv_time, &ltemp);
+       up->timestamp = rbufp->recv_time;
+       dpt = rbufp->recv_buffer;
+       for (bufcnt = 0; bufcnt < rbufp->recv_length; bufcnt++) {
+               sample = up->comp[~*dpt++ & 0xff];
+
+               /*
+                * Clip noise spikes greater than MAXAMP. If no clips,
+                * increase the gain a tad; if the clips are too high, 
+                * decrease a tad.
+                */
+               if (sample > MAXAMP) {
+                       sample = MAXAMP;
+                       up->clipcnt++;
+               } else if (sample < -MAXAMP) {
+                       sample = -MAXAMP;
+                       up->clipcnt++;
+               }
+
+               /*
+                * Variable frequency oscillator. The codec oscillator
+                * runs at the nominal rate of 8000 samples per second,
+                * or 125 us per sample. A frequency change of one unit
+                * results in either duplicating or deleting one sample
+                * per second, which results in a frequency change of
+                * 125 PPM.
+                */
+               up->phase += up->freq / SECOND;
+               up->phase += pp->fudgetime2 / 1e6;
+               if (up->phase >= .5) {
+                       up->phase -= 1.;
+               } else if (up->phase < -.5) {
+                       up->phase += 1.;
+                       irig_rf(peer, sample);
+                       irig_rf(peer, sample);
+               } else {
+                       irig_rf(peer, sample);
+               }
+               L_ADD(&up->timestamp, &up->tick);
+
+               /*
+                * Once each second, determine the IRIG format and gain.
+                */
+               up->seccnt = (up->seccnt + 1) % SECOND;
+               if (up->seccnt == 0) {
+                       if (up->irig_b > up->irig_e) {
+                               up->decim = 1;
+                               up->fdelay = IRIG_B;
+                       } else {
+                               up->decim = 10;
+                               up->fdelay = IRIG_E;
+                       }
+                       irig_gain(peer);
+                       up->irig_b = up->irig_e = 0;
+               }
+       }
+
+       /*
+        * Set the input port and monitor gain for the next buffer.
+        */
+       if (pp->sloppyclockflag & CLK_FLAG2)
+               up->port = 2;
+       else
+               up->port = 1;
+       if (pp->sloppyclockflag & CLK_FLAG3)
+               up->mongain = MONGAIN;
+       else
+               up->mongain = 0;
+}
+
+/*
+ * irig_rf - RF processing
+ *
+ * This routine filters the RF signal using a highpass filter for IRIG-B
+ * and a lowpass filter for IRIG-E. In case of IRIG-E, the samples are
+ * decimated by a factor of ten. The lowpass filter functions also as a
+ * decimation filter in this case. Note that the codec filters function
+ * as roofing filters to attenuate both the high and low ends of the
+ * passband. IIR filter coefficients were determined using Matlab Signal
+ * Processing Toolkit.
+ */
+static void
+irig_rf(
+       struct peer *peer,      /* peer structure pointer */
+       double  sample          /* current signal sample */
+       )
+{
+       struct refclockproc *pp;
+       struct irigunit *up;
+
+       /*
+        * Local variables
+        */
+       double  irig_b, irig_e; /* irig filter outputs */
+
+       pp = peer->procptr;
+       up = (struct irigunit *)pp->unitptr;
+
+       /*
+        * IRIG-B filter. 4th-order elliptic, 800-Hz highpass, 0.3 dB
+        * passband ripple, -50 dB stopband ripple, phase delay .0022
+        * s)
+        */
+       irig_b = (up->hpf[4] = up->hpf[3]) * 2.322484e-01;
+       irig_b += (up->hpf[3] = up->hpf[2]) * -1.103929e+00;
+       irig_b += (up->hpf[2] = up->hpf[1]) * 2.351081e+00;
+       irig_b += (up->hpf[1] = up->hpf[0]) * -2.335036e+00;
+       up->hpf[0] = sample - irig_b;
+       irig_b = up->hpf[0] * 4.335855e-01
+           + up->hpf[1] * -1.695859e+00
+           + up->hpf[2] * 2.525004e+00
+           + up->hpf[3] * -1.695859e+00
+           + up->hpf[4] * 4.335855e-01;
+       up->irig_b += irig_b * irig_b;
+
+       /*
+        * IRIG-E filter. 4th-order elliptic, 130-Hz lowpass, 0.3 dB
+        * passband ripple, -50 dB stopband ripple, phase delay .0219 s.
+        */
+       irig_e = (up->lpf[4] = up->lpf[3]) * 8.694604e-01;
+       irig_e += (up->lpf[3] = up->lpf[2]) * -3.589893e+00;
+       irig_e += (up->lpf[2] = up->lpf[1]) * 5.570154e+00;
+       irig_e += (up->lpf[1] = up->lpf[0]) * -3.849667e+00;
+       up->lpf[0] = sample - irig_e;
+       irig_e = up->lpf[0] * 3.215696e-03
+           + up->lpf[1] * -1.174951e-02
+           + up->lpf[2] * 1.712074e-02
+           + up->lpf[3] * -1.174951e-02
+           + up->lpf[4] * 3.215696e-03;
+       up->irig_e += irig_e * irig_e;
+
+       /*
+        * Decimate by a factor of either 1 (IRIG-B) or 10 (IRIG-E).
+        */
+       up->badcnt = (up->badcnt + 1) % up->decim;
+       if (up->badcnt == 0) {
+               if (up->decim == 1)
+                       irig_base(peer, irig_b);
+               else
+                       irig_base(peer, irig_e);
+       }
+}
+
+/*
+ * irig_base - baseband processing
+ *
+ * This routine processes the baseband signal and demodulates the AM
+ * carrier using a synchronous detector. It then synchronizes to the
+ * data frame at the baud rate and decodes the data pulses.
+ */
+static void
+irig_base(
+       struct peer *peer,      /* peer structure pointer */
+       double  sample          /* current signal sample */
+       )
+{
+       struct refclockproc *pp;
+       struct irigunit *up;
+
+       /*
+        * Local variables
+        */
+       double  xxing;          /* phase detector interpolated output */
+       double  lope;           /* integrator output */
+       double  env;            /* envelope detector output */
+       double  dtemp;          /* double temp */
+
+       pp = peer->procptr;
+       up = (struct irigunit *)pp->unitptr;
+
+       /*
+        * Synchronous baud integrator. Corresponding samples of current
+        * and past baud intervals are integrated to refine the envelope
+        * amplitude and phase estimate. We keep one cycle of both the
+        * raw and integrated data for later use.
+        */
+       up->envphase = (up->envphase + 1) % BAUD;
+       up->carphase = (up->carphase + 1) % CYCLE;
+       up->integ[up->envphase] += (sample - up->integ[up->envphase]) /
+           (5 * up->tc);
+       lope = up->integ[up->envphase];
+       up->lastenv[up->carphase] = sample;
+       up->lastint[up->carphase] = lope;
+
+       /*
+        * Phase detector. Sample amplitudes are integrated over the
+        * baud interval. Cycle phase is determined from these
+        * amplitudes using an eight-sample cyclic buffer. A phase
+        * change of 360 degrees produces an output change of one unit.
+        */ 
+       if (up->lastsig > 0 && lope <= 0) {
+               xxing = lope / (up->lastsig - lope);
+               up->zxing += (up->carphase - 4 + xxing) / CYCLE;
+       }
+       up->lastsig = lope;
+
+       /*
+        * Update signal/noise estimates and PLL phase/frequency.
+        */
+       if (up->envphase == 0) {
+
+               /*
+                * Update envelope signal and noise estimates and mess
+                * with error bits.
+                */
+               up->maxsignal = up->intmax;
+               up->noise = up->intmin;
+               if (up->maxsignal < DRPOUT)
+                       up->errflg |= IRIG_ERR_AMP;
+               if (up->maxsignal > 0)
+                       up->modndx = (up->intmax - up->intmin) /
+                           up->intmax;
+               else
+                       up->modndx = 0;
+               if (up->modndx < MODMIN)
+                       up->errflg |= IRIG_ERR_MOD;
+               up->intmin = 1e6; up->intmax = 0;
+               if (up->errflg & (IRIG_ERR_AMP | IRIG_ERR_FREQ |
+                  IRIG_ERR_MOD | IRIG_ERR_SYNCH)) {
+                       up->tc = MINTC;
+                       up->tcount = 0;
+               }
+
+               /*
+                * Update PLL phase and frequency. The PLL time constant
+                * is set initially to stabilize the frequency within a
+                * minute or two, then increases to the maximum. The
+                * frequency is clamped so that the PLL capture range
+                * cannot be exceeded.
+                */
+               dtemp = up->zxing * up->decim / BAUD;
+               up->yxing = dtemp;
+               up->zxing = 0.;
+               up->phase += dtemp / up->tc;
+               up->freq += dtemp / (4. * up->tc * up->tc);
+               if (up->freq > MAXFREQ) {
+                       up->freq = MAXFREQ;
+                       up->errflg |= IRIG_ERR_FREQ;
+               } else if (up->freq < -MAXFREQ) {
+                       up->freq = -MAXFREQ;
+                       up->errflg |= IRIG_ERR_FREQ;
+               }
+       }
+
+       /*
+        * Synchronous demodulator. There are eight samples in the cycle
+        * and ten cycles in the baud interval. The amplitude of each
+        * cycle is determined at the last sample in the cycle. The
+        * beginning of the data pulse is determined from the integrated
+        * samples, while the end of the pulse is determined from the
+        * raw samples. The raw data bits are demodulated relative to
+        * the slice level and left-shifted in the decoding register.
+        */
+       if (up->carphase != 7)
+               return;
+
+       env = (up->lastenv[2] - up->lastenv[6]) / 2.;
+       lope = (up->lastint[2] - up->lastint[6]) / 2.;
+       if (lope > up->intmax)
+               up->intmax = lope;
+       if (lope < up->intmin)
+               up->intmin = lope;
+
+       /*
+        * Pulse code demodulator and reference timestamp. The decoder
+        * looks for a sequence of ten bits; the first two bits must be
+        * one, the last two bits must be zero. Frame synch is asserted
+        * when three correct frames have been found.
+        */
+       up->pulse = (up->pulse + 1) % 10;
+       if (up->pulse == 1)
+               up->envmax = env;
+       else if (up->pulse == 9)
+               up->envmin = env;
+       up->dcycles <<= 1;
+       if (env >= (up->envmax + up->envmin) / 2.)
+               up->dcycles |= 1;
+       up->cycles <<= 1;
+       if (lope >= (up->maxsignal + up->noise) / 2.)
+               up->cycles |= 1;
+       if ((up->cycles & 0x303c0f03) == 0x300c0300) {
+               l_fp ltemp;
+               int bitz;
+
+               /*
+                * The PLL time constant starts out small, in order to
+                * sustain a frequency tolerance of 250 PPM. It
+                * gradually increases as the loop settles down. Note
+                * that small wiggles are not believed, unless they
+                * persist for lots of samples.
+                */
+               if (up->pulse != 9)
+                       up->errflg |= IRIG_ERR_SYNCH;
+               up->pulse = 9;
+               up->exing = -up->yxing;
+               if (fabs(up->envxing - up->envphase) <= 1) {
+                       up->tcount++;
+                       if (up->tcount > 50 * up->tc) {
+                               up->tc++;
+                               if (up->tc > MAXTC)
+                                       up->tc = MAXTC;
+                               up->tcount = 0;
+                               up->envxing = up->envphase;
+                       } else {
+                               up->exing -= up->envxing - up->envphase;
+                       }
+               } else {
+                       up->tcount = 0;
+                       up->envxing = up->envphase;
+               }
+
+               /*
+                * Determine a reference timestamp, accounting for the
+                * codec delay and filter delay. Note the timestamp is
+                * for the previous frame, so we have to backtrack for
+                * this plus the delay since the last carrier positive
+                * zero crossing.
+                */
+               dtemp = up->decim * ((up->exing + BAUD) / SECOND + 1.) +
+                   up->fdelay;
+               DTOLFP(dtemp, &ltemp);
+               pp->lastrec = up->timestamp;
+               L_SUB(&pp->lastrec, &ltemp);
+
+               /*
+                * The data bits are collected in ten-bit frames. The
+                * first two and last two bits are determined by frame
+                * sync and ignored here; the resulting patterns
+                * represent zero (0-1 bits), one (2-4 bits) and
+                * position identifier (5-6 bits). The remaining
+                * patterns represent errors and are treated as zeros.
+                */
+               bitz = up->dcycles & 0xfc;
+               switch(bitz) {
+
+               case 0x00:
+               case 0x80:
+                       irig_decode(peer, BIT0);
+                       break;
+
+               case 0xc0:
+               case 0xe0:
+               case 0xf0:
+                       irig_decode(peer, BIT1);
+                       break;
+
+               case 0xf8:
+               case 0xfc:
+                       irig_decode(peer, BITP);
+                       break;
+
+               default:
+                       irig_decode(peer, 0);
+                       up->errflg |= IRIG_ERR_DECODE;
+               }
+       }
+}
+
+
+/*
+ * irig_decode - decode the data
+ *
+ * This routine assembles bits into digits, digits into subfields and
+ * subfields into the timecode field. Bits can have values of zero, one
+ * or position identifier. There are four bits per digit, two digits per
+ * subfield and ten subfields per field. The last bit in every subfield
+ * and the first bit in the first subfield are position identifiers.
+ */
+static void
+irig_decode(
+       struct  peer *peer,     /* peer structure pointer */
+       int     bit             /* data bit (0, 1 or 2) */
+       )
+{
+       struct refclockproc *pp;
+       struct irigunit *up;
+#ifdef IRIG_SUCKS
+       int     i;
+#endif /* IRIG_SUCKS */
+
+       /*
+        * Local variables
+        */
+       char    syncchar;       /* sync character (Spectracom) */
+       char    sbs[6];         /* binary seconds since 0h */
+       char    spare[2];       /* mulligan digits */
+
+        pp = peer->procptr;
+       up = (struct irigunit *)pp->unitptr;
+
+       /*
+        * Assemble subfield bits.
+        */
+       up->bits <<= 1;
+       if (bit == BIT1) {
+               up->bits |= 1;
+       } else if (bit == BITP && up->lastbit == BITP) {
+
+               /*
+                * Frame sync - two adjacent position identifiers.
+                * Monitor the reference timestamp and wiggle the
+                * clock, but only if no errors have occurred.
+                */
+               up->bitcnt = 1;
+               up->fieldcnt = 0;
+               up->lastbit = 0;
+               if (up->errflg == 0) {
+#ifdef IRIG_SUCKS
+                       l_fp    ltemp;
+
+                       /*
+                        * You really don't wanna know what comes down
+                        * here. Leave it to say Solaris 2.8 broke the
+                        * nice clean audio stream, apparently affected
+                        * by a 5-ms sawtooth jitter. Sundown on
+                        * Solaris. This leaves a little twilight.
+                        *
+                        * The scheme involves differentiation, forward
+                        * learning and integration. The sawtooth has a
+                        * period of 11 seconds. The timestamp
+                        * differences are integrated and subtracted
+                        * from the signal.
+                        */
+                       ltemp = pp->lastrec;
+                       L_SUB(&ltemp, &pp->lastref);
+                       if (ltemp.l_f < 0)
+                               ltemp.l_i = -1;
+                       else
+                               ltemp.l_i = 0;
+                       pp->lastref = pp->lastrec;
+                       if (!L_ISNEG(&ltemp))
+                               L_CLR(&up->wigwag);
+                       else
+                               L_ADD(&up->wigwag, &ltemp);
+                       L_SUB(&pp->lastrec, &up->wigwag);
+                       up->wiggle[up->wp] = ltemp;
+
+                       /*
+                        * Bottom fisher. To understand this, you have
+                        * to know about velocity microphones and AM
+                        * transmitters. No further explanation is
+                        * offered, as this is truly a black art.
+                        */
+                       up->wigbot[up->wp] = pp->lastrec;
+                       for (i = 0; i < WIGGLE; i++) {
+                               if (i != up->wp)
+                                       up->wigbot[i].l_ui++;
+                               L_SUB(&pp->lastrec, &up->wigbot[i]);
+                               if (L_ISNEG(&pp->lastrec))
+                                       L_ADD(&pp->lastrec,
+                                           &up->wigbot[i]);
+                               else
+                                       pp->lastrec = up->wigbot[i];
+                       }
+                       up->wp++;
+                       up->wp %= WIGGLE;
+                       up->wuggle = pp->lastrec;
+                       refclock_process(pp);
+#else /* IRIG_SUCKS */
+                       pp->lastref = pp->lastrec;
+                       up->wuggle = pp->lastrec;
+                       refclock_process(pp);
+#endif /* IRIG_SUCKS */
+               }
+               up->errflg = 0;
+       }
+       up->bitcnt = (up->bitcnt + 1) % SUBFLD;
+       if (up->bitcnt == 0) {
+
+               /*
+                * End of subfield. Encode two hexadecimal digits in
+                * little-endian timecode field.
+                */
+               if (up->fieldcnt == 0)
+                   up->bits <<= 1;
+               if (up->xptr < 2)
+                   up->xptr = 2 * FIELD;
+               up->timecode[--up->xptr] = hexchar[(up->bits >> 5) &
+                   0xf];
+               up->timecode[--up->xptr] = hexchar[up->bits & 0xf];
+               up->fieldcnt = (up->fieldcnt + 1) % FIELD;
+               if (up->fieldcnt == 0) {
+
+                       /*
+                        * End of field. Decode the timecode and wind
+                        * the clock. Not all IRIG generators have the
+                        * year; if so, it is nonzero after year 2000.
+                        * Not all have the hardware status bit; if so,
+                        * it is lit when the source is okay and dim
+                        * when bad. We watch this only if the year is
+                        * nonzero. Not all are configured for signature
+                        * control. If so, all BCD digits are set to
+                        * zero if the source is bad. In this case the
+                        * refclock_process() will reject the timecode
+                        * as invalid.
+                        */
+                       up->xptr = 2 * FIELD;
+                       if (sscanf((char *)up->timecode,
+                          "%6s%2d%c%2s%3d%2d%2d%2d", sbs, &pp->year,
+                           &syncchar, spare, &pp->day, &pp->hour,
+                           &pp->minute, &pp->second) != 8)
+                               pp->leap = LEAP_NOTINSYNC;
+                       else
+                               pp->leap = LEAP_NOWARNING;
+                       up->second = (up->second + up->decim) % 60;
+                       if (pp->year > 0)
+                               pp->year += 2000;
+                       if (pp->second != up->second)
+                               up->errflg |= IRIG_ERR_CHECK;
+                       up->second = pp->second;
+                       sprintf(pp->a_lastcode,
+                           "%02x %c %2d %3d %02d:%02d:%02d %4.0f %3d %6.3f %2d %6.1f %6.1f %s",
+                           up->errflg, syncchar, pp->year, pp->day,
+                           pp->hour, pp->minute, pp->second,
+                           up->maxsignal, up->gain, up->modndx,
+                           up->tc, up->exing * 1e6 / SECOND, up->freq *
+                           1e6 / SECOND, ulfptoa(&up->wuggle, 6));
+                       pp->lencode = strlen(pp->a_lastcode);
+                       if (pp->sloppyclockflag & CLK_FLAG4) {
+                               record_clock_stats(&peer->srcadr,
+                                   pp->a_lastcode);
+#ifdef DEBUG
+                               if (debug)
+                                       printf("irig: %s\n",
+                                           pp->a_lastcode);
+#endif /* DEBUG */
+                       }
+               }
+       }
+       up->lastbit = bit;
+}
+
+
+/*
+ * irig_poll - called by the transmit procedure
+ *
+ * This routine sweeps up the timecode updates since the last poll. For
+ * IRIG-B there should be at least 60 updates; for IRIG-E there should
+ * be at least 6. If nothing is heard, a timeout event is declared and
+ * any orphaned timecode updates are sent to foster care. 
+ */
+static void
+irig_poll(
+       int     unit,           /* instance number (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct irigunit *up;
+
+       pp = peer->procptr;
+       up = (struct irigunit *)pp->unitptr;
+
+       if (pp->coderecv == pp->codeproc) {
+               refclock_report(peer, CEVNT_TIMEOUT);
+               return;
+
+       } else {
+               refclock_receive(peer);
+               record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+               if (debug)
+                       printf("irig: %s\n", pp->a_lastcode);
+#endif /* DEBUG */
+       }
+       pp->polls++;
+       
+}
+
+
+/*
+ * irig_gain - adjust codec gain
+ *
+ * This routine is called once each second. If the signal envelope
+ * amplitude is too low, the codec gain is bumped up by four units; if
+ * too high, it is bumped down. The decoder is relatively insensitive to
+ * amplitude, so this crudity works just fine. The input port is set and
+ * the error flag is cleared, mostly to be ornery.
+ */
+static void
+irig_gain(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct irigunit *up;
+
+       pp = peer->procptr;
+       up = (struct irigunit *)pp->unitptr;
+
+       /*
+        * Apparently, the codec uses only the high order bits of the
+        * gain control field. Thus, it may take awhile for changes to
+        * wiggle the hardware bits.
+        */
+       if (up->clipcnt == 0) {
+               up->gain += 4;
+               if (up->gain > MAXGAIN)
+                       up->gain = MAXGAIN;
+       } else if (up->clipcnt > MAXCLP) {
+               up->gain -= 4;
+               if (up->gain < 0)
+                       up->gain = 0;
+       }
+       audio_gain(up->gain, up->mongain, up->port);
+       up->clipcnt = 0;
+}
+
+#else
+int refclock_irig_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_jjy.c b/ntpd/refclock_jjy.c
new file mode 100644 (file)
index 0000000..d1707ce
--- /dev/null
@@ -0,0 +1,1159 @@
+/*
+ * refclock_jjy - clock driver for JJY receivers
+ */
+
+/**********************************************************************/
+/*                                                                    */
+/*  Copyright (C) 2001-2004, Takao Abe.  All rights reserved.         */
+/*                                                                    */
+/*  Permission to use, copy, modify, and distribute this software     */
+/*  and its documentation for any purpose is hereby granted           */
+/*  without fee, provided that the following conditions are met:      */
+/*                                                                    */
+/*  One retains the entire copyright notice properly, and both the    */
+/*  copyright notice and this license. in the documentation and/or    */
+/*  other materials provided with the distribution.                   */
+/*                                                                    */
+/*  This software and the name of the author must not be used to      */
+/*  endorse or promote products derived from this software without    */
+/*  prior written permission.                                         */
+/*                                                                    */
+/*  THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESSED OR IMPLIED    */
+/*  WARRANTIES OF ANY KIND, INCLUDING, BUT NOT LIMITED TO, THE        */
+/*  IMPLIED WARRANTIES OF MERCHANTABLILITY AND FITNESS FOR A          */
+/*  PARTICULAR PURPOSE.                                               */
+/*  IN NO EVENT SHALL THE AUTHOR TAKAO ABE BE LIABLE FOR ANY DIRECT,  */
+/*  INDIRECT, GENERAL, 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. */
+/*                                                                    */
+/*  This driver is developed in my private time, and is opened as     */
+/*  voluntary contributions for the NTP.                              */
+/*  The manufacturer of the JJY receiver has not participated in      */
+/*  a development of this driver.                                     */
+/*  The manufacturer does not warrant anything about this driver,     */
+/*  and is not liable for anything about this driver.                 */
+/*                                                                    */
+/**********************************************************************/
+/*                                                                    */
+/*  Author     Takao Abe                                              */
+/*  Email      abetakao@bea.hi-ho.ne.jp                               */
+/*  Homepage   http://www.bea.hi-ho.ne.jp/abetakao/                   */
+/*                                                                    */
+/**********************************************************************/
+/*                                                                    */
+/*  History                                                           */
+/*                                                                    */
+/*  2001/07/15                                                        */
+/*    [New]    Support the Tristate Ltd. JJY receiver                 */
+/*                                                                    */
+/*  2001/08/04                                                        */
+/*    [Change] Log to clockstats even if bad reply                    */
+/*    [Fix]    PRECISION = (-3) (about 100 ms)                        */
+/*    [Add]    Support the C-DEX Co.Ltd. JJY receiver                 */
+/*                                                                    */
+/*  2001/12/04                                                        */
+/*    [Fix]    C-DEX JST2000 ( fukusima@goto.info.waseda.ac.jp )      */
+/*                                                                    */
+/*  2002/07/12                                                        */
+/*    [Fix]    Portability for FreeBSD ( patched by the user )        */
+/*                                                                    */
+/*  2004/10/31                                                        */
+/*    [Change] Command send timing for the Tristate Ltd. JJY receiver */
+/*             JJY-01 ( Firmware version 2.01 )                       */
+/*             Thanks to Andy Taki for testing under FreeBSD          */
+/*                                                                    */
+/*  2004/11/28                                                        */
+/*    [Add]    Support the Echo Keisokuki LT-2000 receiver            */
+/*                                                                    */
+/*  2006/11/04                                                        */
+/*    [Fix]    C-DEX JST2000                                          */
+/*             Thanks to Hideo Kuramatsu for the patch                */
+/*                                                                    */
+/*  2009/04/05                                                        */
+/*    [Add]    Support the CITIZEN T.I.C JJY-200 receiver             */
+/*                                                                    */
+/**********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_JJY)
+
+#include <stdio.h>
+#include <ctype.h>
+#include <string.h>
+#include <sys/time.h>
+#include <time.h>
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_tty.h"
+#include "ntp_refclock.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+/**********************************************************************/
+/*                                                                    */
+/*  The Tristate Ltd. JJY receiver JJY01                              */
+/*                                                                    */
+/*  Command        Response                 Remarks                   */
+/*  ------------   ----------------------   ---------------------     */
+/*  date<CR><LF>   YYYY/MM/DD XXX<CR><LF>                             */
+/*  time<CR><LF>   HH:MM:SS<CR><LF>                                   */
+/*  stim<CR><LF>   HH:MM:SS<CR><LF>         Reply at just second      */
+/*                                                                    */
+/*  During synchronization after a receiver is turned on,             */
+/*  It replies the past time from 2000/01/01 00:00:00.                */
+/*  The function "refclock_process" checks the time and tells         */
+/*  as an insanity time.                                              */
+/*                                                                    */
+/**********************************************************************/
+/*                                                                    */
+/*  The C-DEX Co. Ltd. JJY receiver JST2000                           */
+/*                                                                    */
+/*  Command        Response                 Remarks                   */
+/*  ------------   ----------------------   ---------------------     */
+/*  <ENQ>1J<ETX>   <STX>JYYMMDD HHMMSSS<ETX>                          */
+/*                                                                    */
+/**********************************************************************/
+/*                                                                    */
+/*  The Echo Keisokuki Co. Ltd. JJY receiver LT2000                   */
+/*                                                                    */
+/*  Command        Response                 Remarks                   */
+/*  ------------   ----------------------   ---------------------     */
+/*  #                                       Mode 1 (Request&Send)     */
+/*  T              YYMMDDWHHMMSS<BCC1><BCC2><CR>                      */
+/*  C                                       Mode 2 (Continuous)       */
+/*                 YYMMDDWHHMMSS<ST1><ST2><ST3><ST4><CR>              */
+/*                 <SUB>                    Second signal             */
+/*                                                                    */
+/**********************************************************************/
+/*                                                                    */
+/*  The CITIZEN T.I.C CO., LTD. JJY receiver JJY200                   */
+/*                                                                    */
+/*  Command        Response                 Remarks                   */
+/*  ------------   ----------------------   ---------------------     */
+/*                 'XX YY/MM/DD W HH:MM:SS<CR>                        */
+/*                                          XX: OK|NG|ER              */
+/*                                          W:  0(Monday)-6(Sunday)   */
+/*                                                                    */
+/**********************************************************************/
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/jjy%d"    /* device name and unit */
+#define        SPEED232        B9600           /* uart speed (9600 baud) */
+#define        SPEED232_TRISTATE_JJY01         B9600   /* UART speed (9600 baud) */
+#define        SPEED232_CDEX_JST2000           B9600   /* UART speed (9600 baud) */
+#define        SPEED232_ECHOKEISOKUKI_LT2000   B9600   /* UART speed (9600 baud) */
+#define        SPEED232_CITIZENTIC_JJY200      B4800   /* UART speed (4800 baud) */
+#define        REFID           "JJY"           /* reference ID */
+#define        DESCRIPTION     "JJY Receiver"
+#define        PRECISION       (-3)           /* precision assumed (about 100 ms) */
+
+/*
+ * JJY unit control structure
+ */
+struct jjyunit {
+       char    unittype ;          /* UNITTYPE_XXXXXXXXXX */
+    short   operationmode ;     /* Echo Keisokuki LT-2000 : 1 or 2 */
+       short   version ;
+       short   linediscipline ;        /* LDISC_CLK or LDISC_RAW */
+    char    bPollFlag ;         /* Set by jjy_pool and Reset by jjy_receive */
+       int     linecount ;
+       int     lineerror ;
+       int     year, month, day, hour, minute, second, msecond ;
+/* LDISC_RAW only */
+#define        MAX_LINECOUNT   8
+#define        MAX_RAWBUF      64
+       int     lineexpect ;
+       int     charexpect [ MAX_LINECOUNT ] ;
+       int     charcount ;
+       char    rawbuf [ MAX_RAWBUF ] ;
+};
+
+#define        UNITTYPE_TRISTATE_JJY01 1
+#define        UNITTYPE_CDEX_JST2000   2
+#define        UNITTYPE_ECHOKEISOKUKI_LT2000   3
+#define        UNITTYPE_CITIZENTIC_JJY200      4
+
+/*
+ * Function prototypes
+ */
+static int     jjy_start                   P((int, struct peer *));
+static void    jjy_shutdown                P((int, struct peer *));
+static void    jjy_poll                    P((int, struct peer *));
+static void    jjy_poll_tristate_jjy01     P((int, struct peer *));
+static void    jjy_poll_cdex_jst2000       P((int, struct peer *));
+static void    jjy_poll_echokeisokuki_lt2000    P((int, struct peer *));
+static  void    jjy_poll_citizentic_jjy200          P((int, struct peer *));
+static void    jjy_receive                 P((struct recvbuf *));
+static int     jjy_receive_tristate_jjy01  P((struct recvbuf *));
+static int     jjy_receive_cdex_jst2000    P((struct recvbuf *));
+static int     jjy_receive_echokeisokuki_lt2000 P((struct recvbuf *));
+static  int     jjy_receive_citizentic_jjy200       P((struct recvbuf *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_jjy = {
+       jjy_start,      /* start up driver */
+       jjy_shutdown,   /* shutdown driver */
+       jjy_poll,       /* transmit poll message */
+       noentry,        /* not used */
+       noentry,        /* not used */
+       noentry,        /* not used */
+       NOFLAGS         /* not used */
+};
+
+/*
+ * Start up driver return code
+ */
+#define        RC_START_SUCCESS        1
+#define        RC_START_ERROR          0
+
+/*
+ * Local constants definition
+ */
+
+#define        MAX_LOGTEXT     64
+
+
+/**************************************************************************************************/
+/*  jjy_start - open the devices and initialize data for processing                               */
+/**************************************************************************************************/
+static int
+jjy_start ( int unit, struct peer *peer )
+{
+
+       struct jjyunit      *up ;
+       struct refclockproc *pp ;
+       int     fd ;
+       char    *pDeviceName ;
+       short   iDiscipline ;
+       int     iSpeed232 ;
+
+#ifdef DEBUG
+       if ( debug ) {
+               printf ( "jjy_start (refclock_jjy.c) : %s  mode=%d  ", ntoa(&peer->srcadr), peer->ttl ) ;
+               printf ( DEVICE, unit ) ;
+               printf ( "\n" ) ;
+       }
+#endif
+       /*
+        * Open serial port
+        */
+       if ( ! ( pDeviceName = (char*) emalloc ( strlen(DEVICE) + 10 ) ) ) {
+               return RC_START_ERROR ;
+       }
+       sprintf ( pDeviceName, DEVICE, unit ) ;
+
+       /*
+        * peer->ttl is a mode number specified by "127.127.40.X mode N" in the ntp.conf
+        */
+       switch ( peer->ttl ) {
+       case 0 :
+    case 1 :
+        iDiscipline = LDISC_CLK ;
+        iSpeed232   = SPEED232_TRISTATE_JJY01 ;
+        break ;
+    case 2 :
+        iDiscipline = LDISC_RAW ;
+        iSpeed232   = SPEED232_CDEX_JST2000   ;
+        break ;
+    case 3 :
+        iDiscipline = LDISC_CLK ;
+        iSpeed232   = SPEED232_ECHOKEISOKUKI_LT2000 ;
+        break ;
+    case 4 :
+        iDiscipline = LDISC_CLK ;
+        iSpeed232   = SPEED232_CITIZENTIC_JJY200 ;
+        break ;
+       default :
+               msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Unsupported mode",
+                         ntoa(&peer->srcadr), peer->ttl ) ;
+               free ( (void*) pDeviceName ) ;
+               return RC_START_ERROR ;
+       }
+
+       if ( ! ( fd = refclock_open ( pDeviceName, iSpeed232, iDiscipline ) ) ) {
+               free ( (void*) pDeviceName ) ;
+               return RC_START_ERROR ;
+       }
+       free ( (void*) pDeviceName ) ;
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if ( ! ( up = (struct jjyunit *) emalloc (sizeof(struct jjyunit)) ) ) {
+               close ( fd ) ;
+               return RC_START_ERROR ;
+       }
+
+       memset ( (char*)up, 0, sizeof(struct jjyunit) ) ;
+       up->linediscipline = iDiscipline ;
+
+       /*
+        * peer->ttl is a mode number specified by "127.127.40.X mode N" in the ntp.conf
+        */
+       switch ( peer->ttl ) {
+       case 0 :
+               /*
+                * The mode 0 is a default clock type at this time.
+                * But this will be change to auto-detect mode in the future.
+                */
+       case 1 :
+               up->unittype = UNITTYPE_TRISTATE_JJY01 ;
+               up->version  = 100 ;
+               up->lineexpect = 2 ;
+               up->charexpect[0] = 14 ; /* YYYY/MM/DD WWW<CR><LF> */
+               up->charexpect[1] =  8 ; /* HH:MM:SS<CR><LF> */
+               break ;
+       case 2 :
+               up->unittype = UNITTYPE_CDEX_JST2000 ;
+               up->lineexpect = 1 ;
+               up->charexpect[0] = 15 ; /* <STX>JYYMMDD HHMMSSS<ETX> */
+               break ;
+       case 3 :
+               up->unittype = UNITTYPE_ECHOKEISOKUKI_LT2000 ;
+               up->operationmode = 2 ;  /* Mode 2 : Continuous mode */
+               up->lineexpect = 1 ;
+        switch ( up->operationmode ) {
+        case 1 :
+                       up->charexpect[0] = 15 ; /* YYMMDDWHHMMSS<BCC1><BCC2><CR> */
+                       break ;
+               case 2 :
+                       up->charexpect[0] = 17 ; /* YYMMDDWHHMMSS<ST1><ST2><ST3><ST4><CR> */
+                       break ;
+               }
+               break ;
+    case 4 :
+        up->unittype = UNITTYPE_CITIZENTIC_JJY200 ;
+        up->lineexpect = 1 ;
+        up->charexpect[0] = 23 ; /* 'XX YY/MM/DD W HH:MM:SS<CR> */
+        break ;
+       default :
+               msyslog ( LOG_ERR, "JJY receiver [ %s mode %d ] : Unsupported mode",
+                         ntoa(&peer->srcadr), peer->ttl ) ;
+               close ( fd ) ;
+               free ( (void*) up ) ;
+               return RC_START_ERROR ;
+       }
+
+       pp = peer->procptr ;
+       pp->unitptr       = (caddr_t) up ;
+       pp->io.clock_recv = jjy_receive ;
+       pp->io.srcclock   = (caddr_t) peer ;
+       pp->io.datalen    = 0 ;
+       pp->io.fd         = fd ;
+       if ( ! io_addclock(&pp->io) ) {
+               close ( fd ) ;
+               free ( (void*) up ) ;
+               return RC_START_ERROR ;
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION ;
+       peer->burst     = 1 ;
+       pp->clockdesc   = DESCRIPTION ;
+       memcpy ( (char*)&pp->refid, REFID, strlen(REFID) ) ;
+
+       return RC_START_SUCCESS ;
+
+}
+
+
+/**************************************************************************************************/
+/*  jjy_shutdown - shutdown the clock                                                             */
+/**************************************************************************************************/
+static void
+jjy_shutdown ( int unit, struct peer *peer )
+{
+
+       struct jjyunit      *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr ;
+       up = (struct jjyunit *) pp->unitptr ;
+       io_closeclock ( &pp->io ) ;
+       free ( (void*) up ) ;
+
+}
+
+
+/**************************************************************************************************/
+/*  jjy_receive - receive data from the serial interface                                          */
+/**************************************************************************************************/
+static void
+jjy_receive ( struct recvbuf *rbufp )
+{
+
+       struct jjyunit      *up ;
+       struct refclockproc *pp ;
+       struct peer         *peer;
+
+       l_fp    tRecvTimestamp;         /* arrival timestamp */
+       int     rc ;
+       char    sLogText [ MAX_LOGTEXT ] ;
+       int     i, bCntrlChar ;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *) rbufp->recv_srcclock ;
+       pp = peer->procptr ;
+       up = (struct jjyunit *) pp->unitptr ;
+
+       /*
+        * Get next input line
+        */
+       pp->lencode  = refclock_gtlin ( rbufp, pp->a_lastcode, BMAX, &tRecvTimestamp ) ;
+
+       if ( up->linediscipline == LDISC_RAW ) {
+               /*
+                * The reply with <STX> and <ETX> may give a blank line
+                */
+               if ( pp->lencode == 0  &&  up->charcount == 0 ) return ;
+               /*
+                * Copy received charaters to temporary buffer 
+                */
+               for ( i = 0 ; i < pp->lencode && up->charcount < MAX_RAWBUF - 2 ; i ++ , up->charcount ++ ) {
+                       up->rawbuf[up->charcount] = pp->a_lastcode[i] ;
+               }
+               while ( up->charcount > 0 && up->rawbuf[0] < ' ' ) {
+                       for ( i = 0 ; i < up->charcount - 1 ; i ++ ) up->rawbuf[i] = up->rawbuf[i+1] ;
+                       up->charcount -- ;
+               }
+               bCntrlChar = 0 ;
+               for ( i = 0 ; i < up->charcount ; i ++ ) {
+                       if ( up->rawbuf[i] < ' ' ) {
+                               bCntrlChar = 1 ;
+                               break ;
+                       }
+               }
+               if ( pp->lencode > 0  &&  up->linecount < up->lineexpect ) {
+                       if ( bCntrlChar == 0  &&  up->charcount < up->charexpect[up->linecount] ) return ;
+               }
+               up->rawbuf[up->charcount] = 0 ;
+       } else {
+               /*
+                * The reply with <CR><LF> gives a blank line
+                */
+               if ( pp->lencode == 0 ) return ;
+       }
+       /*
+        * We get down to business
+        */
+
+       pp->lastrec = tRecvTimestamp ;
+
+       up->linecount ++ ;
+
+       if ( up->lineerror != 0 ) return ;
+
+       switch ( up->unittype ) {
+       
+       case UNITTYPE_TRISTATE_JJY01 :
+               rc = jjy_receive_tristate_jjy01  ( rbufp ) ;
+               break ;
+
+       case UNITTYPE_CDEX_JST2000 :
+               rc = jjy_receive_cdex_jst2000 ( rbufp ) ;
+               break ;
+
+       case UNITTYPE_ECHOKEISOKUKI_LT2000 :
+               rc = jjy_receive_echokeisokuki_lt2000 ( rbufp ) ;
+               break ;
+
+    case UNITTYPE_CITIZENTIC_JJY200 :
+        rc = jjy_receive_citizentic_jjy200 ( rbufp ) ;
+        break ;
+
+       default :
+               rc = 0 ;
+               break ;
+
+       }
+
+       if ( up->linediscipline == LDISC_RAW ) {
+               if ( up->linecount <= up->lineexpect  &&  up->charcount > up->charexpect[up->linecount-1] ) {
+                       for ( i = 0 ; i < up->charcount - up->charexpect[up->linecount-1] ; i ++ ) {
+                               up->rawbuf[i] = up->rawbuf[i+up->charexpect[up->linecount-1]] ;
+                       }
+                       up->charcount -= up->charexpect[up->linecount-1] ;
+               } else {
+                       up->charcount = 0 ;
+               }
+       }
+
+       if ( rc == 0 ) return ;
+
+    up->bPollFlag = 0 ;
+
+       if ( up->lineerror != 0 ) {
+               refclock_report ( peer, CEVNT_BADREPLY ) ;
+               strcpy  ( sLogText, "BAD REPLY [" ) ;
+               if ( up->linediscipline == LDISC_RAW ) {
+                       strncat ( sLogText, up->rawbuf, MAX_LOGTEXT - strlen ( sLogText ) - 1 ) ;
+               } else {
+                       strncat ( sLogText, pp->a_lastcode, MAX_LOGTEXT - strlen ( sLogText ) - 1 ) ;
+               }
+               sLogText[MAX_LOGTEXT-1] = 0 ;
+               if ( strlen ( sLogText ) < MAX_LOGTEXT - 2 ) strcat ( sLogText, "]" ) ;
+               record_clock_stats ( &peer->srcadr, sLogText ) ;
+               return ;
+       }
+
+       pp->year   = up->year ;
+       pp->day    = ymd2yd ( up->year, up->month, up->day ) ;
+       pp->hour   = up->hour ;
+       pp->minute = up->minute ;
+       pp->second = up->second ;
+       pp->nsec   = up->msecond * 1000000;
+
+       /* 
+        * JST to UTC 
+        */
+       pp->hour -= 9 ;
+       if ( pp->hour < 0 ) {
+               pp->hour += 24 ;
+               pp->day -- ;
+               if ( pp->day < 1 ) {
+                       pp->year -- ;
+                       pp->day  = ymd2yd ( pp->year, 12, 31 ) ;
+               }
+       }
+#ifdef DEBUG
+       if ( debug ) {
+               printf ( "jjy_receive (refclock_jjy.c) : %04d/%02d/%02d %02d:%02d:%02d.%1d JST   ", 
+                         up->year, up->month, up->day, up->hour, up->minute, up->second, up->msecond/100 ) ;
+               printf ( "( %04d/%03d %02d:%02d:%02d.%1d UTC )\n",
+                         pp->year, pp->day, pp->hour, pp->minute, pp->second, (int)(pp->nsec/100000000) ) ;
+       }
+#endif
+
+       /*
+        * Process the new sample in the median filter and determine the
+        * timecode timestamp.
+        */
+
+       sprintf ( sLogText, "%04d/%02d/%02d %02d:%02d:%02d.%1d JST",
+                 up->year, up->month, up->day, up->hour, up->minute, up->second, up->msecond/100 ) ;
+       record_clock_stats ( &peer->srcadr, sLogText ) ;
+
+       if ( ! refclock_process ( pp ) ) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return ;
+       }
+
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+
+}
+
+/**************************************************************************************************/
+
+static int
+jjy_receive_tristate_jjy01 ( struct recvbuf *rbufp )
+{
+
+       static  char    *sFunctionName = "jjy_receive_tristate_jjy01" ;
+
+       struct jjyunit      *up ;
+       struct refclockproc *pp ;
+       struct peer         *peer;
+
+       char    *pBuf ;
+       int     iLen ;
+       int     rc ;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *) rbufp->recv_srcclock ;
+       pp = peer->procptr ;
+       up = (struct jjyunit *) pp->unitptr ;
+
+       if ( up->linediscipline == LDISC_RAW ) {
+               pBuf = up->rawbuf ;
+               iLen = up->charcount ;
+       } else {
+           pBuf = pp->a_lastcode ;
+           iLen = pp->lencode ;
+       }
+
+       switch ( up->linecount ) {
+
+       case 1 : /* YYYY/MM/DD WWW */
+
+               if ( iLen != 14 ) {
+#ifdef DEBUG
+               if ( debug >= 2 ) {
+                       printf ( "%s (refclock_jjy.c) : Reply length error ( up->linecount=%d  iLen=%d )\n", sFunctionName, up->linecount, iLen ) ;
+               }
+#endif
+                       up->lineerror = 1 ;
+                       break ;
+               }
+               rc = sscanf ( pBuf, "%4d/%2d/%2d", &up->year, &up->month, &up->day ) ;
+               if ( rc != 3 || up->year < 2000 || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31 ) {
+#ifdef DEBUG
+               if ( debug >= 2 ) {
+                       printf ( "%s (refclock_jjy.c) : Date error ( up->linecount=%d )\n", sFunctionName, up->linecount ) ;
+               }
+#endif
+                       up->lineerror = 1 ;
+                       break ;
+               }
+
+               /*** Start of modification on 2004/10/31 */
+               /*
+                * Following codes are moved from the function jjy_poll_tristate_jjy01 in this source.
+                * The Tristate JJY-01 ( Firmware version 1.01 ) accepts "time" and "stim" commands without any delay.
+                * But the JJY-01 ( Firmware version 2.01 ) does not accept these commands continuously,
+                * so this driver issues the second command "stim" after the reply of the first command "date".
+                */
+
+               /*
+                * Send "stim<CR><LF>" or "time<CR><LF>" command
+                */
+                
+
+               if ( up->version >= 100 ) {
+#ifdef DEBUG
+                       if ( debug ) {
+                               printf ( "%s (refclock_jjy.c) : send 'stim<CR><LF>'\n", sFunctionName ) ;
+                       }
+#endif
+                       if ( write ( pp->io.fd, "stim\r\n",6 ) != 6  ) {
+                               refclock_report ( peer, CEVNT_FAULT ) ;
+                       }
+               } else {
+#ifdef DEBUG
+                       if ( debug ) {
+                               printf ( "%s (refclock_jjy.c) : send 'time<CR><LF>'\n", sFunctionName ) ;
+                       }
+#endif
+                       if ( write ( pp->io.fd, "time\r\n",6 ) != 6  ) {
+                               refclock_report ( peer, CEVNT_FAULT ) ;
+                       }
+               }
+               /*** End of modification ***/
+
+               return 0 ;
+
+       case 2 : /* HH:MM:SS */
+
+               if ( iLen != 8 ) {
+#ifdef DEBUG
+               if ( debug >= 2 ) {
+                       printf ( "%s (refclock_jjy.c) : Reply length error ( up->linecount=%d  iLen=%d )\n", sFunctionName, up->linecount, iLen ) ;
+               }
+#endif
+                       up->lineerror = 1 ;
+                       break ;
+               }
+               rc = sscanf ( pBuf, "%2d:%2d:%2d", &up->hour, &up->minute, &up->second ) ;
+               if ( rc != 3 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
+#ifdef DEBUG
+               if ( debug >= 2 ) {
+                       printf ( "%s (refclock_jjy.c) : Time error ( up->linecount=%d )\n", sFunctionName, up->linecount ) ;
+               }
+#endif
+                       up->lineerror = 1 ;
+                       break ;
+               }
+               up->msecond = 0 ;
+               if ( up->hour == 0 && up->minute == 0 && up->second <= 2 ) {
+                       /*
+                        * The command "date" and "time" ( or "stim" ) were sent to the JJY receiver continuously.
+                        * But the JJY receiver replies a date and time separately.
+                        * Just after midnight transitions, we ignore this time.
+                        */
+                       return 0 ;
+               }
+               break ;
+
+       default : /*  Unexpected reply */
+
+               up->lineerror = 1 ;
+               break ;
+
+       }
+
+       return 1 ;
+
+}
+
+/**************************************************************************************************/
+
+static int
+jjy_receive_cdex_jst2000 ( struct recvbuf *rbufp )
+{
+
+       static  char    *sFunctionName = "jjy_receive_cdex_jst2000" ;
+
+       struct jjyunit      *up ;
+       struct refclockproc *pp ;
+       struct peer         *peer;
+
+       char    *pBuf ;
+       int     iLen ;
+       int     rc ;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *) rbufp->recv_srcclock ;
+       pp = peer->procptr ;
+       up = (struct jjyunit *) pp->unitptr ;
+
+       if ( up->linediscipline == LDISC_RAW ) {
+               pBuf = up->rawbuf ;
+               iLen = up->charcount ;
+       } else {
+           pBuf = pp->a_lastcode ;
+           iLen = pp->lencode ;
+       }
+
+       switch ( up->linecount ) {
+
+       case 1 : /* JYYMMDD HHMMSSS */
+
+               if ( iLen != 15 ) {
+#ifdef DEBUG
+               if ( debug >= 2 ) {
+                       printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", sFunctionName, iLen ) ;
+               }
+#endif
+                       up->lineerror = 1 ;
+                       break ;
+               }
+               rc = sscanf ( pBuf, "J%2d%2d%2d%*1d%2d%2d%2d%1d",
+                             &up->year, &up->month, &up->day, &up->hour, &up->minute, &up->second, &up->msecond ) ;
+               if ( rc != 7 || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
+                 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
+#ifdef DEBUG
+               if ( debug >= 2 ) {
+                       printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %02d %02d %02d * %02d %02d %02d.%1d ]\n", sFunctionName,
+                                                rc, up->year, up->month, up->day, up->hour, up->minute, up->second, up->msecond ) ;
+               }
+#endif
+                       up->lineerror = 1 ;
+                       break ;
+               }
+               up->year    += 2000 ;
+               up->msecond *= 100 ;
+               break ;
+
+       default : /*  Unexpected reply */
+
+               up->lineerror = 1 ;
+               break ;
+
+       }
+
+       return 1 ;
+
+}
+
+/**************************************************************************************************/
+
+static int
+jjy_receive_echokeisokuki_lt2000 ( struct recvbuf *rbufp )
+{
+
+       static  char    *sFunctionName = "jjy_receive_echokeisokuki_lt2000" ;
+
+       struct jjyunit      *up ;
+       struct refclockproc *pp ;
+       struct peer         *peer;
+
+       char    *pBuf ;
+       int     iLen ;
+       int     rc ;
+    int     i, ibcc, ibcc1, ibcc2 ;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *) rbufp->recv_srcclock ;
+       pp = peer->procptr ;
+       up = (struct jjyunit *) pp->unitptr ;
+
+       if ( up->linediscipline == LDISC_RAW ) {
+               pBuf = up->rawbuf ;
+               iLen = up->charcount ;
+       } else {
+           pBuf = pp->a_lastcode ;
+           iLen = pp->lencode ;
+       }
+
+       switch ( up->linecount ) {
+
+       case 1 : /* YYMMDDWHHMMSS<BCC1><BCC2> or YYMMDDWHHMMSS<ST1><ST2><ST3><ST4> */
+
+               if ( ( up->operationmode == 1 && iLen != 15 ) || ( up->operationmode == 2 && iLen != 17 ) ) {
+#ifdef DEBUG
+               if ( debug >= 2 ) {
+                       printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", sFunctionName, iLen ) ;
+               }
+#endif
+                       if ( up->operationmode == 1 ) {
+#ifdef DEBUG
+                               if ( debug ) {
+                                       printf ( "%s (refclock_jjy.c) : send '#'\n", sFunctionName ) ;
+                               }
+#endif
+                               if ( write ( pp->io.fd, "#",1 ) != 1  ) {
+                                       refclock_report ( peer, CEVNT_FAULT ) ;
+                               }
+                       }
+                       up->lineerror = 1 ;
+                       break ;
+               }
+
+               if ( up->operationmode == 1 ) {
+
+               for ( i = ibcc = 0 ; i < 13 ; i ++ ) ibcc ^= pBuf[i] ;
+               ibcc1 = 0x30 | ( ( ibcc >> 4 ) & 0xF ) ;
+               ibcc2 = 0x30 | ( ( ibcc      ) & 0xF ) ;
+               if ( pBuf[13] != ibcc1 || pBuf[14] != ibcc2 ) {
+#ifdef DEBUG
+                       if ( debug >= 2 ) {
+                               printf ( "%s (refclock_jjy.c) : BCC error ( Recv=%02X,%02X / Calc=%02X,%02X)\n", sFunctionName, pBuf[13]&0xFF, pBuf[14]&0xFF, ibcc1, ibcc2 ) ;
+                       }
+#endif
+                               up->lineerror = 1 ;
+                               break ;
+                       }
+
+        }
+
+               rc = sscanf ( pBuf, "%2d%2d%2d%*1d%2d%2d%2d",
+                      &up->year, &up->month, &up->day, &up->hour, &up->minute, &up->second ) ;
+               if ( rc != 6 || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
+                 || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
+#ifdef DEBUG
+               if ( debug >= 2 ) {
+                       printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %02d %02d %02d * %02d %02d %02d ]\n", sFunctionName,
+                                                rc, up->year, up->month, up->day, up->hour, up->minute, up->second ) ;
+               }
+#endif
+                       up->lineerror = 1 ;
+                       break ;
+               }
+
+               up->year += 2000 ;
+
+               if ( up->operationmode == 2 ) {
+
+                       /* A time stamp comes on every 0.5 seccond in the mode 2 of the LT-2000. */
+                       up->msecond = 500 ;
+                       pp->second -- ;
+                       if ( pp->second < 0 ) {
+                               pp->second = 59 ;
+                               pp->minute -- ;
+                               if ( pp->minute < 0 ) {
+                                       pp->minute = 59 ;
+                                       pp->hour -- ;
+                                       if ( pp->hour < 0 ) {
+                                               pp->hour = 23 ;
+                                               pp->day -- ;
+                                               if ( pp->day < 1 ) {
+                                                       pp->year -- ;
+                                                       pp->day  = ymd2yd ( pp->year, 12, 31 ) ;
+                                               }
+                                       }
+                               }
+                       }
+
+                       /* Switch from mode 2 to mode 1 in order to restraint of useless time stamp. */
+#ifdef DEBUG
+                       if ( debug ) {
+                               printf ( "%s (refclock_jjy.c) : send '#'\n", sFunctionName ) ;
+                       }
+#endif
+                       if ( write ( pp->io.fd, "#",1 ) != 1  ) {
+                               refclock_report ( peer, CEVNT_FAULT ) ;
+                       }
+
+               }
+
+               break ;
+
+       default : /*  Unexpected reply */
+
+#ifdef DEBUG
+               if ( debug ) {
+                       printf ( "%s (refclock_jjy.c) : send '#'\n", sFunctionName ) ;
+               }
+#endif
+               if ( write ( pp->io.fd, "#",1 ) != 1  ) {
+                       refclock_report ( peer, CEVNT_FAULT ) ;
+               }
+
+               up->lineerror = 1 ;
+               break ;
+
+       }
+
+       return 1 ;
+
+}
+
+/**************************************************************************************************/
+
+static int
+jjy_receive_citizentic_jjy200 ( struct recvbuf *rbufp )
+{
+
+    static  char    *sFunctionName = "jjy_receive_citizentic_jjy200" ;
+
+    struct jjyunit      *up ;
+    struct refclockproc *pp ;
+    struct peer         *peer;
+
+    char    *pBuf ;
+    int     iLen ;
+    int     rc ;
+    char    cApostrophe, sStatus[3] ;
+    int     iWeekday ;
+
+    /*
+     * Initialize pointers and read the timecode and timestamp
+     */
+    peer = (struct peer *) rbufp->recv_srcclock ;
+    pp = peer->procptr ;
+    up = (struct jjyunit *) pp->unitptr ;
+
+    if ( up->linediscipline == LDISC_RAW ) {
+        pBuf = up->rawbuf ;
+        iLen = up->charcount ;
+    } else {
+        pBuf = pp->a_lastcode ;
+        iLen = pp->lencode ;
+    }
+
+    /*
+     * JJY-200 sends a timestamp every second.
+     * So, a timestamp is ignored unless it is right after polled.
+     */
+    if ( ! up->bPollFlag ) return 0 ;
+
+    switch ( up->linecount ) {
+
+    case 1 : /* 'XX YY/MM/DD W HH:MM:SS<CR> */
+
+        if ( iLen != 23 ) {
+#ifdef DEBUG
+            if ( debug >= 2 ) {
+                printf ( "%s (refclock_jjy.c) : Reply length error ( iLen=%d )\n", sFunctionName, iLen ) ;
+            }
+#endif
+            up->lineerror = 1 ;
+            break ;
+        }
+
+        rc = sscanf ( pBuf, "%c%2s %2d/%2d/%2d %1d %2d:%2d:%2d",
+                      &cApostrophe, sStatus, 
+                      &up->year, &up->month, &up->day, &iWeekday, &up->hour, &up->minute, &up->second ) ;
+        sStatus[2] = 0 ;
+        if ( rc != 9 || cApostrophe != '\'' || strcmp( sStatus, "OK" ) != 0
+          || up->month < 1 || up->month > 12 || up->day < 1 || up->day > 31
+          || iWeekday > 6
+          || up->hour > 23 || up->minute > 59 || up->second > 60 ) {
+#ifdef DEBUG
+            if ( debug >= 2 ) {
+                printf ( "%s (refclock_jjy.c) : Time error (rc=%d) [ %c %2s %02d %02d %02d %d %02d %02d %02d ]\n", sFunctionName,
+                         rc, cApostrophe, sStatus, up->year, up->month, up->day, iWeekday, up->hour, up->minute, up->second ) ;
+            }
+#endif
+            up->lineerror = 1 ;
+            break ;
+        }
+
+        up->year += 2000 ;
+        up->msecond = 0 ;
+
+        break ;
+
+    default : /* Unexpected reply */
+
+        up->lineerror = 1 ;
+        break ;
+
+    }
+
+    return 1 ;
+
+}
+
+/**************************************************************************************************/
+/*  jjy_poll - called by the transmit procedure                                                   */
+/**************************************************************************************************/
+static void
+jjy_poll ( int unit, struct peer *peer )
+{
+
+       struct jjyunit      *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct jjyunit *) pp->unitptr ;
+
+       if ( pp->polls > 0  &&  up->linecount == 0 ) {
+               /*
+                * No reply for last command
+                */
+               refclock_report ( peer, CEVNT_TIMEOUT ) ;
+       }
+
+#ifdef DEBUG
+       if ( debug ) {
+               printf ( "jjy_poll (refclock_jjy.c) : %ld\n", pp->polls ) ;
+       }
+#endif
+
+       pp->polls ++ ;
+
+    up->bPollFlag = 1 ;
+       up->linecount = 0 ;
+       up->lineerror = 0 ;
+       up->charcount = 0 ;
+
+       switch ( up->unittype ) {
+       
+       case UNITTYPE_TRISTATE_JJY01 :
+               jjy_poll_tristate_jjy01  ( unit, peer ) ;
+               break ;
+
+       case UNITTYPE_CDEX_JST2000 :
+               jjy_poll_cdex_jst2000 ( unit, peer ) ;
+               break ;
+
+       case UNITTYPE_ECHOKEISOKUKI_LT2000 :
+               jjy_poll_echokeisokuki_lt2000 ( unit, peer ) ;
+               break ;
+
+    case UNITTYPE_CITIZENTIC_JJY200 :
+        jjy_poll_citizentic_jjy200 ( unit, peer ) ;
+        break ;
+
+       default :
+               break ;
+
+       }
+
+}
+
+/**************************************************************************************************/
+
+static void
+jjy_poll_tristate_jjy01  ( int unit, struct peer *peer )
+{
+
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+
+       /*
+        * Send "date<CR><LF>" command
+        */
+
+#ifdef DEBUG
+       if ( debug ) {
+               printf ( "jjy_poll_tristate_jjy01 (refclock_jjy.c) : send 'date<CR><LF>'\n" ) ;
+       }
+#endif
+
+       if ( write ( pp->io.fd, "date\r\n",6 ) != 6  ) {
+               refclock_report ( peer, CEVNT_FAULT ) ;
+       }
+
+}
+
+/**************************************************************************************************/
+
+static void
+jjy_poll_cdex_jst2000 ( int unit, struct peer *peer )
+{
+
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+
+       /*
+        * Send "<ENQ>1J<ETX>" command
+        */
+
+#ifdef DEBUG
+       if ( debug ) {
+               printf ( "jjy_poll_cdex_jst2000 (refclock_jjy.c) : send '<ENQ>1J<ETX>'\n" ) ;
+       }
+#endif
+
+       if ( write ( pp->io.fd, "\0051J\003", 4 ) != 4  ) {
+               refclock_report ( peer, CEVNT_FAULT ) ;
+       }
+
+}
+
+/**************************************************************************************************/
+
+static void
+jjy_poll_echokeisokuki_lt2000 ( int unit, struct peer *peer )
+{
+
+       struct jjyunit      *up;
+       struct refclockproc *pp;
+
+       char    sCmd[2] ;
+
+       pp = peer->procptr;
+       up = (struct jjyunit *) pp->unitptr ;
+
+       /*
+        * Send "T" or "C" command
+        */
+
+       switch ( up->operationmode ) {
+       case 1 : sCmd[0] = 'T' ; break ;
+       case 2 : sCmd[0] = 'C' ; break ;
+       }
+       sCmd[1] = 0 ;
+
+#ifdef DEBUG
+       if ( debug ) {
+               printf ( "jjy_poll_echokeisokuki_lt2000 (refclock_jjy.c) : send '%s'\n", sCmd ) ;
+       }
+#endif
+
+       if ( write ( pp->io.fd, sCmd, 1 ) != 1  ) {
+               refclock_report ( peer, CEVNT_FAULT ) ;
+       }
+
+}
+
+/**************************************************************************************************/
+
+static void
+jjy_poll_citizentic_jjy200 ( int unit, struct peer *peer )
+{
+
+    /* Do nothing ( up->bPollFlag is set by the jjy_poll ) */
+
+}
+
+#else
+int refclock_jjy_bs ;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_jupiter.c b/ntpd/refclock_jupiter.c
new file mode 100644 (file)
index 0000000..c10d9fa
--- /dev/null
@@ -0,0 +1,1137 @@
+/*
+ * Copyright (c) 1997, 1998, 2003
+ *     The Regents of the University of California.  All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 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, Lawrence Berkeley Laboratory.
+ * 4. The name of the University may not 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.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_JUPITER) && defined(HAVE_PPSAPI)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include "jupiter.h"
+
+#ifdef HAVE_PPSAPI
+# include "ppsapi_timepps.h"
+#endif
+
+#ifdef XNTP_BIG_ENDIAN
+#define getshort(s) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff))
+#define putshort(s) ((((s) & 0xff) << 8) | (((s) >> 8) & 0xff))
+#else
+#define getshort(s) (s)
+#define putshort(s) (s)
+#endif
+
+/* XXX */
+#ifdef sun
+char *strerror(int);
+#endif
+
+/*
+ * This driver supports the Rockwell Jupiter GPS Receiver board
+ * adapted to precision timing applications.  It requires the
+ * ppsclock line discipline or streams module described in the
+ * Line Disciplines and Streams Drivers page. It also requires a
+ * gadget box and 1-PPS level converter, such as described in the
+ * Pulse-per-second (PPS) Signal Interfacing page.
+ *
+ * It may work (with minor modifications) with other Rockwell GPS
+ * receivers such as the CityTracker.
+ */
+
+/*
+ * GPS Definitions
+ */
+#define        DEVICE          "/dev/gps%d"    /* device name and unit */
+#define        SPEED232        B9600           /* baud */
+
+/*
+ * Radio interface parameters
+ */
+#define        PRECISION       (-18)   /* precision assumed (about 4 us) */
+#define        REFID   "GPS\0"         /* reference id */
+#define        DESCRIPTION     "Rockwell Jupiter GPS Receiver" /* who we are */
+#define        DEFFUDGETIME    0       /* default fudge time (ms) */
+
+/* Unix timestamp for the GPS epoch: January 6, 1980 */
+#define GPS_EPOCH 315964800
+
+/* Double short to unsigned int */
+#define DS2UI(p) ((getshort((p)[1]) << 16) | getshort((p)[0]))
+
+/* Double short to signed int */
+#define DS2I(p) ((getshort((p)[1]) << 16) | getshort((p)[0]))
+
+/* One week's worth of seconds */
+#define WEEKSECS (7 * 24 * 60 * 60)
+
+/*
+ * Jupiter unit control structure.
+ */
+struct instance {
+       struct peer *peer;              /* peer */
+       u_int  pollcnt;                 /* poll message counter */
+       u_int  polled;                  /* Hand in a time sample? */
+#ifdef HAVE_PPSAPI
+       pps_params_t pps_params;        /* pps parameters */
+       pps_info_t pps_info;            /* last pps data */
+       pps_handle_t pps_handle;        /* pps handle */
+       u_int assert;                   /* pps edge to use */
+       u_int hardpps;                  /* enable kernel mode */
+       struct timespec ts;             /* last timestamp */
+#endif
+       l_fp limit;
+       u_int gpos_gweek;               /* Current GPOS GPS week number */
+       u_int gpos_sweek;               /* Current GPOS GPS seconds into week */
+       u_int gweek;                    /* current GPS week number */
+       u_int32 lastsweek;              /* last seconds into GPS week */
+       time_t timecode;                /* current ntp timecode */
+       u_int32 stime;                  /* used to detect firmware bug */
+       int wantid;                     /* don't reconfig on channel id msg */
+       u_int  moving;                  /* mobile platform? */
+       u_char sloppyclockflag;         /* fudge flags */
+       u_short sbuf[512];              /* local input buffer */
+       int ssize;                      /* space used in sbuf */
+};
+
+/*
+ * Function prototypes
+ */
+static void    jupiter_canmsg  P((struct instance *, u_int));
+static u_short jupiter_cksum   P((u_short *, u_int));
+static int     jupiter_config  P((struct instance *));
+static void    jupiter_debug   P((struct peer *, char *, char *, ...))
+    __attribute__ ((format (printf, 3, 4)));
+static char *  jupiter_parse_t P((struct instance *, u_short *));
+static char *  jupiter_parse_gpos      P((struct instance *, u_short *));
+static void    jupiter_platform        P((struct instance *, u_int));
+static void    jupiter_poll    P((int, struct peer *));
+static void    jupiter_control P((int, struct refclockstat *, struct
+                                   refclockstat *, struct peer *));
+#ifdef HAVE_PPSAPI
+static int     jupiter_ppsapi  P((struct instance *));
+static int     jupiter_pps     P((struct instance *));
+#endif /* HAVE_PPSAPI */
+static int     jupiter_recv    P((struct instance *));
+static void    jupiter_receive P((struct recvbuf *rbufp));
+static void    jupiter_reqmsg  P((struct instance *, u_int, u_int));
+static void    jupiter_reqonemsg       P((struct instance *, u_int));
+static char *  jupiter_send    P((struct instance *, struct jheader *));
+static void    jupiter_shutdown        P((int, struct peer *));
+static int     jupiter_start   P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_jupiter = {
+       jupiter_start,          /* start up driver */
+       jupiter_shutdown,       /* shut down driver */
+       jupiter_poll,           /* transmit poll message */
+       jupiter_control,        /* (clock control) */
+       noentry,                /* (clock init) */
+       noentry,                /* (clock buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+/*
+ * jupiter_start - open the devices and initialize data for processing
+ */
+static int
+jupiter_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       struct instance *instance;
+       int fd = -1;
+       char gpsdev[20];
+
+       /*
+        * Open serial port
+        */
+       (void)sprintf(gpsdev, DEVICE, unit);
+       fd = refclock_open(gpsdev, SPEED232, LDISC_RAW);
+       if (fd == 0) {
+               jupiter_debug(peer, "jupiter_start", "open %s: %s",
+                   gpsdev, strerror(errno));
+               return (0);
+       }
+
+       /* Allocate unit structure */
+       if ((instance = (struct instance *)
+           emalloc(sizeof(struct instance))) == NULL) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)instance, 0, sizeof(struct instance));
+       instance->peer = peer;
+       pp = peer->procptr;
+       pp->io.clock_recv = jupiter_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(instance);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)instance;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+
+#ifdef HAVE_PPSAPI
+       instance->assert = 1;
+       instance->hardpps = 0;
+       /*
+        * Start the PPSAPI interface if it is there. Default to use
+        * the assert edge and do not enable the kernel hardpps.
+        */
+       if (time_pps_create(fd, &instance->pps_handle) < 0) {
+               instance->pps_handle = 0;
+               msyslog(LOG_ERR,
+                       "refclock_jupiter: time_pps_create failed: %m");
+       }
+       else if (!jupiter_ppsapi(instance))
+               goto clean_up;
+#endif /* HAVE_PPSAPI */
+
+       /* Ensure the receiver is properly configured */
+       if (!jupiter_config(instance))
+               goto clean_up;
+
+       return (1);
+
+clean_up:
+       jupiter_shutdown(unit, peer);
+       pp->unitptr = 0;
+       return (0);
+}
+
+/*
+ * jupiter_shutdown - shut down the clock
+ */
+static void
+jupiter_shutdown(int unit, struct peer *peer)
+{
+       struct instance *instance;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       instance = (struct instance *)pp->unitptr;
+       if (!instance)
+               return;
+
+#ifdef HAVE_PPSAPI
+       if (instance->pps_handle) {
+               time_pps_destroy(instance->pps_handle);
+               instance->pps_handle = 0;
+       }
+#endif /* HAVE_PPSAPI */
+
+       io_closeclock(&pp->io);
+       free(instance);
+}
+
+/*
+ * jupiter_config - Configure the receiver
+ */
+static int
+jupiter_config(struct instance *instance)
+{
+       jupiter_debug(instance->peer, "jupiter_config", "init receiver");
+
+       /*
+        * Initialize the unit variables
+        */
+       instance->sloppyclockflag = instance->peer->procptr->sloppyclockflag;
+       instance->moving = !!(instance->sloppyclockflag & CLK_FLAG2);
+       if (instance->moving)
+               jupiter_debug(instance->peer, "jupiter_config",
+                       "mobile platform");
+
+       instance->pollcnt     = 2;
+       instance->polled      = 0;
+       instance->gpos_gweek = 0;
+       instance->gpos_sweek = 0;
+       instance->gweek = 0;
+       instance->lastsweek = 2 * WEEKSECS;
+       instance->timecode = 0;
+       instance->stime = 0;
+       instance->ssize = 0;
+
+       /* Stop outputting all messages */
+       jupiter_canmsg(instance, JUPITER_ALL);
+
+       /* Request the receiver id so we can syslog the firmware version */
+       jupiter_reqonemsg(instance, JUPITER_O_ID);
+
+       /* Flag that this the id was requested (so we don't get called again) */
+       instance->wantid = 1;
+
+       /* Request perodic time mark pulse messages */
+       jupiter_reqmsg(instance, JUPITER_O_PULSE, 1);
+
+       /* Request perodic geodetic position status */
+       jupiter_reqmsg(instance, JUPITER_O_GPOS, 1);
+
+       /* Set application platform type */
+       if (instance->moving)
+               jupiter_platform(instance, JUPITER_I_PLAT_MED);
+       else
+               jupiter_platform(instance, JUPITER_I_PLAT_LOW);
+
+       return (1);
+}
+
+#ifdef HAVE_PPSAPI
+/*
+ * Initialize PPSAPI
+ */
+int
+jupiter_ppsapi(
+       struct instance *instance       /* unit structure pointer */
+       )
+{
+       int capability;
+
+       if (time_pps_getcap(instance->pps_handle, &capability) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_jupiter: time_pps_getcap failed: %m");
+               return (0);
+       }
+       memset(&instance->pps_params, 0, sizeof(pps_params_t));
+       if (!instance->assert)
+               instance->pps_params.mode = capability & PPS_CAPTURECLEAR;
+       else
+               instance->pps_params.mode = capability & PPS_CAPTUREASSERT;
+       if (!(instance->pps_params.mode & (PPS_CAPTUREASSERT | PPS_CAPTURECLEAR))) {
+               msyslog(LOG_ERR,
+                   "refclock_jupiter: invalid capture edge %d",
+                   instance->assert);
+               return (0);
+       }
+       instance->pps_params.mode |= PPS_TSFMT_TSPEC;
+       if (time_pps_setparams(instance->pps_handle, &instance->pps_params) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_jupiter: time_pps_setparams failed: %m");
+               return (0);
+       }
+       if (instance->hardpps) {
+               if (time_pps_kcbind(instance->pps_handle, PPS_KC_HARDPPS,
+                                   instance->pps_params.mode & ~PPS_TSFMT_TSPEC,
+                                   PPS_TSFMT_TSPEC) < 0) {
+                       msyslog(LOG_ERR,
+                           "refclock_jupiter: time_pps_kcbind failed: %m");
+                       return (0);
+               }
+               pps_enable = 1;
+       }
+/*     instance->peer->precision = PPS_PRECISION; */
+
+#if DEBUG
+       if (debug) {
+               time_pps_getparams(instance->pps_handle, &instance->pps_params);
+               jupiter_debug(instance->peer, "refclock_jupiter",
+                       "pps capability 0x%x version %d mode 0x%x kern %d",
+                       capability, instance->pps_params.api_version,
+                       instance->pps_params.mode, instance->hardpps);
+       }
+#endif
+
+       return (1);
+}
+
+/*
+ * Get PPSAPI timestamps.
+ *
+ * Return 0 on failure and 1 on success.
+ */
+static int
+jupiter_pps(struct instance *instance)
+{
+       pps_info_t pps_info;
+       struct timespec timeout, ts;
+       double dtemp;
+       l_fp tstmp;
+
+       /*
+        * Convert the timespec nanoseconds field to ntp l_fp units.
+        */ 
+       if (instance->pps_handle == 0)
+               return 1;
+       timeout.tv_sec = 0;
+       timeout.tv_nsec = 0;
+       memcpy(&pps_info, &instance->pps_info, sizeof(pps_info_t));
+       if (time_pps_fetch(instance->pps_handle, PPS_TSFMT_TSPEC, &instance->pps_info,
+           &timeout) < 0)
+               return 1;
+       if (instance->pps_params.mode & PPS_CAPTUREASSERT) {
+               if (pps_info.assert_sequence ==
+                   instance->pps_info.assert_sequence)
+                       return 1;
+               ts = instance->pps_info.assert_timestamp;
+       } else if (instance->pps_params.mode & PPS_CAPTURECLEAR) {
+               if (pps_info.clear_sequence ==
+                   instance->pps_info.clear_sequence)
+                       return 1;
+               ts = instance->pps_info.clear_timestamp;
+       } else {
+               return 1;
+       }
+       if ((instance->ts.tv_sec == ts.tv_sec) && (instance->ts.tv_nsec == ts.tv_nsec))
+               return 1;
+       instance->ts = ts;
+
+       tstmp.l_ui = ts.tv_sec + JAN_1970;
+       dtemp = ts.tv_nsec * FRAC / 1e9;
+       tstmp.l_uf = (u_int32)dtemp;
+       instance->peer->procptr->lastrec = tstmp;
+       return 0;
+}
+#endif /* HAVE_PPSAPI */
+
+/*
+ * jupiter_poll - jupiter watchdog routine
+ */
+static void
+jupiter_poll(int unit, struct peer *peer)
+{
+       struct instance *instance;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       instance = (struct instance *)pp->unitptr;
+
+       /*
+        * You don't need to poll this clock.  It puts out timecodes
+        * once per second.  If asked for a timestamp, take note.
+        * The next time a timecode comes in, it will be fed back.
+        */
+
+       /*
+        * If we haven't had a response in a while, reset the receiver.
+        */
+       if (instance->pollcnt > 0) {
+               instance->pollcnt--;
+       } else {
+               refclock_report(peer, CEVNT_TIMEOUT);
+
+               /* Request the receiver id to trigger a reconfig */
+               jupiter_reqonemsg(instance, JUPITER_O_ID);
+               instance->wantid = 0;
+       }
+
+       /*
+        * polled every 64 seconds. Ask jupiter_receive to hand in
+        * a timestamp.
+        */
+       instance->polled = 1;
+       pp->polls++;
+}
+
+/*
+ * jupiter_control - fudge control
+ */
+static void
+jupiter_control(
+       int unit,               /* unit (not used) */
+       struct refclockstat *in, /* input parameters (not used) */
+       struct refclockstat *out, /* output parameters (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct instance *instance;
+       u_char sloppyclockflag;
+
+       pp = peer->procptr;
+       instance = (struct instance *)pp->unitptr;
+
+       DTOLFP(pp->fudgetime2, &instance->limit);
+       /* Force positive value. */
+       if (L_ISNEG(&instance->limit))
+               L_NEG(&instance->limit);
+
+#ifdef HAVE_PPSAPI
+       instance->assert = !(pp->sloppyclockflag & CLK_FLAG3);
+       jupiter_ppsapi(instance);
+#endif /* HAVE_PPSAPI */
+
+       sloppyclockflag = instance->sloppyclockflag;
+       instance->sloppyclockflag = pp->sloppyclockflag;
+       if ((instance->sloppyclockflag & CLK_FLAG2) !=
+           (sloppyclockflag & CLK_FLAG2)) {
+               jupiter_debug(peer,
+                   "jupiter_control",
+                   "mode switch: reset receiver");
+               jupiter_config(instance);
+               return;
+       }
+}
+
+/*
+ * jupiter_receive - receive gps data
+ * Gag me!
+ */
+static void
+jupiter_receive(struct recvbuf *rbufp)
+{
+       int bpcnt, cc, size, ppsret;
+       time_t last_timecode;
+       u_int32 laststime;
+       char *cp;
+       u_char *bp;
+       u_short *sp;
+       struct jid *ip;
+       struct jheader *hp;
+       struct peer *peer;
+       struct refclockproc *pp;
+       struct instance *instance;
+       l_fp tstamp;
+
+       /* Initialize pointers and read the timecode and timestamp */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       instance = (struct instance *)pp->unitptr;
+
+       bp = (u_char *)rbufp->recv_buffer;
+       bpcnt = rbufp->recv_length;
+
+       /* This shouldn't happen */
+       if (bpcnt > sizeof(instance->sbuf) - instance->ssize)
+               bpcnt = sizeof(instance->sbuf) - instance->ssize;
+
+       /* Append to input buffer */
+       memcpy((u_char *)instance->sbuf + instance->ssize, bp, bpcnt);
+       instance->ssize += bpcnt;
+
+       /* While there's at least a header and we parse an intact message */
+       while (instance->ssize > sizeof(*hp) && (cc = jupiter_recv(instance)) > 0) {
+               instance->pollcnt = 2;
+
+               tstamp = rbufp->recv_time;
+               hp = (struct jheader *)instance->sbuf;
+               sp = (u_short *)(hp + 1);
+               size = cc - sizeof(*hp);
+               switch (getshort(hp->id)) {
+
+               case JUPITER_O_PULSE:
+                       if (size != sizeof(struct jpulse)) {
+                               jupiter_debug(peer,
+                                   "jupiter_receive", "pulse: len %d != %u",
+                                   size, (int)sizeof(struct jpulse));
+                               refclock_report(peer, CEVNT_BADREPLY);
+                               break;
+                       }
+
+                       /*
+                        * There appears to be a firmware bug related
+                        * to the pulse message; in addition to the one
+                        * per second messages, we get an extra pulse
+                        * message once an hour (on the anniversary of
+                        * the cold start). It seems to come 200 ms
+                        * after the one requested. So if we've seen a
+                        * pulse message in the last 210 ms, we skip
+                        * this one.
+                        */
+                       laststime = instance->stime;
+                       instance->stime = DS2UI(((struct jpulse *)sp)->stime);
+                       if (laststime != 0 && instance->stime - laststime <= 21) {
+                               jupiter_debug(peer, "jupiter_receive", 
+                               "avoided firmware bug (stime %.2f, laststime %.2f)",
+                               (double)instance->stime * 0.01, (double)laststime * 0.01);
+                               break;
+                       }
+
+                       /* Retrieve pps timestamp */
+                       ppsret = jupiter_pps(instance);
+
+                       /*
+                        * Add one second if msg received early
+                        * (i.e. before limit, a.k.a. fudgetime2) in
+                        * the second.
+                        */
+                       L_SUB(&tstamp, &pp->lastrec);
+                       if (!L_ISGEQ(&tstamp, &instance->limit))
+                               ++pp->lastrec.l_ui;
+
+                       /* Parse timecode (even when there's no pps) */
+                       last_timecode = instance->timecode;
+                       if ((cp = jupiter_parse_t(instance, sp)) != NULL) {
+                               jupiter_debug(peer,
+                                   "jupiter_receive", "pulse: %s", cp);
+                               break;
+                       }
+
+                       /* Bail if we didn't get a pps timestamp */
+                       if (ppsret)
+                               break;
+
+                       /* Bail if we don't have the last timecode yet */
+                       if (last_timecode == 0)
+                               break;
+
+                       /* Add the new sample to a median filter */
+                       tstamp.l_ui = JAN_1970 + last_timecode;
+                       tstamp.l_uf = 0;
+
+                       refclock_process_offset(pp, tstamp, pp->lastrec, pp->fudgetime1);
+
+                       /*
+                        * The clock will blurt a timecode every second
+                        * but we only want one when polled.  If we
+                        * havn't been polled, bail out.
+                        */
+                       if (!instance->polled)
+                               break;
+                       instance->polled = 0;
+
+                       /*
+                        * It's a live one!  Remember this time.
+                        */
+
+                       pp->lastref = pp->lastrec;
+                       refclock_receive(peer);
+
+                       /*
+                        * If we get here - what we got from the clock is
+                        * OK, so say so
+                        */
+                       refclock_report(peer, CEVNT_NOMINAL);
+
+                       /*
+                        * We have succeeded in answering the poll.
+                        * Turn off the flag and return
+                        */
+                       instance->polled = 0;
+                       break;
+
+               case JUPITER_O_GPOS:
+                       if (size != sizeof(struct jgpos)) {
+                               jupiter_debug(peer,
+                                   "jupiter_receive", "gpos: len %d != %u",
+                                   size, (int)sizeof(struct jgpos));
+                               refclock_report(peer, CEVNT_BADREPLY);
+                               break;
+                       }
+
+                       if ((cp = jupiter_parse_gpos(instance, sp)) != NULL) {
+                               jupiter_debug(peer,
+                                   "jupiter_receive", "gpos: %s", cp);
+                               break;
+                       }
+                       break;
+
+               case JUPITER_O_ID:
+                       if (size != sizeof(struct jid)) {
+                               jupiter_debug(peer,
+                                   "jupiter_receive", "id: len %d != %u",
+                                   size, (int)sizeof(struct jid));
+                               refclock_report(peer, CEVNT_BADREPLY);
+                               break;
+                       }
+                       /*
+                        * If we got this message because the Jupiter
+                        * just powered instance, it needs to be reconfigured.
+                        */
+                       ip = (struct jid *)sp;
+                       jupiter_debug(peer,
+                           "jupiter_receive", "%s chan ver %s, %s (%s)",
+                           ip->chans, ip->vers, ip->date, ip->opts);
+                       msyslog(LOG_DEBUG,
+                           "jupiter_receive: %s chan ver %s, %s (%s)",
+                           ip->chans, ip->vers, ip->date, ip->opts);
+                       if (instance->wantid)
+                               instance->wantid = 0;
+                       else {
+                               jupiter_debug(peer,
+                                   "jupiter_receive", "reset receiver");
+                               jupiter_config(instance);
+                               /*
+                                * Restore since jupiter_config() just
+                                * zeroed it
+                                */
+                               instance->ssize = cc;
+                       }
+                       break;
+
+               default:
+                       jupiter_debug(peer,
+                           "jupiter_receive", "unknown message id %d",
+                           getshort(hp->id));
+                       break;
+               }
+               instance->ssize -= cc;
+               if (instance->ssize < 0) {
+                       fprintf(stderr, "jupiter_recv: negative ssize!\n");
+                       abort();
+               } else if (instance->ssize > 0)
+                       memcpy(instance->sbuf, (u_char *)instance->sbuf + cc, instance->ssize);
+       }
+}
+
+static char *
+jupiter_parse_t(struct instance *instance, u_short *sp)
+{
+       struct tm *tm;
+       char *cp;
+       struct jpulse *jp;
+       u_int32 sweek;
+       time_t last_timecode;
+       u_short flags;
+
+       jp = (struct jpulse *)sp;
+
+       /* The timecode is presented as seconds into the current GPS week */
+       sweek = DS2UI(jp->sweek) % WEEKSECS;
+
+       /*
+        * If we don't know the current GPS week, calculate it from the
+        * current time. (It's too bad they didn't include this
+        * important value in the pulse message). We'd like to pick it
+        * up from one of the other messages like gpos or chan but they
+        * don't appear to be synchronous with time keeping and changes
+        * too soon (something like 10 seconds before the new GPS
+        * week).
+        *
+        * If we already know the current GPS week, increment it when
+        * we wrap into a new week.
+        */
+       if (instance->gweek == 0) {
+               if (!instance->gpos_gweek) {
+                       return ("jupiter_parse_t: Unknown gweek");
+               }
+
+               instance->gweek = instance->gpos_gweek;
+
+               /*
+                * Fix warps. GPOS has GPS time and PULSE has UTC.
+                * Plus, GPOS need not be completely in synch with
+                * the PPS signal.
+                */
+               if (instance->gpos_sweek >= sweek) {
+                       if ((instance->gpos_sweek - sweek) > WEEKSECS / 2)
+                               ++instance->gweek;
+               }
+               else {
+                       if ((sweek - instance->gpos_sweek) > WEEKSECS / 2)
+                               --instance->gweek;
+               }
+       }
+       else if (sweek == 0 && instance->lastsweek == WEEKSECS - 1) {
+               ++instance->gweek;
+               jupiter_debug(instance->peer,
+                   "jupiter_parse_t", "NEW gps week %u", instance->gweek);
+       }
+
+       /*
+        * See if the sweek stayed the same (this happens when there is
+        * no pps pulse).
+        *
+        * Otherwise, look for time warps:
+        *
+        *   - we have stored at least one lastsweek and
+        *   - the sweek didn't increase by one and
+        *   - we didn't wrap to a new GPS week
+        *
+        * Then we warped.
+        */
+       if (instance->lastsweek == sweek)
+               jupiter_debug(instance->peer,
+                   "jupiter_parse_t", "gps sweek not incrementing (%d)",
+                   sweek);
+       else if (instance->lastsweek != 2 * WEEKSECS &&
+           instance->lastsweek + 1 != sweek &&
+           !(sweek == 0 && instance->lastsweek == WEEKSECS - 1))
+               jupiter_debug(instance->peer,
+                   "jupiter_parse_t", "gps sweek jumped (was %d, now %d)",
+                   instance->lastsweek, sweek);
+       instance->lastsweek = sweek;
+
+       /* This timecode describes next pulse */
+       last_timecode = instance->timecode;
+       instance->timecode =
+           GPS_EPOCH + (instance->gweek * WEEKSECS) + sweek;
+
+       if (last_timecode == 0)
+               /* XXX debugging */
+               jupiter_debug(instance->peer,
+                   "jupiter_parse_t", "UTC <none> (gweek/sweek %u/%u)",
+                   instance->gweek, sweek);
+       else {
+               /* XXX debugging */
+               tm = gmtime(&last_timecode);
+               cp = asctime(tm);
+
+               jupiter_debug(instance->peer,
+                   "jupiter_parse_t", "UTC %.24s (gweek/sweek %u/%u)",
+                   cp, instance->gweek, sweek);
+
+               /* Billboard last_timecode (which is now the current time) */
+               instance->peer->procptr->year   = tm->tm_year + 1900;
+               instance->peer->procptr->day    = tm->tm_yday + 1;
+               instance->peer->procptr->hour   = tm->tm_hour;
+               instance->peer->procptr->minute = tm->tm_min;
+               instance->peer->procptr->second = tm->tm_sec;
+       }
+
+       flags = getshort(jp->flags);
+
+       /* Toss if not designated "valid" by the gps */
+       if ((flags & JUPITER_O_PULSE_VALID) == 0) {
+               refclock_report(instance->peer, CEVNT_BADTIME);
+               return ("time mark not valid");
+       }
+
+       /* We better be sync'ed to UTC... */
+       if ((flags & JUPITER_O_PULSE_UTC) == 0) {
+               refclock_report(instance->peer, CEVNT_BADTIME);
+               return ("time mark not sync'ed to UTC");
+       }
+
+       return (NULL);
+}
+
+static char *
+jupiter_parse_gpos(struct instance *instance, u_short *sp)
+{
+       struct jgpos *jg;
+       time_t t;
+       struct tm *tm;
+       char *cp;
+
+       jg = (struct jgpos *)sp;
+
+       if (jg->navval != 0) {
+               /*
+                * Solution not valid. Use caution and refuse
+                * to determine GPS week from this message.
+                */
+               instance->gpos_gweek = 0;
+               instance->gpos_sweek = 0;
+               return ("Navigation solution not valid");
+       }
+
+       instance->gpos_gweek = jg->gweek;
+       instance->gpos_sweek = DS2UI(jg->sweek);
+       while(instance->gpos_sweek >= WEEKSECS) {
+               instance->gpos_sweek -= WEEKSECS;
+               ++instance->gpos_gweek;
+       }
+       instance->gweek = 0;
+
+       t = GPS_EPOCH + (instance->gpos_gweek * WEEKSECS) + instance->gpos_sweek;
+       tm = gmtime(&t);
+       cp = asctime(tm);
+
+       jupiter_debug(instance->peer,
+               "jupiter_parse_g", "GPS %.24s (gweek/sweek %u/%u)",
+               cp, instance->gpos_gweek, instance->gpos_sweek);
+       return (NULL);
+}
+
+/*
+ * jupiter_debug - print debug messages
+ */
+#if defined(__STDC__) || defined(SYS_WINNT)
+static void
+jupiter_debug(struct peer *peer, char *function, char *fmt, ...)
+#else
+static void
+jupiter_debug(peer, function, fmt, va_alist)
+       struct peer *peer;
+       char *function;
+       char *fmt;
+#endif /* __STDC__ */
+{
+       char buffer[200];
+       va_list ap;
+
+#if defined(__STDC__) || defined(SYS_WINNT)
+       va_start(ap, fmt);
+#else
+       va_start(ap);
+#endif /* __STDC__ */
+       /*
+        * Print debug message to stdout
+        * In the future, we may want to get get more creative...
+        */
+       vsnprintf(buffer, sizeof(buffer), fmt, ap);
+       record_clock_stats(&(peer->srcadr), buffer);
+#ifdef DEBUG
+       if (debug) {
+               fprintf(stdout, "%s: ", function);
+               fprintf(stdout, buffer);
+               fprintf(stdout, "\n");
+               fflush(stdout);
+       }
+#endif
+
+       va_end(ap);
+}
+
+/* Checksum and transmit a message to the Jupiter */
+static char *
+jupiter_send(struct instance *instance, struct jheader *hp)
+{
+       u_int len, size;
+       int cc;
+       u_short *sp;
+       static char errstr[132];
+
+       size = sizeof(*hp);
+       hp->hsum = putshort(jupiter_cksum((u_short *)hp,
+           (size / sizeof(u_short)) - 1));
+       len = getshort(hp->len);
+       if (len > 0) {
+               sp = (u_short *)(hp + 1);
+               sp[len] = putshort(jupiter_cksum(sp, len));
+               size += (len + 1) * sizeof(u_short);
+       }
+
+       if ((cc = write(instance->peer->procptr->io.fd, (char *)hp, size)) < 0) {
+               (void)sprintf(errstr, "write: %s", strerror(errno));
+               return (errstr);
+       } else if (cc != size) {
+               (void)sprintf(errstr, "short write (%d != %d)", cc, size);
+               return (errstr);
+       }
+       return (NULL);
+}
+
+/* Request periodic message output */
+static struct {
+       struct jheader jheader;
+       struct jrequest jrequest;
+} reqmsg = {
+       { putshort(JUPITER_SYNC), 0,
+           putshort((sizeof(struct jrequest) / sizeof(u_short)) - 1),
+           0, JUPITER_FLAG_REQUEST | JUPITER_FLAG_NAK |
+           JUPITER_FLAG_CONN | JUPITER_FLAG_LOG, 0 },
+       { 0, 0, 0, 0 }
+};
+
+/* An interval of zero means to output on trigger */
+static void
+jupiter_reqmsg(struct instance *instance, u_int id,
+    u_int interval)
+{
+       struct jheader *hp;
+       struct jrequest *rp;
+       char *cp;
+
+       hp = &reqmsg.jheader;
+       hp->id = putshort(id);
+       rp = &reqmsg.jrequest;
+       rp->trigger = putshort(interval == 0);
+       rp->interval = putshort(interval);
+       if ((cp = jupiter_send(instance, hp)) != NULL)
+               jupiter_debug(instance->peer, "jupiter_reqmsg", "%u: %s", id, cp);
+}
+
+/* Cancel periodic message output */
+static struct jheader canmsg = {
+       putshort(JUPITER_SYNC), 0, 0, 0,
+       JUPITER_FLAG_REQUEST | JUPITER_FLAG_NAK | JUPITER_FLAG_DISC,
+       0
+};
+
+static void
+jupiter_canmsg(struct instance *instance, u_int id)
+{
+       struct jheader *hp;
+       char *cp;
+
+       hp = &canmsg;
+       hp->id = putshort(id);
+       if ((cp = jupiter_send(instance, hp)) != NULL)
+               jupiter_debug(instance->peer, "jupiter_canmsg", "%u: %s", id, cp);
+}
+
+/* Request a single message output */
+static struct jheader reqonemsg = {
+       putshort(JUPITER_SYNC), 0, 0, 0,
+       JUPITER_FLAG_REQUEST | JUPITER_FLAG_NAK | JUPITER_FLAG_QUERY,
+       0
+};
+
+static void
+jupiter_reqonemsg(struct instance *instance, u_int id)
+{
+       struct jheader *hp;
+       char *cp;
+
+       hp = &reqonemsg;
+       hp->id = putshort(id);
+       if ((cp = jupiter_send(instance, hp)) != NULL)
+               jupiter_debug(instance->peer, "jupiter_reqonemsg", "%u: %s", id, cp);
+}
+
+/* Set the platform dynamics */
+static struct {
+       struct jheader jheader;
+       struct jplat jplat;
+} platmsg = {
+       { putshort(JUPITER_SYNC), putshort(JUPITER_I_PLAT),
+           putshort((sizeof(struct jplat) / sizeof(u_short)) - 1), 0,
+           JUPITER_FLAG_REQUEST | JUPITER_FLAG_NAK, 0 },
+       { 0, 0, 0 }
+};
+
+static void
+jupiter_platform(struct instance *instance, u_int platform)
+{
+       struct jheader *hp;
+       struct jplat *pp;
+       char *cp;
+
+       hp = &platmsg.jheader;
+       pp = &platmsg.jplat;
+       pp->platform = putshort(platform);
+       if ((cp = jupiter_send(instance, hp)) != NULL)
+               jupiter_debug(instance->peer, "jupiter_platform", "%u: %s", platform, cp);
+}
+
+/* Checksum "len" shorts */
+static u_short
+jupiter_cksum(u_short *sp, u_int len)
+{
+       u_short sum, x;
+
+       sum = 0;
+       while (len-- > 0) {
+               x = *sp++;
+               sum += getshort(x);
+       }
+       return (~sum + 1);
+}
+
+/* Return the size of the next message (or zero if we don't have it all yet) */
+static int
+jupiter_recv(struct instance *instance)
+{
+       int n, len, size, cc;
+       struct jheader *hp;
+       u_char *bp;
+       u_short *sp;
+
+       /* Must have at least a header's worth */
+       cc = sizeof(*hp);
+       size = instance->ssize;
+       if (size < cc)
+               return (0);
+
+       /* Search for the sync short if missing */
+       sp = instance->sbuf;
+       hp = (struct jheader *)sp;
+       if (getshort(hp->sync) != JUPITER_SYNC) {
+               /* Wasn't at the front, sync up */
+               jupiter_debug(instance->peer, "jupiter_recv", "syncing");
+               bp = (u_char *)sp;
+               n = size;
+               while (n >= 2) {
+                       if (bp[0] != (JUPITER_SYNC & 0xff)) {
+                               /*
+                               jupiter_debug(instance->peer, "{0x%x}", bp[0]);
+                               */
+                               ++bp;
+                               --n;
+                               continue;
+                       }
+                       if (bp[1] == ((JUPITER_SYNC >> 8) & 0xff))
+                               break;
+                       /*
+                       jupiter_debug(instance->peer, "{0x%x 0x%x}", bp[0], bp[1]);
+                       */
+                       bp += 2;
+                       n -= 2;
+               }
+               /*
+               jupiter_debug(instance->peer, "\n");
+               */
+               /* Shuffle data to front of input buffer */
+               if (n > 0)
+                       memcpy(sp, bp, n);
+               size = n;
+               instance->ssize = size;
+               if (size < cc || hp->sync != JUPITER_SYNC)
+                       return (0);
+       }
+
+       if (jupiter_cksum(sp, (cc / sizeof(u_short) - 1)) !=
+           getshort(hp->hsum)) {
+           jupiter_debug(instance->peer, "jupiter_recv", "bad header checksum!");
+               /* This is drastic but checksum errors should be rare */
+               instance->ssize = 0;
+               return (0);
+       }
+
+       /* Check for a payload */
+       len = getshort(hp->len);
+       if (len > 0) {
+               n = (len + 1) * sizeof(u_short);
+               /* Not enough data yet */
+               if (size < cc + n)
+                       return (0);
+
+               /* Check payload checksum */
+               sp = (u_short *)(hp + 1);
+               if (jupiter_cksum(sp, len) != getshort(sp[len])) {
+                       jupiter_debug(instance->peer,
+                           "jupiter_recv", "bad payload checksum!");
+                       /* This is drastic but checksum errors should be rare */
+                       instance->ssize = 0;
+                       return (0);
+               }
+               cc += n;
+       }
+       return (cc);
+}
+
+#else /* not (REFCLOCK && CLOCK_JUPITER && HAVE_PPSAPI) */
+int refclock_jupiter_bs;
+#endif /* not (REFCLOCK && CLOCK_JUPITER && HAVE_PPSAPI) */
diff --git a/ntpd/refclock_leitch.c b/ntpd/refclock_leitch.c
new file mode 100644 (file)
index 0000000..e1ba0c4
--- /dev/null
@@ -0,0 +1,626 @@
+/*
+ * refclock_leitch - clock driver for the Leitch CSD-5300 Master Clock
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_LEITCH)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef STREAM
+#include <stropts.h>
+#if defined(LEITCHCLK)
+#include <sys/clkdefs.h>
+#endif /* LEITCHCLK */
+#endif /* STREAM */
+
+#include "ntp_stdlib.h"
+
+
+/*
+ * Driver for Leitch CSD-5300 Master Clock System
+ *
+ * COMMANDS:
+ *     DATE:   D <CR>
+ *     TIME:   T <CR>
+ *     STATUS: S <CR>
+ *     LOOP:   L <CR>
+ *
+ * FORMAT:
+ *     DATE: YYMMDD<CR>
+ *     TIME: <CR>/HHMMSS <CR>/HHMMSS <CR>/HHMMSS <CR>/
+ *             second bondaried on the stop bit of the <CR>
+ *             second boundaries at '/' above.
+ *     STATUS: G (good), D (diag fail), T (time not provided) or
+ *             P (last phone update failed)
+ */
+#define MAXUNITS 1             /* max number of LEITCH units */
+#define LEITCHREFID    "ATOM"  /* reference id */
+#define LEITCH_DESCRIPTION "Leitch: CSD 5300 Master Clock System Driver"
+#define LEITCH232 "/dev/leitch%d"      /* name of radio device */
+#define SPEED232 B300          /* uart speed (300 baud) */ 
+#ifdef DEBUG
+#define leitch_send(A,M) \
+if (debug) fprintf(stderr,"write leitch %s\n",M); \
+if ((write(A->leitchio.fd,M,sizeof(M)) < 0)) {\
+       if (debug) \
+           fprintf(stderr, "leitch_send: unit %d send failed\n", A->unit); \
+       else \
+           msyslog(LOG_ERR, "leitch_send: unit %d send failed %m",A->unit);}
+#else
+#define leitch_send(A,M) \
+if ((write(A->leitchio.fd,M,sizeof(M)) < 0)) {\
+       msyslog(LOG_ERR, "leitch_send: unit %d send failed %m",A->unit);}
+#endif
+
+#define STATE_IDLE 0
+#define STATE_DATE 1
+#define STATE_TIME1 2
+#define STATE_TIME2 3
+#define STATE_TIME3 4
+
+/*
+ * LEITCH unit control structure
+ */
+struct leitchunit {
+       struct peer *peer;
+       struct refclockio leitchio;
+       u_char unit;
+       short year;
+       short yearday;
+       short month;
+       short day;
+       short hour;
+       short second;
+       short minute;
+       short state;
+       u_short fudge1;
+       l_fp reftime1;
+       l_fp reftime2;
+       l_fp reftime3;
+       l_fp codetime1;
+       l_fp codetime2;
+       l_fp codetime3;
+       u_long yearstart;
+};
+
+/*
+ * Function prototypes
+ */
+static void    leitch_init     P((void));
+static int     leitch_start    P((int, struct peer *));
+static void    leitch_shutdown P((int, struct peer *));
+static void    leitch_poll     P((int, struct peer *));
+static void    leitch_control  P((int, struct refclockstat *, struct refclockstat *, struct peer *));
+#define        leitch_buginfo  noentry
+static void    leitch_receive  P((struct recvbuf *));
+static void    leitch_process  P((struct leitchunit *));
+#if 0
+static void    leitch_timeout  P((struct peer *));
+#endif
+static int     leitch_get_date P((struct recvbuf *, struct leitchunit *));
+static int     leitch_get_time P((struct recvbuf *, struct leitchunit *, int));
+static int     days_per_year           P((int));
+
+static struct leitchunit leitchunits[MAXUNITS];
+static u_char unitinuse[MAXUNITS];
+static u_char stratumtouse[MAXUNITS];
+static u_int32 refid[MAXUNITS];
+
+static char days_in_month [] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_leitch = {
+       leitch_start, leitch_shutdown, leitch_poll,
+       leitch_control, leitch_init, leitch_buginfo, NOFLAGS
+};
+
+/*
+ * leitch_init - initialize internal leitch driver data
+ */
+static void
+leitch_init(void)
+{
+       int i;
+
+       memset((char*)leitchunits, 0, sizeof(leitchunits));
+       memset((char*)unitinuse, 0, sizeof(unitinuse));
+       for (i = 0; i < MAXUNITS; i++)
+           memcpy((char *)&refid[i], LEITCHREFID, 4);
+}
+
+/*
+ * leitch_shutdown - shut down a LEITCH clock
+ */
+static void
+leitch_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+#ifdef DEBUG
+       if (debug)
+           fprintf(stderr, "leitch_shutdown()\n");
+#endif
+}
+
+/*
+ * leitch_poll - called by the transmit procedure
+ */
+static void
+leitch_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct leitchunit *leitch;
+
+       /* start the state machine rolling */
+
+#ifdef DEBUG
+       if (debug)
+           fprintf(stderr, "leitch_poll()\n");
+#endif
+       if (unit >= MAXUNITS) {
+               /* XXXX syslog it */
+               return;
+       }
+
+       leitch = &leitchunits[unit];
+
+       if (leitch->state != STATE_IDLE) {
+               /* reset and wait for next poll */
+               /* XXXX syslog it */
+               leitch->state = STATE_IDLE;
+       } else {
+               leitch_send(leitch,"D\r");
+               leitch->state = STATE_DATE;
+       }
+}
+
+static void
+leitch_control(
+       int unit,
+       struct refclockstat *in,
+       struct refclockstat *out,
+       struct peer *passed_peer
+       )
+{
+       if (unit >= MAXUNITS) {
+               msyslog(LOG_ERR,
+                       "leitch_control: unit %d invalid", unit);
+               return;
+       }
+
+       if (in) {
+               if (in->haveflags & CLK_HAVEVAL1)
+                   stratumtouse[unit] = (u_char)(in->fudgeval1);
+               if (in->haveflags & CLK_HAVEVAL2)
+                   refid[unit] = in->fudgeval2;
+               if (unitinuse[unit]) {
+                       struct peer *peer;
+
+                       peer = (&leitchunits[unit])->peer;
+                       peer->stratum = stratumtouse[unit];
+                       peer->refid = refid[unit];
+               }
+       }
+
+       if (out) {
+               memset((char *)out, 0, sizeof (struct refclockstat));
+               out->type = REFCLK_ATOM_LEITCH;
+               out->haveflags = CLK_HAVEVAL1 | CLK_HAVEVAL2;
+               out->fudgeval1 = (int32)stratumtouse[unit];
+               out->fudgeval2 = refid[unit];
+               out->p_lastcode = "";
+               out->clockdesc = LEITCH_DESCRIPTION;
+       }
+}
+
+/*
+ * leitch_start - open the LEITCH devices and initialize data for processing
+ */
+static int
+leitch_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct leitchunit *leitch;
+       int fd232;
+       char leitchdev[20];
+
+       /*
+        * Check configuration info.
+        */
+       if (unit >= MAXUNITS) {
+               msyslog(LOG_ERR, "leitch_start: unit %d invalid", unit);
+               return (0);
+       }
+
+       if (unitinuse[unit]) {
+               msyslog(LOG_ERR, "leitch_start: unit %d in use", unit);
+               return (0);
+       }
+
+       /*
+        * Open serial port.
+        */
+       (void) sprintf(leitchdev, LEITCH232, unit);
+       fd232 = open(leitchdev, O_RDWR, 0777);
+       if (fd232 == -1) {
+               msyslog(LOG_ERR,
+                       "leitch_start: open of %s: %m", leitchdev);
+               return (0);
+       }
+
+       leitch = &leitchunits[unit];
+       memset((char*)leitch, 0, sizeof(*leitch));
+
+#if defined(HAVE_SYSV_TTYS)
+       /*
+        * System V serial line parameters (termio interface)
+        *
+        */
+       {       struct termio ttyb;
+       if (ioctl(fd232, TCGETA, &ttyb) < 0) {
+               msyslog(LOG_ERR,
+                       "leitch_start: ioctl(%s, TCGETA): %m", leitchdev);
+               goto screwed;
+       }
+       ttyb.c_iflag = IGNBRK|IGNPAR|ICRNL;
+       ttyb.c_oflag = 0;
+       ttyb.c_cflag = SPEED232|CS8|CLOCAL|CREAD;
+       ttyb.c_lflag = ICANON;
+       ttyb.c_cc[VERASE] = ttyb.c_cc[VKILL] = '\0';
+       if (ioctl(fd232, TCSETA, &ttyb) < 0) {
+               msyslog(LOG_ERR,
+                       "leitch_start: ioctl(%s, TCSETA): %m", leitchdev);
+               goto screwed;
+       }
+       }
+#endif /* HAVE_SYSV_TTYS */
+#if defined(HAVE_TERMIOS)
+       /*
+        * POSIX serial line parameters (termios interface)
+        *
+        * The LEITCHCLK option provides timestamping at the driver level. 
+        * It requires the tty_clk streams module.
+        */
+       {       struct termios ttyb, *ttyp;
+
+       ttyp = &ttyb;
+       if (tcgetattr(fd232, ttyp) < 0) {
+               msyslog(LOG_ERR,
+                       "leitch_start: tcgetattr(%s): %m", leitchdev);
+               goto screwed;
+       }
+       ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL;
+       ttyp->c_oflag = 0;
+       ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD;
+       ttyp->c_lflag = ICANON;
+       ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0';
+       if (tcsetattr(fd232, TCSANOW, ttyp) < 0) {
+               msyslog(LOG_ERR,
+                       "leitch_start: tcsetattr(%s): %m", leitchdev);
+               goto screwed;
+       }
+       if (tcflush(fd232, TCIOFLUSH) < 0) {
+               msyslog(LOG_ERR,
+                       "leitch_start: tcflush(%s): %m", leitchdev);
+               goto screwed;
+       }
+       }
+#endif /* HAVE_TERMIOS */
+#ifdef STREAM
+#if defined(LEITCHCLK)
+       if (ioctl(fd232, I_PUSH, "clk") < 0)
+           msyslog(LOG_ERR,
+                   "leitch_start: ioctl(%s, I_PUSH, clk): %m", leitchdev);
+       if (ioctl(fd232, CLK_SETSTR, "\n") < 0)
+           msyslog(LOG_ERR,
+                   "leitch_start: ioctl(%s, CLK_SETSTR): %m", leitchdev);
+#endif /* LEITCHCLK */
+#endif /* STREAM */
+#if defined(HAVE_BSD_TTYS)
+       /*
+        * 4.3bsd serial line parameters (sgttyb interface)
+        *
+        * The LEITCHCLK option provides timestamping at the driver level. 
+        * It requires the tty_clk line discipline and 4.3bsd or later.
+        */
+       {       struct sgttyb ttyb;
+#if defined(LEITCHCLK)
+       int ldisc = CLKLDISC;
+#endif /* LEITCHCLK */
+
+       if (ioctl(fd232, TIOCGETP, &ttyb) < 0) {
+               msyslog(LOG_ERR,
+                       "leitch_start: ioctl(%s, TIOCGETP): %m", leitchdev);
+               goto screwed;
+       }
+       ttyb.sg_ispeed = ttyb.sg_ospeed = SPEED232;
+#if defined(LEITCHCLK)
+       ttyb.sg_erase = ttyb.sg_kill = '\r';
+       ttyb.sg_flags = RAW;
+#else
+       ttyb.sg_erase = ttyb.sg_kill = '\0';
+       ttyb.sg_flags = EVENP|ODDP|CRMOD;
+#endif /* LEITCHCLK */
+       if (ioctl(fd232, TIOCSETP, &ttyb) < 0) {
+               msyslog(LOG_ERR,
+                       "leitch_start: ioctl(%s, TIOCSETP): %m", leitchdev);
+               goto screwed;
+       }
+#if defined(LEITCHCLK)
+       if (ioctl(fd232, TIOCSETD, &ldisc) < 0) {
+               msyslog(LOG_ERR,
+                       "leitch_start: ioctl(%s, TIOCSETD): %m",leitchdev);
+               goto screwed;
+       }
+#endif /* LEITCHCLK */
+       }
+#endif /* HAVE_BSD_TTYS */
+
+       /*
+        * Set up the structures
+        */
+       leitch->peer = peer;
+       leitch->unit = unit;
+       leitch->state = STATE_IDLE;
+       leitch->fudge1 = 15;    /* 15ms */
+
+       leitch->leitchio.clock_recv = leitch_receive;
+       leitch->leitchio.srcclock = (caddr_t) leitch;
+       leitch->leitchio.datalen = 0;
+       leitch->leitchio.fd = fd232;
+       if (!io_addclock(&leitch->leitchio)) {
+               goto screwed;
+       }
+
+       /*
+        * All done.  Initialize a few random peer variables, then
+        * return success.
+        */
+       peer->precision = 0;
+       peer->stratum = stratumtouse[unit];
+       peer->refid = refid[unit];
+       unitinuse[unit] = 1;
+       return(1);
+
+       /*
+        * Something broke; abandon ship.
+        */
+    screwed:
+       close(fd232);
+       return(0);
+}
+
+/*
+ * leitch_receive - receive data from the serial interface on a leitch
+ * clock
+ */
+static void
+leitch_receive(
+       struct recvbuf *rbufp
+       )
+{
+       struct leitchunit *leitch = (struct leitchunit *)rbufp->recv_srcclock;
+
+#ifdef DEBUG
+       if (debug)
+           fprintf(stderr, "leitch_recieve(%*.*s)\n", 
+                   rbufp->recv_length, rbufp->recv_length,
+                   rbufp->recv_buffer);
+#endif
+       if (rbufp->recv_length != 7)
+           return; /* The date is return with a trailing newline,
+                      discard it. */
+
+       switch (leitch->state) {
+           case STATE_IDLE:    /* unexpected, discard and resync */
+               return;
+           case STATE_DATE:
+               if (!leitch_get_date(rbufp,leitch)) {
+                       leitch->state = STATE_IDLE;
+                       break;
+               }
+               leitch_send(leitch,"T\r");
+#ifdef DEBUG
+               if (debug)
+                   fprintf(stderr, "%u\n",leitch->yearday);
+#endif
+               leitch->state = STATE_TIME1;
+               break;
+           case STATE_TIME1:
+               if (!leitch_get_time(rbufp,leitch,1)) {
+               }
+               if (!clocktime(leitch->yearday,leitch->hour,leitch->minute,
+                              leitch->second, 1, rbufp->recv_time.l_ui,
+                              &leitch->yearstart, &leitch->reftime1.l_ui)) {
+                       leitch->state = STATE_IDLE;
+                       break;
+               }
+               leitch->reftime1.l_uf = 0;
+#ifdef DEBUG
+               if (debug)
+                   fprintf(stderr, "%lu\n", (u_long)leitch->reftime1.l_ui);
+#endif
+               MSUTOTSF(leitch->fudge1, leitch->reftime1.l_uf);
+               leitch->codetime1 = rbufp->recv_time;
+               leitch->state = STATE_TIME2;
+               break;
+           case STATE_TIME2:
+               if (!leitch_get_time(rbufp,leitch,2)) {
+               }
+               if (!clocktime(leitch->yearday,leitch->hour,leitch->minute,
+                              leitch->second, 1, rbufp->recv_time.l_ui,
+                              &leitch->yearstart, &leitch->reftime2.l_ui)) {
+                       leitch->state = STATE_IDLE;
+                       break;
+               }
+#ifdef DEBUG
+               if (debug)
+                   fprintf(stderr, "%lu\n", (u_long)leitch->reftime2.l_ui);
+#endif
+               MSUTOTSF(leitch->fudge1, leitch->reftime2.l_uf);
+               leitch->codetime2 = rbufp->recv_time;
+               leitch->state = STATE_TIME3;
+               break;
+           case STATE_TIME3:
+               if (!leitch_get_time(rbufp,leitch,3)) {
+               }
+               if (!clocktime(leitch->yearday,leitch->hour,leitch->minute,
+                              leitch->second, GMT, rbufp->recv_time.l_ui,
+                              &leitch->yearstart, &leitch->reftime3.l_ui)) {
+                       leitch->state = STATE_IDLE;
+                       break;
+               }
+#ifdef DEBUG
+               if (debug)
+                   fprintf(stderr, "%lu\n", (u_long)leitch->reftime3.l_ui);
+#endif
+               MSUTOTSF(leitch->fudge1, leitch->reftime3.l_uf);
+               leitch->codetime3 = rbufp->recv_time;
+               leitch_process(leitch);
+               leitch->state = STATE_IDLE;
+               break;
+           default:
+               msyslog(LOG_ERR,
+                       "leitech_receive: invalid state %d unit %d",
+                       leitch->state, leitch->unit);
+       }
+}
+
+/*
+ * leitch_process - process a pile of samples from the clock
+ *
+ * This routine uses a three-stage median filter to calculate offset and
+ * dispersion. reduce jitter. The dispersion is calculated as the span
+ * of the filter (max - min), unless the quality character (format 2) is
+ * non-blank, in which case the dispersion is calculated on the basis of
+ * the inherent tolerance of the internal radio oscillator, which is
+ * +-2e-5 according to the radio specifications.
+ */
+static void
+leitch_process(
+       struct leitchunit *leitch
+       )
+{
+       l_fp off;
+       l_fp tmp_fp;
+      /*double doffset;*/
+
+       off = leitch->reftime1;
+       L_SUB(&off,&leitch->codetime1);
+       tmp_fp = leitch->reftime2;
+       L_SUB(&tmp_fp,&leitch->codetime2);
+       if (L_ISGEQ(&off,&tmp_fp))
+           off = tmp_fp;
+       tmp_fp = leitch->reftime3;
+       L_SUB(&tmp_fp,&leitch->codetime3);
+
+       if (L_ISGEQ(&off,&tmp_fp))
+           off = tmp_fp;
+      /*LFPTOD(&off, doffset);*/
+       refclock_receive(leitch->peer);
+}
+
+/*
+ * days_per_year
+ */
+static int
+days_per_year(
+       int year
+       )
+{
+       if (year%4) {   /* not a potential leap year */
+               return (365);
+       } else {
+               if (year % 100) {       /* is a leap year */
+                       return (366);
+               } else {        
+                       if (year % 400) {
+                               return (365);
+                       } else {
+                               return (366);
+                       }
+               }
+       }
+}
+
+static int
+leitch_get_date(
+       struct recvbuf *rbufp,
+       struct leitchunit *leitch
+       )
+{
+       int i;
+
+       if (rbufp->recv_length < 6)
+           return(0);
+#undef  BAD    /* confict: defined as (-1) in AIX sys/param.h */
+#define BAD(A) (rbufp->recv_buffer[A] < '0') || (rbufp->recv_buffer[A] > '9')
+       if (BAD(0)||BAD(1)||BAD(2)||BAD(3)||BAD(4)||BAD(5))
+           return(0);
+#define ATOB(A) ((rbufp->recv_buffer[A])-'0')
+       leitch->year = ATOB(0)*10 + ATOB(1);
+       leitch->month = ATOB(2)*10 + ATOB(3);
+       leitch->day = ATOB(4)*10 + ATOB(5);
+
+       /* sanity checks */
+       if (leitch->month > 12)
+           return(0);
+       if (leitch->day > days_in_month[leitch->month-1])
+           return(0);
+
+       /* calculate yearday */
+       i = 0;
+       leitch->yearday = leitch->day;
+
+       while ( i < (leitch->month-1) )
+           leitch->yearday += days_in_month[i++];
+
+       if ((days_per_year((leitch->year>90?1900:2000)+leitch->year)==365) && 
+           leitch->month > 2)
+           leitch->yearday--;
+
+       return(1);
+}
+
+/*
+ * leitch_get_time
+ */
+static int
+leitch_get_time(
+       struct recvbuf *rbufp,
+       struct leitchunit *leitch,
+       int which
+       )
+{
+       if (BAD(0)||BAD(1)||BAD(2)||BAD(3)||BAD(4)||BAD(5))
+           return(0);
+       leitch->hour = ATOB(0)*10 +ATOB(1);
+       leitch->minute = ATOB(2)*10 +ATOB(3);
+       leitch->second = ATOB(4)*10 +ATOB(5);
+
+       if ((leitch->hour > 23) || (leitch->minute > 60) ||
+           (leitch->second > 60))
+           return(0);
+       return(1);
+}
+
+#else
+int refclock_leitch_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_local.c b/ntpd/refclock_local.c
new file mode 100644 (file)
index 0000000..dc6f1ae
--- /dev/null
@@ -0,0 +1,258 @@
+
+/*
+ * refclock_local - local pseudo-clock driver
+ *
+ * wjm 17-aug-1995: add a hook for special treatment of VMS_LOCALUNIT
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#ifdef REFCLOCK
+
+#include "ntpd.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef KERNEL_PLL
+#include "ntp_syscall.h"
+#endif
+
+/*
+ * This is a hack to allow a machine to use its own system clock as a
+ * reference clock, i.e., to free-run using no outside clock discipline
+ * source. This is useful if you want to use NTP in an isolated
+ * environment with no radio clock or NIST modem available. Pick a
+ * machine that you figure has a good clock oscillator and configure it
+ * with this driver. Set the clock using the best means available, like
+ * eyeball-and-wristwatch. Then, point all the other machines at this
+ * one or use broadcast (not multicast) mode to distribute time.
+ *
+ * Another application for this driver is if you want to use a
+ * particular server's clock as the clock of last resort when all other
+ * normal synchronization sources have gone away. This is especially
+ * useful if that server has an ovenized oscillator. For this you would
+ * configure this driver at a higher stratum (say 5) to prevent the
+ * server's stratum from falling below that.
+ *
+ * A third application for this driver is when an external discipline
+ * source is available, such as the NIST "lockclock" program, which
+ * synchronizes the local clock via a telephone modem and the NIST
+ * Automated Computer Time Service (ACTS), or the Digital Time
+ * Synchronization Service (DTSS), which runs on DCE machines. In this
+ * case the stratum should be set at zero, indicating a bona fide
+ * stratum-1 source. Exercise some caution with this, since there is no
+ * easy way to telegraph via NTP that something might be wrong in the
+ * discipline source itself. In the case of DTSS, the local clock can
+ * have a rather large jitter, depending on the interval between
+ * corrections and the intrinsic frequency error of the clock
+ * oscillator. In extreme cases, this can cause clients to exceed the
+ * 128-ms slew window and drop off the NTP subnet.
+ *
+ * THis driver includes provisions to telegraph synchronization state
+ * and related variables by means of kernel variables with specially
+ * modified kernels. This is done using the ntp_adjtime() syscall.
+ * In the cases where another protocol or device synchronizes the local
+ * host, the data given to the kernel can be slurped up by this driver
+ * and distributed to clients by ordinary NTP messaging.
+ *
+ * In the default mode the behavior of the clock selection algorithm is
+ * modified when this driver is in use. The algorithm is designed so
+ * that this driver will never be selected unless no other discipline
+ * source is available. This can be overriden with the prefer keyword of
+ * the server configuration command, in which case only this driver will
+ * be selected for synchronization and all other discipline sources will
+ * be ignored. This behavior is intended for use when an external
+ * discipline source controls the system clock.
+ *
+ * Fudge Factors
+ *
+ * The stratum for this driver set at 5 by default, but it can be
+ * changed by the fudge command and/or the ntpdc utility. The reference
+ * ID is 127.0.0.1 by default, but can be changed using the same mechanism.
+ * *NEVER* configure this driver to operate at a stratum which might
+ * possibly disrupt a client with access to a bona fide primary server,
+ * unless the local clock oscillator is reliably disciplined by another
+ * source. *NEVER NEVER* configure a server which might devolve to an
+ * undisciplined local clock to use multicast mode. Always remember that
+ * an improperly configured local clock driver let loose in the Internet
+ * can cause very serious disruption. This is why most of us who care
+ * about good time use cryptographic authentication.
+ *
+ * This driver provides a mechanism to trim the local clock in both time
+ * and frequency, as well as a way to manipulate the leap bits. The
+ * fudge time1 parameter adjusts the time, in seconds, and the fudge
+ * time2 parameter adjusts the frequency, in ppm. The fudge time1
+ * parameter is additive; that is, it adds an increment to the current
+ * time. The fudge time2 parameter directly sets the frequency.
+ */
+/*
+ * Local interface definitions
+ */
+#define PRECISION      (-7)    /* about 10 ms precision */
+#define DESCRIPTION "Undisciplined local clock" /* WRU */
+#define STRATUM        5       /* default stratum */
+#define DISPERSION     .01     /* default dispersion (10 ms) */
+
+/*
+ * Imported from the timer module
+ */
+extern u_long current_time;
+
+/*
+ * Imported from ntp_proto
+ */
+extern s_char sys_precision;
+
+#ifdef KERNEL_PLL
+/*
+ * Imported from ntp_loopfilter
+ */
+extern int pll_control;        /* kernel pll control */
+extern int kern_enable;                /* kernel pll enabled */
+extern int ext_enable;         /* external clock enable */
+#endif /* KERNEL_PLL */
+
+/*
+ * Function prototypes
+ */
+static int local_start P((int, struct peer *));
+static void    local_poll      P((int, struct peer *));
+
+/*
+ * Local variables
+ */
+static u_long poll_time;       /* last time polled */
+       
+/*
+ * Transfer vector
+ */
+struct refclock refclock_local = {
+       local_start,            /* start up driver */
+       noentry,                /* shut down driver (not used) */
+       local_poll,             /* transmit poll message */
+       noentry,                /* not used (old lcl_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old lcl_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * local_start - start up the clock
+ */
+static int
+local_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = sys_precision;
+       pp->leap = LEAP_NOTINSYNC;
+       peer->stratum = STRATUM;
+       pp->stratum = STRATUM;
+       pp->clockdesc = DESCRIPTION;
+       memcpy(&pp->refid, "LOCL", 4);
+       poll_time = current_time;
+       return (1);
+}
+
+
+/*
+ * local_poll - called by the transmit procedure
+ *
+ * LOCKCLOCK: If the kernel supports the nanokernel or microkernel
+ * system calls, the leap bits are extracted from the kernel. If there
+ * is a kernel error or the kernel leap bits are set to 11, the NTP leap
+ * bits are set to 11 and the stratum is set to infinity. Otherwise, the
+ * NTP leap bits are set to the kernel leap bits and the stratum is set
+ * as fudged. This behavior does not faithfully follow the
+ * specification, but is probably more appropriate in a multiple-server
+ * national laboratory network.
+ */
+static void
+local_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+#if defined(KERNEL_PLL) && defined(LOCKCLOCK)
+       struct timex ntv;
+#endif /* KERNEL_PLL LOCKCLOCK */
+       struct refclockproc *pp;
+
+#if defined(VMS) && defined(VMS_LOCALUNIT)
+       if (unit == VMS_LOCALUNIT) {
+               extern void vms_local_poll(struct peer *);
+
+               vms_local_poll(peer);
+               return;
+       }
+#endif /* VMS && VMS_LOCALUNIT */
+       pp = peer->procptr;
+       pp->polls++;
+
+       /*
+        * Ramble through the usual filtering and grooming code, which
+        * is essentially a no-op and included mostly for pretty
+        * billboards. We allow a one-time time adjustment using fudge
+        * time1 (s) and a continuous frequency adjustment using fudge
+        * time 2 (ppm).
+        */
+       get_systime(&pp->lastrec);
+       pp->fudgetime1 += pp->fudgetime2 * 1e-6 * (current_time -
+           poll_time);
+       poll_time = current_time;
+       refclock_process_offset(pp, pp->lastrec, pp->lastrec,
+           pp->fudgetime1);
+
+       /*
+        * If another process is disciplining the system clock, we set
+        * the leap bits and quality indicators from the kernel.
+        */
+#if defined(KERNEL_PLL) && defined(LOCKCLOCK)
+       memset(&ntv,  0, sizeof ntv);
+       switch (ntp_adjtime(&ntv)) {
+       case TIME_OK:
+               pp->leap = LEAP_NOWARNING;
+               peer->stratum = pp->stratum;
+               break;
+
+       case TIME_INS:
+               pp->leap = LEAP_ADDSECOND;
+               peer->stratum = pp->stratum;
+               break;
+
+       case TIME_DEL:
+               pp->leap = LEAP_DELSECOND;
+               peer->stratum = pp->stratum;
+               break;
+
+       default:
+               pp->leap = LEAP_NOTINSYNC;
+               peer->stratum = STRATUM_UNSPEC;
+       }
+       pp->disp = 0;
+       pp->jitter = 0;
+#else /* KERNEL_PLL LOCKCLOCK */
+       pp->leap = LEAP_NOWARNING;
+       pp->disp = DISPERSION;
+       pp->jitter = 0;
+#endif /* KERNEL_PLL LOCKCLOCK */
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+       pp->fudgetime1 = 0;
+}
+#else
+int refclock_local_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_msfees.c b/ntpd/refclock_msfees.c
new file mode 100644 (file)
index 0000000..98034b5
--- /dev/null
@@ -0,0 +1,1462 @@
+/* refclock_ees - clock driver for the EES M201 receiver */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_MSFEES) && defined(PPS)
+
+/* Currently REQUIRES STREAM and PPSCD. CLK and CBREAK modes
+ * were removed as the code was overly hairy, they weren't in use
+ * (hence probably didn't work).  Still in RCS file at cl.cam.ac.uk
+ */
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+
+#include <ctype.h>
+#if defined(HAVE_BSD_TTYS)
+#include <sgtty.h>
+#endif /* HAVE_BSD_TTYS */
+#if defined(HAVE_SYSV_TTYS)
+#include <termio.h>
+#endif /* HAVE_SYSV_TTYS */
+#if defined(HAVE_TERMIOS)
+#include <termios.h>
+#endif
+#if defined(STREAM)
+#include <stropts.h>
+#endif
+
+#ifdef HAVE_SYS_TERMIOS_H
+# include <sys/termios.h>
+#endif
+#ifdef HAVE_SYS_PPSCLOCK_H
+# include <sys/ppsclock.h>
+#endif
+
+#include "ntp_stdlib.h"
+
+int dbg = 0;
+/*
+       fudgefactor     = fudgetime1;
+       os_delay        = fudgetime2;
+          offset_fudge = os_delay + fudgefactor + inherent_delay;
+       stratumtouse    = fudgeval1 & 0xf
+       dbg             = fudgeval2;
+       sloppyclockflag = flags & CLK_FLAG1;
+               1         log smoothing summary when processing sample
+               4         dump the buffer from the clock
+               8         EIOGETKD the last n uS time stamps
+       if (flags & CLK_FLAG2 && unitinuse) ees->leaphold = 0;
+       ees->dump_vals  = flags & CLK_FLAG3;
+       ees->usealldata = flags & CLK_FLAG4;
+
+
+       bug->values[0] = (ees->lasttime) ? current_time - ees->lasttime : 0;
+       bug->values[1] = (ees->clocklastgood)?current_time-ees->clocklastgood:0;
+       bug->values[2] = (u_long)ees->status;
+       bug->values[3] = (u_long)ees->lastevent;
+       bug->values[4] = (u_long)ees->reason;
+       bug->values[5] = (u_long)ees->nsamples;
+       bug->values[6] = (u_long)ees->codestate;
+       bug->values[7] = (u_long)ees->day;
+       bug->values[8] = (u_long)ees->hour;
+       bug->values[9] = (u_long)ees->minute;
+       bug->values[10] = (u_long)ees->second;
+       bug->values[11] = (u_long)ees->tz;
+       bug->values[12] = ees->yearstart;
+       bug->values[13] = (ees->leaphold > current_time) ?
+                               ees->leaphold - current_time : 0;
+       bug->values[14] = inherent_delay[unit].l_uf;
+       bug->values[15] = offset_fudge[unit].l_uf;
+
+       bug->times[0] = ees->reftime;
+       bug->times[1] = ees->arrvtime;
+       bug->times[2] = ees->lastsampletime;
+       bug->times[3] = ees->offset;
+       bug->times[4] = ees->lowoffset;
+       bug->times[5] = ees->highoffset;
+       bug->times[6] = inherent_delay[unit];
+       bug->times[8] = os_delay[unit];
+       bug->times[7] = fudgefactor[unit];
+       bug->times[9] = offset_fudge[unit];
+       bug->times[10]= ees->yearstart, 0;
+       */
+
+/* This should support the use of an EES M201 receiver with RS232
+ * output (modified to transmit time once per second).
+ *
+ * For the format of the message sent by the clock, see the EESM_
+ * definitions below.
+ *
+ * It appears to run free for an integral number of minutes, until the error
+ * reaches 4mS, at which point it steps at second = 01.
+ * It appears that sometimes it steps 4mS (say at 7 min interval),
+ * then the next minute it decides that it was an error, so steps back.
+ * On the next minute it steps forward again :-(
+ * This is typically 16.5uS/S then 3975uS at the 4min re-sync,
+ * or 9.5uS/S then 3990.5uS at a 7min re-sync,
+ * at which point it may lose the "00" second time stamp.
+ * I assume that the most accurate time is just AFTER the re-sync.
+ * Hence remember the last cycle interval,
+ *
+ * Can run in any one of:
+ *
+ *     PPSCD   PPS signal sets CD which interupts, and grabs the current TOD
+ *     (sun)           *in the interupt code*, so as to avoid problems with
+ *                     the STREAMS scheduling.
+ *
+ * It appears that it goes 16.5 uS slow each second, then every 4 mins it
+ * generates no "00" second tick, and gains 3975 uS. Ho Hum ! (93/2/7)
+ */
+
+/* Definitions */
+#ifndef        MAXUNITS
+#define        MAXUNITS        4       /* maximum number of EES units permitted */
+#endif
+
+#ifndef        EES232
+#define        EES232  "/dev/ees%d"    /* Device to open to read the data */
+#endif
+
+/* Other constant stuff */
+#ifndef        EESPRECISION
+#define        EESPRECISION    (-10)           /* what the heck - 2**-10 = 1ms */
+#endif
+#ifndef        EESREFID
+#define        EESREFID        "MSF\0"         /* String to identify the clock */
+#endif
+#ifndef        EESHSREFID
+#define        EESHSREFID      (0x7f7f0000 | ((REFCLK_MSF_EES) << 8)) /* Numeric refid */
+#endif
+
+/* Description of clock */
+#define        EESDESCRIPTION          "EES M201 MSF Receiver"
+
+/* Speed we run the clock port at. If this is changed the UARTDELAY
+ * value should be recomputed to suit.
+ */
+#ifndef        SPEED232
+#define        SPEED232        B9600   /* 9600 baud */
+#endif
+
+/* What is the inherent delay for this mode of working, i.e. when is the
+ * data time stamped.
+ */
+#define        SAFETY_SHIFT    10      /* Split the shift to avoid overflow */
+#define        BITS_TO_L_FP(bits, baud) \
+(((((bits)*2 +1) << (FRACTION_PREC-SAFETY_SHIFT)) / (2*baud)) << SAFETY_SHIFT)
+#define        INH_DELAY_CBREAK        BITS_TO_L_FP(119, 9600)
+#define        INH_DELAY_PPS           BITS_TO_L_FP(  0, 9600)
+
+#ifndef        STREAM_PP1
+#define        STREAM_PP1      "ppsclocd\0<-- patch space for module name1 -->"
+#endif
+#ifndef        STREAM_PP2
+#define        STREAM_PP2      "ppsclock\0<-- patch space for module name2 -->"
+#endif
+
+     /* Offsets of the bytes of the serial line code.  The clock gives
+ * local time with a GMT/BST indication. The EESM_ definitions
+ * give offsets into ees->lastcode.
+ */
+#define EESM_CSEC       0      /* centiseconds - always zero in our clock  */
+#define EESM_SEC        1      /* seconds in BCD                           */
+#define EESM_MIN        2      /* minutes in BCD                           */
+#define EESM_HOUR       3      /* hours in BCD                             */
+#define EESM_DAYWK      4      /* day of week (Sun = 0 etc)                */
+#define EESM_DAY        5      /* day of month in BCD                      */
+#define EESM_MON        6      /* month in BCD                             */
+#define EESM_YEAR       7      /* year MOD 100 in BCD                      */
+#define EESM_LEAP       8      /* 0x0f if leap year, otherwise zero        */
+#define EESM_BST        9      /* 0x03 if BST, 0x00 if GMT                 */
+#define EESM_MSFOK     10      /* 0x3f if radio good, otherwise zero       */
+                               /* followed by a frame alignment byte (0xff) /
+                               /  which is not put into the lastcode buffer*/
+
+/* Length of the serial time code, in characters.  The first length
+ * is less the frame alignment byte.
+ */
+#define        LENEESPRT       (EESM_MSFOK+1)
+#define        LENEESCODE      (LENEESPRT+1)
+
+     /* Code state. */
+#define        EESCS_WAIT      0       /* waiting for start of timecode */
+#define        EESCS_GOTSOME   1       /* have an incomplete time code buffered */
+
+     /* Default fudge factor and character to receive */
+#define        DEFFUDGETIME    0       /* Default user supplied fudge factor */
+#ifndef        DEFOSTIME
+#define        DEFOSTIME       0       /* Default OS delay -- passed by Make ? */
+#endif
+#define        DEFINHTIME      INH_DELAY_PPS /* inherent delay due to sample point*/
+
+     /* Limits on things.  Reduce the number of samples to SAMPLEREDUCE by median
+ * elimination.  If we're running with an accurate clock, chose the BESTSAMPLE
+ * as the estimated offset, otherwise average the remainder.
+ */
+#define        FULLSHIFT       6                       /* NCODES root 2 */
+#define NCODES         (1<< FULLSHIFT)         /* 64 */
+#define        REDUCESHIFT     (FULLSHIFT -1)          /* SAMPLEREDUCE root 2 */
+
+     /* Towards the high ( Why ?) end of half */
+#define        BESTSAMPLE      ((samplereduce * 3) /4) /* 24 */
+
+     /* Leap hold time.  After a leap second the clock will no longer be
+ * reliable until it resynchronizes.  Hope 40 minutes is enough. */
+#define        EESLEAPHOLD     (40 * 60)
+
+#define        EES_STEP_F      (1 << 24) /* the receiver steps in units of about 4ms */
+#define        EES_STEP_F_GRACE (EES_STEP_F/8) /*Allow for slop of 1/8 which is .5ms*/
+#define        EES_STEP_NOTE   (1 << 21)/* Log any unexpected jumps, say .5 ms .... */
+#define        EES_STEP_NOTES  50      /* Only do a limited number */
+#define        MAX_STEP        16      /* Max number of steps to remember */
+
+     /* debug is a bit mask of debugging that is wanted */
+#define        DB_SYSLOG_SMPLI         0x0001
+#define        DB_SYSLOG_SMPLE         0x0002
+#define        DB_SYSLOG_SMTHI         0x0004
+#define        DB_SYSLOG_NSMTHE        0x0008
+#define        DB_SYSLOG_NSMTHI        0x0010
+#define        DB_SYSLOG_SMTHE         0x0020
+#define        DB_PRINT_EV             0x0040
+#define        DB_PRINT_CDT            0x0080
+#define        DB_PRINT_CDTC           0x0100
+#define        DB_SYSLOG_KEEPD         0x0800
+#define        DB_SYSLOG_KEEPE         0x1000
+#define        DB_LOG_DELTAS           0x2000
+#define        DB_PRINT_DELTAS         0x4000
+#define        DB_LOG_AWAITMORE        0x8000
+#define        DB_LOG_SAMPLES          0x10000
+#define        DB_NO_PPS               0x20000
+#define        DB_INC_PPS              0x40000
+#define        DB_DUMP_DELTAS          0x80000
+
+     struct eesunit {                  /* EES unit control structure. */
+            struct peer *peer;         /* associated peer structure */
+            struct refclockio io;              /* given to the I/O handler */
+            l_fp       reftime;                /* reference time */
+            l_fp       lastsampletime;         /* time as in txt from last EES msg */
+            l_fp       arrvtime;               /* Time at which pkt arrived */
+            l_fp       codeoffsets[NCODES];    /* the time of arrival of 232 codes */
+            l_fp       offset;                 /* chosen offset        (for clkbug) */
+            l_fp       lowoffset;              /* lowest sample offset (for clkbug) */
+            l_fp       highoffset;             /* highest   "     "    (for clkbug) */
+            char       lastcode[LENEESCODE+6]; /* last time code we received */
+            u_long     lasttime;               /* last time clock heard from */
+            u_long     clocklastgood;          /* last time good radio seen */
+            u_char     lencode;                /* length of code in buffer */
+            u_char     nsamples;               /* number of samples we've collected */
+            u_char     codestate;              /* state of 232 code reception */
+            u_char     unit;                   /* unit number for this guy */
+            u_char     status;                 /* clock status */
+            u_char     lastevent;              /* last clock event */
+            u_char     reason;                 /* reason for last abort */
+            u_char     hour;                   /* hour of day */
+            u_char     minute;                 /* minute of hour */
+            u_char     second;                 /* seconds of minute */
+            char       tz;                     /* timezone from clock */
+            u_char     ttytype;                /* method used */
+            u_char     dump_vals;              /* Should clock values be dumped */
+            u_char     usealldata;             /* Use ALL samples */
+            u_short    day;                    /* day of year from last code */
+            u_long     yearstart;              /* start of current year */
+            u_long     leaphold;               /* time of leap hold expiry */
+            u_long     badformat;              /* number of bad format codes */
+            u_long     baddata;                /* number of invalid time codes */
+            u_long     timestarted;            /* time we started this */
+            long       last_pps_no;            /* The serial # of the last PPS */
+            char       fix_pending;            /* Is a "sync to time" pending ? */
+            /* Fine tuning - compensate for 4 mS ramping .... */
+            l_fp       last_l;                 /* last time stamp */
+            u_char     last_steps[MAX_STEP];   /* Most recent n steps */
+            int        best_av_step;           /* Best guess at average step */
+            char       best_av_step_count;     /* # of steps over used above */
+            char       this_step;              /* Current pos in buffer */
+            int        last_step_late;         /* How late the last step was (0-59) */
+            long       jump_fsecs;             /* # of fractions of a sec last jump */
+            u_long     last_step;              /* time of last step */
+            int        last_step_secs;         /* Number of seconds in last step */
+            int        using_ramp;             /* 1 -> noemal, -1 -> over stepped */
+     };
+#define        last_sec        last_l.l_ui
+#define        last_sfsec      last_l.l_f
+#define        this_uisec      ((ees->arrvtime).l_ui)
+#define        this_sfsec      ((ees->arrvtime).l_f)
+#define        msec(x)         ((x) / (1<<22))
+#define        LAST_STEPS      (sizeof ees->last_steps / sizeof ees->last_steps[0])
+#define        subms(x)        ((((((x < 0) ? (-(x)) : (x)) % (1<<22))/2) * 625) / (1<<(22 -5)))
+
+/* Bitmask for what methods to try to use -- currently only PPS enabled */
+#define        T_CBREAK        1
+#define        T_PPS           8
+/* macros to test above */
+#define        is_cbreak(x)    ((x)->ttytype & T_CBREAK)
+#define        is_pps(x)       ((x)->ttytype & T_PPS)
+#define        is_any(x)       ((x)->ttytype)
+
+#define        CODEREASON      20      /* reason codes */
+
+/* Data space for the unit structures.  Note that we allocate these on
+ * the fly, but never give them back. */
+static struct eesunit *eesunits[MAXUNITS];
+static u_char unitinuse[MAXUNITS];
+
+/* Keep the fudge factors separately so they can be set even
+ * when no clock is configured. */
+static l_fp inherent_delay[MAXUNITS];          /* when time stamp is taken */
+static l_fp fudgefactor[MAXUNITS];             /* fudgetime1 */
+static l_fp os_delay[MAXUNITS];                        /* fudgetime2 */
+static l_fp offset_fudge[MAXUNITS];            /* Sum of above */
+static u_char stratumtouse[MAXUNITS];
+static u_char sloppyclockflag[MAXUNITS];
+
+static int deltas[60];
+
+static l_fp acceptable_slop; /* = { 0, 1 << (FRACTION_PREC -2) }; */
+static l_fp onesec; /* = { 1, 0 }; */
+
+#ifndef        DUMP_BUF_SIZE   /* Size of buffer to be used by dump_buf */
+#define        DUMP_BUF_SIZE   10112
+#endif
+
+/* ees_reset - reset the count back to zero */
+#define        ees_reset(ees) (ees)->nsamples = 0; \
+(ees)->codestate = EESCS_WAIT
+
+/* ees_event - record and report an event */
+#define        ees_event(ees, evcode) if ((ees)->status != (u_char)(evcode)) \
+ees_report_event((ees), (evcode))
+
+     /* Find the precision of the system clock by reading it */
+#define        USECS   1000000
+#define        MINSTEP 5       /* some systems increment uS on each call */
+#define        MAXLOOPS (USECS/9)
+
+/*
+ * Function prototypes
+ */
+
+static int     msfees_start    P((int unit, struct peer *peer));
+static void    msfees_shutdown P((int unit, struct peer *peer));
+static void    msfees_poll     P((int unit, struct peer *peer));
+static void    msfees_init     P((void));
+static void    dump_buf        P((l_fp *coffs, int from, int to, char *text));
+static void    ees_report_event P((struct eesunit *ees, int code));
+static void    ees_receive     P((struct recvbuf *rbufp));
+static void    ees_process     P((struct eesunit *ees));
+#ifdef QSORT_USES_VOID_P
+static int     offcompare      P((const void *va, const void *vb));
+#else
+static int     offcompare      P((const l_fp *a, const l_fp *b));
+#endif /* QSORT_USES_VOID_P */
+
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_msfees = {
+       msfees_start,           /* start up driver */
+       msfees_shutdown,        /* shut down driver */
+       msfees_poll,            /* transmit poll message */
+       noentry,                /* not used */
+       msfees_init,            /* initialize driver */
+       noentry,                /* not used */
+       NOFLAGS                 /* not used */
+};
+
+
+static void
+dump_buf(
+       l_fp *coffs,
+       int from,
+       int to,
+       char *text
+       )
+{
+       char buff[DUMP_BUF_SIZE + 80];
+       int i;
+       register char *ptr = buff;
+
+       sprintf(ptr, text);
+       for (i=from; i<to; i++)
+       {       while (*ptr) ptr++;
+       if ((ptr-buff) > DUMP_BUF_SIZE) msyslog(LOG_DEBUG, "D: %s", ptr=buff);
+       sprintf(ptr, " %06d", ((int)coffs[i].l_f) / 4295);
+       }
+       msyslog(LOG_DEBUG, "D: %s", buff);
+}
+
+/* msfees_init - initialize internal ees driver data */
+static void
+msfees_init(void)
+{
+       register int i;
+       /* Just zero the data arrays */
+       memset((char *)eesunits, 0, sizeof eesunits);
+       memset((char *)unitinuse, 0, sizeof unitinuse);
+
+       acceptable_slop.l_ui = 0;
+       acceptable_slop.l_uf = 1 << (FRACTION_PREC -2);
+
+       onesec.l_ui = 1;
+       onesec.l_uf = 0;
+
+       /* Initialize fudge factors to default. */
+       for (i = 0; i < MAXUNITS; i++) {
+               fudgefactor[i].l_ui     = 0;
+               fudgefactor[i].l_uf     = DEFFUDGETIME;
+               os_delay[i].l_ui        = 0;
+               os_delay[i].l_uf        = DEFOSTIME;
+               inherent_delay[i].l_ui  = 0;
+               inherent_delay[i].l_uf  = DEFINHTIME;
+               offset_fudge[i]         = os_delay[i];
+               L_ADD(&offset_fudge[i], &fudgefactor[i]);
+               L_ADD(&offset_fudge[i], &inherent_delay[i]);
+               stratumtouse[i]         = 0;
+               sloppyclockflag[i]      = 0;
+       }
+}
+
+
+/* msfees_start - open the EES devices and initialize data for processing */
+static int
+msfees_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct eesunit *ees;
+       register int i;
+       int fd232 = -1;
+       char eesdev[20];
+       struct termios ttyb, *ttyp;
+       struct refclockproc *pp;
+       pp = peer->procptr;
+
+       if (unit >= MAXUNITS) {
+               msyslog(LOG_ERR, "ees clock: unit number %d invalid (max %d)",
+                       unit, MAXUNITS-1);
+               return 0;
+       }
+       if (unitinuse[unit]) {
+               msyslog(LOG_ERR, "ees clock: unit number %d in use", unit);
+               return 0;
+       }
+
+       /* Unit okay, attempt to open the devices.  We do them both at
+        * once to make sure we can */
+       (void) sprintf(eesdev, EES232, unit);
+
+       fd232 = open(eesdev, O_RDWR, 0777);
+       if (fd232 == -1) {
+               msyslog(LOG_ERR, "ees clock: open of %s failed: %m", eesdev);
+               return 0;
+       }
+
+#ifdef TIOCEXCL
+       /* Set for exclusive use */
+       if (ioctl(fd232, TIOCEXCL, (char *)0) < 0) {
+               msyslog(LOG_ERR, "ees clock: ioctl(%s, TIOCEXCL): %m", eesdev);
+               goto screwed;
+       }
+#endif
+
+       /* STRIPPED DOWN VERSION: Only PPS CD is supported at the moment */
+
+       /* Set port characteristics.  If we don't have a STREAMS module or
+        * a clock line discipline, cooked mode is just usable, even though it
+        * strips the top bit.  The only EES byte which uses the top
+        * bit is the year, and we don't use that anyway. If we do
+        * have the line discipline, we choose raw mode, and the
+        * line discipline code will block up the messages.
+        */
+
+       /* STIPPED DOWN VERSION: Only PPS CD is supported at the moment */
+
+       ttyp = &ttyb;
+       if (tcgetattr(fd232, ttyp) < 0) {
+               msyslog(LOG_ERR, "msfees_start: tcgetattr(%s): %m", eesdev);
+               goto screwed;
+       }
+
+       ttyp->c_iflag = IGNBRK|IGNPAR|ICRNL;
+       ttyp->c_cflag = SPEED232|CS8|CLOCAL|CREAD;
+       ttyp->c_oflag = 0;
+       ttyp->c_lflag = ICANON;
+       ttyp->c_cc[VERASE] = ttyp->c_cc[VKILL] = '\0';
+       if (tcsetattr(fd232, TCSANOW, ttyp) < 0) {
+               msyslog(LOG_ERR, "msfees_start: tcsetattr(%s): %m", eesdev);
+               goto screwed;
+       }
+
+       if (tcflush(fd232, TCIOFLUSH) < 0) {
+               msyslog(LOG_ERR, "msfees_start: tcflush(%s): %m", eesdev);
+               goto screwed;
+       }
+
+       inherent_delay[unit].l_uf = INH_DELAY_PPS;
+
+       /* offset fudge (how *late* the timestamp is) = fudge + os delays */
+       offset_fudge[unit] = os_delay[unit];
+       L_ADD(&offset_fudge[unit], &fudgefactor[unit]);
+       L_ADD(&offset_fudge[unit], &inherent_delay[unit]);
+
+       /* Looks like this might succeed.  Find memory for the structure.
+        * Look to see if there are any unused ones, if not we malloc() one.
+        */
+       if (eesunits[unit] != 0) /* The one we want is okay */
+           ees = eesunits[unit];
+       else {
+               /* Look for an unused, but allocated struct */
+               for (i = 0; i < MAXUNITS; i++) {
+                       if (!unitinuse[i] && eesunits[i] != 0)
+                           break;
+               }
+
+               if (i < MAXUNITS) {     /* Reclaim this one */
+                       ees = eesunits[i];
+                       eesunits[i] = 0;
+               }                       /* no spare -- make a new one */
+               else ees = (struct eesunit *) emalloc(sizeof(struct eesunit));
+       }
+       memset((char *)ees, 0, sizeof(struct eesunit));
+       eesunits[unit] = ees;
+
+       /* Set up the structures */
+       ees->peer       = peer;
+       ees->unit       = (u_char)unit;
+       ees->timestarted= current_time;
+       ees->ttytype    = 0;
+       ees->io.clock_recv= ees_receive;
+       ees->io.srcclock= (caddr_t)ees;
+       ees->io.datalen = 0;
+       ees->io.fd      = fd232;
+
+       /* Okay.  Push one of the two (linked into the kernel, or dynamically
+        * loaded) STREAMS module, and give it to the I/O code to start
+        * receiving stuff.
+        */
+
+#ifdef STREAM
+       {
+               int rc1;
+               /* Pop any existing onews first ... */
+               while (ioctl(fd232, I_POP, 0 ) >= 0) ;
+
+               /* Now try pushing either of the possible modules */
+               if ((rc1=ioctl(fd232, I_PUSH, STREAM_PP1)) < 0 &&
+                   ioctl(fd232, I_PUSH, STREAM_PP2) < 0) {
+                       msyslog(LOG_ERR,
+                               "ees clock: Push of `%s' and `%s' to %s failed %m",
+                               STREAM_PP1, STREAM_PP2, eesdev);
+                       goto screwed;
+               }
+               else {
+                       NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
+                               msyslog(LOG_INFO, "I: ees clock: PUSHed %s on %s",
+                                       (rc1 >= 0) ? STREAM_PP1 : STREAM_PP2, eesdev);
+                       ees->ttytype |= T_PPS;
+               }
+       }
+#endif /* STREAM */
+
+       /* Add the clock */
+       if (!io_addclock(&ees->io)) {
+               /* Oh shit.  Just close and return. */
+               msyslog(LOG_ERR, "ees clock: io_addclock(%s): %m", eesdev);
+               goto screwed;
+       }
+
+
+       /* All done.  Initialize a few random peer variables, then
+        * return success. */
+       peer->precision = sys_precision;
+       peer->stratum   = stratumtouse[unit];
+       if (stratumtouse[unit] <= 1) {
+               memcpy((char *)&pp->refid, EESREFID, 4);
+               if (unit > 0 && unit < 10)
+                   ((char *)&pp->refid)[3] = '0' + unit;
+       } else {
+               peer->refid = htonl(EESHSREFID);
+       }
+       unitinuse[unit] = 1;
+       pp->unitptr = (caddr_t) &eesunits[unit];
+       pp->clockdesc = EESDESCRIPTION;
+       msyslog(LOG_ERR, "ees clock: %s OK on %d", eesdev, unit);
+       return (1);
+
+    screwed:
+       if (fd232 != -1)
+           (void) close(fd232);
+       return (0);
+}
+
+
+/* msfees_shutdown - shut down a EES clock */
+static void
+msfees_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct eesunit *ees;
+
+       if (unit >= MAXUNITS) {
+               msyslog(LOG_ERR,
+                       "ees clock: INTERNAL ERROR, unit number %d invalid (max %d)",
+                       unit, MAXUNITS);
+               return;
+       }
+       if (!unitinuse[unit]) {
+               msyslog(LOG_ERR,
+                       "ees clock: INTERNAL ERROR, unit number %d not in use", unit);
+               return;
+       }
+
+       /* Tell the I/O module to turn us off.  We're history. */
+       ees = eesunits[unit];
+       io_closeclock(&ees->io);
+       unitinuse[unit] = 0;
+}
+
+
+/* ees_report_event - note the occurance of an event */
+static void
+ees_report_event(
+       struct eesunit *ees,
+       int code
+       )
+{
+       if (ees->status != (u_char)code) {
+               ees->status = (u_char)code;
+               if (code != CEVNT_NOMINAL)
+                   ees->lastevent = (u_char)code;
+               /* Should report event to trap handler in here.
+                * Soon...
+                */
+       }
+}
+
+
+/* ees_receive - receive data from the serial interface on an EES clock */
+static void
+ees_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register int n_sample;
+       register int day;
+       register struct eesunit *ees;
+       register u_char *dpt;           /* Data PoinTeR: move along ... */
+       register u_char *dpend;         /* Points just *after* last data char */
+       register char *cp;
+       l_fp tmp;
+       int call_pps_sample = 0;
+       l_fp pps_arrvstamp;
+       int     sincelast;
+       int     pps_step = 0;
+       int     suspect_4ms_step = 0;
+       struct ppsclockev ppsclockev;
+       long *ptr = (long *) &ppsclockev;
+       int rc;
+       int request;
+#ifdef HAVE_CIOGETEV
+       request = CIOGETEV;
+#endif
+#ifdef HAVE_TIOCGPPSEV
+       request = TIOCGPPSEV;
+#endif
+
+       /* Get the clock this applies to and a pointer to the data */
+       ees = (struct eesunit *)rbufp->recv_srcclock;
+       dpt = (u_char *)&rbufp->recv_space;
+       dpend = dpt + rbufp->recv_length;
+       if ((dbg & DB_LOG_AWAITMORE) && (rbufp->recv_length != LENEESCODE))
+           printf("[%d] ", rbufp->recv_length);
+
+       /* Check out our state and process appropriately */
+       switch (ees->codestate) {
+           case EESCS_WAIT:
+               /* Set an initial guess at the timestamp as the recv time.
+                * If just running in CBREAK mode, we can't improve this.
+                * If we have the CLOCK Line Discipline, PPSCD, or sime such,
+                * then we will do better later ....
+                */
+               ees->arrvtime = rbufp->recv_time;
+               ees->codestate = EESCS_GOTSOME;
+               ees->lencode = 0;
+               /*FALLSTHROUGH*/
+
+           case EESCS_GOTSOME:
+               cp = &(ees->lastcode[ees->lencode]);
+
+               /* Gobble the bytes until the final (possibly stripped) 0xff */
+               while (dpt < dpend && (*dpt & 0x7f) != 0x7f) {
+                       *cp++ = (char)*dpt++;
+                       ees->lencode++;
+                       /* Oh dear -- too many bytes .. */
+                       if (ees->lencode > LENEESPRT) {
+                               NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
+                                       msyslog(LOG_INFO,
+                                               "I: ees clock: %d + %d > %d [%02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x %02x]",
+                                               ees->lencode, dpend - dpt, LENEESPRT,
+#define D(x) (ees->lastcode[x])
+                                               D(0), D(1), D(2), D(3), D(4), D(5), D(6),
+                                               D(7), D(8), D(9), D(10), D(11), D(12));
+#undef D
+                               ees->badformat++;
+                               ees->reason = CODEREASON + 1;
+                               ees_event(ees, CEVNT_BADREPLY);
+                               ees_reset(ees);
+                               return;
+                       }
+               }
+               /* Gave up because it was end of the buffer, rather than ff */
+               if (dpt == dpend) {
+                       /* Incomplete.  Wait for more. */
+                       if (dbg & DB_LOG_AWAITMORE)
+                           msyslog(LOG_INFO,
+                                   "I: ees clock %d: %p == %p: await more",
+                                   ees->unit, dpt, dpend);
+                       return;
+               }
+
+               /* This shouldn't happen ... ! */
+               if ((*dpt & 0x7f) != 0x7f) {
+                       msyslog(LOG_INFO, "I: ees clock: %0x & 0x7f != 0x7f", *dpt);
+                       ees->badformat++;
+                       ees->reason = CODEREASON + 2;
+                       ees_event(ees, CEVNT_BADREPLY);
+                       ees_reset(ees);
+                       return;
+               }
+
+               /* Skip the 0xff */
+               dpt++;
+
+               /* Finally, got a complete buffer.  Mainline code will
+                * continue on. */
+               cp = ees->lastcode;
+               break;
+
+           default:
+               msyslog(LOG_ERR, "ees clock: INTERNAL ERROR: %d state %d",
+                       ees->unit, ees->codestate);
+               ees->reason = CODEREASON + 5;
+               ees_event(ees, CEVNT_FAULT);
+               ees_reset(ees);
+               return;
+       }
+
+       /* Boy!  After all that crap, the lastcode buffer now contains
+        * something we hope will be a valid time code.  Do length
+        * checks and sanity checks on constant data.
+        */
+       ees->codestate = EESCS_WAIT;
+       ees->lasttime = current_time;
+       if (ees->lencode != LENEESPRT) {
+               ees->badformat++;
+               ees->reason = CODEREASON + 6;
+               ees_event(ees, CEVNT_BADREPLY);
+               ees_reset(ees);
+               return;
+       }
+
+       cp = ees->lastcode;
+
+       /* Check that centisecond is zero */
+       if (cp[EESM_CSEC] != 0) {
+               ees->baddata++;
+               ees->reason = CODEREASON + 7;
+               ees_event(ees, CEVNT_BADREPLY);
+               ees_reset(ees);
+               return;
+       }
+
+       /* Check flag formats */
+       if (cp[EESM_LEAP] != 0 && cp[EESM_LEAP] != 0x0f) {
+               ees->badformat++;
+               ees->reason = CODEREASON + 8;
+               ees_event(ees, CEVNT_BADREPLY);
+               ees_reset(ees);
+               return;
+       }
+
+       if (cp[EESM_BST] != 0 && cp[EESM_BST] != 0x03) {
+               ees->badformat++;
+               ees->reason = CODEREASON + 9;
+               ees_event(ees, CEVNT_BADREPLY);
+               ees_reset(ees);
+               return;
+       }
+
+       if (cp[EESM_MSFOK] != 0 && cp[EESM_MSFOK] != 0x3f) {
+               ees->badformat++;
+               ees->reason = CODEREASON + 10;
+               ees_event(ees, CEVNT_BADREPLY);
+               ees_reset(ees);
+               return;
+       }
+
+       /* So far, so good.  Compute day, hours, minutes, seconds,
+        * time zone.  Do range checks on these.
+        */
+
+#define bcdunpack(val) ( (((val)>>4) & 0x0f) * 10 + ((val) & 0x0f) )
+#define istrue(x)      ((x)?1:0)
+
+       ees->second  = bcdunpack(cp[EESM_SEC]);  /* second       */
+       ees->minute  = bcdunpack(cp[EESM_MIN]);  /* minute       */
+       ees->hour    = bcdunpack(cp[EESM_HOUR]); /* hour         */
+
+       day          = bcdunpack(cp[EESM_DAY]);  /* day of month */
+
+       switch (bcdunpack(cp[EESM_MON])) {       /* month        */
+
+               /*  Add in lengths of all previous months.  Add one more
+                   if it is a leap year and after February.
+               */
+           case 12:    day += NOV;                       /*FALLSTHROUGH*/
+           case 11:    day += OCT;                       /*FALLSTHROUGH*/
+           case 10:    day += SEP;                       /*FALLSTHROUGH*/
+           case  9:    day += AUG;                       /*FALLSTHROUGH*/
+           case  8:    day += JUL;                       /*FALLSTHROUGH*/
+           case  7:    day += JUN;                       /*FALLSTHROUGH*/
+           case  6:    day += MAY;                       /*FALLSTHROUGH*/
+           case  5:    day += APR;                       /*FALLSTHROUGH*/
+           case  4:    day += MAR;                       /*FALLSTHROUGH*/
+           case  3:    day += FEB;
+               if (istrue(cp[EESM_LEAP])) day++; /*FALLSTHROUGH*/
+           case  2:    day += JAN;                       /*FALLSTHROUGH*/
+           case  1:    break;
+           default:    ees->baddata++;
+               ees->reason = CODEREASON + 11;
+               ees_event(ees, CEVNT_BADDATE);
+               ees_reset(ees);
+               return;
+       }
+
+       ees->day     = day;
+
+       /* Get timezone. The clocktime routine wants the number
+        * of hours to add to the delivered time to get UT.
+        * Currently -1 if BST flag set, 0 otherwise.  This
+        * is the place to tweak things if double summer time
+        * ever happens.
+        */
+       ees->tz      = istrue(cp[EESM_BST]) ? -1 : 0;
+
+       if (ees->day > 366 || ees->day < 1 ||
+           ees->hour > 23 || ees->minute > 59 || ees->second > 59) {
+               ees->baddata++;
+               ees->reason = CODEREASON + 12;
+               ees_event(ees, CEVNT_BADDATE);
+               ees_reset(ees);
+               return;
+       }
+
+       n_sample = ees->nsamples;
+
+       /* Now, compute the reference time value: text -> tmp.l_ui */
+       if (!clocktime(ees->day, ees->hour, ees->minute, ees->second,
+                      ees->tz, rbufp->recv_time.l_ui, &ees->yearstart,
+                      &tmp.l_ui)) {
+               ees->baddata++;
+               ees->reason = CODEREASON + 13;
+               ees_event(ees, CEVNT_BADDATE);
+               ees_reset(ees);
+               return;
+       }
+       tmp.l_uf = 0;
+
+       /*  DON'T use ees->arrvtime -- it may be < reftime */
+       ees->lastsampletime = tmp;
+
+       /* If we are synchronised to the radio, update the reference time.
+        * Also keep a note of when clock was last good.
+        */
+       if (istrue(cp[EESM_MSFOK])) {
+               ees->reftime = tmp;
+               ees->clocklastgood = current_time;
+       }
+
+
+       /* Compute the offset.  For the fractional part of the
+        * offset we use the expected delay for the message.
+        */
+       ees->codeoffsets[n_sample].l_ui = tmp.l_ui;
+       ees->codeoffsets[n_sample].l_uf = 0;
+
+       /* Number of seconds since the last step */
+       sincelast = this_uisec - ees->last_step;
+
+       memset((char *) &ppsclockev, 0, sizeof ppsclockev);
+
+       rc = ioctl(ees->io.fd, request, (char *) &ppsclockev);
+       if (dbg & DB_PRINT_EV) fprintf(stderr,
+                                        "[%x] CIOGETEV u%d %d (%x %d) gave %d (%d): %08lx %08lx %ld\n",
+                                        DB_PRINT_EV, ees->unit, ees->io.fd, request, is_pps(ees),
+                                        rc, errno, ptr[0], ptr[1], ptr[2]);
+
+       /* If we managed to get the time of arrival, process the info */
+       if (rc >= 0) {
+               int conv = -1;
+               pps_step = ppsclockev.serial - ees->last_pps_no;
+
+               /* Possible that PPS triggered, but text message didn't */
+               if (pps_step == 2) msyslog(LOG_ERR, "pps step = 2 @ %02d", ees->second);
+               if (pps_step == 2 && ees->second == 1) suspect_4ms_step |= 1;
+               if (pps_step == 2 && ees->second == 2) suspect_4ms_step |= 4;
+
+               /* allow for single loss of PPS only */
+               if (pps_step != 1 && pps_step != 2)
+                   fprintf(stderr, "PPS step: %d too far off %ld (%d)\n",
+                           ppsclockev.serial, ees->last_pps_no, pps_step);
+               else if (!buftvtots((char *) &(ppsclockev.tv), &pps_arrvstamp))
+                   fprintf(stderr, "buftvtots failed\n");
+               else {  /* if ((ABS(time difference) - 0.25) < 0)
+                        * then believe it ...
+                        */
+                       l_fp diff;
+                       diff = pps_arrvstamp;
+                       conv = 0;
+                       L_SUB(&diff, &ees->arrvtime);
+                       if (dbg & DB_PRINT_CDT)
+                           printf("[%x] Have %lx.%08lx and %lx.%08lx -> %lx.%08lx @ %s",
+                                  DB_PRINT_CDT, (long)ees->arrvtime.l_ui, (long)ees->arrvtime.l_uf,
+                                  (long)pps_arrvstamp.l_ui, (long)pps_arrvstamp.l_uf,
+                                  (long)diff.l_ui, (long)diff.l_uf,
+                                  ctime(&(ppsclockev.tv.tv_sec)));
+                       if (L_ISNEG(&diff)) M_NEG(diff.l_ui, diff.l_uf);
+                       L_SUB(&diff, &acceptable_slop);
+                       if (L_ISNEG(&diff)) {   /* AOK -- pps_sample */
+                               ees->arrvtime = pps_arrvstamp;
+                               conv++;
+                               call_pps_sample++;
+                       }
+                       /* Some loss of some signals around sec = 1 */
+                       else if (ees->second == 1) {
+                               diff = pps_arrvstamp;
+                               L_ADD(&diff, &onesec);
+                               L_SUB(&diff, &ees->arrvtime);
+                               if (L_ISNEG(&diff)) M_NEG(diff.l_ui, diff.l_uf);
+                               L_SUB(&diff, &acceptable_slop);
+                               msyslog(LOG_ERR, "Have sec==1 slip %ds a=%08x-p=%08x -> %x.%08x (u=%d) %s",
+                                       pps_arrvstamp.l_ui - ees->arrvtime.l_ui,
+                                       pps_arrvstamp.l_uf,
+                                       ees->arrvtime.l_uf,
+                                       diff.l_ui, diff.l_uf,
+                                       (int)ppsclockev.tv.tv_usec,
+                                       ctime(&(ppsclockev.tv.tv_sec)));
+                               if (L_ISNEG(&diff)) {   /* AOK -- pps_sample */
+                                       suspect_4ms_step |= 2;
+                                       ees->arrvtime = pps_arrvstamp;
+                                       L_ADD(&ees->arrvtime, &onesec);
+                                       conv++;
+                                       call_pps_sample++;
+                               }
+                       }
+               }
+               ees->last_pps_no = ppsclockev.serial;
+               if (dbg & DB_PRINT_CDTC)
+                   printf(
+                           "[%x] %08lx %08lx %d u%d (%d %d)\n",
+                           DB_PRINT_CDTC, (long)pps_arrvstamp.l_ui,
+                           (long)pps_arrvstamp.l_uf, conv, ees->unit,
+                           call_pps_sample, pps_step);
+       }
+
+       /* See if there has been a 4ms jump at a minute boundry */
+       {       l_fp    delta;
+#define        delta_isec      delta.l_ui
+#define        delta_ssec      delta.l_i
+#define        delta_sfsec     delta.l_f
+       long    delta_f_abs;
+
+       delta.l_i = ees->arrvtime.l_i;
+       delta.l_f = ees->arrvtime.l_f;
+
+       L_SUB(&delta, &ees->last_l);
+       delta_f_abs = delta_sfsec;
+       if (delta_f_abs < 0) delta_f_abs = -delta_f_abs;
+
+       /* Dump the deltas each minute */
+       if (dbg & DB_DUMP_DELTAS)
+       {       if (/*0 <= ees->second && */
+               ees->second < ((sizeof deltas) / (sizeof deltas[0]))) deltas[ees->second] = delta_sfsec;
+       /* Dump on second 1, as second 0 sometimes missed */
+       if (ees->second == 1) {
+               char text[16 * ((sizeof deltas) / (sizeof deltas[0]))];
+               char *cptr=text;
+               int i;
+               for (i=0; i<((sizeof deltas) / (sizeof deltas[0])); i++) {
+                       sprintf(cptr, " %d.%04d",
+                               msec(deltas[i]), subms(deltas[i]));
+                       while (*cptr) cptr++;
+               }
+               msyslog(LOG_ERR, "Deltas: %d.%04d<->%d.%04d: %s",
+                       msec(EES_STEP_F - EES_STEP_F_GRACE), subms(EES_STEP_F - EES_STEP_F_GRACE),
+                       msec(EES_STEP_F + EES_STEP_F_GRACE), subms(EES_STEP_F + EES_STEP_F_GRACE),
+                       text+1);
+               for (i=0; i<((sizeof deltas) / (sizeof deltas[0])); i++) deltas[i] = 0;
+       }
+       }
+
+       /* Lets see if we have a 4 mS step at a minute boundaary */
+       if (    ((EES_STEP_F - EES_STEP_F_GRACE) < delta_f_abs) &&
+               (delta_f_abs < (EES_STEP_F + EES_STEP_F_GRACE)) &&
+               (ees->second == 0 || ees->second == 1 || ees->second == 2) &&
+               (sincelast < 0 || sincelast > 122)
+               ) {     /* 4ms jump at min boundry */
+               int old_sincelast;
+               int count=0;
+               int sum = 0;
+               /* Yes -- so compute the ramp time */
+               if (ees->last_step == 0) sincelast = 0;
+               old_sincelast = sincelast;
+
+               /* First time in, just set "ees->last_step" */
+               if(ees->last_step) {
+                       int other_step = 0;
+                       int third_step = 0;
+                       int this_step = (sincelast + (60 /2)) / 60;
+                       int p_step = ees->this_step;
+                       int p;
+                       ees->last_steps[p_step] = this_step;
+                       p= p_step;
+                       p_step++;
+                       if (p_step >= LAST_STEPS) p_step = 0;
+                       ees->this_step = p_step;
+                               /* Find the "average" interval */
+                       while (p != p_step) {
+                               int this = ees->last_steps[p];
+                               if (this == 0) break;
+                               if (this != this_step) {
+                                       if (other_step == 0 && (
+                                               this== (this_step +2) ||
+                                               this== (this_step -2) ||
+                                               this== (this_step +1) ||
+                                               this== (this_step -1)))
+                                           other_step = this;
+                                       if (other_step != this) {
+                                               int idelta = (this_step - other_step);
+                                               if (idelta < 0) idelta = - idelta;
+                                               if (third_step == 0 && (
+                                                       (idelta == 1) ? (
+                                                               this == (other_step +1) ||
+                                                               this == (other_step -1) ||
+                                                               this == (this_step +1) ||
+                                                               this == (this_step -1))
+                                                       :
+                                                       (
+                                                               this == (this_step + other_step)/2
+                                                               )
+                                                       )) third_step = this;
+                                               if (third_step != this) break;
+                                       }
+                               }
+                               sum += this;
+                               p--;
+                               if (p < 0) p += LAST_STEPS;
+                               count++;
+                       }
+                       msyslog(LOG_ERR, "MSF%d: %d: This=%d (%d), other=%d/%d, sum=%d, count=%d, pps_step=%d, suspect=%x", ees->unit, p, ees->last_steps[p], this_step, other_step, third_step, sum, count, pps_step, suspect_4ms_step);
+                       if (count != 0) sum = ((sum * 60) + (count /2)) / count;
+#define        SV(x) (ees->last_steps[(x + p_step) % LAST_STEPS])
+                       msyslog(LOG_ERR, "MSF%d: %x steps %d: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d",
+                               ees->unit, suspect_4ms_step, p_step, SV(0), SV(1), SV(2), SV(3), SV(4), SV(5), SV(6),
+                               SV(7), SV(8), SV(9), SV(10), SV(11), SV(12), SV(13), SV(14), SV(15));
+                       printf("MSF%d: steps %d: %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d %d\n",
+                              ees->unit, p_step, SV(0), SV(1), SV(2), SV(3), SV(4), SV(5), SV(6),
+                              SV(7), SV(8), SV(9), SV(10), SV(11), SV(12), SV(13), SV(14), SV(15));
+#undef SV
+                       ees->jump_fsecs = delta_sfsec;
+                       ees->using_ramp = 1;
+                       if (sincelast > 170)
+                           ees->last_step_late += sincelast - ((sum) ? sum : ees->last_step_secs);
+                       else ees->last_step_late = 30;
+                       if (ees->last_step_late < -60 || ees->last_step_late > 120) ees->last_step_late = 30;
+                       if (ees->last_step_late < 0) ees->last_step_late = 0;
+                       if (ees->last_step_late >= 60) ees->last_step_late = 59;
+                       sincelast = 0;
+               }
+               else {  /* First time in -- just save info */
+                       ees->last_step_late = 30;
+                       ees->jump_fsecs = delta_sfsec;
+                       ees->using_ramp = 1;
+                       sum = 4 * 60;
+               }
+               ees->last_step = this_uisec;
+               printf("MSF%d: d=%3ld.%04ld@%d :%d:%d:$%d:%d:%d\n",
+                      ees->unit, (long)msec(delta_sfsec), (long)subms(delta_sfsec),
+                      ees->second, old_sincelast, ees->last_step_late, count, sum,
+                      ees->last_step_secs);
+               msyslog(LOG_ERR, "MSF%d: d=%3d.%04d@%d :%d:%d:%d:%d:%d",
+                       ees->unit, msec(delta_sfsec), subms(delta_sfsec), ees->second,
+                       old_sincelast, ees->last_step_late, count, sum, ees->last_step_secs);
+               if (sum) ees->last_step_secs = sum;
+       }
+       /* OK, so not a 4ms step at a minute boundry */
+       else {
+               if (suspect_4ms_step) msyslog(LOG_ERR,
+                                             "MSF%d: suspect = %x, but delta of %d.%04d [%d.%04d<%d.%04d<%d.%04d: %d %d]",
+                                             ees->unit, suspect_4ms_step, msec(delta_sfsec), subms(delta_sfsec),
+                                             msec(EES_STEP_F - EES_STEP_F_GRACE),
+                                             subms(EES_STEP_F - EES_STEP_F_GRACE),
+                                             (int)msec(delta_f_abs),
+                                             (int)subms(delta_f_abs),
+                                             msec(EES_STEP_F + EES_STEP_F_GRACE),
+                                             subms(EES_STEP_F + EES_STEP_F_GRACE),
+                                             ees->second,
+                                             sincelast);
+               if ((delta_f_abs > EES_STEP_NOTE) && ees->last_l.l_i) {
+                       static int ees_step_notes = EES_STEP_NOTES;
+                       if (ees_step_notes > 0) {
+                               ees_step_notes--;
+                               printf("MSF%d: D=%3ld.%04ld@%02d :%d%s\n",
+                                      ees->unit, (long)msec(delta_sfsec), (long)subms(delta_sfsec),
+                                      ees->second, sincelast, ees_step_notes ? "" : " -- NO MORE !");
+                               msyslog(LOG_ERR, "MSF%d: D=%3d.%04d@%02d :%d%s",
+                                       ees->unit, msec(delta_sfsec), subms(delta_sfsec), ees->second, (ees->last_step) ? sincelast : -1, ees_step_notes ? "" : " -- NO MORE !");
+                       }
+               }
+       }
+       }
+       ees->last_l = ees->arrvtime;
+
+       /* IF we have found that it's ramping
+        * && it's within twice the expected ramp period
+        * && there is a non zero step size (avoid /0 !)
+        * THEN we twiddle things
+        */
+       if (ees->using_ramp &&
+           sincelast < (ees->last_step_secs)*2 &&
+           ees->last_step_secs)
+       {       long    sec_of_ramp = sincelast + ees->last_step_late;
+       long    fsecs;
+       l_fp    inc;
+
+       /* Ramp time may vary, so may ramp for longer than last time */
+       if (sec_of_ramp > (ees->last_step_secs + 120))
+           sec_of_ramp =  ees->last_step_secs;
+
+       /* sec_of_ramp * ees->jump_fsecs may overflow 2**32 */
+       fsecs = sec_of_ramp * (ees->jump_fsecs /  ees->last_step_secs);
+
+       if (dbg & DB_LOG_DELTAS) msyslog(LOG_ERR,
+                                          "[%x] MSF%d: %3ld/%03d -> d=%11ld (%d|%ld)",
+                                          DB_LOG_DELTAS,
+                                          ees->unit, sec_of_ramp, ees->last_step_secs, fsecs,
+                                          pps_arrvstamp.l_f, pps_arrvstamp.l_f + fsecs);
+       if (dbg & DB_PRINT_DELTAS) printf(
+               "MSF%d: %3ld/%03d -> d=%11ld (%ld|%ld)\n",
+               ees->unit, sec_of_ramp, ees->last_step_secs, fsecs,
+               (long)pps_arrvstamp.l_f, pps_arrvstamp.l_f + fsecs);
+
+       /* Must sign extend the result */
+       inc.l_i = (fsecs < 0) ? -1 : 0;
+       inc.l_f = fsecs;
+       if (dbg & DB_INC_PPS)
+       {       L_SUB(&pps_arrvstamp, &inc);
+       L_SUB(&ees->arrvtime, &inc);
+       }
+       else
+       {       L_ADD(&pps_arrvstamp, &inc);
+       L_ADD(&ees->arrvtime, &inc);
+       }
+       }
+       else {
+               if (dbg & DB_LOG_DELTAS) msyslog(LOG_ERR,
+                                                  "[%x] MSF%d: ees->using_ramp=%d, sincelast=%x / %x, ees->last_step_secs=%x",
+                                                  DB_LOG_DELTAS,
+                                                  ees->unit, ees->using_ramp,
+                                                  sincelast,
+                                                  (ees->last_step_secs)*2,
+                                                  ees->last_step_secs);
+               if (dbg & DB_PRINT_DELTAS) printf(
+                       "[%x] MSF%d: ees->using_ramp=%d, sincelast=%x / %x, ees->last_step_secs=%x\n",
+                       DB_LOG_DELTAS,
+                       ees->unit, ees->using_ramp,
+                       sincelast,
+                       (ees->last_step_secs)*2,
+                       ees->last_step_secs);
+       }
+
+       L_SUB(&ees->arrvtime, &offset_fudge[ees->unit]);
+       L_SUB(&pps_arrvstamp, &offset_fudge[ees->unit]);
+
+       if (call_pps_sample && !(dbg & DB_NO_PPS)) {
+               /* Sigh -- it expects its args negated */
+               L_NEG(&pps_arrvstamp);
+               /*
+                * I had to disable this here, since it appears there is no pointer to the
+                * peer structure.
+                *
+                (void) pps_sample(peer, &pps_arrvstamp);
+               */
+       }
+
+       /* Subtract off the local clock time stamp */
+       L_SUB(&ees->codeoffsets[n_sample], &ees->arrvtime);
+       if (dbg & DB_LOG_SAMPLES) msyslog(LOG_ERR,
+                                           "MSF%d: [%x] %d (ees: %d %d) (pps: %d %d)%s",
+                                           ees->unit, DB_LOG_DELTAS, n_sample,
+                                           ees->codeoffsets[n_sample].l_f,
+                                           ees->codeoffsets[n_sample].l_f / 4295,
+                                           pps_arrvstamp.l_f,
+                                           pps_arrvstamp.l_f /4295,
+                                           (dbg & DB_NO_PPS) ? " [no PPS]" : "");
+
+       if (ees->nsamples++ == NCODES-1) ees_process(ees);
+
+       /* Done! */
+}
+
+
+/* offcompare - auxiliary comparison routine for offset sort */
+
+#ifdef QSORT_USES_VOID_P
+static int
+offcompare(
+       const void *va,
+       const void *vb
+       )
+{
+       const l_fp *a = (const l_fp *)va;
+       const l_fp *b = (const l_fp *)vb;
+       return(L_ISGEQ(a, b) ? (L_ISEQU(a, b) ? 0 : 1) : -1);
+}
+#else
+static int
+offcompare(
+       const l_fp *a,
+       const l_fp *b
+       )
+{
+       return(L_ISGEQ(a, b) ? (L_ISEQU(a, b) ? 0 : 1) : -1);
+}
+#endif /* QSORT_USES_VOID_P */
+
+
+/* ees_process - process a pile of samples from the clock */
+static void
+ees_process(
+       struct eesunit *ees
+       )
+{
+       static int last_samples = -1;
+       register int i, j;
+       register int noff;
+       register l_fp *coffs = ees->codeoffsets;
+       l_fp offset, tmp;
+       double dispersion;      /* ++++ */
+       int lostsync, isinsync;
+       int samples = ees->nsamples;
+       int samplelog = 0;      /* keep "gcc -Wall" happy ! */
+       int samplereduce = (samples + 1) / 2;
+       double doffset;
+
+       /* Reset things to zero so we don't have to worry later */
+       ees_reset(ees);
+
+       if (sloppyclockflag[ees->unit]) {
+               samplelog = (samples <  2) ? 0 :
+                       (samples <  5) ? 1 :
+                       (samples <  9) ? 2 :
+                       (samples < 17) ? 3 :
+                       (samples < 33) ? 4 : 5;
+               samplereduce = (1 << samplelog);
+       }
+
+       if (samples != last_samples &&
+           ((samples != (last_samples-1)) || samples < 3)) {
+               msyslog(LOG_ERR, "Samples=%d (%d), samplereduce=%d ....",
+                       samples, last_samples, samplereduce);
+               last_samples = samples;
+       }
+       if (samples < 1) return;
+
+       /* If requested, dump the raw data we have in the buffer */
+       if (ees->dump_vals) dump_buf(coffs, 0, samples, "Raw  data  is:");
+
+       /* Sort the offsets, trim off the extremes, then choose one. */
+       qsort(
+#ifdef QSORT_USES_VOID_P
+           (void *)
+#else
+           (char *)
+#endif
+           coffs, (size_t)samples, sizeof(l_fp), offcompare);
+
+       noff = samples;
+       i = 0;
+       while ((noff - i) > samplereduce) {
+               /* Trim off the sample which is further away
+                * from the median.  We work this out by doubling
+                * the median, subtracting off the end samples, and
+                * looking at the sign of the answer, using the
+                * identity (c-b)-(b-a) == 2*b-a-c
+                */
+               tmp = coffs[(noff + i)/2];
+               L_ADD(&tmp, &tmp);
+               L_SUB(&tmp, &coffs[i]);
+               L_SUB(&tmp, &coffs[noff-1]);
+               if (L_ISNEG(&tmp)) noff--; else i++;
+       }
+
+       /* If requested, dump the reduce data we have in the buffer */
+       if (ees->dump_vals) dump_buf(coffs, i, noff, "Reduced    to:");
+
+       /* What we do next depends on the setting of the sloppy clock flag.
+        * If it is on, average the remainder to derive our estimate.
+        * Otherwise, just pick a representative value from the remaining stuff
+        */
+       if (sloppyclockflag[ees->unit]) {
+               offset.l_ui = offset.l_uf = 0;
+               for (j = i; j < noff; j++)
+                   L_ADD(&offset, &coffs[j]);
+               for (j = samplelog; j > 0; j--)
+                   L_RSHIFTU(&offset);
+       }
+       else offset = coffs[i+BESTSAMPLE];
+
+       /* Compute the dispersion as the difference between the
+        * lowest and highest offsets that remain in the
+        * consideration list.
+        *
+        * It looks like MOST clocks have MOD (max error), so halve it !
+        */
+       tmp = coffs[noff-1];
+       L_SUB(&tmp, &coffs[i]);
+#define        FRACT_SEC(n) ((1 << 30) / (n/2))
+       dispersion = LFPTOFP(&tmp) / 2; /* ++++ */
+       if (dbg & (DB_SYSLOG_SMPLI | DB_SYSLOG_SMPLE)) msyslog(
+               (dbg & DB_SYSLOG_SMPLE) ? LOG_ERR : LOG_INFO,
+               "I: [%x] Offset=%06d (%d), disp=%f%s [%d], %d %d=%d %d:%d %d=%d %d",
+               dbg & (DB_SYSLOG_SMPLI | DB_SYSLOG_SMPLE),
+               offset.l_f / 4295, offset.l_f,
+               (dispersion * 1526) / 100,
+               (sloppyclockflag[ees->unit]) ? " by averaging" : "",
+               FRACT_SEC(10) / 4295,
+               (coffs[0].l_f) / 4295,
+               i,
+               (coffs[i].l_f) / 4295,
+               (coffs[samples/2].l_f) / 4295,
+               (coffs[i+BESTSAMPLE].l_f) / 4295,
+               noff-1,
+               (coffs[noff-1].l_f) / 4295,
+               (coffs[samples-1].l_f) / 4295);
+
+       /* Are we playing silly wotsits ?
+        * If we are using all data, see if there is a "small" delta,
+        * and if so, blurr this with 3/4 of the delta from the last value
+        */
+       if (ees->usealldata && ees->offset.l_uf) {
+               long diff = (long) (ees->offset.l_uf - offset.l_uf);
+
+               /* is the delta small enough ? */
+               if ((- FRACT_SEC(100)) < diff && diff < FRACT_SEC(100)) {
+                       int samd = (64 * 4) / samples;
+                       long new;
+                       if (samd < 2) samd = 2;
+                       new = offset.l_uf + ((diff * (samd -1)) / samd);
+
+                       /* Sign change -> need to fix up int part */
+                       if ((new & 0x80000000) !=
+                           (((long) offset.l_uf) & 0x80000000))
+                       {       NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
+                                       msyslog(LOG_INFO, "I: %lx != %lx (%lx %lx), so add %d",
+                                               new & 0x80000000,
+                                               ((long) offset.l_uf) & 0x80000000,
+                                               new, (long) offset.l_uf,
+                                               (new < 0) ? -1 : 1);
+                               offset.l_ui += (new < 0) ? -1 : 1;
+                       }
+                       dispersion /= 4;
+                       if (dbg & (DB_SYSLOG_SMTHI | DB_SYSLOG_SMTHE)) msyslog(
+                               (dbg & DB_SYSLOG_SMTHE) ? LOG_ERR : LOG_INFO,
+                               "I: [%x] Smooth data: %ld -> %ld, dispersion now %f",
+                               dbg & (DB_SYSLOG_SMTHI | DB_SYSLOG_SMTHE),
+                               ((long) offset.l_uf) / 4295, new / 4295,
+                               (dispersion * 1526) / 100);
+                       offset.l_uf = (unsigned long) new;
+               }
+               else if (dbg & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE)) msyslog(
+                       (dbg & DB_SYSLOG_NSMTHE) ? LOG_ERR : LOG_INFO,
+                       "[%x] No smooth as delta not %d < %ld < %d",
+                       dbg & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE),
+                       - FRACT_SEC(100), diff, FRACT_SEC(100));
+       }
+       else if (dbg & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE)) msyslog(
+               (dbg & DB_SYSLOG_NSMTHE) ? LOG_ERR : LOG_INFO,
+               "I: [%x] No smooth as flag=%x and old=%x=%d (%d:%d)",
+               dbg & (DB_SYSLOG_NSMTHI | DB_SYSLOG_NSMTHE),
+               ees->usealldata, ees->offset.l_f, ees->offset.l_uf,
+               offset.l_f, ees->offset.l_f - offset.l_f);
+
+       /* Collect offset info for debugging info */
+       ees->offset = offset;
+       ees->lowoffset = coffs[i];
+       ees->highoffset = coffs[noff-1];
+
+       /* Determine synchronization status.  Can be unsync'd either
+        * by a report from the clock or by a leap hold.
+        *
+        * Loss of the radio signal for a short time does not cause
+        * us to go unsynchronised, since the receiver keeps quite
+        * good time on its own.  The spec says 20ms in 4 hours; the
+        * observed drift in our clock (Cambridge) is about a second
+        * a day, but even that keeps us within the inherent tolerance
+        * of the clock for about 15 minutes. Observation shows that
+        * the typical "short" outage is 3 minutes, so to allow us
+        * to ride out those, we will give it 5 minutes.
+        */
+       lostsync = current_time - ees->clocklastgood > 300 ? 1 : 0;
+       isinsync = (lostsync || ees->leaphold > current_time) ? 0 : 1;
+
+       /* Done.  Use time of last good, synchronised code as the
+        * reference time, and lastsampletime as the receive time.
+        */
+       if (ees->fix_pending) {
+               msyslog(LOG_ERR, "MSF%d: fix_pending=%d -> jump %x.%08x\n",
+                       ees->fix_pending, ees->unit, offset.l_i, offset.l_f);
+               ees->fix_pending = 0;
+       }
+       LFPTOD(&offset, doffset);
+       refclock_receive(ees->peer);
+       ees_event(ees, lostsync ? CEVNT_PROP : CEVNT_NOMINAL);
+}
+
+/* msfees_poll - called by the transmit procedure */
+static void
+msfees_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       if (unit >= MAXUNITS) {
+               msyslog(LOG_ERR, "ees clock poll: INTERNAL: unit %d invalid",
+                       unit);
+               return;
+       }
+       if (!unitinuse[unit]) {
+               msyslog(LOG_ERR, "ees clock poll: INTERNAL: unit %d unused",
+                       unit);
+               return;
+       }
+
+       ees_process(eesunits[unit]);
+
+       if ((current_time - eesunits[unit]->lasttime) > 150)
+           ees_event(eesunits[unit], CEVNT_FAULT);
+}
+
+
+#else
+int refclock_msfees_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_mx4200.c b/ntpd/refclock_mx4200.c
new file mode 100644 (file)
index 0000000..68150b7
--- /dev/null
@@ -0,0 +1,1652 @@
+/*
+ * This software was developed by the Computer Systems Engineering group
+ * at Lawrence Berkeley Laboratory under DARPA contract BG 91-66.
+ *
+ * Copyright (c) 1992 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 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, Lawrence Berkeley Laboratory.
+ * 4. The name of the University may not 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.
+ */
+
+/*
+ * Modified: Marc Brett <marc.brett@westgeo.com>   Sept, 1999.
+ *
+ * 1. Added support for alternate PPS schemes, with code mostly
+ *    copied from the Oncore driver (Thanks, Poul-Henning Kamp).
+ *    This code runs on SunOS 4.1.3 with ppsclock-1.6a1 and Solaris 7.
+ */
+
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_MX4200) && defined(HAVE_PPSAPI)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include "mx4200.h"
+
+#ifdef HAVE_SYS_TERMIOS_H
+# include <sys/termios.h>
+#endif
+#ifdef HAVE_SYS_PPSCLOCK_H
+# include <sys/ppsclock.h>
+#endif
+
+#include "ntp_sprintf.h"
+
+#ifndef HAVE_STRUCT_PPSCLOCKEV
+struct ppsclockev {
+# ifdef HAVE_STRUCT_TIMESPEC
+       struct timespec tv;
+# else
+       struct timeval tv;
+# endif
+       u_int serial;
+};
+#endif /* ! HAVE_STRUCT_PPSCLOCKEV */
+
+#ifdef HAVE_PPSAPI
+# include "ppsapi_timepps.h"
+#endif /* HAVE_PPSAPI */
+
+/*
+ * This driver supports the Magnavox Model MX 4200 GPS Receiver
+ * adapted to precision timing applications.  It requires the
+ * ppsclock line discipline or streams module described in the
+ * Line Disciplines and Streams Drivers page. It also requires a
+ * gadget box and 1-PPS level converter, such as described in the
+ * Pulse-per-second (PPS) Signal Interfacing page.
+ *
+ * It's likely that other compatible Magnavox receivers such as the
+ * MX 4200D, MX 9212, MX 9012R, MX 9112 will be supported by this code.
+ */
+
+/*
+ * Check this every time you edit the code!
+ */
+#define YEAR_LAST_MODIFIED 2000
+
+/*
+ * GPS Definitions
+ */
+#define        DEVICE          "/dev/gps%d"    /* device name and unit */
+#define        SPEED232        B4800           /* baud */
+
+/*
+ * Radio interface parameters
+ */
+#define        PRECISION       (-18)   /* precision assumed (about 4 us) */
+#define        REFID   "GPS\0"         /* reference id */
+#define        DESCRIPTION     "Magnavox MX4200 GPS Receiver" /* who we are */
+#define        DEFFUDGETIME    0       /* default fudge time (ms) */
+
+#define        SLEEPTIME       32      /* seconds to wait for reconfig to complete */
+
+/*
+ * Position Averaging.
+ */
+#define INTERVAL       1       /* Interval between position measurements (s) */
+#define AVGING_TIME    24      /* Number of hours to average */
+#define NOT_INITIALIZED        -9999.  /* initial pivot longitude */
+
+/*
+ * MX4200 unit control structure.
+ */
+struct mx4200unit {
+       u_int  pollcnt;                 /* poll message counter */
+       u_int  polled;                  /* Hand in a time sample? */
+       u_int  lastserial;              /* last pps serial number */
+       struct ppsclockev ppsev;        /* PPS control structure */
+       double avg_lat;                 /* average latitude */
+       double avg_lon;                 /* average longitude */
+       double avg_alt;                 /* average height */
+       double central_meridian;        /* central meridian */
+       double N_fixes;                 /* Number of position measurements */
+       int    last_leap;               /* leap second warning */
+       u_int  moving;                  /* mobile platform? */
+       u_long sloppyclockflag;         /* fudge flags */
+       u_int  known;                   /* position known yet? */
+       u_long clamp_time;              /* when to stop postion averaging */
+       u_long log_time;                /* when to print receiver status */
+       pps_handle_t    pps_h;
+       pps_params_t    pps_p;
+       pps_info_t      pps_i;
+};
+
+static char pmvxg[] = "PMVXG";
+
+/* XXX should be somewhere else */
+#ifdef __GNUC__
+#if __GNUC__ < 2  || (__GNUC__ == 2 && __GNUC_MINOR__ < 5)
+#ifndef __attribute__
+#define __attribute__(args)
+#endif /* __attribute__ */
+#endif /* __GNUC__ < 2  || (__GNUC__ == 2 && __GNUC_MINOR__ < 5) */
+#else
+#ifndef __attribute__
+#define __attribute__(args)
+#endif /* __attribute__ */
+#endif /* __GNUC__ */
+/* XXX end */
+
+/*
+ * Function prototypes
+ */
+static int     mx4200_start    P((int, struct peer *));
+static void    mx4200_shutdown P((int, struct peer *));
+static void    mx4200_receive  P((struct recvbuf *));
+static void    mx4200_poll     P((int, struct peer *));
+
+static char *  mx4200_parse_t  P((struct peer *));
+static char *  mx4200_parse_p  P((struct peer *));
+static char *  mx4200_parse_s  P((struct peer *));
+#ifdef QSORT_USES_VOID_P
+int    mx4200_cmpl_fp  P((const void *, const void *));
+#else
+int    mx4200_cmpl_fp  P((const l_fp *, const l_fp *));
+#endif /* not QSORT_USES_VOID_P */
+static int     mx4200_config   P((struct peer *));
+static void    mx4200_ref      P((struct peer *));
+static void    mx4200_send     P((struct peer *, char *, ...))
+    __attribute__ ((format (printf, 2, 3)));
+static u_char  mx4200_cksum    P((char *, int));
+static int     mx4200_jday     P((int, int, int));
+static void    mx4200_debug    P((struct peer *, char *, ...))
+    __attribute__ ((format (printf, 2, 3)));
+static int     mx4200_pps      P((struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_mx4200 = {
+       mx4200_start,           /* start up driver */
+       mx4200_shutdown,        /* shut down driver */
+       mx4200_poll,            /* transmit poll message */
+       noentry,                /* not used (old mx4200_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old mx4200_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+
+/*
+ * mx4200_start - open the devices and initialize data for processing
+ */
+static int
+mx4200_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct mx4200unit *up;
+       struct refclockproc *pp;
+       int fd;
+       char gpsdev[20];
+
+       /*
+        * Open serial port
+        */
+       (void)sprintf(gpsdev, DEVICE, unit);
+       if (!(fd = refclock_open(gpsdev, SPEED232, LDISC_PPS))) {
+           return (0);
+       }
+
+       /*
+        * Allocate unit structure
+        */
+       if (!(up = (struct mx4200unit *) emalloc(sizeof(struct mx4200unit)))) {
+               perror("emalloc");
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct mx4200unit));
+       pp = peer->procptr;
+       pp->io.clock_recv = mx4200_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+
+       /* Ensure the receiver is properly configured */
+       return mx4200_config(peer);
+}
+
+
+/*
+ * mx4200_shutdown - shut down the clock
+ */
+static void
+mx4200_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct mx4200unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct mx4200unit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * mx4200_config - Configure the receiver
+ */
+static int
+mx4200_config(
+       struct peer *peer
+       )
+{
+       char tr_mode;
+       int add_mode;
+       register struct mx4200unit *up;
+       struct refclockproc *pp;
+       int mode;
+
+       pp = peer->procptr;
+       up = (struct mx4200unit *)pp->unitptr;
+
+       /*
+        * Initialize the unit variables
+        *
+        * STRANGE BEHAVIOUR WARNING: The fudge flags are not available
+        * at the time mx4200_start is called.  These are set later,
+        * and so the code must be prepared to handle changing flags.
+        */
+       up->sloppyclockflag = pp->sloppyclockflag;
+       if (pp->sloppyclockflag & CLK_FLAG2) {
+               up->moving   = 1;       /* Receiver on mobile platform */
+               msyslog(LOG_DEBUG, "mx4200_config: mobile platform");
+       } else {
+               up->moving   = 0;       /* Static Installation */
+       }
+       up->pollcnt             = 2;
+       up->polled              = 0;
+       up->known               = 0;
+       up->avg_lat             = 0.0;
+       up->avg_lon             = 0.0;
+       up->avg_alt             = 0.0;
+       up->central_meridian    = NOT_INITIALIZED;
+       up->N_fixes             = 0.0;
+       up->last_leap           = 0;    /* LEAP_NOWARNING */
+       up->clamp_time          = current_time + (AVGING_TIME * 60 * 60);
+       up->log_time            = current_time + SLEEPTIME;
+
+       if (time_pps_create(pp->io.fd, &up->pps_h) < 0) {
+               perror("time_pps_create");
+               msyslog(LOG_ERR,
+                       "mx4200_config: time_pps_create failed: %m");
+               return (0);
+       }
+       if (time_pps_getcap(up->pps_h, &mode) < 0) {
+               msyslog(LOG_ERR,
+                       "mx4200_config: time_pps_getcap failed: %m");
+               return (0);
+       }
+
+       if (time_pps_getparams(up->pps_h, &up->pps_p) < 0) {
+               msyslog(LOG_ERR,
+                       "mx4200_config: time_pps_getparams failed: %m");
+               return (0);
+       }
+
+       /* nb. only turn things on, if someone else has turned something
+        *      on before we get here, leave it alone!
+        */
+
+       up->pps_p.mode = PPS_CAPTUREASSERT | PPS_TSFMT_TSPEC;
+       up->pps_p.mode &= mode;         /* only set what is legal */
+
+       if (time_pps_setparams(up->pps_h, &up->pps_p) < 0) {
+               perror("time_pps_setparams");
+               msyslog(LOG_ERR,
+                       "mx4200_config: time_pps_setparams failed: %m");
+               exit(1);
+       }
+
+       if (time_pps_kcbind(up->pps_h, PPS_KC_HARDPPS, PPS_CAPTUREASSERT,
+                       PPS_TSFMT_TSPEC) < 0) {
+               perror("time_pps_kcbind");
+               msyslog(LOG_ERR,
+                       "mx4200_config: time_pps_kcbind failed: %m");
+               exit(1);
+       }
+
+
+       /*
+        * "007" Control Port Configuration
+        * Zero the output list (do it twice to flush possible junk)
+        */
+       mx4200_send(peer, "%s,%03d,,%d,,,,,,", pmvxg,
+           PMVXG_S_PORTCONF,
+           /* control port output block Label */
+           1);         /* clear current output control list (1=yes) */
+       /* add/delete sentences from list */
+       /* must be null */
+       /* sentence output rate (sec) */
+       /* precision for position output */
+       /* nmea version for cga & gll output */
+       /* pass-through control */
+       mx4200_send(peer, "%s,%03d,,%d,,,,,,", pmvxg,
+           PMVXG_S_PORTCONF, 1);
+
+       /*
+        * Request software configuration so we can syslog the firmware version
+        */
+       mx4200_send(peer, "%s,%03d", "CDGPQ", PMVXG_D_SOFTCONF);
+
+       /*
+        * "001" Initialization/Mode Control, Part A
+        * Where ARE we?
+        */
+       mx4200_send(peer, "%s,%03d,,,,,,,,,,", pmvxg,
+           PMVXG_S_INITMODEA);
+       /* day of month */
+       /* month of year */
+       /* year */
+       /* gmt */
+       /* latitude   DDMM.MMMM */
+       /* north/south */
+       /* longitude DDDMM.MMMM */
+       /* east/west */
+       /* height */
+       /* Altitude Reference 1=MSL */
+
+       /*
+        * "001" Initialization/Mode Control, Part B
+        * Start off in 2d/3d coast mode, holding altitude to last known
+        * value if only 3 satellites available.
+        */
+       mx4200_send(peer, "%s,%03d,%d,,%.1f,%.1f,%d,%d,%d,%c,%d",
+           pmvxg, PMVXG_S_INITMODEB,
+           3,          /* 2d/3d coast */
+           /* reserved */
+           0.1,        /* hor accel fact as per Steve (m/s**2) */
+           0.1,        /* ver accel fact as per Steve (m/s**2) */
+           10,         /* vdop */
+           10,         /* hdop limit as per Steve */
+           5,          /* elevation limit as per Steve (deg) */
+           'U',        /* time output mode (UTC) */
+           0);         /* local time offset from gmt (HHHMM) */
+
+       /*
+        * "023" Time Recovery Configuration
+        * Get UTC time from a stationary receiver.
+        * (Set field 1 'D' == dynamic if we are on a moving platform).
+        * (Set field 1 'S' == static  if we are not moving).
+        * (Set field 1 'K' == known position if we can initialize lat/lon/alt).
+        */
+
+       if (pp->sloppyclockflag & CLK_FLAG2)
+               up->moving   = 1;       /* Receiver on mobile platform */
+       else
+               up->moving   = 0;       /* Static Installation */
+
+       up->pollcnt  = 2;
+       if (up->moving) {
+               /* dynamic: solve for pos, alt, time, while moving */
+               tr_mode = 'D';
+       } else {
+               /* static: solve for pos, alt, time, while stationary */
+               tr_mode = 'S';
+       }
+       mx4200_send(peer, "%s,%03d,%c,%c,%c,%d,%d,%d,", pmvxg,
+           PMVXG_S_TRECOVCONF,
+           tr_mode,    /* time recovery mode (see above ) */
+           'U',        /* synchronize to UTC */
+           'A',        /* always output a time pulse */
+           500,        /* max time error in ns */
+           0,          /* user bias in ns */
+           1);         /* output "830" sentences to control port */
+                       /* Multi-satellite mode */
+
+       /*
+        * Output position information (to calculate fixed installation
+        * location) only if we are not moving
+        */
+       if (up->moving) {
+               add_mode = 2;   /* delete from list */
+       } else {
+               add_mode = 1;   /* add to list */
+       }
+
+
+       /*
+        * "007" Control Port Configuration
+        * Output "021" position, height, velocity reports
+        */
+       mx4200_send(peer, "%s,%03d,%03d,%d,%d,,%d,,,", pmvxg,
+           PMVXG_S_PORTCONF,
+           PMVXG_D_PHV, /* control port output block Label */
+           0,          /* clear current output control list (0=no) */
+           add_mode,   /* add/delete sentences from list (1=add, 2=del) */
+                       /* must be null */
+           INTERVAL);  /* sentence output rate (sec) */
+                       /* precision for position output */
+                       /* nmea version for cga & gll output */
+                       /* pass-through control */
+
+       return (1);
+}
+
+/*
+ * mx4200_ref - Reconfigure unit as a reference station at a known position.
+ */
+static void
+mx4200_ref(
+       struct peer *peer
+       )
+{
+       register struct mx4200unit *up;
+       struct refclockproc *pp;
+       double minute, lat, lon, alt;
+       char lats[16], lons[16];
+       char nsc, ewc;
+
+       pp = peer->procptr;
+       up = (struct mx4200unit *)pp->unitptr;
+
+       /* Should never happen! */
+       if (up->moving) return;
+
+       /*
+        * Set up to output status information in the near future
+        */
+       up->log_time    = current_time + SLEEPTIME;
+
+       /*
+        * "007" Control Port Configuration
+        * Stop outputting "021" position, height, velocity reports
+        */
+       mx4200_send(peer, "%s,%03d,%03d,%d,%d,,,,,", pmvxg,
+           PMVXG_S_PORTCONF,
+           PMVXG_D_PHV, /* control port output block Label */
+           0,          /* clear current output control list (0=no) */
+           2);         /* add/delete sentences from list (2=delete) */
+                       /* must be null */
+                       /* sentence output rate (sec) */
+                       /* precision for position output */
+                       /* nmea version for cga & gll output */
+                       /* pass-through control */
+
+       /*
+        * "001" Initialization/Mode Control, Part B
+        * Put receiver in fully-constrained 2d nav mode
+        */
+       mx4200_send(peer, "%s,%03d,%d,,%.1f,%.1f,%d,%d,%d,%c,%d",
+           pmvxg, PMVXG_S_INITMODEB,
+           2,          /* 2d nav */
+           /* reserved */
+           0.1,        /* hor accel fact as per Steve (m/s**2) */
+           0.1,        /* ver accel fact as per Steve (m/s**2) */
+           10,         /* vdop */
+           10,         /* hdop limit as per Steve */
+           5,          /* elevation limit as per Steve (deg) */
+           'U',        /* time output mode (UTC) */
+           0);         /* local time offset from gmt (HHHMM) */
+
+       /*
+        * "023" Time Recovery Configuration
+        * Get UTC time from a stationary receiver.  Solve for time only.
+        * This should improve the time resolution dramatically.
+        */
+       mx4200_send(peer, "%s,%03d,%c,%c,%c,%d,%d,%d,", pmvxg,
+           PMVXG_S_TRECOVCONF,
+           'K',        /* known position: solve for time only */
+           'U',        /* synchronize to UTC */
+           'A',        /* always output a time pulse */
+           500,        /* max time error in ns */
+           0,          /* user bias in ns */
+           1);         /* output "830" sentences to control port */
+       /* Multi-satellite mode */
+
+       /*
+        * "000" Initialization/Mode Control - Part A
+        * Fix to our averaged position.
+        */
+       if (up->central_meridian != NOT_INITIALIZED) {
+               up->avg_lon += up->central_meridian;
+               if (up->avg_lon < -180.0) up->avg_lon += 360.0;
+               if (up->avg_lon >  180.0) up->avg_lon -= 360.0;
+       }
+
+       if (up->avg_lat >= 0.0) {
+               lat = up->avg_lat;
+               nsc = 'N';
+       } else {
+               lat = up->avg_lat * (-1.0);
+               nsc = 'S';
+       }
+       if (up->avg_lon >= 0.0) {
+               lon = up->avg_lon;
+               ewc = 'E';
+       } else {
+               lon = up->avg_lon * (-1.0);
+               ewc = 'W';
+       }
+       alt = up->avg_alt;
+       minute = (lat - (double)(int)lat) * 60.0;
+       sprintf(lats,"%02d%02.4f", (int)lat, minute);
+       minute = (lon - (double)(int)lon) * 60.0;
+       sprintf(lons,"%03d%02.4f", (int)lon, minute);
+
+       mx4200_send(peer, "%s,%03d,,,,,%s,%c,%s,%c,%.2f,%d", pmvxg,
+           PMVXG_S_INITMODEA,
+           /* day of month */
+           /* month of year */
+           /* year */
+           /* gmt */
+           lats,       /* latitude   DDMM.MMMM */
+           nsc,        /* north/south */
+           lons,       /* longitude DDDMM.MMMM */
+           ewc,        /* east/west */
+           alt,        /* Altitude */
+           1);         /* Altitude Reference (0=WGS84 ellipsoid, 1=MSL geoid)*/
+
+       msyslog(LOG_DEBUG,
+           "mx4200: reconfig to fixed location: %s %c, %s %c, %.2f m",
+               lats, nsc, lons, ewc, alt );
+
+}
+
+/*
+ * mx4200_poll - mx4200 watchdog routine
+ */
+static void
+mx4200_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct mx4200unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct mx4200unit *)pp->unitptr;
+
+       /*
+        * You don't need to poll this clock.  It puts out timecodes
+        * once per second.  If asked for a timestamp, take note.
+        * The next time a timecode comes in, it will be fed back.
+        */
+
+       /*
+        * If we haven't had a response in a while, reset the receiver.
+        */
+       if (up->pollcnt > 0) {
+               up->pollcnt--;
+       } else {
+               refclock_report(peer, CEVNT_TIMEOUT);
+
+               /*
+                * Request a "000" status message which should trigger a
+                * reconfig
+                */
+               mx4200_send(peer, "%s,%03d",
+                   "CDGPQ",            /* query from CDU to GPS */
+                   PMVXG_D_STATUS);    /* label of desired sentence */
+       }
+
+       /*
+        * polled every 64 seconds. Ask mx4200_receive to hand in
+        * a timestamp.
+        */
+       up->polled = 1;
+       pp->polls++;
+
+       /*
+        * Output receiver status information.
+        */
+       if ((up->log_time > 0) && (current_time > up->log_time)) {
+               up->log_time = 0;
+               /*
+                * Output the following messages once, for debugging.
+                *    "004" Mode Data
+                *    "523" Time Recovery Parameters
+                */
+               mx4200_send(peer, "%s,%03d", "CDGPQ", PMVXG_D_MODEDATA);
+               mx4200_send(peer, "%s,%03d", "CDGPQ", PMVXG_D_TRECOVUSEAGE);
+       }
+}
+
+static char char2hex[] = "0123456789ABCDEF";
+
+/*
+ * mx4200_receive - receive gps data
+ */
+static void
+mx4200_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct mx4200unit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       char *cp;
+       int sentence_type;
+       u_char ck;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp.
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct mx4200unit *)pp->unitptr;
+
+       /*
+        * If operating mode has been changed, then reinitialize the receiver
+        * before doing anything else.
+        */
+       if ((pp->sloppyclockflag & CLK_FLAG2) !=
+           (up->sloppyclockflag & CLK_FLAG2)) {
+               up->sloppyclockflag = pp->sloppyclockflag;
+               mx4200_debug(peer,
+                   "mx4200_receive: mode switch: reset receiver\n");
+               mx4200_config(peer);
+               return;
+       }
+       up->sloppyclockflag = pp->sloppyclockflag;
+
+       /*
+        * Read clock output.  Automatically handles STREAMS, CLKLDISC.
+        */
+       pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &pp->lastrec);
+
+       /*
+        * There is a case where <cr><lf> generates 2 timestamps.
+        */
+       if (pp->lencode == 0)
+               return;
+
+       up->pollcnt = 2;
+       pp->a_lastcode[pp->lencode] = '\0';
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       mx4200_debug(peer, "mx4200_receive: %d %s\n",
+                    pp->lencode, pp->a_lastcode);
+
+       /*
+        * The structure of the control port sentences is based on the
+        * NMEA-0183 Standard for interfacing Marine Electronics
+        * Navigation Devices (Version 1.5)
+        *
+        *      $PMVXG,XXX, ....................*CK<cr><lf>
+        *
+        *              $       Sentence Start Identifier (reserved char)
+        *                         (Start-of-Sentence Identifier)
+        *              P       Special ID (Proprietary)
+        *              MVX     Originator ID (Magnavox)
+        *              G       Interface ID (GPS)
+        *              ,       Field Delimiters (reserved char)
+        *              XXX     Sentence Type
+        *              ......  Data
+        *              *       Checksum Field Delimiter (reserved char)
+        *              CK      Checksum
+        *              <cr><lf> Carriage-Return/Line Feed (reserved chars)
+        *                         (End-of-Sentence Identifier)
+        *
+        * Reject if any important landmarks are missing.
+        */
+       cp = pp->a_lastcode + pp->lencode - 3;
+       if (cp < pp->a_lastcode || *pp->a_lastcode != '$' || cp[0] != '*' ) {
+               mx4200_debug(peer, "mx4200_receive: bad format\n");
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       /*
+        * Check and discard the checksum
+        */
+       ck = mx4200_cksum(&pp->a_lastcode[1], pp->lencode - 4);
+       if (char2hex[ck >> 4] != cp[1] || char2hex[ck & 0xf] != cp[2]) {
+               mx4200_debug(peer, "mx4200_receive: bad checksum\n");
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+       *cp = '\0';
+
+       /*
+        * Get the sentence type.
+        */
+       sentence_type = 0;
+       if ((cp = strchr(pp->a_lastcode, ',')) == NULL) {
+               mx4200_debug(peer, "mx4200_receive: no sentence\n");
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+       cp++;
+       sentence_type = strtol(cp, &cp, 10);
+
+       /*
+        * Process the sentence according to its type.
+        */
+       switch (sentence_type) {
+
+       /*
+        * "000" Status message
+        */
+       case PMVXG_D_STATUS:
+               /*
+                * XXX
+                * Since we configure the receiver to not give us status
+                * messages and since the receiver outputs status messages by
+                * default after being reset to factory defaults when sent the
+                * "$PMVXG,018,C\r\n" message, any status message we get
+                * indicates the reciever needs to be initialized; thus, it is
+                * not necessary to decode the status message.
+                */
+               if ((cp = mx4200_parse_s(peer)) != NULL) {
+                       mx4200_debug(peer,
+                                    "mx4200_receive: status: %s\n", cp);
+               }
+               mx4200_debug(peer, "mx4200_receive: reset receiver\n");
+               mx4200_config(peer);
+               break;
+
+       /*
+        * "021" Position, Height, Velocity message,
+        *  if we are still averaging our position
+        */
+       case PMVXG_D_PHV:
+               if (!up->known) {
+                       /*
+                        * Parse the message, calculating our averaged position.
+                        */
+                       if ((cp = mx4200_parse_p(peer)) != NULL) {
+                               mx4200_debug(peer, "mx4200_receive: pos: %s\n", cp);
+                               return;
+                       }
+                       mx4200_debug(peer,
+                           "mx4200_receive: position avg %f %.9f %.9f %.4f\n",
+                           up->N_fixes, up->avg_lat, up->avg_lon, up->avg_alt);
+                       /*
+                        * Reinitialize as a reference station
+                        * if position is well known.
+                        */
+                       if (current_time > up->clamp_time) {
+                               up->known++;
+                               mx4200_debug(peer, "mx4200_receive: reconfiguring!\n");
+                               mx4200_ref(peer);
+                       }
+               }
+               break;
+
+       /*
+        * Print to the syslog:
+        * "004" Mode Data
+        * "030" Software Configuration
+        * "523" Time Recovery Parameters Currently in Use
+        */
+       case PMVXG_D_MODEDATA:
+       case PMVXG_D_SOFTCONF:
+       case PMVXG_D_TRECOVUSEAGE:
+
+               if ((cp = mx4200_parse_s(peer)) != NULL) {
+                       mx4200_debug(peer,
+                                    "mx4200_receive: multi-record: %s\n", cp);
+               }
+               break;
+
+       /*
+        * "830" Time Recovery Results message
+        */
+       case PMVXG_D_TRECOVOUT:
+
+               /*
+                * Capture the last PPS signal.
+                * Precision timestamp is returned in pp->lastrec
+                */
+               if (mx4200_pps(peer) != NULL) {
+                       mx4200_debug(peer, "mx4200_receive: pps failure\n");
+                       refclock_report(peer, CEVNT_FAULT);
+                       return;
+               }
+
+
+               /*
+                * Parse the time recovery message, and keep the info
+                * to print the pretty billboards.
+                */
+               if ((cp = mx4200_parse_t(peer)) != NULL) {
+                       mx4200_debug(peer, "mx4200_receive: time: %s\n", cp);
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+
+               /*
+                * Add the new sample to a median filter.
+                */
+               if (!refclock_process(pp)) {
+                       mx4200_debug(peer,"mx4200_receive: offset: %.6f\n",
+                           pp->offset);
+                       refclock_report(peer, CEVNT_BADTIME);
+                       return;
+               }
+
+               /*
+                * The clock will blurt a timecode every second but we only
+                * want one when polled.  If we havn't been polled, bail out.
+                */
+               if (!up->polled)
+                       return;
+
+               /*
+                * Return offset and dispersion to control module.  We use
+                * lastrec as both the reference time and receive time in
+                * order to avoid being cute, like setting the reference time
+                * later than the receive time, which may cause a paranoid
+                * protocol module to chuck out the data.
+                */
+               mx4200_debug(peer, "mx4200_receive: process time: ");
+               mx4200_debug(peer, "%4d-%03d %02d:%02d:%02d at %s, %.6f\n",
+                   pp->year, pp->day, pp->hour, pp->minute, pp->second,
+                   prettydate(&pp->lastrec), pp->offset);
+               pp->lastref = pp->lastrec;
+               refclock_receive(peer);
+
+               /*
+                * We have succeeded in answering the poll.
+                * Turn off the flag and return
+                */
+               up->polled = 0;
+               break;
+
+       /*
+        * Ignore all other sentence types
+        */
+       default:
+               break;
+
+       } /* switch (sentence_type) */
+
+       return;
+}
+
+
+/*
+ * Parse a mx4200 time recovery message. Returns a string if error.
+ *
+ * A typical message looks like this.  Checksum has already been stripped.
+ *
+ *    $PMVXG,830,T,YYYY,MM,DD,HH:MM:SS,U,S,FFFFFF,PPPPP,BBBBBB,LL
+ *
+ *     Field   Field Contents
+ *     -----   --------------
+ *             Block Label: $PMVXG
+ *             Sentence Type: 830=Time Recovery Results
+ *                     This sentence is output approximately 1 second
+ *                     preceding the 1PPS output.  It indicates the
+ *                     exact time of the next pulse, whether or not the
+ *                     time mark will be valid (based on operator-specified
+ *                     error tolerance), the time to which the pulse is
+ *                     synchronized, the receiver operating mode,
+ *                     and the time error of the *last* 1PPS output.
+ *     1  char Time Mark Valid: T=Valid, F=Not Valid
+ *     2  int  Year: 1993-
+ *     3  int  Month of Year: 1-12
+ *     4  int  Day of Month: 1-31
+ *     5  int  Time of Day: HH:MM:SS
+ *     6  char Time Synchronization: U=UTC, G=GPS
+ *     7  char Time Recovery Mode: D=Dynamic, S=Static,
+ *                     K=Known Position, N=No Time Recovery
+ *     8  int  Oscillator Offset: The filter's estimate of the oscillator
+ *                     frequency error, in parts per billion (ppb).
+ *     9  int  Time Mark Error: The computed error of the *last* pulse
+ *                     output, in nanoseconds.
+ *     10 int  User Time Bias: Operator specified bias, in nanoseconds
+ *     11 int  Leap Second Flag: Indicates that a leap second will
+ *                     occur.  This value is usually zero, except during
+ *                     the week prior to the leap second occurrence, when
+ *                     this value will be set to +1 or -1.  A value of
+ *                     +1 indicates that GPS time will be 1 second
+ *                     further ahead of UTC time.
+ *
+ */
+static char *
+mx4200_parse_t(
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       struct mx4200unit *up;
+       char   time_mark_valid, time_sync, op_mode;
+       int    sentence_type, valid;
+       int    year, day_of_year, month, day_of_month;
+       int    hour, minute, second, leapsec;
+       int    oscillator_offset, time_mark_error, time_bias;
+
+       pp = peer->procptr;
+       up = (struct mx4200unit *)pp->unitptr;
+
+       leapsec = 0;  /* Not all receivers output leap second warnings (!) */
+       sscanf(pp->a_lastcode,
+               "$PMVXG,%d,%c,%d,%d,%d,%d:%d:%d,%c,%c,%d,%d,%d,%d",
+               &sentence_type, &time_mark_valid, &year, &month, &day_of_month,
+               &hour, &minute, &second, &time_sync, &op_mode,
+               &oscillator_offset, &time_mark_error, &time_bias, &leapsec);
+
+       if (sentence_type != PMVXG_D_TRECOVOUT)
+               return ("wrong rec-type");
+
+       switch (time_mark_valid) {
+               case 'T':
+                       valid = 1;
+                       break;
+               case 'F':
+                       valid = 0;
+                       break;
+               default:
+                       return ("bad pulse-valid");
+       }
+
+       switch (time_sync) {
+               case 'G':
+                       return ("synchronized to GPS; should be UTC");
+               case 'U':
+                       break; /* UTC -> ok */
+               default:
+                       return ("not synchronized to UTC");
+       }
+
+       /*
+        * Check for insane time (allow for possible leap seconds)
+        */
+       if (second > 60 || minute > 59 || hour > 23 ||
+           second <  0 || minute <  0 || hour <  0) {
+               mx4200_debug(peer,
+                   "mx4200_parse_t: bad time %02d:%02d:%02d",
+                   hour, minute, second);
+               if (leapsec != 0)
+                       mx4200_debug(peer, " (leap %+d\n)", leapsec);
+               mx4200_debug(peer, "\n");
+               refclock_report(peer, CEVNT_BADTIME);
+               return ("bad time");
+       }
+       if ( second == 60 ) {
+               msyslog(LOG_DEBUG,
+                   "mx4200: leap second! %02d:%02d:%02d",
+                   hour, minute, second);
+       }
+
+       /*
+        * Check for insane date
+        * (Certainly can't be any year before this code was last altered!)
+        */
+       if (day_of_month > 31 || month > 12 ||
+           day_of_month <  1 || month <  1 || year < YEAR_LAST_MODIFIED) {
+               mx4200_debug(peer,
+                   "mx4200_parse_t: bad date (%4d-%02d-%02d)\n",
+                   year, month, day_of_month);
+               refclock_report(peer, CEVNT_BADDATE);
+               return ("bad date");
+       }
+
+       /*
+        * Silly Hack for MX4200:
+        * ASCII message is for *next* 1PPS signal, but we have the
+        * timestamp for the *last* 1PPS signal.  So we have to subtract
+        * a second.  Discard if we are on a month boundary to avoid
+        * possible leap seconds and leap days.
+        */
+       second--;
+       if (second < 0) {
+               second = 59;
+               minute--;
+               if (minute < 0) {
+                       minute = 59;
+                       hour--;
+                       if (hour < 0) {
+                               hour = 23;
+                               day_of_month--;
+                               if (day_of_month < 1) {
+                                       return ("sorry, month boundary");
+                               }
+                       }
+               }
+       }
+
+       /*
+        * Calculate Julian date
+        */
+       if (!(day_of_year = mx4200_jday(year, month, day_of_month))) {
+               mx4200_debug(peer,
+                   "mx4200_parse_t: bad julian date %d (%4d-%02d-%02d)\n",
+                   day_of_year, year, month, day_of_month);
+               refclock_report(peer, CEVNT_BADDATE);
+               return("invalid julian date");
+       }
+
+       /*
+        * Setup leap second indicator
+        */
+       switch (leapsec) {
+               case 0:
+                       pp->leap = LEAP_NOWARNING;
+                       break;
+               case 1:
+                       pp->leap = LEAP_ADDSECOND;
+                       break;
+               case -1:
+                       pp->leap = LEAP_DELSECOND;
+                       break;
+               default:
+                       pp->leap = LEAP_NOTINSYNC;
+       }
+
+       /*
+        * Any change to the leap second warning status?
+        */
+       if (leapsec != up->last_leap ) {
+               msyslog(LOG_DEBUG,
+                   "mx4200: leap second warning: %d to %d (%d)",
+                   up->last_leap, leapsec, pp->leap);
+       }
+       up->last_leap = leapsec;
+
+       /*
+        * Copy time data for billboard monitoring.
+        */
+
+       pp->year   = year;
+       pp->day    = day_of_year;
+       pp->hour   = hour;
+       pp->minute = minute;
+       pp->second = second;
+
+       /*
+        * Toss if sentence is marked invalid
+        */
+       if (!valid || pp->leap == LEAP_NOTINSYNC) {
+               mx4200_debug(peer, "mx4200_parse_t: time mark not valid\n");
+               refclock_report(peer, CEVNT_BADTIME);
+               return ("pulse invalid");
+       }
+
+       return (NULL);
+}
+
+/*
+ * Calculate the checksum
+ */
+static u_char
+mx4200_cksum(
+       register char *cp,
+       register int n
+       )
+{
+       register u_char ck;
+
+       for (ck = 0; n-- > 0; cp++)
+               ck ^= *cp;
+       return (ck);
+}
+
+/*
+ * Tables to compute the day of year.  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};
+
+/*
+ * Calculate the the Julian Day
+ */
+static int
+mx4200_jday(
+       int year,
+       int month,
+       int day_of_month
+       )
+{
+       register int day, i;
+       int leap_year;
+
+       /*
+        * Is this a leap year ?
+        */
+       if (year % 4) {
+               leap_year = 0; /* FALSE */
+       } else {
+               if (year % 100) {
+                       leap_year = 1; /* TRUE */
+               } else {
+                       if (year % 400) {
+                               leap_year = 0; /* FALSE */
+                       } else {
+                               leap_year = 1; /* TRUE */
+                       }
+               }
+       }
+
+       /*
+        * Calculate the Julian Date
+        */
+       day = day_of_month;
+
+       if (leap_year) {
+               /* a leap year */
+               if (day > day2tab[month - 1]) {
+                       return (0);
+               }
+               for (i = 0; i < month - 1; i++)
+                   day += day2tab[i];
+       } else {
+               /* not a leap year */
+               if (day > day1tab[month - 1]) {
+                       return (0);
+               }
+               for (i = 0; i < month - 1; i++)
+                   day += day1tab[i];
+       }
+       return (day);
+}
+
+/*
+ * Parse a mx4200 position/height/velocity sentence.
+ *
+ * A typical message looks like this.  Checksum has already been stripped.
+ *
+ * $PMVXG,021,SSSSSS.SS,DDMM.MMMM,N,DDDMM.MMMM,E,HHHHH.H,GGGG.G,EEEE.E,WWWW.W,MM
+ *
+ *     Field   Field Contents
+ *     -----   --------------
+ *             Block Label: $PMVXG
+ *             Sentence Type: 021=Position, Height Velocity Data
+ *                     This sentence gives the receiver position, height,
+ *                     navigation mode, and velocity north/east.
+ *                     *This sentence is intended for post-analysis
+ *                     applications.*
+ *     1 float UTC measurement time (seconds into week)
+ *     2 float WGS-84 Lattitude (degrees, minutes)
+ *     3  char N=North, S=South
+ *     4 float WGS-84 Longitude (degrees, minutes)
+ *     5  char E=East, W=West
+ *     6 float Altitude (meters above mean sea level)
+ *     7 float Geoidal height (meters)
+ *     8 float East velocity (m/sec)
+ *     9 float West Velocity (m/sec)
+ *     10  int Navigation Mode
+ *                 Mode if navigating:
+ *                     1 = Position from remote device
+ *                     2 = 2-D position
+ *                     3 = 3-D position
+ *                     4 = 2-D differential position
+ *                     5 = 3-D differential position
+ *                     6 = Static
+ *                     8 = Position known -- reference station
+ *                     9 = Position known -- Navigator
+ *                 Mode if not navigating:
+ *                     51 = Too few satellites
+ *                     52 = DOPs too large
+ *                     53 = Position STD too large
+ *                     54 = Velocity STD too large
+ *                     55 = Too many iterations for velocity
+ *                     56 = Too many iterations for position
+ *                     57 = 3 sat startup failed
+ *                     58 = Command abort
+ */
+static char *
+mx4200_parse_p(
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       struct mx4200unit *up;
+       int sentence_type, mode;
+       double mtime, lat, lon, alt, geoid, vele, veln;
+       char   north_south, east_west;
+
+       pp = peer->procptr;
+       up = (struct mx4200unit *)pp->unitptr;
+
+       /* Should never happen! */
+       if (up->moving) return ("mobile platform - no pos!");
+
+       sscanf ( pp->a_lastcode,
+               "$PMVXG,%d,%lf,%lf,%c,%lf,%c,%lf,%lf,%lf,%lf,%d",
+               &sentence_type, &mtime, &lat, &north_south, &lon, &east_west,
+               &alt, &geoid, &vele, &veln, &mode);
+
+       /* Sentence type */
+       if (sentence_type != PMVXG_D_PHV)
+               return ("wrong rec-type");
+
+       /*
+        * return if not navigating
+        */
+       if (mode > 10)
+               return ("not navigating");
+       if (mode != 3 && mode != 5)
+               return ("not navigating in 3D");
+
+       /* Latitude (always +ve) and convert DDMM.MMMM to decimal */
+       if (lat <  0.0) return ("negative latitude");
+       if (lat > 9000.0) lat = 9000.0;
+       lat *= 0.01;
+       lat = ((int)lat) + (((lat - (int)lat)) * 1.6666666666666666);
+
+       /* North/South */
+       switch (north_south) {
+               case 'N':
+                       break;
+               case 'S':
+                       lat *= -1.0;
+                       break;
+               default:
+                       return ("invalid north/south indicator");
+       }
+
+       /* Longitude (always +ve) and convert DDDMM.MMMM to decimal */
+       if (lon <   0.0) return ("negative longitude");
+       if (lon > 180.0) lon = 180.0;
+       lon *= 0.01;
+       lon = ((int)lon) + (((lon - (int)lon)) * 1.6666666666666666);
+
+       /* East/West */
+       switch (east_west) {
+               case 'E':
+                       break;
+               case 'W':
+                       lon *= -1.0;
+                       break;
+               default:
+                       return ("invalid east/west indicator");
+       }
+
+       /*
+        * Normalize longitude to near 0 degrees.
+        * Assume all data are clustered around first reading.
+        */
+       if (up->central_meridian == NOT_INITIALIZED) {
+               up->central_meridian = lon;
+               mx4200_debug(peer,
+                   "mx4200_receive: central meridian =  %.9f \n",
+                   up->central_meridian);
+       }
+       lon -= up->central_meridian;
+       if (lon < -180.0) lon += 360.0;
+       if (lon >  180.0) lon -= 360.0;
+
+       /*
+        * Calculate running averages
+        */
+
+       up->avg_lon = (up->N_fixes * up->avg_lon) + lon;
+       up->avg_lat = (up->N_fixes * up->avg_lat) + lat;
+       up->avg_alt = (up->N_fixes * up->avg_alt) + alt;
+
+       up->N_fixes += 1.0;
+
+       up->avg_lon /= up->N_fixes;
+       up->avg_lat /= up->N_fixes;
+       up->avg_alt /= up->N_fixes;
+
+       mx4200_debug(peer,
+           "mx4200_receive: position rdg %.0f: %.9f %.9f %.4f (CM=%.9f)\n",
+           up->N_fixes, lat, lon, alt, up->central_meridian);
+
+       return (NULL);
+}
+
+/*
+ * Parse a mx4200 Status sentence
+ * Parse a mx4200 Mode Data sentence
+ * Parse a mx4200 Software Configuration sentence
+ * Parse a mx4200 Time Recovery Parameters Currently in Use sentence
+ * (used only for logging raw strings)
+ *
+ * A typical message looks like this.  Checksum has already been stripped.
+ *
+ * $PMVXG,000,XXX,XX,X,HHMM,X
+ *
+ *     Field   Field Contents
+ *     -----   --------------
+ *             Block Label: $PMVXG
+ *             Sentence Type: 000=Status.
+ *                     Returns status of the receiver to the controller.
+ *     1       Current Receiver Status:
+ *             ACQ = Satellite re-acquisition
+ *             ALT = Constellation selection
+ *             COR = Providing corrections (for reference stations only)
+ *             IAC = Initial acquisition
+ *             IDL = Idle, no satellites
+ *             NAV = Navigation
+ *             STS = Search the Sky (no almanac available)
+ *             TRK = Tracking
+ *     2       Number of satellites that should be visible
+ *     3       Number of satellites being tracked
+ *     4       Time since last navigation status if not currently navigating
+ *             (hours, minutes)
+ *     5       Initialization status:
+ *             0 = Waiting for initialization parameters
+ *             1 = Initialization completed
+ *
+ * A typical message looks like this.  Checksum has already been stripped.
+ *
+ * $PMVXG,004,C,R,D,H.HH,V.VV,TT,HHHH,VVVV,T
+ *
+ *     Field   Field Contents
+ *     -----   --------------
+ *             Block Label: $PMVXG
+ *             Sentence Type: 004=Software Configuration.
+ *                     Defines the navigation mode and criteria for
+ *                     acceptable navigation for the receiver.
+ *     1       Constrain Altitude Mode:
+ *             0 = Auto.  Constrain altitude (2-D solution) and use
+ *                 manual altitude input when 3 sats avalable.  Do
+ *                 not constrain altitude (3-D solution) when 4 sats
+ *                 available.
+ *             1 = Always constrain altitude (2-D solution).
+ *             2 = Never constrain altitude (3-D solution).
+ *             3 = Coast.  Constrain altitude (2-D solution) and use
+ *                 last GPS altitude calculation when 3 sats avalable.
+ *                 Do not constrain altitude (3-D solution) when 4 sats
+ *                 available.
+ *     2       Altitude Reference: (always 0 for MX4200)
+ *             0 = Ellipsoid
+ *             1 = Geoid (MSL)
+ *     3       Differential Navigation Control:
+ *             0 = Disabled
+ *             1 = Enabled
+ *     4       Horizontal Acceleration Constant (m/sec**2)
+ *     5       Vertical Acceleration Constant (m/sec**2) (0 for MX4200)
+ *     6       Tracking Elevation Limit (degrees)
+ *     7       HDOP Limit
+ *     8       VDOP Limit
+ *     9       Time Output Mode:
+ *             U = UTC
+ *             L = Local time
+ *     10      Local Time Offset (minutes) (absent on MX4200)
+ *
+ * A typical message looks like this.  Checksum has already been stripped.
+ *
+ * $PMVXG,030,NNNN,FFF
+ *
+ *     Field   Field Contents
+ *     -----   --------------
+ *             Block Label: $PMVXG
+ *             Sentence Type: 030=Software Configuration.
+ *                     This sentence contains the navigation processor
+ *                     and baseband firmware version numbers.
+ *     1       Nav Processor Version Number
+ *     2       Baseband Firmware Version Number
+ *
+ * A typical message looks like this.  Checksum has already been stripped.
+ *
+ * $PMVXG,523,M,S,M,EEEE,BBBBBB,C,R
+ *
+ *     Field   Field Contents
+ *     -----   --------------
+ *             Block Label: $PMVXG
+ *             Sentence Type: 523=Time Recovery Parameters Currently in Use.
+ *                     This sentence contains the configuration of the
+ *                     time recovery feature of the receiver.
+ *     1       Time Recovery Mode:
+ *             D = Dynamic; solve for position and time while moving
+ *             S = Static; solve for position and time while stationary
+ *             K = Known position input, solve for time only
+ *             N = No time recovery
+ *     2       Time Synchronization:
+ *             U = UTC time
+ *             G = GPS time
+ *     3       Time Mark Mode:
+ *             A = Always output a time pulse
+ *             V = Only output time pulse if time is valid (as determined
+ *                 by Maximum Time Error)
+ *     4       Maximum Time Error - the maximum error (in nanoseconds) for
+ *             which a time mark will be considered valid.
+ *     5       User Time Bias - external bias in nanoseconds
+ *     6       Time Message Control:
+ *             0 = Do not output the time recovery message
+ *             1 = Output the time recovery message (record 830) to
+ *                 Control port
+ *             2 = Output the time recovery message (record 830) to
+ *                 Equipment port
+ *     7       Reserved
+ *     8       Position Known PRN (absent on MX 4200)
+ *
+ */
+static char *
+mx4200_parse_s(
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       struct mx4200unit *up;
+       int sentence_type;
+
+       pp = peer->procptr;
+       up = (struct mx4200unit *)pp->unitptr;
+
+        sscanf ( pp->a_lastcode, "$PMVXG,%d", &sentence_type);
+
+       /* Sentence type */
+       switch (sentence_type) {
+
+               case PMVXG_D_STATUS:
+                       msyslog(LOG_DEBUG,
+                         "mx4200: status: %s", pp->a_lastcode);
+                       break;
+               case PMVXG_D_MODEDATA:
+                       msyslog(LOG_DEBUG,
+                         "mx4200: mode data: %s", pp->a_lastcode);
+                       break;
+               case PMVXG_D_SOFTCONF:
+                       msyslog(LOG_DEBUG,
+                         "mx4200: firmware configuration: %s", pp->a_lastcode);
+                       break;
+               case PMVXG_D_TRECOVUSEAGE:
+                       msyslog(LOG_DEBUG,
+                         "mx4200: time recovery parms: %s", pp->a_lastcode);
+                       break;
+               default:
+                       return ("wrong rec-type");
+       }
+
+       return (NULL);
+}
+
+/*
+ * Process a PPS signal, placing a timestamp in pp->lastrec.
+ */
+static int
+mx4200_pps(
+       struct peer *peer
+       )
+{
+       int temp_serial;
+       struct refclockproc *pp;
+       struct mx4200unit *up;
+
+       struct timespec timeout;
+
+       pp = peer->procptr;
+       up = (struct mx4200unit *)pp->unitptr;
+
+       /*
+        * Grab the timestamp of the PPS signal.
+        */
+       temp_serial = up->pps_i.assert_sequence;
+       timeout.tv_sec  = 0;
+       timeout.tv_nsec = 0;
+       if (time_pps_fetch(up->pps_h, PPS_TSFMT_TSPEC, &(up->pps_i),
+                       &timeout) < 0) {
+               mx4200_debug(peer,
+                 "mx4200_pps: time_pps_fetch: serial=%ul, %s\n",
+                    (unsigned long)up->pps_i.assert_sequence, strerror(errno));
+               refclock_report(peer, CEVNT_FAULT);
+               return(1);
+       }
+       if (temp_serial == up->pps_i.assert_sequence) {
+               mx4200_debug(peer,
+                  "mx4200_pps: assert_sequence serial not incrementing: %ul\n",
+                       (unsigned long)up->pps_i.assert_sequence);
+               refclock_report(peer, CEVNT_FAULT);
+               return(1);
+       }
+       /*
+        * Check pps serial number against last one
+        */
+       if (up->lastserial + 1 != up->pps_i.assert_sequence &&
+           up->lastserial != 0) {
+               if (up->pps_i.assert_sequence == up->lastserial) {
+                       mx4200_debug(peer, "mx4200_pps: no new pps event\n");
+               } else {
+                       mx4200_debug(peer, "mx4200_pps: missed %ul pps events\n",
+                           up->pps_i.assert_sequence - up->lastserial - 1UL);
+               }
+               refclock_report(peer, CEVNT_FAULT);
+       }
+       up->lastserial = up->pps_i.assert_sequence;
+
+       /*
+        * Return the timestamp in pp->lastrec
+        */
+
+       pp->lastrec.l_ui = up->pps_i.assert_timestamp.tv_sec +
+                          (u_int32) JAN_1970;
+       pp->lastrec.l_uf = ((double)(up->pps_i.assert_timestamp.tv_nsec) *
+                          4.2949672960) + 0.5;
+
+       return(0);
+}
+
+/*
+ * mx4200_debug - print debug messages
+ */
+#if defined(__STDC__)
+static void
+mx4200_debug(struct peer *peer, char *fmt, ...)
+#else
+static void
+mx4200_debug(peer, fmt, va_alist)
+     struct peer *peer;
+     char *fmt;
+#endif /* __STDC__ */
+{
+#ifdef DEBUG
+       va_list ap;
+       struct refclockproc *pp;
+       struct mx4200unit *up;
+
+       if (debug) {
+
+#if defined(__STDC__)
+               va_start(ap, fmt);
+#else
+               va_start(ap);
+#endif /* __STDC__ */
+
+               pp = peer->procptr;
+               up = (struct mx4200unit *)pp->unitptr;
+
+
+               /*
+                * Print debug message to stdout
+                * In the future, we may want to get get more creative...
+                */
+               vprintf(fmt, ap);
+
+               va_end(ap);
+       }
+#endif
+}
+
+/*
+ * Send a character string to the receiver.  Checksum is appended here.
+ */
+#if defined(__STDC__)
+static void
+mx4200_send(struct peer *peer, char *fmt, ...)
+#else
+static void
+mx4200_send(peer, fmt, va_alist)
+     struct peer *peer;
+     char *fmt;
+     va_dcl
+#endif /* __STDC__ */
+{
+       struct refclockproc *pp;
+       struct mx4200unit *up;
+
+       register char *cp;
+       register int n, m;
+       va_list ap;
+       char buf[1024];
+       u_char ck;
+
+#if defined(__STDC__)
+       va_start(ap, fmt);
+#else
+       va_start(ap);
+#endif /* __STDC__ */
+
+       pp = peer->procptr;
+       up = (struct mx4200unit *)pp->unitptr;
+
+       cp = buf;
+       *cp++ = '$';
+       n = VSNPRINTF((cp, sizeof(buf) - 1, fmt, ap));
+       ck = mx4200_cksum(cp, n);
+       cp += n;
+       ++n;
+       n += SNPRINTF((cp, sizeof(buf) - n - 5, "*%02X\r\n", ck));
+
+       m = write(pp->io.fd, buf, (unsigned)n);
+       if (m < 0)
+               msyslog(LOG_ERR, "mx4200_send: write: %m (%s)", buf);
+       mx4200_debug(peer, "mx4200_send: %d %s\n", m, buf);
+       va_end(ap);
+}
+
+#else
+int refclock_mx4200_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_neoclock4x.c b/ntpd/refclock_neoclock4x.c
new file mode 100644 (file)
index 0000000..374c81a
--- /dev/null
@@ -0,0 +1,1113 @@
+/*
+ *
+ * Refclock_neoclock4x.c
+ * - NeoClock4X driver for DCF77 or FIA Timecode
+ *
+ * Date: 2006-01-11 v1.15
+ *
+ * see http://www.linum.com/redir/jump/id=neoclock4x&action=redir
+ * for details about the NeoClock4X device
+ *
+ * Copyright (C) 2002-2004 by Linum Software GmbH <neoclock4x@linum.com>
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if defined(REFCLOCK) && (defined(CLOCK_NEOCLOCK4X))
+
+#include <unistd.h>
+#include <sys/time.h>
+#include <sys/types.h>
+#include <termios.h>
+#include <sys/ioctl.h>
+#include <ctype.h>
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_control.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#if defined HAVE_SYS_MODEM_H
+# include <sys/modem.h>
+# ifndef __QNXNTO__
+#  define TIOCMSET MCSETA
+#  define TIOCMGET MCGETA
+#  define TIOCM_RTS MRTS
+# endif
+#endif
+
+#ifdef HAVE_TERMIOS_H
+# ifdef TERMIOS_NEEDS__SVID3
+#  define _SVID3
+# endif
+# include <termios.h>
+# ifdef TERMIOS_NEEDS__SVID3
+#  undef _SVID3
+# endif
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+
+/*
+ * NTP version 4.20 change the pp->msec field to pp->nsec.
+ * To allow to support older ntp versions with this sourcefile
+ * you can define NTP_PRE_420 to allow this driver to compile
+ * with ntp version back to 4.1.2.
+ *
+ */
+#if 0
+#define NTP_PRE_420
+#endif
+
+/*
+ * If you want the driver for whatever reason to not use
+ * the TX line to send anything to your NeoClock4X
+ * device you must tell the NTP refclock driver which
+ * firmware you NeoClock4X device uses.
+ *
+ * If you want to enable this feature change the "#if 0"
+ * line to "#if 1" and make sure that the defined firmware
+ * matches the firmware off your NeoClock4X receiver!
+ *
+ */
+
+#if 0
+#define NEOCLOCK4X_FIRMWARE                NEOCLOCK4X_FIRMWARE_VERSION_A
+#endif
+
+/* at this time only firmware version A is known */
+#define NEOCLOCK4X_FIRMWARE_VERSION_A      'A'
+
+#define NEOCLOCK4X_TIMECODELEN 37
+
+#define NEOCLOCK4X_OFFSET_SERIAL            3
+#define NEOCLOCK4X_OFFSET_RADIOSIGNAL       9
+#define NEOCLOCK4X_OFFSET_DAY              12
+#define NEOCLOCK4X_OFFSET_MONTH            14
+#define NEOCLOCK4X_OFFSET_YEAR             16
+#define NEOCLOCK4X_OFFSET_HOUR             18
+#define NEOCLOCK4X_OFFSET_MINUTE           20
+#define NEOCLOCK4X_OFFSET_SECOND           22
+#define NEOCLOCK4X_OFFSET_HSEC             24
+#define NEOCLOCK4X_OFFSET_DOW              26
+#define NEOCLOCK4X_OFFSET_TIMESOURCE       28
+#define NEOCLOCK4X_OFFSET_DSTSTATUS        29
+#define NEOCLOCK4X_OFFSET_QUARZSTATUS      30
+#define NEOCLOCK4X_OFFSET_ANTENNA1         31
+#define NEOCLOCK4X_OFFSET_ANTENNA2         33
+#define NEOCLOCK4X_OFFSET_CRC              35
+
+#define NEOCLOCK4X_DRIVER_VERSION          "1.15 (2006-01-11)"
+
+#define NSEC_TO_MILLI                      1000000
+
+struct neoclock4x_unit {
+  l_fp laststamp;      /* last receive timestamp */
+  short        unit;           /* NTP refclock unit number */
+  u_long polled;       /* flag to detect noreplies */
+  char leap_status;    /* leap second flag */
+  int  recvnow;
+
+  char  firmware[80];
+  char  firmwaretag;
+  char  serial[7];
+  char  radiosignal[4];
+  char  timesource;
+  char  dststatus;
+  char  quarzstatus;
+  int   antenna1;
+  int   antenna2;
+  int   utc_year;
+  int   utc_month;
+  int   utc_day;
+  int   utc_hour;
+  int   utc_minute;
+  int   utc_second;
+  int   utc_msec;
+};
+
+static int     neoclock4x_start        P((int, struct peer *));
+static void    neoclock4x_shutdown     P((int, struct peer *));
+static void    neoclock4x_receive      P((struct recvbuf *));
+static void    neoclock4x_poll         P((int, struct peer *));
+static void    neoclock4x_control      P((int, struct refclockstat *, struct refclockstat *, struct peer *));
+
+static int      neol_atoi_len           P((const char str[], int *, int));
+static int      neol_hexatoi_len        P((const char str[], int *, int));
+static void     neol_jdn_to_ymd         P((unsigned long, int *, int *, int *));
+static void     neol_localtime          P((unsigned long, int* , int*, int*, int*, int*, int*));
+static unsigned long neol_mktime        P((int, int, int, int, int, int));
+#if !defined(NEOCLOCK4X_FIRMWARE)
+static int      neol_query_firmware     P((int, int, char *, int));
+static int      neol_check_firmware     P((int, const char*, char *));
+#endif
+
+struct refclock refclock_neoclock4x = {
+  neoclock4x_start,    /* start up driver */
+  neoclock4x_shutdown, /* shut down driver */
+  neoclock4x_poll,     /* transmit poll message */
+  neoclock4x_control,
+  noentry,             /* initialize driver (not used) */
+  noentry,             /* not used */
+  NOFLAGS                      /* not used */
+};
+
+static int
+neoclock4x_start(int unit,
+                struct peer *peer)
+{
+  struct neoclock4x_unit *up;
+  struct refclockproc *pp;
+  int fd;
+  char dev[20];
+  int sl232;
+#if defined(HAVE_TERMIOS)
+  struct termios termsettings;
+#endif
+#if !defined(NEOCLOCK4X_FIRMWARE)
+  int tries;
+#endif
+
+  (void) snprintf(dev, sizeof(dev)-1, "/dev/neoclock4x-%d", unit);
+
+  /* LDISC_STD, LDISC_RAW
+   * Open serial port. Use CLK line discipline, if available.
+   */
+  fd = refclock_open(dev, B2400, LDISC_STD);
+  if(fd <= 0)
+    {
+      return (0);
+    }
+
+#if defined(HAVE_TERMIOS)
+
+#if 1
+  if(tcgetattr(fd, &termsettings) < 0)
+    {
+      msyslog(LOG_CRIT, "NeoClock4X(%d): (tcgetattr) can't query serial port settings: %m", unit);
+      (void) close(fd);
+      return (0);
+    }
+
+  /* 2400 Baud 8N2 */
+  termsettings.c_iflag = IGNBRK | IGNPAR | ICRNL;
+  termsettings.c_oflag = 0;
+  termsettings.c_cflag = CS8 | CSTOPB | CLOCAL | CREAD;
+  (void)cfsetispeed(&termsettings, (u_int)B2400);
+  (void)cfsetospeed(&termsettings, (u_int)B2400);
+
+  if(tcsetattr(fd, TCSANOW, &termsettings) < 0)
+    {
+      msyslog(LOG_CRIT, "NeoClock4X(%d): (tcsetattr) can't set serial port 2400 8N2: %m", unit);
+      (void) close(fd);
+      return (0);
+    }
+
+#else
+  if(tcgetattr(fd, &termsettings) < 0)
+    {
+      msyslog(LOG_CRIT, "NeoClock4X(%d): (tcgetattr) can't query serial port settings: %m", unit);
+      (void) close(fd);
+      return (0);
+    }
+
+  /* 2400 Baud 8N2 */
+  termsettings.c_cflag &= ~PARENB;
+  termsettings.c_cflag |= CSTOPB;
+  termsettings.c_cflag &= ~CSIZE;
+  termsettings.c_cflag |= CS8;
+
+  if(tcsetattr(fd, TCSANOW, &termsettings) < 0)
+    {
+      msyslog(LOG_CRIT, "NeoClock4X(%d): (tcsetattr) can't set serial port 2400 8N2: %m", unit);
+      (void) close(fd);
+      return (0);
+    }
+#endif
+
+#elif defined(HAVE_SYSV_TTYS)
+  if(ioctl(fd, TCGETA, &termsettings) < 0)
+    {
+      msyslog(LOG_CRIT, "NeoClock4X(%d): (TCGETA) can't query serial port settings: %m", unit);
+      (void) close(fd);
+      return (0);
+    }
+
+  /* 2400 Baud 8N2 */
+  termsettings.c_cflag &= ~PARENB;
+  termsettings.c_cflag |= CSTOPB;
+  termsettings.c_cflag &= ~CSIZE;
+  termsettings.c_cflag |= CS8;
+
+  if(ioctl(fd, TCSETA, &termsettings) < 0)
+    {
+      msyslog(LOG_CRIT, "NeoClock4X(%d): (TSGETA) can't set serial port 2400 8N2: %m", unit);
+      (void) close(fd);
+      return (0);
+    }
+#else
+  msyslog(LOG_EMERG, "NeoClock4X(%d): don't know how to set port to 2400 8N2 with this OS!", unit);
+  (void) close(fd);
+  return (0);
+#endif
+
+#if defined(TIOCMSET) && (defined(TIOCM_RTS) || defined(CIOCM_RTS))
+  /* turn on RTS, and DTR for power supply */
+  /* NeoClock4x is powered from serial line */
+  if(ioctl(fd, TIOCMGET, (caddr_t)&sl232) == -1)
+    {
+      msyslog(LOG_CRIT, "NeoClock4X(%d): can't query RTS/DTR state: %m", unit);
+      (void) close(fd);
+      return (0);
+    }
+#ifdef TIOCM_RTS
+  sl232 = sl232 | TIOCM_DTR | TIOCM_RTS;       /* turn on RTS, and DTR for power supply */
+#else
+  sl232 = sl232 | CIOCM_DTR | CIOCM_RTS;       /* turn on RTS, and DTR for power supply */
+#endif
+  if(ioctl(fd, TIOCMSET, (caddr_t)&sl232) == -1)
+    {
+      msyslog(LOG_CRIT, "NeoClock4X(%d): can't set RTS/DTR to power neoclock4x: %m", unit);
+      (void) close(fd);
+      return (0);
+    }
+#else
+  msyslog(LOG_EMERG, "NeoClock4X(%d): don't know how to set DTR/RTS to power NeoClock4X with this OS!",
+         unit);
+  (void) close(fd);
+  return (0);
+#endif
+
+  up = (struct neoclock4x_unit *) emalloc(sizeof(struct neoclock4x_unit));
+  if(!(up))
+    {
+      msyslog(LOG_ERR, "NeoClock4X(%d): can't allocate memory for: %m",unit);
+      (void) close(fd);
+      return (0);
+    }
+
+  memset((char *)up, 0, sizeof(struct neoclock4x_unit));
+  pp = peer->procptr;
+  pp->clockdesc = "NeoClock4X";
+  pp->unitptr = (caddr_t)up;
+  pp->io.clock_recv = neoclock4x_receive;
+  pp->io.srcclock = (caddr_t)peer;
+  pp->io.datalen = 0;
+  pp->io.fd = fd;
+  /*
+   * no fudge time is given by user!
+   * use 169.583333 ms to compensate the serial line delay
+   * formula is:
+   * 2400 Baud / 11 bit = 218.18 charaters per second
+   *  (NeoClock4X timecode len)
+   */
+  pp->fudgetime1 = (NEOCLOCK4X_TIMECODELEN * 11) / 2400.0;
+
+  /*
+   * Initialize miscellaneous variables
+   */
+  peer->precision = -10;
+  peer->burst = NSTAGE;
+  memcpy((char *)&pp->refid, "neol", 4);
+
+  up->leap_status = 0;
+  up->unit = unit;
+  strcpy(up->firmware, "?");
+  up->firmwaretag = '?';
+  strcpy(up->serial, "?");
+  strcpy(up->radiosignal, "?");
+  up->timesource  = '?';
+  up->dststatus   = '?';
+  up->quarzstatus = '?';
+  up->antenna1    = -1;
+  up->antenna2    = -1;
+  up->utc_year    = 0;
+  up->utc_month   = 0;
+  up->utc_day     = 0;
+  up->utc_hour    = 0;
+  up->utc_minute  = 0;
+  up->utc_second  = 0;
+  up->utc_msec    = 0;
+
+#if defined(NEOCLOCK4X_FIRMWARE)
+#if NEOCLOCK4X_FIRMWARE == NEOCLOCK4X_FIRMWARE_VERSION_A
+  strcpy(up->firmware, "(c) 2002 NEOL S.A. FRANCE / L0.01 NDF:A:* (compile time)");
+  up->firmwaretag = 'A';
+#else
+  msyslog(LOG_EMERG, "NeoClock4X(%d): unknown firmware defined at compile time for NeoClock4X",
+         unit);
+  (void) close(fd);
+  pp->io.fd = -1;
+  free(pp->unitptr);
+  pp->unitptr = NULL;
+  return (0);
+#endif
+#else
+  for(tries=0; tries < 5; tries++)
+    {
+      NLOG(NLOG_CLOCKINFO)
+       msyslog(LOG_INFO, "NeoClock4X(%d): checking NeoClock4X firmware version (%d/5)", unit, tries);
+      /* wait 3 seconds for receiver to power up */
+      sleep(3);
+      if(neol_query_firmware(pp->io.fd, up->unit, up->firmware, sizeof(up->firmware)))
+       {
+         break;
+       }
+    }
+
+  /* can I handle this firmware version? */
+  if(!neol_check_firmware(up->unit, up->firmware, &up->firmwaretag))
+    {
+      (void) close(fd);
+      pp->io.fd = -1;
+      free(pp->unitptr);
+      pp->unitptr = NULL;
+      return (0);
+    }
+#endif
+
+  if(!io_addclock(&pp->io))
+    {
+      msyslog(LOG_ERR, "NeoClock4X(%d): error add peer to ntpd: %m", unit);
+      (void) close(fd);
+      pp->io.fd = -1;
+      free(pp->unitptr);
+      pp->unitptr = NULL;
+      return (0);
+    }
+
+  NLOG(NLOG_CLOCKINFO)
+    msyslog(LOG_INFO, "NeoClock4X(%d): receiver setup successful done", unit);
+
+  return (1);
+}
+
+static void
+neoclock4x_shutdown(int unit,
+                  struct peer *peer)
+{
+  struct neoclock4x_unit *up;
+  struct refclockproc *pp;
+  int sl232;
+
+  if(NULL != peer)
+    {
+      pp = peer->procptr;
+      if(pp != NULL)
+        {
+          up = (struct neoclock4x_unit *)pp->unitptr;
+          if(up != NULL)
+            {
+              if(-1 !=  pp->io.fd)
+                {
+#if defined(TIOCMSET) && (defined(TIOCM_RTS) || defined(CIOCM_RTS))
+                  /* turn on RTS, and DTR for power supply */
+                  /* NeoClock4x is powered from serial line */
+                  if(ioctl(pp->io.fd, TIOCMGET, (caddr_t)&sl232) == -1)
+                    {
+                      msyslog(LOG_CRIT, "NeoClock4X(%d): can't query RTS/DTR state: %m",
+                              unit);
+                    }
+#ifdef TIOCM_RTS
+                  /* turn on RTS, and DTR for power supply */
+                  sl232 &= ~(TIOCM_DTR | TIOCM_RTS);
+#else
+                  /* turn on RTS, and DTR for power supply */
+                  sl232 &= ~(CIOCM_DTR | CIOCM_RTS);
+#endif
+                  if(ioctl(pp->io.fd, TIOCMSET, (caddr_t)&sl232) == -1)
+                    {
+                      msyslog(LOG_CRIT, "NeoClock4X(%d): can't set RTS/DTR to power neoclock4x: %m",
+                              unit);
+                    }
+#endif
+                  io_closeclock(&pp->io);
+                }
+              free(up);
+              pp->unitptr = NULL;
+            }
+        }
+    }
+
+  msyslog(LOG_ERR, "NeoClock4X(%d): shutdown", unit);
+
+  NLOG(NLOG_CLOCKINFO)
+    msyslog(LOG_INFO, "NeoClock4X(%d): receiver shutdown done", unit);
+}
+
+static void
+neoclock4x_receive(struct recvbuf *rbufp)
+{
+  struct neoclock4x_unit *up;
+  struct refclockproc *pp;
+  struct peer *peer;
+  unsigned long calc_utc;
+  int day;
+  int month;   /* ddd conversion */
+  int c;
+  int dsec;
+  unsigned char calc_chksum;
+  int recv_chksum;
+
+  peer = (struct peer *)rbufp->recv_srcclock;
+  pp = peer->procptr;
+  up = (struct neoclock4x_unit *)pp->unitptr;
+
+  /* wait till poll interval is reached */
+  if(0 == up->recvnow)
+    return;
+
+  /* reset poll interval flag */
+  up->recvnow = 0;
+
+  /* read last received timecode */
+  pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &pp->lastrec);
+  pp->leap = LEAP_NOWARNING;
+
+  if(NEOCLOCK4X_TIMECODELEN != pp->lencode)
+    {
+      NLOG(NLOG_CLOCKEVENT)
+       msyslog(LOG_WARNING, "NeoClock4X(%d): received data has invalid length, expected %d bytes, received %d bytes: %s",
+               up->unit, NEOCLOCK4X_TIMECODELEN, pp->lencode, pp->a_lastcode);
+      refclock_report(peer, CEVNT_BADREPLY);
+      return;
+    }
+
+  neol_hexatoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_CRC], &recv_chksum, 2);
+
+  /* calculate checksum */
+  calc_chksum = 0;
+  for(c=0; c < NEOCLOCK4X_OFFSET_CRC; c++)
+    {
+      calc_chksum += pp->a_lastcode[c];
+    }
+  if(recv_chksum != calc_chksum)
+    {
+      NLOG(NLOG_CLOCKEVENT)
+       msyslog(LOG_WARNING, "NeoClock4X(%d): received data has invalid chksum: %s",
+               up->unit, pp->a_lastcode);
+      refclock_report(peer, CEVNT_BADREPLY);
+      return;
+    }
+
+  /* Allow synchronization even is quartz clock is
+   * never initialized.
+   * WARNING: This is dangerous!
+   */
+  up->quarzstatus = pp->a_lastcode[NEOCLOCK4X_OFFSET_QUARZSTATUS];
+  if(0==(pp->sloppyclockflag & CLK_FLAG2))
+    {
+      if('I' != up->quarzstatus)
+       {
+         NLOG(NLOG_CLOCKEVENT)
+           msyslog(LOG_NOTICE, "NeoClock4X(%d): quartz clock is not initialized: %s",
+                   up->unit, pp->a_lastcode);
+         pp->leap = LEAP_NOTINSYNC;
+         refclock_report(peer, CEVNT_BADDATE);
+         return;
+       }
+    }
+  if('I' != up->quarzstatus)
+    {
+      NLOG(NLOG_CLOCKEVENT)
+       msyslog(LOG_NOTICE, "NeoClock4X(%d): using uninitialized quartz clock for time synchronization: %s",
+               up->unit, pp->a_lastcode);
+    }
+
+  /*
+   * If NeoClock4X is not synchronized to a radio clock
+   * check if we're allowed to synchronize with the quartz
+   * clock.
+   */
+  up->timesource = pp->a_lastcode[NEOCLOCK4X_OFFSET_TIMESOURCE];
+  if(0==(pp->sloppyclockflag & CLK_FLAG2))
+    {
+      if('A' != up->timesource)
+       {
+         /* not allowed to sync with quartz clock */
+         if(0==(pp->sloppyclockflag & CLK_FLAG1))
+           {
+             refclock_report(peer, CEVNT_BADTIME);
+             pp->leap = LEAP_NOTINSYNC;
+             return;
+           }
+       }
+    }
+
+  /* this should only used when first install is done */
+  if(pp->sloppyclockflag & CLK_FLAG4)
+    {
+      msyslog(LOG_DEBUG, "NeoClock4X(%d): received data: %s",
+             up->unit, pp->a_lastcode);
+    }
+
+  /* 123456789012345678901234567890123456789012345 */
+  /* S/N123456DCF1004021010001202ASX1213CR\r\n */
+
+  neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_YEAR], &pp->year, 2);
+  neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_MONTH], &month, 2);
+  neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_DAY], &day, 2);
+  neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_HOUR], &pp->hour, 2);
+  neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_MINUTE], &pp->minute, 2);
+  neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_SECOND], &pp->second, 2);
+  neol_atoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_HSEC], &dsec, 2);
+#if defined(NTP_PRE_420)
+  pp->msec = dsec * 10; /* convert 1/100s from neoclock to real miliseconds */
+#else
+  pp->nsec = dsec * 10 * NSEC_TO_MILLI; /* convert 1/100s from neoclock to nanoseconds */
+#endif
+
+  memcpy(up->radiosignal, &pp->a_lastcode[NEOCLOCK4X_OFFSET_RADIOSIGNAL], 3);
+  up->radiosignal[3] = 0;
+  memcpy(up->serial, &pp->a_lastcode[NEOCLOCK4X_OFFSET_SERIAL], 6);
+  up->serial[6] = 0;
+  up->dststatus = pp->a_lastcode[NEOCLOCK4X_OFFSET_DSTSTATUS];
+  neol_hexatoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_ANTENNA1], &up->antenna1, 2);
+  neol_hexatoi_len(&pp->a_lastcode[NEOCLOCK4X_OFFSET_ANTENNA2], &up->antenna2, 2);
+
+  /*
+    Validate received values at least enough to prevent internal
+    array-bounds problems, etc.
+  */
+  if((pp->hour < 0) || (pp->hour > 23) ||
+     (pp->minute < 0) || (pp->minute > 59) ||
+     (pp->second < 0) || (pp->second > 60) /*Allow for leap seconds.*/ ||
+     (day < 1) || (day > 31) ||
+     (month < 1) || (month > 12) ||
+     (pp->year < 0) || (pp->year > 99)) {
+    /* Data out of range. */
+    NLOG(NLOG_CLOCKEVENT)
+      msyslog(LOG_WARNING, "NeoClock4X(%d): date/time out of range: %s",
+             up->unit, pp->a_lastcode);
+    refclock_report(peer, CEVNT_BADDATE);
+    return;
+  }
+
+  /* Year-2000 check not needed anymore. Same problem
+   * will arise at 2099 but what should we do...?
+   *
+   * wrap 2-digit date into 4-digit
+   *
+   * if(pp->year < YEAR_PIVOT)
+   * {
+   *   pp->year += 100;
+   * }
+  */
+  pp->year += 2000;
+
+  /* adjust NeoClock4X local time to UTC */
+  calc_utc = neol_mktime(pp->year, month, day, pp->hour, pp->minute, pp->second);
+  calc_utc -= 3600;
+  /* adjust NeoClock4X daylight saving time if needed */
+  if('S' == up->dststatus)
+    calc_utc -= 3600;
+  neol_localtime(calc_utc, &pp->year, &month, &day, &pp->hour, &pp->minute, &pp->second);
+
+  /*
+    some preparations
+  */
+  pp->day = ymd2yd(pp->year, month, day);
+  pp->leap = 0;
+
+  if(pp->sloppyclockflag & CLK_FLAG4)
+    {
+      msyslog(LOG_DEBUG, "NeoClock4X(%d): calculated UTC date/time: %04d-%02d-%02d %02d:%02d:%02d.%03ld",
+             up->unit,
+             pp->year, month, day,
+             pp->hour, pp->minute, pp->second,
+#if defined(NTP_PRE_420)
+              pp->msec
+#else
+              pp->nsec/NSEC_TO_MILLI
+#endif
+              );
+    }
+
+  up->utc_year   = pp->year;
+  up->utc_month  = month;
+  up->utc_day    = day;
+  up->utc_hour   = pp->hour;
+  up->utc_minute = pp->minute;
+  up->utc_second = pp->second;
+#if defined(NTP_PRE_420)
+  up->utc_msec   = pp->msec;
+#else
+  up->utc_msec   = pp->nsec/NSEC_TO_MILLI;
+#endif
+
+  if(!refclock_process(pp))
+    {
+      NLOG(NLOG_CLOCKEVENT)
+       msyslog(LOG_WARNING, "NeoClock4X(%d): refclock_process failed!", up->unit);
+      refclock_report(peer, CEVNT_FAULT);
+      return;
+    }
+  refclock_receive(peer);
+
+  /* report good status */
+  refclock_report(peer, CEVNT_NOMINAL);
+
+  record_clock_stats(&peer->srcadr, pp->a_lastcode);
+}
+
+static void
+neoclock4x_poll(int unit,
+               struct peer *peer)
+{
+  struct neoclock4x_unit *up;
+  struct refclockproc *pp;
+
+  pp = peer->procptr;
+  up = (struct neoclock4x_unit *)pp->unitptr;
+
+  pp->polls++;
+  up->recvnow = 1;
+}
+
+static void
+neoclock4x_control(int unit,
+                  struct refclockstat *in,
+                  struct refclockstat *out,
+                  struct peer *peer)
+{
+  struct neoclock4x_unit *up;
+  struct refclockproc *pp;
+
+  if(NULL == peer)
+    {
+      msyslog(LOG_ERR, "NeoClock4X(%d): control: unit invalid/inactive", unit);
+      return;
+    }
+
+  pp = peer->procptr;
+  if(NULL == pp)
+    {
+      msyslog(LOG_ERR, "NeoClock4X(%d): control: unit invalid/inactive", unit);
+      return;
+    }
+
+  up = (struct neoclock4x_unit *)pp->unitptr;
+  if(NULL == up)
+    {
+      msyslog(LOG_ERR, "NeoClock4X(%d): control: unit invalid/inactive", unit);
+      return;
+    }
+
+  if(NULL != in)
+    {
+      /* check to see if a user supplied time offset is given */
+      if(in->haveflags & CLK_HAVETIME1)
+       {
+         pp->fudgetime1 = in->fudgetime1;
+         NLOG(NLOG_CLOCKINFO)
+           msyslog(LOG_NOTICE, "NeoClock4X(%d): using fudgetime1 with %0.5fs from ntp.conf.",
+                   unit, pp->fudgetime1);
+       }
+
+      /* notify */
+      if(pp->sloppyclockflag & CLK_FLAG1)
+       {
+         NLOG(NLOG_CLOCKINFO)
+           msyslog(LOG_NOTICE, "NeoClock4X(%d): quartz clock is used to synchronize time if radio clock has no reception.", unit);
+       }
+      else
+       {
+         NLOG(NLOG_CLOCKINFO)
+           msyslog(LOG_NOTICE, "NeoClock4X(%d): time is only adjusted with radio signal reception.", unit);
+       }
+    }
+
+  if(NULL != out)
+    {
+      char *tt;
+      char tmpbuf[80];
+
+      out->kv_list = (struct ctl_var *)0;
+      out->type    = REFCLK_NEOCLOCK4X;
+
+      snprintf(tmpbuf, sizeof(tmpbuf)-1,
+              "%04d-%02d-%02d %02d:%02d:%02d.%03d",
+              up->utc_year, up->utc_month, up->utc_day,
+              up->utc_hour, up->utc_minute, up->utc_second,
+              up->utc_msec);
+      tt = add_var(&out->kv_list, sizeof(tmpbuf)-1, RO|DEF);
+      snprintf(tt, sizeof(tmpbuf)-1, "calc_utc=\"%s\"", tmpbuf);
+
+      tt = add_var(&out->kv_list, 40, RO|DEF);
+      snprintf(tt, 39, "radiosignal=\"%s\"", up->radiosignal);
+      tt = add_var(&out->kv_list, 40, RO|DEF);
+      snprintf(tt, 39, "antenna1=\"%d\"", up->antenna1);
+      tt = add_var(&out->kv_list, 40, RO|DEF);
+      snprintf(tt, 39, "antenna2=\"%d\"", up->antenna2);
+      tt = add_var(&out->kv_list, 40, RO|DEF);
+      if('A' == up->timesource)
+       snprintf(tt, 39, "timesource=\"radio\"");
+      else if('C' == up->timesource)
+       snprintf(tt, 39, "timesource=\"quartz\"");
+      else
+       snprintf(tt, 39, "timesource=\"unknown\"");
+      tt = add_var(&out->kv_list, 40, RO|DEF);
+      if('I' == up->quarzstatus)
+       snprintf(tt, 39, "quartzstatus=\"synchronized\"");
+      else if('X' == up->quarzstatus)
+        snprintf(tt, 39, "quartzstatus=\"not synchronized\"");
+      else
+       snprintf(tt, 39, "quartzstatus=\"unknown\"");
+      tt = add_var(&out->kv_list, 40, RO|DEF);
+      if('S' == up->dststatus)
+        snprintf(tt, 39, "dststatus=\"summer\"");
+      else if('W' == up->dststatus)
+        snprintf(tt, 39, "dststatus=\"winter\"");
+      else
+        snprintf(tt, 39, "dststatus=\"unknown\"");
+      tt = add_var(&out->kv_list, 80, RO|DEF);
+      snprintf(tt, 79, "firmware=\"%s\"", up->firmware);
+      tt = add_var(&out->kv_list, 40, RO|DEF);
+      snprintf(tt, 39, "firmwaretag=\"%c\"", up->firmwaretag);
+      tt = add_var(&out->kv_list, 80, RO|DEF);
+      snprintf(tt, 79, "driver version=\"%s\"", NEOCLOCK4X_DRIVER_VERSION);
+      tt = add_var(&out->kv_list, 80, RO|DEF);
+      snprintf(tt, 79, "serialnumber=\"%s\"", up->serial);
+    }
+}
+
+static int
+neol_hexatoi_len(const char str[],
+                int *result,
+                int maxlen)
+{
+  int hexdigit;
+  int i;
+  int n = 0;
+
+  for(i=0; isxdigit((int)str[i]) && i < maxlen; i++)
+    {
+      hexdigit = isdigit((int)str[i]) ? toupper(str[i]) - '0' : toupper(str[i]) - 'A' + 10;
+      n = 16 * n + hexdigit;
+    }
+  *result = n;
+  return (n);
+}
+
+static int
+neol_atoi_len(const char str[],
+                 int *result,
+                 int maxlen)
+{
+  int digit;
+  int i;
+  int n = 0;
+
+  for(i=0; isdigit((int)str[i]) && i < maxlen; i++)
+    {
+      digit = str[i] - '0';
+      n = 10 * n + digit;
+    }
+  *result = n;
+  return (n);
+}
+
+/* Converts Gregorian date to seconds since 1970-01-01 00:00:00.
+ * Assumes input in normal date format, i.e. 1980-12-31 23:59:59
+ * => year=1980, mon=12, day=31, hour=23, min=59, sec=59.
+ *
+ * [For the Julian calendar (which was used in Russia before 1917,
+ * Britain & colonies before 1752, anywhere else before 1582,
+ * and is still in use by some communities) leave out the
+ * -year/100+year/400 terms, and add 10.]
+ *
+ * This algorithm was first published by Gauss (I think).
+ *
+ * WARNING: this function will overflow on 2106-02-07 06:28:16 on
+ * machines were long is 32-bit! (However, as time_t is signed, we
+ * will already get problems at other places on 2038-01-19 03:14:08)
+ */
+static unsigned long
+neol_mktime(int year,
+           int mon,
+           int day,
+           int hour,
+           int min,
+           int sec)
+{
+  if (0 >= (int) (mon -= 2)) {    /* 1..12 . 11,12,1..10 */
+    mon += 12;      /* Puts Feb last since it has leap day */
+    year -= 1;
+  }
+  return (((
+            (unsigned long)(year/4 - year/100 + year/400 + 367*mon/12 + day) +
+            year*365 - 719499
+            )*24 + hour /* now have hours */
+           )*60 + min /* now have minutes */
+          )*60 + sec; /* finally seconds */
+}
+
+static void
+neol_localtime(unsigned long utc,
+              int* year,
+              int* month,
+              int* day,
+              int* hour,
+              int* min,
+              int* sec)
+{
+  *sec = utc % 60;
+  utc /= 60;
+  *min = utc % 60;
+  utc /= 60;
+  *hour = utc % 24;
+  utc /= 24;
+
+  /*             JDN Date 1/1/1970 */
+  neol_jdn_to_ymd(utc + 2440588L, year, month, day);
+}
+
+static void
+neol_jdn_to_ymd(unsigned long jdn,
+               int *yy,
+               int *mm,
+               int *dd)
+{
+  unsigned long x, z, m, d, y;
+  unsigned long daysPer400Years = 146097UL;
+  unsigned long fudgedDaysPer4000Years = 1460970UL + 31UL;
+
+  x = jdn + 68569UL;
+  z = 4UL * x / daysPer400Years;
+  x = x - (daysPer400Years * z + 3UL) / 4UL;
+  y = 4000UL * (x + 1) / fudgedDaysPer4000Years;
+  x = x - 1461UL * y / 4UL + 31UL;
+  m = 80UL * x / 2447UL;
+  d = x - 2447UL * m / 80UL;
+  x = m / 11UL;
+  m = m + 2UL - 12UL * x;
+  y = 100UL * (z - 49UL) + y + x;
+
+  *yy = (int)y;
+  *mm = (int)m;
+  *dd = (int)d;
+}
+
+#if !defined(NEOCLOCK4X_FIRMWARE)
+static int
+neol_query_firmware(int fd,
+                   int unit,
+                   char *firmware,
+                   int maxlen)
+{
+  char tmpbuf[256];
+  int len;
+  int lastsearch;
+  unsigned char c;
+  int last_c_was_crlf;
+  int last_crlf_conv_len;
+  int init;
+  int read_errors;
+  int flag = 0;
+  int chars_read;
+
+  /* wait a little bit */
+  sleep(1);
+  if(-1 != write(fd, "V", 1))
+    {
+      /* wait a little bit */
+      sleep(1);
+      memset(tmpbuf, 0x00, sizeof(tmpbuf));
+
+      len = 0;
+      lastsearch = 0;
+      last_c_was_crlf = 0;
+      last_crlf_conv_len = 0;
+      init = 1;
+      read_errors = 0;
+      chars_read = 0;
+      for(;;)
+       {
+         if(read_errors > 5)
+           {
+             msyslog(LOG_ERR, "NeoClock4X(%d): can't read firmware version (timeout)", unit);
+             strcpy(tmpbuf, "unknown due to timeout");
+             break;
+           }
+          if(chars_read > 500)
+            {
+             msyslog(LOG_ERR, "NeoClock4X(%d): can't read firmware version (garbage)", unit);
+             strcpy(tmpbuf, "unknown due to garbage input");
+             break;
+            }
+         if(-1 == read(fd, &c, 1))
+           {
+              if(EAGAIN != errno)
+                {
+                  msyslog(LOG_DEBUG, "NeoClock4x(%d): read: %s", unit ,strerror(errno));
+                  read_errors++;
+                }
+              else
+                {
+                  sleep(1);
+                }
+             continue;
+           }
+          else
+            {
+              chars_read++;
+            }
+
+         if(init)
+           {
+             if(0xA9 != c) /* wait for (c) char in input stream */
+               continue;
+
+             strcpy(tmpbuf, "(c)");
+             len = 3;
+             init = 0;
+             continue;
+           }
+
+#if 0
+         msyslog(LOG_NOTICE, "NeoClock4X(%d): firmware %c = %02Xh", unit, c, c);
+#endif
+
+         if(0x0A == c || 0x0D == c)
+           {
+             if(last_c_was_crlf)
+               {
+                 char *ptr;
+                 ptr = strstr(&tmpbuf[lastsearch], "S/N");
+                 if(NULL != ptr)
+                   {
+                     tmpbuf[last_crlf_conv_len] = 0;
+                     flag = 1;
+                     break;
+                   }
+                 /* convert \n to / */
+                 last_crlf_conv_len = len;
+                 tmpbuf[len++] = ' ';
+                 tmpbuf[len++] = '/';
+                 tmpbuf[len++] = ' ';
+                 lastsearch = len;
+               }
+             last_c_was_crlf = 1;
+           }
+         else
+           {
+             last_c_was_crlf = 0;
+             if(0x00 != c)
+               tmpbuf[len++] = (char) c;
+           }
+         tmpbuf[len] = '\0';
+         if(len > sizeof(tmpbuf)-5)
+           break;
+       }
+    }
+  else
+    {
+      msyslog(LOG_ERR, "NeoClock4X(%d): can't query firmware version", unit);
+      strcpy(tmpbuf, "unknown error");
+    }
+  strncpy(firmware, tmpbuf, maxlen);
+  firmware[maxlen] = '\0';
+
+  if(flag)
+    {
+      NLOG(NLOG_CLOCKINFO)
+       msyslog(LOG_INFO, "NeoClock4X(%d): firmware version: %s", unit, firmware);
+    }
+
+  return (flag);
+}
+
+static int
+neol_check_firmware(int unit,
+                    const char *firmware,
+                    char *firmwaretag)
+{
+  char *ptr;
+
+  *firmwaretag = '?';
+  ptr = strstr(firmware, "NDF:");
+  if(NULL != ptr)
+    {
+      if((strlen(firmware) - strlen(ptr)) >= 7)
+        {
+          if(':' == *(ptr+5) && '*' == *(ptr+6))
+            *firmwaretag = *(ptr+4);
+        }
+    }
+
+  if('A' != *firmwaretag)
+    {
+      msyslog(LOG_CRIT, "NeoClock4X(%d): firmware version \"%c\" not supported with this driver version!", unit, *firmwaretag);
+      return (0);
+    }
+
+  return (1);
+}
+#endif
+
+#else
+int refclock_neoclock4x_bs;
+#endif /* REFCLOCK */
+
+/*
+ * History:
+ * refclock_neoclock4x.c
+ *
+ * 2002/04/27 cjh
+ * Revision 1.0  first release
+ *
+ * 2002/07/15 cjh
+ * preparing for bitkeeper reposity
+ *
+ * 2002/09/09 cjh
+ * Revision 1.1
+ * - don't assume sprintf returns an int anymore
+ * - change the way the firmware version is read
+ * - some customers would like to put a device called
+ *   data diode to the NeoClock4X device to disable
+ *   the write line. We need to now the firmware
+ *   version even in this case. We made a compile time
+ *   definition in this case. The code was previously
+ *   only available on request.
+ *
+ * 2003/01/08 cjh
+ * Revision 1.11
+ * - changing xprinf to xnprinf to avoid buffer overflows
+ * - change some logic
+ * - fixed memory leaks if drivers can't initialize
+ *
+ * 2003/01/10 cjh
+ * Revision 1.12
+ * - replaced ldiv
+ * - add code to support FreeBSD
+ *
+ * 2003/07/07 cjh
+ * Revision 1.13
+ * - fix reporting of clock status
+ *   changes. previously a bad clock
+ *   status was never reset.
+ *
+ * 2004/04/07 cjh
+ * Revision 1.14
+ * - open serial port in a way
+ *   AIX and some other OS can
+ *   handle much better
+ *
+ * 2006/01/11 cjh
+ * Revision 1.15
+ * - remove some unsued #ifdefs
+ * - fix nsec calculation, closes #499
+ *
+ */
diff --git a/ntpd/refclock_nmea.c b/ntpd/refclock_nmea.c
new file mode 100644 (file)
index 0000000..a176ee8
--- /dev/null
@@ -0,0 +1,763 @@
+/*
+ * refclock_nmea.c - clock driver for an NMEA GPS CLOCK
+ *             Michael Petry Jun 20, 1994
+ *              based on refclock_heathn.c
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_NMEA)
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_unixtime.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#ifdef HAVE_PPSAPI
+# include "ppsapi_timepps.h"
+#endif /* HAVE_PPSAPI */
+
+#ifdef SYS_WINNT
+extern int async_write(int, const void *, unsigned int);
+#undef write
+#define write(fd, data, octets)        async_write(fd, data, octets)
+#endif
+
+/*
+ * This driver supports the NMEA GPS Receiver with
+ *
+ * Protype was refclock_trak.c, Thanks a lot.
+ *
+ * The receiver used spits out the NMEA sentences for boat navigation.
+ * And you thought it was an information superhighway.  Try a raging river
+ * filled with rapids and whirlpools that rip away your data and warp time.
+ *
+ * If HAVE_PPSAPI is defined code to use the PPSAPI will be compiled in.
+ * On startup if initialization of the PPSAPI fails, it will fall back
+ * to the "normal" timestamps.
+ *
+ * The PPSAPI part of the driver understands fudge flag2 and flag3. If
+ * flag2 is set, it will use the clear edge of the pulse. If flag3 is
+ * set, kernel hardpps is enabled.
+ *
+ * GPS sentences other than RMC (the default) may be enabled by setting
+ * the relevent bits of 'mode' in the server configuration line
+ * server 127.127.20.x mode X
+ * 
+ * bit 0 - enables RMC (1)
+ * bit 1 - enables GGA (2)
+ * bit 2 - enables GLL (4)
+ * multiple sentences may be selected
+ */
+
+/*
+ * Definitions
+ */
+#ifdef SYS_WINNT
+# define DEVICE "COM%d:"       /* COM 1 - 3 supported */
+#else
+# define DEVICE        "/dev/gps%d"    /* name of radio device */
+#endif
+#define        SPEED232        B4800   /* uart speed (4800 bps) */
+#define        PRECISION       (-9)    /* precision assumed (about 2 ms) */
+#define        PPS_PRECISION   (-20)   /* precision assumed (about 1 us) */
+#define        REFID           "GPS\0" /* reference id */
+#define        DESCRIPTION     "NMEA GPS Clock" /* who we are */
+#define NANOSECOND     1000000000 /* one second (ns) */
+#define RANGEGATE      500000  /* range gate (ns) */
+
+#define LENNMEA                75      /* min timecode length */
+
+/*
+ * Tables to compute the ddd of year form icky dd/mm 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};
+
+/*
+ * Unit control structure
+ */
+struct nmeaunit {
+       int     pollcnt;        /* poll message counter */
+       int     polled;         /* Hand in a sample? */
+       l_fp    tstamp;         /* timestamp of last poll */
+#ifdef HAVE_PPSAPI
+       struct timespec ts;     /* last timestamp */
+       pps_params_t pps_params; /* pps parameters */
+       pps_info_t pps_info;    /* last pps data */
+       pps_handle_t handle;    /* pps handlebars */
+#endif /* HAVE_PPSAPI */
+};
+
+/*
+ * Function prototypes
+ */
+static int     nmea_start      P((int, struct peer *));
+static void    nmea_shutdown   P((int, struct peer *));
+#ifdef HAVE_PPSAPI
+static void    nmea_control    P((int, struct refclockstat *, struct
+                                   refclockstat *, struct peer *));
+static int     nmea_ppsapi     P((struct peer *, int, int));
+static int     nmea_pps        P((struct nmeaunit *, l_fp *));
+#endif /* HAVE_PPSAPI */
+static void    nmea_receive    P((struct recvbuf *));
+static void    nmea_poll       P((int, struct peer *));
+static void    gps_send        P((int, const char *, struct peer *));
+static char    *field_parse    P((char *, int));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_nmea = {
+       nmea_start,             /* start up driver */
+       nmea_shutdown,  /* shut down driver */
+       nmea_poll,              /* transmit poll message */
+#ifdef HAVE_PPSAPI
+       nmea_control,           /* fudge control */
+#else
+       noentry,                /* fudge control */
+#endif /* HAVE_PPSAPI */
+       noentry,                /* initialize driver */
+       noentry,                /* buginfo */
+       NOFLAGS                 /* not used */
+};
+
+/*
+ * nmea_start - open the GPS devices and initialize data for processing
+ */
+static int
+nmea_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct nmeaunit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+
+       /*
+        * Open serial port. Use CLK line discipline, if available.
+        */
+       (void)sprintf(device, DEVICE, unit);
+
+       fd = refclock_open(device, SPEED232, LDISC_CLK);
+       if (fd <= 0) {
+#ifdef HAVE_READLINK
+          /* nmead support added by Jon Miner (cp_n18@yahoo.com)
+           *
+           * See http://home.hiwaay.net/~taylorc/gps/nmea-server/
+           * for information about nmead
+           *
+           * To use this, you need to create a link from /dev/gpsX to
+           * the server:port where nmead is running.  Something like this:
+           *
+           * ln -s server:port /dev/gps1
+           */
+          char buffer[80];
+          char *nmea_host;
+          int   nmea_port;
+          int   len;
+          struct hostent *he;
+          struct protoent *p;
+          struct sockaddr_in so_addr;
+
+          if ((len = readlink(device,buffer,sizeof(buffer))) == -1)
+            return(0);
+          buffer[len] = 0;
+
+          if ((nmea_host = strtok(buffer,":")) == NULL)
+            return(0);
+         
+          nmea_port = atoi(strtok(NULL,":"));
+
+          if ((he = gethostbyname(nmea_host)) == NULL)
+            return(0);
+          if ((p = getprotobyname("ip")) == NULL)
+            return(0);
+          so_addr.sin_family = AF_INET;
+          so_addr.sin_port = htons(nmea_port);
+          so_addr.sin_addr = *((struct in_addr *) he->h_addr);
+
+          if ((fd = socket(PF_INET,SOCK_STREAM,p->p_proto)) == -1)
+            return(0);
+          if (connect(fd,(struct sockaddr *)&so_addr,SOCKLEN(&so_addr)) == -1) {
+            close(fd);
+            return (0);
+          }
+#else
+            return (0);
+#endif
+        }
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       up = (struct nmeaunit *)emalloc(sizeof(struct nmeaunit));
+       if (up == NULL) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct nmeaunit));
+       pp = peer->procptr;
+       pp->io.clock_recv = nmea_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       up->pollcnt = 2;
+       gps_send(pp->io.fd,"$PMOTG,RMC,0000*1D\r\n", peer);
+
+#ifdef HAVE_PPSAPI
+       /*
+        * Start the PPSAPI interface if it is there. Default to use
+        * the assert edge and do not enable the kernel hardpps.
+        */
+       if (time_pps_create(fd, &up->handle) < 0) {
+               up->handle = 0;
+               msyslog(LOG_ERR,
+                   "refclock_nmea: time_pps_create failed: %m");
+               return (1);
+       }
+       return(nmea_ppsapi(peer, 0, 0));
+#else
+       return (1);
+#endif /* HAVE_PPSAPI */
+}
+
+/*
+ * nmea_shutdown - shut down a GPS clock
+ */
+static void
+nmea_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct nmeaunit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct nmeaunit *)pp->unitptr;
+#ifdef HAVE_PPSAPI
+       if (up->handle != 0)
+               time_pps_destroy(up->handle);
+#endif /* HAVE_PPSAPI */
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+#ifdef HAVE_PPSAPI
+/*
+ * nmea_control - fudge control
+ */
+static void
+nmea_control(
+       int unit,               /* unit (not used */
+       struct refclockstat *in, /* input parameters (not uded) */
+       struct refclockstat *out, /* output parameters (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       nmea_ppsapi(peer, pp->sloppyclockflag & CLK_FLAG2,
+           pp->sloppyclockflag & CLK_FLAG3);
+}
+
+
+/*
+ * Initialize PPSAPI
+ */
+int
+nmea_ppsapi(
+       struct peer *peer,      /* peer structure pointer */
+       int enb_clear,          /* clear enable */
+       int enb_hardpps         /* hardpps enable */
+       )
+{
+       struct refclockproc *pp;
+       struct nmeaunit *up;
+       int capability;
+
+       pp = peer->procptr;
+       up = (struct nmeaunit *)pp->unitptr;
+       if (time_pps_getcap(up->handle, &capability) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_nmea: time_pps_getcap failed: %m");
+               return (0);
+       }
+       memset(&up->pps_params, 0, sizeof(pps_params_t));
+       if (enb_clear)
+               up->pps_params.mode = capability & PPS_CAPTURECLEAR;
+       else
+               up->pps_params.mode = capability & PPS_CAPTUREASSERT;
+       if (!up->pps_params.mode) {
+               msyslog(LOG_ERR,
+                   "refclock_nmea: invalid capture edge %d",
+                   !enb_clear);
+               return (0);
+       }
+       up->pps_params.mode |= PPS_TSFMT_TSPEC;
+       if (time_pps_setparams(up->handle, &up->pps_params) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_nmea: time_pps_setparams failed: %m");
+               return (0);
+       }
+       if (enb_hardpps) {
+               if (time_pps_kcbind(up->handle, PPS_KC_HARDPPS,
+                                   up->pps_params.mode & ~PPS_TSFMT_TSPEC,
+                                   PPS_TSFMT_TSPEC) < 0) {
+                       msyslog(LOG_ERR,
+                           "refclock_nmea: time_pps_kcbind failed: %m");
+                       return (0);
+               }
+               pps_enable = 1;
+       }
+       peer->precision = PPS_PRECISION;
+
+#if DEBUG
+       if (debug) {
+               time_pps_getparams(up->handle, &up->pps_params);
+               printf(
+                   "refclock_ppsapi: capability 0x%x version %d mode 0x%x kern %d\n",
+                   capability, up->pps_params.api_version,
+                   up->pps_params.mode, enb_hardpps);
+       }
+#endif
+
+       return (1);
+}
+
+/*
+ * Get PPSAPI timestamps.
+ *
+ * Return 0 on failure and 1 on success.
+ */
+static int
+nmea_pps(
+       struct nmeaunit *up,
+       l_fp *tsptr
+       )
+{
+       pps_info_t pps_info;
+       struct timespec timeout, ts;
+       double dtemp;
+       l_fp tstmp;
+
+       /*
+        * Convert the timespec nanoseconds field to ntp l_fp units.
+        */ 
+       if (up->handle == 0)
+               return (0);
+       timeout.tv_sec = 0;
+       timeout.tv_nsec = 0;
+       memcpy(&pps_info, &up->pps_info, sizeof(pps_info_t));
+       if (time_pps_fetch(up->handle, PPS_TSFMT_TSPEC, &up->pps_info,
+           &timeout) < 0)
+               return (0);
+       if (up->pps_params.mode & PPS_CAPTUREASSERT) {
+               if (pps_info.assert_sequence ==
+                   up->pps_info.assert_sequence)
+                       return (0);
+               ts = up->pps_info.assert_timestamp;
+       } else if (up->pps_params.mode & PPS_CAPTURECLEAR) {
+               if (pps_info.clear_sequence ==
+                   up->pps_info.clear_sequence)
+                       return (0);
+               ts = up->pps_info.clear_timestamp;
+       } else {
+               return (0);
+       }
+       if ((up->ts.tv_sec == ts.tv_sec) && (up->ts.tv_nsec == ts.tv_nsec))
+               return (0);
+       up->ts = ts;
+
+       tstmp.l_ui = ts.tv_sec + JAN_1970;
+       dtemp = ts.tv_nsec * FRAC / 1e9;
+       tstmp.l_uf = (u_int32)dtemp;
+       *tsptr = tstmp;
+       return (1);
+}
+#endif /* HAVE_PPSAPI */
+
+/*
+ * nmea_receive - receive data from the serial interface
+ */
+static void
+nmea_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct nmeaunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       int month, day;
+       int i;
+       char *cp, *dp;
+       int cmdtype;
+       /* Use these variables to hold data until we decide its worth keeping */
+       char    rd_lastcode[BMAX];
+       l_fp    rd_tmp;
+       u_short rd_lencode;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct nmeaunit *)pp->unitptr;
+       rd_lencode = (u_short)refclock_gtlin(rbufp, rd_lastcode, BMAX, &rd_tmp);
+
+       /*
+        * There is a case that a <CR><LF> gives back a "blank" line
+        */
+       if (rd_lencode == 0)
+           return;
+
+#ifdef DEBUG
+       if (debug)
+           printf("nmea: gpsread %d %s\n", rd_lencode,
+                  rd_lastcode);
+#endif
+
+       /*
+        * We check the timecode format and decode its contents. The
+        * we only care about a few of them.  The most important being
+        * the $GPRMC format
+        * $GPRMC,hhmmss,a,fddmm.xx,n,dddmmm.xx,w,zz.z,yyy.,ddmmyy,dd,v*CC
+        * For Magellan (ColorTrak) GLL probably datum (order of sentences)
+        * also mode (0,1,2,3) select sentence ANY/ALL, RMC, GGA, GLL
+        * $GPGLL,3513.8385,S,14900.7851,E,232420.594,A*21
+        * $GPGGA,232420.59,3513.8385,S,14900.7851,E,1,05,3.4,00519,M,,,,*3F
+        * $GPRMB,...
+        * $GPRMC,232418.19,A,3513.8386,S,14900.7853,E,00.0,000.0,121199,12.,E*77
+        * $GPAPB,...
+        * $GPGSA,...
+        * $GPGSV,...
+        * $GPGSV,...
+        */
+#define GPXXX  0
+#define GPRMC  1
+#define GPGGA  2
+#define GPGLL  4
+       cp = rd_lastcode;
+       cmdtype=0;
+       if(strncmp(cp,"$GPRMC",6)==0) {
+               cmdtype=GPRMC;
+       }
+       else if(strncmp(cp,"$GPGGA",6)==0) {
+               cmdtype=GPGGA;
+       }
+       else if(strncmp(cp,"$GPGLL",6)==0) {
+               cmdtype=GPGLL;
+       }
+       else if(strncmp(cp,"$GPXXX",6)==0) {
+               cmdtype=GPXXX;
+       }
+       else
+           return;
+
+
+       /* See if I want to process this message type */
+       if ( ((peer->ttl == 0) && (cmdtype != GPRMC))
+           || ((peer->ttl != 0) && !(cmdtype & peer->ttl)) )
+               return;
+
+       pp->lencode = rd_lencode;
+       strcpy(pp->a_lastcode,rd_lastcode);
+       cp = pp->a_lastcode;
+
+       pp->lastrec = up->tstamp = rd_tmp;
+       up->pollcnt = 2;
+
+#ifdef DEBUG
+       if (debug)
+           printf("nmea: timecode %d %s\n", pp->lencode,
+                  pp->a_lastcode);
+#endif
+
+
+       /* Grab field depending on clock string type */
+       switch( cmdtype ) {
+           case GPRMC:
+               /*
+                * Test for synchronization.  Check for quality byte.
+                */
+               dp = field_parse(cp,2);
+               if( dp[0] != 'A')
+                       pp->leap = LEAP_NOTINSYNC;
+               else
+                       pp->leap = LEAP_NOWARNING;
+
+               /* Now point at the time field */
+               dp = field_parse(cp,1);
+               break;
+
+
+           case GPGGA:
+               /*
+                * Test for synchronization.  Check for quality byte.
+                */
+               dp = field_parse(cp,6);
+               if( dp[0] == '0')
+                       pp->leap = LEAP_NOTINSYNC;
+               else
+                       pp->leap = LEAP_NOWARNING;
+
+               /* Now point at the time field */
+               dp = field_parse(cp,1);
+               break;
+
+
+           case GPGLL:
+               /*
+                * Test for synchronization.  Check for quality byte.
+                */
+               dp = field_parse(cp,6);
+               if( dp[0] != 'A')
+                       pp->leap = LEAP_NOTINSYNC;
+               else
+                       pp->leap = LEAP_NOWARNING;
+
+               /* Now point at the time field */
+               dp = field_parse(cp,5);
+               break;
+
+
+           case GPXXX:
+               return;
+           default:
+               return;
+
+       }
+
+               /*
+                *      Check time code format of NMEA
+                */
+
+               if( !isdigit((int)dp[0]) ||
+                   !isdigit((int)dp[1]) ||
+                   !isdigit((int)dp[2]) ||
+                   !isdigit((int)dp[3]) ||
+                   !isdigit((int)dp[4]) ||
+                   !isdigit((int)dp[5])        
+                   ) {
+                       refclock_report(peer, CEVNT_BADREPLY);
+                       return;
+               }
+
+
+       /*
+        * Convert time and check values.
+        */
+       pp->hour = ((dp[0] - '0') * 10) + dp[1] - '0';
+       pp->minute = ((dp[2] - '0') * 10) + dp[3] -  '0';
+       pp->second = ((dp[4] - '0') * 10) + dp[5] - '0';
+       /* Default to 0 milliseconds, if decimal convert milliseconds in
+          one, two or three digits
+       */
+       pp->nsec = 0; 
+       if (dp[6] == '.') {
+               if (isdigit((int)dp[7])) {
+                       pp->nsec = (dp[7] - '0') * 100000000;
+                       if (isdigit((int)dp[8])) {
+                               pp->nsec += (dp[8] - '0') * 10000000;
+                               if (isdigit((int)dp[9])) {
+                                       pp->nsec += (dp[9] - '0') * 1000000;
+                               }
+                       }
+               }
+       }
+
+       if (pp->hour > 23 || pp->minute > 59 || pp->second > 59
+         || pp->nsec > 1000000000) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+
+
+       /*
+        * Convert date and check values.
+        */
+       if (cmdtype==GPRMC) {
+           dp = field_parse(cp,9);
+           day = dp[0] - '0';
+           day = (day * 10) + dp[1] - '0';
+           month = dp[2] - '0';
+           month = (month * 10) + dp[3] - '0';
+           pp->year = dp[4] - '0';
+           pp->year = (pp->year * 10) + dp[5] - '0';
+       }
+       else {
+       /* only time */
+           time_t tt = time(NULL);
+           struct tm * t = gmtime(&tt);
+           day = t->tm_mday;
+           month = t->tm_mon + 1;
+           pp->year= t->tm_year;
+       }
+
+       if (month < 1 || month > 12 || day < 1) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+
+        /* Hmmmm this will be a nono for 2100,2200,2300 but I don't think I'll be here */
+        /* good thing that 2000 is a leap year */
+       /* pp->year will be 00-99 if read from GPS, 00->  (years since 1900) from tm_year */
+       if (pp->year % 4) {
+               if (day > day1tab[month - 1]) {
+                       refclock_report(peer, CEVNT_BADTIME);
+                       return;
+               }
+               for (i = 0; i < month - 1; i++)
+                   day += day1tab[i];
+       } else {
+               if (day > day2tab[month - 1]) {
+                       refclock_report(peer, CEVNT_BADTIME);
+                       return;
+               }
+               for (i = 0; i < month - 1; i++)
+                   day += day2tab[i];
+       }
+       pp->day = day;
+
+
+#ifdef HAVE_PPSAPI
+       /*
+        * If the PPSAPI is working, rather use its timestamps.
+        * assume that the PPS occurs on the second so blow any msec
+        */
+       if (nmea_pps(up, &rd_tmp) == 1) {
+               pp->lastrec = up->tstamp = rd_tmp;
+               pp->nsec = 0;
+       }
+#endif /* HAVE_PPSAPI */
+
+       /*
+        * Process the new sample in the median filter and determine the
+        * reference clock offset and dispersion. We use lastrec as both
+        * the reference time and receive time, in order to avoid being
+        * cute, like setting the reference time later than the receive
+        * time, which may cause a paranoid protocol module to chuck out
+        * the data.
+        */
+
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+
+
+
+       /*
+        * Only go on if we had been polled.
+        */
+       if (!up->polled)
+           return;
+       up->polled = 0;
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+
+        /* If we get here - what we got from the clock is OK, so say so */
+         refclock_report(peer, CEVNT_NOMINAL);
+
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+
+}
+
+/*
+ * nmea_poll - called by the transmit procedure
+ *
+ * We go to great pains to avoid changing state here, since there may be
+ * more than one eavesdropper receiving the same timecode.
+ */
+static void
+nmea_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct nmeaunit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct nmeaunit *)pp->unitptr;
+       if (up->pollcnt == 0)
+           refclock_report(peer, CEVNT_TIMEOUT);
+       else
+           up->pollcnt--;
+       pp->polls++;
+       up->polled = 1;
+
+       /*
+        * usually nmea_receive can get a timestamp every second
+        */
+
+       gps_send(pp->io.fd,"$PMOTG,RMC,0000*1D\r\n", peer);
+}
+
+/*
+ *
+ *     gps_send(fd,cmd, peer)  Sends a command to the GPS receiver.
+ *      as     gps_send(fd,"rqts,u\r", peer);
+ *
+ *     We don't currently send any data, but would like to send
+ *     RTCM SC104 messages for differential positioning. It should
+ *     also give us better time. Without a PPS output, we're
+ *     Just fooling ourselves because of the serial code paths
+ *
+ */
+static void
+gps_send(
+       int fd,
+       const char *cmd,
+       struct peer *peer
+       )
+{
+
+       if (write(fd, cmd, strlen(cmd)) == -1) {
+               refclock_report(peer, CEVNT_FAULT);
+       }
+}
+
+static char *
+field_parse(
+       char *cp,
+       int fn
+       )
+{
+       char *tp;
+       int i = fn;
+
+       for (tp = cp; *tp != '\0'; tp++) {
+               if (*tp == ',')
+                   i--;
+               if (i == 0)
+                   break;
+       }
+       return (++tp);
+}
+#else
+int refclock_nmea_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_oncore.c b/ntpd/refclock_oncore.c
new file mode 100644 (file)
index 0000000..e1d23a9
--- /dev/null
@@ -0,0 +1,3732 @@
+/*
+ * ----------------------------------------------------------------------------
+ * "THE BEER-WARE LICENSE" (Revision 42):
+ * <phk@FreeBSD.ORG> wrote this file.  As long as you retain this notice you
+ * can do whatever you want with this stuff. If we meet some day, and you think
+ * this stuff is worth it, you can buy me a beer in return.   Poul-Henning Kamp
+ * ----------------------------------------------------------------------------
+ *
+ * refclock_oncore.c
+ *
+ * Driver for some of the various the Motorola Oncore GPS receivers.
+ *   should work with Basic, PVT6, VP, UT, UT+, GT, GT+, SL, M12, M12+T
+ *     The receivers with TRAIM (VP, UT, UT+, M12+T), will be more accurate
+ *     than the others.
+ *     The receivers without position hold (GT, GT+) will be less accurate.
+ *
+ * Tested with:
+ *
+ *             (UT)                               (VP)
+ *   COPYRIGHT 1991-1997 MOTOROLA INC. COPYRIGHT 1991-1996 MOTOROLA INC.
+ *   SFTW P/N #     98-P36848P         SFTW P/N # 98-P36830P
+ *   SOFTWARE VER # 2                  SOFTWARE VER # 8
+ *   SOFTWARE REV # 2                  SOFTWARE REV # 8
+ *   SOFTWARE DATE  APR 24 1998        SOFTWARE DATE  06 Aug 1996
+ *   MODEL #   R1121N1114              MODEL #    B4121P1155
+ *   HWDR P/N # 1                      HDWR P/N # _
+ *   SERIAL #  R0010A                  SERIAL #   SSG0226478
+ *   MANUFACTUR DATE 6H07              MANUFACTUR DATE 7E02
+ *                                     OPTIONS LIST    IB
+ *
+ *           (Basic)                              (M12)
+ *   COPYRIGHT 1991-1994 MOTOROLA INC. COPYRIGHT 1991-2000 MOTOROLA INC.
+ *   SFTW P/N # 98-P39949M             SFTW P/N # 61-G10002A
+ *   SOFTWARE VER # 5                  SOFTWARE VER # 1
+ *   SOFTWARE REV # 0                  SOFTWARE REV # 3
+ *   SOFTWARE DATE  20 JAN 1994        SOFTWARE DATE  Mar 13 2000
+ *   MODEL #   A11121P116              MODEL #    P143T12NR1
+ *   HDWR P/N # _                      HWDR P/N # 1
+ *   SERIAL #  SSG0049809              SERIAL #   P003UD
+ *   MANUFACTUR DATE 417AMA199         MANUFACTUR DATE 0C27
+ *   OPTIONS LIST    AB
+ *
+ *           (M12+T)                             (M12+T later version)
+ *   COPYRIGHT 1991-2002 MOTOROLA INC. COPYRIGHT 1991-2003 MOTOROLA INC.
+ *   SFTW P/N #     61-G10268A         SFTW P/N #     61-G10268A
+ *   SOFTWARE VER # 2                  SOFTWARE VER # 2
+ *   SOFTWARE REV # 0                  SOFTWARE REV # 1
+ *   SOFTWARE DATE  AUG 14 2002        SOFTWARE DATE  APR 16 2003
+ *   MODEL #   P283T12T11              MODEL #    P273T12T12
+ *   HWDR P/N # 2                      HWDR P/N # 2
+ *   SERIAL #  P04DC2                  SERIAL #   P05Z7Z
+ *   MANUFACTUR DATE 2J17              MANUFACTUR DATE 3G15
+ *
+ * --------------------------------------------------------------------------
+ * Reg Clemens (Feb 2006)
+ * Fix some gcc4 compiler complaints
+ * Fix possible segfault in oncore_init_shmem
+ * change all (possible) fprintf(stderr, to record_clock_stats
+ * Apply patch from Russell J. Yount <rjy@cmu.edu> Fixed (new) MT12+T UTC not correct
+ *   immediately after new Almanac Read.
+ * Apply patch for new PPS implementation by Rodolfo Giometti <giometti@linux.it>
+ *   now code can use old Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de> or
+ *   the new one.  Compiles depending on timepps.h seen.
+ * --------------------------------------------------------------------------
+ * Luis Batanero Guerrero <luisba@rao.es> (Dec 2005) Patch for leap seconds
+ * (the oncore driver was setting the wrong ntpd variable)
+ * --------------------------------------------------------------------------
+ * Reg.Clemens (Mar 2004)
+ * Support for interfaces other than PPSAPI removed, for Solaris, SunOS,
+ * SCO, you now need to use one of the timepps.h files in the root dir.
+ * this driver will 'grab' it for you if you dont have one in /usr/include
+ * --------------------------------------------------------------------------
+ * This code uses the two devices
+ *     /dev/oncore.serial.n
+ *     /dev/oncore.pps.n
+ * which may be linked to the same device.
+ * and can read initialization data from the file
+ *     /etc/ntp.oncoreN, /etc/ntp.oncore.N, or /etc/ntp.oncore, where
+ *     n or N are the unit number, viz 127.127.30.N.
+ * --------------------------------------------------------------------------
+ * Reg.Clemens <reg@dwf.com> Sep98.
+ *  Original code written for FreeBSD.
+ *  With these mods it works on FreeBSD, SunOS, Solaris and Linux
+ *    (SunOS 4.1.3 + ppsclock)
+ *    (Solaris7 + MU4)
+ *    (RedHat 5.1 2.0.35 + PPSKit, 2.1.126 + or later).
+ *
+ *  Lat,Long,Ht, cable-delay, offset, and the ReceiverID (along with the
+ *  state machine state) are printed to CLOCKSTATS if that file is enabled
+ *  in /etc/ntp.conf.
+ *
+ * --------------------------------------------------------------------------
+ *
+ * According to the ONCORE manual (TRM0003, Rev 3.2, June 1998, page 3.13)
+ * doing an average of 10000 valid 2D and 3D fixes is what the automatic
+ * site survey mode does.  Looking at the output from the receiver
+ * it seems like it is only using 3D fixes.
+ * When we do it ourselves, take 10000 3D fixes.
+ */
+
+#define POS_HOLD_AVERAGE       10000   /* nb, 10000s ~= 2h45m */
+
+/*
+ * ONCORE_SHMEM_STATUS will create a mmap(2)'ed file named according to a
+ * "STATUS" line in the oncore config file, which contains the most recent
+ * copy of all types of messages we recognize. This file can be mmap(2)'ed
+ * by monitoring and statistics programs.
+ *
+ * See separate HTML documentation for this option.
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_ONCORE)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_unixtime.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <sys/stat.h>
+#ifdef ONCORE_SHMEM_STATUS
+# ifdef HAVE_SYS_MMAN_H
+#  include <sys/mman.h>
+#  ifndef MAP_FAILED
+#   define MAP_FAILED ((u_char *) -1)
+#  endif  /* MAP_FAILED */
+# endif /* HAVE_SYS_MMAN_H */
+#endif /* ONCORE_SHMEM_STATUS */
+
+#ifdef HAVE_PPSAPI
+# include "ppsapi_timepps.h"
+#endif
+
+#ifdef HAVE_SYS_SIO_H
+# include <sys/sio.h>
+#endif
+
+enum receive_state {
+       ONCORE_NO_IDEA,
+       ONCORE_CHECK_ID,
+       ONCORE_CHECK_CHAN,
+       ONCORE_HAVE_CHAN,
+       ONCORE_RESET_SENT,
+       ONCORE_TEST_SENT,
+       ONCORE_INIT,
+       ONCORE_ALMANAC,
+       ONCORE_RUN
+};
+
+enum site_survey_state {
+       ONCORE_SS_UNKNOWN,
+       ONCORE_SS_TESTING,
+       ONCORE_SS_HW,
+       ONCORE_SS_SW,
+       ONCORE_SS_DONE
+};
+
+enum antenna_state {
+      ONCORE_ANTENNA_UNKNOWN = -1,
+      ONCORE_ANTENNA_OK      = 0,
+      ONCORE_ANTENNA_OC      = 1,
+      ONCORE_ANTENNA_UC      = 2,
+      ONCORE_ANTENNA_NV      = 3
+};
+
+/* Model Name, derived from the @@Cj message.
+ * Used to initialize some variables.
+ */
+
+enum oncore_model {
+       ONCORE_BASIC,
+       ONCORE_PVT6,
+       ONCORE_VP,
+       ONCORE_UT,
+       ONCORE_UTPLUS,
+       ONCORE_GT,
+       ONCORE_GTPLUS,
+       ONCORE_SL,
+       ONCORE_M12,
+       ONCORE_UNKNOWN
+};
+
+/* the bits that describe these properties are in the same place
+ * on the VP/UT, but have moved on the M12.  As such we extract
+ * them, and use them from this struct.
+ *
+ */
+
+struct RSM {
+       u_char  posn0D;
+       u_char  posn2D;
+       u_char  posn3D;
+       u_char  bad_almanac;
+       u_char  bad_fix;
+};
+
+/* It is possible to test the VP/UT each cycle (@@Ea or equivalent) to
+ * see what mode it is in.  The bits on the M12 are multiplexed with
+ * other messages, so we have to 'keep' the last known mode here.
+ */
+
+enum posn_mode {
+       MODE_UNKNOWN,
+       MODE_0D,
+       MODE_2D,
+       MODE_3D
+};
+
+struct instance {
+       int     unit;           /* 127.127.30.unit */
+       struct  refclockproc *pp;
+       struct  peer *peer;
+
+       int     ttyfd;          /* TTY file descriptor */
+       int     ppsfd;          /* PPS file descriptor */
+       int     shmemfd;        /* Status shm descriptor */
+       pps_handle_t pps_h;
+       pps_params_t pps_p;
+       enum receive_state o_state;             /* Receive state */
+       enum posn_mode mode;                    /* 0D, 2D, 3D */
+       enum site_survey_state site_survey;     /* Site Survey state */
+       enum antenna_state ant_state;           /* antenna state */
+
+       int     Bj_day;
+
+       u_long  delay;          /* ns */
+       long    offset;         /* ns */
+
+       u_char  *shmem;
+       char    *shmem_fname;
+       u_int   shmem_Cb;
+       u_int   shmem_Ba;
+       u_int   shmem_Ea;
+       u_int   shmem_Ha;
+       u_char  shmem_reset;
+       u_char  shmem_Posn;
+       u_char  shmem_bad_Ea;
+       u_char  almanac_from_shmem;
+
+       double  ss_lat;
+       double  ss_long;
+       double  ss_ht;
+       double  dH;
+       int     ss_count;
+       u_char  posn_set;
+
+       enum oncore_model model;
+       u_int   version;
+       u_int   revision;
+
+       u_char  chan;           /* 6 for PVT6 or BASIC, 8 for UT/VP, 12 for m12, 0 if unknown */
+       s_char  traim;          /* do we have traim? yes UT/VP, M12+T, no BASIC, GT, M12, -1 unknown, 0 no, +1 yes */
+                               /* the following 7 are all timing counters */
+       u_char  traim_delay;    /* seconds counter, waiting for reply */
+       u_char  count;          /* cycles thru Ea before starting */
+       u_char  count1;         /* cycles thru Ea after SS_TESTING, waiting for SS_HW */
+       u_char  count2;         /* cycles thru Ea after count, to check for @@Ea */
+       u_char  count3;         /* cycles thru Ea checking for # channels */
+       u_char  count4;         /* cycles thru leap after Gj to issue Bj */
+       u_char  count5;         /* cycles thru get_timestamp waiting for valid UTC correction */
+       u_char  count5_set;     /* only set count5 once */
+       u_char  pollcnt;
+       u_char  timeout;        /* count to retry Cj after Fa self-test */
+
+       struct  RSM rsm;        /* bits extracted from Receiver Status Msg in @@Ea */
+       u_char  printed;
+       u_char  polled;
+       u_long  ev_serial;
+       int     Rcvptr;
+       u_char  Rcvbuf[500];
+       u_char  BEHa[160];      /* Ba, Ea or Ha */
+       u_char  BEHn[80];       /* Bn , En , or Hn */
+       u_char  Cj[300];
+       u_char  Ag;             /* Satellite mask angle */
+       u_char  saw_At;
+       u_char  saw_Ay;
+       u_char  saw_Az;
+       s_char  saw_Gj;
+       u_char  have_dH;
+       u_char  init_type;
+       s_char  saw_tooth;
+       s_char  chan_in;        /* chan number from INPUT, will always use it */
+       u_char  chan_id;        /* chan number determined from part number */
+       u_char  chan_ck;        /* chan number determined by sending commands to hardware */
+       s_char  traim_in;       /* TRAIM from INPUT, will always use ON/OFF specified */
+       s_char  traim_id;       /* TRAIM determined from part number */
+       u_char  traim_ck;       /* TRAIM determined by sending commands to hardware */
+       u_char  once;           /* one pass code at top of BaEaHa */
+       s_char  assert;
+       u_char  hardpps;
+};
+
+#define rcvbuf instance->Rcvbuf
+#define rcvptr instance->Rcvptr
+
+static int     oncore_start          P((int, struct peer *));
+static void    oncore_poll           P((int, struct peer *));
+static void    oncore_shutdown       P((int, struct peer *));
+static void    oncore_consume        P((struct instance *));
+static void    oncore_read_config    P((struct instance *));
+static void    oncore_receive        P((struct recvbuf *));
+static int     oncore_ppsapi         P((struct instance *));
+static void    oncore_get_timestamp  P((struct instance *, long, long));
+static void    oncore_init_shmem     P((struct instance *));
+
+static void    oncore_antenna_report P((struct instance *, enum antenna_state));
+static void    oncore_chan_test      P((struct instance *));
+static void    oncore_check_almanac  P((struct instance *));
+static void    oncore_check_antenna  P((struct instance *));
+static void    oncore_check_leap_sec P((struct instance *));
+static int     oncore_checksum_ok    P((u_char *, int));
+static void    oncore_compute_dH     P((struct instance *));
+static void    oncore_load_almanac   P((struct instance *));
+static void    oncore_print_Cb       P((struct instance *, u_char *));
+/* static  void    oncore_print_array   P((u_char *, int));    */
+static void    oncore_print_posn     P((struct instance *));
+static void    oncore_sendmsg        P((int, u_char *, size_t));
+static void    oncore_set_posn       P((struct instance *));
+static void    oncore_set_traim      P((struct instance *));
+static void    oncore_shmem_get_3D   P((struct instance *));
+static void    oncore_ss             P((struct instance *));
+static int     oncore_wait_almanac   P((struct instance *));
+
+static void    oncore_msg_any     P((struct instance *, u_char *, size_t, int));
+static void    oncore_msg_Adef    P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Ag      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_As      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_At      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Ay      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Az      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_BaEaHa  P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Bd      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Bj      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_BnEnHn  P((struct instance *, u_char *, size_t));
+static void    oncore_msg_CaFaIa  P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Cb      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Cf      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Cj      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Cj_id   P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Cj_init P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Ga      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Gb      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Gj      P((struct instance *, u_char *, size_t));
+static void    oncore_msg_Sz      P((struct instance *, u_char *, size_t));
+
+struct refclock refclock_oncore = {
+       oncore_start,           /* start up driver */
+       oncore_shutdown,        /* shut down driver */
+       oncore_poll,            /* transmit poll message */
+       noentry,                /* not used */
+       noentry,                /* not used */
+       noentry,                /* not used */
+       NOFLAGS                 /* not used */
+};
+
+/*
+ * Understanding the next bit here is not easy unless you have a manual
+ * for the the various Oncore Models.
+ */
+
+static struct msg_desc {
+       const char      flag[3];
+       const int       len;
+       void            (*handler) P((struct instance *, u_char *, size_t));
+       const char      *fmt;
+       int             shmem;
+} oncore_messages[] = {
+                       /* Ea and En first since they're most common */
+       { "Ea",  76,    oncore_msg_BaEaHa, "mdyyhmsffffaaaaoooohhhhmmmmvvhhddtntimsdimsdimsdimsdimsdimsdimsdimsdsC" },
+       { "Ba",  68,    oncore_msg_BaEaHa, "mdyyhmsffffaaaaoooohhhhmmmmvvhhddtntimsdimsdimsdimsdimsdimsdsC" },
+       { "Ha", 154,    oncore_msg_BaEaHa, "mdyyhmsffffaaaaoooohhhhmmmmaaaaoooohhhhmmmmVVvvhhddntimsiddimsiddimsiddimsiddimsiddimsiddimsiddimsiddimsiddimsiddimsiddimsiddssrrccooooTTushmvvvvvvC" },
+       { "Bn",  59,    oncore_msg_BnEnHn, "otaapxxxxxxxxxxpysreensffffsffffsffffsffffsffffsffffC" },
+       { "En",  69,    oncore_msg_BnEnHn, "otaapxxxxxxxxxxpysreensffffsffffsffffsffffsffffsffffsffffsffffC" },
+       { "Hn",  78,    oncore_msg_BnEnHn, "" },
+       { "Ab",  10,    0,                 "" },
+       { "Ac",  11,    0,                 "" },
+       { "Ad",  11,    oncore_msg_Adef,   "" },
+       { "Ae",  11,    oncore_msg_Adef,   "" },
+       { "Af",  15,    oncore_msg_Adef,   "" },
+       { "Ag",   8,    oncore_msg_Ag,     "" }, /* Satellite mask angle */
+       { "As",  20,    oncore_msg_As,     "" },
+       { "At",   8,    oncore_msg_At,     "" },
+       { "Au",  12,    0,                 "" },
+       { "Av",   8,    0,                 "" },
+       { "Aw",   8,    0,                 "" },
+       { "Ay",  11,    oncore_msg_Ay,     "" },
+       { "Az",  11,    oncore_msg_Az,     "" },
+       { "AB",   8,    0,                 "" },
+       { "Bb",  92,    0,                 "" },
+       { "Bd",  23,    oncore_msg_Bd,     "" },
+       { "Bj",   8,    oncore_msg_Bj,     "" },
+       { "Ca",   9,    oncore_msg_CaFaIa, "" },
+       { "Cb",  33,    oncore_msg_Cb,     "" },
+       { "Cf",   7,    oncore_msg_Cf,     "" },
+       { "Cg",   8,    0,                 "" },
+       { "Ch",   9,    0,                 "" },
+       { "Cj", 294,    oncore_msg_Cj,     "" },
+       { "Ek",  71,    0,                 "" },
+       { "Fa",   9,    oncore_msg_CaFaIa, "" },
+       { "Ga",  20,    oncore_msg_Ga,     "" },
+       { "Gb",  17,    oncore_msg_Gb,     "" },
+       { "Gc",   8,    0,                 "" },
+       { "Gd",   8,    0,                 "" },
+       { "Ge",   8,    0,                 "" },
+       { "Gj",  21,    oncore_msg_Gj,     "" },
+       { "Ia",  10,    oncore_msg_CaFaIa, "" },
+       { "Sz",   8,    oncore_msg_Sz,     "" },
+       { {0},    7,    0,                 "" }
+};
+
+
+static u_char oncore_cmd_Aa[]  = { 'A', 'a', 0, 0, 0 };                            /* 6/8      Time of Day                             */
+static u_char oncore_cmd_Ab[]  = { 'A', 'b', 0, 0, 0 };                            /* 6/8      GMT Correction                          */
+static u_char oncore_cmd_AB[]  = { 'A', 'B', 4 };                                  /* VP       Application Type: Static                */
+static u_char oncore_cmd_Ac[]  = { 'A', 'c', 0, 0, 0, 0 };                         /* 6/8      Date                                    */
+static u_char oncore_cmd_Ad[]  = { 'A', 'd', 0,0,0,0 };                            /* 6/8      Latitude                                */
+static u_char oncore_cmd_Ae[]  = { 'A', 'e', 0,0,0,0 };                            /* 6/8      Longitude                               */
+static u_char oncore_cmd_Af[]  = { 'A', 'f', 0,0,0,0, 0 };                         /* 6/8      Height                                  */
+static u_char oncore_cmd_Ag[]  = { 'A', 'g', 0 };                                  /* 6/8/12   Satellite Mask Angle                    */
+static u_char oncore_cmd_Agx[] = { 'A', 'g', 0xff };                               /* 6/8/12   Satellite Mask Angle: read              */
+static u_char oncore_cmd_As[]  = { 'A', 's', 0,0,0,0, 0,0,0,0, 0,0,0,0, 0 };       /* 6/8/12   Posn Hold Parameters                    */
+static u_char oncore_cmd_Asx[] = { 'A', 's', 0x7f,0xff,0xff,0xff,                  /* 6/8/12   Posn Hold Readback                      */
+                                            0x7f,0xff,0xff,0xff,                   /*           on UT+ this doesnt work with 0xff      */
+                                            0x7f,0xff,0xff,0xff, 0xff };           /*           but does work with 0x7f (sigh).        */
+static u_char oncore_cmd_At0[] = { 'A', 't', 0 };                                  /* 6/8      Posn Hold: off                          */
+static u_char oncore_cmd_At1[] = { 'A', 't', 1 };                                  /* 6/8      Posn Hold: on                           */
+static u_char oncore_cmd_At2[] = { 'A', 't', 2 };                                  /* 6/8      Posn Hold: Start Site Survey            */
+static u_char oncore_cmd_Atx[] = { 'A', 't', 0xff };                               /* 6/8      Posn Hold: Read Back                    */
+static u_char oncore_cmd_Au[]  = { 'A', 'u', 0,0,0,0, 0 };                         /* GT/M12   Altitude Hold Ht.                       */
+static u_char oncore_cmd_Av0[] = { 'A', 'v', 0 };                                  /* VP/GT    Altitude Hold: off                      */
+static u_char oncore_cmd_Av1[] = { 'A', 'v', 1 };                                  /* VP/GT    Altitude Hold: on                       */
+static u_char oncore_cmd_Aw[]  = { 'A', 'w', 1 };                                  /* 6/8/12   UTC/GPS time selection                  */
+static u_char oncore_cmd_Ay[]  = { 'A', 'y', 0, 0, 0, 0 };                         /* Timing   1PPS time offset: set                   */
+static u_char oncore_cmd_Ayx[] = { 'A', 'y', 0xff, 0xff, 0xff, 0xff };             /* Timing   1PPS time offset: Read                  */
+static u_char oncore_cmd_Az[]  = { 'A', 'z', 0, 0, 0, 0 };                         /* 6/8UT/12 1PPS Cable Delay: set                   */
+static u_char oncore_cmd_Azx[] = { 'A', 'z', 0xff, 0xff, 0xff, 0xff };             /* 6/8UT/12 1PPS Cable Delay: Read                  */
+static u_char oncore_cmd_Ba0[] = { 'B', 'a', 0 };                                  /* 6        Position/Data/Status: off               */
+static u_char oncore_cmd_Ba[]  = { 'B', 'a', 1 };                                  /* 6        Position/Data/Status: on                */
+static u_char oncore_cmd_Bb[]  = { 'B', 'b', 1 };                                  /* 6/8/12   Visible Satellites                      */
+static u_char oncore_cmd_Bd[]  = { 'B', 'd', 1 };                                  /* 6/8/12?  Almanac Status Msg.                     */
+static u_char oncore_cmd_Be[]  = { 'B', 'e', 1 };                                  /* 6/8/12   Request Almanac Data                    */
+static u_char oncore_cmd_Bj[]  = { 'B', 'j', 0 };                                  /* 6/8      Leap Second Pending                     */
+static u_char oncore_cmd_Bn0[] = { 'B', 'n', 0, 1, 0,10, 2, 0,0,0, 0,0,0,0,0,0,0 }; /* 6       TRAIM setup/status: msg off, traim on   */
+static u_char oncore_cmd_Bn[]  = { 'B', 'n', 1, 1, 0,10, 2, 0,0,0, 0,0,0,0,0,0,0 }; /* 6       TRAIM setup/status: msg on,  traim on   */
+static u_char oncore_cmd_Bnx[] = { 'B', 'n', 0, 0, 0,10, 2, 0,0,0, 0,0,0,0,0,0,0 }; /* 6       TRAIM setup/status: msg off, traim off  */
+static u_char oncore_cmd_Ca[]  = { 'C', 'a' };                                     /* 6        Self Test                               */
+static u_char oncore_cmd_Cf[]  = { 'C', 'f' };                                     /* 6/8/12   Set to Defaults                         */
+static u_char oncore_cmd_Cg[]  = { 'C', 'g', 1 };                                  /* VP       Posn Fix/Idle Mode                      */
+static u_char oncore_cmd_Cj[]  = { 'C', 'j' };                                     /* 6/8/12   Receiver ID                             */
+static u_char oncore_cmd_Ea0[] = { 'E', 'a', 0 };                                  /* 8        Position/Data/Status: off               */
+static u_char oncore_cmd_Ea[]  = { 'E', 'a', 1 };                                  /* 8        Position/Data/Status: on                */
+static u_char oncore_cmd_Ek[]  = { 'E', 'k', 0 }; /* just turn off */              /* 8        Posn/Status/Data - extension            */
+static u_char oncore_cmd_En0[] = { 'E', 'n', 0, 1, 0,10, 2, 0,0,0, 0,0,0,0,0,0,0 }; /* 8/GT    TRAIM setup/status: msg off, traim on   */
+static u_char oncore_cmd_En[]  = { 'E', 'n', 1, 1, 0,10, 2, 0,0,0, 0,0,0,0,0,0,0 }; /* 8/GT    TRAIM setup/status: msg on,  traim on   */
+static u_char oncore_cmd_Enx[] = { 'E', 'n', 0, 0, 0,10, 2, 0,0,0, 0,0,0,0,0,0,0 }; /* 8/GT    TRAIM setup/status: msg off, traim off  */
+static u_char oncore_cmd_Fa[]  = { 'F', 'a' };                                     /* 8        Self Test                               */
+static u_char oncore_cmd_Ga[]  = { 'G', 'a', 0,0,0,0, 0,0,0,0, 0,0,0,0, 0 };       /* 12       Position Set                            */
+static u_char oncore_cmd_Gax[] = { 'G', 'a', 0xff, 0xff, 0xff, 0xff,               /* 12       Position Set: Read                      */
+                                            0xff, 0xff, 0xff, 0xff,                /*                                                  */
+                                            0xff, 0xff, 0xff, 0xff, 0xff };        /*                                                  */
+static u_char oncore_cmd_Gb[]  = { 'G', 'b', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 };       /* 12       set Date/Time                           */
+static u_char oncore_cmd_Gc[]  = { 'G', 'c', 1 };                                  /* 12       PPS Control: On Cont                    */
+static u_char oncore_cmd_Gd0[] = { 'G', 'd', 0 };                                  /* 12       Position Control: 3D (no hold)          */
+static u_char oncore_cmd_Gd1[] = { 'G', 'd', 1 };                                  /* 12       Position Control: 0D (3D hold)          */
+static u_char oncore_cmd_Gd2[] = { 'G', 'd', 2 };                                  /* 12       Position Control: 2D (Alt Hold)         */
+static u_char oncore_cmd_Gd3[] = { 'G', 'd', 3 };                                  /* 12       Position Coltrol: Start Site Survey     */
+static u_char oncore_cmd_Ge0[] = { 'G', 'e', 0 };                                  /* M12+T    TRAIM: off                              */
+static u_char oncore_cmd_Ge[]  = { 'G', 'e', 1 };                                  /* M12+T    TRAIM: on                               */
+static u_char oncore_cmd_Gj[]  = { 'G', 'j' };                                     /* 8?/12    Leap Second Pending                     */
+static u_char oncore_cmd_Ha0[] = { 'H', 'a', 0 };                                  /* 12       Position/Data/Status: off               */
+static u_char oncore_cmd_Ha[]  = { 'H', 'a', 1 };                                  /* 12       Position/Data/Status: on                */
+static u_char oncore_cmd_Hn0[] = { 'H', 'n', 0 };                                  /* 12       TRAIM Status: off                       */
+static u_char oncore_cmd_Hn[]  = { 'H', 'n', 1 };                                  /* 12       TRAIM Status: on                        */
+static u_char oncore_cmd_Ia[]  = { 'I', 'a' };                                     /* 12       Self Test                               */
+
+/* it appears that as of 1997/1998, the UT had As,At, but not Au,Av
+ *                                 the GT had Au,Av, but not As,At
+ * This was as of v2.0 of both firmware sets. possibly 1.3 for UT.
+ * Bj in UT at v1.3
+ * dont see Bd in UT/GT thru 1999
+ * Gj in UT as of 3.0, 1999 , Bj as of 1.3
+ */
+
+static char *Month[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jly",
+       "Aug", "Sep", "Oct", "Nov", "Dec" };
+
+#define DEVICE1        "/dev/oncore.serial.%d" /* name of serial device */
+#define DEVICE2        "/dev/oncore.pps.%d"    /* name of pps device */
+
+#define SPEED          B9600           /* Oncore Binary speed (9600 bps) */
+
+/*
+ * Assemble and disassemble 32bit signed quantities from a buffer.
+ *
+ */
+
+       /* to buffer, int w, u_char *buf */
+#define w32_buf(buf,w) { u_int i_tmp;                     \
+                         i_tmp = (w<0) ? (~(-w)+1) : (w); \
+                         (buf)[0] = (i_tmp >> 24) & 0xff; \
+                         (buf)[1] = (i_tmp >> 16) & 0xff; \
+                         (buf)[2] = (i_tmp >>  8) & 0xff; \
+                         (buf)[3] = (i_tmp      ) & 0xff; \
+                       }
+
+#define w32(buf)      (((buf)[0]&0xff) << 24 | \
+                      ((buf)[1]&0xff) << 16 | \
+                      ((buf)[2]&0xff) <<  8 | \
+                      ((buf)[3]&0xff) )
+
+       /* from buffer, char *buf, result to an int */
+#define buf_w32(buf) (((buf)[0]&0200) ? (-(~w32(buf)+1)) : w32(buf))
+
+
+/*
+ * oncore_start - initialize data for processing
+ */
+
+static int
+oncore_start(
+       int unit,
+       struct peer *peer
+       )
+{
+#define STRING_LEN     32
+       register struct instance *instance;
+       struct refclockproc *pp;
+       int fd1, fd2, num;
+       char device1[STRING_LEN], device2[STRING_LEN], Msg[160];
+       const char *cp;
+       struct stat stat1, stat2;
+
+       /* create instance structure for this unit */
+
+       if (!(instance = (struct instance *) malloc(sizeof *instance))) {
+               perror("malloc");
+               return (0);
+       }
+       memset((char *) instance, 0, sizeof *instance);
+
+       /* initialize miscellaneous variables */
+
+       pp = peer->procptr;
+       pp->unitptr    = (caddr_t) instance;
+       instance->pp   = pp;
+       instance->unit = unit;
+       instance->peer = peer;
+       instance->assert = 1;
+       instance->once = 1;
+
+       instance->Bj_day = -1;
+       instance->traim = -1;
+       instance->traim_in = -1;
+       instance->chan_in = -1;
+       instance->model = ONCORE_UNKNOWN;
+       instance->mode = MODE_UNKNOWN;
+       instance->site_survey = ONCORE_SS_UNKNOWN;
+       instance->Ag = 0xff;            /* Satellite mask angle, unset by user */
+       instance->ant_state = ONCORE_ANTENNA_UNKNOWN;
+
+       peer->precision = -26;
+       peer->minpoll = 4;
+       peer->maxpoll = 4;
+       pp->clockdesc = "Motorola Oncore GPS Receiver";
+       memcpy((char *)&pp->refid, "GPS\0", (size_t) 4);
+
+       cp = "ONCORE DRIVER -- CONFIGURING";
+       record_clock_stats(&(instance->peer->srcadr), cp);
+
+       instance->o_state = ONCORE_NO_IDEA;
+       cp = "state = ONCORE_NO_IDEA";
+       record_clock_stats(&(instance->peer->srcadr), cp);
+
+       /* Now open files.
+        * This is a bit complicated, a we dont want to open the same file twice
+        * (its a problem on some OS), and device2 may not exist for the new PPS
+        */
+
+       (void)sprintf(device1, DEVICE1, unit);
+       (void)sprintf(device2, DEVICE2, unit);
+
+       /* OPEN DEVICES */
+       /* opening different devices for fd1 and fd2 presents no problems */
+       /* opening the SAME device twice, seems to be OS dependent.
+               (a) on Linux (no streams) no problem
+               (b) on SunOS (and possibly Solaris, untested), (streams)
+                       never see the line discipline.
+          Since things ALWAYS work if we only open the device once, we check
+            to see if the two devices are in fact the same, then proceed to
+            do one open or two.
+       */
+
+       if (stat(device1, &stat1)) {
+               sprintf(Msg, "Can't stat fd1 (%s)\n", device1);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+               exit(1);
+       }
+
+       if (stat(device2, &stat2)) {
+               sprintf(Msg, "Can't stat fd2 (%s)\n", device2);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+               exit(1);
+       }
+
+       if (!(fd1 = refclock_open(device1, SPEED, LDISC_RAW))) {
+               sprintf(Msg, "Can't open fd1 (%s)\n", device1);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+               exit(1);
+       }
+
+       if ((stat1.st_dev == stat2.st_dev) && (stat1.st_ino == stat2.st_ino))   /* same device here */
+               fd2 = fd1;
+       else {  /* different devices here */
+               if ((fd2=open(device2, O_RDWR)) < 0) {
+                       sprintf(Msg, "Can't open fd2 (%s)\n", device2);
+                       record_clock_stats(&(instance->peer->srcadr), Msg);
+                       exit(1);
+               }
+       }
+       num = fd2;
+
+       /* open ppsapi soure */
+
+       if (time_pps_create(num, &instance->pps_h) < 0) {
+               record_clock_stats(&(instance->peer->srcadr), "PPSAPI not found in kernel");
+               return(0);
+       }
+
+       /* continue initialization */
+
+       instance->ttyfd = fd1;
+       instance->ppsfd = fd2;
+
+       /* go read any input data in /etc/ntp.oncoreX or /etc/ntp/oncore.X */
+
+       oncore_read_config(instance);
+
+       if (!oncore_ppsapi(instance))
+               return(0);
+
+       pp->io.clock_recv = oncore_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd1;
+       if (!io_addclock(&pp->io)) {
+               record_clock_stats(&(instance->peer->srcadr), "ONCORE: io_addclock");
+               (void) close(fd1);
+               free(instance);
+               return (0);
+       }
+
+#ifdef ONCORE_SHMEM_STATUS
+       /*
+        * Before starting ONCORE, lets setup SHMEM
+        * This will include merging an old SHMEM into the new one if
+        * an old one is found.
+        */
+
+       oncore_init_shmem(instance);
+#endif
+
+       /*
+        * This will return the Model of the Oncore receiver.
+        * and start the Initialization loop in oncore_msg_Cj.
+        */
+
+       instance->o_state = ONCORE_CHECK_ID;
+       cp = "state = ONCORE_CHECK_ID";
+       record_clock_stats(&(instance->peer->srcadr), cp);
+
+       instance->timeout = 4;
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Cg, sizeof(oncore_cmd_Cg)); /* Set Posn Fix mode (not Idle (VP)) */
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Cj, sizeof(oncore_cmd_Cj));
+
+       instance->pollcnt = 2;
+       return (1);
+}
+
+
+/*
+ * oncore_shutdown - shut down the clock
+ */
+
+static void
+oncore_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct instance *instance;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       instance = (struct instance *) pp->unitptr;
+
+       io_closeclock(&pp->io);
+
+       time_pps_destroy (instance->pps_h);
+
+       close(instance->ttyfd);
+
+       if ((instance->ppsfd != -1) && (instance->ppsfd != instance->ttyfd))
+               close(instance->ppsfd);
+
+       if (instance->shmemfd)
+               close(instance->shmemfd);
+
+       free(instance);
+}
+
+
+
+/*
+ * oncore_poll - called by the transmit procedure
+ */
+
+static void
+oncore_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct instance *instance;
+
+       instance = (struct instance *) peer->procptr->unitptr;
+       if (instance->timeout) {
+               char    *cp;
+
+               instance->timeout--;
+               if (instance->timeout == 0) {
+                       cp = "Oncore: No response from @@Cj, shutting down driver";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+                       oncore_shutdown(unit, peer);
+               } else {
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Cj, sizeof(oncore_cmd_Cj));
+                       cp = "Oncore: Resend @@Cj";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+               }
+               return;
+       }
+
+       if (!instance->pollcnt)
+               refclock_report(peer, CEVNT_TIMEOUT);
+       else
+               instance->pollcnt--;
+       peer->procptr->polls++;
+       instance->polled = 1;
+}
+
+
+
+/*
+ * Initialize PPSAPI
+ */
+
+static int
+oncore_ppsapi(
+       struct instance *instance
+       )
+{
+       int cap, mode, mode1;
+       char *cp, Msg[160];
+
+       if (time_pps_getcap(instance->pps_h, &cap) < 0) {
+               msyslog(LOG_ERR, "time_pps_getcap failed: %m");
+               return (0);
+       }
+
+       if (time_pps_getparams(instance->pps_h, &instance->pps_p) < 0) {
+               msyslog(LOG_ERR, "time_pps_getparams failed: %m");
+               return (0);
+       }
+
+       /* nb. only turn things on, if someone else has turned something
+        *      on before we get here, leave it alone!
+        */
+
+       if (instance->assert) {
+               cp = "Assert.";
+               mode = PPS_CAPTUREASSERT;
+               mode1 = PPS_OFFSETASSERT;
+       } else {
+               cp = "Clear.";
+               mode = PPS_CAPTURECLEAR;
+               mode1 = PPS_OFFSETCLEAR;
+       }
+       sprintf(Msg, "Initializing timeing to %s.", cp);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+
+       if (!(mode & cap)) {
+               sprintf(Msg, "Can't set timeing to %s, exiting...", cp);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+               return(0);
+       }
+
+       if (!(mode1 & cap)) {
+               sprintf(Msg, "Can't set PPS_%sCLEAR, this will increase jitter.", cp);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+               mode1 = 0;
+       }
+
+       /* only set what is legal */
+
+       instance->pps_p.mode = (mode | mode1 | PPS_TSFMT_TSPEC) & cap;
+
+       if (time_pps_setparams(instance->pps_h, &instance->pps_p) < 0) {
+               record_clock_stats(&(instance->peer->srcadr), "ONCORE: time_pps_setparams fails");
+               exit(1);
+       }
+
+       /* If HARDPPS is on, we tell kernel */
+
+       if (instance->hardpps) {
+               int     i;
+
+               record_clock_stats(&(instance->peer->srcadr), "HARDPPS Set.");
+
+               if (instance->assert)
+                       i = PPS_CAPTUREASSERT;
+               else
+                       i = PPS_CAPTURECLEAR;
+
+               /* we know that 'i' is legal from above */
+
+               if (time_pps_kcbind(instance->pps_h, PPS_KC_HARDPPS, i,
+                   PPS_TSFMT_TSPEC) < 0) {
+                       msyslog(LOG_ERR, "time_pps_kcbind failed: %m");
+                       record_clock_stats(&(instance->peer->srcadr), "HARDPPS failed, abort...");
+                       return (0);
+               }
+               pps_enable = 1;
+       }
+       return(1);
+}
+
+
+
+#ifdef ONCORE_SHMEM_STATUS
+static void
+oncore_init_shmem(
+       struct instance *instance
+       )
+{
+       int i, l, n, fd, shmem_old_size, n1;
+       char Msg[160];
+       u_char *cp, *cp1, *buf, *shmem_old;
+       struct msg_desc *mp;
+       struct stat sbuf;
+       size_t shmem_length;
+
+       /*
+       * The first thing we do is see if there is an instance->shmem_fname file (still)
+       * out there from a previous run.  If so, we copy it in and use it to initialize
+       * shmem (so we won't lose our almanac if we need it).
+       */
+
+       shmem_old = 0;
+       shmem_old_size = 0;
+       if ((fd = open(instance->shmem_fname, O_RDONLY)) < 0)
+               record_clock_stats(&(instance->peer->srcadr), "ONCORE: Can't open SHMEM file");
+       else {
+               fstat(fd, &sbuf);
+               shmem_old_size = sbuf.st_size;
+               if (shmem_old_size != 0) {
+                       shmem_old = (u_char *) malloc((unsigned) sbuf.st_size);
+                       if (shmem_old == NULL)
+                               record_clock_stats(&(instance->peer->srcadr), "ONCORE: Can't malloc buffer for shmem_old");
+                       else
+                               read(fd, shmem_old, shmem_old_size);
+               }
+               close(fd);
+       }
+
+       /* OK, we now create the NEW SHMEM. */
+
+       if ((instance->shmemfd = open(instance->shmem_fname, O_RDWR|O_CREAT|O_TRUNC, 0644)) < 0) {
+               record_clock_stats(&(instance->peer->srcadr), "ONCORE: Can't open shmem");
+               if (shmem_old)
+                       free(shmem_old);
+
+               return;
+       }
+
+       /* see how big it needs to be */
+
+       n = 1;
+       for (mp=oncore_messages; mp->flag[0]; mp++) {
+               mp->shmem = n;
+               /* Allocate space for multiplexed almanac, and 0D/2D/3D @@Ea records */
+               if (!strcmp(mp->flag, "Cb")) {
+                       instance->shmem_Cb = n;
+                       n += (mp->len + 3) * 34;
+               }
+               if (!strcmp(mp->flag, "Ba")) {
+                       instance->shmem_Ba = n;
+                       n += (mp->len + 3) * 3;
+               }
+               if (!strcmp(mp->flag, "Ea")) {
+                       instance->shmem_Ea = n;
+                       n += (mp->len + 3) * 3;
+               }
+               if (!strcmp(mp->flag, "Ha")) {
+                       instance->shmem_Ha = n;
+                       n += (mp->len + 3) * 3;
+               }
+               n += (mp->len + 3);
+       }
+       shmem_length = n + 2;
+
+       buf = malloc(shmem_length);
+       if (buf == NULL) {
+               record_clock_stats(&(instance->peer->srcadr), "ONCORE: Can't malloc buffer for shmem");
+               close(instance->shmemfd);
+               if (shmem_old)
+                       free(shmem_old);
+
+               return;
+       }
+
+       memset(buf, 0, shmem_length);
+
+       /* next build the new SHMEM buffer in memory */
+
+       for (mp=oncore_messages; mp->flag[0]; mp++) {
+               l = mp->shmem;
+               buf[l + 0] = mp->len >> 8;
+               buf[l + 1] = mp->len & 0xff;
+               buf[l + 2] = 0;
+               buf[l + 3] = '@';
+               buf[l + 4] = '@';
+               buf[l + 5] = mp->flag[0];
+               buf[l + 6] = mp->flag[1];
+               if (!strcmp(mp->flag, "Cb") || !strcmp(mp->flag, "Ba") || !strcmp(mp->flag, "Ea") || !strcmp(mp->flag, "Ha")) {
+                       if (!strcmp(mp->flag, "Cb"))
+                               n = 35;
+                       else
+                               n = 4;
+                       for (i=1; i<n; i++) {
+                               buf[l + i * (mp->len+3) + 0] = mp->len >> 8;
+                               buf[l + i * (mp->len+3) + 1] = mp->len & 0xff;
+                               buf[l + i * (mp->len+3) + 2] = 0;
+                               buf[l + i * (mp->len+3) + 3] = '@';
+                               buf[l + i * (mp->len+3) + 4] = '@';
+                               buf[l + i * (mp->len+3) + 5] = mp->flag[0];
+                               buf[l + i * (mp->len+3) + 6] = mp->flag[1];
+                       }
+               }
+       }
+
+       /* we now walk thru the two buffers (shmem_old and buf, soon to become shmem)
+        * copying the data in shmem_old to buf.
+        * When we are done we write it out and free both buffers.
+        * If the structure sizes dont agree, I will not copy.
+        * This could be due to an addition/deletion or a problem with the disk file.
+        */
+
+       if (shmem_old) {
+               if (shmem_old_size == shmem_length) {
+                       for (cp=buf+4, cp1=shmem_old+4; (n = 256*(*(cp-3)) + *(cp-2));  cp+=(n+3), cp1+=(n+3)) {
+                               n1 = 256*(*(cp1-3)) + *(cp1-2);
+                               if (n == 0 || n1 != n || strncmp((char *) cp, (char *) cp1, 4))
+                                       break;
+
+                               memcpy(cp, cp1, (size_t) n);
+                       }
+               }
+               free(shmem_old);
+       }
+
+       i = write(instance->shmemfd, buf, shmem_length);
+       free(buf);
+
+       if (i != shmem_length) {
+               record_clock_stats(&(instance->peer->srcadr), "ONCORE: error writing shmem");
+               close(instance->shmemfd);
+               return;
+       }
+
+       instance->shmem = (u_char *) mmap(0, shmem_length,
+               PROT_READ | PROT_WRITE,
+#ifdef MAP_HASSEMAPHORE
+               MAP_HASSEMAPHORE |
+#endif
+               MAP_SHARED, instance->shmemfd, (off_t)0);
+
+       if (instance->shmem == (u_char *)MAP_FAILED) {
+               instance->shmem = 0;
+               close(instance->shmemfd);
+               return;
+       }
+
+       sprintf(Msg, "SHMEM (size = %ld) is CONFIGURED and available as %s",
+               (u_long) shmem_length, instance->shmem_fname);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+#endif /* ONCORE_SHMEM_STATUS */
+
+
+
+/*
+ * Read Input file if it exists.
+ */
+
+static void
+oncore_read_config(
+       struct instance *instance
+       )
+{
+/*
+ * First we try to open the configuration file
+ *    /etc/oncoreN
+ * where N is the unit number viz 127.127.30.N.
+ * If we don't find it we try
+ *    /etc/ntp.oncore.N
+ * and then
+ *    /etc/ntp.oncore
+ *
+ * If we don't find any then we don't have the cable delay or PPS offset
+ * and we choose MODE (4) below.
+ *
+ * Five Choices for MODE
+ *    (0) ONCORE is preinitialized, don't do anything to change it.
+ *         nb, DON'T set 0D mode, DON'T set Delay, position...
+ *    (1) NO RESET, Read Position, delays from data file, lock it in, go to 0D mode.
+ *    (2) NO RESET, Read Delays from data file, do SITE SURVEY to get position,
+ *                 lock this in, go to 0D mode.
+ *    (3) HARD RESET, Read Position, delays from data file, lock it in, go to 0D mode.
+ *    (4) HARD RESET, Read Delays from data file, do SITE SURVEY to get position,
+ *                 lock this in, go to 0D mode.
+ *     NB. If a POSITION is specified in the config file with mode=(2,4) [SITE SURVEY]
+ *        then this position is set as the INITIAL position of the ONCORE.
+ *        This can reduce the time to first fix.
+ * -------------------------------------------------------------------------------
+ * Note that an Oncore UT without a battery backup retains NO information if it is
+ *   power cycled, with a Battery Backup it remembers the almanac, etc.
+ * For an Oncore VP, there is an eeprom that will contain this data, along with the
+ *   option of Battery Backup.
+ * So a UT without Battery Backup is equivalent to doing a HARD RESET on each
+ *   power cycle, since there is nowhere to store the data.
+ * -------------------------------------------------------------------------------
+ *
+ * If we open one or the other of the files, we read it looking for
+ *   MODE, LAT, LON, (HT, HTGPS, HTMSL), DELAY, OFFSET, ASSERT, CLEAR, HARDPPS,
+ *   STATUS, POSN3D, POSN2D, CHAN, TRAIM
+ * then initialize using method MODE.  For Mode = (1,3) all of (LAT, LON, HT) must
+ *   be present or mode reverts to (2,4).
+ *
+ * Read input file.
+ *
+ *     # is comment to end of line
+ *     = allowed between 1st and 2nd fields.
+ *
+ *     Expect to see one line with 'MODE' as first field, followed by an integer
+ *        in the range 0-4 (default = 4).
+ *
+ *     Expect to see two lines with 'LONG', 'LAT' followed by 1-3 fields.
+ *     All numbers are floating point.
+ *             DDD.ddd
+ *             DDD  MMM.mmm
+ *             DDD  MMM  SSS.sss
+ *
+ *     Expect to see one line with 'HT' as first field,
+ *        followed by 1-2 fields.  First is a number, the second is 'FT' or 'M'
+ *        for feet or meters.  HT is the height above the GPS ellipsoid.
+ *        If the receiver reports height in both GPS and MSL, then we will report
+ *        the difference GPS-MSL on the clockstats file.
+ *
+ *     There is an optional line, starting with DELAY, followed
+ *        by 1 or two fields.  The first is a number (a time) the second is
+ *        'MS', 'US' or 'NS' for miliseconds, microseconds or nanoseconds.
+ *         DELAY  is cable delay, typically a few tens of ns.
+ *
+ *     There is an optional line, starting with OFFSET, followed
+ *        by 1 or two fields.  The first is a number (a time) the second is
+ *        'MS', 'US' or 'NS' for miliseconds, microseconds or nanoseconds.
+ *        OFFSET is the offset of the PPS pulse from 0. (only fully implemented
+ *             with the PPSAPI, we need to be able to tell the Kernel about this
+ *             offset if the Kernel PLL is in use, but can only do this presently
+ *             when using the PPSAPI interface.  If not using the Kernel PLL,
+ *             then there is no problem.
+ *
+ *     There is an optional line, with either ASSERT or CLEAR on it, which
+ *        determine which transition of the PPS signal is used for timing by the
+ *        PPSAPI.  If neither is present, then ASSERT is assumed.
+ *        ASSERT/CLEAR can also be set with FLAG2 of the ntp.conf input.
+ *        For Flag2, ASSERT=0, and hence is default.
+ *
+ *     There is an optional line, with HARDPPS on it.  Including this line causes
+ *        the PPS signal to control the kernel PLL.
+ *        HARDPPS can also be set with FLAG3 of the ntp.conf input.
+ *        For Flag3, 0 is disabled, and the default.
+ *
+ *     There are three options that have to do with using the shared memory option.
+ *        First, to enable the option there must be a SHMEM line with a file name.
+ *        The file name is the file associated with the shared memory.
+ *
+ *     In shared memory, there is one 'record' for each returned variable.
+ *     For the @@Ea data there are three 'records' containing position data.
+ *        There will always be data in the record corresponding to the '0D' @@Ea record,
+ *        and the user has a choice of filling the '3D' record by specifying POSN3D,
+ *        or the '2D' record by specifying POSN2D.  In either case the '2D' or '3D'
+ *        record is filled once every 15s.
+ *
+ *     Two additional variables that can be set are CHAN and TRAIM.  These should be
+ *        set correctly by the code examining the @@Cj record, but we bring them out here
+ *        to allow the user to override either the # of channels, or the existence of TRAIM.
+ *        CHAN expects to be followed by in integer: 6, 8, or 12. TRAIM expects to be
+ *        followed by YES or NO.
+ *
+ *     There is an optional line with MASK on it followed by one integer field in the
+ *        range 0 to 89. This sets the satellite mask angle and will determine the minimum
+ *        elevation angle for satellites to be tracked by the receiver. The default value
+ *        is 10 deg for the VP and 0 deg for all other receivers.
+ *
+ * So acceptable input would be
+ *     # these are my coordinates (RWC)
+ *     LON  -106 34.610
+ *     LAT    35 08.999
+ *     HT      1589    # could equally well say HT 5215 FT
+ *     DELAY  60 ns
+ */
+
+       FILE    *fd;
+       char    *cp, *cc, *ca, line[100], units[2], device[20], Msg[160], **cpp;
+       char    *dirs[] = { "/etc/ntp", "/etc", 0 };
+       int     i, sign, lat_flg, long_flg, ht_flg, mode, mask;
+       double  f1, f2, f3;
+
+       fd = NULL;      /* just to shutup gcc complaint */
+       for (cpp=dirs; *cpp; cpp++) {
+               cp = *cpp;
+               sprintf(device, "%s/ntp.oncore.%d", cp, instance->unit); /* try "ntp.oncore.0 */
+               if ((fd=fopen(device, "r")))
+                       break;
+               sprintf(device, "%s/ntp.oncore%d", cp, instance->unit);  /* try "ntp.oncore0" */
+               if ((fd=fopen(device, "r")))
+                       break;
+               sprintf(device, "%s/ntp.oncore", cp);   /* and finally "ntp.oncore" */
+               if ((fd=fopen(device, "r")))
+                       break;
+       }
+
+       if (!fd) {      /* no inputfile, default to the works ... */
+               instance->init_type = 4;
+               return;
+       }
+
+       mode = mask = 0;
+       lat_flg = long_flg = ht_flg = 0;
+       while (fgets(line, 100, fd)) {
+
+               /* Remove comments */
+               if ((cp = strchr(line, '#')))
+                       *cp = '\0';
+
+               /* Remove trailing space */
+               for (i = strlen(line);
+                    i > 0 && isascii((int)line[i - 1]) && isspace((int)line[i - 1]);
+                       )
+                       line[--i] = '\0';
+
+               /* Remove leading space */
+               for (cc = line; *cc && isascii((int)*cc) && isspace((int)*cc); cc++)
+                       continue;
+
+               /* Stop if nothing left */
+               if (!*cc)
+                       continue;
+
+               /* 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 == '='))
+                                       break;
+                       }
+               }
+
+               /* Remove space (and possible =) leading the arg */
+               for (; *ca && isascii((int)*ca) && (isspace((int)*ca) || (*ca == '=')); ca++)
+                       continue;
+
+               if (!strncmp(cc, "STATUS", (size_t) 6) || !strncmp(cc, "SHMEM", (size_t) 5)) {
+                       i = strlen(ca);
+                       instance->shmem_fname = (char *) malloc((unsigned) (i+1));
+                       strcpy(instance->shmem_fname, ca);
+                       continue;
+               }
+
+               /* Uppercase argument as well */
+               for (cp = ca; *cp; cp++)
+                       if (isascii((int)*cp) && islower((int)*cp))
+                               *cp = toupper(*cp);
+
+               if (!strncmp(cc, "LAT", (size_t) 3)) {
+                       f1 = f2 = f3 = 0;
+                       sscanf(ca, "%lf %lf %lf", &f1, &f2, &f3);
+                       sign = 1;
+                       if (f1 < 0) {
+                               f1 = -f1;
+                               sign = -1;
+                       }
+                       instance->ss_lat = sign*1000*(fabs(f3) + 60*(fabs(f2) + 60*f1)); /*miliseconds*/
+                       lat_flg++;
+               } else if (!strncmp(cc, "LON", (size_t) 3)) {
+                       f1 = f2 = f3 = 0;
+                       sscanf(ca, "%lf %lf %lf", &f1, &f2, &f3);
+                       sign = 1;
+                       if (f1 < 0) {
+                               f1 = -f1;
+                               sign = -1;
+                       }
+                       instance->ss_long = sign*1000*(fabs(f3) + 60*(fabs(f2) + 60*f1)); /*miliseconds*/
+                       long_flg++;
+               } else if (!strncmp(cc, "HT", (size_t) 2)) {
+                       f1 = 0;
+                       units[0] = '\0';
+                       sscanf(ca, "%lf %1s", &f1, units);
+                       if (units[0] == 'F')
+                               f1 = 0.3048 * f1;
+                       instance->ss_ht = 100 * f1;    /* cm */
+                       ht_flg++;
+               } else if (!strncmp(cc, "DELAY", (size_t) 5)) {
+                       f1 = 0;
+                       units[0] = '\0';
+                       sscanf(ca, "%lf %1s", &f1, units);
+                       if (units[0] == 'N')
+                               ;
+                       else if (units[0] == 'U')
+                               f1 = 1000 * f1;
+                       else if (units[0] == 'M')
+                               f1 = 1000000 * f1;
+                       else
+                               f1 = 1000000000 * f1;
+                       if (f1 < 0 || f1 > 1.e9)
+                               f1 = 0;
+                       if (f1 < 0 || f1 > 999999) {
+                               sprintf(Msg, "PPS Cable delay of %fns out of Range, ignored", f1);
+                               record_clock_stats(&(instance->peer->srcadr), Msg);
+                       } else
+                               instance->delay = f1;           /* delay in ns */
+               } else if (!strncmp(cc, "OFFSET", (size_t) 6)) {
+                       f1 = 0;
+                       units[0] = '\0';
+                       sscanf(ca, "%lf %1s", &f1, units);
+                       if (units[0] == 'N')
+                               ;
+                       else if (units[0] == 'U')
+                               f1 = 1000 * f1;
+                       else if (units[0] == 'M')
+                               f1 = 1000000 * f1;
+                       else
+                               f1 = 1000000000 * f1;
+                       if (f1 < 0 || f1 > 1.e9)
+                               f1 = 0;
+                       if (f1 < 0 || f1 > 999999999.) {
+                               sprintf(Msg, "PPS Offset of %fns out of Range, ignored", f1);
+                               record_clock_stats(&(instance->peer->srcadr), Msg);
+                       } else
+                               instance->offset = f1;          /* offset in ns */
+               } else if (!strncmp(cc, "MODE", (size_t) 4)) {
+                       sscanf(ca, "%d", &mode);
+                       if (mode < 0 || mode > 4)
+                               mode = 4;
+               } else if (!strncmp(cc, "ASSERT", (size_t) 6)) {
+                       instance->assert = 1;
+               } else if (!strncmp(cc, "CLEAR", (size_t) 5)) {
+                       instance->assert = 0;
+               } else if (!strncmp(cc, "HARDPPS", (size_t) 7)) {
+                       instance->hardpps = 1;
+               } else if (!strncmp(cc, "POSN2D", (size_t) 6)) {
+                       instance->shmem_Posn = 2;
+               } else if (!strncmp(cc, "POSN3D", (size_t) 6)) {
+                       instance->shmem_Posn = 3;
+               } else if (!strncmp(cc, "CHAN", (size_t) 4)) {
+                       sscanf(ca, "%d", &i);
+                       if ((i == 6) || (i == 8) || (i == 12))
+                               instance->chan_in = i;
+               } else if (!strncmp(cc, "TRAIM", (size_t) 5)) {
+                       instance->traim_in = 1;         /* so TRAIM alone is YES */
+                       if (!strcmp(ca, "NO") || !strcmp(ca, "OFF"))    /* Yes/No, On/Off */
+                               instance->traim_in = 0;
+               } else if (!strncmp(cc, "MASK", (size_t) 4)) {
+                       sscanf(ca, "%d", &mask);
+                       if (mask > -1 && mask < 90)
+                               instance->Ag = mask;                    /* Satellite mask angle */
+               }
+       }
+       fclose(fd);
+
+       /*
+        *    OK, have read all of data file, and extracted the good stuff.
+        *    If lat/long/ht specified they ALL must be specified for mode = (1,3).
+        */
+
+       instance->posn_set = 1;
+       if (!( lat_flg && long_flg && ht_flg )) {
+               printf("ONCORE: incomplete data on %s\n", device);
+               instance->posn_set = 0;
+               if (mode == 1 || mode == 3) {
+                       sprintf(Msg, "Input Mode = %d, but no/incomplete position, mode set to %d", mode, mode+1);
+                       record_clock_stats(&(instance->peer->srcadr), Msg);
+                       mode++;
+               }
+       }
+       instance->init_type = mode;
+
+       sprintf(Msg, "Input mode = %d", mode);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+
+
+
+/*
+ * move data from NTP to buffer (toss the extra in the unlikely case it won't fit)
+ */
+
+static void
+oncore_receive(
+       struct recvbuf *rbufp
+       )
+{
+       size_t i;
+       u_char *p;
+       struct peer *peer;
+       struct instance *instance;
+
+       peer = (struct peer *)rbufp->recv_srcclock;
+       instance = (struct instance *) peer->procptr->unitptr;
+       p = (u_char *) &rbufp->recv_space;
+
+#if 0
+       if (debug > 4) {
+               int i;
+               printf("ONCORE: >>>");
+               for(i=0; i<rbufp->recv_length; i++)
+                       printf("%02x ", p[i]);
+               printf("\n");
+               printf("ONCORE: >>>");
+               for(i=0; i<rbufp->recv_length; i++)
+                       printf("%03o ", p[i]);
+               printf("\n");
+       }
+#endif
+
+       i = rbufp->recv_length;
+       if (rcvbuf+rcvptr+i > &rcvbuf[sizeof rcvbuf])
+               i = sizeof(rcvbuf) - rcvptr;    /* and some char will be lost */
+       memcpy(rcvbuf+rcvptr, p, i);
+       rcvptr += i;
+       oncore_consume(instance);
+}
+
+
+
+/*
+ * Deal with any complete messages
+ */
+
+static void
+oncore_consume(
+       struct instance *instance
+       )
+{
+       int i, m;
+       unsigned l;
+
+       while (rcvptr >= 7) {
+               if (rcvbuf[0] != '@' || rcvbuf[1] != '@') {
+                       /* We're not in sync, lets try to get there */
+                       for (i=1; i < rcvptr-1; i++)
+                               if (rcvbuf[i] == '@' && rcvbuf[i+1] == '@')
+                                       break;
+#ifdef DEBUG
+                       if (debug > 4)
+                               printf("ONCORE[%d]: >>> skipping %d chars\n", instance->unit, i);
+#endif
+                       if (i != rcvptr)
+                               memcpy(rcvbuf, rcvbuf+i, (size_t)(rcvptr-i));
+                       rcvptr -= i;
+                       continue;
+               }
+
+               /* Ok, we have a header now */
+               l = sizeof(oncore_messages)/sizeof(oncore_messages[0]) -1;
+               for(m=0; m<l; m++)
+                       if (!strncmp(oncore_messages[m].flag, (char *)(rcvbuf+2), (size_t) 2))
+                               break;
+               if (m == l) {
+#ifdef DEBUG
+                       if (debug > 4)
+                               printf("ONCORE[%d]: >>> Unknown MSG, skipping 4 (%c%c)\n", instance->unit, rcvbuf[2], rcvbuf[3]);
+#endif
+                       memcpy(rcvbuf, rcvbuf+4, (size_t) 4);
+                       rcvptr -= 4;
+                       continue;
+               }
+
+               l = oncore_messages[m].len;
+#if 0
+               if (debug > 3)
+                       printf("ONCORE[%d]: GOT: %c%c  %d of %d entry %d\n", instance->unit, rcvbuf[2], rcvbuf[3], rcvptr, l, m);
+#endif
+               /* Got the entire message ? */
+
+               if (rcvptr < l)
+                       return;
+
+               /* are we at the end of message? should be <Cksum><CR><LF> */
+
+               if (rcvbuf[l-2] != '\r' || rcvbuf[l-1] != '\n') {
+#ifdef DEBUG
+                       if (debug)
+                               printf("ONCORE[%d]: NO <CR><LF> at end of message\n", instance->unit);
+#endif
+               } else {        /* check the CheckSum */
+                       if (oncore_checksum_ok(rcvbuf, l)) {
+                               if (instance->shmem != NULL) {
+                                       instance->shmem[oncore_messages[m].shmem + 2]++;
+                                       memcpy(instance->shmem + oncore_messages[m].shmem + 3,
+                                           rcvbuf, (size_t) l);
+                               }
+                               oncore_msg_any(instance, rcvbuf, (size_t) (l-3), m);
+                               if (oncore_messages[m].handler)
+                                       oncore_messages[m].handler(instance, rcvbuf, (size_t) (l-3));
+                       }
+#ifdef DEBUG
+                       else if (debug) {
+                               printf("ONCORE[%d]: Checksum mismatch!\n", instance->unit);
+                               printf("ONCORE[%d]: @@%c%c ", instance->unit, rcvbuf[2], rcvbuf[3]);
+                               for (i=4; i<l; i++)
+                                       printf("%03o ", rcvbuf[i]);
+                               printf("\n");
+                       }
+#endif
+               }
+
+               if (l != rcvptr)
+                       memcpy(rcvbuf, rcvbuf+l, (size_t) (rcvptr-l));
+               rcvptr -= l;
+       }
+}
+
+
+
+static void
+oncore_get_timestamp(
+       struct instance *instance,
+       long dt1,       /* tick offset THIS time step */
+       long dt2        /* tick offset NEXT time step */
+       )
+{
+       int     Rsm;
+       u_long  j;
+       l_fp ts, ts_tmp;
+       double dmy;
+#ifdef HAVE_STRUCT_TIMESPEC
+       struct timespec *tsp = 0;
+#else
+       struct timeval  *tsp = 0;
+#endif
+       int     current_mode;
+       u_long  i;
+       pps_params_t current_params;
+       struct timespec timeout;
+       pps_info_t pps_i;
+
+#if 1
+       /* If we are in SiteSurvey mode, then we are in 3D mode, and we fall thru.
+        * If we have Finished the SiteSurvey, then we fall thru for the 14/15
+        *  times we get here in 0D mode (the 1/15 is in 3D for SHMEM).
+        * This gives good time, which gets better when the SS is done.
+        */
+
+       if ((instance->site_survey == ONCORE_SS_DONE) && (instance->mode != MODE_0D))
+#else
+       /* old check, only fall thru for SS_DONE and 0D mode, 2h45m wait for ticks */
+
+       if ((instance->site_survey != ONCORE_SS_DONE) || (instance->mode != MODE_0D))
+#endif
+               return;
+
+       /* Don't do anything without an almanac to define the GPS->UTC delta */
+
+       if (instance->rsm.bad_almanac)
+               return;
+
+       /* Once the Almanac is valid, the M12+T does not produce valid UTC
+        * immediately.
+        * Wait for UTC offset decode valid, then wait one message more
+        * so we are not off by 13 seconds after  reset.
+        */
+
+       if (instance->count5) {
+               instance->count5--;
+               return;
+       }
+
+       j = instance->ev_serial;
+       timeout.tv_sec = 0;
+       timeout.tv_nsec = 0;
+       if (time_pps_fetch(instance->pps_h, PPS_TSFMT_TSPEC, &pps_i,
+           &timeout) < 0) {
+               printf("ONCORE: time_pps_fetch failed\n");
+               return;
+       }
+
+       if (instance->assert) {
+               tsp = &pps_i.assert_timestamp;
+
+#ifdef DEBUG
+               if (debug > 2) {
+                       i = (u_long) pps_i.assert_sequence;
+# ifdef HAVE_STRUCT_TIMESPEC
+                       printf("ONCORE[%d]: serial/j (%lu, %lu) %ld.%09ld\n",
+                           instance->unit, i, j,
+                           (long)tsp->tv_sec, (long)tsp->tv_nsec);
+# else
+                       printf("ONCORE[%d]: serial/j (%lu, %lu) %ld.%06ld\n",
+                           instance->unit, i, j,
+                           (long)tsp->tv_sec, (long)tsp->tv_usec);
+# endif
+               }
+#endif
+
+               if (pps_i.assert_sequence == j) {
+                       printf("ONCORE: oncore_get_timestamp, error serial pps\n");
+                       return;
+               }
+               instance->ev_serial = pps_i.assert_sequence;
+       } else {
+               tsp = &pps_i.clear_timestamp;
+
+#ifdef DEBUG
+               if (debug > 2) {
+                       i = (u_long) pps_i.clear_sequence;
+# ifdef HAVE_STRUCT_TIMESPEC
+                       printf("ONCORE[%d]: serial/j (%lu, %lu) %ld.%09ld\n",
+                           instance->unit, i, j, (long)tsp->tv_sec, (long)tsp->tv_nsec);
+# else
+                       printf("ONCORE[%d]: serial/j (%lu, %lu) %ld.%06ld\n",
+                           instance->unit, i, j, (long)tsp->tv_sec, (long)tsp->tv_usec);
+# endif
+               }
+#endif
+
+               if (pps_i.clear_sequence == j) {
+                       printf("ONCORE: oncore_get_timestamp, error serial pps\n");
+                       return;
+               }
+               instance->ev_serial = pps_i.clear_sequence;
+       }
+
+       /* convert timespec -> ntp l_fp */
+
+       dmy = tsp->tv_nsec;
+       dmy /= 1e9;
+       ts.l_uf = dmy * 4294967296.0;
+       ts.l_ui = tsp->tv_sec;
+
+#if 0
+     alternate code for previous 4 lines is
+       dmy = 1.0e-9*tsp->tv_nsec;      /* fractional part */
+       DTOLFP(dmy, &ts);
+       dmy = tsp->tv_sec;              /* integer part */
+       DTOLFP(dmy, &ts_tmp);
+       L_ADD(&ts, &ts_tmp);
+     or more simply
+       dmy = 1.0e-9*tsp->tv_nsec;      /* fractional part */
+       DTOLFP(dmy, &ts);
+       ts.l_ui = tsp->tv_sec;
+#endif /* 0 */
+
+       /* now have timestamp in ts */
+       /* add in saw_tooth and offset, these will be ZERO if no TRAIM */
+       /* they will be IGNORED if the PPSAPI cant do PPS_OFFSET/ASSERT/CLEAR */
+       /* we just try to add them in and dont test for that here */
+
+       /* saw_tooth not really necessary if using TIMEVAL */
+       /* since its only precise to us, but do it anyway. */
+
+       /* offset in ns, and is positive (late), we subtract */
+       /* to put the PPS time transition back where it belongs */
+
+       /* must hand the offset for the NEXT sec off to the Kernel to do */
+       /* the addition, so that the Kernel PLL sees the offset too */
+
+       if (instance->assert)
+               instance->pps_p.assert_offset.tv_nsec = -dt2;
+       else
+               instance->pps_p.clear_offset.tv_nsec  = -dt2;
+
+       /* The following code is necessary, and not just a time_pps_setparams,
+        * using the saved instance->pps_p, since some other process on the
+        * machine may have diddled with the mode bits (say adding something
+        * that it needs).  We take what is there and ADD what we need.
+        * [[ The results from the time_pps_getcap is unlikely to change so
+        *    we could probably just save it, but I choose to do the call ]]
+        * Unfortunately, there is only ONE set of mode bits in the kernel per
+        * interface, and not one set for each open handle.
+        *
+        * There is still a race condition here where we might mess up someone
+        * elses mode, but if he is being careful too, he should survive.
+        */
+
+       if (time_pps_getcap(instance->pps_h, &current_mode) < 0) {
+               msyslog(LOG_ERR, "time_pps_getcap failed: %m");
+               return;
+       }
+
+       if (time_pps_getparams(instance->pps_h, &current_params) < 0) {
+               msyslog(LOG_ERR, "time_pps_getparams failed: %m");
+               return;
+       }
+
+               /* or current and mine */
+       current_params.mode |= instance->pps_p.mode;
+               /* but only set whats legal */
+       current_params.mode &= current_mode;
+
+       current_params.assert_offset.tv_sec = 0;
+       current_params.assert_offset.tv_nsec = -dt2;
+       current_params.clear_offset.tv_sec = 0;
+       current_params.clear_offset.tv_nsec = -dt2;
+
+       if (time_pps_setparams(instance->pps_h, &current_params))
+               record_clock_stats(&(instance->peer->srcadr), "ONCORE: Error doing time_pps_setparams");
+
+       /* have time from UNIX origin, convert to NTP origin. */
+
+       ts.l_ui += JAN_1970;
+       instance->pp->lastrec = ts;
+
+       /* print out information about this timestamp (long line) */
+
+       ts_tmp = ts;
+       ts_tmp.l_ui = 0;        /* zero integer part */
+       LFPTOD(&ts_tmp, dmy);   /* convert fractional part to a double */
+       j = 1.0e9*dmy;          /* then to integer ns */
+
+       Rsm = 0;
+       if (instance->chan == 6)
+               Rsm = instance->BEHa[64];
+       else if (instance->chan == 8)
+               Rsm = instance->BEHa[72];
+       else if (instance->chan == 12)
+               Rsm = ((instance->BEHa[129]<<8) | instance->BEHa[130]);
+
+       if (instance->chan == 6 || instance->chan == 8) {
+               char    f1[5], f2[5], f3[5], f4[5];
+               if (instance->traim) {
+                       sprintf(f1, "%d", instance->BEHn[21]);
+                       sprintf(f2, "%d", instance->BEHn[22]);
+                       sprintf(f3, "%2d", instance->BEHn[23]*256+instance->BEHn[24]);
+                       sprintf(f4, "%3d", (s_char) instance->BEHn[25]);
+               } else {
+                       strcpy(f1, "x");
+                       strcpy(f2, "x");
+                       strcpy(f3, "xx");
+                       strcpy(f4, "xxx");
+               }
+               sprintf(instance->pp->a_lastcode,       /* MAX length 128, currently at 121 */
+ "%u.%09lu %d %d %2d %2d %2d %2ld rstat   %02x dop %4.1f nsat %2d,%d traim %d,%s,%s sigma %s neg-sawtooth %s sat %d%d%d%d%d%d%d%d",
+                   ts.l_ui, j,
+                   instance->pp->year, instance->pp->day,
+                   instance->pp->hour, instance->pp->minute, instance->pp->second,
+                   (long) tsp->tv_sec % 60,
+                   Rsm, 0.1*(256*instance->BEHa[35]+instance->BEHa[36]),
+                   /*rsat      dop */
+                   instance->BEHa[38], instance->BEHa[39], instance->traim, f1, f2,
+                   /*  nsat visible,     nsat tracked,     traim,traim,traim */
+                   f3, f4,
+                   /* sigma neg-sawtooth */
+         /*sat*/   instance->BEHa[41], instance->BEHa[45], instance->BEHa[49], instance->BEHa[53],
+                   instance->BEHa[57], instance->BEHa[61], instance->BEHa[65], instance->BEHa[69]
+                   );                                  /* will be 0 for 6 chan */
+       } else if (instance->chan == 12) {
+               char    f1[5], f2[5], f3[5], f4[5];
+               if (instance->traim) {
+                       sprintf(f1, "%d", instance->BEHn[6]);
+                       sprintf(f2, "%d", instance->BEHn[7]);
+                       sprintf(f3, "%d", instance->BEHn[12]*256+instance->BEHn[13]);
+                       sprintf(f4, "%3d", (s_char) instance->BEHn[14]);
+               } else {
+                       strcpy(f1, "x");
+                       strcpy(f2, "x");
+                       strcpy(f3, "x");
+                       strcpy(f4, "xxx");
+               }
+               sprintf(instance->pp->a_lastcode,
+ "%u.%09lu %d %d %2d %2d %2d %2ld rstat %02x dop %4.1f nsat %2d,%d traim %d,%s,%s sigma %s neg-sawtooth %s sat %d%d%d%d%d%d%d%d%d%d%d%d",
+                   ts.l_ui, j,
+                   instance->pp->year, instance->pp->day,
+                   instance->pp->hour, instance->pp->minute, instance->pp->second,
+                   (long) tsp->tv_sec % 60,
+                   Rsm, 0.1*(256*instance->BEHa[53]+instance->BEHa[54]),
+                   /*rsat      dop */
+                   instance->BEHa[55], instance->BEHa[56], instance->traim, f1, f2,
+                   /*  nsat visible,     nsat tracked   traim,traim,traim */
+                   f3, f4,
+                   /* sigma neg-sawtooth */
+         /*sat*/   instance->BEHa[58], instance->BEHa[64], instance->BEHa[70], instance->BEHa[76],
+                   instance->BEHa[82], instance->BEHa[88], instance->BEHa[94], instance->BEHa[100],
+                   instance->BEHa[106], instance->BEHa[112], instance->BEHa[118], instance->BEHa[124]
+                   );
+       }
+
+#ifdef DEBUG
+       if (debug > 2) {
+               int n;
+
+               n = strlen(instance->pp->a_lastcode);
+               printf("ONCORE[%d]: len = %d %s\n", instance->unit, n, instance->pp->a_lastcode);
+       }
+#endif
+
+       /* and some things I dont understand (magic ntp things) */
+
+       if (!refclock_process(instance->pp)) {
+               refclock_report(instance->peer, CEVNT_BADTIME);
+               return;
+       }
+
+       record_clock_stats(&(instance->peer->srcadr), instance->pp->a_lastcode);
+       instance->pollcnt = 2;
+
+       if (instance->polled) {
+               instance->polled = 0;
+            /* instance->pp->dispersion = instance->pp->skew = 0;      */
+               instance->pp->lastref = instance->pp->lastrec;
+               refclock_receive(instance->peer);
+       }
+}
+
+
+/*************** oncore_msg_XX routines start here *******************/
+
+
+/*
+ * print Oncore response message.
+ */
+
+static void
+oncore_msg_any(
+       struct instance *instance,
+       u_char *buf,
+       size_t len,
+       int idx
+       )
+{
+       int i;
+       const char *fmt = oncore_messages[idx].fmt;
+       const char *p;
+#ifdef HAVE_GETCLOCK
+       struct timespec ts;
+#endif
+       struct timeval tv;
+
+#ifdef DEBUG
+       if (debug > 3) {
+# ifdef HAVE_GETCLOCK
+               (void) getclock(TIMEOFDAY, &ts);
+               tv.tv_sec = ts.tv_sec;
+               tv.tv_usec = ts.tv_nsec / 1000;
+# else
+               GETTIMEOFDAY(&tv, 0);
+# endif
+               printf("ONCORE[%d]: %ld.%06ld\n", instance->unit, (long) tv.tv_sec, (long) tv.tv_usec);
+
+               if (!*fmt) {
+                       printf(">>@@%c%c ", buf[2], buf[3]);
+                       for(i=2; i < len && i < 2400 ; i++)
+                               printf("%02x", buf[i]);
+                       printf("\n");
+                       return;
+               } else {
+                       printf("##");
+                       for (p = fmt; *p; p++) {
+                               putchar(*p);
+                               putchar('_');
+                       }
+                       printf("\n%c%c", buf[2], buf[3]);
+                       i = 4;
+                       for (p = fmt; *p; p++) {
+                               printf("%02x", buf[i++]);
+                       }
+                       printf("\n");
+               }
+       }
+#endif
+}
+
+
+
+/* Latitude, Longitude, Height */
+
+static void
+oncore_msg_Adef(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+}
+
+
+
+/* Mask Angle */
+
+static void
+oncore_msg_Ag(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{              char  Msg[160], *cp;
+
+               cp = "set to";
+               if (instance->o_state == ONCORE_RUN)
+                       cp = "is";
+
+               instance->Ag = buf[4];
+               sprintf(Msg, "Satellite mask angle %s %d degrees", cp, (int) instance->Ag);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+
+
+
+/*
+ * get Position hold position
+ */
+
+static void
+oncore_msg_As(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       instance->ss_lat  = buf_w32(&buf[4]);
+       instance->ss_long = buf_w32(&buf[8]);
+       instance->ss_ht   = buf_w32(&buf[12]);
+
+       /* Print out Position */
+       oncore_print_posn(instance);
+}
+
+
+
+/*
+ * Try to use Oncore UT+ Auto Survey Feature
+ *     If its not there (VP), set flag to do it ourselves.
+ */
+
+static void
+oncore_msg_At(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       char    *cp;
+
+       instance->saw_At = 1;
+       if (instance->site_survey == ONCORE_SS_TESTING) {
+               if (buf[4] == 2) {
+                       record_clock_stats(&(instance->peer->srcadr),
+                                       "Initiating hardware 3D site survey");
+
+                       cp = "SSstate = ONCORE_SS_HW";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+                       instance->site_survey = ONCORE_SS_HW;
+               }
+       }
+}
+
+
+
+/*
+ * get PPS Offset
+ * Nb. @@Ay is not supported for early UT (no plus) model
+ */
+
+static void
+oncore_msg_Ay(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       char Msg[120];
+
+       if (instance->saw_Ay)
+               return;
+
+       instance->saw_Ay = 1;
+
+       instance->offset = buf_w32(&buf[4]);
+
+       sprintf(Msg, "PPS Offset is set to %ld ns", instance->offset);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+
+
+
+/*
+ * get Cable Delay
+ */
+
+static void
+oncore_msg_Az(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       char Msg[120];
+
+       if (instance->saw_Az)
+               return;
+
+       instance->saw_Az = 1;
+
+       instance->delay = buf_w32(&buf[4]);
+
+       sprintf(Msg, "Cable delay is set to %ld ns", instance->delay);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+
+
+
+/* Ba, Ea and Ha come here, these contain Position */
+
+static void
+oncore_msg_BaEaHa(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       const char      *cp;
+       char            Msg[160];
+       int             mode;
+
+       /* OK, we are close to the RUN state now.
+        * But we have a few more items to initialize first.
+        *
+        * At the beginning of this routine there are several 'timers'.
+        * We enter this routine 1/sec, and since the upper levels of NTP have usurped
+        * the use of timers, we use the 1/sec entry to do things that
+        * we would normally do with timers...
+        */
+
+       if (instance->o_state == ONCORE_CHECK_CHAN) {   /* here while checking for the # chan */
+               if (buf[2] == 'B') {            /* 6chan */
+                       if (instance->chan_ck < 6) instance->chan_ck = 6;
+               } else if (buf[2] == 'E') {     /* 8chan */
+                       if (instance->chan_ck < 8) instance->chan_ck = 8;
+               } else if (buf[2] == 'H') {     /* 12chan */
+                       if (instance->chan_ck < 12) instance->chan_ck = 12;
+               }
+
+               if (instance->count3++ < 5)
+                       return;
+
+               instance->count3 = 0;
+
+               if (instance->chan_in != -1)    /* set in Input */
+                       instance->chan = instance->chan_in;
+               else                            /* set from test */
+                       instance->chan = instance->chan_ck;
+
+               sprintf(Msg, "Input   says chan = %d", instance->chan_in);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+               sprintf(Msg, "Model # says chan = %d", instance->chan_id);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+               sprintf(Msg, "Testing says chan = %d", instance->chan_ck);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+               sprintf(Msg, "Using        chan = %d", instance->chan);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+
+               instance->o_state = ONCORE_HAVE_CHAN;
+               cp = "state = ONCORE_HAVE_CHAN";
+               record_clock_stats(&(instance->peer->srcadr), cp);
+
+               instance->timeout = 4;
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Cj, sizeof(oncore_cmd_Cj));
+               return;
+       }
+
+       if (instance->o_state != ONCORE_ALMANAC && instance->o_state != ONCORE_RUN)
+               return;
+
+       /* PAUSE 5sec - make sure results are stable, before using position */
+
+       if (instance->count) {
+               if (instance->count++ < 5)
+                       return;
+               instance->count = 0;
+       }
+
+       memcpy(instance->BEHa, buf, (size_t) (len+3));  /* Ba, Ea or Ha */
+
+       /* check the antenna (did it get unplugged) and almanac (is it ready) for changes. */
+
+       oncore_check_almanac(instance);
+       oncore_check_antenna(instance);
+
+       /* If we are in Almanac mode, waiting for Almanac, we can't do anything till we have it */
+       /* When we have an almanac, we will start the Bn/En/@@Hn messages */
+
+       if (instance->o_state == ONCORE_ALMANAC)
+               if (oncore_wait_almanac(instance))
+                       return;
+
+       /* do some things once when we get this far in BaEaHa */
+
+       if (instance->once) {
+               instance->once = 0;
+               instance->count2 = 1;
+
+               /* Have we seen an @@At (position hold) command response */
+               /* if not, message out */
+
+               if (instance->chan != 12 && !instance->saw_At) {
+                       cp = "Not Good, no @@At command (no Position Hold), must be a GT/GT+";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Av1, sizeof(oncore_cmd_Av1));
+               }
+
+               /* have an Almanac, can start the SiteSurvey
+                * (actually only need to get past the almanac_load where we diddle with At
+                *  command,- we can't change it after we start the HW_SS below
+                */
+
+               mode = instance->init_type;
+               switch (mode) {
+               case 0: /* NO initialization, don't change anything */
+               case 1: /* Use given Position */
+               case 3:
+                       instance->site_survey = ONCORE_SS_DONE;
+                       cp = "SSstate = ONCORE_SS_DONE";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+                       break;
+
+               case 2:
+               case 4: /* Site Survey */
+                       cp = "SSstate = ONCORE_SS_TESTING";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+                       instance->site_survey = ONCORE_SS_TESTING;
+                       instance->count1 = 1;
+                       if (instance->chan == 12)
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Gd3,  sizeof(oncore_cmd_Gd3));  /* M12+T */
+                       else
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_At2,  sizeof(oncore_cmd_At2));  /* not GT, arg not VP */
+                       break;
+               }
+
+               /* Read back PPS Offset for Output */
+               /* Nb. This will fail silently for early UT (no plus) and M12 models */
+
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ayx,  sizeof(oncore_cmd_Ayx));
+
+               /* Read back Cable Delay for Output */
+
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Azx,  sizeof(oncore_cmd_Azx));
+
+               /* Read back Satellite Mask Angle for Output */
+
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Agx,  sizeof(oncore_cmd_Agx));
+       }
+
+
+       /* Unfortunately, the Gd3 command returns '3' for the M12 v1.3 firmware where it is
+        * out-of-range and it should return 0-2. (v1.3 can't do a HW Site Survey)
+        * We must do the Gd3, and then wait a cycle or two for things to settle,
+        * then check Ha[130]&0x10 to see if a SS is in progress.
+        * We will set SW if HW has not been set after an appropriate delay.
+        */
+
+       if (instance->site_survey == ONCORE_SS_TESTING) {
+               if (instance->chan == 12) {
+                       if (instance->count1) {
+                               if (instance->count1++ > 5 || instance->BEHa[130]&0x10) {
+                                       instance->count1 = 0;
+                                       if (instance->BEHa[130]&0x10) {
+                                               record_clock_stats(&(instance->peer->srcadr),
+                                                               "Initiating hardware 3D site survey");
+
+                                               record_clock_stats(&(instance->peer->srcadr), "SSstate = ONCORE_SS_HW");
+                                               instance->site_survey = ONCORE_SS_HW;
+                                       } else {
+                                               record_clock_stats(&(instance->peer->srcadr), "SSstate = ONCORE_SS_SW");
+                                               instance->site_survey = ONCORE_SS_SW;
+                                       }
+                               }
+                       }
+               } else {
+                       if (instance->count1) {
+                               if (instance->count1++ > 5) {
+                                       instance->count1 = 0;
+                                       /*
+                                        * For instance->site_survey to still be ONCORE_SS_TESTING, then after a 5sec
+                                        * wait after the @@At2/@@Gd3 command we have not changed the state to
+                                        * ONCORE_SS_HW.  If the Hardware is capable of doing a Site Survey, then
+                                        * the variable would have been changed by now.
+                                        * There are three possibilities:
+                                        * 6/8chan
+                                        *   (a) We did not get a response to the @@At0 or @@At2 commands,
+                                        *         and it must be a GT/GT+/SL with no position hold mode.
+                                        *         We will have to do it ourselves.
+                                        *   (b) We saw the @@At0, @@At2 commands, but @@At2 failed,
+                                        *         must be a VP or older UT which doesn't have Site Survey mode.
+                                        *         We will have to do it ourselves.
+                                        * 12chan
+                                        *   (c) We saw the @@Gd command, and saw H[13]*0x10
+                                        *         We will have to do it ourselves (done above)
+                                        */
+
+                                       sprintf(Msg, "Initiating software 3D site survey (%d samples)",
+                                               POS_HOLD_AVERAGE);
+                                       record_clock_stats(&(instance->peer->srcadr), Msg);
+
+                                       record_clock_stats(&(instance->peer->srcadr), "SSstate = ONCORE_SS_SW");
+                                       instance->site_survey = ONCORE_SS_SW;
+
+                                       instance->ss_lat = instance->ss_long = instance->ss_ht = 0;
+                                       if (instance->chan == 12)
+                                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Gd0, sizeof(oncore_cmd_Gd0)); /* disable */
+                                       else {
+                                               oncore_sendmsg(instance->ttyfd, oncore_cmd_At0, sizeof(oncore_cmd_At0)); /* disable */
+                                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Av0, sizeof(oncore_cmd_Av0)); /* disable */
+                                       }
+                               }
+                       }
+               }
+       }
+
+       /* check the mode we are in 0/2/3D */
+
+       if (instance->chan == 6) {
+               if (instance->BEHa[64]&0x8)
+                       instance->mode = MODE_0D;
+               else if (instance->BEHa[64]&0x10)
+                       instance->mode = MODE_2D;
+               else if (instance->BEHa[64]&0x20)
+                       instance->mode = MODE_3D;
+       } else if (instance->chan == 8) {
+               if (instance->BEHa[72]&0x8)
+                       instance->mode = MODE_0D;
+               else if (instance->BEHa[72]&0x10)
+                       instance->mode = MODE_2D;
+               else if (instance->BEHa[72]&0x20)
+                       instance->mode = MODE_3D;
+       } else if (instance->chan == 12) {
+               int bits;
+
+               bits = (instance->BEHa[129]>>5) & 0x7;  /* actually Ha */
+               if (bits == 0x4)
+                       instance->mode = MODE_0D;
+               else if (bits == 0x6)
+                       instance->mode = MODE_2D;
+               else if (bits == 0x7)
+                       instance->mode = MODE_3D;
+       }
+
+       /* copy the record to the (extra) location in SHMEM */
+
+       if (instance->shmem) {
+               int     i;
+               u_char  *smp;    /* pointer to start of shared mem for Ba/Ea/Ha */
+
+               switch(instance->chan) {
+               case 6:   smp = &instance->shmem[instance->shmem_Ba]; break;
+               case 8:   smp = &instance->shmem[instance->shmem_Ea]; break;
+               case 12:  smp = &instance->shmem[instance->shmem_Ha]; break;
+               default:  smp = (u_char *) NULL;                      break;
+               }
+
+               switch (instance->mode) {
+               case MODE_0D:   i = 1; break;   /* 0D, Position Hold */
+               case MODE_2D:   i = 2; break;   /* 2D, Altitude Hold */
+               case MODE_3D:   i = 3; break;   /* 3D fix */
+               default:        i = 0; break;
+               }
+
+               if (i && smp != NULL) {
+                       i *= (len+6);
+                       smp[i + 2]++;
+                       memcpy(&smp[i+3], buf, (size_t) (len+3));
+               }
+       }
+
+       /*
+        * check if traim timer active
+        * if it hasn't been cleared, then @@Bn/@@En/@@Hn did not respond
+        */
+
+       if (instance->traim_delay) {
+               if (instance->traim_delay++ > 5) {
+                       instance->traim = 0;
+                       instance->traim_delay = 0;
+                       cp = "ONCORE: Did not detect TRAIM response, TRAIM = OFF";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+
+                       oncore_set_traim(instance);
+               } else
+                       return;
+
+       }
+
+       /* by now should have a @@Ba/@@Ea/@@Ha with good data in it */
+
+       if (!instance->have_dH && !instance->traim_delay)
+               oncore_compute_dH(instance);
+
+       /*
+        * must be ONCORE_RUN if we are here.
+        * Have # chan and TRAIM by now.
+        */
+
+       instance->pp->year   = buf[6]*256+buf[7];
+       instance->pp->day    = ymd2yd(buf[6]*256+buf[7], buf[4], buf[5]);
+       instance->pp->hour   = buf[8];
+       instance->pp->minute = buf[9];
+       instance->pp->second = buf[10];
+
+       /*
+        * Are we doing a Hardware or Software Site Survey?
+        */
+
+       if (instance->site_survey == ONCORE_SS_HW || instance->site_survey == ONCORE_SS_SW)
+               oncore_ss(instance);
+
+       /* see if we ever saw a response from the @@Ayx above */
+
+       if (instance->count2) {
+               if (instance->count2++ > 5) {   /* this delay to check on @@Ay command */
+                       instance->count2 = 0;
+
+                       /* Have we seen an Ay (1PPS time offset) command response */
+                       /* if not, and non-zero offset, zero the offset, and send message */
+
+                       if (!instance->saw_Ay && instance->offset) {
+                               cp = "No @@Ay command, PPS OFFSET ignored";
+                               record_clock_stats(&(instance->peer->srcadr), cp);
+                               instance->offset = 0;
+                       }
+               }
+       }
+
+       /*
+        * Check the leap second status once per day.
+        */
+
+       oncore_check_leap_sec(instance);
+
+       /*
+        * if SHMEM active, every 15s, steal one 'tick' to get 2D or 3D posn.
+        */
+
+       if (instance->shmem && !instance->shmem_bad_Ea && instance->shmem_Posn && (instance->site_survey == ONCORE_SS_DONE))
+               oncore_shmem_get_3D(instance);
+
+       if (!instance->traim)   /* NO traim, no BnEnHn, go get tick */
+               oncore_get_timestamp(instance, instance->offset, instance->offset);
+}
+
+
+
+/* Almanac Status */
+
+static void
+oncore_msg_Bd(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       char Msg[160];
+
+       sprintf(Msg, "Bd: Almanac %s, week = %d, t = %d, %d SVs: %x",
+               ((buf[4]) ? "LOADED" : "(NONE)"), buf[5], buf[6], buf[7], w32(&buf[8]) );
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+
+
+
+/* get leap-second warning message */
+
+/*
+ * @@Bj does NOT behave as documented in current Oncore firmware.
+ * It turns on the LEAP indicator when the data is set, and does not,
+ * as documented, wait until the beginning of the month when the
+ * leap second will occur.
+ * Since this firmware bug will never be fixed in all the outstanding Oncore receivers
+ * @@Bj is only called in June/December.
+ */
+
+static void
+oncore_msg_Bj(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       const char      *cp;
+
+       switch(buf[4]) {
+       case 1:
+               instance->pp->leap = LEAP_ADDSECOND;
+               cp = "Set pp.leap to LEAP_ADDSECOND";
+               break;
+       case 2:
+               instance->pp->leap = LEAP_DELSECOND;
+               cp = "Set pp.leap to LEAP_DELSECOND";
+               break;
+       case 0:
+       default:
+               instance->pp->leap = LEAP_NOWARNING;
+               cp = "Set pp.leap to LEAP_NOWARNING";
+               break;
+       }
+       record_clock_stats(&(instance->peer->srcadr), cp);
+}
+
+
+
+static void
+oncore_msg_BnEnHn(
+       struct instance *instance,
+       u_char *buf,
+       size_t  len
+       )
+{
+       long    dt1, dt2;
+       char    *cp;
+
+       if (instance->o_state != ONCORE_RUN)
+               return;
+
+       if (instance->traim_delay) {     /* flag that @@Bn/@@En/Hn returned */
+                       instance->traim_ck = 1;
+                       instance->traim_delay = 0;
+                       cp = "ONCORE: Detected TRAIM, TRAIM = ON";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+
+                       oncore_set_traim(instance);
+       }
+
+       memcpy(instance->BEHn, buf, (size_t) len);      /* Bn or En or Hn */
+
+       if (!instance->traim)   /* BnEnHn will be turned off in any case */
+               return;
+
+       /* If Time RAIM doesn't like it, don't trust it */
+
+       if (buf[2] == 'H') {
+               if (instance->BEHn[6])  /* bad TRAIM */
+                       return;
+
+               dt1 = instance->saw_tooth + instance->offset;    /* dt this time step */
+               instance->saw_tooth = (s_char) instance->BEHn[14]; /* update for next time Hn[14] */
+               dt2 = instance->saw_tooth + instance->offset;    /* dt next time step */
+       } else {
+               if (instance->BEHn[21]) /* bad TRAIM */
+                       return;
+
+               dt1 = instance->saw_tooth + instance->offset;    /* dt this time step */
+               instance->saw_tooth = (s_char) instance->BEHn[25]; /* update for next time Bn[25], En[25] */
+               dt2 = instance->saw_tooth + instance->offset;    /* dt next time step */
+       }
+
+       oncore_get_timestamp(instance, dt1, dt2);
+}
+
+
+
+/* Here for @@Ca, @@Fa and @@Ia messages */
+
+/* These are Self test Commands for 6, 8, and 12 chan receivers.
+ * There are good reasons NOT to do a @@Ca, @@Fa or @@Ia command with the ONCORE.
+ * It was found that under some circumstances the following
+ * command would fail if issued immediately after the return from the
+ * @@Fa, but a 2sec delay seemed to fix things.  Since simply calling
+ * sleep(2) is wasteful, and may cause trouble for some OS's, repeating
+ * itimer, we set a flag, and test it at the next POLL.  If it hasn't
+ * been cleared, we reissue the @@Cj that is issued below.
+ * Note that we do a @@Cj at the beginning, and again here.
+ * The first is to get the info, the 2nd is just used as a safe command
+ * after the @@Fa for all Oncores (and it was in this posn in the
+ * original code).
+ */
+
+static void
+oncore_msg_CaFaIa(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       char *cp;
+       int     i;
+
+       if (instance->o_state == ONCORE_TEST_SENT) {
+               enum antenna_state antenna;
+
+               instance->timeout = 0;
+
+#ifdef DEBUG
+               if (debug > 2) {
+                       if (buf[2] == 'I')
+                               printf("ONCORE[%d]: >>@@%ca %x %x %x\n", instance->unit, buf[2], buf[4], buf[5], buf[6]);
+                       else
+                               printf("ONCORE[%d]: >>@@%ca %x %x\n", instance->unit, buf[2], buf[4], buf[5]);
+               }
+#endif
+
+               antenna = (buf[4] & 0xc0) >> 6;
+               buf[4] &= ~0xc0;
+
+               i = buf[4] || buf[5];
+               if (buf[2] == 'I') i = i || buf[6];
+               if (i) {
+                       if (buf[2] == 'I') {
+                               msyslog(LOG_ERR, "ONCORE[%d]: self test failed: result %02x %02x %02x",
+                                       instance->unit, buf[4], buf[5], buf[6]);
+                       } else {
+                               msyslog(LOG_ERR, "ONCORE[%d]: self test failed: result %02x %02x",
+                                       instance->unit, buf[4], buf[5]);
+                       }
+                       cp = "ONCORE: self test failed, shutting down driver";
+                       record_clock_stats(&instance->peer->srcadr, cp);
+
+                       refclock_report(instance->peer, CEVNT_FAULT);
+                       oncore_shutdown(instance->unit, instance->peer);
+                       return;
+               }
+
+               /* report the current antenna state */
+
+               oncore_antenna_report(instance, antenna);
+
+               instance->o_state = ONCORE_INIT;
+               cp = "state = ONCORE_INIT";
+               record_clock_stats(&(instance->peer->srcadr), cp);
+
+               instance->timeout = 4;
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Cj, sizeof(oncore_cmd_Cj));
+       }
+}
+
+
+
+/*
+ * Demultiplex the almanac into shmem
+ */
+
+static void
+oncore_msg_Cb(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       int i;
+
+       if (instance->shmem == NULL)
+               return;
+
+       if (buf[4] == 5 && buf[5] > 0 && buf[5] < 26)
+               i = buf[5];
+       else if (buf[4] == 4 && buf[5] <= 5)
+               i = buf[5] + 24;
+       else if (buf[4] == 4 && buf[5] <= 10)
+               i = buf[5] + 23;
+       else if (buf[4] == 4 && buf[5] == 25)
+               i = 34;
+       else {
+               char *cp;
+
+               cp = "Cb: Response is NO ALMANAC";
+               record_clock_stats(&(instance->peer->srcadr), cp);
+               return;
+       }
+
+       i *= 36;
+       instance->shmem[instance->shmem_Cb + i + 2]++;
+       memcpy(instance->shmem + instance->shmem_Cb + i + 3, buf, (size_t) (len + 3));
+
+#if 1
+       {
+       char Msg[160];
+       sprintf(Msg, "See Cb [%d,%d]", buf[4], buf[5]);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+       }
+#endif
+}
+
+
+
+/*
+ * Set to Factory Defaults (Reasonable for UT w/ no Battery Backup
+ *     not so for VP (eeprom) or any unit with a battery
+ */
+
+static void
+oncore_msg_Cf(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       const char *cp;
+
+       if (instance->o_state == ONCORE_RESET_SENT) {
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Cg, sizeof(oncore_cmd_Cg)); /* Return to  Posn Fix mode */
+                                                                                      /* Reset set VP to IDLE */
+               instance->o_state = ONCORE_TEST_SENT;
+               cp = "state = ONCORE_TEST_SENT";
+               record_clock_stats(&(instance->peer->srcadr), cp);
+
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Cj, sizeof(oncore_cmd_Cj));
+       }
+}
+
+
+
+/*
+ * This is the Grand Central Station for the Preliminary Initialization.
+ * Once done here we move on to oncore_msg_BaEaHa for final Initialization and Running.
+ *
+ * We do an @@Cj whenever we need a safe command for all Oncores.
+ * The @@Cj gets us back here where we can switch to the next phase of setup.
+ *
+ * o Once at the very beginning (in start) to get the Model number.
+ *   This info is printed, but no longer used.
+ * o Again after we have determined the number of Channels in the receiver.
+ * o And once later after we have done a reset and test, (which may hang),
+ *   as we are about to initialize the Oncore and start it running.
+ * o We have one routine below for each case.
+ */
+
+static void
+oncore_msg_Cj(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       int     mode;
+       char    *cp;
+
+       memcpy(instance->Cj, buf, len);
+
+       instance->timeout = 0;
+       if (instance->o_state == ONCORE_CHECK_ID) {
+               oncore_msg_Cj_id(instance, buf, len);
+               oncore_chan_test(instance);
+       } else if (instance->o_state == ONCORE_HAVE_CHAN) {
+               mode = instance->init_type;
+               if (mode == 3 || mode == 4) {   /* Cf will return here to check for TEST */
+                       instance->o_state = ONCORE_RESET_SENT;
+                       cp = "state = ONCORE_RESET_SENT";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Cf, sizeof(oncore_cmd_Cf));
+               } else {
+                       instance->o_state = ONCORE_TEST_SENT;
+                       cp = "state = ONCORE_TEST_SENT";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+               }
+       }
+
+       if (instance->o_state == ONCORE_TEST_SENT) {
+               if (instance->chan == 6)
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Ca, sizeof(oncore_cmd_Ca));
+               else if (instance->chan == 8)
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Fa, sizeof(oncore_cmd_Fa));
+               else if (instance->chan == 12)
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Ia, sizeof(oncore_cmd_Ia));
+       } else if (instance->o_state == ONCORE_INIT)
+               oncore_msg_Cj_init(instance, buf, len);
+}
+
+
+
+/* The information on determining a Oncore 'Model', viz VP, UT, etc, from
+ *     the Model Number comes from "Richard M. Hambly" <rick@cnssys.com>
+ *     and from Motorola.  Until recently Rick was the only source of
+ *     this information as Motorola didn't give the information out.
+ *
+ * Determine the Type from the Model #, this determines #chan and if TRAIM is
+ *   available.
+ *
+ * The Information from this routine is NO LONGER USED.
+ * The RESULTS are PRINTED, BUT NOT USED, and the routine COULD BE DELETED
+ */
+
+static void
+oncore_msg_Cj_id(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       char *cp, *cp1, *cp2, Model[21], Msg[160];
+
+       /* Write Receiver ID message to clockstats file */
+
+       instance->Cj[294] = '\0';
+       for (cp=(char *)instance->Cj; cp< (char *) &instance->Cj[294]; ) {
+               cp1 = strchr(cp, '\r');
+               if (!cp1)
+                       cp1 = (char *)&instance->Cj[294];
+               *cp1 = '\0';
+               record_clock_stats(&(instance->peer->srcadr), cp);
+               *cp1 = '\r';
+               cp = cp1+2;
+       }
+
+       /* next, the Firmware Version and Revision numbers */
+
+       instance->version  = atoi((char *) &instance->Cj[83]);
+       instance->revision = atoi((char *) &instance->Cj[111]);
+
+       /* from model number decide which Oncore this is,
+               and then the number of channels */
+
+       for (cp= (char *) &instance->Cj[160]; *cp == ' '; cp++)   /* start right after 'Model #' */
+               ;
+       cp1 = cp;
+       cp2 = Model;
+       for (; !isspace((int)*cp) && cp-cp1 < 20; cp++, cp2++)
+               *cp2 = *cp;
+       *cp2 = '\0';
+
+       cp = 0;
+       if (!strncmp(Model, "PVT6", (size_t) 4)) {
+               cp = "PVT6";
+               instance->model = ONCORE_PVT6;
+       } else if (Model[0] == 'A') {
+               cp = "Basic";
+               instance->model = ONCORE_BASIC;
+       } else if (Model[0] == 'B' || !strncmp(Model, "T8", (size_t) 2)) {
+               cp = "VP";
+               instance->model = ONCORE_VP;
+       } else if (Model[0] == 'P') {
+               cp = "M12";
+               instance->model = ONCORE_M12;
+       } else if (Model[0] == 'R' || Model[0] == 'D' || Model[0] == 'S') {
+               if (Model[5] == 'N') {
+                       cp = "GT";
+                       instance->model = ONCORE_GT;
+               } else if ((Model[1] == '3' || Model[1] == '4') && Model[5] == 'G') {
+                       cp = "GT+";
+                       instance->model = ONCORE_GTPLUS;
+               } else if ((Model[1] == '5' && Model[5] == 'U') || (Model[1] == '1' && Model[5] == 'A')) {
+                               cp = "UT";
+                               instance->model = ONCORE_UT;
+               } else if (Model[1] == '5' && Model[5] == 'G') {
+                       cp = "UT+";
+                       instance->model = ONCORE_UTPLUS;
+               } else if (Model[1] == '6' && Model[5] == 'G') {
+                       cp = "SL";
+                       instance->model = ONCORE_SL;
+               } else {
+                       cp = "Unknown";
+                       instance->model = ONCORE_UNKNOWN;
+               }
+       } else  {
+               cp = "Unknown";
+               instance->model = ONCORE_UNKNOWN;
+       }
+
+       /* use MODEL to set CHAN and TRAIM and possibly zero SHMEM */
+
+       sprintf(Msg, "This looks like an Oncore %s with version %d.%d firmware.", cp, instance->version, instance->revision);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+
+       instance->chan_id = 8;     /* default */
+       if (instance->model == ONCORE_BASIC || instance->model == ONCORE_PVT6)
+               instance->chan_id = 6;
+       else if (instance->model == ONCORE_VP || instance->model == ONCORE_UT || instance->model == ONCORE_UTPLUS)
+               instance->chan_id = 8;
+       else if (instance->model == ONCORE_M12)
+               instance->chan_id = 12;
+
+       instance->traim_id = 0;    /* default */
+       if (instance->model == ONCORE_BASIC || instance->model == ONCORE_PVT6)
+               instance->traim_id = 0;
+       else if (instance->model == ONCORE_VP || instance->model == ONCORE_UT || instance->model == ONCORE_UTPLUS)
+               instance->traim_id = 1;
+       else if (instance->model == ONCORE_M12)
+               instance->traim_id = -1;
+
+       sprintf(Msg, "Channels = %d, TRAIM = %s", instance->chan_id,
+               ((instance->traim_id < 0) ? "UNKNOWN" : ((instance->traim_id > 0) ? "ON" : "OFF")));
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+
+
+
+/* OK, know type of Oncore, have possibly reset it, and have tested it.
+ * We know the number of channels.
+ * We will determine whether we have TRAIM before we actually start.
+ * Now initialize.
+ */
+
+static void
+oncore_msg_Cj_init(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       char *cp, Msg[160];
+       u_char Cmd[20];
+       int     mode;
+
+
+       /* The M12 with 1.3 or 2.0 Firmware, loses track of all Satellites and has to
+        * start again if we go from 0D -> 3D, then loses them again when we
+        * go from 3D -> 0D.  We do this to get a @@Ea message for SHMEM.
+        * For NOW we will turn this aspect of filling SHMEM off for the M12
+        */
+
+       if (instance->chan == 12) {
+               instance->shmem_bad_Ea = 1;
+               sprintf(Msg, "*** SHMEM partially enabled for ONCORE M12 s/w v%d.%d ***", instance->version, instance->revision);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+       }
+
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Cg, sizeof(oncore_cmd_Cg)); /* Return to  Posn Fix mode */
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Bb, sizeof(oncore_cmd_Bb)); /* turn on for shmem (6/8/12) */
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Ek, sizeof(oncore_cmd_Ek)); /* turn off (VP) */
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Aw, sizeof(oncore_cmd_Aw)); /* UTC time (6/8/12) */
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_AB, sizeof(oncore_cmd_AB)); /* Appl type static (VP) */
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Be, sizeof(oncore_cmd_Be)); /* Tell us the Almanac for shmem (6/8/12) */
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Bd, sizeof(oncore_cmd_Bd)); /* Tell us when Almanac changes */
+
+       mode = instance->init_type;
+
+       /* If there is Position input in the Config file
+        * and mode = (1,3) set it as posn hold posn, goto 0D mode.
+        *  or mode = (2,4) set it as INITIAL position, and do Site Survey.
+        */
+
+       if (instance->posn_set) {
+               record_clock_stats(&(instance->peer->srcadr), "Setting Posn from input data");
+               oncore_set_posn(instance);      /* this should print posn indirectly thru the As cmd */
+       } else  /* must issue an @@At here to check on 6/8 Position Hold, set_posn would have */
+               if (instance->chan != 12)
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Atx, sizeof(oncore_cmd_Atx));
+
+       if (mode != 0) {
+                       /* cable delay in ns */
+               memcpy(Cmd, oncore_cmd_Az, (size_t) sizeof(oncore_cmd_Az));
+               w32_buf(&Cmd[-2+4], instance->delay);
+               oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Az));   /* 6,8,12 */
+
+                       /* PPS offset in ns */
+               if (instance->offset) {
+                       memcpy(Cmd, oncore_cmd_Ay, (size_t) sizeof(oncore_cmd_Ay));     /* some have it, some don't */
+                       w32_buf(&Cmd[-2+4], instance->offset);                  /* will check for hw response */
+                       oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Ay));
+               }
+
+               /* Satellite mask angle */
+
+               if (instance->Ag != 0xff) {     /* will have 0xff in it if not set by user */
+                       memcpy(Cmd, oncore_cmd_Ag, (size_t) sizeof(oncore_cmd_Ag));
+                       Cmd[-2+4] = instance->Ag;
+                       oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Ag));
+               }
+       }
+
+       /* 6, 8 12 chan - Position/Status/Data Output Message, 1/s
+        * now we're really running
+        * these were ALL started in the chan test,
+        * However, if we had mode=3,4 then commands got turned off, so we turn
+        * them on again here just in case
+        */
+
+       if (instance->chan == 6) { /* start 6chan, kill 8,12chan commands, possibly testing VP in 6chan mode */
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ea0, sizeof(oncore_cmd_Ea0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_En0, sizeof(oncore_cmd_En0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ha0, sizeof(oncore_cmd_Ha0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Hn0, sizeof(oncore_cmd_Hn0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ba,  sizeof(oncore_cmd_Ba ));
+       } else if (instance->chan == 8) {  /* start 8chan, kill 6,12chan commands */
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ba0, sizeof(oncore_cmd_Ba0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Bn0, sizeof(oncore_cmd_Bn0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ha0, sizeof(oncore_cmd_Ha0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Hn0, sizeof(oncore_cmd_Hn0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ea,  sizeof(oncore_cmd_Ea ));
+       } else if (instance->chan == 12){  /* start 12chan, kill 6,12chan commands */
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ba0, sizeof(oncore_cmd_Ba0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Bn0, sizeof(oncore_cmd_Bn0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ea0, sizeof(oncore_cmd_Ea0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_En0, sizeof(oncore_cmd_En0));
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ha,  sizeof(oncore_cmd_Ha ));
+       }
+
+       instance->count = 1;
+       instance->o_state = ONCORE_ALMANAC;
+       cp = "state = ONCORE_ALMANAC";
+       record_clock_stats(&(instance->peer->srcadr), cp);
+}
+
+
+
+/* 12chan position */
+
+static void
+oncore_msg_Ga(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       char Msg[160];
+       long lat, lon, ht;
+       double Lat, Lon, Ht;
+
+
+       lat = buf_w32(&buf[4]);
+       lon = buf_w32(&buf[8]);
+       ht  = buf_w32(&buf[12]);  /* GPS ellipsoid */
+
+       Lat = lat;
+       Lon = lon;
+       Ht  = ht;
+
+       Lat /= 3600000;
+       Lon /= 3600000;
+       Ht  /= 100;
+
+
+       sprintf(Msg, "Ga Posn Lat = %.7f, Lon = %.7f, Ht  = %.2f", Lat, Lon, Ht);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+
+       instance->ss_lat  = lat;
+       instance->ss_long = lon;
+       instance->ss_ht   = ht;
+
+       oncore_print_posn(instance);
+}
+
+
+
+/* 12 chan time/date */
+
+static void
+oncore_msg_Gb(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       char    Msg[160], *gmts;
+       int     mo, d, y, h, m, s, gmth, gmtm;
+
+       mo = buf[4];
+       d  = buf[5];
+       y  = 256*buf[6]+buf[7];
+
+       h  = buf[8];
+       m  = buf[9];
+       s  = buf[10];
+
+       gmts = ((buf[11] == 0) ? "+" : "-");
+       gmth = buf[12];
+       gmtm = buf[13];
+
+       sprintf(Msg, "Date/Time set to: %d%s%d %2d:%02d:%02d GMT (GMT offset is %s%02d:%02d)",
+               d, Month[mo-1], y, h, m, s, gmts, gmth, gmtm);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+
+
+
+/* Leap Second for M12, gives all info from satellite message */
+/* also in UT v3.0 */
+
+static void
+oncore_msg_Gj(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       int dt;
+       char Msg[160], *cp;
+
+       instance->saw_Gj = 1; /* flag, saw_Gj, dont need to try Bj in check_leap */
+
+       /* print the message to verify whats there */
+
+       dt = buf[5] - buf[4];
+
+#if 1
+       sprintf(Msg, "ONCORE[%d]: Leap Sec Msg: %d %d %d %d %d %d %d %d %d %d",
+                       instance->unit,
+                       buf[4], buf[5], 256*buf[6]+buf[7], buf[8], buf[9], buf[10],
+                       (buf[14]+256*(buf[13]+256*(buf[12]+256*buf[11]))),
+                       buf[15], buf[16], buf[17]);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+#endif
+       if (dt) {
+               sprintf(Msg, "ONCORE[%d]: Leap second (%d) scheduled for %d%s%d at %d:%d:%d",
+                       instance->unit,
+                       dt, buf[9], Month[buf[8]-1], 256*buf[6]+buf[7],
+                       buf[15], buf[16], buf[17]);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+       }
+
+       /* Only raise warning within a month of the leap second */
+
+       instance->pp->leap = LEAP_NOWARNING;
+       cp = "Set pp.leap to LEAP_NOWARNING";
+
+       if (buf[6] == instance->BEHa[6] && buf[7] == instance->BEHa[7] && /* year */
+           buf[8] == instance->BEHa[4]) {      /* month */
+               if (dt) {
+                       if (dt < 0) {
+                               instance->pp->leap = LEAP_DELSECOND;
+                               cp = "Set pp.leap to LEAP_DELSECOND";
+                       } else {
+                               instance->pp->leap = LEAP_ADDSECOND;
+                               cp = "Set pp.leap to LEAP_ADDSECOND";
+                       }
+               }
+       }
+       record_clock_stats(&(instance->peer->srcadr), cp);
+}
+
+
+
+/* Power on failure */
+
+static void
+oncore_msg_Sz(
+       struct instance *instance,
+       u_char *buf,
+       size_t len
+       )
+{
+       const char *cp;
+
+       cp = "Oncore: System Failure at Power On";
+       if (instance && instance->peer) {
+               record_clock_stats(&(instance->peer->srcadr), cp);
+               oncore_shutdown(instance->unit, instance->peer);
+       }
+}
+
+/************** Small Subroutines ***************/
+
+
+static void
+oncore_antenna_report(
+       struct instance *instance,
+       enum antenna_state new_state)
+{
+       char *cp;
+
+       if (instance->ant_state == new_state)
+               return;
+
+       switch (new_state) {
+       case ONCORE_ANTENNA_OK: cp = "GPS antenna: OK";                   break;
+       case ONCORE_ANTENNA_OC: cp = "GPS antenna: short (overcurrent)";  break;
+       case ONCORE_ANTENNA_UC: cp = "GPS antenna: open (not connected)"; break;
+       case ONCORE_ANTENNA_NV: cp = "GPS antenna: short (no voltage)";   break;
+       default:                cp = "GPS antenna: ?";                    break;
+       }
+
+       instance->ant_state = new_state;
+       record_clock_stats(&instance->peer->srcadr, cp);
+}
+
+
+
+static void
+oncore_chan_test(
+       struct instance *instance
+       )
+{
+       char    *cp;
+
+       /* subroutine oncore_Cj_id has determined the number of channels from the
+        * model number of the attached oncore.  This is not always correct since
+        * the oncore could have non-standard firmware.  Here we check (independently) by
+        * trying a 6, 8, and 12 chan command, and see which responds.
+        * Caution: more than one CAN respond.
+        *
+        * This #chan is used by the code rather than that calculated from the model number.
+        */
+
+       instance->o_state = ONCORE_CHECK_CHAN;
+       cp = "state = ONCORE_CHECK_CHAN";
+       record_clock_stats(&(instance->peer->srcadr), cp);
+
+       instance->count3 = 1;
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Ba, sizeof(oncore_cmd_Ba));
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Ea, sizeof(oncore_cmd_Ea));
+       oncore_sendmsg(instance->ttyfd, oncore_cmd_Ha, sizeof(oncore_cmd_Ha));
+}
+
+
+
+/* check for a GOOD Almanac, have we got one yet? */
+
+static void
+oncore_check_almanac(
+       struct instance *instance
+       )
+{
+       if (instance->chan == 6) {
+               instance->rsm.bad_almanac = instance->BEHa[64]&0x1;
+               instance->rsm.bad_fix     = instance->BEHa[64]&0x52;
+       } else if (instance->chan == 8) {
+               instance->rsm.bad_almanac = instance->BEHa[72]&0x1;
+               instance->rsm.bad_fix     = instance->BEHa[72]&0x52;
+       } else if (instance->chan == 12) {
+               int bits1, bits2, bits3;
+
+               bits1 = (instance->BEHa[129]>>5) & 0x7;         /* actually Ha */
+               bits2 = instance->BEHa[130];
+               instance->rsm.bad_almanac = (bits2 & 0x80);
+               instance->rsm.bad_fix     = (bits2 & 0x8) || (bits1 == 0x2);
+                                         /* too few sat     Bad Geom     */
+
+               bits3 = instance->BEHa[141];    /* UTC parameters */
+               if (!instance->count5_set && (bits3 & 0xC0)) {
+                       instance->count5 = 2;
+                       instance->count5_set = 1;
+               }
+#if 0
+{
+               char Msg[160];
+
+               sprintf(Msg, "ONCORE[%d]: DEBUG BITS: (%x %x), (%x %x %x),  %x %x %x %x %x\n",
+               instance->unit,
+               instance->BEHa[129], instance->BEHa[130], bits1, bits2, bits3, instance->mode == MODE_0D,
+               instance->mode == MODE_2D, instance->mode == MODE_3D,
+               instance->rsm.bad_almanac, instance->rsm.bad_fix);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+#endif
+       }
+}
+
+
+
+/* check the antenna for changes (did it get unplugged?) */
+
+static void
+oncore_check_antenna(
+       struct instance *instance
+       )
+{
+       enum antenna_state antenna;             /* antenna state */
+
+       antenna = instance->ant_state;
+       if (instance->chan == 12)
+               antenna = (instance->BEHa[130] & 0x6 ) >> 1;
+       else
+               antenna = (instance->BEHa[37] & 0xc0) >> 6;  /* prob unset 6, set GT, UT unset VP */
+
+       oncore_antenna_report (instance, antenna);
+}
+
+
+
+/*
+ * Check the leap second status once per day.
+ *
+ * Note that the ONCORE firmware for the Bj command is wrong at
+ * least in the VP.
+ * It starts advertising a LEAP SECOND as soon as the GPS satellite
+ * data message (page 18, subframe 4) is updated to a date in the
+ * future, and does not wait for the month that it will occur.
+ * The event will usually be advertised several months in advance.
+ * Since there is a one bit flag, there is no way to tell if it is
+ * this month, or when...
+ *
+ * As such, we have the workaround below, of only checking for leap
+ * seconds with the Bj command in June/December.
+ *
+ * The Gj command gives more information, and we can tell in which
+ * month to apply the correction.
+ *
+ * Note that with the VP we COULD read the raw data message, and
+ * interpret it ourselves, but since this is specific to this receiver
+ * only, and the above workaround is adequate, we don't bother.
+ */
+
+static void
+oncore_check_leap_sec(
+       struct instance *instance
+       )
+{
+       if (instance->Bj_day != instance->BEHa[5]) {     /* do this 1/day */
+               instance->Bj_day = instance->BEHa[5];
+
+               if (instance->saw_Gj < 0) {     /* -1 DONT have Gj use Bj */
+                       if ((instance->BEHa[4] == 6) || (instance->BEHa[4] == 12))
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Bj, sizeof(oncore_cmd_Bj));
+                       return;
+               }
+
+               if (instance->saw_Gj == 0)      /* 0 is dont know if we have Gj */
+                       instance->count4 = 1;
+
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Gj, sizeof(oncore_cmd_Gj));
+               return;
+       }
+
+       /* Gj works for some 6/8 chan UT and the M12      */
+       /* if no response from Gj in 5 sec, we try Bj     */
+       /* which isnt implemented in all the GT/UT either */
+
+       if (instance->count4) {         /* delay, waiting for Gj response */
+               if (instance->saw_Gj == 1)
+                       instance->count4 = 0;
+               else if (instance->count4++ > 5) {      /* delay, waiting for Gj response */
+                       instance->saw_Gj = -1;          /* didnt see it, will use Bj */
+                       instance->count4 = 0;
+                       if ((instance->BEHa[4] == 6) || (instance->BEHa[4] == 12))
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Bj, sizeof(oncore_cmd_Bj));
+               }
+       }
+}
+
+
+
+/* check the message checksum,
+ *  buf points to START of message ( @@ )
+ *  len is length WITH CR/LF.
+ */
+
+static int
+oncore_checksum_ok(
+       u_char *buf,
+       int     len
+       )
+{
+       int     i, j;
+
+       j = 0;
+       for (i = 2; i < len-3; i++)
+               j ^= buf[i];
+
+       return(j == buf[len-3]);
+}
+
+
+
+static void
+oncore_compute_dH(
+       struct instance *instance
+       )
+{
+       int GPS, MSL;
+       char    Msg[160];
+
+       /* Here calculate dH = GPS - MSL for output message */
+       /* also set Altitude Hold mode if GT */
+
+       instance->have_dH = 1;
+       if (instance->chan == 12) {
+               GPS = buf_w32(&instance->BEHa[39]);
+               MSL = buf_w32(&instance->BEHa[43]);
+       } else {
+               GPS = buf_w32(&instance->BEHa[23]);
+               MSL = buf_w32(&instance->BEHa[27]);
+       }
+       instance->dH = GPS - MSL;
+       instance->dH /= 100.;
+
+       /* if MSL is not set, the calculation is meaningless */
+
+       if (MSL) {      /* not set ! */
+               sprintf(Msg, "dH = (GPS - MSL) = %.2fm", instance->dH);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+       }
+}
+
+
+
+/*
+ * try loading Almanac from shmem (where it was copied from shmem_old
+ */
+
+static void
+oncore_load_almanac(
+       struct instance *instance
+       )
+{
+       u_char  *cp, Cmd[20];
+       int     n;
+       struct timeval tv;
+       struct tm *tm;
+
+       if (!instance->shmem)
+               return;
+
+#if 1
+       for (cp=instance->shmem+4; (n = 256*(*(cp-3)) + *(cp-2)); cp+=(n+3)) {
+               if (!strncmp((char *) cp, "@@Cb", 4) &&
+                   oncore_checksum_ok(cp, 33) &&
+                   (*(cp+4) == 4 || *(cp+4) == 5)) {
+                       write(instance->ttyfd, cp, n);
+#if 1
+                       oncore_print_Cb(instance, cp);
+#endif
+               }
+       }
+#else
+/************DEBUG************/
+       for (cp=instance->shmem+4; (n = 256*(*(cp-3)) + *(cp-2)); cp+=(n+3)) {
+               char Msg[160];
+
+               sprintf(Msg, "See %c%c%c%c %d", *(cp), *(cp+1), *(cp+2), *(cp+3), *(cp+4));
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+
+               if (!strncmp(cp, "@@Cb", 4)) {
+                       oncore_print_Cb(instance, cp);
+                       if (oncore_checksum_ok(cp, 33)) {
+                               if (*(cp+4) == 4 || *(cp+4) == 5) {
+                                       record_clock_stats(&(instance->peer->srcadr), "GOOD SF");
+                                       write(instance->ttyfd, cp, n);
+                               } else
+                                       record_clock_stats(&(instance->peer->srcadr), "BAD SF");
+                       } else
+                               record_clock_stats(&(instance->peer->srcadr), "BAD CHECKSUM");
+               }
+       }
+/************DEBUG************/
+#endif
+
+       /* Must load position and time or the Almanac doesn't do us any good */
+
+       if (!instance->posn_set) {      /* if we input a posn use it, else from SHMEM */
+               record_clock_stats(&(instance->peer->srcadr), "Loading Posn from SHMEM");
+               for (cp=instance->shmem+4; (n = 256*(*(cp-3)) + *(cp-2));  cp+=(n+3)) {
+                       if ((instance->chan == 6  && (!strncmp((char *) cp, "@@Ba", 4) && oncore_checksum_ok(cp,  68))) ||
+                           (instance->chan == 8  && (!strncmp((char *) cp, "@@Ea", 4) && oncore_checksum_ok(cp,  76))) ||
+                           (instance->chan == 12 && (!strncmp((char *) cp, "@@Ha", 4) && oncore_checksum_ok(cp, 154)))) {
+                               int ii, jj, kk;
+
+                               instance->posn_set = 1;
+                               ii = buf_w32(cp + 15);
+                               jj = buf_w32(cp + 19);
+                               kk = buf_w32(cp + 23);
+#if 0
+{
+char Msg[160];
+sprintf(Msg, "SHMEM posn = %ld (%d, %d, %d)", (long) (cp-instance->shmem), ii, jj, kk);
+record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+#endif
+                               if (ii != 0 || jj != 0 || kk != 0) { /* phk asked for this test */
+                                       instance->ss_lat  = ii;
+                                       instance->ss_long = jj;
+                                       instance->ss_ht   = kk;
+                               }
+                       }
+               }
+       }
+       oncore_set_posn(instance);
+
+       /* and set time to time from Computer clock */
+
+       gettimeofday(&tv, 0);
+       tm = gmtime((const time_t *) &tv.tv_sec);
+#if 1
+       {
+       char Msg[160];
+       sprintf(Msg, "DATE %d %d %d, %d %d %d", 1900+tm->tm_year, tm->tm_mon, tm->tm_mday,
+               tm->tm_hour, tm->tm_min, tm->tm_sec);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+       }
+#endif
+       if (instance->chan == 12) {
+               memcpy(Cmd, oncore_cmd_Gb, (size_t) sizeof(oncore_cmd_Gb));
+               Cmd[-2+4]  = tm->tm_mon + 1;
+               Cmd[-2+5]  = tm->tm_mday;
+               Cmd[-2+6]  = (1900+tm->tm_year)/256;
+               Cmd[-2+7]  = (1900+tm->tm_year)%256;
+               Cmd[-2+8]  = tm->tm_hour;
+               Cmd[-2+9]  = tm->tm_min;
+               Cmd[-2+10] = tm->tm_sec;
+               Cmd[-2+11] = 0;
+               Cmd[-2+12] = 0;
+               Cmd[-2+13] = 0;
+               oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Gb));
+       } else {
+               /* First set GMT offset to zero */
+
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Ab,  sizeof(oncore_cmd_Ab));
+
+               memcpy(Cmd, oncore_cmd_Ac, (size_t) sizeof(oncore_cmd_Ac));
+               Cmd[-2+4] = tm->tm_mon + 1;
+               Cmd[-2+5] = tm->tm_mday;
+               Cmd[-2+6] = (1900+tm->tm_year)/256;
+               Cmd[-2+7] = (1900+tm->tm_year)%256;
+               oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Ac));
+
+               memcpy(Cmd, oncore_cmd_Aa, (size_t) sizeof(oncore_cmd_Aa));
+               Cmd[-2+4] = tm->tm_hour;
+               Cmd[-2+5] = tm->tm_min;
+               Cmd[-2+6] = tm->tm_sec;
+               oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Aa));
+       }
+
+       record_clock_stats(&(instance->peer->srcadr), "Setting Posn and Time after Loading Almanac");
+}
+
+
+
+/* Almanac data input */
+
+static void
+oncore_print_Cb(
+       struct instance *instance,
+       u_char *cp
+       )
+{
+#if 0
+       int     ii;
+       char    Msg[160];
+
+       printf("DEBUG: See: %c%c%c%c\n", *(cp), *(cp+1), *(cp+2), *(cp+3));
+       printf("DEBUG: Cb: [%d,%d]", *(cp+4), *(cp+5));
+       for(ii=0; ii<33; ii++)
+               printf(" %d", *(cp+ii));
+       printf("\n");
+
+       sprintf(Msg, "Debug: Cb: [%d,%d]", *(cp+4), *(cp+5));
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+#endif
+}
+
+
+#if 0
+static void
+oncore_print_array(
+       u_char *cp,
+       int     n
+       )
+{
+       int     jj, i, j, nn;
+
+       nn = 0;
+       printf("\nTOP\n");
+       jj = n/16;
+       for (j=0; j<jj; j++) {
+               printf("%4d: ", nn);
+               nn += 16;
+               for (i=0; i<16; i++)
+                       printf(" %o", *cp++);
+               printf("\n");
+       }
+}
+#endif
+
+
+static void
+oncore_print_posn(
+       struct instance *instance
+       )
+{
+       char Msg[120], ew, ns;
+       double xd, xm, xs, yd, ym, ys, hm, hft;
+       int idx, idy, is, imx, imy;
+       long lat, lon;
+
+       record_clock_stats(&(instance->peer->srcadr), "Posn:");
+       ew = 'E';
+       lon = instance->ss_long;
+       if (lon < 0) {
+               ew = 'W';
+               lon = -lon;
+       }
+
+       ns = 'N';
+       lat = instance->ss_lat;
+       if (lat < 0) {
+               ns = 'S';
+               lat = -lat;
+       }
+
+       hm = instance->ss_ht/100.;
+       hft= hm/0.3048;
+
+       xd = lat/3600000.;      /* lat, lon in int msec arc, ht in cm. */
+       yd = lon/3600000.;
+       sprintf(Msg, "Lat = %c %11.7fdeg,    Long = %c %11.7fdeg,    Alt = %5.2fm (%5.2fft) GPS", ns, xd, ew, yd, hm, hft);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+
+       idx = xd;
+       idy = yd;
+       imx = lat%3600000;
+       imy = lon%3600000;
+       xm = imx/60000.;
+       ym = imy/60000.;
+       sprintf(Msg,
+           "Lat = %c %3ddeg %7.4fm,   Long = %c %3ddeg %8.5fm,  Alt = %7.2fm (%7.2fft) GPS", ns, idx, xm, ew, idy, ym, hm, hft);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+
+       imx = xm;
+       imy = ym;
+       is  = lat%60000;
+       xs  = is/1000.;
+       is  = lon%60000;
+       ys  = is/1000.;
+       sprintf(Msg,
+           "Lat = %c %3ddeg %2dm %5.2fs, Long = %c %3ddeg %2dm %5.2fs, Alt = %7.2fm (%7.2fft) GPS", ns, idx, imx, xs, ew, idy, imy, ys, hm, hft);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+}
+
+
+
+/*
+ * write message to Oncore.
+ */
+
+static void
+oncore_sendmsg(
+       int     fd,
+       u_char *ptr,
+       size_t len
+       )
+{
+       u_char cs = 0;
+
+#ifdef DEBUG
+       if (debug > 4)
+               printf("ONCORE: Send @@%c%c %d\n", ptr[0], ptr[1], (int) len);
+#endif
+       write(fd, "@@", (size_t) 2);
+       write(fd, ptr, len);
+       while (len--)
+               cs ^= *ptr++;
+       write(fd, &cs, (size_t) 1);
+       write(fd, "\r\n", (size_t) 2);
+}
+
+
+
+static void
+oncore_set_posn(
+       struct instance *instance
+       )
+{
+       int     mode;
+       u_char    Cmd[20];
+
+       /* Turn OFF position hold, it needs to be off to set position (for some units),
+          will get set ON in @@Ea later */
+
+       if (instance->chan == 12)
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Gd0, sizeof(oncore_cmd_Gd0)); /* (12) */
+       else {
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_At0, sizeof(oncore_cmd_At0)); /* (6/8) */
+               oncore_sendmsg(instance->ttyfd, oncore_cmd_Av0, sizeof(oncore_cmd_Av0)); /* (6/8) */
+       }
+
+       mode = instance->init_type;
+
+       if (mode != 0) {        /* first set posn hold position */
+               memcpy(Cmd, oncore_cmd_As, (size_t) sizeof(oncore_cmd_As));     /* don't modify static variables */
+               w32_buf(&Cmd[-2+4],  (int) instance->ss_lat);
+               w32_buf(&Cmd[-2+8],  (int) instance->ss_long);
+               w32_buf(&Cmd[-2+12], (int) instance->ss_ht);
+               Cmd[-2+16] = 0;
+               oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_As));   /* posn hold 3D posn (6/8/12) */
+
+               memcpy(Cmd, oncore_cmd_Au, (size_t) sizeof(oncore_cmd_Au));
+               w32_buf(&Cmd[-2+4], (int) instance->ss_ht);
+               Cmd[-2+8] = 0;
+               oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Au));   /* altitude hold (6/8/12 not UT, M12T) */
+
+               /* next set current position */
+
+               if (instance->chan == 12) {
+                       memcpy(Cmd, oncore_cmd_Ga, (size_t) sizeof(oncore_cmd_Ga));
+                       w32_buf(&Cmd[-2+4], (int) instance->ss_lat);
+                       w32_buf(&Cmd[-2+8], (int) instance->ss_long);
+                       w32_buf(&Cmd[-2+12],(int) instance->ss_ht);
+                       Cmd[-2+16] = 0;
+                       oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Ga));             /* 3d posn (12) */
+               } else {
+                       memcpy(Cmd, oncore_cmd_Ad, (size_t) sizeof(oncore_cmd_Ad));
+                       w32_buf(&Cmd[-2+4], (int) instance->ss_lat);
+                       oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Ad));   /* lat (6/8) */
+
+                       memcpy(Cmd, oncore_cmd_Ae, (size_t) sizeof(oncore_cmd_Ae));
+                       w32_buf(&Cmd[-2+4], (int) instance->ss_long);
+                       oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Ae));   /* long (6/8) */
+
+                       memcpy(Cmd, oncore_cmd_Af, (size_t) sizeof(oncore_cmd_Af));
+                       w32_buf(&Cmd[-2+4], (int) instance->ss_ht);
+                       Cmd[-2+8] = 0;
+                       oncore_sendmsg(instance->ttyfd, Cmd,  sizeof(oncore_cmd_Af));   /* ht (6/8) */
+               }
+
+               /* Finally, turn on position hold */
+
+               if (instance->chan == 12)
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Gd1,  sizeof(oncore_cmd_Gd1));
+               else
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_At1,  sizeof(oncore_cmd_At1));
+       }
+}
+
+
+
+static void
+oncore_set_traim(
+       struct instance *instance
+       )
+{
+       char    Msg[160];
+
+       if (instance->traim_in != -1)   /* set in Input */
+               instance->traim = instance->traim_in;
+       else
+               instance->traim = instance->traim_ck;
+
+       sprintf(Msg, "Input   says TRAIM = %d", instance->traim_in);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+       sprintf(Msg, "Model # says TRAIM = %d", instance->traim_id);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+       sprintf(Msg, "Testing says TRAIM = %d", instance->traim_ck);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+       sprintf(Msg, "Using        TRAIM = %d", instance->traim);
+       record_clock_stats(&(instance->peer->srcadr), Msg);
+
+       if (instance->traim_ck == 1 && instance->traim == 0) {
+               /* if it should be off, and I turned it on during testing,
+                  then turn it off again */
+               if (instance->chan == 6)
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Bnx, sizeof(oncore_cmd_Bnx));
+               else if (instance->chan == 8)
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Enx, sizeof(oncore_cmd_Enx));
+               else    /* chan == 12 */
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Ge0, sizeof(oncore_cmd_Ge0));
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Hn0, sizeof(oncore_cmd_Hn0));
+       }
+}
+
+
+
+/*
+ * if SHMEM active, every 15s, steal one 'tick' to get 2D or 3D posn.
+ */
+
+static void
+oncore_shmem_get_3D(
+       struct instance *instance
+       )
+{
+       if (instance->pp->second%15 == 3) {     /* start the sequence */                        /* by changing mode */
+               instance->shmem_reset = 1;
+               if (instance->chan == 12) {
+                       if (instance->shmem_Posn == 2)
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Gd2,  sizeof(oncore_cmd_Gd2));  /* 2D */
+                       else
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Gd0,  sizeof(oncore_cmd_Gd0));  /* 3D */
+               } else {
+                       if (instance->saw_At) {                 /* out of 0D -> 3D mode */
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_At0, sizeof(oncore_cmd_At0));
+                               if (instance->shmem_Posn == 2)  /* 3D -> 2D mode */
+                                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Av1, sizeof(oncore_cmd_Av1));
+                       } else
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Av0, sizeof(oncore_cmd_Av0));
+               }
+       } else if (instance->shmem_reset || (instance->mode != MODE_0D)) {
+               instance->shmem_reset = 0;
+               if (instance->chan == 12)
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Gd1,  sizeof(oncore_cmd_Gd1));       /* 0D */
+               else {
+                       if (instance->saw_At) {
+                               if (instance->mode == MODE_2D)  /* 2D -> 3D or 0D mode */
+                                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Av0, sizeof(oncore_cmd_Av0));
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_At1,  sizeof(oncore_cmd_At1)); /* to 0D mode */
+                       } else
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Av1,  sizeof(oncore_cmd_Av1));
+               }
+       }
+}
+
+
+
+/*
+ * Here we do the Software SiteSurvey.
+ * We have to average our own position for the Position Hold Mode
+ *   We use Heights from the GPS ellipsoid.
+ * We check for the END of either HW or SW SiteSurvey.
+ */
+
+static void
+oncore_ss(
+       struct instance *instance
+       )
+{
+       char    *cp, Msg[160];
+       double  lat, lon, ht;
+
+
+       if (instance->site_survey == ONCORE_SS_HW) {
+               /*
+                * Check to see if Hardware SiteSurvey has Finished.
+                */
+
+               if ((instance->chan == 8  && !(instance->BEHa[37]  & 0x20)) ||
+                   (instance->chan == 12 && !(instance->BEHa[130] & 0x10))) {
+                       record_clock_stats(&(instance->peer->srcadr), "Now in 0D mode");
+
+                       if (instance->chan == 12)
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Gax, sizeof(oncore_cmd_Gax));
+                       else
+                               oncore_sendmsg(instance->ttyfd, oncore_cmd_Asx, sizeof(oncore_cmd_Asx));
+
+                       cp = "SSstate = ONCORE_SS_DONE";
+                       record_clock_stats(&(instance->peer->srcadr), cp);
+                       instance->site_survey = ONCORE_SS_DONE;
+               }
+       } else {
+               /*
+                * Must be a Software Site Survey.
+                */
+
+               if (instance->rsm.bad_fix)      /* Not if poor geometry or less than 3 sats */
+                       return;
+
+               if (instance->mode != MODE_3D)  /* Use only 3D Fixes */
+                       return;
+
+               instance->ss_lat  += buf_w32(&instance->BEHa[15]);
+               instance->ss_long += buf_w32(&instance->BEHa[19]);
+               instance->ss_ht   += buf_w32(&instance->BEHa[23]);  /* GPS ellipsoid */
+               instance->ss_count++;
+
+               if (instance->ss_count != POS_HOLD_AVERAGE)
+                       return;
+
+               instance->ss_lat  /= POS_HOLD_AVERAGE;
+               instance->ss_long /= POS_HOLD_AVERAGE;
+               instance->ss_ht   /= POS_HOLD_AVERAGE;
+
+               sprintf(Msg, "Surveyed posn: lat %.3f (mas) long %.3f (mas) ht %.3f (cm)",
+                       instance->ss_lat, instance->ss_long, instance->ss_ht);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+               lat = instance->ss_lat/3600000.;
+               lon = instance->ss_long/3600000.;
+               ht  = instance->ss_ht/100;
+               sprintf(Msg, "Surveyed posn: lat %.7f (deg) long %.7f (deg) ht %.2f (m)",
+                       lat, lon, ht);
+               record_clock_stats(&(instance->peer->srcadr), Msg);
+
+               oncore_set_posn(instance);
+
+               record_clock_stats(&(instance->peer->srcadr), "Now in 0D mode");
+
+               cp = "SSstate = ONCORE_SS_DONE";
+               record_clock_stats(&(instance->peer->srcadr), cp);
+               instance->site_survey = ONCORE_SS_DONE;
+       }
+}
+
+
+
+static int
+oncore_wait_almanac(
+       struct instance *instance
+       )
+{
+       if (instance->rsm.bad_almanac) {
+#ifdef DEBUG
+               if (debug)
+                       printf("ONCORE[%d]: waiting for almanac\n", instance->unit);
+#endif
+
+               /*
+                * If we get here (first time) then we don't have an almanac in memory.
+                * Check if we have a SHMEM, and if so try to load whatever is there.
+                */
+
+               if (!instance->almanac_from_shmem) {
+                       instance->almanac_from_shmem = 1;
+                       oncore_load_almanac(instance);
+               }
+               return(1);
+       } else {  /* Here we have the Almanac, we will be starting the @@Bn/@@En/@@Hn
+                    commands, and can finally check for TRAIM.  Again, we set a delay
+                    (5sec) and wait for things to settle down */
+
+               if (instance->chan == 6)
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Bn, sizeof(oncore_cmd_Bn));
+               else if (instance->chan == 8)
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_En, sizeof(oncore_cmd_En));
+               else if (instance->chan == 12) {
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Gc, sizeof(oncore_cmd_Gc));  /* 1PPS on, continuous */
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Ge, sizeof(oncore_cmd_Ge));  /* TRAIM on */
+                       oncore_sendmsg(instance->ttyfd, oncore_cmd_Hn, sizeof(oncore_cmd_Hn));  /* TRAIM status 1/s */
+               }
+               instance->traim_delay = 1;
+
+               record_clock_stats(&(instance->peer->srcadr), "Have now loaded an ALMANAC");
+
+               instance->o_state = ONCORE_RUN;
+               record_clock_stats(&(instance->peer->srcadr), "state = ONCORE_RUN");
+       }
+       return(0);
+}
+
+
+
+#else
+int refclock_oncore_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_palisade.c b/ntpd/refclock_palisade.c
new file mode 100644 (file)
index 0000000..adb4659
--- /dev/null
@@ -0,0 +1,955 @@
+/*
+ * This software was developed by the Software and Component Technologies
+ * group of Trimble Navigation, Ltd.
+ *
+ * Copyright (c) 1997, 1998, 1999, 2000  Trimble Navigation Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *    This product includes software developed by Trimble Navigation, Ltd.
+ * 4. The name of Trimble Navigation Ltd. may not be used to endorse or
+ *    promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TRIMBLE NAVIGATION LTD. ``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 TRIMBLE NAVIGATION LTD. 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.
+ */
+
+/*
+ * refclock_palisade - clock driver for the Trimble Palisade GPS
+ * timing receiver
+ *
+ * For detailed information on this program, please refer to the html 
+ * Refclock 29 page accompanying the NTP distribution.
+ *
+ * for questions / bugs / comments, contact:
+ * sven_dietrich@trimble.com
+ *
+ * Sven-Thorsten Dietrich
+ * 645 North Mary Avenue
+ * Post Office Box 3642
+ * Sunnyvale, CA 94088-3642
+ *
+ * Version 2.45; July 14, 1999
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if defined(REFCLOCK) && (defined(PALISADE) || defined(CLOCK_PALISADE))
+
+#ifdef SYS_WINNT
+extern int async_write(int, const void *, unsigned int);
+#undef write
+#define write(fd, data, octets)        async_write(fd, data, octets)
+#endif
+
+#include "refclock_palisade.h"
+/* Table to get from month to day of the year */
+const int days_of_year [12] = {
+       0,  31,  59,  90, 120, 151, 181, 212, 243, 273, 304, 334
+};
+
+#ifdef DEBUG
+const char * Tracking_Status[15][15] = { 
+               { "Doing Fixes\0" }, { "Good 1SV\0" }, { "Approx. 1SV\0" },
+               {"Need Time\0" }, { "Need INIT\0" }, { "PDOP too High\0" },
+               { "Bad 1SV\0" }, { "0SV Usable\0" }, { "1SV Usable\0" },
+               { "2SV Usable\0" }, { "3SV Usable\0" }, { "No Integrity\0" },
+               { "Diff Corr\0" }, { "Overdet Clock\0" }, { "Invalid\0" } };
+#endif
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_palisade = {
+       palisade_start,         /* start up driver */
+       palisade_shutdown,      /* shut down driver */
+       palisade_poll,          /* transmit poll message */
+       noentry,                /* not used  */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used */
+       NOFLAGS                 /* not used */
+};
+
+int day_of_year P((char *dt));
+
+/* Extract the clock type from the mode setting */
+#define CLK_TYPE(x) ((int)(((x)->ttl) & 0x7F))
+
+/* Supported clock types */
+#define CLK_TRIMBLE    0       /* Trimble Palisade */
+#define CLK_PRAECIS    1       /* Endrun Technologies Praecis */
+
+int praecis_msg;
+static void praecis_parse(struct recvbuf *rbufp, struct peer *peer);
+
+/*
+ * palisade_start - open the devices and initialize data for processing
+ */
+static int
+palisade_start (
+#ifdef PALISADE
+       unit, peer
+       )
+       int unit;
+       struct peer *peer;
+#else /* ANSI */
+       int unit,
+       struct peer *peer
+       )
+#endif
+{
+       struct palisade_unit *up;
+       struct refclockproc *pp;
+       int fd;
+       char gpsdev[20];
+
+       struct termios tio;
+#ifdef SYS_WINNT
+       (void) sprintf(gpsdev, "COM%d:", unit);
+#else  
+       (void) sprintf(gpsdev, DEVICE, unit);
+#endif
+       /*
+        * Open serial port. 
+        */
+#if defined PALISADE
+        fd = open(gpsdev, O_RDWR
+#ifdef O_NONBLOCK
+                  | O_NONBLOCK
+#endif
+                  );
+#else /* NTP 4.x */
+       fd = refclock_open(gpsdev, SPEED232, LDISC_RAW);
+#endif
+       if (fd <= 0) {
+#ifdef DEBUG
+               printf("Palisade(%d) start: open %s failed\n", unit, gpsdev);
+#endif
+               return 0;
+       }
+
+       msyslog(LOG_NOTICE, "Palisade(%d) fd: %d dev: %s", unit, fd,
+               gpsdev);
+
+#if defined PALISADE 
+        tio.c_cflag = (CS8|CLOCAL|CREAD|PARENB|PARODD);
+        tio.c_iflag = (IGNBRK);
+        tio.c_oflag = (0);
+        tio.c_lflag = (0);
+
+        if (cfsetispeed(&tio, SPEED232) == -1) {
+                msyslog(LOG_ERR,"Palisade(%d) cfsetispeed(fd, &tio): %m",unit);
+#ifdef DEBUG
+                printf("Palisade(%d) cfsetispeed(fd, &tio)\n",unit);
+#endif
+                return 0;
+        }
+        if (cfsetospeed(&tio, SPEED232) == -1) {
+#ifdef DEBUG
+                printf("Palisade(%d) cfsetospeed(fd, &tio)\n",unit);
+#endif
+                msyslog(LOG_ERR,"Palisade(%d) cfsetospeed(fd, &tio): %m",unit);
+                return 0;
+        }
+#else /* NTP 4.x */
+        if (tcgetattr(fd, &tio) < 0) {
+                msyslog(LOG_ERR, 
+                       "Palisade(%d) tcgetattr(fd, &tio): %m",unit);
+#ifdef DEBUG
+                printf("Palisade(%d) tcgetattr(fd, &tio)\n",unit);
+#endif
+                return (0);
+        }
+
+        tio.c_cflag |= (PARENB|PARODD);
+        tio.c_iflag &= ~ICRNL;
+#endif /*  NTP 4.x */
+
+       if (tcsetattr(fd, TCSANOW, &tio) == -1) {
+                msyslog(LOG_ERR, "Palisade(%d) tcsetattr(fd, &tio): %m",unit);
+#ifdef DEBUG
+                printf("Palisade(%d) tcsetattr(fd, &tio)\n",unit);
+#endif
+                return 0;
+        }
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       up = (struct palisade_unit *) emalloc(sizeof(struct palisade_unit));
+             
+       if (!(up)) {
+                msyslog(LOG_ERR, "Palisade(%d) emalloc: %m",unit);
+#ifdef DEBUG
+                printf("Palisade(%d) emalloc\n",unit);
+#endif
+               (void) close(fd);
+               return (0);
+       }
+
+       memset((char *)up, 0, sizeof(struct palisade_unit));
+
+       up->type = CLK_TYPE(peer);
+       switch (up->type) {
+               case CLK_TRIMBLE:
+                       /* Normal mode, do nothing */
+                       break;
+               case CLK_PRAECIS:
+                       msyslog(LOG_NOTICE, "Palisade(%d) Praecis mode enabled\n",unit);
+                       break;
+               default:
+                       msyslog(LOG_NOTICE, "Palisade(%d) mode unknown\n",unit);
+                       break;
+       }
+
+       pp = peer->procptr;
+       pp->io.clock_recv = palisade_io;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+#ifdef DEBUG
+                printf("Palisade(%d) io_addclock\n",unit);
+#endif
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       pp->unitptr = (caddr_t)up;
+       pp->clockdesc = DESCRIPTION;
+
+       peer->precision = PRECISION;
+       peer->sstclktype = CTL_SST_TS_UHF;
+       peer->minpoll = TRMB_MINPOLL;
+       peer->maxpoll = TRMB_MAXPOLL;
+       memcpy((char *)&pp->refid, REFID, 4);
+       
+       up->leap_status = 0;
+       up->unit = (short) unit;
+       up->rpt_status = TSIP_PARSED_EMPTY;
+       up->rpt_cnt = 0;
+
+       return 1;
+}
+
+
+/*
+ * palisade_shutdown - shut down the clock
+ */
+static void
+palisade_shutdown (
+#ifdef PALISADE
+       unit, peer
+       )
+       int unit;
+       struct peer *peer;
+#else /* ANSI */
+       int unit,
+       struct peer *peer
+       )
+#endif
+{
+       struct palisade_unit *up;
+       struct refclockproc *pp;
+       pp = peer->procptr;
+       up = (struct palisade_unit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+
+/* 
+ * unpack_date - get day and year from date
+ */
+int
+day_of_year (
+#ifdef PALISADE
+       dt
+       )
+       char * dt;
+#else
+       char * dt
+       )
+#endif
+{
+       int day, mon, year;
+
+       mon = dt[1];
+       /* Check month is inside array bounds */
+       if ((mon < 1) || (mon > 12)) 
+               return -1;
+
+       day = dt[0] + days_of_year[mon - 1];
+       year = getint((u_char *) (dt + 2)); 
+
+       if ( !(year % 4) && ((year % 100) || 
+               (!(year % 100) && !(year%400)))
+                       &&(mon > 2))
+                       day ++; /* leap year and March or later */
+
+       return day;
+}
+
+
+/* 
+ * TSIP_decode - decode the TSIP data packets 
+ */
+int
+TSIP_decode (
+#ifdef PALISADE
+       peer
+       )
+       struct peer *peer;
+#else
+       struct peer *peer
+       )
+#endif
+{
+       int st;
+       long   secint;
+       double secs;
+       double secfrac;
+       unsigned short event = 0;
+
+       struct palisade_unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct palisade_unit *)pp->unitptr;
+
+       /*
+        * Check the time packet, decode its contents. 
+        * If the timecode has invalid length or is not in
+        * proper format, declare bad format and exit.
+        */
+
+       if ((up->rpt_buf[0] == (char) 0x41) ||
+               (up->rpt_buf[0] == (char) 0x46) ||
+               (up->rpt_buf[0] == (char) 0x54) ||
+               (up->rpt_buf[0] == (char) 0x4B) ||
+               (up->rpt_buf[0] == (char) 0x6D)) {
+
+       /* standard time packet - GPS time and GPS week number */
+#ifdef DEBUG
+                       printf("Palisade Port B packets detected. Connect to Port A\n");
+#endif
+
+               return 0;       
+       }
+
+       /*
+        * We cast both to u_char to as 0x8f uses the sign bit on a char
+        */
+       if ((u_char) up->rpt_buf[0] == (u_char) 0x8f) {
+       /* 
+        * Superpackets
+        */
+          event = (unsigned short) (getint((u_char *) &mb(1)) & 0xffff);
+          if (!((pp->sloppyclockflag & CLK_FLAG2) || event)) 
+               /* Ignore Packet */
+                       return 0;          
+       
+          switch (mb(0) & 0xff) {
+            int GPS_UTC_Offset;
+            case PACKET_8F0B: 
+
+               if (up->polled <= 0)
+                       return 0;
+
+               if (up->rpt_cnt != LENCODE_8F0B)  /* check length */
+                       break;
+               
+#ifdef DEBUG
+if (debug > 1) {
+               int ts;
+               double lat, lon, alt;
+               lat = getdbl((u_char *) &mb(42)) * R2D;
+               lon = getdbl((u_char *) &mb(50)) * R2D;
+               alt = getdbl((u_char *) &mb(58));
+
+               printf("TSIP_decode: unit %d: Latitude: %03.4f Longitude: %03.4f Alt: %05.2f m\n",
+                               up->unit, lat,lon,alt);
+               printf("TSIP_decode: unit %d: Sats:", up->unit);
+               for (st = 66, ts = 0; st <= 73; st++) if (mb(st)) {
+                       if (mb(st) > 0) ts++;
+                       printf(" %02d", mb(st));
+               }
+               printf(" : Tracking %d\n", ts); 
+       }
+#endif
+
+               GPS_UTC_Offset = getint((u_char *) &mb(16));  
+               if (GPS_UTC_Offset == 0) { /* Check UTC offset */ 
+#ifdef DEBUG
+                        printf("TSIP_decode: UTC Offset Unknown\n");
+#endif
+                       break;
+               }
+
+               secs = getdbl((u_char *) &mb(3));
+               secint = (long) secs;
+               secfrac = secs - secint; /* 0.0 <= secfrac < 1.0 */
+
+               pp->nsec = (long) (secfrac * 1000000000); 
+
+               secint %= 86400;    /* Only care about today */
+               pp->hour = secint / 3600;
+               secint %= 3600;
+               pp->minute = secint / 60;
+               secint %= 60;
+               pp->second = secint % 60;
+               
+               if ((pp->day = day_of_year(&mb(11))) < 0) break;
+
+               pp->year = getint((u_char *) &mb(13)); 
+
+#ifdef DEBUG
+       if (debug > 1)
+               printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%06ld %02d/%02d/%04d UTC %02d\n",
+                       up->unit, mb(0) & 0xff, event, pp->hour, pp->minute, 
+                       pp->second, pp->nsec, mb(12), mb(11), pp->year, GPS_UTC_Offset);
+#endif
+               /* Only use this packet when no
+                * 8F-AD's are being received
+                */
+
+               if (up->leap_status) {
+                       up->leap_status = 0;
+                       return 0;
+               }
+
+               return 2;
+               break;
+
+         case PACKET_NTP:
+               /* Palisade-NTP Packet */
+
+               if (up->rpt_cnt != LENCODE_NTP) /* check length */
+                       break;
+       
+               up->leap_status = mb(19);
+
+               if (up->polled  <= 0) 
+                       return 0;
+                               
+               /* Check Tracking Status */
+               st = mb(18);
+               if (st < 0 || st > 14) st = 14;
+               if ((st >= 2 && st <= 7) || st == 11 || st == 12) {
+#ifdef DEBUG
+                printf("TSIP_decode: Not Tracking Sats : %s\n",
+                               *Tracking_Status[st]);
+#endif
+                       refclock_report(peer, CEVNT_BADTIME);
+                       up->polled = -1;
+                       return 0;
+                       break;
+               }
+
+               if (up->leap_status & PALISADE_LEAP_PENDING) {
+                       if (up->leap_status & PALISADE_UTC_TIME)  
+                               pp->leap = LEAP_ADDSECOND;
+                       else
+                               pp->leap = LEAP_DELSECOND;
+               }
+               else if (up->leap_status)
+                       pp->leap = LEAP_NOWARNING;
+               
+               else {  /* UTC flag is not set:
+                        * Receiver may have been reset, and lost
+                        * its UTC almanac data */
+                       pp->leap = LEAP_NOTINSYNC;
+#ifdef DEBUG
+                        printf("TSIP_decode: UTC Almanac unavailable: %d\n",
+                               mb(19));        
+#endif
+                       refclock_report(peer, CEVNT_BADTIME);
+                       up->polled = -1;
+                       return 0;
+               }
+
+               pp->nsec = (long) (getdbl((u_char *) &mb(3)) * 1000000000);
+
+               if ((pp->day = day_of_year(&mb(14))) < 0) 
+                       break;
+               pp->year = getint((u_char *) &mb(16)); 
+               pp->hour = mb(11);
+               pp->minute = mb(12);
+               pp->second = mb(13);
+
+#ifdef DEBUG
+       if (debug > 1)
+printf("TSIP_decode: unit %d: %02X #%d %02d:%02d:%02d.%06ld %02d/%02d/%04d UTC %02x %s\n",
+                       up->unit, mb(0) & 0xff, event, pp->hour, pp->minute, 
+                       pp->second, pp->nsec, mb(15), mb(14), pp->year,
+                       mb(19), *Tracking_Status[st]);
+#endif
+               return 1;
+               break;
+
+         default:      
+               /* Ignore Packet */
+               return 0;
+         } /* switch */
+       }/* if 8F packets */    
+
+       refclock_report(peer, CEVNT_BADREPLY);
+       up->polled = -1;
+#ifdef DEBUG
+       printf("TSIP_decode: unit %d: bad packet %02x-%02x event %d len %d\n", 
+                  up->unit, up->rpt_buf[0] & 0xff, mb(0) & 0xff, 
+                       event, up->rpt_cnt);
+#endif
+       return 0;
+}
+
+/*
+ * palisade__receive - receive data from the serial interface
+ */
+
+static void
+palisade_receive (
+#ifdef PALISADE
+       peer
+       )
+       struct peer * peer;
+#else /* ANSI */
+       struct peer * peer
+       )
+#endif
+{
+       struct palisade_unit *up;
+       struct refclockproc *pp;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp.
+        */
+       pp = peer->procptr;
+       up = (struct palisade_unit *)pp->unitptr;
+               
+       if (! TSIP_decode(peer)) return;
+       
+       if (up->polled <= 0) 
+           return;   /* no poll pending, already received or timeout */
+
+       up->polled = 0;  /* Poll reply received */
+       pp->lencode = 0; /* clear time code */
+#ifdef DEBUG
+       if (debug) 
+               printf(
+       "palisade_receive: unit %d: %4d %03d %02d:%02d:%02d.%06ld\n",
+                       up->unit, pp->year, pp->day, pp->hour, pp->minute, 
+                       pp->second, pp->nsec);
+#endif
+
+       /*
+        * Process the sample
+        * Generate timecode: YYYY DoY HH:MM:SS.microsec 
+        * report and process 
+        */
+
+       (void) sprintf(pp->a_lastcode,"%4d %03d %02d:%02d:%02d.%06ld",
+                  pp->year,pp->day,pp->hour,pp->minute, pp->second,pp->nsec); 
+       pp->lencode = 24;
+
+#ifdef PALISADE
+       pp->lasttime = current_time;
+#endif
+       if (!refclock_process(pp
+#ifdef PALISADE
+               , PALISADE_SAMPLES, PALISADE_SAMPLES * 3 / 5
+#endif
+               )) {
+               refclock_report(peer, CEVNT_BADTIME);
+
+#ifdef DEBUG
+               printf("palisade_receive: unit %d: refclock_process failed!\n",
+                       up->unit);
+#endif
+               return;
+       }
+
+       record_clock_stats(&peer->srcadr, pp->a_lastcode); 
+
+#ifdef DEBUG
+       if (debug)
+           printf("palisade_receive: unit %d: %s\n",
+                  up->unit, prettydate(&pp->lastrec));
+#endif
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer
+#ifdef PALISADE
+               , &pp->offset, 0, pp->dispersion,
+              &pp->lastrec, &pp->lastrec, pp->leap             
+#endif         
+               );
+}
+
+
+/*
+ * palisade_poll - called by the transmit procedure
+ *
+ */
+static void
+palisade_poll (
+#ifdef PALISADE
+       unit, peer
+       )
+       int unit;
+       struct peer *peer;
+#else
+       int unit,
+       struct peer *peer
+       )
+#endif
+{
+       struct palisade_unit *up;
+       struct refclockproc *pp;
+       
+       pp = peer->procptr;
+       up = (struct palisade_unit *)pp->unitptr;
+
+       pp->polls++;
+       if (up->polled > 0) /* last reply never arrived or error */ 
+           refclock_report(peer, CEVNT_TIMEOUT);
+
+       up->polled = 2; /* synchronous packet + 1 event */
+       
+#ifdef DEBUG
+       if (debug)
+           printf("palisade_poll: unit %d: polling %s\n", unit,
+                  (pp->sloppyclockflag & CLK_FLAG2) ? 
+                       "synchronous packet" : "event");
+#endif 
+
+       if (pp->sloppyclockflag & CLK_FLAG2) 
+           return;  /* using synchronous packet input */
+
+       if(up->type == CLK_PRAECIS) {
+               if(write(peer->procptr->io.fd,"SPSTAT\r\n",8) < 0)
+                       msyslog(LOG_ERR, "Palisade(%d) write: %m:",unit);
+               else {
+                       praecis_msg = 1;
+                       return;
+               }
+       }
+
+       if (HW_poll(pp) < 0) 
+           refclock_report(peer, CEVNT_FAULT); 
+}
+
+static void
+praecis_parse(struct recvbuf *rbufp, struct peer *peer)
+{
+       static char buf[100];
+       static int p = 0;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+
+       memcpy(buf+p,rbufp->recv_space.X_recv_buffer, rbufp->recv_length);
+       p += rbufp->recv_length;
+
+       if(buf[p-2] == '\r' && buf[p-1] == '\n') {
+               buf[p-2] = '\0';
+               record_clock_stats(&peer->srcadr, buf);
+
+               p = 0;
+               praecis_msg = 0;
+
+               if (HW_poll(pp) < 0)
+                       refclock_report(peer, CEVNT_FAULT);
+
+       }
+}
+
+static void
+palisade_io (
+#ifdef PALISADE
+       rbufp
+       )
+       struct recvbuf *rbufp;
+#else /* ANSI */
+       struct recvbuf *rbufp
+       )
+#endif
+{
+       /*
+        * Initialize pointers and read the timecode and timestamp.
+        */
+       struct palisade_unit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+
+       char * c, * d;
+
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct palisade_unit *)pp->unitptr;
+
+       if(up->type == CLK_PRAECIS) {
+               if(praecis_msg) {
+                       praecis_parse(rbufp,peer);
+                       return;
+               }
+       }
+
+       c = (char *) &rbufp->recv_space;
+       d = c + rbufp->recv_length;
+               
+       while (c != d) {
+
+               /* Build time packet */
+               switch (up->rpt_status) {
+
+                   case TSIP_PARSED_DLE_1:
+                       switch (*c)
+                       {
+                           case 0:
+                           case DLE:
+                           case ETX:
+                               up->rpt_status = TSIP_PARSED_EMPTY;
+                               break;
+
+                           default:
+                               up->rpt_status = TSIP_PARSED_DATA;
+                               /* save packet ID */
+                               up->rpt_buf[0] = *c;
+                               break;
+                       }
+                       break;
+
+                   case TSIP_PARSED_DATA:
+                       if (*c == DLE)
+                           up->rpt_status = TSIP_PARSED_DLE_2;
+                       else 
+                           mb(up->rpt_cnt++) = *c;
+                       break;
+
+                   case TSIP_PARSED_DLE_2:
+                       if (*c == DLE) {
+                               up->rpt_status = TSIP_PARSED_DATA;
+                               mb(up->rpt_cnt++) = 
+                                               *c;
+                       }       
+                       else if (*c == ETX) 
+                                   up->rpt_status = TSIP_PARSED_FULL;
+                       else    {
+                               /* error: start new report packet */
+                               up->rpt_status = TSIP_PARSED_DLE_1;
+                               up->rpt_buf[0] = *c;
+                       }
+                       break;
+
+                   case TSIP_PARSED_FULL:
+                   case TSIP_PARSED_EMPTY:
+                   default:
+                       if ( *c != DLE)
+                          up->rpt_status = TSIP_PARSED_EMPTY;
+                else 
+                          up->rpt_status = TSIP_PARSED_DLE_1;
+                        break;
+               }
+               
+               c++;
+
+               if (up->rpt_status == TSIP_PARSED_DLE_1) {
+                   up->rpt_cnt = 0;
+                       if (pp->sloppyclockflag & CLK_FLAG2) 
+                               /* stamp it */
+                               get_systime(&pp->lastrec);
+               }
+               else if (up->rpt_status == TSIP_PARSED_EMPTY)
+                       up->rpt_cnt = 0;
+
+               else if (up->rpt_cnt > BMAX) 
+                       up->rpt_status =TSIP_PARSED_EMPTY;
+
+               if (up->rpt_status == TSIP_PARSED_FULL) 
+                       palisade_receive(peer);
+
+       } /* while chars in buffer */
+}
+
+
+/*
+ * Trigger the Palisade's event input, which is driven off the RTS
+ *
+ * Take a system time stamp to match the GPS time stamp.
+ *
+ */
+long
+HW_poll (
+#ifdef PALISADE
+       pp      /* pointer to unit structure */
+       )
+       struct refclockproc * pp;       /* pointer to unit structure */
+#else
+       struct refclockproc * pp        /* pointer to unit structure */
+       )
+#endif
+{      
+       int x;  /* state before & after RTS set */
+       struct palisade_unit *up;
+
+       up = (struct palisade_unit *) pp->unitptr;
+
+       /* read the current status, so we put things back right */
+       if (ioctl(pp->io.fd, TIOCMGET, &x) < 0) {
+#ifdef DEBUG
+       if (debug)
+           printf("Palisade HW_poll: unit %d: GET %s\n", up->unit, strerror(errno));
+#endif
+               msyslog(LOG_ERR, "Palisade(%d) HW_poll: ioctl(fd,GET): %m", 
+                       up->unit);
+               return -1;
+       }
+  
+       x |= TIOCM_RTS;        /* turn on RTS  */
+
+       /* Edge trigger */
+       if (ioctl(pp->io.fd, TIOCMSET, &x) < 0) { 
+#ifdef DEBUG
+       if (debug)
+           printf("Palisade HW_poll: unit %d: SET \n", up->unit);
+#endif
+               msyslog(LOG_ERR,
+                       "Palisade(%d) HW_poll: ioctl(fd, SET, RTS_on): %m", 
+                       up->unit);
+               return -1;
+       }
+
+       x &= ~TIOCM_RTS;        /* turn off RTS  */
+       
+       /* poll timestamp */
+       get_systime(&pp->lastrec);
+
+       if (ioctl(pp->io.fd, TIOCMSET, &x) == -1) {
+#ifdef DEBUG
+       if (debug)
+           printf("Palisade HW_poll: unit %d: UNSET \n", up->unit);
+#endif
+               msyslog(LOG_ERR,
+                       "Palisade(%d) HW_poll: ioctl(fd, UNSET, RTS_off): %m", 
+                       up->unit);
+               return -1;
+       }
+
+       return 0;
+}
+
+#if 0 /* unused */
+/*
+ * this 'casts' a character array into a float
+ */
+float
+getfloat (
+#ifdef PALISADE
+       bp
+       )
+       u_char *bp;
+#else
+       u_char *bp
+       )
+#endif
+{
+       float sval;
+#ifdef WORDS_BIGENDIAN 
+       ((char *) &sval)[0] = *bp++;
+       ((char *) &sval)[1] = *bp++;
+       ((char *) &sval)[2] = *bp++;
+       ((char *) &sval)[3] = *bp++;
+#else
+       ((char *) &sval)[3] = *bp++;
+       ((char *) &sval)[2] = *bp++;
+       ((char *) &sval)[1] = *bp++;
+       ((char *) &sval)[0] = *bp;
+#endif  /* ! XNTP_BIG_ENDIAN */ 
+       return sval;
+}
+#endif
+
+/*
+ * this 'casts' a character array into a double
+ */
+double
+getdbl (
+#ifdef PALISADE
+       bp
+       )
+       u_char *bp;
+#else
+       u_char *bp
+       )
+#endif
+{
+       double dval;
+#ifdef WORDS_BIGENDIAN 
+       ((char *) &dval)[0] = *bp++;
+       ((char *) &dval)[1] = *bp++;
+       ((char *) &dval)[2] = *bp++;
+       ((char *) &dval)[3] = *bp++;
+       ((char *) &dval)[4] = *bp++;
+       ((char *) &dval)[5] = *bp++;
+       ((char *) &dval)[6] = *bp++;
+       ((char *) &dval)[7] = *bp;
+#else
+       ((char *) &dval)[7] = *bp++;
+       ((char *) &dval)[6] = *bp++;
+       ((char *) &dval)[5] = *bp++;
+       ((char *) &dval)[4] = *bp++;
+       ((char *) &dval)[3] = *bp++;
+       ((char *) &dval)[2] = *bp++;
+       ((char *) &dval)[1] = *bp++;
+       ((char *) &dval)[0] = *bp;
+#endif  /* ! XNTP_BIG_ENDIAN */ 
+       return dval;
+}
+
+/*
+ * cast a 16 bit character array into a short (16 bit) int
+ */
+short
+getint (
+#ifdef PALISADE
+       bp
+       )
+       u_char *bp;
+#else
+       u_char *bp
+       )
+#endif
+{
+return (short) (bp[1] + (bp[0] << 8));
+}
+
+#else
+int refclock_palisade_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_palisade.h b/ntpd/refclock_palisade.h
new file mode 100644 (file)
index 0000000..e63f3da
--- /dev/null
@@ -0,0 +1,170 @@
+/*
+ * This software was developed by the Software and Component Technologies
+ * group of Trimble Navigation, Ltd.
+ *
+ * Copyright (c) 1997, 1998, 1999, 2000   Trimble Navigation Ltd.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *    This product includes software developed by Trimble Navigation, Ltd.
+ * 4. The name of Trimble Navigation Ltd. may not be used to endorse or
+ *    promote products derived from this software without specific prior
+ *    written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY TRIMBLE NAVIGATION LTD. ``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 TRIMBLE NAVIGATION LTD. 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.
+ */
+
+/*
+ * refclock_palisade - clock driver for the Trimble Palisade GPS
+ * timing receiver
+ *
+ * For detailed information on this program, please refer to the html 
+ * Refclock 29 page accompanying the NTP distribution.
+ *
+ * for questions / bugs / comments, contact:
+ * sven_dietrich@trimble.com
+ *
+ * Sven-Thorsten Dietrich
+ * 645 North Mary Avenue
+ * Post Office Box 3642
+ * Sunnyvale, CA 94088-3642
+ *
+ */
+
+#ifndef _REFCLOCK_PALISADE_H
+#define _REFCLOCK_PALISADE_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if defined HAVE_SYS_MODEM_H
+#include <sys/modem.h>
+#ifndef __QNXNTO__
+#define TIOCMSET MCSETA
+#define TIOCMGET MCGETA
+#define TIOCM_RTS MRTS
+#endif
+#endif
+
+#ifdef HAVE_TERMIOS_H
+# ifdef TERMIOS_NEEDS__SVID3
+#  define _SVID3
+# endif
+# include <termios.h>
+# ifdef TERMIOS_NEEDS__SVID3
+#  undef _SVID3
+# endif
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_control.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+/*
+ * GPS Definitions
+ */
+#define        DESCRIPTION     "Trimble Palisade GPS" /* Long name */
+#define        PRECISION       (-20)   /* precision assumed (about 1 us) */
+#define        REFID           "GPS\0" /* reference ID */
+#define TRMB_MINPOLL    4      /* 16 seconds */
+#define TRMB_MAXPOLL   5       /* 32 seconds */
+
+/*
+ * I/O Definitions
+ */
+#define        DEVICE          "/dev/palisade%d"       /* device name and unit */
+#define        SPEED232        B9600                   /* uart speed (9600 baud) */
+
+/*
+ * TSIP Report Definitions
+ */
+#define LENCODE_8F0B   74      /* Length of TSIP 8F-0B Packet & header */
+#define LENCODE_NTP     22     /* Length of Palisade NTP Packet */
+
+/* Allowed Sub-Packet ID's */
+#define PACKET_8F0B    0x0B
+#define PACKET_NTP     0xAD
+
+#define DLE 0x10
+#define ETX 0x03
+
+/* parse states */
+#define TSIP_PARSED_EMPTY       0      
+#define TSIP_PARSED_FULL        1
+#define TSIP_PARSED_DLE_1       2
+#define TSIP_PARSED_DATA        3
+#define TSIP_PARSED_DLE_2       4
+
+/* 
+ * Leap-Insert and Leap-Delete are encoded as follows:
+ *     PALISADE_UTC_TIME set   and PALISADE_LEAP_PENDING set: INSERT leap
+ */
+
+#define PALISADE_LEAP_INPROGRESS 0x08 /* This is the leap flag                 */
+#define PALISADE_LEAP_WARNING    0x04 /* GPS Leap Warning (see ICD-200) */
+#define PALISADE_LEAP_PENDING    0x02 /* Leap Pending (24 hours)               */
+#define PALISADE_UTC_TIME        0x01 /* UTC time available                            */
+
+#define mb(_X_) (up->rpt_buf[(_X_ + 1)]) /* shortcut for buffer access */
+
+/* Conversion Definitions */
+#define GPS_PI                 (3.1415926535898)
+#define        R2D             (180.0/GPS_PI)
+
+/*
+ * Palisade unit control structure.
+ */
+struct palisade_unit {
+       short           unit;           /* NTP refclock unit number */
+       int             polled;         /* flag to detect noreplies */
+       char            leap_status;    /* leap second flag */
+       char            rpt_status;     /* TSIP Parser State */
+       short           rpt_cnt;        /* TSIP packet length so far */
+       char            rpt_buf[BMAX];   /* packet assembly buffer */
+       int             type;           /* Clock mode type */
+};
+
+/*
+ * Function prototypes
+ */
+
+static int     palisade_start          P((int, struct peer *));
+static void    palisade_shutdown       P((int, struct peer *));
+static void    palisade_receive        P((struct peer *));
+static void    palisade_poll           P((int, struct peer *));
+static  void   palisade_io             P((struct recvbuf *));
+int            palisade_configure      P((int, struct peer *));
+int            TSIP_decode             P((struct peer *));
+long           HW_poll                 P((struct refclockproc *));
+float          getfloat                P((u_char *)); 
+double                 getdbl                  P((u_char *));
+short                  getint                  P((u_char *));
+
+#endif /* PALISADE_H */
diff --git a/ntpd/refclock_parse.c b/ntpd/refclock_parse.c
new file mode 100644 (file)
index 0000000..0b0109c
--- /dev/null
@@ -0,0 +1,6045 @@
+/*
+ * /src/NTP/REPOSITORY/ntp4-dev/ntpd/refclock_parse.c,v 4.80 2007/08/11 12:06:29 kardel Exp
+ *
+ * refclock_parse.c,v 4.80 2007/08/11 12:06:29 kardel Exp
+ *
+ * generic reference clock driver for several DCF/GPS/MSF/... receivers
+ *
+ * PPS notes:
+ *   On systems that support PPSAPI (RFC2783) PPSAPI is the
+ *   preferred interface.
+ *
+ *   Optionally make use of a STREAMS module for input processing where
+ *   available and configured. This STREAMS module reduces the time
+ *   stamp latency for serial and PPS events.
+ *   Currently the STREAMS module is only available for Suns running
+ *   SunOS 4.x and SunOS5.x.
+ *
+ * Copyright (c) 1995-2007 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include "config.h"
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PARSE)
+
+/*
+ * This driver currently provides the support for
+ *   - Meinberg receiver DCF77 PZF 535 (TCXO version)       (DCF)
+ *   - Meinberg receiver DCF77 PZF 535 (OCXO version)       (DCF)
+ *   - Meinberg receiver DCF77 PZF 509                      (DCF)
+ *   - Meinberg receiver DCF77 AM receivers (e.g. C51)      (DCF)
+ *   - IGEL CLOCK                                           (DCF)
+ *   - ELV DCF7000                                          (DCF)
+ *   - Schmid clock                                         (DCF)
+ *   - Conrad DCF77 receiver module                         (DCF)
+ *   - FAU DCF77 NTP receiver (TimeBrick)                   (DCF)
+ *   - WHARTON 400A Series clock                           (DCF)
+ *
+ *   - Meinberg GPS166/GPS167                               (GPS)
+ *   - Trimble (TSIP and TAIP protocol)                     (GPS)
+ *
+ *   - RCC8000 MSF Receiver                                 (MSF)
+ *   - VARITEXT clock                                      (MSF)
+ */
+
+/*
+ * Meinberg receivers are usually connected via a
+ * 9600 baud serial line
+ *
+ * The Meinberg GPS receivers also have a special NTP time stamp
+ * format. The firmware release is Uni-Erlangen.
+ *
+ * Meinberg generic receiver setup:
+ *     output time code every second
+ *     Baud rate 9600 7E2S
+ *
+ * Meinberg GPS16x setup:
+ *      output time code every second
+ *      Baudrate 19200 8N1
+ *
+ * This software supports the standard data formats used
+ * in Meinberg receivers.
+ *
+ * Special software versions are only sensible for the
+ * GPS 16x family of receivers.
+ *
+ * Meinberg can be reached via: http://www.meinberg.de/
+ */
+
+#include "ntpd.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"      /* includes <sys/time.h> */
+#include "ntp_control.h"
+#include "ntp_string.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#ifndef TM_IN_SYS_TIME
+# include <time.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#if !defined(STREAM) && !defined(HAVE_SYSV_TTYS) && !defined(HAVE_BSD_TTYS) && !defined(HAVE_TERMIOS)
+# include "Bletch:  Define one of {STREAM,HAVE_SYSV_TTYS,HAVE_TERMIOS}"
+#endif
+
+#ifdef STREAM
+# include <sys/stream.h>
+# include <sys/stropts.h>
+#endif
+
+#ifdef HAVE_TERMIOS
+# define TTY_GETATTR(_FD_, _ARG_) tcgetattr((_FD_), (_ARG_))
+# define TTY_SETATTR(_FD_, _ARG_) tcsetattr((_FD_), TCSANOW, (_ARG_))
+# undef HAVE_SYSV_TTYS
+#endif
+
+#ifdef HAVE_SYSV_TTYS
+# define TTY_GETATTR(_FD_, _ARG_) ioctl((_FD_), TCGETA, (_ARG_))
+# define TTY_SETATTR(_FD_, _ARG_) ioctl((_FD_), TCSETAW, (_ARG_))
+#endif
+
+#ifdef HAVE_BSD_TTYS
+/* #error CURRENTLY NO BSD TTY SUPPORT */
+# include "Bletch: BSD TTY not currently supported"
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif
+
+#ifdef HAVE_PPSAPI
+# include "ppsapi_timepps.h"
+#endif
+
+#ifdef PPS
+# ifdef HAVE_SYS_PPSCLOCK_H
+#  include <sys/ppsclock.h>
+# endif
+# ifdef HAVE_TIO_SERIAL_STUFF
+#  include <linux/serial.h>
+# endif
+#endif
+
+#define BUFFER_SIZE(_BUF, _PTR) ((_BUF) + sizeof(_BUF) - (_PTR))
+#define BUFFER_SIZES(_BUF, _PTR, _SZ) ((_BUF) + (_SZ) - (_PTR))
+
+/*
+ * document type of PPS interfacing - copy of ifdef mechanism in local_input()
+ */
+#undef PPS_METHOD 
+
+#ifdef HAVE_PPSAPI
+#define PPS_METHOD "PPS API"
+#else
+#ifdef TIOCDCDTIMESTAMP
+#define PPS_METHOD "TIOCDCDTIMESTAMP"
+#else /* TIOCDCDTIMESTAMP */
+#if defined(HAVE_STRUCT_PPSCLOCKEV) && (defined(HAVE_CIOGETEV) || defined(HAVE_TIOCGPPSEV))
+#ifdef HAVE_CIOGETEV
+#define PPS_METHOD "CIOGETEV"
+#endif
+#ifdef HAVE_TIOCGPPSEV
+#define PPS_METHOD "TIOCGPPSEV"
+#endif
+#endif
+#endif /* TIOCDCDTIMESTAMP */
+#endif /* HAVE_PPSAPI */
+
+#include "ntp_io.h"
+#include "ntp_stdlib.h"
+
+#include "parse.h"
+#include "mbg_gps166.h"
+#include "trimble.h"
+#include "binio.h"
+#include "ascii.h"
+#include "ieee754io.h"
+#include "recvbuff.h"
+
+static char rcsid[] = "refclock_parse.c,v 4.80 2007/08/11 12:06:29 kardel Exp";
+
+/**===========================================================================
+ ** external interface to ntp mechanism
+ **/
+
+static int     parse_start     P((int, struct peer *));
+static void    parse_shutdown  P((int, struct peer *));
+static void    parse_poll      P((int, struct peer *));
+static void    parse_control   P((int, struct refclockstat *, struct refclockstat *, struct peer *));
+
+struct refclock refclock_parse = {
+       parse_start,
+       parse_shutdown,
+       parse_poll,
+       parse_control,
+       noentry,
+       noentry,
+       NOFLAGS
+};
+
+/*
+ * Definitions
+ */
+#define        MAXUNITS        4       /* maximum number of "PARSE" units permitted */
+#define PARSEDEVICE    "/dev/refclock-%d" /* device to open %d is unit number */
+#define PARSEPPSDEVICE "/dev/refclockpps-%d" /* optional pps device to open %d is unit number */
+
+#undef ABS
+#define ABS(_X_) (((_X_) < 0) ? -(_X_) : (_X_))
+
+#define PARSE_HARDPPS_DISABLE 0
+#define PARSE_HARDPPS_ENABLE  1
+
+/**===========================================================================
+ ** function vector for dynamically binding io handling mechanism
+ **/
+
+struct parseunit;              /* to keep inquiring minds happy */
+
+typedef struct bind
+{
+  const char *bd_description;                                  /* name of type of binding */
+  int  (*bd_init)     P((struct parseunit *));                 /* initialize */
+  void (*bd_end)      P((struct parseunit *));                 /* end */
+  int   (*bd_setcs)    P((struct parseunit *, parsectl_t *));  /* set character size */
+  int  (*bd_disable)  P((struct parseunit *));                 /* disable */
+  int  (*bd_enable)   P((struct parseunit *));                 /* enable */
+  int  (*bd_getfmt)   P((struct parseunit *, parsectl_t *));   /* get format */
+  int  (*bd_setfmt)   P((struct parseunit *, parsectl_t *));   /* setfmt */
+  int  (*bd_timecode) P((struct parseunit *, parsectl_t *));   /* get time code */
+  void (*bd_receive)  P((struct recvbuf *));                   /* receive operation */
+  int  (*bd_io_input) P((struct recvbuf *));                   /* input operation */
+} bind_t;
+
+#define PARSE_END(_X_)                 (*(_X_)->binding->bd_end)(_X_)
+#define PARSE_SETCS(_X_, _CS_)         (*(_X_)->binding->bd_setcs)(_X_, _CS_)
+#define PARSE_ENABLE(_X_)              (*(_X_)->binding->bd_enable)(_X_)
+#define PARSE_DISABLE(_X_)             (*(_X_)->binding->bd_disable)(_X_)
+#define PARSE_GETFMT(_X_, _DCT_)       (*(_X_)->binding->bd_getfmt)(_X_, _DCT_)
+#define PARSE_SETFMT(_X_, _DCT_)       (*(_X_)->binding->bd_setfmt)(_X_, _DCT_)
+#define PARSE_GETTIMECODE(_X_, _DCT_)  (*(_X_)->binding->bd_timecode)(_X_, _DCT_)
+
+/*
+ * io modes
+ */
+#define PARSE_F_PPSPPS         0x0001 /* use loopfilter PPS code (CIOGETEV) */
+#define PARSE_F_PPSONSECOND    0x0002 /* PPS pulses are on second */
+
+
+/**===========================================================================
+ ** error message regression handling
+ **
+ ** there are quite a few errors that can occur in rapid succession such as
+ ** noisy input data or no data at all. in order to reduce the amount of
+ ** syslog messages in such case, we are using a backoff algorithm. We limit
+ ** the number of error messages of a certain class to 1 per time unit. if a
+ ** configurable number of messages is displayed that way, we move on to the
+ ** next time unit / count for that class. a count of messages that have been
+ ** suppressed is held and displayed whenever a corresponding message is
+ ** displayed. the time units for a message class will also be displayed.
+ ** whenever an error condition clears we reset the error message state,
+ ** thus we would still generate much output on pathological conditions
+ ** where the system oscillates between OK and NOT OK states. coping
+ ** with that condition is currently considered too complicated.
+ **/
+
+#define ERR_ALL                (unsigned)~0    /* "all" errors */
+#define ERR_BADDATA    (unsigned)0     /* unusable input data/conversion errors */
+#define ERR_NODATA     (unsigned)1     /* no input data */
+#define ERR_BADIO      (unsigned)2     /* read/write/select errors */
+#define ERR_BADSTATUS  (unsigned)3     /* unsync states */
+#define ERR_BADEVENT   (unsigned)4     /* non nominal events */
+#define ERR_INTERNAL   (unsigned)5     /* internal error */
+#define ERR_CNT                (unsigned)(ERR_INTERNAL+1)
+
+#define ERR(_X_)       if (list_err(parse, (_X_)))
+
+struct errorregression
+{
+       u_long err_count;       /* number of repititions per class */
+       u_long err_delay;       /* minimum delay between messages */
+};
+
+static struct errorregression
+err_baddata[] =                        /* error messages for bad input data */
+{
+       { 1,       0 },         /* output first message immediately */
+       { 5,      60 },         /* output next five messages in 60 second intervals */
+       { 3,    3600 },         /* output next 3 messages in hour intervals */
+       { 0, 12*3600 }          /* repeat messages only every 12 hours */
+};
+
+static struct errorregression
+err_nodata[] =                 /* error messages for missing input data */
+{
+       { 1,       0 },         /* output first message immediately */
+       { 5,      60 },         /* output next five messages in 60 second intervals */
+       { 3,    3600 },         /* output next 3 messages in hour intervals */
+       { 0, 12*3600 }          /* repeat messages only every 12 hours */
+};
+
+static struct errorregression
+err_badstatus[] =              /* unsynchronized state messages */
+{
+       { 1,       0 },         /* output first message immediately */
+       { 5,      60 },         /* output next five messages in 60 second intervals */
+       { 3,    3600 },         /* output next 3 messages in hour intervals */
+       { 0, 12*3600 }          /* repeat messages only every 12 hours */
+};
+
+static struct errorregression
+err_badio[] =                  /* io failures (bad reads, selects, ...) */
+{
+       { 1,       0 },         /* output first message immediately */
+       { 5,      60 },         /* output next five messages in 60 second intervals */
+       { 5,    3600 },         /* output next 3 messages in hour intervals */
+       { 0, 12*3600 }          /* repeat messages only every 12 hours */
+};
+
+static struct errorregression
+err_badevent[] =               /* non nominal events */
+{
+       { 20,      0 },         /* output first message immediately */
+       { 6,      60 },         /* output next five messages in 60 second intervals */
+       { 5,    3600 },         /* output next 3 messages in hour intervals */
+       { 0, 12*3600 }          /* repeat messages only every 12 hours */
+};
+
+static struct errorregression
+err_internal[] =               /* really bad things - basically coding/OS errors */
+{
+       { 0,       0 },         /* output all messages immediately */
+};
+
+static struct errorregression *
+err_tbl[] =
+{
+       err_baddata,
+       err_nodata,
+       err_badio,
+       err_badstatus,
+       err_badevent,
+       err_internal
+};
+
+struct errorinfo
+{
+       u_long err_started;     /* begin time (ntp) of error condition */
+       u_long err_last;        /* last time (ntp) error occurred */
+       u_long err_cnt; /* number of error repititions */
+       u_long err_suppressed;  /* number of suppressed messages */
+       struct errorregression *err_stage; /* current error stage */
+};
+
+/**===========================================================================
+ ** refclock instance data
+ **/
+
+struct parseunit
+{
+       /*
+        * NTP management
+        */
+       struct peer         *peer;              /* backlink to peer structure - refclock inactive if 0  */
+       struct refclockproc *generic;           /* backlink to refclockproc structure */
+
+       /*
+        * PARSE io
+        */
+       bind_t       *binding;          /* io handling binding */
+       
+       /*
+        * parse state
+        */
+       parse_t       parseio;          /* io handling structure (user level parsing) */
+
+       /*
+        * type specific parameters
+        */
+       struct parse_clockinfo   *parse_type;           /* link to clock description */
+
+       /*
+        * clock state handling/reporting
+        */
+       u_char        flags;            /* flags (leap_control) */
+       u_long        lastchange;       /* time (ntp) when last state change accured */
+       u_long        statetime[CEVNT_MAX+1]; /* accumulated time of clock states */
+       u_long        pollneeddata;     /* current_time(!=0) for receive sample expected in PPS mode */
+       u_short       lastformat;       /* last format used */
+       u_long        lastsync;         /* time (ntp) when clock was last seen fully synchronized */
+        u_long        maxunsync;        /* max time in seconds a receiver is trusted after loosing synchronisation */
+        double        ppsphaseadjust;   /* phase adjustment of PPS time stamp */
+        u_long        lastmissed;       /* time (ntp) when poll didn't get data (powerup heuristic) */
+       u_long        ppsserial;        /* magic cookie for ppsclock serials (avoids stale ppsclock data) */
+       int           ppsfd;            /* fd to ise for PPS io */
+#ifdef HAVE_PPSAPI
+        pps_handle_t  ppshandle;        /* store PPSAPI handle */
+        pps_params_t  ppsparams;        /* current PPS parameters */
+        int           hardppsstate;     /* current hard pps state */
+#endif
+       parsetime_t   timedata;         /* last (parse module) data */
+       void         *localdata;        /* optional local, receiver-specific data */
+        unsigned long localstate;       /* private local state */
+       struct errorinfo errors[ERR_CNT];  /* error state table for suppressing excessive error messages */
+       struct ctl_var *kv;             /* additional pseudo variables */
+       u_long        laststatistic;    /* time when staticstics where output */
+};
+
+
+/**===========================================================================
+ ** Clockinfo section all parameter for specific clock types
+ ** includes NTP parameters, TTY parameters and IO handling parameters
+ **/
+
+static void    poll_dpoll      P((struct parseunit *));
+static void    poll_poll       P((struct peer *));
+static int     poll_init       P((struct parseunit *));
+
+typedef struct poll_info
+{
+       u_long      rate;               /* poll rate - once every "rate" seconds - 0 off */
+       const char *string;             /* string to send for polling */
+       u_long      count;              /* number of characters in string */
+} poll_info_t;
+
+#define NO_CL_FLAGS    0
+#define NO_POLL                0
+#define NO_INIT                0
+#define NO_END         0
+#define NO_EVENT       0
+#define NO_LCLDATA     0
+#define NO_MESSAGE     0
+#define NO_PPSDELAY     0
+
+#define DCF_ID         "DCF"   /* generic DCF */
+#define DCF_A_ID       "DCFa"  /* AM demodulation */
+#define DCF_P_ID       "DCFp"  /* psuedo random phase shift */
+#define GPS_ID         "GPS"   /* GPS receiver */
+
+#define        NOCLOCK_ROOTDELAY       0.0
+#define        NOCLOCK_BASEDELAY       0.0
+#define        NOCLOCK_DESCRIPTION     0
+#define NOCLOCK_MAXUNSYNC       0
+#define NOCLOCK_CFLAG           0
+#define NOCLOCK_IFLAG           0
+#define NOCLOCK_OFLAG           0
+#define NOCLOCK_LFLAG           0
+#define NOCLOCK_ID             "TILT"
+#define NOCLOCK_POLL           NO_POLL
+#define NOCLOCK_INIT           NO_INIT
+#define NOCLOCK_END            NO_END
+#define NOCLOCK_DATA           NO_LCLDATA
+#define NOCLOCK_FORMAT         ""
+#define NOCLOCK_TYPE           CTL_SST_TS_UNSPEC
+#define NOCLOCK_SAMPLES                0
+#define NOCLOCK_KEEP           0 
+
+#define DCF_TYPE               CTL_SST_TS_LF
+#define GPS_TYPE               CTL_SST_TS_UHF
+
+/*
+ * receiver specific constants
+ */
+#define MBG_SPEED              (B9600)
+#define MBG_CFLAG              (CS7|PARENB|CREAD|CLOCAL|HUPCL|CSTOPB)
+#define MBG_IFLAG              (IGNBRK|IGNPAR|ISTRIP)
+#define MBG_OFLAG              0
+#define MBG_LFLAG              0
+#define MBG_FLAGS               PARSE_F_PPSONSECOND
+
+/*
+ * Meinberg DCF77 receivers
+ */
+#define        DCFUA31_ROOTDELAY       0.0  /* 0 */
+#define        DCFUA31_BASEDELAY       0.010  /* 10.7421875ms: 10 ms (+/- 3 ms) */
+#define        DCFUA31_DESCRIPTION     "Meinberg DCF77 C51 or compatible"
+#define DCFUA31_MAXUNSYNC       60*30       /* only trust clock for 1/2 hour */
+#define DCFUA31_SPEED          MBG_SPEED
+#define DCFUA31_CFLAG           MBG_CFLAG
+#define DCFUA31_IFLAG           MBG_IFLAG
+#define DCFUA31_OFLAG           MBG_OFLAG
+#define DCFUA31_LFLAG           MBG_LFLAG
+#define DCFUA31_SAMPLES                5
+#define DCFUA31_KEEP           3
+#define DCFUA31_FORMAT         "Meinberg Standard"
+
+/*
+ * Meinberg DCF PZF535/TCXO (FM/PZF) receiver
+ */
+#define        DCFPZF535_ROOTDELAY     0.0
+#define        DCFPZF535_BASEDELAY     0.001968  /* 1.968ms +- 104us (oscilloscope) - relative to start (end of STX) */
+#define        DCFPZF535_DESCRIPTION   "Meinberg DCF PZF 535/509 / TCXO"
+#define DCFPZF535_MAXUNSYNC     60*60*12           /* only trust clock for 12 hours
+                                                   * @ 5e-8df/f we have accumulated
+                                                   * at most 2.16 ms (thus we move to
+                                                   * NTP synchronisation */
+#define DCFPZF535_SPEED                MBG_SPEED
+#define DCFPZF535_CFLAG         MBG_CFLAG
+#define DCFPZF535_IFLAG         MBG_IFLAG
+#define DCFPZF535_OFLAG         MBG_OFLAG
+#define DCFPZF535_LFLAG         MBG_LFLAG
+#define DCFPZF535_SAMPLES             5
+#define DCFPZF535_KEEP                3
+#define DCFPZF535_FORMAT       "Meinberg Standard"
+
+/*
+ * Meinberg DCF PZF535/OCXO receiver
+ */
+#define        DCFPZF535OCXO_ROOTDELAY 0.0
+#define        DCFPZF535OCXO_BASEDELAY 0.001968 /* 1.968ms +- 104us (oscilloscope) - relative to start (end of STX) */
+#define        DCFPZF535OCXO_DESCRIPTION "Meinberg DCF PZF 535/509 / OCXO"
+#define DCFPZF535OCXO_MAXUNSYNC     60*60*96       /* only trust clock for 4 days
+                                                   * @ 5e-9df/f we have accumulated
+                                                   * at most an error of 1.73 ms
+                                                   * (thus we move to NTP synchronisation) */
+#define DCFPZF535OCXO_SPEED        MBG_SPEED
+#define DCFPZF535OCXO_CFLAG         MBG_CFLAG
+#define DCFPZF535OCXO_IFLAG         MBG_IFLAG
+#define DCFPZF535OCXO_OFLAG         MBG_OFLAG
+#define DCFPZF535OCXO_LFLAG         MBG_LFLAG
+#define DCFPZF535OCXO_SAMPLES             5
+#define DCFPZF535OCXO_KEEP                3
+#define DCFPZF535OCXO_FORMAT       "Meinberg Standard"
+
+/*
+ * Meinberg GPS16X receiver
+ */
+static void    gps16x_message   P((struct parseunit *, parsetime_t *));
+static  int     gps16x_poll_init P((struct parseunit *));
+
+#define        GPS16X_ROOTDELAY        0.0         /* nothing here */
+#define        GPS16X_BASEDELAY        0.001968         /* XXX to be fixed ! 1.968ms +- 104us (oscilloscope) - relative to start (end of STX) */
+#define        GPS16X_DESCRIPTION      "Meinberg GPS16x receiver"
+#define GPS16X_MAXUNSYNC        60*60*96       /* only trust clock for 4 days
+                                               * @ 5e-9df/f we have accumulated
+                                               * at most an error of 1.73 ms
+                                               * (thus we move to NTP synchronisation) */
+#define GPS16X_SPEED           B19200
+#define GPS16X_CFLAG            (CS8|CREAD|CLOCAL|HUPCL)
+#define GPS16X_IFLAG            (IGNBRK|IGNPAR)
+#define GPS16X_OFLAG            MBG_OFLAG
+#define GPS16X_LFLAG            MBG_LFLAG
+#define GPS16X_POLLRATE        6
+#define GPS16X_POLLCMD ""
+#define GPS16X_CMDSIZE 0
+
+static poll_info_t gps16x_pollinfo = { GPS16X_POLLRATE, GPS16X_POLLCMD, GPS16X_CMDSIZE };
+
+#define GPS16X_INIT            gps16x_poll_init
+#define GPS16X_POLL            0
+#define GPS16X_END             0
+#define GPS16X_DATA            ((void *)(&gps16x_pollinfo))
+#define GPS16X_MESSAGE         gps16x_message
+#define GPS16X_ID              GPS_ID
+#define GPS16X_FORMAT          "Meinberg GPS Extended"
+#define GPS16X_SAMPLES         5
+#define GPS16X_KEEP            3
+
+/*
+ * ELV DCF7000 Wallclock-Receiver/Switching Clock (Kit)
+ *
+ * This is really not the hottest clock - but before you have nothing ...
+ */
+#define DCF7000_ROOTDELAY      0.0 /* 0 */
+#define DCF7000_BASEDELAY      0.405 /* slow blow */
+#define DCF7000_DESCRIPTION    "ELV DCF7000"
+#define DCF7000_MAXUNSYNC      (60*5) /* sorry - but it just was not build as a clock */
+#define DCF7000_SPEED          (B9600)
+#define DCF7000_CFLAG           (CS8|CREAD|PARENB|PARODD|CLOCAL|HUPCL)
+#define DCF7000_IFLAG          (IGNBRK)
+#define DCF7000_OFLAG          0
+#define DCF7000_LFLAG          0
+#define DCF7000_SAMPLES                5
+#define DCF7000_KEEP           3
+#define DCF7000_FORMAT         "ELV DCF7000"
+
+/*
+ * Schmid DCF Receiver Kit
+ *
+ * When the WSDCF clock is operating optimally we want the primary clock
+ * distance to come out at 300 ms.  Thus, peer.distance in the WSDCF peer
+ * structure is set to 290 ms and we compute delays which are at least
+ * 10 ms long.  The following are 290 ms and 10 ms expressed in u_fp format
+ */
+#define WS_POLLRATE    1       /* every second - watch interdependency with poll routine */
+#define WS_POLLCMD     "\163"
+#define WS_CMDSIZE     1
+
+static poll_info_t wsdcf_pollinfo = { WS_POLLRATE, WS_POLLCMD, WS_CMDSIZE };
+
+#define WSDCF_INIT             poll_init
+#define WSDCF_POLL             poll_dpoll
+#define WSDCF_END              0
+#define WSDCF_DATA             ((void *)(&wsdcf_pollinfo))
+#define        WSDCF_ROOTDELAY         0.0     /* 0 */
+#define        WSDCF_BASEDELAY         0.010   /*  ~  10ms */
+#define WSDCF_DESCRIPTION      "WS/DCF Receiver"
+#define WSDCF_FORMAT           "Schmid"
+#define WSDCF_MAXUNSYNC                (60*60) /* assume this beast hold at 1 h better than 2 ms XXX-must verify */
+#define WSDCF_SPEED            (B1200)
+#define WSDCF_CFLAG            (CS8|CREAD|CLOCAL)
+#define WSDCF_IFLAG            0
+#define WSDCF_OFLAG            0
+#define WSDCF_LFLAG            0
+#define WSDCF_SAMPLES          5
+#define WSDCF_KEEP             3
+
+/*
+ * RAW DCF77 - input of DCF marks via RS232 - many variants
+ */
+#define RAWDCF_FLAGS           0
+#define RAWDCF_ROOTDELAY       0.0 /* 0 */
+#define RAWDCF_BASEDELAY       0.258
+#define RAWDCF_FORMAT          "RAW DCF77 Timecode"
+#define RAWDCF_MAXUNSYNC       (0) /* sorry - its a true receiver - no signal - no time */
+#define RAWDCF_SPEED           (B50)
+#ifdef NO_PARENB_IGNPAR /* Was: defined(SYS_IRIX4) || defined(SYS_IRIX5) */
+/* somehow doesn't grok PARENB & IGNPAR (mj) */
+# define RAWDCF_CFLAG            (CS8|CREAD|CLOCAL)
+#else
+# define RAWDCF_CFLAG            (CS8|CREAD|CLOCAL|PARENB)
+#endif
+#ifdef RAWDCF_NO_IGNPAR /* Was: defined(SYS_LINUX) && defined(CLOCK_RAWDCF) */
+# define RAWDCF_IFLAG          0
+#else
+# define RAWDCF_IFLAG          (IGNPAR)
+#endif
+#define RAWDCF_OFLAG           0
+#define RAWDCF_LFLAG           0
+#define RAWDCF_SAMPLES         20
+#define RAWDCF_KEEP            12
+#define RAWDCF_INIT            0
+
+/*
+ * RAW DCF variants
+ */
+/*
+ * Conrad receiver
+ *
+ * simplest (cheapest) DCF clock - e. g. DCF77 receiver by Conrad
+ * (~40DM - roughly $30 ) followed by a level converter for RS232
+ */
+#define CONRAD_BASEDELAY       0.292 /* Conrad receiver @ 50 Baud on a Sun */
+#define CONRAD_DESCRIPTION     "RAW DCF77 CODE (Conrad DCF77 receiver module)"
+
+/* Gude Analog- und Digitalsystem GmbH 'Expert mouseCLOCK USB v2.0' */
+#define GUDE_EMC_USB_V20_SPEED            (B4800)
+#define GUDE_EMC_USB_V20_BASEDELAY        0.425 /* USB serial<->USB converter FTDI232R */
+#define GUDE_EMC_USB_V20_DESCRIPTION      "RAW DCF77 CODE (Expert mouseCLOCK USB v2.0)"
+
+/*
+ * TimeBrick receiver
+ */
+#define TIMEBRICK_BASEDELAY    0.210 /* TimeBrick @ 50 Baud on a Sun */
+#define TIMEBRICK_DESCRIPTION  "RAW DCF77 CODE (TimeBrick)"
+
+/*
+ * IGEL:clock receiver
+ */
+#define IGELCLOCK_BASEDELAY    0.258 /* IGEL:clock receiver */
+#define IGELCLOCK_DESCRIPTION  "RAW DCF77 CODE (IGEL:clock)"
+#define IGELCLOCK_SPEED                (B1200)
+#define IGELCLOCK_CFLAG                (CS8|CREAD|HUPCL|CLOCAL)
+
+/*
+ * RAWDCF receivers that need to be powered from DTR
+ * (like Expert mouse clock)
+ */
+static int     rawdcf_init_1   P((struct parseunit *));
+#define RAWDCFDTRSET_DESCRIPTION       "RAW DCF77 CODE (DTR SET/RTS CLR)"
+#define RAWDCFDTRSET_INIT              rawdcf_init_1
+
+/*
+ * RAWDCF receivers that need to be powered from
+ * DTR CLR and RTS SET
+ */
+static int     rawdcf_init_2   P((struct parseunit *));
+#define RAWDCFDTRCLRRTSSET_DESCRIPTION "RAW DCF77 CODE (DTR CLR/RTS SET)"
+#define RAWDCFDTRCLRRTSSET_INIT        rawdcf_init_2
+
+/*
+ * Trimble GPS receivers (TAIP and TSIP protocols)
+ */
+#ifndef TRIM_POLLRATE
+#define TRIM_POLLRATE  0       /* only true direct polling */
+#endif
+
+#define TRIM_TAIPPOLLCMD       ">SRM;FR_FLAG=F;EC_FLAG=F<>QTM<"
+#define TRIM_TAIPCMDSIZE       (sizeof(TRIM_TAIPPOLLCMD)-1)
+
+static poll_info_t trimbletaip_pollinfo = { TRIM_POLLRATE, TRIM_TAIPPOLLCMD, TRIM_TAIPCMDSIZE };
+static int     trimbletaip_init        P((struct parseunit *));
+static void    trimbletaip_event       P((struct parseunit *, int));
+
+/* query time & UTC correction data */
+static char tsipquery[] = { DLE, 0x21, DLE, ETX, DLE, 0x2F, DLE, ETX };
+
+static poll_info_t trimbletsip_pollinfo = { TRIM_POLLRATE, tsipquery, sizeof(tsipquery) };
+static int     trimbletsip_init        P((struct parseunit *));
+static void    trimbletsip_end         P((struct parseunit *));
+static void    trimbletsip_message     P((struct parseunit *, parsetime_t *));
+static void    trimbletsip_event       P((struct parseunit *, int));
+
+#define TRIMBLETSIP_IDLE_TIME      (300) /* 5 minutes silence at most */
+#define TRIMBLE_RESET_HOLDOFF       TRIMBLETSIP_IDLE_TIME
+
+#define TRIMBLETAIP_SPEED          (B4800)
+#define TRIMBLETAIP_CFLAG           (CS8|CREAD|CLOCAL)
+#define TRIMBLETAIP_IFLAG           (BRKINT|IGNPAR|ISTRIP|ICRNL|IXON)
+#define TRIMBLETAIP_OFLAG           (OPOST|ONLCR)
+#define TRIMBLETAIP_LFLAG           (0)
+
+#define TRIMBLETSIP_SPEED          (B9600)
+#define TRIMBLETSIP_CFLAG           (CS8|CLOCAL|CREAD|PARENB|PARODD)
+#define TRIMBLETSIP_IFLAG           (IGNBRK)
+#define TRIMBLETSIP_OFLAG           (0)
+#define TRIMBLETSIP_LFLAG           (ICANON)
+
+#define TRIMBLETSIP_SAMPLES        5
+#define TRIMBLETSIP_KEEP           3
+#define TRIMBLETAIP_SAMPLES        5
+#define TRIMBLETAIP_KEEP           3
+
+#define TRIMBLETAIP_FLAGS          (PARSE_F_PPSONSECOND)
+#define TRIMBLETSIP_FLAGS          (TRIMBLETAIP_FLAGS)
+
+#define TRIMBLETAIP_POLL           poll_dpoll
+#define TRIMBLETSIP_POLL           poll_dpoll
+
+#define TRIMBLETAIP_INIT           trimbletaip_init
+#define TRIMBLETSIP_INIT           trimbletsip_init
+
+#define TRIMBLETAIP_EVENT          trimbletaip_event   
+
+#define TRIMBLETSIP_EVENT          trimbletsip_event   
+#define TRIMBLETSIP_MESSAGE        trimbletsip_message
+
+#define TRIMBLETAIP_END                    0
+#define TRIMBLETSIP_END                    trimbletsip_end
+
+#define TRIMBLETAIP_DATA           ((void *)(&trimbletaip_pollinfo))
+#define TRIMBLETSIP_DATA           ((void *)(&trimbletsip_pollinfo))
+
+#define TRIMBLETAIP_ID             GPS_ID
+#define TRIMBLETSIP_ID             GPS_ID
+
+#define TRIMBLETAIP_FORMAT         "Trimble TAIP"
+#define TRIMBLETSIP_FORMAT         "Trimble TSIP"
+
+#define TRIMBLETAIP_ROOTDELAY        0x0
+#define TRIMBLETSIP_ROOTDELAY        0x0
+
+#define TRIMBLETAIP_BASEDELAY        0.0
+#define TRIMBLETSIP_BASEDELAY        0.020     /* GPS time message latency */
+
+#define TRIMBLETAIP_DESCRIPTION      "Trimble GPS (TAIP) receiver"
+#define TRIMBLETSIP_DESCRIPTION      "Trimble GPS (TSIP) receiver"
+
+#define TRIMBLETAIP_MAXUNSYNC        0
+#define TRIMBLETSIP_MAXUNSYNC        0
+
+#define TRIMBLETAIP_EOL                    '<'
+
+/*
+ * RadioCode Clocks RCC 800 receiver
+ */
+#define RCC_POLLRATE   0       /* only true direct polling */
+#define RCC_POLLCMD    "\r"
+#define RCC_CMDSIZE    1
+
+static poll_info_t rcc8000_pollinfo = { RCC_POLLRATE, RCC_POLLCMD, RCC_CMDSIZE };
+#define RCC8000_FLAGS          0
+#define RCC8000_POLL            poll_dpoll
+#define RCC8000_INIT            poll_init
+#define RCC8000_END             0
+#define RCC8000_DATA            ((void *)(&rcc8000_pollinfo))
+#define RCC8000_ROOTDELAY       0.0
+#define RCC8000_BASEDELAY       0.0
+#define RCC8000_ID              "MSF"
+#define RCC8000_DESCRIPTION     "RCC 8000 MSF Receiver"
+#define RCC8000_FORMAT          "Radiocode RCC8000"
+#define RCC8000_MAXUNSYNC       (60*60) /* should be ok for an hour */
+#define RCC8000_SPEED          (B2400)
+#define RCC8000_CFLAG           (CS8|CREAD|CLOCAL)
+#define RCC8000_IFLAG           (IGNBRK|IGNPAR)
+#define RCC8000_OFLAG           0
+#define RCC8000_LFLAG           0
+#define RCC8000_SAMPLES         5
+#define RCC8000_KEEP           3
+
+/*
+ * Hopf Radio clock 6021 Format 
+ *
+ */
+#define HOPF6021_ROOTDELAY     0.0
+#define HOPF6021_BASEDELAY     0.0
+#define HOPF6021_DESCRIPTION   "HOPF 6021"
+#define HOPF6021_FORMAT         "hopf Funkuhr 6021"
+#define HOPF6021_MAXUNSYNC     (60*60)  /* should be ok for an hour */
+#define HOPF6021_SPEED         (B9600)
+#define HOPF6021_CFLAG          (CS8|CREAD|CLOCAL)
+#define HOPF6021_IFLAG         (IGNBRK|ISTRIP)
+#define HOPF6021_OFLAG         0
+#define HOPF6021_LFLAG         0
+#define HOPF6021_FLAGS          0
+#define HOPF6021_SAMPLES        5
+#define HOPF6021_KEEP          3
+
+/*
+ * Diem's Computime Radio Clock Receiver
+ */
+#define COMPUTIME_FLAGS       0
+#define COMPUTIME_ROOTDELAY   0.0
+#define COMPUTIME_BASEDELAY   0.0
+#define COMPUTIME_ID          DCF_ID
+#define COMPUTIME_DESCRIPTION "Diem's Computime receiver"
+#define COMPUTIME_FORMAT      "Diem's Computime Radio Clock"
+#define COMPUTIME_TYPE        DCF_TYPE
+#define COMPUTIME_MAXUNSYNC   (60*60)       /* only trust clock for 1 hour */
+#define COMPUTIME_SPEED       (B9600)
+#define COMPUTIME_CFLAG       (CSTOPB|CS7|CREAD|CLOCAL)
+#define COMPUTIME_IFLAG       (IGNBRK|IGNPAR|ISTRIP)
+#define COMPUTIME_OFLAG       0
+#define COMPUTIME_LFLAG       0
+#define COMPUTIME_SAMPLES     5
+#define COMPUTIME_KEEP        3
+
+/*
+ * Varitext Radio Clock Receiver
+ */
+#define VARITEXT_FLAGS       0
+#define VARITEXT_ROOTDELAY   0.0
+#define VARITEXT_BASEDELAY   0.0
+#define VARITEXT_ID          "MSF"
+#define VARITEXT_DESCRIPTION "Varitext receiver"
+#define VARITEXT_FORMAT      "Varitext Radio Clock"
+#define VARITEXT_TYPE        DCF_TYPE
+#define VARITEXT_MAXUNSYNC   (60*60)       /* only trust clock for 1 hour */
+#define VARITEXT_SPEED       (B9600)
+#define VARITEXT_CFLAG       (CS7|CREAD|CLOCAL|PARENB|PARODD)
+#define VARITEXT_IFLAG       (IGNPAR|IGNBRK|INPCK) /*|ISTRIP)*/
+#define VARITEXT_OFLAG       0
+#define VARITEXT_LFLAG       0
+#define VARITEXT_SAMPLES     32
+#define VARITEXT_KEEP        20
+
+static struct parse_clockinfo
+{
+       u_long  cl_flags;               /* operation flags (io modes) */
+  void  (*cl_poll)    P((struct parseunit *));                 /* active poll routine */
+  int   (*cl_init)    P((struct parseunit *));                 /* active poll init routine */
+  void  (*cl_event)   P((struct parseunit *, int));            /* special event handling (e.g. reset clock) */
+  void  (*cl_end)     P((struct parseunit *));                 /* active poll end routine */
+  void  (*cl_message) P((struct parseunit *, parsetime_t *));  /* process a lower layer message */
+       void   *cl_data;                /* local data area for "poll" mechanism */
+       double    cl_rootdelay;         /* rootdelay */
+       double    cl_basedelay;         /* current offset by which the RS232
+                               time code is delayed from the actual time */
+       const char *cl_id;              /* ID code */
+       const char *cl_description;             /* device name */
+       const char *cl_format;          /* fixed format */
+       u_char  cl_type;                /* clock type (ntp control) */
+       u_long  cl_maxunsync;           /* time to trust oscillator after losing synch */
+       u_long  cl_speed;               /* terminal input & output baudrate */
+       u_long  cl_cflag;             /* terminal control flags */
+       u_long  cl_iflag;             /* terminal input flags */
+       u_long  cl_oflag;             /* terminal output flags */
+       u_long  cl_lflag;             /* terminal local flags */
+       u_long  cl_samples;           /* samples for median filter */
+       u_long  cl_keep;              /* samples for median filter to keep */
+} parse_clockinfo[] =
+{
+       {                               /* mode 0 */
+               MBG_FLAGS,
+               NO_POLL,
+               NO_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               DCFPZF535_ROOTDELAY,
+               DCFPZF535_BASEDELAY,
+               DCF_P_ID,
+               DCFPZF535_DESCRIPTION,
+               DCFPZF535_FORMAT,
+               DCF_TYPE,
+               DCFPZF535_MAXUNSYNC,
+               DCFPZF535_SPEED,
+               DCFPZF535_CFLAG,
+               DCFPZF535_IFLAG,
+               DCFPZF535_OFLAG,
+               DCFPZF535_LFLAG,
+               DCFPZF535_SAMPLES,
+               DCFPZF535_KEEP
+       },
+       {                               /* mode 1 */
+               MBG_FLAGS,
+               NO_POLL,
+               NO_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               DCFPZF535OCXO_ROOTDELAY,
+               DCFPZF535OCXO_BASEDELAY,
+               DCF_P_ID,
+               DCFPZF535OCXO_DESCRIPTION,
+               DCFPZF535OCXO_FORMAT,
+               DCF_TYPE,
+               DCFPZF535OCXO_MAXUNSYNC,
+               DCFPZF535OCXO_SPEED,
+               DCFPZF535OCXO_CFLAG,
+               DCFPZF535OCXO_IFLAG,
+               DCFPZF535OCXO_OFLAG,
+               DCFPZF535OCXO_LFLAG,
+               DCFPZF535OCXO_SAMPLES,
+               DCFPZF535OCXO_KEEP
+       },
+       {                               /* mode 2 */
+               MBG_FLAGS,
+               NO_POLL,
+               NO_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               DCFUA31_ROOTDELAY,
+               DCFUA31_BASEDELAY,
+               DCF_A_ID,
+               DCFUA31_DESCRIPTION,
+               DCFUA31_FORMAT,
+               DCF_TYPE,
+               DCFUA31_MAXUNSYNC,
+               DCFUA31_SPEED,
+               DCFUA31_CFLAG,
+               DCFUA31_IFLAG,
+               DCFUA31_OFLAG,
+               DCFUA31_LFLAG,
+               DCFUA31_SAMPLES,
+               DCFUA31_KEEP
+       },
+       {                               /* mode 3 */
+               MBG_FLAGS,
+               NO_POLL,
+               NO_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               DCF7000_ROOTDELAY,
+               DCF7000_BASEDELAY,
+               DCF_A_ID,
+               DCF7000_DESCRIPTION,
+               DCF7000_FORMAT,
+               DCF_TYPE,
+               DCF7000_MAXUNSYNC,
+               DCF7000_SPEED,
+               DCF7000_CFLAG,
+               DCF7000_IFLAG,
+               DCF7000_OFLAG,
+               DCF7000_LFLAG,
+               DCF7000_SAMPLES,
+               DCF7000_KEEP
+       },
+       {                               /* mode 4 */
+               NO_CL_FLAGS,
+               WSDCF_POLL,
+               WSDCF_INIT,
+               NO_EVENT,
+               WSDCF_END,
+               NO_MESSAGE,
+               WSDCF_DATA,
+               WSDCF_ROOTDELAY,
+               WSDCF_BASEDELAY,
+               DCF_A_ID,
+               WSDCF_DESCRIPTION,
+               WSDCF_FORMAT,
+               DCF_TYPE,
+               WSDCF_MAXUNSYNC,
+               WSDCF_SPEED,
+               WSDCF_CFLAG,
+               WSDCF_IFLAG,
+               WSDCF_OFLAG,
+               WSDCF_LFLAG,
+               WSDCF_SAMPLES,
+               WSDCF_KEEP
+       },
+       {                               /* mode 5 */
+               RAWDCF_FLAGS,
+               NO_POLL,
+               RAWDCF_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               RAWDCF_ROOTDELAY,
+               CONRAD_BASEDELAY,
+               DCF_A_ID,
+               CONRAD_DESCRIPTION,
+               RAWDCF_FORMAT,
+               DCF_TYPE,
+               RAWDCF_MAXUNSYNC,
+               RAWDCF_SPEED,
+               RAWDCF_CFLAG,
+               RAWDCF_IFLAG,
+               RAWDCF_OFLAG,
+               RAWDCF_LFLAG,
+               RAWDCF_SAMPLES,
+               RAWDCF_KEEP
+       },
+       {                               /* mode 6 */
+               RAWDCF_FLAGS,
+               NO_POLL,
+               RAWDCF_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               RAWDCF_ROOTDELAY,
+               TIMEBRICK_BASEDELAY,
+               DCF_A_ID,
+               TIMEBRICK_DESCRIPTION,
+               RAWDCF_FORMAT,
+               DCF_TYPE,
+               RAWDCF_MAXUNSYNC,
+               RAWDCF_SPEED,
+               RAWDCF_CFLAG,
+               RAWDCF_IFLAG,
+               RAWDCF_OFLAG,
+               RAWDCF_LFLAG,
+               RAWDCF_SAMPLES,
+               RAWDCF_KEEP
+       },
+       {                               /* mode 7 */
+               MBG_FLAGS,
+               GPS16X_POLL,
+               GPS16X_INIT,
+               NO_EVENT,
+               GPS16X_END,
+               GPS16X_MESSAGE,
+               GPS16X_DATA,
+               GPS16X_ROOTDELAY,
+               GPS16X_BASEDELAY,
+               GPS16X_ID,
+               GPS16X_DESCRIPTION,
+               GPS16X_FORMAT,
+               GPS_TYPE,
+               GPS16X_MAXUNSYNC,
+               GPS16X_SPEED,
+               GPS16X_CFLAG,
+               GPS16X_IFLAG,
+               GPS16X_OFLAG,
+               GPS16X_LFLAG,
+               GPS16X_SAMPLES,
+               GPS16X_KEEP
+       },
+       {                               /* mode 8 */
+               RAWDCF_FLAGS,
+               NO_POLL,
+               NO_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               RAWDCF_ROOTDELAY,
+               IGELCLOCK_BASEDELAY,
+               DCF_A_ID,
+               IGELCLOCK_DESCRIPTION,
+               RAWDCF_FORMAT,
+               DCF_TYPE,
+               RAWDCF_MAXUNSYNC,
+               IGELCLOCK_SPEED,
+               IGELCLOCK_CFLAG,
+               RAWDCF_IFLAG,
+               RAWDCF_OFLAG,
+               RAWDCF_LFLAG,
+               RAWDCF_SAMPLES,
+               RAWDCF_KEEP
+       },
+       {                               /* mode 9 */
+               TRIMBLETAIP_FLAGS,
+#if TRIM_POLLRATE              /* DHD940515: Allow user config */
+               NO_POLL,
+#else
+               TRIMBLETAIP_POLL,
+#endif
+               TRIMBLETAIP_INIT,
+               TRIMBLETAIP_EVENT,
+               TRIMBLETAIP_END,
+               NO_MESSAGE,
+               TRIMBLETAIP_DATA,
+               TRIMBLETAIP_ROOTDELAY,
+               TRIMBLETAIP_BASEDELAY,
+               TRIMBLETAIP_ID,
+               TRIMBLETAIP_DESCRIPTION,
+               TRIMBLETAIP_FORMAT,
+               GPS_TYPE,
+               TRIMBLETAIP_MAXUNSYNC,
+               TRIMBLETAIP_SPEED,
+               TRIMBLETAIP_CFLAG,
+               TRIMBLETAIP_IFLAG,
+               TRIMBLETAIP_OFLAG,
+               TRIMBLETAIP_LFLAG,
+               TRIMBLETAIP_SAMPLES,
+               TRIMBLETAIP_KEEP
+       },
+       {                               /* mode 10 */
+               TRIMBLETSIP_FLAGS,
+#if TRIM_POLLRATE              /* DHD940515: Allow user config */
+               NO_POLL,
+#else
+               TRIMBLETSIP_POLL,
+#endif
+               TRIMBLETSIP_INIT,
+               TRIMBLETSIP_EVENT,
+               TRIMBLETSIP_END,
+               TRIMBLETSIP_MESSAGE,
+               TRIMBLETSIP_DATA,
+               TRIMBLETSIP_ROOTDELAY,
+               TRIMBLETSIP_BASEDELAY,
+               TRIMBLETSIP_ID,
+               TRIMBLETSIP_DESCRIPTION,
+               TRIMBLETSIP_FORMAT,
+               GPS_TYPE,
+               TRIMBLETSIP_MAXUNSYNC,
+               TRIMBLETSIP_SPEED,
+               TRIMBLETSIP_CFLAG,
+               TRIMBLETSIP_IFLAG,
+               TRIMBLETSIP_OFLAG,
+               TRIMBLETSIP_LFLAG,
+               TRIMBLETSIP_SAMPLES,
+               TRIMBLETSIP_KEEP
+       },
+       {                             /* mode 11 */
+               NO_CL_FLAGS,
+               RCC8000_POLL,
+               RCC8000_INIT,
+               NO_EVENT,
+               RCC8000_END,
+               NO_MESSAGE,
+               RCC8000_DATA,
+               RCC8000_ROOTDELAY,
+               RCC8000_BASEDELAY,
+               RCC8000_ID,
+               RCC8000_DESCRIPTION,
+               RCC8000_FORMAT,
+               DCF_TYPE,
+               RCC8000_MAXUNSYNC,
+               RCC8000_SPEED,
+               RCC8000_CFLAG,
+               RCC8000_IFLAG,
+               RCC8000_OFLAG,
+               RCC8000_LFLAG,
+               RCC8000_SAMPLES,
+               RCC8000_KEEP
+       },
+       {                             /* mode 12 */
+               HOPF6021_FLAGS,
+               NO_POLL,     
+               NO_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               HOPF6021_ROOTDELAY,
+               HOPF6021_BASEDELAY,
+               DCF_ID,
+               HOPF6021_DESCRIPTION,
+               HOPF6021_FORMAT,
+               DCF_TYPE,
+               HOPF6021_MAXUNSYNC,
+               HOPF6021_SPEED,
+               HOPF6021_CFLAG,
+               HOPF6021_IFLAG,
+               HOPF6021_OFLAG,
+               HOPF6021_LFLAG,
+               HOPF6021_SAMPLES,
+               HOPF6021_KEEP
+       },
+       {                            /* mode 13 */
+               COMPUTIME_FLAGS,
+               NO_POLL,
+               NO_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               COMPUTIME_ROOTDELAY,
+               COMPUTIME_BASEDELAY,
+               COMPUTIME_ID,
+               COMPUTIME_DESCRIPTION,
+               COMPUTIME_FORMAT,
+               COMPUTIME_TYPE,
+               COMPUTIME_MAXUNSYNC,
+               COMPUTIME_SPEED,
+               COMPUTIME_CFLAG,
+               COMPUTIME_IFLAG,
+               COMPUTIME_OFLAG,
+               COMPUTIME_LFLAG,
+               COMPUTIME_SAMPLES,
+               COMPUTIME_KEEP
+       },
+       {                               /* mode 14 */
+               RAWDCF_FLAGS,
+               NO_POLL,
+               RAWDCFDTRSET_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               RAWDCF_ROOTDELAY,
+               RAWDCF_BASEDELAY,
+               DCF_A_ID,
+               RAWDCFDTRSET_DESCRIPTION,
+               RAWDCF_FORMAT,
+               DCF_TYPE,
+               RAWDCF_MAXUNSYNC,
+               RAWDCF_SPEED,
+               RAWDCF_CFLAG,
+               RAWDCF_IFLAG,
+               RAWDCF_OFLAG,
+               RAWDCF_LFLAG,
+               RAWDCF_SAMPLES,
+               RAWDCF_KEEP
+       },
+       {                               /* mode 15 */
+               0,                              /* operation flags (io modes) */
+               NO_POLL,                        /* active poll routine */
+               NO_INIT,                        /* active poll init routine */
+               NO_EVENT,                       /* special event handling (e.g. reset clock) */
+               NO_END,                         /* active poll end routine */
+               NO_MESSAGE,                     /* process a lower layer message */
+               NO_LCLDATA,                     /* local data area for "poll" mechanism */
+               0,                              /* rootdelay */
+               11.0 /* bits */ / 9600,         /* current offset by which the RS232
+                                               time code is delayed from the actual time */
+               DCF_ID,                         /* ID code */
+               "WHARTON 400A Series clock",    /* device name */
+               "WHARTON 400A Series clock Output Format 1",    /* fixed format */
+                       /* Must match a format-name in a libparse/clk_xxx.c file */
+               DCF_TYPE,                       /* clock type (ntp control) */
+               (1*60*60),                      /* time to trust oscillator after losing synch */
+               B9600,                          /* terminal input & output baudrate */
+               (CS8|CREAD|PARENB|CLOCAL|HUPCL),/* terminal control flags */
+               0,                              /* terminal input flags */
+               0,                              /* terminal output flags */
+               0,                              /* terminal local flags */
+               5,                              /* samples for median filter */
+               3,                              /* samples for median filter to keep */
+       },
+       {                               /* mode 16 - RAWDCF RTS set, DTR clr */
+               RAWDCF_FLAGS,
+               NO_POLL,
+               RAWDCFDTRCLRRTSSET_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               RAWDCF_ROOTDELAY,
+               RAWDCF_BASEDELAY,
+               DCF_A_ID,
+               RAWDCFDTRCLRRTSSET_DESCRIPTION,
+               RAWDCF_FORMAT,
+               DCF_TYPE,
+               RAWDCF_MAXUNSYNC,
+               RAWDCF_SPEED,
+               RAWDCF_CFLAG,
+               RAWDCF_IFLAG,
+               RAWDCF_OFLAG,
+               RAWDCF_LFLAG,
+               RAWDCF_SAMPLES,
+               RAWDCF_KEEP
+       },
+        {                            /* mode 17 */
+                VARITEXT_FLAGS,
+                NO_POLL,
+                NO_INIT,
+                NO_EVENT,
+                NO_END,
+                NO_MESSAGE,
+                NO_LCLDATA,
+                VARITEXT_ROOTDELAY,
+                VARITEXT_BASEDELAY,
+                VARITEXT_ID,
+                VARITEXT_DESCRIPTION,
+                VARITEXT_FORMAT,
+                VARITEXT_TYPE,
+                VARITEXT_MAXUNSYNC,
+                VARITEXT_SPEED,
+                VARITEXT_CFLAG,
+                VARITEXT_IFLAG,
+                VARITEXT_OFLAG,
+                VARITEXT_LFLAG,
+                VARITEXT_SAMPLES,
+                VARITEXT_KEEP
+        },
+       {                               /* mode 18 */
+               MBG_FLAGS,
+               NO_POLL,
+               NO_INIT,
+               NO_EVENT,
+               GPS16X_END,
+               GPS16X_MESSAGE,
+               GPS16X_DATA,
+               GPS16X_ROOTDELAY,
+               GPS16X_BASEDELAY,
+               GPS16X_ID,
+               GPS16X_DESCRIPTION,
+               GPS16X_FORMAT,
+               GPS_TYPE,
+               GPS16X_MAXUNSYNC,
+               GPS16X_SPEED,
+               GPS16X_CFLAG,
+               GPS16X_IFLAG,
+               GPS16X_OFLAG,
+               GPS16X_LFLAG,
+               GPS16X_SAMPLES,
+               GPS16X_KEEP
+       },
+       {                               /* mode 19 */
+               RAWDCF_FLAGS,
+               NO_POLL,
+               RAWDCF_INIT,
+               NO_EVENT,
+               NO_END,
+               NO_MESSAGE,
+               NO_LCLDATA,
+               RAWDCF_ROOTDELAY,
+               GUDE_EMC_USB_V20_BASEDELAY,
+               DCF_A_ID,
+               GUDE_EMC_USB_V20_DESCRIPTION,
+               RAWDCF_FORMAT,
+               DCF_TYPE,
+               RAWDCF_MAXUNSYNC,
+               GUDE_EMC_USB_V20_SPEED,
+               RAWDCF_CFLAG,
+               RAWDCF_IFLAG,
+               RAWDCF_OFLAG,
+               RAWDCF_LFLAG,
+               RAWDCF_SAMPLES,
+               RAWDCF_KEEP
+       },
+};
+
+static int ncltypes = sizeof(parse_clockinfo) / sizeof(struct parse_clockinfo);
+
+#define CLK_REALTYPE(x) ((int)(((x)->ttl) & 0x7F))
+#define CLK_TYPE(x)    ((CLK_REALTYPE(x) >= ncltypes) ? ~0 : CLK_REALTYPE(x))
+#define CLK_UNIT(x)    ((int)REFCLOCKUNIT(&(x)->srcadr))
+#define CLK_PPS(x)     (((x)->ttl) & 0x80)
+
+/*
+ * Other constant stuff
+ */
+#define        PARSEHSREFID    0x7f7f08ff      /* 127.127.8.255 refid for hi strata */
+
+#define PARSESTATISTICS   (60*60)              /* output state statistics every hour */
+
+static int notice = 0;
+
+#define PARSE_STATETIME(parse, i) ((parse->generic->currentstatus == i) ? parse->statetime[i] + current_time - parse->lastchange : parse->statetime[i])
+
+static void parse_event   P((struct parseunit *, int));
+static void parse_process P((struct parseunit *, parsetime_t *));
+static void clear_err     P((struct parseunit *, u_long));
+static int  list_err      P((struct parseunit *, u_long));
+static char * l_mktime    P((u_long));
+
+/**===========================================================================
+ ** implementation error message regression module
+ **/
+static void
+clear_err(
+       struct parseunit *parse,
+       u_long            lstate
+       )
+{
+       if (lstate == ERR_ALL)
+       {
+               int i;
+
+               for (i = 0; i < ERR_CNT; i++)
+               {
+                       parse->errors[i].err_stage   = err_tbl[i];
+                       parse->errors[i].err_cnt     = 0;
+                       parse->errors[i].err_last    = 0;
+                       parse->errors[i].err_started = 0;
+                       parse->errors[i].err_suppressed = 0;
+               }
+       }
+       else
+       {
+               parse->errors[lstate].err_stage   = err_tbl[lstate];
+               parse->errors[lstate].err_cnt     = 0;
+               parse->errors[lstate].err_last    = 0;
+               parse->errors[lstate].err_started = 0;
+               parse->errors[lstate].err_suppressed = 0;
+       }
+}
+
+static int
+list_err(
+       struct parseunit *parse,
+       u_long            lstate
+       )
+{
+       int do_it;
+       struct errorinfo *err = &parse->errors[lstate];
+
+       if (err->err_started == 0)
+       {
+               err->err_started = current_time;
+       }
+
+       do_it = (current_time - err->err_last) >= err->err_stage->err_delay;
+
+       if (do_it)
+           err->err_cnt++;
+  
+       if (err->err_stage->err_count &&
+           (err->err_cnt >= err->err_stage->err_count))
+       {
+               err->err_stage++;
+               err->err_cnt = 0;
+       }
+
+       if (!err->err_cnt && do_it)
+           msyslog(LOG_INFO, "PARSE receiver #%d: interval for following error message class is at least %s",
+                   CLK_UNIT(parse->peer), l_mktime(err->err_stage->err_delay));
+
+       if (!do_it)
+           err->err_suppressed++;
+       else
+           err->err_last = current_time;
+
+       if (do_it && err->err_suppressed)
+       {
+               msyslog(LOG_INFO, "PARSE receiver #%d: %ld message%s suppressed, error condition class persists for %s",
+                       CLK_UNIT(parse->peer), err->err_suppressed, (err->err_suppressed == 1) ? " was" : "s where",
+                       l_mktime(current_time - err->err_started));
+               err->err_suppressed = 0;
+       }
+  
+       return do_it;
+}
+
+/*--------------------------------------------------
+ * mkreadable - make a printable ascii string (without
+ * embedded quotes so that the ntpq protocol isn't
+ * fooled
+ */
+#ifndef isprint
+#define isprint(_X_) (((_X_) > 0x1F) && ((_X_) < 0x7F))
+#endif
+
+static char *
+mkreadable(
+       char  *buffer,
+       long  blen,
+       const char  *src,
+       u_long  srclen,
+       int hex
+       )
+{
+       char *b    = buffer;
+       char *endb = (char *)0;
+
+       if (blen < 4)
+               return (char *)0;               /* don't bother with mini buffers */
+
+       endb = buffer + blen - 4;
+
+       blen--;                 /* account for '\0' */
+
+       while (blen && srclen--)
+       {
+               if (!hex &&             /* no binary only */
+                   (*src != '\\') &&   /* no plain \ */
+                   (*src != '"') &&    /* no " */
+                   isprint((int)*src)) /* only printables */
+               {                       /* they are easy... */
+                       *buffer++ = *src++;
+                       blen--;
+               }
+               else
+               {
+                       if (blen < 4)
+                       {
+                               while (blen--)
+                               {
+                                       *buffer++ = '.';
+                               }
+                               *buffer = '\0';
+                               return b;
+                       }
+                       else
+                       {
+                               if (*src == '\\')
+                               {
+                                       strcpy(buffer,"\\\\");
+                                       buffer += 2;
+                                       blen   -= 2;
+                                       src++;
+                               }
+                               else
+                               {
+                                       sprintf(buffer, "\\x%02x", *src++);
+                                       blen   -= 4;
+                                       buffer += 4;
+                               }
+                       }
+               }
+               if (srclen && !blen && endb) /* overflow - set last chars to ... */
+                       strcpy(endb, "...");
+       }
+
+       *buffer = '\0';
+       return b;
+}
+
+
+/*--------------------------------------------------
+ * mkascii - make a printable ascii string
+ * assumes (unless defined better) 7-bit ASCII
+ */
+static char *
+mkascii(
+       char  *buffer,
+       long  blen,
+       const char  *src,
+       u_long  srclen
+       )
+{
+       return mkreadable(buffer, blen, src, srclen, 0);
+}
+
+/**===========================================================================
+ ** implementation of i/o handling methods
+ ** (all STREAM, partial STREAM, user level)
+ **/
+
+/*
+ * define possible io handling methods
+ */
+#ifdef STREAM
+static int  ppsclock_init   P((struct parseunit *));
+static int  stream_init     P((struct parseunit *));
+static void stream_end      P((struct parseunit *));
+static int  stream_enable   P((struct parseunit *));
+static int  stream_disable  P((struct parseunit *));
+static int  stream_setcs    P((struct parseunit *, parsectl_t *));
+static int  stream_getfmt   P((struct parseunit *, parsectl_t *));
+static int  stream_setfmt   P((struct parseunit *, parsectl_t *));
+static int  stream_timecode P((struct parseunit *, parsectl_t *));
+static void stream_receive  P((struct recvbuf *));
+#endif
+                                        
+static int  local_init     P((struct parseunit *));
+static void local_end      P((struct parseunit *));
+static int  local_nop      P((struct parseunit *));
+static int  local_setcs    P((struct parseunit *, parsectl_t *));
+static int  local_getfmt   P((struct parseunit *, parsectl_t *));
+static int  local_setfmt   P((struct parseunit *, parsectl_t *));
+static int  local_timecode P((struct parseunit *, parsectl_t *));
+static void local_receive  P((struct recvbuf *));
+static int  local_input    P((struct recvbuf *));
+
+static bind_t io_bindings[] =
+{
+#ifdef STREAM
+       {
+               "parse STREAM",
+               stream_init,
+               stream_end,
+               stream_setcs,
+               stream_disable,
+               stream_enable,
+               stream_getfmt,
+               stream_setfmt,
+               stream_timecode,
+               stream_receive,
+               0,
+       },
+       {
+               "ppsclock STREAM",
+               ppsclock_init,
+               local_end,
+               local_setcs,
+               local_nop,
+               local_nop,
+               local_getfmt,
+               local_setfmt,
+               local_timecode,
+               local_receive,
+               local_input,
+       },
+#endif
+       {
+               "normal",
+               local_init,
+               local_end,
+               local_setcs,
+               local_nop,
+               local_nop,
+               local_getfmt,
+               local_setfmt,
+               local_timecode,
+               local_receive,
+               local_input,
+       },
+       {
+               (char *)0,
+       }
+};
+
+#ifdef STREAM
+
+#define fix_ts(_X_) \
+                        if ((&(_X_))->tv.tv_usec >= 1000000)                \
+                          {                                                 \
+                           (&(_X_))->tv.tv_usec -= 1000000;                \
+                           (&(_X_))->tv.tv_sec  += 1;                      \
+                         }
+
+#define cvt_ts(_X_, _Y_) \
+                        {                                                   \
+                         l_fp ts;                                          \
+                         fix_ts((_X_));                                    \
+                         if (!buftvtots((const char *)&(&(_X_))->tv, &ts)) \
+                           {                                               \
+                              ERR(ERR_BADDATA)                             \
+                                msyslog(LOG_ERR,"parse: stream_receive: timestamp conversion error (buftvtots) (%s) (%ld.%06ld) ", (_Y_), (long)(&(_X_))->tv.tv_sec, (long)(&(_X_))->tv.tv_usec);\
+                             return;                                       \
+                           }                                               \
+                         else                                              \
+                           {                                               \
+                             (&(_X_))->fp = ts;                            \
+                           }                                               \
+                       }
+
+/*--------------------------------------------------
+ * ppsclock STREAM init
+ */
+static int
+ppsclock_init(
+       struct parseunit *parse
+       )
+{
+        static char m1[] = "ppsclocd";
+       static char m2[] = "ppsclock";
+       
+       /*
+        * now push the parse streams module
+        * it will ensure exclusive access to the device
+        */
+       if (ioctl(parse->ppsfd, I_PUSH, (caddr_t)m1) == -1 &&
+           ioctl(parse->ppsfd, I_PUSH, (caddr_t)m2) == -1)
+       {
+               if (errno != EINVAL)
+               {
+                       msyslog(LOG_ERR, "PARSE receiver #%d: ppsclock_init: ioctl(fd, I_PUSH, \"ppsclock\"): %m",
+                               CLK_UNIT(parse->peer));
+               }
+               return 0;
+       }
+       if (!local_init(parse))
+       {
+               (void)ioctl(parse->ppsfd, I_POP, (caddr_t)0);
+               return 0;
+       }
+
+       parse->flags |= PARSE_PPSCLOCK;
+       return 1;
+}
+
+/*--------------------------------------------------
+ * parse STREAM init
+ */
+static int
+stream_init(
+       struct parseunit *parse
+       )
+{
+       static char m1[] = "parse";
+       /*
+        * now push the parse streams module
+        * to test whether it is there (neat interface 8-( )
+        */
+       if (ioctl(parse->generic->io.fd, I_PUSH, (caddr_t)m1) == -1)
+       {
+               if (errno != EINVAL) /* accept non-existence */
+               {
+                       msyslog(LOG_ERR, "PARSE receiver #%d: stream_init: ioctl(fd, I_PUSH, \"parse\"): %m", CLK_UNIT(parse->peer));
+               }
+               return 0;
+       }
+       else
+       {
+               while(ioctl(parse->generic->io.fd, I_POP, (caddr_t)0) == 0)
+                   /* empty loop */;
+
+               /*
+                * now push it a second time after we have removed all
+                * module garbage
+                */
+               if (ioctl(parse->generic->io.fd, I_PUSH, (caddr_t)m1) == -1)
+               {
+                       msyslog(LOG_ERR, "PARSE receiver #%d: stream_init: ioctl(fd, I_PUSH, \"parse\"): %m", CLK_UNIT(parse->peer));
+                       return 0;
+               }
+               else
+               {
+                       return 1;
+               }
+       }
+}
+
+/*--------------------------------------------------
+ * parse STREAM end
+ */
+static void
+stream_end(
+       struct parseunit *parse
+       )
+{
+       while(ioctl(parse->generic->io.fd, I_POP, (caddr_t)0) == 0)
+           /* empty loop */;
+}
+
+/*--------------------------------------------------
+ * STREAM setcs
+ */
+static int
+stream_setcs(
+       struct parseunit *parse,
+       parsectl_t  *tcl
+       )
+{
+       struct strioctl strioc;
+  
+       strioc.ic_cmd     = PARSEIOC_SETCS;
+       strioc.ic_timout  = 0;
+       strioc.ic_dp      = (char *)tcl;
+       strioc.ic_len     = sizeof (*tcl);
+
+       if (ioctl(parse->generic->io.fd, I_STR, (caddr_t)&strioc) == -1)
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: stream_setcs: ioctl(fd, I_STR, PARSEIOC_SETCS): %m", CLK_UNIT(parse->peer));
+               return 0;
+       }
+       return 1;
+}
+
+/*--------------------------------------------------
+ * STREAM enable
+ */
+static int
+stream_enable(
+       struct parseunit *parse
+       )
+{
+       struct strioctl strioc;
+  
+       strioc.ic_cmd     = PARSEIOC_ENABLE;
+       strioc.ic_timout  = 0;
+       strioc.ic_dp      = (char *)0;
+       strioc.ic_len     = 0;
+
+       if (ioctl(parse->generic->io.fd, I_STR, (caddr_t)&strioc) == -1)
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: stream_enable: ioctl(fd, I_STR, PARSEIOC_ENABLE): %m", CLK_UNIT(parse->peer));
+               return 0;
+       }
+       parse->generic->io.clock_recv = stream_receive; /* ok - parse input in kernel */
+       return 1;
+}
+
+/*--------------------------------------------------
+ * STREAM disable
+ */
+static int
+stream_disable(
+       struct parseunit *parse
+       )
+{
+       struct strioctl strioc;
+  
+       strioc.ic_cmd     = PARSEIOC_DISABLE;
+       strioc.ic_timout  = 0;
+       strioc.ic_dp      = (char *)0;
+       strioc.ic_len     = 0;
+
+       if (ioctl(parse->generic->io.fd, I_STR, (caddr_t)&strioc) == -1)
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: stream_disable: ioctl(fd, I_STR, PARSEIOC_DISABLE): %m", CLK_UNIT(parse->peer));
+               return 0;
+       }
+       parse->generic->io.clock_recv = local_receive; /* ok - parse input in daemon */
+       return 1;
+}
+
+/*--------------------------------------------------
+ * STREAM getfmt
+ */
+static int
+stream_getfmt(
+       struct parseunit *parse,
+       parsectl_t  *tcl
+       )
+{
+       struct strioctl strioc;
+  
+       strioc.ic_cmd     = PARSEIOC_GETFMT;
+       strioc.ic_timout  = 0;
+       strioc.ic_dp      = (char *)tcl;
+       strioc.ic_len     = sizeof (*tcl);
+       if (ioctl(parse->generic->io.fd, I_STR, (caddr_t)&strioc) == -1)
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: ioctl(fd, I_STR, PARSEIOC_GETFMT): %m", CLK_UNIT(parse->peer));
+               return 0;
+       }
+       return 1;
+}
+
+/*--------------------------------------------------
+ * STREAM setfmt
+ */
+static int
+stream_setfmt(
+       struct parseunit *parse,
+       parsectl_t  *tcl
+       )
+{
+       struct strioctl strioc;
+  
+       strioc.ic_cmd     = PARSEIOC_SETFMT;
+       strioc.ic_timout  = 0;
+       strioc.ic_dp      = (char *)tcl;
+       strioc.ic_len     = sizeof (*tcl);
+
+       if (ioctl(parse->generic->io.fd, I_STR, (caddr_t)&strioc) == -1)
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: stream_setfmt: ioctl(fd, I_STR, PARSEIOC_SETFMT): %m", CLK_UNIT(parse->peer));
+               return 0;
+       }
+       return 1;
+}
+
+
+/*--------------------------------------------------
+ * STREAM timecode
+ */
+static int
+stream_timecode(
+       struct parseunit *parse,
+       parsectl_t  *tcl
+       )
+{
+       struct strioctl strioc;
+  
+       strioc.ic_cmd     = PARSEIOC_TIMECODE;
+       strioc.ic_timout  = 0;
+       strioc.ic_dp      = (char *)tcl;
+       strioc.ic_len     = sizeof (*tcl);
+       
+       if (ioctl(parse->generic->io.fd, I_STR, (caddr_t)&strioc) == -1)
+       {
+               ERR(ERR_INTERNAL)
+                       msyslog(LOG_ERR, "PARSE receiver #%d: stream_timecode: ioctl(fd, I_STR, PARSEIOC_TIMECODE): %m", CLK_UNIT(parse->peer));
+               return 0;
+       }
+       clear_err(parse, ERR_INTERNAL);
+       return 1;
+}
+
+/*--------------------------------------------------
+ * STREAM receive
+ */
+static void
+stream_receive(
+       struct recvbuf *rbufp
+       )
+{
+       struct parseunit *parse = (struct parseunit *)((void *)rbufp->recv_srcclock);
+       parsetime_t parsetime;
+
+       if (!parse->peer)
+           return;
+
+       if (rbufp->recv_length != sizeof(parsetime_t))
+       {
+               ERR(ERR_BADIO)
+                       msyslog(LOG_ERR,"PARSE receiver #%d: stream_receive: bad size (got %d expected %d)",
+                               CLK_UNIT(parse->peer), rbufp->recv_length, (int)sizeof(parsetime_t));
+               parse_event(parse, CEVNT_BADREPLY);
+               return;
+       }
+       clear_err(parse, ERR_BADIO);
+  
+       memmove((caddr_t)&parsetime,
+               (caddr_t)rbufp->recv_buffer,
+               sizeof(parsetime_t));
+
+#ifdef DEBUG
+       if (debug > 3)
+         {
+           printf("PARSE receiver #%d: status %06x, state %08x, time %lx.%08lx, stime %lx.%08lx, ptime %lx.%08lx\n",
+                  CLK_UNIT(parse->peer),
+                  (unsigned int)parsetime.parse_status,
+                  (unsigned int)parsetime.parse_state,
+                  (unsigned long)parsetime.parse_time.tv.tv_sec,
+                  (unsigned long)parsetime.parse_time.tv.tv_usec,
+                  (unsigned long)parsetime.parse_stime.tv.tv_sec,
+                  (unsigned long)parsetime.parse_stime.tv.tv_usec,
+                  (unsigned long)parsetime.parse_ptime.tv.tv_sec,
+                  (unsigned long)parsetime.parse_ptime.tv.tv_usec);
+         }
+#endif
+
+       /*
+        * switch time stamp world - be sure to normalize small usec field
+        * errors.
+        */
+
+       cvt_ts(parsetime.parse_stime, "parse_stime");
+
+       if (PARSE_TIMECODE(parsetime.parse_state))
+       {
+           cvt_ts(parsetime.parse_time, "parse_time");
+       }
+
+       if (PARSE_PPS(parsetime.parse_state))
+           cvt_ts(parsetime.parse_ptime, "parse_ptime");
+
+       parse_process(parse, &parsetime);
+}
+#endif
+
+/*--------------------------------------------------
+ * local init
+ */
+static int
+local_init(
+       struct parseunit *parse
+       )
+{
+       return parse_ioinit(&parse->parseio);
+}
+
+/*--------------------------------------------------
+ * local end
+ */
+static void
+local_end(
+       struct parseunit *parse
+       )
+{
+       parse_ioend(&parse->parseio);
+}
+
+
+/*--------------------------------------------------
+ * local nop
+ */
+static int
+local_nop(
+       struct parseunit *parse
+       )
+{
+       return 1;
+}
+
+/*--------------------------------------------------
+ * local setcs
+ */
+static int
+local_setcs(
+       struct parseunit *parse,
+       parsectl_t  *tcl
+       )
+{
+       return parse_setcs(tcl, &parse->parseio);
+}
+
+/*--------------------------------------------------
+ * local getfmt
+ */
+static int
+local_getfmt(
+       struct parseunit *parse,
+       parsectl_t  *tcl
+       )
+{
+       return parse_getfmt(tcl, &parse->parseio);
+}
+
+/*--------------------------------------------------
+ * local setfmt
+ */
+static int
+local_setfmt(
+       struct parseunit *parse,
+       parsectl_t  *tcl
+       )
+{
+       return parse_setfmt(tcl, &parse->parseio);
+}
+
+/*--------------------------------------------------
+ * local timecode
+ */
+static int
+local_timecode(
+       struct parseunit *parse,
+       parsectl_t  *tcl
+       )
+{
+       return parse_timecode(tcl, &parse->parseio);
+}
+
+
+/*--------------------------------------------------
+ * local input
+ */
+static int
+local_input(
+       struct recvbuf *rbufp
+       )
+{
+       struct parseunit *parse = (struct parseunit *)((void *)rbufp->recv_srcclock);
+       int count;
+       unsigned char *s;
+       timestamp_t ts;
+
+       if (!parse->peer)
+               return 0;
+
+       /*
+        * eat all characters, parsing then and feeding complete samples
+        */
+       count = rbufp->recv_length;
+       s = (unsigned char *)rbufp->recv_buffer;
+       ts.fp = rbufp->recv_time;
+
+       while (count--)
+       {
+               if (parse_ioread(&parse->parseio, (unsigned int)(*s++), &ts))
+               {
+                       struct recvbuf *buf;
+
+                       /*
+                        * got something good to eat
+                        */
+                       if (!PARSE_PPS(parse->parseio.parse_dtime.parse_state))
+                       {
+#ifdef HAVE_PPSAPI
+                               if (parse->flags & PARSE_PPSCLOCK)
+                               {
+                                       struct timespec pps_timeout;
+                                       pps_info_t      pps_info;
+                               
+                                       pps_timeout.tv_sec  = 0;
+                                       pps_timeout.tv_nsec = 0;
+
+                                       if (time_pps_fetch(parse->ppshandle, PPS_TSFMT_TSPEC, &pps_info,
+                                                          &pps_timeout) == 0)
+                                       {
+                                               if (pps_info.assert_sequence + pps_info.clear_sequence != parse->ppsserial)
+                                               {
+                                                       double dtemp;
+
+                                                       struct timespec pts;
+                                                       /*
+                                                        * add PPS time stamp if available via ppsclock module
+                                                        * and not supplied already.
+                                                        */
+                                                       if (parse->flags & PARSE_CLEAR)
+                                                         pts = pps_info.clear_timestamp;
+                                                       else
+                                                         pts = pps_info.assert_timestamp;
+
+                                                       parse->parseio.parse_dtime.parse_ptime.fp.l_ui = pts.tv_sec + JAN_1970;
+
+                                                       dtemp = pts.tv_nsec / 1e9;
+                                                       if (dtemp < 0.) {
+                                                               dtemp += 1;
+                                                               parse->parseio.parse_dtime.parse_ptime.fp.l_ui--;
+                                                       }
+                                                       if (dtemp > 1.) {
+                                                               dtemp -= 1;
+                                                               parse->parseio.parse_dtime.parse_ptime.fp.l_ui++;
+                                                       }
+                                                       parse->parseio.parse_dtime.parse_ptime.fp.l_uf = dtemp * FRAC;
+
+                                                       parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
+#ifdef DEBUG
+                                                       if (debug > 3)
+                                                       {
+                                                               printf(
+                                                                      "parse: local_receive: fd %d PPSAPI seq %ld - PPS %s\n",
+                                                                      rbufp->fd,
+                                                                      (long)pps_info.assert_sequence + (long)pps_info.clear_sequence,
+                                                                      lfptoa(&parse->parseio.parse_dtime.parse_ptime.fp, 6));
+                                                       }
+#endif
+                                               }
+#ifdef DEBUG
+                                               else
+                                               {
+                                                       if (debug > 3)
+                                                       {
+                                                               printf(
+                                                                      "parse: local_receive: fd %d PPSAPI seq assert %ld, seq clear %ld - NO PPS event\n",
+                                                                      rbufp->fd,
+                                                                      (long)pps_info.assert_sequence, (long)pps_info.clear_sequence);
+                                                       }
+                                               }
+#endif
+                                               parse->ppsserial = pps_info.assert_sequence + pps_info.clear_sequence;
+                                       }
+#ifdef DEBUG
+                                       else
+                                       {
+                                               if (debug > 3)
+                                               {
+                                                       printf(
+                                                              "parse: local_receive: fd %d PPSAPI time_pps_fetch errno = %d\n",
+                                                              rbufp->fd,
+                                                              errno);
+                                               }
+                                       }
+#endif
+                               }
+#else
+#ifdef TIOCDCDTIMESTAMP
+                               struct timeval dcd_time;
+                               
+                               if (ioctl(parse->ppsfd, TIOCDCDTIMESTAMP, &dcd_time) != -1)
+                               {
+                                       l_fp tstmp;
+                                       
+                                       TVTOTS(&dcd_time, &tstmp);
+                                       tstmp.l_ui += JAN_1970;
+                                       L_SUB(&ts.fp, &tstmp);
+                                       if (ts.fp.l_ui == 0)
+                                       {
+#ifdef DEBUG
+                                               if (debug)
+                                               {
+                                                       printf(
+                                                              "parse: local_receive: fd %d DCDTIMESTAMP %s\n",
+                                                              parse->ppsfd,
+                                                              lfptoa(&tstmp, 6));
+                                                       printf(" sigio %s\n",
+                                                              lfptoa(&ts.fp, 6));
+                                               }
+#endif
+                                               parse->parseio.parse_dtime.parse_ptime.fp = tstmp;
+                                               parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
+                                       }
+                               }
+#else /* TIOCDCDTIMESTAMP */
+#if defined(HAVE_STRUCT_PPSCLOCKEV) && (defined(HAVE_CIOGETEV) || defined(HAVE_TIOCGPPSEV))
+                               if (parse->flags & PARSE_PPSCLOCK)
+                                 {
+                                   l_fp tts;
+                                   struct ppsclockev ev;
+
+#ifdef HAVE_CIOGETEV
+                                   if (ioctl(parse->ppsfd, CIOGETEV, (caddr_t)&ev) == 0)
+#endif
+#ifdef HAVE_TIOCGPPSEV
+                                   if (ioctl(parse->ppsfd, TIOCGPPSEV, (caddr_t)&ev) == 0)
+#endif
+                                       {
+                                         if (ev.serial != parse->ppsserial)
+                                           {
+                                             /*
+                                              * add PPS time stamp if available via ppsclock module
+                                              * and not supplied already.
+                                              */
+                                             if (!buftvtots((const char *)&ev.tv, &tts))
+                                               {
+                                                 ERR(ERR_BADDATA)
+                                                   msyslog(LOG_ERR,"parse: local_receive: timestamp conversion error (buftvtots) (ppsclockev.tv)");
+                                               }
+                                             else
+                                               {
+                                                 parse->parseio.parse_dtime.parse_ptime.fp = tts;
+                                                 parse->parseio.parse_dtime.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
+                                               }
+                                           }
+                                         parse->ppsserial = ev.serial;
+                                       }
+                                 }
+#endif
+#endif /* TIOCDCDTIMESTAMP */
+#endif /* !HAVE_PPSAPI */
+                       }
+                       if (count)
+                       {       /* simulate receive */
+                               buf = get_free_recv_buffer();
+                               if (buf != NULL) {
+                                       memmove((caddr_t)buf->recv_buffer,
+                                               (caddr_t)&parse->parseio.parse_dtime,
+                                               sizeof(parsetime_t));
+                                       buf->recv_length  = sizeof(parsetime_t);
+                                       buf->recv_time    = rbufp->recv_time;
+                                       buf->srcadr       = rbufp->srcadr;
+                                       buf->dstadr       = rbufp->dstadr;
+                                       buf->receiver     = rbufp->receiver;
+                                       buf->fd           = rbufp->fd;
+                                       buf->X_from_where = rbufp->X_from_where;
+                                       add_full_recv_buffer(buf);
+                               }
+                               parse_iodone(&parse->parseio);
+                       }
+                       else
+                       {
+                               memmove((caddr_t)rbufp->recv_buffer,
+                                       (caddr_t)&parse->parseio.parse_dtime,
+                                       sizeof(parsetime_t));
+                               parse_iodone(&parse->parseio);
+                               rbufp->recv_length = sizeof(parsetime_t);
+                               return 1; /* got something & in place return */
+                       }
+               }
+       }
+       return 0;               /* nothing to pass up */
+}
+
+/*--------------------------------------------------
+ * local receive
+ */
+static void
+local_receive(
+       struct recvbuf *rbufp
+       )
+{
+       struct parseunit *parse = (struct parseunit *)((void *)rbufp->recv_srcclock);
+       parsetime_t parsetime;
+
+       if (!parse->peer)
+           return;
+
+       if (rbufp->recv_length != sizeof(parsetime_t))
+       {
+               ERR(ERR_BADIO)
+                       msyslog(LOG_ERR,"PARSE receiver #%d: local_receive: bad size (got %d expected %d)",
+                               CLK_UNIT(parse->peer), rbufp->recv_length, (int)sizeof(parsetime_t));
+               parse_event(parse, CEVNT_BADREPLY);
+               return;
+       }
+       clear_err(parse, ERR_BADIO);
+  
+       memmove((caddr_t)&parsetime,
+               (caddr_t)rbufp->recv_buffer,
+               sizeof(parsetime_t));
+
+#ifdef DEBUG
+       if (debug > 3)
+         {
+           printf("PARSE receiver #%d: status %06x, state %08x, time(fp) %lx.%08lx, stime(fp) %lx.%08lx, ptime(fp) %lx.%08lx\n",
+                  CLK_UNIT(parse->peer),
+                  (unsigned int)parsetime.parse_status,
+                  (unsigned int)parsetime.parse_state,
+                  (unsigned long)parsetime.parse_time.fp.l_ui,
+                  (unsigned long)parsetime.parse_time.fp.l_uf,
+                  (unsigned long)parsetime.parse_stime.fp.l_ui,
+                  (unsigned long)parsetime.parse_stime.fp.l_uf,
+                  (unsigned long)parsetime.parse_ptime.fp.l_ui,
+                  (unsigned long)parsetime.parse_ptime.fp.l_uf);
+         }
+#endif
+
+       parse_process(parse, &parsetime);
+}
+
+/*--------------------------------------------------
+ * init_iobinding - find and initialize lower layers
+ */
+static bind_t *
+init_iobinding(
+       struct parseunit *parse
+       )
+{
+  bind_t *b = io_bindings;
+
+       while (b->bd_description != (char *)0)
+       {
+               if ((*b->bd_init)(parse))
+               {
+                       return b;
+               }
+               b++;
+       }
+       return (bind_t *)0;
+}
+
+/**===========================================================================
+ ** support routines
+ **/
+
+/*--------------------------------------------------
+ * convert a flag field to a string
+ */
+static char *
+parsestate(
+       u_long lstate,
+       char *buffer,
+       int size
+       )
+{
+       static struct bits
+       {
+               u_long      bit;
+               const char *name;
+       } flagstrings[] =
+         {
+                 { PARSEB_ANNOUNCE,   "DST SWITCH WARNING" },
+                 { PARSEB_POWERUP,    "NOT SYNCHRONIZED" },
+                 { PARSEB_NOSYNC,     "TIME CODE NOT CONFIRMED" },
+                 { PARSEB_DST,        "DST" },
+                 { PARSEB_UTC,        "UTC DISPLAY" },
+                 { PARSEB_LEAPADD,    "LEAP ADD WARNING" },
+                 { PARSEB_LEAPDEL,    "LEAP DELETE WARNING" },
+                 { PARSEB_LEAPSECOND, "LEAP SECOND" },
+                 { PARSEB_ALTERNATE,  "ALTERNATE ANTENNA" },
+                 { PARSEB_TIMECODE,   "TIME CODE" },
+                 { PARSEB_PPS,        "PPS" },
+                 { PARSEB_POSITION,   "POSITION" },
+                 { 0 }
+         };
+
+       static struct sbits
+       {
+               u_long      bit;
+               const char *name;
+       } sflagstrings[] =
+         {
+                 { PARSEB_S_LEAP,     "LEAP INDICATION" },
+                 { PARSEB_S_PPS,      "PPS SIGNAL" },
+                 { PARSEB_S_ANTENNA,  "ANTENNA" },
+                 { PARSEB_S_POSITION, "POSITION" },
+                 { 0 }
+         };
+       int i;
+       char *s, *t;
+
+
+       *buffer = '\0';
+       s = t = buffer;
+
+       i = 0;
+       while (flagstrings[i].bit)
+       {
+               if (flagstrings[i].bit & lstate)
+               {
+                       if (s != t)
+                               strncpy(t, "; ", BUFFER_SIZES(buffer, t, size));
+                       strncat(t, flagstrings[i].name, BUFFER_SIZES(buffer, t, size));
+                       t += strlen(t);
+               }
+               i++;
+       }
+
+       if (lstate & (PARSEB_S_LEAP|PARSEB_S_ANTENNA|PARSEB_S_PPS|PARSEB_S_POSITION))
+       {
+               if (s != t)
+                       strncpy(t, "; ", BUFFER_SIZES(buffer, t, size));
+
+               t += strlen(t);
+
+               strncpy(t, "(", BUFFER_SIZES(buffer, t, size));
+
+               s = t = t + strlen(t);
+
+               i = 0;
+               while (sflagstrings[i].bit)
+               {
+                       if (sflagstrings[i].bit & lstate)
+                       {
+                               if (t != s)
+                               {
+                                       strncpy(t, "; ", BUFFER_SIZES(buffer, t, size));
+                                       t += 2;
+                               }
+       
+                               strncpy(t, sflagstrings[i].name, BUFFER_SIZES(buffer, t, size));
+                               t += strlen(t);
+                       }
+                       i++;
+               }
+               strncpy(t, ")", BUFFER_SIZES(buffer, t, size));
+       }
+       return buffer;
+}
+
+/*--------------------------------------------------
+ * convert a status flag field to a string
+ */
+static char *
+parsestatus(
+       u_long lstate,
+       char *buffer,
+       int size
+       )
+{
+       static struct bits
+       {
+               u_long      bit;
+               const char *name;
+       } flagstrings[] =
+         {
+                 { CVT_OK,      "CONVERSION SUCCESSFUL" },
+                 { CVT_NONE,    "NO CONVERSION" },
+                 { CVT_FAIL,    "CONVERSION FAILED" },
+                 { CVT_BADFMT,  "ILLEGAL FORMAT" },
+                 { CVT_BADDATE, "DATE ILLEGAL" },
+                 { CVT_BADTIME, "TIME ILLEGAL" },
+                 { CVT_ADDITIONAL, "ADDITIONAL DATA" },
+                 { 0 }
+         };
+       int i;
+
+       *buffer = '\0';
+
+       i = 0;
+       while (flagstrings[i].bit)
+       {
+               if (flagstrings[i].bit & lstate)
+               {
+                       if (buffer[0])
+                               strncat(buffer, "; ", size);
+                       strncat(buffer, flagstrings[i].name, size);
+               }
+               i++;
+       }
+
+       return buffer;
+}
+
+/*--------------------------------------------------
+ * convert a clock status flag field to a string
+ */
+static const char *
+clockstatus(
+       u_long lstate
+       )
+{
+       static char buffer[20];
+       static struct status
+       {
+               u_long      value;
+               const char *name;
+       } flagstrings[] =
+         {
+                 { CEVNT_NOMINAL, "NOMINAL" },
+                 { CEVNT_TIMEOUT, "NO RESPONSE" },
+                 { CEVNT_BADREPLY,"BAD FORMAT" },
+                 { CEVNT_FAULT,   "FAULT" },
+                 { CEVNT_PROP,    "PROPAGATION DELAY" },
+                 { CEVNT_BADDATE, "ILLEGAL DATE" },
+                 { CEVNT_BADTIME, "ILLEGAL TIME" },
+                 { (unsigned)~0L }
+         };
+       int i;
+
+       i = 0;
+       while (flagstrings[i].value != ~0)
+       {
+               if (flagstrings[i].value == lstate)
+               {
+                       return flagstrings[i].name;
+               }
+               i++;
+       }
+
+       snprintf(buffer, sizeof(buffer), "unknown #%ld", (u_long)lstate);
+
+       return buffer;
+}
+
+
+/*--------------------------------------------------
+ * l_mktime - make representation of a relative time
+ */
+static char *
+l_mktime(
+       u_long delta
+       )
+{
+       u_long tmp, m, s;
+       static char buffer[40];
+       char *t;
+
+       buffer[0] = '\0';
+
+       if ((tmp = delta / (60*60*24)) != 0)
+       {
+               snprintf(buffer, BUFFER_SIZE(buffer, buffer), "%ldd+", (u_long)tmp);
+               delta -= tmp * 60*60*24;
+       }
+
+       s = delta % 60;
+       delta /= 60;
+       m = delta % 60;
+       delta /= 60;
+
+       t = buffer + strlen(buffer);
+
+       snprintf(t, BUFFER_SIZE(buffer, t), "%02d:%02d:%02d",
+                (int)delta, (int)m, (int)s);
+
+       return buffer;
+}
+
+
+/*--------------------------------------------------
+ * parse_statistics - list summary of clock states
+ */
+static void
+parse_statistics(
+       struct parseunit *parse
+       )
+{
+       int i;
+
+       NLOG(NLOG_CLOCKSTATIST) /* conditional if clause for conditional syslog */
+               {
+                       msyslog(LOG_INFO, "PARSE receiver #%d: running time: %s",
+                               CLK_UNIT(parse->peer),
+                               l_mktime(current_time - parse->generic->timestarted));
+
+                       msyslog(LOG_INFO, "PARSE receiver #%d: current status: %s",
+                               CLK_UNIT(parse->peer),
+                               clockstatus(parse->generic->currentstatus));
+
+                       for (i = 0; i <= CEVNT_MAX; i++)
+                       {
+                               u_long s_time;
+                               u_long percent, d = current_time - parse->generic->timestarted;
+
+                               percent = s_time = PARSE_STATETIME(parse, i);
+
+                               while (((u_long)(~0) / 10000) < percent)
+                               {
+                                       percent /= 10;
+                                       d       /= 10;
+                               }
+
+                               if (d)
+                                   percent = (percent * 10000) / d;
+                               else
+                                   percent = 10000;
+
+                               if (s_time)
+                                   msyslog(LOG_INFO, "PARSE receiver #%d: state %18s: %13s (%3ld.%02ld%%)",
+                                           CLK_UNIT(parse->peer),
+                                           clockstatus((unsigned int)i),
+                                           l_mktime(s_time),
+                                           percent / 100, percent % 100);
+                       }
+               }
+}
+
+/*--------------------------------------------------
+ * cparse_statistics - wrapper for statistics call
+ */
+static void
+cparse_statistics(
+        struct parseunit *parse
+       )
+{
+       if (parse->laststatistic + PARSESTATISTICS < current_time)
+               parse_statistics(parse);
+       parse->laststatistic = current_time;
+}
+
+/**===========================================================================
+ ** ntp interface routines
+ **/
+
+/*--------------------------------------------------
+ * parse_shutdown - shut down a PARSE clock
+ */
+static void
+parse_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct parseunit *parse = (struct parseunit *)0;
+
+       if (peer && peer->procptr)
+               parse = (struct parseunit *)peer->procptr->unitptr;
+
+       if (!parse)
+       {
+               /* nothing to clean up */
+               return;
+       }
+
+        if (!parse->peer)
+       {
+               msyslog(LOG_INFO, "PARSE receiver #%d: INTERNAL ERROR - unit already inactive - shutdown ignored", unit);
+               return;
+       }
+
+#ifdef HAVE_PPSAPI
+       if (parse->flags & PARSE_PPSCLOCK)
+       {
+               (void)time_pps_destroy(parse->ppshandle);
+       }
+#endif
+       if (parse->generic->io.fd != parse->ppsfd && parse->ppsfd != -1)
+               (void)close(parse->ppsfd);  /* close separate PPS source */
+
+       /*
+        * print statistics a last time and
+        * stop statistics machine
+        */
+       parse_statistics(parse);
+
+       if (parse->parse_type->cl_end)
+       {
+               parse->parse_type->cl_end(parse);
+       }
+       
+       /*
+        * cleanup before leaving this world
+        */
+       if (parse->binding)
+           PARSE_END(parse);
+
+       /*
+        * Tell the I/O module to turn us off.  We're history.
+        */
+       io_closeclock(&parse->generic->io);
+
+       free_varlist(parse->kv);
+  
+       NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
+               msyslog(LOG_INFO, "PARSE receiver #%d: reference clock \"%s\" removed",
+                       CLK_UNIT(parse->peer), parse->parse_type->cl_description);
+
+       parse->peer = (struct peer *)0; /* unused now */
+       peer->procptr->unitptr = (caddr_t)0;
+       free(parse);
+}
+
+#ifdef HAVE_PPSAPI
+/*----------------------------------------
+ * set up HARDPPS via PPSAPI
+ */
+static void
+parse_hardpps(
+             struct parseunit *parse,
+             int mode
+             )
+{
+        if (parse->hardppsstate == mode)
+               return;
+
+       if (CLK_PPS(parse->peer) && (parse->flags & PARSE_PPSKERNEL)) {
+               int     i = 0;
+
+               if (mode == PARSE_HARDPPS_ENABLE) 
+                       {
+                               if (parse->flags & PARSE_CLEAR)
+                                       i = PPS_CAPTURECLEAR;
+                               else
+                                       i = PPS_CAPTUREASSERT;
+                       }
+               
+               if (time_pps_kcbind(parse->ppshandle, PPS_KC_HARDPPS, i,
+                   PPS_TSFMT_TSPEC) < 0) {
+                       msyslog(LOG_ERR, "PARSE receiver #%d: time_pps_kcbind failed: %m",
+                               CLK_UNIT(parse->peer));
+               } else {
+                       NLOG(NLOG_CLOCKINFO)
+                               msyslog(LOG_INFO, "PARSE receiver #%d: kernel PPS synchronisation %sabled",
+                                       CLK_UNIT(parse->peer), (mode == PARSE_HARDPPS_ENABLE) ? "en" : "dis");
+                       /*
+                        * tell the rest, that we have a kernel PPS source, iff we ever enable HARDPPS
+                        */
+                       if (mode == PARSE_HARDPPS_ENABLE)
+                               pps_enable = 1;
+               }
+       }
+
+       parse->hardppsstate = mode;
+}
+
+/*----------------------------------------
+ * set up PPS via PPSAPI
+ */
+static int
+parse_ppsapi(
+            struct parseunit *parse
+       )
+{
+       int cap, mode, mode1;
+       char *cp;
+       
+       parse->flags &= ~PARSE_PPSCLOCK;
+
+       if (time_pps_getcap(parse->ppshandle, &cap) < 0) {
+               msyslog(LOG_ERR, "PARSE receiver #%d: parse_ppsapi: time_pps_getcap failed: %m",
+                       CLK_UNIT(parse->peer));
+               
+               return 0;
+       }
+
+       if (time_pps_getparams(parse->ppshandle, &parse->ppsparams) < 0) {
+               msyslog(LOG_ERR, "PARSE receiver #%d: parse_ppsapi: time_pps_getparams failed: %m",
+                       CLK_UNIT(parse->peer));
+               return 0;
+       }
+
+       /* nb. only turn things on, if someone else has turned something
+        *      on before we get here, leave it alone!
+        */
+
+       if (parse->flags & PARSE_CLEAR) {
+               cp = "CLEAR";
+               mode = PPS_CAPTURECLEAR;
+               mode1 = PPS_OFFSETCLEAR;
+       } else {
+               cp = "ASSERT";
+               mode = PPS_CAPTUREASSERT;
+               mode1 = PPS_OFFSETASSERT;
+       }
+
+       msyslog(LOG_INFO, "PARSE receiver #%d: initializing PPS to %s",
+               CLK_UNIT(parse->peer), cp);
+
+       if (!(mode & cap)) {
+         msyslog(LOG_ERR, "PARSE receiver #%d: FAILED to initialize PPS to %s (PPS API capabilities=0x%x)",
+                 CLK_UNIT(parse->peer), cp, cap);
+       
+               return 0;
+       }
+
+       if (!(mode1 & cap)) {
+         msyslog(LOG_WARNING, "PARSE receiver #%d: Cannot set PPS_%sCLEAR, this will increase jitter (PPS API capabilities=0x%x)",
+                 CLK_UNIT(parse->peer), cp, cap);
+               mode1 = 0;
+       } else {
+               if (mode1 == PPS_OFFSETCLEAR) 
+                       {
+                               parse->ppsparams.clear_offset.tv_sec = -parse->ppsphaseadjust;
+                               parse->ppsparams.clear_offset.tv_nsec = -1e9*(parse->ppsphaseadjust - (long)parse->ppsphaseadjust);
+                       }
+         
+               if (mode1 == PPS_OFFSETASSERT)
+                       {
+                               parse->ppsparams.assert_offset.tv_sec = -parse->ppsphaseadjust;
+                               parse->ppsparams.assert_offset.tv_nsec = -1e9*(parse->ppsphaseadjust - (long)parse->ppsphaseadjust);
+                       }
+       }
+       
+       /* only set what is legal */
+
+       parse->ppsparams.mode = (mode | mode1 | PPS_TSFMT_TSPEC) & cap;
+
+       if (time_pps_setparams(parse->ppshandle, &parse->ppsparams) < 0) {
+         msyslog(LOG_ERR, "PARSE receiver #%d: FAILED set PPS parameters: %m",
+                 CLK_UNIT(parse->peer));
+               return 0;
+       }
+
+       parse->flags |= PARSE_PPSCLOCK;
+       return 1;
+}
+#else
+#define parse_hardpps(_PARSE_, _MODE_) /* empty */
+#endif
+
+/*--------------------------------------------------
+ * parse_start - open the PARSE devices and initialize data for processing
+ */
+static int
+parse_start(
+       int sysunit,
+       struct peer *peer
+       )
+{
+       u_int unit;
+       int fd232;
+#ifdef HAVE_TERMIOS
+       struct termios tio;             /* NEEDED FOR A LONG TIME ! */
+#endif
+#ifdef HAVE_SYSV_TTYS
+       struct termio tio;              /* NEEDED FOR A LONG TIME ! */
+#endif
+       struct parseunit * parse;
+       char parsedev[sizeof(PARSEDEVICE)+20];
+       char parseppsdev[sizeof(PARSEPPSDEVICE)+20];
+       parsectl_t tmp_ctl;
+       u_int type;
+
+       /*
+        * get out Copyright information once
+        */
+       if (!notice)
+        {
+               NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
+                       msyslog(LOG_INFO, "NTP PARSE support: Copyright (c) 1989-2006, Frank Kardel");
+               notice = 1;
+       }
+
+       type = CLK_TYPE(peer);
+       unit = CLK_UNIT(peer);
+
+       if ((type == ~0) || (parse_clockinfo[type].cl_description == (char *)0))
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: unsupported clock type %d (max %d)",
+                       unit, CLK_REALTYPE(peer), ncltypes-1);
+               return 0;
+       }
+
+       /*
+        * Unit okay, attempt to open the device.
+        */
+       (void) snprintf(parsedev, sizeof(parsedev), PARSEDEVICE, unit);
+       (void) snprintf(parseppsdev, sizeof(parsedev), PARSEPPSDEVICE, unit);
+
+#ifndef O_NOCTTY
+#define O_NOCTTY 0
+#endif
+
+       fd232 = open(parsedev, O_RDWR | O_NOCTTY
+#ifdef O_NONBLOCK
+                    | O_NONBLOCK
+#endif
+                    , 0777);
+
+       if (fd232 == -1)
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: open of %s failed: %m", unit, parsedev);
+               return 0;
+       }
+
+       parse = (struct parseunit *)emalloc(sizeof(struct parseunit));
+
+       memset((char *)parse, 0, sizeof(struct parseunit));
+
+       parse->generic = peer->procptr;  /* link up */
+       parse->generic->unitptr = (caddr_t)parse; /* link down */
+
+       /*
+        * Set up the structures
+        */
+       parse->generic->timestarted    = current_time;
+       parse->lastchange     = current_time;
+
+       parse->flags          = 0;
+       parse->pollneeddata   = 0;
+       parse->laststatistic  = current_time;
+       parse->lastformat     = (unsigned short)~0;     /* assume no format known */
+       parse->timedata.parse_status = (unsigned short)~0;      /* be sure to mark initial status change */
+       parse->lastmissed     = 0;      /* assume got everything */
+       parse->ppsserial      = 0;
+       parse->ppsfd          = -1;
+       parse->localdata      = (void *)0;
+       parse->localstate     = 0;
+       parse->kv             = (struct ctl_var *)0;
+
+       clear_err(parse, ERR_ALL);
+  
+       parse->parse_type     = &parse_clockinfo[type];
+       
+       parse->maxunsync      = parse->parse_type->cl_maxunsync;
+
+       parse->generic->fudgetime1 = parse->parse_type->cl_basedelay;
+
+       parse->generic->fudgetime2 = 0.0;
+       parse->ppsphaseadjust = parse->generic->fudgetime2;
+
+       parse->generic->clockdesc  = parse->parse_type->cl_description;
+
+       peer->rootdelay       = parse->parse_type->cl_rootdelay;
+       peer->sstclktype      = parse->parse_type->cl_type;
+       peer->precision       = sys_precision;
+       
+       peer->stratum         = STRATUM_REFCLOCK;
+
+       if (peer->stratum <= 1)
+           memmove((char *)&parse->generic->refid, parse->parse_type->cl_id, 4);
+       else
+           parse->generic->refid = htonl(PARSEHSREFID);
+       
+       parse->generic->io.fd = fd232;
+       
+       parse->peer = peer;             /* marks it also as busy */
+
+       /*
+        * configure terminal line
+        */
+       if (TTY_GETATTR(fd232, &tio) == -1)
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcgetattr(%d, &tio): %m", unit, fd232);
+               parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
+               return 0;
+       }
+       else
+       {
+#ifndef _PC_VDISABLE
+               memset((char *)tio.c_cc, 0, sizeof(tio.c_cc));
+#else
+               int disablec;
+               errno = 0;              /* pathconf can deliver -1 without changing errno ! */
+
+               disablec = fpathconf(parse->generic->io.fd, _PC_VDISABLE);
+               if (disablec == -1 && errno)
+               {
+                       msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: fpathconf(fd, _PC_VDISABLE): %m", CLK_UNIT(parse->peer));
+                       memset((char *)tio.c_cc, 0, sizeof(tio.c_cc)); /* best guess */
+               }
+               else
+                   if (disablec != -1)
+                       memset((char *)tio.c_cc, disablec, sizeof(tio.c_cc));
+#endif
+
+#if defined (VMIN) || defined(VTIME)
+               if ((parse_clockinfo[type].cl_lflag & ICANON) == 0)
+               {
+#ifdef VMIN
+                       tio.c_cc[VMIN]   = 1;
+#endif
+#ifdef VTIME
+                       tio.c_cc[VTIME]  = 0;
+#endif
+               }
+#endif
+
+               tio.c_cflag = parse_clockinfo[type].cl_cflag;
+               tio.c_iflag = parse_clockinfo[type].cl_iflag;
+               tio.c_oflag = parse_clockinfo[type].cl_oflag;
+               tio.c_lflag = parse_clockinfo[type].cl_lflag;
+       
+
+#ifdef HAVE_TERMIOS
+               if ((cfsetospeed(&tio, parse_clockinfo[type].cl_speed) == -1) ||
+                   (cfsetispeed(&tio, parse_clockinfo[type].cl_speed) == -1))
+               {
+                       msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcset{i,o}speed(&tio, speed): %m", unit);
+                       parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
+                       return 0;
+               }
+#else
+               tio.c_cflag     |= parse_clockinfo[type].cl_speed;
+#endif
+
+               /*
+                * set up pps device
+                * if the PARSEPPSDEVICE can be opened that will be used
+                * for PPS else PARSEDEVICE will be used
+                */
+               parse->ppsfd = open(parseppsdev, O_RDWR | O_NOCTTY
+#ifdef O_NONBLOCK
+                                   | O_NONBLOCK
+#endif
+                                   , 0777);
+
+               if (parse->ppsfd == -1)
+               {
+                       parse->ppsfd = fd232;
+               }
+
+/*
+ * Linux PPS - the old way
+ */
+#if defined(HAVE_TIO_SERIAL_STUFF)             /* Linux hack: define PPS interface */
+               {
+                       struct serial_struct    ss;
+                       if (ioctl(parse->ppsfd, TIOCGSERIAL, &ss) < 0 ||
+                           (
+#ifdef ASYNC_LOW_LATENCY
+                            ss.flags |= ASYNC_LOW_LATENCY,
+#endif
+#ifndef HAVE_PPSAPI
+#ifdef ASYNC_PPS_CD_NEG
+                            ss.flags |= ASYNC_PPS_CD_NEG,
+#endif
+#endif
+                            ioctl(parse->ppsfd, TIOCSSERIAL, &ss)) < 0) {
+                               msyslog(LOG_NOTICE, "refclock_parse: TIOCSSERIAL fd %d, %m", parse->ppsfd);
+                               msyslog(LOG_NOTICE,
+                                       "refclock_parse: optional PPS processing not available");
+                       } else {
+                               parse->flags    |= PARSE_PPSCLOCK;
+#ifdef ASYNC_PPS_CD_NEG
+                               NLOG(NLOG_CLOCKINFO)
+                                 msyslog(LOG_INFO,
+                                         "refclock_parse: PPS detection on");
+#endif
+                       }
+               }
+#endif
+
+/*
+ * SUN the Solaris way
+ */
+#ifdef HAVE_TIOCSPPS                   /* SUN PPS support */
+               if (CLK_PPS(parse->peer))
+                   {
+                       int i = 1;
+                   
+                       if (ioctl(parse->ppsfd, TIOCSPPS, (caddr_t)&i) == 0)
+                           {
+                               parse->flags |= PARSE_PPSCLOCK;
+                           }
+                   }
+#endif
+
+/*
+ * PPS via PPSAPI
+ */
+#if defined(HAVE_PPSAPI)
+               parse->hardppsstate = PARSE_HARDPPS_DISABLE;
+               if (CLK_PPS(parse->peer))
+               {
+                 if (time_pps_create(parse->ppsfd, &parse->ppshandle) < 0) 
+                   {
+                     msyslog(LOG_NOTICE, "PARSE receiver #%d: parse_start: could not set up PPS: %m", CLK_UNIT(parse->peer));
+                   }
+                 else
+                   {
+                     parse_ppsapi(parse);
+                   }
+               }
+#endif
+
+               if (TTY_SETATTR(fd232, &tio) == -1)
+               {
+                       msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: tcsetattr(%d, &tio): %m", unit, fd232);
+                       parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
+                       return 0;
+               }
+       }
+
+       /*
+        * pick correct input machine
+        */
+       parse->generic->io.srcclock = (caddr_t)parse;
+       parse->generic->io.datalen = 0;
+       
+       parse->binding = init_iobinding(parse);
+
+       if (parse->binding == (bind_t *)0)
+               {
+                       msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: io sub system initialisation failed.", CLK_UNIT(parse->peer));
+                       parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
+                       return 0;                       /* well, ok - special initialisation broke */
+               }      
+
+       parse->generic->io.clock_recv = parse->binding->bd_receive; /* pick correct receive routine */
+       parse->generic->io.io_input   = parse->binding->bd_io_input; /* pick correct input routine */
+
+       /*
+        * as we always(?) get 8 bit chars we want to be
+        * sure, that the upper bits are zero for less
+        * than 8 bit I/O - so we pass that information on.
+        * note that there can be only one bit count format
+        * per file descriptor
+        */
+
+       switch (tio.c_cflag & CSIZE)
+       {
+           case CS5:
+               tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS5;
+               break;
+
+           case CS6:
+               tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS6;
+               break;
+
+           case CS7:
+               tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS7;
+               break;
+
+           case CS8:
+               tmp_ctl.parsesetcs.parse_cs = PARSE_IO_CS8;
+               break;
+       }
+
+       if (!PARSE_SETCS(parse, &tmp_ctl))
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: parse_setcs() FAILED.", unit);
+               parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
+               return 0;                       /* well, ok - special initialisation broke */
+       }
+  
+       strncpy(tmp_ctl.parseformat.parse_buffer, parse->parse_type->cl_format, sizeof(tmp_ctl.parseformat.parse_buffer));
+       tmp_ctl.parseformat.parse_count = strlen(tmp_ctl.parseformat.parse_buffer);
+
+       if (!PARSE_SETFMT(parse, &tmp_ctl))
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: parse_start: parse_setfmt() FAILED.", unit);
+               parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
+               return 0;                       /* well, ok - special initialisation broke */
+       }
+  
+       /*
+        * get rid of all IO accumulated so far
+        */
+#ifdef HAVE_TERMIOS
+       (void) tcflush(parse->generic->io.fd, TCIOFLUSH);
+#else
+#if defined(TCFLSH) && defined(TCIOFLUSH)
+       {
+               int flshcmd = TCIOFLUSH;
+
+               (void) ioctl(parse->generic->io.fd, TCFLSH, (caddr_t)&flshcmd);
+       }
+#endif
+#endif
+
+       /*
+        * try to do any special initializations
+        */
+       if (parse->parse_type->cl_init)
+               {
+                       if (parse->parse_type->cl_init(parse))
+                               {
+                                       parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
+                                       return 0;               /* well, ok - special initialisation broke */
+                               }
+               }
+       
+       /*
+        * Insert in async io device list.
+        */
+       if (!io_addclock(&parse->generic->io))
+        {
+               msyslog(LOG_ERR,
+                       "PARSE receiver #%d: parse_start: addclock %s fails (ABORT - clock type requires async io)", CLK_UNIT(parse->peer), parsedev);
+               parse_shutdown(CLK_UNIT(parse->peer), peer); /* let our cleaning staff do the work */
+               return 0;
+       }
+
+       /*
+        * print out configuration
+        */
+       NLOG(NLOG_CLOCKINFO)
+               {
+                       /* conditional if clause for conditional syslog */
+                       msyslog(LOG_INFO, "PARSE receiver #%d: reference clock \"%s\" (I/O device %s, PPS device %s) added",
+                               CLK_UNIT(parse->peer),
+                               parse->parse_type->cl_description, parsedev,
+                               (parse->ppsfd != parse->generic->io.fd) ? parseppsdev : parsedev);
+
+                       msyslog(LOG_INFO, "PARSE receiver #%d: Stratum %d, trust time %s, precision %d",
+                               CLK_UNIT(parse->peer),
+                               parse->peer->stratum,
+                               l_mktime(parse->maxunsync), parse->peer->precision);
+
+                       msyslog(LOG_INFO, "PARSE receiver #%d: rootdelay %.6f s, phase adjustment %.6f s, PPS phase adjustment %.6f s, %s IO handling",
+                               CLK_UNIT(parse->peer),
+                               parse->parse_type->cl_rootdelay,
+                               parse->generic->fudgetime1,
+                               parse->ppsphaseadjust,
+                                parse->binding->bd_description);
+
+                       msyslog(LOG_INFO, "PARSE receiver #%d: Format recognition: %s", CLK_UNIT(parse->peer),
+                               parse->parse_type->cl_format);
+                        msyslog(LOG_INFO, "PARSE receiver #%d: %sPPS support%s", CLK_UNIT(parse->peer),
+                               CLK_PPS(parse->peer) ? "" : "NO ",
+                               CLK_PPS(parse->peer) ?
+#ifdef PPS_METHOD
+                               " (implementation " PPS_METHOD ")"
+#else
+                               ""
+#endif
+                               : ""
+                               );
+               }
+
+       return 1;
+}
+
+/*--------------------------------------------------
+ * parse_ctl - process changes on flags/time values
+ */
+static void
+parse_ctl(
+           struct parseunit *parse,
+           struct refclockstat *in
+           )
+{
+        if (in)
+       {
+               if (in->haveflags & (CLK_HAVEFLAG1|CLK_HAVEFLAG2|CLK_HAVEFLAG3|CLK_HAVEFLAG4))
+               {
+                 parse->flags = (parse->flags & ~(CLK_FLAG1|CLK_FLAG2|CLK_FLAG3|CLK_FLAG4)) |
+                   (in->flags & (CLK_FLAG1|CLK_FLAG2|CLK_FLAG3|CLK_FLAG4));
+#if defined(HAVE_PPSAPI)
+                 if (CLK_PPS(parse->peer))
+                   {
+                     parse_ppsapi(parse);
+                   }
+#endif
+               }
+               
+               if (in->haveflags & CLK_HAVETIME1)
+                {
+                 parse->generic->fudgetime1 = in->fudgetime1;
+                 msyslog(LOG_INFO, "PARSE receiver #%d: new phase adjustment %.6f s",
+                         CLK_UNIT(parse->peer),
+                         parse->generic->fudgetime1);
+               }
+               
+               if (in->haveflags & CLK_HAVETIME2)
+                {
+                 parse->generic->fudgetime2 = in->fudgetime2;
+                 if (parse->flags & PARSE_TRUSTTIME) 
+                   {
+                     parse->maxunsync = (u_long)ABS(in->fudgetime2);
+                     msyslog(LOG_INFO, "PARSE receiver #%d: new trust time %s",
+                             CLK_UNIT(parse->peer),
+                             l_mktime(parse->maxunsync));
+                   }
+                 else
+                   {
+                     parse->ppsphaseadjust = in->fudgetime2;
+                     msyslog(LOG_INFO, "PARSE receiver #%d: new PPS phase adjustment %.6f s",
+                         CLK_UNIT(parse->peer),
+                             parse->ppsphaseadjust);
+#if defined(HAVE_PPSAPI)
+                     if (CLK_PPS(parse->peer))
+                     {
+                             parse_ppsapi(parse);
+                     }
+#endif
+                   }
+               }
+       }
+}
+
+/*--------------------------------------------------
+ * parse_poll - called by the transmit procedure
+ */
+static void
+parse_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct parseunit *parse = (struct parseunit *)peer->procptr->unitptr;
+
+       if (peer != parse->peer)
+       {
+               msyslog(LOG_ERR,
+                       "PARSE receiver #%d: poll: INTERNAL: peer incorrect",
+                       unit);
+               return;
+       }
+
+       /*
+        * Update clock stat counters
+        */
+       parse->generic->polls++;
+
+       if (parse->pollneeddata && 
+           ((current_time - parse->pollneeddata) > (1<<(max(min(parse->peer->hpoll, parse->peer->ppoll), parse->peer->minpoll)))))
+       {
+               /*
+                * start worrying when exceeding a poll inteval
+                * bad news - didn't get a response last time
+                */
+               parse->lastmissed = current_time;
+               parse_event(parse, CEVNT_TIMEOUT);
+               
+               ERR(ERR_NODATA)
+                       msyslog(LOG_WARNING, "PARSE receiver #%d: no data from device within poll interval (check receiver / wiring)", CLK_UNIT(parse->peer));
+       }
+
+       /*
+        * we just mark that we want the next sample for the clock filter
+        */
+       parse->pollneeddata = current_time;
+
+       if (parse->parse_type->cl_poll)
+       {
+               parse->parse_type->cl_poll(parse);
+       }
+
+       cparse_statistics(parse);
+
+       return;
+}
+
+#define LEN_STATES 300         /* length of state string */
+
+/*--------------------------------------------------
+ * parse_control - set fudge factors, return statistics
+ */
+static void
+parse_control(
+       int unit,
+       struct refclockstat *in,
+       struct refclockstat *out,
+       struct peer *peer
+       )
+{
+        struct parseunit *parse = (struct parseunit *)peer->procptr->unitptr;
+       parsectl_t tmpctl;
+
+       static char outstatus[400];     /* status output buffer */
+
+       if (out)
+       {
+               out->lencode       = 0;
+               out->p_lastcode    = 0;
+               out->kv_list       = (struct ctl_var *)0;
+       }
+
+       if (!parse || !parse->peer)
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: parse_control: unit invalid (UNIT INACTIVE)",
+                       unit);
+               return;
+       }
+
+       unit = CLK_UNIT(parse->peer);
+
+       /*
+        * handle changes
+        */
+       parse_ctl(parse, in);
+               
+       /*
+        * supply data
+        */
+       if (out)
+       {
+               u_long sum = 0;
+               char *tt, *start;
+               int i;
+
+               outstatus[0] = '\0';
+
+               out->type       = REFCLK_PARSE;
+
+               /*
+                * keep fudgetime2 in sync with TRUSTTIME/MAXUNSYNC flag1
+                */
+               parse->generic->fudgetime2 = (parse->flags & PARSE_TRUSTTIME) ? (double)parse->maxunsync : parse->ppsphaseadjust;
+
+               /*
+                * figure out skew between PPS and RS232 - just for informational
+                * purposes
+                */
+               if (PARSE_SYNC(parse->timedata.parse_state))
+               {
+                       if (PARSE_PPS(parse->timedata.parse_state) && PARSE_TIMECODE(parse->timedata.parse_state))
+                       {
+                               l_fp off;
+
+                               /*
+                                * we have a PPS and RS232 signal - calculate the skew
+                                * WARNING: assumes on TIMECODE == PULSE (timecode after pulse)
+                                */
+                               off = parse->timedata.parse_stime.fp;
+                               L_SUB(&off, &parse->timedata.parse_ptime.fp); /* true offset */
+                               tt = add_var(&out->kv_list, 80, RO);
+                               snprintf(tt, 80, "refclock_ppsskew=%s", lfptoms(&off, 6));
+                       }
+               }
+
+               if (PARSE_PPS(parse->timedata.parse_state))
+               {
+                       tt = add_var(&out->kv_list, 80, RO|DEF);
+                       snprintf(tt, 80, "refclock_ppstime=\"%s\"", gmprettydate(&parse->timedata.parse_ptime.fp));
+               }
+
+               start = tt = add_var(&out->kv_list, 128, RO|DEF);
+               snprintf(tt, 128, "refclock_time=\"");
+               tt += strlen(tt);
+
+               if (parse->timedata.parse_time.fp.l_ui == 0)
+               {
+                       strncpy(tt, "<UNDEFINED>\"", BUFFER_SIZES(start, tt, 128));
+               }
+               else
+               {
+                       snprintf(tt, 128, "%s\"", gmprettydate(&parse->timedata.parse_time.fp));
+               }
+
+               if (!PARSE_GETTIMECODE(parse, &tmpctl))
+               {
+                       ERR(ERR_INTERNAL)
+                               msyslog(LOG_ERR, "PARSE receiver #%d: parse_control: parse_timecode() FAILED", unit);
+               }
+               else
+               {
+                       start = tt = add_var(&out->kv_list, 512, RO|DEF);
+                       snprintf(tt, 512, "refclock_status=\"");
+                       tt += strlen(tt);
+
+                       /*
+                        * copy PPS flags from last read transaction (informational only)
+                        */
+                       tmpctl.parsegettc.parse_state |= parse->timedata.parse_state &
+                               (PARSEB_PPS|PARSEB_S_PPS);
+
+                       (void) parsestate(tmpctl.parsegettc.parse_state, tt, BUFFER_SIZES(start, tt, 512));
+
+                       strncat(tt, "\"", BUFFER_SIZES(start, tt, 512));
+
+                       if (tmpctl.parsegettc.parse_count)
+                           mkascii(outstatus+strlen(outstatus), (int)(sizeof(outstatus)- strlen(outstatus) - 1),
+                                   tmpctl.parsegettc.parse_buffer, (unsigned)(tmpctl.parsegettc.parse_count));
+
+               }
+       
+               tmpctl.parseformat.parse_format = tmpctl.parsegettc.parse_format;
+       
+               if (!PARSE_GETFMT(parse, &tmpctl))
+               {
+                       ERR(ERR_INTERNAL)
+                               msyslog(LOG_ERR, "PARSE receiver #%d: parse_control: parse_getfmt() FAILED", unit);
+               }
+               else
+               {
+                       tt = add_var(&out->kv_list, 80, RO|DEF);
+                       snprintf(tt, 80, "refclock_format=\"");
+
+                       strncat(tt, tmpctl.parseformat.parse_buffer, tmpctl.parseformat.parse_count);
+                       strncat(tt,"\"", 80);
+               }
+
+               /*
+                * gather state statistics
+                */
+
+               start = tt = add_var(&out->kv_list, LEN_STATES, RO|DEF);
+               strncpy(tt, "refclock_states=\"", LEN_STATES);
+               tt += strlen(tt);
+
+               for (i = 0; i <= CEVNT_MAX; i++)
+               {
+                       u_long s_time;
+                       u_long d = current_time - parse->generic->timestarted;
+                       u_long percent;
+
+                       percent = s_time = PARSE_STATETIME(parse, i);
+
+                       while (((u_long)(~0) / 10000) < percent)
+                       {
+                               percent /= 10;
+                               d       /= 10;
+                       }
+       
+                       if (d)
+                           percent = (percent * 10000) / d;
+                       else
+                           percent = 10000;
+
+                       if (s_time)
+                       {
+                               char item[80];
+                               int count;
+                               
+                               snprintf(item, 80, "%s%s%s: %s (%d.%02d%%)",
+                                       sum ? "; " : "",
+                                       (parse->generic->currentstatus == i) ? "*" : "",
+                                       clockstatus((unsigned int)i),
+                                       l_mktime(s_time),
+                                       (int)(percent / 100), (int)(percent % 100));
+                               if ((count = strlen(item)) < (LEN_STATES - 40 - (tt - start)))
+                                       {
+                                               strncpy(tt, item, BUFFER_SIZES(start, tt, LEN_STATES));
+                                               tt  += count;
+                                       }
+                               sum += s_time;
+                       }
+               }
+               
+               snprintf(tt, BUFFER_SIZES(start, tt, LEN_STATES), "; running time: %s\"", l_mktime(sum));
+               
+               tt = add_var(&out->kv_list, 32, RO);
+               snprintf(tt, 32,  "refclock_id=\"%s\"", parse->parse_type->cl_id);
+               
+               tt = add_var(&out->kv_list, 80, RO);
+               snprintf(tt, 80,  "refclock_iomode=\"%s\"", parse->binding->bd_description);
+
+               tt = add_var(&out->kv_list, 128, RO);
+               snprintf(tt, 128, "refclock_driver_version=\"%s\"", rcsid);
+               
+               {
+                       struct ctl_var *k;
+                       
+                       k = parse->kv;
+                       while (k && !(k->flags & EOV))
+                       {
+                               set_var(&out->kv_list, k->text, strlen(k->text)+1, k->flags);
+                               k++;
+                       }
+               }
+      
+               out->lencode       = strlen(outstatus);
+               out->p_lastcode    = outstatus;
+       }
+}
+
+/**===========================================================================
+ ** processing routines
+ **/
+
+/*--------------------------------------------------
+ * event handling - note that nominal events will also be posted
+ * keep track of state dwelling times
+ */
+static void
+parse_event(
+       struct parseunit *parse,
+       int event
+       )
+{
+       if (parse->generic->currentstatus != (u_char) event)
+       {
+               parse->statetime[parse->generic->currentstatus] += current_time - parse->lastchange;
+               parse->lastchange              = current_time;
+
+               if (parse->parse_type->cl_event)
+                   parse->parse_type->cl_event(parse, event);
+      
+               if (event == CEVNT_NOMINAL)
+               {
+                       NLOG(NLOG_CLOCKSTATUS)
+                               msyslog(LOG_INFO, "PARSE receiver #%d: SYNCHRONIZED",
+                                       CLK_UNIT(parse->peer));
+               }
+
+               refclock_report(parse->peer, event);
+       }
+}
+
+/*--------------------------------------------------
+ * process a PARSE time sample
+ */
+static void
+parse_process(
+       struct parseunit *parse,
+       parsetime_t      *parsetime
+       )
+{
+       l_fp off, rectime, reftime;
+       double fudge;
+       
+       /*
+        * check for changes in conversion status
+        * (only one for each new status !)
+        */
+       if (((parsetime->parse_status & CVT_MASK) != CVT_OK) &&
+           ((parsetime->parse_status & CVT_MASK) != CVT_NONE) &&
+           (parse->timedata.parse_status != parsetime->parse_status))
+       {
+               char buffer[400];
+               
+               NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
+                       msyslog(LOG_WARNING, "PARSE receiver #%d: conversion status \"%s\"",
+                               CLK_UNIT(parse->peer), parsestatus(parsetime->parse_status, buffer, sizeof(buffer)));
+               
+               if ((parsetime->parse_status & CVT_MASK) == CVT_FAIL)
+               {
+                       /*
+                        * tell more about the story - list time code
+                        * there is a slight change for a race condition and
+                        * the time code might be overwritten by the next packet
+                        */
+                       parsectl_t tmpctl;
+                       
+                       if (!PARSE_GETTIMECODE(parse, &tmpctl))
+                       {
+                               ERR(ERR_INTERNAL)
+                                       msyslog(LOG_ERR, "PARSE receiver #%d: parse_process: parse_timecode() FAILED", CLK_UNIT(parse->peer));
+                       }
+                       else
+                       {
+                               ERR(ERR_BADDATA)
+                                       msyslog(LOG_WARNING, "PARSE receiver #%d: FAILED TIMECODE: \"%s\" (check receiver configuration / wiring)",
+                                               CLK_UNIT(parse->peer), mkascii(buffer, sizeof buffer, tmpctl.parsegettc.parse_buffer, (unsigned)(tmpctl.parsegettc.parse_count - 1)));
+                       }
+               }
+       }
+
+       /*
+        * examine status and post appropriate events
+        */
+       if ((parsetime->parse_status & CVT_MASK) != CVT_OK)
+       {
+               /*
+                * got bad data - tell the rest of the system
+                */
+               switch (parsetime->parse_status & CVT_MASK)
+               {
+               case CVT_NONE:
+                       if ((parsetime->parse_status & CVT_ADDITIONAL) &&
+                           parse->parse_type->cl_message)
+                               parse->parse_type->cl_message(parse, parsetime);
+                       /*
+                        * save PPS information that comes piggyback
+                        */
+                       if (PARSE_PPS(parsetime->parse_state))
+                         {
+                           parse->timedata.parse_state |= PARSEB_PPS|PARSEB_S_PPS;
+                           parse->timedata.parse_ptime  = parsetime->parse_ptime;
+                         }
+                       break;          /* well, still waiting - timeout is handled at higher levels */
+                           
+               case CVT_FAIL:
+                       if (parsetime->parse_status & CVT_BADFMT)
+                       {
+                               parse_event(parse, CEVNT_BADREPLY);
+                       }
+                       else
+                               if (parsetime->parse_status & CVT_BADDATE)
+                               {
+                                       parse_event(parse, CEVNT_BADDATE);
+                               }
+                               else
+                                       if (parsetime->parse_status & CVT_BADTIME)
+                                       {
+                                               parse_event(parse, CEVNT_BADTIME);
+                                       }
+                                       else
+                                       {
+                                               parse_event(parse, CEVNT_BADREPLY); /* for the lack of something better */
+                                       }
+               }
+               return;                 /* skip the rest - useless */
+       }
+
+       /*
+        * check for format changes
+        * (in case somebody has swapped clocks 8-)
+        */
+       if (parse->lastformat != parsetime->parse_format)
+       {
+               parsectl_t tmpctl;
+       
+               tmpctl.parseformat.parse_format = parsetime->parse_format;
+
+               if (!PARSE_GETFMT(parse, &tmpctl))
+               {
+                       ERR(ERR_INTERNAL)
+                               msyslog(LOG_ERR, "PARSE receiver #%d: parse_getfmt() FAILED", CLK_UNIT(parse->peer));
+               }
+               else
+               {
+                       NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
+                               msyslog(LOG_INFO, "PARSE receiver #%d: packet format \"%s\"",
+                                       CLK_UNIT(parse->peer), tmpctl.parseformat.parse_buffer);
+               }
+               parse->lastformat = parsetime->parse_format;
+       }
+
+       /*
+        * now, any changes ?
+        */
+       if ((parse->timedata.parse_state ^ parsetime->parse_state) &
+           ~(unsigned)(PARSEB_PPS|PARSEB_S_PPS))
+       {
+               char tmp1[200];
+               char tmp2[200];
+               /*
+                * something happend - except for PPS events
+                */
+       
+               (void) parsestate(parsetime->parse_state, tmp1, sizeof(tmp1));
+               (void) parsestate(parse->timedata.parse_state, tmp2, sizeof(tmp2));
+       
+               NLOG(NLOG_CLOCKINFO) /* conditional if clause for conditional syslog */
+                       msyslog(LOG_INFO,"PARSE receiver #%d: STATE CHANGE: %s -> %s",
+                               CLK_UNIT(parse->peer), tmp2, tmp1);
+       }
+
+       /*
+        * carry on PPS information if still usable
+        */
+       if (PARSE_PPS(parse->timedata.parse_state) && !PARSE_PPS(parsetime->parse_state))
+        {
+               parsetime->parse_state |= PARSEB_PPS|PARSEB_S_PPS;
+               parsetime->parse_ptime  = parse->timedata.parse_ptime;
+       }
+
+       /*
+        * remember for future
+        */
+       parse->timedata = *parsetime;
+
+       /*
+        * check to see, whether the clock did a complete powerup or lost PZF signal
+        * and post correct events for current condition
+        */
+       if (PARSE_POWERUP(parsetime->parse_state))
+       {
+               /*
+                * this is bad, as we have completely lost synchronisation
+                * well this is a problem with the receiver here
+                * for PARSE Meinberg DCF77 receivers the lost synchronisation
+                * is true as it is the powerup state and the time is taken
+                * from a crude real time clock chip
+                * for the PZF series this is only partly true, as
+                * PARSE_POWERUP only means that the pseudo random
+                * phase shift sequence cannot be found. this is only
+                * bad, if we have never seen the clock in the SYNC
+                * state, where the PHASE and EPOCH are correct.
+                * for reporting events the above business does not
+                * really matter, but we can use the time code
+                * even in the POWERUP state after having seen
+                * the clock in the synchronized state (PZF class
+                * receivers) unless we have had a telegram disruption
+                * after having seen the clock in the SYNC state. we
+                * thus require having seen the clock in SYNC state
+                * *after* having missed telegrams (noresponse) from
+                * the clock. one problem remains: we might use erroneously
+                * POWERUP data if the disruption is shorter than 1 polling
+                * interval. fortunately powerdowns last usually longer than 64
+                * seconds and the receiver is at least 2 minutes in the
+                * POWERUP or NOSYNC state before switching to SYNC
+                */
+               parse_event(parse, CEVNT_FAULT);
+               NLOG(NLOG_CLOCKSTATUS)
+                       ERR(ERR_BADSTATUS)
+                       msyslog(LOG_ERR,"PARSE receiver #%d: NOT SYNCHRONIZED",
+                               CLK_UNIT(parse->peer));
+       }
+       else
+       {
+               /*
+                * we have two states left
+                *
+                * SYNC:
+                *  this state means that the EPOCH (timecode) and PHASE
+                *  information has be read correctly (at least two
+                *  successive PARSE timecodes were received correctly)
+                *  this is the best possible state - full trust
+                *
+                * NOSYNC:
+                *  The clock should be on phase with respect to the second
+                *  signal, but the timecode has not been received correctly within
+                *  at least the last two minutes. this is a sort of half baked state
+                *  for PARSE Meinberg DCF77 clocks this is bad news (clock running
+                *  without timecode confirmation)
+                *  PZF 535 has also no time confirmation, but the phase should be
+                *  very precise as the PZF signal can be decoded
+                */
+
+               if (PARSE_SYNC(parsetime->parse_state))
+               {
+                       /*
+                        * currently completely synchronized - best possible state
+                        */
+                       parse->lastsync = current_time;
+                       clear_err(parse, ERR_BADSTATUS);
+               }
+               else
+               {
+                       /*
+                        * we have had some problems receiving the time code
+                        */
+                       parse_event(parse, CEVNT_PROP);
+                       NLOG(NLOG_CLOCKSTATUS)
+                               ERR(ERR_BADSTATUS)
+                               msyslog(LOG_ERR,"PARSE receiver #%d: TIMECODE NOT CONFIRMED",
+                                       CLK_UNIT(parse->peer));
+               }
+       }
+
+       fudge = parse->generic->fudgetime1; /* standard RS232 Fudgefactor */
+       
+       if (PARSE_TIMECODE(parsetime->parse_state))
+       {
+               rectime = parsetime->parse_stime.fp;
+               off = reftime = parsetime->parse_time.fp;
+       
+               L_SUB(&off, &rectime); /* prepare for PPS adjustments logic */
+
+#ifdef DEBUG
+               if (debug > 3)
+                       printf("PARSE receiver #%d: Reftime %s, Recvtime %s - initial offset %s\n",
+                              CLK_UNIT(parse->peer),
+                              prettydate(&reftime),
+                              prettydate(&rectime),
+                              lfptoa(&off,6));
+#endif
+       }
+
+       if (PARSE_PPS(parsetime->parse_state) && CLK_PPS(parse->peer))
+       {
+               l_fp offset;
+               double ppsphaseadjust = parse->ppsphaseadjust;
+
+#ifdef HAVE_PPSAPI
+               /*
+                * set fudge = 0.0 if already included in PPS time stamps
+                */
+               if (parse->ppsparams.mode & (PPS_OFFSETCLEAR|PPS_OFFSETASSERT))
+                       {
+                               ppsphaseadjust = 0.0;
+                       }
+#endif
+
+               /*
+                * we have a PPS signal - much better than the RS232 stuff (we hope)
+                */
+               offset = parsetime->parse_ptime.fp;
+
+#ifdef DEBUG
+               if (debug > 3)
+                       printf("PARSE receiver #%d: PPStime %s\n",
+                               CLK_UNIT(parse->peer),
+                               prettydate(&offset));
+#endif
+               if (PARSE_TIMECODE(parsetime->parse_state))
+               {
+                       if (M_ISGEQ(off.l_i, off.l_f, -1, 0x80000000) &&
+                           M_ISGEQ(0, 0x7fffffff, off.l_i, off.l_f))
+                       {
+                               fudge = ppsphaseadjust; /* pick PPS fudge factor */
+                       
+                               /*
+                                * RS232 offsets within [-0.5..0.5[ - take PPS offsets
+                                */
+
+                               if (parse->parse_type->cl_flags & PARSE_F_PPSONSECOND)
+                               {
+                                       reftime = off = offset;
+                                       if (reftime.l_uf & (unsigned)0x80000000)
+                                               reftime.l_ui++;
+                                       reftime.l_uf = 0;
+
+                                       
+                                       /*
+                                        * implied on second offset
+                                        */
+                                       off.l_uf = ~off.l_uf; /* map [0.5..1[ -> [-0.5..0[ */
+                                       off.l_ui = (off.l_f < 0) ? ~0 : 0; /* sign extend */
+                               }
+                               else
+                               {
+                                       /*
+                                        * time code describes pulse
+                                        */
+                                       reftime = off = parsetime->parse_time.fp;
+
+                                       L_SUB(&off, &offset); /* true offset */
+                               }
+                       }
+                       /*
+                        * take RS232 offset when PPS when out of bounds
+                        */
+               }
+               else
+               {
+                       fudge = ppsphaseadjust; /* pick PPS fudge factor */
+                       /*
+                        * Well, no time code to guide us - assume on second pulse
+                        * and pray, that we are within [-0.5..0.5[
+                        */
+                       off = offset;
+                       reftime = offset;
+                       if (reftime.l_uf & (unsigned)0x80000000)
+                               reftime.l_ui++;
+                       reftime.l_uf = 0;
+                       /*
+                        * implied on second offset
+                        */
+                       off.l_uf = ~off.l_uf; /* map [0.5..1[ -> [-0.5..0[ */
+                       off.l_ui = (off.l_f < 0) ? ~0 : 0; /* sign extend */
+               }
+       }
+       else
+       {
+               if (!PARSE_TIMECODE(parsetime->parse_state))
+               {
+                       /*
+                        * Well, no PPS, no TIMECODE, no more work ...
+                        */
+                       if ((parsetime->parse_status & CVT_ADDITIONAL) &&
+                           parse->parse_type->cl_message)
+                               parse->parse_type->cl_message(parse, parsetime);
+                       return;
+               }
+       }
+
+#ifdef DEBUG
+       if (debug > 3)
+               printf("PARSE receiver #%d: Reftime %s, Recvtime %s - final offset %s\n",
+                       CLK_UNIT(parse->peer),
+                       prettydate(&reftime),
+                       prettydate(&rectime),
+                       lfptoa(&off,6));
+#endif
+
+
+       rectime = reftime;
+       L_SUB(&rectime, &off);  /* just to keep the ntp interface happy */
+       
+#ifdef DEBUG
+       if (debug > 3)
+               printf("PARSE receiver #%d: calculated Reftime %s, Recvtime %s\n",
+                       CLK_UNIT(parse->peer),
+                       prettydate(&reftime),
+                       prettydate(&rectime));
+#endif
+
+       if ((parsetime->parse_status & CVT_ADDITIONAL) &&
+           parse->parse_type->cl_message)
+               parse->parse_type->cl_message(parse, parsetime);
+
+       if (PARSE_SYNC(parsetime->parse_state))
+       {
+               /*
+                * log OK status
+                */
+               parse_event(parse, CEVNT_NOMINAL);
+       }
+
+       clear_err(parse, ERR_BADIO);
+       clear_err(parse, ERR_BADDATA);
+       clear_err(parse, ERR_NODATA);
+       clear_err(parse, ERR_INTERNAL);
+  
+       /*
+        * and now stick it into the clock machine
+        * samples are only valid iff lastsync is not too old and
+        * we have seen the clock in sync at least once
+        * after the last time we didn't see an expected data telegram
+        * at startup being not in sync is also bad just like
+        * POWERUP state
+        * see the clock states section above for more reasoning
+        */
+       if (((current_time - parse->lastsync) > parse->maxunsync) ||
+           (parse->lastsync < parse->lastmissed) ||
+           ((parse->lastsync == 0) && !PARSE_SYNC(parsetime->parse_state)) ||
+           PARSE_POWERUP(parsetime->parse_state))
+       {
+               parse->generic->leap = LEAP_NOTINSYNC;
+               parse->lastsync = 0;    /* wait for full sync again */
+       }
+       else
+       {
+               if (PARSE_LEAPADD(parsetime->parse_state))
+               {
+                       /*
+                        * we pick this state also for time code that pass leap warnings
+                        * without direction information (as earth is currently slowing
+                        * down).
+                        */
+                       parse->generic->leap = (parse->flags & PARSE_LEAP_DELETE) ? LEAP_DELSECOND : LEAP_ADDSECOND;
+               }
+               else
+                   if (PARSE_LEAPDEL(parsetime->parse_state))
+                   {
+                           parse->generic->leap = LEAP_DELSECOND;
+                   }
+                   else
+                   {
+                           parse->generic->leap = LEAP_NOWARNING;
+                   }
+       }
+
+       if (parse->generic->leap != LEAP_NOTINSYNC)
+       {
+               /*
+                * only good/trusted samples are interesting
+                */
+#ifdef DEBUG
+               if (debug > 2) 
+                       {
+                               printf("PARSE receiver #%d: refclock_process_offset(reftime=%s, rectime=%s, Fudge=%f)\n",
+                                      CLK_UNIT(parse->peer),
+                                      prettydate(&reftime),
+                                      prettydate(&rectime),
+                                      fudge);
+                       }
+#endif
+               parse->generic->lastref = reftime;
+               
+               refclock_process_offset(parse->generic, reftime, rectime, fudge);
+
+               /*
+                * pass PPS information on to PPS clock
+                */
+               if (PARSE_PPS(parsetime->parse_state) && CLK_PPS(parse->peer))
+                       {
+                               (void) pps_sample(&parse->timedata.parse_ptime.fp);
+                               parse_hardpps(parse, PARSE_HARDPPS_ENABLE);
+                       }
+       } else {
+               parse_hardpps(parse, PARSE_HARDPPS_DISABLE);
+       }
+
+       /*
+        * ready, unless the machine wants a sample or 
+        * we are in fast startup mode (peer->dist > MAXDISTANCE)
+        */
+       if (!parse->pollneeddata && parse->peer->disp <= MAXDISTANCE)
+           return;
+
+       parse->pollneeddata = 0;
+
+       parse->timedata.parse_state &= ~(unsigned)(PARSEB_PPS|PARSEB_S_PPS);
+
+       refclock_receive(parse->peer);
+}
+\f
+/**===========================================================================
+ ** special code for special clocks
+ **/
+
+static void
+mk_utcinfo(
+          char *t,
+          int wnt,
+          int wnlsf,
+          int dn,
+          int dtls,
+          int dtlsf,
+          int size
+          )
+{
+  l_fp leapdate;
+  char *start = t;
+  
+  snprintf(t, size, "current correction %d sec", dtls);
+  t += strlen(t);
+  
+  if (wnlsf < 990)
+    wnlsf += 1024;
+  
+  if (wnt < 990)
+    wnt += 1024;
+  
+  gpstolfp((unsigned short)wnlsf, (unsigned short)dn, 0, &leapdate);
+  
+  if ((dtlsf != dtls) &&
+      ((wnlsf - wnt) < 52))
+    {
+           snprintf(t, BUFFER_SIZES(start, t, size), ", next correction %d sec on %s, new GPS-UTC offset %d",
+             dtlsf - dtls, gmprettydate(&leapdate), dtlsf);
+    }
+  else
+    {
+           snprintf(t, BUFFER_SIZES(start, t, size), ", last correction on %s",
+             gmprettydate(&leapdate));
+    }
+}
+
+#ifdef CLOCK_MEINBERG
+/**===========================================================================
+ ** Meinberg GPS166/GPS167 support
+ **/
+
+/*------------------------------------------------------------
+ * gps16x_message - process GPS16x messages
+ */
+static void
+gps16x_message(
+              struct parseunit *parse,
+              parsetime_t      *parsetime
+              )
+{
+       if (parse->timedata.parse_msglen && parsetime->parse_msg[0] == SOH)
+       {
+               GPS_MSG_HDR header;
+               unsigned char *bufp = (unsigned char *)parsetime->parse_msg + 1;
+               
+#ifdef DEBUG
+               if (debug > 2)
+               {
+                       char msgbuffer[600];
+                       
+                       mkreadable(msgbuffer, sizeof(msgbuffer), (char *)parsetime->parse_msg, parsetime->parse_msglen, 1);
+                       printf("PARSE receiver #%d: received message (%d bytes) >%s<\n",
+                               CLK_UNIT(parse->peer),
+                               parsetime->parse_msglen,
+                               msgbuffer);
+               }
+#endif
+               get_mbg_header(&bufp, &header);
+               if (header.gps_hdr_csum == mbg_csum(parsetime->parse_msg + 1, 6) &&
+                   (header.gps_len == 0 ||
+                    (header.gps_len < sizeof(parsetime->parse_msg) &&
+                     header.gps_data_csum == mbg_csum(bufp, header.gps_len))))
+               {
+                       /*
+                        * clean message
+                        */
+                       switch (header.gps_cmd)
+                       {
+                       case GPS_SW_REV:
+                               {
+                                       char buffer[64];
+                                       SW_REV gps_sw_rev;
+                                       
+                                       get_mbg_sw_rev(&bufp, &gps_sw_rev);
+                                       snprintf(buffer, sizeof(buffer), "meinberg_gps_version=\"%x.%02x%s%s\"",
+                                               (gps_sw_rev.code >> 8) & 0xFF,
+                                               gps_sw_rev.code & 0xFF,
+                                               gps_sw_rev.name[0] ? " " : "",
+                                               gps_sw_rev.name);
+                                       set_var(&parse->kv, buffer, strlen(buffer)+1, RO|DEF);
+                               }
+                       break;
+
+                       case GPS_STAT:
+                               {
+                                       static struct state
+                                       {
+                                               unsigned short flag; /* status flag */
+                                               unsigned const char *string; /* bit name */
+                                       } states[] =
+                                         {
+                                                 { TM_ANT_DISCONN, (const unsigned char *)"ANTENNA FAULTY" },
+                                                 { TM_SYN_FLAG,    (const unsigned char *)"NO SYNC SIGNAL" },
+                                                 { TM_NO_SYNC,     (const unsigned char *)"NO SYNC POWERUP" },
+                                                 { TM_NO_POS,      (const unsigned char *)"NO POSITION" },
+                                                 { 0, (const unsigned char *)"" }
+                                         };
+                                       unsigned short status;
+                                       struct state *s = states;
+                                       char buffer[512];
+                                       char *p, *b;
+                                       
+                                       status = get_lsb_short(&bufp);
+                                       snprintf(buffer, sizeof(buffer), "meinberg_gps_status=\"[0x%04x] ", status);
+                                       
+                                       if (status)
+                                       {
+                                               p = b = buffer + strlen(buffer);
+                                               while (s->flag)
+                                               {
+                                                       if (status & s->flag)
+                                                       {
+                                                               if (p != b)
+                                                               {
+                                                                       *p++ = ',';
+                                                                       *p++ = ' ';
+                                                               }
+                                                               
+                                                               strncat(p, (const char *)s->string, sizeof(buffer));
+                                                       }
+                                                       s++;
+                                               }
+               
+                                               *p++ = '"';
+                                               *p   = '\0';
+                                       }
+                                       else
+                                       {
+                                               strncat(buffer, "<OK>\"", sizeof(buffer));
+                                       }
+               
+                                       set_var(&parse->kv, buffer, strlen(buffer)+1, RO|DEF);
+                               }
+                       break;
+
+                       case GPS_POS_XYZ:
+                               {
+                                       XYZ xyz;
+                                       char buffer[256];
+                                       
+                                       get_mbg_xyz(&bufp, xyz);
+                                       snprintf(buffer, sizeof(buffer), "gps_position(XYZ)=\"%s m, %s m, %s m\"",
+                                               mfptoa(xyz[XP].l_ui, xyz[XP].l_uf, 1),
+                                               mfptoa(xyz[YP].l_ui, xyz[YP].l_uf, 1),
+                                               mfptoa(xyz[ZP].l_ui, xyz[ZP].l_uf, 1));
+                                       
+                                       set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
+                               }
+                       break;
+             
+                       case GPS_POS_LLA:
+                               {
+                                       LLA lla;
+                                       char buffer[256];
+                                       
+                                       get_mbg_lla(&bufp, lla);
+                                       
+                                       snprintf(buffer, sizeof(buffer), "gps_position(LLA)=\"%s deg, %s deg, %s m\"",
+                                               mfptoa(lla[LAT].l_ui, lla[LAT].l_uf, 4),
+                                               mfptoa(lla[LON].l_ui, lla[LON].l_uf, 4), 
+                                               mfptoa(lla[ALT].l_ui, lla[ALT].l_uf, 1));
+                                       
+                                       set_var(&parse->kv, buffer, sizeof(buffer), RO|DEF);
+                               }
+                       break;
+             
+                       case GPS_TZDL:
+                               break;
+             
+                       case GPS_PORT_PARM:
+                               break;
+             
+                       case GPS_SYNTH:
+                               break;
+                               
+                       case GPS_ANT_INFO:
+                               {
+                                       ANT_INFO antinfo;
+                                       char buffer[512];
+                                       char *p;
+                                       
+                                       get_mbg_antinfo(&bufp, &antinfo);
+                                       snprintf(buffer, sizeof(buffer), "meinberg_antenna_status=\"");
+                                       p = buffer + strlen(buffer);
+                                       
+                                       switch (antinfo.status)
+                                       {
+                                       case ANT_INVALID:
+                                               strncat(p, "<OK>", BUFFER_SIZE(buffer, p));
+                                               p += strlen(p);
+                                               break;
+                                               
+                                       case ANT_DISCONN:
+                                               strncat(p, "DISCONNECTED since ", BUFFER_SIZE(buffer, p));
+                                               NLOG(NLOG_CLOCKSTATUS)
+                                                       ERR(ERR_BADSTATUS)
+                                                       msyslog(LOG_ERR,"PARSE receiver #%d: ANTENNA FAILURE: %s",
+                                                               CLK_UNIT(parse->peer), p);
+                                               
+                                               p += strlen(p);
+                                               mbg_tm_str(&p, &antinfo.tm_disconn, BUFFER_SIZE(buffer, p));
+                                               *p = '\0';
+                                               break;
+                   
+                                       case ANT_RECONN:
+                                               strncat(p, "RECONNECTED on ", BUFFER_SIZE(buffer, p));
+                                               p += strlen(p);
+                                               mbg_tm_str(&p, &antinfo.tm_reconn, BUFFER_SIZE(buffer, p));
+                                               snprintf(p, BUFFER_SIZE(buffer, p), ", reconnect clockoffset %c%ld.%07ld s, disconnect time ",
+                                                       (antinfo.delta_t < 0) ? '-' : '+',
+                                                       ABS(antinfo.delta_t) / 10000,
+                                                       ABS(antinfo.delta_t) % 10000);
+                                               p += strlen(p);
+                                               mbg_tm_str(&p, &antinfo.tm_disconn, BUFFER_SIZE(buffer, p));
+                                               *p = '\0';
+                                               break;
+                   
+                                       default:
+                                               snprintf(p, BUFFER_SIZE(buffer, p), "bad status 0x%04x", antinfo.status);
+                                               p += strlen(p);
+                                               break;
+                                       }
+                                       
+                                       strncat(p, "\"", BUFFER_SIZE(buffer, p));
+                                       
+                                       set_var(&parse->kv, buffer, strlen(buffer)+1, RO|DEF);
+                               }
+                       break;
+             
+                       case GPS_UCAP:
+                               break;
+                               
+                       case GPS_CFGH:
+                               {
+                                       CFGH cfgh;
+                                       char buffer[512];
+                                       char *p;
+                                       
+                                       get_mbg_cfgh(&bufp, &cfgh);
+                                       if (cfgh.valid)
+                                       {
+                                               int i;
+                                               
+                                               p = buffer;
+                                               strncpy(buffer, "gps_tot_51=\"", BUFFER_SIZE(buffer, p));
+                                               p += strlen(p);
+                                               mbg_tgps_str(&p, &cfgh.tot_51, BUFFER_SIZE(buffer, p));
+                                               strncpy(p, "\"", BUFFER_SIZE(buffer, p));
+                                               set_var(&parse->kv, buffer, strlen(buffer)+1, RO);
+                                               
+                                               p = buffer;
+                                               strncpy(buffer, "gps_tot_63=\"", BUFFER_SIZE(buffer, p));
+                                               p += strlen(p);
+                                               mbg_tgps_str(&p, &cfgh.tot_63, BUFFER_SIZE(buffer, p));
+                                               strncpy(p, "\"", BUFFER_SIZE(buffer, p));
+                                               set_var(&parse->kv, buffer, strlen(buffer)+1, RO);
+                                               
+                                               p = buffer;
+                                               strncpy(buffer, "gps_t0a=\"", BUFFER_SIZE(buffer, p));
+                                               p += strlen(p);
+                                               mbg_tgps_str(&p, &cfgh.t0a, BUFFER_SIZE(buffer, p));
+                                               strncpy(p, "\"", BUFFER_SIZE(buffer, p));
+                                               set_var(&parse->kv, buffer, strlen(buffer)+1, RO);
+                                               
+                                               for (i = MIN_SVNO; i < MAX_SVNO; i++)
+                                               {
+                                                       p = buffer;
+                                                       snprintf(p, BUFFER_SIZE(buffer, p), "gps_cfg[%d]=\"[0x%x] ", i, cfgh.cfg[i]);
+                                                       p += strlen(p);
+                                                       switch (cfgh.cfg[i] & 0x7)
+                                                       {
+                                                       case 0:
+                                                               strncpy(p, "BLOCK I", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 1:
+                                                               strncpy(p, "BLOCK II", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       default:
+                                                               strncpy(p, "bad CFG", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       }
+                                                       strncat(p, "\"", BUFFER_SIZE(buffer, p));
+                                                       set_var(&parse->kv, buffer, strlen(buffer)+1, RO);
+                                                       
+                                                       p = buffer;
+                                                       snprintf(p, BUFFER_SIZE(buffer, p), "gps_health[%d]=\"[0x%x] ", i, cfgh.health[i]);
+                                                       p += strlen(p);
+                                                       switch ((cfgh.health[i] >> 5) & 0x7 )
+                                                       {
+                                                       case 0:
+                                                               strncpy(p, "OK;", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 1:
+                                                               strncpy(p, "PARITY;", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 2:
+                                                               strncpy(p, "TLM/HOW;", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 3:
+                                                               strncpy(p, "Z-COUNT;", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 4:
+                                                               strncpy(p, "SUBFRAME 1,2,3;", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 5:
+                                                               strncpy(p, "SUBFRAME 4,5;", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 6:
+                                                               strncpy(p, "UPLOAD BAD;", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 7:
+                                                               strncpy(p, "DATA BAD;", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       }
+                                                       
+                                                       p += strlen(p);
+                                                       
+                                                       switch (cfgh.health[i] & 0x1F)
+                                                       {
+                                                       case 0:
+                                                               strncpy(p, "SIGNAL OK", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 0x1C:
+                                                               strncpy(p, "SV TEMP OUT", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 0x1D:
+                                                               strncpy(p, "SV WILL BE TEMP OUT", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       case 0x1E:
+                                                               break;
+                                                       case 0x1F:
+                                                               strncpy(p, "MULTIPLE ERRS", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       default:
+                                                               strncpy(p, "TRANSMISSION PROBLEMS", BUFFER_SIZE(buffer, p));
+                                                               break;
+                                                       }
+                                                       
+                                                       strncat(p, "\"", sizeof(buffer));
+                                                       set_var(&parse->kv, buffer, strlen(buffer)+1, RO);
+                                               }
+                                       }
+                               }
+                       break;
+             
+                       case GPS_ALM:
+                               break;
+                               
+                       case GPS_EPH:
+                               break;
+                               
+                       case GPS_UTC:
+                               {
+                                       UTC utc;
+                                       char buffer[512];
+                                       char *p;
+                                       
+                                       p = buffer;
+                                       
+                                       get_mbg_utc(&bufp, &utc);
+                                       
+                                       if (utc.valid)
+                                       {
+                                               strncpy(p, "gps_utc_correction=\"", sizeof(buffer));
+                                               p += strlen(p);
+                                               mk_utcinfo(p, utc.t0t.wn, utc.WNlsf, utc.DNt, utc.delta_tls, utc.delta_tlsf, BUFFER_SIZE(buffer, p));
+                                               strncat(p, "\"", BUFFER_SIZE(buffer, p));
+                                       }
+                                       else
+                                       {
+                                               strncpy(p, "gps_utc_correction=\"<NO UTC DATA>\"", BUFFER_SIZE(buffer, p));
+                                       }
+                                       set_var(&parse->kv, buffer, strlen(buffer)+1, RO|DEF);
+                               }
+                       break;
+                       
+                       case GPS_IONO:
+                               break;
+                               
+                       case GPS_ASCII_MSG:
+                               {
+                                       ASCII_MSG gps_ascii_msg;
+                                       char buffer[128];
+               
+                                       get_mbg_ascii_msg(&bufp, &gps_ascii_msg);
+                                       
+                                       if (gps_ascii_msg.valid)
+                                               {
+                                                       char buffer1[128];
+                                                       mkreadable(buffer1, sizeof(buffer1), gps_ascii_msg.s, strlen(gps_ascii_msg.s), (int)0);
+                                                       
+                                                       snprintf(buffer, sizeof(buffer), "gps_message=\"%s\"", buffer1);
+                                               }
+                                       else
+                                               strncpy(buffer, "gps_message=<NONE>", sizeof(buffer));
+                                       
+                                       set_var(&parse->kv, buffer, strlen(buffer)+1, RO|DEF);
+                               }
+                       
+                       break;
+             
+                       default:
+                               break;
+                       }
+               }
+               else
+               {
+                       msyslog(LOG_DEBUG, "PARSE receiver #%d: gps16x_message: message checksum error: hdr_csum = 0x%x (expected 0x%lx), data_len = %d, data_csum = 0x%x (expected 0x%lx)",
+                               CLK_UNIT(parse->peer),
+                               header.gps_hdr_csum, mbg_csum(parsetime->parse_msg + 1, 6),
+                               header.gps_len,
+                               header.gps_data_csum, mbg_csum(bufp, (unsigned)((header.gps_len < sizeof(parsetime->parse_msg)) ? header.gps_len : 0)));
+               }
+       }
+  
+       return;
+}
+
+/*------------------------------------------------------------
+ * gps16x_poll - query the reciver peridically
+ */
+static void
+gps16x_poll(
+           struct peer *peer
+           )
+{
+       struct parseunit *parse = (struct parseunit *)peer->procptr->unitptr;
+       
+       static GPS_MSG_HDR sequence[] = 
+       {
+               { GPS_SW_REV,          0, 0, 0 },
+               { GPS_STAT,            0, 0, 0 },
+               { GPS_UTC,             0, 0, 0 },
+               { GPS_ASCII_MSG,       0, 0, 0 },
+               { GPS_ANT_INFO,        0, 0, 0 },
+               { GPS_CFGH,            0, 0, 0 },
+               { GPS_POS_XYZ,         0, 0, 0 },
+               { GPS_POS_LLA,         0, 0, 0 },
+               { (unsigned short)~0,  0, 0, 0 }
+       };
+      
+       int rtc;
+       unsigned char cmd_buffer[64];
+       unsigned char *outp = cmd_buffer;
+       GPS_MSG_HDR *header;
+       
+       if (((poll_info_t *)parse->parse_type->cl_data)->rate)
+       {
+               parse->peer->nextaction = current_time + ((poll_info_t *)parse->parse_type->cl_data)->rate;
+       }
+
+       if (sequence[parse->localstate].gps_cmd == (unsigned short)~0)
+               parse->localstate = 0;
+       
+       header = sequence + parse->localstate++;
+       
+       *outp++ = SOH;          /* start command */
+       
+       put_mbg_header(&outp, header);
+       outp = cmd_buffer + 1;
+       
+       header->gps_hdr_csum = (short)mbg_csum(outp, 6);
+       put_mbg_header(&outp, header);
+       
+#ifdef DEBUG
+       if (debug > 2)
+       {
+               char buffer[128];
+               
+               mkreadable(buffer, sizeof(buffer), (char *)cmd_buffer, (unsigned)(outp - cmd_buffer), 1);
+               printf("PARSE receiver #%d: transmitted message #%ld (%d bytes) >%s<\n",
+                      CLK_UNIT(parse->peer),
+                      parse->localstate - 1,
+                      (int)(outp - cmd_buffer),
+                      buffer); 
+       }
+#endif
+  
+       rtc = write(parse->generic->io.fd, cmd_buffer, (unsigned long)(outp - cmd_buffer));
+       
+       if (rtc < 0)
+       {
+               ERR(ERR_BADIO)
+                       msyslog(LOG_ERR, "PARSE receiver #%d: gps16x_poll: failed to send cmd to clock: %m", CLK_UNIT(parse->peer));
+       }
+       else
+       if (rtc != outp - cmd_buffer)
+       {
+               ERR(ERR_BADIO)
+                       msyslog(LOG_ERR, "PARSE receiver #%d: gps16x_poll: failed to send cmd incomplete (%d of %d bytes sent)", CLK_UNIT(parse->peer), rtc, (int)(outp - cmd_buffer));
+       }
+
+       clear_err(parse, ERR_BADIO);
+       return;
+}
+
+/*--------------------------------------------------
+ * init routine - setup timer
+ */
+static int
+gps16x_poll_init(
+       struct parseunit *parse
+       )
+{
+       if (((poll_info_t *)parse->parse_type->cl_data)->rate)
+       {
+               parse->peer->action = gps16x_poll;
+               gps16x_poll(parse->peer);
+       }
+
+       return 0;
+}
+
+#else
+static void
+gps16x_message(
+              struct parseunit *parse,
+              parsetime_t      *parsetime
+              )
+{}
+static int
+gps16x_poll_init(
+       struct parseunit *parse
+       )
+{
+       return 1;
+}
+#endif /* CLOCK_MEINBERG */
+\f
+/**===========================================================================
+ ** clock polling support
+ **/
+
+/*--------------------------------------------------
+ * direct poll routine
+ */
+static void
+poll_dpoll(
+       struct parseunit *parse
+       )
+{
+       int rtc;
+       const char *ps = ((poll_info_t *)parse->parse_type->cl_data)->string;
+       int   ct = ((poll_info_t *)parse->parse_type->cl_data)->count;
+
+       rtc = write(parse->generic->io.fd, ps, (unsigned long)ct);
+       if (rtc < 0)
+       {
+               ERR(ERR_BADIO)
+                       msyslog(LOG_ERR, "PARSE receiver #%d: poll_dpoll: failed to send cmd to clock: %m", CLK_UNIT(parse->peer));
+       }
+       else
+           if (rtc != ct)
+           {
+                   ERR(ERR_BADIO)
+                           msyslog(LOG_ERR, "PARSE receiver #%d: poll_dpoll: failed to send cmd incomplete (%d of %d bytes sent)", CLK_UNIT(parse->peer), rtc, ct);
+           }
+       clear_err(parse, ERR_BADIO);
+}
+
+/*--------------------------------------------------
+ * periodic poll routine
+ */
+static void
+poll_poll(
+       struct peer *peer
+       )
+{
+       struct parseunit *parse = (struct parseunit *)peer->procptr->unitptr;
+       
+       if (parse->parse_type->cl_poll)
+               parse->parse_type->cl_poll(parse);
+
+       if (((poll_info_t *)parse->parse_type->cl_data)->rate)
+       {
+               parse->peer->nextaction = current_time + ((poll_info_t *)parse->parse_type->cl_data)->rate;
+       }
+}
+
+/*--------------------------------------------------
+ * init routine - setup timer
+ */
+static int
+poll_init(
+       struct parseunit *parse
+       )
+{
+       if (((poll_info_t *)parse->parse_type->cl_data)->rate)
+       {
+               parse->peer->action = poll_poll;
+               poll_poll(parse->peer);
+       }
+
+       return 0;
+}
+\f
+/**===========================================================================
+ ** Trimble support
+ **/
+
+/*-------------------------------------------------------------
+ * trimble TAIP init routine - setup EOL and then do poll_init.
+ */
+static int
+trimbletaip_init(
+       struct parseunit *parse
+       )
+{
+#ifdef HAVE_TERMIOS
+       struct termios tio;
+#endif
+#ifdef HAVE_SYSV_TTYS
+       struct termio tio;
+#endif
+       /*
+        * configure terminal line for trimble receiver
+        */
+       if (TTY_GETATTR(parse->generic->io.fd, &tio) == -1)
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: trimbletaip_init: tcgetattr(fd, &tio): %m", CLK_UNIT(parse->peer));
+               return 0;
+       }
+       else
+       {
+               tio.c_cc[VEOL] = TRIMBLETAIP_EOL;
+       
+               if (TTY_SETATTR(parse->generic->io.fd, &tio) == -1)
+               {
+                       msyslog(LOG_ERR, "PARSE receiver #%d: trimbletaip_init: tcsetattr(fd, &tio): %m", CLK_UNIT(parse->peer));
+                       return 0;
+               }
+       }
+       return poll_init(parse);
+}
+
+/*--------------------------------------------------
+ * trimble TAIP event routine - reset receiver upon data format trouble
+ */
+static const char *taipinit[] = {
+       ">FPV00000000<",
+       ">SRM;ID_FLAG=F;CS_FLAG=T;EC_FLAG=F;FR_FLAG=T;CR_FLAG=F<",
+       ">FTM00020001<",
+       (char *)0
+};
+      
+static void
+trimbletaip_event(
+       struct parseunit *parse,
+       int event
+       )
+{
+       switch (event)
+       {
+           case CEVNT_BADREPLY:        /* reset on garbled input */
+           case CEVNT_TIMEOUT:         /* reset on no input */
+                   {
+                           const char **iv;
+
+                           iv = taipinit;
+                           while (*iv)
+                           {
+                                   int rtc = write(parse->generic->io.fd, *iv, strlen(*iv));
+                                   if (rtc < 0)
+                                   {
+                                           msyslog(LOG_ERR, "PARSE receiver #%d: trimbletaip_event: failed to send cmd to clock: %m", CLK_UNIT(parse->peer));
+                                           return;
+                                   }
+                                   else
+                                   {
+                                           if (rtc != strlen(*iv))
+                                           {
+                                                   msyslog(LOG_ERR, "PARSE receiver #%d: trimbletaip_event: failed to send cmd incomplete (%d of %d bytes sent)",
+                                                           CLK_UNIT(parse->peer), rtc, (int)strlen(*iv));
+                                                   return;
+                                           }
+                                   }
+                                   iv++;
+                           }
+
+                           NLOG(NLOG_CLOCKINFO)
+                                   ERR(ERR_BADIO)
+                                   msyslog(LOG_ERR, "PARSE receiver #%d: trimbletaip_event: RECEIVER INITIALIZED",
+                                           CLK_UNIT(parse->peer));
+                   }
+                   break;
+
+           default:                    /* ignore */
+               break;
+       }
+}
+
+/*
+ * This driver supports the Trimble SVee Six Plus GPS receiver module.
+ * It should support other Trimble receivers which use the Trimble Standard
+ * Interface Protocol (see below).
+ *
+ * The module has a serial I/O port for command/data and a 1 pulse-per-second
+ * output, about 1 microsecond wide. The leading edge of the pulse is
+ * coincident with the change of the GPS second. This is the same as
+ * the change of the UTC second +/- ~1 microsecond. Some other clocks
+ * specifically use a feature in the data message as a timing reference, but
+ * the SVee Six Plus does not do this. In fact there is considerable jitter
+ * on the timing of the messages, so this driver only supports the use
+ * of the PPS pulse for accurate timing. Where it is determined that
+ * the offset is way off, when first starting up ntpd for example,
+ * the timing of the data stream is used until the offset becomes low enough
+ * (|offset| < CLOCK_MAX), at which point the pps offset is used.
+ *
+ * It can use either option for receiving PPS information - the 'ppsclock'
+ * stream pushed onto the serial data interface to timestamp the Carrier
+ * Detect interrupts, where the 1PPS connects to the CD line. This only
+ * works on SunOS 4.1.x currently. To select this, define PPSPPS in
+ * Config.local. The other option is to use a pulse-stretcher/level-converter
+ * to convert the PPS pulse into a RS232 start pulse & feed this into another
+ * tty port. To use this option, define PPSCLK in Config.local. The pps input,
+ * by whichever method, is handled in ntp_loopfilter.c
+ *
+ * The receiver uses a serial message protocol called Trimble Standard
+ * Interface Protocol (it can support others but this driver only supports
+ * TSIP). Messages in this protocol have the following form:
+ *
+ * <DLE><id> ... <data> ... <DLE><ETX>
+ *
+ * Any bytes within the <data> portion of value 10 hex (<DLE>) are doubled
+ * on transmission and compressed back to one on reception. Otherwise
+ * the values of data bytes can be anything. The serial interface is RS-422
+ * asynchronous using 9600 baud, 8 data bits with odd party (**note** 9 bits
+ * in total!), and 1 stop bit. The protocol supports byte, integer, single,
+ * and double datatypes. Integers are two bytes, sent most significant first.
+ * Singles are IEEE754 single precision floating point numbers (4 byte) sent
+ * sign & exponent first. Doubles are IEEE754 double precision floating point
+ * numbers (8 byte) sent sign & exponent first.
+ * The receiver supports a large set of messages, only a small subset of
+ * which are used here. From driver to receiver the following are used:
+ *
+ *  ID    Description
+ *
+ *  21    Request current time
+ *  22    Mode Select
+ *  2C    Set/Request operating parameters
+ *  2F    Request UTC info
+ *  35    Set/Request I/O options
+
+ * From receiver to driver the following are recognised:
+ *
+ *  ID    Description
+ *
+ *  41    GPS Time
+ *  44    Satellite selection, PDOP, mode
+ *  46    Receiver health
+ *  4B    Machine code/status
+ *  4C    Report operating parameters (debug only)
+ *  4F    UTC correction data (used to get leap second warnings)
+ *  55    I/O options (debug only)
+ *
+ * All others are accepted but ignored.
+ *
+ */
+
+#define PI             3.1415926535898 /* lots of sig figs */
+#define D2R            PI/180.0
+
+/*-------------------------------------------------------------------
+ * sendcmd, sendbyte, sendetx, sendflt, sendint implement the command
+ * interface to the receiver.
+ *
+ * CAVEAT: the sendflt, sendint routines are byte order dependend and
+ * float implementation dependend - these must be converted to portable
+ * versions !
+ *
+ * CURRENT LIMITATION: float implementation. This runs only on systems
+ * with IEEE754 floats as native floats
+ */
+
+typedef struct trimble
+{
+       u_long last_msg;        /* last message received */
+       u_long last_reset;      /* last time a reset was issued */
+       u_char qtracking;       /* query tracking status */
+       u_long ctrack;          /* current tracking set */
+       u_long ltrack;          /* last tracking set */
+} trimble_t;
+
+union uval {
+       u_char  bd[8];
+       int     iv;
+       float   fv;
+       double  dv;
+};
+  
+struct txbuf
+{
+       short idx;                      /* index to first unused byte */
+       u_char *txt;                    /* pointer to actual data buffer */
+};
+
+void   sendcmd         P((struct txbuf *buf, int c)); 
+void   sendbyte        P((struct txbuf *buf, int b)); 
+void   sendetx         P((struct txbuf *buf, struct parseunit *parse)); 
+void   sendint         P((struct txbuf *buf, int a)); 
+void   sendflt         P((struct txbuf *buf, double a)); 
+void
+sendcmd(
+       struct txbuf *buf,
+       int c
+       )
+{
+       buf->txt[0] = DLE;
+       buf->txt[1] = (u_char)c;
+       buf->idx = 2;
+}
+
+void   sendcmd         P((struct txbuf *buf, int c)); 
+void   sendbyte        P((struct txbuf *buf, int b)); 
+void   sendetx         P((struct txbuf *buf, struct parseunit *parse)); 
+void   sendint         P((struct txbuf *buf, int a)); 
+void   sendflt         P((struct txbuf *buf, double a)); 
+void
+sendbyte(
+       struct txbuf *buf,
+       int b
+       )
+{
+       if (b == DLE)
+           buf->txt[buf->idx++] = DLE;
+       buf->txt[buf->idx++] = (u_char)b;
+}
+
+void
+sendetx(
+       struct txbuf *buf,
+       struct parseunit *parse
+       )
+{
+       buf->txt[buf->idx++] = DLE;
+       buf->txt[buf->idx++] = ETX;
+
+       if (write(parse->generic->io.fd, buf->txt, (unsigned long)buf->idx) != buf->idx)
+       {
+               ERR(ERR_BADIO)
+                       msyslog(LOG_ERR, "PARSE receiver #%d: sendetx: failed to send cmd to clock: %m", CLK_UNIT(parse->peer));
+       }
+       else
+       {
+#ifdef DEBUG
+         if (debug > 2)
+         {
+                 char buffer[256];
+                 
+                 mkreadable(buffer, sizeof(buffer), (char *)buf->txt, (unsigned)buf->idx, 1);
+                 printf("PARSE receiver #%d: transmitted message (%d bytes) >%s<\n",
+                        CLK_UNIT(parse->peer),
+                        buf->idx, buffer); 
+         }
+#endif
+               clear_err(parse, ERR_BADIO);
+       }
+}
+
+void  
+sendint(
+       struct txbuf *buf,
+       int a
+       )
+{
+       /* send 16bit int, msbyte first */
+       sendbyte(buf, (u_char)((a>>8) & 0xff));
+       sendbyte(buf, (u_char)(a & 0xff));
+}
+
+void
+sendflt(
+       struct txbuf *buf,
+       double a
+       )
+{
+       int i;
+       union uval uval;
+
+       uval.fv = a;
+#ifdef WORDS_BIGENDIAN
+       for (i=0; i<=3; i++)
+#else
+           for (i=3; i>=0; i--)
+#endif
+               sendbyte(buf, uval.bd[i]);
+}
+
+#define TRIM_POS_OPT   0x13    /* output position with high precision */
+#define TRIM_TIME_OPT  0x03    /* use UTC time stamps, on second */
+
+/*--------------------------------------------------
+ * trimble TSIP setup routine
+ */
+static int
+trimbletsip_setup(
+                 struct parseunit *parse,
+                 const char *reason
+                 )
+{
+       u_char buffer[256];
+       struct txbuf buf;
+       trimble_t *t = parse->localdata;
+
+       if (t && t->last_reset &&
+           ((t->last_reset + TRIMBLE_RESET_HOLDOFF) > current_time)) {
+               return 1;       /* not yet */
+       }
+
+       if (t)
+               t->last_reset = current_time;
+                       
+       buf.txt = buffer;
+  
+       sendcmd(&buf, CMD_CVERSION);    /* request software versions */
+       sendetx(&buf, parse);
+       
+       sendcmd(&buf, CMD_COPERPARAM);  /* set operating parameters */
+       sendbyte(&buf, 4);      /* static */
+       sendflt(&buf, 5.0*D2R); /* elevation angle mask = 10 deg XXX */
+       sendflt(&buf, 4.0);     /* s/n ratio mask = 6 XXX */
+       sendflt(&buf, 12.0);    /* PDOP mask = 12 */
+       sendflt(&buf, 8.0);     /* PDOP switch level = 8 */
+       sendetx(&buf, parse);
+       
+       sendcmd(&buf, CMD_CMODESEL);    /* fix mode select */
+       sendbyte(&buf, 1);      /* time transfer mode */
+       sendetx(&buf, parse);
+       
+       sendcmd(&buf, CMD_CMESSAGE);    /* request system message */
+       sendetx(&buf, parse);
+       
+       sendcmd(&buf, CMD_CSUPER);      /* superpacket fix */
+       sendbyte(&buf, 0x2);    /* binary mode */
+       sendetx(&buf, parse);
+       
+       sendcmd(&buf, CMD_CIOOPTIONS);  /* set I/O options */
+       sendbyte(&buf, TRIM_POS_OPT);   /* position output */
+       sendbyte(&buf, 0x00);   /* no velocity output */
+       sendbyte(&buf, TRIM_TIME_OPT);  /* UTC, compute on seconds */
+       sendbyte(&buf, 0x00);   /* no raw measurements */
+       sendetx(&buf, parse);
+       
+       sendcmd(&buf, CMD_CUTCPARAM);   /* request UTC correction data */
+       sendetx(&buf, parse);
+
+       NLOG(NLOG_CLOCKINFO)
+               ERR(ERR_BADIO)
+               msyslog(LOG_ERR, "PARSE receiver #%d: trimbletsip_setup: RECEIVER RE-INITIALIZED (%s)", CLK_UNIT(parse->peer), reason);
+
+       return 0;
+}
+
+/*--------------------------------------------------
+ * TRIMBLE TSIP check routine
+ */
+static void
+trimble_check(
+             struct peer *peer
+             )
+{
+       struct parseunit *parse = (struct parseunit *)peer->procptr->unitptr;
+       trimble_t *t = parse->localdata;
+       u_char buffer[256];
+       struct txbuf buf;
+       buf.txt = buffer;
+       
+       if (t)
+       {
+               if (current_time > t->last_msg + TRIMBLETSIP_IDLE_TIME)
+                       (void)trimbletsip_setup(parse, "message timeout");
+       }
+
+       poll_poll(parse->peer); /* emit query string and re-arm timer */
+       
+       if (t && t->qtracking)
+       {
+               u_long oldsats = t->ltrack & ~t->ctrack;
+               
+               t->qtracking = 0;
+               t->ltrack = t->ctrack;
+               
+               if (oldsats)
+               {
+                       int i;
+                               
+                       for (i = 0; oldsats; i++) {
+                               if (oldsats & (1 << i))
+                                       {
+                                               sendcmd(&buf, CMD_CSTATTRACK);
+                                               sendbyte(&buf, i+1);    /* old sat */
+                                               sendetx(&buf, parse);
+                                       }
+                               oldsats &= ~(1 << i);
+                       }
+               }
+                                               
+               sendcmd(&buf, CMD_CSTATTRACK);
+               sendbyte(&buf, 0x00);   /* current tracking set */
+               sendetx(&buf, parse);
+       }
+}
+
+/*--------------------------------------------------
+ * TRIMBLE TSIP end routine
+ */
+static void
+trimbletsip_end(
+             struct parseunit *parse
+             )
+{      trimble_t *t = parse->localdata;
+       
+       if (t)
+       {
+               free(t);
+               parse->localdata = (void *)0;
+       }
+       parse->peer->nextaction = 0;
+       parse->peer->action = (void (*) P((struct peer *)))0;
+}
+
+/*--------------------------------------------------
+ * TRIMBLE TSIP init routine
+ */
+static int
+trimbletsip_init(
+       struct parseunit *parse
+       )
+{
+#if defined(VEOL) || defined(VEOL2)
+#ifdef HAVE_TERMIOS
+       struct termios tio;             /* NEEDED FOR A LONG TIME ! */
+#endif
+#ifdef HAVE_SYSV_TTYS
+       struct termio tio;              /* NEEDED FOR A LONG TIME ! */
+#endif
+       /*
+        * allocate local data area
+        */
+       if (!parse->localdata)
+       {
+               trimble_t *t;
+               
+               t = (trimble_t *)(parse->localdata = emalloc(sizeof(trimble_t)));
+               
+               if (t)
+               {
+                       memset((char *)t, 0, sizeof(trimble_t));
+                       t->last_msg = current_time;
+               }
+       }
+
+       parse->peer->action     = trimble_check;
+       parse->peer->nextaction = current_time;
+
+       /*
+        * configure terminal line for ICANON mode with VEOL characters
+        */
+       if (TTY_GETATTR(parse->generic->io.fd, &tio) == -1)
+       {
+               msyslog(LOG_ERR, "PARSE receiver #%d: trimbletsip_init: tcgetattr(%d, &tio): %m", CLK_UNIT(parse->peer), parse->generic->io.fd);
+               return 0;
+       }
+       else
+       {
+               if ((parse_clockinfo[CLK_TYPE(parse->peer)].cl_lflag & ICANON))
+               {
+#ifdef VEOL
+                       tio.c_cc[VEOL]  = ETX;
+#endif
+#ifdef VEOL2
+                       tio.c_cc[VEOL2]  = DLE;
+#endif
+               }
+
+               if (TTY_SETATTR(parse->generic->io.fd, &tio) == -1)
+               {
+                       msyslog(LOG_ERR, "PARSE receiver #%d: trimbletsip_init: tcsetattr(%d, &tio): %m", CLK_UNIT(parse->peer), parse->generic->io.fd);
+                       return 0;
+               }
+       }
+#endif
+       return trimbletsip_setup(parse, "initial startup");
+}
+
+/*------------------------------------------------------------
+ * trimbletsip_event - handle Trimble events
+ * simple evente handler - attempt to re-initialize receiver
+ */
+static void
+trimbletsip_event(
+       struct parseunit *parse,
+       int event
+       )
+{
+       switch (event)
+       {
+           case CEVNT_BADREPLY:        /* reset on garbled input */
+           case CEVNT_TIMEOUT:         /* reset on no input */
+                   (void)trimbletsip_setup(parse, "event BAD_REPLY/TIMEOUT");
+                   break;
+
+           default:                    /* ignore */
+               break;
+       }
+}
+
+/*
+ * getflt, getint convert fields in the incoming data into the
+ * appropriate type of item
+ *
+ * CAVEAT: these routines are currently definitely byte order dependent
+ * and assume Representation(float) == IEEE754
+ * These functions MUST be converted to portable versions (especially
+ * converting the float representation into ntp_fp formats in order
+ * to avoid floating point operations at all!
+ */
+
+static float
+getflt(
+       u_char *bp
+       )
+{
+       union uval uval;
+       
+#ifdef WORDS_BIGENDIAN
+       uval.bd[0] = *bp++;
+       uval.bd[1] = *bp++;
+       uval.bd[2] = *bp++;
+       uval.bd[3] = *bp;
+#else  /* ! WORDS_BIGENDIAN */
+       uval.bd[3] = *bp++;
+       uval.bd[2] = *bp++;
+       uval.bd[1] = *bp++;
+       uval.bd[0] = *bp;
+#endif /* ! WORDS_BIGENDIAN */
+       return uval.fv;
+}
+
+static double
+getdbl(
+       u_char *bp
+       )
+{
+       union uval uval;
+       
+#ifdef WORDS_BIGENDIAN
+       uval.bd[0] = *bp++;
+       uval.bd[1] = *bp++;
+       uval.bd[2] = *bp++;
+       uval.bd[3] = *bp++;
+       uval.bd[4] = *bp++;
+       uval.bd[5] = *bp++;
+       uval.bd[6] = *bp++;
+       uval.bd[7] = *bp;
+#else  /* ! WORDS_BIGENDIAN */
+       uval.bd[7] = *bp++;
+       uval.bd[6] = *bp++;
+       uval.bd[5] = *bp++;
+       uval.bd[4] = *bp++;
+       uval.bd[3] = *bp++;
+       uval.bd[2] = *bp++;
+       uval.bd[1] = *bp++;
+       uval.bd[0] = *bp;
+#endif /* ! WORDS_BIGENDIAN */
+       return uval.dv;
+}
+
+static int
+getshort(
+        unsigned char *p
+        )
+{
+       return get_msb_short(&p);
+}
+
+/*--------------------------------------------------
+ * trimbletsip_message - process trimble messages
+ */
+#define RTOD (180.0 / 3.1415926535898)
+#define mb(_X_) (buffer[2+(_X_)]) /* shortcut for buffer access */
+
+static void
+trimbletsip_message(
+                   struct parseunit *parse,
+                   parsetime_t      *parsetime
+                   )
+{
+       unsigned char *buffer = parsetime->parse_msg;
+       unsigned int   size   = parsetime->parse_msglen;
+       
+       if ((size < 4) ||
+           (buffer[0]      != DLE) ||
+           (buffer[size-1] != ETX) ||
+           (buffer[size-2] != DLE))
+       {
+#ifdef DEBUG
+               if (debug > 2) {
+                       int i;
+
+                       printf("TRIMBLE BAD packet, size %d:\n  ", size);
+                       for (i = 0; i < size; i++) {
+                               printf ("%2.2x, ", buffer[i]&0xff);
+                               if (i%16 == 15) printf("\n\t");
+                       }
+                       printf("\n");
+               }
+#endif
+               return;
+       }
+       else
+       {
+               int var_flag;
+               trimble_t *tr = parse->localdata;
+               unsigned int cmd = buffer[1];
+               char pbuffer[200];
+               char *t = pbuffer;
+               cmd_info_t *s;
+               
+#ifdef DEBUG
+               if (debug > 3) {
+                       int i;
+
+                       printf("TRIMBLE packet 0x%02x, size %d:\n       ", cmd, size);
+                       for (i = 0; i < size; i++) {
+                               printf ("%2.2x, ", buffer[i]&0xff);
+                               if (i%16 == 15) printf("\n\t");
+                       }
+                       printf("\n");
+               }
+#endif
+
+               if (tr)
+                       tr->last_msg = current_time;
+               
+               s = trimble_convert(cmd, trimble_rcmds);
+               
+               if (s)
+               {
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "%s=\"", s->varname);
+               }
+               else
+               {
+                       DPRINTF(1, ("TRIMBLE UNKNOWN COMMAND 0x%02x\n", cmd));
+                       return;
+               }
+
+               var_flag = s->varmode;
+
+               t += strlen(t);
+               
+               switch(cmd)
+               {
+               case CMD_RCURTIME:
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "%f, %d, %f",
+                                getflt((unsigned char *)&mb(0)), getshort((unsigned char *)&mb(4)),
+                                getflt((unsigned char *)&mb(6)));
+                       break;
+                       
+               case CMD_RBEST4:
+                       strncpy(t, "mode: ", BUFFER_SIZE(pbuffer, t));
+                       t += strlen(t);
+                       switch (mb(0) & 0xF)
+                       {
+                       default:
+                               snprintf(t, BUFFER_SIZE(pbuffer, t), "0x%x", mb(0) & 0x7);
+                               break;
+
+                       case 1:
+                               strncpy(t, "0D", BUFFER_SIZE(pbuffer, t));
+                               break;
+                               
+                       case 3:
+                               strncpy(t, "2D", BUFFER_SIZE(pbuffer, t));
+                               break;
+                               
+                       case 4:
+                               strncpy(t, "3D", BUFFER_SIZE(pbuffer, t));
+                               break;
+                       }
+                       t += strlen(t);
+                       if (mb(0) & 0x10)
+                               strncpy(t, "-MANUAL, ", BUFFER_SIZE(pbuffer, t));
+                       else
+                               strncpy(t, "-AUTO, ", BUFFER_SIZE(pbuffer, t));
+                       t += strlen(t);
+                       
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "satellites %02d %02d %02d %02d, PDOP %.2f, HDOP %.2f, VDOP %.2f, TDOP %.2f",
+                               mb(1), mb(2), mb(3), mb(4),
+                               getflt((unsigned char *)&mb(5)),
+                               getflt((unsigned char *)&mb(9)),
+                               getflt((unsigned char *)&mb(13)),
+                               getflt((unsigned char *)&mb(17)));
+
+                       break;
+                       
+               case CMD_RVERSION:
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "%d.%d (%d/%d/%d)",
+                               mb(0)&0xff, mb(1)&0xff, 1900+(mb(4)&0xff), mb(2)&0xff, mb(3)&0xff);
+                       break;
+                       
+               case CMD_RRECVHEALTH:
+               {
+                       static const char *msgs[] =
+                       {
+                               "Battery backup failed",
+                               "Signal processor error",
+                               "Alignment error, channel or chip 1",
+                               "Alignment error, channel or chip 2",
+                               "Antenna feed line fault",
+                               "Excessive ref freq. error",
+                               "<BIT 6>",
+                               "<BIT 7>"
+                       };
+                       
+                       int i, bits;
+                       
+                       switch (mb(0) & 0xFF)
+                       {
+                       default:
+                               snprintf(t, BUFFER_SIZE(pbuffer, t), "illegal value 0x%02x", mb(0) & 0xFF);
+                               break;
+                       case 0x00:
+                               strncpy(t, "doing position fixes", BUFFER_SIZE(pbuffer, t));
+                               break;
+                       case 0x01:
+                               strncpy(t, "no GPS time yet", BUFFER_SIZE(pbuffer, t));
+                               break;
+                       case 0x03:
+                               strncpy(t, "PDOP too high", BUFFER_SIZE(pbuffer, t));
+                               break;
+                       case 0x08:
+                               strncpy(t, "no usable satellites", BUFFER_SIZE(pbuffer, t));
+                               break;
+                       case 0x09:
+                               strncpy(t, "only ONE usable satellite", BUFFER_SIZE(pbuffer, t));
+                               break;
+                       case 0x0A:
+                               strncpy(t, "only TWO usable satellites", BUFFER_SIZE(pbuffer, t));
+                               break;
+                       case 0x0B:
+                               strncpy(t, "only THREE usable satellites", BUFFER_SIZE(pbuffer, t));
+                               break;
+                       case 0x0C:
+                               strncpy(t, "the chosen satellite is unusable", BUFFER_SIZE(pbuffer, t));
+                               break;
+                       }
+
+                       t += strlen(t);
+
+                       bits = mb(1) & 0xFF;
+                       
+                       for (i = 0; i < 8; i++)
+                               if (bits & (0x1<<i))
+                               {
+                                       snprintf(t, BUFFER_SIZE(pbuffer, t), ", %s", msgs[i]);
+                                       t += strlen(t);
+                               }
+               }
+               break;
+                       
+               case CMD_RMESSAGE:
+                       mkreadable(t, (int)BUFFER_SIZE(pbuffer, t), (char *)&mb(0), (unsigned)(size - 2 - (&mb(0) - buffer)), 0);
+                       break;
+                       
+               case CMD_RMACHSTAT:
+               {
+                       static const char *msgs[] =
+                       {
+                               "Synthesizer Fault",
+                               "Battery Powered Time Clock Fault",
+                               "A-to-D Converter Fault",
+                               "The almanac stored in the receiver is not complete and current",
+                               "<BIT 4>",
+                               "<BIT 5",
+                               "<BIT 6>",
+                               "<BIT 7>"
+                       };
+                       
+                       int i, bits;
+
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "machine id 0x%02x", mb(0) & 0xFF);
+                       t += strlen(t);
+                       
+                       bits = mb(1) & 0xFF;
+                       
+                       for (i = 0; i < 8; i++)
+                               if (bits & (0x1<<i))
+                               {
+                                       snprintf(t, BUFFER_SIZE(pbuffer, t), ", %s", msgs[i]);
+                                       t += strlen(t);
+                               }
+
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), ", Superpackets %ssupported", (mb(2) & 0xFF) ? "" :"un" );
+               }
+               break;
+                       
+               case CMD_ROPERPARAM:
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "%2x %.1f %.1f %.1f %.1f",
+                               mb(0), getflt((unsigned char *)&mb(1)), getflt((unsigned char *)&mb(5)),
+                               getflt((unsigned char *)&mb(9)), getflt((unsigned char *)&mb(13)));
+                       break;
+                       
+               case CMD_RUTCPARAM:
+               {
+                       float t0t = getflt((unsigned char *)&mb(14));
+                       short wnt = getshort((unsigned char *)&mb(18));
+                       short dtls = getshort((unsigned char *)&mb(12));
+                       short wnlsf = getshort((unsigned char *)&mb(20));
+                       short dn = getshort((unsigned char *)&mb(22));
+                       short dtlsf = getshort((unsigned char *)&mb(24));
+
+                       if ((int)t0t != 0)
+                         {
+                                 mk_utcinfo(t, wnt, wnlsf, dn, dtls, dtlsf, BUFFER_SIZE(pbuffer, t));
+                         }
+                       else
+                         {
+                           strncpy(t, "<NO UTC DATA>", BUFFER_SIZE(pbuffer, t));
+                         }
+               }
+               break;
+
+               case CMD_RSAT1BIAS:
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "%.1fm %.2fm/s at %.1fs",
+                               getflt(&mb(0)), getflt(&mb(4)), getflt(&mb(8)));
+                       break;
+
+               case CMD_RIOOPTIONS:
+               {
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "%02x %02x %02x %02x",
+                               mb(0), mb(1), mb(2), mb(3));
+                       if (mb(0) != TRIM_POS_OPT ||
+                           mb(2) != TRIM_TIME_OPT)
+                       {
+                               (void)trimbletsip_setup(parse, "bad io options");
+                       }
+               }
+               break;
+               
+               case CMD_RSPOSXYZ:
+               {
+                       double x = getflt((unsigned char *)&mb(0));
+                       double y = getflt((unsigned char *)&mb(4));
+                       double z = getflt((unsigned char *)&mb(8));
+                       double f = getflt((unsigned char *)&mb(12));
+                       
+                       if (f > 0.0)
+                         snprintf(t, BUFFER_SIZE(pbuffer, t), "x= %.1fm, y= %.1fm, z= %.1fm, time_of_fix= %f sec",
+                                 x, y, z,
+                                 f);
+                       else
+                         return;
+               }
+               break;
+
+               case CMD_RSLLAPOS:
+               {
+                       double lat = getflt((unsigned char *)&mb(0));
+                       double lng = getflt((unsigned char *)&mb(4));
+                       double f   = getflt((unsigned char *)&mb(12));
+                       
+                       if (f > 0.0)
+                         snprintf(t, BUFFER_SIZE(pbuffer, t), "lat %f %c, long %f %c, alt %.2fm",
+                                 ((lat < 0.0) ? (-lat) : (lat))*RTOD, (lat < 0.0 ? 'S' : 'N'),
+                                 ((lng < 0.0) ? (-lng) : (lng))*RTOD, (lng < 0.0 ? 'W' : 'E'),
+                                 getflt((unsigned char *)&mb(8)));
+                       else
+                         return;
+               }
+               break;
+
+               case CMD_RDOUBLEXYZ:
+               {
+                       double x = getdbl((unsigned char *)&mb(0));
+                       double y = getdbl((unsigned char *)&mb(8));
+                       double z = getdbl((unsigned char *)&mb(16));
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "x= %.1fm, y= %.1fm, z= %.1fm",
+                               x, y, z);
+               }
+               break;
+                               
+               case CMD_RDOUBLELLA:
+               {
+                       double lat = getdbl((unsigned char *)&mb(0));
+                       double lng = getdbl((unsigned char *)&mb(8));
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "lat %f %c, lon %f %c, alt %.2fm",
+                               ((lat < 0.0) ? (-lat) : (lat))*RTOD, (lat < 0.0 ? 'S' : 'N'),
+                               ((lng < 0.0) ? (-lng) : (lng))*RTOD, (lng < 0.0 ? 'W' : 'E'),
+                               getdbl((unsigned char *)&mb(16)));
+               }
+               break;
+
+               case CMD_RALLINVIEW:
+               {
+                       int i, sats;
+                       
+                       strncpy(t, "mode: ", BUFFER_SIZE(pbuffer, t));
+                       t += strlen(t);
+                       switch (mb(0) & 0x7)
+                       {
+                       default:
+                               snprintf(t, BUFFER_SIZE(pbuffer, t), "0x%x", mb(0) & 0x7);
+                               break;
+
+                       case 3:
+                               strncpy(t, "2D", BUFFER_SIZE(pbuffer, t));
+                               break;
+                               
+                       case 4:
+                               strncpy(t, "3D", BUFFER_SIZE(pbuffer, t));
+                               break;
+                       }
+                       t += strlen(t);
+                       if (mb(0) & 0x8)
+                               strncpy(t, "-MANUAL, ", BUFFER_SIZE(pbuffer, t));
+                       else
+                               strncpy(t, "-AUTO, ", BUFFER_SIZE(pbuffer, t));
+                       t += strlen(t);
+                       
+                       sats = (mb(0)>>4) & 0xF;
+                       
+                       snprintf(t, BUFFER_SIZE(pbuffer, t), "PDOP %.2f, HDOP %.2f, VDOP %.2f, TDOP %.2f, %d satellite%s in view: ",
+                               getflt((unsigned char *)&mb(1)),
+                               getflt((unsigned char *)&mb(5)),
+                               getflt((unsigned char *)&mb(9)),
+                               getflt((unsigned char *)&mb(13)),
+                               sats, (sats == 1) ? "" : "s");
+                       t += strlen(t);
+
+                       for (i=0; i < sats; i++)
+                       {
+                               snprintf(t, BUFFER_SIZE(pbuffer, t), "%s%02d", i ? ", " : "", mb(17+i));
+                               t += strlen(t);
+                               if (tr)
+                                       tr->ctrack |= (1 << (mb(17+i)-1));
+                       }
+
+                       if (tr)
+                        { /* mark for tracking status query */
+                               tr->qtracking = 1;
+                       }
+               }
+               break;
+               
+               case CMD_RSTATTRACK:
+               {
+                       snprintf(t-2, BUFFER_SIZE(pbuffer, t-2), "[%02d]=\"", mb(0)); /* add index to var name */
+                       t += strlen(t);
+
+                       if (getflt((unsigned char *)&mb(4)) < 0.0)
+                       {
+                               strncpy(t, "<NO MEASUREMENTS>", BUFFER_SIZE(pbuffer, t));
+                               var_flag &= ~DEF;
+                       }
+                       else
+                       {       
+                               snprintf(t, BUFFER_SIZE(pbuffer, t), "ch=%d, acq=%s, eph=%d, signal_level= %5.2f, elevation= %5.2f, azimuth= %6.2f",
+                                       (mb(1) & 0xFF)>>3,
+                                       mb(2) ? ((mb(2) == 1) ? "ACQ" : "SRCH") : "NEVER",
+                                       mb(3),
+                                       getflt((unsigned char *)&mb(4)),
+                                       getflt((unsigned char *)&mb(12)) * RTOD,
+                                       getflt((unsigned char *)&mb(16)) * RTOD);
+                               t += strlen(t);
+                               if (mb(20))
+                               {
+                                       var_flag &= ~DEF;
+                                       strncpy(t, ", OLD", BUFFER_SIZE(pbuffer, t));
+                               }
+                               t += strlen(t);
+                               if (mb(22))
+                               {
+                                       if (mb(22) == 1)
+                                               strncpy(t, ", BAD PARITY", BUFFER_SIZE(pbuffer, t));
+                                       else
+                                               if (mb(22) == 2)
+                                                       strncpy(t, ", BAD EPH HEALTH", BUFFER_SIZE(pbuffer, t));
+                               }
+                               t += strlen(t);
+                               if (mb(23))
+                                       strncpy(t, ", collecting data", BUFFER_SIZE(pbuffer, t));
+                       }
+               }
+               break;
+               
+               default:
+                       strncpy(t, "<UNDECODED>", BUFFER_SIZE(pbuffer, t));
+                       break;
+               }
+               t += strlen(t);
+
+               strncpy(t,"\"", BUFFER_SIZE(pbuffer, t));
+               set_var(&parse->kv, pbuffer, sizeof(pbuffer), var_flag);
+       }
+}
+
+\f
+/**============================================================
+ ** RAWDCF support
+ **/
+
+/*--------------------------------------------------
+ * rawdcf_init_1 - set up modem lines for RAWDCF receivers
+ * SET DTR line
+ */
+#if defined(TIOCMSET) && (defined(TIOCM_DTR) || defined(CIOCM_DTR))
+static int
+rawdcf_init_1(
+       struct parseunit *parse
+       )
+{
+       /* fixed 2000 for using with Linux by Wolfram Pienkoss <wp@bszh.de> */
+       /*
+        * You can use the RS232 to supply the power for a DCF77 receiver.
+        * Here a voltage between the DTR and the RTS line is used. Unfortunately
+        * the name has changed from CIOCM_DTR to TIOCM_DTR recently.
+        */
+       int sl232;
+
+       if (ioctl(parse->generic->io.fd, TIOCMGET, (caddr_t)&sl232) == -1)
+       {
+               msyslog(LOG_NOTICE, "PARSE receiver #%d: rawdcf_init_1: WARNING: ioctl(fd, TIOCMGET, [C|T]IOCM_DTR): %m", CLK_UNIT(parse->peer));
+               return 0;
+       }
+
+#ifdef TIOCM_DTR
+       sl232 = (sl232 & ~TIOCM_RTS) | TIOCM_DTR;       /* turn on DTR, clear RTS for power supply */
+#else
+       sl232 = (sl232 & ~CIOCM_RTS) | CIOCM_DTR;       /* turn on DTR, clear RTS for power supply */
+#endif
+
+       if (ioctl(parse->generic->io.fd, TIOCMSET, (caddr_t)&sl232) == -1)
+       {
+               msyslog(LOG_NOTICE, "PARSE receiver #%d: rawdcf_init_1: WARNING: ioctl(fd, TIOCMSET, [C|T]IOCM_DTR): %m", CLK_UNIT(parse->peer));
+       }
+       return 0;
+}
+#else
+static int
+rawdcfdtr_init_1(
+       struct parseunit *parse
+       )
+{
+       msyslog(LOG_NOTICE, "PARSE receiver #%d: rawdcf_init_1: WARNING: OS interface incapable of setting DTR to power DCF modules", CLK_UNIT(parse->peer));
+       return 0;
+}
+#endif  /* DTR initialisation type */
+
+/*--------------------------------------------------
+ * rawdcf_init_2 - set up modem lines for RAWDCF receivers
+ * CLR DTR line, SET RTS line
+ */
+#if defined(TIOCMSET) &&  (defined(TIOCM_RTS) || defined(CIOCM_RTS))
+static int
+rawdcf_init_2(
+       struct parseunit *parse
+       )
+{
+       /* fixed 2000 for using with Linux by Wolfram Pienkoss <wp@bszh.de> */
+       /*
+        * You can use the RS232 to supply the power for a DCF77 receiver.
+        * Here a voltage between the DTR and the RTS line is used. Unfortunately
+        * the name has changed from CIOCM_DTR to TIOCM_DTR recently.
+        */
+       int sl232;
+
+       if (ioctl(parse->generic->io.fd, TIOCMGET, (caddr_t)&sl232) == -1)
+       {
+               msyslog(LOG_NOTICE, "PARSE receiver #%d: rawdcf_init_2: WARNING: ioctl(fd, TIOCMGET, [C|T]IOCM_RTS): %m", CLK_UNIT(parse->peer));
+               return 0;
+       }
+
+#ifdef TIOCM_RTS
+       sl232 = (sl232 & ~TIOCM_DTR) | TIOCM_RTS;       /* turn on RTS, clear DTR for power supply */
+#else
+       sl232 = (sl232 & ~CIOCM_DTR) | CIOCM_RTS;       /* turn on RTS, clear DTR for power supply */
+#endif
+
+       if (ioctl(parse->generic->io.fd, TIOCMSET, (caddr_t)&sl232) == -1)
+       {
+               msyslog(LOG_NOTICE, "PARSE receiver #%d: rawdcf_init_2: WARNING: ioctl(fd, TIOCMSET, [C|T]IOCM_RTS): %m", CLK_UNIT(parse->peer));
+       }
+       return 0;
+}
+#else
+static int
+rawdcf_init_2(
+       struct parseunit *parse
+       )
+{
+       msyslog(LOG_NOTICE, "PARSE receiver #%d: rawdcf_init_2: WARNING: OS interface incapable of setting RTS to power DCF modules", CLK_UNIT(parse->peer));
+       return 0;
+}
+#endif  /* DTR initialisation type */
+
+#else  /* defined(REFCLOCK) && defined(PARSE) */
+int refclock_parse_bs;
+#endif /* defined(REFCLOCK) && defined(PARSE) */
+
+/*
+ * History:
+ *
+ * refclock_parse.c,v
+ * Revision 4.80  2007/08/11 12:06:29  kardel
+ * update comments wrt/ to PPS
+ *
+ * Revision 4.79  2007/08/11 11:52:23  kardel
+ * - terminate io bindings before io_closeclock() will close our file descriptor
+ *
+ * Revision 4.78  2006/12/22 20:08:27  kardel
+ * Bug 746 (RFE): add configuration for Expert mouseCLOCK USB v2.0 as mode 19
+ *
+ * Revision 4.77  2006/08/05 07:44:49  kardel
+ * support optionally separate PPS devices via /dev/refclockpps-{0..3}
+ *
+ * Revision 4.76  2006/06/22 18:40:47  kardel
+ * clean up signedness (gcc 4)
+ *
+ * Revision 4.75  2006/06/22 16:58:10  kardel
+ * Bug #632: call parse_ppsapi() in parse_ctl() when updating
+ * the PPS offset. Fix sign of offset passed to kernel.
+ *
+ * Revision 4.74  2006/06/18 21:18:37  kardel
+ * NetBSD Coverity CID 3796: possible NULL deref
+ *
+ * Revision 4.73  2006/05/26 14:23:46  kardel
+ * cleanup of copyright info
+ *
+ * Revision 4.72  2006/05/26 14:19:43  kardel
+ * cleanup of ioctl cruft
+ *
+ * Revision 4.71  2006/05/26 14:15:57  kardel
+ * delay adding refclock to async refclock io after all initializations
+ *
+ * Revision 4.70  2006/05/25 18:20:50  kardel
+ * bug #619
+ * terminate parse io engine after de-registering
+ * from refclock io engine
+ *
+ * Revision 4.69  2006/05/25 17:28:02  kardel
+ * complete refclock io structure initialization *before* inserting it into the
+ * refclock input machine (avoids null pointer deref) (bug #619)
+ *
+ * Revision 4.68  2006/05/01 17:02:51  kardel
+ * copy receiver method also for newlwy created receive buffers
+ *
+ * Revision 4.67  2006/05/01 14:37:29  kardel
+ * If an input buffer parses into more than one message do insert the
+ * parsed message in a new input buffer instead of processing it
+ * directly. This avoids deed complicated processing in signal
+ * handling.
+ *
+ * Revision 4.66  2006/03/18 00:45:30  kardel
+ * coverity fixes found in NetBSD coverity scan
+ *
+ * Revision 4.65  2006/01/26 06:08:33  kardel
+ * output errno on PPS setup failure
+ *
+ * Revision 4.64  2005/11/09 20:44:47  kardel
+ * utilize full PPS timestamp resolution from PPS API
+ *
+ * Revision 4.63  2005/10/07 22:10:25  kardel
+ * bounded buffer implementation
+ *
+ * Revision 4.62.2.2  2005/09/25 10:20:16  kardel
+ * avoid unexpected buffer overflows due to sprintf("%f") on strange floats:
+ * replace almost all str* and *printf functions be their buffer bounded
+ * counterparts
+ *
+ * Revision 4.62.2.1  2005/08/27 16:19:27  kardel
+ * limit re-set rate of trimble clocks
+ *
+ * Revision 4.62  2005/08/06 17:40:00  kardel
+ * cleanup size handling wrt/ to buffer boundaries
+ *
+ * Revision 4.61  2005/07/27 21:16:19  kardel
+ * fix a long (> 11 years) misconfiguration wrt/ Meinberg cflag factory
+ * default setup. CSTOPB was missing for the 7E2 default data format of
+ * the DCF77 clocks.
+ *
+ * Revision 4.60  2005/07/17 21:14:44  kardel
+ * change contents of version string to include the RCS/CVS Id
+ *
+ * Revision 4.59  2005/07/06 06:56:38  kardel
+ * syntax error
+ *
+ * Revision 4.58  2005/07/04 13:10:40  kardel
+ * fix bug 455: tripping over NULL pointer on cleanup
+ * fix shadow storage logic for ppsphaseadjust and trustime wrt/ time2
+ * fix compiler warnings for some platforms wrt/ printf formatstrings and
+ *     varying structure element sizes
+ * reorder assignment in binding to avoid tripping over NULL pointers
+ *
+ * Revision 4.57  2005/06/25 09:25:19  kardel
+ * sort out log output sequence
+ *
+ * Revision 4.56  2005/06/14 21:47:27  kardel
+ * collect samples only if samples are ok (sync or trusted flywheel)
+ * propagate pps phase adjustment value to kernel via PPSAPI to help HARDPPS
+ * en- and dis-able HARDPPS in correlation to receiver sync state
+ *
+ * Revision 4.55  2005/06/02 21:28:31  kardel
+ * clarify trust logic
+ *
+ * Revision 4.54  2005/06/02 17:06:49  kardel
+ * change status reporting to use fixed refclock_report()
+ *
+ * Revision 4.53  2005/06/02 16:33:31  kardel
+ * fix acceptance of clocks unsync clocks right at start
+ *
+ * Revision 4.52  2005/05/26 21:55:06  kardel
+ * cleanup status reporting
+ *
+ * Revision 4.51  2005/05/26 19:19:14  kardel
+ * implement fast refclock startup
+ *
+ * Revision 4.50  2005/04/16 20:51:35  kardel
+ * set pps_enable = 1 when binding a kernel PPS source
+ *
+ * Revision 4.49  2005/04/16 17:29:26  kardel
+ * add non polling clock type 18 for just listenning to Meinberg clocks
+ *
+ * Revision 4.48  2005/04/16 16:22:27  kardel
+ * bk sync 20050415 ntp-dev
+ *
+ * Revision 4.47  2004/11/29 10:42:48  kardel
+ * bk sync ntp-dev 20041129
+ *
+ * Revision 4.46  2004/11/29 10:26:29  kardel
+ * keep fudgetime2 in sync with trusttime/ppsphaseadjust depending in flag1
+ *
+ * Revision 4.45  2004/11/14 20:53:20  kardel
+ * clear PPS flags after using them
+ *
+ * Revision 4.44  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ * Revision 4.43  2001/05/26 22:53:16  kardel
+ * 20010526 reconcilation
+ *
+ * Revision 4.42  2000/05/14 15:31:51  kardel
+ * PPSAPI && RAWDCF modemline support
+ *
+ * Revision 4.41  2000/04/09 19:50:45  kardel
+ * fixed rawdcfdtr_init() -> rawdcf_init_1
+ *
+ * Revision 4.40  2000/04/09 15:27:55  kardel
+ * modem line fiddle in rawdcf_init_2
+ *
+ * Revision 4.39  2000/03/18 09:16:55  kardel
+ * PPSAPI integration
+ *
+ * Revision 4.38  2000/03/05 20:25:06  kardel
+ * support PPSAPI
+ *
+ * Revision 4.37  2000/03/05 20:11:14  kardel
+ * 4.0.99g reconcilation
+ *
+ * Revision 4.36  1999/11/28 17:18:20  kardel
+ * disabled burst mode
+ *
+ * Revision 4.35  1999/11/28 09:14:14  kardel
+ * RECON_4_0_98F
+ *
+ * Revision 4.34  1999/05/14 06:08:05  kardel
+ * store current_time in a suitable container (u_long)
+ *
+ * Revision 4.33  1999/05/13 21:48:38  kardel
+ * double the no response timeout interval
+ *
+ * Revision 4.32  1999/05/13 20:09:13  kardel
+ * complain only about missing polls after a full poll interval
+ *
+ * Revision 4.31  1999/05/13 19:59:32  kardel
+ * add clock type 16 for RTS set DTR clr in RAWDCF
+ *
+ * Revision 4.30  1999/02/28 20:36:43  kardel
+ * fixed printf fmt
+ *
+ * Revision 4.29  1999/02/28 19:58:23  kardel
+ * updated copyright information
+ *
+ * Revision 4.28  1999/02/28 19:01:50  kardel
+ * improved debug out on sent Meinberg messages
+ *
+ * Revision 4.27  1999/02/28 18:05:55  kardel
+ * no linux/ppsclock.h stuff
+ *
+ * Revision 4.26  1999/02/28 15:27:27  kardel
+ * wharton clock integration
+ *
+ * Revision 4.25  1999/02/28 14:04:46  kardel
+ * added missing double quotes to UTC information string
+ *
+ * Revision 4.24  1999/02/28 12:06:50  kardel
+ * (parse_control): using gmprettydate instead of prettydate()
+ * (mk_utcinfo): new function for formatting GPS derived UTC information
+ * (gps16x_message): changed to use mk_utcinfo()
+ * (trimbletsip_message): changed to use mk_utcinfo()
+ * ignoring position information in unsynchronized mode
+ * (parse_start): augument linux support for optional ASYNC_LOW_LATENCY
+ *
+ * Revision 4.23  1999/02/23 19:47:53  kardel
+ * fixed #endifs
+ * (stream_receive): fixed formats
+ *
+ * Revision 4.22  1999/02/22 06:21:02  kardel
+ * use new autoconfig symbols
+ *
+ * Revision 4.21  1999/02/21 12:18:13  kardel
+ * 4.91f reconcilation
+ *
+ * Revision 4.20  1999/02/21 10:53:36  kardel
+ * initial Linux PPSkit version
+ *
+ * Revision 4.19  1999/02/07 09:10:45  kardel
+ * clarify STREAMS mitigation rules in comment
+ *
+ * Revision 4.18  1998/12/20 23:45:34  kardel
+ * fix types and warnings
+ *
+ * Revision 4.17  1998/11/15 21:24:51  kardel
+ * cannot access mbg_ routines when CLOCK_MEINBERG
+ * is not defined
+ *
+ * Revision 4.16  1998/11/15 20:28:17  kardel
+ * Release 4.0.73e13 reconcilation
+ *
+ * Revision 4.15  1998/08/22 21:56:08  kardel
+ * fixed IO handling for non-STREAM IO
+ *
+ * Revision 4.14  1998/08/16 19:00:48  kardel
+ * (gps16x_message): reduced UTC parameter information (dropped A0,A1)
+ * made uval a local variable (killed one of the last globals)
+ * (sendetx): added logging of messages when in debug mode
+ * (trimble_check): added periodic checks to facilitate re-initialization
+ * (trimbletsip_init): made use of EOL character if in non-kernel operation
+ * (trimbletsip_message): extended message interpretation
+ * (getdbl): fixed data conversion
+ *
+ * Revision 4.13  1998/08/09 22:29:13  kardel
+ * Trimble TSIP support
+ *
+ * Revision 4.12  1998/07/11 10:05:34  kardel
+ * Release 4.0.73d reconcilation
+ *
+ * Revision 4.11  1998/06/14 21:09:42  kardel
+ * Sun acc cleanup
+ *
+ * Revision 4.10  1998/06/13 12:36:45  kardel
+ * signed/unsigned, name clashes
+ *
+ * Revision 4.9  1998/06/12 15:30:00  kardel
+ * prototype fixes
+ *
+ * Revision 4.8  1998/06/12 11:19:42  kardel
+ * added direct input processing routine for refclocks in
+ * order to avaiod that single character io gobbles up all
+ * receive buffers and drops input data. (Problem started
+ * with fast machines so a character a buffer was possible
+ * one of the few cases where faster machines break existing
+ * allocation algorithms)
+ *
+ * Revision 4.7  1998/06/06 18:35:20  kardel
+ * (parse_start): added BURST mode initialisation
+ *
+ * Revision 4.6  1998/05/27 06:12:46  kardel
+ * RAWDCF_BASEDELAY default added
+ * old comment removed
+ * casts for ioctl()
+ *
+ * Revision 4.5  1998/05/25 22:05:09  kardel
+ * RAWDCF_SETDTR option removed
+ * clock type 14 attempts to set DTR for
+ * power supply of RAWDCF receivers
+ *
+ * Revision 4.4  1998/05/24 16:20:47  kardel
+ * updated comments referencing Meinberg clocks
+ * added RAWDCF clock with DTR set option as type 14
+ *
+ * Revision 4.3  1998/05/24 10:48:33  kardel
+ * calibrated CONRAD RAWDCF default fudge factor
+ *
+ * Revision 4.2  1998/05/24 09:59:35  kardel
+ * corrected version information (ntpq support)
+ *
+ * Revision 4.1  1998/05/24 09:52:31  kardel
+ * use fixed format only (new IO model)
+ * output debug to stdout instead of msyslog()
+ * don't include >"< in ASCII output in order not to confuse
+ * ntpq parsing
+ *
+ * Revision 4.0  1998/04/10 19:52:11  kardel
+ * Start 4.0 release version numbering
+ *
+ * Revision 1.2  1998/04/10 19:28:04  kardel
+ * initial NTP VERSION 4 integration of PARSE with GPS166 binary support
+ * derived from 3.105.1.2 from V3 tree
+ *
+ * Revision information 3.1 - 3.105 from log deleted 1998/04/10 kardel
+ *
+ */
diff --git a/ntpd/refclock_pcf.c b/ntpd/refclock_pcf.c
new file mode 100644 (file)
index 0000000..d4e9fd1
--- /dev/null
@@ -0,0 +1,224 @@
+/*
+ * refclock_pcf - clock driver for the Conrad parallel port radio clock
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PCF)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+/*
+ * This driver supports the parallel port radio clock sold by Conrad
+ * Electronic under order numbers 967602 and 642002.
+ *
+ * It requires that the local timezone be CET/CEST and that the pcfclock
+ * device driver be installed.  A device driver for Linux is available at
+ * http://home.pages.de/~voegele/pcf.html.  Information about a FreeBSD
+ * driver is available at http://schumann.cx/pcfclock/.
+ */
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/pcfclocks/%d"
+#define        OLDDEVICE       "/dev/pcfclock%d"
+#define        PRECISION       (-1)    /* precision assumed (about 0.5 s) */
+#define REFID          "PCF"
+#define DESCRIPTION    "Conrad parallel port radio clock"
+
+#define LENPCF         18      /* timecode length */
+
+/*
+ * Function prototypes
+ */
+static int     pcf_start               P((int, struct peer *));
+static void    pcf_shutdown            P((int, struct peer *));
+static void    pcf_poll                P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct  refclock refclock_pcf = {
+       pcf_start,              /* start up driver */
+       pcf_shutdown,           /* shut down driver */
+       pcf_poll,               /* transmit poll message */
+       noentry,                /* not used */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * pcf_start - open the device and initialize data for processing
+ */
+static int
+pcf_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       int fd;
+       char device[128];
+
+       /*
+        * Open device file for reading.
+        */
+       (void)sprintf(device, DEVICE, unit);
+       fd = open(device, O_RDONLY);
+       if (fd == -1) {
+               (void)sprintf(device, OLDDEVICE, unit);
+               fd = open(device, O_RDONLY);
+       }
+#ifdef DEBUG
+       if (debug)
+               printf ("starting PCF with device %s\n",device);
+#endif
+       if (fd == -1) {
+               return (0);
+       }
+       
+       pp = peer->procptr;
+       pp->io.clock_recv = noentry;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       /* one transmission takes 172.5 milliseconds since the radio clock
+          transmits 69 bits with a period of 2.5 milliseconds per bit */
+       pp->fudgetime1 = 0.1725;
+       memcpy((char *)&pp->refid, REFID, 4);
+
+       return (1);
+}
+
+
+/*
+ * pcf_shutdown - shut down the clock
+ */
+static void
+pcf_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       
+       pp = peer->procptr;
+       (void)close(pp->io.fd);
+}
+
+
+/*
+ * pcf_poll - called by the transmit procedure
+ */
+static void
+pcf_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       char buf[LENPCF];
+       struct tm tm, *tp;
+       time_t t;
+       
+       pp = peer->procptr;
+
+       buf[0] = 0;
+       if (read(pp->io.fd, buf, sizeof(buf)) < sizeof(buf) || buf[0] != 9) {
+               refclock_report(peer, CEVNT_FAULT);
+               return;
+       }
+
+       tm.tm_mday = buf[11] * 10 + buf[10];
+       tm.tm_mon = buf[13] * 10 + buf[12] - 1;
+       tm.tm_year = buf[15] * 10 + buf[14];
+       tm.tm_hour = buf[7] * 10 + buf[6];
+       tm.tm_min = buf[5] * 10 + buf[4];
+       tm.tm_sec = buf[3] * 10 + buf[2];
+       tm.tm_isdst = (buf[8] & 1) ? 1 : (buf[8] & 2) ? 0 : -1;
+
+       /*
+        * Y2K convert the 2-digit year
+        */
+       if (tm.tm_year < 99)
+               tm.tm_year += 100;
+       
+       t = mktime(&tm);
+       if (t == (time_t) -1) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+
+#if defined(__GLIBC__) && defined(_BSD_SOURCE)
+       if ((tm.tm_isdst > 0 && tm.tm_gmtoff != 7200)
+           || (tm.tm_isdst == 0 && tm.tm_gmtoff != 3600)
+           || tm.tm_isdst < 0) {
+#ifdef DEBUG
+               if (debug)
+                       printf ("local time zone not set to CET/CEST\n");
+#endif
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+#endif
+
+       pp->lencode = strftime(pp->a_lastcode, BMAX, "%Y %m %d %H %M %S", &tm);
+
+#if defined(_REENTRANT) || defined(_THREAD_SAFE)
+       tp = gmtime_r(&t, &tm);
+#else
+       tp = gmtime(&t);
+#endif
+       if (!tp) {
+               refclock_report(peer, CEVNT_FAULT);
+               return;
+       }
+
+       get_systime(&pp->lastrec);
+       pp->polls++;
+       pp->year = tp->tm_year + 1900;
+       pp->day = tp->tm_yday + 1;
+       pp->hour = tp->tm_hour;
+       pp->minute = tp->tm_min;
+       pp->second = tp->tm_sec;
+       pp->nsec = buf[16] * 31250000;
+       if (buf[17] & 1)
+               pp->nsec += 500000000;
+
+#ifdef DEBUG
+       if (debug)
+               printf ("pcf%d: time is %04d/%02d/%02d %02d:%02d:%02d UTC\n",
+                       unit, pp->year, tp->tm_mon + 1, tp->tm_mday, pp->hour,
+                       pp->minute, pp->second);
+#endif
+
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       if ((buf[1] & 1) && !(pp->sloppyclockflag & CLK_FLAG2))
+               pp->leap = LEAP_NOTINSYNC;
+       else
+               pp->leap = LEAP_NOWARNING;
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+}
+#else
+int refclock_pcf_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_pst.c b/ntpd/refclock_pst.c
new file mode 100644 (file)
index 0000000..776e28e
--- /dev/null
@@ -0,0 +1,322 @@
+/*
+ * refclock_pst - clock driver for PSTI/Traconex WWV/WWVH receivers
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_PST)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+/*
+ * This driver supports the PSTI 1010 and Traconex 1020 WWV/WWVH
+ * Receivers. No specific claim of accuracy is made for these receiver,
+ * but actual experience suggests that 10 ms would be a conservative
+ * assumption.
+ * 
+ * The DIPswitches should be set for 9600 bps line speed, 24-hour day-
+ * of-year format and UTC time zone. Automatic correction for DST should
+ * be disabled. It is very important that the year be set correctly in
+ * the DIPswitches; otherwise, the day of year will be incorrect after
+ * 28 April of a normal or leap year. The propagation delay DIPswitches
+ * should be set according to the distance from the transmitter for both
+ * WWV and WWVH, as described in the instructions. While the delay can
+ * be set only to within 11 ms, the fudge time1 parameter can be used
+ * for vernier corrections.
+ *
+ * Using the poll sequence QTQDQM, the response timecode is in three
+ * sections totalling 50 ASCII printing characters, as concatenated by
+ * the driver, in the following format:
+ *
+ * ahh:mm:ss.fffs<cr> yy/dd/mm/ddd<cr> frdzycchhSSFTttttuuxx<cr>
+ *
+ *     on-time = first <cr>
+ *     hh:mm:ss.fff = hours, minutes, seconds, milliseconds
+ *     a = AM/PM indicator (' ' for 24-hour mode)
+ *     yy = year (from internal switches)
+ *     dd/mm/ddd = day of month, month, day of year
+ *     s = daylight-saving indicator (' ' for 24-hour mode)
+ *     f = frequency enable (O = all frequencies enabled)
+ *     r = baud rate (3 = 1200, 6 = 9600)
+ *     d = features indicator (@ = month/day display enabled)
+ *     z = time zone (0 = UTC)
+ *     y = year (5 = 91)
+ *     cc = WWV propagation delay (52 = 22 ms)
+ *     hh = WWVH propagation delay (81 = 33 ms)
+ *     SS = status (80 or 82 = operating correctly)
+ *     F = current receive frequency (4 = 15 MHz)
+ *     T = transmitter (C = WWV, H = WWVH)
+ *     tttt = time since last update (0000 = minutes)
+ *     uu = flush character (03 = ^c)
+ *     xx = 94 (unknown)
+ *
+ * The alarm condition is indicated by other than '8' at A, which occurs
+ * during initial synchronization and when received signal is lost for
+ * an extended period; unlock condition is indicated by other than
+ * "0000" in the tttt subfield at Q.
+ *
+ * Fudge Factors
+ *
+ * There are no special fudge factors other than the generic.
+ */
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/wwv%d" /* device name and unit */
+#define        SPEED232        B9600   /* uart speed (9600 baud) */
+#define        PRECISION       (-10)   /* precision assumed (about 1 ms) */
+#define        WWVREFID        "WWV\0" /* WWV reference ID */
+#define        WWVHREFID       "WWVH"  /* WWVH reference ID */
+#define        DESCRIPTION     "PSTI/Traconex WWV/WWVH Receiver" /* WRU */
+#define PST_PHI                (10e-6) /* max clock oscillator offset */
+#define LENPST         46      /* min timecode length */
+
+/*
+ * Unit control structure
+ */
+struct pstunit {
+       int     tcswitch;       /* timecode switch */
+       char    *lastptr;       /* pointer to timecode data */
+};
+
+/*
+ * Function prototypes
+ */
+static int     pst_start       P((int, struct peer *));
+static void    pst_shutdown    P((int, struct peer *));
+static void    pst_receive     P((struct recvbuf *));
+static void    pst_poll        P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_pst = {
+       pst_start,              /* start up driver */
+       pst_shutdown,           /* shut down driver */
+       pst_poll,               /* transmit poll message */
+       noentry,                /* not used (old pst_control) */
+       noentry,                /* initialize driver */
+       noentry,                /* not used (old pst_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * pst_start - open the devices and initialize data for processing
+ */
+static int
+pst_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct pstunit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+
+       /*
+        * Open serial port. Use CLK line discipline, if available.
+        */
+       (void)sprintf(device, DEVICE, unit);
+       if (!(fd = refclock_open(device, SPEED232, LDISC_CLK)))
+               return (0);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct pstunit *)emalloc(sizeof(struct pstunit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct pstunit));
+       pp = peer->procptr;
+       pp->io.clock_recv = pst_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, WWVREFID, 4);
+       peer->burst = MAXSTAGE;
+       return (1);
+}
+
+
+/*
+ * pst_shutdown - shut down the clock
+ */
+static void
+pst_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct pstunit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct pstunit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * pst_receive - receive data from the serial interface
+ */
+static void
+pst_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct pstunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       l_fp trtmp;
+       u_long ltemp;
+       char ampmchar;          /* AM/PM indicator */
+       char daychar;           /* standard/daylight indicator */
+       char junque[10];        /* "yy/dd/mm/" discard */
+       char info[14];          /* "frdzycchhSSFT" clock info */
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct pstunit *)pp->unitptr;
+       up->lastptr += refclock_gtlin(rbufp, up->lastptr, pp->a_lastcode
+           + BMAX - 2 - up->lastptr, &trtmp);
+       *up->lastptr++ = ' ';
+       *up->lastptr = '\0';
+
+       /*
+        * Note we get a buffer and timestamp for each <cr>, but only
+        * the first timestamp is retained.
+        */
+       if (up->tcswitch == 0)
+               pp->lastrec = trtmp;
+       up->tcswitch++;
+       pp->lencode = up->lastptr - pp->a_lastcode;
+       if (up->tcswitch < 3)
+               return;
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. If the timecode has invalid length or is not in
+        * proper format, we declare bad format and exit.
+        */
+       if (pp->lencode < LENPST) {
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       /*
+        * Timecode format:
+        * "ahh:mm:ss.fffs yy/dd/mm/ddd frdzycchhSSFTttttuuxx"
+        */
+       if (sscanf(pp->a_lastcode,
+           "%c%2d:%2d:%2d.%3ld%c %9s%3d%13s%4ld",
+           &ampmchar, &pp->hour, &pp->minute, &pp->second, &pp->nsec,
+           &daychar, junque, &pp->day, info, &ltemp) != 10) {
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+       pp->nsec *= 1000000;
+
+       /*
+        * Decode synchronization, quality and last update. If
+        * unsynchronized, set the leap bits accordingly and exit. Once
+        * synchronized, the dispersion depends only on when the clock
+        * was last heard, which depends on the time since last update,
+        * as reported by the clock.
+        */
+       if (info[9] != '8')
+               pp->leap = LEAP_NOTINSYNC;
+       if (info[12] == 'H')
+               memcpy((char *)&pp->refid, WWVHREFID, 4);
+       else
+               memcpy((char *)&pp->refid, WWVREFID, 4);
+       if (peer->stratum <= 1)
+               peer->refid = pp->refid;
+       if (ltemp == 0)
+               pp->lastref = pp->lastrec;
+       pp->disp = PST_PHI * ltemp * 60;
+
+       /*
+        * Process the new sample in the median filter and determine the
+        * timecode timestamp.
+        */
+       if (!refclock_process(pp))
+               refclock_report(peer, CEVNT_BADTIME);
+       else if (peer->disp > MAXDISTANCE)
+               refclock_receive(peer);
+}
+
+
+/*
+ * pst_poll - called by the transmit procedure
+ */
+static void
+pst_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct pstunit *up;
+       struct refclockproc *pp;
+
+       /*
+        * Time to poll the clock. The PSTI/Traconex clock responds to a
+        * "QTQDQMT" by returning a timecode in the format specified
+        * above. Note there is no checking on state, since this may not
+        * be the only customer reading the clock. Only one customer
+        * need poll the clock; all others just listen in. If the clock
+        * becomes unreachable, declare a timeout and keep going.
+        */
+       pp = peer->procptr;
+       up = (struct pstunit *)pp->unitptr;
+       up->tcswitch = 0;
+       up->lastptr = pp->a_lastcode;
+       if (write(pp->io.fd, "QTQDQMT", 6) != 6)
+               refclock_report(peer, CEVNT_FAULT);
+       if (peer->burst > 0)
+               return;
+       if (pp->coderecv == pp->codeproc) {
+               refclock_report(peer, CEVNT_TIMEOUT);
+               return;
+       }
+       refclock_receive(peer);
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+       if (debug)
+               printf("pst: timecode %d %s\n", pp->lencode,
+                   pp->a_lastcode);
+#endif
+       peer->burst = MAXSTAGE;
+       pp->polls++;
+}
+
+#else
+int refclock_pst_int;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_ripencc.c b/ntpd/refclock_ripencc.c
new file mode 100644 (file)
index 0000000..d9fa204
--- /dev/null
@@ -0,0 +1,4866 @@
+/*
+ * $Id: refclock_ripencc.c,v 1.13 2002/06/18 14:20:55 marks Exp marks $
+ *
+ * Copyright (c) 2002  RIPE NCC
+ *
+ * All Rights Reserved
+ *
+ * Permission to use, copy, modify, and distribute this software and its
+ * documentation for any purpose and without fee is hereby granted,
+ * 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 the author not be
+ * used in advertising or publicity pertaining to distribution of the
+ * software without specific, written prior permission.
+ *
+ * THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
+ * ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS; IN NO EVENT SHALL
+ * AUTHOR 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.
+ *
+ *
+ *
+ * This driver was developed for use with the RIPE NCC TTM project.
+ *
+ *
+ * The initial driver was developed by Daniel Karrenberg <dfk@ripe.net> 
+ * using the code made available by Trimble. This was for xntpd-3.x.x
+ *
+ * Rewrite of the driver for ntpd-4.x.x by Mark Santcroos <marks@ripe.net>
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#if defined(REFCLOCK) && defined(CLOCK_RIPENCC)
+
+#include "ntp_stdlib.h"
+#include "ntpd.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_io.h"
+
+#ifdef HAVE_PPSAPI
+# include "ppsapi_timepps.h"
+#endif
+
+/*
+ * Definitions
+ */
+
+/* we are on little endian */
+#define BYTESWAP
+
+/* 
+ * DEBUG statements: uncomment if necessary
+ */
+/* #define DEBUG_NCC */ /* general debug statements */
+/* #define DEBUG_PPS */ /* debug pps */
+/* #define DEBUG_RAW */ /* print raw packets */
+
+#define TRIMBLE_OUTPUT_FUNC
+#define TSIP_VERNUM "7.12a"
+
+#ifndef FALSE
+#define FALSE  (0)
+#define TRUE   (!FALSE)
+#endif /* FALSE */
+
+#define GPS_PI         (3.1415926535898)
+#define GPS_C          (299792458.)
+#define        D2R             (GPS_PI/180.0)
+#define        R2D             (180.0/GPS_PI)
+#define WEEK   (604800.)
+#define MAXCHAN  (8)
+
+/* control characters for TSIP packets */
+#define DLE    (0x10)
+#define ETX    (0x03)
+
+#define MAX_RPTBUF (256)
+
+/* values of TSIPPKT.status */
+#define TSIP_PARSED_EMPTY      0
+#define TSIP_PARSED_FULL       1
+#define TSIP_PARSED_DLE_1      2
+#define TSIP_PARSED_DATA       3
+#define TSIP_PARSED_DLE_2      4
+
+#define UTCF_UTC_AVAIL  (unsigned char) (1)             /* UTC available */
+#define UTCF_LEAP_SCHD  (unsigned char) (1<<4)  /* Leap scheduled */
+#define UTCF_LEAP_PNDG  (unsigned char) (1<<5)  /* Leap pending, will occur at end of day */
+
+#define DEVICE  "/dev/gps%d"   /* name of radio device */
+#define PRECISION       (-9)    /* precision assumed (about 2 ms) */
+#define PPS_PRECISION   (-20)  /* precision assumed (about 1 us) */
+#define REFID           "GPS\0" /* reference id */
+#define REFID_LEN      4
+#define DESCRIPTION     "RIPE NCC GPS (Palisade)"      /* Description */
+#define SPEED232        B9600   /* 9600 baud */
+
+#define NSAMPLES        3       /* stages of median filter */
+
+/* Structures */
+
+/* TSIP packets have the following structure, whether report or command. */
+typedef struct {
+       short 
+               counter,        /* counter */
+               len;            /* size of buf; < MAX_RPTBUF unsigned chars */
+       unsigned char
+               status,         /* TSIP packet format/parse status */
+               code,           /* TSIP code */
+               buf[MAX_RPTBUF];/* report or command string */
+} TSIPPKT;
+
+/* TSIP binary data structures */
+typedef struct {
+       unsigned char
+               t_oa_raw, SV_health;
+       float
+               e, t_oa, i_0, OMEGADOT, sqrt_A,
+               OMEGA_0, omega, M_0, a_f0, a_f1,
+               Axis, n, OMEGA_n, ODOT_n, t_zc;
+       short
+               weeknum, wn_oa;
+} ALM_INFO;
+
+typedef struct {     /*  Almanac health page (25) parameters  */
+       unsigned char
+               WN_a, SV_health[32], t_oa;
+} ALH_PARMS;
+
+typedef struct {     /*  Universal Coordinated Time (UTC) parms */
+       double
+               A_0;
+       float
+               A_1;
+       short
+               delta_t_LS;
+       float
+               t_ot;
+       short
+               WN_t, WN_LSF, DN, delta_t_LSF;
+} UTC_INFO;
+
+typedef struct {      /*  Ionospheric info (float)  */
+       float
+               alpha_0, alpha_1, alpha_2, alpha_3,
+               beta_0, beta_1, beta_2, beta_3;
+} ION_INFO;
+
+typedef struct {      /*  Subframe 1 info (float)  */
+       short
+               weeknum;
+       unsigned char
+               codeL2, L2Pdata, SVacc_raw, SV_health;
+       short
+               IODC;
+       float
+               T_GD, t_oc, a_f2, a_f1, a_f0, SVacc;
+} EPHEM_CLOCK;
+
+typedef        struct {     /*  Ephemeris info (float)  */
+       unsigned char
+               IODE, fit_interval;
+       float
+               C_rs, delta_n;
+       double
+               M_0;
+       float
+               C_uc;
+       double
+               e;
+       float
+               C_us;
+       double
+               sqrt_A;
+       float
+               t_oe, C_ic;
+       double
+               OMEGA_0;
+       float
+               C_is;
+       double
+               i_0;
+       float
+               C_rc;
+       double
+               omega;
+       float
+               OMEGADOT, IDOT;
+       double
+               Axis, n, r1me2, OMEGA_n, ODOT_n;
+} EPHEM_ORBIT;
+
+typedef struct {     /* Navigation data structure */
+       short
+               sv_number;     /* SV number (0 = no entry) */
+       float
+               t_ephem;       /* time of ephemeris collection */
+       EPHEM_CLOCK
+               ephclk;        /* subframe 1 data */
+       EPHEM_ORBIT
+               ephorb;        /* ephemeris data */
+} NAV_INFO;
+
+typedef struct {
+       unsigned char
+               bSubcode,
+               operating_mode,
+               dgps_mode,
+               dyn_code,
+               trackmode;
+       float
+               elev_mask,
+               cno_mask,
+               dop_mask,
+               dop_switch;
+       unsigned char
+               dgps_age_limit;
+} TSIP_RCVR_CFG;
+
+
+#ifdef TRIMBLE_OUTPUT_FUNC
+static char
+       *dayname[7] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"},
+       old_baudnum[] = {0, 1, 4, 5, 6, 8, 9, 11, 28, 12},
+        *st_baud_text_app [] = {"", "", "  300", "  600", " 1200", " 2400", 
+               " 4800", " 9600", "19200", "38400"},
+       *old_parity_text[] = {"EVEN", "ODD", "", "", "NONE"},
+       *parity_text [] = {"NONE", "ODD", "EVEN"},
+       *old_input_ch[] = { "TSIP", "RTCM (6 of 8 bits)"},
+       *old_output_ch[] = { "TSIP", "No output", "", "", "", "NMEA 0183"},
+       *protocols_in_text[] = { "", "TSIP", "", ""},
+       *protocols_out_text[] = { "", "TSIP", "NMEA"},
+       *rcvr_port_text [] = { "Port A      ", "Port B      ", "Current Port"},
+       *dyn_text [] = {"Unchanged", "Land", "Sea", "Air", "Static"},
+       *NavModeText0xBB[] = {"automatic", "time only (0-D)", "", "2-D",
+               "3-D", "", "", "OverDetermined Time"},
+       *PPSTimeBaseText[] = {"GPS", "UTC", "USER"},
+       *PPSPolarityText[] = {"Positive", "Negative"},
+       *MaskText[] = { "Almanac  ", "Ephemeris", "UTC      ", "Iono     ",
+               "GPS Msg  ", "Alm Hlth ", "Time Fix ", "SV Select",
+               "Ext Event", "Pos Fix  ", "Raw Meas "};
+
+#endif /* TRIMBLE_OUTPUT_FUNC */
+
+/*
+ * Unit control structure
+ */
+struct ripencc_unit {                   
+        int unit;                       /* unit number */
+        int     pollcnt;                /* poll message counter */
+        int     polled;                 /* Hand in a sample? */
+        char leapdelta;                 /* delta of next leap event */
+        unsigned char utcflags;         /* delta of next leap event */
+        l_fp    tstamp;                 /* timestamp of last poll */
+        
+        struct timespec ts;             /* last timestamp */
+        pps_params_t pps_params;        /* pps parameters */
+        pps_info_t pps_info;            /* last pps data */
+        pps_handle_t handle;            /* pps handlebars */
+
+};
+
+
+/*******************        PROTOYPES            *****************/
+
+/*  prototypes for report parsing primitives */
+short rpt_0x3D (TSIPPKT *rpt, unsigned char *tx_baud_index,
+       unsigned char *rx_baud_index, unsigned char *char_format_index,
+       unsigned char *stop_bits, unsigned char *tx_mode_index,
+       unsigned char *rx_mode_index);
+short rpt_0x40 (TSIPPKT *rpt, unsigned char *sv_prn, short *week_num,
+       float *t_zc, float *eccentricity, float *t_oa, float *i_0,
+       float *OMEGA_dot, float *sqrt_A, float *OMEGA_0, float *omega,
+       float *M_0);
+short rpt_0x41 (TSIPPKT *rpt, float *time_of_week, float *UTC_offset,
+       short *week_num);
+short rpt_0x42 (TSIPPKT *rpt, float ECEF_pos[3], float *time_of_fix);
+short rpt_0x43 (TSIPPKT *rpt, float ECEF_vel[3], float *freq_offset,
+       float *time_of_fix);
+short rpt_0x45 (TSIPPKT *rpt, unsigned char *major_nav_version,
+       unsigned char *minor_nav_version, unsigned char *nav_day,
+       unsigned char *nav_month, unsigned char *nav_year,
+       unsigned char *major_dsp_version, unsigned char *minor_dsp_version,
+       unsigned char *dsp_day, unsigned char *dsp_month,
+       unsigned char *dsp_year);
+short rpt_0x46 (TSIPPKT *rpt, unsigned char *status1, unsigned char *status2);
+short rpt_0x47 (TSIPPKT *rpt, unsigned char *nsvs, unsigned char *sv_prn,
+       float *snr);
+short rpt_0x48 (TSIPPKT *rpt, unsigned char *message);
+short rpt_0x49 (TSIPPKT *rpt, unsigned char *sv_health);
+short rpt_0x4A (TSIPPKT *rpt, float *lat, float *lon, float *alt,
+       float *clock_bias, float *time_of_fix);
+short rpt_0x4A_2 (TSIPPKT *rpt, float *alt, float *dummy,
+       unsigned char *alt_flag);
+short rpt_0x4B (TSIPPKT *rpt, unsigned char *machine_id,
+       unsigned char *status3, unsigned char *status4);
+short rpt_0x4C (TSIPPKT *rpt, unsigned char *dyn_code, float *el_mask,
+       float *snr_mask, float *dop_mask, float *dop_switch);
+short rpt_0x4D (TSIPPKT *rpt, float *osc_offset);
+short rpt_0x4E (TSIPPKT *rpt, unsigned char *response);
+short rpt_0x4F (TSIPPKT *rpt, double *a0, float *a1, float *time_of_data,
+       short *dt_ls, short *wn_t, short *wn_lsf, short *dn, short *dt_lsf);
+short rpt_0x54 (TSIPPKT *rpt, float *clock_bias, float *freq_offset,
+       float *time_of_fix);
+short rpt_0x55 (TSIPPKT *rpt, unsigned char *pos_code, unsigned char *vel_code,
+       unsigned char *time_code, unsigned char *aux_code);
+short rpt_0x56 (TSIPPKT *rpt, float vel_ENU[3], float *freq_offset,
+       float *time_of_fix);
+short rpt_0x57 (TSIPPKT *rpt, unsigned char *source_code,
+       unsigned char *diag_code, short *week_num, float *time_of_fix);
+short rpt_0x58 (TSIPPKT *rpt, unsigned char *op_code, unsigned char *data_type,
+       unsigned char *sv_prn, unsigned char *data_length,
+       unsigned char *data_packet);
+short rpt_0x59 (TSIPPKT *rpt, unsigned char *code_type,
+       unsigned char status_code[32]);
+short rpt_0x5A (TSIPPKT *rpt, unsigned char *sv_prn, float *sample_length,
+       float *signal_level, float *code_phase, float *Doppler,
+       double *time_of_fix);
+short rpt_0x5B (TSIPPKT *rpt, unsigned char *sv_prn, unsigned char *sv_health,
+       unsigned char *sv_iode, unsigned char *fit_interval_flag,
+       float *time_of_collection, float *time_of_eph, float *sv_accy);
+short rpt_0x5C (TSIPPKT *rpt, unsigned char *sv_prn, unsigned char *slot,
+       unsigned char *chan, unsigned char *acq_flag, unsigned char *eph_flag,
+       float *signal_level, float *time_of_last_msmt, float *elev,
+       float *azim, unsigned char *old_msmt_flag,
+       unsigned char *integer_msec_flag, unsigned char *bad_data_flag,
+       unsigned char *data_collect_flag);
+short rpt_0x6D (TSIPPKT *rpt, unsigned char *manual_mode, unsigned char *nsvs,
+       unsigned char *ndim, unsigned char sv_prn[], float *pdop,
+       float *hdop, float *vdop, float *tdop);
+short rpt_0x82 (TSIPPKT *rpt, unsigned char *diff_mode);
+short rpt_0x83 (TSIPPKT *rpt, double ECEF_pos[3], double *clock_bias,
+       float *time_of_fix);
+short rpt_0x84 (TSIPPKT *rpt, double *lat, double *lon, double *alt,
+       double *clock_bias, float *time_of_fix);
+short rpt_Paly0xBB(TSIPPKT *rpt, TSIP_RCVR_CFG *TsipxBB);
+short rpt_0xBC   (TSIPPKT *rpt, unsigned char *port_num,
+       unsigned char *in_baud, unsigned char *out_baud,
+       unsigned char *data_bits, unsigned char *parity,
+       unsigned char *stop_bits, unsigned char *flow_control,
+       unsigned char *protocols_in, unsigned char *protocols_out,
+       unsigned char *reserved);
+
+/* prototypes for superpacket parsers */
+
+short rpt_0x8F0B (TSIPPKT *rpt, unsigned short *event, double *tow,
+   unsigned char *date, unsigned char *month, short *year,
+   unsigned char *dim_mode, short *utc_offset, double *bias, double *drift,
+   float *bias_unc, float *dr_unc, double *lat, double *lon, double *alt,
+   char sv_id[8]);
+short rpt_0x8F14 (TSIPPKT *rpt, short *datum_idx, double datum_coeffs[5]);
+short rpt_0x8F15 (TSIPPKT *rpt, short *datum_idx, double datum_coeffs[5]);
+short rpt_0x8F20 (TSIPPKT *rpt, unsigned char *info, double *lat,
+       double *lon, double *alt, double vel_enu[], double *time_of_fix,
+       short *week_num, unsigned char *nsvs, unsigned char sv_prn[], 
+       short sv_IODC[], short *datum_index);
+short rpt_0x8F41 (TSIPPKT *rpt, unsigned char *bSearchRange,
+       unsigned char *bBoardOptions, unsigned long *iiSerialNumber,
+       unsigned char *bBuildYear, unsigned char *bBuildMonth,
+       unsigned char *bBuildDay, unsigned char *bBuildHour,
+       float *fOscOffset, unsigned short *iTestCodeId);
+short rpt_0x8F42 (TSIPPKT *rpt, unsigned char *bProdOptionsPre,
+       unsigned char *bProdNumberExt, unsigned short *iCaseSerialNumberPre,
+       unsigned long *iiCaseSerialNumber, unsigned long *iiProdNumber,
+       unsigned short *iPremiumOptions, unsigned short *iMachineID,
+       unsigned short *iKey);
+short rpt_0x8F45 (TSIPPKT *rpt, unsigned char *bSegMask);
+short rpt_0x8F4A_16 (TSIPPKT *rpt, unsigned char *pps_enabled,
+       unsigned char *pps_timebase, unsigned char *pos_polarity,
+       double *pps_offset, float *bias_unc_threshold);
+short rpt_0x8F4B (TSIPPKT *rpt, unsigned long *decorr_max);
+short rpt_0x8F4D (TSIPPKT *rpt, unsigned long *event_mask);
+short rpt_0x8FA5 (TSIPPKT *rpt, unsigned char *spktmask);
+short rpt_0x8FAD (TSIPPKT *rpt, unsigned short *COUNT, double *FracSec,
+    unsigned char *Hour, unsigned char *Minute, unsigned char *Second,
+    unsigned char *Day, unsigned char *Month, unsigned short *Year,
+    unsigned char *Status, unsigned char *Flags);
+
+/**/
+/* prototypes for command-encode primitives with suffix convention:  */
+/* c = clear, s = set, q = query, e = enable, d = disable            */
+void cmd_0x1F  (TSIPPKT *cmd);
+void cmd_0x26  (TSIPPKT *cmd);
+void cmd_0x2F  (TSIPPKT *cmd);
+void cmd_0x35s (TSIPPKT *cmd, unsigned char pos_code, unsigned char vel_code,
+       unsigned char time_code, unsigned char opts_code);
+void cmd_0x3C  (TSIPPKT *cmd, unsigned char sv_prn);
+void cmd_0x3Ds (TSIPPKT *cmd, unsigned char baud_out, unsigned char baud_inp,
+       unsigned char char_code, unsigned char stopbitcode,
+       unsigned char output_mode, unsigned char input_mode);
+void cmd_0xBBq (TSIPPKT *cmd, unsigned char subcode) ;
+
+/* prototypes 8E commands */
+void cmd_0x8E0Bq (TSIPPKT *cmd);
+void cmd_0x8E41q (TSIPPKT *cmd);
+void cmd_0x8E42q (TSIPPKT *cmd);
+void cmd_0x8E4Aq (TSIPPKT *cmd);
+void cmd_0x8E4As (TSIPPKT *cmd, unsigned char PPSOnOff, unsigned char TimeBase,
+       unsigned char Polarity, double PPSOffset, float Uncertainty);
+void cmd_0x8E4Bq (TSIPPKT *cmd);
+void cmd_0x8E4Ds (TSIPPKT *cmd, unsigned long AutoOutputMask);
+void cmd_0x8EADq (TSIPPKT *cmd);
+
+/* header/source border XXXXXXXXXXXXXXXXXXXXXXXXXX */
+
+/* Trimble parse functions */
+static         int     parse0x8FAD     P((TSIPPKT *, struct peer *));
+static         int     parse0x8F0B     P((TSIPPKT *, struct peer *));
+#ifdef TRIMBLE_OUTPUT_FUNC
+static         int     parseany        P((TSIPPKT *, struct peer *));
+static         void    TranslateTSIPReportToText       P((TSIPPKT *, char *));
+#endif /* TRIMBLE_OUTPUT_FUNC */
+static         int     parse0x5C       P((TSIPPKT *, struct peer *));
+static         int     parse0x4F       P((TSIPPKT *, struct peer *));
+static void    tsip_input_proc P((TSIPPKT *, int));
+
+/* Trimble helper functions */
+static void    bPutFloat       P((float *, unsigned char *));
+static void    bPutDouble      P((double *, unsigned char *));
+static void    bPutULong       P((unsigned long *, unsigned char *));
+static int     print_msg_table_header  P((int rptcode, char *HdrStr, int force));
+static char *  show_time       P((float time_of_week));
+
+/* RIPE NCC functions */
+static void    ripencc_control P((int, struct refclockstat *, struct
+                               refclockstat *, struct peer *));
+static int     ripencc_ppsapi  P((struct peer *, int, int));
+static int     ripencc_get_pps_ts      P((struct ripencc_unit *, l_fp *));
+static int     ripencc_start   P((int, struct peer *));
+static         void    ripencc_shutdown        P((int, struct peer *));
+static         void    ripencc_poll    P((int, struct peer *));
+static         void    ripencc_send    P((struct peer *, TSIPPKT spt));
+static         void    ripencc_receive P((struct recvbuf *));
+
+/* fill in reflock structure for our clock */
+struct refclock refclock_ripencc = {
+       ripencc_start,          /* start up driver */
+       ripencc_shutdown,       /* shut down driver */
+       ripencc_poll,           /* transmit poll message */
+       ripencc_control,        /* control function */
+       noentry,                /* initialize driver */
+       noentry,                /* debug info */
+       NOFLAGS                 /* clock flags */
+};
+
+/*
+ *  Tables to compute the ddd of year form icky dd/mm 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};
+
+
+/*
+ * ripencc_start - open the GPS devices and initialize data for processing
+ */
+static int
+ripencc_start(int unit, struct peer *peer)
+{
+       register struct ripencc_unit *up;
+       struct refclockproc *pp;
+       char device[40];
+       int fd;
+       struct termios tio;
+       TSIPPKT spt;
+
+       /*
+        * Open serial port
+        */
+       (void)snprintf(device, sizeof(device), DEVICE, unit);
+       if (!(fd = refclock_open(device, SPEED232, LDISC_RAW)))
+               return (0);
+
+       /* from refclock_palisade.c */
+       if (tcgetattr(fd, &tio) < 0) {
+               msyslog(LOG_ERR, "Palisade(%d) tcgetattr(fd, &tio): %m",unit);
+               return (0);
+       }
+
+       /*
+        * set flags
+        */
+       tio.c_cflag |= (PARENB|PARODD);
+       tio.c_iflag &= ~ICRNL;
+       if (tcsetattr(fd, TCSANOW, &tio) == -1) {
+               msyslog(LOG_ERR, "Palisade(%d) tcsetattr(fd, &tio): %m",unit);
+               return (0);
+       }
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct ripencc_unit *) 
+                               emalloc(sizeof(struct ripencc_unit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct ripencc_unit));
+       pp = peer->procptr;
+       pp->io.clock_recv = ripencc_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, REFID_LEN);
+       up->pollcnt = 2;
+       up->unit = unit;
+       up->leapdelta = 0;
+       up->utcflags = 0;
+
+       /*
+        * Initialize the Clock
+        */
+
+       /* query software versions */
+       cmd_0x1F(&spt);                 
+       ripencc_send(peer, spt);          
+
+       /* query receiver health */
+       cmd_0x26(&spt);                 
+       ripencc_send(peer, spt);
+
+       /* query serial numbers */      
+       cmd_0x8E42q(&spt);              
+       ripencc_send(peer, spt);  
+       
+       /* query manuf params */
+       cmd_0x8E41q(&spt);              
+       ripencc_send(peer, spt); 
+
+       /* i/o opts */ /* trimble manual page A30 */
+       cmd_0x35s(&spt, 
+               0x1C,   /* position */
+               0x00,   /* velocity */
+               0x05,   /* timing */
+               0x0a);  /* auxilary */
+       ripencc_send(peer, spt);
+       
+       /* turn off port A */
+       cmd_0x3Ds (&spt,
+               0x0B, /* baud_out */
+               0x0B, /* baud_inp */
+               0x07, /* char_code */
+               0x07, /* stopbitcode */
+               0x01, /* output_mode */
+               0x00); /* input_mode */
+       ripencc_send(peer, spt);
+
+       /* set i/o options */
+       cmd_0x8E4As (&spt,
+               0x01,           /* PPS on */
+               0x01,           /* Timebase UTC */
+               0x00,           /* polarity positive */
+               0.,             /* 100 ft. cable XXX make flag */
+               1e-6 * GPS_C);  /* turn of biasuncert. > (1us) */
+       ripencc_send(peer,spt);
+
+       /* all outomatic packet output off */
+       cmd_0x8E4Ds(&spt,
+               0x00000000); /* AutoOutputMask */
+       ripencc_send(peer, spt);
+
+       cmd_0xBBq (&spt,
+               0x00); /* query primary configuration */
+       ripencc_send(peer,spt);
+
+
+       /* query PPS parameters */
+       cmd_0x8E4Aq (&spt); /* query PPS params */
+       ripencc_send(peer,spt);
+
+       /* query survey limit */
+       cmd_0x8E4Bq (&spt); /* query survey limit */
+       ripencc_send(peer,spt);
+
+#ifdef DEBUG_NCC
+       if (debug)
+               printf("ripencc_start: success\n");
+#endif /* DEBUG_NCC */
+
+       /*
+        * Start the PPSAPI interface if it is there. Default to use
+        * the assert edge and do not enable the kernel hardpps.
+        */
+       if (time_pps_create(fd, &up->handle) < 0) {
+               up->handle = 0;
+               msyslog(LOG_ERR, "refclock_ripencc: time_pps_create failed: %m");
+               return (1);
+       }
+
+       return(ripencc_ppsapi(peer, 0, 0));
+}
+
+/*
+ * ripencc_control - fudge control
+ */
+static void
+ripencc_control(
+       int unit,               /* unit (not used) */
+       struct refclockstat *in, /* input parameters (not used) */
+       struct refclockstat *out, /* output parameters (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+
+#ifdef DEBUG_NCC
+       msyslog(LOG_INFO,"%s()",__FUNCTION__);
+#endif /* DEBUG_NCC */
+
+       pp = peer->procptr;
+       ripencc_ppsapi(peer, pp->sloppyclockflag & CLK_FLAG2,
+           pp->sloppyclockflag & CLK_FLAG3);
+}
+
+
+/*
+ * Initialize PPSAPI
+ */
+int
+ripencc_ppsapi(
+       struct peer *peer,      /* peer structure pointer */
+       int enb_clear,          /* clear enable */
+       int enb_hardpps         /* hardpps enable */
+       )
+{
+       struct refclockproc *pp;
+       struct ripencc_unit *up;
+       int capability;
+
+       pp = peer->procptr;
+       up = (struct ripencc_unit *)pp->unitptr;
+       if (time_pps_getcap(up->handle, &capability) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_ripencc: time_pps_getcap failed: %m");
+               return (0);
+       }
+       memset(&up->pps_params, 0, sizeof(pps_params_t));
+       if (enb_clear)
+               up->pps_params.mode = capability & PPS_CAPTURECLEAR;
+       else
+               up->pps_params.mode = capability & PPS_CAPTUREASSERT;
+       if (!up->pps_params.mode) {
+               msyslog(LOG_ERR,
+                   "refclock_ripencc: invalid capture edge %d",
+                   !enb_clear);
+               return (0);
+       }
+       up->pps_params.mode |= PPS_TSFMT_TSPEC;
+       if (time_pps_setparams(up->handle, &up->pps_params) < 0) {
+               msyslog(LOG_ERR,
+                   "refclock_ripencc: time_pps_setparams failed: %m");
+               return (0);
+       }
+       if (enb_hardpps) {
+               if (time_pps_kcbind(up->handle, PPS_KC_HARDPPS,
+                                   up->pps_params.mode & ~PPS_TSFMT_TSPEC,
+                                   PPS_TSFMT_TSPEC) < 0) {
+                       msyslog(LOG_ERR,
+                           "refclock_ripencc: time_pps_kcbind failed: %m");
+                       return (0);
+               }
+               pps_enable = 1;
+       }
+       peer->precision = PPS_PRECISION;
+
+#if DEBUG_NCC
+       if (debug) {
+               time_pps_getparams(up->handle, &up->pps_params);
+               printf(
+                   "refclock_ripencc: capability 0x%x version %d mode 0x%x kern %d\n",
+                   capability, up->pps_params.api_version,
+                   up->pps_params.mode, enb_hardpps);
+       }
+#endif /* DEBUG_NCC */
+
+       return (1);
+}
+
+/*
+ * This function is called every 64 seconds from ripencc_receive
+ * It will fetch the pps time 
+ *
+ * Return 0 on failure and 1 on success.
+ */
+static int
+ripencc_get_pps_ts(
+       struct ripencc_unit *up,
+       l_fp *tsptr
+       )
+{
+       pps_info_t pps_info;
+       struct timespec timeout, ts;
+       double dtemp;
+       l_fp tstmp;
+
+#ifdef DEBUG_PPS
+       msyslog(LOG_INFO,"ripencc_get_pps_ts\n");
+#endif /* DEBUG_PPS */
+
+
+       /*
+        * Convert the timespec nanoseconds field to ntp l_fp units.
+        */ 
+       if (up->handle == 0)
+               return (0);
+       timeout.tv_sec = 0;
+       timeout.tv_nsec = 0;
+       memcpy(&pps_info, &up->pps_info, sizeof(pps_info_t));
+       if (time_pps_fetch(up->handle, PPS_TSFMT_TSPEC, &up->pps_info,
+           &timeout) < 0)
+               return (0);
+       if (up->pps_params.mode & PPS_CAPTUREASSERT) {
+               if (pps_info.assert_sequence ==
+                   up->pps_info.assert_sequence)
+                       return (0);
+               ts = up->pps_info.assert_timestamp;
+       } else if (up->pps_params.mode & PPS_CAPTURECLEAR) {
+               if (pps_info.clear_sequence ==
+                   up->pps_info.clear_sequence)
+                       return (0);
+               ts = up->pps_info.clear_timestamp;
+       } else {
+               return (0);
+       }
+       if ((up->ts.tv_sec == ts.tv_sec) && (up->ts.tv_nsec == ts.tv_nsec))
+               return (0);
+       up->ts = ts;
+
+       tstmp.l_ui = ts.tv_sec + JAN_1970;
+       dtemp = ts.tv_nsec * FRAC / 1e9;
+       tstmp.l_uf = (u_int32)dtemp;
+
+#ifdef DEBUG_PPS
+       msyslog(LOG_INFO,"ts.tv_sec: %d\n",(int)ts.tv_sec);
+       msyslog(LOG_INFO,"ts.tv_nsec: %ld\n",ts.tv_nsec);
+#endif /* DEBUG_PPS */
+
+       *tsptr = tstmp;
+       return (1);
+}
+
+/*
+ * ripencc_shutdown - shut down a GPS clock
+ */
+static void
+ripencc_shutdown(int unit, struct peer *peer)
+{
+       register struct ripencc_unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct ripencc_unit *)pp->unitptr;
+
+       if (up->handle != 0)
+               time_pps_destroy(up->handle);
+
+       io_closeclock(&pp->io);
+
+       free(up);
+}
+
+/*
+ * ripencc_poll - called by the transmit procedure
+ */
+static void
+ripencc_poll(int unit, struct peer *peer)
+{
+       register struct ripencc_unit *up;
+       struct refclockproc *pp;
+       TSIPPKT spt;
+
+#ifdef DEBUG_NCC
+       if (debug)
+               fprintf(stderr, "ripencc_poll(%d)\n", unit);
+#endif /* DEBUG_NCC */
+       pp = peer->procptr;
+       up = (struct ripencc_unit *)pp->unitptr;
+       if (up->pollcnt == 0)
+               refclock_report(peer, CEVNT_TIMEOUT);
+       else
+               up->pollcnt--;
+
+       pp->polls++;
+       up->polled = 1;
+
+       /* poll for UTC superpacket */
+       cmd_0x8EADq (&spt);
+       ripencc_send(peer,spt);
+}
+
+/*
+ * ripencc_send - send message to clock
+ * use the structures being created by the trimble functions!
+ * makes the code more readable/clean
+ */
+static void
+ripencc_send(struct peer *peer, TSIPPKT spt)
+{
+       unsigned char *ip, *op;
+       unsigned char obuf[512];
+
+#ifdef DEBUG_RAW
+       {
+               register struct ripencc_unit *up;
+               register struct refclockproc *pp;       
+
+               pp = peer->procptr;
+               up = (struct ripencc_unit *)pp->unitptr;
+               if (debug)
+                       printf("ripencc_send(%d, %02X)\n", up->unit, cmd);
+       }
+#endif /* DEBUG_RAW */
+
+       ip = spt.buf;
+       op = obuf;
+
+       *op++ = 0x10;
+       *op++ = spt.code;
+
+       while (spt.len--) {
+               if (op-obuf > sizeof(obuf)-5) {
+                       msyslog(LOG_ERR, "ripencc_send obuf overflow!");
+                       refclock_report(peer, CEVNT_FAULT);
+                       return;
+               }
+                       
+               if (*ip == 0x10)  /* byte stuffing */
+                       *op++ = 0x10;
+               *op++ = *ip++;
+       }
+       
+       *op++ = 0x10;
+       *op++ = 0x03;
+
+#ifdef DEBUG_RAW
+       if (debug) { /* print raw packet */
+               unsigned char *cp;
+               int i;
+
+               printf("ripencc_send: len %d\n", op-obuf);
+               for (i=1, cp=obuf; cp<op; i++, cp++) {
+                       printf(" %02X", *cp);
+                       if (i%10 == 0) 
+                               printf("\n");
+               }
+               printf("\n");
+       }
+#endif /* DEBUG_RAW */
+
+       if (write(peer->procptr->io.fd, obuf, op-obuf) == -1) {
+                       refclock_report(peer, CEVNT_FAULT);
+       }
+}
+
+/*
+ * ripencc_receive()
+ *
+ * called when a packet is received on the serial port
+ * takes care of further processing
+ *
+ */
+static void
+ripencc_receive(struct recvbuf *rbufp)
+{
+       register struct ripencc_unit *up;
+       register struct refclockproc *pp;       
+       struct peer *peer;
+       static TSIPPKT rpt; /* structure for current incoming TSIP report  */ 
+       TSIPPKT spt; /* send packet */
+       int ns_since_pps;                       
+       int i;
+       char *cp;
+       /* Use these variables to hold data until we decide its worth keeping */
+       char    rd_lastcode[BMAX];
+       l_fp    rd_tmp;
+       u_short rd_lencode;
+
+       /* msyslog(LOG_INFO, "%s",__FUNCTION__); */
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct ripencc_unit *)pp->unitptr;
+       rd_lencode = refclock_gtlin(rbufp, rd_lastcode, BMAX, &rd_tmp);
+
+#ifdef DEBUG_RAW
+       if (debug)
+               fprintf(stderr, "ripencc_receive(%d)\n", up->unit);
+#endif /* DEBUG_RAW */
+
+#ifdef DEBUG_RAW
+       if (debug) { /* print raw packet */
+               int i;
+               unsigned char *cp;
+
+               printf("ripencc_receive: len %d\n", rbufp->recv_length);
+               for (i=1, cp=(char*)&rbufp->recv_space; i <= rbufp->recv_length; i++, cp++) {
+                       printf(" %02X", *cp);
+                       if (i%10 == 0) 
+                               printf("\n");
+               }
+               printf("\n");
+       }
+#endif /* DEBUG_RAW */
+
+       cp = (char*) &rbufp->recv_space;
+       i=rbufp->recv_length;
+
+       while (i--) { /* loop over received chars */
+
+               tsip_input_proc(&rpt, (unsigned char) *cp++);
+
+               if (rpt.status != TSIP_PARSED_FULL)
+                       continue;
+
+               switch (rpt.code) {
+
+               case 0x8F:      /* superpacket */
+
+                       switch (rpt.buf[0]) {
+
+                       case 0xAD:      /* UTC Time */
+                               /*
+                                * When polling on port B the timecode 
+                                * is the time of the previous PPS.
+                                * If we completed receiving the packet 
+                                * less than 150ms after the turn of the second, 
+                                * it may have the code of the previous second.
+                                * We do not trust that and simply poll again
+                                * without even parsing it.
+                                *
+                                * More elegant would be to re-schedule the poll,
+                                * but I do not know (yet) how to do that cleanly.
+                                *
+                                */
+                               /* BLA ns_since_pps = ncc_tstmp(rbufp, &trtmp); */
+/*   if (up->polled && ns_since_pps > -1 && ns_since_pps < 150) { */
+
+                               ns_since_pps=200;
+                               if (up->polled && ns_since_pps < 150) {
+                                       msyslog(LOG_INFO, "%s(): up->polled",__FUNCTION__);
+                                       ripencc_poll(up->unit, peer);
+                                       break;
+                               }
+
+                               /*
+                                * Parse primary utc time packet
+                                * and fill refclock structure 
+                                * from results. 
+                                */
+                               if (parse0x8FAD(&rpt, peer) < 0) {
+                                               msyslog(LOG_INFO, "%s(): parse0x8FAD < 0",__FUNCTION__);
+                                               refclock_report(peer, CEVNT_BADREPLY);
+                                               break;
+                               }
+                               /*
+                                * If the PPSAPI is working, rather use its 
+                                * timestamps.
+                                * assume that the PPS occurs on the second 
+                                * so blow any msec
+                                */
+                               if (ripencc_get_pps_ts(up, &rd_tmp) == 1) {
+                                       pp->lastrec = up->tstamp = rd_tmp;
+                                       pp->nsec = 0;
+                               }
+                               else
+                                       msyslog(LOG_INFO, "%s(): ripencc_get_pps_ts returns failure\n",__FUNCTION__);
+
+
+                               if (!up->polled) { 
+                                       msyslog(LOG_INFO, "%s(): unrequested packet\n",__FUNCTION__);
+                                       /* unrequested packet */
+                                       break;
+                               }
+
+                               /* we have been polled ! */
+                               up->polled = 0;
+                               up->pollcnt = 2;
+
+                               /* poll for next packet */
+                               cmd_0x8E0Bq(&spt);
+                               ripencc_send(peer,spt);
+                               
+                               if (ns_since_pps < 0) { /* no PPS */
+                                       msyslog(LOG_INFO, "%s(): ns_since_pps < 0",__FUNCTION__);
+                                       refclock_report(peer, CEVNT_BADTIME);
+                                       break;
+                               }
+
+                               /*
+                                * Process the new sample in the median filter and determine the
+                                * reference clock offset and dispersion. 
+                                */
+                               if (!refclock_process(pp)) {
+                                       msyslog(LOG_INFO, "%s(): !refclock_process",__FUNCTION__);
+                                       refclock_report(peer, CEVNT_BADTIME);
+                                       break;
+                               }
+
+                               refclock_receive(peer);
+                               break;
+                       
+                       case 0x0B: /* comprehensive time packet */
+                               parse0x8F0B(&rpt, peer);
+                               break;
+
+                       default: /* other superpackets */
+#ifdef DEBUG_NCC
+                               msyslog(LOG_INFO, "%s(): calling parseany",__FUNCTION__);
+#endif /* DEBUG_NCC */
+#ifdef TRIMBLE_OUTPUT_FUNC
+                               parseany(&rpt, peer);
+#endif /* TRIMBLE_OUTPUT_FUNC */
+                               break;
+                       }
+                       break;
+
+               case 0x4F:      /* UTC parameters, for leap info */
+                       parse0x4F(&rpt, peer);
+                       break;
+
+               case 0x5C:      /* sat tracking data */
+                       parse0x5C(&rpt, peer);
+                       break;
+
+               default: /* other packets */
+#ifdef TRIMBLE_OUTPUT_FUNC
+                       parseany(&rpt, peer);
+#endif /* TRIMBLE_OUTPUT_FUNC */
+                       break;
+               }
+               rpt.status = TSIP_PARSED_EMPTY;
+       }
+}
+
+/* 
+ * All trimble functions that are directly referenced from driver code
+ * (so not from parseany)
+ */
+
+void cmd_0x1F (TSIPPKT *cmd)
+/* request software versions */
+{
+       cmd->len = 0;
+       cmd->code = 0x1F;
+}
+
+void cmd_0x26 (TSIPPKT *cmd)
+/* request receiver health */
+{
+       cmd->len = 0;
+       cmd->code = 0x26;
+}
+
+
+
+
+void cmd_0x2F (TSIPPKT *cmd)
+/* request UTC params */
+{
+       cmd->len = 0;
+       cmd->code = 0x2F;
+}
+
+void cmd_0x35s  (TSIPPKT *cmd, unsigned char pos_code, unsigned char vel_code,
+       unsigned char time_code, unsigned char opts_code)
+/* set serial I/O options */
+{
+       cmd->buf[0] = pos_code;
+       cmd->buf[1] = vel_code;
+       cmd->buf[2] = time_code;
+       cmd->buf[3] = opts_code;
+       cmd->len = 4;
+       cmd->code = 0x35;
+}
+void cmd_0x3C  (TSIPPKT *cmd, unsigned char sv_prn)
+/* request tracking status */
+{
+       cmd->buf[0] = sv_prn;
+       cmd->len = 1;
+       cmd->code = 0x3C;
+}
+
+
+void cmd_0x3Ds (TSIPPKT *cmd,
+       unsigned char baud_out, unsigned char baud_inp,
+   unsigned char char_code, unsigned char stopbitcode,
+   unsigned char output_mode, unsigned char input_mode)
+/* set Channel A configuration for dual-port operation */
+{
+       cmd->buf[0] = baud_out;         /* XMT baud rate */
+       cmd->buf[1] = baud_inp;         /* RCV baud rate */
+       cmd->buf[2] = char_code;           /* parity and #bits per byte */
+       cmd->buf[3] = stopbitcode;      /* number of stop bits code */
+       cmd->buf[4] = output_mode;      /* Ch. A transmission mode */
+       cmd->buf[5] = input_mode;       /* Ch. A reception mode */
+       cmd->len = 6;
+       cmd->code = 0x3D;
+}
+
+
+/* query primary configuration */
+void cmd_0xBBq (TSIPPKT *cmd,
+       unsigned char subcode)
+{
+
+       cmd->len = 1;
+       cmd->code = 0xBB;
+       cmd->buf[0] = subcode;
+}
+
+
+/**** Superpackets ****/
+void cmd_0x8E0Bq (TSIPPKT *cmd)
+/* 8E-0B to query 8F-0B controls */
+{
+
+       cmd->len = 1;
+       cmd->code = 0x8E;
+       cmd->buf[0] = 0x0B;
+}
+
+
+void cmd_0x8E41q (TSIPPKT *cmd)
+/* 8F-41 to query board serial number */
+{
+
+       cmd->len = 1;
+       cmd->code = 0x8E;
+       cmd->buf[0] = 0x41;
+}
+
+
+void cmd_0x8E42q (TSIPPKT *cmd)
+/* 8F-42 to query product serial number */
+{
+
+       cmd->len = 1;
+       cmd->code = 0x8E;
+       cmd->buf[0] = 0x42;
+}
+void cmd_0x8E4Aq (TSIPPKT *cmd)
+/* 8F-4A to query PPS parameters */
+{
+       cmd->len = 1;
+       cmd->code = 0x8E;
+       cmd->buf[0] = 0x4A;
+}
+
+
+/* set i/o options */
+void cmd_0x8E4As (TSIPPKT *cmd,
+       unsigned char PPSOnOff,
+       unsigned char TimeBase,
+       unsigned char Polarity,
+   double PPSOffset,
+   float Uncertainty)
+{
+       cmd->len = 16;
+       cmd->code = 0x8E;
+       cmd->buf[0] = 0x4A;
+       cmd->buf[1] = PPSOnOff;
+       cmd->buf[2] = TimeBase;
+       cmd->buf[3] = Polarity;
+       bPutDouble (&PPSOffset, &cmd->buf[4]);
+       bPutFloat (&Uncertainty, &cmd->buf[12]);
+}
+void cmd_0x8E4Bq (TSIPPKT *cmd)
+/* 8F-4B query survey limit */
+{
+       cmd->len = 1;
+       cmd->code = 0x8E;
+       cmd->buf[0] = 0x4B;
+}
+
+
+/* poll for UTC superpacket */
+void cmd_0x8EADq (TSIPPKT *cmd)
+/* 8E-AD to query 8F-AD controls */
+{
+       cmd->len = 1;
+       cmd->code = 0x8E;
+       cmd->buf[0] = 0xAD;
+}
+
+/* all outomatic packet output off */
+void cmd_0x8E4Ds (TSIPPKT *cmd,
+       unsigned long AutoOutputMask)
+{
+       cmd->len = 5;
+       cmd->code = 0x8E;
+       cmd->buf[0] = 0x4D;
+       bPutULong (&AutoOutputMask, &cmd->buf[1]);
+}
+
+
+
+
+/* for DOS machines, reverse order of bytes as they come through the
+ * serial port. */
+#ifdef BYTESWAP
+static short bGetShort (unsigned char *bp)
+{
+       short outval;
+   unsigned char *optr;
+
+   optr = (unsigned char*)&outval + 1;
+   *optr-- = *bp++;
+   *optr = *bp;
+       return outval;
+}
+
+#ifdef TRIMBLE_OUTPUT_FUNC
+static unsigned short bGetUShort (unsigned char *bp)
+{
+       unsigned short outval;
+   unsigned char *optr;
+
+   optr = (unsigned char*)&outval + 1;
+   *optr-- = *bp++;
+   *optr = *bp;
+       return outval;
+}
+
+static long bGetLong (unsigned char *bp)
+{
+       long outval;
+   unsigned char *optr;
+
+   optr = (unsigned char*)&outval + 3;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr = *bp;
+       return outval;
+}
+
+static unsigned long bGetULong (unsigned char *bp)
+{
+       unsigned long outval;
+   unsigned char *optr;
+
+   optr = (unsigned char*)&outval + 3;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr = *bp;
+       return outval;
+}
+#endif /* TRIMBLE_OUTPUT_FUNC */
+
+static float bGetSingle (unsigned char *bp)
+{
+       float outval;
+   unsigned char *optr;
+
+   optr = (unsigned char*)&outval + 3;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr = *bp;
+       return outval;
+}
+
+static double bGetDouble (unsigned char *bp)
+{
+       double outval;
+   unsigned char *optr;
+
+   optr = (unsigned char*)&outval + 7;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr-- = *bp++;
+   *optr = *bp;
+       return outval;
+}
+
+#else /* not BYTESWAP */
+
+#define bGetShort(bp)  (*(short*)(bp))
+#define bGetLong(bp)   (*(long*)(bp))
+#define bGetULong(bp)  (*(unsigned long*)(bp))
+#define bGetSingle(bp)         (*(float*)(bp))
+#define bGetDouble(bp) (*(double*)(bp))
+
+#endif /* BYTESWAP */
+/*
+ * Byte-reversal is necessary for little-endian (Intel-based) machines.
+ * TSIP streams are Big-endian (Motorola-based).
+ */
+#ifdef BYTESWAP
+
+void
+bPutFloat (float *in, unsigned char *out)
+{
+       unsigned char *inptr;
+
+   inptr = (unsigned char*)in + 3;
+   *out++ = *inptr--;
+   *out++ = *inptr--;
+   *out++ = *inptr--;
+   *out = *inptr;
+}
+
+static void
+bPutULong (unsigned long *in, unsigned char *out)
+{
+       unsigned char *inptr;
+
+   inptr = (unsigned char*)in + 3;
+   *out++ = *inptr--;
+   *out++ = *inptr--;
+   *out++ = *inptr--;
+   *out = *inptr;
+}
+
+static void
+bPutDouble (double *in, unsigned char *out)
+{
+       unsigned char *inptr;
+
+   inptr = (unsigned char*)in + 7;
+   *out++ = *inptr--;
+   *out++ = *inptr--;
+   *out++ = *inptr--;
+   *out++ = *inptr--;
+   *out++ = *inptr--;
+   *out++ = *inptr--;
+   *out++ = *inptr--;
+   *out = *inptr;
+}
+
+#else  /* not BYTESWAP */
+
+void bPutShort (short a, unsigned char *cmdbuf) {*(short*) cmdbuf = a;}
+void bPutULong (long a, unsigned char *cmdbuf)         {*(long*) cmdbuf = a;}
+void bPutFloat (float a, unsigned char *cmdbuf) {*(float*) cmdbuf = a;}
+void bPutDouble (double a, unsigned char *cmdbuf){*(double*) cmdbuf = a;}
+
+#endif /* BYTESWAP */
+
+/*
+ * Parse primary utc time packet
+ * and fill refclock structure 
+ * from results. 
+ *
+ * 0 = success
+ * -1 = errors
+ */
+
+static int
+parse0x8FAD(rpt, peer)
+       TSIPPKT *rpt;
+       struct peer *peer;      
+{
+       register struct refclockproc *pp;       
+       register struct ripencc_unit *up;
+
+       unsigned day, month, year;      /* data derived from received timecode */
+       unsigned hour, minute, second;
+       unsigned char trackstat, utcflags;
+
+       static char logbuf[1024];       /* logging string buffer */
+       int i;
+       unsigned char *buf;
+               
+       buf = rpt->buf;
+       pp = peer->procptr;
+
+       if (rpt->len != 22) 
+               return (-1);
+       
+       if (bGetShort(&buf[1]) != 0) {
+#ifdef DEBUG_NCC
+               if (debug) 
+                       printf("parse0x8FAD: event count != 0\n");
+#endif /* DEBUG_NCC */
+               return(-1);
+       }
+
+
+       if (bGetDouble(&buf[3]) != 0.0) {
+#ifdef DEBUG_NCC
+               if (debug) 
+                       printf("parse0x8FAD: fracsecs != 0\n");
+#endif /* DEBUG_NCC */
+               return(-1);
+       }
+
+       hour = (unsigned int) buf[11];
+       minute = (unsigned int) buf[12];
+       second = (unsigned int) buf[13];
+       day =           (unsigned int) buf[14];
+       month =         (unsigned int) buf[15];
+       year =          bGetShort(&buf[16]);
+       trackstat = buf[18];
+       utcflags = buf[19];
+
+
+       sprintf(logbuf, "U1 %d.%d.%d %02d:%02d:%02d %d %02x",
+               day, month, year, hour, minute, second, trackstat, utcflags);
+
+#ifdef DEBUG_NCC
+       if (debug) 
+               puts(logbuf);
+#endif /* DEBUG_NCC */
+
+       record_clock_stats(&peer->srcadr, logbuf);
+
+       if (!utcflags & UTCF_UTC_AVAIL)
+               return(-1);
+
+       /* poll for UTC parameters once and then if UTC flag changed */
+       up = (struct ripencc_unit *) pp->unitptr;
+       if (utcflags != up->utcflags) {
+               TSIPPKT spt; /* local structure for send packet */
+               cmd_0x2F (&spt); /* request UTC params */
+               ripencc_send(peer,spt);
+               up->utcflags = utcflags;
+       }
+       
+       /*
+        * If we hit the leap second, we choose to skip this sample
+        * rather than rely on other code to be perfectly correct.
+        * No offense, just defense ;-).
+        */
+       if (second == 60)
+               return(-1);
+
+       /* now check and convert the time we received */
+
+       pp->year = year;
+       if (month < 1 || month > 12 || day < 1 || day > 31) 
+               return(-1);
+
+       if (pp->year % 4) {
+               if (day > day1tab[month - 1]) 
+                       return(-1);
+               for (i = 0; i < month - 1; i++)
+                       day += day1tab[i];
+       } else {
+               if (day > day2tab[month - 1]) 
+                       return(-1);
+               for (i = 0; i < month - 1; i++)
+                       day += day2tab[i];
+       }
+       pp->day = day;
+       pp->hour = hour;
+       pp->minute = minute;
+       pp-> second = second;
+       pp->nsec = 0;
+
+       if ((utcflags&UTCF_LEAP_PNDG) && up->leapdelta != 0) 
+               pp-> leap = (up->leapdelta > 0 ? LEAP_ADDSECOND : LEAP_DELSECOND); 
+       else
+               pp-> leap = LEAP_NOWARNING;  
+
+       return (0);
+}
+
+/*
+ * Parse comprehensive time packet 
+ *
+ * 0 = success
+ * -1 = errors
+ */
+
+int parse0x8F0B(rpt, peer)
+       TSIPPKT *rpt;
+       struct peer *peer;      
+{
+       register struct refclockproc *pp;       
+
+       unsigned day, month, year;      /* data derived from received timecode */
+       unsigned hour, minute, second;
+       unsigned utcoff;
+       unsigned char mode;
+       double  bias, rate;
+       float biasunc, rateunc;
+       double lat, lon, alt;
+       short lat_deg, lon_deg;
+       float lat_min, lon_min;
+       unsigned char north_south, east_west;
+       char sv[9];
+
+       static char logbuf[1024];       /* logging string buffer */
+       unsigned char b;
+       int i;
+       unsigned char *buf;
+       double tow;
+               
+       buf = rpt->buf;
+       pp = peer->procptr;
+
+       if (rpt->len != 74) 
+               return (-1);
+       
+       if (bGetShort(&buf[1]) != 0)
+               return(-1);;
+
+       tow =  bGetDouble(&buf[3]);
+
+       if (tow == -1.0) {
+               return(-1);
+       }
+       else if ((tow >= 604800.0) || (tow < 0.0)) {
+               return(-1);
+       }
+       else
+       {
+               if (tow < 604799.9) tow = tow + .00000001;
+               second = (unsigned int) fmod(tow, 60.);
+               minute =  (unsigned int) fmod(tow/60., 60.);
+               hour = (unsigned int )fmod(tow / 3600., 24.);
+       } 
+
+
+       day =           (unsigned int) buf[11];
+       month =         (unsigned int) buf[12];
+       year =          bGetShort(&buf[13]);
+       mode =          buf[15];
+       utcoff =        bGetShort(&buf[16]);
+       bias =          bGetDouble(&buf[18]) / GPS_C * 1e9;     /* ns */
+       rate =          bGetDouble(&buf[26]) / GPS_C * 1e9;     /* ppb */ 
+       biasunc =       bGetSingle(&buf[34]) / GPS_C * 1e9;     /* ns */
+       rateunc =       bGetSingle(&buf[38]) / GPS_C * 1e9;     /* ppb */
+       lat =           bGetDouble(&buf[42]) * R2D;
+       lon =           bGetDouble(&buf[50]) * R2D;
+       alt =           bGetDouble(&buf[58]);
+
+       if (lat < 0.0) {
+               north_south = 'S';
+               lat = -lat;
+       }
+       else {
+               north_south = 'N';
+       }
+       lat_deg = (short)lat;
+       lat_min = (lat - lat_deg) * 60.0;
+
+       if (lon < 0.0) {
+               east_west = 'W';
+               lon = -lon;
+       }
+       else {
+               east_west = 'E';
+       }
+
+       lon_deg = (short)lon;
+       lon_min = (lon - lon_deg) * 60.0;
+
+       for (i=0; i<8; i++) {
+               sv[i] = buf[i + 66];
+               if (sv[i]) {
+                       TSIPPKT spt; /* local structure for sendpacket */
+                       b = (unsigned char) (sv[i]<0 ? -sv[i] : sv[i]);
+                       /* request tracking status */
+                       cmd_0x3C  (&spt, b);
+                       ripencc_send(peer,spt);
+               }
+       }
+
+
+       sprintf(logbuf, "C1 %02d%02d%04d %02d%02d%02d %d %7.0f %.1f %.0f %.1f %d %02d%09.6f %c %02d%09.6f %c %.0f  %d %d %d %d %d %d %d %d",
+               day, month, year, hour, minute, second, mode, bias, biasunc, rate, rateunc, utcoff,
+               lat_deg, lat_min, north_south, lon_deg, lon_min, east_west, alt,
+               sv[0], sv[1], sv[2], sv[3], sv[4], sv[5], sv[6], sv[7]);
+
+#ifdef DEBUG_NCC
+       if (debug) 
+               puts(logbuf);
+#endif /* DEBUG_NCC */
+
+       record_clock_stats(&peer->srcadr, logbuf);
+
+       return (0);
+}
+
+#ifdef TRIMBLE_OUTPUT_FUNC
+/* 
+ * Parse any packet using Trimble machinery
+ */
+int parseany(rpt, peer)        
+       TSIPPKT *rpt;
+       struct peer *peer;      
+{
+       static char logbuf[1024];       /* logging string buffer */
+
+       TranslateTSIPReportToText (rpt, logbuf);        /* anything else */
+#ifdef DEBUG_NCC
+       if (debug) 
+               puts(&logbuf[1]);
+#endif /* DEBUG_NCC */
+       record_clock_stats(&peer->srcadr, &logbuf[1]);
+       return(0);
+}
+#endif /* TRIMBLE_OUTPUT_FUNC */
+
+
+/*
+ * Parse UTC Parameter Packet
+ * 
+ * See the IDE for documentation!
+ *
+ * 0 = success
+ * -1 = errors
+ */
+
+int parse0x4F(rpt, peer)
+       TSIPPKT *rpt;
+       struct peer *peer;      
+{
+       register struct ripencc_unit *up;
+
+       double a0;
+       float a1, tot;
+       int dt_ls, wn_t, wn_lsf, dn, dt_lsf;
+
+       static char logbuf[1024];       /* logging string buffer */
+       unsigned char *buf;
+               
+       buf = rpt->buf;
+       
+       if (rpt->len != 26) 
+               return (-1);
+       a0 = bGetDouble (buf);
+       a1 = bGetSingle (&buf[8]);
+       dt_ls = bGetShort (&buf[12]);
+       tot = bGetSingle (&buf[14]);
+       wn_t = bGetShort (&buf[18]);
+       wn_lsf = bGetShort (&buf[20]);
+       dn = bGetShort (&buf[22]);
+       dt_lsf = bGetShort (&buf[24]);
+
+       sprintf(logbuf, "L1 %d %d %d %g %g %g %d %d %d",
+               dt_lsf - dt_ls, dt_ls, dt_lsf, a0, a1, tot, wn_t, wn_lsf, dn); 
+
+#ifdef DEBUG_NCC
+       if (debug) 
+               puts(logbuf);
+#endif /* DEBUG_NCC */
+
+       record_clock_stats(&peer->srcadr, logbuf);
+
+       up = (struct ripencc_unit *) peer->procptr->unitptr;
+       up->leapdelta = dt_lsf - dt_ls;
+
+       return (0);
+}
+
+/*
+ * Parse Tracking Status packet
+ *
+ * 0 = success
+ * -1 = errors
+ */
+
+int parse0x5C(rpt, peer)
+       TSIPPKT *rpt;
+       struct peer *peer;      
+{
+       unsigned char prn, channel, aqflag, ephstat;
+       float snr, azinuth, elevation;
+
+       static char logbuf[1024];       /* logging string buffer */
+       unsigned char *buf;
+               
+       buf = rpt->buf;
+       
+       if (rpt->len != 24) 
+               return(-1);
+
+       prn = buf[0];
+       channel = (unsigned char)(buf[1] >> 3);
+       if (channel == 0x10) 
+               channel = 2;
+       else 
+               channel++;
+       aqflag = buf[2];
+       ephstat = buf[3];
+       snr = bGetSingle(&buf[4]);
+       elevation = bGetSingle(&buf[12]) * R2D;
+       azinuth = bGetSingle(&buf[16]) * R2D;
+
+       sprintf(logbuf, "S1 %02d %d %d %02x %4.1f %5.1f %4.1f",
+               prn, channel, aqflag, ephstat, snr, azinuth, elevation);
+
+#ifdef DEBUG_NCC
+       if (debug) 
+               puts(logbuf);
+#endif /* DEBUG_NCC */
+
+       record_clock_stats(&peer->srcadr, logbuf);
+
+       return (0);
+}
+
+/******* Code below is from Trimble Tsipchat *************/
+
+/*
+ * *************************************************************************
+ *
+ * Trimble Navigation, Ltd.
+ * OEM Products Development Group
+ * P.O. Box 3642
+ * 645 North Mary Avenue
+ * Sunnyvale, California 94088-3642
+ *
+ * Corporate Headquarter:
+ *    Telephone:  (408) 481-8000
+ *    Fax:        (408) 481-6005
+ *
+ * Technical Support Center:
+ *    Telephone:  (800) 767-4822       (U.S. and Canada)
+ *                (408) 481-6940    (outside U.S. and Canada)
+ *    Fax:        (408) 481-6020
+ *    BBS:        (408) 481-7800
+ *    e-mail:     trimble_support@trimble.com
+ *             ftp://ftp.trimble.com/pub/sct/embedded/bin
+ *
+ * *************************************************************************
+ *
+ * -------  BYTE-SWAPPING  -------
+ * TSIP is big-endian (Motorola) protocol.  To use on little-endian (Intel)
+ * systems, the bytes of all multi-byte types (shorts, floats, doubles, etc.)
+ * must be reversed.  This is controlled by the MACRO BYTESWAP; if defined, it
+ * assumes little-endian protocol.
+ * --------------------------------
+ *
+ * T_PARSER.C and T_PARSER.H contains primitive functions that interpret
+ * reports received from the receiver.  A second source file pair,
+ * T_FORMAT.C and T_FORMAT.H, contin the matching TSIP command formatters.
+ *
+ * The module is in very portable, basic C language.  It can be used as is, or
+ * with minimal changes if a TSIP communications application is needed separate
+ * from TSIPCHAT. The construction of most argument lists avoid the use of
+ * structures, but the developer is encouraged to reconstruct them using such
+ * definitions to meet project requirements.  Declarations of T_PARSER.C
+ * functions are included in T_PARSER.H to provide prototyping definitions.
+ *
+ * There are two types of functions: a serial input processing routine,
+ *                            tsip_input_proc()
+ * which assembles incoming bytes into a TSIPPKT structure, and the
+ * report parsers, rpt_0x??().
+ *
+ * 1) The function tsip_input_proc() accumulates bytes from the receiver,
+ * strips control bytes (DLE), and checks if the report end sequence (DLE ETX)
+ * has been received.  rpt.status is defined as TSIP_PARSED_FULL (== 1)
+ * if a complete packet is available.
+ *
+ * 2) The functions rpt_0x??() are report string interpreters patterned after
+ * the document called "Trimble Standard Interface Protocol".  It should be
+ * noted that if the report buffer is sent into the receiver with the wrong
+ * length (byte count), the rpt_0x??() returns the Boolean equivalence for
+ * TRUE.
+ *
+ * *************************************************************************
+ *
+ */
+
+
+/**/
+static void tsip_input_proc (
+       TSIPPKT *rpt,
+       int inbyte)
+/* reads bytes until serial buffer is empty or a complete report
+ * has been received; end of report is signified by DLE ETX.
+ */
+{
+       unsigned char newbyte;
+
+       if (inbyte < 0 || inbyte > 0xFF) return;
+
+       newbyte = (unsigned char)(inbyte);
+       switch (rpt->status)
+       {
+       case TSIP_PARSED_DLE_1:
+               switch (newbyte)
+               {
+               case 0:
+               case ETX:
+       /* illegal TSIP IDs */
+         rpt->len = 0;
+                       rpt->status = TSIP_PARSED_EMPTY;
+                       break;
+               case DLE:
+       /* try normal message start again */
+                       rpt->len = 0;
+                       rpt->status = TSIP_PARSED_DLE_1;
+                       break;
+               default:
+       /* legal TSIP ID; start message */
+                       rpt->code = newbyte;
+         rpt->len = 0;
+                       rpt->status = TSIP_PARSED_DATA;
+                       break;
+               }
+               break;
+       case TSIP_PARSED_DATA:
+               switch (newbyte) {
+               case DLE:
+       /* expect DLE or ETX next */
+                       rpt->status = TSIP_PARSED_DLE_2;
+                       break;
+               default:
+       /* normal data byte  */
+                       rpt->buf[rpt->len] = newbyte;
+                       rpt->len++;
+         /* no change in rpt->status */
+                       break;
+               }
+               break;
+       case TSIP_PARSED_DLE_2:
+               switch (newbyte) {
+               case DLE:
+       /* normal data byte */
+                       rpt->buf[rpt->len] = newbyte;
+                       rpt->len++;
+                       rpt->status = TSIP_PARSED_DATA;
+                       break;
+               case ETX:
+                       /* end of message; return TRUE here. */
+                       rpt->status = TSIP_PARSED_FULL;
+                       break;
+               default:
+                       /* error: treat as TSIP_PARSED_DLE_1; start new report packet */
+                       rpt->code = newbyte;
+         rpt->len = 0;
+                       rpt->status = TSIP_PARSED_DATA;
+               }
+               break;
+       case TSIP_PARSED_FULL:
+       case TSIP_PARSED_EMPTY:
+       default:
+               switch (newbyte) {
+               case DLE:
+       /* normal message start */
+                       rpt->len = 0;
+                       rpt->status = TSIP_PARSED_DLE_1;
+                       break;
+               default:
+                       /* error: ignore newbyte */
+                       rpt->len = 0;
+                       rpt->status = TSIP_PARSED_EMPTY;
+               }
+               break;
+       }
+       if (rpt->len > MAX_RPTBUF) {
+               /* error: start new report packet */
+               rpt->status = TSIP_PARSED_EMPTY;
+               rpt->len = 0;
+       }
+}
+
+#ifdef TRIMBLE_OUTPUT_FUNC
+
+/**/
+short rpt_0x3D (TSIPPKT *rpt,
+       unsigned char *tx_baud_index,
+       unsigned char *rx_baud_index,
+       unsigned char *char_format_index,
+       unsigned char *stop_bits,
+       unsigned char *tx_mode_index,
+       unsigned char *rx_mode_index)
+/* Channel A configuration for dual port operation */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 6) return TRUE;
+       *tx_baud_index = buf[0];
+       *rx_baud_index = buf[1];
+       *char_format_index = buf[2];
+       *stop_bits = (unsigned char)((buf[3] == 0x07) ? 1 : 2);
+       *tx_mode_index = buf[4];
+       *rx_mode_index = buf[5];
+       return FALSE;
+}
+
+/**/
+short rpt_0x40 (TSIPPKT *rpt,
+       unsigned char *sv_prn,
+       short *week_num,
+       float *t_zc,
+       float *eccentricity,
+       float *t_oa,
+       float *i_0,
+       float *OMEGA_dot,
+       float *sqrt_A,
+       float *OMEGA_0,
+       float *omega,
+       float *M_0)
+/* almanac data for specified satellite */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 39) return TRUE;
+       *sv_prn = buf[0];
+       *t_zc = bGetSingle (&buf[1]);
+       *week_num = bGetShort (&buf[5]);
+       *eccentricity = bGetSingle (&buf[7]);
+       *t_oa = bGetSingle (&buf[11]);
+       *i_0 = bGetSingle (&buf[15]);
+       *OMEGA_dot = bGetSingle (&buf[19]);
+       *sqrt_A = bGetSingle (&buf[23]);
+       *OMEGA_0 = bGetSingle (&buf[27]);
+       *omega = bGetSingle (&buf[31]);
+       *M_0 = bGetSingle (&buf[35]);
+       return FALSE;
+}
+
+short rpt_0x41 (TSIPPKT *rpt,
+       float *time_of_week,
+       float *UTC_offset,
+       short *week_num)
+/* GPS time */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+       
+       if (rpt->len != 10) return TRUE;
+       *time_of_week = bGetSingle (buf);
+       *week_num = bGetShort (&buf[4]);
+       *UTC_offset = bGetSingle (&buf[6]);
+       return FALSE;
+}
+
+short rpt_0x42 (TSIPPKT *rpt,
+       float pos_ECEF[3],
+       float *time_of_fix)
+/* position in ECEF, single precision */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+       
+       if (rpt->len != 16) return TRUE;
+       pos_ECEF[0] = bGetSingle (buf);
+       pos_ECEF[1]= bGetSingle (&buf[4]);
+       pos_ECEF[2]= bGetSingle (&buf[8]);
+       *time_of_fix = bGetSingle (&buf[12]);
+       return FALSE;
+}
+
+short rpt_0x43 (TSIPPKT *rpt,
+       float ECEF_vel[3],
+       float *freq_offset,
+       float *time_of_fix)
+/* velocity in ECEF, single precision */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 20) return TRUE;
+       ECEF_vel[0] = bGetSingle (buf);
+       ECEF_vel[1] = bGetSingle (&buf[4]);
+       ECEF_vel[2] = bGetSingle (&buf[8]);
+       *freq_offset = bGetSingle (&buf[12]);
+       *time_of_fix = bGetSingle (&buf[16]);
+       return FALSE;
+}
+
+short rpt_0x45 (TSIPPKT *rpt,
+       unsigned char *major_nav_version,
+       unsigned char *minor_nav_version,
+       unsigned char *nav_day,
+       unsigned char *nav_month,
+       unsigned char *nav_year,
+       unsigned char *major_dsp_version,
+       unsigned char *minor_dsp_version,
+       unsigned char *dsp_day,
+       unsigned char *dsp_month,
+       unsigned char *dsp_year)
+/* software versions */        
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 10) return TRUE;
+       *major_nav_version = buf[0];
+       *minor_nav_version = buf[1];
+       *nav_day = buf[2];
+       *nav_month = buf[3];
+       *nav_year = buf[4];
+       *major_dsp_version = buf[5];
+       *minor_dsp_version = buf[6];
+       *dsp_day = buf[7];
+       *dsp_month = buf[8];
+       *dsp_year = buf[9];
+       return FALSE;
+}
+
+short rpt_0x46 (TSIPPKT *rpt,
+       unsigned char *status1,
+       unsigned char *status2)
+/* receiver health and status */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 2) return TRUE;
+       *status1 = buf[0];
+       *status2 = buf[1];
+       return FALSE;
+}
+
+short rpt_0x47 (TSIPPKT *rpt,
+       unsigned char *nsvs, unsigned char *sv_prn,
+       float *snr)
+/* signal levels for all satellites tracked */
+{
+       short isv;
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 1 + 5*buf[0]) return TRUE;
+       *nsvs = buf[0];
+       for (isv = 0; isv < (*nsvs); isv++) {
+               sv_prn[isv] = buf[5*isv + 1];
+               snr[isv] = bGetSingle (&buf[5*isv + 2]);
+       }
+       return FALSE;
+}
+
+short rpt_0x48 (TSIPPKT *rpt,
+       unsigned char *message)
+/* GPS system message */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 22) return TRUE;
+       memcpy (message, buf, 22);
+       message[22] = 0;
+       return FALSE;
+}
+
+short rpt_0x49 (TSIPPKT *rpt,
+       unsigned char *sv_health)
+/* health for all satellites from almanac health page */
+{
+       short i;
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 32) return TRUE;
+       for (i = 0; i < 32; i++) sv_health [i]= buf[i];
+       return FALSE;
+}
+
+short rpt_0x4A (TSIPPKT *rpt,
+       float *lat,
+       float *lon,
+       float *alt,
+       float *clock_bias,
+       float *time_of_fix)
+/* position in lat-lon-alt, single precision */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 20) return TRUE;
+       *lat = bGetSingle (buf);
+       *lon = bGetSingle (&buf[4]);
+       *alt = bGetSingle (&buf[8]);
+       *clock_bias = bGetSingle (&buf[12]);
+       *time_of_fix = bGetSingle (&buf[16]);
+       return FALSE;
+}
+
+short rpt_0x4A_2 (TSIPPKT *rpt,
+       float *alt, float *dummy , unsigned char *alt_flag)
+/* reference altitude parameters */
+{
+       unsigned char *buf;
+
+       buf = rpt->buf;
+
+       if (rpt->len != 9) return TRUE;
+       *alt = bGetSingle (buf);
+       *dummy = bGetSingle (&buf[4]);
+       *alt_flag = buf[8];
+       return FALSE;
+}
+
+short rpt_0x4B (TSIPPKT *rpt,
+       unsigned char *machine_id,
+       unsigned char *status3,
+       unsigned char *status4)
+/* machine ID code, status */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 3) return TRUE;
+       *machine_id = buf[0];
+       *status3 = buf[1];
+       *status4 = buf[2];
+       return FALSE;
+}
+
+short rpt_0x4C (TSIPPKT *rpt,
+       unsigned char *dyn_code,
+       float *el_mask,
+       float *snr_mask,
+       float *dop_mask,
+       float *dop_switch)
+/* operating parameters and masks */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 17) return TRUE;
+       *dyn_code = buf[0];
+       *el_mask = bGetSingle (&buf[1]);
+       *snr_mask = bGetSingle (&buf[5]);
+       *dop_mask = bGetSingle (&buf[9]);
+       *dop_switch = bGetSingle (&buf[13]);
+       return FALSE;
+}
+
+short rpt_0x4D (TSIPPKT *rpt,
+       float *osc_offset)
+/* oscillator offset */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 4) return TRUE;
+       *osc_offset = bGetSingle (buf);
+       return FALSE;
+}
+
+short rpt_0x4E (TSIPPKT *rpt,
+       unsigned char *response)
+/* yes/no response to command to set GPS time */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 1) return TRUE;
+       *response = buf[0];
+       return FALSE;
+}
+
+short rpt_0x4F (TSIPPKT *rpt,
+       double *a0,
+       float *a1,
+       float *time_of_data,
+       short *dt_ls,
+       short *wn_t,
+       short *wn_lsf,
+       short *dn,
+       short *dt_lsf)
+/* UTC data */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 26) return TRUE;
+       *a0 = bGetDouble (buf);
+       *a1 = bGetSingle (&buf[8]);
+       *dt_ls = bGetShort (&buf[12]);
+       *time_of_data = bGetSingle (&buf[14]);
+       *wn_t = bGetShort (&buf[18]);
+       *wn_lsf = bGetShort (&buf[20]);
+       *dn = bGetShort (&buf[22]);
+       *dt_lsf = bGetShort (&buf[24]);
+       return FALSE;
+}
+
+/**/
+short rpt_0x54 (TSIPPKT *rpt,
+       float *clock_bias,
+   float *freq_offset,
+   float *time_of_fix)
+/* clock offset and frequency offset in 1-SV (0-D) mode */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 12) return TRUE;
+       *clock_bias = bGetSingle (buf);
+       *freq_offset = bGetSingle (&buf[4]);
+       *time_of_fix = bGetSingle (&buf[8]);
+       return FALSE;
+}
+
+short rpt_0x55 (TSIPPKT *rpt,
+       unsigned char *pos_code,
+       unsigned char *vel_code,
+       unsigned char *time_code,
+       unsigned char *aux_code)
+/* I/O serial options */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+       
+       if (rpt->len != 4) return TRUE;
+       *pos_code = buf[0];
+       *vel_code = buf[1];
+       *time_code = buf[2];
+       *aux_code = buf[3];
+       return FALSE;
+}
+
+short rpt_0x56 (TSIPPKT *rpt,
+       float vel_ENU[3], float *freq_offset, float *time_of_fix)
+/* velocity in east-north-up coordinates */    
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+       
+       if (rpt->len != 20) return TRUE;
+       /* east */
+       vel_ENU[0] = bGetSingle (buf);
+       /* north */
+       vel_ENU[1] = bGetSingle (&buf[4]);
+       /* up */
+       vel_ENU[2] = bGetSingle (&buf[8]);
+       *freq_offset = bGetSingle (&buf[12]);
+       *time_of_fix = bGetSingle (&buf[16]);
+       return FALSE;
+}
+
+short rpt_0x57 (TSIPPKT *rpt,
+       unsigned char *source_code, unsigned char *diag_code,
+       short *week_num,
+       float *time_of_fix)
+/* info about last computed fix */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+       
+       if (rpt->len != 8) return TRUE;
+       *source_code = buf[0];
+       *diag_code = buf[1];
+       *time_of_fix = bGetSingle (&buf[2]);
+       *week_num = bGetShort (&buf[6]);
+       return FALSE;
+}
+
+short rpt_0x58 (TSIPPKT *rpt,
+       unsigned char *op_code, unsigned char *data_type, unsigned char *sv_prn,
+       unsigned char *data_length, unsigned char *data_packet)
+/* GPS system data or acknowledgment of GPS system data load */
+{
+       unsigned char *buf, *buf4;
+       short dl;
+       ALM_INFO* alminfo;
+       ION_INFO* ioninfo;
+       UTC_INFO* utcinfo;
+       NAV_INFO* navinfo;
+
+       buf = rpt->buf;
+
+       if (buf[0] == 2) {
+               if (rpt->len < 4) return TRUE;
+               if (rpt->len != 4+buf[3]) return TRUE;
+       }
+       else if (rpt->len != 3) {
+               return TRUE;
+       }
+       *op_code = buf[0];
+       *data_type = buf[1];
+       *sv_prn = buf[2];
+       if (*op_code == 2) {
+               dl = buf[3];
+               *data_length = (unsigned char)dl;
+               buf4 = &buf[4];
+               switch (*data_type) {
+               case 2:
+                       /* Almanac */
+                       if (*data_length != sizeof (ALM_INFO)) return TRUE;
+                       alminfo = (ALM_INFO*)data_packet;
+                       alminfo->t_oa_raw  = buf4[0];
+                       alminfo->SV_health = buf4[1];
+                       alminfo->e         = bGetSingle(&buf4[2]);
+                       alminfo->t_oa      = bGetSingle(&buf4[6]);
+                       alminfo->i_0       = bGetSingle(&buf4[10]);
+                       alminfo->OMEGADOT  = bGetSingle(&buf4[14]);
+                       alminfo->sqrt_A    = bGetSingle(&buf4[18]);
+                       alminfo->OMEGA_0   = bGetSingle(&buf4[22]);
+                       alminfo->omega     = bGetSingle(&buf4[26]);
+                       alminfo->M_0       = bGetSingle(&buf4[30]);
+                       alminfo->a_f0      = bGetSingle(&buf4[34]);
+                       alminfo->a_f1      = bGetSingle(&buf4[38]);
+                       alminfo->Axis      = bGetSingle(&buf4[42]);
+                       alminfo->n         = bGetSingle(&buf4[46]);
+                       alminfo->OMEGA_n   = bGetSingle(&buf4[50]);
+                       alminfo->ODOT_n    = bGetSingle(&buf4[54]);
+                       alminfo->t_zc      = bGetSingle(&buf4[58]);
+                       alminfo->weeknum   = bGetShort(&buf4[62]);
+                       alminfo->wn_oa     = bGetShort(&buf4[64]);
+                       break;
+
+               case 3:
+                       /* Almanac health page */
+                       if (*data_length != sizeof (ALH_PARMS) + 3) return TRUE;
+
+                       /* this record is returned raw */
+                       memcpy (data_packet, buf4, dl);
+                       break;
+
+               case 4:
+                       /* Ionosphere */
+                       if (*data_length != sizeof (ION_INFO) + 8) return TRUE;
+                       ioninfo = (ION_INFO*)data_packet;
+                       ioninfo->alpha_0   = bGetSingle (&buf4[8]);
+                       ioninfo->alpha_1   = bGetSingle (&buf4[12]);
+                       ioninfo->alpha_2   = bGetSingle (&buf4[16]);
+                       ioninfo->alpha_3   = bGetSingle (&buf4[20]);
+                       ioninfo->beta_0    = bGetSingle (&buf4[24]);
+                       ioninfo->beta_1    = bGetSingle (&buf4[28]);
+                       ioninfo->beta_2    = bGetSingle (&buf4[32]);
+                       ioninfo->beta_3    = bGetSingle (&buf4[36]);
+                       break;
+
+               case 5:
+                       /* UTC */
+                       if (*data_length != sizeof (UTC_INFO) + 13) return TRUE;
+                       utcinfo = (UTC_INFO*)data_packet;
+                       utcinfo->A_0       = bGetDouble (&buf4[13]);
+                       utcinfo->A_1       = bGetSingle (&buf4[21]);
+                       utcinfo->delta_t_LS = bGetShort (&buf4[25]);
+                       utcinfo->t_ot      = bGetSingle(&buf4[27]);
+                       utcinfo->WN_t      = bGetShort (&buf4[31]);
+                       utcinfo->WN_LSF    = bGetShort (&buf4[33]);
+                       utcinfo->DN        = bGetShort (&buf4[35]);
+                       utcinfo->delta_t_LSF = bGetShort (&buf4[37]);
+                       break;
+
+               case 6:
+                       /* Ephemeris */
+                       if (*data_length != sizeof (NAV_INFO) - 1) return TRUE;
+
+                       navinfo = (NAV_INFO*)data_packet;
+
+                       navinfo->sv_number = buf4[0];
+                       navinfo->t_ephem = bGetSingle (&buf4[1]);
+                       navinfo->ephclk.weeknum = bGetShort (&buf4[5]);
+
+                       navinfo->ephclk.codeL2 = buf4[7];
+                       navinfo->ephclk.L2Pdata = buf4[8];
+                       navinfo->ephclk.SVacc_raw = buf4[9];
+                       navinfo->ephclk.SV_health = buf4[10];
+                       navinfo->ephclk.IODC = bGetShort (&buf4[11]);
+                       navinfo->ephclk.T_GD = bGetSingle (&buf4[13]);
+                       navinfo->ephclk.t_oc = bGetSingle (&buf4[17]);
+                       navinfo->ephclk.a_f2 = bGetSingle (&buf4[21]);
+                       navinfo->ephclk.a_f1 = bGetSingle (&buf4[25]);
+                       navinfo->ephclk.a_f0 = bGetSingle (&buf4[29]);
+                       navinfo->ephclk.SVacc = bGetSingle (&buf4[33]);
+
+                       navinfo->ephorb.IODE = buf4[37];
+                       navinfo->ephorb.fit_interval = buf4[38];
+                       navinfo->ephorb.C_rs = bGetSingle (&buf4[39]);
+                       navinfo->ephorb.delta_n = bGetSingle (&buf4[43]);
+                       navinfo->ephorb.M_0 = bGetDouble (&buf4[47]);
+                       navinfo->ephorb.C_uc = bGetSingle (&buf4[55]);
+                       navinfo->ephorb.e = bGetDouble (&buf4[59]);
+                       navinfo->ephorb.C_us = bGetSingle (&buf4[67]);
+                       navinfo->ephorb.sqrt_A = bGetDouble (&buf4[71]);
+                       navinfo->ephorb.t_oe = bGetSingle (&buf4[79]);
+                       navinfo->ephorb.C_ic = bGetSingle (&buf4[83]);
+                       navinfo->ephorb.OMEGA_0 = bGetDouble (&buf4[87]);
+                       navinfo->ephorb.C_is = bGetSingle (&buf4[95]);
+                       navinfo->ephorb.i_0 = bGetDouble (&buf4[99]);
+                       navinfo->ephorb.C_rc = bGetSingle (&buf4[107]);
+                       navinfo->ephorb.omega = bGetDouble (&buf4[111]);
+                       navinfo->ephorb.OMEGADOT=bGetSingle (&buf4[119]);
+                       navinfo->ephorb.IDOT = bGetSingle (&buf4[123]);
+                       navinfo->ephorb.Axis = bGetDouble (&buf4[127]);
+                       navinfo->ephorb.n = bGetDouble (&buf4[135]);
+                       navinfo->ephorb.r1me2 = bGetDouble (&buf4[143]);
+                       navinfo->ephorb.OMEGA_n=bGetDouble (&buf4[151]);
+                       navinfo->ephorb.ODOT_n = bGetDouble (&buf4[159]);
+                       break;
+               }
+       }
+       return FALSE;
+}
+
+short rpt_0x59 (TSIPPKT *rpt,
+       unsigned char *code_type,
+       unsigned char status_code[32])
+/* satellite enable/disable or health heed/ignore list */      
+{
+       short iprn;
+       unsigned char *buf;
+       buf = rpt->buf;
+       
+       if (rpt->len != 33) return TRUE;
+       *code_type = buf[0];
+       for (iprn = 0; iprn < 32; iprn++)
+               status_code[iprn] = buf[iprn + 1];
+       return FALSE;
+}
+
+short rpt_0x5A (TSIPPKT *rpt,
+       unsigned char *sv_prn,
+       float *sample_length,
+       float *signal_level,
+       float *code_phase,
+       float *Doppler,
+       double *time_of_fix)
+/* raw measurement data - code phase/Doppler */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 25) return TRUE;
+       *sv_prn = buf[0];
+       *sample_length = bGetSingle (&buf[1]);
+       *signal_level = bGetSingle (&buf[5]);
+       *code_phase = bGetSingle (&buf[9]);
+       *Doppler = bGetSingle (&buf[13]);
+       *time_of_fix = bGetDouble (&buf[17]);
+       return FALSE;
+}
+
+short rpt_0x5B (TSIPPKT *rpt,
+       unsigned char *sv_prn,
+       unsigned char *sv_health,
+       unsigned char *sv_iode,
+       unsigned char *fit_interval_flag,
+       float *time_of_collection,
+       float *time_of_eph,
+       float *sv_accy)
+/* satellite ephorb status */  
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+       
+       if (rpt->len != 16) return TRUE;
+       *sv_prn = buf[0];
+       *time_of_collection = bGetSingle (&buf[1]);
+       *sv_health = buf[5];
+       *sv_iode = buf[6];
+       *time_of_eph = bGetSingle (&buf[7]);
+       *fit_interval_flag = buf[11];
+       *sv_accy = bGetSingle (&buf[12]);
+       return FALSE;
+}
+
+short rpt_0x5C (TSIPPKT *rpt,
+       unsigned char *sv_prn,
+       unsigned char *slot,
+       unsigned char *chan,
+       unsigned char *acq_flag,
+       unsigned char *eph_flag,
+       float *signal_level,
+       float *time_of_last_msmt,
+       float *elev,
+       float *azim,
+       unsigned char *old_msmt_flag,
+       unsigned char *integer_msec_flag,
+       unsigned char *bad_data_flag,
+       unsigned char *data_collect_flag)
+/* satellite tracking status */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+       
+       if (rpt->len != 24) return TRUE;
+       *sv_prn = buf[0];
+       *slot = (unsigned char)((buf[1] & 0x07) + 1);
+       *chan = (unsigned char)(buf[1] >> 3);
+       if (*chan == 0x10) *chan = 2;
+       else (*chan)++;
+       *acq_flag = buf[2];
+       *eph_flag = buf[3];
+       *signal_level = bGetSingle (&buf[4]);
+       *time_of_last_msmt = bGetSingle (&buf[8]);
+       *elev = bGetSingle (&buf[12]);
+       *azim = bGetSingle (&buf[16]);
+       *old_msmt_flag = buf[20];
+       *integer_msec_flag = buf[21];
+       *bad_data_flag = buf[22];
+       *data_collect_flag = buf[23];
+       return FALSE;
+}
+
+/**/
+short rpt_0x6D (TSIPPKT *rpt,
+       unsigned char *manual_mode,
+       unsigned char *nsvs,
+       unsigned char *ndim,
+       unsigned char sv_prn[],
+       float *pdop,
+       float *hdop,
+       float *vdop,
+       float *tdop)
+/* over-determined satellite selection for position fixes, PDOP, fix mode */
+{
+       short islot;
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       *nsvs = (unsigned char)((buf[0] & 0xF0) >> 4);
+       if ((*nsvs)>8) return TRUE;
+       if (rpt->len != 17 + (*nsvs) ) return TRUE;
+
+       *manual_mode = (unsigned char)(buf[0] & 0x08);
+       *ndim  = (unsigned char)((buf[0] & 0x07));
+       *pdop = bGetSingle (&buf[1]);
+       *hdop = bGetSingle (&buf[5]);
+       *vdop = bGetSingle (&buf[9]);
+       *tdop = bGetSingle (&buf[13]);
+       for (islot = 0; islot < (*nsvs); islot++)
+               sv_prn[islot] = buf[islot + 17];
+       return FALSE;
+}
+
+/**/
+short rpt_0x82 (TSIPPKT *rpt,
+       unsigned char *diff_mode)
+/* differential fix mode */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 1) return TRUE;
+       *diff_mode = buf[0];
+       return FALSE;
+}
+
+short rpt_0x83 (TSIPPKT *rpt,
+       double ECEF_pos[3],
+       double *clock_bias,
+       float *time_of_fix)
+/* position, ECEF double precision */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 36) return TRUE;
+       ECEF_pos[0] = bGetDouble (buf);
+       ECEF_pos[1] = bGetDouble (&buf[8]);
+       ECEF_pos[2] = bGetDouble (&buf[16]);
+       *clock_bias  = bGetDouble (&buf[24]);
+       *time_of_fix = bGetSingle (&buf[32]);
+       return FALSE;
+}
+
+short rpt_0x84 (TSIPPKT *rpt,
+       double *lat,
+       double *lon,
+       double *alt,
+       double *clock_bias,
+       float *time_of_fix)
+/* position, lat-lon-alt double precision */   
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 36) return TRUE;
+       *lat = bGetDouble (buf);
+       *lon = bGetDouble (&buf[8]);
+       *alt = bGetDouble (&buf[16]);
+       *clock_bias = bGetDouble (&buf[24]);
+       *time_of_fix = bGetSingle (&buf[32]);
+       return FALSE;
+}
+
+short rpt_Paly0xBB(TSIPPKT *rpt,
+       TSIP_RCVR_CFG *TsipxBB)
+{
+
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       /* Palisade is inconsistent with other TSIP, which has a kength of 40 */
+       /* if (rpt->len != 40) return TRUE; */
+       if (rpt->len != 43) return TRUE;
+
+       TsipxBB->bSubcode               =       buf[0];
+       TsipxBB->operating_mode =       buf[1]  ;
+       TsipxBB->dyn_code                       =       buf[3]  ;
+       TsipxBB->elev_mask              =  bGetSingle (&buf[5]);
+       TsipxBB->cno_mask                       =       bGetSingle (&buf[9]);
+       TsipxBB->dop_mask               =  bGetSingle (&buf[13]);
+       TsipxBB->dop_switch     =  bGetSingle (&buf[17]);
+       return FALSE;
+}
+
+short rpt_0xBC (TSIPPKT *rpt,
+       unsigned char *port_num,
+   unsigned char *in_baud,
+       unsigned char *out_baud,
+   unsigned char *data_bits,
+       unsigned char *parity,
+   unsigned char *stop_bits,
+   unsigned char *flow_control,
+       unsigned char *protocols_in,
+   unsigned char *protocols_out,
+   unsigned char *reserved)
+/* Receiver serial port configuration */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 10) return TRUE;
+       *port_num = buf[0];
+       *in_baud = buf[1];
+       *out_baud = buf[2];
+       *data_bits = buf[3];
+       *parity = buf[4];
+       *stop_bits = buf[5];
+       *flow_control = buf[6];
+       *protocols_in = buf[7];
+       *protocols_out = buf[8];
+       *reserved = buf[9];
+
+       return FALSE;
+}
+
+/**** Superpackets ****/
+
+short rpt_0x8F0B(TSIPPKT *rpt,
+                 unsigned short *event,
+                 double *tow,
+                 unsigned char *date,
+                 unsigned char *month,
+                 short *year,
+                 unsigned char *dim_mode,
+                 short *utc_offset,
+                 double *bias,
+                 double *drift,
+                 float *bias_unc,
+                 float *dr_unc,
+                 double *lat,
+                 double *lon,
+                 double *alt,
+                 char sv_id[8])
+{
+       short local_index;
+       unsigned char *buf;
+
+       buf = rpt->buf;
+       if (rpt->len != 74) return TRUE;
+       *event = bGetShort(&buf[1]);
+       *tow = bGetDouble(&buf[3]);
+       *date = buf[11];
+       *month = buf[12];
+       *year = bGetShort(&buf[13]);
+       *dim_mode = buf[15];
+       *utc_offset = bGetShort(&buf[16]);
+       *bias = bGetDouble(&buf[18]);
+       *drift = bGetDouble(&buf[26]);
+       *bias_unc = bGetSingle(&buf[34]);
+       *dr_unc = bGetSingle(&buf[38]);
+       *lat = bGetDouble(&buf[42]);
+       *lon = bGetDouble(&buf[50]);
+       *alt = bGetDouble(&buf[58]);
+
+       for (local_index=0; local_index<8; local_index++) sv_id[local_index] = buf[local_index + 66];
+       return FALSE;
+}
+
+short rpt_0x8F14 (TSIPPKT *rpt,
+       short *datum_idx,
+       double datum_coeffs[5])
+/*  datum index and coefficients  */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 43) return TRUE;
+       *datum_idx = bGetShort(&buf[1]);
+       datum_coeffs[0] = bGetDouble (&buf[3]);
+       datum_coeffs[1] = bGetDouble (&buf[11]);
+       datum_coeffs[2] = bGetDouble (&buf[19]);
+       datum_coeffs[3] = bGetDouble (&buf[27]);
+       datum_coeffs[4] = bGetDouble (&buf[35]);
+       return FALSE;
+}
+
+
+short rpt_0x8F15 (TSIPPKT *rpt,
+       short *datum_idx,
+       double datum_coeffs[5])
+/*  datum index and coefficients  */
+{
+       unsigned char *buf;
+       buf = rpt->buf;
+
+       if (rpt->len != 43) return TRUE;
+       *datum_idx = bGetShort(&buf[1]);
+       datum_coeffs[0] = bGetDouble (&buf[3]);
+       datum_coeffs[1] = bGetDouble (&buf[11]);
+       datum_coeffs[2] = bGetDouble (&buf[19]);
+       datum_coeffs[3] = bGetDouble (&buf[27]);
+       datum_coeffs[4] = bGetDouble (&buf[35]);
+       return FALSE;
+}
+
+
+#define MAX_LONG  (2147483648.)   /* 2**31 */
+
+short rpt_0x8F20 (TSIPPKT *rpt,
+       unsigned char *info,
+       double *lat,
+       double *lon,
+       double *alt,
+       double vel_enu[],
+       double *time_of_fix,
+       short *week_num,
+       unsigned char *nsvs,
+       unsigned char sv_prn[],
+       short sv_IODC[],
+       short *datum_index)
+{
+       short
+               isv;
+       unsigned char
+               *buf, prnx, iode;
+       unsigned long
+               ulongtemp;
+       long
+               longtemp;
+       double
+               vel_scale;
+
+       buf = rpt->buf;
+
+       if (rpt->len != 56) return TRUE;
+
+       vel_scale = (buf[24]&1)? 0.020 : 0.005;
+       vel_enu[0] = bGetShort (buf+2)*vel_scale;
+       vel_enu[1] = bGetShort (buf+4)*vel_scale;
+       vel_enu[2] = bGetShort (buf+6)*vel_scale;
+
+       *time_of_fix = bGetULong (buf+8)*.001;
+
+       longtemp = bGetLong (buf+12);
+       *lat = longtemp*(GPS_PI/MAX_LONG);
+
+       ulongtemp = bGetULong (buf+16);
+       *lon = ulongtemp*(GPS_PI/MAX_LONG);
+       if (*lon > GPS_PI) *lon -= 2.0*GPS_PI;
+
+       *alt = bGetLong (buf+20)*.001;
+       /* 25 blank; 29 = UTC */
+       (*datum_index) = (short)((short)buf[26]-1);
+       *info = buf[27];
+       *nsvs = buf[28];
+       *week_num = bGetShort (&buf[30]);
+       for (isv = 0; isv < 8; isv++) {
+               prnx = buf[32+2*isv];
+               sv_prn[isv] = (unsigned char)(prnx&0x3F);
+      iode = buf[33+2*isv];
+               sv_IODC[isv] = (short)(iode | ((prnx>>6)<<8));
+       }
+       return FALSE;
+}
+
+short rpt_0x8F41 (TSIPPKT *rpt,
+       unsigned char *bSearchRange,
+       unsigned char *bBoardOptions,
+       unsigned long *iiSerialNumber,
+       unsigned char *bBuildYear,
+       unsigned char *bBuildMonth,
+       unsigned char *bBuildDay,
+       unsigned char *bBuildHour,
+       float *fOscOffset,
+       unsigned short *iTestCodeId)
+{
+       if(rpt->len != 17) return FALSE;
+       *bSearchRange = rpt->buf[1];
+       *bBoardOptions = rpt->buf[2];
+       *iiSerialNumber = bGetLong(&rpt->buf[3]);
+       *bBuildYear = rpt->buf[7];
+       *bBuildMonth = rpt->buf[8];
+       *bBuildDay = rpt->buf[9];
+       *bBuildHour =   rpt->buf[10];
+       *fOscOffset = bGetSingle(&rpt->buf[11]);
+       *iTestCodeId = bGetShort(&rpt->buf[15]);
+/*     Tsipx8E41Data = *Tsipx8E41; */
+       return TRUE;
+}
+
+short rpt_0x8F42 (TSIPPKT *rpt,
+       unsigned char *bProdOptionsPre,
+       unsigned char *bProdNumberExt,
+       unsigned short *iCaseSerialNumberPre,
+       unsigned long *iiCaseSerialNumber,
+       unsigned long *iiProdNumber,
+       unsigned short *iPremiumOptions,
+       unsigned short *iMachineID,
+       unsigned short *iKey)
+{
+       if(rpt->len != 19) return FALSE;
+       *bProdOptionsPre = rpt->buf[1];
+       *bProdNumberExt = rpt->buf[2];
+       *iCaseSerialNumberPre = bGetShort(&rpt->buf[3]);
+       *iiCaseSerialNumber = bGetLong(&rpt->buf[5]);
+       *iiProdNumber = bGetLong(&rpt->buf[9]);
+       *iPremiumOptions = bGetShort(&rpt->buf[13]);
+       *iMachineID = bGetShort(&rpt->buf[15]);
+       *iKey = bGetShort(&rpt->buf[17]);
+       return TRUE;
+}
+
+short rpt_0x8F45(TSIPPKT *rpt,
+   unsigned char *bSegMask)
+{
+       if(rpt->len != 2) return FALSE;
+       *bSegMask = rpt->buf[1];
+       return TRUE;
+}
+
+short rpt_0x8F4A_16(TSIPPKT *rpt,
+       unsigned char *pps_enabled,
+   unsigned char *pps_timebase,
+   unsigned char *pos_polarity,
+   double *pps_offset,
+   float *bias_unc_threshold)
+/* Stinger PPS definition */
+{
+       unsigned char
+       *buf;
+
+   buf = rpt->buf;
+   if (rpt->len != 16) return TRUE;
+   *pps_enabled = buf[1];
+   *pps_timebase = buf[2];
+   *pos_polarity = buf[3];
+   *pps_offset = bGetDouble(&buf[4]);
+   *bias_unc_threshold = bGetSingle(&buf[12]);
+       return FALSE;
+}
+
+short rpt_0x8F4B(TSIPPKT *rpt,
+                 unsigned long *decorr_max)
+{
+       unsigned char
+       *buf;
+
+   buf = rpt->buf;
+   if (rpt->len != 5) return TRUE;
+   *decorr_max = bGetLong(&buf[1]);
+   return FALSE;
+}
+
+short rpt_0x8F4D(TSIPPKT *rpt,
+       unsigned long *event_mask)
+{
+       unsigned char
+       *buf;
+
+   buf = rpt->buf;
+   if (rpt->len != 5) return TRUE;
+   *event_mask = bGetULong (&buf[1]);
+   return FALSE;
+}
+
+short rpt_0x8FA5(TSIPPKT *rpt,
+       unsigned char *spktmask)
+{
+       unsigned char
+       *buf;
+
+   buf = rpt->buf;
+   if (rpt->len != 5) return TRUE;
+   spktmask[0] = buf[1];
+   spktmask[1] = buf[2];
+   spktmask[2] = buf[3];
+   spktmask[3] = buf[4];
+   return FALSE;
+}
+
+short rpt_0x8FAD (TSIPPKT *rpt,
+    unsigned short *COUNT,
+    double *FracSec,
+    unsigned char *Hour,
+    unsigned char *Minute,
+    unsigned char *Second,
+    unsigned char *Day,
+    unsigned char *Month,
+    unsigned short *Year,
+    unsigned char *Status,
+    unsigned char *Flags)
+{
+
+       if (rpt->len != 22) return TRUE;
+
+    *COUNT = bGetUShort(&rpt->buf[1]);
+    *FracSec = bGetDouble(&rpt->buf[3]);
+    *Hour = rpt->buf[11];
+    *Minute = rpt->buf[12];
+    *Second = rpt->buf[13];
+    *Day = rpt->buf[14];
+    *Month = rpt->buf[15];
+    *Year = bGetUShort(&rpt->buf[16]);
+    *Status = rpt->buf[18];
+    *Flags = rpt->buf[19];
+    return FALSE;
+}
+
+
+/*
+ * *************************************************************************
+ *
+ * Trimble Navigation, Ltd.
+ * OEM Products Development Group
+ * P.O. Box 3642
+ * 645 North Mary Avenue
+ * Sunnyvale, California 94088-3642
+ *
+ * Corporate Headquarter:
+ *    Telephone:  (408) 481-8000
+ *    Fax:        (408) 481-6005
+ *
+ * Technical Support Center:
+ *    Telephone:  (800) 767-4822       (U.S. and Canada)
+ *                (408) 481-6940    (outside U.S. and Canada)
+ *    Fax:        (408) 481-6020
+ *    BBS:        (408) 481-7800
+ *    e-mail:     trimble_support@trimble.com
+ *             ftp://ftp.trimble.com/pub/sct/embedded/bin
+ *
+ * *************************************************************************
+ *
+ * T_REPORT.C consists of a primary function TranslateTSIPReportToText()
+ * called by main().
+ *
+ * This function takes a character buffer that has been received as a report
+ * from a TSIP device and interprets it.  The character buffer has been
+ * assembled using tsip_input_proc() in T_PARSER.C.
+ *
+ * A large case statement directs processing to one of many mid-level
+ * functions.  The mid-level functions specific to the current report
+ * code passes the report buffer to the appropriate report decoder
+ * rpt_0x?? () in T_PARSER.C, which converts the byte stream in rpt.buf
+ * to data values approporaite for use.
+ *
+ * *************************************************************************
+ *
+ */
+
+
+#define GOOD_PARSE 0
+#define BADID_PARSE 1
+#define BADLEN_PARSE 2
+#define BADDATA_PARSE 3
+
+#define B_TSIP 0x02
+#define B_NMEA 0x04
+
+
+/* pbuf is the pointer to the current location of the text output */
+static char
+       *pbuf;
+
+/* keep track of whether the message has been successfully parsed */
+static short
+       parsed;
+
+
+/* convert time of week into day-hour-minute-second and print */
+char* show_time (float time_of_week)
+{
+       short   days, hours, minutes;
+       float seconds;
+       double tow = 0;
+   static char timestring [80];
+
+       if (time_of_week == -1.0)
+   {
+               sprintf(timestring, "   <No time yet>   ");
+       }
+       else if ((time_of_week >= 604800.0) || (time_of_week < 0.0))
+   {
+               sprintf(timestring, "     <Bad time>     ");
+       }
+   else
+   {
+               if (time_of_week < 604799.9) 
+                       tow = time_of_week + .00000001;
+               seconds = (float)fmod(tow, 60.);
+               minutes =  (short) fmod(tow/60., 60.);
+               hours = (short)fmod(tow / 3600., 24.);
+               days = (short)(tow / 86400.0);
+               sprintf(timestring, " %s %02d:%02d:%05.2f   ",
+               dayname[days], hours, minutes, seconds);
+   }
+   return timestring;
+}
+
+/**/
+/* 0x3D */
+static void rpt_chan_A_config (TSIPPKT *rpt)
+{
+       unsigned char
+               tx_baud_index, rx_baud_index,
+               char_format_index, stop_bits,
+      tx_mode_index, rx_mode_index,
+      databits, parity;
+       int
+               i, nbaud;
+
+       /* unload rptbuf */
+       if (rpt_0x3D (rpt,
+               &tx_baud_index, &rx_baud_index, &char_format_index,
+               &stop_bits, &tx_mode_index, &rx_mode_index)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nChannel A Configuration");
+
+   nbaud = sizeof(old_baudnum);
+
+       for (i = 0; i < nbaud; ++i) if (tx_baud_index == old_baudnum[i]) break;
+       pbuf += sprintf(pbuf, "\n   Transmit speed: %s at %s",
+               old_output_ch[tx_mode_index], st_baud_text_app[i]);
+
+       for (i = 0; i < nbaud; ++i) if (rx_baud_index == old_baudnum[i]) break;
+       pbuf += sprintf(pbuf, "\n   Receive speed: %s at %s",
+               old_input_ch[rx_mode_index], st_baud_text_app[i]);
+
+       databits = (unsigned char)((char_format_index & 0x03) + 5);
+
+       parity = (unsigned char)(char_format_index >> 2);
+       if (parity > 4) parity = 2;
+
+       pbuf += sprintf(pbuf, "\n   Character format (bits/char, parity, stop bits): %d-%s-%d",
+               databits, old_parity_text[parity], stop_bits);
+}
+
+/**/
+/* 0x40 */
+static void rpt_almanac_data_page (TSIPPKT *rpt)
+{
+       unsigned char
+               sv_prn;
+       short
+               week_num;
+       float
+               t_zc,
+               eccentricity,
+               t_oa,
+               i_0,
+               OMEGA_dot,
+               sqrt_A,
+               OMEGA_0,
+               omega,
+               M_0;
+
+       /* unload rptbuf */
+       if (rpt_0x40 (rpt,
+               &sv_prn, &week_num, &t_zc, &eccentricity, &t_oa,
+               &i_0, &OMEGA_dot, &sqrt_A, &OMEGA_0, &omega, &M_0)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nAlmanac for SV %02d", sv_prn);
+       pbuf += sprintf(pbuf, "\n       Captured:%15.0f %s",
+       t_zc, show_time (t_zc));
+       pbuf += sprintf(pbuf, "\n           week:%15d", week_num);
+       pbuf += sprintf(pbuf, "\n   Eccentricity:%15g", eccentricity);
+       pbuf += sprintf(pbuf, "\n           T_oa:%15.0f %s",
+       t_oa, show_time (t_oa));
+       pbuf += sprintf(pbuf, "\n            i 0:%15g", i_0);
+       pbuf += sprintf(pbuf, "\n      OMEGA dot:%15g", OMEGA_dot);
+       pbuf += sprintf(pbuf, "\n         sqrt A:%15g", sqrt_A);
+       pbuf += sprintf(pbuf, "\n        OMEGA 0:%15g", OMEGA_0);
+       pbuf += sprintf(pbuf, "\n          omega:%15g", omega);
+       pbuf += sprintf(pbuf, "\n            M 0:%15g", M_0);
+}
+
+/* 0x41 */
+static void rpt_GPS_time (TSIPPKT *rpt)
+{
+       float
+               time_of_week, UTC_offset;
+       short
+               week_num;
+
+       /* unload rptbuf */
+       if (rpt_0x41 (rpt, &time_of_week, &UTC_offset, &week_num)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nGPS time:%s GPS week: %d   UTC offset %.1f",
+       show_time(time_of_week), week_num, UTC_offset);
+
+}
+
+/* 0x42 */
+static void rpt_single_ECEF_position (TSIPPKT *rpt)
+{
+       float
+               ECEF_pos[3], time_of_fix;
+
+       /* unload rptbuf */
+       if (rpt_0x42 (rpt, ECEF_pos, &time_of_fix)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nSXYZ:  %15.0f  %15.0f  %15.0f    %s",
+               ECEF_pos[0], ECEF_pos[1], ECEF_pos[2],
+      show_time(time_of_fix));
+}
+
+/* 0x43 */
+static void rpt_single_ECEF_velocity (TSIPPKT *rpt)
+{
+
+       float
+               ECEF_vel[3], freq_offset, time_of_fix;
+
+       /* unload rptbuf */
+       if (rpt_0x43 (rpt, ECEF_vel, &freq_offset, &time_of_fix)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nVelECEF: %11.3f  %11.3f  %11.3f  %12.3f%s",
+               ECEF_vel[0], ECEF_vel[1], ECEF_vel[2], freq_offset,
+      show_time(time_of_fix));
+}
+
+/*  0x45  */
+static void rpt_SW_version (TSIPPKT *rpt) {
+       unsigned char
+               major_nav_version, minor_nav_version,
+               nav_day, nav_month, nav_year,
+               major_dsp_version, minor_dsp_version,
+               dsp_day, dsp_month, dsp_year;
+
+       /* unload rptbuf */
+       if (rpt_0x45 (rpt,
+               &major_nav_version, &minor_nav_version,
+               &nav_day, &nav_month, &nav_year,
+               &major_dsp_version, &minor_dsp_version,
+               &dsp_day, &dsp_month, &dsp_year)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf,
+"\nFW Versions:  Nav Proc %2d.%02d  %2d/%2d/%2d  Sig Proc %2d.%02d  %2d/%2d/%2d",
+               major_nav_version, minor_nav_version, nav_day, nav_month, nav_year,
+               major_dsp_version, minor_dsp_version, dsp_day, dsp_month, dsp_year);
+}
+
+/* 0x46 */
+static void rpt_rcvr_health (TSIPPKT *rpt)
+{
+       unsigned char
+               status1, status2;
+       static char
+               *sc_text[] = {
+                       "Doing position fixes",
+                       "Don't have GPS time yet",
+                       "Waiting for almanac collection",
+                       "DOP too high          ",
+                       "No satellites available",
+                       "Only 1 satellite available",
+                       "Only 2 satellites available",
+                       "Only 3 satellites available",
+                       "No satellites usable   ",
+                       "Only 1 satellite usable",
+                       "Only 2 satellites usable",
+                       "Only 3 satellites usable",
+                       "Chosen satellite unusable"};
+
+
+       /* unload rptbuf */
+       if (rpt_0x46 (rpt, &status1, &status2))
+       {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nRcvr status1: %s (%02Xh); ",
+       sc_text[rpt->buf[0]], status1);
+
+       pbuf += sprintf(pbuf, "status2: %s, %s (%02Xh)",
+               (status2 & 0x01)?"No BBRAM":"BBRAM OK",
+               (status2 & 0x10)?"No Ant":"Ant OK",
+      status2);
+}
+
+/* 0x47 */
+static void rpt_SNR_all_SVs (TSIPPKT *rpt)
+{
+       unsigned char
+               nsvs, sv_prn[12];
+       short
+               isv;
+       float
+               snr[12];
+
+       /* unload rptbuf */
+       if (rpt_0x47 (rpt, &nsvs, sv_prn, snr))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nSNR for satellites: %d", nsvs);
+       for (isv = 0; isv < nsvs; isv++)
+   {
+               pbuf += sprintf(pbuf, "\n    SV %02d   %6.2f",
+       sv_prn[isv], snr[isv]);
+       }
+}
+
+/* 0x48 */
+static void rpt_GPS_system_message (TSIPPKT *rpt)
+{
+       unsigned char
+               message[23];
+
+       /* unload rptbuf */
+       if (rpt_0x48 (rpt, message))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nGPS message: %s", message);
+}
+
+/* 0x49 */
+static void rpt_almanac_health_page (TSIPPKT *rpt)
+{
+       short
+               iprn;
+       unsigned char
+               sv_health [32];
+
+       /* unload rptbuf */
+       if (rpt_0x49 (rpt, sv_health))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nAlmanac health page:");
+       for (iprn = 0; iprn < 32; iprn++)
+   {
+               if (!(iprn%5)) *pbuf++ = '\n';
+               pbuf += sprintf(pbuf, "    SV%02d  %2X",
+       (iprn+1) , sv_health[iprn]);
+       }
+}
+
+/* 0x4A */
+static void rpt_single_lla_position (TSIPPKT *rpt) {
+       short
+               lat_deg, lon_deg;
+       float
+               lat, lon,
+               alt, clock_bias, time_of_fix;
+       double lat_min, lon_min;
+       unsigned char
+               north_south, east_west;
+
+       if (rpt_0x4A (rpt,
+               &lat, &lon, &alt, &clock_bias, &time_of_fix))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       /* convert from radians to degrees */
+       lat *= (float)R2D;
+       north_south = 'N';
+       if (lat < 0.0)
+   {
+               north_south = 'S';
+               lat = -lat;
+       }
+       lat_deg = (short)lat;
+       lat_min = (lat - lat_deg) * 60.0;
+
+       lon *= (float)R2D;
+       east_west = 'E';
+       if (lon < 0.0)
+   {
+               east_west = 'W';
+               lon = -lon;
+       }
+       lon_deg = (short)lon;
+       lon_min = (lon - lon_deg) * 60.0;
+
+       pbuf += sprintf(pbuf, "\nSLLA: %4d: %06.3f  %c%5d:%06.3f  %c%10.2f  %12.2f%s",
+               lat_deg, lat_min, north_south,
+               lon_deg, lon_min, east_west,
+               alt, clock_bias,
+               show_time(time_of_fix));
+}
+
+/* 0x4A */
+static void rpt_ref_alt (TSIPPKT *rpt) {
+
+       float
+               alt, dummy;
+       unsigned char
+               alt_flag;
+
+       if (rpt_0x4A_2 (rpt,
+               &alt, &dummy, &alt_flag))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nReference Alt:   %.1f m;    %s",
+       alt, alt_flag?"ON":"OFF");
+}
+
+/* 0x4B */
+static void rpt_rcvr_id_and_status (TSIPPKT *rpt)
+{
+
+       unsigned char
+               machine_id, status3, status4;
+
+       /* unload rptbuf */
+       if (rpt_0x4B (rpt, &machine_id, &status3, &status4))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nRcvr Machine ID: %d; Status3 = %s, %s (%02Xh)",
+       machine_id,
+               (status3 & 0x02)?"No RTC":"RTC OK",
+               (status3 & 0x08)?"No Alm":"Alm OK",
+               status3);
+}
+
+/* 0x4C */
+static void rpt_operating_parameters (TSIPPKT *rpt)
+{
+       unsigned char
+               dyn_code;
+       float
+               el_mask, snr_mask, dop_mask, dop_switch;
+
+       /* unload rptbuf */
+       if (rpt_0x4C (rpt, &dyn_code, &el_mask,
+               &snr_mask, &dop_mask, &dop_switch))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nOperating Parameters:");
+       pbuf += sprintf(pbuf, "\n     Dynamics code = %d %s",
+       dyn_code, dyn_text[dyn_code]);
+       pbuf += sprintf(pbuf, "\n     Elevation mask = %.2fø", el_mask * R2D);
+       pbuf += sprintf(pbuf, "\n     SNR mask = %.2f", snr_mask);
+       pbuf += sprintf(pbuf, "\n     DOP mask = %.2f", dop_mask);
+       pbuf += sprintf(pbuf, "\n     DOP switch = %.2f", dop_switch);
+}
+
+/* 0x4D */
+static void rpt_oscillator_offset (TSIPPKT *rpt)
+{
+       float
+               osc_offset;
+
+       /* unload rptbuf */
+       if (rpt_0x4D (rpt, &osc_offset))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nOscillator offset: %.2f Hz = %.3f PPM",
+       osc_offset, osc_offset/1575.42);
+}
+
+/* 0x4E */
+static void rpt_GPS_time_set_response (TSIPPKT *rpt)
+{
+
+       unsigned char
+               response;
+
+       /* unload rptbuf */
+       if (rpt_0x4E (rpt, &response))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       switch (response)
+   {
+       case 'Y':
+               pbuf += sprintf(pbuf, "\nTime set accepted");
+               break;
+
+       case 'N':
+               pbuf += sprintf(pbuf, "\nTime set rejected or not required");
+               break;
+
+       default:
+               parsed = BADDATA_PARSE;
+       }
+}
+
+/* 0x4F */
+static void rpt_UTC_offset (TSIPPKT *rpt)
+{
+       double
+               a0;
+       float
+               a1, time_of_data;
+       short
+               dt_ls, wn_t, wn_lsf, dn, dt_lsf;
+
+       /* unload rptbuf */
+       if (rpt_0x4F (rpt, &a0, &a1, &time_of_data,
+               &dt_ls, &wn_t, &wn_lsf, &dn, &dt_lsf)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nUTC Correction Data");
+       pbuf += sprintf(pbuf, "\n   A_0         = %g  ", a0);
+       pbuf += sprintf(pbuf, "\n   A_1         = %g  ", a1);
+       pbuf += sprintf(pbuf, "\n   delta_t_LS  = %d  ", dt_ls);
+       pbuf += sprintf(pbuf, "\n   t_ot        = %.0f  ", time_of_data);
+       pbuf += sprintf(pbuf, "\n   WN_t        = %d  ", wn_t );
+       pbuf += sprintf(pbuf, "\n   WN_LSF      = %d  ", wn_lsf );
+       pbuf += sprintf(pbuf, "\n   DN          = %d  ", dn );
+       pbuf += sprintf(pbuf, "\n   delta_t_LSF = %d  ", dt_lsf );
+}
+
+/**/
+/* 0x54 */
+static void rpt_1SV_bias (TSIPPKT *rpt)
+{
+       float
+               clock_bias, freq_offset, time_of_fix;
+
+       /* unload rptbuf */
+       if (rpt_0x54 (rpt, &clock_bias, &freq_offset, &time_of_fix)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf (pbuf, "\nTime Fix   Clock Bias: %6.2f m  Freq Bias: %6.2f m/s%s",
+               clock_bias, freq_offset, show_time (time_of_fix));
+}
+
+/* 0x55 */
+static void rpt_io_opt (TSIPPKT *rpt)
+{
+       unsigned char
+               pos_code, vel_code, time_code, aux_code;
+
+       /* unload rptbuf */
+       if (rpt_0x55 (rpt,
+               &pos_code, &vel_code, &time_code, &aux_code)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+       /* rptbuf unloaded */
+
+       pbuf += sprintf(pbuf, "\nI/O Options: %2X %2X %2X %2X",
+               pos_code, vel_code, time_code, aux_code);
+
+       if (pos_code & 0x01) {
+               pbuf += sprintf(pbuf, "\n    ECEF XYZ position output");
+       }
+
+       if (pos_code & 0x02) {
+               pbuf += sprintf(pbuf, "\n    LLA position output");
+       }
+
+       pbuf += sprintf(pbuf, (pos_code & 0x04)?
+               "\n    MSL altitude output (Geoid height) ":
+               "\n    WGS-84 altitude output");
+
+       pbuf += sprintf(pbuf, (pos_code & 0x08)?
+               "\n    MSL altitude input":
+      "\n    WGS-84 altitude input");
+
+       pbuf += sprintf(pbuf, (pos_code & 0x10)?
+               "\n    Double precision":
+      "\n    Single precision");
+
+       if (pos_code & 0x20) {
+               pbuf += sprintf(pbuf, "\n    All Enabled Superpackets");
+       }
+
+       if (vel_code & 0x01) {
+               pbuf += sprintf(pbuf, "\n    ECEF XYZ velocity output");
+       }
+
+       if (vel_code & 0x02) {
+               pbuf += sprintf(pbuf, "\n    ENU velocity output");
+       }
+
+       pbuf += sprintf(pbuf, (time_code & 0x01)?
+                 "\n    Time tags in UTC":
+        "\n    Time tags in GPS time");
+
+       if (time_code & 0x02) {
+               pbuf += sprintf(pbuf, "\n    Fixes delayed to integer seconds");
+       }
+
+       if (time_code & 0x04) {
+               pbuf += sprintf(pbuf, "\n    Fixes sent only on request");
+       }
+
+       if (time_code & 0x08) {
+               pbuf += sprintf(pbuf, "\n    Synchronized measurements");
+       }
+
+       if (time_code & 0x10) {
+               pbuf += sprintf(pbuf, "\n    Minimize measurement propagation");
+       }
+
+   pbuf += sprintf(pbuf, (time_code & 0x20) ?
+               "\n    PPS output at all times" :
+       "\n    PPS output during fixes");
+
+       if (aux_code & 0x01) {
+               pbuf += sprintf(pbuf, "\n    Raw measurement output");
+       }
+
+       if (aux_code & 0x02) {
+               pbuf += sprintf(pbuf, "\n    Code-phase smoothed before output");
+       }
+
+       if (aux_code & 0x04) {
+               pbuf += sprintf(pbuf, "\n    Additional fix status");
+       }
+
+       pbuf += sprintf(pbuf, (aux_code & 0x08)?
+       "\n    Signal Strength Output as dBHz" :
+       "\n    Signal Strength Output as AMU");
+}
+
+/* 0x56 */
+static void rpt_ENU_velocity (TSIPPKT *rpt)
+{
+       float
+               vel_ENU[3], freq_offset, time_of_fix;
+
+       /* unload rptbuf */
+       if (rpt_0x56 (rpt, vel_ENU, &freq_offset, &time_of_fix)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nVel ENU: %11.3f  %11.3f  %11.3f  %12.3f%s",
+               vel_ENU[0], vel_ENU[1], vel_ENU[2], freq_offset,
+      show_time (time_of_fix));
+}
+
+/* 0x57 */
+static void rpt_last_fix_info (TSIPPKT *rpt)
+{
+       unsigned char
+               source_code, diag_code;
+       short
+               week_num;
+       float
+               time_of_fix;
+
+       /* unload rptbuf */
+       if (rpt_0x57 (rpt, &source_code, &diag_code, &week_num, &time_of_fix)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\n source code %d;   diag code: %2Xh",
+       source_code, diag_code);
+       pbuf += sprintf(pbuf, "\n    Time of last fix:%s", show_time(time_of_fix));
+       pbuf += sprintf(pbuf, "\n    Week of last fix: %d", week_num);
+}
+
+/* 0x58 */
+static void rpt_GPS_system_data (TSIPPKT *rpt)
+{
+       unsigned char
+       iprn,
+               op_code, data_type, sv_prn,
+               data_length, data_packet[250];
+       ALM_INFO
+               *almanac;
+       ALH_PARMS
+               *almh;
+       UTC_INFO
+               *utc;
+       ION_INFO
+               *ionosphere;
+       EPHEM_CLOCK
+               *cdata;
+       EPHEM_ORBIT
+               *edata;
+       NAV_INFO
+               *nav_data;
+       unsigned char
+               curr_t_oa;
+       unsigned short
+               curr_wn_oa;
+       static char
+               *datname[] =
+               {"", "", "Almanac Orbit",
+               "Health Page & Ref Time", "Ionosphere", "UTC ",
+               "Ephemeris"};
+
+       /* unload rptbuf */
+       if (rpt_0x58 (rpt, &op_code, &data_type, &sv_prn,
+               &data_length, data_packet))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nSystem data [%d]:  %s  SV%02d",
+               data_type, datname[data_type], sv_prn);
+       switch (op_code)
+       {
+       case 1:
+               pbuf += sprintf(pbuf, "  Acknowledgment");
+               break;
+       case 2:
+               pbuf += sprintf(pbuf, "  length = %d bytes", data_length);
+               switch (data_type) {
+               case 2:
+                       /* Almanac */
+                       if (sv_prn == 0 || sv_prn > 32) {
+                               pbuf += sprintf(pbuf, "  Binary PRN invalid");
+                               return;
+                       }
+                       almanac = (ALM_INFO*)data_packet;
+                       pbuf += sprintf(pbuf, "\n   t_oa_raw = % -12d    SV_hlth  = % -12d  ",
+               almanac->t_oa_raw , almanac->SV_health );
+                       pbuf += sprintf(pbuf, "\n   e        = % -12g    t_oa     = % -12g  ",
+               almanac->e        , almanac->t_oa     );
+                       pbuf += sprintf(pbuf, "\n   i_0      = % -12g    OMEGADOT = % -12g  ",
+               almanac->i_0      , almanac->OMEGADOT );
+                       pbuf += sprintf(pbuf, "\n   sqrt_A   = % -12g    OMEGA_0  = % -12g  ",
+               almanac->sqrt_A   , almanac->OMEGA_0  );
+                       pbuf += sprintf(pbuf, "\n   omega    = % -12g    M_0      = % -12g  ",
+               almanac->omega    , almanac->M_0      );
+                       pbuf += sprintf(pbuf, "\n   a_f0     = % -12g    a_f1     = % -12g  ",
+               almanac->a_f0     , almanac->a_f1     );
+                       pbuf += sprintf(pbuf, "\n   Axis     = % -12g    n        = % -12g  ",
+               almanac->Axis     , almanac->n        );
+                       pbuf += sprintf(pbuf, "\n   OMEGA_n  = % -12g    ODOT_n   = % -12g  ",
+               almanac->OMEGA_n  , almanac->ODOT_n   );
+                       pbuf += sprintf(pbuf, "\n   t_zc     = % -12g    weeknum  = % -12d  ",
+               almanac->t_zc     , almanac->weeknum  );
+                       pbuf += sprintf(pbuf, "\n   wn_oa    = % -12d", almanac->wn_oa    );
+                       break;
+
+               case 3:
+                       /* Almanac health page */
+                       almh = (ALH_PARMS*)data_packet;
+                       pbuf += sprintf(pbuf, "\n   t_oa = %d, wn_oa&0xFF = %d  ",
+               almh->t_oa, almh->WN_a);
+                       pbuf += sprintf(pbuf, "\nAlmanac health page:");
+                       for (iprn = 0; iprn < 32; iprn++) {
+                               if (!(iprn%5)) *pbuf++ = '\n';
+                               pbuf += sprintf(pbuf, "    SV%02d  %2X",
+               (iprn+1) , almh->SV_health[iprn]);
+                       }
+                       curr_t_oa = data_packet[34];
+                       curr_wn_oa = (unsigned short)((data_packet[35]<<8) + data_packet[36]);
+                       pbuf += sprintf(pbuf, "\n   current t_oa = %d, wn_oa = %d  ",
+               curr_t_oa, curr_wn_oa);
+                       break;
+
+               case 4:
+                       /* Ionosphere */
+                       ionosphere = (ION_INFO*)data_packet;
+                       pbuf += sprintf(pbuf, "\n   alpha_0 = % -12g  alpha_1 = % -12g ",
+                ionosphere->alpha_0, ionosphere->alpha_1);
+                       pbuf += sprintf(pbuf, "\n   alpha_2 = % -12g  alpha_3 = % -12g ",
+                ionosphere->alpha_2, ionosphere->alpha_3);
+                       pbuf += sprintf(pbuf, "\n   beta_0  = % -12g  beta_1  = % -12g  ",
+                ionosphere->beta_0, ionosphere->beta_1);
+                       pbuf += sprintf(pbuf, "\n   beta_2  = % -12g  beta_3  = % -12g  ",
+                ionosphere->beta_2, ionosphere->beta_3);
+                       break;
+
+               case 5:
+                       /* UTC */
+                       utc = (UTC_INFO*)data_packet;
+                       pbuf += sprintf(pbuf, "\n   A_0         = %g  ", utc->A_0);
+                       pbuf += sprintf(pbuf, "\n   A_1         = %g  ", utc->A_1);
+                       pbuf += sprintf(pbuf, "\n   delta_t_LS  = %d  ", utc->delta_t_LS);
+                       pbuf += sprintf(pbuf, "\n   t_ot        = %.0f  ", utc->t_ot );
+                       pbuf += sprintf(pbuf, "\n   WN_t        = %d  ", utc->WN_t );
+                       pbuf += sprintf(pbuf, "\n   WN_LSF      = %d  ", utc->WN_LSF );
+                       pbuf += sprintf(pbuf, "\n   DN          = %d  ", utc->DN );
+                       pbuf += sprintf(pbuf, "\n   delta_t_LSF = %d  ", utc->delta_t_LSF );
+                       break;
+
+               case 6: /* Ephemeris */
+                       if (sv_prn == 0 || sv_prn > 32) {
+                               pbuf += sprintf(pbuf, "  Binary PRN invalid");
+                               return;
+                       }
+                       nav_data = (NAV_INFO*)data_packet;
+
+                       pbuf += sprintf(pbuf, "\n     SV_PRN = % -12d .  t_ephem = % -12g . ",
+               nav_data->sv_number , nav_data->t_ephem );
+                       cdata = &(nav_data->ephclk);
+                       pbuf += sprintf(pbuf,
+               "\n    weeknum = % -12d .   codeL2 = % -12d .  L2Pdata = % -12d",
+               cdata->weeknum , cdata->codeL2 , cdata->L2Pdata );
+                       pbuf += sprintf(pbuf,
+               "\n  SVacc_raw = % -12d .SV_health = % -12d .     IODC = % -12d",
+               cdata->SVacc_raw, cdata->SV_health, cdata->IODC );
+                       pbuf += sprintf(pbuf,
+               "\n       T_GD = % -12g .     t_oc = % -12g .     a_f2 = % -12g",
+               cdata->T_GD, cdata->t_oc, cdata->a_f2 );
+                       pbuf += sprintf(pbuf,
+               "\n       a_f1 = % -12g .     a_f0 = % -12g .    SVacc = % -12g",
+               cdata->a_f1, cdata->a_f0, cdata->SVacc );
+                       edata = &(nav_data->ephorb);
+                       pbuf += sprintf(pbuf,
+                "\n       IODE = % -12d .fit_intvl = % -12d .     C_rs = % -12g",
+                edata->IODE, edata->fit_interval, edata->C_rs );
+                       pbuf += sprintf(pbuf,
+               "\n    delta_n = % -12g .      M_0 = % -12g .     C_uc = % -12g",
+               edata->delta_n, edata->M_0, edata->C_uc );
+                       pbuf += sprintf(pbuf,
+               "\n        ecc = % -12g .     C_us = % -12g .   sqrt_A = % -12g",
+                edata->e, edata->C_us, edata->sqrt_A );
+                       pbuf += sprintf(pbuf,
+               "\n       t_oe = % -12g .     C_ic = % -12g .  OMEGA_0 = % -12g",
+            edata->t_oe, edata->C_ic, edata->OMEGA_0 );
+                       pbuf += sprintf(pbuf,
+                "\n       C_is = % -12g .      i_0 = % -12g .     C_rc = % -12g",
+                edata->C_is, edata->i_0, edata->C_rc );
+                       pbuf += sprintf(pbuf,
+                "\n      omega = % -12g . OMEGADOT = % -12g .     IDOT = % -12g",
+               edata->omega, edata->OMEGADOT, edata->IDOT );
+                       pbuf += sprintf(pbuf,
+             "\n       Axis = % -12g .        n = % -12g .    r1me2 = % -12g",
+                edata->Axis, edata->n, edata->r1me2 );
+                       pbuf += sprintf(pbuf,
+          "\n    OMEGA_n = % -12g .   ODOT_n = % -12g",
+                edata->OMEGA_n, edata->ODOT_n );
+                       break;
+               }
+       }
+}
+
+
+/* 0x59: */
+static void rpt_SVs_enabled (TSIPPKT *rpt)
+{
+       unsigned char
+       numsvs,
+               code_type,
+      status_code[32];
+       short
+               iprn;
+
+       /* unload rptbuf */
+       if (rpt_0x59 (rpt, &code_type, status_code))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+   switch (code_type)
+   {
+   case 3: pbuf += sprintf(pbuf, "\nSVs Disabled:\n"); break;
+   case 6: pbuf += sprintf(pbuf, "\nSVs with Health Ignored:\n"); break;
+   default: return;
+   }
+   numsvs = 0;
+       for (iprn=0; iprn<32; iprn++)
+   {
+       if (status_code[iprn])
+      {
+               pbuf += sprintf(pbuf, " %02d", iprn+1);
+          numsvs++;
+      }
+   }
+   if (numsvs == 0) pbuf += sprintf(pbuf, "None");
+}
+
+
+/* 0x5A */
+static void rpt_raw_msmt (TSIPPKT *rpt)
+{
+       unsigned char
+               sv_prn;
+       float
+               sample_length, signal_level, code_phase, Doppler;
+       double
+               time_of_fix;
+
+       /* unload rptbuf */
+       if (rpt_0x5A (rpt, &sv_prn, &sample_length, &signal_level,
+               &code_phase, &Doppler, &time_of_fix))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\n   %02d %5.0f %7.1f %10.2f %10.2f %12.3f %s",
+               sv_prn, sample_length, signal_level, code_phase, Doppler, time_of_fix,
+               show_time ((float)time_of_fix));
+}
+
+/* 0x5B */
+static void rpt_SV_ephemeris_status (TSIPPKT *rpt)
+{
+       unsigned char
+               sv_prn, sv_health, sv_iode, fit_interval_flag;
+       float
+               time_of_collection, time_of_eph, sv_accy;
+
+       /* unload rptbuf */
+       if (rpt_0x5B (rpt, &sv_prn, &sv_health, &sv_iode, &fit_interval_flag,
+               &time_of_collection, &time_of_eph, &sv_accy))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\n  SV%02d  %s   %2Xh     %2Xh ",
+       sv_prn, show_time (time_of_collection), sv_health, sv_iode);
+       /* note: cannot use show_time twice in same call */
+       pbuf += sprintf(pbuf, "%s   %1d   %4.1f",
+      show_time (time_of_eph), fit_interval_flag, sv_accy);
+}
+
+/* 0x5C */
+static void rpt_SV_tracking_status (TSIPPKT *rpt)
+{
+       unsigned char
+               sv_prn, chan, slot, acq_flag, eph_flag,
+               old_msmt_flag, integer_msec_flag, bad_data_flag,
+               data_collect_flag;
+       float
+               signal_level, time_of_last_msmt,
+               elev, azim;
+
+       /* unload rptbuf */
+       if (rpt_0x5C (rpt,
+               &sv_prn, &slot, &chan, &acq_flag, &eph_flag,
+               &signal_level, &time_of_last_msmt, &elev, &azim,
+               &old_msmt_flag, &integer_msec_flag, &bad_data_flag,
+               &data_collect_flag))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf,
+"\n SV%2d  %1d   %1d   %1d   %4.1f  %s  %5.1f  %5.1f",
+               sv_prn, chan,
+      acq_flag, eph_flag, signal_level,
+      show_time(time_of_last_msmt),
+               elev*R2D, azim*R2D);
+}
+
+/**/
+/* 0x6D */
+static void rpt_allSV_selection (TSIPPKT *rpt)
+{
+       unsigned char
+               manual_mode, nsvs, sv_prn[8], ndim;
+       short
+               islot;
+       float
+               pdop, hdop, vdop, tdop;
+
+       /* unload rptbuf */
+       if (rpt_0x6D (rpt,
+               &manual_mode, &nsvs, &ndim, sv_prn,
+               &pdop, &hdop, &vdop, &tdop))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       switch (ndim)
+   {
+   case 0:
+               pbuf += sprintf(pbuf, "\nMode: Searching, %d-SV:", nsvs);
+      break;
+   case 1:
+               pbuf += sprintf(pbuf, "\nMode: One-SV Timing:");
+      break;
+   case 3: case 4:
+               pbuf += sprintf(pbuf, "\nMode: %c-%dD, %d-SV:",
+                       manual_mode ? 'M' : 'A', ndim - 1,  nsvs);
+      break;
+       case 5:
+               pbuf += sprintf(pbuf, "\nMode: Timing, %d-SV:", nsvs);
+      break;
+   default:
+               pbuf += sprintf(pbuf, "\nMode: Unknown = %d:", ndim);
+      break;
+   }
+
+       for (islot = 0; islot < nsvs; islot++)
+   {
+               if (sv_prn[islot]) pbuf += sprintf(pbuf, " %02d", sv_prn[islot]);
+       }
+   if (ndim == 3 || ndim == 4)
+   {
+               pbuf += sprintf(pbuf, ";  DOPs: P %.1f H %.1f V %.1f T %.1f",
+                       pdop, hdop, vdop, tdop);
+   }
+}
+
+/**/
+/* 0x82 */
+static void rpt_DGPS_position_mode (TSIPPKT *rpt)
+{
+       unsigned char
+               diff_mode;
+
+       /* unload rptbuf */
+       if (rpt_0x82 (rpt, &diff_mode)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nFix is%s DGPS-corrected (%s mode)  (%d)",
+       (diff_mode&1) ? "" : " not",
+       (diff_mode&2) ? "auto" : "manual",
+      diff_mode);
+}
+
+/* 0x83 */
+static void rpt_double_ECEF_position (TSIPPKT *rpt)
+{
+
+       double
+               ECEF_pos[3], clock_bias;
+       float
+               time_of_fix;
+
+       /* unload rptbuf */
+       if (rpt_0x83 (rpt, ECEF_pos, &clock_bias, &time_of_fix))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\nDXYZ:%12.2f  %13.2f  %13.2f %12.2f%s",
+               ECEF_pos[0], ECEF_pos[1], ECEF_pos[2], clock_bias,
+               show_time(time_of_fix));
+}
+
+/* 0x84 */
+static void rpt_double_lla_position (TSIPPKT *rpt)
+{
+       short
+               lat_deg, lon_deg;
+       double
+               lat, lon, lat_min, lon_min,
+               alt, clock_bias;
+       float
+               time_of_fix;
+       unsigned char
+               north_south, east_west;
+
+       /* unload rptbuf */
+       if (rpt_0x84 (rpt,
+               &lat, &lon, &alt, &clock_bias, &time_of_fix))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       lat *= R2D;
+       lon *= R2D;
+       if (lat < 0.0) {
+               north_south = 'S';
+               lat = -lat;
+       } else {
+               north_south = 'N';
+       }
+       lat_deg = (short)lat;
+       lat_min = (lat - lat_deg) * 60.0;
+
+       if (lon < 0.0) {
+               east_west = 'W';
+               lon = -lon;
+       } else {
+               east_west = 'E';
+       }
+       lon_deg = (short)lon;
+       lon_min = (lon - lon_deg) * 60.0;
+       pbuf += sprintf(pbuf, "\nDLLA: %2d:%08.5f %c; %3d:%08.5f %c; %10.2f %12.2f%s",
+               lat_deg, lat_min, north_south,
+               lon_deg, lon_min, east_west,
+               alt, clock_bias,
+               show_time(time_of_fix));
+}
+
+/* 0xBB */
+static void rpt_complete_rcvr_config (TSIPPKT *rpt)
+{
+       TSIP_RCVR_CFG TsipxBB ;
+       /* unload rptbuf */
+       if (rpt_Paly0xBB (rpt, &TsipxBB))
+       {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       pbuf += sprintf(pbuf, "\n   operating mode:      %s",
+               NavModeText0xBB[TsipxBB.operating_mode]);
+       pbuf += sprintf(pbuf, "\n   dynamics:            %s",
+               dyn_text[TsipxBB.dyn_code]);
+       pbuf += sprintf(pbuf, "\n   elev angle mask:     %g deg",
+               TsipxBB.elev_mask * R2D);
+       pbuf += sprintf(pbuf, "\n   SNR mask:            %g AMU",
+               TsipxBB.cno_mask);
+       pbuf += sprintf(pbuf, "\n   DOP mask:            %g",
+               TsipxBB.dop_mask);
+       pbuf += sprintf(pbuf, "\n   DOP switch:          %g",
+               TsipxBB.dop_switch);
+       return ;
+}
+
+/* 0xBC */
+static void rpt_rcvr_serial_port_config (TSIPPKT *rpt)
+{
+       unsigned char
+               port_num, in_baud, out_baud, data_bits, parity, stop_bits, flow_control,
+               protocols_in, protocols_out, reserved;
+       unsigned char known;
+
+       /* unload rptbuf */
+       if (rpt_0xBC (rpt, &port_num, &in_baud, &out_baud, &data_bits, &parity,
+                       &stop_bits, &flow_control, &protocols_in, &protocols_out, &reserved)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+       /* rptbuf unloaded */
+
+       pbuf += sprintf(pbuf, "\n   RECEIVER serial port %s config:",
+               rcvr_port_text[port_num]);
+
+       pbuf += sprintf(pbuf, "\n             I/O Baud %s/%s, %d - %s - %d",
+               st_baud_text_app[in_baud],
+               st_baud_text_app[out_baud],
+               data_bits+5,
+               parity_text[parity],
+               stop_bits=1);
+       pbuf += sprintf(pbuf, "\n             Input protocols: ");
+       known = FALSE;
+       if (protocols_in&B_TSIP)
+   {
+               pbuf += sprintf(pbuf, "%s ", protocols_in_text[1]);
+               known = TRUE;
+       }
+       if (known == FALSE) pbuf += sprintf(pbuf, "No known");
+
+       pbuf += sprintf(pbuf, "\n             Output protocols: ");
+       known = FALSE;
+       if (protocols_out&B_TSIP)
+   {
+               pbuf += sprintf(pbuf, "%s ", protocols_out_text[1]);
+               known = TRUE;
+       }
+       if (protocols_out&B_NMEA)
+   {
+               pbuf += sprintf(pbuf, "%s ", protocols_out_text[2]);
+               known = TRUE;
+       }
+       if (known == FALSE) pbuf += sprintf(pbuf, "No known");
+       reserved = reserved;
+
+ }
+
+/* 0x8F */
+/* 8F0B */
+static void rpt_8F0B(TSIPPKT *rpt)
+{
+       const char
+       *oprtng_dim[7] = {
+       "horizontal (2-D)",
+         "full position (3-D)",
+         "single satellite (0-D)",
+         "automatic",
+         "N/A",
+         "N/A",
+         "overdetermined clock"};
+   char
+       sv_id[8];
+   unsigned char
+       month,
+      date,
+      dim_mode,
+      north_south,
+      east_west;
+   unsigned short
+       event;
+   short
+       utc_offset,
+      year,
+      local_index;
+       short
+       lat_deg,
+      lon_deg;
+   float
+       bias_unc,
+      dr_unc;
+   double
+       tow,
+      bias,
+      drift,
+      lat,
+      lon,
+      alt,
+      lat_min,
+      lon_min;
+   int
+       numfix,
+      numnotfix;
+
+       if (rpt_0x8F0B(rpt,
+       &event,
+      &tow,
+      &date,
+      &month,
+      &year,
+      &dim_mode,
+      &utc_offset,
+      &bias,
+      &drift,
+      &bias_unc,
+      &dr_unc,
+      &lat,
+      &lon,
+      &alt,
+      sv_id))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       if (event == 0)
+   {
+       pbuf += sprintf(pbuf, "\nNew partial+full meas");
+       }
+   else
+   {
+               pbuf += sprintf(pbuf, "\nEvent count: %5d", event);
+   }
+
+       pbuf += sprintf(pbuf, "\nGPS time  : %s %2d/%2d/%2d (DMY)",
+       show_time(tow), date, month, year);
+       pbuf += sprintf(pbuf, "\nMode      : %s", oprtng_dim[dim_mode]);
+       pbuf += sprintf(pbuf, "\nUTC offset: %2d", utc_offset);
+       pbuf += sprintf(pbuf, "\nClock Bias: %6.2f m", bias);
+       pbuf += sprintf(pbuf, "\nFreq bias : %6.2f m/s", drift);
+       pbuf += sprintf(pbuf, "\nBias unc  : %6.2f m", bias_unc);
+       pbuf += sprintf(pbuf, "\nFreq unc  : %6.2f m/s", dr_unc);
+
+       lat *= R2D; /* convert from radians to degrees */
+       lon *= R2D;
+       if (lat < 0.0)
+   {
+               north_south = 'S';
+               lat = -lat;
+       }
+   else
+   {
+               north_south = 'N';
+       }
+
+       lat_deg = (short)lat;
+       lat_min = (lat - lat_deg) * 60.0;
+       if (lon < 0.0)
+   {
+               east_west = 'W';
+               lon = -lon;
+       }
+   else
+   {
+               east_west = 'E';
+       }
+
+       lon_deg = (short)lon;
+       lon_min = (lon - lon_deg) * 60.0;
+       pbuf += sprintf(pbuf, "\nPosition  :");
+       pbuf += sprintf(pbuf, " %4d %6.3f %c", lat_deg, lat_min, north_south);
+       pbuf += sprintf(pbuf, " %5d %6.3f %c", lon_deg, lon_min, east_west);
+       pbuf += sprintf(pbuf, " %10.2f", alt);
+
+   numfix = numnotfix = 0;
+       for (local_index=0; local_index<8; local_index++)
+   {
+               if (sv_id[local_index] < 0) numnotfix++;
+               if (sv_id[local_index] > 0) numfix++;
+   }
+   if (numfix > 0)
+   {
+               pbuf += sprintf(pbuf, "\nSVs used in fix  : ");
+               for (local_index=0; local_index<8; local_index++)
+          {
+                       if (sv_id[local_index] > 0)
+       {
+               pbuf += sprintf(pbuf, "%2d ", sv_id[local_index]);
+             }
+       }
+   }
+   if (numnotfix > 0)
+   {
+               pbuf += sprintf(pbuf, "\nOther SVs tracked: ");
+               for (local_index=0; local_index<8; local_index++)
+          {
+                       if (sv_id[local_index] < 0)
+       {
+               pbuf += sprintf(pbuf, "%2d ", sv_id[local_index]);
+             }
+       }
+   }
+}
+
+/* 0x8F14 */
+static void rpt_8F14 (TSIPPKT *rpt)
+/* Datum parameters */
+{
+       double
+               datum_coeffs[5];
+       short
+               datum_idx;
+
+       /* unload rptbuf */
+       if (rpt_0x8F14 (rpt, &datum_idx, datum_coeffs))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       if (datum_idx == -1)
+   {
+       pbuf += sprintf(pbuf, "\nUser-Entered Datum:");
+               pbuf += sprintf(pbuf, "\n   dx        = %6.1f", datum_coeffs[0]);
+               pbuf += sprintf(pbuf, "\n   dy        = %6.1f", datum_coeffs[1]);
+               pbuf += sprintf(pbuf, "\n   dz        = %6.1f", datum_coeffs[2]);
+               pbuf += sprintf(pbuf, "\n   a-axis    = %10.3f", datum_coeffs[3]);
+               pbuf += sprintf(pbuf, "\n   e-squared = %16.14f", datum_coeffs[4]);
+   }
+   else if (datum_idx == 0)
+   {
+       pbuf += sprintf(pbuf, "\nWGS-84 datum, Index 0 ");
+   }
+   else
+   {
+       pbuf += sprintf(pbuf, "\nStandard Datum, Index %3d ", datum_idx);
+   }
+}
+
+/* 0x8F15 */
+static void rpt_8F15 (TSIPPKT *rpt)
+/* Datum parameters */
+{
+       double
+               datum_coeffs[5];
+       short
+               datum_idx;
+
+       /* unload rptbuf */
+       if (rpt_0x8F15 (rpt, &datum_idx, datum_coeffs)) {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+
+       if (datum_idx == -1)
+   {
+       pbuf += sprintf(pbuf, "\nUser-Entered Datum:");
+               pbuf += sprintf(pbuf, "\n   dx        = %6.1f", datum_coeffs[0]);
+               pbuf += sprintf(pbuf, "\n   dy        = %6.1f", datum_coeffs[1]);
+               pbuf += sprintf(pbuf, "\n   dz        = %6.1f", datum_coeffs[2]);
+               pbuf += sprintf(pbuf, "\n   a-axis    = %10.3f", datum_coeffs[3]);
+               pbuf += sprintf(pbuf, "\n   e-squared = %16.14f", datum_coeffs[4]);
+   }
+   else if (datum_idx == 0)
+   {
+       pbuf += sprintf(pbuf, "\nWGS-84 datum, Index 0 ");
+   }
+   else
+   {
+       pbuf += sprintf(pbuf, "\nStandard Datum, Index %3d ", datum_idx);
+   }
+}
+
+/* 0x8F20 */
+#define INFO_DGPS       0x02
+#define INFO_2D         0x04
+#define INFO_ALTSET     0x08
+#define INFO_FILTERED   0x10
+static void rpt_8F20 (TSIPPKT *rpt)
+{
+       unsigned char
+               info, nsvs, sv_prn[32];
+       short
+               week_num, datum_index, sv_IODC[32];
+       double
+               lat, lon, alt, time_of_fix;
+       double
+               londeg, latdeg, vel[3];
+       short
+               isv;
+   char
+       datum_string[20];
+
+       /* unload rptbuf */
+       if (rpt_0x8F20 (rpt,
+               &info, &lat, &lon, &alt, vel,
+               &time_of_fix,
+               &week_num, &nsvs, sv_prn, sv_IODC, &datum_index))
+       {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+       pbuf += sprintf(pbuf,
+       "\nFix at: %04d:%3s:%02d:%02d:%06.3f GPS (=UTC+%2ds)  FixType: %s%s%s",
+       week_num,
+               dayname[(short)(time_of_fix/86400.0)],
+               (short)fmod(time_of_fix/3600., 24.),
+               (short)fmod(time_of_fix/60., 60.),
+               fmod(time_of_fix, 60.),
+      (char)rpt->buf[29],              /* UTC offset */
+               (info & INFO_DGPS)?"Diff":"",
+               (info & INFO_2D)?"2D":"3D",
+               (info & INFO_FILTERED)?"-Filtrd":"");
+
+   if (datum_index > 0)
+   {
+               sprintf(datum_string, "Datum%3d", datum_index);
+   }
+   else if (datum_index)
+   {
+               sprintf(datum_string, "Unknown ");
+   }
+   else
+   {
+               sprintf(datum_string, "WGS-84");
+   }
+
+       /* convert from radians to degrees */
+       latdeg = R2D * fabs(lat);
+       londeg = R2D * fabs(lon);
+       pbuf += sprintf(pbuf,
+       "\n   Pos: %4d:%09.6f %c %5d:%09.6f %c %10.2f m HAE (%s)",
+               (short)latdeg, fmod (latdeg, 1.)*60.0,
+               (lat<0.0)?'S':'N',
+               (short)londeg, fmod (londeg, 1.)*60.0,
+               (lon<0.0)?'W':'E',
+               alt,
+      datum_string);
+       pbuf += sprintf(pbuf,
+       "\n   Vel:    %9.3f E       %9.3f N      %9.3f U   (m/sec)",
+               vel[0], vel[1], vel[2]);
+
+       pbuf += sprintf(pbuf,
+       "\n   SVs: ");
+       for (isv = 0; isv < nsvs; isv++) {
+               pbuf += sprintf(pbuf, " %02d", sv_prn[isv]);
+       }
+       pbuf += sprintf(pbuf, "     (IODEs:");
+       for (isv = 0; isv < nsvs; isv++) {
+               pbuf += sprintf(pbuf, " %02X", sv_IODC[isv]&0xFF);
+       }
+       pbuf += sprintf(pbuf, ")");
+}
+
+/* 0x8F41 */
+static void rpt_8F41(TSIPPKT *rpt)
+{
+       unsigned char
+       bSearchRange,
+               bBoardOptions,
+               bBuildYear,
+               bBuildMonth,
+               bBuildDay,
+               bBuildHour;
+       float
+       fOscOffset;
+       unsigned short
+       iTestCodeId;
+       unsigned long
+               iiSerialNumber;
+
+   if (!rpt_0x8F41(rpt,
+               &bSearchRange,
+               &bBoardOptions,
+               &iiSerialNumber,
+               &bBuildYear,
+               &bBuildMonth,
+               &bBuildDay,
+               &bBuildHour,
+               &fOscOffset,
+               &iTestCodeId))
+   {
+               parsed = BADLEN_PARSE;
+      return;
+   }
+
+   pbuf += sprintf(pbuf, "\n  search range:          %d",
+       bSearchRange);
+   pbuf += sprintf(pbuf, "\n  board options:         %d",
+      bBoardOptions);
+   pbuf += sprintf(pbuf, "\n  board serial #:        %ld",
+      iiSerialNumber);
+   pbuf += sprintf(pbuf, "\n  build date/hour:       %02d/%02d/%02d %02d:00",
+       bBuildDay, bBuildMonth, bBuildYear, bBuildHour);
+   pbuf += sprintf(pbuf, "\n  osc offset:            %.3f PPM (%.0f Hz)",
+       fOscOffset/1575.42, fOscOffset);
+   pbuf += sprintf(pbuf, "\n  test code:             %d",
+       iTestCodeId);
+}
+
+/* 0x8F42 */
+static void rpt_8F42(TSIPPKT *rpt)
+{
+       unsigned char
+       bProdOptionsPre,
+      bProdNumberExt;
+       unsigned short
+       iCaseSerialNumberPre,
+      iPremiumOptions,
+      iMachineID,
+      iKey;
+       unsigned long
+       iiCaseSerialNumber,
+               iiProdNumber;
+
+   if (!rpt_0x8F42(rpt,
+               &bProdOptionsPre,
+               &bProdNumberExt,
+               &iCaseSerialNumberPre,
+               &iiCaseSerialNumber,
+               &iiProdNumber,
+               &iPremiumOptions,
+               &iMachineID,
+               &iKey))
+   {
+               parsed = BADLEN_PARSE;
+      return;
+   }
+
+       pbuf += sprintf(pbuf, "\nProduct ID 8F42");
+   pbuf += sprintf(pbuf, "\n   extension:            %d", bProdNumberExt);
+   pbuf += sprintf(pbuf, "\n   case serial # prefix: %d", iCaseSerialNumberPre);
+   pbuf += sprintf(pbuf, "\n   case serial #:        %ld", iiCaseSerialNumber);
+   pbuf += sprintf(pbuf, "\n   prod. #:              %ld", iiProdNumber);
+       pbuf += sprintf(pbuf, "\n   premium options:      %Xh", iPremiumOptions);
+   pbuf += sprintf(pbuf, "\n   machine ID:           %d", iMachineID);
+   pbuf += sprintf(pbuf, "\n   key:                  %Xh", iKey);
+}
+
+/* 0x8F45 */
+static void rpt_8F45(TSIPPKT *rpt)
+{
+   unsigned char bSegMask;
+
+   if (!rpt_0x8F45(rpt,
+       &bSegMask))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+       }
+       pbuf += sprintf(pbuf, "\nCleared Segment Mask: %Xh", bSegMask);
+}
+
+static void rpt_8F4A(TSIPPKT *rpt)
+/* Stinger PPS def */
+{
+       unsigned char
+       pps_enabled,
+      pps_timebase,
+      pps_polarity;
+   float
+       bias_unc_threshold;
+   double
+       pps_offset;
+
+       if (rpt_0x8F4A_16 (rpt,
+       &pps_enabled,
+      &pps_timebase,
+      &pps_polarity,
+      &pps_offset,
+      &bias_unc_threshold))
+   {
+       parsed = BADLEN_PARSE;
+          return;
+   }
+
+       pbuf += sprintf(pbuf, "\nPPS is         %s",    pps_enabled?"enabled":"disabled");
+   pbuf += sprintf(pbuf, "\n   timebase:   %s", PPSTimeBaseText[pps_timebase]);
+   pbuf += sprintf(pbuf, "\n   polarity:   %s", PPSPolarityText[pps_polarity]);
+   pbuf += sprintf(pbuf, "\n   offset:     %.1f ns, ", pps_offset*1.e9);
+   pbuf += sprintf(pbuf, "\n   biasunc:    %.1f ns", bias_unc_threshold/GPS_C*1.e9);
+}
+
+static void rpt_8F4B(TSIPPKT *rpt)
+/* fast-SA decorrolation time for self-survey */
+{
+       unsigned long
+       decorr_max;
+
+   if (rpt_0x8F4B(rpt, &decorr_max))
+   {
+               parsed = BADLEN_PARSE;
+      return;
+   }
+
+   pbuf += sprintf(pbuf,
+       "\nMax # of position fixes for self-survey : %ld",
+      decorr_max);
+}
+
+static void rpt_8F4D(TSIPPKT *rpt)
+{
+       static char
+       *linestart;
+       unsigned long
+       OutputMask;
+   static unsigned long
+       MaskBit[] = {
+       0x00000001, 0x00000002, 0x00000004, 0x00000008, 0x00000010, 0x00000020,
+       0x00000100L, 0x00000800L, 0x00001000L,
+         0x40000000L, 0x80000000L};
+   int
+       ichoice,
+       numchoices;
+
+   if (rpt_0x8F4D(rpt, &OutputMask))
+   {
+               parsed = BADLEN_PARSE;
+      return;
+   }
+
+   pbuf += sprintf(pbuf, "\nAuto-Report Mask: %02X %02X %02X %02X",
+       (unsigned char)(OutputMask>>24),
+       (unsigned char)(OutputMask>>16),
+       (unsigned char)(OutputMask>>8),
+       (unsigned char)OutputMask);
+
+   numchoices = sizeof(MaskText)/sizeof(char*);
+   pbuf += sprintf(pbuf, "\nAuto-Reports scheduled for Output:");
+   linestart = pbuf;
+   for (ichoice=0; ichoice<numchoices; ichoice++)
+   {
+       if (OutputMask&MaskBit[ichoice])
+      {
+               pbuf += sprintf(pbuf, "%s %s",
+               (pbuf==linestart)?"\n     ":",",
+          MaskText[ichoice]);
+                       if (pbuf-linestart > 60) linestart = pbuf;
+      }
+   }
+
+   pbuf += sprintf(pbuf, "\nAuto-Reports NOT scheduled for Output:");
+   linestart = pbuf;
+   for (ichoice=0; ichoice<numchoices; ichoice++)
+   {
+       if (OutputMask&MaskBit[ichoice]) continue;
+               pbuf += sprintf(pbuf, "%s %s",
+               (pbuf==linestart)?"\n     ":",",
+         MaskText[ichoice]);
+               if (pbuf-linestart > 60) linestart = pbuf;
+   }
+}
+
+static void rpt_8FA5(TSIPPKT *rpt)
+{
+       unsigned char
+       spktmask[4];
+
+   if (rpt_0x8FA5(rpt, spktmask))
+   {
+               parsed = BADLEN_PARSE;
+      return;
+   }
+
+   pbuf += sprintf(pbuf, "\nSuperpacket auto-output mask: %02X %02X %02X %02X",
+       spktmask[0], spktmask[1], spktmask[2], spktmask[3]);
+
+   if (spktmask[0]&0x01) pbuf+= sprintf (pbuf, "\n    PPS   8F-0B");
+   if (spktmask[0]&0x02) pbuf+= sprintf (pbuf, "\n    Event 8F-0B");
+   if (spktmask[0]&0x10) pbuf+= sprintf (pbuf, "\n    PPS   8F-AD");
+   if (spktmask[0]&0x20) pbuf+= sprintf (pbuf, "\n    Event 8F-AD");
+   if (spktmask[2]&0x01) pbuf+= sprintf (pbuf, "\n    ppos Fix 8F-20");
+}
+
+static void rpt_8FAD (TSIPPKT *rpt)
+{
+   unsigned short
+       Count,
+       Year;
+   double
+       FracSec;
+   unsigned char
+       Hour,
+       Minute,
+       Second,
+       Day,
+       Month,
+       Status,
+       Flags;
+       static char* Status8FADText[] = {
+      "CODE_DOING_FIXES",
+      "CODE_GOOD_1_SV",
+      "CODE_APPX_1SV",
+      "CODE_NEED_TIME",
+      "CODE_NEED_INITIALIZATION",
+      "CODE_PDOP_HIGH",
+      "CODE_BAD_1SV",
+      "CODE_0SVS",
+      "CODE_1SV",
+      "CODE_2SVS",
+      "CODE_3SVS",
+      "CODE_NO_INTEGRITY",
+      "CODE_DCORR_GEN",
+      "CODE_OVERDET_CLK",
+      "Invalid Status"},
+       *LeapStatusText[] = {
+       " UTC Avail", " ", " ", " ",
+      " Scheduled", " Pending", " Warning", " In Progress"};
+    int i;
+
+       if (rpt_0x8FAD (rpt,
+       &Count,
+       &FracSec,
+       &Hour,
+       &Minute,
+       &Second,
+       &Day,
+       &Month,
+       &Year,
+       &Status,
+       &Flags))
+   {
+               parsed = BADLEN_PARSE;
+               return;
+   }
+
+       pbuf += sprintf(pbuf,    "\n8FAD   Count: %d   Status: %s",
+       Count, Status8FADText[Status]);
+
+       pbuf += sprintf(pbuf, "\n   Leap Flags:");
+   if (Flags)
+   {
+       for (i=0; i<8; i++)
+      {
+       if (Flags&(1<<i)) pbuf += sprintf(pbuf, LeapStatusText[i]);
+      }
+   }
+   else
+   {
+       pbuf += sprintf(pbuf, "  UTC info not available");
+   }
+
+       pbuf += sprintf(pbuf,     "\n      %02d/%02d/%04d (DMY)  %02d:%02d:%02d.%09ld UTC",
+               Day, Month, Year, Hour, Minute, Second, (long)(FracSec*1.e9));
+}
+
+
+int print_msg_table_header (int rptcode, char *HdrStr, int force)
+{
+       /* force header is to help auto-output function */
+       /* last_rptcode is to determine whether to print a header */
+       /* for the first occurrence of a series of reports */
+       static int
+               last_rptcode = 0;
+   int
+       numchars;
+
+   numchars = 0;
+       if (force || rptcode!=last_rptcode)
+   {
+               /* supply a header in console output */
+       switch (rptcode)
+               {
+               case 0x5A:
+                       numchars = sprintf(HdrStr, "\nRaw Measurement Data");
+                       numchars += sprintf(HdrStr+numchars,
+               "\n   SV  Sample   SNR  Code Phase   Doppler    Seconds     Time of Meas");
+                       break;
+
+               case 0x5B:
+                       numchars = sprintf(HdrStr, "\nEphemeris Status");
+                       numchars += sprintf(HdrStr+numchars,
+                               "\n    SV     Time collected     Health  IODE        t oe         Fit   URA");
+                       break;
+
+               case 0x5C:
+                       numchars = sprintf(HdrStr, "\nTracking Info");
+                       numchars += sprintf(HdrStr+numchars,
+               "\n   SV  C Acq Eph   SNR     Time of Meas       Elev  Azim   ");
+                       break;
+
+      }
+       }
+       last_rptcode = rptcode;
+   return (short)numchars;
+}
+
+static void unknown_rpt (TSIPPKT *rpt)
+{
+       int i;
+
+       /* app-specific rpt packets */
+       if (parsed == BADLEN_PARSE)
+   {
+               pbuf += sprintf(pbuf, "\nTSIP report packet ID %2Xh, length %d: Bad length",
+       rpt->code, rpt->len);
+   }
+       if (parsed == BADID_PARSE)
+   {
+               pbuf += sprintf(pbuf,
+       "\nTSIP report packet ID %2Xh, length %d: translation not supported",
+               rpt->code, rpt->len);
+   }
+
+       if (parsed == BADDATA_PARSE)
+   {
+               pbuf += sprintf(pbuf,
+       "\nTSIP report packet ID %2Xh, length %d: data content incorrect",
+               rpt->code, rpt->len);
+   }
+
+       for (i = 0; i < rpt->len; i++) {
+               if ((i % 20) == 0) *pbuf++ = '\n';
+               pbuf += sprintf(pbuf, " %02X", rpt->buf[i]);
+       }
+}
+/**/
+/*
+** main subroutine, called from ProcessInputBytesWhileWaitingForKBHit()
+*/
+void TranslateTSIPReportToText (TSIPPKT *rpt, char *TextOutputBuffer)
+{
+
+       /* pbuf is the pointer to the current location of the text output */
+       pbuf = TextOutputBuffer;
+
+   /* keep track of whether the message has been successfully parsed */
+       parsed = GOOD_PARSE;
+
+       /* print a header if this is the first of a series of messages */
+       pbuf += print_msg_table_header (rpt->code, pbuf, FALSE);
+
+   /* process incoming TSIP report according to code */
+       switch (rpt->code)
+   {
+       case 0x3D: rpt_chan_A_config (rpt); break;
+       case 0x40: rpt_almanac_data_page (rpt); break;
+       case 0x41: rpt_GPS_time (rpt); break;
+       case 0x42: rpt_single_ECEF_position (rpt); break;
+       case 0x43: rpt_single_ECEF_velocity (rpt); break;
+       case 0x45: rpt_SW_version (rpt); break;
+       case 0x46: rpt_rcvr_health (rpt); break;
+       case 0x47: rpt_SNR_all_SVs (rpt); break;
+       case 0x48: rpt_GPS_system_message (rpt); break;
+       case 0x49: rpt_almanac_health_page (rpt); break;
+       case 0x4A: switch (rpt->len) {
+       /*
+      ** special case (=slip-up) in the TSIP protocol;
+      ** parsing method depends on length
+      */
+       case 20: rpt_single_lla_position (rpt); break;
+      case  9: rpt_ref_alt (rpt); break;
+               } break;
+       case 0x4B: rpt_rcvr_id_and_status (rpt);break;
+       case 0x4C: rpt_operating_parameters (rpt); break;
+       case 0x4D: rpt_oscillator_offset (rpt); break;
+       case 0x4E: rpt_GPS_time_set_response (rpt); break;
+       case 0x4F: rpt_UTC_offset (rpt); break;
+   case 0x54: rpt_1SV_bias (rpt); break;
+       case 0x55: rpt_io_opt (rpt); break;
+       case 0x56: rpt_ENU_velocity (rpt); break;
+       case 0x57: rpt_last_fix_info (rpt); break;
+       case 0x58: rpt_GPS_system_data (rpt); break;
+       case 0x59: rpt_SVs_enabled (rpt); break;
+       case 0x5A: rpt_raw_msmt (rpt); break;
+       case 0x5B: rpt_SV_ephemeris_status (rpt); break;
+       case 0x5C: rpt_SV_tracking_status (rpt); break;
+       case 0x6D: rpt_allSV_selection (rpt); break;
+       case 0x82: rpt_DGPS_position_mode (rpt); break;
+       case 0x83: rpt_double_ECEF_position (rpt); break;
+       case 0x84: rpt_double_lla_position (rpt); break;
+       case 0xBB: rpt_complete_rcvr_config (rpt); break;
+       case 0xBC: rpt_rcvr_serial_port_config (rpt); break;
+
+       case 0x8F: switch (rpt->buf[0])
+       {
+      /* superpackets; parsed according to subcodes */
+      case 0x0B: rpt_8F0B(rpt); break;
+      case 0x14: rpt_8F14(rpt); break;
+      case 0x15: rpt_8F15(rpt); break;
+               case 0x20: rpt_8F20(rpt); break;
+      case 0x41: rpt_8F41(rpt); break;
+      case 0x42: rpt_8F42(rpt); break;
+      case 0x45: rpt_8F45(rpt); break;
+      case 0x4A: rpt_8F4A(rpt); break;
+      case 0x4B: rpt_8F4B(rpt); break;
+      case 0x4D: rpt_8F4D(rpt); break;
+      case 0xA5: rpt_8FA5(rpt); break;
+          case 0xAD: rpt_8FAD(rpt); break;
+               default: parsed = BADID_PARSE; break;
+               }
+               break;
+
+       default: parsed = BADID_PARSE; break;
+       }
+
+       if (parsed != GOOD_PARSE)
+       {
+          /*
+       **The message has TSIP structure (DLEs, etc.)
+          ** but could not be parsed by above routines
+       */
+               unknown_rpt (rpt);
+       }
+
+   /* close TextOutputBuffer */
+   pbuf = '\0';
+}
+
+#endif /* TRIMBLE_OUTPUT_FUNC */
+
+#else  /* defined(REFCLOCK) && defined(CLOCK_RIPENCC) */
+int refclock_ripencc_bs;
+#endif /* defined(REFCLOCK) && defined(CLOCK_RIPENCC) */
+
diff --git a/ntpd/refclock_shm.c b/ntpd/refclock_shm.c
new file mode 100644 (file)
index 0000000..7be263d
--- /dev/null
@@ -0,0 +1,312 @@
+/*
+ * refclock_shm - clock driver for utc via shared memory 
+ * - under construction -
+ * To add new modes: Extend or union the shmTime-struct. Do not
+ * extend/shrink size, because otherwise existing implementations
+ * will specify wrong size of shared memory-segment
+ * PB 18.3.97
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_SHM)
+
+#include "ntpd.h"
+#undef fileno   
+#include "ntp_io.h"
+#undef fileno   
+#include "ntp_refclock.h"
+#undef fileno   
+#include "ntp_unixtime.h"
+#undef fileno   
+#include "ntp_stdlib.h"
+
+#undef fileno   
+#include <ctype.h>
+#undef fileno   
+
+#ifndef SYS_WINNT
+# include <sys/ipc.h>
+# include <sys/shm.h>
+# include <assert.h>
+# include <unistd.h>
+# include <stdio.h>
+#endif
+
+/*
+ * This driver supports a reference clock attached thru shared memory
+ */ 
+
+/*
+ * SHM interface definitions
+ */
+#define PRECISION       (-1)    /* precision assumed (0.5 s) */
+#define REFID           "SHM"   /* reference ID */
+#define DESCRIPTION     "SHM/Shared memory interface"
+
+#define NSAMPLES        3       /* stages of median filter */
+
+/*
+ * Function prototypes
+ */
+static  int     shm_start       (int, struct peer *);
+static  void    shm_shutdown    (int, struct peer *);
+static  void    shm_poll        (int unit, struct peer *);
+
+/*
+ * Transfer vector
+ */
+struct  refclock refclock_shm = {
+       shm_start,              /* start up driver */
+       shm_shutdown,           /* shut down driver */
+       shm_poll,               /* transmit poll message */
+       noentry,                /* not used */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used */
+       NOFLAGS                 /* not used */
+};
+struct shmTime {
+       int    mode; /* 0 - if valid set
+                     *       use values, 
+                     *       clear valid
+                     * 1 - if valid set 
+                     *       if count before and after read of values is equal,
+                     *         use values 
+                     *       clear valid
+                     */
+       int    count;
+       time_t clockTimeStampSec;
+       int    clockTimeStampUSec;
+       time_t receiveTimeStampSec;
+       int    receiveTimeStampUSec;
+       int    leap;
+       int    precision;
+       int    nsamples;
+       int    valid;
+       int    dummy[10]; 
+};
+
+struct shmTime *getShmTime(int);
+
+struct shmTime *getShmTime (int unit) {
+#ifndef SYS_WINNT
+       int shmid=0;
+
+       assert (unit<10); /* MAXUNIT is 4, so should never happen */
+       shmid=shmget (0x4e545030+unit, sizeof (struct shmTime), 
+                     IPC_CREAT|(unit<2?0700:0777));
+       if (shmid==-1) { /*error */
+               msyslog(LOG_ERR,"SHM shmget (unit %d): %s",unit,strerror(errno));
+               return 0;
+       }
+       else { /* no error  */
+               struct shmTime *p=(struct shmTime *)shmat (shmid, 0, 0);
+               if ((int)(long)p==-1) { /* error */
+                       msyslog(LOG_ERR,"SHM shmat (unit %d): %s",unit,strerror(errno));
+                       return 0;
+               }
+               return p;
+       }
+#else
+       char buf[10];
+       LPSECURITY_ATTRIBUTES psec=0;
+       HANDLE shmid=0;
+       SECURITY_DESCRIPTOR sd;
+       SECURITY_ATTRIBUTES sa;
+       sprintf (buf,"NTP%d",unit);
+       if (unit>=2) { /* world access */
+               if (!InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION)) {
+                       msyslog(LOG_ERR,"SHM InitializeSecurityDescriptor (unit %d): %m",unit);
+                       return 0;
+               }
+               if (!SetSecurityDescriptorDacl(&sd,1,0,0)) {
+                       msyslog(LOG_ERR,"SHM SetSecurityDescriptorDacl (unit %d): %m",unit);
+                       return 0;
+               }
+               sa.nLength=sizeof (SECURITY_ATTRIBUTES);
+               sa.lpSecurityDescriptor=&sd;
+               sa.bInheritHandle=0;
+               psec=&sa;
+       }
+       shmid=CreateFileMapping ((HANDLE)0xffffffff, psec, PAGE_READWRITE,
+                                0, sizeof (struct shmTime),buf);
+       if (!shmid) { /*error*/
+               char buf[1000];
+               FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
+                              0, GetLastError (), 0, buf, sizeof (buf), 0);
+               msyslog(LOG_ERR,"SHM CreateFileMapping (unit %d): %s",unit,buf);
+               return 0;
+       }
+       else {
+               struct shmTime *p=(struct shmTime *) MapViewOfFile (shmid, 
+                                                                   FILE_MAP_WRITE, 0, 0, sizeof (struct shmTime));
+               if (p==0) { /*error*/
+                       char buf[1000];
+                       FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
+                                      0, GetLastError (), 0, buf, sizeof (buf), 0);
+                       msyslog(LOG_ERR,"SHM MapViewOfFile (unit %d): %s",unit,buf);
+                       return 0;
+               }
+               return p;
+       }
+#endif
+}
+/*
+ * shm_start - attach to shared memory
+ */
+static int
+shm_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct refclockproc *pp;
+       pp = peer->procptr;
+       pp->io.clock_recv = noentry;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = -1;
+       pp->unitptr = (caddr_t)getShmTime(unit);
+
+       /*
+        * Initialize miscellaneous peer variables
+        */
+       memcpy((char *)&pp->refid, REFID, 4);
+       if (pp->unitptr!=0) {
+               ((struct shmTime*)pp->unitptr)->precision=PRECISION;
+               peer->precision = ((struct shmTime*)pp->unitptr)->precision;
+               ((struct shmTime*)pp->unitptr)->valid=0;
+               ((struct shmTime*)pp->unitptr)->nsamples=NSAMPLES;
+               pp->clockdesc = DESCRIPTION;
+               return (1);
+       }
+       else {
+               return 0;
+       }
+}
+
+
+/*
+ * shm_shutdown - shut down the clock
+ */
+static void
+shm_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct shmTime *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct shmTime *)pp->unitptr;
+#ifndef SYS_WINNT
+       /* HMS: shmdt()wants char* or const void * */
+       (void) shmdt (up);
+#else
+       UnmapViewOfFile (up);
+#endif
+}
+
+
+/*
+ * shm_poll - called by the transmit procedure
+ */
+static void
+shm_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct shmTime *up;
+       struct refclockproc *pp;
+
+       /*
+        * This is the main routine. It snatches the time from the shm
+        * board and tacks on a local timestamp.
+        */
+       pp = peer->procptr;
+       up = (struct shmTime*)pp->unitptr;
+       if (up==0) { /* try to map again - this may succeed if meanwhile some-
+                       body has ipcrm'ed the old (unaccessible) shared mem
+                       segment  */
+               pp->unitptr = (caddr_t)getShmTime(unit);
+               up = (struct shmTime*)pp->unitptr;
+       }
+       if (up==0) {
+               refclock_report(peer, CEVNT_FAULT);
+               return;
+       }
+       if (up->valid) {
+               struct timeval tvr;
+               struct timeval tvt;
+               struct tm *t;
+               int ok=1;
+               tvr.tv_sec = 0;
+               tvr.tv_usec = 0;
+               tvt.tv_sec = 0;
+               tvt.tv_usec = 0;
+               switch (up->mode) {
+                   case 0: {
+                           tvr.tv_sec=up->receiveTimeStampSec;
+                           tvr.tv_usec=up->receiveTimeStampUSec;
+                           tvt.tv_sec=up->clockTimeStampSec;
+                           tvt.tv_usec=up->clockTimeStampUSec;
+                   }
+                   break;
+                   case 1: {
+                           int cnt=up->count;
+                           tvr.tv_sec=up->receiveTimeStampSec;
+                           tvr.tv_usec=up->receiveTimeStampUSec;
+                           tvt.tv_sec=up->clockTimeStampSec;
+                           tvt.tv_usec=up->clockTimeStampUSec;
+                           ok=(cnt==up->count);
+                   }
+                   break;
+                   default:
+                       msyslog (LOG_ERR, "SHM: bad mode found in shared memory: %d",up->mode);
+               }
+               up->valid=0;
+               if (ok) {
+                       time_t help;    /* XXX NetBSD has incompatible tv_sec */
+
+                       TVTOTS(&tvr,&pp->lastrec);
+                       pp->lastrec.l_ui += JAN_1970;
+                       /* pp->lasttime = current_time; */
+                       pp->polls++;
+                       help = tvt.tv_sec;
+                       t = gmtime (&help);
+                       pp->day=t->tm_yday+1;
+                       pp->hour=t->tm_hour;
+                       pp->minute=t->tm_min;
+                       pp->second=t->tm_sec;
+                       pp->nsec=tvt.tv_usec * 1000;
+                       peer->precision=up->precision;
+                       pp->leap=up->leap;
+               } 
+               else {
+                       refclock_report(peer, CEVNT_FAULT);
+                       msyslog (LOG_NOTICE, "SHM: access clash in shared memory");
+                       return;
+               }
+       }
+       else {
+               refclock_report(peer, CEVNT_TIMEOUT);
+               /*
+               msyslog (LOG_NOTICE, "SHM: no new value found in shared memory");
+               */
+               return;
+       }
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+}
+
+#else
+int refclock_shm_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_tpro.c b/ntpd/refclock_tpro.c
new file mode 100644 (file)
index 0000000..3c42568
--- /dev/null
@@ -0,0 +1,216 @@
+/*
+ * refclock_tpro - clock driver for the KSI/Odetics TPRO-S IRIG-B reader
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_TPRO)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "sys/tpro.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+/*
+ * This driver supports the KSI/Odetecs TPRO-S IRIG-B reader and TPRO-
+ * SAT GPS receiver for the Sun Microsystems SBus. It requires that the
+ * tpro.o device driver be installed and loaded.
+ */ 
+
+/*
+ * TPRO interface definitions
+ */
+#define        DEVICE           "/dev/tpro%d" /* device name and unit */
+#define        PRECISION       (-20)   /* precision assumed (1 us) */
+#define        REFID           "IRIG"  /* reference ID */
+#define        DESCRIPTION     "KSI/Odetics TPRO/S IRIG Interface" /* WRU */
+
+/*
+ * Unit control structure
+ */
+struct tprounit {
+       struct  tproval tprodata; /* data returned from tpro read */
+};
+
+/*
+ * Function prototypes
+ */
+static int     tpro_start      P((int, struct peer *));
+static void    tpro_shutdown   P((int, struct peer *));
+static void    tpro_poll       P((int unit, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_tpro = {
+       tpro_start,             /* start up driver */
+       tpro_shutdown,          /* shut down driver */
+       tpro_poll,              /* transmit poll message */
+       noentry,                /* not used (old tpro_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old tpro_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * tpro_start - open the TPRO device and initialize data for processing
+ */
+static int
+tpro_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct tprounit *up;
+       struct refclockproc *pp;
+       char device[20];
+       int fd;
+
+       /*
+        * Open TPRO device
+        */
+       (void)sprintf(device, DEVICE, unit);
+       fd = open(device, O_RDONLY | O_NDELAY, 0777);
+       if (fd == -1) {
+               msyslog(LOG_ERR, "tpro_start: open of %s: %m", device);
+               return (0);
+       }
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct tprounit *) emalloc(sizeof(struct tprounit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct tprounit));
+       pp = peer->procptr;
+       pp->io.clock_recv = noentry;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous peer variables
+        */
+       peer->precision = PRECISION;
+       peer->burst = NSTAGE;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       return (1);
+}
+
+
+/*
+ * tpro_shutdown - shut down the clock
+ */
+static void
+tpro_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct tprounit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct tprounit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * tpro_poll - called by the transmit procedure
+ */
+static void
+tpro_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct tprounit *up;
+       struct refclockproc *pp;
+       struct tproval *tp;
+
+       /*
+        * This is the main routine. It snatches the time from the TPRO
+        * board and tacks on a local timestamp.
+        */
+       pp = peer->procptr;
+       up = (struct tprounit *)pp->unitptr;
+
+       tp = &up->tprodata;
+       if (read(pp->io.fd, (char *)tp, sizeof(struct tproval)) < 0) {
+               refclock_report(peer, CEVNT_FAULT);
+               return;
+       }
+       get_systime(&pp->lastrec);
+       pp->polls++;
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. If the timecode has invalid length or is not in
+        * proper format, we declare bad format and exit. Note: we
+        * can't use the sec/usec conversion produced by the driver,
+        * since the year may be suspect. All format error checking is
+        * done by the sprintf() and sscanf() routines.
+        *
+        * Note that the refclockproc usec member has now become nsec.
+        * We could either multiply the read-in usec value by 1000 or
+        * we could pad the written string appropriately and read the
+        * resulting value in already scaled.
+        */
+       sprintf(pp->a_lastcode,
+           "%1x%1x%1x %1x%1x:%1x%1x:%1x%1x.%1x%1x%1x%1x%1x%1x %1x",
+           tp->day100, tp->day10, tp->day1, tp->hour10, tp->hour1,
+           tp->min10, tp->min1, tp->sec10, tp->sec1, tp->ms100,
+           tp->ms10, tp->ms1, tp->usec100, tp->usec10, tp->usec1,
+           tp->status);
+           pp->lencode = strlen(pp->a_lastcode);
+#ifdef DEBUG
+       if (debug)
+               printf("tpro: time %s timecode %d %s\n",
+                  ulfptoa(&pp->lastrec, 6), pp->lencode,
+                  pp->a_lastcode);
+#endif
+       if (sscanf(pp->a_lastcode, "%3d %2d:%2d:%2d.%6ld", &pp->day,
+           &pp->hour, &pp->minute, &pp->second, &pp->nsec)
+           != 5) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       pp->nsec *= 1000;       /* Convert usec to nsec */
+       if (!tp->status & 0x3)
+               pp->leap = LEAP_NOTINSYNC;
+       else
+               pp->leap = LEAP_NOWARNING;
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       if (peer->burst > 0)
+               return;
+       if (pp->coderecv == pp->codeproc) {
+               refclock_report(peer, CEVNT_TIMEOUT);
+               return;
+       }
+       refclock_receive(peer);
+       pp->lastref = pp->lastrec;
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       refclock_receive(peer);
+       peer->burst = NSTAGE;
+}
+
+#else
+int refclock_tpro_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_trak.c b/ntpd/refclock_trak.c
new file mode 100644 (file)
index 0000000..3a4a54e
--- /dev/null
@@ -0,0 +1,359 @@
+/*
+ * refclock_trak - clock driver for the TRAK 8810 GPS Station Clock
+ *
+ * Tomoaki TSURUOKA <tsuruoka@nc.fukuoka-u.ac.jp> 
+ *     original version  Dec, 1993
+ *     revised  version  Sep, 1994 for ntp3.4e or later
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_TRAK) && defined(PPS)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+#include "ntp_unixtime.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef HAVE_SYS_TERMIOS_H
+# include <sys/termios.h>
+#endif
+#ifdef HAVE_SYS_PPSCLOCK_H
+# include <sys/ppsclock.h>
+#endif
+
+/*
+ * This driver supports the TRAK 8810/8820 GPS Station Clock. The claimed
+ * accuracy at the 1-pps output is 200-300 ns relative to the broadcast
+ * signal; however, in most cases the actual accuracy is limited by the
+ * precision of the timecode and the latencies of the serial interface
+ * and operating system.
+ *
+ * For best accuracy, this radio requires the LDISC_ACTS line
+ * discipline, which captures a timestamp at the '*' on-time character
+ * of the timecode. Using this discipline the jitter is in the order of
+ * 1 ms and systematic error about 0.5 ms. If unavailable, the buffer
+ * timestamp is used, which is captured at the \r ending the timecode
+ * message. This introduces a systematic error of 23 character times, or
+ * about 24 ms at 9600 bps, together with a jitter well over 8 ms on Sun
+ * IPC-class machines.
+ *
+ * Using the memus, the radio should be set for 9600 bps, one stop bit
+ * and no parity. It should be set to operate in computer (no echo)
+ * mode. The timecode format includes neither the year nor leap-second
+ * warning. No provisions are included in this preliminary version of
+ * the driver to read and record detailed internal radio status.
+ *
+ * In operation, this driver sends a RQTS\r request to the radio at
+ * initialization in order to put it in continuous time output mode. The
+ * radio then sends the following message once each second:
+ *
+ *     *RQTS U,ddd:hh:mm:ss.0,q<cr><lf>
+ *
+ *     on-time = '*'\v *        ddd = day of year
+ *     hh:mm:ss = hours, minutes, seconds
+ *     q = quality indicator (phase error), 0-6:
+ *             0 > 20 us
+ *             6 > 10 us
+ *             5 > 1 us
+ *             4 > 100 ns
+ *             3 > 10 ns
+ *             2 < 10 ns
+ *
+ * The alarm condition is indicated by '0' at Q, which means the radio
+ * has a phase error than 20 usec relative to the broadcast time. The
+ * absence of year, DST and leap-second warning in this format is also
+ * alarming.
+ *
+ * The continuous time mode is disabled using the RQTX<cr> request,
+ * following which the radio sends a RQTX DONE<cr><lf> response. In the
+ * normal mode, other control and status requests are effective,
+ * including the leap-second status request RQLS<cr>. The radio responds
+ * wtih RQLS yy,mm,dd<cr><lf>, where yy,mm,dd are the year, month and
+ * day. Presumably, this gives the epoch of the next leap second,
+ * RQLS 00,00,00 if none is specified in the GPS message. Specified in
+ * this form, the information is generally useless and is ignored by
+ * the driver.
+ *
+ * Fudge Factors
+ *
+ * There are no special fudge factors other than the generic.
+ */
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/trak%d" /* device name and unit */
+#define        SPEED232        B9600   /* uart speed (9600 baud) */
+#define        PRECISION       (-20)   /* precision assumed (about 1 us) */
+#define        REFID           "GPS\0" /* reference ID */
+#define        DESCRIPTION     "TRACK 8810/8820 Station Clock" /* WRU */
+
+#define        LENTRAK         24      /* timecode length */
+#define C_CTO          "RQTS\r" /* start continuous time output */
+
+/*
+ * Unit control structure
+ */
+struct trakunit {
+       int     polled;         /* poll message flag */
+       l_fp    tstamp;         /* timestamp of last poll */
+};
+
+/*
+ * Function prototypes
+ */
+static int     trak_start      P((int, struct peer *));
+static void    trak_shutdown   P((int, struct peer *));
+static void    trak_receive    P((struct recvbuf *));
+static void    trak_poll       P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_trak = {
+       trak_start,             /* start up driver */
+       trak_shutdown,          /* shut down driver */
+       trak_poll,              /* transmit poll message */
+       noentry,                /* not used (old trak_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old trak_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * trak_start - open the devices and initialize data for processing
+ */
+static int
+trak_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct trakunit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+
+       /*
+        * Open serial port. The LDISC_ACTS line discipline inserts a
+        * timestamp following the "*" on-time character of the
+        * timecode.
+        */
+       (void)sprintf(device, DEVICE, unit);
+       if (
+#ifdef PPS
+               !(fd = refclock_open(device, SPEED232, LDISC_CLK))
+#else
+               !(fd = refclock_open(device, SPEED232, 0))
+#endif /* PPS */
+               )
+           return (0);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct trakunit *)
+             emalloc(sizeof(struct trakunit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct trakunit));
+       pp = peer->procptr;
+       pp->io.clock_recv = trak_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       up->polled = 0;
+
+       /*
+        * Start continuous time output. If something breaks, fold the
+        * tent and go home.
+        */
+       if (write(pp->io.fd, C_CTO, sizeof(C_CTO)) != sizeof(C_CTO)) {
+               refclock_report(peer, CEVNT_FAULT);
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       return (1);
+}
+
+
+/*
+ * trak_shutdown - shut down the clock
+ */
+static void
+trak_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct trakunit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct trakunit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * trak_receive - receive data from the serial interface
+ */
+static void
+trak_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct trakunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       l_fp trtmp;
+       char *dpt, *dpend;
+       char qchar;
+#ifdef PPS
+       struct ppsclockev ppsev;
+       int request;
+#ifdef HAVE_CIOGETEV
+        request = CIOGETEV;
+#endif
+#ifdef HAVE_TIOCGPPSEV
+        request = TIOCGPPSEV;
+#endif
+#endif /* PPS */
+
+       /*
+        * Initialize pointers and read the timecode and timestamp. We
+        * then chuck out everything, including runts, except one
+        * message each poll interval.
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct trakunit *)pp->unitptr;
+       pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode, BMAX,
+                                    &pp->lastrec);
+
+       /*
+        * We get a buffer and timestamp following the '*' on-time
+        * character. If a valid timestamp, we use that in place of the
+        * buffer timestamp and edit out the timestamp for prettyprint
+        * billboards.
+        */
+       dpt = pp->a_lastcode;
+       dpend = dpt + pp->lencode;
+       if (*dpt == '*' && buftvtots(dpt + 1, &trtmp)) {
+               if (trtmp.l_i == pp->lastrec.l_i || trtmp.l_i ==
+                   pp->lastrec.l_i + 1) {
+                       pp->lastrec = trtmp;
+                       dpt += 9;
+                       while (dpt < dpend) {
+                               *(dpt - 8) = *dpt;
+                               ++dpt;
+                       }
+               }
+       }
+       if (up->polled == 0) return;
+       up->polled = 0;
+#ifndef PPS
+       get_systime(&up->tstamp);
+#endif
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+       if (debug)
+           printf("trak: timecode %d %s\n", pp->lencode,
+                  pp->a_lastcode);
+#endif
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. If the timecode has invalid length or is not in
+        * proper format, we declare bad format and exit.
+        */
+       if (pp->lencode < LENTRAK) {
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       /*
+        * Timecode format: "*RQTS U,ddd:hh:mm:ss.0,q"
+        */
+       if (sscanf(pp->a_lastcode, "*RQTS U,%3d:%2d:%2d:%2d.0,%c",
+                  &pp->day, &pp->hour, &pp->minute, &pp->second, &qchar) != 5) {
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       /*
+        * Decode quality and leap characters. If unsynchronized, set
+        * the leap bits accordingly and exit.
+        */
+       if (qchar == '0') {
+               pp->leap = LEAP_NOTINSYNC;
+               return;
+       }
+#ifdef PPS
+       if(ioctl(fdpps,request,(caddr_t) &ppsev) >=0) {
+               ppsev.tv.tv_sec += (u_int32) JAN_1970;
+               TVTOTS(&ppsev.tv,&up->tstamp);
+       }
+#endif /* PPS */
+       /* record the last ppsclock event time stamp */
+       pp->lastrec = up->tstamp;
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+        }
+       pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+}
+
+
+/*
+ * trak_poll - called by the transmit procedure
+ */
+static void
+trak_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct trakunit *up;
+       struct refclockproc *pp;
+
+       /*
+        * We don't really do anything here, except arm the receiving
+        * side to capture a sample and check for timeouts.
+        */
+       pp = peer->procptr;
+       up = (struct trakunit *)pp->unitptr;
+       if (up->polled)
+           refclock_report(peer, CEVNT_TIMEOUT);
+       pp->polls++;
+       up->polled = 1;
+}
+
+#else
+int refclock_trak_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_true.c b/ntpd/refclock_true.c
new file mode 100644 (file)
index 0000000..dd355d9
--- /dev/null
@@ -0,0 +1,873 @@
+/*
+ * refclock_true - clock driver for the Kinemetrics Truetime receivers
+ *     Receiver Version 3.0C - tested plain, with CLKLDISC
+ *     Developement work being done:
+ *     - Properly handle varying satellite positions (more acurately)
+ *     - Integrate GPSTM and/or OMEGA and/or TRAK and/or ??? drivers
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_TRUETIME)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+/* This should be an atom clock but those are very hard to build.
+ *
+ * The PCL720 from P C Labs has an Intel 8253 lookalike, as well as a bunch
+ * of TTL input and output pins, all brought out to the back panel.  If you
+ * wire a PPS signal (such as the TTL PPS coming out of a GOES or other
+ * Kinemetrics/Truetime clock) to the 8253's GATE0, and then also wire the
+ * 8253's OUT0 to the PCL720's INPUT3.BIT0, then we can read CTR0 to get the
+ * number of uSecs since the last PPS upward swing, mediated by reading OUT0
+ * to find out if the counter has wrapped around (this happens if more than
+ * 65535us (65ms) elapses between the PPS event and our being called.)
+ */
+#ifdef CLOCK_PPS720
+# undef min    /* XXX */
+# undef max    /* XXX */
+# include <machine/inline.h>
+# include <sys/pcl720.h>
+# include <sys/i8253.h>
+# define PCL720_IOB 0x2a0      /* XXX */
+# define PCL720_CTR 0          /* XXX */
+#endif
+
+/*
+ * Support for Kinemetrics Truetime Receivers
+ *     GOES
+ *     GPS/TM-TMD
+ *     XL-DC           (a 151-602-210, reported by the driver as a GPS/TM-TMD)
+ *     GPS-800 TCU     (an 805-957 with the RS232 Talker/Listener module)
+ *     OM-DC:          getting stale ("OMEGA")
+ *
+ * Most of this code is originally from refclock_wwvb.c with thanks.
+ * It has been so mangled that wwvb is not a recognizable ancestor.
+ *
+ * Timcode format: ADDD:HH:MM:SSQCL
+ *     A - control A           (this is stripped before we see it)
+ *     Q - Quality indication  (see below)
+ *     C - Carriage return
+ *     L - Line feed
+ *
+ * Quality codes indicate possible error of
+ *   468-DC GOES Receiver:
+ *   GPS-TM/TMD Receiver: (default quality codes for XL-DC)
+ *       ?     +/- 1  milliseconds     #     +/- 100 microseconds
+ *       *     +/- 10 microseconds     .     +/- 1   microsecond
+ *     space   less than 1 microsecond
+ *   OM-DC OMEGA Receiver: (default quality codes for OMEGA)
+ *   WARNING OMEGA navigation system is no longer existent
+ *       >     >+- 5 seconds
+ *       ?     >+/- 500 milliseconds    #     >+/- 50 milliseconds
+ *       *     >+/- 5 milliseconds      .     >+/- 1 millisecond
+ *      A-H    less than 1 millisecond.  Character indicates which station
+ *             is being received as follows:
+ *             A = Norway, B = Liberia, C = Hawaii, D = North Dakota,
+ *             E = La Reunion, F = Argentina, G = Australia, H = Japan.
+ *
+ * The carriage return start bit begins on 0 seconds and extends to 1 bit time.
+ *
+ * Notes on 468-DC and OMEGA receiver:
+ *
+ * Send the clock a 'R' or 'C' and once per second a timestamp will
+ * appear.  Send a 'P' to get the satellite position once (GOES only.)
+ *
+ * Notes on the 468-DC receiver:
+ *
+ * Since the old east/west satellite locations are only historical, you can't
+ * set your clock propagation delay settings correctly and still use
+ * automatic mode. The manual says to use a compromise when setting the
+ * switches. This results in significant errors. The solution; use fudge
+ * time1 and time2 to incorporate corrections. If your clock is set for
+ * 50 and it should be 58 for using the west and 46 for using the east,
+ * use the line
+ *
+ * fudge 127.127.5.0 time1 +0.008 time2 -0.004
+ *
+ * This corrects the 4 milliseconds advance and 8 milliseconds retard
+ * needed. The software will ask the clock which satellite it sees.
+ *
+ * Ntp.conf parameters:
+ * time1 - offset applied to samples when reading WEST satellite (default = 0)
+ * time2 - offset applied to samples when reading EAST satellite (default = 0)
+ * val1  - stratum to assign to this clock (default = 0)
+ * val2  - refid assigned to this clock (default = "TRUE", see below)
+ * flag1 - will silence the clock side of ntpd, just reading the clock
+ *         without trying to write to it.  (default = 0)
+ * flag2 - generate a debug file /tmp/true%d.
+ * flag3 - enable ppsclock streams module
+ * flag4 - use the PCL-720 (BSD/OS only)
+ */
+
+
+/*
+ * Definitions
+ */
+#define        DEVICE          "/dev/true%d"
+#define        SPEED232        B9600   /* 9600 baud */
+
+/*
+ * Radio interface parameters
+ */
+#define        PRECISION       (-10)   /* precision assumed (about 1 ms) */
+#define        REFID           "TRUE"  /* reference id */
+#define        DESCRIPTION     "Kinemetrics/TrueTime Receiver"
+
+/*
+ * Tags which station (satellite) we see
+ */
+#define GOES_WEST      0       /* Default to WEST satellite and apply time1 */
+#define GOES_EAST      1       /* until you discover otherwise */
+
+/*
+ * used by the state machine
+ */
+enum true_event        {e_Init, e_Huh, e_F18, e_F50, e_F51, e_Satellite,
+                e_Poll, e_Location, e_TS, e_Max};
+const char *events[] = {"Init", "Huh", "F18", "F50", "F51", "Satellite",
+                       "Poll", "Location", "TS"};
+#define eventStr(x) (((int)x<(int)e_Max) ? events[(int)x] : "?")
+
+enum true_state        {s_Base, s_InqTM, s_InqTCU, s_InqOmega, s_InqGOES,
+                s_Init, s_F18, s_F50, s_Start, s_Auto, s_Max};
+const char *states[] = {"Base", "InqTM", "InqTCU", "InqOmega", "InqGOES",
+                       "Init", "F18", "F50", "Start", "Auto"};
+#define stateStr(x) (((int)x<(int)s_Max) ? states[(int)x] : "?")
+
+enum true_type {t_unknown, t_goes, t_tm, t_tcu, t_omega, t_Max};
+const char *types[] = {"unknown", "goes", "tm", "tcu", "omega"};
+#define typeStr(x) (((int)x<(int)t_Max) ? types[(int)x] : "?")
+
+/*
+ * unit control structure
+ */
+struct true_unit {
+       unsigned int    pollcnt;        /* poll message counter */
+       unsigned int    station;        /* which station we are on */
+       unsigned int    polled;         /* Hand in a time sample? */
+       enum true_state state;          /* state machine */
+       enum true_type  type;           /* what kind of clock is it? */
+       int             unit;           /* save an extra copy of this */
+       FILE            *debug;         /* debug logging file */
+#ifdef CLOCK_PPS720
+       int             pcl720init;     /* init flag for PCL 720 */
+#endif
+};
+
+/*
+ * Function prototypes
+ */
+static int     true_start      P((int, struct peer *));
+static void    true_shutdown   P((int, struct peer *));
+static void    true_receive    P((struct recvbuf *));
+static void    true_poll       P((int, struct peer *));
+static void    true_send       P((struct peer *, const char *));
+static void    true_doevent    P((struct peer *, enum true_event));
+
+#ifdef CLOCK_PPS720
+static u_long  true_sample720  P((void));
+#endif
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_true = {
+       true_start,             /* start up driver */
+       true_shutdown,          /* shut down driver */
+       true_poll,              /* transmit poll message */
+       noentry,                /* not used (old true_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old true_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+#if !defined(__STDC__)
+# define true_debug (void)
+#else
+static void
+true_debug(struct peer *peer, const char *fmt, ...)
+{
+       va_list ap;
+       int want_debugging, now_debugging;
+       struct refclockproc *pp;
+       struct true_unit *up;
+
+       va_start(ap, fmt);
+       pp = peer->procptr;
+       up = (struct true_unit *)pp->unitptr;
+
+       want_debugging = (pp->sloppyclockflag & CLK_FLAG2) != 0;
+       now_debugging = (up->debug != NULL);
+       if (want_debugging != now_debugging)
+       {
+               if (want_debugging) {
+                   char filename[40];
+                   int fd;
+
+                   snprintf(filename, sizeof(filename), "/tmp/true%d.debug", up->unit);
+                   fd = open(filename, O_CREAT | O_WRONLY | O_EXCL, 0600);
+                   if (fd >= 0 && (up->debug = fdopen(fd, "r+"))) {
+#ifdef HAVE_SETVBUF
+                           static char buf[BUFSIZ];
+                           setvbuf(up->debug, buf, _IOLBF, BUFSIZ);
+#else
+                           setlinebuf(up->debug);
+#endif
+                   }
+           } else {
+                   fclose(up->debug);
+                   up->debug = NULL;
+           }
+       }
+
+       if (up->debug) {
+               fprintf(up->debug, "true%d: ", up->unit);
+               vfprintf(up->debug, fmt, ap);
+       }
+}
+#endif /*STDC*/
+
+/*
+ * true_start - open the devices and initialize data for processing
+ */
+static int
+true_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct true_unit *up;
+       struct refclockproc *pp;
+       char device[40];
+       int fd;
+
+       /*
+        * Open serial port
+        */
+       (void)snprintf(device, sizeof(device), DEVICE, unit);
+       if (!(fd = refclock_open(device, SPEED232, LDISC_CLK)))
+           return (0);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct true_unit *)
+             emalloc(sizeof(struct true_unit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct true_unit));
+       pp = peer->procptr;
+       pp->io.clock_recv = true_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       up->pollcnt = 2;
+       up->type = t_unknown;
+       up->state = s_Base;
+       true_doevent(peer, e_Init);
+       return (1);
+}
+
+/*
+ * true_shutdown - shut down the clock
+ */
+static void
+true_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct true_unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct true_unit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * true_receive - receive data from the serial interface on a clock
+ */
+static void
+true_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct true_unit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       u_short new_station;
+       char synced;
+       int i;
+       int lat, lon, off;      /* GOES Satellite position */
+        /* Use these variable to hold data until we decide its worth keeping */
+        char    rd_lastcode[BMAX];
+        l_fp    rd_tmp;
+        u_short rd_lencode;
+
+       /*
+        * Get the clock this applies to and pointers to the data.
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct true_unit *)pp->unitptr;
+
+       /*
+        * Read clock output.  Automatically handles STREAMS, CLKLDISC.
+        */
+        rd_lencode = refclock_gtlin(rbufp, rd_lastcode, BMAX, &rd_tmp);
+        rd_lastcode[rd_lencode] = '\0';
+
+       /*
+        * There is a case where <cr><lf> generates 2 timestamps.
+        */
+        if (rd_lencode == 0)
+            return;
+        pp->lencode = rd_lencode;
+        strcpy(pp->a_lastcode, rd_lastcode);
+        pp->lastrec = rd_tmp;
+       true_debug(peer, "receive(%s) [%d]\n", pp->a_lastcode, pp->lencode);
+
+       up->pollcnt = 2;
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. This code decodes a multitude of different
+        * clock messages. Timecodes are processed if needed. All replies
+        * will be run through the state machine to tweak driver options
+        * and program the clock.
+        */
+
+       /*
+        * Clock misunderstood our last command?
+        */
+       if (pp->a_lastcode[0] == '?' ||
+           strcmp(pp->a_lastcode, "ERROR 05 NO SUCH FUNCTION") == 0) {
+               true_doevent(peer, e_Huh);
+               return;
+       }
+
+       /*
+        * Timecode: "nnnnn+nnn-nnn"
+        * (from GOES clock when asked about satellite position)
+        */
+       if ((pp->a_lastcode[5] == '+' || pp->a_lastcode[5] == '-') &&
+           (pp->a_lastcode[9] == '+' || pp->a_lastcode[9] == '-') &&
+           sscanf(pp->a_lastcode, "%5d%*c%3d%*c%3d", &lon, &lat, &off) == 3
+           ) {
+               const char *label = "Botch!";
+
+               /*
+                * This is less than perfect.  Call the (satellite)
+                * either EAST or WEST and adjust slop accodingly
+                * Perfectionists would recalculate the exact delay
+                * and adjust accordingly...
+                */
+               if (lon > 7000 && lon < 14000) {
+                       if (lon < 10000) {
+                               new_station = GOES_EAST;
+                               label = "EAST";
+                       } else {
+                               new_station = GOES_WEST;
+                               label = "WEST";
+                       }
+                               
+                       if (new_station != up->station) {
+                               double dtemp;
+
+                               dtemp = pp->fudgetime1;
+                               pp->fudgetime1 = pp->fudgetime2;
+                               pp->fudgetime2 = dtemp;
+                               up->station = new_station;
+                       }
+               }
+               else {
+                       /*refclock_report(peer, CEVNT_BADREPLY);*/
+                       label = "UNKNOWN";
+               }
+               true_debug(peer, "GOES: station %s\n", label);
+               true_doevent(peer, e_Satellite);
+               return;
+       }
+
+       /*
+        * Timecode: "Fnn"
+        * (from TM/TMD clock when it wants to tell us what it's up to.)
+        */
+       if (sscanf(pp->a_lastcode, "F%2d", &i) == 1 && i > 0 && i < 80) {
+               switch (i) {
+                   case 50:
+                       true_doevent(peer, e_F50);
+                       break;
+                   case 51:
+                       true_doevent(peer, e_F51);
+                       break;
+                   default:
+                       true_debug(peer, "got F%02d - ignoring\n", i);
+                       break;
+               }
+               return;
+       }
+
+       /*
+        * Timecode: " TRUETIME Mk III" or " TRUETIME XL"
+        * (from a TM/TMD/XL clock during initialization.)
+        */
+       if (strcmp(pp->a_lastcode, " TRUETIME Mk III") == 0 ||
+           strncmp(pp->a_lastcode, " TRUETIME XL", 12) == 0) {
+               true_doevent(peer, e_F18);
+               NLOG(NLOG_CLOCKSTATUS) {
+                       msyslog(LOG_INFO, "TM/TMD/XL: %s", pp->a_lastcode);
+               }
+               return;
+       }
+
+       /*
+        * Timecode: "N03726428W12209421+000033"
+        *                      1         2
+        *            0123456789012345678901234
+        * (from a TCU during initialization)
+        */
+       if ((pp->a_lastcode[0] == 'N' || pp->a_lastcode[0] == 'S') &&
+           (pp->a_lastcode[9] == 'W' || pp->a_lastcode[9] == 'E') &&
+           pp->a_lastcode[18] == '+') {
+               true_doevent(peer, e_Location);
+               NLOG(NLOG_CLOCKSTATUS) {
+                       msyslog(LOG_INFO, "TCU-800: %s", pp->a_lastcode);
+               }
+               return;
+       }
+       /*
+        * Timecode: "ddd:hh:mm:ssQ"
+        * (from all clocks supported by this driver.)
+        */
+       if (pp->a_lastcode[3] == ':' &&
+           pp->a_lastcode[6] == ':' &&
+           pp->a_lastcode[9] == ':' &&
+           sscanf(pp->a_lastcode, "%3d:%2d:%2d:%2d%c",
+                  &pp->day, &pp->hour, &pp->minute,
+                  &pp->second, &synced) == 5) {
+
+               /*
+                * Adjust the synchronize indicator according to timecode
+                * say were OK, and then say not if we really are not OK
+                */
+               if (synced == '>' || synced == '#' || synced == '?')
+                   pp->leap = LEAP_NOTINSYNC;
+               else
+                    pp->leap = LEAP_NOWARNING;
+
+               true_doevent(peer, e_TS);
+
+#ifdef CLOCK_PPS720
+               /* If it's taken more than 65ms to get here, we'll lose. */
+               if ((pp->sloppyclockflag & CLK_FLAG4) && up->pcl720init) {
+                       l_fp   off;
+
+#ifdef CLOCK_ATOM
+                       /*
+                        * find out what time it really is. Include
+                        * the count from the PCL720
+                        */
+                       if (!clocktime(pp->day, pp->hour, pp->minute, 
+                                      pp->second, GMT, pp->lastrec.l_ui, 
+                                      &pp->yearstart, &off.l_ui)) {
+                               refclock_report(peer, CEVNT_BADTIME);
+                               return;
+                       }
+                       off.l_uf = 0;
+#endif
+
+                       pp->usec = true_sample720();
+#ifdef CLOCK_ATOM
+                       TVUTOTSF(pp->usec, off.l_uf);
+#endif
+
+                       /*
+                        * Stomp all over the timestamp that was pulled out
+                        * of the input stream. It's irrelevant since we've
+                        * adjusted the input time to reflect now (via pp->usec)
+                        * rather than when the data was collected.
+                        */
+                       get_systime(&pp->lastrec);
+#ifdef CLOCK_ATOM
+                       /*
+                        * Create a true offset for feeding to pps_sample()
+                        */
+                       L_SUB(&off, &pp->lastrec);
+
+                       pps_sample(peer, &off);
+#endif
+                       true_debug(peer, "true_sample720: %luus\n", pp->usec);
+               }
+#endif
+
+               /*
+                * The clock will blurt a timecode every second but we only
+                * want one when polled.  If we havn't been polled, bail out.
+                */
+               if (!up->polled)
+                   return;
+
+               true_doevent(peer, e_Poll);
+               if (!refclock_process(pp)) {
+                       refclock_report(peer, CEVNT_BADTIME);
+                       return;
+               }
+               /*
+                * If clock is good we send a NOMINAL message so that
+                * any previous BAD messages are nullified
+                */
+                pp->lastref = pp->lastrec;
+               refclock_receive(peer);
+               refclock_report(peer, CEVNT_NOMINAL);
+
+               /*
+                * We have succedded in answering the poll.
+                * Turn off the flag and return
+                */
+               up->polled = 0;
+
+               return;
+       }
+
+       /*
+        * No match to known timecodes, report failure and return
+        */
+       refclock_report(peer, CEVNT_BADREPLY);
+       return;
+}
+
+
+/*
+ * true_send - time to send the clock a signal to cough up a time sample
+ */
+static void
+true_send(
+       struct peer *peer,
+       const char *cmd
+       )
+{
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       if (!(pp->sloppyclockflag & CLK_FLAG1)) {
+               register int len = strlen(cmd);
+
+               true_debug(peer, "Send '%s'\n", cmd);
+               if (write(pp->io.fd, cmd, (unsigned)len) != len)
+                   refclock_report(peer, CEVNT_FAULT);
+               else
+                   pp->polls++;
+       }
+}
+
+
+/*
+ * state machine for initializing and controlling a clock
+ */
+static void
+true_doevent(
+       struct peer *peer,
+       enum true_event event
+       )
+{
+       struct true_unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct true_unit *)pp->unitptr;
+       if (event != e_TS) {
+               NLOG(NLOG_CLOCKSTATUS) {
+                       msyslog(LOG_INFO, "TRUE: clock %s, state %s, event %s",
+                               typeStr(up->type),
+                               stateStr(up->state),
+                               eventStr(event));
+               }
+       }
+       true_debug(peer, "clock %s, state %s, event %s\n",
+                  typeStr(up->type), stateStr(up->state), eventStr(event));
+       switch (up->type) {
+           case t_goes:
+               switch (event) {
+                   case e_Init:        /* FALLTHROUGH */
+                   case e_Satellite:
+                       /*
+                        * Switch back to on-second time codes and return.
+                        */
+                       true_send(peer, "C");
+                       up->state = s_Start;
+                       break;
+                   case e_Poll:
+                       /*
+                        * After each poll, check the station (satellite).
+                        */
+                       true_send(peer, "P");
+                       /* No state change needed. */
+                       break;
+                   default:
+                       break;
+               }
+               /* FALLTHROUGH */
+           case t_omega:
+               switch (event) {
+                   case e_Init:
+                       true_send(peer, "C");
+                       up->state = s_Start;
+                       break;
+                   case e_TS:
+                       if (up->state != s_Start && up->state != s_Auto) {
+                               true_send(peer, "\03\r");
+                               break;
+                       }
+                       up->state = s_Auto;
+                       break;
+                   default:
+                       break;
+               }
+               break;
+           case t_tm:
+               switch (event) {
+                   case e_Init:
+                       true_send(peer, "F18\r");
+                       up->state = s_Init;
+                       break;
+                   case e_F18:
+                       true_send(peer, "F50\r");
+                       up->state = s_F18;
+                       break;
+                   case e_F50:
+                       true_send(peer, "F51\r");
+                       up->state = s_F50;
+                       break;
+                   case e_F51:
+                       true_send(peer, "F08\r");
+                       up->state = s_Start;
+                       break;
+                   case e_TS:
+                       if (up->state != s_Start && up->state != s_Auto) {
+                               true_send(peer, "\03\r");
+                               break;
+                       }
+                       up->state = s_Auto;
+                       break;
+                   default:
+                       break;
+               }
+               break;
+           case t_tcu:
+               switch (event) {
+                   case e_Init:
+                       true_send(peer, "MD3\r");       /* GPS Synch'd Gen. */
+                       true_send(peer, "TSU\r");       /* UTC, not GPS. */
+                       true_send(peer, "AU\r");        /* Auto Timestamps. */
+                       up->state = s_Start;
+                       break;
+                   case e_TS:
+                       if (up->state != s_Start && up->state != s_Auto) {
+                               true_send(peer, "\03\r");
+                               break;
+                       }
+                       up->state = s_Auto;
+                       break;
+                   default:
+                       break;
+               }
+               break;
+           case t_unknown:
+               switch (up->state) {
+                   case s_Base:
+                       if (event != e_Init)
+                           abort();
+                       true_send(peer, "P\r");
+                       up->state = s_InqGOES;
+                       break;
+                   case s_InqGOES:
+                       switch (event) {
+                           case e_Satellite:
+                               up->type = t_goes;
+                               true_doevent(peer, e_Init);
+                               break;
+                           case e_Init:        /*FALLTHROUGH*/
+                           case e_Huh: /*FALLTHROUGH*/
+                           case e_TS:
+                               up->state = s_InqOmega;
+                               true_send(peer, "C\r");
+                               break;
+                           default:
+                               abort();
+                       }
+                       break;
+                   case s_InqOmega:
+                       switch (event) {
+                           case e_TS:
+                               up->type = t_omega;
+                               up->state = s_Auto;     /* Inq side-effect. */
+                               break;
+                           case e_Init:        /*FALLTHROUGH*/
+                           case e_Huh:
+                               up->state = s_InqTM;
+                               true_send(peer, "F18\r");
+                               break;
+                           default:
+                               abort();
+                       }
+                       break;
+                   case s_InqTM:
+                       switch (event) {
+                           case e_F18:
+                               up->type = t_tm;
+                               true_doevent(peer, e_Init);
+                               break;
+                           case e_Init:        /*FALLTHROUGH*/
+                           case e_Huh:
+                               true_send(peer, "PO\r");
+                               up->state = s_InqTCU;
+                               break;
+                           default:
+                               abort();
+                       }
+                       break;
+                   case s_InqTCU:
+                       switch (event) {
+                           case e_Location:
+                               up->type = t_tcu;
+                               true_doevent(peer, e_Init);
+                               break;
+                           case e_Init:        /*FALLTHROUGH*/
+                           case e_Huh:
+                               up->state = s_Base;
+                               sleep(1);       /* XXX */
+                               break;
+                           default:
+                               abort();
+                       }
+                       break;
+                       /*
+                        * An expedient hack to prevent lint complaints,
+                        * these don't actually need to be used here...
+                        */
+                   case s_Init:
+                   case s_F18:
+                   case s_F50:
+                   case s_Start:
+                   case s_Auto:
+                   case s_Max:
+                       msyslog(LOG_INFO, "TRUE: state %s is unexpected!", stateStr(up->state));
+               }
+               break;
+           default:
+               abort();
+               /* NOTREACHED */
+       }
+
+#ifdef CLOCK_PPS720
+       if ((pp->sloppyclockflag & CLK_FLAG4) && !up->pcl720init) {
+               /* Make counter trigger on gate0, count down from 65535. */
+               pcl720_load(PCL720_IOB, PCL720_CTR, i8253_oneshot, 65535);
+               /*
+                * (These constants are OK since
+                * they represent hardware maximums.)
+                */
+               NLOG(NLOG_CLOCKINFO) {
+                       msyslog(LOG_NOTICE, "PCL-720 initialized");
+               }
+               up->pcl720init++;
+       }
+#endif
+
+
+}
+
+/*
+ * true_poll - called by the transmit procedure
+ */
+static void
+true_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       struct true_unit *up;
+       struct refclockproc *pp;
+
+       /*
+        * You don't need to poll this clock.  It puts out timecodes
+        * once per second.  If asked for a timestamp, take note.
+        * The next time a timecode comes in, it will be fed back.
+        */
+       pp = peer->procptr;
+       up = (struct true_unit *)pp->unitptr;
+       if (up->pollcnt > 0)
+           up->pollcnt--;
+       else {
+               true_doevent(peer, e_Init);
+               refclock_report(peer, CEVNT_TIMEOUT);
+       }
+
+       /*
+        * polled every 64 seconds. Ask true_receive to hand in a
+        * timestamp.
+        */
+       up->polled = 1;
+       pp->polls++;
+}
+
+#ifdef CLOCK_PPS720
+/*
+ * true_sample720 - sample the PCL-720
+ */
+static u_long
+true_sample720(void)
+{
+       unsigned long f;
+
+       /* We wire the PCL-720's 8253.OUT0 to bit 0 of connector 3.
+        * If it is not being held low now, we did not get called
+        * within 65535us.
+        */
+       if (inb(pcl720_data_16_23(PCL720_IOB)) & 0x01) {
+               NLOG(NLOG_CLOCKINFO) {
+                       msyslog(LOG_NOTICE, "PCL-720 out of synch");
+               }
+               return (0);
+       }
+       f = (65536 - pcl720_read(PCL720_IOB, PCL720_CTR));
+#ifdef PPS720_DEBUG
+       msyslog(LOG_DEBUG, "PCL-720: %luus", f);
+#endif
+       return (f);
+}
+#endif
+
+#else
+int refclock_true_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_tt560.c b/ntpd/refclock_tt560.c
new file mode 100644 (file)
index 0000000..f3d7bc1
--- /dev/null
@@ -0,0 +1,274 @@
+/*
+ * refclock_tt560 - clock driver for the TrueTime 560 IRIG-B decoder
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_TT560)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "sys/tt560_api.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+/*
+ * This driver supports the TrueTime 560 IRIG-B decoder for the PCI bus.
+ */ 
+
+/*
+ * TT560 interface definitions
+ */
+#define        DEVICE           "/dev/tt560%d" /* device name and unit */
+#define        PRECISION       (-20)   /* precision assumed (1 us) */
+#define        REFID           "IRIG"  /* reference ID */
+#define        DESCRIPTION     "TrueTime 560 IRIG-B PCI Decoder"
+
+/*
+ * Unit control structure
+ */
+struct tt560unit {
+       tt_mem_space_t   *tt_mem;       /* mapped address of PCI board */
+       time_freeze_reg_t tt560rawt;    /* data returned from PCI board */
+};
+
+typedef union byteswap_u
+{
+    unsigned int long_word;
+    unsigned char byte[4];
+} byteswap_t;
+
+/*
+ * Function prototypes
+ */
+static int     tt560_start     P((int, struct peer *));
+static void    tt560_shutdown  P((int, struct peer *));
+static void    tt560_poll      P((int unit, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_tt560 = {
+       tt560_start,            /* clock_start    */
+       tt560_shutdown,         /* clock_shutdown */
+       tt560_poll,             /* clock_poll     */
+       noentry,                /* clock_control (not used) */
+       noentry,                /* clock_init    (not used) */
+       noentry,                /* clock_buginfo (not used) */
+       NOFLAGS                 /* clock_flags   (not used) */
+};
+
+
+/*
+ * tt560_start - open the TT560 device and initialize data for processing
+ */
+static int
+tt560_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct tt560unit *up;
+       struct refclockproc *pp;
+       char device[20];
+       int     fd;
+        caddr_t membase;
+
+       /*
+        * Open TT560 device
+        */
+       (void)sprintf(device, DEVICE, unit);
+       fd = open(device, O_RDWR);
+       if (fd == -1) {
+               msyslog(LOG_ERR, "tt560_start: open of %s: %m", device);
+               return (0);
+       }
+
+       /*
+        * Map the device registers into user space.
+        */
+       membase = mmap ((caddr_t) 0, TTIME_MEMORY_SIZE,
+                       PROT_READ | PROT_WRITE,
+                       MAP_SHARED, fd, (off_t)0);
+
+       if (membase == (caddr_t) -1) {
+               msyslog(LOG_ERR, "tt560_start: mapping of %s: %m", device);
+               (void) close(fd);
+               return (0);
+       }
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct tt560unit *) emalloc(sizeof(struct tt560unit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct tt560unit));
+       up->tt_mem = (tt_mem_space_t *)membase;
+       pp = peer->procptr;
+       pp->io.clock_recv = noentry;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous peer variables
+        */
+       peer->precision = PRECISION;
+       peer->burst = NSTAGE;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       return (1);
+}
+
+
+/*
+ * tt560_shutdown - shut down the clock
+ */
+static void
+tt560_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct tt560unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct tt560unit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * tt560_poll - called by the transmit procedure
+ */
+static void
+tt560_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct tt560unit *up;
+       struct refclockproc       *pp;
+       time_freeze_reg_t         *tp;
+       tt_mem_space_t            *mp;
+
+       int i;
+       unsigned int *p_time_t, *tt_mem_t;
+
+       /*
+        * This is the main routine. It snatches the time from the TT560
+        * board and tacks on a local timestamp.
+        */
+       pp = peer->procptr;
+       up = (struct tt560unit *)pp->unitptr;
+       mp = up->tt_mem;
+       tp = &up->tt560rawt;
+
+       p_time_t = (unsigned int *)tp;
+       tt_mem_t = (unsigned int *)&mp->time_freeze_reg;
+
+       *tt_mem_t = 0;          /* update the time freeze register */
+                               /* and copy time stamp to memory */
+       for (i=0; i < TIME_FREEZE_REG_LEN; i++) {
+           *p_time_t = byte_swap(*tt_mem_t);
+            p_time_t++;
+            tt_mem_t++;
+       }
+
+       get_systime(&pp->lastrec);
+       pp->polls++;
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. If the timecode has invalid length or is not in
+        * proper format, we declare bad format and exit. Note: we
+        * can't use the sec/usec conversion produced by the driver,
+        * since the year may be suspect. All format error checking is
+        * done by the sprintf() and sscanf() routines.
+        */
+       sprintf(pp->a_lastcode,
+           "%1x%1x%1x %1x%1x:%1x%1x:%1x%1x.%1x%1x%1x%1x%1x%1x %1x",
+           tp->hun_day,  tp->tens_day,  tp->unit_day,
+                         tp->tens_hour, tp->unit_hour,
+                         tp->tens_min,  tp->unit_min,
+                         tp->tens_sec,  tp->unit_sec,
+           tp->hun_ms,   tp->tens_ms,   tp->unit_ms,
+           tp->hun_us,   tp->tens_us,   tp->unit_us,
+           tp->status);
+           pp->lencode = strlen(pp->a_lastcode);
+#ifdef DEBUG
+       if (debug)
+               printf("tt560: time %s timecode %d %s\n",
+                  ulfptoa(&pp->lastrec, 6), pp->lencode,
+                  pp->a_lastcode);
+#endif
+       if (sscanf(pp->a_lastcode, "%3d %2d:%2d:%2d.%6ld", 
+                  &pp->day, &pp->hour, &pp->minute, &pp->second, &pp->usec)
+           != 5) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       if ((tp->status & 0x6) != 0x6)
+               pp->leap = LEAP_NOTINSYNC;
+       else
+               pp->leap = LEAP_NOWARNING;
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+       if (peer->burst > 0)
+               return;
+       if (pp->coderecv == pp->codeproc) {
+               refclock_report(peer, CEVNT_TIMEOUT);
+               return;
+       }
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+       refclock_receive(peer);
+       peer->burst = NSTAGE;
+}
+
+/******************************************************************
+ *
+ *  byte_swap
+ *
+ *  Inputs: 32 bit integer
+ *
+ *  Output: byte swapped 32 bit integer.
+ *
+ *  This routine is used to compensate for the byte alignment
+ *  differences between big-endian and little-endian integers.
+ *
+ ******************************************************************/
+static unsigned int
+byte_swap(unsigned int input_num)
+{
+    byteswap_t    byte_swap;
+    unsigned char temp;
+
+    byte_swap.long_word = input_num;
+
+    temp              = byte_swap.byte[3];
+    byte_swap.byte[3] = byte_swap.byte[0];
+    byte_swap.byte[0] = temp;
+
+    temp              = byte_swap.byte[2];
+    byte_swap.byte[2] = byte_swap.byte[1];
+    byte_swap.byte[1] = temp;
+
+    return (byte_swap.long_word);
+}
+
+#else
+int refclock_tt560_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_ulink.c b/ntpd/refclock_ulink.c
new file mode 100644 (file)
index 0000000..d7a62fe
--- /dev/null
@@ -0,0 +1,589 @@
+/*
+ * refclock_ulink - clock driver for Ultralink  WWVB receiver
+ */
+
+/***********************************************************************
+ *                                                                     *
+ * Copyright (c) David L. Mills 1992-1998                              *
+ *                                                                     *
+ * Permission to use, copy, modify, and distribute this software and   *
+ * its documentation for any purpose and without fee is hereby         *
+ * granted, provided that the above copyright notice appears in all    *
+ * copies and that both the copyright notice and this permission       *
+ * notice appear in supporting documentation, and that the name        *
+ * University of Delaware not be used in advertising or publicity      *
+ * pertaining to distribution of the software without specific,        *
+ * written prior permission. The University of Delaware makes no       *
+ * representations about the suitability this software for any         *
+ * purpose. It is provided "as is" without express or implied          *
+ * warranty.                                                           *
+ **********************************************************************/
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_ULINK)
+
+#include <stdio.h>
+#include <ctype.h>
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+/* This driver supports ultralink Model 320,325,330,331,332 WWVB radios
+ *
+ * this driver was based on the refclock_wwvb.c driver
+ * in the ntp distribution.
+ *
+ * Fudge Factors
+ *
+ * fudge flag1 0 don't poll clock
+ *             1 send poll character
+ *
+ * revision history:
+ *             99/9/09 j.c.lang        original edit's
+ *             99/9/11 j.c.lang        changed timecode parse to 
+ *                                      match what the radio actually
+ *                                      sends. 
+ *              99/10/11 j.c.lang       added support for continous
+ *                                      time code mode (dipsw2)
+ *             99/11/26 j.c.lang       added support for 320 decoder
+ *                                      (taken from Dave Strout's
+ *                                      Model 320 driver)
+ *             99/11/29 j.c.lang       added fudge flag 1 to control
+ *                                     clock polling
+ *             99/12/15 j.c.lang       fixed 320 quality flag
+ *             01/02/21 s.l.smith      fixed 33x quality flag
+ *                                     added more debugging stuff
+ *                                     updated 33x time code explanation
+ *             04/01/23 frank migge    added support for 325 decoder
+ *                                      (tested with ULM325.F)
+ *
+ * Questions, bugs, ideas send to:
+ *     Joseph C. Lang
+ *     tcnojl1@earthlink.net
+ *
+ *     Dave Strout
+ *     dstrout@linuxfoundry.com
+ *
+ *      Frank Migge
+ *      frank.migge@oracle.com
+ *
+ *
+ * on the Ultralink model 33X decoder Dip switch 2 controls
+ * polled or continous timecode 
+ * set fudge flag1 if using polled (needed for model 320 and 325)
+ * dont set fudge flag1 if dip switch 2 is set on model 33x decoder
+*/
+
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/wwvb%d" /* device name and unit */
+#define        SPEED232        B9600   /* uart speed (9600 baud) */
+#define        PRECISION       (-10)   /* precision assumed (about 10 ms) */
+#define        REFID           "WWVB"  /* reference ID */
+#define        DESCRIPTION     "Ultralink WWVB Receiver" /* WRU */
+
+#define        LEN33X          32      /* timecode length Model 33X and 325 */
+#define LEN320         24      /* timecode length Model 320 */
+
+#define        SIGLCHAR33x     'S'     /* signal strength identifier char 325 */
+#define        SIGLCHAR325     'R'     /* signal strength identifier char 33x */
+
+/*
+ *  unit control structure
+ */
+struct ulinkunit {
+       u_char  tcswitch;       /* timecode switch */
+       l_fp    laststamp;      /* last receive timestamp */
+};
+
+/*
+ * Function prototypes
+ */
+static int     ulink_start     P((int, struct peer *));
+static void    ulink_shutdown  P((int, struct peer *));
+static void    ulink_receive   P((struct recvbuf *));
+static void    ulink_poll      P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_ulink = {
+       ulink_start,            /* start up driver */
+       ulink_shutdown,         /* shut down driver */
+       ulink_poll,             /* transmit poll message */
+       noentry,                /* not used  */
+       noentry,                /* not used  */
+       noentry,                /* not used  */
+       NOFLAGS
+};
+
+
+/*
+ * ulink_start - open the devices and initialize data for processing
+ */
+static int
+ulink_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct ulinkunit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+
+       /*
+        * Open serial port. Use CLK line discipline, if available.
+        */
+       (void)sprintf(device, DEVICE, unit);
+       if (!(fd = refclock_open(device, SPEED232, LDISC_CLK)))
+               return (0);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct ulinkunit *)
+             emalloc(sizeof(struct ulinkunit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct ulinkunit));
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t)up;
+       pp->io.clock_recv = ulink_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       peer->burst = NSTAGE;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       return (1);
+}
+
+
+/*
+ * ulink_shutdown - shut down the clock
+ */
+static void
+ulink_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct ulinkunit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct ulinkunit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * ulink_receive - receive data from the serial interface
+ */
+static void
+ulink_receive(
+       struct recvbuf *rbufp
+       )
+{
+       struct ulinkunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+
+       l_fp    trtmp;          /* arrival timestamp */
+       int     quality;        /* quality indicator */
+       int     temp;           /* int temp */
+       char    syncchar;       /* synchronization indicator */
+       char    leapchar;       /* leap indicator */
+       char    modechar;       /* model 320 mode flag */
+        char   siglchar;       /* model difference between 33x/325 */
+       char    char_quality[2];        /* temp quality flag */
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct ulinkunit *)pp->unitptr;
+       temp = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp);
+
+       /*
+        * Note we get a buffer and timestamp for both a <cr> and <lf>,
+        * but only the <cr> timestamp is retained. 
+        */
+       if (temp == 0) {
+               if (up->tcswitch == 0) {
+                       up->tcswitch = 1;
+                       up->laststamp = trtmp;
+               } else
+                   up->tcswitch = 0;
+               return;
+       }
+       pp->lencode = temp;
+       pp->lastrec = up->laststamp;
+       up->laststamp = trtmp;
+       up->tcswitch = 1;
+#ifdef DEBUG
+       if (debug)
+               printf("ulink: timecode %d %s\n", pp->lencode,
+                   pp->a_lastcode);
+#endif
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. If the timecode has invalid length or is not in
+        * proper format, we declare bad format and exit.
+        */
+       syncchar = leapchar = modechar = siglchar = ' ';
+       switch (pp->lencode ) {
+               case LEN33X:
+
+               /*
+                 * First we check if the format is 33x or 325:
+                *   <CR><LF>S9+D 00 YYYY+DDDUTCS HH:MM:SSL+5 (33x)
+                *   <CR><LF>R5_1C00LYYYY+DDDUTCS HH:MM:SSL+5 (325)
+                * simply by comparing if the signal level is 'S' or 'R'
+                 */
+
+                 if (sscanf(pp->a_lastcode, "%c%*31c",
+                            &siglchar) == 1) {
+
+                    if(siglchar == SIGLCHAR325) {
+
+                          /*
+                   * decode for a Model 325 decoder.
+                   * Timecode format from January 23, 2004 datasheet is:
+                    *
+                   *   <CR><LF>R5_1C00LYYYY+DDDUTCS HH:MM:SSL+5
+                    *
+                   *   R      WWVB decodersignal readability R1 - R5
+                   *   5      R1 is unreadable, R5 is best
+                   *   space  a space (0x20)
+                   *   1      Data bit 0, 1, M (pos mark), or ? (unknown).
+                   *   C      Reception from either (C)olorado or (H)awaii 
+                   *   00     Hours since last good WWVB frame sync. Will 
+                   *          be 00-99
+                   *   space  Space char (0x20) or (0xa5) if locked to wwvb
+                   *   YYYY   Current year, 2000-2099
+                   *   +      Leap year indicator. '+' if a leap year,
+                   *          a space (0x20) if not.
+                   *   DDD    Day of year, 000 - 365.
+                   *   UTC    Timezone (always 'UTC').
+                   *   S      Daylight savings indicator
+                   *             S - standard time (STD) in effect
+                   *             O - during STD to DST day 0000-2400
+                   *             D - daylight savings time (DST) in effect
+                   *             I - during DST to STD day 0000-2400
+                   *   space  Space character (0x20)
+                   *   HH     Hours 00-23
+                   *   :      This is the REAL in sync indicator (: = insync)  
+                   *   MM     Minutes 00-59
+                   *   :      : = in sync ? = NOT in sync
+                   *   SS     Seconds 00-59
+                   *   L      Leap second flag. Changes from space (0x20)
+                   *          to 'I' or 'D' during month preceding leap
+                   *          second adjustment. (I)nsert or (D)elete
+                   *   +5     UT1 correction (sign + digit ))
+                   */
+
+                      if (sscanf(pp->a_lastcode, 
+                          "%*2c %*2c%2c%*c%4d%*c%3d%*4c %2d%c%2d:%2d%c%*2c",
+                         char_quality, &pp->year, &pp->day, 
+                          &pp->hour, &syncchar, &pp->minute, &pp->second, 
+                          &leapchar) == 8) { 
+               
+                         if (char_quality[0] == '0') {
+                               quality = 0;
+                         } else if (char_quality[0] == '0') {
+                               quality = (char_quality[1] & 0x0f);
+                         } else  {
+                               quality = 99;
+                         }
+
+                         if (leapchar == 'I' ) leapchar = '+';
+                         if (leapchar == 'D' ) leapchar = '-';
+
+                         /*
+                         #ifdef DEBUG
+                         if (debug) {
+                            printf("ulink: char_quality %c %c\n", 
+                                    char_quality[0], char_quality[1]);
+                            printf("ulink: quality %d\n", quality);
+                            printf("ulink: syncchar %x\n", syncchar);
+                            printf("ulink: leapchar %x\n", leapchar);
+                          }
+                          #endif
+                          */
+
+                       }
+               
+                    } 
+                    if(siglchar == SIGLCHAR33x) {
+                
+                  /*
+                   * We got a Model 33X decoder.
+                   * Timecode format from January 29, 2001 datasheet is:
+                   *   <CR><LF>S9+D 00 YYYY+DDDUTCS HH:MM:SSL+5
+                   *   S      WWVB decoder sync indicator. S for in-sync(?)
+                   *          or N for noisy signal.
+                   *   9+     RF signal level in S-units, 0-9 followed by
+                   *          a space (0x20). The space turns to '+' if the
+                   *          level is over 9.
+                   *   D      Data bit 0, 1, 2 (position mark), or
+                   *          3 (unknown).
+                   *   space  Space character (0x20)
+                   *   00     Hours since last good WWVB frame sync. Will 
+                   *          be 00-23 hrs, or '1d' to '7d'. Will be 'Lk'
+                    *          if currently in sync. 
+                   *   space  Space character (0x20)
+                   *   YYYY   Current year, 1990-2089
+                   *   +      Leap year indicator. '+' if a leap year,
+                   *          a space (0x20) if not.
+                   *   DDD    Day of year, 001 - 366.
+                   *   UTC    Timezone (always 'UTC').
+                   *   S      Daylight savings indicator
+                   *             S - standard time (STD) in effect
+                   *             O - during STD to DST day 0000-2400
+                   *             D - daylight savings time (DST) in effect
+                   *             I - during DST to STD day 0000-2400
+                   *   space  Space character (0x20)
+                   *   HH     Hours 00-23
+                   *   :      This is the REAL in sync indicator (: = insync)  
+                   *   MM     Minutes 00-59
+                   *   :      : = in sync ? = NOT in sync
+                   *   SS     Seconds 00-59
+                   *   L      Leap second flag. Changes from space (0x20)
+                   *          to '+' or '-' during month preceding leap
+                   *          second adjustment.
+                   *   +5     UT1 correction (sign + digit ))
+                   */
+
+                      if (sscanf(pp->a_lastcode, 
+                           "%*4c %2c %4d%*c%3d%*4c %2d%c%2d:%2d%c%*2c",
+                          char_quality, &pp->year, &pp->day, 
+                           &pp->hour, &syncchar, &pp->minute, &pp->second, 
+                           &leapchar) == 8) { 
+               
+                          if (char_quality[0] == 'L') {
+                               quality = 0;
+                          } else if (char_quality[0] == '0') {
+                               quality = (char_quality[1] & 0x0f);
+                          } else  {
+                               quality = 99;
+                          }
+       
+                           /*
+                           #ifdef DEBUG
+                          if (debug) {
+                               printf("ulink: char_quality %c %c\n", 
+                                        char_quality[0], char_quality[1]);
+                               printf("ulink: quality %d\n", quality);
+                               printf("ulink: syncchar %x\n", syncchar);
+                               printf("ulink: leapchar %x\n", leapchar);
+                           }
+                           #endif
+                           */
+
+                       }
+                    }
+                   break;
+               }
+
+               case LEN320:
+
+               /*
+                * Model 320 Decoder
+                * The timecode format is:
+                *
+                *  <cr><lf>SQRYYYYDDD+HH:MM:SS.mmLT<cr>
+                *
+                * where:
+                *
+                * S = 'S' -- sync'd in last hour,
+                *     '0'-'9' - hours x 10 since last update,
+                *     '?' -- not in sync
+                * Q = Number of correlating time-frames, from 0 to 5
+                * R = 'R' -- reception in progress,
+                *     'N' -- Noisy reception,
+                *     ' ' -- standby mode
+                * YYYY = year from 1990 to 2089
+                * DDD = current day from 1 to 366
+                * + = '+' if current year is a leap year, else ' '
+                * HH = UTC hour 0 to 23
+                * MM = Minutes of current hour from 0 to 59
+                * SS = Seconds of current minute from 0 to 59
+                * mm = 10's milliseconds of the current second from 00 to 99
+                * L  = Leap second pending at end of month
+                *     'I' = insert, 'D'= delete
+                * T  = DST <-> STD transition indicators
+                *
+                */
+
+               if (sscanf(pp->a_lastcode, "%c%1d%c%4d%3d%*c%2d:%2d:%2d.%2ld%c",
+                      &syncchar, &quality, &modechar, &pp->year, &pp->day,
+                      &pp->hour, &pp->minute, &pp->second,
+                       &pp->nsec, &leapchar) == 10) {
+               pp->nsec *= 10000000; /* M320 returns 10's of msecs */
+               if (leapchar == 'I' ) leapchar = '+';
+               if (leapchar == 'D' ) leapchar = '-';
+               if (syncchar != '?' ) syncchar = ':';
+
+               break;
+               }
+
+               default:
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       /*
+        * Decode quality indicator
+        * For the 325 & 33x series, the lower the number the "better" 
+        * the time is. I used the dispersion as the measure of time 
+        * quality. The quality indicator in the 320 is the number of 
+        * correlating time frames (the more the better)
+        */
+
+       /* 
+        * The spec sheet for the 325 & 33x series states the clock will
+        * maintain +/-0.002 seconds accuracy when locked to WWVB. This 
+        * is indicated by 'Lk' in the quality portion of the incoming 
+        * string. When not in lock, a drift of +/-0.015 seconds should 
+        * be allowed for.
+        * With the quality indicator decoding scheme above, the 'Lk' 
+        * condition will produce a quality value of 0. If the quality 
+        * indicator starts with '0' then the second character is the 
+        * number of hours since we were last locked. If the first 
+        * character is anything other than 'L' or '0' then we have been 
+        * out of lock for more than 9 hours so we assume the worst and 
+        * force a quality value that selects the 'default' maximum 
+        * dispersion. The dispersion values below are what came with the
+        * driver. They're not unreasonable so they've not been changed.
+        */
+
+       if (pp->lencode == LEN33X) {
+               switch (quality) {
+                       case 0 :
+                               pp->disp=.002;
+                               break;
+                       case 1 :
+                               pp->disp=.02;
+                               break;
+                       case 2 :
+                               pp->disp=.04;
+                               break;
+                       case 3 :
+                               pp->disp=.08;
+                               break;
+                       default:
+                               pp->disp=MAXDISPERSE;
+                               break;
+               }
+       } else {
+               switch (quality) {
+                       case 5 :
+                               pp->disp=.002;
+                               break;
+                       case 4 :
+                               pp->disp=.02;
+                               break;
+                       case 3 :
+                               pp->disp=.04;
+                               break;
+                       case 2 :
+                               pp->disp=.08;
+                               break;
+                       case 1 :
+                               pp->disp=.16;
+                               break;
+                       default:
+                               pp->disp=MAXDISPERSE;
+                               break;
+               }
+
+       }
+
+       /*
+        * Decode synchronization, and leap characters. If
+        * unsynchronized, set the leap bits accordingly and exit.
+        * Otherwise, set the leap bits according to the leap character.
+        */
+
+       if (syncchar != ':')
+               pp->leap = LEAP_NOTINSYNC;
+       else if (leapchar == '+')
+               pp->leap = LEAP_ADDSECOND;
+       else if (leapchar == '-')
+               pp->leap = LEAP_DELSECOND;
+       else
+               pp->leap = LEAP_NOWARNING;
+
+       /*
+        * Process the new sample in the median filter and determine the
+        * timecode timestamp.
+        */
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+       }
+
+}
+
+/*
+ * ulink_poll - called by the transmit procedure
+ */
+
+static void
+ulink_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+        struct refclockproc *pp;
+        char pollchar;
+
+        pp = peer->procptr;
+        pollchar = 'T';
+       if (pp->sloppyclockflag & CLK_FLAG1) {
+               if (write(pp->io.fd, &pollchar, 1) != 1)
+                       refclock_report(peer, CEVNT_FAULT);
+               else
+                   pp->polls++;
+       }
+       else
+                   pp->polls++;
+
+        if (peer->burst > 0)
+                return;
+        if (pp->coderecv == pp->codeproc) {
+                refclock_report(peer, CEVNT_TIMEOUT);
+                return;
+        }
+        pp->lastref = pp->lastrec;
+       refclock_receive(peer);
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+        peer->burst = NSTAGE;
+
+}
+
+#else
+int refclock_ulink_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_wwv.c b/ntpd/refclock_wwv.c
new file mode 100644 (file)
index 0000000..b7e0d9a
--- /dev/null
@@ -0,0 +1,2709 @@
+/*
+ * refclock_wwv - clock driver for NIST WWV/H time/frequency station
+ */
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_WWV)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+#include "audio.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+#ifdef HAVE_SYS_IOCTL_H
+# include <sys/ioctl.h>
+#endif /* HAVE_SYS_IOCTL_H */
+
+#define ICOM 1
+
+#ifdef ICOM
+#include "icom.h"
+#endif /* ICOM */
+
+/*
+ * Audio WWV/H demodulator/decoder
+ *
+ * This driver synchronizes the computer time using data encoded in
+ * radio transmissions from NIST time/frequency stations WWV in Boulder,
+ * CO, and WWVH in Kauai, HI. Transmissions are made continuously on
+ * 2.5, 5, 10 and 15 MHz from WWV and WWVH, and 20 MHz from WWV. An
+ * ordinary AM shortwave receiver can be tuned manually to one of these
+ * frequencies or, in the case of ICOM receivers, the receiver can be
+ * tuned automatically using this program as propagation conditions
+ * change throughout the weasons, both day and night.
+ *
+ * The driver receives, demodulates and decodes the radio signals when
+ * connected to the audio codec of a workstation running Solaris, SunOS
+ * FreeBSD or Linux, and with a little help, other workstations with
+ * similar codecs or sound cards. In this implementation, only one audio
+ * driver and codec can be supported on a single machine.
+ *
+ * The demodulation and decoding algorithms used in this driver are
+ * based on those developed for the TAPR DSP93 development board and the
+ * TI 320C25 digital signal processor described in: Mills, D.L. A
+ * precision radio clock for WWV transmissions. Electrical Engineering
+ * Report 97-8-1, University of Delaware, August 1997, 25 pp., available
+ * from www.eecis.udel.edu/~mills/reports.html. The algorithms described
+ * in this report have been modified somewhat to improve performance
+ * under weak signal conditions and to provide an automatic station
+ * identification feature.
+ *
+ * The ICOM code is normally compiled in the driver. It isn't used,
+ * unless the mode keyword on the server configuration command specifies
+ * a nonzero ICOM ID select code. The C-IV trace is turned on if the
+ * debug level is greater than one.
+ *
+ * Fudge factors
+ *
+ * Fudge flag4 causes the dubugging output described above to be
+ * recorded in the clockstats file. Fudge flag2 selects the audio input
+ * port, where 0 is the mike port (default) and 1 is the line-in port.
+ * It does not seem useful to select the compact disc player port. Fudge
+ * flag3 enables audio monitoring of the input signal. For this purpose,
+ * the monitor gain is set to a default value.
+ */
+/*
+ * General definitions. These ordinarily do not need to be changed.
+ */
+#define        DEVICE_AUDIO    "/dev/audio" /* audio device name */
+#define        AUDIO_BUFSIZ    320     /* audio buffer size (50 ms) */
+#define        PRECISION       (-10)   /* precision assumed (about 1 ms) */
+#define        DESCRIPTION     "WWV/H Audio Demodulator/Decoder" /* WRU */
+#define SECOND         8000    /* second epoch (sample rate) (Hz) */
+#define MINUTE         (SECOND * 60) /* minute epoch */
+#define OFFSET         128     /* companded sample offset */
+#define SIZE           256     /* decompanding table size */
+#define        MAXAMP          6000.   /* max signal level reference */
+#define        MAXCLP          100     /* max clips above reference per s */
+#define MAXSNR         40.     /* max SNR reference */
+#define MAXFREQ                1.5     /* max frequency tolerance (187 PPM) */
+#define DATCYC         170     /* data filter cycles */
+#define DATSIZ         (DATCYC * MS) /* data filter size */
+#define SYNCYC         800     /* minute filter cycles */
+#define SYNSIZ         (SYNCYC * MS) /* minute filter size */
+#define TCKCYC         5       /* tick filter cycles */
+#define TCKSIZ         (TCKCYC * MS) /* tick filter size */
+#define NCHAN          5       /* number of radio channels */
+#define        AUDIO_PHI       5e-6    /* dispersion growth factor */
+
+/*
+ * Tunable parameters. The DGAIN parameter can be changed to fit the
+ * audio response of the radio at 100 Hz. The WWV/WWVH data subcarrier
+ * is transmitted at about 20 percent percent modulation; the matched
+ * filter boosts it by a factor of 17 and the receiver response does
+ * what it does. The compromise value works for ICOM radios. If the
+ * radio is not tunable, the DCHAN parameter can be changed to fit the
+ * expected best propagation frequency: higher if further from the
+ * transmitter, lower if nearer. The compromise value works for the US
+ * right coast. The FREQ_OFFSET parameter can be used as a frequency
+ * vernier to correct codec requency if greater than MAXFREQ.
+ */
+#define DCHAN          3       /* default radio channel (15 Mhz) */
+#define DGAIN          5.      /* subcarrier gain */
+#define        FREQ_OFFSET     0.      /* codec frequency correction (PPM) */
+
+/*
+ * General purpose status bits (status)
+ *
+ * SELV and/or SELH are set when WWV or WWVH have been heard and cleared
+ * on signal loss. SSYNC is set when the second sync pulse has been
+ * acquired and cleared by signal loss. MSYNC is set when the minute
+ * sync pulse has been acquired. DSYNC is set when the units digit has
+ * has reached the threshold and INSYNC is set when all nine digits have
+ * reached the threshold. The MSYNC, DSYNC and INSYNC bits are cleared
+ * only by timeout, upon which the driver starts over from scratch.
+ *
+ * DGATE is lit if the data bit amplitude or SNR is below thresholds and
+ * BGATE is lit if the pulse width amplitude or SNR is below thresolds.
+ * LEPSEC is set during the last minute of the leap day. At the end of
+ * this minute the driver inserts second 60 in the seconds state machine
+ * and the minute sync slips a second.
+ */
+#define MSYNC          0x0001  /* minute epoch sync */
+#define SSYNC          0x0002  /* second epoch sync */
+#define DSYNC          0x0004  /* minute units sync */
+#define INSYNC         0x0008  /* clock synchronized */
+#define FGATE          0x0010  /* frequency gate */
+#define DGATE          0x0020  /* data pulse amplitude error */
+#define BGATE          0x0040  /* data pulse width error */
+#define LEPSEC         0x1000  /* leap minute */
+
+/*
+ * Station scoreboard bits
+ *
+ * These are used to establish the signal quality for each of the five
+ * frequencies and two stations.
+ */
+#define SELV           0x0100  /* WWV station select */
+#define SELH           0x0200  /* WWVH station select */
+
+/*
+ * Alarm status bits (alarm)
+ *
+ * These bits indicate various alarm conditions, which are decoded to
+ * form the quality character included in the timecode.
+ */
+#define CMPERR         1       /* digit or misc bit compare error */
+#define LOWERR         2       /* low bit or digit amplitude or SNR */
+#define NINERR         4       /* less than nine digits in minute */
+#define SYNERR         8       /* not tracking second sync */
+
+/*
+ * Watchcat timeouts (watch)
+ *
+ * If these timeouts expire, the status bits are mashed to zero and the
+ * driver starts from scratch. Suitably more refined procedures may be
+ * developed in future. All these are in minutes.
+ */
+#define ACQSN          6       /* station acquisition timeout */
+#define DATA           15      /* unit minutes timeout */
+#define SYNCH          40      /* station sync timeout */
+#define PANIC          (2 * 1440) /* panic timeout */
+
+/*
+ * Thresholds. These establish the minimum signal level, minimum SNR and
+ * maximum jitter thresholds which establish the error and false alarm
+ * rates of the driver. The values defined here may be on the
+ * adventurous side in the interest of the highest sensitivity.
+ */
+#define MTHR           13.     /* minute sync gate (percent) */
+#define TTHR           50.     /* minute sync threshold (percent) */
+#define AWND           20      /* minute sync jitter threshold (ms) */
+#define ATHR           2500.   /* QRZ minute sync threshold */
+#define ASNR           20.     /* QRZ minute sync SNR threshold (dB) */
+#define QTHR           2500.   /* QSY minute sync threshold */
+#define QSNR           20.     /* QSY minute sync SNR threshold (dB) */
+#define STHR           2500.   /* second sync threshold */
+#define        SSNR            15.     /* second sync SNR threshold (dB) */
+#define SCMP           10      /* second sync compare threshold */
+#define DTHR           1000.   /* bit threshold */
+#define DSNR           10.     /* bit SNR threshold (dB) */
+#define AMIN           3       /* min bit count */
+#define AMAX           6       /* max bit count */
+#define BTHR           1000.   /* digit threshold */
+#define BSNR           3.      /* digit likelihood threshold (dB) */
+#define BCMP           3       /* digit compare threshold */
+#define        MAXERR          40      /* maximum error alarm */
+
+/*
+ * Tone frequency definitions. The increments are for 4.5-deg sine
+ * table.
+ */
+#define MS             (SECOND / 1000) /* samples per millisecond */
+#define IN100          ((100 * 80) / SECOND) /* 100 Hz increment */
+#define IN1000         ((1000 * 80) / SECOND) /* 1000 Hz increment */
+#define IN1200         ((1200 * 80) / SECOND) /* 1200 Hz increment */
+
+/*
+ * Acquisition and tracking time constants
+ */
+#define MINAVG         8       /* min averaging time */
+#define MAXAVG         1024    /* max averaging time */
+#define FCONST         3       /* frequency time constant */
+#define TCONST         16      /* data bit/digit time constant */
+
+/*
+ * Miscellaneous status bits (misc)
+ *
+ * These bits correspond to designated bits in the WWV/H timecode. The
+ * bit probabilities are exponentially averaged over several minutes and
+ * processed by a integrator and threshold.
+ */
+#define DUT1           0x01    /* 56 DUT .1 */
+#define DUT2           0x02    /* 57 DUT .2 */
+#define DUT4           0x04    /* 58 DUT .4 */
+#define DUTS           0x08    /* 50 DUT sign */
+#define DST1           0x10    /* 55 DST1 leap warning */
+#define DST2           0x20    /* 2 DST2 DST1 delayed one day */
+#define SECWAR         0x40    /* 3 leap second warning */
+
+/*
+ * The on-time synchronization point for the driver is the second epoch
+ * sync pulse produced by the FIR matched filters. As the 5-ms delay of
+ * these filters is compensated, the program delay is 1.1 ms due to the
+ * 600-Hz IIR bandpass filter. The measured receiver delay is 4.7 ms and
+ * the codec delay less than 0.2 ms. The additional propagation delay
+ * specific to each receiver location can be programmed in the fudge
+ * time1 and time2 values for WWV and WWVH, respectively.
+ */
+#define PDELAY (.0011 + .0047 + .0002) /* net system delay (s) */
+
+/*
+ * Table of sine values at 4.5-degree increments. This is used by the
+ * synchronous matched filter demodulators.
+ */
+double sintab[] = {
+ 0.000000e+00,  7.845910e-02,  1.564345e-01,  2.334454e-01, /* 0-3 */
+ 3.090170e-01,  3.826834e-01,  4.539905e-01,  5.224986e-01, /* 4-7 */
+ 5.877853e-01,  6.494480e-01,  7.071068e-01,  7.604060e-01, /* 8-11 */
+ 8.090170e-01,  8.526402e-01,  8.910065e-01,  9.238795e-01, /* 12-15 */
+ 9.510565e-01,  9.723699e-01,  9.876883e-01,  9.969173e-01, /* 16-19 */
+ 1.000000e+00,  9.969173e-01,  9.876883e-01,  9.723699e-01, /* 20-23 */
+ 9.510565e-01,  9.238795e-01,  8.910065e-01,  8.526402e-01, /* 24-27 */
+ 8.090170e-01,  7.604060e-01,  7.071068e-01,  6.494480e-01, /* 28-31 */
+ 5.877853e-01,  5.224986e-01,  4.539905e-01,  3.826834e-01, /* 32-35 */
+ 3.090170e-01,  2.334454e-01,  1.564345e-01,  7.845910e-02, /* 36-39 */
+-0.000000e+00, -7.845910e-02, -1.564345e-01, -2.334454e-01, /* 40-43 */
+-3.090170e-01, -3.826834e-01, -4.539905e-01, -5.224986e-01, /* 44-47 */
+-5.877853e-01, -6.494480e-01, -7.071068e-01, -7.604060e-01, /* 48-51 */
+-8.090170e-01, -8.526402e-01, -8.910065e-01, -9.238795e-01, /* 52-55 */
+-9.510565e-01, -9.723699e-01, -9.876883e-01, -9.969173e-01, /* 56-59 */
+-1.000000e+00, -9.969173e-01, -9.876883e-01, -9.723699e-01, /* 60-63 */
+-9.510565e-01, -9.238795e-01, -8.910065e-01, -8.526402e-01, /* 64-67 */
+-8.090170e-01, -7.604060e-01, -7.071068e-01, -6.494480e-01, /* 68-71 */
+-5.877853e-01, -5.224986e-01, -4.539905e-01, -3.826834e-01, /* 72-75 */
+-3.090170e-01, -2.334454e-01, -1.564345e-01, -7.845910e-02, /* 76-79 */
+ 0.000000e+00};                                                    /* 80 */
+
+/*
+ * Decoder operations at the end of each second are driven by a state
+ * machine. The transition matrix consists of a dispatch table indexed
+ * by second number. Each entry in the table contains a case switch
+ * number and argument.
+ */
+struct progx {
+       int sw;                 /* case switch number */
+       int arg;                /* argument */
+};
+
+/*
+ * Case switch numbers
+ */
+#define IDLE           0       /* no operation */
+#define COEF           1       /* BCD bit */
+#define COEF1          2       /* BCD bit for minute unit */
+#define COEF2          3       /* BCD bit not used */
+#define DECIM9         4       /* BCD digit 0-9 */
+#define DECIM6         5       /* BCD digit 0-6 */
+#define DECIM3         6       /* BCD digit 0-3 */
+#define DECIM2         7       /* BCD digit 0-2 */
+#define MSCBIT         8       /* miscellaneous bit */
+#define MSC20          9       /* miscellaneous bit */         
+#define MSC21          10      /* QSY probe channel */         
+#define MIN1           11      /* latch time */                
+#define MIN2           12      /* leap second */
+#define SYNC2          13      /* latch minute sync pulse */           
+#define SYNC3          14      /* latch data pulse */          
+
+/*
+ * Offsets in decoding matrix
+ */
+#define MN             0       /* minute digits (2) */
+#define HR             2       /* hour digits (2) */
+#define DA             4       /* day digits (3) */
+#define YR             7       /* year digits (2) */
+
+struct progx progx[] = {
+       {SYNC2, 0},             /* 0 latch minute sync pulse */
+       {SYNC3, 0},             /* 1 latch data pulse */
+       {MSCBIT, DST2},         /* 2 dst2 */
+       {MSCBIT, SECWAR},       /* 3 lw */
+       {COEF,  0},             /* 4 1 year units */
+       {COEF,  1},             /* 5 2 */
+       {COEF,  2},             /* 6 4 */
+       {COEF,  3},             /* 7 8 */
+       {DECIM9, YR},           /* 8 */
+       {IDLE,  0},             /* 9 p1 */
+       {COEF1, 0},             /* 10 1 minute units */
+       {COEF1, 1},             /* 11 2 */
+       {COEF1, 2},             /* 12 4 */
+       {COEF1, 3},             /* 13 8 */
+       {DECIM9, MN},           /* 14 */
+       {COEF,  0},             /* 15 10 minute tens */
+       {COEF,  1},             /* 16 20 */
+       {COEF,  2},             /* 17 40 */
+       {COEF2, 3},             /* 18 80 (not used) */
+       {DECIM6, MN + 1},       /* 19 p2 */
+       {COEF,  0},             /* 20 1 hour units */
+       {COEF,  1},             /* 21 2 */
+       {COEF,  2},             /* 22 4 */
+       {COEF,  3},             /* 23 8 */
+       {DECIM9, HR},           /* 24 */
+       {COEF,  0},             /* 25 10 hour tens */
+       {COEF,  1},             /* 26 20 */
+       {COEF2, 2},             /* 27 40 (not used) */
+       {COEF2, 3},             /* 28 80 (not used) */
+       {DECIM2, HR + 1},       /* 29 p3 */
+       {COEF,  0},             /* 30 1 day units */
+       {COEF,  1},             /* 31 2 */
+       {COEF,  2},             /* 32 4 */
+       {COEF,  3},             /* 33 8 */
+       {DECIM9, DA},           /* 34 */
+       {COEF,  0},             /* 35 10 day tens */
+       {COEF,  1},             /* 36 20 */
+       {COEF,  2},             /* 37 40 */
+       {COEF,  3},             /* 38 80 */
+       {DECIM9, DA + 1},       /* 39 p4 */
+       {COEF,  0},             /* 40 100 day hundreds */
+       {COEF,  1},             /* 41 200 */
+       {COEF2, 2},             /* 42 400 (not used) */
+       {COEF2, 3},             /* 43 800 (not used) */
+       {DECIM3, DA + 2},       /* 44 */
+       {IDLE,  0},             /* 45 */
+       {IDLE,  0},             /* 46 */
+       {IDLE,  0},             /* 47 */
+       {IDLE,  0},             /* 48 */
+       {IDLE,  0},             /* 49 p5 */
+       {MSCBIT, DUTS},         /* 50 dut+- */
+       {COEF,  0},             /* 51 10 year tens */
+       {COEF,  1},             /* 52 20 */
+       {COEF,  2},             /* 53 40 */
+       {COEF,  3},             /* 54 80 */
+       {MSC20, DST1},          /* 55 dst1 */
+       {MSCBIT, DUT1},         /* 56 0.1 dut */
+       {MSCBIT, DUT2},         /* 57 0.2 */
+       {MSC21, DUT4},          /* 58 0.4 QSY probe channel */
+       {MIN1,  0},             /* 59 p6 latch time */
+       {MIN2,  0}              /* 60 leap second */
+};
+
+/*
+ * BCD coefficients for maximum likelihood digit decode
+ */
+#define P15    1.              /* max positive number */
+#define N15    -1.             /* max negative number */
+
+/*
+ * Digits 0-9
+ */
+#define P9     (P15 / 4)       /* mark (+1) */
+#define N9     (N15 / 4)       /* space (-1) */
+
+double bcd9[][4] = {
+       {N9, N9, N9, N9},       /* 0 */
+       {P9, N9, N9, N9},       /* 1 */
+       {N9, P9, N9, N9},       /* 2 */
+       {P9, P9, N9, N9},       /* 3 */
+       {N9, N9, P9, N9},       /* 4 */
+       {P9, N9, P9, N9},       /* 5 */
+       {N9, P9, P9, N9},       /* 6 */
+       {P9, P9, P9, N9},       /* 7 */
+       {N9, N9, N9, P9},       /* 8 */
+       {P9, N9, N9, P9},       /* 9 */
+       {0, 0, 0, 0}            /* backstop */
+};
+
+/*
+ * Digits 0-6 (minute tens)
+ */
+#define P6     (P15 / 3)       /* mark (+1) */
+#define N6     (N15 / 3)       /* space (-1) */
+
+double bcd6[][4] = {
+       {N6, N6, N6, 0},        /* 0 */
+       {P6, N6, N6, 0},        /* 1 */
+       {N6, P6, N6, 0},        /* 2 */
+       {P6, P6, N6, 0},        /* 3 */
+       {N6, N6, P6, 0},        /* 4 */
+       {P6, N6, P6, 0},        /* 5 */
+       {N6, P6, P6, 0},        /* 6 */
+       {0, 0, 0, 0}            /* backstop */
+};
+
+/*
+ * Digits 0-3 (day hundreds)
+ */
+#define P3     (P15 / 2)       /* mark (+1) */
+#define N3     (N15 / 2)       /* space (-1) */
+
+double bcd3[][4] = {
+       {N3, N3, 0, 0},         /* 0 */
+       {P3, N3, 0, 0},         /* 1 */
+       {N3, P3, 0, 0},         /* 2 */
+       {P3, P3, 0, 0},         /* 3 */
+       {0, 0, 0, 0}            /* backstop */
+};
+
+/*
+ * Digits 0-2 (hour tens)
+ */
+#define P2     (P15 / 2)       /* mark (+1) */
+#define N2     (N15 / 2)       /* space (-1) */
+
+double bcd2[][4] = {
+       {N2, N2, 0, 0},         /* 0 */
+       {P2, N2, 0, 0},         /* 1 */
+       {N2, P2, 0, 0},         /* 2 */
+       {0, 0, 0, 0}            /* backstop */
+};
+
+/*
+ * DST decode (DST2 DST1) for prettyprint
+ */
+char dstcod[] = {
+       'S',                    /* 00 standard time */
+       'I',                    /* 01 set clock ahead at 0200 local */
+       'O',                    /* 10 set clock back at 0200 local */
+       'D'                     /* 11 daylight time */
+};
+
+/*
+ * The decoding matrix consists of nine row vectors, one for each digit
+ * of the timecode. The digits are stored from least to most significant
+ * order. The maximum likelihood timecode is formed from the digits
+ * corresponding to the maximum likelihood values reading in the
+ * opposite order: yy ddd hh:mm.
+ */
+struct decvec {
+       int radix;              /* radix (3, 4, 6, 10) */
+       int digit;              /* current clock digit */
+       int mldigit;            /* maximum likelihood digit */
+       int count;              /* match count */
+       double digprb;          /* max digit probability */
+       double digsnr;          /* likelihood function (dB) */
+       double like[10];        /* likelihood integrator 0-9 */
+};
+
+/*
+ * The station structure (sp) is used to acquire the minute pulse from
+ * WWV and/or WWVH. These stations are distinguished by the frequency
+ * used for the second and minute sync pulses, 1000 Hz for WWV and 1200
+ * Hz for WWVH. Other than frequency, the format is the same.
+ */
+struct sync {
+       double  epoch;          /* accumulated epoch differences */
+       double  maxeng;         /* sync max energy */
+       double  noieng;         /* sync noise energy */
+       long    pos;            /* max amplitude position */
+       long    lastpos;        /* last max position */
+       long    mepoch;         /* minute synch epoch */
+
+       double  amp;            /* sync signal */
+       double  syneng;         /* sync signal max */
+       double  synmax;         /* sync signal max latched at 0 s */
+       double  synsnr;         /* sync signal SNR */
+       double  metric;         /* signal quality metric */
+       int     reach;          /* reachability register */
+       int     count;          /* bit counter */
+       int     select;         /* select bits */
+       char    refid[5];       /* reference identifier */
+};
+
+/*
+ * The channel structure (cp) is used to mitigate between channels.
+ */
+struct chan {
+       int     gain;           /* audio gain */
+       struct sync wwv;        /* wwv station */
+       struct sync wwvh;       /* wwvh station */
+};
+
+/*
+ * WWV unit control structure (up)
+ */
+struct wwvunit {
+       l_fp    timestamp;      /* audio sample timestamp */
+       l_fp    tick;           /* audio sample increment */
+       double  phase, freq;    /* logical clock phase and frequency */
+       double  monitor;        /* audio monitor point */
+#ifdef ICOM
+       int     fd_icom;        /* ICOM file descriptor */
+#endif /* ICOM */
+       int     errflg;         /* error flags */
+       int     watch;          /* watchcat */
+
+       /*
+        * Audio codec variables
+        */
+       double  comp[SIZE];     /* decompanding table */
+       int     port;           /* codec port */
+       int     gain;           /* codec gain */
+       int     mongain;        /* codec monitor gain */
+       int     clipcnt;        /* sample clipped count */
+
+       /*
+        * Variables used to establish basic system timing
+        */
+       int     avgint;         /* master time constant */
+       int     yepoch;         /* sync epoch */
+       int     repoch;         /* buffered sync epoch */
+       double  epomax;         /* second sync amplitude */
+       double  eposnr;         /* second sync SNR */
+       double  irig;           /* data I channel amplitude */
+       double  qrig;           /* data Q channel amplitude */
+       int     datapt;         /* 100 Hz ramp */
+       double  datpha;         /* 100 Hz VFO control */
+       int     rphase;         /* second sample counter */
+       long    mphase;         /* minute sample counter */
+
+       /*
+        * Variables used to mitigate which channel to use
+        */
+       struct chan mitig[NCHAN]; /* channel data */
+       struct sync *sptr;      /* station pointer */
+       int     dchan;          /* data channel */
+       int     schan;          /* probe channel */
+       int     achan;          /* active channel */
+
+       /*
+        * Variables used by the clock state machine
+        */
+       struct decvec decvec[9]; /* decoding matrix */
+       int     rsec;           /* seconds counter */
+       int     digcnt;         /* count of digits synchronized */
+
+       /*
+        * Variables used to estimate signal levels and bit/digit
+        * probabilities
+        */
+       double  datsig;         /* data signal max */
+       double  datsnr;         /* data signal SNR (dB) */
+
+       /*
+        * Variables used to establish status and alarm conditions
+        */
+       int     status;         /* status bits */
+       int     alarm;          /* alarm flashers */
+       int     misc;           /* miscellaneous timecode bits */
+       int     errcnt;         /* data bit error counter */
+};
+
+/*
+ * Function prototypes
+ */
+static int     wwv_start       P((int, struct peer *));
+static void    wwv_shutdown    P((int, struct peer *));
+static void    wwv_receive     P((struct recvbuf *));
+static void    wwv_poll        P((int, struct peer *));
+
+/*
+ * More function prototypes
+ */
+static void    wwv_epoch       P((struct peer *));
+static void    wwv_rf          P((struct peer *, double));
+static void    wwv_endpoc      P((struct peer *, int));
+static void    wwv_rsec        P((struct peer *, double));
+static void    wwv_qrz         P((struct peer *, struct sync *, int));
+static void    wwv_corr4       P((struct peer *, struct decvec *,
+                                   double [], double [][4]));
+static void    wwv_gain        P((struct peer *));
+static void    wwv_tsec        P((struct peer *));
+static int     timecode        P((struct wwvunit *, char *));
+static double  wwv_snr         P((double, double));
+static int     carry           P((struct decvec *));
+static int     wwv_newchan     P((struct peer *));
+static void    wwv_newgame     P((struct peer *));
+static double  wwv_metric      P((struct sync *));
+static void    wwv_clock       P((struct peer *));
+#ifdef ICOM
+static int     wwv_qsy         P((struct peer *, int));
+#endif /* ICOM */
+
+static double qsy[NCHAN] = {2.5, 5, 10, 15, 20}; /* frequencies (MHz) */
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_wwv = {
+       wwv_start,              /* start up driver */
+       wwv_shutdown,           /* shut down driver */
+       wwv_poll,               /* transmit poll message */
+       noentry,                /* not used (old wwv_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old wwv_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * wwv_start - open the devices and initialize data for processing
+ */
+static int
+wwv_start(
+       int     unit,           /* instance number (used by PCM) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+#ifdef ICOM
+       int     temp;
+#endif /* ICOM */
+
+       /*
+        * Local variables
+        */
+       int     fd;             /* file descriptor */
+       int     i;              /* index */
+       double  step;           /* codec adjustment */
+
+       /*
+        * Open audio device
+        */
+       fd = audio_init(DEVICE_AUDIO, AUDIO_BUFSIZ, unit);
+       if (fd < 0)
+               return (0);
+#ifdef DEBUG
+       if (debug)
+               audio_show();
+#endif /* DEBUG */
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct wwvunit *)emalloc(sizeof(struct wwvunit)))) {
+               close(fd);
+               return (0);
+       }
+       memset(up, 0, sizeof(struct wwvunit));
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t)up;
+       pp->io.clock_recv = wwv_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               close(fd);
+               free(up);
+               return (0);
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+
+       /*
+        * The companded samples are encoded sign-magnitude. The table
+        * contains all the 256 values in the interest of speed.
+        */
+       up->comp[0] = up->comp[OFFSET] = 0.;
+       up->comp[1] = 1.; up->comp[OFFSET + 1] = -1.;
+       up->comp[2] = 3.; up->comp[OFFSET + 2] = -3.;
+       step = 2.;
+       for (i = 3; i < OFFSET; i++) {
+               up->comp[i] = up->comp[i - 1] + step;
+               up->comp[OFFSET + i] = -up->comp[i];
+                if (i % 16 == 0)
+                   step *= 2.;
+       }
+       DTOLFP(1. / SECOND, &up->tick);
+
+       /*
+        * Initialize the decoding matrix with the radix for each digit
+        * position.
+        */
+       up->decvec[MN].radix = 10;      /* minutes */
+       up->decvec[MN + 1].radix = 6;
+       up->decvec[HR].radix = 10;      /* hours */
+       up->decvec[HR + 1].radix = 3;
+       up->decvec[DA].radix = 10;      /* days */
+       up->decvec[DA + 1].radix = 10;
+       up->decvec[DA + 2].radix = 4;
+       up->decvec[YR].radix = 10;      /* years */
+       up->decvec[YR + 1].radix = 10;
+
+#ifdef ICOM
+       /*
+        * Initialize autotune if available. Note that the ICOM select
+        * code must be less than 128, so the high order bit can be used
+        * to select the line speed 0 (9600 bps) or 1 (1200 bps).
+        */
+       temp = 0;
+#ifdef DEBUG
+       if (debug > 1)
+               temp = P_TRACE;
+#endif /* DEBUG */
+       if (peer->ttl != 0) {
+               if (peer->ttl & 0x80)
+                       up->fd_icom = icom_init("/dev/icom", B1200,
+                           temp);
+               else
+                       up->fd_icom = icom_init("/dev/icom", B9600,
+                           temp);
+               if (up->fd_icom < 0) {
+                       NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                           msyslog(LOG_NOTICE,
+                           "icom: %m");
+                       up->errflg = CEVNT_FAULT;
+               }
+       }
+       if (up->fd_icom > 0) {
+               if (wwv_qsy(peer, DCHAN) != 0) {
+                       NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                           msyslog(LOG_NOTICE,
+                           "icom: radio not found");
+                       up->errflg = CEVNT_FAULT;
+                       close(up->fd_icom);
+                       up->fd_icom = 0;
+               } else {
+                       NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                           msyslog(LOG_NOTICE,
+                           "icom: autotune enabled");
+               }
+       }
+#endif /* ICOM */
+
+       /*
+        * Let the games begin.
+        */
+       wwv_newgame(peer);
+       return (1);
+}
+
+
+/*
+ * wwv_shutdown - shut down the clock
+ */
+static void
+wwv_shutdown(
+       int     unit,           /* instance number (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+       if (up == NULL)
+               return;
+
+       io_closeclock(&pp->io);
+#ifdef ICOM
+       if (up->fd_icom > 0)
+               close(up->fd_icom);
+#endif /* ICOM */
+       free(up);
+}
+
+
+/*
+ * wwv_receive - receive data from the audio device
+ *
+ * This routine reads input samples and adjusts the logical clock to
+ * track the A/D sample clock by dropping or duplicating codec samples.
+ * It also controls the A/D signal level with an AGC loop to mimimize
+ * quantization noise and avoid overload.
+ */
+static void
+wwv_receive(
+       struct recvbuf *rbufp   /* receive buffer structure pointer */
+       )
+{
+       struct peer *peer;
+       struct refclockproc *pp;
+       struct wwvunit *up;
+
+       /*
+        * Local variables
+        */
+       double  sample;         /* codec sample */
+       u_char  *dpt;           /* buffer pointer */
+       int     bufcnt;         /* buffer counter */
+       l_fp    ltemp;
+
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+
+       /*
+        * Main loop - read until there ain't no more. Note codec
+        * samples are bit-inverted.
+        */
+       DTOLFP((double)rbufp->recv_length / SECOND, &ltemp);
+       L_SUB(&rbufp->recv_time, &ltemp);
+       up->timestamp = rbufp->recv_time;
+       dpt = rbufp->recv_buffer;
+       for (bufcnt = 0; bufcnt < rbufp->recv_length; bufcnt++) {
+               sample = up->comp[~*dpt++ & 0xff];
+
+               /*
+                * Clip noise spikes greater than MAXAMP (6000) and
+                * record the number of clips to be used later by the
+                * AGC.
+                */
+               if (sample > MAXAMP) {
+                       sample = MAXAMP;
+                       up->clipcnt++;
+               } else if (sample < -MAXAMP) {
+                       sample = -MAXAMP;
+                       up->clipcnt++;
+               }
+
+               /*
+                * Variable frequency oscillator. The codec oscillator
+                * runs at the nominal rate of 8000 samples per second,
+                * or 125 us per sample. A frequency change of one unit
+                * results in either duplicating or deleting one sample
+                * per second, which results in a frequency change of
+                * 125 PPM.
+                */
+               up->phase += up->freq / SECOND;
+               up->phase += FREQ_OFFSET / 1e6;
+               if (up->phase >= .5) {
+                       up->phase -= 1.;
+               } else if (up->phase < -.5) {
+                       up->phase += 1.;
+                       wwv_rf(peer, sample);
+                       wwv_rf(peer, sample);
+               } else {
+                       wwv_rf(peer, sample);
+               }
+               L_ADD(&up->timestamp, &up->tick);
+       }
+
+       /*
+        * Set the input port and monitor gain for the next buffer.
+        */
+       if (pp->sloppyclockflag & CLK_FLAG2)
+               up->port = 2;
+       else
+               up->port = 1;
+       if (pp->sloppyclockflag & CLK_FLAG3)
+               up->mongain = MONGAIN;
+       else
+               up->mongain = 0;
+}
+
+
+/*
+ * wwv_poll - called by the transmit procedure
+ *
+ * This routine keeps track of status. If no offset samples have been
+ * processed during a poll interval, a timeout event is declared. If
+ * errors have have occurred during the interval, they are reported as
+ * well.
+ */
+static void
+wwv_poll(
+       int     unit,           /* instance number (not used) */
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+       if (pp->coderecv == pp->codeproc)
+               up->errflg = CEVNT_TIMEOUT;
+       if (up->errflg)
+               refclock_report(peer, up->errflg);
+       up->errflg = 0;
+       pp->polls++;
+}
+
+
+/*
+ * wwv_rf - process signals and demodulate to baseband
+ *
+ * This routine grooms and filters decompanded raw audio samples. The
+ * output signal is the 100-Hz filtered baseband data signal in
+ * quadrature phase. The routine also determines the minute synch epoch,
+ * as well as certain signal maxima, minima and related values.
+ *
+ * There are two 1-s ramps used by this program. Both count the 8000
+ * logical clock samples spanning exactly one second. The epoch ramp
+ * counts the samples starting at an arbitrary time. The rphase ramp
+ * counts the samples starting at the 5-ms second sync pulse found
+ * during the epoch ramp.
+ *
+ * There are two 1-m ramps used by this program. The mphase ramp counts
+ * the 480,000 logical clock samples spanning exactly one minute and
+ * starting at an arbitrary time. The rsec ramp counts the 60 seconds of
+ * the minute starting at the 800-ms minute sync pulse found during the
+ * mphase ramp. The rsec ramp drives the seconds state machine to
+ * determine the bits and digits of the timecode. 
+ *
+ * Demodulation operations are based on three synthesized quadrature
+ * sinusoids: 100 Hz for the data signal, 1000 Hz for the WWV sync
+ * signal and 1200 Hz for the WWVH sync signal. These drive synchronous
+ * matched filters for the data signal (170 ms at 100 Hz), WWV minute
+ * sync signal (800 ms at 1000 Hz) and WWVH minute sync signal (800 ms
+ * at 1200 Hz). Two additional matched filters are switched in
+ * as required for the WWV second sync signal (5 cycles at 1000 Hz) and
+ * WWVH second sync signal (6 cycles at 1200 Hz).
+ */
+static void
+wwv_rf(
+       struct peer *peer,      /* peerstructure pointer */
+       double isig             /* input signal */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+       struct sync *sp, *rp;
+
+       static double lpf[5];   /* 150-Hz lpf delay line */
+       double data;            /* lpf output */
+       static double bpf[9];   /* 1000/1200-Hz bpf delay line */
+       double syncx;           /* bpf output */
+       static double mf[41];   /* 1000/1200-Hz mf delay line */
+       double mfsync;          /* mf output */
+
+       static int iptr;        /* data channel pointer */
+       static double ibuf[DATSIZ]; /* data I channel delay line */
+       static double qbuf[DATSIZ]; /* data Q channel delay line */
+
+       static int jptr;        /* sync channel pointer */
+       static int kptr;        /* tick channel pointer */
+
+       static int csinptr;     /* wwv channel phase */
+       static double cibuf[SYNSIZ]; /* wwv I channel delay line */
+       static double cqbuf[SYNSIZ]; /* wwv Q channel delay line */
+       static double ciamp;    /* wwv I channel amplitude */
+       static double cqamp;    /* wwv Q channel amplitude */
+
+       static double csibuf[TCKSIZ]; /* wwv I tick delay line */
+       static double csqbuf[TCKSIZ]; /* wwv Q tick delay line */
+       static double csiamp;   /* wwv I tick amplitude */
+       static double csqamp;   /* wwv Q tick amplitude */
+
+       static int hsinptr;     /* wwvh channel phase */
+       static double hibuf[SYNSIZ]; /* wwvh I channel delay line */
+       static double hqbuf[SYNSIZ]; /* wwvh Q channel delay line */
+       static double hiamp;    /* wwvh I channel amplitude */
+       static double hqamp;    /* wwvh Q channel amplitude */
+
+       static double hsibuf[TCKSIZ]; /* wwvh I tick delay line */
+       static double hsqbuf[TCKSIZ]; /* wwvh Q tick delay line */
+       static double hsiamp;   /* wwvh I tick amplitude */
+       static double hsqamp;   /* wwvh Q tick amplitude */
+
+       static double epobuf[SECOND]; /* second sync comb filter */
+       static double epomax, nxtmax; /* second sync amplitude buffer */
+       static int epopos;      /* epoch second sync position buffer */
+
+       static int iniflg;      /* initialization flag */
+       int     pdelay;         /* propagation delay (samples) */
+       int     epoch;          /* comb filter index */
+       double  dtemp;
+       int     i;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+
+       if (!iniflg) {
+               iniflg = 1;
+               memset((char *)lpf, 0, sizeof(lpf));
+               memset((char *)bpf, 0, sizeof(bpf));
+               memset((char *)mf, 0, sizeof(mf));
+               memset((char *)ibuf, 0, sizeof(ibuf));
+               memset((char *)qbuf, 0, sizeof(qbuf));
+               memset((char *)cibuf, 0, sizeof(cibuf));
+               memset((char *)cqbuf, 0, sizeof(cqbuf));
+               memset((char *)csibuf, 0, sizeof(csibuf));
+               memset((char *)csqbuf, 0, sizeof(csqbuf));
+               memset((char *)hibuf, 0, sizeof(hibuf));
+               memset((char *)hqbuf, 0, sizeof(hqbuf));
+               memset((char *)hsibuf, 0, sizeof(hsibuf));
+               memset((char *)hsqbuf, 0, sizeof(hsqbuf));
+               memset((char *)epobuf, 0, sizeof(epobuf));
+       }
+
+       /*
+        * Baseband data demodulation. The 100-Hz subcarrier is
+        * extracted using a 150-Hz IIR lowpass filter. This attenuates
+        * the 1000/1200-Hz sync signals, as well as the 440-Hz and
+        * 600-Hz tones and most of the noise and voice modulation
+        * components.
+        *
+        * The subcarrier is transmitted 10 dB down from the carrier.
+        * The DGAIN parameter can be adjusted for this and to
+        * compensate for the radio audio response at 100 Hz.
+        *
+        * Matlab IIR 4th-order IIR elliptic, 150 Hz lowpass, 0.2 dB
+        * passband ripple, -50 dB stopband ripple.
+        */
+       data = (lpf[4] = lpf[3]) * 8.360961e-01;
+       data += (lpf[3] = lpf[2]) * -3.481740e+00;
+       data += (lpf[2] = lpf[1]) * 5.452988e+00;
+       data += (lpf[1] = lpf[0]) * -3.807229e+00;
+       lpf[0] = isig * DGAIN - data;
+       data = lpf[0] * 3.281435e-03
+           + lpf[1] * -1.149947e-02
+           + lpf[2] * 1.654858e-02
+           + lpf[3] * -1.149947e-02
+           + lpf[4] * 3.281435e-03;
+
+       /*
+        * The 100-Hz data signal is demodulated using a pair of
+        * quadrature multipliers, matched filters and a phase lock
+        * loop. The I and Q quadrature data signals are produced by
+        * multiplying the filtered signal by 100-Hz sine and cosine
+        * signals, respectively. The signals are processed by 170-ms
+        * synchronous matched filters to produce the amplitude and
+        * phase signals used by the demodulator. The signals are scaled
+        * to produce unit energy at the maximum value.
+        */
+       i = up->datapt;
+       up->datapt = (up->datapt + IN100) % 80;
+       dtemp = sintab[i] * data / (MS / 2. * DATCYC);
+       up->irig -= ibuf[iptr];
+       ibuf[iptr] = dtemp;
+       up->irig += dtemp;
+
+       i = (i + 20) % 80;
+       dtemp = sintab[i] * data / (MS / 2. * DATCYC);
+       up->qrig -= qbuf[iptr];
+       qbuf[iptr] = dtemp;
+       up->qrig += dtemp;
+       iptr = (iptr + 1) % DATSIZ;
+
+       /*
+        * Baseband sync demodulation. The 1000/1200 sync signals are
+        * extracted using a 600-Hz IIR bandpass filter. This removes
+        * the 100-Hz data subcarrier, as well as the 440-Hz and 600-Hz
+        * tones and most of the noise and voice modulation components.
+        *
+        * Matlab 4th-order IIR elliptic, 800-1400 Hz bandpass, 0.2 dB
+        * passband ripple, -50 dB stopband ripple.
+        */
+       syncx = (bpf[8] = bpf[7]) * 4.897278e-01;
+       syncx += (bpf[7] = bpf[6]) * -2.765914e+00;
+       syncx += (bpf[6] = bpf[5]) * 8.110921e+00;
+       syncx += (bpf[5] = bpf[4]) * -1.517732e+01;
+       syncx += (bpf[4] = bpf[3]) * 1.975197e+01;
+       syncx += (bpf[3] = bpf[2]) * -1.814365e+01;
+       syncx += (bpf[2] = bpf[1]) * 1.159783e+01;
+       syncx += (bpf[1] = bpf[0]) * -4.735040e+00;
+       bpf[0] = isig - syncx;
+       syncx = bpf[0] * 8.203628e-03
+           + bpf[1] * -2.375732e-02
+           + bpf[2] * 3.353214e-02
+           + bpf[3] * -4.080258e-02
+           + bpf[4] * 4.605479e-02
+           + bpf[5] * -4.080258e-02
+           + bpf[6] * 3.353214e-02
+           + bpf[7] * -2.375732e-02
+           + bpf[8] * 8.203628e-03;
+
+       /*
+        * The 1000/1200 sync signals are demodulated using a pair of
+        * quadrature multipliers and matched filters. However,
+        * synchronous demodulation at these frequencies is impractical,
+        * so only the signal amplitude is used. The I and Q quadrature
+        * sync signals are produced by multiplying the filtered signal
+        * by 1000-Hz (WWV) and 1200-Hz (WWVH) sine and cosine signals,
+        * respectively. The WWV and WWVH signals are processed by 800-
+        * ms synchronous matched filters and combined to produce the
+        * minute sync signal and detect which one (or both) the WWV or
+        * WWVH signal is present. The WWV and WWVH signals are also
+        * processed by 5-ms synchronous matched filters and combined to
+        * produce the second sync signal. The signals are scaled to
+        * produce unit energy at the maximum value.
+        *
+        * Note the master timing ramps, which run continuously. The
+        * minute counter (mphase) counts the samples in the minute,
+        * while the second counter (epoch) counts the samples in the
+        * second.
+        */
+       up->mphase = (up->mphase + 1) % MINUTE;
+       epoch = up->mphase % SECOND;
+
+       /*
+        * WWV
+        */
+       i = csinptr;
+       csinptr = (csinptr + IN1000) % 80;
+
+       dtemp = sintab[i] * syncx / (MS / 2.);
+       ciamp -= cibuf[jptr];
+       cibuf[jptr] = dtemp;
+       ciamp += dtemp;
+       csiamp -= csibuf[kptr];
+       csibuf[kptr] = dtemp;
+       csiamp += dtemp;
+
+       i = (i + 20) % 80;
+       dtemp = sintab[i] * syncx / (MS / 2.);
+       cqamp -= cqbuf[jptr];
+       cqbuf[jptr] = dtemp;
+       cqamp += dtemp;
+       csqamp -= csqbuf[kptr];
+       csqbuf[kptr] = dtemp;
+       csqamp += dtemp;
+
+       sp = &up->mitig[up->achan].wwv;
+       sp->amp = sqrt(ciamp * ciamp + cqamp * cqamp) / SYNCYC;
+       if (!(up->status & MSYNC))
+               wwv_qrz(peer, sp, (int)(pp->fudgetime1 * SECOND));
+
+       /*
+        * WWVH
+        */
+       i = hsinptr;
+       hsinptr = (hsinptr + IN1200) % 80;
+
+       dtemp = sintab[i] * syncx / (MS / 2.);
+       hiamp -= hibuf[jptr];
+       hibuf[jptr] = dtemp;
+       hiamp += dtemp;
+       hsiamp -= hsibuf[kptr];
+       hsibuf[kptr] = dtemp;
+       hsiamp += dtemp;
+
+       i = (i + 20) % 80;
+       dtemp = sintab[i] * syncx / (MS / 2.);
+       hqamp -= hqbuf[jptr];
+       hqbuf[jptr] = dtemp;
+       hqamp += dtemp;
+       hsqamp -= hsqbuf[kptr];
+       hsqbuf[kptr] = dtemp;
+       hsqamp += dtemp;
+
+       rp = &up->mitig[up->achan].wwvh;
+       rp->amp = sqrt(hiamp * hiamp + hqamp * hqamp) / SYNCYC;
+       if (!(up->status & MSYNC))
+               wwv_qrz(peer, rp, (int)(pp->fudgetime2 * SECOND));
+       jptr = (jptr + 1) % SYNSIZ;
+       kptr = (kptr + 1) % TCKSIZ;
+
+       /*
+        * The following section is called once per minute. It does
+        * housekeeping and timeout functions and empties the dustbins.
+        */
+       if (up->mphase == 0) {
+               up->watch++;
+               if (!(up->status & MSYNC)) {
+
+                       /*
+                        * If minute sync has not been acquired before
+                        * ACQSN timeout (6 min), or if no signal is
+                        * heard, the program cycles to the next
+                        * frequency and tries again.
+                        */
+                       if (!wwv_newchan(peer))
+                               up->watch = 0;
+#ifdef ICOM
+                       if (up->fd_icom > 0)
+                               wwv_qsy(peer, up->dchan);
+#endif /* ICOM */
+               } else {
+
+                       /*
+                        * If the leap bit is set, set the minute epoch
+                        * back one second so the station processes
+                        * don't miss a beat.
+                        */
+                       if (up->status & LEPSEC) {
+                               up->mphase -= SECOND;
+                               if (up->mphase < 0)
+                                       up->mphase += MINUTE;
+                       }
+               }
+       }
+
+       /*
+        * When the channel metric reaches threshold and the second
+        * counter matches the minute epoch within the second, the
+        * driver has synchronized to the station. The second number is
+        * the remaining seconds until the next minute epoch, while the
+        * sync epoch is zero. Watch out for the first second; if
+        * already synchronized to the second, the buffered sync epoch
+        * must be set.
+        *
+        * Note the guard interval is 200 ms; if for some reason the
+        * clock drifts more than that, it might wind up in the wrong
+        * second. If the maximum frequency error is not more than about
+        * 1 PPM, the clock can go as much as two days while still in
+        * the same second.
+        */
+       if (up->status & MSYNC) {
+               wwv_epoch(peer);
+       } else if (up->sptr != NULL) {
+               sp = up->sptr;
+               if (sp->metric >= TTHR && epoch == sp->mepoch % SECOND)                     {
+                       up->rsec = (60 - sp->mepoch / SECOND) % 60;
+                       up->rphase = 0;
+                       up->status |= MSYNC;
+                       up->watch = 0;
+                       if (!(up->status & SSYNC))
+                               up->repoch = up->yepoch = epoch;
+                       else
+                               up->repoch = up->yepoch;
+                       
+               }
+       }
+
+       /*
+        * The second sync pulse is extracted using 5-ms (40 sample) FIR
+        * matched filters at 1000 Hz for WWV or 1200 Hz for WWVH. This
+        * pulse is used for the most precise synchronization, since if
+        * provides a resolution of one sample (125 us). The filters run
+        * only if the station has been reliably determined.
+        */
+       if (up->status & SELV) {
+               pdelay = (int)(pp->fudgetime1 * SECOND);
+               mfsync = sqrt(csiamp * csiamp + csqamp * csqamp) /
+                   TCKCYC;
+       } else if (up->status & SELH) {
+               pdelay = (int)(pp->fudgetime2 * SECOND);
+               mfsync = sqrt(hsiamp * hsiamp + hsqamp * hsqamp) /
+                   TCKCYC;
+       } else {
+               pdelay = 0;
+               mfsync = 0;
+       }
+
+       /*
+        * Enhance the seconds sync pulse using a 1-s (8000-sample) comb
+        * filter. Correct for the FIR matched filter delay, which is 5
+        * ms for both the WWV and WWVH filters, and also for the
+        * propagation delay. Once each second look for second sync. If
+        * not in minute sync, fiddle the codec gain. Note the SNR is
+        * computed from the maximum sample and the envelope of the
+        * sample 6 ms before it, so if we slip more than a cycle the
+        * SNR should plummet. The signal is scaled to produce unit
+        * energy at the maximum value.
+        */
+       dtemp = (epobuf[epoch] += (mfsync - epobuf[epoch]) /
+           up->avgint);
+       if (dtemp > epomax) {
+               int     j;
+
+               epomax = dtemp;
+               epopos = epoch;
+               j = epoch - 6 * MS;
+               if (j < 0)
+                       j += SECOND;
+               nxtmax = fabs(epobuf[j]);
+       }
+       if (epoch == 0) {
+               up->epomax = epomax;
+               up->eposnr = wwv_snr(epomax, nxtmax);
+               epopos -= pdelay + TCKCYC * MS;
+               if (epopos < 0)
+                       epopos += SECOND;
+               wwv_endpoc(peer, epopos);
+               if (!(up->status & SSYNC))
+                       up->alarm |= SYNERR;
+               epomax = 0;
+               if (!(up->status & MSYNC))
+                       wwv_gain(peer);
+       }
+}
+
+
+/*
+ * wwv_qrz - identify and acquire WWV/WWVH minute sync pulse
+ *
+ * This routine implements a virtual station process used to acquire
+ * minute sync and to mitigate among the ten frequency and station
+ * combinations. During minute sync acquisition the process probes each
+ * frequency and station in turn for the minute pulse, which
+ * involves searching through the entire 480,000-sample minute. The
+ * process finds the maximum signal and RMS noise plus signal. Then, the
+ * actual noise is determined by subtracting the energy of the matched
+ * filter.
+ *
+ * Students of radar receiver technology will discover this algorithm
+ * amounts to a range-gate discriminator. A valid pulse must have peak
+ * amplitude at least QTHR (2500) and SNR at least QSNR (20) dB and the
+ * difference between the current and previous epoch must be less than
+ * AWND (20 ms). Note that the discriminator peak occurs about 800 ms
+ * into the second, so the timing is retarded to the previous second
+ * epoch.
+ */
+static void
+wwv_qrz(
+       struct peer *peer,      /* peer structure pointer */
+       struct sync *sp,        /* sync channel structure */
+       int     pdelay          /* propagation delay (samples) */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+       char    tbuf[80];       /* monitor buffer */
+       long    epoch;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+
+       /*
+        * Find the sample with peak amplitude, which defines the minute
+        * epoch. Accumulate all samples to determine the total noise
+        * energy.
+        */
+       epoch = up->mphase - pdelay - SYNSIZ;
+       if (epoch < 0)
+               epoch += MINUTE;
+       if (sp->amp > sp->maxeng) {
+               sp->maxeng = sp->amp;
+               sp->pos = epoch;
+       }
+       sp->noieng += sp->amp;
+
+       /*
+        * At the end of the minute, determine the epoch of the minute
+        * sync pulse, as well as the difference between the current and
+        * previous epoches due to the intrinsic frequency error plus
+        * jitter. When calculating the SNR, subtract the pulse energy
+        * from the total noise energy and then normalize.
+        */
+       if (up->mphase == 0) {
+               sp->synmax = sp->maxeng;
+               sp->synsnr = wwv_snr(sp->synmax, (sp->noieng -
+                   sp->synmax) / MINUTE);
+               if (sp->count == 0)
+                       sp->lastpos = sp->pos;
+               epoch = (sp->pos - sp->lastpos) % MINUTE;
+               sp->reach <<= 1;
+               if (sp->reach & (1 << AMAX))
+                       sp->count--;
+               if (sp->synmax > ATHR && sp->synsnr > ASNR) {
+                       if (abs(epoch) < AWND * MS) {
+                               sp->reach |= 1;
+                               sp->count++;
+                               sp->mepoch = sp->lastpos = sp->pos;
+                       } else if (sp->count == 1) {
+                               sp->lastpos = sp->pos;
+                       }
+               }
+               if (up->watch > ACQSN)
+                       sp->metric = 0;
+               else
+                       sp->metric = wwv_metric(sp);
+               if (pp->sloppyclockflag & CLK_FLAG4) {
+                       sprintf(tbuf,
+                           "wwv8 %04x %3d %s %04x %.0f %.0f/%.1f %4ld %4ld",
+                           up->status, up->gain, sp->refid,
+                           sp->reach & 0xffff, sp->metric, sp->synmax,
+                           sp->synsnr, sp->pos % SECOND, epoch);
+                       record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+                       if (debug)
+                               printf("%s\n", tbuf);
+#endif /* DEBUG */
+               }
+               sp->maxeng = sp->noieng = 0;
+       }
+}
+
+
+/*
+ * wwv_endpoc - identify and acquire second sync pulse
+ *
+ * This routine is called at the end of the second sync interval. It
+ * determines the second sync epoch position within the second and
+ * disciplines the sample clock using a frequency-lock loop (FLL).
+ *
+ * Second sync is determined in the RF input routine as the maximum
+ * over all 8000 samples in the second comb filter. To assure accurate
+ * and reliable time and frequency discipline, this routine performs a
+ * great deal of heavy-handed heuristic data filtering and grooming.
+ */
+static void
+wwv_endpoc(
+       struct peer *peer,      /* peer structure pointer */
+       int epopos              /* epoch max position */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+       static int epoch_mf[3]; /* epoch median filter */
+       static int tepoch;      /* current second epoch */
+       static int xepoch;      /* last second epoch */
+       static int zepoch;      /* last run epoch */
+       static int zcount;      /* last run end time */
+       static int scount;      /* seconds counter */
+       static int syncnt;      /* run length counter */
+       static int maxrun;      /* longest run length */
+       static int mepoch;      /* longest run end epoch */
+       static int mcount;      /* longest run end time */
+       static int avgcnt;      /* averaging interval counter */
+       static int avginc;      /* averaging ratchet */
+       static int iniflg;      /* initialization flag */
+       char tbuf[80];          /* monitor buffer */
+       double dtemp;
+       int tmp2;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+       if (!iniflg) {
+               iniflg = 1;
+               memset((char *)epoch_mf, 0, sizeof(epoch_mf));
+       }
+
+       /*
+        * If the signal amplitude or SNR fall below thresholds, dim the
+        * second sync lamp and wait for hotter ions. If no stations are
+        * heard, we are either in a probe cycle or the ions are really
+        * cold. 
+        */
+       scount++;
+       if (up->epomax < STHR || up->eposnr < SSNR) {
+               up->status &= ~(SSYNC | FGATE);
+               avgcnt = syncnt = maxrun = 0;
+               return;
+       }
+       if (!(up->status & (SELV | SELH)))
+               return;
+
+       /*
+        * A three-stage median filter is used to help denoise the
+        * second sync pulse. The median sample becomes the candidate
+        * epoch.
+        */
+       epoch_mf[2] = epoch_mf[1];
+       epoch_mf[1] = epoch_mf[0];
+       epoch_mf[0] = epopos;
+       if (epoch_mf[0] > epoch_mf[1]) {
+               if (epoch_mf[1] > epoch_mf[2])
+                       tepoch = epoch_mf[1];   /* 0 1 2 */
+               else if (epoch_mf[2] > epoch_mf[0])
+                       tepoch = epoch_mf[0];   /* 2 0 1 */
+               else
+                       tepoch = epoch_mf[2];   /* 0 2 1 */
+       } else {
+               if (epoch_mf[1] < epoch_mf[2])
+                       tepoch = epoch_mf[1];   /* 2 1 0 */
+               else if (epoch_mf[2] < epoch_mf[0])
+                       tepoch = epoch_mf[0];   /* 1 0 2 */
+               else
+                       tepoch = epoch_mf[2];   /* 1 2 0 */
+       }
+
+
+       /*
+        * If the epoch candidate is the same as the last one, increment
+        * the run counter. If not, save the length, epoch and end
+        * time of the current run for use later and reset the counter.
+        * The epoch is considered valid if the run is at least SCMP
+        * (10) s, the minute is synchronized and the interval since the
+        * last epoch  is not greater than the averaging interval. Thus,
+        * after a long absence, the program will wait a full averaging
+        * interval while the comb filter charges up and noise
+        * dissapates..
+        */
+       tmp2 = (tepoch - xepoch) % SECOND;
+       if (tmp2 == 0) {
+               syncnt++;
+               if (syncnt > SCMP && up->status & MSYNC && (up->status &
+                   FGATE || scount - zcount <= up->avgint)) {
+                       up->status |= SSYNC;
+                       up->yepoch = tepoch;
+               }
+       } else if (syncnt >= maxrun) {
+               maxrun = syncnt;
+               mcount = scount;
+               mepoch = xepoch;
+               syncnt = 0;
+       }
+       if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status & MSYNC))
+           {
+               sprintf(tbuf,
+                   "wwv1 %04x %3d %4d %5.0f %5.1f %5d %4d %4d %4d",
+                   up->status, up->gain, tepoch, up->epomax,
+                   up->eposnr, tmp2, avgcnt, syncnt,
+                   maxrun);
+               record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+               if (debug)
+                       printf("%s\n", tbuf);
+#endif /* DEBUG */
+       }
+       avgcnt++;
+       if (avgcnt < up->avgint) {
+               xepoch = tepoch;
+               return;
+       }
+
+       /*
+        * The sample clock frequency is disciplined using a first-order
+        * feedback loop with time constant consistent with the Allan
+        * intercept of typical computer clocks. During each averaging
+        * interval the candidate epoch at the end of the longest run is
+        * determined. If the longest run is zero, all epoches in the
+        * interval are different, so the candidate epoch is the current
+        * epoch. The frequency update is computed from the candidate
+        * epoch difference (125-us units) and time difference (seconds)
+        * between updates.
+        */
+       if (syncnt >= maxrun) {
+               maxrun = syncnt;
+               mcount = scount;
+               mepoch = xepoch;
+       }
+       xepoch = tepoch;
+       if (maxrun == 0) {
+               mepoch = tepoch;
+               mcount = scount;
+       }
+
+       /*
+        * The master clock runs at the codec sample frequency of 8000
+        * Hz, so the intrinsic time resolution is 125 us. The frequency
+        * resolution ranges from 18 PPM at the minimum averaging
+        * interval of 8 s to 0.12 PPM at the maximum interval of 1024
+        * s. An offset update is determined at the end of the longest
+        * run in each averaging interval. The frequency adjustment is
+        * computed from the difference between offset updates and the
+        * interval between them.
+        *
+        * The maximum frequency adjustment ranges from 187 PPM at the
+        * minimum interval to 1.5 PPM at the maximum. If the adjustment
+        * exceeds the maximum, the update is discarded and the
+        * hysteresis counter is decremented. Otherwise, the frequency
+        * is incremented by the adjustment, but clamped to the maximum
+        * 187.5 PPM. If the update is less than half the maximum, the
+        * hysteresis counter is incremented. If the counter increments
+        * to +3, the averaging interval is doubled and the counter set
+        * to zero; if it decrements to -3, the interval is halved and
+        * the counter set to zero.
+        */
+       dtemp = (mepoch - zepoch) % SECOND;
+       if (up->status & FGATE) {
+               if (abs(dtemp) < MAXFREQ * MINAVG) {
+                       up->freq += (dtemp / 2.) / ((mcount - zcount) *
+                           FCONST);
+                       if (up->freq > MAXFREQ)
+                               up->freq = MAXFREQ;
+                       else if (up->freq < -MAXFREQ)
+                               up->freq = -MAXFREQ;
+                       if (abs(dtemp) < MAXFREQ * MINAVG / 2.) {
+                               if (avginc < 3) {
+                                       avginc++;
+                               } else {
+                                       if (up->avgint < MAXAVG) {
+                                               up->avgint <<= 1;
+                                               avginc = 0;
+                                       }
+                               }
+                       }
+               } else {
+                       if (avginc > -3) {
+                               avginc--;
+                       } else {
+                               if (up->avgint > MINAVG) {
+                                       up->avgint >>= 1;
+                                       avginc = 0;
+                               }
+                       }
+               }
+       }
+       if (pp->sloppyclockflag & CLK_FLAG4) {
+               sprintf(tbuf,
+                   "wwv2 %04x %5.0f %5.1f %5d %4d %4d %4d %4.0f %7.2f",
+                   up->status, up->epomax, up->eposnr, mepoch,
+                   up->avgint, maxrun, mcount - zcount, dtemp,
+                   up->freq * 1e6 / SECOND);
+               record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+               if (debug)
+                       printf("%s\n", tbuf);
+#endif /* DEBUG */
+       }
+
+       /*
+        * This is a valid update; set up for the next interval.
+        */
+       up->status |= FGATE;
+       zepoch = mepoch;
+       zcount = mcount;
+       avgcnt = syncnt = maxrun = 0;
+}
+
+
+/*
+ * wwv_epoch - epoch scanner
+ *
+ * This routine extracts data signals from the 100-Hz subcarrier. It
+ * scans the receiver second epoch to determine the signal amplitudes
+ * and pulse timings. Receiver synchronization is determined by the
+ * minute sync pulse detected in the wwv_rf() routine and the second
+ * sync pulse detected in the wwv_epoch() routine. The transmitted
+ * signals are delayed by the propagation delay, receiver delay and
+ * filter delay of this program. Delay corrections are introduced
+ * separately for WWV and WWVH. 
+ *
+ * Most communications radios use a highpass filter in the audio stages,
+ * which can do nasty things to the subcarrier phase relative to the
+ * sync pulses. Therefore, the data subcarrier reference phase is
+ * disciplined using the hardlimited quadrature-phase signal sampled at
+ * the same time as the in-phase signal. The phase tracking loop uses
+ * phase adjustments of plus-minus one sample (125 us). 
+ */
+static void
+wwv_epoch(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+       struct chan *cp;
+       static double sigmin, sigzer, sigone, engmax, engmin;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+
+       /*
+        * Find the maximum minute sync pulse energy for both the
+        * WWV and WWVH stations. This will be used later for channel
+        * and station mitigation. Also set the seconds epoch at 800 ms
+        * well before the end of the second to make sure we never set
+        * the epoch backwards.
+        */
+       cp = &up->mitig[up->achan];
+       if (cp->wwv.amp > cp->wwv.syneng) 
+               cp->wwv.syneng = cp->wwv.amp;
+       if (cp->wwvh.amp > cp->wwvh.syneng) 
+               cp->wwvh.syneng = cp->wwvh.amp;
+       if (up->rphase == 800 * MS)
+               up->repoch = up->yepoch;
+
+       /*
+        * Use the signal amplitude at epoch 15 ms as the noise floor.
+        * This gives a guard time of +-15 ms from the beginning of the
+        * second until the second pulse rises at 30 ms. There is a
+        * compromise here; we want to delay the sample as long as
+        * possible to give the radio time to change frequency and the
+        * AGC to stabilize, but as early as possible if the second
+        * epoch is not exact.
+        */
+       if (up->rphase == 15 * MS)
+               sigmin = sigzer = sigone = up->irig;
+
+       /*
+        * Latch the data signal at 200 ms. Keep this around until the
+        * end of the second. Use the signal energy as the peak to
+        * compute the SNR. Use the Q sample to adjust the 100-Hz
+        * reference oscillator phase.
+        */
+       if (up->rphase == 200 * MS) {
+               sigzer = up->irig;
+               engmax = sqrt(up->irig * up->irig + up->qrig *
+                   up->qrig);
+               up->datpha = up->qrig / up->avgint;
+               if (up->datpha >= 0) {
+                       up->datapt++;
+                       if (up->datapt >= 80)
+                               up->datapt -= 80;
+               } else {
+                       up->datapt--;
+                       if (up->datapt < 0)
+                               up->datapt += 80;
+               }
+       }
+
+
+       /*
+        * Latch the data signal at 500 ms. Keep this around until the
+        * end of the second.
+        */
+       else if (up->rphase == 500 * MS)
+               sigone = up->irig;
+
+       /*
+        * At the end of the second crank the clock state machine and
+        * adjust the codec gain. Note the epoch is buffered from the
+        * center of the second in order to avoid jitter while the
+        * seconds synch is diddling the epoch. Then, determine the true
+        * offset and update the median filter in the driver interface.
+        *
+        * Use the energy at the end of the second as the noise to
+        * compute the SNR for the data pulse. This gives a better
+        * measurement than the beginning of the second, especially when
+        * returning from the probe channel. This gives a guard time of
+        * 30 ms from the decay of the longest pulse to the rise of the
+        * next pulse.
+        */
+       up->rphase++;
+       if (up->mphase % SECOND == up->repoch) {
+               up->status &= ~(DGATE | BGATE);
+               engmin = sqrt(up->irig * up->irig + up->qrig *
+                   up->qrig);
+               up->datsig = engmax;
+               up->datsnr = wwv_snr(engmax, engmin);
+
+               /*
+                * If the amplitude or SNR is below threshold, average a
+                * 0 in the the integrators; otherwise, average the
+                * bipolar signal. This is done to avoid noise polution.
+                */
+               if (engmax < DTHR || up->datsnr < DSNR) {
+                       up->status |= DGATE;
+                       wwv_rsec(peer, 0);
+               } else {
+                       sigzer -= sigone;
+                       sigone -= sigmin;
+                       wwv_rsec(peer, sigone - sigzer);
+               }
+               if (up->status & (DGATE | BGATE))
+                       up->errcnt++;
+               if (up->errcnt > MAXERR)
+                       up->alarm |= LOWERR;
+               wwv_gain(peer);
+               cp = &up->mitig[up->achan];
+               cp->wwv.syneng = 0;
+               cp->wwvh.syneng = 0;
+               up->rphase = 0;
+       }
+}
+
+
+/*
+ * wwv_rsec - process receiver second
+ *
+ * This routine is called at the end of each receiver second to
+ * implement the per-second state machine. The machine assembles BCD
+ * digit bits, decodes miscellaneous bits and dances the leap seconds.
+ *
+ * Normally, the minute has 60 seconds numbered 0-59. If the leap
+ * warning bit is set, the last minute (1439) of 30 June (day 181 or 182
+ * for leap years) or 31 December (day 365 or 366 for leap years) is
+ * augmented by one second numbered 60. This is accomplished by
+ * extending the minute interval by one second and teaching the state
+ * machine to ignore it.
+ */
+static void
+wwv_rsec(
+       struct peer *peer,      /* peer structure pointer */
+       double bit
+       )
+{
+       static int iniflg;      /* initialization flag */
+       static double bcddld[4]; /* BCD data bits */
+       static double bitvec[61]; /* bit integrator for misc bits */
+       struct refclockproc *pp;
+       struct wwvunit *up;
+       struct chan *cp;
+       struct sync *sp, *rp;
+       char    tbuf[80];       /* monitor buffer */
+       int     sw, arg, nsec;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+       if (!iniflg) {
+               iniflg = 1;
+               memset((char *)bitvec, 0, sizeof(bitvec));
+       }
+
+       /*
+        * The bit represents the probability of a hit on zero (negative
+        * values), a hit on one (positive values) or a miss (zero
+        * value). The likelihood vector is the exponential average of
+        * these probabilities. Only the bits of this vector
+        * corresponding to the miscellaneous bits of the timecode are
+        * used, but it's easier to do them all. After that, crank the
+        * seconds state machine.
+        */
+       nsec = up->rsec;
+       up->rsec++;
+       bitvec[nsec] += (bit - bitvec[nsec]) / TCONST;
+       sw = progx[nsec].sw;
+       arg = progx[nsec].arg;
+
+       /*
+        * The minute state machine. Fly off to a particular section as
+        * directed by the transition matrix and second number.
+        */
+       switch (sw) {
+
+       /*
+        * Ignore this second.
+        */
+       case IDLE:                      /* 9, 45-49 */
+               break;
+
+       /*
+        * Probe channel stuff
+        *
+        * The WWV/H format contains data pulses in second 59 (position
+        * identifier) and second 1, but not in second 0. The minute
+        * sync pulse is contained in second 0. At the end of second 58
+        * QSY to the probe channel, which rotates in turn over all
+        * WWV/H frequencies. At the end of second 0 measure the minute
+        * sync pulse. At the end of second 1 measure the data pulse and
+        * QSY back to the data channel. Note that the actions commented
+        * here happen at the end of the second numbered as shown.
+        *
+        * At the end of second 0 save the minute sync amplitude latched
+        * at 800 ms as the signal later used to calculate the SNR. 
+        */
+       case SYNC2:                     /* 0 */
+               cp = &up->mitig[up->achan];
+               cp->wwv.synmax = cp->wwv.syneng;
+               cp->wwvh.synmax = cp->wwvh.syneng;
+               break;
+
+       /*
+        * At the end of second 1 use the minute sync amplitude latched
+        * at 800 ms as the noise to calculate the SNR. If the minute
+        * sync pulse and SNR are above thresholds and the data pulse
+        * amplitude and SNR are above thresolds, shift a 1 into the
+        * station reachability register; otherwise, shift a 0. The
+        * number of 1 bits in the last six intervals is a component of
+        * the channel metric computed by the wwv_metric() routine.
+        * Finally, QSY back to the data channel.
+        */
+       case SYNC3:                     /* 1 */
+               cp = &up->mitig[up->achan];
+
+               /*
+                * WWV station
+                */
+               sp = &cp->wwv;
+               sp->synsnr = wwv_snr(sp->synmax, sp->amp);
+               sp->reach <<= 1;
+               if (sp->reach & (1 << AMAX))
+                       sp->count--;
+               if (sp->synmax >= QTHR && sp->synsnr >= QSNR &&
+                   !(up->status & (DGATE | BGATE))) {
+                       sp->reach |= 1;
+                       sp->count++;
+               }
+               sp->metric = wwv_metric(sp);
+
+               /*
+                * WWVH station
+                */
+               rp = &cp->wwvh;
+               rp->synsnr = wwv_snr(rp->synmax, rp->amp);
+               rp->reach <<= 1;
+               if (rp->reach & (1 << AMAX))
+                       rp->count--;
+               if (rp->synmax >= QTHR && rp->synsnr >= QSNR &&
+                   !(up->status & (DGATE | BGATE))) {
+                       rp->reach |= 1;
+                       rp->count++;
+               }
+               rp->metric = wwv_metric(rp);
+               if (pp->sloppyclockflag & CLK_FLAG4) {
+                       sprintf(tbuf,
+                           "wwv5 %04x %3d %4d %.0f/%.1f %.0f/%.1f %s %04x %.0f %.0f/%.1f %s %04x %.0f %.0f/%.1f",
+                           up->status, up->gain, up->yepoch,
+                           up->epomax, up->eposnr, up->datsig,
+                           up->datsnr,
+                           sp->refid, sp->reach & 0xffff,
+                           sp->metric, sp->synmax, sp->synsnr,
+                           rp->refid, rp->reach & 0xffff,
+                           rp->metric, rp->synmax, rp->synsnr);
+                       record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+                       if (debug)
+                               printf("%s\n", tbuf);
+#endif /* DEBUG */
+               }
+               up->errcnt = up->digcnt = up->alarm = 0;
+
+               /*
+                * We now begin the minute scan. If not yet synchronized
+                * to a station, restart if the units digit has not been
+                * found within the DATA timeout (15 m) or if not
+                * synchronized within the SYNCH timeout (40 m). After
+                * synchronizing to a station, restart if no stations
+                * are found within the PANIC timeout (2 days).
+                */
+               if (up->status & INSYNC) {
+                       if (up->watch > PANIC) {
+                               wwv_newgame(peer);
+                               return;
+                       }
+               } else {
+                       if (!(up->status & DSYNC)) {
+                               if (up->watch > DATA) {
+                                       wwv_newgame(peer);
+                                       return;
+                               }
+                       }
+                       if (up->watch > SYNCH) {
+                               wwv_newgame(peer);
+                               return;
+                       }
+               }
+               wwv_newchan(peer);
+#ifdef ICOM
+               if (up->fd_icom > 0)
+                       wwv_qsy(peer, up->dchan);
+#endif /* ICOM */
+               break;
+
+       /*
+        * Save the bit probability in the BCD data vector at the index
+        * given by the argument. Bits not used in the digit are forced
+        * to zero.
+        */
+       case COEF1:                     /* 4-7 */ 
+               bcddld[arg] = bit;
+               break;
+
+       case COEF:                      /* 10-13, 15-17, 20-23, 25-26,
+                                          30-33, 35-38, 40-41, 51-54 */
+               if (up->status & DSYNC) 
+                       bcddld[arg] = bit;
+               else
+                       bcddld[arg] = 0;
+               break;
+
+       case COEF2:                     /* 18, 27-28, 42-43 */
+               bcddld[arg] = 0;
+               break;
+
+       /*
+        * Correlate coefficient vector with each valid digit vector and
+        * save in decoding matrix. We step through the decoding matrix
+        * digits correlating each with the coefficients and saving the
+        * greatest and the next lower for later SNR calculation.
+        */
+       case DECIM2:                    /* 29 */
+               wwv_corr4(peer, &up->decvec[arg], bcddld, bcd2);
+               break;
+
+       case DECIM3:                    /* 44 */
+               wwv_corr4(peer, &up->decvec[arg], bcddld, bcd3);
+               break;
+
+       case DECIM6:                    /* 19 */
+               wwv_corr4(peer, &up->decvec[arg], bcddld, bcd6);
+               break;
+
+       case DECIM9:                    /* 8, 14, 24, 34, 39 */
+               wwv_corr4(peer, &up->decvec[arg], bcddld, bcd9);
+               break;
+
+       /*
+        * Miscellaneous bits. If above the positive threshold, declare
+        * 1; if below the negative threshold, declare 0; otherwise
+        * raise the BGATE bit. The design is intended to avoid
+        * integrating noise under low SNR conditions.
+        */
+       case MSC20:                     /* 55 */
+               wwv_corr4(peer, &up->decvec[YR + 1], bcddld, bcd9);
+               /* fall through */
+
+       case MSCBIT:                    /* 2-3, 50, 56-57 */
+               if (bitvec[nsec] > BTHR) {
+                       if (!(up->misc & arg))
+                               up->alarm |= CMPERR;
+                       up->misc |= arg;
+               } else if (bitvec[nsec] < -BTHR) {
+                       if (up->misc & arg)
+                               up->alarm |= CMPERR;
+                       up->misc &= ~arg;
+               } else {
+                       up->status |= BGATE;
+               }
+               break;
+
+       /*
+        * Save the data channel gain, then QSY to the probe channel and
+        * dim the seconds comb filters. The newchan() routine will
+        * light them back up.
+        */
+       case MSC21:                     /* 58 */
+               if (bitvec[nsec] > BTHR) {
+                       if (!(up->misc & arg))
+                               up->alarm |= CMPERR;
+                       up->misc |= arg;
+               } else if (bitvec[nsec] < -BTHR) {
+                       if (up->misc & arg)
+                               up->alarm |= CMPERR;
+                       up->misc &= ~arg;
+               } else {
+                       up->status |= BGATE;
+               }
+               up->status &= ~(SELV | SELH);
+#ifdef ICOM
+               if (up->fd_icom > 0) {
+                       up->schan = (up->schan + 1) % NCHAN;
+                       wwv_qsy(peer, up->schan);
+               } else {
+                       up->mitig[up->achan].gain = up->gain;
+               }
+#else
+               up->mitig[up->achan].gain = up->gain;
+#endif /* ICOM */
+               break;
+
+       /*
+        * The endgames
+        *
+        * During second 59 the receiver and codec AGC are settling
+        * down, so the data pulse is unusable as quality metric. If
+        * LEPSEC is set on the last minute of 30 June or 31 December,
+        * the transmitter and receiver insert an extra second (60) in
+        * the timescale and the minute sync repeats the second. Once
+        * leaps occurred at intervals of about 18 months, but the last
+        * leap before the most recent leap in 1995 was in  1998.
+        */
+       case MIN1:                      /* 59 */
+               if (up->status & LEPSEC)
+                       break;
+
+               /* fall through */
+
+       case MIN2:                      /* 60 */
+               up->status &= ~LEPSEC;
+               wwv_tsec(peer);
+               up->rsec = 0;
+               wwv_clock(peer);
+               break;
+       }
+       if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status &
+           DSYNC)) {
+               sprintf(tbuf,
+                   "wwv3 %2d %04x %3d %4d %5.0f %5.1f %5.0f %5.1f %5.0f",
+                   nsec, up->status, up->gain, up->yepoch, up->epomax,
+                   up->eposnr, up->datsig, up->datsnr, bit);
+               record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+               if (debug)
+                       printf("%s\n", tbuf);
+#endif /* DEBUG */
+       }
+       pp->disp += AUDIO_PHI;
+}
+
+/*
+ * The radio clock is set if the alarm bits are all zero. After that,
+ * the time is considered valid if the second sync bit is lit. It should
+ * not be a surprise, especially if the radio is not tunable, that
+ * sometimes no stations are above the noise and the integrators
+ * discharge below the thresholds. We assume that, after a day of signal
+ * loss, the minute sync epoch will be in the same second. This requires
+ * the codec frequency be accurate within 6 PPM. Practical experience
+ * shows the frequency typically within 0.1 PPM, so after a day of
+ * signal loss, the time should be within 8.6 ms.. 
+ */
+static void
+wwv_clock(
+       struct peer *peer       /* peer unit pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+       l_fp    offset;         /* offset in NTP seconds */
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+       if (!(up->status & SSYNC))
+               up->alarm |= SYNERR;
+       if (up->digcnt < 9)
+               up->alarm |= NINERR;
+       if (!(up->alarm))
+               up->status |= INSYNC;
+       if (up->status & INSYNC && up->status & SSYNC) {
+               if (up->misc & SECWAR)
+                       pp->leap = LEAP_ADDSECOND;
+               else
+                       pp->leap = LEAP_NOWARNING;
+               pp->second = up->rsec;
+               pp->minute = up->decvec[MN].digit + up->decvec[MN +
+                   1].digit * 10;
+               pp->hour = up->decvec[HR].digit + up->decvec[HR +
+                   1].digit * 10;
+               pp->day = up->decvec[DA].digit + up->decvec[DA +
+                   1].digit * 10 + up->decvec[DA + 2].digit * 100;
+               pp->year = up->decvec[YR].digit + up->decvec[YR +
+                   1].digit * 10;
+               pp->year += 2000;
+               L_CLR(&offset);
+               if (!clocktime(pp->day, pp->hour, pp->minute,
+                   pp->second, GMT, up->timestamp.l_ui,
+                   &pp->yearstart, &offset.l_ui)) {
+                       up->errflg = CEVNT_BADTIME;
+               } else {
+                       up->watch = 0;
+                       pp->disp = 0;
+                       pp->lastref = up->timestamp;
+                       refclock_process_offset(pp, offset,
+                           up->timestamp, PDELAY);
+                       refclock_receive(peer);
+               }
+       }
+       pp->lencode = timecode(up, pp->a_lastcode);
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+       if (debug)
+               printf("wwv: timecode %d %s\n", pp->lencode,
+                   pp->a_lastcode);
+#endif /* DEBUG */
+}
+
+
+/*
+ * wwv_corr4 - determine maximum likelihood digit
+ *
+ * This routine correlates the received digit vector with the BCD
+ * coefficient vectors corresponding to all valid digits at the given
+ * position in the decoding matrix. The maximum value corresponds to the
+ * maximum likelihood digit, while the ratio of this value to the next
+ * lower value determines the likelihood function. Note that, if the
+ * digit is invalid, the likelihood vector is averaged toward a miss.
+ */
+static void
+wwv_corr4(
+       struct peer *peer,      /* peer unit pointer */
+       struct decvec *vp,      /* decoding table pointer */
+       double  data[],         /* received data vector */
+       double  tab[][4]        /* correlation vector array */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+       double  topmax, nxtmax; /* metrics */
+       double  acc;            /* accumulator */
+       char    tbuf[80];       /* monitor buffer */
+       int     mldigit;        /* max likelihood digit */
+       int     i, j;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+
+       /*
+        * Correlate digit vector with each BCD coefficient vector. If
+        * any BCD digit bit is bad, consider all bits a miss. Until the
+        * minute units digit has been resolved, don't to anything else.
+        * Note the SNR is calculated as the ratio of the largest
+        * likelihood value to the next largest likelihood value.
+        */
+       mldigit = 0;
+       topmax = nxtmax = -MAXAMP;
+       for (i = 0; tab[i][0] != 0; i++) {
+               acc = 0;
+               for (j = 0; j < 4; j++)
+                       acc += data[j] * tab[i][j];
+               acc = (vp->like[i] += (acc - vp->like[i]) / TCONST);
+               if (acc > topmax) {
+                       nxtmax = topmax;
+                       topmax = acc;
+                       mldigit = i;
+               } else if (acc > nxtmax) {
+                       nxtmax = acc;
+               }
+       }
+       vp->digprb = topmax;
+       vp->digsnr = wwv_snr(topmax, nxtmax);
+
+       /*
+        * The current maximum likelihood digit is compared to the last
+        * maximum likelihood digit. If different, the compare counter
+        * and maximum likelihood digit are reset.  When the compare
+        * counter reaches the BCMP threshold (3), the digit is assumed
+        * correct. When the compare counter of all nine digits have
+        * reached threshold, the clock is assumed correct.
+        *
+        * Note that the clock display digit is set before the compare
+        * counter has reached threshold; however, the clock display is
+        * not considered correct until all nine clock digits have
+        * reached threshold. This is intended as eye candy, but avoids
+        * mistakes when the signal is low and the SNR is very marginal.
+        * once correctly set, the maximum likelihood digit is ignored
+        * on the assumption the clock will always be correct unless for
+        * some reason it drifts to a different second.
+        */
+       vp->mldigit = mldigit;
+       if (vp->digprb < BTHR || vp->digsnr < BSNR) {
+               vp->count = 0;
+               up->status |= BGATE;
+       } else {
+               up->status |= DSYNC;
+               if (vp->digit != mldigit) {
+                       vp->count = 0;
+                       up->alarm |= CMPERR;
+                       if (!(up->status & INSYNC))
+                               vp->digit = mldigit;
+               } else {
+                       if (vp->count < BCMP)
+                               vp->count++;
+                       else
+                               up->digcnt++;
+               }
+       }
+       if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status &
+           INSYNC)) {
+               sprintf(tbuf,
+                   "wwv4 %2d %04x %3d %4d %5.0f %2d %d %d %d %5.0f %5.1f",
+                   up->rsec - 1, up->status, up->gain, up->yepoch,
+                   up->epomax, vp->radix, vp->digit, vp->mldigit,
+                   vp->count, vp->digprb, vp->digsnr);
+               record_clock_stats(&peer->srcadr, tbuf);
+#ifdef DEBUG
+               if (debug)
+                       printf("%s\n", tbuf);
+#endif /* DEBUG */
+       }
+}
+
+
+/*
+ * wwv_tsec - transmitter minute processing
+ *
+ * This routine is called at the end of the transmitter minute. It
+ * implements a state machine that advances the logical clock subject to
+ * the funny rules that govern the conventional clock and calendar.
+ */
+static void
+wwv_tsec(
+       struct peer *peer       /* driver structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+       int minute, day, isleap;
+       int temp;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+
+       /*
+        * Advance minute unit of the day. Don't propagate carries until
+        * the unit minute digit has been found.
+        */
+       temp = carry(&up->decvec[MN]);  /* minute units */
+       if (!(up->status & DSYNC))
+               return;
+
+       /*
+        * Propagate carries through the day.
+        */ 
+       if (temp == 0)                  /* carry minutes */
+               temp = carry(&up->decvec[MN + 1]);
+       if (temp == 0)                  /* carry hours */
+               temp = carry(&up->decvec[HR]);
+       if (temp == 0)
+               temp = carry(&up->decvec[HR + 1]);
+
+       /*
+        * Decode the current minute and day. Set leap day if the
+        * timecode leap bit is set on 30 June or 31 December. Set leap
+        * minute if the last minute on leap day, but only if the clock
+        * is syncrhronized. This code fails in 2400 AD.
+        */
+       minute = up->decvec[MN].digit + up->decvec[MN + 1].digit *
+           10 + up->decvec[HR].digit * 60 + up->decvec[HR +
+           1].digit * 600;
+       day = up->decvec[DA].digit + up->decvec[DA + 1].digit * 10 +
+           up->decvec[DA + 2].digit * 100;
+
+       /*
+        * Set the leap bit on the last minute of the leap day.
+        */
+       isleap = up->decvec[YR].digit & 0x3;
+       if (up->misc & SECWAR && up->status & INSYNC) {
+               if ((day == (isleap ? 182 : 183) || day == (isleap ?
+                   365 : 366)) && minute == 1439)
+                       up->status |= LEPSEC;
+       }
+
+       /*
+        * Roll the day if this the first minute and propagate carries
+        * through the year.
+        */
+       if (minute != 1440)
+               return;
+
+       minute = 0;
+       while (carry(&up->decvec[HR]) != 0); /* advance to minute 0 */
+       while (carry(&up->decvec[HR + 1]) != 0);
+       day++;
+       temp = carry(&up->decvec[DA]);  /* carry days */
+       if (temp == 0)
+               temp = carry(&up->decvec[DA + 1]);
+       if (temp == 0)
+               temp = carry(&up->decvec[DA + 2]);
+
+       /*
+        * Roll the year if this the first day and propagate carries
+        * through the century.
+        */
+       if (day != (isleap ? 365 : 366))
+               return;
+
+       day = 1;
+       while (carry(&up->decvec[DA]) != 1); /* advance to day 1 */
+       while (carry(&up->decvec[DA + 1]) != 0);
+       while (carry(&up->decvec[DA + 2]) != 0);
+       temp = carry(&up->decvec[YR]);  /* carry years */
+       if (temp == 0)
+               carry(&up->decvec[YR + 1]);
+}
+
+
+/*
+ * carry - process digit
+ *
+ * This routine rotates a likelihood vector one position and increments
+ * the clock digit modulo the radix. It returns the new clock digit or
+ * zero if a carry occurred. Once synchronized, the clock digit will
+ * match the maximum likelihood digit corresponding to that position.
+ */
+static int
+carry(
+       struct decvec *dp       /* decoding table pointer */
+       )
+{
+       int temp;
+       int j;
+
+       dp->digit++;
+       if (dp->digit == dp->radix)
+               dp->digit = 0;
+       temp = dp->like[dp->radix - 1];
+       for (j = dp->radix - 1; j > 0; j--)
+               dp->like[j] = dp->like[j - 1];
+       dp->like[0] = temp;
+       return (dp->digit);
+}
+
+
+/*
+ * wwv_snr - compute SNR or likelihood function
+ */
+static double
+wwv_snr(
+       double signal,          /* signal */
+       double noise            /* noise */
+       )
+{
+       double rval;
+
+       /*
+        * This is a little tricky. Due to the way things are measured,
+        * either or both the signal or noise amplitude can be negative
+        * or zero. The intent is that, if the signal is negative or
+        * zero, the SNR must always be zero. This can happen with the
+        * subcarrier SNR before the phase has been aligned. On the
+        * other hand, in the likelihood function the "noise" is the
+        * next maximum down from the peak and this could be negative.
+        * However, in this case the SNR is truly stupendous, so we
+        * simply cap at MAXSNR dB (40).
+        */
+       if (signal <= 0) {
+               rval = 0;
+       } else if (noise <= 0) {
+               rval = MAXSNR;
+       } else {
+               rval = 20. * log10(signal / noise);
+               if (rval > MAXSNR)
+                       rval = MAXSNR;
+       }
+       return (rval);
+}
+
+
+/*
+ * wwv_newchan - change to new data channel
+ *
+ * The radio actually appears to have ten channels, one channel for each
+ * of five frequencies and each of two stations (WWV and WWVH), although
+ * if not tunable only the DCHAN channel appears live. While the radio
+ * is tuned to the working data channel frequency and station for most
+ * of the minute, during seconds 59, 0 and 1 the radio is tuned to a
+ * probe frequency in order to search for minute sync pulse and data
+ * subcarrier from other transmitters.
+ *
+ * The search for WWV and WWVH operates simultaneously, with WWV minute
+ * sync pulse at 1000 Hz and WWVH at 1200 Hz. The probe frequency
+ * rotates each minute over 2.5, 5, 10, 15 and 20 MHz in order and yes,
+ * we all know WWVH is dark on 20 MHz, but few remember when WWV was lit
+ * on 25 MHz.
+ *
+ * This routine selects the best channel using a metric computed from
+ * the reachability register and minute pulse amplitude. Normally, the
+ * award goes to the the channel with the highest metric; but, in case
+ * of ties, the award goes to the channel with the highest minute sync
+ * pulse amplitude and then to the highest frequency.
+ *
+ * The routine performs an important squelch function to keep dirty data
+ * from polluting the integrators. In order to consider a station valid,
+ * the metric must be at least MTHR (13); otherwise, the station select
+ * bits are cleared so the second sync is disabled and the data bit
+ * integrators averaged to a miss. 
+ */
+static int
+wwv_newchan(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+       struct sync *sp, *rp;
+       double rank, dtemp;
+       int i, j;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+
+       /*
+        * Search all five station pairs looking for the channel with
+        * maximum metric. If no station is found above thresholds, tune
+        * to WWV on 15 MHz, set the reference ID to NONE and wait for
+        * hotter ions.
+        */
+       sp = NULL;
+       j = 0;
+       rank = 0;
+       for (i = 0; i < NCHAN; i++) {
+               rp = &up->mitig[i].wwvh;
+               dtemp = rp->metric;
+               if (dtemp >= rank) {
+                       rank = dtemp;
+                       sp = rp;
+                       j = i;
+               }
+               rp = &up->mitig[i].wwv;
+               dtemp = rp->metric;
+               if (dtemp >= rank) {
+                       rank = dtemp;
+                       sp = rp;
+                       j = i;
+               }
+       }
+
+       /*
+        * If the strongest signal is less than the MTHR threshold (13),
+        * we are beneath the waves, so squelch the second sync. If the
+        * strongest signal is greater than the threshold, tune to that
+        * frequency and transmitter QTH.
+        */
+       if (rank < MTHR) {
+               up->dchan = (up->dchan + 1) % NCHAN;
+               up->status &= ~(SELV | SELH);
+               return (FALSE);
+       }
+       up->dchan = j;
+       up->status |= SELV | SELH;
+       up->sptr = sp;
+       memcpy(&pp->refid, sp->refid, 4);
+       peer->refid = pp->refid;
+       return (TRUE);
+}
+
+
+/*
+ * wwv_newgame - reset and start over
+ *
+ * There are four conditions resulting in a new game:
+ *
+ * 1   During initial acquisition (MSYNC dark) going 6 minutes (ACQSN)
+ *     without reliably finding the minute pulse (MSYNC lit).
+ *
+ * 2   After finding the minute pulse (MSYNC lit), going 15 minutes
+ *     (DATA) without finding the unit seconds digit.
+ *
+ * 3   After finding good data (DATA lit), going more than 40 minutes
+ *     (SYNCH) without finding station sync (INSYNC lit).
+ *
+ * 4   After finding station sync (INSYNC lit), going more than 2 days
+ *     (PANIC) without finding any station. 
+ */
+static void
+wwv_newgame(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+       struct chan *cp;
+       int i;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+
+       /*
+        * Initialize strategic values. Note we set the leap bits
+        * NOTINSYNC and the refid "NONE".
+        */
+       peer->leap = LEAP_NOTINSYNC;
+       up->watch = up->status = up->alarm = 0;
+       up->avgint = MINAVG;
+       up->freq = 0;
+       up->gain = MAXGAIN / 2;
+
+       /*
+        * Initialize the station processes for audio gain, select bit,
+        * station/frequency identifier and reference identifier. Start
+        * probing at the next channel after the data channel.
+        */
+       memset(up->mitig, 0, sizeof(up->mitig));
+       for (i = 0; i < NCHAN; i++) {
+               cp = &up->mitig[i];
+               cp->gain = up->gain;
+               cp->wwv.select = SELV;
+               sprintf(cp->wwv.refid, "WV%.0f", floor(qsy[i])); 
+               cp->wwvh.select = SELH;
+               sprintf(cp->wwvh.refid, "WH%.0f", floor(qsy[i])); 
+       }
+       up->dchan = (DCHAN + NCHAN - 1) % NCHAN;;
+       wwv_newchan(peer);
+       up->achan = up->schan = up->dchan;
+#ifdef ICOM
+       if (up->fd_icom > 0)
+               wwv_qsy(peer, up->dchan);
+#endif /* ICOM */
+}
+
+/*
+ * wwv_metric - compute station metric
+ *
+ * The most significant bits represent the number of ones in the
+ * station reachability register. The least significant bits represent
+ * the minute sync pulse amplitude. The combined value is scaled 0-100.
+ */
+double
+wwv_metric(
+       struct sync *sp         /* station pointer */
+       )
+{
+       double  dtemp;
+
+       dtemp = sp->count * MAXAMP;
+       if (sp->synmax < MAXAMP)
+               dtemp += sp->synmax;
+       else
+               dtemp += MAXAMP - 1;
+       dtemp /= (AMAX + 1) * MAXAMP;
+       return (dtemp * 100.);
+}
+
+
+#ifdef ICOM
+/*
+ * wwv_qsy - Tune ICOM receiver
+ *
+ * This routine saves the AGC for the current channel, switches to a new
+ * channel and restores the AGC for that channel. If a tunable receiver
+ * is not available, just fake it.
+ */
+static int
+wwv_qsy(
+       struct peer *peer,      /* peer structure pointer */
+       int     chan            /* channel */
+       )
+{
+       int rval = 0;
+       struct refclockproc *pp;
+       struct wwvunit *up;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+       if (up->fd_icom > 0) {
+               up->mitig[up->achan].gain = up->gain;
+               rval = icom_freq(up->fd_icom, peer->ttl & 0x7f,
+                   qsy[chan]);
+               up->achan = chan;
+               up->gain = up->mitig[up->achan].gain;
+       }
+       return (rval);
+}
+#endif /* ICOM */
+
+
+/*
+ * timecode - assemble timecode string and length
+ *
+ * Prettytime format - similar to Spectracom
+ *
+ * sq yy ddd hh:mm:ss ld dut lset agc iden sig errs freq avgt
+ *
+ * s   sync indicator ('?' or ' ')
+ * q   error bits (hex 0-F)
+ * yyyy        year of century
+ * ddd day of year
+ * hh  hour of day
+ * mm  minute of hour
+ * ss  second of minute)
+ * l   leap second warning (' ' or 'L')
+ * d   DST state ('S', 'D', 'I', or 'O')
+ * dut DUT sign and magnitude (0.1 s)
+ * lset        minutes since last clock update
+ * agc audio gain (0-255)
+ * iden        reference identifier (station and frequency)
+ * sig signal quality (0-100)
+ * errs        bit errors in last minute
+ * freq        frequency offset (PPM)
+ * avgt        averaging time (s)
+ */
+static int
+timecode(
+       struct wwvunit *up,     /* driver structure pointer */
+       char *ptr               /* target string */
+       )
+{
+       struct sync *sp;
+       int year, day, hour, minute, second, dut;
+       char synchar, leapchar, dst;
+       char cptr[50];
+       
+
+       /*
+        * Common fixed-format fields
+        */
+       synchar = (up->status & INSYNC) ? ' ' : '?';
+       year = up->decvec[YR].digit + up->decvec[YR + 1].digit * 10 +
+           2000;
+       day = up->decvec[DA].digit + up->decvec[DA + 1].digit * 10 +
+           up->decvec[DA + 2].digit * 100;
+       hour = up->decvec[HR].digit + up->decvec[HR + 1].digit * 10;
+       minute = up->decvec[MN].digit + up->decvec[MN + 1].digit * 10;
+       second = 0;
+       leapchar = (up->misc & SECWAR) ? 'L' : ' ';
+       dst = dstcod[(up->misc >> 4) & 0x3];
+       dut = up->misc & 0x7;
+       if (!(up->misc & DUTS))
+               dut = -dut;
+       sprintf(ptr, "%c%1X", synchar, up->alarm);
+       sprintf(cptr, " %4d %03d %02d:%02d:%02d %c%c %+d",
+           year, day, hour, minute, second, leapchar, dst, dut);
+       strcat(ptr, cptr);
+
+       /*
+        * Specific variable-format fields
+        */
+       sp = up->sptr;
+       sprintf(cptr, " %d %d %s %.0f %d %.1f %d", up->watch,
+           up->mitig[up->dchan].gain, sp->refid, sp->metric,
+           up->errcnt, up->freq / SECOND * 1e6, up->avgint);
+       strcat(ptr, cptr);
+       return (strlen(ptr));
+}
+
+
+/*
+ * wwv_gain - adjust codec gain
+ *
+ * This routine is called at the end of each second. During the second
+ * the number of signal clips above the MAXAMP threshold (6000). If
+ * there are no clips, the gain is bumped up; if there are more than
+ * MAXCLP clips (100), it is bumped down. The decoder is relatively
+ * insensitive to amplitude, so this crudity works just peachy. The
+ * input port is set and the error flag is cleared, mostly to be ornery.
+ */
+static void
+wwv_gain(
+       struct peer *peer       /* peer structure pointer */
+       )
+{
+       struct refclockproc *pp;
+       struct wwvunit *up;
+
+       pp = peer->procptr;
+       up = (struct wwvunit *)pp->unitptr;
+
+       /*
+        * Apparently, the codec uses only the high order bits of the
+        * gain control field. Thus, it may take awhile for changes to
+        * wiggle the hardware bits.
+        */
+       if (up->clipcnt == 0) {
+               up->gain += 4;
+               if (up->gain > MAXGAIN)
+                       up->gain = MAXGAIN;
+       } else if (up->clipcnt > MAXCLP) {
+               up->gain -= 4;
+               if (up->gain < 0)
+                       up->gain = 0;
+       }
+       audio_gain(up->gain, up->mongain, up->port);
+       up->clipcnt = 0;
+#if DEBUG
+       if (debug > 1)
+               audio_show();
+#endif
+}
+
+
+#else
+int refclock_wwv_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_wwvb.c b/ntpd/refclock_wwvb.c
new file mode 100644 (file)
index 0000000..7bddd3a
--- /dev/null
@@ -0,0 +1,459 @@
+/*
+ * refclock_wwvb - clock driver for Spectracom WWVB and GPS receivers
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_SPECTRACOM)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+/*
+ * This driver supports the Spectracom Model 8170 and Netclock/2 WWVB
+ * Synchronized Clocks and the Netclock/GPS Master Clock. Both the WWVB
+ * and GPS clocks have proven reliable sources of time; however, the
+ * WWVB clocks have proven vulnerable to high ambient conductive RF
+ * interference. The claimed accuracy of the WWVB clocks is 100 us
+ * relative to the broadcast signal, while the claimed accuracy of the
+ * GPS clock is 50 ns; however, in most cases the actual accuracy is
+ * limited by the resolution of the timecode and the latencies of the
+ * serial interface and operating system.
+ *
+ * The WWVB and GPS clocks should be configured for 24-hour display,
+ * AUTO DST off, time zone 0 (UTC), data format 0 or 2 (see below) and
+ * baud rate 9600. If the clock is to used as the source for the IRIG
+ * Audio Decoder (refclock_irig.c in this distribution), it should be
+ * configured for AM IRIG output and IRIG format 1 (IRIG B with
+ * signature control). The GPS clock can be configured either to respond
+ * to a 'T' poll character or left running continuously. 
+ *
+ * There are two timecode formats used by these clocks. Format 0, which
+ * is available with both the Netclock/2 and 8170, and format 2, which
+ * is available only with the Netclock/2, specially modified 8170 and
+ * GPS.
+ *
+ * Format 0 (22 ASCII printing characters):
+ *
+ * <cr><lf>i  ddd hh:mm:ss TZ=zz<cr><lf>
+ *
+ *     on-time = first <cr>
+ *     hh:mm:ss = hours, minutes, seconds
+ *     i = synchronization flag (' ' = in synch, '?' = out of synch)
+ *
+ * The alarm condition is indicated by other than ' ' at a, which occurs
+ * during initial synchronization and when received signal is lost for
+ * about ten hours.
+ *
+ * Format 2 (24 ASCII printing characters):
+ *
+ * <cr><lf>iqyy ddd hh:mm:ss.fff ld
+ *
+ *     on-time = <cr>
+ *     i = synchronization flag (' ' = in synch, '?' = out of synch)
+ *     q = quality indicator (' ' = locked, 'A'...'D' = unlocked)
+ *     yy = year (as broadcast)
+ *     ddd = day of year
+ *     hh:mm:ss.fff = hours, minutes, seconds, milliseconds
+ *
+ * The alarm condition is indicated by other than ' ' at a, which occurs
+ * during initial synchronization and when received signal is lost for
+ * about ten hours. The unlock condition is indicated by other than ' '
+ * at q.
+ *
+ * The q is normally ' ' when the time error is less than 1 ms and a
+ * character in the set 'A'...'D' when the time error is less than 10,
+ * 100, 500 and greater than 500 ms respectively. The l is normally ' ',
+ * but is set to 'L' early in the month of an upcoming UTC leap second
+ * and reset to ' ' on the first day of the following month. The d is
+ * set to 'S' for standard time 'I' on the day preceding a switch to
+ * daylight time, 'D' for daylight time and 'O' on the day preceding a
+ * switch to standard time. The start bit of the first <cr> is
+ * synchronized to the indicated time as returned.
+ *
+ * This driver does not need to be told which format is in use - it
+ * figures out which one from the length of the message. The driver
+ * makes no attempt to correct for the intrinsic jitter of the radio
+ * itself, which is a known problem with the older radios.
+ *
+ * Fudge Factors
+ *
+ * This driver can retrieve a table of quality data maintained
+ * internally by the Netclock/2 clock. If flag4 of the fudge
+ * configuration command is set to 1, the driver will retrieve this
+ * table and write it to the clockstats file when the first timecode
+ * message of a new day is received.
+ *
+ * PPS calibration fudge time 1: format 0 .003134, format 2 .004034
+ */
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/wwvb%d" /* device name and unit */
+#define        SPEED232        B9600   /* uart speed (9600 baud) */
+#define        PRECISION       (-13)   /* precision assumed (about 100 us) */
+#define        REFID           "WWVB"  /* reference ID */
+#define        DESCRIPTION     "Spectracom WWVB/GPS Receiver" /* WRU */
+
+#define        LENWWVB0        22      /* format 0 timecode length */
+#define LENWWVB1       22      /* format 1 timecode length */
+#define        LENWWVB2        24      /* format 2 timecode length */
+#define LENWWVB3        29      /* format 3 timecode length */
+#define MONLIN         15      /* number of monitoring lines */
+
+/*
+ * WWVB unit control structure
+ */
+struct wwvbunit {
+       l_fp    laststamp;      /* last receive timestamp */
+       u_char  lasthour;       /* last hour (for monitor) */
+       u_char  linect;         /* count ignored lines (for monitor */
+};
+
+/*
+ * Function prototypes
+ */
+static int     wwvb_start      P((int, struct peer *));
+static void    wwvb_shutdown   P((int, struct peer *));
+static void    wwvb_receive    P((struct recvbuf *));
+static void    wwvb_poll       P((int, struct peer *));
+static void    wwvb_timer      P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_wwvb = {
+       wwvb_start,             /* start up driver */
+       wwvb_shutdown,          /* shut down driver */
+       wwvb_poll,              /* transmit poll message */
+       noentry,                /* not used (old wwvb_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old wwvb_buginfo) */
+       wwvb_timer              /* called once per second */
+};
+
+
+/*
+ * wwvb_start - open the devices and initialize data for processing
+ */
+static int
+wwvb_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct wwvbunit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+
+       /*
+        * Open serial port. Use CLK line discipline, if available.
+        */
+       sprintf(device, DEVICE, unit);
+       if (!(fd = refclock_open(device, SPEED232, LDISC_CLK)))
+               return (0);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct wwvbunit *)
+             emalloc(sizeof(struct wwvbunit)))) {
+               close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct wwvbunit));
+       pp = peer->procptr;
+       pp->unitptr = (caddr_t)up;
+       pp->io.clock_recv = wwvb_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               close(fd);
+               free(up);
+               return (0);
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       return (1);
+}
+
+
+/*
+ * wwvb_shutdown - shut down the clock
+ */
+static void
+wwvb_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct wwvbunit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct wwvbunit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * wwvb_receive - receive data from the serial interface
+ */
+static void
+wwvb_receive(
+       struct recvbuf *rbufp
+       )
+{
+       struct wwvbunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+
+       l_fp    trtmp;          /* arrival timestamp */
+       int     tz;             /* time zone */
+       int     day, month;     /* ddd conversion */
+       int     temp;           /* int temp */
+       char    syncchar;       /* synchronization indicator */
+       char    qualchar;       /* quality indicator */
+       char    leapchar;       /* leap indicator */
+       char    dstchar;        /* daylight/standard indicator */
+       char    tmpchar;        /* trashbin */
+
+       /*
+        * Initialize pointers and read the timecode and timestamp
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct wwvbunit *)pp->unitptr;
+       temp = refclock_gtlin(rbufp, pp->a_lastcode, BMAX, &trtmp);
+
+       /*
+        * Note we get a buffer and timestamp for both a <cr> and <lf>,
+        * but only the <cr> timestamp is retained. Note: in format 0 on
+        * a Netclock/2 or upgraded 8170 the start bit is delayed 100
+        * +-50 us relative to the pps; however, on an unmodified 8170
+        * the start bit can be delayed up to 10 ms. In format 2 the
+        * reading precision is only to the millisecond. Thus, unless
+        * you have a PPS gadget and don't have to have the year, format
+        * 0 provides the lowest jitter.
+        */
+       if (temp == 0) {
+               up->laststamp = trtmp;
+               return;
+       }
+       pp->lencode = temp;
+       pp->lastrec = up->laststamp;
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. This code uses the timecode length to determine
+        * format 0, 2 or 3. If the timecode has invalid length or is
+        * not in proper format, we declare bad format and exit.
+        */
+       syncchar = qualchar = leapchar = dstchar = ' ';
+       tz = 0;
+       switch (pp->lencode) {
+
+       case LENWWVB0:
+
+               /*
+                * Timecode format 0: "I  ddd hh:mm:ss DTZ=nn"
+                */
+               if (sscanf(pp->a_lastcode,
+                   "%c %3d %2d:%2d:%2d%c%cTZ=%2d",
+                   &syncchar, &pp->day, &pp->hour, &pp->minute,
+                   &pp->second, &tmpchar, &dstchar, &tz) == 8)
+                       pp->nsec = 0;
+                       break;
+
+       case LENWWVB2:
+
+               /*
+                * Timecode format 2: "IQyy ddd hh:mm:ss.mmm LD" */
+               if (sscanf(pp->a_lastcode,
+                   "%c%c %2d %3d %2d:%2d:%2d.%3ld %c",
+                   &syncchar, &qualchar, &pp->year, &pp->day,
+                   &pp->hour, &pp->minute, &pp->second, &pp->nsec,
+                   &leapchar) == 9)
+                       pp->nsec *= 1000000;
+                       break;
+
+       case LENWWVB3:
+
+               /*
+                * Timecode format 3: "0003I yyyymmdd hhmmss+0000SL#"
+                */
+               if (sscanf(pp->a_lastcode,
+                   "0003%c %4d%2d%2d %2d%2d%2d+0000%c%c",
+                   &syncchar, &pp->year, &month, &day, &pp->hour,
+                   &pp->minute, &pp->second, &dstchar, &leapchar) == 8)
+                   {
+                       pp->day = ymd2yd(pp->year, month, day);
+                       pp->nsec = 0;
+                       break;
+               }
+
+       default:
+
+               /*
+                * Unknown format: If dumping internal table, record
+                * stats; otherwise, declare bad format.
+                */
+               if (up->linect > 0) {
+                       up->linect--;
+                       record_clock_stats(&peer->srcadr,
+                           pp->a_lastcode);
+               } else {
+                       refclock_report(peer, CEVNT_BADREPLY);
+               }
+               return;
+       }
+
+       /*
+        * Decode synchronization, quality and leap characters. If
+        * unsynchronized, set the leap bits accordingly and exit.
+        * Otherwise, set the leap bits according to the leap character.
+        * Once synchronized, the dispersion depends only on the
+        * quality character.
+        */
+       switch (qualchar) {
+
+           case ' ':
+               pp->disp = .001;
+               pp->lastref = pp->lastrec;
+               break;
+
+           case 'A':
+               pp->disp = .01;
+               break;
+
+           case 'B':
+               pp->disp = .1;
+               break;
+
+           case 'C':
+               pp->disp = .5;
+               break;
+
+           case 'D':
+               pp->disp = MAXDISPERSE;
+               break;
+
+           default:
+               pp->disp = MAXDISPERSE;
+               refclock_report(peer, CEVNT_BADREPLY);
+               break;
+       }
+       if (syncchar != ' ')
+               pp->leap = LEAP_NOTINSYNC;
+       else if (leapchar == 'L')
+               pp->leap = LEAP_ADDSECOND;
+       else
+               pp->leap = LEAP_NOWARNING;
+
+       /*
+        * Process the new sample in the median filter and determine the
+        * timecode timestamp.
+        */
+       if (!refclock_process(pp))
+               refclock_report(peer, CEVNT_BADTIME);
+       if (peer->disp > MAXDISTANCE)
+               refclock_receive(peer);
+}
+
+
+/*
+ * wwvb_timer - called once per second by the transmit procedure
+ */
+static void
+wwvb_timer(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct wwvbunit *up;
+       struct refclockproc *pp;
+       char    pollchar;       /* character sent to clock */
+
+       /*
+        * Time to poll the clock. The Spectracom clock responds to a
+        * 'T' by returning a timecode in the format(s) specified above.
+        * Note there is no checking on state, since this may not be the
+        * only customer reading the clock. Only one customer need poll
+        * the clock; all others just listen in.
+        */
+       pp = peer->procptr;
+       up = (struct wwvbunit *)pp->unitptr;
+       if (up->linect > 0)
+               pollchar = 'R';
+       else
+               pollchar = 'T';
+       if (write(pp->io.fd, &pollchar, 1) != 1)
+               refclock_report(peer, CEVNT_FAULT);
+}
+
+
+/*
+ * wwvb_poll - called by the transmit procedure
+ */
+static void
+wwvb_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct wwvbunit *up;
+       struct refclockproc *pp;
+
+       /*
+        * Sweep up the samples received since the last poll. If none
+        * are received, declare a timeout and keep going.
+        */
+       pp = peer->procptr;
+       up = (struct wwvbunit *)pp->unitptr;
+       pp->polls++;
+
+       /*
+        * If the monitor flag is set (flag4), we dump the internal
+        * quality table at the first timecode beginning the day.
+        */
+       if (pp->sloppyclockflag & CLK_FLAG4 && pp->hour <
+           (int)up->lasthour)
+               up->linect = MONLIN;
+       up->lasthour = pp->hour;
+
+       /*
+        * Process median filter samples. If none received, declare a
+        * timeout and keep going.
+        */
+       if (pp->coderecv == pp->codeproc) {
+               refclock_report(peer, CEVNT_TIMEOUT);
+               return;
+       }
+       refclock_receive(peer);
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+#ifdef DEBUG
+       if (debug)
+               printf("wwvb: timecode %d %s\n", pp->lencode,
+                   pp->a_lastcode);
+#endif
+}
+
+#else
+int refclock_wwvb_bs;
+#endif /* REFCLOCK */
diff --git a/ntpd/refclock_zyfer.c b/ntpd/refclock_zyfer.c
new file mode 100644 (file)
index 0000000..44f2c4d
--- /dev/null
@@ -0,0 +1,346 @@
+/*
+ * refclock_zyfer - clock driver for the Zyfer GPSTarplus Clock
+ *
+ * Harlan Stenn, Jan 2002
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_ZYFER)
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+#include "ntp_unixtime.h"
+
+#include <stdio.h>
+#include <ctype.h>
+
+#ifdef HAVE_SYS_TERMIOS_H
+# include <sys/termios.h>
+#endif
+#ifdef HAVE_SYS_PPSCLOCK_H
+# include <sys/ppsclock.h>
+#endif
+
+/*
+ * This driver provides support for the TOD serial port of a Zyfer GPStarplus.
+ * This clock also provides PPS as well as IRIG outputs.
+ * Precision is limited by the serial driver, etc.
+ *
+ * If I was really brave I'd hack/generalize the serial driver to deal
+ * with arbitrary on-time characters.  This clock *begins* the stream with
+ * `!`, the on-time character, and the string is *not* EOL-terminated.
+ *
+ * Configure the beast for 9600, 8N1.  While I see leap-second stuff
+ * in the documentation, the published specs on the TOD format only show
+ * the seconds going to '59'.  I see no leap warning in the TOD format.
+ *
+ * The clock sends the following message once per second:
+ *
+ *     !TIME,2002,017,07,59,32,2,4,1
+ *           YYYY DDD HH MM SS m T O
+ *
+ *     !               On-time character
+ *     YYYY            Year
+ *     DDD     001-366 Day of Year
+ *     HH      00-23   Hour
+ *     MM      00-59   Minute
+ *     SS      00-59   Second (probably 00-60)
+ *     m       1-5     Time Mode:
+ *                     1 = GPS time
+ *                     2 = UTC time
+ *                     3 = LGPS time (Local GPS)
+ *                     4 = LUTC time (Local UTC)
+ *                     5 = Manual time
+ *     T       4-9     Time Figure Of Merit:
+ *                     4         x <= 1us
+ *                     5   1us < x <= 10 us
+ *                     6  10us < x <= 100us
+ *                     7 100us < x <= 1ms
+ *                     8   1ms < x <= 10ms
+ *                     9  10ms < x
+ *     O       0-4     Operation Mode:
+ *                     0 Warm-up
+ *                     1 Time Locked
+ *                     2 Coasting
+ *                     3 Recovering
+ *                     4 Manual
+ *
+ */
+
+/*
+ * Interface definitions
+ */
+#define        DEVICE          "/dev/zyfer%d" /* device name and unit */
+#define        SPEED232        B9600   /* uart speed (9600 baud) */
+#define        PRECISION       (-20)   /* precision assumed (about 1 us) */
+#define        REFID           "GPS\0" /* reference ID */
+#define        DESCRIPTION     "Zyfer GPStarplus" /* WRU */
+
+#define        LENZYFER        29      /* timecode length */
+
+/*
+ * Unit control structure
+ */
+struct zyferunit {
+       u_char  Rcvbuf[LENZYFER + 1];
+       u_char  polled;         /* poll message flag */
+       int     pollcnt;
+       l_fp    tstamp;         /* timestamp of last poll */
+       int     Rcvptr;
+};
+
+/*
+ * Function prototypes
+ */
+static int     zyfer_start     P((int, struct peer *));
+static void    zyfer_shutdown  P((int, struct peer *));
+static void    zyfer_receive   P((struct recvbuf *));
+static void    zyfer_poll      P((int, struct peer *));
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_zyfer = {
+       zyfer_start,            /* start up driver */
+       zyfer_shutdown,         /* shut down driver */
+       zyfer_poll,             /* transmit poll message */
+       noentry,                /* not used (old zyfer_control) */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used (old zyfer_buginfo) */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * zyfer_start - open the devices and initialize data for processing
+ */
+static int
+zyfer_start(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct zyferunit *up;
+       struct refclockproc *pp;
+       int fd;
+       char device[20];
+
+       /*
+        * Open serial port.
+        * Something like LDISC_ACTS that looked for ! would be nice...
+        */
+       (void)sprintf(device, DEVICE, unit);
+       if ( !(fd = refclock_open(device, SPEED232, LDISC_RAW)) )
+           return (0);
+
+       msyslog(LOG_NOTICE, "zyfer(%d) fd: %d dev <%s>", unit, fd, device);
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct zyferunit *)
+             emalloc(sizeof(struct zyferunit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct zyferunit));
+       pp = peer->procptr;
+       pp->io.clock_recv = zyfer_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+       pp->unitptr = (caddr_t)up;
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       peer->precision = PRECISION;
+       pp->clockdesc = DESCRIPTION;
+       memcpy((char *)&pp->refid, REFID, 4);
+       up->pollcnt = 2;
+       up->polled = 0;         /* May not be needed... */
+
+       return (1);
+}
+
+
+/*
+ * zyfer_shutdown - shut down the clock
+ */
+static void
+zyfer_shutdown(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct zyferunit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct zyferunit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+/*
+ * zyfer_receive - receive data from the serial interface
+ */
+static void
+zyfer_receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct zyferunit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+       int tmode;              /* Time mode */
+       int tfom;               /* Time Figure Of Merit */
+       int omode;              /* Operation mode */
+       u_char *p;
+#ifdef PPS
+       struct ppsclockev ppsev;
+       int request;
+#ifdef HAVE_CIOGETEV
+        request = CIOGETEV;
+#endif
+#ifdef HAVE_TIOCGPPSEV
+        request = TIOCGPPSEV;
+#endif
+#endif /* PPS */
+
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct zyferunit *)pp->unitptr;
+       p = (u_char *) &rbufp->recv_space;
+       /*
+        * If lencode is 0:
+        * - if *rbufp->recv_space is !
+        * - - call refclock_gtlin to get things going
+        * - else flush
+        * else stuff it on the end of lastcode
+        * If we don't have LENZYFER bytes
+        * - wait for more data
+        * Crack the beast, and if it's OK, process it.
+        *
+        * We use refclock_gtlin() because we might use LDISC_CLK.
+        *
+        * Under FreeBSD, we get the ! followed by two 14-byte packets.
+        */
+
+       if (pp->lencode >= LENZYFER)
+               pp->lencode = 0;
+
+       if (!pp->lencode) {
+               if (*p == '!')
+                       pp->lencode = refclock_gtlin(rbufp, pp->a_lastcode,
+                                                    BMAX, &pp->lastrec);
+               else
+                       return;
+       } else {
+               memcpy(pp->a_lastcode + pp->lencode, p, rbufp->recv_length);
+               pp->lencode += rbufp->recv_length;
+               pp->a_lastcode[pp->lencode] = '\0';
+       }
+
+       if (pp->lencode < LENZYFER)
+               return;
+
+       record_clock_stats(&peer->srcadr, pp->a_lastcode);
+
+       /*
+        * We get down to business, check the timecode format and decode
+        * its contents. If the timecode has invalid length or is not in
+        * proper format, we declare bad format and exit.
+        */
+
+       if (pp->lencode != LENZYFER) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+
+       /*
+        * Timecode sample: "!TIME,2002,017,07,59,32,2,4,1"
+        */
+       if (sscanf(pp->a_lastcode, "!TIME,%4d,%3d,%2d,%2d,%2d,%d,%d,%d",
+                  &pp->year, &pp->day, &pp->hour, &pp->minute, &pp->second,
+                  &tmode, &tfom, &omode) != 8) {
+               refclock_report(peer, CEVNT_BADREPLY);
+               return;
+       }
+
+       if (tmode != 2) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+       }
+
+       /* Should we make sure tfom is 4? */
+
+       if (omode != 1) {
+               pp->leap = LEAP_NOTINSYNC;
+               return;
+       }
+#ifdef PPS
+       if(ioctl(fdpps,request,(caddr_t) &ppsev) >=0) {
+               ppsev.tv.tv_sec += (u_int32) JAN_1970;
+               TVTOTS(&ppsev.tv,&up->tstamp);
+       }
+       /* record the last ppsclock event time stamp */
+       pp->lastrec = up->tstamp;
+#endif /* PPS */
+       if (!refclock_process(pp)) {
+               refclock_report(peer, CEVNT_BADTIME);
+               return;
+        }
+
+       /*
+        * Good place for record_clock_stats()
+        */
+       up->pollcnt = 2;
+
+       if (up->polled) {
+               up->polled = 0;
+               refclock_receive(peer);
+       }
+}
+
+
+/*
+ * zyfer_poll - called by the transmit procedure
+ */
+static void
+zyfer_poll(
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct zyferunit *up;
+       struct refclockproc *pp;
+
+       /*
+        * We don't really do anything here, except arm the receiving
+        * side to capture a sample and check for timeouts.
+        */
+       pp = peer->procptr;
+       up = (struct zyferunit *)pp->unitptr;
+       if (!up->pollcnt)
+               refclock_report(peer, CEVNT_TIMEOUT);
+       else
+               up->pollcnt--;
+       pp->polls++;
+       up->polled = 1;
+}
+
+#else
+int refclock_zyfer_bs;
+#endif /* REFCLOCK */
diff --git a/ntpdate/Makefile.am b/ntpdate/Makefile.am
new file mode 100644 (file)
index 0000000..3372f49
--- /dev/null
@@ -0,0 +1,28 @@
+#AUTOMAKE_OPTIONS=     ../util/ansi2knr
+
+bindir=                ${exec_prefix}/${BINSUBDIR}
+#bin_PROGRAMS= ntpdate ntptimeset
+bin_PROGRAMS=  ntpdate
+EXTRA_PROGRAMS=        ntptimeset
+
+ntptimeset_SOURCES=    ntptimeset.c ntptime_config.c
+AM_CPPFLAGS=   -I$(top_srcdir)/include
+# LDADD might need RESLIB and ADJLIB
+LDADD=         version.o ../libntp/libntp.a
+DISTCLEANFILES=        .version version.c stamp-v
+noinst_HEADERS=        ntpdate.h
+ETAGS_ARGS=    Makefile.am
+
+$(PROGRAMS): $(LDADD)
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE)
+
+$(top_srcdir)/version :
+       cd $(top_srcdir) && $(MAKE) version
+
+version.o: $(ntpdate_OBJECTS) ../libntp/libntp.a Makefile $(top_srcdir)/version
+       env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpdate
+       $(COMPILE) -c version.c
+
+include ../bincheck.mf
diff --git a/ntpdate/Makefile.in b/ntpdate/Makefile.in
new file mode 100644 (file)
index 0000000..d127815
--- /dev/null
@@ -0,0 +1,581 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+#AUTOMAKE_OPTIONS=     ../util/ansi2knr
+
+# we traditionally installed software in bindir, while it should have gone
+# in sbindir.  Now that we offer a choice, look in the "other" installation
+# subdir to warn folks if there is another version there.
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = ntpdate$(EXEEXT)
+EXTRA_PROGRAMS = ntptimeset$(EXEEXT)
+DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/../bincheck.mf \
+       $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+subdir = ntpdate
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)"
+PROGRAMS = $(bin_PROGRAMS)
+ntpdate_SOURCES = ntpdate.c
+ntpdate_OBJECTS = ntpdate.$(OBJEXT)
+ntpdate_LDADD = $(LDADD)
+ntpdate_DEPENDENCIES = version.o ../libntp/libntp.a
+am_ntptimeset_OBJECTS = ntptimeset.$(OBJEXT) ntptime_config.$(OBJEXT)
+ntptimeset_OBJECTS = $(am_ntptimeset_OBJECTS)
+ntptimeset_LDADD = $(LDADD)
+ntptimeset_DEPENDENCIES = version.o ../libntp/libntp.a
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = ntpdate.c $(ntptimeset_SOURCES)
+DIST_SOURCES = ntpdate.c $(ntptimeset_SOURCES)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = ${exec_prefix}/${BINSUBDIR}
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+ntptimeset_SOURCES = ntptimeset.c ntptime_config.c
+AM_CPPFLAGS = -I$(top_srcdir)/include
+# LDADD might need RESLIB and ADJLIB
+LDADD = version.o ../libntp/libntp.a
+DISTCLEANFILES = .version version.c stamp-v
+noinst_HEADERS = ntpdate.h
+ETAGS_ARGS = Makefile.am
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../bincheck.mf $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ntpdate/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign ntpdate/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p || test -f $$p1; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+           echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+           $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+       @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+ntpdate$(EXEEXT): $(ntpdate_OBJECTS) $(ntpdate_DEPENDENCIES) 
+       @rm -f ntpdate$(EXEEXT)
+       $(LINK) $(ntpdate_OBJECTS) $(ntpdate_LDADD) $(LIBS)
+ntptimeset$(EXEEXT): $(ntptimeset_OBJECTS) $(ntptimeset_DEPENDENCIES) 
+       @rm -f ntptimeset$(EXEEXT)
+       $(LINK) $(ntptimeset_OBJECTS) $(ntptimeset_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdate.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntptime_config.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntptimeset.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(PROGRAMS) $(HEADERS)
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+       -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+       @$(NORMAL_INSTALL)
+       $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS
+
+.MAKE: install-am install-exec-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+       clean-generic clean-libtool ctags distclean distclean-compile \
+       distclean-generic distclean-libtool distclean-tags distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-binPROGRAMS install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-exec-hook \
+       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 uninstall \
+       uninstall-am uninstall-binPROGRAMS
+
+
+$(PROGRAMS): $(LDADD)
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE)
+
+$(top_srcdir)/version :
+       cd $(top_srcdir) && $(MAKE) version
+
+version.o: $(ntpdate_OBJECTS) ../libntp/libntp.a Makefile $(top_srcdir)/version
+       env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpdate
+       $(COMPILE) -c version.c
+
+install-exec-hook:
+       @case ${BINSUBDIR} in                                   \
+        bin) ODIR=${exec_prefix}/sbin ;;                       \
+        sbin) ODIR=${exec_prefix}/bin ;;                       \
+       esac;                                                   \
+       test -z "${bin_PROGRAMS}${bin_SCRIPTS}"                 \
+       || for i in ${bin_PROGRAMS} ${bin_SCRIPTS} " "; do              \
+          test ! -f $$ODIR/$$i || echo "*** $$i is also in $$ODIR!";   \
+       done
+
+#
+
+# 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.
+.NOEXPORT:
diff --git a/ntpdate/README b/ntpdate/README
new file mode 100644 (file)
index 0000000..27b51ed
--- /dev/null
@@ -0,0 +1,7 @@
+README file for directory ./ntpdate of the NTP Version 4 distribution
+
+This directory contains the sources for the ntpdate utility program. See
+the README and RELNOTES files in the parent directory for directions on
+how to make and install this program. The current version number of this
+program is in the version.c file.
+
diff --git a/ntpdate/ntpdate.c b/ntpdate/ntpdate.c
new file mode 100644 (file)
index 0000000..a0a90ce
--- /dev/null
@@ -0,0 +1,2328 @@
+/*
+ * ntpdate - set the time of day by polling one or more NTP servers
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#ifdef HAVE_NETINFO
+#include <netinfo/ni.h>
+#endif
+
+#include "ntp_machine.h"
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntp_io.h"
+#include "ntp_unixtime.h"
+#include "ntpdate.h"
+#include "ntp_string.h"
+#include "ntp_syslog.h"
+#include "ntp_select.h"
+#include "ntp_stdlib.h"
+
+/* Don't include ISC's version of IPv6 variables and structures */
+#define ISC_IPV6_H 1
+#include "isc/net.h"
+#include "isc/result.h"
+#include "isc/sockaddr.h"
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <stdio.h>
+#include <signal.h>
+#include <ctype.h>
+#ifdef HAVE_POLL_H
+# include <poll.h>
+#endif
+#ifndef SYS_WINNT
+# ifdef HAVE_SYS_SIGNAL_H
+#  include <sys/signal.h>
+# else
+#  include <signal.h>
+# endif
+# ifdef HAVE_SYS_IOCTL_H
+#  include <sys/ioctl.h>
+# endif
+#endif /* SYS_WINNT */
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif /* HAVE_SYS_RESOURCE_H */
+
+#include <arpa/inet.h>
+
+#ifdef SYS_VXWORKS
+# include "ioLib.h"
+# include "sockLib.h"
+# include "timers.h"
+
+/* select wants a zero structure ... */
+struct timeval timeout = {0,0};
+#elif defined(SYS_WINNT)
+/*
+ * Windows does not abort a select select call if SIGALRM goes off
+ * so a 200 ms timeout is needed
+ */
+struct timeval timeout = {0,1000000/TIMER_HZ};
+#else
+struct timeval timeout = {60,0};
+#endif
+
+#ifdef HAVE_NETINFO
+#include <netinfo/ni.h>
+#endif
+
+#include "recvbuff.h"
+
+#ifdef SYS_WINNT
+#define EPROTONOSUPPORT WSAEPROTONOSUPPORT
+#define EAFNOSUPPORT   WSAEAFNOSUPPORT
+#define EPFNOSUPPORT   WSAEPFNOSUPPORT
+#define TARGET_RESOLUTION 1  /* Try for 1-millisecond accuracy
+                               on Windows NT timers. */
+#pragma comment(lib, "winmm")
+isc_boolean_t ntp_port_inuse(int af, u_short port);
+UINT wTimerRes;
+#endif /* SYS_WINNT */
+
+/*
+ * Scheduling priority we run at
+ */
+#ifndef SYS_VXWORKS
+# define       NTPDATE_PRIO    (-12)
+#else
+# define       NTPDATE_PRIO    (100)
+#endif
+
+#if defined(HAVE_TIMER_SETTIME) || defined (HAVE_TIMER_CREATE)
+/* POSIX TIMERS - vxWorks doesn't have itimer - casey */
+static timer_t ntpdate_timerid;
+#endif
+
+/*
+ * Compatibility stuff for Version 2
+ */
+#define NTP_MAXSKW     0x28f   /* 0.01 sec in fp format */
+#define NTP_MINDIST    0x51f   /* 0.02 sec in fp format */
+#define PEER_MAXDISP   (64*FP_SECOND)  /* maximum dispersion (fp 64) */
+#define NTP_INFIN      15      /* max stratum, infinity a la Bellman-Ford */
+#define NTP_MAXWGT     (8*FP_SECOND)   /* maximum select weight 8 seconds */
+#define NTP_MAXLIST    5       /* maximum select list size */
+#define PEER_SHIFT     8       /* 8 suitable for crystal time base */
+
+/*
+ * for get_systime()
+ */
+s_char sys_precision;          /* local clock precision (log2 s) */
+
+/*
+ * Debugging flag
+ */
+volatile int debug = 0;
+
+/*
+ * File descriptor masks etc. for call to select
+ */
+
+int ai_fam_templ;
+int nbsock;             /* the number of sockets used */
+SOCKET fd[MAX_AF];
+int fd_family[MAX_AF]; /* to remember the socket family */
+#ifdef HAVE_POLL_H
+struct pollfd fdmask[MAX_AF];
+#else
+fd_set fdmask;
+SOCKET maxfd;
+#endif
+int polltest = 0;
+
+/*
+ * Initializing flag.  All async routines watch this and only do their
+ * thing when it is clear.
+ */
+int initializing = 1;
+
+/*
+ * Alarm flag. Set when an alarm occurs
+ */
+volatile int alarm_flag = 0;
+
+/*
+ * Simple query flag.
+ */
+int simple_query = 0;
+
+/*
+ * Unprivileged port flag.
+ */
+int unpriv_port = 0;
+
+/*
+ * Program name.
+ */
+char *progname;
+
+/*
+ * Systemwide parameters and flags
+ */
+int sys_samples = DEFSAMPLES;  /* number of samples/server */
+u_long sys_timeout = DEFTIMEOUT; /* timeout time, in TIMER_HZ units */
+struct server *sys_servers;    /* the server list */
+int sys_numservers = 0;        /* number of servers to poll */
+int sys_authenticate = 0;      /* true when authenticating */
+u_int32 sys_authkey = 0;       /* set to authentication key in use */
+u_long sys_authdelay = 0;      /* authentication delay */
+int sys_version = NTP_VERSION; /* version to poll with */
+
+/*
+ * The current internal time
+ */
+u_long current_time = 0;
+
+/*
+ * Counter for keeping track of completed servers
+ */
+int complete_servers = 0;
+
+/*
+ * File of encryption keys
+ */
+
+#ifndef KEYFILE
+# ifndef SYS_WINNT
+#define KEYFILE        "/etc/ntp.keys"
+# else
+#define KEYFILE        "%windir%\\ntp.keys"
+# endif /* SYS_WINNT */
+#endif /* KEYFILE */
+
+#ifndef SYS_WINNT
+const char *key_file = KEYFILE;
+#else
+char key_file_storage[MAX_PATH+1], *key_file ;
+#endif  /* SYS_WINNT */
+
+/*
+ * Miscellaneous flags
+ */
+int verbose = 0;
+int always_step = 0;
+int never_step = 0;
+
+int ntpdatemain P((int, char **));
+
+static void    transmit        P((struct server *));
+static void    receive         P((struct recvbuf *));
+static void    server_data P((struct server *, s_fp, l_fp *, u_fp));
+static void    clock_filter    P((struct server *));
+static struct server *clock_select P((void));
+static int clock_adjust        P((void));
+static void    addserver       P((char *));
+static struct server *findserver P((struct sockaddr_storage *));
+void   timer   P((void));
+static void    init_alarm      P((void));
+#ifndef SYS_WINNT
+static RETSIGTYPE alarming P((int));
+#endif /* SYS_WINNT */
+static void    init_io         P((void));
+static void    sendpkt         P((struct sockaddr_storage *, struct pkt *, int));
+void   input_handler   P((void));
+
+static int l_adj_systime       P((l_fp *));
+static int l_step_systime      P((l_fp *));
+
+static void    printserver P((struct server *, FILE *));
+
+#ifdef SYS_WINNT
+int    on = 1;
+WORD   wVersionRequested;
+WSADATA        wsaData;
+HANDLE TimerThreadHandle = NULL;
+#endif /* SYS_WINNT */
+
+#ifdef NO_MAIN_ALLOWED
+CALL(ntpdate,"ntpdate",ntpdatemain);
+
+void clear_globals()
+{
+  /*
+   * Debugging flag
+   */
+  debug = 0;
+
+  ntp_optind = 0;
+  /*
+   * Initializing flag.  All async routines watch this and only do their
+   * thing when it is clear.
+   */
+  initializing = 1;
+
+  /*
+   * Alarm flag.  Set when an alarm occurs
+   */
+  alarm_flag = 0;
+
+  /*
+   * Simple query flag.
+   */
+  simple_query = 0;
+
+  /*
+   * Unprivileged port flag.
+   */
+  unpriv_port = 0;
+
+  /*
+   * Systemwide parameters and flags
+   */
+  sys_numservers = 0;    /* number of servers to poll */
+  sys_authenticate = 0;   /* true when authenticating */
+  sys_authkey = 0;        /* set to authentication key in use */
+  sys_authdelay = 0;   /* authentication delay */
+  sys_version = NTP_VERSION;  /* version to poll with */
+
+  /*
+   * The current internal time
+   */
+  current_time = 0;
+
+  /*
+   * Counter for keeping track of completed servers
+   */
+  complete_servers = 0;
+  verbose = 0;
+  always_step = 0;
+  never_step = 0;
+}
+#endif
+
+#ifdef HAVE_NETINFO
+static ni_namelist *getnetinfoservers P((void));
+#endif
+
+/*
+ * Main program.  Initialize us and loop waiting for I/O and/or
+ * timer expiries.
+ */
+#ifndef NO_MAIN_ALLOWED
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       return ntpdatemain (argc, argv);
+}
+#endif /* NO_MAIN_ALLOWED */
+
+int
+ntpdatemain (
+       int argc,
+       char *argv[]
+       )
+{
+       int was_alarmed;
+       int tot_recvbufs;
+       struct recvbuf *rbuf;
+       l_fp tmp;
+       int errflg;
+       int c;
+       int nfound;
+
+#ifdef HAVE_NETINFO
+       ni_namelist *netinfoservers;
+#endif
+#ifdef SYS_WINNT
+       HANDLE process_handle;
+
+       wVersionRequested = MAKEWORD(1,1);
+       if (WSAStartup(wVersionRequested, &wsaData)) {
+               netsyslog(LOG_ERR, "No useable winsock.dll: %m");
+               exit(1);
+       }
+
+       key_file = key_file_storage;
+
+       if (!ExpandEnvironmentStrings(KEYFILE, key_file, MAX_PATH))
+       {
+               msyslog(LOG_ERR, "ExpandEnvironmentStrings(KEYFILE) failed: %m\n");
+       }
+#endif /* SYS_WINNT */
+
+#ifdef NO_MAIN_ALLOWED
+       clear_globals();
+#endif
+
+
+       /* Check to see if we have IPv6. Otherwise force the -4 flag */
+       if (isc_net_probeipv6() != ISC_R_SUCCESS) {
+               ai_fam_templ = AF_INET;
+       }
+
+       errflg = 0;
+       progname = argv[0];
+       syslogit = 0;
+
+       /*
+        * Decode argument list
+        */
+       while ((c = ntp_getopt(argc, argv, "46a:bBde:k:o:p:qst:uv")) != EOF)
+               switch (c)
+               {
+               case '4':
+                       ai_fam_templ = AF_INET;
+                       break;
+               case '6':
+                       ai_fam_templ = AF_INET6;
+                       break;
+               case 'a':
+                       c = atoi(ntp_optarg);
+                       sys_authenticate = 1;
+                       sys_authkey = c;
+                       break;
+               case 'b':
+                       always_step++;
+                       never_step = 0;
+                       break;
+               case 'B':
+                       never_step++;
+                       always_step = 0;
+                       break;
+               case 'd':
+                       ++debug;
+                       break;
+               case 'e':
+                       if (!atolfp(ntp_optarg, &tmp)
+                       || tmp.l_ui != 0) {
+                               (void) fprintf(stderr,
+                                          "%s: encryption delay %s is unlikely\n",
+                                          progname, ntp_optarg);
+                               errflg++;
+                       } else {
+                               sys_authdelay = tmp.l_uf;
+                       }
+                       break;
+               case 'k':
+                       key_file = ntp_optarg;
+                       break;
+               case 'o':
+                       sys_version = atoi(ntp_optarg);
+                       break;
+               case 'p':
+                       c = atoi(ntp_optarg);
+                       if (c <= 0 || c > NTP_SHIFT) {
+                               (void) fprintf(stderr,
+                                          "%s: number of samples (%d) is invalid\n",
+                                          progname, c);
+                               errflg++;
+                       } else {
+                               sys_samples = c;
+                       }
+                       break;
+               case 'q':
+                       simple_query = 1;
+                       break;
+               case 's':
+                       syslogit = 1;
+                       break;
+               case 't':
+                       if (!atolfp(ntp_optarg, &tmp)) {
+                               (void) fprintf(stderr,
+                                          "%s: timeout %s is undecodeable\n",
+                                          progname, ntp_optarg);
+                               errflg++;
+                       } else {
+                               sys_timeout = ((LFPTOFP(&tmp) * TIMER_HZ)
+                                          + 0x8000) >> 16;
+                               if (sys_timeout == 0)
+                               sys_timeout = 1;
+                       }
+                       break;
+               case 'v':
+                       verbose = 1;
+                       break;
+               case 'u':
+                       unpriv_port = 1;
+                       break;
+               case '?':
+                       ++errflg;
+                       break;
+               default:
+                       break;
+           }
+       
+       if (errflg) {
+               (void) fprintf(stderr,
+                   "usage: %s [-46bBdqsuv] [-a key#] [-e delay] [-k file] [-p samples] [-o version#] [-t timeo] server ...\n",
+                   progname);
+               exit(2);
+       }
+
+       if (debug || simple_query) {
+#ifdef HAVE_SETVBUF
+               static char buf[BUFSIZ];
+#ifdef SYS_WINNT
+               /* Win32 does not implement line buffering */
+               setvbuf(stdout, NULL, _IONBF, BUFSIZ);
+#else
+               setvbuf(stdout, buf, _IOLBF, BUFSIZ);
+#endif /* SYS_WINNT */
+#else
+               setlinebuf(stdout);
+#endif
+       }
+
+       /*
+        * Logging.  Open the syslog if we have to
+        */
+       if (syslogit) {
+#if !defined (SYS_WINNT) && !defined (SYS_VXWORKS) && !defined SYS_CYGWIN32
+# ifndef       LOG_DAEMON
+               openlog("ntpdate", LOG_PID);
+# else
+
+#  ifndef      LOG_NTP
+#      define  LOG_NTP LOG_DAEMON
+#  endif
+               openlog("ntpdate", LOG_PID | LOG_NDELAY, LOG_NTP);
+               if (debug)
+                       setlogmask(LOG_UPTO(LOG_DEBUG));
+               else
+                       setlogmask(LOG_UPTO(LOG_INFO));
+# endif /* LOG_DAEMON */
+#endif /* SYS_WINNT */
+       }
+
+       if (debug || verbose)
+               msyslog(LOG_NOTICE, "%s", Version);
+
+       /*
+        * Add servers we are going to be polling
+        */
+#ifdef HAVE_NETINFO
+       netinfoservers = getnetinfoservers();
+#endif
+
+       for ( ; ntp_optind < argc; ntp_optind++)
+               addserver(argv[ntp_optind]);
+
+#ifdef HAVE_NETINFO
+       if (netinfoservers) {
+               if ( netinfoservers->ni_namelist_len &&
+                   *netinfoservers->ni_namelist_val ) {
+                       u_int servercount = 0;
+                       while (servercount < netinfoservers->ni_namelist_len) {
+                               if (debug) msyslog(LOG_DEBUG,
+                                                  "Adding time server %s from NetInfo configuration.",
+                                                  netinfoservers->ni_namelist_val[servercount]);
+                               addserver(netinfoservers->ni_namelist_val[servercount++]);
+                       }
+               }
+               ni_namelist_free(netinfoservers);
+               free(netinfoservers);
+       }
+#endif
+
+       if (sys_numservers == 0) {
+               msyslog(LOG_ERR, "no servers can be used, exiting");
+               exit(1);
+       }
+
+       /*
+        * Initialize the time of day routines and the I/O subsystem
+        */
+       if (sys_authenticate) {
+               init_auth();
+               if (!authreadkeys(key_file)) {
+                       msyslog(LOG_ERR, "no key file <%s>, exiting", key_file);
+                       exit(1);
+               }
+               authtrust(sys_authkey, 1);
+               if (!authistrusted(sys_authkey)) {
+                       msyslog(LOG_ERR, "authentication key %lu unknown",
+                               (unsigned long) sys_authkey);
+                       exit(1);
+               }
+       }
+       init_io();
+       init_alarm();
+
+       /*
+        * Set the priority.
+        */
+#ifdef SYS_VXWORKS
+       taskPrioritySet( taskIdSelf(), NTPDATE_PRIO);
+#endif
+#if defined(HAVE_ATT_NICE)
+       nice (NTPDATE_PRIO);
+#endif
+#if defined(HAVE_BSD_NICE)
+       (void) setpriority(PRIO_PROCESS, 0, NTPDATE_PRIO);
+#endif
+#ifdef SYS_WINNT
+       process_handle = GetCurrentProcess();
+       if (!SetPriorityClass(process_handle, (DWORD) REALTIME_PRIORITY_CLASS)) {
+               msyslog(LOG_ERR, "SetPriorityClass failed: %m");
+       }
+#endif /* SYS_WINNT */
+
+
+
+       initializing = 0;
+       was_alarmed = 0;
+
+       while (complete_servers < sys_numservers) {
+#ifdef HAVE_POLL_H
+               struct pollfd* rdfdes;
+               rdfdes = fdmask;
+#else
+               fd_set rdfdes;
+               rdfdes = fdmask;
+#endif
+
+               if (alarm_flag) {               /* alarmed? */
+                       was_alarmed = 1;
+                       alarm_flag = 0;
+               }
+               tot_recvbufs = full_recvbuffs();        /* get received buffers */
+
+               if (!was_alarmed && tot_recvbufs == 0) {
+                       /*
+                        * Nothing to do.        Wait for something.
+                        */
+#ifdef HAVE_POLL_H
+                       nfound = poll(rdfdes, (unsigned int)nbsock, timeout.tv_sec * 1000);
+
+#else
+                       nfound = select(maxfd, &rdfdes, (fd_set *)0,
+                                       (fd_set *)0, &timeout);
+#endif
+                       if (nfound > 0)
+                               input_handler();
+                       else if (nfound == SOCKET_ERROR)
+                       {
+#ifndef SYS_WINNT
+                               if (errno != EINTR)
+#else
+                               if (WSAGetLastError() != WSAEINTR)
+#endif
+                                       netsyslog(LOG_ERR,
+#ifdef HAVE_POLL_H
+                                               "poll() error: %m"
+#else
+                                               "select() error: %m"
+#endif
+                                               );
+                       } else if (errno != 0) {
+#ifndef SYS_VXWORKS
+                               netsyslog(LOG_DEBUG,
+#ifdef HAVE_POLL_H
+                                       "poll(): nfound = %d, error: %m",
+#else
+                                       "select(): nfound = %d, error: %m",
+#endif
+                                       nfound);
+#endif
+                       }
+                       if (alarm_flag) {               /* alarmed? */
+                               was_alarmed = 1;
+                               alarm_flag = 0;
+                       }
+                       tot_recvbufs = full_recvbuffs();        /* get received buffers */
+               }
+
+               /*
+                * Out here, signals are unblocked.  Call receive
+                * procedure for each incoming packet.
+                */
+               rbuf = get_full_recv_buffer();
+               while (rbuf != NULL)
+               {
+                       receive(rbuf);
+                       freerecvbuf(rbuf);
+                       rbuf = get_full_recv_buffer();
+               }
+
+               /*
+                * Call timer to process any timeouts
+                */
+               if (was_alarmed) {
+                       timer();
+                       was_alarmed = 0;
+               }
+
+               /*
+                * Go around again
+                */
+       }
+
+       /*
+        * When we get here we've completed the polling of all servers.
+        * Adjust the clock, then exit.
+        */
+#ifdef SYS_WINNT
+       WSACleanup();
+#endif
+#ifdef SYS_VXWORKS
+       close (fd);
+       timer_delete(ntpdate_timerid);
+#endif
+
+       return clock_adjust();
+}
+
+
+/*
+ * transmit - transmit a packet to the given server, or mark it completed.
+ *             This is called by the timeout routine and by the receive
+ *             procedure.
+ */
+static void
+transmit(
+       register struct server *server
+       )
+{
+       struct pkt xpkt;
+
+       if (debug)
+               printf("transmit(%s)\n", stoa(&(server->srcadr)));
+
+       if (server->filter_nextpt < server->xmtcnt) {
+               l_fp ts;
+               /*
+                * Last message to this server timed out.  Shift
+                * zeros into the filter.
+                */
+               L_CLR(&ts);
+               server_data(server, 0, &ts, 0);
+       }
+
+       if ((int)server->filter_nextpt >= sys_samples) {
+               /*
+                * Got all the data we need.  Mark this guy
+                * completed and return.
+                */
+               server->event_time = 0;
+               complete_servers++;
+               return;
+       }
+
+       /*
+        * If we're here, send another message to the server.  Fill in
+        * the packet and let 'er rip.
+        */
+       xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
+                                        sys_version, MODE_CLIENT);
+       xpkt.stratum = STRATUM_TO_PKT(STRATUM_UNSPEC);
+       xpkt.ppoll = NTP_MINPOLL;
+       xpkt.precision = NTPDATE_PRECISION;
+       xpkt.rootdelay = htonl(NTPDATE_DISTANCE);
+       xpkt.rootdispersion = htonl(NTPDATE_DISP);
+       xpkt.refid = htonl(NTPDATE_REFID);
+       L_CLR(&xpkt.reftime);
+       L_CLR(&xpkt.org);
+       L_CLR(&xpkt.rec);
+
+       /*
+        * Determine whether to authenticate or not.    If so,
+        * fill in the extended part of the packet and do it.
+        * If not, just timestamp it and send it away.
+        */
+       if (sys_authenticate) {
+               int len;
+
+               xpkt.exten[0] = htonl(sys_authkey);
+               get_systime(&server->xmt);
+               L_ADDUF(&server->xmt, sys_authdelay);
+               HTONL_FP(&server->xmt, &xpkt.xmt);
+               len = authencrypt(sys_authkey, (u_int32 *)&xpkt, LEN_PKT_NOMAC);
+               sendpkt(&(server->srcadr), &xpkt, (int)(LEN_PKT_NOMAC + len));
+
+               if (debug > 1)
+                       printf("transmit auth to %s\n",
+                          stoa(&(server->srcadr)));
+       } else {
+               get_systime(&(server->xmt));
+               HTONL_FP(&server->xmt, &xpkt.xmt);
+               sendpkt(&(server->srcadr), &xpkt, LEN_PKT_NOMAC);
+
+               if (debug > 1)
+                       printf("transmit to %s\n", stoa(&(server->srcadr)));
+       }
+
+       /*
+        * Update the server timeout and transmit count
+        */
+       server->event_time = current_time + sys_timeout;
+       server->xmtcnt++;
+}
+
+
+/*
+ * receive - receive and process an incoming frame
+ */
+static void
+receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct pkt *rpkt;
+       register struct server *server;
+       register s_fp di;
+       l_fp t10, t23, tmp;
+       l_fp org;
+       l_fp rec;
+       l_fp ci;
+       int has_mac;
+       int is_authentic;
+
+       if (debug)
+               printf("receive(%s)\n", stoa(&rbufp->recv_srcadr));
+       /*
+        * Check to see if the packet basically looks like something
+        * intended for us.
+        */
+       if (rbufp->recv_length == LEN_PKT_NOMAC)
+               has_mac = 0;
+       else if (rbufp->recv_length >= LEN_PKT_NOMAC)
+               has_mac = 1;
+       else {
+               if (debug)
+                       printf("receive: packet length %d\n",
+                          rbufp->recv_length);
+               return;                 /* funny length packet */
+       }
+
+       rpkt = &(rbufp->recv_pkt);
+       if (PKT_VERSION(rpkt->li_vn_mode) < NTP_OLDVERSION ||
+               PKT_VERSION(rpkt->li_vn_mode) > NTP_VERSION) {
+               return;
+       }
+
+       if ((PKT_MODE(rpkt->li_vn_mode) != MODE_SERVER
+                && PKT_MODE(rpkt->li_vn_mode) != MODE_PASSIVE)
+               || rpkt->stratum >= STRATUM_UNSPEC) {
+               if (debug)
+                       printf("receive: mode %d stratum %d\n",
+                          PKT_MODE(rpkt->li_vn_mode), rpkt->stratum);
+               return;
+       }
+
+       /*
+        * So far, so good.  See if this is from a server we know.
+        */
+       server = findserver(&(rbufp->recv_srcadr));
+       if (server == NULL) {
+               if (debug)
+                       printf("receive: server not found\n");
+               return;
+       }
+
+       /*
+        * Decode the org timestamp and make sure we're getting a response
+        * to our last request.
+        */
+       NTOHL_FP(&rpkt->org, &org);
+       if (!L_ISEQU(&org, &server->xmt)) {
+               if (debug)
+                       printf("receive: pkt.org and peer.xmt differ\n");
+               return;
+       }
+
+       /*
+        * Check out the authenticity if we're doing that.
+        */
+       if (!sys_authenticate)
+               is_authentic = 1;
+       else {
+               is_authentic = 0;
+
+               if (debug > 3)
+                       printf("receive: rpkt keyid=%ld sys_authkey=%ld decrypt=%ld\n",
+                          (long int)ntohl(rpkt->exten[0]), (long int)sys_authkey,
+                          (long int)authdecrypt(sys_authkey, (u_int32 *)rpkt,
+                               LEN_PKT_NOMAC, (int)(rbufp->recv_length - LEN_PKT_NOMAC)));
+
+               if (has_mac && ntohl(rpkt->exten[0]) == sys_authkey &&
+                       authdecrypt(sys_authkey, (u_int32 *)rpkt, LEN_PKT_NOMAC,
+                       (int)(rbufp->recv_length - LEN_PKT_NOMAC)))
+                       is_authentic = 1;
+               if (debug)
+                       printf("receive: authentication %s\n",
+                          is_authentic ? "passed" : "failed");
+       }
+       server->trust <<= 1;
+       if (!is_authentic)
+               server->trust |= 1;
+
+       /*
+        * Looks good.  Record info from the packet.
+        */
+       server->leap = PKT_LEAP(rpkt->li_vn_mode);
+       server->stratum = PKT_TO_STRATUM(rpkt->stratum);
+       server->precision = rpkt->precision;
+       server->rootdelay = ntohl(rpkt->rootdelay);
+       server->rootdispersion = ntohl(rpkt->rootdispersion);
+       server->refid = rpkt->refid;
+       NTOHL_FP(&rpkt->reftime, &server->reftime);
+       NTOHL_FP(&rpkt->rec, &rec);
+       NTOHL_FP(&rpkt->xmt, &server->org);
+
+       /*
+        * Make sure the server is at least somewhat sane.      If not, try
+        * again.
+        */
+       if (L_ISZERO(&rec) || !L_ISHIS(&server->org, &rec)) {
+               transmit(server);
+               return;
+       }
+
+       /*
+        * Calculate the round trip delay (di) and the clock offset (ci).
+        * We use the equations (reordered from those in the spec):
+        *
+        * d = (t2 - t3) - (t1 - t0)
+        * c = ((t2 - t3) + (t1 - t0)) / 2
+        */
+       t10 = server->org;              /* pkt.xmt == t1 */
+       L_SUB(&t10, &rbufp->recv_time); /* recv_time == t0*/
+
+       t23 = rec;                      /* pkt.rec == t2 */
+       L_SUB(&t23, &org);              /* pkt->org == t3 */
+
+       /* now have (t2 - t3) and (t0 - t1).    Calculate (ci) and (di) */
+       /*
+        * Calculate (ci) = ((t1 - t0) / 2) + ((t2 - t3) / 2)
+        * For large offsets this may prevent an overflow on '+'
+        */
+       ci = t10;
+       L_RSHIFT(&ci);
+       tmp = t23;
+       L_RSHIFT(&tmp);
+       L_ADD(&ci, &tmp);
+
+       /*
+        * Calculate di in t23 in full precision, then truncate
+        * to an s_fp.
+        */
+       L_SUB(&t23, &t10);
+       di = LFPTOFP(&t23);
+
+       if (debug > 3)
+               printf("offset: %s, delay %s\n", lfptoa(&ci, 6), fptoa(di, 5));
+
+       di += (FP_SECOND >> (-(int)NTPDATE_PRECISION))
+               + (FP_SECOND >> (-(int)server->precision)) + NTP_MAXSKW;
+
+       if (di <= 0) {          /* value still too raunchy to use? */
+               L_CLR(&ci);
+               di = 0;
+       } else {
+               di = max(di, NTP_MINDIST);
+       }
+
+       /*
+        * Shift this data in, then transmit again.
+        */
+       server_data(server, (s_fp) di, &ci, 0);
+       transmit(server);
+}
+
+
+/*
+ * server_data - add a sample to the server's filter registers
+ */
+static void
+server_data(
+       register struct server *server,
+       s_fp d,
+       l_fp *c,
+       u_fp e
+       )
+{
+       u_short i;
+
+       i = server->filter_nextpt;
+       if (i < NTP_SHIFT) {
+               server->filter_delay[i] = d;
+               server->filter_offset[i] = *c;
+               server->filter_soffset[i] = LFPTOFP(c);
+               server->filter_error[i] = e;
+               server->filter_nextpt = (u_short)(i + 1);
+       }
+}
+
+
+/*
+ * clock_filter - determine a server's delay, dispersion and offset
+ */
+static void
+clock_filter(
+       register struct server *server
+       )
+{
+       register int i, j;
+       int ord[NTP_SHIFT];
+
+       /*
+        * Sort indices into increasing delay order
+        */
+       for (i = 0; i < sys_samples; i++)
+               ord[i] = i;
+
+       for (i = 0; i < (sys_samples-1); i++) {
+               for (j = i+1; j < sys_samples; j++) {
+                       if (server->filter_delay[ord[j]] == 0)
+                               continue;
+                       if (server->filter_delay[ord[i]] == 0
+                               || (server->filter_delay[ord[i]]
+                               > server->filter_delay[ord[j]])) {
+                               register int tmp;
+
+                               tmp = ord[i];
+                               ord[i] = ord[j];
+                               ord[j] = tmp;
+                       }
+               }
+       }
+
+       /*
+        * Now compute the dispersion, and assign values to delay and
+        * offset.      If there are no samples in the register, delay and
+        * offset go to zero and dispersion is set to the maximum.
+        */
+       if (server->filter_delay[ord[0]] == 0) {
+               server->delay = 0;
+               L_CLR(&server->offset);
+               server->soffset = 0;
+               server->dispersion = PEER_MAXDISP;
+       } else {
+               register s_fp d;
+
+               server->delay = server->filter_delay[ord[0]];
+               server->offset = server->filter_offset[ord[0]];
+               server->soffset = LFPTOFP(&server->offset);
+               server->dispersion = 0;
+               for (i = 1; i < sys_samples; i++) {
+                       if (server->filter_delay[ord[i]] == 0)
+                               d = PEER_MAXDISP;
+                       else {
+                               d = server->filter_soffset[ord[i]]
+                                       - server->filter_soffset[ord[0]];
+                               if (d < 0)
+                                       d = -d;
+                               if (d > PEER_MAXDISP)
+                                       d = PEER_MAXDISP;
+                       }
+                       /*
+                        * XXX This *knows* PEER_FILTER is 1/2
+                        */
+                       server->dispersion += (u_fp)(d) >> i;
+               }
+       }
+       /*
+        * We're done
+        */
+}
+
+
+/*
+ * clock_select - select the pick-of-the-litter clock from the samples
+ *               we've got.
+ */
+static struct server *
+clock_select(void)
+{
+       register struct server *server;
+       register int i;
+       register int nlist;
+       register s_fp d;
+       register int j;
+       register int n;
+       s_fp local_threshold;
+       struct server *server_list[NTP_MAXCLOCK];
+       u_fp server_badness[NTP_MAXCLOCK];
+       struct server *sys_server;
+
+       /*
+        * This first chunk of code is supposed to go through all
+        * servers we know about to find the NTP_MAXLIST servers which
+        * are most likely to succeed.  We run through the list
+        * doing the sanity checks and trying to insert anyone who
+        * looks okay.  We are at all times aware that we should
+        * only keep samples from the top two strata and we only need
+        * NTP_MAXLIST of them.
+        */
+       nlist = 0;      /* none yet */
+       for (server = sys_servers; server != NULL; server = server->next_server) {
+               if (server->delay == 0) {
+                       if (debug)
+                               printf("%s: Server dropped: no data\n", ntoa(&server->srcadr));
+                       continue;       /* no data */
+               }
+               if (server->stratum > NTP_INFIN) {
+                       if (debug)
+                               printf("%s: Server dropped: strata too high\n", ntoa(&server->srcadr));
+                       continue;       /* stratum no good */
+               }
+               if (server->delay > NTP_MAXWGT) {
+                       if (debug)
+                               printf("%s: Server dropped: server too far away\n", 
+                                       ntoa(&server->srcadr));
+                       continue;       /* too far away */
+               }
+               if (server->leap == LEAP_NOTINSYNC) {
+                       if (debug)
+                               printf("%s: Server dropped: Leap not in sync\n", ntoa(&server->srcadr));
+                       continue;       /* he's in trouble */
+               }
+               if (!L_ISHIS(&server->org, &server->reftime)) {
+                       if (debug)
+                               printf("%s: Server dropped: server is very broken\n", 
+                                      ntoa(&server->srcadr));
+                       continue;       /* very broken host */
+               }
+               if ((server->org.l_ui - server->reftime.l_ui)
+                   >= NTP_MAXAGE) {
+                       if (debug)
+                               printf("%s: Server dropped: Server has gone too long without sync\n", 
+                                      ntoa(&server->srcadr));
+                       continue;       /* too long without sync */
+               }
+               if (server->trust != 0) {
+                       if (debug)
+                               printf("%s: Server dropped: Server is untrusted\n",
+                                      ntoa(&server->srcadr));
+                       continue;
+               }
+
+               /*
+                * This one seems sane.  Find where he belongs
+                * on the list.
+                */
+               d = server->dispersion + server->dispersion;
+               for (i = 0; i < nlist; i++)
+                       if (server->stratum <= server_list[i]->stratum)
+                       break;
+               for ( ; i < nlist; i++) {
+                       if (server->stratum < server_list[i]->stratum)
+                               break;
+                       if (d < (s_fp) server_badness[i])
+                               break;
+               }
+
+               /*
+                * If i points past the end of the list, this
+                * guy is a loser, else stick him in.
+                */
+               if (i >= NTP_MAXLIST)
+                       continue;
+               for (j = nlist; j > i; j--)
+                       if (j < NTP_MAXLIST) {
+                               server_list[j] = server_list[j-1];
+                               server_badness[j]
+                                       = server_badness[j-1];
+                       }
+
+               server_list[i] = server;
+               server_badness[i] = d;
+               if (nlist < NTP_MAXLIST)
+                       nlist++;
+       }
+
+       /*
+        * Got the five-or-less best.    Cut the list where the number of
+        * strata exceeds two.
+        */
+       j = 0;
+       for (i = 1; i < nlist; i++)
+               if (server_list[i]->stratum > server_list[i-1]->stratum)
+               if (++j == 2) {
+                       nlist = i;
+                       break;
+               }
+
+       /*
+        * Whew!  What we should have by now is 0 to 5 candidates for
+        * the job of syncing us.  If we have none, we're out of luck.
+        * If we have one, he's a winner.  If we have more, do falseticker
+        * detection.
+        */
+
+       if (nlist == 0)
+               sys_server = 0;
+       else if (nlist == 1) {
+               sys_server = server_list[0];
+       } else {
+               /*
+                * Re-sort by stratum, bdelay estimate quality and
+                * server.delay.
+                */
+               for (i = 0; i < nlist-1; i++)
+                       for (j = i+1; j < nlist; j++) {
+                               if (server_list[i]->stratum
+                               < server_list[j]->stratum)
+                               break;  /* already sorted by stratum */
+                               if (server_list[i]->delay
+                               < server_list[j]->delay)
+                               continue;
+                               server = server_list[i];
+                               server_list[i] = server_list[j];
+                               server_list[j] = server;
+                       }
+
+               /*
+                * Calculate the fixed part of the dispersion limit
+                */
+               local_threshold = (FP_SECOND >> (-(int)NTPDATE_PRECISION))
+                       + NTP_MAXSKW;
+
+               /*
+                * Now drop samples until we're down to one.
+                */
+               while (nlist > 1) {
+                       for (n = 0; n < nlist; n++) {
+                               server_badness[n] = 0;
+                               for (j = 0; j < nlist; j++) {
+                                       if (j == n) /* with self? */
+                                               continue;
+                                       d = server_list[j]->soffset
+                                               - server_list[n]->soffset;
+                                       if (d < 0)      /* absolute value */
+                                               d = -d;
+                                       /*
+                                        * XXX This code *knows* that
+                                        * NTP_SELECT is 3/4
+                                        */
+                                       for (i = 0; i < j; i++)
+                                               d = (d>>1) + (d>>2);
+                                       server_badness[n] += d;
+                               }
+                       }
+
+                       /*
+                        * We now have an array of nlist badness
+                        * coefficients.        Find the badest.  Find
+                        * the minimum precision while we're at
+                        * it.
+                        */
+                       i = 0;
+                       n = server_list[0]->precision;;
+                       for (j = 1; j < nlist; j++) {
+                               if (server_badness[j] >= server_badness[i])
+                                       i = j;
+                               if (n > server_list[j]->precision)
+                                       n = server_list[j]->precision;
+                       }
+
+                       /*
+                        * i is the index of the server with the worst
+                        * dispersion.  If his dispersion is less than
+                        * the threshold, stop now, else delete him and
+                        * continue around again.
+                        */
+                       if ( (s_fp) server_badness[i] < (local_threshold
+                                                        + (FP_SECOND >> (-n))))
+                               break;
+                       for (j = i + 1; j < nlist; j++)
+                               server_list[j-1] = server_list[j];
+                       nlist--;
+               }
+
+               /*
+                * What remains is a list of less than 5 servers.  Take
+                * the best.
+                */
+               sys_server = server_list[0];
+       }
+
+       /*
+        * That's it.  Return our server.
+        */
+       return sys_server;
+}
+
+
+/*
+ * clock_adjust - process what we've received, and adjust the time
+ *              if we got anything decent.
+ */
+static int
+clock_adjust(void)
+{
+       register struct server *sp, *server;
+       s_fp absoffset;
+       int dostep;
+
+       for (sp = sys_servers; sp != NULL; sp = sp->next_server)
+               clock_filter(sp);
+       server = clock_select();
+
+       if (debug || simple_query) {
+               for (sp = sys_servers; sp != NULL; sp = sp->next_server)
+                       printserver(sp, stdout);
+       }
+
+       if (server == 0) {
+               msyslog(LOG_ERR,
+                       "no server suitable for synchronization found");
+               return(1);
+       }
+
+       if (always_step) {
+               dostep = 1;
+       } else if (never_step) {
+               dostep = 0;
+       } else {
+               absoffset = server->soffset;
+               if (absoffset < 0)
+                       absoffset = -absoffset;
+               dostep = (absoffset >= NTPDATE_THRESHOLD || absoffset < 0);
+       }
+
+       if (dostep) {
+               if (simple_query || debug || l_step_systime(&server->offset)){
+                       msyslog(LOG_NOTICE, "step time server %s offset %s sec",
+                               stoa(&server->srcadr),
+                               lfptoa(&server->offset, 6));
+               }
+       } else {
+#if !defined SYS_WINNT && !defined SYS_CYGWIN32
+               if (simple_query || l_adj_systime(&server->offset)) {
+                       msyslog(LOG_NOTICE, "adjust time server %s offset %s sec",
+                               stoa(&server->srcadr),
+                               lfptoa(&server->offset, 6));
+               }
+#else
+               /* The NT SetSystemTimeAdjustment() call achieves slewing by
+                * changing the clock frequency. This means that we cannot specify
+                * it to slew the clock by a definite amount and then stop like
+                * the Unix adjtime() routine. We can technically adjust the clock
+                * frequency, have ntpdate sleep for a while, and then wake
+                * up and reset the clock frequency, but this might cause some
+                * grief if the user attempts to run ntpd immediately after
+                * ntpdate and the socket is in use.
+                */
+               printf("\nThe -b option is required by ntpdate on Windows NT platforms\n");
+               exit(1);
+#endif /* SYS_WINNT */
+       }
+       return(0);
+}
+
+
+/*
+ * is_unreachable - check to see if we have a route to given destination
+ *                 (non-blocking).
+ */
+static int
+is_reachable (struct sockaddr_storage *dst)
+{
+       SOCKET sockfd;
+
+       sockfd = socket(dst->ss_family, SOCK_DGRAM, 0);
+       if (sockfd == -1) {
+               return 0;
+       }
+
+       if(connect(sockfd, (struct sockaddr *)dst, SOCKLEN(dst))) {
+               closesocket(sockfd);
+               return 0;
+       }
+       closesocket(sockfd);
+       return 1;
+}
+
+
+
+/* XXX ELIMINATE: merge BIG slew into adj_systime in lib/systime.c */
+/*
+ * addserver - determine a server's address and allocate a new structure
+ *             for it.
+ */
+static void
+addserver(
+       char *serv
+       )
+{
+       register struct server *server;
+       /* Address infos structure to store result of getaddrinfo */
+       struct addrinfo *addrResult, *ptr;
+       /* Address infos structure to store hints for getaddrinfo */
+       struct addrinfo hints;
+       /* Error variable for getaddrinfo */
+       int error;
+       /* Service name */
+       char service[5];
+       strcpy(service, "ntp");
+
+       /* Get host address. Looking for UDP datagram connection. */
+       memset(&hints, 0, sizeof(hints));
+       hints.ai_family = ai_fam_templ;
+       hints.ai_socktype = SOCK_DGRAM;
+
+#ifdef DEBUG
+       if (debug)
+               printf("Looking for host %s and service %s\n", serv, service);
+#endif
+
+       error = getaddrinfo(serv, service, &hints, &addrResult);
+       if (error != 0) {
+               /* Conduct more refined error analysis */
+               if (error == EAI_FAIL || error == EAI_AGAIN){
+                       /* Name server is unusable. Exit after failing on the
+                          first server, in order to shorten the timeout caused
+                          by waiting for resolution of several servers */
+                       fprintf(stderr, "Name server cannot be used, exiting");
+                       msyslog(LOG_ERR, "name server cannot be used, reason: %s\n", gai_strerror(error));
+                       exit(1);
+               }
+               fprintf(stderr, "Error : %s\n", gai_strerror(error));
+               msyslog(LOG_ERR, "can't find host %s\n", serv);
+               return;
+       }
+#ifdef DEBUG
+       else if (debug) {
+               fprintf(stderr, "host found : %s\n", stohost((struct sockaddr_storage*)addrResult->ai_addr));
+       }
+#endif
+
+       /* We must get all returned server in case the first one fails */
+       for (ptr = addrResult; ptr != NULL; ptr = ptr->ai_next) {
+               if (is_reachable ((struct sockaddr_storage *)ptr->ai_addr)) {
+                       server = (struct server *)emalloc(sizeof(struct server));
+                       memset((char *)server, 0, sizeof(struct server));
+
+                       memset(&(server->srcadr), 0, sizeof(struct sockaddr_storage));
+                       memcpy(&(server->srcadr), ptr->ai_addr, ptr->ai_addrlen);
+                       server->event_time = ++sys_numservers;
+                       if (sys_servers == NULL)
+                               sys_servers = server;
+                       else {
+                               struct server *sp;
+
+                               for (sp = sys_servers; sp->next_server != NULL;
+                                    sp = sp->next_server) ;
+                               sp->next_server = server;
+                       }
+               }
+       }
+
+       freeaddrinfo(addrResult);
+}
+
+
+/*
+ * findserver - find a server in the list given its address
+ * ***(For now it isn't totally AF-Independant, to check later..)
+ */
+static struct server *
+findserver(
+       struct sockaddr_storage *addr
+       )
+{
+       struct server *server;
+       struct server *mc_server;
+       isc_sockaddr_t laddr;
+       isc_sockaddr_t saddr;
+
+       if(addr->ss_family == AF_INET) {
+               isc_sockaddr_fromin( &laddr, &((struct sockaddr_in*)addr)->sin_addr, 0);
+       }
+       else {
+               isc_sockaddr_fromin6(&laddr, &((struct sockaddr_in6*)addr)->sin6_addr, 0);
+       }
+
+
+       mc_server = NULL;
+       if (htons(((struct sockaddr_in*)addr)->sin_port) != NTP_PORT)
+               return 0;
+
+       for (server = sys_servers; server != NULL; 
+            server = server->next_server) {
+               
+               if(server->srcadr.ss_family == AF_INET) {
+                       isc_sockaddr_fromin(&saddr, &((struct sockaddr_in*)&server->srcadr)->sin_addr, 0);
+               }
+               else {
+                       isc_sockaddr_fromin6(&saddr, &((struct sockaddr_in6*)&server->srcadr)->sin6_addr, 0);
+               }
+               if (isc_sockaddr_eqaddr(&laddr, &saddr) == ISC_TRUE)
+                       return server;
+
+               if(addr->ss_family == server->srcadr.ss_family) {
+                       if (isc_sockaddr_ismulticast(&saddr) == ISC_TRUE)
+                               mc_server = server;
+               }
+       }
+
+       if (mc_server != NULL) {        
+
+               struct server *sp;
+
+               if (mc_server->event_time != 0) {
+                       mc_server->event_time = 0;
+                       complete_servers++;
+               }
+
+               server = (struct server *)emalloc(sizeof(struct server));
+               memset((char *)server, 0, sizeof(struct server));
+
+               memcpy(&server->srcadr, addr, sizeof(struct sockaddr_storage));
+
+               server->event_time = ++sys_numservers;
+
+               for (sp = sys_servers; sp->next_server != NULL;
+                    sp = sp->next_server) ;
+               sp->next_server = server;
+               transmit(server);
+       }
+       return NULL;
+}
+
+
+/*
+ * timer - process a timer interrupt
+ */
+void
+timer(void)
+{
+       struct server *server;
+
+       /*
+        * Bump the current idea of the time
+        */
+       current_time++;
+
+       /*
+        * Search through the server list looking for guys
+        * who's event timers have expired.  Give these to
+        * the transmit routine.
+        */
+       for (server = sys_servers; server != NULL; 
+            server = server->next_server) {
+               if (server->event_time != 0
+                   && server->event_time <= current_time)
+                       transmit(server);
+       }
+}
+
+
+/*
+ * The code duplication in the following subroutine sucks, but
+ * we need to appease ansi2knr.
+ */
+
+#ifndef SYS_WINNT
+/*
+ * alarming - record the occurance of an alarm interrupt
+ */
+static RETSIGTYPE
+alarming(
+       int sig
+       )
+{
+       alarm_flag++;
+}
+#else
+void CALLBACK 
+alarming(UINT uTimerID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
+{
+       alarm_flag++;
+}
+#endif /* SYS_WINNT */
+
+
+#ifdef SYS_WINNT
+static void
+callTimeEndPeriod(void)
+{
+       timeEndPeriod( wTimerRes );
+       wTimerRes = 0;
+}
+#endif /* SYS_WINNT */
+
+
+/*
+ * init_alarm - set up the timer interrupt
+ */
+static void
+init_alarm(void)
+{
+#ifndef SYS_WINNT
+# ifndef HAVE_TIMER_SETTIME
+       struct itimerval itimer;
+# else
+       struct itimerspec ntpdate_itimer;
+# endif
+#else
+       TIMECAPS tc;
+       UINT wTimerID;
+# endif /* SYS_WINNT */
+#if defined SYS_CYGWIN32 || defined SYS_WINNT
+       HANDLE hToken;
+       TOKEN_PRIVILEGES tkp;
+       DWORD dwUser = 0;
+#endif /* SYS_WINNT */
+
+       alarm_flag = 0;
+
+#ifndef SYS_WINNT
+# if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME)
+       alarm_flag = 0;
+       /* this code was put in as setitimer() is non existant this us the
+        * POSIX "equivalents" setup - casey
+        */
+       /* ntpdate_timerid is global - so we can kill timer later */
+       if (timer_create (CLOCK_REALTIME, NULL, &ntpdate_timerid) ==
+#  ifdef SYS_VXWORKS
+               ERROR
+#  else
+               -1
+#  endif
+               )
+       {
+               fprintf (stderr, "init_alarm(): timer_create (...) FAILED\n");
+               return;
+       }
+
+       /*      TIMER_HZ = (5)
+        * Set up the alarm interrupt.  The first comes 1/(2*TIMER_HZ)
+        * seconds from now and they continue on every 1/TIMER_HZ seconds.
+        */
+       (void) signal_no_reset(SIGALRM, alarming);
+       ntpdate_itimer.it_interval.tv_sec = ntpdate_itimer.it_value.tv_sec = 0;
+       ntpdate_itimer.it_interval.tv_nsec = 1000000000/TIMER_HZ;
+       ntpdate_itimer.it_value.tv_nsec = 1000000000/(TIMER_HZ<<1);
+       timer_settime(ntpdate_timerid, 0 /* !TIMER_ABSTIME */, &ntpdate_itimer, NULL);
+# else
+       /*
+        * Set up the alarm interrupt.  The first comes 1/(2*TIMER_HZ)
+        * seconds from now and they continue on every 1/TIMER_HZ seconds.
+        */
+       (void) signal_no_reset(SIGALRM, alarming);
+       itimer.it_interval.tv_sec = itimer.it_value.tv_sec = 0;
+       itimer.it_interval.tv_usec = 1000000/TIMER_HZ;
+       itimer.it_value.tv_usec = 1000000/(TIMER_HZ<<1);
+
+       setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
+# endif
+#if defined SYS_CYGWIN32
+       /*
+        * Get privileges needed for fiddling with the clock
+        */
+
+       /* get the current process token handle */
+       if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
+               msyslog(LOG_ERR, "OpenProcessToken failed: %m");
+               exit(1);
+       }
+       /* get the LUID for system-time privilege. */
+       LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkp.Privileges[0].Luid);
+       tkp.PrivilegeCount = 1;         /* one privilege to set */
+       tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+       /* get set-time privilege for this process. */
+       AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES) NULL, 0);
+       /* cannot test return value of AdjustTokenPrivileges. */
+       if (GetLastError() != ERROR_SUCCESS)
+               msyslog(LOG_ERR, "AdjustTokenPrivileges failed: %m");
+#endif
+#else  /* SYS_WINNT */
+       _tzset();
+
+       /*
+        * Get privileges needed for fiddling with the clock
+        */
+
+       /* get the current process token handle */
+       if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
+               msyslog(LOG_ERR, "OpenProcessToken failed: %m");
+               exit(1);
+       }
+       /* get the LUID for system-time privilege. */
+       LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkp.Privileges[0].Luid);
+       tkp.PrivilegeCount = 1;         /* one privilege to set */
+       tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+       /* get set-time privilege for this process. */
+       AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES) NULL, 0);
+       /* cannot test return value of AdjustTokenPrivileges. */
+       if (GetLastError() != ERROR_SUCCESS)
+               msyslog(LOG_ERR, "AdjustTokenPrivileges failed: %m");
+
+       /*
+        * Set up timer interrupts for every 2**EVENT_TIMEOUT seconds
+        * Under Win/NT, expiry of timer interval leads to invocation
+        * of a callback function (on a different thread) rather than
+        * generating an alarm signal
+        */
+
+       /* determine max and min resolution supported */
+       if(timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
+               msyslog(LOG_ERR, "timeGetDevCaps failed: %m");
+               exit(1);
+       }
+       wTimerRes = min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
+       /* establish the minimum timer resolution that we'll use */
+       timeBeginPeriod(wTimerRes);
+       atexit(callTimeEndPeriod);
+
+       /* start the timer event */
+       wTimerID = timeSetEvent(
+               (UINT) (1000/TIMER_HZ),         /* Delay */
+               wTimerRes,                      /* Resolution */
+               (LPTIMECALLBACK) alarming,      /* Callback function */
+               (DWORD) dwUser,                 /* User data */
+               TIME_PERIODIC);                 /* Event type (periodic) */
+       if (wTimerID == 0) {
+               msyslog(LOG_ERR, "timeSetEvent failed: %m");
+               exit(1);
+       }
+#endif /* SYS_WINNT */
+}
+
+
+
+
+/*
+ * We do asynchronous input using the SIGIO facility.  A number of
+ * recvbuf buffers are preallocated for input. In the signal
+ * handler we poll to see if the socket is ready and read the
+ * packets from it into the recvbuf's along with a time stamp and
+ * an indication of the source host and the interface it was received
+ * through.  This allows us to get as accurate receive time stamps
+ * as possible independent of other processing going on.
+ *
+ * We allocate a number of recvbufs equal to the number of servers
+ * plus 2.     This should be plenty.
+ */
+
+
+/*
+ * init_io - initialize I/O data and open socket
+ */
+static void
+init_io(void)
+{
+       struct addrinfo *res, *ressave;
+       struct addrinfo hints;
+       char service[5];
+       int optval = 1;
+       int check_ntp_port_in_use = !debug && !simple_query && !unpriv_port;
+
+       /*
+        * Init buffer free list and stat counters
+        */
+       init_recvbuff(sys_numservers + 2);
+
+       /*
+        * Open the socket
+        */
+
+       strcpy(service, "ntp");
+
+       /*
+        * Init hints addrinfo structure
+        */
+       memset(&hints, 0, sizeof(hints));
+       hints.ai_family = ai_fam_templ;
+       hints.ai_flags = AI_PASSIVE;
+       hints.ai_socktype = SOCK_DGRAM;
+
+       if(getaddrinfo(NULL, service, &hints, &res) != 0) {
+              msyslog(LOG_ERR, "getaddrinfo() failed: %m");
+              exit(1);
+              /*NOTREACHED*/
+       }
+
+#ifdef SYS_WINNT
+       if (check_ntp_port_in_use && ntp_port_inuse(AF_INET, NTP_PORT)){
+               netsyslog(LOG_ERR, "the NTP socket is in use, exiting: %m");
+               exit(1);
+       }
+#endif
+
+       /* Remember the address of the addrinfo structure chain */
+       ressave = res;
+
+       /*
+        * For each structure returned, open and bind socket
+        */
+       for(nbsock = 0; (nbsock < MAX_AF) && res ; res = res->ai_next) {
+       /* create a datagram (UDP) socket */
+               fd[nbsock] = socket(res->ai_family, res->ai_socktype, res->ai_protocol);
+               if (fd[nbsock] == SOCKET_ERROR) {
+#ifndef SYS_WINNT
+               if (errno == EPROTONOSUPPORT || errno == EAFNOSUPPORT ||
+                   errno == EPFNOSUPPORT)
+#else
+               int err = WSAGetLastError();
+               if (err == WSAEPROTONOSUPPORT || err == WSAEAFNOSUPPORT ||
+                   err == WSAEPFNOSUPPORT)
+#endif
+                       continue;
+               netsyslog(LOG_ERR, "socket() failed: %m");
+               exit(1);
+               /*NOTREACHED*/
+               }
+               /* set socket to reuse address */
+               if (setsockopt(fd[nbsock], SOL_SOCKET, SO_REUSEADDR, (void*) &optval, sizeof(optval)) < 0) {
+                               netsyslog(LOG_ERR, "setsockopt() SO_REUSEADDR failed: %m");
+                               exit(1);
+                               /*NOTREACHED*/
+               }
+#ifdef IPV6_V6ONLY
+               /* Restricts AF_INET6 socket to IPv6 communications (see RFC 2553bis-03) */
+               if (res->ai_family == AF_INET6)
+                       if (setsockopt(fd[nbsock], IPPROTO_IPV6, IPV6_V6ONLY, (void*) &optval, sizeof(optval)) < 0) {
+                                  netsyslog(LOG_ERR, "setsockopt() IPV6_V6ONLY failed: %m");
+                                       exit(1);
+                                       /*NOTREACHED*/
+               }
+#endif
+
+               /* Remember the socket family in fd_family structure */
+               fd_family[nbsock] = res->ai_family;
+
+               /*
+                * bind the socket to the NTP port
+                */
+               if (check_ntp_port_in_use) {
+                       if (bind(fd[nbsock], res->ai_addr, SOCKLEN(res->ai_addr)) < 0) {
+#ifndef SYS_WINNT
+                               if (errno == EADDRINUSE)
+#else
+                               if (WSAGetLastError() == WSAEADDRINUSE)
+#endif /* SYS_WINNT */
+                                       netsyslog(LOG_ERR, "the NTP socket is in use, exiting");
+                               else
+                                       netsyslog(LOG_ERR, "bind() fails: %m");
+                               exit(1);
+                       }
+               }
+
+#ifdef HAVE_POLL_H
+               fdmask[nbsock].fd = fd[nbsock];
+               fdmask[nbsock].events = POLLIN;
+#else
+               FD_SET(fd[nbsock], &fdmask);
+               if (maxfd < fd[nbsock]+1) {
+                       maxfd = fd[nbsock]+1;
+               }
+#endif
+
+               /*
+                * set non-blocking,
+                */
+#ifndef SYS_WINNT
+# ifdef SYS_VXWORKS
+               {
+               int on = TRUE;
+
+               if (ioctl(fd[nbsock],FIONBIO, &on) == ERROR) {
+                 netsyslog(LOG_ERR, "ioctl(FIONBIO) fails: %m");
+                       exit(1);
+               }
+               }
+# else /* not SYS_VXWORKS */
+#  if defined(O_NONBLOCK)
+               if (fcntl(fd[nbsock], F_SETFL, O_NONBLOCK) < 0) {
+                       netsyslog(LOG_ERR, "fcntl(FNDELAY|FASYNC) fails: %m");
+                       exit(1);
+                       /*NOTREACHED*/
+               }
+#  else /* not O_NONBLOCK */
+#      if defined(FNDELAY)
+               if (fcntl(fd[nbsock], F_SETFL, FNDELAY) < 0) {
+                       netsyslog(LOG_ERR, "fcntl(FNDELAY|FASYNC) fails: %m");
+                       exit(1);
+                       /*NOTREACHED*/
+               }
+#      else /* FNDELAY */
+#       include "Bletch: Need non blocking I/O"
+#      endif /* FNDELAY */
+#  endif /* not O_NONBLOCK */
+# endif /* SYS_VXWORKS */
+#else /* SYS_WINNT */
+               if (ioctlsocket(fd[nbsock], FIONBIO, (u_long *) &on) == SOCKET_ERROR) {
+                       netsyslog(LOG_ERR, "ioctlsocket(FIONBIO) fails: %m");
+                       exit(1);
+               }
+#endif /* SYS_WINNT */
+               nbsock++;
+       }
+       freeaddrinfo(ressave);
+}
+
+/*
+ * sendpkt - send a packet to the specified destination
+ */
+static void
+sendpkt(
+       struct sockaddr_storage *dest,
+       struct pkt *pkt,
+       int len
+       )
+{
+       int i;
+       int cc;
+       SOCKET sock = INVALID_SOCKET;
+
+#ifdef SYS_WINNT
+       DWORD err;
+#endif /* SYS_WINNT */
+
+       /* Find a local family compatible socket to send ntp packet to ntp server */
+       for(i = 0; (i < MAX_AF); i++) {
+               if(dest->ss_family == fd_family[i]) {
+                       sock = fd[i];
+               break;
+               }
+       }
+
+       if ( sock == INVALID_SOCKET ) {
+               netsyslog(LOG_ERR, "cannot find family compatible socket to send ntp packet");
+               exit(1);
+               /*NOTREACHED*/
+       }
+
+       cc = sendto(sock, (char *)pkt, len, 0, (struct sockaddr *)dest,
+                       SOCKLEN(dest));
+
+       if (cc == SOCKET_ERROR) {
+#ifndef SYS_WINNT
+               if (errno != EWOULDBLOCK && errno != ENOBUFS)
+#else
+               err = WSAGetLastError();
+               if (err != WSAEWOULDBLOCK && err != WSAENOBUFS)
+#endif /* SYS_WINNT */
+                       netsyslog(LOG_ERR, "sendto(%s): %m", stohost(dest));
+       }
+}
+
+
+/*
+ * input_handler - receive packets asynchronously
+ */
+void
+input_handler(void)
+{
+       register int n;
+       register struct recvbuf *rb;
+       struct timeval tvzero;
+       int fromlen;
+       l_fp ts;
+       int i;
+#ifdef HAVE_POLL_H
+       struct pollfd fds[MAX_AF];
+#else
+       fd_set fds;
+#endif
+       int fdc = 0;
+
+       /*
+        * Do a poll to see if we have data
+        */
+       for (;;) {
+               tvzero.tv_sec = tvzero.tv_usec = 0;
+#ifdef HAVE_POLL_H
+               memcpy(fds, fdmask, sizeof(fdmask));
+               n = poll(fds, (unsigned int)nbsock, tvzero.tv_sec * 1000);
+
+               /*
+                * Determine which socket received data
+                */
+
+               for(i=0; i < nbsock; i++) {
+                       if(fds[i].revents & POLLIN) {
+                               fdc = fd[i];
+                               break;
+                       }
+               }
+
+#else
+               fds = fdmask;
+               n = select(maxfd, &fds, (fd_set *)0, (fd_set *)0, &tvzero);
+
+               /*
+                * Determine which socket received data
+                */
+
+               for(i=0; i < nbsock; i++) {
+                       if(FD_ISSET(fd[i], &fds)) {
+                                fdc = fd[i];
+                                break;
+                       }
+               }
+
+#endif
+
+               /*
+                * If nothing to do, just return.  If an error occurred,
+                * complain and return.  If we've got some, freeze a
+                * timestamp.
+                */
+               if (n == 0)
+                       return;
+               else if (n == -1) {
+                       if (errno != EINTR)
+                               netsyslog(LOG_ERR,
+#ifdef HAVE_POLL_H
+                                       "poll() error: %m"
+#else
+                                       "select() error: %m"
+#endif
+                                       );
+                       return;
+               }
+               get_systime(&ts);
+
+               /*
+                * Get a buffer and read the frame.  If we
+                * haven't got a buffer, or this is received
+                * on the wild card socket, just dump the packet.
+                */
+               if (initializing || free_recvbuffs() == 0) {
+                       char buf[100];
+
+
+#ifndef SYS_WINNT
+                       (void) read(fdc, buf, sizeof buf);
+#else
+                       /* NT's _read does not operate on nonblocking sockets
+                        * either recvfrom or ReadFile() has to be used here.
+                        * ReadFile is used in [ntpd]ntp_intres() and ntpdc,
+                        * just to be different use recvfrom() here
+                        */
+                       recvfrom(fdc, buf, sizeof(buf), 0, (struct sockaddr *)0, NULL);
+#endif /* SYS_WINNT */
+                       continue;
+               }
+
+               rb = get_free_recv_buffer();
+
+               fromlen = sizeof(struct sockaddr_storage);
+               rb->recv_length = recvfrom(fdc, (char *)&rb->recv_pkt,
+                  sizeof(rb->recv_pkt), 0,
+                  (struct sockaddr *)&rb->recv_srcadr, &fromlen);
+               if (rb->recv_length == -1) {
+                       freerecvbuf(rb);
+                       continue;
+               }
+
+               /*
+                * Got one.  Mark how and when it got here,
+                * put it on the full list.
+                */
+               rb->recv_time = ts;
+               add_full_recv_buffer(rb);
+       }
+}
+
+
+#if !defined SYS_WINNT && !defined SYS_CYGWIN32
+/*
+ * adj_systime - do a big long slew of the system time
+ */
+static int
+l_adj_systime(
+       l_fp *ts
+       )
+{
+       struct timeval adjtv, oadjtv;
+       int isneg = 0;
+       l_fp offset;
+#ifndef STEP_SLEW
+       l_fp overshoot;
+#endif
+
+       /*
+        * Take the absolute value of the offset
+        */
+       offset = *ts;
+       if (L_ISNEG(&offset)) {
+               isneg = 1;
+               L_NEG(&offset);
+       }
+
+#ifndef STEP_SLEW
+       /*
+        * Calculate the overshoot.  XXX N.B. This code *knows*
+        * ADJ_OVERSHOOT is 1/2.
+        */
+       overshoot = offset;
+       L_RSHIFTU(&overshoot);
+       if (overshoot.l_ui != 0 || (overshoot.l_uf > ADJ_MAXOVERSHOOT)) {
+               overshoot.l_ui = 0;
+               overshoot.l_uf = ADJ_MAXOVERSHOOT;
+       }
+       L_ADD(&offset, &overshoot);
+#endif
+       TSTOTV(&offset, &adjtv);
+
+       if (isneg) {
+               adjtv.tv_sec = -adjtv.tv_sec;
+               adjtv.tv_usec = -adjtv.tv_usec;
+       }
+
+       if (adjtv.tv_usec != 0 && !debug) {
+               if (adjtime(&adjtv, &oadjtv) < 0) {
+                       msyslog(LOG_ERR, "Can't adjust the time of day: %m");
+                       return 0;
+               }
+       }
+       return 1;
+}
+#endif /* SYS_WINNT */
+
+
+/*
+ * This fuction is not the same as lib/systime step_systime!!!
+ */
+static int
+l_step_systime(
+       l_fp *ts
+       )
+{
+       double dtemp;
+
+#ifdef SLEWALWAYS
+#ifdef STEP_SLEW
+       l_fp ftmp;
+       int isneg;
+       int n;
+
+       if (debug) return 1;
+       /*
+        * Take the absolute value of the offset
+        */
+       ftmp = *ts;
+       if (L_ISNEG(&ftmp)) {
+               L_NEG(&ftmp);
+               isneg = 1;
+       } else
+               isneg = 0;
+
+       if (ftmp.l_ui >= 3) {           /* Step it and slew - we might win */
+               LFPTOD(ts, dtemp);
+               n = step_systime(dtemp);
+               if (!n)
+                       return n;
+               if (isneg)
+                       ts->l_ui = ~0;
+               else
+                       ts->l_ui = ~0;
+       }
+       /*
+        * Just add adjustment into the current offset.  The update
+        * routine will take care of bringing the system clock into
+        * line.
+        */
+#endif
+       if (debug)
+               return 1;
+#ifdef FORCE_NTPDATE_STEP
+       LFPTOD(ts, dtemp);
+       return step_systime(dtemp);
+#else
+       l_adj_systime(ts);
+       return 1;
+#endif
+#else /* SLEWALWAYS */
+       if (debug)
+               return 1;
+       LFPTOD(ts, dtemp);
+       return step_systime(dtemp);
+#endif /* SLEWALWAYS */
+}
+
+
+/* XXX ELIMINATE printserver similar in ntptrace.c, ntpdate.c */
+/*
+ * printserver - print detail information for a server
+ */
+static void
+printserver(
+       register struct server *pp,
+       FILE *fp
+       )
+{
+       register int i;
+       char junk[5];
+       char *str;
+
+       if (!debug) {
+               (void) fprintf(fp, "server %s, stratum %d, offset %s, delay %s\n",
+                                  stoa(&pp->srcadr), pp->stratum,
+                                  lfptoa(&pp->offset, 6), fptoa((s_fp)pp->delay, 5));
+               return;
+       }
+
+       (void) fprintf(fp, "server %s, port %d\n",
+                          stoa(&pp->srcadr), ntohs(((struct sockaddr_in*)&(pp->srcadr))->sin_port));
+
+       (void) fprintf(fp, "stratum %d, precision %d, leap %c%c, trust %03o\n",
+                          pp->stratum, pp->precision,
+                          pp->leap & 0x2 ? '1' : '0',
+                          pp->leap & 0x1 ? '1' : '0',
+                          pp->trust);
+
+       if (pp->stratum == 1) {
+               junk[4] = 0;
+               memmove(junk, (char *)&pp->refid, 4);
+               str = junk;
+       } else {
+               str = stoa(&pp->srcadr);
+       }
+       (void) fprintf(fp,
+                          "refid [%s], delay %s, dispersion %s\n",
+                          str, fptoa((s_fp)pp->delay, 5),
+                          ufptoa(pp->dispersion, 5));
+
+       (void) fprintf(fp, "transmitted %d, in filter %d\n",
+                          pp->xmtcnt, pp->filter_nextpt);
+
+       (void) fprintf(fp, "reference time:    %s\n",
+                          prettydate(&pp->reftime));
+       (void) fprintf(fp, "originate timestamp: %s\n",
+                          prettydate(&pp->org));
+       (void) fprintf(fp, "transmit timestamp:  %s\n",
+                          prettydate(&pp->xmt));
+
+       (void) fprintf(fp, "filter delay: ");
+       for (i = 0; i < NTP_SHIFT; i++) {
+               (void) fprintf(fp, " %-8.8s", fptoa(pp->filter_delay[i], 5));
+               if (i == (NTP_SHIFT>>1)-1)
+                       (void) fprintf(fp, "\n        ");
+       }
+       (void) fprintf(fp, "\n");
+
+       (void) fprintf(fp, "filter offset:");
+       for (i = 0; i < PEER_SHIFT; i++) {
+               (void) fprintf(fp, " %-8.8s", lfptoa(&pp->filter_offset[i], 6));
+               if (i == (PEER_SHIFT>>1)-1)
+                       (void) fprintf(fp, "\n        ");
+       }
+       (void) fprintf(fp, "\n");
+
+       (void) fprintf(fp, "delay %s, dispersion %s\n",
+                          fptoa((s_fp)pp->delay, 5), ufptoa(pp->dispersion, 5));
+
+       (void) fprintf(fp, "offset %s\n\n",
+                          lfptoa(&pp->offset, 6));
+}
+
+#if !defined(HAVE_VSPRINTF)
+int
+vsprintf(
+       char *str,
+       const char *fmt,
+       va_list ap
+       )
+{
+       FILE f;
+       int len;
+
+       f._flag = _IOWRT+_IOSTRG;
+       f._ptr = str;
+       f._cnt = 32767;
+       len = _doprnt(fmt, ap, &f);
+       *f._ptr = 0;
+       return (len);
+}
+#endif
+
+#if 0
+/* override function in library since SA_RESTART makes ALL syscalls restart */
+#ifdef SA_RESTART
+void
+signal_no_reset(
+       int sig,
+       void (*func)()
+       )
+{
+       int n;
+       struct sigaction vec;
+
+       vec.sa_handler = func;
+       sigemptyset(&vec.sa_mask);
+       vec.sa_flags = 0;
+
+       while (1)
+       {
+               n = sigaction(sig, &vec, NULL);
+               if (n == -1 && errno == EINTR)
+                       continue;
+               break;
+       }
+       if (n == -1)
+       {
+               perror("sigaction");
+               exit(1);
+       }
+}
+#endif
+#endif
+
+#ifdef HAVE_NETINFO
+static ni_namelist *
+getnetinfoservers(void)
+{
+       ni_status status;
+       void *domain;
+       ni_id confdir;
+       ni_namelist *namelist = (ni_namelist*)malloc(sizeof(ni_namelist));
+
+       /* Find a time server in NetInfo */
+       if ((status = ni_open(NULL, ".", &domain)) != NI_OK) return NULL;
+
+       while (status = ni_pathsearch(domain, &confdir, NETINFO_CONFIG_DIR) == NI_NODIR) {
+               void *next_domain;
+               if (ni_open(domain, "..", &next_domain) != NI_OK) break;
+               ni_free(domain);
+               domain = next_domain;
+       }
+       if (status != NI_OK) return NULL;
+
+       NI_INIT(namelist);
+       if (ni_lookupprop(domain, &confdir, "server", namelist) != NI_OK) {
+               ni_namelist_free(namelist);
+               free(namelist);
+               return NULL;
+       }
+
+       return(namelist);
+}
+#endif
+
+#ifdef SYS_WINNT
+isc_boolean_t ntp_port_inuse(int af, u_short port)
+{
+       /*
+        * Check if NTP socket is already in use on this system
+        * This is only for Windows Systems, as they tend not to fail on the real bind() below
+        */
+       
+       SOCKET checksocket;
+       struct sockaddr_in checkservice;
+       checksocket = socket(af, SOCK_DGRAM, 0);
+       if (checksocket == INVALID_SOCKET) {
+               return (ISC_TRUE);
+       }
+
+       checkservice.sin_family = (short) AF_INET;
+       checkservice.sin_addr.s_addr = INADDR_LOOPBACK;
+       checkservice.sin_port = htons(port);
+
+       if (bind(checksocket, (struct sockaddr *)&checkservice,
+               sizeof(checkservice)) == SOCKET_ERROR) {
+               if ( WSAGetLastError() == WSAEADDRINUSE ){
+                       closesocket(checksocket);
+                       return (ISC_TRUE);
+               }
+       }
+       closesocket(checksocket);
+       return (ISC_FALSE);
+}
+#endif
diff --git a/ntpdate/ntpdate.h b/ntpdate/ntpdate.h
new file mode 100644 (file)
index 0000000..f3531b3
--- /dev/null
@@ -0,0 +1,104 @@
+/*
+ * ntpdate.h - declarations for the ntpdate and ntptimeset programs
+ */
+
+#include "ntp_malloc.h"
+
+extern void    loadservers     P((char *cfgpath));
+
+/*
+ * The server structure is a much simplified version of the
+ * peer structure, for ntpdate's use.  Since we always send
+ * in client mode and expect to receive in server mode, this
+ * leaves only a very limited number of things we need to
+ * remember about the server.
+ */
+struct server {
+       struct server *next_server;     /* next server in build list */
+       struct sockaddr_storage srcadr; /* address of remote host */
+       u_char version;                 /* version to use */
+       u_char leap;                    /* leap indicator */
+       u_char stratum;                 /* stratum of remote server */
+       s_char precision;               /* server's clock precision */
+       u_char trust;                   /* trustability of the filtered data */
+       u_fp rootdelay;                 /* distance from primary clock */
+       u_fp rootdispersion;            /* peer clock dispersion */
+       u_int32 refid;                  /* peer reference ID */
+       l_fp reftime;                   /* time of peer's last update */
+       u_long event_time;              /* time for next timeout */
+       u_long last_xmit;               /* time of last transmit */
+       u_short xmtcnt;                 /* number of packets transmitted */
+       u_short rcvcnt;                 /* number of packets received */
+       u_char reach;                   /* reachability, NTP_WINDOW bits */
+       u_short filter_nextpt;          /* index into filter shift register */
+       s_fp filter_delay[NTP_SHIFT];   /* delay part of shift register */
+       l_fp filter_offset[NTP_SHIFT];  /* offset part of shift register */
+       s_fp filter_soffset[NTP_SHIFT]; /* offset in s_fp format, for disp */
+       u_fp filter_error[NTP_SHIFT];   /* error part of shift register */
+       l_fp org;                       /* peer's originate time stamp */
+       l_fp xmt;                       /* transmit time stamp */
+       u_fp delay;                     /* filter estimated delay */
+       u_fp dispersion;                /* filter estimated dispersion */
+       l_fp offset;                    /* filter estimated clock offset */
+       s_fp soffset;                   /* fp version of above */
+};
+
+
+/*
+ * ntpdate runs everything on a simple, short timeout.  It sends a
+ * packet and sets the timeout (by default, to a small value suitable
+ * for a LAN).  If it receives a response it sends another request.
+ * If it times out it shifts zeroes into the filter and sends another
+ * request.
+ *
+ * The timer routine is run often (once every 1/5 second currently)
+ * so that time outs are done with reasonable precision.
+ */
+#define TIMER_HZ       (5)             /* 5 per second */
+
+/*
+ * ntpdate will make a long adjustment using adjtime() if the times
+ * are close, or step the time if the times are farther apart.  The
+ * following defines what is "close".
+ */
+#define        NTPDATE_THRESHOLD       (FP_SECOND >> 1)        /* 1/2 second */
+
+#define NTP_MAXAGE     86400   /* one day in seconds */
+
+/*
+ * When doing adjustments, ntpdate actually overadjusts (currently
+ * by 50%, though this may change).  While this will make it take longer
+ * to reach a steady state condition, it will typically result in
+ * the clock keeping more accurate time, on average.  The amount of
+ * overshoot is limited.
+ */
+#ifdef NOTNOW
+#define        ADJ_OVERSHOOT   1/2     /* this is hard coded */
+#endif /* NOTNOW */
+#define        ADJ_MAXOVERSHOOT        0x10000000      /* 50 ms as a ts fraction */
+
+/*
+ * Since ntpdate isn't aware of some of the things that normally get
+ * put in an NTP packet, we fix some values.
+ */
+#define        NTPDATE_PRECISION       (-6)            /* use this precision */
+#define        NTPDATE_DISTANCE        FP_SECOND       /* distance is 1 sec */
+#define        NTPDATE_DISP            FP_SECOND       /* so is the dispersion */
+#define        NTPDATE_REFID           (0)             /* reference ID to use */
+#define PEER_MAXDISP   (64*FP_SECOND)  /* maximum dispersion (fp 64) */
+
+
+/*
+ * Some defaults
+ */
+#define        DEFTIMEOUT      5               /* 5 timer increments */
+#define        DEFSAMPLES      4               /* get 4 samples per server */
+#define        DEFPRECISION    (-5)            /* the precision we claim */
+#define        DEFMAXPERIOD    60              /* maximum time to wait */
+#define        DEFMINSERVERS   3               /* minimum responding servers */
+#define        DEFMINVALID     1               /* mimimum servers with valid time */
+
+/*
+ * Define the max number of sockets we can open
+ */
+#define MAX_AF 2
diff --git a/ntpdate/ntptime_config.c b/ntpdate/ntptime_config.c
new file mode 100644 (file)
index 0000000..e784d28
--- /dev/null
@@ -0,0 +1,552 @@
+/*
+ * ntptime_config.c
+ *
+ * What follows is a simplified version of the config parsing code
+ * in ntpd/ntp_config.c.  We only parse a subset of the configuration
+ * syntax, and don't bother whining about things we don't understand.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntp_io.h"
+#include "ntp_unixtime.h"
+#include "ntp_filegen.h"
+#include "ntpdate.h"
+#include "ntp_syslog.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <signal.h>
+#include <ctype.h>
+
+/*
+ * These routines are used to read the configuration file at
+ * startup time.  An entry in the file must fit on a single line.
+ * Entries are processed as multiple tokens separated by white space
+ * Lines are considered terminated when a '#' is encountered.  Blank
+ * lines are ignored.
+ */
+
+/*
+ * Configuration file name
+ */
+#ifndef CONFIG_FILE
+# ifndef SYS_WINNT
+#  define      CONFIG_FILE "/etc/ntp.conf"
+# else /* SYS_WINNT */
+#  define      CONFIG_FILE     "%windir%\\ntp.conf"
+#  define      ALT_CONFIG_FILE "%windir%\\ntp.ini"
+# endif /* SYS_WINNT */
+#endif /* not CONFIG_FILE */
+
+/*
+ *
+ * We understand the following configuration entries and defaults.
+ *
+ * peer [ addr ] [ version 3 ] [ key 0 ] [ minpoll 6 ] [ maxpoll 10 ]
+ * server [ addr ] [ version 3 ] [ key 0 ] [ minpoll 6 ] [ maxpoll 10 ]
+ * keys file_name
+ */
+
+#define CONFIG_UNKNOWN         0
+
+#define CONFIG_PEER            1
+#define CONFIG_SERVER          2
+#define CONFIG_KEYS            8
+
+#define CONF_MOD_VERSION       1
+#define CONF_MOD_KEY           2
+#define CONF_MOD_MINPOLL       3
+#define CONF_MOD_MAXPOLL       4
+#define CONF_MOD_PREFER        5
+#define CONF_MOD_BURST         6
+#define CONF_MOD_SKEY          7
+#define CONF_MOD_TTL           8
+#define CONF_MOD_MODE          9
+
+/*
+ * Translation table - keywords to function index
+ */
+struct keyword {
+       const char *text;
+       int keytype;
+};
+
+/*
+ * Command keywords
+ */
+static struct keyword keywords[] = {
+       { "peer",       CONFIG_PEER },
+       { "server",     CONFIG_SERVER },
+       { "keys",       CONFIG_KEYS },
+       { "",           CONFIG_UNKNOWN }
+};
+
+/*
+ * "peer", "server", "broadcast" modifier keywords
+ */
+static struct keyword mod_keywords[] = {
+       { "version",    CONF_MOD_VERSION },
+       { "key",    CONF_MOD_KEY },
+       { "minpoll",    CONF_MOD_MINPOLL },
+       { "maxpoll",    CONF_MOD_MAXPOLL },
+       { "prefer", CONF_MOD_PREFER },
+       { "burst",  CONF_MOD_BURST },
+       { "autokey",    CONF_MOD_SKEY },
+       { "mode",   CONF_MOD_MODE },    /* reference clocks */
+       { "ttl",    CONF_MOD_TTL },     /* NTP peers */
+       { "",       CONFIG_UNKNOWN }
+};
+
+/*
+ * Limits on things
+ */
+#define MAXTOKENS      20      /* 20 tokens on line */
+#define MAXLINE        1024    /* maximum length of line */
+#define MAXFILENAME 128 /* maximum length of a file name (alloca()?) */
+
+/*
+ * Miscellaneous macros
+ */
+#define STRSAME(s1, s2)        (*(s1) == *(s2) && strcmp((s1), (s2)) == 0)
+#define ISEOL(c)               ((c) == '#' || (c) == '\n' || (c) == '\0')
+#define ISSPACE(c)             ((c) == ' ' || (c) == '\t')
+#define STREQ(a, b)    (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+/*
+ * Systemwide parameters and flags
+ */
+extern struct server **sys_servers;    /* the server list */
+extern int sys_numservers;     /* number of servers to poll */
+extern char *key_file;
+
+/*
+ * Function prototypes
+ */
+static int gettokens   P((FILE *, char *, char **, int *));
+static int matchkey    P((char *, struct keyword *));
+static int getnetnum   P((const char *num, struct sockaddr_in *addr,
+                          int complain));
+
+
+/*
+ * loadservers - load list of NTP servers from configuration file
+ */
+void
+loadservers(
+       char *cfgpath
+       )
+{
+       register int i;
+       int errflg;
+       int peerversion;
+       int minpoll;
+       int maxpoll;
+       /* int ttl; */
+       int srvcnt;
+       /* u_long peerkey; */
+       int peerflags;
+       struct sockaddr_in peeraddr;
+       FILE *fp;
+       char line[MAXLINE];
+       char *(tokens[MAXTOKENS]);
+       int ntokens;
+       int tok;
+       const char *config_file;
+#ifdef SYS_WINNT
+       char *alt_config_file;
+       LPTSTR temp;
+       char config_file_storage[MAX_PATH];
+       char alt_config_file_storage[MAX_PATH];
+#endif /* SYS_WINNT */
+       struct server *server, *srvlist;
+
+       /*
+        * Initialize, initialize
+        */
+       srvcnt = 0;
+       srvlist = 0;
+       errflg = 0;
+#ifdef DEBUG
+       debug = 0;
+#endif /* DEBUG */
+#ifndef SYS_WINNT
+       config_file = cfgpath ? cfgpath : CONFIG_FILE;
+#else
+       if (cfgpath) {
+               config_file = cfgpath;
+       } else {
+               temp = CONFIG_FILE;
+               if (!ExpandEnvironmentStrings((LPCTSTR)temp, (LPTSTR)config_file_storage, (DWORD)sizeof(config_file_storage))) {
+                       msyslog(LOG_ERR, "ExpandEnvironmentStrings CONFIG_FILE failed: %m\n");
+                       exit(1);
+               }
+               config_file = config_file_storage;
+       }
+
+       temp = ALT_CONFIG_FILE;
+       if (!ExpandEnvironmentStrings((LPCTSTR)temp, (LPTSTR)alt_config_file_storage, (DWORD)sizeof(alt_config_file_storage))) {
+               msyslog(LOG_ERR, "ExpandEnvironmentStrings ALT_CONFIG_FILE failed: %m\n");
+               exit(1);
+       }
+       alt_config_file = alt_config_file_storage;
+M
+#endif /* SYS_WINNT */
+
+       if ((fp = fopen(FindConfig(config_file), "r")) == NULL)
+       {
+               fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig(config_file));
+               msyslog(LOG_INFO, "getconfig: Couldn't open <%s>", FindConfig(config_file));
+#ifdef SYS_WINNT
+               /* Under WinNT try alternate_config_file name, first NTP.CONF, then NTP.INI */
+
+               if ((fp = fopen(FindConfig(alt_config_file), "r")) == NULL) {
+
+                       /*
+                        * Broadcast clients can sometimes run without
+                        * a configuration file.
+                        */
+
+                       fprintf(stderr, "getconfig: Couldn't open <%s>\n", FindConfig(alt_config_file));
+                       msyslog(LOG_INFO, "getconfig: Couldn't open <%s>", FindConfig(alt_config_file));
+                       return;
+               }
+#else  /* not SYS_WINNT */
+               return;
+#endif /* not SYS_WINNT */
+       }
+
+       while ((tok = gettokens(fp, line, tokens, &ntokens))
+              != CONFIG_UNKNOWN) {
+               switch(tok) {
+                   case CONFIG_PEER:
+                   case CONFIG_SERVER:
+                       
+                       if (ntokens < 2) {
+                               msyslog(LOG_ERR,
+                                       "No address for %s, line ignored",
+                                       tokens[0]);
+                               break;
+                       }
+                       
+                       if (!getnetnum(tokens[1], &peeraddr, 1)) {
+                               /* Resolve now, or lose! */
+                               break;
+                       } else {
+                               errflg = 0;
+                               
+                               /* Shouldn't be able to specify multicast */
+                               if (IN_CLASSD(ntohl(peeraddr.sin_addr.s_addr))
+                                   || ISBADADR(&peeraddr)) {
+                                       msyslog(LOG_ERR,
+                                               "attempt to configure invalid address %s",
+                                               ntoa(&peeraddr));
+                                       break;
+                               }
+                       }
+
+                       peerversion = NTP_VERSION;
+                       minpoll = NTP_MINDPOLL;
+                       maxpoll = NTP_MAXDPOLL;
+                       /* peerkey = 0; */
+                       peerflags = 0;
+                       /* ttl = 0; */
+                       for (i = 2; i < ntokens; i++)
+                           switch (matchkey(tokens[i], mod_keywords)) {
+                               case CONF_MOD_VERSION:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "peer/server version requires an argument");
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   peerversion = atoi(tokens[++i]);
+                                   if ((u_char)peerversion > NTP_VERSION
+                                       || (u_char)peerversion < NTP_OLDVERSION) {
+                                           msyslog(LOG_ERR,
+                                                   "inappropriate version number %s, line ignored",
+                                                   tokens[i]);
+                                           errflg = 1;
+                                   }
+                                   break;
+                                       
+                               case CONF_MOD_KEY:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "key: argument required");
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   ++i;
+                                   /* peerkey = (int)atol(tokens[i]); */
+                                   peerflags |= FLAG_AUTHENABLE;
+                                   break;
+
+                               case CONF_MOD_MINPOLL:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "minpoll: argument required");
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   minpoll = atoi(tokens[++i]);
+                                   if (minpoll < NTP_MINPOLL)
+                                       minpoll = NTP_MINPOLL;
+                                   break;
+
+                               case CONF_MOD_MAXPOLL:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "maxpoll: argument required"
+                                                   );
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   maxpoll = atoi(tokens[++i]);
+                                   if (maxpoll > NTP_MAXPOLL)
+                                       maxpoll = NTP_MAXPOLL;
+                                   break;
+
+                               case CONF_MOD_PREFER:
+                                   peerflags |= FLAG_PREFER;
+                                   break;
+
+                               case CONF_MOD_BURST:
+                                   peerflags |= FLAG_BURST;
+                                   break;
+
+                               case CONF_MOD_SKEY:
+                                   peerflags |= FLAG_SKEY | FLAG_AUTHENABLE;
+                                   break;
+
+                               case CONF_MOD_TTL:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "ttl: argument required");
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   ++i;
+                                   /* ttl = atoi(tokens[i]); */
+                                   break;
+
+                               case CONF_MOD_MODE:
+                                   if (i >= ntokens-1) {
+                                           msyslog(LOG_ERR,
+                                                   "mode: argument required");
+                                           errflg = 1;
+                                           break;
+                                   }
+                                   ++i;
+                                   /* ttl = atoi(tokens[i]); */
+                                   break;
+
+                               case CONFIG_UNKNOWN:
+                                   errflg = 1;
+                                   break;
+                           }
+                       if (minpoll > maxpoll) {
+                               msyslog(LOG_ERR, "config error: minpoll > maxpoll");
+                               errflg = 1;
+                       }
+                       if (errflg == 0) {
+                               server = (struct server *)emalloc(sizeof(struct server));
+                               memset((char *)server, 0, sizeof(struct server));
+                               server->srcadr = peeraddr;
+                               server->version = peerversion;
+                               server->dispersion = PEER_MAXDISP;
+                               server->next_server = srvlist;
+                               srvlist = server;
+                               srvcnt++;
+                       }
+                       break;
+                       
+                       case CONFIG_KEYS:
+                       if (ntokens >= 2) {
+                               key_file = (char *) emalloc(strlen(tokens[1]) + 1);
+                               strcpy(key_file, tokens[1]);
+                       }
+                       break;
+               }
+       }
+       (void) fclose(fp);
+
+       /* build final list */
+       sys_numservers = srvcnt;
+       sys_servers = (struct server **) 
+           emalloc(sys_numservers * sizeof(struct server *));
+       for(i=0;i<sys_numservers;i++) {
+               sys_servers[i] = srvlist;
+               srvlist = srvlist->next_server;
+       }
+}
+
+
+
+/*
+ * gettokens - read a line and return tokens
+ */
+static int
+gettokens(
+       FILE *fp,
+       char *line,
+       char **tokenlist,
+       int *ntokens
+       )
+{
+       register char *cp;
+       register int eol;
+       register int ntok;
+       register int quoted = 0;
+
+       /*
+        * Find start of first token
+        */
+       again:
+       while ((cp = fgets(line, MAXLINE, fp)) != NULL) {
+               cp = line;
+               while (ISSPACE(*cp))
+                       cp++;
+               if (!ISEOL(*cp))
+                       break;
+       }
+       if (cp == NULL) {
+               *ntokens = 0;
+               return CONFIG_UNKNOWN;  /* hack.  Is recognized as EOF */
+       }
+
+       /*
+        * Now separate out the tokens
+        */
+       eol = 0;
+       ntok = 0;
+       while (!eol) {
+               tokenlist[ntok++] = cp;
+               while (!ISEOL(*cp) && (!ISSPACE(*cp) || quoted))
+                       quoted ^= (*cp++ == '"');
+
+               if (ISEOL(*cp)) {
+                       *cp = '\0';
+                       eol = 1;
+               } else {                /* must be space */
+                       *cp++ = '\0';
+                       while (ISSPACE(*cp))
+                               cp++;
+                       if (ISEOL(*cp))
+                               eol = 1;
+               }
+               if (ntok == MAXTOKENS)
+                       eol = 1;
+       }
+
+       /*
+        * Return the match
+        */
+       *ntokens = ntok;
+       ntok = matchkey(tokenlist[0], keywords);
+       if (ntok == CONFIG_UNKNOWN)
+               goto again;
+       return ntok;
+}
+
+
+
+/*
+ * matchkey - match a keyword to a list
+ */
+static int
+matchkey(
+       register char *word,
+       register struct keyword *keys
+       )
+{
+       for (;;) {
+               if (keys->keytype == CONFIG_UNKNOWN) {
+                       return CONFIG_UNKNOWN;
+               }
+               if (STRSAME(word, keys->text))
+                       return keys->keytype;
+               keys++;
+       }
+}
+
+
+/*
+ * getnetnum - return a net number (this is crude, but careful)
+ */
+static int
+getnetnum(
+       const char *num,
+       struct sockaddr_in *addr,
+       int complain
+       )
+{
+       register const char *cp;
+       register char *bp;
+       register int i;
+       register int temp;
+       char buf[80];           /* will core dump on really stupid stuff */
+       u_int32 netnum;
+
+       /* XXX ELIMINATE replace with decodenetnum */
+       cp = num;
+       netnum = 0;
+       for (i = 0; i < 4; i++) {
+               bp = buf;
+               while (isdigit((int)*cp))
+                       *bp++ = *cp++;
+               if (bp == buf)
+                       break;
+
+               if (i < 3) {
+                       if (*cp++ != '.')
+                               break;
+               } else if (*cp != '\0')
+                       break;
+
+               *bp = '\0';
+               temp = atoi(buf);
+               if (temp > 255)
+                       break;
+               netnum <<= 8;
+               netnum += temp;
+#ifdef DEBUG
+               if (debug > 3)
+                       printf("getnetnum %s step %d buf %s temp %d netnum %lu\n",
+                          num, i, buf, temp, (u_long)netnum);
+#endif
+       }
+
+       if (i < 4) {
+               if (complain)
+                       msyslog(LOG_ERR,
+                               "getnetnum: \"%s\" invalid host number, line ignored",
+                               num);
+#ifdef DEBUG
+               if (debug > 3)
+                       printf(
+                               "getnetnum: \"%s\" invalid host number, line ignored\n",
+                               num);
+#endif
+               return 0;
+       }
+
+       /*
+        * make up socket address.      Clear it out for neatness.
+        */
+       memset((void *)addr, 0, sizeof(struct sockaddr_in));
+       addr->sin_family = AF_INET;
+       addr->sin_port = htons(NTP_PORT);
+       addr->sin_addr.s_addr = htonl(netnum);
+#ifdef DEBUG
+       if (debug > 1)
+               printf("getnetnum given %s, got %s (%lx)\n",
+                  num, ntoa(addr), (u_long)netnum);
+#endif
+       return 1;
+}
diff --git a/ntpdate/ntptimeset.c b/ntpdate/ntptimeset.c
new file mode 100644 (file)
index 0000000..2485aad
--- /dev/null
@@ -0,0 +1,2164 @@
+/*
+ * ntptimeset - get/set the time via ntp
+ *
+ * GOAL:
+ * The goal of ntptime is to set the current time on system startup
+ * to the best possible time using the network very wisely. It is assumed
+ * that after a resonable time has been sett then ntp daemon will
+ * maintain it.
+ *
+ * PROBLEM DOMAIN:
+ * We have three sets of issues related to acheiving the goal. The first
+ * issue is using the network when normal traffic is happening or when
+ * the entire network world is recovering from a campus wide power failure
+ * and is restarting. The second issue is the class of machine whether it
+ * is a user's office workstation being handled by an uneducated user or
+ * a server computer being handled by a trained operations staff. The third
+ * issue is whether the ratio of people to computers and whether the 
+ * environment is stable and viable or not.
+ *
+ * NETWORK USAGE:
+ * The first issue of using the network wisely is a question of whether
+ * the network load and time server load and state are normal. If things
+ * are normal ntptime can do what ntpdate does of sending out 4 packets
+ * quickly to each server (new transmit done with each ack). However
+ * if network or time load is high then this scheme will simply contribute
+ * to problems. Given we have minimal state, we simply weight lost packets
+ * significantly and make sure we throttle output as much as possible
+ * without performance lost for quick startups.
+ *
+ * TRAINING AND KNOWLEDGE:
+ * The second issue of uneducated user of a office workstation versus a
+ * trained operation staff of a server machine translates into simply an
+ * issue of untrained and trained users.
+ * 
+ * The training issue implies that for the sake of the users involved in the
+ * handling of their office workstation, problems and options should be
+ * communicated simply and effectively and not in terse expert related
+ * descriptions without possible options to be taken. The operator's training
+ * and education enables them to deal with either type of communication and
+ * control.
+ *
+ * AUTOMATION AND MANUAL CONTROL:
+ * The last issue boils down to a design problem. If the design tends to go
+ * into a manual mode when the environment is non-viable then one person
+ * handling many computers all at the same time will be heavily impacted. On
+ * the other hand, if the design tends to be automatic and does not indicate
+ * a way for the user to take over control then the computer will be
+ * unavailable for the user until the proble is resolved by someone else or
+ * the user.
+ *
+ * NOTE: Please do not have this program print out every minute some line,
+ *       of output. If this happens and the environment is in trouble then
+ *       many pages of paper on many different machines will be filled up.
+ *       Save some tress in your lifetime.
+ * 
+ * CONCLUSION:
+ * The behavior of the program derived from these three issues should be
+ * that during normal situations it quickly sets the time and allow the
+ * system to startup.
+ *
+ * However during abnormal conditions as detected by unresponsive servers,
+ * out-of-sync or bad responses and other detections, it should print out
+ * a simple but clear message and continue in a mellow way to get the best
+ * possible time. It may never get the time and if so should also indicate
+ * this.
+ *
+ * Rudy Nedved
+ * 18-May-1993
+ *
+ ****************************************************************
+ *
+ * Much of the above is confusing or no longer relevant.  For example,
+ * it is rare these days for a machine's console to be a printing terminal,
+ * so the comment about saving trees doesn't mean much.  Nonetheless,
+ * the basic principles still stand:
+ *
+ * - Work automatically, without human control or intervention.  To
+ *   this end, we use the same configuration file as ntpd itself, so
+ *   you don't have to specify servers or other information on the
+ *   command line.  We also recognize that sometimes we won't be able
+ *   to contact any servers, and give up in that event instead of
+ *   hanging forever.
+ *
+ * - Behave in a sane way, both internally and externally, even in the
+ *   face of insane conditions.  That means we back off quickly when
+ *   we don't hear a response, to avoid network congestion.  Like
+ *   ntpd, we verify responses from several servers before accepting
+ *   the new time data.
+ *
+ *   However, we don't assume that the local clock is right, or even
+ *   close, because it might not be at boot time, and we want to catch
+ *   and correct that situation.  This behaviour has saved us in several
+ *   instances.  On HP-UX 9.0x, there used to be a bug in adjtimed which
+ *   would cause the time to be set to some wild value, making the machine
+ *   essentially unusable (we use Kerberos authentication pervasively,
+ *   and it requires workstations and servers to have a time within five
+ *   minutes of the Kerberos server).  We also have problems on PC's
+ *   running both Linux and some Microsoft OS -- they tend to disagree
+ *   on what the BIOS clock should say, and who should update it, and
+ *   when.  On those systems, we not only run ntptimeset at boot, we
+ *   also reset the BIOS clock based on the result, so the correct
+ *   time will be retained across reboots.
+ *
+ * For these reasons, and others, we have continued to use this tool
+ * rather than ntpdate.  It is run automatically at boot time on every
+ * workstation and server in our facility.
+ *
+ * In the past, we called this program 'ntptime'.  Unfortunately, the
+ * ntp v4 distribution also includes a program with that name.  In
+ * order to avoid confusion, we have renamed our program 'ntptimeset',
+ * which more accurately describes what it does.
+ *
+ * Jeffrey T. Hutzelman (N3NHS) <jhutz+@cmu.edu>
+ * School of Computer Science - Research Computing Facility
+ * Carnegie Mellon University - Pittsburgh, PA
+ * 16-Aug-1999
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntp_machine.h"
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntp_io.h"
+#include "iosignal.h"
+#include "ntp_unixtime.h"
+#include "ntpdate.h"
+#include "ntp_string.h"
+#include "ntp_syslog.h"
+#include "ntp_select.h"
+#include "ntp_stdlib.h"
+
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+
+#include <stdio.h>
+#include <signal.h>
+#include <ctype.h>
+#ifndef SYS_WINNT
+# ifdef HAVE_SYS_SIGNAL_H
+#  include <sys/signal.h>
+# else
+#  include <signal.h>
+# endif
+# include <sys/ioctl.h>
+#endif /* SYS_WINNT */
+
+#ifdef HAVE_SYS_RESOURCE_H
+# include <sys/resource.h>
+#endif /* HAVE_SYS_RESOURCE_H */
+
+#ifdef SYS_VXWORKS
+# include "ioLib.h"
+# include "sockLib.h"
+# include "timers.h"
+#endif
+
+#include "recvbuff.h"
+
+#ifdef SYS_WINNT
+# define TARGET_RESOLUTION 1  /* Try for 1-millisecond accuracy
+                               on Windows NT timers. */
+#pragma comment(lib, "winmm")
+#endif /* SYS_WINNT */
+
+/*
+ * Scheduling priority we run at
+ */
+#ifndef SYS_VXWORKS
+# define       NTPDATE_PRIO    (-12)
+#else
+# define       NTPDATE_PRIO    (100)
+#endif
+
+#if defined(HAVE_TIMER_SETTIME) || defined (HAVE_TIMER_CREATE)
+/* POSIX TIMERS - vxWorks doesn't have itimer - casey */
+static timer_t ntpdate_timerid;
+#endif
+
+/*
+ * Compatibility stuff for Version 2
+ */
+#define NTP_MAXSKW     0x28f   /* 0.01 sec in fp format */
+#define NTP_MINDIST 0x51f      /* 0.02 sec in fp format */
+#define NTP_INFIN      15      /* max stratum, infinity a la Bellman-Ford */
+#define NTP_MAXWGT     (8*FP_SECOND)   /* maximum select weight 8 seconds */
+#define NTP_MAXLIST 5  /* maximum select list size */
+#define PEER_SHIFT     8       /* 8 suitable for crystal time base */
+
+/*
+ * Debugging flag
+ */
+volatile int debug = 0;
+
+/*
+ * File descriptor masks etc. for call to select
+ */
+int fd;
+fd_set fdmask;
+
+/*
+ * Initializing flag.  All async routines watch this and only do their
+ * thing when it is clear.
+ */
+int initializing = 1;
+
+/*
+ * Alarm flag. Set when an alarm occurs
+ */
+volatile int alarm_flag = 0;
+
+/*
+ * Set the time if valid time determined
+ */
+int set_time = 0;
+
+/*
+ * transmission rate control
+ */
+#define        MINTRANSMITS    (3)     /* minimum total packets per server */
+#define        MAXXMITCOUNT    (2)     /* maximum packets per time interrupt */
+
+/*
+ * time setting constraints
+ */
+#define        DESIREDDISP     (4*FP_SECOND)   /* desired dispersion, (fp 4) */
+int max_period = DEFMAXPERIOD;
+int min_servers = DEFMINSERVERS;
+int min_valid = DEFMINVALID;
+
+/*
+ * counters related to time setting constraints
+ */
+int contacted = 0;             /* # of servers we have sent to */
+int responding = 0;            /* servers responding */
+int validcount = 0;            /* servers with valid time */
+int valid_n_low = 0;           /* valid time servers with low dispersion */
+
+/*
+ * Unpriviledged port flag.
+ */
+int unpriv_port = 0;
+
+/*
+ * Program name.
+ */
+char *progname;
+
+/*
+ * Systemwide parameters and flags
+ */
+struct server **sys_servers;   /* the server list */
+int sys_numservers = 0;        /* number of servers to poll */
+int sys_authenticate = 0;      /* true when authenticating */
+u_int32 sys_authkey = 0;       /* set to authentication key in use */
+u_long sys_authdelay = 0;      /* authentication delay */
+
+/*
+ * The current internal time
+ */
+u_long current_time = 0;
+
+/*
+ * File of encryption keys
+ */
+
+#ifndef KEYFILE
+# ifndef SYS_WINNT
+#define KEYFILE        "/etc/ntp.keys"
+# else
+#define KEYFILE        "%windir%\\ntp.keys"
+# endif /* SYS_WINNT */
+#endif /* KEYFILE */
+
+#ifndef SYS_WINNT
+const char *key_file = KEYFILE;
+#else
+char key_file_storage[MAX_PATH+1], *key_file ;
+#endif  /* SYS_WINNT */
+
+/*
+ * total packet counts
+ */
+u_long total_xmit = 0;
+u_long total_recv = 0;
+
+/*
+ * Miscellaneous flags
+ */
+int verbose = 0;
+#define        HORRIBLEOK      3       /* how many packets to let out */
+int horrible = 0;      /* how many packets we drop for testing */
+int secondhalf = 0;    /* second half of timeout period */
+int printmsg = 0;      /* print time response analysis */
+
+/*
+ * The half time and finish time in internal time
+ */
+u_long half_time = 0;
+u_long finish_time = 0;
+
+
+int    ntptimesetmain  P((int argc, char *argv[]));
+static void    analysis        P((int final));
+static int     have_enough     P((void));
+static void    transmit        P((register struct server *server));
+static void    receive         P((struct recvbuf *rbufp));
+static void    clock_filter P((register struct server *server, s_fp d, l_fp *c));
+static void    clock_count     P((void));
+static struct server *clock_select P((void));
+static void    set_local_clock P((void));
+static struct server *findserver P((struct sockaddr_in *addr));
+static void    timer           P((void));
+#ifndef SYS_WINNT
+static RETSIGTYPE      alarming        P((int sig));
+#endif /* SYS_WINNT */
+static void    init_alarm      P((void));
+static void    init_io         P((void));
+static int     sendpkt         P((struct sockaddr_in *dest, struct pkt *pkt, int len));
+       void    input_handler   P((l_fp *xts));
+static void    printserver     P((register struct server *pp, FILE *fp));
+#if !defined(HAVE_VSPRINTF)
+int    vsprintf        P((char *str, const char *fmt, va_list ap));
+#endif
+
+#ifdef HAVE_SIGNALED_IO
+extern  void    wait_for_signal P((void));
+extern  void    unblock_io_and_alarm P((void));
+extern  void    block_io_and_alarm P((void));
+#endif
+
+
+#ifdef NO_MAIN_ALLOWED
+CALL(ntptimeset,"ntptimeset",ntptimesetmain);
+
+void clear_globals()
+{
+  /*
+   * Debugging flag
+   */
+  debug = 0;
+
+  ntp_optind = 0;
+
+  /*
+   * Initializing flag.  All async routines watch this and only do their
+   * thing when it is clear.
+   */
+  initializing = 1;
+
+  /*
+   * Alarm flag.  Set when an alarm occurs
+   */
+  alarm_flag = 0;
+
+  /*
+   * Unpriviledged port flag.
+   */
+  unpriv_port = 0;
+
+  /*
+   * Systemwide parameters and flags
+   */
+  sys_numservers = 0;    /* number of servers to poll */
+  sys_authenticate = 0;   /* true when authenticating */
+  sys_authkey = 0;        /* set to authentication key in use */
+  sys_authdelay = 0;   /* authentication delay */
+
+  /*
+   * The current internal time
+   */
+  current_time = 0;
+
+  verbose = 0;
+}
+#endif /* NO_MAIN_ALLOWED */
+
+/*
+ * Main program.  Initialize us and loop waiting for I/O and/or
+ * timer expiries.
+ */
+#ifndef NO_MAIN_ALLOWED
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       return ntptimesetmain(argc, argv);
+}
+#endif /* NO_MAIN_ALLOWED */
+          
+
+int
+ntptimesetmain(
+       int argc,
+       char *argv[]
+       )
+{
+       int was_alarmed;
+       int tot_recvbufs;
+       struct recvbuf *rbuf;
+       l_fp tmp;
+       int errflg;
+       int c;
+       extern char *ntp_optarg;
+       extern int ntp_optind;
+       int ltmp;
+       char *cfgpath;
+
+#ifdef SYS_WINNT
+       HANDLE process_handle;
+
+       wVersionRequested = MAKEWORD(1,1);
+       if (WSAStartup(wVersionRequested, &wsaData)) {
+               msyslog(LOG_ERR, "No useable winsock.dll: %m");
+               exit(1);
+       }
+#endif /* SYS_WINNT */
+
+#ifdef NO_MAIN_ALLOWED
+       clear_globals();
+#endif
+
+       errflg = 0;
+       cfgpath = 0;
+       progname = argv[0];
+       syslogit = 0;
+
+       /*
+        * Decode argument list
+        */
+       while ((c = ntp_getopt(argc, argv, "a:c:de:slt:uvHS:V:")) != EOF)
+               switch (c)
+               {
+               case 'a':
+                       c = atoi(ntp_optarg);
+                       sys_authenticate = 1;
+                       sys_authkey = c;
+                       break;
+               case 'c':
+                       cfgpath = ntp_optarg;
+                       break;
+               case 'd':
+                       ++debug;
+                       break;
+               case 'e':
+                       if (!atolfp(ntp_optarg, &tmp)
+                           || tmp.l_ui != 0) {
+                               (void) fprintf(stderr,
+                                   "%s: encryption delay %s is unlikely\n",
+                                   progname, ntp_optarg);
+                               errflg++;
+                       } else {
+                               sys_authdelay = tmp.l_uf;
+                       }
+                       break;
+               case 's':
+                       set_time = 1;
+                       break;
+               case 'l':
+                       syslogit = 1;
+                       break;
+               case 't':
+                       ltmp = atoi(ntp_optarg);
+                       if (ltmp <= 0) {
+                           (void) fprintf(stderr,
+                               "%s: maximum time period (%d) is invalid\n",
+                               progname, ltmp);
+                           errflg++;
+                       }
+                       else
+                           max_period = ltmp;
+                       break;
+               case 'u':
+                       unpriv_port = 1;
+                       break;
+               case 'v':
+                       ++verbose;
+                       break;
+               case 'H':
+                       horrible++;
+                       break;
+               case 'S':
+                       ltmp = atoi(ntp_optarg);
+                       if (ltmp <= 0) {
+                           (void) fprintf(stderr,
+                               "%s: minimum responding (%d) is invalid\n",
+                               progname, ltmp);
+                           errflg++;
+                       }
+                       else
+                           min_servers = ltmp;
+                       break;
+               case 'V':
+                       ltmp = atoi(ntp_optarg);
+                       if (ltmp <= 0) {
+                           (void) fprintf(stderr,
+                               "%s: minimum valid (%d) is invalid\n",
+                               progname, ltmp);
+                           errflg++;
+                       }
+                       else
+                           min_valid = ltmp;
+                       break;
+               case '?':
+                       ++errflg;
+                       break;
+               default:
+                       break;
+               }
+
+       
+       if (errflg || ntp_optind < argc) {
+               fprintf(stderr,"usage: %s [switches...]\n",progname);
+               fprintf(stderr,"  -v       (verbose)\n");
+               fprintf(stderr,"  -c path  (set config file path)\n");
+               fprintf(stderr,"  -a key   (authenticate using key)\n");
+               fprintf(stderr,"  -e delay (authentication delay)\n");
+               fprintf(stderr,"  -S num   (# of servers that must respond)\n");
+               fprintf(stderr,"  -V num   (# of servers that must valid)\n");
+               fprintf(stderr,"  -s       (set the time based if okay)\n");
+               fprintf(stderr,"  -t secs  (time period before ending)\n");
+               fprintf(stderr,"  -l       (use syslog facility)\n");
+               fprintf(stderr,"  -u       (use unprivileged port)\n");
+               fprintf(stderr,"  -H       (drop packets for debugging)\n");
+               fprintf(stderr,"  -d       (debug output)\n");
+               exit(2);
+       }
+
+       /*
+        * Logging.  Open the syslog if we have to
+        */
+       if (syslogit) {
+#if !defined (SYS_WINNT) && !defined (SYS_VXWORKS) && !defined SYS_CYGWIN32
+# ifndef       LOG_DAEMON
+               openlog("ntptimeset", LOG_PID);
+# else
+
+#  ifndef      LOG_NTP
+#      define  LOG_NTP LOG_DAEMON
+#  endif
+               openlog("ntptimeset", LOG_PID | LOG_NDELAY, LOG_NTP);
+               if (debug)
+                       setlogmask(LOG_UPTO(LOG_DEBUG));
+               else
+                       setlogmask(LOG_UPTO(LOG_INFO));
+# endif /* LOG_DAEMON */
+#endif /* SYS_WINNT */
+       }
+
+       if (debug || verbose)
+               msyslog(LOG_INFO, "%s", Version);
+
+       if (horrible)
+               msyslog(LOG_INFO, "Dropping %d out of %d packets",
+                       horrible,horrible+HORRIBLEOK);
+       /*
+        * Add servers we are going to be polling
+        */
+       loadservers(cfgpath);
+
+       if (sys_numservers < min_servers) {
+               msyslog(LOG_ERR, "Found %d servers, require %d servers",
+                       sys_numservers,min_servers);
+               exit(2);
+       }
+
+       /*
+        * determine when we will end at least
+        */
+       finish_time = max_period * TIMER_HZ;
+       half_time = finish_time >> 1;
+
+       /*
+        * Initialize the time of day routines and the I/O subsystem
+        */
+       if (sys_authenticate) {
+               init_auth();
+#ifdef SYS_WINNT
+               if (!key_file) key_file = KEYFILE;
+               if (!ExpandEnvironmentStrings(key_file, key_file_storage, MAX_PATH))
+               {
+                       msyslog(LOG_ERR, "ExpandEnvironmentStrings(%s) failed: %m\n",
+                               key_file);
+               } else {
+                       key_file = key_file_storage;
+               }
+#endif /* SYS_WINNT */
+
+               if (!authreadkeys(key_file)) {
+                       msyslog(LOG_ERR, "no key file, exiting");
+                       exit(1);
+               }
+               if (!authistrusted(sys_authkey)) {
+                       char buf[10];
+
+                       (void) sprintf(buf, "%lu", (unsigned long)sys_authkey);
+                       msyslog(LOG_ERR, "authentication key %s unknown", buf);
+                       exit(1);
+               }
+       }
+       init_io();
+       init_alarm();
+
+       /*
+        * Set the priority.
+        */
+#ifdef SYS_VXWORKS
+       taskPrioritySet( taskIdSelf(), NTPDATE_PRIO);
+#endif
+#if defined(HAVE_ATT_NICE)
+       nice (NTPDATE_PRIO);
+#endif
+#if defined(HAVE_BSD_NICE)
+       (void) setpriority(PRIO_PROCESS, 0, NTPDATE_PRIO);
+#endif
+#ifdef SYS_WINNT
+       process_handle = GetCurrentProcess();
+       if (!SetPriorityClass(process_handle, (DWORD) REALTIME_PRIORITY_CLASS)) {
+               msyslog(LOG_ERR, "SetPriorityClass failed: %m");
+       }
+#endif /* SYS_WINNT */
+
+       initializing = 0;
+
+       /*
+        * Use select() on all on all input fd's for unlimited
+        * time.  select() will terminate on SIGALARM or on the
+        * reception of input.  Using select() means we can't do
+        * robust signal handling and we get a potential race
+        * between checking for alarms and doing the select().
+        * Mostly harmless, I think.
+        * Keep going until we have enough information, or time is up.
+        */
+       /* On VMS, I suspect that select() can't be interrupted
+        * by a "signal" either, so I take the easy way out and
+        * have select() time out after one second.
+        * System clock updates really aren't time-critical,
+        * and - lacking a hardware reference clock - I have
+        * yet to learn about anything else that is.
+        */
+       was_alarmed = 0;
+       while (finish_time > current_time) {
+#if !defined(HAVE_SIGNALED_IO) 
+               fd_set rdfdes;
+               int nfound;
+#elif defined(HAVE_SIGNALED_IO)
+               block_io_and_alarm();
+#endif
+
+               tot_recvbufs = full_recvbuffs();        /* get received buffers */
+               if (printmsg) {
+                       printmsg = 0;
+                       analysis(0);
+               }
+               if (alarm_flag) {               /* alarmed? */
+                       was_alarmed = 1;
+                       alarm_flag = 0;
+               }
+
+               if (!was_alarmed && tot_recvbufs > 0) {
+                       /*
+                        * Nothing to do.  Wait for something.
+                        */
+#ifndef HAVE_SIGNALED_IO
+                       rdfdes = fdmask;
+# if defined(VMS) || defined(SYS_VXWORKS)
+                       /* make select() wake up after one second */
+                       {
+                               struct timeval t1;
+
+                               t1.tv_sec = 1; t1.tv_usec = 0;
+                               nfound = select(fd+1, &rdfdes, (fd_set *)0,
+                                               (fd_set *)0, &t1);
+                       }
+# else
+                       nfound = select(fd+1, &rdfdes, (fd_set *)0,
+                                       (fd_set *)0, (struct timeval *)0);
+# endif /* VMS */
+                       if (nfound > 0) {
+                               l_fp ts;
+                               get_systime(&ts);
+                               (void)input_handler(&ts);
+                       }
+                       else if (nfound == -1 && errno != EINTR)
+                               msyslog(LOG_ERR, "select() error: %m");
+                       else if (debug) {
+# if !defined SYS_VXWORKS && !defined SYS_CYGWIN32 /* to unclutter log */
+                               msyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound);
+# endif
+                       }
+#else /* HAVE_SIGNALED_IO */
+                        
+                       wait_for_signal();
+#endif /* HAVE_SIGNALED_IO */
+                       if (alarm_flag)         /* alarmed? */
+                       {
+                               was_alarmed = 1;
+                               alarm_flag = 0;
+                       }
+                       tot_recvbufs = full_recvbuffs();  /* get received buffers */
+               }
+#ifdef HAVE_SIGNALED_IO
+               unblock_io_and_alarm();
+#endif /* HAVE_SIGNALED_IO */
+
+               /*
+                * Out here, signals are unblocked.  Call timer routine
+                * to process expiry.
+                */
+               if (was_alarmed)
+               {
+                       timer();
+                       was_alarmed = 0;
+               }
+
+               /*
+                * Call the data procedure to handle each received
+                * packet.
+                */
+               rbuf = get_full_recv_buffer();
+               while (rbuf != NULL)
+               {
+                       receive(rbuf);
+                       freerecvbuf(rbuf);
+                       rbuf = get_full_recv_buffer();
+               }
+
+               /*
+                * Do we have enough information to stop now?
+                */
+               if (have_enough())
+                       break;  /* time to end */
+
+               /*
+                * Go around again
+                */
+       }
+
+       /*
+        * adjust the clock and exit accordingly
+        */
+       set_local_clock();
+
+       /*
+        * if we get here then we are in trouble
+        */
+       return(1);
+}
+
+
+/*
+ * analysis - print a message indicating what is happening with time service
+ *           must mimic have_enough() procedure.
+ */
+static void
+analysis(
+       int final
+       )
+{
+       if (contacted < sys_numservers) {
+               printf("%d servers of %d have been probed with %d packets\n",
+                      contacted,sys_numservers,MINTRANSMITS);
+               return;
+       }
+       if (!responding) {
+               printf("No response from any of %d servers, network problem?\n",
+                      sys_numservers);
+               return;
+       }
+       else if (responding < min_servers) {
+               printf("%d servers out of %d responding, need at least %d.\n",
+                      responding, sys_numservers, min_servers);
+               return;
+       }
+       if (!validcount) {
+               printf("%d servers responding but none have valid time\n",
+                      responding);
+               return;
+       }
+       else if (validcount < min_valid) {
+               printf("%d servers responding, %d are valid, need %d valid\n",
+                      responding,validcount,min_valid);
+               return;
+       }
+       if (!final && valid_n_low != validcount) {
+               printf("%d valid servers but only %d have low dispersion\n",
+                      validcount,valid_n_low);
+               return;
+       }
+}
+
+
+/* have_enough - see if we have enough information to terminate probing
+ */
+static int
+have_enough(void)
+{
+       /* have we contacted all servers yet? */
+       if (contacted < sys_numservers)
+               return 0;       /* no...try some more */
+
+       /* have we got at least minimum servers responding? */
+       if (responding < min_servers)
+               return 0;       /* no...try some more */
+
+       /* count the clocks */
+       (void) clock_count();
+
+       /* have we got at least minimum valid clocks? */
+       if (validcount <= 0 || validcount < min_valid)
+               return 0;       /* no...try some more */
+
+       /* do we have all valid servers with low dispersion */
+       if (!secondhalf && valid_n_low != validcount)
+               return 0;
+
+       /* if we get into the secondhalf then we ignore dispersion */
+
+       /* all conditions have been met...end */
+       return 1;
+}
+
+
+/*
+ * transmit - transmit a packet to the given server, or mark it completed.
+ *           This is called by the timeout routine and by the receive
+ *           procedure.
+ */
+static void
+transmit(
+       register struct server *server
+       )
+{
+       struct pkt xpkt;
+       int timeout;
+
+       if (debug > 2)
+               printf("transmit(%s)\n", ntoa(&server->srcadr));
+
+       if ((server->reach & 01) == 0) {
+               l_fp ts;
+               /*
+                * Last message to this server timed out.  Shift
+                * zeros into the filter.
+                */
+               L_CLR(&ts);
+               clock_filter(server, 0, &ts);
+       }
+
+       /*
+        * shift reachable register over
+        */
+       server->reach <<= 1;
+
+       /*
+        * If we're here, send another message to the server.  Fill in
+        * the packet and let 'er rip.
+        */
+       xpkt.li_vn_mode = PKT_LI_VN_MODE(LEAP_NOTINSYNC,
+               server->version, MODE_CLIENT);
+       xpkt.stratum = STRATUM_TO_PKT(STRATUM_UNSPEC);
+       xpkt.ppoll = NTP_MINPOLL;
+       xpkt.precision = NTPDATE_PRECISION;
+       xpkt.rootdelay = htonl(NTPDATE_DISTANCE);
+       xpkt.rootdispersion = htonl(NTPDATE_DISP);
+       xpkt.refid = htonl(NTPDATE_REFID);
+       L_CLR(&xpkt.reftime);
+       L_CLR(&xpkt.org);
+       L_CLR(&xpkt.rec);
+
+       /*
+        * Determine whether to authenticate or not.  If so,
+        * fill in the extended part of the packet and do it.
+        * If not, just timestamp it and send it away.
+        */
+       if (sys_authenticate) {
+               int len;
+
+               xpkt.exten[0] = htonl(sys_authkey);
+               get_systime(&server->xmt);
+               L_ADDUF(&server->xmt, sys_authdelay);
+               HTONL_FP(&server->xmt, &xpkt.xmt);
+               len = authencrypt(sys_authkey, (u_int32 *)&xpkt, LEN_PKT_NOMAC);
+               if (sendpkt(&(server->srcadr), &xpkt, (int)(LEN_PKT_NOMAC + len))) {
+                       if (debug > 1)
+                               printf("failed transmit auth to %s\n",
+                                   ntoa(&(server->srcadr)));
+                       return;
+               }
+
+               if (debug > 1)
+                       printf("transmit auth to %s\n",
+                           ntoa(&(server->srcadr)));
+       } else {
+               get_systime(&(server->xmt));
+               HTONL_FP(&server->xmt, &xpkt.xmt);
+               if (sendpkt(&(server->srcadr), &xpkt, LEN_PKT_NOMAC)) {
+                       if (debug > 1)
+                               printf("failed transmit to %s\n", 
+                                   ntoa(&(server->srcadr)));
+                       return;
+               }
+
+               if (debug > 1)
+                       printf("transmit to %s\n", ntoa(&(server->srcadr)));
+       }
+
+       /*
+        * count transmits, record contacted count and set transmit time
+        */
+       if (++server->xmtcnt == MINTRANSMITS)
+           contacted++;
+       server->last_xmit = current_time;
+
+       /*
+        * determine timeout for this packet. The more packets we send
+        * to the host, the slower we get. If the host indicates that
+        * it is not "sane" then we expect even less.
+        */
+       if (server->xmtcnt < MINTRANSMITS) {
+           /* we have not sent enough */
+           timeout = TIMER_HZ;         /* 1 second probe */
+       }
+       else if (server->rcvcnt <= 0) {
+           /* we have heard nothing */
+           if (secondhalf)
+               timeout = TIMER_HZ<<4;  /* 16 second probe */
+           else
+               timeout = TIMER_HZ<<3;  /* 8 second probe */
+       }
+       else {
+           /* if we have low dispersion then probe infrequently */
+           if (server->dispersion <= DESIREDDISP)
+               timeout = TIMER_HZ<<4;  /* 16 second probe */
+           /* if the server is not in sync then let it alone */
+           else if (server->leap == LEAP_NOTINSYNC)
+               timeout = TIMER_HZ<<4;  /* 16 second probe */
+           /* if the server looks broken ignore it */
+           else if (server->org.l_ui < server->reftime.l_ui)
+               timeout = TIMER_HZ<<5;  /* 32 second probe */
+           else if (secondhalf)
+               timeout = TIMER_HZ<<2;  /* 4 second probe */
+           else
+               timeout = TIMER_HZ<<1;  /* 2 second probe */
+       }
+
+       /*
+        * set next transmit time based on timeout
+        */
+       server->event_time = current_time + timeout;
+}
+
+
+/*
+ * receive - receive and process an incoming frame
+ */
+static void
+receive(
+       struct recvbuf *rbufp
+       )
+{
+       register struct pkt *rpkt;
+       register struct server *server;
+       register s_fp di;
+       l_fp t10, t23;
+       l_fp org;
+       l_fp rec;
+       l_fp ci;
+       int has_mac;
+       int is_authentic;
+
+       if (debug > 2)
+               printf("receive(%s)\n", ntoa(&rbufp->srcadr));
+       /*
+        * Check to see if the packet basically looks like something
+        * intended for us.
+        */
+       if (rbufp->recv_length == LEN_PKT_NOMAC)
+               has_mac = 0;
+       else if (rbufp->recv_length >= LEN_PKT_NOMAC)
+               has_mac = 1;
+       else {
+               if (debug > 2)
+                       printf("receive: packet length %d\n",
+                           rbufp->recv_length);
+               return;         /* funny length packet */
+       }
+
+       rpkt = &(rbufp->recv_pkt);
+       if (PKT_VERSION(rpkt->li_vn_mode) < NTP_OLDVERSION ||
+           PKT_VERSION(rpkt->li_vn_mode) > NTP_VERSION) {
+               if (debug > 1)
+                       printf("receive: bad version %d\n",
+                              PKT_VERSION(rpkt->li_vn_mode));
+               return;
+       }
+
+       if ((PKT_MODE(rpkt->li_vn_mode) != MODE_SERVER
+           && PKT_MODE(rpkt->li_vn_mode) != MODE_PASSIVE)
+           || rpkt->stratum >=STRATUM_UNSPEC) {
+               if (debug > 1)
+                       printf("receive: mode %d stratum %d\n",
+                           PKT_MODE(rpkt->li_vn_mode), rpkt->stratum);
+               return;
+       }
+       
+       /*
+        * So far, so good.  See if this is from a server we know.
+        */
+       server = findserver(&(rbufp->srcadr));
+       if (server == NULL) {
+               if (debug > 1)
+                       printf("receive: server not found\n");
+               return;
+       }
+
+       /*
+        * Decode the org timestamp and make sure we're getting a response
+        * to our last request.
+        */
+       NTOHL_FP(&rpkt->org, &org);
+       if (!L_ISEQU(&org, &server->xmt)) {
+               if (debug > 1)
+                       printf("receive: pkt.org and peer.xmt differ\n");
+               return;
+       }
+       
+       /*
+        * Check out the authenticity if we're doing that.
+        */
+       if (!sys_authenticate)
+               is_authentic = 1;
+       else {
+               is_authentic = 0;
+
+               if (debug > 3)
+                       printf("receive: rpkt keyid=%ld sys_authkey=%ld decrypt=%ld\n",
+                          (long int)ntohl(rpkt->exten[0]), (long int)sys_authkey,
+                          (long int)authdecrypt(sys_authkey, (u_int32 *)rpkt,
+                               LEN_PKT_NOMAC, (int)(rbufp->recv_length - LEN_PKT_NOMAC)));
+
+               if (has_mac && ntohl(rpkt->exten[0]) == sys_authkey &&
+                       authdecrypt(sys_authkey, (u_int32 *)rpkt, LEN_PKT_NOMAC,
+                       (int)(rbufp->recv_length - LEN_PKT_NOMAC)))
+                       is_authentic = 1;
+               if (debug)
+                       printf("receive: authentication %s\n",
+                          is_authentic ? "passed" : "failed");
+       }
+       server->trust <<= 1;
+       if (!is_authentic)
+               server->trust |= 1;
+       
+       /*
+        * Looks good.  Record info from the packet.
+        */
+       server->leap = PKT_LEAP(rpkt->li_vn_mode);
+       server->stratum = PKT_TO_STRATUM(rpkt->stratum);
+       server->precision = rpkt->precision;
+       server->rootdelay = ntohl(rpkt->rootdelay);
+       server->rootdispersion = ntohl(rpkt->rootdispersion);
+       server->refid = rpkt->refid;
+       NTOHL_FP(&rpkt->reftime, &server->reftime);
+       NTOHL_FP(&rpkt->rec, &rec);
+       NTOHL_FP(&rpkt->xmt, &server->org);
+
+       /*
+        * count this guy as responding
+        */
+       server->reach |= 1;
+       if (server->rcvcnt++ == 0)
+               responding++;
+
+       /*
+        * Make sure the server is at least somewhat sane.  If not, ignore
+        * it for later.
+        */
+       if (L_ISZERO(&rec) || !L_ISHIS(&server->org, &rec)) {
+               if (debug > 1)
+                       printf("receive: pkt insane\n");
+               return;
+       }
+
+       /*
+        * Calculate the round trip delay (di) and the clock offset (ci).
+        * We use the equations (reordered from those in the spec):
+        *
+        * d = (t2 - t3) - (t1 - t0)
+        * c = ((t2 - t3) + (t1 - t0)) / 2
+        */
+       t10 = server->org;              /* pkt.xmt == t1 */
+       L_SUB(&t10, &rbufp->recv_time); /* recv_time == t0*/
+
+       t23 = rec;                      /* pkt.rec == t2 */
+       L_SUB(&t23, &org);              /* pkt->org == t3 */
+
+       /* now have (t2 - t3) and (t0 - t1).  Calculate (ci) and (di) */
+       ci = t10;
+       L_ADD(&ci, &t23);
+       L_RSHIFT(&ci);
+
+       /*
+        * Calculate di in t23 in full precision, then truncate
+        * to an s_fp.
+        */
+       L_SUB(&t23, &t10);
+       di = LFPTOFP(&t23);
+
+       if (debug > 3)
+               printf("offset: %s, delay %s\n", lfptoa(&ci, 6), fptoa(di, 5));
+
+       di += (FP_SECOND >> (-(int)NTPDATE_PRECISION))
+           + (FP_SECOND >> (-(int)server->precision)) + NTP_MAXSKW;
+
+       if (di <= 0) {          /* value still too raunchy to use? */
+               L_CLR(&ci);
+               di = 0;
+       } else {
+               di = max(di, NTP_MINDIST);
+       }
+
+
+       /*
+        * This one is valid.  Give it to clock_filter(),
+        */
+       clock_filter(server, di, &ci);
+       if (debug > 1)
+               printf("receive from %s\n", ntoa(&rbufp->srcadr));
+
+       /*
+        * See if we should goes the transmission. If not return now
+        * otherwise have the next event time be shortened
+        */
+       if (server->stratum <= NTP_INFIN)
+           return;     /* server does not have a stratum */
+       if (server->leap == LEAP_NOTINSYNC)
+           return;     /* just booted server or out of sync */
+       if (!L_ISHIS(&server->org, &server->reftime))
+           return;     /* broken host */
+       if (server->trust != 0)
+           return;     /* can not trust it */
+
+       if (server->dispersion < DESIREDDISP)
+           return;     /* we have the desired dispersion */
+
+       server->event_time -= (TIMER_HZ+1);
+}
+
+
+/*
+ * clock_filter - add clock sample, determine a server's delay, dispersion
+ *                and offset
+ */
+static void
+clock_filter(
+       register struct server *server,
+       s_fp di,
+       l_fp *c
+       )
+{
+       register int i, j;
+       int ord[NTP_SHIFT];
+
+       /*
+        * Insert sample and increment nextpt
+        */
+
+       i = server->filter_nextpt;
+       server->filter_delay[i] = di;
+       server->filter_offset[i] = *c;
+       server->filter_soffset[i] = LFPTOFP(c);
+       server->filter_nextpt++;
+       if (server->filter_nextpt >= NTP_SHIFT)
+               server->filter_nextpt = 0;
+
+       /*
+        * Sort indices into increasing delay order
+        */
+       for (i = 0; i < NTP_SHIFT; i++)
+               ord[i] = i;
+       
+       for (i = 0; i < (NTP_SHIFT-1); i++) {
+               for (j = i+1; j < NTP_SHIFT; j++) {
+                       if (server->filter_delay[ord[j]] == 0)
+                               continue;
+                       if (server->filter_delay[ord[i]] == 0
+                           || (server->filter_delay[ord[i]]
+                           > server->filter_delay[ord[j]])) {
+                               register int tmp;
+
+                               tmp = ord[i];
+                               ord[i] = ord[j];
+                               ord[j] = tmp;
+                       }
+               }
+       }
+
+       /*
+        * Now compute the dispersion, and assign values to delay and
+        * offset.  If there are no samples in the register, delay and
+        * offset go to zero and dispersion is set to the maximum.
+        */
+       if (server->filter_delay[ord[0]] == 0) {
+               server->delay = 0;
+               L_CLR(&server->offset);
+               server->soffset = 0;
+               server->dispersion = PEER_MAXDISP;
+       } else {
+               register s_fp d;
+
+               server->delay = server->filter_delay[ord[0]];
+               server->offset = server->filter_offset[ord[0]];
+               server->soffset = LFPTOFP(&server->offset);
+               server->dispersion = 0;
+               for (i = 1; i < NTP_SHIFT; i++) {
+                       if (server->filter_delay[ord[i]] == 0)
+                               d = PEER_MAXDISP;
+                       else {
+                               d = server->filter_soffset[ord[i]]
+                                   - server->filter_soffset[ord[0]];
+                               if (d < 0)
+                                       d = -d;
+                               if (d > PEER_MAXDISP)
+                                       d = PEER_MAXDISP;
+                       }
+                       /*
+                        * XXX This *knows* PEER_FILTER is 1/2
+                        */
+                       server->dispersion += (u_fp)(d) >> i;
+               }
+       }
+       /*
+        * We're done
+        */
+}
+
+
+/* clock_count - count the clock sources we have
+ */
+static void
+clock_count(void)
+{
+       register struct server *server;
+       register int n;
+
+       /* reset counts */
+       validcount = valid_n_low = 0;
+
+       /* go through the list of servers and count the clocks we believe
+        * and that have low dispersion
+        */
+       for (n = 0; n < sys_numservers; n++) {
+               server = sys_servers[n];
+               if (server->delay == 0) {
+                       continue;       /* no data */
+               }
+               if (server->stratum > NTP_INFIN) {
+                       continue;       /* stratum no good */
+               }
+               if (server->delay > NTP_MAXWGT) {
+                       continue;       /* too far away */
+               }
+               if (server->leap == LEAP_NOTINSYNC)
+                       continue;       /* he's in trouble */
+               if (!L_ISHIS(&server->org, &server->reftime)) {
+                       continue;       /* very broken host */
+               }
+               if ((server->org.l_ui - server->reftime.l_ui) >= NTP_MAXAGE) {
+                       continue;       /* too long without sync */
+               }
+               if (server->trust != 0) {
+                       continue;
+               }
+
+               /*
+                * This one is a valid time source..
+                */
+               validcount++;
+
+               /*
+                * See if this one has a okay low dispersion
+                */
+               if (server->dispersion <= DESIREDDISP)
+                   valid_n_low++;
+       }
+
+       if (debug > 1)
+               printf("have %d, valid %d, low %d\n",
+                       responding, validcount, valid_n_low);
+}
+
+
+/*
+ * clock_select - select the pick-of-the-litter clock from the samples
+ *               we've got.
+ */
+static struct server *
+clock_select(void)
+{
+       register struct server *server;
+       register int i;
+       register int nlist;
+       register s_fp d;
+       register int j;
+       register int n;
+       s_fp local_threshold;
+       struct server *server_list[NTP_MAXCLOCK];
+       u_fp server_badness[NTP_MAXCLOCK];
+       struct server *sys_server;
+
+       /*
+        * This first chunk of code is supposed to go through all
+        * servers we know about to find the NTP_MAXLIST servers which
+        * are most likely to succeed.  We run through the list
+        * doing the sanity checks and trying to insert anyone who
+        * looks okay.  We are at all times aware that we should
+        * only keep samples from the top two strata and we only need
+        * NTP_MAXLIST of them.
+        */
+       nlist = 0;      /* none yet */
+       for (n = 0; n < sys_numservers; n++) {
+               server = sys_servers[n];
+               if (server->delay == 0)
+                       continue;       /* no data */
+               if (server->stratum > NTP_INFIN)
+                       continue;       /* stratum no good */
+               if (server->delay > NTP_MAXWGT) {
+                       continue;       /* too far away */
+               }
+               if (server->leap == LEAP_NOTINSYNC)
+                       continue;       /* he's in trouble */
+               if (!L_ISHIS(&server->org, &server->reftime)) {
+                       continue;       /* very broken host */
+               }
+               if ((server->org.l_ui - server->reftime.l_ui)
+                   >= NTP_MAXAGE) {
+                       continue;       /* too long without sync */
+               }
+               if (server->trust != 0) {
+                       continue;
+               }
+
+               /*
+                * This one seems sane.  Find where he belongs
+                * on the list.
+                */
+               d = server->dispersion + server->dispersion;
+               for (i = 0; i < nlist; i++)
+                       if (server->stratum <= server_list[i]->stratum)
+                               break;
+               for ( ; i < nlist; i++) {
+                       if (server->stratum < server_list[i]->stratum)
+                               break;
+                       if (d < (s_fp) server_badness[i])
+                               break;
+               }
+
+               /*
+                * If i points past the end of the list, this
+                * guy is a loser, else stick him in.
+                */
+               if (i >= NTP_MAXLIST)
+                       continue;
+               for (j = nlist; j > i; j--)
+                       if (j < NTP_MAXLIST) {
+                               server_list[j] = server_list[j-1];
+                               server_badness[j]
+                                   = server_badness[j-1];
+                       }
+
+               server_list[i] = server;
+               server_badness[i] = d;
+               if (nlist < NTP_MAXLIST)
+                       nlist++;
+       }
+
+       /*
+        * Got the five-or-less best.  Cut the list where the number of
+        * strata exceeds two.
+        */
+       j = 0;
+       for (i = 1; i < nlist; i++)
+               if (server_list[i]->stratum > server_list[i-1]->stratum)
+                       if (++j == 2) {
+                               nlist = i;
+                               break;
+                       }
+
+       /*
+        * Whew!  What we should have by now is 0 to 5 candidates for
+        * the job of syncing us.  If we have none, we're out of luck.
+        * If we have one, he's a winner.  If we have more, do falseticker
+        * detection.
+        */
+
+       if (nlist == 0)
+               sys_server = 0;
+       else if (nlist == 1) {
+               sys_server = server_list[0];
+       } else {
+               /*
+                * Re-sort by stratum, bdelay estimate quality and
+                * server.delay.
+                */
+               for (i = 0; i < nlist-1; i++)
+                       for (j = i+1; j < nlist; j++) {
+                               if (server_list[i]->stratum
+                                   < server_list[j]->stratum)
+                                       break;  /* already sorted by stratum */
+                               if (server_list[i]->delay
+                                   < server_list[j]->delay)
+                                       continue;
+                               server = server_list[i];
+                               server_list[i] = server_list[j];
+                               server_list[j] = server;
+                       }
+               
+               /*
+                * Calculate the fixed part of the dispersion limit
+                */
+               local_threshold = (FP_SECOND >> (-(int)NTPDATE_PRECISION))
+                   + NTP_MAXSKW;
+
+               /*
+                * Now drop samples until we're down to one.
+                */
+               while (nlist > 1) {
+                       for (n = 0; n < nlist; n++) {
+                               server_badness[n] = 0;
+                               for (j = 0; j < nlist; j++) {
+                                       if (j == n)     /* with self? */
+                                               continue;
+                                       d = server_list[j]->soffset
+                                           - server_list[n]->soffset;
+                                       if (d < 0)      /* absolute value */
+                                               d = -d;
+                                       /*
+                                        * XXX This code *knows* that
+                                        * NTP_SELECT is 3/4
+                                        */
+                                       for (i = 0; i < j; i++)
+                                               d = (d>>1) + (d>>2);
+                                       server_badness[n] += d;
+                               }
+                       }
+
+                       /*
+                        * We now have an array of nlist badness
+                        * coefficients.  Find the badest.  Find
+                        * the minimum precision while we're at
+                        * it.
+                        */
+                       i = 0;
+                       n = server_list[0]->precision;;
+                       for (j = 1; j < nlist; j++) {
+                               if (server_badness[j] >= server_badness[i])
+                                       i = j;
+                               if (n > server_list[j]->precision)
+                                       n = server_list[j]->precision;
+                       }
+                       
+                       /*
+                        * i is the index of the server with the worst
+                        * dispersion.  If his dispersion is less than
+                        * the threshold, stop now, else delete him and
+                        * continue around again.
+                        */
+                       if (server_badness[i] < (local_threshold
+                                                + (FP_SECOND >> (-n))))
+                               break;
+                       for (j = i + 1; j < nlist; j++)
+                               server_list[j-1] = server_list[j];
+                       nlist--;
+               }
+
+               /*
+                * What remains is a list of less than 5 servers.  Take
+                * the best.
+                */
+               sys_server = server_list[0];
+       }
+
+       /*
+        * That's it.  Return our server.
+        */
+       return sys_server;
+}
+
+
+/*
+ * set_local_clock -- handle setting the local clock or displaying info.
+ */
+static void
+set_local_clock(void)
+{
+       register int i;
+       register struct server *server;
+       time_t tmp;
+       double dtemp;
+
+       /*
+        * if setting time then print final analysis
+        */
+       if (set_time)
+           analysis(1);
+
+       /*
+        * pick a clock
+        */
+       server = clock_select();
+
+       /*
+        * do some display of information
+        */
+       if (debug || verbose) {
+               for (i = 0; i < sys_numservers; i++)
+                       printserver(sys_servers[i], stdout);
+               if (debug)
+                       printf("packets sent %ld, received %ld\n",
+                               total_xmit, total_recv);
+       }
+
+       /*
+        * see if we have a server to set the time with
+        */
+       if (server == 0) {
+           if (!set_time || verbose)
+               fprintf(stdout,"No servers available to sync time with\n");
+           exit(1);
+       }
+
+       /*
+        * we have a valid and selected time to use!!!!!
+        */
+
+       /*
+        * if we are not setting the time then display offset and exit
+        */
+       if (!set_time) {
+               fprintf(stdout,
+                       "Your clock is off by %s seconds. (%s) [%ld/%ld]\n",
+                       lfptoa(&server->offset, 7),
+                       ntoa(&server->srcadr),
+                       total_xmit, total_recv);
+               exit(0);
+       }
+
+       /*
+        * set the clock
+        * XXX: Examine the more flexible approach used by ntpdate.
+        * Note that a design consideration here is that we sometimes
+        * _want_ to step the clock by a _huge_ amount in either
+        * direction, because the local clock is completely bogus.
+        * This condition must be recognized and dealt with, so
+        * that we always get a good time when this completes.
+        * -- jhutz+@cmu.edu, 16-Aug-1999
+        */
+       LFPTOD(&server->offset, dtemp);
+       step_systime(dtemp);
+       time(&tmp);
+       fprintf(stdout,"Time set to %.20s [%s %s %ld/%ld]\n",
+               ctime(&tmp)+4,
+               ntoa(&server->srcadr),
+               lfptoa(&server->offset, 7),
+               total_xmit, total_recv);
+       exit(0);
+}
+
+
+/*
+ * findserver - find a server in the list given its address
+ */
+static struct server *
+findserver(
+       struct sockaddr_in *addr
+       )
+{
+       register int i;
+       register u_int32 netnum;
+
+       if (htons(addr->sin_port) != NTP_PORT)
+               return 0;
+       netnum = addr->sin_addr.s_addr;
+
+       for (i = 0; i < sys_numservers; i++) {
+               if (netnum == sys_servers[i]->srcadr.sin_addr.s_addr)
+                       return sys_servers[i];
+       }
+       return 0;
+}
+
+
+/*
+ * timer - process a timer interrupt
+ */
+static void
+timer(void)
+{
+       register int k;
+
+       /*
+        * Bump the current idea of the time
+        */
+       current_time++;
+
+       /*
+        * see if we have reached half time
+        */
+       if (current_time >= half_time && !secondhalf) {
+           secondhalf++;
+           if (debug)
+               printf("\nSecond Half of Timeout!\n");
+           printmsg++;
+       }
+
+       /*
+        * We only want to send a few packets per transmit interrupt
+        * to throttle things
+        */
+       for(k = 0;k < MAXXMITCOUNT;k++) {
+           register int i, oldi;
+           register u_long oldxtime;
+
+           /*
+            * We want to send a packet out for a server that has an
+            * expired event time. However to be mellow about this, we only
+            * use one expired event timer and to avoid starvation we use
+            * the one with the oldest last transmit time.
+            */
+           oldi = -1;
+           oldxtime = 0;
+           for (i = 0; i < sys_numservers; i++) {
+               if (sys_servers[i]->event_time <= current_time) {
+                   if (oldi < 0 || oldxtime > sys_servers[i]->last_xmit) {
+                       oldxtime = sys_servers[i]->last_xmit;
+                       oldi = i;
+                   }
+               }
+           }
+           if (oldi >= 0)
+               transmit(sys_servers[oldi]);
+           else
+               break;  /* no expired event */
+       } /* end of transmit loop */
+}
+
+
+#ifndef SYS_WINNT
+/*
+ * alarming - record the occurance of an alarm interrupt
+ */
+static RETSIGTYPE
+alarming(
+       int sig
+       )
+#else
+void CALLBACK 
+alarming(UINT uTimerID, UINT uMsg, DWORD dwUser, DWORD dw1, DWORD dw2)
+#endif /* SYS_WINNT */
+{
+       alarm_flag++;
+}
+
+
+/*
+ * init_alarm - set up the timer interrupt
+ */
+static void
+init_alarm(void)
+{
+#ifndef SYS_WINNT
+# ifndef HAVE_TIMER_SETTIME
+       struct itimerval itimer;
+# else
+       struct itimerspec ntpdate_itimer;
+# endif
+#else
+       TIMECAPS tc;
+       UINT wTimerRes, wTimerID;
+# endif /* SYS_WINNT */
+#if defined SYS_CYGWIN32 || defined SYS_WINNT
+       HANDLE hToken;
+       TOKEN_PRIVILEGES tkp;
+       DWORD dwUser = 0;
+#endif /* SYS_WINNT */
+
+       alarm_flag = 0;
+
+#ifndef SYS_WINNT
+# if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME)
+       alarm_flag = 0;
+       /* this code was put in as setitimer() is non existant this us the
+        * POSIX "equivalents" setup - casey
+        */
+       /* ntpdate_timerid is global - so we can kill timer later */
+       if (timer_create (CLOCK_REALTIME, NULL, &ntpdate_timerid) ==
+#  ifdef SYS_VXWORKS
+               ERROR
+#  else
+               -1
+#  endif
+               )
+       {
+               fprintf (stderr, "init_alarm(): timer_create (...) FAILED\n");
+               return;
+       }
+
+       /*      TIMER_HZ = (5)
+        * Set up the alarm interrupt.  The first comes 1/(2*TIMER_HZ)
+        * seconds from now and they continue on every 1/TIMER_HZ seconds.
+        */
+       (void) signal_no_reset(SIGALRM, alarming);
+       ntpdate_itimer.it_interval.tv_sec = ntpdate_itimer.it_value.tv_sec = 0;
+       ntpdate_itimer.it_interval.tv_nsec = 1000000000/TIMER_HZ;
+       ntpdate_itimer.it_value.tv_nsec = 1000000000/(TIMER_HZ<<1);
+       timer_settime(ntpdate_timerid, 0 /* !TIMER_ABSTIME */, &ntpdate_itimer, NULL);
+# else
+       /*
+        * Set up the alarm interrupt.  The first comes 1/(2*TIMER_HZ)
+        * seconds from now and they continue on every 1/TIMER_HZ seconds.
+        */
+       (void) signal_no_reset(SIGALRM, alarming);
+       itimer.it_interval.tv_sec = itimer.it_value.tv_sec = 0;
+       itimer.it_interval.tv_usec = 1000000/TIMER_HZ;
+       itimer.it_value.tv_usec = 1000000/(TIMER_HZ<<1);
+       setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
+# endif
+#if defined SYS_CYGWIN32
+       /*
+        * Get previleges needed for fiddling with the clock
+        */
+
+       /* get the current process token handle */
+       if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
+               msyslog(LOG_ERR, "OpenProcessToken failed: %m");
+               exit(1);
+       }
+       /* get the LUID for system-time privilege. */
+       LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkp.Privileges[0].Luid);
+       tkp.PrivilegeCount = 1;  /* one privilege to set */
+       tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+       /* get set-time privilege for this process. */
+       AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES) NULL, 0);
+       /* cannot test return value of AdjustTokenPrivileges. */
+       if (GetLastError() != ERROR_SUCCESS)
+               msyslog(LOG_ERR, "AdjustTokenPrivileges failed: %m");
+#endif
+#else  /* SYS_WINNT */
+       _tzset();
+
+       /*
+        * Get previleges needed for fiddling with the clock
+        */
+
+       /* get the current process token handle */
+       if (!OpenProcessToken(GetCurrentProcess(), TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) {
+               msyslog(LOG_ERR, "OpenProcessToken failed: %m");
+               exit(1);
+       }
+       /* get the LUID for system-time privilege. */
+       LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkp.Privileges[0].Luid);
+       tkp.PrivilegeCount = 1;  /* one privilege to set */
+       tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+       /* get set-time privilege for this process. */
+       AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,(PTOKEN_PRIVILEGES) NULL, 0);
+       /* cannot test return value of AdjustTokenPrivileges. */
+       if (GetLastError() != ERROR_SUCCESS)
+               msyslog(LOG_ERR, "AdjustTokenPrivileges failed: %m");
+
+       /*
+        * Set up timer interrupts for every 2**EVENT_TIMEOUT seconds
+        * Under Win/NT, expiry of timer interval leads to invocation
+        * of a callback function (on a different thread) rather than
+        * generating an alarm signal
+        */
+
+       /* determine max and min resolution supported */
+       if(timeGetDevCaps(&tc, sizeof(TIMECAPS)) != TIMERR_NOERROR) {
+               msyslog(LOG_ERR, "timeGetDevCaps failed: %m");
+               exit(1);
+       }
+       wTimerRes = min(max(tc.wPeriodMin, TARGET_RESOLUTION), tc.wPeriodMax);
+       /* establish the minimum timer resolution that we'll use */
+       timeBeginPeriod(wTimerRes);
+
+       /* start the timer event */
+       wTimerID = timeSetEvent(
+               (UINT) (1000/TIMER_HZ),    /* Delay */
+               wTimerRes,                       /* Resolution */
+               (LPTIMECALLBACK) alarming, /* Callback function */
+               (DWORD) dwUser,          /* User data */
+               TIME_PERIODIC);          /* Event type (periodic) */
+       if (wTimerID == 0) {
+               msyslog(LOG_ERR, "timeSetEvent failed: %m");
+               exit(1);
+       }
+#endif /* SYS_WINNT */
+}
+
+
+/*
+ * init_io - initialize I/O data and open socket
+ */
+static void
+init_io(void)
+{
+#ifdef SYS_WINNT
+       WORD wVersionRequested;
+       WSADATA wsaData;
+       init_transmitbuff();
+#endif /* SYS_WINNT */
+
+       /*
+        * Init buffer free list and stat counters
+        */
+       init_recvbuff(sys_numservers + 2);
+
+#if defined(HAVE_SIGNALED_IO)
+       set_signal();
+#endif
+
+#ifdef SYS_WINNT
+       wVersionRequested = MAKEWORD(1,1);
+       if (WSAStartup(wVersionRequested, &wsaData))
+       {
+               msyslog(LOG_ERR, "No useable winsock.dll: %m");
+               exit(1);
+       }
+#endif /* SYS_WINNT */
+
+       BLOCKIO();
+
+       /* create a datagram (UDP) socket */
+       if ((fd = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+               msyslog(LOG_ERR, "socket() failed: %m");
+               exit(1);
+               /*NOTREACHED*/
+       }
+
+       /*
+        * bind the socket to the NTP port
+        */
+       if (!debug && set_time && !unpriv_port) {
+               struct sockaddr_in addr;
+
+               memset((char *)&addr, 0, sizeof addr);
+               addr.sin_family = AF_INET;
+               addr.sin_port = htons(NTP_PORT);
+               addr.sin_addr.s_addr = htonl(INADDR_ANY);
+               if (bind(fd, (struct sockaddr *)&addr, sizeof(addr)) < 0) {
+#ifndef SYS_WINNT
+                       if (errno == EADDRINUSE)
+#else
+                       if (WSAGetLastError() == WSAEADDRINUSE)
+#endif
+                               msyslog(LOG_ERR,
+                                   "the NTP socket is in use, exiting");
+                       else
+                               msyslog(LOG_ERR, "bind() fails: %m");
+                       exit(1);
+               }
+       }
+
+       FD_ZERO(&fdmask);
+       FD_SET(fd, &fdmask);
+
+       /*
+        * 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: %m");
+               exit(1);
+               /*NOTREACHED*/
+       }
+#elif defined(FNDELAY)
+       if (fcntl(fd, F_SETFL, FNDELAY) < 0)
+       {
+               msyslog(LOG_ERR, "fcntl(FNDELAY) fails: %m");
+               exit(1);
+               /*NOTREACHED*/
+       }
+#elif defined(O_NDELAY) /* generally the same as FNDELAY */
+       if (fcntl(fd, F_SETFL, O_NDELAY) < 0)
+       {
+               msyslog(LOG_ERR, "fcntl(O_NDELAY) fails: %m");
+               exit(1);
+               /*NOTREACHED*/
+       }
+#elif defined(FIONBIO)
+       if (
+# if defined(VMS)
+               (ioctl(fd,FIONBIO,&1) < 0)
+# elif defined(SYS_WINNT)
+               (ioctlsocket(fd,FIONBIO,(u_long *) &on) == SOCKET_ERROR)
+# else
+               (ioctl(fd,FIONBIO,&on) < 0)
+# endif
+          )
+       {
+               msyslog(LOG_ERR, "ioctl(FIONBIO) fails: %m");
+               exit(1);
+               /*NOTREACHED*/
+       }
+#elif defined(FIOSNBIO)
+       if (ioctl(fd,FIOSNBIO,&on) < 0)
+       {
+               msyslog(LOG_ERR, "ioctl(FIOSNBIO) fails: %m");
+               exit(1);
+               /*NOTREACHED*/
+       }
+#else
+# include "Bletch: Need non-blocking I/O!"
+#endif
+
+#ifdef HAVE_SIGNALED_IO
+       init_socket_sig(fd);
+#endif /* not HAVE_SIGNALED_IO */
+
+       UNBLOCKIO();
+}
+
+
+/*
+ * sendpkt - send a packet to the specified destination
+ */
+static int
+sendpkt(
+       struct sockaddr_in *dest,
+       struct pkt *pkt,
+       int len
+       )
+{
+       int cc;
+       static int horriblecnt = 0;
+#ifdef SYS_WINNT
+       DWORD err;
+#endif /* SYS_WINNT */
+
+       total_xmit++;   /* count it */
+
+       if (horrible) {
+           if (++horriblecnt > HORRIBLEOK) {
+               if (debug > 3)
+                       printf("dropping send (%s)\n", ntoa(dest));
+               if (horriblecnt >= HORRIBLEOK+horrible)
+                   horriblecnt = 0;
+               return 0;
+           }
+       }
+
+
+       cc = sendto(fd, (char *)pkt, (size_t)len, 0, (struct sockaddr *)dest,
+           sizeof(struct sockaddr_in));
+#ifndef SYS_WINNT
+       if (cc == -1) {
+               if (errno != EWOULDBLOCK && errno != ENOBUFS)
+#else
+       if (cc == SOCKET_ERROR) {
+               err = WSAGetLastError();
+               if (err != WSAEWOULDBLOCK && err != WSAENOBUFS)
+#endif /* SYS_WINNT */
+                       msyslog(LOG_ERR, "sendto(%s): %m", ntoa(dest));
+               return -1;
+       }
+       return 0;
+}
+
+
+/*
+ * input_handler - receive packets asynchronously
+ */
+void
+input_handler(l_fp *xts)
+{
+       register int n;
+       register struct recvbuf *rb;
+       struct timeval tvzero;
+       int fromlen;
+       fd_set fds;
+       l_fp ts;
+       ts = *xts; /* we ignore xts, but make the compiler happy */
+
+       /*
+        * Do a poll to see if we have data
+        */
+       for (;;) {
+               fds = fdmask;
+               tvzero.tv_sec = tvzero.tv_usec = 0;
+               n = select(fd+1, &fds, (fd_set *)0, (fd_set *)0, &tvzero);
+
+               /*
+                * If nothing to do, just return.  If an error occurred,
+                * complain and return.  If we've got some, freeze a
+                * timestamp.
+                */
+               if (n == 0)
+                       return;
+               else if (n == -1) {
+                       if (errno != EINTR) {
+                               msyslog(LOG_ERR, "select() error: %m");
+                       }
+                       return;
+               }
+               get_systime(&ts);
+
+               /*
+                * Get a buffer and read the frame.  If we
+                * haven't got a buffer, or this is received
+                * on the wild card socket, just dump the packet.
+                */
+               if (initializing || free_recvbuffs == 0) {
+                       char buf[100];
+
+#ifndef SYS_WINNT
+                       (void) read(fd, buf, sizeof buf);
+#else
+                       /* NT's _read does not operate on nonblocking sockets
+                        * either recvfrom or ReadFile() has to be used here.
+                        * ReadFile is used in [ntpd]ntp_intres() and ntpdc,
+                        * just to be different use recvfrom() here
+                        */
+                       recvfrom(fd, buf, sizeof(buf), 0, (struct sockaddr *)0, NULL);
+#endif /* SYS_WINNT */
+                       continue;
+               }
+
+               rb = get_free_recv_buffer();
+
+               fromlen = sizeof(struct sockaddr_in);
+               rb->recv_length = recvfrom(fd, (char *)&rb->recv_pkt,
+                   sizeof(rb->recv_pkt), 0,
+                   (struct sockaddr *)&rb->srcadr, &fromlen);
+               if (rb->recv_length == -1) {
+                       freerecvbuf(rb);
+                       continue;
+               }
+
+               /*
+                * Got one.  Mark how and when it got here,
+                * put it on the full list.
+                */
+               rb->recv_time = ts;
+               add_full_recv_buffer(rb);
+               total_recv++;   /* count it */
+       }
+}
+
+
+/* XXX ELIMINATE printserver similar in ntptrace.c, ntpdate.c */
+/*
+ * printserver - print detail information for a server
+ */
+static void
+printserver(
+       register struct server *pp,
+       FILE *fp
+       )
+{
+       register int i;
+       char junk[5];
+       char *str;
+
+       if (!debug) {
+           (void) fprintf(fp,
+               "%-15s %d/%d %03o v%d s%d offset %9s delay %s disp %s\n",
+               ntoa(&pp->srcadr),
+               pp->xmtcnt,pp->rcvcnt,pp->reach,
+               pp->version,pp->stratum,
+               lfptoa(&pp->offset, 6), ufptoa(pp->delay, 5),
+               ufptoa(pp->dispersion, 4));
+           return;
+       }
+
+       (void) fprintf(fp, "server %s, port %d\n",
+                          ntoa(&pp->srcadr), ntohs(pp->srcadr.sin_port));
+
+       (void) fprintf(fp, "stratum %d, precision %d, leap %c%c, trust %03o\n",
+                          pp->stratum, pp->precision,
+                          pp->leap & 0x2 ? '1' : '0',
+                          pp->leap & 0x1 ? '1' : '0',
+                          pp->trust);
+
+       if (pp->stratum == 1) {
+               junk[4] = 0;
+               memmove(junk, (char *)&pp->refid, 4);
+               str = junk;
+       } else {
+               str = numtoa(pp->refid);
+       }
+       (void) fprintf(fp,
+                          "refid [%s], delay %s, dispersion %s\n",
+                          str, fptoa((s_fp)pp->delay, 5),
+                          ufptoa(pp->dispersion, 5));
+
+       (void) fprintf(fp, "transmitted %d, received %d, reachable %03o\n",
+           pp->xmtcnt, pp->rcvcnt, pp->reach);
+
+       (void) fprintf(fp, "reference time:    %s\n",
+                          prettydate(&pp->reftime));
+       (void) fprintf(fp, "originate timestamp: %s\n",
+                          prettydate(&pp->org));
+       (void) fprintf(fp, "transmit timestamp:  %s\n",
+                          prettydate(&pp->xmt));
+
+       (void) fprintf(fp, "filter delay: ");
+       for (i = 0; i < NTP_SHIFT; i++) {
+               (void) fprintf(fp, " %-8.8s", fptoa(pp->filter_delay[i], 5));
+               if (i == (NTP_SHIFT>>1)-1)
+                       (void) fprintf(fp, "\n        ");
+       }
+       (void) fprintf(fp, "\n");
+
+       (void) fprintf(fp, "filter offset:");
+       for (i = 0; i < PEER_SHIFT; i++) {
+               (void) fprintf(fp, " %-8.8s", lfptoa(&pp->filter_offset[i], 6));
+               if (i == (PEER_SHIFT>>1)-1)
+                       (void) fprintf(fp, "\n        ");
+       }
+       (void) fprintf(fp, "\n");
+
+       (void) fprintf(fp, "delay %s, dispersion %s\n",
+                          fptoa((s_fp)pp->delay, 5), ufptoa(pp->dispersion, 5));
+
+       (void) fprintf(fp, "offset %s\n\n",
+                          lfptoa(&pp->offset, 6));
+}
+
+#if !defined(HAVE_VSPRINTF)
+int
+vsprintf(
+       char *str,
+       const char *fmt,
+       va_list ap
+       )
+{
+       FILE f;
+       int len;
+
+       f._flag = _IOWRT+_IOSTRG;
+       f._ptr = str;
+       f._cnt = 32767;
+       len = _doprnt(fmt, ap, &f);
+       *f._ptr = 0;
+       return (len);
+}
+#endif
diff --git a/ntpdc/Makefile.am b/ntpdc/Makefile.am
new file mode 100644 (file)
index 0000000..858c523
--- /dev/null
@@ -0,0 +1,66 @@
+AUTOMAKE_OPTIONS=      ../util/ansi2knr
+
+bindir=                ${exec_prefix}/${BINSUBDIR}
+bin_PROGRAMS=  ntpdc
+EXTRA_PROGRAMS=        ntpdc-layout
+EXTRA_DATA=    check-layout
+BUILT_SOURCES= @MAKE_CHECK_LAYOUT@
+AM_CPPFLAGS=   -I$(top_srcdir)/include $(LIBOPTS_CFLAGS)
+# LDADD might need RESLIB and ADJLIB
+ntpdc_LDADD=   version.o @READLINE_LIBS@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+# ntpdc-layout doesn't need any additional libraries at all
+ntpdc_layout_LDADD=
+DISTCLEANFILES=        .version version.c
+CLEANFILES=    check-layout layout.here nl.c ntpdc-layout
+noinst_HEADERS=        ntpdc.h
+ETAGS_ARGS=    Makefile.am
+EXTRA_DIST=    nl_in.c nl.pl layout.std        \
+               ntpdc-opts.def ntpdc.1 ntpdc-opts.texi ntpdc-opts.menu
+BUILT_SOURCES+=        ntpdc-opts.c ntpdc-opts.h ntpdc.1 ntpdc-opts.texi       \
+               ntpdc-opts.menu
+man_MANS=      ntpdc.1
+run_ag=         cd $(srcdir) && autogen -L ../include --writable
+std_def_list=  $(top_srcdir)/include/debug-opt.def             \
+               $(top_srcdir)/include/autogen-version.def       \
+               $(top_srcdir)/include/copyright.def             \
+               $(top_srcdir)/include/homerc.def                \
+               $(top_srcdir)/include/version.def
+
+$(srcdir)/ntpdc-opts.h: $(srcdir)/ntpdc-opts.c
+$(srcdir)/ntpdc-opts.c: $(srcdir)/ntpdc-opts.def $(std_def_list)
+       $(run_ag) ntpdc-opts.def
+
+$(srcdir)/ntpdc.1: $(srcdir)/ntpdc-opts.def $(std_def_list)
+       $(run_ag) -Tagman1.tpl -bntpdc ntpdc-opts.def
+
+$(srcdir)/ntpdc-opts.texi $(srcdir)/ntpdc-opts.menu: $(srcdir)/ntpdc-opts.def $(std_def_list)
+       $(run_ag) -Taginfo.tpl -DLEVEL=section ntpdc-opts.def
+
+ntpdc_SOURCES = ntpdc.c ntpdc_ops.c ntpdc-opts.c ntpdc-opts.h
+
+ntpdc-layout.o: nl.c
+
+layout.here: ntpdc-layout
+       ./ntpdc-layout > $@
+
+check-layout: ntpdc-layout layout.std layout.here
+       cmp $(srcdir)/layout.std layout.here && echo stamp > $@
+
+$(PROGRAMS): $(LDADD)
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE)
+
+$(top_srcdir)/version :
+       cd $(top_srcdir) && $(MAKE) version
+
+version.o: $(ntpdc_OBJECTS) ../libntp/libntp.a Makefile $(top_srcdir)/version
+       env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpdc
+       $(COMPILE) -c version.c
+
+# I ran nl_in.c (attached, to be installed into ntpdc) through
+# $(CC) -E nl_in.c | nl.pl > nl.c
+nl.c: nl_in.c nl.pl Makefile.am
+       $(CC) -E $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(srcdir)/nl_in.c | ./nl.pl > nl.c
+
+include ../bincheck.mf
diff --git a/ntpdc/Makefile.in b/ntpdc/Makefile.in
new file mode 100644 (file)
index 0000000..0e4ce77
--- /dev/null
@@ -0,0 +1,725 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# we traditionally installed software in bindir, while it should have gone
+# in sbindir.  Now that we offer a choice, look in the "other" installation
+# subdir to warn folks if there is another version there.
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+ANSI2KNR = ../util/ansi2knr
+bin_PROGRAMS = ntpdc$(EXEEXT)
+EXTRA_PROGRAMS = ntpdc-layout$(EXEEXT)
+DIST_COMMON = README $(noinst_HEADERS) $(srcdir)/../bincheck.mf \
+       $(srcdir)/Makefile.am $(srcdir)/Makefile.in $(srcdir)/nl.pl.in
+subdir = ntpdc
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES = nl.pl
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
+PROGRAMS = $(bin_PROGRAMS)
+am_ntpdc_OBJECTS = ntpdc$U.$(OBJEXT) ntpdc_ops$U.$(OBJEXT) \
+       ntpdc-opts$U.$(OBJEXT)
+ntpdc_OBJECTS = $(am_ntpdc_OBJECTS)
+am__DEPENDENCIES_1 =
+ntpdc_DEPENDENCIES = version.o $(am__DEPENDENCIES_1) \
+       ../libntp/libntp.a
+ntpdc_layout_SOURCES = ntpdc-layout.c
+ntpdc_layout_OBJECTS = ntpdc-layout$U.$(OBJEXT)
+ntpdc_layout_DEPENDENCIES =
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(ntpdc_SOURCES) ntpdc-layout.c
+DIST_SOURCES = $(ntpdc_SOURCES) ntpdc-layout.c
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+man1dir = $(mandir)/man1
+NROFF = nroff
+MANS = $(man_MANS)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = ${exec_prefix}/${BINSUBDIR}
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+EXTRA_DATA = check-layout
+BUILT_SOURCES = @MAKE_CHECK_LAYOUT@ ntpdc-opts.c ntpdc-opts.h ntpdc.1 \
+       ntpdc-opts.texi ntpdc-opts.menu
+AM_CPPFLAGS = -I$(top_srcdir)/include $(LIBOPTS_CFLAGS)
+# LDADD might need RESLIB and ADJLIB
+ntpdc_LDADD = version.o @READLINE_LIBS@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+# ntpdc-layout doesn't need any additional libraries at all
+ntpdc_layout_LDADD = 
+DISTCLEANFILES = .version version.c
+CLEANFILES = check-layout layout.here nl.c ntpdc-layout
+noinst_HEADERS = ntpdc.h
+ETAGS_ARGS = Makefile.am
+EXTRA_DIST = nl_in.c nl.pl layout.std  \
+               ntpdc-opts.def ntpdc.1 ntpdc-opts.texi ntpdc-opts.menu
+
+man_MANS = ntpdc.1
+run_ag = cd $(srcdir) && autogen -L ../include --writable
+std_def_list = $(top_srcdir)/include/debug-opt.def             \
+               $(top_srcdir)/include/autogen-version.def       \
+               $(top_srcdir)/include/copyright.def             \
+               $(top_srcdir)/include/homerc.def                \
+               $(top_srcdir)/include/version.def
+
+ntpdc_SOURCES = ntpdc.c ntpdc_ops.c ntpdc-opts.c ntpdc-opts.h
+all: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/../bincheck.mf $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ntpdc/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign ntpdc/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+nl.pl: $(top_builddir)/config.status $(srcdir)/nl.pl.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p || test -f $$p1; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+           echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+           $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+       @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+ntpdc$(EXEEXT): $(ntpdc_OBJECTS) $(ntpdc_DEPENDENCIES) 
+       @rm -f ntpdc$(EXEEXT)
+       $(LINK) $(ntpdc_OBJECTS) $(ntpdc_LDADD) $(LIBS)
+ntpdc-layout$(EXEEXT): $(ntpdc_layout_OBJECTS) $(ntpdc_layout_DEPENDENCIES) 
+       @rm -f ntpdc-layout$(EXEEXT)
+       $(LINK) $(ntpdc_layout_OBJECTS) $(ntpdc_layout_LDADD) $(LIBS)
+
+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)/ntpdc$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdc-layout$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdc-opts$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpdc_ops$U.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+ntpdc_.c: ntpdc.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpdc.c; then echo $(srcdir)/ntpdc.c; else echo ntpdc.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpdc-layout_.c: ntpdc-layout.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpdc-layout.c; then echo $(srcdir)/ntpdc-layout.c; else echo ntpdc-layout.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpdc-opts_.c: ntpdc-opts.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpdc-opts.c; then echo $(srcdir)/ntpdc-opts.c; else echo ntpdc-opts.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpdc_ops_.c: ntpdc_ops.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpdc_ops.c; then echo $(srcdir)/ntpdc_ops.c; else echo ntpdc_ops.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpdc_.$(OBJEXT) ntpdc_.lo ntpdc-layout_.$(OBJEXT) ntpdc-layout_.lo \
+ntpdc-opts_.$(OBJEXT) ntpdc-opts_.lo ntpdc_ops_.$(OBJEXT) \
+ntpdc_ops_.lo : $(ANSI2KNR)
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-man1: $(man_MANS)
+       @$(NORMAL_INSTALL)
+       test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+       @list=''; test -n "$(man1dir)" || exit 0; \
+       { for i in $$list; do echo "$$i"; done; \
+       l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.1[a-z]*$$/p'; \
+       } | while read p; do \
+         if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; echo "$$p"; \
+       done | \
+       sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+       sed 'N;N;s,\n, ,g' | { \
+       list=; while read file base inst; do \
+         if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+         fi; \
+       done; \
+       for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+       while read files; do \
+         test -z "$$files" || { \
+           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+           $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+       done; }
+
+uninstall-man1:
+       @$(NORMAL_UNINSTALL)
+       @list=''; test -n "$(man1dir)" || exit 0; \
+       files=`{ for i in $$list; do echo "$$i"; done; \
+       l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.1[a-z]*$$/p'; \
+       } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @list='$(MANS)'; if test -n "$$list"; then \
+         list=`for p in $$list; do \
+           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+           if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+         if test -n "$$list" && \
+           grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+           echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+           grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/         /' >&2; \
+           echo "       to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+           echo "       typically \`make maintainer-clean' will remove them" >&2; \
+           exit 1; \
+         else :; fi; \
+       else :; fi
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(PROGRAMS) $(MANS) $(HEADERS)
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+       -test -z "$(CLEANFILES)" || rm -f $(CLEANFILES)
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+       -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+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-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+       @$(NORMAL_INSTALL)
+       $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man1
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-man
+
+uninstall-man: uninstall-man1
+
+.MAKE: ../util/ansi2knr all check install install-am install-exec-am \
+       install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+       clean-generic clean-libtool ctags distclean distclean-compile \
+       distclean-generic distclean-libtool distclean-tags distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-binPROGRAMS install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-exec-hook \
+       install-html install-html-am install-info install-info-am \
+       install-man install-man1 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 uninstall-binPROGRAMS uninstall-man \
+       uninstall-man1
+
+
+$(srcdir)/ntpdc-opts.h: $(srcdir)/ntpdc-opts.c
+$(srcdir)/ntpdc-opts.c: $(srcdir)/ntpdc-opts.def $(std_def_list)
+       $(run_ag) ntpdc-opts.def
+
+$(srcdir)/ntpdc.1: $(srcdir)/ntpdc-opts.def $(std_def_list)
+       $(run_ag) -Tagman1.tpl -bntpdc ntpdc-opts.def
+
+$(srcdir)/ntpdc-opts.texi $(srcdir)/ntpdc-opts.menu: $(srcdir)/ntpdc-opts.def $(std_def_list)
+       $(run_ag) -Taginfo.tpl -DLEVEL=section ntpdc-opts.def
+
+ntpdc-layout.o: nl.c
+
+layout.here: ntpdc-layout
+       ./ntpdc-layout > $@
+
+check-layout: ntpdc-layout layout.std layout.here
+       cmp $(srcdir)/layout.std layout.here && echo stamp > $@
+
+$(PROGRAMS): $(LDADD)
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE)
+
+$(top_srcdir)/version :
+       cd $(top_srcdir) && $(MAKE) version
+
+version.o: $(ntpdc_OBJECTS) ../libntp/libntp.a Makefile $(top_srcdir)/version
+       env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpdc
+       $(COMPILE) -c version.c
+
+# I ran nl_in.c (attached, to be installed into ntpdc) through
+# $(CC) -E nl_in.c | nl.pl > nl.c
+nl.c: nl_in.c nl.pl Makefile.am
+       $(CC) -E $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(srcdir)/nl_in.c | ./nl.pl > nl.c
+
+install-exec-hook:
+       @case ${BINSUBDIR} in                                   \
+        bin) ODIR=${exec_prefix}/sbin ;;                       \
+        sbin) ODIR=${exec_prefix}/bin ;;                       \
+       esac;                                                   \
+       test -z "${bin_PROGRAMS}${bin_SCRIPTS}"                 \
+       || for i in ${bin_PROGRAMS} ${bin_SCRIPTS} " "; do              \
+          test ! -f $$ODIR/$$i || echo "*** $$i is also in $$ODIR!";   \
+       done
+
+#
+
+# 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.
+.NOEXPORT:
diff --git a/ntpdc/README b/ntpdc/README
new file mode 100644 (file)
index 0000000..618e846
--- /dev/null
@@ -0,0 +1,6 @@
+README file for directory ./xntpdc of the NTP Version 4 distribution
+
+This directory contains the sources for the xntpdc utility program. See
+the README and RELNOTES files in the parent directory for directions on
+how to make and install this program. The current version number of this
+program is in the version.c file.
diff --git a/ntpdc/layout.std b/ntpdc/layout.std
new file mode 100644 (file)
index 0000000..daff636
--- /dev/null
@@ -0,0 +1,439 @@
+sizeof(struct req_pkt) = 212
+offsetof(rm_vn_mode) = 0
+offsetof(auth_seq) = 1
+offsetof(implementation) = 2
+offsetof(request) = 3
+offsetof(err_nitems) = 4
+offsetof(mbz_itemsize) = 6
+offsetof(data) = 8
+offsetof(tstamp) = 184
+offsetof(keyid) = 192
+offsetof(mac) = 196
+
+sizeof(struct req_pkt_tail) = 28
+offsetof(tstamp) = 0
+offsetof(keyid) = 8
+offsetof(mac) = 12
+
+sizeof(struct resp_pkt) = 508
+offsetof(rm_vn_mode) = 0
+offsetof(auth_seq) = 1
+offsetof(implementation) = 2
+offsetof(request) = 3
+offsetof(err_nitems) = 4
+offsetof(mbz_itemsize) = 6
+offsetof(data) = 8
+
+sizeof(struct info_peer_list) = 32
+offsetof(addr) = 0
+offsetof(port) = 4
+offsetof(hmode) = 6
+offsetof(flags) = 7
+offsetof(v6_flag) = 8
+offsetof(unused1) = 12
+offsetof(addr6) = 16
+
+sizeof(struct info_peer_summary) = 72
+offsetof(dstadr) = 0
+offsetof(srcadr) = 4
+offsetof(srcport) = 8
+offsetof(stratum) = 10
+offsetof(hpoll) = 11
+offsetof(ppoll) = 12
+offsetof(reach) = 13
+offsetof(flags) = 14
+offsetof(hmode) = 15
+offsetof(delay) = 16
+offsetof(offset) = 20
+offsetof(dispersion) = 28
+offsetof(v6_flag) = 32
+offsetof(unused1) = 36
+offsetof(dstadr6) = 40
+offsetof(srcadr6) = 56
+
+sizeof(struct info_peer) = 280
+offsetof(dstadr) = 0
+offsetof(srcadr) = 4
+offsetof(srcport) = 8
+offsetof(flags) = 10
+offsetof(leap) = 11
+offsetof(hmode) = 12
+offsetof(pmode) = 13
+offsetof(stratum) = 14
+offsetof(ppoll) = 15
+offsetof(hpoll) = 16
+offsetof(precision) = 17
+offsetof(version) = 18
+offsetof(unused8) = 19
+offsetof(reach) = 20
+offsetof(unreach) = 21
+offsetof(flash) = 22
+offsetof(ttl) = 23
+offsetof(flash2) = 24
+offsetof(associd) = 26
+offsetof(keyid) = 28
+offsetof(pkeyid) = 32
+offsetof(refid) = 36
+offsetof(timer) = 40
+offsetof(rootdelay) = 44
+offsetof(rootdispersion) = 48
+offsetof(reftime) = 52
+offsetof(org) = 60
+offsetof(rec) = 68
+offsetof(xmt) = 76
+offsetof(filtdelay) = 84
+offsetof(filtoffset) = 116
+offsetof(order) = 180
+offsetof(delay) = 188
+offsetof(dispersion) = 192
+offsetof(offset) = 196
+offsetof(selectdisp) = 204
+offsetof(unused1) = 208
+offsetof(unused2) = 212
+offsetof(unused3) = 216
+offsetof(unused4) = 220
+offsetof(unused5) = 224
+offsetof(unused6) = 228
+offsetof(unused7) = 232
+offsetof(estbdelay) = 236
+offsetof(v6_flag) = 240
+offsetof(unused9) = 244
+offsetof(dstadr6) = 248
+offsetof(srcadr6) = 264
+
+sizeof(struct info_peer_stats) = 120
+offsetof(dstadr) = 0
+offsetof(srcadr) = 4
+offsetof(srcport) = 8
+offsetof(flags) = 10
+offsetof(timereset) = 12
+offsetof(timereceived) = 16
+offsetof(timetosend) = 20
+offsetof(timereachable) = 24
+offsetof(sent) = 28
+offsetof(unused1) = 32
+offsetof(processed) = 36
+offsetof(unused2) = 40
+offsetof(badauth) = 44
+offsetof(bogusorg) = 48
+offsetof(oldpkt) = 52
+offsetof(unused3) = 56
+offsetof(unused4) = 60
+offsetof(seldisp) = 64
+offsetof(selbroken) = 68
+offsetof(unused5) = 72
+offsetof(candidate) = 76
+offsetof(unused6) = 77
+offsetof(unused7) = 78
+offsetof(unused8) = 79
+offsetof(v6_flag) = 80
+offsetof(unused9) = 84
+offsetof(dstadr6) = 88
+offsetof(srcadr6) = 104
+
+sizeof(struct info_loop) = 24
+offsetof(last_offset) = 0
+offsetof(drift_comp) = 8
+offsetof(compliance) = 16
+offsetof(watchdog_timer) = 20
+
+sizeof(struct info_sys) = 80
+offsetof(peer) = 0
+offsetof(peer_mode) = 4
+offsetof(leap) = 5
+offsetof(stratum) = 6
+offsetof(precision) = 7
+offsetof(rootdelay) = 8
+offsetof(rootdispersion) = 12
+offsetof(refid) = 16
+offsetof(reftime) = 20
+offsetof(poll) = 28
+offsetof(flags) = 32
+offsetof(unused1) = 33
+offsetof(unused2) = 34
+offsetof(unused3) = 35
+offsetof(bdelay) = 36
+offsetof(frequency) = 40
+offsetof(authdelay) = 44
+offsetof(stability) = 52
+offsetof(v6_flag) = 56
+offsetof(unused4) = 60
+offsetof(peer6) = 64
+
+sizeof(struct info_sys_stats) = 44
+offsetof(timeup) = 0
+offsetof(timereset) = 4
+offsetof(denied) = 8
+offsetof(oldversionpkt) = 12
+offsetof(newversionpkt) = 16
+offsetof(unknownversion) = 20
+offsetof(badlength) = 24
+offsetof(processed) = 28
+offsetof(badauth) = 32
+offsetof(received) = 36
+offsetof(limitrejected) = 40
+
+sizeof(struct old_info_sys_stats) = 40
+offsetof(timeup) = 0
+offsetof(timereset) = 4
+offsetof(denied) = 8
+offsetof(oldversionpkt) = 12
+offsetof(newversionpkt) = 16
+offsetof(unknownversion) = 20
+offsetof(badlength) = 24
+offsetof(processed) = 28
+offsetof(badauth) = 32
+offsetof(wanderhold) = 36
+
+sizeof(struct info_mem_stats) = 148
+offsetof(timereset) = 0
+offsetof(totalpeermem) = 4
+offsetof(freepeermem) = 6
+offsetof(findpeer_calls) = 8
+offsetof(allocations) = 12
+offsetof(demobilizations) = 16
+offsetof(hashcount) = 20
+
+sizeof(struct info_io_stats) = 40
+offsetof(timereset) = 0
+offsetof(totalrecvbufs) = 4
+offsetof(freerecvbufs) = 6
+offsetof(fullrecvbufs) = 8
+offsetof(lowwater) = 10
+offsetof(dropped) = 12
+offsetof(ignored) = 16
+offsetof(received) = 20
+offsetof(sent) = 24
+offsetof(notsent) = 28
+offsetof(interrupts) = 32
+offsetof(int_received) = 36
+
+sizeof(struct info_timer_stats) = 16
+offsetof(timereset) = 0
+offsetof(alarms) = 4
+offsetof(overflows) = 8
+offsetof(xmtcalls) = 12
+
+sizeof(struct old_conf_peer) = 16
+offsetof(peeraddr) = 0
+offsetof(hmode) = 4
+offsetof(version) = 5
+offsetof(minpoll) = 6
+offsetof(maxpoll) = 7
+offsetof(flags) = 8
+offsetof(ttl) = 9
+offsetof(unused) = 10
+offsetof(keyid) = 12
+
+sizeof(struct conf_peer) = 168
+offsetof(peeraddr) = 0
+offsetof(hmode) = 4
+offsetof(version) = 5
+offsetof(minpoll) = 6
+offsetof(maxpoll) = 7
+offsetof(flags) = 8
+offsetof(ttl) = 9
+offsetof(unused1) = 10
+offsetof(keyid) = 12
+offsetof(keystr) = 16
+offsetof(v6_flag) = 144
+offsetof(unused2) = 148
+offsetof(peeraddr6) = 152
+
+sizeof(struct conf_unpeer) = 24
+offsetof(peeraddr) = 0
+offsetof(v6_flag) = 4
+offsetof(peeraddr6) = 8
+
+sizeof(struct conf_sys_flags) = 4
+offsetof(flags) = 0
+
+sizeof(struct info_restrict) = 56
+offsetof(addr) = 0
+offsetof(mask) = 4
+offsetof(count) = 8
+offsetof(flags) = 12
+offsetof(mflags) = 14
+offsetof(v6_flag) = 16
+offsetof(unused1) = 20
+offsetof(addr6) = 24
+offsetof(mask6) = 40
+
+sizeof(struct conf_restrict) = 48
+offsetof(addr) = 0
+offsetof(mask) = 4
+offsetof(flags) = 8
+offsetof(mflags) = 10
+offsetof(v6_flag) = 12
+offsetof(addr6) = 16
+offsetof(mask6) = 32
+
+sizeof(struct info_monitor_1) = 72
+offsetof(lasttime) = 0
+offsetof(firsttime) = 4
+offsetof(lastdrop) = 8
+offsetof(count) = 12
+offsetof(addr) = 16
+offsetof(daddr) = 20
+offsetof(flags) = 24
+offsetof(port) = 28
+offsetof(mode) = 30
+offsetof(version) = 31
+offsetof(v6_flag) = 32
+offsetof(unused1) = 36
+offsetof(addr6) = 40
+offsetof(daddr6) = 56
+
+sizeof(struct info_monitor) = 48
+offsetof(lasttime) = 0
+offsetof(firsttime) = 4
+offsetof(lastdrop) = 8
+offsetof(count) = 12
+offsetof(addr) = 16
+offsetof(port) = 20
+offsetof(mode) = 22
+offsetof(version) = 23
+offsetof(v6_flag) = 24
+offsetof(unused1) = 28
+offsetof(addr6) = 32
+
+sizeof(struct old_info_monitor) = 40
+offsetof(lasttime) = 0
+offsetof(firsttime) = 4
+offsetof(count) = 8
+offsetof(addr) = 12
+offsetof(port) = 16
+offsetof(mode) = 18
+offsetof(version) = 19
+offsetof(v6_flag) = 20
+offsetof(addr6) = 24
+
+sizeof(struct reset_flags) = 4
+offsetof(flags) = 0
+
+sizeof(struct info_auth) = 36
+offsetof(timereset) = 0
+offsetof(numkeys) = 4
+offsetof(numfreekeys) = 8
+offsetof(keylookups) = 12
+offsetof(keynotfound) = 16
+offsetof(encryptions) = 20
+offsetof(decryptions) = 24
+offsetof(expired) = 28
+offsetof(keyuncached) = 32
+
+sizeof(struct info_trap) = 64
+offsetof(local_address) = 0
+offsetof(trap_address) = 4
+offsetof(trap_port) = 8
+offsetof(sequence) = 10
+offsetof(settime) = 12
+offsetof(origtime) = 16
+offsetof(resets) = 20
+offsetof(flags) = 24
+offsetof(v6_flag) = 28
+offsetof(local_address6) = 32
+offsetof(trap_address6) = 48
+
+sizeof(struct conf_trap) = 48
+offsetof(local_address) = 0
+offsetof(trap_address) = 4
+offsetof(trap_port) = 8
+offsetof(unused) = 10
+offsetof(v6_flag) = 12
+offsetof(local_address6) = 16
+offsetof(trap_address6) = 32
+
+sizeof(struct info_control) = 60
+offsetof(ctltimereset) = 0
+offsetof(numctlreq) = 4
+offsetof(numctlbadpkts) = 8
+offsetof(numctlresponses) = 12
+offsetof(numctlfrags) = 16
+offsetof(numctlerrors) = 20
+offsetof(numctltooshort) = 24
+offsetof(numctlinputresp) = 28
+offsetof(numctlinputfrag) = 32
+offsetof(numctlinputerr) = 36
+offsetof(numctlbadoffset) = 40
+offsetof(numctlbadversion) = 44
+offsetof(numctldatatooshort) = 48
+offsetof(numctlbadop) = 52
+offsetof(numasyncmsgs) = 56
+
+sizeof(struct info_clock) = 52
+offsetof(clockadr) = 0
+offsetof(type) = 4
+offsetof(flags) = 5
+offsetof(lastevent) = 6
+offsetof(currentstatus) = 7
+offsetof(polls) = 8
+offsetof(noresponse) = 12
+offsetof(badformat) = 16
+offsetof(baddata) = 20
+offsetof(timestarted) = 24
+offsetof(fudgetime1) = 28
+offsetof(fudgetime2) = 36
+offsetof(fudgeval1) = 44
+offsetof(fudgeval2) = 48
+
+sizeof(struct conf_fudge) = 20
+offsetof(clockadr) = 0
+offsetof(which) = 4
+offsetof(fudgetime) = 8
+offsetof(fudgeval_flags) = 16
+
+sizeof(struct info_clkbug) = 332
+offsetof(clockadr) = 0
+offsetof(nvalues) = 4
+offsetof(ntimes) = 5
+offsetof(svalues) = 6
+offsetof(stimes) = 8
+offsetof(values) = 12
+offsetof(times) = 76
+
+sizeof(struct info_kernel) = 60
+offsetof(offset) = 0
+offsetof(freq) = 4
+offsetof(maxerror) = 8
+offsetof(esterror) = 12
+offsetof(status) = 16
+offsetof(shift) = 18
+offsetof(constant) = 20
+offsetof(precision) = 24
+offsetof(tolerance) = 28
+offsetof(ppsfreq) = 32
+offsetof(jitter) = 36
+offsetof(stabil) = 40
+offsetof(jitcnt) = 44
+offsetof(calcnt) = 48
+offsetof(errcnt) = 52
+offsetof(stbcnt) = 56
+
+sizeof(struct info_if_stats) = 136
+offsetof(unaddr) = 0
+offsetof(unbcast) = 16
+offsetof(unmask) = 32
+offsetof(v6_flag) = 48
+offsetof(name) = 52
+offsetof(flags) = 84
+offsetof(last_ttl) = 88
+offsetof(num_mcast) = 92
+offsetof(received) = 96
+offsetof(sent) = 100
+offsetof(notsent) = 104
+offsetof(uptime) = 108
+offsetof(scopeid) = 112
+offsetof(ifindex) = 116
+offsetof(ifnum) = 120
+offsetof(peercnt) = 124
+offsetof(family) = 128
+offsetof(ignore_packets) = 130
+offsetof(action) = 131
+offsetof(_filler0) = 132
+
+sizeof(struct info_dns_assoc) = 32
+offsetof(peeraddr) = 0
+offsetof(associd) = 4
+offsetof(hostname) = 6
+
diff --git a/ntpdc/nl.pl b/ntpdc/nl.pl
new file mode 100755 (executable)
index 0000000..afea8b7
--- /dev/null
@@ -0,0 +1,37 @@
+#! /usr/local/bin/perl -w
+
+$found = 0;
+$last = 0;
+$debug = 0;
+
+while (<>) {
+    next if /^#/;
+    next if /^\s*$/;
+    if (/^struct req_pkt/) {
+       $found = 1;
+    }
+    if (/^struct info_dns_assoc/) {
+       $last = 1;
+    }
+    if ($found) {
+       if (/^(struct\s*\w*)\s*{\s*$/) {
+           $type = $1;
+           print STDERR "type = '$type'\n" if $debug;
+           printf "  printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n";
+           next;
+       }
+       if (/\s*\w+\s+(\w*)\s*(\[.*\])?\s*;\s*$/) {
+           $field = $1;
+           print STDERR "\tfield = '$field'\n" if $debug;
+           printf "  printf(\"offsetof($field) = %%d\\n\", \n\t (int) offsetof($type, $field));\n";
+           next;
+       }
+       if (/^}\s*;\s*$/) {
+           printf "  printf(\"\\n\");\n\n";
+           $found = 0 if $last;
+           next;
+       }
+       print STDERR "Unmatched line: $_";
+       exit 1;
+    }
+}
diff --git a/ntpdc/nl.pl.in b/ntpdc/nl.pl.in
new file mode 100644 (file)
index 0000000..813dc1f
--- /dev/null
@@ -0,0 +1,37 @@
+#! @PATH_PERL@ -w
+
+$found = 0;
+$last = 0;
+$debug = 0;
+
+while (<>) {
+    next if /^#/;
+    next if /^\s*$/;
+    if (/^struct req_pkt/) {
+       $found = 1;
+    }
+    if (/^struct info_dns_assoc/) {
+       $last = 1;
+    }
+    if ($found) {
+       if (/^(struct\s*\w*)\s*{\s*$/) {
+           $type = $1;
+           print STDERR "type = '$type'\n" if $debug;
+           printf "  printf(\"sizeof($type) = %%d\\n\", \n\t (int) sizeof($type));\n";
+           next;
+       }
+       if (/\s*\w+\s+(\w*)\s*(\[.*\])?\s*;\s*$/) {
+           $field = $1;
+           print STDERR "\tfield = '$field'\n" if $debug;
+           printf "  printf(\"offsetof($field) = %%d\\n\", \n\t (int) offsetof($type, $field));\n";
+           next;
+       }
+       if (/^}\s*;\s*$/) {
+           printf "  printf(\"\\n\");\n\n";
+           $found = 0 if $last;
+           next;
+       }
+       print STDERR "Unmatched line: $_";
+       exit 1;
+    }
+}
diff --git a/ntpdc/nl_in.c b/ntpdc/nl_in.c
new file mode 100644 (file)
index 0000000..3df8c78
--- /dev/null
@@ -0,0 +1,3 @@
+#include <config.h>
+#include "ntpdc.h"
+#include "ntp_request.h"
diff --git a/ntpdc/ntpdc-layout.c b/ntpdc/ntpdc-layout.c
new file mode 100644 (file)
index 0000000..b05fbf3
--- /dev/null
@@ -0,0 +1,21 @@
+/*
+ * ntpdc-layout - print layout of NTP mode 7 request/response packets
+ */
+
+#include <stdio.h>
+#include <stddef.h>
+
+#include "ntpdc.h"
+#include "ntp_stdlib.h"
+
+#if defined(IMPL_XNTPD_OLD) && IMPL_XNTPD != 3
+#error Unexpected IMPL_XNTPD
+#endif
+
+int
+main(void)
+{
+#include "nl.c"
+
+  return (EXIT_SUCCESS);
+}
diff --git a/ntpdc/ntpdc-opts.c b/ntpdc/ntpdc-opts.c
new file mode 100644 (file)
index 0000000..41be37e
--- /dev/null
@@ -0,0 +1,667 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.c)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:00 AM EST
+ *  From the definitions    ntpdc-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This source file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  ntpdc author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * ntpdc copyright 1970-2009 David L. Mills and/or others - all rights reserved
+ *
+ * see html/copyright.html
+ */
+
+
+#include <limits.h>
+
+#define OPTION_CODE_COMPILE 1
+#include "ntpdc-opts.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+tSCC zCopyright[] =
+       "ntpdc copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved";
+tSCC zCopyrightNotice[] =
+       
+/* extracted from ../include/copyright.def near line 8 */
+"see html/copyright.html";
+extern tUsageProc optionUsage;
+
+/*
+ *  global included definitions
+ */
+#ifdef __windows
+  extern int atoi(const char*);
+#else
+# include <stdlib.h>
+#endif
+
+#ifndef NULL
+#  define NULL 0
+#endif
+#ifndef EXIT_SUCCESS
+#  define  EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#  define  EXIT_FAILURE 1
+#endif
+/*
+ *  Ipv4 option description:
+ */
+tSCC    zIpv4Text[] =
+        "Force IPv4 DNS name resolution";
+tSCC    zIpv4_NAME[]               = "IPV4";
+tSCC    zIpv4_Name[]               = "ipv4";
+#define IPV4_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Ipv6 option description:
+ */
+tSCC    zIpv6Text[] =
+        "Force IPv6 DNS name resolution";
+tSCC    zIpv6_NAME[]               = "IPV6";
+tSCC    zIpv6_Name[]               = "ipv6";
+#define IPV6_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Command option description:
+ */
+tSCC    zCommandText[] =
+        "run a command and exit";
+tSCC    zCommand_NAME[]            = "COMMAND";
+tSCC    zCommand_Name[]            = "command";
+#define COMMAND_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Listpeers option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zListpeersText[] =
+        "Print a list of the peers";
+tSCC    zListpeers_NAME[]          = "LISTPEERS";
+tSCC    zListpeers_Name[]          = "listpeers";
+static const int
+    aListpeersCantList[] = {
+    INDEX_OPT_COMMAND, NO_EQUIVALENT };
+#define LISTPEERS_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Peers option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zPeersText[] =
+        "Print a list of the peers";
+tSCC    zPeers_NAME[]              = "PEERS";
+tSCC    zPeers_Name[]              = "peers";
+static const int
+    aPeersCantList[] = {
+    INDEX_OPT_COMMAND, NO_EQUIVALENT };
+#define PEERS_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Showpeers option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zShowpeersText[] =
+        "Show a list of the peers";
+tSCC    zShowpeers_NAME[]          = "SHOWPEERS";
+tSCC    zShowpeers_Name[]          = "showpeers";
+static const int
+    aShowpeersCantList[] = {
+    INDEX_OPT_COMMAND, NO_EQUIVALENT };
+#define SHOWPEERS_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Interactive option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zInteractiveText[] =
+        "Force ntpq to operate in interactive mode";
+tSCC    zInteractive_NAME[]        = "INTERACTIVE";
+tSCC    zInteractive_Name[]        = "interactive";
+static const int
+    aInteractiveCantList[] = {
+    INDEX_OPT_COMMAND,
+    INDEX_OPT_LISTPEERS,
+    INDEX_OPT_PEERS,
+    INDEX_OPT_SHOWPEERS, NO_EQUIVALENT };
+#define INTERACTIVE_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Debug_Level option description:
+ */
+#ifdef DEBUG
+tSCC    zDebug_LevelText[] =
+        "Increase output debug message level";
+tSCC    zDebug_Level_NAME[]        = "DEBUG_LEVEL";
+tSCC    zDebug_Level_Name[]        = "debug-level";
+#define DEBUG_LEVEL_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Debug_Level */
+#define VALUE_OPT_DEBUG_LEVEL NO_EQUIVALENT
+#define DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zDebug_LevelText       NULL
+#define zDebug_Level_NAME      NULL
+#define zDebug_Level_Name      NULL
+#endif  /* DEBUG */
+
+/*
+ *  Set_Debug_Level option description:
+ */
+#ifdef DEBUG
+tSCC    zSet_Debug_LevelText[] =
+        "Set the output debug message level";
+tSCC    zSet_Debug_Level_NAME[]    = "SET_DEBUG_LEVEL";
+tSCC    zSet_Debug_Level_Name[]    = "set-debug-level";
+#define SET_DEBUG_LEVEL_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+#else   /* disable Set_Debug_Level */
+#define VALUE_OPT_SET_DEBUG_LEVEL NO_EQUIVALENT
+#define SET_DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zSet_Debug_LevelText       NULL
+#define zSet_Debug_Level_NAME      NULL
+#define zSet_Debug_Level_Name      NULL
+#endif  /* DEBUG */
+
+/*
+ *  Numeric option description:
+ */
+tSCC    zNumericText[] =
+        "numeric host addresses";
+tSCC    zNumeric_NAME[]            = "NUMERIC";
+tSCC    zNumeric_Name[]            = "numeric";
+#define NUMERIC_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Help/More_Help/Version option descriptions:
+ */
+tSCC zHelpText[]       = "Display usage information and exit";
+tSCC zHelp_Name[]      = "help";
+
+tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
+tSCC zMore_Help_Name[] = "more-help";
+
+tSCC zVersionText[]    = "Output version information and exit";
+tSCC zVersion_Name[]   = "version";
+
+/*
+ *  Save/Load_Opts option description:
+ */
+tSCC zSave_OptsText[]     = "Save the option state to a config file";
+tSCC zSave_Opts_Name[]    = "save-opts";
+
+tSCC zLoad_OptsText[]     = "Load options from a config file";
+tSCC zLoad_Opts_NAME[]    = "LOAD_OPTS";
+
+tSCC zNotLoad_Opts_Name[] = "no-load-opts";
+tSCC zNotLoad_Opts_Pfx[]  = "no";
+#define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
+/*
+ *  Declare option callback procedures
+ */
+#ifdef DEBUG
+  static tOptProc doOptSet_Debug_Level;
+#else /* not DEBUG */
+# define doOptSet_Debug_Level NULL
+#endif /* def/not DEBUG */
+#if defined(TEST_NTPDC_OPTS)
+/*
+ *  Under test, omit argument processing, or call optionStackArg,
+ *  if multiple copies are allowed.
+ */
+extern tOptProc
+    optionPagedUsage, optionStackArg, optionVersionStderr;
+static tOptProc
+    doUsageOpt;
+
+/*
+ *  #define map the "normal" callout procs to the test ones...
+ */
+#define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
+
+
+#else /* NOT defined TEST_NTPDC_OPTS */
+/*
+ *  When not under test, there are different procs to use
+ */
+extern tOptProc
+    optionPagedUsage, optionPrintVersion, optionStackArg;
+static tOptProc
+    doUsageOpt;
+
+/*
+ *  #define map the "normal" callout procs
+ */
+#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
+
+#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
+#endif /* defined(TEST_NTPDC_OPTS) */
+#ifdef TEST_NTPDC_OPTS
+# define DOVERPROC optionVersionStderr
+#else
+# define DOVERPROC optionPrintVersion
+#endif /* TEST_NTPDC_OPTS */
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Ntpdc Option Descriptions.
+ */
+static tOptDesc optDesc[ OPTION_CT ] = {
+  {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
+     /* equiv idx, value */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IPV4_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
+     /* equiv idx, value */ NOLIMIT, NOLIMIT,
+     /* equivalenced to  */ INDEX_OPT_IPV4,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IPV6_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 2, VALUE_OPT_COMMAND,
+     /* equiv idx, value */ 2, VALUE_OPT_COMMAND,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ COMMAND_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zCommandText, zCommand_NAME, zCommand_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 3, VALUE_OPT_LISTPEERS,
+     /* equiv idx, value */ 3, VALUE_OPT_LISTPEERS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ LISTPEERS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aListpeersCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zListpeersText, zListpeers_NAME, zListpeers_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 4, VALUE_OPT_PEERS,
+     /* equiv idx, value */ 4, VALUE_OPT_PEERS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PEERS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aPeersCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPeersText, zPeers_NAME, zPeers_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 5, VALUE_OPT_SHOWPEERS,
+     /* equiv idx, value */ 5, VALUE_OPT_SHOWPEERS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SHOWPEERS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aShowpeersCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zShowpeersText, zShowpeers_NAME, zShowpeers_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 6, VALUE_OPT_INTERACTIVE,
+     /* equiv idx, value */ 6, VALUE_OPT_INTERACTIVE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ INTERACTIVE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aInteractiveCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zInteractiveText, zInteractive_NAME, zInteractive_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 7, VALUE_OPT_DEBUG_LEVEL,
+     /* equiv idx, value */ 7, VALUE_OPT_DEBUG_LEVEL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ DEBUG_LEVEL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 8, VALUE_OPT_SET_DEBUG_LEVEL,
+     /* equiv idx, value */ 8, VALUE_OPT_SET_DEBUG_LEVEL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ SET_DEBUG_LEVEL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ SET_DEBUG_LEVEL_OPT_PROC,
+     /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 9, VALUE_OPT_NUMERIC,
+     /* equiv idx, value */ 9, VALUE_OPT_NUMERIC,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ NUMERIC_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zNumericText, zNumeric_NAME, zNumeric_Name,
+     /* disablement strs */ NULL, NULL },
+
+#ifdef NO_OPTIONAL_OPT_ARGS
+#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
+#else
+#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
+                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
+#endif
+
+  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ DOVERPROC,
+     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
+     /* disablement strs */ NULL, NULL },
+
+#undef VERSION_OPT_FLAGS
+
+
+  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doUsageOpt,
+     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ optionPagedUsage,
+     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
+                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
+                         | OPTST_DISABLE_IMM, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionLoadOpt,
+     /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
+     /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
+};
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Ntpdc Option Environment
+ */
+tSCC   zPROGNAME[]   = "NTPDC";
+tSCC   zUsageTitle[] =
+"ntpdc - vendor-specific NTP query program - Ver. 4.2.4p8\n\
+USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n";
+tSCC   zRcName[]     = ".ntprc";
+tSCC*  apzHomeList[] = {
+       "$HOME",
+       ".",
+       NULL };
+
+tSCC   zBugsAddr[]    = "http://bugs.ntp.org, bugs@ntp.org";
+#define zExplain NULL
+tSCC    zDetail[]     = "\n\
+The\n\
+[= prog-name =]\n\
+utility program is used to query an NTP daemon about its\n\
+current state and to request changes in that state.\n\
+It uses NTP mode 7 control message formats described in the source code.\n\
+The program may\n\
+be run either in interactive mode or controlled using command line\n\
+arguments.\n\
+Extensive state and statistics information is available\n\
+through the\n\
+[= prog-name =]\n\
+interface.\n\
+In addition, nearly all the\n\
+configuration options which can be specified at startup using\n\
+ntpd's configuration file may also be specified at run time using\n\
+[= prog-name =] .\n";
+tSCC    zFullVersion[] = NTPDC_FULL_VERSION;
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
+
+#if defined(ENABLE_NLS)
+# define OPTPROC_BASE OPTPROC_TRANSLATE
+  static tOptionXlateProc translate_option_strings;
+#else
+# define OPTPROC_BASE OPTPROC_NONE
+# define translate_option_strings NULL
+#endif /* ENABLE_NLS */
+
+tOptions ntpdcOptions = {
+    OPTIONS_STRUCT_VERSION,
+    0, NULL,                    /* original argc + argv    */
+    ( OPTPROC_BASE
+    + OPTPROC_ERRSTOP
+    + OPTPROC_SHORTOPT
+    + OPTPROC_LONGOPT
+    + OPTPROC_NO_REQ_OPT
+    + OPTPROC_ENVIRON
+    + OPTPROC_HAS_IMMED ),
+    0, NULL,                    /* current option index, current option */
+    NULL,         NULL,         zPROGNAME,
+    zRcName,      zCopyright,   zCopyrightNotice,
+    zFullVersion, apzHomeList,  zUsageTitle,
+    zExplain,     zDetail,      optDesc,
+    zBugsAddr,                  /* address to send bugs to */
+    NULL, NULL,                 /* extensions/saved state  */
+    optionUsage,       /* usage procedure */
+    translate_option_strings,   /* translation procedure */
+    /*
+     *  Indexes to special options
+     */
+    { INDEX_OPT_MORE_HELP,
+      INDEX_OPT_SAVE_OPTS,
+      NO_EQUIVALENT /* index of '-#' option */,
+      NO_EQUIVALENT /* index of default opt */
+    },
+    15 /* full option count */, 10 /* user option count */
+};
+
+/*
+ *  Create the static procedure(s) declared above.
+ */
+static void
+doUsageOpt(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    USAGE( EXIT_SUCCESS );
+}
+
+#if ! defined(TEST_NTPDC_OPTS)
+
+/* * * * * * *
+ *
+ *   For the set-debug-level option, when DEBUG is #define-d.
+ */
+#ifdef DEBUG
+static void
+doOptSet_Debug_Level(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    /* extracted from ../include/debug-opt.def, line 29 */
+DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
+}
+#endif /* defined DEBUG */
+
+#endif /* defined(TEST_NTPDC_OPTS) */
+
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
+
+#if defined(TEST_NTPDC_OPTS) /* TEST MAIN PROCEDURE: */
+
+int
+main( int argc, char** argv )
+{
+    int res = EXIT_SUCCESS;
+    (void)optionProcess( &ntpdcOptions, argc, argv );
+    {
+        void optionPutShell( tOptions* );
+        optionPutShell( &ntpdcOptions );
+    }
+    return res;
+}
+#endif  /* defined TEST_NTPDC_OPTS */
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
+
+#if ENABLE_NLS
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <autoopts/usage-txt.h>
+
+static char* AO_gettext( char const* pz );
+static void  coerce_it(void** s);
+
+static char*
+AO_gettext( char const* pz )
+{
+    char* pzRes;
+    if (pz == NULL)
+        return NULL;
+    pzRes = _(pz);
+    if (pzRes == pz)
+        return pzRes;
+    pzRes = strdup( pzRes );
+    if (pzRes == NULL) {
+        fputs( _("No memory for duping translated strings\n"), stderr );
+        exit( EXIT_FAILURE );
+    }
+    return pzRes;
+}
+
+static void coerce_it(void** s) { *s = AO_gettext(*s); }
+#define COERSION(_f) \
+  coerce_it((void*)&(ntpdcOptions._f))
+
+/*
+ *  This invokes the translation code (e.g. gettext(3)).
+ */
+static void
+translate_option_strings( void )
+{
+    /*
+     *  Guard against re-translation.  It won't work.  The strings will have
+     *  been changed by the first pass through this code.  One shot only.
+     */
+    if (option_usage_text.field_ct == 0)
+        return;
+    /*
+     *  Do the translations.  The first pointer follows the field count field.
+     *  The field count field is the size of a pointer.
+     */
+    {
+        char** ppz = (char**)(void*)&(option_usage_text);
+        int    ix  = option_usage_text.field_ct;
+
+        do {
+            ppz++;
+            *ppz = AO_gettext(*ppz);
+        } while (--ix > 0);
+    }
+    option_usage_text.field_ct = 0;
+
+    {
+        tOptDesc* pOD = ntpdcOptions.pOptDesc;
+        int       ix  = ntpdcOptions.optCt;
+
+        for (;;) {
+            pOD->pzText           = AO_gettext(pOD->pzText);
+            pOD->pz_NAME          = AO_gettext(pOD->pz_NAME);
+            pOD->pz_Name          = AO_gettext(pOD->pz_Name);
+            pOD->pz_DisableName   = AO_gettext(pOD->pz_DisableName);
+            pOD->pz_DisablePfx    = AO_gettext(pOD->pz_DisablePfx);
+            if (--ix <= 0)
+                break;
+            pOD++;
+        }
+    }
+    COERSION(pzCopyright);
+    COERSION(pzCopyNotice);
+    COERSION(pzFullVersion);
+    COERSION(pzUsageTitle);
+    COERSION(pzExplain);
+    COERSION(pzDetail);
+}
+
+#endif /* ENABLE_NLS */
+
+#ifdef  __cplusplus
+}
+#endif
+/* ntpdc-opts.c ends here */
diff --git a/ntpdc/ntpdc-opts.def b/ntpdc/ntpdc-opts.def
new file mode 100644 (file)
index 0000000..0b5aefe
--- /dev/null
@@ -0,0 +1,127 @@
+/* -*- Mode: Text -*- */
+
+autogen definitions options;
+
+prog-name      = "ntpdc";
+prog-title     = "vendor-specific NTP query program";
+argument       = '[ host ...]';
+
+#include copyright.def
+#include homerc.def
+#include autogen-version.def
+
+test-main;
+
+flag = {
+    name      = ipv4;
+    value     = 4;
+    equivalence = ipv4;
+    descrip   = "Force IPv4 DNS name resolution";
+    doc = <<-  _EndOfDoc_
+       Force DNS resolution of following host names on the command line
+       to the IPv4 namespace.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = ipv6;
+    value     = 6;
+    equivalence = ipv4;
+    descrip   = "Force IPv6 DNS name resolution";
+    doc = <<-  _EndOfDoc_
+       Force DNS resolution of following host names on the command line
+       to the IPv6 namespace.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = command;
+    value     = c;
+    arg-type  = string;
+    descrip   = "run a command and exit";
+    max       = NOLIMIT;
+    arg-name  = cmd;
+    stack-arg;
+    doc = <<-  _EndOfDoc_
+       The following argument is interpreted as an interactive format command
+       and is added to the list of commands to be executed on the specified
+       host(s).
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = listpeers;
+    value     = l;
+    descrip   = "Print a list of the peers";
+    flags-cant = command;
+    doc = <<-  _EndOfDoc_
+       Print a list of the peers known to the server as well as a summary of
+       their state. This is equivalent to the 'listpeers' interactive command.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = peers;
+    value     = p;
+    descrip   = "Print a list of the peers";
+    flags-cant = command;
+    doc = <<-  _EndOfDoc_
+       Print a list of the peers known to the server as well as a summary
+       of their state. This is equivalent to the 'peers' interactive command.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = showpeers;
+    value     = s;
+    descrip   = "Show a list of the peers";
+    flags-cant = command;
+    doc = <<-  _EndOfDoc_
+       Print a list of the peers known to the server as well as a summary
+       of their state. This is equivalent to the 'dmpeers' interactive command.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = interactive;
+    value     = i;
+    flags-cant = command, listpeers, peers, showpeers;
+    descrip   = "Force ntpq to operate in interactive mode";
+    doc = <<-  _EndOfDoc_
+       Force ntpq to operate in interactive mode.  Prompts will be written
+       to the standard output and commands read from the standard input.
+       _EndOfDoc_;
+};
+
+#include debug-opt.def
+
+flag = {
+    name      = numeric;
+    value     = n;
+    descrip   = "numeric host addresses";
+    doc = <<-  _EndOfDoc_
+       Output all host addresses in dotted-quad numeric format rather than
+       converting to the canonical host names. 
+       _EndOfDoc_;
+};
+
+detail = <<-  _END_DETAIL
+       The
+       [= prog-name =]
+       utility program is used to query an NTP daemon about its
+       current state and to request changes in that state.
+       It uses NTP mode 7 control message formats described in the source code.
+       The program may
+       be run either in interactive mode or controlled using command line
+       arguments.
+       Extensive state and statistics information is available
+       through the
+       [= prog-name =]
+       interface.
+       In addition, nearly all the
+       configuration options which can be specified at startup using
+       ntpd's configuration file may also be specified at run time using
+       [= prog-name =] .
+
+
+       _END_DETAIL;
diff --git a/ntpdc/ntpdc-opts.h b/ntpdc/ntpdc-opts.h
new file mode 100644 (file)
index 0000000..f6eef65
--- /dev/null
@@ -0,0 +1,222 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (ntpdc-opts.h)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:00 AM EST
+ *  From the definitions    ntpdc-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This header file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  ntpdc author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * ntpdc copyright 1970-2009 David L. Mills and/or others - all rights reserved
+ *
+ * see html/copyright.html
+ */
+/*
+ *  This file contains the programmatic interface to the Automated
+ *  Options generated for the ntpdc program.
+ *  These macros are documented in the AutoGen info file in the
+ *  "AutoOpts" chapter.  Please refer to that doc for usage help.
+ */
+#ifndef AUTOOPTS_NTPDC_OPTS_H_GUARD
+#define AUTOOPTS_NTPDC_OPTS_H_GUARD
+#include "config.h"
+#include <autoopts/options.h>
+
+/*
+ *  Ensure that the library used for compiling this generated header is at
+ *  least as new as the version current when the header template was released
+ *  (not counting patch version increments).  Also ensure that the oldest
+ *  tolerable version is at least as old as what was current when the header
+ *  template was released.
+ */
+#define AO_TEMPLATE_VERSION 118784
+#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
+ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
+# error option template version mismatches autoopts/options.h header
+  Choke Me.
+#endif
+
+/*
+ *  Enumeration of each option:
+ */
+typedef enum {
+        INDEX_OPT_IPV4             =  0,
+        INDEX_OPT_IPV6             =  1,
+        INDEX_OPT_COMMAND          =  2,
+        INDEX_OPT_LISTPEERS        =  3,
+        INDEX_OPT_PEERS            =  4,
+        INDEX_OPT_SHOWPEERS        =  5,
+        INDEX_OPT_INTERACTIVE      =  6,
+        INDEX_OPT_DEBUG_LEVEL      =  7,
+        INDEX_OPT_SET_DEBUG_LEVEL  =  8,
+        INDEX_OPT_NUMERIC          =  9,
+        INDEX_OPT_VERSION          = 10,
+        INDEX_OPT_HELP             = 11,
+        INDEX_OPT_MORE_HELP        = 12,
+        INDEX_OPT_SAVE_OPTS        = 13,
+        INDEX_OPT_LOAD_OPTS        = 14
+} teOptIndex;
+
+#define OPTION_CT    15
+#define NTPDC_VERSION       "4.2.4p8"
+#define NTPDC_FULL_VERSION  "ntpdc - vendor-specific NTP query program - Ver. 4.2.4p8"
+
+/*
+ *  Interface defines for all options.  Replace "n" with the UPPER_CASED
+ *  option name (as in the teOptIndex enumeration above).
+ *  e.g. HAVE_OPT( IPV4 )
+ */
+#define         DESC(n) (ntpdcOptions.pOptDesc[INDEX_OPT_## n])
+#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
+#define      OPT_ARG(n) (DESC(n).optArg.argString)
+#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
+#define    COUNT_OPT(n) (DESC(n).optOccCt)
+#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
+#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
+#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
+#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
+#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
+#define    CLEAR_OPT(n) STMTS( \
+                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
+                if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
+                    DESC(n).fOptState |= OPTST_DISABLED; \
+                DESC(n).optCookie = NULL )
+
+/*
+ *  Make sure there are no #define name conflicts with the option names
+ */
+#ifndef     NO_OPTION_NAME_WARNINGS
+# ifdef    IPV4
+#  warning undefining IPV4 due to option name conflict
+#  undef   IPV4
+# endif
+# ifdef    IPV6
+#  warning undefining IPV6 due to option name conflict
+#  undef   IPV6
+# endif
+# ifdef    COMMAND
+#  warning undefining COMMAND due to option name conflict
+#  undef   COMMAND
+# endif
+# ifdef    LISTPEERS
+#  warning undefining LISTPEERS due to option name conflict
+#  undef   LISTPEERS
+# endif
+# ifdef    PEERS
+#  warning undefining PEERS due to option name conflict
+#  undef   PEERS
+# endif
+# ifdef    SHOWPEERS
+#  warning undefining SHOWPEERS due to option name conflict
+#  undef   SHOWPEERS
+# endif
+# ifdef    INTERACTIVE
+#  warning undefining INTERACTIVE due to option name conflict
+#  undef   INTERACTIVE
+# endif
+# ifdef    DEBUG_LEVEL
+#  warning undefining DEBUG_LEVEL due to option name conflict
+#  undef   DEBUG_LEVEL
+# endif
+# ifdef    SET_DEBUG_LEVEL
+#  warning undefining SET_DEBUG_LEVEL due to option name conflict
+#  undef   SET_DEBUG_LEVEL
+# endif
+# ifdef    NUMERIC
+#  warning undefining NUMERIC due to option name conflict
+#  undef   NUMERIC
+# endif
+#else  /* NO_OPTION_NAME_WARNINGS */
+# undef IPV4
+# undef IPV6
+# undef COMMAND
+# undef LISTPEERS
+# undef PEERS
+# undef SHOWPEERS
+# undef INTERACTIVE
+# undef DEBUG_LEVEL
+# undef SET_DEBUG_LEVEL
+# undef NUMERIC
+#endif  /*  NO_OPTION_NAME_WARNINGS */
+
+/*
+ *  Interface defines for specific options.
+ */
+#define VALUE_OPT_IPV4           '4'
+#define WHICH_OPT_IPV4           (DESC(IPV4).optActualValue)
+#define WHICH_IDX_IPV4           (DESC(IPV4).optActualIndex)
+#define VALUE_OPT_IPV6           '6'
+#define VALUE_OPT_COMMAND        'c'
+#define VALUE_OPT_LISTPEERS      'l'
+#define VALUE_OPT_PEERS          'p'
+#define VALUE_OPT_SHOWPEERS      's'
+#define VALUE_OPT_INTERACTIVE    'i'
+#ifdef DEBUG
+#define VALUE_OPT_DEBUG_LEVEL    'd'
+#endif /* DEBUG */
+#ifdef DEBUG
+#define VALUE_OPT_SET_DEBUG_LEVEL 'D'
+#endif /* DEBUG */
+#define VALUE_OPT_NUMERIC        'n'
+
+#define VALUE_OPT_VERSION       'v'
+#define VALUE_OPT_HELP          '?'
+#define VALUE_OPT_MORE_HELP     '!'
+#define VALUE_OPT_SAVE_OPTS     '>'
+#define VALUE_OPT_LOAD_OPTS     '<'
+#define SET_OPT_SAVE_OPTS(a)   STMTS( \
+        DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
+        DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
+        DESC(SAVE_OPTS).optArg.argString = (char const*)(a) )
+/*
+ *  Interface defines not associated with particular options
+ */
+#define ERRSKIP_OPTERR  STMTS( ntpdcOptions.fOptSet &= ~OPTPROC_ERRSTOP )
+#define ERRSTOP_OPTERR  STMTS( ntpdcOptions.fOptSet |= OPTPROC_ERRSTOP )
+#define RESTART_OPT(n)  STMTS( \
+                ntpdcOptions.curOptIdx = (n); \
+                ntpdcOptions.pzCurOpt  = NULL )
+#define START_OPT       RESTART_OPT(1)
+#define USAGE(c)        (*ntpdcOptions.pUsageProc)( &ntpdcOptions, c )
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/opthead.tpl near line 360 */
+
+/* * * * * *
+ *
+ *  Declare the ntpdc option descriptor.
+ */
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+extern tOptions   ntpdcOptions;
+
+#ifndef _
+#  if ENABLE_NLS
+#    include <stdio.h>
+     static inline char* aoGetsText( char const* pz ) {
+         if (pz == NULL) return NULL;
+         return (char*)gettext( pz );
+     }
+#    define _(s)  aoGetsText(s)
+#  else  /* ENABLE_NLS */
+#    define _(s)  s
+#  endif /* ENABLE_NLS */
+#endif
+
+#ifdef  __cplusplus
+}
+#endif
+#endif /* AUTOOPTS_NTPDC_OPTS_H_GUARD */
+/* ntpdc-opts.h ends here */
diff --git a/ntpdc/ntpdc-opts.menu b/ntpdc/ntpdc-opts.menu
new file mode 100644 (file)
index 0000000..42ca3b4
--- /dev/null
@@ -0,0 +1 @@
+* ntpdc Invocation::               Invoking ntpdc
diff --git a/ntpdc/ntpdc-opts.texi b/ntpdc/ntpdc-opts.texi
new file mode 100644 (file)
index 0000000..121c270
--- /dev/null
@@ -0,0 +1,278 @@
+@node ntpdc Invocation
+@section Invoking ntpdc
+@pindex ntpdc
+@cindex vendor-specific NTP query program
+@ignore
+# 
+# EDIT THIS FILE WITH CAUTION  (ntpdc-opts.texi)
+# 
+# It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:02 AM EST
+# From the definitions    ntpdc-opts.def
+# and the template file   aginfo.tpl
+@end ignore
+This program has no explanation.
+
+The
+[= prog-name =]
+utility program is used to query an NTP daemon about its
+current state and to request changes in that state.
+It uses NTP mode 7 control message formats described in the source code.
+The program may
+be run either in interactive mode or controlled using command line
+arguments.
+Extensive state and statistics information is available
+through the
+[= prog-name =]
+interface.
+In addition, nearly all the
+configuration options which can be specified at startup using
+ntpd's configuration file may also be specified at run time using
+[= prog-name =] .
+
+
+
+This section was generated by @strong{AutoGen},
+the aginfo template and the option descriptions for the @command{ntpdc} program.  It documents the ntpdc usage text and option meanings.
+
+This software is released under a specialized copyright license.
+
+@menu
+* ntpdc usage::                  ntpdc usage help (-?)
+* ntpdc command::                command option (-c)
+* ntpdc debug-level::            debug-level option (-d)
+* ntpdc interactive::            interactive option (-i)
+* ntpdc ipv4::                   ipv4 option (-4)
+* ntpdc ipv6::                   ipv6 option (-6)
+* ntpdc listpeers::              listpeers option (-l)
+* ntpdc numeric::                numeric option (-n)
+* ntpdc peers::                  peers option (-p)
+* ntpdc set-debug-level::        set-debug-level option (-D)
+* ntpdc showpeers::              showpeers option (-s)
+@end menu
+
+@node ntpdc usage
+@subsection ntpdc usage help (-?)
+@cindex ntpdc usage
+
+This is the automatically generated usage text for ntpdc:
+
+@exampleindent 0
+@example
+ntpdc - vendor-specific NTP query program - Ver. 4.2.5p247-RC
+USAGE:  ntpdc [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [ host ...]
+  Flg Arg Option-Name    Description
+   -4 no  ipv4           Force IPv4 DNS name resolution
+                                - prohibits these options:
+                                ipv6
+   -6 no  ipv6           Force IPv6 DNS name resolution
+                                - prohibits these options:
+                                ipv4
+   -c Str command        run a command and exit
+                                - may appear multiple times
+   -l no  listpeers      Print a list of the peers
+                                - prohibits these options:
+                                command
+   -p no  peers          Print a list of the peers
+                                - prohibits these options:
+                                command
+   -s no  showpeers      Show a list of the peers
+                                - prohibits these options:
+                                command
+   -i no  interactive    Force ntpq to operate in interactive mode
+                                - prohibits these options:
+                                command
+                                listpeers
+                                peers
+                                showpeers
+   -d no  debug-level    Increase output debug message level
+                                - may appear multiple times
+   -D Str set-debug-level Set the output debug message level
+                                - may appear multiple times
+   -n no  numeric        numeric host addresses
+      opt version        Output version information and exit
+   -? no  help           Display extended usage information and exit
+   -! no  more-help      Extended usage information passed thru pager
+   -> opt save-opts      Save the option state to a config file
+   -< Str load-opts      Load options from a config file
+                                - disabled as --no-load-opts
+                                - may appear multiple times
+
+Options are specified by doubled hyphens and their name
+or by a single hyphen and the flag character.
+
+The following option preset mechanisms are supported:
+ - reading file /users/stenn/.ntprc
+ - reading file /deacon/backroom/snaps/ntp-stable/ntpdc/.ntprc
+ - examining environment variables named NTPDC_*
+
+The
+[= prog-name =]
+utility program is used to query an NTP daemon about its
+current state and to request changes in that state.
+It uses NTP mode 7 control message formats described in the source code.
+The program may
+be run either in interactive mode or controlled using command line
+arguments.
+Extensive state and statistics information is available
+through the
+[= prog-name =]
+interface.
+In addition, nearly all the
+configuration options which can be specified at startup using
+ntpd's configuration file may also be specified at run time using
+[= prog-name =] .
+
+please send bug reports to:  http://bugs.ntp.org, bugs@@ntp.org
+@end example
+@exampleindent 4
+
+@node ntpdc ipv4
+@subsection ipv4 option (-4)
+@cindex ntpdc-ipv4
+
+This is the ``force ipv4 dns name resolution'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is a member of the ipv4 class of options.
+@end itemize
+
+Force DNS resolution of following host names on the command line
+to the IPv4 namespace.
+
+@node ntpdc ipv6
+@subsection ipv6 option (-6)
+@cindex ntpdc-ipv6
+
+This is the ``force ipv6 dns name resolution'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is a member of the ipv4 class of options.
+@end itemize
+
+Force DNS resolution of following host names on the command line
+to the IPv6 namespace.
+
+@node ntpdc command
+@subsection command option (-c)
+@cindex ntpdc-command
+
+This is the ``run a command and exit'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+The following argument is interpreted as an interactive format command
+and is added to the list of commands to be executed on the specified
+host(s).
+
+@node ntpdc listpeers
+@subsection listpeers option (-l)
+@cindex ntpdc-listpeers
+
+This is the ``print a list of the peers'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+command.
+@end itemize
+
+Print a list of the peers known to the server as well as a summary of
+their state. This is equivalent to the 'listpeers' interactive command.
+
+@node ntpdc peers
+@subsection peers option (-p)
+@cindex ntpdc-peers
+
+This is the ``print a list of the peers'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+command.
+@end itemize
+
+Print a list of the peers known to the server as well as a summary
+of their state. This is equivalent to the 'peers' interactive command.
+
+@node ntpdc showpeers
+@subsection showpeers option (-s)
+@cindex ntpdc-showpeers
+
+This is the ``show a list of the peers'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+command.
+@end itemize
+
+Print a list of the peers known to the server as well as a summary
+of their state. This is equivalent to the 'dmpeers' interactive command.
+
+@node ntpdc interactive
+@subsection interactive option (-i)
+@cindex ntpdc-interactive
+
+This is the ``force ntpq to operate in interactive mode'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+command, listpeers, peers, showpeers.
+@end itemize
+
+Force ntpq to operate in interactive mode.  Prompts will be written
+to the standard output and commands read from the standard input.
+
+@node ntpdc debug-level
+@subsection debug-level option (-d)
+@cindex ntpdc-debug-level
+
+This is the ``increase output debug message level'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@item
+must be compiled in by defining @code{DEBUG} during the compilation.
+@end itemize
+
+Increase the debugging message output level.
+
+@node ntpdc set-debug-level
+@subsection set-debug-level option (-D)
+@cindex ntpdc-set-debug-level
+
+This is the ``set the output debug message level'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@item
+must be compiled in by defining @code{DEBUG} during the compilation.
+@end itemize
+
+Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+
+@node ntpdc numeric
+@subsection numeric option (-n)
+@cindex ntpdc-numeric
+
+This is the ``numeric host addresses'' option.
+Output all host addresses in dotted-quad numeric format rather than
+converting to the canonical host names. 
diff --git a/ntpdc/ntpdc.1 b/ntpdc/ntpdc.1
new file mode 100644 (file)
index 0000000..4227065
--- /dev/null
@@ -0,0 +1,158 @@
+.TH NTPDC 1 2009-12-08 "( 4.2.4p8)" "Programmer's Manual"
+.\"  EDIT THIS FILE WITH CAUTION  (ntpdc.1)
+.\"  
+.\"  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:01 AM EST
+.\"  From the definitions    ntpdc-opts.def
+.\"  and the template file   agman1.tpl
+.\"
+.SH NAME
+ntpdc \- vendor-specific NTP query program
+.SH SYNOPSIS
+.B ntpdc
+.\" Mixture of short (flag) options and long options
+.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..."
+.br
+.in +8
+[ host ...]
+.SH "DESCRIPTION"
+This manual page documents, briefly, the \fBntpdc\fP command.
+The
+[= prog-name =]
+utility program is used to query an NTP daemon about its
+current state and to request changes in that state.
+It uses NTP mode 7 control message formats described in the source code.
+The program may
+be run either in interactive mode or controlled using command line
+arguments.
+Extensive state and statistics information is available
+through the
+[= prog-name =]
+interface.
+In addition, nearly all the
+configuration options which can be specified at startup using
+ntpd's configuration file may also be specified at run time using
+[= prog-name =] .
+
+
+.SH OPTIONS
+.TP
+.BR \-4 ", " \--ipv4
+Force IPv4 DNS name resolution.
+This option is a member of the ipv4 class of options.
+.sp
+Force DNS resolution of following host names on the command line
+to the IPv4 namespace.
+.TP
+.BR \-6 ", " \--ipv6
+Force IPv6 DNS name resolution.
+This option is a member of the ipv4 class of options.
+.sp
+Force DNS resolution of following host names on the command line
+to the IPv6 namespace.
+.TP
+.BR \-c " \fIcmd\fP, " \--command "=" \fIcmd\fP
+run a command and exit.
+This option may appear an unlimited number of times.
+.sp
+The following argument is interpreted as an interactive format command
+and is added to the list of commands to be executed on the specified
+host(s).
+.TP
+.BR \-l ", " \--listpeers
+Print a list of the peers.
+This option must not appear in combination with any of the following options:
+command.
+.sp
+Print a list of the peers known to the server as well as a summary of
+their state. This is equivalent to the 'listpeers' interactive command.
+.TP
+.BR \-p ", " \--peers
+Print a list of the peers.
+This option must not appear in combination with any of the following options:
+command.
+.sp
+Print a list of the peers known to the server as well as a summary
+of their state. This is equivalent to the 'peers' interactive command.
+.TP
+.BR \-s ", " \--showpeers
+Show a list of the peers.
+This option must not appear in combination with any of the following options:
+command.
+.sp
+Print a list of the peers known to the server as well as a summary
+of their state. This is equivalent to the 'dmpeers' interactive command.
+.TP
+.BR \-i ", " \--interactive
+Force ntpq to operate in interactive mode.
+This option must not appear in combination with any of the following options:
+command, listpeers, peers, showpeers.
+.sp
+Force ntpq to operate in interactive mode.  Prompts will be written
+to the standard output and commands read from the standard input.
+.TP
+.BR \-d ", " \--debug-level
+Increase output debug message level.
+This option may appear an unlimited number of times.
+.sp
+Increase the debugging message output level.
+.TP
+.BR \-D " \fIstring\fP, " \--set-debug-level "=" \fIstring\fP
+Set the output debug message level.
+This option may appear an unlimited number of times.
+.sp
+Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+.TP
+.BR \-n ", " \--numeric
+numeric host addresses.
+.sp
+Output all host addresses in dotted-quad numeric format rather than
+converting to the canonical host names. 
+.TP
+.BR \-? , " \--help"
+Display usage information and exit.
+.TP
+.BR \-! , " \--more-help"
+Extended usage information passed thru pager.
+.TP
+.BR \-> " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]"
+Save the option state to \fIrcfile\fP.  The default is the \fIlast\fP
+configuration file listed in the \fBOPTION PRESETS\fP section, below.
+.TP
+.BR \-< " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts"
+Load options from \fIrcfile\fP.
+The \fIno-load-opts\fP form will disable the loading
+of earlier RC/INI files.  \fI--no-load-opts\fP is handled early,
+out of order.
+.TP
+.BR \-v " [{\fIv|c|n\fP}]," " \--version" "[=\fI{v|c|n}\fP]"
+Output version of program and exit.  The default mode is `v', a simple
+version.  The `c' mode will print copyright information and `n' will
+print the full copyright notice.
+.SH OPTION PRESETS
+Any option that is not marked as \fInot presettable\fP may be preset
+by loading values from configuration ("RC" or ".INI") file(s) and values from
+environment variables named:
+.nf
+  \fBNTPDC_<option-name>\fP or \fBNTPDC\fP
+.fi
+.aj
+The environmental presets take precedence (are processed later than)
+the configuration files.
+The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP".
+If any of these are directories, then the file \fI.ntprc\fP
+is searched for within those directories.
+.SH AUTHOR
+David L. Mills and/or others
+.br
+Please send bug reports to:  http://bugs.ntp.org, bugs@ntp.org
+
+.PP
+.nf
+.na
+see html/copyright.html
+.fi
+.ad
+.PP
+This manual page was \fIAutoGen\fP-erated from the \fBntpdc\fP
+option definitions.
diff --git a/ntpdc/ntpdc.c b/ntpdc/ntpdc.c
new file mode 100644 (file)
index 0000000..9126533
--- /dev/null
@@ -0,0 +1,1999 @@
+/*
+ * ntpdc - control and monitor your ntpd daemon
+ */
+
+#include <stdio.h>
+
+#include <ctype.h>
+#include <signal.h>
+#include <setjmp.h>
+
+#include "ntpdc.h"
+#include "ntp_select.h"
+#include "ntp_io.h"
+#include "ntp_stdlib.h"
+/* Don't include ISC's version of IPv6 variables and structures */
+#define ISC_IPV6_H 1
+#include "isc/net.h"
+#include "isc/result.h"
+
+#include "ntpdc-opts.h"
+
+#ifdef SYS_WINNT
+# include <Mswsock.h>
+# include <io.h>
+#else
+# define closesocket close
+#endif /* SYS_WINNT */
+
+#if defined(HAVE_LIBREADLINE) || defined (HAVE_LIBEDIT)
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif /* HAVE_LIBREADLINE || HAVE_LIBEDIT */
+
+#ifdef SYS_VXWORKS
+                               /* vxWorks needs mode flag -casey*/
+# define open(name, flags)   open(name, flags, 0777)
+# define SERVER_PORT_NUM     123
+#endif
+
+/* We use COMMAND as an autogen keyword */
+#ifdef COMMAND
+# undef COMMAND
+#endif
+
+/*
+ * Because we now potentially understand a lot of commands (and
+ * it requires a lot of commands to talk to ntpd) we will run
+ * interactive if connected to a terminal.
+ */
+static int     interactive = 0;        /* set to 1 when we should prompt */
+static const char *    prompt = "ntpdc> ";     /* prompt to ask him about */
+
+/*
+ * Keyid used for authenticated requests.  Obtained on the fly.
+ */
+static u_long  info_auth_keyid;
+static int keyid_entered = 0;
+
+/*
+ * Type of key md5
+ */
+#define        KEY_TYPE_MD5    4
+
+static int info_auth_keytype = KEY_TYPE_MD5;   /* MD5 */
+u_long current_time;           /* needed by authkeys; not used */
+
+/*
+ * for get_systime()
+ */
+s_char sys_precision;          /* local clock precision (log2 s) */
+
+int            ntpdcmain       P((int, char **));
+/*
+ * Built in command handler declarations
+ */
+static int     openhost        P((const char *));
+static int     sendpkt         P((char *, int));
+static void    growpktdata     P((void));
+static int     getresponse     P((int, int, int *, int *, char **, int));
+static int     sendrequest     P((int, int, int, int, int, char *));
+static void    getcmds         P((void));
+static RETSIGTYPE abortcmd     P((int));
+static void    docmd           P((const char *));
+static void    tokenize        P((const char *, char **, int *));
+static int     findcmd         P((char *, struct xcmd *, struct xcmd *, struct xcmd **));
+static int     getarg          P((char *, int, arg_v *));
+static int     getnetnum       P((const char *, struct sockaddr_storage *, char *, int));
+static void    help            P((struct parse *, FILE *));
+#ifdef QSORT_USES_VOID_P
+static int     helpsort        P((const void *, const void *));
+#else
+static int     helpsort        P((char **, char **));
+#endif
+static void    printusage      P((struct xcmd *, FILE *));
+static void    timeout         P((struct parse *, FILE *));
+static void    my_delay        P((struct parse *, FILE *));
+static void    host            P((struct parse *, FILE *));
+static void    keyid           P((struct parse *, FILE *));
+static void    keytype         P((struct parse *, FILE *));
+static void    passwd          P((struct parse *, FILE *));
+static void    hostnames       P((struct parse *, FILE *));
+static void    setdebug        P((struct parse *, FILE *));
+static void    quit            P((struct parse *, FILE *));
+static void    version         P((struct parse *, FILE *));
+static void    warning         P((const char *, const char *, const char *));
+static void    error           P((const char *, const char *, const char *));
+static u_long  getkeyid        P((const char *));
+
+
+
+/*
+ * Built-in commands we understand
+ */
+static struct xcmd builtins[] = {
+       { "?",          help,           {  OPT|NTP_STR, NO, NO, NO },
+         { "command", "", "", "" },
+         "tell the use and syntax of commands" },
+       { "help",       help,           {  OPT|NTP_STR, NO, NO, NO },
+         { "command", "", "", "" },
+         "tell the use and syntax of commands" },
+       { "timeout",    timeout,        { OPT|NTP_UINT, NO, NO, NO },
+         { "msec", "", "", "" },
+         "set the primary receive time out" },
+       { "delay",      my_delay,       { OPT|NTP_INT, NO, NO, NO },
+         { "msec", "", "", "" },
+         "set the delay added to encryption time stamps" },
+       { "host",       host,           { OPT|NTP_STR, OPT|NTP_STR, NO, NO },
+         { "-4|-6", "hostname", "", "" },
+         "specify the host whose NTP server we talk to" },
+       { "passwd",     passwd,         { OPT|NTP_STR, NO, NO, NO },
+         { "", "", "", "" },
+         "specify a password to use for authenticated requests"},
+       { "hostnames",  hostnames,      { OPT|NTP_STR, NO, NO, NO },
+         { "yes|no", "", "", "" },
+         "specify whether hostnames or net numbers are printed"},
+       { "debug",      setdebug,       { OPT|NTP_STR, NO, NO, NO },
+         { "no|more|less", "", "", "" },
+         "set/change debugging level" },
+       { "quit",       quit,           { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "exit ntpdc" },
+       { "exit",       quit,           { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "exit ntpdc" },
+       { "keyid",      keyid,          { OPT|NTP_UINT, NO, NO, NO },
+         { "key#", "", "", "" },
+         "set/show keyid to use for authenticated requests" },
+       { "keytype",    keytype,        { OPT|NTP_STR, NO, NO, NO },
+         { "(md5|des)", "", "", "" },
+         "set/show key authentication type for authenticated requests (des|md5)" },
+       { "version",    version,        { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "print version number" },
+       { 0,            0,              { NO, NO, NO, NO },
+         { "", "", "", "" }, "" }
+};
+
+
+/*
+ * Default values we use.
+ */
+#define        DEFTIMEOUT      (5)             /* 5 second time out */
+#define        DEFSTIMEOUT     (2)             /* 2 second time out after first */
+#define        DEFDELAY        0x51EB852       /* 20 milliseconds, l_fp fraction */
+#define        DEFHOST         "localhost"     /* default host name */
+#define        LENHOSTNAME     256             /* host name is 256 characters long */
+#define        MAXCMDS         100             /* maximum commands on cmd line */
+#define        MAXHOSTS        200             /* maximum hosts on cmd line */
+#define        MAXLINE         512             /* maximum line length */
+#define        MAXTOKENS       (1+1+MAXARGS+MOREARGS+2)        /* maximum number of usable tokens */
+#define        SCREENWIDTH     78              /* nominal screen width in columns */
+
+/*
+ * Some variables used and manipulated locally
+ */
+static struct timeval tvout = { DEFTIMEOUT, 0 };       /* time out for reads */
+static struct timeval tvsout = { DEFSTIMEOUT, 0 };     /* secondary time out */
+static l_fp delay_time;                                /* delay time */
+static char currenthost[LENHOSTNAME];                  /* current host name */
+int showhostnames = 1;                                 /* show host names by default */
+
+static int ai_fam_templ;                               /* address family */
+static int ai_fam_default;                             /* default address family */
+static SOCKET sockfd;                                  /* fd socket is opened on */
+static int havehost = 0;                               /* set to 1 when host open */
+int s_port = 0;
+
+#if defined (SYS_WINNT) || defined (SYS_VXWORKS)
+char password[9];
+#endif /* SYS_WINNT || SYS_VXWORKS */
+
+#ifdef SYS_WINNT
+DWORD NumberOfBytesWritten;
+
+HANDLE TimerThreadHandle = NULL;       /* 1998/06/03 - Used in ntplib/machines.c */
+void timer(void)       {  ; }; /* 1998/06/03 - Used in ntplib/machines.c */
+
+#endif /* SYS_WINNT */
+
+/*
+ * Holds data returned from queries.  We allocate INITDATASIZE
+ * octets to begin with, increasing this as we need to.
+ */
+#define        INITDATASIZE    (sizeof(struct resp_pkt) * 16)
+#define        INCDATASIZE     (sizeof(struct resp_pkt) * 8)
+
+static char *pktdata;
+static int pktdatasize;
+
+/*
+ * These are used to help the magic with old and new versions of ntpd.
+ */
+int impl_ver = IMPL_XNTPD;
+static int req_pkt_size = REQ_LEN_NOMAC;
+
+/*
+ * For commands typed on the command line (with the -c option)
+ */
+static int numcmds = 0;
+static const char *ccmds[MAXCMDS];
+#define        ADDCMD(cp)      if (numcmds < MAXCMDS) ccmds[numcmds++] = (cp)
+
+/*
+ * When multiple hosts are specified.
+ */
+static int numhosts = 0;
+static const char *chosts[MAXHOSTS];
+#define        ADDHOST(cp)     if (numhosts < MAXHOSTS) chosts[numhosts++] = (cp)
+
+/*
+ * Error codes for internal use
+ */
+#define        ERR_INCOMPLETE          16
+#define        ERR_TIMEOUT             17
+
+/*
+ * Macro definitions we use
+ */
+#define        ISSPACE(c)      ((c) == ' ' || (c) == '\t')
+#define        ISEOL(c)        ((c) == '\n' || (c) == '\r' || (c) == '\0')
+#define        STREQ(a, b)     (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+/*
+ * For converting time stamps to dates
+ */
+#define        JAN_1970        2208988800      /* 1970 - 1900 in seconds */
+
+/*
+ * Jump buffer for longjumping back to the command level
+ */
+static jmp_buf interrupt_buf;
+static  volatile int jump = 0;
+
+/*
+ * Pointer to current output unit
+ */
+static FILE *current_output;
+
+/*
+ * Command table imported from ntpdc_ops.c
+ */
+extern struct xcmd opcmds[];
+
+char *progname;
+volatile int debug;
+
+#ifdef NO_MAIN_ALLOWED
+CALL(ntpdc,"ntpdc",ntpdcmain);
+#else
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       return ntpdcmain(argc, argv);
+}
+#endif
+
+#ifdef SYS_VXWORKS
+void clear_globals(void)
+{
+    showhostnames = 0;              /* show host names by default */
+    havehost = 0;                   /* set to 1 when host open */
+    numcmds = 0;
+    numhosts = 0;
+}
+#endif
+
+/*
+ * main - parse arguments and handle options
+ */
+int
+ntpdcmain(
+       int argc,
+       char *argv[]
+       )
+{
+       extern int ntp_optind;
+
+       delay_time.l_ui = 0;
+       delay_time.l_uf = DEFDELAY;
+
+#ifdef SYS_VXWORKS
+       clear_globals();
+       taskPrioritySet(taskIdSelf(), 100 );
+#endif
+
+#ifdef SYS_WINNT
+       if (!Win32InitSockets())
+       {
+               fprintf(stderr, "No useable winsock.dll:");
+               exit(1);
+       }
+#endif /* SYS_WINNT */
+
+       /* Check to see if we have IPv6. Otherwise force the -4 flag */
+       if (isc_net_probeipv6() != ISC_R_SUCCESS) {
+               ai_fam_default = AF_INET;
+       }
+
+       progname = argv[0];
+
+       {
+               int optct = optionProcess(&ntpdcOptions, argc, argv);
+               argc -= optct;
+               argv += optct;
+       }
+
+       switch (WHICH_IDX_IPV4) {
+           case INDEX_OPT_IPV4:
+               ai_fam_templ = AF_INET;
+               break;
+           case INDEX_OPT_IPV6:
+               ai_fam_templ = AF_INET6;
+               break;
+           default:
+               ai_fam_templ = ai_fam_default;
+               break;
+       }
+
+       if (HAVE_OPT(COMMAND)) {
+               int             cmdct = STACKCT_OPT( COMMAND );
+               const char**    cmds  = STACKLST_OPT( COMMAND );
+
+               while (cmdct-- > 0) {
+                       ADDCMD(*cmds++);
+               }
+       }
+
+       debug = DESC(DEBUG_LEVEL).optOccCt;
+
+       if (HAVE_OPT(INTERACTIVE)) {
+               interactive = 1;
+       }
+
+       if (HAVE_OPT(NUMERIC)) {
+               showhostnames = 0;
+       }
+
+       if (HAVE_OPT(LISTPEERS)) {
+               ADDCMD("listpeers");
+       }
+
+       if (HAVE_OPT(PEERS)) {
+               ADDCMD("peers");
+       }
+
+       if (HAVE_OPT(SHOWPEERS)) {
+               ADDCMD("dmpeers");
+       }
+
+       if (ntp_optind == argc) {
+               ADDHOST(DEFHOST);
+       } else {
+               for (; ntp_optind < argc; ntp_optind++)
+                   ADDHOST(argv[ntp_optind]);
+       }
+
+       if (numcmds == 0 && interactive == 0
+           && isatty(fileno(stdin)) && isatty(fileno(stderr))) {
+               interactive = 1;
+       }
+
+#if 0
+       ai_fam_templ = ai_fam_default;
+       while ((c = ntp_getopt(argc, argv, "46c:dilnps")) != EOF)
+           switch (c) {
+               case '4':
+                   ai_fam_templ = AF_INET;
+                   break;
+               case '6':
+                   ai_fam_templ = AF_INET6;
+                   break;
+               case 'c':
+                   ADDCMD(ntp_optarg);
+                   break;
+               case 'd':
+                   ++debug;
+                   break;
+               case 'i':
+                   interactive = 1;
+                   break;
+               case 'l':
+                   ADDCMD("listpeers");
+                   break;
+               case 'n':
+                   showhostnames = 0;
+                   break;
+               case 'p':
+                   ADDCMD("peers");
+                   break;
+               case 's':
+                   ADDCMD("dmpeers");
+                   break;
+               default:
+                   errflg++;
+                   break;
+           }
+
+       if (errflg) {
+               (void) fprintf(stderr,
+                              "usage: %s [-46dilnps] [-c cmd] host ...\n",
+                              progname);
+               exit(2);
+       }
+
+       if (ntp_optind == argc) {
+               ADDHOST(DEFHOST);
+       } else {
+               for (; ntp_optind < argc; ntp_optind++)
+                   ADDHOST(argv[ntp_optind]);
+       }
+
+       if (numcmds == 0 && interactive == 0
+           && isatty(fileno(stdin)) && isatty(fileno(stderr))) {
+               interactive = 1;
+       }
+#endif
+
+#ifndef SYS_WINNT /* Under NT cannot handle SIGINT, WIN32 spawns a handler */
+       if (interactive)
+           (void) signal_no_reset(SIGINT, abortcmd);
+#endif /* SYS_WINNT */
+
+       /*
+        * Initialize the packet data buffer
+        */
+       pktdata = (char *)malloc(INITDATASIZE);
+       if (pktdata == NULL) {
+               (void) fprintf(stderr, "%s: malloc() failed!\n", progname);
+               exit(1);
+       }
+       pktdatasize = INITDATASIZE;
+
+       if (numcmds == 0) {
+               (void) openhost(chosts[0]);
+               getcmds();
+       } else {
+               int ihost;
+               int icmd;
+
+               for (ihost = 0; ihost < numhosts; ihost++) {
+                       if (openhost(chosts[ihost]))
+                           for (icmd = 0; icmd < numcmds; icmd++) {
+                                   if (numhosts > 1) 
+                                       printf ("--- %s ---\n",chosts[ihost]);
+                                   docmd(ccmds[icmd]);
+                           }
+               }
+       }
+#ifdef SYS_WINNT
+       WSACleanup();
+#endif
+       return(0);
+} /* main end */
+
+
+/*
+ * openhost - open a socket to a host
+ */
+static int
+openhost(
+       const char *hname
+       )
+{
+       char temphost[LENHOSTNAME];
+       int a_info, i;
+       struct addrinfo hints, *ai = NULL;
+       register const char *cp;
+       char name[LENHOSTNAME];
+       char service[5];
+
+       /*
+        * We need to get by the [] if they were entered 
+        */
+       
+       cp = hname;
+       
+       if (*cp == '[') {
+               cp++;   
+               for(i = 0; *cp != ']'; cp++, i++)
+                       name[i] = *cp;  
+               name[i] = '\0';
+               hname = name;
+       }       
+
+       /*
+        * First try to resolve it as an ip address and if that fails,
+        * do a fullblown (dns) lookup. That way we only use the dns
+        * when it is needed and work around some implementations that
+        * will return an "IPv4-mapped IPv6 address" address if you
+        * give it an IPv4 address to lookup.
+        */
+       strcpy(service, "ntp");
+       memset((char *)&hints, 0, sizeof(struct addrinfo));
+       hints.ai_family = ai_fam_templ;
+       hints.ai_protocol = IPPROTO_UDP;
+       hints.ai_socktype = SOCK_DGRAM;
+       hints.ai_flags = AI_NUMERICHOST;
+
+       a_info = getaddrinfo(hname, service, &hints, &ai);
+       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(hname, service, &hints, &ai);      
+       }
+       /* Some older implementations don't like AI_ADDRCONFIG. */
+       if (a_info == EAI_BADFLAGS) {
+               hints.ai_flags = AI_CANONNAME;
+               a_info = getaddrinfo(hname, service, &hints, &ai);      
+       }
+       if (a_info != 0) {
+               (void) fprintf(stderr, "%s\n", gai_strerror(a_info));
+               if (ai != NULL)
+                       freeaddrinfo(ai);
+               return 0;
+       }
+
+       if (ai->ai_canonname == NULL) {
+               strncpy(temphost, stoa((struct sockaddr_storage *)ai->ai_addr),
+                   LENHOSTNAME);
+               temphost[LENHOSTNAME-1] = '\0';
+       } else {
+               strncpy(temphost, ai->ai_canonname, LENHOSTNAME);
+               temphost[LENHOSTNAME-1] = '\0';
+       }
+
+       if (debug > 2)
+           printf("Opening host %s\n", temphost);
+
+       if (havehost == 1) {
+               if (debug > 2)
+                   printf("Closing old host %s\n", currenthost);
+               (void) closesocket(sockfd);
+               havehost = 0;
+       }
+       (void) strcpy(currenthost, temphost);
+       
+       /* port maps to the same in both families */
+       s_port = ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port; 
+#ifdef SYS_VXWORKS
+       ((struct sockaddr_in6 *)&hostaddr)->sin6_port = htons(SERVER_PORT_NUM);
+       if (ai->ai_family == AF_INET)
+               *(struct sockaddr_in *)&hostaddr= 
+                       *((struct sockaddr_in *)ai->ai_addr);
+       else 
+               *(struct sockaddr_in6 *)&hostaddr= 
+                       *((struct sockaddr_in6 *)ai->ai_addr);
+#endif /* SYS_VXWORKS */
+
+#ifdef SYS_WINNT
+       {
+               int optionValue = SO_SYNCHRONOUS_NONALERT;
+               int err;
+
+               err = setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&optionValue, sizeof(optionValue));
+               if (err != NO_ERROR) {
+                       (void) fprintf(stderr, "cannot open nonoverlapped sockets\n");
+                       exit(1);
+               }
+       }
+
+       sockfd = socket(ai->ai_family, SOCK_DGRAM, 0);
+       if (sockfd == INVALID_SOCKET) {
+               error("socket", "", "");
+               exit(-1);
+       }
+#else
+       sockfd = socket(ai->ai_family, SOCK_DGRAM, 0);
+       if (sockfd == -1)
+           error("socket", "", "");
+#endif /* SYS_WINNT */
+
+       
+#ifdef NEED_RCVBUF_SLOP
+# ifdef SO_RCVBUF
+       {
+               int rbufsize = INITDATASIZE + 2048; /* 2K for slop */
+
+               if (setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF,
+                              &rbufsize, sizeof(int)) == -1)
+                   error("setsockopt", "", "");
+       }
+# endif
+#endif
+
+#ifdef SYS_VXWORKS
+       if (connect(sockfd, (struct sockaddr *)&hostaddr, 
+                   sizeof(hostaddr)) == -1)
+#else
+       if (connect(sockfd, (struct sockaddr *)ai->ai_addr,
+                   ai->ai_addrlen) == -1)
+#endif /* SYS_VXWORKS */
+           error("connect", "", "");
+       if (ai != NULL)
+               freeaddrinfo(ai);
+       havehost = 1;
+       req_pkt_size = REQ_LEN_NOMAC;
+       impl_ver = IMPL_XNTPD;
+       return 1;
+}
+
+
+/* XXX ELIMINATE sendpkt similar in ntpq.c, ntpdc.c, ntp_io.c, ntptrace.c */
+/*
+ * sendpkt - send a packet to the remote host
+ */
+static int
+sendpkt(
+       char *xdata,
+       int xdatalen
+       )
+{
+       if (send(sockfd, xdata, (size_t)xdatalen, 0) == -1) {
+               warning("write to %s failed", currenthost, "");
+               return -1;
+       }
+
+       return 0;
+}
+
+
+/*
+ * growpktdata - grow the packet data area
+ */
+static void
+growpktdata(void)
+{
+       pktdatasize += INCDATASIZE;
+       pktdata = (char *)realloc(pktdata, (unsigned)pktdatasize);
+       if (pktdata == 0) {
+               (void) fprintf(stderr, "%s: realloc() failed!\n", progname);
+               exit(1);
+       }
+}
+
+
+/*
+ * getresponse - get a (series of) response packet(s) and return the data
+ */
+static int
+getresponse(
+       int implcode,
+       int reqcode,
+       int *ritems,
+       int *rsize,
+       char **rdata,
+       int esize
+       )
+{
+       struct resp_pkt rpkt;
+       struct timeval tvo;
+       int items;
+       int i;
+       int size;
+       int datasize;
+       char *datap;
+       char *tmp_data;
+       char haveseq[MAXSEQ+1];
+       int firstpkt;
+       int lastseq;
+       int numrecv;
+       int seq;
+       fd_set fds;
+       int n;
+       int pad;
+
+       /*
+        * This is pretty tricky.  We may get between 1 and many packets
+        * back in response to the request.  We peel the data out of
+        * each packet and collect it in one long block.  When the last
+        * packet in the sequence is received we'll know how many we
+        * should have had.  Note we use one long time out, should reconsider.
+        */
+       *ritems = 0;
+       *rsize = 0;
+       firstpkt = 1;
+       numrecv = 0;
+       *rdata = datap = pktdata;
+       lastseq = 999;  /* too big to be a sequence number */
+       memset(haveseq, 0, sizeof(haveseq));
+       FD_ZERO(&fds);
+
+    again:
+       if (firstpkt)
+           tvo = tvout;
+       else
+           tvo = tvsout;
+       
+       FD_SET(sockfd, &fds);
+       n = select(sockfd+1, &fds, (fd_set *)0, (fd_set *)0, &tvo);
+
+       if (n == -1) {
+               warning("select fails", "", "");
+               return -1;
+       }
+       if (n == 0) {
+               /*
+                * Timed out.  Return what we have
+                */
+               if (firstpkt) {
+                       (void) fprintf(stderr,
+                                      "%s: timed out, nothing received\n", currenthost);
+                       return ERR_TIMEOUT;
+               } else {
+                       (void) fprintf(stderr,
+                                      "%s: timed out with incomplete data\n",
+                                      currenthost);
+                       if (debug) {
+                               printf("Received sequence numbers");
+                               for (n = 0; n <= MAXSEQ; n++)
+                                   if (haveseq[n])
+                                       printf(" %d,", n);
+                               if (lastseq != 999)
+                                   printf(" last frame received\n");
+                               else
+                                   printf(" last frame not received\n");
+                       }
+                       return ERR_INCOMPLETE;
+               }
+       }
+
+       n = recv(sockfd, (char *)&rpkt, sizeof(rpkt), 0);
+       if (n == -1) {
+               warning("read", "", "");
+               return -1;
+       }
+
+
+       /*
+        * Check for format errors.  Bug proofing.
+        */
+       if (n < RESP_HEADER_SIZE) {
+               if (debug)
+                   printf("Short (%d byte) packet received\n", n);
+               goto again;
+       }
+       if (INFO_VERSION(rpkt.rm_vn_mode) > NTP_VERSION ||
+           INFO_VERSION(rpkt.rm_vn_mode) < NTP_OLDVERSION) {
+               if (debug)
+                   printf("Packet received with version %d\n",
+                          INFO_VERSION(rpkt.rm_vn_mode));
+               goto again;
+       }
+       if (INFO_MODE(rpkt.rm_vn_mode) != MODE_PRIVATE) {
+               if (debug)
+                   printf("Packet received with mode %d\n",
+                          INFO_MODE(rpkt.rm_vn_mode));
+               goto again;
+       }
+       if (INFO_IS_AUTH(rpkt.auth_seq)) {
+               if (debug)
+                   printf("Encrypted packet received\n");
+               goto again;
+       }
+       if (!ISRESPONSE(rpkt.rm_vn_mode)) {
+               if (debug)
+                   printf("Received request packet, wanted response\n");
+               goto again;
+       }
+       if (INFO_MBZ(rpkt.mbz_itemsize) != 0) {
+               if (debug)
+                   printf("Received packet with nonzero MBZ field!\n");
+               goto again;
+       }
+
+       /*
+        * Check implementation/request.  Could be old data getting to us.
+        */
+       if (rpkt.implementation != implcode || rpkt.request != reqcode) {
+               if (debug)
+                   printf(
+                           "Received implementation/request of %d/%d, wanted %d/%d",
+                           rpkt.implementation, rpkt.request,
+                           implcode, reqcode);
+               goto again;
+       }
+
+       /*
+        * Check the error code.  If non-zero, return it.
+        */
+       if (INFO_ERR(rpkt.err_nitems) != INFO_OKAY) {
+               if (debug && ISMORE(rpkt.rm_vn_mode)) {
+                       printf("Error code %d received on not-final packet\n",
+                              INFO_ERR(rpkt.err_nitems));
+               }
+               return (int)INFO_ERR(rpkt.err_nitems);
+       }
+
+       /*
+        * Collect items and size.  Make sure they make sense.
+        */
+       items = INFO_NITEMS(rpkt.err_nitems);
+       size = INFO_ITEMSIZE(rpkt.mbz_itemsize);
+       if (esize > size)
+               pad = esize - size;
+       else 
+               pad = 0;
+       if ((datasize = items*size) > (n-RESP_HEADER_SIZE)) {
+               if (debug)
+                   printf(
+                           "Received items %d, size %d (total %d), data in packet is %d\n",
+                           items, size, datasize, n-RESP_HEADER_SIZE);
+               goto again;
+       }
+
+       /*
+        * If this isn't our first packet, make sure the size matches
+        * the other ones.
+        */
+       if (!firstpkt && esize != *rsize) {
+               if (debug)
+                   printf("Received itemsize %d, previous %d\n",
+                          size, *rsize);
+               goto again;
+       }
+       /*
+        * If we've received this before, +toss it
+        */
+       seq = INFO_SEQ(rpkt.auth_seq);
+       if (haveseq[seq]) {
+               if (debug)
+                   printf("Received duplicate sequence number %d\n", seq);
+               goto again;
+       }
+       haveseq[seq] = 1;
+
+       /*
+        * If this is the last in the sequence, record that.
+        */
+       if (!ISMORE(rpkt.rm_vn_mode)) {
+               if (lastseq != 999) {
+                       printf("Received second end sequence packet\n");
+                       goto again;
+               }
+               lastseq = seq;
+       }
+
+       /*
+        * So far, so good.  Copy this data into the output array.
+        */
+       if ((datap + datasize + (pad * items)) > (pktdata + pktdatasize)) {
+               int offset = datap - pktdata;
+               growpktdata();
+               *rdata = pktdata; /* might have been realloced ! */
+               datap = pktdata + offset;
+       }
+       /* 
+        * We now move the pointer along according to size and number of
+        * items.  This is so we can play nice with older implementations
+        */
+
+       tmp_data = (char *)rpkt.data;
+       for(i = 0; i <items; i++){
+               memmove(datap, tmp_data, (unsigned)size);
+               tmp_data += size;
+               memset(datap + size, 0, pad);
+               datap += size + pad;
+       }
+
+       if (firstpkt) {
+               firstpkt = 0;
+               *rsize = size + pad;
+       }
+       *ritems += items;
+
+       /*
+        * Finally, check the count of received packets.  If we've got them
+        * all, return
+        */
+       ++numrecv;
+       if (numrecv <= lastseq)
+           goto again;
+       return INFO_OKAY;
+}
+
+
+/*
+ * sendrequest - format and send a request packet
+ */
+static int
+sendrequest(
+       int implcode,
+       int reqcode,
+       int auth,
+       int qitems,
+       int qsize,
+       char *qdata
+       )
+{
+       struct req_pkt qpkt;
+       int datasize;
+
+       memset((char *)&qpkt, 0, sizeof qpkt);
+
+       qpkt.rm_vn_mode = RM_VN_MODE(0, 0, 0);
+       qpkt.implementation = (u_char)implcode;
+       qpkt.request = (u_char)reqcode;
+
+       datasize = qitems * qsize;
+       if (datasize != 0 && qdata != NULL) {
+               memmove((char *)qpkt.data, qdata, (unsigned)datasize);
+               qpkt.err_nitems = ERR_NITEMS(0, qitems);
+               qpkt.mbz_itemsize = MBZ_ITEMSIZE(qsize);
+       } else {
+               qpkt.err_nitems = ERR_NITEMS(0, 0);
+               qpkt.mbz_itemsize = MBZ_ITEMSIZE(qsize);  /* allow for optional first item */
+       }
+
+       if (!auth || (keyid_entered && info_auth_keyid == 0)) {
+               qpkt.auth_seq = AUTH_SEQ(0, 0);
+               return sendpkt((char *)&qpkt, req_pkt_size);
+       } else {
+               l_fp ts;
+               int maclen = 0;
+               const char *pass = "\0";
+               struct req_pkt_tail *qpktail;
+
+               qpktail = (struct req_pkt_tail *)((char *)&qpkt + req_pkt_size
+                   + MAX_MAC_LEN - sizeof(struct req_pkt_tail));
+
+               if (info_auth_keyid == 0) {
+                       if (((struct conf_peer *)qpkt.data)->keyid > 0)
+                               info_auth_keyid = ((struct conf_peer *)qpkt.data)->keyid;
+                       else {
+                               maclen = getkeyid("Keyid: ");
+                               if (maclen == 0) {
+                                       (void) fprintf(stderr,
+                                           "Invalid key identifier\n");
+                                       return 1;
+                               }
+                               info_auth_keyid = maclen;
+                       }
+               }
+               if (!authistrusted(info_auth_keyid)) {
+                       pass = getpass("MD5 Password: ");
+                       if (*pass == '\0') {
+                               (void) fprintf(stderr,
+                                   "Invalid password\n");
+                               return (1);
+                       }
+               }
+               authusekey(info_auth_keyid, info_auth_keytype, (const u_char *)pass);
+               authtrust(info_auth_keyid, 1);
+               qpkt.auth_seq = AUTH_SEQ(1, 0);
+               qpktail->keyid = htonl(info_auth_keyid);
+               get_systime(&ts);
+               L_ADD(&ts, &delay_time);
+               HTONL_FP(&ts, &qpktail->tstamp);
+               maclen = authencrypt(info_auth_keyid, (u_int32 *)&qpkt,
+                   req_pkt_size);
+               if (maclen == 0) {  
+                       (void) fprintf(stderr, "Key not found\n");
+                       return (1);
+               }
+               return sendpkt((char *)&qpkt, (int)(req_pkt_size + maclen));
+       }
+       /*NOTREACHED*/
+}
+
+
+/*
+ * doquery - send a request and process the response
+ */
+int
+doquery(
+       int implcode,
+       int reqcode,
+       int auth,
+       int qitems,
+       int qsize,
+       char *qdata,
+       int *ritems,
+       int *rsize,
+       char **rdata,
+       int quiet_mask,
+       int esize
+       )
+{
+       int res;
+       char junk[512];
+       fd_set fds;
+       struct timeval tvzero;
+
+       /*
+        * Check to make sure host is open
+        */
+       if (!havehost) {
+               (void) fprintf(stderr, "***No host open, use `host' command\n");
+               return -1;
+       }
+
+       /*
+        * Poll the socket and clear out any pending data
+        */
+again:
+       do {
+               tvzero.tv_sec = tvzero.tv_usec = 0;
+               FD_ZERO(&fds);
+               FD_SET(sockfd, &fds);
+               res = select(sockfd+1, &fds, (fd_set *)0, (fd_set *)0, &tvzero);
+
+               if (res == -1) {
+                       warning("polling select", "", "");
+                       return -1;
+               } else if (res > 0)
+
+                   (void) recv(sockfd, junk, sizeof junk, 0);
+       } while (res > 0);
+
+
+       /*
+        * send a request
+        */
+       res = sendrequest(implcode, reqcode, auth, qitems, qsize, qdata);
+       if (res != 0)
+           return res;
+       
+       /*
+        * Get the response.  If we got a standard error, print a message
+        */
+       res = getresponse(implcode, reqcode, ritems, rsize, rdata, esize);
+
+       /*
+        * Try to be compatible with older implementations of ntpd.
+        */
+       if (res == INFO_ERR_FMT && req_pkt_size != 48) {
+               int oldsize;
+
+               oldsize = req_pkt_size;
+
+               switch(req_pkt_size) {
+               case REQ_LEN_NOMAC:
+                       req_pkt_size = 160;
+                       break;
+               case 160:
+                       req_pkt_size = 48;
+                       break;
+               }
+               if (impl_ver == IMPL_XNTPD) {
+                       fprintf(stderr,
+                           "***Warning changing to older implementation\n");
+                       return INFO_ERR_IMPL;
+               }
+
+               fprintf(stderr,
+                   "***Warning changing the request packet size from %d to %d\n",
+                   oldsize, req_pkt_size);
+               goto again;
+       }
+
+       /* log error message if not told to be quiet */
+       if ((res > 0) && (((1 << res) & quiet_mask) == 0)) {
+               switch(res) {
+                   case INFO_ERR_IMPL:
+                       /* Give us a chance to try the older implementation. */
+                       if (implcode == IMPL_XNTPD)
+                               break;
+                       (void) fprintf(stderr,
+                                      "***Server implementation incompatable with our own\n");
+                       break;
+                   case INFO_ERR_REQ:
+                       (void) fprintf(stderr,
+                                      "***Server doesn't implement this request\n");
+                       break;
+                   case INFO_ERR_FMT:
+                       (void) fprintf(stderr,
+                                      "***Server reports a format error in the received packet (shouldn't happen)\n");
+                       break;
+                   case INFO_ERR_NODATA:
+                       (void) fprintf(stderr,
+                                      "***Server reports data not found\n");
+                       break;
+                   case INFO_ERR_AUTH:
+                       (void) fprintf(stderr, "***Permission denied\n");
+                       break;
+                   case ERR_TIMEOUT:
+                       (void) fprintf(stderr, "***Request timed out\n");
+                       break;
+                   case ERR_INCOMPLETE:
+                       (void) fprintf(stderr,
+                                      "***Response from server was incomplete\n");
+                       break;
+                   default:
+                       (void) fprintf(stderr,
+                                      "***Server returns unknown error code %d\n", res);
+                       break;
+               }
+       }
+       return res;
+}
+
+
+/*
+ * getcmds - read commands from the standard input and execute them
+ */
+static void
+getcmds(void)
+{
+#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
+       char *line;
+
+       for (;;) {
+               if ((line = readline(interactive?prompt:"")) == NULL) return;
+               if (*line) add_history(line);
+               docmd(line);
+               free(line);
+       }
+#else /* not (HAVE_LIBREADLINE || HAVE_LIBEDIT) */
+       char line[MAXLINE];
+
+       for (;;) {
+               if (interactive) {
+#ifdef VMS     /* work around a problem with mixing stdout & stderr */
+                       fputs("",stdout);
+#endif
+                       (void) fputs(prompt, stderr);
+                       (void) fflush(stderr);
+               }
+
+               if (fgets(line, sizeof line, stdin) == NULL)
+                   return;
+
+               docmd(line);
+       }
+#endif /* not HAVE_LIBREADLINE || HAVE_LIBEDIT */
+}
+
+
+#ifndef SYS_WINNT /* Under NT cannot handle SIGINT, WIN32 spawns a handler */
+/*
+ * abortcmd - catch interrupts and abort the current command
+ */
+static RETSIGTYPE
+abortcmd(
+       int sig
+       )
+{
+
+       if (current_output == stdout)
+           (void) fflush(stdout);
+       putc('\n', stderr);
+       (void) fflush(stderr);
+       if (jump) longjmp(interrupt_buf, 1);
+}
+#endif /* SYS_WINNT */
+
+/*
+ * docmd - decode the command line and execute a command
+ */
+static void
+docmd(
+       const char *cmdline
+       )
+{
+       char *tokens[1+MAXARGS+MOREARGS+2];
+       struct parse pcmd;
+       int ntok;
+       int i, ti;
+       int rval;
+       struct xcmd *xcmd;
+
+       ai_fam_templ = ai_fam_default;
+       /*
+        * Tokenize the command line.  If nothing on it, return.
+        */
+       tokenize(cmdline, tokens, &ntok);
+       if (ntok == 0)
+           return;
+       
+       /*
+        * Find the appropriate command description.
+        */
+       i = findcmd(tokens[0], builtins, opcmds, &xcmd);
+       if (i == 0) {
+               (void) fprintf(stderr, "***Command `%s' unknown\n",
+                              tokens[0]);
+               return;
+       } else if (i >= 2) {
+               (void) fprintf(stderr, "***Command `%s' ambiguous\n",
+                              tokens[0]);
+               return;
+       }
+       
+       /*
+        * Save the keyword, then walk through the arguments, interpreting
+        * as we go.
+        */
+       pcmd.keyword = tokens[0];
+       pcmd.nargs = 0;
+       ti = 1;
+       for (i = 0; i < MAXARGS && xcmd->arg[i] != NO;) {
+               if ((i+ti) >= ntok) {
+                       if (!(xcmd->arg[i] & OPT)) {
+                               printusage(xcmd, stderr);
+                               return;
+                       }
+                       break;
+               }
+               if ((xcmd->arg[i] & OPT) && (*tokens[i+ti] == '>'))
+                       break;
+               rval = getarg(tokens[i+ti], (int)xcmd->arg[i], &pcmd.argval[i]);
+               if (rval == -1) {
+                       ti++;
+                       continue;
+               }
+               if (rval == 0)
+                       return;
+               pcmd.nargs++;
+               i++;
+       }
+
+       /* Any extra args are assumed to be "OPT|NTP_STR". */
+       for ( ; i < MAXARGS + MOREARGS;) {
+            if ((i+ti) >= ntok)
+                 break;
+               rval = getarg(tokens[i+ti], (int)(OPT|NTP_STR), &pcmd.argval[i]);
+               if (rval == -1) {
+                       ti++;
+                       continue;
+               }
+               if (rval == 0)
+                       return;
+               pcmd.nargs++;
+               i++;
+       }
+
+       i += ti;
+       if (i < ntok && *tokens[i] == '>') {
+               char *fname;
+
+               if (*(tokens[i]+1) != '\0')
+                   fname = tokens[i]+1;
+               else if ((i+1) < ntok)
+                   fname = tokens[i+1];
+               else {
+                       (void) fprintf(stderr, "***No file for redirect\n");
+                       return;
+               }
+
+               current_output = fopen(fname, "w");
+               if (current_output == NULL) {
+                       (void) fprintf(stderr, "***Error opening %s: ", fname);
+                       perror("");
+                       return;
+               }
+       } else {
+               current_output = stdout;
+       }
+
+       if (interactive && setjmp(interrupt_buf)) {
+               return;
+       } else {
+               jump = 1;
+               (xcmd->handler)(&pcmd, current_output);
+               jump = 0;
+               if (current_output != stdout)
+                       (void) fclose(current_output);
+               current_output = NULL;
+       }
+}
+
+
+/*
+ * tokenize - turn a command line into tokens
+ */
+static void
+tokenize(
+       const char *line,
+       char **tokens,
+       int *ntok
+       )
+{
+       register const char *cp;
+       register char *sp;
+       static char tspace[MAXLINE];
+
+       sp = tspace;
+       cp = line;
+       for (*ntok = 0; *ntok < MAXTOKENS; (*ntok)++) {
+               tokens[*ntok] = sp;
+               while (ISSPACE(*cp))
+                   cp++;
+               if (ISEOL(*cp))
+                   break;
+               do {
+                       *sp++ = *cp++;
+               } while (!ISSPACE(*cp) && !ISEOL(*cp));
+
+               *sp++ = '\0';
+       }
+}
+
+
+
+/*
+ * findcmd - find a command in a command description table
+ */
+static int
+findcmd(
+       register char *str,
+       struct xcmd *clist1,
+       struct xcmd *clist2,
+       struct xcmd **cmd
+       )
+{
+       register struct xcmd *cl;
+       register int clen;
+       int nmatch;
+       struct xcmd *nearmatch = NULL;
+       struct xcmd *clist;
+
+       clen = strlen(str);
+       nmatch = 0;
+       if (clist1 != 0)
+           clist = clist1;
+       else if (clist2 != 0)
+           clist = clist2;
+       else
+           return 0;
+
+    again:
+       for (cl = clist; cl->keyword != 0; cl++) {
+               /* do a first character check, for efficiency */
+               if (*str != *(cl->keyword))
+                   continue;
+               if (strncmp(str, cl->keyword, (unsigned)clen) == 0) {
+                       /*
+                        * Could be extact match, could be approximate.
+                        * Is exact if the length of the keyword is the
+                        * same as the str.
+                        */
+                       if (*((cl->keyword) + clen) == '\0') {
+                               *cmd = cl;
+                               return 1;
+                       }
+                       nmatch++;
+                       nearmatch = cl;
+               }
+       }
+
+                               /*
+                                * See if there is more to do.  If so, go again.  Sorry about the
+                                * goto, too much looking at BSD sources...
+                                */
+       if (clist == clist1 && clist2 != 0) {
+               clist = clist2;
+               goto again;
+       }
+
+                               /*
+                                * If we got extactly 1 near match, use it, else return number
+                                * of matches.
+                                */
+       if (nmatch == 1) {
+               *cmd = nearmatch;
+               return 1;
+       }
+       return nmatch;
+}
+
+
+/*
+ * getarg - interpret an argument token
+ *
+ * string is always set.
+ * type is set to the decoded type.
+ *
+ * return:      0 - failure
+ *              1 - success
+ *             -1 - skip to next token
+ */
+static int
+getarg(
+       char *str,
+       int code,
+       arg_v *argp
+       )
+{
+       int isneg;
+       char *cp, *np;
+       static const char *digits = "0123456789";
+
+       memset(argp, 0, sizeof(*argp));
+
+       argp->string = str;
+       argp->type   = code & ~OPT;
+
+       switch (argp->type) {
+           case NTP_STR:
+               break;
+           case NTP_ADD:
+               if (!strcmp("-6", str)) {
+                       ai_fam_templ = AF_INET6;
+                       return -1;
+               } else if (!strcmp("-4", str)) {
+                       ai_fam_templ = AF_INET;
+                       return -1;
+               }
+               if (!getnetnum(str, &(argp->netnum), (char *)0, 0)) {
+                       return 0;
+               }
+               break;
+           case NTP_INT:
+           case NTP_UINT:
+               isneg = 0;
+               np = str;
+               if (*np == '-') {
+                       np++;
+                       isneg = 1;
+               }
+
+               argp->uval = 0;
+               do {
+                       cp = strchr(digits, *np);
+                       if (cp == NULL) {
+                               (void) fprintf(stderr,
+                                              "***Illegal integer value %s\n", str);
+                               return 0;
+                       }
+                       argp->uval *= 10;
+                       argp->uval += (cp - digits);
+               } while (*(++np) != '\0');
+
+               if (isneg) {
+                       if ((code & ~OPT) == NTP_UINT) {
+                               (void) fprintf(stderr,
+                                              "***Value %s should be unsigned\n", str);
+                               return 0;
+                       }
+                       argp->ival = -argp->ival;
+               }
+               break;
+           case IP_VERSION:
+               if (!strcmp("-6", str))
+                       argp->ival = 6 ;
+               else if (!strcmp("-4", str))
+                       argp->ival = 4 ;
+               else {
+                       (void) fprintf(stderr,
+                           "***Version must be either 4 or 6\n");
+                       return 0;
+               }
+               break;
+       }
+
+       return 1;
+}
+
+
+/*
+ * getnetnum - given a host name, return its net number
+ *            and (optional) full name
+ */
+static int
+getnetnum(
+       const char *hname,
+       struct sockaddr_storage *num,
+       char *fullhost,
+       int af
+       )
+{
+       int sockaddr_len;
+       struct addrinfo hints, *ai = NULL;
+
+       sockaddr_len = (af == AF_INET)
+                          ? sizeof(struct sockaddr_in)
+                          : sizeof(struct sockaddr_in6);
+       memset((char *)&hints, 0, sizeof(struct addrinfo));
+       hints.ai_flags = AI_CANONNAME;
+#ifdef AI_ADDRCONFIG
+       hints.ai_flags |= AI_ADDRCONFIG;
+#endif
+       
+       /* decodenetnum only works with addresses */
+       if (decodenetnum(hname, num)) {
+               if (fullhost != 0) {
+                       getnameinfo((struct sockaddr *)num, sockaddr_len, 
+                                   fullhost, sizeof(fullhost), NULL, 0, 
+                                   NI_NUMERICHOST); 
+               }
+               return 1;
+       } else if (getaddrinfo(hname, "ntp", &hints, &ai) == 0) {
+               memmove((char *)num, ai->ai_addr, ai->ai_addrlen);
+               if (fullhost != 0)
+                       (void) strcpy(fullhost, ai->ai_canonname);
+               return 1;
+       } else {
+               (void) fprintf(stderr, "***Can't find host %s\n", hname);
+               return 0;
+       }
+       /*NOTREACHED*/
+}
+
+/*
+ * nntohost - convert network number to host name.  This routine enforces
+ *            the showhostnames setting.
+ */
+char *
+nntohost(
+       struct sockaddr_storage *netnum
+       )
+{
+       if (!showhostnames)
+           return stoa(netnum);
+
+       if ((netnum->ss_family == AF_INET) && ISREFCLOCKADR(netnum))
+               return refnumtoa(netnum);
+       return socktohost(netnum);
+}
+
+
+/*
+ * Finally, the built in command handlers
+ */
+
+/*
+ * help - tell about commands, or details of a particular command
+ */
+static void
+help(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct xcmd *xcp;
+       char *cmd;
+       const char *list[100];
+       int word, words;     
+        int row, rows;
+       int col, cols;
+
+       if (pcmd->nargs == 0) {
+               words = 0;
+               for (xcp = builtins; xcp->keyword != 0; xcp++) {
+                       if (*(xcp->keyword) != '?')
+                           list[words++] = xcp->keyword;
+               }
+                for (xcp = opcmds; xcp->keyword != 0; xcp++)
+                   list[words++] = xcp->keyword;
+
+               qsort(
+#ifdef QSORT_USES_VOID_P
+                   (void *)
+#else
+                   (char *)
+#endif
+                       (list), (size_t)(words), sizeof(char *), helpsort);
+               col = 0;
+               for (word = 0; word < words; word++) {
+                       int length = strlen(list[word]);
+                       if (col < length) {
+                           col = length;
+                        }
+               }
+
+               cols = SCREENWIDTH / ++col;
+                rows = (words + cols - 1) / cols;
+
+               (void) fprintf(fp, "ntpdc commands:\n");
+
+               for (row = 0; row < rows; row++) {
+                        for (word = row; word < words; word += rows) {
+                               (void) fprintf(fp, "%-*.*s", col, col-1, list[word]);
+                        }
+                       (void) fprintf(fp, "\n");
+               }
+       } else {
+               cmd = pcmd->argval[0].string;
+               words = findcmd(cmd, builtins, opcmds, &xcp);
+               if (words == 0) {
+                       (void) fprintf(stderr,
+                                      "Command `%s' is unknown\n", cmd);
+                       return;
+               } else if (words >= 2) {
+                       (void) fprintf(stderr,
+                                      "Command `%s' is ambiguous\n", cmd);
+                       return;
+               }
+               (void) fprintf(fp, "function: %s\n", xcp->comment);
+               printusage(xcp, fp);
+       }
+}
+
+
+/*
+ * helpsort - do hostname qsort comparisons
+ */
+#ifdef QSORT_USES_VOID_P
+static int
+helpsort(
+       const void *t1,
+       const void *t2
+       )
+{
+       char const * const * name1 = (char const * const *)t1;
+       char const * const * name2 = (char const * const *)t2;
+
+       return strcmp(*name1, *name2);
+}
+#else
+static int
+helpsort(
+       char **name1,
+       char **name2
+       )
+{
+       return strcmp(*name1, *name2);
+}
+#endif
+
+
+/*
+ * printusage - print usage information for a command
+ */
+static void
+printusage(
+       struct xcmd *xcp,
+       FILE *fp
+       )
+{
+       int i, opt46;
+
+       opt46 = 0;
+       (void) fprintf(fp, "usage: %s", xcp->keyword);
+       for (i = 0; i < MAXARGS && xcp->arg[i] != NO; i++) {
+               if (opt46 == 0 && (xcp->arg[i] & ~OPT) == NTP_ADD) {
+                       (void) fprintf(fp, " [ -4|-6 ]");
+                       opt46 = 1;
+               }
+               if (xcp->arg[i] & OPT)
+                   (void) fprintf(fp, " [ %s ]", xcp->desc[i]);
+               else
+                   (void) fprintf(fp, " %s", xcp->desc[i]);
+       }
+       (void) fprintf(fp, "\n");
+}
+
+
+/*
+ * timeout - set time out time
+ */
+static void
+timeout(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int val;
+
+       if (pcmd->nargs == 0) {
+               val = tvout.tv_sec * 1000 + tvout.tv_usec / 1000;
+               (void) fprintf(fp, "primary timeout %d ms\n", val);
+       } else {
+               tvout.tv_sec = pcmd->argval[0].uval / 1000;
+               tvout.tv_usec = (pcmd->argval[0].uval - (tvout.tv_sec * 1000))
+                       * 1000;
+       }
+}
+
+
+/*
+ * my_delay - set delay for auth requests
+ */
+static void
+my_delay(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int isneg;
+       u_long val;
+
+       if (pcmd->nargs == 0) {
+               val = delay_time.l_ui * 1000 + delay_time.l_uf / 4294967;
+               (void) fprintf(fp, "delay %lu ms\n", val);
+       } else {
+               if (pcmd->argval[0].ival < 0) {
+                       isneg = 1;
+                       val = (u_long)(-pcmd->argval[0].ival);
+               } else {
+                       isneg = 0;
+                       val = (u_long)pcmd->argval[0].ival;
+               }
+
+               delay_time.l_ui = val / 1000;
+               val %= 1000;
+               delay_time.l_uf = val * 4294967;        /* 2**32/1000 */
+
+               if (isneg)
+                   L_NEG(&delay_time);
+       }
+}
+
+
+/*
+ * host - set the host we are dealing with.
+ */
+static void
+host(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int i;
+
+       if (pcmd->nargs == 0) {
+               if (havehost)
+                   (void) fprintf(fp, "current host is %s\n", currenthost);
+               else
+                   (void) fprintf(fp, "no current host\n");
+               return;
+       }
+
+       i = 0;
+       if (pcmd->nargs == 2) {
+               if (!strcmp("-4", pcmd->argval[i].string))
+                       ai_fam_templ = AF_INET;
+               else if (!strcmp("-6", pcmd->argval[i].string))
+                       ai_fam_templ = AF_INET6;
+               else {
+                       if (havehost)
+                               (void) fprintf(fp,
+                                   "current host remains %s\n", currenthost);
+                       else
+                               (void) fprintf(fp, "still no current host\n");
+                       return;
+               }
+               i = 1;
+       }
+       if (openhost(pcmd->argval[i].string)) {
+               (void) fprintf(fp, "current host set to %s\n", currenthost);
+       } else {
+               if (havehost)
+                   (void) fprintf(fp,
+                                  "current host remains %s\n", currenthost);
+               else
+                   (void) fprintf(fp, "still no current host\n");
+       }
+}
+
+
+/*
+ * keyid - get a keyid to use for authenticating requests
+ */
+static void
+keyid(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0) {
+               if (info_auth_keyid == 0 && !keyid_entered)
+                   (void) fprintf(fp, "no keyid defined\n");
+               else if (info_auth_keyid == 0 && keyid_entered)
+                   (void) fprintf(fp, "no keyid will be sent\n");
+               else
+                   (void) fprintf(fp, "keyid is %lu\n", (u_long)info_auth_keyid);
+       } else {
+               info_auth_keyid = pcmd->argval[0].uval;
+               keyid_entered = 1;
+       }
+}
+
+
+/*
+ * keytype - get type of key to use for authenticating requests
+ */
+static void
+keytype(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0)
+           fprintf(fp, "keytype is %s\n",
+                   (info_auth_keytype == KEY_TYPE_MD5) ? "MD5" : "???");
+       else
+           switch (*(pcmd->argval[0].string)) {
+               case 'm':
+               case 'M':
+                   info_auth_keytype = KEY_TYPE_MD5;
+                   break;
+
+               default:
+                   fprintf(fp, "keytype must be 'md5'\n");
+           }
+}
+
+
+
+/*
+ * passwd - get an authentication key
+ */
+/*ARGSUSED*/
+static void
+passwd(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       char *pass;
+
+       if (info_auth_keyid == 0) {
+               info_auth_keyid = getkeyid("Keyid: ");
+               if (info_auth_keyid == 0) {
+                       (void)fprintf(fp, "Keyid must be defined\n");
+                       return;
+               }
+       }
+       if (!interactive) {
+               authusekey(info_auth_keyid, info_auth_keytype,
+                          (u_char *)pcmd->argval[0].string);
+               authtrust(info_auth_keyid, 1);
+       } else {
+               pass = getpass("MD5 Password: ");
+               if (*pass == '\0')
+                   (void) fprintf(fp, "Password unchanged\n");
+               else {
+                   authusekey(info_auth_keyid, info_auth_keytype,
+                              (u_char *)pass);
+                   authtrust(info_auth_keyid, 1);
+               }
+       }
+}
+
+
+/*
+ * hostnames - set the showhostnames flag
+ */
+static void
+hostnames(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0) {
+               if (showhostnames)
+                   (void) fprintf(fp, "hostnames being shown\n");
+               else
+                   (void) fprintf(fp, "hostnames not being shown\n");
+       } else {
+               if (STREQ(pcmd->argval[0].string, "yes"))
+                   showhostnames = 1;
+               else if (STREQ(pcmd->argval[0].string, "no"))
+                   showhostnames = 0;
+               else
+                   (void)fprintf(stderr, "What?\n");
+       }
+}
+
+
+/*
+ * setdebug - set/change debugging level
+ */
+static void
+setdebug(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0) {
+               (void) fprintf(fp, "debug level is %d\n", debug);
+               return;
+       } else if (STREQ(pcmd->argval[0].string, "no")) {
+               debug = 0;
+       } else if (STREQ(pcmd->argval[0].string, "more")) {
+               debug++;
+       } else if (STREQ(pcmd->argval[0].string, "less")) {
+               debug--;
+       } else {
+               (void) fprintf(fp, "What?\n");
+               return;
+       }
+       (void) fprintf(fp, "debug level set to %d\n", debug);
+}
+
+
+/*
+ * quit - stop this nonsense
+ */
+/*ARGSUSED*/
+static void
+quit(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (havehost)
+           closesocket(sockfd);
+       exit(0);
+}
+
+
+/*
+ * version - print the current version number
+ */
+/*ARGSUSED*/
+static void
+version(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+
+       (void) fprintf(fp, "%s\n", Version);
+       return;
+}
+
+
+/*
+ * warning - print a warning message
+ */
+static void
+warning(
+       const char *fmt,
+       const char *st1,
+       const char *st2
+       )
+{
+       (void) fprintf(stderr, "%s: ", progname);
+       (void) fprintf(stderr, fmt, st1, st2);
+       (void) fprintf(stderr, ": ");
+       perror("");
+}
+
+
+/*
+ * error - print a message and exit
+ */
+static void
+error(
+       const char *fmt,
+       const char *st1,
+       const char *st2
+       )
+{
+       warning(fmt, st1, st2);
+       exit(1);
+}
+
+/*
+ * getkeyid - prompt the user for a keyid to use
+ */
+static u_long
+getkeyid(
+       const char *keyprompt
+       )
+{
+       register char *p;
+       register int c;
+       FILE *fi;
+       char pbuf[20];
+
+#ifndef SYS_WINNT
+       if ((fi = fdopen(open("/dev/tty", 2), "r")) == NULL)
+#else
+           if ((fi = _fdopen((int)GetStdHandle(STD_INPUT_HANDLE), "r")) == NULL)
+#endif /* SYS_WINNT */
+               fi = stdin;
+           else
+               setbuf(fi, (char *)NULL);
+       fprintf(stderr, "%s", keyprompt); fflush(stderr);
+       for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
+               if (p < &pbuf[18])
+                   *p++ = (char) c;
+       }
+       *p = '\0';
+       if (fi != stdin)
+           fclose(fi);
+       return (u_int32)atoi(pbuf);
+}
diff --git a/ntpdc/ntpdc.h b/ntpdc/ntpdc.h
new file mode 100644 (file)
index 0000000..785c312
--- /dev/null
@@ -0,0 +1,67 @@
+/*
+ * ntpdc.h - definitions of interest to ntpdc
+ */
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntp_request.h"
+#include "ntp_string.h"
+#include "ntp_malloc.h"
+
+/*
+ * Maximum number of arguments
+ */
+#define        MAXARGS 4
+#define        MOREARGS 10
+
+/*
+ * Flags for forming descriptors.
+ */
+#define        OPT             0x80    /* this argument is optional, or'd with type */
+
+#define        NO              0x0
+#define        NTP_STR         0x1     /* string argument */
+#define        NTP_UINT        0x2     /* unsigned integer */
+#define        NTP_INT         0x3     /* signed integer */
+#define        NTP_ADD         0x4     /* IP network address */
+#define IP_VERSION     0x5     /* IP version */
+
+/*
+ * Arguments are returned in a struct - no
+ * union space saving is attempted. 
+ */
+typedef struct {
+       u_char type;
+       char *string;
+       long ival;
+       u_long uval;
+       struct sockaddr_storage netnum;
+} arg_v;
+
+/*
+ * Structure for passing parsed command line
+ */
+struct parse {
+       char *keyword;
+       arg_v argval[MAXARGS + MOREARGS];
+       int nargs;
+};
+
+/*
+ * ntpdc includes a command parser which could charitably be called
+ * crude.  The following structure is used to define the command
+ * syntax.
+ */
+struct xcmd {
+  const char *keyword;         /* command key word */
+       void (*handler) P((struct parse *, FILE *));    /* command handler */
+       u_char arg[MAXARGS];    /* descriptors for arguments */
+  const char *desc[MAXARGS];   /* descriptions for arguments */
+  const char *comment;
+};
+
+extern int impl_ver;
+extern int showhostnames;
+extern int s_port;
+
+extern int     doquery P((int, int, int, int, int, char *, int *, int *, char **, int, int));
+extern char *  nntohost        P((struct sockaddr_storage *));
diff --git a/ntpdc/ntpdc_ops.c b/ntpdc/ntpdc_ops.c
new file mode 100644 (file)
index 0000000..e40016b
--- /dev/null
@@ -0,0 +1,3204 @@
+/*
+ * ntpdc_ops.c - subroutines which are called to perform operations by xntpdc
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <stddef.h>
+
+#include "ntpdc.h"
+#include "ntp_control.h"
+#include "ntp_refclock.h"
+#include "ntp_stdlib.h"
+
+#include <ctype.h>
+#ifdef HAVE_SYS_TIMEX_H
+# include <sys/timex.h>
+#endif
+#if !defined(__bsdi__) && !defined(apollo)
+#include <netinet/in.h>
+#endif
+
+#include <arpa/inet.h>
+
+/*
+ * Declarations for command handlers in here
+ */
+static int     checkitems      P((int, FILE *));
+static int     checkitemsize   P((int, int));
+static int     check1item      P((int, FILE *));
+static void    peerlist        P((struct parse *, FILE *));
+static void    peers           P((struct parse *, FILE *));
+static void    doconfig        P((struct parse *pcmd, FILE *fp, int mode, int refc));
+static void    dmpeers         P((struct parse *, FILE *));
+static void    dopeers         P((struct parse *, FILE *, int));
+static void    printpeer       P((struct info_peer *, FILE *));
+static void    showpeer        P((struct parse *, FILE *));
+static void    peerstats       P((struct parse *, FILE *));
+static void    loopinfo        P((struct parse *, FILE *));
+static void    sysinfo         P((struct parse *, FILE *));
+static void    sysstats        P((struct parse *, FILE *));
+static void    iostats         P((struct parse *, FILE *));
+static void    memstats        P((struct parse *, FILE *));
+static void    timerstats      P((struct parse *, FILE *));
+static void    addpeer         P((struct parse *, FILE *));
+static void    addserver       P((struct parse *, FILE *));
+static void    addrefclock     P((struct parse *, FILE *));
+static void    broadcast       P((struct parse *, FILE *));
+static void    doconfig        P((struct parse *, FILE *, int, int));
+static void    unconfig        P((struct parse *, FILE *));
+static void    set             P((struct parse *, FILE *));
+static void    sys_clear       P((struct parse *, FILE *));
+static void    doset           P((struct parse *, FILE *, int));
+static void    reslist         P((struct parse *, FILE *));
+static void    new_restrict    P((struct parse *, FILE *));
+static void    unrestrict      P((struct parse *, FILE *));
+static void    delrestrict     P((struct parse *, FILE *));
+static void    do_restrict     P((struct parse *, FILE *, int));
+static void    monlist         P((struct parse *, FILE *));
+static void    reset           P((struct parse *, FILE *));
+static void    preset          P((struct parse *, FILE *));
+static void    readkeys        P((struct parse *, FILE *));
+static void    trustkey        P((struct parse *, FILE *));
+static void    untrustkey      P((struct parse *, FILE *));
+static void    do_trustkey     P((struct parse *, FILE *, int));
+static void    authinfo        P((struct parse *, FILE *));
+static void    traps           P((struct parse *, FILE *));
+static void    addtrap         P((struct parse *, FILE *));
+static void    clrtrap         P((struct parse *, FILE *));
+static void    do_addclr_trap  P((struct parse *, FILE *, int));
+static void    requestkey      P((struct parse *, FILE *));
+static void    controlkey      P((struct parse *, FILE *));
+static void    do_changekey    P((struct parse *, FILE *, int));
+static void    ctlstats        P((struct parse *, FILE *));
+static void    clockstat       P((struct parse *, FILE *));
+static void    fudge           P((struct parse *, FILE *));
+static void    clkbug          P((struct parse *, FILE *));
+static void    kerninfo        P((struct parse *, FILE *));
+static  void    get_if_stats    P((struct parse *, FILE *));
+static  void    do_if_reload    P((struct parse *, FILE *));
+
+/*
+ * Commands we understand.  Ntpdc imports this.
+ */
+struct xcmd opcmds[] = {
+       { "listpeers",  peerlist,       { OPT|IP_VERSION, NO, NO, NO },
+         { "-4|-6", "", "", "" },
+         "display list of peers the server knows about [IP Version]" },
+       { "peers",      peers,  { OPT|IP_VERSION, NO, NO, NO },
+         { "-4|-6", "", "", "" },
+         "display peer summary information [IP Version]" },
+       { "dmpeers",    dmpeers,        { OPT|IP_VERSION, NO, NO, NO },
+         { "-4|-6", "", "", "" },
+         "display peer summary info the way Dave Mills likes it (IP Version)" },
+       { "showpeer",   showpeer,       { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD},
+         { "peer_address", "peer2_addr", "peer3_addr", "peer4_addr" },
+         "display detailed information for one or more peers" },
+       { "pstats",     peerstats,      { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD },
+         { "peer_address", "peer2_addr", "peer3_addr", "peer4_addr" },
+         "display statistical information for one or more peers" },
+       { "loopinfo",   loopinfo,       { OPT|NTP_STR, NO, NO, NO },
+         { "oneline|multiline", "", "", "" },
+         "display loop filter information" },
+       { "sysinfo",    sysinfo,        { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "display local server information" },
+       { "sysstats",   sysstats,       { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "display local server statistics" },
+       { "memstats",   memstats,       { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "display peer memory usage statistics" },
+       { "iostats",    iostats,        { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "display I/O subsystem statistics" },
+       { "timerstats", timerstats,     { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "display event timer subsystem statistics" },
+       { "addpeer",    addpeer,        { NTP_ADD, OPT|NTP_STR, OPT|NTP_STR, OPT|NTP_STR },
+         { "addr", "keyid", "version", "minpoll#|prefer|burst|iburst|'minpoll N'|'maxpoll N'|'keyid N'|'version N' ..." },
+         "configure a new peer association" },
+       { "addserver",  addserver,      { NTP_ADD, OPT|NTP_STR, OPT|NTP_STR, OPT|NTP_STR },
+         { "addr", "keyid", "version", "minpoll#|prefer|burst|iburst|'minpoll N'|'maxpoll N'|'keyid N'|'version N' ..." },
+         "configure a new server" },
+       { "addrefclock",addrefclock,    { NTP_ADD, OPT|NTP_UINT, OPT|NTP_STR, OPT|NTP_STR },
+         { "addr", "mode", "minpoll|prefer", "minpoll|prefer" },
+         "configure a new server" },
+       { "broadcast",  broadcast,      { NTP_ADD, OPT|NTP_STR, OPT|NTP_STR, OPT|NTP_STR },
+         { "addr", "keyid", "version", "minpoll" },
+         "configure broadcasting time service" },
+       { "unconfig",   unconfig,       { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD },
+         { "peer_address", "peer2_addr", "peer3_addr", "peer4_addr" },
+         "unconfigure existing peer assocations" },
+       { "enable",     set,            { NTP_STR, OPT|NTP_STR, OPT|NTP_STR, OPT|NTP_STR },
+         { "auth|bclient|monitor|pll|kernel|stats", "...", "...", "..." },
+         "set a system flag (auth, bclient, monitor, pll, kernel, stats)" },
+        { "disable",   sys_clear,      { NTP_STR, OPT|NTP_STR, OPT|NTP_STR, OPT|NTP_STR },
+         { "auth|bclient|monitor|pll|kernel|stats", "...", "...", "..." },
+         "clear a system flag (auth, bclient, monitor, pll, kernel, stats)" },
+       { "reslist",    reslist,        {OPT|IP_VERSION, NO, NO, NO },
+         { "-4|-6", "", "", "" },
+         "display the server's restrict list" },
+       { "restrict",   new_restrict,   { NTP_ADD, NTP_ADD, NTP_STR, OPT|NTP_STR },
+         { "address", "mask",
+           "ntpport|ignore|noserve|notrust|noquery|nomodify|nopeer|version|kod",
+           "..." },
+         "create restrict entry/add flags to entry" },
+       { "unrestrict", unrestrict,     { NTP_ADD, NTP_ADD, NTP_STR, OPT|NTP_STR },
+         { "address", "mask",
+           "ntpport|ignore|noserve|notrust|noquery|nomodify|nopeer|version|kod",
+           "..." },
+         "remove flags from a restrict entry" },
+       { "delrestrict", delrestrict,   { NTP_ADD, NTP_ADD, OPT|NTP_STR, NO },
+         { "address", "mask", "ntpport", "" },
+         "delete a restrict entry" },
+       { "monlist",    monlist,        { OPT|NTP_INT, NO, NO, NO },
+         { "version", "", "", "" },
+         "display data the server's monitor routines have collected" },
+       { "reset",      reset,          { NTP_STR, OPT|NTP_STR, OPT|NTP_STR, OPT|NTP_STR },
+         { "io|sys|mem|timer|auth|allpeers", "...", "...", "..." },
+         "reset various subsystem statistics counters" },
+       { "preset",     preset,         { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD },
+         { "peer_address", "peer2_addr", "peer3_addr", "peer4_addr" },
+         "reset stat counters associated with particular peer(s)" },
+       { "readkeys",   readkeys,       { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "request a reread of the keys file and re-init of system keys" },
+       { "trustedkey", trustkey,       { NTP_UINT, OPT|NTP_UINT, OPT|NTP_UINT, OPT|NTP_UINT },
+         { "keyid", "keyid", "keyid", "keyid" },
+         "add one or more key ID's to the trusted list" },
+       { "untrustedkey", untrustkey,   { NTP_UINT, OPT|NTP_UINT, OPT|NTP_UINT, OPT|NTP_UINT },
+         { "keyid", "keyid", "keyid", "keyid" },
+         "remove one or more key ID's from the trusted list" },
+       { "authinfo",   authinfo,       { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "display the state of the authentication code" },
+       { "traps",      traps,          { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "display the traps set in the server" },
+       { "addtrap",    addtrap,        { NTP_ADD, OPT|NTP_UINT, OPT|NTP_ADD, NO },
+         { "address", "port", "interface", "" },
+         "configure a trap in the server" },
+       { "clrtrap",    clrtrap,        { NTP_ADD, OPT|NTP_UINT, OPT|NTP_ADD, NO },
+         { "address", "port", "interface", "" },
+         "remove a trap (configured or otherwise) from the server" },
+       { "requestkey", requestkey,     { NTP_UINT, NO, NO, NO },
+         { "keyid", "", "", "" },
+         "change the keyid the server uses to authenticate requests" },
+       { "controlkey", controlkey,     { NTP_UINT, NO, NO, NO },
+         { "keyid", "", "", "" },
+         "change the keyid the server uses to authenticate control messages" },
+       { "ctlstats",   ctlstats,       { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "display packet count statistics from the control module" },
+       { "clockstat",  clockstat,      { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD },
+         { "address", "address", "address", "address" },
+         "display clock status information" },
+       { "fudge",      fudge,          { NTP_ADD, NTP_STR, NTP_STR, NO },
+         { "address", "time1|time2|val1|val2|flags", "value", "" },
+         "set/change one of a clock's fudge factors" },
+       { "clkbug",     clkbug,         { NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD, OPT|NTP_ADD },
+         { "address", "address", "address", "address" },
+         "display clock debugging information" },
+       { "kerninfo",   kerninfo,       { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "display the kernel pll/pps variables" },
+       { "ifstats",    get_if_stats,   { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "list interface statistics" },
+       { "ifreload",   do_if_reload,   { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "reload interface configuration" },
+       { 0,            0,              { NO, NO, NO, NO },
+         { "", "", "", "" }, "" }
+};
+
+/*
+ * For quick string comparisons
+ */
+#define        STREQ(a, b)     (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+
+/*
+ * checkitems - utility to print a message if no items were returned
+ */
+static int
+checkitems(
+       int items,
+       FILE *fp
+       )
+{
+       if (items == 0) {
+               (void) fprintf(fp, "No data returned in response to query\n");
+               return 0;
+       }
+       return 1;
+}
+
+
+/*
+ * checkitemsize - utility to print a message if the item size is wrong
+ */
+static int
+checkitemsize(
+       int itemsize,
+       int expected
+       )
+{
+       if (itemsize != expected) {
+               (void) fprintf(stderr,
+                              "***Incorrect item size returned by remote host (%d should be %d)\n",
+                              itemsize, expected);
+               return 0;
+       }
+       return 1;
+}
+
+
+/*
+ * check1item - check to make sure we have exactly one item
+ */
+static int
+check1item(
+       int items,
+       FILE *fp
+       )
+{
+       if (items == 0) {
+               (void) fprintf(fp, "No data returned in response to query\n");
+               return 0;
+       }
+       if (items > 1) {
+               (void) fprintf(fp, "Expected one item in response, got %d\n",
+                              items);
+               return 0;
+       }
+       return 1;
+}
+
+
+
+/*
+ * peerlist - get a short list of peers
+ */
+/*ARGSUSED*/
+static void
+peerlist(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_peer_list *plist;
+       struct sockaddr_storage paddr;
+       int items;
+       int itemsize;
+       int res;
+
+again:
+       res = doquery(impl_ver, REQ_PEER_LIST, 0, 0, 0, (char *)NULL, &items,
+                     &itemsize, (void *)&plist, 0, 
+                     sizeof(struct info_peer_list));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!checkitems(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_peer_list)) &&
+           !checkitemsize(itemsize, v4sizeof(struct info_peer_list)))
+           return;
+
+       while (items > 0) {
+               memset((char *)&paddr, 0, sizeof(paddr));
+               if (plist->v6_flag != 0) {
+                       GET_INADDR6(paddr) = plist->addr6;
+                       paddr.ss_family = AF_INET6;
+               } else {
+                       GET_INADDR(paddr) = plist->addr;
+                       paddr.ss_family = AF_INET;
+               }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               paddr.ss_len = SOCKLEN(&paddr);
+#endif
+               if ((pcmd->nargs == 0) ||
+                   ((pcmd->argval->ival == 6) && (plist->v6_flag != 0)) ||
+                   ((pcmd->argval->ival == 4) && (plist->v6_flag == 0)))
+                       (void) fprintf(fp, "%-9s %s\n",
+                               modetoa(plist->hmode),
+                               nntohost(&paddr));
+               plist++;
+               items--;
+       }
+}
+
+
+/*
+ * peers - show peer summary
+ */
+static void
+peers(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       dopeers(pcmd, fp, 0);
+}
+
+/*
+ * dmpeers - show peer summary, Dave Mills style
+ */
+static void
+dmpeers(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       dopeers(pcmd, fp, 1);
+}
+
+
+/*
+ * peers - show peer summary
+ */
+/*ARGSUSED*/
+static void
+dopeers(
+       struct parse *pcmd,
+       FILE *fp,
+       int dmstyle
+       )
+{
+       struct info_peer_summary *plist;
+       struct sockaddr_storage dstadr;
+       struct sockaddr_storage srcadr;
+       int items;
+       int itemsize;
+       int ntp_poll;
+       int res;
+       int c;
+       l_fp tempts;
+
+again:
+       res = doquery(impl_ver, REQ_PEER_LIST_SUM, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&plist, 0, 
+                     sizeof(struct info_peer_summary));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!checkitems(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_peer_summary)) &&
+           !checkitemsize(itemsize, v4sizeof(struct info_peer_summary)))
+               return;
+
+       (void) fprintf(fp,
+                      "     remote           local      st poll reach  delay   offset    disp\n");
+       (void) fprintf(fp,
+                      "=======================================================================\n");
+       while (items > 0) {
+               if (!dmstyle) {
+                       if (plist->flags & INFO_FLAG_SYSPEER)
+                           c = '*';
+                       else if (plist->hmode == MODE_ACTIVE)
+                           c = '+';
+                       else if (plist->hmode == MODE_PASSIVE)
+                           c = '-';
+                       else if (plist->hmode == MODE_CLIENT)
+                           c = '=';
+                       else if (plist->hmode == MODE_BROADCAST)
+                           c = '^';
+                       else if (plist->hmode == MODE_BCLIENT)
+                           c = '~';
+                       else
+                           c = ' ';
+               } else {
+                       if (plist->flags & INFO_FLAG_SYSPEER)
+                           c = '*';
+                       else if (plist->flags & INFO_FLAG_SHORTLIST)
+                           c = '+';
+                       else if (plist->flags & INFO_FLAG_SEL_CANDIDATE)
+                           c = '.';
+                       else
+                           c = ' ';
+               }
+               NTOHL_FP(&(plist->offset), &tempts);
+               ntp_poll = 1<<max(min3(plist->ppoll, plist->hpoll, NTP_MAXPOLL),
+                                 NTP_MINPOLL);
+               memset((char *)&dstadr, 0, sizeof(dstadr));
+               memset((char *)&srcadr, 0, sizeof(srcadr));
+               if (plist->v6_flag != 0) {
+                       GET_INADDR6(dstadr) = plist->dstadr6;
+                       GET_INADDR6(srcadr) = plist->srcadr6;
+                       srcadr.ss_family = AF_INET6;
+                       dstadr.ss_family = AF_INET6;
+               } else {
+                       GET_INADDR(dstadr) = plist->dstadr;
+                       GET_INADDR(srcadr) = plist->srcadr;
+                       srcadr.ss_family = AF_INET;
+                       dstadr.ss_family = AF_INET;
+               }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               srcadr.ss_len = SOCKLEN(&srcadr);
+               dstadr.ss_len = SOCKLEN(&dstadr);
+#endif
+               if ((pcmd->nargs == 0) ||
+                   ((pcmd->argval->ival == 6) && (plist->v6_flag != 0)) ||
+                   ((pcmd->argval->ival == 4) && (plist->v6_flag == 0)))
+                       (void) fprintf(fp,
+                           "%c%-15.15s %-15.15s %2d %4d  %3o %7.7s %9.9s %7.7s\n",
+                           c, nntohost(&srcadr), stoa(&dstadr),
+                           plist->stratum, ntp_poll, plist->reach,
+                           fptoa(NTOHS_FP(plist->delay), 5),
+                           lfptoa(&tempts, 6),
+                           ufptoa(NTOHS_FP(plist->dispersion), 5));
+               plist++;
+               items--;
+       }
+}
+
+/* Convert a refid & stratum (in host order) to a string */
+static char*
+refid_string(
+       u_int32 refid,
+       int stratum
+       )
+{
+       if (stratum <= 1) {
+               static char junk[5];
+               junk[4] = 0;
+               memmove(junk, (char *)&refid, 4);
+               return junk;
+       }
+
+       return numtoa(refid);
+}
+
+static void
+print_pflag(
+           FILE *fp,
+           u_int32 flags
+           )
+{
+     const char *str;
+
+     if (flags == 0) {
+               (void) fprintf(fp, " none\n");
+       } else {
+               str = "";
+               if (flags & INFO_FLAG_SYSPEER) {
+                       (void) fprintf(fp, " system_peer");
+                       str = ",";
+               }
+               if (flags & INFO_FLAG_CONFIG) {
+                       (void) fprintf(fp, "%s config", str);
+                       str = ",";
+               }
+               if (flags & INFO_FLAG_REFCLOCK) {
+                       (void) fprintf(fp, "%s refclock", str);
+                       str = ",";
+               }
+               if (flags & INFO_FLAG_AUTHENABLE) {
+                       (void) fprintf(fp, "%s auth", str);
+                       str = ",";
+               }
+               if (flags & INFO_FLAG_BCLIENT) {
+                       (void) fprintf(fp, "%s bclient", str);
+                       str = ",";
+               }
+               if (flags & INFO_FLAG_PREFER) {
+                       (void) fprintf(fp, "%s prefer", str);
+                       str = ",";
+               }
+               if (flags & INFO_FLAG_IBURST) {
+                       (void) fprintf(fp, "%s iburst", str);
+                       str = ",";
+               }
+               if (flags & INFO_FLAG_BURST) {
+                       (void) fprintf(fp, "%s burst", str);
+               }
+               (void) fprintf(fp, "\n");
+       }
+}
+/*
+ * printpeer - print detail information for a peer
+ */
+static void
+printpeer(
+       register struct info_peer *pp,
+       FILE *fp
+       )
+{
+       register int i;
+       l_fp tempts;
+       struct sockaddr_storage srcadr, dstadr;
+       
+       memset((char *)&srcadr, 0, sizeof(srcadr));
+       memset((char *)&dstadr, 0, sizeof(dstadr));
+       if (pp->v6_flag != 0) {
+               srcadr.ss_family = AF_INET6;
+               dstadr.ss_family = AF_INET6;
+               GET_INADDR6(srcadr) = pp->srcadr6;
+               GET_INADDR6(dstadr) = pp->dstadr6;
+       } else {
+               srcadr.ss_family = AF_INET;
+               dstadr.ss_family = AF_INET;
+               GET_INADDR(srcadr) = pp->srcadr;
+               GET_INADDR(dstadr) = pp->dstadr;
+       }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+       srcadr.ss_len = SOCKLEN(&srcadr);
+       dstadr.ss_len = SOCKLEN(&dstadr);
+#endif
+       (void) fprintf(fp, "remote %s, local %s\n",
+                      stoa(&srcadr), stoa(&dstadr));
+       (void) fprintf(fp, "hmode %s, pmode %s, stratum %d, precision %d\n",
+                      modetoa(pp->hmode), modetoa(pp->pmode),
+                      pp->stratum, pp->precision);
+       
+       (void) fprintf(fp,
+                      "leap %c%c, refid [%s], rootdistance %s, rootdispersion %s\n",
+                      pp->leap & 0x2 ? '1' : '0',
+                      pp->leap & 0x1 ? '1' : '0',
+                      refid_string(pp->refid, pp->stratum), fptoa(NTOHS_FP(pp->rootdelay), 5),
+                      ufptoa(NTOHS_FP(pp->rootdispersion), 5));
+       
+       (void) fprintf(fp,
+                      "ppoll %d, hpoll %d, keyid %lu, version %d, association %u\n",
+                      pp->ppoll, pp->hpoll, (u_long)pp->keyid, pp->version, ntohs(pp->associd));
+
+       (void) fprintf(fp,
+                      "reach %03o, unreach %d, flash 0x%04x, ",
+                      pp->reach, pp->unreach, pp->flash2);
+
+       (void) fprintf(fp, "boffset %s, ttl/mode %d\n",
+                      fptoa(NTOHS_FP(pp->estbdelay), 5), pp->ttl);
+       
+       (void) fprintf(fp, "timer %lds, flags", (long)ntohl(pp->timer));
+       print_pflag(fp, pp->flags); 
+
+       NTOHL_FP(&pp->reftime, &tempts);
+       (void) fprintf(fp, "reference time:      %s\n",
+                      prettydate(&tempts));
+       NTOHL_FP(&pp->org, &tempts);
+       (void) fprintf(fp, "originate timestamp: %s\n",
+                      prettydate(&tempts));
+       NTOHL_FP(&pp->rec, &tempts);
+       (void) fprintf(fp, "receive timestamp:   %s\n",
+                      prettydate(&tempts));
+       NTOHL_FP(&pp->xmt, &tempts);
+       (void) fprintf(fp, "transmit timestamp:  %s\n",
+                      prettydate(&tempts));
+       
+       (void) fprintf(fp, "filter delay: ");
+       for (i = 0; i < NTP_SHIFT; i++) {
+               (void) fprintf(fp, " %-8.8s",
+                              fptoa(NTOHS_FP(pp->filtdelay[i]), 5));
+               if (i == (NTP_SHIFT>>1)-1)
+                   (void) fprintf(fp, "\n              ");
+       }
+       (void) fprintf(fp, "\n");
+
+       (void) fprintf(fp, "filter offset:");
+       for (i = 0; i < NTP_SHIFT; i++) {
+               NTOHL_FP(&pp->filtoffset[i], &tempts);
+               (void) fprintf(fp, " %-8.8s", lfptoa(&tempts, 6));
+               if (i == (NTP_SHIFT>>1)-1)
+                   (void) fprintf(fp, "\n              ");
+       }
+       (void) fprintf(fp, "\n");
+
+       (void) fprintf(fp, "filter order: ");
+       for (i = 0; i < NTP_SHIFT; i++) {
+               (void) fprintf(fp, " %-8d", pp->order[i]);
+               if (i == (NTP_SHIFT>>1)-1)
+                   (void) fprintf(fp, "\n              ");
+       }
+       (void) fprintf(fp, "\n");
+       
+
+       NTOHL_FP(&pp->offset, &tempts);
+       (void) fprintf(fp,
+                      "offset %s, delay %s, error bound %s, filter error %s\n",
+                      lfptoa(&tempts, 6), fptoa(NTOHS_FP(pp->delay), 5),
+                      ufptoa(NTOHS_FP(pp->dispersion), 5),
+                      ufptoa(NTOHS_FP(pp->selectdisp), 5));
+}
+
+
+/*
+ * showpeer - show detailed information for a peer
+ */
+static void
+showpeer(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_peer *pp;
+       /* 4 is the maximum number of peers which will fit in a packet */
+       struct info_peer_list *pl, plist[min(MAXARGS, 4)];
+       int qitems;
+       int items;
+       int itemsize;
+       int res;
+       int sendsize;
+
+again:
+       if (impl_ver == IMPL_XNTPD)
+               sendsize = sizeof(struct info_peer_list);
+       else
+               sendsize = v4sizeof(struct info_peer_list);
+
+       for (qitems = 0, pl = plist; qitems < min(pcmd->nargs, 4); qitems++) {
+               if (pcmd->argval[qitems].netnum.ss_family == AF_INET) {
+                       pl->addr = GET_INADDR(pcmd->argval[qitems].netnum);
+                       if (impl_ver == IMPL_XNTPD)
+                               pl->v6_flag = 0;
+               } else {
+                       if (impl_ver == IMPL_XNTPD_OLD) {
+                               fprintf(stderr,
+                                   "***Server doesn't understand IPv6 addresses\n");
+                               return;
+                       }
+                       pl->addr6 = GET_INADDR6(pcmd->argval[qitems].netnum);
+                       pl->v6_flag = 1;
+               }
+               pl->port = (u_short)s_port;
+               pl->hmode = pl->flags = 0;
+               pl = (struct info_peer_list *)((char *)pl + sendsize);
+       }
+
+       res = doquery(impl_ver, REQ_PEER_INFO, 0, qitems,
+                     sendsize, (char *)plist, &items,
+                     &itemsize, (void *)&pp, 0, sizeof(struct info_peer));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!checkitems(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_peer)) &&
+           !checkitemsize(itemsize, v4sizeof(struct info_peer)))
+           return;
+
+       while (items-- > 0) {
+               printpeer(pp, fp);
+               if (items > 0)
+                   (void) fprintf(fp, "\n");
+               pp++;
+       }
+}
+
+
+/*
+ * peerstats - return statistics for a peer
+ */
+static void
+peerstats(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_peer_stats *pp;
+       /* 4 is the maximum number of peers which will fit in a packet */
+       struct info_peer_list *pl, plist[min(MAXARGS, 4)];
+       struct sockaddr_storage src, dst;
+       int qitems;
+       int items;
+       int itemsize;
+       int res;
+       int sendsize;
+
+again:
+       if (impl_ver == IMPL_XNTPD)
+               sendsize = sizeof(struct info_peer_list);
+       else
+               sendsize = v4sizeof(struct info_peer_list);
+
+       memset((char *)plist, 0, sizeof(struct info_peer_list) * min(MAXARGS, 4));
+       for (qitems = 0, pl = plist; qitems < min(pcmd->nargs, 4); qitems++) {
+               if (pcmd->argval[qitems].netnum.ss_family == AF_INET) {
+                       pl->addr = GET_INADDR(pcmd->argval[qitems].netnum);
+                       if (impl_ver == IMPL_XNTPD)
+                               pl->v6_flag = 0;
+               } else {
+                       if (impl_ver == IMPL_XNTPD_OLD) {
+                               fprintf(stderr,
+                                   "***Server doesn't understand IPv6 addresses\n");
+                               return;
+                       }
+                       pl->addr6 = GET_INADDR6(pcmd->argval[qitems].netnum);
+                       pl->v6_flag = 1;
+               }
+               pl->port = (u_short)s_port;
+               pl->hmode = plist[qitems].flags = 0;
+               pl = (struct info_peer_list *)((char *)pl + sendsize);
+       }
+
+       res = doquery(impl_ver, REQ_PEER_STATS, 0, qitems,
+                     sendsize, (char *)plist, &items,
+                     &itemsize, (void *)&pp, 0, 
+                     sizeof(struct info_peer_stats));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!checkitems(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_peer_stats)) &&
+           !checkitemsize(itemsize, v4sizeof(struct info_peer_stats)))
+           return;
+
+       while (items-- > 0) {
+               memset((char *)&src, 0, sizeof(src));
+               memset((char *)&dst, 0, sizeof(dst));
+               if (pp->v6_flag != 0) {
+                       GET_INADDR6(src) = pp->srcadr6;
+                       GET_INADDR6(dst) = pp->dstadr6;
+                       src.ss_family = AF_INET6;
+                       dst.ss_family = AF_INET6;
+               } else {
+                       GET_INADDR(src) = pp->srcadr;
+                       GET_INADDR(dst) = pp->dstadr;
+                       src.ss_family = AF_INET;
+                       dst.ss_family = AF_INET;
+               }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               src.ss_len = SOCKLEN(&src);
+               dst.ss_len = SOCKLEN(&dst);
+#endif
+               (void) fprintf(fp, "remote host:          %s\n",
+                              nntohost(&src));
+               (void) fprintf(fp, "local interface:      %s\n",
+                              stoa(&dst));
+               (void) fprintf(fp, "time last received:   %lds\n",
+                              (long)ntohl(pp->timereceived));
+               (void) fprintf(fp, "time until next send: %lds\n",
+                              (long)ntohl(pp->timetosend));
+               (void) fprintf(fp, "reachability change:  %lds\n",
+                              (long)ntohl(pp->timereachable));
+               (void) fprintf(fp, "packets sent:         %ld\n",
+                              (long)ntohl(pp->sent));
+               (void) fprintf(fp, "packets received:     %ld\n",
+                              (long)ntohl(pp->processed));
+               (void) fprintf(fp, "bad authentication:   %ld\n",
+                              (long)ntohl(pp->badauth));
+               (void) fprintf(fp, "bogus origin:         %ld\n",
+                              (long)ntohl(pp->bogusorg));
+               (void) fprintf(fp, "duplicate:            %ld\n",
+                              (long)ntohl(pp->oldpkt));
+               (void) fprintf(fp, "bad dispersion:       %ld\n",
+                              (long)ntohl(pp->seldisp));
+               (void) fprintf(fp, "bad reference time:   %ld\n",
+                              (long)ntohl(pp->selbroken));
+               (void) fprintf(fp, "candidate order:      %d\n",
+                              (int)pp->candidate);
+               if (items > 0)
+                   (void) fprintf(fp, "\n");
+               (void) fprintf(fp, "flags:      ");
+               print_pflag(fp, ntohs(pp->flags));
+               pp++;
+       }
+}
+
+
+/*
+ * loopinfo - show loop filter information
+ */
+static void
+loopinfo(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_loop *il;
+       int items;
+       int itemsize;
+       int oneline = 0;
+       int res;
+       l_fp tempts;
+
+       if (pcmd->nargs > 0) {
+               if (STREQ(pcmd->argval[0].string, "oneline"))
+                   oneline = 1;
+               else if (STREQ(pcmd->argval[0].string, "multiline"))
+                   oneline = 0;
+               else {
+                       (void) fprintf(stderr, "How many lines?\n");
+                       return;
+               }
+       }
+
+again:
+       res = doquery(impl_ver, REQ_LOOP_INFO, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&il, 0, 
+                     sizeof(struct info_loop));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!check1item(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_loop)))
+           return;
+
+       if (oneline) {
+               l_fp temp2ts;
+
+               NTOHL_FP(&il->last_offset, &tempts);
+               NTOHL_FP(&il->drift_comp, &temp2ts);
+
+               (void) fprintf(fp,
+                              "offset %s, frequency %s, time_const %ld, watchdog %ld\n",
+                              lfptoa(&tempts, 6),
+                              lfptoa(&temp2ts, 3),
+                              (long)(int32_t)ntohl((u_long)il->compliance),
+                              (u_long)ntohl((u_long)il->watchdog_timer));
+       } else {
+               NTOHL_FP(&il->last_offset, &tempts);
+               (void) fprintf(fp, "offset:               %s s\n",
+                              lfptoa(&tempts, 6));
+               NTOHL_FP(&il->drift_comp, &tempts);
+               (void) fprintf(fp, "frequency:            %s ppm\n",
+                              lfptoa(&tempts, 3));
+               (void) fprintf(fp, "poll adjust:          %ld\n",
+                              (long)(int32_t)ntohl(il->compliance));
+               (void) fprintf(fp, "watchdog timer:       %ld s\n",
+                              (u_long)ntohl(il->watchdog_timer));
+       }
+}
+
+
+/*
+ * sysinfo - show current system state
+ */
+/*ARGSUSED*/
+static void
+sysinfo(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_sys *is;
+       struct sockaddr_storage peeraddr;
+       int items;
+       int itemsize;
+       int res;
+       l_fp tempts;
+
+again:
+       res = doquery(impl_ver, REQ_SYS_INFO, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&is, 0,
+                     sizeof(struct info_sys));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!check1item(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_sys)) &&
+           !checkitemsize(itemsize, v4sizeof(struct info_sys)))
+           return;
+
+       memset((char *)&peeraddr, 0, sizeof(peeraddr));
+       if (is->v6_flag != 0) {
+               GET_INADDR6(peeraddr) = is->peer6;
+               peeraddr.ss_family = AF_INET6;
+       } else {
+               GET_INADDR(peeraddr) = is->peer;
+               peeraddr.ss_family = AF_INET;
+       }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+       peeraddr.ss_len = SOCKLEN(&peeraddr);
+#endif
+       (void) fprintf(fp, "system peer:          %s\n", nntohost(&peeraddr));
+       (void) fprintf(fp, "system peer mode:     %s\n", modetoa(is->peer_mode));
+       (void) fprintf(fp, "leap indicator:       %c%c\n",
+                      is->leap & 0x2 ? '1' : '0',
+                      is->leap & 0x1 ? '1' : '0');
+       (void) fprintf(fp, "stratum:              %d\n", (int)is->stratum);
+       (void) fprintf(fp, "precision:            %d\n", (int)is->precision);
+       (void) fprintf(fp, "root distance:        %s s\n",
+                      fptoa(NTOHS_FP(is->rootdelay), 5));
+       (void) fprintf(fp, "root dispersion:      %s s\n",
+                      ufptoa(NTOHS_FP(is->rootdispersion), 5));
+       (void) fprintf(fp, "reference ID:         [%s]\n",
+                      refid_string(is->refid, is->stratum));
+       NTOHL_FP(&is->reftime, &tempts);
+       (void) fprintf(fp, "reference time:       %s\n", prettydate(&tempts));
+
+       (void) fprintf(fp, "system flags:         ");
+       if ((is->flags & (INFO_FLAG_BCLIENT | INFO_FLAG_AUTHENABLE |
+           INFO_FLAG_NTP | INFO_FLAG_KERNEL| INFO_FLAG_CAL |
+           INFO_FLAG_PPS_SYNC | INFO_FLAG_MONITOR | INFO_FLAG_FILEGEN)) == 0) {
+               (void) fprintf(fp, "none\n");
+       } else {
+               if (is->flags & INFO_FLAG_BCLIENT)
+                   (void) fprintf(fp, "bclient ");
+               if (is->flags & INFO_FLAG_AUTHENTICATE)
+                   (void) fprintf(fp, "auth ");
+               if (is->flags & INFO_FLAG_MONITOR)
+                   (void) fprintf(fp, "monitor ");
+               if (is->flags & INFO_FLAG_NTP)
+                   (void) fprintf(fp, "ntp ");
+               if (is->flags & INFO_FLAG_KERNEL)
+                   (void) fprintf(fp, "kernel ");
+               if (is->flags & INFO_FLAG_FILEGEN)
+                   (void) fprintf(fp, "stats ");
+               if (is->flags & INFO_FLAG_CAL)
+                   (void) fprintf(fp, "calibrate ");
+               if (is->flags & INFO_FLAG_PPS_SYNC)
+                   (void) fprintf(fp, "pps ");
+               (void) fprintf(fp, "\n");
+       }
+       (void) fprintf(fp, "jitter:               %s s\n",
+                      fptoa(ntohl(is->frequency), 6));
+       (void) fprintf(fp, "stability:            %s ppm\n",
+                      ufptoa(ntohl(is->stability), 3));
+       (void) fprintf(fp, "broadcastdelay:       %s s\n",
+                      fptoa(NTOHS_FP(is->bdelay), 6));
+       NTOHL_FP(&is->authdelay, &tempts);
+       (void) fprintf(fp, "authdelay:            %s s\n", lfptoa(&tempts, 6));
+}
+
+
+/*
+ * sysstats - print system statistics
+ */
+/*ARGSUSED*/
+static void
+sysstats(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_sys_stats *ss;
+       int items;
+       int itemsize;
+       int res;
+
+again:
+       res = doquery(impl_ver, REQ_SYS_STATS, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&ss, 0, 
+                     sizeof(struct info_sys_stats));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!check1item(items, fp))
+           return;
+
+       if (itemsize != sizeof(struct info_sys_stats) &&
+           itemsize != sizeof(struct old_info_sys_stats)) {
+               /* issue warning according to new structure size */
+               checkitemsize(itemsize, sizeof(struct info_sys_stats));
+               return;
+       }
+       fprintf(fp, "time since restart:     %ld\n",
+              (u_long)ntohl(ss->timeup));
+       fprintf(fp, "time since reset:       %ld\n",
+               (u_long)ntohl(ss->timereset));
+        fprintf(fp, "packets received:       %ld\n",
+               (u_long)ntohl(ss->received));
+       fprintf(fp, "packets processed:      %ld\n",
+               (u_long)ntohl(ss->processed));
+       fprintf(fp, "current version:        %ld\n",
+              (u_long)ntohl(ss->newversionpkt));
+       fprintf(fp, "previous version:       %ld\n",
+              (u_long)ntohl(ss->oldversionpkt));
+       fprintf(fp, "bad version:            %ld\n",
+              (u_long)ntohl(ss->unknownversion));
+       fprintf(fp, "access denied:          %ld\n",
+               (u_long)ntohl(ss->denied));
+       fprintf(fp, "bad length or format:   %ld\n",
+              (u_long)ntohl(ss->badlength));
+       fprintf(fp, "bad authentication:     %ld\n",
+              (u_long)ntohl(ss->badauth));
+       if (itemsize != sizeof(struct info_sys_stats))
+           return;
+       
+       fprintf(fp, "rate exceeded:          %ld\n",
+              (u_long)ntohl(ss->limitrejected));
+}
+
+
+
+/*
+ * iostats - print I/O statistics
+ */
+/*ARGSUSED*/
+static void
+iostats(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_io_stats *io;
+       int items;
+       int itemsize;
+       int res;
+
+again:
+       res = doquery(impl_ver, REQ_IO_STATS, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&io, 0, 
+                     sizeof(struct info_io_stats));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!check1item(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_io_stats)))
+           return;
+
+       (void) fprintf(fp, "time since reset:     %ld\n",
+                      (u_long)ntohl(io->timereset));
+       (void) fprintf(fp, "receive buffers:      %d\n",
+                      ntohs(io->totalrecvbufs));
+       (void) fprintf(fp, "free receive buffers: %d\n",
+                      ntohs(io->freerecvbufs));
+       (void) fprintf(fp, "used receive buffers: %d\n",
+                      ntohs(io->fullrecvbufs));
+       (void) fprintf(fp, "low water refills:    %d\n",
+                      ntohs(io->lowwater));
+       (void) fprintf(fp, "dropped packets:      %ld\n",
+                      (u_long)ntohl(io->dropped));
+       (void) fprintf(fp, "ignored packets:      %ld\n",
+                      (u_long)ntohl(io->ignored));
+       (void) fprintf(fp, "received packets:     %ld\n",
+                      (u_long)ntohl(io->received));
+       (void) fprintf(fp, "packets sent:         %ld\n",
+                      (u_long)ntohl(io->sent));
+       (void) fprintf(fp, "packets not sent:     %ld\n",
+                      (u_long)ntohl(io->notsent));
+       (void) fprintf(fp, "interrupts handled:   %ld\n",
+                      (u_long)ntohl(io->interrupts));
+       (void) fprintf(fp, "received by int:      %ld\n",
+                      (u_long)ntohl(io->int_received));
+}
+
+
+/*
+ * memstats - print peer memory statistics
+ */
+/*ARGSUSED*/
+static void
+memstats(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_mem_stats *mem;
+       int i;
+       int items;
+       int itemsize;
+       int res;
+
+again:
+       res = doquery(impl_ver, REQ_MEM_STATS, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&mem, 0, 
+                     sizeof(struct info_mem_stats));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!check1item(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_mem_stats)))
+           return;
+
+       (void) fprintf(fp, "time since reset:     %ld\n",
+                      (u_long)ntohl(mem->timereset));
+       (void) fprintf(fp, "total peer memory:    %d\n",
+                      ntohs(mem->totalpeermem));
+       (void) fprintf(fp, "free peer memory:     %d\n",
+                      ntohs(mem->freepeermem));
+       (void) fprintf(fp, "calls to findpeer:    %ld\n",
+                      (u_long)ntohl(mem->findpeer_calls));
+       (void) fprintf(fp, "new peer allocations: %ld\n",
+                      (u_long)ntohl(mem->allocations));
+       (void) fprintf(fp, "peer demobilizations: %ld\n",
+                      (u_long)ntohl(mem->demobilizations));
+
+       (void) fprintf(fp, "hash table counts:   ");
+       for (i = 0; i < NTP_HASH_SIZE; i++) {
+               (void) fprintf(fp, "%4d", (int)mem->hashcount[i]);
+               if ((i % 8) == 7 && i != (NTP_HASH_SIZE-1)) {
+                       (void) fprintf(fp, "\n                     ");
+               }
+       }
+       (void) fprintf(fp, "\n");
+}
+
+
+
+/*
+ * timerstats - print timer statistics
+ */
+/*ARGSUSED*/
+static void
+timerstats(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_timer_stats *tim;
+       int items;
+       int itemsize;
+       int res;
+
+again:
+       res = doquery(impl_ver, REQ_TIMER_STATS, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&tim, 0, 
+                     sizeof(struct info_timer_stats));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!check1item(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_timer_stats)))
+           return;
+
+       (void) fprintf(fp, "time since reset:  %ld\n",
+                      (u_long)ntohl(tim->timereset));
+       (void) fprintf(fp, "alarms handled:    %ld\n",
+                      (u_long)ntohl(tim->alarms));
+       (void) fprintf(fp, "alarm overruns:    %ld\n",
+                      (u_long)ntohl(tim->overflows));
+       (void) fprintf(fp, "calls to transmit: %ld\n",
+                      (u_long)ntohl(tim->xmtcalls));
+}
+
+
+/*
+ * addpeer - configure an active mode association
+ */
+static void
+addpeer(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       doconfig(pcmd, fp, MODE_ACTIVE, 0);
+}
+
+
+/*
+ * addserver - configure a client mode association
+ */
+static void
+addserver(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       doconfig(pcmd, fp, MODE_CLIENT, 0);
+}
+
+/*
+ * addrefclock - configure a reference clock association
+ */
+static void
+addrefclock(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       doconfig(pcmd, fp, MODE_CLIENT, 1);
+}
+
+/*
+ * broadcast - configure a broadcast mode association
+ */
+static void
+broadcast(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       doconfig(pcmd, fp, MODE_BROADCAST, 0);
+}
+
+
+/*
+ * config - configure a new peer association
+ */
+static void
+doconfig(
+       struct parse *pcmd,
+       FILE *fp,
+       int mode,
+        int refc
+       )
+{
+       struct conf_peer cpeer;
+       int items;
+       int itemsize;
+       char *dummy;
+       u_long keyid;
+       u_int version;
+       u_char minpoll;
+       u_char maxpoll;
+       u_int flags;
+       u_char cmode;
+       int res;
+       int sendsize;
+       int numtyp;
+
+again:
+       keyid = 0;
+       version = 3;
+       flags = 0;
+       res = 0;
+       cmode = 0;
+       minpoll = NTP_MINDPOLL;
+       maxpoll = NTP_MAXDPOLL;
+       numtyp = 1;
+       if (refc)
+            numtyp = 5;
+
+       if (impl_ver == IMPL_XNTPD)
+               sendsize = sizeof(struct conf_peer);
+       else
+               sendsize = v4sizeof(struct conf_peer);
+
+       items = 1;
+       while (pcmd->nargs > items) {
+               if (STREQ(pcmd->argval[items].string, "prefer"))
+                   flags |= CONF_FLAG_PREFER;
+               else if (STREQ(pcmd->argval[items].string, "burst"))
+                   flags |= CONF_FLAG_BURST;
+               else if (STREQ(pcmd->argval[items].string, "dynamic"))
+                   (void) fprintf(fp, "Warning: the \"dynamic\" keyword has been obsoleted and will be removed in the next release\n"); 
+               else if (STREQ(pcmd->argval[items].string, "iburst"))
+                   flags |= CONF_FLAG_IBURST;
+               else if (!refc && STREQ(pcmd->argval[items].string, "keyid"))
+                   numtyp = 1;
+               else if (!refc && STREQ(pcmd->argval[items].string, "version"))
+                   numtyp = 2;
+               else if (STREQ(pcmd->argval[items].string, "minpoll"))
+                   numtyp = 3;
+               else if (STREQ(pcmd->argval[items].string, "maxpoll"))
+                   numtyp = 4;
+               else {
+                       long val;
+                       if (!atoint(pcmd->argval[items].string, &val))
+                            numtyp = 0;                                  
+                       switch (numtyp) {
+                       case 1:
+                            keyid = val;
+                            numtyp = 2;                                  
+                            break;
+                            
+                       case 2:
+                            version = (u_int) val;
+                            numtyp = 0;                                  
+                            break;
+
+                       case 3:
+                            minpoll = (u_char)val;
+                            numtyp = 0;                                  
+                            break;
+
+                       case 4:
+                            maxpoll = (u_char)val;
+                            numtyp = 0;                                  
+                            break;
+
+                       case 5:
+                            cmode = (u_char)val;
+                            numtyp = 0;                                  
+                            break;
+
+                       default:
+                            (void) fprintf(fp, "*** '%s' not understood\n",
+                                           pcmd->argval[items].string);
+                            res++;
+                            numtyp = 0;                                  
+                       }
+                       if (val < 0) {
+                            (void) fprintf(stderr,
+                                    "***Value '%s' should be unsigned\n",
+                                     pcmd->argval[items].string);
+                            res++;
+                       }
+                  }
+            items++;
+       }
+       if (keyid > 0)
+            flags |= CONF_FLAG_AUTHENABLE;
+       if (version > NTP_VERSION ||
+           version < NTP_OLDVERSION) {
+            (void)fprintf(fp, "***invalid version number: %u\n",
+                          version);
+            res++;
+       }
+       if (minpoll < NTP_MINPOLL || minpoll > NTP_MAXPOLL || 
+           maxpoll < NTP_MINPOLL || maxpoll > NTP_MAXPOLL || 
+           minpoll > maxpoll) {
+            (void) fprintf(fp, "***min/max-poll must be within %d..%d\n",
+                           NTP_MINPOLL, NTP_MAXPOLL);
+            res++;
+       }                                       
+
+       if (res)
+           return;
+
+       memset((void *)&cpeer, 0, sizeof(cpeer));
+
+       if (pcmd->argval[0].netnum.ss_family == AF_INET) {
+               cpeer.peeraddr = GET_INADDR(pcmd->argval[0].netnum);
+               if (impl_ver == IMPL_XNTPD)
+                       cpeer.v6_flag = 0;
+       } else {
+               if (impl_ver == IMPL_XNTPD_OLD) {
+                       fprintf(stderr,
+                           "***Server doesn't understand IPv6 addresses\n");
+                       return;
+               }
+               cpeer.peeraddr6 = GET_INADDR6(pcmd->argval[0].netnum);
+               cpeer.v6_flag = 1;
+       }
+       cpeer.hmode = (u_char) mode;
+       cpeer.keyid = keyid;
+       cpeer.version = (u_char) version;
+       cpeer.minpoll = minpoll;
+       cpeer.maxpoll = maxpoll;
+       cpeer.flags = (u_char)flags;
+       cpeer.ttl = cmode;
+
+       res = doquery(impl_ver, REQ_CONFIG, 1, 1,
+                     sendsize, (char *)&cpeer, &items,
+                     &itemsize, &dummy, 0, sizeof(struct conf_peer));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == INFO_ERR_FMT) {
+               (void) fprintf(fp,
+                   "***Retrying command with old conf_peer size\n");
+               res = doquery(impl_ver, REQ_CONFIG, 1, 1,
+                             sizeof(struct old_conf_peer), (char *)&cpeer,
+                             &items, &itemsize, &dummy, 0,
+                             sizeof(struct conf_peer));
+       }
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+       return;
+}
+
+
+/*
+ * unconfig - unconfigure some associations
+ */
+static void
+unconfig(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       /* 8 is the maximum number of peers which will fit in a packet */
+       struct conf_unpeer *pl, plist[min(MAXARGS, 8)];
+       int qitems;
+       int items;
+       int itemsize;
+       char *dummy;
+       int res;
+       int sendsize;
+
+again:
+       if (impl_ver == IMPL_XNTPD)
+               sendsize = sizeof(struct conf_unpeer);
+       else
+               sendsize = v4sizeof(struct conf_unpeer);
+
+       for (qitems = 0, pl = plist; qitems < min(pcmd->nargs, 8); qitems++) {
+               if (pcmd->argval[0].netnum.ss_family == AF_INET) {
+                       pl->peeraddr = GET_INADDR(pcmd->argval[qitems].netnum);
+                       if (impl_ver == IMPL_XNTPD)
+                               pl->v6_flag = 0;
+               } else {
+                       if (impl_ver == IMPL_XNTPD_OLD) {
+                               fprintf(stderr,
+                                   "***Server doesn't understand IPv6 addresses\n");
+                               return;
+                       }
+                       pl->peeraddr6 =
+                           GET_INADDR6(pcmd->argval[qitems].netnum);
+                       pl->v6_flag = 1;
+               }
+               pl = (struct conf_unpeer *)((char *)pl + sendsize);
+       }
+
+       res = doquery(impl_ver, REQ_UNCONFIG, 1, qitems,
+                     sendsize, (char *)plist, &items,
+                     &itemsize, &dummy, 0, sizeof(struct conf_unpeer));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+}
+
+
+/*
+ * set - set some system flags
+ */
+static void
+set(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       doset(pcmd, fp, REQ_SET_SYS_FLAG);
+}
+
+
+/*
+ * clear - clear some system flags
+ */
+static void
+sys_clear(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       doset(pcmd, fp, REQ_CLR_SYS_FLAG);
+}
+
+
+/*
+ * doset - set/clear system flags
+ */
+static void
+doset(
+       struct parse *pcmd,
+       FILE *fp,
+       int req
+       )
+{
+       /* 8 is the maximum number of peers which will fit in a packet */
+       struct conf_sys_flags sys;
+       int items;
+       int itemsize;
+       char *dummy;
+       int res;
+
+       sys.flags = 0;
+       res = 0;
+       for (items = 0; items < pcmd->nargs; items++) {
+               if (STREQ(pcmd->argval[items].string, "auth"))
+                       sys.flags |= SYS_FLAG_AUTH;
+               else if (STREQ(pcmd->argval[items].string, "bclient"))
+                       sys.flags |= SYS_FLAG_BCLIENT;
+               else if (STREQ(pcmd->argval[items].string, "calibrate"))
+                       sys.flags |= SYS_FLAG_CAL;
+               else if (STREQ(pcmd->argval[items].string, "kernel"))
+                       sys.flags |= SYS_FLAG_KERNEL;
+               else if (STREQ(pcmd->argval[items].string, "monitor"))
+                       sys.flags |= SYS_FLAG_MONITOR;
+               else if (STREQ(pcmd->argval[items].string, "ntp"))
+                       sys.flags |= SYS_FLAG_NTP;
+               else if (STREQ(pcmd->argval[items].string, "pps"))
+                       sys.flags |= SYS_FLAG_PPS;
+               else if (STREQ(pcmd->argval[items].string, "stats"))
+                       sys.flags |= SYS_FLAG_FILEGEN;
+               else {
+                       (void) fprintf(fp, "Unknown flag %s\n",
+                           pcmd->argval[items].string);
+                       res = 1;
+               }
+       }
+
+       sys.flags = htonl(sys.flags);
+       if (res || sys.flags == 0)
+           return;
+
+again:
+       res = doquery(impl_ver, req, 1, 1,
+                     sizeof(struct conf_sys_flags), (char *)&sys, &items,
+                     &itemsize, &dummy, 0, sizeof(struct conf_sys_flags));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+}
+
+
+/*
+ * data for printing/interrpreting the restrict flags
+ */
+struct resflags {
+  const char *str;
+       int bit;
+};
+
+/* XXX: HMS: we apparently don't report set bits we do not recognize. */
+
+static struct resflags resflagsV2[] = {
+       { "ignore",     0x001 },
+       { "noserve",    0x002 },
+       { "notrust",    0x004 },
+       { "noquery",    0x008 },
+       { "nomodify",   0x010 },
+       { "nopeer",     0x020 },
+       { "notrap",     0x040 },
+       { "lptrap",     0x080 },
+       { "limited",    0x100 },
+       { "",           0 }
+};
+
+static struct resflags resflagsV3[] = {
+       { "ignore",     RES_IGNORE },
+       { "noserve",    RES_DONTSERVE },
+       { "notrust",    RES_DONTTRUST },
+       { "noquery",    RES_NOQUERY },
+       { "nomodify",   RES_NOMODIFY },
+       { "nopeer",     RES_NOPEER },
+       { "notrap",     RES_NOTRAP },
+       { "lptrap",     RES_LPTRAP },
+       { "limited",    RES_LIMITED },
+       { "version",    RES_VERSION },
+       { "kod",        RES_DEMOBILIZE },
+       { "timeout",    RES_TIMEOUT },
+
+       { "",           0 }
+};
+
+static struct resflags resmflags[] = {
+       { "ntpport",    RESM_NTPONLY },
+       { "interface",  RESM_INTERFACE },
+       { "",           0 }
+};
+
+
+/*
+ * reslist - obtain and print the server's restrict list
+ */
+/*ARGSUSED*/
+static void
+reslist(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_restrict *rl;
+       struct sockaddr_storage resaddr;
+       struct sockaddr_storage maskaddr;
+       int items;
+       int itemsize;
+       int res;
+       int skip;
+       char *addr;
+       char *mask;
+       struct resflags *rf;
+       u_int32 count;
+       u_short flags;
+       u_short mflags;
+       char flagstr[300];
+       static const char *comma = ", ";
+
+again:
+       res = doquery(impl_ver, REQ_GET_RESTRICT, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&rl, 0, 
+                     sizeof(struct info_restrict));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!checkitems(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_restrict)) &&
+           !checkitemsize(itemsize, v4sizeof(struct info_restrict)))
+           return;
+
+       (void) fprintf(fp,
+              "   address          mask            count        flags\n");
+       (void) fprintf(fp,
+                      "=====================================================================\n");
+
+       while (items > 0) {
+               memset((char *)&resaddr, 0, sizeof(resaddr));
+               memset((char *)&maskaddr, 0, sizeof(maskaddr));
+               if (rl->v6_flag != 0) {
+                       GET_INADDR6(resaddr) = rl->addr6;
+                       GET_INADDR6(maskaddr) = rl->mask6;
+                       resaddr.ss_family = AF_INET6;
+                       maskaddr.ss_family = AF_INET6;
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+                       resaddr.ss_len = SOCKLEN(&resaddr);
+#endif
+                       addr = nntohost(&resaddr);
+               } else {
+                       GET_INADDR(resaddr) = rl->addr;
+                       GET_INADDR(maskaddr) = rl->mask;
+                       resaddr.ss_family = AF_INET;
+                       maskaddr.ss_family = AF_INET;
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+                       resaddr.ss_len = SOCKLEN(&resaddr);
+#endif
+                       if ((rl->mask == (u_int32)0xffffffff))
+                               addr = nntohost(&resaddr);
+                       else
+                               addr = stoa(&resaddr);
+               }
+               mask = stoa(&maskaddr);
+               skip = 1;
+               if ((pcmd->nargs == 0) ||
+                   ((pcmd->argval->ival == 6) && (rl->v6_flag != 0)) ||
+                   ((pcmd->argval->ival == 4) && (rl->v6_flag == 0)))
+                       skip = 0;
+               count = ntohl(rl->count);
+               flags = ntohs(rl->flags);
+               mflags = ntohs(rl->mflags);
+               flagstr[0] = '\0';
+
+               res = 1;
+               rf = &resmflags[0];
+               while (rf->bit != 0) {
+                       if (mflags & rf->bit) {
+                               if (!res)
+                                   (void) strcat(flagstr, comma);
+                               res = 0;
+                               (void) strcat(flagstr, rf->str);
+                       }
+                       rf++;
+               }
+
+               rf = (impl_ver == IMPL_XNTPD_OLD)
+                    ? &resflagsV2[0]
+                    : &resflagsV3[0]
+                    ;
+               while (rf->bit != 0) {
+                       if (flags & rf->bit) {
+                               if (!res)
+                                   (void) strcat(flagstr, comma);
+                               res = 0;
+                               (void) strcat(flagstr, rf->str);
+                       }
+                       rf++;
+               }
+
+               if (flagstr[0] == '\0')
+                   (void) strcpy(flagstr, "none");
+
+               if (!skip)
+                       (void) fprintf(fp, "%-15.15s %-15.15s %9ld  %s\n",
+                                       addr, mask, (u_long)count, flagstr);
+               rl++;
+               items--;
+       }
+}
+
+
+
+/*
+ * new_restrict - create/add a set of restrictions
+ */
+static void
+new_restrict(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       do_restrict(pcmd, fp, REQ_RESADDFLAGS);
+}
+
+
+/*
+ * unrestrict - remove restriction flags from existing entry
+ */
+static void
+unrestrict(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       do_restrict(pcmd, fp, REQ_RESSUBFLAGS);
+}
+
+
+/*
+ * delrestrict - delete an existing restriction
+ */
+static void
+delrestrict(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       do_restrict(pcmd, fp, REQ_UNRESTRICT);
+}
+
+
+/*
+ * do_restrict - decode commandline restrictions and make the request
+ */
+static void
+do_restrict(
+       struct parse *pcmd,
+       FILE *fp,
+       int req_code
+       )
+{
+       struct conf_restrict cres;
+       int items;
+       int itemsize;
+       char *dummy;
+       u_int32 num;
+       u_long bit;
+       int i;
+       int res;
+       int err;
+       int sendsize;
+
+       /* Initialize cres */
+       cres.addr = 0;
+       cres.mask = 0;
+       cres.flags = 0;
+       cres.mflags = 0;
+       cres.v6_flag = 0;
+
+again:
+       if (impl_ver == IMPL_XNTPD)
+               sendsize = sizeof(struct conf_restrict);
+       else
+               sendsize = v4sizeof(struct conf_restrict);
+
+       if (pcmd->argval[0].netnum.ss_family == AF_INET) {
+               cres.addr = GET_INADDR(pcmd->argval[0].netnum);
+               cres.mask = GET_INADDR(pcmd->argval[1].netnum);
+               if (impl_ver == IMPL_XNTPD)
+                       cres.v6_flag = 0;
+       } else {
+               if (impl_ver == IMPL_XNTPD_OLD) {
+                       fprintf(stderr,
+                           "***Server doesn't understand IPv6 addresses\n");
+                       return;
+               }
+               cres.addr6 = GET_INADDR6(pcmd->argval[0].netnum);
+               cres.v6_flag = 1;
+       }
+       cres.flags = 0;
+       cres.mflags = 0;
+       err = 0;
+       for (res = 2; res < pcmd->nargs; res++) {
+               if (STREQ(pcmd->argval[res].string, "ntpport")) {
+                       cres.mflags |= RESM_NTPONLY;
+               } else {
+                       for (i = 0; resflagsV3[i].bit != 0; i++) {
+                               if (STREQ(pcmd->argval[res].string,
+                                         resflagsV3[i].str))
+                                   break;
+                       }
+                       if (resflagsV3[i].bit != 0) {
+                               cres.flags |= resflagsV3[i].bit;
+                               if (req_code == REQ_UNRESTRICT) {
+                                       (void) fprintf(fp,
+                                                      "Flag %s inappropriate\n",
+                                                      resflagsV3[i].str);
+                                       err++;
+                               }
+                       } else {
+                               (void) fprintf(fp, "Unknown flag %s\n",
+                                              pcmd->argval[res].string);
+                               err++;
+                       }
+               }
+       }
+       cres.flags = htons(cres.flags);
+       cres.mflags = htons(cres.mflags);
+
+       /*
+        * Make sure mask for default address is zero.  Otherwise,
+        * make sure mask bits are contiguous.
+        */
+       if (pcmd->argval[0].netnum.ss_family == AF_INET) {
+               if (cres.addr == 0) {
+                       cres.mask = 0;
+               } else {
+                       num = ntohl(cres.mask);
+                       for (bit = 0x80000000; bit != 0; bit >>= 1)
+                           if ((num & bit) == 0)
+                               break;
+                       for ( ; bit != 0; bit >>= 1)
+                           if ((num & bit) != 0)
+                               break;
+                       if (bit != 0) {
+                               (void) fprintf(fp, "Invalid mask %s\n",
+                                              numtoa(cres.mask));
+                               err++;
+                       }
+               }
+       } else {
+               /* XXX IPv6 sanity checking stuff */
+       }
+
+       if (err)
+           return;
+
+       res = doquery(impl_ver, req_code, 1, 1,
+                     sendsize, (char *)&cres, &items,
+                     &itemsize, &dummy, 0, sizeof(struct conf_restrict));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+       return;
+}
+
+
+/*
+ * monlist - obtain and print the server's monitor data
+ */
+/*ARGSUSED*/
+static void
+monlist(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       char *struct_star;
+       struct sockaddr_storage addr;
+       struct sockaddr_storage dstadr;
+       int items;
+       int itemsize;
+       int res;
+       int version = -1;
+
+       if (pcmd->nargs > 0) {
+               version = pcmd->argval[0].ival;
+       }
+
+again:
+       res = doquery(impl_ver,
+                     (version == 1 || version == -1) ? REQ_MON_GETLIST_1 :
+                     REQ_MON_GETLIST, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, &struct_star,
+                     (version < 0) ? (1 << INFO_ERR_REQ) : 0, 
+                     sizeof(struct info_monitor_1));
+
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == INFO_ERR_REQ && version < 0) 
+           res = doquery(impl_ver, REQ_MON_GETLIST, 0, 0, 0, (char *)NULL,
+                         &items, &itemsize, &struct_star, 0, 
+                         sizeof(struct info_monitor));
+       
+       if (res != 0)
+           return;
+
+       if (!checkitems(items, fp))
+           return;
+
+       if (itemsize == sizeof(struct info_monitor_1) ||
+           itemsize == v4sizeof(struct info_monitor_1)) {
+               struct info_monitor_1 *ml = (struct info_monitor_1 *) struct_star;
+
+               (void) fprintf(fp,
+                              "remote address          port local address      count m ver code avgint  lstint\n");
+               (void) fprintf(fp,
+                              "===============================================================================\n");
+               while (items > 0) {
+                       memset((char *)&addr, 0, sizeof(addr));
+                       memset((char *)&dstadr, 0, sizeof(dstadr));
+                       if (ml->v6_flag != 0) {
+                               GET_INADDR6(addr) = ml->addr6;
+                               addr.ss_family = AF_INET6;
+                               GET_INADDR6(dstadr) = ml->daddr6;
+                               dstadr.ss_family = AF_INET6;
+                       } else {
+                               GET_INADDR(addr) = ml->addr;
+                               addr.ss_family = AF_INET;
+                               GET_INADDR(dstadr) = ml->daddr;
+                               dstadr.ss_family = AF_INET;
+                       }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+                       addr.ss_len = SOCKLEN(&addr);
+                       dstadr.ss_len = SOCKLEN(&dstadr);
+#endif
+                       if ((pcmd->nargs == 0) ||
+                           ((pcmd->argval->ival == 6) && (ml->v6_flag != 0)) ||
+                           ((pcmd->argval->ival == 4) && (ml->v6_flag == 0)))
+                               (void) fprintf(fp, 
+                                   "%-22.22s %5d %-15s %8ld %1d %1d %6lx %6lu %7lu\n",
+                                   nntohost(&addr), 
+                                   ntohs(ml->port),
+                                   stoa(&dstadr),
+                                   (u_long)ntohl(ml->count),
+                                   ml->mode,
+                                   ml->version,
+                                   (u_long)ntohl(ml->lastdrop),
+                                   (u_long)ntohl(ml->lasttime),
+                                   (u_long)ntohl(ml->firsttime));
+                       ml++;
+                       items--;
+               }
+       } else if (itemsize == sizeof(struct info_monitor) ||
+           itemsize == v4sizeof(struct info_monitor)) {
+               struct info_monitor *ml = (struct info_monitor *) struct_star;
+
+               (void) fprintf(fp,
+                              "     address               port     count mode ver code avgint  lstint\n");
+               (void) fprintf(fp,
+                              "===============================================================================\n");
+               while (items > 0) {
+                       memset((char *)&dstadr, 0, sizeof(dstadr));
+                       if (ml->v6_flag != 0) {
+                               GET_INADDR6(dstadr) = ml->addr6;
+                               dstadr.ss_family = AF_INET6;
+                       } else {
+                               GET_INADDR(dstadr) = ml->addr;
+                               dstadr.ss_family = AF_INET;
+                       }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+                       dstadr.ss_len = SOCKLEN(&dstadr);
+#endif
+                       if ((pcmd->nargs == 0) ||
+                           ((pcmd->argval->ival == 6) && (ml->v6_flag != 0)) ||
+                           ((pcmd->argval->ival == 4) && (ml->v6_flag == 0)))
+                               (void) fprintf(fp,
+                                   "%-25.25s %5d %9ld %4d %2d %9lx %9lu %9lu\n",
+                                   nntohost(&dstadr),
+                                   ntohs(ml->port),
+                                   (u_long)ntohl(ml->count),
+                                   ml->mode,
+                                   ml->version,
+                                   (u_long)ntohl(ml->lastdrop),
+                                   (u_long)ntohl(ml->lasttime),
+                                   (u_long)ntohl(ml->firsttime));
+                       ml++;
+                       items--;
+               }
+       } else if (itemsize == sizeof(struct old_info_monitor)) {
+               struct old_info_monitor *oml = (struct old_info_monitor *)struct_star;
+               (void) fprintf(fp,
+                              "     address          port     count  mode version  lasttime firsttime\n");
+               (void) fprintf(fp,
+                              "======================================================================\n");
+               while (items > 0) {
+                       memset((char *)&dstadr, 0, sizeof(dstadr));
+                       if (oml->v6_flag != 0) {
+                               GET_INADDR6(dstadr) = oml->addr6;
+                               dstadr.ss_family = AF_INET6;
+                       } else {
+                               GET_INADDR(dstadr) = oml->addr;
+                               dstadr.ss_family = AF_INET;
+                       }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+                       dstadr.ss_len = SOCKLEN(&dstadr);
+#endif
+                       (void) fprintf(fp, "%-20.20s %5d %9ld %4d   %3d %9lu %9lu\n",
+                                      nntohost(&dstadr),
+                                      ntohs(oml->port),
+                                      (u_long)ntohl(oml->count),
+                                      oml->mode,
+                                      oml->version,
+                                      (u_long)ntohl(oml->lasttime),
+                                      (u_long)ntohl(oml->firsttime));
+                       oml++;
+                       items--;
+               }
+       } else {
+               /* issue warning according to new info_monitor size */
+               checkitemsize(itemsize, sizeof(struct info_monitor));
+       }
+}
+
+
+/*
+ * Mapping between command line strings and stat reset flags
+ */
+struct statreset {
+  const char *str;
+       int flag;
+} sreset[] = {
+       { "io",         RESET_FLAG_IO },
+       { "sys",        RESET_FLAG_SYS },
+       { "mem",        RESET_FLAG_MEM },
+       { "timer",      RESET_FLAG_TIMER },
+       { "auth",       RESET_FLAG_AUTH },
+       { "allpeers",   RESET_FLAG_ALLPEERS },
+       { "",           0 }
+};
+
+/*
+ * reset - reset statistic counters
+ */
+static void
+reset(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct reset_flags rflags;
+       int items;
+       int itemsize;
+       char *dummy;
+       int i;
+       int res;
+       int err;
+
+       err = 0;
+       rflags.flags = 0;
+       for (res = 0; res < pcmd->nargs; res++) {
+               for (i = 0; sreset[i].flag != 0; i++) {
+                       if (STREQ(pcmd->argval[res].string, sreset[i].str))
+                           break;
+               }
+               if (sreset[i].flag == 0) {
+                       (void) fprintf(fp, "Flag %s unknown\n",
+                                      pcmd->argval[res].string);
+                       err++;
+               } else {
+                       rflags.flags |= sreset[i].flag;
+               }
+       }
+       rflags.flags = htonl(rflags.flags);
+
+       if (err) {
+               (void) fprintf(fp, "Not done due to errors\n");
+               return;
+       }
+
+again:
+       res = doquery(impl_ver, REQ_RESET_STATS, 1, 1,
+                     sizeof(struct reset_flags), (char *)&rflags, &items,
+                     &itemsize, &dummy, 0, sizeof(struct reset_flags));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+       return;
+}
+
+
+
+/*
+ * preset - reset stat counters for particular peers
+ */
+static void
+preset(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       /* 8 is the maximum number of peers which will fit in a packet */
+       struct conf_unpeer *pl, plist[min(MAXARGS, 8)];
+       int qitems;
+       int items;
+       int itemsize;
+       char *dummy;
+       int res;
+       int sendsize;
+
+again:
+       if (impl_ver == IMPL_XNTPD)
+               sendsize = sizeof(struct conf_unpeer);
+       else
+               sendsize = v4sizeof(struct conf_unpeer);
+
+       for (qitems = 0, pl = plist; qitems < min(pcmd->nargs, 8); qitems++) {
+               if (pcmd->argval[qitems].netnum.ss_family == AF_INET) {
+                       pl->peeraddr = GET_INADDR(pcmd->argval[qitems].netnum);
+                       if (impl_ver == IMPL_XNTPD)
+                               pl->v6_flag = 0;
+               } else {
+                       if (impl_ver == IMPL_XNTPD_OLD) {
+                               fprintf(stderr,
+                                   "***Server doesn't understand IPv6 addresses\n");
+                               return;
+                       }
+                       pl->peeraddr6 =
+                           GET_INADDR6(pcmd->argval[qitems].netnum);
+                       pl->v6_flag = 1;
+               }
+               pl = (struct conf_unpeer *)((char *)pl + sendsize);
+       }
+
+       res = doquery(impl_ver, REQ_RESET_PEER, 1, qitems,
+                     sendsize, (char *)plist, &items,
+                     &itemsize, &dummy, 0, sizeof(struct conf_unpeer));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+}
+
+
+/*
+ * readkeys - request the server to reread the keys file
+ */
+/*ARGSUSED*/
+static void
+readkeys(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int items;
+       int itemsize;
+       char *dummy;
+       int res;
+
+again:
+       res = doquery(impl_ver, REQ_REREAD_KEYS, 1, 0, 0, (char *)0,
+                     &items, &itemsize, &dummy, 0, sizeof(dummy));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+       return;
+}
+
+
+/*
+ * trustkey - add some keys to the trusted key list
+ */
+static void
+trustkey(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       do_trustkey(pcmd, fp, REQ_TRUSTKEY);
+}
+
+
+/*
+ * untrustkey - remove some keys from the trusted key list
+ */
+static void
+untrustkey(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       do_trustkey(pcmd, fp, REQ_UNTRUSTKEY);
+}
+
+
+/*
+ * do_trustkey - do grunge work of adding/deleting keys
+ */
+static void
+do_trustkey(
+       struct parse *pcmd,
+       FILE *fp,
+       int req
+       )
+{
+       u_long keyids[MAXARGS];
+       int i;
+       int items;
+       int itemsize;
+       char *dummy;
+       int ritems;
+       int res;
+
+       ritems = 0;
+       for (i = 0; i < pcmd->nargs; i++) {
+               keyids[ritems++] = pcmd->argval[i].uval;
+       }
+
+again:
+       res = doquery(impl_ver, req, 1, ritems, sizeof(u_long),
+                     (char *)keyids, &items, &itemsize, &dummy, 0, 
+                     sizeof(dummy));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+       return;
+}
+
+
+
+/*
+ * authinfo - obtain and print info about authentication
+ */
+/*ARGSUSED*/
+static void
+authinfo(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_auth *ia;
+       int items;
+       int itemsize;
+       int res;
+
+again:
+       res = doquery(impl_ver, REQ_AUTHINFO, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&ia, 0, 
+                     sizeof(struct info_auth));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!check1item(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_auth)))
+           return;
+
+       (void) fprintf(fp, "time since reset:     %ld\n",
+           (u_long)ntohl(ia->timereset));
+       (void) fprintf(fp, "stored keys:          %ld\n",
+           (u_long)ntohl(ia->numkeys));
+       (void) fprintf(fp, "free keys:            %ld\n",
+           (u_long)ntohl(ia->numfreekeys));
+       (void) fprintf(fp, "key lookups:          %ld\n",
+           (u_long)ntohl(ia->keylookups));
+       (void) fprintf(fp, "keys not found:       %ld\n",
+           (u_long)ntohl(ia->keynotfound));
+       (void) fprintf(fp, "uncached keys:        %ld\n",
+           (u_long)ntohl(ia->keyuncached));
+       (void) fprintf(fp, "encryptions:          %ld\n",
+           (u_long)ntohl(ia->encryptions));
+       (void) fprintf(fp, "decryptions:          %ld\n",
+           (u_long)ntohl(ia->decryptions));
+       (void) fprintf(fp, "expired keys:         %ld\n",
+           (u_long)ntohl(ia->expired));
+}
+
+
+
+/*
+ * traps - obtain and print a list of traps
+ */
+/*ARGSUSED*/
+static void
+traps(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int i;
+       struct info_trap *it;
+       struct sockaddr_storage trap_addr, local_addr;
+       int items;
+       int itemsize;
+       int res;
+
+again:
+       res = doquery(impl_ver, REQ_TRAPS, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&it, 0, 
+                     sizeof(struct info_trap));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!checkitems(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_trap)) &&
+           !checkitemsize(itemsize, v4sizeof(struct info_trap)))
+           return;
+
+       for (i = 0; i < items; i++ ) {
+               if (i != 0)
+                   (void) fprintf(fp, "\n");
+               memset((char *)&trap_addr, 0, sizeof(trap_addr));
+               memset((char *)&local_addr, 0, sizeof(local_addr));
+               if (it->v6_flag != 0) {
+                       GET_INADDR6(trap_addr) = it->trap_address6;
+                       GET_INADDR6(local_addr) = it->local_address6;
+                       trap_addr.ss_family = AF_INET6;
+                       local_addr.ss_family = AF_INET6;
+               } else {
+                       GET_INADDR(trap_addr) = it->trap_address;
+                       GET_INADDR(local_addr) = it->local_address;
+                       trap_addr.ss_family = AF_INET;
+                       local_addr.ss_family = AF_INET;
+               }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               trap_addr.ss_len = SOCKLEN(&trap_addr);
+               local_addr.ss_len = SOCKLEN(&local_addr);
+#endif
+               (void) fprintf(fp, "address %s, port %d\n",
+                               stoa(&trap_addr), 
+                               ntohs(it->trap_port));
+               (void) fprintf(fp, "interface: %s, ",
+                               (it->local_address == 0)
+                               ? "wildcard"
+                               : stoa(&local_addr));
+               if (ntohl(it->flags) & TRAP_CONFIGURED)
+                   (void) fprintf(fp, "configured\n");
+               else if (ntohl(it->flags) & TRAP_NONPRIO)
+                   (void) fprintf(fp, "low priority\n");
+               else
+                   (void) fprintf(fp, "normal priority\n");
+               
+               (void) fprintf(fp, "set for %ld secs, last set %ld secs ago\n",
+                              (long)ntohl(it->origtime),
+                              (long)ntohl(it->settime));
+               (void) fprintf(fp, "sequence %d, number of resets %ld\n",
+                              ntohs(it->sequence),
+                              (long)ntohl(it->resets));
+       }
+}
+
+
+/*
+ * addtrap - configure a trap
+ */
+static void
+addtrap(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       do_addclr_trap(pcmd, fp, REQ_ADD_TRAP);
+}
+
+
+/*
+ * clrtrap - clear a trap from the server
+ */
+static void
+clrtrap(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       do_addclr_trap(pcmd, fp, REQ_CLR_TRAP);
+}
+
+
+/*
+ * do_addclr_trap - do grunge work of adding/deleting traps
+ */
+static void
+do_addclr_trap(
+       struct parse *pcmd,
+       FILE *fp,
+       int req
+       )
+{
+       struct conf_trap ctrap;
+       int items;
+       int itemsize;
+       char *dummy;
+       int res;
+       int sendsize;
+
+again:
+       if (impl_ver == IMPL_XNTPD)
+               sendsize = sizeof(struct conf_trap);
+       else
+               sendsize = v4sizeof(struct conf_trap);
+
+       if (pcmd->argval[0].netnum.ss_family == AF_INET) {
+               ctrap.trap_address = GET_INADDR(pcmd->argval[0].netnum);
+               if (impl_ver == IMPL_XNTPD)
+                       ctrap.v6_flag = 0;
+       } else {
+               if (impl_ver == IMPL_XNTPD_OLD) {
+                       fprintf(stderr,
+                           "***Server doesn't understand IPv6 addresses\n");
+                       return;
+               }
+               ctrap.trap_address6 = GET_INADDR6(pcmd->argval[0].netnum);
+               ctrap.v6_flag = 1;
+       }
+       ctrap.local_address = 0;
+       ctrap.trap_port = htons(TRAPPORT);
+       ctrap.unused = 0;
+
+       if (pcmd->nargs > 1) {
+               ctrap.trap_port
+                       = htons((u_short)(pcmd->argval[1].uval & 0xffff));
+               if (pcmd->nargs > 2) {
+                       if (pcmd->argval[2].netnum.ss_family !=
+                           pcmd->argval[0].netnum.ss_family) {
+                               fprintf(stderr,
+                                   "***Cannot mix IPv4 and IPv6 addresses\n");
+                               return;
+                       }
+                       if (pcmd->argval[2].netnum.ss_family == AF_INET)
+                               ctrap.local_address = GET_INADDR(pcmd->argval[2].netnum);
+                       else
+                               ctrap.local_address6 = GET_INADDR6(pcmd->argval[2].netnum);
+               }
+       }
+
+       res = doquery(impl_ver, req, 1, 1, sendsize,
+                     (char *)&ctrap, &items, &itemsize, &dummy, 0, 
+                     sizeof(struct conf_trap));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+       return;
+}
+
+
+
+/*
+ * requestkey - change the server's request key (a dangerous request)
+ */
+static void
+requestkey(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       do_changekey(pcmd, fp, REQ_REQUEST_KEY);
+}
+
+
+/*
+ * controlkey - change the server's control key
+ */
+static void
+controlkey(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       do_changekey(pcmd, fp, REQ_CONTROL_KEY);
+}
+
+
+
+/*
+ * do_changekey - do grunge work of changing keys
+ */
+static void
+do_changekey(
+       struct parse *pcmd,
+       FILE *fp,
+       int req
+       )
+{
+       u_long key;
+       int items;
+       int itemsize;
+       char *dummy;
+       int res;
+
+
+       key = htonl((u_int32)pcmd->argval[0].uval);
+
+again:
+       res = doquery(impl_ver, req, 1, 1, sizeof(u_int32),
+                     (char *)&key, &items, &itemsize, &dummy, 0, 
+                     sizeof(dummy));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+       return;
+}
+
+
+
+/*
+ * ctlstats - obtain and print info about authentication
+ */
+/*ARGSUSED*/
+static void
+ctlstats(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_control *ic;
+       int items;
+       int itemsize;
+       int res;
+
+again:
+       res = doquery(impl_ver, REQ_GET_CTLSTATS, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&ic, 0, 
+                     sizeof(struct info_control));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!check1item(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_control)))
+           return;
+
+       (void) fprintf(fp, "time since reset:       %ld\n",
+                      (u_long)ntohl(ic->ctltimereset));
+       (void) fprintf(fp, "requests received:      %ld\n",
+                      (u_long)ntohl(ic->numctlreq));
+       (void) fprintf(fp, "responses sent:         %ld\n",
+                      (u_long)ntohl(ic->numctlresponses));
+       (void) fprintf(fp, "fragments sent:         %ld\n",
+                      (u_long)ntohl(ic->numctlfrags));
+       (void) fprintf(fp, "async messages sent:    %ld\n",
+                      (u_long)ntohl(ic->numasyncmsgs));
+       (void) fprintf(fp, "error msgs sent:        %ld\n",
+                      (u_long)ntohl(ic->numctlerrors));
+       (void) fprintf(fp, "total bad pkts:         %ld\n",
+                      (u_long)ntohl(ic->numctlbadpkts));
+       (void) fprintf(fp, "packet too short:       %ld\n",
+                      (u_long)ntohl(ic->numctltooshort));
+       (void) fprintf(fp, "response on input:      %ld\n",
+                      (u_long)ntohl(ic->numctlinputresp));
+       (void) fprintf(fp, "fragment on input:      %ld\n",
+                      (u_long)ntohl(ic->numctlinputfrag));
+       (void) fprintf(fp, "error set on input:     %ld\n",
+                      (u_long)ntohl(ic->numctlinputerr));
+       (void) fprintf(fp, "bad offset on input:    %ld\n",
+                      (u_long)ntohl(ic->numctlbadoffset));
+       (void) fprintf(fp, "bad version packets:    %ld\n",
+                      (u_long)ntohl(ic->numctlbadversion));
+       (void) fprintf(fp, "data in pkt too short:  %ld\n",
+                      (u_long)ntohl(ic->numctldatatooshort));
+       (void) fprintf(fp, "unknown op codes:       %ld\n",
+                      (u_long)ntohl(ic->numctlbadop));
+}
+
+
+/*
+ * clockstat - get and print clock status information
+ */
+static void
+clockstat(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_clock *cl;
+       /* 8 is the maximum number of clocks which will fit in a packet */
+       u_long clist[min(MAXARGS, 8)];
+       int qitems;
+       int items;
+       int itemsize;
+       int res;
+       l_fp ts;
+       struct clktype *clk;
+
+       for (qitems = 0; qitems < min(pcmd->nargs, 8); qitems++)
+           clist[qitems] = GET_INADDR(pcmd->argval[qitems].netnum);
+
+again:
+       res = doquery(impl_ver, REQ_GET_CLOCKINFO, 0, qitems,
+                     sizeof(u_int32), (char *)clist, &items,
+                     &itemsize, (void *)&cl, 0, sizeof(struct info_clock));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!checkitems(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_clock)))
+           return;
+
+       while (items-- > 0) {
+               (void) fprintf(fp, "clock address:        %s\n",
+                              numtoa(cl->clockadr));
+               for (clk = clktypes; clk->code >= 0; clk++)
+                   if (clk->code == cl->type)
+                       break;
+               if (clk->code >= 0)
+                   (void) fprintf(fp, "clock type:           %s\n",
+                                  clk->clocktype);
+               else
+                   (void) fprintf(fp, "clock type:           unknown type (%d)\n",
+                                  cl->type);
+               (void) fprintf(fp, "last event:           %d\n",
+                              cl->lastevent);
+               (void) fprintf(fp, "current status:       %d\n",
+                              cl->currentstatus);
+               (void) fprintf(fp, "number of polls:      %lu\n",
+                              (u_long)ntohl(cl->polls));
+               (void) fprintf(fp, "no response to poll:  %lu\n",
+                              (u_long)ntohl(cl->noresponse));
+               (void) fprintf(fp, "bad format responses: %lu\n",
+                              (u_long)ntohl(cl->badformat));
+               (void) fprintf(fp, "bad data responses:   %lu\n",
+                              (u_long)ntohl(cl->baddata));
+               (void) fprintf(fp, "running time:         %lu\n",
+                              (u_long)ntohl(cl->timestarted));
+               NTOHL_FP(&cl->fudgetime1, &ts);
+               (void) fprintf(fp, "fudge time 1:         %s\n",
+                              lfptoa(&ts, 6));
+               NTOHL_FP(&cl->fudgetime2, &ts);
+               (void) fprintf(fp, "fudge time 2:         %s\n",
+                              lfptoa(&ts, 6));
+               (void) fprintf(fp, "stratum:              %ld\n",
+                              (u_long)ntohl(cl->fudgeval1));
+               (void) fprintf(fp, "reference ID:         %s\n",
+                              refid_string(ntohl(cl->fudgeval2), 0));
+               (void) fprintf(fp, "fudge flags:          0x%x\n",
+                              cl->flags);
+
+               if (items > 0)
+                   (void) fprintf(fp, "\n");
+               cl++;
+       }
+}
+
+
+/*
+ * fudge - set clock fudge factors
+ */
+static void
+fudge(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct conf_fudge fudgedata;
+       int items;
+       int itemsize;
+       char *dummy;
+       l_fp ts;
+       int res;
+       long val;
+       u_long u_val;
+       int err;
+
+
+       err = 0;
+       memset((char *)&fudgedata, 0, sizeof fudgedata);
+       fudgedata.clockadr = GET_INADDR(pcmd->argval[0].netnum);
+
+       if (STREQ(pcmd->argval[1].string, "time1")) {
+               fudgedata.which = htonl(FUDGE_TIME1);
+               if (!atolfp(pcmd->argval[2].string, &ts))
+                   err = 1;
+               else
+                   NTOHL_FP(&ts, &fudgedata.fudgetime);
+       } else if (STREQ(pcmd->argval[1].string, "time2")) {
+               fudgedata.which = htonl(FUDGE_TIME2);
+               if (!atolfp(pcmd->argval[2].string, &ts))
+                   err = 1;
+               else
+                   NTOHL_FP(&ts, &fudgedata.fudgetime);
+       } else if (STREQ(pcmd->argval[1].string, "val1")) {
+               fudgedata.which = htonl(FUDGE_VAL1);
+               if (!atoint(pcmd->argval[2].string, &val))
+                   err = 1;
+               else
+                   fudgedata.fudgeval_flags = htonl(val);
+       } else if (STREQ(pcmd->argval[1].string, "val2")) {
+               fudgedata.which = htonl(FUDGE_VAL2);
+               if (!atoint(pcmd->argval[2].string, &val))
+                   err = 1;
+               else
+                   fudgedata.fudgeval_flags = htonl((u_int32)val);
+       } else if (STREQ(pcmd->argval[1].string, "flags")) {
+               fudgedata.which = htonl(FUDGE_FLAGS);
+               if (!hextoint(pcmd->argval[2].string, &u_val))
+                   err = 1;
+               else
+                   fudgedata.fudgeval_flags = htonl((u_int32)(u_val & 0xf));
+       } else {
+               (void) fprintf(stderr, "What fudge is %s?\n",
+                              pcmd->argval[1].string);
+               return;
+       }
+
+       if (err) {
+               (void) fprintf(stderr, "Unknown fudge parameter %s\n",
+                              pcmd->argval[2].string);
+               return;
+       }
+
+again:
+       res = doquery(impl_ver, REQ_SET_CLKFUDGE, 1, 1,
+                     sizeof(struct conf_fudge), (char *)&fudgedata, &items,
+                     &itemsize, &dummy, 0, sizeof(dummy));
+
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res == 0)
+           (void) fprintf(fp, "done!\n");
+       return;
+}
+
+/*
+ * clkbug - get and print clock debugging information
+ */
+static void
+clkbug(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       register int i;
+       register int n;
+       register u_int32 s;
+       struct info_clkbug *cl;
+       /* 8 is the maximum number of clocks which will fit in a packet */
+       u_long clist[min(MAXARGS, 8)];
+       u_int32 ltemp;
+       int qitems;
+       int items;
+       int itemsize;
+       int res;
+       int needsp;
+       l_fp ts;
+
+       for (qitems = 0; qitems < min(pcmd->nargs, 8); qitems++)
+           clist[qitems] = GET_INADDR(pcmd->argval[qitems].netnum);
+
+again:
+       res = doquery(impl_ver, REQ_GET_CLKBUGINFO, 0, qitems,
+                     sizeof(u_int32), (char *)clist, &items,
+                     &itemsize, (void *)&cl, 0, sizeof(struct info_clkbug));
+       
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+
+       if (!checkitems(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_clkbug)))
+           return;
+
+       while (items-- > 0) {
+               (void) fprintf(fp, "clock address:        %s\n",
+                              numtoa(cl->clockadr));
+               n = (int)cl->nvalues;
+               (void) fprintf(fp, "values: %d", n);
+               s = ntohs(cl->svalues);
+               if (n > NUMCBUGVALUES)
+                   n = NUMCBUGVALUES;
+               for (i = 0; i < n; i++) {
+                       ltemp = ntohl(cl->values[i]);
+                       ltemp &= 0xffffffff;    /* HMS: This does nothing now */
+                       if ((i & 0x3) == 0)
+                           (void) fprintf(fp, "\n");
+                       if (s & (1 << i))
+                           (void) fprintf(fp, "%12ld", (u_long)ltemp);
+                       else
+                           (void) fprintf(fp, "%12lu", (u_long)ltemp);
+               }
+               (void) fprintf(fp, "\n");
+
+               n = (int)cl->ntimes;
+               (void) fprintf(fp, "times: %d", n);
+               s = ntohl(cl->stimes);
+               if (n > NUMCBUGTIMES)
+                   n = NUMCBUGTIMES;
+               needsp = 0;
+               for (i = 0; i < n; i++) {
+                       if ((i & 0x1) == 0) {
+                           (void) fprintf(fp, "\n");
+                       } else {
+                               for (;needsp > 0; needsp--)
+                                   putc(' ', fp);
+                       }
+                       NTOHL_FP(&cl->times[i], &ts);
+                       if (s & (1 << i)) {
+                               (void) fprintf(fp, "%17s",
+                                              lfptoa(&ts, 6));
+                               needsp = 22;
+                       } else {
+                               (void) fprintf(fp, "%37s",
+                                              uglydate(&ts));
+                               needsp = 2;
+                       }
+               }
+               (void) fprintf(fp, "\n");
+               if (items > 0) {
+                       cl++;
+                       (void) fprintf(fp, "\n");
+               }
+       }
+}
+
+
+/*
+ * kerninfo - display the kernel pll/pps variables
+ */
+static void
+kerninfo(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_kernel *ik;
+       int items;
+       int itemsize;
+       int res;
+       unsigned status;
+       double tscale = 1e-6;
+
+again:
+       res = doquery(impl_ver, REQ_GET_KERNEL, 0, 0, 0, (char *)NULL,
+                     &items, &itemsize, (void *)&ik, 0, 
+                     sizeof(struct info_kernel));
+
+       if (res == INFO_ERR_IMPL && impl_ver == IMPL_XNTPD) {
+               impl_ver = IMPL_XNTPD_OLD;
+               goto again;
+       }
+
+       if (res != 0)
+           return;
+       if (!check1item(items, fp))
+           return;
+       if (!checkitemsize(itemsize, sizeof(struct info_kernel)))
+           return;
+
+       status = ntohs(ik->status) & 0xffff;
+       /*
+        * pll variables. We know more than we should about the NANO bit.
+        */
+#ifdef STA_NANO
+       if (status & STA_NANO)
+               tscale = 1e-9;
+#endif
+       (void)fprintf(fp, "pll offset:           %g s\n",
+           (int32_t)ntohl(ik->offset) * tscale);
+       (void)fprintf(fp, "pll frequency:        %s ppm\n",
+           fptoa((s_fp)ntohl(ik->freq), 3));
+       (void)fprintf(fp, "maximum error:        %g s\n",
+           (u_long)ntohl(ik->maxerror) * 1e-6);
+       (void)fprintf(fp, "estimated error:      %g s\n",
+           (u_long)ntohl(ik->esterror) * 1e-6);
+       (void)fprintf(fp, "status:               %04x ", status);
+#ifdef STA_PLL
+       if (status & STA_PLL) (void)fprintf(fp, " pll");
+#endif
+#ifdef STA_PPSFREQ
+       if (status & STA_PPSFREQ) (void)fprintf(fp, " ppsfreq");
+#endif
+#ifdef STA_PPSTIME
+       if (status & STA_PPSTIME) (void)fprintf(fp, " ppstime");
+#endif
+#ifdef STA_FLL
+       if (status & STA_FLL) (void)fprintf(fp, " fll");
+#endif
+#ifdef STA_INS
+       if (status & STA_INS) (void)fprintf(fp, " ins");
+#endif
+#ifdef STA_DEL
+       if (status & STA_DEL) (void)fprintf(fp, " del");
+#endif
+#ifdef STA_UNSYNC
+       if (status & STA_UNSYNC) (void)fprintf(fp, " unsync");
+#endif
+#ifdef STA_FREQHOLD
+       if (status & STA_FREQHOLD) (void)fprintf(fp, " freqhold");
+#endif
+#ifdef STA_PPSSIGNAL
+       if (status & STA_PPSSIGNAL) (void)fprintf(fp, " ppssignal");
+#endif
+#ifdef STA_PPSJITTER
+       if (status & STA_PPSJITTER) (void)fprintf(fp, " ppsjitter");
+#endif
+#ifdef STA_PPSWANDER
+       if (status & STA_PPSWANDER) (void)fprintf(fp, " ppswander");
+#endif
+#ifdef STA_PPSERROR
+       if (status & STA_PPSERROR) (void)fprintf(fp, " ppserror");
+#endif
+#ifdef STA_CLOCKERR
+       if (status & STA_CLOCKERR) (void)fprintf(fp, " clockerr");
+#endif
+#ifdef STA_NANO
+       if (status & STA_NANO) (void)fprintf(fp, " nano");
+#endif
+#ifdef STA_MODE
+       if (status & STA_MODE) (void)fprintf(fp, " mode=fll");
+#endif
+#ifdef STA_CLK
+       if (status & STA_CLK) (void)fprintf(fp, " src=B");
+#endif
+       (void)fprintf(fp, "\n");
+       (void)fprintf(fp, "pll time constant:    %ld\n",
+           (u_long)ntohl(ik->constant));
+       (void)fprintf(fp, "precision:            %g s\n",
+           (u_long)ntohl(ik->precision) * tscale);
+       (void)fprintf(fp, "frequency tolerance:  %s ppm\n",
+           fptoa((s_fp)ntohl(ik->tolerance), 0));
+
+       /*
+        * For backwards compatibility (ugh), we find the pps variables
+        * only if the shift member is nonzero.
+        */
+       if (!ik->shift)
+           return;
+
+       /*
+        * pps variables
+        */
+       (void)fprintf(fp, "pps frequency:        %s ppm\n",
+           fptoa((s_fp)ntohl(ik->ppsfreq), 3));
+       (void)fprintf(fp, "pps stability:        %s ppm\n",
+           fptoa((s_fp)ntohl(ik->stabil), 3));
+       (void)fprintf(fp, "pps jitter:           %g s\n",
+           (u_long)ntohl(ik->jitter) * tscale);
+       (void)fprintf(fp, "calibration interval: %d s\n",
+                     1 << ntohs(ik->shift));
+       (void)fprintf(fp, "calibration cycles:   %ld\n",
+                     (u_long)ntohl(ik->calcnt));
+       (void)fprintf(fp, "jitter exceeded:      %ld\n",
+                     (u_long)ntohl(ik->jitcnt));
+       (void)fprintf(fp, "stability exceeded:   %ld\n",
+                     (u_long)ntohl(ik->stbcnt));
+       (void)fprintf(fp, "calibration errors:   %ld\n",
+                     (u_long)ntohl(ik->errcnt));
+}
+
+#define IF_LIST_FMT     "%2d %c %48s %c %c %12.12s %03x %3d %2d %5d %5d %5d %2d %2d %3d %7d\n"
+#define IF_LIST_FMT_STR "%2s %c %48s %c %c %12.12s %3s %3s %2s %5s %5s %5s %2s %2s %3s %7s\n"
+#define IF_LIST_AFMT_STR "     %48s %c\n"
+#define IF_LIST_LABELS  "#", 'A', "Address/Mask/Broadcast", 'T', 'E', "IF name", "Flg", "TL", "#M", "recv", "sent", "drop", "S", "IX", "PC", "uptime"
+#define IF_LIST_LINE    "=====================================================================================================================\n"
+
+static void
+iflist(
+       FILE *fp,
+       struct info_if_stats *ifs,
+       int items,
+       int itemsize,
+       int res
+       )
+{
+       static char *actions = "?.+-";
+       struct sockaddr_storage saddr;
+
+       if (res != 0)
+           return;
+
+       if (!checkitems(items, fp))
+           return;
+
+       if (!checkitemsize(itemsize, sizeof(struct info_if_stats)))
+           return;
+
+       fprintf(fp, IF_LIST_FMT_STR, IF_LIST_LABELS);
+       fprintf(fp, IF_LIST_LINE);
+       
+       while (items > 0) {
+               if (ntohl(ifs->v6_flag)) {
+                       memcpy((char *)&GET_INADDR6(saddr), (char *)&ifs->unaddr.addr6, sizeof(ifs->unaddr.addr6));
+                       saddr.ss_family = AF_INET6;
+               } else {
+                       memcpy((char *)&GET_INADDR(saddr), (char *)&ifs->unaddr.addr, sizeof(ifs->unaddr.addr));
+                       saddr.ss_family = AF_INET;
+               }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               saddr.ss_len = SOCKLEN(&saddr);
+#endif
+               fprintf(fp, IF_LIST_FMT,
+                       ntohl(ifs->ifnum),
+                       actions[(ifs->action >= 1 && ifs->action < 4) ? ifs->action : 0],
+                       stoa((&saddr)), 'A',
+                       ifs->ignore_packets ? 'D' : 'E',
+                       ifs->name,
+                       ntohl(ifs->flags),
+                       ntohl(ifs->last_ttl),
+                       ntohl(ifs->num_mcast),
+                       ntohl(ifs->received),
+                       ntohl(ifs->sent),
+                       ntohl(ifs->notsent),
+                       ntohl(ifs->scopeid),
+                       ntohl(ifs->ifindex),
+                       ntohl(ifs->peercnt),
+                       ntohl(ifs->uptime));
+
+               if (ntohl(ifs->v6_flag)) {
+                       memcpy((char *)&GET_INADDR6(saddr), (char *)&ifs->unmask.addr6, sizeof(ifs->unmask.addr6));
+                       saddr.ss_family = AF_INET6;
+               } else {
+                       memcpy((char *)&GET_INADDR(saddr), (char *)&ifs->unmask.addr, sizeof(ifs->unmask.addr));
+                       saddr.ss_family = AF_INET;
+               }
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+               saddr.ss_len = SOCKLEN(&saddr);
+#endif
+               fprintf(fp, IF_LIST_AFMT_STR, stoa(&saddr), 'M');
+
+               if (!ntohl(ifs->v6_flag) && ntohl(ifs->flags) & (INT_BCASTOPEN)) {
+                       memcpy((char *)&GET_INADDR(saddr), (char *)&ifs->unbcast.addr, sizeof(ifs->unbcast.addr));
+                       saddr.ss_family = AF_INET;
+#ifdef HAVE_SA_LEN_IN_STRUCT_SOCKADDR
+                       saddr.ss_len = SOCKLEN(&saddr);
+#endif
+                       fprintf(fp, IF_LIST_AFMT_STR, stoa(&saddr), 'B');
+
+               }
+
+               ifs++;
+               items--;
+       }
+}
+
+/*ARGSUSED*/
+static void
+get_if_stats(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_if_stats *ifs;
+       int items;
+       int itemsize;
+       int res;
+
+       res = doquery(impl_ver, REQ_IF_STATS, 1, 0, 0, (char *)NULL, &items,
+                     &itemsize, (void *)&ifs, 0, 
+                     sizeof(struct info_if_stats));
+       iflist(fp, ifs, items, itemsize, res);
+}
+
+/*ARGSUSED*/
+static void
+do_if_reload(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct info_if_stats *ifs;
+       int items;
+       int itemsize;
+       int res;
+
+       res = doquery(impl_ver, REQ_IF_RELOAD, 1, 0, 0, (char *)NULL, &items,
+                     &itemsize, (void *)&ifs, 0, 
+                     sizeof(struct info_if_stats));
+       iflist(fp, ifs, items, itemsize, res);
+}
diff --git a/ntpq/Makefile.am b/ntpq/Makefile.am
new file mode 100644 (file)
index 0000000..7cd3f0a
--- /dev/null
@@ -0,0 +1,42 @@
+AUTOMAKE_OPTIONS=      ../util/ansi2knr
+
+bin_PROGRAMS=  ntpq
+AM_CPPFLAGS=   -I$(top_srcdir)/include $(LIBOPTS_CFLAGS)
+
+# LDADD might need RESLIB and ADJLIB
+ntpq_LDADD=    version.o @READLINE_LIBS@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+DISTCLEANFILES=        .version version.c
+noinst_HEADERS=        ntpq.h
+ETAGS_ARGS=    Makefile.am
+EXTRA_DIST=    ntpq-opts.def ntpq.1 ntpq-opts.texi ntpq-opts.menu
+BUILT_SOURCES= ntpq-opts.c ntpq-opts.h ntpq.1 ntpq-opts.texi ntpq-opts.menu
+man_MANS=      ntpq.1
+run_ag=         cd $(srcdir) && autogen -L ../include --writable
+std_def_list=  $(top_srcdir)/include/debug-opt.def             \
+               $(top_srcdir)/include/autogen-version.def       \
+               $(top_srcdir)/include/copyright.def             \
+               $(top_srcdir)/include/homerc.def                \
+               $(top_srcdir)/include/version.def
+ntpq_SOURCES=  ntpq.c ntpq-subs.c ntpq-opts.c ntpq-opts.h
+
+$(srcdir)/ntpq-opts.h: $(srcdir)/ntpq-opts.c
+$(srcdir)/ntpq-opts.c: $(srcdir)/ntpq-opts.def $(std_def_list)
+       $(run_ag) ntpq-opts.def
+
+$(srcdir)/ntpq.1: $(srcdir)/ntpq-opts.def $(std_def_list)
+       $(run_ag) -Tagman1.tpl -bntpq ntpq-opts.def
+
+$(srcdir)/ntpq-opts.texi $(srcdir)/ntpq-opts.menu: $(srcdir)/ntpq-opts.def $(std_def_list)
+       $(run_ag) -Taginfo.tpl -DLEVEL=section ntpq-opts.def
+
+$(PROGRAMS): $(LDADD)
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE)
+
+$(top_srcdir)/version :
+       cd $(top_srcdir) && $(MAKE) version
+
+version.o: $(ntpq_OBJECTS) ../libntp/libntp.a Makefile $(top_srcdir)/version
+       env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpq
+       $(COMPILE) -c version.c
diff --git a/ntpq/Makefile.in b/ntpq/Makefile.in
new file mode 100644 (file)
index 0000000..0c5fcae
--- /dev/null
@@ -0,0 +1,673 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+ANSI2KNR = ../util/ansi2knr
+bin_PROGRAMS = ntpq$(EXEEXT)
+subdir = ntpq
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
+PROGRAMS = $(bin_PROGRAMS)
+am_ntpq_OBJECTS = ntpq$U.$(OBJEXT) ntpq-subs$U.$(OBJEXT) \
+       ntpq-opts$U.$(OBJEXT)
+ntpq_OBJECTS = $(am_ntpq_OBJECTS)
+am__DEPENDENCIES_1 =
+ntpq_DEPENDENCIES = version.o $(am__DEPENDENCIES_1) ../libntp/libntp.a
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(ntpq_SOURCES)
+DIST_SOURCES = $(ntpq_SOURCES)
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+man1dir = $(mandir)/man1
+NROFF = nroff
+MANS = $(man_MANS)
+HEADERS = $(noinst_HEADERS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+AM_CPPFLAGS = -I$(top_srcdir)/include $(LIBOPTS_CFLAGS)
+
+# LDADD might need RESLIB and ADJLIB
+ntpq_LDADD = version.o @READLINE_LIBS@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+DISTCLEANFILES = .version version.c
+noinst_HEADERS = ntpq.h
+ETAGS_ARGS = Makefile.am
+EXTRA_DIST = ntpq-opts.def ntpq.1 ntpq-opts.texi ntpq-opts.menu
+BUILT_SOURCES = ntpq-opts.c ntpq-opts.h ntpq.1 ntpq-opts.texi ntpq-opts.menu
+man_MANS = ntpq.1
+run_ag = cd $(srcdir) && autogen -L ../include --writable
+std_def_list = $(top_srcdir)/include/debug-opt.def             \
+               $(top_srcdir)/include/autogen-version.def       \
+               $(top_srcdir)/include/copyright.def             \
+               $(top_srcdir)/include/homerc.def                \
+               $(top_srcdir)/include/version.def
+
+ntpq_SOURCES = ntpq.c ntpq-subs.c ntpq-opts.c ntpq-opts.h
+all: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign ntpq/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign ntpq/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p || test -f $$p1; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+           echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+           $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+       @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+ntpq$(EXEEXT): $(ntpq_OBJECTS) $(ntpq_DEPENDENCIES) 
+       @rm -f ntpq$(EXEEXT)
+       $(LINK) $(ntpq_OBJECTS) $(ntpq_LDADD) $(LIBS)
+
+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)/ntpq$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpq-opts$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntpq-subs$U.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+ntpq_.c: ntpq.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpq.c; then echo $(srcdir)/ntpq.c; else echo ntpq.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpq-opts_.c: ntpq-opts.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpq-opts.c; then echo $(srcdir)/ntpq-opts.c; else echo ntpq-opts.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpq-subs_.c: ntpq-subs.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntpq-subs.c; then echo $(srcdir)/ntpq-subs.c; else echo ntpq-subs.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntpq_.$(OBJEXT) ntpq_.lo ntpq-opts_.$(OBJEXT) ntpq-opts_.lo \
+ntpq-subs_.$(OBJEXT) ntpq-subs_.lo : $(ANSI2KNR)
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-man1: $(man_MANS)
+       @$(NORMAL_INSTALL)
+       test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+       @list=''; test -n "$(man1dir)" || exit 0; \
+       { for i in $$list; do echo "$$i"; done; \
+       l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.1[a-z]*$$/p'; \
+       } | while read p; do \
+         if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; echo "$$p"; \
+       done | \
+       sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+       sed 'N;N;s,\n, ,g' | { \
+       list=; while read file base inst; do \
+         if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+         fi; \
+       done; \
+       for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+       while read files; do \
+         test -z "$$files" || { \
+           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+           $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+       done; }
+
+uninstall-man1:
+       @$(NORMAL_UNINSTALL)
+       @list=''; test -n "$(man1dir)" || exit 0; \
+       files=`{ for i in $$list; do echo "$$i"; done; \
+       l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.1[a-z]*$$/p'; \
+       } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @list='$(MANS)'; if test -n "$$list"; then \
+         list=`for p in $$list; do \
+           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+           if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+         if test -n "$$list" && \
+           grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+           echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+           grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/         /' >&2; \
+           echo "       to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+           echo "       typically \`make maintainer-clean' will remove them" >&2; \
+           exit 1; \
+         else :; fi; \
+       else :; fi
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(PROGRAMS) $(MANS) $(HEADERS)
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+       -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+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-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man1
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-man
+
+uninstall-man: uninstall-man1
+
+.MAKE: ../util/ansi2knr all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+       clean-generic clean-libtool ctags distclean distclean-compile \
+       distclean-generic distclean-libtool distclean-tags distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-binPROGRAMS 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-man1 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 uninstall-binPROGRAMS uninstall-man \
+       uninstall-man1
+
+
+$(srcdir)/ntpq-opts.h: $(srcdir)/ntpq-opts.c
+$(srcdir)/ntpq-opts.c: $(srcdir)/ntpq-opts.def $(std_def_list)
+       $(run_ag) ntpq-opts.def
+
+$(srcdir)/ntpq.1: $(srcdir)/ntpq-opts.def $(std_def_list)
+       $(run_ag) -Tagman1.tpl -bntpq ntpq-opts.def
+
+$(srcdir)/ntpq-opts.texi $(srcdir)/ntpq-opts.menu: $(srcdir)/ntpq-opts.def $(std_def_list)
+       $(run_ag) -Taginfo.tpl -DLEVEL=section ntpq-opts.def
+
+$(PROGRAMS): $(LDADD)
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE)
+
+$(top_srcdir)/version :
+       cd $(top_srcdir) && $(MAKE) version
+
+version.o: $(ntpq_OBJECTS) ../libntp/libntp.a Makefile $(top_srcdir)/version
+       env CSET=`cat $(top_srcdir)/version` $(top_builddir)/scripts/mkver ntpq
+       $(COMPILE) -c version.c
+
+# 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.
+.NOEXPORT:
diff --git a/ntpq/README b/ntpq/README
new file mode 100644 (file)
index 0000000..d280f74
--- /dev/null
@@ -0,0 +1,6 @@
+README file for directory ./ntpq of the NTP Version 4 distribution
+
+This directory contains the sources for the ntpq utility program. See
+the README and RELNOTES files in the parent directory for directions on
+how to make and install this program. The current version number of this
+program is in the version.c file.
diff --git a/ntpq/ntpq-opts.c b/ntpq/ntpq-opts.c
new file mode 100644 (file)
index 0000000..868ef29
--- /dev/null
@@ -0,0 +1,607 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.c)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:26 AM EST
+ *  From the definitions    ntpq-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This source file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  ntpq author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * ntpq copyright 1970-2009 David L. Mills and/or others - all rights reserved
+ *
+ * see html/copyright.html
+ */
+
+
+#include <limits.h>
+
+#define OPTION_CODE_COMPILE 1
+#include "ntpq-opts.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+tSCC zCopyright[] =
+       "ntpq copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved";
+tSCC zCopyrightNotice[] =
+       
+/* extracted from ../include/copyright.def near line 8 */
+"see html/copyright.html";
+extern tUsageProc optionUsage;
+
+/*
+ *  global included definitions
+ */
+#ifdef __windows
+  extern int atoi(const char*);
+#else
+# include <stdlib.h>
+#endif
+
+#ifndef NULL
+#  define NULL 0
+#endif
+#ifndef EXIT_SUCCESS
+#  define  EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#  define  EXIT_FAILURE 1
+#endif
+/*
+ *  Ipv4 option description:
+ */
+tSCC    zIpv4Text[] =
+        "Force IPv4 DNS name resolution";
+tSCC    zIpv4_NAME[]               = "IPV4";
+tSCC    zIpv4_Name[]               = "ipv4";
+#define IPV4_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Ipv6 option description:
+ */
+tSCC    zIpv6Text[] =
+        "Force IPv6 DNS name resolution";
+tSCC    zIpv6_NAME[]               = "IPV6";
+tSCC    zIpv6_Name[]               = "ipv6";
+#define IPV6_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Command option description:
+ */
+tSCC    zCommandText[] =
+        "run a command and exit";
+tSCC    zCommand_NAME[]            = "COMMAND";
+tSCC    zCommand_Name[]            = "command";
+#define COMMAND_FLAGS       (OPTST_DISABLED | OPTST_STACKED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Debug_Level option description:
+ */
+#ifdef DEBUG
+tSCC    zDebug_LevelText[] =
+        "Increase output debug message level";
+tSCC    zDebug_Level_NAME[]        = "DEBUG_LEVEL";
+tSCC    zDebug_Level_Name[]        = "debug-level";
+#define DEBUG_LEVEL_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Debug_Level */
+#define VALUE_OPT_DEBUG_LEVEL NO_EQUIVALENT
+#define DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zDebug_LevelText       NULL
+#define zDebug_Level_NAME      NULL
+#define zDebug_Level_Name      NULL
+#endif  /* DEBUG */
+
+/*
+ *  Set_Debug_Level option description:
+ */
+#ifdef DEBUG
+tSCC    zSet_Debug_LevelText[] =
+        "Set the output debug message level";
+tSCC    zSet_Debug_Level_NAME[]    = "SET_DEBUG_LEVEL";
+tSCC    zSet_Debug_Level_Name[]    = "set-debug-level";
+#define SET_DEBUG_LEVEL_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+#else   /* disable Set_Debug_Level */
+#define VALUE_OPT_SET_DEBUG_LEVEL NO_EQUIVALENT
+#define SET_DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zSet_Debug_LevelText       NULL
+#define zSet_Debug_Level_NAME      NULL
+#define zSet_Debug_Level_Name      NULL
+#endif  /* DEBUG */
+
+/*
+ *  Peers option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zPeersText[] =
+        "Print a list of the peers";
+tSCC    zPeers_NAME[]              = "PEERS";
+tSCC    zPeers_Name[]              = "peers";
+static const int
+    aPeersCantList[] = {
+    INDEX_OPT_INTERACTIVE, NO_EQUIVALENT };
+#define PEERS_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Interactive option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zInteractiveText[] =
+        "Force ntpq to operate in interactive mode";
+tSCC    zInteractive_NAME[]        = "INTERACTIVE";
+tSCC    zInteractive_Name[]        = "interactive";
+static const int
+    aInteractiveCantList[] = {
+    INDEX_OPT_COMMAND,
+    INDEX_OPT_PEERS, NO_EQUIVALENT };
+#define INTERACTIVE_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Numeric option description:
+ */
+tSCC    zNumericText[] =
+        "numeric host addresses";
+tSCC    zNumeric_NAME[]            = "NUMERIC";
+tSCC    zNumeric_Name[]            = "numeric";
+#define NUMERIC_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Help/More_Help/Version option descriptions:
+ */
+tSCC zHelpText[]       = "Display usage information and exit";
+tSCC zHelp_Name[]      = "help";
+
+tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
+tSCC zMore_Help_Name[] = "more-help";
+
+tSCC zVersionText[]    = "Output version information and exit";
+tSCC zVersion_Name[]   = "version";
+
+/*
+ *  Save/Load_Opts option description:
+ */
+tSCC zSave_OptsText[]     = "Save the option state to a config file";
+tSCC zSave_Opts_Name[]    = "save-opts";
+
+tSCC zLoad_OptsText[]     = "Load options from a config file";
+tSCC zLoad_Opts_NAME[]    = "LOAD_OPTS";
+
+tSCC zNotLoad_Opts_Name[] = "no-load-opts";
+tSCC zNotLoad_Opts_Pfx[]  = "no";
+#define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
+/*
+ *  Declare option callback procedures
+ */
+#ifdef DEBUG
+  static tOptProc doOptSet_Debug_Level;
+#else /* not DEBUG */
+# define doOptSet_Debug_Level NULL
+#endif /* def/not DEBUG */
+#if defined(TEST_NTPQ_OPTS)
+/*
+ *  Under test, omit argument processing, or call optionStackArg,
+ *  if multiple copies are allowed.
+ */
+extern tOptProc
+    optionPagedUsage, optionStackArg, optionVersionStderr;
+static tOptProc
+    doUsageOpt;
+
+/*
+ *  #define map the "normal" callout procs to the test ones...
+ */
+#define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
+
+
+#else /* NOT defined TEST_NTPQ_OPTS */
+/*
+ *  When not under test, there are different procs to use
+ */
+extern tOptProc
+    optionPagedUsage, optionPrintVersion, optionStackArg;
+static tOptProc
+    doUsageOpt;
+
+/*
+ *  #define map the "normal" callout procs
+ */
+#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
+
+#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
+#endif /* defined(TEST_NTPQ_OPTS) */
+#ifdef TEST_NTPQ_OPTS
+# define DOVERPROC optionVersionStderr
+#else
+# define DOVERPROC optionPrintVersion
+#endif /* TEST_NTPQ_OPTS */
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Ntpq Option Descriptions.
+ */
+static tOptDesc optDesc[ OPTION_CT ] = {
+  {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
+     /* equiv idx, value */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IPV4_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
+     /* equiv idx, value */ NOLIMIT, NOLIMIT,
+     /* equivalenced to  */ INDEX_OPT_IPV4,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IPV6_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 2, VALUE_OPT_COMMAND,
+     /* equiv idx, value */ 2, VALUE_OPT_COMMAND,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ COMMAND_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionStackArg,
+     /* desc, NAME, name */ zCommandText, zCommand_NAME, zCommand_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 3, VALUE_OPT_DEBUG_LEVEL,
+     /* equiv idx, value */ 3, VALUE_OPT_DEBUG_LEVEL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ DEBUG_LEVEL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 4, VALUE_OPT_SET_DEBUG_LEVEL,
+     /* equiv idx, value */ 4, VALUE_OPT_SET_DEBUG_LEVEL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ SET_DEBUG_LEVEL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ SET_DEBUG_LEVEL_OPT_PROC,
+     /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 5, VALUE_OPT_PEERS,
+     /* equiv idx, value */ 5, VALUE_OPT_PEERS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PEERS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aPeersCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPeersText, zPeers_NAME, zPeers_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 6, VALUE_OPT_INTERACTIVE,
+     /* equiv idx, value */ 6, VALUE_OPT_INTERACTIVE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ INTERACTIVE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aInteractiveCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zInteractiveText, zInteractive_NAME, zInteractive_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 7, VALUE_OPT_NUMERIC,
+     /* equiv idx, value */ 7, VALUE_OPT_NUMERIC,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ NUMERIC_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zNumericText, zNumeric_NAME, zNumeric_Name,
+     /* disablement strs */ NULL, NULL },
+
+#ifdef NO_OPTIONAL_OPT_ARGS
+#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
+#else
+#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
+                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
+#endif
+
+  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ DOVERPROC,
+     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
+     /* disablement strs */ NULL, NULL },
+
+#undef VERSION_OPT_FLAGS
+
+
+  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doUsageOpt,
+     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ optionPagedUsage,
+     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
+                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
+                         | OPTST_DISABLE_IMM, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionLoadOpt,
+     /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
+     /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
+};
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Ntpq Option Environment
+ */
+tSCC   zPROGNAME[]   = "NTPQ";
+tSCC   zUsageTitle[] =
+"ntpq - standard NTP query program - Ver. 4.2.4p8\n\
+USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]... [ host ...]\n";
+tSCC   zRcName[]     = ".ntprc";
+tSCC*  apzHomeList[] = {
+       "$HOME",
+       ".",
+       NULL };
+
+tSCC   zBugsAddr[]    = "http://bugs.ntp.org, bugs@ntp.org";
+#define zExplain NULL
+tSCC    zDetail[]     = "\n\
+The\n\
+[= prog-name =]\n\
+utility program is used to query NTP servers which\n\
+implement the standard NTP mode 6 control message formats defined\n\
+in Appendix B of the NTPv3 specification RFC1305, requesting\n\
+information about current state and/or changes in that state.\n\
+The same formats are used in NTPv4, although some of the\n\
+variables have changed and new ones added.\n";
+tSCC    zFullVersion[] = NTPQ_FULL_VERSION;
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
+
+#if defined(ENABLE_NLS)
+# define OPTPROC_BASE OPTPROC_TRANSLATE
+  static tOptionXlateProc translate_option_strings;
+#else
+# define OPTPROC_BASE OPTPROC_NONE
+# define translate_option_strings NULL
+#endif /* ENABLE_NLS */
+
+tOptions ntpqOptions = {
+    OPTIONS_STRUCT_VERSION,
+    0, NULL,                    /* original argc + argv    */
+    ( OPTPROC_BASE
+    + OPTPROC_ERRSTOP
+    + OPTPROC_SHORTOPT
+    + OPTPROC_LONGOPT
+    + OPTPROC_NO_REQ_OPT
+    + OPTPROC_ENVIRON
+    + OPTPROC_HAS_IMMED ),
+    0, NULL,                    /* current option index, current option */
+    NULL,         NULL,         zPROGNAME,
+    zRcName,      zCopyright,   zCopyrightNotice,
+    zFullVersion, apzHomeList,  zUsageTitle,
+    zExplain,     zDetail,      optDesc,
+    zBugsAddr,                  /* address to send bugs to */
+    NULL, NULL,                 /* extensions/saved state  */
+    optionUsage,       /* usage procedure */
+    translate_option_strings,   /* translation procedure */
+    /*
+     *  Indexes to special options
+     */
+    { INDEX_OPT_MORE_HELP,
+      INDEX_OPT_SAVE_OPTS,
+      NO_EQUIVALENT /* index of '-#' option */,
+      NO_EQUIVALENT /* index of default opt */
+    },
+    13 /* full option count */, 8 /* user option count */
+};
+
+/*
+ *  Create the static procedure(s) declared above.
+ */
+static void
+doUsageOpt(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    USAGE( EXIT_SUCCESS );
+}
+
+#if ! defined(TEST_NTPQ_OPTS)
+
+/* * * * * * *
+ *
+ *   For the set-debug-level option, when DEBUG is #define-d.
+ */
+#ifdef DEBUG
+static void
+doOptSet_Debug_Level(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    /* extracted from ../include/debug-opt.def, line 29 */
+DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
+}
+#endif /* defined DEBUG */
+
+#endif /* defined(TEST_NTPQ_OPTS) */
+
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
+
+#if defined(TEST_NTPQ_OPTS) /* TEST MAIN PROCEDURE: */
+
+int
+main( int argc, char** argv )
+{
+    int res = EXIT_SUCCESS;
+    (void)optionProcess( &ntpqOptions, argc, argv );
+    {
+        void optionPutShell( tOptions* );
+        optionPutShell( &ntpqOptions );
+    }
+    return res;
+}
+#endif  /* defined TEST_NTPQ_OPTS */
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
+
+#if ENABLE_NLS
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <autoopts/usage-txt.h>
+
+static char* AO_gettext( char const* pz );
+static void  coerce_it(void** s);
+
+static char*
+AO_gettext( char const* pz )
+{
+    char* pzRes;
+    if (pz == NULL)
+        return NULL;
+    pzRes = _(pz);
+    if (pzRes == pz)
+        return pzRes;
+    pzRes = strdup( pzRes );
+    if (pzRes == NULL) {
+        fputs( _("No memory for duping translated strings\n"), stderr );
+        exit( EXIT_FAILURE );
+    }
+    return pzRes;
+}
+
+static void coerce_it(void** s) { *s = AO_gettext(*s); }
+#define COERSION(_f) \
+  coerce_it((void*)&(ntpqOptions._f))
+
+/*
+ *  This invokes the translation code (e.g. gettext(3)).
+ */
+static void
+translate_option_strings( void )
+{
+    /*
+     *  Guard against re-translation.  It won't work.  The strings will have
+     *  been changed by the first pass through this code.  One shot only.
+     */
+    if (option_usage_text.field_ct == 0)
+        return;
+    /*
+     *  Do the translations.  The first pointer follows the field count field.
+     *  The field count field is the size of a pointer.
+     */
+    {
+        char** ppz = (char**)(void*)&(option_usage_text);
+        int    ix  = option_usage_text.field_ct;
+
+        do {
+            ppz++;
+            *ppz = AO_gettext(*ppz);
+        } while (--ix > 0);
+    }
+    option_usage_text.field_ct = 0;
+
+    {
+        tOptDesc* pOD = ntpqOptions.pOptDesc;
+        int       ix  = ntpqOptions.optCt;
+
+        for (;;) {
+            pOD->pzText           = AO_gettext(pOD->pzText);
+            pOD->pz_NAME          = AO_gettext(pOD->pz_NAME);
+            pOD->pz_Name          = AO_gettext(pOD->pz_Name);
+            pOD->pz_DisableName   = AO_gettext(pOD->pz_DisableName);
+            pOD->pz_DisablePfx    = AO_gettext(pOD->pz_DisablePfx);
+            if (--ix <= 0)
+                break;
+            pOD++;
+        }
+    }
+    COERSION(pzCopyright);
+    COERSION(pzCopyNotice);
+    COERSION(pzFullVersion);
+    COERSION(pzUsageTitle);
+    COERSION(pzExplain);
+    COERSION(pzDetail);
+}
+
+#endif /* ENABLE_NLS */
+
+#ifdef  __cplusplus
+}
+#endif
+/* ntpq-opts.c ends here */
diff --git a/ntpq/ntpq-opts.def b/ntpq/ntpq-opts.def
new file mode 100644 (file)
index 0000000..928bd9d
--- /dev/null
@@ -0,0 +1,345 @@
+/* -*- Mode: Text -*- */
+
+autogen definitions options;
+
+#include copyright.def
+#include homerc.def
+#include autogen-version.def
+
+prog-name      = "ntpq";
+prog-title     = "standard NTP query program";
+argument       = '[ host ...]';
+
+test-main;
+
+flag = {
+    name      = ipv4;
+    value     = 4;
+    equivalence = ipv4;
+    descrip   = "Force IPv4 DNS name resolution";
+    doc = <<-  _EndOfDoc_
+       Force DNS resolution of following host names on the command line
+       to the IPv4 namespace.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = ipv6;
+    value     = 6;
+    equivalence = ipv4;
+    descrip   = "Force IPv6 DNS name resolution";
+    doc = <<-  _EndOfDoc_
+       Force DNS resolution of following host names on the command line
+       to the IPv6 namespace.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = command;
+    value     = c;
+    arg-type  = string;
+    descrip   = "run a command and exit";
+    max       = NOLIMIT;
+    arg-name  = cmd;
+    stack-arg;
+    doc = <<-  _EndOfDoc_
+       The following argument is interpreted as an interactive format command
+       and is added to the list of commands to be executed on the specified
+       host(s).
+       _EndOfDoc_;
+};
+
+#include debug-opt.def
+
+flag = {
+    name      = peers;
+    value     = p;
+    descrip   = "Print a list of the peers";
+    flags-cant = interactive;
+    doc = <<-  _EndOfDoc_
+       Print a list of the peers known to the server as well as a summary
+       of their state. This is equivalent to the 'peers' interactive command.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = interactive;
+    value     = i;
+    flags-cant = command, peers;
+    descrip   = "Force ntpq to operate in interactive mode";
+    doc = <<-  _EndOfDoc_
+       Force ntpq to operate in interactive mode.  Prompts will be written
+       to the standard output and commands read from the standard input.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = numeric;
+    value     = n;
+    descrip   = "numeric host addresses";
+    doc = <<-  _EndOfDoc_
+       Output all host addresses in dotted-quad numeric format rather than
+       converting to the canonical host names. 
+       _EndOfDoc_;
+};
+
+detail = <<-  _END_DETAIL
+       The
+       [= prog-name =]
+       utility program is used to query NTP servers which
+       implement the standard NTP mode 6 control message formats defined
+       in Appendix B of the NTPv3 specification RFC1305, requesting
+       information about current state and/or changes in that state.
+       The same formats are used in NTPv4, although some of the
+       variables have changed and new ones added.
+       _END_DETAIL;
+
+prog-man-descrip = <<-  _END_PROG_MAN_DESCRIP
+       The
+       [= prog-name =]
+       utility program is used to query NTP servers which
+       implement the standard NTP mode 6 control message formats defined
+       in Appendix B of the NTPv3 specification RFC1305, requesting
+       information about current state and/or changes in that state.
+       The same formats are used in NTPv4, although some of the
+       variables have changed and new ones added. The description on this
+       page is for the NTPv4 variables.
+       The program may be run either in interactive mode or controlled using
+       command line arguments.
+       Requests to read and write arbitrary
+       variables can be assembled, with raw and pretty-printed output
+       options being available.
+       The
+       [= prog-name =]
+       utility can also obtain and print a
+       list of peers in a common format by sending multiple queries to the
+       server.
+
+       If one or more request options is included on the command line
+       when
+       [= prog-name =]
+       is executed, each of the requests will be sent
+       to the NTP servers running on each of the hosts given as command
+       line arguments, or on localhost by default.
+       If no request options
+       are given,
+       [= prog-name =]
+       will attempt to read commands from the
+       standard input and execute these on the NTP server running on the
+       first host given on the command line, again defaulting to localhost
+       when no other host is specified.
+       The
+       [= prog-name =]
+       utility will prompt for
+       commands if the standard input is a terminal device.
+
+       The
+       [= prog-name =]
+       utility uses NTP mode 6 packets to communicate with the
+       NTP server, and hence can be used to query any compatible server on
+       the network which permits it.
+       Note that since NTP is a UDP protocol
+       this communication will be somewhat unreliable, especially over
+       large distances in terms of network topology.
+       The
+       [= prog-name =]
+       utility makes
+       one attempt to retransmit requests, and will time requests out if
+       the remote host is not heard from within a suitable timeout
+       time.
+
+       Specifying a
+       command line option other than
+       .Fl i
+       or
+       .Fl n
+       will
+       cause the specified query (queries) to be sent to the indicated
+       host(s) immediately.
+       Otherwise,
+       [= prog-name =]  
+       will attempt to read
+       interactive format commands from the standard input.
+       .Ss "Internal Commands"
+       Interactive format commands consist of a keyword followed by zero
+       to four arguments.
+       Only enough characters of the full keyword to
+       uniquely identify the command need be typed.
+
+       A
+       number of interactive format commands are executed entirely within
+       the
+       [= prog-name =]
+       utility itself and do not result in NTP mode 6
+       requests being sent to a server.
+       These are described following.
+       @table @code
+       @item ? [command_keyword]
+       @itemx help [command_keyword]
+       A
+       .Ql \&?
+       by itself will print a list of all the command
+       keywords known to this incarnation of
+       [= prog-name =] .
+       A
+       .Ql \&?
+       followed by a command keyword will print function and usage
+       information about the command.
+       This command is probably a better
+       source of information about
+       [= prog-name =]
+       than this manual
+       page.
+       @item addvars
+       .Ar variable_name [=value] ...
+       .Xc
+       @item rmvars variable_name ...
+       @item clearvars
+       The data carried by NTP mode 6 messages consists of a list of
+       items of the form
+       .Ql variable_name=value ,
+       where the
+       .Ql =value
+       is ignored, and can be omitted,
+       in requests to the server to read variables.
+       The
+       [= prog-name =]
+       utility maintains an internal list in which data to be included in control
+       messages can be assembled, and sent using the
+       .Ic readlist
+       and
+       .Ic writelist
+       commands described below.
+       The
+       .Ic addvars
+       command allows variables and their optional values to be added to
+       the list.
+       If more than one variable is to be added, the list should
+       be comma-separated and not contain white space.
+       The
+       .Ic rmvars
+       command can be used to remove individual variables from the list,
+       while the
+       .Ic clearlist
+       command removes all variables from the
+       list.
+       @item authenticate [ yes | no ]
+       Normally
+       [= prog-name =]
+       does not authenticate requests unless
+       they are write requests.
+       The command
+       .Ql authenticate yes
+       causes
+       [= prog-name =]
+       to send authentication with all requests it
+       makes.
+       Authenticated requests causes some servers to handle
+       requests slightly differently, and can occasionally melt the CPU in
+       fuzzballs if you turn authentication on before doing a
+       .Ic peer
+       display.
+       The command
+       .Ql authenticate
+       causes
+       [= prog-name =]
+       to display whether or not
+       [= prog-name =]
+       is currently autheinticating requests.
+       @item cooked
+       Causes output from query commands to be "cooked", so that
+       variables which are recognized by
+       [= prog-name =]
+       will have their
+       values reformatted for human consumption.
+       Variables which
+       [= prog-name =]
+       thinks should have a decodable value but didn't are
+       marked with a trailing
+       .Ql \&? .
+       .@item debug [
+       .Cm more |
+       .Cm less |
+       .Cm off
+       ]
+       .Xc
+       With no argument, displays the current debug level.
+       Otherwise, the debug level is changed to the indicated level.
+       @item delay milliseconds
+       Specify a time interval to be added to timestamps included in
+       requests which require authentication.
+       This is used to enable
+       (unreliable) server reconfiguration over long delay network paths
+       or between machines whose clocks are unsynchronized.
+       Actually the
+       server does not now require timestamps in authenticated requests,
+       so this command may be obsolete.
+       @item host hostname
+       Set the host to which future queries will be sent.
+       Hostname may
+       be either a host name or a numeric address.
+       @item hostnames Cm yes | Cm no
+       If
+       .Cm yes
+       is specified, host names are printed in
+       information displays.
+       If
+       .Cm no
+       is specified, numeric
+       addresses are printed instead.
+       The default is
+       .Cm yes ,
+       unless
+       modified using the command line
+       .Fl n
+       switch.
+       @item keyid keyid
+       This command allows the specification of a key number to be
+       used to authenticate configuration requests.
+       This must correspond
+       to a key number the server has been configured to use for this
+       purpose.
+       @item ntpversion [
+       .Cm 1 |
+       .Cm 2 |
+       .Cm 3 |
+       .Cm 4
+       ]
+       .Xc
+       Sets the NTP version number which
+       [= prog-name =]
+       claims in
+       packets.
+       Defaults to 3, Note that mode 6 control messages (and
+       modes, for that matter) didn't exist in NTP version 1.
+       There appear
+       to be no servers left which demand version 1.
+       With no argument, displays the current NTP version that will be used
+       when communicating with servers.
+       @item quit
+       Exit
+       [= prog-name =] .
+       @item passwd
+       This command prompts you to type in a password (which will not
+       be echoed) which will be used to authenticate configuration
+       requests.
+       The password must correspond to the key configured for
+       use by the NTP server for this purpose if such requests are to be
+       successful.
+       @item raw
+       Causes all output from query commands is printed as received
+       from the remote server.
+       The only formating/interpretation done on
+       the data is to transform nonascii data into a printable (but barely
+       understandable) form.
+       @item timeout Ar milliseconds
+       Specify a timeout period for responses to server queries.
+       The
+       default is about 5000 milliseconds.
+       Note that since
+       [= prog-name =]
+       retries each query once after a timeout, the total waiting time for
+       a timeout will be twice the timeout value set.
+       @end table
+
+       _END_PROG_MAN_DESCRIP;
diff --git a/ntpq/ntpq-opts.h b/ntpq/ntpq-opts.h
new file mode 100644 (file)
index 0000000..2badce7
--- /dev/null
@@ -0,0 +1,208 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (ntpq-opts.h)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:26 AM EST
+ *  From the definitions    ntpq-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This header file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  ntpq author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * ntpq copyright 1970-2009 David L. Mills and/or others - all rights reserved
+ *
+ * see html/copyright.html
+ */
+/*
+ *  This file contains the programmatic interface to the Automated
+ *  Options generated for the ntpq program.
+ *  These macros are documented in the AutoGen info file in the
+ *  "AutoOpts" chapter.  Please refer to that doc for usage help.
+ */
+#ifndef AUTOOPTS_NTPQ_OPTS_H_GUARD
+#define AUTOOPTS_NTPQ_OPTS_H_GUARD
+#include "config.h"
+#include <autoopts/options.h>
+
+/*
+ *  Ensure that the library used for compiling this generated header is at
+ *  least as new as the version current when the header template was released
+ *  (not counting patch version increments).  Also ensure that the oldest
+ *  tolerable version is at least as old as what was current when the header
+ *  template was released.
+ */
+#define AO_TEMPLATE_VERSION 118784
+#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
+ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
+# error option template version mismatches autoopts/options.h header
+  Choke Me.
+#endif
+
+/*
+ *  Enumeration of each option:
+ */
+typedef enum {
+        INDEX_OPT_IPV4             =  0,
+        INDEX_OPT_IPV6             =  1,
+        INDEX_OPT_COMMAND          =  2,
+        INDEX_OPT_DEBUG_LEVEL      =  3,
+        INDEX_OPT_SET_DEBUG_LEVEL  =  4,
+        INDEX_OPT_PEERS            =  5,
+        INDEX_OPT_INTERACTIVE      =  6,
+        INDEX_OPT_NUMERIC          =  7,
+        INDEX_OPT_VERSION          = 8,
+        INDEX_OPT_HELP             = 9,
+        INDEX_OPT_MORE_HELP        = 10,
+        INDEX_OPT_SAVE_OPTS        = 11,
+        INDEX_OPT_LOAD_OPTS        = 12
+} teOptIndex;
+
+#define OPTION_CT    13
+#define NTPQ_VERSION       "4.2.4p8"
+#define NTPQ_FULL_VERSION  "ntpq - standard NTP query program - Ver. 4.2.4p8"
+
+/*
+ *  Interface defines for all options.  Replace "n" with the UPPER_CASED
+ *  option name (as in the teOptIndex enumeration above).
+ *  e.g. HAVE_OPT( IPV4 )
+ */
+#define         DESC(n) (ntpqOptions.pOptDesc[INDEX_OPT_## n])
+#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
+#define      OPT_ARG(n) (DESC(n).optArg.argString)
+#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
+#define    COUNT_OPT(n) (DESC(n).optOccCt)
+#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
+#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
+#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
+#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
+#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
+#define    CLEAR_OPT(n) STMTS( \
+                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
+                if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
+                    DESC(n).fOptState |= OPTST_DISABLED; \
+                DESC(n).optCookie = NULL )
+
+/*
+ *  Make sure there are no #define name conflicts with the option names
+ */
+#ifndef     NO_OPTION_NAME_WARNINGS
+# ifdef    IPV4
+#  warning undefining IPV4 due to option name conflict
+#  undef   IPV4
+# endif
+# ifdef    IPV6
+#  warning undefining IPV6 due to option name conflict
+#  undef   IPV6
+# endif
+# ifdef    COMMAND
+#  warning undefining COMMAND due to option name conflict
+#  undef   COMMAND
+# endif
+# ifdef    DEBUG_LEVEL
+#  warning undefining DEBUG_LEVEL due to option name conflict
+#  undef   DEBUG_LEVEL
+# endif
+# ifdef    SET_DEBUG_LEVEL
+#  warning undefining SET_DEBUG_LEVEL due to option name conflict
+#  undef   SET_DEBUG_LEVEL
+# endif
+# ifdef    PEERS
+#  warning undefining PEERS due to option name conflict
+#  undef   PEERS
+# endif
+# ifdef    INTERACTIVE
+#  warning undefining INTERACTIVE due to option name conflict
+#  undef   INTERACTIVE
+# endif
+# ifdef    NUMERIC
+#  warning undefining NUMERIC due to option name conflict
+#  undef   NUMERIC
+# endif
+#else  /* NO_OPTION_NAME_WARNINGS */
+# undef IPV4
+# undef IPV6
+# undef COMMAND
+# undef DEBUG_LEVEL
+# undef SET_DEBUG_LEVEL
+# undef PEERS
+# undef INTERACTIVE
+# undef NUMERIC
+#endif  /*  NO_OPTION_NAME_WARNINGS */
+
+/*
+ *  Interface defines for specific options.
+ */
+#define VALUE_OPT_IPV4           '4'
+#define WHICH_OPT_IPV4           (DESC(IPV4).optActualValue)
+#define WHICH_IDX_IPV4           (DESC(IPV4).optActualIndex)
+#define VALUE_OPT_IPV6           '6'
+#define VALUE_OPT_COMMAND        'c'
+#ifdef DEBUG
+#define VALUE_OPT_DEBUG_LEVEL    'd'
+#endif /* DEBUG */
+#ifdef DEBUG
+#define VALUE_OPT_SET_DEBUG_LEVEL 'D'
+#endif /* DEBUG */
+#define VALUE_OPT_PEERS          'p'
+#define VALUE_OPT_INTERACTIVE    'i'
+#define VALUE_OPT_NUMERIC        'n'
+
+#define VALUE_OPT_VERSION       'v'
+#define VALUE_OPT_HELP          '?'
+#define VALUE_OPT_MORE_HELP     '!'
+#define VALUE_OPT_SAVE_OPTS     '>'
+#define VALUE_OPT_LOAD_OPTS     '<'
+#define SET_OPT_SAVE_OPTS(a)   STMTS( \
+        DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
+        DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
+        DESC(SAVE_OPTS).optArg.argString = (char const*)(a) )
+/*
+ *  Interface defines not associated with particular options
+ */
+#define ERRSKIP_OPTERR  STMTS( ntpqOptions.fOptSet &= ~OPTPROC_ERRSTOP )
+#define ERRSTOP_OPTERR  STMTS( ntpqOptions.fOptSet |= OPTPROC_ERRSTOP )
+#define RESTART_OPT(n)  STMTS( \
+                ntpqOptions.curOptIdx = (n); \
+                ntpqOptions.pzCurOpt  = NULL )
+#define START_OPT       RESTART_OPT(1)
+#define USAGE(c)        (*ntpqOptions.pUsageProc)( &ntpqOptions, c )
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/opthead.tpl near line 360 */
+
+/* * * * * *
+ *
+ *  Declare the ntpq option descriptor.
+ */
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+extern tOptions   ntpqOptions;
+
+#ifndef _
+#  if ENABLE_NLS
+#    include <stdio.h>
+     static inline char* aoGetsText( char const* pz ) {
+         if (pz == NULL) return NULL;
+         return (char*)gettext( pz );
+     }
+#    define _(s)  aoGetsText(s)
+#  else  /* ENABLE_NLS */
+#    define _(s)  s
+#  endif /* ENABLE_NLS */
+#endif
+
+#ifdef  __cplusplus
+}
+#endif
+#endif /* AUTOOPTS_NTPQ_OPTS_H_GUARD */
+/* ntpq-opts.h ends here */
diff --git a/ntpq/ntpq-opts.menu b/ntpq/ntpq-opts.menu
new file mode 100644 (file)
index 0000000..c06f90d
--- /dev/null
@@ -0,0 +1 @@
+* ntpq Invocation::                Invoking ntpq
diff --git a/ntpq/ntpq-opts.texi b/ntpq/ntpq-opts.texi
new file mode 100644 (file)
index 0000000..a0618ce
--- /dev/null
@@ -0,0 +1,219 @@
+@node ntpq Invocation
+@section Invoking ntpq
+@pindex ntpq
+@cindex standard NTP query program
+@ignore
+# 
+# EDIT THIS FILE WITH CAUTION  (ntpq-opts.texi)
+# 
+# It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:28 AM EST
+# From the definitions    ntpq-opts.def
+# and the template file   aginfo.tpl
+@end ignore
+This program has no explanation.
+
+The
+[= prog-name =]
+utility program is used to query NTP servers which
+implement the standard NTP mode 6 control message formats defined
+in Appendix B of the NTPv3 specification RFC1305, requesting
+information about current state and/or changes in that state.
+The same formats are used in NTPv4, although some of the
+variables have changed and new ones added.
+
+This section was generated by @strong{AutoGen},
+the aginfo template and the option descriptions for the @command{ntpq} program.  It documents the ntpq usage text and option meanings.
+
+This software is released under a specialized copyright license.
+
+@menu
+* ntpq usage::                  ntpq usage help (-?)
+* ntpq command::                command option (-c)
+* ntpq debug-level::            debug-level option (-d)
+* ntpq interactive::            interactive option (-i)
+* ntpq ipv4::                   ipv4 option (-4)
+* ntpq ipv6::                   ipv6 option (-6)
+* ntpq numeric::                numeric option (-n)
+* ntpq peers::                  peers option (-p)
+* ntpq set-debug-level::        set-debug-level option (-D)
+@end menu
+
+@node ntpq usage
+@subsection ntpq usage help (-?)
+@cindex ntpq usage
+
+This is the automatically generated usage text for ntpq:
+
+@exampleindent 0
+@example
+ntpq - standard NTP query program - Ver. 4.2.5p247-RC
+USAGE:  ntpq [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... [ host ...]
+  Flg Arg Option-Name    Description
+   -4 no  ipv4           Force IPv4 DNS name resolution
+                                - prohibits these options:
+                                ipv6
+   -6 no  ipv6           Force IPv6 DNS name resolution
+                                - prohibits these options:
+                                ipv4
+   -c Str command        run a command and exit
+                                - may appear multiple times
+   -d no  debug-level    Increase output debug message level
+                                - may appear multiple times
+   -D Str set-debug-level Set the output debug message level
+                                - may appear multiple times
+   -p no  peers          Print a list of the peers
+                                - prohibits these options:
+                                interactive
+   -i no  interactive    Force ntpq to operate in interactive mode
+                                - prohibits these options:
+                                command
+                                peers
+   -n no  numeric        numeric host addresses
+      no  old-rv         Always output status line with readvar
+      opt version        Output version information and exit
+   -? no  help           Display extended usage information and exit
+   -! no  more-help      Extended usage information passed thru pager
+   -> opt save-opts      Save the option state to a config file
+   -< Str load-opts      Load options from a config file
+                                - disabled as --no-load-opts
+                                - may appear multiple times
+
+Options are specified by doubled hyphens and their name
+or by a single hyphen and the flag character.
+
+The following option preset mechanisms are supported:
+ - reading file /users/stenn/.ntprc
+ - reading file /deacon/backroom/snaps/ntp-stable/ntpq/.ntprc
+ - examining environment variables named NTPQ_*
+
+The
+[= prog-name =]
+utility program is used to query NTP servers which
+implement the standard NTP mode 6 control message formats defined
+in Appendix B of the NTPv3 specification RFC1305, requesting
+information about current state and/or changes in that state.
+The same formats are used in NTPv4, although some of the
+variables have changed and new ones added.
+
+please send bug reports to:  http://bugs.ntp.org, bugs@@ntp.org
+@end example
+@exampleindent 4
+
+@node ntpq ipv4
+@subsection ipv4 option (-4)
+@cindex ntpq-ipv4
+
+This is the ``force ipv4 dns name resolution'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is a member of the ipv4 class of options.
+@end itemize
+
+Force DNS resolution of following host names on the command line
+to the IPv4 namespace.
+
+@node ntpq ipv6
+@subsection ipv6 option (-6)
+@cindex ntpq-ipv6
+
+This is the ``force ipv6 dns name resolution'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is a member of the ipv4 class of options.
+@end itemize
+
+Force DNS resolution of following host names on the command line
+to the IPv6 namespace.
+
+@node ntpq command
+@subsection command option (-c)
+@cindex ntpq-command
+
+This is the ``run a command and exit'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@end itemize
+
+The following argument is interpreted as an interactive format command
+and is added to the list of commands to be executed on the specified
+host(s).
+
+@node ntpq debug-level
+@subsection debug-level option (-d)
+@cindex ntpq-debug-level
+
+This is the ``increase output debug message level'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@item
+must be compiled in by defining @code{DEBUG} during the compilation.
+@end itemize
+
+Increase the debugging message output level.
+
+@node ntpq set-debug-level
+@subsection set-debug-level option (-D)
+@cindex ntpq-set-debug-level
+
+This is the ``set the output debug message level'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@item
+must be compiled in by defining @code{DEBUG} during the compilation.
+@end itemize
+
+Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+
+@node ntpq peers
+@subsection peers option (-p)
+@cindex ntpq-peers
+
+This is the ``print a list of the peers'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+interactive.
+@end itemize
+
+Print a list of the peers known to the server as well as a summary
+of their state. This is equivalent to the 'peers' interactive command.
+
+@node ntpq interactive
+@subsection interactive option (-i)
+@cindex ntpq-interactive
+
+This is the ``force ntpq to operate in interactive mode'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+command, peers.
+@end itemize
+
+Force ntpq to operate in interactive mode.  Prompts will be written
+to the standard output and commands read from the standard input.
+
+@node ntpq numeric
+@subsection numeric option (-n)
+@cindex ntpq-numeric
+
+This is the ``numeric host addresses'' option.
+Output all host addresses in dotted-quad numeric format rather than
+converting to the canonical host names. 
diff --git a/ntpq/ntpq-subs.c b/ntpq/ntpq-subs.c
new file mode 100644 (file)
index 0000000..07f25ce
--- /dev/null
@@ -0,0 +1,1768 @@
+/*
+ * ntpq_ops.c - subroutines which are called to perform operations by ntpq
+ */
+
+#include <stdio.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include "ntpq.h"
+#include "ntp_stdlib.h"
+
+extern char *  chosts[];
+extern char currenthost[];
+extern int     numhosts;
+int    maxhostlen;
+
+/*
+ * Declarations for command handlers in here
+ */
+static int checkassocid        P((u_int32));
+static char *  strsave         P((char *));
+static struct varlist *findlistvar P((struct varlist *, char *));
+static void    doaddvlist      P((struct varlist *, char *));
+static void    dormvlist       P((struct varlist *, char *));
+static void    doclearvlist    P((struct varlist *));
+static void    makequerydata   P((struct varlist *, int *, char *));
+static int doquerylist P((struct varlist *, int, int, int, u_short *, int *, char **));
+static void    doprintvlist    P((struct varlist *, FILE *));
+static void    addvars         P((struct parse *, FILE *));
+static void    rmvars          P((struct parse *, FILE *));
+static void    clearvars       P((struct parse *, FILE *));
+static void    showvars        P((struct parse *, FILE *));
+static int dolist              P((struct varlist *, int, int, int, FILE *));
+static void    readlist        P((struct parse *, FILE *));
+static void    writelist       P((struct parse *, FILE *));
+static void    readvar         P((struct parse *, FILE *));
+static void    writevar        P((struct parse *, FILE *));
+static void    clocklist       P((struct parse *, FILE *));
+static void    clockvar        P((struct parse *, FILE *));
+static int findassidrange      P((u_int32, u_int32, int *, int *));
+static void    mreadlist       P((struct parse *, FILE *));
+static void    mreadvar        P((struct parse *, FILE *));
+static int dogetassoc  P((FILE *));
+static void    printassoc      P((int, FILE *));
+static void    associations    P((struct parse *, FILE *));
+static void    lassociations   P((struct parse *, FILE *));
+static void    passociations   P((struct parse *, FILE *));
+static void    lpassociations  P((struct parse *, FILE *));
+
+#ifdef UNUSED
+static void    radiostatus P((struct parse *, FILE *));
+#endif /* UNUSED */
+
+static void    pstatus         P((struct parse *, FILE *));
+static long    when            P((l_fp *, l_fp *, l_fp *));
+static char *  prettyinterval  P((char *, long));
+static int doprintpeers        P((struct varlist *, int, int, int, char *, FILE *, int));
+static int dogetpeers  P((struct varlist *, int, FILE *, int));
+static void    dopeers         P((int, FILE *, int));
+static void    peers           P((struct parse *, FILE *));
+static void    lpeers          P((struct parse *, FILE *));
+static void    doopeers        P((int, FILE *, int));
+static void    opeers          P((struct parse *, FILE *));
+static void    lopeers         P((struct parse *, FILE *));
+
+
+/*
+ * Commands we understand.     Ntpdc imports this.
+ */
+struct xcmd opcmds[] = {
+       { "associations", associations, {  NO, NO, NO, NO },
+         { "", "", "", "" },
+         "print list of association ID's and statuses for the server's peers" },
+       { "passociations", passociations,   {  NO, NO, NO, NO },
+         { "", "", "", "" },
+         "print list of associations returned by last associations command" },
+       { "lassociations", lassociations,   {  NO, NO, NO, NO },
+         { "", "", "", "" },
+         "print list of associations including all client information" },
+       { "lpassociations", lpassociations, {  NO, NO, NO, NO },
+         { "", "", "", "" },
+         "print last obtained list of associations, including client information" },
+       { "addvars",    addvars,    { NTP_STR, NO, NO, NO },
+         { "name[=value][,...]", "", "", "" },
+         "add variables to the variable list or change their values" },
+       { "rmvars", rmvars,     { NTP_STR, NO, NO, NO },
+         { "name[,...]", "", "", "" },
+         "remove variables from the variable list" },
+       { "clearvars",  clearvars,  { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "remove all variables from the variable list" },
+       { "showvars",   showvars,   { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "print variables on the variable list" },
+       { "readlist",   readlist,   { OPT|NTP_UINT, NO, NO, NO },
+         { "assocID", "", "", "" },
+         "read the system or peer variables included in the variable list" },
+       { "rl",     readlist,   { OPT|NTP_UINT, NO, NO, NO },
+         { "assocID", "", "", "" },
+         "read the system or peer variables included in the variable list" },
+       { "writelist",  writelist,  { OPT|NTP_UINT, NO, NO, NO },
+         { "assocID", "", "", "" },
+         "write the system or peer variables included in the variable list" },
+       { "readvar",    readvar,    { OPT|NTP_UINT, OPT|NTP_STR, NO, NO },
+         { "assocID", "name=value[,...]", "", "" },
+         "read system or peer variables" },
+       { "rv",     readvar,    { OPT|NTP_UINT, OPT|NTP_STR, NO, NO },
+         { "assocID", "name=value[,...]", "", "" },
+         "read system or peer variables" },
+       { "writevar",   writevar,   { NTP_UINT, NTP_STR, NO, NO },
+         { "assocID", "name=value,[...]", "", "" },
+         "write system or peer variables" },
+       { "mreadlist",  mreadlist,  { NTP_UINT, NTP_UINT, NO, NO },
+         { "assocID", "assocID", "", "" },
+         "read the peer variables in the variable list for multiple peers" },
+       { "mrl",    mreadlist,  { NTP_UINT, NTP_UINT, NO, NO },
+         { "assocID", "assocID", "", "" },
+         "read the peer variables in the variable list for multiple peers" },
+       { "mreadvar",   mreadvar,   { NTP_UINT, NTP_UINT, OPT|NTP_STR, NO },
+         { "assocID", "assocID", "name=value[,...]", "" },
+         "read peer variables from multiple peers" },
+       { "mrv",    mreadvar,   { NTP_UINT, NTP_UINT, OPT|NTP_STR, NO },
+         { "assocID", "assocID", "name=value[,...]", "" },
+         "read peer variables from multiple peers" },
+       { "clocklist",  clocklist,  { OPT|NTP_UINT, NO, NO, NO },
+         { "assocID", "", "", "" },
+         "read the clock variables included in the variable list" },
+       { "cl",     clocklist,  { OPT|NTP_UINT, NO, NO, NO },
+         { "assocID", "", "", "" },
+         "read the clock variables included in the variable list" },
+       { "clockvar",   clockvar,   { OPT|NTP_UINT, OPT|NTP_STR, NO, NO },
+         { "assocID", "name=value[,...]", "", "" },
+         "read clock variables" },
+       { "cv",     clockvar,   { OPT|NTP_UINT, OPT|NTP_STR, NO, NO },
+         { "assocID", "name=value[,...]", "", "" },
+         "read clock variables" },
+       { "pstatus",    pstatus,    { NTP_UINT, NO, NO, NO },
+         { "assocID", "", "", "" },
+         "print status information returned for a peer" },
+       { "peers",  peers,      { OPT|IP_VERSION, NO, NO, NO },
+         { "-4|-6", "", "", "" },
+         "obtain and print a list of the server's peers [IP version]" },
+       { "lpeers", lpeers,     { OPT|IP_VERSION, NO, NO, NO },
+         { "-4|-6", "", "", "" },
+         "obtain and print a list of all peers and clients [IP version]" },
+       { "opeers", opeers,     { OPT|IP_VERSION, NO, NO, NO },
+         { "-4|-6", "", "", "" },
+         "print peer list the old way, with dstadr shown rather than refid [IP version]" },
+       { "lopeers", lopeers,   { OPT|IP_VERSION, NO, NO, NO },
+         { "-4|-6", "", "", "" },
+         "obtain and print a list of all peers and clients showing dstadr [IP version]" },
+       { 0,            0,              { NO, NO, NO, NO },
+         { "-4|-6", "", "", "" }, "" }
+};
+
+
+/*
+ * Variable list data space
+ */
+#define MAXLIST        64      /* maximum number of variables in list */
+#define LENHOSTNAME 256 /* host name is 256 characters long */
+/*
+ * Old CTL_PST defines for version 2.
+ */
+#define OLD_CTL_PST_CONFIG                     0x80
+#define OLD_CTL_PST_AUTHENABLE         0x40
+#define OLD_CTL_PST_AUTHENTIC          0x20
+#define OLD_CTL_PST_REACH                      0x10
+#define OLD_CTL_PST_SANE                       0x08
+#define OLD_CTL_PST_DISP                       0x04
+#define OLD_CTL_PST_SEL_REJECT         0
+#define OLD_CTL_PST_SEL_SELCAND        1
+#define OLD_CTL_PST_SEL_SYNCCAND       2
+#define OLD_CTL_PST_SEL_SYSPEER        3
+
+
+char flash2[] = " .+*    "; /* flash decode for version 2 */
+char flash3[] = " x.-+#*o"; /* flash decode for peer status version 3 */
+
+struct varlist {
+       char *name;
+       char *value;
+} varlist[MAXLIST] = { { 0, 0 } };
+
+/*
+ * Imported from ntpq.c
+ */
+extern int showhostnames;
+extern int rawmode;
+extern struct servent *server_entry;
+extern struct association assoc_cache[];
+extern int numassoc;
+extern u_char pktversion;
+extern struct ctl_var peer_var[];
+
+/*
+ * For quick string comparisons
+ */
+#define STREQ(a, b) (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+
+/*
+ * checkassocid - return the association ID, checking to see if it is valid
+ */
+static int
+checkassocid(
+       u_int32 value
+       )
+{
+       if (value == 0 || value >= 65536) {
+               (void) fprintf(stderr, "***Invalid association ID specified\n");
+               return 0;
+       }
+       return (int)value;
+}
+
+
+/*
+ * strsave - save a string
+ * XXX - should be in libntp.a
+ */
+static char *
+strsave(
+       char *str
+       )
+{
+       char *cp;
+       u_int len;
+
+       len = strlen(str) + 1;
+       if ((cp = (char *)malloc(len)) == NULL) {
+               (void) fprintf(stderr, "Malloc failed!!\n");
+               exit(1);
+       }
+
+       memmove(cp, str, len);
+       return (cp);
+}
+
+
+/*
+ * findlistvar - look for the named variable in a list and return if found
+ */
+static struct varlist *
+findlistvar(
+       struct varlist *list,
+       char *name
+       )
+{
+       register struct varlist *vl;
+
+       for (vl = list; vl < list + MAXLIST && vl->name != 0; vl++)
+               if (STREQ(name, vl->name))
+               return vl;
+       if (vl < list + MAXLIST)
+               return vl;
+       return (struct varlist *)0;
+}
+
+
+/*
+ * doaddvlist - add variable(s) to the variable list
+ */
+static void
+doaddvlist(
+       struct varlist *vlist,
+       char *vars
+       )
+{
+       register struct varlist *vl;
+       int len;
+       char *name;
+       char *value;
+
+       len = strlen(vars);
+       while (nextvar(&len, &vars, &name, &value)) {
+               vl = findlistvar(vlist, name);
+               if (vl == 0) {
+                       (void) fprintf(stderr, "Variable list full\n");
+                       return;
+               }
+
+               if (vl->name == 0) {
+                       vl->name = strsave(name);
+               } else if (vl->value != 0) {
+                       free(vl->value);
+                       vl->value = 0;
+               }
+
+               if (value != 0)
+                       vl->value = strsave(value);
+       }
+}
+
+
+/*
+ * dormvlist - remove variable(s) from the variable list
+ */
+static void
+dormvlist(
+       struct varlist *vlist,
+       char *vars
+       )
+{
+       register struct varlist *vl;
+       int len;
+       char *name;
+       char *value;
+
+       len = strlen(vars);
+       while (nextvar(&len, &vars, &name, &value)) {
+               vl = findlistvar(vlist, name);
+               if (vl == 0 || vl->name == 0) {
+                       (void) fprintf(stderr, "Variable `%s' not found\n",
+                                      name);
+               } else {
+                       free((void *)vl->name);
+                       if (vl->value != 0)
+                           free(vl->value);
+                       for ( ; (vl+1) < (varlist+MAXLIST)
+                                     && (vl+1)->name != 0; vl++) {
+                               vl->name = (vl+1)->name;
+                               vl->value = (vl+1)->value;
+                       }
+                       vl->name = vl->value = 0;
+               }
+       }
+}
+
+
+/*
+ * doclearvlist - clear a variable list
+ */
+static void
+doclearvlist(
+       struct varlist *vlist
+       )
+{
+       register struct varlist *vl;
+
+       for (vl = vlist; vl < vlist + MAXLIST && vl->name != 0; vl++) {
+               free((void *)vl->name);
+               vl->name = 0;
+               if (vl->value != 0) {
+                       free(vl->value);
+                       vl->value = 0;
+               }
+       }
+}
+
+
+/*
+ * makequerydata - form a data buffer to be included with a query
+ */
+static void
+makequerydata(
+       struct varlist *vlist,
+       int *datalen,
+       char *data
+       )
+{
+       register struct varlist *vl;
+       register char *cp, *cpend;
+       register int namelen, valuelen;
+       register int totallen;
+
+       cp = data;
+       cpend = data + *datalen;
+
+       for (vl = vlist; vl < vlist + MAXLIST && vl->name != 0; vl++) {
+               namelen = strlen(vl->name);
+               if (vl->value == 0)
+                       valuelen = 0;
+               else
+                       valuelen = strlen(vl->value);
+               totallen = namelen + valuelen + (valuelen != 0) + (cp != data);
+               if (cp + totallen > cpend)
+                       break;
+
+               if (cp != data)
+                       *cp++ = ',';
+               memmove(cp, vl->name, (unsigned)namelen);
+               cp += namelen;
+               if (valuelen != 0) {
+                       *cp++ = '=';
+                       memmove(cp, vl->value, (unsigned)valuelen);
+                       cp += valuelen;
+               }
+       }
+       *datalen = cp - data;
+}
+
+
+/*
+ * doquerylist - send a message including variables in a list
+ */
+static int
+doquerylist(
+       struct varlist *vlist,
+       int op,
+       int associd,
+       int auth,
+       u_short *rstatus,
+       int *dsize,
+       char **datap
+       )
+{
+       char data[CTL_MAX_DATA_LEN];
+       int datalen;
+
+       datalen = sizeof(data);
+       makequerydata(vlist, &datalen, data);
+
+       return doquery(op, associd, auth, datalen, data, rstatus,
+                          dsize, datap);
+}
+
+
+/*
+ * doprintvlist - print the variables on a list
+ */
+static void
+doprintvlist(
+       struct varlist *vlist,
+       FILE *fp
+       )
+{
+       register struct varlist *vl;
+
+       if (vlist->name == 0) {
+               (void) fprintf(fp, "No variables on list\n");
+       } else {
+               for (vl = vlist; vl < vlist + MAXLIST && vl->name != 0; vl++) {
+                       if (vl->value == 0) {
+                               (void) fprintf(fp, "%s\n", vl->name);
+                       } else {
+                               (void) fprintf(fp, "%s=%s\n",
+                                                  vl->name, vl->value);
+                       }
+               }
+       }
+}
+
+
+/*
+ * addvars - add variables to the variable list
+ */
+/*ARGSUSED*/
+static void
+addvars(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       doaddvlist(varlist, pcmd->argval[0].string);
+}
+
+
+/*
+ * rmvars - remove variables from the variable list
+ */
+/*ARGSUSED*/
+static void
+rmvars(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       dormvlist(varlist, pcmd->argval[0].string);
+}
+
+
+/*
+ * clearvars - clear the variable list
+ */
+/*ARGSUSED*/
+static void
+clearvars(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       doclearvlist(varlist);
+}
+
+
+/*
+ * showvars - show variables on the variable list
+ */
+/*ARGSUSED*/
+static void
+showvars(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       doprintvlist(varlist, fp);
+}
+
+
+/*
+ * dolist - send a request with the given list of variables
+ */
+static int
+dolist(
+       struct varlist *vlist,
+       int associd,
+       int op,
+       int type,
+       FILE *fp
+       )
+{
+       char *datap;
+       int res;
+       int dsize;
+       u_short rstatus;
+
+       res = doquerylist(vlist, op, associd, 0, &rstatus, &dsize, &datap);
+
+       if (res != 0)
+               return 0;
+
+       if (numhosts > 1)
+               (void) fprintf(fp, "server=%s ", currenthost);
+       if (dsize == 0) {
+               if (associd == 0)
+                       (void) fprintf(fp, "No system%s variables returned\n",
+                                  (type == TYPE_CLOCK) ? " clock" : "");
+               else
+                       (void) fprintf(fp,
+                                  "No information returned for%s association %u\n",
+                                  (type == TYPE_CLOCK) ? " clock" : "", associd);
+               return 1;
+       }
+
+       (void) fprintf(fp,"assID=%d ",associd);
+       printvars(dsize, datap, (int)rstatus, type, fp);
+       return 1;
+}
+
+
+/*
+ * readlist - send a read variables request with the variables on the list
+ */
+static void
+readlist(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int associd;
+
+       if (pcmd->nargs == 0) {
+               associd = 0;
+       } else {
+         /* HMS: I think we want the u_int32 target here, not the u_long */
+               if (pcmd->argval[0].uval == 0)
+                       associd = 0;
+               else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
+                       return;
+       }
+
+       (void) dolist(varlist, associd, CTL_OP_READVAR,
+                         (associd == 0) ? TYPE_SYS : TYPE_PEER, fp);
+}
+
+
+/*
+ * writelist - send a write variables request with the variables on the list
+ */
+static void
+writelist(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       char *datap;
+       int res;
+       int associd;
+       int dsize;
+       u_short rstatus;
+
+       if (pcmd->nargs == 0) {
+               associd = 0;
+       } else {
+               /* HMS: Do we really want uval here? */
+               if (pcmd->argval[0].uval == 0)
+                       associd = 0;
+               else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
+                       return;
+       }
+
+       res = doquerylist(varlist, CTL_OP_WRITEVAR, associd, 1, &rstatus,
+                         &dsize, &datap);
+
+       if (res != 0)
+               return;
+
+       if (numhosts > 1)
+               (void) fprintf(fp, "server=%s ", currenthost);
+       if (dsize == 0)
+               (void) fprintf(fp, "done! (no data returned)\n");
+       else {
+               (void) fprintf(fp,"assID=%d ",associd);
+               printvars(dsize, datap, (int)rstatus,
+                         (associd != 0) ? TYPE_PEER : TYPE_SYS, fp);
+       }
+       return;
+}
+
+
+/*
+ * readvar - send a read variables request with the specified variables
+ */
+static void
+readvar(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int associd;
+       struct varlist tmplist[MAXLIST];
+
+       /* HMS: uval? */
+       if (pcmd->nargs == 0 || pcmd->argval[0].uval == 0)
+               associd = 0;
+       else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
+               return;
+
+       memset((char *)tmplist, 0, sizeof(tmplist));
+       if (pcmd->nargs >= 2)
+               doaddvlist(tmplist, pcmd->argval[1].string);
+
+       (void) dolist(tmplist, associd, CTL_OP_READVAR,
+                         (associd == 0) ? TYPE_SYS : TYPE_PEER, fp);
+
+       doclearvlist(tmplist);
+}
+
+
+/*
+ * writevar - send a write variables request with the specified variables
+ */
+static void
+writevar(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       char *datap;
+       int res;
+       int associd;
+       int dsize;
+       u_short rstatus;
+       struct varlist tmplist[MAXLIST];
+
+       /* HMS: uval? */
+       if (pcmd->argval[0].uval == 0)
+               associd = 0;
+       else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
+               return;
+
+       memset((char *)tmplist, 0, sizeof(tmplist));
+       doaddvlist(tmplist, pcmd->argval[1].string);
+
+       res = doquerylist(tmplist, CTL_OP_WRITEVAR, associd, 1, &rstatus,
+                         &dsize, &datap);
+
+       doclearvlist(tmplist);
+
+       if (res != 0)
+               return;
+
+       if (numhosts > 1)
+               (void) fprintf(fp, "server=%s ", currenthost);
+       if (dsize == 0)
+               (void) fprintf(fp, "done! (no data returned)\n");
+       else {
+               (void) fprintf(fp,"assID=%d ",associd);
+               printvars(dsize, datap, (int)rstatus,
+                         (associd != 0) ? TYPE_PEER : TYPE_SYS, fp);
+       }
+       return;
+}
+
+
+/*
+ * clocklist - send a clock variables request with the variables on the list
+ */
+static void
+clocklist(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int associd;
+
+       /* HMS: uval? */
+       if (pcmd->nargs == 0) {
+               associd = 0;
+       } else {
+               if (pcmd->argval[0].uval == 0)
+                       associd = 0;
+               else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
+                       return;
+       }
+
+       (void) dolist(varlist, associd, CTL_OP_READCLOCK, TYPE_CLOCK, fp);
+}
+
+
+/*
+ * clockvar - send a clock variables request with the specified variables
+ */
+static void
+clockvar(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int associd;
+       struct varlist tmplist[MAXLIST];
+
+       /* HMS: uval? */
+       if (pcmd->nargs == 0 || pcmd->argval[0].uval == 0)
+               associd = 0;
+       else if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
+               return;
+
+       memset((char *)tmplist, 0, sizeof(tmplist));
+       if (pcmd->nargs >= 2)
+               doaddvlist(tmplist, pcmd->argval[1].string);
+
+       (void) dolist(tmplist, associd, CTL_OP_READCLOCK, TYPE_CLOCK, fp);
+
+       doclearvlist(tmplist);
+}
+
+
+/*
+ * findassidrange - verify a range of association ID's
+ */
+static int
+findassidrange(
+       u_int32 assid1,
+       u_int32 assid2,
+       int *from,
+       int *to
+       )
+{
+       register int i;
+       int f, t;
+
+       if (assid1 == 0 || assid1 > 65535) {
+               (void) fprintf(stderr,
+                                  "***Invalid association ID %lu specified\n", (u_long)assid1);
+               return 0;
+       }
+
+       if (assid2 == 0 || assid2 > 65535) {
+               (void) fprintf(stderr,
+                                  "***Invalid association ID %lu specified\n", (u_long)assid2);
+               return 0;
+       }
+
+       f = t = -1;
+       for (i = 0; i < numassoc; i++) {
+               if (assoc_cache[i].assid == assid1) {
+                       f = i;
+                       if (t != -1)
+                               break;
+               }
+               if (assoc_cache[i].assid == assid2) {
+                       t = i;
+                       if (f != -1)
+                               break;
+               }
+       }
+
+       if (f == -1 || t == -1) {
+               (void) fprintf(stderr,
+                                  "***Association ID %lu not found in list\n",
+                                  (f == -1) ? (u_long)assid1 : (u_long)assid2);
+               return 0;
+       }
+
+       if (f < t) {
+               *from = f;
+               *to = t;
+       } else {
+               *from = t;
+               *to = f;
+       }
+       return 1;
+}
+
+
+
+/*
+ * mreadlist - send a read variables request for multiple associations
+ */
+static void
+mreadlist(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int i;
+       int from;
+       int to;
+
+       /* HMS: uval? */
+       if (!findassidrange(pcmd->argval[0].uval, pcmd->argval[1].uval,
+                               &from, &to))
+               return;
+
+       for (i = from; i <= to; i++) {
+               if (i != from)
+                       (void) fprintf(fp, "\n");
+               if (!dolist(varlist, (int)assoc_cache[i].assid,
+                               CTL_OP_READVAR, TYPE_PEER, fp))
+                       return;
+       }
+       return;
+}
+
+
+/*
+ * mreadvar - send a read variables request for multiple associations
+ */
+static void
+mreadvar(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int i;
+       int from;
+       int to;
+       struct varlist tmplist[MAXLIST];
+
+       /* HMS: uval? */
+       if (!findassidrange(pcmd->argval[0].uval, pcmd->argval[1].uval,
+                               &from, &to))
+               return;
+
+       memset((char *)tmplist, 0, sizeof(tmplist));
+       if (pcmd->nargs >= 3)
+               doaddvlist(tmplist, pcmd->argval[2].string);
+
+       for (i = from; i <= to; i++) {
+               if (i != from)
+                       (void) fprintf(fp, "\n");
+               if (!dolist(varlist, (int)assoc_cache[i].assid,
+                               CTL_OP_READVAR, TYPE_PEER, fp))
+                       break;
+       }
+       doclearvlist(tmplist);
+       return;
+}
+
+
+/*
+ * dogetassoc - query the host for its list of associations
+ */
+static int
+dogetassoc(
+       FILE *fp
+       )
+{
+       char *datap;
+       int res;
+       int dsize;
+       u_short rstatus;
+
+       res = doquery(CTL_OP_READSTAT, 0, 0, 0, (char *)0, &rstatus,
+                         &dsize, &datap);
+
+       if (res != 0)
+               return 0;
+
+       if (dsize == 0) {
+               if (numhosts > 1)
+                       (void) fprintf(fp, "server=%s ", currenthost);
+               (void) fprintf(fp, "No association ID's returned\n");
+               return 0;
+       }
+
+       if (dsize & 0x3) {
+               if (numhosts > 1)
+                       (void) fprintf(stderr, "server=%s ", currenthost);
+               (void) fprintf(stderr,
+                                  "***Server returned %d octets, should be multiple of 4\n",
+                                  dsize);
+               return 0;
+       }
+
+       numassoc = 0;
+       while (dsize > 0) {
+               assoc_cache[numassoc].assid = ntohs(*((u_short *)datap));
+               datap += sizeof(u_short);
+               assoc_cache[numassoc].status = ntohs(*((u_short *)datap));
+               datap += sizeof(u_short);
+               if (++numassoc >= MAXASSOC)
+                       break;
+               dsize -= sizeof(u_short) + sizeof(u_short);
+       }
+       sortassoc();
+       return 1;
+}
+
+
+/*
+ * printassoc - print the current list of associations
+ */
+static void
+printassoc(
+       int showall,
+       FILE *fp
+       )
+{
+       register char *bp;
+       int i;
+       u_char statval;
+       int event;
+       u_long event_count;
+       const char *conf;
+       const char *reach;
+       const char *auth;
+       const char *condition = "";
+       const char *last_event;
+       const char *cnt;
+       char buf[128];
+
+       if (numassoc == 0) {
+               (void) fprintf(fp, "No association ID's in list\n");
+               return;
+       }
+
+       /*
+        * Output a header
+        */
+       (void) fprintf(fp,
+                          "\nind assID status  conf reach auth condition  last_event cnt\n");
+       (void) fprintf(fp,
+                          "===========================================================\n");
+       for (i = 0; i < numassoc; i++) {
+               statval = (u_char) CTL_PEER_STATVAL(assoc_cache[i].status);
+               if (!showall && !(statval & (CTL_PST_CONFIG|CTL_PST_REACH)))
+                       continue;
+               event = CTL_PEER_EVENT(assoc_cache[i].status);
+               event_count = CTL_PEER_NEVNT(assoc_cache[i].status);
+               if (statval & CTL_PST_CONFIG)
+                       conf = "yes";
+               else
+                       conf = "no";
+               if (statval & CTL_PST_REACH || 1) {
+                       reach = "yes";
+                       if (statval & CTL_PST_AUTHENABLE) {
+                               if (statval & CTL_PST_AUTHENTIC)
+                                       auth = "ok ";
+                               else
+                                       auth = "bad";
+                       } else
+                               auth = "none";
+
+                       if (pktversion > NTP_OLDVERSION)
+                               switch (statval & 0x7) {
+                               case CTL_PST_SEL_REJECT:
+                                       condition = "reject";
+                                       break;
+                               case CTL_PST_SEL_SANE:
+                                       condition = "falsetick";
+                                       break;
+                               case CTL_PST_SEL_CORRECT:
+                                       condition = "excess";
+                                       break;
+                               case CTL_PST_SEL_SELCAND:
+                                       condition = "outlyer";
+                                       break;
+                               case CTL_PST_SEL_SYNCCAND:
+                                       condition = "candidat";
+                                       break;
+                               case CTL_PST_SEL_DISTSYSPEER:
+                                       condition = "selected";
+                                       break;
+                               case CTL_PST_SEL_SYSPEER:
+                                       condition = "sys.peer";
+                                       break;
+                               case CTL_PST_SEL_PPS:
+                                       condition = "pps.peer";
+                                       break;
+                               }
+                       else
+                               switch (statval & 0x3) {
+                               case OLD_CTL_PST_SEL_REJECT:
+                                       if (!(statval & OLD_CTL_PST_SANE))
+                                       condition = "insane";
+                                       else if (!(statval & OLD_CTL_PST_DISP))
+                                       condition = "hi_disp";
+                                       else
+                                       condition = "";
+                                       break;
+                               case OLD_CTL_PST_SEL_SELCAND:
+                                       condition = "sel_cand";
+                                       break;
+                               case OLD_CTL_PST_SEL_SYNCCAND:
+                                       condition = "sync_cand";
+                                       break;
+                               case OLD_CTL_PST_SEL_SYSPEER:
+                                       condition = "sys_peer";
+                                       break;
+                               }
+
+               } else {
+                       reach = "no";
+                       auth = condition = "";
+               }
+
+               switch (PEER_EVENT|event) {
+                       case EVNT_PEERIPERR:
+                       last_event = "IP error";
+                       break;
+                       case EVNT_PEERAUTH:
+                       last_event = "auth fail";
+                       break;
+                       case EVNT_UNREACH:
+                       last_event = "lost reach";
+                       break;
+                       case EVNT_REACH:
+                       last_event = "reachable";
+                       break;
+                       case EVNT_PEERCLOCK:
+                       last_event = "clock expt";
+                       break;
+#if 0
+                       case EVNT_PEERSTRAT:
+                       last_event = "stratum chg";
+                       break;
+#endif
+                       default:
+                       last_event = "";
+                       break;
+               }
+
+               if (event_count != 0)
+                       cnt = uinttoa(event_count);
+               else
+                       cnt = "";
+               (void) sprintf(buf,
+                                  "%3d %5u  %04x   %3.3s  %4s  %4.4s %9.9s %11s %2s",
+                                  i+1, assoc_cache[i].assid, assoc_cache[i].status,
+                                  conf, reach, auth, condition, last_event, cnt);
+               bp = &buf[strlen(buf)];
+               while (bp > buf && *(bp-1) == ' ')
+                       *(--bp) = '\0';
+               (void) fprintf(fp, "%s\n", buf);
+       }
+}
+
+
+
+/*
+ * associations - get, record and print a list of associations
+ */
+/*ARGSUSED*/
+static void
+associations(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (dogetassoc(fp))
+               printassoc(0, fp);
+}
+
+
+/*
+ * lassociations - get, record and print a long list of associations
+ */
+/*ARGSUSED*/
+static void
+lassociations(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (dogetassoc(fp))
+               printassoc(1, fp);
+}
+
+
+/*
+ * passociations - print the association list
+ */
+/*ARGSUSED*/
+static void
+passociations(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       printassoc(0, fp);
+}
+
+
+/*
+ * lpassociations - print the long association list
+ */
+/*ARGSUSED*/
+static void
+lpassociations(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       printassoc(1, fp);
+}
+
+
+#ifdef UNUSED
+/*
+ * radiostatus - print the radio status returned by the server
+ */
+/*ARGSUSED*/
+static void
+radiostatus(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       char *datap;
+       int res;
+       int dsize;
+       u_short rstatus;
+
+       res = doquery(CTL_OP_READCLOCK, 0, 0, 0, (char *)0, &rstatus,
+                         &dsize, &datap);
+
+       if (res != 0)
+               return;
+
+       if (numhosts > 1)
+               (void) fprintf(fp, "server=%s ", currenthost);
+       if (dsize == 0) {
+               (void) fprintf(fp, "No radio status string returned\n");
+               return;
+       }
+
+       asciize(dsize, datap, fp);
+}
+#endif /* UNUSED */
+
+/*
+ * pstatus - print peer status returned by the server
+ */
+static void
+pstatus(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       char *datap;
+       int res;
+       int associd;
+       int dsize;
+       u_short rstatus;
+
+       /* HMS: uval? */
+       if ((associd = checkassocid(pcmd->argval[0].uval)) == 0)
+               return;
+
+       res = doquery(CTL_OP_READSTAT, associd, 0, 0, (char *)0, &rstatus,
+                         &dsize, &datap);
+
+       if (res != 0)
+               return;
+
+       if (numhosts > 1)
+               (void) fprintf(fp, "server=%s ", currenthost);
+       if (dsize == 0) {
+               (void) fprintf(fp,
+                                  "No information returned for association %u\n",
+                                  associd);
+               return;
+       }
+
+       (void) fprintf(fp,"assID=%d ",associd);
+       printvars(dsize, datap, (int)rstatus, TYPE_PEER, fp);
+}
+
+
+/*
+ * when - print how long its been since his last packet arrived
+ */
+static long
+when(
+       l_fp *ts,
+       l_fp *rec,
+       l_fp *reftime
+       )
+{
+       l_fp *lasttime;
+
+       if (rec->l_ui != 0)
+               lasttime = rec;
+       else if (reftime->l_ui != 0)
+               lasttime = reftime;
+       else
+               return 0;
+
+       return (ts->l_ui - lasttime->l_ui);
+}
+
+
+/*
+ * Pretty-print an interval into the given buffer, in a human-friendly format.
+ */
+static char *
+prettyinterval(
+       char *buf,
+       long diff
+       )
+{
+       if (diff <= 0) {
+               buf[0] = '-';
+               buf[1] = 0;
+               return buf;
+       }
+
+       if (diff <= 2048) {
+               (void) sprintf(buf, "%ld", (long int)diff);
+               return buf;
+       }
+
+       diff = (diff + 29) / 60;
+       if (diff <= 300) {
+               (void) sprintf(buf, "%ldm", (long int)diff);
+               return buf;
+       }
+
+       diff = (diff + 29) / 60;
+       if (diff <= 96) {
+               (void) sprintf(buf, "%ldh", (long int)diff);
+               return buf;
+       }
+
+       diff = (diff + 11) / 24;
+       (void) sprintf(buf, "%ldd", (long int)diff);
+       return buf;
+}
+
+static char
+decodeaddrtype(
+       struct sockaddr_storage *sock
+       )
+{
+       char ch = '-';
+       u_int32 dummy;
+       struct sockaddr_in6 *sin6;
+
+       switch(sock->ss_family) {
+       case AF_INET:
+               dummy = ((struct sockaddr_in *)sock)->sin_addr.s_addr;
+               dummy = ntohl(dummy);
+               ch = (char)(((dummy&0xf0000000)==0xe0000000) ? 'm' :
+                       ((dummy&0x000000ff)==0x000000ff) ? 'b' :
+                       ((dummy&0xffffffff)==0x7f000001) ? 'l' :
+                       ((dummy&0xffffffe0)==0x00000000) ? '-' :
+                       'u');
+               break;
+       case AF_INET6:
+               sin6 = (struct sockaddr_in6 *)sock;
+               if (IN6_IS_ADDR_MULTICAST(&sin6->sin6_addr))
+                       ch = 'm';
+               else
+                       ch = 'u';
+               break;
+       default:
+               ch = '-';
+               break;
+       }
+       return ch;
+}
+
+/*
+ * A list of variables required by the peers command
+ */
+struct varlist opeervarlist[] = {
+       { "srcadr", 0 },    /* 0 */
+       { "dstadr", 0 },    /* 1 */
+       { "stratum",    0 },    /* 2 */
+       { "hpoll",  0 },    /* 3 */
+       { "ppoll",  0 },    /* 4 */
+       { "reach",  0 },    /* 5 */
+       { "delay",  0 },    /* 6 */
+       { "offset", 0 },    /* 7 */
+       { "jitter", 0 },    /* 8 */
+       { "dispersion", 0 },    /* 9 */
+       { "rec",    0 },    /* 10 */
+       { "reftime",    0 },    /* 11 */
+       { "srcport",    0 },    /* 12 */
+       { 0,            0 }
+};
+
+struct varlist peervarlist[] = {
+       { "srcadr", 0 },    /* 0 */
+       { "refid",  0 },    /* 1 */
+       { "stratum",    0 },    /* 2 */
+       { "hpoll",  0 },    /* 3 */
+       { "ppoll",  0 },    /* 4 */
+       { "reach",  0 },    /* 5 */
+       { "delay",  0 },    /* 6 */
+       { "offset", 0 },    /* 7 */
+       { "jitter", 0 },    /* 8 */
+       { "dispersion", 0 },    /* 9 */
+       { "rec",    0 },    /* 10 */
+       { "reftime",    0 },    /* 11 */
+       { "srcport",    0 },    /* 12 */
+       { 0,            0 }
+};
+
+#define HAVE_SRCADR 0
+#define HAVE_DSTADR 1
+#define HAVE_REFID     1
+#define HAVE_STRATUM   2
+#define HAVE_HPOLL     3
+#define HAVE_PPOLL     4
+#define HAVE_REACH     5
+#define HAVE_DELAY     6
+#define HAVE_OFFSET 7
+#define HAVE_JITTER 8
+#define HAVE_DISPERSION 9
+#define HAVE_REC       10
+#define HAVE_REFTIME   11
+#define HAVE_SRCPORT   12
+#define MAXHAVE        13
+
+/*
+ * Decode an incoming data buffer and print a line in the peer list
+ */
+static int
+doprintpeers(
+       struct varlist *pvl,
+       int associd,
+       int rstatus,
+       int datalen,
+       char *data,
+       FILE *fp,
+       int af
+       )
+{
+       char *name;
+       char *value = NULL;
+       int i;
+       int c;
+
+       struct sockaddr_storage srcadr;
+       struct sockaddr_storage dstadr;
+       u_long srcport = 0;
+       char *dstadr_refid = "0.0.0.0";
+       u_long stratum = 0;
+       long ppoll = 0;
+       long hpoll = 0;
+       u_long reach = 0;
+       l_fp estoffset;
+       l_fp estdelay;
+       l_fp estjitter;
+       l_fp estdisp;
+       l_fp reftime;
+       l_fp rec;
+       l_fp ts;
+       u_char havevar[MAXHAVE];
+       u_long poll_sec;
+       char type = '?';
+       char refid_string[10];
+       char whenbuf[8], pollbuf[8];
+       char clock_name[LENHOSTNAME];
+
+       memset((char *)havevar, 0, sizeof(havevar));
+       get_systime(&ts);
+       
+       memset((char *)&srcadr, 0, sizeof(struct sockaddr_storage));
+       memset((char *)&dstadr, 0, sizeof(struct sockaddr_storage));
+
+       /* Initialize by zeroing out estimate variables */
+       memset((char *)&estoffset, 0, sizeof(l_fp));
+       memset((char *)&estdelay, 0, sizeof(l_fp));
+       memset((char *)&estjitter, 0, sizeof(l_fp));
+       memset((char *)&estdisp, 0, sizeof(l_fp));
+
+       while (nextvar(&datalen, &data, &name, &value)) {
+               struct sockaddr_storage dum_store;
+
+               i = findvar(name, peer_var, 1);
+               if (i == 0)
+                       continue;       /* don't know this one */
+               switch (i) {
+                       case CP_SRCADR:
+                       if (decodenetnum(value, &srcadr))
+                               havevar[HAVE_SRCADR] = 1;
+                       break;
+                       case CP_DSTADR:
+                       if (decodenetnum(value, &dum_store))
+                               type = decodeaddrtype(&dum_store);
+                       if (pvl == opeervarlist) {
+                               if (decodenetnum(value, &dstadr)) {
+                                       havevar[HAVE_DSTADR] = 1;
+                                       dstadr_refid = stoa(&dstadr);
+                               }
+                       }
+                       break;
+                       case CP_REFID:
+                       if (pvl == peervarlist) {
+                               havevar[HAVE_REFID] = 1;
+                               if (*value == '\0') {
+                                       dstadr_refid = "0.0.0.0";
+                               } else if ((int)strlen(value) <= 4) {
+                                       refid_string[0] = '.';
+                                       (void) strcpy(&refid_string[1], value);
+                                       i = strlen(refid_string);
+                                       refid_string[i] = '.';
+                                       refid_string[i+1] = '\0';
+                                       dstadr_refid = refid_string;
+                               } else if (decodenetnum(value, &dstadr)) {
+                                       if (SOCKNUL(&dstadr))
+                                               dstadr_refid = "0.0.0.0";
+                                       else if ((dstadr.ss_family == AF_INET)
+                                           && ISREFCLOCKADR(&dstadr))
+                                               dstadr_refid =
+                                                   refnumtoa(&dstadr);
+                                       else
+                                               dstadr_refid =
+                                                   stoa(&dstadr);
+                               } else {
+                                       havevar[HAVE_REFID] = 0;
+                               }
+                       }
+                       break;
+                       case CP_STRATUM:
+                       if (decodeuint(value, &stratum))
+                               havevar[HAVE_STRATUM] = 1;
+                       break;
+                       case CP_HPOLL:
+                       if (decodeint(value, &hpoll)) {
+                               havevar[HAVE_HPOLL] = 1;
+                               if (hpoll < 0)
+                                       hpoll = NTP_MINPOLL;
+                       }
+                       break;
+                       case CP_PPOLL:
+                       if (decodeint(value, &ppoll)) {
+                               havevar[HAVE_PPOLL] = 1;
+                               if (ppoll < 0)
+                                       ppoll = NTP_MINPOLL;
+                       }
+                       break;
+                       case CP_REACH:
+                       if (decodeuint(value, &reach))
+                               havevar[HAVE_REACH] = 1;
+                       break;
+                       case CP_DELAY:
+                       if (decodetime(value, &estdelay))
+                               havevar[HAVE_DELAY] = 1;
+                       break;
+                       case CP_OFFSET:
+                       if (decodetime(value, &estoffset))
+                               havevar[HAVE_OFFSET] = 1;
+                       break;
+                       case CP_JITTER:
+                       if (pvl == peervarlist)
+                               if (decodetime(value, &estjitter))
+                                       havevar[HAVE_JITTER] = 1;
+                       break;
+                       case CP_DISPERSION:
+                       if (decodetime(value, &estdisp))
+                               havevar[HAVE_DISPERSION] = 1;
+                       break;
+                       case CP_REC:
+                       if (decodets(value, &rec))
+                               havevar[HAVE_REC] = 1;
+                       break;
+                       case CP_SRCPORT:
+                       if (decodeuint(value, &srcport))
+                               havevar[HAVE_SRCPORT] = 1;
+                       break;
+                       case CP_REFTIME:
+                       havevar[HAVE_REFTIME] = 1;
+                       if (!decodets(value, &reftime))
+                               L_CLR(&reftime);
+                       break;
+                       default:
+                       break;
+               }
+       }
+
+       /*
+        * Check to see if the srcport is NTP's port.  If not this probably
+        * isn't a valid peer association.
+        */
+       if (havevar[HAVE_SRCPORT] && srcport != NTP_PORT)
+               return (1);
+
+       /*
+        * Got everything, format the line
+        */
+       poll_sec = 1<<max(min3(ppoll, hpoll, NTP_MAXPOLL), NTP_MINPOLL);
+       if (pktversion > NTP_OLDVERSION)
+               c = flash3[CTL_PEER_STATVAL(rstatus) & 0x7];
+       else
+               c = flash2[CTL_PEER_STATVAL(rstatus) & 0x3];
+       if (numhosts > 1)
+               (void) fprintf(fp, "%-*s ", maxhostlen, currenthost);
+       if (af == 0 || srcadr.ss_family == af){
+               strcpy(clock_name, nntohost(&srcadr));
+               
+               (void) fprintf(fp,
+                       "%c%-15.15s %-15.15s %2ld %c %4.4s %4.4s  %3lo  %7.7s %8.7s %7.7s\n",
+                       c, clock_name, dstadr_refid, stratum, type,
+                       prettyinterval(whenbuf, when(&ts, &rec, &reftime)),
+                       prettyinterval(pollbuf, (int)poll_sec), reach,
+                       lfptoms(&estdelay, 3), lfptoms(&estoffset, 3),
+                       havevar[HAVE_JITTER] ? lfptoms(&estjitter, 3) :
+                       lfptoms(&estdisp, 3));
+               return (1);
+       }
+       else
+               return(1);
+}
+
+#undef HAVE_SRCADR
+#undef HAVE_DSTADR
+#undef HAVE_STRATUM
+#undef HAVE_PPOLL
+#undef HAVE_HPOLL
+#undef HAVE_REACH
+#undef HAVE_ESTDELAY
+#undef HAVE_ESTOFFSET
+#undef HAVE_JITTER
+#undef HAVE_ESTDISP
+#undef HAVE_REFID
+#undef HAVE_REC
+#undef HAVE_SRCPORT
+#undef HAVE_REFTIME
+#undef MAXHAVE
+
+
+/*
+ * dogetpeers - given an association ID, read and print the spreadsheet
+ *             peer variables.
+ */
+static int
+dogetpeers(
+       struct varlist *pvl,
+       int associd,
+       FILE *fp,
+       int af
+       )
+{
+       char *datap;
+       int res;
+       int dsize;
+       u_short rstatus;
+
+#ifdef notdef
+       res = doquerylist(pvl, CTL_OP_READVAR, associd, 0, &rstatus,
+                         &dsize, &datap);
+#else
+       /*
+        * Damn fuzzballs
+        */
+       res = doquery(CTL_OP_READVAR, associd, 0, 0, (char *)0, &rstatus,
+                         &dsize, &datap);
+#endif
+
+       if (res != 0)
+               return 0;
+
+       if (dsize == 0) {
+               if (numhosts > 1)
+                       (void) fprintf(stderr, "server=%s ", currenthost);
+               (void) fprintf(stderr,
+                                  "***No information returned for association %d\n",
+                                  associd);
+               return 0;
+       }
+
+       return doprintpeers(pvl, associd, (int)rstatus, dsize, datap, fp, af);
+}
+
+
+/*
+ * peers - print a peer spreadsheet
+ */
+static void
+dopeers(
+       int showall,
+       FILE *fp,
+       int af
+       )
+{
+       register int i;
+       char fullname[LENHOSTNAME];
+       struct sockaddr_storage netnum;
+
+       if (!dogetassoc(fp))
+               return;
+
+       for (i = 0; i < numhosts; ++i) {
+               if (getnetnum(chosts[i], &netnum, fullname, af))
+                       if ((int)strlen(fullname) > maxhostlen)
+                               maxhostlen = strlen(fullname);
+       }
+       if (numhosts > 1)
+               (void) fprintf(fp, "%-*.*s ", maxhostlen, maxhostlen, "server");
+       (void) fprintf(fp,
+                          "     remote           refid      st t when poll reach   delay   offset  jitter\n");
+       if (numhosts > 1)
+               for (i = 0; i <= maxhostlen; ++i)
+               (void) fprintf(fp, "=");
+       (void) fprintf(fp,
+                          "==============================================================================\n");
+
+       for (i = 0; i < numassoc; i++) {
+               if (!showall &&
+                       !(CTL_PEER_STATVAL(assoc_cache[i].status)
+                         & (CTL_PST_CONFIG|CTL_PST_REACH)))
+                       continue;
+               if (!dogetpeers(peervarlist, (int)assoc_cache[i].assid, fp, af)) {
+                       return;
+               }
+       }
+       return;
+}
+
+
+/*
+ * peers - print a peer spreadsheet
+ */
+/*ARGSUSED*/
+static void
+peers(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int af = 0;
+
+       if (pcmd->nargs == 1) {
+               if (pcmd->argval->ival == 6)
+                       af = AF_INET6;
+               else
+                       af = AF_INET;
+       }
+       dopeers(0, fp, af);
+}
+
+
+/*
+ * lpeers - print a peer spreadsheet including all fuzzball peers
+ */
+/*ARGSUSED*/
+static void
+lpeers(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int af = 0;
+
+       if (pcmd->nargs == 1) {
+               if (pcmd->argval->ival == 6)
+                       af = AF_INET6;
+               else
+                       af = AF_INET;
+       }
+       dopeers(1, fp, af);
+}
+
+
+/*
+ * opeers - print a peer spreadsheet
+ */
+static void
+doopeers(
+       int showall,
+       FILE *fp,
+       int af
+       )
+{
+       register int i;
+       char fullname[LENHOSTNAME];
+       struct sockaddr_storage netnum;
+
+       if (!dogetassoc(fp))
+               return;
+
+       for (i = 0; i < numhosts; ++i) {
+               if (getnetnum(chosts[i], &netnum, fullname, af))
+                       if ((int)strlen(fullname) > maxhostlen)
+                               maxhostlen = strlen(fullname);
+       }
+       if (numhosts > 1)
+               (void) fprintf(fp, "%-*.*s ", maxhostlen, maxhostlen, "server");
+       (void) fprintf(fp,
+                          "     remote           local      st t when poll reach   delay   offset    disp\n");
+       if (numhosts > 1)
+               for (i = 0; i <= maxhostlen; ++i)
+               (void) fprintf(fp, "=");
+       (void) fprintf(fp,
+                          "==============================================================================\n");
+
+       for (i = 0; i < numassoc; i++) {
+               if (!showall &&
+                       !(CTL_PEER_STATVAL(assoc_cache[i].status)
+                         & (CTL_PST_CONFIG|CTL_PST_REACH)))
+                       continue;
+               if (!dogetpeers(opeervarlist, (int)assoc_cache[i].assid, fp, af)) {
+                       return;
+               }
+       }
+       return;
+}
+
+
+/*
+ * opeers - print a peer spreadsheet the old way
+ */
+/*ARGSUSED*/
+static void
+opeers(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int af = 0;
+
+       if (pcmd->nargs == 1) {
+               if (pcmd->argval->ival == 6)
+                       af = AF_INET6;
+               else
+                       af = AF_INET;
+       }
+       doopeers(0, fp, af);
+}
+
+
+/*
+ * lopeers - print a peer spreadsheet including all fuzzball peers
+ */
+/*ARGSUSED*/
+static void
+lopeers(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int af = 0;
+
+       if (pcmd->nargs == 1) {
+               if (pcmd->argval->ival == 6)
+                       af = AF_INET6;
+               else
+                       af = AF_INET;
+       }
+       doopeers(1, fp, af);
+}
diff --git a/ntpq/ntpq.1 b/ntpq/ntpq.1
new file mode 100644 (file)
index 0000000..f65ae9a
--- /dev/null
@@ -0,0 +1,385 @@
+.TH NTPQ 1 2009-12-08 "( 4.2.4p8)" "Programmer's Manual"
+.\"  EDIT THIS FILE WITH CAUTION  (ntpq.1)
+.\"  
+.\"  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:27 AM EST
+.\"  From the definitions    ntpq-opts.def
+.\"  and the template file   agman1.tpl
+.\"
+.SH NAME
+ntpq \- standard NTP query program
+.SH SYNOPSIS
+.B ntpq
+.\" Mixture of short (flag) options and long options
+.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..."
+.br
+.in +8
+[ host ...]
+.SH "DESCRIPTION"
+This manual page documents, briefly, the \fBntpq\fP command.
+The
+[= prog-name =]
+utility program is used to query NTP servers which
+implement the standard NTP mode 6 control message formats defined
+in Appendix B of the NTPv3 specification RFC1305, requesting
+information about current state and/or changes in that state.
+The same formats are used in NTPv4, although some of the
+variables have changed and new ones added. The description on this
+page is for the NTPv4 variables.
+The program may be run either in interactive mode or controlled using
+command line arguments.
+Requests to read and write arbitrary
+variables can be assembled, with raw and pretty-printed output
+options being available.
+The
+[= prog-name =]
+utility can also obtain and print a
+list of peers in a common format by sending multiple queries to the
+server.
+
+If one or more request options is included on the command line
+when
+[= prog-name =]
+is executed, each of the requests will be sent
+to the NTP servers running on each of the hosts given as command
+line arguments, or on localhost by default.
+If no request options
+are given,
+[= prog-name =]
+will attempt to read commands from the
+standard input and execute these on the NTP server running on the
+first host given on the command line, again defaulting to localhost
+when no other host is specified.
+The
+[= prog-name =]
+utility will prompt for
+commands if the standard input is a terminal device.
+
+The
+[= prog-name =]
+utility uses NTP mode 6 packets to communicate with the
+NTP server, and hence can be used to query any compatible server on
+the network which permits it.
+Note that since NTP is a UDP protocol
+this communication will be somewhat unreliable, especially over
+large distances in terms of network topology.
+The
+[= prog-name =]
+utility makes
+one attempt to retransmit requests, and will time requests out if
+the remote host is not heard from within a suitable timeout
+time.
+
+Specifying a
+command line option other than
+.Fl i
+or
+.Fl n
+will
+cause the specified query (queries) to be sent to the indicated
+host(s) immediately.
+Otherwise,
+[= prog-name =]  
+will attempt to read
+interactive format commands from the standard input.
+.Ss "Internal Commands"
+Interactive format commands consist of a keyword followed by zero
+to four arguments.
+Only enough characters of the full keyword to
+uniquely identify the command need be typed.
+
+A
+number of interactive format commands are executed entirely within
+the
+[= prog-name =]
+utility itself and do not result in NTP mode 6
+requests being sent to a server.
+These are described following.
+.sp
+.IR "? [command_keyword]"
+.sp 1x help [command_keyword]
+A
+.Ql \&?
+by itself will print a list of all the command
+keywords known to this incarnation of
+[= prog-name =] .
+A
+.Ql \&?
+followed by a command keyword will print function and usage
+information about the command.
+This command is probably a better
+source of information about
+[= prog-name =]
+than this manual
+page.
+.sp
+.IR "addvars"
+.Ar variable_name [=value] ...
+.Xc
+.sp
+.IR "rmvars variable_name ..."
+.sp
+.IR "clearvars"
+The data carried by NTP mode 6 messages consists of a list of
+items of the form
+.Ql variable_name=value ,
+where the
+.Ql =value
+is ignored, and can be omitted,
+in requests to the server to read variables.
+The
+[= prog-name =]
+utility maintains an internal list in which data to be included in control
+messages can be assembled, and sent using the
+.Ic readlist
+and
+.Ic writelist
+commands described below.
+The
+.Ic addvars
+command allows variables and their optional values to be added to
+the list.
+If more than one variable is to be added, the list should
+be comma-separated and not contain white space.
+The
+.Ic rmvars
+command can be used to remove individual variables from the list,
+while the
+.Ic clearlist
+command removes all variables from the
+list.
+.sp
+.IR "authenticate [ yes | no ]"
+Normally
+[= prog-name =]
+does not authenticate requests unless
+they are write requests.
+The command
+.Ql authenticate yes
+causes
+[= prog-name =]
+to send authentication with all requests it
+makes.
+Authenticated requests causes some servers to handle
+requests slightly differently, and can occasionally melt the CPU in
+fuzzballs if you turn authentication on before doing a
+.Ic peer
+display.
+The command
+.Ql authenticate
+causes
+[= prog-name =]
+to display whether or not
+[= prog-name =]
+is currently autheinticating requests.
+.sp
+.IR "cooked"
+Causes output from query commands to be "cooked", so that
+variables which are recognized by
+[= prog-name =]
+will have their
+values reformatted for human consumption.
+Variables which
+[= prog-name =]
+thinks should have a decodable value but didn't are
+marked with a trailing
+.Ql \&? .
+.@item debug [
+.Cm more |
+.Cm less |
+.Cm off
+]
+.Xc
+With no argument, displays the current debug level.
+Otherwise, the debug level is changed to the indicated level.
+.sp
+.IR "delay milliseconds"
+Specify a time interval to be added to timestamps included in
+requests which require authentication.
+This is used to enable
+(unreliable) server reconfiguration over long delay network paths
+or between machines whose clocks are unsynchronized.
+Actually the
+server does not now require timestamps in authenticated requests,
+so this command may be obsolete.
+.sp
+.IR "host hostname"
+Set the host to which future queries will be sent.
+Hostname may
+be either a host name or a numeric address.
+.sp
+.IR "hostnames Cm yes | Cm no"
+If
+.Cm yes
+is specified, host names are printed in
+information displays.
+If
+.Cm no
+is specified, numeric
+addresses are printed instead.
+The default is
+.Cm yes ,
+unless
+modified using the command line
+.Fl n
+switch.
+.sp
+.IR "keyid keyid"
+This command allows the specification of a key number to be
+used to authenticate configuration requests.
+This must correspond
+to a key number the server has been configured to use for this
+purpose.
+.sp
+.IR "ntpversion ["
+.Cm 1 |
+.Cm 2 |
+.Cm 3 |
+.Cm 4
+]
+.Xc
+Sets the NTP version number which
+[= prog-name =]
+claims in
+packets.
+Defaults to 3, Note that mode 6 control messages (and
+modes, for that matter) didn't exist in NTP version 1.
+There appear
+to be no servers left which demand version 1.
+With no argument, displays the current NTP version that will be used
+when communicating with servers.
+.sp
+.IR "quit"
+Exit
+[= prog-name =] .
+.sp
+.IR "passwd"
+This command prompts you to type in a password (which will not
+be echoed) which will be used to authenticate configuration
+requests.
+The password must correspond to the key configured for
+use by the NTP server for this purpose if such requests are to be
+successful.
+.sp
+.IR "raw"
+Causes all output from query commands is printed as received
+from the remote server.
+The only formating/interpretation done on
+the data is to transform nonascii data into a printable (but barely
+understandable) form.
+.sp
+.IR "timeout Ar milliseconds"
+Specify a timeout period for responses to server queries.
+The
+default is about 5000 milliseconds.
+Note that since
+[= prog-name =]
+retries each query once after a timeout, the total waiting time for
+a timeout will be twice the timeout value set.
+.br
+
+.SH OPTIONS
+.TP
+.BR \-4 ", " \--ipv4
+Force IPv4 DNS name resolution.
+This option is a member of the ipv4 class of options.
+.sp
+Force DNS resolution of following host names on the command line
+to the IPv4 namespace.
+.TP
+.BR \-6 ", " \--ipv6
+Force IPv6 DNS name resolution.
+This option is a member of the ipv4 class of options.
+.sp
+Force DNS resolution of following host names on the command line
+to the IPv6 namespace.
+.TP
+.BR \-c " \fIcmd\fP, " \--command "=" \fIcmd\fP
+run a command and exit.
+This option may appear an unlimited number of times.
+.sp
+The following argument is interpreted as an interactive format command
+and is added to the list of commands to be executed on the specified
+host(s).
+.TP
+.BR \-d ", " \--debug-level
+Increase output debug message level.
+This option may appear an unlimited number of times.
+.sp
+Increase the debugging message output level.
+.TP
+.BR \-D " \fIstring\fP, " \--set-debug-level "=" \fIstring\fP
+Set the output debug message level.
+This option may appear an unlimited number of times.
+.sp
+Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+.TP
+.BR \-p ", " \--peers
+Print a list of the peers.
+This option must not appear in combination with any of the following options:
+interactive.
+.sp
+Print a list of the peers known to the server as well as a summary
+of their state. This is equivalent to the 'peers' interactive command.
+.TP
+.BR \-i ", " \--interactive
+Force ntpq to operate in interactive mode.
+This option must not appear in combination with any of the following options:
+command, peers.
+.sp
+Force ntpq to operate in interactive mode.  Prompts will be written
+to the standard output and commands read from the standard input.
+.TP
+.BR \-n ", " \--numeric
+numeric host addresses.
+.sp
+Output all host addresses in dotted-quad numeric format rather than
+converting to the canonical host names. 
+.TP
+.BR \-? , " \--help"
+Display usage information and exit.
+.TP
+.BR \-! , " \--more-help"
+Extended usage information passed thru pager.
+.TP
+.BR \-> " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]"
+Save the option state to \fIrcfile\fP.  The default is the \fIlast\fP
+configuration file listed in the \fBOPTION PRESETS\fP section, below.
+.TP
+.BR \-< " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts"
+Load options from \fIrcfile\fP.
+The \fIno-load-opts\fP form will disable the loading
+of earlier RC/INI files.  \fI--no-load-opts\fP is handled early,
+out of order.
+.TP
+.BR \-v " [{\fIv|c|n\fP}]," " \--version" "[=\fI{v|c|n}\fP]"
+Output version of program and exit.  The default mode is `v', a simple
+version.  The `c' mode will print copyright information and `n' will
+print the full copyright notice.
+.SH OPTION PRESETS
+Any option that is not marked as \fInot presettable\fP may be preset
+by loading values from configuration ("RC" or ".INI") file(s) and values from
+environment variables named:
+.nf
+  \fBNTPQ_<option-name>\fP or \fBNTPQ\fP
+.fi
+.aj
+The environmental presets take precedence (are processed later than)
+the configuration files.
+The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP".
+If any of these are directories, then the file \fI.ntprc\fP
+is searched for within those directories.
+.SH AUTHOR
+David L. Mills and/or others
+.br
+Please send bug reports to:  http://bugs.ntp.org, bugs@ntp.org
+
+.PP
+.nf
+.na
+see html/copyright.html
+.fi
+.ad
+.PP
+This manual page was \fIAutoGen\fP-erated from the \fBntpq\fP
+option definitions.
diff --git a/ntpq/ntpq.c b/ntpq/ntpq.c
new file mode 100644 (file)
index 0000000..2e51b35
--- /dev/null
@@ -0,0 +1,3293 @@
+/*
+ * ntpq - query an NTP server using mode 6 commands
+ */
+
+#include <stdio.h>
+
+#include <ctype.h>
+#include <signal.h>
+#include <setjmp.h>
+#include <sys/types.h>
+#include <sys/time.h>
+
+#include "ntpq.h"
+#include "ntp_unixtime.h"
+#include "ntp_calendar.h"
+#include "ntp_io.h"
+#include "ntp_select.h"
+#include "ntp_stdlib.h"
+/* Don't include ISC's version of IPv6 variables and structures */
+#define ISC_IPV6_H 1
+#include "isc/net.h"
+#include "isc/result.h"
+
+#include "ntpq-opts.h"
+
+#ifdef SYS_WINNT
+# include <Mswsock.h>
+# include <io.h>
+#else
+# define closesocket close
+#endif /* SYS_WINNT */
+
+#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
+# include <readline/readline.h>
+# include <readline/history.h>
+#endif /* HAVE_LIBREADLINE || HAVE_LIBEDIT */
+
+#ifdef SYS_VXWORKS
+                               /* vxWorks needs mode flag -casey*/
+# define open(name, flags)   open(name, flags, 0777)
+# define SERVER_PORT_NUM     123
+#endif
+
+/* we use COMMAND as an autogen keyword */
+#ifdef COMMAND
+# undef COMMAND
+#endif
+
+/*
+ * Because we potentially understand a lot of commands we will run
+ * interactive if connected to a terminal.
+ */
+int interactive = 0;           /* set to 1 when we should prompt */
+const char *prompt = "ntpq> "; /* prompt to ask him about */
+
+
+/*
+ * for get_systime()
+ */
+s_char sys_precision;          /* local clock precision (log2 s) */
+
+/*
+ * Keyid used for authenticated requests.  Obtained on the fly.
+ */
+u_long info_auth_keyid = 0;
+
+/*
+ * Type of key md5
+ */
+#define        KEY_TYPE_MD5    4
+
+static int info_auth_keytype = KEY_TYPE_MD5;   /* MD5 */
+u_long current_time;           /* needed by authkeys; not used */
+
+/*
+ * Flag which indicates we should always send authenticated requests
+ */
+int always_auth = 0;
+
+/*
+ * Flag which indicates raw mode output.
+ */
+int rawmode = 0;
+
+/*
+ * Packet version number we use
+ */
+u_char pktversion = NTP_OLDVERSION + 1;
+
+/*
+ * Don't jump if no set jmp.
+ */
+volatile int jump = 0;
+
+/*
+ * Format values
+ */
+#define        PADDING 0
+#define        TS      1       /* time stamp */
+#define        FL      2       /* l_fp type value */
+#define        FU      3       /* u_fp type value */
+#define        FS      4       /* s_fp type value */
+#define        UI      5       /* unsigned integer value */
+#define        SI      6       /* signed integer value */
+#define        HA      7       /* host address */
+#define        NA      8       /* network address */
+#define        ST      9       /* string value */
+#define        RF      10      /* refid (sometimes string, sometimes not) */
+#define        LP      11      /* leap (print in binary) */
+#define        OC      12      /* integer, print in octal */
+#define        MD      13      /* mode */
+#define        AR      14      /* array of times */
+#define FX     15      /* test flags */
+#define        EOV     255     /* end of table */
+
+
+/*
+ * System variable values.  The array can be indexed by
+ * the variable index to find the textual name.
+ */
+struct ctl_var sys_var[] = {
+       { 0,            PADDING, "" },          /* 0 */
+       { CS_LEAP,      LP,     "leap" },       /* 1 */
+       { CS_STRATUM,   UI,     "stratum" },    /* 2 */
+       { CS_PRECISION, SI,     "precision" },  /* 3 */
+       { CS_ROOTDELAY, FS,     "rootdelay" },  /* 4 */
+       { CS_ROOTDISPERSION, FU, "rootdispersion" }, /* 5 */
+       { CS_REFID,     RF,     "refid" },      /* 6 */
+       { CS_REFTIME,   TS,     "reftime" },    /* 7 */
+       { CS_POLL,      UI,     "poll" },       /* 8 */
+       { CS_PEERID,    UI,     "peer" },       /* 9 */
+       { CS_STATE,     UI,     "state" },      /* 10 */
+       { CS_OFFSET,    FL,     "offset" },     /* 11 */
+       { CS_DRIFT,     FS,     "frequency" },  /* 12 */
+       { CS_JITTER,    FU,     "jitter" },     /* 13 */
+       { CS_CLOCK,     TS,     "clock" },      /* 14 */
+       { CS_PROCESSOR, ST,     "processor" },  /* 15 */
+       { CS_SYSTEM,    ST,     "system" },     /* 16 */
+       { CS_VERSION,   ST,     "version" },    /* 17 */
+       { CS_STABIL,    FS,     "stability" },  /* 18 */
+       { CS_VARLIST,   ST,     "sys_var_list" }, /* 19 */
+       { 0,            EOV,    ""      }
+};
+
+
+/*
+ * Peer variable list
+ */
+struct ctl_var peer_var[] = {
+       { 0,            PADDING, "" },          /* 0 */
+       { CP_CONFIG,    UI,     "config" },     /* 1 */
+       { CP_AUTHENABLE, UI,    "authenable" }, /* 2 */
+       { CP_AUTHENTIC, UI,     "authentic" },  /* 3 */
+       { CP_SRCADR,    HA,     "srcadr" },     /* 4 */
+       { CP_SRCPORT,   UI,     "srcport" },    /* 5 */
+       { CP_DSTADR,    NA,     "dstadr" },     /* 6 */
+       { CP_DSTPORT,   UI,     "dstport" },    /* 7 */
+       { CP_LEAP,      LP,     "leap" },       /* 8 */
+       { CP_HMODE,     MD,     "hmode" },      /* 9 */
+       { CP_STRATUM,   UI,     "stratum" },    /* 10 */
+       { CP_PPOLL,     UI,     "ppoll" },      /* 11 */
+       { CP_HPOLL,     UI,     "hpoll" },      /* 12 */
+       { CP_PRECISION, SI,     "precision" },  /* 13 */
+       { CP_ROOTDELAY, FS,     "rootdelay" },  /* 14 */
+       { CP_ROOTDISPERSION, FU, "rootdispersion" }, /* 15 */
+       { CP_REFID,     RF,     "refid" },      /* 16 */
+       { CP_REFTIME,   TS,     "reftime" },    /* 17 */
+       { CP_ORG,       TS,     "org" },        /* 18 */
+       { CP_REC,       TS,     "rec" },        /* 19 */
+       { CP_XMT,       TS,     "xmt" },        /* 20 */
+       { CP_REACH,     OC,     "reach" },      /* 21 */
+       { CP_UNREACH,   UI,     "unreach" },    /* 22 */
+       { CP_TIMER,     UI,     "timer" },      /* 23 */
+       { CP_DELAY,     FS,     "delay" },      /* 24 */
+       { CP_OFFSET,    FL,     "offset" },     /* 25 */
+       { CP_JITTER,    FU,     "jitter" },     /* 26 */
+       { CP_DISPERSION, FU,    "dispersion" }, /* 27 */
+       { CP_KEYID,     UI,     "keyid" },      /* 28 */
+       { CP_FILTDELAY, AR,     "filtdelay" },  /* 29 */
+       { CP_FILTOFFSET, AR,    "filtoffset" }, /* 30 */
+       { CP_PMODE,     ST,     "pmode" },      /* 31 */
+       { CP_RECEIVED,  UI,     "received" },   /* 32 */
+       { CP_SENT,      UI,     "sent" },       /* 33 */
+       { CP_FILTERROR, AR,     "filtdisp" },   /* 34 */
+       { CP_FLASH,     FX,     "flash" },      /* 35 */ 
+       { CP_TTL,       UI,     "ttl" },        /* 36 */
+       /*
+        * These are duplicate entries so that we can
+        * process deviant version of the ntp protocol.
+        */
+       { CP_SRCADR,    HA,     "peeraddr" },   /* 4 */
+       { CP_SRCPORT,   UI,     "peerport" },   /* 5 */
+       { CP_PPOLL,     UI,     "peerpoll" },   /* 11 */
+       { CP_HPOLL,     UI,     "hostpoll" },   /* 12 */
+       { CP_FILTERROR, AR,     "filterror" },  /* 34 */
+       { 0,            EOV,    ""      }
+};
+
+
+/*
+ * Clock variable list
+ */
+struct ctl_var clock_var[] = {
+       { 0,            PADDING, "" },          /* 0 */
+       { CC_TYPE,      UI,     "type" },       /* 1 */
+       { CC_TIMECODE,  ST,     "timecode" },   /* 2 */
+       { CC_POLL,      UI,     "poll" },       /* 3 */
+       { CC_NOREPLY,   UI,     "noreply" },    /* 4 */
+       { CC_BADFORMAT, UI,     "badformat" },  /* 5 */
+       { CC_BADDATA,   UI,     "baddata" },    /* 6 */
+       { CC_FUDGETIME1, FL,    "fudgetime1" }, /* 7 */
+       { CC_FUDGETIME2, FL,    "fudgetime2" }, /* 8 */
+       { CC_FUDGEVAL1, UI,     "stratum" },    /* 9 */
+       { CC_FUDGEVAL2, RF,     "refid" },      /* 10 */
+       { CC_FLAGS,     UI,     "flags" },      /* 11 */
+       { CC_DEVICE,    ST,     "device" },     /* 12 */
+       { 0,            EOV,    ""      }
+};
+
+
+/*
+ * flasher bits
+ */
+static const char *tstflagnames[] = {
+       "pkt_dup",              /* TEST1 */
+       "pkt_bogus",            /* TEST2 */
+       "pkt_proto",            /* TEST3 */
+       "pkt_denied",           /* TEST4 */
+       "pkt_auth",             /* TEST5 */
+       "pkt_synch",            /* TEST6 */
+       "pkt_dist",             /* TEST7 */
+       "pkt_autokey",          /* TEST8 */
+       "pkt_crypto",           /* TEST9 */
+       "peer_stratum",         /* TEST10 */
+       "peer_dist",            /* TEST11 */
+       "peer_loop",            /* TEST12 */
+       "peer_unfit"            /* TEST13 */
+};
+
+
+int            ntpqmain        P((int, char **));
+/*
+ * Built in command handler declarations
+ */
+static int     openhost        P((const char *));
+static int     sendpkt         P((char *, int));
+static int     getresponse     P((int, int, u_short *, int *, char **, int));
+static int     sendrequest     P((int, int, int, int, char *));
+static char *  tstflags        P((u_long));
+static void    getcmds         P((void));
+static RETSIGTYPE abortcmd     P((int));
+static void    docmd           P((const char *));
+static void    tokenize        P((const char *, char **, int *));
+static int     findcmd         P((char *, struct xcmd *, struct xcmd *, struct xcmd **));
+static int     getarg          P((char *, int, arg_v *));
+static int     rtdatetolfp     P((char *, l_fp *));
+static int     decodearr       P((char *, int *, l_fp *));
+static void    help            P((struct parse *, FILE *));
+#ifdef QSORT_USES_VOID_P
+static int     helpsort        P((const void *, const void *));
+#else
+static int     helpsort        P((char **, char **));
+#endif
+static void    printusage      P((struct xcmd *, FILE *));
+static void    timeout         P((struct parse *, FILE *));
+static void    auth_delay      P((struct parse *, FILE *));
+static void    host            P((struct parse *, FILE *));
+static void    ntp_poll        P((struct parse *, FILE *));
+static void    keyid           P((struct parse *, FILE *));
+static void    keytype         P((struct parse *, FILE *));
+static void    passwd          P((struct parse *, FILE *));
+static void    hostnames       P((struct parse *, FILE *));
+static void    setdebug        P((struct parse *, FILE *));
+static void    quit            P((struct parse *, FILE *));
+static void    version         P((struct parse *, FILE *));
+static void    raw             P((struct parse *, FILE *));
+static void    cooked          P((struct parse *, FILE *));
+static void    authenticate    P((struct parse *, FILE *));
+static void    ntpversion      P((struct parse *, FILE *));
+static void    warning         P((const char *, const char *, const char *));
+static void    error           P((const char *, const char *, const char *));
+static u_long  getkeyid        P((const char *));
+static void    atoascii        P((int, char *, char *));
+static void    makeascii       P((int, char *, FILE *));
+static void    rawprint        P((int, int, char *, int, FILE *));
+static void    startoutput     P((void));
+static void    output          P((FILE *, char *, char *));
+static void    endoutput       P((FILE *));
+static void    outputarr       P((FILE *, char *, int, l_fp *));
+static void    cookedprint     P((int, int, char *, int, FILE *));
+#ifdef QSORT_USES_VOID_P
+static int     assoccmp        P((const void *, const void *));
+#else
+static int     assoccmp        P((struct association *, struct association *));
+#endif /* sgi || bsdi */
+
+
+/*
+ * Built-in commands we understand
+ */
+struct xcmd builtins[] = {
+       { "?",          help,           {  OPT|NTP_STR, NO, NO, NO },
+         { "command", "", "", "" },
+         "tell the use and syntax of commands" },
+       { "help",       help,           {  OPT|NTP_STR, NO, NO, NO },
+         { "command", "", "", "" },
+         "tell the use and syntax of commands" },
+       { "timeout",    timeout,        { OPT|NTP_UINT, NO, NO, NO },
+         { "msec", "", "", "" },
+         "set the primary receive time out" },
+       { "delay",      auth_delay,     { OPT|NTP_INT, NO, NO, NO },
+         { "msec", "", "", "" },
+         "set the delay added to encryption time stamps" },
+       { "host",       host,           { OPT|NTP_STR, OPT|NTP_STR, NO, NO },
+         { "-4|-6", "hostname", "", "" },
+         "specify the host whose NTP server we talk to" },
+       { "poll",       ntp_poll,       { OPT|NTP_UINT, OPT|NTP_STR, NO, NO },
+         { "n", "verbose", "", "" },
+         "poll an NTP server in client mode `n' times" },
+       { "passwd",     passwd,         { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "specify a password to use for authenticated requests"},
+       { "hostnames",  hostnames,      { OPT|NTP_STR, NO, NO, NO },
+         { "yes|no", "", "", "" },
+         "specify whether hostnames or net numbers are printed"},
+       { "debug",      setdebug,       { OPT|NTP_STR, NO, NO, NO },
+         { "no|more|less", "", "", "" },
+         "set/change debugging level" },
+       { "quit",       quit,           { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "exit ntpq" },
+       { "exit",       quit,           { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "exit ntpq" },
+       { "keyid",      keyid,          { OPT|NTP_UINT, NO, NO, NO },
+         { "key#", "", "", "" },
+         "set keyid to use for authenticated requests" },
+       { "version",    version,        { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "print version number" },
+       { "raw",        raw,            { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "do raw mode variable output" },
+       { "cooked",     cooked,         { NO, NO, NO, NO },
+         { "", "", "", "" },
+         "do cooked mode variable output" },
+       { "authenticate", authenticate, { OPT|NTP_STR, NO, NO, NO },
+         { "yes|no", "", "", "" },
+         "always authenticate requests to this server" },
+       { "ntpversion", ntpversion,     { OPT|NTP_UINT, NO, NO, NO },
+         { "version number", "", "", "" },
+         "set the NTP version number to use for requests" },
+       { "keytype",    keytype,        { OPT|NTP_STR, NO, NO, NO },
+         { "key type (md5|des)", "", "", "" },
+         "set key type to use for authenticated requests (des|md5)" },
+       { 0,            0,              { NO, NO, NO, NO },
+         { "", "", "", "" }, "" }
+};
+
+
+/*
+ * Default values we use.
+ */
+#define        DEFTIMEOUT      (5)             /* 5 second time out */
+#define        DEFSTIMEOUT     (2)             /* 2 second time out after first */
+#define        DEFDELAY        0x51EB852       /* 20 milliseconds, l_fp fraction */
+#define        DEFHOST         "localhost"     /* default host name */
+#define        LENHOSTNAME     256             /* host name is 256 characters long */
+#define        MAXCMDS         100             /* maximum commands on cmd line */
+#define        MAXHOSTS        200             /* maximum hosts on cmd line */
+#define        MAXLINE         512             /* maximum line length */
+#define        MAXTOKENS       (1+MAXARGS+2)   /* maximum number of usable tokens */
+#define        MAXVARLEN       256             /* maximum length of a variable name */
+#define        MAXVALLEN       400             /* maximum length of a variable value */
+#define        MAXOUTLINE      72              /* maximum length of an output line */
+#define SCREENWIDTH     76              /* nominal screen width in columns */
+
+/*
+ * Some variables used and manipulated locally
+ */
+struct timeval tvout = { DEFTIMEOUT, 0 };      /* time out for reads */
+struct timeval tvsout = { DEFSTIMEOUT, 0 };    /* secondary time out */
+l_fp delay_time;                               /* delay time */
+char currenthost[LENHOSTNAME];                 /* current host name */
+struct sockaddr_in hostaddr = { 0 };           /* host address */
+int showhostnames = 1;                         /* show host names by default */
+
+int ai_fam_templ;                              /* address family */
+int ai_fam_default;                            /* default address family */
+SOCKET sockfd;                                 /* fd socket is opened on */
+int havehost = 0;                              /* set to 1 when host open */
+int s_port = 0;
+struct servent *server_entry = NULL;           /* server entry for ntp */
+
+#ifdef SYS_WINNT
+DWORD NumberOfBytesWritten;
+
+HANDLE TimerThreadHandle = NULL;       /* 1998/06/03 - Used in ntplib/machines.c */
+void timer(void)       {  ; }; /* 1998/06/03 - Used in ntplib/machines.c */
+
+#endif /* SYS_WINNT */
+
+/*
+ * Sequence number used for requests.  It is incremented before
+ * it is used.
+ */
+u_short sequence;
+
+/*
+ * Holds data returned from queries.  Declare buffer long to be sure of
+ * alignment.
+ */
+#define        MAXFRAGS        24              /* maximum number of fragments */
+#define        DATASIZE        (MAXFRAGS*480)  /* maximum amount of data */
+long pktdata[DATASIZE/sizeof(long)];
+
+/*
+ * Holds association data for use with the &n operator.
+ */
+struct association assoc_cache[MAXASSOC];
+int numassoc = 0;              /* number of cached associations */
+
+/*
+ * For commands typed on the command line (with the -c option)
+ */
+int numcmds = 0;
+const char *ccmds[MAXCMDS];
+#define        ADDCMD(cp)      if (numcmds < MAXCMDS) ccmds[numcmds++] = (cp)
+
+/*
+ * When multiple hosts are specified.
+ */
+int numhosts = 0;
+const char *chosts[MAXHOSTS];
+#define        ADDHOST(cp)     if (numhosts < MAXHOSTS) chosts[numhosts++] = (cp)
+
+/*
+ * Error codes for internal use
+ */
+#define        ERR_UNSPEC              256
+#define        ERR_INCOMPLETE  257
+#define        ERR_TIMEOUT             258
+#define        ERR_TOOMUCH             259
+
+/*
+ * Macro definitions we use
+ */
+#define        ISSPACE(c)      ((c) == ' ' || (c) == '\t')
+#define        ISEOL(c)        ((c) == '\n' || (c) == '\r' || (c) == '\0')
+#define        STREQ(a, b)     (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+/*
+ * Jump buffer for longjumping back to the command level
+ */
+jmp_buf interrupt_buf;
+
+/*
+ * Points at file being currently printed into
+ */
+FILE *current_output;
+
+/*
+ * Command table imported from ntpdc_ops.c
+ */
+extern struct xcmd opcmds[];
+
+char *progname;
+volatile int debug;
+
+#ifdef NO_MAIN_ALLOWED
+CALL(ntpq,"ntpq",ntpqmain);
+
+void clear_globals(void)
+{
+    extern int ntp_optind;
+    showhostnames = 0;                         /* don'tshow host names by default */
+    ntp_optind = 0;
+    server_entry = NULL;            /* server entry for ntp */
+    havehost = 0;                              /* set to 1 when host open */
+    numassoc = 0;              /* number of cached associations */
+    numcmds = 0;
+    numhosts = 0;
+}
+#endif
+
+/*
+ * main - parse arguments and handle options
+ */
+#ifndef NO_MAIN_ALLOWED
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       return ntpqmain(argc, argv);
+}
+#endif
+
+int
+ntpqmain(
+       int argc,
+       char *argv[]
+       )
+{
+       extern int ntp_optind;
+
+#ifdef SYS_VXWORKS
+       clear_globals();
+       taskPrioritySet(taskIdSelf(), 100 );
+#endif
+
+       delay_time.l_ui = 0;
+       delay_time.l_uf = DEFDELAY;
+
+#ifdef SYS_WINNT
+       if (!Win32InitSockets())
+       {
+               fprintf(stderr, "No useable winsock.dll:");
+               exit(1);
+       }
+#endif /* SYS_WINNT */
+
+       /* Check to see if we have IPv6. Otherwise force the -4 flag */
+       if (isc_net_probeipv6() != ISC_R_SUCCESS) {
+               ai_fam_default = AF_INET;
+       }
+
+       progname = argv[0];
+
+       {
+               int optct = optionProcess(&ntpqOptions, argc, argv);
+               argc -= optct;
+               argv += optct;
+       }
+
+       switch (WHICH_IDX_IPV4) {
+           case INDEX_OPT_IPV4:
+               ai_fam_templ = AF_INET;
+               break;
+           case INDEX_OPT_IPV6:
+               ai_fam_templ = AF_INET6;
+               break;
+           default:
+               ai_fam_templ = ai_fam_default;
+               break;
+       }
+
+       if (HAVE_OPT(COMMAND)) {
+               int             cmdct = STACKCT_OPT( COMMAND );
+               const char**    cmds  = STACKLST_OPT( COMMAND );
+
+               while (cmdct-- > 0) {
+                       ADDCMD(*cmds++);
+               }
+       }
+
+       debug = DESC(DEBUG_LEVEL).optOccCt;
+
+       if (HAVE_OPT(INTERACTIVE)) {
+               interactive = 1;
+       }
+
+       if (HAVE_OPT(NUMERIC)) {
+               showhostnames = 0;
+       }
+
+       if (HAVE_OPT(PEERS)) {
+               ADDCMD("peers");
+       }
+
+#if 0
+       while ((c = ntp_getopt(argc, argv, "46c:dinp")) != EOF)
+           switch (c) {
+               case '4':
+                   ai_fam_templ = AF_INET;
+                   break;
+               case '6':
+                   ai_fam_templ = AF_INET6;
+                   break;
+               case 'c':
+                   ADDCMD(ntp_optarg);
+                   break;
+               case 'd':
+                   ++debug;
+                   break;
+               case 'i':
+                   interactive = 1;
+                   break;
+               case 'n':
+                   showhostnames = 0;
+                   break;
+               case 'p':
+                   ADDCMD("peers");
+                   break;
+               default:
+                   errflg++;
+                   break;
+           }
+       if (errflg) {
+               (void) fprintf(stderr,
+                              "usage: %s [-46dinp] [-c cmd] host ...\n",
+                              progname);
+               exit(2);
+       }
+#endif
+       if (ntp_optind == argc) {
+               ADDHOST(DEFHOST);
+       } else {
+               for (; ntp_optind < argc; ntp_optind++)
+                   ADDHOST(argv[ntp_optind]);
+       }
+
+       if (numcmds == 0 && interactive == 0
+           && isatty(fileno(stdin)) && isatty(fileno(stderr))) {
+               interactive = 1;
+       }
+
+#ifndef SYS_WINNT /* Under NT cannot handle SIGINT, WIN32 spawns a handler */
+       if (interactive)
+           (void) signal_no_reset(SIGINT, abortcmd);
+#endif /* SYS_WINNT */
+
+       if (numcmds == 0) {
+               (void) openhost(chosts[0]);
+               getcmds();
+       } else {
+               int ihost;
+               int icmd;
+
+               for (ihost = 0; ihost < numhosts; ihost++) {
+                       if (openhost(chosts[ihost]))
+                           for (icmd = 0; icmd < numcmds; icmd++)
+                               docmd(ccmds[icmd]);
+               }
+       }
+#ifdef SYS_WINNT
+       WSACleanup();
+#endif /* SYS_WINNT */
+       return 0;
+}
+
+
+/*
+ * openhost - open a socket to a host
+ */
+static int
+openhost(
+       const char *hname
+       )
+{
+       char temphost[LENHOSTNAME];
+       int a_info, i;
+       struct addrinfo hints, *ai = NULL;
+       register const char *cp;
+       char name[LENHOSTNAME];
+       char service[5];
+
+       /*
+        * We need to get by the [] if they were entered
+        */
+       
+       cp = hname;
+       
+       if(*cp == '[') {
+               cp++;
+               for(i = 0; *cp != ']'; cp++, i++)
+                       name[i] = *cp;
+       name[i] = '\0';
+       hname = name;
+       }
+
+       /*
+        * First try to resolve it as an ip address and if that fails,
+        * do a fullblown (dns) lookup. That way we only use the dns
+        * when it is needed and work around some implementations that
+        * will return an "IPv4-mapped IPv6 address" address if you
+        * give it an IPv4 address to lookup.
+        */
+       strcpy(service, "ntp");
+       memset((char *)&hints, 0, sizeof(struct addrinfo));
+       hints.ai_family = ai_fam_templ;
+       hints.ai_protocol = IPPROTO_UDP;
+       hints.ai_socktype = SOCK_DGRAM;
+       hints.ai_flags = AI_NUMERICHOST;
+
+       a_info = getaddrinfo(hname, service, &hints, &ai);
+       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(hname, service, &hints, &ai);      
+       }
+       /* Some older implementations don't like AI_ADDRCONFIG. */
+       if (a_info == EAI_BADFLAGS) {
+               hints.ai_flags = AI_CANONNAME;
+               a_info = getaddrinfo(hname, service, &hints, &ai);      
+       }
+       if (a_info != 0) {
+               (void) fprintf(stderr, "%s\n", gai_strerror(a_info));
+               return 0;
+       }
+
+       if (ai->ai_canonname == NULL) {
+               strncpy(temphost, stoa((struct sockaddr_storage *)ai->ai_addr),
+                   LENHOSTNAME);
+               temphost[LENHOSTNAME-1] = '\0';
+
+       } else {
+               strncpy(temphost, ai->ai_canonname, LENHOSTNAME);
+               temphost[LENHOSTNAME-1] = '\0';
+       }
+
+       if (debug > 2)
+           printf("Opening host %s\n", temphost);
+
+       if (havehost == 1) {
+               if (debug > 2)
+                   printf("Closing old host %s\n", currenthost);
+               (void) closesocket(sockfd);
+               havehost = 0;
+       }
+       (void) strcpy(currenthost, temphost);
+
+       /* port maps to the same location in both families */
+       s_port = ((struct sockaddr_in6 *)ai->ai_addr)->sin6_port;
+#ifdef SYS_VXWORKS
+       ((struct sockaddr_in6 *)&hostaddr)->sin6_port = htons(SERVER_PORT_NUM);
+       if (ai->ai_family == AF_INET)
+               *(struct sockaddr_in *)&hostaddr=
+                       *((struct sockaddr_in *)ai->ai_addr);
+       else
+               *(struct sockaddr_in6 *)&hostaddr=
+                       *((struct sockaddr_in6 *)ai->ai_addr);
+#endif /* SYS_VXWORKS */
+
+#ifdef SYS_WINNT
+       {
+               int optionValue = SO_SYNCHRONOUS_NONALERT;
+               int err;
+
+               err = setsockopt(INVALID_SOCKET, SOL_SOCKET, SO_OPENTYPE, (char *)&optionValue, sizeof(optionValue));
+               if (err != NO_ERROR) {
+                       (void) fprintf(stderr, "cannot open nonoverlapped sockets\n");
+                       exit(1);
+               }
+       }
+#endif /* SYS_WINNT */
+
+       sockfd = socket(ai->ai_family, SOCK_DGRAM, 0);
+       if (sockfd == INVALID_SOCKET) {
+               error("socket", "", "");
+       }
+
+       
+#ifdef NEED_RCVBUF_SLOP
+# ifdef SO_RCVBUF
+       { int rbufsize = DATASIZE + 2048;       /* 2K for slop */
+       if (setsockopt(sockfd, SOL_SOCKET, SO_RCVBUF,
+                      &rbufsize, sizeof(int)) == -1)
+           error("setsockopt", "", "");
+       }
+# endif
+#endif
+
+#ifdef SYS_VXWORKS
+       if (connect(sockfd, (struct sockaddr *)&hostaddr,
+                   sizeof(hostaddr)) == -1)
+#else
+       if (connect(sockfd, (struct sockaddr *)ai->ai_addr,
+                   ai->ai_addrlen) == -1)
+#endif /* SYS_VXWORKS */
+           error("connect", "", "");
+       if (a_info == 0)
+               freeaddrinfo(ai);
+       havehost = 1;
+       return 1;
+}
+
+
+/* XXX ELIMINATE sendpkt similar in ntpq.c, ntpdc.c, ntp_io.c, ntptrace.c */
+/*
+ * sendpkt - send a packet to the remote host
+ */
+static int
+sendpkt(
+       char *xdata,
+       int xdatalen
+       )
+{
+       if (debug >= 3)
+           printf("Sending %d octets\n", xdatalen);
+
+
+       if (send(sockfd, xdata, (size_t)xdatalen, 0) == -1) {
+               warning("write to %s failed", currenthost, "");
+               return -1;
+       }
+
+       if (debug >= 4) {
+               int first = 8;
+               printf("Packet data:\n");
+               while (xdatalen-- > 0) {
+                       if (first-- == 0) {
+                               printf("\n");
+                               first = 7;
+                       }
+                       printf(" %02x", *xdata++ & 0xff);
+               }
+               printf("\n");
+       }
+       return 0;
+}
+
+
+
+/*
+ * getresponse - get a (series of) response packet(s) and return the data
+ */
+static int
+getresponse(
+       int opcode,
+       int associd,
+       u_short *rstatus,
+       int *rsize,
+       char **rdata,
+       int timeo
+       )
+{
+       struct ntp_control rpkt;
+       struct timeval tvo;
+       u_short offsets[MAXFRAGS+1];
+       u_short counts[MAXFRAGS+1];
+       u_short offset;
+       u_short count;
+       int numfrags;
+       int seenlastfrag;
+       fd_set fds;
+       int n;
+
+       /*
+        * This is pretty tricky.  We may get between 1 and MAXFRAG packets
+        * back in response to the request.  We peel the data out of
+        * each packet and collect it in one long block.  When the last
+        * packet in the sequence is received we'll know how much data we
+        * should have had.  Note we use one long time out, should reconsider.
+        */
+       *rsize = 0;
+       if (rstatus)
+           *rstatus = 0;
+       *rdata = (char *)pktdata;
+
+       numfrags = 0;
+       seenlastfrag = 0;
+
+       FD_ZERO(&fds);
+
+    again:
+       if (numfrags == 0)
+           tvo = tvout;
+       else
+           tvo = tvsout;
+       
+       FD_SET(sockfd, &fds);
+       n = select(sockfd+1, &fds, (fd_set *)0, (fd_set *)0, &tvo);
+
+#if 0
+       if (debug >= 1)
+           printf("select() returns %d\n", n);
+#endif
+
+       if (n == -1) {
+               warning("select fails", "", "");
+               return -1;
+       }
+       if (n == 0) {
+               /*
+                * Timed out.  Return what we have
+                */
+               if (numfrags == 0) {
+                       if (timeo)
+                           (void) fprintf(stderr,
+                                          "%s: timed out, nothing received\n",
+                                          currenthost);
+                       return ERR_TIMEOUT;
+               } else {
+                       if (timeo)
+                           (void) fprintf(stderr,
+                                          "%s: timed out with incomplete data\n",
+                                          currenthost);
+                       if (debug) {
+                               printf("Received fragments:\n");
+                               for (n = 0; n < numfrags; n++)
+                                   printf("%4d %d\n", offsets[n],
+                                          counts[n]);
+                               if (seenlastfrag)
+                                   printf("last fragment received\n");
+                               else
+                                   printf("last fragment not received\n");
+                       }
+                       return ERR_INCOMPLETE;
+               }
+       }
+
+       n = recv(sockfd, (char *)&rpkt, sizeof(rpkt), 0);
+       if (n == -1) {
+               warning("read", "", "");
+               return -1;
+       }
+
+       if (debug >= 4) {
+               int len = n, first = 8;
+               char *data = (char *)&rpkt;
+
+               printf("Packet data:\n");
+               while (len-- > 0) {
+                       if (first-- == 0) {
+                               printf("\n");
+                               first = 7;
+                       }
+                       printf(" %02x", *data++ & 0xff);
+               }
+               printf("\n");
+       }
+
+       /*
+        * Check for format errors.  Bug proofing.
+        */
+       if (n < CTL_HEADER_LEN) {
+               if (debug)
+                   printf("Short (%d byte) packet received\n", n);
+               goto again;
+       }
+       if (PKT_VERSION(rpkt.li_vn_mode) > NTP_VERSION
+           || PKT_VERSION(rpkt.li_vn_mode) < NTP_OLDVERSION) {
+               if (debug)
+                   printf("Packet received with version %d\n",
+                          PKT_VERSION(rpkt.li_vn_mode));
+               goto again;
+       }
+       if (PKT_MODE(rpkt.li_vn_mode) != MODE_CONTROL) {
+               if (debug)
+                   printf("Packet received with mode %d\n",
+                          PKT_MODE(rpkt.li_vn_mode));
+               goto again;
+       }
+       if (!CTL_ISRESPONSE(rpkt.r_m_e_op)) {
+               if (debug)
+                   printf("Received request packet, wanted response\n");
+               goto again;
+       }
+
+       /*
+        * Check opcode and sequence number for a match.
+        * Could be old data getting to us.
+        */
+       if (ntohs(rpkt.sequence) != sequence) {
+               if (debug)
+                   printf(
+                           "Received sequnce number %d, wanted %d\n",
+                           ntohs(rpkt.sequence), sequence);
+               goto again;
+       }
+       if (CTL_OP(rpkt.r_m_e_op) != opcode) {
+               if (debug)
+                   printf(
+                           "Received opcode %d, wanted %d (sequence number okay)\n",
+                           CTL_OP(rpkt.r_m_e_op), opcode);
+               goto again;
+       }
+
+       /*
+        * Check the error code.  If non-zero, return it.
+        */
+       if (CTL_ISERROR(rpkt.r_m_e_op)) {
+               int errcode;
+
+               errcode = (ntohs(rpkt.status) >> 8) & 0xff;
+               if (debug && CTL_ISMORE(rpkt.r_m_e_op)) {
+                       printf("Error code %d received on not-final packet\n",
+                              errcode);
+               }
+               if (errcode == CERR_UNSPEC)
+                   return ERR_UNSPEC;
+               return errcode;
+       }
+
+       /*
+        * Check the association ID to make sure it matches what
+        * we sent.
+        */
+       if (ntohs(rpkt.associd) != associd) {
+               if (debug)
+                   printf("Association ID %d doesn't match expected %d\n",
+                          ntohs(rpkt.associd), associd);
+               /*
+                * Hack for silly fuzzballs which, at the time of writing,
+                * return an assID of sys.peer when queried for system variables.
+                */
+#ifdef notdef
+               goto again;
+#endif
+       }
+
+       /*
+        * Collect offset and count.  Make sure they make sense.
+        */
+       offset = ntohs(rpkt.offset);
+       count = ntohs(rpkt.count);
+
+       if (debug >= 3) {
+               int shouldbesize;
+               u_long key;
+               u_long *lpkt;
+               int maclen;
+
+               /*
+                * Usually we ignore authentication, but for debugging purposes
+                * we watch it here.
+                */
+               shouldbesize = CTL_HEADER_LEN + count;
+
+               /* round to 8 octet boundary */
+               shouldbesize = (shouldbesize + 7) & ~7;
+
+               if (n & 0x3) {
+                       printf("Packet not padded, size = %d\n", n);
+               } if ((maclen = n - shouldbesize) >= MIN_MAC_LEN) {
+                       printf(
+                               "Packet shows signs of authentication (total %d, data %d, mac %d)\n",
+                               n, shouldbesize, maclen);
+                       lpkt = (u_long *)&rpkt;
+                       printf("%08lx %08lx %08lx %08lx %08lx %08lx\n",
+                              (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) - 3]),
+                              (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) - 2]),
+                              (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) - 1]),
+                              (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long)]),
+                              (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) + 1]),
+                              (u_long)ntohl(lpkt[(n - maclen)/sizeof(u_long) + 2]));
+                       key = ntohl(lpkt[(n - maclen) / sizeof(u_long)]);
+                       printf("Authenticated with keyid %lu\n", (u_long)key);
+                       if (key != 0 && key != info_auth_keyid) {
+                               printf("We don't know that key\n");
+                       } else {
+                               if (authdecrypt(key, (u_int32 *)&rpkt,
+                                   n - maclen, maclen)) {
+                                       printf("Auth okay!\n");
+                               } else {
+                                       printf("Auth failed!\n");
+                               }
+                       }
+               }
+       }
+
+       if (debug >= 2)
+           printf("Got packet, size = %d\n", n);
+       if (count > (u_short)(n-CTL_HEADER_LEN)) {
+               if (debug)
+                   printf(
+                           "Received count of %d octets, data in packet is %d\n",
+                           count, n-CTL_HEADER_LEN);
+               goto again;
+       }
+       if (count == 0 && CTL_ISMORE(rpkt.r_m_e_op)) {
+               if (debug)
+                   printf("Received count of 0 in non-final fragment\n");
+               goto again;
+       }
+       if (offset + count > sizeof(pktdata)) {
+               if (debug)
+                   printf("Offset %d, count %d, too big for buffer\n",
+                          offset, count);
+               return ERR_TOOMUCH;
+       }
+       if (seenlastfrag && !CTL_ISMORE(rpkt.r_m_e_op)) {
+               if (debug)
+                   printf("Received second last fragment packet\n");
+               goto again;
+       }
+
+       /*
+        * So far, so good.  Record this fragment, making sure it doesn't
+        * overlap anything.
+        */
+       if (debug >= 2)
+           printf("Packet okay\n");;
+
+       if (numfrags == MAXFRAGS) {
+               if (debug)
+                   printf("Number of fragments exceeds maximum\n");
+               return ERR_TOOMUCH;
+       }
+       
+       for (n = 0; n < numfrags; n++) {
+               if (offset == offsets[n])
+                   goto again; /* duplicate */
+               if (offset < offsets[n])
+                   break;
+       }
+       
+       if ((u_short)(n > 0 && offsets[n-1] + counts[n-1]) > offset)
+           goto overlap;
+       if (n < numfrags && (u_short)(offset + count) > offsets[n])
+           goto overlap;
+       
+       {
+               register int i;
+               
+               for (i = numfrags; i > n; i--) {
+                       offsets[i] = offsets[i-1];
+                       counts[i] = counts[i-1];
+               }
+       }
+       offsets[n] = offset;
+       counts[n] = count;
+       numfrags++;
+
+       /*
+        * Got that stuffed in right.  Figure out if this was the last.
+        * Record status info out of the last packet.
+        */
+       if (!CTL_ISMORE(rpkt.r_m_e_op)) {
+               seenlastfrag = 1;
+               if (rstatus != 0)
+                   *rstatus = ntohs(rpkt.status);
+       }
+
+       /*
+        * Copy the data into the data buffer.
+        */
+       memmove((char *)pktdata + offset, (char *)rpkt.data, count);
+
+       /*
+        * If we've seen the last fragment, look for holes in the sequence.
+        * If there aren't any, we're done.
+        */
+       if (seenlastfrag && offsets[0] == 0) {
+               for (n = 1; n < numfrags; n++) {
+                       if (offsets[n-1] + counts[n-1] != offsets[n])
+                           break;
+               }
+               if (n == numfrags) {
+                       *rsize = offsets[numfrags-1] + counts[numfrags-1];
+                       return 0;
+               }
+       }
+       goto again;
+
+    overlap:
+       /*
+        * Print debugging message about overlapping fragments
+        */
+       if (debug)
+           printf("Overlapping fragments returned in response\n");
+       goto again;
+}
+
+
+/*
+ * sendrequest - format and send a request packet
+ */
+static int
+sendrequest(
+       int opcode,
+       int associd,
+       int auth,
+       int qsize,
+       char *qdata
+       )
+{
+       struct ntp_control qpkt;
+       int pktsize;
+
+       /*
+        * Check to make sure the data will fit in one packet
+        */
+       if (qsize > CTL_MAX_DATA_LEN) {
+               (void) fprintf(stderr,
+                              "***Internal error!  qsize (%d) too large\n",
+                              qsize);
+               return 1;
+       }
+
+       /*
+        * Fill in the packet
+        */
+       qpkt.li_vn_mode = PKT_LI_VN_MODE(0, pktversion, MODE_CONTROL);
+       qpkt.r_m_e_op = (u_char)(opcode & CTL_OP_MASK);
+       qpkt.sequence = htons(sequence);
+       qpkt.status = 0;
+       qpkt.associd = htons((u_short)associd);
+       qpkt.offset = 0;
+       qpkt.count = htons((u_short)qsize);
+
+       /*
+        * If we have data, copy it in and pad it out to a 64
+        * bit boundary.
+        */
+       if (qsize > 0) {
+               memmove((char *)qpkt.data, qdata, (unsigned)qsize);
+               pktsize = qsize + CTL_HEADER_LEN;
+               while (pktsize & (sizeof(u_long) - 1)) {
+                       qpkt.data[qsize++] = 0;
+                       pktsize++;
+               }
+       } else {
+               pktsize = CTL_HEADER_LEN;
+       }
+
+       /*
+        * If it isn't authenticated we can just send it.  Otherwise
+        * we're going to have to think about it a little.
+        */
+       if (!auth && !always_auth) {
+               return sendpkt((char *)&qpkt, pktsize);
+       } else {
+               const char *pass = "\0";
+               int maclen = 0;
+               u_long my_keyid;
+
+               /*
+                * Pad out packet to a multiple of 8 octets to be sure
+                * receiver can handle it.
+                */
+               while (pktsize & 7) {
+                       qpkt.data[qsize++] = 0;
+                       pktsize++;
+               }
+
+               /*
+                * Get the keyid and the password if we don't have one.
+                */
+               if (info_auth_keyid == 0) {
+                       int u_keyid = getkeyid("Keyid: ");
+                       if (u_keyid == 0 || u_keyid > NTP_MAXKEY) {
+                               (void) fprintf(stderr,
+                                  "Invalid key identifier\n");
+                               return 1;
+                       }
+                       info_auth_keyid = u_keyid;
+               }
+               if (!authistrusted(info_auth_keyid)) {
+                       pass = getpass("MD5 Password: ");
+                       if (*pass == '\0') {
+                               (void) fprintf(stderr,
+                                 "Invalid password\n");
+                               return (1);
+                       }
+               }
+               authusekey(info_auth_keyid, info_auth_keytype, (const u_char *)pass);
+               authtrust(info_auth_keyid, 1);
+
+               /*
+                * Stick the keyid in the packet where
+                * cp currently points.  Cp should be aligned
+                * properly.  Then do the encryptions.
+                */
+               my_keyid = htonl(info_auth_keyid);
+               memcpy(&qpkt.data[qsize], &my_keyid, sizeof my_keyid);
+               maclen = authencrypt(info_auth_keyid, (u_int32 *)&qpkt,
+                   pktsize);
+               if (maclen == 0) {
+                       (void) fprintf(stderr, "Key not found\n");
+                       return (1);
+               }
+               return sendpkt((char *)&qpkt, pktsize + maclen);
+       }
+       /*NOTREACHED*/
+}
+
+
+/*
+ * doquery - send a request and process the response
+ */
+int
+doquery(
+       int opcode,
+       int associd,
+       int auth,
+       int qsize,
+       char *qdata,
+       u_short *rstatus,
+       int *rsize,
+       char **rdata
+       )
+{
+       int res;
+       int done;
+
+       /*
+        * Check to make sure host is open
+        */
+       if (!havehost) {
+               (void) fprintf(stderr, "***No host open, use `host' command\n");
+               return -1;
+       }
+
+       done = 0;
+       sequence++;
+
+    again:
+       /*
+        * send a request
+        */
+       res = sendrequest(opcode, associd, auth, qsize, qdata);
+       if (res != 0)
+           return res;
+       
+       /*
+        * Get the response.  If we got a standard error, print a message
+        */
+       res = getresponse(opcode, associd, rstatus, rsize, rdata, done);
+
+       if (res > 0) {
+               if (!done && (res == ERR_TIMEOUT || res == ERR_INCOMPLETE)) {
+                       if (res == ERR_INCOMPLETE) {
+                               /*
+                                * better bump the sequence so we don't
+                                * get confused about differing fragments.
+                                */
+                               sequence++;
+                       }
+                       done = 1;
+                       goto again;
+               }
+               if (numhosts > 1)
+                       (void) fprintf(stderr, "server=%s ", currenthost);
+               switch(res) {
+                   case CERR_BADFMT:
+                       (void) fprintf(stderr,
+                           "***Server reports a bad format request packet\n");
+                       break;
+                   case CERR_PERMISSION:
+                       (void) fprintf(stderr,
+                           "***Server disallowed request (authentication?)\n");
+                       break;
+                   case CERR_BADOP:
+                       (void) fprintf(stderr,
+                           "***Server reports a bad opcode in request\n");
+                       break;
+                   case CERR_BADASSOC:
+                       (void) fprintf(stderr,
+                           "***Association ID %d unknown to server\n",associd);
+                       break;
+                   case CERR_UNKNOWNVAR:
+                       (void) fprintf(stderr,
+                           "***A request variable unknown to the server\n");
+                       break;
+                   case CERR_BADVALUE:
+                       (void) fprintf(stderr,
+                           "***Server indicates a request variable was bad\n");
+                       break;
+                   case ERR_UNSPEC:
+                       (void) fprintf(stderr,
+                           "***Server returned an unspecified error\n");
+                       break;
+                   case ERR_TIMEOUT:
+                       (void) fprintf(stderr, "***Request timed out\n");
+                       break;
+                   case ERR_INCOMPLETE:
+                       (void) fprintf(stderr,
+                           "***Response from server was incomplete\n");
+                       break;
+                   case ERR_TOOMUCH:
+                       (void) fprintf(stderr,
+                           "***Buffer size exceeded for returned data\n");
+                       break;
+                   default:
+                       (void) fprintf(stderr,
+                           "***Server returns unknown error code %d\n", res);
+                       break;
+               }
+       }
+       return res;
+}
+
+
+/*
+ * getcmds - read commands from the standard input and execute them
+ */
+static void
+getcmds(void)
+{
+#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
+        char *line;
+
+        for (;;) {
+                if ((line = readline(interactive?prompt:"")) == NULL) return;
+                if (*line) add_history(line);
+                docmd(line);
+                free(line);
+        }
+#else /* not (HAVE_LIBREADLINE || HAVE_LIBEDIT) */
+        char line[MAXLINE];
+
+        for (;;) {
+                if (interactive) {
+#ifdef VMS      /* work around a problem with mixing stdout & stderr */
+                        fputs("",stdout);
+#endif
+                        (void) fputs(prompt, stderr);
+                        (void) fflush(stderr);
+                }
+
+                if (fgets(line, sizeof line, stdin) == NULL)
+                    return;
+
+                docmd(line);
+        }
+#endif /* not (HAVE_LIBREADLINE || HAVE_LIBEDIT) */
+}
+
+#ifndef SYS_WINNT /* Under NT cannot handle SIGINT, WIN32 spawns a handler */
+/*
+ * abortcmd - catch interrupts and abort the current command
+ */
+static RETSIGTYPE
+abortcmd(
+       int sig
+       )
+{
+       if (current_output == stdout)
+           (void) fflush(stdout);
+       putc('\n', stderr);
+       (void) fflush(stderr);
+       if (jump) longjmp(interrupt_buf, 1);
+}
+#endif /* SYS_WINNT */
+
+/*
+ * docmd - decode the command line and execute a command
+ */
+static void
+docmd(
+       const char *cmdline
+       )
+{
+       char *tokens[1+MAXARGS+2];
+       struct parse pcmd;
+       int ntok;
+       static int i;
+       struct xcmd *xcmd;
+
+       /*
+        * Tokenize the command line.  If nothing on it, return.
+        */
+       tokenize(cmdline, tokens, &ntok);
+       if (ntok == 0)
+           return;
+       
+       /*
+        * Find the appropriate command description.
+        */
+       i = findcmd(tokens[0], builtins, opcmds, &xcmd);
+       if (i == 0) {
+               (void) fprintf(stderr, "***Command `%s' unknown\n",
+                              tokens[0]);
+               return;
+       } else if (i >= 2) {
+               (void) fprintf(stderr, "***Command `%s' ambiguous\n",
+                              tokens[0]);
+               return;
+       }
+       
+       /*
+        * Save the keyword, then walk through the arguments, interpreting
+        * as we go.
+        */
+       pcmd.keyword = tokens[0];
+       pcmd.nargs = 0;
+       for (i = 0; i < MAXARGS && xcmd->arg[i] != NO; i++) {
+               if ((i+1) >= ntok) {
+                       if (!(xcmd->arg[i] & OPT)) {
+                               printusage(xcmd, stderr);
+                               return;
+                       }
+                       break;
+               }
+               if ((xcmd->arg[i] & OPT) && (*tokens[i+1] == '>'))
+                   break;
+               if (!getarg(tokens[i+1], (int)xcmd->arg[i], &pcmd.argval[i]))
+                   return;
+               pcmd.nargs++;
+       }
+
+       i++;
+       if (i < ntok && *tokens[i] == '>') {
+               char *fname;
+
+               if (*(tokens[i]+1) != '\0')
+                   fname = tokens[i]+1;
+               else if ((i+1) < ntok)
+                   fname = tokens[i+1];
+               else {
+                       (void) fprintf(stderr, "***No file for redirect\n");
+                       return;
+               }
+
+               current_output = fopen(fname, "w");
+               if (current_output == NULL) {
+                       (void) fprintf(stderr, "***Error opening %s: ", fname);
+                       perror("");
+                       return;
+               }
+               i = 1;          /* flag we need a close */
+       } else {
+               current_output = stdout;
+               i = 0;          /* flag no close */
+       }
+
+       if (interactive && setjmp(interrupt_buf)) {
+               jump = 0;
+               return;
+       } else {
+               jump++;
+               (xcmd->handler)(&pcmd, current_output);
+               jump = 0;       /* HMS: 961106: was after fclose() */
+               if (i) (void) fclose(current_output);
+       }
+}
+
+
+/*
+ * tokenize - turn a command line into tokens
+ */
+static void
+tokenize(
+       const char *line,
+       char **tokens,
+       int *ntok
+       )
+{
+       register const char *cp;
+       register char *sp;
+       static char tspace[MAXLINE];
+
+       sp = tspace;
+       cp = line;
+       for (*ntok = 0; *ntok < MAXTOKENS; (*ntok)++) {
+               tokens[*ntok] = sp;
+               while (ISSPACE(*cp))
+                   cp++;
+               if (ISEOL(*cp))
+                   break;
+               do {
+                       *sp++ = *cp++;
+               } while (!ISSPACE(*cp) && !ISEOL(*cp));
+
+               *sp++ = '\0';
+       }
+}
+
+
+
+/*
+ * findcmd - find a command in a command description table
+ */
+static int
+findcmd(
+       register char *str,
+       struct xcmd *clist1,
+       struct xcmd *clist2,
+       struct xcmd **cmd
+       )
+{
+       register struct xcmd *cl;
+       register int clen;
+       int nmatch;
+       struct xcmd *nearmatch = NULL;
+       struct xcmd *clist;
+
+       clen = strlen(str);
+       nmatch = 0;
+       if (clist1 != 0)
+           clist = clist1;
+       else if (clist2 != 0)
+           clist = clist2;
+       else
+           return 0;
+
+    again:
+       for (cl = clist; cl->keyword != 0; cl++) {
+               /* do a first character check, for efficiency */
+               if (*str != *(cl->keyword))
+                   continue;
+               if (strncmp(str, cl->keyword, (unsigned)clen) == 0) {
+                       /*
+                        * Could be extact match, could be approximate.
+                        * Is exact if the length of the keyword is the
+                        * same as the str.
+                        */
+                       if (*((cl->keyword) + clen) == '\0') {
+                               *cmd = cl;
+                               return 1;
+                       }
+                       nmatch++;
+                       nearmatch = cl;
+               }
+       }
+
+       /*
+        * See if there is more to do.  If so, go again.  Sorry about the
+        * goto, too much looking at BSD sources...
+        */
+       if (clist == clist1 && clist2 != 0) {
+               clist = clist2;
+               goto again;
+       }
+
+       /*
+        * If we got extactly 1 near match, use it, else return number
+        * of matches.
+        */
+       if (nmatch == 1) {
+               *cmd = nearmatch;
+               return 1;
+       }
+       return nmatch;
+}
+
+
+/*
+ * getarg - interpret an argument token
+ */
+static int
+getarg(
+       char *str,
+       int code,
+       arg_v *argp
+       )
+{
+       int isneg;
+       char *cp, *np;
+       static const char *digits = "0123456789";
+
+       switch (code & ~OPT) {
+           case NTP_STR:
+               argp->string = str;
+               break;
+           case NTP_ADD:
+               if (!getnetnum(str, &(argp->netnum), (char *)0, 0)) {
+                       return 0;
+               }
+               break;
+           case NTP_INT:
+           case NTP_UINT:
+               isneg = 0;
+               np = str;
+               if (*np == '&') {
+                       np++;
+                       isneg = atoi(np);
+                       if (isneg <= 0) {
+                               (void) fprintf(stderr,
+                                              "***Association value `%s' invalid/undecodable\n", str);
+                               return 0;
+                       }
+                       if (isneg > numassoc) {
+                               if (numassoc == 0) {
+                                       (void) fprintf(stderr,
+                                                      "***Association for `%s' unknown (max &%d)\n",
+                                                      str, numassoc);
+                                       return 0;
+                               } else {
+                                       isneg = numassoc;
+                               }
+                       }
+                       argp->uval = assoc_cache[isneg-1].assid;
+                       break;
+               }
+
+               if (*np == '-') {
+                       np++;
+                       isneg = 1;
+               }
+
+               argp->uval = 0;
+               do {
+                       cp = strchr(digits, *np);
+                       if (cp == NULL) {
+                               (void) fprintf(stderr,
+                                              "***Illegal integer value %s\n", str);
+                               return 0;
+                       }
+                       argp->uval *= 10;
+                       argp->uval += (cp - digits);
+               } while (*(++np) != '\0');
+
+               if (isneg) {
+                       if ((code & ~OPT) == NTP_UINT) {
+                               (void) fprintf(stderr,
+                                              "***Value %s should be unsigned\n", str);
+                               return 0;
+                       }
+                       argp->ival = -argp->ival;
+               }
+               break;
+            case IP_VERSION:
+               if (!strcmp("-6", str))
+                       argp->ival = 6 ;
+               else if (!strcmp("-4", str))
+                       argp->ival = 4 ;
+               else {
+                       (void) fprintf(stderr,
+                           "***Version must be either 4 or 6\n");
+                       return 0;
+               }
+               break;
+       }
+
+       return 1;
+}
+
+
+/*
+ * getnetnum - given a host name, return its net number
+ *            and (optional) full name
+ */
+int
+getnetnum(
+       const char *hname,
+       struct sockaddr_storage *num,
+       char *fullhost,
+       int af
+       )
+{
+       int sockaddr_len;
+       struct addrinfo hints, *ai = NULL;
+
+       sockaddr_len = (af == AF_INET)
+                          ? sizeof(struct sockaddr_in)
+                          : sizeof(struct sockaddr_in6);
+       memset((char *)&hints, 0, sizeof(struct addrinfo));
+       hints.ai_flags = AI_CANONNAME;
+#ifdef AI_ADDRCONFIG
+       hints.ai_flags |= AI_ADDRCONFIG;
+#endif
+       
+       /* decodenetnum works with addresses only */
+       if (decodenetnum(hname, num)) {
+               if (fullhost != 0) {
+                       getnameinfo((struct sockaddr *)num, sockaddr_len,
+                                       fullhost, sizeof(fullhost), NULL, 0,
+                                       NI_NUMERICHOST);
+               }
+               return 1;
+       } else if (getaddrinfo(hname, "ntp", &hints, &ai) == 0) {
+               memmove((char *)num, ai->ai_addr, ai->ai_addrlen);
+               if (ai->ai_canonname != 0)
+                   (void) strcpy(fullhost, ai->ai_canonname);
+               return 1;
+       } else {
+               (void) fprintf(stderr, "***Can't find host %s\n", hname);
+               return 0;
+       }
+       /*NOTREACHED*/
+}
+
+/*
+ * nntohost - convert network number to host name.  This routine enforces
+ *            the showhostnames setting.
+ */
+char *
+nntohost(
+       struct sockaddr_storage *netnum
+       )
+{
+       if (!showhostnames)
+           return stoa(netnum);
+       if ((netnum->ss_family == AF_INET) && ISREFCLOCKADR(netnum))
+               return refnumtoa(netnum);
+       return socktohost(netnum);
+}
+
+
+/*
+ * rtdatetolfp - decode an RT-11 date into an l_fp
+ */
+static int
+rtdatetolfp(
+       char *str,
+       l_fp *lfp
+       )
+{
+       register char *cp;
+       register int i;
+       struct calendar cal;
+       char buf[4];
+       static const char *months[12] = {
+               "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+               "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+       };
+
+       cal.yearday = 0;
+
+       /*
+        * An RT-11 date looks like:
+        *
+        * d[d]-Mth-y[y] hh:mm:ss
+        *
+        * (No docs, but assume 4-digit years are also legal...)
+        *
+        * d[d]-Mth-y[y[y[y]]] hh:mm:ss
+        */
+       cp = str;
+       if (!isdigit((int)*cp)) {
+               if (*cp == '-') {
+                       /*
+                        * Catch special case
+                        */
+                       L_CLR(lfp);
+                       return 1;
+               }
+               return 0;
+       }
+
+       cal.monthday = (u_char) (*cp++ - '0');  /* ascii dependent */
+       if (isdigit((int)*cp)) {
+               cal.monthday = (u_char)((cal.monthday << 3) + (cal.monthday << 1));
+               cal.monthday = (u_char)(cal.monthday + *cp++ - '0');
+       }
+
+       if (*cp++ != '-')
+           return 0;
+       
+       for (i = 0; i < 3; i++)
+           buf[i] = *cp++;
+       buf[3] = '\0';
+
+       for (i = 0; i < 12; i++)
+           if (STREQ(buf, months[i]))
+               break;
+       if (i == 12)
+           return 0;
+       cal.month = (u_char)(i + 1);
+
+       if (*cp++ != '-')
+           return 0;
+       
+       if (!isdigit((int)*cp))
+           return 0;
+       cal.year = (u_short)(*cp++ - '0');
+       if (isdigit((int)*cp)) {
+               cal.year = (u_short)((cal.year << 3) + (cal.year << 1));
+               cal.year = (u_short)(*cp++ - '0');
+       }
+       if (isdigit((int)*cp)) {
+               cal.year = (u_short)((cal.year << 3) + (cal.year << 1));
+               cal.year = (u_short)(cal.year + *cp++ - '0');
+       }
+       if (isdigit((int)*cp)) {
+               cal.year = (u_short)((cal.year << 3) + (cal.year << 1));
+               cal.year = (u_short)(cal.year + *cp++ - '0');
+       }
+
+       /*
+        * Catch special case.  If cal.year == 0 this is a zero timestamp.
+        */
+       if (cal.year == 0) {
+               L_CLR(lfp);
+               return 1;
+       }
+
+       if (*cp++ != ' ' || !isdigit((int)*cp))
+           return 0;
+       cal.hour = (u_char)(*cp++ - '0');
+       if (isdigit((int)*cp)) {
+               cal.hour = (u_char)((cal.hour << 3) + (cal.hour << 1));
+               cal.hour = (u_char)(cal.hour + *cp++ - '0');
+       }
+
+       if (*cp++ != ':' || !isdigit((int)*cp))
+           return 0;
+       cal.minute = (u_char)(*cp++ - '0');
+       if (isdigit((int)*cp)) {
+               cal.minute = (u_char)((cal.minute << 3) + (cal.minute << 1));
+               cal.minute = (u_char)(cal.minute + *cp++ - '0');
+       }
+
+       if (*cp++ != ':' || !isdigit((int)*cp))
+           return 0;
+       cal.second = (u_char)(*cp++ - '0');
+       if (isdigit((int)*cp)) {
+               cal.second = (u_char)((cal.second << 3) + (cal.second << 1));
+               cal.second = (u_char)(cal.second + *cp++ - '0');
+       }
+
+       /*
+        * For RT-11, 1972 seems to be the pivot year
+        */
+       if (cal.year < 72)
+               cal.year += 2000;
+       if (cal.year < 100)
+               cal.year += 1900;
+
+       lfp->l_ui = caltontp(&cal);
+       lfp->l_uf = 0;
+       return 1;
+}
+
+
+/*
+ * decodets - decode a timestamp into an l_fp format number, with
+ *           consideration of fuzzball formats.
+ */
+int
+decodets(
+       char *str,
+       l_fp *lfp
+       )
+{
+       /*
+        * If it starts with a 0x, decode as hex.
+        */
+       if (*str == '0' && (*(str+1) == 'x' || *(str+1) == 'X'))
+           return hextolfp(str+2, lfp);
+
+       /*
+        * If it starts with a '"', try it as an RT-11 date.
+        */
+       if (*str == '"') {
+               register char *cp = str+1;
+               register char *bp;
+               char buf[30];
+
+               bp = buf;
+               while (*cp != '"' && *cp != '\0' && bp < &buf[29])
+                   *bp++ = *cp++;
+               *bp = '\0';
+               return rtdatetolfp(buf, lfp);
+       }
+
+       /*
+        * Might still be hex.  Check out the first character.  Talk
+        * about heuristics!
+        */
+       if ((*str >= 'A' && *str <= 'F') || (*str >= 'a' && *str <= 'f'))
+           return hextolfp(str, lfp);
+
+       /*
+        * Try it as a decimal.  If this fails, try as an unquoted
+        * RT-11 date.  This code should go away eventually.
+        */
+       if (atolfp(str, lfp))
+           return 1;
+       return rtdatetolfp(str, lfp);
+}
+
+
+/*
+ * decodetime - decode a time value.  It should be in milliseconds
+ */
+int
+decodetime(
+       char *str,
+       l_fp *lfp
+       )
+{
+       return mstolfp(str, lfp);
+}
+
+
+/*
+ * decodeint - decode an integer
+ */
+int
+decodeint(
+       char *str,
+       long *val
+       )
+{
+       if (*str == '0') {
+               if (*(str+1) == 'x' || *(str+1) == 'X')
+                   return hextoint(str+2, val);
+               return octtoint(str, val);
+       }
+       return atoint(str, val);
+}
+
+
+/*
+ * decodeuint - decode an unsigned integer
+ */
+int
+decodeuint(
+       char *str,
+       u_long *val
+       )
+{
+       if (*str == '0') {
+               if (*(str + 1) == 'x' || *(str + 1) == 'X')
+                       return (hextoint(str + 2, val));
+               return (octtoint(str, val));
+       }
+       return (atouint(str, val));
+}
+
+
+/*
+ * decodearr - decode an array of time values
+ */
+static int
+decodearr(
+       char *str,
+       int *narr,
+       l_fp *lfparr
+       )
+{
+       register char *cp, *bp;
+       register l_fp *lfp;
+       char buf[60];
+
+       lfp = lfparr;
+       cp = str;
+       *narr = 0;
+
+       while (*narr < 8) {
+               while (isspace((int)*cp))
+                   cp++;
+               if (*cp == '\0')
+                   break;
+
+               bp = buf;
+               while (!isspace((int)*cp) && *cp != '\0')
+                   *bp++ = *cp++;
+               *bp++ = '\0';
+
+               if (!decodetime(buf, lfp))
+                   return 0;
+               (*narr)++;
+               lfp++;
+       }
+       return 1;
+}
+
+
+/*
+ * Finally, the built in command handlers
+ */
+
+/*
+ * help - tell about commands, or details of a particular command
+ */
+static void
+help(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       struct xcmd *xcp;
+       char *cmd;
+       const char *list[100];
+        int word, words;
+        int row, rows;
+        int col, cols;
+
+       if (pcmd->nargs == 0) {
+               words = 0;
+               for (xcp = builtins; xcp->keyword != 0; xcp++) {
+                       if (*(xcp->keyword) != '?')
+                           list[words++] = xcp->keyword;
+               }
+               for (xcp = opcmds; xcp->keyword != 0; xcp++)
+                   list[words++] = xcp->keyword;
+
+               qsort(
+#ifdef QSORT_USES_VOID_P
+                   (void *)
+#else
+                   (char *)
+#endif
+                       (list), (size_t)(words), sizeof(char *), helpsort);
+               col = 0;
+               for (word = 0; word < words; word++) {
+                       int length = strlen(list[word]);
+                       if (col < length) {
+                           col = length;
+                        }
+               }
+
+               cols = SCREENWIDTH / ++col;
+                rows = (words + cols - 1) / cols;
+
+               (void) fprintf(fp, "ntpq commands:\n");
+
+               for (row = 0; row < rows; row++) {
+                        for (word = row; word < words; word += rows) {
+                               (void) fprintf(fp, "%-*.*s", col, col-1, list[word]);
+                        }
+                        (void) fprintf(fp, "\n");
+                }
+       } else {
+               cmd = pcmd->argval[0].string;
+               words = findcmd(cmd, builtins, opcmds, &xcp);
+               if (words == 0) {
+                       (void) fprintf(stderr,
+                                      "Command `%s' is unknown\n", cmd);
+                       return;
+               } else if (words >= 2) {
+                       (void) fprintf(stderr,
+                                      "Command `%s' is ambiguous\n", cmd);
+                       return;
+               }
+               (void) fprintf(fp, "function: %s\n", xcp->comment);
+               printusage(xcp, fp);
+       }
+}
+
+
+/*
+ * helpsort - do hostname qsort comparisons
+ */
+#ifdef QSORT_USES_VOID_P
+static int
+helpsort(
+       const void *t1,
+       const void *t2
+       )
+{
+       char const * const * name1 = (char const * const *)t1;
+       char const * const * name2 = (char const * const *)t2;
+
+       return strcmp(*name1, *name2);
+}
+
+#else
+static int
+helpsort(
+       char **name1,
+       char **name2
+       )
+{
+       return strcmp(*name1, *name2);
+}
+#endif
+
+/*
+ * printusage - print usage information for a command
+ */
+static void
+printusage(
+       struct xcmd *xcp,
+       FILE *fp
+       )
+{
+       register int i;
+
+       (void) fprintf(fp, "usage: %s", xcp->keyword);
+       for (i = 0; i < MAXARGS && xcp->arg[i] != NO; i++) {
+               if (xcp->arg[i] & OPT)
+                   (void) fprintf(fp, " [ %s ]", xcp->desc[i]);
+               else
+                   (void) fprintf(fp, " %s", xcp->desc[i]);
+       }
+       (void) fprintf(fp, "\n");
+}
+
+
+/*
+ * timeout - set time out time
+ */
+static void
+timeout(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int val;
+
+       if (pcmd->nargs == 0) {
+               val = tvout.tv_sec * 1000 + tvout.tv_usec / 1000;
+               (void) fprintf(fp, "primary timeout %d ms\n", val);
+       } else {
+               tvout.tv_sec = pcmd->argval[0].uval / 1000;
+               tvout.tv_usec = (pcmd->argval[0].uval - (tvout.tv_sec * 1000))
+                       * 1000;
+       }
+}
+
+
+/*
+ * auth_delay - set delay for auth requests
+ */
+static void
+auth_delay(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int isneg;
+       u_long val;
+
+       if (pcmd->nargs == 0) {
+               val = delay_time.l_ui * 1000 + delay_time.l_uf / 4294967;
+               (void) fprintf(fp, "delay %lu ms\n", val);
+       } else {
+               if (pcmd->argval[0].ival < 0) {
+                       isneg = 1;
+                       val = (u_long)(-pcmd->argval[0].ival);
+               } else {
+                       isneg = 0;
+                       val = (u_long)pcmd->argval[0].ival;
+               }
+
+               delay_time.l_ui = val / 1000;
+               val %= 1000;
+               delay_time.l_uf = val * 4294967;        /* 2**32/1000 */
+
+               if (isneg)
+                   L_NEG(&delay_time);
+       }
+}
+
+
+/*
+ * host - set the host we are dealing with.
+ */
+static void
+host(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       int i;
+
+       if (pcmd->nargs == 0) {
+               if (havehost)
+                   (void) fprintf(fp, "current host is %s\n", currenthost);
+               else
+                   (void) fprintf(fp, "no current host\n");
+               return;
+       }
+
+       i = 0;
+       ai_fam_templ = ai_fam_default;
+       if (pcmd->nargs == 2) {
+               if (!strcmp("-4", pcmd->argval[i].string))
+                       ai_fam_templ = AF_INET;
+               else if (!strcmp("-6", pcmd->argval[i].string))
+                       ai_fam_templ = AF_INET6;
+               else {
+                       if (havehost)
+                               (void) fprintf(fp,
+                                   "current host remains %s\n", currenthost);
+                       else
+                               (void) fprintf(fp, "still no current host\n");
+                       return;
+               }
+               i = 1;
+       }
+       if (openhost(pcmd->argval[i].string)) {
+               (void) fprintf(fp, "current host set to %s\n", currenthost);
+               numassoc = 0;
+       } else {
+               if (havehost)
+                   (void) fprintf(fp,
+                                  "current host remains %s\n", currenthost);
+               else
+                   (void) fprintf(fp, "still no current host\n");
+       }
+}
+
+
+/*
+ * poll - do one (or more) polls of the host via NTP
+ */
+/*ARGSUSED*/
+static void
+ntp_poll(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       (void) fprintf(fp, "poll not implemented yet\n");
+}
+
+
+/*
+ * keyid - get a keyid to use for authenticating requests
+ */
+static void
+keyid(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0) {
+               if (info_auth_keyid == 0)
+                   (void) fprintf(fp, "no keyid defined\n");
+               else
+                   (void) fprintf(fp, "keyid is %lu\n", (u_long)info_auth_keyid);
+       } else {
+               /* allow zero so that keyid can be cleared. */
+               if(pcmd->argval[0].uval > NTP_MAXKEY)
+                   (void) fprintf(fp, "Invalid key identifier\n");
+               info_auth_keyid = pcmd->argval[0].uval;
+       }
+}
+
+/*
+ * keytype - get type of key to use for authenticating requests
+ */
+static void
+keytype(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0)
+           fprintf(fp, "keytype is %s\n",
+                   (info_auth_keytype == KEY_TYPE_MD5) ? "MD5" : "???");
+       else
+           switch (*(pcmd->argval[0].string)) {
+               case 'm':
+               case 'M':
+                   info_auth_keytype = KEY_TYPE_MD5;
+                   break;
+
+               default:
+                   fprintf(fp, "keytype must be 'md5'\n");
+           }
+}
+
+
+
+/*
+ * passwd - get an authentication key
+ */
+/*ARGSUSED*/
+static void
+passwd(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       char *pass;
+
+       if (info_auth_keyid == 0) {
+               int u_keyid = getkeyid("Keyid: ");
+               if (u_keyid == 0 || u_keyid > NTP_MAXKEY) {
+                       (void)fprintf(fp, "Invalid key identifier\n");
+                       return;
+               }
+               info_auth_keyid = u_keyid;
+       }
+       pass = getpass("MD5 Password: ");
+       if (*pass == '\0')
+           (void) fprintf(fp, "Password unchanged\n");
+       else {
+           authusekey(info_auth_keyid, info_auth_keytype, (u_char *)pass);
+           authtrust(info_auth_keyid, 1);
+       }
+}
+
+
+/*
+ * hostnames - set the showhostnames flag
+ */
+static void
+hostnames(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0) {
+               if (showhostnames)
+                   (void) fprintf(fp, "hostnames being shown\n");
+               else
+                   (void) fprintf(fp, "hostnames not being shown\n");
+       } else {
+               if (STREQ(pcmd->argval[0].string, "yes"))
+                   showhostnames = 1;
+               else if (STREQ(pcmd->argval[0].string, "no"))
+                   showhostnames = 0;
+               else
+                   (void)fprintf(stderr, "What?\n");
+       }
+}
+
+
+
+/*
+ * setdebug - set/change debugging level
+ */
+static void
+setdebug(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0) {
+               (void) fprintf(fp, "debug level is %d\n", debug);
+               return;
+       } else if (STREQ(pcmd->argval[0].string, "no")) {
+               debug = 0;
+       } else if (STREQ(pcmd->argval[0].string, "more")) {
+               debug++;
+       } else if (STREQ(pcmd->argval[0].string, "less")) {
+               debug--;
+       } else {
+               (void) fprintf(fp, "What?\n");
+               return;
+       }
+       (void) fprintf(fp, "debug level set to %d\n", debug);
+}
+
+
+/*
+ * quit - stop this nonsense
+ */
+/*ARGSUSED*/
+static void
+quit(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (havehost)
+           closesocket(sockfd);        /* cleanliness next to godliness */
+       exit(0);
+}
+
+
+/*
+ * version - print the current version number
+ */
+/*ARGSUSED*/
+static void
+version(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+
+       (void) fprintf(fp, "%s\n", Version);
+       return;
+}
+
+
+/*
+ * raw - set raw mode output
+ */
+/*ARGSUSED*/
+static void
+raw(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       rawmode = 1;
+       (void) fprintf(fp, "Output set to raw\n");
+}
+
+
+/*
+ * cooked - set cooked mode output
+ */
+/*ARGSUSED*/
+static void
+cooked(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       rawmode = 0;
+       (void) fprintf(fp, "Output set to cooked\n");
+       return;
+}
+
+
+/*
+ * authenticate - always authenticate requests to this host
+ */
+static void
+authenticate(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0) {
+               if (always_auth) {
+                       (void) fprintf(fp,
+                                      "authenticated requests being sent\n");
+               } else
+                   (void) fprintf(fp,
+                                  "unauthenticated requests being sent\n");
+       } else {
+               if (STREQ(pcmd->argval[0].string, "yes")) {
+                       always_auth = 1;
+               } else if (STREQ(pcmd->argval[0].string, "no")) {
+                       always_auth = 0;
+               } else
+                   (void)fprintf(stderr, "What?\n");
+       }
+}
+
+
+/*
+ * ntpversion - choose the NTP version to use
+ */
+static void
+ntpversion(
+       struct parse *pcmd,
+       FILE *fp
+       )
+{
+       if (pcmd->nargs == 0) {
+               (void) fprintf(fp,
+                              "NTP version being claimed is %d\n", pktversion);
+       } else {
+               if (pcmd->argval[0].uval < NTP_OLDVERSION
+                   || pcmd->argval[0].uval > NTP_VERSION) {
+                       (void) fprintf(stderr, "versions %d to %d, please\n",
+                                      NTP_OLDVERSION, NTP_VERSION);
+               } else {
+                       pktversion = (u_char) pcmd->argval[0].uval;
+               }
+       }
+}
+
+
+/*
+ * warning - print a warning message
+ */
+static void
+warning(
+       const char *fmt,
+       const char *st1,
+       const char *st2
+       )
+{
+       (void) fprintf(stderr, "%s: ", progname);
+       (void) fprintf(stderr, fmt, st1, st2);
+       (void) fprintf(stderr, ": ");
+       perror("");
+}
+
+
+/*
+ * error - print a message and exit
+ */
+static void
+error(
+       const char *fmt,
+       const char *st1,
+       const char *st2
+       )
+{
+       warning(fmt, st1, st2);
+       exit(1);
+}
+
+/*
+ * getkeyid - prompt the user for a keyid to use
+ */
+static u_long
+getkeyid(
+       const char *keyprompt
+       )
+{
+       register char *p;
+       register int c;
+       FILE *fi;
+       char pbuf[20];
+
+#ifndef SYS_WINNT
+       if ((fi = fdopen(open("/dev/tty", 2), "r")) == NULL)
+#else
+           if ((fi = _fdopen((int)GetStdHandle(STD_INPUT_HANDLE), "r")) == NULL)
+#endif /* SYS_WINNT */
+               fi = stdin;
+           else
+               setbuf(fi, (char *)NULL);
+       fprintf(stderr, "%s", keyprompt); fflush(stderr);
+       for (p=pbuf; (c = getc(fi))!='\n' && c!=EOF;) {
+               if (p < &pbuf[18])
+                   *p++ = (char)c;
+       }
+       *p = '\0';
+       if (fi != stdin)
+           fclose(fi);
+       if (strcmp(pbuf, "0") == 0)
+           return 0;
+
+       return (u_long) atoi(pbuf);
+}
+
+
+/*
+ * atoascii - printable-ize possibly ascii data using the character
+ *           transformations cat -v uses.
+ */
+static void
+atoascii(
+       int length,
+       char *data,
+       char *outdata
+       )
+{
+       register u_char *cp;
+       register u_char *ocp;
+       register u_char c;
+
+       if (!data)
+       {
+               *outdata = '\0';
+               return;
+       }
+
+       ocp = (u_char *)outdata;
+       for (cp = (u_char *)data; cp < (u_char *)data + length; cp++) {
+               c = *cp;
+               if (c == '\0')
+                   break;
+               if (c == '\0')
+                   break;
+               if (c > 0177) {
+                       *ocp++ = 'M';
+                       *ocp++ = '-';
+                       c &= 0177;
+               }
+
+               if (c < ' ') {
+                       *ocp++ = '^';
+                       *ocp++ = (u_char)(c + '@');
+               } else if (c == 0177) {
+                       *ocp++ = '^';
+                       *ocp++ = '?';
+               } else {
+                       *ocp++ = c;
+               }
+               if (ocp >= ((u_char *)outdata + length - 4))
+                   break;
+       }
+       *ocp++ = '\0';
+}
+
+
+
+/*
+ * makeascii - print possibly ascii data using the character
+ *            transformations that cat -v uses.
+ */
+static void
+makeascii(
+       int length,
+       char *data,
+       FILE *fp
+       )
+{
+       register u_char *cp;
+       register int c;
+
+       for (cp = (u_char *)data; cp < (u_char *)data + length; cp++) {
+               c = (int)*cp;
+               if (c > 0177) {
+                       putc('M', fp);
+                       putc('-', fp);
+                       c &= 0177;
+               }
+
+               if (c < ' ') {
+                       putc('^', fp);
+                       putc(c+'@', fp);
+               } else if (c == 0177) {
+                       putc('^', fp);
+                       putc('?', fp);
+               } else {
+                       putc(c, fp);
+               }
+       }
+}
+
+
+/*
+ * asciize - same thing as makeascii except add a newline
+ */
+void
+asciize(
+       int length,
+       char *data,
+       FILE *fp
+       )
+{
+       makeascii(length, data, fp);
+       putc('\n', fp);
+}
+
+
+/*
+ * Some circular buffer space
+ */
+#define        CBLEN   80
+#define        NUMCB   6
+
+char circ_buf[NUMCB][CBLEN];
+int nextcb = 0;
+
+/*
+ * nextvar - find the next variable in the buffer
+ */
+int
+nextvar(
+       int *datalen,
+       char **datap,
+       char **vname,
+       char **vvalue
+       )
+{
+       register char *cp;
+       register char *np;
+       register char *cpend;
+       register char *npend;   /* character after last */
+       int quoted = 0;
+       static char name[MAXVARLEN];
+       static char value[MAXVALLEN];
+
+       cp = *datap;
+       cpend = cp + *datalen;
+
+       /*
+        * Space past commas and white space
+        */
+       while (cp < cpend && (*cp == ',' || isspace((int)*cp)))
+           cp++;
+       if (cp == cpend)
+           return 0;
+       
+       /*
+        * Copy name until we hit a ',', an '=', a '\r' or a '\n'.  Backspace
+        * over any white space and terminate it.
+        */
+       np = name;
+       npend = &name[MAXVARLEN];
+       while (cp < cpend && np < npend && *cp != ',' && *cp != '='
+              && *cp != '\r' && *cp != '\n')
+           *np++ = *cp++;
+       /*
+        * Check if we ran out of name space, without reaching the end or a
+        * terminating character
+        */
+       if (np == npend && !(cp == cpend || *cp == ',' || *cp == '=' ||
+                            *cp == '\r' || *cp == '\n'))
+           return 0;
+       while (isspace((int)(*(np-1))))
+           np--;
+       *np = '\0';
+       *vname = name;
+
+       /*
+        * Check if we hit the end of the buffer or a ','.  If so we are done.
+        */
+       if (cp == cpend || *cp == ',' || *cp == '\r' || *cp == '\n') {
+               if (cp != cpend)
+                   cp++;
+               *datap = cp;
+               *datalen = cpend - cp;
+               *vvalue = (char *)0;
+               return 1;
+       }
+
+       /*
+        * So far, so good.  Copy out the value
+        */
+       cp++;   /* past '=' */
+       while (cp < cpend && (isspace((int)*cp) && *cp != '\r' && *cp != '\n'))
+           cp++;
+       np = value;
+       npend = &value[MAXVALLEN];
+       while (cp < cpend && np < npend && ((*cp != ',') || quoted))
+       {
+               quoted ^= ((*np++ = *cp++) == '"');
+       }
+
+       /*
+        * Check if we overran the value buffer while still in a quoted string
+        * or without finding a comma
+        */
+       if (np == npend && (quoted || *cp != ','))
+           return 0;
+       /*
+        * Trim off any trailing whitespace
+        */
+       while (np > value && isspace((int)(*(np-1))))
+           np--;
+       *np = '\0';
+
+       /*
+        * Return this.  All done.
+        */
+       if (cp != cpend)
+           cp++;
+       *datap = cp;
+       *datalen = cpend - cp;
+       *vvalue = value;
+       return 1;
+}
+
+
+/*
+ * findvar - see if this variable is known to us.
+ * If "code" is 1, return ctl_var->code.
+ * Otherwise return the ordinal position of the found variable.
+ */
+int
+findvar(
+       char *varname,
+       struct ctl_var *varlist,
+       int code
+       )
+{
+       register char *np;
+       register struct ctl_var *vl;
+
+       vl = varlist;
+       np = varname;
+       while (vl->fmt != EOV) {
+               if (vl->fmt != PADDING && STREQ(np, vl->text))
+                   return (code)
+                               ? vl->code
+                               : (vl - varlist)
+                           ;
+               vl++;
+       }
+       return 0;
+}
+
+
+
+/*
+ * printvars - print variables returned in response packet
+ */
+void
+printvars(
+       int length,
+       char *data,
+       int status,
+       int sttype,
+       FILE *fp
+       )
+{
+       if (rawmode)
+           rawprint(sttype, length, data, status, fp);
+       else
+           cookedprint(sttype, length, data, status, fp);
+}
+
+
+/*
+ * rawprint - do a printout of the data in raw mode
+ */
+static void
+rawprint(
+       int datatype,
+       int length,
+       char *data,
+       int status,
+       FILE *fp
+       )
+{
+       register char *cp;
+       register char *cpend;
+
+       /*
+        * Essentially print the data as is.  We reformat unprintables, though.
+        */
+       cp = data;
+       cpend = data + length;
+
+       (void) fprintf(fp, "status=0x%04x,\n", status);
+
+       while (cp < cpend) {
+               if (*cp == '\r') {
+                       /*
+                        * If this is a \r and the next character is a
+                        * \n, supress this, else pretty print it.  Otherwise
+                        * just output the character.
+                        */
+                       if (cp == (cpend-1) || *(cp+1) != '\n')
+                           makeascii(1, cp, fp);
+               } else if (isspace((int)*cp) || isprint((int)*cp)) {
+                       putc(*cp, fp);
+               } else {
+                       makeascii(1, cp, fp);
+               }
+               cp++;
+       }
+}
+
+
+/*
+ * Global data used by the cooked output routines
+ */
+int out_chars;         /* number of characters output */
+int out_linecount;     /* number of characters output on this line */
+
+
+/*
+ * startoutput - get ready to do cooked output
+ */
+static void
+startoutput(void)
+{
+       out_chars = 0;
+       out_linecount = 0;
+}
+
+
+/*
+ * output - output a variable=value combination
+ */
+static void
+output(
+       FILE *fp,
+       char *name,
+       char *value
+       )
+{
+       int lenname;
+       int lenvalue;
+
+       lenname = strlen(name);
+       lenvalue = strlen(value);
+
+       if (out_chars != 0) {
+               putc(',', fp);
+               out_chars++;
+               out_linecount++;
+               if ((out_linecount + lenname + lenvalue + 3) > MAXOUTLINE) {
+                       putc('\n', fp);
+                       out_chars++;
+                       out_linecount = 0;
+               } else {
+                       putc(' ', fp);
+                       out_chars++;
+                       out_linecount++;
+               }
+       }
+
+       fputs(name, fp);
+       putc('=', fp);
+       fputs(value, fp);
+       out_chars += lenname + 1 + lenvalue;
+       out_linecount += lenname + 1 + lenvalue;
+}
+
+
+/*
+ * endoutput - terminate a block of cooked output
+ */
+static void
+endoutput(
+       FILE *fp
+       )
+{
+       if (out_chars != 0)
+           putc('\n', fp);
+}
+
+
+/*
+ * outputarr - output an array of values
+ */
+static void
+outputarr(
+       FILE *fp,
+       char *name,
+       int narr,
+       l_fp *lfp
+       )
+{
+       register char *bp;
+       register char *cp;
+       register int i;
+       register int len;
+       char buf[256];
+
+       bp = buf;
+       /*
+        * Hack to align delay and offset values
+        */
+       for (i = (int)strlen(name); i < 11; i++)
+           *bp++ = ' ';
+       
+       for (i = narr; i > 0; i--) {
+               if (i != narr)
+                   *bp++ = ' ';
+               cp = lfptoms(lfp, 2);
+               len = strlen(cp);
+               if (len > 7) {
+                       cp[7] = '\0';
+                       len = 7;
+               }
+               while (len < 7) {
+                       *bp++ = ' ';
+                       len++;
+               }
+               while (*cp != '\0')
+                   *bp++ = *cp++;
+               lfp++;
+       }
+       *bp = '\0';
+       output(fp, name, buf);
+}
+
+static char *
+tstflags(
+       u_long val
+       )
+{
+       register char *cb, *s;
+       register int i;
+       register const char *sep;
+
+       sep = "";
+       i = 0;
+       s = cb = &circ_buf[nextcb][0];
+       if (++nextcb >= NUMCB)
+           nextcb = 0;
+
+       sprintf(cb, "%02lx", val);
+       cb += strlen(cb);
+       if (!val) {
+               strcat(cb, " ok");
+               cb += strlen(cb);
+       } else {
+               *cb++ = ' ';
+               for (i = 0; i < 13; i++) {
+                       if (val & 0x1) {
+                               sprintf(cb, "%s%s", sep, tstflagnames[i]);
+                               sep = ", ";
+                               cb += strlen(cb);
+                       }
+                       val >>= 1;
+               }
+       }
+       *cb = '\0';
+       return s;
+}
+
+/*
+ * cookedprint - output variables in cooked mode
+ */
+static void
+cookedprint(
+       int datatype,
+       int length,
+       char *data,
+       int status,
+       FILE *fp
+       )
+{
+       register int varid;
+       char *name;
+       char *value;
+       char output_raw;
+       int fmt;
+       struct ctl_var *varlist;
+       l_fp lfp;
+       long ival;
+       struct sockaddr_storage hval;
+       u_long uval;
+       l_fp lfparr[8];
+       int narr;
+
+       switch (datatype) {
+           case TYPE_PEER:
+               varlist = peer_var;
+               break;
+           case TYPE_SYS:
+               varlist = sys_var;
+               break;
+           case TYPE_CLOCK:
+               varlist = clock_var;
+               break;
+           default:
+               (void) fprintf(stderr, "Unknown datatype(0x%x) in cookedprint\n", datatype);
+               return;
+       }
+
+       (void) fprintf(fp, "status=%04x %s,\n", status,
+                      statustoa(datatype, status));
+
+       startoutput();
+       while (nextvar(&length, &data, &name, &value)) {
+               varid = findvar(name, varlist, 0);
+               if (varid == 0) {
+                       output_raw = '*';
+               } else {
+                       output_raw = 0;
+                       fmt = varlist[varid].fmt;
+                       switch(fmt) {
+                           case TS:
+                               if (!decodets(value, &lfp))
+                                   output_raw = '?';
+                               else
+                                   output(fp, name, prettydate(&lfp));
+                               break;
+                           case FL:
+                           case FU:
+                           case FS:
+                               if (!decodetime(value, &lfp))
+                                   output_raw = '?';
+                               else {
+                                       switch (fmt) {
+                                           case FL:
+                                               output(fp, name,
+                                                      lfptoms(&lfp, 3));
+                                               break;
+                                           case FU:
+                                               output(fp, name,
+                                                      ulfptoms(&lfp, 3));
+                                               break;
+                                           case FS:
+                                               output(fp, name,
+                                                      lfptoms(&lfp, 3));
+                                               break;
+                                       }
+                               }
+                               break;
+                       
+                           case UI:
+                               if (!decodeuint(value, &uval))
+                                   output_raw = '?';
+                               else
+                                   output(fp, name, uinttoa(uval));
+                               break;
+                       
+                           case SI:
+                               if (!decodeint(value, &ival))
+                                   output_raw = '?';
+                               else
+                                   output(fp, name, inttoa(ival));
+                               break;
+
+                           case HA:
+                           case NA:
+                               if (!decodenetnum(value, &hval))
+                                   output_raw = '?';
+                               else if (fmt == HA){
+                                   output(fp, name, nntohost(&hval));
+                               } else {
+                                   output(fp, name, stoa(&hval));
+                               }
+                               break;
+                       
+                           case ST:
+                               output_raw = '*';
+                               break;
+                       
+                           case RF:
+                               if (decodenetnum(value, &hval)) {
+                                       if ((hval.ss_family == AF_INET) &&
+                                           ISREFCLOCKADR(&hval))
+                                               output(fp, name,
+                                                   refnumtoa(&hval));
+                                       else
+                                               output(fp, name, stoa(&hval));
+                               } else if ((int)strlen(value) <= 4)
+                                   output(fp, name, value);
+                               else
+                                   output_raw = '?';
+                               break;
+
+                           case LP:
+                               if (!decodeuint(value, &uval) || uval > 3)
+                                   output_raw = '?';
+                               else {
+                                       char b[3];
+                                       b[0] = b[1] = '0';
+                                       if (uval & 0x2)
+                                           b[0] = '1';
+                                       if (uval & 0x1)
+                                           b[1] = '1';
+                                       b[2] = '\0';
+                                       output(fp, name, b);
+                               }
+                               break;
+
+                           case OC:
+                               if (!decodeuint(value, &uval))
+                                   output_raw = '?';
+                               else {
+                                       char b[12];
+
+                                       (void) snprintf(b, sizeof b, "%03lo", uval);
+                                       output(fp, name, b);
+                               }
+                               break;
+                       
+                           case MD:
+                               if (!decodeuint(value, &uval))
+                                   output_raw = '?';
+                               else
+                                   output(fp, name, uinttoa(uval));
+                               break;
+                       
+                           case AR:
+                               if (!decodearr(value, &narr, lfparr))
+                                   output_raw = '?';
+                               else
+                                   outputarr(fp, name, narr, lfparr);
+                               break;
+
+                           case FX:
+                               if (!decodeuint(value, &uval))
+                                   output_raw = '?';
+                               else
+                                   output(fp, name, tstflags(uval));
+                               break;
+                       
+                           default:
+                               (void) fprintf(stderr,
+                                   "Internal error in cookedprint, %s=%s, fmt %d\n",
+                                   name, value, fmt);
+                               break;
+                       }
+
+               }
+               if (output_raw != 0) {
+                       char bn[401];
+                       char bv[401];
+                       int len;
+
+                       atoascii(400, name, bn);
+                       atoascii(400, value, bv);
+                       if (output_raw != '*') {
+                               len = strlen(bv);
+                               bv[len] = output_raw;
+                               bv[len+1] = '\0';
+                       }
+                       output(fp, bn, bv);
+               }
+       }
+       endoutput(fp);
+}
+
+
+/*
+ * sortassoc - sort associations in the cache into ascending order
+ */
+void
+sortassoc(void)
+{
+       if (numassoc > 1)
+           qsort(
+#ifdef QSORT_USES_VOID_P
+                   (void *)
+#else
+                   (char *)
+#endif
+                   assoc_cache, (size_t)numassoc,
+                   sizeof(struct association), assoccmp);
+}
+
+
+/*
+ * assoccmp - compare two associations
+ */
+#ifdef QSORT_USES_VOID_P
+static int
+assoccmp(
+       const void *t1,
+       const void *t2
+       )
+{
+       const struct association *ass1 = (const struct association *)t1;
+       const struct association *ass2 = (const struct association *)t2;
+
+       if (ass1->assid < ass2->assid)
+           return -1;
+       if (ass1->assid > ass2->assid)
+           return 1;
+       return 0;
+}
+#else
+static int
+assoccmp(
+       struct association *ass1,
+       struct association *ass2
+       )
+{
+       if (ass1->assid < ass2->assid)
+           return -1;
+       if (ass1->assid > ass2->assid)
+           return 1;
+       return 0;
+}
+#endif /* not QSORT_USES_VOID_P */
diff --git a/ntpq/ntpq.h b/ntpq/ntpq.h
new file mode 100644 (file)
index 0000000..0f29fd5
--- /dev/null
@@ -0,0 +1,93 @@
+/*
+ * ntpq.h - definitions of interest to ntpq
+ */
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntp_control.h"
+#include "ntp_string.h"
+#include "ntp_malloc.h"
+
+/*
+ * Maximum number of arguments
+ */
+#define        MAXARGS 4
+
+/*
+ * Flags for forming descriptors.
+ */
+/*
+ * Flags for forming descriptors.
+ */
+#define        OPT             0x80    /* this argument is optional, or'd with type */
+
+#define        NO              0x0
+#define        NTP_STR         0x1     /* string argument */
+#define        NTP_UINT        0x2     /* unsigned integer */
+#define        NTP_INT         0x3     /* signed integer */
+#define        NTP_ADD         0x4     /* IP network address */
+#define IP_VERSION     0x5     /* IP version */
+
+/*
+ * Arguments are returned in a union
+ */
+typedef union {
+       char *string;
+       long ival;
+       u_long uval;
+       struct sockaddr_storage netnum;
+} arg_v;
+
+/*
+ * Structure for passing parsed command line
+ */
+struct parse {
+       const char *keyword;
+       arg_v argval[MAXARGS];
+       int nargs;
+};
+
+/*
+ * ntpdc includes a command parser which could charitably be called
+ * crude.  The following structure is used to define the command
+ * syntax.
+ */
+struct xcmd {
+  const char *keyword;         /* command key word */
+       void (*handler) P((struct parse *, FILE *));    /* command handler */
+       u_char arg[MAXARGS];    /* descriptors for arguments */
+  const char *desc[MAXARGS];   /* descriptions for arguments */
+  const char *comment;
+};
+
+/*
+ * Structure to hold association data
+ */
+struct association {
+       u_short assid;
+       u_short status;
+};
+
+#define        MAXASSOC        1024
+
+/*
+ * Structure for translation tables between text format
+ * variable indices and text format.
+ */
+struct ctl_var {
+       u_short code;
+       u_short fmt;
+       const char *text;
+};
+
+extern void    asciize         P((int, char *, FILE *));
+extern int     getnetnum       P((const char *, struct sockaddr_storage *, char *, int));
+extern void    sortassoc       P((void));
+extern int     doquery         P((int, int, int, int, char *, u_short *, int *, char **));
+extern char *  nntohost        P((struct sockaddr_storage *));
+extern int     decodets        P((char *, l_fp *));
+extern int     decodeuint      P((char *, u_long *));
+extern int     nextvar         P((int *, char **, char **, char **));
+extern int     decodetime      P((char *, l_fp *));
+extern void    printvars       P((int, char *, int, int, FILE *));
+extern int     decodeint       P((char *, long *));
+extern int     findvar         P((char *, struct ctl_var *, int code));
diff --git a/packageinfo.sh b/packageinfo.sh
new file mode 100644 (file)
index 0000000..702373f
--- /dev/null
@@ -0,0 +1,31 @@
+repotype=stable
+# version=Protocol.Major.Minor
+# odd minor numbers are for -dev, even minor numbers are for -stable
+proto=4
+major=2
+minor=4
+version=${proto}.${major}.${minor}
+# Point.  3 cases:
+# - Numeric values increment
+# - empty 'increments' to 1
+# - NEW 'increments' to empty
+point=8
+# Special.  Normally unused.  A suffix.
+#special=ag
+special=
+# [???] To start an RC cycle: RC->yes
+# To release from an RC cycle: rcpoint-> GO
+# ReleaseCandidate. 'yes' or 'no'.
+#releasecandidate=yes
+releasecandidate=no
+# ChangeLog tag
+CLTAG=NTP_4_2_0
+###
+# The following is for ntp-stable.  2 cases:
+# - Numeric values increment
+# - GO triggers a release (from releasecandidate=yes)
+# - - rcpoint gets set to 0
+# - - releasecandidate gets set to no
+# - GRONK is for -dev
+rcpoint=
+#rcpoint=GRONK
diff --git a/packaging/ntp-4.2.4-groups.patch b/packaging/ntp-4.2.4-groups.patch
new file mode 100644 (file)
index 0000000..360e9c6
--- /dev/null
@@ -0,0 +1,35 @@
+--- ntp-4.2.4/ntpd/ntpd.c.groups       2006-12-29 00:02:02.000000000 +0100
++++ ntp-4.2.4/ntpd/ntpd.c      2007-01-02 16:24:21.000000000 +0100
+@@ -874,10 +874,18 @@
+                               sw_uid = (uid_t)strtoul(user, &endp, 0);
+                               if (*endp != '\0') 
+                                       goto getuser;
++
++                                if ((pw = getpwuid(sw_uid)) != NULL) {
++                                        user = strdup(pw->pw_name);
++                                } else {
++                                      user = (char *)-1;
++                                }
++
+                       } else {
+ getuser:      
+                               if ((pw = getpwnam(user)) != NULL) {
+                                       sw_uid = pw->pw_uid;
++                                      sw_gid = pw->pw_gid;
+                               } else {
+                                       errno = 0;
+                                       msyslog(LOG_ERR, "Cannot find user `%s'", user);
+@@ -913,6 +921,13 @@
+                               exit (-1);
+                       }
+               }
++
++              if (user && (user != (char *)-1) && initgroups(user, sw_gid)) {
++                        msyslog(LOG_ERR, "Cannot initgroups() to user `%s': %m", user);
++                        exit (-1);
++                }
++      
++
+               if (group && setgid(sw_gid)) {
+                       msyslog(LOG_ERR, "Cannot setgid() to group `%s': %m", group);
+                       exit (-1);
diff --git a/packaging/ntp-4.2.4-html2man.patch b/packaging/ntp-4.2.4-html2man.patch
new file mode 100644 (file)
index 0000000..333d452
--- /dev/null
@@ -0,0 +1,183 @@
+--- ntp-4.2.4/scripts/html2man.in.html2man     2006-06-06 22:17:10.000000000 +0200
++++ ntp-4.2.4/scripts/html2man.in      2007-01-08 12:47:31.000000000 +0100
+@@ -23,10 +23,10 @@
+            'ntpq' => ['ntpq', 8, 'ntpd(8), ntpdc(8)'],
+            'ntpdate' => ['ntpdate', 8, 'ntpd(8)'],
+            'ntpdc' => ['ntpdc', 8, 'ntpd(8)'],
+-           'ntptime' => ['ntpdtime', 8, 'ntpd(8), ntpdate(8)'],
++           'ntptime' => ['ntptime', 8, 'ntpd(8), ntpdate(8)'],
+            'ntptrace' => ['ntptrace', 8, 'ntpd(8)'],
+            'keygen' => ['ntp-keygen', 8, 'ntpd(8), ntp_auth(5)'],
+-           'confopt' => ['ntp.conf', 5, 'ntpd(8)'],
++           'confopt' => ['ntp.conf', 5, 'ntpd(8), ntp_auth(5), ntp_mon(5), ntp_acc(5), ntp_clock(5), ntp_misc(5)'],
+            'authopt' => ['ntp_auth', 5, 'ntp.conf(5), ntpd(8)'],
+            'monopt' => ['ntp_mon', 5, 'ntp.conf(5)'],
+            'accopt' => ['ntp_acc', 5, 'ntp.conf(5)'],
+@@ -34,17 +34,8 @@
+            'miscopt' => ['ntp_misc', 5, 'ntp.conf(5)']);
+ # Disclaimer to go in SEE ALSO section of the man page
+-$seealso_disclaimer = 'These man pages are automatically hacked from the main NTP ' .
+-    'documentation pages, which are maintained in HTML format.  These files are ' .
+-    'included in the NTP source distribution.  If you installed NTP from a binary ' .
+-    'package, or it came pre-installed on your system, chances are the documentation ' .
+-    'was also included in the usual place for your system.  The HTML files are more ' .
+-    'correct and complete than these man pages, which are provided for your reference ' .
+-    'only.';
+-
+-# Disclaimer to go right at the top
+-$top_disclaimer = 'This file was automatically generated from HTML source, and may be ' .
+-    'incorrect.  See the SEE ALSO section at the end of this file for more info';
++$seealso_disclaimer = "Primary source of documentation: /usr/share/doc/ntp-*\n\n" .
++    "This file was automatically generated from HTML source.\n";
+ mkdir $MANDIR, 0777;
+ mkdir "$MANDIR/man8", 0777;
+@@ -64,7 +55,8 @@
+     $fileinfo = $manfiles{$filename};
+     $p = HTML::TokeParser->new("$filename.html") || die "Can't open $filename.html: $!";
+-    open(MANOUT, ">$MANDIR/man$fileinfo->[1]/$fileinfo->[0].$fileinfo->[1]")
++    $fileout = "$MANDIR/man$fileinfo->[1]/$fileinfo->[0].$fileinfo->[1]";
++    open(MANOUT, ">$fileout")
+       || die "Can't open: $!";
+     $p->get_tag("title");
+@@ -73,7 +65,6 @@
+     # Setup man header
+     print MANOUT ".TH " . $fileinfo->[0] . " " . $fileinfo->[1] .  "\n";
+-    print MANOUT ".UC 4\n";
+     print MANOUT ".SH NAME\n";
+     $pat = $fileinfo->[0];
+     if ($name =~ /$pat/) {
+@@ -81,10 +72,12 @@
+       # Add the manpage name, if not in the HTML title already
+       print MANOUT "$fileinfo->[0] - ";
+     }
+-    print MANOUT "$name\n\n";
+-
+-    print MANOUT "$top_disclaimer\n";
++    print MANOUT "$name\n.SH \\ \n\n";
++    @fontstack = ();
++    $deflevel = 0;
++    $pre = 0;
++    $ignore = 0;
+     # Now start scanning.  We basically print everything after translating some tags.
+     # $token->[0] has "T", "S", "E" for Text, Start, End
+     # $token->[1] has the tag name, or text (for "T" case)
+@@ -92,19 +85,37 @@
+     while (my $token = $p->get_token) {
+       if($token->[0] eq "T") {
+           my $text = $token->[1];
+-          if($tag) {
+-              $text =~ s/^[\n ]*//;
+-              $text =~ s/[\n ]*$/ /;
++          if (!$pre) {
++              if($tag) {
++                  $text =~ s/^[\n\t ]*//;
++              }
++              $text =~ s/^[\n\t ][\n\t ]+$//;
++              $text =~ s/[\n\t ]+/ /g;
++              $text =~ s/&nbsp\;/ /g;
++              $text =~ s/&gt\;/>/g;
++              $text =~ s/&lt\;/</g;
++              $text =~ s/&quot\;/"/g;
++              $text =~ s/&amp\;/&/g;
++              $text =~ s/^\./\\[char46]/;
+           }
+-          $text =~ s/&nbsp\;/ /g;
+-          $text =~ s/^\./\\./;
+           print MANOUT "$text";
+           $tag = 0;
+       }
+       if($token->[0] eq "S") {
+           if($token->[1] eq "h4") {
+               my $text = uc($p->get_trimmed_text("/h4"));
+-              print MANOUT ".SH $text\n";
++              # ignore these two sections in ntpd.html
++              if ($filename eq "ntpd" &&
++                  ($text eq "FILES" || $text eq "CONFIGURATION OPTIONS")) {
++                      $ignore = 1;
++                      close(MANOUT);
++                      open(MANOUT, ">/dev/null");
++              } elsif ($ignore) {
++                  $ignore = 0;
++                  close(MANOUT);
++                  open(MANOUT, ">>$fileout");
++              }
++              print MANOUT "\n\n.SH $text\n";
+           }
+           if($token->[1] eq "tt") {
+               push @fontstack, "tt";
+@@ -118,22 +129,30 @@
+               my $text = $p->get_trimmed_text("/address");
+               print MANOUT "\n.SH AUTHOR\n$text\n";
+           }
+-          if($token->[1] eq "dt") {
+-              $tmp = $deflevel-4;
+-              print MANOUT "\n.RS $tmp\n";
++          if($token->[1] eq "dt" || $token->[1] eq "br" && $deflevel > 0) {
++              print MANOUT "\n.TP 8\n";
+               $tag = 1;
+           }
+           if($token->[1] eq "dd") {
+-              print MANOUT "\n.RS $deflevel\n";
++              print MANOUT "\n";
+               $tag = 1;
+           }
+           if($token->[1] eq "dl") {
+-              $deflevel+=4;
++              $deflevel+=1;
++              if ($deflevel > 0) {
++                  print MANOUT "\n.RS ", $deflevel > 1 ? 8 : 0;
++              }
++          }
++          if($token->[1] eq "p") {
++              print MANOUT "\n";
++          }
++          if($token->[1] eq "pre") {
++              print MANOUT "\n.nf";
++              $pre = 1;
+           }
+       }
+       elsif($token->[0] eq "E") {
+-          if($token->[1] eq "dd") {
+-              print MANOUT "\n.RE\n";
++          if($token->[1] eq "h4") {
+               $tag = 1;
+           }
+           if($token->[1] eq "tt") {
+@@ -157,15 +176,27 @@
+               print MANOUT "$fontswitch";
+           }
+           if($token->[1] eq "dl") {
+-              $deflevel-=4;
++              if ($deflevel > 0) {
++                  print MANOUT "\n.RE";
++              }
++              print MANOUT "\n";
++              $deflevel-=1;
+           }
+-          if($token->[1] eq "dt") {
+-              print MANOUT "\n.RE";
++          if($token->[1] eq "p") {
++              print MANOUT "\n";
+               $tag = 1;
+           }
++          if($token->[1] eq "pre") {
++              print MANOUT "\n.fi";
++              $pre = 0;
++          }
+       }
+     }
+-    print MANOUT ".SH SEE ALSO\n\n";
++    if ($ignore) {
++      close(MANOUT);
++      open(MANOUT, ">>$fileout");
++    }
++    print MANOUT "\n.SH SEE ALSO\n\n";
+     print MANOUT "$fileinfo->[2]\n\n";
+     print MANOUT "$seealso_disclaimer\n";
+     close(MANOUT);
diff --git a/packaging/ntp-4.2.4-linkfastmath.patch b/packaging/ntp-4.2.4-linkfastmath.patch
new file mode 100644 (file)
index 0000000..b9cf076
--- /dev/null
@@ -0,0 +1,11 @@
+--- ntp-4.2.4/ntpd/Makefile.in.linkfastmath    2006-12-29 00:58:57.000000000 +0100
++++ ntp-4.2.4/ntpd/Makefile.in 2007-01-02 17:56:48.000000000 +0100
+@@ -281,7 +281,7 @@
+ # sqrt                                ntp_control.o
+ # floor                               refclock_wwv.o
+ # which are (usually) provided by -lm.
+-ntpd_LDADD = $(LDADD) -lm @LCRYPTO@ $(LIBOPTS_LDADD) ../libntp/libntp.a
++ntpd_LDADD = $(LDADD) -lm -ffast-math @LCRYPTO@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+ ntpdsim_LDADD = $(LDADD) ../libntp/libntpsim.a -lm @LCRYPTO@ $(LIBOPTS_LDADD)
+ ntpdsim_CFLAGS = $(CFLAGS) -DSIM
+ check_y2k_LDADD = $(LDADD) ../libntp/libntp.a
diff --git a/packaging/ntp-4.2.4-sprintf.patch b/packaging/ntp-4.2.4-sprintf.patch
new file mode 100644 (file)
index 0000000..089ec35
--- /dev/null
@@ -0,0 +1,65 @@
+--- ntp-4.2.4/ntpd/refclock_wwv.c.sprintf      2006-12-28 13:03:49.000000000 +0100
++++ ntp-4.2.4/ntpd/refclock_wwv.c      2007-01-02 17:52:10.000000000 +0100
+@@ -1364,7 +1364,7 @@
+               else
+                       sp->metric = wwv_metric(sp);
+               if (pp->sloppyclockflag & CLK_FLAG4) {
+-                      sprintf(tbuf,
++                      snprintf(tbuf, sizeof (tbuf),
+                           "wwv8 %04x %3d %s %04x %.0f %.0f/%.1f %4ld %4ld",
+                           up->status, up->gain, sp->refid,
+                           sp->reach & 0xffff, sp->metric, sp->synmax,
+@@ -1491,7 +1491,7 @@
+       }
+       if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status & MSYNC))
+           {
+-              sprintf(tbuf,
++              snprintf(tbuf, sizeof (tbuf),
+                   "wwv1 %04x %3d %4d %5.0f %5.1f %5d %4d %4d %4d",
+                   up->status, up->gain, tepoch, up->epomax,
+                   up->eposnr, tmp2, avgcnt, syncnt,
+@@ -1582,7 +1582,7 @@
+               }
+       }
+       if (pp->sloppyclockflag & CLK_FLAG4) {
+-              sprintf(tbuf,
++              snprintf(tbuf, sizeof (tbuf),
+                   "wwv2 %04x %5.0f %5.1f %5d %4d %4d %4d %4.0f %7.2f",
+                   up->status, up->epomax, up->eposnr, mepoch,
+                   up->avgint, maxrun, mcount - zcount, dtemp,
+@@ -1768,7 +1768,7 @@
+       struct wwvunit *up;
+       struct chan *cp;
+       struct sync *sp, *rp;
+-      char    tbuf[80];       /* monitor buffer */
++      char    tbuf[128];      /* monitor buffer */
+       int     sw, arg, nsec;
+       pp = peer->procptr;
+@@ -1869,7 +1869,7 @@
+               }
+               rp->metric = wwv_metric(rp);
+               if (pp->sloppyclockflag & CLK_FLAG4) {
+-                      sprintf(tbuf,
++                      snprintf(tbuf, sizeof (tbuf),
+                           "wwv5 %04x %3d %4d %.0f/%.1f %.0f/%.1f %s %04x %.0f %.0f/%.1f %s %04x %.0f %.0f/%.1f",
+                           up->status, up->gain, up->yepoch,
+                           up->epomax, up->eposnr, up->datsig,
+@@ -2041,7 +2041,7 @@
+       }
+       if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status &
+           DSYNC)) {
+-              sprintf(tbuf,
++              snprintf(tbuf, sizeof (tbuf),
+                   "wwv3 %2d %04x %3d %4d %5.0f %5.1f %5.0f %5.1f %5.0f",
+                   nsec, up->status, up->gain, up->yepoch, up->epomax,
+                   up->eposnr, up->datsig, up->datsnr, bit);
+@@ -2212,7 +2212,7 @@
+       }
+       if ((pp->sloppyclockflag & CLK_FLAG4) && !(up->status &
+           INSYNC)) {
+-              sprintf(tbuf,
++              snprintf(tbuf, sizeof (tbuf),
+                   "wwv4 %2d %04x %3d %4d %5.0f %2d %d %d %d %5.0f %5.1f",
+                   up->rsec - 1, up->status, up->gain, up->yepoch,
+                   up->epomax, vp->radix, vp->digit, vp->mldigit,
diff --git a/packaging/ntp-4.2.4p0-droproot.patch b/packaging/ntp-4.2.4p0-droproot.patch
new file mode 100644 (file)
index 0000000..1902d5b
--- /dev/null
@@ -0,0 +1,206 @@
+--- ntp-4.2.4p0/ntpdate/ntpdate.c.droproot     2007-02-22 12:02:08.000000000 +0100
++++ ntp-4.2.4p0/ntpdate/ntpdate.c      2007-03-07 16:06:26.000000000 +0100
+@@ -53,6 +53,12 @@
+ #include <arpa/inet.h>
++/* Linux capabilities */
++#include <sys/capability.h>
++#include <sys/prctl.h>
++#include <pwd.h>
++#include <grp.h>
++
+ #ifdef SYS_VXWORKS
+ # include "ioLib.h"
+ # include "sockLib.h"
+@@ -159,6 +165,11 @@
+ int unpriv_port = 0;
+ /*
++ * Use capabilities to drop privileges and switch uids
++ */
++char *server_user;
++
++/*
+  * Program name.
+  */
+ char *progname;
+@@ -301,6 +312,88 @@
+ static ni_namelist *getnetinfoservers P((void));
+ #endif
++/* This patch is adapted (copied) from Chris Wings drop root patch
++ * for xntpd.
++ */
++void drop_root(uid_t server_uid, gid_t server_gid)
++{
++  cap_t caps;
++
++  if (prctl(PR_SET_KEEPCAPS, 1)) {
++              if (syslogit) {
++                      msyslog(LOG_ERR, "prctl(PR_SET_KEEPCAPS, 1) failed");
++              }
++              else {
++                      fprintf(stderr, "prctl(PR_SET_KEEPCAPS, 1) failed.\n");
++              }
++    exit(1);
++  }
++
++  if ( setgroups(0, NULL) == -1 ) {
++              if (syslogit) {
++                      msyslog(LOG_ERR, "setgroups failed.");
++              }
++              else {
++                      fprintf(stderr, "setgroups failed.\n");
++              }
++    exit(1);
++  }
++
++  if ( setegid(server_gid) == -1 || seteuid(server_uid) == -1 ) {
++              if (syslogit) {
++                      msyslog(LOG_ERR, "setegid/seteuid to uid=%d/gid=%d failed.", server_uid,
++                                                      server_gid);
++              }
++              else {
++                      fprintf(stderr, "setegid/seteuid to uid=%d/gid=%d failed.\n", server_uid,
++                                                      server_gid);
++              }
++    exit(1);
++  }
++
++  caps = cap_from_text("cap_sys_time=epi");
++  if (caps == NULL) {
++              if (syslogit) {
++                      msyslog(LOG_ERR, "cap_from_text failed.");
++              }
++              else {
++                      fprintf(stderr, "cap_from_text failed.\n");
++              }
++    exit(1);
++  }
++
++  if (cap_set_proc(caps) == -1) {
++              if (syslogit) {
++                      msyslog(LOG_ERR, "cap_set_proc failed.");
++              }
++              else {
++                      fprintf(stderr, "cap_set_proc failed.\n");
++              }
++    exit(1);
++  }
++  
++  /* Try to free the memory from cap_from_text */
++  cap_free( caps );
++
++  if ( setregid(server_gid, server_gid) == -1 ||
++       setreuid(server_uid, server_uid) == -1 ) {
++              if (syslogit) {
++                      msyslog(LOG_ERR, "setregid/setreuid to uid=%d/gid=%d failed.",
++                                                      server_uid, server_gid);
++              }
++              else {
++                      fprintf(stderr, "setregid/setreuid to uid=%d/gid=%d failed.\n",
++                                                      server_uid, server_gid);
++              }
++    exit(1);
++  }
++
++      if (syslogit) {
++              msyslog(LOG_DEBUG, "running as uid(%d)/gid(%d) euid(%d)/egid(%d).",
++                                              getuid(), getgid(), geteuid(), getegid());
++      }
++}
++
+ /*
+  * Main program.  Initialize us and loop waiting for I/O and/or
+  * timer expiries.
+@@ -354,7 +447,7 @@
+       clear_globals();
+ #endif
+-
++      server_user = NULL;
+       /* Check to see if we have IPv6. Otherwise force the -4 flag */
+       if (isc_net_probeipv6() != ISC_R_SUCCESS) {
+               ai_fam_templ = AF_INET;
+@@ -367,7 +460,7 @@
+       /*
+        * Decode argument list
+        */
+-      while ((c = ntp_getopt(argc, argv, "46a:bBde:k:o:p:qst:uv")) != EOF)
++      while ((c = ntp_getopt(argc, argv, "46a:bBde:k:o:p:qst:uvU:")) != EOF)
+               switch (c)
+               {
+               case '4':
+@@ -445,6 +538,14 @@
+               case 'u':
+                       unpriv_port = 1;
+                       break;
++              case 'U':
++                      if (ntp_optarg) {
++                              server_user = strdup(ntp_optarg);
++                      }
++                      else {
++                              ++errflg;
++                      }
++                      break;
+               case '?':
+                       ++errflg;
+                       break;
+@@ -454,7 +555,7 @@
+       
+       if (errflg) {
+               (void) fprintf(stderr,
+-                  "usage: %s [-46bBdqsuv] [-a key#] [-e delay] [-k file] [-p samples] [-o version#] [-t timeo] server ...\n",
++                  "usage: %s [-46bBdqsuv] [-a key#] [-e delay] [-k file] [-p samples] [-o version#] [-t timeo] [-U username] server ...\n",
+                   progname);
+               exit(2);
+       }
+@@ -574,6 +675,24 @@
+       initializing = 0;
+       was_alarmed = 0;
++      if (server_user) {
++              struct passwd *pwd = NULL;
++
++              /* Lookup server_user uid/gid before chroot/chdir */
++              pwd = getpwnam( server_user );
++              if ( pwd == NULL ) {
++                      if (syslogit) {
++                              msyslog(LOG_ERR, "Failed to lookup user '%s'.", server_user);
++                      }
++                      else {
++                              fprintf(stderr, "Failed to lookup user '%s'.\n", server_user);
++                      }
++                      exit(1);
++              }
++              drop_root(pwd->pw_uid, pwd->pw_gid);
++      }
++
++
+       while (complete_servers < sys_numservers) {
+ #ifdef HAVE_POLL_H
+               struct pollfd* rdfdes;
+--- ntp-4.2.4p0/html/ntpdate.html.droproot     2006-12-28 13:02:58.000000000 +0100
++++ ntp-4.2.4p0/html/ntpdate.html      2007-03-07 15:57:33.000000000 +0100
+@@ -18,7 +18,7 @@
+               <hr>
+               <p>Disclaimer: The functionality of this program is now available in the <tt>ntpd</tt> program. See the <tt>-q</tt> command line option in the <a href="ntpd.html"><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</a> page. After a suitable period of mourning, the <tt>ntpdate</tt> program is to be retired from this distribution</p>
+               <h4>Synopsis</h4>
+-              <tt>ntpdate [ -bBdoqsuv ] [ -a <i>key</i> ] [ -e <i>authdelay</i> ] [ -k <i>keyfile</i> ] [ -o <i>version</i> ] [ -p <i>samples</i> ] [ -t <i>timeout</i> ] <i>server</i> [ ... ]</tt>
++              <tt>ntpdate [ -bBdoqsuv ] [ -a <i>key</i> ] [ -e <i>authdelay</i> ] [ -k <i>keyfile</i> ] [ -o <i>version</i> ] [ -p <i>samples</i> ] [ -t <i>timeout</i> ] [ -U <i>user_name</i> ] <i>server</i> [ ... ]</tt>
+               <h4>Description</h4>
+               <tt>ntpdate</tt> sets the local date and time by polling the Network Time Protocol (NTP) server(s) given as the <i>server</i> arguments to determine the correct time. It must be run as root on the local host. A number of samples are obtained from each of the servers specified and a subset of the NTP clock filter and selection algorithms are applied to select the best of these. Note that the accuracy and reliability of <tt>ntpdate</tt> depends on the number of servers, the number of polls each time it is run and the interval between runs.
+               <p><tt>ntpdate</tt> can be run manually as necessary to set the host clock, or it can be run from the host startup script to set the clock at boot time. This is useful in some cases to set the clock initially before starting the NTP daemon <tt>ntpd</tt>. It is also possible to run <tt>ntpdate</tt> from a <tt>cron</tt> script. However, it is important to note that <tt>ntpdate</tt> with contrived <tt>cron</tt> scripts is no substitute for the NTP daemon, which uses sophisticated algorithms to maximize accuracy and reliability while minimizing resource use. Finally, since <tt>ntpdate</tt> does not discipline the host clock frequency as does <tt>ntpd</tt>, the accuracy using <tt>ntpdate</tt> is limited.</p>
+@@ -58,6 +58,11 @@
+                       <dd>Direct <tt>ntpdate</tt> to use an unprivileged port or outgoing packets. This is most useful when behind a firewall that blocks incoming traffic to privileged ports, and you want to synchronise with hosts beyond the firewall. Note that the <tt>-d</tt> option always uses unprivileged ports.
+                       <dt><tt>-<i>v</i></tt>
+                       <dd>Be verbose. This option will cause <tt>ntpdate</tt>'s version identification string to be logged.
++
++                      <dt><tt>-U <i>user_name</i></tt></dt>
++                      <dd>ntpdate process drops root privileges and changes user ID to
++                      <i>user_name</i> and group ID to the primary group of 
++                      <i>server_user</i>.
+               </dl>
+               <h4>Diagnostics</h4>
+               <tt>ntpdate</tt>'s exit status is zero if it finds a server and updates the clock, and nonzero otherwise.
diff --git a/packaging/ntp-4.2.4p0-retcode.patch b/packaging/ntp-4.2.4p0-retcode.patch
new file mode 100644 (file)
index 0000000..0502f6c
--- /dev/null
@@ -0,0 +1,13 @@
+https://ntp.isc.org/bugs/show_bug.cgi?id=759
+
+--- ntp-4.2.4p0/ntpd/ntp_proto.c.retcode       2006-12-28 13:03:32.000000000 +0100
++++ ntp-4.2.4p0/ntpd/ntp_proto.c       2007-05-22 15:20:07.000000000 +0200
+@@ -303,7 +303,7 @@
+                               if (peer_ntpdate == 0) {
+                                       msyslog(LOG_NOTICE,
+                                           "no reply; clock not set");
+-                                      exit (0);
++                                      exit (1);
+                               }
+                       }
+               }
diff --git a/packaging/ntp-4.2.4p2-clockselect.patch b/packaging/ntp-4.2.4p2-clockselect.patch
new file mode 100644 (file)
index 0000000..f0e3aba
--- /dev/null
@@ -0,0 +1,15 @@
+--- ntp-4.2.4p2/ntpd/ntp_proto.c.clockselect   2007-08-16 16:40:46.000000000 +0200
++++ ntp-4.2.4p2/ntpd/ntp_proto.c       2007-08-16 16:31:32.000000000 +0200
+@@ -2085,10 +2085,12 @@ clock_select(void)
+                       typeacts->status = CTL_PST_SEL_DISTSYSPEER;
+                       peer_list[0] = typeacts;
+                       nlist = 1;
++                      error[0] = synch[0] = 0.0;
+               } else if (typelocal != 0) {
+                       typelocal->status = CTL_PST_SEL_DISTSYSPEER;
+                       peer_list[0] = typelocal;
+                       nlist = 1;
++                      error[0] = synch[0] = 0.0;
+               } else {
+                       if (osys_peer != NULL) {
+                               NLOG(NLOG_SYNCSTATUS)
diff --git a/packaging/ntp-4.2.4p2-filegen.patch b/packaging/ntp-4.2.4p2-filegen.patch
new file mode 100644 (file)
index 0000000..264068f
--- /dev/null
@@ -0,0 +1,11 @@
+--- ntp-4.2.4p2/ntpd/ntp_config.c.filegen      2006-12-28 13:03:27.000000000 +0100
++++ ntp-4.2.4p2/ntpd/ntp_config.c      2007-07-19 17:09:42.000000000 +0200
+@@ -1733,7 +1733,7 @@ getconfig(
+                        * peerkey         is (ab)used for filegen type
+                        * peerflags   is (ab)used for filegen flags
+                        */
+-                      peerversion = 0;
++                      peerversion = 1;
+                       peerkey =         filegen->type;
+                       peerflags =   filegen->flag;
+                       errflg = 0;
diff --git a/packaging/ntp-4.2.4p2-noif.patch b/packaging/ntp-4.2.4p2-noif.patch
new file mode 100644 (file)
index 0000000..2e610f3
--- /dev/null
@@ -0,0 +1,77 @@
+diff -up ntp-4.2.4p2/libisc/ifiter_sysctl.c.noif ntp-4.2.4p2/libisc/ifiter_sysctl.c
+--- ntp-4.2.4p2/libisc/ifiter_sysctl.c.noif    2006-06-06 22:16:23.000000000 +0200
++++ ntp-4.2.4p2/libisc/ifiter_sysctl.c 2007-09-24 16:08:55.000000000 +0200
+@@ -309,7 +309,10 @@ internal_destroy(isc_interfaceiter_t *it
+        */
+ }
+-static
+-void internal_first(isc_interfaceiter_t *iter) {
++static isc_result_t
++internal_first(isc_interfaceiter_t *iter) {
+       iter->pos = 0;
++      if (iter->pos >= iter->bufused)
++              return (ISC_R_NOMORE);
++      return (ISC_R_SUCCESS);
+ }
+diff -up ntp-4.2.4p2/libisc/ifiter_ioctl.c.noif ntp-4.2.4p2/libisc/ifiter_ioctl.c
+--- ntp-4.2.4p2/libisc/ifiter_ioctl.c.noif     2007-09-24 16:08:55.000000000 +0200
++++ ntp-4.2.4p2/libisc/ifiter_ioctl.c  2007-09-24 16:08:55.000000000 +0200
+@@ -1098,8 +1098,8 @@ internal_destroy(isc_interfaceiter_t *it
+ #endif
+ }
+-static
+-void internal_first(isc_interfaceiter_t *iter) {
++static isc_result_t
++internal_first(isc_interfaceiter_t *iter) {
+ #ifdef HAVE_TRUCLUSTER
+       int clua_result;
+ #endif
+@@ -1118,5 +1118,10 @@ void internal_first(isc_interfaceiter_t 
+ #endif
+ #ifdef __linux
+       linux_if_inet6_first(iter);
++      if (iter->valid == ISC_R_SUCCESS)
++              return (iter->valid);
+ #endif
++      if (iter->pos >= (unsigned int) iter->ifc.ifc_len)
++              return (ISC_R_NOMORE);
++      return (ISC_R_SUCCESS);
+ }
+diff -up ntp-4.2.4p2/libisc/interfaceiter.c.noif ntp-4.2.4p2/libisc/interfaceiter.c
+--- ntp-4.2.4p2/libisc/interfaceiter.c.noif    2006-06-06 22:16:24.000000000 +0200
++++ ntp-4.2.4p2/libisc/interfaceiter.c 2007-09-24 16:08:55.000000000 +0200
+@@ -170,14 +170,11 @@ isc_interfaceiter_first(isc_interfaceite
+       REQUIRE(VALID_IFITER(iter));
+-      internal_first(iter);
+-      for (;;) {
++      for (result = internal_first(iter); result == ISC_R_SUCCESS;
++                      result = internal_next(iter)) {
+               result = internal_current(iter);
+               if (result != ISC_R_IGNORE)
+                       break;
+-              result = internal_next(iter);
+-              if (result != ISC_R_SUCCESS)
+-                      break;
+       }
+       iter->result = result;
+       return (result);
+diff -up ntp-4.2.4p2/libisc/ifiter_getifaddrs.c.noif ntp-4.2.4p2/libisc/ifiter_getifaddrs.c
+--- ntp-4.2.4p2/libisc/ifiter_getifaddrs.c.noif        2006-06-06 22:16:22.000000000 +0200
++++ ntp-4.2.4p2/libisc/ifiter_getifaddrs.c     2007-09-24 16:08:55.000000000 +0200
+@@ -185,7 +185,10 @@ internal_destroy(isc_interfaceiter_t *it
+       iter->ifaddrs = NULL;
+ }
+-static
+-void internal_first(isc_interfaceiter_t *iter) {
++static isc_result_t
++internal_first(isc_interfaceiter_t *iter) {
+       iter->pos = iter->ifaddrs;
++      if (iter->pos == NULL)
++              return (ISC_R_NOMORE);
++      return (ISC_R_SUCCESS);
+ }
diff --git a/packaging/ntp-4.2.4p2-noseed.patch b/packaging/ntp-4.2.4p2-noseed.patch
new file mode 100644 (file)
index 0000000..38ca527
--- /dev/null
@@ -0,0 +1,140 @@
+--- ntp-4.2.4p2/html/keygen.html.noseed        2007-07-18 16:03:45.000000000 +0200
++++ ntp-4.2.4p2/html/keygen.html       2007-07-18 16:03:33.000000000 +0200
+@@ -102,6 +102,7 @@
+               <p>All cryptographically sound key generation schemes must have means to randomize the entropy seed used to initialize the internal pseudo-random number generator used by the library routines. The OpenSSL library uses a designated random seed file for this purpose. The file must be available when starting the NTP daemon and <tt>ntp-keygen</tt> program. If a site supports OpenSSL or its companion OpenSSH, it is very likely that means to do this are already available.</p>
+               <p>It is important to understand that entropy must be evolved for each generation, for otherwise the random number sequence would be predictable. Various means dependent on external events, such as keystroke intervals, can be used to do this and some systems have built-in entropy sources. Suitable means are described in the OpenSSL software documentation, but are outside the scope of this page.</p>
+               <p>The entropy seed used by the OpenSSL library is contained in a file, usually called <tt>.rnd</tt>, which must be available when starting the NTP daemon or the <tt>ntp-keygen</tt> program. The NTP daemon will first look for the file using the path specified by the <tt>randfile</tt> subcommand of the <tt>crypto</tt> configuration command. If not specified in this way, or when starting the <tt>ntp-keygen</tt> program, the OpenSSL library will look for the file using the path specified by the <tt>RANDFILE</tt> environment variable in the user home directory, whether root or some other user. If the <tt>RANDFILE</tt> environment variable is not present, the library will look for the <tt>.rnd</tt> file in the user home directory. If the file is not available or cannot be written, the daemon exits with a message to the system log and the program exits with a suitable error message.</p>
++              <p>On systems that provide /dev/urandom, the randomness device is used instead and the file specified by the <tt>randfile</tt> subcommand or the <tt>RANDFILE</tt> environment variable is ignored.</p>
+               <h4 id="priv">Cryptographic Data Files</h4>
+               <p>All other file formats begin with two lines. The first contains the file name, including the generated host name and filestamp. The second contains the datestamp in conventional Unix <tt>date</tt> format. Lines beginning with <tt>#</tt> are considered comments and ignored by the <i><tt>ntp-keygen </tt></i>program and <tt>ntpd</tt> daemon. Cryptographic values are encoded first using ASN.1 rules, then encrypted if necessary, and finally written PEM-encoded printable ASCII format preceded and followed by MIME content identifier lines.</p>
+               <p id="symkey">The format of the symmetric keys file is somewhat different than the other files in the interest of backward compatibility. Since DES-CBC is deprecated in NTPv4, the only key format of interest is MD5 alphanumeric strings. Following hte heard the keys are entered one per line in the format</p>
+--- ntp-4.2.4p2/util/ntp-keygen.c.noseed       2007-06-20 13:03:23.000000000 +0200
++++ ntp-4.2.4p2/util/ntp-keygen.c      2007-07-18 16:03:45.000000000 +0200
+@@ -362,20 +362,24 @@ main(
+        */
+       ERR_load_crypto_strings();
+       OpenSSL_add_all_algorithms();
+-      if (RAND_file_name(pathbuf, MAXFILENAME) == NULL) {
+-              fprintf(stderr, "RAND_file_name %s\n",
+-                  ERR_error_string(ERR_get_error(), NULL));
+-              return (-1);
+-      }
+-      temp = RAND_load_file(pathbuf, -1);
+-      if (temp == 0) {
++
++      /* But only if openssl doesn't use /dev/urandom */
++      if (RAND_status() != 1) {
++              if (RAND_file_name(pathbuf, MAXFILENAME) == NULL) {
++                      fprintf(stderr, "RAND_file_name %s\n",
++                          ERR_error_string(ERR_get_error(), NULL));
++                      return (-1);
++              }
++              temp = RAND_load_file(pathbuf, -1);
++              if (temp == 0) {
++                      fprintf(stderr,
++                          "RAND_load_file %s not found or empty\n", pathbuf);
++                      return (-1);
++              }
+               fprintf(stderr,
+-                  "RAND_load_file %s not found or empty\n", pathbuf);
+-              return (-1);
++                  "Random seed file %s %u bytes\n", pathbuf, temp);
++              RAND_add(&epoch, sizeof(epoch), 4.0);
+       }
+-      fprintf(stderr,
+-          "Random seed file %s %u bytes\n", pathbuf, temp);
+-      RAND_add(&epoch, sizeof(epoch), 4.0);
+ #endif
+       /*
+--- ntp-4.2.4p2/ntpd/ntp_crypto.c.noseed       2006-12-28 13:03:28.000000000 +0100
++++ ntp-4.2.4p2/ntpd/ntp_crypto.c      2007-07-18 16:03:45.000000000 +0200
+@@ -3878,6 +3878,9 @@ crypto_setup(void)
+       memset(&pubkey, 0, sizeof(pubkey));
+       memset(&tai_leap, 0, sizeof(tai_leap));
++      ERR_load_crypto_strings();
++      OpenSSL_add_all_algorithms();
++
+       /*
+        * Load required random seed file and seed the random number
+        * generator. Be default, it is found in the user home
+@@ -3885,40 +3888,49 @@ crypto_setup(void)
+        * depending on the system. Wiggle the contents a bit and write
+        * it back so the sequence does not repeat when we next restart.
+        */
+-      ERR_load_crypto_strings();
+-      if (rand_file == NULL) {
+-              if ((RAND_file_name(filename, MAXFILENAME)) != NULL) {
++
++      /* But only if openssl doesn't use /dev/urandom */
++      if (RAND_status() != 1) {
++              if (rand_file == NULL) {
++                      if ((RAND_file_name(filename, MAXFILENAME)) != NULL) {
++                              rand_file = emalloc(strlen(filename) + 1);
++                              strcpy(rand_file, filename);
++                      }
++              } else if (*rand_file != '/') {
++                      snprintf(filename, MAXFILENAME, "%s/%s", keysdir,
++                                      rand_file);
++                      free(rand_file);
+                       rand_file = emalloc(strlen(filename) + 1);
+                       strcpy(rand_file, filename);
+               }
+-      } else if (*rand_file != '/') {
+-              snprintf(filename, MAXFILENAME, "%s/%s", keysdir,
+-                  rand_file);
+-              free(rand_file);
+-              rand_file = emalloc(strlen(filename) + 1);
+-              strcpy(rand_file, filename);
+-      }
+-      if (rand_file == NULL) {
+-              msyslog(LOG_ERR,
+-                  "crypto_setup: random seed file not specified");
+-              exit (-1);
+-      }
+-      if ((bytes = RAND_load_file(rand_file, -1)) == 0) {
+-              msyslog(LOG_ERR,
+-                  "crypto_setup: random seed file %s not found\n",
+-                  rand_file);
+-              exit (-1);
+-      }
+-      get_systime(&seed);
+-      RAND_seed(&seed, sizeof(l_fp));
+-      RAND_write_file(rand_file);
+-      OpenSSL_add_all_algorithms();
++              if (rand_file == NULL) {
++                      msyslog(LOG_ERR,
++                              "crypto_setup: random seed file not specified");
++                      exit (-1);
++              }
++              if ((bytes = RAND_load_file(rand_file, -1)) == 0) {
++                      msyslog(LOG_ERR,
++                              "crypto_setup: random seed file %s not found\n",
++                              rand_file);
++                      exit (-1);
++              }
++              get_systime(&seed);
++              RAND_seed(&seed, sizeof(l_fp));
++              RAND_write_file(rand_file);
+ #ifdef DEBUG
+-      if (debug)
+-              printf(
+-                  "crypto_setup: OpenSSL version %lx random seed file %s bytes read %d\n",
+-                  SSLeay(), rand_file, bytes);
++              if (debug)
++                      printf(
++                              "crypto_setup: OpenSSL version %lx random seed file %s bytes read %d\n",
++                              SSLeay(), rand_file, bytes);
+ #endif
++      } else {
++#ifdef DEBUG
++              if (debug)
++                      printf(
++                              "crypto_setup: OpenSSL version %lx seeding not required\n",
++                              SSLeay());
++#endif
++      }
+       /*
+        * Load required host key from file "ntpkey_host_<hostname>". It
diff --git a/packaging/ntp-4.2.4p2-tentative.patch b/packaging/ntp-4.2.4p2-tentative.patch
new file mode 100644 (file)
index 0000000..21f359b
--- /dev/null
@@ -0,0 +1,20 @@
+--- ntp-4.2.4p2/libisc/ifiter_ioctl.c.tentative        2006-12-28 13:03:07.000000000 +0100
++++ ntp-4.2.4p2/libisc/ifiter_ioctl.c  2007-07-16 13:04:15.000000000 +0200
+@@ -94,6 +94,7 @@ struct isc_interfaceiter {
+ #include <sys/socket.h>
+ #endif
++#include <linux/rtnetlink.h>
+ /*
+  * Size of buffer for SIOCGLIFCONF, in bytes.  We assume no sane system
+@@ -516,6 +517,9 @@ linux_if_inet6_current(isc_interfaceiter
+       if ((ifreq.ifr_flags & IFF_MULTICAST) != 0)
+               iter->current.flags |= INTERFACE_F_MULTICAST;
+ #endif
++      /* ignore tentative address */
++      if (flags & IFA_F_TENTATIVE)
++              iter->current.flags &= ~INTERFACE_F_UP;
+       /*
+        * enable_multicast_if() requires scopeid for setsockopt,
diff --git a/packaging/ntp-4.2.4p4-cmsgalign.patch b/packaging/ntp-4.2.4p4-cmsgalign.patch
new file mode 100644 (file)
index 0000000..fab5d87
--- /dev/null
@@ -0,0 +1,14 @@
+diff -up ntp-4.2.4p4/ntpd/ntp_io.c.cmsgalign ntp-4.2.4p4/ntpd/ntp_io.c
+--- ntp-4.2.4p4/ntpd/ntp_io.c.cmsgalign        2008-03-10 20:01:21.000000000 +0100
++++ ntp-4.2.4p4/ntpd/ntp_io.c  2008-03-10 20:04:02.000000000 +0100
+@@ -2933,8 +2933,8 @@ read_network_packet(SOCKET fd, struct in
+       msghdr.msg_namelen    = sizeof(rb->recv_srcadr);
+       msghdr.msg_iov        = &iovec;
+       msghdr.msg_iovlen     = 1;
+-      msghdr.msg_control    = (void *)&control;
+-      msghdr.msg_controllen = sizeof(control);
++      msghdr.msg_control    = (void *)((long)(control + 7) & -8); /* align to 8 bytes */
++      msghdr.msg_controllen = sizeof(control) - 8;
+       msghdr.msg_flags      = 0;
+       rb->recv_length       = recvmsg(fd, &msghdr, 0);
+ #endif
diff --git a/packaging/ntp-4.2.4p4-kernel.patch b/packaging/ntp-4.2.4p4-kernel.patch
new file mode 100644 (file)
index 0000000..9d1c1c7
--- /dev/null
@@ -0,0 +1,48 @@
+diff -up ntp-4.2.4p4/ntpd/cmd_args.c.kernel ntp-4.2.4p4/ntpd/cmd_args.c
+--- ntp-4.2.4p4/ntpd/cmd_args.c.kernel 2007-08-18 22:24:43.000000000 +0200
++++ ntp-4.2.4p4/ntpd/cmd_args.c        2008-02-27 16:57:56.000000000 +0100
+@@ -179,8 +179,10 @@ getCmdOpts(
+               } while (--ct > 0);
+       }
+-      if (HAVE_OPT( SLEW ))
++      if (HAVE_OPT( SLEW )) {
+               clock_max = 600;
++              kern_enable = 0;
++      }
+       if (HAVE_OPT( UPDATEINTERVAL )) {
+               long val = OPT_VALUE_UPDATEINTERVAL;
+diff -up ntp-4.2.4p4/ntpd/ntp_loopfilter.c.kernel ntp-4.2.4p4/ntpd/ntp_loopfilter.c
+--- ntp-4.2.4p4/ntpd/ntp_loopfilter.c.kernel   2007-02-24 12:02:05.000000000 +0100
++++ ntp-4.2.4p4/ntpd/ntp_loopfilter.c  2008-02-27 16:57:56.000000000 +0100
+@@ -337,8 +337,6 @@ local_clock(
+        */
+       clock_frequency = flladj = plladj = 0;
+       mu = peer->epoch - sys_clocktime;
+-      if (clock_max == 0 || clock_max > 0.5)
+-              kern_enable = 0;
+       rval = 1;
+       if (fabs(fp_offset) > clock_max && clock_max > 0) {
+               switch (state) {
+@@ -893,9 +891,9 @@ loop_config(
+               pll_control = 1;
+               memset(&ntv, 0, sizeof(ntv));
+ #ifdef STA_NANO
+-              ntv.modes = MOD_BITS | MOD_NANO;
++              ntv.modes = MOD_BITS | MOD_FREQUENCY | MOD_NANO;
+ #else /* STA_NANO */
+-              ntv.modes = MOD_BITS;
++              ntv.modes = MOD_BITS | MOD_FREQUENCY;
+ #endif /* STA_NANO */
+               ntv.maxerror = MAXDISPERSE;
+               ntv.esterror = MAXDISPERSE;
+@@ -1001,6 +999,8 @@ loop_config(
+        */
+       case LOOP_MAX:                  /* step threshold */
+               clock_max = freq;
++              if (clock_max == 0 || clock_max > 0.5)
++                      kern_enable = 0;
+               break;
+       case LOOP_PANIC:                /* panic threshold */
diff --git a/packaging/ntp-4.2.4p4-multilisten.patch b/packaging/ntp-4.2.4p4-multilisten.patch
new file mode 100644 (file)
index 0000000..04bfe7f
--- /dev/null
@@ -0,0 +1,126 @@
+diff -up ntp-4.2.4p4/include/ntpd.h.multilisten ntp-4.2.4p4/include/ntpd.h
+--- ntp-4.2.4p4/include/ntpd.h.multilisten     2006-12-28 13:03:06.000000000 +0100
++++ ntp-4.2.4p4/include/ntpd.h 2007-10-25 14:48:46.000000000 +0200
+@@ -79,6 +79,8 @@ extern  void enable_broadcast P((struct 
+ extern  void  enable_multicast_if P((struct interface *, struct sockaddr_storage *));
+ extern        void    interface_dump   P((struct interface *));
++extern  void    add_specific_interface P((const char *));
++extern  void    init_specific_interface P((void));
+ extern  void    interface_update P((interface_receiver_t, void *));
+ extern        void    init_io         P((void));
+ extern        void    input_handler   P((l_fp *));
+diff -up ntp-4.2.4p4/ntpd/ntp_io.c.multilisten ntp-4.2.4p4/ntpd/ntp_io.c
+--- ntp-4.2.4p4/ntpd/ntp_io.c.multilisten      2007-08-18 22:24:44.000000000 +0200
++++ ntp-4.2.4p4/ntpd/ntp_io.c  2007-10-25 14:48:46.000000000 +0200
+@@ -66,7 +66,15 @@
+ #endif  /* IPv6 Support */
+ extern int listen_to_virtual_ips;
+-extern const char *specific_interface;
++
++/* interface names to listen on */
++struct specific_interface {
++      const char *name;
++      ISC_LINK(struct specific_interface) link;
++};
++
++ISC_LIST(struct specific_interface) specific_interface_list;
++
+ #if defined(SO_TIMESTAMP) && defined(SCM_TIMESTAMP)
+ #if defined(CMSG_FIRSTHDR)
+@@ -924,14 +932,15 @@ address_okay(struct interface *iface) {
+       /*
+        * Check if the interface is specified
+        */
+-      if (specific_interface != NULL) {
+-              if (strcasecmp(iface->name, specific_interface) == 0) {
+-                      DPRINTF(4, ("address_okay: specific interface name matched - OK\n"));
+-                      return (ISC_TRUE);
+-              } else {
+-                      DPRINTF(4, ("address_okay: specific interface name NOT matched - FAIL\n"));
+-                      return (ISC_FALSE);
+-              }
++      if (ISC_LIST_HEAD(specific_interface_list)) {
++              struct specific_interface *iface_;
++              for (iface_ = ISC_LIST_HEAD(specific_interface_list); iface_ != NULL; iface_ = ISC_LIST_NEXT(iface_, link))
++                      if (strcasecmp(iface->name, iface_->name) == 0) {
++                              DPRINTF(4, ("address_okay: specific interface name matched - OK\n"));
++                              return (ISC_TRUE);
++                      }
++              DPRINTF(4, ("address_okay: specific interface name NOT matched - FAIL\n"));
++              return (ISC_FALSE);
+       }
+       else {
+               if (listen_to_virtual_ips == 0  && 
+@@ -1044,6 +1053,23 @@ refresh_interface(struct interface * int
+ #endif /* !OS_MISSES_SPECIFIC_ROUTE_UPDATES */
+ }
++void
++add_specific_interface (const char *if_name)
++{
++      struct specific_interface *iface;
++
++      iface = (struct specific_interface *)emalloc(sizeof(struct specific_interface));
++      iface->name = if_name;
++      ISC_LINK_INIT(iface, link);
++      ISC_LIST_APPEND(specific_interface_list, iface, link);
++}
++
++void
++init_specific_interface (void)
++{
++      ISC_LIST_INIT(specific_interface_list);
++}
++
+ /*
+  * interface_update - externally callable update function
+  */
+diff -up ntp-4.2.4p4/ntpd/cmd_args.c.multilisten ntp-4.2.4p4/ntpd/cmd_args.c
+--- ntp-4.2.4p4/ntpd/cmd_args.c.multilisten    2007-08-18 22:24:43.000000000 +0200
++++ ntp-4.2.4p4/ntpd/cmd_args.c        2007-10-25 14:50:44.000000000 +0200
+@@ -22,7 +22,6 @@
+  * Definitions of things either imported from or exported to outside
+  */
+ extern char const *progname;
+-extern const char *specific_interface;
+ extern short default_ai_family;
+ #ifdef HAVE_NETINFO
+diff -up ntp-4.2.4p4/ntpd/ntpd.c.multilisten ntp-4.2.4p4/ntpd/ntpd.c
+--- ntp-4.2.4p4/ntpd/ntpd.c.multilisten        2007-10-25 14:48:46.000000000 +0200
++++ ntp-4.2.4p4/ntpd/ntpd.c    2007-10-25 14:48:46.000000000 +0200
+@@ -156,7 +156,6 @@ volatile int debug = 0;            /* No debugging
+ #endif
+ int   listen_to_virtual_ips = 1;
+-const char *specific_interface = NULL;        /* interface name or IP address to bind to */
+ /*
+  * No-fork flag.  If set, we do not become a background daemon.
+@@ -537,18 +536,14 @@ ntpdmain(
+       if (HAVE_OPT( NOVIRTUALIPS ))
+               listen_to_virtual_ips = 0;
++      init_specific_interface();
++
+       if (HAVE_OPT( INTERFACE )) {
+-#if 0
+               int     ifacect = STACKCT_OPT( INTERFACE );
+-              char**  ifaces  = STACKLST_OPT( INTERFACE );
++              const char** ifaces  = STACKLST_OPT( INTERFACE );
+-              /* malloc space for the array of names */
+-              while (ifacect-- > 0) {
+-                      next_iface = *ifaces++;
+-              }
+-#else
+-              specific_interface = OPT_ARG( INTERFACE );
+-#endif
++              while (ifacect-- > 0)
++                      add_specific_interface(*ifaces++);
+       }
+       if (HAVE_OPT( NICE ))
diff --git a/packaging/ntp-4.2.4p4-resinit.patch b/packaging/ntp-4.2.4p4-resinit.patch
new file mode 100644 (file)
index 0000000..e754900
--- /dev/null
@@ -0,0 +1,19 @@
+diff -up ntp-4.2.4p5/ntpd/ntp_intres.c.resinit ntp-4.2.4p5/ntpd/ntp_intres.c
+--- ntp-4.2.4p5/ntpd/ntp_intres.c.resinit      2008-08-10 13:02:43.000000000 +0200
++++ ntp-4.2.4p5/ntpd/ntp_intres.c      2008-10-07 14:54:20.000000000 +0200
+@@ -39,6 +39,7 @@
+ /**/
+ #include <netinet/in.h>
+ #include <arpa/inet.h>
++#include <resolv.h>
+ /**/
+ #ifdef HAVE_SYS_PARAM_H
+ # include <sys/param.h>               /* MAXHOSTNAMELEN (often) */
+@@ -272,6 +273,7 @@ ntp_intres(void)
+                        * Sleep a little to make sure the network is completely up
+                        */
+                       sleep(SLEEPTIME);
++                      res_init();
+                       doconfigure(1);
+                       /* prepare retry, in case there's more work to do */
diff --git a/packaging/ntp-4.2.4p5-driftonexit.patch b/packaging/ntp-4.2.4p5-driftonexit.patch
new file mode 100644 (file)
index 0000000..0d99d41
--- /dev/null
@@ -0,0 +1,11 @@
+diff -up ntp-4.2.4p5/ntpd/ntpd.c.driftonexit ntp-4.2.4p5/ntpd/ntpd.c
+--- ntp-4.2.4p5/ntpd/ntpd.c.driftonexit        2008-10-07 15:22:27.000000000 +0200
++++ ntp-4.2.4p5/ntpd/ntpd.c    2008-10-07 16:29:06.000000000 +0200
+@@ -1174,7 +1174,6 @@ finish(
+ {
+       msyslog(LOG_NOTICE, "ntpd exiting on signal %d", sig);
+-      write_stats();
+ #ifdef HAVE_DNSREGISTRATION
+       if (mdns != NULL)
+       DNSServiceRefDeallocate(mdns);
diff --git a/packaging/ntp-4.2.4p5-htmldoc.patch b/packaging/ntp-4.2.4p5-htmldoc.patch
new file mode 100644 (file)
index 0000000..3b44128
--- /dev/null
@@ -0,0 +1,399 @@
+diff -up ntp-4.2.4p5/html/authopt.html.htmldoc ntp-4.2.4p5/html/authopt.html
+--- ntp-4.2.4p5/html/authopt.html.htmldoc      2006-12-28 13:02:54.000000000 +0100
++++ ntp-4.2.4p5/html/authopt.html      2008-08-18 12:31:59.000000000 +0200
+@@ -74,7 +74,7 @@
+                       <dt><tt>controlkey <i>key</i></tt>
+                       <dd>Specifies the key identifier to use with the <a href="ntpq.html"><tt>ntpq</tt></a> utility, which uses the standard protocol defined in RFC-1305. The <tt><i>key</i></tt> argument is the key identifier for a trusted key, where the value can be in the range 1 to 65,534, inclusive.
+                       <dt><tt>crypto [cert <i>file</i>] [leap <i>file</i>] [randfile <i>file</i>] [host <i>file</i>] [sign <i>file</i>] [ident <i>scheme</i>] [iffpar <i>file</i>] [gqpar <i>file</i>] [mvpar <i>file</i>] [pw <i>password</i>]</tt>
+-                      <dd>This command requires the OpenSSL library. It activates public key cryptography, selects the message digest and signature encryption scheme and loads the required private and public values described above. If one or more files are left unspecified, the default names are used as described above. Unless the complete path and name of the file are specified, the location of a file is relative to the keys directory specified in the <tt>keysdir</tt> command or default <tt>/usr/local/etc</tt>. Following are the subcommands:
++                      <dd>This command requires the OpenSSL library. It activates public key cryptography, selects the message digest and signature encryption scheme and loads the required private and public values described above. If one or more files are left unspecified, the default names are used as described above. Unless the complete path and name of the file are specified, the location of a file is relative to the keys directory specified in the <tt>keysdir</tt> command or default <tt>/etc/ntp/crypto</tt>. Following are the subcommands:
+                               <dl>
+                                       <dt><tt>cert <i>file</i></tt>
+                                       <dd>Specifies the location of the required host public certificate file. This overrides the link <tt>ntpkey_cert_<i>hostname</i></tt> in the keys directory.
+@@ -103,7 +103,7 @@
+                       <dt><tt>keys <i>keyfile</i></tt>
+                       <dd>Specifies the complete path and location of the MD5 key file containing the keys and key identifiers used by <tt>ntpd</tt>, <tt>ntpq</tt> and <tt>ntpdc</tt> when operating with symmetric key cryptography. This is the same operation as the <tt>-k </tt>command line option.
+                       <dt><tt>keysdir <i>path</i></tt>
+-                      <dd>This command specifies the default directory path for cryptographic keys, parameters and certificates. The default is <tt>/usr/local/etc/</tt>.
++                      <dd>This command specifies the default directory path for cryptographic keys, parameters and certificates. The default is <tt>/etc/ntp/crypto</tt>.
+                       <dt><tt>requestkey <i>key</i></tt>
+                       <dd>Specifies the key identifier to use with the <a href="ntpdc.html"><tt>ntpdc</tt></a> utility program, which uses a proprietary protocol specific to this implementation of <tt>ntpd</tt>. The <tt><i>key</i></tt> argument is a key identifier for the trusted key, where the value can be in the range 1 to 65,534, inclusive.
+                       <dt><tt>revoke [<i>logsec</i>]</tt>
+diff -up ntp-4.2.4p5/html/confopt.html.htmldoc ntp-4.2.4p5/html/confopt.html
+--- ntp-4.2.4p5/html/confopt.html.htmldoc      2008-08-10 13:02:43.000000000 +0200
++++ ntp-4.2.4p5/html/confopt.html      2008-08-18 12:31:59.000000000 +0200
+@@ -32,8 +32,8 @@
+               <p>There are three types of associations: persistent, preemptable and ephemeral. Persistent associations are mobilized by a configuration command and never demobilized. Preemptable associations, which are new to NTPv4, are mobilized by a configuration command which includes the <tt>prempt</tt> flag and are demobilized by timeout or error. Ephemeral associations are mobilized upon arrival of designated messages and demobilized by timeout or error.</p>
+               <dl>
+                       <dt><tt>server <i>address</i> [options ...]</tt><br>
+-                              <tt>peer <i>address</i> [</tt><tt>options ...]<br>
+-                                      broadcast <i>address</i> [options ...]</tt><br>
++                              <tt>peer <i>address</i> [options ...]</tt><br>
++                                      <tt>broadcast <i>address</i> [options ...]</tt><br>
+                               <tt>manycastclient <i>address</i> [options ...]</tt>
+                       <dd>These four commands specify the time server name or address to be used and the mode in which to operate. The <i>address</i> can be either a DNS name or a IP address in dotted-quad notation. Additional information on association behavior can be found in the <a href="assoc.html">Association Management</a> page.
+                               <dl>
+diff -up ntp-4.2.4p5/html/keygen.html.htmldoc ntp-4.2.4p5/html/keygen.html
+--- ntp-4.2.4p5/html/keygen.html.htmldoc       2008-08-18 12:31:59.000000000 +0200
++++ ntp-4.2.4p5/html/keygen.html       2008-08-18 12:31:59.000000000 +0200
+@@ -32,17 +32,17 @@
+               </ul>
+               <hr>
+               <h4 id="synop">Synopsis</h4>
+-              <p id="intro"><tt>ntp-keygen [ -deGgHIMnPT ] [ -c [RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] [ -i <i>name</i> ] [ -p <i>password</i> ] [ -S [ RSA | DSA ] ] [ -s <i>name</i> ] [ -v <i>nkeys</i> ]</tt></p>
++              <p id="intro"><tt>ntp-keygen [ -deGgHIMPT ] [ -c [RSA-MD2 | RSA-MD5 | RSA-SHA | RSA-SHA1 | RSA-MDC2 | RSA-RIPEMD160 | DSA-SHA | DSA-SHA1 ] ] [ -i <i>name</i> ] [ -m <i>modulus</i> ] [ -p <i>password</i> ] [ -q <i>password</i> ] [ -S [ RSA | DSA ] ] [ -s <i>name</i> ] [ -v <i>nkeys</i> ] [ -V <i>params</i> ]</tt></p>
+               <h4 id="descrip">Description</h4>
+               <p>This program generates cryptographic data files used by the NTPv4 authentication and identification schemes. It generates MD5 key files used in symmetric key cryptography. In addition, if the OpenSSL software library has been installed, it generates keys, certificate and identity files used in public key cryptography. These files are used for cookie encryption, digital signature and challenge/response identification algorithms compatible with the Internet standard security infrastructure.</p>
+               <p>By default, files are not encrypted by <tt>ntp-keygen</tt>. The <tt>-p <i>password</i></tt> option specifies the write password and <tt>-q <i>password</i></tt> option the read password for previously encrypted files. The <tt>ntp-keygen</tt> program prompts for the password if it reads an encrypted file and the password is missing or incorrect. If an encrypted file is read successfully and no write password is specified, the read password is used as the write password by default.</p>
+               <p>The <tt>ntpd</tt> configuration command <tt>crypto pw <i>password</i></tt> specifies the read password for previously encrypted files. The daemon expires on the spot if the password is missing or incorrect. For convenience, if a file has been previously encrypted, the default read password is the name of the host running the program. If the previous write password is specified as the host name, these files can be read by that host with no explicit password.</p>
+               <p>All files are in PEM-encoded printable ASCII format, so they can be embedded as MIME attachments in mail to other sites and certificate authorities. File names begin with the prefix <tt>ntpkey_</tt> and end with the postfix <tt><i>_hostname.filestamp</i></tt>, where <tt><i>hostname</i></tt> is usually the string returned by the Unix <tt>gethostname()</tt> routine, and <tt><i>filestamp</i></tt> is the NTP seconds when the file was generated, in decimal digits. This both guarantees uniqueness and simplifies maintenance procedures, since all files can be quickly removed by a <tt>rm ntpkey*</tt> command or all files generated at a specific time can be removed by a <tt>rm *<i>filestamp</i></tt> command. To further reduce the risk of misconfiguration, the first two lines of a file contain the file name and generation date and time as comments.</p>
+-              <p>All files are installed by default in the keys directory <tt>/usr/local/etc</tt>, which is normally in a shared filesystem in NFS-mounted networks. The actual location of the keys directory and each file can be overridden by configuration commands, but this is not recommended. Normally, the files for each host are generated by that host and used only by that host, although exceptions exist as noted later on this page.</p>
++              <p>All files are installed by default in the keys directory <tt>/etc/ntp/crypto</tt>. The actual location of the keys directory and each file can be overridden by configuration commands, but this is not recommended. Normally, the files for each host are generated by that host and used only by that host, although exceptions exist as noted later on this page.</p>
+               <p>Normally, files containing private values, including the host key, sign key and identification parameters, are permitted root read/write-only; while others containing public values are permitted world readable. Alternatively, files containing private values can be encrypted and these files permitted world readable, which simplifies maintenance in shared file systems. Since uniqueness is insured by the hostname and file name extensions, the files for a NFS server and dependent clients can all be installed in the same shared directory.</p>
+               <p>The recommended practice is to keep the file name extensions when installing a file and to install a soft link from the generic names specified elsewhere on this page to the generated files. This allows new file generations to be activated simply by changing the link. If a link is present, <tt>ntpd</tt> follows it to the file name to extract the filestamp. If a link is not present, <tt>ntpd</tt> extracts the filestamp from the file itself. This allows clients to verify that the file and generation times are always current. The <tt>ntp-keygen</tt> program uses the same extension for all files generated at one time, so each generation is distinct and can be readily recognized in monitoring data.</p>
+               <h4 id="run">Running the program</h4>
+-              <p>The safest way to run the <tt>ntp-keygen</tt> program is logged in directly as root. The recommended procedure is change to the keys directory, usually <tt>/ust/local/etc</tt>, then run the program. When run for the first time, or if all <tt>ntpkey</tt> files have been removed, the program generates a RSA host key file and matching RSA-MD5 certificate file, which is all that is necessary in many cases. The program also generates soft links from the generic names to the respective files. If run again, the program uses the same host key file, but generates a new certificate file and link.</p>
++              <p>The safest way to run the <tt>ntp-keygen</tt> program is logged in directly as root. The recommended procedure is change to the keys directory, usually <tt>/etc/ntp/crypto</tt>, then run the program. When run for the first time, or if all <tt>ntpkey</tt> files have been removed, the program generates a RSA host key file and matching RSA-MD5 certificate file, which is all that is necessary in many cases. The program also generates soft links from the generic names to the respective files. If run again, the program uses the same host key file, but generates a new certificate file and link.</p>
+               <p>The host key is used to encrypt the cookie when required and so must be RSA type. By default, the host key is also the sign key used to encrypt signatures. When necessary, a different sign key can be specified and this can be either RSA or DSA type. By default, the message digest type is MD5, but any combination of sign key type and message digest type supported by the OpenSSL library can be specified, including those using the MD2, MD5, SHA, SHA1, MDC2 and RIPE160 message digest algorithms. However, the scheme specified in the certificate must be compatible with the sign key. Certificates using any digest algorithm are compatible with RSA sign keys; however, only SHA and SHA1 certificates are compatible with DSA sign keys.</p>
+               <p>Private/public key files and certificates are compatible with other OpenSSL applications and very likely other libraries as well. Certificates or certificate requests derived from them should be compatible with extant industry practice, although some users might find the interpretation of X509v3 extension fields somewhat liberal. However, the identification parameter files, although encoded as the other files, are probably not compatible with anything other than Autokey.</p>
+               <p>Running the program as other than root and using the Unix <tt>su</tt> command to assume root may not work properly, since by default the OpenSSL library looks for the random seed file <tt>.rnd</tt> in the user home directory. However, there should be only one <tt>.rnd</tt>, most conveniently in the root directory, so it is convenient to define the <tt>$RANDFILE</tt> environment variable used by the OpenSSL library as the path to <tt>/.rnd</tt>.</p>
+@@ -81,11 +81,13 @@
+                       <dd>Set the suject name to <i>name</i>. This is used as the subject field in certificates and in the file name for host and sign keys.
+                       <dt><tt>-M</tt>
+                       <dd>Generate MD5 keys, obsoleting any that may exist.
++                      <dt><tt>-m <i>modulus</i></tt>
++                      <dd>Set prime modulus size in bits (256 - 2048). Default size is 512.
+                       <dt><tt>-P</tt>
+                       <dd>Generate a private certificate. By default, the program generates public certificates.
+                       <dt><tt>-p <i>password</i></tt>
+                       <dd>Encrypt generated files containing private data with <tt><i>password</i></tt> and the DES-CBC algorithm.
+-                      <dt><tt>-q</tt>
++                      <dt><tt>-q <i>password</i></tt>
+                       <dd>Set the password for reading files to <tt><i>password</i></tt>.
+                       <dt><tt>-S [ RSA | DSA ]</tt>
+                       <dd>Generate a new sign key of the designated type, obsoleting any that may exist. By default, the program uses the host key as the sign key.
+diff -up ntp-4.2.4p5/html/monopt.html.htmldoc ntp-4.2.4p5/html/monopt.html
+--- ntp-4.2.4p5/html/monopt.html.htmldoc       2006-12-28 13:02:56.000000000 +0100
++++ ntp-4.2.4p5/html/monopt.html       2008-08-18 12:31:59.000000000 +0200
+@@ -82,9 +82,7 @@
+                                               <dl>
+                                                       <dt><i><tt>name</tt></i>
+                                                       <dd>This is the type of the statistics records, as shown in the <tt>statistics</tt> command.
+-                                              </dl>
+-                                      <dd><tt>file <i>filename</i></tt>
+-                                              <dl>
++                                      <dt><tt>file <i>filename</i></tt>
+                                                       <dd>This is the file name for the statistics records. Filenames of set members are built from three concatenated elements <i><tt>prefix</tt></i>, <i><tt>filename</tt></i> and <i><tt>suffix</tt></i>:
+                                                               <dl>
+                                                                       <dt><i><tt>prefix</tt></i>
+@@ -94,9 +92,7 @@
+                                                                       <dt><i><tt>suffix</tt></i>
+                                                                       <dd>This part is reflects individual elements of a file set. It is generated according to the type of a file set.
+                                                               </dl>
+-                                              </dl>
+-                                      <dd><tt>type <i>typename</i></tt>
+-                                              <dl>
++                                      <dt><tt>type <i>typename</i></tt>
+                                                       <dd>A file generation set is characterized by its type. The following types are supported:
+                                                               <dl>
+                                                                       <dt><tt>none</tt>
+@@ -114,13 +110,9 @@
+                                                                       <dt><tt>age</tt>
+                                                                       <dd>This type of file generation sets changes to a new element of the file set every 24 hours of server operation. The filename suffix consists of a dot, the letter <tt>a</tt>, and an 8-digit number. This number is taken to be the number of seconds the server is running at the start of the corresponding 24-hour period. Information is only written to a file generation by specifying <tt>enable</tt>; output is prevented by specifying <tt>disable</tt>.
+                                                               </dl>
+-                                              </dl>
+-                                      <dd><tt>link | nolink</tt>
+-                                              <dl>
++                                      <dt><tt>link | nolink</tt>
+                                                       <dd>It is convenient to be able to access the current element of a file generation set by a fixed name. This feature is enabled by specifying <tt>link</tt> and disabled using <tt>nolink</tt>. If <tt>link</tt> is specified, a hard link from the current file set element to a file without suffix is created. When there is already a file with this name and the number of links of this file is one, it is renamed appending a dot, the letter <tt>C</tt>, and the pid of the <tt>ntpd</tt> server process. When the number of links is greater than one, the file is unlinked. This allows the current file to be accessed by a constant name.
+-                                              </dl>
+-                                      <dd><tt>enable | disable</tt>
+-                                              <dl>
++                                      <dt><tt>enable | disable</tt>
+                                                       <dd>Enables or disables the recording function.
+                                               </dl>
+                               </dl>
+diff -up ntp-4.2.4p5/html/ntpd.html.htmldoc ntp-4.2.4p5/html/ntpd.html
+--- ntp-4.2.4p5/html/ntpd.html.htmldoc 2006-12-28 13:02:57.000000000 +0100
++++ ntp-4.2.4p5/html/ntpd.html 2008-08-18 12:31:59.000000000 +0200
+@@ -34,7 +34,7 @@
+               </ul>
+               <hr>
+               <h4 id="synop">Synopsis</h4>
+-              <tt>ntpd [ -46aAbdDgLmnNqx ] [ -c <i>conffile</i> ] [ -f <i>driftfile</i> ] [ -i <i>jaildir</i> ] [ -k <i>keyfile</i> ] [ -l <i>logfile</i> ] [ -p <i>pidfile</i> ] [ -P <i>priority</i> ] [ -r <i>broadcastdelay</i> ] [ -s <i>statsdir</i> ] [ -t <i>key</i> ] [ -u <i>user</i>[:<i>group</i>] ] [ -U <i>interface_update_interval</i> ] [ -v <i>variable</i> ] [ -V <i>variable</i> ]</tt>
++              <tt>ntpd [ -46aAbdDgLnNqx ] [ -c <i>conffile</i> ] [ -f <i>driftfile</i> ] [ -i <i>jaildir</i> ] [ -I <i>iface</i> ] [ -k <i>keyfile</i> ] [ -l <i>logfile</i> ] [ -p <i>pidfile</i> ] [ -P <i>priority</i> ] [ -r <i>broadcastdelay</i> ] [ -s <i>statsdir</i> ] [ -t <i>key</i> ] [ -u <i>user</i>[:<i>group</i>] ] [ -U <i>interface_update_interval</i> ] [ -v <i>variable</i> ] [ -V <i>variable</i> ]</tt>
+               <h4 id="descr">Description</h4>
+               <p>The <tt>ntpd</tt> program is an operating system daemon which sets and maintains the system time of day in synchronism with Internet standard time servers. It is a complete implementation of the Network Time Protocol (NTP) version 4, but also retains compatibility with version 3, as defined by RFC-1305, and version 1 and 2, as defined by RFC-1059 and RFC-1119, respectively. <tt>ntpd</tt> does most computations in 64-bit floating point arithmetic and does relatively clumsy 64-bit fixed point operations only when necessary to preserve the ultimate precision, about 232 picoseconds. While the ultimate precision is not achievable with ordinary workstations and networks of today, it may be required with future gigahertz CPU clocks and gigabit LANs.</p>
+               <h4 id="op">How NTP Operates</h4>
+@@ -63,8 +63,13 @@
+               <p>In contexts where a host name is expected, a <tt>-4</tt> qualifier preceding the host name forces DNS resolution to the IPv4 namespace, while a <tt>-6</tt> qualifier forces DNS resolution to the IPv6 namespace.</p>
+               <p>Various internal <tt>ntpd</tt> variables can be displayed and configuration options altered while the <tt>ntpd</tt> is running using the <tt><a href="ntpq.html">ntpq</a></tt> and <tt><a href="ntpdc.html">ntpdc</a></tt> utility programs.</p>
+               <p>When <tt>ntpd</tt> starts it looks at the value of <tt>umask</tt>, and if zero <tt>ntpd</tt> will set the <tt>umask</tt> to <tt>022</tt>.</p>
++              <p>Unless the <tt>-n</tt>, <tt>-d</tt> or <tt>-D</tt> option is used, <tt>ntpd</tt> changes the current working directory to the root directory, so any options or commands specifying paths need to use an absolute path or a path relative to the root.</p>
+               <h4 id="cmd">Command Line Options</h4>
+               <dl>
++                      <dt><tt>-4</tt>
++                      <dd>Force DNS resolution of host names to the IPv4 namespace.
++                      <dt><tt>-6</tt>
++                      <dd>Force DNS resolution of host names to the IPv6 namespace.
+                       <dt><tt>-a</tt>
+                       <dd>Require cryptographic authentication for broadcast client, multicast client and symmetric passive associations. This is the default.
+                       <dt><tt>-A</tt>
+@@ -78,13 +83,15 @@
+                       <dt><tt>-D <i>level</i></tt>
+                       <dd>Specify debugging level directly.
+                       <dt><tt>-f <i>driftfile</i></tt>
+-                      <dd>Specify the name and path of the frequency file, default <tt>/etc/ntp.drift</tt>. This is the same operation as the <tt>driftfile <i>driftfile</i></tt> configuration command.
++                      <dd>Specify the name and path of the frequency file. This is the same operation as the <tt>driftfile <i>driftfile</i></tt> configuration command.
+                       <dt><tt>-g</tt>
+                       <dd>Normally, <tt>ntpd</tt> exits with a message to the system log if the offset exceeds the panic threshold, which is 1000 s by default. This option allows the time to be set to any value without restriction; however, this can happen only once. If the threshold is exceeded after that, <tt>ntpd</tt> will exit with a message to the system log. This option can be used with the <tt>-q</tt> and <tt>-x</tt> options. See the <tt>tinker</tt> command for other options.
+                       <dt><tt>-i <i>jaildir</i></tt>
+                       <dd>Chroot the server to the directory <i>jaildir</i>. This option also implies that the server attempts to drop root privileges at startup (otherwise, chroot gives very little additional security), and it is only available if the OS supports to run the server without full root privileges. You may need to also specify a <tt>-u</tt> option.
++                      <dt><tt>-I <i>iface</i></tt>
++                      <dd>Listen on interface. This option may appear an unlimited number of times.
+                       <dt><tt>-k <i>keyfile</i></tt>
+-                      <dd>Specify the name and path of the symmetric key file, default <tt>/etc/ntp.keys</tt>. This is the same operation as the <tt>keys <i>keyfile</i></tt> configuration command.
++                      <dd>Specify the name and path of the symmetric key file. This is the same operation as the <tt>keys <i>keyfile</i></tt> configuration command.
+                       <dt><tt>-l <i>logfile</i></tt>
+                       <dd>Specify the name and path of the log file. The default is the system log file. This is the same operation as the <tt>logfile <i>logfile</i></tt> configuration command.
+                       <dt><tt>-L</tt>
+@@ -143,7 +150,7 @@
+                       </tr>
+                       <tr>
+                               <td width="30%">frequency file</td>
+-                              <td width="30%"><tt>/etc/ntp.drift</tt></td>
++                              <td width="30%"><tt>none</tt></td>
+                               <td width="20%"><tt>-f</tt></td>
+                               <td width="20%"><tt>driftfile</tt></td>
+                       </tr>
+@@ -167,17 +174,20 @@
+                       </tr>
+                       <tr>
+                               <td width="30%">statistics path</td>
+-                              <td width="30%"><tt>/var/NTP</tt></td>
++                              <td width="30%"><tt>/var/log/ntpstats/</tt></td>
+                               <td width="20%"><tt>-s</tt></td>
+                               <td width="20%"><tt>statsdir</tt></td>
+                       </tr>
+                       <tr>
+                               <td width="30%">keys path</td>
+-                              <td width="30%"><tt>/usr/local/etc</tt></td>
+-                              <td width="20%"><tt>-k</tt></td>
++                              <td width="30%"><tt>/etc/ntp/crypto</tt></td>
++                              <td width="20%"><tt>none</tt></td>
+                               <td width="20%"><tt>keysdir</tt></td>
+                       </tr>
+               </table>
++              <h4 id="codes">Exit Codes</h4>
++              <p>A non-zero exit code indicates an error. Any error messages are logged to the system log by default.</p>
++              <p>The exit code is 0 only when <tt>ntpd</tt> is terminated by a signal, or when the <tt>-q</tt> option is used and <tt>ntpd</tt> successfully sets the system clock.</p>
+               <hr>
+               <script type="text/javascript" language="javascript" src="scripts/footer.txt"></script>
+       </body>
+diff -up ntp-4.2.4p5/html/ntpdate.html.htmldoc ntp-4.2.4p5/html/ntpdate.html
+--- ntp-4.2.4p5/html/ntpdate.html.htmldoc      2008-08-18 12:31:59.000000000 +0200
++++ ntp-4.2.4p5/html/ntpdate.html      2008-08-18 12:31:59.000000000 +0200
+@@ -18,9 +18,9 @@
+               <hr>
+               <p>Disclaimer: The functionality of this program is now available in the <tt>ntpd</tt> program. See the <tt>-q</tt> command line option in the <a href="ntpd.html"><tt>ntpd</tt> - Network Time Protocol (NTP) daemon</a> page. After a suitable period of mourning, the <tt>ntpdate</tt> program is to be retired from this distribution</p>
+               <h4>Synopsis</h4>
+-              <tt>ntpdate [ -bBdoqsuv ] [ -a <i>key</i> ] [ -e <i>authdelay</i> ] [ -k <i>keyfile</i> ] [ -o <i>version</i> ] [ -p <i>samples</i> ] [ -t <i>timeout</i> ] [ -U <i>user_name</i> ] <i>server</i> [ ... ]</tt>
++              <tt>ntpdate [ -46bBdqsuv ] [ -a <i>key</i> ] [ -e <i>authdelay</i> ] [ -k <i>keyfile</i> ] [ -o <i>version</i> ] [ -p <i>samples</i> ] [ -t <i>timeout</i> ] [ -U <i>user_name</i> ] <i>server</i> [ ... ]</tt>
+               <h4>Description</h4>
+-              <tt>ntpdate</tt> sets the local date and time by polling the Network Time Protocol (NTP) server(s) given as the <i>server</i> arguments to determine the correct time. It must be run as root on the local host. A number of samples are obtained from each of the servers specified and a subset of the NTP clock filter and selection algorithms are applied to select the best of these. Note that the accuracy and reliability of <tt>ntpdate</tt> depends on the number of servers, the number of polls each time it is run and the interval between runs.
++              <p><tt>ntpdate</tt> sets the local date and time by polling the Network Time Protocol (NTP) server(s) given as the <i>server</i> arguments to determine the correct time. It must be run as root on the local host. A number of samples are obtained from each of the servers specified and a subset of the NTP clock filter and selection algorithms are applied to select the best of these. Note that the accuracy and reliability of <tt>ntpdate</tt> depends on the number of servers, the number of polls each time it is run and the interval between runs.</p>
+               <p><tt>ntpdate</tt> can be run manually as necessary to set the host clock, or it can be run from the host startup script to set the clock at boot time. This is useful in some cases to set the clock initially before starting the NTP daemon <tt>ntpd</tt>. It is also possible to run <tt>ntpdate</tt> from a <tt>cron</tt> script. However, it is important to note that <tt>ntpdate</tt> with contrived <tt>cron</tt> scripts is no substitute for the NTP daemon, which uses sophisticated algorithms to maximize accuracy and reliability while minimizing resource use. Finally, since <tt>ntpdate</tt> does not discipline the host clock frequency as does <tt>ntpd</tt>, the accuracy using <tt>ntpdate</tt> is limited.</p>
+               <p>Time adjustments are made by <tt>ntpdate</tt> in one of two ways. If <tt>ntpdate</tt> determines the clock is in error more than 0.5 second it will simply step the time by calling the system <tt>settimeofday()</tt> routine. If the error is less than 0.5 seconds, it will slew the time by calling the system <tt>adjtime()</tt> routine. The latter technique is less disruptive and more accurate when the error is small, and works quite well when <tt>ntpdate</tt> is run by <tt>cron</tt> every hour or two.</p>
+               <p><tt>ntpdate</tt> will decline to set the date if an NTP server daemon (e.g., <tt>ntpd</tt>) is running on the same host. When running <tt>ntpdate</tt> on a regular basis from <tt>cron</tt> as an alternative to running a daemon, doing so once every hour or two will result in precise enough timekeeping to avoid stepping the clock.</p>
+@@ -33,9 +33,9 @@
+                       <dt><tt>-6</tt>
+                       <dd>Force DNS resolution of following host names on the command line to the IPv6 namespace.
+                       <dt><tt>-a <i>key</i></tt>
+-                      <dd>Enable the authentication function and specify the key identifier to be used for authentication as the argument <i>key</i><tt>ntpdate</tt>. The keys and key identifiers must match in both the client and server key files. The default is to disable the authentication function.
++                      <dd>Enable the authentication function and specify the key identifier to be used for authentication as the argument <i>key</i>. The keys and key identifiers must match in both the client and server key files. The default is to disable the authentication function.
+                       <dt><tt>-B</tt>
+-                      <dd>Force the time to always be slewed using the adjtime() system call, even if the measured offset is greater than +-128 ms. The default is to step the time using settimeofday() if the offset is greater than +-128 ms. Note that, if the offset is much greater than +-128 ms in this case, that it can take a long time (hours) to slew the clock to the correct value. During this time. the host should not be used to synchronize clients.
++                      <dd>Force the time to always be slewed using the adjtime() system call, even if the measured offset is greater than +-500 ms. The default is to step the time using settimeofday() if the offset is greater than +-500 ms. Note that, if the offset is much greater than +-500 ms in this case, that it can take a long time (hours) to slew the clock to the correct value. During this time. the host should not be used to synchronize clients.
+                       <dt><tt>-b</tt>
+                       <dd>Force the time to be stepped using the settimeofday() system call, rather than slewed (default) using the adjtime() system call. This option should be used when called from a startup file at boot time.
+                       <dt><tt>-d</tt>
+@@ -43,9 +43,9 @@
+                       <dt><tt>-e <i>authdelay</i></tt>
+                       <dd>Specify the processing delay to perform an authentication function as the value <i>authdelay</i>, in seconds and fraction (see <tt>ntpd</tt> for details). This number is usually small enough to be negligible for most purposes, though specifying a value may improve timekeeping on very slow CPU's.
+                       <dt><tt>-k <i>keyfile</i></tt>
+-                      <dd>Specify the path for the authentication key file as the string <i>keyfile</i>. The default is <tt>/etc/ntp.keys</tt>. This file should be in the format described in <tt>ntpd</tt>.
++                      <dd>Specify the path for the authentication key file as the string <i>keyfile</i>. The default is <tt>/etc/ntp/keys</tt>. This file should be in the format described in <tt>ntpd</tt>.
+                       <dt><tt>-o <i>version</i></tt>
+-                      <dd>Specify the NTP version for outgoing packets as the integer <i>version</i>, which can be 1 or 2. The default is 3. This allows <tt>ntpdate</tt> to be used with older NTP versions.
++                      <dd>Specify the NTP version for outgoing packets as the integer <i>version</i>, which can be 1 or 2. The default is 4. This allows <tt>ntpdate</tt> to be used with older NTP versions.
+                       <dt><tt>-p <i>samples</i></tt>
+                       <dd>Specify the number of samples to be acquired from each server as the integer <i>samples</i>, with values from 1 to 8 inclusive. The default is 4.
+                       <dt><i><tt>-q</tt></i>
+@@ -55,7 +55,7 @@
+                       <dt><tt>-t <i>timeout</i></tt>
+                       <dd>Specify the maximum time waiting for a server response as the value <i>timeout</i>, in seconds and fraction. The value is is rounded to a multiple of 0.2 seconds. The default is 1 second, a value suitable for polling across a LAN.
+                       <dt><tt>-u</tt>
+-                      <dd>Direct <tt>ntpdate</tt> to use an unprivileged port or outgoing packets. This is most useful when behind a firewall that blocks incoming traffic to privileged ports, and you want to synchronise with hosts beyond the firewall. Note that the <tt>-d</tt> option always uses unprivileged ports.
++                      <dd>Direct <tt>ntpdate</tt> to use an unprivileged port for outgoing packets. This is most useful when behind a firewall that blocks incoming traffic to privileged ports, and you want to synchronize with hosts beyond the firewall. Note that the <tt>-d</tt> option always uses unprivileged ports.
+                       <dt><tt>-<i>v</i></tt>
+                       <dd>Be verbose. This option will cause <tt>ntpdate</tt>'s version identification string to be logged.
+@@ -67,7 +67,7 @@
+               <h4>Diagnostics</h4>
+               <tt>ntpdate</tt>'s exit status is zero if it finds a server and updates the clock, and nonzero otherwise.
+               <h4>Files</h4>
+-              <tt>/etc/ntp.keys</tt> - encryption keys used by <tt>ntpdate</tt>.
++              <tt>/etc/ntp/keys</tt> - encryption keys used by <tt>ntpdate</tt>.
+               <h4>Bugs</h4>
+               The slew adjustment is actually 50% larger than the measured offset, since this (it is argued) will tend to keep a badly drifting clock more accurate. This is probably not a good idea and may cause a troubling hunt for some values of the kernel variables <tt>tick</tt> and <tt>tickadj</tt>.&nbsp;
+               <hr>
+diff -up ntp-4.2.4p5/html/ntpdc.html.htmldoc ntp-4.2.4p5/html/ntpdc.html
+--- ntp-4.2.4p5/html/ntpdc.html.htmldoc        2008-08-10 13:02:44.000000000 +0200
++++ ntp-4.2.4p5/html/ntpdc.html        2008-08-18 12:38:13.000000000 +0200
+@@ -19,9 +19,9 @@
+               <script type="text/javascript" language="javascript" src="scripts/links12.txt"></script>
+               <hr>
+               <h4>Synopsis</h4>
+-              <tt>ntpdc [ -ilnps ] [ -c <i>command</i> ] [ <i>host</i> ] [ ... ]</tt>
++              <tt>ntpdc [ -46dilnps ] [ -c <i>command</i> ] [ <i>host</i> ] [ ... ]</tt>
+               <h4>Description</h4>
+-              <tt>ntpdc</tt> is used to query the <tt>ntpd</tt> daemon about its current state and to request changes in that state. The program may be run either in interactive mode or controlled using command line arguments. Extensive state and statistics information is available through the <tt>ntpdc</tt> interface. In addition, nearly all the configuration options which can be specified at startup using ntpd's configuration file may also be specified at run time using <tt>ntpdc</tt>.
++              <p><tt>ntpdc</tt> is used to query the <tt>ntpd</tt> daemon about its current state and to request changes in that state. The program may be run either in interactive mode or controlled using command line arguments. Extensive state and statistics information is available through the <tt>ntpdc</tt> interface. In addition, nearly all the configuration options which can be specified at startup using ntpd's configuration file may also be specified at run time using <tt>ntpdc</tt>.</p>
+               <p>If one or more request options are included on the command line when <tt>ntpdc</tt> is executed, each of the requests will be sent to the NTP servers running on each of the hosts given as command line arguments, or on localhost by default. If no request options are given, <tt>ntpdc</tt> will attempt to read commands from the standard input and execute these on the NTP server running on the first host given on the command line, again defaulting to localhost when no other host is specified. <tt>ntpdc</tt> will prompt for commands if the standard input is a terminal device.</p>
+               <p><tt>ntpdc</tt> uses NTP mode 7 packets to communicate with the NTP server, and hence can be used to query any compatible server on the network which permits it. Note that since NTP is a UDP protocol this communication will be somewhat unreliable, especially over large distances in terms of network topology. <tt>ntpdc</tt> makes no attempt to retransmit requests, and will time requests out if the remote host is not heard from within a suitable timeout time.</p>
+               <p>The operation of <tt>ntpdc</tt> are specific to the particular implementation of the <tt>ntpd</tt> daemon and can be expected to work only with this and maybe some previous versions of the daemon. Requests from a remote <tt>ntpdc</tt> program which affect the state of the local server must be authenticated, which requires both the remote program and local server share a common key and key identifier.</p>
+@@ -35,6 +35,8 @@
+                       <dd>Force DNS resolution of following host names on the command line to the IPv6 namespace.
+                       <dt><tt>-c <i>command</i></tt>
+                       <dd>The following argument is interpreted as an interactive format command and is added to the list of commands to be executed on the specified host(s). Multiple -c options may be given.
++                      <dt><tt>-d</tt>
++                      <dd>Turn on debugging mode.
+                       <dt><tt>-i</tt>
+                       <dd>Force <tt>ntpdc</tt> to operate in interactive mode. Prompts will be written to the standard output and commands read from the standard input.
+                       <dt><tt>-l</tt>
+@@ -134,11 +136,11 @@
+               <dt><tt>addpeer <i>peer_address</i> [
+               <i>keyid</i> ] [ <i>version</i> ] [
+               <tt>minpoll# | prefer | iburst  | burst | minpoll
+-              <i>N</i> | <tt>maxpoll</tt> <i>N</i> [...] ]</tt>
++              <i>N</i> | <tt>maxpoll</tt> <i>N</i> [...] </tt> ]</tt>
+               <dt><tt>addpeer <i>peer_address</i> [
+               <tt>prefer | iburst | burst | minpoll
+               <i>N</i> | <tt>maxpoll</tt> <i>N</i> | <tt>keyid</tt>
+-                      <i>N</i> | <tt>version</tt> <i>N</i> [...] ]</tt>
++                      <i>N</i> | <tt>version</tt> <i>N</i> [...] </tt> ]</tt>
+                       <dd>Add a configured peer association at the
+                       given address and operating in symmetric
+                       active mode. Note that an existing association
+@@ -162,15 +164,15 @@
+                       <tt>peer</tt> configuration file command of
+                       ntpd.  See the <a href="confopt.html">Server Options</a> page for further information.
+                       Each flag (or its absence) replaces the
+-                      previous setting. The <tt>prefer</tt> keyword indicates a preferred peer (and thus will be used primarily for clock synchronisation if possible). The preferred peer also determines the validity of the PPS signal - if the preferred peer is suitable for synchronisation so is the PPS signal.
++                      previous setting. The <tt>prefer</tt> keyword indicates a preferred peer (and thus will be used primarily for clock synchronization if possible). The preferred peer also determines the validity of the PPS signal - if the preferred peer is suitable for synchronization so is the PPS signal.
+                       <dt><tt>addserver <i>peer_address</i> [
+               <i>keyid</i> ] [ <i>version</i> ] [
+               <tt>minpoll# | prefer | iburst  | burst | minpoll
+-              <i>N</i> | <tt>maxpoll</tt> <i>N</i> [...] ]</tt>
++              <i>N</i> | <tt>maxpoll</tt> <i>N</i> [...] </tt> ]</tt>
+               <dt><tt>addserver <i>peer_address</i> [
+               <tt>prefer | iburst | burst | minpoll
+               <i>N</i> | <tt>maxpoll</tt> <i>N</i> | <tt>keyid</tt>
+-                      <i>N</i> | <tt>version</tt> <i>N</i> [...] ]</tt>
++                      <i>N</i> | <tt>version</tt> <i>N</i> [...] </tt> ]</tt>
+                       <dd>Identical to the addpeer command, except that the operating mode is client.
+                       <dt><tt>broadcast <i>peer_address</i> [
+                       <i>keyid</i> ] [ <i>version</i> ] [ <i>prefer</i> ]</tt>
+@@ -199,9 +201,9 @@
+                       <dd>Returns information concerning the authentication module, including known keys and counts of encryptions and decryptions which have been done.
+                       <dt><tt>traps</tt>
+                       <dd>Display the traps set in the server. See the source listing for further information.
+-                      <dt><tt>addtrap [ <i>address</i> [ <i>port</i> ] [ <i>interface</i> ]</tt>
++                      <dt><tt>addtrap [ <i>address</i> ] [ <i>port</i> ] [ <i>interface</i> ]</tt>
+                       <dd>Set a trap for asynchronous messages. See the source listing for further information.
+-                      <dt><tt>clrtrap [ <i>address</i> [ <i>port</i> ] [ <i>interface</i>]</tt>
++                      <dt><tt>clrtrap [ <i>address</i> ] [ <i>port</i> ] [ <i>interface</i>]</tt>
+                       <dd>Clear a trap for asynchronous messages. See the source listing for further information.
+                       <dt><tt>reset</tt>
+                       <dd>Clear the statistics counters in various modules of the server. See the source listing for further information.
+diff -up ntp-4.2.4p5/html/ntpq.html.htmldoc ntp-4.2.4p5/html/ntpq.html
+--- ntp-4.2.4p5/html/ntpq.html.htmldoc 2006-06-06 22:16:06.000000000 +0200
++++ ntp-4.2.4p5/html/ntpq.html 2008-08-18 12:31:59.000000000 +0200
+@@ -19,11 +19,11 @@
+               <script type="text/javascript" language="javascript" src="scripts/links12.txt"></script>
+               <hr>
+               <h4>Synopsis</h4>
+-              <tt>ntpq [-inp] [-c <i>command</i>] [<i>host</i>] [...]</tt>
++              <tt>ntpq [-46dinp] [-c <i>command</i>] [<i>host</i>] [...]</tt>
+               <h4>Description</h4>
+               <p>The <tt>ntpq</tt> utility program is used to monitor NTP daemon <tt>ntpd</tt> operations and determine performance. It uses the standard NTP mode 6 control message formats defined in Appendix B of the NTPv3 specification RFC1305. The same formats are used in NTPv4, although some of the variables have changed and new ones added. The description on this page is for the NTPv4 variables.</p>
+               <p>The program can be run either in interactive mode or controlled using command line arguments. Requests to read and write arbitrary variables can be assembled, with raw and pretty-printed output options being available. The <tt>ntpq</tt> can also obtain and print a list of peers in a common format by sending multiple queries to the server.</p>
+-              <p>If one or more request options is included on the command line when <tt>ntpq</tt> is executed, each of the requests will be sent to the NTP servers running on each of the hosts given as command line arguments, or on localhost by default. If no request options are given, <tt>ntpq</tt> will attempt to read commands from the standard input and execute these on the NTP server running on the first host given on the command line, again defaulting to localhost when no other host is specified. <tt>ntpq</tt>will prompt for commands if the standard input is a terminal device.</p>
++              <p>If one or more request options is included on the command line when <tt>ntpq</tt> is executed, each of the requests will be sent to the NTP servers running on each of the hosts given as command line arguments, or on localhost by default. If no request options are given, <tt>ntpq</tt> will attempt to read commands from the standard input and execute these on the NTP server running on the first host given on the command line, again defaulting to localhost when no other host is specified. <tt>ntpq</tt> will prompt for commands if the standard input is a terminal device.</p>
+               <p><tt>ntpq</tt> uses NTP mode 6 packets to communicate with the NTP server, and hence can be used to query any compatible server on the network which permits it. Note that since NTP is a UDP protocol this communication will be somewhat unreliable, especially over large distances in terms of network topology. <tt>ntpq</tt> makes one attempt to retransmit requests, and will time requests out if the remote host is not heard from within a suitable timeout time.</p>
+               <p>Note that in contexts where a host name is expected, a <tt>-4</tt> qualifier preceding the host name forces DNS resolution to the IPv4 namespace, while a <tt>-6</tt> qualifier forces DNS resolution to the IPv6 namespace.</p>
+               <p>For examples and usage, see the <a href="debug.html">NTP Debugging Techniques</a> page.</p>
+@@ -73,7 +73,7 @@
+                       <dt><tt>quit</tt>
+                       <dd>Exit <tt>ntpq</tt>.
+                       <dt><tt>raw</tt>
+-                      <dd>Causes all output from query commands is printed as received from the remote server. The only formating/interpretation done on the data is to transform nonascii data into a printable (but barely understandable) form.
++                      <dd>Causes all output from query commands is printed as received from the remote server. The only formatting/interpretation done on the data is to transform non-ASCII data into a printable (but barely understandable) form.
+                       <dt><tt>timeout <i>millseconds</i></tt>
+                       <dd>Specify a timeout period for responses to server queries. The default is about 5000 milliseconds. Note that since <tt>ntpq</tt> retries each query once after a timeout, the total waiting time for a timeout will be twice the timeout value set.
+               </dl>
+@@ -135,7 +135,7 @@
+                       <dt><tt>*&nbsp;&nbsp;sys.peer</tt>
+                       <dd>The peer has been declared the system peer and lends its variables to the system variables.
+                       <dt><tt>o&nbsp;&nbsp;pps.peer</tt>
+-                      <dd>The peer has been declared the system peer and lends its variables to thesystem variables. However, the actual system synchronization is derived from a pulse-per-second (PPS) signal, either indirectly via the PPS reference clock driver or directly via kernel interface.
++                      <dd>The peer has been declared the system peer and lends its variables to the system variables. However, the actual system synchronization is derived from a pulse-per-second (PPS) signal, either indirectly via the PPS reference clock driver or directly via kernel interface.
+               </dl>
+               <h4>System Variables</h4>
+               <p>The <tt>status, leap, stratum, precision, rootdelay, rootdispersion, refid, reftime, poll, offset, and frequency</tt> variables are described in RFC-1305 specification. Additional NTPv4 system variables include the following.</p>
+@@ -240,14 +240,14 @@
+                       <dd>Access is denied. See the <a href="accopt.html">Access Control Options</a> page.
+                       <dt><tt>0x010 TEST5</tt>
+                       <dd>Cryptographic authentication fails. See the <a href="authopt.html">Authentication Options</a> page.
+-                      <dt><tt>0x020TEST6</tt>
++                      <dt><tt>0x020 TEST6</tt>
+                       <dd>The server is unsynchronized. Wind up its clock first.
+                       <dt><tt>0x040 TEST7</tt>
+                       <dd>The server stratum is at the maximum than 15. It is probably unsynchronized and its clock needs to be wound up.
+                       <dt><tt>0x080 TEST8</tt>
+                       <dd>Either the root delay or dispersion is greater than one second, which is highly unlikely unless the peer is unsynchronized to Mars.
+                       <dt><tt>0x100 TEST9</tt>
+-                      <dd>Either the peer delay or dispersion is greater than one second, which is higly unlikely unless the peer is on Mars.
++                      <dd>Either the peer delay or dispersion is greater than one second, which is highly unlikely unless the peer is on Mars.
+                       <dt><tt>0x200 TEST10</tt>
+                       <dd>The autokey protocol has detected an authentication failure. See the <a href="authopt.html">Authentication Options</a> page.
+                       <dt><tt>0x400 TEST11</tt>
+diff -up ntp-4.2.4p5/html/ntptrace.html.htmldoc ntp-4.2.4p5/html/ntptrace.html
+--- ntp-4.2.4p5/html/ntptrace.html.htmldoc     2006-06-06 22:16:06.000000000 +0200
++++ ntp-4.2.4p5/html/ntptrace.html     2008-08-18 12:31:59.000000000 +0200
+@@ -17,7 +17,7 @@
+               <br clear="left">
+               <hr>
+               <h4>Synopsis</h4>
+-              <tt>ntptrace [ -vdn ] [ -r <i>retries</i> ] [ -t <i>timeout</i> ] [ <i>server</i> ]</tt>
++              <tt>ntptrace [ -n ] [ -m <i>maxhosts</i> ] [ <i>server</i> ]</tt>
+               <h4>Description</h4>
+               <p><tt>ntptrace</tt> determines where a given Network Time Protocol (NTP) server gets its time from, and follows the chain of NTP servers back to their master time source. If given no arguments, it starts with <tt>localhost</tt>. Here is an example of the output from <tt>ntptrace</tt>:</p>
+               <pre>
+@@ -29,16 +29,8 @@ usndh.edu: stratum 1, offset 0.0019298, 
+               <p>On each line, the fields are (left to right): the host name, the host stratum, the time offset between that host and the local host (as measured by <tt>ntptrace</tt>; this is why it is not always zero for &quot;<tt>localhost</tt>&quot;), the host synchronization distance, and (only for stratum-1 servers) the reference clock ID. All times are given in seconds. Note that the stratum is the server hop count to the primary source, while the synchronization distance is the estimated error relative to the primary source. These terms are precisely defined in RFC-1305.</p>
+               <h4>Options</h4>
+               <dl>
+-                      <dt><tt>-d</tt>
+-                      <dd>Turns on some debugging output.
+                       <dt><tt>-n</tt>
+                       <dd>Turns off the printing of host names; instead, host IP addresses are given. This may be useful if a nameserver is down.
+-                      <dt><tt>-r <i>retries</i></tt>
+-                      <dd>Sets the number of retransmission attempts for each host (default = 5).
+-                      <dt><tt>-t <i>timeout</i></tt>
+-                      <dd>Sets the retransmission timeout (in seconds) (default = 2).
+-                      <dt><tt>-v</tt>
+-                      <dd>Prints verbose information about the NTP servers.
+               </dl>
+               <h4>Bugs</h4>
+               <p>This program makes no attempt to improve accuracy by doing multiple samples.</p>
diff --git a/packaging/ntp-4.2.4p5-rtnetlink.patch b/packaging/ntp-4.2.4p5-rtnetlink.patch
new file mode 100644 (file)
index 0000000..d281794
--- /dev/null
@@ -0,0 +1,116 @@
+diff -up ntp-4.2.4p5/ntpd/ntp_io.c.rtnetlink ntp-4.2.4p5/ntpd/ntp_io.c
+--- ntp-4.2.4p5/ntpd/ntp_io.c.rtnetlink        2008-08-28 16:02:21.000000000 +0200
++++ ntp-4.2.4p5/ntpd/ntp_io.c  2008-08-28 16:03:58.000000000 +0200
+@@ -216,6 +216,9 @@ struct vsock {
+       ISC_LINK(vsock_t)               link;
+ };
++#define HAS_ROUTING_SOCKET 1
++#define HAVE_RTNETLINK 1
++
+ #if !defined(HAVE_IO_COMPLETION_PORT) && defined(HAS_ROUTING_SOCKET)
+ /*
+  * async notification processing (e. g. routing sockets)
+@@ -3858,6 +3861,10 @@ find_flagged_addr_in_list(struct sockadd
+ #ifdef HAS_ROUTING_SOCKET
+ #include <net/route.h>
++#ifdef HAVE_RTNETLINK
++#include <linux/rtnetlink.h>
++#endif
++
+ #ifndef UPDATE_GRACE
+ #define UPDATE_GRACE  2       /* wait UPDATE_GRACE seconds before scanning */
+ #endif
+@@ -3866,9 +3873,12 @@ static void
+ process_routing_msgs(struct asyncio_reader *reader)
+ {
+       char buffer[5120];
+-      char *p = buffer;
+-
+-      int cnt;
++      int cnt, msg_type;
++#ifdef HAVE_RTNETLINK
++      struct nlmsghdr *nh;
++#else
++      char *p;
++#endif
+       
+       if (disable_dynamic_updates) {
+               /*
+@@ -3892,8 +3902,11 @@ process_routing_msgs(struct asyncio_read
+       /*
+        * process routing message
+        */
+-      while ((p + sizeof(struct rt_msghdr)) <= (buffer + cnt))
+-      {
++#ifdef HAVE_RTNETLINK
++      for (nh = (struct nlmsghdr *)buffer; NLMSG_OK(nh, cnt); nh = NLMSG_NEXT(nh, cnt)) {
++              msg_type = nh->nlmsg_type;
++#else
++      for (p = buffer; (p + sizeof(struct rt_msghdr)) <= (buffer + cnt); p += rtm->rtm_msglen) {
+               struct rt_msghdr *rtm;
+               
+               rtm = (struct rt_msghdr *)p;
+@@ -3903,8 +3916,9 @@ process_routing_msgs(struct asyncio_read
+                       delete_asyncio_reader(reader);
+                       return;
+               }
+-              
+-              switch (rtm->rtm_type) {
++              msg_type = rtm->rtm_type;
++#endif
++              switch (msg_type) {
+ #ifdef RTM_NEWADDR
+               case RTM_NEWADDR:
+ #endif
+@@ -3935,17 +3949,21 @@ process_routing_msgs(struct asyncio_read
+                       /*
+                        * we are keen on new and deleted addresses and if an interface goes up and down or routing changes
+                        */
+-                      DPRINTF(3, ("routing message op = %d: scheduling interface update\n", rtm->rtm_type));
++                      DPRINTF(3, ("routing message op = %d: scheduling interface update\n", msg_type));
+                       timer_interfacetimeout(current_time + UPDATE_GRACE);
+                       break;
++#ifdef HAVE_RTNETLINK
++              case NLMSG_DONE:
++                      /* end of multipart message */
++                      return;
++#endif
+               default:
+                       /*
+                        * the rest doesn't bother us.
+                        */
+-                      DPRINTF(4, ("routing message op = %d: ignored\n", rtm->rtm_type));
++                      DPRINTF(4, ("routing message op = %d: ignored\n", msg_type));
+                       break;
+               }
+-              p += rtm->rtm_msglen;
+       }
+ }
+@@ -3956,10 +3974,24 @@ static void
+ init_async_notifications()
+ {
+       struct asyncio_reader *reader;
++#ifdef HAVE_RTNETLINK
++      int fd = socket(PF_NETLINK, SOCK_RAW, NETLINK_ROUTE);
++      struct sockaddr_nl sa;
++#else
+       int fd = socket(PF_ROUTE, SOCK_RAW, 0);
++#endif
+       
+       if (fd >= 0) {
+               fd = move_fd(fd);
++#ifdef HAVE_RTNETLINK
++              memset(&sa, 0, sizeof(sa));
++              sa.nl_family = PF_NETLINK;
++              sa.nl_groups = RTMGRP_IPV4_IFADDR | RTMGRP_IPV6_IFADDR;
++              if (bind(fd, (struct sockaddr*)&sa, sizeof(sa)) < 0) {
++                      msyslog(LOG_ERR, "bind failed on routing socket (%m) - using polled interface update");
++                      return;
++              }
++#endif
+               init_nonblocking_io(fd);
+ #if defined(HAVE_SIGNALED_IO)
+               init_socket_sig(fd);
diff --git a/packaging/ntp-4.2.4p7-bcast.patch b/packaging/ntp-4.2.4p7-bcast.patch
new file mode 100644 (file)
index 0000000..50d5dc2
--- /dev/null
@@ -0,0 +1,114 @@
+diff -up ntp-4.2.4p7/ntpd/ntp_io.c.bcast ntp-4.2.4p7/ntpd/ntp_io.c
+--- ntp-4.2.4p7/ntpd/ntp_io.c.bcast    2009-05-18 16:53:05.000000000 +0200
++++ ntp-4.2.4p7/ntpd/ntp_io.c  2009-05-18 16:54:19.000000000 +0200
+@@ -150,6 +150,8 @@ int ninterfaces;                   /* Total number of in
+ volatile int disable_dynamic_updates;   /* when set to != 0 dynamic updates won't happen */
++static int pktinfo_status = 0;                /* is IP_PKTINFO on wildipv4 iface enabled? */
++
+ #ifdef REFCLOCK
+ /*
+  * Refclock stuff.    We keep a chain of structures with data concerning
+@@ -1611,6 +1613,18 @@ set_reuseaddr(int flag) {
+ #endif /* ! SO_EXCLUSIVEADDRUSE */
+ }
++static void
++set_pktinfo(int flag)
++{
++      if (wildipv4 == NULL)
++              return;
++      if (setsockopt(wildipv4->fd, SOL_IP, IP_PKTINFO, &flag, sizeof (flag))) {
++              if (debug > 1)
++                      printf("setsockopt(IP_PKTINFO) failed: %s\n", strerror(errno));
++      } else
++              pktinfo_status = flag;
++}
++
+ /*
+  * This is just a wrapper around an internal function so we can
+  * make other changes as necessary later on
+@@ -2027,6 +2041,7 @@ io_setbclient(void)
+ #else
+       netsyslog(LOG_ERR, "io_setbclient: Broadcast Client disabled by build");
+ #endif
++      set_pktinfo(1);
+ }
+ /*
+@@ -2049,6 +2064,7 @@ io_unsetbclient(void)
+                   continue;
+               lstatus = socket_broadcast_disable(interf, &interf->sin);
+       }
++      set_pktinfo(0);
+ }
+ /*
+@@ -2957,7 +2973,8 @@ read_network_packet(SOCKET fd, struct in
+ #ifdef HAVE_TIMESTAMP
+       struct msghdr msghdr;
+       struct iovec iovec;
+-      char control[TIMESTAMP_CTLMSGBUF_SIZE]; /* pick up control messages */
++      char control[sizeof (struct cmsghdr) * 2 + sizeof (struct timeval) +
++              sizeof (struct in_pktinfo) + 32];       /* pick up control messages */
+ #endif
+       /*
+@@ -2969,7 +2986,7 @@ read_network_packet(SOCKET fd, struct in
+       rb = get_free_recv_buffer();
+-      if (rb == NULL || itf->ignore_packets == ISC_TRUE)
++      if (rb == NULL || (itf->ignore_packets == ISC_TRUE && !(pktinfo_status && itf == wildipv4)))
+       {
+               char buf[RX_BUFF_SIZE];
+               struct sockaddr_storage from;
+@@ -3031,6 +3048,34 @@ read_network_packet(SOCKET fd, struct in
+               return (buflen);
+       }
++      if (pktinfo_status && itf->ignore_packets == ISC_TRUE && itf == wildipv4) {
++              /* check for broadcast on 255.255.255.255, exception allowed on wildipv4 */
++              struct cmsghdr *cmsg;
++              struct in_pktinfo *pktinfo = NULL;
++
++              if ((cmsg = CMSG_FIRSTHDR(&msghdr)))
++                      do {
++                              if (cmsg->cmsg_level == SOL_IP && cmsg->cmsg_type == IP_PKTINFO)
++                                      pktinfo = (struct in_pktinfo *) CMSG_DATA(cmsg);
++                      } while ((cmsg = CMSG_NXTHDR(&msghdr, cmsg)));
++              if (pktinfo && pktinfo->ipi_addr.s_addr == INADDR_BROADCAST) {
++#ifdef DEBUG
++                      if (debug > 3) {
++                              printf("INADDR_BROADCAST\n");
++                      }
++#endif
++              } else {
++#ifdef DEBUG
++                      if (debug > 3)
++                              printf("%s on (%lu) fd=%d from %s\n", "ignore",
++                                              free_recvbuffs(), fd, stoa(&rb->recv_srcadr));
++#endif
++                      packets_ignored++;
++                      freerecvbuf(rb);
++                      return (buflen);
++              }
++      }
++
+ #ifdef DEBUG
+       if (debug > 2) {
+               if(rb->recv_srcadr.ss_family == AF_INET)
+diff -up ntp-4.2.4p7/ntpd/ntp_peer.c.bcast ntp-4.2.4p7/ntpd/ntp_peer.c
+--- ntp-4.2.4p7/ntpd/ntp_peer.c.bcast  2008-08-10 13:02:40.000000000 +0200
++++ ntp-4.2.4p7/ntpd/ntp_peer.c        2009-05-18 16:53:05.000000000 +0200
+@@ -709,7 +709,8 @@ select_peerinterface(struct peer *peer, 
+        * as our (network) source address would be undefined and
+        * crypto will not work without knowing the own transmit address
+        */
+-      if (interface != NULL && interface->flags & INT_WILDCARD)
++      if (interface != NULL && interface->flags & INT_WILDCARD &&
++                      !(cast_flags & MDF_BCAST))
+ #ifdef SYS_WINNT
+               if ( !accept_wildcard_if_for_winnt )  
+ #endif
diff --git a/packaging/ntp-4.2.4p7-daemonpll.patch b/packaging/ntp-4.2.4p7-daemonpll.patch
new file mode 100644 (file)
index 0000000..013346a
--- /dev/null
@@ -0,0 +1,33 @@
+diff -up ntp-4.2.4p7/ntpd/ntp_loopfilter.c.daemonpll ntp-4.2.4p7/ntpd/ntp_loopfilter.c
+--- ntp-4.2.4p7/ntpd/ntp_loopfilter.c.daemonpll        2009-05-18 18:13:31.000000000 +0200
++++ ntp-4.2.4p7/ntpd/ntp_loopfilter.c  2009-05-18 18:18:13.000000000 +0200
+@@ -489,10 +489,9 @@ local_clock(
+                       /*
+                        * For the PLL the integration interval
+                        * (numerator) is the minimum of the update
+-                       * interval and poll interval. This allows
+-                       * oversampling, but not undersampling.
++                       * interval and Allan intercept.
+                        */ 
+-                      etemp = min(mu, (u_long)ULOGTOD(sys_poll));
++                      etemp = min(mu, allan_xpt);
+                       dtemp = 4 * CLOCK_PLL * ULOGTOD(sys_poll);
+                       plladj = fp_offset * etemp / (dtemp * dtemp);
+                       rstclock(S_SYNC, peer->epoch, fp_offset);
+@@ -801,13 +805,10 @@ adj_host_clock(
+       /*
+        * Implement the phase and frequency adjustments. The gain
+-       * factor (denominator) is not allowed to increase beyond the
+-       * Allan intercept. It doesn't make sense to average phase noise
+-       * beyond this point and it helps to damp residual offset at the
+-       * longer poll intervals.
++       * factor (denominator) increases with poll interval, so is
++       * dominated by the FLL above the Allan intercept.
+        */
+-      adjustment = clock_offset / (CLOCK_PLL * min(ULOGTOD(sys_poll),
+-          allan_xpt));
++      adjustment = clock_offset / (CLOCK_PLL * ULOGTOD(sys_poll));
+       clock_offset -= adjustment;
+       adj_systime(adjustment + drift_comp);
+ #endif /* LOCKCLOCK */
diff --git a/packaging/ntp-4.2.4p7-freqmode.patch b/packaging/ntp-4.2.4p7-freqmode.patch
new file mode 100644 (file)
index 0000000..9a809bd
--- /dev/null
@@ -0,0 +1,97 @@
+diff -up ntp-4.2.4p7/ntpd/ntp_loopfilter.c.freqmode ntp-4.2.4p7/ntpd/ntp_loopfilter.c
+--- ntp-4.2.4p7/ntpd/ntp_loopfilter.c.freqmode 2009-05-28 15:19:30.000000000 +0200
++++ ntp-4.2.4p7/ntpd/ntp_loopfilter.c  2009-05-28 17:21:30.000000000 +0200
+@@ -133,6 +133,7 @@ u_long     sys_clocktime;          /* last system cl
+ u_long        pps_control;            /* last pps update */
+ u_long        sys_tai;                /* UTC offset from TAI (s) */
+ static void rstclock P((int, u_long, double)); /* transition function */
++static double direct_freq(double, u_long); /* calculate frequency directly */
+ #ifdef KERNEL_PLL
+ struct timex ntv;             /* kernel API parameters */
+@@ -359,8 +360,7 @@ local_clock(
+                       if (mu < clock_minstep)
+                               return (0);
+-                      clock_frequency = (fp_offset - clock_offset) /
+-                          mu;
++                      clock_frequency = direct_freq(fp_offset, mu);
+                       /* fall through to S_SPIK */
+@@ -451,16 +451,16 @@ local_clock(
+               /*
+                * In S_FREQ state ignore updates until the stepout
+-               * threshold. After that, correct the phase and
+-               * frequency and switch to S_SYNC state.
++               * threshold. After that, compute the new frequency, but
++               * do not adjust the phase or frequency until the next
++               * update.
+                */
+               case S_FREQ:
+                       if (mu < clock_minstep)
+                               return (0);
+-                      clock_frequency = (fp_offset - clock_offset) /
+-                          mu;
+-                      rstclock(S_SYNC, peer->epoch, fp_offset);
++                      clock_frequency = direct_freq(fp_offset, mu);
++                      rstclock(S_SYNC, peer->epoch, 0);
+                       break;
+               /*
+@@ -590,8 +590,7 @@ local_clock(
+                        */
+                       if (clock_frequency != 0) {
+                               ntv.modes |= MOD_FREQUENCY;
+-                              ntv.freq = (int32)((clock_frequency +
+-                                  drift_comp) * 65536e6);
++                              ntv.freq = (int32)(clock_frequency * 65536e6);
+                       }
+                       ntv.esterror = (u_int32)(clock_jitter * 1e6);
+                       ntv.maxerror = (u_int32)((sys_rootdelay / 2 +
+@@ -837,6 +836,43 @@ rstclock(
+       last_offset = clock_offset = offset;
+ }
++/*
++ * calc_freq - calculate frequency directly
++ *
++ * This is very carefully done. When the offset is first computed at the
++ * first update, a residual frequency component results. Subsequently,
++ * updates are suppresed until the end of the measurement interval while
++ * the offset is amortized. At the end of the interval the frequency is
++ * calculated from the current offset, residual offset, length of the
++ * interval and residual frequency component. At the same time the
++ * frequenchy file is armed for update at the next hourly stats.
++ */
++static double
++direct_freq(
++      double  fp_offset,
++      u_long mu
++      )
++{
++
++#ifdef KERNEL_PLL
++      /*
++       * If the kernel is enabled, we need the residual offset to
++       * calculate the frequency correction.
++       */
++      if (pll_control && kern_enable) {
++              memset(&ntv,  0, sizeof(ntv));
++              ntp_adjtime(&ntv);
++#ifdef STA_NANO
++              clock_offset = ntv.offset / 1e9;
++#else /* STA_NANO */
++              clock_offset = ntv.offset / 1e6;
++#endif /* STA_NANO */
++              drift_comp = ntv.freq / 65536e6;
++      }
++#endif /* KERNEL_PLL */
++      return (fp_offset - clock_offset) / mu + drift_comp;
++}
++
+ int huffpuff_enabled()
+ {
diff --git a/packaging/ntp-4.2.4p7-ipv6.patch b/packaging/ntp-4.2.4p7-ipv6.patch
new file mode 100644 (file)
index 0000000..dccc97a
--- /dev/null
@@ -0,0 +1,23 @@
+diff -up ntp-4.2.4p7/configure.ipv6 ntp-4.2.4p7/configure
+--- ntp-4.2.4p7/configure.ipv6 2009-05-18 17:18:31.000000000 +0200
++++ ntp-4.2.4p7/configure      2009-05-18 17:22:37.000000000 +0200
+@@ -46206,15 +46206,19 @@ cat confdefs.h >>conftest.$ac_ext
+ cat >>conftest.$ac_ext <<_ACEOF
+ /* end confdefs.h.  */
++#define _GNU_SOURCE
+                           #include <sys/types.h>
+                           #include <sys/socket.h>
+                           #include <netinet/in.h>
++;
+                           $isc_netinetin6_hack
+                           $isc_netinet6in6_hack
++;
+ int
+ main ()
+ {
++;
+                           struct in6_pktinfo xyzzy;
diff --git a/packaging/ntp-4.2.4p7-minpoll.patch b/packaging/ntp-4.2.4p7-minpoll.patch
new file mode 100644 (file)
index 0000000..7421930
--- /dev/null
@@ -0,0 +1,36 @@
+diff -up ntp-4.2.4p7/html/confopt.html.minpoll ntp-4.2.4p7/html/confopt.html
+--- ntp-4.2.4p7/html/confopt.html.minpoll      2009-05-19 14:23:01.000000000 +0200
++++ ntp-4.2.4p7/html/confopt.html      2009-05-19 14:27:27.000000000 +0200
+@@ -56,7 +56,7 @@
+                       <dd>When the server is unreachable, send a burst of eight packets instead of the usual one. The packet spacing is normally 2 s; however, the spacing between the first and second packets can be changed with the <a href="miscopt.html"><tt>calldelay</tt></a> command to allow additional time for a modem or ISDN call to complete. This option is valid with only the <tt>server</tt> command and is a recommended option with this command.<dt><tt>key</tt> <i><tt>key</tt></i>
+                       <dd>All packets sent to and received from the server or peer are to include authentication fields encrypted using the specified <i><tt>key</tt></i> identifier with values from 1 to 65534, inclusive. The default is to include no encryption field. This option is valid with all commands.<dt><tt>minpoll <i>minpoll</i></tt><br>
+                               <tt>maxpoll <i>maxpoll</i></tt>
+-                      <dd>These options specify the minimum and maximum poll intervals for NTP messages, in seconds as a power of two. The maximum poll interval defaults to 10 (1,024 s), but can be increased by the <tt>maxpoll</tt> option to an upper limit of 17 (36.4 h). The minimum poll interval defaults to 6 (64 s), but can be decreased by the <tt>minpoll</tt> option to a lower limit of 4 (16 s). These option are valid only with the <tt>server</tt> and <tt>peer</tt> commands.<dt><tt>noselect</tt>
++                      <dd>These options specify the minimum and maximum poll intervals for NTP messages, in seconds as a power of two. The maximum poll interval defaults to 10 (1,024 s), but can be increased by the <tt>maxpoll</tt> option to an upper limit of 17 (36.4 h). The minimum poll interval defaults to 6 (64 s), but can be decreased by the <tt>minpoll</tt> option to a lower limit of 3 (8 s). These option are valid only with the <tt>server</tt> and <tt>peer</tt> commands.<dt><tt>noselect</tt>
+                       <dd>Marks the server as unused, except for display purposes. The server is discarded by the selection algorithm. This option is valid only with the <tt>server</tt> and <tt>peer</tt> commands.<dt><tt>preempt</tt>
+                       <dd>Specifies the association as preemptable rather than the default persistent. This option is valied only with the <tt>server</tt> command.<dt><tt>prefer</tt>
+                       <dd>Marks the server as preferred. All other things being equal, this host will be chosen for synchronization among a set of correctly operating hosts. See the <a href="prefer.html">Mitigation Rules and the <tt>prefer</tt> Keyword</a> page for further information. This option is valid only with the <tt>server</tt> and <tt>peer</tt> commands.<dt><tt>true</tt>
+diff -up ntp-4.2.4p7/include/ntp.h.minpoll ntp-4.2.4p7/include/ntp.h
+--- ntp-4.2.4p7/include/ntp.h.minpoll  2008-08-10 13:02:42.000000000 +0200
++++ ntp-4.2.4p7/include/ntp.h  2009-05-19 14:23:01.000000000 +0200
+@@ -104,7 +104,7 @@ typedef char s_char;
+  * Poll interval parameters
+  */
+ #define NTP_UNREACH   24      /* poll unreach threshold */
+-#define       NTP_MINPOLL     4       /* log2 min poll interval (16 s) */
++#define       NTP_MINPOLL     3       /* log2 min poll interval (8 s) */
+ #define NTP_MINDPOLL  6       /* log2 default min poll (64 s) */
+ #define NTP_MAXDPOLL  10      /* log2 default max poll (~17 m) */
+ #define       NTP_MAXPOLL     17      /* log2 max poll interval (~36 h) */
+diff -up ntp-4.2.4p7/ntpd/ntp_loopfilter.c.minpoll ntp-4.2.4p7/ntpd/ntp_loopfilter.c
+--- ntp-4.2.4p7/ntpd/ntp_loopfilter.c.minpoll  2009-05-19 14:23:01.000000000 +0200
++++ ntp-4.2.4p7/ntpd/ntp_loopfilter.c  2009-05-19 14:23:01.000000000 +0200
+@@ -404,7 +404,7 @@ local_clock(
+                           fp_offset);
+                       reinit_timer();
+                       tc_counter = 0;
+-                      sys_poll = NTP_MINPOLL;
++                      sys_poll = NTP_MINPOLL + 1;
+                       sys_tai = 0;
+                       clock_jitter = LOGTOD(sys_precision);
+                       rval = 2;
diff --git a/packaging/ntp-4.2.4p7-nano.patch b/packaging/ntp-4.2.4p7-nano.patch
new file mode 100644 (file)
index 0000000..a0ddf50
--- /dev/null
@@ -0,0 +1,18 @@
+diff -up ntp-4.2.4p7/include/ntp_syscall.h.nano ntp-4.2.4p7/include/ntp_syscall.h
+--- ntp-4.2.4p7/include/ntp_syscall.h.nano     2009-05-19 10:26:49.000000000 +0200
++++ ntp-4.2.4p7/include/ntp_syscall.h  2009-05-19 10:28:05.000000000 +0200
+@@ -14,6 +14,14 @@
+ # include <sys/timex.h>
+ #endif
++#if defined(ADJ_NANO) && !defined(MOD_NANO)
++#define MOD_NANO ADJ_NANO
++#endif
++
++#if defined(ADJ_TAI) && !defined(MOD_TAI)
++#define MOD_TAI ADJ_TAI
++#endif
++
+ #ifndef STA_MODE
+ #define STA_MODE        0x4000  /* mode (0 = PLL, 1 = FLL) (ro) */
+ #endif
diff --git a/packaging/ntp-4.2.4p7-sleep.patch b/packaging/ntp-4.2.4p7-sleep.patch
new file mode 100644 (file)
index 0000000..d8539ba
--- /dev/null
@@ -0,0 +1,430 @@
+diff -up ntp-4.2.4p7/include/ntp_refclock.h.sleep ntp-4.2.4p7/include/ntp_refclock.h
+--- ntp-4.2.4p7/include/ntp_refclock.h.sleep   2006-06-06 22:16:19.000000000 +0200
++++ ntp-4.2.4p7/include/ntp_refclock.h 2009-07-21 16:38:47.000000000 +0200
+@@ -260,6 +260,7 @@ extern     void    refclock_control P((struct s
+                                   struct refclockstat *));
+ extern        int     refclock_open   P((char *, u_int, u_int));
+ extern        int     refclock_setup  P((int, u_int, u_int));
++extern        int     refclock_timer_needed   P((struct peer *));
+ extern        void    refclock_timer  P((struct peer *));
+ extern        void    refclock_transmit P((struct peer *));
+ extern        int     refclock_ioctl  P((int, u_int));
+diff -up ntp-4.2.4p7/include/ntp_stdlib.h.sleep ntp-4.2.4p7/include/ntp_stdlib.h
+--- ntp-4.2.4p7/include/ntp_stdlib.h.sleep     2006-12-28 13:03:05.000000000 +0100
++++ ntp-4.2.4p7/include/ntp_stdlib.h   2009-07-21 16:38:47.000000000 +0200
+@@ -101,6 +101,7 @@ extern     const char *    FindConfig      P((const 
+ extern        void    signal_no_reset P((int, RETSIGTYPE (*func)(int)));
+ extern        void    getauthkeys     P((const char *));
++extern        int     auth_agekeys_is_needed P((void));
+ extern        void    auth_agekeys    P((void));
+ extern        void    rereadkeys      P((void));
+diff -up ntp-4.2.4p7/include/ntpd.h.sleep ntp-4.2.4p7/include/ntpd.h
+--- ntp-4.2.4p7/include/ntpd.h.sleep   2009-07-21 16:38:47.000000000 +0200
++++ ntp-4.2.4p7/include/ntpd.h 2009-07-21 16:38:47.000000000 +0200
+@@ -120,8 +120,10 @@ extern    int     leap_actual P((int));
+ /* ntp_loopfilter.c */
+ extern        void    init_loopfilter P((void));
+ extern        int     local_clock P((struct peer *, double));
+-extern        void    adj_host_clock  P((void));
++extern        int     adj_host_clock_is_needed P((void));
++extern        void    adj_host_clock  P((int));
+ extern        void    loop_config P((int, double));
++extern        int     huffpuff_enabled P((void));
+ extern        void    huffpuff        P((void));
+ extern        u_long  sys_clocktime;
+ extern        u_long  sys_tai;
+@@ -221,6 +223,7 @@ extern     void    hack_restrict   P((int, struct
+ /* ntp_timer.c */
+ extern        void    init_timer      P((void));
+ extern        void    reinit_timer    P((void));
++extern        int     when_next_event P((void));
+ extern        void    timer           P((void));
+ extern        void    timer_clr_stats P((void));
+ extern  void    timer_interfacetimeout P((u_long));
+diff -up ntp-4.2.4p7/libntp/authkeys.c.sleep ntp-4.2.4p7/libntp/authkeys.c
+--- ntp-4.2.4p7/libntp/authkeys.c.sleep        2004-02-25 06:58:03.000000000 +0100
++++ ntp-4.2.4p7/libntp/authkeys.c      2009-07-21 16:38:47.000000000 +0200
+@@ -394,6 +394,24 @@ auth_delkeys(void)
+       }
+ }
++int auth_agekeys_is_needed() {
++      struct savekey *sk;
++      int i;
++
++      if (authnumkeys > 20)
++              return 1;
++
++      for (i = 0; i < HASHSIZE; i++) {
++              sk = key_hash[i];
++              while (sk != 0) {
++                      if (sk->lifetime > 0)
++                              return 1;
++                      sk = sk->next;
++              }
++      }
++      return 0;
++}
++
+ /*
+  * auth_agekeys - delete keys whose lifetimes have expired
+  */
+diff -up ntp-4.2.4p7/ntpd/ntp_loopfilter.c.sleep ntp-4.2.4p7/ntpd/ntp_loopfilter.c
+--- ntp-4.2.4p7/ntpd/ntp_loopfilter.c.sleep    2009-07-21 16:38:47.000000000 +0200
++++ ntp-4.2.4p7/ntpd/ntp_loopfilter.c  2009-07-21 16:38:47.000000000 +0200
+@@ -752,6 +752,10 @@ local_clock(
+ #endif /* LOCKCLOCK */
+ }
++int adj_host_clock_is_needed() {
++      return !(!ntp_enable || mode_ntpdate || (pll_control &&
++          kern_enable));
++}
+ /*
+  * adj_host_clock - Called once every second to update the local clock.
+@@ -761,7 +765,7 @@ local_clock(
+  */
+ void
+ adj_host_clock(
+-      void
++      int time_elapsed
+       )
+ {
+       double  adjustment;
+@@ -776,7 +780,8 @@ adj_host_clock(
+        * maximum error and the local clock driver will pick it up and
+        * pass to the common refclock routines. Very elegant.
+        */
+-      sys_rootdispersion += clock_phi;
++      sys_rootdispersion += clock_phi * time_elapsed;
++      DPRINTF(2, ("loopfilter: %d\n", time_elapsed));
+ #ifndef LOCKCLOCK
+       /*
+@@ -833,6 +838,11 @@ rstclock(
+ }
++int huffpuff_enabled()
++{
++      return sys_huffpuff != NULL;
++}
++
+ /*
+  * huff-n'-puff filter
+  */
+diff -up ntp-4.2.4p7/ntpd/ntp_refclock.c.sleep ntp-4.2.4p7/ntpd/ntp_refclock.c
+--- ntp-4.2.4p7/ntpd/ntp_refclock.c.sleep      2006-06-06 22:16:43.000000000 +0200
++++ ntp-4.2.4p7/ntpd/ntp_refclock.c    2009-07-21 16:38:47.000000000 +0200
+@@ -309,6 +309,21 @@ refclock_unpeer(
+ }
++int
++refclock_timer_needed(
++      struct peer *peer       /* peer structure pointer */
++      )
++{
++      u_char clktype;
++      int unit;
++
++      clktype = peer->refclktype;
++      unit = peer->refclkunit;
++      if (refclock_conf[clktype]->clock_timer != noentry)
++              return 1;
++      return 0;
++}
++
+ /*
+  * refclock_timer - called once per second for housekeeping.
+  */
+diff -up ntp-4.2.4p7/ntpd/ntp_timer.c.sleep ntp-4.2.4p7/ntpd/ntp_timer.c
+--- ntp-4.2.4p7/ntpd/ntp_timer.c.sleep 2009-05-12 07:58:55.000000000 +0200
++++ ntp-4.2.4p7/ntpd/ntp_timer.c       2009-07-21 16:38:47.000000000 +0200
+@@ -63,6 +63,7 @@ volatile u_long alarm_overflow;
+ #define HOUR  (60*60)
+ u_long current_time;
++l_fp timer_base;
+ /*
+  * Stats.  Number of overflows and number of calls to transmit().
+@@ -99,6 +100,8 @@ static      RETSIGTYPE alarming P((int));
+ void 
+ reinit_timer(void)
+ {
++      get_systime(&timer_base);
++#if 0
+ #if !defined(SYS_WINNT) && !defined(VMS)
+ #  if defined(HAVE_TIMER_CREATE) && defined(HAVE_TIMER_SETTIME)
+       timer_gettime(ntpd_timerid, &itimer);
+@@ -132,6 +135,7 @@ reinit_timer(void)
+       setitimer(ITIMER_REAL, &itimer, (struct itimerval *)0);
+ #  endif
+ # endif /* VMS */
++#endif
+ }
+ /*
+@@ -159,6 +163,8 @@ init_timer(void)
+       timer_xmtcalls = 0;
+       timer_timereset = 0;
++      get_systime(&timer_base);
++#if 0
+ #if !defined(SYS_WINNT)
+       /*
+        * Set up the alarm interrupt.  The first comes 2**EVENT_TIMEOUT
+@@ -242,6 +248,7 @@ init_timer(void)
+       }
+ #endif /* SYS_WINNT */
++#endif
+ }
+ #if defined(SYS_WINNT)
+@@ -252,6 +259,46 @@ get_timer_handle(void)
+ }
+ #endif
++int when_next_event() {
++      register struct peer *peer, *next_peer;
++      u_int n;
++      int next = current_time + HOUR;
++
++      if (adj_host_clock_is_needed())
++              return 1;
++      for (n = 0; n < NTP_HASH_SIZE; n++) {
++              for (peer = peer_hash[n]; peer != 0; peer = next_peer) {
++                      next_peer = peer->next;
++#ifdef REFCLOCK
++                      if (peer->flags & FLAG_REFCLOCK && refclock_timer_needed(peer))
++                              return 1;
++#endif /* REFCLOCK */
++                      if (peer->action && peer->nextaction < next)
++                              next = peer->nextaction;
++                      if (peer->nextdate < next)
++                              next = peer->nextdate;
++              }
++      }
++
++      if (auth_agekeys_is_needed() && keys_timer < next)
++              next = keys_timer;
++      if (huffpuff_enabled() && huffpuff_timer < next)
++              next = huffpuff_timer;
++#ifdef OPENSSL
++      if (revoke_timer < next)
++              next = revoke_timer;
++#endif /* OPENSSL */
++      if (interface_interval && interface_timer < next)
++              next = interface_timer;
++      if (stats_timer < next)
++              next = stats_timer;
++
++      next -= current_time;
++      if (next <= 0)
++              next = 1;
++      return next;
++}
++
+ /*
+  * timer - dispatch anyone who needs to be
+  */
+@@ -264,14 +311,12 @@ timer(void)
+ #endif /* OPENSSL */
+       u_int n;
+-      current_time += (1<<EVENT_TIMEOUT);
+-
+       /*
+        * Adjustment timeout first.
+        */
+       if (adjust_timer <= current_time) {
+-              adjust_timer += 1;
+-              adj_host_clock();
++              adj_host_clock(current_time - adjust_timer + 1);
++              adjust_timer = current_time + 1;
+               kod_proto();
+ #ifdef REFCLOCK
+               for (n = 0; n < NTP_HASH_SIZE; n++) {
+diff -up ntp-4.2.4p7/ntpd/ntpd.c.sleep ntp-4.2.4p7/ntpd/ntpd.c
+--- ntp-4.2.4p7/ntpd/ntpd.c.sleep      2009-07-21 16:38:47.000000000 +0200
++++ ntp-4.2.4p7/ntpd/ntpd.c    2009-07-21 16:39:29.000000000 +0200
+@@ -179,8 +179,6 @@ extern const char *Version;
+ char const *progname;
+-int was_alarmed;
+-
+ #ifdef DECL_SYSCALL
+ /*
+  * We put this here, since the argument profile is syscall-specific
+@@ -434,6 +432,7 @@ set_process_priority(void)
+               msyslog(LOG_ERR, "set_process_priority: No way found to improve our priority");
+ }
++#define TS_LAST_SIZE 2
+ /*
+  * Main program.  Initialize us, disconnect us from the tty if necessary,
+@@ -446,6 +445,9 @@ ntpdmain(
+       )
+ {
+       l_fp now;
++      l_fp ts_last[TS_LAST_SIZE];
++      unsigned int ts_last_index;
++      int time_elapsed;
+       struct recvbuf *rbuf;
+ #ifdef _AIX                   /* HMS: ifdef SIGDANGER? */
+       struct sigaction sa;
+@@ -998,7 +1000,11 @@ getgroup:        
+ #else /* normal I/O */
+       BLOCK_IO_AND_ALARM();
+-      was_alarmed = 0;
++
++      for (ts_last_index = 0; ts_last_index < TS_LAST_SIZE; ts_last_index++)
++              L_CLR(&ts_last[ts_last_index]);
++      time_elapsed = ts_last_index = 0;
++
+       for (;;)
+       {
+ # if !defined(HAVE_SIGNALED_IO) 
+@@ -1009,39 +1015,66 @@ getgroup:      
+               int nfound;
+ # endif
+-              if (alarm_flag)         /* alarmed? */
+-              {
+-                      was_alarmed = 1;
+-                      alarm_flag = 0;
+-              }
+-
+-              if (!was_alarmed && has_full_recv_buffer() == ISC_FALSE)
++              if (has_full_recv_buffer() == ISC_FALSE)
+               {
+                       /*
+                        * Nothing to do.  Wait for something.
+                        */
+ # ifndef HAVE_SIGNALED_IO
++                      extern l_fp timer_base;
++                      l_fp ts, ts2, ts3;
++                      double d;
++
+                       rdfdes = activefds;
+-#  if defined(VMS) || defined(SYS_VXWORKS)
+-                      /* make select() wake up after one second */
+-                      {
++                      ts2 = timer_base;
++                      get_systime(&ts);
++                      ts3 = ts;
++                      L_SUB(&ts3, &ts_last[ts_last_index]);
++
++                      /* don't call when_next_event() too often */
++                      if (ts3.l_ui)
++                              ts2.l_ui += when_next_event();
++                      else
++                              ts2.l_ui += 1;
++
++                      L_SUB(&ts2, &ts);
++                      LFPTOD(&ts2, d);
++                      DPRINTF(2, ("main: scheduled event in %f\n", d));
++                      if (d > 0.0) {
+                               struct timeval t1;
+-                              t1.tv_sec = 1; t1.tv_usec = 0;
++                              t1.tv_sec = d;
++                              t1.tv_usec = (d - t1.tv_sec) * 1000000;
+                               nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
+                                               (fd_set *)0, &t1);
++                              get_systime(&ts);
++                      } else
++                              nfound = 0;
++
++                      ts3 = ts;
++                      L_SUB(&ts3, &timer_base);
++#ifdef DEBUG 
++                      LFPTOD(&ts3, d);
++                      DPRINTF(2, ("main: elapsed %f\n", d));
++#endif
++
++                      if (ts3.l_i < 0 || ts3.l_ui > ts2.l_ui + 10) {
++#ifdef DEBUG 
++                              DPRINTF(2, ("main: unexpected time jump\n"));
++#endif
++                              ts3.l_ui = 0;
++                              reinit_timer();
+                       }
+-#  else
+-                      nfound = select(maxactivefd+1, &rdfdes, (fd_set *)0,
+-                                      (fd_set *)0, (struct timeval *)0);
+-#  endif /* VMS */
+-                      if (nfound > 0)
+-                      {
+-                              l_fp ts;
+-                              get_systime(&ts);
++                      time_elapsed += ts3.l_ui;
++                      current_time += ts3.l_ui;
++                      timer_base.l_ui += ts3.l_ui;
++                      if (nfound > 0)
++                      {
+                               (void)input_handler(&ts);
++                              ts_last[ts_last_index] = ts;
++                              ts_last_index = (ts_last_index + 1) % TS_LAST_SIZE;
+                       }
+                       else if (nfound == -1 && errno != EINTR)
+                               netsyslog(LOG_ERR, "select() error: %m");
+@@ -1050,17 +1083,12 @@ getgroup:      
+                               netsyslog(LOG_DEBUG, "select(): nfound=%d, error: %m", nfound);
+ #  endif /* DEBUG */
+ # else /* HAVE_SIGNALED_IO */
+-                        
++#  error not supported
+                       wait_for_signal();
+ # endif /* HAVE_SIGNALED_IO */
+-                      if (alarm_flag)         /* alarmed? */
+-                      {
+-                              was_alarmed = 1;
+-                              alarm_flag = 0;
+-                      }
+               }
+-              if (was_alarmed)
++              if (time_elapsed)
+               {
+                       UNBLOCK_IO_AND_ALARM();
+                       /*
+@@ -1068,7 +1096,7 @@ getgroup:        
+                        * to process expiry.
+                        */
+                       timer();
+-                      was_alarmed = 0;
++                      time_elapsed = 0;
+                         BLOCK_IO_AND_ALARM();
+               }
+@@ -1086,19 +1114,8 @@ getgroup:       
+                       rbuf = get_full_recv_buffer();
+                       while (rbuf != NULL)
+                       {
+-                              if (alarm_flag)
+-                              {
+-                                      was_alarmed = 1;
+-                                      alarm_flag = 0;
+-                              }
+                               UNBLOCK_IO_AND_ALARM();
+-                              if (was_alarmed)
+-                              {       /* avoid timer starvation during lengthy I/O handling */
+-                                      timer();
+-                                      was_alarmed = 0;
+-                              }
+-
+                               /*
+                                * Call the data procedure to handle each received
+                                * packet.
diff --git a/packaging/ntp-4.2.4p7-stamode.patch b/packaging/ntp-4.2.4p7-stamode.patch
new file mode 100644 (file)
index 0000000..5c1870f
--- /dev/null
@@ -0,0 +1,26 @@
+diff -up ntp-4.2.4p7/include/ntp_syscall.h.stamode ntp-4.2.4p7/include/ntp_syscall.h
+--- ntp-4.2.4p7/include/ntp_syscall.h.stamode  2004-02-25 06:57:56.000000000 +0100
++++ ntp-4.2.4p7/include/ntp_syscall.h  2009-05-19 10:21:34.000000000 +0200
+@@ -14,6 +14,10 @@
+ # include <sys/timex.h>
+ #endif
++#ifndef STA_MODE
++#define STA_MODE        0x4000  /* mode (0 = PLL, 1 = FLL) (ro) */
++#endif
++
+ #ifndef NTP_SYSCALLS_LIBC
+ #ifdef NTP_SYSCALLS_STD
+ # define ntp_adjtime(t)               syscall(SYS_ntp_adjtime, (t))
+diff -up ntp-4.2.4p7/ntpd/ntp_loopfilter.c.stamode ntp-4.2.4p7/ntpd/ntp_loopfilter.c
+--- ntp-4.2.4p7/ntpd/ntp_loopfilter.c.stamode  2009-05-19 10:20:03.000000000 +0200
++++ ntp-4.2.4p7/ntpd/ntp_loopfilter.c  2009-05-19 10:25:22.000000000 +0200
+@@ -644,7 +644,7 @@ local_clock(
+                           "kernel time sync error %04x", ntv.status);
+                       ntv.status &= ~(STA_PPSFREQ | STA_PPSTIME);
+               } else {
+-                      if ((ntv.status ^ pll_status) & ~STA_FLL)
++                      if ((ntv.status ^ pll_status) & ~(STA_FLL | STA_MODE))
+                               NLOG(NLOG_SYNCEVENT | NLOG_SYSEVENT)
+                                   msyslog(LOG_NOTICE,
+                                   "kernel time sync status change %04x",
diff --git a/packaging/ntp-4.2.4p8-editline.patch b/packaging/ntp-4.2.4p8-editline.patch
new file mode 100644 (file)
index 0000000..5b21918
--- /dev/null
@@ -0,0 +1,57 @@
+diff -uNpr ntp-4.2.4p8/configure ntp-4.2.4p8-fixed/configure
+--- ntp-4.2.4p8/configure      2009-12-08 21:07:43.000000000 +0800
++++ ntp-4.2.4p8-fixed/configure        2009-12-14 18:01:05.000000000 +0800
+@@ -17217,8 +17217,14 @@ done
+ # following block becomes on 4.2.5: NTP_LINEEDITLIBS
++READLINE_LIBS="-ledit"
++cat >>confdefs.h <<\_ACEOF
++#define HAVE_LIBEDIT
++_ACEOF
++
+ for ac_header in readline/history.h readline/readline.h
+ do :
++break
+   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+ eval as_val=\$$as_ac_Header
+@@ -17232,7 +17238,7 @@ fi
+ done
+ case "$ac_cv_header_readline_history_h$ac_cv_header_readline_readline_h" in
+- *no*) ;;
++ *) ;;
+  *) save_LIBS=$LIBS
+     LIBS=
+     # Ralf Wildenhues: either unset ... or cache READLINE_LIBS
+diff -uNpr ntp-4.2.4p8/ntpdc/ntpdc.c ntp-4.2.4p8-fixed/ntpdc/ntpdc.c
+--- ntp-4.2.4p8/ntpdc/ntpdc.c  2009-12-08 19:55:59.000000000 +0800
++++ ntp-4.2.4p8-fixed/ntpdc/ntpdc.c    2009-12-14 17:59:07.000000000 +0800
+@@ -26,9 +26,8 @@
+ # define closesocket close
+ #endif /* SYS_WINNT */
+-#if defined(HAVE_LIBREADLINE) || defined (HAVE_LIBEDIT)
+-# include <readline/readline.h>
+-# include <readline/history.h>
++#if defined (HAVE_LIBEDIT)
++# include <editline/readline.h>
+ #endif /* HAVE_LIBREADLINE || HAVE_LIBEDIT */
+ #ifdef SYS_VXWORKS
+diff -uNpr ntp-4.2.4p8/ntpq/ntpq.c ntp-4.2.4p8-fixed/ntpq/ntpq.c
+--- ntp-4.2.4p8/ntpq/ntpq.c    2009-12-08 19:55:59.000000000 +0800
++++ ntp-4.2.4p8-fixed/ntpq/ntpq.c      2009-12-14 17:59:07.000000000 +0800
+@@ -30,9 +30,8 @@
+ # define closesocket close
+ #endif /* SYS_WINNT */
+-#if defined(HAVE_LIBREADLINE) || defined(HAVE_LIBEDIT)
+-# include <readline/readline.h>
+-# include <readline/history.h>
++#if defined(HAVE_LIBEDIT)
++# include <editline/readline.h>
+ #endif /* HAVE_LIBREADLINE || HAVE_LIBEDIT */
+ #ifdef SYS_VXWORKS
diff --git a/packaging/ntp-4.2.4p8-gettime.patch b/packaging/ntp-4.2.4p8-gettime.patch
new file mode 100644 (file)
index 0000000..eab9f55
--- /dev/null
@@ -0,0 +1,14 @@
+diff -uNpr ntp-4.2.4p8/configure ntp-4.2.4p8-fixed/configure
+--- ntp-4.2.4p8/configure      2009-12-08 21:07:43.000000000 +0800
++++ ntp-4.2.4p8-fixed/configure        2009-12-14 18:16:27.000000000 +0800
+@@ -20215,6 +20215,10 @@ case "$host" in
+     ;;
+  *) for ac_func in clock_gettime clock_settime
+ do :
++   cat >>confdefs.h <<_ACEOF
++#define `echo "HAVE_$ac_func" | $as_tr_cpp` 1
++_ACEOF
++continue
+   as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+ eval as_val=\$$as_ac_var
diff --git a/packaging/ntp-4.2.4p8-mlock.patch b/packaging/ntp-4.2.4p8-mlock.patch
new file mode 100644 (file)
index 0000000..dfbba21
--- /dev/null
@@ -0,0 +1,137 @@
+diff -uNpr ntp-4.2.4p8/html/ntpd.html ntp-4.2.4p8-fixed/html/ntpd.html
+--- ntp-4.2.4p8/html/ntpd.html 2006-12-28 20:02:57.000000000 +0800
++++ ntp-4.2.4p8-fixed/html/ntpd.html   2009-12-14 18:02:33.000000000 +0800
+@@ -89,6 +89,8 @@
+                       <dd>Specify the name and path of the log file. The default is the system log file. This is the same operation as the <tt>logfile <i>logfile</i></tt> configuration command.
+                       <dt><tt>-L</tt>
+                       <dd>Do not listen to virtual IPs. The default is to listen.
++                      <dt><tt>-m</tt>
++                      <dd>Lock memory.
+                       <dt><tt>-n</tt>
+                       <dd>Don't fork.
+                       <dt><tt>-N</tt>
+diff -uNpr ntp-4.2.4p8/ntpd/ntpd.c ntp-4.2.4p8-fixed/ntpd/ntpd.c
+--- ntp-4.2.4p8/ntpd/ntpd.c    2009-12-08 19:55:58.000000000 +0800
++++ ntp-4.2.4p8-fixed/ntpd/ntpd.c      2009-12-14 18:02:33.000000000 +0800
+@@ -696,7 +696,8 @@ ntpdmain(
+       }
+ #endif
+-#if defined(HAVE_MLOCKALL) && defined(MCL_CURRENT) && defined(MCL_FUTURE)
++#if defined(MCL_CURRENT) && defined(MCL_FUTURE)
++    if (HAVE_OPT( MLOCK )) {
+ # ifdef HAVE_SETRLIMIT
+       /*
+        * Set the stack limit to something smaller, so that we don't lock a lot
+@@ -722,7 +723,7 @@ ntpdmain(
+            * fail if we drop root privlege.  To be useful the value
+            * has to be larger than the largest ntpd resident set size.
+            */
+-          rl.rlim_cur = rl.rlim_max = 32*1024*1024;
++          rl.rlim_cur = rl.rlim_max = 64*1024*1024;
+           if (setrlimit(RLIMIT_MEMLOCK, &rl) == -1) {
+               msyslog(LOG_ERR, "Cannot set RLIMIT_MEMLOCK: %m");
+           }
+@@ -734,6 +735,7 @@ ntpdmain(
+        */
+       if (mlockall(MCL_CURRENT|MCL_FUTURE) < 0)
+               msyslog(LOG_ERR, "mlockall(): %m");
++    }
+ #else /* not (HAVE_MLOCKALL && MCL_CURRENT && MCL_FUTURE) */
+ # ifdef HAVE_PLOCK
+ #  ifdef PROCLOCK
+diff -uNpr ntp-4.2.4p8/ntpd/ntpd-opts.c ntp-4.2.4p8-fixed/ntpd/ntpd-opts.c
+--- ntp-4.2.4p8/ntpd/ntpd-opts.c       2009-12-08 21:13:09.000000000 +0800
++++ ntp-4.2.4p8-fixed/ntpd/ntpd-opts.c 2009-12-14 18:02:33.000000000 +0800
+@@ -264,6 +264,15 @@ tSCC    zNice_Name[]               = "ni
+ #define NICE_FLAGS       (OPTST_DISABLED)
+ /*
++ *  Mlock option description:
++ */
++tSCC    zMlockText[] =
++        "Lock memory";
++tSCC    zMlock_NAME[]               = "MLOCK";
++tSCC    zMlock_Name[]               = "mlock";
++#define MLOCK_FLAGS       (OPTST_DISABLED)
++
++/*
+  *  Pidfile option description:
+  */
+ tSCC    zPidfileText[] =
+@@ -789,6 +798,18 @@ static tOptDesc optDesc[ OPTION_CT ] = {
+                                 OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
+ #endif
++  {  /* entry idx, value */ 29, VALUE_OPT_MLOCK,
++     /* equiv idx, value */ 29, VALUE_OPT_MLOCK,
++     /* equivalenced to  */ NO_EQUIVALENT,
++     /* min, max, act ct */ 0, 1, 0,
++     /* opt state flags  */ MLOCK_FLAGS, 0,
++     /* last opt argumnt */ { NULL },
++     /* arg list/cookie  */ NULL,
++     /* must/cannot opts */ NULL, NULL,
++     /* option proc      */ NULL,
++     /* desc, NAME, name */ zMlockText, zMlock_NAME, zMlock_Name,
++     /* disablement strs */ NULL, NULL },
++
+   {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
+      /* equiv idx value  */ NO_EQUIVALENT, 0,
+      /* equivalenced to  */ NO_EQUIVALENT,
+@@ -881,7 +902,7 @@ tOptions ntpdOptions = {
+       NO_EQUIVALENT /* index of '-#' option */,
+       NO_EQUIVALENT /* index of default opt */
+     },
+-    32 /* full option count */, 29 /* user option count */
++    33 /* full option count */, 30 /* user option count */
+ };
+ /*
+diff -uNpr ntp-4.2.4p8/ntpd/ntpd-opts.h ntp-4.2.4p8-fixed/ntpd/ntpd-opts.h
+--- ntp-4.2.4p8/ntpd/ntpd-opts.h       2009-12-08 21:13:09.000000000 +0800
++++ ntp-4.2.4p8-fixed/ntpd/ntpd-opts.h 2009-12-14 18:04:13.000000000 +0800
+@@ -81,12 +81,13 @@ typedef enum {
+         INDEX_OPT_VAR              = 26,
+         INDEX_OPT_DVAR             = 27,
+         INDEX_OPT_SLEW             = 28,
+-        INDEX_OPT_VERSION          = 29,
+-        INDEX_OPT_HELP             = 30,
+-        INDEX_OPT_MORE_HELP        = 31
++        INDEX_OPT_MLOCK            = 29,
++        INDEX_OPT_VERSION          = 30,
++        INDEX_OPT_HELP             = 31,
++        INDEX_OPT_MORE_HELP        = 32
+ } teOptIndex;
+-#define OPTION_CT    32
++#define OPTION_CT    33
+ #define NTPD_VERSION       "4.2.4p8"
+ #define NTPD_FULL_VERSION  "ntpd - NTP daemon program - Ver. 4.2.4p8"
+@@ -179,6 +180,10 @@ typedef enum {
+ #  warning undefining MODIFYMMTIMER due to option name conflict
+ #  undef   MODIFYMMTIMER
+ # endif
++# ifdef    MLOCK
++#  warning undefining MLOCK due to option name conflict
++#  undef   MLOCK
++# endif
+ # ifdef    NOFORK
+ #  warning undefining NOFORK due to option name conflict
+ #  undef   NOFORK
+@@ -248,6 +253,7 @@ typedef enum {
+ # undef LOGFILE
+ # undef NOVIRTUALIPS
+ # undef MODIFYMMTIMER
++# undef MLOCK
+ # undef NOFORK
+ # undef NICE
+ # undef PIDFILE
+@@ -290,6 +296,7 @@ typedef enum {
+ #ifdef SYS_WINNT
+ #define VALUE_OPT_MODIFYMMTIMER  'M'
+ #endif /* SYS_WINNT */
++#define VALUE_OPT_MLOCK          'm'
+ #define VALUE_OPT_NOFORK         'n'
+ #define VALUE_OPT_NICE           'N'
+ #define VALUE_OPT_PIDFILE        'p'
diff --git a/packaging/ntp-4.2.4p8-nosntp.patch b/packaging/ntp-4.2.4p8-nosntp.patch
new file mode 100644 (file)
index 0000000..d58c329
--- /dev/null
@@ -0,0 +1,42 @@
+diff -uNpr ntp-4.2.4p8/configure ntp-4.2.4p8-fixed/configure
+--- ntp-4.2.4p8/configure      2009-12-08 21:07:43.000000000 +0800
++++ ntp-4.2.4p8-fixed/configure        2009-12-14 18:13:22.000000000 +0800
+@@ -988,8 +988,7 @@ LDFLAGS
+ LIBS
+ CPPFLAGS
+ CPP'
+-ac_subdirs_all='arlib
+-sntp'
++ac_subdirs_all='arlib'
+ # Initialize some variables set by options.
+ ac_init_help=
+@@ -25764,7 +25763,7 @@ ac_config_files="$ac_config_files script
+ ac_config_files="$ac_config_files util/Makefile"
+-subdirs="$subdirs sntp"
++subdirs="$subdirs"
+ cat >confcache <<\_ACEOF
+diff -uNpr ntp-4.2.4p8/Makefile.in ntp-4.2.4p8-fixed/Makefile.in
+--- ntp-4.2.4p8/Makefile.in    2009-12-08 21:07:31.000000000 +0800
++++ ntp-4.2.4p8-fixed/Makefile.in      2009-12-14 18:10:02.000000000 +0800
+@@ -246,7 +246,7 @@ ACLOCAL_AMFLAGS = -I m4 -I libopts/m4
+ NULL = 
+ SUBDIRS = $(am__append_1) scripts include ElectricFence @ARLIB_DIR@ \
+       libntp libparse ntpd ntpdate ntpdc ntpq parseutil adjtimed \
+-      clockstuff kernel sntp util $(NULL)
++      clockstuff kernel util $(NULL)
+ DIST_SUBDIRS = \
+       scripts         \
+       include         \
+@@ -263,7 +263,6 @@ DIST_SUBDIRS = \
+       adjtimed        \
+       clockstuff      \
+       kernel          \
+-      sntp            \
+       util            \
+       $(NULL)
diff --git a/packaging/ntp-4.2.4p8.tar.bz2 b/packaging/ntp-4.2.4p8.tar.bz2
new file mode 100644 (file)
index 0000000..a63ee6f
Binary files /dev/null and b/packaging/ntp-4.2.4p8.tar.bz2 differ
diff --git a/packaging/ntp.changes b/packaging/ntp.changes
new file mode 100644 (file)
index 0000000..c74834d
--- /dev/null
@@ -0,0 +1,579 @@
+* Wed May 30 03:17:39 UTC 2012 - Lin Yang <lin.a.yang@intel.con> - 4.2.4p8
+- Initial commit to Gerrit
+
+* Tue May 03 2011 Chris Ferron <chris.e.ferron@linux.intel.com> - 4.2.4p8
+- FEA#16109 - [FEA] Implement SystemD as MeeGo init provide
+- As systemd is now the MeeGo init provider there is no need for chkconfig, service or init scripts
+  to be used. 
+
+* Thu Apr 29 2010 Anas Nashif <anas.nashif@intel.com> - 4.2.4p8
+- ntp.moblin.org -> ntp.meego.com (bmc#358)
+
+* Sat Apr 03 2010 Anas Nashif <anas.nashif@intel.com> - 4.2.4p8
+- Do not use zones, use ntp.moblin.org for now until we have a meego ntp
+  server (Fixes BMC#358)
+
+* Mon Dec 14 2009 Passion Zhao <passion.zhao@intel.com> - 4.2.4p8-1
+- Update to 4.2.4p8 to address CVE-2009-3563
+- Rebase the patch: 
+  ntp-4.2.4p8-editline.patch ntp-4.2.4p8-gettime.patch 
+  ntp-4.2.4p8-mlock.patch ntp-4.2.4p8-nosntp.patch
+
+* Sun Aug 30 2009 Anas Nashif <anas.nashif@intel.com> - 4.2.4p7
+- Fixed build errors with new gcc
+
+* Thu May 21 2009 Passion Zhao <passion.zhao@intel.com>
+- Update to 4.2.4p7 to address CVE-2009-1252
+- Update the patch: ntp-4.2.4p7-ipv6.patch, ntp-4.2.4p7-mlock.patch, ntp-4.2.4p7-nosntp.patch
+- Remove upstreamed patch: ntp-CVE-2009-0159.patch,ntp-CVE-2009-0021.patch 
+- Remove useless & unappliable patch: ntp-4.2.4p5-retryres.patch
+
+
+* Thu Apr 23 2009 Anas Nashif <anas.nashif@intel.com> 4.2.4p5
+- Do not use fedora ntp servers
+- disable service start by default
+
+* Thu Apr 23 2009 Passion Zhao <passion.zhao@intel.com>
+- Add ntp-CVE-2009-0159.patch
+
+* Fri Jan 23 2009 Passion Zhao <passion.zhao@intel.com>
+- Add ntp-CVE-2009-0021.patch
+
+* Thu Jan 7 2009 Arjan van de Ven <arjan@linux.intel.com>
+- don't run the shutdown script on shutdown for ntpdate..
+  there's nothing to do anyway
+* Tue Dec 16 2008 Anas Nashif <anas.nashif@intel.com> 4.2.4p5
+- Initial import into moblin
+
+* Wed Oct 08 2008 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p5-2
+- retry failed name resolution few times before giving up (#460561)
+- don't write drift file upon exit
+- run ntpq with full path in ntp-wait script
+
+* Fri Aug 29 2008 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p5-1
+- update to 4.2.4p5
+- add support for fast interface updates
+
+* Mon Jul 28 2008 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p4-7
+- reload resolv.conf after temporary failure in name resolution (#456743)
+- use clock_gettime
+- make subpackages for perl scripts and ntpdate (#452097, #456116)
+
+* Mon Apr 07 2008 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p4-6
+- don't use /etc/sysconfig/clock in ntpdate init script
+
+* Mon Mar 10 2008 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p4-5
+- fix building IPv6 support with new glibc-headers (#436713)
+- avoid unaligned memory access (#435301)
+- fix receiving broadcasts on 255.255.255.255
+
+* Fri Feb 29 2008 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p4-4
+- reset kernel frequency when -x option is used
+- create separate init script for ntpdate
+- add note about paths and exit codes to ntpd man page
+
+* Tue Feb 19 2008 Fedora Release Engineering <rel-eng@fedoraproject.org> - 4.2.4p4-3
+- Autorebuild for GCC 4.3
+
+* Wed Dec 05 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p4-2
+- rebuild for openssl bump
+
+* Fri Oct 26 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p4-1
+- update to 4.2.4p4
+- fix default NTP version for outgoing packets in ntpdate man page
+  (#245408)
+- replace BSD with advertising code in ntpdc and ntpq
+
+* Mon Sep 24 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p2-6
+- require perl (#274771)
+- don't fail when starting with no interfaces (#300371)
+
+* Tue Aug 21 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p2-5
+- avoid use of uninitialized floating-point values in clock_select
+- update license tag (Tom "spot" Callaway)
+- drop sntp, MSNTP license is non-free
+
+* Mon Aug 13 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p2-4
+- allow loopback to share non-loopback address (#249226)
+- require readline >= 5.2-3 (#250917)
+
+* Wed Jul 25 2007 Jesse Keating <jkeating@redhat.com> - 4.2.4p2-3
+- Rebuild for RH #249435
+
+* Tue Jul 24 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p2-2
+- ignore tentative addresses (#246297)
+- improve init script (#247003)
+- fix sleep patch
+- ease Autokey setup (#139673)
+  - change default keysdir to /etc/ntp/crypto
+  - set crypto password in /etc/ntp/crypto/pw
+  - don't use randfile if /dev/urandom is used by OpenSSL
+- change default statsdir to /var/log/ntpstats/, use statistics type
+  as default filename
+- package more doc files
+
+* Thu Jun 21 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p2-1
+- update to 4.2.4p2
+
+* Tue May 22 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p0-3
+- fix interface updates with -I or -L option (#240254)
+- accept multiple -I options
+- fix broadcast client/server to accept/allow sending
+  broadcasts on 255.255.255.255 (#226958)
+- fix return codes in init script (#240120)
+- exit with nonzero code if ntpd -q did not set clock (#240134)
+- drop revert452 patch, fixed in kernel 2.6.19
+- make with _smp_mflags
+
+* Wed May 09 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p0-2
+- compile with crypto support on 64bit architectures (#239576)
+- update sleep patch
+
+* Wed Mar 07 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4p0-1
+- update to 4.2.4p0
+- fix init script
+  - don't add second -g to ntpd options (#228424)
+  - update getopts
+  - skip all refclocks when parsing ntp.conf
+- spec cleanup
+
+* Mon Jan 29 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4-4
+- don't wake up every second (#204748)
+- add option to enable memory locking (#195617)
+- fix broadcast client
+- use option values in ntp-keygen
+- improve man pages
+
+* Tue Jan 23 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4-3
+- disable autoopts option preset mechanisms for ntpd
+- document -I option of ntpd
+- generate makewhatis friendly man pages
+
+* Mon Jan 08 2007 Miroslav Lichvar <mlichvar@redhat.com> 4.2.4-1
+- update to 4.2.4 (#146884)
+- don't use local clock in default config
+- autogenerate man pages from HTML
+- clean up spec a bit
+
+* Wed Nov 22 2006 Miroslav Lichvar <mlichvar@redhat.com> 4.2.2p4-2
+- pass additional options to ntpdate (#202204)
+
+* Tue Nov 21 2006 Miroslav Lichvar <mlichvar@redhat.com> 4.2.2p4-1
+- update to 4.2.2p4
+- fix buffer overflow in WWV Audio driver (#216309)
+- don't mark init script as config
+
+* Fri Aug 18 2006 Miroslav Lichvar <mlichvar@redhat.com> 4.2.2p1-3
+- use adjtime when offset is more than 0.5s (#154625)
+
+* Mon Jul 24 2006 Miroslav Lichvar <mlichvar@redhat.com> 4.2.2p1-2
+- link ntpd with -ffast-math on ia64 (#147980)
+
+* Tue Jul 18 2006 Miroslav Lichvar <mlichvar@redhat.com> 4.2.2p1-1
+- update to 4.2.2p1
+- add more examples to ntp.conf
+
+* Thu Jul 06 2006 Miroslav Lichvar <mlichvar@redhat.com> 4.2.2-3
+- fix manycast support in ntpdate (#194329)
+- reply to manycast requests with null refid
+- enable mlockall (#195617)
+- correct threshold value in ntpdate manpage
+
+* Wed Jun 14 2006 Miroslav Lichvar <mlichvar@redhat.com> 4.2.2-2
+- update initscript, ntp.conf, man pages
+- package sntp
+
+* Mon Jun 12 2006 Miroslav Lichvar <mlichvar@redhat.com> 4.2.2-1
+- update to ntp-4.2.2
+- drop drift file upgrade script
+- use proper CFLAGS for ntpstat
+
+* Thu May 11 2006 Miroslav Lichvar <mlichvar@redhat.com> - 4.2.0.a.20050816-14
+- modify ntp.conf, change default restrict, remove broadcastdelay,
+  use fedora.pool.ntp.org (#189667)
+- don't install drift file
+- remove unsupported options from ntptrace manpage (#137717)
+- fix default paths in manpages for ntp-keygen and ntpdate
+
+* Fri Apr 07 2006 Miroslav Lichvar <mlichvar@redhat.com> - 4.2.0.a.20050816-13
+- add option to sync hwclock after ntpdate (#179571)
+
+* Fri Mar 31 2006 Miroslav Lichvar <mlichvar@redhat.com> - 4.2.0.a.20050816-12
+- fix initscript:
+  - replace -U with -u in getopts (#187003)
+  - don't pass group to ntpdate -U argument and ignore -i in options (#142926)
+  - set ntpconf for -c
+  - remove -p 8 from ntpdate arguments
+  - don't call ntpdate when step-tickers doesn't contain anything useful
+    and -x isn't in options
+- fix default keyfile for ntpdate (#183196)
+
+* Thu Feb 23 2006 Miroslav Lichvar <mlichvar@redhat.com> - 4.2.0.a.20050816-11
+- update man pages (#153195, #162856)
+- drop C-Frame-121, vsnprintf, minusTi and loconly patch
+- prevent segfault when loopback interface is not configured (#159056)
+- spec cleanup
+
+* Fri Feb 10 2006 Jesse Keating <jkeating@redhat.com> - 4.2.0.a.20050816-10.2.1
+- bump again for double-long bug on ppc(64)
+
+* Tue Feb 07 2006 Jesse Keating <jkeating@redhat.com> - 4.2.0.a.20050816-10.2
+- rebuilt for new gcc4.1 snapshot and glibc changes
+
+* Fri Dec 09 2005 Jesse Keating <jkeating@redhat.com>
+- rebuilt
+
+* Wed Nov 9 2005 Petr Raszyk <praszyk@redhat.com> 4.2.0.a.20050816-10
+- ntpd does not submit his local clock (if there is no peer).
+  ntpdate->ntpd #163862 , Patch13: ntp-stable-4.2.0a-20050816-loconly.patch
+
+* Wed Nov 2 2005 Petr Raszyk <praszyk@redhat.com> 4.2.0.a.20050816-9
+- Wrong parameter -T   -i
+- Patch ntp-stable-4.2.0a-20050816-minusTi.patch
+
+* Mon Oct 31 2005 Petr Raszyk <praszyk@redhat.com> 4.2.0.a.20050816-3
+- A similar patch as ntp-4.0.99j-vsnprintf.patch in FEDORA CORE 4
+- (current patch is ntp-stable-4.2.0a-20050816-vsnprintf.patch)
+
+* Tue Sep 27 2005 Petr Raszyk <praszyk@redhat.com> 4.2.0.a.20050816-2
+- Fix fails on upgrade, if ntpd is disabled (#166773)
+- A cosmetic patch. There are some comments and braces '{' '}' added.
+- One unprintable character was converted to octal-form .
+- It can be removed anytime (conversion of the cvs-projets for C-Frame 121,
+- (auto-debug, auto-trace for cfr-printnet server).
+
+* Thu Aug 25 2005 Jindrich Novy <jnovy@redhat.com> 4.2.0.a.20050816-1
+- update to the latest stable 4.2.0.a.20050816
+- drop upstreamed .gcc4, .vsnprintf patches
+- remove obsolete .autofoo patch
+- make patch numbering less chaotic
+- don't package backup for .droproot patch
+
+* Thu Apr 14 2005 Jiri Ryska <jryska@redhat.com> 4.2.0.a.20040617-8
+- fixed gid setting when ntpd started with -u flag (#147743)
+
+* Tue Mar 08 2005 Jiri Ryska <jryska@redhat.com> 4.2.0.a.20040617-7
+- removed -Werror
+- patched for gcc4 and rebuilt
+
+* Wed Jan 12 2005 Tim Waugh <twaugh@redhat.com> - 4.2.0.a.20040617-6
+- Rebuilt for new readline.
+
+* Mon Dec 13 2004 Harald Hoyer <harald@redhat.com> - 4.2.0.a.20040617-5
+- patched ntp to build with -D_FORTIFYSOURCE=2 -Wall -Wextra -Werror
+
+* Mon Oct 11 2004 Harald Hoyer <harald@redhat.com> - 4.2.0.a.20040617-4
+- removed firewall hole punching from the initscript; rely on iptables
+  ESTABLISHED,RELATED or manual firewall configuration
+
+* Fri Oct  8 2004 Harald Hoyer <harald@redhat.com> - 4.2.0.a.20040617-3
+- improved postsection
+- BuildRequires readline-devel
+- PreReq grep
+
+* Thu Sep 30 2004 Harald Hoyer <harald@redhat.com> - 4.2.0.a.20040617-2
+- set pool.ntp.org as the default timeserver pool
+
+* Mon Sep 13 2004 Harald Hoyer <harald@redhat.com> - 4.2.0.a.20040617-1
+- version ntp-stable-4.2.0a-20040617
+
+* Tue Aug 17 2004 Harald Hoyer <harald@redhat.com> - 4.2.0.a.20040616-4
+- added ntp-4.2.0-sbinpath.patch (bug 130536)
+
+* Tue Aug 17 2004 Harald Hoyer <harald@redhat.com> - 4.2.0.a.20040616-3
+- added ntp-stable-4.2.0a-20040616-groups.patch (bug 130112)
+
+* Thu Jul 29 2004 Harald Hoyer <harald@redhat.com> - 4.2.0.a.20040616-2
+- take chroot in account (bug 127252)
+
+* Fri Jul 23 2004 Harald Hoyer <harald@redhat.com> - 4.2.0.a.20040616-1
+- new version ntp-stable-4.2.0a-20040616
+- removed most patches
+
+* Tue Jun 15 2004 Elliot Lee <sopwith@redhat.com>
+- rebuilt
+
+* Thu Mar 11 2004 Harald Hoyer <harald@redhat.com> - 4.2.0-7
+- ntpgenkey fixed (117378)
+- fixed initscript to call ntpdate with -U (117894)
+
+* Fri Feb 13 2004 Elliot Lee <sopwith@redhat.com>
+- rebuilt
+
+* Wed Jan 28 2004 Harald Hoyer <harald@faro.stuttgart.redhat.com> - 4.2.0-5
+- readded ntp-wait and ntptrace
+- new filter-requires to prevent perl dependency
+
+* Mon Jan 26 2004 Harald Hoyer <harald@redhat.de> 4.2.0-4
+- added autofoo patch
+
+* Tue Oct 28 2003 Harald Hoyer <harald@redhat.de> 4.2.0-3
+- removed libmd5 dependency
+- removed perl dependency
+
+* Tue Oct 28 2003 Harald Hoyer <harald@redhat.de> 4.2.0-2
+- fixed initscript to use new FW chain name
+
+* Mon Oct 27 2003 Harald Hoyer <harald@redhat.de> 4.2.0-1
+- 4.2.0
+- added PIE
+
+* Thu Sep 11 2003 Harald Hoyer <harald@redhat.de> 4.1.2-4
+- changed ntp.conf driftfile path #104207
+
+* Fri Aug 29 2003 Florian La Roche <Florian.LaRoche@redhat.de>
+- also build as non-root
+
+* Thu Aug 28 2003 Harald Hoyer <harald@redhat.de> 0:4.1.2-2
+- added ntpstat
+- added manpages
+
+* Wed Jul 01 2003 Harald Hoyer <harald@redhat.de> 0:4.1.2-1.rc3.5
+- move driftfile to /var
+
+* Wed Jul 01 2003 Harald Hoyer <harald@redhat.de> 0:4.1.2-1.rc3.4
+- make a seperate directory for drift
+- security fix, patch ntp-4.1.1c-rc3-authkey.patch #96927
+* Wed Jun 18 2003 Harald Hoyer <harald@redhat.de> 0:4.1.2-1.rc3.3
+- %%{_sysconfdir}/ntp/drift.TEMP needs to be writable by ntp #97754
+- no duplicate fw entries #97624
+
+* Wed Jun 18 2003 Harald Hoyer <harald@redhat.de> 0:4.1.2-1.rc3.2
+- changed permissions of config files  
+
+* Tue Jun 17 2003 Harald Hoyer <harald@redhat.de> 0:4.1.2-1.rc3.1
+- updated to rc3 
+
+* Wed Jun 04 2003 Elliot Lee <sopwith@redhat.com>
+- rebuilt
+
+* Thu May 22 2003 Harald Hoyer <harald@redhat.de> 0:4.1.2-0.rc2.2
+- corrected pid file name in %%{_sysconfdir}/sysconfig/ntpd
+
+* Tue Apr 28 2003 Harald Hoyer <harald@redhat.de> 0:4.1.2-0.rc2.1
+- update to 4.1.1rc2
+
+* Tue Feb 25 2003 Harald Hoyer <harald@redhat.de> 0:4.1.2-0.rc1.3
+- better awk for timeservers #85090, #82713, #82714
+
+* Thu Feb 13 2003 Harald Hoyer <harald@redhat.de> 0:4.1.2-0.rc1.2
+- added loopfilter patch, -x should work now!
+- removed slew warning
+
+* Mon Feb 10 2003 Harald Hoyer <harald@redhat.de> 1:4.1.1-2
+- ok, messed up with the versions... added epoch :(
+
+* Fri Feb 07 2003 Harald Hoyer <harald@redhat.de> 4.1.1-1
+- going back to stable 4.1.1 with the limit patch
+- added limit patch
+- added slew warning
+
+* Thu Jan 30 2003 Harald Hoyer <harald@redhat.de> 4.1.73-2
+- removed exit on ntpdate fail, better add '-g' option
+
+* Wed Jan 29 2003 Harald Hoyer <harald@redhat.de> 4.1.73-1
+- update to version 4.1.73
+- removed most of the patches
+- limit ntp_adjtime parameters
+
+* Wed Jan 22 2003 Tim Powers <timp@redhat.com>
+- rebuilt
+
+* Wed Nov 20 2002 Harald Hoyer <harald@redhat.de> 4.1.1b-1
+- updated to version 4.1.1b
+- improved initscript - use ntpdate on -x
+- improved initscript - open firewall only for timeservers
+- ntp-4.1.1a-adjtime.patch removed (already in source)
+- ntp-4.1.1a-mfp.patch removed (already in source)
+- ntp-4.0.99j-vsnprintf.patch removed (already in source)
+
+* Tue Nov 19 2002 Harald Hoyer <harald@redhat.de> 4.1.1a-12
+- added adjtime patch #75558
+
+* Wed Nov 13 2002 Harald Hoyer <harald@redhat.de>
+- more ntpd.init service description #77715
+
+* Mon Nov 11 2002 Harald Hoyer <harald@redhat.de>
+- ntp-4.1.1a-mfp.patch fixes #77086
+
+* Sat Aug 31 2002 Florian La Roche <Florian.LaRoche@redhat.de>
+- add option -n to initscript to avoid DNS lookups #72756
+
+* Fri Aug 23 2002 Jeremy Katz <katzj@redhat.com>
+- service should fail to start ntpd if running ntpdate fails
+
+* Tue Aug 20 2002 Harald Hoyer <harald@redhat.de>
+- added two more 'echo's in the initscript
+
+* Thu Aug 15 2002 Harald Hoyer <harald@redhat.de>
+- added firewall opener in initscript
+
+* Tue Jul 23 2002 Harald Hoyer <harald@redhat.de>
+- removed libelf dependency
+- removed stripping
+
+* Fri Jun 21 2002 Tim Powers <timp@redhat.com>
+- automated rebuild
+
+* Tue Jun 11 2002 Harald Hoyer <harald@redhat.de> 4.1.1a-3
+- refixed #46464
+- another genkeys/snprintf bugfix
+
+* Wed May 22 2002 Harald Hoyer <harald@redhat.de> 4.1.1a-1
+- update to version 4.1.1a
+
+* Mon Apr 08 2002 Harald Hoyer <harald@redhat.de> 4.1.1-1
+- update to 4.1.1 (changes are minimal)
+- more examples in default configuration
+
+* Tue Apr 02 2002 Harald Hoyer <harald@redhat.de> 4.1.0b-6
+- more secure default configuration (#62238)
+
+* Mon Jan 28 2002 Harald Hoyer <harald@redhat.de> 4.1.0b-5
+- more regex magic for the grep (#57837)
+
+* Mon Jan 28 2002 Harald Hoyer <harald@redhat.de> 4.1.0b-4
+- created drift with dummy value #58294
+- grep for timeservers in ntp.conf also for ntpdate #57837
+- check return value of ntpdate #58836
+
+* Wed Jan 09 2002 Tim Powers <timp@redhat.com> 4.1.0b-3
+- automated rebuild
+
+* Tue Jan 08 2002 Harald Hoyer <harald@redhat.de> 4.1.0b-2
+- added --enable-all-clocks --enable-parse-clocks (#57761)
+
+* Tue Dec 13 2001 Harald Hoyer <harald@redhat.de> 4.1.0b-1
+- bumped version
+- fixed #57391, #44580
+- set startup position to 58 after named
+
+* Wed Sep 05 2001 Harald Hoyer <harald@redhat.de> 4.1.0-4
+- fixed #53184
+
+* Tue Sep 04 2001 Harald Hoyer <harald@redhat.de> 4.1.0-3
+- fixed #53089 /bin/nologin -> /sbin/nologin
+
+* Fri Aug 31 2001 Harald Hoyer <harald@redhat.de> 4.1.0-2
+- fixed #50247 thx to <enrico.scholz@informatik.tu-chemnitz.de>
+
+* Thu Aug 30 2001 Harald Hoyer <harald@redhat.de> 4.1.0-1
+- wow, how stupid can a man be ;).. fixed #50698 
+- updated to 4.1.0 (changes are small and in non-critical regions)
+
+* Wed Aug 29 2001 Harald Hoyer <harald@redhat.de> 4.0.99mrc2-5
+- really, really :) fixed #52763, #50698 and #50526
+
+* Mon Aug 27 2001 Tim Powers <timp@redhat.com> 4.0.99mrc2-4
+- rebuilt against newer libcap
+- Copyright -> license
+
+* Wed Jul 25 2001 Harald Hoyer <harald@redhat.com> 4.0.99mrc2-3
+- integrated droproot patch (#35653)
+- removed librt and libreadline dependency 
+
+* Sat Jul  7 2001 Tim Powers <timp@redhat.com>
+- don't build build sgid root dirs
+
+* Mon Jun 18 2001 Harald Hoyer <harald@redhat.de>
+- new snapshot
+- removed typos and security patch (already there)
+- commented multicastclient in config file
+
+* Thu Jun 07 2001 Florian La Roche <Florian.LaRoche@redhat.de>
+- call libtoolize to compile on newer archs
+
+* Mon Apr  9 2001 Preston Brown <pbrown@redhat.com>
+- remove ghost files make RHN happy
+- modify initscript to match accordingly
+
+* Fri Apr  6 2001 Pekka Savola <pekkas@netcore.fi>
+- Add the remote root exploit patch (based on ntp-hackers).
+- Enhance droproot patch (more documentation, etc.) <Jarno.Huuskonen@uku.fi>
+- Tweak the droproot patch to include sys/prctl.h, not linux/prctl.h
+(implicit declarations)
+- Remote groupdel commands, shouldn't be needed.
+- Removed -Wcast-qual and -Wconversion due to excessive warnings (hackish).
+- Make ntp compilable with both glibc 2.1 and 2.2.x (very dirty hack)
+- Add %%{_sysconfdir}/sysconfig/ntpd which drops root privs by default
+
+* Thu Apr  5 2001 Preston Brown <pbrown@redhat.com>
+- security patch for ntpd
+
+* Mon Mar 26 2001 Preston Brown <pbrown@redhat.com>
+- don't run configure macro twice (#32804)
+
+* Sun Mar 25 2001 Pekka Savola <pekkas@netcore.fi>
+- require/buildprereq libcap/libcap-devel
+- use 'ntp' user, tune the pre/post scripts, %%files
+- add $OPTIONS to the init script
+
+* Tue Mar 20 2001 Jarno Huuskonen <Jarno.Huuskonen@uku.fi>
+- droproot/caps patch
+- add ntpd user in pre
+- make %%{_sysconfdir}/ntp ntpd writable
+
+* Mon Mar  5 2001 Preston Brown <pbrown@redhat.com>
+- allow comments in %%{_sysconfdir}/ntp/step-tickers file (#28786).
+- need patch0 (glibc patch) on ia64 too
+
+* Tue Feb 13 2001 Florian La Roche <Florian.LaRoche@redhat.de>
+- also set prog=ntpd in initscript
+
+* Tue Feb 13 2001 Florian La Roche <Florian.LaRoche@redhat.de>
+- use "$prog" instead of "$0" for the init script
+
+* Thu Feb  8 2001 Preston Brown <pbrown@redhat.com>
+- i18n-neutral .init script (#26525)
+
+* Tue Feb  6 2001 Preston Brown <pbrown@redhat.com>
+- use gethostbyname on addresses in %%{_sysconfdir}/ntp.conf for ntptime command (#26250)
+
+* Mon Feb  5 2001 Preston Brown <pbrown@redhat.com>
+- start earlier and stop later (#23530)
+
+* Mon Feb  5 2001 Bernhard Rosenkraenzer <bero@redhat.com>
+- i18nize init script (#26078)
+
+* Sat Jan  6 2001 Jeff Johnson <jbj@redhat.com>
+- typo in ntp.conf (#23173).
+
+* Mon Dec 11 2000 Karsten Hopp <karsten@redhat.de>
+- rebuilt to fix permissions of /usr/share/doc/ntp-xxx
+
+* Thu Nov  2 2000 Jeff Johnson <jbj@redhat.com>
+- correct mis-spellings in ntpq.htm (#20007).
+
+* Thu Oct 19 2000 Jeff Johnson <jbj@redhat.com>
+- add %%ghost %%{_sysconfdir}/ntp/drift (#15222).
+
+* Wed Oct 18 2000 Jeff Johnson <jbj@redhat.com>
+- comment out default values for keys, warn about starting with -A (#19316).
+- take out -A from ntpd startup as well.
+- update to 4.0.99k.
+
+* Wed Aug 23 2000 Jeff Johnson <jbj@redhat.com>
+- use vsnprintf rather than vsprintf (#16676).
+
+* Mon Aug 14 2000 Jeff Johnson <jbj@redhat.com>
+- remove Conflicts: so that the installer is happy.
+
+* Tue Jul 25 2000 Jeff Johnson <jbj@redhat.com>
+- workaround glibc-2.1.90 lossage for now.
+
+* Thu Jul 20 2000 Bill Nottingham <notting@redhat.com>
+- move initscript back
+
+* Wed Jul 12 2000 Prospector <bugzilla@redhat.com>
+- automatic rebuild
+
+* Mon Jun 26 2000 Preston Brown <pbrown@redhat.com>
+- move and update init script, update post/preun/postun scripts
+
+* Wed Jun 21 2000 Preston Brown <pbrown@redhat.com>
+- noreplace ntp.conf,keys files
+
+* Mon Jun 12 2000 Jeff Johnson <jbj@redhat.com>
+- Create 4.0.99j package.
+- FHS packaging.
diff --git a/packaging/ntp.conf b/packaging/ntp.conf
new file mode 100644 (file)
index 0000000..c9a21d7
--- /dev/null
@@ -0,0 +1,55 @@
+# For more information about this file, see the man pages
+# ntp.conf(5), ntp_acc(5), ntp_auth(5), ntp_clock(5), ntp_misc(5), ntp_mon(5).
+
+driftfile VARNTP/drift
+
+# Permit time synchronization with our time source, but do not
+# permit the source to query or modify the service on this system.
+restrict default kod nomodify notrap nopeer noquery
+restrict -6 default kod nomodify notrap nopeer noquery
+
+# Permit all access over the loopback interface.  This could
+# be tightened as well, but to do so would effect some of
+# the administrative functions.
+restrict 127.0.0.1 
+restrict -6 ::1
+
+# Hosts on local network are less restricted.
+#restrict 192.168.1.0 mask 255.255.255.0 nomodify notrap
+
+# Use public servers from the pool.ntp.org project.
+# Please consider joining the pool (http://www.pool.ntp.org/join.html).
+server ntp.meego.com
+
+#broadcast 192.168.1.255 autokey       # broadcast server
+#broadcastclient                       # broadcast client
+#broadcast 224.0.1.1 autokey           # multicast server
+#multicastclient 224.0.1.1             # multicast client
+#manycastserver 239.255.254.254                # manycast server
+#manycastclient 239.255.254.254 autokey # manycast client
+
+# Undisciplined Local Clock. This is a fake driver intended for backup
+# and when no outside source of synchronized time is available. 
+#server        127.127.1.0     # local clock
+#fudge 127.127.1.0 stratum 10  
+
+# Enable public key cryptography.
+#crypto
+
+includefile ETCNTP/crypto/pw
+
+# Key file containing the keys and key identifiers used when operating
+# with symmetric key cryptography. 
+keys ETCNTP/keys
+
+# Specify the key identifiers which are trusted.
+#trustedkey 4 8 42
+
+# Specify the key identifier to use with the ntpdc utility.
+#requestkey 8
+
+# Specify the key identifier to use with the ntpq utility.
+#controlkey 8
+
+# Enable writing of statistics records.
+#statistics clockstats cryptostats loopstats peerstats
diff --git a/packaging/ntp.cryptopw b/packaging/ntp.cryptopw
new file mode 100644 (file)
index 0000000..b76b0ca
--- /dev/null
@@ -0,0 +1,4 @@
+# Specify the password to decrypt files containing private keys and identity
+# parameters.  This is required only if these files have been encrypted.
+#
+#crypto pw apassword
diff --git a/packaging/ntp.dhclient b/packaging/ntp.dhclient
new file mode 100644 (file)
index 0000000..04e1a71
--- /dev/null
@@ -0,0 +1,59 @@
+#!/bin/bash
+#
+# ntp.sh: dhclient-script plugin for NTP settings,
+#         place in /etc/dhcp/dhclient.d and 'chmod +x ntp.sh' to enable
+#
+# Copyright (C) 2008 Red Hat, Inc.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
+#
+# Author(s): David Cantrell <dcantrell@redhat.com>
+#            Miroslav Lichvar <mlichvar@redhat.com>
+#
+
+CONF=/etc/ntp.conf
+SAVECONF=${SAVEDIR}/${CONF##*/}.predhclient.${interface}
+
+ntp_replace_conf() {
+        echo "$1" | diff -q ${CONF} - > /dev/null 2>&1
+        if [ $? -eq 1 ]; then
+            echo "$1" > ${CONF}
+            restorecon ${CONF} >/dev/null 2>&1
+            service ntpd condrestart >/dev/null 2>&1
+        fi
+}
+
+ntp_config() {
+    if [ ! "${PEERNTP}" = "no" ] && [ -n "${new_ntp_servers}" ] &&
+        [ -e ${CONF} ] && [ -d ${SAVEDIR} ]; then
+        local conf=$(egrep -v '^server .*  # added by /sbin/dhclient-script$' < ${CONF})
+
+        conf=$(echo "$conf"
+            for s in ${new_ntp_servers}; do
+                echo "server ${s}  # added by /sbin/dhclient-script"
+            done)
+
+        [ -f ${SAVECONF} ] || touch ${SAVECONF}
+        ntp_replace_conf "$conf"
+    fi
+}
+
+ntp_restore() {
+    if [ -e ${CONF} ] && [ -f ${SAVECONF} ]; then
+        local conf=$(egrep -v '^server .*  # added by /sbin/dhclient-script$' < ${CONF})
+
+        ntp_replace_conf "$conf"
+        rm -f ${SAVECONF}
+    fi
+}
diff --git a/packaging/ntp.keys b/packaging/ntp.keys
new file mode 100644 (file)
index 0000000..5500a71
--- /dev/null
@@ -0,0 +1,5 @@
+#
+# PLEASE DO NOT USE THE DEFAULT VALUES HERE.
+#
+#65535 M       akey
+#1     M       pass
diff --git a/packaging/ntp.spec b/packaging/ntp.spec
new file mode 100644 (file)
index 0000000..2e54ad7
--- /dev/null
@@ -0,0 +1,327 @@
+Summary: The NTP daemon and utilities
+Name: ntp
+Version: 4.2.4p8
+Release: 1
+# primary license (COPYRIGHT) : MIT
+# ElectricFence/ (not used) : GPLv2
+# kernel/sys/ppsclock.h (not used) : BSD with advertising
+# include/ntif.h (not used) : BSD
+# include/rsa_md5.h : BSD with advertising
+# include/ntp_rfc2553.h : BSD with advertising
+# libisc/inet_aton.c (not used) : BSD with advertising
+# libntp/md5c.c : BSD with advertising
+# libntp/mktime.c : BSD with advertising
+# libntp/ntp_random.c : BSD with advertising
+# libntp/memmove.c : BSD with advertising
+# libntp/ntp_rfc2553.c : BSD with advertising
+# libntp/adjtimex.c (not used) : BSD
+# libopts/ : BSD or GPLv2+
+# libparse/ : BSD
+# ntpd/refclock_jjy.c: MIT
+# ntpd/refclock_oncore.c : BEERWARE License (aka, Public Domain)
+# ntpd/refclock_palisade.c : BSD with advertising
+# ntpd/refclock_jupiter.c : BSD with advertising
+# ntpd/refclock_mx4200.c : BSD with advertising
+# ntpd/refclock_palisade.h : BSD with advertising
+# ntpstat-0.2/ : GPLv2
+# util/ansi2knr.c (not used) : GPL+
+# sntp/ (not packaged) : MSNTP
+License: (MIT and BSD and BSD with advertising) and GPLv2
+Group: System Environment/Daemons
+Source0: %{name}-%{version}.tar.bz2
+Source1: ntp.conf
+Source2: ntp.keys
+Source4: ntpd.sysconfig
+Source5: ntpstat-0.2.tgz
+Source6: ntp.step-tickers
+Source8: ntp.cryptopw
+Source9: ntpdate.sysconfig
+Source10: ntp.dhclient
+
+# ntpbz #628, #1073
+Patch1: ntp-4.2.4p4-kernel.patch
+# add support for dropping root to ntpdate
+Patch2: ntp-4.2.4p0-droproot.patch
+# ntpbz #812
+Patch3: ntp-4.2.4-groups.patch
+# ntpbz #1170
+Patch4: ntp-4.2.4p7-daemonpll.patch
+# link ntpd with -ffast-math on ia64
+Patch5: ntp-4.2.4-linkfastmath.patch
+# ntpbz #1134
+Patch6: ntp-4.2.4p2-tentative.patch
+# ntpbz #897
+Patch7: ntp-4.2.4p2-noseed.patch
+# ntpbz #830
+Patch8: ntp-4.2.4p4-multilisten.patch
+# fix script used to generate man pages
+Patch9: ntp-4.2.4-html2man.patch
+# ntpbz #898
+Patch10: ntp-4.2.4p5-htmldoc.patch
+# fixed in 4.2.5
+Patch11: ntp-4.2.4p2-filegen.patch
+# ntpbz #738
+Patch12: ntp-4.2.4-sprintf.patch
+# use editline instead of readline
+Patch13: ntp-4.2.4p8-editline.patch
+# add option -m to lock memory
+Patch14: ntp-4.2.4p8-mlock.patch
+# fixed in 4.2.5
+Patch15: ntp-4.2.4p2-clockselect.patch
+# don't build sntp
+Patch16: ntp-4.2.4p8-nosntp.patch
+# ntpbz #802
+Patch17: ntp-4.2.4p7-sleep.patch
+# ntpbz #779, #823
+Patch18: ntp-4.2.4p7-bcast.patch
+# ntpbz #759
+Patch19: ntp-4.2.4p0-retcode.patch
+# ntpbz #397
+Patch20: ntp-4.2.4p2-noif.patch
+# force IPv6 support
+Patch21: ntp-4.2.4p7-ipv6.patch
+# align buffer for control messages
+Patch22: ntp-4.2.4p4-cmsgalign.patch
+# force use of clock_gettime
+Patch23: ntp-4.2.4p8-gettime.patch
+# reload resolv.conf after failure in name resolution
+Patch24: ntp-4.2.4p4-resinit.patch
+# ntpbz #992
+Patch25: ntp-4.2.4p5-rtnetlink.patch
+# don't log STA_MODE (PLL/FLL) changes
+Patch26: ntp-4.2.4p7-stamode.patch
+# ntpbz #808
+Patch27: ntp-4.2.4p5-driftonexit.patch
+# add missing nanokernel macros
+Patch28: ntp-4.2.4p7-nano.patch
+# allow minpoll 3 as in 4.2.5
+Patch29: ntp-4.2.4p7-minpoll.patch
+# fix frequency mode, backported from 4.2.5
+Patch30: ntp-4.2.4p7-freqmode.patch
+# handle unknown clock types
+Patch31: ntpstat-0.2-clksrc.patch
+# process first packet in multipacket response
+Patch32: ntpstat-0.2-multipacket.patch
+
+URL: http://www.ntp.org
+Requires: ntpdate = %{version}-%{release}
+BuildRequires: pkgconfig(openssl)
+BuildRequires: libcap-devel libedit-devel perl-HTML-Parser
+
+%description
+The Network Time Protocol (NTP) is used to synchronize a computer's
+time with another reference time source. This package includes ntpd
+(a daemon which continuously adjusts system time) and utilities used
+to query and configure the ntpd daemon.
+
+Perl scripts ntp-wait and ntptrace are in the ntp-perl package and
+the ntpdate program is in the ntpdate package. The documentation is
+in the ntp-doc package.
+
+%package perl
+Summary: NTP utilities written in perl
+Group: Applications/System
+Requires: %{name} = %{version}-%{release}
+# perl introduced in 4.2.4p4-7
+Obsoletes: %{name} < 4.2.4p4-7
+%description perl
+This package contains perl scripts ntp-wait and ntptrace.
+%package -n ntpdate
+Summary: Utility to set the date and time via NTP
+Group: Applications/System
+Requires(pre): /usr/sbin/groupadd
+Requires(pre): /usr/sbin/useradd
+
+%description -n ntpdate
+ntpdate is a program for retrieving the date and time from
+NTP servers.
+
+%package doc
+Summary: NTP documentation
+Group: Documentation
+Requires: %{name} = %{version}-%{release}
+BuildArch: noarch
+%description doc
+This package contains NTP documentation in HTML format.
+%define ntpdocdir %{_datadir}/doc/%{name}-%{version}
+
+# pool.ntp.org vendor zone which will be used in ntp.conf
+%if 0%{!?vendorzone:1}
+%define vendorzone meego.
+%endif
+
+%prep 
+%setup -q -a 5 -n %{name}-%{version}
+
+%patch1 -p1 -b .kernel
+%patch2 -p1 -b .droproot
+%patch3 -p1 -b .groups
+%patch4 -p1 -b .daemonpll
+%patch6 -p1 -b .tentative
+%patch7 -p1 -b .noseed
+%patch8 -p1 -b .multilisten
+%patch9 -p1 -b .html2man
+%patch10 -p1 -b .htmldoc
+%patch11 -p1 -b .filegen
+%patch12 -p1 -b .sprintf
+%patch13 -p1 -b .editline
+%patch14 -p1 -b .mlock
+%patch15 -p1 -b .clockselect
+%patch16 -p1 -b .nosntp
+%patch17 -p1 -b .sleep
+%patch18 -p1 -b .bcast
+%patch19 -p1 -b .retcode
+%patch20 -p1 -b .noif
+%patch21 -p1 -b .ipv6
+%patch22 -p1 -b .cmsgalign
+%patch24 -p1 -b .resinit
+%patch25 -p1 -b .rtnetlink
+%patch26 -p1 -b .stamode
+%patch27 -p1 -b .driftonexit
+%patch28 -p1 -b .nano
+%patch29 -p1 -b .minpoll
+%patch30 -p1 -b .freqmode
+%patch31 -p1 -b .clksrc
+%patch32 -p1 -b .multipacket
+
+# clock_gettime needs -lrt
+sed -i.gettime 's|^LIBS = @LIBS@|& -lrt|' ntp{d,q,dc,date}/Makefile.in
+%patch23 -p1 -b .gettime
+
+%ifarch ia64
+%patch5 -p1 -b .linkfastmath
+%endif
+
+for f in COPYRIGHT; do
+       iconv -f iso8859-1 -t utf8 -o ${f}{_,} && touch -r ${f}{,_} && mv -f ${f}{_,}
+done
+
+%build
+export CFLAGS="$RPM_OPT_FLAGS -fno-strict-aliasing"
+if echo 'int main () { return 0; }' | gcc -pie -fPIE -O2 -xc - -o pietest 2>/dev/null; then
+       ./pietest && export CFLAGS="$CFLAGS -pie -fPIE"
+       rm -f pietest
+fi
+%configure \
+       --sysconfdir=%{_sysconfdir}/ntp/crypto \
+       --with-openssl-libdir=%{_libdir} \
+       --enable-all-clocks --enable-parse-clocks \
+       --enable-linuxcaps
+echo '#define KEYFILE "%{_sysconfdir}/ntp/keys"' >> ntpdate/ntpdate.h
+echo '#define NTP_VAR "%{_localstatedir}/log/ntpstats/"' >> config.h
+
+make %{?_smp_mflags}
+
+sed -i 's|$ntpq = "ntpq"|$ntpq = "%{_sbindir}/ntpq"|' scripts/ntptrace
+sed -i 's|ntpq -c |%{_sbindir}/ntpq -c |' scripts/ntp-wait
+
+pushd html
+../scripts/html2man
+# remove adjacent blank lines
+sed -i 's/^[\t\ ]*$//;/./,/^$/!d' man/man*/*.[58]
+popd 
+
+make -C ntpstat-0.2 CFLAGS="$CFLAGS"
+
+%install
+rm -rf $RPM_BUILD_ROOT
+
+make DESTDIR=$RPM_BUILD_ROOT bindir=%{_sbindir} install
+
+mkdir -p $RPM_BUILD_ROOT%{_mandir}/man{5,8}
+rm -rf $RPM_BUILD_ROOT%{_mandir}/man1
+
+pushd ntpstat-0.2
+mkdir -p $RPM_BUILD_ROOT%{_bindir}
+install -m 755 ntpstat $RPM_BUILD_ROOT%{_bindir}
+install -m 644 ntpstat.1 $RPM_BUILD_ROOT%{_mandir}/man8/ntpstat.8
+popd
+
+# fix section numbers
+sed -i 's/\(\.TH[a-zA-Z ]*\)[1-9]\(.*\)/\18\2/' $RPM_BUILD_ROOT%{_mandir}/man8/*.8
+cp -r html/man/man[58] $RPM_BUILD_ROOT%{_mandir}
+
+mkdir -p $RPM_BUILD_ROOT%{ntpdocdir}
+cp -p COPYRIGHT ChangeLog NEWS $RPM_BUILD_ROOT%{ntpdocdir}
+
+# prepare html documentation
+find html | egrep '\.(html|css|txt|jpg|gif)$' | grep -v '/build/\|sntp' | \
+       cpio -pmd $RPM_BUILD_ROOT%{ntpdocdir}
+find $RPM_BUILD_ROOT%{ntpdocdir} -type f | xargs chmod 644
+find $RPM_BUILD_ROOT%{ntpdocdir} -type d | xargs chmod 755
+
+pushd $RPM_BUILD_ROOT
+mkdir -p .%{_sysconfdir}/{ntp/crypto,sysconfig,dhcp/dhclient.d}
+mkdir -p .%{_localstatedir}/{lib/ntp,log/ntpstats}
+touch .%{_localstatedir}/lib/ntp/drift
+sed -e 's|VENDORZONE\.|%{vendorzone}|' \
+       -e 's|ETCNTP|%{_sysconfdir}/ntp|' \
+       -e 's|VARNTP|%{_localstatedir}/lib/ntp|' \
+       < %{SOURCE1} > .%{_sysconfdir}/ntp.conf
+touch -r %{SOURCE1} .%{_sysconfdir}/ntp.conf
+install -p -m600 %{SOURCE2} .%{_sysconfdir}/ntp/keys
+install -p -m644 %{SOURCE4} .%{_sysconfdir}/sysconfig/ntpd
+install -p -m644 %{SOURCE9} .%{_sysconfdir}/sysconfig/ntpdate
+install -p -m644 %{SOURCE6} .%{_sysconfdir}/ntp/step-tickers
+install -p -m600 %{SOURCE8} .%{_sysconfdir}/ntp/crypto/pw
+install -p -m755 %{SOURCE10} .%{_sysconfdir}/dhcp/dhclient.d/ntp.sh
+popd
+
+%clean
+rm -rf $RPM_BUILD_ROOT
+
+%pre -n ntpdate
+/usr/sbin/groupadd -g 38 ntp  2> /dev/null || :
+/usr/sbin/useradd -u 38 -g 38 -s /sbin/nologin -M -r -d %{_sysconfdir}/ntp ntp 2>/dev/null || :
+
+%files
+%defattr(-,root,root)
+%dir %{ntpdocdir}
+%{ntpdocdir}/COPYRIGHT
+%{ntpdocdir}/ChangeLog
+%{ntpdocdir}/NEWS
+%{_sbindir}/ntp-keygen
+%{_sbindir}/ntpd
+%{_sbindir}/ntpdc
+%{_sbindir}/ntpq
+%{_sbindir}/ntptime
+%{_sbindir}/tickadj
+%config(noreplace) %{_sysconfdir}/sysconfig/ntpd
+%config(noreplace) %{_sysconfdir}/ntp.conf
+%dir %attr(750,root,ntp) %{_sysconfdir}/ntp/crypto
+%config(noreplace) %{_sysconfdir}/ntp/crypto/pw
+%dir %{_sysconfdir}/dhcp/dhclient.d
+%{_sysconfdir}/dhcp/dhclient.d/ntp.sh
+%dir %attr(-,ntp,ntp) %{_localstatedir}/lib/ntp
+%ghost %attr(644,ntp,ntp) %{_localstatedir}/lib/ntp/drift
+%dir %attr(-,ntp,ntp) %{_localstatedir}/log/ntpstats
+%{_bindir}/ntpstat
+%{_mandir}/man5/*.5*
+%{_mandir}/man8/ntp-keygen.8*
+%{_mandir}/man8/ntpd.8*
+%{_mandir}/man8/ntpdc.8*
+%{_mandir}/man8/ntpq.8*
+%{_mandir}/man8/ntpstat.8*
+%{_mandir}/man8/ntptime.8*
+
+%files perl
+%defattr(-,root,root)
+%{_sbindir}/ntp-wait
+%{_sbindir}/ntptrace
+%{_mandir}/man8/ntptrace.8*
+
+%files -n ntpdate
+%defattr(-,root,root)
+%config(noreplace) %{_sysconfdir}/sysconfig/ntpdate
+%dir %{_sysconfdir}/ntp
+%config(noreplace) %{_sysconfdir}/ntp/keys
+%config(noreplace) %verify(not md5 size mtime) %{_sysconfdir}/ntp/step-tickers
+%{_sbindir}/ntpdate
+%{_mandir}/man8/ntpdate.8*
+
+%files doc
+%defattr(-,root,root)
+%{ntpdocdir}/html
+
diff --git a/packaging/ntp.step-tickers b/packaging/ntp.step-tickers
new file mode 100644 (file)
index 0000000..92b33c9
--- /dev/null
@@ -0,0 +1 @@
+# List of servers used for initial synchronization.
diff --git a/packaging/ntpd.sysconfig b/packaging/ntpd.sysconfig
new file mode 100644 (file)
index 0000000..30dcfc3
--- /dev/null
@@ -0,0 +1,2 @@
+# Drop root to id 'ntp:ntp' by default.
+OPTIONS="-u ntp:ntp -p /var/run/ntpd.pid -g"
diff --git a/packaging/ntpdate.sysconfig b/packaging/ntpdate.sysconfig
new file mode 100644 (file)
index 0000000..667093a
--- /dev/null
@@ -0,0 +1,5 @@
+# Options for ntpdate
+OPTIONS="-U ntp -s -b"
+
+# Set to 'yes' to sync hw clock after successful ntpdate
+SYNC_HWCLOCK=no
diff --git a/packaging/ntpstat-0.2-clksrc.patch b/packaging/ntpstat-0.2-clksrc.patch
new file mode 100644 (file)
index 0000000..c427f1f
--- /dev/null
@@ -0,0 +1,12 @@
+diff -up ntp-4.2.4p7/ntpstat-0.2/ntpstat.c.ntpstat ntp-4.2.4p7/ntpstat-0.2/ntpstat.c
+--- ntp-4.2.4p7/ntpstat-0.2/ntpstat.c.ntpstat  2002-06-10 08:02:12.000000000 +0200
++++ ntp-4.2.4p7/ntpstat-0.2/ntpstat.c  2009-07-20 12:22:35.000000000 +0200
+@@ -187,7 +187,7 @@ int main (void) {
+     else
+       printf("unknown source");
+-    if (!strncmp(clksrcname[clksrc],clksrcname[6],sizeof(clksrcname[6]))) {
++    if (clksrc == 6) {
+       // source of sync is another NTP server so check the IP address
+       strncpy(buff, ntpmsg.payload, sizeof(buff));
+       if ((newstr = strstr (buff, REFID))) {
diff --git a/packaging/ntpstat-0.2-multipacket.patch b/packaging/ntpstat-0.2-multipacket.patch
new file mode 100644 (file)
index 0000000..ca21257
--- /dev/null
@@ -0,0 +1,12 @@
+diff -up ntp-4.2.4p7/ntpstat-0.2/ntpstat.c.ntpstat ntp-4.2.4p7/ntpstat-0.2/ntpstat.c
+--- ntp-4.2.4p7/ntpstat-0.2/ntpstat.c.ntpstat  2002-06-10 08:02:12.000000000 +0200
++++ ntp-4.2.4p7/ntpstat-0.2/ntpstat.c  2009-07-20 12:22:35.000000000 +0200
+@@ -151,7 +151,7 @@ int main (void) {
+   /* For the reply message to be valid, the first byte should be as sent, 
+      and the second byte should be the same, with the response bit set */
+   byte1ok = ((ntpmsg.byte1&0x3F) == B1VAL);
+-  byte2ok = (ntpmsg.byte2 == (B2VAL|RMASK));
++  byte2ok = ((ntpmsg.byte2 & ~MMASK) == (B2VAL|RMASK));
+   if (!(byte1ok && byte2ok)) {
+     fprintf (stderr,"status word is 0x%02x%02x\n", ntpmsg.byte1,ntpmsg.byte2 );
+     die ("return data appears to be invalid based on status word");
diff --git a/packaging/ntpstat-0.2.tgz b/packaging/ntpstat-0.2.tgz
new file mode 100644 (file)
index 0000000..37c439c
Binary files /dev/null and b/packaging/ntpstat-0.2.tgz differ
diff --git a/parseutil/Makefile.am b/parseutil/Makefile.am
new file mode 100644 (file)
index 0000000..01f6bd2
--- /dev/null
@@ -0,0 +1,13 @@
+#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+noinst_PROGRAMS = @TESTDCF@ @DCFD@
+EXTRA_PROGRAMS = testdcf dcfd
+INCLUDES = -I$(top_srcdir)/include
+ETAGS_ARGS = Makefile.am
+DISTCLEANFILES = $(EXTRA_PROGRAMS)
+#EXTRA_DIST= TAGS
+
+check-local: @DCFD@
+       case "$(noinst_PROGRAMS)" in    \
+        *dcfd*) ./dcfd -Y ;;           \
+       esac
diff --git a/parseutil/Makefile.in b/parseutil/Makefile.in
new file mode 100644 (file)
index 0000000..3f56f67
--- /dev/null
@@ -0,0 +1,524 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+ANSI2KNR = ../util/ansi2knr
+EXTRA_PROGRAMS = testdcf$(EXEEXT) dcfd$(EXEEXT)
+subdir = parseutil
+DIST_COMMON = README $(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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+PROGRAMS = $(noinst_PROGRAMS)
+dcfd_SOURCES = dcfd.c
+dcfd_OBJECTS = dcfd$U.$(OBJEXT)
+dcfd_LDADD = $(LDADD)
+testdcf_SOURCES = testdcf.c
+testdcf_OBJECTS = testdcf$U.$(OBJEXT)
+testdcf_LDADD = $(LDADD)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = dcfd.c testdcf.c
+DIST_SOURCES = dcfd.c testdcf.c
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+
+#AUTOMAKE_OPTIONS = ../util/ansi2knr no-dependencies
+AUTOMAKE_OPTIONS = ../util/ansi2knr
+noinst_PROGRAMS = @TESTDCF@ @DCFD@
+INCLUDES = -I$(top_srcdir)/include
+ETAGS_ARGS = Makefile.am
+DISTCLEANFILES = $(EXTRA_PROGRAMS)
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign parseutil/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign parseutil/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+
+clean-noinstPROGRAMS:
+       @list='$(noinst_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+dcfd$(EXEEXT): $(dcfd_OBJECTS) $(dcfd_DEPENDENCIES) 
+       @rm -f dcfd$(EXEEXT)
+       $(LINK) $(dcfd_OBJECTS) $(dcfd_LDADD) $(LIBS)
+testdcf$(EXEEXT): $(testdcf_OBJECTS) $(testdcf_DEPENDENCIES) 
+       @rm -f testdcf$(EXEEXT)
+       $(LINK) $(testdcf_OBJECTS) $(testdcf_LDADD) $(LIBS)
+
+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)/dcfd$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testdcf$U.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+dcfd_.c: dcfd.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/dcfd.c; then echo $(srcdir)/dcfd.c; else echo dcfd.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+testdcf_.c: testdcf.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/testdcf.c; then echo $(srcdir)/testdcf.c; else echo testdcf.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+dcfd_.$(OBJEXT) dcfd_.lo testdcf_.$(OBJEXT) testdcf_.lo : $(ANSI2KNR)
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+       $(MAKE) $(AM_MAKEFLAGS) check-local
+check: check-am
+all-am: Makefile $(PROGRAMS)
+installdirs:
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+       -test -z "$(DISTCLEANFILES)" || rm -f $(DISTCLEANFILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool clean-noinstPROGRAMS \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am:
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am:
+
+.MAKE: ../util/ansi2knr check-am install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am check-local clean \
+       clean-generic clean-libtool clean-noinstPROGRAMS 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
+
+#EXTRA_DIST= TAGS
+
+check-local: @DCFD@
+       case "$(noinst_PROGRAMS)" in    \
+        *dcfd*) ./dcfd -Y ;;           \
+       esac
+
+# 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.
+.NOEXPORT:
diff --git a/parseutil/README b/parseutil/README
new file mode 100644 (file)
index 0000000..8bc5140
--- /dev/null
@@ -0,0 +1,16 @@
+This directory contains some DCF77 related programs.
+They have not yet fully been ported to architectures other than Sun with
+SunOS 4.x.  So if you want to try them you are on your own - a little
+porting may be necessary.
+
+parsetest:     simple parse streams module test
+               Works only under SunOS with parse Streams Module loaded
+               and Meinberg-Clocks
+
+testdcf:       simple DCF77 raw impulse test program via 50Baud RS232
+
+dcfd:          simple DCF77 raw impulse receiver with NTP loopfilter
+               mechanics for synchronisation (allows DCF77 synchronisation
+               without network code in a nutshell)
+
+Frank Kardel
diff --git a/parseutil/dcfd.c b/parseutil/dcfd.c
new file mode 100644 (file)
index 0000000..c87ab35
--- /dev/null
@@ -0,0 +1,1903 @@
+/*
+ * /src/NTP/REPOSITORY/ntp4-dev/parseutil/dcfd.c,v 4.18 2005/10/07 22:08:18 kardel RELEASE_20051008_A
+ *  
+ * dcfd.c,v 4.18 2005/10/07 22:08:18 kardel RELEASE_20051008_A
+ *
+ * DCF77 100/200ms pulse synchronisation daemon program (via 50Baud serial line)
+ *
+ * Features:
+ *  DCF77 decoding
+ *  simple NTP loopfilter logic for local clock
+ *  interactive display for debugging
+ *
+ * Lacks:
+ *  Leap second handling (at that level you should switch to NTP Version 4 - really!)
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <signal.h>
+#include <syslog.h>
+#include <time.h>
+
+/*
+ * NTP compilation environment
+ */
+#include "ntp_stdlib.h"
+#include "ntpd.h"   /* indirectly include ntp.h to get YEAR_PIVOT   Y2KFixes */
+
+/*
+ * select which terminal handling to use (currently only SysV variants)
+ */
+#if defined(HAVE_TERMIOS_H) || defined(STREAM)
+#include <termios.h>
+#define TTY_GETATTR(_FD_, _ARG_) tcgetattr((_FD_), (_ARG_))
+#define TTY_SETATTR(_FD_, _ARG_) tcsetattr((_FD_), TCSANOW, (_ARG_))
+#else  /* not HAVE_TERMIOS_H || STREAM */
+# if defined(HAVE_TERMIO_H) || defined(HAVE_SYSV_TTYS)
+#  include <termio.h>
+#  define TTY_GETATTR(_FD_, _ARG_) ioctl((_FD_), TCGETA, (_ARG_))
+#  define TTY_SETATTR(_FD_, _ARG_) ioctl((_FD_), TCSETAW, (_ARG_))
+# endif/* HAVE_TERMIO_H || HAVE_SYSV_TTYS */
+#endif /* not HAVE_TERMIOS_H || STREAM */
+
+
+#ifndef TTY_GETATTR
+#include "Bletch: MUST DEFINE ONE OF 'HAVE_TERMIOS_H' or 'HAVE_TERMIO_H'"
+#endif
+
+#ifndef days_per_year
+#define days_per_year(_x_) (((_x_) % 4) ? 365 : (((_x_) % 400) ? 365 : 366))
+#endif
+
+#define timernormalize(_a_) \
+       if ((_a_)->tv_usec >= 1000000) \
+       { \
+               (_a_)->tv_sec  += (_a_)->tv_usec / 1000000; \
+               (_a_)->tv_usec  = (_a_)->tv_usec % 1000000; \
+       } \
+       if ((_a_)->tv_usec < 0) \
+       { \
+               (_a_)->tv_sec  -= 1 + (-(_a_)->tv_usec / 1000000); \
+               (_a_)->tv_usec = 999999 - (-(_a_)->tv_usec - 1); \
+       }
+
+#ifdef timeradd
+#undef timeradd
+#endif
+#define timeradd(_a_, _b_) \
+       (_a_)->tv_sec  += (_b_)->tv_sec; \
+       (_a_)->tv_usec += (_b_)->tv_usec; \
+       timernormalize((_a_))
+
+#ifdef timersub
+#undef timersub
+#endif
+#define timersub(_a_, _b_) \
+       (_a_)->tv_sec  -= (_b_)->tv_sec; \
+       (_a_)->tv_usec -= (_b_)->tv_usec; \
+       timernormalize((_a_))
+
+/*
+ * debug macros
+ */
+#define PRINTF if (interactive) printf
+#define LPRINTF if (interactive && loop_filter_debug) printf
+
+#ifdef DEBUG
+#define dprintf(_x_) LPRINTF _x_
+#else
+#define dprintf(_x_)
+#endif
+
+#ifdef DECL_ERRNO
+     extern int errno;
+#endif
+
+static char *revision = "4.18";
+
+/*
+ * display received data (avoids also detaching from tty)
+ */
+static int interactive = 0;
+
+/*
+ * display loopfilter (clock control) variables
+ */
+static int loop_filter_debug = 0;
+
+/*
+ * do not set/adjust system time
+ */
+static int no_set = 0;
+
+/*
+ * time that passes between start of DCF impulse and time stamping (fine
+ * adjustment) in microseconds (receiver/OS dependent)
+ */
+#define DEFAULT_DELAY  230000  /* rough estimate */
+
+/*
+ * The two states we can be in - eithe we receive nothing
+ * usable or we have the correct time
+ */
+#define NO_SYNC                0x01
+#define SYNC           0x02
+
+static int    sync_state = NO_SYNC;
+static time_t last_sync;
+
+static unsigned long ticks = 0;
+
+static char pat[] = "-\\|/";
+
+#define LINES          (24-2)  /* error lines after which the two headlines are repeated */
+
+#define MAX_UNSYNC     (10*60) /* allow synchronisation loss for 10 minutes */
+#define NOTICE_INTERVAL (20*60)        /* mention missing synchronisation every 20 minutes */
+
+/*
+ * clock adjustment PLL - see NTP protocol spec (RFC1305) for details
+ */
+
+#define USECSCALE      10
+#define TIMECONSTANT   2
+#define ADJINTERVAL    0
+#define FREQ_WEIGHT    18
+#define PHASE_WEIGHT   7
+#define MAX_DRIFT      0x3FFFFFFF
+
+#define R_SHIFT(_X_, _Y_) (((_X_) < 0) ? -(-(_X_) >> (_Y_)) : ((_X_) >> (_Y_)))
+
+static struct timeval max_adj_offset = { 0, 128000 };
+
+static long clock_adjust = 0;  /* current adjustment value (usec * 2^USECSCALE) */
+static long accum_drift   = 0; /* accumulated drift value  (usec / ADJINTERVAL) */
+static long adjustments  = 0;
+static char skip_adjust  = 1;  /* discard first adjustment (bad samples) */
+
+/*
+ * DCF77 state flags
+ */
+#define DCFB_ANNOUNCE           0x0001 /* switch time zone warning (DST switch) */
+#define DCFB_DST                0x0002 /* DST in effect */
+#define DCFB_LEAP              0x0004 /* LEAP warning (1 hour prior to occurrence) */
+#define DCFB_ALTERNATE         0x0008 /* alternate antenna used */
+
+struct clocktime               /* clock time broken up from time code */
+{
+       long wday;              /* Day of week: 1: Monday - 7: Sunday */
+       long day;
+       long month;
+       long year;
+       long hour;
+       long minute;
+       long second;
+       long usecond;
+       long utcoffset; /* in minutes */
+       long flags;             /* current clock status  (DCF77 state flags) */
+};
+
+typedef struct clocktime clocktime_t;
+
+/*
+ * (usually) quick constant multiplications
+ */
+#define TIMES10(_X_) (((_X_) << 3) + ((_X_) << 1))     /* *8 + *2 */
+#define TIMES24(_X_) (((_X_) << 4) + ((_X_) << 3))      /* *16 + *8 */
+#define TIMES60(_X_) ((((_X_) << 4)  - (_X_)) << 2)     /* *(16 - 1) *4 */
+/*
+ * generic l_abs() function
+ */
+#define l_abs(_x_)     (((_x_) < 0) ? -(_x_) : (_x_))
+
+/*
+ * conversion related return/error codes
+ */
+#define CVT_MASK       0x0000000F /* conversion exit code */
+#define   CVT_NONE     0x00000001 /* format not applicable */
+#define   CVT_FAIL     0x00000002 /* conversion failed - error code returned */
+#define   CVT_OK       0x00000004 /* conversion succeeded */
+#define CVT_BADFMT     0x00000010 /* general format error - (unparsable) */
+#define CVT_BADDATE    0x00000020 /* invalid date */
+#define CVT_BADTIME    0x00000040 /* invalid time */
+
+/*
+ * DCF77 raw time code
+ *
+ * From "Zur Zeit", Physikalisch-Technische Bundesanstalt (PTB), Braunschweig
+ * und Berlin, Maerz 1989
+ *
+ * Timecode transmission:
+ * AM:
+ *     time marks are send every second except for the second before the
+ *     next minute mark
+ *     time marks consist of a reduction of transmitter power to 25%
+ *     of the nominal level
+ *     the falling edge is the time indication (on time)
+ *     time marks of a 100ms duration constitute a logical 0
+ *     time marks of a 200ms duration constitute a logical 1
+ * FM:
+ *     see the spec. (basically a (non-)inverted psuedo random phase shift)
+ *
+ * Encoding:
+ * Second      Contents
+ * 0  - 10     AM: free, FM: 0
+ * 11 - 14     free
+ * 15          R     - alternate antenna
+ * 16          A1    - expect zone change (1 hour before)
+ * 17 - 18     Z1,Z2 - time zone
+ *              0  0 illegal
+ *              0  1 MEZ  (MET)
+ *              1  0 MESZ (MED, MET DST)
+ *              1  1 illegal
+ * 19          A2    - expect leap insertion/deletion (1 hour before)
+ * 20          S     - start of time code (1)
+ * 21 - 24     M1    - BCD (lsb first) Minutes
+ * 25 - 27     M10   - BCD (lsb first) 10 Minutes
+ * 28          P1    - Minute Parity (even)
+ * 29 - 32     H1    - BCD (lsb first) Hours
+ * 33 - 34      H10   - BCD (lsb first) 10 Hours
+ * 35          P2    - Hour Parity (even)
+ * 36 - 39     D1    - BCD (lsb first) Days
+ * 40 - 41     D10   - BCD (lsb first) 10 Days
+ * 42 - 44     DW    - BCD (lsb first) day of week (1: Monday -> 7: Sunday)
+ * 45 - 49     MO    - BCD (lsb first) Month
+ * 50           MO0   - 10 Months
+ * 51 - 53     Y1    - BCD (lsb first) Years
+ * 54 - 57     Y10   - BCD (lsb first) 10 Years
+ * 58          P3    - Date Parity (even)
+ * 59                - usually missing (minute indication), except for leap insertion
+ */
+
+/*-----------------------------------------------------------------------
+ * conversion table to map DCF77 bit stream into data fields.
+ * Encoding:
+ *   Each field of the DCF77 code is described with two adjacent entries in
+ *   this table. The first entry specifies the offset into the DCF77 data stream
+ *   while the length is given as the difference between the start index and
+ *   the start index of the following field.
+ */
+static struct rawdcfcode 
+{
+       char offset;                    /* start bit */
+} rawdcfcode[] =
+{
+       {  0 }, { 15 }, { 16 }, { 17 }, { 19 }, { 20 }, { 21 }, { 25 }, { 28 }, { 29 },
+       { 33 }, { 35 }, { 36 }, { 40 }, { 42 }, { 45 }, { 49 }, { 50 }, { 54 }, { 58 }, { 59 }
+};
+
+/*-----------------------------------------------------------------------
+ * symbolic names for the fields of DCF77 describes in "rawdcfcode".
+ * see comment above for the structure of the DCF77 data
+ */
+#define DCF_M  0
+#define DCF_R  1
+#define DCF_A1 2
+#define DCF_Z  3
+#define DCF_A2 4
+#define DCF_S  5
+#define DCF_M1 6
+#define DCF_M10        7
+#define DCF_P1 8
+#define DCF_H1 9
+#define DCF_H10        10
+#define DCF_P2 11
+#define DCF_D1 12
+#define DCF_D10        13
+#define DCF_DW 14
+#define DCF_MO 15
+#define DCF_MO0        16
+#define DCF_Y1 17
+#define DCF_Y10        18
+#define DCF_P3 19
+
+/*-----------------------------------------------------------------------
+ * parity field table (same encoding as rawdcfcode)
+ * This table describes the sections of the DCF77 code that are
+ * parity protected
+ */
+static struct partab
+{
+       char offset;                    /* start bit of parity field */
+} partab[] =
+{
+       { 21 }, { 29 }, { 36 }, { 59 }
+};
+
+/*-----------------------------------------------------------------------
+ * offsets for parity field descriptions
+ */
+#define DCF_P_P1       0
+#define DCF_P_P2       1
+#define DCF_P_P3       2
+
+/*-----------------------------------------------------------------------
+ * legal values for time zone information
+ */
+#define DCF_Z_MET 0x2
+#define DCF_Z_MED 0x1
+
+/*-----------------------------------------------------------------------
+ * symbolic representation if the DCF77 data stream
+ */
+static struct dcfparam
+{
+       unsigned char onebits[60];
+       unsigned char zerobits[60];
+} dcfparam = 
+{
+       "###############RADMLS1248124P124812P1248121241248112481248P", /* 'ONE' representation */
+       "--------------------s-------p------p----------------------p"  /* 'ZERO' representation */
+};
+
+/*-----------------------------------------------------------------------
+ * extract a bitfield from DCF77 datastream
+ * All numeric fields are LSB first.
+ * buf holds a pointer to a DCF77 data buffer in symbolic
+ *     representation
+ * idx holds the index to the field description in rawdcfcode
+ */
+static unsigned long
+ext_bf(
+       register unsigned char *buf,
+       register int   idx
+       )
+{
+       register unsigned long sum = 0;
+       register int i, first;
+
+       first = rawdcfcode[idx].offset;
+  
+       for (i = rawdcfcode[idx+1].offset - 1; i >= first; i--)
+       {
+               sum <<= 1;
+               sum |= (buf[i] != dcfparam.zerobits[i]);
+       }
+       return sum;
+}
+
+/*-----------------------------------------------------------------------
+ * check even parity integrity for a bitfield
+ *
+ * buf holds a pointer to a DCF77 data buffer in symbolic
+ *     representation
+ * idx holds the index to the field description in partab
+ */
+static unsigned
+pcheck(
+       register unsigned char *buf,
+       register int   idx
+       )
+{
+       register int i,last;
+       register unsigned psum = 1;
+
+       last = partab[idx+1].offset;
+
+       for (i = partab[idx].offset; i < last; i++)
+           psum ^= (buf[i] != dcfparam.zerobits[i]);
+
+       return psum;
+}
+
+/*-----------------------------------------------------------------------
+ * convert a DCF77 data buffer into wall clock time + flags
+ *
+ * buffer holds a pointer to a DCF77 data buffer in symbolic
+ *        representation
+ * size   describes the length of DCF77 information in bits (represented
+ *        as chars in symbolic notation
+ * clock  points to a wall clock time description of the DCF77 data (result)
+ */
+static unsigned long
+convert_rawdcf(
+              unsigned char   *buffer,
+              int              size,
+              clocktime_t     *clock_time
+              )
+{
+       if (size < 57)
+       {
+               PRINTF("%-30s", "*** INCOMPLETE");
+               return CVT_NONE;
+       }
+  
+       /*
+        * check Start and Parity bits
+        */
+       if ((ext_bf(buffer, DCF_S) == 1) &&
+           pcheck(buffer, DCF_P_P1) &&
+           pcheck(buffer, DCF_P_P2) &&
+           pcheck(buffer, DCF_P_P3))
+       {
+               /*
+                * buffer OK - extract all fields and build wall clock time from them
+                */
+
+               clock_time->flags  = 0;
+               clock_time->usecond= 0;
+               clock_time->second = 0;
+               clock_time->minute = ext_bf(buffer, DCF_M10);
+               clock_time->minute = TIMES10(clock_time->minute) + ext_bf(buffer, DCF_M1);
+               clock_time->hour   = ext_bf(buffer, DCF_H10);
+               clock_time->hour   = TIMES10(clock_time->hour)   + ext_bf(buffer, DCF_H1);
+               clock_time->day    = ext_bf(buffer, DCF_D10);
+               clock_time->day    = TIMES10(clock_time->day)    + ext_bf(buffer, DCF_D1);
+               clock_time->month  = ext_bf(buffer, DCF_MO0);
+               clock_time->month  = TIMES10(clock_time->month)  + ext_bf(buffer, DCF_MO);
+               clock_time->year   = ext_bf(buffer, DCF_Y10);
+               clock_time->year   = TIMES10(clock_time->year)   + ext_bf(buffer, DCF_Y1);
+               clock_time->wday   = ext_bf(buffer, DCF_DW);
+
+               /*
+                * determine offset to UTC by examining the time zone
+                */
+               switch (ext_bf(buffer, DCF_Z))
+               {
+                   case DCF_Z_MET:
+                       clock_time->utcoffset = -60;
+                       break;
+
+                   case DCF_Z_MED:
+                       clock_time->flags     |= DCFB_DST;
+                       clock_time->utcoffset  = -120;
+                       break;
+
+                   default:
+                       PRINTF("%-30s", "*** BAD TIME ZONE");
+                       return CVT_FAIL|CVT_BADFMT;
+               }
+
+               /*
+                * extract various warnings from DCF77
+                */
+               if (ext_bf(buffer, DCF_A1))
+                   clock_time->flags |= DCFB_ANNOUNCE;
+
+               if (ext_bf(buffer, DCF_A2))
+                   clock_time->flags |= DCFB_LEAP;
+
+               if (ext_bf(buffer, DCF_R))
+                   clock_time->flags |= DCFB_ALTERNATE;
+
+               return CVT_OK;
+       }
+       else
+       {
+               /*
+                * bad format - not for us
+                */
+               PRINTF("%-30s", "*** BAD FORMAT (invalid/parity)");
+               return CVT_FAIL|CVT_BADFMT;
+       }
+}
+
+/*-----------------------------------------------------------------------
+ * raw dcf input routine - fix up 50 baud
+ * characters for 1/0 decision
+ */
+static unsigned long
+cvt_rawdcf(
+          unsigned char   *buffer,
+          int              size,
+          clocktime_t     *clock_time
+          )
+{
+       register unsigned char *s = buffer;
+       register unsigned char *e = buffer + size;
+       register unsigned char *b = dcfparam.onebits;
+       register unsigned char *c = dcfparam.zerobits;
+       register unsigned rtc = CVT_NONE;
+       register unsigned int i, lowmax, highmax, cutoff, span;
+#define BITS 9
+       unsigned char     histbuf[BITS];
+       /*
+        * the input buffer contains characters with runs of consecutive
+        * bits set. These set bits are an indication of the DCF77 pulse
+        * length. We assume that we receive the pulse at 50 Baud. Thus
+        * a 100ms pulse would generate a 4 bit train (20ms per bit and
+        * start bit)
+        * a 200ms pulse would create all zeroes (and probably a frame error)
+        *
+        * The basic idea is that on corret reception we must have two
+        * maxima in the pulse length distribution histogram. (one for
+        * the zero representing pulses and one for the one representing
+        * pulses)
+        * There will always be ones in the datastream, thus we have to see
+        * two maxima.
+        * The best point to cut for a 1/0 decision is the minimum between those
+        * between the maxima. The following code tries to find this cutoff point.
+        */
+
+       /*
+        * clear histogram buffer
+        */
+       for (i = 0; i < BITS; i++)
+       {
+               histbuf[i] = 0;
+       }
+
+       cutoff = 0;
+       lowmax = 0;
+
+       /*
+        * convert sequences of set bits into bits counts updating
+        * the histogram alongway
+        */
+       while (s < e)
+       {
+               register unsigned int ch = *s ^ 0xFF;
+               /*
+                * check integrity and update histogramm
+                */
+               if (!((ch+1) & ch) || !*s)
+               {
+                       /*
+                        * character ok
+                        */
+                       for (i = 0; ch; i++)
+                       {
+                               ch >>= 1;
+                       }
+
+                       *s = i;
+                       histbuf[i]++;
+                       cutoff += i;
+                       lowmax++;
+               }
+               else
+               {
+                       /*
+                        * invalid character (no consecutive bit sequence)
+                        */
+                       dprintf(("parse: cvt_rawdcf: character check for 0x%x@%d FAILED\n", *s, s - buffer));
+                       *s = (unsigned char)~0;
+                       rtc = CVT_FAIL|CVT_BADFMT;
+               }
+               s++;
+       }
+
+       /*
+        * first cutoff estimate (average bit count - must be between both
+        * maxima)
+        */
+       if (lowmax)
+       {
+               cutoff /= lowmax;
+       }
+       else
+       {
+               cutoff = 4;     /* doesn't really matter - it'll fail anyway, but gives error output */
+       }
+
+       dprintf(("parse: cvt_rawdcf: average bit count: %d\n", cutoff));
+
+       lowmax = 0;  /* weighted sum */
+       highmax = 0; /* bitcount */
+
+       /*
+        * collect weighted sum of lower bits (left of initial guess)
+        */
+       dprintf(("parse: cvt_rawdcf: histogram:"));
+       for (i = 0; i <= cutoff; i++)
+       {
+               lowmax  += histbuf[i] * i;
+               highmax += histbuf[i];
+               dprintf((" %d", histbuf[i]));
+       }
+       dprintf((" <M>"));
+
+       /*
+        * round up
+        */
+       lowmax += highmax / 2;
+
+       /*
+        * calculate lower bit maximum (weighted sum / bit count)
+        *
+        * avoid divide by zero
+        */
+       if (highmax)
+       {
+               lowmax /= highmax;
+       }
+       else
+       {
+               lowmax = 0;
+       }
+
+       highmax = 0; /* weighted sum of upper bits counts */
+       cutoff = 0;  /* bitcount */
+
+       /*
+        * collect weighted sum of lower bits (right of initial guess)
+        */
+       for (; i < BITS; i++)
+       {
+               highmax+=histbuf[i] * i;
+               cutoff +=histbuf[i];
+               dprintf((" %d", histbuf[i]));
+       }
+       dprintf(("\n"));
+
+       /*
+        * determine upper maximum (weighted sum / bit count)
+        */
+       if (cutoff)
+       {
+               highmax /= cutoff;
+       }
+       else
+       {
+               highmax = BITS-1;
+       }
+
+       /*
+        * following now holds:
+        * lowmax <= cutoff(initial guess) <= highmax
+        * best cutoff is the minimum nearest to higher bits
+        */
+
+       /*
+        * find the minimum between lowmax and highmax (detecting
+        * possibly a minimum span)
+        */
+       span = cutoff = lowmax;
+       for (i = lowmax; i <= highmax; i++)
+       {
+               if (histbuf[cutoff] > histbuf[i])
+               {
+                       /*
+                        * got a new minimum move beginning of minimum (cutoff) and
+                        * end of minimum (span) there
+                        */
+                       cutoff = span = i;
+               }
+               else
+                   if (histbuf[cutoff] == histbuf[i])
+                   {
+                           /*
+                            * minimum not better yet - but it spans more than
+                            * one bit value - follow it
+                            */
+                           span = i;
+                   }
+       }
+
+       /*
+        * cutoff point for 1/0 decision is the middle of the minimum section
+        * in the histogram
+        */
+       cutoff = (cutoff + span) / 2;
+
+       dprintf(("parse: cvt_rawdcf: lower maximum %d, higher maximum %d, cutoff %d\n", lowmax, highmax, cutoff));
+
+       /*
+        * convert the bit counts to symbolic 1/0 information for data conversion
+        */
+       s = buffer;
+       while ((s < e) && *c && *b)
+       {
+               if (*s == (unsigned char)~0)
+               {
+                       /*
+                        * invalid character
+                        */
+                       *s = '?';
+               }
+               else
+               {
+                       /*
+                        * symbolic 1/0 representation
+                        */
+                       *s = (*s >= cutoff) ? *b : *c;
+               }
+               s++;
+               b++;
+               c++;
+       }
+
+       /*
+        * if everything went well so far return the result of the symbolic
+        * conversion routine else just the accumulated errors
+        */
+       if (rtc != CVT_NONE) 
+       {
+               PRINTF("%-30s", "*** BAD DATA");
+       }
+
+       return (rtc == CVT_NONE) ? convert_rawdcf(buffer, size, clock_time) : rtc;
+}
+
+/*-----------------------------------------------------------------------
+ * convert a wall clock time description of DCF77 to a Unix time (seconds
+ * since 1.1. 1970 UTC)
+ */
+static time_t
+dcf_to_unixtime(
+               clocktime_t   *clock_time,
+               unsigned *cvtrtc
+               )
+{
+#define SETRTC(_X_)    { if (cvtrtc) *cvtrtc = (_X_); }
+       static int days_of_month[] = 
+       {
+               0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
+       };
+       register int i;
+       time_t t;
+  
+       /*
+        * map 2 digit years to 19xx (DCF77 is a 20th century item)
+        */
+       if ( clock_time->year < YEAR_PIVOT )    /* in case of      Y2KFixes [ */
+               clock_time->year += 100;        /* *year%100, make tm_year */
+                                               /* *(do we need this?) */
+       if ( clock_time->year < YEAR_BREAK )    /* (failsafe if) */
+           clock_time->year += 1900;                           /* Y2KFixes ] */
+
+       /*
+        * must have been a really bad year code - drop it
+        */
+       if (clock_time->year < (YEAR_PIVOT + 1900) )            /* Y2KFixes */
+       {
+               SETRTC(CVT_FAIL|CVT_BADDATE);
+               return -1;
+       }
+       /*
+        * sorry, slow section here - but it's not time critical anyway
+        */
+
+       /*
+        * calculate days since 1970 (watching leap years)
+        */
+       t = julian0( clock_time->year ) - julian0( 1970 );
+
+                               /* month */
+       if (clock_time->month <= 0 || clock_time->month > 12)
+       {
+               SETRTC(CVT_FAIL|CVT_BADDATE);
+               return -1;              /* bad month */
+       }
+                               /* adjust current leap year */
+#if 0
+       if (clock_time->month < 3 && days_per_year(clock_time->year) == 366)
+           t--;
+#endif
+
+       /*
+        * collect days from months excluding the current one
+        */
+       for (i = 1; i < clock_time->month; i++)
+       {
+               t += days_of_month[i];
+       }
+                               /* day */
+       if (clock_time->day < 1 || ((clock_time->month == 2 && days_per_year(clock_time->year) == 366) ?
+                              clock_time->day > 29 : clock_time->day > days_of_month[clock_time->month]))
+       {
+               SETRTC(CVT_FAIL|CVT_BADDATE);
+               return -1;              /* bad day */
+       }
+
+       /*
+        * collect days from date excluding the current one
+        */
+       t += clock_time->day - 1;
+
+                               /* hour */
+       if (clock_time->hour < 0 || clock_time->hour >= 24)
+       {
+               SETRTC(CVT_FAIL|CVT_BADTIME);
+               return -1;              /* bad hour */
+       }
+
+       /*
+        * calculate hours from 1. 1. 1970
+        */
+       t = TIMES24(t) + clock_time->hour;
+
+                               /* min */
+       if (clock_time->minute < 0 || clock_time->minute > 59)
+       {
+               SETRTC(CVT_FAIL|CVT_BADTIME);
+               return -1;              /* bad min */
+       }
+
+       /*
+        * calculate minutes from 1. 1. 1970
+        */
+       t = TIMES60(t) + clock_time->minute;
+                               /* sec */
+  
+       /*
+        * calculate UTC in minutes
+        */
+       t += clock_time->utcoffset;
+
+       if (clock_time->second < 0 || clock_time->second > 60)  /* allow for LEAPs */
+       {
+               SETRTC(CVT_FAIL|CVT_BADTIME);
+               return -1;              /* bad sec */
+       }
+
+       /*
+        * calculate UTC in seconds - phew !
+        */
+       t  = TIMES60(t) + clock_time->second;
+                               /* done */
+       return t;
+}
+
+/*-----------------------------------------------------------------------
+ * cheap half baked 1/0 decision - for interactive operation only
+ */
+static char
+type(
+     unsigned int c
+     )
+{
+       c ^= 0xFF;
+       return (c > 0xF);
+}
+
+/*-----------------------------------------------------------------------
+ * week day representation
+ */
+static const char *wday[8] =
+{
+       "??",
+       "Mo",
+       "Tu",
+       "We",
+       "Th",
+       "Fr",
+       "Sa",
+       "Su"
+};
+
+/*-----------------------------------------------------------------------
+ * generate a string representation for a timeval
+ */
+static char *
+pr_timeval(
+          struct timeval *val
+          )
+{
+       static char buf[20];
+
+       if (val->tv_sec == 0)
+           sprintf(buf, "%c0.%06ld", (val->tv_usec < 0) ? '-' : '+', (long int)l_abs(val->tv_usec));
+       else
+           sprintf(buf, "%ld.%06ld", (long int)val->tv_sec, (long int)l_abs(val->tv_usec));
+       return buf;
+}
+
+/*-----------------------------------------------------------------------
+ * correct the current time by an offset by setting the time rigorously
+ */
+static void
+set_time(
+        struct timeval *offset
+        )
+{
+       struct timeval the_time;
+
+       if (no_set)
+           return;
+
+       LPRINTF("set_time: %s ", pr_timeval(offset));
+       syslog(LOG_NOTICE, "setting time (offset %s)", pr_timeval(offset));
+
+       if (gettimeofday(&the_time, 0L) == -1)
+       {
+               perror("gettimeofday()");
+       }
+       else
+       {
+               timeradd(&the_time, offset);
+               if (settimeofday(&the_time, 0L) == -1)
+               {
+                       perror("settimeofday()");
+               }
+       }
+}
+
+/*-----------------------------------------------------------------------
+ * slew the time by a given offset
+ */
+static void
+adj_time(
+        long offset
+        )
+{
+       struct timeval time_offset;
+
+       if (no_set)
+           return;
+
+       time_offset.tv_sec  = offset / 1000000;
+       time_offset.tv_usec = offset % 1000000;
+
+       LPRINTF("adj_time: %ld us ", (long int)offset);
+       if (adjtime(&time_offset, 0L) == -1)
+           perror("adjtime()");
+}
+
+/*-----------------------------------------------------------------------
+ * read in a possibly previously written drift value
+ */
+static void
+read_drift(
+          const char *drift_file
+          )
+{
+       FILE *df;
+
+       df = fopen(drift_file, "r");
+       if (df != NULL)
+       {
+               int idrift = 0, fdrift = 0;
+
+               fscanf(df, "%4d.%03d", &idrift, &fdrift);
+               fclose(df);
+               LPRINTF("read_drift: %d.%03d ppm ", idrift, fdrift);
+
+               accum_drift = idrift << USECSCALE;
+               fdrift     = (fdrift << USECSCALE) / 1000;
+               accum_drift += fdrift & (1<<USECSCALE);
+               LPRINTF("read_drift: drift_comp %ld ", (long int)accum_drift);
+       }
+}
+
+/*-----------------------------------------------------------------------
+ * write out the current drift value
+ */
+static void
+update_drift(
+            const char *drift_file,
+            long offset,
+            time_t reftime
+            )
+{
+       FILE *df;
+
+       df = fopen(drift_file, "w");
+       if (df != NULL)
+       {
+               int idrift = R_SHIFT(accum_drift, USECSCALE);
+               int fdrift = accum_drift & ((1<<USECSCALE)-1);
+
+               LPRINTF("update_drift: drift_comp %ld ", (long int)accum_drift);
+               fdrift = (fdrift * 1000) / (1<<USECSCALE);
+               fprintf(df, "%4d.%03d %c%ld.%06ld %.24s\n", idrift, fdrift,
+                       (offset < 0) ? '-' : '+', (long int)(l_abs(offset) / 1000000),
+                       (long int)(l_abs(offset) % 1000000), asctime(localtime(&reftime)));
+               fclose(df);
+               LPRINTF("update_drift: %d.%03d ppm ", idrift, fdrift);
+       }
+}
+
+/*-----------------------------------------------------------------------
+ * process adjustments derived from the DCF77 observation
+ * (controls clock PLL)
+ */
+static void
+adjust_clock(
+            struct timeval *offset,
+            const char *drift_file,
+            time_t reftime
+            )
+{
+       struct timeval toffset;
+       register long usecoffset;
+       int tmp;
+
+       if (no_set)
+           return;
+
+       if (skip_adjust)
+       {
+               skip_adjust = 0;
+               return;
+       }
+
+       toffset = *offset;
+       toffset.tv_sec  = l_abs(toffset.tv_sec);
+       toffset.tv_usec = l_abs(toffset.tv_usec);
+       if (timercmp(&toffset, &max_adj_offset, >))
+       {
+               /*
+                * hopeless - set the clock - and clear the timing
+                */
+               set_time(offset);
+               clock_adjust = 0;
+               skip_adjust  = 1;
+               return;
+       }
+
+       usecoffset   = offset->tv_sec * 1000000 + offset->tv_usec;
+
+       clock_adjust = R_SHIFT(usecoffset, TIMECONSTANT);       /* adjustment to make for next period */
+
+       tmp = 0;
+       while (adjustments > (1 << tmp))
+           tmp++;
+       adjustments = 0;
+       if (tmp > FREQ_WEIGHT)
+           tmp = FREQ_WEIGHT;
+
+       accum_drift  += R_SHIFT(usecoffset << USECSCALE, TIMECONSTANT+TIMECONSTANT+FREQ_WEIGHT-tmp);
+
+       if (accum_drift > MAX_DRIFT)            /* clamp into interval */
+           accum_drift = MAX_DRIFT;
+       else
+           if (accum_drift < -MAX_DRIFT)
+               accum_drift = -MAX_DRIFT;
+
+       update_drift(drift_file, usecoffset, reftime);
+       LPRINTF("clock_adjust: %s, clock_adjust %ld, drift_comp %ld(%ld) ",
+               pr_timeval(offset),(long int) R_SHIFT(clock_adjust, USECSCALE),
+               (long int)R_SHIFT(accum_drift, USECSCALE), (long int)accum_drift);
+}
+
+/*-----------------------------------------------------------------------
+ * adjust the clock by a small mount to simulate frequency correction
+ */
+static void
+periodic_adjust(
+               void
+               )
+{
+       register long adjustment;
+
+       adjustments++;
+
+       adjustment = R_SHIFT(clock_adjust, PHASE_WEIGHT);
+
+       clock_adjust -= adjustment;
+
+       adjustment += R_SHIFT(accum_drift, USECSCALE+ADJINTERVAL);
+
+       adj_time(adjustment);
+}
+
+/*-----------------------------------------------------------------------
+ * control synchronisation status (warnings) and do periodic adjusts
+ * (frequency control simulation)
+ */
+static void
+tick(
+     int signum
+     )
+{
+       static unsigned long last_notice = 0;
+
+#if !defined(HAVE_SIGACTION) && !defined(HAVE_SIGVEC)
+       (void)signal(SIGALRM, tick);
+#endif
+
+       periodic_adjust();
+
+       ticks += 1<<ADJINTERVAL;
+
+       if ((ticks - last_sync) > MAX_UNSYNC)
+       {
+               /*
+                * not getting time for a while
+                */
+               if (sync_state == SYNC)
+               {
+                       /*
+                        * completely lost information
+                        */
+                       sync_state = NO_SYNC;
+                       syslog(LOG_INFO, "DCF77 reception lost (timeout)");
+                       last_notice = ticks;
+               }
+               else
+                   /*
+                    * in NO_SYNC state - look whether its time to speak up again
+                    */
+                   if ((ticks - last_notice) > NOTICE_INTERVAL)
+                   {
+                           syslog(LOG_NOTICE, "still not synchronized to DCF77 - check receiver/signal");
+                           last_notice = ticks;
+                   }
+       }
+
+#ifndef ITIMER_REAL
+       (void) alarm(1<<ADJINTERVAL);
+#endif
+}
+
+/*-----------------------------------------------------------------------
+ * break association from terminal to avoid catching terminal
+ * or process group related signals (-> daemon operation)
+ */
+static void
+detach(
+       void
+       )
+{
+#   ifdef HAVE_DAEMON
+       daemon(0, 0);
+#   else /* not HAVE_DAEMON */
+       if (fork())
+           exit(0);
+
+       {
+               u_long s;
+               int max_fd;
+
+#if defined(HAVE_SYSCONF) && defined(_SC_OPEN_MAX)
+               max_fd = sysconf(_SC_OPEN_MAX);
+#else /* HAVE_SYSCONF && _SC_OPEN_MAX */
+               max_fd = getdtablesize();
+#endif /* HAVE_SYSCONF && _SC_OPEN_MAX */
+               for (s = 0; s < max_fd; s++)
+                   (void) close((int)s);
+               (void) open("/", 0);
+               (void) dup2(0, 1);
+               (void) dup2(0, 2);
+#ifdef SYS_DOMAINOS
+               {
+                       uid_$t puid;
+                       status_$t st;
+
+                       proc2_$who_am_i(&puid);
+                       proc2_$make_server(&puid, &st);
+               }
+#endif /* SYS_DOMAINOS */
+#if defined(HAVE_SETPGID) || defined(HAVE_SETSID)
+# ifdef HAVE_SETSID
+               if (setsid() == (pid_t)-1)
+                   syslog(LOG_ERR, "dcfd: setsid(): %m");
+# else
+               if (setpgid(0, 0) == -1)
+                   syslog(LOG_ERR, "dcfd: setpgid(): %m");
+# endif
+#else /* HAVE_SETPGID || HAVE_SETSID */
+               {
+                       int fid;
+
+                       fid = open("/dev/tty", 2);
+                       if (fid >= 0)
+                       {
+                               (void) ioctl(fid, (u_long) TIOCNOTTY, (char *) 0);
+                               (void) close(fid);
+                       }
+# ifdef HAVE_SETPGRP_0
+                       (void) setpgrp();
+# else /* HAVE_SETPGRP_0 */
+                       (void) setpgrp(0, getpid());
+# endif /* HAVE_SETPGRP_0 */
+               }
+#endif /* HAVE_SETPGID || HAVE_SETSID */
+       }
+#endif /* not HAVE_DAEMON */
+}
+
+/*-----------------------------------------------------------------------
+ * list possible arguments and options
+ */
+static void
+usage(
+      char *program
+      )
+{
+  fprintf(stderr, "usage: %s [-n] [-f] [-l] [-t] [-i] [-o] [-d <drift_file>] [-D <input delay>] <device>\n", program);
+       fprintf(stderr, "\t-n              do not change time\n");
+       fprintf(stderr, "\t-i              interactive\n");
+       fprintf(stderr, "\t-t              trace (print all datagrams)\n");
+       fprintf(stderr, "\t-f              print all databits (includes PTB private data)\n");
+       fprintf(stderr, "\t-l              print loop filter debug information\n");
+       fprintf(stderr, "\t-o              print offet average for current minute\n");
+       fprintf(stderr, "\t-Y              make internal Y2K checks then exit\n");      /* Y2KFixes */
+       fprintf(stderr, "\t-d <drift_file> specify alternate drift file\n");
+       fprintf(stderr, "\t-D <input delay>specify delay from input edge to processing in micro seconds\n");
+}
+
+/*-----------------------------------------------------------------------
+ * check_y2k() - internal check of Y2K logic
+ *     (a lot of this logic lifted from ../ntpd/check_y2k.c)
+ */
+static int
+check_y2k( void )
+{ 
+    int  year;                 /* current working year */
+    int  year0 = 1900;         /* sarting year for NTP time */
+    int  yearend;              /* ending year we test for NTP time.
+                                   * 32-bit systems: through 2036, the
+                                     **year in which NTP time overflows.
+                                   * 64-bit systems: a reasonable upper
+                                     **limit (well, maybe somewhat beyond
+                                     **reasonable, but well before the
+                                     **max time, by which time the earth
+                                     **will be dead.) */
+    time_t Time;
+    struct tm LocalTime;
+
+    int Fatals, Warnings;
+#define Error(year) if ( (year)>=2036 && LocalTime.tm_year < 110 ) \
+       Warnings++; else Fatals++
+
+    Fatals = Warnings = 0;
+
+    Time = time( (time_t *)NULL );
+    LocalTime = *localtime( &Time );
+
+    year = ( sizeof( u_long ) > 4 )    /* save max span using year as temp */
+               ? ( 400 * 3 )           /* three greater gregorian cycles */
+               : ((int)(0x7FFFFFFF / 365.242 / 24/60/60)* 2 ); /*32-bit limit*/
+                       /* NOTE: will automacially expand test years on
+                        * 64 bit machines.... this may cause some of the
+                        * existing ntp logic to fail for years beyond
+                        * 2036 (the current 32-bit limit). If all checks
+                        * fail ONLY beyond year 2036 you may ignore such
+                        * errors, at least for a decade or so. */
+    yearend = year0 + year;
+
+    year = 1900+YEAR_PIVOT;
+    printf( "  starting year %04d\n", (int) year );
+    printf( "  ending year   %04d\n", (int) yearend );
+
+    for ( ; year < yearend; year++ )
+    {
+       clocktime_t  ct;
+       time_t       Observed;
+       time_t       Expected;
+       unsigned     Flag;
+       unsigned long t;
+
+       ct.day = 1;
+       ct.month = 1;
+       ct.year = year;
+       ct.hour = ct.minute = ct.second = ct.usecond = 0;
+       ct.utcoffset = 0;
+       ct.flags = 0;
+
+       Flag = 0;
+       Observed = dcf_to_unixtime( &ct, &Flag );
+               /* seems to be a clone of parse_to_unixtime() with
+                * *a minor difference to arg2 type */
+       if ( ct.year != year )
+       {
+           fprintf( stdout, 
+              "%04d: dcf_to_unixtime(,%d) CORRUPTED ct.year: was %d\n",
+              (int)year, (int)Flag, (int)ct.year );
+           Error(year);
+           break;
+       }
+       t = julian0(year) - julian0(1970);      /* Julian day from 1970 */
+       Expected = t * 24 * 60 * 60;
+       if ( Observed != Expected  ||  Flag )
+       {   /* time difference */
+           fprintf( stdout, 
+              "%04d: dcf_to_unixtime(,%d) FAILURE: was=%lu s/b=%lu  (%ld)\n",
+              year, (int)Flag, 
+              (unsigned long)Observed, (unsigned long)Expected,
+              ((long)Observed - (long)Expected) );
+           Error(year);
+           break;
+       }
+
+       if ( year >= YEAR_PIVOT+1900 )
+       {
+           /* check year % 100 code we put into dcf_to_unixtime() */
+           ct.year = year % 100;
+           Flag = 0;
+
+           Observed = dcf_to_unixtime( &ct, &Flag );
+
+           if ( Observed != Expected  ||  Flag )
+           {   /* time difference */
+               fprintf( stdout, 
+"%04d: dcf_to_unixtime(%d,%d) FAILURE: was=%lu s/b=%lu  (%ld)\n",
+                  year, (int)ct.year, (int)Flag, 
+                  (unsigned long)Observed, (unsigned long)Expected,
+                  ((long)Observed - (long)Expected) );
+               Error(year);
+               break;
+           }
+
+           /* check year - 1900 code we put into dcf_to_unixtime() */
+           ct.year = year - 1900;
+           Flag = 0;
+
+           Observed = dcf_to_unixtime( &ct, &Flag );
+
+           if ( Observed != Expected  ||  Flag ) {   /* time difference */
+                   fprintf( stdout, 
+                            "%04d: dcf_to_unixtime(%d,%d) FAILURE: was=%lu s/b=%lu  (%ld)\n",
+                            year, (int)ct.year, (int)Flag, 
+                            (unsigned long)Observed, (unsigned long)Expected,
+                            ((long)Observed - (long)Expected) );
+                   Error(year);
+               break;
+           }
+
+
+       }
+    }
+
+    return ( Fatals );
+}
+
+/*--------------------------------------------------
+ * rawdcf_init - set up modem lines for RAWDCF receivers
+ */
+#if defined(TIOCMSET) && (defined(TIOCM_DTR) || defined(CIOCM_DTR))
+static void
+rawdcf_init(
+       int fd
+       )
+{
+       /*
+        * You can use the RS232 to supply the power for a DCF77 receiver.
+        * Here a voltage between the DTR and the RTS line is used. Unfortunately
+        * the name has changed from CIOCM_DTR to TIOCM_DTR recently.
+        */
+       
+#ifdef TIOCM_DTR
+       int sl232 = TIOCM_DTR;  /* turn on DTR for power supply */
+#else
+       int sl232 = CIOCM_DTR;  /* turn on DTR for power supply */
+#endif
+
+       if (ioctl(fd, TIOCMSET, (caddr_t)&sl232) == -1)
+       {
+               syslog(LOG_NOTICE, "rawdcf_init: WARNING: ioctl(fd, TIOCMSET, [C|T]IOCM_DTR): %m");
+       }
+}
+#else
+static void
+rawdcf_init(
+           int fd
+       )
+{
+       syslog(LOG_NOTICE, "rawdcf_init: WARNING: OS interface incapable of setting DTR to power DCF modules");
+}
+#endif  /* DTR initialisation type */
+
+/*-----------------------------------------------------------------------
+ * main loop - argument interpreter / setup / main loop
+ */
+int
+main(
+     int argc,
+     char **argv
+     )
+{
+       unsigned char c;
+       char **a = argv;
+       int  ac = argc;
+       char *file = NULL;
+       const char *drift_file = "/etc/dcfd.drift";
+       int fd;
+       int offset = 15;
+       int offsets = 0;
+       int delay = DEFAULT_DELAY;      /* average delay from input edge to time stamping */
+       int trace = 0;
+       int errs = 0;
+
+       /*
+        * process arguments
+        */
+       while (--ac)
+       {
+               char *arg = *++a;
+               if (*arg == '-')
+                   while ((c = *++arg))
+                       switch (c)
+                       {
+                           case 't':
+                               trace = 1;
+                               interactive = 1;
+                               break;
+
+                           case 'f':
+                               offset = 0;
+                               interactive = 1;
+                               break;
+
+                           case 'l':
+                               loop_filter_debug = 1;
+                               offsets = 1;
+                               interactive = 1;
+                               break;
+
+                           case 'n':
+                               no_set = 1;
+                               break;
+
+                           case 'o':
+                               offsets = 1;
+                               interactive = 1;
+                               break;
+
+                           case 'i':
+                               interactive = 1;
+                               break;
+
+                           case 'D':
+                               if (ac > 1)
+                               {
+                                       delay = atoi(*++a);
+                                       ac--;
+                               }
+                               else
+                               {
+                                       fprintf(stderr, "%s: -D requires integer argument\n", argv[0]);
+                                       errs=1;
+                               }
+                               break;
+             
+                           case 'd':
+                               if (ac > 1)
+                               {
+                                       drift_file = *++a;
+                                       ac--;
+                               }
+                               else
+                               {
+                                       fprintf(stderr, "%s: -d requires file name argument\n", argv[0]);
+                                       errs=1;
+                               }
+                               break;
+             
+                           case 'Y':   
+                               errs=check_y2k();
+                               exit( errs ? 1 : 0 );
+
+                           default:
+                               fprintf(stderr, "%s: unknown option -%c\n", argv[0], c);
+                               errs=1;
+                               break;
+                       }
+               else
+                   if (file == NULL)
+                       file = arg;
+                   else
+                   {
+                           fprintf(stderr, "%s: device specified twice\n", argv[0]);
+                           errs=1;
+                   }
+       }
+
+       if (errs)
+       {
+               usage(argv[0]);
+               exit(1);
+       }
+       else
+           if (file == NULL)
+           {
+                   fprintf(stderr, "%s: device not specified\n", argv[0]);
+                   usage(argv[0]);
+                   exit(1);
+           }
+
+       errs = LINES+1;
+
+       /*
+        * get access to DCF77 tty port
+        */
+       fd = open(file, O_RDONLY);
+       if (fd == -1)
+       {
+               perror(file);
+               exit(1);
+       }
+       else
+       {
+               int i, rrc;
+               struct timeval t, tt, tlast;
+               struct timeval timeout;
+               struct timeval phase;
+               struct timeval time_offset;
+               char pbuf[61];          /* printable version */
+               char buf[61];           /* raw data */
+               clocktime_t clock_time; /* wall clock time */
+               time_t utc_time = 0;
+               time_t last_utc_time = 0;
+               long usecerror = 0;
+               long lasterror = 0;
+#if defined(HAVE_TERMIOS_H) || defined(STREAM)
+               struct termios term;
+#else  /* not HAVE_TERMIOS_H || STREAM */
+# if defined(HAVE_TERMIO_H) || defined(HAVE_SYSV_TTYS)
+               struct termio term;
+# endif/* HAVE_TERMIO_H || HAVE_SYSV_TTYS */
+#endif /* not HAVE_TERMIOS_H || STREAM */
+               unsigned int rtc = CVT_NONE;
+
+               rawdcf_init(fd);
+               
+               timeout.tv_sec  = 1;
+               timeout.tv_usec = 500000;
+
+               phase.tv_sec    = 0;
+               phase.tv_usec   = delay;
+
+               /*
+                * setup TTY (50 Baud, Read, 8Bit, No Hangup, 1 character IO)
+                */
+               if (TTY_GETATTR(fd,  &term) == -1)
+               {
+                       perror("tcgetattr");
+                       exit(1);
+               }
+
+               memset(term.c_cc, 0, sizeof(term.c_cc));
+               term.c_cc[VMIN] = 1;
+#ifdef NO_PARENB_IGNPAR
+               term.c_cflag = CS8|CREAD|CLOCAL;
+#else
+               term.c_cflag = CS8|CREAD|CLOCAL|PARENB;
+#endif
+               term.c_iflag = IGNPAR;
+               term.c_oflag = 0;
+               term.c_lflag = 0;
+
+               cfsetispeed(&term, B50);
+               cfsetospeed(&term, B50);
+
+               if (TTY_SETATTR(fd, &term) == -1)
+               {
+                       perror("tcsetattr");
+                       exit(1);
+               }
+
+               /*
+                * lose terminal if in daemon operation
+                */
+               if (!interactive)
+                   detach();
+      
+               /*
+                * get syslog() initialized
+                */
+#ifdef LOG_DAEMON
+               openlog("dcfd", LOG_PID, LOG_DAEMON);
+#else
+               openlog("dcfd", LOG_PID);
+#endif
+
+               /*
+                * setup periodic operations (state control / frequency control)
+                */
+#ifdef HAVE_SIGACTION
+               {
+                       struct sigaction act;
+
+# ifdef HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION
+                       act.sa_sigaction = (void (*) P((int, siginfo_t *, void *)))0;
+# endif /* HAVE_SA_SIGACTION_IN_STRUCT_SIGACTION */
+                       act.sa_handler   = tick;
+                       sigemptyset(&act.sa_mask);
+                       act.sa_flags     = 0;
+
+                       if (sigaction(SIGALRM, &act, (struct sigaction *)0) == -1)
+                       {
+                               syslog(LOG_ERR, "sigaction(SIGALRM): %m");
+                               exit(1);
+                       }
+               }
+#else
+#ifdef HAVE_SIGVEC
+               {
+                       struct sigvec vec;
+
+                       vec.sv_handler   = tick;
+                       vec.sv_mask      = 0;
+                       vec.sv_flags     = 0;
+
+                       if (sigvec(SIGALRM, &vec, (struct sigvec *)0) == -1)
+                       {
+                               syslog(LOG_ERR, "sigvec(SIGALRM): %m");
+                               exit(1);
+                       }
+               }
+#else
+               (void) signal(SIGALRM, tick);
+#endif
+#endif
+
+#ifdef ITIMER_REAL
+               {
+                       struct itimerval it;
+
+                       it.it_interval.tv_sec  = 1<<ADJINTERVAL;
+                       it.it_interval.tv_usec = 0;
+                       it.it_value.tv_sec     = 1<<ADJINTERVAL;
+                       it.it_value.tv_usec    = 0;
+       
+                       if (setitimer(ITIMER_REAL, &it, (struct itimerval *)0) == -1)
+                       {
+                               syslog(LOG_ERR, "setitimer: %m");
+                               exit(1);
+                       }
+               }
+#else
+               (void) alarm(1<<ADJINTERVAL);
+#endif
+
+               PRINTF("  DCF77 monitor %s - Copyright (C) 1993-2005 by Frank Kardel\n\n", revision);
+
+               pbuf[60] = '\0';
+               for ( i = 0; i < 60; i++)
+                   pbuf[i] = '.';
+
+               read_drift(drift_file);
+
+               /*
+                * what time is it now (for interval measurement)
+                */
+               gettimeofday(&tlast, 0L);
+               i = 0;
+               /*
+                * loop until input trouble ...
+                */
+               do
+               {
+                       /*
+                        * get an impulse
+                        */
+                       while ((rrc = read(fd, &c, 1)) == 1)
+                       {
+                               gettimeofday(&t, 0L);
+                               tt = t;
+                               timersub(&t, &tlast);
+
+                               if (errs > LINES)
+                               {
+                                       PRINTF("  %s", &"PTB private....RADMLSMin....PHour..PMDay..DayMonthYear....P\n"[offset]);
+                                       PRINTF("  %s", &"---------------RADMLS1248124P124812P1248121241248112481248P\n"[offset]);
+                                       errs = 0;
+                               }
+
+                               /*
+                                * timeout -> possible minute mark -> interpretation
+                                */
+                               if (timercmp(&t, &timeout, >))
+                               {
+                                       PRINTF("%c %.*s ", pat[i % (sizeof(pat)-1)], 59 - offset, &pbuf[offset]);
+
+                                       if ((rtc = cvt_rawdcf((unsigned char *)buf, i, &clock_time)) != CVT_OK)
+                                       {
+                                               /*
+                                                * this data was bad - well - forget synchronisation for now
+                                                */
+                                               PRINTF("\n");
+                                               if (sync_state == SYNC)
+                                               {
+                                                       sync_state = NO_SYNC;
+                                                       syslog(LOG_INFO, "DCF77 reception lost (bad data)");
+                                               }
+                                               errs++;
+                                       }
+                                       else
+                                           if (trace)
+                                           {
+                                                   PRINTF("\r  %.*s ", 59 - offset, &buf[offset]);
+                                           }
+
+
+                                       buf[0] = c;
+
+                                       /*
+                                        * collect first character
+                                        */
+                                       if (((c^0xFF)+1) & (c^0xFF))
+                                           pbuf[0] = '?';
+                                       else
+                                           pbuf[0] = type(c) ? '#' : '-';
+
+                                       for ( i = 1; i < 60; i++)
+                                           pbuf[i] = '.';
+
+                                       i = 0;
+                               }
+                               else
+                               {
+                                       /*
+                                        * collect character
+                                        */
+                                       buf[i] = c;
+
+                                       /*
+                                        * initial guess (usually correct)
+                                        */
+                                       if (((c^0xFF)+1) & (c^0xFF))
+                                           pbuf[i] = '?';
+                                       else
+                                           pbuf[i] = type(c) ? '#' : '-';
+
+                                       PRINTF("%c %.*s ", pat[i % (sizeof(pat)-1)], 59 - offset, &pbuf[offset]);
+                               }
+
+                               if (i == 0 && rtc == CVT_OK)
+                               {
+                                       /*
+                                        * we got a good time code here - try to convert it to
+                                        * UTC
+                                        */
+                                       if ((utc_time = dcf_to_unixtime(&clock_time, &rtc)) == -1)
+                                       {
+                                               PRINTF("*** BAD CONVERSION\n");
+                                       }
+
+                                       if (utc_time != (last_utc_time + 60))
+                                       {
+                                               /*
+                                                * well, two successive sucessful telegrams are not 60 seconds
+                                                * apart
+                                                */
+                                               PRINTF("*** NO MINUTE INC\n");
+                                               if (sync_state == SYNC)
+                                               {
+                                                       sync_state = NO_SYNC;
+                                                       syslog(LOG_INFO, "DCF77 reception lost (data mismatch)");
+                                               }
+                                               errs++;
+                                               rtc = CVT_FAIL|CVT_BADTIME|CVT_BADDATE;
+                                       }
+                                       else
+                                           usecerror = 0;
+
+                                       last_utc_time = utc_time;
+                               }
+
+                               if (rtc == CVT_OK)
+                               {
+                                       if (i == 0)
+                                       {
+                                               /*
+                                                * valid time code - determine offset and
+                                                * note regained reception
+                                                */
+                                               last_sync = ticks;
+                                               if (sync_state == NO_SYNC)
+                                               {
+                                                       syslog(LOG_INFO, "receiving DCF77");
+                                               }
+                                               else
+                                               {
+                                                       /*
+                                                        * we had at least one minute SYNC - thus
+                                                        * last error is valid
+                                                        */
+                                                       time_offset.tv_sec  = lasterror / 1000000;
+                                                       time_offset.tv_usec = lasterror % 1000000;
+                                                       adjust_clock(&time_offset, drift_file, utc_time);
+                                               }
+                                               sync_state = SYNC;
+                                       }
+
+                                       time_offset.tv_sec  = utc_time + i;
+                                       time_offset.tv_usec = 0;
+
+                                       timeradd(&time_offset, &phase);
+
+                                       usecerror += (time_offset.tv_sec - tt.tv_sec) * 1000000 + time_offset.tv_usec
+                                               -tt.tv_usec;
+
+                                       /*
+                                        * output interpreted DCF77 data
+                                        */
+                                       PRINTF(offsets ? "%s, %2ld:%02ld:%02d, %ld.%02ld.%02ld, <%s%s%s%s> (%c%ld.%06lds)" :
+                                              "%s, %2ld:%02ld:%02d, %ld.%02ld.%02ld, <%s%s%s%s>",
+                                              wday[clock_time.wday],
+                                              clock_time.hour, clock_time.minute, i, clock_time.day, clock_time.month,
+                                              clock_time.year,
+                                              (clock_time.flags & DCFB_ALTERNATE) ? "R" : "_",
+                                              (clock_time.flags & DCFB_ANNOUNCE) ? "A" : "_",
+                                              (clock_time.flags & DCFB_DST) ? "D" : "_",
+                                              (clock_time.flags & DCFB_LEAP) ? "L" : "_",
+                                              (lasterror < 0) ? '-' : '+', l_abs(lasterror) / 1000000, l_abs(lasterror) % 1000000
+                                              );
+
+                                       if (trace && (i == 0))
+                                       {
+                                               PRINTF("\n");
+                                               errs++;
+                                       }
+                                       lasterror = usecerror / (i+1);
+                               }
+                               else
+                               {
+                                       lasterror = 0; /* we cannot calculate phase errors on bad reception */
+                               }
+
+                               PRINTF("\r");
+
+                               if (i < 60)
+                               {
+                                       i++;
+                               }
+
+                               tlast = tt;
+
+                               if (interactive)
+                                   fflush(stdout);
+                       }
+               } while ((rrc == -1) && (errno == EINTR));
+      
+               /*
+                * lost IO - sorry guys
+                */
+               syslog(LOG_ERR, "TERMINATING - cannot read from device %s (%m)", file);
+
+               (void)close(fd);
+       }
+
+       closelog();
+  
+       return 0;
+}
+
+/*
+ * History:
+ *
+ * dcfd.c,v
+ * Revision 4.18  2005/10/07 22:08:18  kardel
+ * make dcfd.c compile on NetBSD 3.99.9 again (configure/sigvec compatibility fix)
+ *
+ * Revision 4.17.2.1  2005/10/03 19:15:16  kardel
+ * work around configure not detecting a missing sigvec compatibility
+ * interface on NetBSD 3.99.9 and above
+ *
+ * Revision 4.17  2005/08/10 10:09:44  kardel
+ * output revision information
+ *
+ * Revision 4.16  2005/08/10 06:33:25  kardel
+ * cleanup warnings
+ *
+ * Revision 4.15  2005/08/10 06:28:45  kardel
+ * fix setting of baud rate
+ *
+ * Revision 4.14  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.13  2004/11/14 15:29:41  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ */
diff --git a/parseutil/testdcf.c b/parseutil/testdcf.c
new file mode 100644 (file)
index 0000000..223ab30
--- /dev/null
@@ -0,0 +1,540 @@
+/*
+ * /src/NTP/ntp4-dev/parseutil/testdcf.c,v 4.10 2005/08/06 14:18:43 kardel RELEASE_20050806_A
+ *
+ * testdcf.c,v 4.10 2005/08/06 14:18:43 kardel RELEASE_20050806_A
+ *  
+ * simple DCF77 100/200ms pulse test program (via 50Baud serial line)
+ *
+ * Copyright (c) 1995-2005 by Frank Kardel <kardel <AT> ntp.org>
+ * Copyright (c) 1989-1994 by Frank Kardel, Friedrich-Alexander Universität Erlangen-Nürnberg, Germany
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. Neither the name of the author 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 AUTHOR 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 AUTHOR 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.
+ *
+ */
+
+#include "ntp_stdlib.h"
+
+#include <sys/ioctl.h>
+#include <unistd.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <termios.h>
+
+/*
+ * state flags
+ */
+#define DCFB_ANNOUNCE           0x0001 /* switch time zone warning (DST switch) */
+#define DCFB_DST                0x0002 /* DST in effect */
+#define DCFB_LEAP              0x0004 /* LEAP warning (1 hour prior to occurrence) */
+#define DCFB_ALTERNATE         0x0008 /* alternate antenna used */
+
+struct clocktime               /* clock time broken up from time code */
+{
+       long wday;
+       long day;
+       long month;
+       long year;
+       long hour;
+       long minute;
+       long second;
+       long usecond;
+       long utcoffset; /* in minutes */
+       long flags;             /* current clock status */
+};
+
+typedef struct clocktime clocktime_t;
+
+static char type(unsigned int);
+
+#define TIMES10(_X_) (((_X_) << 3) + ((_X_) << 1))
+
+/*
+ * parser related return/error codes
+ */
+#define CVT_MASK       0x0000000F /* conversion exit code */
+#define   CVT_NONE     0x00000001 /* format not applicable */
+#define   CVT_FAIL     0x00000002 /* conversion failed - error code returned */
+#define   CVT_OK       0x00000004 /* conversion succeeded */
+#define CVT_BADFMT     0x00000010 /* general format error - (unparsable) */
+
+/*
+ * DCF77 raw time code
+ *
+ * From "Zur Zeit", Physikalisch-Technische Bundesanstalt (PTB), Braunschweig
+ * und Berlin, Maerz 1989
+ *
+ * Timecode transmission:
+ * AM:
+ *     time marks are send every second except for the second before the
+ *     next minute mark
+ *     time marks consist of a reduction of transmitter power to 25%
+ *     of the nominal level
+ *     the falling edge is the time indication (on time)
+ *     time marks of a 100ms duration constitute a logical 0
+ *     time marks of a 200ms duration constitute a logical 1
+ * FM:
+ *     see the spec. (basically a (non-)inverted psuedo random phase shift)
+ *
+ * Encoding:
+ * Second      Contents
+ * 0  - 10     AM: free, FM: 0
+ * 11 - 14     free
+ * 15          R     - alternate antenna
+ * 16          A1    - expect zone change (1 hour before)
+ * 17 - 18     Z1,Z2 - time zone
+ *              0  0 illegal
+ *              0  1 MEZ  (MET)
+ *              1  0 MESZ (MED, MET DST)
+ *              1  1 illegal
+ * 19          A2    - expect leap insertion/deletion (1 hour before)
+ * 20          S     - start of time code (1)
+ * 21 - 24     M1    - BCD (lsb first) Minutes
+ * 25 - 27     M10   - BCD (lsb first) 10 Minutes
+ * 28          P1    - Minute Parity (even)
+ * 29 - 32     H1    - BCD (lsb first) Hours
+ * 33 - 34      H10   - BCD (lsb first) 10 Hours
+ * 35          P2    - Hour Parity (even)
+ * 36 - 39     D1    - BCD (lsb first) Days
+ * 40 - 41     D10   - BCD (lsb first) 10 Days
+ * 42 - 44     DW    - BCD (lsb first) day of week (1: Monday -> 7: Sunday)
+ * 45 - 49     MO    - BCD (lsb first) Month
+ * 50           MO0   - 10 Months
+ * 51 - 53     Y1    - BCD (lsb first) Years
+ * 54 - 57     Y10   - BCD (lsb first) 10 Years
+ * 58          P3    - Date Parity (even)
+ * 59                - usually missing (minute indication), except for leap insertion
+ */
+
+static char revision[] = "4.10";
+
+static struct rawdcfcode 
+{
+       char offset;                    /* start bit */
+} rawdcfcode[] =
+{
+       {  0 }, { 15 }, { 16 }, { 17 }, { 19 }, { 20 }, { 21 }, { 25 }, { 28 }, { 29 },
+       { 33 }, { 35 }, { 36 }, { 40 }, { 42 }, { 45 }, { 49 }, { 50 }, { 54 }, { 58 }, { 59 }
+};
+
+#define DCF_M  0
+#define DCF_R  1
+#define DCF_A1 2
+#define DCF_Z  3
+#define DCF_A2 4
+#define DCF_S  5
+#define DCF_M1 6
+#define DCF_M10        7
+#define DCF_P1 8
+#define DCF_H1 9
+#define DCF_H10        10
+#define DCF_P2 11
+#define DCF_D1 12
+#define DCF_D10        13
+#define DCF_DW 14
+#define DCF_MO 15
+#define DCF_MO0        16
+#define DCF_Y1 17
+#define DCF_Y10        18
+#define DCF_P3 19
+
+static struct partab
+{
+       char offset;                    /* start bit of parity field */
+} partab[] =
+{
+       { 21 }, { 29 }, { 36 }, { 59 }
+};
+
+#define DCF_P_P1       0
+#define DCF_P_P2       1
+#define DCF_P_P3       2
+
+#define DCF_Z_MET 0x2
+#define DCF_Z_MED 0x1
+
+static unsigned long
+ext_bf(
+       register unsigned char *buf,
+       register int   idx
+       )
+{
+       register unsigned long sum = 0;
+       register int i, first;
+
+       first = rawdcfcode[idx].offset;
+  
+       for (i = rawdcfcode[idx+1].offset - 1; i >= first; i--)
+       {
+               sum <<= 1;
+               sum |= (buf[i] != '-');
+       }
+       return sum;
+}
+
+static unsigned
+pcheck(
+       register unsigned char *buf,
+       register int   idx
+       )
+{
+       register int i,last;
+       register unsigned psum = 1;
+
+       last = partab[idx+1].offset;
+
+       for (i = partab[idx].offset; i < last; i++)
+           psum ^= (buf[i] != '-');
+
+       return psum;
+}
+
+static unsigned long
+convert_rawdcf(
+       register unsigned char   *buffer,
+       register int              size,
+       register clocktime_t     *clock_time
+       )
+{
+       if (size < 57)
+       {
+               printf("%-30s", "*** INCOMPLETE");
+               return CVT_NONE;
+       }
+  
+       /*
+        * check Start and Parity bits
+        */
+       if ((ext_bf(buffer, DCF_S) == 1) &&
+           pcheck(buffer, DCF_P_P1) &&
+           pcheck(buffer, DCF_P_P2) &&
+           pcheck(buffer, DCF_P_P3))
+       {
+               /*
+                * buffer OK
+                */
+
+               clock_time->flags  = 0;
+               clock_time->usecond= 0;
+               clock_time->second = 0;
+               clock_time->minute = ext_bf(buffer, DCF_M10);
+               clock_time->minute = TIMES10(clock_time->minute) + ext_bf(buffer, DCF_M1);
+               clock_time->hour   = ext_bf(buffer, DCF_H10);
+               clock_time->hour   = TIMES10(clock_time->hour) + ext_bf(buffer, DCF_H1);
+               clock_time->day    = ext_bf(buffer, DCF_D10);
+               clock_time->day    = TIMES10(clock_time->day) + ext_bf(buffer, DCF_D1);
+               clock_time->month  = ext_bf(buffer, DCF_MO0);
+               clock_time->month  = TIMES10(clock_time->month) + ext_bf(buffer, DCF_MO);
+               clock_time->year   = ext_bf(buffer, DCF_Y10);
+               clock_time->year   = TIMES10(clock_time->year) + ext_bf(buffer, DCF_Y1);
+               clock_time->wday   = ext_bf(buffer, DCF_DW);
+
+               switch (ext_bf(buffer, DCF_Z))
+               {
+                   case DCF_Z_MET:
+                       clock_time->utcoffset = -60;
+                       break;
+
+                   case DCF_Z_MED:
+                       clock_time->flags     |= DCFB_DST;
+                       clock_time->utcoffset  = -120;
+                       break;
+
+                   default:
+                       printf("%-30s", "*** BAD TIME ZONE");
+                       return CVT_FAIL|CVT_BADFMT;
+               }
+
+               if (ext_bf(buffer, DCF_A1))
+                   clock_time->flags |= DCFB_ANNOUNCE;
+
+               if (ext_bf(buffer, DCF_A2))
+                   clock_time->flags |= DCFB_LEAP;
+
+               if (ext_bf(buffer, DCF_R))
+                   clock_time->flags |= DCFB_ALTERNATE;
+
+               return CVT_OK;
+       }
+       else
+       {
+               /*
+                * bad format - not for us
+                */
+               printf("%-30s", "*** BAD FORMAT (invalid/parity)");
+               return CVT_FAIL|CVT_BADFMT;
+       }
+}
+
+static char
+type(
+       unsigned int c
+       )
+{
+       c ^= 0xFF;
+       return (c >= 0xF);
+}
+
+static const char *wday[8] =
+{
+       "??",
+       "Mo",
+       "Tu",
+       "We",
+       "Th",
+       "Fr",
+       "Sa",
+       "Su"
+};
+
+static char pat[] = "-\\|/";
+
+#define LINES (24-2)   /* error lines after which the two headlines are repeated */
+
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       if ((argc != 2) && (argc != 3))
+       {
+               fprintf(stderr, "usage: %s [-f|-t|-ft|-tf] <device>\n", argv[0]);
+               exit(1);
+       }
+       else
+       {
+               unsigned char c;
+               char *file;
+               int fd;
+               int offset = 15;
+               int trace = 0;
+               int errs = LINES+1;
+
+               /*
+                * SIMPLE(!) argument "parser"
+                */
+               if (argc == 3)
+               {
+                       if (strcmp(argv[1], "-f") == 0)
+                           offset = 0;
+                       if (strcmp(argv[1], "-t") == 0)
+                           trace = 1;
+                       if ((strcmp(argv[1], "-ft") == 0) ||
+                           (strcmp(argv[1], "-tf") == 0))
+                       {
+                               offset = 0;
+                               trace = 1;
+                       }
+                       file = argv[2];
+               }
+               else
+               {
+                       file = argv[1];
+               }
+
+               fd = open(file, O_RDONLY);
+               if (fd == -1)
+               {
+                       perror(file);
+                       exit(1);
+               }
+               else
+               {
+                       int i;
+#ifdef TIOCM_RTS
+                       int on = TIOCM_RTS;
+#endif
+                       struct timeval t, tt, tlast;
+                       char buf[61];
+                       clocktime_t clock_time;
+                       struct termios term;
+                       int rtc = CVT_NONE;
+
+                       if (tcgetattr(fd,  &term) == -1)
+                       {
+                               perror("tcgetattr");
+                               exit(1);
+                       }
+
+                       memset(term.c_cc, 0, sizeof(term.c_cc));
+                       term.c_cc[VMIN] = 1;
+#ifdef NO_PARENB_IGNPAR /* Was: defined(SYS_IRIX4) || defined (SYS_IRIX5) */
+                       /* somehow doesn't grok PARENB & IGNPAR (mj) */
+                       term.c_cflag = CS8|CREAD|CLOCAL;
+#else
+                       term.c_cflag = CS8|CREAD|CLOCAL|PARENB;
+#endif
+                       term.c_iflag = IGNPAR;
+                       term.c_oflag = 0;
+                       term.c_lflag = 0;
+
+                       cfsetispeed(&term, B50);
+                       cfsetospeed(&term, B50);
+
+                       if (tcsetattr(fd, TCSANOW, &term) == -1)
+                       {
+                               perror("tcsetattr");
+                               exit(1);
+                       }
+
+#ifdef I_POP
+                       while (ioctl(fd, I_POP, 0) == 0)
+                           ;
+#endif
+#if defined(TIOCMBIC) && defined(TIOCM_RTS)
+                       if (ioctl(fd, TIOCMBIC, (caddr_t)&on) == -1)
+                       {
+                               perror("TIOCM_RTS");
+                       }
+#endif
+
+                       printf("  DCF77 monitor %s - Copyright (C) 1993-2005, Frank Kardel\n\n", revision);
+
+                       clock_time.hour = 0;
+                       clock_time.minute = 0;
+                       clock_time.day = 0;
+                       clock_time.wday = 0;
+                       clock_time.month = 0;
+                       clock_time.year = 0;
+                       clock_time.flags = 0;
+                       buf[60] = '\0';
+                       for ( i = 0; i < 60; i++)
+                           buf[i] = '.';
+
+                       gettimeofday(&tlast, 0L);
+                       i = 0;
+                       while (read(fd, &c, 1) == 1)
+                       {
+                               gettimeofday(&t, 0L);
+                               tt = t;
+                               t.tv_sec -= tlast.tv_sec;
+                               t.tv_usec -= tlast.tv_usec;
+                               if (t.tv_usec < 0)
+                               {
+                                       t.tv_usec += 1000000;
+                                       t.tv_sec  -= 1;
+                               }
+
+                               if (errs > LINES)
+                               {
+                                       printf("  %s", &"PTB private....RADMLSMin....PHour..PMDay..DayMonthYear....P\n"[offset]);
+                                       printf("  %s", &"---------------RADMLS1248124P124812P1248121241248112481248P\n"[offset]);
+                                       errs = 0;
+                               }
+
+                               if (t.tv_sec > 1 ||
+                                   (t.tv_sec == 1 &&
+                                    t.tv_usec > 500000))
+                               {
+                                       printf("%c %.*s ", pat[i % (sizeof(pat)-1)], 59 - offset, &buf[offset]);
+
+                                       if ((rtc = convert_rawdcf((unsigned char *)buf, i, &clock_time)) != CVT_OK)
+                                       {
+                                               printf("\n");
+                                               clock_time.hour = 0;
+                                               clock_time.minute = 0;
+                                               clock_time.day = 0;
+                                               clock_time.wday = 0;
+                                               clock_time.month = 0;
+                                               clock_time.year = 0;
+                                               clock_time.flags = 0;
+                                               errs++;
+                                       }
+
+                                       if (((c^0xFF)+1) & (c^0xFF))
+                                           buf[0] = '?';
+                                       else
+                                           buf[0] = type(c) ? '#' : '-';
+
+                                       for ( i = 1; i < 60; i++)
+                                           buf[i] = '.';
+
+                                       i = 0;
+                               }
+                               else
+                               {
+                                       if (((c^0xFF)+1) & (c^0xFF))
+                                           buf[i] = '?';
+                                       else
+                                           buf[i] = type(c) ? '#' : '-';
+
+                                       printf("%c %.*s ", pat[i % (sizeof(pat)-1)], 59 - offset, &buf[offset]);
+                               }
+
+                               if (rtc == CVT_OK)
+                               {
+                                       printf("%s, %2d:%02d:%02d, %d.%02d.%02d, <%s%s%s%s>",
+                                              wday[clock_time.wday],
+                                              (int)clock_time.hour, (int)clock_time.minute, (int)i, (int)clock_time.day, (int)clock_time.month,
+                                              (int)clock_time.year,
+                                              (clock_time.flags & DCFB_ALTERNATE) ? "R" : "_",
+                                              (clock_time.flags & DCFB_ANNOUNCE) ? "A" : "_",
+                                              (clock_time.flags & DCFB_DST) ? "D" : "_",
+                                              (clock_time.flags & DCFB_LEAP) ? "L" : "_"
+                                              );
+                                       if (trace && (i == 0))
+                                       {
+                                               printf("\n");
+                                               errs++;
+                                       }
+                               }
+
+                               printf("\r");
+
+                               if (i < 60)
+                               {
+                                       i++;
+                               }
+
+                               tlast = tt;
+
+                               fflush(stdout);
+                       }
+                       close(fd);
+               }
+       }
+       return 0;
+}
+
+/*
+ * History:
+ *
+ * testdcf.c,v
+ * Revision 4.10  2005/08/06 14:18:43  kardel
+ * cleanup warnings
+ *
+ * Revision 4.9  2005/08/06 14:14:38  kardel
+ * document revision on startup
+ *
+ * Revision 4.8  2005/08/06 14:10:08  kardel
+ * fix setting of baud rate
+ *
+ * Revision 4.7  2005/04/16 17:32:10  kardel
+ * update copyright
+ *
+ * Revision 4.6  2004/11/14 15:29:42  kardel
+ * support PPSAPI, upgrade Copyright to Berkeley style
+ *
+ */
diff --git a/ports/winnt/include/arpa/inet.h b/ports/winnt/include/arpa/inet.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/clockstuff.h b/ports/winnt/include/clockstuff.h
new file mode 100644 (file)
index 0000000..f523bd7
--- /dev/null
@@ -0,0 +1,38 @@
+#ifndef _CLOCKSTUFF_H
+#define _CLOCKSTUFF_H
+
+#include "ntp_machine.h"
+#include <time.h>
+#include <sys\timeb.h>
+
+#include "ntp_syslog.h"
+
+/* Windows NT versions of gettimeofday and settimeofday
+ *
+ * ftime() has internal DayLightSavings related BUGS
+ * therefore switched to GetSystemTimeAsFileTime()
+ */
+
+void init_winnt_time(void);
+void shutdown_winnt_time(void);
+void reset_winnt_time(void);
+void lock_thread_to_processor(HANDLE);
+
+/* 100ns intervals between 1/1/1601 and 1/1/1970 as reported by
+ * SystemTimeToFileTime()
+ */
+
+#define FILETIME_1970     0x019db1ded53e8000
+#define HECTONANOSECONDS  10000000ui64
+
+/*
+ * Multimedia Timer
+ */
+
+void set_mm_timer(int);
+
+enum {
+       MM_TIMER_LORES,
+       MM_TIMER_HIRES
+};
+#endif
diff --git a/ports/winnt/include/config.h b/ports/winnt/include/config.h
new file mode 100644 (file)
index 0000000..c0ef778
--- /dev/null
@@ -0,0 +1,358 @@
+/* config.h for Windows NT */
+
+#ifndef __CONFIG_H
+#define __CONFIG_H
+
+/*
+ * For newer compilers we may we want newer prototypes from Windows
+ * so we target _WIN32_WINNT at WINXP, but we also want our binary to
+ * run on NT 4, so newer functions are runtime linked and the linker
+ * /version:0x0400 * switch is used to override the .exe file minimum
+ * version. For older compilers we leave it at NT 4.0.
+ */
+#ifndef _WIN32_WINNT
+#if _MSC_VER > 1400            /* At least VS 2005 */
+#define _WIN32_WINNT 0x0501
+#else                          /* NT 4.0 */
+#define _WIN32_WINNT 0x0400 
+#endif
+#endif
+
+
+#define _CRT_SECURE_NO_DEPRECATE 1
+/*
+ * ANSI C compliance enabled
+ */
+#define __STDC__ 1
+
+/*
+ * We need to include string.h first before we override strerror
+ * otherwise we can get errors during the build
+ */
+#include <string.h>
+
+/*
+ * We need to include stdio.h first before we #define snprintf
+ * otherwise we can get errors during the build
+ */
+#include <stdio.h>
+
+/* Prevent inclusion of winsock.h in windows.h */
+#ifndef _WINSOCKAPI_
+#define _WINSOCKAPI_  
+#endif
+
+#ifndef __RPCASYNC_H__
+#define __RPCASYNC_H__
+#endif
+
+/*
+ * VS.NET's version of wspiapi.h has a bug in it
+ * where it assigns a value to a variable inside
+ * an if statement. It should be comparing them.
+ * We prevent inclusion since we are not using this
+ * code so we don't have to see the warning messages
+ */
+#ifndef _WSPIAPI_H_
+/* #define _WSPIAPI_H_ */ /* need these wrappers for ntpd.exe to load on w2k */
+#endif
+
+/* Include Windows headers */
+#include <windows.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+
+/*
+ * Some definitions we are using are missing in the headers
+ * shipping with VC6. However, if the SDK is installed then the 
+ * SDK's headers may declare the missing types. This is at least 
+ * the case in the Oct 2001 SDK. That SDK and all subsequent 
+ * versions also define the symbol _W64, so we can use that one
+ * to determine whether some types need to be defined, or not.
+ */
+#ifdef _W64
+/* VC6 can include wspiapi.h only if the SDK is installed */
+#include <wspiapi.h>
+#endif
+
+/* #include <runtimelink.h> */ /* must come after ws2tcpip.h */
+#undef interface
+#include <process.h>
+
+/* ---------------------------------------------------------------------
+ * Above this line are #include lines and the few #define lines
+ * needed before including headers.
+ */
+
+/*
+ * IPv6 requirements
+ */
+/*
+ * For VS.NET most of the IPv6 types and structures are defined.
+ * This should depend on the contrents of the available headers, 
+ * not on the compiler version.
+ */
+#if defined _MSC_VER && _MSC_VER > 1200
+#define HAVE_STRUCT_SOCKADDR_STORAGE
+#define ISC_PLATFORM_HAVEIPV6
+#define ISC_PLATFORM_HAVEIN6PKTINFO
+#define NO_OPTION_NAME_WARNINGS
+#endif
+
+#ifndef _W64
+/* VC6 doesn't know about socklen_t, except if the SDK is installed */
+typedef int socklen_t;
+#endif
+
+#define ISC_PLATFORM_NEEDIN6ADDRANY
+#define HAVE_SOCKADDR_IN6
+
+/*
+ * The type of the socklen_t defined for getnameinfo() and getaddrinfo()
+ * is int for VS compilers on Windows but the type is already declared 
+ */
+#define GETSOCKNAME_SOCKLEN_TYPE socklen_t
+
+#if defined _MSC_VER && _MSC_VER < 1400
+/*
+ * Use 32-bit time definitions for versions prior to VS 2005
+ * VS 2005 defaults to 64-bit time
+ */
+# define SIZEOF_TIME_T 4
+#else
+# define SIZEOF_TIME_T 8
+#endif
+
+
+/*
+ * An attempt to cut down the number of warnings generated during compilation.
+ * All of these should be benign to disable.
+ */
+
+#pragma warning(disable: 4100) /* unreferenced formal parameter */
+#pragma warning(disable: 4101) /* unreferenced local variable */
+#pragma warning(disable: 4127) /* conditional expression is constant */
+#pragma warning(disable: 4996) /* more secure replacement available */
+
+/*
+ * Windows NT Configuration Values
+ */
+#if defined _DEBUG /* Use VC standard macro definitions */
+# define DEBUG 1
+#endif
+
+#define __windows__ 1
+/* Define if you have the ANSI C header files.  */
+#define STDC_HEADERS 1
+
+#define OPEN_BCAST_SOCKET              1       /* for ntp_io.c */
+#define TYPEOF_IP_MULTICAST_LOOP       BOOL
+#define SETSOCKOPT_ARG_CAST            (const char *)
+#define HAVE_RANDOM 
+#define MAXHOSTNAMELEN                 64
+#define AUTOKEY
+
+/*
+ * Multimedia timer enable
+ */
+#define USE_MM_TIMER
+
+/* Enable OpenSSL */
+#define OPENSSL 1
+
+/*
+ * Keywords and functions that Microsoft maps
+ * to other names
+ */
+#define inline         __inline
+#define vsnprintf      _vsnprintf
+#define snprintf       _snprintf
+#define stricmp                _stricmp
+#define strcasecmp     _stricmp
+#define isascii                __isascii
+#define finite         _finite
+#define random         rand
+#define srandom                srand
+#define fdopen         _fdopen
+#define read           _read
+#define open           _open
+#ifndef close
+#define close          _close
+#endif
+#define write          _write
+#define strdup         _strdup
+#define stat           _stat           /*struct stat from  <sys/stat.h> */
+#define unlink         _unlink
+/*
+ * punt on fchmod on Windows
+ */
+#define fchmod(x,y)    {}
+#define lseek          _lseek
+#define pipe           _pipe
+#define dup2           _dup2
+/*
+ * scale, unix sleep is seconds, Windows Sleep is msec
+ */
+#define sleep(x)       Sleep((unsigned)(x) * 1000)
+#define fileno         _fileno
+#define isatty         _isatty
+#define mktemp         _mktemp
+#define getpid         _getpid
+
+typedef int pid_t;             /* PID is an int */
+typedef int ssize_t;           /* ssize is an int */
+typedef __int32 int32_t;       /* define a typedef for int32_t */
+#define HAVE_INT32_T   1
+
+/*
+ * Map the stream to the file number
+ */
+#define STDOUT_FILENO  _fileno(stdout)
+#define STDERR_FILENO  _fileno(stderr)
+
+/* Point to a local version for error string handling */
+# define strerror      NTstrerror
+char *NTstrerror(int errnum);
+
+int NT_set_process_priority(void);     /* Define this function */
+
+# define MCAST                         /* Enable Multicast Support */
+# define MULTICAST_NONEWSOCKET         /* Don't create a new socket for mcast address */
+
+# define REFCLOCK                      /* from ntpd.mak */
+
+# define CLOCK_LOCAL                   /* from ntpd.mak */
+/* # define CLOCK_PARSE  */
+/* # define CLOCK_ATOM */
+/* # define HAVE_TIMEPPS_H */
+/* # define HAVE_PPSAPI */
+/* # define CLOCK_SHM  */               /* from ntpd.mak */
+# define CLOCK_HOPF_SERIAL     /* device 38, hopf DCF77/GPS serial line receiver  */
+# define CLOCK_HOPF_PCI                /* device 39, hopf DCF77/GPS PCI-Bus receiver  */
+# define CLOCK_NMEA
+# define CLOCK_PALISADE                /* from ntpd.mak */
+# define CLOCK_DUMBCLOCK
+# define CLOCK_TRIMBLEDC
+# define CLOCK_TRIMTSIP 1
+# define CLOCK_JUPITER
+
+# define NTP_LITTLE_ENDIAN             /* from libntp.mak */
+# define NTP_POSIX_SOURCE
+
+# define SYSLOG_FILE                   /* from libntp.mak */
+# define SYSV_TIMEOFDAY                        /* for ntp_unixtime.h */
+
+# define SIZEOF_SIGNED_CHAR    1
+# define SIZEOF_INT            4       /* for ntp_types.h */
+
+# define QSORT_USES_VOID_P
+# define HAVE_SETVBUF
+# define HAVE_VSPRINTF
+# define HAVE_SNPRINTF
+# define HAVE_VSNPRINTF
+# define HAVE_PROTOTYPES               /* from ntpq.mak */
+# define HAVE_MEMMOVE
+# define HAVE_TERMIOS_H
+# define HAVE_ERRNO_H
+# define HAVE_STDARG_H
+# define HAVE_NO_NICE
+# define HAVE_MKTIME
+# define TIME_WITH_SYS_TIME
+# define HAVE_IO_COMPLETION_PORT
+# define ISC_PLATFORM_NEEDNTOP
+# define ISC_PLATFORM_NEEDPTON
+# define HAVE_VPRINTF
+
+#define HAVE_LIMITS_H  1
+#define HAVE_STRDUP    1
+#define HAVE_STRCHR    1
+#define HAVE_FCNTL_H   1
+
+#ifndef _INTPTR_T_DEFINED
+typedef long intptr_t;
+#define _INTPTR_T_DEFINED
+#endif
+#define HAVE_INTPTR_T
+
+#ifndef _UINTPTR_T_DEFINED
+typedef unsigned long uintptr_t;
+#define _UINTPTR_T_DEFINED
+#endif
+#define HAVE_UINTPTR_T
+
+#if !defined( _W64 )
+  /*
+   * if DWORD_PTR needs to be defined then the build environment
+   * is pure 32 bit Windows. Since DWORD_PTR and DWORD have 
+   * the same size in 32 bit Windows we can safely define
+   * a replacement.
+   */
+  typedef DWORD DWORD_PTR;
+#endif
+
+#define NEED_S_CHAR_TYPEDEF
+
+#define USE_PROTOTYPES                 /* for ntp_types.h */
+
+/* Directory separator, usually / or \ */
+#define        DIR_SEP '\\'
+
+
+#define ULONG_CONST(a) a ## UL
+
+#define NOKMEM
+#define RETSIGTYPE void
+
+#ifndef STR_SYSTEM
+#define STR_SYSTEM "Windows"
+#endif
+
+#ifndef STR_PROCESSOR
+
+#define STRINGIZE(arg) #arg
+
+#ifdef _M_IX86
+#ifndef _M_IX86_FP
+#define STR_PROCESSOR "x86"
+#else
+#if !_M_IX86_FP 
+#define STR_PROCESSOR "x86"
+#else 
+#if _M_IX86_FP > 2
+#define STR_PROCESSOR "x86-FP-" STRINGIZE(_M_IX86_FP)
+#else
+#if _M_IX86_FP == 2
+#define STR_PROCESSOR "x86-SSE2"
+#else
+#define STR_PROCESSOR "x86-SSE"
+#endif /* _M_IX86 == 2 */
+#endif /* _M_IX86_FP > 2 */
+#endif /* !_M_IX86_FP */
+#endif /* !defined(_M_IX86_FP) */
+#endif /* !defined(_M_IX86) */
+
+#ifdef _M_IA64
+#define STR_PROCESSOR "Itanium"
+#endif
+
+#ifdef _M_X64
+#define STR_PROCESSOR "x64"
+#endif
+
+#endif /* !defined(STR_PROCESSOR) */
+
+#define  SIOCGIFFLAGS SIO_GET_INTERFACE_LIST /* used in ntp_io.c */
+/*
+ * Below this line are includes which must happen after the bulk of
+ * config.h is processed.  If you need to add another #include to this
+ * file the preferred location is near the top, above the similar
+ * line of hyphens.
+ * ---------------------------------------------------------------------
+ */
+
+/*
+ * Include standard stat information
+ */
+#include <isc/stat.h>
+
+#endif /* __CONFIG_H */
diff --git a/ports/winnt/include/hopf_PCI_io.h b/ports/winnt/include/hopf_PCI_io.h
new file mode 100755 (executable)
index 0000000..7bca1d3
--- /dev/null
@@ -0,0 +1,91 @@
+/* 
+ * hopf_PCI_io.h
+ * structur definition and prototype Function declarations
+ *
+ * Date: 21.03.2000 Revision: 01.10 
+ *
+ * Copyright (C) 1999, 2000 by Bernd Altmeier altmeier@ATLSoft.de
+ * 
+ */
+
+#if defined(__cplusplus)
+extern "C"{
+#endif
+
+#ifndef __inpREAD_H
+#define __inpREAD_H
+
+
+typedef struct _CLOCKVER {    
+       CHAR cVersion[255];  
+} CLOCKVER, *PCLOCKVER, *LPCLOCKVER;
+
+typedef struct _HOPFTIME {
+    WORD wYear;
+    WORD wMonth;
+    WORD wDayOfWeek;
+    WORD wDay;
+    WORD wHour;
+    WORD wMinute;
+    WORD wSecond;
+    WORD wMilliseconds;
+    WORD wStatus;
+} HOPFTIME, *PHOPFTIME, *LPHOPFTIME;
+
+typedef struct _SATSTAT {    
+       BYTE wVisible;    
+       BYTE wMode;
+    BYTE wSat0;
+       BYTE wRat0;
+       BYTE wSat1;
+       BYTE wRat1;
+       BYTE wSat2;
+       BYTE wRat2;
+       BYTE wSat3;
+       BYTE wRat3;
+       BYTE wSat4;
+       BYTE wRat4;
+       BYTE wSat5;
+       BYTE wRat5;
+       BYTE wSat6;
+       BYTE wRat6;
+       BYTE wSat7;
+       BYTE wRat7;
+} SATSTAT, *PSATSTAT, *LPSATSTAT;
+
+
+typedef struct _GPSPOS {    
+       LONG wAltitude;    // Höhe immer 0
+       LONG wLongitude;   // Länge in Msec
+       LONG wLatitude;    // Breite in Msec  
+} GPSPOS, *PGPSPOS, *LPGPSPOS;
+
+
+typedef struct _DCFANTENNE {    
+       BYTE bStatus;    
+       BYTE bStatus1;    
+       WORD wAntValue;    
+} DCFANTENNE, *PDCFANTENNE, *LPDCFANTENNE;
+
+
+
+// Function declarations
+BOOL  OpenHopfDevice();
+BOOL  CloseHopfDevice();
+VOID  GetHopfTime(LPHOPFTIME Data, DWORD Offset);
+VOID  GetHopfLocalTime(LPHOPFTIME Data);
+VOID  GetHopfSystemTime(LPHOPFTIME Data);
+VOID  GetSatData(LPSATSTAT Data);
+VOID  GetDiffTime(LPLONG Data);
+VOID  GetPosition(LPGPSPOS Data);
+VOID  GetHardwareVersion(LPCLOCKVER Data);
+VOID  GetHardwareData(LPDWORD Data,WORD Ofs);
+VOID  GetDCFAntenne(LPDCFANTENNE Data);
+#if defined(__cplusplus)
+}
+#endif 
+
+#endif /* inpREAD_H */
+
diff --git a/ports/winnt/include/isc/int.h b/ports/winnt/include/isc/int.h
new file mode 100644 (file)
index 0000000..46430c3
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: int.h,v 1.10 2001/07/09 21:06:26 gson Exp $ */
+
+#ifndef ISC_INT_H
+#define ISC_INT_H 1
+
+#define _INTEGRAL_MAX_BITS 64
+#include <limits.h>
+
+typedef __int8                         isc_int8_t;
+typedef unsigned __int8                        isc_uint8_t;
+typedef __int16                                isc_int16_t;
+typedef unsigned __int16               isc_uint16_t;
+typedef __int32                                isc_int32_t;
+typedef unsigned __int32               isc_uint32_t;
+typedef __int64                                isc_int64_t;
+typedef unsigned __int64               isc_uint64_t;
+
+#define ISC_INT8_MIN   -128
+#define ISC_INT8_MAX   127
+#define ISC_UINT8_MAX  255
+
+#define ISC_INT16_MIN  -32768
+#define ISC_INT16_MAX  32767
+#define ISC_UINT16_MAX 65535
+
+/*
+ * Note that "int" is 32 bits on all currently supported Unix-like operating
+ * systems, but "long" can be either 32 bits or 64 bits, thus the 32 bit
+ * constants are not qualified with "L".
+ */
+#define ISC_INT32_MIN  _I32_MIN
+#define ISC_INT32_MAX  _I32_MAX
+#define ISC_UINT32_MAX _UI32_MAX
+
+#define ISC_INT64_MIN  _I64_MIN
+#define ISC_INT64_MAX  _I64_MAX
+#define ISC_UINT64_MAX _UI64_MAX
+
+#endif /* ISC_INT_H */
diff --git a/ports/winnt/include/isc/ipv6.h b/ports/winnt/include/isc/ipv6.h
new file mode 100644 (file)
index 0000000..828ca76
--- /dev/null
@@ -0,0 +1,129 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2000-2002  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: ipv6.h,v 1.9.2.2.2.5 2004/04/19 06:39:55 marka Exp $ */
+
+#ifndef ISC_IPV6_H
+#define ISC_IPV6_H 1
+
+/*****
+ ***** Module Info
+ *****/
+
+/*
+ * IPv6 definitions for systems which do not support IPv6.
+ *
+ * MP:
+ *     No impact.
+ *
+ * Reliability:
+ *     No anticipated impact.
+ *
+ * Resources:
+ *     N/A.
+ *
+ * Security:
+ *     No anticipated impact.
+ *
+ * Standards:
+ *     RFC 2553.
+ */
+
+#if _MSC_VER < 1300
+#define in6_addr in_addr6
+#endif
+
+#ifndef IN6ADDR_ANY_INIT
+#define IN6ADDR_ANY_INIT       {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 }}
+#endif
+#ifndef IN6ADDR_LOOPBACK_INIT
+#define IN6ADDR_LOOPBACK_INIT  {{ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 }}
+#endif
+
+extern const struct in6_addr isc_in6addr_any;
+extern const struct in6_addr isc_in6addr_loopback;
+
+/*
+ * Unspecified
+ */
+
+#ifndef IN6_IS_ADDR_UNSPECIFIED
+#define IN6_IS_ADDR_UNSPECIFIED(a)     (\
+*((u_long *)((a)->s6_addr)    ) == 0 && \
+*((u_long *)((a)->s6_addr) + 1) == 0 && \
+*((u_long *)((a)->s6_addr) + 2) == 0 && \
+*((u_long *)((a)->s6_addr) + 3) == 0 \
+)
+#endif
+/*
+ * Loopback
+ */
+#ifndef IN6_IS_ADDR_LOOPBACK
+#define IN6_IS_ADDR_LOOPBACK(a) (\
+*((u_long *)((a)->s6_addr)    ) == 0 && \
+*((u_long *)((a)->s6_addr) + 1) == 0 && \
+*((u_long *)((a)->s6_addr) + 2) == 0 && \
+*((u_long *)((a)->s6_addr) + 3) == htonl(1) \
+)
+#endif
+
+/*
+ * IPv4 compatible
+ */
+#ifndef IN6_IS_ADDR_V4COMPAT
+#define IN6_IS_ADDR_V4COMPAT(a)  (\
+*((u_long *)((a)->s6_addr)    ) == 0 && \
+*((u_long *)((a)->s6_addr) + 1) == 0 && \
+*((u_long *)((a)->s6_addr) + 2) == 0 && \
+*((u_long *)((a)->s6_addr) + 3) != 0 && \
+*((u_long *)((a)->s6_addr) + 3) != htonl(1) \
+)
+#endif
+
+/*
+ * Mapped
+ */
+#ifndef IN6_IS_ADDR_V4MAPPED
+#define IN6_IS_ADDR_V4MAPPED(a) (\
+*((u_long *)((a)->s6_addr)    ) == 0 && \
+*((u_long *)((a)->s6_addr) + 1) == 0 && \
+*((u_long *)((a)->s6_addr) + 2) == htonl(0x0000ffff))
+#endif
+
+/*
+ * Multicast
+ */
+#ifndef IN6_IS_ADDR_MULTICAST
+#define IN6_IS_ADDR_MULTICAST(a)       \
+       ((a)->s6_addr[0] == 0xffU)
+#endif
+/*
+ * Unicast link / site local.
+ */
+#ifndef IN6_IS_ADDR_LINKLOCAL
+#define IN6_IS_ADDR_LINKLOCAL(a)       (\
+(*((u_long *)((a)->s6_addr)    ) == 0xfe) && \
+((*((u_long *)((a)->s6_addr) + 1) & 0xc0) == 0x80))
+#endif
+
+#ifndef IN6_IS_ADDR_SITELOCAL
+#define IN6_IS_ADDR_SITELOCAL(a)       (\
+(*((u_long *)((a)->s6_addr)    ) == 0xfe) && \
+((*((u_long *)((a)->s6_addr) + 1) & 0xc0) == 0xc0))
+#endif
+
+#endif /* ISC_IPV6_H */
diff --git a/ports/winnt/include/isc/mutex.h b/ports/winnt/include/isc/mutex.h
new file mode 100644 (file)
index 0000000..cb168ac
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 1998-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: mutex.h,v 1.16 2001/07/09 21:06:27 gson Exp $ */
+
+#ifndef ISC_MUTEX_H
+#define ISC_MUTEX_H 1
+
+#include <isc/net.h>
+#include <windows.h>
+
+#include <isc/result.h>
+
+typedef CRITICAL_SECTION isc_mutex_t;
+
+/* This definition is here since WINBASE.H omits it for some reason */
+
+WINBASEAPI BOOL WINAPI
+TryEnterCriticalSection(LPCRITICAL_SECTION lpCriticalSection);
+
+#define isc_mutex_init(mp) \
+       (InitializeCriticalSection((mp)), ISC_R_SUCCESS)
+#define isc_mutex_lock(mp) \
+       (EnterCriticalSection((mp)), ISC_R_SUCCESS)
+#define isc_mutex_unlock(mp) \
+       (LeaveCriticalSection((mp)), ISC_R_SUCCESS)
+#define isc_mutex_trylock(mp) \
+       (TryEnterCriticalSection((mp)) ? ISC_R_SUCCESS : ISC_R_LOCKBUSY)
+#define isc_mutex_destroy(mp) \
+       (DeleteCriticalSection((mp)), ISC_R_SUCCESS)
+
+/*
+ * This is a placeholder for now since we are not keeping any mutex stats
+ */
+#define isc_mutex_stats(fp)
+
+#endif /* ISC_MUTEX_H */
diff --git a/ports/winnt/include/isc/net.h b/ports/winnt/include/isc/net.h
new file mode 100644 (file)
index 0000000..e43f32d
--- /dev/null
@@ -0,0 +1,325 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: net.h,v 1.15.12.10 2004/04/29 01:31:23 marka Exp $ */
+
+#ifndef ISC_NET_H
+#define ISC_NET_H 1
+
+/*
+ * Also define LWRES_IPV6_H to keep it from being included if liblwres is
+ * being used, or redefinition errors will occur.
+ */
+#define LWRES_IPV6_H 1
+
+
+
+/*****
+ ***** Module Info
+ *****/
+
+/*
+ * Basic Networking Types
+ *
+ * This module is responsible for defining the following basic networking
+ * types:
+ *
+ *             struct in_addr
+ *             struct in6_addr
+ *             struct in6_pktinfo
+ *             struct sockaddr
+ *             struct sockaddr_in
+ *             struct sockaddr_in6
+ *             in_port_t
+ *
+ * It ensures that the AF_ and PF_ macros are defined.
+ *
+ * It declares ntoh[sl]() and hton[sl]().
+ *
+ * It declares inet_aton(), inet_ntop(), and inet_pton().
+ *
+ * It ensures that INADDR_ANY, IN6ADDR_ANY_INIT, in6addr_any, and
+ * in6addr_loopback are available.
+ *
+ * It ensures that IN_MULTICAST() is available to check for multicast
+ * addresses.
+ *
+ * MP:
+ *     No impact.
+ *
+ * Reliability:
+ *     No anticipated impact.
+ *
+ * Resources:
+ *     N/A.
+ *
+ * Security:
+ *     No anticipated impact.
+ *
+ * Standards:
+ *     BSD Socket API
+ *     RFC 2553
+ */
+
+/***
+ *** Imports.
+ ***/
+#include <isc/platform.h>
+
+/*
+ * Because of some sort of problem in the MS header files, this cannot
+ * be simple "#include <winsock2.h>", because winsock2.h tries to include
+ * windows.h, which then generates an error out of mswsock.h.  _You_
+ * figure it out.
+ */
+#ifndef _WINSOCKAPI_
+#define _WINSOCKAPI_   /* Prevent inclusion of winsock.h in windows.h */
+#endif
+
+#include <winsock2.h>
+
+#include <sys/types.h>
+
+#include <isc/lang.h>
+#include <isc/types.h>
+
+#include <ws2tcpip.h>
+#include <isc/ipv6.h>
+
+/*
+ * This is here because named client, interfacemgr.c, etc. use the name as
+ * a variable
+ */
+#undef interface 
+
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK 0x7f000001UL
+#endif
+
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifndef ISC_PLATFORM_HAVEIN6PKTINFO
+struct in6_pktinfo {
+       struct in6_addr ipi6_addr;    /* src/dst IPv6 address */
+       unsigned int    ipi6_ifindex; /* send/recv interface index */
+};
+#endif
+#endif
+
+#if _MSC_VER < 1300
+#define in6addr_any isc_net_in6addrany
+#define in6addr_loopback isc_in6addr_loopback
+#endif
+
+/*
+ * Ensure type in_port_t is defined.
+ */
+#ifdef ISC_PLATFORM_NEEDPORTT
+typedef isc_uint16_t in_port_t;
+#endif
+
+/*
+ * If this system does not have MSG_TRUNC (as returned from recvmsg())
+ * ISC_PLATFORM_RECVOVERFLOW will be defined.  This will enable the MSG_TRUNC
+ * faking code in socket.c.
+ */
+#ifndef MSG_TRUNC
+#define ISC_PLATFORM_RECVOVERFLOW
+#endif
+
+#define ISC__IPADDR(x) ((isc_uint32_t)htonl((isc_uint32_t)(x)))
+
+#define ISC_IPADDR_ISMULTICAST(i) \
+               (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \
+                == ISC__IPADDR(0xe0000000))
+
+#define ISC_IPADDR_ISEXPERIMENTAL(i) \
+               (((isc_uint32_t)(i) & ISC__IPADDR(0xf0000000)) \
+                == ISC__IPADDR(0xf0000000))
+
+/*
+ * Fix the FD_SET and FD_CLR Macros to properly cast
+ */
+#undef FD_CLR
+#define FD_CLR(fd, set) do { \
+    u_int __i; \
+    for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
+        if (((fd_set FAR *)(set))->fd_array[__i] == (SOCKET) fd) { \
+            while (__i < ((fd_set FAR *)(set))->fd_count-1) { \
+                ((fd_set FAR *)(set))->fd_array[__i] = \
+                    ((fd_set FAR *)(set))->fd_array[__i+1]; \
+                __i++; \
+            } \
+            ((fd_set FAR *)(set))->fd_count--; \
+            break; \
+        } \
+    } \
+} while (0)
+
+#undef FD_SET
+#define FD_SET(fd, set) do { \
+    u_int __i; \
+    for (__i = 0; __i < ((fd_set FAR *)(set))->fd_count; __i++) { \
+        if (((fd_set FAR *)(set))->fd_array[__i] == (SOCKET)(fd)) { \
+            break; \
+        } \
+    } \
+    if (__i == ((fd_set FAR *)(set))->fd_count) { \
+        if (((fd_set FAR *)(set))->fd_count < FD_SETSIZE) { \
+            ((fd_set FAR *)(set))->fd_array[__i] = (SOCKET)(fd); \
+            ((fd_set FAR *)(set))->fd_count++; \
+        } \
+    } \
+} while (0)
+
+/*
+ * Windows Sockets errors redefined as regular Berkeley error constants.
+ * These are usually commented out in Windows NT to avoid conflicts with errno.h.
+ * Use the WSA constants instead.
+ */
+
+#define EWOULDBLOCK             WSAEWOULDBLOCK
+#define EINPROGRESS             WSAEINPROGRESS
+#define EALREADY                WSAEALREADY
+#define ENOTSOCK                WSAENOTSOCK
+#define EDESTADDRREQ            WSAEDESTADDRREQ
+#define EMSGSIZE                WSAEMSGSIZE
+#define EPROTOTYPE              WSAEPROTOTYPE
+#define ENOPROTOOPT             WSAENOPROTOOPT
+#define EPROTONOSUPPORT         WSAEPROTONOSUPPORT
+#define ESOCKTNOSUPPORT         WSAESOCKTNOSUPPORT
+#define EOPNOTSUPP              WSAEOPNOTSUPP
+#define EPFNOSUPPORT            WSAEPFNOSUPPORT
+#define EAFNOSUPPORT            WSAEAFNOSUPPORT
+#define EADDRINUSE              WSAEADDRINUSE
+#define EADDRNOTAVAIL           WSAEADDRNOTAVAIL
+#define ENETDOWN                WSAENETDOWN
+#define ENETUNREACH             WSAENETUNREACH
+#define ENETRESET               WSAENETRESET
+#define ECONNABORTED            WSAECONNABORTED
+#define ECONNRESET              WSAECONNRESET
+#define ENOBUFS                 WSAENOBUFS
+#define EISCONN                 WSAEISCONN
+#define ENOTCONN                WSAENOTCONN
+#define ESHUTDOWN               WSAESHUTDOWN
+#define ETOOMANYREFS            WSAETOOMANYREFS
+#define ETIMEDOUT               WSAETIMEDOUT
+#define ECONNREFUSED            WSAECONNREFUSED
+#define ELOOP                   WSAELOOP
+#define EHOSTDOWN               WSAEHOSTDOWN
+#define EHOSTUNREACH            WSAEHOSTUNREACH
+#define EPROCLIM                WSAEPROCLIM
+#define EUSERS                  WSAEUSERS
+#define EDQUOT                  WSAEDQUOT
+#define ESTALE                  WSAESTALE
+#define EREMOTE                 WSAEREMOTE
+
+
+/***
+ *** Functions.
+ ***/
+
+ISC_LANG_BEGINDECLS
+
+isc_result_t
+isc_net_probeipv4(void);
+/*
+ * Check if the system's kernel supports IPv4.
+ *
+ * Returns:
+ *
+ *     ISC_R_SUCCESS           IPv4 is supported.
+ *     ISC_R_NOTFOUND          IPv4 is not supported.
+ *     ISC_R_DISABLED          IPv4 is disabled.
+ *     ISC_R_UNEXPECTED
+ */
+
+isc_result_t
+isc_net_probeipv6(void);
+/*
+ * Check if the system's kernel supports IPv6.
+ *
+ * Returns:
+ *
+ *     ISC_R_SUCCESS           IPv6 is supported.
+ *     ISC_R_NOTFOUND          IPv6 is not supported.
+ *     ISC_R_DISABLED          IPv6 is disabled.
+ *     ISC_R_UNEXPECTED
+ */
+
+isc_result_t
+isc_net_probe_ipv6only(void);
+/*
+ * Check if the system's kernel supports the IPV6_V6ONLY socket option.
+ *
+ * Returns:
+ *
+ *     ISC_R_SUCCESS           the option is supported for both TCP and UDP.
+ *     ISC_R_NOTFOUND          IPv6 itself or the option is not supported.
+ *     ISC_R_UNEXPECTED
+ */
+
+isc_result_t
+isc_net_probe_ipv6pktinfo(void);
+/*
+ * Check if the system's kernel supports the IPV6_(RECV)PKTINFO socket option
+ * for UDP sockets.
+ *
+ * Returns:
+ *
+ *     ISC_R_SUCCESS           the option is supported.
+ *     ISC_R_NOTFOUND          IPv6 itself or the option is not supported.
+ *     ISC_R_UNEXPECTED
+ */
+
+void
+isc_net_disableipv4(void);
+
+void
+isc_net_disableipv6(void);
+
+void
+isc_net_enableipv4(void);
+
+void
+isc_net_enableipv6(void);
+
+#ifdef ISC_PLATFORM_NEEDNTOP
+const char *
+isc_net_ntop(int af, const void *src, char *dst, size_t size);
+#define inet_ntop isc_net_ntop
+#endif
+
+#ifdef ISC_PLATFORM_NEEDPTON
+int
+isc_net_pton(int af, const char *src, void *dst);
+#define inet_pton isc_net_pton
+#endif
+
+#ifdef ISC_PLATFORM_NEEDATON
+int
+isc_net_aton(const char *cp, struct in_addr *addr);
+#define inet_aton isc_net_aton
+#endif
+
+/* Socket Initialization Code */
+
+BOOL
+Win32InitSockets();
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_NET_H */
diff --git a/ports/winnt/include/isc/offset.h b/ports/winnt/include/isc/offset.h
new file mode 100644 (file)
index 0000000..cd34ffb
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2000, 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: offset.h,v 1.2 2001/07/08 05:09:32 mayer Exp $ */
+
+#ifndef ISC_OFFSET_H
+#define ISC_OFFSET_H 1
+
+/*
+ * File offsets are operating-system dependent.
+ */
+#include <limits.h>             /* Required for CHAR_BIT. */
+#include <sys/types.h>
+typedef long off_t;
+
+typedef off_t isc_offset_t;
+
+/*
+ * POSIX says "Additionally, blkcnt_t and off_t are extended signed integral
+ * types", so the maximum value is all 1s except for the high bit.
+ * This definition is more complex than it really needs to be because it was
+ * crafted to keep both the SunOS 5.6 and the HP/UX 11 compilers quiet about
+ * integer overflow.  For example, though this is equivalent to just left
+ * shifting 1 to the high bit and then inverting the bits, the SunOS compiler
+ * is unhappy about shifting a positive "1" to negative in a signed integer.
+ */
+#define ISC_OFFSET_MAXIMUM \
+       (~(((off_t)-1 >> (sizeof(off_t) * CHAR_BIT - 1)) \
+                     << (sizeof(off_t) * CHAR_BIT - 1)))
+
+#endif /* ISC_OFFSET_H */
diff --git a/ports/winnt/include/isc/once.h b/ports/winnt/include/isc/once.h
new file mode 100644 (file)
index 0000000..e5e8366
--- /dev/null
@@ -0,0 +1,43 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: once.h,v 1.6 2001/01/09 21:59:06 bwelling Exp $ */
+
+#ifndef ISC_ONCE_H
+#define ISC_ONCE_H 1
+
+#include <isc/lang.h>
+#include <isc/result.h>
+
+ISC_LANG_BEGINDECLS
+
+typedef struct {
+       int status;
+       int counter;
+} isc_once_t;
+
+#define ISC_ONCE_INIT_NEEDED 0
+#define ISC_ONCE_INIT_DONE 1
+
+#define ISC_ONCE_INIT { ISC_ONCE_INIT_NEEDED, 1 }
+
+isc_result_t
+isc_once_do(isc_once_t *controller, void(*function)(void));
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_ONCE_H */
diff --git a/ports/winnt/include/isc/platform.h b/ports/winnt/include/isc/platform.h
new file mode 100644 (file)
index 0000000..10e2a01
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * Copyright (C) 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: platform.h,v 1.7 2001/11/19 22:32:04 gson Exp $ */
+
+#ifndef ISC_PLATFORM_H
+#define ISC_PLATFORM_H 1
+
+/*****
+ ***** Platform-dependent defines.
+ *****/
+
+#define ISC_PLATFORM_USETHREADS
+
+/***
+ *** Network.
+ ***/
+
+/*
+ * This should not be defined yet until we can support IPV6
+ * on Windows Platforms.
+ *
+#define ISC_PLATFORM_HAVEIPV6
+*/
+#define ISC_PLATFORM_NEEDPORTT
+#undef MSG_TRUNC
+#define ISC_PLATFORM_NEEDNTOP
+#define ISC_PLATFORM_NEEDPTON
+#define ISC_PLATFORM_NEEDATON
+
+#define ISC_PLATFORM_QUADFORMAT "I64"
+
+#define ISC_PLATFORM_NEEDSTRSEP
+
+/*
+ * Used to control how extern data is linked; needed for Win32 platforms.
+ */
+#define ISC_PLATFORM_USEDECLSPEC 1
+
+/*
+ * Define this here for now as winsock2.h defines h_errno
+ * and we don't want to redeclare it.
+ */
+#define ISC_PLATFORM_NONSTDHERRNO
+ /*
+ * Set up a macro for importing and exporting from the DLL
+ */
+
+#define LIBISC_EXTERNAL_DATA 
+#if 0
+#ifdef LIBISC_EXPORTS
+#define LIBISC_EXTERNAL_DATA __declspec(dllexport)
+#else
+#define LIBISC_EXTERNAL_DATA __declspec(dllimport) 
+#endif
+
+#ifdef LIBISCCFG_EXPORTS
+#define LIBISCCFG_EXTERNAL_DATA __declspec(dllexport)
+#else
+#define LIBISCCFG_EXTERNAL_DATA __declspec(dllimport) 
+#endif
+
+#ifdef LIBISCCC_EXPORTS
+#define LIBISCCC_EXTERNAL_DATA __declspec(dllexport)
+#else
+#define LIBISCCC_EXTERNAL_DATA __declspec(dllimport) 
+#endif
+
+#ifdef LIBDNS_EXPORTS
+#define LIBDNS_EXTERNAL_DATA __declspec(dllexport)
+#else
+#define LIBDNS_EXTERNAL_DATA __declspec(dllimport)
+#endif
+
+#ifdef LIBBIND9_EXPORTS
+#define LIBBIND9_EXTERNAL_DATA __declspec(dllexport)
+#else
+#define LIBBIND9_EXTERNAL_DATA __declspec(dllimport)
+#endif
+
+#endif /* if 0 */
+
+#endif /* ISC_PLATFORM_H */
diff --git a/ports/winnt/include/isc/stat.h b/ports/winnt/include/isc/stat.h
new file mode 100644 (file)
index 0000000..cb67351
--- /dev/null
@@ -0,0 +1,66 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 2000, 2001, 2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: stat.h,v 1.3.2.2.2.1 2004/03/06 08:15:17 marka Exp $ */
+
+#ifndef ISC_STAT_H
+#define ISC_STAT_H 1
+
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <io.h>
+
+/* open() under unix allows setting of read/write permissions
+ * at the owner, group and other levels.  These don't exist in NT
+ * We'll just map them all to the NT equivalent 
+ */
+
+#define S_IREAD        _S_IREAD        /* read permission, owner */
+#define S_IWRITE _S_IWRITE     /* write permission, owner */
+#define S_IRUSR _S_IREAD       /* Owner read permission */
+#define S_IWUSR _S_IWRITE      /* Owner write permission */
+#define S_IRGRP _S_IREAD       /* Group read permission */
+#define S_IWGRP _S_IWRITE      /* Group write permission */
+#define S_IROTH _S_IREAD       /* Other read permission */
+#define S_IWOTH _S_IWRITE      /* Other write permission */
+
+#ifndef S_ISDIR
+# define S_ISDIR(m)    (((m) & S_IFMT) == S_IFDIR)
+#endif
+#ifndef S_ISREG
+# define S_ISREG(m)    (((m) & S_IFMT) == S_IFREG)
+#endif
+
+#define S_IFMT   _S_IFMT         /* file type mask */
+#define S_IFDIR  _S_IFDIR        /* directory */
+#define S_IFCHR  _S_IFCHR        /* character special */
+#define S_IFIFO  _S_IFIFO        /* pipe */
+#define S_IFREG  _S_IFREG        /* regular */
+#define S_IREAD  _S_IREAD        /* read permission, owner */
+#define S_IWRITE _S_IWRITE       /* write permission, owner */
+#define S_IEXEC  _S_IEXEC        /* execute/search permission, owner */
+
+#define O_RDONLY        _O_RDONLY
+#define O_WRONLY        _O_WRONLY
+#define O_RDWR          _O_RDWR
+#define O_APPEND        _O_APPEND
+#define O_CREAT         _O_CREAT
+#define O_TRUNC         _O_TRUNC
+#define O_EXCL          _O_EXCL
+
+
+#endif /* ISC_STAT_H */
diff --git a/ports/winnt/include/isc/strerror.h b/ports/winnt/include/isc/strerror.h
new file mode 100644 (file)
index 0000000..3739681
--- /dev/null
@@ -0,0 +1,42 @@
+/*
+ * Copyright (C) 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: strerror.h,v 1.2 2001/11/20 01:45:49 gson Exp $ */
+
+#ifndef ISC_STRERROR_H
+#define ISC_STRERROR_H
+
+#include <sys/types.h>
+
+#include <isc/lang.h>
+
+ISC_LANG_BEGINDECLS
+
+#define ISC_STRERRORSIZE 128
+
+/*
+ * Provide a thread safe wrapper to strerrror().
+ *
+ * Requires:
+ *     'buf' to be non NULL.
+ */
+void
+isc__strerror(int num, char *buf, size_t bufsize);
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_STRERROR_H */
diff --git a/ports/winnt/include/isc/win32os.h b/ports/winnt/include/isc/win32os.h
new file mode 100644 (file)
index 0000000..6379456
--- /dev/null
@@ -0,0 +1,71 @@
+/*
+ * Copyright (C) 2002 Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: win32os.h,v 1.2 2002/08/03 01:36:24 mayer Exp $ */
+
+#ifndef ISC_WIN32OS_H
+#define ISC_WIN32OS_H 1
+
+#include <isc/lang.h>
+
+ISC_LANG_BEGINDECLS
+
+/*
+ * Return the number of CPUs available on the system, or 1 if this cannot
+ * be determined.
+ */
+
+unsigned int
+isc_win32os_majorversion(void);
+/*
+ * Major Version of the O/S.
+ */
+
+unsigned int
+isc_win32os_minorversion(void);
+/*
+ * Minor Version of the O/S.
+ */
+
+unsigned int
+isc_win32os_servicepackmajor(void);
+/*
+ * Major Version of the Service Pack for O/S.
+ */
+
+unsigned int
+isc_win32os_servicepackminor(void);
+/*
+ * Minor Version of the Service Pack for O/S.
+ */
+
+int
+isc_win32os_versioncheck(unsigned int major, unsigned int minor,
+                    unsigned int updatemajor, unsigned int updateminor);
+
+/*
+ * Checks the current version of the operating system with the
+ * supplied version information.
+ * Returns:
+ * -1  if less than the version information supplied
+ *  0   if equal to all of the version information supplied
+ * +1   if greater than the version information supplied
+ */
+
+ISC_LANG_ENDDECLS
+
+#endif /* ISC_OS_H */
diff --git a/ports/winnt/include/netdb.h b/ports/winnt/include/netdb.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/netinet/in.h b/ports/winnt/include/netinet/in.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/netinet/in_system.h b/ports/winnt/include/netinet/in_system.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/netinet/ip.h b/ports/winnt/include/netinet/ip.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/ntp_iocompletionport.h b/ports/winnt/include/ntp_iocompletionport.h
new file mode 100644 (file)
index 0000000..6e7b92b
--- /dev/null
@@ -0,0 +1,28 @@
+#if !defined __ntp_iocompletionport_h
+# define __ntp_iocompletionport_h
+
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "clockstuff.h"
+
+# if defined(HAVE_IO_COMPLETION_PORT)
+
+extern void    init_io_completion_port (void);
+extern void    uninit_io_completion_port (void);
+
+extern int     io_completion_port_add_socket (SOCKET fd, struct interface *);
+
+struct refclockio; /* in ntp_refclock.h but inclusion here triggers problems */
+extern int     io_completion_port_add_clock_io (struct refclockio *rio);
+
+extern int     io_completion_port_sendto (struct interface *, struct pkt *, int, struct sockaddr_storage*);
+
+extern HANDLE  get_io_event (void);
+
+extern HANDLE  get_exit_event (void);          /* Handle of the exit event */
+
+extern int     GetReceivedBuffers (void);
+
+# endif
+
+#endif
diff --git a/ports/winnt/include/ntp_timer.h b/ports/winnt/include/ntp_timer.h
new file mode 100644 (file)
index 0000000..b8c4030
--- /dev/null
@@ -0,0 +1,12 @@
+#if !defined(__NTP_TIMER_H_)
+#define __NTP_TIMER_H_
+
+extern void            timer_clr_stats                 P((void));
+
+#if defined(SYS_WINNT)
+extern HANDLE  get_timer_handle        P((void));
+#endif
+
+
+
+#endif
\ No newline at end of file
diff --git a/ports/winnt/include/ntservice.h b/ports/winnt/include/ntservice.h
new file mode 100644 (file)
index 0000000..550300c
--- /dev/null
@@ -0,0 +1,35 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: ntservice.h,v 1.2 2002/08/03 01:31:48 mayer Exp $ */
+
+#ifndef NTSERVICE_H
+#define NTSERVICE_H
+
+#include <winsvc.h>
+
+#define NTP_DISPLAY_NAME "NetworkTimeProtocol"
+#define NTP_SERVICE_NAME "ntpd"
+
+void ntservice_init();
+void UpdateSCM(DWORD);
+void ServiceControl(DWORD dwCtrlCode);
+void ntservice_shutdown();
+BOOL ntservice_isservice();
+BOOL WINAPI OnConsoleEvent(DWORD dwCtrlType);
+
+#endif
\ No newline at end of file
diff --git a/ports/winnt/include/sys/ioctl.h b/ports/winnt/include/sys/ioctl.h
new file mode 100644 (file)
index 0000000..6f4b076
--- /dev/null
@@ -0,0 +1,11 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
+
+#ifndef _IOCTL_H
+#define _IOCTL_H
+
+#include "win32_io.h"
+
+#endif
\ No newline at end of file
diff --git a/ports/winnt/include/sys/param.h b/ports/winnt/include/sys/param.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/sys/resource.h b/ports/winnt/include/sys/resource.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/sys/signal.h b/ports/winnt/include/sys/signal.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/sys/socket.h b/ports/winnt/include/sys/socket.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/sys/time.h b/ports/winnt/include/sys/time.h
new file mode 100644 (file)
index 0000000..e27cce6
--- /dev/null
@@ -0,0 +1,18 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
+
+#ifndef SYS_TIME_H
+#define SYS_TIME_H
+
+#include <config.h>
+#include <windows.h>
+#include "ntp_types.h"
+#include <time.h>
+#include <sys/timeb.h>
+
+extern int gettimeofday (struct timeval *);
+extern int settimeofday (struct timeval *);
+
+#endif /* SYS_TIME_H */
diff --git a/ports/winnt/include/sys/wait.h b/ports/winnt/include/sys/wait.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/syslog.h b/ports/winnt/include/syslog.h
new file mode 100644 (file)
index 0000000..5cbf30a
--- /dev/null
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* From BIND 9 lib/isc/include/isc/: syslog.h,v 1.4 2002/08/01 03:43:31 mayer */
+
+#ifndef _SYSLOG_H
+#define _SYSLOG_H
+
+#include <stdio.h>
+
+/* Constant definitions for openlog() */
+#define LOG_PID                1
+#define LOG_CONS       2
+/* NT event log does not support facility level */
+#define LOG_KERN       0
+#define LOG_USER       0
+#define LOG_MAIL       0
+#define LOG_DAEMON     0
+#define LOG_AUTH       0
+#define LOG_SYSLOG     0
+#define LOG_LPR                0
+#define LOG_LOCAL0     0
+#define LOG_LOCAL1     0
+#define LOG_LOCAL2     0
+#define LOG_LOCAL3     0
+#define LOG_LOCAL4     0
+#define LOG_LOCAL5     0
+#define LOG_LOCAL6     0
+#define LOG_LOCAL7     0
+
+#define LOG_EMERG       0       /* system is unusable */
+#define LOG_ALERT       1       /* action must be taken immediately */
+#define LOG_CRIT        2       /* critical conditions */
+#define LOG_ERR         3       /* error conditions */
+#define LOG_WARNING     4       /* warning conditions */
+#define LOG_NOTICE      5       /* normal but signification condition */
+#define LOG_INFO        6       /* informational */
+#define LOG_DEBUG       7       /* debug-level messages */
+
+/*
+ * These are ignored on NT
+ */
+#define LOG_NDELAY     0       /* Open the connection to syslogd immediately */
+
+#define LOG_UPTO(pri)   ((1 << ((pri)+1)) - 1)  /* all priorities through pri */
+
+void
+syslog(int level, const char *fmt, ...);
+
+void
+openlog(const char *, int, ...);
+
+void
+closelog(void);
+
+void
+ModifyLogLevel(int level);
+
+int
+setlogmask(int maskpri);
+
+void
+InitNTLogging(FILE *, int);
+
+void
+NTReportError(const char *, const char *);
+
+#endif
diff --git a/ports/winnt/include/termios.h b/ports/winnt/include/termios.h
new file mode 100644 (file)
index 0000000..94502c9
--- /dev/null
@@ -0,0 +1,7 @@
+#ifndef _TERMIOS_H
+#define _TERMIOS_H
+
+#include "win32_io.h"
+/* Dummy for Winnt */
+
+#endif
diff --git a/ports/winnt/include/transmitbuff.h b/ports/winnt/include/transmitbuff.h
new file mode 100644 (file)
index 0000000..2a4e906
--- /dev/null
@@ -0,0 +1,50 @@
+#if !defined __transmitbuff_h
+#define __transmitbuff_h
+
+#include "ntp.h"
+#if defined HAVE_IO_COMPLETION_PORT
+# include "ntp_iocompletionport.h"
+#endif
+#include <isc/list.h>
+
+/*
+ * Format of a transmitbuf.  These are used by the asynchronous receive
+ * routine to store outgoing packets and related information.
+ */
+
+typedef struct transmitbuf transmitbuf_t;
+
+typedef struct transmitbuf {
+       ISC_LINK(transmitbuf_t) link;
+
+       WSABUF  wsabuf;
+       time_t  ts;             /* Time stamp for the request */
+
+       /*
+        * union {
+        *      struct  pkt             pkt;
+        *      struct  ntp_control     ctlpkt;
+        *} pkt;
+        */
+       char pkt[512];
+
+} transmitbuf;
+
+
+extern void    init_transmitbuff       P((void));
+
+
+/* freetransmitbuf - make a single transmitbuf available for reuse
+ */
+extern void    free_transmit_buffer    P((transmitbuf_t *));
+
+/*  Get a free buffer (typically used so an async
+ *  read can directly place data into the buffer
+ *
+ *  The buffer is removed from the free list. Make sure
+ *  you put it back with freetransmitbuf() or 
+ */
+extern transmitbuf_t *get_free_transmit_buffer P((void));
+
+#endif /* defined __transmitbuff_h */
+
diff --git a/ports/winnt/include/unistd.h b/ports/winnt/include/unistd.h
new file mode 100644 (file)
index 0000000..5e15997
--- /dev/null
@@ -0,0 +1,4 @@
+/**************************************************************
+ * Dummy Header for Unix to Windows NT portability
+ * Created for NTP package
+ **************************************************************/
diff --git a/ports/winnt/include/win32_io.h b/ports/winnt/include/win32_io.h
new file mode 100644 (file)
index 0000000..dcbeba7
--- /dev/null
@@ -0,0 +1,204 @@
+#if !defined(_WIN32_IO_)
+#define _WIN32_IO_
+
+/*  Flag definitions for compatibility
+ *  ==================================
+*/
+
+#include <fcntl.h>
+
+#define NCCS 4
+#define VEOL 3
+typedef unsigned char  cc_t;
+typedef unsigned int   speed_t;
+typedef unsigned int   tcflag_t;
+
+struct termios
+  {
+    tcflag_t c_iflag;          /* input mode flags */
+    tcflag_t c_oflag;          /* output mode flags */
+    tcflag_t c_cflag;          /* control mode flags */
+    tcflag_t c_lflag;          /* local mode flags */
+    cc_t c_line;                       /* line discipline */
+    cc_t c_cc[NCCS];           /* control characters */ 
+    speed_t c_ispeed;          /* input speed */
+    speed_t c_ospeed;          /* output speed */
+  };
+
+/* c_cc characters 
+#define VINTR 0
+#define VQUIT 1
+#define VERASE 2
+#define VKILL 3
+#define VEOF 4
+#define VTIME 5
+#define VMIN 6
+#define VSWTC 7
+#define VSTART 8
+#define VSTOP 9
+#define VSUSP 10
+#define VEOL 11
+#define VREPRINT 12
+#define VDISCARD 13
+#define VWERASE 14
+#define VLNEXT 15
+#define VEOL2 16
+*/
+
+/* c_iflag bits */
+#define IGNBRK 0000001
+#define BRKINT 0000002
+#define IGNPAR 0000004
+#define PARMRK 0000010
+#define INPCK  0000020
+#define ISTRIP 0000040
+#define INLCR  0000100
+#define IGNCR  0000200
+#define ICRNL  0000400
+#define IUCLC  0001000
+#define IXON   0002000
+#define IXANY  0004000
+#define IXOFF  0010000
+#define IMAXBEL        0020000
+
+/* c_oflag bits */
+#define OPOST  0000001
+#define OLCUC  0000002
+#define ONLCR  0000004
+#define OCRNL  0000010
+#define ONOCR  0000020
+#define ONLRET 0000040
+#define OFILL  0000100
+#define OFDEL  0000200
+#define NLDLY  0000400
+#define   NL0  0000000
+#define   NL1  0000400
+#define CRDLY  0003000
+#define   CR0  0000000
+#define   CR1  0001000
+#define   CR2  0002000
+#define   CR3  0003000
+#define TABDLY 0014000
+#define   TAB0 0000000
+#define   TAB1 0004000
+#define   TAB2 0010000
+#define   TAB3 0014000
+#define   XTABS        0014000
+#define BSDLY  0020000
+#define   BS0  0000000
+#define   BS1  0020000
+#define VTDLY  0040000
+#define   VT0  0000000
+#define   VT1  0040000
+#define FFDLY  0100000
+#define   FF0  0000000
+#define   FF1  0100000
+
+/* c_cflag bit meaning */
+#define CBAUD  0010017
+#define  B0    0000000         /* hang up */
+#define  B50   0000001
+#define  B75   0000002
+#define  B110  0000003
+#define  B134  0000004
+#define  B150  0000005
+#define  B200  0000006
+#define  B300  0000007
+#define  B600  0000010
+#define  B1200 0000011
+#define  B1800 0000012
+#define  B2400 0000013
+#define  B4800 0000014
+#define  B9600 0000015
+#define  B19200        0000016
+#define  B38400        0000017
+#define EXTA B19200
+#define EXTB B38400
+#define CSIZE  0000060
+#define   CS5  0000000
+#define   CS6  0000020
+#define   CS7  0000040
+#define   CS8  0000060
+#define CSTOPB 0000100
+#define CREAD  0000200
+#define PARENB 0000400
+#define PARODD 0001000
+#define HUPCL  0002000
+#define CLOCAL 0004000
+#define CBAUDEX 0010000
+#define  B57600  0010001
+#define  B115200 0010002
+#define  B230400 0010003
+#define  B460800 0010004
+#define CIBAUD   002003600000  /* input baud rate (not used) */
+#define CRTSCTS          020000000000          /* flow control */
+
+/* c_lflag bits */
+#define ISIG   0000001
+#define ICANON 0000002
+#define XCASE  0000004
+#define ECHO   0000010
+#define ECHOE  0000020
+#define ECHOK  0000040
+#define ECHONL 0000100
+#define NOFLSH 0000200
+#define TOSTOP 0000400
+#define ECHOCTL        0001000
+#define ECHOPRT        0002000
+#define ECHOKE 0004000
+#define FLUSHO 0010000
+#define PENDIN 0040000
+#define IEXTEN 0100000
+
+/* tcflow() and TCXONC use these */
+#define        TCOOFF          0
+#define        TCOON           1
+#define        TCIOFF          2
+#define        TCION           3
+
+/* tcflush() and TCFLSH use these */
+#define        TCIFLUSH        0
+#define        TCOFLUSH        1
+#define        TCIOFLUSH       2
+
+/* tcsetattr uses these */
+#define        TCSANOW         0
+#define        TCSADRAIN       1
+#define        TCSAFLUSH       2
+
+/* modem lines */
+#define TIOCM_LE        0x001
+#define TIOCM_DTR       0x002
+#define TIOCM_RTS       0x004
+#define TIOCM_ST        0x008
+#define TIOCM_SR        0x010
+#define TIOCM_CTS       0x020
+#define TIOCM_CAR       0x040
+#define TIOCM_RNG       0x080
+#define TIOCM_DSR       0x100
+#define TIOCM_CD        TIOCM_CAR
+#define TIOCM_RI        TIOCM_RNG
+#define TIOCM_OUT1      0x2000
+#define TIOCM_OUT2      0x4000
+
+/* ioctl */
+#define TIOCMGET        0x5415
+#define TIOCMSET        0x5418       
+/*
+#define cfgetospeed(dcb) dcb->BaudRate
+#define cfgetispeed(dcb) dcb->BaudRate
+#define cfsetospeed(dcb,speed) (dcb->BaudRate = (speed), 0)
+#define cfsetispeed(dcb,speed) (dcb->BaudRate = (speed), 0)
+
+
+
+extern BOOL    TTY_GETATTR P((int fd, DCB *tio));
+extern BOOL    TTY_SETATTR P((int fd, const DCB *tio));
+
+*/
+
+extern int ioctl               (int, int, int *);
+extern int     tcsetattr       (int fd, int optional_actions, const struct termios *);
+extern int     tcgetattr       (int fd, struct termios *);
+#endif /* defined _WIN32_IO_ */
+
diff --git a/ports/winnt/instsrv/Instsrv.dsp b/ports/winnt/instsrv/Instsrv.dsp
new file mode 100644 (file)
index 0000000..050ca22
--- /dev/null
@@ -0,0 +1,103 @@
+# Microsoft Developer Studio Project File - Name="instsrv" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
+\r
+CFG=instsrv - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "Instsrv.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "Instsrv.mak" CFG="instsrv - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "instsrv - Win32 Release" (based on "Win32 (x86) Console Application")\r
+!MESSAGE "instsrv - Win32 Debug" (based on "Win32 (x86) Console Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""$/ntp/dev/ports/winnt/instsrv", VVBAAAAA"\r
+# PROP Scc_LocalPath "."\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "instsrv - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD CPP /nologo /MT /W4 /GX /O2 /I "..\..\..\include" /I "..\include" /I "." /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /YX"windows.h" /FD /c\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+# ADD LINK32 kernel32.lib user32.lib advapi32.lib /nologo /subsystem:console /machine:I386 /out:"../bin/Release/Instsrv.exe"\r
+\r
+!ELSEIF  "$(CFG)" == "instsrv - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
+# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "..\..\..\include" /I "..\include" /I "." /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /FD /GZ /c\r
+# SUBTRACT CPP /YX\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 kernel32.lib user32.lib advapi32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin/Debug/Instsrv.exe" /pdbtype:sept\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "instsrv - Win32 Release"\r
+# Name "instsrv - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=.\instsrv.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# End Group\r
+# End Target\r
+# End Project\r
diff --git a/ports/winnt/instsrv/Instsrv.vcproj b/ports/winnt/instsrv/Instsrv.vcproj
new file mode 100644 (file)
index 0000000..79ba797
--- /dev/null
@@ -0,0 +1,253 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="instsrv"
+       ProjectGUID="{C3534C4D-6DF1-498E-9904-4337878A1515}"
+       TargetFrameworkVersion="0"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory=".\Debug"
+                       IntermediateDirectory=".\Debug"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Debug/Instsrv.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               WholeProgramOptimization="true"
+                               AdditionalIncludeDirectories="..\..\..\include,..\include,."
+                               PreprocessorDefinitions="_DEBUG;_CONSOLE;WIN32;SYS_WINNT;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"
+                               MinimalRebuild="false"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               PrecompiledHeaderFile=".\Debug/Instsrv.pch"
+                               AssemblerListingLocation=".\Debug/"
+                               ObjectFile=".\Debug/"
+                               ProgramDataBaseFileName="..\bin\Debug\instsrv-vc90"
+                               BrowseInformation="1"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="oldnames.lib"
+                               OutputFile="../bin/Debug/Instsrv.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Debug\Instsrv.pdb"
+                               SubSystem="1"
+                               LinkTimeCodeGeneration="1"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Debug/Instsrv.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory=".\Release"
+                       IntermediateDirectory=".\Release"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Release/Instsrv.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               InlineFunctionExpansion="1"
+                               AdditionalIncludeDirectories="..\..\..\include,..\include,."
+                               PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32;_WINDOWS;SYS_WINNT;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"
+                               StringPooling="true"
+                               RuntimeLibrary="0"
+                               EnableFunctionLevelLinking="true"
+                               PrecompiledHeaderFile=".\Release/Instsrv.pch"
+                               AssemblerListingLocation=".\Release/"
+                               ObjectFile=".\Release/"
+                               ProgramDataBaseFileName="..\bin\Release\instsrv-vc90"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="oldnames.lib"
+                               OutputFile="../bin/Release/Instsrv.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Release\Instsrv.pdb"
+                               SubSystem="1"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Release/Instsrv.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+                       >
+                       <File
+                               RelativePath="instsrv.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl"
+                       >
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+                       >
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/ports/winnt/instsrv/instsrv.c b/ports/winnt/instsrv/instsrv.c
new file mode 100644 (file)
index 0000000..b3acc9f
--- /dev/null
@@ -0,0 +1,461 @@
+/*
+ *  File: instsrv.c
+ *  Purpose: To install a new service and to insert registry entries.
+ *
+ */
+#ifndef __RPCASYNC_H__
+#define __RPCASYNC_H__ /* Skip asynch rpc inclusion */
+#endif
+
+#include <windows.h>
+#include <stdio.h>
+
+#define PERR(api) printf("\n%s: Error %d from %s on line %d",  \
+    __FILE__, GetLastError(), api, __LINE__);
+
+#define MSG_FOR_ACCESS_DENIED "You aren't authorized to do this - please see your system Administrator"
+#define MSG_1_FOR_BAD_PATH "The fully qualified path name to the .exe must be given, and"
+#define MSG_2_FOR_BAD_PATH "  the drive letter must be for a fixed disk (e.g., not a net drive)"
+
+SC_HANDLE schService;
+SC_HANDLE schSCManager;
+int ok2;
+
+VOID DisplayHelp(VOID);
+
+/* --------------------------------------------------------------------------------------- */
+
+int InstallService(LPCTSTR serviceName, LPCTSTR displayName, LPCTSTR serviceExe)
+{
+  LPCTSTR lpszBinaryPathName = serviceExe;
+  TCHAR lpszRootPathName[] ="?:\\";
+
+  if ( (':' != *(lpszBinaryPathName+1)) || ('\\' != *(lpszBinaryPathName+2)) )
+  { printf("\n%s",MSG_1_FOR_BAD_PATH);
+    printf("\n%s\n",MSG_2_FOR_BAD_PATH);
+    return 1;
+  }
+
+  #define DRIVE_TYPE_INDETERMINATE 0
+  #define ROOT_DIR_DOESNT_EXIST    1
+
+  *lpszRootPathName = *(lpszBinaryPathName+0) ;
+
+  switch (  GetDriveType(lpszRootPathName)  )
+  {
+    case DRIVE_FIXED :
+    { // OK
+      break;
+    }
+    case  ROOT_DIR_DOESNT_EXIST :
+    { printf("\n%s",MSG_1_FOR_BAD_PATH);
+      printf("\n  the root directory where the .exe is specified to be must exist, and");
+      printf("\n%s\n",MSG_2_FOR_BAD_PATH);
+      return 1;
+    }
+    case  DRIVE_TYPE_INDETERMINATE :
+    case  DRIVE_REMOVABLE          :
+    case  DRIVE_REMOTE             :
+    case  DRIVE_CDROM              :
+    case  DRIVE_RAMDISK            :
+    { printf("\n%s",MSG_1_FOR_BAD_PATH);
+      printf("\n%s\n",MSG_2_FOR_BAD_PATH);
+      return 1;
+    }
+    default :
+    { printf("\n%s",MSG_1_FOR_BAD_PATH);
+      printf("\n%s\n",MSG_2_FOR_BAD_PATH);
+      return 1;
+    }
+  }
+
+  if (INVALID_HANDLE_VALUE == CreateFile(lpszBinaryPathName,
+                                         GENERIC_READ,
+                                         FILE_SHARE_READ,
+                                         NULL,
+                                         OPEN_EXISTING,
+                                         FILE_ATTRIBUTE_NORMAL,
+                                         NULL))
+  { 
+    printf("\n%s",MSG_1_FOR_BAD_PATH);
+    printf("\n  the file must exist, and");
+    printf("\n%s\n",MSG_2_FOR_BAD_PATH);
+    return 1;
+  }
+
+  schService = CreateService(
+        schSCManager,               // SCManager database
+        serviceName,                // name of service
+        displayName,                // name to display
+        SERVICE_ALL_ACCESS,         // desired access
+        SERVICE_WIN32_OWN_PROCESS,  // service type
+        SERVICE_AUTO_START,         // start type
+        SERVICE_ERROR_NORMAL,       // error control type
+        lpszBinaryPathName,         // service's binary
+        NULL,                       // no load ordering group
+        NULL,                       // no tag identifier
+        NULL,                       // no dependencies
+        NULL,                       // Local System account
+        NULL);                      // null password
+
+  if (NULL == schService)
+  { switch (GetLastError())
+    {
+      case ERROR_ACCESS_DENIED :
+      { printf("\n%s",MSG_FOR_ACCESS_DENIED);
+        break;
+      }
+      case ERROR_SERVICE_EXISTS :
+      { printf("\nThe %s service is already installed",serviceName);
+        printf("\nRemove it first if you need to re-install a new version\n");
+        break;
+      }
+      default :
+      { PERR("CreateService");
+      }
+    }
+    return 1;
+  }
+  else
+
+  CloseServiceHandle(schService);
+  return 0;
+}
+
+/* --------------------------------------------------------------------------------------- */
+
+int RemoveService(LPCTSTR serviceName)
+{
+  {
+    #define                                     SZ_ENUM_BUF 4096
+    ENUM_SERVICE_STATUS        essServiceStatus[SZ_ENUM_BUF];
+    DWORD   dwBufSize = sizeof(essServiceStatus);
+    DWORD   dwBytesNeeded      = 0;
+    DWORD   dwServicesReturned = 0;
+    DWORD   dwResumeHandle     = 0;
+    DWORD   dwI                = 0;
+    BOOLEAN bFound = FALSE;
+
+    if (!EnumServicesStatus(schSCManager,
+                            SERVICE_WIN32,
+                            SERVICE_ACTIVE,
+                            (LPENUM_SERVICE_STATUS)&essServiceStatus,
+                            dwBufSize,
+                            &dwBytesNeeded,
+                            &dwServicesReturned,
+                            &dwResumeHandle))
+    { switch (GetLastError())
+      {
+        case ERROR_ACCESS_DENIED :
+        { printf("\n%s",MSG_FOR_ACCESS_DENIED);
+          break;
+        }
+        default :
+        { PERR("EnumServicesStatus");
+        }
+      }
+      return 1;
+    }
+
+    for (dwI=0; dwI<dwServicesReturned; dwI++)
+    { if(0 == _stricmp(essServiceStatus[dwI].lpServiceName,serviceName))
+      { bFound = TRUE;
+        break;
+      }
+    }
+
+    if (bFound)
+    { printf("\nThe %s service cannot be removed until it has been stopped.",serviceName);
+      printf("\nTo stop the %s service, use the Stop button in the Control",serviceName);
+      printf("\n  Panel Services applet\n");
+      return 1;
+    }
+  }
+
+  schService = OpenService(schSCManager,
+                           serviceName,
+                           SERVICE_ALL_ACCESS);
+  if (NULL == schService)
+  { switch (GetLastError())
+    {
+      case ERROR_ACCESS_DENIED :
+      { printf("\n%s",MSG_FOR_ACCESS_DENIED);
+        break;
+      }
+      case ERROR_SERVICE_DOES_NOT_EXIST :
+      { printf("\nThe %s service is not installed, so cannot be removed\n",serviceName);
+        break;
+      }
+      default :
+      { PERR("OpenService");
+      }
+    }
+    return 1;
+  }
+
+  if (DeleteService(schService))
+  { printf("\nDelete of Service \"Network Time Protocol\" was SUCCESSFUL\n");
+   return 0;
+  }
+  else
+  { switch (GetLastError())
+    {
+      case ERROR_ACCESS_DENIED :
+      { printf("\n%s",MSG_FOR_ACCESS_DENIED);
+        break;
+      }
+      default :
+      { PERR("DeleteService");
+      }
+    }
+   return 1;
+  }
+}
+
+/* --------------------------------------------------------------------------------------- */
+
+int addSourceToRegistry(LPSTR pszAppname, LPSTR pszMsgDLL)
+{
+  HKEY hk;                      /* registry key handle */
+  DWORD dwData;
+  BOOL bSuccess;
+  char   regarray[200];
+  char *lpregarray = regarray;
+
+  /* When an application uses the RegisterEventSource or OpenEventLog
+     function to get a handle of an event log, the event loggging service
+     searches for the specified source name in the registry. You can add a
+     new source name to the registry by opening a new registry subkey
+     under the Application key and adding registry values to the new
+     subkey. */
+
+  strcpy(lpregarray, "SYSTEM\\CurrentControlSet\\Services\\EventLog\\Application\\");
+  strcat(lpregarray, pszAppname);
+  /* Create a new key for our application */
+  bSuccess = RegCreateKey(HKEY_LOCAL_MACHINE, lpregarray, &hk);
+   if(bSuccess != ERROR_SUCCESS)
+    {
+      PERR("RegCreateKey");
+      return 1;
+    }
+    
+  /* Add the Event-ID message-file name to the subkey. */
+  bSuccess = RegSetValueEx(hk,  /* subkey handle         */
+      "EventMessageFile",       /* value name            */
+      0,                        /* must be zero          */
+      REG_EXPAND_SZ,            /* value type            */
+      (LPBYTE) pszMsgDLL,       /* address of value data */
+      strlen(pszMsgDLL) + 1);   /* length of value data  */
+ if(bSuccess != ERROR_SUCCESS)
+    {
+      PERR("RegSetValueEx");
+      return 1;
+    }
+  
+  /* Set the supported types flags and addit to the subkey. */
+  dwData = EVENTLOG_ERROR_TYPE | EVENTLOG_WARNING_TYPE |
+      EVENTLOG_INFORMATION_TYPE;
+  bSuccess = RegSetValueEx(hk,  /* subkey handle                */
+      "TypesSupported",         /* value name                   */
+      0,                        /* must be zero                 */
+      REG_DWORD,                /* value type                   */
+      (LPBYTE) &dwData,         /* address of value data        */
+      sizeof(DWORD));           /* length of value data         */
+  if(bSuccess != ERROR_SUCCESS)
+    {
+      PERR("RegSetValueEx");
+      return 1;
+    }
+  RegCloseKey(hk);
+  return 0;
+}
+
+/* --------------------------------------------------------------------------------------- */
+
+int addKeysToRegistry()
+
+{
+  HKEY hk;                      /* registry key handle */
+  BOOL bSuccess;
+  char   myarray[200];
+  char *lpmyarray = myarray;
+  int arsize = 0;
+
+  /* now add the depends on service key */
+  /* Create a new key for our application */
+  bSuccess = RegCreateKey(HKEY_LOCAL_MACHINE,
+      "SYSTEM\\CurrentControlSet\\Services\\NTP", &hk);
+  if(bSuccess != ERROR_SUCCESS)
+    {
+      PERR("RegCreateKey");
+      return 1;
+    }
+
+  strcpy(lpmyarray,"TcpIp");
+  lpmyarray = lpmyarray + 6;
+  arsize = arsize + 6;
+  strcpy(lpmyarray,"Afd");
+  lpmyarray = lpmyarray + 4;
+  arsize = arsize + 4;
+  arsize = arsize + 2;
+  strcpy(lpmyarray,"\0\0");
+  
+  bSuccess = RegSetValueEx(hk,  /* subkey handle         */
+      "DependOnService",        /* value name            */
+      0,                        /* must be zero          */
+      REG_MULTI_SZ,             /* value type            */
+      (LPBYTE) &myarray,        /* address of value data */
+      arsize);                  /* length of value data  */
+   if(bSuccess != ERROR_SUCCESS)
+    {
+      PERR("RegSetValueEx");
+      return 1;
+    }
+
+  RegCloseKey(hk);
+  return 0;
+}
+
+/* --------------------------------------------------------------------------------------- */
+
+int main(int argc, char *argv[])
+{
+  #define           SZ_NAME_BUF  270  // 256 is max, add a little
+  UCHAR   ucNameBuf[SZ_NAME_BUF] = "NTP";
+  LPTSTR  lpszServName = (LPTSTR)&ucNameBuf;
+
+  UCHAR   ucDNameBuf[SZ_NAME_BUF] = "Network Time Protocol";
+  LPTSTR  lpszDispName = (LPTSTR)&ucDNameBuf;
+
+
+  UCHAR   ucExeNBuf[SZ_NAME_BUF] = "";
+  LPTSTR  lpszExeName  = (LPTSTR)&ucExeNBuf;
+
+  BOOL    bRemovingService = FALSE;
+  char *p;
+
+  int ok = 0;  
+  
+  // check if Win32s, if so, display notice and terminate
+      if( GetVersion() & 0x80000000 )
+      {
+        MessageBox( NULL,
+           "This application cannot run on Windows 3.1.\n"
+           "This application will now terminate.",
+           "NAMED",
+           MB_OK | MB_ICONSTOP | MB_SETFOREGROUND );
+        return( 1 );
+      }
+  if (argc == 2)
+     bRemovingService = (!stricmp(argv[1], "remove"));
+
+  if(!bRemovingService)
+   {
+
+  
+  if (argc != 2)
+  {
+    DisplayHelp();
+    return(1);
+  }
+
+  p=argv[1];
+  if (    ('/' == *p)
+       || ('-' == *p) )
+  {
+    DisplayHelp();
+    return(1);
+  }
+        
+  
+   }
+
+  if (strlen(argv[1]) > 256)
+    {
+      printf("\nThe service name cannot be longer than 256 characters\n");
+      return(1);
+    }
+
+
+
+  bRemovingService = (!stricmp(argv[1], "remove"));
+  schSCManager = OpenSCManager(
+                      NULL,                   // machine (NULL == local)
+                      NULL,                   // database (NULL == default)
+                      SC_MANAGER_ALL_ACCESS); // access required
+
+  if (NULL == schSCManager)
+  { switch (GetLastError())
+    {
+      case ERROR_ACCESS_DENIED :
+      { printf("\n%s",MSG_FOR_ACCESS_DENIED);
+        break;
+      }
+      default :
+      { PERR("OpenSCManager");
+      }
+    }
+    return (0);
+  }
+   
+  if (bRemovingService)
+  {
+   ok = RemoveService(lpszServName);
+  }
+  else
+  {
+   /* get the exe name */
+   strcpy(lpszExeName,argv[1]);
+   ok = InstallService(lpszServName, lpszDispName, lpszExeName);
+  }
+
+  CloseServiceHandle(schSCManager);
+
+  if (!bRemovingService)
+    {
+  if (ok == 0)
+   { /* Set the Event-ID message-file name. */
+    ok = addSourceToRegistry("NTP", lpszExeName);
+    if (ok == 0)
+      ok = addKeysToRegistry();
+    else return ok;
+
+    if (ok == 0)
+    {
+      printf("\nThe \"Network Time Protocol\" service was successfully created.\n");
+      printf("\nDon't forget!!! You must now go to the Control Panel and");
+      printf("\n  use the Services applet to change the account name and");
+      printf("\n  password that the NTP Service will use when");
+      printf("\n  it starts.");
+      printf("\nTo do this: use the Startup button in the Services applet,");
+      printf("\n  and (for example) specify the desired account and");
+      printf("\n  correct password.");
+      printf("\nAlso, use the Services applet to ensure this newly installed");
+      printf("\n  service starts automatically on bootup.\n");
+     return 0;
+    }
+   }
+  else return ok;
+  }
+ return 0;
+}
+
+/* --------------------------------------------------------------------------------------- */
+
+VOID DisplayHelp(VOID)
+{
+    printf("Installs or removes the NTP service.\n");
+    printf("To install the NTP service,\n");
+    printf("type INSTSRV <path> \n");
+    printf("Where:\n");
+    printf("    path    Absolute path to the NTP service, name.exe.  You must\n");
+    printf("            use a fully qualified path and the drive letter must be for a\n");
+    printf("            fixed, local drive.\n\n");
+    printf("For example, INSTSRV i:\\winnt\\system32\\ntpd.exe\n");
+    printf("To remove the NTP service,\n");
+    printf("type INSTSRV remove \n");
+
+}
+
+/* EOF */
diff --git a/ports/winnt/libisc/interfaceiter.c b/ports/winnt/libisc/interfaceiter.c
new file mode 100644 (file)
index 0000000..212122f
--- /dev/null
@@ -0,0 +1,421 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: interfaceiter.c,v 1.7 2001/11/27 01:56:21 gson Exp $ */
+
+/*
+ * Note that this code will need to be revisited to support IPv6 Interfaces.
+ * For now we just iterate through IPv4 interfaces.
+ */
+
+#include <config.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <isc/interfaceiter.h>
+#include <isc/mem.h>
+#include <isc/result.h>
+#include <isc/string.h>
+#include <isc/strerror.h>
+#include <isc/types.h>
+#include <isc/util.h>
+
+/* Common utility functions */
+
+/*
+ * Extract the network address part from a "struct sockaddr".
+ *
+ * The address family is given explicity
+ * instead of using src->sa_family, because the latter does not work
+ * for copying a network mask obtained by SIOCGIFNETMASK (it does
+ * not have a valid address family).
+ */
+
+
+#define IFITER_MAGIC           0x49464954U     /* IFIT. */
+#define VALID_IFITER(t)                ((t) != NULL && (t)->magic == IFITER_MAGIC)
+
+struct isc_interfaceiter {
+       unsigned int            magic;          /* Magic number. */
+       isc_mem_t               *mctx;
+       int                     socket;
+       INTERFACE_INFO          IFData;         /* Current Interface Info */
+       int                     numIF;          /* Current Interface count */
+       int                     totalIF;        /* Total Number
+                                                  of Interfaces */
+       INTERFACE_INFO          *buf;           /* Buffer for WSAIoctl data. */
+       unsigned int            bufsize;        /* Bytes allocated. */
+       INTERFACE_INFO          *pos;           /* Current offset in IF List */
+       isc_interface_t         current;        /* Current interface data. */
+       isc_result_t            result;         /* Last result code. */
+};
+
+
+/*
+ * Size of buffer for SIO_GET_INTERFACE_LIST, in number of interfaces.
+ * We assume no sane system will have more than than 1K of IP addresses on
+ * all of its adapters.
+ */
+#define IFCONF_SIZE_INITIAL      16
+#define IFCONF_SIZE_INCREMENT    64
+#define IFCONF_SIZE_MAX                1040
+
+static void
+get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) {
+       dst->family = family;
+       switch (family) {
+       case AF_INET:
+               memcpy(&dst->type.in,
+                      &((struct sockaddr_in *) src)->sin_addr,
+                      sizeof(struct in_addr));
+               break;
+       case    AF_INET6:
+               memcpy(&dst->type.in6,
+                      &((struct sockaddr_in6 *) src)->sin6_addr,
+                      sizeof(struct in6_addr));
+               break;
+       default:
+               INSIST(0);
+               break;
+       }
+}
+
+/*
+ * The WSAIoctl code is not fetching the broadcast address for each interface address
+ * so we need to reconstruct it from the address and its network mask
+ */
+static void
+get_broadcastaddr(isc_netaddr_t *bcastaddr, isc_netaddr_t *addr, isc_netaddr_t *netmask) {
+
+       unsigned char *p, *a, *n;
+       int i;
+
+       p = (unsigned char *) &bcastaddr->type.in;
+       a = (unsigned char *) &addr->type.in;
+       n = (unsigned char *) &netmask->type.in;
+
+       for (i=0; i < 4; i++) {
+               p[i] = (unsigned char) (a[i] | ~n[i]);
+       }
+
+}
+
+isc_result_t
+isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
+       char strbuf[ISC_STRERRORSIZE]; 
+       isc_interfaceiter_t *iter;
+       isc_result_t result;
+       int error;
+       unsigned long bytesReturned = 0;
+
+       REQUIRE(iterp != NULL);
+       REQUIRE(*iterp == NULL);
+
+       iter = isc_mem_get(mctx, sizeof(*iter));
+       if (iter == NULL)
+               return (ISC_R_NOMEMORY);
+
+       iter->mctx = mctx;
+       iter->buf = NULL;
+
+       /*
+        * Create an unbound datagram socket to do the
+        * SIO_GET_INTERFACE_LIST WSAIoctl on.
+        */
+       if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+               error = WSAGetLastError();
+               isc__strerror(error, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                               "making interface scan socket: %s",
+                               strbuf);
+               result = ISC_R_UNEXPECTED;
+               goto socket_failure;
+       }
+
+       /*
+        * Get the interface configuration, allocating more memory if
+        * necessary.
+        */
+       iter->bufsize = IFCONF_SIZE_INITIAL*sizeof(INTERFACE_INFO);
+
+       for (;;) {
+               iter->buf = isc_mem_get(mctx, iter->bufsize);
+               if (iter->buf == NULL) {
+                       result = ISC_R_NOMEMORY;
+                       goto alloc_failure;
+               }
+
+               if (WSAIoctl(iter->socket, SIO_GET_INTERFACE_LIST,
+                            0, 0, iter->buf, iter->bufsize,
+                            &bytesReturned, 0, 0) == SOCKET_ERROR)
+               {
+                       error = WSAGetLastError();
+                       if (error != WSAEFAULT && error != WSAENOBUFS) {
+                               errno = error;
+                               isc__strerror(error, strbuf, sizeof(strbuf));
+                               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                               "get interface configuration: %s",
+                                               strbuf);
+                               result = ISC_R_UNEXPECTED;
+                               goto ioctl_failure;
+                       }
+                       /*
+                        * EINVAL.  Retry with a bigger buffer.
+                        */
+               } else {
+                       /*
+                        * The WSAIoctl succeeded.
+                        * If the number of the returned bytes is the same
+                        * as the buffer size, we will grow it just in
+                        * case and retry.
+                        */
+                       if (bytesReturned > 0 &&
+                           (bytesReturned < iter->bufsize))
+                               break;
+               }
+               if (iter->bufsize >= IFCONF_SIZE_MAX*sizeof(INTERFACE_INFO)) {
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                        "get interface configuration: "
+                                        "maximum buffer size exceeded");
+                       result = ISC_R_UNEXPECTED;
+                       goto ioctl_failure;
+               }
+               isc_mem_put(mctx, iter->buf, iter->bufsize);
+
+               iter->bufsize += IFCONF_SIZE_INCREMENT *
+                       sizeof(INTERFACE_INFO);
+       }
+
+       /*
+        * A newly created iterator has an undefined position
+        * until isc_interfaceiter_first() is called.
+        */
+       iter->pos = NULL;
+       iter->result = ISC_R_FAILURE;
+       iter->numIF = 0;
+       iter->totalIF = bytesReturned/sizeof(INTERFACE_INFO);
+
+
+       iter->magic = IFITER_MAGIC;
+       *iterp = iter;
+       /* We don't need the socket any more, so close it */
+       closesocket(iter->socket);
+       return (ISC_R_SUCCESS);
+
+ ioctl_failure:
+       isc_mem_put(mctx, iter->buf, iter->bufsize);
+
+ alloc_failure:
+       (void) closesocket(iter->socket);
+
+ socket_failure:
+       isc_mem_put(mctx, iter, sizeof(*iter));
+       return (result);
+}
+
+/*
+ * Get information about the current interface to iter->current.
+ * If successful, return ISC_R_SUCCESS.
+ * If the interface has an unsupported address family, or if
+ * some operation on it fails, return ISC_R_IGNORE to make
+ * the higher-level iterator code ignore it.
+ */
+
+static isc_result_t
+internal_current(isc_interfaceiter_t *iter, int family) {
+       BOOL ifNamed = FALSE;
+       unsigned long flags;
+
+       REQUIRE(VALID_IFITER(iter));
+       REQUIRE(iter->numIF >= 0);
+
+       memset(&iter->current, 0, sizeof(iter->current));
+       iter->current.af = family;
+
+       get_addr(family, &iter->current.address,
+                (struct sockaddr *)&(iter->IFData.iiAddress));
+
+       /* XXXPDM This will need to be revisited */
+       iter->current.ifindex = 0;      /* Set to zero for now */
+       iter->current.scopeid = 0;      /* Set to zero for now */
+
+
+       /*
+        * Get interface flags.
+        */
+
+       iter->current.flags = 0;
+       flags = iter->IFData.iiFlags;
+
+       if ((flags & IFF_UP) != 0)
+               iter->current.flags |= INTERFACE_F_UP;
+
+       if ((flags & IFF_POINTTOPOINT) != 0) {
+               iter->current.flags |= INTERFACE_F_POINTTOPOINT;
+               sprintf(iter->current.name, "PPP Interface %d", iter->numIF);
+               ifNamed = TRUE;
+       }
+
+       if ((flags & IFF_LOOPBACK) != 0) {
+               iter->current.flags |= INTERFACE_F_LOOPBACK;
+               sprintf(iter->current.name, "Loopback Interface %d",
+                       iter->numIF);
+               ifNamed = TRUE;
+       }
+
+       if ((flags & IFF_BROADCAST) != 0) {
+               iter->current.flags |= INTERFACE_F_BROADCAST;
+       }
+
+       if ((flags & IFF_MULTICAST) != 0) {
+               iter->current.flags |= INTERFACE_F_MULTICAST;
+       }
+
+       /*
+        * Get the network mask.
+        */
+       switch (family) {
+       case AF_INET:
+               get_addr(family, &iter->current.netmask,
+                        (struct sockaddr *)&(iter->IFData.iiNetmask));
+               break;
+       case AF_INET6:
+               break;
+       }
+
+       /*
+        * If the interface is point-to-point, get the destination address.
+        */
+       if ((iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0) {
+               get_addr(family, &iter->current.dstaddress,
+               (struct sockaddr *)&(iter->IFData.iiBroadcastAddress));
+       }
+       /*
+        * If the interface is broadcast, get the broadcast address.
+        */
+       if ((iter->current.flags & INTERFACE_F_BROADCAST) != 0) {
+               get_addr(family, &iter->current.broadcast, 
+               (struct sockaddr *)&(iter->IFData.iiBroadcastAddress));
+               get_broadcastaddr(&iter->current.broadcast, &iter->current.address,
+                                  &iter->current.netmask);
+       }
+
+       if (ifNamed == FALSE)
+               sprintf(iter->current.name,
+                       "IP Interface %d", iter->numIF);
+
+       return (ISC_R_SUCCESS);
+}
+
+/*
+ * Step the iterator to the next interface.  Unlike
+ * isc_interfaceiter_next(), this may leave the iterator
+ * positioned on an interface that will ultimately
+ * be ignored.  Return ISC_R_NOMORE if there are no more
+ * interfaces, otherwise ISC_R_SUCCESS.
+ */
+static isc_result_t
+internal_next(isc_interfaceiter_t *iter) {
+       if (iter->numIF >= iter->totalIF)
+               return (ISC_R_NOMORE);
+
+       /*
+        * The first one needs to be set up to point to the last
+        * Element of the array.  Go to the end and back up
+        * Microsoft's implementation is peculiar for returning
+        * the list in reverse order
+        */
+        
+       if (iter->numIF == 0)
+               iter->pos = (INTERFACE_INFO *)(iter->buf + (iter->totalIF));
+
+       iter->pos--;
+       if (&(iter->pos) < &(iter->buf))
+               return (ISC_R_NOMORE);
+
+       memset(&(iter->IFData), 0, sizeof(INTERFACE_INFO));
+       memcpy(&(iter->IFData), iter->pos, sizeof(INTERFACE_INFO));
+       iter->numIF++;
+
+       return (ISC_R_SUCCESS);
+}
+
+isc_result_t
+isc_interfaceiter_current(isc_interfaceiter_t *iter,
+                         isc_interface_t *ifdata) {
+       REQUIRE(iter->result == ISC_R_SUCCESS);
+       memcpy(ifdata, &iter->current, sizeof(*ifdata));
+       return (ISC_R_SUCCESS);
+}
+
+isc_result_t
+isc_interfaceiter_first(isc_interfaceiter_t *iter) {
+       isc_result_t result;
+
+       REQUIRE(VALID_IFITER(iter));
+
+       iter->numIF = 0;
+       for (;;) {
+               result = internal_next(iter);
+               if (result != ISC_R_SUCCESS)
+                       break;
+               result = internal_current(iter, AF_INET);
+               if (result != ISC_R_IGNORE)
+                       break;
+       }
+       iter->result = result;
+       return (result);
+}
+
+isc_result_t
+isc_interfaceiter_next(isc_interfaceiter_t *iter) {
+       isc_result_t result;
+
+       REQUIRE(VALID_IFITER(iter));
+       REQUIRE(iter->result == ISC_R_SUCCESS);
+
+       for (;;) {
+               result = internal_next(iter);
+               if (result != ISC_R_SUCCESS)
+                       break;
+               result = internal_current(iter,AF_INET);
+               if (result != ISC_R_IGNORE)
+                       break;
+       }
+       iter->result = result;
+       return (result);
+}
+
+void
+isc_interfaceiter_destroy(isc_interfaceiter_t **iterp) {
+       isc_interfaceiter_t *iter;
+       REQUIRE(iterp != NULL);
+       iter = *iterp;
+       REQUIRE(VALID_IFITER(iter));
+
+       isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
+
+       iter->magic = 0;
+       isc_mem_put(iter->mctx, iter, sizeof(*iter));
+       *iterp = NULL;
+}
+
diff --git a/ports/winnt/libisc/isc_strerror.c b/ports/winnt/libisc/isc_strerror.c
new file mode 100644 (file)
index 0000000..55a7295
--- /dev/null
@@ -0,0 +1,500 @@
+/*
+ * Copyright (C) 2002  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* From BIND 9 lib/isc/win32/: strerror.c,v 1.5 2002/08/01 03:52:14 mayer */
+
+/*
+ * We don't need this warning message
+ */
+#pragma warning(disable: 4127) /* conditional expression is constant */
+
+#include <stdio.h>
+#include <string.h>
+#include <windows.h>
+#include <isc/list.h>
+
+
+/*
+ * Messsage list
+ */
+typedef struct msg_list msg_list_t;
+
+struct msg_list {
+       int code;
+       char *msg;
+       ISC_LINK(msg_list_t) link;
+};
+
+static ISC_LIST(msg_list_t) errormsg_list;
+
+BOOL initialized = FALSE;
+
+static CRITICAL_SECTION ErrorMsgLock;
+# define LOCK(lock)    EnterCriticalSection(lock)
+# define UNLOCK(lock)  LeaveCriticalSection(lock)
+
+/*
+ * Forward declarations
+ */
+
+char *
+FormatError(int error);
+
+char *
+GetWSAErrorMessage(int errval);
+
+static char *
+isc__NTstrerror(int err);
+
+/*
+ * Initialize the error message list
+ */
+
+void
+initialize() {
+       ISC_LIST_INIT(errormsg_list);
+       InitializeCriticalSection(&ErrorMsgLock);
+       initialized = TRUE;
+}
+
+char *
+NTstrerror(int errnum) {
+       if(!initialized)
+               initialize();
+       return (isc__NTstrerror(errnum));
+}
+/*
+ * This routine needs to free up any buffer allocated by FormatMessage
+ * if that routine gets used.
+ */
+
+void
+isc__strerror(int num, char *buf, size_t size) {
+       char *msg;
+       unsigned int unum = num;
+       if(!initialized)
+               initialize();
+
+       msg = isc__NTstrerror(num);
+       if (msg != NULL)
+               _snprintf(buf, size, "%s", msg);
+       else
+               _snprintf(buf, size, "Unknown error: %u", unum);
+}
+
+/*
+ * Note this will cause a memory leak unless the memory allocated here
+ * is freed by calling LocalFree.  isc__strerror does this before unlocking.
+ * This only gets called if there is a system type of error and will likely
+ * be an unusual event.
+ */
+char *
+FormatError(int error) {
+       LPVOID lpMsgBuf = NULL;
+
+       msg_list_t *lmsg; 
+
+       /*
+        * See if we already have the error code
+        */
+
+       LOCK(&ErrorMsgLock);
+
+       lmsg = ISC_LIST_HEAD(errormsg_list);
+       while (lmsg != NULL) {
+               if (lmsg->code == error) {
+                       lpMsgBuf = lmsg->msg;
+                       UNLOCK(&ErrorMsgLock);
+                       return (lpMsgBuf);
+               }
+               lmsg = ISC_LIST_NEXT(lmsg, link);
+       }
+
+       /*
+        * Not found
+        */
+
+       FormatMessage( 
+               FORMAT_MESSAGE_ALLOCATE_BUFFER | 
+               FORMAT_MESSAGE_FROM_SYSTEM | 
+               FORMAT_MESSAGE_IGNORE_INSERTS,
+               NULL,
+               error,
+               /* Default language */
+               MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+               (LPTSTR) &lpMsgBuf,
+               0,
+               NULL); 
+
+       if (lpMsgBuf != NULL) {
+               lmsg = malloc(sizeof(msg_list_t));
+               lmsg->code = error;
+               lmsg->msg = lpMsgBuf;
+               ISC_LIST_APPEND(errormsg_list, lmsg, link);
+       }
+       UNLOCK(&ErrorMsgLock);
+       return (lpMsgBuf);
+}
+
+/*
+ * This routine checks the error value and calls the WSA Windows Sockets
+ * Error message function GetWSAErrorMessage below if it's within that range
+ * since those messages are not available in the system error messages.
+ */
+static char *
+isc__NTstrerror(int err) {
+       char *retmsg = NULL;
+
+       /* Copy the error value first in case of other errors */        
+       DWORD errval = err; 
+
+       /* Get the Winsock2 error messages */
+       if (errval >= WSABASEERR && errval <= (WSABASEERR + 1015)) {
+               retmsg = GetWSAErrorMessage(errval);
+               if (retmsg != NULL)
+                       return (retmsg);
+       }
+       /*
+        * If it's not one of the standard Unix error codes,
+        * try a system error message
+        */
+       if (errval > (DWORD) _sys_nerr) {
+               return (FormatError(errval));
+       } else {
+               return (_sys_errlist[errval]);
+       }
+}
+
+/*
+ * This is a replacement for perror
+ */
+void __cdecl
+NTperror(char *errmsg) {
+       /* Copy the error value first in case of other errors */
+       int errval = errno; 
+       char *msg;
+       if(!initialized)
+               initialize();
+
+       msg = isc__NTstrerror(errval);
+       fprintf(stderr, "%s: %s\n", errmsg, msg);
+
+}
+
+/*
+ * Return the error string related to Winsock2 errors.
+ * This function is necessary since FormatMessage knows nothing about them
+ * and there is no function to get them.
+ */
+char *
+GetWSAErrorMessage(int errval) {
+       char *msg;
+
+       switch (errval) {
+
+       case WSAEINTR:
+               msg = "Interrupted system call";
+               break;
+
+       case WSAEBADF:
+               msg = "Bad file number";
+               break;
+
+       case WSAEACCES:
+               msg = "Permission denied";
+               break;
+
+       case WSAEFAULT:
+               msg = "Bad address";
+               break;
+
+       case WSAEINVAL:
+               msg = "Invalid argument";
+               break;
+
+       case WSAEMFILE:
+               msg = "Too many open sockets";
+               break;
+
+       case WSAEWOULDBLOCK:
+               msg = "Operation would block";
+               break;
+
+       case WSAEINPROGRESS:
+               msg = "Operation now in progress";
+               break;
+
+       case WSAEALREADY:
+               msg = "Operation already in progress";
+               break;
+
+       case WSAENOTSOCK:
+               msg = "Socket operation on non-socket";
+               break;
+
+       case WSAEDESTADDRREQ:
+               msg = "Destination address required";
+               break;
+
+       case WSAEMSGSIZE:
+               msg = "Message too long";
+               break;
+
+       case WSAEPROTOTYPE:
+               msg = "Protocol wrong type for socket";
+               break;
+
+       case WSAENOPROTOOPT:
+               msg = "Bad protocol option";
+               break;
+
+       case WSAEPROTONOSUPPORT:
+               msg = "Protocol not supported";
+               break;
+
+       case WSAESOCKTNOSUPPORT:
+               msg = "Socket type not supported";
+               break;
+
+       case WSAEOPNOTSUPP:
+               msg = "Operation not supported on socket";
+               break;
+
+       case WSAEPFNOSUPPORT:
+               msg = "Protocol family not supported";
+               break;
+
+       case WSAEAFNOSUPPORT:
+               msg = "Address family not supported";
+               break;
+
+       case WSAEADDRINUSE:
+               msg = "Address already in use";
+               break;
+
+       case WSAEADDRNOTAVAIL:
+               msg = "Can't assign requested address";
+               break;
+
+       case WSAENETDOWN:
+               msg = "Network is down";
+               break;
+
+       case WSAENETUNREACH:
+               msg = "Network is unreachable";
+               break;
+
+       case WSAENETRESET:
+               msg = "Net connection reset";
+               break;
+
+       case WSAECONNABORTED:
+               msg = "Software caused connection abort";
+               break;
+
+       case WSAECONNRESET:
+               msg = "Connection reset by peer";
+               break;
+
+       case WSAENOBUFS:
+               msg = "No buffer space available";
+               break;
+
+       case WSAEISCONN:
+               msg = "Socket is already connected";
+               break;
+
+       case WSAENOTCONN:
+               msg = "Socket is not connected";
+               break;
+
+       case WSAESHUTDOWN:
+               msg = "Can't send after socket shutdown";
+               break;
+
+       case WSAETOOMANYREFS:
+               msg = "Too many references: can't splice";
+               break;
+
+       case WSAETIMEDOUT:
+               msg = "Connection timed out";
+               break;
+
+       case WSAECONNREFUSED:
+               msg = "Connection refused";
+               break;
+
+       case WSAELOOP:
+               msg = "Too many levels of symbolic links";
+               break;
+
+       case WSAENAMETOOLONG:
+               msg = "File name too long";
+               break;
+
+       case WSAEHOSTDOWN:
+               msg = "Host is down";
+               break;
+
+       case WSAEHOSTUNREACH:
+               msg = "No route to host";
+               break;
+
+       case WSAENOTEMPTY:
+               msg = "Directory not empty";
+               break;
+
+       case WSAEPROCLIM:
+               msg = "Too many processes";
+               break;
+
+       case WSAEUSERS:
+               msg = "Too many users";
+               break;
+
+       case WSAEDQUOT:
+               msg = "Disc quota exceeded";
+               break;
+
+       case WSAESTALE:
+               msg = "Stale NFS file handle";
+               break;
+
+       case WSAEREMOTE:
+               msg = "Too many levels of remote in path";
+               break;
+
+       case WSASYSNOTREADY:
+               msg = "Network system is unavailable";
+               break;
+
+       case WSAVERNOTSUPPORTED:
+               msg = "Winsock version out of range";
+               break;
+
+       case WSANOTINITIALISED:
+               msg = "WSAStartup not yet called";
+               break;
+
+       case WSAEDISCON:
+               msg = "Graceful shutdown in progress";
+               break;
+/*
+       case WSAHOST_NOT_FOUND:
+               msg = "Host not found";
+               break;
+
+       case WSANO_DATA:
+               msg = "No host data of that type was found";
+               break;
+*/
+       default:
+               msg = NULL;
+               break;
+       }
+       return (msg);
+}
+
+/*
+ * These error messages are more informative about CryptAPI Errors than the
+ * standard error messages
+ */
+
+char *
+GetCryptErrorMessage(int errval) {
+       char *msg;
+
+       switch (errval) {
+
+       case NTE_BAD_FLAGS:
+               msg = "The dwFlags parameter has an illegal value.";
+               break;
+       case NTE_BAD_KEYSET:
+               msg = "The Registry entry for the key container "
+                       "could not be opened and may not exist.";
+               break;
+       case NTE_BAD_KEYSET_PARAM:
+               msg = "The pszContainer or pszProvider parameter "
+                       "is set to an illegal value.";
+               break;
+       case NTE_BAD_PROV_TYPE:
+               msg = "The value of the dwProvType parameter is out "
+                       "of range. All provider types must be from "
+                       "1 to 999, inclusive.";
+               break;
+       case NTE_BAD_SIGNATURE:
+               msg = "The provider DLL signature did not verify "
+                       "correctly. Either the DLL or the digital "
+                       "signature has been tampered with.";
+               break;
+       case NTE_EXISTS:
+               msg = "The dwFlags parameter is CRYPT_NEWKEYSET, but the key"
+                     " container already exists.";
+               break;
+       case NTE_KEYSET_ENTRY_BAD:
+               msg = "The Registry entry for the pszContainer key container "
+                     "was found (in the HKEY_CURRENT_USER window), but is "
+                     "corrupt. See the section System Administration for "
+                     " etails about CryptoAPI's Registry usage.";
+               break;
+       case NTE_KEYSET_NOT_DEF:
+               msg = "No Registry entry exists in the HKEY_CURRENT_USER "
+                       "window for the key container specified by "
+                       "pszContainer.";
+               break;
+       case NTE_NO_MEMORY:
+               msg = "The CSP ran out of memory during the operation.";
+               break;
+       case NTE_PROV_DLL_NOT_FOUND:
+               msg = "The provider DLL file does not exist or is not on the "
+                     "current path.";
+               break;
+       case NTE_PROV_TYPE_ENTRY_BAD:
+               msg = "The Registry entry for the provider type specified by "
+                     "dwProvType is corrupt. This error may relate to "
+                     "either the user default CSP list or the machine "
+                     "default CSP list. See the section System "
+                     "Administration for details about CryptoAPI's "
+                     "Registry usage.";
+               break;
+       case NTE_PROV_TYPE_NO_MATCH:
+               msg = "The provider type specified by dwProvType does not "
+                     "match the provider type found in the Registry. Note "
+                     "that this error can only occur when pszProvider "
+                     "specifies an actual CSP name.";
+               break;
+       case NTE_PROV_TYPE_NOT_DEF:
+               msg = "No Registry entry exists for the provider type "
+                     "specified by dwProvType.";
+               break;
+       case NTE_PROVIDER_DLL_FAIL:
+               msg = "The provider DLL file could not be loaded, and "
+                     "may not exist. If it exists, then the file is "
+                     "not a valid DLL.";
+               break;
+       case NTE_SIGNATURE_FILE_BAD:
+               msg = "An error occurred while loading the DLL file image, "
+                     "prior to verifying its signature.";
+               break;
+
+       default:
+               msg = NULL;
+               break;
+       }
+       return msg;
+}
+
diff --git a/ports/winnt/libisc/net.c b/ports/winnt/libisc/net.c
new file mode 100644 (file)
index 0000000..60375b5
--- /dev/null
@@ -0,0 +1,335 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2003  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: net.c,v 1.3.2.2.4.7 2004/04/29 01:31:23 marka Exp $ */
+
+#include <config.h>
+
+#include <errno.h>
+#include <unistd.h>
+
+#include <ws2tcpip.h>
+#include <isc/ipv6.h>
+#include <isc/net.h>
+#include <isc/once.h>
+#include <isc/strerror.h>
+#include <isc/string.h>
+#include <isc/util.h>
+
+#if defined(ISC_PLATFORM_NEEDIN6ADDRANY)
+const struct in6_addr isc_net_in6addrany = IN6ADDR_ANY_INIT;
+#endif
+
+static isc_boolean_t   once = ISC_FALSE;
+static isc_once_t      once_ipv6only = ISC_ONCE_INIT;
+static isc_once_t      once_ipv6pktinfo = ISC_ONCE_INIT;
+static isc_result_t    ipv4_result = ISC_R_NOTFOUND;
+static isc_result_t    ipv6_result = ISC_R_NOTFOUND;
+static isc_result_t    ipv6only_result = ISC_R_NOTFOUND;
+static isc_result_t    ipv6pktinfo_result = ISC_R_NOTFOUND;
+
+static isc_result_t
+try_proto(int domain) {
+       SOCKET s;
+       isc_result_t result = ISC_R_SUCCESS;
+       char strbuf[ISC_STRERRORSIZE];
+       int errval;
+
+       s = socket(domain, SOCK_STREAM, 0);
+       if (s == INVALID_SOCKET) {
+               errval = WSAGetLastError();
+               switch (errval) {
+               case WSAEAFNOSUPPORT:
+               case WSAEPROTONOSUPPORT:
+               case WSAEINVAL:
+                       return (ISC_R_NOTFOUND);
+               default:
+                       isc__strerror(errval, strbuf, sizeof(strbuf));
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                        "socket() %s failed",
+                                        strbuf);
+                       return (ISC_R_UNEXPECTED);
+               }
+       }
+
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifdef WANT_IPV6
+#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
+       if (domain == PF_INET6) {
+               struct sockaddr_in6 sin6;
+               unsigned int len;
+
+               /*
+                * Check to see if IPv6 is broken, as is common on Linux.
+                */
+               len = sizeof(sin6);
+               if (getsockname(s, (struct sockaddr *)&sin6, (void *)&len) < 0)
+               {
+                       result = ISC_R_NOTFOUND;
+               } else {
+                       if (len == sizeof(struct sockaddr_in6))
+                               result = ISC_R_SUCCESS;
+                       else {
+                               result = ISC_R_NOTFOUND;
+                       }
+               }
+       }
+#endif
+#endif
+#endif
+
+       closesocket(s);
+
+       return (result);
+}
+
+static void
+initialize_action(void) {
+       ipv4_result = try_proto(PF_INET);
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifdef WANT_IPV6
+#ifdef ISC_PLATFORM_HAVEIN6PKTINFO
+       ipv6_result = try_proto(PF_INET6);
+#endif
+#endif
+#endif
+}
+
+static void
+initialize(void) {
+       if(once == ISC_FALSE) {
+               initialize_action();
+               once = ISC_TRUE;
+       }
+}
+
+isc_result_t
+isc_net_probeipv4(void) {
+       initialize();
+       return (ipv4_result);
+}
+
+isc_result_t
+isc_net_probeipv6(void) {
+       initialize();
+       return (ipv6_result);
+}
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifdef WANT_IPV6
+static void
+try_ipv6only(void) {
+#ifdef IPV6_V6ONLY
+       SOCKET s;
+       int on;
+       char strbuf[ISC_STRERRORSIZE];
+#endif
+       isc_result_t result;
+
+       result = isc_net_probeipv6();
+       if (result != ISC_R_SUCCESS) {
+               ipv6only_result = result;
+               return;
+       }
+
+#ifndef IPV6_V6ONLY
+       ipv6only_result = ISC_R_NOTFOUND;
+       return;
+#else
+       /* check for TCP sockets */
+       s = socket(PF_INET6, SOCK_STREAM, 0);
+       if (s == INVALID_SOCKET) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "socket() %s: %s",
+                                isc_msgcat_get(isc_msgcat,
+                                               ISC_MSGSET_GENERAL,
+                                               ISC_MSG_FAILED,
+                                               "failed"),
+                                strbuf);
+               ipv6only_result = ISC_R_UNEXPECTED;
+               return;
+       }
+
+       on = 1;
+       if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) {
+               ipv6only_result = ISC_R_NOTFOUND;
+               goto close;
+       }
+
+       close(s);
+
+       /* check for UDP sockets */
+       s = socket(PF_INET6, SOCK_DGRAM, 0);
+       if (s == INVALID_SOCKET) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "socket() %s: %s",
+                                isc_msgcat_get(isc_msgcat,
+                                               ISC_MSGSET_GENERAL,
+                                               ISC_MSG_FAILED,
+                                               "failed"),
+                                strbuf);
+               ipv6only_result = ISC_R_UNEXPECTED;
+               return;
+       }
+
+       on = 1;
+       if (setsockopt(s, IPPROTO_IPV6, IPV6_V6ONLY, &on, sizeof(on)) < 0) {
+               ipv6only_result = ISC_R_NOTFOUND;
+               goto close;
+       }
+
+       close(s);
+
+       ipv6only_result = ISC_R_SUCCESS;
+
+close:
+       close(s);
+       return;
+#endif /* IPV6_V6ONLY */
+}
+
+static void
+initialize_ipv6only(void) {
+       RUNTIME_CHECK(isc_once_do(&once_ipv6only,
+                                 try_ipv6only) == ISC_R_SUCCESS);
+}
+
+static void
+try_ipv6pktinfo(void) {
+       int s, on;
+       char strbuf[ISC_STRERRORSIZE];
+       isc_result_t result;
+       int optname;
+
+       result = isc_net_probeipv6();
+       if (result != ISC_R_SUCCESS) {
+               ipv6pktinfo_result = result;
+               return;
+       }
+
+       /* we only use this for UDP sockets */
+       s = socket(PF_INET6, SOCK_DGRAM, IPPROTO_UDP);
+       if (s == -1) {
+               isc__strerror(errno, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                "socket() %s: %s",
+                                isc_msgcat_get(isc_msgcat,
+                                               ISC_MSGSET_GENERAL,
+                                               ISC_MSG_FAILED,
+                                               "failed"),
+                                strbuf);
+               ipv6pktinfo_result = ISC_R_UNEXPECTED;
+               return;
+       }
+
+#ifdef IPV6_RECVPKTINFO
+       optname = IPV6_RECVPKTINFO;
+#else
+       optname = IPV6_PKTINFO;
+#endif
+       on = 1;
+       if (setsockopt(s, IPPROTO_IPV6, optname, &on, sizeof(on)) < 0) {
+               ipv6pktinfo_result = ISC_R_NOTFOUND;
+               goto close;
+       }
+
+       close(s);
+       ipv6pktinfo_result = ISC_R_SUCCESS;
+
+close:
+       close(s);
+       return;
+}
+
+static void
+initialize_ipv6pktinfo(void) {
+       RUNTIME_CHECK(isc_once_do(&once_ipv6pktinfo,
+                                 try_ipv6pktinfo) == ISC_R_SUCCESS);
+}
+#endif /* WANT_IPV6 */
+#endif /* ISC_PLATFORM_HAVEIPV6 */
+
+isc_result_t
+isc_net_probe_ipv6only(void) {
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifdef WANT_IPV6
+       initialize_ipv6only();
+#else
+       ipv6only_result = ISC_R_NOTFOUND;
+#endif
+#endif
+       return (ipv6only_result);
+}
+
+isc_result_t
+isc_net_probe_ipv6pktinfo(void) {
+#ifdef ISC_PLATFORM_HAVEIPV6
+#ifdef WANT_IPV6
+       initialize_ipv6pktinfo();
+#else
+       ipv6pktinfo_result = ISC_R_NOTFOUND;
+#endif
+#endif
+       return (ipv6pktinfo_result);
+}
+
+void
+isc_net_disableipv4(void) {
+       initialize();
+       if (ipv4_result == ISC_R_SUCCESS)
+               ipv4_result = ISC_R_DISABLED;
+}
+
+void
+isc_net_disableipv6(void) {
+       initialize();
+       if (ipv6_result == ISC_R_SUCCESS)
+               ipv6_result = ISC_R_DISABLED;
+}
+
+void
+isc_net_enableipv4(void) {
+       initialize();
+       if (ipv4_result == ISC_R_DISABLED)
+               ipv4_result = ISC_R_SUCCESS;
+}
+
+void
+isc_net_enableipv6(void) {
+       initialize();
+       if (ipv6_result == ISC_R_DISABLED)
+               ipv6_result = ISC_R_SUCCESS;
+}
+/*
+ * Initialize socket services
+ */
+BOOL Win32InitSockets() {
+       WORD wVersionRequested;
+       WSADATA wsaData;
+       int err;
+
+       /* Need Winsock 2.0 or better */
+       wVersionRequested = MAKEWORD(2, 0);
+       err = WSAStartup(wVersionRequested, &wsaData);
+       if ( err != 0 ) {
+               /* Tell the user that we could not find a usable Winsock DLL */
+               return(FALSE);
+       }
+       return(TRUE);
+}
diff --git a/ports/winnt/libisc/once.c b/ports/winnt/libisc/once.c
new file mode 100644 (file)
index 0000000..846f037
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: once.c,v 1.9 2001/07/09 21:06:16 gson Exp $ */
+
+/* Principal Authors: DCL */
+
+#include <config.h>
+
+#include <windows.h>
+
+#include <isc/once.h>
+#include <isc/assertions.h>
+#include <isc/util.h>
+
+isc_result_t
+isc_once_do(isc_once_t *controller, void(*function)(void)) {
+       REQUIRE(controller != NULL && function != NULL);
+
+       if (controller->status == ISC_ONCE_INIT_NEEDED) {
+
+               if (InterlockedDecrement((long *)&controller->counter) == 0) {
+                       if (controller->status == ISC_ONCE_INIT_NEEDED) {
+                               function();
+                               controller->status = ISC_ONCE_INIT_DONE;
+                       }
+               } else {
+                       while (controller->status == ISC_ONCE_INIT_NEEDED) {
+                               /*
+                                * Spin wait.
+                                */
+                       }
+               }
+       }
+
+       return (ISC_R_SUCCESS);
+}
diff --git a/ports/winnt/libisc/win32os.c b/ports/winnt/libisc/win32os.c
new file mode 100644 (file)
index 0000000..05ca09e
--- /dev/null
@@ -0,0 +1,101 @@
+/*
+ * Copyright (C) 2002 Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: win32os.c,v 1.2 2002/08/03 01:36:24 mayer Exp $ */
+
+#include <windows.h>
+
+#include <isc/win32os.h>
+
+static BOOL bInit = FALSE;
+static OSVERSIONINFOEX osVer;
+
+static void
+initialize_action(void) {
+       BOOL bSuccess;
+
+       if (bInit)
+               return; 
+       /*
+        * NOTE: VC++ 6.0 gets this function declaration wrong
+        * so we compensate by casting the argument
+        */
+       osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
+       bSuccess = GetVersionEx((OSVERSIONINFO *) &osVer);
+
+       /*
+        * Versions of NT before NT4.0 SP6 did not return the
+        * extra info that the EX structure provides and returns
+        * a failure so we need to retry with the old structure.
+        */
+       if(!bSuccess) {
+               osVer.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
+               bSuccess = GetVersionEx((OSVERSIONINFO *) &osVer);
+       }
+       bInit = TRUE;
+}
+
+unsigned int
+isc_win32os_majorversion(void) {
+       initialize_action();
+       return ((unsigned int)osVer.dwMajorVersion);
+}
+
+unsigned int
+isc_win32os_minorversion(void) {
+       initialize_action();
+       return ((unsigned int)osVer.dwMinorVersion);
+}
+
+unsigned int
+isc_win32os_servicepackmajor(void) {
+       initialize_action();
+       return ((unsigned int)osVer.wServicePackMajor);
+}
+
+unsigned int
+isc_win32os_servicepackminor(void) {
+       initialize_action();
+       return ((unsigned int)osVer.wServicePackMinor);
+}
+
+int
+isc_win32os_versioncheck(unsigned int major, unsigned int minor,
+                    unsigned int spmajor, unsigned int spminor) {
+
+       initialize_action();
+
+       if (major < isc_win32os_majorversion())
+               return (1);
+       if (major > isc_win32os_majorversion())
+               return (-1);
+       if (minor < isc_win32os_minorversion())
+               return (1);
+       if (minor > isc_win32os_minorversion())
+               return (-1);
+       if (spmajor < isc_win32os_servicepackmajor())
+               return (1);
+       if (spmajor > isc_win32os_servicepackmajor())
+               return (-1);
+       if (spminor < isc_win32os_servicepackminor())
+               return (1);
+       if (spminor > isc_win32os_servicepackminor())
+               return (-1);
+
+       /* Exact */
+       return (0);
+}
\ No newline at end of file
diff --git a/ports/winnt/libntp/SetSystemTime.c b/ports/winnt/libntp/SetSystemTime.c
new file mode 100644 (file)
index 0000000..1465719
--- /dev/null
@@ -0,0 +1,34 @@
+
+#include "clockstuff.h"
+#include "ntp_stdlib.h"
+
+const char *   set_tod_using = "SetSystemTime";
+
+int
+ntp_set_tod(
+       struct timeval *tv,
+       void *tzp
+       )
+{
+       SYSTEMTIME st;
+       struct tm *gmtm;
+       const time_t x = tv->tv_sec;
+       long y = tv->tv_usec;
+       (void) tzp;
+
+       gmtm = gmtime(&x);
+       st.wSecond              = (WORD) gmtm->tm_sec;
+       st.wMinute              = (WORD) gmtm->tm_min;
+       st.wHour                = (WORD) gmtm->tm_hour;
+       st.wDay                 = (WORD) gmtm->tm_mday;
+       st.wMonth               = (WORD) (gmtm->tm_mon  + 1);
+       st.wYear                = (WORD) (gmtm->tm_year + 1900);
+       st.wDayOfWeek           = (WORD) gmtm->tm_wday;
+       st.wMilliseconds        = (WORD) (y / 1000);
+
+       if (!SetSystemTime(&st)) {
+               msyslog(LOG_ERR, "SetSystemTime failed: %m\n");
+               return -1;
+       }
+       return 0;
+}
diff --git a/ports/winnt/libntp/dnslookup.c b/ports/winnt/libntp/dnslookup.c
new file mode 100644 (file)
index 0000000..6d72edc
--- /dev/null
@@ -0,0 +1,197 @@
+/*
+ * Copyright (C) 2006  Internet Systems Consortium, Inc. ("ISC")
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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 module uses Windows lookup facilities to get the address information
+ * wherever it resides. This avoids calling the Internet standard funcction
+ * gethostbyname and gives us more control over the results since the
+ * Microsoft implementation seems to return the wrong error code for some
+ * conditions.
+ */
+
+#include <config.h>
+#include <ws2tcpip.h>
+#include <nspapi.h>
+#include <svcguid.h>
+#include <ntp_rfc2553.h>
+#include <malloc.h>
+#include <ntp_stdlib.h>
+#include <syslog.h>
+
+/*
+ * Set this Macro to force retries even if it fails
+ * the lookup
+ */
+#ifdef FORCE_DNSRETRY
+
+#undef EAI_NONAME
+#define EAI_NONAME EAI_AGAIN
+
+#endif
+
+typedef struct hostent hostent_t;
+
+int ReturnCode(int errcode)
+{
+       int retcode;
+
+       switch (errcode)
+       {
+       case 0:
+               return (0);
+       case WSAEINVAL:
+               return (EAI_BADFLAGS);
+       case WSANO_DATA:
+               return (EAI_NONAME);
+       case WSANOTINITIALISED:
+       case WSASERVICE_NOT_FOUND:
+               return (EAI_FAIL);
+       case WSA_NOT_ENOUGH_MEMORY:
+               return (EAI_MEMORY);
+       default:
+               return (EAI_FAIL);
+       }
+}
+
+int
+AddToAddresses(char **Addresses, int *cnt, CSADDR_INFO *csaddr)
+{
+
+       int csize;
+       struct in_addr *sinaddr;
+       char *addr;
+       struct in_addr *addr_list;
+       struct sockaddr_in *sin;
+       sin = (struct sockaddr_in *) csaddr->RemoteAddr.lpSockaddr;
+       if (*Addresses != NULL)
+       {
+               csize = _msize(*Addresses);
+               addr_list = realloc(*Addresses, csize + sizeof(struct in_addr));
+       }
+       else
+       {
+               csize = 0;
+               addr_list = malloc(sizeof(struct in_addr));
+       }
+       addr = (char *) addr_list;
+       sinaddr = &((struct in_addr*) addr)[(*cnt)];
+       memset(sinaddr, 0, sizeof(sinaddr));
+       memcpy(sinaddr, &sin->sin_addr, sizeof(struct in_addr));
+       
+       (*cnt)++;
+       *Addresses = (char *) addr_list;
+       return 0;
+}
+
+int
+DNSlookup_name(
+       const char *name,
+       int ai_family,
+       struct hostent **Addresses
+)
+{
+       char buffer[sizeof(WSAQUERYSET) + 2048];
+       WSAQUERYSET query;
+       struct hostent *addr = NULL;
+       char *bufaddr = NULL;
+       char ** addrlist = &bufaddr;
+       int addrcnt = 0;
+       WSAQUERYSET *results = (WSAQUERYSET *) buffer;
+       GUID    HostnameGUID = SVCID_INET_HOSTADDRBYNAME;
+       HANDLE  handle;
+       DWORD dwLength;
+       int err = 0;
+       int retcode = 0;
+       int errcode = 0;
+       DWORD i;
+
+       /*
+        * First we must create a query set
+        */
+       memset(&query, 0, sizeof(query));
+       query.dwSize = sizeof(query);
+       query.lpszServiceInstanceName = (char *)name;
+       query.dwNameSpace = NS_DNS;
+       query.lpServiceClassId = &HostnameGUID;
+
+       err = WSALookupServiceBegin(&query,
+                                 LUP_RETURN_NAME | LUP_RETURN_BLOB | LUP_RETURN_ADDR,
+                                 &handle);
+
+       if(err == SOCKET_ERROR)
+       {
+               /*
+                * Convert the error code and return
+                */
+               return (ReturnCode(WSAGetLastError()));
+       }
+
+       /*
+        * Initially none
+        * Change if we get something
+        */
+       retcode = EAI_NONAME;
+       dwLength = sizeof(buffer);
+
+       while(err == 0)         /* Drop out when error */
+       {
+               memset(&buffer, 0, dwLength);
+               err = WSALookupServiceNext(
+                                       handle,
+                                       0,
+                                       &dwLength,
+                                       results);
+               errcode = WSAGetLastError();
+               if (results->dwNumberOfCsAddrs > 0)
+               {
+                       if (addr == NULL)
+                       {
+                               addr = (struct hostent *) malloc(sizeof(struct hostent));
+                               memset(addr, 0, sizeof(struct hostent));
+                               addr->h_addrtype = (short) results->lpcsaBuffer->iSocketType;
+                               addr->h_length = sizeof(struct in_addr); /* Only passing back the address */
+                               addrlist = malloc(sizeof(char *));
+                               *addrlist = NULL;
+                       }
+                       for (i = 0; i < results->dwNumberOfCsAddrs; i++)
+                       {
+                               AddToAddresses(addrlist, &addrcnt, &results->lpcsaBuffer[i]);
+                       }
+               }
+
+       }
+       if (addr != NULL)
+       {
+               addr->h_name = (char *) name;
+               addr->h_addr_list = addrlist;
+               retcode = 0;
+               *Addresses = addr;
+       }
+       else
+       {
+#ifdef FORCE_DNSRETRY
+               /*
+                * We do this or the error would never be logged
+                */
+               if (errcode == WSANO_DATA)
+                       msyslog(LOG_ERR, "Address not found for %s", name);
+#endif
+               retcode = ReturnCode(errcode);
+       }
+       WSALookupServiceEnd(handle);
+       return (retcode);
+}
+
diff --git a/ports/winnt/libntp/interfaceiter.c b/ports/winnt/libntp/interfaceiter.c
new file mode 100644 (file)
index 0000000..cfea7ec
--- /dev/null
@@ -0,0 +1,380 @@
+/*
+ * Copyright (C) 1999-2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* $Id: interfaceiter.c,v 1.7 2001/11/27 01:56:21 gson Exp $ */
+
+/*
+ * Note that this code will need to be revisited to support IPv6 Interfaces.
+ * For now we just iterate through IPv4 interfaces.
+ */
+
+#include <config.h>
+#include <winsock2.h>
+#include <ws2tcpip.h>
+#include <sys/types.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+
+#include <isc/interfaceiter.h>
+#include <isc/mem.h>
+#include <isc/result.h>
+#include <isc/string.h>
+#include <isc/strerror.h>
+#include <isc/types.h>
+#include <isc/util.h>
+
+/* Common utility functions */
+
+/*
+ * Extract the network address part from a "struct sockaddr".
+ *
+ * The address family is given explicity
+ * instead of using src->sa_family, because the latter does not work
+ * for copying a network mask obtained by SIOCGIFNETMASK (it does
+ * not have a valid address family).
+ */
+
+
+#define IFITER_MAGIC           0x49464954U     /* IFIT. */
+#define VALID_IFITER(t)                ((t) != NULL && (t)->magic == IFITER_MAGIC)
+
+struct isc_interfaceiter {
+       unsigned int            magic;          /* Magic number. */
+       isc_mem_t               *mctx;
+       int                     socket;
+       INTERFACE_INFO          IFData;         /* Current Interface Info */
+       int                     numIF;          /* Current Interface count */
+       int                     totalIF;        /* Total Number
+                                                  of Interfaces */
+       INTERFACE_INFO          *buf;           /* Buffer for WSAIoctl data. */
+       unsigned int            bufsize;        /* Bytes allocated. */
+       INTERFACE_INFO          *pos;           /* Current offset in IF List */
+       isc_interface_t         current;        /* Current interface data. */
+       isc_result_t            result;         /* Last result code. */
+};
+
+
+/*
+ * Size of buffer for SIO_GET_INTERFACE_LIST, in number of interfaces.
+ * We assume no sane system will have more than than 1K of IP addresses on
+ * all of its adapters.
+ */
+#define IFCONF_SIZE_INITIAL      16
+#define IFCONF_SIZE_INCREMENT    64
+#define IFCONF_SIZE_MAX                1040
+
+static void
+get_addr(unsigned int family, isc_netaddr_t *dst, struct sockaddr *src) {
+       dst->family = family;
+       switch (family) {
+       case AF_INET:
+               memcpy(&dst->type.in,
+                      &((struct sockaddr_in *) src)->sin_addr,
+                      sizeof(struct in_addr));
+               break;
+       case    AF_INET6:
+               memcpy(&dst->type.in6,
+                      &((struct sockaddr_in6 *) src)->sin6_addr,
+                      sizeof(struct in6_addr));
+               break;
+       default:
+               INSIST(0);
+               break;
+       }
+}
+
+isc_result_t
+isc_interfaceiter_create(isc_mem_t *mctx, isc_interfaceiter_t **iterp) {
+       char strbuf[ISC_STRERRORSIZE]; 
+       isc_interfaceiter_t *iter;
+       isc_result_t result;
+       int error;
+       unsigned long bytesReturned = 0;
+
+       REQUIRE(mctx != NULL);
+       REQUIRE(iterp != NULL);
+       REQUIRE(*iterp == NULL);
+
+       iter = isc_mem_get(mctx, sizeof(*iter));
+       if (iter == NULL)
+               return (ISC_R_NOMEMORY);
+
+       iter->mctx = mctx;
+       iter->buf = NULL;
+
+       /*
+        * Create an unbound datagram socket to do the
+        * SIO_GET_INTERFACE_LIST WSAIoctl on.
+        */
+       if ((iter->socket = socket(AF_INET, SOCK_DGRAM, 0)) < 0) {
+               error = WSAGetLastError();
+               isc__strerror(error, strbuf, sizeof(strbuf));
+               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                               "making interface scan socket: %s",
+                               strbuf);
+               result = ISC_R_UNEXPECTED;
+               goto socket_failure;
+       }
+
+       /*
+        * Get the interface configuration, allocating more memory if
+        * necessary.
+        */
+       iter->bufsize = IFCONF_SIZE_INITIAL*sizeof(INTERFACE_INFO);
+
+       for (;;) {
+               iter->buf = isc_mem_get(mctx, iter->bufsize);
+               if (iter->buf == NULL) {
+                       result = ISC_R_NOMEMORY;
+                       goto alloc_failure;
+               }
+
+               if (WSAIoctl(iter->socket, SIO_GET_INTERFACE_LIST,
+                            0, 0, iter->buf, iter->bufsize,
+                            &bytesReturned, 0, 0) == SOCKET_ERROR)
+               {
+                       error = WSAGetLastError();
+                       if (error != WSAEFAULT && error != WSAENOBUFS) {
+                               errno = error;
+                               isc__strerror(error, strbuf, sizeof(strbuf));
+                               UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                               "get interface configuration: %s",
+                                               strbuf);
+                               result = ISC_R_UNEXPECTED;
+                               goto ioctl_failure;
+                       }
+                       /*
+                        * EINVAL.  Retry with a bigger buffer.
+                        */
+               } else {
+                       /*
+                        * The WSAIoctl succeeded.
+                        * If the number of the returned bytes is the same
+                        * as the buffer size, we will grow it just in
+                        * case and retry.
+                        */
+                       if (bytesReturned > 0 &&
+                           (bytesReturned < iter->bufsize))
+                               break;
+               }
+               if (iter->bufsize >= IFCONF_SIZE_MAX*sizeof(INTERFACE_INFO)) {
+                       UNEXPECTED_ERROR(__FILE__, __LINE__,
+                                        "get interface configuration: "
+                                        "maximum buffer size exceeded");
+                       result = ISC_R_UNEXPECTED;
+                       goto ioctl_failure;
+               }
+               isc_mem_put(mctx, iter->buf, iter->bufsize);
+
+               iter->bufsize += IFCONF_SIZE_INCREMENT *
+                       sizeof(INTERFACE_INFO);
+       }
+
+       /*
+        * A newly created iterator has an undefined position
+        * until isc_interfaceiter_first() is called.
+        */
+       iter->pos = NULL;
+       iter->result = ISC_R_FAILURE;
+       iter->numIF = 0;
+       iter->totalIF = bytesReturned/sizeof(INTERFACE_INFO);
+
+
+       iter->magic = IFITER_MAGIC;
+       *iterp = iter;
+       /* We don't need the socket any more, so close it */
+       closesocket(iter->socket);
+       return (ISC_R_SUCCESS);
+
+ ioctl_failure:
+       isc_mem_put(mctx, iter->buf, iter->bufsize);
+
+ alloc_failure:
+       (void) closesocket(iter->socket);
+
+ socket_failure:
+       isc_mem_put(mctx, iter, sizeof(*iter));
+       return (result);
+}
+
+/*
+ * Get information about the current interface to iter->current.
+ * If successful, return ISC_R_SUCCESS.
+ * If the interface has an unsupported address family, or if
+ * some operation on it fails, return ISC_R_IGNORE to make
+ * the higher-level iterator code ignore it.
+ */
+
+static isc_result_t
+internal_current(isc_interfaceiter_t *iter, int family) {
+       BOOL ifNamed = FALSE;
+       unsigned long flags;
+
+       REQUIRE(VALID_IFITER(iter));
+       REQUIRE(iter->numIF >= 0);
+
+       memset(&iter->current, 0, sizeof(iter->current));
+       iter->current.af = family;
+
+       get_addr(family, &iter->current.address,
+                (struct sockaddr *)&(iter->IFData.iiAddress));
+
+       /*
+        * Get interface flags.
+        */
+
+       iter->current.flags = 0;
+       flags = iter->IFData.iiFlags;
+
+       if ((flags & IFF_UP) != 0)
+               iter->current.flags |= INTERFACE_F_UP;
+
+       if ((flags & IFF_POINTTOPOINT) != 0) {
+               iter->current.flags |= INTERFACE_F_POINTTOPOINT;
+               sprintf(iter->current.name, "PPP Interface %d", iter->numIF);
+               ifNamed = TRUE;
+       }
+
+       if ((flags & IFF_LOOPBACK) != 0) {
+               iter->current.flags |= INTERFACE_F_LOOPBACK;
+               sprintf(iter->current.name, "Loopback Interface %d",
+                       iter->numIF);
+               ifNamed = TRUE;
+       }
+
+       /*
+        * If the interface is point-to-point, get the destination address.
+        */
+       if ((iter->current.flags & INTERFACE_F_POINTTOPOINT) != 0) {
+               get_addr(family, &iter->current.dstaddress,
+               (struct sockaddr *)&(iter->IFData.iiBroadcastAddress));
+       }
+
+       if (ifNamed == FALSE)
+               sprintf(iter->current.name,
+                       "TCP/IP Interface %d", iter->numIF);
+
+       /*
+        * Get the network mask.
+        */
+       switch (family) {
+       case AF_INET:
+               get_addr(family, &iter->current.netmask,
+                        (struct sockaddr *)&(iter->IFData.iiNetmask));
+               break;
+       case AF_INET6:
+               break;
+       }
+
+       return (ISC_R_SUCCESS);
+}
+
+/*
+ * Step the iterator to the next interface.  Unlike
+ * isc_interfaceiter_next(), this may leave the iterator
+ * positioned on an interface that will ultimately
+ * be ignored.  Return ISC_R_NOMORE if there are no more
+ * interfaces, otherwise ISC_R_SUCCESS.
+ */
+static isc_result_t
+internal_next(isc_interfaceiter_t *iter) {
+       if (iter->numIF >= iter->totalIF)
+               return (ISC_R_NOMORE);
+
+       /*
+        * The first one needs to be set up to point to the last
+        * Element of the array.  Go to the end and back up
+        * Microsoft's implementation is peculiar for returning
+        * the list in reverse order
+        */
+        
+       if (iter->numIF == 0)
+               iter->pos = (INTERFACE_INFO *)(iter->buf + (iter->totalIF));
+
+       iter->pos--;
+       if (&(iter->pos) < &(iter->buf))
+               return (ISC_R_NOMORE);
+
+       memset(&(iter->IFData), 0, sizeof(INTERFACE_INFO));
+       memcpy(&(iter->IFData), iter->pos, sizeof(INTERFACE_INFO));
+       iter->numIF++;
+
+       return (ISC_R_SUCCESS);
+}
+
+isc_result_t
+isc_interfaceiter_current(isc_interfaceiter_t *iter,
+                         isc_interface_t *ifdata) {
+       REQUIRE(iter->result == ISC_R_SUCCESS);
+       memcpy(ifdata, &iter->current, sizeof(*ifdata));
+       return (ISC_R_SUCCESS);
+}
+
+isc_result_t
+isc_interfaceiter_first(isc_interfaceiter_t *iter) {
+       isc_result_t result;
+
+       REQUIRE(VALID_IFITER(iter));
+
+       iter->numIF = 0;
+       for (;;) {
+               result = internal_next(iter);
+               if (result != ISC_R_SUCCESS)
+                       break;
+               result = internal_current(iter, AF_INET);
+               if (result != ISC_R_IGNORE)
+                       break;
+       }
+       iter->result = result;
+       return (result);
+}
+
+isc_result_t
+isc_interfaceiter_next(isc_interfaceiter_t *iter) {
+       isc_result_t result;
+
+       REQUIRE(VALID_IFITER(iter));
+       REQUIRE(iter->result == ISC_R_SUCCESS);
+
+       for (;;) {
+               result = internal_next(iter);
+               if (result != ISC_R_SUCCESS)
+                       break;
+               result = internal_current(iter,AF_INET);
+               if (result != ISC_R_IGNORE)
+                       break;
+       }
+       iter->result = result;
+       return (result);
+}
+
+void
+isc_interfaceiter_destroy(isc_interfaceiter_t **iterp) {
+       isc_interfaceiter_t *iter;
+       REQUIRE(iterp != NULL);
+       iter = *iterp;
+       REQUIRE(VALID_IFITER(iter));
+
+       isc_mem_put(iter->mctx, iter->buf, iter->bufsize);
+
+       iter->magic = 0;
+       isc_mem_put(iter->mctx, iter, sizeof(*iter));
+       *iterp = NULL;
+}
+
diff --git a/ports/winnt/libntp/libntp.dsp b/ports/winnt/libntp/libntp.dsp
new file mode 100644 (file)
index 0000000..ba5d8d9
--- /dev/null
@@ -0,0 +1,674 @@
+# Microsoft Developer Studio Project File - Name="libntp" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Static Library" 0x0104\r
+\r
+CFG=libntp - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "libntp.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "libntp.mak" CFG="libntp - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "libntp - Win32 Release" (based on "Win32 (x86) Static Library")\r
+!MESSAGE "libntp - Win32 Debug" (based on "Win32 (x86) Static Library")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""$/ntp/dev/ports/winnt/libntp", AWBAAAAA"\r
+# PROP Scc_LocalPath "."\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "libntp - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_MBCS" /D "_LIB" /YX /FD /c\r
+# ADD CPP /nologo /MD /W4 /GX /O2 /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /I "..\..\..\libopts" /D "NDEBUG" /D "_LIB" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FD /c\r
+# SUBTRACT CPP /YX\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LIB32=link.exe -lib\r
+# ADD BASE LIB32 /nologo\r
+# ADD LIB32 /nologo\r
+\r
+!ELSEIF  "$(CFG)" == "libntp - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "libntp___Win32_Debug"\r
+# PROP BASE Intermediate_Dir "libntp___Win32_Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_MBCS" /D "_LIB" /YX /FD /GZ /c\r
+# ADD CPP /nologo /MDd /W4 /Gm /GX /ZI /Od /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /I "..\..\..\libopts" /D "_DEBUG" /D "_LIB" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /FD /GZ /c\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LIB32=link.exe -lib\r
+# ADD BASE LIB32 /nologo\r
+# ADD LIB32 /nologo\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "libntp - Win32 Release"\r
+# Name "libntp - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\a_md5encrypt.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\adjtime.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\assertions.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\atoint.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\atolfp.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\atouint.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\authkeys.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\authreadkeys.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\authusekey.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\buftvtots.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\caljulian.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\caltontp.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\calyearstart.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\clocktime.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\clocktypes.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\decodenetnum.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\dnslookup.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\dofptoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\dolfptoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\emalloc.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\error.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\findconfig.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\fptoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\fptoms.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\getopt.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\hextoint.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\hextolfp.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\humandate.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\inet_aton.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\inet_ntop.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\inet_pton.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libisc\interfaceiter.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\inttoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\iosignal.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libisc\isc_strerror.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\lib.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\lib_strbuf.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libopts\libopts.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\machines.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\md5c.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\mem.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\memmove.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\mfptoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\mfptoms.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\mktime.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\modetoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\msgcat.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\mstolfp.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\msutotsf.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\msyslog.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libisc\net.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\netaddr.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\netof.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\netscope.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\ntp_random.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\ntp_rfc2553.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\numtoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\numtohost.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\octtoint.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libisc\once.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\prettydate.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\randfile.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\recvbuff.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\refnumtoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\SetSystemTime.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libisc\sockaddr.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\socktoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\socktohost.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\statestr.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\syslog.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\syssignal.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\systime.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\transmitbuff.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\tsftomsu.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\tstotv.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\tvtoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\tvtots.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\uglydate.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\uinttoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\utvtoa.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libisc\win32os.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\ymd2yd.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\binio.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\clockstuff.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\config.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\global.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ieee754io.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\netinet\in.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\arpa\inet.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\isc\interfaceiter.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\sys\ioctl.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\iosignal.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\isc\ipv6.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\l_stdlib.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\lib_strbuf.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\md5.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\isc\net.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\isc\netaddr.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\netdb.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\isc\netscope.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_calendar.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_control.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_fp.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_if.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_io.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\ntp_iocompletionport.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_machine.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_malloc.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_proto.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_random.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_refclock.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_rfc2553.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_select.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_stdlib.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_string.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_syslog.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\ntp_timer.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_types.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_unixtime.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntpd.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\recvbuff.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\sys\signal.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\sys\socket.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\syslog.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\termios.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\sys\time.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\transmitbuff.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\win32_io.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\isc\win32os.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Generated Files"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Source File\r
+\r
+SOURCE=.\messages.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Source File\r
+\r
+SOURCE=.\messages.mc\r
+\r
+!IF  "$(CFG)" == "libntp - Win32 Release"\r
+\r
+# PROP Ignore_Default_Tool 1\r
+# Begin Custom Build - Message Compiler\r
+InputDir=.\r
+InputPath=.\messages.mc\r
+InputName=messages\r
+\r
+BuildCmds= \\r
+       mc -h $(InputDir) -r $(InputDir) -e h $(InputPath)\r
+\r
+"$(InputDir)\$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+   $(BuildCmds)\r
+\r
+"$(InputDir)\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+   $(BuildCmds)\r
+\r
+"$(InputDir)\msg00001.bin" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+   $(BuildCmds)\r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "libntp - Win32 Debug"\r
+\r
+# PROP Ignore_Default_Tool 1\r
+# Begin Custom Build - Message Compiler\r
+InputDir=.\r
+InputPath=.\messages.mc\r
+InputName=messages\r
+\r
+BuildCmds= \\r
+       mc -h $(InputDir) -r $(InputDir) -e h $(InputPath)\r
+\r
+"$(InputDir)\$(InputName).rc" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+   $(BuildCmds)\r
+\r
+"$(InputDir)\$(InputName).h" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+   $(BuildCmds)\r
+\r
+"$(InputDir)\msg00001.bin" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+   $(BuildCmds)\r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# End Group\r
+# End Target\r
+# End Project\r
diff --git a/ports/winnt/libntp/libntp.vcproj b/ports/winnt/libntp/libntp.vcproj
new file mode 100644 (file)
index 0000000..6a11534
--- /dev/null
@@ -0,0 +1,2233 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="libntp"
+       ProjectGUID="{400FBFCB-462E-40D0-B06B-3B74E3FFFD00}"
+       TargetFrameworkVersion="0"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory=".\Debug"
+                       IntermediateDirectory=".\Debug"
+                       ConfigurationType="4"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               WholeProgramOptimization="false"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\include,..\..\..\libopts"
+                               PreprocessorDefinitions="_DEBUG;_LIB;WIN32;SYS_WINNT;HAVE_CONFIG_H;_USE_32BIT_TIME_T;"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               PrecompiledHeaderFile=".\Debug/libntp.pch"
+                               AssemblerListingLocation=".\Debug/"
+                               ObjectFile=".\Debug/"
+                               ProgramDataBaseFileName=".\Debug/"
+                               BrowseInformation="1"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                               OutputFile=".\Debug\libntp.lib"
+                               SuppressStartupBanner="true"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Debug/libntp.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory=".\Release"
+                       IntermediateDirectory=".\Release"
+                       ConfigurationType="4"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               InlineFunctionExpansion="1"
+                               WholeProgramOptimization="false"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\include,..\..\..\libopts"
+                               PreprocessorDefinitions="NDEBUG;_LIB;WIN32;SYS_WINNT;HAVE_CONFIG_H;_USE_32BIT_TIME_T;"
+                               GeneratePreprocessedFile="0"
+                               StringPooling="true"
+                               ExceptionHandling="0"
+                               RuntimeLibrary="0"
+                               EnableFunctionLevelLinking="false"
+                               PrecompiledHeaderFile=".\Release/libntp.pch"
+                               AssemblerListingLocation=".\Release/"
+                               ObjectFile=".\Release/"
+                               ProgramDataBaseFileName=".\Release\"
+                               BrowseInformation="1"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLibrarianTool"
+                               OutputFile=".\Release\libntp.lib"
+                               SuppressStartupBanner="true"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Release/libntp.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+                       >
+                       <File
+                               RelativePath="..\..\..\libntp\a_md5encrypt.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\adjtime.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\assertions.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\atoint.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\atolfp.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\atouint.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\authkeys.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\authreadkeys.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\authusekey.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\buftvtots.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\caljulian.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\caltontp.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\calyearstart.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\clocktime.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\clocktypes.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\decodenetnum.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="dnslookup.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\dofptoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\dolfptoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\emalloc.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\error.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\findconfig.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\fptoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\fptoms.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\getopt.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\hextoint.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\hextolfp.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\humandate.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\inet_aton.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\inet_ntop.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\inet_pton.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libisc\interfaceiter.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\inttoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\iosignal.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libisc\isc_strerror.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\lib.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\lib_strbuf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libopts\libopts.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               WarningLevel="0"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               WarningLevel="0"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\machines.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\md5c.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\mem.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\memmove.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\mfptoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\mfptoms.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\mktime.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\modetoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\msgcat.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\mstolfp.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\msutotsf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\msyslog.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libisc\net.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\netaddr.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\netof.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\netscope.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\ntp_random.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\ntp_rfc2553.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\numtoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\numtohost.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\octtoint.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libisc\once.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\prettydate.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="randfile.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\recvbuff.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\refnumtoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="SetSystemTime.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libisc\sockaddr.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\socktoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\socktohost.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\statestr.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="syslog.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\syssignal.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\systime.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="transmitbuff.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\tsftomsu.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\tstotv.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\tvtoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\tvtots.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\uglydate.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\uinttoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\utvtoa.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libisc\win32os.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\ymd2yd.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl"
+                       >
+                       <File
+                               RelativePath="..\..\..\include\binio.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\clockstuff.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\config.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\global.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ieee754io.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\netinet\in.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\arpa\inet.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\isc\interfaceiter.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\sys\ioctl.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\iosignal.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\isc\ipv6.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\l_stdlib.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\lib_strbuf.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\md5.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\isc\net.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\isc\netaddr.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\netdb.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\isc\netscope.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_calendar.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_control.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_debug.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_fp.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_if.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_io.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\ntp_iocompletionport.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_machine.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_malloc.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_proto.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_random.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_refclock.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_rfc2553.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_select.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_stdlib.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_string.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_syslog.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\ntp_timer.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_types.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_unixtime.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntpd.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\recvbuff.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\sys\signal.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\sys\socket.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\syslog.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\termios.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\sys\time.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\transmitbuff.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\win32_io.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\isc\win32os.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Generated Files"
+                       >
+                       <File
+                               RelativePath="messages.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       >
+                       <File
+                               RelativePath="messages.mc"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Message Compiler"
+                                               CommandLine="mc -h $(InputDir) -r $(InputDir) -e h $(InputPath)&#x0D;&#x0A;"
+                                               Outputs="$(InputDir)$(InputName).rc;$(InputDir)$(InputName).h;$(InputDir)msg00001.bin"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCustomBuildTool"
+                                               Description="Message Compiler"
+                                               CommandLine="mc -h $(InputDir) -r $(InputDir) -e h $(InputPath)&#x0D;&#x0A;"
+                                               Outputs="$(InputDir)$(InputName).rc;$(InputDir)$(InputName).h;$(InputDir)msg00001.bin"
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/ports/winnt/libntp/messages.mc b/ports/winnt/libntp/messages.mc
new file mode 100644 (file)
index 0000000..3a6bc7d
--- /dev/null
@@ -0,0 +1,161 @@
+; /*
+; Microsoft Developer Support
+; Copyright (c) 1992 Microsoft Corporation
+;
+; This file contains the message definitions for the Win32
+; syslog support messages for the nntp firewall
+
+;-------------------------------------------------------------------------
+; HEADER SECTION
+;
+; The header section defines names and language identifiers for use
+; by the message definitions later in this file. The MessageIdTypedef,
+; SeverityNames, FacilityNames, and LanguageNames keywords are
+; optional and not required.
+;
+;
+MessageIdTypedef=DWORD
+;
+; The MessageIdTypedef keyword gives a typedef name that is used in a
+; type cast for each message code in the generated include file. Each
+; message code appears in the include file with the format: #define
+; name ((type) 0xnnnnnnnn) The default value for type is empty, and no
+; type cast is generated. It is the programmer's responsibility to
+; specify a typedef statement in the application source code to define
+; the type. The type used in the typedef must be large enough to
+; accomodate the entire 32-bit message code.
+;
+;
+SeverityNames=(Success=0x0:STATUS_SEVERITY_SUCCESS
+               Informational=0x1:STATUS_SEVERITY_INFORMATIONAL
+               Warning=0x2:STATUS_SEVERITY_WARNING
+               Error=0x3:STATUS_SEVERITY_ERROR
+              )
+;
+; The SeverityNames keyword defines the set of names that are allowed
+; as the value of the Severity keyword in the message definition. The
+; set is delimited by left and right parentheses. Associated with each
+; severity name is a number that, when shifted left by 30, gives the
+; bit pattern to logical-OR with the Facility value and MessageId
+; value to form the full 32-bit message code. The default value of
+; this keyword is:
+;
+; SeverityNames=(
+;   Success=0x0
+;   Informational=0x1
+;   Warning=0x2
+;   Error=0x3
+;   )
+;
+; Severity values occupy the high two bits of a 32-bit message code.
+; Any severity value that does not fit in two bits is an error. The
+; severity codes can be given symbolic names by following each value
+; with :name
+;
+;
+;FacilityNames=(System=0x0:FACILITY_SYSTEM
+;               Runtime=0x2:FACILITY_RUNTIME
+;               Stubs=0x3:FACILITY_STUBS
+;               Io=0x4:FACILITY_IO_ERROR_CODE
+;              )
+;
+; The FacilityNames keyword defines the set of names that are allowed
+; as the value of the Facility keyword in the message definition. The
+; set is delimited by left and right parentheses. Associated with each
+; facility name is a number that, when shift it left by 16 bits, gives
+; the bit pattern to logical-OR with the Severity value and MessageId
+; value to form the full 32-bit message code. The default value of
+; this keyword is:
+;
+; FacilityNames=(
+;   System=0x0FF
+;   Application=0xFFF
+;   )
+;
+; Facility codes occupy the low order 12 bits of the high order
+; 16-bits of a 32-bit message code. Any facility code that does not
+; fit in 12 bits is an error. This allows for 4,096 facility codes.
+; The first 256 codes are reserved for use by the system software. The
+; facility codes can be given symbolic names by following each value
+; with :name
+;
+;
+; The LanguageNames keyword defines the set of names that are allowed
+; as the value of the Language keyword in the message definition. The
+; set is delimited by left and right parentheses. Associated with each
+; language name is a number and a file name that are used to name the
+; generated resource file that contains the messages for that
+; language. The number corresponds to the language identifier to use
+; in the resource table. The number is separated from the file name
+; with a colon. The initial value of LanguageNames is:
+;
+; LanguageNames=(English=1:MSG00001)
+;
+; Any new names in the source file which don't override the built-in
+; names are added to the list of valid languages. This allows an
+; application to support private languages with descriptive names.
+;
+;
+;-------------------------------------------------------------------------
+; MESSAGE DEFINITION SECTION
+;
+; Following the header section is the body of the Message Compiler
+; source file. The body consists of zero or more message definitions.
+; Each message definition begins with one or more of the following
+; statements:
+;
+; MessageId = [number|+number]
+; Severity = severity_name
+; Facility = facility_name
+; SymbolicName = name
+;
+; The MessageId statement marks the beginning of the message
+; definition. A MessageID statement is required for each message,
+; although the value is optional. If no value is specified, the value
+; used is the previous value for the facility plus one. If the value
+; is specified as +number then the value used is the previous value
+; for the facility, plus the number after the plus sign. Otherwise, if
+; a numeric value is given, that value is used. Any MessageId value
+; that does not fit in 16 bits is an error.
+;
+; The Severity and Facility statements are optional. These statements
+; specify additional bits to OR into the final 32-bit message code. If
+; not specified they default to the value last specified for a message
+; definition. The initial values prior to processing the first message
+; definition are:
+;
+; Severity=Success
+; Facility=Application
+;
+; The value associated with Severity and Facility must match one of
+; the names given in the FacilityNames and SeverityNames statements in
+; the header section. The SymbolicName statement allows you to
+; associate a C/C++ symbolic constant with the final 32-bit message
+; code.
+; */
+
+MessageId=0x1
+Severity=Error
+Facility=Application
+SymbolicName=NTP_ERROR
+Language=English
+%1
+.
+
+MessageId=0x2
+Severity=Warning
+Facility=Application
+SymbolicName=NTP_WARNING
+Language=English
+%1
+
+.
+MessageId=0x3
+Severity=Informational
+Facility=Application
+SymbolicName=NTP_INFO
+Language=English
+%1
+
+
+
diff --git a/ports/winnt/libntp/mexit.c b/ports/winnt/libntp/mexit.c
new file mode 100644 (file)
index 0000000..e6b4469
--- /dev/null
@@ -0,0 +1,30 @@
+/*
+ * mexit - Used to exit the NTPD daemon
+ * 
+ */
+
+#include <windows.h>
+#include <stdio.h>
+
+HANDLE hServDoneEvent = NULL;
+
+void
+service_exit(
+       int status
+       )
+{
+       extern int debug;
+
+       if (debug) /* did not become a service, simply exit */
+           ExitThread((DWORD)status);
+       else {
+               /* service mode, need to have the service_main routine
+                * register with the service control manager that the 
+                * service has stopped running, before exiting
+                */
+               if ((status > 0) && (hServDoneEvent != NULL))
+                   SetEvent(hServDoneEvent);
+               ExitThread((DWORD)status);
+       }
+}
+
diff --git a/ports/winnt/libntp/randfile.c b/ports/winnt/libntp/randfile.c
new file mode 100644 (file)
index 0000000..8068917
--- /dev/null
@@ -0,0 +1,114 @@
+/*
+ * Make sure that there is a good source of random characters
+ * so that OpenSSL can work properly and securely.
+ */
+
+/* Skip asynch rpc inclusion */
+#ifndef __RPCASYNC_H__
+#define __RPCASYNC_H__
+#endif
+
+#include <windows.h>
+#include <wincrypt.h>
+
+#include <stdio.h>
+
+unsigned int   getrandom_chars(int desired, unsigned char *buf, int lenbuf);
+BOOL           create_random_file(char *filename);
+
+BOOL
+init_randfile()
+{
+       FILE *rf;
+       char *randfile;
+       char *homedir;
+       char tmp[256];
+       /* See if the environmental variable RANDFILE is defined
+        * and the file exists
+        */
+       randfile = getenv("RANDFILE");
+       if (randfile != NULL) {
+               rf = fopen(randfile, "rb");
+               if (rf != NULL) {
+                       fclose(rf);
+                       return (TRUE);
+               }
+               else {
+                       /* The environmental variable exists but not the file */
+                       return (create_random_file(randfile));
+               }
+       }
+       /*
+        * If the RANDFILE environmental variable does not exist,
+        * see if the HOME enviromental variable exists and
+        * a .rnd file is in there.
+        */
+       homedir = getenv("HOME");
+       if (homedir != NULL) {
+               strcpy(tmp, homedir);
+               strcat(tmp, "\\.rnd");
+               rf = fopen(tmp, "rb");
+               if (rf != NULL) {
+                       fclose(rf);
+                       return (TRUE);
+               }
+               else {
+                       /* The HOME environmental variable exists but not the file */
+                       return (create_random_file(tmp));
+               }
+       }
+       /*
+        * Final try. Look for it on the C:\ directory
+        * NOTE: This is a really bad place for it security-wise
+        * However, OpenSSL looks for it there if it can't find it elsewhere
+        */
+       rf = fopen("C:\\.rnd", "rb");
+       if (rf != NULL) {
+               fclose(rf);
+               return (TRUE);
+       }
+       /* The file does not exist */
+       return (create_random_file("C:\\.rnd"));
+}
+/*
+ * Routine to create the random file with 1024 random characters
+ */
+BOOL
+create_random_file(char *filename) {
+       FILE *rf;
+       int nchars;
+       unsigned char buf[1025];
+
+       nchars = getrandom_chars(1024, buf, sizeof(buf));
+       rf = fopen(filename, "wb");
+       if (rf == NULL)
+               return (FALSE);
+       fwrite(buf, sizeof(unsigned char), nchars, rf);
+       fclose(rf);
+       return (TRUE);
+}
+
+unsigned int
+getrandom_chars(int desired, unsigned char *buf, int lenbuf) {
+       HCRYPTPROV hcryptprov;
+       BOOL err;
+
+       if (buf == NULL || lenbuf <= 0 || desired > lenbuf)
+               return (0);
+       /*
+        * The first time we just try to acquire the context
+        */
+       err = CryptAcquireContext(&hcryptprov, NULL, NULL, PROV_RSA_FULL,
+                                 CRYPT_VERIFYCONTEXT);
+       if (!err){
+               return (0);
+       }
+       if (!CryptGenRandom(hcryptprov, desired, buf)) {
+               CryptReleaseContext(hcryptprov, 0);
+               return (0);
+       }
+
+       CryptReleaseContext(hcryptprov, 0);
+       return (desired);
+}
+
diff --git a/ports/winnt/libntp/strerror.c b/ports/winnt/libntp/strerror.c
new file mode 100644 (file)
index 0000000..58d4c65
--- /dev/null
@@ -0,0 +1,440 @@
+/*
+ * Copyright (C) 2002  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* From BIND 9 lib/isc/win32/: strerror.c,v 1.5 2002/08/01 03:52:14 mayer */
+
+#include <stdio.h>
+#include <string.h>
+#include <winsock2.h>
+
+/*
+ * Forward declarations
+ */
+
+char *
+FormatError(int error);
+
+char *
+GetWSAErrorMessage(int errval);
+
+char *
+NTstrerror(int err, BOOL *bfreebuf);
+
+char *
+strerror(int errnum) {
+       BOOL bfreebuf;
+       return (NTstrerror(errnum, &bfreebuf));
+}
+/*
+ * This routine needs to free up any buffer allocated by FormatMessage
+ * if that routine gets used.
+ */
+
+void
+isc__strerror(int num, char *buf, size_t size) {
+       char *msg;
+       BOOL freebuf;
+       unsigned int unum = num;
+
+       freebuf = FALSE;
+       msg = NTstrerror(num, &freebuf);
+       if (msg != NULL)
+               _snprintf(buf, size, "%s", msg);
+       else
+               _snprintf(buf, size, "Unknown error: %u", unum);
+       if(freebuf && msg != NULL) {
+               LocalFree(msg);
+       }
+}
+
+/*
+ * Note this will cause a memory leak unless the memory allocated here
+ * is freed by calling LocalFree.  isc__strerror does this before unlocking.
+ * This only gets called if there is a system type of error and will likely
+ * be an unusual event.
+ */
+char *
+FormatError(int error) {
+       LPVOID lpMsgBuf = NULL;
+       FormatMessage( 
+               FORMAT_MESSAGE_ALLOCATE_BUFFER | 
+               FORMAT_MESSAGE_FROM_SYSTEM | 
+               FORMAT_MESSAGE_IGNORE_INSERTS,
+               NULL,
+               error,
+               /* Default language */
+               MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT),
+               (LPTSTR) &lpMsgBuf,
+               0,
+               NULL); 
+
+       return (lpMsgBuf);
+}
+
+/*
+ * This routine checks the error value and calls the WSA Windows Sockets
+ * Error message function GetWSAErrorMessage below if it's within that range
+ * since those messages are not available in the system error messages.
+ */
+char *
+NTstrerror(int err, BOOL *bfreebuf) {
+       char *retmsg = NULL;
+
+       /* Copy the error value first in case of other errors */        
+       DWORD errval = err; 
+
+       *bfreebuf = FALSE;
+
+       /* Get the Winsock2 error messages */
+       if (errval >= WSABASEERR && errval <= (WSABASEERR + 1015)) {
+               retmsg = GetWSAErrorMessage(errval);
+               if (retmsg != NULL)
+                       return (retmsg);
+       }
+       /*
+        * If it's not one of the standard Unix error codes,
+        * try a system error message
+        */
+       if (errval > (DWORD) _sys_nerr) {
+               *bfreebuf = TRUE;
+               return (FormatError(errval));
+       } else {
+               return (_sys_errlist[errval]);
+       }
+}
+
+/*
+ * This is a replacement for perror
+ */
+void __cdecl
+NTperror(char *errmsg) {
+       /* Copy the error value first in case of other errors */
+       int errval = errno; 
+       BOOL bfreebuf = FALSE;
+       char *msg;
+
+       msg = NTstrerror(errval, &bfreebuf);
+       fprintf(stderr, "%s: %s\n", errmsg, msg);
+       if(bfreebuf == TRUE) {
+               LocalFree(msg);
+       }
+
+}
+
+/*
+ * Return the error string related to Winsock2 errors.
+ * This function is necessary since FormatMessage knows nothing about them
+ * and there is no function to get them.
+ */
+char *
+GetWSAErrorMessage(int errval) {
+       char *msg;
+
+       switch (errval) {
+
+       case WSAEINTR:
+               msg = "Interrupted system call";
+               break;
+
+       case WSAEBADF:
+               msg = "Bad file number";
+               break;
+
+       case WSAEACCES:
+               msg = "Permission denied";
+               break;
+
+       case WSAEFAULT:
+               msg = "Bad address";
+               break;
+
+       case WSAEINVAL:
+               msg = "Invalid argument";
+               break;
+
+       case WSAEMFILE:
+               msg = "Too many open sockets";
+               break;
+
+       case WSAEWOULDBLOCK:
+               msg = "Operation would block";
+               break;
+
+       case WSAEINPROGRESS:
+               msg = "Operation now in progress";
+               break;
+
+       case WSAEALREADY:
+               msg = "Operation already in progress";
+               break;
+
+       case WSAENOTSOCK:
+               msg = "Socket operation on non-socket";
+               break;
+
+       case WSAEDESTADDRREQ:
+               msg = "Destination address required";
+               break;
+
+       case WSAEMSGSIZE:
+               msg = "Message too long";
+               break;
+
+       case WSAEPROTOTYPE:
+               msg = "Protocol wrong type for socket";
+               break;
+
+       case WSAENOPROTOOPT:
+               msg = "Bad protocol option";
+               break;
+
+       case WSAEPROTONOSUPPORT:
+               msg = "Protocol not supported";
+               break;
+
+       case WSAESOCKTNOSUPPORT:
+               msg = "Socket type not supported";
+               break;
+
+       case WSAEOPNOTSUPP:
+               msg = "Operation not supported on socket";
+               break;
+
+       case WSAEPFNOSUPPORT:
+               msg = "Protocol family not supported";
+               break;
+
+       case WSAEAFNOSUPPORT:
+               msg = "Address family not supported";
+               break;
+
+       case WSAEADDRINUSE:
+               msg = "Address already in use";
+               break;
+
+       case WSAEADDRNOTAVAIL:
+               msg = "Can't assign requested address";
+               break;
+
+       case WSAENETDOWN:
+               msg = "Network is down";
+               break;
+
+       case WSAENETUNREACH:
+               msg = "Network is unreachable";
+               break;
+
+       case WSAENETRESET:
+               msg = "Net connection reset";
+               break;
+
+       case WSAECONNABORTED:
+               msg = "Software caused connection abort";
+               break;
+
+       case WSAECONNRESET:
+               msg = "Connection reset by peer";
+               break;
+
+       case WSAENOBUFS:
+               msg = "No buffer space available";
+               break;
+
+       case WSAEISCONN:
+               msg = "Socket is already connected";
+               break;
+
+       case WSAENOTCONN:
+               msg = "Socket is not connected";
+               break;
+
+       case WSAESHUTDOWN:
+               msg = "Can't send after socket shutdown";
+               break;
+
+       case WSAETOOMANYREFS:
+               msg = "Too many references: can't splice";
+               break;
+
+       case WSAETIMEDOUT:
+               msg = "Connection timed out";
+               break;
+
+       case WSAECONNREFUSED:
+               msg = "Connection refused";
+               break;
+
+       case WSAELOOP:
+               msg = "Too many levels of symbolic links";
+               break;
+
+       case WSAENAMETOOLONG:
+               msg = "File name too long";
+               break;
+
+       case WSAEHOSTDOWN:
+               msg = "Host is down";
+               break;
+
+       case WSAEHOSTUNREACH:
+               msg = "No route to host";
+               break;
+
+       case WSAENOTEMPTY:
+               msg = "Directory not empty";
+               break;
+
+       case WSAEPROCLIM:
+               msg = "Too many processes";
+               break;
+
+       case WSAEUSERS:
+               msg = "Too many users";
+               break;
+
+       case WSAEDQUOT:
+               msg = "Disc quota exceeded";
+               break;
+
+       case WSAESTALE:
+               msg = "Stale NFS file handle";
+               break;
+
+       case WSAEREMOTE:
+               msg = "Too many levels of remote in path";
+               break;
+
+       case WSASYSNOTREADY:
+               msg = "Network system is unavailable";
+               break;
+
+       case WSAVERNOTSUPPORTED:
+               msg = "Winsock version out of range";
+               break;
+
+       case WSANOTINITIALISED:
+               msg = "WSAStartup not yet called";
+               break;
+
+       case WSAEDISCON:
+               msg = "Graceful shutdown in progress";
+               break;
+/*
+       case WSAHOST_NOT_FOUND:
+               msg = "Host not found";
+               break;
+
+       case WSANO_DATA:
+               msg = "No host data of that type was found";
+               break;
+*/
+       default:
+               msg = NULL;
+               break;
+       }
+       return (msg);
+}
+
+/*
+ * These error messages are more informative about CryptAPI Errors than the
+ * standard error messages
+ */
+
+char *
+GetCryptErrorMessage(int errval) {
+       char *msg;
+
+       switch (errval) {
+
+       case NTE_BAD_FLAGS:
+               msg = "The dwFlags parameter has an illegal value.";
+               break;
+       case NTE_BAD_KEYSET:
+               msg = "The Registry entry for the key container "
+                       "could not be opened and may not exist.";
+               break;
+       case NTE_BAD_KEYSET_PARAM:
+               msg = "The pszContainer or pszProvider parameter "
+                       "is set to an illegal value.";
+               break;
+       case NTE_BAD_PROV_TYPE:
+               msg = "The value of the dwProvType parameter is out "
+                       "of range. All provider types must be from "
+                       "1 to 999, inclusive.";
+               break;
+       case NTE_BAD_SIGNATURE:
+               msg = "The provider DLL signature did not verify "
+                       "correctly. Either the DLL or the digital "
+                       "signature has been tampered with.";
+               break;
+       case NTE_EXISTS:
+               msg = "The dwFlags parameter is CRYPT_NEWKEYSET, but the key"
+                     " container already exists.";
+               break;
+       case NTE_KEYSET_ENTRY_BAD:
+               msg = "The Registry entry for the pszContainer key container "
+                     "was found (in the HKEY_CURRENT_USER window), but is "
+                     "corrupt. See the section System Administration for "
+                     " etails about CryptoAPI's Registry usage.";
+               break;
+       case NTE_KEYSET_NOT_DEF:
+               msg = "No Registry entry exists in the HKEY_CURRENT_USER "
+                       "window for the key container specified by "
+                       "pszContainer.";
+               break;
+       case NTE_NO_MEMORY:
+               msg = "The CSP ran out of memory during the operation.";
+               break;
+       case NTE_PROV_DLL_NOT_FOUND:
+               msg = "The provider DLL file does not exist or is not on the "
+                     "current path.";
+               break;
+       case NTE_PROV_TYPE_ENTRY_BAD:
+               msg = "The Registry entry for the provider type specified by "
+                     "dwProvType is corrupt. This error may relate to "
+                     "either the user default CSP list or the machine "
+                     "default CSP list. See the section System "
+                     "Administration for details about CryptoAPI's "
+                     "Registry usage.";
+               break;
+       case NTE_PROV_TYPE_NO_MATCH:
+               msg = "The provider type specified by dwProvType does not "
+                     "match the provider type found in the Registry. Note "
+                     "that this error can only occur when pszProvider "
+                     "specifies an actual CSP name.";
+               break;
+       case NTE_PROV_TYPE_NOT_DEF:
+               msg = "No Registry entry exists for the provider type "
+                     "specified by dwProvType.";
+               break;
+       case NTE_PROVIDER_DLL_FAIL:
+               msg = "The provider DLL file could not be loaded, and "
+                     "may not exist. If it exists, then the file is "
+                     "not a valid DLL.";
+               break;
+       case NTE_SIGNATURE_FILE_BAD:
+               msg = "An error occurred while loading the DLL file image, "
+                     "prior to verifying its signature.";
+               break;
+
+       default:
+               msg = NULL;
+               break;
+       }
+       return msg;
+}
+
diff --git a/ports/winnt/libntp/syslog.c b/ports/winnt/libntp/syslog.c
new file mode 100644 (file)
index 0000000..ad1ff93
--- /dev/null
@@ -0,0 +1,194 @@
+/*
+ * Copyright (C) 2001  Internet Software Consortium.
+ *
+ * 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 INTERNET SOFTWARE CONSORTIUM
+ * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL
+ * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL
+ * INTERNET SOFTWARE CONSORTIUM 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.
+ */
+
+/* From BIND 9 lib/isc/win32/: syslog.c,v 1.6 2002/08/03 01:34:14 mayer */
+
+#include <config.h>
+
+#include <stdio.h>
+#include <windows.h>
+#include <string.h>
+#include <stdlib.h>
+#include <syslog.h>
+
+#include <messages.h>
+
+static HANDLE hAppLog = NULL;
+static FILE *log_stream;
+static int debug_level = 0;
+static char progname[51] = "NTP";
+static int logmask = 0;
+
+static struct dsn_c_pvt_sfnt {
+       int val;
+       const char *strval;
+} facilities[] = {
+       { LOG_KERN,             "kern" },
+       { LOG_USER,             "user" },
+       { LOG_MAIL,             "mail" },
+       { LOG_DAEMON,           "daemon" },
+       { LOG_AUTH,             "auth" },
+       { LOG_SYSLOG,           "syslog" },
+       { LOG_LPR,              "lpr" },
+#ifdef LOG_NEWS
+       { LOG_NEWS,             "news" },
+#endif
+#ifdef LOG_UUCP
+       { LOG_UUCP,             "uucp" },
+#endif
+#ifdef LOG_CRON
+       { LOG_CRON,             "cron" },
+#endif
+#ifdef LOG_AUTHPRIV
+       { LOG_AUTHPRIV,         "authpriv" },
+#endif
+#ifdef LOG_FTP
+       { LOG_FTP,              "ftp" },
+#endif
+       { LOG_LOCAL0,           "local0"},
+       { LOG_LOCAL1,           "local1"},
+       { LOG_LOCAL2,           "local2"},
+       { LOG_LOCAL3,           "local3"},
+       { LOG_LOCAL4,           "local4"},
+       { LOG_LOCAL5,           "local5"},
+       { LOG_LOCAL6,           "local6"},
+       { LOG_LOCAL7,           "local7"},
+       { 0,                    NULL }
+};
+
+#if 0
+BOOL
+isc_syslog_facilityfromstring(const char *str, int *facilityp) {
+       int i;
+
+       REQUIRE(str != NULL);
+       REQUIRE(facilityp != NULL);
+
+       for (i = 0 ; facilities[i].strval != NULL ; i++) {
+               if (strcasecmp(facilities[i].strval, str) == 0) {
+                       *facilityp = facilities[i].val;
+                       return (TRUE);
+               }
+       }
+       return (FALSE);
+}
+#endif
+/*
+ * Log to the NT Event Log
+ */
+void
+syslog(int level, const char *fmt, ...) {
+       va_list ap;
+       char buf[1024];
+       char *str[1];
+
+       str[0] = buf;
+
+       va_start(ap, fmt);
+       vsprintf(buf, fmt, ap);
+       va_end(ap);
+
+       /* Make sure that the channel is open to write the event */
+       if (hAppLog == NULL) {
+               openlog(progname, LOG_PID);
+       }
+       switch (level) {
+               case LOG_INFO:
+               case LOG_NOTICE:
+               case LOG_DEBUG:
+                       ReportEvent(hAppLog, EVENTLOG_INFORMATION_TYPE, 0,
+                                   NTP_INFO, NULL, 1, 0, str, NULL);
+                       break;
+               case LOG_WARNING:
+                       ReportEvent(hAppLog, EVENTLOG_WARNING_TYPE, 0,
+                                   NTP_WARNING, NULL, 1, 0, str, NULL);
+                       break;
+               default:
+                       ReportEvent(hAppLog, EVENTLOG_ERROR_TYPE, 0,
+                                   NTP_ERROR, NULL, 1, 0, str, NULL);
+                       break;
+               }
+}
+
+/*
+ * Initialize event logging
+ */
+void
+openlog(const char *name, int flags, ...) {
+       /* Get a handle to the Application event log */
+       hAppLog = RegisterEventSource(NULL, progname);
+       strcpy(progname, name);
+}
+
+/*
+ * Close the Handle to the application Event Log
+ * We don't care whether or not we succeeded so ignore return values
+ * In fact if we failed then we would have nowhere to put the message
+ */
+void
+closelog() {
+       DeregisterEventSource(hAppLog);
+}
+
+/*
+ * Keep event logging synced with the current debug level
+ */
+void
+ModifyLogLevel(int level) {
+       debug_level = level;    
+}
+/*
+ * Set the log priority mask to the given value.
+ * Return the previous priority mask
+ * Note that this setting is ignored in Win32
+ */
+int
+setlogmask(int maskpri) {
+       int temp = logmask;
+       logmask = maskpri;
+       return (temp);
+}
+
+/*
+ * Initialize logging for the port section of libbind.
+ * Piggyback onto stream given.
+ */
+void
+InitNTLogging(FILE *stream, int debug) {
+       log_stream = stream;
+       ModifyLogLevel(debug);
+}
+/*
+ * This function is for reporting errors to the application
+ * event log in case the regular syslog is not available
+ * mainly during startup. It should not be used under normal
+ * circumstances.
+ */
+void
+NTReportError(const char *name, const char *str) {
+       HANDLE hNTAppLog = NULL;
+       const char *buf[1];
+
+       buf[0] = str;
+
+       hNTAppLog = RegisterEventSource(NULL, name);
+
+       ReportEvent(hNTAppLog, EVENTLOG_ERROR_TYPE, 0,
+                   NTP_ERROR, NULL, 1, 0, buf, NULL);
+
+       DeregisterEventSource(hNTAppLog);
+}
\ No newline at end of file
diff --git a/ports/winnt/libntp/transmitbuff.c b/ports/winnt/libntp/transmitbuff.c
new file mode 100644 (file)
index 0000000..5d2679c
--- /dev/null
@@ -0,0 +1,135 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include "ntp_machine.h"
+#include "ntp_fp.h"
+#include "ntp_stdlib.h"
+#include "ntp_syslog.h"
+
+#include <isc/list.h>
+#include "transmitbuff.h"
+
+/*
+ * transmitbuf memory management
+ */
+#define TRANSMIT_INIT          10      /* 10 buffers initially */
+#define TRANSMIT_LOWAT          3      /* when we're down to three buffers get more */
+#define TRANSMIT_INC            5      /* get 5 more at a time */
+#define TRANSMIT_TOOMANY       40      /* this is way too many buffers */
+
+/*
+ * Memory allocation
+ */
+static volatile u_long full_transmitbufs = 0;  /* number of transmitbufs on fulllist */
+static volatile u_long free_transmitbufs = 0;  /* number of transmitbufs on freelist */
+
+ISC_LIST(transmitbuf_t)        free_transmit_list;     /* Currently used transmit buffers */
+ISC_LIST(transmitbuf_t)        full_transmit_list;     /* Currently used transmit buffers */
+
+static u_long total_transmitbufs = 0;          /* total transmitbufs currently in use */
+static u_long lowater_additions = 0;           /* number of times we have added memory */
+
+static CRITICAL_SECTION TransmitLock;
+# define LOCK(lock)    EnterCriticalSection(lock)
+# define UNLOCK(lock)  LeaveCriticalSection(lock)
+
+static void 
+initialise_buffer(transmitbuf *buff)
+{
+       memset((char *) buff, 0, sizeof(transmitbuf));
+
+       buff->wsabuf.len = 0;
+       buff->wsabuf.buf = (char *) &buff->pkt;
+}
+
+static void
+add_buffer_to_freelist(transmitbuf *tb)
+{
+       ISC_LIST_APPEND(free_transmit_list, tb, link);
+       free_transmitbufs++;
+}
+
+static void
+create_buffers(int nbufs)
+{
+       transmitbuf_t *buf;
+       int i;
+
+       buf = (transmitbuf_t *) emalloc(nbufs*sizeof(transmitbuf_t));
+       for (i = 0; i < nbufs; i++)
+       {
+               initialise_buffer(buf);
+               add_buffer_to_freelist(buf);
+               total_transmitbufs++;
+               buf++;
+       }
+
+       lowater_additions++;
+}
+
+extern void
+init_transmitbuff(void)
+{
+       /*
+        * Init buffer free list and stat counters
+        */
+       ISC_LIST_INIT(full_transmit_list);
+       ISC_LIST_INIT(free_transmit_list);
+       free_transmitbufs = total_transmitbufs = 0;
+       full_transmitbufs = lowater_additions = 0;
+       create_buffers(TRANSMIT_INIT);
+
+       InitializeCriticalSection(&TransmitLock);
+}
+
+static void
+delete_buffer_from_full_list(transmitbuf_t *tb) {
+
+       transmitbuf_t *next = NULL;
+       transmitbuf_t *lbuf = ISC_LIST_HEAD(full_transmit_list);
+
+       while (lbuf != NULL) {
+               next = ISC_LIST_NEXT(lbuf, link);
+               if (lbuf == tb) {
+                       ISC_LIST_DEQUEUE(full_transmit_list, lbuf, link);
+                       break;
+               }
+               else
+                       lbuf = next;
+       }
+       full_transmitbufs--;
+}
+
+extern void
+free_transmit_buffer(transmitbuf_t *rb)
+{
+       LOCK(&TransmitLock);
+       delete_buffer_from_full_list(rb);
+       add_buffer_to_freelist(rb);
+       UNLOCK(&TransmitLock);
+}
+
+
+extern transmitbuf *
+get_free_transmit_buffer(void)
+{
+
+       transmitbuf_t * buffer = NULL;
+       LOCK(&TransmitLock);
+       if (free_transmitbufs <= 0) {
+               create_buffers(TRANSMIT_INC);
+       }
+       buffer = ISC_LIST_HEAD(free_transmit_list);
+       if (buffer != NULL)
+       {
+               ISC_LIST_DEQUEUE(free_transmit_list, buffer, link);
+               free_transmitbufs--;
+               ISC_LIST_APPEND(full_transmit_list, buffer, link);
+               full_transmitbufs++;
+       }
+       UNLOCK(&TransmitLock);
+       return (buffer);
+}
+
diff --git a/ports/winnt/libntp/util_clockstuff.c b/ports/winnt/libntp/util_clockstuff.c
new file mode 100644 (file)
index 0000000..b6c593a
--- /dev/null
@@ -0,0 +1,33 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "clockstuff.h"
+
+DWORD units_per_tick = 0;
+DOUBLE ppm_per_adjust_unit = 0.0; /* to satisfy libntp */
+
+int
+gettimeofday(
+       struct timeval *tv
+       )
+{
+       /*  Use the system time (roughly synchronised to the tick, and
+        *  extrapolated using the system performance counter.
+        */
+
+       FILETIME StartTime;
+       ULONGLONG Time;
+
+       GetSystemTimeAsFileTime(&StartTime);
+       Time = (((ULONGLONG) StartTime.dwHighDateTime) << 32) + 
+               (ULONGLONG) StartTime.dwLowDateTime;
+
+       /* Convert the hecto-nano second time to tv format
+        */
+       Time -= FILETIME_1970;
+       tv->tv_sec = (LONG) ( Time / 10000000ui64);
+       tv->tv_usec = (LONG) (( Time % 10000000ui64) / 10);
+
+       return 0;
+}
diff --git a/ports/winnt/ntp-keygen/ntpkeygen.dsp b/ports/winnt/ntp-keygen/ntpkeygen.dsp
new file mode 100644 (file)
index 0000000..2d6bdb1
--- /dev/null
@@ -0,0 +1,158 @@
+# Microsoft Developer Studio Project File - Name="ntpkeygen" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
+\r
+CFG=ntpkeygen - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntpkeygen.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntpkeygen.mak" CFG="ntpkeygen - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "ntpkeygen - Win32 Release" (based on "Win32 (x86) Console Application")\r
+!MESSAGE "ntpkeygen - Win32 Debug" (based on "Win32 (x86) Console Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""$/ntp/dev/ports/winnt/ntpkeygen", OWBAAAAA"\r
+# PROP Scc_LocalPath "."\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "ntpkeygen - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD CPP /nologo /MD /W4 /GX /O2 /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /I "..\..\..\libopts" /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /YX /FD /c\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib $(OPENSSL)\out32dll\libeay32.lib   ..\libntp\Release\libntp.lib /nologo /subsystem:console /machine:I386 /out:"../bin/Release/ntp-keygen.exe"\r
+\r
+!ELSEIF  "$(CFG)" == "ntpkeygen - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
+# ADD CPP /nologo /MDd /W4 /Gm /GX /ZI /Od /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /I "..\..\..\libopts" /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /YX /FD /GZ /c\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib $(OPENSSL)\out32dll\libeay32.lib  ..\libntp\Debug\libntp.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin/Debug/ntp-keygen.exe" /pdbtype:sept\r
+# SUBTRACT LINK32 /pdb:none\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "ntpkeygen - Win32 Release"\r
+# Name "ntpkeygen - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\getopt.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE="..\..\..\util\ntp-keygen-opts.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE="..\..\..\util\ntp-keygen.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\ntp_random.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libntp\randfile.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libntp\util_clockstuff.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\version.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# End Group\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\configure\r
+\r
+!IF  "$(CFG)" == "ntpkeygen - Win32 Release"\r
+\r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntpkeygen \r
+       \r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "ntpkeygen - Win32 Debug"\r
+\r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntpkeygen \r
+       \r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/ports/winnt/ntp-keygen/ntpkeygen.vcproj b/ports/winnt/ntp-keygen/ntpkeygen.vcproj
new file mode 100644 (file)
index 0000000..892d13a
--- /dev/null
@@ -0,0 +1,419 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="ntp-keygen"
+       ProjectGUID="{C88C1FBF-59D2-447F-BF57-0BCA8889028F}"
+       RootNamespace="ntp-keygen"
+       TargetFrameworkVersion="0"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory=".\Debug"
+                       IntermediateDirectory=".\Debug"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       DeleteExtensionsOnClean="version.c,*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Debug/ntpkeygen.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               WholeProgramOptimization="true"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\include,$(OPENSSL)\inc32,..\..\..\libopts"
+                               PreprocessorDefinitions="_DEBUG;_CONSOLE;WIN32;__STDC__;SYS_WINNT;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"
+                               MinimalRebuild="true"
+                               ExceptionHandling="0"
+                               BasicRuntimeChecks="3"
+                               SmallerTypeCheck="true"
+                               RuntimeLibrary="1"
+                               PrecompiledHeaderFile=".\Debug/ntpkeygen.pch"
+                               AssemblerListingLocation=".\Debug/"
+                               ObjectFile=".\Debug/"
+                               ProgramDataBaseFileName="..\bin\Debug\ntp-keygen-vc90"
+                               BrowseInformation="1"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib $(OPENSSL)\lib\vc\libeay32MDd.lib"
+                               OutputFile="../bin/Debug/ntp-keygen.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Debug\ntp-keygen.pdb"
+                               SubSystem="1"
+                               LinkTimeCodeGeneration="1"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Debug/ntpkeygen.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory=".\Release"
+                       IntermediateDirectory=".\Release"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       DeleteExtensionsOnClean="version.c,*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Release/ntpkeygen.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               InlineFunctionExpansion="1"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\include,$(OPENSSL)\inc32,..\..\..\libopts"
+                               PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32;__STDC__;SYS_WINNT;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"
+                               StringPooling="true"
+                               RuntimeLibrary="0"
+                               EnableFunctionLevelLinking="true"
+                               PrecompiledHeaderFile=".\Release/ntpkeygen.pch"
+                               AssemblerListingLocation=".\Release/"
+                               ObjectFile=".\Release/"
+                               ProgramDataBaseFileName="..\bin\Release\ntp-keygen-vc90"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib $(OPENSSL)\lib\vc\libeay32MD.lib ..\libntp\Release\libntp.lib"
+                               OutputFile="../bin/Release/ntp-keygen.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Release\ntp-keygen.pdb"
+                               SubSystem="1"
+                               LinkTimeCodeGeneration="0"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Release/ntpkeygen.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+                       >
+                       <File
+                               RelativePath="..\..\..\libntp\getopt.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\util\ntp-keygen-opts.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               WarningLevel="3"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               WarningLevel="3"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\util\ntp-keygen.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\ntp_random.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libntp\randfile.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libntp\util_clockstuff.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="version.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl"
+                       >
+                       <File
+                               RelativePath="..\include\config.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+                       >
+               </Filter>
+               <File
+                       RelativePath="..\..\..\configure"
+                       >
+                       <FileConfiguration
+                               Name="Debug|Win32"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpkeygen&#x0D;&#x0A;"
+                                       Outputs="$(ProjectDir)version.c"
+                               />
+                       </FileConfiguration>
+                       <FileConfiguration
+                               Name="Release|Win32"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpkeygen&#x0D;&#x0A;"
+                                       Outputs="$(ProjectDir)version.c"
+                               />
+                       </FileConfiguration>
+               </File>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/ports/winnt/ntp.dsw b/ports/winnt/ntp.dsw
new file mode 100644 (file)
index 0000000..2f819e6
--- /dev/null
@@ -0,0 +1,113 @@
+Microsoft Developer Studio Workspace File, Format Version 6.00\r
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!\r
+\r
+###############################################################################\r
+\r
+Project: "instsrv"=".\instsrv\Instsrv.dsp" - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+}}}\r
+\r
+###############################################################################\r
+\r
+Project: "libntp"=".\libntp\libntp.dsp" - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+}}}\r
+\r
+###############################################################################\r
+\r
+Project: "ntpd"=".\ntpd\ntpd.dsp" - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+    Begin Project Dependency\r
+    Project_Dep_Name libntp\r
+    End Project Dependency\r
+}}}\r
+\r
+###############################################################################\r
+\r
+Project: "ntpdate"=".\ntpdate\ntpdate.dsp" - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+    Begin Project Dependency\r
+    Project_Dep_Name libntp\r
+    End Project Dependency\r
+}}}\r
+\r
+###############################################################################\r
+\r
+Project: "ntpdc"=".\ntpdc\ntpdc.dsp" - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+    Begin Project Dependency\r
+    Project_Dep_Name libntp\r
+    End Project Dependency\r
+}}}\r
+\r
+###############################################################################\r
+\r
+Project: "ntpkeygen"=".\ntp-keygen\ntpkeygen.dsp" - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+}}}\r
+\r
+###############################################################################\r
+\r
+Project: "ntpq"=".\ntpq\ntpq.dsp" - Package Owner=<4>\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<4>\r
+{{{\r
+    Begin Project Dependency\r
+    Project_Dep_Name libntp\r
+    End Project Dependency\r
+}}}\r
+\r
+###############################################################################\r
+\r
+Global:\r
+\r
+Package=<5>\r
+{{{\r
+}}}\r
+\r
+Package=<3>\r
+{{{\r
+}}}\r
+\r
+###############################################################################\r
+\r
diff --git a/ports/winnt/ntp.sln b/ports/winnt/ntp.sln
new file mode 100644 (file)
index 0000000..f519adb
--- /dev/null
@@ -0,0 +1,71 @@
+
+Microsoft Visual Studio Solution File, Format Version 10.00
+# Visual C++ Express 2008
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntpd", "ntpd\ntpd.vcproj", "{CB61F8BF-9637-495C-9087-E8664B400CE0}"
+       ProjectSection(ProjectDependencies) = postProject
+               {400FBFCB-462E-40D0-B06B-3B74E3FFFD00} = {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}
+       EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "instsrv", "instsrv\Instsrv.vcproj", "{C3534C4D-6DF1-498E-9904-4337878A1515}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libntp", "libntp\libntp.vcproj", "{400FBFCB-462E-40D0-B06B-3B74E3FFFD00}"
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntpdate", "ntpdate\ntpdate.vcproj", "{2789A62E-3F46-44F1-AAF0-816CD23C2911}"
+       ProjectSection(ProjectDependencies) = postProject
+               {400FBFCB-462E-40D0-B06B-3B74E3FFFD00} = {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}
+       EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntpdc", "ntpdc\ntpdc.vcproj", "{8011C820-B3D5-4034-86EA-FFC30AE6764B}"
+       ProjectSection(ProjectDependencies) = postProject
+               {400FBFCB-462E-40D0-B06B-3B74E3FFFD00} = {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}
+       EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntpkeygen", "ntp-keygen\ntpkeygen.vcproj", "{C88C1FBF-59D2-447F-BF57-0BCA8889028F}"
+       ProjectSection(ProjectDependencies) = postProject
+               {400FBFCB-462E-40D0-B06B-3B74E3FFFD00} = {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}
+       EndProjectSection
+EndProject
+Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "ntpq", "ntpq\ntpq.vcproj", "{6A92BF14-8931-48B1-A571-DEBE9F190616}"
+       ProjectSection(ProjectDependencies) = postProject
+               {400FBFCB-462E-40D0-B06B-3B74E3FFFD00} = {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}
+       EndProjectSection
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Win32 = Debug|Win32
+               Release|Win32 = Release|Win32
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {C3534C4D-6DF1-498E-9904-4337878A1515}.Debug|Win32.ActiveCfg = Debug|Win32
+               {C3534C4D-6DF1-498E-9904-4337878A1515}.Debug|Win32.Build.0 = Debug|Win32
+               {C3534C4D-6DF1-498E-9904-4337878A1515}.Release|Win32.ActiveCfg = Release|Win32
+               {C3534C4D-6DF1-498E-9904-4337878A1515}.Release|Win32.Build.0 = Release|Win32
+               {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}.Debug|Win32.ActiveCfg = Debug|Win32
+               {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}.Debug|Win32.Build.0 = Debug|Win32
+               {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}.Release|Win32.ActiveCfg = Release|Win32
+               {400FBFCB-462E-40D0-B06B-3B74E3FFFD00}.Release|Win32.Build.0 = Release|Win32
+               {CB61F8BF-9637-495C-9087-E8664B400CE0}.Debug|Win32.ActiveCfg = Debug|Win32
+               {CB61F8BF-9637-495C-9087-E8664B400CE0}.Debug|Win32.Build.0 = Debug|Win32
+               {CB61F8BF-9637-495C-9087-E8664B400CE0}.Release|Win32.ActiveCfg = Release|Win32
+               {CB61F8BF-9637-495C-9087-E8664B400CE0}.Release|Win32.Build.0 = Release|Win32
+               {2789A62E-3F46-44F1-AAF0-816CD23C2911}.Debug|Win32.ActiveCfg = Debug|Win32
+               {2789A62E-3F46-44F1-AAF0-816CD23C2911}.Debug|Win32.Build.0 = Debug|Win32
+               {2789A62E-3F46-44F1-AAF0-816CD23C2911}.Release|Win32.ActiveCfg = Release|Win32
+               {2789A62E-3F46-44F1-AAF0-816CD23C2911}.Release|Win32.Build.0 = Release|Win32
+               {8011C820-B3D5-4034-86EA-FFC30AE6764B}.Debug|Win32.ActiveCfg = Debug|Win32
+               {8011C820-B3D5-4034-86EA-FFC30AE6764B}.Debug|Win32.Build.0 = Debug|Win32
+               {8011C820-B3D5-4034-86EA-FFC30AE6764B}.Release|Win32.ActiveCfg = Release|Win32
+               {8011C820-B3D5-4034-86EA-FFC30AE6764B}.Release|Win32.Build.0 = Release|Win32
+               {C88C1FBF-59D2-447F-BF57-0BCA8889028F}.Debug|Win32.ActiveCfg = Debug|Win32
+               {C88C1FBF-59D2-447F-BF57-0BCA8889028F}.Debug|Win32.Build.0 = Debug|Win32
+               {C88C1FBF-59D2-447F-BF57-0BCA8889028F}.Release|Win32.ActiveCfg = Release|Win32
+               {C88C1FBF-59D2-447F-BF57-0BCA8889028F}.Release|Win32.Build.0 = Release|Win32
+               {6A92BF14-8931-48B1-A571-DEBE9F190616}.Debug|Win32.ActiveCfg = Debug|Win32
+               {6A92BF14-8931-48B1-A571-DEBE9F190616}.Debug|Win32.Build.0 = Debug|Win32
+               {6A92BF14-8931-48B1-A571-DEBE9F190616}.Release|Win32.ActiveCfg = Release|Win32
+               {6A92BF14-8931-48B1-A571-DEBE9F190616}.Release|Win32.Build.0 = Release|Win32
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+EndGlobal
diff --git a/ports/winnt/ntpd/hopf_PCI_io.c b/ports/winnt/ntpd/hopf_PCI_io.c
new file mode 100644 (file)
index 0000000..c50088b
--- /dev/null
@@ -0,0 +1,290 @@
+/* 
+ * hopf_PCI_io.c
+ * Read data from a hopf PCI clock using the ATLSoft WinNT driver.
+ *
+ * Date: 21.03.2000 Revision: 01.10 
+ *
+ * Copyright (C) 1999, 2000 by Bernd Altmeier altmeier@ATLSoft.de
+ * 
+ */
+
+/*
+ * Ignore nonstandard extension warning.
+ * This happens when including winioctl.h
+ */
+#pragma warning( disable : 4201)
+#define _FILESYSTEMFSCTL_
+
+#include <config.h>
+#include <windows.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <winioctl.h>
+#include "hopf_PCI_io.h"
+
+#include <stddef.h>
+
+#define ATL_PASSTHROUGH_READ_TOSIZE    3*sizeof(ULONG)         
+#define ATL_PASSTHROUGH_READ_FROMSIZE  0                               
+#define IOCTL_ATLSOFT_PASSTHROUGH_READ CTL_CODE(       \
+                                               FILE_DEVICE_UNKNOWN,    \
+                                               0x805,                  \
+                                               METHOD_BUFFERED,        \
+                                               FILE_ANY_ACCESS)
+
+
+HANDLE hDevice = NULL; // this is the handle to the PCI Device
+
+HANDLE                         hRdEvent;
+OVERLAPPED                     Rdoverlapped;
+OVERLAPPED                     *pRdOverlapped;
+
+ULONG                          iobuffer[256];
+DWORD                          cbReturned;
+BOOL                           HaveBoard = FALSE; 
+struct{
+       ULONG   region;
+       ULONG   offset;
+       ULONG   count;
+       }io_params;
+
+
+BOOL OpenHopfDevice()
+{
+               OSVERSIONINFO                   VersionInfo;
+               ULONG                                   deviceNumber;
+               CHAR                                    deviceName[255];
+                               
+               VersionInfo.dwOSVersionInfoSize=sizeof(OSVERSIONINFO);
+               GetVersionEx(&VersionInfo);
+               switch(VersionInfo.dwPlatformId)
+               {
+                       case VER_PLATFORM_WIN32_WINDOWS:        // Win95/98
+                               return(FALSE);  //      "NTP does not support Win 95-98."
+                       break;
+
+                       case VER_PLATFORM_WIN32_NT:     // WinNT
+                               deviceNumber=0; 
+                               sprintf(deviceName,"\\\\.\\hclk6039%d",deviceNumber+1);
+                               hDevice=CreateFile(
+                                       deviceName,
+                                       GENERIC_WRITE|GENERIC_READ,                     
+                                       FILE_SHARE_WRITE|FILE_SHARE_READ,       
+                                       NULL,                                                           
+                                       OPEN_EXISTING,                                          
+                                       FILE_FLAG_DELETE_ON_CLOSE | FILE_FLAG_OVERLAPPED,
+                                       NULL);
+                       break;
+
+                       default:
+                               hDevice=INVALID_HANDLE_VALUE;
+                       break;
+
+               } // end switch
+
+               if ( hDevice == INVALID_HANDLE_VALUE ) // the system didn't return a handle
+               {
+                       return(FALSE);  //"A handle to the driver could not be obtained properly"
+               }
+
+                       hRdEvent=CreateEvent(NULL,      // an event to be used for async transfers
+                                                               TRUE,   
+                                                               FALSE,  
+                                                               NULL);  
+
+                       if ( hRdEvent == INVALID_HANDLE_VALUE ) 
+                               return(FALSE);  // the system didn't return a handle
+
+                       pRdOverlapped=&Rdoverlapped;
+                       pRdOverlapped->hEvent=hRdEvent;
+
+       HaveBoard = TRUE; // board installed and we have access
+
+       return TRUE;
+} // end of OpenHopfDevice()
+
+
+BOOL  CloseHopfDevice(){
+
+       CloseHandle(hRdEvent);// When done, close the handle to the driver
+       if (CloseHandle(hDevice)==TRUE) // unlink the driver using a CloseHandle call
+    {
+               return TRUE;
+    }
+       return FALSE; // "The driver handle could not be unlinked properly"
+
+} // end of CloseHopfDevice()
+
+
+void ReadHopfDevice(){
+
+    if (HaveBoard){
+       DeviceIoControl(hDevice, IOCTL_ATLSOFT_PASSTHROUGH_READ, &io_params,ATL_PASSTHROUGH_READ_TOSIZE,
+               iobuffer,ATL_PASSTHROUGH_READ_FROMSIZE+io_params.count*sizeof(ULONG),&cbReturned, pRdOverlapped);
+       }
+}
+
+
+
+
+void GetHardwareData(LPDWORD Data32,WORD Ofs)
+{
+       io_params.region = 1;
+       io_params.offset = Ofs;
+       io_params.count =1;
+       ReadHopfDevice();
+       *Data32 = iobuffer[0];
+    return;
+}
+
+
+void GetHopfTime(LPHOPFTIME Data,DWORD Offset)
+{
+       io_params.region = 1;
+       io_params.offset = Offset;
+       io_params.count =4;
+
+       ReadHopfDevice();
+
+       Data->wHour = 0;
+       Data->wMinute = 0;
+       Data->wSecond = 0;
+       while (iobuffer[0] >= (60 * 60 * 1000)) {
+               iobuffer[0] = iobuffer[0] - 60*60 *1000;
+               Data->wHour++;
+               }
+       while (iobuffer[0] >= (60 * 1000)) {
+               iobuffer[0] = iobuffer[0] - 60 *1000;
+               Data->wMinute++;
+               }
+       while (iobuffer[0] >= (1000)) {
+               iobuffer[0] = iobuffer[0] - 1000;
+               Data->wSecond++;
+               }
+       Data->wMilliseconds = LOWORD(iobuffer[0]);
+       Data->wDay = HIBYTE(HIWORD(iobuffer[1]));
+       Data->wMonth = LOBYTE(HIWORD(iobuffer[1]));
+       Data->wYear = LOWORD(iobuffer[1]);
+       Data->wDayOfWeek = HIBYTE(HIWORD(iobuffer[2]));
+       if (Data->wDayOfWeek == 7) // Dow Korrektur
+               Data->wDayOfWeek = 0;
+       
+       io_params.region = 1;
+       io_params.offset += 0x08;
+       io_params.count =1;
+
+       ReadHopfDevice();
+
+       Data->wStatus = LOBYTE(HIWORD(iobuffer[0]));
+   return;
+}
+
+
+void GetHopfLocalTime(LPHOPFTIME Data)
+{
+       DWORD Offset = 0;
+     GetHopfTime(Data,Offset);
+    return;
+}
+
+
+void GetHopfSystemTime(LPHOPFTIME Data)
+{
+       DWORD Offset = 0x10;
+     GetHopfTime(Data,Offset);
+    return;
+}
+
+
+void  GetSatData(LPSATSTAT Data)
+{
+       io_params.region = 1;
+       io_params.offset = 0xb0;
+       io_params.count =5;
+
+       ReadHopfDevice();
+                               
+       Data->wVisible= HIBYTE(HIWORD(iobuffer[0]));
+       Data->wMode   = LOBYTE(LOWORD(iobuffer[0]));
+       Data->wSat0   = HIBYTE(HIWORD(iobuffer[1]));
+       Data->wRat0   = LOBYTE(HIWORD(iobuffer[1]));
+       Data->wSat1   = HIBYTE(LOWORD(iobuffer[1]));
+       Data->wRat1   = LOBYTE(LOWORD(iobuffer[1]));
+       Data->wSat2   = HIBYTE(HIWORD(iobuffer[2]));
+       Data->wRat2   = LOBYTE(HIWORD(iobuffer[2]));
+       Data->wSat3   = HIBYTE(LOWORD(iobuffer[2]));
+       Data->wRat3   = LOBYTE(LOWORD(iobuffer[2]));
+       Data->wSat4   = HIBYTE(HIWORD(iobuffer[3]));
+       Data->wRat4   = LOBYTE(HIWORD(iobuffer[3]));
+       Data->wSat5   = HIBYTE(LOWORD(iobuffer[3]));
+       Data->wRat5   = LOBYTE(LOWORD(iobuffer[3]));
+       Data->wSat6   = HIBYTE(HIWORD(iobuffer[4]));
+       Data->wRat6   = LOBYTE(HIWORD(iobuffer[4]));
+       Data->wSat7   = HIBYTE(LOWORD(iobuffer[4]));
+       Data->wRat7   = LOBYTE(LOWORD(iobuffer[4]));
+       
+    return;
+}
+
+void GetDiffTime(LPLONG Data)
+{
+       io_params.region = 1;
+       io_params.offset = 0x0c;
+       io_params.count =1;
+
+       ReadHopfDevice();
+
+    *Data = iobuffer[0];
+    return;
+}
+
+void  GetPosition(LPGPSPOS Data){
+       io_params.region = 1;
+       io_params.offset = 0x90; // Positionsdaten Länge
+       io_params.count  = 1;
+
+       ReadHopfDevice();
+
+       Data->wLongitude        = iobuffer[0]; //in Millisekunden
+       io_params.region = 1;
+       io_params.offset = 0xa0; // Positionsdaten Breite
+       io_params.count  = 1;
+
+       ReadHopfDevice();
+
+       Data->wLatitude = iobuffer[0];
+       Data->wAltitude = 0;
+    return;
+}
+
+void  GetHardwareVersion(LPCLOCKVER Data){
+int i;
+       io_params.region = 1;
+       io_params.offset = 0x50;
+       io_params.count =12;
+
+       ReadHopfDevice();
+                               
+       strcpy(Data->cVersion,"");
+       iobuffer[13] =0;
+       for (i=0; i < 13; i++){
+               Data->cVersion[i * 4    ] = HIBYTE(HIWORD(iobuffer[i]));
+               Data->cVersion[i * 4 + 1] = LOBYTE(HIWORD(iobuffer[i]));
+               Data->cVersion[i * 4 + 2] = HIBYTE(LOWORD(iobuffer[i]));
+               Data->cVersion[i * 4 + 3] = LOBYTE(LOWORD(iobuffer[i]));
+       }
+}
+
+void  GetDCFAntenne(LPDCFANTENNE Data){
+       io_params.region = 1;
+       io_params.offset = 0xcc;        //
+       io_params.count = 1;
+
+       ReadHopfDevice();
+       Data->bStatus1  = HIBYTE(HIWORD(iobuffer[0])); // 
+       Data->bStatus   = LOBYTE(HIWORD(iobuffer[0])); //
+       Data->wAntValue  = LOWORD(iobuffer[0]);
+    return;
+}
+
+
diff --git a/ports/winnt/ntpd/nt_clockstuff.c b/ports/winnt/ntpd/nt_clockstuff.c
new file mode 100644 (file)
index 0000000..465e89b
--- /dev/null
@@ -0,0 +1,688 @@
+/* Windows NT Clock Routines
+ *
+ *
+ * Revision History:
+ * $Log$
+ * Revision 1.9  2000/11/19 09:02:12  dietrich
+ * From: Ron Thornton [rthornto@pictel.com]
+ * Sent: Thu 11/16/00 8:51 AM
+ * On Windows 2000 it requires a privilege on the current process token
+ * that is disabled by default on Windows 2000.
+ *
+ * I set the token by adding the following code at the beginning of the
+ * init_winnt_time() function in nt_clockstuff.c.
+ *
+ * Revision 1.8  2000/11/19 08:03:20  dietrich
+ * From: "Colin Dancer" <colin.dancer@pyrochrome.net>
+ * To: <bugs@ntp.org>
+ * Sent: 10 November 2000 12:59
+ * Subject: NT bug in NTP 4.0.99j
+ *
+ * I've found a bug in (and produced a fix for) the NT clock interpolation
+ * code in NTP 4.0.99j.
+ *
+ * The symptoms of the problem are that gettimeofday() function on NT
+ * can be wrong by hundreds of seconds if, while a gettimeofday() call
+ * is being processed, an APC completes after the query of the performance
+ * counter but before the lock is grabbed.  The most obvious fix is to move
+ * the lock to include the querying of the performance counter, but this
+ * could affect the predictability of the timestamp so I have instead
+ * tweaked the code to detect and sidestep the duff calculation.
+ *
+ * I've also found that on a loaded system the execution of the APC can be
+ * delayed, leading to errors of upto 10ms.  There is no easy fix to this,
+ * but I do have code for an alternative interpolation scheme which avoids
+ * the problem on single processor systems. I'm currently integrating this
+ * along with code for deciding which algorithm to use based on whether
+ * the system is SP or MP.
+ *
+ * Created by Sven Dietrich  sven@inter-yacht.com
+ *
+ */
+
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "ntp_stdlib.h"
+#include "clockstuff.h"
+#include "ntservice.h"
+#include "ntp_timer.h"
+#include "ntpd.h"
+
+/*
+ * Include code to possibly modify the MM timer while the service is active. 
+ */
+
+  /*
+   * Whether or not MM timer modifications takes place is still controlled 
+   * by the variable below which is initialized by a default value but 
+   * might be changed depending on a command line switch.
+   */
+  int modify_mm_timer = MM_TIMER_LORES;
+
+  #define MM_TIMER_INTV   1  /* the interval we'd want to set the MM timer to [ms] */
+
+  static UINT wTimerRes;
+  static TIMECAPS tc;
+
+
+extern double sys_residual;    /* residual from previous adjustment */
+
+char szMsgPath[255];
+BOOL init_randfile();
+
+static long last_Adj = 0;
+
+#define LS_CORR_INTV_SECS  2   /* seconds to apply leap second correction */
+#define LS_CORR_INTV   ( (LONGLONG) HECTONANOSECONDS * LS_CORR_INTV_SECS )  
+#define LS_CORR_LIMIT  ( (LONGLONG) HECTONANOSECONDS / 2 )  // half a second
+
+typedef union
+{
+       FILETIME ft;
+       ULONGLONG ull;
+} FT_ULL;
+
+static FT_ULL ls_ft;
+static DWORD ls_time_adjustment;
+static LARGE_INTEGER ls_ref_perf_cnt;
+static LONGLONG ls_elapsed;
+
+static void StartClockThread(void);
+static void StopClockThread(void);
+
+
+static CRITICAL_SECTION TimerCritialSection; /* lock for LastTimerCount & LastTimerTime */
+
+static ULONGLONG RollOverCount = 0;
+static ULONGLONG LastTimerCount = 0;
+static ULONGLONG LastTimerTime = 0;
+
+static HANDLE ClockThreadHandle = NULL;
+static HANDLE TimerThreadExitRequest = NULL;
+
+static DWORD every = 0;
+static DWORD initial_units_per_tick = 0;
+static DWORD lastLowTimer = 0;
+
+ULONGLONG PerfFrequency = 0;
+static DWORD units_per_tick = 0;
+static DOUBLE ppm_per_adjust_unit = 0.0;
+
+/*
+ * Request Multimedia Timer
+ */
+void
+set_mm_timer(int timerres)
+{
+       modify_mm_timer = timerres;
+}
+/*
+ * adj_systime - called once every second to make system time adjustments.
+ * Returns 1 if okay, 0 if trouble.
+ */
+int
+adj_systime(
+       double now
+       )
+{
+       double dtemp;
+       u_char isneg = 0;
+       int rc;
+       long dwTimeAdjustment;
+
+       /*
+        * Add the residual from the previous adjustment to the new
+        * adjustment, bound and round.
+        */
+       dtemp = sys_residual + now;
+       sys_residual = 0;
+       if (dtemp < 0)
+       {
+               isneg = 1;
+               dtemp = -dtemp;
+       }
+
+       if (dtemp > NTP_MAXFREQ)
+               dtemp = NTP_MAXFREQ;
+
+       dtemp = dtemp * 1e6;
+
+       if (isneg)
+               dtemp = -dtemp;
+
+       /* dtemp is in micro seconds. NT uses 100 ns units,
+        * so a unit change in dwTimeAdjustment corresponds
+        * to slewing 10 ppm on a 100 Hz system.
+        * Calculate the number of 100ns units to add,
+        * using OS tick frequency as per suggestion from Harry Pyle,
+        * and leave the remainder in dtemp */
+       dwTimeAdjustment = (DWORD)( dtemp / ppm_per_adjust_unit + (isneg ? -0.5 : 0.5)) ;
+       dtemp += (double) -dwTimeAdjustment * ppm_per_adjust_unit;      
+
+
+  /* If a leap second is pending then determine the UTC time stamp 
+        * of when the insertion must take place */
+       if (leap_next & LEAP_ADDSECOND)  
+       {
+               if ( ls_ft.ull == 0 )  /* time stamp has not yet been computed */
+               {
+                       FT_ULL ft;
+                       SYSTEMTIME st;
+                       int itmp;
+
+                       GetSystemTimeAsFileTime(&ft.ft);   
+                       FileTimeToSystemTime(&ft.ft, &st);
+
+                       /* Accept leap announcement only 1 month in advance,
+                        * for end of March, June, September, or December.
+                        */
+                       if ( ( st.wMonth % 3 ) == 0 )
+                       {
+                               /* The comarison time stamp is computed according 
+                                * to 0:00h UTC of the following day */   
+                               if ( ++st.wMonth > 12 )
+                               {
+                                       st.wMonth -= 12;
+                                       st.wYear++;
+                               }
+                               
+                               st.wDay = 1;
+                               st.wHour = 0;
+                               st.wMinute = 0;
+                               st.wSecond = 0;
+                               st.wMilliseconds = 0;
+
+                               SystemTimeToFileTime(&st, &ls_ft.ft);
+                               msyslog(LOG_INFO, "Detected positive leap second announcement "
+                                                 "for %04d-%02d-%02d %02d:%02d:%02d UTC",
+                                                                                                       st.wYear, st.wMonth, st.wDay,
+                                                 st.wHour, st.wMinute, st.wSecond);
+                       }
+               }
+  }
+
+  /* If the time stamp for the next leap second has been set
+        * then check if the leap second must be handled */
+       if ( ls_ft.ull )
+       {
+               LARGE_INTEGER this_perf_count;
+
+               QueryPerformanceCounter( &this_perf_count );
+
+               if ( ls_time_adjustment == 0 ) /* has not yet been scheduled */
+               {
+                       FT_ULL curr_ft;
+
+                       GetSystemTimeAsFileTime(&curr_ft.ft);   
+                       if ( curr_ft.ull >= ls_ft.ull )
+                       {
+                               ls_time_adjustment = every / LS_CORR_INTV_SECS;
+                               ls_ref_perf_cnt = this_perf_count;
+                               ls_elapsed = 0;
+                               msyslog(LOG_INFO, "Inserting positive leap second.");
+                       }
+               }
+               else  /* leap sec adjustment has been scheduled previously */
+               {
+                       ls_elapsed = ( this_perf_count.QuadPart - ls_ref_perf_cnt.QuadPart ) 
+                                      * HECTONANOSECONDS / PerfFrequency;
+               }
+
+               if ( ls_time_adjustment )  /* leap second adjustment is currently active */
+               {
+                       if ( ls_elapsed > ( LS_CORR_INTV - LS_CORR_LIMIT ) )
+                       {
+                               ls_time_adjustment = 0;  /* leap second adjustment done */
+                               ls_ft.ull = 0;
+                       }
+
+               /* NOTE: While the system time is slewed during the leap second 
+                * the interpolation function which is based on the performance 
+                * counter does not account for the slew.
+                */
+               dwTimeAdjustment -= ls_time_adjustment;
+               }
+       }
+
+
+       /* only adjust the clock if adjustment changes */
+       if (last_Adj != dwTimeAdjustment) {     
+                       last_Adj = dwTimeAdjustment;
+# ifdef DEBUG
+               if (debug > 1)
+                       printf("SetSystemTimeAdjustment( %ld) + (%ld)\n", dwTimeAdjustment, units_per_tick);                    
+# endif
+                       dwTimeAdjustment += units_per_tick;
+                       rc = !SetSystemTimeAdjustment(dwTimeAdjustment, FALSE);
+       }
+       else rc = 0;
+       if (rc)
+       {
+               msyslog(LOG_ERR, "Can't adjust time: %m");
+               return 0;
+       }
+       else {
+               sys_residual = dtemp / 1000000.0;
+       }
+
+#ifdef DEBUG
+       if (debug > 6)
+               printf("adj_systime: adj %.9f -> remaining residual %.9f\n", now, sys_residual);
+#endif
+       return 1;
+}
+
+
+void init_winnt_time(void)
+{
+       BOOL noslew;
+       HANDLE hToken = INVALID_HANDLE_VALUE;
+       TOKEN_PRIVILEGES tkp;
+
+       /*
+        * Make sure the service is initialized
+        * before we do anything else
+        */
+       ntservice_init();
+
+       /* Set the Event-ID message-file name. */
+       if (!GetModuleFileName(NULL, szMsgPath, sizeof(szMsgPath))) 
+       {
+               msyslog(LOG_ERR, "GetModuleFileName(PGM_EXE_FILE) failed: %m\n");
+               exit(1);
+       }
+
+       /* Initialize random file before OpenSSL checks */
+       if(!init_randfile())
+               msyslog(LOG_ERR, "Unable to initialize .rnd file\n");
+
+       /*
+        * Get privileges needed for fiddling with the clock
+        */
+
+         /* get the current process token handle */
+       if (!OpenProcessToken(GetCurrentProcess(),
+            TOKEN_ADJUST_PRIVILEGES | TOKEN_QUERY, &hToken)) 
+       {
+               msyslog(LOG_ERR, "OpenProcessToken failed: %m");
+               exit(-1);
+       }
+         /* get the LUID for system-time privilege. */
+       LookupPrivilegeValue(NULL, SE_SYSTEMTIME_NAME, &tkp.Privileges[0].Luid);
+       tkp.PrivilegeCount = 1;  /* one privilege to set */
+       tkp.Privileges[0].Attributes = SE_PRIVILEGE_ENABLED;
+
+       /* get set-time privilege for this process. */
+       AdjustTokenPrivileges(hToken, FALSE, &tkp, 0,
+               (PTOKEN_PRIVILEGES) NULL, 0);
+
+       /* cannot use return value of AdjustTokenPrivileges. */
+       /* (success does not indicate all privileges were set) */
+       if (GetLastError() != ERROR_SUCCESS) 
+       {
+               msyslog(LOG_ERR, "AdjustTokenPrivileges failed: %m");
+               /* later set time call will probably fail */
+       }
+
+       /* Reset the Clock to a reasonable increment */
+       if (!GetSystemTimeAdjustment(&initial_units_per_tick, &every,&noslew))
+       {
+               msyslog(LOG_ERR, "GetSystemTimeAdjustment failed: %m\n");
+               exit(-1);
+       }
+
+       units_per_tick = initial_units_per_tick;
+
+       /* Calculate the time adjustment resulting from incrementing
+        * units per tick by 1 unit for 1 second */
+       ppm_per_adjust_unit = 1000000.0 / (double) every;
+
+#ifdef DEBUG
+       msyslog(LOG_INFO, "Initial Clock increment %7.1f us",
+                       (float) (units_per_tick / 10));
+       msyslog(LOG_INFO, "Adjustment rate %5.3f ppm/s", ppm_per_adjust_unit);
+#endif
+
+       StartClockThread();
+
+       /* Set up the Console Handler */
+       if (!SetConsoleCtrlHandler(OnConsoleEvent, TRUE))
+       {
+               msyslog(LOG_ERR, "Can't set console control handler: %m");
+       }
+}
+
+
+void reset_winnt_time(void)
+{
+       /* restore the clock frequency back to its original value */
+       if (!SetSystemTimeAdjustment(0, TRUE)) 
+       {
+               msyslog(LOG_ERR, "Failed to reset clock state, SetSystemTimeAdjustment(): %m");
+       }
+       /* read the current system time, and write it back to
+           force CMOS update: */
+      /************ Added back in 2003-01-26 *****************/
+       {
+               SYSTEMTIME st;
+               GetSystemTime(&st);
+               SetSystemTime(&st);
+       }
+}
+
+
+
+int
+gettimeofday(
+       struct timeval *tv
+       )
+{
+       /*  Use the system time (roughly synchronised to the tick, and
+        *  extrapolated using the system performance counter.
+        */
+
+       ULONGLONG Count;
+       LARGE_INTEGER LargeIntNowCount;
+       ULONGLONG Time;
+       ULONGLONG NowCount;
+       ULONGLONG PreCount;                                                  /*FIX*/
+       LONGLONG TicksElapsed;
+       LONG time_adjustment;
+
+       /*  Mark a mark ASAP. The latency to here should
+        *  be reasonably deterministic
+        */
+
+       PreCount = LastTimerCount;                                           /*FIX*/
+
+       if (!QueryPerformanceCounter(&LargeIntNowCount)) {
+               msyslog(LOG_ERR, "QueryPeformanceCounter failed: %m");
+               exit(1);
+       }
+
+       NowCount = LargeIntNowCount.QuadPart;
+
+       /*  Get base time we are going to extrapolate from
+        */     
+       EnterCriticalSection(&TimerCritialSection);
+       Count = LastTimerCount;
+       Time = LastTimerTime;
+       LeaveCriticalSection(&TimerCritialSection);
+
+       /*  Calculate when now is.
+        *
+        *  Result = LastTimerTime +  (NowCount - LastTimerCount) / PerfFrequency
+        */
+
+       if (NowCount >= Count)
+       {
+               TicksElapsed = NowCount - Count; /* linear progression of ticks */
+       }
+       else
+       {
+       /************************************************************************/
+       /* Differentiate between real rollover and the case of taking a         */
+       /* perfcount then the APC coming in.                                    */
+       /************************************************************************/
+               if (Count > PreCount)                                           /*FIX*/
+               {                                                               /*FIX*/
+                       TicksElapsed = 0;                                       /*FIX*/
+               }                                                               /*FIX*/
+               else                                                            /*FIX*/
+               {                                                               /*FIX*/
+                       TicksElapsed = NowCount + (RollOverCount - Count);      /*FIX*/
+               }                                                               /*FIX*/
+       }
+
+       /*  Calculate the new time (in 100's of nano-seconds)
+        */
+       time_adjustment = (long) ((TicksElapsed * HECTONANOSECONDS) / PerfFrequency);
+       Time += time_adjustment;
+
+       /* Convert the hecto-nano second time to tv format
+        */
+       Time -= FILETIME_1970;
+       tv->tv_sec = (LONG) ( Time / 10000000ui64);
+       tv->tv_usec = (LONG) (( Time % 10000000ui64) / 10);
+
+       return 0;
+}
+
+static void CALLBACK
+TimerApcFunction(
+       LPVOID lpArgToCompletionRoutine,
+       DWORD dwTimerLowValue,
+       DWORD dwTimerHighValue
+       )
+{
+       LARGE_INTEGER LargeIntNowCount;
+       (void) lpArgToCompletionRoutine; /* not used */
+
+       if (dwTimerLowValue == lastLowTimer) return;
+       
+       /* Grab the counter first of all */
+       QueryPerformanceCounter(&LargeIntNowCount);
+
+       /* Save this for next time */
+       lastLowTimer = dwTimerLowValue;
+
+       /* Check to see if the counter has rolled. This happens
+          more often on Multi-CPU systems */
+
+       if ((ULONGLONG) LargeIntNowCount.QuadPart < LastTimerCount) {
+               /* Counter Rolled - try and estimate the rollover point using
+                 the nominal counter frequency divided by an estimate of the
+                 OS frequency */
+               RollOverCount = LastTimerCount + PerfFrequency * every /  HECTONANOSECONDS -
+                       (ULONGLONG) LargeIntNowCount.QuadPart;
+#ifdef DEBUG
+               msyslog(LOG_INFO,
+                       "Performance Counter Rollover %I64u:\rLast Timer Count %I64u\rCurrent Count %I64u",
+                               RollOverCount, LastTimerCount, LargeIntNowCount.QuadPart);
+#endif
+       }
+
+       /* Now we can hang out and wait for the critical section to free up;
+          we will get the CPU this timeslice. Meanwhile other tasks can use
+          the last value of LastTimerCount */
+               
+       EnterCriticalSection(&TimerCritialSection);
+       LastTimerCount = (ULONGLONG) LargeIntNowCount.QuadPart;
+       LastTimerTime = ((ULONGLONG) dwTimerHighValue << 32) +
+                        (ULONGLONG) dwTimerLowValue;
+       LeaveCriticalSection(&TimerCritialSection);
+}
+
+
+
+DWORD WINAPI ClockThread(void *arg)
+{
+
+       LARGE_INTEGER DueTime;
+       HANDLE WaitableTimerHandle = CreateWaitableTimer(NULL, FALSE, NULL);
+
+       (void) arg; /* not used */
+
+       if (WaitableTimerHandle != NULL) {
+               DueTime.QuadPart = 0i64;
+               if (SetWaitableTimer(WaitableTimerHandle, &DueTime, 1L /* ms */, TimerApcFunction, &WaitableTimerHandle, FALSE) != NO_ERROR) {
+                       for(;;) {
+                               if (WaitForSingleObjectEx(TimerThreadExitRequest, INFINITE, TRUE) == WAIT_OBJECT_0) {
+                                       break; /* we've been asked to exit */
+                               }
+                       }
+               }
+               CloseHandle(WaitableTimerHandle);
+               WaitableTimerHandle = NULL;
+       }
+       return 0;
+}
+
+
+static void StartClockThread(void)
+{
+       DWORD tid;
+       FILETIME StartTime;
+       LARGE_INTEGER Freq = { 0, 0 };
+       
+       /* get the performance counter freq */
+       if (!QueryPerformanceFrequency(&Freq))
+       {
+               msyslog(LOG_ERR, "QueryPerformanceFrequency failed: %m\n");
+               exit (-1);
+       }
+
+       PerfFrequency = Freq.QuadPart;
+
+
+       if ( modify_mm_timer != 0)
+       {
+               if (timeGetDevCaps( &tc, sizeof( tc ) ) == TIMERR_NOERROR ) 
+               {
+                       wTimerRes = min( max( tc.wPeriodMin, MM_TIMER_INTV ), tc.wPeriodMax );
+
+                       timeBeginPeriod( wTimerRes );
+#ifdef DEBUG
+                       msyslog( LOG_INFO, "MM timer resolution: %u..%u ms, set to %u ms\n",
+                                tc.wPeriodMin, tc.wPeriodMax, wTimerRes );
+#endif
+               }
+               else
+                       msyslog( LOG_ERR, "Failed to get MM timer caps\n" );
+       }
+
+
+       /* init variables with the time now */
+       GetSystemTimeAsFileTime(&StartTime);
+       LastTimerTime = (((ULONGLONG) StartTime.dwHighDateTime) << 32) +
+                         (ULONGLONG) StartTime.dwLowDateTime;
+
+       /* init sync objects */
+       InitializeCriticalSection(&TimerCritialSection);
+       TimerThreadExitRequest = CreateEvent(NULL, FALSE, FALSE, "TimerThreadExitRequest");
+
+       ClockThreadHandle = CreateThread(NULL, 0, ClockThread, NULL, 
+               CREATE_SUSPENDED, &tid);
+
+       if (ClockThreadHandle != NULL) {
+               /* remember the thread priority is only within the process class */
+               if (!SetThreadPriority(ClockThreadHandle, THREAD_PRIORITY_TIME_CRITICAL)) {
+                       DPRINTF(1, ("Error setting thread priority\n"));
+               }
+
+               lock_thread_to_processor(ClockThreadHandle);
+               ResumeThread(ClockThreadHandle);
+
+               lock_thread_to_processor(GetCurrentThread());
+
+               atexit( StopClockThread );
+       }
+}
+
+
+void
+lock_thread_to_processor(HANDLE thread)
+{
+       static  DWORD_PTR       ProcessAffinityMask;
+       static  DWORD_PTR       ThreadAffinityMask;
+       DWORD_PTR               SystemAffinityMask;
+       char                    *cputext;
+       unsigned int            cpu;
+
+       if ( ! ProcessAffinityMask) {
+               /*
+                * Choose which processor to nail the main and clock threads to.
+                * If we have more than one, we simply choose the 2nd.
+                * Randomly choosing from 2 to n would be better, but in
+                * either case with clock and network interrupts more likely
+                * to be serviced by the first procecssor, let's stay away 
+                * from it.  QueryPerformanceCounter is not necessarily
+                * consistent across CPUs, hence the need to nail the two
+                * threads involved in QPC-based interpolation to the same
+                * CPU.
+                */
+
+               GetProcessAffinityMask(
+                       GetCurrentProcess(), 
+                       &ProcessAffinityMask,
+                       &SystemAffinityMask);
+
+               /*
+                * respect NTPD_CPU environment variable if present
+                * for testing.  NTPD_CPU=0 means use all CPUs, 1-64
+                * means lock threads involved in interpolation to
+                * that CPU.  Default to 2nd if more than 1.
+                */
+
+               cpu = 2;
+               cputext = getenv("NTPD_CPU");
+               if (cputext) {
+                       cpu = (unsigned int) atoi(cputext);
+                       cpu = min((8 * sizeof(DWORD_PTR)), cpu);
+               }
+
+               /* 
+                * Clear all bits except the 2nd.  If we have only one proc
+                * that leaves ThreadAffinityMask zeroed and we won't bother
+                * with SetThreadAffinityMask.
+                */
+
+               ThreadAffinityMask = (0 == cpu) ? 0 : (1 << (cpu - 1));
+
+               if (ThreadAffinityMask && 
+                       !(ThreadAffinityMask & ProcessAffinityMask)) {
+
+                       DPRINTF(1, ("Selected CPU %u (mask %x) is outside "
+                                       "process mask %x, using all CPUs.\n",
+                                       cpu, ThreadAffinityMask, 
+                                       ProcessAffinityMask));
+               } else {
+                       DPRINTF(1, ("Wiring to processor %u (0 means all) "
+                                       "affinity mask %x\n",   
+                                       cpu, ThreadAffinityMask));
+               }
+
+               ThreadAffinityMask &= ProcessAffinityMask;
+       }
+
+       if (ThreadAffinityMask && 
+               !SetThreadAffinityMask(thread, ThreadAffinityMask)) {
+               
+               DPRINTF(1, ("Unable to wire thread to mask %x: %s\n", 
+                       ThreadAffinityMask, strerror(GetLastError())));
+       }
+}
+
+
+static void StopClockThread(void)
+{      
+       if ( wTimerRes )  /* if not 0 then the MM timer has been modified at startup */
+       {
+               timeEndPeriod( wTimerRes ); 
+               wTimerRes = 0;
+#ifdef DEBUG
+               msyslog( LOG_INFO, "MM timer set to default\n" );
+#endif
+       }
+
+       if (SetEvent(TimerThreadExitRequest) &&
+           WaitForSingleObject(ClockThreadHandle, 10000L) == 0)
+       {
+               CloseHandle(TimerThreadExitRequest);
+               TimerThreadExitRequest = NULL;
+
+               CloseHandle(ClockThreadHandle);
+               ClockThreadHandle = NULL;
+
+               DeleteCriticalSection(&TimerCritialSection);
+       }
+       else
+       {
+               msyslog(LOG_ERR, "Failed to stop clock thread.");
+               Sleep( 100 );
+       }
+}
diff --git a/ports/winnt/ntpd/ntp_iocompletionport.c b/ports/winnt/ntpd/ntp_iocompletionport.c
new file mode 100644 (file)
index 0000000..d9b3567
--- /dev/null
@@ -0,0 +1,919 @@
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined (HAVE_IO_COMPLETION_PORT)
+
+#include <stddef.h>
+#include <stdio.h>
+#include <process.h>
+#include "ntp_stdlib.h"
+#include "syslog.h"
+#include "ntp_machine.h"
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntpd.h"
+#include "ntp_refclock.h"
+#include "ntp_iocompletionport.h"
+#include "transmitbuff.h"
+#include "ntp_request.h"
+#include "ntp_io.h"
+#include "clockstuff.h"
+
+/*
+ * Request types
+ */
+enum {
+       SOCK_RECV,
+       SOCK_SEND,
+       SERIAL_WAIT,
+       SERIAL_READ,
+       SERIAL_WRITE
+};
+
+
+typedef struct IoCompletionInfo {
+       OVERLAPPED                      overlapped;
+       int                             request_type;
+       union {
+               recvbuf_t               *rbuf;
+               transmitbuf_t           *tbuf;
+       } buff_space;
+} IoCompletionInfo;
+
+#define        recv_buf        buff_space.rbuf
+#define        trans_buf       buff_space.tbuf
+
+
+#if !defined( _W64 )
+  /*
+   * if ULONG_PTR needs to be defined then the build environment
+   * is pure 32 bit Windows. Since ULONG_PTR and DWORD have 
+   * the same size in 32 bit Windows we can safely define
+   * a replacement.
+   */
+  typedef DWORD ULONG_PTR;
+#endif
+
+/*
+ * local function definitions
+ */
+static int QueueSerialWait(struct refclockio *, recvbuf_t *buff, IoCompletionInfo *lpo, BOOL clear_timestamp);
+
+static int OnSocketRecv(ULONG_PTR, IoCompletionInfo *, DWORD, int);
+static int OnSerialWaitComplete(ULONG_PTR, IoCompletionInfo *, DWORD, int);
+static int OnSerialReadComplete(ULONG_PTR, IoCompletionInfo *, DWORD, int);
+static int OnWriteComplete(ULONG_PTR, IoCompletionInfo *, DWORD, int);
+
+/* #define USE_HEAP */
+
+#ifdef USE_HEAP
+static HANDLE hHeapHandle = NULL;
+#endif
+
+static HANDLE hIoCompletionPort = NULL;
+
+static HANDLE WaitableIoEventHandle = NULL;
+static HANDLE WaitableExitEventHandle = NULL;
+
+#ifdef NTPNEEDNAMEDHANDLE
+#define WAITABLEIOEVENTHANDLE "WaitableIoEventHandle"
+#else
+#define WAITABLEIOEVENTHANDLE NULL
+#endif
+
+#define MAXHANDLES 3
+HANDLE WaitHandles[MAXHANDLES] = { NULL, NULL, NULL };
+
+IoCompletionInfo *
+GetHeapAlloc(char *fromfunc)
+{
+       IoCompletionInfo *lpo;
+
+#ifdef USE_HEAP
+       lpo = (IoCompletionInfo *) HeapAlloc(hHeapHandle,
+                            HEAP_ZERO_MEMORY,
+                            sizeof(IoCompletionInfo));
+#else
+       lpo = (IoCompletionInfo *) calloc(1, sizeof(*lpo));
+#endif
+       DPRINTF(3, ("Allocation %d memory for %s, ptr %x\n", sizeof(IoCompletionInfo), fromfunc, lpo));
+
+       return (lpo);
+}
+
+void
+FreeHeap(IoCompletionInfo *lpo, char *fromfunc)
+{
+       DPRINTF(3, ("Freeing memory for %s, ptr %x\n", fromfunc, lpo));
+
+#ifdef USE_HEAP
+       HeapFree(hHeapHandle, 0, lpo);
+#else
+       free(lpo);
+#endif
+}
+
+transmitbuf_t *
+get_trans_buf()
+{
+       transmitbuf_t *tb  = (transmitbuf_t *) emalloc(sizeof(transmitbuf_t));
+       tb->wsabuf.len = 0;
+       tb->wsabuf.buf = (char *) &tb->pkt;
+       return (tb);
+}
+
+void
+free_trans_buf(transmitbuf_t *tb)
+{
+       free(tb);
+}
+
+HANDLE
+get_io_event()
+{
+       return( WaitableIoEventHandle );
+}
+HANDLE
+get_exit_event()
+{
+       return( WaitableExitEventHandle );
+}
+
+/*  This function will add an entry to the I/O completion port
+ *  that will signal the I/O thread to exit (gracefully)
+ */
+static void
+signal_io_completion_port_exit()
+{
+       if (!PostQueuedCompletionStatus(hIoCompletionPort, 0, 0, 0)) {
+               msyslog(LOG_ERR, "Can't request service thread to exit: %m");
+               exit(1);
+       }
+}
+
+static unsigned WINAPI
+iocompletionthread(void *NotUsed)
+{
+       BOOL bSuccess = FALSE;
+       int errstatus = 0;
+       DWORD BytesTransferred = 0;
+       ULONG_PTR Key = 0;
+       IoCompletionInfo * lpo = NULL;
+       u_long time_next_ifscan_after_error = 0;
+
+       /* UNUSED_ARG(NotUsed); */
+
+       /*
+        *      socket and refclock receive call gettimeofday()
+        *      so the I/O thread needs to be on the same 
+        *      processor as the main and timing threads
+        *      to ensure consistent QueryPerformanceCounter()
+        *      results.
+        */
+       lock_thread_to_processor(GetCurrentThread());
+
+       /*      Set the thread priority high enough so I/O will
+        *      preempt normal recv packet processing, but not
+        *      higher than the timer sync thread.
+        */
+       if (!SetThreadPriority(GetCurrentThread(), THREAD_PRIORITY_ABOVE_NORMAL)) {
+               msyslog(LOG_ERR, "Can't set thread priority: %m");
+       }
+
+       while (TRUE) {
+               bSuccess = GetQueuedCompletionStatus(
+                                       hIoCompletionPort, 
+                                       &BytesTransferred, 
+                                       &Key, 
+                                       (LPOVERLAPPED *) &lpo, 
+                                       INFINITE);
+               if (lpo == NULL)
+               {
+                       DPRINTF(2, ("Overlapped IO Thread Exiting\n"));
+                       break; /* fail */
+               }
+               
+               /*
+                * Deal with errors
+                */
+               if (bSuccess)
+                       errstatus = 0;
+               else
+               {
+                       errstatus = GetLastError();
+                       if (BytesTransferred == 0)
+                       {
+                               if (WSA_OPERATION_ABORTED == errstatus) {
+                                       DPRINTF(4, ("Transfer Operation aborted\n"));
+                               } else if (ERROR_UNEXP_NET_ERR == errstatus) {
+                                       /*
+                                        * We get this error when trying to send an the network
+                                        * interface is gone or has lost link.  Rescan interfaces
+                                        * to catch on sooner, but no more than once per minute.
+                                        * Once ntp is able to detect changes without polling
+                                        * this should be unneccessary
+                                        */
+                                       if (time_next_ifscan_after_error < current_time) {
+                                               time_next_ifscan_after_error = current_time + 60;
+                                               timer_interfacetimeout(current_time);
+                                       }
+                                       DPRINTF(4, ("sendto unexpected network error, interface may be down\n"));
+                               }
+                       }
+                       else
+                       {
+                               msyslog(LOG_ERR, "sendto error after %d bytes: %m", BytesTransferred);
+                       }
+               }
+
+               /*
+                * Invoke the appropriate function based on
+                * the value of the request_type
+                */
+               switch(lpo->request_type)
+               {
+               case SERIAL_WAIT:
+                       OnSerialWaitComplete(Key, lpo, BytesTransferred, errstatus);
+                       break;
+               case SERIAL_READ:
+                       OnSerialReadComplete(Key, lpo, BytesTransferred, errstatus);
+                       break;
+               case SOCK_RECV:
+                       OnSocketRecv(Key, lpo, BytesTransferred, errstatus);
+                       break;
+               case SOCK_SEND:
+               case SERIAL_WRITE:
+                       OnWriteComplete(Key, lpo, BytesTransferred, errstatus);
+                       break;
+               default:
+                       DPRINTF(1, ("Unknown request type %d found in completion port\n",
+                                   lpo->request_type));
+                       break;
+               }
+       }
+
+       return 0;
+}
+
+/*  Create/initialise the I/O creation port
+ */
+extern void
+init_io_completion_port(
+       void
+       )
+{
+       unsigned tid;
+       HANDLE thread;
+
+#ifdef USE_HEAP
+       /*
+        * Create a handle to the Heap
+        */
+       hHeapHandle = HeapCreate(0, 20*sizeof(IoCompletionInfo), 0);
+       if (hHeapHandle == NULL)
+       {
+               msyslog(LOG_ERR, "Can't initialize Heap: %m");
+               exit(1);
+       }
+#endif
+
+       /* Create the event used to signal an IO event
+        */
+       WaitableIoEventHandle = CreateEvent(NULL, FALSE, FALSE, WAITABLEIOEVENTHANDLE);
+       if (WaitableIoEventHandle == NULL) {
+               msyslog(LOG_ERR,
+               "Can't create I/O event handle: %m - another process may be running - EXITING");
+               exit(1);
+       }
+       /* Create the event used to signal an exit event
+        */
+       WaitableExitEventHandle = CreateEvent(NULL, FALSE, FALSE, NULL);
+       if (WaitableExitEventHandle == NULL) {
+               msyslog(LOG_ERR,
+               "Can't create exit event handle: %m - EXITING");
+               exit(1);
+       }
+
+       /* Create the IO completion port
+        */
+       hIoCompletionPort = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0);
+       if (hIoCompletionPort == NULL) {
+               msyslog(LOG_ERR, "Can't create I/O completion port: %m");
+               exit(1);
+       }
+
+       /*
+        * Initialize the Wait Handles
+        */
+       WaitHandles[0] = get_io_event();
+       WaitHandles[1] = get_exit_event(); /* exit request */
+       WaitHandles[2] = get_timer_handle();
+
+       /* Have one thread servicing I/O - there were 4, but this would 
+        * somehow cause NTP to stop replying to ntpq requests; TODO
+        */
+       thread = (HANDLE)_beginthreadex(
+               NULL, 
+               0, 
+               iocompletionthread, 
+               NULL, 
+               CREATE_SUSPENDED, 
+               &tid);
+       ResumeThread(thread);
+       CloseHandle(thread);
+}
+       
+
+extern void
+uninit_io_completion_port(
+       void
+       )
+{
+       if (hIoCompletionPort != NULL) {
+               /*  Get each of the service threads to exit
+               */
+               signal_io_completion_port_exit();
+       }
+}
+
+
+static int QueueSerialWait(struct refclockio *rio, recvbuf_t *buff, IoCompletionInfo *lpo, BOOL clear_timestamp)
+{
+       lpo->request_type = SERIAL_WAIT;
+       lpo->recv_buf = buff;
+
+       if (clear_timestamp)
+               memset(&buff->recv_time, 0, sizeof(buff->recv_time));
+
+       buff->fd = _get_osfhandle(rio->fd);
+       if (!WaitCommEvent((HANDLE) buff->fd, (DWORD *)&buff->recv_buffer, (LPOVERLAPPED) lpo)) {
+               if (ERROR_IO_PENDING != GetLastError()) {
+                       msyslog(LOG_ERR, "Can't wait on Refclock: %m");
+                       freerecvbuf(buff);
+                       return 0;
+               }
+       }
+       return 1;
+}
+
+
+static int 
+OnSerialWaitComplete(ULONG_PTR i, IoCompletionInfo *lpo, DWORD Bytes, int errstatus)
+{
+       recvbuf_t *buff;
+       struct refclockio * rio = (struct refclockio *) i;
+       struct peer *pp;
+       l_fp arrival_time;
+       DWORD comm_mask;
+       DWORD modem_status;
+       static const l_fp zero_time = { 0 };
+       DWORD dwBytesReturned;
+       BOOL rc;
+
+       get_systime(&arrival_time);
+
+       /*
+        * Get the recvbuf pointer from the overlapped buffer.
+        */
+       buff = lpo->recv_buf;
+       comm_mask = (*(DWORD *)&buff->recv_buffer);
+#ifdef DEBUG
+               if (errstatus || comm_mask & ~(EV_RXFLAG | EV_RLSD)) {
+                       msyslog(LOG_ERR, "WaitCommEvent returned unexpected mask %x errstatus %d",
+                               comm_mask, errstatus);
+                       exit(-1);
+               }
+#endif
+               if (comm_mask & EV_RLSD) { 
+                       modem_status = 0;
+                       GetCommModemStatus((HANDLE)buff->fd, &modem_status);
+                       if (modem_status & MS_RLSD_ON) {
+                               /*
+                                * Use the timestamp from this PPS CD not
+                                * the later end of line.
+                                */
+                               buff->recv_time = arrival_time;
+                       }
+
+                       if (!(comm_mask & EV_RXFLAG)) {
+                               /*
+                                * if we didn't see an end of line yet
+                                * issue another wait for it.
+                                */
+                               QueueSerialWait(rio, buff, lpo, FALSE);
+                               return 1;
+                       }
+               }
+
+               /*
+                * We've detected the end of line of serial input.
+                * Use this timestamp unless we already have a CD PPS
+                * timestamp in buff->recv_time.
+                */
+               if (memcmp(&buff->recv_time, &zero_time, sizeof buff->recv_time)) {
+                       /*
+                        * We will first see a user PPS timestamp here on either
+                        * the first or second line of text.  Log a one-time
+                        * message while processing the second line.
+                        */
+                       if (1 == rio->recvcount) {
+                               pp = (struct peer *)rio->srcclock;
+                               msyslog(LOG_NOTICE, "Using user-mode PPS timestamp for %s",
+                                       refnumtoa(&pp->srcadr));
+                       }
+               } else {
+                       buff->recv_time = arrival_time;
+               }
+
+               /*
+                * Now that we have a complete line waiting, read it.
+                * There is still a race here, but we're likely to win.
+                */
+
+               lpo->request_type = SERIAL_READ;
+
+               rc = ReadFile(
+                       (HANDLE)buff->fd,
+                       buff->wsabuff.buf,
+                       buff->wsabuff.len,
+                       &buff->wsabuff.len,
+                       (LPOVERLAPPED) lpo);
+
+               if (!rc && ERROR_IO_PENDING != GetLastError()) {
+                       msyslog(LOG_ERR, "Can't read from Refclock: %m");
+                       freerecvbuf(buff);
+                       return 0;
+               }
+
+       return 1;
+}
+
+/* Return 1 on Successful Read */
+static int 
+OnSerialReadComplete(ULONG_PTR i, IoCompletionInfo *lpo, DWORD Bytes, int errstatus)
+{
+       recvbuf_t *buff;
+       struct refclockio * rio = (struct refclockio *) i;
+
+       /*
+        * Get the recvbuf pointer from the overlapped buffer.
+        */
+       buff = lpo->recv_buf;
+
+       /*
+        * ignore 0 bytes read due to timeout's and closure on fd
+        */
+       if (!errstatus && Bytes) {
+               buff->recv_length = (int) Bytes;
+               buff->receiver = rio->clock_recv;
+               buff->dstadr = NULL;
+               buff->recv_srcclock = rio->srcclock;
+               packets_received++;
+               /*
+                * Eat the first line of input as it's possibly
+                * partial and if a PPS is present, it may not 
+                * have fired since the port was opened.
+                */
+               if (rio->recvcount++) {
+                       add_full_recv_buffer(buff);
+                       /*
+                        * Now signal we have something to process
+                        */
+                       SetEvent(WaitableIoEventHandle);
+                       buff = get_free_recv_buffer_alloc();
+               }
+       }
+
+       QueueSerialWait(rio, buff, lpo, TRUE);
+
+       return 1;
+}
+
+/*  Add a reference clock data structures I/O handles to
+ *  the I/O completion port. Return 1 if any error.
+ */  
+int
+io_completion_port_add_clock_io(
+       struct refclockio *rio
+       )
+{
+       IoCompletionInfo *lpo;
+       recvbuf_t *buff;
+
+       if (NULL == CreateIoCompletionPort((HANDLE)_get_osfhandle(rio->fd), hIoCompletionPort, (ULONG_PTR) rio, 0)) {
+               msyslog(LOG_ERR, "Can't add COM port to i/o completion port: %m");
+               return 1;
+       }
+
+       lpo = (IoCompletionInfo *) GetHeapAlloc("io_completion_port_add_clock_io");
+       if (lpo == NULL)
+       {
+               msyslog(LOG_ERR, "Can't allocate heap for completion port: %m");
+               return 1;
+       }
+
+       buff = get_free_recv_buffer_alloc();
+       QueueSerialWait(rio, buff, lpo, TRUE);
+       return 0;
+}
+
+/*
+ * Queue a receiver on a socket. Returns 0 if no buffer can be queued 
+ *
+ *  Note: As per the winsock documentation, we use WSARecvFrom. Using
+ *        ReadFile() is less efficient.
+ */
+static unsigned long QueueSocketRecv(SOCKET s, recvbuf_t *buff, IoCompletionInfo *lpo) {
+       
+       int AddrLen;
+
+       lpo->request_type = SOCK_RECV;
+       lpo->recv_buf = buff;
+
+       if (buff != NULL) {
+               DWORD BytesReceived = 0;
+               DWORD Flags = 0;
+               buff->fd = s;
+               AddrLen = sizeof(struct sockaddr_in);
+               buff->src_addr_len = sizeof(struct sockaddr);
+
+               if (SOCKET_ERROR == WSARecvFrom(buff->fd, &buff->wsabuff, 1, 
+                                               &BytesReceived, &Flags, 
+                                               (struct sockaddr *) &buff->recv_srcadr, (LPINT) &buff->src_addr_len, 
+                                               (LPOVERLAPPED) lpo, NULL)) {
+                       DWORD Result = WSAGetLastError();
+                       switch (Result) {
+                               case NO_ERROR :
+                               case WSA_IO_PENDING :
+                                       break ;
+
+                               case WSAENOTSOCK :
+                                       netsyslog(LOG_ERR, "Can't read from socket, because it isn't a socket: %m");
+                                       /* return the buffer */
+                                       freerecvbuf(buff);
+                                       return 0;
+                                       break;
+
+                               case WSAEFAULT :
+                                       netsyslog(LOG_ERR, "The buffers parameter is incorrect: %m");
+                                       /* return the buffer */
+                                       freerecvbuf(buff);
+                                       return 0;
+                               break;
+
+                               default :
+                                 /* nop */ ;
+                       }
+               }
+       }
+       else 
+               return 0;
+       return 1;
+}
+
+
+/* Returns 0 if any Error */
+static int 
+OnSocketRecv(ULONG_PTR i, IoCompletionInfo *lpo, DWORD Bytes, int errstatus)
+{
+       struct recvbuf *buff = NULL;
+       recvbuf_t *newbuff;
+       isc_boolean_t ignore_this;
+       l_fp arrival_time;
+       struct interface * inter = (struct interface *) i;
+       
+       get_systime(&arrival_time);
+
+       /*  Convert the overlapped pointer back to a recvbuf pointer.
+       */
+       
+       /*
+        * Check returned structures
+        */
+       if (lpo == NULL)
+               return (1); /* Nothing to do */
+
+       buff = lpo->recv_buf;
+       /*
+        * Make sure we have a buffer
+        */
+       if (buff == NULL) {
+               return (1);
+       }
+
+       /*
+        * If the socket is closed we get an Operation Aborted error
+        * Just clean up
+        */
+       if (errstatus == WSA_OPERATION_ABORTED)
+       {
+               freerecvbuf(buff);
+               FreeHeap(lpo, "OnSocketRecv: Socket Closed");
+               return (1);
+       }
+
+
+       /*
+        * Get a new recv buffer for the replacement socket receive
+        */
+       newbuff = get_free_recv_buffer_alloc();
+       QueueSocketRecv(inter->fd, newbuff, lpo);
+
+       ignore_this = inter->ignore_packets;
+
+       /*
+        * If we keep it add some info to the structure
+        */
+       if (Bytes > 0 && ignore_this == ISC_FALSE) {
+               memcpy(&buff->recv_time, &arrival_time, sizeof buff->recv_time);        
+               buff->recv_length = (int) Bytes;
+               buff->receiver = receive; 
+               buff->dstadr = inter;
+#ifdef DEBUG
+               if (debug > 1)
+                       printf("Received %d bytes of fd %d in buffer %x from %s\n", Bytes, buff->fd, buff, stoa(&buff->recv_srcadr));
+#endif
+               packets_received++;
+               inter->received++;
+               add_full_recv_buffer(buff);
+               /*
+                * Now signal we have something to process
+                */
+               SetEvent(WaitableIoEventHandle);
+       }
+       else
+               freerecvbuf(buff);
+
+       return 1;
+}
+
+
+/*  Add a socket handle to the I/O completion port, and send 
+ *  NTP_RECVS_PER_SOCKET recv requests to the kernel.
+ */
+extern int
+io_completion_port_add_socket(SOCKET fd, struct interface *inter)
+{
+       IoCompletionInfo *lpo;
+       recvbuf_t *buff;
+       int n;
+
+       if (fd != INVALID_SOCKET) {
+               if (NULL == CreateIoCompletionPort((HANDLE) fd, hIoCompletionPort,
+                                                  (DWORD) inter, 0)) {
+                       msyslog(LOG_ERR, "Can't add socket to i/o completion port: %m");
+                       return 1;
+               }
+       }
+
+       /*
+        * Windows 2000 bluescreens with bugcheck 0x76
+        * PROCESS_HAS_LOCKED_PAGES at ntpd process
+        * termination when using more than one pending
+        * receive per socket.  A runtime version test
+        * would allow using more on newer versions
+        * of Windows.
+        */
+
+#define WINDOWS_RECVS_PER_SOCKET 1
+
+       for (n = 0; n < WINDOWS_RECVS_PER_SOCKET; n++) {
+
+               buff = get_free_recv_buffer_alloc();
+               lpo = (IoCompletionInfo *) GetHeapAlloc("io_completion_port_add_socket");
+               if (lpo == NULL)
+               {
+                       msyslog(LOG_ERR, "Can't allocate heap for completion port: %m");
+                       return 1;
+               }
+
+               QueueSocketRecv(fd, buff, lpo);
+
+       }
+       return 0;
+}
+
+static int 
+OnWriteComplete(ULONG_PTR i, IoCompletionInfo *lpo, DWORD Bytes, int errstatus)
+{
+       transmitbuf_t *buff;
+       struct interface *inter;
+
+       /* UNUSED_ARG(Bytes); */
+
+       buff = lpo->trans_buf;
+
+       free_trans_buf(buff);
+
+       if (SOCK_SEND == lpo->request_type) {
+               switch (errstatus) {
+               case WSA_OPERATION_ABORTED:
+               case NO_ERROR:
+                       break;
+
+               default:
+                       inter = (struct interface *)i;
+                       packets_notsent++;
+                       inter->notsent++;
+                       break;
+               }
+       }
+
+       if (errstatus == WSA_OPERATION_ABORTED)
+               FreeHeap(lpo, "OnWriteComplete: Socket Closed");
+       else
+               FreeHeap(lpo, "OnWriteComplete");
+       return 1;
+}
+
+
+/*
+ * Return value is really GetLastError-style error code
+ * which is a DWORD but using int, which is large enough,
+ * decreases #ifdef forest in ntp_io.c harmlessly.
+ */
+int    
+io_completion_port_sendto(
+       struct interface *inter,        
+       struct pkt *pkt,        
+       int len, 
+       struct sockaddr_storage* dest)
+{
+       transmitbuf_t *buff = NULL;
+       DWORD Result = ERROR_SUCCESS;
+       int errval;
+       int AddrLen;
+       IoCompletionInfo *lpo;
+       DWORD BytesSent = 0;
+       DWORD Flags = 0;
+
+       lpo = (IoCompletionInfo *) GetHeapAlloc("io_completion_port_sendto");
+
+       if (lpo == NULL)
+               return ERROR_OUTOFMEMORY;
+
+       if (len <= sizeof(buff->pkt)) {
+               buff = get_trans_buf();
+
+               if (buff == NULL) {
+                       msyslog(LOG_ERR, "No more transmit buffers left - data discarded");
+                       FreeHeap(lpo, "io_completion_port_sendto");
+                       return ERROR_OUTOFMEMORY;
+               }
+
+
+
+               memcpy(&buff->pkt, pkt, len);
+               buff->wsabuf.buf = buff->pkt;
+               buff->wsabuf.len = len;
+
+               AddrLen = sizeof(struct sockaddr_in);
+               lpo->request_type = SOCK_SEND;
+               lpo->trans_buf = buff;
+
+               Result = WSASendTo(inter->fd, &buff->wsabuf, 1, &BytesSent, Flags, (struct sockaddr *) dest, AddrLen, (LPOVERLAPPED) lpo, NULL);
+
+               if(Result == SOCKET_ERROR)
+               {
+                       errval = WSAGetLastError();
+                       switch (errval) {
+
+                       case NO_ERROR :
+                       case WSA_IO_PENDING :
+                               Result = ERROR_SUCCESS;
+                               break ;
+
+                       /*
+                        * Something bad happened
+                        */
+                       default :
+                               netsyslog(LOG_ERR, "WSASendTo - error sending message: %m");
+                               free_trans_buf(buff);
+                               FreeHeap(lpo, "io_completion_port_sendto");
+                               break;
+                       }
+               }
+#ifdef DEBUG
+               if (debug > 3)
+                       printf("WSASendTo - %d bytes to %s : %d\n", len, stoa(dest), Result);
+#endif
+               return (Result);
+       }
+       else {
+#ifdef DEBUG
+               if (debug) printf("Packet too large: %d Bytes\n", len);
+#endif
+               return ERROR_INSUFFICIENT_BUFFER;
+       }
+}
+
+
+/*
+ * async_write, clone of write(), used by some reflock drivers
+ */
+int    
+async_write(
+       int fd,
+       const void *data,
+       unsigned int count)
+{
+       transmitbuf_t *buff;
+       IoCompletionInfo *lpo;
+       DWORD BytesWritten;
+
+       if (count > sizeof buff->pkt) {
+#ifdef DEBUG
+               if (debug) {
+                       printf("async_write: %d bytes too large, limit is %d\n",
+                               count, sizeof buff->pkt);
+                       exit(-1);
+               }
+#endif
+               errno = ENOMEM;
+               return -1;
+       }
+
+       buff = get_trans_buf();
+       lpo = (IoCompletionInfo *) GetHeapAlloc("async_write");
+
+       if (! buff || ! lpo) {
+               if (buff) {
+                       free_trans_buf(buff);
+#ifdef DEBUG
+                       if (debug)
+                               printf("async_write: out of memory, \n");
+#endif
+               } else {
+                       msyslog(LOG_ERR, "No more transmit buffers left - data discarded");
+               }
+
+               errno = ENOMEM;
+               return -1;
+       }
+
+       lpo->request_type = SERIAL_WRITE;
+       lpo->trans_buf = buff;
+       memcpy(&buff->pkt, data, count);
+
+       if (! WriteFile((HANDLE)_get_osfhandle(fd), buff->pkt, count, &BytesWritten, (LPOVERLAPPED) lpo) &&
+               ERROR_IO_PENDING != GetLastError()) {
+
+               msyslog(LOG_ERR, "async_write - error %m");
+               free_trans_buf(buff);
+               FreeHeap(lpo, "async_write");
+               errno = EBADF;
+               return -1;
+       }
+
+       return count;
+}
+
+
+/*
+ * GetReceivedBuffers
+ * Note that this is in effect the main loop for processing requests
+ * both send and receive. This should be reimplemented
+ */
+int GetReceivedBuffers()
+{
+       isc_boolean_t have_packet = ISC_FALSE;
+       while (!have_packet) {
+               DWORD Index = WaitForMultipleObjects(MAXHANDLES, WaitHandles, FALSE, INFINITE);
+               switch (Index) {
+               case WAIT_OBJECT_0 + 0 : /* Io event */
+# ifdef DEBUG
+                       if ( debug > 3 )
+                       {
+                               printf( "IoEvent occurred\n" );
+                       }
+# endif
+                       have_packet = ISC_TRUE;
+                       break;
+               case WAIT_OBJECT_0 + 1 : /* exit request */
+                       exit(0);
+                       break;
+               case WAIT_OBJECT_0 + 2 : /* timer */
+                       timer();
+                       break;
+               case WAIT_IO_COMPLETION : /* loop */
+               case WAIT_TIMEOUT :
+                       break;
+               case WAIT_FAILED:
+                       msyslog(LOG_ERR, "ntpd: WaitForMultipleObjects Failed: Error: %m");
+                       break;
+
+                       /* For now do nothing if not expected */
+               default:
+                       break;          
+                               
+               } /* switch */
+       }
+
+       return (full_recvbuffs());      /* get received buffers */
+}
+
+#else
+  static int NonEmptyCompilationUnit;
+#endif
+
diff --git a/ports/winnt/ntpd/ntpd.dsp b/ports/winnt/ntpd/ntpd.dsp
new file mode 100644 (file)
index 0000000..ff783a8
--- /dev/null
@@ -0,0 +1,750 @@
+# Microsoft Developer Studio Project File - Name="ntpd" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
+\r
+CFG=ntpd - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntpd.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntpd.mak" CFG="ntpd - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "ntpd - Win32 Release" (based on "Win32 (x86) Console Application")\r
+!MESSAGE "ntpd - Win32 Debug" (based on "Win32 (x86) Console Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""$/ntp/dev/ports/winnt/ntpd", JWBAAAAA"\r
+# PROP Scc_LocalPath "."\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "ntpd - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD CPP /nologo /MD /W4 /GX /O2 /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /I "..\..\..\libopts" /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /YX"windows.h" /FD /c\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib winmm.lib $(OPENSSL)\out32dll\libeay32.lib /nologo /subsystem:console /machine:I386 /out:"../bin/Release/ntpd.exe"\r
+\r
+!ELSEIF  "$(CFG)" == "ntpd - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
+# ADD CPP /nologo /MDd /W3 /Gm /GX /ZI /Od /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /I "..\..\..\libopts" /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /FD /GZ /c\r
+# SUBTRACT CPP /YX\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib winmm.lib $(OPENSSL)\out32dll\libeay32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin/Debug/ntpd.exe" /pdbtype:sept\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "ntpd - Win32 Release"\r
+# Name "ntpd - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\cmd_args.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\nt_clockstuff.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_config.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_control.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_crypto.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_filegen.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_intres.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_io.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\ntp_iocompletionport.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_loopfilter.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_monitor.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_peer.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_proto.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_refclock.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_request.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_restrict.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_timer.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntp_util.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE="..\..\..\ntpd\ntpd-opts.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\ntpd.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\ntservice.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\win32_io.c\r
+# SUBTRACT CPP /YX\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ascii.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\isc\assertions.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\binio.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\isc\boolean.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\clockstuff.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\config.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\hopf_PCI_io.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ieee754io.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\netinet\in.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\arpa\inet.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\isc\int.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\isc\interfaceiter.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\iosignal.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\isc\ipv6.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\jupiter.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\l_stdlib.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libntp\log.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\mbg_gps166.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\isc\net.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\isc\netaddr.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\netdb.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_calendar.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_cmdargs.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_config.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_control.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_debug.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_filegen.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_fp.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_if.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_io.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\ntp_iocompletionport.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_machine.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_malloc.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_proto.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_random.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_refclock.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_request.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_rfc2553.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_select.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_stdlib.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_string.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_syslog.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\ntp_timer.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_tty.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_types.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntp_unixtime.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE="..\..\..\ntpd\ntpd-opts.h"\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\ntpd.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\ntservice.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\isc\offset.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libopts\autoopts\options.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\sys\param.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\isc\platform.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\recvbuff.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\include\isc\result.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\sys\socket.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\syslog.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\termios.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\transmitbuff.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\sys\wait.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\win32_io.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\isc\win32os.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Generated Files"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Source File\r
+\r
+SOURCE=..\libntp\messages.rc\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libntp\MSG00001.bin\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\version.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# Begin Source File\r
+\r
+SOURCE=..\libntp\messages.mc\r
+# End Source File\r
+# End Group\r
+# Begin Group "Reference Clock"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Source File\r
+\r
+SOURCE=.\hopf_PCI_io.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_acts.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_arbiter.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_arc.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_as2201.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_atom.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_bancomm.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_chu.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_conf.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_datum.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_dumbclock.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_gpsvme.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_heath.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_hopfpci.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_hopfser.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_hpgps.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_irig.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_jupiter.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_leitch.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_local.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_msfees.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_mx4200.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_nmea.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_oncore.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_palisade.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_palisade.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_parse.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_pst.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_ptbacts.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_shm.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_tpro.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_trak.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_true.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_usno.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpd\refclock_wwvb.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# End Group\r
+# Begin Group "Parse Lib"\r
+\r
+# PROP Default_Filter ""\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\clk_computime.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\clk_dcf7000.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\clk_hopf6021.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\clk_meinberg.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\clk_rawdcf.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\clk_rcc8000.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\clk_schmid.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\clk_trimtaip.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\clk_trimtsip.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\data_mbg.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\parse.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\libparse\parse_conf.c\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# End Group\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\configure\r
+\r
+!IF  "$(CFG)" == "ntpd - Win32 Release"\r
+\r
+USERDEP__CONFI="..\scripts\mkver.bat"  \r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntpd \r
+       \r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "ntpd - Win32 Debug"\r
+\r
+USERDEP__CONFI="..\scripts\mkver.bat"  \r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntpd \r
+       \r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\scripts\mkver.bat\r
+# PROP Exclude_From_Build 1\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/ports/winnt/ntpd/ntpd.vcproj b/ports/winnt/ntpd/ntpd.vcproj
new file mode 100644 (file)
index 0000000..79b64ca
--- /dev/null
@@ -0,0 +1,2202 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="ntpd"
+       ProjectGUID="{CB61F8BF-9637-495C-9087-E8664B400CE0}"
+       TargetFrameworkVersion="0"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory=".\Release"
+                       IntermediateDirectory=".\Release"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       DeleteExtensionsOnClean="*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Release/ntpd.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               InlineFunctionExpansion="2"
+                               EnableIntrinsicFunctions="true"
+                               FavorSizeOrSpeed="1"
+                               WholeProgramOptimization="true"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\inc32,$(OPENSSL)\include,..\..\..\libopts"
+                               PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32;SYS_WINNT;HAVE_CONFIG_H;_USE_32BIT_TIME_T"
+                               StringPooling="true"
+                               ExceptionHandling="0"
+                               RuntimeLibrary="0"
+                               EnableFunctionLevelLinking="false"
+                               PrecompiledHeaderFile=".\Release/ntpd.pch"
+                               AssemblerListingLocation=".\Release/"
+                               ObjectFile=".\Release/"
+                               ProgramDataBaseFileName="..\bin\Release\ntpd-vc90"
+                               BrowseInformation="1"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib winmm.lib $(OPENSSL)\lib\libeay32.lib"
+                               OutputFile="../bin/Release/ntpd.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Release\ntpd.pdb"
+                               SubSystem="1"
+                               OptimizeForWindows98="0"
+                               LinkTimeCodeGeneration="1"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="2"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Release/ntpd.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory=".\Debug"
+                       IntermediateDirectory=".\Debug"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       DeleteExtensionsOnClean="*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+                       WholeProgramOptimization="1"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Debug/ntpd.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               InlineFunctionExpansion="2"
+                               EnableIntrinsicFunctions="true"
+                               FavorSizeOrSpeed="1"
+                               WholeProgramOptimization="false"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\include,$(OPENSSL)\inc32,..\..\..\libopts"
+                               PreprocessorDefinitions="_DEBUG;_CONSOLE;WIN32;SYS_WINNT;HAVE_CONFIG_H;_USE_32BIT_TIME_T"
+                               MinimalRebuild="true"
+                               ExceptionHandling="0"
+                               BasicRuntimeChecks="3"
+                               SmallerTypeCheck="true"
+                               RuntimeLibrary="1"
+                               EnableFunctionLevelLinking="true"
+                               PrecompiledHeaderFile=".\Debug/ntpd.pch"
+                               AssemblerListingLocation=".\Debug/"
+                               ObjectFile=".\Debug/"
+                               ProgramDataBaseFileName="..\bin\Debug\ntpd-vc90"
+                               BrowseInformation="1"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib winmm.lib $(OPENSSL)\lib\libeay32.lib"
+                               OutputFile="../bin/Debug/ntpd.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Debug\ntpd.pdb"
+                               SubSystem="1"
+                               OptimizeForWindows98="0"
+                               LinkTimeCodeGeneration="0"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Debug/ntpd.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+                       >
+                       <File
+                               RelativePath="..\..\..\ntpd\cmd_args.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="nt_clockstuff.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_config.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_control.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_crypto.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_filegen.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_intres.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_io.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="ntp_iocompletionport.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_loopfilter.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_monitor.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_peer.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_proto.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_refclock.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_request.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_restrict.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_timer.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntp_util.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntpd-opts.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntpd.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="ntservice.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="win32_io.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl"
+                       >
+                       <File
+                               RelativePath="..\..\..\include\ascii.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\isc\assertions.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\binio.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\isc\boolean.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\clockstuff.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\config.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\hopf_PCI_io.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ieee754io.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\netinet\in.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\arpa\inet.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\isc\int.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\isc\interfaceiter.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\iosignal.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\isc\ipv6.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\jupiter.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\l_stdlib.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libntp\log.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\mbg_gps166.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\isc\net.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\isc\netaddr.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\netdb.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_calendar.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_cmdargs.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_config.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_control.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_debug.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_filegen.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_fp.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_if.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_io.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\ntp_iocompletionport.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_machine.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_malloc.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_proto.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_random.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_refclock.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_request.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_rfc2553.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_select.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_stdlib.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_string.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_syslog.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\ntp_timer.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_tty.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_types.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntp_unixtime.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\ntpd-opts.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\ntpd.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\ntservice.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\isc\offset.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libopts\autoopts\options.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\sys\param.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\isc\platform.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\recvbuff.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\include\isc\result.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\sys\socket.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\syslog.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\termios.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\timepps.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\transmitbuff.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\sys\wait.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\win32_io.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\include\isc\win32os.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Generated Files"
+                       >
+                       <File
+                               RelativePath="..\libntp\messages.rc"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCResourceCompilerTool"
+                                               PreprocessorDefinitions=""
+                                               AdditionalIncludeDirectories="..\libntp"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCResourceCompilerTool"
+                                               PreprocessorDefinitions=""
+                                               AdditionalIncludeDirectories="..\libntp"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libntp\MSG00001.bin"
+                               >
+                       </File>
+                       <File
+                               RelativePath="version.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               ShowIncludes="true"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+                       >
+                       <File
+                               RelativePath="..\libntp\messages.mc"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Reference Clock"
+                       >
+                       <File
+                               RelativePath="hopf_PCI_io.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_acts.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_arbiter.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_arc.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_as2201.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_atom.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_bancomm.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_chu.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_conf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_datum.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_dumbclock.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_gpsvme.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_heath.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_hopfpci.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_hopfser.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_hpgps.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_irig.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_jjy.c"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_jupiter.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_leitch.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_local.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_msfees.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_mx4200.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_nmea.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_oncore.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_palisade.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_palisade.h"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_parse.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_pcf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_pst.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_ptbacts.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_shm.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_tpro.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_trak.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_true.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_usno.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpd\refclock_wwvb.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Parse Lib"
+                       >
+                       <File
+                               RelativePath="..\..\..\libparse\clk_computime.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\clk_dcf7000.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\clk_hopf6021.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\clk_meinberg.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\clk_rawdcf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\clk_rcc8000.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\clk_schmid.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\clk_trimtaip.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\clk_trimtsip.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\data_mbg.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\parse.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\libparse\parse_conf.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       ExcludedFromBuild="true"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <File
+                       RelativePath="..\..\..\configure"
+                       >
+                       <FileConfiguration
+                               Name="Release|Win32"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpd&#x0D;&#x0A;"
+                                       AdditionalDependencies="..\scripts\mkver.bat;..\include\config.h;ntp_iocompletionport.c;win32_io.c;ntpd.c;ntp_timer.c;"
+                                       Outputs="$(ProjectDir)version.c"
+                               />
+                       </FileConfiguration>
+                       <FileConfiguration
+                               Name="Debug|Win32"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpd&#x0D;&#x0A;"
+                                       AdditionalDependencies="..\scripts\mkver.bat;..\include\config.h;ntp_iocompletionport.c;win32_io.c;ntpd.c;ntp_timer.c;"
+                                       Outputs="$(ProjectDir)version.c"
+                               />
+                       </FileConfiguration>
+               </File>
+               <File
+                       RelativePath="..\scripts\mkver.bat"
+                       >
+                       <FileConfiguration
+                               Name="Release|Win32"
+                               ExcludedFromBuild="true"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                               />
+                       </FileConfiguration>
+                       <FileConfiguration
+                               Name="Debug|Win32"
+                               ExcludedFromBuild="true"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                               />
+                       </FileConfiguration>
+               </File>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/ports/winnt/ntpd/ntservice.c b/ports/winnt/ntpd/ntservice.c
new file mode 100644 (file)
index 0000000..a9afe1f
--- /dev/null
@@ -0,0 +1,280 @@
+/*
+ * Copyright (C) 2004  Internet Systems Consortium, Inc. ("ISC")
+ * Copyright (C) 1999-2002  Internet Software Consortium.
+ *
+ * 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 ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS.  IN NO EVENT SHALL ISC 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.
+ */
+
+/* $Id: ntservice.c,v 1.3.2.1.10.3 2004/03/08 04:04:22 marka Exp $ */
+
+#include <config.h>
+#include <stdio.h>
+
+#include <ntp_cmdargs.h>
+#include <ntp_stdlib.h>
+#include "syslog.h"
+#include "ntservice.h"
+#include "clockstuff.h"
+#include "ntp_iocompletionport.h"
+#include "isc/win32os.h"
+#ifdef DEBUG
+#include <crtdbg.h>
+#endif
+
+/* Handle to SCM for updating service status */
+static SERVICE_STATUS_HANDLE hServiceStatus = 0;
+static BOOL foreground = FALSE;
+static char ConsoleTitle[128];
+static int glb_argc;
+static char **glb_argv;
+HANDLE hServDoneEvent = NULL;
+int accept_wildcard_if_for_winnt;
+extern volatile int debug;
+extern char *progname;
+
+void uninit_io_completion_port();
+int ntpdmain(int argc, char *argv[]);
+/*
+ * Forward declarations
+ */
+void ServiceControl(DWORD dwCtrlCode);
+void ntservice_exit(void);
+
+void WINAPI service_main( DWORD argc, LPTSTR *argv )
+{
+       if ( argc > 1 )
+       {
+               /*
+                * Let command line parameters from the Windows SCM GUI
+                * override the standard parameters from the ImagePath registry key.
+                */
+               glb_argc = argc;
+               glb_argv = argv;
+       }
+
+       ntpdmain( glb_argc, glb_argv );
+}
+
+
+/*
+ * This is the entry point for the executable 
+ * We can call ntpdmain() explicitly or via StartServiceCtrlDispatcher()
+ * as we need to.
+ */
+int main( int argc, char *argv[] )
+{
+       int rc;
+       int i = 1;
+
+       /* Save the command line parameters */
+       glb_argc = argc;
+       glb_argv = argv;
+
+       /* Under original Windows NT we must not discard the wildcard */
+       /* socket to workaround a bug in NT's getsockname(). */
+       if ( isc_win32os_majorversion() <= 4 )
+               accept_wildcard_if_for_winnt = 1;
+
+       /* Command line users should put -n in the options */
+       while (argv[i]) {
+               if (!_strnicmp(argv[i], "-d", 2) ||
+                       !strcmp(argv[i], "-q") ||
+                       !strcmp(argv[i], "--help") ||
+                       !strcmp(argv[i], "-n")) {
+                       foreground = TRUE;
+                       break;
+               }
+               i++;
+       }
+
+       if (foreground) {
+               /* run in console window */
+               exit(ntpdmain(argc, argv));
+       } else {
+               /* Start up as service */
+
+               SERVICE_TABLE_ENTRY dispatchTable[] = {
+                       { TEXT(NTP_DISPLAY_NAME), (LPSERVICE_MAIN_FUNCTION) service_main },
+                       { NULL, NULL }
+               };
+
+               rc = StartServiceCtrlDispatcher(dispatchTable);
+               if (!rc) {
+                       progname = argv[0];
+                       rc = GetLastError();
+#ifdef DEBUG
+                       fprintf(stderr, "%s: unable to start as service, rc: %i\n\n", progname, rc);
+#endif
+                       fprintf(stderr, "\nUse -d, -q, --help or -n to run from the command line.\n");
+                       exit(rc);
+               }
+       }
+       exit(0);
+}
+
+/*
+ * Initialize the Service by registering it.
+ */
+void
+ntservice_init() {
+       if (!foreground) {
+               /* Register handler with the SCM */
+               hServiceStatus = RegisterServiceCtrlHandler(NTP_DISPLAY_NAME,
+                                       (LPHANDLER_FUNCTION)ServiceControl);
+               if (!hServiceStatus) {
+                       NTReportError(NTP_SERVICE_NAME,
+                               "could not register service control handler");
+                       UpdateSCM(SERVICE_STOPPED);
+                       exit(1);
+               }
+               UpdateSCM(SERVICE_RUNNING);
+       } else {
+               strcpy(ConsoleTitle, "NTP Version ");
+               strcat(ConsoleTitle, Version);
+               SetConsoleTitle(ConsoleTitle);
+       }
+
+       atexit( ntservice_exit );
+}
+/*
+ * Routine to check if this is a service or a foreground program
+ */
+BOOL
+ntservice_isservice() {
+       return(!foreground);
+}
+/* service_ctrl - control handler for NTP service
+ * signals the service_main routine of start/stop requests
+ * from the control panel or other applications making
+ * win32API calls
+ */
+void
+ntservice_exit( void )
+{
+
+       if (!foreground) { /* did not become a service, simply exit */
+               /* service mode, need to have the service_main routine
+                * register with the service control manager that the 
+                * service has stopped running, before exiting
+                */
+               UpdateSCM(SERVICE_STOPPED);
+       }
+       uninit_io_completion_port();
+       Sleep( 200 );   //##++ 
+
+       reset_winnt_time();
+
+       msyslog(LOG_INFO, "ntservice: The Network Time Protocol Service has stopped.");
+
+# ifdef DEBUG
+       _CrtDumpMemoryLeaks();
+# endif 
+}
+
+/* 
+ * ServiceControl(): Handles requests from the SCM and passes them on
+ * to the service.
+ */
+void
+ServiceControl(DWORD dwCtrlCode) {
+       /* Handle the requested control code */
+       HANDLE exitEvent = get_exit_event();
+
+       switch(dwCtrlCode) {
+
+       case SERVICE_CONTROL_SHUTDOWN:
+       case SERVICE_CONTROL_STOP:
+               UpdateSCM(SERVICE_STOP_PENDING);
+               if (exitEvent != NULL) {
+                       SetEvent(exitEvent);
+                       Sleep( 100 );  //##++
+               }
+               return;
+       case SERVICE_CONTROL_PAUSE:
+       case SERVICE_CONTROL_CONTINUE:
+       case SERVICE_CONTROL_INTERROGATE:
+        default:
+               break;
+       }
+       UpdateSCM(SERVICE_RUNNING);
+}
+
+/*
+ * Tell the Service Control Manager the state of the service.
+ */
+void UpdateSCM(DWORD state) {
+       SERVICE_STATUS ss;
+       static DWORD dwState = SERVICE_STOPPED;
+
+       if (hServiceStatus) {
+               if (state)
+                       dwState = state;
+
+               memset(&ss, 0, sizeof(SERVICE_STATUS));
+               ss.dwServiceType |= SERVICE_WIN32_OWN_PROCESS;
+               ss.dwCurrentState = dwState;
+               ss.dwControlsAccepted = SERVICE_ACCEPT_STOP |
+                                       SERVICE_ACCEPT_SHUTDOWN;
+               ss.dwCheckPoint = 0;
+               ss.dwServiceSpecificExitCode = 0;
+               ss.dwWin32ExitCode = NO_ERROR;
+               ss.dwWaitHint = dwState == SERVICE_STOP_PENDING ? 5000 : 1000;
+
+               if (!SetServiceStatus(hServiceStatus, &ss)) {
+                       ss.dwCurrentState = SERVICE_STOPPED;
+                       SetServiceStatus(hServiceStatus, &ss);
+               }
+       }
+}
+
+BOOL WINAPI 
+OnConsoleEvent(  
+       DWORD dwCtrlType
+       )
+{
+       HANDLE exitEvent = get_exit_event();
+
+       switch (dwCtrlType) {
+#ifdef DEBUG
+               case CTRL_BREAK_EVENT :
+                       if (debug > 0) {
+                               debug <<= 1;
+                       }
+                       else {
+                               debug = 1;
+                       }
+                       if (debug > 8) {
+                               debug = 0;
+                       }
+                       printf("debug level %d\n", debug);
+               break ;
+#endif
+
+               case CTRL_C_EVENT  :
+               case CTRL_CLOSE_EVENT :
+               case CTRL_SHUTDOWN_EVENT :
+                       if (exitEvent != NULL) {
+                               SetEvent(exitEvent);
+                               Sleep( 100 );  //##++
+                       }
+               break;
+
+               default :
+                       return FALSE;
+
+
+       }
+       return TRUE;;
+}
+
diff --git a/ports/winnt/ntpd/refclock_trimbledc.c b/ports/winnt/ntpd/refclock_trimbledc.c
new file mode 100644 (file)
index 0000000..c90b526
--- /dev/null
@@ -0,0 +1,292 @@
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if defined(REFCLOCK) && defined(CLOCK_TRIMBLEDC)
+
+#include "refclock_trimbledc.h"
+extern int debug;
+
+static int     trimbledc_start         (int, struct peer *);
+static void    trimbledc_shutdown      (int, struct peer *);
+static void    trimbledc_receive       (struct recvbuf *);
+static void    trimbledc_poll          (int, struct peer *);
+static void    trimbledc_io            (char, int, unsigned char *, l_fp*, struct trimbledc_unit *);
+
+
+/*
+ * Transfer vector
+ */
+struct refclock refclock_trimbledc = {
+       trimbledc_start,        /* start up driver */
+       trimbledc_shutdown,     /* shut down driver */
+       trimbledc_poll,         /* transmit poll message */
+       noentry,                /* not used  */
+       noentry,                /* initialize driver (not used) */
+       noentry,                /* not used */
+       NOFLAGS                 /* not used */
+};
+
+
+/*
+ * trimbledc_start - open the devices and initialize data for processing
+ */
+static int
+trimbledc_start (
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct trimbledc_unit *up;
+       struct refclockproc *pp;
+       int fd;
+       char gpsdev[20];
+
+       struct termios tio;
+#ifdef SYS_WINNT
+       (void) sprintf(gpsdev, DEVICE, unit);
+#else
+       (void) sprintf(gpsdev, DEVICE, unit + 1);
+#endif
+       /*
+        * Open serial port. 
+        */
+       fd = refclock_open(gpsdev, SPEED232, LDISC_RAW);
+       if (fd == -1) {
+               msyslog(LOG_ERR,"Trimble (%d) start: open %s failed: %m",
+                       unit, gpsdev);
+               return 0;
+       }
+
+       msyslog(LOG_NOTICE, "Trimble (%d) fd: %d dev: %s", unit, fd, gpsdev);
+
+        if (tcgetattr(fd, &tio) < 0) {
+                msyslog(LOG_ERR, 
+                       "Trimble (%d) tcgetattr(fd, &tio): %m",unit);
+                return (0);
+        }
+
+        tio.c_cflag |= (PARENB|PARODD);
+        tio.c_iflag &= ~ICRNL;
+
+       if (tcsetattr(fd, TCSANOW, &tio) == -1) {
+                msyslog(LOG_ERR, "Trimble (%d) tcsetattr(fd, &tio): %m",unit);
+                return 0;
+        }
+
+       /*
+        * Allocate and initialize unit structure
+        */
+       if (!(up = (struct trimbledc_unit *)
+             emalloc(sizeof(struct trimbledc_unit)))) {
+               (void) close(fd);
+               return (0);
+       }
+       memset((char *)up, 0, sizeof(struct trimbledc_unit));
+
+       pp = peer->procptr;
+       pp->io.clock_recv = trimbledc_receive;
+       pp->io.srcclock = (caddr_t)peer;
+       pp->io.datalen = 0;
+       pp->io.fd = fd;
+
+       if (!io_addclock(&pp->io)) {
+               (void) close(fd);
+               free(up);
+               return (0);
+       }
+
+       /*
+        * Initialize miscellaneous variables
+        */
+       pp->unitptr = (caddr_t)up;
+       pp->clockdesc = DESCRIPTION;
+
+       peer->precision = PRECISION;
+       peer->sstclktype = CTL_SST_TS_UHF;
+       peer->minpoll = TRIMBLEDC_MINPOLL;
+       peer->maxpoll = TRIMBLEDC_MAXPOLL;
+       memcpy((char *)&pp->refid, REFID, 4);
+
+       up->leap_status = 0;
+       up->unit = unit;
+       up->io_ptr[0] = up->io_ptr[1] = 0;
+
+       return 1;
+}
+
+
+/*
+ * trimbledc_shutdown - shut down the clock
+ */
+static void
+trimbledc_shutdown (
+       int unit,
+       struct peer *peer
+       )
+{
+       register struct trimbledc_unit *up;
+       struct refclockproc *pp;
+       pp = peer->procptr;
+       up = (struct trimbledc_unit *)pp->unitptr;
+       io_closeclock(&pp->io);
+       free(up);
+}
+
+
+
+/* 
+ * TSIP_decode - decode the TSIP data packets 
+ */
+static int
+trimbledc_decode (
+       struct peer *peer
+       )
+{
+#ifdef DEBUG
+       double lat, lon, alt;
+#endif
+       int st, ts;
+       long   secint;
+       double secs;
+       double secfrac;
+       unsigned short event = 0;
+
+       register struct trimbledc_unit *up;
+       struct refclockproc *pp;
+
+       pp = peer->procptr;
+       up = (struct trimbledc_unit *)pp->unitptr;
+
+       /*
+        * Check the time packet, decode its contents. 
+        * If the timecode has invalid length or is not in
+        * proper format, declare bad format and exit.
+        */
+
+       if (up->rpt_buf[0] ==0x41) 
+       /* standard time packet - GPS time and GPS week number */
+               return 0;       
+
+
+       refclock_report(peer, CEVNT_BADREPLY);
+       up->polled = -1;
+#ifdef DEBUG
+       if (debug)
+       printf("TRIMBLEDC_decode: unit %d: bad packet %02x-%02x event %d len %d\n", 
+                  up->unit, up->rpt_buf[0] & 0xff, mb(0) & 0xff, 
+                       event, up->rpt_cnt);
+#endif
+       return 0;
+}
+
+/*
+ * trimbledc__receive - receive data from the serial interface
+ */
+
+static void
+trimbledc_receive (
+       struct recvbuf *rbufp
+       )
+{
+       register struct trimbledc_unit *up;
+       struct refclockproc *pp;
+       struct peer *peer;
+
+       /*
+        * Initialize pointers and read the timecode and timestamp.
+        */
+       peer = (struct peer *)rbufp->recv_srcclock;
+       pp = peer->procptr;
+       up = (struct trimbledc_unit *)pp->unitptr;
+
+       
+       for (;FALSE;) {
+               trimbledc_io(pp->sloppyclockflag & CLK_FLAG2, rbufp->recv_length,
+                           &rbufp->recv_buffer, &pp->lastrec, up);       
+
+
+
+
+               (void) sprintf(pp->a_lastcode,"%4d %03d %02d:%02d:%02d.%06ld",
+                               pp->year,pp->day,pp->hour,pp->minute, pp->second,pp->usec); 
+                               pp->lencode = 24;
+
+               if (!refclock_process(pp)) {
+                       refclock_report(peer, CEVNT_BADTIME);
+
+#ifdef DEBUG
+                       if (debug)
+                       printf("trimbledc_receive: unit %d: refclock_process failed!\n",
+                               up->unit);
+#endif
+                       continue;
+               }
+
+               record_clock_stats(&peer->srcadr, pp->a_lastcode); 
+
+#ifdef DEBUG
+               if (debug)
+                       if (debug)
+                       printf("trimbledc_receive: unit %d: %s\n",
+                          up->unit, prettydate(&pp->lastrec));
+#endif
+
+               refclock_receive(peer);
+       }
+}
+
+
+/*
+ * trimbledc_poll - called by the transmit procedure
+ *
+ */
+static void
+trimbledc_poll (
+       int unit,
+       struct peer *peer
+       )
+{
+       struct trimbledc_unit *up;
+       struct refclockproc *pp;
+       
+       pp = peer->procptr;
+       up = (struct trimbledc_unit *)pp->unitptr;
+
+       pp->polls++;
+       if (up->polled > 0) /* last reply never arrived or error */ 
+           refclock_report(peer, CEVNT_TIMEOUT);
+
+       up->polled = 2; /* synchronous packet + 1 event */
+       
+#ifdef DEBUG
+       if (debug)
+           printf("trimbledc_poll: unit %d: polling %s\n", unit,
+                  (pp->sloppyclockflag & CLK_FLAG2) ? 
+                       "synchronous packet" : "event");
+#endif 
+
+       if (pp->sloppyclockflag & CLK_FLAG2) 
+           return;  /* using synchronous packet input */
+
+//     if (HW_poll(pp) < 0) 
+           refclock_report(peer, CEVNT_FAULT); 
+}
+
+
+static void
+trimbledc_io (
+       char noevents,
+       int buflen,                     /* bytes in buffer to process */
+       unsigned char *bufp,            /* receive buffer */
+       l_fp* t_in,                     /* receive time stamp */
+       struct trimbledc_unit *up       /* pointer to unit data structure   */
+       )
+{
+       
+}
+
+
+
+
+#endif /* REFCLOCK */
diff --git a/ports/winnt/ntpd/refclock_trimbledc.h b/ports/winnt/ntpd/refclock_trimbledc.h
new file mode 100644 (file)
index 0000000..f53ff7f
--- /dev/null
@@ -0,0 +1,97 @@
+/*
+ * refclock_trimbledc - clock driver for the Trimble Data Collector compatible
+ * GPS receivers (4000, 4700, 4800, 7400, ...)
+ *
+ * Greg Brackley (greg@trimble.co.nz)
+ */
+
+#ifndef _REFCLOCK_TRIMBLEDC_H
+#define _REFCLOCK_TRIMBLEDC_H
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#if defined HAVE_SYS_MODEM_H
+#include <sys/modem.h>
+#define TIOCMSET MCSETA
+#define TIOCMGET MCGETA
+#define TIOCM_RTS MRTS
+#endif
+
+#ifdef HAVE_TERMIOS_H
+#include <termios.h>
+#endif
+
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif
+
+#include "ntpd.h"
+#include "ntp_io.h"
+#include "ntp_control.h"
+#include "ntp_refclock.h"
+#include "ntp_unixtime.h"
+#include "ntp_stdlib.h"
+
+/*
+ * GPS Definitions
+ */
+#define        DESCRIPTION     "Trimble Data Collector GPS" /* Long name */
+#define        PRECISION       (-20)   /* precision assumed (about 1 us) */
+#define        REFID           "GPS\0" /* reference ID */
+#define NSAMPLES               1
+#define NSKEEP                 1
+#define TRIMBLEDC_MINPOLL      4
+#define TRIMBLEDC_MAXPOLL      4
+
+/*
+ * I/O Definitions
+ */
+#if !defined SYS_WINNT
+#define        DEVICE          "/dev/trimbledc%d"      /* device name and unit */
+#else
+#define        DEVICE          "\\\\.\\COM%d"          /* device name and unit */
+#endif
+#define        SPEED232        B9600                   /* uart speed (9600 baud) */
+
+#define POLL_AVG       10  /* number of samples to average code delay */
+#define DC_IO_BUFSIZE  512 /* IO buffer */
+#define DC_MAXLEN      260  /* maximum length TSIP packet */
+
+/* 
+ * Leap-Insert and Leap-Delete are encoded as follows:
+ *     PALISADE_UTC_TIME set   and PALISADE_LEAP_PENDING set: INSERT leap
+ *     PALISADE_UTC_TIME clear and PALISADE_LEAP_PENDING set: DELETE leap
+ */
+
+#define PALISADE_LEAP_WARNING    0x04 /* GPS Leap Warning (see ICD-200) */
+#define PALISADE_LEAP_PENDING    0x02 /* Leap Pending (24 hours) */
+#define PALISADE_UTC_TIME        0x01 /* UTC time available */
+
+#define mb(_X_) (up->rpt_buf[(_X_ + 1)]) /* shortcut for buffer access */
+
+/* Conversion Definitions */
+#define GPS_PI                 (3.1415926535898)
+#define        R2D             (180.0/GPS_PI)
+
+typedef enum TrimbleDcParseState {
+
+  TrimbleParseStateAck,
+  TrimbleParseStateNak,
+  TrimbleParseStateData,
+
+} TrimbleDcParseState;
+
+struct trimbledc_unit {
+       int             unit;           /* NTP refclock unit number */
+       int             polled;         /* flag to detect noreplies */
+       char            leap_status;    /* leap second flag */
+       TrimbleDcParseState             rpt_status;     
+       short           rpt_cnt;        
+       char            rpt_buf[DC_MAXLEN];     
+       char            io_buf[DC_IO_BUFSIZE];
+       short           io_ptr[2];      /* 0 = head, 1 = tail */
+};
+
+#endif /* _REFCLOCK_TRIMBLEDC_H */
diff --git a/ports/winnt/ntpd/win32_io.c b/ports/winnt/ntpd/win32_io.c
new file mode 100644 (file)
index 0000000..20aa6dc
--- /dev/null
@@ -0,0 +1,403 @@
+/* This file implements system calls that are not compatible with UNIX */
+
+#include <config.h>
+#include <stdio.h>
+#include "ntp_machine.h"
+#include "ntp_stdlib.h"
+#include "ntp_syslog.h"
+#include "ntp_debug.h"
+#include "ntp_fp.h"
+#include "ntp.h"
+#include "ntp_refclock.h"
+#include "win32_io.h"
+
+#define MAX_SERIAL 16  /* COM1-COM16 */
+
+
+int NT_set_process_priority(void)
+{
+       if (!SetPriorityClass(GetCurrentProcess(), REALTIME_PRIORITY_CLASS)) 
+               {
+               msyslog(LOG_ERR, "SetPriorityClass: %m"); 
+               return 0;
+               }
+       else 
+               return 1;
+}
+
+
+/*
+ * common_serial_open ensures duplicate opens of the same port
+ * work by duplicating the handle for the 2nd open, allowing
+ * refclock_atom to share a GPS refclock's comm port.
+ *
+ */
+
+HANDLE common_serial_open(
+       char *dev
+       )
+{
+       static HANDLE SerialHandles[MAX_SERIAL+1] = {0};
+       HANDLE RetHandle;
+       int unit;
+
+       if (1 != sscanf(dev, "COM%d:", &unit) || unit > MAX_SERIAL)
+               return INVALID_HANDLE_VALUE;
+
+       if (!SerialHandles[unit])
+               SerialHandles[unit] = CreateFile(
+                                       dev,
+                                       GENERIC_READ | GENERIC_WRITE,
+                                       0, /* sharing prohibited */
+                                       NULL, /* default security */
+                                       OPEN_EXISTING,
+                                       FILE_ATTRIBUTE_NORMAL | FILE_FLAG_OVERLAPPED,
+                                       NULL);
+
+       if (INVALID_HANDLE_VALUE == SerialHandles[unit]) {
+               SerialHandles[unit] = 0;
+               return INVALID_HANDLE_VALUE;
+       }
+
+       DuplicateHandle(
+               GetCurrentProcess(),
+               SerialHandles[unit],
+               GetCurrentProcess(),
+               &RetHandle,
+               0,
+               FALSE,
+               DUPLICATE_SAME_ACCESS
+               );
+
+       return RetHandle;
+}
+
+/*
+ * pps_open - open serial port for PPS
+ *
+ * This routine opens a serial port for and returns the 
+ * file descriptor if success and -1 if failure.
+ */
+int pps_open(
+       char *dev,              /* device name pointer */
+       int access,             /* O_RDWR */
+       int mode                /* unused */
+       )
+{
+       HANDLE Handle;
+       char windev[3 + 20 + 1 + 1];
+       int unit;
+
+       if (1 != sscanf(dev, "/dev/pps%d", &unit)) {
+               errno = ENOENT;
+               return -1;
+       }
+       /*
+        * there never is a COM0: but this is the ntp convention
+        */
+       _snprintf(windev, sizeof(windev)-1, "COM%d:", unit);
+       windev[sizeof(windev)-1] = 0; 
+
+       /*
+        * open communication port handle
+        */
+       Handle = common_serial_open(windev);
+
+       if (Handle == INVALID_HANDLE_VALUE) {  
+               msyslog(LOG_ERR, "pps_open: Device %s CreateFile error: %m", windev);
+               errno = EMFILE; /* lie, lacking conversion from GetLastError() */
+               return -1;
+       }
+
+       return (int) _open_osfhandle((int)Handle, _O_TEXT);
+}
+
+/*
+ * refclock_open - open serial port for reference clock
+ *
+ * This routine opens a serial port for I/O and sets default options. It
+ * returns the file descriptor if success and zero if failure.
+ */
+int refclock_open(
+       char *dev,              /* device name pointer */
+       u_int speed,            /* serial port speed (code) */
+       u_int flags             /* line discipline flags */
+       )
+{
+       HANDLE Handle = INVALID_HANDLE_VALUE;
+       COMMTIMEOUTS timeouts;
+       DCB dcb;
+
+       /*
+        * open communication port handle
+        */
+       Handle = common_serial_open(dev);
+
+       if (Handle == INVALID_HANDLE_VALUE) {  
+                
+               msyslog(LOG_ERR, "NT_COM: Device %s CreateFile error: %m", dev);
+               return -1;
+       }
+
+       /*  Change the input/output buffers to be large.
+       */
+       if (!SetupComm( Handle, 1024, 1024)) {
+               msyslog(LOG_ERR, "NT_COM: Device %s SetupComm error: %m", dev);
+               return -1;
+       }
+
+       dcb.DCBlength = sizeof(dcb);
+       if (!GetCommState(Handle, &dcb)) {
+               // Error getting current DCB settings
+               msyslog(LOG_ERR, "NT_COM: Device %s GetCommState error: %m", dev);
+               return -1;
+       }
+
+       switch (speed) {
+         case B300 :   dcb.BaudRate = 300; break;
+         case B1200 :  dcb.BaudRate = 1200; break;
+         case B2400 :  dcb.BaudRate = 2400; break;
+         case B4800 :  dcb.BaudRate = 4800; break;
+         case B9600 :  dcb.BaudRate = 9600; break;
+         case B19200 : dcb.BaudRate = 19200; break;
+         case B38400 : dcb.BaudRate = 38400; break;
+         case B57600 : dcb.BaudRate = 57600; break;
+         case B115200 : dcb.BaudRate = 115200; break;
+         default :
+               msyslog(LOG_ERR, "NT_COM: Device %s unsupported baud rate", dev);
+               return -1;
+       }
+
+
+       dcb.fBinary = TRUE;
+       dcb.fParity = TRUE;
+       dcb.fOutxCtsFlow = 0;
+       dcb.fOutxDsrFlow = 0;
+       dcb.fDtrControl = DTR_CONTROL_DISABLE;
+       dcb.fDsrSensitivity = 0;
+       dcb.fTXContinueOnXoff = TRUE;
+       dcb.fOutX = 0; 
+       dcb.fInX = 0;
+       dcb.fErrorChar = 0;
+       dcb.fNull = 0;
+       dcb.fRtsControl = RTS_CONTROL_DISABLE; // RTS_CONTROL_DISABLE;
+       dcb.fAbortOnError = 0;
+       dcb.ByteSize = 8;
+       dcb.StopBits = ONESTOPBIT;
+       dcb.Parity = NOPARITY;
+       dcb.ErrorChar = 0;
+       dcb.EvtChar = 13; /* CR */
+       dcb.EofChar = 0;
+
+       if (!SetCommState(Handle, &dcb)) {
+               msyslog(LOG_ERR, "NT_COM: Device %s SetCommState error: %m", dev);
+               return -1;
+       }
+
+       /* watch out for CR (dcb.EvtChar) as well as the CD line */
+       if (!SetCommMask(Handle, EV_RXFLAG | EV_RLSD)) {
+               msyslog(LOG_ERR, "NT_COM: Device %s SetCommMask error: %m", dev);
+               return -1;
+       }
+
+       /* configure the handle to never block */
+       timeouts.ReadIntervalTimeout = MAXDWORD;
+       timeouts.ReadTotalTimeoutMultiplier = 0;
+       timeouts.ReadTotalTimeoutConstant = 0;
+       timeouts.WriteTotalTimeoutMultiplier = 0;
+       timeouts.WriteTotalTimeoutConstant = 0;
+
+       if (!SetCommTimeouts(Handle, &timeouts)) {
+               msyslog(LOG_ERR, "NT_COM: Device %s SetCommTimeouts error: %m", dev);
+               return -1;
+       }
+
+       return (int) _open_osfhandle((int)Handle, _O_TEXT);
+}
+
+int 
+ioctl(int fd,
+       int cmd,
+       int *x)
+{
+       HANDLE h = (HANDLE) _get_osfhandle(fd);
+
+       if ((cmd == TIOCMSET) && (*x & TIOCM_RTS)) {
+               if (!EscapeCommFunction(h, SETRTS)) 
+                       return -1;
+       }
+       else if ((cmd == TIOCMSET) && !(*x & TIOCM_RTS)){
+               if (!EscapeCommFunction(h, CLRRTS)) 
+                       return -1;
+       }
+       if ((cmd == TIOCMSET) && (*x & TIOCM_DTR)) {
+               if (!EscapeCommFunction(h, SETDTR)) 
+                       return -1;
+       }
+       else if ((cmd == TIOCMSET) && !(*x & TIOCM_DTR)){
+               if (!EscapeCommFunction(h, CLRDTR)) 
+                       return -1;
+       }
+
+       return 0;
+}
+
+
+int    
+tcsetattr(
+       int fd, 
+       int optional_actions, 
+       const struct termios * s)
+{
+       DCB dcb = { 0 };
+       HANDLE Handle = (HANDLE) _get_osfhandle(fd);
+       dcb.DCBlength = sizeof(dcb);
+       if (!GetCommState(Handle, &dcb)) {
+               // Error getting current DCB settings
+               msyslog(LOG_ERR, "NT_COM: GetCommState error: %m");
+               return FALSE;
+       }
+
+       switch (max(s->c_ospeed, s->c_ispeed)) {
+               case B300 :   dcb.BaudRate = 300; break;
+               case B1200 :  dcb.BaudRate = 1200; break;
+               case B2400 :  dcb.BaudRate = 2400; break;
+               case B4800 :  dcb.BaudRate = 4800; break;
+               case B9600 :  dcb.BaudRate = 9600; break;
+               case B19200 : dcb.BaudRate = 19200; break;
+               case B38400 : dcb.BaudRate = 38400; break;
+               case B57600 : dcb.BaudRate = 57600; break;
+               case B115200 : dcb.BaudRate = 115200; break;
+               default :
+                       msyslog(LOG_ERR, "NT_COM: unsupported baud rate");
+                       return FALSE;
+       }
+
+       switch (s->c_cflag & CSIZE) {
+               case CS5 : dcb.ByteSize = 5; break;
+               case CS6 : dcb.ByteSize = 6; break;
+               case CS7 : dcb.ByteSize = 7; break;
+               case CS8 : dcb.ByteSize = 8; break;
+               default :
+                       msyslog(LOG_ERR, "NT_COM: unsupported word size");
+                       return FALSE;
+       }
+
+       if (s->c_cflag & PARENB) {
+               dcb.fParity = TRUE;
+               if (s->c_cflag & PARODD) {
+                       dcb.Parity = ODDPARITY;
+               }
+               else {
+                       dcb.Parity = EVENPARITY;
+               }
+       }
+       else {
+               dcb.fParity = FALSE;
+               dcb.Parity = NOPARITY;
+       }
+       if (s->c_cflag & CSTOPB ) {
+               dcb.StopBits = TWOSTOPBITS;
+       }
+       else {
+               dcb.StopBits = ONESTOPBIT;
+       }
+
+       if (!SetCommState(Handle, &dcb)) {
+               msyslog(LOG_ERR, "NT_COM: SetCommState error 2: %m");
+               return FALSE;
+       }
+       return TRUE;
+}
+
+extern int     
+tcgetattr(
+       int fd, struct termios *s)
+{
+       DCB dcb;
+       HANDLE Handle = (HANDLE) _get_osfhandle(fd);
+
+       dcb.DCBlength = sizeof(dcb);
+       if (!GetCommState(Handle, &dcb)) {
+               msyslog(LOG_ERR, "NT_COM: GetCommState error: %m");
+               return FALSE;
+       }
+
+       /*  Set c_ispeed & c_ospeed
+       */
+       switch (dcb.BaudRate) {
+               case 300 : s->c_ispeed = s->c_ospeed = B300; break;
+               case 1200 : s->c_ispeed = s->c_ospeed = B1200; break;
+               case 2400 : s->c_ispeed = s->c_ospeed = B2400; break;
+               case 4800 : s->c_ispeed = s->c_ospeed = B4800; break;
+               case 9600 : s->c_ispeed = s->c_ospeed = B9600; break;
+               case 19200 : s->c_ispeed = s->c_ospeed = B19200; break;
+               case 38400 : s->c_ispeed = s->c_ospeed = B38400; break;
+               case 57600 : s->c_ispeed = s->c_ospeed = B57600; break;
+               case 115200 : s->c_ispeed = s->c_ospeed = B115200; break;
+               default : s->c_ispeed = s->c_ospeed = B9600;
+       }
+       
+
+       s->c_cflag = 0;
+       switch (dcb.ByteSize) {
+               case 5 : s->c_cflag |= CS5; break;
+               case 6 : s->c_cflag |= CS6; break;
+               case 7 : s->c_cflag |= CS7; break;
+               case 8 : s->c_cflag |= CS8; break;
+       }
+       if (dcb.fParity) {
+                 s->c_cflag |= PARENB;
+       }
+       switch (dcb.Parity) {
+               case EVENPARITY : break;
+               case MARKPARITY : break;
+               case NOPARITY : break;
+               case ODDPARITY : s->c_cflag |= PARODD; break;
+               case SPACEPARITY : break;
+       }
+       switch (dcb.StopBits) {
+               case ONESTOPBIT : break;
+               case ONE5STOPBITS : break;
+               case TWOSTOPBITS : s->c_cflag |= CSTOPB; break;
+       }
+
+       s->c_iflag = 0;
+       s->c_lflag = 0;
+       s->c_line = 0;
+       s->c_oflag = 0;
+
+       return TRUE; /* ok */
+}
+
+
+extern int tcflush(int fd, int mode) {
+       int Result = 0;
+       HANDLE h = (HANDLE) _get_osfhandle(fd);
+       switch ( mode ) {
+       case TCIFLUSH:
+               Result = PurgeComm(h, PURGE_RXCLEAR);
+               break;
+       case TCOFLUSH:
+               Result = PurgeComm(h, PURGE_TXABORT);
+               break;
+       case TCIOFLUSH:
+               Result = PurgeComm(h, PURGE_RXCLEAR | PURGE_TXABORT);
+               break;
+       }
+       if ( Result == 0 ) return -1;   /* failed */
+       else return 0;                                  /* successful */
+}
+
+
+extern int cfsetispeed(struct termios *tio, int speed) {
+
+return 0;              
+};     
+
+
+extern int cfsetospeed(struct termios *tio, int speed) {
+
+return 0;              
+};     
+
diff --git a/ports/winnt/ntpdate/ntpdate.dsp b/ports/winnt/ntpdate/ntpdate.dsp
new file mode 100644 (file)
index 0000000..118bef9
--- /dev/null
@@ -0,0 +1,146 @@
+# Microsoft Developer Studio Project File - Name="ntpdate" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
+\r
+CFG=ntpdate - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntpdate.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntpdate.mak" CFG="ntpdate - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "ntpdate - Win32 Release" (based on "Win32 (x86) Console Application")\r
+!MESSAGE "ntpdate - Win32 Debug" (based on "Win32 (x86) Console Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""$/ntp/dev/ports/winnt/ntpdate", OWBAAAAA"\r
+# PROP Scc_LocalPath "."\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "ntpdate - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD CPP /nologo /MD /W4 /GX /O2 /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /YX /FD /c\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib /nologo /subsystem:console /machine:I386 /out:"../bin/Release/ntpdate.exe"\r
+\r
+!ELSEIF  "$(CFG)" == "ntpdate - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
+# ADD CPP /nologo /MDd /W4 /Gm /GX /ZI /Od /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /YX /FD /GZ /c\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin/Debug/ntpdate.exe" /pdbtype:sept\r
+# SUBTRACT LINK32 /pdb:none\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "ntpdate - Win32 Release"\r
+# Name "ntpdate - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpdate\ntpdate.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libntp\util_clockstuff.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\version.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpdate\ntpdate.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# End Group\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\configure\r
+\r
+!IF  "$(CFG)" == "ntpdate - Win32 Release"\r
+\r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntpdate \r
+       \r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "ntpdate - Win32 Debug"\r
+\r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntpdate \r
+       \r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/ports/winnt/ntpdate/ntpdate.vcproj b/ports/winnt/ntpdate/ntpdate.vcproj
new file mode 100644 (file)
index 0000000..37e0c14
--- /dev/null
@@ -0,0 +1,327 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="ntpdate"
+       ProjectGUID="{2789A62E-3F46-44F1-AAF0-816CD23C2911}"
+       TargetFrameworkVersion="0"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory=".\Debug"
+                       IntermediateDirectory=".\Debug"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       DeleteExtensionsOnClean="version.c,*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Debug/ntpdate.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               WholeProgramOptimization="false"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\include,$(OPENSSL)\inc32"
+                               PreprocessorDefinitions="_DEBUG;_CONSOLE;WIN32;__STDC__;SYS_WINNT;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               PrecompiledHeaderFile=".\Debug/ntpdate.pch"
+                               AssemblerListingLocation=".\Debug/"
+                               ObjectFile=".\Debug/"
+                               ProgramDataBaseFileName="..\bin\Debug\ntpdate-vc90"
+                               BrowseInformation="1"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib"
+                               OutputFile="../bin/Debug/ntpdate.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Debug\ntpdate.pdb"
+                               SubSystem="1"
+                               LinkTimeCodeGeneration="0"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Debug/ntpdate.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory=".\Release"
+                       IntermediateDirectory=".\Release"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       DeleteExtensionsOnClean="version.c,*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Release/ntpdate.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               InlineFunctionExpansion="1"
+                               WholeProgramOptimization="true"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\include,$(OPENSSL)\inc32"
+                               PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32;__STDC__;SYS_WINNT;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"
+                               StringPooling="true"
+                               RuntimeLibrary="0"
+                               EnableFunctionLevelLinking="true"
+                               PrecompiledHeaderFile=".\Release/ntpdate.pch"
+                               AssemblerListingLocation=".\Release/"
+                               ObjectFile=".\Release/"
+                               ProgramDataBaseFileName="..\bin\Release\ntpdate-vc90"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib"
+                               OutputFile="../bin/Release/ntpdate.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Release\ntpdate.pdb"
+                               SubSystem="1"
+                               LinkTimeCodeGeneration="1"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Release/ntpdate.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+                       >
+                       <File
+                               RelativePath="..\..\..\ntpdate\ntpdate.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libntp\util_clockstuff.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="version.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl"
+                       >
+                       <File
+                               RelativePath="..\..\..\ntpdate\ntpdate.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+                       >
+               </Filter>
+               <File
+                       RelativePath="..\..\..\configure"
+                       >
+                       <FileConfiguration
+                               Name="Debug|Win32"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpdate&#x0D;&#x0A;"
+                                       Outputs="$(ProjectDir)version.c"
+                               />
+                       </FileConfiguration>
+                       <FileConfiguration
+                               Name="Release|Win32"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpdate&#x0D;&#x0A;"
+                                       Outputs="$(ProjectDir)version.c"
+                               />
+                       </FileConfiguration>
+               </File>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/ports/winnt/ntpdc/ntpdc.dsp b/ports/winnt/ntpdc/ntpdc.dsp
new file mode 100644 (file)
index 0000000..5c44491
--- /dev/null
@@ -0,0 +1,153 @@
+# Microsoft Developer Studio Project File - Name="ntpdc" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
+\r
+CFG=ntpdc - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntpdc.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntpdc.mak" CFG="ntpdc - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "ntpdc - Win32 Release" (based on "Win32 (x86) Console Application")\r
+!MESSAGE "ntpdc - Win32 Debug" (based on "Win32 (x86) Console Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""$/ntp/dev/ports/winnt/ntpdc", SWBAAAAA"\r
+# PROP Scc_LocalPath "."\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "ntpdc - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD CPP /nologo /MD /W4 /GX /O2 /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /I "..\..\..\libopts" /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /YX"windows.h" /FD /c\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+# ADD LINK32 kernel32.lib user32.lib ws2_32.lib advapi32.lib /nologo /subsystem:console /machine:I386 /out:"../bin/Release/ntpdc.exe"\r
+\r
+!ELSEIF  "$(CFG)" == "ntpdc - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
+# ADD CPP /nologo /MDd /W4 /Gm /GX /ZI /Od /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /I "..\..\..\libopts" /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /YX"windows.h" /FD /GZ /c\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 kernel32.lib user32.lib ws2_32.lib advapi32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin/Debug/ntpdc.exe" /pdbtype:sept\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "ntpdc - Win32 Release"\r
+# Name "ntpdc - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE="..\..\..\ntpdc\ntpdc-opts.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpdc\ntpdc.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpdc\ntpdc_ops.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libntp\util_clockstuff.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\version.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpdc\ntpdc.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# End Group\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\configure\r
+\r
+!IF  "$(CFG)" == "ntpdc - Win32 Release"\r
+\r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntpdc \r
+       \r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "ntpdc - Win32 Debug"\r
+\r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntpdc \r
+       \r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/ports/winnt/ntpdc/ntpdc.vcproj b/ports/winnt/ntpdc/ntpdc.vcproj
new file mode 100644 (file)
index 0000000..94b6211
--- /dev/null
@@ -0,0 +1,376 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="ntpdc"
+       ProjectGUID="{8011C820-B3D5-4034-86EA-FFC30AE6764B}"
+       TargetFrameworkVersion="0"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory=".\Debug"
+                       IntermediateDirectory=".\Debug"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       DeleteExtensionsOnClean="version.c,*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Debug/ntpdc.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               WholeProgramOptimization="true"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\include,$(OPENSSL)\inc32,..\..\..\libopts"
+                               PreprocessorDefinitions="_DEBUG;_CONSOLE;WIN32;__STDC__;SYS_WINNT;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               PrecompiledHeaderFile=".\Debug/ntpdc.pch"
+                               AssemblerListingLocation=".\Debug/"
+                               ObjectFile=".\Debug/"
+                               ProgramDataBaseFileName="..\bin\Debug\ntpdc-vc90"
+                               BrowseInformation="1"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib"
+                               OutputFile="../bin/Debug/ntpdc.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Debug\ntpdc.pdb"
+                               SubSystem="1"
+                               LinkTimeCodeGeneration="1"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Debug/ntpdc.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory=".\Release"
+                       IntermediateDirectory=".\Release"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       DeleteExtensionsOnClean="version.c,*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Release/ntpdc.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               InlineFunctionExpansion="1"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\include,$(OPENSSL)\inc32,..\..\..\libopts"
+                               PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32;__STDC__;SYS_WINNT;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"
+                               StringPooling="true"
+                               RuntimeLibrary="0"
+                               EnableFunctionLevelLinking="true"
+                               PrecompiledHeaderFile=".\Release/ntpdc.pch"
+                               AssemblerListingLocation=".\Release/"
+                               ObjectFile=".\Release/"
+                               ProgramDataBaseFileName="..\bin\Release\ntpdc-vc90"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib"
+                               OutputFile="../bin/Release/ntpdc.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Release\ntpdc.pdb"
+                               SubSystem="1"
+                               LinkTimeCodeGeneration="0"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Release/ntpdc.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+                       >
+                       <File
+                               RelativePath="..\..\..\ntpdc\ntpdc-opts.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               WarningLevel="3"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               WarningLevel="3"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpdc\ntpdc.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               WarningLevel="3"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               WarningLevel="3"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpdc\ntpdc_ops.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               WarningLevel="3"
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                               WarningLevel="3"
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libntp\util_clockstuff.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="version.c"
+                               >
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl"
+                       >
+                       <File
+                               RelativePath="..\..\..\ntpdc\ntpdc.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+                       >
+               </Filter>
+               <File
+                       RelativePath="..\..\..\configure"
+                       >
+                       <FileConfiguration
+                               Name="Debug|Win32"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpdc&#x0D;&#x0A;"
+                                       Outputs="$(ProjectDir)version.c"
+                               />
+                       </FileConfiguration>
+                       <FileConfiguration
+                               Name="Release|Win32"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpdc&#x0D;&#x0A;"
+                                       Outputs="$(ProjectDir)version.c"
+                               />
+                       </FileConfiguration>
+               </File>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/ports/winnt/ntpq/ntpq.dsp b/ports/winnt/ntpq/ntpq.dsp
new file mode 100644 (file)
index 0000000..8ffb7ec
--- /dev/null
@@ -0,0 +1,153 @@
+# Microsoft Developer Studio Project File - Name="ntpq" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
+\r
+CFG=ntpq - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntpq.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntpq.mak" CFG="ntpq - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "ntpq - Win32 Release" (based on "Win32 (x86) Console Application")\r
+!MESSAGE "ntpq - Win32 Debug" (based on "Win32 (x86) Console Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""$/ntp/dev/ports/winnt/ntpq", WWBAAAAA"\r
+# PROP Scc_LocalPath "."\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "ntpq - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD CPP /nologo /MD /W4 /GX /O2 /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /I "..\..\..\libopts" /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /YX /FD /c\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+# ADD LINK32 kernel32.lib user32.lib ws2_32.lib advapi32.lib /nologo /subsystem:console /machine:I386 /out:"../bin/Release/ntpq.exe"\r
+\r
+!ELSEIF  "$(CFG)" == "ntpq - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
+# ADD CPP /nologo /MDd /W4 /Gm /GX /ZI /Od /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /I "..\..\..\libopts" /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /YX /FD /GZ /c\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 kernel32.lib user32.lib ws2_32.lib advapi32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin/Debug/ntpq.exe" /pdbtype:sept\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "ntpq - Win32 Release"\r
+# Name "ntpq - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE="..\..\..\ntpq\ntpq-opts.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE="..\..\..\ntpq\ntpq-subs.c"\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpq\ntpq.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libntp\util_clockstuff.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\version.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntpq\ntpq.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# End Group\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\configure\r
+\r
+!IF  "$(CFG)" == "ntpq - Win32 Release"\r
+\r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntpq \r
+       \r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "ntpq - Win32 Debug"\r
+\r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntpq \r
+       \r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/ports/winnt/ntpq/ntpq.vcproj b/ports/winnt/ntpq/ntpq.vcproj
new file mode 100644 (file)
index 0000000..bf2b57d
--- /dev/null
@@ -0,0 +1,370 @@
+<?xml version="1.0" encoding="Windows-1252"?>
+<VisualStudioProject
+       ProjectType="Visual C++"
+       Version="9.00"
+       Name="ntpq"
+       ProjectGUID="{6A92BF14-8931-48B1-A571-DEBE9F190616}"
+       TargetFrameworkVersion="0"
+       >
+       <Platforms>
+               <Platform
+                       Name="Win32"
+               />
+       </Platforms>
+       <ToolFiles>
+       </ToolFiles>
+       <Configurations>
+               <Configuration
+                       Name="Release|Win32"
+                       OutputDirectory=".\Release"
+                       IntermediateDirectory=".\Release"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       DeleteExtensionsOnClean="version.c,*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Release/ntpq.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="2"
+                               InlineFunctionExpansion="1"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,$(OPENSSL)\include,$(OPENSSL)\inc32,..\..\..\libopts"
+                               PreprocessorDefinitions="NDEBUG;_CONSOLE;WIN32;SYS_WINNT;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"
+                               StringPooling="true"
+                               RuntimeLibrary="0"
+                               EnableFunctionLevelLinking="true"
+                               PrecompiledHeaderFile=".\Release/ntpq.pch"
+                               AssemblerListingLocation=".\Release/"
+                               ObjectFile=".\Release/"
+                               ProgramDataBaseFileName="..\bin\Release\ntpq-vc90"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="NDEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib"
+                               OutputFile="../bin/Release/ntpq.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Release\ntpq.pdb"
+                               SubSystem="1"
+                               LinkTimeCodeGeneration="0"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Release/ntpq.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+               <Configuration
+                       Name="Debug|Win32"
+                       OutputDirectory=".\Debug"
+                       IntermediateDirectory=".\Debug"
+                       ConfigurationType="1"
+                       InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops"
+                       UseOfMFC="0"
+                       ATLMinimizesCRunTimeLibraryUsage="false"
+                       CharacterSet="2"
+                       DeleteExtensionsOnClean="version.c,*.obj;*.ilk;*.tlb;*.tli;*.tlh;*.tmp;*.rsp;*.pgc;*.pgd;*.meta;$(TargetPath)"
+                       >
+                       <Tool
+                               Name="VCPreBuildEventTool"
+                       />
+                       <Tool
+                               Name="VCCustomBuildTool"
+                       />
+                       <Tool
+                               Name="VCXMLDataGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCWebServiceProxyGeneratorTool"
+                       />
+                       <Tool
+                               Name="VCMIDLTool"
+                               TypeLibraryName=".\Debug/ntpq.tlb"
+                               HeaderFileName=""
+                       />
+                       <Tool
+                               Name="VCCLCompilerTool"
+                               Optimization="0"
+                               WholeProgramOptimization="true"
+                               AdditionalIncludeDirectories=".,..\include,..\..\..\include,,$(OPENSSL)\include,$(OPENSSL)\inc32,..\..\..\libopts"
+                               PreprocessorDefinitions="_DEBUG;_CONSOLE;WIN32;;SYS_WINNT;HAVE_CONFIG_H;_CRT_SECURE_NO_WARNINGS"
+                               MinimalRebuild="true"
+                               BasicRuntimeChecks="3"
+                               RuntimeLibrary="1"
+                               PrecompiledHeaderFile=".\Debug/ntpq.pch"
+                               AssemblerListingLocation=".\Debug/"
+                               ObjectFile=".\Debug/"
+                               ProgramDataBaseFileName="..\bin\Debug\ntpq-vc90"
+                               BrowseInformation="1"
+                               WarningLevel="4"
+                               SuppressStartupBanner="true"
+                               DebugInformationFormat="3"
+                               CompileAs="1"
+                       />
+                       <Tool
+                               Name="VCManagedResourceCompilerTool"
+                       />
+                       <Tool
+                               Name="VCResourceCompilerTool"
+                               PreprocessorDefinitions="_DEBUG"
+                               Culture="1033"
+                       />
+                       <Tool
+                               Name="VCPreLinkEventTool"
+                       />
+                       <Tool
+                               Name="VCLinkerTool"
+                               AdditionalDependencies="ws2_32.lib"
+                               OutputFile="../bin/Debug/ntpq.exe"
+                               Version="0x0400"
+                               LinkIncremental="1"
+                               SuppressStartupBanner="true"
+                               GenerateManifest="false"
+                               GenerateDebugInformation="true"
+                               ProgramDatabaseFile="..\bin\Debug\ntpq.pdb"
+                               SubSystem="1"
+                               LinkTimeCodeGeneration="1"
+                               RandomizedBaseAddress="1"
+                               DataExecutionPrevention="0"
+                               TargetMachine="1"
+                       />
+                       <Tool
+                               Name="VCALinkTool"
+                       />
+                       <Tool
+                               Name="VCManifestTool"
+                       />
+                       <Tool
+                               Name="VCXDCMakeTool"
+                       />
+                       <Tool
+                               Name="VCBscMakeTool"
+                               SuppressStartupBanner="true"
+                               OutputFile=".\Debug/ntpq.bsc"
+                       />
+                       <Tool
+                               Name="VCFxCopTool"
+                       />
+                       <Tool
+                               Name="VCAppVerifierTool"
+                       />
+                       <Tool
+                               Name="VCPostBuildEventTool"
+                       />
+               </Configuration>
+       </Configurations>
+       <References>
+       </References>
+       <Files>
+               <Filter
+                       Name="Source Files"
+                       Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+                       >
+                       <File
+                               RelativePath="..\..\..\ntpq\ntpq-opts.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpq\ntpq-subs.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\..\..\ntpq\ntpq.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="..\libntp\util_clockstuff.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+                       <File
+                               RelativePath="version.c"
+                               >
+                               <FileConfiguration
+                                       Name="Release|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                               <FileConfiguration
+                                       Name="Debug|Win32"
+                                       >
+                                       <Tool
+                                               Name="VCCLCompilerTool"
+                                               AdditionalIncludeDirectories=""
+                                               PreprocessorDefinitions=""
+                                       />
+                               </FileConfiguration>
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Header Files"
+                       Filter="h;hpp;hxx;hm;inl"
+                       >
+                       <File
+                               RelativePath="..\..\..\ntpq\ntpq.h"
+                               >
+                       </File>
+               </Filter>
+               <Filter
+                       Name="Resource Files"
+                       Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+                       >
+               </Filter>
+               <File
+                       RelativePath="..\..\..\configure"
+                       >
+                       <FileConfiguration
+                               Name="Release|Win32"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpq&#x0D;&#x0A;"
+                                       Outputs="$(ProjectDir)version.c"
+                               />
+                       </FileConfiguration>
+                       <FileConfiguration
+                               Name="Debug|Win32"
+                               >
+                               <Tool
+                                       Name="VCCustomBuildTool"
+                                       CommandLine="echo Using NT Shell Script to generate version.c&#x0D;&#x0A;..\scripts\mkver.bat -P ntpq&#x0D;&#x0A;"
+                                       Outputs="$(ProjectDir)version.c"
+                               />
+                       </FileConfiguration>
+               </File>
+       </Files>
+       <Globals>
+       </Globals>
+</VisualStudioProject>
diff --git a/ports/winnt/ntptrace/ntptrace.dsp b/ports/winnt/ntptrace/ntptrace.dsp
new file mode 100644 (file)
index 0000000..29ec0cf
--- /dev/null
@@ -0,0 +1,153 @@
+# Microsoft Developer Studio Project File - Name="ntptrace" - Package Owner=<4>\r
+# Microsoft Developer Studio Generated Build File, Format Version 6.00\r
+# ** DO NOT EDIT **\r
+\r
+# TARGTYPE "Win32 (x86) Console Application" 0x0103\r
+\r
+CFG=ntptrace - Win32 Debug\r
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,\r
+!MESSAGE use the Export Makefile command and run\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntptrace.mak".\r
+!MESSAGE \r
+!MESSAGE You can specify a configuration when running NMAKE\r
+!MESSAGE by defining the macro CFG on the command line. For example:\r
+!MESSAGE \r
+!MESSAGE NMAKE /f "ntptrace.mak" CFG="ntptrace - Win32 Debug"\r
+!MESSAGE \r
+!MESSAGE Possible choices for configuration are:\r
+!MESSAGE \r
+!MESSAGE "ntptrace - Win32 Release" (based on "Win32 (x86) Console Application")\r
+!MESSAGE "ntptrace - Win32 Debug" (based on "Win32 (x86) Console Application")\r
+!MESSAGE \r
+\r
+# Begin Project\r
+# PROP AllowPerConfigDependencies 0\r
+# PROP Scc_ProjName ""$/ntp/dev/ports/winnt/ntptrace", AXBAAAAA"\r
+# PROP Scc_LocalPath "."\r
+CPP=cl.exe\r
+RSC=rc.exe\r
+\r
+!IF  "$(CFG)" == "ntptrace - Win32 Release"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 0\r
+# PROP BASE Output_Dir "Release"\r
+# PROP BASE Intermediate_Dir "Release"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 0\r
+# PROP Output_Dir "Release"\r
+# PROP Intermediate_Dir "Release"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c\r
+# ADD CPP /nologo /MT /W4 /GX /O2 /I "\\" /I "$(OPENSSL)\inc32" /I "." /I "..\include" /I "..\..\..\include" /D "NDEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /YX"windows.h" /FD /c\r
+# ADD BASE RSC /l 0x409 /d "NDEBUG"\r
+# ADD RSC /l 0x409 /d "NDEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386\r
+# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib /nologo /subsystem:console /machine:I386\r
+\r
+!ELSEIF  "$(CFG)" == "ntptrace - Win32 Debug"\r
+\r
+# PROP BASE Use_MFC 0\r
+# PROP BASE Use_Debug_Libraries 1\r
+# PROP BASE Output_Dir "Debug"\r
+# PROP BASE Intermediate_Dir "Debug"\r
+# PROP BASE Target_Dir ""\r
+# PROP Use_MFC 0\r
+# PROP Use_Debug_Libraries 1\r
+# PROP Output_Dir "Debug"\r
+# PROP Intermediate_Dir "Debug"\r
+# PROP Ignore_Export_Lib 0\r
+# PROP Target_Dir ""\r
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c\r
+# ADD CPP /nologo /MTd /W4 /Gm /GX /ZI /Od /I "." /I "..\include" /I "..\..\..\include" /I "$(OPENSSL)\inc32" /D "_DEBUG" /D "_CONSOLE" /D "WIN32" /D "_MBCS" /D "__STDC__" /D "SYS_WINNT" /D "HAVE_CONFIG_H" /D _WIN32_WINNT=0x400 /FR /YX"windows.h" /FD /GZ /c\r
+# ADD BASE RSC /l 0x409 /d "_DEBUG"\r
+# ADD RSC /l 0x409 /d "_DEBUG"\r
+BSC32=bscmake.exe\r
+# ADD BASE BSC32 /nologo\r
+# ADD BSC32 /nologo\r
+LINK32=link.exe\r
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept\r
+# ADD LINK32 kernel32.lib user32.lib advapi32.lib ws2_32.lib /nologo /subsystem:console /debug /machine:I386 /out:"../bin/Debug/ntptrace.exe" /pdbtype:sept\r
+\r
+!ENDIF \r
+\r
+# Begin Target\r
+\r
+# Name "ntptrace - Win32 Release"\r
+# Name "ntptrace - Win32 Debug"\r
+# Begin Group "Source Files"\r
+\r
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntptrace\ntptrace.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\libntp\util_clockstuff.c\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=.\version.c\r
+# End Source File\r
+# End Group\r
+# Begin Group "Header Files"\r
+\r
+# PROP Default_Filter "h;hpp;hxx;hm;inl"\r
+# Begin Source File\r
+\r
+SOURCE=..\include\sys\ioctl.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\ntptrace\ntptrace.h\r
+# End Source File\r
+# Begin Source File\r
+\r
+SOURCE=..\include\sys\resource.h\r
+# End Source File\r
+# End Group\r
+# Begin Group "Resource Files"\r
+\r
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"\r
+# End Group\r
+# Begin Source File\r
+\r
+SOURCE=..\..\..\configure\r
+\r
+!IF  "$(CFG)" == "ntptrace - Win32 Release"\r
+\r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntptrace \r
+       \r
+# End Custom Build\r
+\r
+!ELSEIF  "$(CFG)" == "ntptrace - Win32 Debug"\r
+\r
+# Begin Custom Build\r
+ProjDir=.\r
+InputPath=..\..\..\configure\r
+\r
+"$(ProjDir)\version.c" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"\r
+       echo Using NT Shell Script to generate version.c \r
+       ..\scripts\mkver.bat -P ntptrace \r
+       \r
+# End Custom Build\r
+\r
+!ENDIF \r
+\r
+# End Source File\r
+# End Target\r
+# End Project\r
diff --git a/ports/winnt/scripts/mkver.bat b/ports/winnt/scripts/mkver.bat
new file mode 100755 (executable)
index 0000000..71e6d80
--- /dev/null
@@ -0,0 +1,437 @@
+@echo off
+GOTO PROG
+
+see notes/remarks directly below this header:
+######################################################################
+#
+# Revision: mkver.bat
+# Author:   Frederick Czajka
+# Date:     02/10/2000
+# Purpose:  Provide a NT Shell script to replace the perl script 
+#           that replaced the UNIX mkver shell script.
+#           
+# 
+#
+# Notes:  I had two goals with this script one to only use native
+#         NT Shell commands and two was too emulate the PERL style
+#         output. This required some work for the DATE format as 
+#         you will see and TIME was really tricky to get a format 
+#         matching PERLs!
+#
+#
+# Changes:
+# 08/08/2006   Heiko Gerstung
+#                              - bugfixed point / rcpoint errors leading to a wrong
+#                                version string 
+#                              - added a few cases for uppercase strings
+# 03/09/2005   Heiko Gerstung
+#                              - added UTC offset to version time information
+#                              - bugfixed several issues preventing this script to be used on NT4 
+#                              - removed an obsolete warning
+#
+# 03/08/2005   Danny Mayer
+#                              - bugfixed NOBK label position
+#
+# 03/08/2005   Heiko Gerstung
+#                              - bugfixed BK detection and support for multiple ChangeSets 
+#                              
+# 02/24/2005   Heiko Gerstung
+#                              - check if BK is installed and do not try to call it if not
+#
+#
+# 02/03/2005   Heiko Gerstung
+#                              - now getting NTP version from version.m4 (not configure)
+#                              - added BK ChangeSet revision and Openssl-Indicator (-o) 
+#                                to the version number
+#                              - major rework of the time and date recognition routines
+#                                in order to reflect international settings and OS-
+#                                dependand formats
+#
+######################################################################
+
+Notes/Howtos:
+
+If you spot an error stating that bk.exe could not be found or executed
+although it is installed on your computer, you should try to add the path 
+to your BK binary in your IDE configuration (for VisualStudio see 
+Tools/Options/Directories/Executables).
+
+Alternatively you can create a file called 'version' in the root path of 
+your ntp source tree which holds a string that is added to the version number.
+
+
+:PROG
+IF {%1} == {} GOTO USAGE
+IF {%1} == {-H} GOTO USAGE
+IF {%2} == {} GOTO USAGE
+IF {%1} == {-P} GOTO BEGIN
+
+
+
+REM *****************************************************************************************************************
+REM For any other bizarre permutation...
+REM *****************************************************************************************************************
+GOTO USAGE
+
+:BEGIN
+
+SET GENERATED_PROGRAM=%2
+
+REM *****************************************************************************************************************
+REM Reimplemented from orginal Unix Shell script
+REM *****************************************************************************************************************
+       IF NOT EXIST .version ECHO 0 > .version
+       FOR /F %%i IN (.version) do @SET RUN=%%i
+       SET /A RUN=%RUN%+1
+       ECHO %RUN% > .version
+
+REM *****************************************************************************************************************
+REM Resetting variables
+REM *****************************************************************************************************************
+       SET VER=
+       SET CSET=
+       SET SSL=
+       SET MYDATE=
+       SET MYTIME=
+       SET DAY=99
+       SET NMM=99
+       SET YEAR=0
+       SET HOUR=
+       SET MIN=
+       SET MMIN=
+       SET SEC=
+       SET SUBSEC=
+       SET DATEDELIM=
+       SET TIMEDELIM=
+       SET DATEFORMAT=
+       SET TIMEFORMAT=
+       SET UTC=
+       SET ACTIVEBIAS=
+
+REM *****************************************************************************************************************
+REM Check if DATE and TIME environment variables are available
+REM *****************************************************************************************************************
+
+       SET MYDATE=%DATE%
+       SET MYTIME=%TIME%
+
+       REM ** Not available (huh? Are you older than NT4SP6A, grandpa?)
+       IF "%MYDATE%" == "" FOR /F "TOKENS=1 DELIMS=" %%a IN ('date/t') DO SET MYDATE=%%a
+       IF "%MYTIME%" == "" FOR /F "TOKENS=1 DELIMS=" %%a IN ('time/t') DO SET MYTIME=%%a
+
+REM *****************************************************************************************************************
+REM Try to find out UTC offset 
+REM *****************************************************************************************************************
+
+       REM *** Start with setting a dummy value which is used when we are not able to find out the real UTC offset
+       SET UTC=(LOCAL TIME)
+       SET UTC_HR=
+       SET UTC_MIN=
+       SET UTC_SIGN=
+       
+       REM *** Now get the timezone settings from the registry
+       regedit /e %TEMP%\TZ.TMP "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\TimeZoneInformation"
+       IF NOT EXIST %TEMP%\TZ.TMP GOTO NOTZINFO
+
+       for /f "Tokens=1* Delims==" %%a in ('type %TEMP%\TZ.TMP') do if %%a == "ActiveTimeBias" SET ACTIVEBIAS=%%b
+       for /f "Tokens=1* Delims=:" %%a in ('echo %ACTIVEBIAS%') do ( SET ACTIVEBIAS=%%b & SET PARTYP=%%a )
+       
+       REM *** Clean up temporary file
+       IF EXIST %TEMP%\TZ.TMP DEL %TEMP%\TZ.TMP
+       
+       REM *** Check if we really got a dword value from the registry ...
+       IF NOT "%PARTYP%"=="dword " goto NOTZINFO
+
+       REM *** Check if we are in UTC timezone, then we can avoid some stress...
+       if "%ACTIVEBIAS%" == "00000000" SET UTC=(UTC) & GOTO NOTZINFO
+       
+       SET HI=0x%ACTIVEBIAS:~0,4%
+       SET LO=0x%ACTIVEBIAS:~4,4%
+       
+       if "%HI%"=="0xffff" ( SET /A ACTIVEBIAS=%LO% - %HI% - 1 ) ELSE ( SET /A ACTIVEBIAS=%LO%)
+       SET /A UTC_HR="%ACTIVEBIAS%/60"
+       SET /A UTC_MIN="%ACTIVEBIAS% %% 60"
+       SET UTC_SIGN=%ACTIVEBIAS:~0,1%
+
+       REM *** check the direction in which the local timezone alters UTC time
+       IF NOT "%UTC_SIGN%"=="-" SET UTC_SIGN=+
+       IF "%UTC_SIGN%"=="-" SET UTC_HR=%UTC_HR:~1,2%
+
+       REM *** Now turn the direction, because we need to know it from the viewpoint of UTC
+       IF "%UTC_SIGN%"=="+" (SET UTC_SIGN=-) ELSE (SET UTC_SIGN=+)
+
+       REM *** Put the values in a "00" format
+       IF %UTC_HR% LEQ 9 SET UTC_HR=0%UTC_HR%
+       IF %UTC_MIN% LEQ 9 SET UTC_MIN=0%UTC_MIN%
+                       
+       REM *** Set up UTC offset string used in version string
+       SET UTC=(UTC%UTC_SIGN%%UTC_HR%:%UTC_MIN%)
+       
+       
+:NOTZINFO
+echo off
+
+REM *****************************************************************************************************************
+REM Now grab the Version number out of the source code (using the version.m4 file...)
+REM *****************************************************************************************************************
+
+       REM First, get the main NTP version number. In recent versions this must be extracted 
+       REM from a packageinfo.sh file while in earlier versions the info was available from 
+       REM a version.m4 file.
+       SET F_PACKAGEINFO_SH=..\..\..\packageinfo.sh
+       TYPE ..\..\..\packageinfo.sh | FIND /V "rcpoint=" | FIND "point=" > point.txt
+       SET F_POINT_SH=point.txt
+       
+       SET F_VERSION_M4=..\..\..\version.m4
+       IF EXIST %F_PACKAGEINFO_SH% goto VER_FROM_PACKAGE_INFO
+       IF EXIST ..\..\..\version.m4 goto VER_FROM_M4
+        goto ERRNOVERF
+
+:VER_FROM_PACKAGE_INFO
+       REM Get version from packageinfo.sh file, which contains lines reading e.g.
+       
+       FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr  "proto=" %%F_PACKAGEINFO_SH%%') DO SET PROTO=%%a
+       FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr  "major=" %%F_PACKAGEINFO_SH%%') DO SET MAJOR=%%a
+       FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr  "minor=" %%F_PACKAGEINFO_SH%%') DO SET MINOR=%%a
+
+       FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr  "point=" %%F_POINT_SH%%') DO SET POINT=%%a
+       IF NOT "%POINT%"=="" set POINT=p%POINT%
+       IF "%POINT%"=="NEW" set POINT=
+
+       FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr  "rcpoint=" %%F_PACKAGEINFO_SH%%') DO SET RCPOINT=%%a
+
+       FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr  "special=" %%F_PACKAGEINFO_SH%%') DO SET SPECIAL=%%a
+       IF NOT "%SPECIAL%"=="" set SPECIAL=-%SPECIAL%
+
+       FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr  "releasecandidate=" %%F_PACKAGEINFO_SH%%') DO SET REL_CAND_STR=%%a
+       IF /I "%REL_CAND_STR%"=="yes" set REL_CAND=-RC
+       IF /I "%REL_CAND_STR%"=="Yes" set REL_CAND=-RC
+       IF /I "%REL_CAND_STR%"=="YES" set REL_CAND=-RC
+       IF /I "%REL_CAND_STR%"=="Y" set REL_CAND=-RC
+       IF /I "%REL_CAND_STR%"=="y" set REL_CAND=-RC
+
+       FOR /F "eol=# TOKENS=2 DELIMS==" %%a IN ('findstr  "repotype=" %%F_PACKAGEINFO_SH%%') DO SET REPOTYPE=%%a
+       IF "%REPOTYPE%"=="stable" set REPOTYPE=STABLE
+       IF "%REPOTYPE%"=="Stable" set REPOTYPE=STABLE
+       
+       IF NOT "%REPOTYPE%"=="STABLE" SET RCPOINT=
+
+       SET VER=%PROTO%.%MAJOR%.%MINOR%%POINT%%SPECIAL%%REL_CAND%%RCPOINT%
+       
+       goto VER_GET_CSET
+       
+
+:VER_FROM_M4
+       REM Get version from version.m4 file, which contains a line reading e.g.
+       REM m4_define([VERSION_NUMBER],[4.2.0b-rc1])
+       FOR /F "TOKENS=4 DELIMS==[] " %%a IN ('findstr  "VERSION_NUMBER" ..\..\..\version.m4') DO @SET VER=%%a
+       echo --- %VER% ---
+
+:VER_GET_CSET
+       REM Now we have the version info, try to add a BK ChangeSet version number
+       
+       REM ** Check if BK is installed ...
+       bk -R prs -hr+ -nd:I: ChangeSet 2> NUL > NUL
+       IF ERRORLEVEL 1 GOTO NOBK
+
+       REM ** Try to get the CSet rev directly from BK
+       FOR /F "TOKENS=1 DELIMS==" %%a IN ('bk.exe -R prs -hr+ -nd:I: ChangeSet') DO @SET CSET=%%a
+
+:NOBK
+       REM ** If that was not successful, we'll take a look into a version file, if available
+       IF EXIST ..\..\..\version ( 
+               IF "%CSET%"=="" FOR /F "TOKENS=1" %%a IN ('type ..\..\..\version') DO @SET CSET=%%a
+       )
+
+       REM ** Now, expand our version number with the CSet revision, if we managed to get one
+       IF NOT "%CSET%"=="" SET VER=%VER%@%CSET%
+               
+       REM We can add a "crypto" identifier (-o) if we see that Crypto support is included in our build
+       IF NOT EXIST ..\include\config.h goto ERRNOCONF
+       FOR /F "TOKENS=1-3 " %%a IN ('findstr /R "^#define\ OPENSSL" ..\include\config.h') DO @SET SSL=%%c
+       IF "%SSL%"=="1" SET VER=%VER%-o
+
+
+REM *****************************************************************************************************************
+REM Check for user settings regarding the time and date format, we use the registry to find out...
+REM *****************************************************************************************************************
+
+
+       REM Any temporary files left from a previous run? Go where you belong...
+       IF exist userset.reg del userset.reg
+       IF exist userset.txt del userset.txt
+       
+       regedit /E userset.reg "HKEY_CURRENT_USER\Control Panel\International"
+       IF not exist userset.reg goto ERRNOREG
+
+       rem *** convert from unicode to ascii if necessary
+       type userset.reg > userset.txt
+
+
+       FOR /F "TOKENS=1-9 DELIMS== " %%a IN ('findstr "iDate" userset.txt') DO SET DATEFORMAT=%%b
+       FOR /F "TOKENS=1-9 DELIMS== " %%a IN ('findstr "iTime" userset.txt') DO SET TIMEFORMAT=%%b
+
+       FOR /F "TOKENS=1-9 DELIMS== " %%a IN ('findstr /R "sDate\>" userset.txt') DO SET DATEDELIM=%%b
+       FOR /F "TOKENS=1-9 DELIMS== " %%a IN ('findstr /R "sTime\>" userset.txt') DO SET TIMEDELIM=%%b
+       
+       IF "%TIMEFORMAT%"=="" GOTO ERRNOTIME
+       IF "%DATEFORMAT%"=="" GOTO ERRNODATE
+       IF "%TIMEDELIM%"=="" GOTO ERRNOTIME
+       IF "%DATEDELIM%"=="" GOTO ERRNODATE
+
+       SET TIMEDELIM=%TIMEDELIM:~1,1%
+       SET DATEDELIM=%DATEDELIM:~1,1%
+       SET TIMEFORMAT=%TIMEFORMAT:~1,1%
+       SET DATEFORMAT=%DATEFORMAT:~1,1%
+       
+REM *****************************************************************************************************************
+REM Well, well. Its time to look at the time and format it in a standard way (if possible)
+REM *****************************************************************************************************************
+
+
+       FOR /F "TOKENS=1-4 DELIMS=%TIMEDELIM% " %%a IN ('echo %MYTIME%') DO SET AA=%%a&SET BB=%%b&SET CC=%%c&SET DD=%%d
+
+       REM 12H Format
+       IF "%TIMEFORMAT%" == "0" (
+               SET HOUR=%AA%
+               SET MIN=%BB%
+               FOR /F "USEBACKQ TOKENS=1 DELIMS=ap" %%a IN ('%BB%') DO SET MMIN=%%a
+               SET SEC=%CC%
+               SET SUBSEC=%DD%
+       )
+
+       REM Get rid of the "a" or "p" if we have one of these in our minute string
+       IF NOT "%MMIN%"=="%MIN%" FOR /F "USEBACKQ TOKENS=1 DELIMS=ap " %%a IN ('%MIN%') DO SET MIN=%%a
+
+       REM 24H Format
+       IF "%TIMEFORMAT%" == "1" (
+               SET HOUR=%AA%
+               SET MIN=%BB%
+               SET SEC=%CC%
+               SET SUBSEC=%DD%
+       )
+
+       IF "%HOUR%"=="" GOTO ERRNOTIME
+       IF "%MIN%"=="" GOTO ERRNOTIME
+       
+       IF "%SEC%"=="" SET SEC=00
+       IF "%SUBSEC%"=="" SET SUBSEC=00
+
+
+REM *****************************************************************************************************************
+REM It's time to format the date :-)
+REM *****************************************************************************************************************
+
+
+       FOR /F "TOKENS=1-4 DELIMS=./- " %%a IN ('ECHO %MYDATE%') DO SET AA=%%a&SET BB=%%b&SET CC=%%c&SET DD=%%d
+
+       IF "%DD%" == "" (
+               REM No Day of Week in Date
+               ( IF "%DATEFORMAT%" == "0" SET DOW=_&SET DAY=%BB%&SET NMM=%AA%&SET YEAR=%CC% )
+               ( IF "%DATEFORMAT%" == "1" SET DOW=_&SET DAY=%AA%&SET NMM=%BB%&SET YEAR=%CC% )
+               ( IF "%DATEFORMAT%" == "2" SET DOW=_&SET DAY=%CC%&SET NMM=%BB%&SET YEAR=%AA% )
+       ) ELSE (
+               ( IF "%DATEFORMAT%" == "0" SET DOW=%AA%&SET DAY=%CC%&SET NMM=%BB%&SET YEAR=%DD% )
+               ( IF "%DATEFORMAT%" == "1" SET DOW=%AA%&SET DAY=%BB%&SET NMM=%CC%&SET YEAR=%DD% )
+               ( IF "%DATEFORMAT%" == "2" SET DOW=%AA%&SET DAY=%DD%&SET NMM=%CC%&SET YEAR=%BB% )
+       )
+       
+       REM Something went wrong, we weren't able to get a valid date
+       IF NOT "%YEAR%" == "0" GOTO DATEOK
+       goto ERRNODATE
+
+:DATEOK
+
+       REM Clean up any temporary files we may have created...
+       REM IF exist userset.reg del userset.reg
+       REM IF exist userset.txt del userset.txt
+
+       IF "%NMM%" == "01" SET MONTH=Jan
+       IF "%NMM%" == "02" SET MONTH=Feb
+       IF "%NMM%" == "03" SET MONTH=Mar
+       IF "%NMM%" == "04" SET MONTH=Apr
+       IF "%NMM%" == "05" SET MONTH=May
+       IF "%NMM%" == "06" SET MONTH=Jun
+       IF "%NMM%" == "07" SET MONTH=Jul
+       IF "%NMM%" == "08" SET MONTH=Aug
+       IF "%NMM%" == "09" SET MONTH=Sep
+       IF "%NMM%" == "10" SET MONTH=Oct
+       IF "%NMM%" == "11" SET MONTH=Nov
+       IF "%NMM%" == "12" SET MONTH=Dec
+
+       IF NOT {%MONTH%} == {} GOTO DATE_OK
+
+       REM *** Not US date format! Assume ISO: yyyy-mm-dd
+
+       FOR /F "TOKENS=1-4 DELIMS=/- " %%a IN ('date/t') DO SET DAY=%%a&SET yyyy=%%b&SET nmm=%%c&SET dd=%%d
+
+       echo a=%%a b=%%b c=%%c d=%%d
+       IF "%NMM%" == "01" SET MONTH=Jan
+       IF "%NMM%" == "02" SET MONTH=Feb
+       IF "%NMM%" == "03" SET MONTH=Mar
+       IF "%NMM%" == "04" SET MONTH=Apr
+       IF "%NMM%" == "05" SET MONTH=May
+       IF "%NMM%" == "06" SET MONTH=Jun
+       IF "%NMM%" == "07" SET MONTH=Jul
+       IF "%NMM%" == "08" SET MONTH=Aug
+       IF "%NMM%" == "09" SET MONTH=Sep
+       IF "%NMM%" == "10" SET MONTH=Oct
+       IF "%NMM%" == "11" SET MONTH=Nov
+       IF "%NMM%" == "12" SET MONTH=Dec
+
+:DATE_OK
+       IF "%SS" == "" SET SS="00"
+
+
+REM *****************************************************************************************************************
+REM Now create a valid version.c file ...
+REM *****************************************************************************************************************
+
+       ECHO Version %VER% Build %RUN% date %MONTH%/%DAY%/%YEAR% time %HOUR%:%MIN%:%SEC% %UTC%
+       ECHO char * Version = "%GENERATED_PROGRAM% %VER% %MONTH% %DAY% %HOUR%:%MIN%:%SEC% %UTC% %YEAR% (%RUN%)" ; > version.c
+       GOTO EOF
+
+
+REM *****************************************************************************************************************
+REM Here are the error messages I know
+REM *****************************************************************************************************************
+:ERRNOREG
+   ECHO "Error: Registry could not be read (check if regedit.exe is available and works as expected)"
+   GOTO EOF
+
+
+:ERRNODATE
+    ECHO "Error: Dateformat unknown (check if contents of userset.txt are correctly, especially for iDate and sDate)"
+       GOTO EOF
+
+:ERRNOTIME
+    ECHO "Error: Timeformat unknown (check if contents of userset.txt are correctly, especially for iTime and sTime)"
+       GOTO EOF
+
+:ERRNOVERF
+    ECHO "Error: Version file not found (searching for ../../../version.m4)"
+       GOTO EOF
+
+:ERRNOCONF
+    ECHO "Error: Config.h file not found (searching for ../include/config.h)"
+       GOTO EOF
+
+
+REM *****************************************************************************************************************
+REM Show'em how to run (me)
+REM *****************************************************************************************************************
+:USAGE
+
+   ECHO Usage: mkver.bat [ -P <Program Name> -H ]
+   ECHO   -P          Database Name
+   ECHO   -H          Help on options
+
+REM *****************************************************************************************************************
+REM All good things come to an end someday. Time to leave
+REM *****************************************************************************************************************
+:EOF
+
+REM *** Cleaning up 
+IF EXIST point.txt DEL point.txt
+IF EXIST userset.txt DEL userset.txt
+IF EXIST userset.reg DEL userset.reg
diff --git a/readme.y2kfixes b/readme.y2kfixes
new file mode 100644 (file)
index 0000000..e9a63c1
Binary files /dev/null and b/readme.y2kfixes differ
diff --git a/results.y2kfixes b/results.y2kfixes
new file mode 100644 (file)
index 0000000..32f42cf
--- /dev/null
@@ -0,0 +1,76 @@
+Script started on Sat Jan  1 04:14:09 2000
+[root@timetest ntpdate]# date
+Sat Jan  1 04:14:11 EST 2000
+[root@timetest ntpdate]# ./ntpdate -b timelord.att.com
+14 Jul 13:44:39 ntpdate[11723]: step time server 135.16.xxxx.xxxx offset -14740193.210537 sec
+[root@timetest ntpdate]# date
+Wed Jul 14 13:44:42 EST 1999
+[root@timetest ntpdate]# cd ../ntptrace
+[root@timetest ntptrace]# ./ntptrace timelord.att.com
+timelord.att.com: stratum 2, offset -0.000879, synch distance 0.07207
+timemaster.att.com: stratum 1, offset -0.004876, synch distance 0.03485, refid 'GPS'
+[root@timetest ntptrace]# cd -
+[root@timetest ntpdate]# date
+Mon Feb 28 01:00:04 EST 2000
+[root@timetest ntpdate]# ./ntpdate -b timelord.att.com
+14 Jul 13:49:01 ntpdate[11760]: step time server 135.16.xxxx.xxxx offset -19739467.533126 sec
+[root@timetest ntpdate]# date
+Wed Jul 14 13:49:03 EST 1999
+[root@timetest ntpdate]# cd -
+[root@timetest ntptrace]# ./ntptrace timelord.att.com
+timelord.att.com: stratum 2, offset 0.001383, synch distance 0.05644
+timemaster.att.com: stratum 1, offset -0.006355, synch distance 0.04178, refid 'GPS'
+[root@timetest ntptrace]# cd -
+[root@timetest ntpdate]# date
+Tue Feb 29 01:00:05 EST 2000
+[root@timetest ntpdate]# ./ntpdate -b timelord.att.com
+14 Jul 13:57:41 ntpdate[12423]: step time server 135.16.xxxx.xxxx offset -19825349.396585 sec
+[root@timetest ntpdate]# date
+Wed Jul 14 13:57:43 EST 1999
+[root@timetest ntpdate]# cd -
+[root@timetest ntptrace]# ./ntptrace timelord.att.com
+timelord.att.com: stratum 2, offset -0.000094, synch distance 0.06522
+timemaster.att.com: stratum 1, offset -0.010803, synch distance 0.03078, refid 'GPS'
+[root@timetest ntptrace]# cd -
+[root@timetest ntpdate]# date 
+Wed Mar  1 01:00:03 EST 2000
+[root@timetest ntpdate]# ./ntpdate -b timelord.att.com
+14 Jul 13:58:10 ntpdate[12525]: step time server 135.16.xxxx.xxxx offset -19911719.766061 sec
+[root@timetest ntpdate]# date
+Wed Jul 14 13:58:12 EST 1999
+[root@timetest ntpdate]# cd -
+[root@timetest ntptrace]# ./ntptrace timelord.att.com
+timelord.att.com: stratum 2, offset -0.000719, synch distance 0.06561
+timemaster.att.com: stratum 1, offset -0.013598, synch distance 0.03116, refid 'GPS'
+
+Script done on Wed Jul 14 13:58:28 1999
+
+RESULTS OK.
+--------------------END OF TEST1-------------------- 
+
+
+### freeware test configuration
+server 127.127.1.0 prefer
+fudge 127.127.1.0 stratum 0
+driftfile drift.log
+
+
+ntpdate timelord.att.com
+server 135.16.xxxx.xxxx stratum 1, offset 0.000033, delay 0.02975
+31 Dec 23:58:59 ntpdate[83551]: adjust time server 135.16.74.3 offset 0.039057 s
+ec
+
+ntpdate timelord.att.com
+server 135.16.xxxx.xxxx stratum 1, offset 0.000019, delay 0.02504
+01 Jan 00:01:05 ntpdate[8352]: adjust time server 135.16.74.3 offset 0.039057 s
+ec
+
+ntpdate timelord.att.com
+server 135.25.xxxx.xxxx, stratum 1, offset -0.000023, delay 0.02731
+29 Feb 00:02:15 ntpdate[8353]: adjust time server 135.25.xxxx.xxxx offset -0.000023 sec
+
+
+
+
+
+
diff --git a/scripts/Makefile.am b/scripts/Makefile.am
new file mode 100644 (file)
index 0000000..76d7655
--- /dev/null
@@ -0,0 +1,5 @@
+bin_SCRIPTS=   ntp-wait ntptrace
+noinst_SCRIPTS=        calc_tickadj checktime freq_adj html2man mkver ntpsweep ntpver plot_summary summary
+EXTRA_DIST = VersionName fixautomakedepsmagic genCommitLog genver      \
+       hpadjtime.sh monitoring ntp-close ntp-groper ntp-restart        \
+       ntp-status rc1 rc2 stats
diff --git a/scripts/Makefile.in b/scripts/Makefile.in
new file mode 100644 (file)
index 0000000..8577e77
--- /dev/null
@@ -0,0 +1,470 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = scripts
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       $(srcdir)/calc_tickadj.in $(srcdir)/checktime.in \
+       $(srcdir)/freq_adj.in $(srcdir)/html2man.in $(srcdir)/mkver.in \
+       $(srcdir)/ntp-wait.in $(srcdir)/ntpsweep.in \
+       $(srcdir)/ntptrace.in $(srcdir)/ntpver.in \
+       $(srcdir)/plot_summary.in $(srcdir)/summary.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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES = calc_tickadj checktime freq_adj html2man mkver \
+       ntp-wait ntpsweep ntptrace ntpver plot_summary summary
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(bindir)"
+SCRIPTS = $(bin_SCRIPTS) $(noinst_SCRIPTS)
+SOURCES =
+DIST_SOURCES =
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+bin_SCRIPTS = ntp-wait ntptrace
+noinst_SCRIPTS = calc_tickadj checktime freq_adj html2man mkver ntpsweep ntpver plot_summary summary
+EXTRA_DIST = VersionName fixautomakedepsmagic genCommitLog genver      \
+       hpadjtime.sh monitoring ntp-close ntp-groper ntp-restart        \
+       ntp-status rc1 rc2 stats
+
+all: all-am
+
+.SUFFIXES:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign scripts/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign scripts/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+calc_tickadj: $(top_builddir)/config.status $(srcdir)/calc_tickadj.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+checktime: $(top_builddir)/config.status $(srcdir)/checktime.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+freq_adj: $(top_builddir)/config.status $(srcdir)/freq_adj.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+html2man: $(top_builddir)/config.status $(srcdir)/html2man.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+mkver: $(top_builddir)/config.status $(srcdir)/mkver.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+ntp-wait: $(top_builddir)/config.status $(srcdir)/ntp-wait.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+ntpsweep: $(top_builddir)/config.status $(srcdir)/ntpsweep.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+ntptrace: $(top_builddir)/config.status $(srcdir)/ntptrace.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+ntpver: $(top_builddir)/config.status $(srcdir)/ntpver.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+plot_summary: $(top_builddir)/config.status $(srcdir)/plot_summary.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+summary: $(top_builddir)/config.status $(srcdir)/summary.in
+       cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@
+install-binSCRIPTS: $(bin_SCRIPTS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do \
+         if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+         if test -f "$$d$$p"; then echo "$$d$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n' \
+           -e 'h;s|.*|.|' \
+           -e 'p;x;s,.*/,,;$(transform)' | sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1; } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) { files[d] = files[d] " " $$1; \
+             if (++n[d] == $(am__install_max)) { \
+               print "f", d, files[d]; n[d] = 0; files[d] = "" } } \
+           else { print "f", d "/" $$4, $$1 } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+            if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+            test -z "$$files" || { \
+              echo " $(INSTALL_SCRIPT) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+              $(INSTALL_SCRIPT) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+            } \
+       ; done
+
+uninstall-binSCRIPTS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_SCRIPTS)'; test -n "$(bindir)" || exit 0; \
+       files=`for p in $$list; do echo "$$p"; done | \
+              sed -e 's,.*/,,;$(transform)'`; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+tags: TAGS
+TAGS:
+
+ctags: CTAGS
+CTAGS:
+
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(SCRIPTS)
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+maintainer-clean-generic:
+       @echo "This command is intended for maintainers to use"
+       @echo "it deletes files that may require special tools to rebuild."
+clean: clean-am
+
+clean-am: clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-am
+       -rm -f Makefile
+distclean-am: clean-am distclean-generic
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binSCRIPTS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-generic mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binSCRIPTS
+
+.MAKE: install-am install-strip
+
+.PHONY: all all-am check check-am clean clean-generic clean-libtool \
+       distclean distclean-generic distclean-libtool distdir dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-binSCRIPTS 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-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       uninstall uninstall-am uninstall-binSCRIPTS
+
+
+# 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.
+.NOEXPORT:
diff --git a/scripts/README b/scripts/README
new file mode 100644 (file)
index 0000000..673ddb4
--- /dev/null
@@ -0,0 +1,43 @@
+README file for directory ./scripts of the NTP Version 4 distribution
+
+This directory contains shell and perl script files for the configuration,
+monitoring and support of NTP installations. See the README and RELNOTES
+files in the parent directory for directions on how to use these files.
+
+calc_tickadj   Calculates "optimal" value for tick given ntp.drift file
+
+freq_adj       Calculates and optionally sets the clock frequency
+               based on ntp.drift .  For FreeBSD systems.
+
+mkver.in       script to create new version numbers for all sources
+
+monitoring      directory containing perl scripts useful for monitoring
+                operations
+
+rc1            start/stop scripts for NTP
+
+rc2            start/stop script for NTP
+
+ntp-close      find public stratum 2 servers that don't respond
+
+ntp-groper     script useful for reaching out and rattling the cages of
+               NTP peers to see if animals are inside the bars
+
+ntp-restart    script useful for killing and restarting the NTP daemon
+
+ntp-wait       Blocks until ntpd is in state 4 (synchronized).
+               Hopefully useful at boot time, to delay the boot sequence
+               until after "ntpd -g" has set the time.
+
+ntpsweep       prints per host given in <file> the NTP stratum level, the
+               clock offset in seconds, the daemon version, the operating
+               system and the processor.
+
+ntpver         What version of the NTP daemon is running?
+
+stats          directory containing awk and shell scripts useful for
+               maintaining statistics summaries of clockstats, loopstats
+               and peerstats files
+
+support         directory containing shell and perl scripts useful for
+                configuration and monitoring of NTP subnets
diff --git a/scripts/VersionName b/scripts/VersionName
new file mode 100755 (executable)
index 0000000..f601cc3
--- /dev/null
@@ -0,0 +1,41 @@
+#! /bin/sh
+# This script must be executed from the TLD of the source tree...
+. ./packageinfo.sh
+
+NAME="$version"
+case $point in
+ [0-9]*)
+    NAME="${NAME}p$point"
+    ;;
+ NEW) ;;
+ '') ;;
+ *) echo "Unexpected value for 'point' <$point>!"
+    exit 1
+    ;;
+esac
+
+case $special in
+ '') ;;
+ *) NAME="${NAME}-$special" ;;
+esac
+
+case $releasecandidate in
+ [Nn][Oo]) ;;
+ [Yy][Ee][Ss]) NAME="${NAME}-RC" ;;
+ *) echo "Unexpected value for 'releasecandidate' <$releasecandidate>!"
+    exit 1
+    ;;
+esac
+
+case $repotype in
+ stable)
+    case $rcpoint in
+     [0-9]*)
+       NAME="${NAME}$rcpoint"
+       ;;
+    esac
+    ;;
+esac
+
+echo "$NAME"
diff --git a/scripts/calc_tickadj.in b/scripts/calc_tickadj.in
new file mode 100644 (file)
index 0000000..32eae12
--- /dev/null
@@ -0,0 +1,38 @@
+#! @PATH_PERL@
+#
+# drift of 104.8576 -> +1 tick.  Base  of 10000 ticks.
+#
+# 970306 HMS Deal with nanoseconds.  Fix sign of adjustments.
+
+$df="/etc/ntp.drift";
+# Assumes a 100Hz box with "tick" of 10000
+# Someday, we might call "tickadj" for better values...
+$base=10000;   # tick: 1,000,000 / HZ
+$cvt=104.8576; # 2 ** 20 / $base
+$v1=0.;
+$v2="";
+
+if (open(DF, $df))
+  {
+    if ($_=<DF>)
+      {
+        ($v1, $v2) = split;
+      }
+
+    while ($v1 < 0)
+      {
+        $v1 += $cvt;
+        $base--;
+      }
+
+    while ($v1 > $cvt)
+      {
+        $v1 -= $cvt;
+        $base++;
+      }
+  }
+
+printf("%.3f (drift)\n", $v1);
+
+printf("%d usec; %d nsec\n", $base, ($base + ($v1/$cvt)) * 1000);
+
diff --git a/scripts/checktime.in b/scripts/checktime.in
new file mode 100644 (file)
index 0000000..2fe8f71
--- /dev/null
@@ -0,0 +1,79 @@
+#! @PATH_PERL@
+#! @PATH_PERL@ -d
+# 
+# This script compares the time of several machines with the
+# time on the local host.
+#
+# Use or modify it as you wish. 
+#
+# As the original author is only expecting 14 minutes of fame, 
+# leaving his name attached would be appreciated.
+#
+# R. Gary Cutbill <rgary@chrysalis.com>
+# 21 April 1999
+#
+$tol=2.0;
+$|=1;
+print "Time Check";
+
+open(HOSTS,"ypcat hosts.byaddr |");  # get a list of hosts from the yp server.
+
+while ($line=<HOSTS>) { # loop for each host getting the offset compared to localhost
+       ($addr,$host,$aliases)=split(/\s+/,$line,3);
+        $res=`/usr/local/bin/ntptrace -m 1 -r 1 -t 1 $host`;
+       print ".";
+       chop $res;
+        push (@results,$res);
+}
+print "\n";
+
+
+#
+# Sort the list of hosts, and print out there offsets
+# from the local host.  
+#
+@list=sort appropriately @results;
+foreach $i ( @list ) {
+
+   @dargs=split(/\s+/,$i);
+   if ( $dargs[1] eq "\*Timeout\*" ) { 
+     print "$i\n";
+     chop $dargs[0];
+     push(@down,$dargs[0]);
+   } else {
+     printf "%-25s %7s %3s %6s %10s %5s %8s %8s\n",@dargs;
+     if ( ( $dargs[4] > $tol ) || ( $dargs[4] < -$tol ) ) { 
+        chop $dargs[0];
+         push(@toofarout,$dargs[0]); }
+   }
+}
+#
+# When the above list finishes, hosts that are different by +/- $tol (two seconds)
+# are in @toofarout.  Hosts that are down are in @down. They are treated the same
+# way here, but you might want to do something different depending on your site.
+#
+# print a set of suggested rsh commands to run on the hosts that 
+# don't have "good" time.   "restartntp" is left as an excersize to the reader.
+# I usually use it to kill a running xntpd, ntpdate some server, and the start xntp
+# again.
+# 
+print "\nConsider:\n";
+foreach $i ( (@down,@toofarout) ) {
+    print "  rsh $i sudo restartntp\n";
+}
+
+
+#
+# sort the results from the list.  First by stratum, then by time deviation
+# Put hosts that didn't respond (timed out) on the bottom.
+#
+sub appropriately {
+    @af=split(/\s+/,$a);
+    @bf=split(/\s+/,$b);
+    $aba= ($af[4]<0)?-$af[4]:$af[4];
+    $abb= ($bf[4]<0)?-$bf[4]:$bf[4];
+
+        ( $af[1] ne $bf[1] ) ? $bf[1] cmp $af[1] :
+          ( ( $af[2] != $bf[2] ) ? ( $bf[2] <=> $af[2] ) :
+            ( ( $aba != $abb )  ? ( $abb <=> $aba ) : ($af[0] cmp $bf[0] ) ) );
+}
diff --git a/scripts/fixautomakedepsmagic b/scripts/fixautomakedepsmagic
new file mode 100644 (file)
index 0000000..ec82bba
--- /dev/null
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+prog=`basename $0`
+
+
+t=/tmp/$prog.$$
+
+trap 'rm -f ${t} ; exit 1' 1 3 15
+
+while [ $# -gt 0 ]; do
+        f=$1
+       shift
+       sed -e '/^DEPS_MAGIC :=/,/^-include \$/s/^/#/' $f > $t
+       c="diff $f $t"
+       echo $c
+       $c
+       tstatus=$?
+       if [ $tstatus = 0 ]; then
+               echo "$prog":" $f not modified"
+       elif [ ! -w $f ]; then
+               echo "$prog":" $f not not writable"
+       else
+               c="cp $t $f"
+               echo $c
+               $c
+       fi
+       rm -f $t
+done
diff --git a/scripts/freq_adj.in b/scripts/freq_adj.in
new file mode 100644 (file)
index 0000000..88eb390
--- /dev/null
@@ -0,0 +1,97 @@
+#! @PATH_PERL@ -w
+
+die "perl5 needed\n" unless ($] > 5);
+
+use Getopt::Std;
+use vars qw($opt_n);
+
+getopts('d:nt:');
+
+#chop($ncpu = `sysctl -n hw.ncpu`);
+#die "Found $ncpu CPUs; can only be run on systems with 1 CPU.\n" if ($ncpu > 1);
+
+$driftfile = "/etc/ntp.drift";
+$driftfile = $opt_d if defined($opt_d);
+
+chop($timer = `sysctl -n kern.timecounter.hardware 2> /dev/null`);
+
+$timer =~ tr/\U/\L/;
+
+if ($timer eq '') {
+  open(DM, "/var/run/dmesg.boot");
+  while(<DM>) {
+    # Timecounter "i8254"  frequency 1193182 Hz
+    if (/^Timecounter "(\w+)"\s+/) {
+      $timer = $1;
+      last;
+    }
+  }
+  close(DM);
+}
+
+$opt_t = $timer if !defined($opt_t);
+
+if ($timer ne '') {            # $timer found...
+  if ($opt_t ne  '') {         # - and $opt_t found
+    if ($timer ne $opt_t) {    # - - and they differ
+      warn "You specified a $opt_t timer but I detected a $timer timer.\n";
+      usage();
+      exit 1;
+    } else {                   # - - and they are the same
+      ;
+    }
+  } else {                     # - but no $opt_t specified; this is OK
+    ;
+  }
+} else {                       # No $timer found...
+  if ($opt_t ne '') {          # - but $opt_t was specified
+    $timer = $opt_t;           # - - so use it.
+  } else {                     # - and neither was $opt_t
+    warn "I can't tell what timer you have.  Please specify one.\n";
+    usage();
+    exit 1;
+  }
+}
+
+open(DF, $driftfile) || die "Can't open driftfile ($driftfile): $!\n";
+while(<DF>) {
+    chop;
+    if (/^(-?\d+\.\d+)(\s\d)?$/) {
+       $drift = $1;
+    } else {
+       die "Bogus value in driftfile $driftfile: <$_>\n";
+    }
+}
+close(DF);
+
+print "NTP drift is <$drift>\n";
+
+# Convert from NTP's idea of PPM to a decimal equivalent
+$freq_adj = int ( $drift * ( 10 ** 6 / 2 ** 20) );
+print "normalized freq_adj  is <$freq_adj>\n";
+
+$freq_adj = int ( ( $freq_adj - 1 ) / 2 );
+print "Applying freq_adj of <".-$freq_adj.">\n";
+
+$sysctl = "machdep.".$timer."_freq";
+
+chop($mach_freq = `sysctl -n $sysctl`);
+
+print "$sysctl is <$mach_freq>\n";
+
+$n_mach_freq = $mach_freq - $freq_adj;
+
+if (defined($opt_n)) {
+  print "$sysctl $mach_freq -> $n_mach_freq\n";
+} else {
+  print "i8254: ".`sysctl -w $sysctl=$n_mach_freq`;
+}
+
+sub usage {
+  print STDERR <<EOUsage
+Usage: $0 [-d drift_file] [-n] [-t timer]
+where "drift_file" defaults to /etc/ntp.drift
+and "timer" is usually "tsc" or "i8254"
+and "-n" says "don't really change anything, just say what would happen".
+EOUsage
+}
diff --git a/scripts/genCommitLog b/scripts/genCommitLog
new file mode 100755 (executable)
index 0000000..2a258ad
--- /dev/null
@@ -0,0 +1,7 @@
+#! /bin/sh
+
+set -e
+
+. packageinfo.sh
+bk -R prs -hr${CLTAG}.. -nd':I:' | bk changes -m -v - > CommitLog.new
+mv CommitLog.new CommitLog
diff --git a/scripts/genver b/scripts/genver
new file mode 100755 (executable)
index 0000000..0ce1922
--- /dev/null
@@ -0,0 +1,67 @@
+#! /bin/sh
+
+# possible usage: $0 [-f] [version.m4] [version.def]
+#
+# -f would be 'force the update'
+
+force=0
+outputs=
+for i in $*
+do
+    case "$i" in
+     -f) force=1 ;;
+     version.m4)
+       outputs="version.m4 $outputs"
+       ;;
+     *version.def)
+       outputs="include/version.def $outputs"
+       ;;
+     *) echo "Unrecognized option: $i"
+       exit 1
+       ;;
+    esac
+done
+
+case "$outputs" in
+ '') outputs="version.m4 include/version.def" ;;
+esac
+
+set -e
+
+. ./packageinfo.sh
+
+dversion=`scripts/VersionName`
+
+set +e
+
+case "$outputs" in
+ *version.m4*)
+    echo "m4_define([VERSION_NUMBER],[${dversion}])" > /tmp/version.m4+
+    cmp -s /tmp/version.m4+ version.m4
+    rc=$?
+    case "$force$rc" in
+     00)
+       rm -f /tmp/version.m4+
+       ;;
+     *)
+       mv /tmp/version.m4+ version.m4
+       ;;
+    esac
+    ;;
+esac
+
+case "$outputs" in
+ *version.def*)
+    echo "version = '${dversion}';" > /tmp/version.def+
+    cmp -s /tmp/version.def+ include/version.def
+    rc=$?
+    case "$force$rc" in
+     00)
+       rm -f /tmp/version.def+
+       ;;
+     *)
+       mv /tmp/version.def+ include/version.def
+       ;;
+    esac
+    ;;
+esac
diff --git a/scripts/hpadjtime.sh b/scripts/hpadjtime.sh
new file mode 100755 (executable)
index 0000000..3de2a40
--- /dev/null
@@ -0,0 +1,18 @@
+#! /bin/sh
+val=1
+if [ -f /bin/uname -o -f /usr/bin/uname ]; then
+       set `uname -a | tr '[A-Z]' '[a-z]'`
+       case "$1" in
+               hp-ux)  case "$3" in
+                       *.10.*) val=1 ;;
+                       *.09.03 | *.09.10) case "$5" in
+                               9000/3*) val=1 ;;
+                               *)       val=0 ;;
+                               esac ;;
+                       *) val=0 ;;
+                       esac
+                       ;;
+       *)
+       esac
+fi
+exit $val
diff --git a/scripts/html2man.in b/scripts/html2man.in
new file mode 100755 (executable)
index 0000000..b7cebce
--- /dev/null
@@ -0,0 +1,172 @@
+#! @PATH_PERL@ -w
+#
+# html2man: Converts the NTP HTML documentation to man page format
+#
+# This file require the Perl HTML::TokeParser module:
+# http://search.cpan.org/search?module=HTML::TokeParser
+#
+# Depending on where this is run from, you might need to modify $MANDIR below.
+#
+# Hacked together by Peter Boettcher <boettcher@ll.mit.edu>
+# Last modified: <Mon Jan 28 17:24:38 2002 by pwb>
+
+require HTML::TokeParser;
+
+# use strict;          # I can dream...
+
+$MANDIR = "./man";
+
+# HTML files to convert.  Also include per-file info here: 
+#   name of man page, man section, 'see also' section
+%manfiles = (
+            'ntpd' => ['ntpd', 8, 'ntp.conf(5), ntpq(8), ntpdc(8)'],
+            'ntpq' => ['ntpq', 8, 'ntpd(8), ntpdc(8)'],
+            'ntpdate' => ['ntpdate', 8, 'ntpd(8)'],
+            'ntpdc' => ['ntpdc', 8, 'ntpd(8)'],
+            'ntptime' => ['ntpdtime', 8, 'ntpd(8), ntpdate(8)'],
+            'ntptrace' => ['ntptrace', 8, 'ntpd(8)'],
+            'keygen' => ['ntp-keygen', 8, 'ntpd(8), ntp_auth(5)'],
+            'confopt' => ['ntp.conf', 5, 'ntpd(8)'],
+            'authopt' => ['ntp_auth', 5, 'ntp.conf(5), ntpd(8)'],
+            'monopt' => ['ntp_mon', 5, 'ntp.conf(5)'],
+            'accopt' => ['ntp_acc', 5, 'ntp.conf(5)'],
+            'clockopt' => ['ntp_clock', 5, 'ntp.conf(5)'],
+            'miscopt' => ['ntp_misc', 5, 'ntp.conf(5)']);
+
+# Disclaimer to go in SEE ALSO section of the man page
+$seealso_disclaimer = 'These man pages are automatically hacked from the main NTP ' .
+    'documentation pages, which are maintained in HTML format.  These files are ' .
+    'included in the NTP source distribution.  If you installed NTP from a binary ' .
+    'package, or it came pre-installed on your system, chances are the documentation ' .
+    'was also included in the usual place for your system.  The HTML files are more ' .
+    'correct and complete than these man pages, which are provided for your reference ' .
+    'only.';
+
+# Disclaimer to go right at the top
+$top_disclaimer = 'This file was automatically generated from HTML source, and may be ' .
+    'incorrect.  See the SEE ALSO section at the end of this file for more info';
+
+mkdir $MANDIR, 0777;
+mkdir "$MANDIR/man8", 0777;
+mkdir "$MANDIR/man5", 0777;
+
+# Do the actual processing
+foreach $file (keys %manfiles) {
+    process($file);
+}
+# End of main function
+
+
+
+# Do the real work
+sub process {
+    my($filename) = @_;
+    $fileinfo = $manfiles{$filename};
+
+    $p = HTML::TokeParser->new("$filename.html") || die "Can't open $filename.html: $!";
+    open(MANOUT, ">$MANDIR/man$fileinfo->[1]/$fileinfo->[0].$fileinfo->[1]")
+       || die "Can't open: $!";
+
+    $p->get_tag("title");
+    $name = $p->get_text("/title");
+    $p->get_tag("hr");         # Skip past image and quote, hopefully
+
+    # Setup man header
+    print MANOUT ".TH " . $fileinfo->[0] . " " . $fileinfo->[1] .  "\n";
+    print MANOUT ".UC 4\n";
+    print MANOUT ".SH NAME\n";
+    $pat = $fileinfo->[0];
+    if ($name =~ /$pat/) {
+    } else {
+       # Add the manpage name, if not in the HTML title already
+       print MANOUT "$fileinfo->[0] - ";
+    }
+    print MANOUT "$name\n\n";
+
+    print MANOUT "$top_disclaimer\n";
+
+    # Now start scanning.  We basically print everything after translating some tags.
+    # $token->[0] has "T", "S", "E" for Text, Start, End
+    # $token->[1] has the tag name, or text (for "T" case)
+    #  Theres lots more in the world of tokens, but who cares?
+    while (my $token = $p->get_token) {
+       if($token->[0] eq "T") {
+           my $text = $token->[1];
+           if($tag) {
+               $text =~ s/^[\n ]*//;
+               $text =~ s/[\n ]*$/ /;
+           }
+           $text =~ s/&nbsp\;/ /g;
+           $text =~ s/^\./\\./;
+           print MANOUT "$text";
+           $tag = 0;
+       }
+       if($token->[0] eq "S") {
+           if($token->[1] eq "h4") {
+               my $text = uc($p->get_trimmed_text("/h4"));
+               print MANOUT ".SH $text\n";
+           }
+           if($token->[1] eq "tt") {
+               push @fontstack, "tt";
+               print MANOUT "\\fB";
+           }
+           if($token->[1] eq "i") {
+               push @fontstack, "i";
+               print MANOUT "\\fI";
+           }
+           if($token->[1] eq "address") {
+               my $text = $p->get_trimmed_text("/address");
+               print MANOUT "\n.SH AUTHOR\n$text\n";
+           }
+           if($token->[1] eq "dt") {
+               $tmp = $deflevel-4;
+               print MANOUT "\n.RS $tmp\n";
+               $tag = 1;
+           }
+           if($token->[1] eq "dd") {
+               print MANOUT "\n.RS $deflevel\n";
+               $tag = 1;
+           }
+           if($token->[1] eq "dl") {
+               $deflevel+=4;
+           }
+       }
+       elsif($token->[0] eq "E") {
+           if($token->[1] eq "dd") {
+               print MANOUT "\n.RE\n";
+               $tag = 1;
+           }
+           if($token->[1] eq "tt") {
+               $f = pop @fontstack;
+               if($f ne "tt") {
+                   warn "Oops, mismatched font!  Trying to continue\n";
+               }
+               if ($#fontstack < 0) { $fontswitch = "\\fR"; }
+               elsif ($fontstack[$#fontstack] eq "tt") { $fontswitch = "\\fB"; }
+               else { $fontswitch = "\\fI"; }
+               print MANOUT "$fontswitch";
+           }
+           if($token->[1] eq "i") {
+               $f = pop @fontstack;
+               if($f ne "i") {
+                   warn "Oops, mismatched font!  Trying to continue\n";
+               }
+               if ($#fontstack < 0) { $fontswitch = "\\fR"; }
+               elsif ($fontstack[$#fontstack] eq "tt") { $fontswitch = "\\fB"; }
+               else { $fontswitch = "\\fI"; }
+               print MANOUT "$fontswitch";
+           }
+           if($token->[1] eq "dl") {
+               $deflevel-=4;
+           }
+           if($token->[1] eq "dt") {
+               print MANOUT "\n.RE";
+               $tag = 1;
+           }
+       }
+    }
+    print MANOUT ".SH SEE ALSO\n\n";
+    print MANOUT "$fileinfo->[2]\n\n";
+    print MANOUT "$seealso_disclaimer\n";
+    close(MANOUT);
+}
diff --git a/scripts/mkver.in b/scripts/mkver.in
new file mode 100644 (file)
index 0000000..11aa613
--- /dev/null
@@ -0,0 +1,40 @@
+#!@PATH_SH@
+PROG=${1-UNKNOWN}
+
+ConfStr="$PROG"
+
+ConfStr="$ConfStr @VERSION@"
+
+case "$CSET" in
+ '') ;;
+ *) ConfStr="$ConfStr@$CSET" ;;
+esac
+
+case "@LCRYPTO@" in
+ '') ;;
+ -lcrypto)
+    ConfStr="${ConfStr}-o" ;;
+ *) ConfStr="${ConfStr}-?" ;;
+esac
+
+ConfStr="$ConfStr `LC_TIME=C TZ= date`"
+
+if [ ! -f .version ]; then
+  echo 0 > .version
+fi
+RUN="`cat .version`"
+RUN="`expr $RUN + 1`"
+echo $RUN > .version
+
+ConfStr="$ConfStr (${RUN})"
+
+echo "Version <${ConfStr}>";
+
+rm -f version.c
+cat > version.c << -EoF-
+/*
+ * version file for $PROG
+ */
+#include <config.h>
+const char * Version = "${ConfStr}";
+-EoF-
diff --git a/scripts/monitoring/README b/scripts/monitoring/README
new file mode 100644 (file)
index 0000000..f8eb0a9
--- /dev/null
@@ -0,0 +1,158 @@
+This directory contains support for monitoring the local clock of xntp daemons.
+
+WARNING: The scripts and routines contained in this directory are beta
+        release!  Do not depend on their correct operation. They are,
+        however, in regular use at University of Erlangen-Nuernberg.
+        No severe problems are known for this code.
+
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+PLEASE THINK TWICE BEFORE STARTING MONITORING REMOTE XNTP DEAMONS !!!!
+MONITORING MAY INCREASE THE LOAD OF THE DEAMON MONITORED AND MAY
+INCREASE THE NETWORK LOAD SIGNIFICANTLY
+!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
+
+
+Files are:
+
+README:
+       This file
+
+ntptrap:
+       perl script to log ntp mode 6 trap messages.
+
+       It sends a set_trap request to each server given and dumps the
+       trap messages received. It handles refresh of set_trap.
+       Currently it handles only NTP V2, however the NTP V3 servers
+       also accept v2 requests. It will not interpret v3 system and
+       peer stati correctly.
+
+       usage:
+         ntptrap [-n] [-p <port>] [-l <debug-output>] servers...
+       
+       -n:             do not send set_trap requests
+
+       port:           port to listen for responses
+                       useful if you have a configured trap
+
+       debug-output:   file to write trace output to (for debugging)
+
+       This script convinced me that ntp trap messages are only of
+       little use.
+
+ntploopstat:
+       perl script to gather loop info statistics from xntpd via mode 7
+       LOOP_INFO requests.
+
+       This script collects data to allow monitoring of remote xntp servers
+       where it is not possible to directly access the loopstats file
+       produced by xntpd itself. Of course, it can be used to sample
+       a local server if it is not configured to produce a loopstats file.
+
+       Please note, this program poses a high load on the server as
+       a communication takes place every delay seconds ! USE WITH CARE !
+
+       usage:
+         ntploopstat [-d<delay>] [-t<timeout>] [-l <logfile>] [-v] [ntpserver]
+       
+       delay:          number of seconds to wait between samples
+                       default: 60 seconds
+       timeout:        number of seconds to wait for reply
+                       default 12 seconds
+       logfile:        file to log samples to
+                       default: loopstats:<ntpserver>:
+                       (note the trailing colon)
+                       This name actually is a prefix.
+                       The file name is dynamically derived by appending
+                       the name of the month the sample belongs to.
+                       Thus all samples of a month end up in the same file.
+
+       the format of the files generated is identical to the format used by
+       xntpd with the loopstats file:
+               MJD <seconds since midnight UTC> offset frequency compliance
+       
+       if a timeout occurs the next sample is tried after delay/2 seconds
+
+       The script will terminate after MAX_FAIL (currently 60)
+       consecutive errors.
+
+       Errors are counted for:
+               - error on send call
+               - error on select call
+               - error on recv call
+               - short packet received
+               - bad packet 
+               - error on open for logfile
+
+ntploopwatch:
+       perl script to display loop filter statistics collected by ntploopstat
+       or dumped directly by xntpd.
+
+       Gnuplot is used to produce a graphical representation of the sample
+       values, that have been preprocessed and analysed by this script.
+
+       It can either be called to produce a printout of specific data set or
+       used to continously monitor the values. Monitoring is achieved by 
+       periodically reprocessing the logfiles, which are updated regularly
+       either by a running ntploopstat process or by the running xntpd.
+
+       usage:
+         to watch statistics permanently:
+            ntploopwatch [-v[<level>]] [-c <config-file>] [-d <working-dir>]
+
+         to get a single print out specify also
+                         -P<printer> [-s<samples>]
+                                     [-S <start-time>] [-E <end-time>]
+                                     [-O <MaxOffs>] [-o <MinOffs>]
+       
+       level:          level of verbosity for debugging
+       config-file:    file to read configurable settings from
+                       On each iteration it is checked and reread
+                       if it has been changed
+                       default: loopwatch.config
+       working-dir:    specify working directory for process, affects
+                       interpretation of relative file names
+       
+       All other flags are only useful with printing plots, as otherwise
+       command line values would be replaced by settings from the config file.
+
+       printer:        specify printer to print plot
+                       BSD print systems semantics apply; if printer
+                       is omitted the name "ps" is used; plots are
+                       prepared using PostScript, thus the printer
+                       should best accept postscript input
+
+       For the following see also the comments in loopwatch.config.SAMPLE
+
+       samples:        use last # samples from input data
+       start-time:     ignore input samples before this date
+       end-time:       ignore input samples after this date
+                       if both start-time and end-time are specified
+                       a given samples value is ignored
+       MaxOffs:
+       MinOffs:        restrict value range 
+
+loopwatch.config.SAMPLE:
+       sample config file for ntploopwatch
+       each configurable option is explained there
+
+lr.pl:
+       linear regression package used by ntploopwatch to compute
+       linear approximations for frequency and offset values
+       within display range
+
+timelocal.pl:
+
+       used during conversion of ISO_DATE_TIME values specified in
+       loopwatch config files to unix epoch values (seconds since
+       1970-01-01_00:00_00 UTC)
+
+       A version of this file is distributed with perl-4.x, however,
+       it has a bug related to dates crossing 1970, causing endless loops..
+       The version contained here has been fixed.
+
+ntp.pl:
+       perl support for ntp v2 mode 6 message handling
+       WARNING: This code is beta level - it triggers a memory leak;
+                as for now it is not quite clear, wether this is caused by a
+                bug in perl or by bad usage of perl within this script.
+
diff --git a/scripts/monitoring/loopwatch.config.SAMPLE b/scripts/monitoring/loopwatch.config.SAMPLE
new file mode 100644 (file)
index 0000000..8cefea3
--- /dev/null
@@ -0,0 +1,89 @@
+# sample configuration and control file for ntploowatch
+#
+# delay:       sampling interval in seconds
+delay=60
+# samples:     use only last # samples
+samples=600
+# DO NOT USE srcprefix in shared config files
+# srcprefix:   name of file to read samples from
+#              current time suffix (month name) is appended
+#              defaults to "./var@$STATHOST/loopstats."
+#              The string "$STATHOST"is replaced by the name of the host
+#              being monitored
+#srcprefix=./var@$STATHOST/loopstats.
+#
+# showoffs:    yes/no control display of offset values
+showoffs=yes
+#
+# showfreq:    yes/no control display of frequency values
+showfreq=yes
+#
+# showcmpl:    yes/no control display of compliance values
+showcmpl=no
+#
+# showoreg:    yes/no control display of linear regression of offset values
+showoreg=no
+#
+# showfreg:    yes/no control display of linear regression of frequency values
+showfreg=no
+#
+# timebase:    dynamic/ISO_DATE_TIME point of zero for linear regression
+#              ISO_DATE_TIME:  yyyy-mm-dd_hh:mm:ss.ms
+#              values are interpreted using local time zone
+#              parts omitted from front default to current date/time
+#              parts omitted from end  default to lowest permitted values
+#              to get aa:bb being interpreted as minutes:seconds use aa:bb.0
+#              for dynamic '00:00:00.0 of current day' is used
+timebase=dynamic
+#
+# freqbase:    dynamic/<baseval> 
+#              if a number is given, subtract this from sampling values for display
+#              if dynamic is selected, freqbase is adjusted to fit into the range of
+#              offset values
+freqbase=dynamic
+#
+# cmplscale:   dynamic/<scaling>
+#              if a number is given, the sampling values are divided by this number
+#              if dynamic is selected, cmplscale is adjusted to fit into the range of
+#              offset values
+cmplscale=dynamic
+#
+# DumbScale:   0/1
+#              0 enables dynamic adjust of value ranges for freqbase and cmplscale
+#                timescale is labeled with human readable times
+#              1 only uses explicit scaling for numbers
+#                timescale is labeled with hours relative to timebase
+DumbScale=0
+#
+# StartTime:   none/ISO_DATE_TIME
+#              ignore any samples before the specified date
+StartTime=none
+#
+# EndTime:     none/ISO_DATE_TIME
+#              ignore any samples after the specified date
+#
+#              if both StartTime and EndTime are specified
+#              the value specified for samples is ignored
+EndTime=none
+#
+# MaxOffs:     none/<number>
+#              limit display (y-axis) to values not larger than <number>
+MaxOffset=none
+#
+# MinOffs:     none/<number>
+#              limit display (y-axis) to values not smaller than <number>
+MinOffset=none
+
+#
+# verbose:     <number>
+#              specify level for debugging 
+#              default is 0 for printing and 1 for monitoring
+#              level 1 will just print a timestamp for any display update
+#              (this is every delay seconds)
+verbose=1
+#
+# deltaT:      <seconds>
+#              mark `holes' in the sample data grater than <seconds>
+#              by a break in the plot
+#              default: 512 seconds
+deltaT=512
diff --git a/scripts/monitoring/lr.pl b/scripts/monitoring/lr.pl
new file mode 100644 (file)
index 0000000..1ab3e3f
--- /dev/null
@@ -0,0 +1,151 @@
+;#
+;# lr.pl,v 3.1 1993/07/06 01:09:08 jbj Exp
+;#
+;#
+;# Linear Regression Package for perl
+;# to be 'required' from perl
+;#
+;#  Copyright (c) 1992 
+;#  Frank Kardel, Rainer Pruy
+;#  Friedrich-Alexander Universitaet Erlangen-Nuernberg
+;#
+;#  Copyright (c) 1997 by
+;#  Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
+;#  (Converted to a PERL 5.004 package)
+;#
+;#############################################################
+
+package lr;
+
+##
+## y = A + Bx
+##
+## B = (n * Sum(xy) - Sum(x) * Sum(y)) / (n * Sum(x^2) - Sum(x)^2)
+##
+## A = (Sum(y) - B * Sum(x)) / n
+##
+
+##
+## interface
+##
+;# init(tag);          initialize data set for tag
+;# sample(x, y, tag);  enter sample
+;# Y(x, tag);          compute y for given x 
+;# X(y, tag);          compute x for given y
+;# r(tag);             regression coefficient
+;# cov(tag);           covariance
+;# A(tag);   
+;# B(tag);
+;# sigma(tag);         standard deviation
+;# mean(tag);
+#########################
+
+sub init
+{
+    my $self = shift;
+
+    $self->{n}   = 0;
+    $self->{sx}  = 0.0;
+    $self->{sx2} = 0.0;
+    $self->{sxy} = 0.0;
+    $self->{sy}  = 0.0;
+    $self->{sy2} = 0.0;
+}
+
+sub sample($$)
+{
+    my $self = shift;
+    my($_x, $_y) = @_;
+
+    ++($self->{n});
+    $self->{sx}  += $_x;
+    $self->{sy}  += $_y;
+    $self->{sxy} += $_x * $_y;
+    $self->{sx2} += $_x**2;
+    $self->{sy2} += $_y**2;
+}
+
+sub B()
+{
+    my $self = shift;
+
+    return 1 unless ($self->{n} * $self->{sx2} - $self->{sx}**2);
+    return ($self->{n} * $self->{sxy} - $self->{sx} * $self->{sy})
+       / ($self->{n} * $self->{sx2} - $self->{sx}**2);
+}
+
+sub A()
+{
+    my $self = shift;
+
+    return ($self->{sy} - B() * $self->{sx}) / $self->{n};
+}
+
+sub Y()
+{
+    my $self = shift;
+
+    return A() + B() * $_[$[];
+}
+
+sub X()
+{
+    my $self = shift;
+
+    return ($_[$[] - A()) / B();
+}
+
+sub r()
+{
+    my $self = shift;
+
+    my $s = ($self->{n} * $self->{sx2} - $self->{sx}**2)
+         * ($self->{n} * $self->{sy2} - $self->{sy}**2);
+
+    return 1 unless $s;
+    
+    return ($self->{n} * $self->{sxy} - $self->{sx} * $self->{sy}) / sqrt($s);
+}
+
+sub cov()
+{
+    my $self = shift;
+
+    return ($self->{sxy} - $self->{sx} * $self->{sy} / $self->{n})
+       / ($self->{n} - 1);
+}
+
+sub sigma()
+{
+    my $self = shift;
+
+    return 0 if $self->{n} <= 1;
+    return sqrt(($self->{sy2} - ($self->{sy} * $self->{sy}) / $self->{n})
+               / ($self->{n}));
+}
+
+sub mean()
+{
+    my $self = shift;
+
+    return 0 if $self->{n} <= 0;
+    return $self->{sy} / $self->{n};
+}
+
+sub new
+{
+    my $class = shift;
+    my $self = {
+       (n => undef,
+        sx => undef,
+        sx2 => undef,
+        sxy => undef,
+        sy => undef,
+        sy2 => undef)
+    };
+    bless $self, $class;
+    init($self);
+    return $self;
+}
+
+1;
diff --git a/scripts/monitoring/ntp.pl b/scripts/monitoring/ntp.pl
new file mode 100644 (file)
index 0000000..b23f396
--- /dev/null
@@ -0,0 +1,479 @@
+#!/usr/bin/perl -w
+;#
+;# ntp.pl,v 3.1 1993/07/06 01:09:09 jbj Exp
+;#
+;# process loop filter statistics file and either
+;#     - show statistics periodically using gnuplot
+;#     - or print a single plot
+;#
+;#  Copyright (c) 1992 
+;#  Rainer Pruy Friedrich-Alexander Universitaet Erlangen-Nuernberg
+;#
+;#
+;#############################################################
+
+package ntp;
+
+$NTP_version = 2;
+$ctrl_mode=6;
+
+$byte1 = (($NTP_version & 0x7)<< 3) & 0x34 | ($ctrl_mode & 0x7);
+$MAX_DATA = 468;
+
+$sequence = 0;                 # initial sequence number incred before used
+$pad=4;
+$do_auth=0;                    # no possibility today
+$keyid=0;
+;#list if known keys (passwords)
+%KEYS = ( 0, "\200\200\200\200\200\200\200\200",
+        );
+
+;#-----------------------------------------------------------------------------
+;# access routines for ntp control packet
+    ;# NTP control message format
+    ;#  C  LI|VN|MODE  LI 2bit=00  VN 3bit=2(3) MODE 3bit=6 : $byte1
+    ;#  C  R|E|M|Op    R response  E error    M more   Op opcode
+    ;#  n  sequence
+    ;#  n  status
+    ;#  n  associd
+    ;#  n  offset
+    ;#  n  count
+    ;#  a+ data (+ padding)
+    ;#  optional authentication data
+    ;#  N  key
+    ;#  N2 checksum
+    
+;# first byte of packet
+sub pkt_LI   { return ($_[$[] >> 6) & 0x3; }
+sub pkt_VN   { return ($_[$[] >> 3) & 0x7; }
+sub pkt_MODE { return ($_[$[]     ) & 0x7; }
+
+;# second byte of packet
+sub pkt_R  { return ($_[$[] & 0x80) == 0x80; }
+sub pkt_E  { return ($_[$[] & 0x40) == 0x40; }
+sub pkt_M  { return ($_[$[] & 0x20) == 0x20; }
+sub pkt_OP { return $_[$[] & 0x1f; }
+
+;#-----------------------------------------------------------------------------
+
+sub setkey
+{
+    local($id,$key) = @_;
+
+    $KEYS{$id} = $key if (defined($key));
+    if (! defined($KEYS{$id}))
+    {
+       warn "Key $id not yet specified - key not changed\n";
+       return undef;
+    }
+    return ($keyid,$keyid = $id)[$[];
+}
+
+;#-----------------------------------------------------------------------------
+sub numerical { $a <=> $b; }
+
+;#-----------------------------------------------------------------------------
+
+sub send       #'
+{
+    local($fh,$opcode, $associd, $data,$address) = @_;
+    $fh = caller(0)."'$fh";
+
+    local($junksize,$junk,$packet,$offset,$ret);
+    $offset = 0;
+
+    $sequence++;
+    while(1)
+    {
+       $junksize = length($data);
+       $junksize = $MAX_DATA if $junksize > $MAX_DATA;
+       
+       ($junk,$data) = $data =~ /^(.{$junksize})(.*)$/;
+       $packet
+           = pack("C2n5a".(($junk eq "") ? 0 : &pad($junksize+12,$pad)-12),
+                  $byte1,
+                  ($opcode & 0x1f) | ($data ? 0x20 : 0),
+                  $sequence,
+                  0, $associd,
+                  $offset, $junksize, $junk);
+       if ($do_auth)
+       {
+           ;# not yet
+       }
+       $offset += $junksize;
+
+       if (defined($address))
+       {
+           $ret = send($fh, $packet, 0, $address);
+       }
+       else
+       {
+           $ret = send($fh, $packet, 0);
+       }
+
+       if (! defined($ret))
+       {
+           warn "send failed: $!\n";
+           return undef;
+       }
+       elsif ($ret != length($packet))
+       {
+           warn "send failed: sent only $ret from ".length($packet). "bytes\n";
+           return undef;
+       }
+       return $sequence unless $data;
+    }
+}
+
+;#-----------------------------------------------------------------------------
+;# status interpretation
+;#
+sub getval
+{
+    local($val,*list) = @_;
+    
+    return $list{$val} if defined($list{$val});
+    return sprintf("%s#%d",$list{"-"},$val) if defined($list{"-"});
+    return "unknown-$val";
+}
+
+;#---------------------------------
+;# system status
+;#
+;# format: |LI|CS|SECnt|SECode| LI=2bit CS=6bit SECnt=4bit SECode=4bit
+sub ssw_LI     { return ($_[$[] >> 14) & 0x3; }
+sub ssw_CS     { return ($_[$[] >> 8)  & 0x3f; }
+sub ssw_SECnt  { return ($_[$[] >> 4)  & 0xf; }
+sub ssw_SECode { return $_[$[] & 0xf; }
+
+%LI = ( 0, "leap_none",  1, "leap_add_sec", 2, "leap_del_sec", 3, "sync_alarm", "-", "leap");
+%ClockSource = (0, "sync_unspec",
+               1, "sync_lf_clock",
+               2, "sync_uhf_clock",
+               3, "sync_hf_clock",
+               4, "sync_local_proto",
+               5, "sync_ntp",
+               6, "sync_udp/time",
+               7, "sync_wristwatch",
+               "-", "ClockSource",
+               );
+
+%SystemEvent = (0, "event_unspec",
+               1, "event_restart",
+               2, "event_fault",
+               3, "event_sync_chg",
+               4, "event_sync/strat_chg",
+               5, "event_clock_reset",
+               6, "event_bad_date",
+               7, "event_clock_excptn",
+               "-", "event",
+               );
+sub LI
+{
+    &getval(&ssw_LI($_[$[]),*LI);
+}
+sub ClockSource
+{
+    &getval(&ssw_CS($_[$[]),*ClockSource);
+}
+
+sub SystemEvent
+{
+    &getval(&ssw_SECode($_[$[]),*SystemEvent);
+}
+
+sub system_status
+{
+    return sprintf("%s, %s, %d event%s, %s", &LI($_[$[]), &ClockSource($_[$[]),
+                  &ssw_SECnt($_[$[]), ((&ssw_SECnt($_[$[])==1) ? "" : "s"),
+                  &SystemEvent($_[$[]));
+}
+;#---------------------------------
+;# peer status
+;#
+;# format: |PStat|PSel|PCnt|PCode| Pstat=6bit PSel=2bit PCnt=4bit PCode=4bit
+sub psw_PStat_config     { return ($_[$[] & 0x8000) == 0x8000; }
+sub psw_PStat_authenable { return ($_[$[] & 0x4000) == 0x4000; }
+sub psw_PStat_authentic  { return ($_[$[] & 0x2000) == 0x2000; }
+sub psw_PStat_reach      { return ($_[$[] & 0x1000) == 0x1000; }
+sub psw_PStat_sane       { return ($_[$[] & 0x0800) == 0x0800; }
+sub psw_PStat_dispok     { return ($_[$[] & 0x0400) == 0x0400; }
+sub psw_PStat { return ($_[$[] >> 10) & 0x3f; }
+sub psw_PSel  { return ($_[$[] >> 8)  & 0x3;  }
+sub psw_PCnt  { return ($_[$[] >> 4)  & 0xf; }
+sub psw_PCode { return $_[$[] & 0xf; }
+
+%PeerSelection = (0, "sel_reject",
+                 1, "sel_candidate",
+                 2, "sel_selcand",
+                 3, "sel_sys.peer",
+                 "-", "PeerSel",
+                 );
+%PeerEvent = (0, "event_unspec",
+             1, "event_ip_err",
+             2, "event_authen",
+             3, "event_unreach",
+             4, "event_reach",
+             5, "event_clock_excptn",
+             6, "event_stratum_chg",
+             "-", "event",
+             );
+
+sub PeerSelection
+{
+    &getval(&psw_PSel($_[$[]),*PeerSelection);
+}
+
+sub PeerEvent
+{
+    &getval(&psw_PCode($_[$[]),*PeerEvent);
+}
+
+sub peer_status
+{
+    local($x) = ("");
+    $x .= "config,"     if &psw_PStat_config($_[$[]);
+    $x .= "authenable," if &psw_PStat_authenable($_[$[]);
+    $x .= "authentic,"  if &psw_PStat_authentic($_[$[]);
+    $x .= "reach,"      if &psw_PStat_reach($_[$[]);
+    $x .= &psw_PStat_sane($_[$[]) ? "sane," : "insane,";
+    $x .= "hi_disp," unless &psw_PStat_dispok($_[$[]);
+
+    $x .= sprintf(" %s, %d event%s, %s", &PeerSelection($_[$[]),
+                 &psw_PCnt($_[$[]), ((&psw_PCnt($_[$[]) == 1) ? "" : "s"),
+                 &PeerEvent($_[$[]));
+    return $x;
+}
+
+;#---------------------------------
+;# clock status
+;#
+;# format: |CStat|CEvnt| CStat=8bit CEvnt=8bit
+sub csw_CStat { return ($_[$[] >> 8) & 0xff; }
+sub csw_CEvnt { return $_[$[] & 0xff; }
+
+%ClockStatus = (0, "clk_nominal",
+               1, "clk_timeout",
+               2, "clk_badreply",
+               3, "clk_fault",
+               4, "clk_prop",
+               5, "clk_baddate",
+               6, "clk_badtime",
+               "-", "clk",
+              );
+
+sub clock_status
+{
+    return sprintf("%s, last %s",
+                  &getval(&csw_CStat($_[$[]),*ClockStatus),
+                  &getval(&csw_CEvnt($_[$[]),*ClockStatus));
+}
+
+;#---------------------------------
+;# error status
+;#
+;# format: |Err|reserved|  Err=8bit
+;#
+sub esw_Err { return ($_[$[] >> 8) & 0xff; }
+
+%ErrorStatus = (0, "err_unspec",
+               1, "err_auth_fail",
+               2, "err_invalid_fmt",
+               3, "err_invalid_opcode",
+               4, "err_unknown_assoc",
+               5, "err_unknown_var",
+               6, "err_invalid_value",
+               7, "err_adm_prohibit",
+               );
+
+sub error_status
+{
+    return sprintf("%s", &getval(&esw_Err($_[$[]),*ErrorStatus));
+}
+
+;#-----------------------------------------------------------------------------
+;#
+;# cntrl op name translation
+
+%CntrlOpName = (1, "read_status",
+               2, "read_variables",
+               3, "write_variables",
+               4, "read_clock_variables",
+               5, "write_clock_variables",
+               6, "set_trap",
+               7, "trap_response",
+               31, "unset_trap", # !!! unofficial !!!
+               "-", "cntrlop",
+               );
+
+sub cntrlop_name
+{
+    return &getval($_[$[],*CntrlOpName);
+}
+
+;#-----------------------------------------------------------------------------
+
+$STAT_short_pkt = 0;
+$STAT_pkt = 0;
+
+;# process a NTP control message (response) packet
+;# returns a list ($ret,$data,$status,$associd,$op,$seq,$auth_keyid)
+;#      $ret: undef     --> not yet complete
+;#            ""        --> complete packet received
+;#            "ERROR"   --> error during receive, bad packet, ...
+;#          else        --> error packet - list may contain useful info
+
+
+sub handle_packet
+{
+    local($pkt,$from) = @_;    # parameters
+    local($len_pkt) = (length($pkt));
+;#    local(*FRAGS,*lastseen);
+    local($li_vn_mode,$r_e_m_op,$seq,$status,$associd,$offset,$count,$data);
+    local($autch_keyid,$auth_cksum);
+
+    $STAT_pkt++;
+    if ($len_pkt < 12)
+    {
+       $STAT_short_pkt++;
+       return ("ERROR","short packet received");
+    }
+
+    ;# now break packet apart
+    ($li_vn_mode,$r_e_m_op,$seq,$status,$associd,$offset,$count,$data) =
+       unpack("C2n5a".($len_pkt-12),$pkt);
+    $data=substr($data,$[,$count);
+    if ((($len_pkt - 12) - &pad($count,4)) >= 12)
+    {
+       ;# looks like an authenticator
+       ($auth_keyid,$auth_cksum) =
+           unpack("Na8",substr($pkt,$len_pkt-12+$[,12));
+       $STAT_auth++;
+       ;# no checking of auth_cksum (yet ?)
+    }
+
+    if (&pkt_VN($li_vn_mode) != $NTP_version)
+    {
+       $STAT_bad_version++;
+       return ("ERROR","version ".&pkt_VN($li_vn_mode)."packet ignored");
+    }
+
+    if (&pkt_MODE($li_vn_mode) != $ctrl_mode)
+    {
+       $STAT_bad_mode++;
+       return ("ERROR", "mode ".&pkt_MODE($li_vn_mode)." packet ignored");
+    }
+    
+    ;# handle single fragment fast
+    if ($offset == 0 && &pkt_M($r_e_m_op) == 0)
+    {
+       $STAT_single_frag++;
+       if (&pkt_E($r_e_m_op))
+       {
+           $STAT_err_pkt++;
+           return (&error_status($status),
+                   $data,$status,$associd,&pkt_OP($r_e_m_op),$seq,
+                   $auth_keyid);
+       }
+       else
+       {
+           return ("",
+                   $data,$status,$associd,&pkt_OP($r_e_m_op),$seq,
+                   $auth_keyid);
+       }
+    }
+    else
+    {
+       ;# fragment - set up local name space
+       $id = "$from$seq".&pkt_OP($r_e_m_op);
+       $ID{$id} = 1;
+       *FRAGS = "$id FRAGS";
+       *lastseen = "$id lastseen";
+       
+       $STAT_frag++;
+       
+       $lastseen = 1 if !&pkt_M($r_e_m_op);
+       if (!defined(%FRAGS))
+       {
+           print((&pkt_M($r_e_m_op) ? " more" : "")."\n");
+           $FRAGS{$offset} = $data;
+           ;# save other info
+           @FRAGS = ($status,$associd,&pkt_OP($r_e_m_op),$seq,$auth_keyid,$r_e_m_op);
+       }
+       else
+       {
+           print((&pkt_M($r_e_m_op) ? " more" : "")."\n");
+           ;# add frag to previous - combine on the fly
+           if (defined($FRAGS{$offset}))
+           {
+               $STAT_dup_frag++;
+               return ("ERROR","duplicate fragment at $offset seq=$seq");
+           }
+           
+           $FRAGS{$offset} = $data;
+           
+           undef($loff);
+           foreach $off (sort numerical keys(%FRAGS))
+           {
+               next unless defined($FRAGS{$off});
+               if (defined($loff) &&
+                   ($loff + length($FRAGS{$loff})) == $off)
+               {
+                   $FRAGS{$loff} .= $FRAGS{$off};
+                   delete $FRAGS{$off};
+                   last;
+               }
+               $loff = $off;
+           }
+
+           ;# return packet if all frags arrived
+           ;# at most two frags with possible padding ???
+           if ($lastseen && defined($FRAGS{0}) &&
+               (((scalar(@x=sort numerical keys(%FRAGS)) == 2) &&
+                 (length($FRAGS{0}) + 8) > $x[$[+1]) ||
+                 (scalar(@x=sort numerical keys(%FRAGS)) < 2)))
+           {
+               @x=((&pkt_E($r_e_m_op) ? &error_status($status) : ""),
+                   $FRAGS{0},@FRAGS);
+               &pkt_E($r_e_m_op) ? $STAT_err_frag++ : $STAT_frag_all++;
+               undef(%FRAGS);
+               undef(@FRAGS);
+               undef($lastseen);
+               delete $ID{$id};
+               &main'clear_timeout($id);
+               return @x;
+           }
+           else
+           {
+               &main'set_timeout($id,time+$timeout,"&ntp'handle_packet_timeout(\"".unpack("H*",$id)."\");"); #'";
+           }
+       }
+       return (undef);
+    }
+}
+
+sub handle_packet_timeout
+{
+    local($id) = @_;
+    local($r_e_m_op,*FRAGS,*lastseen,@x) = (@FRAGS[$[+5]);
+    
+    *FRAGS = "$id FRAGS";
+    *lastseen = "$id lastseen";
+    
+    @x=((&pkt_E($r_e_m_op) ? &error_status($status) : "TIMEOUT"),
+       $FRAGS{0},@FRAGS[$[ .. $[+4]);
+    $STAT_frag_timeout++;
+    undef(%FRAGS);
+    undef(@FRAGS);
+    undef($lastseen);
+    delete $ID{$id};
+    return @x;
+}
+
+
+sub pad
+{
+    return $_[$[+1] * int(($_[$[] + $_[$[+1] - 1) / $_[$[+1]);
+}
+
+1;
diff --git a/scripts/monitoring/ntploopstat b/scripts/monitoring/ntploopstat
new file mode 100644 (file)
index 0000000..7583c7c
--- /dev/null
@@ -0,0 +1,458 @@
+#!/usr/bin/perl -w
+# --*-perl-*-
+;#
+;# ntploopstat,v 3.1 1993/07/06 01:09:11 jbj Exp
+;# 
+;# Poll NTP server using NTP mode 7 loopinfo request.
+;# Log info and timestamp to file for processing by ntploopwatch.
+;#
+;#
+;# Copyright (c) 1992
+;# Rainer Pruy Friedrich-Alexander Universitaet Erlangen-Nuernberg
+;#
+;#################################################################
+;#
+;# The format written to the logfile is the same as used by xntpd
+;# for the loopstats file.
+;# This script however allows to gather loop filter statistics from
+;# remote servers where you do not have access to the loopstats logfile.
+;#
+;# Please note: Communication delays affect the accuracy of the
+;#              timestamps recorded. Effects from these delays will probably
+;#              not show up, as timestamps are recorded to the second only.
+;#              (Should have implemented &gettimeofday()..)
+;#
+
+$0 =~ s!^.*/([^/]+)$!$1!;              # beautify script name
+
+$ntpserver = 'localhost';              # default host to poll
+$delay = 60;                           # default sampling rate
+                                      ;# keep it shorter than minpoll (=64)
+                                      ;# to get all values
+
+require "ctime.pl";
+;# handle bug in early ctime distributions
+$ENV{'TZ'} = 'MET' unless defined($ENV{'TZ'}) || $] > 4.010;
+
+if (defined(@ctime'MoY))
+{
+    *MonthName = *ctime'MoY;
+}
+else
+{
+    @MonthName = ('Jan','Feb','Mar','Apr','May','Jun',
+                 'Jul','Aug','Sep','Oct','Nov','Dec');
+}
+
+;# this routine can be redefined to point to syslog if necessary
+sub msg
+{
+    return unless $verbose;
+
+    print  STDERR "$0: ";
+    printf STDERR @_;
+}
+
+;#############################################################
+;#
+;# process command line
+$usage = <<"E-O-S";
+
+usage:
+  $0 [-d<delay>] [-t<timeout>] [-l <logfile>] [-v] [ntpserver]
+E-O-S
+
+while($_ = shift)
+{
+    /^-v(\d*)$/ && ($verbose=($1 eq '') ? 1 : $1,1) && next;
+    /^-d(\d*)$/ &&
+       do {
+           ($1 ne '') && ($delay = $1,1) && next;
+           @ARGV || die("$0: delay value missing after -d\n$usage");
+           $delay = shift;
+           ($delay  >= 0) || die("$0: bad delay value \"$delay\"\n$usage");
+           next;
+       };
+    /^-l$/ &&
+       do {
+           @ARGV || die("$0: logfile missing after -l\n$usage");
+           $logfile = shift;
+           next;
+       };
+    /^-t(\d*(\.\d*)?)$/ &&
+       do {
+           ($1 ne '') && ($timeout = $1,1) && next;
+           @ARGV || die("$0: timeout value missing after -t\n$usage\n");
+           $timeout = shift;
+           ($timeout > 0) ||
+               die("$0: bad timeout value \"$timeout\"\n$usage");
+           next;
+       };
+    
+    /^-/ && die("$0: unknown option \"$_\"\n$usage");
+
+    ;# any other argument is server to poll
+    $ntpserver = $_;
+    last;
+}
+
+if (@ARGV)
+{
+    warn("unexpected arguments: ".join(" ",@ARGV).".\n");
+    die("$0: too many servers specified\n$usage");
+}
+
+;# logfile defaults to include server name
+;# The name of the current month is appended and
+;# the file is opened and closed for each sample.
+;#
+$logfile = "loopstats:$ntpserver." unless defined($logfile);
+$timeout = 12.0 unless defined($timeout); # wait $timeout seconds for reply
+
+$MAX_FAIL = 60;                                # give up after $MAX_FAIL failed polls
+
+
+$MJD_1970 = 40587;
+
+if (eval 'require "syscall.ph";')
+{
+    if (defined(&SYS_gettimeofday))
+    {
+       ;# assume standard
+       ;# gettimeofday(struct timeval *tp,struct timezone *tzp)
+       ;# syntax for gettimeofday syscall
+       ;# tzp = NULL -> undef
+       ;# tp = (long,long)
+       eval 'sub time { local($tz) = pack("LL",0,0);
+              (&msg("gettimeofday failed: $!\n"),
+             return (time))
+             unless syscall(&SYS_gettimeofday,$tz,undef) == 0;
+              local($s,$us) = unpack("LL",$tz);
+              return $s + $us/1000000; }';
+       local($t1,$t2,$t3);
+       $t1 = time;
+       eval '$t2 = &time;';
+       $t3 = time;
+       die("$0: gettimeofday failed: $@.\n") if defined($@) && $@;
+       die("$0: gettimeofday inconsistency time=$t1,gettimeofday=$t2,time=$t2\n")
+           if (int($t1) != int($t2) && int($t3) != int($t2));
+       &msg("Using gettimeofday for timestamps\n");
+    }
+    else
+    {
+       warn("No gettimeofday syscall found - using time builtin for timestamps\n");
+        eval 'sub time { return time; }';
+    }
+}
+else
+{
+    warn("No syscall.ph file found - using time builtin for timestamps\n");
+    eval 'sub time { return time; }';
+}
+
+
+;#------------------+
+;# from ntp_request.h
+;#------------------+
+
+;# NTP mode 7 packet format:
+;#     Byte 1:     ResponseBit MoreBit Version(3bit) Mode(3bit)==7
+;#      Byte 2:     AuthBit Sequence #   - 0 - 127 see MoreBit
+;#      Byte 3:     Implementation #
+;#      Byte 4:     Request Code
+;#
+;#      Short 1:    Err(3bit) NumItems(12bit)
+;#      Short 2:    MBZ(3bit)=0 DataItemSize(12bit)
+;#      0 - 500 byte Data 
+;#  if AuthBit is set:
+;#      Long:       KeyId
+;#      2xLong:     AuthCode
+
+;# 
+$IMPL_XNTPD  = 2;
+$REQ_LOOP_INFO = 8;
+
+
+;# request packet for REQ_LOOP_INFO:
+;#     B1:  RB=0 MB=0 V=2 M=7 
+;#     B2:  S# = 0
+;#     B3:  I# = IMPL_XNTPD
+;#     B4:  RC = REQ_LOOP_INFO
+;#     S1:  E=0 NI=0
+;#     S2:  MBZ=0 DIS=0
+;#     data:  32 byte 0 padding
+;#            8byte timestamp if encryption, 0 padding otherwise
+$loopinfo_reqpkt = 
+    pack("CCCC nn x32 x8", 0x17, 0, $IMPL_XNTPD, $REQ_LOOP_INFO, 0, 0);
+
+;# ignore any auth data in packets
+$loopinfo_response_size =
+    1+1+1+1+2+2                        # header size like request pkt
+    + 8                                # l_fp last_offset
+    + 8                                # l_fp drift_comp
+    + 4                                # u_long compliance
+    + 4                                # u_long watchdog_timer
+    ;
+$loopinfo_response_fmt    = "C4n2N2N2NN"; 
+$loopinfo_response_fmt_v2 = "C4n2N2N2N2N"; 
+
+;#
+;# prepare connection to server
+;# 
+
+;# workaround for broken socket.ph on dynix_ptx
+eval 'sub INTEL {1;}' unless defined(&INTEL);
+eval 'sub ATT {1;}'  unless defined(&ATT);
+
+require "sys/socket.ph";
+
+require 'netinet/in.ph';
+
+;# if you do not have netinet/in.ph enable the following lines
+;#eval 'sub INADDR_ANY { 0x00000000; }' unless defined(&INADDR_ANY);
+;#eval 'sub IPPRORO_UDP { 17; }' unless defined(&IPPROTO_UDP);
+
+if ($ntpserver =~ /^((0x?)?\w+)\.((0x?)?\w+)\.((0x?)?\w+)\.((0x?)?\w+)$/)
+{
+    local($a,$b,$c,$d) = ($1,$3,$5,$7);
+    $a = oct($a) if defined($2);
+    $b = oct($b) if defined($4);
+    $c = oct($c) if defined($6);
+    $d = oct($d) if defined($8);
+    $server_addr = pack("C4", $a,$b,$c,$d);
+
+    $server_mainname
+       = (gethostbyaddr($server_addr,&AF_INET))[$[] || $ntpserver;
+}
+else
+{
+    ($server_mainname,$server_addr)
+       = (gethostbyname($ntpserver))[$[,$[+4];
+
+    die("$0: host \"$ntpserver\" is unknown\n")
+       unless defined($server_addr);
+}
+&msg ("Address of server \"$ntpserver\" is \"%d.%d.%d.%d\"\n",
+      unpack("C4",$server_addr));
+
+$proto_udp = (getprotobyname('udp'))[$[+2] || &IPPROTO_UDP;
+$ntp_port =
+    (getservbyname('ntp','udp'))[$[+2] ||
+    (warn "Could not get port number for service \"ntp/udp\" using 123\n"),
+    ($ntp_port=123);
+;# 
+0 && &SOCK_DGRAM;              # satisfy perl -w ...
+socket(S, &AF_INET, &SOCK_DGRAM, $proto_udp) ||
+    die("Cannot open socket: $!\n");
+
+bind(S, pack("S n N x8", &AF_INET, 0, &INADDR_ANY)) ||
+    die("Cannot bind: $!\n");
+($my_port, $my_addr) = (unpack("S n a4 x8",getsockname(S)))[$[+1,$[+2];
+
+&msg("Listening at address %d.%d.%d.%d port %d\n",
+     unpack("C4",$my_addr), $my_port);
+
+$server_inaddr = pack("Sna4x8", &AF_INET, $ntp_port, $server_addr);
+
+;############################################################
+;#
+;# the main loop:
+;#     send request
+;#      get reply
+;#      wait til next sample time
+
+undef($lasttime);
+$lostpacket = 0;
+
+while(1)
+{
+    $stime = &time;
+
+    &msg("Sending request $stime...\n");
+
+    $ret = send(S,$loopinfo_reqpkt,0,$server_inaddr);
+
+    if (! defined($ret) || $ret < length($loopinfo_reqpkt))
+    {
+       warn("$0: send failed ret=($ret): $!\n");
+       $fail++;
+       next;
+    }
+
+    &msg("Waiting for reply...\n");
+
+    $mask = ""; vec($mask,fileno(S),1) = 1;
+    $ret = select($mask,undef,undef,$timeout);
+
+    if (! defined($ret))
+    {
+       warn("$0: select failed: $!\n");
+       $fail++;
+       next;
+    }
+    elsif ($ret == 0)
+    {
+       warn("$0: request to $ntpserver timed out ($timeout seconds)\n");
+       ;# do not count this event as failure
+       ;# it usually this happens due to dropped udp packets on noisy and
+       ;# havily loaded lines, so just try again;
+       $lostpacket = 1;
+       next;
+    }
+
+    &msg("Receiving reply...\n");
+
+    $len = 520;                                # max size of a mode 7 packet
+    $reply = "";                       # just make it defined for -w
+    $ret = recv(S,$reply,$len,0);
+
+    if (!defined($ret))
+    {
+       warn("$0: recv failed: $!\n");
+       $fail++;
+       next;
+    }
+
+    $etime = &time;
+    &msg("Received at\t$etime\n");
+
+    ;#$time = ($stime + $etime) / 2; # symmetric delay assumed
+    $time = $etime;            # the above assumption breaks for X25
+                              ;# so taking etime makes timestamps be a
+                              ;# little late, but keeps them increasing
+                              ;# monotonously
+
+    &msg(sprintf("Reply from %d.%d.%d.%d took %f seconds\n",
+                (unpack("SnC4",$ret))[$[+2 .. $[+5], ($etime - $stime)));
+
+    if ($len < $loopinfo_response_size)
+    {
+       warn("$0: short packet ($len bytes) received ($loopinfo_response_size bytes expected\n");
+       $fail++;
+       next;
+    }
+    
+    ($b1,$b2,$b3,$b4,$s1,$s2,
+     $offset_i,$offset_f,$drift_i,$drift_f,$compl,$watchdog)
+       = unpack($loopinfo_response_fmt,$reply);
+
+    ;# check reply
+    if (($s1 >> 12) != 0)            # error !
+    {
+       die("$0: got error reply ".($s1>>12)."\n");
+    }
+    if (($b1 != 0x97 && $b1 != 0x9f) || # Reply NotMore V=2 M=7
+       ($b2 != 0 && $b2 != 0x80) ||    # S=0 Auth no/yes
+       $b3 != $IMPL_XNTPD ||           # ! IMPL_XNTPD
+       $b4 != $REQ_LOOP_INFO ||        # Ehh.. not loopinfo reply ?
+       $s1 != 1 ||                     # ????
+       ($s2 != 24 && $s2 != 28)        # 
+       )
+    {
+       warn("$0: Bad/unexpected reply from server:\n");
+       warn("  \"".unpack("H*",$reply)."\"\n");
+       warn("   ".sprintf("b1=%x b2=%x b3=%x b4=%x s1=%d s2=%d\n",
+                          $b1,$b2,$b3,$b4,$s1,$s2));
+       $fail++;
+       next;
+    }
+    elsif ($s2 == 28)
+    {
+      ;# seems to be a version 2 xntpd
+      ($b1,$b2,$b3,$b4,$s1,$s2,
+       $offset_i,$offset_f,$drift_i,$drift_f,$compl_i,$compl_f,$watchdog)
+         = unpack($loopinfo_response_fmt_v2,$reply);
+      $compl = &lfptoa($compl_i, $compl_f);
+    }
+
+    $time -= $watchdog;
+
+    $offset = &lfptoa($offset_i, $offset_f);
+    $drift  = &lfptoa($drift_i, $drift_f);
+
+    &log($time,$offset,$drift,$compl) && ($fail = 0);;
+}
+continue
+{
+    die("$0: Too many failures - terminating\n") if $fail > $MAX_FAIL;
+    &msg("Sleeping " . ($lostpacket ? ($delay / 2) : $delay) . " seconds...\n");
+
+    sleep($lostpacket ? ($delay / 2) : $delay);
+    $lostpacket = 0;
+}
+
+sub log
+{
+    local($time,$offs,$freq,$cmpl) = @_;
+    local($y,$m,$d);
+    local($fname,$suff) = ($logfile);
+
+
+    ;# silently drop sample if distance to last sample is too low
+    if (defined($lasttime) && ($lasttime + 2) >= $time)
+    {
+      &msg("Dropped packet - old sample\n");
+      return 1;
+    }
+
+    ;# $suff determines which samples end up in the same file
+    ;# could have used $year (;-) or WeekOfYear, DayOfYear,....
+    ;# Change it to your suit...
+
+    ($d,$m,$y) = (localtime($time))[$[+3 .. $[+5];
+    $suff = sprintf("%04d%02d%02d",$y+1900,$m+1,$d);
+    $fname .= $suff;
+    if (!open(LOG,">>$fname"))
+    {
+       warn("$0: open($fname) failed: $!\n");
+       $fail++;
+       return 0;
+    }
+    else
+    {
+       ;# file format
+       ;#          MJD seconds offset drift compliance
+       printf LOG ("%d %.3lf %.8lf %.7lf %d\n",
+                   int($time/86400)+$MJD_1970,
+                   $time - int($time/86400) * 86400,
+                   $offs,$freq,$cmpl);
+       close(LOG);
+       $lasttime = $time;
+    }
+    return 1;
+}
+
+;# see ntp_fp.h to understand this
+sub lfptoa
+{
+    local($i,$f) = @_;
+    local($sign) = 1;
+
+    
+    if ($i & 0x80000000)
+    {
+       if ($f == 0)
+       {
+           $i = -$i;
+       }
+       else
+       {
+           $f = -$f;
+           $i = ~$i;
+           $i += 1;                    # 2s complement
+       }
+       $sign = -1;
+       ;#print "NEG: $i $f\n";
+    }
+    else
+    {
+       ;#print "POS: $i $f\n";
+    }
+    ;# unlike xntpd I have perl do the dirty work.
+    ;# Using floats here may affect precision, but
+    ;# currently these bits aren't significant anyway
+    return $sign * ($i + $f/2**32);    
+}
diff --git a/scripts/monitoring/ntploopwatch b/scripts/monitoring/ntploopwatch
new file mode 100644 (file)
index 0000000..a94695c
--- /dev/null
@@ -0,0 +1,1667 @@
+#!/usr/bin/perl -w
+;# --*-perl-*--
+;#
+;# /src/NTP/ntp4-dev/scripts/monitoring/ntploopwatch,v 4.7 2004/11/14 16:11:05 kardel RELEASE_20050508_A
+;#
+;# process loop filter statistics file and either
+;#     - show statistics periodically using gnuplot
+;#     - or print a single plot
+;#
+;#  Copyright (c) 1992-1998 
+;#  Rainer Pruy, Friedrich-Alexander Universität Erlangen-Nürnberg
+;#
+;#
+;#############################################################
+$0 =~ s!^.*/([^/]+)$!$1!;
+$F = ' ' x length($0);
+$|=1;
+
+$ENV{'SHELL'} = '/bin/sh'; # use bourne shell
+
+undef($config);
+undef($workdir);
+undef($PrintIt);
+undef($samples);
+undef($StartTime);
+undef($EndTime);
+($a,$b) if 0;                  # keep -w happy
+$usage = <<"E-O-P";
+usage:
+  to watch statistics permanently:
+     $0 [-v[<level>]] [-c <config-file>] [-d <working-dir>]
+     $F [-h <hostname>]
+
+  to get a single print out specify also
+     $F -P[<printer>] [-s<samples>]
+     $F               [-S <start-time>] [-E <end-time>]
+     $F               [-Y <MaxOffs>] [-y <MinOffs>]
+
+If You like long option names, You can use:
+    -help
+    -c    +config
+    -d    +directory
+    -h    +host
+    -v    +verbose[=<level>]
+    -P    +printer[=<printer>]
+    -s    +samples[=<samples>]
+    -S    +starttime
+    -E    +endtime
+    -Y    +maxy
+    -y    +miny
+
+If <printer> contains a '/' (slash character) output is directed to 
+a file of this name instead of delivered to a printer.
+E-O-P
+
+;# add directory to look for lr.pl and timelocal.pl (in front of current list)
+unshift(@INC,".");
+
+require "lr.pl";       # linear regresion routines
+
+$MJD_1970 = 40587;             # from ntp.h (V3)
+$RecordSize = 48;              # usually a line fits into 42 bytes
+$MinClip = 1;          # clip Y scales with greater range than this
+
+;# largest extension of Y scale from mean value, factor for standart deviation
+$FuzzLow = 2.2;                        # for side closer to zero
+$FuzzBig = 1.8;                        # for side farther from zero
+
+require "ctime.pl";
+require "timelocal.pl";
+;# early distributions of ctime.pl had a bug
+$ENV{'TZ'} = 'MET' unless defined $ENV{'TZ'} || $[ > 4.010;
+if (defined(@ctime'MoY))
+{
+  *Month=*ctime'MoY;
+  *Day=*ctime'DoW;
+}                                      # ' re-sync emacs fontification
+else
+{
+  @Month = ('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
+  @Day   = ('Sun','Mon','Tue','Wed','Thu','Fri','Sat');
+}
+print @ctime'DoW if 0; # ' re-sync emacs fontification
+
+;# max number of days per month
+@MaxNumDaysPerMonth = (31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
+
+;# config settable parameters
+$delay = 60;
+$srcprefix = "./var\@\$STATHOST/loopstats.";
+$showoffs = 1;
+$showfreq = 1;
+$showcmpl = 0;
+$showoreg = 0;
+$showfreg = 0;
+undef($timebase);
+undef($freqbase);
+undef($cmplscale);
+undef($MaxY);
+undef($MinY);
+$deltaT  = 512; # indicate sample data gaps greater than $deltaT seconds
+$verbose = 1;
+
+while($_ = shift(@ARGV))
+{
+    (/^[+-]help$/) && die($usage);
+    
+    (/^-c$/ || /^\+config$/) &&
+       (@ARGV || die($usage), $config = shift(@ARGV), next);
+
+    (/^-d$/ || /^\+directory$/) &&
+       (@ARGV || die($usage), $workdir = shift(@ARGV), next);
+
+    (/^-h$/ || /^\+host$/) &&
+       (@ARGV || die($usage), $STATHOST = shift, next);
+    
+    (/^-v(\d*)$/ || /^\+verbose=?(\d*)$/) &&
+       ($verbose=($1 eq "") ? 1 : $1, next);
+
+    (/^-P(\S*)$/ || /^\+[Pp]rinter=?(\S*)$/) &&
+       ($PrintIt = $1, $verbose==1 && ($verbose = 0), next);
+
+    (/^-s(\d*)$/ || /^\+samples=?(\d*)$/) &&
+       (($samples = ($1 eq "") ? (shift || die($usage)): $1), next);
+    
+    (/^-S$/ || /^\+[Ss]tart[Tt]ime$/) &&
+       (@ARGV || die($usage), $StartTime=&date_time_spec2seconds(shift),next);
+
+    (/^-E$/ || /^\+[Ee]nd[Tt]ime$/) &&
+       (@ARGV || die($usage), $EndTime = &date_time_spec2seconds(shift),next);
+    
+    (/^-Y$/ || /^\+[Mm]ax[Yy]$/) &&
+       (@ARGV || die($usage), $MaxY = shift, next);
+    
+    (/^-y$/ || /^\+[Mm]in[Yy]$/) &&
+       (@ARGV || die($usage), $MinY = shift, next);
+    
+    die("$0: unexpected argument \"$_\"\n$usage");
+}
+
+if (defined($workdir))
+{
+  chdir($workdir) ||
+      die("$0: failed to change working dir to \"$workdir\": $!\n");
+}
+
+$PrintIt = "ps" if defined($PrintIt) && $PrintIt eq "";
+
+if (!defined($PrintIt))
+{
+    defined($samples) &&
+       print "WARNING: your samples value may be shadowed by config file settings\n";
+    defined($StartTime) &&
+       print "WARNING: your StartTime value may be shadowed by config file settings\n";
+    defined($EndTime) &&
+       print "WARNING: your EndTime value may be shadowed by config file settings\n";
+    defined($MaxY) &&
+       print "WARNING: your MaxY value may be shadowed by config file settings\n";
+    defined($MinY) &&
+       print "WARNING: your MinY value may be shadowed by config file settings\n";
+       
+    ;# check operating environment
+    ;# 
+    ;# gnuplot usually has X support
+    ;# I vaguely remember there was one with sunview support
+    ;#
+    ;# If Your plotcmd can display graphics using some other method
+    ;# (Tek window,..) fix the following test
+    ;# (or may be, just disable it)
+    ;#
+    !(defined($ENV{'DISPLAY'}) || defined($ENV{'WINDOW_PARENT'})) &&
+       die("Need window system to monitor statistics\n");
+}
+
+;# configuration file
+$config = "loopwatch.config" unless defined($config);
+($STATHOST = $config) =~ s!.*loopwatch\.config.([^/\.]*)$!$1!
+    unless defined($STATHOST);
+($STATTAG = $STATHOST) =~ s/^([^\.\*\s]+)\..*$/$1/;
+
+$srcprefix =~ s/\$STATHOST/$STATHOST/g;
+
+;# plot command 
+@plotcmd=("gnuplot",
+         '-title', "Ntp loop filter statistics $STATHOST",
+         '-name', "NtpLoopWatch_$STATTAG");
+$tmpfile = "/tmp/ntpstat.$$";
+
+;# other variables
+$doplot = "";  # assembled command for @plotcmd to display plot
+undef($laststat);
+
+;# plot value ranges
+undef($mintime);
+undef($maxtime);
+undef($minoffs);
+undef($maxoffs);
+undef($minfreq);
+undef($maxfreq);
+undef($mincmpl);
+undef($maxcmpl);
+undef($miny);
+undef($maxy);
+
+;# stop operation if plot command dies
+sub sigchld
+{
+  local($pid) = wait;
+  unlink($tmpfile);
+  warn(sprintf("%s: %s died: exit status: %d signal %d\n",
+             $0,
+              (defined($Plotpid) && $Plotpid == $pid)
+              ? "plotcmd" : "unknown child $pid",
+              $?>>8,$? & 0xff)) if $?;
+  exit(1) if $? && defined($Plotpid) && $pid == $Plotpid;
+}
+&sigchld if 0;
+$SIG{'CHLD'} = "sigchld";
+$SIG{'CLD'} = "sigchld";
+
+sub abort
+{
+  unlink($tmpfile);
+  defined($Plotpid) && kill('TERM',$Plotpid);
+  die("$0: received signal SIG$_[$[] - exiting\n");
+}
+&abort if 0;   # make -w happy - &abort IS used
+$SIG{'INT'} = $SIG{'HUP'} = $SIG{'QUIT'} = $SIG{'TERM'} = $SIG{'PIPE'} = "abort";
+
+;#
+sub abs
+{
+  ($_[$[] < 0) ? -($_[$[]) : $_[$[];
+}
+
+sub boolval
+{
+  local($v) = ($_[$[]);
+
+  return 1 if ($v eq 'yes') || ($v eq 'y');
+  return 1 if ($v =~ /^[0-9]*$/) && ($v != 0);
+  return 0;
+}
+
+;#####################
+;# start of real work 
+
+print "starting plot command (" . join(" ",@plotcmd) . ")\n" if $verbose > 1;
+
+$Plotpid = open(PLOT,"|-");
+select((select(PLOT),$|=1)[$[]);       # make PLOT line bufferd
+
+defined($Plotpid) ||
+    die("$0: failed to start plot command: $!\n");
+
+unless ($Plotpid)
+{
+   ;# child == plot command
+   close(STDOUT);
+   open(STDOUT,">&STDERR") ||
+       die("$0: failed to redirect STDOUT of plot command: $!\n");
+   
+   print STDOUT "plot command running as $$\n";
+
+   exec @plotcmd;
+   die("$0: failed to exec (@plotcmd): $!\n");
+   exit(1); # in case ...
+}
+
+sub read_config
+{
+  local($at) = (stat($config))[$[+9];
+  local($_,$c,$v);
+
+  (undef($laststat),(print("stat $config failed: $!\n")),return) if ! defined($at);
+  return if (defined($laststat) && ($laststat == $at));
+  $laststat = $at;
+
+  print "reading configuration from \"$config\"\n" if $verbose;
+
+  open(CF,"<$config") ||
+      (warn("$0: failed to read \"$config\" - using old settings ($!)\n"),
+       return);
+  while(<CF>)
+  {
+    chop;
+    s/^([^\#]*[^\#\s]?)\s*\#.*$//;
+    next if /^\s*$/;
+
+    s/^\s*([^=\s]*)\s*=\s*(.*\S)\s*$/$1=$2/;
+
+    ($c,$v) = split(/=/,$_,2);
+    print "processing \"$c=$v\"\n" if $verbose > 3;
+    ($c eq "delay") && ($delay = $v,1) && next;
+    ($c eq 'samples') && (!defined($PrintIt) || !defined($samples)) &&
+       ($samples = $v,1) && next;
+    ($c eq 'srcprefix') && (($srcprefix=$v)=~s/\$STATHOST/$STATHOST/g,1)
+       && next;
+    ($c eq 'showoffs') &&
+       ($showoffs = boolval($v),1) && next;
+    ($c eq 'showfreq') &&
+       ($showfreq = boolval($v),1) && next;
+    ($c eq 'showcmpl') &&
+       ($showcmpl = boolval($v),1) && next;
+    ($c eq 'showoreg') &&
+       ($showoreg = boolval($v),1) && next;
+    ($c eq 'showfreg') &&
+       ($showfreg = boolval($v),1) && next;
+
+    ($c eq 'exit') && (unlink($tmpfile),die("$0: exit by config request\n"));
+
+    ($c eq 'freqbase' ||
+     $c eq 'cmplscale') &&
+       do {
+           if (! defined($v) || $v eq "" || $v eq 'dynamic')
+           {
+             eval "undef(\$$c);";
+           }
+           else
+           {
+             eval "\$$c = \$v;";
+           }
+           next;
+       };
+    ($c eq 'timebase') &&
+       do {
+           if (! defined($v) || $v eq "" || $v eq "dynamic")
+           {
+             undef($timebase);
+           }
+           else
+           {
+             $timebase=&date_time_spec2seconds($v);
+           }
+       };
+    ($c eq 'EndTime') &&
+       do {
+           next if defined($EndTime) && defined($PrintIt);
+           if (! defined($v) || $v eq "" || $v eq "none")
+           {
+             undef($EndTime);
+           }
+           else
+           {
+             $EndTime=&date_time_spec2seconds($v);
+           }
+       };
+    ($c eq 'StartTime') &&
+       do {
+           next if defined($StartTime) && defined($PrintIt);
+           if (! defined($v) || $v eq "" || $v eq "none")
+           {
+             undef($StartTime);
+           }
+           else
+           {
+             $StartTime=&date_time_spec2seconds($v);
+           }
+       };
+
+    ($c eq 'MaxY') &&
+       do {
+           next if defined($MaxY) && defined($PrintIt);
+           if (! defined($v) || $v eq "" || $v eq "none")
+           {
+             undef($MaxY);
+           }
+           else
+           {
+             $MaxY=$v;
+           }
+       };
+
+    ($c eq 'MinY') &&
+       do {
+           next if defined($MinY) && defined($PrintIt);
+           if (! defined($v) || $v eq "" || $v eq "none")
+           {
+             undef($MinY);
+           }
+           else
+           {
+             $MinY=$v;
+           }
+       };
+
+    ($c eq 'deltaT') &&
+       do {
+           if (!defined($v) || $v eq "")
+           {
+             undef($deltaT);
+           }
+           else
+           {
+             $deltaT = $v;
+           }
+           next;
+       };
+    ($c eq 'verbose') && ! defined($PrintIt) &&
+       do {
+            if (!defined($v) || $v == 0)
+            {
+              $verbose = 0;
+            }
+            else
+            {
+              $verbose = $v;
+            }
+            next;
+       };
+    ;# otherwise: silently ignore unrecognized config line
+  }
+  close(CF);
+  ;# set show defaults when nothing selected
+  $showoffs = $showfreq = $showcmpl = 1
+      unless $showoffs || $showfreq || $showcmpl;
+  if ($verbose > 3)
+  {
+    print  "new configuration:\n";
+    print  "   delay\t= $delay\n";
+    print  "   samples\t= $samples\n";
+    print  "   srcprefix\t= $srcprefix\n";
+    print  "   showoffs\t= $showoffs\n";
+    print  "   showfreq\t= $showfreq\n";
+    print  "   showcmpl\t= $showcmpl\n";
+    print  "   showoreg\t= $showoreg\n";
+    print  "   showfreg\t= $showfreg\n";
+    printf "   timebase\t= %s",defined($timebase)?&ctime($timebase):"dynamic\n";
+    printf "   freqbase\t= %s\n",defined($freqbase)  ?"$freqbase":"dynamic";
+    printf "   cmplscale\t= %s\n",defined($cmplscale)?"$cmplscale":"dynamic";
+    printf "   StartTime\t= %s",defined($StartTime)?&ctime($StartTime):"none\n";
+    printf "   EndTime\t= %s",  defined($EndTime) ?  &ctime($EndTime):"none\n";
+    printf "   MaxY\t= %s",defined($MaxY)? $MaxY      :"none\n";
+    printf "   MinY\t= %s",defined($MinY)? $MinY      :"none\n";
+    print  "   verbose\t= $verbose\n";
+  }
+print "configuration file read\n" if $verbose > 2;
+}
+
+sub make_doplot($$)
+{
+    my($lo, $lf) = @_;
+    local($c) = ("");
+    local($fmt)
+       = ("%s \"%s\" using 1:%d title '%s <%lf %lf> %6s' with lines");
+    local($regfmt)
+       = ("%s ((%lf * x) + %lf) title 'lin. approx. %s (%f t[h]) %s %f <%f> %6s' with lines");
+    
+    $doplot = "    set title 'NTP loopfilter statistics for $STATHOST  " .
+       "(last $LastCnt samples from $srcprefix*)'\n";
+    
+    local($xts,$xte,$i,$t);
+    
+    local($s,$c) = ("");
+
+    ;# number of integral seconds to get at least 12 tic marks on x axis
+    $t = int(($maxtime - $mintime) / 12 + 0.5);
+    $t = 1 unless $t;          # prevent $t to be zero
+    foreach $i (30,
+               60,5*60,15*60,30*60,
+               60*60,2*60*60,6*60*60,12*60*60,
+               24*60*60,48*60*60)
+    {
+       last if $t < $i;
+       $t = $t - ($t % $i);
+    }
+    print "time label resolution: $t seconds\n" if $verbose > 1;
+    
+    ;# make gnuplot use wall clock time labels instead of NTP seconds
+    for ($c="", $i = $mintime - ($mintime % $t);
+        $i <= $maxtime + $t;
+        $i += $t, $c=",")
+    {
+       $s .= $c;
+       ((int($i / $t) % 2) &&
+        ($s .= sprintf("'' %lf",($i - $LastTimeBase)/3600))) ||
+            (($t <= 60) &&
+             ($s .= sprintf("'%d:%02d:%02d' %lf",
+                            (localtime($i))[$[+2,$[+1,$[+0],
+                            ($i - $LastTimeBase)/3600))) 
+                || (($t <= 2*60*60) &&
+                    ($s .= sprintf("'%d:%02d' %lf",
+                                   (localtime($i))[$[+2,$[+1],
+                                   ($i - $LastTimeBase)/3600)))
+                    || (($t <= 12*60*60) &&
+                        ($s .= sprintf("'%s %d:00' %lf",
+                                       $Day[(localtime($i))[$[+6]],
+                                       (localtime($i))[$[+2],
+                                       ($i - $LastTimeBase)/3600)))
+                        || ($s .= sprintf("'%d.%d-%d:00' %lf",
+                                          (localtime($i))[$[+3,$[+4,$[+2],
+                                          ($i - $LastTimeBase)/3600));
+    }
+    $doplot .= "set xtics ($s)\n";
+    
+    chop($xts = &ctime($mintime));
+    chop($xte = &ctime($maxtime));
+    $doplot .= "set xlabel 'Start:  $xts    --   Time Scale   --    End:  $xte'\n";
+    $doplot .= "set yrange [" ;
+    $doplot .= defined($MinY) ? sprintf("%lf", $MinY) : $miny;
+    $doplot .= ':';
+    $doplot .= defined($MaxY) ? sprintf("%lf", $MaxY) : $maxy;
+    $doplot .= "]\n";
+    
+    $doplot .= "   plot";
+    $c = "";
+    $showoffs &&
+       ($doplot .= sprintf($fmt,$c,$tmpfile,2,
+                           "offset",
+                           $minoffs,$maxoffs,
+                           "[ms]"),
+        $c = ",");
+    $LastCmplScale = 1 if ! defined($LastCmplScale);
+    $showcmpl &&
+       ($doplot .= sprintf($fmt,$c,$tmpfile,4,
+                           "compliance" .
+                           (&abs($LastCmplScale) > 1
+                            ? " / $LastCmplScale"
+                            : (&abs($LastCmplScale) == 1 ? "" : " * ".(1/$LastCmplScale))),
+                           $mincmpl/$LastCmplScale,$maxcmpl/$LastCmplScale,
+                           ""),
+        $c = ",");
+    $LastFreqBase = 0 if ! defined($LastFreqBase);
+    $LastFreqBaseString = "?" if ! defined($LastFreqBaseString);
+    $FreqScale = 1 if ! defined($FreqScale);
+    $FreqScaleInv = 1 if ! defined($FreqScaleInv);
+    $showfreq &&
+       ($doplot .= sprintf($fmt,$c,$tmpfile,3,
+                           "frequency" .
+                           ($LastFreqBase > 0
+                            ? " - $LastFreqBaseString" 
+                            : ($LastFreqBase == 0 ? "" : " + $LastFreqBaseString")),
+                           $minfreq * $FreqScale - $LastFreqBase,
+                           $maxfreq * $FreqScale - $LastFreqBase,
+                           "[${FreqScaleInv}ppm]"),
+        $c = ",");
+    $showoreg && $showoffs &&
+       ($doplot .= sprintf($regfmt, $c,
+                           $lo->B(),$lo->A(),
+                           "offset   ",
+                           $lo->B(),
+                           (($lo->A()) < 0 ? '-' : '+'),
+                           &abs($lo->A()), $lo->r(),
+                           "[ms]"),
+        $c = ",");
+    $showfreg && $showfreq &&
+       ($doplot .= sprintf($regfmt, $c,
+                           $lf->B() * $FreqScale,
+                           ($lf->A() + $minfreq) * $FreqScale - $LastFreqBase,
+                           "frequency",
+                           $lf->B() * $FreqScale,
+                           (($lf->A() + $minfreq) * $FreqScale - $LastFreqBase) < 0 ? '-' : '+',
+                           &abs(($lf->A() + $minfreq) * $FreqScale - $LastFreqBase),
+                           $lf->r(),
+                           "[${FreqScaleInv}ppm]"),
+        $c = ",");
+    $doplot .= "\n";
+}
+
+%F_key   = ();
+%F_name  = ();
+%F_size  = ();
+%F_mtime = ();
+%F_first = ();
+%F_last  = ();
+
+sub genfile
+{
+    local($cnt,$in,$out,$lo,$lf,@fpos) = @_;
+    
+    local(@F,@t,$t,$lastT) = ();
+    local(@break,@time,@offs,@freq,@cmpl,@loffset,@filekey) = ();
+    local($lm,$l,@f);
+    
+    local($sdir,$sname);
+    
+    ;# allocate some storage for the tables
+    ;# otherwise realloc may get into troubles
+    if (defined($StartTime) && defined($EndTime))
+    {
+       $l = ($EndTime-$StartTime) -$[+1 +1; # worst case: 1 sample per second
+    }
+    else
+    {
+       $l = $cnt + 10;
+    }
+    print "preextending arrays to $l entries\n" if $verbose > 2;
+    $#break =   $l; for ($i=$[; $i<=$l;$i++) { $break[$i] = 0; }
+    $#time =    $l; for ($i=$[; $i<=$l;$i++) { $time[$i] = 0; }
+    $#offs =    $l; for ($i=$[; $i<=$l;$i++) { $offs[$i] = 0; }
+    $#freq =    $l; for ($i=$[; $i<=$l;$i++) { $freq[$i] = 0; }
+    $#cmpl =    $l; for ($i=$[; $i<=$l;$i++) { $cmpl[$i] = 0; }
+    $#loffset = $l; for ($i=$[; $i<=$l;$i++) { $loffset[$i] = 0; }
+    $#filekey = $l; for ($i=$[; $i<=$l;$i++) { $filekey[$i] = 0; }
+    ;# now reduce size again
+    $#break =   $[ - 1;
+    $#time =    $[ - 1;
+    $#offs =    $[ - 1;
+    $#freq =    $[ - 1;
+    $#cmpl =    $[ - 1;
+    $#loffset = $[ - 1;
+    $#filekey = $[ - 1;
+    print "memory allocation ready\n" if $verbose > 2;
+    sleep(3) if $verbose > 1;
+
+    $fpos[$[] = '' if !defined($fpos[$[]);
+
+    if (index($in,"/") < $[)
+    {
+       $sdir = ".";
+       $sname = $in;
+    }
+    else
+    {
+       ($sdir,$sname) = ($in =~ m!^(.*)/([^/]*)!);
+       $sname = "" unless defined($sname);
+    }
+    
+    $Ltime = -1 if ! defined($Ltime);
+    if (!defined($Lsdir) || $Lsdir ne $sdir || $Ltime != (stat($sdir))[$[+9] ||
+       grep($F_mtime{$_} != (stat($F_name{$_}))[$[+9], @F_files))
+       
+    {
+       print "rescanning directory \"$sdir\" for files \"$sname*\"\n"
+           if $verbose > 1;
+
+       ;# rescan directory on changes
+       $Lsdir = $sdir;
+       $Ltime = (stat($sdir))[$[+9];
+       </X{> if 0;             # dummy line - calm down my formatter
+       local(@newfiles) = < ${in}*[0-9] >;
+       local($st_dev,$st_ino,$st_mtime,$st_size,$name,$key,$modified);
+
+       foreach $name (@newfiles)
+       {
+           ($st_dev,$st_ino,$st_size,$st_mtime) =
+               (stat($name))[$[,$[+1,$[+7,$[+9];
+           $modified = 0;
+           $key = sprintf("%lx|%lu", $st_dev, $st_ino);
+           
+           print "candidate file \"$name\"",
+                  (defined($st_dev) ? "" : " failed: $!"),"\n"
+                     if $verbose > 2;
+           
+           if (! defined($F_key{$name}) || $F_key{$name} ne $key)
+           {
+               $F_key{$name} = $key;
+               $modified++;
+           }
+           if (!defined($F_name{$key}) || $F_name{$key} ne $name)
+           {
+               $F_name{$key} = $name;
+               $modified++;
+           }
+           if (!defined($F_size{$key}) || $F_size{$key} != $st_size)
+           {
+               $F_size{$key} = $st_size;
+               $modified++;
+           }
+           if (!defined($F_mtime{$key}) || $F_mtime{$key} != $st_mtime)
+           {
+               $F_mtime{$key} = $st_mtime;
+               $modified++;
+           }
+           if ($modified)
+           {
+               print "new data \"$name\" key: $key;\n" if $verbose > 1;
+               print "             size: $st_size; mtime: $st_mtime;\n"
+                   if $verbose > 1;
+               $F_last{$key} = $F_first{$key} = $st_mtime;
+               $F_first{$key}--; # prevent zero divide later on
+               ;# now compute derivated attributes
+               open(IN, "<$name") ||
+                   do {
+                       warn "$0: failed to open \"$name\": $!";
+                       next;
+                   };
+
+               while(<IN>)
+               {
+                   @F = split;
+                   next if @F < 5;
+                   next if $F[$[] eq "";
+                   $t = ($F[$[] - $MJD_1970) * 24 * 60 * 60;
+                   $t += $F[$[+1];
+                   $F_first{$key} = $t;
+                   print "\tfound first entry: $t ",&ctime($t)
+                       if $verbose > 4;
+                   last;
+               }
+               seek(IN,
+                    ($st_size > 4*$RecordSize) ? $st_size - 4*$RecordSize : 0,
+                    0);
+               while(<IN>)
+               {
+                   @F = split;
+                   next if @F < 5;
+                   next if $F[$[] eq "";
+                   $t = ($F[$[] - $MJD_1970) * 24 * 60 * 60;
+                   $t += $F[$[+1];
+                   $F_last{$key} = $t;
+                   $_ = <IN>;
+                   print "\tfound last entry: $t ", &ctime($t)
+                       if $verbose > 4 && ! defined($_);
+                   last unless defined($_);
+                   redo;
+                   ;# Ok, calm down...
+                   ;# using $_ = <IN> in conjunction with redo
+                   ;# is semantically equivalent to the while loop, but
+                   ;# I needed a one line look ahead and this solution
+                   ;# was what I thought of first
+                   ;# and.. If you do not like it dont look
+               }
+               close(IN);
+               print("             first: ",$F_first{$key},
+                     " last: ",$F_last{$key},"\n") if $verbose > 1;
+           }
+       }
+       ;# now reclaim memory used for files no longer referenced ...
+       local(%Names);
+       grep($Names{$_} = 1,@newfiles);
+       foreach (keys %F_key)
+       {
+           next if defined($Names{$_});
+           delete $F_key{$_};
+           $verbose > 2 && print "no longer referenced: \"$_\"\n";
+       }
+       %Names = ();
+       
+       grep($Names{$_} = 1,values(%F_key));
+       foreach (keys %F_name)
+       {
+           next if defined($Names{$_});
+           delete $F_name{$_};
+           $verbose > 2 && print "unref name($_)= $F_name{$_}\n";
+       }
+       foreach (keys %F_size)
+       {
+           next if defined($Names{$_});
+           delete $F_size{$_};
+           $verbose > 2 && print "unref size($_)\n";
+       }
+       foreach (keys %F_mtime)
+       {
+           next if defined($Names{$_});
+           delete $F_mtime{$_};
+           $verbose > 2 && print "unref mtime($_)\n";
+       }
+       foreach (keys %F_first)
+       {
+           next if defined($Names{$_});
+           delete $F_first{$_};
+           $verbose > 2 && print "unref first($_)\n";
+       }
+       foreach (keys %F_last)
+       {
+           next if defined($Names{$_});
+           delete $F_last{$_};
+           $verbose > 2 && print "unref last($_)\n";
+       }
+       ;# create list sorted by time
+       @F_files = sort {$F_first{$a} <=> $F_first{$b}; } keys(%F_name);
+       if ($verbose > 1)
+       {
+           print "Resulting file list:\n";
+           foreach (@F_files)
+           {
+               print "\t$_\t$F_name{$_}\n";
+           }
+       }
+    }
+    
+    printf("processing %s; output \"$out\" (%d input files)\n",
+          ((defined($StartTime) && defined($EndTime))
+           ? "time range"
+           : (defined($StartTime) ? "$cnt samples from StartTime" :
+             (defined($EndTime) ? "$cnt samples to EndTime" :
+                "last $cnt samples"))),
+           scalar(@F_files))
+       if $verbose > 1;
+    
+    ;# open output file - will be input for plotcmd
+    open(OUT,">$out") || 
+       do {
+           warn("$0: cannot create \"$out\": $!\n");
+       };
+    
+    @f = @F_files;
+    if (defined($StartTime))
+    {
+       while (@f && ($F_last{$f[$[]} < $StartTime))
+       {
+           print("shifting ", $F_name{$f[$[]},
+                 " last: ", $F_last{$f[$[]},
+                 " < StartTime: $StartTime\n")
+               if $verbose > 3;
+           shift(@f);
+       }
+
+
+    }
+    if (defined($EndTime))
+    {
+       while (@f && ($F_first{$f[$#f]} > $EndTime))
+       {
+           print("popping  ", $F_name{$f[$#f]},
+                 " first: ", $F_first{$f[$#f]},
+                 " > EndTime: $EndTime\n")
+               if $verbose > 3;
+           pop(@f);
+       }
+    }
+    
+    if (@f)
+    {
+       if (defined($StartTime))
+       {
+           print "guess start according to StartTime ($StartTime)\n"
+               if $verbose > 3;
+
+           if ($fpos[$[] eq 'start')
+           {
+               if (grep($_ eq $fpos[$[+1],@f))
+               {
+                   shift(@f) while @f && $f[$[] ne $fpos[$[+1];
+               }
+               else
+               {
+                   @fpos = ('start', $f[$[], undef);
+               }
+           }
+           else
+           {
+               @fpos = ('start' , $f[$[], undef);
+           }
+           
+           if (!defined($fpos[$[+2]))
+           {
+               if ($StartTime <= $F_first{$f[$[]})
+               {
+                   $fpos[$[+2] = 0;
+               }
+               else
+               {
+                   $fpos[$[+2] =
+                       int($F_size{$f[$[]} *
+                           (($StartTime - $F_first{$f[$[]})/
+                            ($F_last{$f[$[]} - $F_first{$f[$[]})));
+                   $fpos[$[+2] = ($fpos[$[+2] <= 2 * $RecordSize)
+                       ? 0 : $fpos[$[+2] - 2 * $RecordSize;
+                   ;# anyway  as the data may contain "time holes" 
+                   ;# our heuristics may baldly fail
+                   ;# so just start at 0
+                   $fpos[$[+2] = 0;
+               }
+           }
+       }
+       elsif (defined($EndTime))
+       {
+           print "guess starting point according to EndTime ($EndTime)\n"
+               if $verbose > 3;
+           
+           if ($fpos[$[] eq 'end')
+           {
+               if (grep($_ eq $fpos[$[+1],@f))
+               {
+                   shift(@f) while @f && $f[$[] ne $fpos[$[+1];
+               }
+               else
+               {
+                   @fpos = ('end', $f[$[], undef);
+               }
+           }
+           else
+           {
+               @fpos = ('end', $f[$[], undef);
+           }
+           
+           if (!defined($fpos[$[+2]))
+           {
+               local(@x) = reverse(@f);
+               local($s,$c) = (0,$cnt);
+               if ($EndTime < $F_last{$x[$[]})
+               {
+                   ;# last file will only be used partially
+                   $s = int($F_size{$x[$[]} *
+                            (($EndTime - $F_first{$x[$[]}) /
+                             ($F_last{$x[$[]} - $F_first{$x[$[]})));
+                   $s = int($s/$RecordSize);
+                   $c -= $s - 1;
+                   if ($c <= 0)
+                   {
+                       ;# start is in the same file
+                       $fpos[$[+1] = $x[$[];
+                       $fpos[$[+2] = ($c >=-2) ? 0 : (-$c - 2) * $RecordSize;
+                       shift(@f) while @f && ($f[$[] ne $x[$[]);
+                   }
+                   else
+                   {
+                       shift(@x);
+                   }
+               }
+               
+               if (!defined($fpos[$[+2]))
+               {
+                   local($_);
+                   while($_ = shift(@x))
+                   {
+                       $s = int($F_size{$_}/$RecordSize);
+                       $c -= $s - 1;
+                       if ($c <= 0)
+                       {
+                           $fpos[$[+1] = $_;
+                           $fpos[$[+2] = ($c>-2) ? 0 : (-$c - 2) * $RecordSize;
+                           shift(@f) while @f && ($f[$[] ne $_);
+                           last;
+                       }
+                   }
+               }
+           }
+       }
+       else
+       {
+           print "guessing starting point according to count ($cnt)\n"
+               if $verbose > 3;
+           ;# guess offset to get last available $cnt samples
+           if ($fpos[$[] eq 'cnt')
+           {
+               if (grep($_ eq $fpos[$[+1],@f))
+               {
+                   print "old positioning applies\n" if $verbose > 3;
+                   shift(@f) while @f && $f[$[] ne $fpos[$[+1];
+               }
+               else
+               {
+                   @fpos = ('cnt', $f[$[], undef);
+               }
+           }
+           else
+           {
+               @fpos = ('cnt', $f[$[], undef);
+           }
+           
+           if (!defined($fpos[$[+2]))
+           {
+               local(@x) = reverse(@f);
+               local($s,$c) = (0,$cnt);
+               
+               local($_);
+               while($_ = shift(@x))
+               {
+                   print "examing \"$_\" $c samples still needed\n"
+                       if $verbose > 4;
+                   $s = int($F_size{$_}/$RecordSize);
+                   $c -= $s - 1;
+                   if ($c <= 0)
+                   {
+                       $fpos[$[+1] = $_;
+                       $fpos[$[+2] = ($c>-2) ? 0 : (-$c - 2) * $RecordSize;
+                       shift(@f) while @f && ($f[$[] ne $_);
+                       last;
+                   }
+               }
+               if (!defined($fpos[$[+2]))
+               {
+                   print "no starting point yet - using start of data\n"
+                       if $verbose > 2;
+                   $fpos[$[+2] = 0;
+               }
+           }
+       }
+    }
+    print "Ooops, no suitable input file ??\n"
+       if $verbose > 1 && @f <= 0;
+
+    printf("Starting at (%s) \"%s\" offset %ld using %d files\n",
+          $fpos[$[+1],
+          $F_name{$fpos[$[+1]},
+          $fpos[$[+2],
+          scalar(@f))
+       if $verbose > 2;
+
+    $lm = 1;
+    $l = 0;    
+    foreach $key (@f)
+    {
+       $file = $F_name{$key};
+       print "processing file \"$file\"\n" if $verbose > 2;
+       
+       open(IN,"<$file") ||
+           (warn("$0: cannot read \"$file\": $!\n"), next);
+       
+       ;# try to seek to a position nearer to the start of the interesting lines
+       ;# should always affect only first item in @f
+       ($key eq $fpos[$[+1]) &&
+           (($verbose > 1) &&
+            print("Seeking to offset $fpos[$[+2]\n"),
+               seek(IN,$fpos[$[+2],0) ||
+                   warn("$0: seek(\"$F_name{$key}\" failed: $|\n"));
+       
+       while(<IN>)
+       {
+           $l++;
+           ($verbose > 3) &&
+               (($l % $lm) == 0 && print("\t$l lines read\n") &&
+                (($l ==     2) && ($lm =    10) ||
+                 ($l ==   100) && ($lm =   100) ||
+                 ($l ==   500) && ($lm =   500) ||
+                 ($l ==  1000) && ($lm =  1000) ||
+                 ($l ==  5000) && ($lm =  5000) ||
+                 ($l == 10000) && ($lm = 10000)));
+           
+           @F = split;
+           
+           next if @F < 6;     # no valid input line is this short
+           next if $F[$[] eq "";
+           next if ($F[$[] !~ /^\d+$/);
+           ($F[$[] !~ /^\d+$/) && # A 'never should have happend' error
+               die("$0: unexpected input line: >$_<\n");
+           
+           ;# modified Julian to UNIX epoch
+           $t = ($F[$[] - $MJD_1970) * 24 * 60 * 60;
+           $t += $F[$[+1];     # add seconds + fraction
+           
+           ;# multiply offset by 1000 to get ms - try to avoid float op
+           (($F[$[+2] =~ s/(\d*)\.(\d{3})(\d*)/$1$2.$3/) &&
+            $F[$[+2] =~ s/0+([\d\.])/($1 eq '.') ? '0.' : $1/e) # strip leading zeros
+               || ($F[$[+2] *= 1000);
+
+           
+           ;# skip samples out of specified time range
+           next if (defined($StartTime) && $StartTime > $t);
+           next if (defined($EndTime) && $EndTime < $t);
+           
+           next if defined($lastT) && $t < $lastT; # backward in time ??
+           
+           push(@offs,$F[$[+2]);
+           push(@freq,$F[$[+3] * (2**20/10**6));
+           push(@cmpl,$F[$[+5]);
+           
+           push(@break, (defined($lastT) && ($t - $lastT > $deltaT))); 
+           $lastT = $t;
+           push(@time,$t);
+           push(@loffset, tell(IN) - length($_));
+           push(@filekey, $key);
+           
+           shift(@break),shift(@time),shift(@offs),
+           shift(@freq), shift(@cmpl),shift(@loffset),
+           shift(@filekey)
+               if @time > $cnt &&
+                   ! (defined($StartTime) && defined($EndTime));
+
+           last if @time >= $cnt && defined($StartTime) && !defined($EndTime);
+       }
+       close(IN);
+       last if @time >= $cnt && defined($StartTime) && !defined($EndTime);
+    }
+    print "input scanned ($l lines/",scalar(@time)," samples)\n"
+       if $verbose > 1;
+    
+    if (@time)
+    {
+       local($_,@F);
+       
+       local($timebase) unless defined($timebase);
+       local($freqbase) unless defined($freqbase);
+       local($cmplscale) unless defined($cmplscale);
+       
+       undef $mintime;
+       undef $maxtime;
+       undef $minoffs;
+       undef $maxoffs;
+       undef $minfreq;
+       undef $maxfreq;
+       undef $mincmpl;
+       undef $maxcmpl;
+       undef $miny;
+       undef $maxy ;
+       
+       print "computing ranges\n" if $verbose > 2;
+       
+       $LastCnt = @time;
+
+       ;# @time is in ascending order (;-)
+       $mintime = $time[$[];
+       $maxtime = $time[$#time];
+       unless (defined($timebase))
+       {
+           local($time,@X) = (time);
+           @X = localtime($time);
+           
+           ;# compute today 00:00:00
+           $timebase = $time - ((($X[$[+2]*60)+$X[$[+1])*60+$X[$[]);
+
+       }
+       $LastTimeBase = $timebase;
+
+       if ($showoffs)
+       {
+           local($i,$m,$f);
+           
+           $minoffs = &min(@offs);
+           $maxoffs = &max(@offs);
+           
+           ;# I know, it is not perl style using indices to access arrays,
+           ;# but I have to proccess two arrays in sync, non-destructively
+           ;# (otherwise a (shift(@a1),shift(a2)) would do),
+           ;# I dont like to make copies of these arrays as they may be huge
+           $i = $[;
+           $lo->sample(($time[$i]-$timebase)/3600,$offs[$i]),$i++
+               while $i <= $#time;
+
+           ($minoffs == $maxoffs) && ($minoffs -= 0.1,$maxoffs += 0.1);
+
+           $i = $lo->sigma();
+           $m = $lo->mean();
+
+           print "mean offset: $m sigma: $i\n" if $verbose > 2;
+
+           if (($maxoffs - $minoffs) > $MinClip)
+           {
+               $f = (&abs($minoffs) < &abs($maxoffs)) ? $FuzzLow : $FuzzBig;
+               $miny = (($m - $minoffs) <= ($f * $i))
+                   ? $minoffs : ($m - $f * $i);
+               $f = ($f == $FuzzLow) ? $FuzzBig : $FuzzLow;
+               $maxy = (($maxoffs - $m) <= ($f * $i))
+                   ? $maxoffs : ($m + $f * $i);
+           }
+           else
+           {
+               $miny = $minoffs;
+               $maxy = $maxoffs;
+           }
+           ($maxy-$miny) == 0 &&
+               (($maxy,$miny)
+                = (($maxoffs - $minoffs) > 0)
+                ? ($maxoffs,$minoffs) : ($MinClip,-$MinClip));
+
+           $maxy = $MaxY if defined($MaxY) && $MaxY < $maxy;
+           $miny = $MinY if defined($MinY) && $MinY > $miny;
+
+           print  "offset min clipped from $minoffs to $miny\n"
+               if $verbose > 2 && $minoffs != $miny;
+           print  "offset max clipped from $maxoffs to $maxy\n"
+               if $verbose > 2 && $maxoffs != $maxy;
+       }
+       
+       if ($showfreq)
+       {
+           local($i,$m);
+           
+           $minfreq = &min(@freq);
+           $maxfreq = &max(@freq);
+           
+           $i = $[;
+           $lf->sample(($time[$i]-$timebase)/3600,$freq[$i]-$minfreq),
+           $i++
+               while $i <= $#time;
+           
+           $i = $lf->sigma();
+           $m = $lf->mean() + $minfreq;
+
+           print "mean frequency: $m sigma: $i\n" if $verbose > 2;
+
+           if (defined($maxy))
+           {
+               local($s) =
+                   ($maxfreq - $minfreq)
+                       ? ($maxy - $miny) / ($maxfreq - $minfreq) : 1;
+
+               if (defined($freqbase))
+               {
+                   $FreqScale = 1;
+                   $FreqScaleInv = "";
+               }
+               else
+               {
+                   $FreqScale = 1;
+                   $FreqScale = 10 ** int(log($s)/log(10) - 0.9999);
+                   $FreqScaleInv =
+                       ("$FreqScale" =~ /^10(0*)$/) ? "0.${1}1" : 
+                        ($FreqScale == 1 ? "" : (1/$FreqScale));
+                   
+                   $freqbase = ($maxfreq + $minfreq)/ 2 * $FreqScale; #$m * $FreqScale;
+                   $freqbase -= ($maxy + $miny) / 2; #$lf->mean();
+
+                   ;# round resulting freqbase
+                   ;# to precision of min max difference
+                   $s = -12;
+                   $s = int(log(($maxfreq-$minfreq)*$FreqScale)/log(10))-1
+                       unless ($maxfreq-$minfreq) < 1e-12;
+                   $s = 10 ** $s;
+                   $freqbase = int($freqbase / $s) * $s;
+               }
+           }
+           else
+           {
+               $FreqScale = 1;
+               $FreqScaleInv = "";
+               $freqbase = $m unless defined($freqbase);
+               if (($maxfreq - $minfreq) > $MinClip)
+               {
+                   $f = (&abs($minfreq) < &abs($maxfreq))
+                       ? $FuzzLow : $FuzzBig;
+                   $miny = (($freqbase - $minfreq) <= ($f * $i))
+                       ? ($minfreq-$freqbase) : (- $f * $i);
+                   $f = ($f == $FuzzLow) ? $FuzzBig : $FuzzLow;
+                   $maxy = (($maxfreq - $freqbase) <= ($f * $i))
+                       ? ($maxfreq-$freqbase) : ($f * $i);
+               }
+               else
+               {
+                   $miny = $minfreq - $freqbase;
+                   $maxy = $maxfreq - $freqbase;
+               }
+               ($maxy - $miny) == 0 &&
+                   (($maxy,$miny) =
+                    (($maxfreq - $minfreq) > 0)
+                    ? ($maxfreq-$freqbase,$minfreq-$freqbase) : (0.5,-0.5));
+               
+               $maxy = $MaxY if defined($MaxY) && $MaxY < $maxy;
+               $miny = $MinY if defined($MinY) && $MinY > $miny;
+
+               print("frequency min clipped from ",$minfreq-$freqbase,
+                     " to $miny\n")
+                   if $verbose > 2 && $miny != ($minfreq - $freqbase);
+               print("frequency max clipped from ",$maxfreq-$freqbase,
+                     " to $maxy\n")
+                   if $verbose > 2 && $maxy != ($maxfreq - $freqbase);
+           }
+           $LastFreqBaseString =
+               sprintf("%g",$freqbase >= 0 ? $freqbase : -$freqbase);
+           $LastFreqBase = $freqbase;
+           print "LastFreqBaseString now \"$LastFreqBaseString\"\n"
+               if $verbose > 5;
+       }
+       else
+       {
+           $FreqScale = 1;
+           $FreqScaleInv = "";
+           $LastFreqBase = 0;
+           $LastFreqBaseString = "";
+       }
+               
+       if ($showcmpl)
+       {
+           $mincmpl = &min(@cmpl);
+           $maxcmpl = &max(@cmpl);
+
+           if (!defined($cmplscale))
+           {
+               if (defined($maxy))
+               {
+                   local($cmp)
+                       = (&abs($miny) > &abs($maxy)) ? &abs($miny) : $maxy;
+                   $cmplscale = $cmp == $maxy ? 1 : -1;
+
+                   foreach (0.01, 0.02, 0.05,
+                            0.1, 0.2, 0.25, 0.4, 0.5,
+                            1, 2, 4, 5,
+                            10, 20, 25, 50,
+                            100, 200, 250, 500, 1000)
+                   {
+                       $cmplscale *= $_, last if $maxcmpl/$_ <= $cmp;
+                   }
+               }
+               else
+               {
+                   $cmplscale = 1;
+                   $miny = $mincmpl ? 0 : -$MinClip;
+                   $maxy = $maxcmpl+$MinClip;
+               }
+           }
+           $LastCmplScale = $cmplscale;
+       }
+       else
+       {
+           $LastCmplScale = 1;
+       }
+       
+       print "creating plot command input file\n" if $verbose > 2;
+       
+       
+       print OUT ("# preprocessed NTP statistics file for $STATHOST\n");
+       print OUT ("#    timebase is: ",&ctime($LastTimeBase))
+           if defined($LastTimeBase);
+       print OUT ("#    frequency is offset by  ",
+                  ($LastFreqBase >= 0 ? "+" : "-"),
+                  "$LastFreqBaseString [${FreqScaleInv}ppm]\n");
+       print OUT ("#    compliance is scaled by $LastCmplScale\n");
+       print OUT ("# time [h]\toffset [ms]\tfrequency [${FreqScaleInv}ppm]\tcompliance\n");
+       
+       printf OUT ("%s%lf\t%lf\t%lf\t%lf\n",
+                   (shift(@break) ? "\n" : ""),
+                   (shift(@time) - $LastTimeBase)/3600,
+                   shift(@offs),
+                   shift(@freq) * $FreqScale - $LastFreqBase,
+                   shift(@cmpl) / $LastCmplScale)
+           while(@time);
+    }
+    else
+    {
+       ;# prevent plotcmd from processing empty file
+       print "Creating plot command dummy...\n" if $verbose > 2;
+       print OUT "# dummy samples\n0 1 2 3\n1 1 2 3\n";
+       $lo->sample(0,1);
+       $lo->sample(1,1);
+       $lf->sample(0,2);
+       $lf->sample(1,2);
+       @time = (0, 1); $maxtime = 1; $mintime = 0;
+       @offs = (1, 1); $maxoffs = 1; $minoffs = 1;
+       @freq = (2, 2); $maxfreq = 2; $minfreq = 2;
+       @cmpl = (3, 3); $maxcmpl = 3; $mincmpl = 3;
+       $LastCnt = 2;
+       $LastFreqBase = 0;
+       $LastCmplScale = 1;
+       $LastTimeBase = 0;
+       $miny = -$MinClip;
+       $maxy = 3 + $MinClip;
+    }
+    close(OUT);
+    
+    print "plot command input file created\n"
+       if $verbose > 2;
+       
+       
+    if (($fpos[$[] eq 'cnt' && scalar(@loffset) >= $cnt) ||
+       ($fpos[$[] eq 'start' && $mintime <= $StartTime) ||
+       ($fpos[$[] eq 'end'))
+    {
+       return ($fpos[$[],$filekey[$[],$loffset[$[]);
+    }
+    else                       # found to few lines - next time start search earlier in file
+    {
+       if ($fpos[$[] eq 'start')
+       {
+           ;# the timestamps we got for F_first and F_last guaranteed
+           ;# that no file is left out
+           ;# the only thing that could happen is:
+           ;# we guessed the starting point wrong
+           ;# compute a new guess from the first record found
+           ;# if this equals our last guess use data of first record
+           ;# otherwise try new guess
+           
+           if ($fpos[$[+1] eq $filekey[$[] && $loffset[$[] > $fpos[$[+2])
+           {
+               local($noff);
+               $noff = $loffset[$[] - ($cnt - @loffset + 1) * $RecordSize;
+               $noff = 0 if $noff < 0;
+               
+               return (@fpos[$[,$[+1], ($noff == $fpos[$[+2]) ? $loffset[$[] : $noff);
+           }
+           return ($fpos[$[],$filekey[$[],$loffset[$[]);
+       }
+       elsif ($fpos[$[] eq 'end' || $fpos[$[] eq 'cnt')
+       {
+           ;# try to start earlier in file
+           ;# if we already started at the beginning
+           ;# try to use previous file
+           ;# this assumes distance to better starting point is at most one file
+           ;# the primary guess at top of genfile() should usually allow this
+           ;# assumption
+           ;# if the offset of the first sample used is within 
+           ;# a different file than we guessed it must have occurred later
+           ;# in the sequence of files
+           ;# this only can happen if our starting file did not contain
+           ;# a valid sample from the starting point we guessed
+           ;# however this does not invalidate our assumption, no check needed
+           local($noff,$key);
+           if ($fpos[$[+2] > 0)
+           {
+               $noff = $fpos[$[+2] - $RecordSize * ($cnt - @loffset + 1);
+               $noff = 0 if $noff < 0;
+               return (@fpos[$[,$[+1],$noff);
+           }
+           else
+           {
+               if ($fpos[$[+1] eq $F_files[$[])
+               {
+                   ;# first file - and not enough samples
+                   ;# use data of first sample
+                   return ($fpos[$[], $filekey[$[], $loffset[$[]);
+               }
+               else
+               {
+                   ;# search key of previous file
+                   $key = $F_files[$[];
+                   @F = reverse(@F_files);
+                   while ($_ = shift(@F))
+                   {
+                       if ($_ eq $fpos[$[+1])
+                       {
+                           $key = shift(@F) if @F;
+                           last;
+                       }
+                   }
+                   $noff = int($F_size{$key} / $RecordSize);
+                   $noff -= $cnt - @loffset;
+                   $noff = 0 if $noff < 0;
+                   $noff *= $RecordSize;
+                   return ($fpos[$[], $key, $noff);
+               }
+           }
+       }
+       else
+       {
+           return ();
+       }
+       
+       return 0 if @loffset <= 1 || ($loffset[$#loffset] - $loffset[$[]) <= 1;
+       
+       ;# EOF - 1.1 * avg(line) * $cnt
+       local($val) =  $loffset[$#loffset]
+           - $cnt * 11 * (($loffset[$#loffset] - $loffset[$[]) / @loffset) / 10;
+       return ($val < 0) ? 0 : $val;
+    }
+}
+
+$Ltime = -1 if ! defined($Ltime);
+$LastFreqBase = 0;
+$LastFreqBaseString = "??";
+
+;# initial setup of plot
+print "initialize plotting\n" if $verbose;
+if (defined($PrintIt))
+{
+  if ($PrintIt =~ m,/,)
+  {
+    print "Saving plot to file $PrintIt\n";
+    print PLOT "set output '$PrintIt'\n";
+  }
+  else
+  {
+    print "Printing plot on printer $PrintIt\n";
+    print PLOT "set output '| lpr -P$PrintIt -h'\n";
+  }
+  print PLOT "set terminal postscript landscape color solid 'Helvetica' 10\n";
+}
+print PLOT "set grid\n";
+print PLOT "set tics out\n";
+print PLOT "set format y '%g '\n";
+printf PLOT "set time 47\n" unless defined($PrintIt);
+
+@filepos =();
+while(1)
+{
+  print &ctime(time) if $verbose;
+
+  ;# update diplay characteristics
+  &read_config;# unless defined($PrintIt);
+
+  unlink($tmpfile);
+  my $lo = lr->new();
+  my $lf = lr->new();
+    
+  @filepos = &genfile($samples,$srcprefix,$tmpfile,$lo,$lf,@filepos);
+
+  ;# make plotcmd display samples
+  make_doplot($lo, $lf);
+  print "Displaying plot...\n" if $verbose > 1;
+  print "command for plot sub process:\n$doplot----\n" if $verbose > 3;
+  print PLOT $doplot;
+}
+continue
+{
+  if (defined($PrintIt))
+  {
+    delete $SIG{'CHLD'};
+    print PLOT "quit\n";
+    close(PLOT);
+    if ($PrintIt =~ m,/,)
+    {
+      print "Plot saved to file $PrintIt\n";
+    }
+    else
+    {
+      print "Plot spooled to printer $PrintIt\n";
+    }
+    unlink($tmpfile);
+    exit(0);
+  }
+  ;# wait $delay seconds
+  print "waiting $delay seconds ..." if $verbose > 2;
+  sleep($delay);
+  print " continuing\n" if $verbose > 2;
+  undef($LastFreqBaseString);
+}
+
+
+sub date_time_spec2seconds
+{
+    local($_) = @_;
+    ;# a date_time_spec consistes of:
+    ;#  YYYY-MM-DD_HH:MM:SS.ms
+    ;# values can be omitted from the beginning and default than to
+    ;# values of current date
+    ;# values omitted from the end default to lowest possible values
+
+    local($time) = time;
+    local($sec,$min,$hour,$mday,$mon,$year)
+       = localtime($time);
+
+    local($last) = ();
+
+    s/^\D*(.*\d)\D*/$1/;       # strip off garbage
+
+  PARSE:
+    {
+       if (s/^(\d{4})(-|$)//)
+       {
+           if ($1 < 1970)
+           {
+               warn("$0: can not handle years before 1970 - year $1 ignored\n");
+               return undef;
+           }
+           elsif ( $1 >= 2070)
+           {
+               warn("$0: can not handle years past 2070 - year $1 ignored\n");
+               return undef;
+           }
+           else
+           {
+               $year = $1 % 100; # 0<= $year < 100
+                                ;# - interpreted 70 .. 99,00 .. 69
+           }
+           $last = $[ + 5;
+           last PARSE if $_ eq '';
+           warn("$0: bad date_time_spec: \"$_\" found after YEAR\n"),
+           return(undef)
+               if $2 eq '';
+       }
+
+       if (s/^(\d{1,2})(-|$)//)
+       {
+           warn("$0: implausible month $1\n"),return(undef)
+               if $1 < 1 || $1 > 12;
+           $mon = $1 - 1;
+           $last = $[ + 4;
+           last PARSE if $_ eq '';
+           warn("$0: bad date_time_spec: \"$_\" found after MONTH\n"),
+           return(undef)
+               if $2 eq '';
+       }
+       else
+       {
+           warn("$0: bad date_time_spec \"$_\"\n"),return(undef)
+               if defined($last);
+           
+       }
+
+       if (s/^(\d{1,2})([_ ]|$)//)
+       {
+           warn("$0: implausible month day $1 for month ".($mon+1)." (".
+                $MaxNumDaysPerMonth[$mon].")$mon\n"),
+           return(undef)
+               if $1 < 1 || $1 > $MaxNumDaysPerMonth[$mon];
+           $mday = $1;
+           $last = $[ + 3;
+           last PARSE if $_ eq '';
+           warn("$0: bad date_time_spec \"$_\" found after MDAY\n"),
+           return(undef)
+               if $2 eq '';
+       }
+       else
+       {
+           warn("$0: bad date_time_spec \"$_\"\n"), return undef
+               if defined($last);
+       }
+
+       ;# now we face a problem:
+       ;# if ! defined($last) a prefix of "07:"
+       ;# can be either 07:MM or 07:ss
+       ;# to get the second interpretation make the user add
+       ;# a msec fraction part and check for this special case
+       if (! defined($last) && s/^(\d{1,2}):(\d{1,2}\.\d+)//)
+       {
+           warn("$0: implausible minute $1\n"), return undef
+               if $1 < 0 || $1 >= 60;
+           warn("$0: implausible second $1\n"), return undef
+               if $2 < 0 || $2 >= 60;
+           $min = $1;
+           $sec = $2;
+           $last = $[ + 1;
+           last PARSE if $_ eq '';
+           warn("$0: bad date_time_spec \"$_\" after SECONDS\n");
+           return undef;
+       }
+       
+       if (s/^(\d{1,2})(:|$)//)
+       {
+           warn("$0: implausible hour $1\n"), return undef
+               if $1 < 0 || $1 > 24;
+           $hour = $1;
+           $last = $[ + 2;
+           last PARSE if $_ eq '';
+           warn("$0: bad date_time_spec found \"$_\" after HOUR\n"),
+           return undef
+               if $2 eq '';
+       }
+       else
+       {
+           warn("$0: bad date_time_spec \"$_\"\n"), return undef
+               if defined($last);
+       }
+
+       if (s/^(\d{1,2})(:|$)//)
+       {
+           warn("$0: implausible minute $1\n"), return undef
+               if $1 < 0 || $1 >=60;
+           $min = $1;
+           $last = $[ + 1;
+           last PARSE if $_ eq '';
+           warn("$0: bad date_time_spec found \"$_\" after MINUTE\n"),
+           return undef
+               if $2 eq '';
+       }
+       else
+       {
+           warn("$0: bad date_time_spec \"$_\"\n"), return undef
+               if defined($last);
+       }
+
+       if (s/^(\d{1,2}(\.\d+)?)//)
+       {
+           warn("$0: implausible second $1\n"), return undef
+               if $1 < 0 || $1 >=60;
+           $sec = $1;
+           $last = $[;
+           last PARSE if $_ eq '';
+           warn("$0: bad date_time_spec found \"$_\" after SECOND\n");
+           return undef;
+       }
+    }
+
+    return $time unless defined($last);
+
+    $sec  = 0 if $last > $[;
+    $min  = 0 if $last > $[ + 1;
+    $hour = 0 if $last > $[ + 2;
+    $mday = 1 if $last > $[ + 3;
+    $mon  = 0 if $last > $[ + 4;
+    local($rtime) = &timelocal($sec,$min,$hour,$mday,$mon,$year, 0,0, 0);
+
+    ;# $rtime may be off if daylight savings time is in effect at given date
+    return $rtime + ($sec - int($sec))
+       if $hour == (localtime($rtime))[$[+2];
+    return
+       &timelocal($sec,$min,$hour,$mday,$mon,$year, 0,0, 1)
+           + ($sec - int($sec));
+}
+
+
+sub min
+{
+  local($m) = shift;
+
+  grep((($m > $_) && ($m = $_),0),@_);
+  $m;
+}
+
+sub max
+{
+  local($m) = shift;
+
+  grep((($m < $_) && ($m = $_),0),@_);
+  $m;
+}
diff --git a/scripts/monitoring/ntptrap b/scripts/monitoring/ntptrap
new file mode 100644 (file)
index 0000000..5a1bcb1
--- /dev/null
@@ -0,0 +1,463 @@
+#!/local/bin/perl --*-perl-*-
+;#
+;# ntptrap,v 3.1 1993/07/06 01:09:15 jbj Exp
+;#
+;# a client for the xntp mode 6 trap mechanism
+;#
+;# Copyright (c) 1992 
+;#  Rainer Pruy Friedrich-Alexander Universitaet Erlangen-Nuernberg
+;#
+;#
+;#############################################################
+$0 =~ s!^.*/([^/]+)$!$1!;              # strip to filename
+;# enforce STDOUT and STDERR to be line buffered
+$| = 1;
+select((select(STDERR),$|=1)[$[]);
+
+;#######################################
+;# load utility routines and definitions
+;#
+require('ntp.pl');                     # implementation of the NTP protocol
+use Socket;
+
+#eval { require('sys/socket.ph'); require('netinet/in.ph') unless defined(&INADDR_ANY); } ||
+#do {
+  #die("$0: $@") unless $[ == index($@, "Can't locate ");
+  #warn "$0: $@";
+  #warn "$0: supplying some default definitions\n";
+  #eval 'sub INADDR_ANY { 0; } sub AF_INET {2;} sub SOCK_DGRAM {2;} 1;' || die "$0: $@";
+#};
+require('getopts.pl');                 # option parsing
+require('ctime.pl');                   # date/time formatting
+
+;######################################
+;# define some global constants
+;#
+$BASE_TIMEOUT=10;
+$FRAG_TIMEOUT=10;
+$MAX_TRY = 5;
+$REFRESH_TIME=60*15;           # 15 minutes (server uses 1 hour)
+$ntp'timeout = $FRAG_TIMEOUT; #';
+$ntp'timeout if 0;
+
+;######################################
+;# now process options
+;#
+sub usage
+{
+    die("usage: $0 [-n] [-p <port>] [-l <logfile>] [host] ...\n");
+}
+
+$opt_l = "/dev/null";  # where to write debug messages to
+$opt_p = 0;            # port to use locally - (0 does mean: will be choosen by kernel)
+
+&usage unless &Getopts('l:p:');
+&Getopts if 0; # make -w happy
+
+@Hosts = ($#ARGV < $[) ? ("localhost") : @ARGV;
+
+;# setup for debug output
+$DEBUGFILE=$opt_l;
+$DEBUGFILE="&STDERR" if $DEBUGFILE eq '-';
+
+open(DEBUG,">>$DEBUGFILE") || die("Cannot open \"$DEBUGFILE\": $!\n");
+select((select(DEBUG),$|=1)[$[]);
+
+;# &log prints a single trap record (adding a (local) time stamp)
+sub log
+{
+    chop($date=&ctime(time));
+    print "$date ",@_,"\n";
+}
+
+sub debug
+{
+    print DEBUG @_,"\n";
+}
+;# 
+$proto_udp = (getprotobyname('udp'))[$[+2] ||
+               (warn("$0: Could not get protocoll number for 'udp' using 17"), 17);
+
+$ntp_port = (getservbyname('ntp','udp'))[$[+2] ||
+             (warn("$0: Could not get port number for service ntp/udp using 123"), 123);
+
+;# 
+socket(S, &AF_INET, &SOCK_DGRAM, $proto_udp) || die("Cannot open socket: $!\n");
+
+;# 
+bind(S, pack("S n a4 x8", &AF_INET, $opt_p, &INADDR_ANY)) ||
+    die("Cannot bind: $!\n");
+
+($my_port, $my_addr) = (unpack("S n a4 x8",getsockname(S)))[$[+1,$[+2];
+&log(sprintf("Listening at address %d.%d.%d.%d port %d",
+            unpack("C4",$my_addr), $my_port));
+
+;# disregister with all servers in case of termination
+sub cleanup
+{
+    &log("Aborted by signal \"$_[$[]\"") if defined($_[$[]);
+
+    foreach (@Hosts)
+    {
+       if ( ! defined($Host{$_}) )
+       {
+               print "no info for host '$_'\n";
+               next;
+       }
+       &ntp'send(S,31,0,"",pack("Sna4x8",&AF_INET,$ntp_port,$Host{$_})); #';
+    }
+    close(S);
+    exit(2);
+}
+
+$SIG{'HUP'} = 'cleanup';
+$SIG{'INT'} = 'cleanup';
+$SIG{'QUIT'} = 'cleanup';
+$SIG{'TERM'} = 'cleanup';
+
+0 && $a && $b;
+sub timeouts                   # sort timeout id array
+{
+    $TIMEOUTS{$a} <=> $TIMEOUTS{$b};
+}
+
+;# a Request element looks like: pack("a4SC",addr,associd,op)
+@Requests= ();
+
+;# compute requests for set trap control msgs to each host given
+{
+    local($name,$addr);
+    
+    foreach (@Hosts)
+    {
+       if (/^(\d+)\.(\d+)\.(\d+)\.(\d+)$/)
+       {
+           ($name,$addr) =
+               (gethostbyaddr(pack("C4",$1,$2,$3,$4),&AF_INET))[$[,$[+4];
+           unless (defined($name))
+           {
+               $name = sprintf("[[%d.%d.%d.%d]]",$1,$2,$3,$4);
+               $addr = pack("C4",$1,$2,$3,$4);
+           }
+       }
+       else
+       {
+           ($name,$addr) = (gethostbyname($_))[$[,$[+4];
+           unless (defined($name))
+           {
+               warn "$0: unknown host \"$_\" - ignored\n";
+               next;
+           }
+       }
+       next if defined($Host{$name});
+       $Host{$name} = $addr;
+       $Host{$_} = $addr;
+       push(@Requests,pack("a4SC",$addr,0,6)); # schedule a set trap request for $name
+    }
+}
+
+sub hostname
+{
+    local($addr) = @_;
+    return $HostName{$addr} if defined($HostName{$addr});
+    local($name) = gethostbyaddr($addr,&AF_INET);
+    &debug(sprintf("hostname(%d.%d.%d.%d) = \"%s\"",unpack("C4",$addr),$name))
+       if defined($name);
+    defined($name) && ($HostName{$addr} = $name) && (return $name);
+    &debug(sprintf("Failed to get name for %d.%d.%d.%d",unpack("C4",$addr)));
+    return sprintf("[%d.%d.%d.%d]",unpack("C4",$addr));
+}
+
+;# when no hosts were given on the commandline no requests have been scheduled
+&usage unless (@Requests);
+
+&debug(sprintf("%d request(s) scheduled",scalar(@Requests)));
+grep(&debug("    - ".$_),keys(%Host));
+
+;# allocate variables;
+$addr="";
+$assoc=0;
+$op = 0;
+$timeout = 0;
+$ret="";
+%TIMEOUTS = ();
+%TIMEOUT_PROCS = ();
+@TIMEOUTS = ();                
+
+$len = 512;
+$buf = " " x $len;
+
+while (1)
+{
+    if (@Requests || @TIMEOUTS)                # if there is some work pending
+    {
+       if (@Requests)
+       {
+           ($addr,$assoc,$op) = unpack("a4SC",($req = shift(@Requests)));
+           &debug(sprintf("Request: %s: %s(%d)",&hostname($addr), &ntp'cntrlop_name($op), $assoc)); #';))
+           $ret = &ntp'send(S,$op,$assoc,"", #'(
+                             pack("Sna4x8",&AF_INET,$ntp_port,$addr));
+           &set_timeout("retry-".unpack("H*",$req),time+$BASE_TIMEOUT,
+                        sprintf("&retry(\"%s\");",unpack("H*",$req)));
+
+           last unless (defined($ret)); # warn called by ntp'send();
+
+           ;# if there are more requests just have a quick look for new messages
+           ;# otherwise grant server time for a response
+           $timeout = @Requests ? 0 : $BASE_TIMEOUT;
+       }
+       if ($timeout && @TIMEOUTS)
+       {
+           ;# ensure not to miss a timeout
+           if ($timeout + time > $TIMEOUTS{$TIMEOUTS[$[]})
+           {
+               $timeout = $TIMEOUTS{$TIMEOUTS[$[]} - time;
+               $timeout = 0 if $timeout < 0;
+           }
+       }
+    }
+    else
+    {
+       ;# no work yet - wait for some messages dropping in
+       ;# usually this will not hapen as the refresh semantic will
+       ;# always have a pending timeout
+       undef($timeout);
+    }
+
+    vec($mask="",fileno(S),1) = 1;
+    $ret = select($mask,undef,undef,$timeout);
+
+    warn("$0: select: $!\n"),last if $ret < 0; # give up on error return from select
+
+    if ($ret == 0)
+    {
+       ;# timeout
+       if (@TIMEOUTS && time > $TIMEOUTS{$TIMEOUTS[$[]})
+       {
+           ;# handle timeout
+           $timeout_proc =
+               (delete $TIMEOUT_PROCS{$TIMEOUTS[$[]},
+                delete $TIMEOUTS{shift(@TIMEOUTS)})[$[];
+           eval $timeout_proc;
+           die "timeout eval (\"$timeout_proc\"): $@\n" if $@;
+       }
+       ;# else: there may be something to be sent
+    }
+    else
+    {
+       ;# data avail
+       $from = recv(S,$buf,$len,0);
+       ;# give up on error return from recv
+       warn("$0: recv: $!\n"), last unless (defined($from));
+
+       $from = (unpack("Sna4",$from))[$[+2]; # keep host addr only
+       ;# could check for ntp_port - but who cares
+       &debug("-Packet from ",&hostname($from));
+
+       ;# stuff packet into ntp mode 6 receive machinery
+       ($ret,$data,$status,$associd,$op,$seq,$auth_keyid) =
+           &ntp'handle_packet($buf,$from); # ';
+       &debug(sprintf("%s uses auth_keyid %d",&hostname($from),$auth_keyid)) if defined($auth_keyid);
+       next unless defined($ret);
+
+       if ($ret eq "")
+       {
+           ;# handle packet
+           ;# simple trap response messages have neither timeout nor retries
+           &clear_timeout("retry-".unpack("H*",pack("a4SC",$from,$associd,$op))) unless $op == 7;
+           delete $RETRY{pack("a4SC",$from,$associd,$op)} unless $op == 7;
+
+           &process_response($from,$ret,$data,$status,$associd,$op,$seq,$auth_keyid);
+       }
+       else
+       {
+           ;# some kind of error
+           &log(sprintf("%50s: %s: %s",(gethostbyaddr($from,&AF_INET))[$[],$ret,$data));
+           if ($ret ne "TIMEOUT" && $ret ne "ERROR")
+           {
+               &clear_timeout("retry-".unpack("H*",pack("a4SC",$from,$associd,$op)));
+           }
+       }
+    }
+    
+}
+
+warn("$0: terminating\n");
+&cleanup;
+exit 0;
+
+;##################################################
+;# timeout support
+;#
+sub set_timeout
+{
+    local($id,$time,$proc) = @_;
+    
+    $TIMEOUTS{$id} = $time;
+    $TIMEOUT_PROCS{$id} = $proc;
+    @TIMEOUTS = sort timeouts keys(%TIMEOUTS);
+    chop($date=&ctime($time));
+    &debug(sprintf("Schedule timeout \"%s\" for %s", $id, $date));
+}
+
+sub clear_timeout
+{
+    local($id) = @_;
+    delete $TIMEOUTS{$id};
+    delete $TIMEOUT_PROCS{$id};
+    @TIMEOUTS = sort timeouts keys(%TIMEOUTS);
+    &debug("Clear  timeout \"$id\"");
+}
+
+0 && &refresh;
+sub refresh
+{
+    local($addr) = @_[$[];
+    $addr = pack("H*",$addr);
+    &debug(sprintf("Refreshing trap for %s", &hostname($addr)));
+    push(@Requests,pack("a4SC",$addr,0,6));
+}
+
+0 && &retry;
+sub retry
+{
+    local($tag) = @_;
+    $tag = pack("H*",$tag);
+    $RETRY{$tag} = 0 if (!defined($RETRY{$tag}));
+
+    if (++$RETRY{$tag} > $MAX_TRY)
+    {
+       &debug(sprintf("Retry failed: %s assoc %5d op %d",
+                      &hostname(substr($tag,$[,4)),
+                      unpack("x4SC",$tag)));
+       return;
+    }
+    &debug(sprintf("Retrying: %s assoc %5d op %d",
+                      &hostname(substr($tag,$[,4)),
+                      unpack("x4SC",$tag)));
+    push(@Requests,$tag);
+}
+
+sub process_response
+{
+    local($from,$ret,$data,$status,$associd,$op,$seq,$auth_keyid) = @_;
+    
+    $msg="";
+    if ($op == 7)              # trap response
+    {
+       $msg .= sprintf("%40s trap#%-5d",
+                       &hostname($from),$seq);
+       &debug (sprintf("\nTrap %d associd %d:\n%s\n===============\n",$seq,$associd,$data));
+       if ($associd == 0)      # system event
+       {
+           $msg .= "  SYSTEM   ";
+           $evnt = &ntp'SystemEvent($status); #';
+           $msg .= "$evnt ";
+           ;# for special cases add additional info
+           ($stratum) = ($data =~ /stratum=(\d+)/);
+           ($refid) = ($data =~ /refid=([\w\.]+)/);
+           $msg .= "stratum=$stratum refid=$refid";
+           if ($refid =~ /\[?(\d+)\.(\d+)\.(\d+)\.(\d+)/)
+           {
+               local($x) = (gethostbyaddr(pack("C4",$1,$2,$3,$4),&AF_INET));
+               $msg .= " " . $x if defined($x)
+           }
+           if ($evnt eq "event_sync_chg")
+           {
+               $msg .= sprintf("%s %s ",
+                               &ntp'LI($status), #',
+                               &ntp'ClockSource($status) #'
+                               );
+           }
+           elsif ($evnt eq "event_sync/strat_chg")
+           {
+               ($peer) = ($data =~ /peer=([0-9]+)/);
+               $msg .= " peer=$peer";
+           }
+           elsif ($evnt eq "event_clock_excptn")
+           {
+               if (($device) = ($data =~ /device=\"([^\"]+)\"/))
+               {
+                   ($cstatus) = ($data =~ /refclockstatus=0?x?([\da-fA-F]+)/);
+                   $Cstatus = hex($cstatus);
+                   $msg .= sprintf("- %-32s",&ntp'clock_status($Cstatus)); #');
+                   ($timecode) = ($data =~ /timecode=\"([^\"]+)\"/);
+                   $msg .= " \"$device\" \"$timecode\"";
+               }
+               else
+               {
+                   push(@Requests,pack("a4SC",$from, $associd, 4));
+               }
+           }
+       }
+       else                    # peer event
+       {
+           $msg .= sprintf("peer %5d ",$associd);
+           ($srcadr) = ($data =~ /srcadr=\[?([\d\.]+)/);
+           $msg .= sprintf("%-18s %40s ", "[$srcadr]",
+                           &hostname(pack("C4",split(/\./,$srcadr))));
+           $evnt = &ntp'PeerEvent($status); #';
+           $msg .= "$evnt ";
+           ;# for special cases include additional info
+           if ($evnt eq "event_clock_excptn")
+           {
+               if (($device) = ($data =~ /device=\"([^\"]+)\"/))
+               {
+                   ;#&debug("----\n$data\n====\n");
+                   ($cstatus) = ($data =~ /refclockstatus=0?x?([\da-fA-F]+)/);
+                   $Cstatus = hex($cstatus);
+                   $msg .= sprintf("- %-32s",&ntp'clock_status($Cstatus)); #');
+                   ($timecode) = ($data =~ /timecode=\"([^\"]+)\"/);
+                   $msg .= " \"$device\" \"$timecode\"";
+               }
+               else
+               {
+                   ;# no clockvars included - post a cv request
+                   push(@Requests,pack("a4SC",$from, $associd, 4));
+               }
+           }
+           elsif ($evnt eq "event_stratum_chg")
+           {
+               ($stratum) = ($data =~ /stratum=(\d+)/);
+               $msg .= "new stratum $stratum";
+           }
+       }
+    }
+    elsif ($op == 6)           # set trap resonse
+    {
+       &debug("Set trap ok from ",&hostname($from));
+       &set_timeout("refresh-".unpack("H*",$from),time+$REFRESH_TIME,
+                    sprintf("&refresh(\"%s\");",unpack("H*",$from)));
+       return;
+    }
+    elsif ($op == 4)           # read clock variables response
+    {
+       ;# status of clock
+       $msg .= sprintf(" %40s ", &hostname($from));
+       if ($associd == 0)
+       {
+           $msg .= "system clock status: ";
+       }
+       else
+       {
+           $msg .= sprintf("peer %5d clock",$associd);
+       }
+       $msg .= sprintf("%-32s",&ntp'clock_status($status)); #');
+       ($device) = ($data =~ /device=\"([^\"]+)\"/);
+       ($timecode) = ($data =~ /timecode=\"([^\"]+)\"/);
+       $msg .= " \"$device\" \"$timecode\"";
+    }
+    elsif ($op == 31)          # unset trap response (UNOFFICIAL op)
+    {
+       ;# clear timeout
+       &debug("Clear Trap ok from ",&hostname($from));
+       &clear_timeout("refresh-".unpack("H*",$from));
+       return;
+    }
+    else                       # unexpected response
+    {
+       $msg .= "unexpected response to op $op assoc=$associd";
+       $msg .= sprintf(" status=%04x",$status);
+    }
+    &log($msg);
+}
diff --git a/scripts/monitoring/timelocal.pl b/scripts/monitoring/timelocal.pl
new file mode 100644 (file)
index 0000000..d0f73a2
--- /dev/null
@@ -0,0 +1,77 @@
+;# timelocal.pl
+;#
+;# Usage:
+;#     $time = timelocal($sec,$min,$hours,$mday,$mon,$year,$junk,$junk,$isdst);
+;#     $time = timegm($sec,$min,$hours,$mday,$mon,$year);
+
+;# These routines are quite efficient and yet are always guaranteed to agree
+;# with localtime() and gmtime().  We manage this by caching the start times
+;# of any months we've seen before.  If we know the start time of the month,
+;# we can always calculate any time within the month.  The start times
+;# themselves are guessed by successive approximation starting at the
+;# current time, since most dates seen in practice are close to the
+;# current date.  Unlike algorithms that do a binary search (calling gmtime
+;# once for each bit of the time value, resulting in 32 calls), this algorithm
+;# calls it at most 6 times, and usually only once or twice.  If you hit
+;# the month cache, of course, it doesn't call it at all.
+
+;# timelocal is implemented using the same cache.  We just assume that we're
+;# translating a GMT time, and then fudge it when we're done for the timezone
+;# and daylight savings arguments.  The timezone is determined by examining
+;# the result of localtime(0) when the package is initialized.  The daylight
+;# savings offset is currently assumed to be one hour.
+
+CONFIG: {
+    package timelocal;
+    
+    @epoch = localtime(0);
+    $tzmin = $epoch[2] * 60 + $epoch[1];       # minutes east of GMT
+    if ($tzmin > 0) {
+       $tzmin = 24 * 60 - $tzmin;              # minutes west of GMT
+       $tzmin -= 24 * 60 if $epoch[5] == 70;   # account for the date line
+    }
+
+    $SEC = 1;
+    $MIN = 60 * $SEC;
+    $HR = 60 * $MIN;
+    $DAYS = 24 * $HR;
+    $YearFix = ((gmtime(946684800))[5] == 100) ? 100 : 0;
+}
+
+sub timegm {
+    package timelocal;
+
+    $ym = pack(C2, @_[5,4]);
+    $cheat = $cheat{$ym} || &cheat;
+    $cheat + $_[0] * $SEC + $_[1] * $MIN + $_[2] * $HR + ($_[3]-1) * $DAYS;
+}
+
+sub timelocal {
+    package timelocal;
+
+    $ym = pack(C2, @_[5,4]);
+    $cheat = $cheat{$ym} || &cheat;
+    $cheat + $_[0] * $SEC + $_[1] * $MIN + $_[2] * $HR + ($_[3]-1) * $DAYS
+       + $tzmin * $MIN - 60 * 60 * ($_[8] != 0);
+}
+
+package timelocal;
+
+sub cheat {
+    $year = $_[5];
+    $month = $_[4];
+    $guess = $^T;
+    @g = gmtime($guess);
+    $year += $YearFix if $year < $epoch[5];
+    while ($diff = $year - $g[5]) {
+       $guess += $diff * (364 * $DAYS);
+       @g = gmtime($guess);
+    }
+    while ($diff = $month - $g[4]) {
+       $guess += $diff * (28 * $DAYS);
+       @g = gmtime($guess);
+    }
+    $g[3]--;
+    $guess -= $g[0] * $SEC + $g[1] * $MIN + $g[2] * $HR + $g[3] * $DAYS;
+    $cheat{$ym} = $guess;
+}
diff --git a/scripts/ntp-close b/scripts/ntp-close
new file mode 100755 (executable)
index 0000000..b5077e6
--- /dev/null
@@ -0,0 +1,8 @@
+#! /bin/sh
+
+lynx -source http://www.eecis.udel.edu/~mills/ntp/clock2.htm |
+       sed -n -e 's,).*,,' -e' /([0-9.]*$/s/.*(//p' |
+       xargs ntpdate -q |
+       sort -n +7 > /tmp/ntp-close
+
+# From: Neal McBurnett <neal@bcn.boulder.co.us>
diff --git a/scripts/ntp-groper b/scripts/ntp-groper
new file mode 100755 (executable)
index 0000000..1fd0cfe
--- /dev/null
@@ -0,0 +1,95 @@
+#!/bin/sh 
+#
+# ntpgroper host ...
+#
+# This script checks each hostname given as an argument to see if
+# it is running NTP.  It reports one of the following messages (assume
+# the host is named "dumbo.hp.com":
+#
+#   dumbo.hp.com not registered in DNS
+#   dumbo.hp.com not responding to ping
+#   dumbo.hp.com refused ntpq connection
+#   dumbo.hp.com not responding to NTP
+#   dumbo.hp.com answers NTP version 2, stratum: 3, ref: telford.nsa.hp.com
+#   dumbo.hp.com answers NTP version 3, stratum: 3, ref: telford.nsa.hp.com
+#
+# It ain't pretty, but it is kinda useful.
+#
+# Walter Underwood, 11 Feb 1993, wunder@hpl.hp.com
+#
+# converted to /bin/sh from /bin/ksh by scott@ee.udel.edu 24 Mar 1993
+
+PATH="/usr/local/etc:$PATH" export PATH
+
+verbose=1
+logfile=/tmp/cntp-log$$
+ntpqlog=/tmp/cntp-ntpq$$
+
+# I wrap the whole thing in parens so that it is possible to redirect
+# all the output somewhere, if desired.
+(
+for host in $*
+do
+    # echo "Trying $host."
+
+    gethost $host > /dev/null 2>&1
+    if [ $? -ne 0 ]
+    then
+        echo "$host not registered in DNS"
+        continue
+    fi
+
+    ping $host 64 1 > /dev/null 2>&1 
+    if [ $? -ne 0 ]
+    then
+        echo "$host not responding to ping"
+       continue
+    fi
+    
+    # Attempt to contact with version 3 ntp, then try version 2.
+    for version in 3 2
+    do
+
+        ntpq -c "ntpversion $version" -p $host > $ntpqlog 2>&1
+
+        if fgrep -s 'Connection refused' $ntpqlog
+        then
+            echo "$host refused ntpq connection"
+            break
+        fi
+
+        responding=1
+        fgrep -s 'timed out, nothing received' $ntpqlog > /dev/null && responding=0
+
+        if   [ $responding -eq 1 ]
+        then
+           ntpq -c "ntpversion $version" -c rl $host > $ntpqlog
+
+            # First we extract the reference ID (usually a host or a clock)
+            synchost=`fgrep "refid=" $ntpqlog`
+            #synchost=${synchost##*refid=} # strip off the beginning of the line
+            #synchost=${synchost%%,*}      # strip off the end  
+           synchost=`expr "$synchost" : '.*refid=\([^,]*\),.*'`
+
+            # Next, we get the stratum
+            stratum=`fgrep "stratum=" $ntpqlog`
+            #stratum=${stratum##*stratum=}
+            #stratum=${stratum%%,*}
+           stratum=`expr "$stratum" : '.*stratum=\([^,]*\),.*'`
+
+           echo "$host answers NTP version $version, stratum: $stratum, ref: $synchost"
+            break;
+        fi
+
+       if [ $version -eq 2 -a $responding -eq 0 ]
+        then
+            echo "$host not responding to NTP"
+        fi
+    done
+done
+)
+# ) >> $logfile
+
+if [ -f $ntpqlog ]; then
+    rm $ntpqlog
+fi
diff --git a/scripts/ntp-restart b/scripts/ntp-restart
new file mode 100755 (executable)
index 0000000..0a1d58a
--- /dev/null
@@ -0,0 +1,10 @@
+#!/bin/sh
+#
+# This script can be used to kill and restart the NTP daemon. Edit the
+# /usr/local/bin/ntpd line to fit.
+#
+kill -INT `ps -ax | egrep "ntpd" | egrep -v "egrep" | sed 's/^\([ 0-9]*\) .*/\1'/`
+sleep 10
+/usr/local/bin/ntpd -g
+/usr/local/bin/ntp-wait
+exit 0
diff --git a/scripts/ntp-status b/scripts/ntp-status
new file mode 100755 (executable)
index 0000000..4109124
--- /dev/null
@@ -0,0 +1,45 @@
+#!/bin/sh
+
+# From: Marc Brett <Marc.Brett@westgeo.com>
+
+# Here's a quick hack which can give you the stratum, delay, offset
+# for any number of ntp servers.
+
+NTPDATE=/usr/local/bin/ntpdate
+NSLOOKUP=/usr/sbin/nslookup
+EGREP=/bin/egrep
+AWK=/bin/awk
+RM=/bin/rm
+FILE=/tmp/ntp.$$
+
+USAGE="Usage: $0 hostname [hostname ...]"
+
+if [ $# -le 0 ]
+then
+       echo $USAGE 2>&1
+       exit 1
+fi
+
+trap '$RM -f $FILE; exit' 1 2 3 4 13 15
+
+for HOST in $*
+do
+    HOSTNAME=`$NSLOOKUP $HOST | $EGREP "Name:" | $AWK '{print $2}'`
+    if [ -n "$HOSTNAME" ]
+    then
+       $NTPDATE -d $HOST 2>/dev/null | $EGREP '^stratum|^delay|^offset|^originate' > $FILE
+       STRATUM=`$EGREP '^stratum' $FILE | $AWK '{print $2}'`
+       OFFSET=`$EGREP '^offset' $FILE | $AWK '{print $2}'`
+       DELAY=`$EGREP '^delay' $FILE | $AWK '{print $2}'`
+       TIMESTAMP=`$EGREP '^originate' $FILE | $AWK '{print $4 " " $5 " " $6 " " $7 " " $8}'`
+       if [ "$STRATUM" -ne 0 ]
+       then
+               echo "$HOSTNAME: stratum:$STRATUM delay:$DELAY offset:$OFFSET  $TIMESTAMP"
+       else
+               echo $HOSTNAME: Not running NTP
+       fi
+    fi
+
+done
+
+$RM -f $FILE
diff --git a/scripts/ntp-wait.in b/scripts/ntp-wait.in
new file mode 100644 (file)
index 0000000..a26630b
--- /dev/null
@@ -0,0 +1,42 @@
+#! @PATH_PERL@ -w
+
+die "perl5 needed\n" unless ($] > 5);
+
+use Getopt::Std;
+
+$opt_f = 0;                    # 'Hard' failure if 'state' is unknown
+$opt_n = 1000;                 # How many tries before we give up? (10 min+)
+$opt_s = 6;                    # Seconds to sleep between tries (6s = 10/min)
+$opt_v = 0;                    # Be verbose?
+
+getopts('fn:s:v');
+
+$cmd = 'ntpq -c "rv 0 state"';
+
+$| = 1;                                # Autoflush output.
+
+print "Waiting for ntpd to synchronize...  " if ($opt_v);
+for ($i = 0; $i < $opt_n; ++$i) {
+    open(Q, $cmd." 2>&1 |") || die "Can't start ntpq: $!";
+    while(<Q>) {
+      if (/^state=4/) {
+       print "\bOK!\n" if ($opt_v);
+       exit 0;
+      }
+
+      if (/request variable was unknown/) {
+       print "\bCan't tell!\nPerhaps you are running an old version of ntpd.\n" if ($opt_v);
+       exit $opt_f;
+      }
+
+      if (/Connection refused/) {
+       print "\bntpd is not running!\n" if ($opt_v);
+       exit 1;
+      }
+    }
+    close(Q);
+    print "\b".substr("*+:.", $i % 4, 1) if ($opt_v);
+    sleep($opt_s);
+}
+print "\bNo!\nntpd did not synchronize.\n" if ($opt_v);
+exit 1;
diff --git a/scripts/ntpsweep.in b/scripts/ntpsweep.in
new file mode 100644 (file)
index 0000000..e503a06
--- /dev/null
@@ -0,0 +1,300 @@
+#! @PATH_PERL@ -w
+#
+# $Id$
+#
+# DISCLAIMER
+# 
+# Copyright (C) 1999,2000 Hans Lambermont and Origin B.V.
+# 
+# Permission to use, copy, modify and distribute this software and its
+# documentation for any purpose and without fee is hereby granted,
+# provided that the above copyright notice appears in all copies and
+# that both the copyright notice and this permission notice appear in
+# supporting documentation. This software is supported as is and without
+# any express or implied warranties, including, without limitation, the
+# implied warranties of merchantability and fitness for a particular
+# purpose. The name Origin B.V. must not be used to endorse or promote
+# products derived from this software without prior written permission.
+#
+# Hans Lambermont <ntpsweep@lambermont.dyndns.org>
+
+require 5.0;           # But actually tested on 5.004 ;)
+use Getopt::Long;       # GetOptions()
+use strict;
+
+my $version = 1.3;
+(my $program = $0) =~ s%.*/(.+?)(.pl)?$%$1%;
+
+# Hardcoded paths/program names
+my $ntpdate = "ntpdate";
+my $ntpq = "ntpq";
+
+# no STDOUT buffering
+$| = 1;
+
+my ($help, $single_host, $showpeers, $maxlevel, $strip, $askversion);
+my $res = GetOptions("help!"      => \$help,
+                    "host=s"     => \$single_host,
+                    "peers!"     => \$showpeers,
+                    "maxlevel=s" => \$maxlevel,
+                    "strip=s"    => \$strip,
+                    "version!"   => \$askversion);
+
+if ($askversion) {
+    print("$version\n");
+    exit 0;
+}
+
+if ($help || ((@ARGV != 1) && !$single_host)) {
+    warn <<EOF;
+This is $program, version $version
+Copyright (C) 1999,2000 Hans Lambermont and Origin B.V.  Disclaimer inside.
+
+Usage:
+  $program [--help|--peers|--strip <string>|--maxlevel <level>|--version] \\
+    <file>|[--host <hostname>]
+
+Description:
+  $program prints per host given in <file> the NTP stratum level, the
+  clock offset in seconds, the daemon version, the operating system and
+  the processor. Optionally recursing through all peers.
+
+Options:
+--help
+    Print this short help text and exit.
+--version
+    Print version ($version) and exit.
+<file>
+    Specify hosts file. File format is one hostname or ip number per line.
+    Lines beginning with # are considered as comment.
+--host <hostname>
+    Speficy a single host, bypassing the need for a hosts file.
+--peers
+    Recursively list all peers a host synchronizes to.
+    An '= ' before a peer means a loop. Recursion stops here.
+--maxlevel <level>
+    Traverse peers up to this level (4 is a reasonable number).
+--strip <string>
+    Strip <string> from hostnames.
+
+Examples:
+    $program myhosts.txt --strip .foo.com
+    $program --host some.host --peers --maxlevel 4
+EOF
+    exit 1;
+}
+
+my $hostsfile = shift;
+my (@hosts, @known_hosts);
+my (%known_host_info, %known_host_peers);
+
+sub read_hosts()
+{
+    local *HOSTS;
+    open (HOSTS, $hostsfile) ||
+       die "$program: FATAL: unable to read $hostsfile: $!\n";
+    while (<HOSTS>) {
+       next if /^\s*(#|$)/; # comment/empty
+       chomp;
+       push(@hosts, $_);
+    }
+    close(HOSTS);
+}
+
+# translate IP to hostname if possible
+sub ip2name {
+    my($ip) = @_;
+    my($addr, $name, $aliases, $addrtype, $length, @addrs);
+    $addr = pack('C4', split(/\./, $ip));
+    ($name, $aliases, $addrtype, $length, @addrs) = gethostbyaddr($addr, 2);
+    if ($name) {
+        # return lower case name
+       return("\L$name");
+    } else {
+       return($ip);
+    }
+}
+
+# item_in_list($item, @list): returns 1 if $item is in @list, 0 if not
+sub item_in_list {
+    my($item, @list) = @_;
+    my($i);
+    foreach $i (@list) {
+       return 1 if ($item eq $i);
+    }
+    return 0;
+}
+
+sub scan_host($;$;$) {
+    my($host, $level, @trace) = @_;
+    my $stratum = 0;
+    my $offset = 0;
+    my $daemonversion = "";
+    my $system = "";
+    my $processor = "";
+    my @peers;
+    my $known_host = 0;
+
+    if (&item_in_list($host, @known_hosts)) {
+       $known_host = 1;
+    } else {
+       # ntpdate part
+       open(NTPDATE, "$ntpdate -bd $host 2>/dev/null |") ||
+       die "Cannot open ntpdate pipe: $!\n";
+       while (<NTPDATE>) {
+           /^stratum\s+(\d+).*$/ && do {
+               $stratum = $1;
+           };
+           /^offset\s+([0-9.-]+)$/ && do {
+               $offset = $1;
+           };
+       }
+       close(NTPDATE);
+    
+       # got answers ? If so, go on.
+       if ($stratum) {
+           # ntpq part
+           my $ntpqparams = "-c 'rv 0 processor,system,daemon_version'";
+           open(NTPQ, "$ntpq $ntpqparams $host 2>/dev/null |") ||
+               die "Cannot open ntpq pipe: $!\n";
+           while (<NTPQ>) {
+               /daemon_version="(.*)"/ && do {
+                   $daemonversion = $1;
+               };
+               /system="([^"]*)"/ && do {
+                   $system = $1;
+               };
+               /processor="([^"]*)"/ && do {
+                   $processor = $1;
+               };
+           }
+           close(NTPQ);
+           
+           # Shorten daemon_version string.
+           $daemonversion =~ s/(;|Mon|Tue|Wed|Thu|Fri|Sat|Sun).*$//;
+           $daemonversion =~ s/version=//;
+           $daemonversion =~ s/(x|)ntpd //;
+           $daemonversion =~ s/(\(|\))//g;
+           $daemonversion =~ s/beta/b/;
+           $daemonversion =~ s/multicast/mc/;
+       
+           # Shorten system string
+           $system =~ s/UNIX\///;
+           $system =~ s/RELEASE/r/;
+           $system =~ s/CURRENT/c/;
+
+           # Shorten processor string
+           $processor =~ s/unknown//;
+       }
+    
+       # got answers ? If so, go on.
+       if ($daemonversion) {
+           # ntpq again, find out the peers this time
+           if ($showpeers) {
+               my $ntpqparams = "-pn";
+               open(NTPQ, "$ntpq $ntpqparams $host 2>/dev/null |") ||
+                   die "Cannot open ntpq pipe: $!\n";
+               while (<NTPQ>) {
+                   /^No association ID's returned$/ && do {
+                       last;
+                   };
+                   /^     remote/ && do {
+                       next;
+                   };
+                   /^==/ && do {
+                       next;
+                   };
+                   /^( |x|\.|-|\+|#|\*|o)([^ ]+)/ && do {
+                       push(@peers, ip2name($2));
+                       next;
+                   };
+                   print "ERROR: $_";
+               }
+               close(NTPQ);
+           }
+       }
+    
+       # Add scanned host to known_hosts array
+       push(@known_hosts, $host);
+       if ($stratum) {
+           $known_host_info{$host} = sprintf("%2d %9.3f %-11s %-12s %s",
+               $stratum, $offset, substr($daemonversion,0,11),
+               substr($system,0,12), substr($processor,0,9));
+       } else {
+           # Stratum level 0 is consider invalid
+           $known_host_info{$host} = sprintf(" ?");
+       }
+       $known_host_peers{$host} = [@peers];
+    }
+
+    if ($stratum || $known_host) { # Valid or known host
+       my $printhost = ' ' x $level . $host;
+       # Shorten host string
+       if ($strip) {
+           $printhost =~ s/$strip//;
+       }
+       # append number of peers in brackets if requested and valid
+       if ($showpeers && ($known_host_info{$host} ne " ?")) {
+           $printhost .= " (" . @{$known_host_peers{$host}} . ")";
+       }
+       # Finally print complete host line
+       printf("%-32s %s\n",
+           substr($printhost,0,32), $known_host_info{$host});
+       if ($showpeers && (eval($maxlevel ? $level < $maxlevel : 1))) {
+           my $peer;
+           push(@trace, $host);
+           # Loop through peers
+           foreach $peer (@{$known_host_peers{$host}}) {
+               if (&item_in_list($peer, @trace)) {
+                   # we've detected a loop !
+                   $printhost = ' ' x ($level + 1) . "= " . $peer;
+                   # Shorten host string
+                   if ($strip) {
+                       $printhost =~ s/$strip//;
+                   }
+                   printf("%-32s %s\n",
+                       substr($printhost,0,32));
+               } else {
+                   if (substr($peer,0,3) ne "127") {
+                       &scan_host($peer, $level + 1, @trace);
+                   }
+               }
+           }
+       }
+    } else { # We did not get answers from this host
+       my $printhost = ' ' x $level . $host;
+       # Shorten host string
+       if ($strip) {
+           $printhost =~ s/$strip//;
+       }
+       printf("%-32s  ?\n", substr($printhost,0,32));
+    }
+}
+
+sub scan_hosts()
+{
+    my $host;
+    for $host (@hosts) {
+       my @trace;
+       push(@trace, $host);
+       scan_host($host, 0, @trace);
+    }
+}
+
+# Main program
+
+if ($single_host) {
+    push(@hosts, $single_host);
+} else {
+    &read_hosts($hostsfile);
+}
+
+# Print header
+print <<EOF;
+Host                             st offset(s) version     system       processor
+--------------------------------+--+---------+-----------+------------+---------
+EOF
+
+&scan_hosts();
+
+exit 0;
diff --git a/scripts/ntptrace.in b/scripts/ntptrace.in
new file mode 100755 (executable)
index 0000000..c3c2a20
--- /dev/null
@@ -0,0 +1,70 @@
+#! @PATH_PERL@ -w
+
+# John Hay -- John.Hay@icomtek.csir.co.za / jhay@FreeBSD.org
+
+use Socket;
+use Getopt::Std;
+use vars qw($opt_n $opt_m);
+
+$ntpq = "ntpq";
+
+getopts('nm:');
+
+$dodns = 1;
+$dodns = 0 if (defined($opt_n));
+
+$max_hosts = (defined($opt_m) ? $opt_m :  99);
+$max_hosts = 0 if ( $max_hosts !~ /^\d+$/ );
+$nb_host = 1;
+
+$host = shift;
+$host ||= "127.0.0.1";
+
+for (;;) {
+       $nb_host++;
+       $rootdelay = 0;
+       $rootdispersion = 0;
+       $stratum = 255;
+       $cmd = "$ntpq -n -c rv $host";
+       open(PH, $cmd . "|") || die "failed to start command $cmd: $!";
+       while (<PH>) {
+               $stratum = $1 if (/stratum=(\d+)/);
+               $peer = $1 if (/peer=(\d+)/);
+               # Very old servers report phase and not offset.
+               $offset = $1 if (/(?:offset|phase)=([^\s,]+)/);
+               $rootdelay = $1 if (/rootdelay=([^\s,]+)/);
+               $rootdispersion = $1 if (/rootdispersion=([^\s,]+)/);
+               $refid = $1 if (/refid=([^\s,]+)/);
+       }
+       close(PH) || die "$cmd failed";
+       last if ($stratum == 255);
+       $offset /= 1000;
+       $syncdistance = ($rootdispersion + ($rootdelay / 2)) / 1000;
+       $dhost = $host;
+       # Only do lookups of IPv4 addresses. The standard lookup functions
+       # of perl only do IPv4 and I don't know if we should require extras.
+       if ($dodns && $host =~ /^(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})$/) {
+               $iaddr = inet_aton($host);
+               $name = (gethostbyaddr($iaddr, AF_INET))[0];
+               $dhost = $name if (defined($name));
+       }
+       printf("%s: stratum %d, offset %f, synch distance %f",
+           $dhost, $stratum, $offset, $syncdistance);
+       printf(", refid '%s'", $refid) if ($stratum == 1);
+       printf("\n");
+       last if ($stratum == 0 || $stratum == 1 || $stratum == 16);
+       last if ($refid =~ /^127\.127\.\d{1,3}\.\d{1,3}$/);
+       last if ($nb_host > $max_hosts);
+
+       $cmd = "$ntpq -n -c \"pstat $peer\" $host";
+       open(PH, $cmd . "|") || die "failed to start command $cmd: $!";
+       $thost = "";
+       while (<PH>) {
+               $thost = $1, last if (/srcadr=(\S+),/);
+       }
+       close(PH) || die "$cmd failed";
+       last if ($thost eq "");
+       last if ($thost =~ /^127\.127\.\d{1,3}\.\d{1,3}$/);
+       $host = $thost;
+}
+
diff --git a/scripts/ntpver.in b/scripts/ntpver.in
new file mode 100644 (file)
index 0000000..be36897
--- /dev/null
@@ -0,0 +1,7 @@
+#!@PATH_SH@
+# print version string of NTP daemon
+# Copyright (c) 1997 by Ulrich Windl
+# Modified 970318: Harlan Stenn: rewritten...
+# usage: ntpver hostname
+
+ntpq -c "rv 0 daemon_version" $* | awk '/daemon_version/ { print $2 }'
diff --git a/scripts/plot_summary.in b/scripts/plot_summary.in
new file mode 100644 (file)
index 0000000..3b46a04
--- /dev/null
@@ -0,0 +1,337 @@
+#! @PATH_PERL@ -w
+# $Id$
+#
+# Use Gnuplot to display data in summary files produced by summary.pl.
+# This script requires GNUPLOT 3.7!
+#
+# Copyright (c) 1997, 1999 by Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+require 5.003; # "never tested with any other version of Perl"
+use strict;
+
+use Time::Local;
+use Getopt::Long;
+
+# parse command line
+my $summary_dir = "/tmp";
+my $identifier = "host " . `hostname`; # origin of these data
+chomp $identifier;                     # remove newline
+my $offset_limit = 0.128;              # limit of absolute offset
+my $output_file = "";                  # output file defaults to stdout
+my $output_file_number = 1;            # numbering of output files
+my $gnuplot_terminal = $ENV{DISPLAY} ? "x11" : "dumb";
+my $wait_after_plot = 1;
+my @peer_list = ();
+
+my %options = ("directory|input-directory=s" => \$summary_dir,
+              "identifier=s" => \$identifier,
+              "offset-limit=f" => \$offset_limit,
+              "output-file=s" => \$output_file,
+              "peer=s@" => \@peer_list,
+              "plot-term|gnuplot-term=s" => \$gnuplot_terminal,
+              "wait-after-plot!" => \$wait_after_plot,
+              );
+
+if ( !GetOptions(%options) )
+{
+    print STDERR "valid options for $0 are:\n";
+    my $opt;
+    foreach $opt (sort(keys %options)) {
+       print STDERR "\t--$opt\t(default is ";
+       if ( ref($options{$opt}) eq "ARRAY" ) {
+           print STDERR join(", ",  map { "'$_'" } @{$options{$opt}});
+       } else {
+           print STDERR "'${$options{$opt}}'";
+       }
+       print STDERR ")\n";
+    }
+    print STDERR "\n";
+    die;
+}
+
+chomp $identifier;
+die "illegal offset-limit: $offset_limit" unless $offset_limit > 0.0;
+$offset_limit *= 1e6;                  # scale to microseconds
+
+# return the smallest value in the given list
+sub min
+{
+    my ($result, @rest) = @_;
+    map { $result = $_ if ($_ < $result) } @rest;
+    return($result);
+}
+
+# return the largest value in the given list
+sub max
+{
+    my ($result, @rest) = @_;
+    map { $result = $_ if ($_ > $result) } @rest;
+    return($result);
+}
+
+# maybe open alternate output file
+sub open_output
+{
+    my $file;
+    if ($output_file) {
+       while ( -r ($file = "$output_file$output_file_number") ) {
+           ++$output_file_number;
+       }
+       open TOUCH, ">$file" and close TOUCH or die "$file: $!";
+       print "set output \"$file\"\n";
+    }
+}
+
+# make Gnuplot wait
+sub maybe_add_pause
+{
+    print "pause -1 \"Press key to continue...\"\n" if $wait_after_plot;
+}
+
+# plot data from loop summary
+sub do_loop
+{
+    my $fname = shift;
+    my $line;
+    my $out_file = "/tmp/tempdata$$";
+    my $cmd_file = "/tmp/tempcmd$$";
+    my ($first_day, $day_out) = ("", 0);
+    my ($lower_bound, $upper_bound, $rms);
+    my ($min_offs, $max_offs) = (1e9, -1e9);
+    my ($min_rms, $max_rms) = (1e9, -1e9);
+    open INPUT, "$fname" or die "$fname: $!";
+    open OUTPUT, ">$out_file" or die "$out_file: $!";
+    my @Fld;
+    while (<INPUT>) {
+       chop;   # strip record separator
+       @Fld = split;
+       if ($#Fld == 0) {
+# loops.19960405
+           $_ = $Fld[0]; s/.*([12]\d{3}[01]\d[0-3]\d)$/$1/;
+           m/(\d{4})(\d{2})(\d{2})/;
+           $line = timegm(59, 59, 23, $3, $2 - 1, $1 - 1900, 0, 0, 0);
+           $line = int $line / 86400;  # days relative to 1970
+           $first_day = "$1-$2-$3 ($line)" unless $day_out;
+           next;
+       }
+       if ($#Fld != 8) {
+           warn "Illegal number of fields in file $fname, line $.";
+           next;
+       }
+# loop 216, 856106+/-874041.5, rms 117239.8, freq 67.52+/-10.335, var 4.850
+       $_ = $Fld[1]; s/,/ /; $line .= " $_";
+       $_ = $Fld[2]; m:(.+?)\+/-(.+),:;
+       $lower_bound = $1 - $2;
+       $upper_bound = $1 + $2;
+       $line .= "$1 $lower_bound $upper_bound";
+       $min_offs = min($min_offs, $lower_bound);
+       $max_offs = max($max_offs, $upper_bound);
+       $_ = $Fld[4]; s/,/ /; $rms = $_;
+       $min_rms = min($min_rms, $rms);
+       $max_rms = max($max_rms, $rms);
+       $line .= " $rms";
+       $_ = $Fld[6]; m:(.+?)\+/-(.+),:;
+       $line .= " $1 " . ($1-$2) . " " . ($1+$2);
+       $line .= " $Fld[8]";
+       print OUTPUT "$line\n";
+       $day_out = 1;
+# 9621 216 856106 -17935.5 1730147.5 117239.8  67.52 57.185 77.855 4.850
+    }
+    close INPUT;
+    close OUTPUT or die "close failed on $out_file: $!";
+    my $ylimit = "[";
+    if ($min_offs < -$offset_limit) {
+       $ylimit .= "-$offset_limit";
+    }
+    $ylimit .= ":";
+    if ($max_offs > $offset_limit) {
+       $ylimit .= "$offset_limit";
+    }
+    if ( $ylimit eq "[:" ) {
+       $ylimit = "";
+    } else {
+       $ylimit = "[] $ylimit]";
+    }
+# build command file for GNUplot
+    open OUTPUT, "> $cmd_file" or die "$cmd_file: $!";
+    my $oldfh = select OUTPUT;
+    print "set term $gnuplot_terminal\n";
+    open_output;
+    print "set grid\n";
+    print "set title \"Loop Summary for $identifier: " .
+       "Daily mean values since $first_day\\n" .
+       "(Offset limit is $offset_limit microseconds)\"\n";
+    print "set ylabel \"[us]\"\n";
+    print "set data style yerrorbars\n";
+    print "set multiplot\n";
+    print "set size 1, 0.5\n";
+    print "set lmargin 8\n";
+    print "set origin 0, 0.5\n";
+    print "plot $ylimit \"$out_file\"" .
+       " using 1:3:4:5 title \"mean offset\", ";
+    print "\"$out_file\" using 1:(\$3-\$6/2) " .
+       "title \"(sigma low)\" with lines, ";
+    print "\"$out_file\" using 1:3 smooth bezier " .
+       "title \"(Bezier med)\" with lines, ";
+    print "\"$out_file\" using 1:(\$3+\$6/2) " .
+       "title \"(sigma high)\" with lines\n";
+    print "set ylabel \"[ppm]\"\n";
+    print "set origin 0, 0.0\n";
+    print "set title\n";
+    print "set xlabel \"Days relative to 1970\"\n";
+    print "plot \"$out_file\" using 1:7:8:9 title \"mean frequency\", ";
+    print "\"$out_file\" using 1:(\$7-\$10/2) " .
+       "title \"(sigma low)\" with lines, ";
+    print "\"$out_file\" using 1:7 smooth bezier " .
+       "title \"(Bezier med)\" with lines, ";
+    print "\"$out_file\" using 1:(\$7+\$10/2) " .
+       "title \"(sigma high)\" with lines\n";
+    print "set nomultiplot\n";
+    maybe_add_pause;
+
+    $ylimit = "[";
+    if ($min_rms < -$offset_limit) {
+       $ylimit .= "-$offset_limit";
+    }
+    $ylimit .= ":";
+    if ($max_rms > $offset_limit) {
+       $ylimit .= "$offset_limit";
+    }
+    if ( $ylimit eq "[:" ) {
+       $ylimit ="";
+    } else {
+       $ylimit = "[] $ylimit]";
+    }
+
+    open_output;
+    print "set title \"Loop Summary for $identifier: " .
+       "Standard deviation since $first_day\\n" .
+       "(Offset limit is $offset_limit microseconds)\"\n";
+    print "set xlabel\n";
+    print "set ylabel \"[us]\"\n";
+    print "set origin 0, 0.5\n";
+    print "set data style linespoints\n";
+    print "set multiplot\n";
+    print "plot $ylimit \"$out_file\" using 1:6 title \"Offset\", ";
+    print "\"$out_file\" using 1:6 smooth bezier " .
+       "title \"(Bezier)\" with lines\n";
+    print "set title\n";
+    print "set origin 0, 0.0\n";
+    print "set xlabel \"Days relative to 1970\"\n";
+    print "set ylabel \"[ppm]\"\n";
+    print "plot \"$out_file\" using 1:10 title \"Frequency\", ";
+    print "\"$out_file\" using 1:10 smooth bezier " .
+       "title \"(Bezier)\" with lines\n";
+    print "set nomultiplot\n";
+    maybe_add_pause;
+
+    close OUTPUT or die "close failed on $cmd_file: $!";
+    select $oldfh;
+    print `gnuplot $cmd_file`;
+    unlink $cmd_file;
+    unlink $out_file;
+}
+
+# plot data form peer summary
+sub do_peer
+{
+    my $fname = shift;
+    my $peer = shift;
+    my $out_file = "/tmp/tempdata$$";
+    my $cmd_file = "/tmp/tempcmd$$";
+    my $line;
+    my ($first_day, $day_out) = ("", 0);
+    open INPUT, "$fname" or die "$fname: $!";
+    open OUTPUT, ">$out_file" or die "$out_file: $!";
+    my @Fld;
+    while (<INPUT>) {
+       chop;   # strip record separator
+       @Fld = split;
+       if ($#Fld == 0) {
+# peers.19960405
+           $_ = $Fld[0]; s/.*([12]\d{3}[01]\d[0-3]\d)$/$1/;
+           m/(\d{4})(\d{2})(\d{2})/ or next;
+           $line = timegm(59, 59, 23, $3, $2 - 1, $1 - 1900, 0, 0, 0);
+           $line = int $line / 86400;  # days relative to 1970
+           $first_day = "$1-$2-$3 ($line)" unless $day_out;
+           next;
+       }
+       if ($#Fld != 7) {
+           warn "Illegal number of fields in file $fname, line $.";
+           next;
+       }
+       next if ($Fld[0] ne $peer);
+#       ident     cnt     mean     rms      max     delay     dist     disp
+# 127.127.8.1       38   30.972  189.867 1154.607    0.000  879.760  111.037
+       $Fld[0] = $line;
+       print OUTPUT join(' ', @Fld) . "\n";
+# 9969 38 30.972 189.867 1154.607 0.000 879.760 111.037
+       $day_out = 1;
+    }
+    close INPUT;
+    close OUTPUT or die "close failed on $out_file: $!";
+    die "no data found for peer $peer" if !$day_out;
+    open OUTPUT, "> $cmd_file" or die "$cmd_file: $!";
+    my $oldfh = select OUTPUT;
+    print "set term $gnuplot_terminal\n";
+    open_output;
+    print "set grid\n";
+    print "set multiplot\n";
+    print "set lmargin 8\n";
+    print "set size 1, 0.34\n";
+    print "set origin 0, 0.66\n";
+    print "set title " .
+       "\"Peer Summary for $peer on $identifier since $first_day\"\n";
+    print "set data style linespoints\n";
+    print "set ylabel \"[us]\"\n";
+    print "plot \"$out_file\" using 1:3 title \"mean offset\", ";
+    print "\"$out_file\" using 1:3 smooth bezier " .
+       "title \"(Bezier)\" with lines, ";
+    print "\"$out_file\" using 1:(\$3-\$7/2) " .
+       "title \"(sigma low)\" with lines, ";
+    print "\"$out_file\" using 1:(\$3+\$7/2) " .
+       "title \"(sigma high)\" with lines\n";
+    print "set title\n";
+    print "set origin 0, 0.34\n";
+    print "set size 1, 0.32\n";
+    print "set ylabel\n";
+    print "plot \"$out_file\" using 1:7 title \"dist\", ";
+    print "\"$out_file\" using 1:7 smooth bezier " .
+       "title \"(Bezier)\" with lines\n";
+    print "set origin 0, 0.00\n";
+    print "set size 1, 0.35\n";
+    print "set xlabel \"Days relative to 1970\"\n";
+    print "plot \"$out_file\" using 1:8 title \"disp\", ";
+    print "\"$out_file\" using 1:8 smooth bezier " .
+       "title \"(Bezier)\" with lines\n";
+    print "set nomultiplot\n";
+    maybe_add_pause;
+
+    select $oldfh;
+    close OUTPUT or die "close failed on $cmd_file: $!";
+    print `gnuplot $cmd_file`;
+    unlink $cmd_file;
+    unlink $out_file;
+}
+
+
+my $loop_summary ="$summary_dir/loop_summary";
+my $peer_summary ="$summary_dir/peer_summary";
+my $clock_summary="$summary_dir/clock_summary";
+
+do_loop $loop_summary;
+map { do_peer $peer_summary, $_ } @peer_list;
diff --git a/scripts/rc1/postinstall b/scripts/rc1/postinstall
new file mode 100644 (file)
index 0000000..d84b8c5
--- /dev/null
@@ -0,0 +1,2 @@
+#!/bin/sh
+/etc/init.d/xntp start
diff --git a/scripts/rc1/preinstall b/scripts/rc1/preinstall
new file mode 100644 (file)
index 0000000..aa18639
--- /dev/null
@@ -0,0 +1,6 @@
+#!/bin/sh
+if [ -x /etc/init.d/xntp ]
+then
+       /etc/init.d/xntp stop
+fi
+exit 0
diff --git a/scripts/rc1/preremove b/scripts/rc1/preremove
new file mode 100644 (file)
index 0000000..b870151
--- /dev/null
@@ -0,0 +1,4 @@
+#!/bin/sh
+/etc/init.d/xntp stop
+
+exit 0
diff --git a/scripts/rc1/prototype b/scripts/rc1/prototype
new file mode 100644 (file)
index 0000000..3de20b0
--- /dev/null
@@ -0,0 +1,19 @@
+!default 755 root bin
+i pkginfo
+i preinstall
+i postinstall
+i preremove
+f none /etc/init.d/xntp=xntp 0755 root other
+l none /etc/rc2.d/S79xntp=/etc/init.d/xntp
+l none /etc/rc1.d/K79xntp=/etc/init.d/xntp
+l none /etc/rc0.d/K79xntp=/etc/init.d/xntp
+f none /usr/sbin/xntpd=xntpd/xntpd 0555 root other
+f none /usr/sbin/xntpdc=xntpdc/xntpdc 0555 root other
+f none /usr/sbin/ntpq=ntpq/ntpq 0555 root other
+f none /usr/sbin/ntptrace=ntptrace/ntptrace 0555 root other
+f none /usr/sbin/ntpdate=ntpdate/ntpdate 0555 root other
+f none /usr/share/man/man1m/xntpd.1m=doc/xntpd.8 0444 root other
+f none /usr/share/man/man1m/xntpdc.1m=doc/xntpdc.8 0444 root other
+f none /usr/share/man/man1m/ntpdate.1m=doc/ntpdate.8 0444 root other
+f none /usr/share/man/man1m/ntpq.1m=doc/ntpq.8 0444 root other
+f none /usr/share/man/man1m/ntptrace.1m=doc/ntptrace.8 0444 root other
diff --git a/scripts/rc1/xntp b/scripts/rc1/xntp
new file mode 100644 (file)
index 0000000..227b943
--- /dev/null
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+killproc() {   # kill named processes
+       pid=`/usr/bin/ps -e |
+               /usr/bin/grep $1 |
+               /usr/bin/sed -e 's/^  *//' -e 's/ .*//'`
+       [ "$pid" != "" ] && kill $pid
+}
+
+case "$1" in
+'start')
+       ps -e | grep xntpd > /dev/null 2>&1
+       if [ $? -eq 0 ]
+       then
+               echo "ntp daemon already running. ntp start aborted"
+               exit 0
+       fi
+       if [ -f /etc/inet/ntp.conf -a -x /usr/sbin/xntpd ]
+       then
+               /usr/sbin/xntpd -c /etc/inet/ntp.conf
+       fi
+       ;;
+'stop')
+       killproc xntpd
+       ;;
+*)
+       echo "Usage: /etc/init.d/xntp { start | stop }"
+       ;;
+esac
diff --git a/scripts/rc2/local.ntpd b/scripts/rc2/local.ntpd
new file mode 100644 (file)
index 0000000..ba53e05
--- /dev/null
@@ -0,0 +1,64 @@
+#! /usr/bin/perl -w
+# 980904 Harlan Stenn - created
+
+# vvv CHANGE THESE vvv
+
+$ps = "/bin/ps x |";
+
+$ntp_conf = "/etc/ntp.conf";
+$ntpd = "/usr/local/bin/xntpd";
+$ntpdate = "/usr/local/bin/ntpdate -b -s 10.0.0.1 10.0.0.2";
+
+# ^^^ CHANGE THESE ^^^
+
+{
+  if (0)
+    {
+    }
+  elsif ($ARGV[0] eq "start")
+    {
+      @pidlist = pidlist($ntpd);
+      if (defined(@pidlist))
+        {
+         warn "NTP is already running\n";
+        }
+      else
+        {
+         if ( -f $ntp_conf && -x $ntpd )
+           {
+              system ($ntpdate);
+              system ($ntpd." -c ".$ntp_conf);
+           }
+        }
+    }
+  elsif ($ARGV[0] eq "stop")
+    {
+      @pidlist = pidlist($ntpd);
+      kill 'TERM', @pidlist if (scalar(@pidlist) > 0);
+    }
+  else
+    {
+      die "Usage: $0 {start,stop}\n";
+    }
+}
+
+sub pidlist ($)
+  {
+    my ($target) = @_;
+    my ($qt) = quotemeta($target);
+    my @pids;
+
+    open(PS, $ps) || die "Can't run ps: $!\n";
+    while (<PS>)
+      {
+       chomp;
+       next unless (/$qt/);
+       print "Got <$_>\n";
+       if (/^\s*(\d+)\s+/)
+         {
+           push @pids, $1;
+         }
+      }
+    close(PS);
+    return @pids;
+  }
diff --git a/scripts/stats/README b/scripts/stats/README
new file mode 100644 (file)
index 0000000..6808963
--- /dev/null
@@ -0,0 +1,39 @@
+Statistics processing scripts (README)
+
+This directory contains a number of scripts for use with the filegen
+facility. Those files ending in .awk are for the Unix awk utility, while
+those ending in .sh are for the csh utility. Normally, the summary.sh
+script is called from a cron job once per day. This script processes the
+daily loopstats, peerstats and clockstats files produced by the daemon,
+updates the loop_summary, peer_summary and clock_summary archive files,
+and deletes the daily files.
+
+In the case of the Austron 2201A GPS receiver, the clockstats file
+contains a wealth of additional monitoring data. These data are summarized
+and writted to the clock_summary file, then a series of special files are
+constructed for later processing by the S utility.
+
+The summary.sh script invokes a number of awk scripts to actually produce
+the data. This may result in multiple scans of the same input file.
+The input file is deleted after processing. In fact, the shell scripts will
+process all input files found of the correct type in chronological order,
+deleting each one as it is scanned, except the current day file.
+
+The summary.sh script can produce input files for the S utility, if it
+is found on the search path. This utility makes PostScript graphs of the
+loopstats data for each day, as well as various statistics produced by
+the Austorn 220aA GPS receiver. The S utility is automatically run
+as a background job. Its control files have the .S extension.
+
+The psummary.awk script can be used to scan the peer_summary file and
+construct an historical reprise of the daily summaries. 
+
+The file formats are documented in the README.stats file and in the
+scripts themselves. Further detail on the radio clock ASCII timecode
+formats and related data are in the README.timecode file.
+
+David L. Mills
+University of Delaware
+mills@udel.edu
+1 November 1993
+Revised 12 April 1994 
diff --git a/scripts/stats/README.stats b/scripts/stats/README.stats
new file mode 100644 (file)
index 0000000..aa8e77f
--- /dev/null
@@ -0,0 +1,246 @@
+Statistics file formats (README.stats)
+
+The xntp3 daemon can produce a variety of statistics files which are
+useful for maintenance, evaluation and retrospective calibration
+purposes. See the xntpd.8 man page for instructions on how to configure
+this feature. Since these files can become rather large and cumbersome,
+they are ordinarily reduced to summary form by running the summary.sh
+shell script once per day, week or month, as appropriate. There are
+three file collections presently defined: peerstats, loopstats and
+clockstats, each of which is described in this note.
+
+peerstats
+
+The following data are collected in the peerstats files. The files are
+reduced to summary data using the peer.sh shell script. See the peer.awk
+script for further information. A line in the file is produced upon
+reception of each valid update from a configured peer.
+
+  49236 30.756 140.173.96.1 9474 0.000603 0.37532
+
+  49236             modified Julian day number
+  30.756            time of day (s) past midnight UTC
+  140.173.96.1      peer identifier (IP address or receiver identifier)
+  9474              peer status word (hex) (see NTP specification)
+  0.000603          offset (s)
+  0.08929           delay (s)
+  0.37532           dispersion (s)
+
+loopstats
+
+The following data are collected in the loopstats files. The files are
+reduced to summary data using the loop.sh shell script. See the loop.awk
+script for further information. A line in the file is produced at each
+valid update of the local clock.
+
+  49236 11.897 -0.000004 -35.9384 0
+
+  49236             modified Julian day number
+  11.897            time of day (s) past midnight UTC
+  -0.000004         time offset (s)
+  -35.9384          frequency offset (ppm)
+  0                 phase-lock loop time constant
+
+clockstats
+
+The following data are collected in the clockstats files. The files are
+reduced to summary data using the clock.sh shell script, which also
+updates the ensemble, etf, itf and tdata data files as well. See the
+clock.awk, ensemble.awk, etf.awk, itf.awk and tdta.awk scripts for
+further information. A line in the file is produced at each valid update
+received from a configured radio clock. Data are at present recorded for
+several radios. The first part of each data line is similar for all
+radios, e.g.:
+
+  49234 60517.826 127.127.4.1   93 247 16:48:21.814
+
+  49234             modified Julian day number
+  60517.826         time of day (s) past midnight UTC
+  127.127.4.1       receiver identifier (Spectracom 8170/Netclock-2)
+  93 247 16:48:21.814  timecode (format varies)
+
+In the case of the Austron GPS receiver, a good deal of additional
+information is extracted from the radio, as described below. The formats
+shown consist of one line with all the fields shown in order. The
+timecode formats specific to each radio follow. See the file
+README.timecodes for detailed information on the timecode formats used
+by these radios.
+
+Spectracom 8170/Netclock-2 WWVB receiver
+
+  49234 60517.826 127.127.4.1 ?A93 247 16:48:21.814
+
+  The '?' and 'A' characters are present only when the receiver is
+  unsynchronized; otherwise, they are replaced by space ' ' characters.
+
+IRIG audio decoder
+
+  49234 60517.826 127.127.6.0 247 16:48:21?
+
+  The '?' character is present only when the receiver is unsynchronized.
+
+Austron 2200A/2201A GPS receiver
+
+  49234 60580.843 127.127.10.1 93:247:16:49:24.814?
+
+  The '?' character is present only when the receiver is unsynchronized.
+
+Depending on the installed options, the Austron 2200A/2201A recognizes a
+number of special commands that report various data items. See the
+refclock_as2201.c source module for a list of the commands used. These
+data are collected only if the following line is included in the
+configuration file ntp.conf:
+
+  fudge 127.127.10.1 flag4 1    # enable extended statistics collection
+
+The format of each data line returned is summarized in the following
+list.
+
+External time/frequency data (requires input buffer option IN)
+
+These data determine the deviations of external time/frequency inputs
+relative to receiver oscillator time. The following data are typical
+using an external cesium oscillator PPS and 5-MHz outputs.
+
+  49234 60580.843 127.127.10.1 93:247:16:49:24.814 ETF
+
+  -85.9             time interval (ns)
+  -89.0             average time interval (ns)
+  4.0               time interval sigma (ns)
+  +1.510E-11        time interval rate
+  -4.500E-11        deltaf/f
+  +1.592E-11        average deltaf/f
+  5.297E-13         sigma deltaf/f
+  500               number of samples
+
+Model and option identifiers
+
+These data show the receiver model number and option configuration.
+
+  49234 60708.848 127.127.10.1 93:247:16:51:32.817 ID;OPT;VER
+
+  GPS 2201A         model ident (must be "GPS 2200A" or "GPS 2201A")
+  TTY1              rs232 option present (required)
+  TC1               IRIG option present (optional)
+  LORAN             LORAN assist option present (optional)
+  IN                input buffer option present (optional)
+  OUT1              output buffer option present (required)
+  B.00              data processor software version ("B.00" or later)
+  B.00              signal processor software version ("B.00" or later)
+  28-Apr-93         software version date ("28-Apr-93" or later)
+
+Internal time/frequency data
+
+These data determine the deviations of the receiver oscillator with
+respect to satellite time.
+
+  49234 60564.846 127.127.10.1 93:247:16:49:08.816 ITF
+
+  COCO              current mode (must be "COCO")
+  0                 code coast mode (must be zero)
+  +6.6152E-08       code sigma (s)
+  -3.5053E-08       code delta t (s)
+  -4.0361E-11       deltat/t
+  -6.4746E-11       oscillator ageing rate
+  500.00            loop time constant
+  4.984072          electrical tuning (V)
+
+GPS/LORAN ensemble data (requires LORAN assist option LORAN)
+
+These data determine the deviations and weights to calculate ensemble
+time from GPS and LORAN data.
+
+  49234 60596.852 127.127.10.1 93:247:16:49:40.812 LORAN ENSEMBLE
+
+  +9.06E-08         GPS t (s)
+  +3.53E-08         GPS sigma (s)
+  .532              GPS weight
+  +3.71E-08         LORAN t (s)
+  +3.76E-08         LORAN sigma (s)
+  .468              LORAN weight
+  +6.56E-08         ensemble t
+  +6.94E-08         ensemble sigma (s)
+
+LORAN stationkeeping data (requires LORAN assist option LORAN)
+
+These data determine which stations of the LORAN chain are being
+tracked, together with individual signal/noise ratios, deviations and
+weights.
+
+  49234 60532.850 127.127.10.1 93:247:16:48:36.820 LORAN TDATA
+
+  M                 station identifier; data follows
+  OK                status (must be "OK" for tracking)
+  0                 cw flag
+  0                 sw flag
+  1162.17           time of arrival
+  -4.6              snr (-30.0 if not "OK" status)
+  1.67E-07          2-sample phase-time deviation
+  .507              weight (included only if "OK" status)
+  W AQ 0 0 3387.80 -31.0  station identifier and data
+  X OK 0 0 1740.27 -11.2 2.20E-07 .294  station identifier and data
+  Y OK 0 0 2180.71 -4.6 2.68E-07 .198  station identifier and data
+  Z CV 0 0 3392.94 -30.0  station identifier and data
+
+Oscillator status and environment
+
+These data determine the receiver oscillator type, mode, status and
+environment. Nominal operating conditions are shown below.
+
+  49234 60628.847 127.127.10.1 93:247:16:50:12.817 OSC;ET;TEMP
+
+  1121 Software     Control  oscillator model and mode (must be
+                    "Software Control")
+  Locked            status (must be "Locked")
+  4.979905          electrical tuning (V)
+  44.81             oscillator cavity temperature
+
+Receiver position, status and offsets
+
+These data determine the receiver position and elevation, together with
+programmable delay corrections for the antenna cable and receiver.
+
+  49234 60788.847 127.127.10.1 93:247:16:52:52.817 POS;PPS;PPSOFF
+
+  +39:40:48.425     receiver latitude (N)
+  -075:45:02.392    receiver longitude (E)
+  +74.09            receiver elevation (m)
+  Stored            position status (must be "Stored")
+  UTC               PPS/PPM alignment (must be "UTC")
+  0                 receiver delay (ns) (should be zero for calibrated
+                    receiver)
+  200               cable delay (ns)
+  0                 user time bias (ns) (must be zero)
+
+Satellite tracking status
+
+These data determine how many satellites are being tracked. At the
+present state of constellation development, there should be at least
+three visible satellites in view. Much of the time the maximum of
+seven are being tracked; rarely this number drops to two.
+
+  49234 60612.850 127.127.10.1 93:247:16:49:56.820 TRSTAT
+
+  24 T              satellite prn and status (T = track, A = acquire)
+  16 A 13 T 20 T 18 T 07 T 12 T  list continued
+
+UTC leap-second information
+
+These data determine when the next leap second is to occur. The exact
+method to use is obscure.
+
+  49234 60548.847 127.127.10.1 93:247:16:48:52.818 UTC
+
+  -1.2107E-08       A0 term (s)
+  -1.2790E-13       A1 term (s)
+  +9.0000E+00       current leap seconds (s)
+  +2.0480E+05       time for leap seconds (s)
+  +2.0100E+02       week number for delta leap (weeks)
+  +1.9100E+02       week number for future leap (weeks)
+  +4.0000E+00       day number for future leap (days)
+  +9.0000E+00       future leap seconds (s)
+
+David L. Mills
+University of Delaware
+mills@udel.edu
+23 October 1993
diff --git a/scripts/stats/README.timecodes b/scripts/stats/README.timecodes
new file mode 100644 (file)
index 0000000..00b5ba5
--- /dev/null
@@ -0,0 +1,149 @@
+Radio Timecode Formats (README.timecodes)
+
+Following are examples of the serial timecode formats used by various
+timecode receivers as given in the instruction manuals. These examples
+are intended only for illustration and not as the basis of system
+design. The following symbols are used to identify the timecode
+character that begins a subfield. The values given after this symbol
+represent the character offset from the beginning of the timecode string
+as edited to remove control characters.
+
+C         on-time character (start bit)
+Y         year of century
+T         time of day
+D         day of year or month/day
+A         alarm indicator (format specific)
+Q         quality indicator (format specific)
+<LF>      ASCII line feed (hex 0a)
+<CR>      ASCII carriage return (hex 0d)
+<SP>      ASCII space (hex 20)
+
+In order to promote uniform behavior in the various implementations, it
+is useful to have a common interpretation of alarm conditions and signal
+quality. When the alarm indicator it on, the receiver is not operating
+correctly or has never synchronized to the broadcast signal. When the
+alarm indicator is off and the quality indicator is on, the receiver has
+synchronized to the broadcast signal, then lost the signal and is
+coasting on its internal oscillator.
+
+In the following uppercase letters, punctuation marks and spaces <SP>
+stand for themselves; lowercase letters stand for fields as described.
+Special characters other than <LF>, <CR> and <SP> are preceded by ^.
+
+Spectracom 8170 and Netclock/2 WWV Synchonized Clock (format 0)
+
+"<CR><LF>i  ddd hh:mm:ss  TZ=zz<CR><LF>"
+ C       A  D   T
+
+     poll: ?; offsets: Y = none, D = 3, T = 7, A = 0, Q = none
+     i = synchronization flag (<SP> = in synch, ? = out synch)
+     ddd = day of year
+     hh:mm:ss = hours, minutes, seconds
+     zz = timezone offset (hours from UTC)
+
+     Note: alarm condition is indicated by other than <SP> at A, which
+     occurs during initial synchronization and when received signal has
+     been lost for about ten hours
+
+     example: "   216 15:36:43  TZ=0"
+               A  D   T
+
+Netclock/2 WWV Synchonized Clock (format 2)
+
+"<CR><LF>iqyy ddd hh:mm:ss.fff ld"
+ C       AQY  D   T
+
+     poll: ?; offsets: Y = 2, D = 5, T = 9, A = 0, Q = 1
+     i = synchronization flag (<SP> = in synch, ? = out synch)
+     q = quality indicator (<SP> < 1ms, A < 10 ms, B < 100 ms, C < 500
+     ms, D > 500 ms)
+     yy = year (as broadcast)
+     ddd = day of year
+     hh:mm:ss.fff = hours, minutes, seconds, milliseconds of day
+     l = leap-second warning (L indicates leap at end of month)
+     d = standard/daylight time indicator (<SP> standard, D daylight)
+
+     Note: alarm condition is indicated by other than <SP> at A, which
+     occurs during initial synchronization and when received signal has
+     been lost for about ten hours; unlock condition is indicated by
+     other than <SP> at Q, with time since last lock indicated by the
+     letter code A < 13 min, B < 1.5 hr, C < 7 hr, D > 7 hr.
+
+     example: "  92 216 15:36:43.640  D"
+               AQ   D   T
+
+TrueTime 468-DC Satellite Synchronized Clock (and other TrueTime
+receivers)
+
+"<CR><LF><^A>ddd:hh:mm:ssq<CR>"
+              D   T       QC
+
+     poll: none; offsets: Y = none, D = 0, T = 4, A = 12, Q = 12
+     hh:mm:ss = hours, minutes, seconds
+     q = quality/alarm indicator (<SP> = locked, ? = alarm)
+
+     Note: alarm condition is indicated by ? at A, which occurs during
+     initial synchronization and when received signal is lost for an
+     extended period; unlock condition is indicated by other than <SP>
+     at Q
+
+     example: "216:15:36:43 "
+               D   T       Q
+
+Heath GC-1000 Most Accurate Clock (WWV/H)
+
+"<CR>hh:mm:ss.f     dd/mm/yy<CR>"
+ C   T        A     D
+
+     poll: none; offsets: Y = none, D = 15, T = 0, A = 9, Q = none
+     hh:mm:ss = hours, minutes, seconds
+     f = deciseconds (? when out of spec)
+     dd/mm = day, month
+     yy = year of century (from DIPswitches)
+
+     Note: 0?:??:??.? is displayed before synch is first established and
+     hh:mm:ss.? once synch is established and then lost again for about
+     a day.
+
+     example: "15:36:43.6     04/08/91"
+               T        A     D     Y
+
+PST/Traconex 1020 Time Source (WWV/H) (firmware revision V4.01)
+
+"frdzycchhSSFTttttuuxx<CR>" "ahh:mm:ss.fffs<CR>" "yy/dd/mm/ddd<CR>"
+          A   Q               T                   Y  D
+
+     poll: "QMQDQT"; offsets: Y = 0, D = 3 T = 1,, A = 11, Q = 13
+     f = frequency enable (O = all frequencies enabled)
+     r = baud rate (3 = 1200, 6 = 9600)
+     d = features indicator (@ = month/day display enabled)
+     z = time zone (0 = UTC)
+     y = year (5 = 1991)
+     cc = WWV propagation delay (52 = 22 ms)
+     hh = WWVH propagation delay (81 = 33 ms)
+     SS = status (80 or 82 = operating correctly)
+     F = current receive frequency (1-5 = 2.5, 5, 10, 15, 20 MHz)
+     T = transmitter (C = WWV, H = WWVH)
+     tttt = time since last update (minutes)
+     uu = flush character (03 = ^C)
+     xx = 94 (unknown) (firmware revision X4.01.999 only)
+
+     a = AM/PM indicator (A = AM, P = PM, <SP> - 24-hour format)
+     hh:mm:ss.fff = hours, minutes, seconds, milliseconds of day
+     s = daylight-saving indicator (<SP> standard, D daylight)
+
+     yy = year of century (from DIPswitches)
+     dd/mm/ddd = day of month, month of year, day of year
+
+     Note: The alarm condition is indicated by other than ? at A, which
+     occurs during initial synchronization and when received signal is
+     lost for an extended period. A receiver unlock condition is
+     indicated by other than "0000" in the tttt subfield at Q.
+
+     example: "O3@055281824C00000394 91/08/04/216  15:36:43.640"
+                             T       Y        D    T
+
+David L. Mills
+University of Delaware
+mills@udel.edu
+23 October 1993
diff --git a/scripts/stats/clock.awk b/scripts/stats/clock.awk
new file mode 100755 (executable)
index 0000000..ef62da9
--- /dev/null
@@ -0,0 +1,431 @@
+# awk program to scan clockstat files and report errors/statistics
+#
+# usage: awk -f check.awk clockstats
+#
+# This program works for the following radios:
+# PST/Traconex 1020 WWV reciever
+# Arbiter 1088 GPS receiver
+# Spectracom 8170/Netclock-2 WWVB receiver
+# IRIG audio decoder
+# Austron 2200A/2201A GPS receiver (see README.austron file)
+#
+BEGIN {
+       etf_min = osc_vmin = osc_tmin = 1e9
+       etf_max = osc_vmax = osc_tmax = -1e9
+}
+#
+# scan all records in file
+#
+{
+       #
+       # select PST/Traconex WWV records
+       # 00:00:37.234  96/07/08/190 O6@0:5281825C07510394
+       #
+       if (NF >= 4 && $3 == "127.127.3.1") {
+               if (substr($6, 14, 4) > "0010")
+                       wwv_sync++
+               if (substr($6, 13, 1) == "C")
+                       wwv_wwv++
+               if (substr($6, 13, 1) == "H")
+                       wwv_wwvh++
+               x = substr($6, 12, 1)
+               if (x == "1")
+                       wwv_2.5++
+               else if (x == "2")
+                       wwv_5++
+               else if (x == "3")
+                       wwv_10++
+               else if (x == "4")
+                       wwv_15++
+               else if (x == "5")
+                       wwv_20++
+               continue
+       }
+       #
+       # select Arbiter GPS records
+       # 96 190 00:00:37.000 0 V=08 S=44 T=3 P=10.6 E=00
+       # N39:42:00.951 W075:46:54.880 210.55      2.50 0.00
+       #
+       if (NF >= 4 && $3 == "127.127.11.1") {
+               if (NF > 8) {
+                       arb_count++
+                       if ($7 != 0)
+                               arb_sync++
+                       x = substr($10, 3, 1)
+                       if (x == "0")
+                               arb_0++
+                       else if (x == "1")
+                               arb_1++
+                       else if (x == "2")
+                               arb_2++
+                       else if (x == "3")
+                               arb_3++
+                       else if (x == "4")
+                               arb_4++
+                       else if (x == "5")
+                               arb_5++
+                       else if (x == "6")
+                       arb_6++
+               } else if (NF == 8) {
+                       arbn++
+                       arb_mean += $7
+                       arb_rms += $7 * $7
+                       if (arbn > 0) {
+                               x = $7 - arb_val
+                               arb_var += x * x
+                       }
+                       arb_val = $7
+               }
+               continue
+       }
+       #
+       # select Spectracom WWVB records
+       # see summary for decode
+       #   96 189 23:59:32.248  D
+       #
+       if (NF >= 4 && $3 == "127.127.4.1") {
+               if ($4 == "SIGNAL" || NF > 7)
+                       printf "%s\n", $0
+               else {
+                       wwvb_count++
+                       if ($4 ~ /\?/)
+                               wwvb_x++
+                       else if ($4 ~ /A/)
+                               wwvb_a++
+                       else if ($4 ~ /B/)
+                               wwvb_b++
+                       else if ($4 ~ /C/)
+                               wwvb_c++
+                       else if ($4 ~ /D/)
+                               wwvb_d++
+               }
+               continue
+       }
+       #
+       # select IRIG audio decoder records
+       # see summary for decode
+       #
+       if (NF >= 4 && $3 == "127.127.6.0") {
+               irig_count++
+               if ($5 ~ /\?/)
+                       irig_error++
+               continue
+       }
+       #
+       # select Austron GPS LORAN ENSEMBLE records
+       # see summary for decode
+       #
+       else if (NF >= 13 && $6 == "ENSEMBLE") {
+               ensemble_count++
+               if ($9 <= 0)
+                       ensemble_badgps++
+               else if ($12 <= 0)
+                       ensemble_badloran++
+               else {
+                       if ($13 > 200e-9 || $13 < -200e-9)
+                               ensemble_200++
+                       else if ($13 > 100e-9 || $13 < -100e-9)
+                               ensemble_100++
+                       ensemble_mean += $13
+                       ensemble_rms += $13 * $13
+               }
+               continue
+       }
+       #
+       # select Austron LORAN TDATA records
+       # see summary for decode; note that signal quality log is simply
+       # copied to output
+       #
+       else if (NF >= 7 && $6 == "TDATA") {
+                tdata_count++
+                for (i = 7; i < NF; i++) {
+                        if ($i == "M" && $(i+1) == "OK") {
+                                i += 5
+                                m += $i
+                               tdata_m++
+                       }
+                        else if ($i == "W" && $(i+1) == "OK") {
+                                i += 5
+                                w += $i
+                               tdata_w++
+                       }
+                        else if ($i == "X" && $(i+1) == "OK") {
+                                i += 5
+                                x += $i
+                               tdata_x++
+                       }
+                        else if ($i == "Y" && $(i+1) == "OK") {
+                                i += 5
+                                y += $i
+                               tdata_y++
+                       }
+                        else if ($i == "Z" && $(i+1) == "OK") {
+                                i += 5
+                                z += $i
+                               tdata_z++
+                       }
+               }       
+               continue
+       }
+       #
+       # select Austron ITF records
+       # see summary for decode
+       #
+       else if (NF >= 13 && $5 == "ITF" && $12 >= 100) {
+               itf_count++
+               if ($9 > 200e-9 || $9 < -200e-9)
+                       itf_200++
+               else if ($9 > 100e-9 || $9 < -100e-9)
+                       itf_100++
+               itf_mean += $9
+               itf_rms += $9 * $9
+               itf_var += $10 * $10
+               continue
+       }
+       #
+       # select Austron ETF records
+       # see summary for decode
+       #
+       else if (NF >= 13 && $5 == "ETF" && $13 >= 100) {
+               etf_count++
+               if ($6 > etf_max)
+                       etf_max = $6
+               else if ($6 < etf_min)
+                       etf_min = $6
+               etf_mean += $6
+               etf_rms += $6 * $6
+               etf_var += $9 * $9
+               continue
+       }
+       #
+       # select Austron TRSTAT records
+       # see summary for decode
+       #
+       else if (NF >= 5 && $5 == "TRSTAT") {
+               trstat_count++
+               j = 0
+               for (i = 6; i <= NF; i++)
+                       if ($i == "T")
+                               j++
+               trstat_sat[j]++
+               continue
+       }
+       #
+       # select Austron ID;OPT;VER records
+       #
+       # config GPS 2201A TTY1 TC1 LORAN IN OUT1 B.00 B.00 28-Apr-93
+       #
+       # GPS 2201A     receiver model
+       # TTY1          rs232 moduel
+       # TC1           IRIG module
+       # LORAN         LORAN assist module
+       # IN            input module
+       # OUT1          output module
+       # B.00 B.00     firmware revision
+       # 28-Apr-9      firmware date3
+        #
+       else if (NF >= 5 && $5 == "ID;OPT;VER") {
+               id_count++
+               id_temp = ""
+               for (i = 6; i <= NF; i++)
+                       id_temp = id_temp " " $i
+               if (id_string != id_temp)
+                       printf "config%s\n", id_temp
+               id_string = id_temp
+               continue        
+       }
+       #
+       # select Austron POS;PPS;PPSOFF records
+       #
+       # position +39:40:48.425 -075:45:02.392 +74.09 Stored UTC 0 200 0
+       #
+       # +39:40:48.425 position north latitude
+       # -075:45:02.392 position east longitude
+       # +74.09        elevation (meters)
+       # Stored        position is stored
+       # UTC           time is relative to UTC
+       # 0 200 0       PPS offsets
+       #
+       else if (NF >= 5 && $5 == "POS;PPS;PPSOFF") {
+               pos_count++
+               pos_temp = ""
+               for (i = 6; i <= NF; i++)
+                       pos_temp = pos_temp " " $i
+               if (pos_string != pos_temp)
+                       printf "position%s\n", pos_temp
+               pos_string = pos_temp
+       continue
+       }
+       #
+       # select Austron OSC;ET;TEMP records
+       #
+       # loop 1121 Software Control Locked
+       #
+       # 1121          oscillator type
+       # Software Control loop is under software control
+       # Locked        loop is locked
+       #
+       else if (NF >= 5 && $5 == "OSC;ET;TEMP") {
+               osc_count++
+               osc_temp = $6 " " $7 " " $8 " " $9
+               if (osc_status != osc_temp)
+                       printf "loop %s\n", osc_temp
+               osc_status = osc_temp
+               if ($10 > osc_vmax)
+                       osc_vmax = $10
+               if ($10 < osc_vmin)
+                       osc_vmin = $10
+               if ($11 > osc_tmax)
+                       osc_tmax = $11
+               if ($11 < osc_tmin)
+                       osc_tmin = $11
+       continue
+       }
+       #
+       # select Austron UTC records
+       # these ain't ready yet
+       #
+       else if (NF >= 5 && $5 == "UTC") {
+               utc_count++
+               utc_temp = ""
+               for (i = 6; i <= NF; i++)
+                       utc_temp = utc_temp " " $i
+               if (utc_string != utc_temp)
+#                      printf "utc%s\n", utc_temp
+                utc_string = utc_temp
+       continue
+       }
+} END {
+#
+# PST/Traconex WWV summary data
+#
+       if (wwv_wwv + wwv_wwvh > 0)
+               printf "wwv %d, wwvh %d, err %d, MHz (2.5) %d, (5) %d, (10) %d, (15) %d, (20) %d\n", wwv_wwv, wwv_wwvh, wwv_sync, wwv_2.5, wwv_5, wwv_10, wwv_15, wwv_20
+#
+# Arbiter 1088 summary data
+#
+# gps          record count
+# err          error count
+# sats(0-6)    satellites tracked
+# mean         1 PPS mean (us)
+# rms          1 PPS rms error (us)
+# var          1 PPS Allan variance
+#
+       if (arb_count > 0) {
+               printf "gps %d, err %d, sats(0-6) %d %d %d %d %d %d %d", arb_count, arb_sync, arb_0, arb_1, arb_2, arb_3, arb_4, arb_5, arb_6
+               if (arbn > 1) {
+                       arb_mean /= arbn
+                       arb_rms = sqrt(arb_rms / arbn - arb_mean * arb_mean)
+                       arb_var = sqrt(arb_var / (2 * (arbn - 1)))
+                       printf ", mean %.2f, rms %.2f, var %.2e\n", arb_mean, arb_rms, arb_var * 1e-6
+               } else {
+                       printf "\n"
+               }
+       }
+#
+# ensemble summary data
+#
+# ensemble     record count
+# badgps       gps data unavailable
+# badloran     loran data unavailable
+# rms          ensemble rms error (ns)
+# >200         ensemble error >200 ns
+# >100         100 ns < ensemble error < 200 ns
+#
+       if (ensemble_count > 0) {
+               ensemble_mean /= ensemble_count
+               ensemble_rms = sqrt(ensemble_rms / ensemble_count - ensemble_mean * ensemble_mean) * 1e9 
+               printf "ensemble %d, badgps %d, badloran %d, rms %.1f, >200 %d, >100 %d\n", ensemble_count, ensemble_badgps, ensemble_badloran, ensemble_rms, ensemble_200, ensemble_100
+       }
+#
+# wwvb summary data
+#
+# wwvb         record count
+# ?            unsynchronized
+# >1           error > 1 ms
+# >10          error > 10 ms
+# >100         error > 100 ms
+# >500         error > 500 ms
+#
+       if (wwvb_count > 0)
+               printf "wwvb %d, ? %d, >1 %d, >10 %d, >100 %d, >500 %d\n", wwvb_count, wwvb_x, wwvb_a, wwvb_b, wwvb_c, wwvb_d
+#
+# irig summary data
+#
+# irig         record count
+# err          error count
+#
+       if (irig_count > 0)
+               printf "irig %d, err %d\n", irig_count, irig_error
+#
+# tdata summary data
+#
+# tdata                record count
+# m            M master OK-count, mean level (dB)
+# w            W slave OK-count, mean level (dB)
+# x            X slave OK-count, mean level (dB)
+# y            Y slave OK-count, mean level (dB)
+# z            Z slave OK-count, mean level (dB)
+#
+       if (tdata_count > 0 ) {
+               if (tdata_m > 0)
+                       m /= tdata_count
+               if (tdata_x > 0)
+                       w /= tdata_count
+               if (tdata_x > 0)
+                       x /= tdata_count
+               if (tdata_y > 0)
+                       y /= tdata_count
+               if (tdata_z > 0)
+                       z /= tdata_count
+               printf "tdata %d, m %d %.1f, w %d %.1f, x %d %.1f, y %d %.1f, z %d %.1f\n", tdata_count, tdata_m, m, tdata_w, w, tdata_x, x, tdata_y, y, tdata_z, z
+       }
+#
+# itf summary data
+#
+# itf          record count
+# rms          itf rms error (ns)
+# >200         itf error > 200 ns
+# >100         itf error > 100 ns
+# var          Allan variance
+#
+       if (itf_count > 1) { 
+               itf_mean /= itf_count
+               itf_rms = sqrt(itf_rms / itf_count - itf_mean * itf_mean) * 1e9
+               itf_var = sqrt(itf_var / (2 * (itf_count - 1)))
+               printf "itf %d, rms %.1f, >200 %d, >100 %d, var %.2e\n", itf_count, itf_rms, itf_200, itf_100, itf_var
+       }
+#
+# etf summary data
+#
+# etf          record count
+# mean         etf mean (ns)
+# rms          etf rms error (ns)
+# max          etf maximum (ns)
+# min          etf minimum (ns)
+# var          Allan variance
+#
+       if (etf_count > 0) {
+                etf_mean /= etf_count
+               etf_rms = sqrt(etf_rms / etf_count - etf_mean * etf_mean)
+               etf_var = sqrt(etf_var / (2 * (etf_count - 1)))
+               printf "etf %d, mean %.1f, rms %.1f, max %d, min %d, var %.2e\n", etf_count, etf_mean, etf_rms, etf_max, etf_min, etf_var
+       }
+#
+# trstat summary data
+#
+# trstat       record count
+# sat          histogram of tracked satellites (0 - 7)
+#
+       if (trstat_count > 0)
+               printf "trstat %d, sat %d %d %d %d %d %d %d %d\n", trstat_count, trstat_sat[0], trstat_sat[1], trstat_sat[2], trstat_sat[2], trstat_sat[3], trstat_sat[4], trstat_sat[5], trstat_sat[6], trstat_sat[7]
+#
+# osc summary data
+#
+# osc          record count
+# control      control midrange (V) +/- deviation (mV)
+# temp         oven temperature midrange +/- deviation (deg C)
+#
+       if (osc_count > 0)
+               printf "osc %d, control %.3f+/-%.3f, temp %.1f+/-%.2f\n", osc_count, (osc_vmax + osc_vmin) / 2, (osc_vmax - osc_vmin) / 2 * 1e3, (osc_tmax + osc_tmin) / 2, (osc_tmax - osc_tmin) / 2
+}
diff --git a/scripts/stats/dupe.awk b/scripts/stats/dupe.awk
new file mode 100755 (executable)
index 0000000..317c2a4
--- /dev/null
@@ -0,0 +1,8 @@
+#
+# delete duplicate lines
+#
+{
+       if (old != $0)
+               printf "%s\n", $0
+       old = $0
+}
diff --git a/scripts/stats/ensemble.S b/scripts/stats/ensemble.S
new file mode 100755 (executable)
index 0000000..32a4dba
--- /dev/null
@@ -0,0 +1,5 @@
+ensemble <- scan(file1, list(day=0, sec=0, gps=0, gpsw=0, loran=0, loranw=0, ensemble=0, std=0))
+str <- paste("eps/", file1, ".eps", sep="")
+postscript(str,  ,  ,  , 5, pointsize=18)
+par(mgp=c(1, 0, 0), tck = 0.03, mar = c(2, 2, 1, 1))
+plot(ensemble$sec, ensemble$ensemble, type="l", xlab=paste("MJD", ensemble$day, "Time (s)"), ylab="Ensemble Offset (ns)", ylim=c(-400, 400))
diff --git a/scripts/stats/ensemble.awk b/scripts/stats/ensemble.awk
new file mode 100755 (executable)
index 0000000..136b33d
--- /dev/null
@@ -0,0 +1,17 @@
+# program to produce loran ensemble statistics from clockstats files
+#
+# usage: awk -f ensemble.awk clockstats
+#
+# format of input record (time values in seconds)
+# 49165 8.628 127.127.10.1 93:178:00:00:07.241 LORAN ENSEMBLE
+# -6.43E-08 +5.02E-08 .091 +5.98E-08 +1.59E-08 .909 +4.85E-08 +3.52E-08
+#
+# format of output record (time values in nanoseconds)
+#  MJD       sec     GPS    wgt    LORAN   wgt      avg   sigma
+# 49165     8.628   -64.3  0.091    59.8  0.909    48.5    35.2
+#
+# select LORAN ENSEMBLE records with valid format and weights
+{
+       if (NF >= 14 && $6 == "ENSEMBLE" && $9 > 0 && $12 > 0)
+               printf "%5s %9.3f %7.1f %6.3f %7.1f %6.3f %7.1f %7.1f\n", $1, $2, $7*1e9, $9, $10*1e9, $12, $13*1e9, $14*1e9
+}
diff --git a/scripts/stats/etf.S b/scripts/stats/etf.S
new file mode 100755 (executable)
index 0000000..9b9c68b
--- /dev/null
@@ -0,0 +1,15 @@
+options(digits=4)
+file2 <- "etf_summary"
+etf <- scan(file1, list(day=0, sec=0, offset=0, stab=0))
+r <- lsfit(etf$sec, etf$offset)
+count<-length(etf$sec)
+mean<-r$coef[[1]]
+std<-sqrt(var(r$residuals))
+slope<-r$coef[[2]] * 1000 
+cat("\n", file=file2 , append=TRUE, fill=FALSE, sep="")
+cat(file1, "\n", file=file2, append=TRUE, fill=FALSE, sep="")
+cat("etf1 ",  count, ", T ", mean, " ns, R ", slope, " ps/s, std ", std, " us\n", file=file2, append=TRUE, fill=FALSE, sep="")
+str <- paste("eps/", file1, ".eps", sep="")
+postscript(str,  ,  ,  , 5, pointsize=18)
+par(mgp=c(1, 0, 0), tck=0.03, mar=c(2, 2, 1, 1))
+plot(etf$sec, etf$offset, type="l", xlab=paste("MJD", etf$day, "Time (s)"), ylab="External Offset (ns)", ylim=c(-400, 400))
diff --git a/scripts/stats/etf.awk b/scripts/stats/etf.awk
new file mode 100755 (executable)
index 0000000..8e6e334
--- /dev/null
@@ -0,0 +1,19 @@
+# program to produce external time/frequence statistics from clockstats files
+#
+# usage: awk -f etf.awk clockstats
+#
+# format of input record
+# 49165 40.473 127.127.10.1 93:178:00:00:39.238 ETF
+# +175.0 +176.8 2.0 +3.729E-11 +1.000E-10 +3.511E-11 4.005E-13 500
+#
+# format of output record (time values in nanoseconds)
+#  MJD      sec      time    freq
+# 49165    40.473   175.0  3.729e-11
+#
+# select ETF records with valid format
+{
+       if (NF >= 9 && $5 == "ETF") {
+               printf "%5s %9.3f %7.1f %10.3e\n", $1, $2, $6, $9
+       }
+}
+
diff --git a/scripts/stats/itf.S b/scripts/stats/itf.S
new file mode 100755 (executable)
index 0000000..56c8c8d
--- /dev/null
@@ -0,0 +1,5 @@
+itf <- scan(file1, list(day=0, sec=0, offset=0, stab=0))
+str <- paste("eps/", file1, ".eps", sep="")
+postscript(str,  ,  ,  , 5, pointsize=18)
+par(mgp=c(1, 0, 0), tck=0.03, mar=c(2, 2, 1, 1))
+plot(itf$sec, itf$offset, type="l", xlab=paste("MJD", itf$day, "Time (s)"), ylab="Internal Offset (ns)", ylim=c(-400, 400))
diff --git a/scripts/stats/itf.awk b/scripts/stats/itf.awk
new file mode 100755 (executable)
index 0000000..2b21c5b
--- /dev/null
@@ -0,0 +1,19 @@
+# program to produce intewrnal time/frequence statistics from clockstats files
+#
+# usage: awk -f itf.awk clockstats
+#
+# format of input record
+# 49227 67.846 127.127.10.1 93:240:00:00:51.816 ITF
+# COCO 0 +2.0579E-07 -3.1037E-08 -7.7723E-11 +6.5455E-10 500.00 4.962819
+#
+# format of output record (time values in nanoseconds)
+#  MJD      sec      time        freq
+# 49227   67.846  +2.0579E-07  -7.7723E-11
+#
+# select ITF records with valid format
+{
+       if (NF >= 10 && $5 == "ITF") {
+               printf "%5s %9.3f %7.1f %10.3e\n", $1, $2, $8 * 1e9, $10
+       }
+}
+
diff --git a/scripts/stats/loop.S b/scripts/stats/loop.S
new file mode 100755 (executable)
index 0000000..8e564b6
--- /dev/null
@@ -0,0 +1,7 @@
+options(digits=4)
+loop <- scan(file1, list(day=0, sec=0, offset=0, freq=0, tc=0))
+loop$offset <- loop$offset * 1e6
+str <- paste("eps/", file1, ".eps", sep="")
+postscript(str,  ,  ,  , 5, pointsize=18)
+par(mgp=c(1, 0, 0), tck=0.03, mar=c(2, 2, 1, 1))
+plot(loop$sec, loop$offset, type="l", xlab=paste("MJD", loop$day, "Time (s)"), ylab="PLL Offset (us)", ylim=c(-400, 400))
diff --git a/scripts/stats/loop.awk b/scripts/stats/loop.awk
new file mode 100755 (executable)
index 0000000..bac90db
--- /dev/null
@@ -0,0 +1,45 @@
+# awk program to scan loopstats files and report errors/statistics
+#
+# usage: awk -f loop.awk loopstats
+#
+# format of loopstats record
+#  MJD    sec   time (s)  freq (ppm)  poll
+# 49235  3.943  0.000016   22.4716    6
+#
+# format of output dataset (time values in milliseconds, freq in ppm)
+# loopstats.19960706
+# loop 1180, 0+/-11.0, rms 2.3, freq -24.45+/-0.045, var 0.019
+#
+BEGIN {
+       loop_tmax = loop_fmax = -1e9
+       loop_tmin = loop_fmin = 1e9
+}
+#
+# scan all records in file
+#
+{
+       if (NF >= 5) {
+               loop_count++
+               if ($3 > loop_tmax)
+                       loop_tmax = $3
+               if ($3 < loop_tmin)
+                       loop_tmin = $3
+               if ($4 > loop_fmax)
+                       loop_fmax = $4
+               if ($4 < loop_fmin)
+                       loop_fmin = $4
+               loop_time += $3
+               loop_time_rms += $3 * $3
+               loop_freq += $4
+               loop_freq_rms += $4 * $4
+       }
+} END {
+       if (loop_count > 0) {
+               loop_time /= loop_count
+                loop_time_rms = sqrt(loop_time_rms / loop_count - loop_time * loop_time)
+               loop_freq /= loop_count
+               loop_freq_rms = sqrt(loop_freq_rms / loop_count - loop_freq * loop_freq)
+               printf "loop %d, %.0f+/-%.1f, rms %.1f, freq %.2f+/-%0.3f, var %.3f\n", loop_count, (loop_tmax + loop_tmin) / 2 * 1e6, (loop_tmax - loop_tmin) / 2 * 1e6, loop_time_rms * 1e6, (loop_fmax + loop_fmin) / 2, (loop_fmax - loop_fmin) / 2, loop_freq_rms
+       }
+}
+
diff --git a/scripts/stats/loop_summary b/scripts/stats/loop_summary
new file mode 100755 (executable)
index 0000000..35479ec
--- /dev/null
@@ -0,0 +1,2 @@
+loopstats.[1-9]
diff --git a/scripts/stats/peer.awk b/scripts/stats/peer.awk
new file mode 100755 (executable)
index 0000000..5fe260e
--- /dev/null
@@ -0,0 +1,68 @@
+# awk program to scan peerstats files and report errors/statistics
+#
+# usage: awk -f peer.awk peerstats
+#
+# format of peerstats record
+#  MJD    sec    ident   stat  offset (s)  delay (s)  disp (s)
+# 49235 11.632 128.4.2.7 f414  -0.000041    0.21910   0.00084
+#
+# format of output dataset (time values in milliseconds)
+# peerstats.19960706
+#        ident     cnt     mean     rms      max     delay     dist     disp
+# ==========================================================================
+# 140.173.112.2     85   -0.509    1.345    4.606   80.417   49.260    1.092
+# 128.4.1.20      1364    0.058    0.364    4.465    3.712   10.540    1.101
+# 140.173.16.1    1415   -0.172    0.185    1.736    3.145    5.020    0.312
+#...
+#
+BEGIN {
+       n = 0
+       MAXDISTANCE = 1.0
+}
+#
+# scan all records in file
+#
+# we toss out all distances greater than one second on the assumption the
+# peer is in initial acquisition
+#
+{
+       if (NF >= 7 && ($7 + $6 / 2) < MAXDISTANCE) {
+               i = n
+               for (j = 0; j < n; j++) {
+                       if ($3 == peer_ident[j])
+                               i = j
+               }
+               if (i == n) {
+                       peer_ident[i] = $3
+                       peer_tmax[i] = peer_dist[i] = -1e9
+                       peer_tmin[i] = 1e9
+                       n++
+               }
+               peer_count[i]++
+               if ($5 > peer_tmax[i])
+                       peer_tmax[i] = $5
+               if ($5 < peer_tmin[i])
+                       peer_tmin[i] = $5
+               dist = $7 + $6 / 2
+               if (dist > peer_dist[i])
+                       peer_dist[i] = dist
+               peer_time[i] += $5
+               peer_time_rms[i] += $5 * $5
+               peer_delay[i] += $6
+               peer_disp[i] +=  $7
+       }
+} END {
+       printf "       ident     cnt     mean     rms      max     delay     dist     disp\n"
+       printf "==========================================================================\n"
+       for (i = 0; i < n; i++) {
+               peer_time[i] /= peer_count[i]
+                peer_time_rms[i] = sqrt(peer_time_rms[i] / peer_count[i] - peer_time[i] * peer_time[i])
+               peer_delay[i] /= peer_count[i]
+               peer_disp[i] /= peer_count[i]
+               peer_tmax[i] = peer_tmax[i] - peer_time[i]
+               peer_tmin[i] = peer_time[i] - peer_tmin[i]
+               if (peer_tmin[i] > peer_tmax[i])
+                       peer_tmax[i] = peer_tmin[i]
+               printf "%-15s%5d%9.3f%9.3f%9.3f%9.3f%9.3f%9.3f\n", peer_ident[i], peer_count[i], peer_time[i] * 1e3, peer_time_rms[i] * 1e3, peer_tmax[i] * 1e3, peer_delay[i] * 1e3, peer_dist[i] * 1e3, peer_disp[i] * 1e3
+       }
+}
diff --git a/scripts/stats/psummary.awk b/scripts/stats/psummary.awk
new file mode 100755 (executable)
index 0000000..ec06b0c
--- /dev/null
@@ -0,0 +1,82 @@
+# program to scan peer_summary file and produce summary of daily summaries
+#
+# usage: awk -f psummary.awk peer_summary
+#
+# format of input records
+# peerstats.19960706
+#        ident     cnt     mean     rms      max     delay     dist     disp
+# ==========================================================================
+# 140.173.112.2     85   -0.509    1.345    4.606   80.417   49.260    1.092
+# 128.4.1.20      1364    0.058    0.364    4.465    3.712   10.540    1.101
+# ...
+#
+# format of output records (actual data from rackety.udel.edu)
+#        host     days     mean       rms       max   >1  >5 >10 >50
+# ==================================================================
+# 127.127.22.1    1090     0.001     0.401    99.800  19  14  13  10
+# 127.0.0.1       1188     0.060     1.622   105.004  78  65  51  32
+# 127.127.4.1      586     0.000     0.000     0.000   0   0   0   0
+# 140.173.64.1     975    -0.010     2.552   257.595 399 192 114   8
+# 128.175.1.3     1121     0.447     8.637   204.123 479 460 397 147
+# 140.173.16.1    1106     0.027     1.014   267.857 242  38  31  23
+# 128.4.1.4       1119     0.023     1.037   267.748 223  41  34  23
+# 128.4.1.2        850     1.202     1.654   267.704 196  53  45  34
+# 128.4.1.20      1101     0.088     1.139   268.322 430 111  83  16
+# 140.173.32.1     979    -0.949     2.344   257.671 396 217 136   7
+# 140.173.112.2   1066     0.040     2.111   152.969 442 315 152  16
+# 140.173.80.1    1059     0.019     1.858    87.690 438 348 150   9
+# 140.173.96.1    1015     0.110     2.007   266.744 399 314 170  17
+# 140.173.128.1   1103    -0.002     2.600   257.672 465 262 132  13
+# 140.222.135.1    347    -4.626     8.804   196.394 135 135 134  95
+# 140.173.128.2   1081    -0.046     2.967   261.448 463 342 172  17
+# 140.222.141.1    354     0.820     8.809   195.333 142 141 139 100
+# 140.173.144.2   1058    -0.107     2.805   270.498 448 341 163  17
+# 140.222.134.1    354    -0.056     8.479   172.458 142 141 141 100
+# 140.222.144.1    415    -1.456     9.964   191.684 161 161 161 123
+# 140.222.136.1    234     0.902     7.707   182.431  62  62  62  48
+# 128.175.1.1      774     0.890     4.838   266.799 358 291 200  83
+# 127.127.10.1    1086    -0.002     1.462   231.128 240 239  60  57
+# 140.173.48.2     576     0.016     4.092   350.512 213 126  88  16
+# 128.4.1.11         3     0.000     0.000     0.000   0   0   0   0
+# 128.4.1.26       386    -1.363    20.251   341.284 164 164 161 132
+#
+# select table beginning with "ident"
+{
+       if (NF < 8 || $1 == "ident")
+               continue
+       i = n
+       for (j = 0; j < n; j++) {
+               if ($1 == peer_ident[j])
+                       i = j
+       }
+       if (i == n) {
+               peer_ident[i] = $1
+               n++
+       }
+       peer_count[i]++
+       if (($7 - $6 / 2) < 400) {
+               peer_count[i]++
+               peer_mean[i] += $3
+               peer_var[i] += $4 * $4
+               if ($5 > peer_max[i])
+                       peer_max[i] = $5
+               if ($5 > 1)
+                       peer_1[i]++
+               if ($5 > 5)
+                       peer_2[i]++
+               if ($5 > 10)
+                       peer_3[i]++
+               if ($5 > 50)
+                       peer_4[i]++
+       }
+} END {
+       printf "       host     days    mean       rms       max   >1  >5 >10 >50\n"
+       printf "==================================================================\n"
+       for (i = 0; i < n; i++) {
+               if (peer_count[i] <= 0)
+                       continue
+               peer_mean[i] /= peer_count[i]
+               peer_var[i] = sqrt(peer_var[i] / peer_count[i])
+               printf "%-15s%4d%10.3f%10.3f%10.3f%4d%4d%4d%4d\n", peer_ident[i], peer_count[i], peer_mean[i], peer_var[i], peer_max[i], peer_1[i], peer_2[i], peer_3[i], peer_4[i]
+       }
+}
diff --git a/scripts/stats/summary.sh b/scripts/stats/summary.sh
new file mode 100755 (executable)
index 0000000..dffdb0b
--- /dev/null
@@ -0,0 +1,88 @@
+#!/bin/sh
+#
+# Script to summarize ipeerstats, loopstats and clockstats files
+#
+# This script can be run from a cron job once per day, week or month. It
+# runs the file-specific summary script and appends the summary data to 
+# designated files.
+#
+DATE=`date +20%y%m%d`
+S=/usr/local/bin/S
+SIN=S.in
+SOUT=S.out
+LOOP=loop_summary
+PEER=peer_summary
+CLOCK=clock_summary
+
+rm -f $SIN $SOUT
+
+#
+# Summarize loopstats files
+#
+for f in loopstats.[12][0-9][0-9][0-9][0-1][0-9][0-3][0-9]; do
+       d=`echo $f | cut -f2 -d.`
+       if [ -f $f ] && [ $DATE != $d ]; then
+               echo " " >>$LOOP
+               echo $f >>$LOOP
+               awk -f loop.awk $f >>$LOOP
+               if [ -f $S ]; then
+                       echo "file1<-"\"${f}\" >>$SIN
+                       echo "source("\""loop.S"\"")" >>$SIN
+                       echo "unix("\""rm ${f}"\"")" >>$SIN
+               else
+                       rm -f $f
+               fi
+       fi
+done
+
+#
+# Summarize peerstats files
+#
+for f in peerstats.199[4-9][0-1][0-9][0-3][0-9]; do
+       d=`echo $f | cut -f2 -d.`
+       if [ -f $f ] && [ $DATE != $d ]; then
+               echo " " >>$PEER
+               echo $f >>$PEER
+               awk -f peer.awk $f >>$PEER
+               rm -f $f
+       fi
+done
+
+#
+# Summarize clockstats files
+#
+for f in clockstats.199[4-9][0-1][0-9][0-3][0-9]; do
+       d=`echo $f | cut -f2 -d.`
+       if [ -f $f ] && [ $DATE != $d ]; then
+               echo " " >>$CLOCK
+               echo $f >>$CLOCK
+               awk -f clock.awk $f >>$CLOCK
+               if [ -f /dev/gps[0-9] ]; then
+                       awk -f itf.awk $f >itf.$d
+                       awk -f etf.awk $f >etf.$d
+                       awk -f ensemble.awk $f >ensemble.$d
+                       awk -f tdata.awk $f >tdata.$d
+               fi
+               rm -f $f
+       fi
+done
+
+#
+# Process clockstat files with S and generate PostScript plots
+#
+for f in itf etf ensemble tdata; do
+       for d in ${f}.199[4-9][0-1][0-9][0-3][0-9]; do
+               if [ -f $d ]; then
+                       if [ -f $S ]; then
+                               echo "file1<-"\"${d}\" >>$SIN
+                               echo "source("\"${f}.S\"")" >>$SIN
+                               echo "unix("\""rm ${d}"\"")" >>$SIN
+                       else
+                               rm -f $d
+                       fi
+               fi
+       done
+done
+if [ -f $SIN ]; then
+       $S BATCH $SIN $SOUT
+fi
diff --git a/scripts/stats/tdata.S b/scripts/stats/tdata.S
new file mode 100755 (executable)
index 0000000..f360a24
--- /dev/null
@@ -0,0 +1,5 @@
+tdata <- scan(file1, list(day=0, sec=0, m=0, w=0, x=0, y=0, z=0))
+str <- paste("eps/", file1, ".eps", sep="")
+postscript(str,  ,  ,  , 5, pointsize=18)
+par(mgp=c(1, 0, 0), tck=0.03, mar=c(2, 2, 1, 1))
+plot(tdata$sec, tdata$m, type="l", xlab=paste("MJD", tdata$day, "Time (s)"), ylab="LORAN-M SNR (dB)")
diff --git a/scripts/stats/tdata.awk b/scripts/stats/tdata.awk
new file mode 100755 (executable)
index 0000000..5be9c04
--- /dev/null
@@ -0,0 +1,45 @@
+# program to produce loran tdata statistics from clockstats files
+#
+# usage: awk -f tdata.awk clockstats
+#
+# format of input record (missing replaced by -40.0)
+# 49228 36.852 127.127.10.1 93:241:00:00:20.812 LORAN TDATA
+# M OK 0 0 1169.14 -7.4 3.16E-07 .424
+# W CV 0 0 3329.30 -16.4 1.81E-06 
+# X OK 0 0 1737.19 -10.5 3.44E-07 .358
+# Y OK 0 0 2182.07 -9.0 4.41E-07 .218
+#
+# format of output record (time in nanoseconds, signal values in dB)
+#  MJD      sec      time     M      W      X      Y      Z
+# 49228    36.852   175.0   -7.4  -16.4  -10.5   -9.0
+#
+# select LORAN TDATA records with valid format
+{
+       if (NF >= 7 && $6 == "TDATA") {
+               m = w = x = y = z = -40.0
+               for (i = 7; i < NF - 5; i++) {
+                       if ($i == "M" && $(i+1) == "OK") {
+                               i += 5
+                               m = $i
+                       }
+                       else if ($i == "W" && $(i+1) == "OK") {
+                               i += 5
+                               w = $i
+                       }
+                       else if ($i == "X" && $(i+1) == "OK") {
+                               i += 5
+                               x = $i
+                       }
+                       else if ($i == "Y" && $(i+1) == "OK") {
+                               i += 5
+                               y = $i
+                       }
+                       else if ($i == "Z" && $(i+1) == "OK") {
+                               i += 5
+                               z = $i
+                       }
+                }
+               printf "%5s %9.3f %6.1f %6.1f %6.1f %6.1f %6.1f\n", $1, $2, m, w, x, y, z
+       }
+}
+
diff --git a/scripts/summary.in b/scripts/summary.in
new file mode 100644 (file)
index 0000000..515dfc6
--- /dev/null
@@ -0,0 +1,373 @@
+#! @PATH_PERL@ -w
+# $Id$
+# Perl version of (summary.sh, loop.awk, peer.awk):
+# Create summaries from xntpd's loop and peer statistics.
+#
+# Copyright (c) 1997, 1999 by Ulrich Windl <Ulrich.Windl@rz.uni-regensburg.de>
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+require 5.003; # "never tested with any other version of Perl"
+use strict;
+
+use Getopt::Long;
+
+my $log_date_pattern = '[12]\d{3}[01]\d[0-3]\d';
+my $statsdir = "/var/log/ntp";         # directory with input files
+my $outputdir = "/tmp";                        # directory for output files
+my $skip_time_steps = 3600.0;          # ignore time offsets larger that this
+my $startdate = "19700101";            # first data file to use (YYYYMMDD)
+my $enddate=`date -u +%Y%m%d`; chomp $enddate; --$enddate;
+my $peer_dist_limit = 400.0;
+
+my %options = ("directory|input-directory=s" => \$statsdir,
+              "output-directory=s" => \$outputdir,
+              "skip-time-steps:f" => \$skip_time_steps,
+              "start-date=s" => \$startdate,
+              "end-date=s" => \$enddate,
+              "peer-dist-limit=f" => \$peer_dist_limit);
+
+if ( !GetOptions(%options) )
+{
+    print STDERR "valid options for $0 are:\n";
+    my $opt;
+    foreach $opt (sort(keys %options)) {
+       print STDERR "\t--$opt\t(default is ";
+       if ( ref($options{$opt}) eq "ARRAY" ) {
+           print STDERR join(", ",  map { "'$_'" } @{$options{$opt}});
+       } else {
+           print STDERR "'${$options{$opt}}'";
+       }
+       print STDERR ")\n";
+    }
+    print STDERR "\n";
+    die;
+}
+
+# check possibly current values of options
+die "$statsdir: no such directory" unless (-d $statsdir);
+die "$outputdir: no such directory" unless (-d $outputdir);
+die "$skip_time_steps: skip-time-steps must be positive"
+    unless ($skip_time_steps >= 0.0);
+die "$startdate: invalid start date|$`|$&|$'"
+    unless ($startdate =~ m/.*$log_date_pattern$/);
+die "$enddate: invalid end date"
+    unless ($enddate =~ m/.*$log_date_pattern$/);
+
+$skip_time_steps = 0.128 if ($skip_time_steps == 0);
+
+sub min
+{
+    my ($result, @rest) = @_;
+    map { $result = $_ if ($_ < $result) } @rest;
+    return($result);
+}
+
+sub max
+{
+    my ($result, @rest) = @_;
+    map { $result = $_ if ($_ > $result) } @rest;
+    return($result);
+}
+
+# calculate mean, range, and standard deviation for offset and frequency
+sub do_loop
+{
+    my ($directory, $fname, $out_file) = @_;
+    print "$directory/$fname\n";
+    open INPUT, "$directory/$fname" or warn "can't open $directory/$fname: $!";
+    open OUTPUT, ">>$out_file" or die "can't open $out_file: $!";
+    print OUTPUT "$fname\n";
+    my ($loop_tmax, $loop_fmax) = (-1e9, -1e9);
+    my ($loop_tmin, $loop_fmin) = (1e9, 1e9);
+    my ($loop_time_rms, $loop_freq_rms) = (0, 0);
+    my $loop_count = 0;
+    my $loop_time = 0;
+    my $loop_freq = 0;
+    my ($freq, $offs);
+    my @Fld;
+    while (<INPUT>) {
+       chop;   # strip record separator
+       @Fld = split;
+       next if ($#Fld < 4);
+#NTPv3: 50529 74356.259 -0.000112 16.1230 8
+#NTPv3: day, sec.msec, offset, drift_comp, sys_poll
+#NTPv4: 51333 54734.582 0.000001648 16.981964 0.000001094 0.020938 6
+#NTPv4: day, sec.msec, offset, drift_comp, sys_error, clock_stabil, sys_poll
+       if ($Fld[2] > $skip_time_steps || $Fld[2] < -$skip_time_steps) {
+           warn "ignoring loop offset $Fld[2] (file $fname, line $.)\n";
+           next
+       }
+       $loop_count++;
+       ($offs, $freq) = ($Fld[2], $Fld[3]);
+       $loop_tmax = max($loop_tmax, $offs);
+       $loop_tmin = min($loop_tmin, $offs);
+       $loop_fmax = max($loop_fmax, $freq);
+       $loop_fmin = min($loop_fmin, $freq);
+       $loop_time += $offs;
+       $loop_time_rms += $offs * $offs;
+       $loop_freq += $freq;
+       $loop_freq_rms += $freq * $freq;
+    }
+    close INPUT;
+    if ($loop_count > 1) {
+       $loop_time /= $loop_count;
+       $loop_time_rms = $loop_time_rms / $loop_count - $loop_time * $loop_time;
+       if ($loop_time_rms < 0) {
+           warn "loop_time_rms: $loop_time_rms < 0";
+           $loop_time_rms = 0;
+       }
+       $loop_time_rms = sqrt($loop_time_rms);
+       $loop_freq /= $loop_count;
+       $loop_freq_rms = $loop_freq_rms / $loop_count - $loop_freq * $loop_freq;
+       if ($loop_freq_rms < 0) {
+           warn "loop_freq_rms: $loop_freq_rms < 0";
+           $loop_freq_rms = 0;
+       }
+       $loop_freq_rms = sqrt($loop_freq_rms);
+       printf OUTPUT
+           ("loop %d, %.0f+/-%.1f, rms %.1f, freq %.2f+/-%0.3f, var %.3f\n",
+            $loop_count, ($loop_tmax + $loop_tmin) / 2 * 1e6,
+            ($loop_tmax - $loop_tmin) / 2 * 1e6, $loop_time_rms * 1e6,
+            ($loop_fmax + $loop_fmin) / 2, ($loop_fmax - $loop_fmin) / 2,
+            $loop_freq_rms);
+    }
+    else {
+       warn "no valid lines in $directory/$fname";
+    }
+    close OUTPUT
+}
+
+# calculate mean, standard deviation, maximum offset, mean dispersion,
+# and maximum distance for each peer
+sub do_peer
+{
+    my ($directory, $fname, $out_file) = @_;
+    print "$directory/$fname\n";
+    open INPUT, "$directory/$fname" or warn "can't open $directory/$fname: $!";
+    open OUTPUT, ">>$out_file" or die "can't open $out_file: $!";
+    print OUTPUT "$fname\n";
+# we toss out all distances greater than one second on the assumption the
+# peer is in initial acquisition
+    my ($n, $MAXDISTANCE) = (0, 1.0);
+    my %peer_time;
+    my %peer_time_rms;
+    my %peer_count;
+    my %peer_delay;
+    my %peer_disp;
+    my %peer_dist;
+    my %peer_ident;
+    my %peer_tmin;
+    my %peer_tmax;
+    my @Fld;
+    my ($i, $j);
+    my ($dist, $offs);
+    while (<INPUT>) {
+       chop;   # strip record separator
+       @Fld = split;
+       next if ($#Fld < 6);
+#NTPv3: 50529 83316.249 127.127.8.1 9674 0.008628 0.00000 0.00700
+#NTPv3: day, sec.msec, addr, status, offset, delay, dispersion
+#NTPv4: 51333 56042.037 127.127.8.1 94f5 -0.000014657 0.000000000 0.000000000 0.000013214
+#NTPv4: day, sec.msec, addr, status, offset, delay, dispersion, skew
+
+       $dist = $Fld[6] + $Fld[5] / 2;
+       next if ($dist > $MAXDISTANCE);
+       $offs = $Fld[4];
+       if ($offs > $skip_time_steps || $offs < -$skip_time_steps) {
+           warn "ignoring peer offset $offs (file $fname, line $.)\n";
+           next
+       }
+       $i = $n;
+       for ($j = 0; $j < $n; $j++) {
+           if ($Fld[2] eq $peer_ident{$j}) {
+               $i = $j;                # peer found
+               last;
+           }
+       }
+       if ($i == $n) {         # add new peer
+           $peer_ident{$i} = $Fld[2];
+           $peer_tmax{$i} = $peer_dist{$i} = -1e9;
+           $peer_tmin{$i} = 1e9;
+           $peer_time{$i} = $peer_time_rms{$i} = 0;
+           $peer_delay{$i} = $peer_disp{$i} = 0;
+           $peer_count{$i} = 0;
+           $n++;
+       }
+       $peer_count{$i}++;
+       $peer_tmax{$i} = max($peer_tmax{$i}, $offs);
+       $peer_tmin{$i} = min($peer_tmin{$i}, $offs);
+       $peer_dist{$i} = max($peer_dist{$i}, $dist);
+       $peer_time{$i} += $offs;
+       $peer_time_rms{$i} += $offs * $offs;
+       $peer_delay{$i} += $Fld[5];
+       $peer_disp{$i} += $Fld[6];
+    }
+    close INPUT;
+    print OUTPUT
+"       ident     cnt     mean     rms      max     delay     dist     disp\n";
+    print OUTPUT
+"==========================================================================\n";
+    my @lines = ();
+    for ($i = 0; $i < $n; $i++) {
+       next if $peer_count{$i} < 2;
+       $peer_time{$i} /= $peer_count{$i};
+       eval { $peer_time_rms{$i} = sqrt($peer_time_rms{$i} / $peer_count{$i} -
+                                        $peer_time{$i} * $peer_time{$i}); };
+       $peer_time_rms{$i} = 0, warn $@ if $@;
+       $peer_delay{$i} /= $peer_count{$i};
+       $peer_disp{$i} /= $peer_count{$i};
+       $peer_tmax{$i} = $peer_tmax{$i} - $peer_time{$i};
+       $peer_tmin{$i} = $peer_time{$i} - $peer_tmin{$i};
+       if ($peer_tmin{$i} > $peer_tmax{$i}) {  # can this happen at all?
+           $peer_tmax{$i} = $peer_tmin{$i};
+       }
+       push @lines, sprintf
+           "%-15s %4d %8.3f %8.3f %8.3f %8.3f %8.3f %8.3f\n",
+           $peer_ident{$i}, $peer_count{$i}, $peer_time{$i} * 1e3,
+           $peer_time_rms{$i} * 1e3, $peer_tmax{$i} * 1e3,
+           $peer_delay{$i} * 1e3, $peer_dist{$i} * 1e3, $peer_disp{$i} * 1e3;
+    }
+    print OUTPUT sort @lines;
+    close OUTPUT;
+}
+
+sub do_clock
+{
+    my ($directory, $fname, $out_file) = @_;
+    print "$directory/$fname\n";
+    open INPUT, "$directory/$fname";
+    open OUTPUT, ">>$out_file" or die "can't open $out_file: $!";
+    print OUTPUT "$fname\n";
+    close INPUT;
+    close OUTPUT;
+}
+
+sub peer_summary
+{
+    my $in_file = shift;
+    my ($i, $j, $n);
+    my (%peer_ident, %peer_count, %peer_mean, %peer_var, %peer_max);
+    my (%peer_1, %peer_2, %peer_3, %peer_4);
+    my $dist;
+    my $max;
+    open INPUT, "<$in_file" or die "can't open $in_file: $!";
+    my @Fld;
+    $n = 0;
+    while (<INPUT>) {
+       chop;   # strip record separator
+       @Fld = split;
+       next if ($#Fld < 7 || $Fld[0] eq 'ident');
+       $i = $n;
+       for ($j = 0; $j < $n; $j++) {
+           if ($Fld[0] eq $peer_ident{$j}) {
+               $i = $j;
+               last;                   # peer found
+           }
+       }
+       if ($i == $n) {                 # add new peer
+           $peer_count{$i} = $peer_mean{$i} = $peer_var{$i} = 0;
+           $peer_max{$i} = 0;
+           $peer_1{$i} = $peer_2{$i} = $peer_3{$i} = $peer_4{$i} = 0;
+           $peer_ident{$i} = $Fld[0];
+           ++$n;
+       }
+       $dist = $Fld[6] - $Fld[5] / 2;
+       if ($dist < $peer_dist_limit) {
+           $peer_count{$i}++;
+           $peer_mean{$i} += $Fld[2];
+           $peer_var{$i} += $Fld[3] * $Fld[3];
+           $max = $Fld[4];
+           $peer_max{$i} = max($peer_max{$i}, $max);
+           if ($max > 1) {
+               $peer_1{$i}++;
+               if ($max > 5) {
+                   $peer_2{$i}++;
+                   if ($max > 10) {
+                       $peer_3{$i}++;
+                       if ($max > 50) {
+                           $peer_4{$i}++;
+                       }
+                   }
+               }
+           }
+       }
+       else {
+           warn "dist exceeds limit: $dist (file $in_file, line $.)\n";
+       }
+    }
+    close INPUT;
+    my @lines = ();
+    print
+       "       host     days    mean       rms       max   >1  >5 >10 >50\n";
+    print
+       "==================================================================\n";
+    for ($i = 0; $i < $n; $i++) {
+       next if ($peer_count{$i} < 2);
+       $peer_mean{$i} /= $peer_count{$i};
+       eval { $peer_var{$i} = sqrt($peer_var{$i} / $peer_count{$i} -
+                                   $peer_mean{$i} * $peer_mean{$i}); };
+       $peer_var{$i} = 0, warn $@ if $@;
+       push @lines, sprintf
+           "%-15s %3d %9.3f% 9.3f %9.3f %3d %3d %3d %3d\n",
+           $peer_ident{$i}, $peer_count{$i}, $peer_mean{$i}, $peer_var{$i},
+           $peer_max{$i}, $peer_1{$i}, $peer_2{$i}, $peer_3{$i}, $peer_4{$i};
+    }
+    print sort @lines;
+}
+
+my $loop_summary="$outputdir/loop_summary";
+my $peer_summary="$outputdir/peer_summary";
+my $clock_summary="$outputdir/clock_summary";
+my (@loopfiles, @peerfiles, @clockfiles);
+
+print STDERR "Creating summaries from $statsdir ($startdate to $enddate)\n";
+
+opendir SDIR, $statsdir or die "directory ${statsdir}: $!";
+rewinddir SDIR;
+@loopfiles=sort grep /loop.*$log_date_pattern/, readdir SDIR;
+rewinddir SDIR;
+@peerfiles=sort grep /peer.*$log_date_pattern/, readdir SDIR;
+rewinddir SDIR;
+@clockfiles=sort grep /clock.*$log_date_pattern/, readdir SDIR;
+closedir SDIR;
+
+# remove old summary files
+map { unlink $_ if -f $_ } ($loop_summary, $peer_summary, $clock_summary);
+
+my $date;
+map {
+    $date = $_; $date =~ s/.*($log_date_pattern)$/$1/;
+    if ($date ge $startdate && $date le $enddate) {
+       do_loop $statsdir, $_, $loop_summary;
+    }
+} @loopfiles;
+
+map {
+    $date = $_; $date =~ s/.*($log_date_pattern)$/$1/;
+    if ($date ge $startdate && $date le $enddate) {
+       do_peer $statsdir, $_, $peer_summary;
+    }
+} @peerfiles;
+
+map {
+    $date = $_; $date =~ s/.*($log_date_pattern)$/$1/;
+    if ($date ge $startdate && $date le $enddate) {
+       do_clock $statsdir, $_, $clock_summary;
+    }
+} @clockfiles;
+
+print STDERR "Creating peer summary with limit $peer_dist_limit\n";
+peer_summary $peer_summary if (-f $peer_summary);
diff --git a/sntp/COPYRIGHT b/sntp/COPYRIGHT
new file mode 100644 (file)
index 0000000..c4f6f5d
--- /dev/null
@@ -0,0 +1,80 @@
+        General Public Licence for the software known as MSNTP
+        ------------------------------------------------------
+
+         (c) Copyright, N.M. Maclaren, 1996, 1997, 2000
+         (c) Copyright, University of Cambridge, 1996, 1997, 2000
+
+
+
+Free use of MSNTP in source and binary forms is permitted, provided that this
+entire licence is duplicated in all copies, and that any documentation,
+announcements, and other materials related to use acknowledge that the software
+was developed by N.M. Maclaren (hereafter refered to as the Author) at the
+University of Cambridge.  Neither the name of the Author nor the University of
+Cambridge may be used to endorse or promote products derived from this material
+without specific prior written permission.
+
+The Author and the University of Cambridge retain the copyright and all other
+legal rights to the software and make it available non-exclusively.  All users
+must ensure that the software in all its derivations carries a copyright notice
+in the form:
+         (c) Copyright N.M. Maclaren,
+         (c) Copyright University of Cambridge.
+
+
+
+                           NO WARRANTY
+
+Because the MSNTP software is licensed free of charge, the Author and the
+University of Cambridge provide absolutely no warranty, either expressed or
+implied, including, but not limited to, the implied warranties of
+merchantability and fitness for a particular purpose.  The entire risk as to
+the quality and performance of the MSNTP software is with you.  Should MSNTP
+prove defective, you assume the cost of all necessary servicing or repair.
+
+In no event, unless required by law, will the Author or the University of
+Cambridge, or any other party who may modify and redistribute this software as
+permitted in accordance with the provisions below, be liable for damages for
+any losses whatsoever, including but not limited to lost profits, lost monies,
+lost or corrupted data, or other special, incidental or consequential losses
+that may arise out of the use or inability to use the MSNTP software.
+
+
+
+                         COPYING POLICY
+
+Permission is hereby granted for copying and distribution of copies of the
+MSNTP source and binary files, and of any part thereof, subject to the
+following licence conditions:
+
+1. You may distribute MSNTP or components of MSNTP, with or without additions
+developed by you or by others.  No charge, other than an "at-cost" distribution
+fee, may be charged for copies, derivations, or distributions of this material
+without the express written consent of the copyright holders.
+
+2. You may also distribute MSNTP along with any other product for sale,
+provided that the cost of the bundled package is the same regardless of whether
+MSNTP is included or not, and provided that those interested only in MSNTP must
+be notified that it is a product freely available from the University of
+Cambridge.
+
+3. If you distribute MSNTP software or parts of MSNTP, with or without
+additions developed by you or others, then you must either make available the
+source to all portions of the MSNTP system (exclusive of any additions made by
+you or by others) upon request, or instead you may notify anyone requesting
+source that it is freely available from the University of Cambridge.
+
+4. You may not omit any of the copyright notices on either the source files,
+the executable files, or the documentation.
+
+5. You may not omit transmission of this License agreement with whatever
+portions of MSNTP that are distributed.
+
+6. Any users of this software must be notified that it is without warranty or
+guarantee of any nature, express or implied, nor is there any fitness for use
+represented.
+
+
+October 1996
+April 1997
+October 2000
diff --git a/sntp/Makefile.am b/sntp/Makefile.am
new file mode 100644 (file)
index 0000000..1bee65d
--- /dev/null
@@ -0,0 +1,77 @@
+# Makefile.am, by Harlan Stenn, from:
+# Makefile for sntp
+# N.M. Maclaren, October 2000.
+
+AUTOMAKE_OPTIONS = foreign
+ACLOCAL_AMFLAGS= -I libopts/m4
+
+AM_CPPFLAGS=   $(LIBOPTS_CFLAGS)
+LDADD= $(LIBOPTS_LDADD)
+
+NULL=
+
+bindir=        ${exec_prefix}/${BINSUBDIR}
+bin_PROGRAMS=  sntp
+#run_ag=         cd $(srcdir) && autogen --writable -L $(top_srcdir)/include
+run_ag=         cd $(srcdir) && autogen --writable
+
+SUBDIRS=
+if NEED_LIBOPTS
+SUBDIRS+= libopts
+endif
+SUBDIRS+= .
+
+sntp_SOURCES = \
+       header.h \
+       internet.c \
+       internet.h \
+       kludges.h \
+       main.c \
+       sntp-opts.c \
+       sntp-opts.h \
+       socket.c \
+       timing.c \
+       unix.c \
+       $(NULL)
+
+dist_man_MANS= sntp.1
+
+EXTRA_DIST=    bincheck.mf     \
+               COPYRIGHT       \
+               sntp-opts.def sntp.1 sntp-opts.texi sntp-opts.menu      \
+               autogen-version.def version.def
+BUILT_SOURCES= check-autogen-version.def check-version.def     \
+               sntp-opts.c sntp-opts.h sntp.1 sntp-opts.texi sntp-opts.menu
+man_MANS=      sntp.1
+
+
+FRC:
+check-autogen-version.def: FRC
+       @cd $(srcdir)                                                   \
+       && test -r ../include/autogen-version.def                       \
+       && ( if cmp -s ../include/autogen-version.def autogen-version.def; \
+          then : ;                                                     \
+          else cp ../include/autogen-version.def autogen-version.def;   \
+               echo "Installing new sntp/autogen-version.def file";    \
+          fi )
+
+check-version.def: FRC
+       @cd $(srcdir)                                   \
+       && test -r ../include/version.def               \
+       && ( if cmp -s ../include/version.def version.def;      \
+          then : ;                                             \
+          else cp ../include/version.def version.def;          \
+               echo "Installing new sntp/version.def file";    \
+          fi )
+
+$(srcdir)/sntp-opts.h: $(srcdir)/sntp-opts.c
+$(srcdir)/sntp-opts.c: $(srcdir)/sntp-opts.def $(srcdir)/version.def
+       $(run_ag) sntp-opts.def
+
+$(srcdir)/sntp.1: $(srcdir)/sntp-opts.def $(srcdir)/version.def
+       $(run_ag) -Tagman1.tpl -bsntp sntp-opts.def
+
+$(srcdir)/sntp-opts.texi $(srcdir)/sntp-opts.menu: $(srcdir)/sntp-opts.def $(srcdir)/version.def
+       $(run_ag) -Taginfo.tpl -DLEVEL=section sntp-opts.def
+
+include bincheck.mf
diff --git a/sntp/Makefile.in b/sntp/Makefile.in
new file mode 100644 (file)
index 0000000..62acb87
--- /dev/null
@@ -0,0 +1,984 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+# Makefile.am, by Harlan Stenn, from:
+# Makefile for sntp
+# N.M. Maclaren, October 2000.
+
+# we traditionally installed software in bindir, while it should have gone
+# in sbindir.  Now that we offer a choice, look in the "other" installation
+# subdir to warn folks if there is another version there.
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+bin_PROGRAMS = sntp$(EXEEXT)
+@NEED_LIBOPTS_TRUE@am__append_1 = libopts
+DIST_COMMON = README $(am__configure_deps) $(dist_man_MANS) \
+       $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       $(srcdir)/bincheck.mf $(srcdir)/config.h.in \
+       $(top_srcdir)/configure compile config.guess config.sub \
+       depcomp install-sh ltmain.sh missing
+subdir = .
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+am__CONFIG_DISTCLEAN_FILES = config.status config.cache config.log \
+ configure.lineno config.status.lineno
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
+PROGRAMS = $(bin_PROGRAMS)
+am__objects_1 =
+am_sntp_OBJECTS = internet.$(OBJEXT) main.$(OBJEXT) \
+       sntp-opts.$(OBJEXT) socket.$(OBJEXT) timing.$(OBJEXT) \
+       unix.$(OBJEXT) $(am__objects_1)
+sntp_OBJECTS = $(am_sntp_OBJECTS)
+sntp_LDADD = $(LDADD)
+am__DEPENDENCIES_1 =
+sntp_DEPENDENCIES = $(am__DEPENDENCIES_1)
+DEFAULT_INCLUDES = -I.@am__isrc@
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(sntp_SOURCES)
+DIST_SOURCES = $(sntp_SOURCES)
+RECURSIVE_TARGETS = all-recursive check-recursive dvi-recursive \
+       html-recursive info-recursive install-data-recursive \
+       install-dvi-recursive install-exec-recursive \
+       install-html-recursive install-info-recursive \
+       install-pdf-recursive install-ps-recursive install-recursive \
+       installcheck-recursive installdirs-recursive pdf-recursive \
+       ps-recursive uninstall-recursive
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+man1dir = $(mandir)/man1
+NROFF = nroff
+MANS = $(dist_man_MANS) $(man_MANS)
+RECURSIVE_CLEAN_TARGETS = mostlyclean-recursive clean-recursive        \
+  distclean-recursive maintainer-clean-recursive
+AM_RECURSIVE_TARGETS = $(RECURSIVE_TARGETS:-recursive=) \
+       $(RECURSIVE_CLEAN_TARGETS:-recursive=) tags TAGS ctags CTAGS \
+       distdir dist dist-all distcheck
+ETAGS = etags
+CTAGS = ctags
+DIST_SUBDIRS = libopts .
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+distdir = $(PACKAGE)-$(VERSION)
+top_distdir = $(distdir)
+am__remove_distdir = \
+  { test ! -d "$(distdir)" \
+    || { find "$(distdir)" -type d ! -perm -200 -exec chmod u+w {} ';' \
+         && rm -fr "$(distdir)"; }; }
+am__relativize = \
+  dir0=`pwd`; \
+  sed_first='s,^\([^/]*\)/.*$$,\1,'; \
+  sed_rest='s,^[^/]*/*,,'; \
+  sed_last='s,^.*/\([^/]*\)$$,\1,'; \
+  sed_butlast='s,/*[^/]*$$,,'; \
+  while test -n "$$dir1"; do \
+    first=`echo "$$dir1" | sed -e "$$sed_first"`; \
+    if test "$$first" != "."; then \
+      if test "$$first" = ".."; then \
+        dir2=`echo "$$dir0" | sed -e "$$sed_last"`/"$$dir2"; \
+        dir0=`echo "$$dir0" | sed -e "$$sed_butlast"`; \
+      else \
+        first2=`echo "$$dir2" | sed -e "$$sed_first"`; \
+        if test "$$first2" = "$$first"; then \
+          dir2=`echo "$$dir2" | sed -e "$$sed_rest"`; \
+        else \
+          dir2="../$$dir2"; \
+        fi; \
+        dir0="$$dir0"/"$$first"; \
+      fi; \
+    fi; \
+    dir1=`echo "$$dir1" | sed -e "$$sed_rest"`; \
+  done; \
+  reldir="$$dir2"
+DIST_ARCHIVES = $(distdir).tar.gz
+GZIP_ENV = --best
+distuninstallcheck_listfiles = find . -type f -print
+distcleancheck_listfiles = find . -type f -print
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = ${exec_prefix}/${BINSUBDIR}
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+AUTOMAKE_OPTIONS = foreign
+ACLOCAL_AMFLAGS = -I libopts/m4
+AM_CPPFLAGS = $(LIBOPTS_CFLAGS)
+LDADD = $(LIBOPTS_LDADD)
+NULL = 
+#run_ag=         cd $(srcdir) && autogen --writable -L $(top_srcdir)/include
+run_ag = cd $(srcdir) && autogen --writable
+SUBDIRS = $(am__append_1) .
+sntp_SOURCES = \
+       header.h \
+       internet.c \
+       internet.h \
+       kludges.h \
+       main.c \
+       sntp-opts.c \
+       sntp-opts.h \
+       socket.c \
+       timing.c \
+       unix.c \
+       $(NULL)
+
+dist_man_MANS = sntp.1
+EXTRA_DIST = bincheck.mf       \
+               COPYRIGHT       \
+               sntp-opts.def sntp.1 sntp-opts.texi sntp-opts.menu      \
+               autogen-version.def version.def
+
+BUILT_SOURCES = check-autogen-version.def check-version.def    \
+               sntp-opts.c sntp-opts.h sntp.1 sntp-opts.texi sntp-opts.menu
+
+man_MANS = sntp.1
+all: $(BUILT_SOURCES) config.h
+       $(MAKE) $(AM_MAKEFLAGS) all-recursive
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+am--refresh:
+       @:
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am $(srcdir)/bincheck.mf $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             echo ' cd $(srcdir) && $(AUTOMAKE) --foreign'; \
+             $(am__cd) $(srcdir) && $(AUTOMAKE) --foreign \
+               && exit 0; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           echo ' $(SHELL) ./config.status'; \
+           $(SHELL) ./config.status;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       $(SHELL) ./config.status --recheck
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       $(am__cd) $(srcdir) && $(AUTOCONF)
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       $(am__cd) $(srcdir) && $(ACLOCAL) $(ACLOCAL_AMFLAGS)
+$(am__aclocal_m4_deps):
+
+config.h: stamp-h1
+       @if test ! -f $@; then \
+         rm -f stamp-h1; \
+         $(MAKE) $(AM_MAKEFLAGS) stamp-h1; \
+       else :; fi
+
+stamp-h1: $(srcdir)/config.h.in $(top_builddir)/config.status
+       @rm -f stamp-h1
+       cd $(top_builddir) && $(SHELL) ./config.status config.h
+$(srcdir)/config.h.in:  $(am__configure_deps) 
+       ($(am__cd) $(top_srcdir) && $(AUTOHEADER))
+       rm -f stamp-h1
+       touch $@
+
+distclean-hdr:
+       -rm -f config.h stamp-h1
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p || test -f $$p1; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+           echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+           $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+       @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+sntp$(EXEEXT): $(sntp_OBJECTS) $(sntp_DEPENDENCIES) 
+       @rm -f sntp$(EXEEXT)
+       $(LINK) $(sntp_OBJECTS) $(sntp_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/internet.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/main.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sntp-opts.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/socket.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timing.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unix.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+
+distclean-libtool:
+       -rm -f libtool config.lt
+install-man1: $(dist_man_MANS) $(man_MANS)
+       @$(NORMAL_INSTALL)
+       test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+       @list=''; test -n "$(man1dir)" || exit 0; \
+       { for i in $$list; do echo "$$i"; done; \
+       l2='$(dist_man_MANS) $(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.1[a-z]*$$/p'; \
+       } | while read p; do \
+         if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; echo "$$p"; \
+       done | \
+       sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+       sed 'N;N;s,\n, ,g' | { \
+       list=; while read file base inst; do \
+         if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+         fi; \
+       done; \
+       for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+       while read files; do \
+         test -z "$$files" || { \
+           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+           $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+       done; }
+
+uninstall-man1:
+       @$(NORMAL_UNINSTALL)
+       @list=''; test -n "$(man1dir)" || exit 0; \
+       files=`{ for i in $$list; do echo "$$i"; done; \
+       l2='$(dist_man_MANS) $(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.1[a-z]*$$/p'; \
+       } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
+
+# This directory's subdirectories are mostly independent; you can cd
+# into them and run `make' without going through this Makefile.
+# To change the values of `make' variables: instead of editing Makefiles,
+# (1) if the variable is set in `config.status', edit `config.status'
+#     (which will cause the Makefiles to be regenerated when you run `make');
+# (2) otherwise, pass the desired values on the `make' command line.
+$(RECURSIVE_TARGETS):
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       target=`echo $@ | sed s/-recursive//`; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           dot_seen=yes; \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done; \
+       if test "$$dot_seen" = "no"; then \
+         $(MAKE) $(AM_MAKEFLAGS) "$$target-am" || exit 1; \
+       fi; test -z "$$fail"
+
+$(RECURSIVE_CLEAN_TARGETS):
+       @failcom='exit 1'; \
+       for f in x $$MAKEFLAGS; do \
+         case $$f in \
+           *=* | --[!k]*);; \
+           *k*) failcom='fail=yes';; \
+         esac; \
+       done; \
+       dot_seen=no; \
+       case "$@" in \
+         distclean-* | maintainer-clean-*) list='$(DIST_SUBDIRS)' ;; \
+         *) list='$(SUBDIRS)' ;; \
+       esac; \
+       rev=''; for subdir in $$list; do \
+         if test "$$subdir" = "."; then :; else \
+           rev="$$subdir $$rev"; \
+         fi; \
+       done; \
+       rev="$$rev ."; \
+       target=`echo $@ | sed s/-recursive//`; \
+       for subdir in $$rev; do \
+         echo "Making $$target in $$subdir"; \
+         if test "$$subdir" = "."; then \
+           local_target="$$target-am"; \
+         else \
+           local_target="$$target"; \
+         fi; \
+         ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) $$local_target) \
+         || eval $$failcom; \
+       done && test -z "$$fail"
+tags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) tags); \
+       done
+ctags-recursive:
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         test "$$subdir" = . || ($(am__cd) $$subdir && $(MAKE) $(AM_MAKEFLAGS) ctags); \
+       done
+
+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: tags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       set x; \
+       here=`pwd`; \
+       if ($(ETAGS) --etags-include --version) >/dev/null 2>&1; then \
+         include_option=--etags-include; \
+         empty_fix=.; \
+       else \
+         include_option=--include; \
+         empty_fix=; \
+       fi; \
+       list='$(SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test ! -f $$subdir/TAGS || \
+             set "$$@" "$$include_option=$$here/$$subdir/TAGS"; \
+         fi; \
+       done; \
+       list='$(SOURCES) $(HEADERS) config.h.in $(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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$unique; \
+         fi; \
+       fi
+ctags: CTAGS
+CTAGS: ctags-recursive $(HEADERS) $(SOURCES) config.h.in $(TAGS_DEPENDENCIES) \
+               $(TAGS_FILES) $(LISP)
+       list='$(SOURCES) $(HEADERS) config.h.in $(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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @list='$(MANS)'; if test -n "$$list"; then \
+         list=`for p in $$list; do \
+           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+           if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+         if test -n "$$list" && \
+           grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+           echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+           grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/         /' >&2; \
+           echo "       to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+           echo "       typically \`make maintainer-clean' will remove them" >&2; \
+           exit 1; \
+         else :; fi; \
+       else :; fi
+       $(am__remove_distdir)
+       test -d "$(distdir)" || mkdir "$(distdir)"
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           test -d "$(distdir)/$$subdir" \
+           || $(MKDIR_P) "$(distdir)/$$subdir" \
+           || exit 1; \
+         fi; \
+       done
+       @list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+         if test "$$subdir" = .; then :; else \
+           dir1=$$subdir; dir2="$(distdir)/$$subdir"; \
+           $(am__relativize); \
+           new_distdir=$$reldir; \
+           dir1=$$subdir; dir2="$(top_distdir)"; \
+           $(am__relativize); \
+           new_top_distdir=$$reldir; \
+           echo " (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) top_distdir="$$new_top_distdir" distdir="$$new_distdir" \\"; \
+           echo "     am__remove_distdir=: am__skip_length_check=: am__skip_mode_fix=: distdir)"; \
+           ($(am__cd) $$subdir && \
+             $(MAKE) $(AM_MAKEFLAGS) \
+               top_distdir="$$new_top_distdir" \
+               distdir="$$new_distdir" \
+               am__remove_distdir=: \
+               am__skip_length_check=: \
+               am__skip_mode_fix=: \
+               distdir) \
+             || exit 1; \
+         fi; \
+       done
+       -test -n "$(am__skip_mode_fix)" \
+       || find "$(distdir)" -type d ! -perm -777 -exec chmod a+rwx {} \; -o \
+         ! -type d ! -perm -444 -links 1 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -400 -exec chmod a+r {} \; -o \
+         ! -type d ! -perm -444 -exec $(install_sh) -c -m a+r {} {} \; \
+       || chmod -R a+r "$(distdir)"
+dist-gzip: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+dist-bzip2: distdir
+       tardir=$(distdir) && $(am__tar) | bzip2 -9 -c >$(distdir).tar.bz2
+       $(am__remove_distdir)
+
+dist-lzma: distdir
+       tardir=$(distdir) && $(am__tar) | lzma -9 -c >$(distdir).tar.lzma
+       $(am__remove_distdir)
+
+dist-xz: distdir
+       tardir=$(distdir) && $(am__tar) | xz -c >$(distdir).tar.xz
+       $(am__remove_distdir)
+
+dist-tarZ: distdir
+       tardir=$(distdir) && $(am__tar) | compress -c >$(distdir).tar.Z
+       $(am__remove_distdir)
+
+dist-shar: distdir
+       shar $(distdir) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).shar.gz
+       $(am__remove_distdir)
+
+dist-zip: distdir
+       -rm -f $(distdir).zip
+       zip -rq $(distdir).zip $(distdir)
+       $(am__remove_distdir)
+
+dist dist-all: distdir
+       tardir=$(distdir) && $(am__tar) | GZIP=$(GZIP_ENV) gzip -c >$(distdir).tar.gz
+       $(am__remove_distdir)
+
+# This target untars the dist file and tries a VPATH configuration.  Then
+# it guarantees that the distribution is self-contained by making another
+# tarfile.
+distcheck: dist
+       case '$(DIST_ARCHIVES)' in \
+       *.tar.gz*) \
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).tar.gz | $(am__untar) ;;\
+       *.tar.bz2*) \
+         bunzip2 -c $(distdir).tar.bz2 | $(am__untar) ;;\
+       *.tar.lzma*) \
+         unlzma -c $(distdir).tar.lzma | $(am__untar) ;;\
+       *.tar.xz*) \
+         xz -dc $(distdir).tar.xz | $(am__untar) ;;\
+       *.tar.Z*) \
+         uncompress -c $(distdir).tar.Z | $(am__untar) ;;\
+       *.shar.gz*) \
+         GZIP=$(GZIP_ENV) gunzip -c $(distdir).shar.gz | unshar ;;\
+       *.zip*) \
+         unzip $(distdir).zip ;;\
+       esac
+       chmod -R a-w $(distdir); chmod a+w $(distdir)
+       mkdir $(distdir)/_build
+       mkdir $(distdir)/_inst
+       chmod a-w $(distdir)
+       test -d $(distdir)/_build || exit 0; \
+       dc_install_base=`$(am__cd) $(distdir)/_inst && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
+         && dc_destdir="$${TMPDIR-/tmp}/am-dc-$$$$/" \
+         && am__cwd=`pwd` \
+         && $(am__cd) $(distdir)/_build \
+         && ../configure --srcdir=.. --prefix="$$dc_install_base" \
+           $(DISTCHECK_CONFIGURE_FLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) \
+         && $(MAKE) $(AM_MAKEFLAGS) dvi \
+         && $(MAKE) $(AM_MAKEFLAGS) check \
+         && $(MAKE) $(AM_MAKEFLAGS) install \
+         && $(MAKE) $(AM_MAKEFLAGS) installcheck \
+         && $(MAKE) $(AM_MAKEFLAGS) uninstall \
+         && $(MAKE) $(AM_MAKEFLAGS) distuninstallcheck_dir="$$dc_install_base" \
+               distuninstallcheck \
+         && chmod -R a-w "$$dc_install_base" \
+         && ({ \
+              (cd ../.. && umask 077 && mkdir "$$dc_destdir") \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" install \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" uninstall \
+              && $(MAKE) $(AM_MAKEFLAGS) DESTDIR="$$dc_destdir" \
+                   distuninstallcheck_dir="$$dc_destdir" distuninstallcheck; \
+             } || { rm -rf "$$dc_destdir"; exit 1; }) \
+         && rm -rf "$$dc_destdir" \
+         && $(MAKE) $(AM_MAKEFLAGS) dist \
+         && rm -rf $(DIST_ARCHIVES) \
+         && $(MAKE) $(AM_MAKEFLAGS) distcleancheck \
+         && cd "$$am__cwd" \
+         || exit 1
+       $(am__remove_distdir)
+       @(echo "$(distdir) archives ready for distribution: "; \
+         list='$(DIST_ARCHIVES)'; for i in $$list; do echo $$i; done) | \
+         sed -e 1h -e 1s/./=/g -e 1p -e 1x -e '$$p' -e '$$x'
+distuninstallcheck:
+       @$(am__cd) '$(distuninstallcheck_dir)' \
+       && test `$(distuninstallcheck_listfiles) | wc -l` -le 1 \
+          || { echo "ERROR: files left after uninstall:" ; \
+               if test -n "$(DESTDIR)"; then \
+                 echo "  (check DESTDIR support)"; \
+               fi ; \
+               $(distuninstallcheck_listfiles) ; \
+               exit 1; } >&2
+distcleancheck: distclean
+       @if test '$(srcdir)' = . ; then \
+         echo "ERROR: distcleancheck can only run from a VPATH build" ; \
+         exit 1 ; \
+       fi
+       @test `$(distcleancheck_listfiles) | wc -l` -eq 0 \
+         || { echo "ERROR: files left in build directory after distclean:" ; \
+              $(distcleancheck_listfiles) ; \
+              exit 1; } >&2
+check-am: all-am
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-recursive
+all-am: Makefile $(PROGRAMS) $(MANS) config.h
+installdirs: installdirs-recursive
+installdirs-am:
+       for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-recursive
+install-exec: install-exec-recursive
+install-data: install-data-recursive
+uninstall: uninstall-recursive
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
+
+installcheck: installcheck-recursive
+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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+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-recursive
+
+clean-am: clean-binPROGRAMS clean-generic clean-libtool mostlyclean-am
+
+distclean: distclean-recursive
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-hdr distclean-libtool distclean-tags
+
+dvi: dvi-recursive
+
+dvi-am:
+
+html: html-recursive
+
+html-am:
+
+info: info-recursive
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-recursive
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+       @$(NORMAL_INSTALL)
+       $(MAKE) $(AM_MAKEFLAGS) install-exec-hook
+install-html: install-html-recursive
+
+install-html-am:
+
+install-info: install-info-recursive
+
+install-info-am:
+
+install-man: install-man1
+
+install-pdf: install-pdf-recursive
+
+install-pdf-am:
+
+install-ps: install-ps-recursive
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-recursive
+       -rm -f $(am__CONFIG_DISTCLEAN_FILES)
+       -rm -rf $(top_srcdir)/autom4te.cache
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-recursive
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-recursive
+
+pdf-am:
+
+ps: ps-recursive
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-man
+
+uninstall-man: uninstall-man1
+
+.MAKE: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) all check \
+       ctags-recursive install install-am install-exec-am \
+       install-strip tags-recursive
+
+.PHONY: $(RECURSIVE_CLEAN_TARGETS) $(RECURSIVE_TARGETS) CTAGS GTAGS \
+       all all-am am--refresh check check-am clean clean-binPROGRAMS \
+       clean-generic clean-libtool ctags ctags-recursive dist \
+       dist-all dist-bzip2 dist-gzip dist-lzma dist-shar dist-tarZ \
+       dist-xz dist-zip distcheck distclean distclean-compile \
+       distclean-generic distclean-hdr distclean-libtool \
+       distclean-tags distcleancheck distdir distuninstallcheck dvi \
+       dvi-am html html-am info info-am install install-am \
+       install-binPROGRAMS install-data install-data-am install-dvi \
+       install-dvi-am install-exec install-exec-am install-exec-hook \
+       install-html install-html-am install-info install-info-am \
+       install-man install-man1 install-pdf install-pdf-am install-ps \
+       install-ps-am install-strip installcheck installcheck-am \
+       installdirs installdirs-am maintainer-clean \
+       maintainer-clean-generic mostlyclean mostlyclean-compile \
+       mostlyclean-generic mostlyclean-libtool pdf pdf-am ps ps-am \
+       tags tags-recursive uninstall uninstall-am \
+       uninstall-binPROGRAMS uninstall-man uninstall-man1
+
+
+FRC:
+check-autogen-version.def: FRC
+       @cd $(srcdir)                                                   \
+       && test -r ../include/autogen-version.def                       \
+       && ( if cmp -s ../include/autogen-version.def autogen-version.def; \
+          then : ;                                                     \
+          else cp ../include/autogen-version.def autogen-version.def;   \
+               echo "Installing new sntp/autogen-version.def file";    \
+          fi )
+
+check-version.def: FRC
+       @cd $(srcdir)                                   \
+       && test -r ../include/version.def               \
+       && ( if cmp -s ../include/version.def version.def;      \
+          then : ;                                             \
+          else cp ../include/version.def version.def;          \
+               echo "Installing new sntp/version.def file";    \
+          fi )
+
+$(srcdir)/sntp-opts.h: $(srcdir)/sntp-opts.c
+$(srcdir)/sntp-opts.c: $(srcdir)/sntp-opts.def $(srcdir)/version.def
+       $(run_ag) sntp-opts.def
+
+$(srcdir)/sntp.1: $(srcdir)/sntp-opts.def $(srcdir)/version.def
+       $(run_ag) -Tagman1.tpl -bsntp sntp-opts.def
+
+$(srcdir)/sntp-opts.texi $(srcdir)/sntp-opts.menu: $(srcdir)/sntp-opts.def $(srcdir)/version.def
+       $(run_ag) -Taginfo.tpl -DLEVEL=section sntp-opts.def
+
+install-exec-hook:
+       @case ${BINSUBDIR} in                                   \
+        bin) ODIR=${exec_prefix}/sbin ;;                       \
+        sbin) ODIR=${exec_prefix}/bin ;;                       \
+       esac;                                                   \
+       test -z "${bin_PROGRAMS}${bin_SCRIPTS}"                 \
+       || for i in ${bin_PROGRAMS} ${bin_SCRIPTS} " "; do              \
+          test ! -f $$ODIR/$$i || echo "*** $$i is also in $$ODIR!";   \
+       done
+
+#
+
+# 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.
+.NOEXPORT:
diff --git a/sntp/README b/sntp/README
new file mode 100644 (file)
index 0000000..d7738e9
--- /dev/null
@@ -0,0 +1,536 @@
+SNTP (Simple Network Time Protocol Utility) - Version 1.6
+----------------------------------------------------------
+
+Please read the file Copyright first.  Also note that the file RFC2030.TXT is
+David Mills's copyright and not the author's - it is just a copy of the RFC
+that is available from so many Internet archives.
+
+RFC 1305 (Network Time Protocol - NTP) is an attempt to provide globally
+consistent timestamps in an extremely hostile environment; it is fiendishly
+complicated and an impressive piece of virtuosity.  RFC 2030 (Simple Network
+Time Protocol - SNTP) which supersedes RFC 1769 describes a subset of this that
+will give excellent accuracy in most environments encountered in practice; it
+uses only the obvious algorithms that have been used since time immemorial.
+
+WARNING: the text version of RFC 1305 is incomplete, and omits the tables that
+are in the Postscript version.  Unfortunately, these contain the only copy of
+some critical information.
+
+draft-mills-sntp-v4-00.txt is the next proposed revision of RFC 2030,
+and the current goal is to have this code implement that specification.
+
+SNTP Servers - Some Little-Known Facts
+--------------------------------------
+
+RFC 2030 states that SNTP clients should be used only at the lowest level,
+which is good practice.  It then states that SNTP servers should be used only
+at stratum 1 (i.e. top level), which is bizarre!  A far saner use of them would
+be for the very lowest level of server, exporting solely to local clients that
+do not themselves act as servers to ANY system (e.g. on a Netware server,
+exporting only to the PCs that it manages).
+
+[There is missing language in the previous paragraph.  SNTP is designed
+to be used in 2 cases: as a client at the lowest levels of the timing
+hierarchy, or as a server of last resort at stratum 1 when connected to
+a modem or radio clock.]
+
+[This is as far as I have updated this file as part of the upgrade.]
+
+If the NTP network were being run as a directed acyclic graph (i.e. using SNTP
+rather than full NTP), with a diameter of D links and a maximum error per link
+of E, the maximum synchronisation error would be D*E.  Reasonable figures for D
+and E are 5 and 0.1 seconds, so this would be adequate for most uses.  Note
+that the fact that the graph is acyclic is critical, which is one reason why
+SNTP client/servers must NEVER be embedded WITHIN an NTP network.
+
+The other reason is that inserting SNTP client/servers at a low stratum (but
+not the root) of an NTP network could easily break NTP!  See RFC 1305 for why,
+but don't expect the answer to stand out at you.  It would be easy to extend
+SNTP to a full-function client/server application, thus making it into a true
+alternative to ntp, but this incompatibility is why it MUST NOT be done.
+
+The above does not mean that the SNTP approach is unsatisfactory, but only that
+it is incompatible with full NTP.  The author would favour a complete SNTP
+network using the SNTP approach, and the statistical error reduction used in
+SNTP, but it actually addresses a slightly different problem from that
+addressed by NTP.  TANSTAAFL.
+
+FINAL WARNING: do NOT use this program to serve NTP requests from outside the
+systems that you manage.  If you do this, and manage to break the time
+synchronisation on other people's systems, you will be regarded very
+unfavourably.  Actually, this should be possible only if their NTP client is
+completely broken, because SNTP does its damnedest to declare its packets as
+the lowest form of NTP timestamp.
+
+
+
+SNTP and its Assumptions
+-------------------------
+
+SNTP is intended to be a straightforward SNTP daemon/utility that is easy to
+build on any reasonable Unix platform (and most near-Unix ones), whether or not
+it has ever been ported to them before.  It is intended to answer the following
+requirements, either by challenge and response or the less reliable broadcast
+method:
+
+    A simple command to run on Unix systems that will check the time
+    and optionally drift compared with a known, local and reliable NTP
+    time server.  No privilege is required just to read the time and
+    estimate the drift.
+
+    A client for Unix systems that will synchronise the time from a known,
+    local and reliable NTP time server.  This is probably the most common
+    one, and the need that caused the program to be written.
+
+    A server for Unix systems that are synchronised other than by NTP
+    methods and that need to synchronise other systems by NTP.  This is
+    the classroom of PCs with a central server scenario.  It is NOT
+    intended to work as a peer with true NTP servers, and won't.
+
+    A simple method by which two or more Unix systems can keep themselves
+    synchronised using what is becoming a standard protocol.  Yes, I know
+    that there are half-a-dozen other such methods.
+
+    A base for building non-Unix SNTP clients.  Some 3/4 of the code
+    (including all of the complicated algorithms and NTP packet handling)
+    should work, unchanged, on any system with an ANSI/ISO C compiler.
+
+There are full tracing facilities and a lot of paranoia in the code to check
+for bad packets (more than in ntp) which may need relaxing in the light of
+experience.  Unfortunately, RFC 1305 does not include a precise description of
+the data protocol, despite its length, and there are some internal
+inconsistencies and differences between it and RFC 2030 and ntp's behaviour.
+
+WARNING: SNTP has not been tested in conjunction with ntp broadcasts or ntp
+clients, as the ability to do so was not available to the author.  It is very
+unlikely that it won't work, but you should check.  Much of the paranoid code
+is only partially tested, too, because it is dealing with cases that are very
+hard to provoke.
+
+It assumes that the local network is tolerably secure and that any accessible
+NTP or SNTP servers are trustworthy.  It also makes no attempt to check that
+it has been installed and is being used correctly (e.g. at an appropriate
+priority) or that the changes it makes have the desired effect.  When you first 
+use it, you should both run it in display mode and use the date command as a
+cross-check.
+
+Furthermore, it does not attempt to solve all of the problems addressed by the
+NTP protocol and you should NOT use it if any of those problems are likely to
+cause you serious trouble.  If they are, bite the bullet and implement ntp, or
+buy a fancy time-server.
+
+
+Building SNTP
+-------------
+
+The contents of the distribution are:
+
+README        -    this file
+Copyright     -    the copyright notice and conditions of use
+Makefile      -    the makefile, with comments for several systems
+header.h      -    the main header (almost entirely portable)
+kludges.h     -    dirty kludges for difficult systems
+internet.h    -    a very small header for internet.c and socket.c
+main.c        -    most of the source (almost entirely portable)
+unix.c        -    just for isatty, sleep and locking
+internet.c    -    Internet host and service name lookup
+socket.c      -    the Berkeley socket code
+sntp.1        -    the man page
+RFC2030.TXT   -    the SNTPv4 specification
+
+All you SHOULD need to do is to uncomment the settings in file Makefile for
+your system or to add new ones.  But real life is not always so simple.  As
+POSIX does not yet define sub-second timers, Internet addressing facilities,
+sockets etc., the code has to rely on the facilities described in the
+ill-defined and non-standard 'X/Open' documents and the almost totally
+unspecified 'BSD' extensions.
+
+Most hacks should be limited to the compiler options (e.g. setting flags like
+_XOPEN_SOURCE), but perverse systems may need additions to kludges.h - please
+report them to the author.  See Makefile and kludges.h for documentation on
+the standard hacks - there only 6, and most are only for obsolete systems.
+But, generally, using the generic set of C options usually works with no
+further ado.
+
+
+Sick, Bizarre or non-Unix Systems
+---------------------------------
+
+A very few Unix systems and almost all non-Unix systems may need changes to the
+code, such as:
+
+    If the system doesn't have Berkeley sockets, you will need to replace
+    socket.c and possibly modify internet.h and internet.c.  All of the
+    systems for which the author needs this have Berkeley sockets.
+
+    NTP is supposedly an Internet protocol, but is not Internet specific.
+    For other types of network, you will need to replace internet.c and
+    probably modify internet.h.
+
+    If the system doesn't have gettimeofday or settimeofday, you will
+    need to modify timing.c.  If it doesn't have adjtime (e.g. HP-UX
+    on PA-RISC before 10.0), you can set -DADJTIME_MISSING and the code
+    will compile but the -a option will always give an error.
+
+    If the system has totally broken signal handling, the program will
+    hang or crash if it can't reach its name server or responses time
+    out.  You may be able to improve matters by hacking internet.c and
+    socket.c, but don't bet on it.
+
+    If the the program won't be able to create files in /etc when
+    updating the clock, you can use another lock file or even set
+    -DLOCKFILE=NULL, which will disable the locking code entirely.  On
+    systems that have it, using /var/run would be better than /etc.
+
+    If the the program hangs when flushing outstanding packets (which
+    you can tell by setting -W), it may help to set -DNONBLOCK_BROKEN.
+    This seems needed only for obsolete systems, like Ultrix.
+
+    If the system isn't Unix, even vaguely, you will probably need to
+    modify all of the above, and unix.c as well.
+
+    Note that adjtime is commonly sick, but you don't need to change the
+    code - just use the -r option whan making large corrections (see below
+    for more details).
+
+Any changes needed to header.h or main.c are bugs.  They may be bugs in the
+code or in the compiler or libraries, but they are bugs.  Please prod the
+people responsible and tell the author, who may be able to bypass them cleanly
+even if they aren't bugs in his code.  The code also makes the following
+assumptions, which would be quite hard to remove:
+
+    8-bit bytes.  Strictly, neither ANSI/ISO C nor POSIX require these,
+    and there were some very early versions of Unix on systems with other
+    byte sizes.  But, without a defined sub-byte facility in C, ....
+
+    At least 32-bit ints.  Well, actually, this wouldn't be too hard to
+    remove.  But most Unix programs make this assumption, and I have very
+    little interest in the more rudimentary versions of MS-DOS etc.
+
+    An ANSI/ISO C compiler.  It didn't seem worth writing dual-language
+    code in 1996.  Tough luck if you haven't got one.
+
+    Tolerably efficient floating-point arithmetic, with at least 13 digits
+    (decimal), preferably 15, in the mantissa of doubles.  Ditto.  If you
+    want to port this to a toaster, please accept my insincerest sympathies
+    and don't bother me.
+
+    A trustworthy local network.  It does not check for DNS, Ethernet,
+    packet or other spoofing, and assumes that any accessible NTP or SNTP
+    servers are properly synchronised.
+
+
+Warnings about Installation and Use
+-----------------------------------
+
+Anyone attempting to fiddle with the clock on their system should already know
+how to write system administration scripts, install daemons and so on.  There
+are a few warnings:
+
+    Don't use the broadcast modes unless you really have to, as the
+    client-server modes are far more reliable.  The broadcast modes were
+    implemented more for virtuosity (a.k.a. SNTP conformance) than use.
+    In particular, the error estimates are mere guesses, and may be low
+    or even very low.  And even reading broadcasts needs privilege.
+
+    The program is not intended to be installed setuid or setgid, and
+    doing so is asking for trouble.  Its ownerships and access modes are
+    not important.  It need not be run by root for merely displaying the
+    time (even in daemon mode).
+
+    The program does not need to run at a high priority (low in Unix
+    terms!) even when being used to set the clock or as a server, except
+    when the '-r' option is  used.  However, doing so may improve its
+    accuracy.
+
+    Unlike NTP, the SNTP protocol contains no protection against
+    client-server loops.  If you set one up, your systems will spin
+    themselves off into a disconnected vortex of unreality!
+
+    It will get very confused if another process changes the local time
+    while it is running.  There is some locking code in unix.c to prevent
+    this program doing this to itself, but it will protect only against
+    some errors.  However, the remaining failures should be harmless.
+
+    Don't run it as a server unless you REALLY know what you are doing.
+    It should be used as a server only on a system that is properly
+    synchronised, by fair means or foul.  If it isn't, you will simply
+    perpetrate misinformation.  And remember that broadcasts are most
+    unpopular with overloaded administrators of overloaded networks.
+
+    Watch out for multi-server broadcasts and systems with multiple ports
+    onto the same Ethernet; there is some code to protect against this,
+    but it is still easy to get confused.
+
+    Don't put the lock file onto an automounted partition or delete it by
+    hand, unless you really want to start two daemons at the same time.
+    Both will probably fail horribly if you do this.
+
+    The daemon save file is checked fairly carefully, but should be in a
+    reasonably safe directory, unless you want hackers to cause trouble.
+    /tmp is safe enough on most systems, but not all - /etc is better.
+
+
+Installing and Using the Program
+--------------------------------
+
+Start by copying the executable and man page to where you want them.  If you
+want only to display the time and as a replacement for the rdate or date
+commands, the installation is finished!
+
+You can use it as a simple unprivileged command to check the time, quite
+independently of whether it is running as a time-updating daemon or server, or
+whether you are running ntp.  You can run it in daemon mode without updating
+the clock, to check for drift, but it may fail if the clock is changed under
+its feet.  Unfortunately, you cannot listen to broadcasts without privilege.
+
+If it is used with the -a option to keep the time synchronised, it is best to
+run it as one of root's cron jobs - for many systems, running it once a day
+should be adequate, but it will depend on the reliability of the local clock.
+The author runs it this way with -a and -x - see below.
+
+If it is used with the -r option to set the time (instead of the rdate or date
+commands), it should be used interactively and either on a lightly loaded
+system or at a high priority.  You should then check the result by running it
+in display mode.
+
+You are advised NOT to run it with the -r option in a cron job, though this is
+not locked out.  If you have to (for example under HP-UX before 10.0), be sure
+to run it as the highest priority that will not cause other system problems and
+set the maximum automatic change to as low a value as you can get away with.
+
+WARNING: adjtime is more than a bit sick on many systems, and will ignore large
+corrections, usually without any form of hint that it has done so.  It is often
+(even usually) necessary to reset the clock to approximately the right time
+using the -r option before using the -a and -x options to keep it correct.
+
+It can be started as a time-updating daemon with the -a and -x options (or -r
+and -x if you must), and will perform some limited drift correction.  In this
+case, start it from any suitable system initialisation script and leave it
+running.  Note that it will stop if it thinks that the time difference or drift
+has got out of control, and you will need to reset the time and restart it by
+hand.
+
+In daemon mode, it will survive its time server or network disappearing for a
+while, but will eventually fail, and will fail immediately if the network call
+returns an unexpected error.  If this is a problem, you can start it (say,
+hourly or nightly) from cron, and it will fail if it is already running
+(provided that you haven't disabled or deleted the lock file).
+
+If it is used as a server, it should be started from any suitable system
+initialisation script, just like any other daemon.  It must be started after
+the networking, of course.  To run it in both server modes, start one copy with 
+the -B option and one with the -S option.
+
+
+Simple Examples of Use
+----------------------
+
+Many people use it solely to check the time of their system, especially as a
+cross-check on ntpd.  You do not need privilege and it will not cause trouble
+to the local network, so you can use it on someone else's system!  You can
+specify one server or several.  For example:
+
+    msntp ntp.server.local ntp.server.neighbour
+
+You can use it to check how your system is drifting, but it isn't very good at
+this if the system is drifting very badly (in which case use the previous
+technique and dc) or if you are running ntp.  You do not need privilege and it
+will not cause trouble to the local network.  For example:
+
+    sntp -x 120 -f /tmp/msntp.state ntp.server.local
+
+More generally, it is used to synchronise the clock, in which case you DO need
+root privilege.  It can be used in many ways, but the author favours running it
+in daemon mode, started from a cron job, which will restart after power cuts
+with no attention, and send a mail message (if cron is configured to do that)
+when it fails badly.  For example, the author uses a root crontab entry on one
+system of:
+
+    15 0 * * * /bin/nice --10 /usr/local/bin/sntp -a -x 480 ntp.server.local
+
+If you have a home computer, it can be set up to resynchronise each time you
+dial up.  For example, the author uses a /etc/ppp/ip-up.d/sntp file on his
+home Linux system of:
+
+    #!/bin/sh
+    sleep 60
+    /bin/nice --10 /usr/local/sbin/sntp -r -P 60 ntp.server.local
+
+-a would be better, but adjtime is broken in Linux.
+
+
+Debugging or Hacking the Program
+--------------------------------
+
+Almost everybody who does this is likely to need to modify only the system
+interfaces.  While they are messy, they are pretty simple and have a simple
+specification.  This is documented in comments in the source.  This is
+described above.
+
+The main program SHOULD need no attention, though it may need the odd tweak to
+bypass compiler problems - please report these, if you encounter any.  If
+something looks odd while it is running, start by setting the -v option (lower
+case), as for investigating network problems, and checking any diagnostics that
+appear.  Note that most of it can be checked in display mode without harming
+your system.
+
+The client will sometimes give up, complaining about inconsistent timestamps or
+similar.  This can be caused by the server being rebooted and similar glitches
+to the time - unfortunately, there is no reliable way to tell an ignorable
+fluctuation from a server up the spout.  If this happens annoyingly often,
+the -V option may help tie down the problem.  In actual use, it is simplest
+just to restart the client in a cron job!
+
+If it needs more than this, then you will need to debug the source seriously.
+Start by putting an icepack on your head and pouring yourself a large whisky!
+While it is commented, it is not well commented, and much of the code interacts
+in complex and horrible ways.  This isn't so much because it lacks 'structure'
+as because one part needs to make assumptions about the numerical properties of
+another.
+
+The -W option (upper case) will print out a complete trace of everything it
+does, and this should be enough to tie down the problem.  It does distort the
+timing a bit, but not usually too badly.  However, wading through that amount
+of gibberish (let alone looking at the source) is not a pleasant task.  If you
+are pretty sure that you have a bug, you may tell the author, and he may ask
+for a copy of the output - but he will reply rudely if you send thousands of
+lines of tracing to him by Email!
+
+Note that there are a fair number of circumstances where its error recovery
+could be better, but is left as it is to keep the code simple.  Most of these
+should be pretty rare.
+
+
+Changes in Version 1.2
+----------------------
+
+The main change was the addition of the daemon mode for drift correction (i.e.
+the -x option).  The daemon code is complex and has a lot of special-casing for
+strange circumstances, not all of which are testable in practice.
+
+A lot of the code was reordered while doing this.  The output was slightly
+different - considerably different with -V.
+
+The error estimation for broadcasts was modified, and should bear more relation
+to reality.  It remains a guess, as there is no way to get decent error error
+estimates under such circumstances.
+
+The -B option is now in minutes, and has a different permissible range and
+default value.
+
+The argument consistency checking for broadcasts was tightened up a bit, and a
+few other internal checks added.  These should not affect any reasonable
+requirement.
+
+A couple of new functions were added to the portability base, but they don't
+use any non-standard new facilities.  However, the specification of the
+functions has changed slightly.
+
+
+Changes in Version 1.3
+----------------------
+
+The main change was the addition of the restarting facility for daemon mode
+(i.e. the -f option), which is pretty straightforward.
+
+There were also a lot of minor changes to the paranoia code in daemon mode, to
+try to separate out the case of a demented server from network and other
+'ignorable' problems.  These are not entirely successful.
+
+
+Changes in Version 1.4 and 1.5
+------------------------------
+
+There turned out to be a couple of places where the author misunderstood the
+specification of NTP, which affect only its use in server mode.  The main
+change is to use stratum 15 instead of stratum 0.
+
+And there were some more relaxations of the paranoia code, to allow for more
+erratic servers, plus a kludge to improve restarting in daemon mode after a
+period of down time has unsynchronised the clock.  There is also an
+incompatible change to the debugging options to add a new level - the old -V
+option is now -W, and -V is an intermediate one for debugging daemon mode - but
+they are both hacker's facilities, and not for normal use.
+
+Version 1.5 adds some very minor fixes.
+
+
+Changes in Version 1.6
+----------------------
+
+The first change is support for multiple server addresses - it uses these in a
+round-robin fashion.  This may be useful when you have access to several
+servers, all of which are a bit iffy.  This means that the restart file format
+is incompatible with msntp 1.5.
+
+It has also been modified to reset itself automatically after detecting an
+inconsistency in its server's timestamps, because the author got sick of the
+failures.  It writes a comment to syslog (uniquely) in such cases.
+
+The ability to query a daemon save file was added.
+
+Related to the above, the -E argument has been redefined to mean an error bound
+on various internal times (which is what it had become, anyway) and a -P option
+introduced to be what the -E argument was documented to be.
+
+The lock and save file handling have been changed to allow defaults to be set
+at installation time, and to be overridable at run-time.  To disable these
+at either stage, simply set the file names to the null string.
+
+And there have been the usual changes for portability, as standards have been
+modified and/or introduced.
+
+
+Future Versions
+---------------
+
+There are unlikely to be any, except probably one to fix bugs in version 1.6.
+
+I attempted to put support for intermittent connexions (e.g. dial-up) into the
+daemon mode, but doing so needs so much code reorganisation that it isn't worth
+it.  What needs doing for that is to separate the socket handling from the
+timekeeping, so that they can be run asynchronously (either in separate
+processes or threads), and to look up a network name and open a socket only
+when prodded (and to close it immediately thereafter).  So just running it
+with the -r option is the current best solution.
+
+I also attempted to put support for the "Unix 2000" interfaces into the code.
+Ha, ha.  Not merely do very few systems define socklen_t (needed for IPv6
+support), but "Unix 2000" neither addresses the leap second problem nor even
+provides an adjtime replacement!  Some function like the latter is critical,
+not so much because of the gradual change, but because of its atomicity;
+without it, msntp really needs to be made non-interruptible, and that brings in
+a ghastly number of system-dependencies.
+
+Realistically, it needs a complete rewrite before adding any more function.
+And, worse, the Unix 'standards' need fixing, too.
+
+
+
+Miscellaneous
+-------------
+
+Thanks are due to Douglas M. Wells of Connection Technologies for helping the
+author with several IP-related conventions, to Sam Nelson of Stirling
+University for testing it on some very strange systems, and to David Mills for
+clarifying what the NTP specification really is.
+
+Thanks are also due to several other people with locating bugs, finding
+appropriate options for the Makefile and passing on extension code and
+suggestions.  As I am sure to leave someone out, I shall not name anyone else.
+
+Version 1.0 - October 1996.
+Version 1.1 - November 1996 - mainly portability improvements.
+Version 1.2 - January 1997 - mainly drift handling, but much reorganisation.
+Version 1.3 - February 1997 - daemon save file, and some robustness changes.
+Version 1.4 - May 1997 - relatively minor fixes, more diagnostic levels etc.
+Version 1.5 - December 1997 - some very minor fixes
+Version 1.6 - October 2000 - quite a few miscellaneous changes
+
+
+Nick Maclaren,
+University of Cambridge Computer Laboratory,
+New Museums Site, Pembroke Street, Cambridge CB2 3QG, England.
+Email:  nmm1@cam.ac.uk
+Tel.:  +44 1223 334761    Fax:  +44 1223 334679
diff --git a/sntp/aclocal.m4 b/sntp/aclocal.m4
new file mode 100644 (file)
index 0000000..1994696
--- /dev/null
@@ -0,0 +1,7128 @@
+# generated automatically by aclocal 1.11 -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2007, 2008, 2009  Free Software Foundation, Inc.
+# This file 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.65],,
+[m4_warning([this file was generated for autoconf 2.65.
+You have another version of autoconf.  It may work, but is not guaranteed to.
+If you have problems, you may need to regenerate the build system entirely.
+To do so, use the procedure documented by the package, typically `autoreconf'.])])
+
+# libtool.m4 - Configure libtool for the host system. -*-Autoconf-*-
+
+# serial 47 AC_PROG_LIBTOOL
+
+
+# AC_PROVIDE_IFELSE(MACRO-NAME, IF-PROVIDED, IF-NOT-PROVIDED)
+# -----------------------------------------------------------
+# If this macro is not defined by Autoconf, define it here.
+m4_ifdef([AC_PROVIDE_IFELSE],
+         [],
+         [m4_define([AC_PROVIDE_IFELSE],
+                [m4_ifdef([AC_PROVIDE_$1],
+                          [$2], [$3])])])
+
+
+# AC_PROG_LIBTOOL
+# ---------------
+AC_DEFUN([AC_PROG_LIBTOOL],
+[AC_REQUIRE([_AC_PROG_LIBTOOL])dnl
+dnl If AC_PROG_CXX has already been expanded, run AC_LIBTOOL_CXX
+dnl immediately, otherwise, hook it in at the end of AC_PROG_CXX.
+  AC_PROVIDE_IFELSE([AC_PROG_CXX],
+    [AC_LIBTOOL_CXX],
+    [define([AC_PROG_CXX], defn([AC_PROG_CXX])[AC_LIBTOOL_CXX
+  ])])
+dnl And a similar setup for Fortran 77 support
+  AC_PROVIDE_IFELSE([AC_PROG_F77],
+    [AC_LIBTOOL_F77],
+    [define([AC_PROG_F77], defn([AC_PROG_F77])[AC_LIBTOOL_F77
+])])
+
+dnl Quote A][M_PROG_GCJ so that aclocal doesn't bring it in needlessly.
+dnl If either AC_PROG_GCJ or A][M_PROG_GCJ have already been expanded, run
+dnl AC_LIBTOOL_GCJ immediately, otherwise, hook it in at the end of both.
+  AC_PROVIDE_IFELSE([AC_PROG_GCJ],
+    [AC_LIBTOOL_GCJ],
+    [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],
+      [AC_LIBTOOL_GCJ],
+      [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],
+       [AC_LIBTOOL_GCJ],
+      [ifdef([AC_PROG_GCJ],
+            [define([AC_PROG_GCJ], defn([AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+       ifdef([A][M_PROG_GCJ],
+            [define([A][M_PROG_GCJ], defn([A][M_PROG_GCJ])[AC_LIBTOOL_GCJ])])
+       ifdef([LT_AC_PROG_GCJ],
+            [define([LT_AC_PROG_GCJ],
+               defn([LT_AC_PROG_GCJ])[AC_LIBTOOL_GCJ])])])])
+])])# AC_PROG_LIBTOOL
+
+
+# _AC_PROG_LIBTOOL
+# ----------------
+AC_DEFUN([_AC_PROG_LIBTOOL],
+[AC_REQUIRE([AC_LIBTOOL_SETUP])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_CXX])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_F77])dnl
+AC_BEFORE([$0],[AC_LIBTOOL_GCJ])dnl
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+AC_SUBST(LIBTOOL)dnl
+
+# Prevent multiple expansion
+define([AC_PROG_LIBTOOL], [])
+])# _AC_PROG_LIBTOOL
+
+
+# AC_LIBTOOL_SETUP
+# ----------------
+AC_DEFUN([AC_LIBTOOL_SETUP],
+[AC_PREREQ(2.50)dnl
+AC_REQUIRE([AC_ENABLE_SHARED])dnl
+AC_REQUIRE([AC_ENABLE_STATIC])dnl
+AC_REQUIRE([AC_ENABLE_FAST_INSTALL])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_PROG_LD])dnl
+AC_REQUIRE([AC_PROG_LD_RELOAD_FLAG])dnl
+AC_REQUIRE([AC_PROG_NM])dnl
+
+AC_REQUIRE([AC_PROG_LN_S])dnl
+AC_REQUIRE([AC_DEPLIBS_CHECK_METHOD])dnl
+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+AC_REQUIRE([AC_OBJEXT])dnl
+AC_REQUIRE([AC_EXEEXT])dnl
+dnl
+
+AC_LIBTOOL_SYS_MAX_CMD_LEN
+AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+AC_LIBTOOL_OBJDIR
+
+AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+_LT_AC_PROG_ECHO_BACKSLASH
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+[sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g']
+
+# Same as above, but do not quote variable references.
+[double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g']
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Constants:
+rm="rm -f"
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+AC_CHECK_TOOL(AR, ar, false)
+AC_CHECK_TOOL(RANLIB, ranlib, :)
+AC_CHECK_TOOL(STRIP, strip, :)
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+test -z "$AS" && AS=as
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$LD" && LD=ld
+test -z "$LN_S" && LN_S="ln -s"
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+test -z "$NM" && NM=nm
+test -z "$SED" && SED=sed
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+    ;;
+  *)
+    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+_LT_CC_BASENAME([$compiler])
+
+# Only perform the check for file, if the check method requires it
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    AC_PATH_MAGIC
+  fi
+  ;;
+esac
+
+AC_PROVIDE_IFELSE([AC_LIBTOOL_DLOPEN], enable_dlopen=yes, enable_dlopen=no)
+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+enable_win32_dll=yes, enable_win32_dll=no)
+
+AC_ARG_ENABLE([libtool-lock],
+    [AC_HELP_STRING([--disable-libtool-lock],
+       [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+AC_ARG_WITH([pic],
+    [AC_HELP_STRING([--with-pic],
+       [try to use only PIC/non-PIC objects @<:@default=use both@:>@])],
+    [pic_mode="$withval"],
+    [pic_mode=default])
+test -z "$pic_mode" && pic_mode=default
+
+# Use C for the default configuration in the libtool script
+tagname=
+AC_LIBTOOL_LANG_C_CONFIG
+_LT_AC_TAGCONFIG
+])# AC_LIBTOOL_SETUP
+
+
+# _LT_AC_SYS_COMPILER
+# -------------------
+AC_DEFUN([_LT_AC_SYS_COMPILER],
+[AC_REQUIRE([AC_PROG_CC])dnl
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+])# _LT_AC_SYS_COMPILER
+
+
+# _LT_CC_BASENAME(CC)
+# -------------------
+# Calculate cc_basename.  Skip known compiler wrappers and cross-prefix.
+AC_DEFUN([_LT_CC_BASENAME],
+[for cc_temp in $1""; do
+  case $cc_temp in
+    compile | *[[\\/]]compile | ccache | *[[\\/]]ccache ) ;;
+    distcc | *[[\\/]]distcc | purify | *[[\\/]]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+])
+
+
+# _LT_COMPILER_BOILERPLATE
+# ------------------------
+# Check for compiler boilerplate output or warnings with
+# the simple compiler test code.
+AC_DEFUN([_LT_COMPILER_BOILERPLATE],
+[ac_outfile=conftest.$ac_objext
+printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+])# _LT_COMPILER_BOILERPLATE
+
+
+# _LT_LINKER_BOILERPLATE
+# ----------------------
+# Check for linker boilerplate output or warnings with
+# the simple link test code.
+AC_DEFUN([_LT_LINKER_BOILERPLATE],
+[ac_outfile=conftest.$ac_objext
+printf "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm conftest*
+])# _LT_LINKER_BOILERPLATE
+
+
+# _LT_AC_SYS_LIBPATH_AIX
+# ----------------------
+# Links a minimal program and checks the executable
+# for the system default hardcoded library path. In most cases,
+# this is /usr/lib:/lib, but when the MPI compilers are used
+# the location of the communication and MPI libs are included too.
+# If we don't find anything, use the default library path according
+# to the aix ld manual.
+AC_DEFUN([_LT_AC_SYS_LIBPATH_AIX],
+[AC_LINK_IFELSE(AC_LANG_PROGRAM,[
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi],[])
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+])# _LT_AC_SYS_LIBPATH_AIX
+
+
+# _LT_AC_SHELL_INIT(ARG)
+# ----------------------
+AC_DEFUN([_LT_AC_SHELL_INIT],
+[ifdef([AC_DIVERSION_NOTICE],
+            [AC_DIVERT_PUSH(AC_DIVERSION_NOTICE)],
+        [AC_DIVERT_PUSH(NOTICE)])
+$1
+AC_DIVERT_POP
+])# _LT_AC_SHELL_INIT
+
+
+# _LT_AC_PROG_ECHO_BACKSLASH
+# --------------------------
+# Add some code to the start of the generated configure script which
+# will find an echo command which doesn't interpret backslashes.
+AC_DEFUN([_LT_AC_PROG_ECHO_BACKSLASH],
+[_LT_AC_SHELL_INIT([
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$ECHO" | sed 's,\\\\\[$]\\[$]0,'[$]0','`
+  ;;
+esac
+
+echo=${ECHO-echo}
+if test "X[$]1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X[$]1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "[$]0" --no-reexec ${1+"[$]@"}
+fi
+
+if test "X[$]1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+[$]*
+EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$ECHO"; then
+if test "X${echo_test_string+set}" != Xset; then
+# find a string as large as possible, as long as the shell can cope with it
+  for cmd in 'sed 50q "[$]0"' 'sed 20q "[$]0"' 'sed 10q "[$]0"' 'sed 2q "[$]0"' 'echo test'; do
+    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+       echo_test_string=`eval $cmd` &&
+       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+    then
+      break
+    fi
+  done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+   echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+   test "X$echo_testing_string" = "X$echo_test_string"; then
+  :
+else
+  # The Solaris, AIX, and Digital Unix default echo programs unquote
+  # backslashes.  This makes it impossible to quote backslashes using
+  #   echo "$something" | sed 's/\\/\\\\/g'
+  #
+  # So, first we look for a working echo in the user's PATH.
+
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for dir in $PATH /usr/ucb; do
+    IFS="$lt_save_ifs"
+    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      echo="$dir/echo"
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  if test "X$echo" = Xecho; then
+    # We didn't find a better echo, so look for alternatives.
+    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      # This shell has a builtin print -r that does the trick.
+      echo='print -r'
+    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+        test "X$CONFIG_SHELL" != X/bin/ksh; then
+      # If we have ksh, try running configure again with it.
+      ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+      export ORIGINAL_CONFIG_SHELL
+      CONFIG_SHELL=/bin/ksh
+      export CONFIG_SHELL
+      exec $CONFIG_SHELL "[$]0" --no-reexec ${1+"[$]@"}
+    else
+      # Try using printf.
+      echo='printf %s\n'
+      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+        echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+        test "X$echo_testing_string" = "X$echo_test_string"; then
+       # Cool, printf works
+       :
+      elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+          test "X$echo_testing_string" = 'X\t' &&
+          echo_testing_string=`($ORIGINAL_CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+          test "X$echo_testing_string" = "X$echo_test_string"; then
+       CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+       export CONFIG_SHELL
+       SHELL="$CONFIG_SHELL"
+       export SHELL
+       echo="$CONFIG_SHELL [$]0 --fallback-echo"
+      elif echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo '\t') 2>/dev/null` &&
+          test "X$echo_testing_string" = 'X\t' &&
+          echo_testing_string=`($CONFIG_SHELL "[$]0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+          test "X$echo_testing_string" = "X$echo_test_string"; then
+       echo="$CONFIG_SHELL [$]0 --fallback-echo"
+      else
+       # maybe with a smaller string...
+       prev=:
+
+       for cmd in 'echo test' 'sed 2q "[$]0"' 'sed 10q "[$]0"' 'sed 20q "[$]0"' 'sed 50q "[$]0"'; do
+         if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+         then
+           break
+         fi
+         prev="$cmd"
+       done
+
+       if test "$prev" != 'sed 50q "[$]0"'; then
+         echo_test_string=`eval $prev`
+         export echo_test_string
+         exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "[$]0" ${1+"[$]@"}
+       else
+         # Oops.  We lost completely, so just stick with echo.
+         echo=echo
+       fi
+      fi
+    fi
+  fi
+fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+ECHO=$echo
+if test "X$ECHO" = "X$CONFIG_SHELL [$]0 --fallback-echo"; then
+   ECHO="$CONFIG_SHELL \\\$\[$]0 --fallback-echo"
+fi
+
+AC_SUBST(ECHO)
+])])# _LT_AC_PROG_ECHO_BACKSLASH
+
+
+# _LT_AC_LOCK
+# -----------
+AC_DEFUN([_LT_AC_LOCK],
+[AC_ARG_ENABLE([libtool-lock],
+    [AC_HELP_STRING([--disable-libtool-lock],
+       [avoid locking (might break parallel builds)])])
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *ELF-32*)
+      HPUX_IA64_MODE="32"
+      ;;
+    *ELF-64*)
+      HPUX_IA64_MODE="64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '[#]line __oline__ "configure"' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+   if test "$lt_cv_prog_gnu_ld" = yes; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -melf32bsmip"
+      ;;
+    *N32*)
+      LD="${LD-ld} -melf32bmipn32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -melf64bmip"
+      ;;
+    esac
+   else
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+   fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if AC_TRY_EVAL(ac_compile); then
+    case `/usr/bin/file conftest.o` in
+    *32-bit*)
+      case $host in
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_i386"
+          ;;
+        ppc64-*linux*|powerpc64-*linux*)
+          LD="${LD-ld} -m elf32ppclinux"
+          ;;
+        s390x-*linux*)
+          LD="${LD-ld} -m elf_s390"
+          ;;
+        sparc64-*linux*)
+          LD="${LD-ld} -m elf32_sparc"
+          ;;
+      esac
+      ;;
+    *64-bit*)
+      case $host in
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        ppc*-*linux*|powerpc*-*linux*)
+          LD="${LD-ld} -m elf64ppc"
+          ;;
+        s390*-*linux*)
+          LD="${LD-ld} -m elf64_s390"
+          ;;
+        sparc*-*linux*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  AC_CACHE_CHECK([whether the C compiler needs -belf], lt_cv_cc_needs_belf,
+    [AC_LANG_PUSH(C)
+     AC_TRY_LINK([],[],[lt_cv_cc_needs_belf=yes],[lt_cv_cc_needs_belf=no])
+     AC_LANG_POP])
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+AC_PROVIDE_IFELSE([AC_LIBTOOL_WIN32_DLL],
+[*-*-cygwin* | *-*-mingw* | *-*-pw32*)
+  AC_CHECK_TOOL(DLLTOOL, dlltool, false)
+  AC_CHECK_TOOL(AS, as, false)
+  AC_CHECK_TOOL(OBJDUMP, objdump, false)
+  ;;
+  ])
+esac
+
+need_locks="$enable_libtool_lock"
+
+])# _LT_AC_LOCK
+
+
+# AC_LIBTOOL_COMPILER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#              [OUTPUT-FILE], [ACTION-SUCCESS], [ACTION-FAILURE])
+# ----------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([AC_LIBTOOL_COMPILER_OPTION],
+[AC_REQUIRE([LT_AC_PROG_SED])
+AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+  ifelse([$4], , [ac_outfile=conftest.$ac_objext], [ac_outfile=$4])
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$3"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+       $2=yes
+     fi
+   fi
+   $rm conftest*
+])
+
+if test x"[$]$2" = xyes; then
+    ifelse([$5], , :, [$5])
+else
+    ifelse([$6], , :, [$6])
+fi
+])# AC_LIBTOOL_COMPILER_OPTION
+
+
+# AC_LIBTOOL_LINKER_OPTION(MESSAGE, VARIABLE-NAME, FLAGS,
+#                          [ACTION-SUCCESS], [ACTION-FAILURE])
+# ------------------------------------------------------------
+# Check whether the given compiler option works
+AC_DEFUN([AC_LIBTOOL_LINKER_OPTION],
+[AC_CACHE_CHECK([$1], [$2],
+  [$2=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $3"
+   printf "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&AS_MESSAGE_LOG_FD
+       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
+       $SED '/^$/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         $2=yes
+       fi
+     else
+       $2=yes
+     fi
+   fi
+   $rm conftest*
+   LDFLAGS="$save_LDFLAGS"
+])
+
+if test x"[$]$2" = xyes; then
+    ifelse([$4], , :, [$4])
+else
+    ifelse([$5], , :, [$5])
+fi
+])# AC_LIBTOOL_LINKER_OPTION
+
+
+# AC_LIBTOOL_SYS_MAX_CMD_LEN
+# --------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_MAX_CMD_LEN],
+[# find the maximum length of command line arguments
+AC_MSG_CHECKING([the maximum length of command line arguments])
+AC_CACHE_VAL([lt_cv_sys_max_cmd_len], [dnl
+  i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536      # usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  *)
+    # If test is not a shell built-in, we'll probably end up computing a
+    # maximum length that is only half of the actual maximum length, but
+    # we can't tell.
+    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+    while (test "X"`$SHELL [$]0 --fallback-echo "X$teststring" 2>/dev/null` \
+              = "XX$teststring") >/dev/null 2>&1 &&
+           new_result=`expr "X$teststring" : ".*" 2>&1` &&
+           lt_cv_sys_max_cmd_len=$new_result &&
+           test $i != 17 # 1/2 MB should be enough
+    do
+      i=`expr $i + 1`
+      teststring=$teststring$teststring
+    done
+    teststring=
+    # Add a significant safety factor because C++ compilers can tack on massive
+    # amounts of additional arguments before passing them to the linker.
+    # It appears as though 1/2 is a usable value.
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    ;;
+  esac
+])
+if test -n $lt_cv_sys_max_cmd_len ; then
+  AC_MSG_RESULT($lt_cv_sys_max_cmd_len)
+else
+  AC_MSG_RESULT(none)
+fi
+])# AC_LIBTOOL_SYS_MAX_CMD_LEN
+
+
+# _LT_AC_CHECK_DLFCN
+# --------------------
+AC_DEFUN([_LT_AC_CHECK_DLFCN],
+[AC_CHECK_HEADERS(dlfcn.h)dnl
+])# _LT_AC_CHECK_DLFCN
+
+
+# _LT_AC_TRY_DLOPEN_SELF (ACTION-IF-TRUE, ACTION-IF-TRUE-W-USCORE,
+#                           ACTION-IF-FALSE, ACTION-IF-CROSS-COMPILING)
+# ------------------------------------------------------------------
+AC_DEFUN([_LT_AC_TRY_DLOPEN_SELF],
+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+if test "$cross_compiling" = yes; then :
+  [$4]
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+[#line __oline__ "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}]
+EOF
+  if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&AS_MESSAGE_LOG_FD 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) $1 ;;
+      x$lt_dlneed_uscore) $2 ;;
+      x$lt_unknown|x*) $3 ;;
+    esac
+  else :
+    # compilation failed
+    $3
+  fi
+fi
+rm -fr conftest*
+])# _LT_AC_TRY_DLOPEN_SELF
+
+
+# AC_LIBTOOL_DLOPEN_SELF
+# -------------------
+AC_DEFUN([AC_LIBTOOL_DLOPEN_SELF],
+[AC_REQUIRE([_LT_AC_CHECK_DLFCN])dnl
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    AC_CHECK_LIB([dl], [dlopen],
+               [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],[
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ])
+   ;;
+
+  *)
+    AC_CHECK_FUNC([shl_load],
+         [lt_cv_dlopen="shl_load"],
+      [AC_CHECK_LIB([dld], [shl_load],
+           [lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"],
+       [AC_CHECK_FUNC([dlopen],
+             [lt_cv_dlopen="dlopen"],
+         [AC_CHECK_LIB([dl], [dlopen],
+               [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"],
+           [AC_CHECK_LIB([svld], [dlopen],
+                 [lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"],
+             [AC_CHECK_LIB([dld], [dld_link],
+                   [lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"])
+             ])
+           ])
+         ])
+       ])
+      ])
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    AC_CACHE_CHECK([whether a program can dlopen itself],
+         lt_cv_dlopen_self, [dnl
+         _LT_AC_TRY_DLOPEN_SELF(
+           lt_cv_dlopen_self=yes, lt_cv_dlopen_self=yes,
+           lt_cv_dlopen_self=no, lt_cv_dlopen_self=cross)
+    ])
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      LDFLAGS="$LDFLAGS $link_static_flag"
+      AC_CACHE_CHECK([whether a statically linked program can dlopen itself],
+         lt_cv_dlopen_self_static, [dnl
+         _LT_AC_TRY_DLOPEN_SELF(
+           lt_cv_dlopen_self_static=yes, lt_cv_dlopen_self_static=yes,
+           lt_cv_dlopen_self_static=no,  lt_cv_dlopen_self_static=cross)
+      ])
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+])# AC_LIBTOOL_DLOPEN_SELF
+
+
+# AC_LIBTOOL_PROG_CC_C_O([TAGNAME])
+# ---------------------------------
+# Check to see if options -c and -o are simultaneously supported by compiler
+AC_DEFUN([AC_LIBTOOL_PROG_CC_C_O],
+[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+AC_CACHE_CHECK([if $compiler supports -c -o file.$ac_objext],
+  [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)],
+  [_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [[^ ]]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:__oline__: $lt_compile\"" >&AS_MESSAGE_LOG_FD)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&AS_MESSAGE_LOG_FD
+   echo "$as_me:__oline__: \$? = $ac_status" >&AS_MESSAGE_LOG_FD
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
+     $SED '/^$/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+     fi
+   fi
+   chmod u+w . 2>&AS_MESSAGE_LOG_FD
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+])
+])# AC_LIBTOOL_PROG_CC_C_O
+
+
+# AC_LIBTOOL_SYS_HARD_LINK_LOCKS([TAGNAME])
+# -----------------------------------------
+# Check to see if we can do hard links to lock some files if needed
+AC_DEFUN([AC_LIBTOOL_SYS_HARD_LINK_LOCKS],
+[AC_REQUIRE([_LT_AC_LOCK])dnl
+
+hard_links="nottested"
+if test "$_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  AC_MSG_CHECKING([if we can lock with hard links])
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  AC_MSG_RESULT([$hard_links])
+  if test "$hard_links" = no; then
+    AC_MSG_WARN([`$CC' does not support `-c -o', so `make -j' may be unsafe])
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+])# AC_LIBTOOL_SYS_HARD_LINK_LOCKS
+
+
+# AC_LIBTOOL_OBJDIR
+# -----------------
+AC_DEFUN([AC_LIBTOOL_OBJDIR],
+[AC_CACHE_CHECK([for objdir], [lt_cv_objdir],
+[rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null])
+objdir=$lt_cv_objdir
+])# AC_LIBTOOL_OBJDIR
+
+
+# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH([TAGNAME])
+# ----------------------------------------------
+# Check hardcoding attributes.
+AC_DEFUN([AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH],
+[AC_MSG_CHECKING([how to hardcode library paths into programs])
+_LT_AC_TAGVAR(hardcode_action, $1)=
+if test -n "$_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)" || \
+   test -n "$_LT_AC_TAGVAR(runpath_var, $1)" || \
+   test "X$_LT_AC_TAGVAR(hardcode_automatic, $1)" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$_LT_AC_TAGVAR(hardcode_direct, $1)" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)" != no &&
+     test "$_LT_AC_TAGVAR(hardcode_minus_L, $1)" != no; then
+    # Linking always hardcodes the temporary library directory.
+    _LT_AC_TAGVAR(hardcode_action, $1)=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    _LT_AC_TAGVAR(hardcode_action, $1)=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  _LT_AC_TAGVAR(hardcode_action, $1)=unsupported
+fi
+AC_MSG_RESULT([$_LT_AC_TAGVAR(hardcode_action, $1)])
+
+if test "$_LT_AC_TAGVAR(hardcode_action, $1)" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+])# AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH
+
+
+# AC_LIBTOOL_SYS_LIB_STRIP
+# ------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_LIB_STRIP],
+[striplib=
+old_striplib=
+AC_MSG_CHECKING([whether stripping libraries is possible])
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  AC_MSG_RESULT([yes])
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         AC_MSG_RESULT([yes])
+       else
+  AC_MSG_RESULT([no])
+fi
+       ;;
+   *)
+  AC_MSG_RESULT([no])
+    ;;
+  esac
+fi
+])# AC_LIBTOOL_SYS_LIB_STRIP
+
+
+# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+# -----------------------------
+# PORTME Fill in your ld.so characteristics
+AC_DEFUN([AC_LIBTOOL_SYS_DYNAMIC_LINKER],
+[AC_MSG_CHECKING([dynamic linker characteristics])
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix4* | aix5*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[[01]] | aix4.[[01]].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([[^/]]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[[45]]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | [grep ';[c-zC-Z]:/' >/dev/null]; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[[.]]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+  if test "$GCC" = yes; then
+    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+  else
+    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+  fi
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+kfreebsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[[123]]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[[01]]* | freebsdelf3.[[01]]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  *) # from 3.2 on
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \[$]2)); skip = 1; } { if (!skip) print \[$]0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,   ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+knetbsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[[89]] | openbsd2.[[89]].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+AC_MSG_RESULT([$dynamic_linker])
+test "$dynamic_linker" = no && can_build_shared=no
+])# AC_LIBTOOL_SYS_DYNAMIC_LINKER
+
+
+# _LT_AC_TAGCONFIG
+# ----------------
+AC_DEFUN([_LT_AC_TAGCONFIG],
+[AC_ARG_WITH([tags],
+    [AC_HELP_STRING([--with-tags@<:@=TAGS@:>@],
+        [include additional configurations @<:@automatic@:>@])],
+    [tagnames="$withval"])
+
+if test -f "$ltmain" && test -n "$tagnames"; then
+  if test ! -f "${ofile}"; then
+    AC_MSG_WARN([output file `$ofile' does not exist])
+  fi
+
+  if test -z "$LTCC"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+    if test -z "$LTCC"; then
+      AC_MSG_WARN([output file `$ofile' does not look like a libtool script])
+    else
+      AC_MSG_WARN([using `LTCC=$LTCC', extracted from `$ofile'])
+    fi
+  fi
+
+  # Extract list of available tagged configurations in $ofile.
+  # Note that this assumes the entire list is on one line.
+  available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
+
+  lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+  for tagname in $tagnames; do
+    IFS="$lt_save_ifs"
+    # Check whether tagname contains only valid characters
+    case `$echo "X$tagname" | $Xsed -e 's:[[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]]::g'` in
+    "") ;;
+    *)  AC_MSG_ERROR([invalid tag name: $tagname])
+       ;;
+    esac
+
+    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+    then
+      AC_MSG_ERROR([tag name \"$tagname\" already exists])
+    fi
+
+    # Update the list of available tags.
+    if test -n "$tagname"; then
+      echo appending configuration tag \"$tagname\" to $ofile
+
+      case $tagname in
+      CXX)
+       if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+           ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+           (test "X$CXX" != "Xg++"))) ; then
+         AC_LIBTOOL_LANG_CXX_CONFIG
+       else
+         tagname=""
+       fi
+       ;;
+
+      F77)
+       if test -n "$F77" && test "X$F77" != "Xno"; then
+         AC_LIBTOOL_LANG_F77_CONFIG
+       else
+         tagname=""
+       fi
+       ;;
+
+      GCJ)
+       if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+         AC_LIBTOOL_LANG_GCJ_CONFIG
+       else
+         tagname=""
+       fi
+       ;;
+
+      RC)
+       AC_LIBTOOL_LANG_RC_CONFIG
+       ;;
+
+      *)
+       AC_MSG_ERROR([Unsupported tag name: $tagname])
+       ;;
+      esac
+
+      # Append the new tag name to the list of available tags.
+      if test -n "$tagname" ; then
+      available_tags="$available_tags $tagname"
+    fi
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  # Now substitute the updated list of available tags.
+  if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+    mv "${ofile}T" "$ofile"
+    chmod +x "$ofile"
+  else
+    rm -f "${ofile}T"
+    AC_MSG_ERROR([unable to update list of available tagged configurations.])
+  fi
+fi
+])# _LT_AC_TAGCONFIG
+
+
+# AC_LIBTOOL_DLOPEN
+# -----------------
+# enable checks for dlopen support
+AC_DEFUN([AC_LIBTOOL_DLOPEN],
+ [AC_BEFORE([$0],[AC_LIBTOOL_SETUP])
+])# AC_LIBTOOL_DLOPEN
+
+
+# AC_LIBTOOL_WIN32_DLL
+# --------------------
+# declare package support for building win32 DLLs
+AC_DEFUN([AC_LIBTOOL_WIN32_DLL],
+[AC_BEFORE([$0], [AC_LIBTOOL_SETUP])
+])# AC_LIBTOOL_WIN32_DLL
+
+
+# AC_ENABLE_SHARED([DEFAULT])
+# ---------------------------
+# implement the --enable-shared flag
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_SHARED],
+[define([AC_ENABLE_SHARED_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([shared],
+    [AC_HELP_STRING([--enable-shared@<:@=PKGS@:>@],
+       [build shared libraries @<:@default=]AC_ENABLE_SHARED_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_shared=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_shared=]AC_ENABLE_SHARED_DEFAULT)
+])# AC_ENABLE_SHARED
+
+
+# AC_DISABLE_SHARED
+# -----------------
+#- set the default shared flag to --disable-shared
+AC_DEFUN([AC_DISABLE_SHARED],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_SHARED(no)
+])# AC_DISABLE_SHARED
+
+
+# AC_ENABLE_STATIC([DEFAULT])
+# ---------------------------
+# implement the --enable-static flag
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_STATIC],
+[define([AC_ENABLE_STATIC_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([static],
+    [AC_HELP_STRING([--enable-static@<:@=PKGS@:>@],
+       [build static libraries @<:@default=]AC_ENABLE_STATIC_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_static=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_static=]AC_ENABLE_STATIC_DEFAULT)
+])# AC_ENABLE_STATIC
+
+
+# AC_DISABLE_STATIC
+# -----------------
+# set the default static flag to --disable-static
+AC_DEFUN([AC_DISABLE_STATIC],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_STATIC(no)
+])# AC_DISABLE_STATIC
+
+
+# AC_ENABLE_FAST_INSTALL([DEFAULT])
+# ---------------------------------
+# implement the --enable-fast-install flag
+# DEFAULT is either `yes' or `no'.  If omitted, it defaults to `yes'.
+AC_DEFUN([AC_ENABLE_FAST_INSTALL],
+[define([AC_ENABLE_FAST_INSTALL_DEFAULT], ifelse($1, no, no, yes))dnl
+AC_ARG_ENABLE([fast-install],
+    [AC_HELP_STRING([--enable-fast-install@<:@=PKGS@:>@],
+    [optimize for fast installation @<:@default=]AC_ENABLE_FAST_INSTALL_DEFAULT[@:>@])],
+    [p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_fast_install=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac],
+    [enable_fast_install=]AC_ENABLE_FAST_INSTALL_DEFAULT)
+])# AC_ENABLE_FAST_INSTALL
+
+
+# AC_DISABLE_FAST_INSTALL
+# -----------------------
+# set the default to --disable-fast-install
+AC_DEFUN([AC_DISABLE_FAST_INSTALL],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+AC_ENABLE_FAST_INSTALL(no)
+])# AC_DISABLE_FAST_INSTALL
+
+
+# AC_LIBTOOL_PICMODE([MODE])
+# --------------------------
+# implement the --with-pic flag
+# MODE is either `yes' or `no'.  If omitted, it defaults to `both'.
+AC_DEFUN([AC_LIBTOOL_PICMODE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+pic_mode=ifelse($#,1,$1,default)
+])# AC_LIBTOOL_PICMODE
+
+
+# AC_PROG_EGREP
+# -------------
+# This is predefined starting with Autoconf 2.54, so this conditional
+# definition can be removed once we require Autoconf 2.54 or later.
+m4_ifndef([AC_PROG_EGREP], [AC_DEFUN([AC_PROG_EGREP],
+[AC_CACHE_CHECK([for egrep], [ac_cv_prog_egrep],
+   [if echo a | (grep -E '(a|b)') >/dev/null 2>&1
+    then ac_cv_prog_egrep='grep -E'
+    else ac_cv_prog_egrep='egrep'
+    fi])
+ EGREP=$ac_cv_prog_egrep
+ AC_SUBST([EGREP])
+])])
+
+
+# AC_PATH_TOOL_PREFIX
+# -------------------
+# find a file program which can recognise shared library
+AC_DEFUN([AC_PATH_TOOL_PREFIX],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_MSG_CHECKING([for $1])
+AC_CACHE_VAL(lt_cv_path_MAGIC_CMD,
+[case $MAGIC_CMD in
+[[\\/*] |  ?:[\\/]*])
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+dnl $ac_dummy forces splitting on constant user-supplied paths.
+dnl POSIX.2 word splitting is done only on the output of word expansions,
+dnl not every word.  This closes a longstanding sh security hole.
+  ac_dummy="ifelse([$2], , $PATH, [$2])"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/$1; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/$1"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac])
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  AC_MSG_RESULT($MAGIC_CMD)
+else
+  AC_MSG_RESULT(no)
+fi
+])# AC_PATH_TOOL_PREFIX
+
+
+# AC_PATH_MAGIC
+# -------------
+# find a file program which can recognise a shared library
+AC_DEFUN([AC_PATH_MAGIC],
+[AC_PATH_TOOL_PREFIX(${ac_tool_prefix}file, /usr/bin$PATH_SEPARATOR$PATH)
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    AC_PATH_TOOL_PREFIX(file, /usr/bin$PATH_SEPARATOR$PATH)
+  else
+    MAGIC_CMD=:
+  fi
+fi
+])# AC_PATH_MAGIC
+
+
+# AC_PROG_LD
+# ----------
+# find the pathname to the GNU or non-GNU linker
+AC_DEFUN([AC_PROG_LD],
+[AC_ARG_WITH([gnu-ld],
+    [AC_HELP_STRING([--with-gnu-ld],
+       [assume the C compiler uses GNU ld @<:@default=no@:>@])],
+    [test "$withval" = no || with_gnu_ld=yes],
+    [with_gnu_ld=no])
+AC_REQUIRE([LT_AC_PROG_SED])dnl
+AC_REQUIRE([AC_PROG_CC])dnl
+AC_REQUIRE([AC_CANONICAL_HOST])dnl
+AC_REQUIRE([AC_CANONICAL_BUILD])dnl
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  AC_MSG_CHECKING([for ld used by $CC])
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [[\\/]]* | ?:[[\\/]]*)
+      re_direlt='/[[^/]][[^/]]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  AC_MSG_CHECKING([for GNU ld])
+else
+  AC_MSG_CHECKING([for non-GNU ld])
+fi
+AC_CACHE_VAL(lt_cv_path_LD,
+[if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+       test "$with_gnu_ld" != no && break
+       ;;
+      *)
+       test "$with_gnu_ld" != yes && break
+       ;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi])
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  AC_MSG_RESULT($LD)
+else
+  AC_MSG_RESULT(no)
+fi
+test -z "$LD" && AC_MSG_ERROR([no acceptable ld found in \$PATH])
+AC_PROG_LD_GNU
+])# AC_PROG_LD
+
+
+# AC_PROG_LD_GNU
+# --------------
+AC_DEFUN([AC_PROG_LD_GNU],
+[AC_REQUIRE([AC_PROG_EGREP])dnl
+AC_CACHE_CHECK([if the linker ($LD) is GNU ld], lt_cv_prog_gnu_ld,
+[# I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac])
+with_gnu_ld=$lt_cv_prog_gnu_ld
+])# AC_PROG_LD_GNU
+
+
+# AC_PROG_LD_RELOAD_FLAG
+# ----------------------
+# find reload flag for linker
+#   -- PORTME Some linkers may need a different reload flag.
+AC_DEFUN([AC_PROG_LD_RELOAD_FLAG],
+[AC_CACHE_CHECK([for $LD option to reload object files],
+  lt_cv_ld_reload_flag,
+  [lt_cv_ld_reload_flag='-r'])
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+])# AC_PROG_LD_RELOAD_FLAG
+
+
+# AC_DEPLIBS_CHECK_METHOD
+# -----------------------
+# how to check for library dependencies
+#  -- PORTME fill in with the dynamic library characteristics
+AC_DEFUN([AC_DEPLIBS_CHECK_METHOD],
+[AC_CACHE_CHECK([how to recognise dependent libraries],
+lt_cv_deplibs_check_method,
+[lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix4* | aix5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[[45]]*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump'.
+  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | kfreebsd*-gnu | dragonfly*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[[3-9]]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|ELF-[[0-9]][[0-9]]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    [lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]']
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[[0-9]][[0-9]][[0-9]]|PA-RISC[[0-9]].[[0-9]]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+nto-qnx*)
+  lt_cv_deplibs_check_method=unknown
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[[^/]]+(\.so\.[[0-9]]+\.[[0-9]]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sco3.2v5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[ML]]SB (shared object|dynamic lib) M[[0-9]][[0-9]]* Version [[0-9]]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [[0-9]][[0-9]]*-bit [[LM]]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+])
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+])# AC_DEPLIBS_CHECK_METHOD
+
+
+# AC_PROG_NM
+# ----------
+# find the pathname to a BSD-compatible name lister
+AC_DEFUN([AC_PROG_NM],
+[AC_CACHE_CHECK([for BSD-compatible nm], lt_cv_path_NM,
+[if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    tmp_nm="$ac_dir/${ac_tool_prefix}nm"
+    if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      # Tru64's nm complains that /dev/null is an invalid object file
+      case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+      */dev/null* | *'Invalid file or object type'*)
+       lt_cv_path_NM="$tmp_nm -B"
+       break
+        ;;
+      *)
+       case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+       */dev/null*)
+         lt_cv_path_NM="$tmp_nm -p"
+         break
+         ;;
+       *)
+         lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+         continue # so that we can try to find one that supports BSD flags
+         ;;
+       esac
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi])
+NM="$lt_cv_path_NM"
+])# AC_PROG_NM
+
+
+# AC_CHECK_LIBM
+# -------------
+# check for math library
+AC_DEFUN([AC_CHECK_LIBM],
+[AC_REQUIRE([AC_CANONICAL_HOST])dnl
+LIBM=
+case $host in
+*-*-beos* | *-*-cygwin* | *-*-pw32* | *-*-darwin*)
+  # These system don't have libm, or don't need it
+  ;;
+*-ncr-sysv4.3*)
+  AC_CHECK_LIB(mw, _mwvalidcheckl, LIBM="-lmw")
+  AC_CHECK_LIB(m, cos, LIBM="$LIBM -lm")
+  ;;
+*)
+  AC_CHECK_LIB(m, cos, LIBM="-lm")
+  ;;
+esac
+])# AC_CHECK_LIBM
+
+
+# AC_LIBLTDL_CONVENIENCE([DIRECTORY])
+# -----------------------------------
+# sets LIBLTDL to the link flags for the libltdl convenience library and
+# LTDLINCL to the include flags for the libltdl header and adds
+# --enable-ltdl-convenience to the configure arguments.  Note that
+# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
+# it is assumed to be `libltdl'.  LIBLTDL will be prefixed with
+# '${top_builddir}/' and LTDLINCL will be prefixed with '${top_srcdir}/'
+# (note the single quotes!).  If your package is not flat and you're not
+# using automake, define top_builddir and top_srcdir appropriately in
+# the Makefiles.
+AC_DEFUN([AC_LIBLTDL_CONVENIENCE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  case $enable_ltdl_convenience in
+  no) AC_MSG_ERROR([this package needs a convenience libltdl]) ;;
+  "") enable_ltdl_convenience=yes
+      ac_configure_args="$ac_configure_args --enable-ltdl-convenience" ;;
+  esac
+  LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdlc.la
+  LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  # For backwards non-gettext consistent compatibility...
+  INCLTDL="$LTDLINCL"
+])# AC_LIBLTDL_CONVENIENCE
+
+
+# AC_LIBLTDL_INSTALLABLE([DIRECTORY])
+# -----------------------------------
+# sets LIBLTDL to the link flags for the libltdl installable library and
+# LTDLINCL to the include flags for the libltdl header and adds
+# --enable-ltdl-install to the configure arguments.  Note that
+# AC_CONFIG_SUBDIRS is not called here.  If DIRECTORY is not provided,
+# and an installed libltdl is not found, it is assumed to be `libltdl'.
+# LIBLTDL will be prefixed with '${top_builddir}/'# and LTDLINCL with
+# '${top_srcdir}/' (note the single quotes!).  If your package is not
+# flat and you're not using automake, define top_builddir and top_srcdir
+# appropriately in the Makefiles.
+# In the future, this macro may have to be called after AC_PROG_LIBTOOL.
+AC_DEFUN([AC_LIBLTDL_INSTALLABLE],
+[AC_BEFORE([$0],[AC_LIBTOOL_SETUP])dnl
+  AC_CHECK_LIB(ltdl, lt_dlinit,
+  [test x"$enable_ltdl_install" != xyes && enable_ltdl_install=no],
+  [if test x"$enable_ltdl_install" = xno; then
+     AC_MSG_WARN([libltdl not installed, but installation disabled])
+   else
+     enable_ltdl_install=yes
+   fi
+  ])
+  if test x"$enable_ltdl_install" = x"yes"; then
+    ac_configure_args="$ac_configure_args --enable-ltdl-install"
+    LIBLTDL='${top_builddir}/'ifelse($#,1,[$1],['libltdl'])/libltdl.la
+    LTDLINCL='-I${top_srcdir}/'ifelse($#,1,[$1],['libltdl'])
+  else
+    ac_configure_args="$ac_configure_args --enable-ltdl-install=no"
+    LIBLTDL="-lltdl"
+    LTDLINCL=
+  fi
+  # For backwards non-gettext consistent compatibility...
+  INCLTDL="$LTDLINCL"
+])# AC_LIBLTDL_INSTALLABLE
+
+
+# AC_LIBTOOL_CXX
+# --------------
+# enable support for C++ libraries
+AC_DEFUN([AC_LIBTOOL_CXX],
+[AC_REQUIRE([_LT_AC_LANG_CXX])
+])# AC_LIBTOOL_CXX
+
+
+# _LT_AC_LANG_CXX
+# ---------------
+AC_DEFUN([_LT_AC_LANG_CXX],
+[AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}CXX])
+])# _LT_AC_LANG_CXX
+
+# _LT_AC_PROG_CXXCPP
+# ---------------
+AC_DEFUN([_LT_AC_PROG_CXXCPP],
+[
+AC_REQUIRE([AC_PROG_CXX])
+if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+    ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+    (test "X$CXX" != "Xg++"))) ; then
+  AC_PROG_CXXCPP
+fi
+])# _LT_AC_PROG_CXXCPP
+
+# AC_LIBTOOL_F77
+# --------------
+# enable support for Fortran 77 libraries
+AC_DEFUN([AC_LIBTOOL_F77],
+[AC_REQUIRE([_LT_AC_LANG_F77])
+])# AC_LIBTOOL_F77
+
+
+# _LT_AC_LANG_F77
+# ---------------
+AC_DEFUN([_LT_AC_LANG_F77],
+[AC_REQUIRE([AC_PROG_F77])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}F77])
+])# _LT_AC_LANG_F77
+
+
+# AC_LIBTOOL_GCJ
+# --------------
+# enable support for GCJ libraries
+AC_DEFUN([AC_LIBTOOL_GCJ],
+[AC_REQUIRE([_LT_AC_LANG_GCJ])
+])# AC_LIBTOOL_GCJ
+
+
+# _LT_AC_LANG_GCJ
+# ---------------
+AC_DEFUN([_LT_AC_LANG_GCJ],
+[AC_PROVIDE_IFELSE([AC_PROG_GCJ],[],
+  [AC_PROVIDE_IFELSE([A][M_PROG_GCJ],[],
+    [AC_PROVIDE_IFELSE([LT_AC_PROG_GCJ],[],
+      [ifdef([AC_PROG_GCJ],[AC_REQUIRE([AC_PROG_GCJ])],
+        [ifdef([A][M_PROG_GCJ],[AC_REQUIRE([A][M_PROG_GCJ])],
+          [AC_REQUIRE([A][C_PROG_GCJ_OR_A][M_PROG_GCJ])])])])])])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}GCJ])
+])# _LT_AC_LANG_GCJ
+
+
+# AC_LIBTOOL_RC
+# --------------
+# enable support for Windows resource files
+AC_DEFUN([AC_LIBTOOL_RC],
+[AC_REQUIRE([LT_AC_PROG_RC])
+_LT_AC_SHELL_INIT([tagnames=${tagnames+${tagnames},}RC])
+])# AC_LIBTOOL_RC
+
+
+# AC_LIBTOOL_LANG_C_CONFIG
+# ------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_C_CONFIG], [_LT_AC_LANG_C_CONFIG])
+AC_DEFUN([_LT_AC_LANG_C_CONFIG],
+[lt_save_CC="$CC"
+AC_LANG_PUSH(C)
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}\n'
+
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+#
+# Check for any special shared library compilation flags.
+#
+_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)=
+if test "$GCC" = no; then
+  case $host_os in
+  sco3.2v5*)
+    _LT_AC_TAGVAR(lt_prog_cc_shlib, $1)='-belf'
+    ;;
+  esac
+fi
+if test -n "$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)"; then
+  AC_MSG_WARN([`$CC' requires `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to build shared libraries])
+  if echo "$old_CC $old_CFLAGS " | grep "[[    ]]$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)[[        ]]" >/dev/null; then :
+  else
+    AC_MSG_WARN([add `$_LT_AC_TAGVAR(lt_prog_cc_shlib, $1)' to the CC or CFLAGS env variable and reconfigure])
+    _LT_AC_TAGVAR(lt_cv_prog_cc_can_build_shared, $1)=no
+  fi
+fi
+
+
+#
+# Check to make sure the static flag actually works.
+#
+AC_LIBTOOL_LINKER_OPTION([if $compiler static flag $_LT_AC_TAGVAR(lt_prog_compiler_static, $1) works],
+  _LT_AC_TAGVAR(lt_prog_compiler_static_works, $1),
+  $_LT_AC_TAGVAR(lt_prog_compiler_static, $1),
+  [],
+  [_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=])
+
+
+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
+
+# Report which librarie types wil actually be built
+AC_MSG_CHECKING([if libtool supports shared libraries])
+AC_MSG_RESULT([$can_build_shared])
+
+AC_MSG_CHECKING([whether to build shared libraries])
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case $host_os in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+
+aix4* | aix5*)
+  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
+    ;;
+esac
+AC_MSG_RESULT([$enable_shared])
+
+AC_MSG_CHECKING([whether to build static libraries])
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+AC_MSG_RESULT([$enable_static])
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_C_CONFIG
+
+
+# AC_LIBTOOL_LANG_CXX_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_CXX_CONFIG], [_LT_AC_LANG_CXX_CONFIG(CXX)])
+AC_DEFUN([_LT_AC_LANG_CXX_CONFIG],
+[AC_LANG_PUSH(C++)
+AC_REQUIRE([AC_PROG_CXX])
+AC_REQUIRE([_LT_AC_PROG_CXXCPP])
+
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+_LT_AC_TAGVAR(always_export_symbols, $1)=no
+_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_direct, $1)=no
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+_LT_AC_TAGVAR(module_cmds, $1)=
+_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_AC_TAGVAR(no_undefined_flag, $1)=
+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Dependencies to place before and after the object being linked:
+_LT_AC_TAGVAR(predep_objects, $1)=
+_LT_AC_TAGVAR(postdep_objects, $1)=
+_LT_AC_TAGVAR(predeps, $1)=
+_LT_AC_TAGVAR(postdeps, $1)=
+_LT_AC_TAGVAR(compiler_lib_search_path, $1)=
+
+# Source file extension for C++ test sources.
+ac_ext=cpp
+
+# Object file extension for compiled C++ test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(int, char *[]) { return(0); }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC=$CC
+lt_save_LD=$LD
+lt_save_GCC=$GCC
+GCC=$GXX
+lt_save_with_gnu_ld=$with_gnu_ld
+lt_save_path_LD=$lt_cv_path_LD
+if test -n "${lt_cv_prog_gnu_ldcxx+set}"; then
+  lt_cv_prog_gnu_ld=$lt_cv_prog_gnu_ldcxx
+else
+  unset lt_cv_prog_gnu_ld
+fi
+if test -n "${lt_cv_path_LDCXX+set}"; then
+  lt_cv_path_LD=$lt_cv_path_LDCXX
+else
+  unset lt_cv_path_LD
+fi
+test -z "${LDCXX+set}" || LD=$LDCXX
+CC=${CXX-"c++"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+# We don't want -fno-exception wen compiling C++ code, so set the
+# no_builtin_flag separately
+if test "$GXX" = yes; then
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+else
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+fi
+
+if test "$GXX" = yes; then
+  # Set up default GNU C++ configuration
+
+  AC_PROG_LD
+
+  # Check if GNU C++ uses GNU ld as the underlying linker, since the
+  # archiving commands below assume that GNU ld is being used.
+  if test "$with_gnu_ld" = yes; then
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    # XXX I think wlarc can be eliminated in ltcf-cxx, but I need to
+    #     investigate it a little bit more. (MM)
+    wlarc='${wl}'
+
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if eval "`$CC -print-prog-name=ld` --help 2>&1" | \
+       grep 'no-whole-archive' > /dev/null; then
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    else
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    with_gnu_ld=no
+    wlarc=
+
+    # A generic and very simple default shared library creation
+    # command for GNU C++ for the case where it uses the native
+    # linker, instead of GNU ld.  If possible, this setting should
+    # overridden to take advantage of the native linker features on
+    # the platform it is being used on.
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+  fi
+
+  # Commands to make compiler produce verbose output that lists
+  # what "hidden" libraries, object files and flags are used when
+  # linking a shared library.
+  output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+else
+  GXX=no
+  with_gnu_ld=no
+  wlarc=
+fi
+
+# PORTME: fill in a description of your system's C++ link characteristics
+AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+_LT_AC_TAGVAR(ld_shlibs, $1)=yes
+case $host_os in
+  aix3*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  aix4* | aix5*)
+    if test "$host_cpu" = ia64; then
+      # On IA64, the linker does run time linking by default, so we don't
+      # have to do anything special.
+      aix_use_runtimelinking=no
+      exp_sym_flag='-Bexport'
+      no_entry_flag=""
+    else
+      aix_use_runtimelinking=no
+
+      # Test if we are trying to use run time linking or normal
+      # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+      # need to do runtime linking.
+      case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+       for ld_flag in $LDFLAGS; do
+         case $ld_flag in
+         *-brtl*)
+           aix_use_runtimelinking=yes
+           break
+           ;;
+         esac
+       done
+      esac
+
+      exp_sym_flag='-bexport'
+      no_entry_flag='-bnoentry'
+    fi
+
+    # When large executables or shared objects are built, AIX ld can
+    # have problems creating the table of contents.  If linking a library
+    # or program results in "error TOC overflow" add -mminimal-toc to
+    # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+    # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+    _LT_AC_TAGVAR(archive_cmds, $1)=''
+    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+    _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+    if test "$GXX" = yes; then
+      case $host_os in aix4.[[012]]|aix4.[[012]].*)
+      # We only want to do this on AIX 4.2 and lower, the check
+      # below for broken collect2 doesn't work under 4.3+
+       collect2name=`${CC} -print-prog-name=collect2`
+       if test -f "$collect2name" && \
+          strings "$collect2name" | grep resolve_lib_name >/dev/null
+       then
+         # We have reworked collect2
+         _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+       else
+         # We have old collect2
+         _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+       fi
+      esac
+      shared_flag='-shared'
+      if test "$aix_use_runtimelinking" = yes; then
+       shared_flag="$shared_flag "'${wl}-G'
+      fi
+    else
+      # not using gcc
+      if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+       shared_flag='-G'
+      else
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag='${wl}-G'
+       else
+         shared_flag='${wl}-bM:SRE'
+       fi
+      fi
+    fi
+
+    # It seems that -bexpall does not export symbols beginning with
+    # underscore (_), so it is better to generate a list of symbols to export.
+    _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+    if test "$aix_use_runtimelinking" = yes; then
+      # Warning - without using the other runtime loading flags (-brtl),
+      # -berok will link without error, but may produce a broken library.
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+      # Determine the default libpath from the value encoded in an empty executable.
+      _LT_AC_SYS_LIBPATH_AIX
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+     else
+      if test "$host_cpu" = ia64; then
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+      else
+       # Determine the default libpath from the value encoded in an empty executable.
+       _LT_AC_SYS_LIBPATH_AIX
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+       # Warning - without using the other run time loading flags,
+       # -berok will link without error, but may produce a broken library.
+       _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+       # -bexpall does not export symbols beginning with underscore (_)
+       _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+       # Exported symbols can be pulled into shared objects from archives
+       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
+       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+       # This is similar to how AIX traditionally builds its shared libraries.
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+      fi
+    fi
+    ;;
+  chorus*)
+    case $cc_basename in
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+
+
+  cygwin* | mingw* | pw32*)
+    # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+    # as there is no search path for DLLs.
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+    _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+    _LT_AC_TAGVAR(always_export_symbols, $1)=no
+    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+
+    if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+      # If the export-symbols file already is a .def file (1st line
+      # is EXPORTS), use it as is; otherwise, prepend...
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+       cp $export_symbols $output_objdir/$soname.def;
+      else
+       echo EXPORTS > $output_objdir/$soname.def;
+       cat $export_symbols >> $output_objdir/$soname.def;
+      fi~
+      $CC -shared -nostdlib $output_objdir/$soname.def $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+    else
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    fi
+  ;;
+      darwin* | rhapsody*)
+        case $host_os in
+        rhapsody* | darwin1.[[012]])
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[[012]])
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+        esac
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+    if test "$GXX" = yes ; then
+      lt_int_apple_cc_single_mod=no
+      output_verbose_link_cmd='echo'
+      if $CC -dumpspecs 2>&1 | $EGREP 'single_module' >/dev/null ; then
+       lt_int_apple_cc_single_mod=yes
+      fi
+      if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      else
+          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+        fi
+        _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+        # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          if test "X$lt_int_apple_cc_single_mod" = Xyes ; then
+            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib -single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          else
+            _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -r -keep_private_externs -nostdlib -o ${lib}-master.o $libobjs~$CC -dynamiclib $allow_undefined_flag -o $lib ${lib}-master.o $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          fi
+            _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+          _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+          _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj ${wl}-single_module $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+          ;;
+      esac
+      fi
+        ;;
+
+  dgux*)
+    case $cc_basename in
+      ec++*)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      ghcx*)
+       # Green Hills C++ Compiler
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+  freebsd[[12]]*)
+    # C++ shared libraries reported to be fairly broken before switch to ELF
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  freebsd-elf*)
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    ;;
+  freebsd* | kfreebsd*-gnu | dragonfly*)
+    # FreeBSD 3 and later use GNU C++ and GNU ld with standard ELF
+    # conventions
+    _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+    ;;
+  gnu*)
+    ;;
+  hpux9*)
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+    _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+                               # but as the default
+                               # location of the library.
+
+    case $cc_basename in
+    CC*)
+      # FIXME: insert proper C++ library support
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    aCC*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -b ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      # Commands to make compiler produce verbose output that lists
+      # what "hidden" libraries, object files and flags are used when
+      # linking a shared library.
+      #
+      # There doesn't appear to be a way to prevent this compiler from
+      # explicitly linking system object files so we need to strip them
+      # from the output so that they don't get included in the library
+      # dependencies.
+      output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "[[-]]L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+      ;;
+    *)
+      if test "$GXX" = yes; then
+        _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -nostdlib -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+        # FIXME: insert proper C++ library support
+        _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+    ;;
+  hpux10*|hpux11*)
+    if test $with_gnu_ld = no; then
+      case $host_cpu in
+      hppa*64*)
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+        ;;
+      ia64*)
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+        ;;
+      *)
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+        ;;
+      esac
+    fi
+    case $host_cpu in
+    hppa*64*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+    ia64*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+                                             # but as the default
+                                             # location of the library.
+      ;;
+    *)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes # Not in the search PATH,
+                                             # but as the default
+                                             # location of the library.
+      ;;
+    esac
+
+    case $cc_basename in
+      CC*)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      aCC*)
+       case $host_cpu in
+       hppa*64*|ia64*)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+         ;;
+       *)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -b ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+         ;;
+       esac
+       # Commands to make compiler produce verbose output that lists
+       # what "hidden" libraries, object files and flags are used when
+       # linking a shared library.
+       #
+       # There doesn't appear to be a way to prevent this compiler from
+       # explicitly linking system object files so we need to strip them
+       # from the output so that they don't get included in the library
+       # dependencies.
+       output_verbose_link_cmd='templist=`($CC -b $CFLAGS -v conftest.$objext 2>&1) | grep "\-L"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+       ;;
+      *)
+       if test "$GXX" = yes; then
+         if test $with_gnu_ld = no; then
+           case $host_cpu in
+           ia64*|hppa*64*)
+             _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $linker_flags $libobjs $deplibs'
+             ;;
+           *)
+             _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+             ;;
+           esac
+         fi
+       else
+         # FIXME: insert proper C++ library support
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       fi
+       ;;
+    esac
+    ;;
+  irix5* | irix6*)
+    case $cc_basename in
+      CC*)
+       # SGI C++
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -all -multigot $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+
+       # Archives containing C++ object files must be created using
+       # "CC -ar", where "CC" is the IRIX C++ compiler.  This is
+       # necessary to make sure instantiated templates are included
+       # in the archive.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -ar -WR,-u -o $oldlib $oldobjs'
+       ;;
+      *)
+       if test "$GXX" = yes; then
+         if test "$with_gnu_ld" = no; then
+           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+         else
+           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` -o $lib'
+         fi
+       fi
+       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+       ;;
+    esac
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+    ;;
+  linux*)
+    case $cc_basename in
+      KCC*)
+       # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+       # KCC will only create a shared library if the output file
+       # ends with ".so" (or ".sl" for HP-UX), so rename the library
+       # to its proper name (with version) after linking.
+       _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib ${wl}-retain-symbols-file,$export_symbols; mv \$templib $lib'
+       # Commands to make compiler produce verbose output that lists
+       # what "hidden" libraries, object files and flags are used when
+       # linking a shared library.
+       #
+       # There doesn't appear to be a way to prevent this compiler from
+       # explicitly linking system object files so we need to strip them
+       # from the output so that they don't get included in the library
+       # dependencies.
+       output_verbose_link_cmd='templist=`$CC $CFLAGS -v conftest.$objext -o libconftest$shared_ext 2>&1 | grep "ld"`; rm -f libconftest$shared_ext; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath,$libdir'
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+
+       # Archives containing C++ object files must be created using
+       # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+       ;;
+      icpc*)
+       # Intel C++
+       with_gnu_ld=yes
+       # version 8.0 and above of icpc choke on multiply defined symbols
+       # if we add $predep_objects and $postdep_objects, however 7.1 and
+       # earlier do not add the objects themselves.
+       case `$CC -V 2>&1` in
+       *"Version 7."*)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+         ;;
+       *)  # Version 8.0 or newer
+         tmp_idyn=
+         case $host_cpu in
+           ia64*) tmp_idyn=' -i_dynamic';;
+         esac
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared'"$tmp_idyn"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+         ;;
+       esac
+       _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive$convenience ${wl}--no-whole-archive'
+       ;;
+      pgCC*)
+        # Portland Group C++ compiler
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname ${wl}-retain-symbols-file ${wl}$export_symbols -o $lib'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+        ;;
+      cxx*)
+       # Compaq C++
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $wl$soname  -o $lib ${wl}-retain-symbols-file $wl$export_symbols'
+
+       runpath_var=LD_RUN_PATH
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       # Commands to make compiler produce verbose output that lists
+       # what "hidden" libraries, object files and flags are used when
+       # linking a shared library.
+       #
+       # There doesn't appear to be a way to prevent this compiler from
+       # explicitly linking system object files so we need to strip them
+       # from the output so that they don't get included in the library
+       # dependencies.
+       output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld .*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+       ;;
+    esac
+    ;;
+  lynxos*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  m88k*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  mvs*)
+    case $cc_basename in
+      cxx*)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+  netbsd*)
+    if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable  -o $lib $predep_objects $libobjs $deplibs $postdep_objects $linker_flags'
+      wlarc=
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    fi
+    # Workaround some broken pre-1.5 toolchains
+    output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep conftest.$objext | $SED -e "s:-lgcc -lc -lgcc::"'
+    ;;
+  openbsd2*)
+    # C++ shared libraries are fairly broken
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  openbsd*)
+    _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+    _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+    _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -o $lib'
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+    if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-retain-symbols-file,$export_symbols -o $lib'
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+    fi
+    output_verbose_link_cmd='echo'
+    ;;
+  osf3*)
+    case $cc_basename in
+      KCC*)
+       # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+       # KCC will only create a shared library if the output file
+       # ends with ".so" (or ".sl" for HP-UX), so rename the library
+       # to its proper name (with version) after linking.
+       _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       # Archives containing C++ object files must be created using
+       # "CC -Bstatic", where "CC" is the KAI C++ compiler.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -Bstatic -o $oldlib $oldobjs'
+
+       ;;
+      RCC*)
+       # Rational C++ 2.4.1
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      cxx*)
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname $soname `test -n "$verstring" && echo ${wl}-set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       # Commands to make compiler produce verbose output that lists
+       # what "hidden" libraries, object files and flags are used when
+       # linking a shared library.
+       #
+       # There doesn't appear to be a way to prevent this compiler from
+       # explicitly linking system object files so we need to strip them
+       # from the output so that they don't get included in the library
+       # dependencies.
+       output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+       ;;
+      *)
+       if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+         # Commands to make compiler produce verbose output that lists
+         # what "hidden" libraries, object files and flags are used when
+         # linking a shared library.
+         output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+       else
+         # FIXME: insert proper C++ library support
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       fi
+       ;;
+    esac
+    ;;
+  osf4* | osf5*)
+    case $cc_basename in
+      KCC*)
+       # Kuck and Associates, Inc. (KAI) C++ Compiler
+
+       # KCC will only create a shared library if the output file
+       # ends with ".so" (or ".sl" for HP-UX), so rename the library
+       # to its proper name (with version) after linking.
+       _LT_AC_TAGVAR(archive_cmds, $1)='tempext=`echo $shared_ext | $SED -e '\''s/\([[^()0-9A-Za-z{}]]\)/\\\\\1/g'\''`; templib=`echo $lib | $SED -e "s/\${tempext}\..*/.so/"`; $CC $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags --soname $soname -o \$templib; mv \$templib $lib'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       # Archives containing C++ object files must be created using
+       # the KAI C++ compiler.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -o $oldlib $oldobjs'
+       ;;
+      RCC*)
+       # Rational C++ 2.4.1
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      cxx*)
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done~
+         echo "-hidden">> $lib.exp~
+         $CC -shared$allow_undefined_flag $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags -msym -soname $soname -Wl,-input -Wl,$lib.exp  `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~
+         $rm $lib.exp'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+       _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+       # Commands to make compiler produce verbose output that lists
+       # what "hidden" libraries, object files and flags are used when
+       # linking a shared library.
+       #
+       # There doesn't appear to be a way to prevent this compiler from
+       # explicitly linking system object files so we need to strip them
+       # from the output so that they don't get included in the library
+       # dependencies.
+       output_verbose_link_cmd='templist=`$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "ld" | grep -v "ld:"`; templist=`echo $templist | $SED "s/\(^.*ld.*\)\( .*ld.*$\)/\1/"`; list=""; for z in $templist; do case $z in conftest.$objext) list="$list $z";; *.$objext);; *) list="$list $z";;esac; done; echo $list'
+       ;;
+      *)
+       if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib ${allow_undefined_flag} $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+
+         # Commands to make compiler produce verbose output that lists
+         # what "hidden" libraries, object files and flags are used when
+         # linking a shared library.
+         output_verbose_link_cmd='$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep "\-L"'
+
+       else
+         # FIXME: insert proper C++ library support
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       fi
+       ;;
+    esac
+    ;;
+  psos*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  sco*)
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    case $cc_basename in
+      CC*)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+  sunos4*)
+    case $cc_basename in
+      CC*)
+       # Sun C++ 4.x
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      lcc*)
+       # Lucid
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+  solaris*)
+    case $cc_basename in
+      CC*)
+       # Sun C++ 4.2, 5.x and Centerline C++
+        _LT_AC_TAGVAR(archive_cmds_need_lc,$1)=yes
+       _LT_AC_TAGVAR(no_undefined_flag, $1)=' -zdefs'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G${allow_undefined_flag}  -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+       $CC -G${allow_undefined_flag}  ${wl}-M ${wl}$lib.exp -h$soname -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+       case $host_os in
+         solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+         *)
+           # The C++ compiler is used as linker so we must use $wl
+           # flag to pass the commands to the underlying system
+           # linker. We must also pass each convience library through
+           # to the system linker between allextract/defaultextract.
+           # The C++ compiler will combine linker options so we
+           # cannot just pass the convience library names through
+           # without $wl.
+           # Supported since Solaris 2.6 (maybe 2.5.1?)
+           _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract'
+           ;;
+       esac
+       _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+       output_verbose_link_cmd='echo'
+
+       # Archives containing C++ object files must be created using
+       # "CC -xar", where "CC" is the Sun C++ compiler.  This is
+       # necessary to make sure instantiated templates are included
+       # in the archive.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC -xar -o $oldlib $oldobjs'
+       ;;
+      gcx*)
+       # Green Hills C++ Compiler
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+
+       # The C++ compiler must be used to create the archive.
+       _LT_AC_TAGVAR(old_archive_cmds, $1)='$CC $LDFLAGS -archive -o $oldlib $oldobjs'
+       ;;
+      *)
+       # GNU C++ compiler with Solaris linker
+       if test "$GXX" = yes && test "$with_gnu_ld" = no; then
+         _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-z ${wl}defs'
+         if $CC --version | grep -v '^2\.7' > /dev/null; then
+           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+           _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $CC -shared -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           output_verbose_link_cmd="$CC -shared $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+         else
+           # g++ 2.7 appears to require `-G' NOT `-shared' on this
+           # platform.
+           _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G -nostdlib $LDFLAGS $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags ${wl}-h $wl$soname -o $lib'
+           _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $CC -G -nostdlib ${wl}-M $wl$lib.exp -o $lib $predep_objects $libobjs $deplibs $postdep_objects $compiler_flags~$rm $lib.exp'
+
+           # Commands to make compiler produce verbose output that lists
+           # what "hidden" libraries, object files and flags are used when
+           # linking a shared library.
+           output_verbose_link_cmd="$CC -G $CFLAGS -v conftest.$objext 2>&1 | grep \"\-L\""
+         fi
+
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $wl$libdir'
+       fi
+       ;;
+    esac
+    ;;
+  sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[[78]]* | unixware7*)
+    _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+    ;;
+  tandem*)
+    case $cc_basename in
+      NCC*)
+       # NonStop-UX NCC 3.20
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+      *)
+       # FIXME: insert proper C++ library support
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       ;;
+    esac
+    ;;
+  vxworks*)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+  *)
+    # FIXME: insert proper C++ library support
+    _LT_AC_TAGVAR(ld_shlibs, $1)=no
+    ;;
+esac
+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_AC_TAGVAR(GCC, $1)="$GXX"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+AC_LIBTOOL_POSTDEP_PREDEP($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC=$lt_save_CC
+LDCXX=$LD
+LD=$lt_save_LD
+GCC=$lt_save_GCC
+with_gnu_ldcxx=$with_gnu_ld
+with_gnu_ld=$lt_save_with_gnu_ld
+lt_cv_path_LDCXX=$lt_cv_path_LD
+lt_cv_path_LD=$lt_save_path_LD
+lt_cv_prog_gnu_ldcxx=$lt_cv_prog_gnu_ld
+lt_cv_prog_gnu_ld=$lt_save_with_gnu_ld
+])# AC_LIBTOOL_LANG_CXX_CONFIG
+
+# AC_LIBTOOL_POSTDEP_PREDEP([TAGNAME])
+# ------------------------
+# Figure out "hidden" library dependencies from verbose
+# compiler output when linking a shared library.
+# Parse the compiler output and extract the necessary
+# objects, libraries and library flags.
+AC_DEFUN([AC_LIBTOOL_POSTDEP_PREDEP],[
+dnl we can't use the lt_simple_compile_test_code here,
+dnl because it contains code intended for an executable,
+dnl not a library.  It's possible we should let each
+dnl tag define a new lt_????_link_test_code variable,
+dnl but it's only used here...
+ifelse([$1],[],[cat > conftest.$ac_ext <<EOF
+int a;
+void foo (void) { a = 0; }
+EOF
+],[$1],[CXX],[cat > conftest.$ac_ext <<EOF
+class Foo
+{
+public:
+  Foo (void) { a = 0; }
+private:
+  int a;
+};
+EOF
+],[$1],[F77],[cat > conftest.$ac_ext <<EOF
+      subroutine foo
+      implicit none
+      integer*4 a
+      a=0
+      return
+      end
+EOF
+],[$1],[GCJ],[cat > conftest.$ac_ext <<EOF
+public class foo {
+  private int a;
+  public void bar (void) {
+    a = 0;
+  }
+};
+EOF
+])
+dnl Parse the compiler output and extract the necessary
+dnl objects, libraries and library flags.
+if AC_TRY_EVAL(ac_compile); then
+  # Parse the compiler output and extract the necessary
+  # objects, libraries and library flags.
+
+  # Sentinel used to keep track of whether or not we are before
+  # the conftest object file.
+  pre_test_object_deps_done=no
+
+  # The `*' in the case matches for architectures that use `case' in
+  # $output_verbose_cmd can trigger glob expansion during the loop
+  # eval without this substitution.
+  output_verbose_link_cmd=`$echo "X$output_verbose_link_cmd" | $Xsed -e "$no_glob_subst"`
+
+  for p in `eval $output_verbose_link_cmd`; do
+    case $p in
+
+    -L* | -R* | -l*)
+       # Some compilers place space between "-{L,R}" and the path.
+       # Remove the space.
+       if test $p = "-L" \
+         || test $p = "-R"; then
+        prev=$p
+        continue
+       else
+        prev=
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+        case $p in
+        -L* | -R*)
+          # Internal compiler library paths should come after those
+          # provided the user.  The postdeps already come after the
+          # user supplied libs so there is no need to process them.
+          if test -z "$_LT_AC_TAGVAR(compiler_lib_search_path, $1)"; then
+            _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${prev}${p}"
+          else
+            _LT_AC_TAGVAR(compiler_lib_search_path, $1)="${_LT_AC_TAGVAR(compiler_lib_search_path, $1)} ${prev}${p}"
+          fi
+          ;;
+        # The "-l" case would never come before the object being
+        # linked, so don't bother handling this case.
+        esac
+       else
+        if test -z "$_LT_AC_TAGVAR(postdeps, $1)"; then
+          _LT_AC_TAGVAR(postdeps, $1)="${prev}${p}"
+        else
+          _LT_AC_TAGVAR(postdeps, $1)="${_LT_AC_TAGVAR(postdeps, $1)} ${prev}${p}"
+        fi
+       fi
+       ;;
+
+    *.$objext)
+       # This assumes that the test object file only shows up
+       # once in the compiler output.
+       if test "$p" = "conftest.$objext"; then
+        pre_test_object_deps_done=yes
+        continue
+       fi
+
+       if test "$pre_test_object_deps_done" = no; then
+        if test -z "$_LT_AC_TAGVAR(predep_objects, $1)"; then
+          _LT_AC_TAGVAR(predep_objects, $1)="$p"
+        else
+          _LT_AC_TAGVAR(predep_objects, $1)="$_LT_AC_TAGVAR(predep_objects, $1) $p"
+        fi
+       else
+        if test -z "$_LT_AC_TAGVAR(postdep_objects, $1)"; then
+          _LT_AC_TAGVAR(postdep_objects, $1)="$p"
+        else
+          _LT_AC_TAGVAR(postdep_objects, $1)="$_LT_AC_TAGVAR(postdep_objects, $1) $p"
+        fi
+       fi
+       ;;
+
+    *) ;; # Ignore the rest.
+
+    esac
+  done
+
+  # Clean up.
+  rm -f a.out a.exe
+else
+  echo "libtool.m4: error: problem compiling $1 test program"
+fi
+
+$rm -f confest.$objext
+
+# PORTME: override above test on systems where it is broken
+ifelse([$1],[CXX],
+[case $host_os in
+solaris*)
+  case $cc_basename in
+  CC*)
+    # Adding this requires a known-good setup of shared libraries for
+    # Sun compiler versions before 5.6, else PIC objects from an old
+    # archive will be linked into the output, leading to subtle bugs.
+    _LT_AC_TAGVAR(postdeps,$1)='-lCstd -lCrun'
+    ;;
+  esac
+esac
+])
+
+case " $_LT_AC_TAGVAR(postdeps, $1) " in
+*" -lc "*) _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no ;;
+esac
+])# AC_LIBTOOL_POSTDEP_PREDEP
+
+# AC_LIBTOOL_LANG_F77_CONFIG
+# ------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_F77_CONFIG], [_LT_AC_LANG_F77_CONFIG(F77)])
+AC_DEFUN([_LT_AC_LANG_F77_CONFIG],
+[AC_REQUIRE([AC_PROG_F77])
+AC_LANG_PUSH(Fortran 77)
+
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+_LT_AC_TAGVAR(allow_undefined_flag, $1)=
+_LT_AC_TAGVAR(always_export_symbols, $1)=no
+_LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_direct, $1)=no
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+_LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+_LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+_LT_AC_TAGVAR(hardcode_automatic, $1)=no
+_LT_AC_TAGVAR(module_cmds, $1)=
+_LT_AC_TAGVAR(module_expsym_cmds, $1)=
+_LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+_LT_AC_TAGVAR(no_undefined_flag, $1)=
+_LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+
+# Source file extension for f77 test sources.
+ac_ext=f
+
+# Object file extension for compiled f77 test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="      subroutine t\n      return\n      end\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="      program t\n      end\n"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${F77-"f77"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+AC_MSG_CHECKING([if libtool supports shared libraries])
+AC_MSG_RESULT([$can_build_shared])
+
+AC_MSG_CHECKING([whether to build shared libraries])
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case $host_os in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+aix4* | aix5*)
+  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
+  ;;
+esac
+AC_MSG_RESULT([$enable_shared])
+
+AC_MSG_CHECKING([whether to build static libraries])
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+AC_MSG_RESULT([$enable_static])
+
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+_LT_AC_TAGVAR(GCC, $1)="$G77"
+_LT_AC_TAGVAR(LD, $1)="$LD"
+
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_POP
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_F77_CONFIG
+
+
+# AC_LIBTOOL_LANG_GCJ_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the C compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_GCJ_CONFIG], [_LT_AC_LANG_GCJ_CONFIG(GCJ)])
+AC_DEFUN([_LT_AC_LANG_GCJ_CONFIG],
+[AC_LANG_SAVE
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[[]] argv) {}; }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${GCJ-"gcj"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+_LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+
+_LT_AC_TAGVAR(old_archive_cmds, $1)=$old_archive_cmds
+
+AC_LIBTOOL_PROG_COMPILER_NO_RTTI($1)
+AC_LIBTOOL_PROG_COMPILER_PIC($1)
+AC_LIBTOOL_PROG_CC_C_O($1)
+AC_LIBTOOL_SYS_HARD_LINK_LOCKS($1)
+AC_LIBTOOL_PROG_LD_SHLIBS($1)
+AC_LIBTOOL_SYS_DYNAMIC_LINKER($1)
+AC_LIBTOOL_PROG_LD_HARDCODE_LIBPATH($1)
+AC_LIBTOOL_SYS_LIB_STRIP
+AC_LIBTOOL_DLOPEN_SELF($1)
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_GCJ_CONFIG
+
+
+# AC_LIBTOOL_LANG_RC_CONFIG
+# --------------------------
+# Ensure that the configuration vars for the Windows resource compiler are
+# suitably defined.  Those variables are subsequently used by
+# AC_LIBTOOL_CONFIG to write the compiler configuration to `libtool'.
+AC_DEFUN([AC_LIBTOOL_LANG_RC_CONFIG], [_LT_AC_LANG_RC_CONFIG(RC)])
+AC_DEFUN([_LT_AC_LANG_RC_CONFIG],
+[AC_LANG_SAVE
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+_LT_AC_TAGVAR(objext, $1)=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+_LT_AC_SYS_COMPILER
+
+# save warnings/boilerplate of simple test code
+_LT_COMPILER_BOILERPLATE
+_LT_LINKER_BOILERPLATE
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${RC-"windres"}
+compiler=$CC
+_LT_AC_TAGVAR(compiler, $1)=$CC
+_LT_CC_BASENAME([$compiler])
+_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)=yes
+
+AC_LIBTOOL_CONFIG($1)
+
+AC_LANG_RESTORE
+CC="$lt_save_CC"
+])# AC_LIBTOOL_LANG_RC_CONFIG
+
+
+# AC_LIBTOOL_CONFIG([TAGNAME])
+# ----------------------------
+# If TAGNAME is not passed, then create an initial libtool script
+# with a default configuration from the untagged config vars.  Otherwise
+# add code to config.status for appending the configuration named by
+# TAGNAME from the matching tagged config vars.
+AC_DEFUN([AC_LIBTOOL_CONFIG],
+[# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    _LT_AC_TAGVAR(compiler, $1) \
+    _LT_AC_TAGVAR(CC, $1) \
+    _LT_AC_TAGVAR(LD, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1) \
+    _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) \
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1) \
+    _LT_AC_TAGVAR(thread_safe_flag_spec, $1) \
+    _LT_AC_TAGVAR(whole_archive_flag_spec, $1) \
+    _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1) \
+    _LT_AC_TAGVAR(old_archive_cmds, $1) \
+    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) \
+    _LT_AC_TAGVAR(predep_objects, $1) \
+    _LT_AC_TAGVAR(postdep_objects, $1) \
+    _LT_AC_TAGVAR(predeps, $1) \
+    _LT_AC_TAGVAR(postdeps, $1) \
+    _LT_AC_TAGVAR(compiler_lib_search_path, $1) \
+    _LT_AC_TAGVAR(archive_cmds, $1) \
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1) \
+    _LT_AC_TAGVAR(postinstall_cmds, $1) \
+    _LT_AC_TAGVAR(postuninstall_cmds, $1) \
+    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) \
+    _LT_AC_TAGVAR(allow_undefined_flag, $1) \
+    _LT_AC_TAGVAR(no_undefined_flag, $1) \
+    _LT_AC_TAGVAR(export_symbols_cmds, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1) \
+    _LT_AC_TAGVAR(hardcode_libdir_separator, $1) \
+    _LT_AC_TAGVAR(hardcode_automatic, $1) \
+    _LT_AC_TAGVAR(module_cmds, $1) \
+    _LT_AC_TAGVAR(module_expsym_cmds, $1) \
+    _LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1) \
+    _LT_AC_TAGVAR(exclude_expsyms, $1) \
+    _LT_AC_TAGVAR(include_expsyms, $1); do
+
+    case $var in
+    _LT_AC_TAGVAR(old_archive_cmds, $1) | \
+    _LT_AC_TAGVAR(old_archive_from_new_cmds, $1) | \
+    _LT_AC_TAGVAR(archive_cmds, $1) | \
+    _LT_AC_TAGVAR(archive_expsym_cmds, $1) | \
+    _LT_AC_TAGVAR(module_cmds, $1) | \
+    _LT_AC_TAGVAR(module_expsym_cmds, $1) | \
+    _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1) | \
+    _LT_AC_TAGVAR(export_symbols_cmds, $1) | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case $lt_echo in
+  *'\[$]0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\[$]0 --fallback-echo"[$]/[$]0 --fallback-echo"/'`
+    ;;
+  esac
+
+ifelse([$1], [],
+  [cfgfile="${ofile}T"
+  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+  $rm -f "$cfgfile"
+  AC_MSG_NOTICE([creating $ofile])],
+  [cfgfile="$ofile"])
+
+  cat <<__EOF__ >> "$cfgfile"
+ifelse([$1], [],
+[#! $SHELL
+
+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool:
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="$SED -e 1s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# The names of the tagged configurations supported by this script.
+available_tags=
+
+# ### BEGIN LIBTOOL CONFIG],
+[# ### BEGIN LIBTOOL TAG CONFIG: $tagname])
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$_LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_[]_LT_AC_TAGVAR(compiler, $1)
+
+# Is the compiler the GNU C compiler?
+with_gcc=$_LT_AC_TAGVAR(GCC, $1)
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_[]_LT_AC_TAGVAR(LD, $1)
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_[]_LT_AC_TAGVAR(lt_cv_prog_compiler_c_o, $1)
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_static, $1)
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_[]_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_[]_LT_AC_TAGVAR(export_dynamic_flag_spec, $1)
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_[]_LT_AC_TAGVAR(whole_archive_flag_spec, $1)
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_[]_LT_AC_TAGVAR(thread_safe_flag_spec, $1)
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_cmds, $1)
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_new_cmds, $1)
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_[]_LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_[]_LT_AC_TAGVAR(archive_cmds, $1)
+archive_expsym_cmds=$lt_[]_LT_AC_TAGVAR(archive_expsym_cmds, $1)
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_[]_LT_AC_TAGVAR(module_cmds, $1)
+module_expsym_cmds=$lt_[]_LT_AC_TAGVAR(module_expsym_cmds, $1)
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_[]_LT_AC_TAGVAR(predep_objects, $1)
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_[]_LT_AC_TAGVAR(postdep_objects, $1)
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_[]_LT_AC_TAGVAR(predeps, $1)
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_[]_LT_AC_TAGVAR(postdeps, $1)
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_[]_LT_AC_TAGVAR(compiler_lib_search_path, $1)
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_[]_LT_AC_TAGVAR(allow_undefined_flag, $1)
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_[]_LT_AC_TAGVAR(no_undefined_flag, $1)
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$_LT_AC_TAGVAR(hardcode_action, $1)
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_[]_LT_AC_TAGVAR(hardcode_libdir_separator, $1)
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$_LT_AC_TAGVAR(hardcode_direct, $1)
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$_LT_AC_TAGVAR(hardcode_minus_L, $1)
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$_LT_AC_TAGVAR(hardcode_shlibpath_var, $1)
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$_LT_AC_TAGVAR(hardcode_automatic, $1)
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$_LT_AC_TAGVAR(link_all_deplibs, $1)
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$_LT_AC_TAGVAR(fix_srcfile_path, $1)"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$_LT_AC_TAGVAR(always_export_symbols, $1)
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_[]_LT_AC_TAGVAR(export_symbols_cmds, $1)
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_[]_LT_AC_TAGVAR(exclude_expsyms, $1)
+
+# Symbols that must always be exported.
+include_expsyms=$lt_[]_LT_AC_TAGVAR(include_expsyms, $1)
+
+ifelse([$1],[],
+[# ### END LIBTOOL CONFIG],
+[# ### END LIBTOOL TAG CONFIG: $tagname])
+
+__EOF__
+
+ifelse([$1],[], [
+  case $host_os in
+  aix3*)
+    cat <<\EOF >> "$cfgfile"
+
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+EOF
+    ;;
+  esac
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" || \
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+])
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
+])# AC_LIBTOOL_CONFIG
+
+
+# AC_LIBTOOL_PROG_COMPILER_NO_RTTI([TAGNAME])
+# -------------------------------------------
+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_NO_RTTI],
+[AC_REQUIRE([_LT_AC_SYS_COMPILER])dnl
+
+_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=
+
+if test "$GCC" = yes; then
+  _LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)=' -fno-builtin'
+
+  AC_LIBTOOL_COMPILER_OPTION([if $compiler supports -fno-rtti -fno-exceptions],
+    lt_cv_prog_compiler_rtti_exceptions,
+    [-fno-rtti -fno-exceptions], [],
+    [_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1) -fno-rtti -fno-exceptions"])
+fi
+])# AC_LIBTOOL_PROG_COMPILER_NO_RTTI
+
+
+# AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+# ---------------------------------
+AC_DEFUN([AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE],
+[AC_REQUIRE([AC_CANONICAL_HOST])
+AC_REQUIRE([AC_PROG_NM])
+AC_REQUIRE([AC_OBJEXT])
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+AC_MSG_CHECKING([command to parse $NM output from $compiler object])
+AC_CACHE_VAL([lt_cv_sys_global_symbol_pipe],
+[
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[[BCDEGRST]]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([[_A-Za-z]][[_A-Za-z0-9]]*\)'
+
+# Transform an extracted symbol line into a proper C declaration
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[[BCDT]]'
+  ;;
+cygwin* | mingw* | pw32*)
+  symcode='[[ABCDGISTW]]'
+  ;;
+hpux*) # Its linker distinguishes data from code symbols
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDEGRST]]'
+  fi
+  lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  ;;
+linux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[[ABCDGIRSTW]]'
+    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([[^ ]]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([[^ ]]*\) \([[^ ]]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[[BCDEGRST]]'
+  ;;
+osf*)
+  symcode='[[BCDEGQRST]]'
+  ;;
+solaris* | sysv5*)
+  symcode='[[BDRT]]'
+  ;;
+sysv4)
+  symcode='[[DFNSTU]]'
+  ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[[ABCDGIRSTW]]' ;;
+esac
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[[     ]]\($symcode$symcode*\)[[       ]][[    ]]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+  if AC_TRY_EVAL(ac_compile); then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if AC_TRY_EVAL(NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+      else
+       rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if grep ' nm_test_var$' "$nlist" >/dev/null; then
+       if grep ' nm_test_func$' "$nlist" >/dev/null; then
+         cat <<EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+         # Now generate the symbol file.
+         eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+
+         cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[[]] =
+{
+EOF
+         $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+         cat <<\EOF >> conftest.$ac_ext
+  {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+         # Now try linking the two files.
+         mv conftest.$ac_objext conftstm.$ac_objext
+         lt_save_LIBS="$LIBS"
+         lt_save_CFLAGS="$CFLAGS"
+         LIBS="conftstm.$ac_objext"
+         CFLAGS="$CFLAGS$_LT_AC_TAGVAR(lt_prog_compiler_no_builtin_flag, $1)"
+         if AC_TRY_EVAL(ac_link) && test -s conftest${ac_exeext}; then
+           pipe_works=yes
+         fi
+         LIBS="$lt_save_LIBS"
+         CFLAGS="$lt_save_CFLAGS"
+       else
+         echo "cannot find nm_test_func in $nlist" >&AS_MESSAGE_LOG_FD
+       fi
+      else
+       echo "cannot find nm_test_var in $nlist" >&AS_MESSAGE_LOG_FD
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&AS_MESSAGE_LOG_FD
+    fi
+  else
+    echo "$progname: failed program was:" >&AS_MESSAGE_LOG_FD
+    cat conftest.$ac_ext >&5
+  fi
+  rm -f conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+])
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  AC_MSG_RESULT(failed)
+else
+  AC_MSG_RESULT(ok)
+fi
+]) # AC_LIBTOOL_SYS_GLOBAL_SYMBOL_PIPE
+
+
+# AC_LIBTOOL_PROG_COMPILER_PIC([TAGNAME])
+# ---------------------------------------
+AC_DEFUN([AC_LIBTOOL_PROG_COMPILER_PIC],
+[_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)=
+_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+_LT_AC_TAGVAR(lt_prog_compiler_static, $1)=
+
+AC_MSG_CHECKING([for $compiler option to produce PIC])
+ ifelse([$1],[CXX],[
+  # C++ specific cases for pic, static, wl, etc.
+  if test "$GXX" = yes; then
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+    aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+      ;;
+    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+    mingw* | os2* | pw32*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      ;;
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+    *djgpp*)
+      # DJGPP does not support shared libraries at all
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+      ;;
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       ;;
+      *)
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       ;;
+      esac
+      ;;
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    case $host_os in
+      aix4* | aix5*)
+       # All AIX code is PIC.
+       if test "$host_cpu" = ia64; then
+         # AIX 5 now supports IA64 processor
+         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+       else
+         _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+       fi
+       ;;
+      chorus*)
+       case $cc_basename in
+       cxch68*)
+         # Green Hills C++ Compiler
+         # _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="--no_auto_instantiation -u __main -u __premain -u _abort -r $COOL_DIR/lib/libOrb.a $MVME_DIR/lib/CC/libC.a $MVME_DIR/lib/classix/libcx.s.a"
+         ;;
+       esac
+       ;;
+       darwin*)
+         # PIC is the default on this platform
+         # Common symbols not allowed in MH_DYLIB files
+         case $cc_basename in
+           xlc*)
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           ;;
+         esac
+       ;;
+      dgux*)
+       case $cc_basename in
+         ec++*)
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           ;;
+         ghcx*)
+           # Green Hills C++ Compiler
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      freebsd* | kfreebsd*-gnu | dragonfly*)
+       # FreeBSD uses GNU C++
+       ;;
+      hpux9* | hpux10* | hpux11*)
+       case $cc_basename in
+         CC*)
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+           if test "$host_cpu" != ia64; then
+             _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+           fi
+           ;;
+         aCC*)
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)="${ac_cv_prog_cc_wl}-a ${ac_cv_prog_cc_wl}archive"
+           case $host_cpu in
+           hppa*64*|ia64*)
+             # +Z the default
+             ;;
+           *)
+             _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+             ;;
+           esac
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      irix5* | irix6* | nonstopux*)
+       case $cc_basename in
+         CC*)
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           # CC pic flag -KPIC is the default.
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      linux*)
+       case $cc_basename in
+         KCC*)
+           # KAI C++ Compiler
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+           ;;
+         icpc* | ecpc*)
+           # Intel C++
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+           ;;
+         pgCC*)
+           # Portland Group C++ compiler.
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           ;;
+         cxx*)
+           # Compaq C++
+           # Make sure the PIC flag is empty.  It appears that all Alpha
+           # Linux and Compaq Tru64 Unix objects are PIC.
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      lynxos*)
+       ;;
+      m88k*)
+       ;;
+      mvs*)
+       case $cc_basename in
+         cxx*)
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-W c,exportall'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      netbsd*)
+       ;;
+      osf3* | osf4* | osf5*)
+       case $cc_basename in
+         KCC*)
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='--backend -Wl,'
+           ;;
+         RCC*)
+           # Rational C++ 2.4.1
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         cxx*)
+           # Digital/Compaq C++
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+           # Make sure the PIC flag is empty.  It appears that all Alpha
+           # Linux and Compaq Tru64 Unix objects are PIC.
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      psos*)
+       ;;
+      sco*)
+       case $cc_basename in
+         CC*)
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      solaris*)
+       case $cc_basename in
+         CC*)
+           # Sun C++ 4.2, 5.x and Centerline C++
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+           ;;
+         gcx*)
+           # Green Hills C++ Compiler
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      sunos4*)
+       case $cc_basename in
+         CC*)
+           # Sun C++ 4.x
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+           ;;
+         lcc*)
+           # Lucid
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      tandem*)
+       case $cc_basename in
+         NCC*)
+           # NonStop-UX NCC 3.20
+           _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+           ;;
+         *)
+           ;;
+       esac
+       ;;
+      unixware*)
+       ;;
+      vxworks*)
+       ;;
+      *)
+       _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+       ;;
+    esac
+  fi
+],
+[
+  if test "$GCC" = yes; then
+    _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+    _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fno-common'
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+       ;;
+      esac
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      else
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-qnocommon'
+         _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='+Z'
+       ;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # PIC (with -KPIC) is the default.
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    newsos6)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    linux*)
+      case $cc_basename in
+      icc* | ecc*)
+       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+       # which looks to be a dead project)
+       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-fpic'
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+        ;;
+      ccc*)
+        _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+        # All Alpha code is PIC.
+        _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+        ;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      # All OSF/1 code is PIC.
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-non_shared'
+      ;;
+
+    sco3.2v5*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kpic'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-dn'
+      ;;
+
+    solaris*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld ';;
+      *)
+       _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Qoption ld '
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-PIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-KPIC'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+       _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-Kconform_pic'
+       _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      fi
+      ;;
+
+    unicos*)
+      _LT_AC_TAGVAR(lt_prog_compiler_wl, $1)='-Wl,'
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+
+    uts4*)
+      _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)='-pic'
+      _LT_AC_TAGVAR(lt_prog_compiler_static, $1)='-Bstatic'
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no
+      ;;
+    esac
+  fi
+])
+AC_MSG_RESULT([$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)])
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)"; then
+  AC_LIBTOOL_COMPILER_OPTION([if $compiler PIC flag $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) works],
+    _LT_AC_TAGVAR(lt_prog_compiler_pic_works, $1),
+    [$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])], [],
+    [case $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1) in
+     "" | " "*) ;;
+     *) _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=" $_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)" ;;
+     esac],
+    [_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+     _LT_AC_TAGVAR(lt_prog_compiler_can_build_shared, $1)=no])
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)=
+    ;;
+  *)
+    _LT_AC_TAGVAR(lt_prog_compiler_pic, $1)="$_LT_AC_TAGVAR(lt_prog_compiler_pic, $1)ifelse([$1],[],[ -DPIC],[ifelse([$1],[CXX],[ -DPIC],[])])"
+    ;;
+esac
+])
+
+
+# AC_LIBTOOL_PROG_LD_SHLIBS([TAGNAME])
+# ------------------------------------
+# See if the linker supports building shared libraries.
+AC_DEFUN([AC_LIBTOOL_PROG_LD_SHLIBS],
+[AC_MSG_CHECKING([whether the $compiler linker ($LD) supports shared libraries])
+ifelse([$1],[CXX],[
+  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  case $host_os in
+  aix4* | aix5*)
+    # If we're using GNU nm, then we don't want the "-C" option.
+    # -C means demangle to AIX nm, but means don't demangle with GNU nm
+    if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+    else
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+    fi
+    ;;
+  pw32*)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)="$ltdll_cmds"
+  ;;
+  cygwin* | mingw*)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/;/^.* __nm__/s/^.* __nm__\([[^ ]]*\) [[^ ]]*/\1 DATA/;/^I /d;/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  *)
+    _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  ;;
+  esac
+],[
+  runpath_var=
+  _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+  _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=no
+  _LT_AC_TAGVAR(archive_cmds, $1)=
+  _LT_AC_TAGVAR(archive_expsym_cmds, $1)=
+  _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)=
+  _LT_AC_TAGVAR(old_archive_from_expsyms_cmds, $1)=
+  _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+  _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+  _LT_AC_TAGVAR(thread_safe_flag_spec, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)=
+  _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+  _LT_AC_TAGVAR(hardcode_direct, $1)=no
+  _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+  _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+  _LT_AC_TAGVAR(link_all_deplibs, $1)=unknown
+  _LT_AC_TAGVAR(hardcode_automatic, $1)=no
+  _LT_AC_TAGVAR(module_cmds, $1)=
+  _LT_AC_TAGVAR(module_expsym_cmds, $1)=
+  _LT_AC_TAGVAR(always_export_symbols, $1)=no
+  _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  _LT_AC_TAGVAR(include_expsyms, $1)=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  _LT_AC_TAGVAR(exclude_expsyms, $1)="_GLOBAL_OFFSET_TABLE_"
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  _LT_CC_BASENAME([$compiler])
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}--rpath ${wl}$libdir'
+    _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+       _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [[01]].* | *\ 2.[[0-9]].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix3* | aix4* | aix5*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+      fi
+      ;;
+
+    amigaos*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+
+      # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+      # that the semantics of dynamic libraries on AmigaOS, at least up
+      # to version 4, is to share data among multiple programs linked
+      # with the same dynamic library.  Since this doesn't match the
+      # behavior of shared libraries on other platforms, we can't use
+      # them.
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+       # support --undefined.  This deserves some investigation.  FIXME
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1) is actually meaningless,
+      # as there is no search path for DLLs.
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(always_export_symbols, $1)=no
+      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[[BCDGRS]] /s/.* \([[^ ]]*\)/\1 DATA/'\'' | $SED -e '\''/^[[AITW]] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+       # If the export-symbols file already is a .def file (1st line
+       # is EXPORTS), use it as is; otherwise, prepend...
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+         cp $export_symbols $output_objdir/$soname.def;
+       else
+         echo EXPORTS > $output_objdir/$soname.def;
+         cat $export_symbols >> $output_objdir/$soname.def;
+       fi~
+       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+      else
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    linux*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       tmp_addflag=
+       case $cc_basename,$host_cpu in
+       pgcc*)                          # Portland Group C compiler
+         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag'
+         ;;
+       pgf77* | pgf90* | pgf95*)       # Portland Group f77 and f90 compilers
+         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag -Mnomain' ;;
+       ecc*,ia64* | icc*,ia64*)                # Intel C compiler on ia64
+         tmp_addflag=' -i_dynamic' ;;
+       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
+         tmp_addflag=' -i_dynamic -nofor_main' ;;
+       ifc* | ifort*)                  # Intel Fortran compiler
+         tmp_addflag=' -nofor_main' ;;
+       esac
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+       if test $supports_anon_versioning = yes; then
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+         $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+       fi
+      else
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+       wlarc=
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris* | sysv5*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+       cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+
+    sunos4*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      fi
+      ;;
+    esac
+
+    if test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no; then
+      runpath_var=
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      if test "$GCC" = yes && test -z "$link_static_flag"; then
+       # Neither direct hardcoding nor static linking is supported with a
+       # broken collect2.
+       _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+      fi
+      ;;
+
+    aix4* | aix5*)
+      if test "$host_cpu" = ia64; then
+       # On IA64, the linker does run time linking by default, so we don't
+       # have to do anything special.
+       aix_use_runtimelinking=no
+       exp_sym_flag='-Bexport'
+       no_entry_flag=""
+      else
+       # If we're using GNU nm, then we don't want the "-C" option.
+       # -C means demangle to AIX nm, but means don't demangle with GNU nm
+       if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+         _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+       else
+         _LT_AC_TAGVAR(export_symbols_cmds, $1)='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\[$]2 == "T") || (\[$]2 == "D") || (\[$]2 == "B")) && ([substr](\[$]3,1,1) != ".")) { print \[$]3 } }'\'' | sort -u > $export_symbols'
+       fi
+       aix_use_runtimelinking=no
+
+       # Test if we are trying to use run time linking or normal
+       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+       # need to do runtime linking.
+       case $host_os in aix4.[[23]]|aix4.[[23]].*|aix5*)
+         for ld_flag in $LDFLAGS; do
+         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+           aix_use_runtimelinking=yes
+           break
+         fi
+         done
+       esac
+
+       exp_sym_flag='-bexport'
+       no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      _LT_AC_TAGVAR(archive_cmds, $1)=''
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=':'
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+
+      if test "$GCC" = yes; then
+       case $host_os in aix4.[[012]]|aix4.[[012]].*)
+       # We only want to do this on AIX 4.2 and lower, the check
+       # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" && \
+          strings "$collect2name" | grep resolve_lib_name >/dev/null
+         then
+         # We have reworked collect2
+         _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+         else
+         # We have old collect2
+         _LT_AC_TAGVAR(hardcode_direct, $1)=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=
+         fi
+       esac
+       shared_flag='-shared'
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag="$shared_flag "'${wl}-G'
+       fi
+      else
+       # not using gcc
+       if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+       else
+       if test "$aix_use_runtimelinking" = yes; then
+           shared_flag='${wl}-G'
+         else
+           shared_flag='${wl}-bM:SRE'
+       fi
+       fi
+      fi
+
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+      if test "$aix_use_runtimelinking" = yes; then
+       # Warning - without using the other runtime loading flags (-brtl),
+       # -berok will link without error, but may produce a broken library.
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       _LT_AC_SYS_LIBPATH_AIX
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+       if test "$host_cpu" = ia64; then
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-R $libdir:/usr/lib:/lib'
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)="-z nodefs"
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+       else
+        # Determine the default libpath from the value encoded in an empty executable.
+        _LT_AC_SYS_LIBPATH_AIX
+        _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-blibpath:$libdir:'"$aix_libpath"
+         # Warning - without using the other run time loading flags,
+         # -berok will link without error, but may produce a broken library.
+         _LT_AC_TAGVAR(no_undefined_flag, $1)=' ${wl}-bernotok'
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-berok'
+         # -bexpall does not export symbols beginning with underscore (_)
+         _LT_AC_TAGVAR(always_export_symbols, $1)=yes
+         # Exported symbols can be pulled into shared objects from archives
+         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=' '
+         _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+         # This is similar to how AIX traditionally builds its shared libraries.
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+       fi
+      fi
+      ;;
+
+    amigaos*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      # see comment about different semantics on the GNU ld section
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    bsdi[[45]]*)
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=' '
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='true'
+      # FIXME: Should let the user specify the lib program.
+      _LT_AC_TAGVAR(old_archive_cmds, $1)='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      _LT_AC_TAGVAR(fix_srcfile_path, $1)='`cygpath -w "$srcfile"`'
+      _LT_AC_TAGVAR(enable_shared_with_static_runtimes, $1)=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[[012]])
+         _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[[012]])
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               _LT_AC_TAGVAR(allow_undefined_flag, $1)='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+      _LT_AC_TAGVAR(hardcode_direct, $1)=no
+      _LT_AC_TAGVAR(hardcode_automatic, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=unsupported
+      _LT_AC_TAGVAR(whole_archive_flag_spec, $1)=''
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+    if test "$GCC" = yes ; then
+       output_verbose_link_cmd='echo'
+        _LT_AC_TAGVAR(archive_cmds, $1)='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+         _LT_AC_TAGVAR(module_cmds, $1)='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         _LT_AC_TAGVAR(archive_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          _LT_AC_TAGVAR(module_expsym_cmds, $1)='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         _LT_AC_TAGVAR(ld_shlibs, $1)=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    freebsd1*)
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | kfreebsd*-gnu | dragonfly*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      ;;
+
+    hpux10* | hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*|ia64*)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       esac
+      else
+       case $host_cpu in
+       hppa*64*|ia64*)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       *)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       esac
+      fi
+      if test "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*)
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='+b $libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+         _LT_AC_TAGVAR(hardcode_direct, $1)=no
+         _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+         ;;
+       ia64*)
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+         _LT_AC_TAGVAR(hardcode_direct, $1)=no
+         _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+         ;;
+       *)
+         _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}+b ${wl}$libdir'
+         _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+         _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+         _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+         ;;
+       esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec_ld, $1)='-rpath $libdir'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    newsos6)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    openbsd*)
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+       _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-E'
+      else
+       case $host_os in
+        openbsd[[01]].* | openbsd2.[[0-7]] | openbsd2.[[0-7]].*)
+          _LT_AC_TAGVAR(archive_cmds, $1)='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+          _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+          ;;
+        *)
+          _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+          _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath,$libdir'
+          ;;
+       esac
+      fi
+      ;;
+
+    os2*)
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(allow_undefined_flag, $1)=unsupported
+      _LT_AC_TAGVAR(archive_cmds, $1)='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      _LT_AC_TAGVAR(old_archive_From_new_cmds, $1)='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    osf4* | osf5*)     # as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' ${wl}-expect_unresolved ${wl}\*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='${wl}-rpath ${wl}$libdir'
+      else
+       _LT_AC_TAGVAR(allow_undefined_flag, $1)=' -expect_unresolved \*'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+       $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+
+       # Both c and cxx compiler support -rpath directly
+       _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-rpath $libdir'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_separator, $1)=:
+      ;;
+
+    sco3.2v5*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='${wl}-Bexport'
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ;;
+
+    solaris*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+      if test "$GCC" = yes; then
+       wlarc='${wl}'
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+         $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+       wlarc=''
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+       $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-R$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      case $host_os in
+      solaris2.[[0-5]] | solaris2.[[0-5]].*) ;;
+      *)
+       # The compiler driver will combine linker options so we
+       # cannot just pass the convience library names through
+       # without $wl, iff we do not link with $LD.
+       # Luckily, gcc supports the same syntax we need for Sun Studio.
+       # Supported since Solaris 2.6 (maybe 2.5.1?)
+       case $wlarc in
+       '')
+         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='-z allextract$convenience -z defaultextract' ;;
+       *)
+         _LT_AC_TAGVAR(whole_archive_flag_spec, $1)='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
+       esac ;;
+      esac
+      _LT_AC_TAGVAR(link_all_deplibs, $1)=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+       # Use $CC to link under sequent, because it throws in some extra .o
+       # files that make .init and .fini sections work.
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=yes
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+       sni)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         _LT_AC_TAGVAR(hardcode_direct, $1)=yes # is this really true???
+       ;;
+       siemens)
+         ## LD is ld it makes a PLAMLIB
+         ## CC just makes a GrossModule.
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+         _LT_AC_TAGVAR(reload_cmds, $1)='$CC -r -o $output$reload_objs'
+         _LT_AC_TAGVAR(hardcode_direct, $1)=no
+        ;;
+       motorola)
+         _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         _LT_AC_TAGVAR(hardcode_direct, $1)=no #Motorola manual says yes, but my tests say they lie
+       ;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv4.3*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      _LT_AC_TAGVAR(export_dynamic_flag_spec, $1)='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+       runpath_var=LD_RUN_PATH
+       hardcode_runpath_var=yes
+       _LT_AC_TAGVAR(ld_shlibs, $1)=yes
+      fi
+      ;;
+
+    sysv4.2uw2*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_direct, $1)=yes
+      _LT_AC_TAGVAR(hardcode_minus_L, $1)=no
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      hardcode_runpath_var=yes
+      runpath_var=LD_RUN_PATH
+      ;;
+
+   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[[78]]* | unixware7*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)='${wl}-z ${wl}text'
+      if test "$GCC" = yes; then
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       _LT_AC_TAGVAR(archive_cmds, $1)='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      runpath_var='LD_RUN_PATH'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    sysv5*)
+      _LT_AC_TAGVAR(no_undefined_flag, $1)=' -z text'
+      # $CC -shared without GNU ld will not create a library from C++
+      # object files and a static libstdc++, better avoid it by now
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(archive_expsym_cmds, $1)='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)=
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      runpath_var='LD_RUN_PATH'
+      ;;
+
+    uts4*)
+      _LT_AC_TAGVAR(archive_cmds, $1)='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      _LT_AC_TAGVAR(hardcode_libdir_flag_spec, $1)='-L$libdir'
+      _LT_AC_TAGVAR(hardcode_shlibpath_var, $1)=no
+      ;;
+
+    *)
+      _LT_AC_TAGVAR(ld_shlibs, $1)=no
+      ;;
+    esac
+  fi
+])
+AC_MSG_RESULT([$_LT_AC_TAGVAR(ld_shlibs, $1)])
+test "$_LT_AC_TAGVAR(ld_shlibs, $1)" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)" in
+x|xyes)
+  # Assume -lc should be added
+  _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $_LT_AC_TAGVAR(archive_cmds, $1) in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      AC_MSG_CHECKING([whether -lc should be explicitly linked in])
+      $rm conftest*
+      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if AC_TRY_EVAL(ac_compile) 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$_LT_AC_TAGVAR(lt_prog_compiler_wl, $1)
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$_LT_AC_TAGVAR(allow_undefined_flag, $1)
+        _LT_AC_TAGVAR(allow_undefined_flag, $1)=
+        if AC_TRY_EVAL(_LT_AC_TAGVAR(archive_cmds, $1) 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1)
+        then
+         _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=no
+        else
+         _LT_AC_TAGVAR(archive_cmds_need_lc, $1)=yes
+        fi
+        _LT_AC_TAGVAR(allow_undefined_flag, $1)=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      AC_MSG_RESULT([$_LT_AC_TAGVAR(archive_cmds_need_lc, $1)])
+      ;;
+    esac
+  fi
+  ;;
+esac
+])# AC_LIBTOOL_PROG_LD_SHLIBS
+
+
+# _LT_AC_FILE_LTDLL_C
+# -------------------
+# Be careful that the start marker always follows a newline.
+AC_DEFUN([_LT_AC_FILE_LTDLL_C], [
+# /* ltdll.c starts here */
+# #define WIN32_LEAN_AND_MEAN
+# #include <windows.h>
+# #undef WIN32_LEAN_AND_MEAN
+# #include <stdio.h>
+#
+# #ifndef __CYGWIN__
+# #  ifdef __CYGWIN32__
+# #    define __CYGWIN__ __CYGWIN32__
+# #  endif
+# #endif
+#
+# #ifdef __cplusplus
+# extern "C" {
+# #endif
+# BOOL APIENTRY DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved);
+# #ifdef __cplusplus
+# }
+# #endif
+#
+# #ifdef __CYGWIN__
+# #include <cygwin/cygwin_dll.h>
+# DECLARE_CYGWIN_DLL( DllMain );
+# #endif
+# HINSTANCE __hDllInstance_base;
+#
+# BOOL APIENTRY
+# DllMain (HINSTANCE hInst, DWORD reason, LPVOID reserved)
+# {
+#   __hDllInstance_base = hInst;
+#   return TRUE;
+# }
+# /* ltdll.c ends here */
+])# _LT_AC_FILE_LTDLL_C
+
+
+# _LT_AC_TAGVAR(VARNAME, [TAGNAME])
+# ---------------------------------
+AC_DEFUN([_LT_AC_TAGVAR], [ifelse([$2], [], [$1], [$1_$2])])
+
+
+# old names
+AC_DEFUN([AM_PROG_LIBTOOL],   [AC_PROG_LIBTOOL])
+AC_DEFUN([AM_ENABLE_SHARED],  [AC_ENABLE_SHARED($@)])
+AC_DEFUN([AM_ENABLE_STATIC],  [AC_ENABLE_STATIC($@)])
+AC_DEFUN([AM_DISABLE_SHARED], [AC_DISABLE_SHARED($@)])
+AC_DEFUN([AM_DISABLE_STATIC], [AC_DISABLE_STATIC($@)])
+AC_DEFUN([AM_PROG_LD],        [AC_PROG_LD])
+AC_DEFUN([AM_PROG_NM],        [AC_PROG_NM])
+
+# This is just to silence aclocal about the macro not being used
+ifelse([AC_DISABLE_FAST_INSTALL])
+
+AC_DEFUN([LT_AC_PROG_GCJ],
+[AC_CHECK_TOOL(GCJ, gcj, no)
+  test "x${GCJFLAGS+set}" = xset || GCJFLAGS="-g -O2"
+  AC_SUBST(GCJFLAGS)
+])
+
+AC_DEFUN([LT_AC_PROG_RC],
+[AC_CHECK_TOOL(RC, windres, no)
+])
+
+# NOTE: This macro has been submitted for inclusion into   #
+#  GNU Autoconf as AC_PROG_SED.  When it is available in   #
+#  a released version of Autoconf we should remove this    #
+#  macro and use it instead.                               #
+# LT_AC_PROG_SED
+# --------------
+# Check for a fully-functional sed program, that truncates
+# as few characters as possible.  Prefer GNU sed if found.
+AC_DEFUN([LT_AC_PROG_SED],
+[AC_MSG_CHECKING([for a sed that does not truncate output])
+AC_CACHE_VAL(lt_cv_path_SED,
+[# Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+])
+SED=$lt_cv_path_SED
+AC_MSG_RESULT([$SED])
+])
+
+# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_AUTOMAKE_VERSION(VERSION)
+# ----------------------------
+# Automake X.Y traces this macro to ensure aclocal.m4 has been
+# generated from the m4 files accompanying Automake X.Y.
+# (This private macro should not be called outside this file.)
+AC_DEFUN([AM_AUTOMAKE_VERSION],
+[am__api_version='1.11'
+dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
+dnl require some minimum version.  Point them to the right macro.
+m4_if([$1], [1.11], [],
+      [AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
+])
+
+# _AM_AUTOCONF_VERSION(VERSION)
+# -----------------------------
+# aclocal traces this macro to find the Autoconf version.
+# This is a private macro too.  Using m4_define simplifies
+# the logic in aclocal, which can simply ignore this definition.
+m4_define([_AM_AUTOCONF_VERSION], [])
+
+# AM_SET_CURRENT_AUTOMAKE_VERSION
+# -------------------------------
+# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
+# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
+AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
+[AM_AUTOMAKE_VERSION([1.11])dnl
+m4_ifndef([AC_AUTOCONF_VERSION],
+  [m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
+_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
+
+# AM_AUX_DIR_EXPAND                                         -*- Autoconf -*-
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
+# $ac_aux_dir to `$srcdir/foo'.  In other projects, it is set to
+# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
+#
+# Of course, Automake must honor this variable whenever it calls a
+# tool from the auxiliary directory.  The problem is that $srcdir (and
+# therefore $ac_aux_dir as well) can be either absolute or relative,
+# depending on how configure is run.  This is pretty annoying, since
+# it makes $ac_aux_dir quite unusable in subdirectories: in the top
+# source directory, any form will work fine, but in subdirectories a
+# relative path needs to be adjusted first.
+#
+# $ac_aux_dir/missing
+#    fails when called from a subdirectory if $ac_aux_dir is relative
+# $top_srcdir/$ac_aux_dir/missing
+#    fails if $ac_aux_dir is absolute,
+#    fails when called from a subdirectory in a VPATH build with
+#          a relative $ac_aux_dir
+#
+# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
+# are both prefixed by $srcdir.  In an in-source build this is usually
+# harmless because $srcdir is `.', but things will broke when you
+# start a VPATH build or use an absolute $srcdir.
+#
+# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
+# iff we strip the leading $srcdir from $ac_aux_dir.  That would be:
+#   am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
+# and then we would define $MISSING as
+#   MISSING="\${SHELL} $am_aux_dir/missing"
+# This will work as long as MISSING is not called from configure, because
+# unfortunately $(top_srcdir) has no meaning in configure.
+# However there are other variables, like CC, which are often used in
+# configure, and could therefore not use this "fixed" $ac_aux_dir.
+#
+# Another solution, used here, is to always expand $ac_aux_dir to an
+# absolute PATH.  The drawback is that using absolute paths prevent a
+# configured tree to be moved without reconfiguration.
+
+AC_DEFUN([AM_AUX_DIR_EXPAND],
+[dnl Rely on autoconf to set up CDPATH properly.
+AC_PREREQ([2.50])dnl
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+])
+
+# AM_CONDITIONAL                                            -*- Autoconf -*-
+
+# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 9
+
+# AM_CONDITIONAL(NAME, SHELL-CONDITION)
+# -------------------------------------
+# Define a conditional.
+AC_DEFUN([AM_CONDITIONAL],
+[AC_PREREQ(2.52)dnl
+ ifelse([$1], [TRUE],  [AC_FATAL([$0: invalid condition: $1])],
+       [$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
+AC_SUBST([$1_TRUE])dnl
+AC_SUBST([$1_FALSE])dnl
+_AM_SUBST_NOTMAKE([$1_TRUE])dnl
+_AM_SUBST_NOTMAKE([$1_FALSE])dnl
+m4_define([_AM_COND_VALUE_$1], [$2])dnl
+if $2; then
+  $1_TRUE=
+  $1_FALSE='#'
+else
+  $1_TRUE='#'
+  $1_FALSE=
+fi
+AC_CONFIG_COMMANDS_PRE(
+[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
+  AC_MSG_ERROR([[conditional "$1" was never defined.
+Usually this means the macro was only invoked conditionally.]])
+fi])])
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 10
+
+# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
+# written in clear, in which case automake, when reading aclocal.m4,
+# will think it sees a *use*, and therefore will trigger all it's
+# C support machinery.  Also note that it means that autoscan, seeing
+# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
+
+
+# _AM_DEPENDENCIES(NAME)
+# ----------------------
+# See how the compiler implements dependency checking.
+# NAME is "CC", "CXX", "GCJ", or "OBJC".
+# We try a few techniques and use that to set a single cache variable.
+#
+# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
+# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
+# dependency, and given that the user is not expected to run this macro,
+# just rely on AC_PROG_CC.
+AC_DEFUN([_AM_DEPENDENCIES],
+[AC_REQUIRE([AM_SET_DEPDIR])dnl
+AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
+AC_REQUIRE([AM_MAKE_INCLUDE])dnl
+AC_REQUIRE([AM_DEP_TRACK])dnl
+
+ifelse([$1], CC,   [depcc="$CC"   am_compiler_list=],
+       [$1], CXX,  [depcc="$CXX"  am_compiler_list=],
+       [$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
+       [$1], UPC,  [depcc="$UPC"  am_compiler_list=],
+       [$1], GCJ,  [depcc="$GCJ"  am_compiler_list='gcc3 gcc'],
+                   [depcc="$$1"   am_compiler_list=])
+
+AC_CACHE_CHECK([dependency style of $depcc],
+               [am_cv_$1_dependencies_compiler_type],
+[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_$1_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
+  fi
+  am__universal=false
+  m4_case([$1], [CC],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac],
+    [CXX],
+    [case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac])
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_$1_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_$1_dependencies_compiler_type=none
+fi
+])
+AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
+AM_CONDITIONAL([am__fastdep$1], [
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_$1_dependencies_compiler_type" = gcc3])
+])
+
+
+# AM_SET_DEPDIR
+# -------------
+# Choose a directory name for dependency files.
+# This macro is AC_REQUIREd in _AM_DEPENDENCIES
+AC_DEFUN([AM_SET_DEPDIR],
+[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
+])
+
+
+# AM_DEP_TRACK
+# ------------
+AC_DEFUN([AM_DEP_TRACK],
+[AC_ARG_ENABLE(dependency-tracking,
+[  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors])
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
+AC_SUBST([AMDEPBACKSLASH])dnl
+_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
+])
+
+# Generate code to set up dependency tracking.              -*- Autoconf -*-
+
+# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+#serial 5
+
+# _AM_OUTPUT_DEPENDENCY_COMMANDS
+# ------------------------------
+AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
+[{
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`AS_DIRNAME("$mf")`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`AS_DIRNAME(["$file"])`
+      AS_MKDIR_P([$dirpart/$fdir])
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+])# _AM_OUTPUT_DEPENDENCY_COMMANDS
+
+
+# AM_OUTPUT_DEPENDENCY_COMMANDS
+# -----------------------------
+# This macro should only be invoked once -- use via AC_REQUIRE.
+#
+# This code is only required when automatic dependency tracking
+# is enabled.  FIXME.  This creates each `.P' file that we will
+# need in order to bootstrap the dependency handling code.
+AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
+[AC_CONFIG_COMMANDS([depfiles],
+     [test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
+     [AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
+])
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 8
+
+# AM_CONFIG_HEADER is obsolete.  It has been replaced by AC_CONFIG_HEADERS.
+AU_DEFUN([AM_CONFIG_HEADER], [AC_CONFIG_HEADERS($@)])
+
+# Do all the work for Automake.                             -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
+# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 16
+
+# This macro actually does too much.  Some checks are only needed if
+# your package does certain things.  But this isn't really a big deal.
+
+# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
+# AM_INIT_AUTOMAKE([OPTIONS])
+# -----------------------------------------------
+# The call with PACKAGE and VERSION arguments is the old style
+# call (pre autoconf-2.50), which is being phased out.  PACKAGE
+# and VERSION should now be passed to AC_INIT and removed from
+# the call to AM_INIT_AUTOMAKE.
+# We support both call styles for the transition.  After
+# the next Automake release, Autoconf can make the AC_INIT
+# arguments mandatory, and then we can depend on a new Autoconf
+# release and drop the old call support.
+AC_DEFUN([AM_INIT_AUTOMAKE],
+[AC_PREREQ([2.62])dnl
+dnl Autoconf wants to disallow AM_ names.  We explicitly allow
+dnl the ones we care about.
+m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
+AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
+AC_REQUIRE([AC_PROG_INSTALL])dnl
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+AC_SUBST([CYGPATH_W])
+
+# Define the identity of the package.
+dnl Distinguish between old-style and new-style calls.
+m4_ifval([$2],
+[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
+ AC_SUBST([PACKAGE], [$1])dnl
+ AC_SUBST([VERSION], [$2])],
+[_AM_SET_OPTIONS([$1])dnl
+dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
+m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
+  [m4_fatal([AC_INIT should be called with package and version arguments])])dnl
+ AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
+ AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
+
+_AM_IF_OPTION([no-define],,
+[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
+ AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
+
+# Some tools Automake needs.
+AC_REQUIRE([AM_SANITY_CHECK])dnl
+AC_REQUIRE([AC_ARG_PROGRAM])dnl
+AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
+AM_MISSING_PROG(AUTOCONF, autoconf)
+AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
+AM_MISSING_PROG(AUTOHEADER, autoheader)
+AM_MISSING_PROG(MAKEINFO, makeinfo)
+AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
+AC_REQUIRE([AM_PROG_MKDIR_P])dnl
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+AC_REQUIRE([AC_PROG_AWK])dnl
+AC_REQUIRE([AC_PROG_MAKE_SET])dnl
+AC_REQUIRE([AM_SET_LEADING_DOT])dnl
+_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
+             [_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
+                            [_AM_PROG_TAR([v7])])])
+_AM_IF_OPTION([no-dependencies],,
+[AC_PROVIDE_IFELSE([AC_PROG_CC],
+                 [_AM_DEPENDENCIES(CC)],
+                 [define([AC_PROG_CC],
+                         defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_CXX],
+                 [_AM_DEPENDENCIES(CXX)],
+                 [define([AC_PROG_CXX],
+                         defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
+AC_PROVIDE_IFELSE([AC_PROG_OBJC],
+                 [_AM_DEPENDENCIES(OBJC)],
+                 [define([AC_PROG_OBJC],
+                         defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
+])
+_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
+dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
+dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen.  This macro
+dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
+AC_CONFIG_COMMANDS_PRE(dnl
+[m4_provide_if([_AM_COMPILER_EXEEXT],
+  [AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
+])
+
+dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion.  Do not
+dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
+dnl mangled by Autoconf and run in a shell conditional statement.
+m4_define([_AC_COMPILER_EXEEXT],
+m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
+
+
+# When config.status generates a header, we must update the stamp-h file.
+# This file resides in the same directory as the config header
+# that is generated.  The stamp files are numbered to have different names.
+
+# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
+# loop where config.status creates the headers, so we can generate
+# our stamp files there.
+AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
+[# Compute $1's index in $config_headers.
+_am_arg=$1
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
+
+# Copyright (C) 2001, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_PROG_INSTALL_SH
+# ------------------
+# Define $install_sh.
+AC_DEFUN([AM_PROG_INSTALL_SH],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+AC_SUBST(install_sh)])
+
+# Copyright (C) 2003, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 2
+
+# Check whether the underlying file-system supports filenames
+# with a leading dot.  For instance MS-DOS doesn't.
+AC_DEFUN([AM_SET_LEADING_DOT],
+[rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+AC_SUBST([am__leading_dot])])
+
+# Check to see how 'make' treats includes.                 -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2009  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 4
+
+# AM_MAKE_INCLUDE()
+# -----------------
+# Check to see how make treats includes.
+AC_DEFUN([AM_MAKE_INCLUDE],
+[am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+AC_MSG_CHECKING([for style of include used by $am_make])
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+AC_SUBST([am__include])
+AC_SUBST([am__quote])
+AC_MSG_RESULT([$_am_result])
+rm -f confinc confmf
+])
+
+# Fake the existence of programs that GNU maintainers use.  -*- Autoconf -*-
+
+# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 6
+
+# AM_MISSING_PROG(NAME, PROGRAM)
+# ------------------------------
+AC_DEFUN([AM_MISSING_PROG],
+[AC_REQUIRE([AM_MISSING_HAS_RUN])
+$1=${$1-"${am_missing_run}$2"}
+AC_SUBST($1)])
+
+
+# AM_MISSING_HAS_RUN
+# ------------------
+# Define MISSING if not defined so far and test if it supports --run.
+# If it does, set am_missing_run to use it, otherwise, to nothing.
+AC_DEFUN([AM_MISSING_HAS_RUN],
+[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
+AC_REQUIRE_AUX_FILE([missing])dnl
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  AC_MSG_WARN([`missing' script is too old or missing])
+fi
+])
+
+# Copyright (C) 2003, 2004, 2005, 2006  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_PROG_MKDIR_P
+# ---------------
+# Check for `mkdir -p'.
+AC_DEFUN([AM_PROG_MKDIR_P],
+[AC_PREREQ([2.60])dnl
+AC_REQUIRE([AC_PROG_MKDIR_P])dnl
+dnl Automake 1.8 to 1.9.6 used to define mkdir_p.  We now use MKDIR_P,
+dnl while keeping a definition of mkdir_p for backward compatibility.
+dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
+dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
+dnl Makefile.ins that do not define MKDIR_P, so we do our own
+dnl adjustment using top_builddir (which is defined more often than
+dnl MKDIR_P).
+AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
+case $mkdir_p in
+  [[\\/$]]* | ?:[[\\/]]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+])
+
+# Helper functions for option handling.                     -*- Autoconf -*-
+
+# Copyright (C) 2001, 2002, 2003, 2005, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 4
+
+# _AM_MANGLE_OPTION(NAME)
+# -----------------------
+AC_DEFUN([_AM_MANGLE_OPTION],
+[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
+
+# _AM_SET_OPTION(NAME)
+# ------------------------------
+# Set option NAME.  Presently that only means defining a flag for this option.
+AC_DEFUN([_AM_SET_OPTION],
+[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
+
+# _AM_SET_OPTIONS(OPTIONS)
+# ----------------------------------
+# OPTIONS is a space-separated list of Automake options.
+AC_DEFUN([_AM_SET_OPTIONS],
+[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
+
+# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
+# -------------------------------------------
+# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
+AC_DEFUN([_AM_IF_OPTION],
+[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
+
+# Check to make sure that the build environment is sane.    -*- Autoconf -*-
+
+# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
+# Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 5
+
+# AM_SANITY_CHECK
+# ---------------
+AC_DEFUN([AM_SANITY_CHECK],
+[AC_MSG_CHECKING([whether build environment is sane])
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[[\\\"\#\$\&\'\`$am_lf]]*)
+    AC_MSG_ERROR([unsafe absolute working directory name]);;
+esac
+case $srcdir in
+  *[[\\\"\#\$\&\'\`$am_lf\ \   ]]*)
+    AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$[*]" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$[*]" != "X $srcdir/configure conftest.file" \
+      && test "$[*]" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      AC_MSG_ERROR([ls -t appears to fail.  Make sure there is not a broken
+alias in your environment])
+   fi
+
+   test "$[2]" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   AC_MSG_ERROR([newly created file is older than distributed files!
+Check your system clock])
+fi
+AC_MSG_RESULT(yes)])
+
+# Copyright (C) 2001, 2003, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# AM_PROG_INSTALL_STRIP
+# ---------------------
+# One issue with vendor `install' (even GNU) is that you can't
+# specify the program used to strip binaries.  This is especially
+# annoying in cross-compiling environments, where the build's strip
+# is unlikely to handle the host's binaries.
+# Fortunately install-sh will honor a STRIPPROG variable, so we
+# always use install-sh in `make install-strip', and initialize
+# STRIPPROG with the value of the STRIP variable (set by the user).
+AC_DEFUN([AM_PROG_INSTALL_STRIP],
+[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
+if test "$cross_compiling" != no; then
+  AC_CHECK_TOOL([STRIP], [strip], :)
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+AC_SUBST([INSTALL_STRIP_PROGRAM])])
+
+# Copyright (C) 2006, 2008  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 2
+
+# _AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
+# This macro is traced by Automake.
+AC_DEFUN([_AM_SUBST_NOTMAKE])
+
+# AM_SUBST_NOTMAKE(VARIABLE)
+# ---------------------------
+# Public sister of _AM_SUBST_NOTMAKE.
+AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
+
+# Check how to create a tarball.                            -*- Autoconf -*-
+
+# Copyright (C) 2004, 2005  Free Software Foundation, Inc.
+#
+# This file 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.
+
+# serial 2
+
+# _AM_PROG_TAR(FORMAT)
+# --------------------
+# Check how to create a tarball in format FORMAT.
+# FORMAT should be one of `v7', `ustar', or `pax'.
+#
+# Substitute a variable $(am__tar) that is a command
+# writing to stdout a FORMAT-tarball containing the directory
+# $tardir.
+#     tardir=directory && $(am__tar) > result.tar
+#
+# Substitute a variable $(am__untar) that extract such
+# a tarball read from stdin.
+#     $(am__untar) < result.tar
+AC_DEFUN([_AM_PROG_TAR],
+[# Always define AMTAR for backward compatibility.
+AM_MISSING_PROG([AMTAR], [tar])
+m4_if([$1], [v7],
+     [am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
+     [m4_case([$1], [ustar],, [pax],,
+              [m4_fatal([Unknown tar format])])
+AC_MSG_CHECKING([how to create a $1 tar archive])
+# Loop over all known methods to create a tar archive until one works.
+_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
+_am_tools=${am_cv_prog_tar_$1-$_am_tools}
+# Do not fold the above two line into one, because Tru64 sh and
+# Solaris sh will not grok spaces in the rhs of `-'.
+for _am_tool in $_am_tools
+do
+  case $_am_tool in
+  gnutar)
+    for _am_tar in tar gnutar gtar;
+    do
+      AM_RUN_LOG([$_am_tar --version]) && break
+    done
+    am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
+    am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
+    am__untar="$_am_tar -xf -"
+    ;;
+  plaintar)
+    # Must skip GNU tar: if it does not support --format= it doesn't create
+    # ustar tarball either.
+    (tar --version) >/dev/null 2>&1 && continue
+    am__tar='tar chf - "$$tardir"'
+    am__tar_='tar chf - "$tardir"'
+    am__untar='tar xf -'
+    ;;
+  pax)
+    am__tar='pax -L -x $1 -w "$$tardir"'
+    am__tar_='pax -L -x $1 -w "$tardir"'
+    am__untar='pax -r'
+    ;;
+  cpio)
+    am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
+    am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
+    am__untar='cpio -i -H $1 -d'
+    ;;
+  none)
+    am__tar=false
+    am__tar_=false
+    am__untar=false
+    ;;
+  esac
+
+  # If the value was cached, stop now.  We just wanted to have am__tar
+  # and am__untar set.
+  test -n "${am_cv_prog_tar_$1}" && break
+
+  # tar/untar a dummy directory, and stop if the command works
+  rm -rf conftest.dir
+  mkdir conftest.dir
+  echo GrepMe > conftest.dir/file
+  AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
+  rm -rf conftest.dir
+  if test -s conftest.tar; then
+    AM_RUN_LOG([$am__untar <conftest.tar])
+    grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
+  fi
+done
+rm -rf conftest.dir
+
+AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
+AC_MSG_RESULT([$am_cv_prog_tar_$1])])
+AC_SUBST([am__tar])
+AC_SUBST([am__untar])
+]) # _AM_PROG_TAR
+
+m4_include([libopts/m4/libopts.m4])
diff --git a/sntp/autogen-version.def b/sntp/autogen-version.def
new file mode 100644 (file)
index 0000000..8943983
--- /dev/null
@@ -0,0 +1,2 @@
+#assert (version-compare >= autogen-version "5.9.1")
+guard-option-names;
diff --git a/sntp/bincheck.mf b/sntp/bincheck.mf
new file mode 100644 (file)
index 0000000..c67827d
--- /dev/null
@@ -0,0 +1,15 @@
+# we traditionally installed software in bindir, while it should have gone
+# in sbindir.  Now that we offer a choice, look in the "other" installation
+# subdir to warn folks if there is another version there.
+
+install-exec-hook:
+       @case ${BINSUBDIR} in                                   \
+        bin) ODIR=${exec_prefix}/sbin ;;                       \
+        sbin) ODIR=${exec_prefix}/bin ;;                       \
+       esac;                                                   \
+       test -z "${bin_PROGRAMS}${bin_SCRIPTS}"                 \
+       || for i in ${bin_PROGRAMS} ${bin_SCRIPTS} " "; do              \
+          test ! -f $$ODIR/$$i || echo "*** $$i is also in $$ODIR!";   \
+       done
+
+#
diff --git a/sntp/compile b/sntp/compile
new file mode 100755 (executable)
index 0000000..1b1d232
--- /dev/null
@@ -0,0 +1,142 @@
+#! /bin/sh
+# Wrapper for compilers which do not understand `-c -o'.
+
+scriptversion=2005-05-14.22
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+# Written by Tom Tromey <tromey@cygnus.com>.
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# This file is maintained in Automake, please report
+# bugs to <bug-automake@gnu.org> or send patches to
+# <automake-patches@gnu.org>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: compile [--help] [--version] PROGRAM [ARGS]
+
+Wrapper for compilers which do not understand `-c -o'.
+Remove `-o dest.o' from ARGS, run PROGRAM with the remaining
+arguments, and rename the output as expected.
+
+If you are trying to build a whole package this is not the
+right script to run: please start by reading the file `INSTALL'.
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "compile $scriptversion"
+    exit $?
+    ;;
+esac
+
+ofile=
+cfile=
+eat=
+
+for arg
+do
+  if test -n "$eat"; then
+    eat=
+  else
+    case $1 in
+      -o)
+       # configure might choose to run compile as `compile cc -o foo foo.c'.
+       # So we strip `-o arg' only if arg is an object.
+       eat=1
+       case $2 in
+         *.o | *.obj)
+           ofile=$2
+           ;;
+         *)
+           set x "$@" -o "$2"
+           shift
+           ;;
+       esac
+       ;;
+      *.c)
+       cfile=$1
+       set x "$@" "$1"
+       shift
+       ;;
+      *)
+       set x "$@" "$1"
+       shift
+       ;;
+    esac
+  fi
+  shift
+done
+
+if test -z "$ofile" || test -z "$cfile"; then
+  # If no `-o' option was seen then we might have been invoked from a
+  # pattern rule where we don't need one.  That is ok -- this is a
+  # normal compilation that the losing compiler can handle.  If no
+  # `.c' file was seen then we are probably linking.  That is also
+  # ok.
+  exec "$@"
+fi
+
+# Name of file we expect compiler to create.
+cofile=`echo "$cfile" | sed -e 's|^.*/||' -e 's/\.c$/.o/'`
+
+# Create the lock directory.
+# Note: use `[/.-]' here to ensure that we don't use the same name
+# that we are using for the .o file.  Also, base the name on the expected
+# object file name, since that is what matters with a parallel build.
+lockdir=`echo "$cofile" | sed -e 's|[/.-]|_|g'`.d
+while true; do
+  if mkdir "$lockdir" >/dev/null 2>&1; then
+    break
+  fi
+  sleep 1
+done
+# FIXME: race condition here if user kills between mkdir and trap.
+trap "rmdir '$lockdir'; exit 1" 1 2 15
+
+# Run the compile.
+"$@"
+ret=$?
+
+if test -f "$cofile"; then
+  mv "$cofile" "$ofile"
+elif test -f "${cofile}bj"; then
+  mv "${cofile}bj" "$ofile"
+fi
+
+rmdir "$lockdir"
+exit $ret
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/sntp/config.guess b/sntp/config.guess
new file mode 100755 (executable)
index 0000000..917bbc5
--- /dev/null
@@ -0,0 +1,1463 @@
+#! /bin/sh
+# Attempt to guess a canonical system name.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+timestamp='2005-07-08'
+
+# This file is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Originally written by Per Bothner <per@bothner.com>.
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# This script attempts to guess a canonical system name similar to
+# config.sub.  If it succeeds, it prints the system name on stdout, and
+# exits with 0.  Otherwise, it exits with 1.
+#
+# The plan is that this can be called by configure scripts if you
+# don't specify an explicit build system type.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION]
+
+Output the configuration name of the system \`$me' is run on.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.guess ($timestamp)
+
+Originally written by Per Bothner.
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help" >&2
+       exit 1 ;;
+    * )
+       break ;;
+  esac
+done
+
+if test $# != 0; then
+  echo "$me: too many arguments$help" >&2
+  exit 1
+fi
+
+trap 'exit 1' 1 2 15
+
+# CC_FOR_BUILD -- compiler used by this script. Note that the use of a
+# compiler to aid in system detection is discouraged as it requires
+# temporary files to be created and, as you can see below, it is a
+# headache to deal with in a portable fashion.
+
+# Historically, `CC_FOR_BUILD' used to be named `HOST_CC'. We still
+# use `HOST_CC' if defined, but it is deprecated.
+
+# Portable tmp directory creation inspired by the Autoconf team.
+
+set_cc_for_build='
+trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ;
+trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
+: ${TMPDIR=/tmp} ;
+ { tmp=`(umask 077 && mktemp -d -q "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
+dummy=$tmp/dummy ;
+tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
+case $CC_FOR_BUILD,$HOST_CC,$CC in
+ ,,)    echo "int x;" > $dummy.c ;
+       for c in cc gcc c89 c99 ; do
+         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+            CC_FOR_BUILD="$c"; break ;
+         fi ;
+       done ;
+       if test x"$CC_FOR_BUILD" = x ; then
+         CC_FOR_BUILD=no_compiler_found ;
+       fi
+       ;;
+ ,,*)   CC_FOR_BUILD=$CC ;;
+ ,*,*)  CC_FOR_BUILD=$HOST_CC ;;
+esac ; set_cc_for_build= ;'
+
+# This is needed to find uname on a Pyramid OSx when run in the BSD universe.
+# (ghazi@noc.rutgers.edu 1994-08-24)
+if (test -f /.attbin/uname) >/dev/null 2>&1 ; then
+       PATH=$PATH:/.attbin ; export PATH
+fi
+
+UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown
+UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
+UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
+UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
+
+# Note: order is significant - the case branches are not exclusive.
+
+case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+    *:NetBSD:*:*)
+       # NetBSD (nbsd) targets should (where applicable) match one or
+       # more of the tupples: *-*-netbsdelf*, *-*-netbsdaout*,
+       # *-*-netbsdecoff* and *-*-netbsd*.  For targets that recently
+       # switched to ELF, *-*-netbsd* would select the old
+       # object file format.  This provides both forward
+       # compatibility and a consistent mechanism for selecting the
+       # object file format.
+       #
+       # Note: NetBSD doesn't particularly care about the vendor
+       # portion of the name.  We always set it to "unknown".
+       sysctl="sysctl -n hw.machine_arch"
+       UNAME_MACHINE_ARCH=`(/sbin/$sysctl 2>/dev/null || \
+           /usr/sbin/$sysctl 2>/dev/null || echo unknown)`
+       case "${UNAME_MACHINE_ARCH}" in
+           armeb) machine=armeb-unknown ;;
+           arm*) machine=arm-unknown ;;
+           sh3el) machine=shl-unknown ;;
+           sh3eb) machine=sh-unknown ;;
+           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+       esac
+       # The Operating System including object format, if it has switched
+       # to ELF recently, or will in the future.
+       case "${UNAME_MACHINE_ARCH}" in
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+               eval $set_cc_for_build
+               if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
+                       | grep __ELF__ >/dev/null
+               then
+                   # Once all utilities can be ECOFF (netbsdecoff) or a.out (netbsdaout).
+                   # Return netbsd for either.  FIX?
+                   os=netbsd
+               else
+                   os=netbsdelf
+               fi
+               ;;
+           *)
+               os=netbsd
+               ;;
+       esac
+       # The OS release
+       # Debian GNU/NetBSD machines have a different userland, and
+       # thus, need a distinct triplet. However, they do not need
+       # kernel version information, so it can be replaced with a
+       # suitable tag, in the style of linux-gnu.
+       case "${UNAME_VERSION}" in
+           Debian*)
+               release='-gnu'
+               ;;
+           *)
+               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               ;;
+       esac
+       # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
+       # contains redundant information, the shorter form:
+       # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
+       echo "${machine}-${os}${release}"
+       exit ;;
+    *:OpenBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
+       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       exit ;;
+    *:ekkoBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       exit ;;
+    macppc:MirBSD:*:*)
+       echo powerppc-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    *:MirBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       exit ;;
+    alpha:OSF1:*:*)
+       case $UNAME_RELEASE in
+       *4.0)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'`
+               ;;
+       *5.*)
+               UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'`
+               ;;
+       esac
+       # According to Compaq, /usr/sbin/psrinfo has been available on
+       # OSF/1 and Tru64 systems produced since 1995.  I hope that
+       # covers most systems running today.  This code pipes the CPU
+       # types through head -n 1, so we only detect the type of CPU 0.
+       ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
+       case "$ALPHA_CPU_TYPE" in
+           "EV4 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "EV4.5 (21064)")
+               UNAME_MACHINE="alpha" ;;
+           "LCA4 (21066/21068)")
+               UNAME_MACHINE="alpha" ;;
+           "EV5 (21164)")
+               UNAME_MACHINE="alphaev5" ;;
+           "EV5.6 (21164A)")
+               UNAME_MACHINE="alphaev56" ;;
+           "EV5.6 (21164PC)")
+               UNAME_MACHINE="alphapca56" ;;
+           "EV5.7 (21164PC)")
+               UNAME_MACHINE="alphapca57" ;;
+           "EV6 (21264)")
+               UNAME_MACHINE="alphaev6" ;;
+           "EV6.7 (21264A)")
+               UNAME_MACHINE="alphaev67" ;;
+           "EV6.8CB (21264C)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8AL (21264B)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.8CX (21264D)")
+               UNAME_MACHINE="alphaev68" ;;
+           "EV6.9A (21264/EV69A)")
+               UNAME_MACHINE="alphaev69" ;;
+           "EV7 (21364)")
+               UNAME_MACHINE="alphaev7" ;;
+           "EV7.9 (21364A)")
+               UNAME_MACHINE="alphaev79" ;;
+       esac
+       # A Pn.n version is a patched version.
+       # A Vn.n version is a released version.
+       # A Tn.n version is a released field test version.
+       # A Xn.n version is an unreleased experimental baselevel.
+       # 1.2 uses "1.2" for uname -r.
+       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       exit ;;
+    Alpha\ *:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # Should we change UNAME_MACHINE based on the output of uname instead
+       # of the specific Alpha model?
+       echo alpha-pc-interix
+       exit ;;
+    21064:Windows_NT:50:3)
+       echo alpha-dec-winnt3.5
+       exit ;;
+    Amiga*:UNIX_System_V:4.0:*)
+       echo m68k-unknown-sysv4
+       exit ;;
+    *:[Aa]miga[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-amigaos
+       exit ;;
+    *:[Mm]orph[Oo][Ss]:*:*)
+       echo ${UNAME_MACHINE}-unknown-morphos
+       exit ;;
+    *:OS/390:*:*)
+       echo i370-ibm-openedition
+       exit ;;
+    *:z/VM:*:*)
+       echo s390-ibm-zvmoe
+       exit ;;
+    *:OS400:*:*)
+        echo powerpc-ibm-os400
+       exit ;;
+    arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
+       echo arm-acorn-riscix${UNAME_RELEASE}
+       exit ;;
+    arm:riscos:*:*|arm:RISCOS:*:*)
+       echo arm-unknown-riscos
+       exit ;;
+    SR2?01:HI-UX/MPP:*:* | SR8000:HI-UX/MPP:*:*)
+       echo hppa1.1-hitachi-hiuxmpp
+       exit ;;
+    Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*)
+       # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE.
+       if test "`(/bin/universe) 2>/dev/null`" = att ; then
+               echo pyramid-pyramid-sysv3
+       else
+               echo pyramid-pyramid-bsd
+       fi
+       exit ;;
+    NILE*:*:*:dcosx)
+       echo pyramid-pyramid-svr4
+       exit ;;
+    DRS?6000:unix:4.0:6*)
+       echo sparc-icl-nx6
+       exit ;;
+    DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*)
+       case `/usr/bin/uname -p` in
+           sparc) echo sparc-icl-nx7; exit ;;
+       esac ;;
+    sun4H:SunOS:5.*:*)
+       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
+       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    i86pc:SunOS:5.*:*)
+       echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:6*:*)
+       # According to config.sub, this is the proper way to canonicalize
+       # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
+       # it's likely to be more like Solaris than SunOS4.
+       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    sun4*:SunOS:*:*)
+       case "`/usr/bin/arch -k`" in
+           Series*|S4*)
+               UNAME_RELEASE=`uname -v`
+               ;;
+       esac
+       # Japanese Language versions have a version number like `4.1.3-JL'.
+       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       exit ;;
+    sun3*:SunOS:*:*)
+       echo m68k-sun-sunos${UNAME_RELEASE}
+       exit ;;
+    sun*:*:4.2BSD:*)
+       UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
+       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       case "`/bin/arch`" in
+           sun3)
+               echo m68k-sun-sunos${UNAME_RELEASE}
+               ;;
+           sun4)
+               echo sparc-sun-sunos${UNAME_RELEASE}
+               ;;
+       esac
+       exit ;;
+    aushp:SunOS:*:*)
+       echo sparc-auspex-sunos${UNAME_RELEASE}
+       exit ;;
+    # The situation for MiNT is a little confusing.  The machine name
+    # can be virtually everything (everything which is not
+    # "atarist" or "atariste" at least should have a processor
+    # > m68000).  The system name ranges from "MiNT" over "FreeMiNT"
+    # to the lowercase version "mint" (or "freemint").  Finally
+    # the system name "TOS" denotes a system which is actually not
+    # MiNT.  But MiNT is downward compatible to TOS, so this should
+    # be no problem.
+    atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
+       echo m68k-atari-mint${UNAME_RELEASE}
+        exit ;;
+    *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
+        echo m68k-atari-mint${UNAME_RELEASE}
+       exit ;;
+    milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
+        echo m68k-milan-mint${UNAME_RELEASE}
+        exit ;;
+    hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
+        echo m68k-hades-mint${UNAME_RELEASE}
+        exit ;;
+    *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
+        echo m68k-unknown-mint${UNAME_RELEASE}
+        exit ;;
+    m68k:machten:*:*)
+       echo m68k-apple-machten${UNAME_RELEASE}
+       exit ;;
+    powerpc:machten:*:*)
+       echo powerpc-apple-machten${UNAME_RELEASE}
+       exit ;;
+    RISC*:Mach:*:*)
+       echo mips-dec-mach_bsd4.3
+       exit ;;
+    RISC*:ULTRIX:*:*)
+       echo mips-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    VAX*:ULTRIX*:*:*)
+       echo vax-dec-ultrix${UNAME_RELEASE}
+       exit ;;
+    2020:CLIX:*:* | 2430:CLIX:*:*)
+       echo clipper-intergraph-clix${UNAME_RELEASE}
+       exit ;;
+    mips:*:*:UMIPS | mips:*:*:RISCos)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+#ifdef __cplusplus
+#include <stdio.h>  /* for printf() prototype */
+       int main (int argc, char *argv[]) {
+#else
+       int main (argc, argv) int argc; char *argv[]; {
+#endif
+       #if defined (host_mips) && defined (MIPSEB)
+       #if defined (SYSTYPE_SYSV)
+         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_SVR4)
+         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+       #endif
+       #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
+         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+       #endif
+       #endif
+         exit (-1);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c &&
+         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`$dummy $dummyarg` &&
+           { echo "$SYSTEM_NAME"; exit; }
+       echo mips-mips-riscos${UNAME_RELEASE}
+       exit ;;
+    Motorola:PowerMAX_OS:*:*)
+       echo powerpc-motorola-powermax
+       exit ;;
+    Motorola:*:4.3:PL8-*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:*:*:PowerMAX_OS | Synergy:PowerMAX_OS:*:*)
+       echo powerpc-harris-powermax
+       exit ;;
+    Night_Hawk:Power_UNIX:*:*)
+       echo powerpc-harris-powerunix
+       exit ;;
+    m88k:CX/UX:7*:*)
+       echo m88k-harris-cxux7
+       exit ;;
+    m88k:*:4*:R4*)
+       echo m88k-motorola-sysv4
+       exit ;;
+    m88k:*:3*:R3*)
+       echo m88k-motorola-sysv3
+       exit ;;
+    AViiON:dgux:*:*)
+        # DG/UX returns AViiON for all architectures
+        UNAME_PROCESSOR=`/usr/bin/uname -p`
+       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       then
+           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
+              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           then
+               echo m88k-dg-dgux${UNAME_RELEASE}
+           else
+               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+           fi
+       else
+           echo i586-dg-dgux${UNAME_RELEASE}
+       fi
+       exit ;;
+    M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
+       echo m88k-dolphin-sysv3
+       exit ;;
+    M88*:*:R3*:*)
+       # Delta 88k system running SVR3
+       echo m88k-motorola-sysv3
+       exit ;;
+    XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3)
+       echo m88k-tektronix-sysv3
+       exit ;;
+    Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD)
+       echo m68k-tektronix-bsd
+       exit ;;
+    *:IRIX*:*:*)
+       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       exit ;;
+    ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
+       echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
+       exit ;;               # Note that: echo "'`uname -s`'" gives 'AIX '
+    i*86:AIX:*:*)
+       echo i386-ibm-aix
+       exit ;;
+    ia64:AIX:*:*)
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:2:3)
+       if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
+               eval $set_cc_for_build
+               sed 's/^                //' << EOF >$dummy.c
+               #include <sys/systemcfg.h>
+
+               main()
+                       {
+                       if (!__power_pc())
+                               exit(1);
+                       puts("powerpc-ibm-aix3.2.5");
+                       exit(0);
+                       }
+EOF
+               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               then
+                       echo "$SYSTEM_NAME"
+               else
+                       echo rs6000-ibm-aix3.2.5
+               fi
+       elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then
+               echo rs6000-ibm-aix3.2.4
+       else
+               echo rs6000-ibm-aix3.2
+       fi
+       exit ;;
+    *:AIX:*:[45])
+       IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
+       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+               IBM_ARCH=rs6000
+       else
+               IBM_ARCH=powerpc
+       fi
+       if [ -x /usr/bin/oslevel ] ; then
+               IBM_REV=`/usr/bin/oslevel`
+       else
+               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+       fi
+       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       exit ;;
+    *:AIX:*:*)
+       echo rs6000-ibm-aix
+       exit ;;
+    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+       echo romp-ibm-bsd4.4
+       exit ;;
+    ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
+       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       exit ;;                             # report: romp-ibm BSD 4.3
+    *:BOSX:*:*)
+       echo rs6000-bull-bosx
+       exit ;;
+    DPX/2?00:B.O.S.:*:*)
+       echo m68k-bull-sysv3
+       exit ;;
+    9000/[34]??:4.3bsd:1.*:*)
+       echo m68k-hp-bsd
+       exit ;;
+    hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*)
+       echo m68k-hp-bsd4.4
+       exit ;;
+    9000/[34678]??:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       case "${UNAME_MACHINE}" in
+           9000/31? )            HP_ARCH=m68000 ;;
+           9000/[34]?? )         HP_ARCH=m68k ;;
+           9000/[678][0-9][0-9])
+               if [ -x /usr/bin/getconf ]; then
+                   sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
+                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
+                    case "${sc_cpu_version}" in
+                      523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
+                      528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                      532)                      # CPU_PA_RISC2_0
+                        case "${sc_kernel_bits}" in
+                          32) HP_ARCH="hppa2.0n" ;;
+                          64) HP_ARCH="hppa2.0w" ;;
+                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                        esac ;;
+                    esac
+               fi
+               if [ "${HP_ARCH}" = "" ]; then
+                   eval $set_cc_for_build
+                   sed 's/^              //' << EOF >$dummy.c
+
+              #define _HPUX_SOURCE
+              #include <stdlib.h>
+              #include <unistd.h>
+
+              int main ()
+              {
+              #if defined(_SC_KERNEL_BITS)
+                  long bits = sysconf(_SC_KERNEL_BITS);
+              #endif
+                  long cpu  = sysconf (_SC_CPU_VERSION);
+
+                  switch (cpu)
+               {
+               case CPU_PA_RISC1_0: puts ("hppa1.0"); break;
+               case CPU_PA_RISC1_1: puts ("hppa1.1"); break;
+               case CPU_PA_RISC2_0:
+              #if defined(_SC_KERNEL_BITS)
+                   switch (bits)
+                       {
+                       case 64: puts ("hppa2.0w"); break;
+                       case 32: puts ("hppa2.0n"); break;
+                       default: puts ("hppa2.0"); break;
+                       } break;
+              #else  /* !defined(_SC_KERNEL_BITS) */
+                   puts ("hppa2.0"); break;
+              #endif
+               default: puts ("hppa1.0"); break;
+               }
+                  exit (0);
+              }
+EOF
+                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+                   test -z "$HP_ARCH" && HP_ARCH=hppa
+               fi ;;
+       esac
+       if [ ${HP_ARCH} = "hppa2.0w" ]
+       then
+           eval $set_cc_for_build
+
+           # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
+           # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
+           # generating 64-bit code.  GNU and HP use different nomenclature:
+           #
+           # $ CC_FOR_BUILD=cc ./config.guess
+           # => hppa2.0w-hp-hpux11.23
+           # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
+           # => hppa64-hp-hpux11.23
+
+           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+               grep __LP64__ >/dev/null
+           then
+               HP_ARCH="hppa2.0w"
+           else
+               HP_ARCH="hppa64"
+           fi
+       fi
+       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       exit ;;
+    ia64:HP-UX:*:*)
+       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux${HPUX_REV}
+       exit ;;
+    3050*:HI-UX:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <unistd.h>
+       int
+       main ()
+       {
+         long cpu = sysconf (_SC_CPU_VERSION);
+         /* The order matters, because CPU_IS_HP_MC68K erroneously returns
+            true for CPU_PA_RISC1_0.  CPU_IS_PA_RISC returns correct
+            results, however.  */
+         if (CPU_IS_PA_RISC (cpu))
+           {
+             switch (cpu)
+               {
+                 case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break;
+                 case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break;
+                 default: puts ("hppa-hitachi-hiuxwe2"); break;
+               }
+           }
+         else if (CPU_IS_HP_MC68K (cpu))
+           puts ("m68k-hitachi-hiuxwe2");
+         else puts ("unknown-hitachi-hiuxwe2");
+         exit (0);
+       }
+EOF
+       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+               { echo "$SYSTEM_NAME"; exit; }
+       echo unknown-hitachi-hiuxwe2
+       exit ;;
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+       echo hppa1.1-hp-bsd
+       exit ;;
+    9000/8??:4.3bsd:*:*)
+       echo hppa1.0-hp-bsd
+       exit ;;
+    *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
+       echo hppa1.0-hp-mpeix
+       exit ;;
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+       echo hppa1.1-hp-osf
+       exit ;;
+    hp8??:OSF1:*:*)
+       echo hppa1.0-hp-osf
+       exit ;;
+    i*86:OSF1:*:*)
+       if [ -x /usr/sbin/sysversion ] ; then
+           echo ${UNAME_MACHINE}-unknown-osf1mk
+       else
+           echo ${UNAME_MACHINE}-unknown-osf1
+       fi
+       exit ;;
+    parisc*:Lites*:*:*)
+       echo hppa1.1-hp-lites
+       exit ;;
+    C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*)
+       echo c1-convex-bsd
+        exit ;;
+    C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+        exit ;;
+    C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*)
+       echo c34-convex-bsd
+        exit ;;
+    C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*)
+       echo c38-convex-bsd
+        exit ;;
+    C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*)
+       echo c4-convex-bsd
+        exit ;;
+    CRAY*Y-MP:*:*:*)
+       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*[A-Z]90:*:*:*)
+       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
+             -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
+             -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*TS:*:*:*)
+       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*T3E:*:*:*)
+       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    CRAY*SV1:*:*:*)
+       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    *:UNICOS/mp:*:*)
+       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       exit ;;
+    F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
+       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+        exit ;;
+    5000:UNIX_System_V:4.*:*)
+        FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
+        FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
+       exit ;;
+    i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
+       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       exit ;;
+    sparc*:BSD/OS:*:*)
+       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:BSD/OS:*:*)
+       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       exit ;;
+    *:FreeBSD:*:*)
+       echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit ;;
+    i*:CYGWIN*:*)
+       echo ${UNAME_MACHINE}-pc-cygwin
+       exit ;;
+    i*:MINGW*:*)
+       echo ${UNAME_MACHINE}-pc-mingw32
+       exit ;;
+    i*:windows32*:*)
+       # uname -m includes "-pc" on this system.
+       echo ${UNAME_MACHINE}-mingw32
+       exit ;;
+    i*:PW*:*)
+       echo ${UNAME_MACHINE}-pc-pw32
+       exit ;;
+    x86:Interix*:[34]*)
+       echo i586-pc-interix${UNAME_RELEASE}|sed -e 's/\..*//'
+       exit ;;
+    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
+       echo i${UNAME_MACHINE}-pc-mks
+       exit ;;
+    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
+       # How do we know it's Interix rather than the generic POSIX subsystem?
+       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
+       # UNAME_MACHINE based on the output of uname instead of i386?
+       echo i586-pc-interix
+       exit ;;
+    i*:UWIN*:*)
+       echo ${UNAME_MACHINE}-pc-uwin
+       exit ;;
+    amd64:CYGWIN*:*:*)
+       echo x86_64-unknown-cygwin
+       exit ;;
+    p*:CYGWIN*:*)
+       echo powerpcle-unknown-cygwin
+       exit ;;
+    prep*:SunOS:5.*:*)
+       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       exit ;;
+    *:GNU:*:*)
+       # the GNU system
+       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       exit ;;
+    *:GNU/*:*:*)
+       # other systems with GNU libc and userland
+       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-gnu
+       exit ;;
+    i*86:Minix:*:*)
+       echo ${UNAME_MACHINE}-pc-minix
+       exit ;;
+    arm*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    cris:Linux:*:*)
+       echo cris-axis-linux-gnu
+       exit ;;
+    crisv32:Linux:*:*)
+       echo crisv32-axis-linux-gnu
+       exit ;;
+    frv:Linux:*:*)
+       echo frv-unknown-linux-gnu
+       exit ;;
+    ia64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m32r*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    m68*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    mips:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef mips
+       #undef mipsel
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=mipsel
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=mips
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    mips64:Linux:*:*)
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #undef CPU
+       #undef mips64
+       #undef mips64el
+       #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL)
+       CPU=mips64el
+       #else
+       #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB)
+       CPU=mips64
+       #else
+       CPU=
+       #endif
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^CPU=`
+       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-gnu"; exit; }
+       ;;
+    ppc:Linux:*:*)
+       echo powerpc-unknown-linux-gnu
+       exit ;;
+    ppc64:Linux:*:*)
+       echo powerpc64-unknown-linux-gnu
+       exit ;;
+    alpha:Linux:*:*)
+       case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
+         EV5)   UNAME_MACHINE=alphaev5 ;;
+         EV56)  UNAME_MACHINE=alphaev56 ;;
+         PCA56) UNAME_MACHINE=alphapca56 ;;
+         PCA57) UNAME_MACHINE=alphapca56 ;;
+         EV6)   UNAME_MACHINE=alphaev6 ;;
+         EV67)  UNAME_MACHINE=alphaev67 ;;
+         EV68*) UNAME_MACHINE=alphaev68 ;;
+        esac
+       objdump --private-headers /bin/sh | grep ld.so.1 >/dev/null
+       if test "$?" = 0 ; then LIBC="libc1" ; else LIBC="" ; fi
+       echo ${UNAME_MACHINE}-unknown-linux-gnu${LIBC}
+       exit ;;
+    parisc:Linux:*:* | hppa:Linux:*:*)
+       # Look for CPU level
+       case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
+         PA7*) echo hppa1.1-unknown-linux-gnu ;;
+         PA8*) echo hppa2.0-unknown-linux-gnu ;;
+         *)    echo hppa-unknown-linux-gnu ;;
+       esac
+       exit ;;
+    parisc64:Linux:*:* | hppa64:Linux:*:*)
+       echo hppa64-unknown-linux-gnu
+       exit ;;
+    s390:Linux:*:* | s390x:Linux:*:*)
+       echo ${UNAME_MACHINE}-ibm-linux
+       exit ;;
+    sh64*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sh*:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    sparc:Linux:*:* | sparc64:Linux:*:*)
+       echo ${UNAME_MACHINE}-unknown-linux-gnu
+       exit ;;
+    x86_64:Linux:*:*)
+       echo x86_64-unknown-linux-gnu
+       exit ;;
+    i*86:Linux:*:*)
+       # The BFD linker knows what the default object file format is, so
+       # first see if it will tell us. cd to the root directory to prevent
+       # problems with other programs or directories called `ld' in the path.
+       # Set LC_ALL=C to ensure ld outputs messages in English.
+       ld_supported_targets=`cd /; LC_ALL=C ld --help 2>&1 \
+                        | sed -ne '/supported targets:/!d
+                                   s/[         ][      ]*/ /g
+                                   s/.*supported targets: *//
+                                   s/ .*//
+                                   p'`
+        case "$ld_supported_targets" in
+         elf32-i386)
+               TENTATIVE="${UNAME_MACHINE}-pc-linux-gnu"
+               ;;
+         a.out-i386-linux)
+               echo "${UNAME_MACHINE}-pc-linux-gnuaout"
+               exit ;;
+         coff-i386)
+               echo "${UNAME_MACHINE}-pc-linux-gnucoff"
+               exit ;;
+         "")
+               # Either a pre-BFD a.out linker (linux-gnuoldld) or
+               # one that does not give us useful --help.
+               echo "${UNAME_MACHINE}-pc-linux-gnuoldld"
+               exit ;;
+       esac
+       # Determine whether the default compiler is a.out or elf
+       eval $set_cc_for_build
+       sed 's/^        //' << EOF >$dummy.c
+       #include <features.h>
+       #ifdef __ELF__
+       # ifdef __GLIBC__
+       #  if __GLIBC__ >= 2
+       LIBC=gnu
+       #  else
+       LIBC=gnulibc1
+       #  endif
+       # else
+       LIBC=gnulibc1
+       # endif
+       #else
+       #ifdef __INTEL_COMPILER
+       LIBC=gnu
+       #else
+       LIBC=gnuaout
+       #endif
+       #endif
+       #ifdef __dietlibc__
+       LIBC=dietlibc
+       #endif
+EOF
+       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep ^LIBC=`
+       test x"${LIBC}" != x && {
+               echo "${UNAME_MACHINE}-pc-linux-${LIBC}"
+               exit
+       }
+       test x"${TENTATIVE}" != x && { echo "${TENTATIVE}"; exit; }
+       ;;
+    i*86:DYNIX/ptx:4*:*)
+       # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
+       # earlier versions are messed up and put the nodename in both
+       # sysname and nodename.
+       echo i386-sequent-sysv4
+       exit ;;
+    i*86:UNIX_SV:4.2MP:2.*)
+        # Unixware is an offshoot of SVR4, but it has its own version
+        # number series starting with 2...
+        # I am not positive that other SVR4 systems won't match this,
+       # I just have to hope.  -- rms.
+        # Use sysv4.2uw... so that sysv4* matches it.
+       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       exit ;;
+    i*86:OS/2:*:*)
+       # If we were able to find `uname', then EMX Unix compatibility
+       # is probably installed.
+       echo ${UNAME_MACHINE}-pc-os2-emx
+       exit ;;
+    i*86:XTS-300:*:STOP)
+       echo ${UNAME_MACHINE}-unknown-stop
+       exit ;;
+    i*86:atheos:*:*)
+       echo ${UNAME_MACHINE}-unknown-atheos
+       exit ;;
+    i*86:syllable:*:*)
+       echo ${UNAME_MACHINE}-pc-syllable
+       exit ;;
+    i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.0*:*)
+       echo i386-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    i*86:*DOS:*:*)
+       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       exit ;;
+    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
+       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+       if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
+               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+       else
+               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+       fi
+       exit ;;
+    i*86:*:5:[678]*)
+       # UnixWare 7.x, OpenUNIX and OpenServer 6.
+       case `/bin/uname -X | grep "^Machine"` in
+           *486*)           UNAME_MACHINE=i486 ;;
+           *Pentium)        UNAME_MACHINE=i586 ;;
+           *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
+       esac
+       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       exit ;;
+    i*86:*:3.2:*)
+       if test -f /usr/options/cb.name; then
+               UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
+               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+       elif /bin/uname -X 2>/dev/null >/dev/null ; then
+               UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
+               (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
+               (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \
+                       && UNAME_MACHINE=i586
+               (/bin/uname -X|grep '^Machine.*Pent *II' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
+                       && UNAME_MACHINE=i686
+               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+       else
+               echo ${UNAME_MACHINE}-pc-sysv32
+       fi
+       exit ;;
+    pc:*:*:*)
+       # Left here for compatibility:
+        # uname -m prints for DJGPP always 'pc', but it prints nothing about
+        # the processor, so we play safe by assuming i386.
+       echo i386-pc-msdosdjgpp
+        exit ;;
+    Intel:Mach:3*:*)
+       echo i386-pc-mach3
+       exit ;;
+    paragon:*:*:*)
+       echo i860-intel-osf1
+       exit ;;
+    i860:*:4.*:*) # i860-SVR4
+       if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
+         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+       else # Add other i860-SVR4 vendors below as they are discovered.
+         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+       fi
+       exit ;;
+    mini*:CTIX:SYS*5:*)
+       # "miniframe"
+       echo m68010-convergent-sysv
+       exit ;;
+    mc68k:UNIX:SYSTEM5:3.51m)
+       echo m68k-convergent-sysv
+       exit ;;
+    M680?0:D-NIX:5.3:*)
+       echo m68k-diab-dnix
+       exit ;;
+    M68*:*:R3V[5678]*:*)
+       test -r /sysV68 && { echo 'm68k-motorola-sysv'; exit; } ;;
+    3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0)
+       OS_REL=''
+       test -r /etc/.relid \
+       && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
+       /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+       /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
+         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+    3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
+        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
+          && { echo i486-ncr-sysv4; exit; } ;;
+    m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
+       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    mc68030:UNIX_System_V:4.*:*)
+       echo m68k-atari-sysv4
+       exit ;;
+    TSUNAMI:LynxOS:2.*:*)
+       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    rs6000:LynxOS:2.*:*)
+       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.0*:*)
+       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       exit ;;
+    SM[BE]S:UNIX_SV:*:*)
+       echo mips-dde-sysv${UNAME_RELEASE}
+       exit ;;
+    RM*:ReliantUNIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    RM*:SINIX-*:*:*)
+       echo mips-sni-sysv4
+       exit ;;
+    *:SINIX-*:*:*)
+       if uname -p 2>/dev/null >/dev/null ; then
+               UNAME_MACHINE=`(uname -p) 2>/dev/null`
+               echo ${UNAME_MACHINE}-sni-sysv4
+       else
+               echo ns32k-sni-sysv
+       fi
+       exit ;;
+    PENTIUM:*:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort
+                      # says <Richard.M.Bartel@ccMail.Census.GOV>
+        echo i586-unisys-sysv4
+        exit ;;
+    *:UNIX_System_V:4*:FTX*)
+       # From Gerald Hewes <hewes@openmarket.com>.
+       # How about differentiating between stratus architectures? -djm
+       echo hppa1.1-stratus-sysv4
+       exit ;;
+    *:*:*:FTX*)
+       # From seanf@swdc.stratus.com.
+       echo i860-stratus-sysv4
+       exit ;;
+    i*86:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo ${UNAME_MACHINE}-stratus-vos
+       exit ;;
+    *:VOS:*:*)
+       # From Paul.Green@stratus.com.
+       echo hppa1.1-stratus-vos
+       exit ;;
+    mc68*:A/UX:*:*)
+       echo m68k-apple-aux${UNAME_RELEASE}
+       exit ;;
+    news*:NEWS-OS:6*:*)
+       echo mips-sony-newsos6
+       exit ;;
+    R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
+       if [ -d /usr/nec ]; then
+               echo mips-nec-sysv${UNAME_RELEASE}
+       else
+               echo mips-unknown-sysv${UNAME_RELEASE}
+       fi
+        exit ;;
+    BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
+       echo powerpc-be-beos
+       exit ;;
+    BeMac:BeOS:*:*)    # BeOS running on Mac or Mac clone, PPC only.
+       echo powerpc-apple-beos
+       exit ;;
+    BePC:BeOS:*:*)     # BeOS running on Intel PC compatible.
+       echo i586-pc-beos
+       exit ;;
+    SX-4:SUPER-UX:*:*)
+       echo sx4-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-5:SUPER-UX:*:*)
+       echo sx5-nec-superux${UNAME_RELEASE}
+       exit ;;
+    SX-6:SUPER-UX:*:*)
+       echo sx6-nec-superux${UNAME_RELEASE}
+       exit ;;
+    Power*:Rhapsody:*:*)
+       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Rhapsody:*:*)
+       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       exit ;;
+    *:Darwin:*:*)
+       UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
+       case $UNAME_PROCESSOR in
+           *86) UNAME_PROCESSOR=i686 ;;
+           unknown) UNAME_PROCESSOR=powerpc ;;
+       esac
+       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       exit ;;
+    *:procnto*:*:* | *:QNX:[0123456789]*:*)
+       UNAME_PROCESSOR=`uname -p`
+       if test "$UNAME_PROCESSOR" = "x86"; then
+               UNAME_PROCESSOR=i386
+               UNAME_MACHINE=pc
+       fi
+       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       exit ;;
+    *:QNX:*:4*)
+       echo i386-pc-qnx
+       exit ;;
+    NSE-?:NONSTOP_KERNEL:*:*)
+       echo nse-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    NSR-?:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk${UNAME_RELEASE}
+       exit ;;
+    *:NonStop-UX:*:*)
+       echo mips-compaq-nonstopux
+       exit ;;
+    BS2000:POSIX*:*:*)
+       echo bs2000-siemens-sysv
+       exit ;;
+    DS/*:UNIX_System_V:*:*)
+       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       exit ;;
+    *:Plan9:*:*)
+       # "uname -m" is not consistent, so use $cputype instead. 386
+       # is converted to i386 for consistency with other x86
+       # operating systems.
+       if test "$cputype" = "386"; then
+           UNAME_MACHINE=i386
+       else
+           UNAME_MACHINE="$cputype"
+       fi
+       echo ${UNAME_MACHINE}-unknown-plan9
+       exit ;;
+    *:TOPS-10:*:*)
+       echo pdp10-unknown-tops10
+       exit ;;
+    *:TENEX:*:*)
+       echo pdp10-unknown-tenex
+       exit ;;
+    KS10:TOPS-20:*:* | KL10:TOPS-20:*:* | TYPE4:TOPS-20:*:*)
+       echo pdp10-dec-tops20
+       exit ;;
+    XKL-1:TOPS-20:*:* | TYPE5:TOPS-20:*:*)
+       echo pdp10-xkl-tops20
+       exit ;;
+    *:TOPS-20:*:*)
+       echo pdp10-unknown-tops20
+       exit ;;
+    *:ITS:*:*)
+       echo pdp10-unknown-its
+       exit ;;
+    SEI:*:*:SEIUX)
+        echo mips-sei-seiux${UNAME_RELEASE}
+       exit ;;
+    *:DragonFly:*:*)
+       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       exit ;;
+    *:*VMS:*:*)
+       UNAME_MACHINE=`(uname -p) 2>/dev/null`
+       case "${UNAME_MACHINE}" in
+           A*) echo alpha-dec-vms ; exit ;;
+           I*) echo ia64-dec-vms ; exit ;;
+           V*) echo vax-dec-vms ; exit ;;
+       esac ;;
+    *:XENIX:*:SysV)
+       echo i386-pc-xenix
+       exit ;;
+    i*86:skyos:*:*)
+       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+       exit ;;
+esac
+
+#echo '(No uname command or uname output not recognized.)' 1>&2
+#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2
+
+eval $set_cc_for_build
+cat >$dummy.c <<EOF
+#ifdef _SEQUENT_
+# include <sys/types.h>
+# include <sys/utsname.h>
+#endif
+main ()
+{
+#if defined (sony)
+#if defined (MIPSEB)
+  /* BFD wants "bsd" instead of "newsos".  Perhaps BFD should be changed,
+     I don't know....  */
+  printf ("mips-sony-bsd\n"); exit (0);
+#else
+#include <sys/param.h>
+  printf ("m68k-sony-newsos%s\n",
+#ifdef NEWSOS4
+          "4"
+#else
+         ""
+#endif
+         ); exit (0);
+#endif
+#endif
+
+#if defined (__arm) && defined (__acorn) && defined (__unix)
+  printf ("arm-acorn-riscix\n"); exit (0);
+#endif
+
+#if defined (hp300) && !defined (hpux)
+  printf ("m68k-hp-bsd\n"); exit (0);
+#endif
+
+#if defined (NeXT)
+#if !defined (__ARCHITECTURE__)
+#define __ARCHITECTURE__ "m68k"
+#endif
+  int version;
+  version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`;
+  if (version < 4)
+    printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version);
+  else
+    printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version);
+  exit (0);
+#endif
+
+#if defined (MULTIMAX) || defined (n16)
+#if defined (UMAXV)
+  printf ("ns32k-encore-sysv\n"); exit (0);
+#else
+#if defined (CMU)
+  printf ("ns32k-encore-mach\n"); exit (0);
+#else
+  printf ("ns32k-encore-bsd\n"); exit (0);
+#endif
+#endif
+#endif
+
+#if defined (__386BSD__)
+  printf ("i386-pc-bsd\n"); exit (0);
+#endif
+
+#if defined (sequent)
+#if defined (i386)
+  printf ("i386-sequent-dynix\n"); exit (0);
+#endif
+#if defined (ns32000)
+  printf ("ns32k-sequent-dynix\n"); exit (0);
+#endif
+#endif
+
+#if defined (_SEQUENT_)
+    struct utsname un;
+
+    uname(&un);
+
+    if (strncmp(un.version, "V2", 2) == 0) {
+       printf ("i386-sequent-ptx2\n"); exit (0);
+    }
+    if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */
+       printf ("i386-sequent-ptx1\n"); exit (0);
+    }
+    printf ("i386-sequent-ptx\n"); exit (0);
+
+#endif
+
+#if defined (vax)
+# if !defined (ultrix)
+#  include <sys/param.h>
+#  if defined (BSD)
+#   if BSD == 43
+      printf ("vax-dec-bsd4.3\n"); exit (0);
+#   else
+#    if BSD == 199006
+      printf ("vax-dec-bsd4.3reno\n"); exit (0);
+#    else
+      printf ("vax-dec-bsd\n"); exit (0);
+#    endif
+#   endif
+#  else
+    printf ("vax-dec-bsd\n"); exit (0);
+#  endif
+# else
+    printf ("vax-dec-ultrix\n"); exit (0);
+# endif
+#endif
+
+#if defined (alliant) && defined (i860)
+  printf ("i860-alliant-bsd\n"); exit (0);
+#endif
+
+  exit (1);
+}
+EOF
+
+$CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null && SYSTEM_NAME=`$dummy` &&
+       { echo "$SYSTEM_NAME"; exit; }
+
+# Apollos put the system type in the environment.
+
+test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit; }
+
+# Convex versions that predate uname can use getsysinfo(1)
+
+if [ -x /usr/convex/getsysinfo ]
+then
+    case `getsysinfo -f cpu_type` in
+    c1*)
+       echo c1-convex-bsd
+       exit ;;
+    c2*)
+       if getsysinfo -f scalar_acc
+       then echo c32-convex-bsd
+       else echo c2-convex-bsd
+       fi
+       exit ;;
+    c34*)
+       echo c34-convex-bsd
+       exit ;;
+    c38*)
+       echo c38-convex-bsd
+       exit ;;
+    c4*)
+       echo c4-convex-bsd
+       exit ;;
+    esac
+fi
+
+cat >&2 <<EOF
+$0: unable to guess system type
+
+This script, last modified $timestamp, has failed to recognize
+the operating system you are using. It is advised that you
+download the most up to date version of the config scripts from
+
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.guess
+and
+  http://savannah.gnu.org/cgi-bin/viewcvs/*checkout*/config/config/config.sub
+
+If the version you run ($0) is already up to date, please
+send the following data and any information you think might be
+pertinent to <config-patches@gnu.org> in order to provide the needed
+information to handle your system.
+
+config.guess timestamp = $timestamp
+
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null`
+
+hostinfo               = `(hostinfo) 2>/dev/null`
+/bin/universe          = `(/bin/universe) 2>/dev/null`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null`
+/bin/arch              = `(/bin/arch) 2>/dev/null`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
+
+UNAME_MACHINE = ${UNAME_MACHINE}
+UNAME_RELEASE = ${UNAME_RELEASE}
+UNAME_SYSTEM  = ${UNAME_SYSTEM}
+UNAME_VERSION = ${UNAME_VERSION}
+EOF
+
+exit 1
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/sntp/config.h.in b/sntp/config.h.in
new file mode 100644 (file)
index 0000000..ae394d7
--- /dev/null
@@ -0,0 +1,304 @@
+/* config.h.in.  Generated from configure.ac by autoheader.  */
+
+/* fopen(3) accepts a 'b' in the mode flag */
+#undef FOPEN_BINARY_FLAG
+
+/* fopen(3) accepts a 't' in the mode flag */
+#undef FOPEN_TEXT_FLAG
+
+/* Define to 1 if you have the `alarm' function. */
+#undef HAVE_ALARM
+
+/* Define to 1 if you have the <arpa/inet.h> header file. */
+#undef HAVE_ARPA_INET_H
+
+/* Define to 1 if you have the `canonicalize_file_name' function. */
+#undef HAVE_CANONICALIZE_FILE_NAME
+
+/* Define this if /dev/zero is readable device */
+#undef HAVE_DEV_ZERO
+
+/* Define to 1 if you have the <dirent.h> header file, and it defines `DIR'.
+   */
+#undef HAVE_DIRENT_H
+
+/* Define to 1 if you have the <dlfcn.h> header file. */
+#undef HAVE_DLFCN_H
+
+/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
+#undef HAVE_DOPRNT
+
+/* Define to 1 if you have the <errno.h> header file. */
+#undef HAVE_ERRNO_H
+
+/* Define to 1 if you have the <fcntl.h> header file. */
+#undef HAVE_FCNTL_H
+
+/* Define to 1 if you have the <float.h> header file. */
+#undef HAVE_FLOAT_H
+
+/* Define to 1 if you have the `gettimeofday' function. */
+#undef HAVE_GETTIMEOFDAY
+
+/* Define to 1 if you have the `inet_ntoa' function. */
+#undef HAVE_INET_NTOA
+
+/* inline keyword or macro available */
+#undef HAVE_INLINE
+
+/* Define to 1 if the system has the type `int16_t'. */
+#undef HAVE_INT16_T
+
+/* Define to 1 if the system has the type `int32_t'. */
+#undef HAVE_INT32_T
+
+/* Define to 1 if the system has the type `int8_t'. */
+#undef HAVE_INT8_T
+
+/* Define to 1 if the system has the type `intptr_t'. */
+#undef HAVE_INTPTR_T
+
+/* Define to 1 if you have the <inttypes.h> header file. */
+#undef HAVE_INTTYPES_H
+
+/* Define to 1 if you have the `gen' library (-lgen). */
+#undef HAVE_LIBGEN
+
+/* Define to 1 if you have the <libgen.h> header file. */
+#undef HAVE_LIBGEN_H
+
+/* Define to 1 if you have the <limits.h> header file. */
+#undef HAVE_LIMITS_H
+
+/* Define to 1 if you have the <memory.h> header file. */
+#undef HAVE_MEMORY_H
+
+/* Define to 1 if you have the `memset' function. */
+#undef HAVE_MEMSET
+
+/* Define to 1 if you have the `mmap' function. */
+#undef HAVE_MMAP
+
+/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
+#undef HAVE_NDIR_H
+
+/* Define to 1 if you have the <netdb.h> header file. */
+#undef HAVE_NETDB_H
+
+/* Define to 1 if you have the <netinet/in.h> header file. */
+#undef HAVE_NETINET_IN_H
+
+/* Define this if pathfind(3) works */
+#undef HAVE_PATHFIND
+
+/* Define this if we have a functional realpath(3C) */
+#undef HAVE_REALPATH
+
+/* Define to 1 if you have the <setjmp.h> header file. */
+#undef HAVE_SETJMP_H
+
+/* Define to 1 if you have the `snprintf' function. */
+#undef HAVE_SNPRINTF
+
+/* Define to 1 if you have the `socket' function. */
+#undef HAVE_SOCKET
+
+/* Define to 1 if you have the `sqrt' function. */
+#undef HAVE_SQRT
+
+/* Does struct sockaddr_storage have ss_family? */
+#undef HAVE_SS_FAMILY_IN_SS
+
+/* Define to 1 if you have the <stdarg.h> header file. */
+#undef HAVE_STDARG_H
+
+/* Define to 1 if you have the <stdint.h> header file. */
+#undef HAVE_STDINT_H
+
+/* Define to 1 if you have the <stdlib.h> header file. */
+#undef HAVE_STDLIB_H
+
+/* Define to 1 if you have the `strchr' function. */
+#undef HAVE_STRCHR
+
+/* Define to 1 if you have the `strdup' function. */
+#undef HAVE_STRDUP
+
+/* Define this if strftime() works */
+#undef HAVE_STRFTIME
+
+/* Define to 1 if you have the <strings.h> header file. */
+#undef HAVE_STRINGS_H
+
+/* Define to 1 if you have the <string.h> header file. */
+#undef HAVE_STRING_H
+
+/* Define to 1 if you have the `strrchr' function. */
+#undef HAVE_STRRCHR
+
+/* Define to 1 if you have the <sysexits.h> header file. */
+#undef HAVE_SYSEXITS_H
+
+/* Define to 1 if you have the <syslog.h> header file. */
+#undef HAVE_SYSLOG_H
+
+/* Define to 1 if you have the <sys/dir.h> header file, and it defines `DIR'.
+   */
+#undef HAVE_SYS_DIR_H
+
+/* Define to 1 if you have the <sys/limits.h> header file. */
+#undef HAVE_SYS_LIMITS_H
+
+/* Define to 1 if you have the <sys/mman.h> header file. */
+#undef HAVE_SYS_MMAN_H
+
+/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
+   */
+#undef HAVE_SYS_NDIR_H
+
+/* Define to 1 if you have the <sys/param.h> header file. */
+#undef HAVE_SYS_PARAM_H
+
+/* Define to 1 if you have the <sys/poll.h> header file. */
+#undef HAVE_SYS_POLL_H
+
+/* Define to 1 if you have the <sys/procset.h> header file. */
+#undef HAVE_SYS_PROCSET_H
+
+/* Define to 1 if you have the <sys/select.h> header file. */
+#undef HAVE_SYS_SELECT_H
+
+/* Define to 1 if you have the <sys/socket.h> header file. */
+#undef HAVE_SYS_SOCKET_H
+
+/* Define to 1 if you have the <sys/stat.h> header file. */
+#undef HAVE_SYS_STAT_H
+
+/* Define to 1 if you have the <sys/stropts.h> header file. */
+#undef HAVE_SYS_STROPTS_H
+
+/* Define to 1 if you have the <sys/time.h> header file. */
+#undef HAVE_SYS_TIME_H
+
+/* Define to 1 if you have the <sys/types.h> header file. */
+#undef HAVE_SYS_TYPES_H
+
+/* Define to 1 if you have the <sys/un.h> header file. */
+#undef HAVE_SYS_UN_H
+
+/* Define to 1 if you have the <sys/wait.h> header file. */
+#undef HAVE_SYS_WAIT_H
+
+/* Define to 1 if the system has the type `uint16_t'. */
+#undef HAVE_UINT16_T
+
+/* Define to 1 if the system has the type `uint32_t'. */
+#undef HAVE_UINT32_T
+
+/* Define to 1 if the system has the type `uint8_t'. */
+#undef HAVE_UINT8_T
+
+/* Define to 1 if the system has the type `uintptr_t'. */
+#undef HAVE_UINTPTR_T
+
+/* Define to 1 if the system has the type `uint_t'. */
+#undef HAVE_UINT_T
+
+/* Define to 1 if you have the <unistd.h> header file. */
+#undef HAVE_UNISTD_H
+
+/* Define to 1 if you have the <utime.h> header file. */
+#undef HAVE_UTIME_H
+
+/* Define to 1 if you have the <values.h> header file. */
+#undef HAVE_VALUES_H
+
+/* Define to 1 if you have the <varargs.h> header file. */
+#undef HAVE_VARARGS_H
+
+/* Define to 1 if you have the `vprintf' function. */
+#undef HAVE_VPRINTF
+
+/* Does struct sockaddr_storage have __ss_family? */
+#undef HAVE___SS_FAMILY_IN_SS
+
+/* Define this if optional arguments are disallowed */
+#undef NO_OPTIONAL_OPT_ARGS
+
+/* Should we avoid #warning on option name collisions? */
+#undef NO_OPTION_NAME_WARNINGS
+
+/* Name of package */
+#undef PACKAGE
+
+/* Define to the address where bug reports for this package should be sent. */
+#undef PACKAGE_BUGREPORT
+
+/* Define to the full name of this package. */
+#undef PACKAGE_NAME
+
+/* Define to the full name and version of this package. */
+#undef PACKAGE_STRING
+
+/* Define to the one symbol short name of this package. */
+#undef PACKAGE_TARNAME
+
+/* Define to the home page for this package. */
+#undef PACKAGE_URL
+
+/* Define to the version of this package. */
+#undef PACKAGE_VERSION
+
+/* name of regex header file */
+#undef REGEX_HEADER
+
+/* Define as the return type of signal handlers (`int' or `void'). */
+#undef RETSIGTYPE
+
+/* The size of `char*', as computed by sizeof. */
+#undef SIZEOF_CHARP
+
+/* The size of `int', as computed by sizeof. */
+#undef SIZEOF_INT
+
+/* The size of `long', as computed by sizeof. */
+#undef SIZEOF_LONG
+
+/* The size of `short', as computed by sizeof. */
+#undef SIZEOF_SHORT
+
+/* Define to 1 if you have the ANSI C header files. */
+#undef STDC_HEADERS
+
+/* Define to 1 if you can safely include both <sys/time.h> and <time.h>. */
+#undef TIME_WITH_SYS_TIME
+
+/* Define to 1 if your <sys/time.h> declares `struct tm'. */
+#undef TM_IN_SYS_TIME
+
+/* Version number of package */
+#undef VERSION
+
+/* Define this if a working libregex can be found */
+#undef WITH_LIBREGEX
+
+/* Define to empty if `const' does not conform to ANSI C. */
+#undef const
+
+/* Define to `__inline__' or `__inline' if that's what the C compiler
+   calls it, or to nothing if 'inline' is not supported under any name.  */
+#ifndef __cplusplus
+#undef inline
+#endif
+
+/* Define to `unsigned int' if <sys/types.h> does not define. */
+#undef size_t
+
+/* normalize ss_family access */
+#undef ss_family
+
+/* normalize ss_len access */
+#undef ss_len
+
+/* Alternate uintptr_t for systems without it. */
+#undef uintptr_t
diff --git a/sntp/config.sub b/sntp/config.sub
new file mode 100755 (executable)
index 0000000..1c366df
--- /dev/null
@@ -0,0 +1,1579 @@
+#! /bin/sh
+# Configuration validation subroutine script.
+#   Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999,
+#   2000, 2001, 2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+timestamp='2005-07-08'
+
+# This file is (in principle) common to ALL GNU software.
+# The presence of a machine in this file suggests that SOME GNU software
+# can handle that machine.  It does not imply ALL GNU software can.
+#
+# This file is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
+# 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+
+# Please send patches to <config-patches@gnu.org>.  Submit a context
+# diff and a properly formatted ChangeLog entry.
+#
+# Configuration subroutine to validate and canonicalize a configuration type.
+# Supply the specified configuration type as an argument.
+# If it is invalid, we print an error message on stderr and exit with code 1.
+# Otherwise, we print the canonical config type on stdout and succeed.
+
+# This file is supposed to be the same for all GNU packages
+# and recognize all the CPU types, system types and aliases
+# that are meaningful with *any* GNU software.
+# Each package is responsible for reporting which valid configurations
+# it does not support.  The user should be able to distinguish
+# a failure to support a valid configuration from a meaningless
+# configuration.
+
+# The goal of this file is to map all the various variations of a given
+# machine specification into a single specification in the form:
+#      CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
+# or in some cases, the newer four-part form:
+#      CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
+# It is wrong to echo any other type of specification.
+
+me=`echo "$0" | sed -e 's,.*/,,'`
+
+usage="\
+Usage: $0 [OPTION] CPU-MFR-OPSYS
+       $0 [OPTION] ALIAS
+
+Canonicalize a configuration name.
+
+Operation modes:
+  -h, --help         print this help, then exit
+  -t, --time-stamp   print date of last modification, then exit
+  -v, --version      print version number, then exit
+
+Report bugs and patches to <config-patches@gnu.org>."
+
+version="\
+GNU config.sub ($timestamp)
+
+Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005
+Free Software Foundation, Inc.
+
+This is free software; see the source for copying conditions.  There is NO
+warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+
+help="
+Try \`$me --help' for more information."
+
+# Parse command line
+while test $# -gt 0 ; do
+  case $1 in
+    --time-stamp | --time* | -t )
+       echo "$timestamp" ; exit ;;
+    --version | -v )
+       echo "$version" ; exit ;;
+    --help | --h* | -h )
+       echo "$usage"; exit ;;
+    -- )     # Stop option processing
+       shift; break ;;
+    - )        # Use stdin as input.
+       break ;;
+    -* )
+       echo "$me: invalid option $1$help"
+       exit 1 ;;
+
+    *local*)
+       # First pass through any local machine types.
+       echo $1
+       exit ;;
+
+    * )
+       break ;;
+  esac
+done
+
+case $# in
+ 0) echo "$me: missing argument$help" >&2
+    exit 1;;
+ 1) ;;
+ *) echo "$me: too many arguments$help" >&2
+    exit 1;;
+esac
+
+# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
+# Here we must recognize all the valid KERNEL-OS combinations.
+maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
+case $maybe_os in
+  nto-qnx* | linux-gnu* | linux-dietlibc | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | \
+  kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* | storm-chaos* | os2-emx* | rtmk-nova*)
+    os=-$maybe_os
+    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
+    ;;
+  *)
+    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
+    if [ $basic_machine != $1 ]
+    then os=`echo $1 | sed 's/.*-/-/'`
+    else os=; fi
+    ;;
+esac
+
+### Let's recognize common machines as not being operating systems so
+### that things like config.sub decstation-3100 work.  We also
+### recognize some manufacturers as not being operating systems, so we
+### can provide default operating systems below.
+case $os in
+       -sun*os*)
+               # Prevent following clause from handling this invalid input.
+               ;;
+       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
+       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
+       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
+       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
+       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
+       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
+       -apple | -axis | -knuth | -cray)
+               os=
+               basic_machine=$1
+               ;;
+       -sim | -cisco | -oki | -wec | -winbond)
+               os=
+               basic_machine=$1
+               ;;
+       -scout)
+               ;;
+       -wrs)
+               os=-vxworks
+               basic_machine=$1
+               ;;
+       -chorusos*)
+               os=-chorusos
+               basic_machine=$1
+               ;;
+       -chorusrdb)
+               os=-chorusrdb
+               basic_machine=$1
+               ;;
+       -hiux*)
+               os=-hiuxwe2
+               ;;
+       -sco5)
+               os=-sco3.2v5
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco4)
+               os=-sco3.2v4
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco3.2v[4-9]*)
+               # Don't forget version if it is 3.2v4 or newer.
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -sco*)
+               os=-sco3.2v2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -udk*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -isc)
+               os=-isc2.2
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -clix*)
+               basic_machine=clipper-intergraph
+               ;;
+       -isc*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
+               ;;
+       -lynx*)
+               os=-lynxos
+               ;;
+       -ptx*)
+               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+               ;;
+       -windowsnt*)
+               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+               ;;
+       -psos*)
+               os=-psos
+               ;;
+       -mint | -mint[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+esac
+
+# Decode aliases for certain CPU-COMPANY combinations.
+case $basic_machine in
+       # Recognize the basic CPU types without company name.
+       # Some are omitted here because they have special meanings below.
+       1750a | 580 \
+       | a29k \
+       | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] | alphapca5[67] \
+       | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
+       | am33_2.0 \
+       | arc | arm | arm[bl]e | arme[lb] | armv[2345] | armv[345][lb] | avr \
+       | bfin \
+       | c4x | clipper \
+       | d10v | d30v | dlx | dsp16xx \
+       | fr30 | frv \
+       | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
+       | i370 | i860 | i960 | ia64 \
+       | ip2k | iq2000 \
+       | m32r | m32rle | m68000 | m68k | m88k | maxq | mcore \
+       | mips | mipsbe | mipseb | mipsel | mipsle \
+       | mips16 \
+       | mips64 | mips64el \
+       | mips64vr | mips64vrel \
+       | mips64orion | mips64orionel \
+       | mips64vr4100 | mips64vr4100el \
+       | mips64vr4300 | mips64vr4300el \
+       | mips64vr5000 | mips64vr5000el \
+       | mips64vr5900 | mips64vr5900el \
+       | mipsisa32 | mipsisa32el \
+       | mipsisa32r2 | mipsisa32r2el \
+       | mipsisa64 | mipsisa64el \
+       | mipsisa64r2 | mipsisa64r2el \
+       | mipsisa64sb1 | mipsisa64sb1el \
+       | mipsisa64sr71k | mipsisa64sr71kel \
+       | mipstx39 | mipstx39el \
+       | mn10200 | mn10300 \
+       | ms1 \
+       | msp430 \
+       | ns16k | ns32k \
+       | or32 \
+       | pdp10 | pdp11 | pj | pjl \
+       | powerpc | powerpc64 | powerpc64le | powerpcle | ppcbe \
+       | pyramid \
+       | sh | sh[1234] | sh[24]a | sh[23]e | sh[34]eb | shbe | shle | sh[1234]le | sh3ele \
+       | sh64 | sh64le \
+       | sparc | sparc64 | sparc64b | sparc86x | sparclet | sparclite \
+       | sparcv8 | sparcv9 | sparcv9b \
+       | strongarm \
+       | tahoe | thumb | tic4x | tic80 | tron \
+       | v850 | v850e \
+       | we32k \
+       | x86 | xscale | xscalee[bl] | xstormy16 | xtensa \
+       | z8k)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m32c)
+               basic_machine=$basic_machine-unknown
+               ;;
+       m6811 | m68hc11 | m6812 | m68hc12)
+               # Motorola 68HC11/12.
+               basic_machine=$basic_machine-unknown
+               os=-none
+               ;;
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+               ;;
+
+       # We use `pc' rather than `unknown'
+       # because (1) that's what they normally are, and
+       # (2) the word "unknown" tends to confuse beginning users.
+       i*86 | x86_64)
+         basic_machine=$basic_machine-pc
+         ;;
+       # Object if more than one company name word.
+       *-*-*)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+       # Recognize the basic CPU types with company name.
+       580-* \
+       | a29k-* \
+       | alpha-* | alphaev[4-8]-* | alphaev56-* | alphaev6[78]-* \
+       | alpha64-* | alpha64ev[4-8]-* | alpha64ev56-* | alpha64ev6[78]-* \
+       | alphapca5[67]-* | alpha64pca5[67]-* | arc-* \
+       | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
+       | avr-* \
+       | bfin-* | bs2000-* \
+       | c[123]* | c30-* | [cjt]90-* | c4x-* | c54x-* | c55x-* | c6x-* \
+       | clipper-* | craynv-* | cydra-* \
+       | d10v-* | d30v-* | dlx-* \
+       | elxsi-* \
+       | f30[01]-* | f700-* | fr30-* | frv-* | fx80-* \
+       | h8300-* | h8500-* \
+       | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
+       | i*86-* | i860-* | i960-* | ia64-* \
+       | ip2k-* | iq2000-* \
+       | m32r-* | m32rle-* \
+       | m68000-* | m680[012346]0-* | m68360-* | m683?2-* | m68k-* \
+       | m88110-* | m88k-* | maxq-* | mcore-* \
+       | mips-* | mipsbe-* | mipseb-* | mipsel-* | mipsle-* \
+       | mips16-* \
+       | mips64-* | mips64el-* \
+       | mips64vr-* | mips64vrel-* \
+       | mips64orion-* | mips64orionel-* \
+       | mips64vr4100-* | mips64vr4100el-* \
+       | mips64vr4300-* | mips64vr4300el-* \
+       | mips64vr5000-* | mips64vr5000el-* \
+       | mips64vr5900-* | mips64vr5900el-* \
+       | mipsisa32-* | mipsisa32el-* \
+       | mipsisa32r2-* | mipsisa32r2el-* \
+       | mipsisa64-* | mipsisa64el-* \
+       | mipsisa64r2-* | mipsisa64r2el-* \
+       | mipsisa64sb1-* | mipsisa64sb1el-* \
+       | mipsisa64sr71k-* | mipsisa64sr71kel-* \
+       | mipstx39-* | mipstx39el-* \
+       | mmix-* \
+       | ms1-* \
+       | msp430-* \
+       | none-* | np1-* | ns16k-* | ns32k-* \
+       | orion-* \
+       | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
+       | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* | ppcbe-* \
+       | pyramid-* \
+       | romp-* | rs6000-* \
+       | sh-* | sh[1234]-* | sh[24]a-* | sh[23]e-* | sh[34]eb-* | shbe-* \
+       | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
+       | sparc-* | sparc64-* | sparc64b-* | sparc86x-* | sparclet-* \
+       | sparclite-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | strongarm-* | sv1-* | sx?-* \
+       | tahoe-* | thumb-* \
+       | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
+       | tron-* \
+       | v850-* | v850e-* | vax-* \
+       | we32k-* \
+       | x86-* | x86_64-* | xps100-* | xscale-* | xscalee[bl]-* \
+       | xstormy16-* | xtensa-* \
+       | ymp-* \
+       | z8k-*)
+               ;;
+       m32c-*)
+               ;;
+       # Recognize the various machine names and aliases which stand
+       # for a CPU type and a company and sometimes even an OS.
+       386bsd)
+               basic_machine=i386-unknown
+               os=-bsd
+               ;;
+       3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
+               basic_machine=m68000-att
+               ;;
+       3b*)
+               basic_machine=we32k-att
+               ;;
+       a29khif)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       abacus)
+               basic_machine=abacus-unknown
+               ;;
+       adobe68k)
+               basic_machine=m68010-adobe
+               os=-scout
+               ;;
+       alliant | fx80)
+               basic_machine=fx80-alliant
+               ;;
+       altos | altos3068)
+               basic_machine=m68k-altos
+               ;;
+       am29k)
+               basic_machine=a29k-none
+               os=-bsd
+               ;;
+       amd64)
+               basic_machine=x86_64-pc
+               ;;
+       amd64-*)
+               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       amdahl)
+               basic_machine=580-amdahl
+               os=-sysv
+               ;;
+       amiga | amiga-*)
+               basic_machine=m68k-unknown
+               ;;
+       amigaos | amigados)
+               basic_machine=m68k-unknown
+               os=-amigaos
+               ;;
+       amigaunix | amix)
+               basic_machine=m68k-unknown
+               os=-sysv4
+               ;;
+       apollo68)
+               basic_machine=m68k-apollo
+               os=-sysv
+               ;;
+       apollo68bsd)
+               basic_machine=m68k-apollo
+               os=-bsd
+               ;;
+       aux)
+               basic_machine=m68k-apple
+               os=-aux
+               ;;
+       balance)
+               basic_machine=ns32k-sequent
+               os=-dynix
+               ;;
+       c90)
+               basic_machine=c90-cray
+               os=-unicos
+               ;;
+       convex-c1)
+               basic_machine=c1-convex
+               os=-bsd
+               ;;
+       convex-c2)
+               basic_machine=c2-convex
+               os=-bsd
+               ;;
+       convex-c32)
+               basic_machine=c32-convex
+               os=-bsd
+               ;;
+       convex-c34)
+               basic_machine=c34-convex
+               os=-bsd
+               ;;
+       convex-c38)
+               basic_machine=c38-convex
+               os=-bsd
+               ;;
+       cray | j90)
+               basic_machine=j90-cray
+               os=-unicos
+               ;;
+       craynv)
+               basic_machine=craynv-cray
+               os=-unicosmp
+               ;;
+       cr16c)
+               basic_machine=cr16c-unknown
+               os=-elf
+               ;;
+       crds | unos)
+               basic_machine=m68k-crds
+               ;;
+       crisv32 | crisv32-* | etraxfs*)
+               basic_machine=crisv32-axis
+               ;;
+       cris | cris-* | etrax*)
+               basic_machine=cris-axis
+               ;;
+       crx)
+               basic_machine=crx-unknown
+               os=-elf
+               ;;
+       da30 | da30-*)
+               basic_machine=m68k-da30
+               ;;
+       decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn)
+               basic_machine=mips-dec
+               ;;
+       decsystem10* | dec10*)
+               basic_machine=pdp10-dec
+               os=-tops10
+               ;;
+       decsystem20* | dec20*)
+               basic_machine=pdp10-dec
+               os=-tops20
+               ;;
+       delta | 3300 | motorola-3300 | motorola-delta \
+             | 3300-motorola | delta-motorola)
+               basic_machine=m68k-motorola
+               ;;
+       delta88)
+               basic_machine=m88k-motorola
+               os=-sysv3
+               ;;
+       djgpp)
+               basic_machine=i586-pc
+               os=-msdosdjgpp
+               ;;
+       dpx20 | dpx20-*)
+               basic_machine=rs6000-bull
+               os=-bosx
+               ;;
+       dpx2* | dpx2*-bull)
+               basic_machine=m68k-bull
+               os=-sysv3
+               ;;
+       ebmon29k)
+               basic_machine=a29k-amd
+               os=-ebmon
+               ;;
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=-bsd
+               ;;
+       encore | umax | mmax)
+               basic_machine=ns32k-encore
+               ;;
+       es1800 | OSE68k | ose68k | ose | OSE)
+               basic_machine=m68k-ericsson
+               os=-ose
+               ;;
+       fx2800)
+               basic_machine=i860-alliant
+               ;;
+       genix)
+               basic_machine=ns32k-ns
+               ;;
+       gmicro)
+               basic_machine=tron-gmicro
+               os=-sysv
+               ;;
+       go32)
+               basic_machine=i386-pc
+               os=-go32
+               ;;
+       h3050r* | hiux*)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       h8300hms)
+               basic_machine=h8300-hitachi
+               os=-hms
+               ;;
+       h8300xray)
+               basic_machine=h8300-hitachi
+               os=-xray
+               ;;
+       h8500hms)
+               basic_machine=h8500-hitachi
+               os=-hms
+               ;;
+       harris)
+               basic_machine=m88k-harris
+               os=-sysv3
+               ;;
+       hp300-*)
+               basic_machine=m68k-hp
+               ;;
+       hp300bsd)
+               basic_machine=m68k-hp
+               os=-bsd
+               ;;
+       hp300hpux)
+               basic_machine=m68k-hp
+               os=-hpux
+               ;;
+       hp3k9[0-9][0-9] | hp9[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k2[0-9][0-9] | hp9k31[0-9])
+               basic_machine=m68000-hp
+               ;;
+       hp9k3[2-9][0-9])
+               basic_machine=m68k-hp
+               ;;
+       hp9k6[0-9][0-9] | hp6[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hp9k7[0-79][0-9] | hp7[0-79][0-9])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k78[0-9] | hp78[0-9])
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[67]1 | hp8[67]1 | hp9k80[24] | hp80[24] | hp9k8[78]9 | hp8[78]9 | hp9k893 | hp893)
+               # FIXME: really hppa2.0-hp
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][13679] | hp8[0-9][13679])
+               basic_machine=hppa1.1-hp
+               ;;
+       hp9k8[0-9][0-9] | hp8[0-9][0-9])
+               basic_machine=hppa1.0-hp
+               ;;
+       hppa-next)
+               os=-nextstep3
+               ;;
+       hppaosf)
+               basic_machine=hppa1.1-hp
+               os=-osf
+               ;;
+       hppro)
+               basic_machine=hppa1.1-hp
+               os=-proelf
+               ;;
+       i370-ibm* | ibm*)
+               basic_machine=i370-ibm
+               ;;
+# I'm not sure what "Sysv32" means.  Should this be sysv3.2?
+       i*86v32)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv32
+               ;;
+       i*86v4*)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv4
+               ;;
+       i*86v)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-sysv
+               ;;
+       i*86sol2)
+               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
+               os=-solaris2
+               ;;
+       i386mach)
+               basic_machine=i386-mach
+               os=-mach
+               ;;
+       i386-vsta | vsta)
+               basic_machine=i386-unknown
+               os=-vsta
+               ;;
+       iris | iris4d)
+               basic_machine=mips-sgi
+               case $os in
+                   -irix*)
+                       ;;
+                   *)
+                       os=-irix4
+                       ;;
+               esac
+               ;;
+       isi68 | isi)
+               basic_machine=m68k-isi
+               os=-sysv
+               ;;
+       m88k-omron*)
+               basic_machine=m88k-omron
+               ;;
+       magnum | m3230)
+               basic_machine=mips-mips
+               os=-sysv
+               ;;
+       merlin)
+               basic_machine=ns32k-utek
+               os=-sysv
+               ;;
+       mingw32)
+               basic_machine=i386-pc
+               os=-mingw32
+               ;;
+       miniframe)
+               basic_machine=m68000-convergent
+               ;;
+       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+               basic_machine=m68k-atari
+               os=-mint
+               ;;
+       mips3*-*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               ;;
+       mips3*)
+               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
+               ;;
+       monitor)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       morphos)
+               basic_machine=powerpc-unknown
+               os=-morphos
+               ;;
+       msdos)
+               basic_machine=i386-pc
+               os=-msdos
+               ;;
+       mvs)
+               basic_machine=i370-ibm
+               os=-mvs
+               ;;
+       ncr3000)
+               basic_machine=i486-ncr
+               os=-sysv4
+               ;;
+       netbsd386)
+               basic_machine=i386-unknown
+               os=-netbsd
+               ;;
+       netwinder)
+               basic_machine=armv4l-rebel
+               os=-linux
+               ;;
+       news | news700 | news800 | news900)
+               basic_machine=m68k-sony
+               os=-newsos
+               ;;
+       news1000)
+               basic_machine=m68030-sony
+               os=-newsos
+               ;;
+       news-3600 | risc-news)
+               basic_machine=mips-sony
+               os=-newsos
+               ;;
+       necv70)
+               basic_machine=v70-nec
+               os=-sysv
+               ;;
+       next | m*-next )
+               basic_machine=m68k-next
+               case $os in
+                   -nextstep* )
+                       ;;
+                   -ns2*)
+                     os=-nextstep2
+                       ;;
+                   *)
+                     os=-nextstep3
+                       ;;
+               esac
+               ;;
+       nh3000)
+               basic_machine=m68k-harris
+               os=-cxux
+               ;;
+       nh[45]000)
+               basic_machine=m88k-harris
+               os=-cxux
+               ;;
+       nindy960)
+               basic_machine=i960-intel
+               os=-nindy
+               ;;
+       mon960)
+               basic_machine=i960-intel
+               os=-mon960
+               ;;
+       nonstopux)
+               basic_machine=mips-compaq
+               os=-nonstopux
+               ;;
+       np1)
+               basic_machine=np1-gould
+               ;;
+       nsr-tandem)
+               basic_machine=nsr-tandem
+               ;;
+       op50n-* | op60c-*)
+               basic_machine=hppa1.1-oki
+               os=-proelf
+               ;;
+       openrisc | openrisc-*)
+               basic_machine=or32-unknown
+               ;;
+       os400)
+               basic_machine=powerpc-ibm
+               os=-os400
+               ;;
+       OSE68000 | ose68000)
+               basic_machine=m68000-ericsson
+               os=-ose
+               ;;
+       os68k)
+               basic_machine=m68k-none
+               os=-os68k
+               ;;
+       pa-hitachi)
+               basic_machine=hppa1.1-hitachi
+               os=-hiuxwe2
+               ;;
+       paragon)
+               basic_machine=i860-intel
+               os=-osf
+               ;;
+       pbd)
+               basic_machine=sparc-tti
+               ;;
+       pbb)
+               basic_machine=m68k-tti
+               ;;
+       pc532 | pc532-*)
+               basic_machine=ns32k-pc532
+               ;;
+       pentium | p5 | k5 | k6 | nexgen | viac3)
+               basic_machine=i586-pc
+               ;;
+       pentiumpro | p6 | 6x86 | athlon | athlon_*)
+               basic_machine=i686-pc
+               ;;
+       pentiumii | pentium2 | pentiumiii | pentium3)
+               basic_machine=i686-pc
+               ;;
+       pentium4)
+               basic_machine=i786-pc
+               ;;
+       pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
+               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumpro-* | p6-* | 6x86-* | athlon-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
+               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pentium4-*)
+               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       pn)
+               basic_machine=pn-gould
+               ;;
+       power)  basic_machine=power-ibm
+               ;;
+       ppc)    basic_machine=powerpc-unknown
+               ;;
+       ppc-*)  basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppcle | powerpclittle | ppc-le | powerpc-little)
+               basic_machine=powerpcle-unknown
+               ;;
+       ppcle-* | powerpclittle-*)
+               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64)  basic_machine=powerpc64-unknown
+               ;;
+       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+               basic_machine=powerpc64le-unknown
+               ;;
+       ppc64le-* | powerpc64little-*)
+               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               ;;
+       ps2)
+               basic_machine=i386-ibm
+               ;;
+       pw32)
+               basic_machine=i586-unknown
+               os=-pw32
+               ;;
+       rom68k)
+               basic_machine=m68k-rom68k
+               os=-coff
+               ;;
+       rm[46]00)
+               basic_machine=mips-siemens
+               ;;
+       rtpc | rtpc-*)
+               basic_machine=romp-ibm
+               ;;
+       s390 | s390-*)
+               basic_machine=s390-ibm
+               ;;
+       s390x | s390x-*)
+               basic_machine=s390x-ibm
+               ;;
+       sa29200)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       sb1)
+               basic_machine=mipsisa64sb1-unknown
+               ;;
+       sb1el)
+               basic_machine=mipsisa64sb1el-unknown
+               ;;
+       sei)
+               basic_machine=mips-sei
+               os=-seiux
+               ;;
+       sequent)
+               basic_machine=i386-sequent
+               ;;
+       sh)
+               basic_machine=sh-hitachi
+               os=-hms
+               ;;
+       sh64)
+               basic_machine=sh64-unknown
+               ;;
+       sparclite-wrs | simso-wrs)
+               basic_machine=sparclite-wrs
+               os=-vxworks
+               ;;
+       sps7)
+               basic_machine=m68k-bull
+               os=-sysv2
+               ;;
+       spur)
+               basic_machine=spur-unknown
+               ;;
+       st2000)
+               basic_machine=m68k-tandem
+               ;;
+       stratus)
+               basic_machine=i860-stratus
+               os=-sysv4
+               ;;
+       sun2)
+               basic_machine=m68000-sun
+               ;;
+       sun2os3)
+               basic_machine=m68000-sun
+               os=-sunos3
+               ;;
+       sun2os4)
+               basic_machine=m68000-sun
+               os=-sunos4
+               ;;
+       sun3os3)
+               basic_machine=m68k-sun
+               os=-sunos3
+               ;;
+       sun3os4)
+               basic_machine=m68k-sun
+               os=-sunos4
+               ;;
+       sun4os3)
+               basic_machine=sparc-sun
+               os=-sunos3
+               ;;
+       sun4os4)
+               basic_machine=sparc-sun
+               os=-sunos4
+               ;;
+       sun4sol2)
+               basic_machine=sparc-sun
+               os=-solaris2
+               ;;
+       sun3 | sun3-*)
+               basic_machine=m68k-sun
+               ;;
+       sun4)
+               basic_machine=sparc-sun
+               ;;
+       sun386 | sun386i | roadrunner)
+               basic_machine=i386-sun
+               ;;
+       sv1)
+               basic_machine=sv1-cray
+               os=-unicos
+               ;;
+       symmetry)
+               basic_machine=i386-sequent
+               os=-dynix
+               ;;
+       t3e)
+               basic_machine=alphaev5-cray
+               os=-unicos
+               ;;
+       t90)
+               basic_machine=t90-cray
+               os=-unicos
+               ;;
+       tic54x | c54x*)
+               basic_machine=tic54x-unknown
+               os=-coff
+               ;;
+       tic55x | c55x*)
+               basic_machine=tic55x-unknown
+               os=-coff
+               ;;
+       tic6x | c6x*)
+               basic_machine=tic6x-unknown
+               os=-coff
+               ;;
+       tx39)
+               basic_machine=mipstx39-unknown
+               ;;
+       tx39el)
+               basic_machine=mipstx39el-unknown
+               ;;
+       toad1)
+               basic_machine=pdp10-xkl
+               os=-tops20
+               ;;
+       tower | tower-32)
+               basic_machine=m68k-ncr
+               ;;
+       tpf)
+               basic_machine=s390x-ibm
+               os=-tpf
+               ;;
+       udi29k)
+               basic_machine=a29k-amd
+               os=-udi
+               ;;
+       ultra3)
+               basic_machine=a29k-nyu
+               os=-sym1
+               ;;
+       v810 | necv810)
+               basic_machine=v810-nec
+               os=-none
+               ;;
+       vaxv)
+               basic_machine=vax-dec
+               os=-sysv
+               ;;
+       vms)
+               basic_machine=vax-dec
+               os=-vms
+               ;;
+       vpp*|vx|vx-*)
+               basic_machine=f301-fujitsu
+               ;;
+       vxworks960)
+               basic_machine=i960-wrs
+               os=-vxworks
+               ;;
+       vxworks68)
+               basic_machine=m68k-wrs
+               os=-vxworks
+               ;;
+       vxworks29k)
+               basic_machine=a29k-wrs
+               os=-vxworks
+               ;;
+       w65*)
+               basic_machine=w65-wdc
+               os=-none
+               ;;
+       w89k-*)
+               basic_machine=hppa1.1-winbond
+               os=-proelf
+               ;;
+       xbox)
+               basic_machine=i686-pc
+               os=-mingw32
+               ;;
+       xps | xps100)
+               basic_machine=xps100-honeywell
+               ;;
+       ymp)
+               basic_machine=ymp-cray
+               os=-unicos
+               ;;
+       z8k-*-coff)
+               basic_machine=z8k-unknown
+               os=-sim
+               ;;
+       none)
+               basic_machine=none-none
+               os=-none
+               ;;
+
+# Here we handle the default manufacturer of certain CPU types.  It is in
+# some cases the only manufacturer, in others, it is the most popular.
+       w89k)
+               basic_machine=hppa1.1-winbond
+               ;;
+       op50n)
+               basic_machine=hppa1.1-oki
+               ;;
+       op60c)
+               basic_machine=hppa1.1-oki
+               ;;
+       romp)
+               basic_machine=romp-ibm
+               ;;
+       mmix)
+               basic_machine=mmix-knuth
+               ;;
+       rs6000)
+               basic_machine=rs6000-ibm
+               ;;
+       vax)
+               basic_machine=vax-dec
+               ;;
+       pdp10)
+               # there are many clones, so DEC is not a safe bet
+               basic_machine=pdp10-unknown
+               ;;
+       pdp11)
+               basic_machine=pdp11-dec
+               ;;
+       we32k)
+               basic_machine=we32k-att
+               ;;
+       sh[1234] | sh[24]a | sh[34]eb | sh[1234]le | sh[23]ele)
+               basic_machine=sh-unknown
+               ;;
+       sparc | sparcv8 | sparcv9 | sparcv9b)
+               basic_machine=sparc-sun
+               ;;
+       cydra)
+               basic_machine=cydra-cydrome
+               ;;
+       orion)
+               basic_machine=orion-highlevel
+               ;;
+       orion105)
+               basic_machine=clipper-highlevel
+               ;;
+       mac | mpw | mac-mpw)
+               basic_machine=m68k-apple
+               ;;
+       pmac | pmac-mpw)
+               basic_machine=powerpc-apple
+               ;;
+       *-unknown)
+               # Make sure to match an already-canonicalized machine name.
+               ;;
+       *)
+               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+
+# Here we canonicalize certain aliases for manufacturers.
+case $basic_machine in
+       *-digital*)
+               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               ;;
+       *-commodore*)
+               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               ;;
+       *)
+               ;;
+esac
+
+# Decode manufacturer-specific aliases for certain operating systems.
+
+if [ x"$os" != x"" ]
+then
+case $os in
+        # First match some system type aliases
+        # that might get confused with valid system types.
+       # -solaris* is a basic system type, with this one exception.
+       -solaris1 | -solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+               ;;
+       -solaris)
+               os=-solaris2
+               ;;
+       -svr4*)
+               os=-sysv4
+               ;;
+       -unixware*)
+               os=-sysv4.2uw
+               ;;
+       -gnu/linux*)
+               os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
+               ;;
+       # First accept the basic system types.
+       # The portable systems comes first.
+       # Each alternative MUST END IN A *, to match a version number.
+       # -sysv* is not here because it comes later, after sysvr4.
+       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
+             | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\
+             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \
+             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
+             | -aos* \
+             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
+             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
+             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* | -openbsd* \
+             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
+             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
+             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
+             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
+             | -chorusos* | -chorusrdb* \
+             | -cygwin* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
+             | -mingw32* | -linux-gnu* | -linux-uclibc* | -uxpv* | -beos* | -mpeix* | -udk* \
+             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
+             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
+             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
+             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
+             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
+             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
+             | -skyos* | -haiku*)
+       # Remember, each alternative MUST END IN *, to match a version number.
+               ;;
+       -qnx*)
+               case $basic_machine in
+                   x86-* | i*86-*)
+                       ;;
+                   *)
+                       os=-nto$os
+                       ;;
+               esac
+               ;;
+       -nto-qnx*)
+               ;;
+       -nto*)
+               os=`echo $os | sed -e 's|nto|nto-qnx|'`
+               ;;
+       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
+             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
+             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+               ;;
+       -mac*)
+               os=`echo $os | sed -e 's|mac|macos|'`
+               ;;
+       -linux-dietlibc)
+               os=-linux-dietlibc
+               ;;
+       -linux*)
+               os=`echo $os | sed -e 's|linux|linux-gnu|'`
+               ;;
+       -sunos5*)
+               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+               ;;
+       -sunos6*)
+               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+               ;;
+       -opened*)
+               os=-openedition
+               ;;
+        -os400*)
+               os=-os400
+               ;;
+       -wince*)
+               os=-wince
+               ;;
+       -osfrose*)
+               os=-osfrose
+               ;;
+       -osf*)
+               os=-osf
+               ;;
+       -utek*)
+               os=-bsd
+               ;;
+       -dynix*)
+               os=-bsd
+               ;;
+       -acis*)
+               os=-aos
+               ;;
+       -atheos*)
+               os=-atheos
+               ;;
+       -syllable*)
+               os=-syllable
+               ;;
+       -386bsd)
+               os=-bsd
+               ;;
+       -ctix* | -uts*)
+               os=-sysv
+               ;;
+       -nova*)
+               os=-rtmk-nova
+               ;;
+       -ns2 )
+               os=-nextstep2
+               ;;
+       -nsk*)
+               os=-nsk
+               ;;
+       # Preserve the version number of sinix5.
+       -sinix5.*)
+               os=`echo $os | sed -e 's|sinix|sysv|'`
+               ;;
+       -sinix*)
+               os=-sysv4
+               ;;
+        -tpf*)
+               os=-tpf
+               ;;
+       -triton*)
+               os=-sysv3
+               ;;
+       -oss*)
+               os=-sysv3
+               ;;
+       -svr4)
+               os=-sysv4
+               ;;
+       -svr3)
+               os=-sysv3
+               ;;
+       -sysvr4)
+               os=-sysv4
+               ;;
+       # This must come after -sysvr4.
+       -sysv*)
+               ;;
+       -ose*)
+               os=-ose
+               ;;
+       -es1800*)
+               os=-ose
+               ;;
+       -xenix)
+               os=-xenix
+               ;;
+       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+               os=-mint
+               ;;
+       -aros*)
+               os=-aros
+               ;;
+       -kaos*)
+               os=-kaos
+               ;;
+       -zvmoe)
+               os=-zvmoe
+               ;;
+       -none)
+               ;;
+       *)
+               # Get rid of the `-' at the beginning of $os.
+               os=`echo $os | sed 's/[^-]*-//'`
+               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               exit 1
+               ;;
+esac
+else
+
+# Here we handle the default operating systems that come with various machines.
+# The value should be what the vendor currently ships out the door with their
+# machine or put another way, the most popular os provided with the machine.
+
+# Note that if you're going to try to match "-MANUFACTURER" here (say,
+# "-sun"), then you have to tell the case statement up towards the top
+# that MANUFACTURER isn't an operating system.  Otherwise, code above
+# will signal an error saying that MANUFACTURER isn't an operating
+# system, and we'll never get to this point.
+
+case $basic_machine in
+       *-acorn)
+               os=-riscix1.2
+               ;;
+       arm*-rebel)
+               os=-linux
+               ;;
+       arm*-semi)
+               os=-aout
+               ;;
+    c4x-* | tic4x-*)
+        os=-coff
+        ;;
+       # This must come before the *-dec entry.
+       pdp10-*)
+               os=-tops20
+               ;;
+       pdp11-*)
+               os=-none
+               ;;
+       *-dec | vax-*)
+               os=-ultrix4.2
+               ;;
+       m68*-apollo)
+               os=-domain
+               ;;
+       i386-sun)
+               os=-sunos4.0.2
+               ;;
+       m68000-sun)
+               os=-sunos3
+               # This also exists in the configure program, but was not the
+               # default.
+               # os=-sunos4
+               ;;
+       m68*-cisco)
+               os=-aout
+               ;;
+       mips*-cisco)
+               os=-elf
+               ;;
+       mips*-*)
+               os=-elf
+               ;;
+       or32-*)
+               os=-coff
+               ;;
+       *-tti)  # must be before sparc entry or we get the wrong os.
+               os=-sysv3
+               ;;
+       sparc-* | *-sun)
+               os=-sunos4.1.1
+               ;;
+       *-be)
+               os=-beos
+               ;;
+       *-haiku)
+               os=-haiku
+               ;;
+       *-ibm)
+               os=-aix
+               ;;
+       *-knuth)
+               os=-mmixware
+               ;;
+       *-wec)
+               os=-proelf
+               ;;
+       *-winbond)
+               os=-proelf
+               ;;
+       *-oki)
+               os=-proelf
+               ;;
+       *-hp)
+               os=-hpux
+               ;;
+       *-hitachi)
+               os=-hiux
+               ;;
+       i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
+               os=-sysv
+               ;;
+       *-cbm)
+               os=-amigaos
+               ;;
+       *-dg)
+               os=-dgux
+               ;;
+       *-dolphin)
+               os=-sysv3
+               ;;
+       m68k-ccur)
+               os=-rtu
+               ;;
+       m88k-omron*)
+               os=-luna
+               ;;
+       *-next )
+               os=-nextstep
+               ;;
+       *-sequent)
+               os=-ptx
+               ;;
+       *-crds)
+               os=-unos
+               ;;
+       *-ns)
+               os=-genix
+               ;;
+       i370-*)
+               os=-mvs
+               ;;
+       *-next)
+               os=-nextstep3
+               ;;
+       *-gould)
+               os=-sysv
+               ;;
+       *-highlevel)
+               os=-bsd
+               ;;
+       *-encore)
+               os=-bsd
+               ;;
+       *-sgi)
+               os=-irix
+               ;;
+       *-siemens)
+               os=-sysv4
+               ;;
+       *-masscomp)
+               os=-rtu
+               ;;
+       f30[01]-fujitsu | f700-fujitsu)
+               os=-uxpv
+               ;;
+       *-rom68k)
+               os=-coff
+               ;;
+       *-*bug)
+               os=-coff
+               ;;
+       *-apple)
+               os=-macos
+               ;;
+       *-atari*)
+               os=-mint
+               ;;
+       *)
+               os=-none
+               ;;
+esac
+fi
+
+# Here we handle the case where we know the os, and the CPU type, but not the
+# manufacturer.  We pick the logical manufacturer.
+vendor=unknown
+case $basic_machine in
+       *-unknown)
+               case $os in
+                       -riscix*)
+                               vendor=acorn
+                               ;;
+                       -sunos*)
+                               vendor=sun
+                               ;;
+                       -aix*)
+                               vendor=ibm
+                               ;;
+                       -beos*)
+                               vendor=be
+                               ;;
+                       -hpux*)
+                               vendor=hp
+                               ;;
+                       -mpeix*)
+                               vendor=hp
+                               ;;
+                       -hiux*)
+                               vendor=hitachi
+                               ;;
+                       -unos*)
+                               vendor=crds
+                               ;;
+                       -dgux*)
+                               vendor=dg
+                               ;;
+                       -luna*)
+                               vendor=omron
+                               ;;
+                       -genix*)
+                               vendor=ns
+                               ;;
+                       -mvs* | -opened*)
+                               vendor=ibm
+                               ;;
+                       -os400*)
+                               vendor=ibm
+                               ;;
+                       -ptx*)
+                               vendor=sequent
+                               ;;
+                       -tpf*)
+                               vendor=ibm
+                               ;;
+                       -vxsim* | -vxworks* | -windiss*)
+                               vendor=wrs
+                               ;;
+                       -aux*)
+                               vendor=apple
+                               ;;
+                       -hms*)
+                               vendor=hitachi
+                               ;;
+                       -mpw* | -macos*)
+                               vendor=apple
+                               ;;
+                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+                               vendor=atari
+                               ;;
+                       -vos*)
+                               vendor=stratus
+                               ;;
+               esac
+               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               ;;
+esac
+
+echo $basic_machine$os
+exit
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "timestamp='"
+# time-stamp-format: "%:y-%02m-%02d"
+# time-stamp-end: "'"
+# End:
diff --git a/sntp/configure b/sntp/configure
new file mode 100755 (executable)
index 0000000..1bcdaf7
--- /dev/null
@@ -0,0 +1,16833 @@
+#! /bin/sh
+# Guess values for system-dependent variables and create Makefiles.
+# Generated by GNU Autoconf 2.65.
+#
+#
+# Copyright (C) 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001,
+# 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Free Software Foundation,
+# Inc.
+#
+#
+# This configure script is free software; the Free Software Foundation
+# gives unlimited permission to copy, distribute and modify it.
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test "x$CONFIG_SHELL" = x; then
+  as_bourne_compatible="if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on \${1+\"\$@\"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '\${1+\"\$@\"}'='\"\$@\"'
+  setopt NO_GLOB_SUBST
+else
+  case \`(set -o) 2>/dev/null\` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+"
+  as_required="as_fn_return () { (exit \$1); }
+as_fn_success () { as_fn_return 0; }
+as_fn_failure () { as_fn_return 1; }
+as_fn_ret_success () { return 0; }
+as_fn_ret_failure () { return 1; }
+
+exitcode=0
+as_fn_success || { exitcode=1; echo as_fn_success failed.; }
+as_fn_failure && { exitcode=1; echo as_fn_failure succeeded.; }
+as_fn_ret_success || { exitcode=1; echo as_fn_ret_success failed.; }
+as_fn_ret_failure && { exitcode=1; echo as_fn_ret_failure succeeded.; }
+if ( set x; as_fn_ret_success y && test x = \"\$1\" ); then :
+
+else
+  exitcode=1; echo positional parameters were not saved.
+fi
+test x\$exitcode = x0 || exit 1"
+  as_suggested="  as_lineno_1=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_1a=\$LINENO
+  as_lineno_2=";as_suggested=$as_suggested$LINENO;as_suggested=$as_suggested" as_lineno_2a=\$LINENO
+  eval 'test \"x\$as_lineno_1'\$as_run'\" != \"x\$as_lineno_2'\$as_run'\" &&
+  test \"x\`expr \$as_lineno_1'\$as_run' + 1\`\" = \"x\$as_lineno_2'\$as_run'\"' || exit 1
+test \$(( 1 + 1 )) = 2 || exit 1"
+  if (eval "$as_required") 2>/dev/null; then :
+  as_have_required=yes
+else
+  as_have_required=no
+fi
+  if test x$as_have_required = xyes && (eval "$as_suggested") 2>/dev/null; then :
+
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+as_found=false
+for as_dir in /bin$PATH_SEPARATOR/usr/bin$PATH_SEPARATOR$PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  as_found=:
+  case $as_dir in #(
+        /*)
+          for as_base in sh bash ksh sh5; do
+            # Try only shells that exist, to save several forks.
+            as_shell=$as_dir/$as_base
+            if { test -f "$as_shell" || test -f "$as_shell.exe"; } &&
+                   { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  CONFIG_SHELL=$as_shell as_have_required=yes
+                  if { $as_echo "$as_bourne_compatible""$as_suggested" | as_run=a "$as_shell"; } 2>/dev/null; then :
+  break 2
+fi
+fi
+          done;;
+       esac
+  as_found=false
+done
+$as_found || { if { test -f "$SHELL" || test -f "$SHELL.exe"; } &&
+             { $as_echo "$as_bourne_compatible""$as_required" | as_run=a "$SHELL"; } 2>/dev/null; then :
+  CONFIG_SHELL=$SHELL as_have_required=yes
+fi; }
+IFS=$as_save_IFS
+
+
+      if test "x$CONFIG_SHELL" != x; then :
+  # We cannot yet assume a decent shell, so we have to provide a
+       # neutralization value for shells without unset; and this also
+       # works around shells that cannot unset nonexistent variables.
+       BASH_ENV=/dev/null
+       ENV=/dev/null
+       (unset BASH_ENV) >/dev/null 2>&1 && unset BASH_ENV ENV
+       export CONFIG_SHELL
+       exec "$CONFIG_SHELL" "$as_myself" ${1+"$@"}
+fi
+
+    if test x$as_have_required = xno; then :
+  $as_echo "$0: This script requires a shell more modern than all"
+  $as_echo "$0: the shells that I found on your system."
+  if test x${ZSH_VERSION+set} = xset ; then
+    $as_echo "$0: In particular, zsh $ZSH_VERSION has bugs and should"
+    $as_echo "$0: be upgraded to zsh 4.3.4 or later."
+  else
+    $as_echo "$0: Please tell bug-autoconf@gnu.org about your system,
+$0: including any error possibly output before this
+$0: message. Then install a modern shell, or manually run
+$0: the script under such a shell if you do have one."
+  fi
+  exit 1
+fi
+fi
+fi
+SHELL=${CONFIG_SHELL-/bin/sh}
+export SHELL
+# Unset more variables known to interfere with behavior of common tools.
+CLICOLOR_FORCE= GREP_OPTIONS=
+unset CLICOLOR_FORCE GREP_OPTIONS
+
+## --------------------- ##
+## M4sh Shell Functions. ##
+## --------------------- ##
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with status $?, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+
+  as_lineno_1=$LINENO as_lineno_1a=$LINENO
+  as_lineno_2=$LINENO as_lineno_2a=$LINENO
+  eval 'test "x$as_lineno_1'$as_run'" != "x$as_lineno_2'$as_run'" &&
+  test "x`expr $as_lineno_1'$as_run' + 1`" = "x$as_lineno_2'$as_run'"' || {
+  # Blame Lee E. McMahon (1931-1989) for sed's syntax.  :-)
+  sed -n '
+    p
+    /[$]LINENO/=
+  ' <$as_myself |
+    sed '
+      s/[$]LINENO.*/&-/
+      t lineno
+      b
+      :lineno
+      N
+      :loop
+      s/[$]LINENO\([^'$as_cr_alnum'_].*\n\)\(.*\)/\2\1\2/
+      t loop
+      s/-\n.*//
+    ' >$as_me.lineno &&
+  chmod +x "$as_me.lineno" ||
+    { $as_echo "$as_me: error: cannot create $as_me.lineno; rerun with a POSIX shell" >&2; as_fn_exit 1; }
+
+  # Don't try to exec as it changes $[0], causing all sort of problems
+  # (the dirname of $[0] is not the place where we might find the
+  # original and so on.  Autoconf is especially sensitive to this).
+  . "./$as_me.lineno"
+  # Exit status is that of the last command.
+  exit
+}
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in #(
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+
+# Check that we are running under the correct shell.
+SHELL=${CONFIG_SHELL-/bin/sh}
+
+case X$ECHO in
+X*--fallback-echo)
+  # Remove one level of quotation (which was required for Make).
+  ECHO=`echo "$ECHO" | sed 's,\\\\\$\\$0,'$0','`
+  ;;
+esac
+
+echo=${ECHO-echo}
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t' ; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell.
+  exec $SHELL "$0" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit 0
+fi
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+if test -z "$ECHO"; then
+if test "X${echo_test_string+set}" != Xset; then
+# find a string as large as possible, as long as the shell can cope with it
+  for cmd in 'sed 50q "$0"' 'sed 20q "$0"' 'sed 10q "$0"' 'sed 2q "$0"' 'echo test'; do
+    # expected sizes: less than 2Kb, 1Kb, 512 bytes, 16 bytes, ...
+    if (echo_test_string=`eval $cmd`) 2>/dev/null &&
+       echo_test_string=`eval $cmd` &&
+       (test "X$echo_test_string" = "X$echo_test_string") 2>/dev/null
+    then
+      break
+    fi
+  done
+fi
+
+if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+   echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+   test "X$echo_testing_string" = "X$echo_test_string"; then
+  :
+else
+  # The Solaris, AIX, and Digital Unix default echo programs unquote
+  # backslashes.  This makes it impossible to quote backslashes using
+  #   echo "$something" | sed 's/\\/\\\\/g'
+  #
+  # So, first we look for a working echo in the user's PATH.
+
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for dir in $PATH /usr/ucb; do
+    IFS="$lt_save_ifs"
+    if (test -f $dir/echo || test -f $dir/echo$ac_exeext) &&
+       test "X`($dir/echo '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`($dir/echo "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      echo="$dir/echo"
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  if test "X$echo" = Xecho; then
+    # We didn't find a better echo, so look for alternatives.
+    if test "X`(print -r '\t') 2>/dev/null`" = 'X\t' &&
+       echo_testing_string=`(print -r "$echo_test_string") 2>/dev/null` &&
+       test "X$echo_testing_string" = "X$echo_test_string"; then
+      # This shell has a builtin print -r that does the trick.
+      echo='print -r'
+    elif (test -f /bin/ksh || test -f /bin/ksh$ac_exeext) &&
+        test "X$CONFIG_SHELL" != X/bin/ksh; then
+      # If we have ksh, try running configure again with it.
+      ORIGINAL_CONFIG_SHELL=${CONFIG_SHELL-/bin/sh}
+      export ORIGINAL_CONFIG_SHELL
+      CONFIG_SHELL=/bin/ksh
+      export CONFIG_SHELL
+      exec $CONFIG_SHELL "$0" --no-reexec ${1+"$@"}
+    else
+      # Try using printf.
+      echo='printf %s\n'
+      if test "X`($echo '\t') 2>/dev/null`" = 'X\t' &&
+        echo_testing_string=`($echo "$echo_test_string") 2>/dev/null` &&
+        test "X$echo_testing_string" = "X$echo_test_string"; then
+       # Cool, printf works
+       :
+      elif echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+          test "X$echo_testing_string" = 'X\t' &&
+          echo_testing_string=`($ORIGINAL_CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+          test "X$echo_testing_string" = "X$echo_test_string"; then
+       CONFIG_SHELL=$ORIGINAL_CONFIG_SHELL
+       export CONFIG_SHELL
+       SHELL="$CONFIG_SHELL"
+       export SHELL
+       echo="$CONFIG_SHELL $0 --fallback-echo"
+      elif echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo '\t') 2>/dev/null` &&
+          test "X$echo_testing_string" = 'X\t' &&
+          echo_testing_string=`($CONFIG_SHELL "$0" --fallback-echo "$echo_test_string") 2>/dev/null` &&
+          test "X$echo_testing_string" = "X$echo_test_string"; then
+       echo="$CONFIG_SHELL $0 --fallback-echo"
+      else
+       # maybe with a smaller string...
+       prev=:
+
+       for cmd in 'echo test' 'sed 2q "$0"' 'sed 10q "$0"' 'sed 20q "$0"' 'sed 50q "$0"'; do
+         if (test "X$echo_test_string" = "X`eval $cmd`") 2>/dev/null
+         then
+           break
+         fi
+         prev="$cmd"
+       done
+
+       if test "$prev" != 'sed 50q "$0"'; then
+         echo_test_string=`eval $prev`
+         export echo_test_string
+         exec ${ORIGINAL_CONFIG_SHELL-${CONFIG_SHELL-/bin/sh}} "$0" ${1+"$@"}
+       else
+         # Oops.  We lost completely, so just stick with echo.
+         echo=echo
+       fi
+      fi
+    fi
+  fi
+fi
+fi
+
+# Copy echo and quote the copy suitably for passing to libtool from
+# the Makefile, instead of quoting the original, which is used later.
+ECHO=$echo
+if test "X$ECHO" = "X$CONFIG_SHELL $0 --fallback-echo"; then
+   ECHO="$CONFIG_SHELL \\\$\$0 --fallback-echo"
+fi
+
+
+
+
+test -n "$DJDIR" || exec 7<&0 </dev/null
+exec 6>&1
+
+# Name of the host.
+# hostname on some systems (SVR3.2, Linux) returns a bogus exit status,
+# so uname gets run too.
+ac_hostname=`(hostname || uname -n) 2>/dev/null | sed 1q`
+
+#
+# Initializations.
+#
+ac_default_prefix=/usr/local
+ac_clean_files=
+ac_config_libobj_dir=.
+LIBOBJS=
+cross_compiling=no
+subdirs=
+MFLAGS=
+MAKEFLAGS=
+
+# Identity of this package.
+PACKAGE_NAME=
+PACKAGE_TARNAME=
+PACKAGE_VERSION=
+PACKAGE_STRING=
+PACKAGE_BUGREPORT=
+PACKAGE_URL=
+
+ac_unique_file="main.c"
+ac_unique_file="header.h"
+# Factoring default headers for most tests.
+ac_includes_default="\
+#include <stdio.h>
+#ifdef HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#ifdef HAVE_SYS_STAT_H
+# include <sys/stat.h>
+#endif
+#ifdef STDC_HEADERS
+# include <stdlib.h>
+# include <stddef.h>
+#else
+# ifdef HAVE_STDLIB_H
+#  include <stdlib.h>
+# endif
+#endif
+#ifdef HAVE_STRING_H
+# if !defined STDC_HEADERS && defined HAVE_MEMORY_H
+#  include <memory.h>
+# endif
+# include <string.h>
+#endif
+#ifdef HAVE_STRINGS_H
+# include <strings.h>
+#endif
+#ifdef HAVE_INTTYPES_H
+# include <inttypes.h>
+#endif
+#ifdef HAVE_STDINT_H
+# include <stdint.h>
+#endif
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif"
+
+ac_subst_vars='am__EXEEXT_FALSE
+am__EXEEXT_TRUE
+LTLIBOBJS
+LIBOBJS
+BINSUBDIR
+HAVE_INLINE
+LIBOPTS_CFLAGS
+LIBOPTS_LDADD
+NEED_LIBOPTS_FALSE
+NEED_LIBOPTS_TRUE
+INSTALL_LIBOPTS_FALSE
+INSTALL_LIBOPTS_TRUE
+LIBOPTS_DIR
+LIBTOOL
+CPP
+RANLIB
+AR
+ECHO
+LN_S
+EGREP
+GREP
+am__fastdepCC_FALSE
+am__fastdepCC_TRUE
+CCDEPMODE
+AMDEPBACKSLASH
+AMDEP_FALSE
+AMDEP_TRUE
+am__quote
+am__include
+DEPDIR
+OBJEXT
+EXEEXT
+ac_ct_CC
+CPPFLAGS
+LDFLAGS
+CFLAGS
+CC
+host_os
+host_vendor
+host_cpu
+host
+build_os
+build_vendor
+build_cpu
+build
+am__untar
+am__tar
+AMTAR
+am__leading_dot
+SET_MAKE
+AWK
+mkdir_p
+MKDIR_P
+INSTALL_STRIP_PROGRAM
+STRIP
+install_sh
+MAKEINFO
+AUTOHEADER
+AUTOMAKE
+AUTOCONF
+ACLOCAL
+VERSION
+PACKAGE
+CYGPATH_W
+am__isrc
+INSTALL_DATA
+INSTALL_SCRIPT
+INSTALL_PROGRAM
+target_alias
+host_alias
+build_alias
+LIBS
+ECHO_T
+ECHO_N
+ECHO_C
+DEFS
+mandir
+localedir
+libdir
+psdir
+pdfdir
+dvidir
+htmldir
+infodir
+docdir
+oldincludedir
+includedir
+localstatedir
+sharedstatedir
+sysconfdir
+datadir
+datarootdir
+libexecdir
+sbindir
+bindir
+program_transform_name
+prefix
+exec_prefix
+PACKAGE_URL
+PACKAGE_BUGREPORT
+PACKAGE_STRING
+PACKAGE_VERSION
+PACKAGE_TARNAME
+PACKAGE_NAME
+PATH_SEPARATOR
+SHELL'
+ac_subst_files=''
+ac_user_opts='
+enable_option_checking
+enable_dependency_tracking
+enable_shared
+enable_static
+enable_fast_install
+with_gnu_ld
+enable_libtool_lock
+with_pic
+with_tags
+enable_local_libopts
+enable_libopts_install
+with_autoopts_config
+with_regex_header
+with_libregex
+with_libregex_cflags
+with_libregex_libs
+enable_optional_args
+with_binsubdir
+'
+      ac_precious_vars='build_alias
+host_alias
+target_alias
+CC
+CFLAGS
+LDFLAGS
+LIBS
+CPPFLAGS
+CPP'
+
+
+# Initialize some variables set by options.
+ac_init_help=
+ac_init_version=false
+ac_unrecognized_opts=
+ac_unrecognized_sep=
+# The variables have the same names as the options, with
+# dashes changed to underlines.
+cache_file=/dev/null
+exec_prefix=NONE
+no_create=
+no_recursion=
+prefix=NONE
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=s,x,x,
+silent=
+site=
+srcdir=
+verbose=
+x_includes=NONE
+x_libraries=NONE
+
+# Installation directory options.
+# These are left unexpanded so users can "make install exec_prefix=/foo"
+# and all the variables that are supposed to be based on exec_prefix
+# by default will actually change.
+# Use braces instead of parens because sh, perl, etc. also accept them.
+# (The list follows the same order as the GNU Coding Standards.)
+bindir='${exec_prefix}/bin'
+sbindir='${exec_prefix}/sbin'
+libexecdir='${exec_prefix}/libexec'
+datarootdir='${prefix}/share'
+datadir='${datarootdir}'
+sysconfdir='${prefix}/etc'
+sharedstatedir='${prefix}/com'
+localstatedir='${prefix}/var'
+includedir='${prefix}/include'
+oldincludedir='/usr/include'
+docdir='${datarootdir}/doc/${PACKAGE}'
+infodir='${datarootdir}/info'
+htmldir='${docdir}'
+dvidir='${docdir}'
+pdfdir='${docdir}'
+psdir='${docdir}'
+libdir='${exec_prefix}/lib'
+localedir='${datarootdir}/locale'
+mandir='${datarootdir}/man'
+
+ac_prev=
+ac_dashdash=
+for ac_option
+do
+  # If the previous option needs an argument, assign it.
+  if test -n "$ac_prev"; then
+    eval $ac_prev=\$ac_option
+    ac_prev=
+    continue
+  fi
+
+  case $ac_option in
+  *=*) ac_optarg=`expr "X$ac_option" : '[^=]*=\(.*\)'` ;;
+  *)   ac_optarg=yes ;;
+  esac
+
+  # Accept the important Cygnus configure options, so we can diagnose typos.
+
+  case $ac_dashdash$ac_option in
+  --)
+    ac_dashdash=yes ;;
+
+  -bindir | --bindir | --bindi | --bind | --bin | --bi)
+    ac_prev=bindir ;;
+  -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*)
+    bindir=$ac_optarg ;;
+
+  -build | --build | --buil | --bui | --bu)
+    ac_prev=build_alias ;;
+  -build=* | --build=* | --buil=* | --bui=* | --bu=*)
+    build_alias=$ac_optarg ;;
+
+  -cache-file | --cache-file | --cache-fil | --cache-fi \
+  | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c)
+    ac_prev=cache_file ;;
+  -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \
+  | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*)
+    cache_file=$ac_optarg ;;
+
+  --config-cache | -C)
+    cache_file=config.cache ;;
+
+  -datadir | --datadir | --datadi | --datad)
+    ac_prev=datadir ;;
+  -datadir=* | --datadir=* | --datadi=* | --datad=*)
+    datadir=$ac_optarg ;;
+
+  -datarootdir | --datarootdir | --datarootdi | --datarootd | --dataroot \
+  | --dataroo | --dataro | --datar)
+    ac_prev=datarootdir ;;
+  -datarootdir=* | --datarootdir=* | --datarootdi=* | --datarootd=* \
+  | --dataroot=* | --dataroo=* | --dataro=* | --datar=*)
+    datarootdir=$ac_optarg ;;
+
+  -disable-* | --disable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*disable-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--disable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=no ;;
+
+  -docdir | --docdir | --docdi | --doc | --do)
+    ac_prev=docdir ;;
+  -docdir=* | --docdir=* | --docdi=* | --doc=* | --do=*)
+    docdir=$ac_optarg ;;
+
+  -dvidir | --dvidir | --dvidi | --dvid | --dvi | --dv)
+    ac_prev=dvidir ;;
+  -dvidir=* | --dvidir=* | --dvidi=* | --dvid=* | --dvi=* | --dv=*)
+    dvidir=$ac_optarg ;;
+
+  -enable-* | --enable-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*enable-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid feature name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"enable_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--enable-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval enable_$ac_useropt=\$ac_optarg ;;
+
+  -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \
+  | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \
+  | --exec | --exe | --ex)
+    ac_prev=exec_prefix ;;
+  -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \
+  | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \
+  | --exec=* | --exe=* | --ex=*)
+    exec_prefix=$ac_optarg ;;
+
+  -gas | --gas | --ga | --g)
+    # Obsolete; use --with-gas.
+    with_gas=yes ;;
+
+  -help | --help | --hel | --he | -h)
+    ac_init_help=long ;;
+  -help=r* | --help=r* | --hel=r* | --he=r* | -hr*)
+    ac_init_help=recursive ;;
+  -help=s* | --help=s* | --hel=s* | --he=s* | -hs*)
+    ac_init_help=short ;;
+
+  -host | --host | --hos | --ho)
+    ac_prev=host_alias ;;
+  -host=* | --host=* | --hos=* | --ho=*)
+    host_alias=$ac_optarg ;;
+
+  -htmldir | --htmldir | --htmldi | --htmld | --html | --htm | --ht)
+    ac_prev=htmldir ;;
+  -htmldir=* | --htmldir=* | --htmldi=* | --htmld=* | --html=* | --htm=* \
+  | --ht=*)
+    htmldir=$ac_optarg ;;
+
+  -includedir | --includedir | --includedi | --included | --include \
+  | --includ | --inclu | --incl | --inc)
+    ac_prev=includedir ;;
+  -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \
+  | --includ=* | --inclu=* | --incl=* | --inc=*)
+    includedir=$ac_optarg ;;
+
+  -infodir | --infodir | --infodi | --infod | --info | --inf)
+    ac_prev=infodir ;;
+  -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*)
+    infodir=$ac_optarg ;;
+
+  -libdir | --libdir | --libdi | --libd)
+    ac_prev=libdir ;;
+  -libdir=* | --libdir=* | --libdi=* | --libd=*)
+    libdir=$ac_optarg ;;
+
+  -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \
+  | --libexe | --libex | --libe)
+    ac_prev=libexecdir ;;
+  -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \
+  | --libexe=* | --libex=* | --libe=*)
+    libexecdir=$ac_optarg ;;
+
+  -localedir | --localedir | --localedi | --localed | --locale)
+    ac_prev=localedir ;;
+  -localedir=* | --localedir=* | --localedi=* | --localed=* | --locale=*)
+    localedir=$ac_optarg ;;
+
+  -localstatedir | --localstatedir | --localstatedi | --localstated \
+  | --localstate | --localstat | --localsta | --localst | --locals)
+    ac_prev=localstatedir ;;
+  -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \
+  | --localstate=* | --localstat=* | --localsta=* | --localst=* | --locals=*)
+    localstatedir=$ac_optarg ;;
+
+  -mandir | --mandir | --mandi | --mand | --man | --ma | --m)
+    ac_prev=mandir ;;
+  -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*)
+    mandir=$ac_optarg ;;
+
+  -nfp | --nfp | --nf)
+    # Obsolete; use --without-fp.
+    with_fp=no ;;
+
+  -no-create | --no-create | --no-creat | --no-crea | --no-cre \
+  | --no-cr | --no-c | -n)
+    no_create=yes ;;
+
+  -no-recursion | --no-recursion | --no-recursio | --no-recursi \
+  | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r)
+    no_recursion=yes ;;
+
+  -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \
+  | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \
+  | --oldin | --oldi | --old | --ol | --o)
+    ac_prev=oldincludedir ;;
+  -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \
+  | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \
+  | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*)
+    oldincludedir=$ac_optarg ;;
+
+  -prefix | --prefix | --prefi | --pref | --pre | --pr | --p)
+    ac_prev=prefix ;;
+  -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*)
+    prefix=$ac_optarg ;;
+
+  -program-prefix | --program-prefix | --program-prefi | --program-pref \
+  | --program-pre | --program-pr | --program-p)
+    ac_prev=program_prefix ;;
+  -program-prefix=* | --program-prefix=* | --program-prefi=* \
+  | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*)
+    program_prefix=$ac_optarg ;;
+
+  -program-suffix | --program-suffix | --program-suffi | --program-suff \
+  | --program-suf | --program-su | --program-s)
+    ac_prev=program_suffix ;;
+  -program-suffix=* | --program-suffix=* | --program-suffi=* \
+  | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*)
+    program_suffix=$ac_optarg ;;
+
+  -program-transform-name | --program-transform-name \
+  | --program-transform-nam | --program-transform-na \
+  | --program-transform-n | --program-transform- \
+  | --program-transform | --program-transfor \
+  | --program-transfo | --program-transf \
+  | --program-trans | --program-tran \
+  | --progr-tra | --program-tr | --program-t)
+    ac_prev=program_transform_name ;;
+  -program-transform-name=* | --program-transform-name=* \
+  | --program-transform-nam=* | --program-transform-na=* \
+  | --program-transform-n=* | --program-transform-=* \
+  | --program-transform=* | --program-transfor=* \
+  | --program-transfo=* | --program-transf=* \
+  | --program-trans=* | --program-tran=* \
+  | --progr-tra=* | --program-tr=* | --program-t=*)
+    program_transform_name=$ac_optarg ;;
+
+  -pdfdir | --pdfdir | --pdfdi | --pdfd | --pdf | --pd)
+    ac_prev=pdfdir ;;
+  -pdfdir=* | --pdfdir=* | --pdfdi=* | --pdfd=* | --pdf=* | --pd=*)
+    pdfdir=$ac_optarg ;;
+
+  -psdir | --psdir | --psdi | --psd | --ps)
+    ac_prev=psdir ;;
+  -psdir=* | --psdir=* | --psdi=* | --psd=* | --ps=*)
+    psdir=$ac_optarg ;;
+
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil)
+    silent=yes ;;
+
+  -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
+    ac_prev=sbindir ;;
+  -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
+  | --sbi=* | --sb=*)
+    sbindir=$ac_optarg ;;
+
+  -sharedstatedir | --sharedstatedir | --sharedstatedi \
+  | --sharedstated | --sharedstate | --sharedstat | --sharedsta \
+  | --sharedst | --shareds | --shared | --share | --shar \
+  | --sha | --sh)
+    ac_prev=sharedstatedir ;;
+  -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \
+  | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \
+  | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \
+  | --sha=* | --sh=*)
+    sharedstatedir=$ac_optarg ;;
+
+  -site | --site | --sit)
+    ac_prev=site ;;
+  -site=* | --site=* | --sit=*)
+    site=$ac_optarg ;;
+
+  -srcdir | --srcdir | --srcdi | --srcd | --src | --sr)
+    ac_prev=srcdir ;;
+  -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*)
+    srcdir=$ac_optarg ;;
+
+  -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \
+  | --syscon | --sysco | --sysc | --sys | --sy)
+    ac_prev=sysconfdir ;;
+  -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \
+  | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*)
+    sysconfdir=$ac_optarg ;;
+
+  -target | --target | --targe | --targ | --tar | --ta | --t)
+    ac_prev=target_alias ;;
+  -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*)
+    target_alias=$ac_optarg ;;
+
+  -v | -verbose | --verbose | --verbos | --verbo | --verb)
+    verbose=yes ;;
+
+  -version | --version | --versio | --versi | --vers | -V)
+    ac_init_version=: ;;
+
+  -with-* | --with-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*with-\([^=]*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--with-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=\$ac_optarg ;;
+
+  -without-* | --without-*)
+    ac_useropt=`expr "x$ac_option" : 'x-*without-\(.*\)'`
+    # Reject names that are not valid shell variable names.
+    expr "x$ac_useropt" : ".*[^-+._$as_cr_alnum]" >/dev/null &&
+      as_fn_error "invalid package name: $ac_useropt"
+    ac_useropt_orig=$ac_useropt
+    ac_useropt=`$as_echo "$ac_useropt" | sed 's/[-+.]/_/g'`
+    case $ac_user_opts in
+      *"
+"with_$ac_useropt"
+"*) ;;
+      *) ac_unrecognized_opts="$ac_unrecognized_opts$ac_unrecognized_sep--without-$ac_useropt_orig"
+        ac_unrecognized_sep=', ';;
+    esac
+    eval with_$ac_useropt=no ;;
+
+  --x)
+    # Obsolete; use --with-x.
+    with_x=yes ;;
+
+  -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \
+  | --x-incl | --x-inc | --x-in | --x-i)
+    ac_prev=x_includes ;;
+  -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \
+  | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*)
+    x_includes=$ac_optarg ;;
+
+  -x-libraries | --x-libraries | --x-librarie | --x-librari \
+  | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l)
+    ac_prev=x_libraries ;;
+  -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \
+  | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*)
+    x_libraries=$ac_optarg ;;
+
+  -*) as_fn_error "unrecognized option: \`$ac_option'
+Try \`$0 --help' for more information."
+    ;;
+
+  *=*)
+    ac_envvar=`expr "x$ac_option" : 'x\([^=]*\)='`
+    # Reject names that are not valid shell variable names.
+    case $ac_envvar in #(
+      '' | [0-9]* | *[!_$as_cr_alnum]* )
+      as_fn_error "invalid variable name: \`$ac_envvar'" ;;
+    esac
+    eval $ac_envvar=\$ac_optarg
+    export $ac_envvar ;;
+
+  *)
+    # FIXME: should be removed in autoconf 3.0.
+    $as_echo "$as_me: WARNING: you should use --build, --host, --target" >&2
+    expr "x$ac_option" : ".*[^-._$as_cr_alnum]" >/dev/null &&
+      $as_echo "$as_me: WARNING: invalid host type: $ac_option" >&2
+    : ${build_alias=$ac_option} ${host_alias=$ac_option} ${target_alias=$ac_option}
+    ;;
+
+  esac
+done
+
+if test -n "$ac_prev"; then
+  ac_option=--`echo $ac_prev | sed 's/_/-/g'`
+  as_fn_error "missing argument to $ac_option"
+fi
+
+if test -n "$ac_unrecognized_opts"; then
+  case $enable_option_checking in
+    no) ;;
+    fatal) as_fn_error "unrecognized options: $ac_unrecognized_opts" ;;
+    *)     $as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2 ;;
+  esac
+fi
+
+# Check all directory arguments for consistency.
+for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
+               datadir sysconfdir sharedstatedir localstatedir includedir \
+               oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
+               libdir localedir mandir
+do
+  eval ac_val=\$$ac_var
+  # Remove trailing slashes.
+  case $ac_val in
+    */ )
+      ac_val=`expr "X$ac_val" : 'X\(.*[^/]\)' \| "X$ac_val" : 'X\(.*\)'`
+      eval $ac_var=\$ac_val;;
+  esac
+  # Be sure to have absolute directory names.
+  case $ac_val in
+    [\\/$]* | ?:[\\/]* )  continue;;
+    NONE | '' ) case $ac_var in *prefix ) continue;; esac;;
+  esac
+  as_fn_error "expected an absolute directory name for --$ac_var: $ac_val"
+done
+
+# There might be people who depend on the old broken behavior: `$host'
+# used to hold the argument of --host etc.
+# FIXME: To remove some day.
+build=$build_alias
+host=$host_alias
+target=$target_alias
+
+# FIXME: To remove some day.
+if test "x$host_alias" != x; then
+  if test "x$build_alias" = x; then
+    cross_compiling=maybe
+    $as_echo "$as_me: WARNING: If you wanted to set the --build type, don't use --host.
+    If a cross compiler is detected then cross compile mode will be used." >&2
+  elif test "x$build_alias" != "x$host_alias"; then
+    cross_compiling=yes
+  fi
+fi
+
+ac_tool_prefix=
+test -n "$host_alias" && ac_tool_prefix=$host_alias-
+
+test "$silent" = yes && exec 6>/dev/null
+
+
+ac_pwd=`pwd` && test -n "$ac_pwd" &&
+ac_ls_di=`ls -di .` &&
+ac_pwd_ls_di=`cd "$ac_pwd" && ls -di .` ||
+  as_fn_error "working directory cannot be determined"
+test "X$ac_ls_di" = "X$ac_pwd_ls_di" ||
+  as_fn_error "pwd does not report name of working directory"
+
+
+# Find the source files, if location was not specified.
+if test -z "$srcdir"; then
+  ac_srcdir_defaulted=yes
+  # Try the directory containing this script, then the parent directory.
+  ac_confdir=`$as_dirname -- "$as_myself" ||
+$as_expr X"$as_myself" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_myself" : 'X\(//\)[^/]' \| \
+        X"$as_myself" : 'X\(//\)$' \| \
+        X"$as_myself" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_myself" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  srcdir=$ac_confdir
+  if test ! -r "$srcdir/$ac_unique_file"; then
+    srcdir=..
+  fi
+else
+  ac_srcdir_defaulted=no
+fi
+if test ! -r "$srcdir/$ac_unique_file"; then
+  test "$ac_srcdir_defaulted" = yes && srcdir="$ac_confdir or .."
+  as_fn_error "cannot find sources ($ac_unique_file) in $srcdir"
+fi
+ac_msg="sources are in $srcdir, but \`cd $srcdir' does not work"
+ac_abs_confdir=`(
+       cd "$srcdir" && test -r "./$ac_unique_file" || as_fn_error "$ac_msg"
+       pwd)`
+# When building in place, set srcdir=.
+if test "$ac_abs_confdir" = "$ac_pwd"; then
+  srcdir=.
+fi
+# Remove unnecessary trailing slashes from srcdir.
+# Double slashes in file names in object file debugging info
+# mess up M-x gdb in Emacs.
+case $srcdir in
+*/) srcdir=`expr "X$srcdir" : 'X\(.*[^/]\)' \| "X$srcdir" : 'X\(.*\)'`;;
+esac
+for ac_var in $ac_precious_vars; do
+  eval ac_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_env_${ac_var}_value=\$${ac_var}
+  eval ac_cv_env_${ac_var}_set=\${${ac_var}+set}
+  eval ac_cv_env_${ac_var}_value=\$${ac_var}
+done
+
+#
+# Report the --help message.
+#
+if test "$ac_init_help" = "long"; then
+  # Omit some internal or obsolete options to make the list less imposing.
+  # This message is too long to be a string in the A/UX 3.1 sh.
+  cat <<_ACEOF
+\`configure' configures this package to adapt to many kinds of systems.
+
+Usage: $0 [OPTION]... [VAR=VALUE]...
+
+To assign environment variables (e.g., CC, CFLAGS...), specify them as
+VAR=VALUE.  See below for descriptions of some of the useful variables.
+
+Defaults for the options are specified in brackets.
+
+Configuration:
+  -h, --help              display this help and exit
+      --help=short        display options specific to this package
+      --help=recursive    display the short help of all the included packages
+  -V, --version           display version information and exit
+  -q, --quiet, --silent   do not print \`checking...' messages
+      --cache-file=FILE   cache test results in FILE [disabled]
+  -C, --config-cache      alias for \`--cache-file=config.cache'
+  -n, --no-create         do not create output files
+      --srcdir=DIR        find the sources in DIR [configure dir or \`..']
+
+Installation directories:
+  --prefix=PREFIX         install architecture-independent files in PREFIX
+                          [$ac_default_prefix]
+  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
+                          [PREFIX]
+
+By default, \`make install' will install all the files in
+\`$ac_default_prefix/bin', \`$ac_default_prefix/lib' etc.  You can specify
+an installation prefix other than \`$ac_default_prefix' using \`--prefix',
+for instance \`--prefix=\$HOME'.
+
+For better control, use the options below.
+
+Fine tuning of the installation directories:
+  --bindir=DIR            user executables [EPREFIX/bin]
+  --sbindir=DIR           system admin executables [EPREFIX/sbin]
+  --libexecdir=DIR        program executables [EPREFIX/libexec]
+  --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
+  --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
+  --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --libdir=DIR            object code libraries [EPREFIX/lib]
+  --includedir=DIR        C header files [PREFIX/include]
+  --oldincludedir=DIR     C header files for non-gcc [/usr/include]
+  --datarootdir=DIR       read-only arch.-independent data root [PREFIX/share]
+  --datadir=DIR           read-only architecture-independent data [DATAROOTDIR]
+  --infodir=DIR           info documentation [DATAROOTDIR/info]
+  --localedir=DIR         locale-dependent data [DATAROOTDIR/locale]
+  --mandir=DIR            man documentation [DATAROOTDIR/man]
+  --docdir=DIR            documentation root [DATAROOTDIR/doc/PACKAGE]
+  --htmldir=DIR           html documentation [DOCDIR]
+  --dvidir=DIR            dvi documentation [DOCDIR]
+  --pdfdir=DIR            pdf documentation [DOCDIR]
+  --psdir=DIR             ps documentation [DOCDIR]
+_ACEOF
+
+  cat <<\_ACEOF
+
+Program names:
+  --program-prefix=PREFIX            prepend PREFIX to installed program names
+  --program-suffix=SUFFIX            append SUFFIX to installed program names
+  --program-transform-name=PROGRAM   run sed PROGRAM on installed program names
+
+System types:
+  --build=BUILD     configure for building on BUILD [guessed]
+  --host=HOST       cross-compile to build programs to run on HOST [BUILD]
+_ACEOF
+fi
+
+if test -n "$ac_init_help"; then
+
+  cat <<\_ACEOF
+
+Optional Features:
+  --disable-option-checking  ignore unrecognized --enable/--with options
+  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
+  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
+  --disable-dependency-tracking  speeds up one-time build
+  --enable-dependency-tracking   do not reject slow dependency extractors
+  --enable-shared[=PKGS]  build shared libraries [default=no]
+  --enable-static[=PKGS]  build static libraries [default=yes]
+  --enable-fast-install[=PKGS]
+                          optimize for fast installation [default=yes]
+  --disable-libtool-lock  avoid locking (might break parallel builds)
+  --enable-local-libopts  Force using the supplied libopts tearoff code
+  --disable-libopts-install
+                          Do not install libopts with client installation
+  --disable-optional-args not wanting optional option args
+
+Optional Packages:
+  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
+  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
+  --with-gnu-ld           assume the C compiler uses GNU ld [default=no]
+  --with-pic              try to use only PIC/non-PIC objects [default=use
+                          both]
+  --with-tags[=TAGS]      include additional configurations [automatic]
+  --with-autoopts-config  specify the config-info script
+  --with-regex-header     a reg expr header is specified
+  --with-libregex         libregex installation prefix
+  --with-libregex-cflags  libregex compile flags
+  --with-libregex-libs    libregex link command arguments
+  --with-binsubdir        bin ={bin,sbin}
+
+Some influential environment variables:
+  CC          C compiler command
+  CFLAGS      C compiler flags
+  LDFLAGS     linker flags, e.g. -L<lib dir> if you have libraries in a
+              nonstandard directory <lib dir>
+  LIBS        libraries to pass to the linker, e.g. -l<library>
+  CPPFLAGS    (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
+              you have headers in a nonstandard directory <include dir>
+  CPP         C preprocessor
+
+Use these variables to override the choices made by `configure' or to help
+it to find libraries and programs with nonstandard names/locations.
+
+Report bugs to the package provider.
+_ACEOF
+ac_status=$?
+fi
+
+if test "$ac_init_help" = "recursive"; then
+  # If there are subdirs, report their specific --help.
+  for ac_dir in : $ac_subdirs_all; do test "x$ac_dir" = x: && continue
+    test -d "$ac_dir" ||
+      { cd "$srcdir" && ac_pwd=`pwd` && srcdir=. && test -d "$ac_dir"; } ||
+      continue
+    ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+    cd "$ac_dir" || { ac_status=$?; continue; }
+    # Check for guested configure.
+    if test -f "$ac_srcdir/configure.gnu"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure.gnu" --help=recursive
+    elif test -f "$ac_srcdir/configure"; then
+      echo &&
+      $SHELL "$ac_srcdir/configure" --help=recursive
+    else
+      $as_echo "$as_me: WARNING: no configuration information is in $ac_dir" >&2
+    fi || ac_status=$?
+    cd "$ac_pwd" || { ac_status=$?; break; }
+  done
+fi
+
+test -n "$ac_init_help" && exit $ac_status
+if $ac_init_version; then
+  cat <<\_ACEOF
+configure
+generated by GNU Autoconf 2.65
+
+Copyright (C) 2009 Free Software Foundation, Inc.
+This configure script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it.
+_ACEOF
+  exit
+fi
+
+## ------------------------ ##
+## Autoconf initialization. ##
+## ------------------------ ##
+
+# ac_fn_c_try_compile LINENO
+# --------------------------
+# Try to compile conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext
+  if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest.$ac_objext; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_compile
+
+# ac_fn_c_try_link LINENO
+# -----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_link ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  rm -f conftest.$ac_objext conftest$ac_exeext
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && {
+        test -z "$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       } && test -s conftest$ac_exeext && {
+        test "$cross_compiling" = yes ||
+        $as_test_x conftest$ac_exeext
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=1
+fi
+  # Delete the IPA/IPO (Inter Procedural Analysis/Optimization) information
+  # created by the PGI compiler (conftest_ipa8_conftest.oo), as it would
+  # interfere with the next link command; also delete a directory that is
+  # left behind by Apple's compiler.  We do this before executing the actions.
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_link
+
+# ac_fn_c_try_cpp LINENO
+# ----------------------
+# Try to preprocess conftest.$ac_ext, and return whether this succeeded.
+ac_fn_c_try_cpp ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_cpp conftest.$ac_ext"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_cpp conftest.$ac_ext") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    grep -v '^ *+' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+    mv -f conftest.er1 conftest.err
+  fi
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } >/dev/null && {
+        test -z "$ac_c_preproc_warn_flag$ac_c_werror_flag" ||
+        test ! -s conftest.err
+       }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+    ac_retval=1
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_cpp
+
+# ac_fn_c_check_header_mongrel LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists, giving a warning if it cannot be compiled using
+# the include files in INCLUDES and setting the cache variable VAR
+# accordingly.
+ac_fn_c_check_header_mongrel ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+else
+  # Is the header compilable?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 usability" >&5
+$as_echo_n "checking $2 usability... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_header_compiler=yes
+else
+  ac_header_compiler=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_compiler" >&5
+$as_echo "$ac_header_compiler" >&6; }
+
+# Is the header present?
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking $2 presence" >&5
+$as_echo_n "checking $2 presence... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <$2>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  ac_header_preproc=yes
+else
+  ac_header_preproc=no
+fi
+rm -f conftest.err conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_header_preproc" >&5
+$as_echo "$ac_header_preproc" >&6; }
+
+# So?  What about this header?
+case $ac_header_compiler:$ac_header_preproc:$ac_c_preproc_warn_flag in #((
+  yes:no: )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&5
+$as_echo "$as_me: WARNING: $2: accepted by the compiler, rejected by the preprocessor!" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+  no:yes:* )
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: present but cannot be compiled" >&5
+$as_echo "$as_me: WARNING: $2: present but cannot be compiled" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     check for missing prerequisite headers?" >&5
+$as_echo "$as_me: WARNING: $2:     check for missing prerequisite headers?" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: see the Autoconf documentation" >&5
+$as_echo "$as_me: WARNING: $2: see the Autoconf documentation" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&5
+$as_echo "$as_me: WARNING: $2:     section \"Present But Cannot Be Compiled\"" >&2;}
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $2: proceeding with the compiler's result" >&5
+$as_echo "$as_me: WARNING: $2: proceeding with the compiler's result" >&2;}
+    ;;
+esac
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=\$ac_header_compiler"
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_header_mongrel
+
+# ac_fn_c_try_run LINENO
+# ----------------------
+# Try to link conftest.$ac_ext, and return whether this succeeded. Assumes
+# that executables *can* be run.
+ac_fn_c_try_run ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && { ac_try='./conftest$ac_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then :
+  ac_retval=0
+else
+  $as_echo "$as_me: program exited with status $ac_status" >&5
+       $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+       ac_retval=$ac_status
+fi
+  rm -rf conftest.dSYM conftest_ipa8_conftest.oo
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_try_run
+
+# ac_fn_c_check_header_compile LINENO HEADER VAR INCLUDES
+# -------------------------------------------------------
+# Tests whether HEADER exists and can be compiled using the include files in
+# INCLUDES, setting the cache variable VAR accordingly.
+ac_fn_c_check_header_compile ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+#include <$2>
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_header_compile
+
+# ac_fn_c_check_func LINENO FUNC VAR
+# ----------------------------------
+# Tests whether FUNC exists, setting the cache variable VAR accordingly
+ac_fn_c_check_func ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+/* Define $2 to an innocuous variant, in case <limits.h> declares $2.
+   For example, HP-UX 11i <limits.h> declares gettimeofday.  */
+#define $2 innocuous_$2
+
+/* System header to define __stub macros and hopefully few prototypes,
+    which can conflict with char $2 (); below.
+    Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+    <limits.h> exists even on freestanding compilers.  */
+
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+
+#undef $2
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char $2 ();
+/* The GNU C library defines this for functions which it implements
+    to always fail with ENOSYS.  Some functions are actually named
+    something starting with __ and the normal name is an alias.  */
+#if defined __stub_$2 || defined __stub___$2
+choke me
+#endif
+
+int
+main ()
+{
+return $2 ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  eval "$3=yes"
+else
+  eval "$3=no"
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_func
+
+# ac_fn_c_check_type LINENO TYPE VAR INCLUDES
+# -------------------------------------------
+# Tests whether TYPE exists after having included INCLUDES, setting cache
+# variable VAR accordingly.
+ac_fn_c_check_type ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for $2" >&5
+$as_echo_n "checking for $2... " >&6; }
+if { as_var=$3; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  eval "$3=no"
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof ($2))
+        return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+if (sizeof (($2)))
+           return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  eval "$3=yes"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$3
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+
+} # ac_fn_c_check_type
+
+# ac_fn_c_compute_int LINENO EXPR VAR INCLUDES
+# --------------------------------------------
+# Tries to find the compile-time value of EXPR in a program that includes
+# INCLUDES, setting VAR accordingly. Returns whether the value could be
+# computed
+ac_fn_c_compute_int ()
+{
+  as_lineno=${as_lineno-"$1"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+  if test "$cross_compiling" = yes; then
+    # Depending upon the size, compute the lo and hi bounds.
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=0 ac_mid=0
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid; break
+else
+  as_fn_arith $ac_mid + 1 && ac_lo=$as_val
+                       if test $ac_lo -le $ac_mid; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       as_fn_arith 2 '*' $ac_mid + 1 && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) < 0)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=-1 ac_mid=-1
+  while :; do
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) >= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_lo=$ac_mid; break
+else
+  as_fn_arith '(' $ac_mid ')' - 1 && ac_hi=$as_val
+                       if test $ac_mid -le $ac_hi; then
+                         ac_lo= ac_hi=
+                         break
+                       fi
+                       as_fn_arith 2 '*' $ac_mid && ac_mid=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  done
+else
+  ac_lo= ac_hi=
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+# Binary search between lo and hi bounds.
+while test "x$ac_lo" != "x$ac_hi"; do
+  as_fn_arith '(' $ac_hi - $ac_lo ')' / 2 + $ac_lo && ac_mid=$as_val
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+int
+main ()
+{
+static int test_array [1 - 2 * !(($2) <= $ac_mid)];
+test_array [0] = 0
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_hi=$ac_mid
+else
+  as_fn_arith '(' $ac_mid ')' + 1 && ac_lo=$as_val
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+done
+case $ac_lo in #((
+?*) eval "$3=\$ac_lo"; ac_retval=0 ;;
+'') ac_retval=1 ;;
+esac
+  else
+    cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+$4
+static long int longval () { return $2; }
+static unsigned long int ulongval () { return $2; }
+#include <stdio.h>
+#include <stdlib.h>
+int
+main ()
+{
+
+  FILE *f = fopen ("conftest.val", "w");
+  if (! f)
+    return 1;
+  if (($2) < 0)
+    {
+      long int i = longval ();
+      if (i != ($2))
+       return 1;
+      fprintf (f, "%ld", i);
+    }
+  else
+    {
+      unsigned long int i = ulongval ();
+      if (i != ($2))
+       return 1;
+      fprintf (f, "%lu", i);
+    }
+  /* Do not output a trailing newline, as this causes \r\n confusion
+     on some platforms.  */
+  return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  echo >>conftest.val; read $3 <conftest.val; ac_retval=0
+else
+  ac_retval=1
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+rm -f conftest.val
+
+  fi
+  eval $as_lineno_stack; test "x$as_lineno_stack" = x && { as_lineno=; unset as_lineno;}
+  as_fn_set_status $ac_retval
+
+} # ac_fn_c_compute_int
+cat >config.log <<_ACEOF
+This file contains any messages produced by compilers while
+running configure, to aid debugging if configure makes a mistake.
+
+It was created by $as_me, which was
+generated by GNU Autoconf 2.65.  Invocation command line was
+
+  $ $0 $@
+
+_ACEOF
+exec 5>>config.log
+{
+cat <<_ASUNAME
+## --------- ##
+## Platform. ##
+## --------- ##
+
+hostname = `(hostname || uname -n) 2>/dev/null | sed 1q`
+uname -m = `(uname -m) 2>/dev/null || echo unknown`
+uname -r = `(uname -r) 2>/dev/null || echo unknown`
+uname -s = `(uname -s) 2>/dev/null || echo unknown`
+uname -v = `(uname -v) 2>/dev/null || echo unknown`
+
+/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null || echo unknown`
+/bin/uname -X     = `(/bin/uname -X) 2>/dev/null     || echo unknown`
+
+/bin/arch              = `(/bin/arch) 2>/dev/null              || echo unknown`
+/usr/bin/arch -k       = `(/usr/bin/arch -k) 2>/dev/null       || echo unknown`
+/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null || echo unknown`
+/usr/bin/hostinfo      = `(/usr/bin/hostinfo) 2>/dev/null      || echo unknown`
+/bin/machine           = `(/bin/machine) 2>/dev/null           || echo unknown`
+/usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null       || echo unknown`
+/bin/universe          = `(/bin/universe) 2>/dev/null          || echo unknown`
+
+_ASUNAME
+
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    $as_echo "PATH: $as_dir"
+  done
+IFS=$as_save_IFS
+
+} >&5
+
+cat >&5 <<_ACEOF
+
+
+## ----------- ##
+## Core tests. ##
+## ----------- ##
+
+_ACEOF
+
+
+# Keep a trace of the command line.
+# Strip out --no-create and --no-recursion so they do not pile up.
+# Strip out --silent because we don't want to record it for future runs.
+# Also quote any args containing shell meta-characters.
+# Make two passes to allow for proper duplicate-argument suppression.
+ac_configure_args=
+ac_configure_args0=
+ac_configure_args1=
+ac_must_keep_next=false
+for ac_pass in 1 2
+do
+  for ac_arg
+  do
+    case $ac_arg in
+    -no-create | --no-c* | -n | -no-recursion | --no-r*) continue ;;
+    -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+    | -silent | --silent | --silen | --sile | --sil)
+      continue ;;
+    *\'*)
+      ac_arg=`$as_echo "$ac_arg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    case $ac_pass in
+    1) as_fn_append ac_configure_args0 " '$ac_arg'" ;;
+    2)
+      as_fn_append ac_configure_args1 " '$ac_arg'"
+      if test $ac_must_keep_next = true; then
+       ac_must_keep_next=false # Got value, back to normal.
+      else
+       case $ac_arg in
+         *=* | --config-cache | -C | -disable-* | --disable-* \
+         | -enable-* | --enable-* | -gas | --g* | -nfp | --nf* \
+         | -q | -quiet | --q* | -silent | --sil* | -v | -verb* \
+         | -with-* | --with-* | -without-* | --without-* | --x)
+           case "$ac_configure_args0 " in
+             "$ac_configure_args1"*" '$ac_arg' "* ) continue ;;
+           esac
+           ;;
+         -* ) ac_must_keep_next=true ;;
+       esac
+      fi
+      as_fn_append ac_configure_args " '$ac_arg'"
+      ;;
+    esac
+  done
+done
+{ ac_configure_args0=; unset ac_configure_args0;}
+{ ac_configure_args1=; unset ac_configure_args1;}
+
+# When interrupted or exit'd, cleanup temporary files, and complete
+# config.log.  We remove comments because anyway the quotes in there
+# would cause problems or look ugly.
+# WARNING: Use '\'' to represent an apostrophe within the trap.
+# WARNING: Do not start the trap code with a newline, due to a FreeBSD 4.0 bug.
+trap 'exit_status=$?
+  # Save into config.log some information that might help in debugging.
+  {
+    echo
+
+    cat <<\_ASBOX
+## ---------------- ##
+## Cache variables. ##
+## ---------------- ##
+_ASBOX
+    echo
+    # The following way of writing the cache mishandles newlines in values,
+(
+  for ac_var in `(set) 2>&1 | sed -n '\''s/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'\''`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+  (set) 2>&1 |
+    case $as_nl`(ac_space='\'' '\''; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      sed -n \
+       "s/'\''/'\''\\\\'\'''\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\''\\2'\''/p"
+      ;; #(
+    *)
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+)
+    echo
+
+    cat <<\_ASBOX
+## ----------------- ##
+## Output variables. ##
+## ----------------- ##
+_ASBOX
+    echo
+    for ac_var in $ac_subst_vars
+    do
+      eval ac_val=\$$ac_var
+      case $ac_val in
+      *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+      esac
+      $as_echo "$ac_var='\''$ac_val'\''"
+    done | sort
+    echo
+
+    if test -n "$ac_subst_files"; then
+      cat <<\_ASBOX
+## ------------------- ##
+## File substitutions. ##
+## ------------------- ##
+_ASBOX
+      echo
+      for ac_var in $ac_subst_files
+      do
+       eval ac_val=\$$ac_var
+       case $ac_val in
+       *\'\''*) ac_val=`$as_echo "$ac_val" | sed "s/'\''/'\''\\\\\\\\'\'''\''/g"`;;
+       esac
+       $as_echo "$ac_var='\''$ac_val'\''"
+      done | sort
+      echo
+    fi
+
+    if test -s confdefs.h; then
+      cat <<\_ASBOX
+## ----------- ##
+## confdefs.h. ##
+## ----------- ##
+_ASBOX
+      echo
+      cat confdefs.h
+      echo
+    fi
+    test "$ac_signal" != 0 &&
+      $as_echo "$as_me: caught signal $ac_signal"
+    $as_echo "$as_me: exit $exit_status"
+  } >&5
+  rm -f core *.core core.conftest.* &&
+    rm -f -r conftest* confdefs* conf$$* $ac_clean_files &&
+    exit $exit_status
+' 0
+for ac_signal in 1 2 13 15; do
+  trap 'ac_signal='$ac_signal'; as_fn_exit 1' $ac_signal
+done
+ac_signal=0
+
+# confdefs.h avoids OS command line length limits that DEFS can exceed.
+rm -f -r conftest* confdefs.h
+
+$as_echo "/* confdefs.h */" > confdefs.h
+
+# Predefined preprocessor variables.
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_NAME "$PACKAGE_NAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_TARNAME "$PACKAGE_TARNAME"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_VERSION "$PACKAGE_VERSION"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_STRING "$PACKAGE_STRING"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_BUGREPORT "$PACKAGE_BUGREPORT"
+_ACEOF
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE_URL "$PACKAGE_URL"
+_ACEOF
+
+
+# Let the site file select an alternate cache file if it wants to.
+# Prefer an explicitly selected file to automatically selected ones.
+ac_site_file1=NONE
+ac_site_file2=NONE
+if test -n "$CONFIG_SITE"; then
+  ac_site_file1=$CONFIG_SITE
+elif test "x$prefix" != xNONE; then
+  ac_site_file1=$prefix/share/config.site
+  ac_site_file2=$prefix/etc/config.site
+else
+  ac_site_file1=$ac_default_prefix/share/config.site
+  ac_site_file2=$ac_default_prefix/etc/config.site
+fi
+for ac_site_file in "$ac_site_file1" "$ac_site_file2"
+do
+  test "x$ac_site_file" = xNONE && continue
+  if test /dev/null != "$ac_site_file" && test -r "$ac_site_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading site script $ac_site_file" >&5
+$as_echo "$as_me: loading site script $ac_site_file" >&6;}
+    sed 's/^/| /' "$ac_site_file" >&5
+    . "$ac_site_file"
+  fi
+done
+
+if test -r "$cache_file"; then
+  # Some versions of bash will fail to source /dev/null (special files
+  # actually), so we avoid doing that.  DJGPP emulates it as a regular file.
+  if test /dev/null != "$cache_file" && test -f "$cache_file"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: loading cache $cache_file" >&5
+$as_echo "$as_me: loading cache $cache_file" >&6;}
+    case $cache_file in
+      [\\/]* | ?:[\\/]* ) . "$cache_file";;
+      *)                      . "./$cache_file";;
+    esac
+  fi
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating cache $cache_file" >&5
+$as_echo "$as_me: creating cache $cache_file" >&6;}
+  >$cache_file
+fi
+
+# Check that the precious variables saved in the cache have kept the same
+# value.
+ac_cache_corrupted=false
+for ac_var in $ac_precious_vars; do
+  eval ac_old_set=\$ac_cv_env_${ac_var}_set
+  eval ac_new_set=\$ac_env_${ac_var}_set
+  eval ac_old_val=\$ac_cv_env_${ac_var}_value
+  eval ac_new_val=\$ac_env_${ac_var}_value
+  case $ac_old_set,$ac_new_set in
+    set,)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was set to \`$ac_old_val' in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,set)
+      { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' was not set in the previous run" >&5
+$as_echo "$as_me: error: \`$ac_var' was not set in the previous run" >&2;}
+      ac_cache_corrupted=: ;;
+    ,);;
+    *)
+      if test "x$ac_old_val" != "x$ac_new_val"; then
+       # differences in whitespace do not lead to failure.
+       ac_old_val_w=`echo x $ac_old_val`
+       ac_new_val_w=`echo x $ac_new_val`
+       if test "$ac_old_val_w" != "$ac_new_val_w"; then
+         { $as_echo "$as_me:${as_lineno-$LINENO}: error: \`$ac_var' has changed since the previous run:" >&5
+$as_echo "$as_me: error: \`$ac_var' has changed since the previous run:" >&2;}
+         ac_cache_corrupted=:
+       else
+         { $as_echo "$as_me:${as_lineno-$LINENO}: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&5
+$as_echo "$as_me: warning: ignoring whitespace changes in \`$ac_var' since the previous run:" >&2;}
+         eval $ac_var=\$ac_old_val
+       fi
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   former value:  \`$ac_old_val'" >&5
+$as_echo "$as_me:   former value:  \`$ac_old_val'" >&2;}
+       { $as_echo "$as_me:${as_lineno-$LINENO}:   current value: \`$ac_new_val'" >&5
+$as_echo "$as_me:   current value: \`$ac_new_val'" >&2;}
+      fi;;
+  esac
+  # Pass precious variables to config.status.
+  if test "$ac_new_set" = set; then
+    case $ac_new_val in
+    *\'*) ac_arg=$ac_var=`$as_echo "$ac_new_val" | sed "s/'/'\\\\\\\\''/g"` ;;
+    *) ac_arg=$ac_var=$ac_new_val ;;
+    esac
+    case " $ac_configure_args " in
+      *" '$ac_arg' "*) ;; # Avoid dups.  Use of quotes ensures accuracy.
+      *) as_fn_append ac_configure_args " '$ac_arg'" ;;
+    esac
+  fi
+done
+if $ac_cache_corrupted; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+  { $as_echo "$as_me:${as_lineno-$LINENO}: error: changes in the environment can compromise the build" >&5
+$as_echo "$as_me: error: changes in the environment can compromise the build" >&2;}
+  as_fn_error "run \`make distclean' and/or \`rm $cache_file' and start over" "$LINENO" 5
+fi
+## -------------------- ##
+## Main body of script. ##
+## -------------------- ##
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+am__api_version='1.11'
+
+ac_aux_dir=
+for ac_dir in "$srcdir" "$srcdir/.." "$srcdir/../.."; do
+  for ac_t in install-sh install.sh shtool; do
+    if test -f "$ac_dir/$ac_t"; then
+      ac_aux_dir=$ac_dir
+      ac_install_sh="$ac_aux_dir/$ac_t -c"
+      break 2
+    fi
+  done
+done
+if test -z "$ac_aux_dir"; then
+  as_fn_error "cannot find install-sh, install.sh, or shtool in \"$srcdir\" \"$srcdir/..\" \"$srcdir/../..\"" "$LINENO" 5
+fi
+
+# These three variables are undocumented and unsupported,
+# and are intended to be withdrawn in a future Autoconf release.
+# They can cause serious problems if a builder's source tree is in a directory
+# whose full name contains unusual characters.
+ac_config_guess="$SHELL $ac_aux_dir/config.guess"  # Please don't use this var.
+ac_config_sub="$SHELL $ac_aux_dir/config.sub"  # Please don't use this var.
+ac_configure="$SHELL $ac_aux_dir/configure"  # Please don't use this var.
+
+
+# Find a good install program.  We prefer a C program (faster),
+# so one script is as good as another.  But avoid the broken or
+# incompatible versions:
+# SysV /etc/install, /usr/sbin/install
+# SunOS /usr/etc/install
+# IRIX /sbin/install
+# AIX /bin/install
+# AmigaOS /C/install, which installs bootblocks on floppy discs
+# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag
+# AFS /usr/afsws/bin/install, which mishandles nonexistent args
+# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
+# OS/2's system install, which has a completely different semantic
+# ./install, which can be erroneously created by make from ./install.sh.
+# Reject install programs that cannot install multiple files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a BSD-compatible install" >&5
+$as_echo_n "checking for a BSD-compatible install... " >&6; }
+if test -z "$INSTALL"; then
+if test "${ac_cv_path_install+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    # Account for people who put trailing slashes in PATH elements.
+case $as_dir/ in #((
+  ./ | .// | /[cC]/* | \
+  /etc/* | /usr/sbin/* | /usr/etc/* | /sbin/* | /usr/afsws/bin/* | \
+  ?:[\\/]os2[\\/]install[\\/]* | ?:[\\/]OS2[\\/]INSTALL[\\/]* | \
+  /usr/ucb/* ) ;;
+  *)
+    # OSF1 and SCO ODT 3.0 have their own names for install.
+    # Don't use installbsd from OSF since it installs stuff as root
+    # by default.
+    for ac_prog in ginstall scoinst install; do
+      for ac_exec_ext in '' $ac_executable_extensions; do
+       if { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; }; then
+         if test $ac_prog = install &&
+           grep dspmsg "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # AIX install.  It has an incompatible calling convention.
+           :
+         elif test $ac_prog = install &&
+           grep pwplus "$as_dir/$ac_prog$ac_exec_ext" >/dev/null 2>&1; then
+           # program-specific install script used by HP pwplus--don't use.
+           :
+         else
+           rm -rf conftest.one conftest.two conftest.dir
+           echo one > conftest.one
+           echo two > conftest.two
+           mkdir conftest.dir
+           if "$as_dir/$ac_prog$ac_exec_ext" -c conftest.one conftest.two "`pwd`/conftest.dir" &&
+             test -s conftest.one && test -s conftest.two &&
+             test -s conftest.dir/conftest.one &&
+             test -s conftest.dir/conftest.two
+           then
+             ac_cv_path_install="$as_dir/$ac_prog$ac_exec_ext -c"
+             break 3
+           fi
+         fi
+       fi
+      done
+    done
+    ;;
+esac
+
+  done
+IFS=$as_save_IFS
+
+rm -rf conftest.one conftest.two conftest.dir
+
+fi
+  if test "${ac_cv_path_install+set}" = set; then
+    INSTALL=$ac_cv_path_install
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for INSTALL within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    INSTALL=$ac_install_sh
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $INSTALL" >&5
+$as_echo "$INSTALL" >&6; }
+
+# Use test -z because SunOS4 sh mishandles braces in ${var-val}.
+# It thinks the first close brace ends the variable substitution.
+test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}'
+
+test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL}'
+
+test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether build environment is sane" >&5
+$as_echo_n "checking whether build environment is sane... " >&6; }
+# Just in case
+sleep 1
+echo timestamp > conftest.file
+# Reject unsafe characters in $srcdir or the absolute working directory
+# name.  Accept space and tab only in the latter.
+am_lf='
+'
+case `pwd` in
+  *[\\\"\#\$\&\'\`$am_lf]*)
+    as_fn_error "unsafe absolute working directory name" "$LINENO" 5;;
+esac
+case $srcdir in
+  *[\\\"\#\$\&\'\`$am_lf\ \    ]*)
+    as_fn_error "unsafe srcdir value: \`$srcdir'" "$LINENO" 5;;
+esac
+
+# Do `set' in a subshell so we don't clobber the current shell's
+# arguments.  Must try -L first in case configure is actually a
+# symlink; some systems play weird games with the mod time of symlinks
+# (eg FreeBSD returns the mod time of the symlink's containing
+# directory).
+if (
+   set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
+   if test "$*" = "X"; then
+      # -L didn't work.
+      set X `ls -t "$srcdir/configure" conftest.file`
+   fi
+   rm -f conftest.file
+   if test "$*" != "X $srcdir/configure conftest.file" \
+      && test "$*" != "X conftest.file $srcdir/configure"; then
+
+      # If neither matched, then we have a broken ls.  This can happen
+      # if, for instance, CONFIG_SHELL is bash and it inherits a
+      # broken ls alias from the environment.  This has actually
+      # happened.  Such a system could not be considered "sane".
+      as_fn_error "ls -t appears to fail.  Make sure there is not a broken
+alias in your environment" "$LINENO" 5
+   fi
+
+   test "$2" = conftest.file
+   )
+then
+   # Ok.
+   :
+else
+   as_fn_error "newly created file is older than distributed files!
+Check your system clock" "$LINENO" 5
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+test "$program_prefix" != NONE &&
+  program_transform_name="s&^&$program_prefix&;$program_transform_name"
+# Use a double $ so make ignores it.
+test "$program_suffix" != NONE &&
+  program_transform_name="s&\$&$program_suffix&;$program_transform_name"
+# Double any \ or $.
+# By default was `s,x,x', remove it if useless.
+ac_script='s/[\\$]/&&/g;s/;s,x,x,$//'
+program_transform_name=`$as_echo "$program_transform_name" | sed "$ac_script"`
+
+# expand $ac_aux_dir to an absolute path
+am_aux_dir=`cd $ac_aux_dir && pwd`
+
+if test x"${MISSING+set}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
+  *)
+    MISSING="\${SHELL} $am_aux_dir/missing" ;;
+  esac
+fi
+# Use eval to expand $SHELL
+if eval "$MISSING --run true"; then
+  am_missing_run="$MISSING --run "
+else
+  am_missing_run=
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`missing' script is too old or missing" >&5
+$as_echo "$as_me: WARNING: \`missing' script is too old or missing" >&2;}
+fi
+
+if test x"${install_sh}" != xset; then
+  case $am_aux_dir in
+  *\ * | *\    *)
+    install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
+  *)
+    install_sh="\${SHELL} $am_aux_dir/install-sh"
+  esac
+fi
+
+# Installed binaries are usually stripped using `strip' when the user
+# run `make install-strip'.  However `strip' might not be the right
+# tool to use in cross-compilation environments, therefore Automake
+# will honor the `STRIP' environment variable to overrule this program.
+if test "$cross_compiling" != no; then
+  if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+fi
+INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a thread-safe mkdir -p" >&5
+$as_echo_n "checking for a thread-safe mkdir -p... " >&6; }
+if test -z "$MKDIR_P"; then
+  if test "${ac_cv_path_mkdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/opt/sfw/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in mkdir gmkdir; do
+        for ac_exec_ext in '' $ac_executable_extensions; do
+          { test -f "$as_dir/$ac_prog$ac_exec_ext" && $as_test_x "$as_dir/$ac_prog$ac_exec_ext"; } || continue
+          case `"$as_dir/$ac_prog$ac_exec_ext" --version 2>&1` in #(
+            'mkdir (GNU coreutils) '* | \
+            'mkdir (coreutils) '* | \
+            'mkdir (fileutils) '4.1*)
+              ac_cv_path_mkdir=$as_dir/$ac_prog$ac_exec_ext
+              break 3;;
+          esac
+        done
+       done
+  done
+IFS=$as_save_IFS
+
+fi
+
+  test -d ./--version && rmdir ./--version
+  if test "${ac_cv_path_mkdir+set}" = set; then
+    MKDIR_P="$ac_cv_path_mkdir -p"
+  else
+    # As a last resort, use the slow shell script.  Don't cache a
+    # value for MKDIR_P within a source directory, because that will
+    # break other packages using the cache if that directory is
+    # removed, or if the value is a relative name.
+    MKDIR_P="$ac_install_sh -d"
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $MKDIR_P" >&5
+$as_echo "$MKDIR_P" >&6; }
+
+mkdir_p="$MKDIR_P"
+case $mkdir_p in
+  [\\/$]* | ?:[\\/]*) ;;
+  */*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
+esac
+
+for ac_prog in gawk mawk nawk awk
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AWK+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AWK"; then
+  ac_cv_prog_AWK="$AWK" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AWK="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AWK=$ac_cv_prog_AWK
+if test -n "$AWK"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AWK" >&5
+$as_echo "$AWK" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$AWK" && break
+done
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ${MAKE-make} sets \$(MAKE)" >&5
+$as_echo_n "checking whether ${MAKE-make} sets \$(MAKE)... " >&6; }
+set x ${MAKE-make}
+ac_make=`$as_echo "$2" | sed 's/+/p/g; s/[^a-zA-Z0-9_]/_/g'`
+if { as_var=ac_cv_prog_make_${ac_make}_set; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat >conftest.make <<\_ACEOF
+SHELL = /bin/sh
+all:
+       @echo '@@@%%%=$(MAKE)=@@@%%%'
+_ACEOF
+# GNU make sometimes prints "make[1]: Entering...", which would confuse us.
+case `${MAKE-make} -f conftest.make 2>/dev/null` in
+  *@@@%%%=?*=@@@%%%*)
+    eval ac_cv_prog_make_${ac_make}_set=yes;;
+  *)
+    eval ac_cv_prog_make_${ac_make}_set=no;;
+esac
+rm -f conftest.make
+fi
+if eval test \$ac_cv_prog_make_${ac_make}_set = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+  SET_MAKE=
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+  SET_MAKE="MAKE=${MAKE-make}"
+fi
+
+rm -rf .tst 2>/dev/null
+mkdir .tst 2>/dev/null
+if test -d .tst; then
+  am__leading_dot=.
+else
+  am__leading_dot=_
+fi
+rmdir .tst 2>/dev/null
+
+if test "`cd $srcdir && pwd`" != "`pwd`"; then
+  # Use -I$(srcdir) only when $(srcdir) != ., so that make's output
+  # is not polluted with repeated "-I."
+  am__isrc=' -I$(srcdir)'
+  # test to see if srcdir already configured
+  if test -f $srcdir/config.status; then
+    as_fn_error "source directory already configured; run \"make distclean\" there first" "$LINENO" 5
+  fi
+fi
+
+# test whether we have cygpath
+if test -z "$CYGPATH_W"; then
+  if (cygpath --version) >/dev/null 2>/dev/null; then
+    CYGPATH_W='cygpath -w'
+  else
+    CYGPATH_W=echo
+  fi
+fi
+
+
+# Define the identity of the package.
+ PACKAGE=msntp
+ VERSION=1.6
+
+
+cat >>confdefs.h <<_ACEOF
+#define PACKAGE "$PACKAGE"
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define VERSION "$VERSION"
+_ACEOF
+
+# Some tools Automake needs.
+
+ACLOCAL=${ACLOCAL-"${am_missing_run}aclocal-${am__api_version}"}
+
+
+AUTOCONF=${AUTOCONF-"${am_missing_run}autoconf"}
+
+
+AUTOMAKE=${AUTOMAKE-"${am_missing_run}automake-${am__api_version}"}
+
+
+AUTOHEADER=${AUTOHEADER-"${am_missing_run}autoheader"}
+
+
+MAKEINFO=${MAKEINFO-"${am_missing_run}makeinfo"}
+
+# We need awk for the "check" target.  The system "awk" is bad on
+# some platforms.
+# Always define AMTAR for backward compatibility.
+
+AMTAR=${AMTAR-"${am_missing_run}tar"}
+
+am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'
+
+
+
+
+
+
+# Make sure we can run config.sub.
+$SHELL "$ac_aux_dir/config.sub" sun4 >/dev/null 2>&1 ||
+  as_fn_error "cannot run $SHELL $ac_aux_dir/config.sub" "$LINENO" 5
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking build system type" >&5
+$as_echo_n "checking build system type... " >&6; }
+if test "${ac_cv_build+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_build_alias=$build_alias
+test "x$ac_build_alias" = x &&
+  ac_build_alias=`$SHELL "$ac_aux_dir/config.guess"`
+test "x$ac_build_alias" = x &&
+  as_fn_error "cannot guess build type; you must specify one" "$LINENO" 5
+ac_cv_build=`$SHELL "$ac_aux_dir/config.sub" $ac_build_alias` ||
+  as_fn_error "$SHELL $ac_aux_dir/config.sub $ac_build_alias failed" "$LINENO" 5
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_build" >&5
+$as_echo "$ac_cv_build" >&6; }
+case $ac_cv_build in
+*-*-*) ;;
+*) as_fn_error "invalid value of canonical build" "$LINENO" 5;;
+esac
+build=$ac_cv_build
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_build
+shift
+build_cpu=$1
+build_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+build_os=$*
+IFS=$ac_save_IFS
+case $build_os in *\ *) build_os=`echo "$build_os" | sed 's/ /-/g'`;; esac
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking host system type" >&5
+$as_echo_n "checking host system type... " >&6; }
+if test "${ac_cv_host+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test "x$host_alias" = x; then
+  ac_cv_host=$ac_cv_build
+else
+  ac_cv_host=`$SHELL "$ac_aux_dir/config.sub" $host_alias` ||
+    as_fn_error "$SHELL $ac_aux_dir/config.sub $host_alias failed" "$LINENO" 5
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_host" >&5
+$as_echo "$ac_cv_host" >&6; }
+case $ac_cv_host in
+*-*-*) ;;
+*) as_fn_error "invalid value of canonical host" "$LINENO" 5;;
+esac
+host=$ac_cv_host
+ac_save_IFS=$IFS; IFS='-'
+set x $ac_cv_host
+shift
+host_cpu=$1
+host_vendor=$2
+shift; shift
+# Remember, the first character of IFS is used to create $*,
+# except with old shells:
+host_os=$*
+IFS=$ac_save_IFS
+case $host_os in *\ *) host_os=`echo "$host_os" | sed 's/ /-/g'`;; esac
+
+
+ac_config_headers="$ac_config_headers config.h"
+
+
+# Checks for programs.
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_CC"; then
+  ac_ct_CC=$CC
+  # Extract the first word of "gcc", so it can be a program name with args.
+set dummy gcc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="gcc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+else
+  CC="$ac_cv_prog_CC"
+fi
+
+if test -z "$CC"; then
+          if test -n "$ac_tool_prefix"; then
+    # Extract the first word of "${ac_tool_prefix}cc", so it can be a program name with args.
+set dummy ${ac_tool_prefix}cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="${ac_tool_prefix}cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  fi
+fi
+if test -z "$CC"; then
+  # Extract the first word of "cc", so it can be a program name with args.
+set dummy cc; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+  ac_prog_rejected=no
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    if test "$as_dir/$ac_word$ac_exec_ext" = "/usr/ucb/cc"; then
+       ac_prog_rejected=yes
+       continue
+     fi
+    ac_cv_prog_CC="cc"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+if test $ac_prog_rejected = yes; then
+  # We found a bogon in the path, so make sure we never use it.
+  set dummy $ac_cv_prog_CC
+  shift
+  if test $# != 0; then
+    # We chose a different compiler from the bogus one.
+    # However, it has the same basename, so the bogon will be chosen
+    # first if we set CC to just the basename; use the full file name.
+    shift
+    ac_cv_prog_CC="$as_dir/$ac_word${1+' '}$@"
+  fi
+fi
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$CC"; then
+  if test -n "$ac_tool_prefix"; then
+  for ac_prog in cl.exe
+  do
+    # Extract the first word of "$ac_tool_prefix$ac_prog", so it can be a program name with args.
+set dummy $ac_tool_prefix$ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$CC"; then
+  ac_cv_prog_CC="$CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_CC="$ac_tool_prefix$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+CC=$ac_cv_prog_CC
+if test -n "$CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $CC" >&5
+$as_echo "$CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+    test -n "$CC" && break
+  done
+fi
+if test -z "$CC"; then
+  ac_ct_CC=$CC
+  for ac_prog in cl.exe
+do
+  # Extract the first word of "$ac_prog", so it can be a program name with args.
+set dummy $ac_prog; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_CC+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_CC"; then
+  ac_cv_prog_ac_ct_CC="$ac_ct_CC" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_CC="$ac_prog"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_CC=$ac_cv_prog_ac_ct_CC
+if test -n "$ac_ct_CC"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_CC" >&5
+$as_echo "$ac_ct_CC" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+  test -n "$ac_ct_CC" && break
+done
+
+  if test "x$ac_ct_CC" = x; then
+    CC=""
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    CC=$ac_ct_CC
+  fi
+fi
+
+fi
+
+
+test -z "$CC" && { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "no acceptable C compiler found in \$PATH
+See \`config.log' for more details." "$LINENO" 5; }
+
+# Provide some information about the compiler.
+$as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler version" >&5
+set X $ac_compile
+ac_compiler=$2
+for ac_option in --version -v -V -qversion; do
+  { { ac_try="$ac_compiler $ac_option >&5"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compiler $ac_option >&5") 2>conftest.err
+  ac_status=$?
+  if test -s conftest.err; then
+    sed '10a\
+... rest of stderr output deleted ...
+         10q' conftest.err >conftest.er1
+    cat conftest.er1 >&5
+  fi
+  rm -f conftest.er1 conftest.err
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+done
+
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files a.out a.out.dSYM a.exe b.out"
+# Try to create an executable without -o first, disregard a.out.
+# It will help us diagnose broken compilers, and finding out an intuition
+# of exeext.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler works" >&5
+$as_echo_n "checking whether the C compiler works... " >&6; }
+ac_link_default=`$as_echo "$ac_link" | sed 's/ -o *conftest[^ ]*//'`
+
+# The possible output files:
+ac_files="a.out conftest.exe conftest a.exe a_out.exe b.out conftest.*"
+
+ac_rmfiles=
+for ac_file in $ac_files
+do
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    * ) ac_rmfiles="$ac_rmfiles $ac_file";;
+  esac
+done
+rm -f $ac_rmfiles
+
+if { { ac_try="$ac_link_default"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link_default") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # Autoconf-2.13 could set the ac_cv_exeext variable to `no'.
+# So ignore a value of `no', otherwise this would lead to `EXEEXT = no'
+# in a Makefile.  We should not override ac_cv_exeext if it was cached,
+# so that the user can short-circuit this test for compilers unknown to
+# Autoconf.
+for ac_file in $ac_files ''
+do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj )
+       ;;
+    [ab].out )
+       # We found the default executable, but exeext='' is most
+       # certainly right.
+       break;;
+    *.* )
+       if test "${ac_cv_exeext+set}" = set && test "$ac_cv_exeext" != no;
+       then :; else
+          ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+       fi
+       # We set ac_cv_exeext here because the later test for it is not
+       # safe: cross compilers may not add the suffix if given an `-o'
+       # argument, so we may need to know it at that point already.
+       # Even if this section looks crufty: it has the advantage of
+       # actually working.
+       break;;
+    * )
+       break;;
+  esac
+done
+test "$ac_cv_exeext" = no && ac_cv_exeext=
+
+else
+  ac_file=''
+fi
+if test -z "$ac_file"; then :
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+$as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "C compiler cannot create executables
+See \`config.log' for more details." "$LINENO" 5; }; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for C compiler default output file name" >&5
+$as_echo_n "checking for C compiler default output file name... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_file" >&5
+$as_echo "$ac_file" >&6; }
+ac_exeext=$ac_cv_exeext
+
+rm -f -r a.out a.out.dSYM a.exe conftest$ac_cv_exeext b.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of executables" >&5
+$as_echo_n "checking for suffix of executables... " >&6; }
+if { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  # If both `conftest.exe' and `conftest' are `present' (well, observable)
+# catch `conftest.exe'.  For instance with Cygwin, `ls conftest' will
+# work properly (i.e., refer to `conftest.exe'), while it won't with
+# `rm'.
+for ac_file in conftest.exe conftest conftest.*; do
+  test -f "$ac_file" || continue
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM | *.o | *.obj ) ;;
+    *.* ) ac_cv_exeext=`expr "$ac_file" : '[^.]*\(\..*\)'`
+         break;;
+    * ) break;;
+  esac
+done
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot compute suffix of executables: cannot compile and link
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+rm -f conftest conftest$ac_cv_exeext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_exeext" >&5
+$as_echo "$ac_cv_exeext" >&6; }
+
+rm -f conftest.$ac_ext
+EXEEXT=$ac_cv_exeext
+ac_exeext=$EXEEXT
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int
+main ()
+{
+FILE *f = fopen ("conftest.out", "w");
+ return ferror (f) || fclose (f) != 0;
+
+  ;
+  return 0;
+}
+_ACEOF
+ac_clean_files="$ac_clean_files conftest.out"
+# Check that the compiler produces executables we can run.  If not, either
+# the compiler is broken, or we cross compile.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are cross compiling" >&5
+$as_echo_n "checking whether we are cross compiling... " >&6; }
+if test "$cross_compiling" != yes; then
+  { { ac_try="$ac_link"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_link") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+  if { ac_try='./conftest$ac_cv_exeext'
+  { { case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_try") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; }; then
+    cross_compiling=no
+  else
+    if test "$cross_compiling" = maybe; then
+       cross_compiling=yes
+    else
+       { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot run C compiled programs.
+If you meant to cross compile, use \`--host'.
+See \`config.log' for more details." "$LINENO" 5; }
+    fi
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $cross_compiling" >&5
+$as_echo "$cross_compiling" >&6; }
+
+rm -f conftest.$ac_ext conftest$ac_cv_exeext conftest.out
+ac_clean_files=$ac_clean_files_save
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for suffix of object files" >&5
+$as_echo_n "checking for suffix of object files... " >&6; }
+if test "${ac_cv_objext+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+rm -f conftest.o conftest.obj
+if { { ac_try="$ac_compile"
+case "(($ac_try" in
+  *\"* | *\`* | *\\*) ac_try_echo=\$ac_try;;
+  *) ac_try_echo=$ac_try;;
+esac
+eval ac_try_echo="\"\$as_me:${as_lineno-$LINENO}: $ac_try_echo\""
+$as_echo "$ac_try_echo"; } >&5
+  (eval "$ac_compile") 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then :
+  for ac_file in conftest.o conftest.obj conftest.*; do
+  test -f "$ac_file" || continue;
+  case $ac_file in
+    *.$ac_ext | *.xcoff | *.tds | *.d | *.pdb | *.xSYM | *.bb | *.bbg | *.map | *.inf | *.dSYM ) ;;
+    *) ac_cv_objext=`expr "$ac_file" : '.*\.\(.*\)'`
+       break;;
+  esac
+done
+else
+  $as_echo "$as_me: failed program was:" >&5
+sed 's/^/| /' conftest.$ac_ext >&5
+
+{ { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "cannot compute suffix of object files: cannot compile
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+rm -f conftest.$ac_cv_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_objext" >&5
+$as_echo "$ac_cv_objext" >&6; }
+OBJEXT=$ac_cv_objext
+ac_objext=$OBJEXT
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we are using the GNU C compiler" >&5
+$as_echo_n "checking whether we are using the GNU C compiler... " >&6; }
+if test "${ac_cv_c_compiler_gnu+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#ifndef __GNUC__
+       choke me
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_compiler_gnu=yes
+else
+  ac_compiler_gnu=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+ac_cv_c_compiler_gnu=$ac_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_compiler_gnu" >&5
+$as_echo "$ac_cv_c_compiler_gnu" >&6; }
+if test $ac_compiler_gnu = yes; then
+  GCC=yes
+else
+  GCC=
+fi
+ac_test_CFLAGS=${CFLAGS+set}
+ac_save_CFLAGS=$CFLAGS
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether $CC accepts -g" >&5
+$as_echo_n "checking whether $CC accepts -g... " >&6; }
+if test "${ac_cv_prog_cc_g+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_save_c_werror_flag=$ac_c_werror_flag
+   ac_c_werror_flag=yes
+   ac_cv_prog_cc_g=no
+   CFLAGS="-g"
+   cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+else
+  CFLAGS=""
+      cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+
+else
+  ac_c_werror_flag=$ac_save_c_werror_flag
+        CFLAGS="-g"
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_g=yes
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+   ac_c_werror_flag=$ac_save_c_werror_flag
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_g" >&5
+$as_echo "$ac_cv_prog_cc_g" >&6; }
+if test "$ac_test_CFLAGS" = set; then
+  CFLAGS=$ac_save_CFLAGS
+elif test $ac_cv_prog_cc_g = yes; then
+  if test "$GCC" = yes; then
+    CFLAGS="-g -O2"
+  else
+    CFLAGS="-g"
+  fi
+else
+  if test "$GCC" = yes; then
+    CFLAGS="-O2"
+  else
+    CFLAGS=
+  fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $CC option to accept ISO C89" >&5
+$as_echo_n "checking for $CC option to accept ISO C89... " >&6; }
+if test "${ac_cv_prog_cc_c89+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_prog_cc_c89=no
+ac_save_CC=$CC
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdarg.h>
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+/* Most of the following tests are stolen from RCS 5.7's src/conf.sh.  */
+struct buf { int x; };
+FILE * (*rcsopen) (struct buf *, struct stat *, int);
+static char *e (p, i)
+     char **p;
+     int i;
+{
+  return p[i];
+}
+static char *f (char * (*g) (char **, int), char **p, ...)
+{
+  char *s;
+  va_list v;
+  va_start (v,p);
+  s = g (p, va_arg (v,int));
+  va_end (v);
+  return s;
+}
+
+/* OSF 4.0 Compaq cc is some sort of almost-ANSI by default.  It has
+   function prototypes and stuff, but not '\xHH' hex character constants.
+   These don't provoke an error unfortunately, instead are silently treated
+   as 'x'.  The following induces an error, until -std is added to get
+   proper ANSI mode.  Curiously '\x00'!='x' always comes out true, for an
+   array size at least.  It's necessary to write '\x00'==0 to get something
+   that's true only with -std.  */
+int osf4_cc_array ['\x00' == 0 ? 1 : -1];
+
+/* IBM C 6 for AIX is almost-ANSI by default, but it replaces macro parameters
+   inside strings and character constants.  */
+#define FOO(x) 'x'
+int xlc6_cc_array[FOO(a) == 'x' ? 1 : -1];
+
+int test (int i, double x);
+struct s1 {int (*f) (int a);};
+struct s2 {int (*f) (double a);};
+int pairnames (int, char **, FILE *(*)(struct buf *, struct stat *, int), int, int);
+int argc;
+char **argv;
+int
+main ()
+{
+return f (e, argv, 0) != argv[0]  ||  f (e, argv, 1) != argv[1];
+  ;
+  return 0;
+}
+_ACEOF
+for ac_arg in '' -qlanglvl=extc89 -qlanglvl=ansi -std \
+       -Ae "-Aa -D_HPUX_SOURCE" "-Xc -D__EXTENSIONS__"
+do
+  CC="$ac_save_CC $ac_arg"
+  if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_prog_cc_c89=$ac_arg
+fi
+rm -f core conftest.err conftest.$ac_objext
+  test "x$ac_cv_prog_cc_c89" != "xno" && break
+done
+rm -f conftest.$ac_ext
+CC=$ac_save_CC
+
+fi
+# AC_CACHE_VAL
+case "x$ac_cv_prog_cc_c89" in
+  x)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: none needed" >&5
+$as_echo "none needed" >&6; } ;;
+  xno)
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: unsupported" >&5
+$as_echo "unsupported" >&6; } ;;
+  *)
+    CC="$CC $ac_cv_prog_cc_c89"
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_prog_cc_c89" >&5
+$as_echo "$ac_cv_prog_cc_c89" >&6; } ;;
+esac
+if test "x$ac_cv_prog_cc_c89" != xno; then :
+
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+DEPDIR="${am__leading_dot}deps"
+
+ac_config_commands="$ac_config_commands depfiles"
+
+
+am_make=${MAKE-make}
+cat > confinc << 'END'
+am__doit:
+       @echo this is the am__doit target
+.PHONY: am__doit
+END
+# If we don't find an include directive, just comment out the code.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for style of include used by $am_make" >&5
+$as_echo_n "checking for style of include used by $am_make... " >&6; }
+am__include="#"
+am__quote=
+_am_result=none
+# First try GNU make style include.
+echo "include confinc" > confmf
+# Ignore all kinds of additional output from `make'.
+case `$am_make -s -f confmf 2> /dev/null` in #(
+*the\ am__doit\ target*)
+  am__include=include
+  am__quote=
+  _am_result=GNU
+  ;;
+esac
+# Now try BSD make style include.
+if test "$am__include" = "#"; then
+   echo '.include "confinc"' > confmf
+   case `$am_make -s -f confmf 2> /dev/null` in #(
+   *the\ am__doit\ target*)
+     am__include=.include
+     am__quote="\""
+     _am_result=BSD
+     ;;
+   esac
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $_am_result" >&5
+$as_echo "$_am_result" >&6; }
+rm -f confinc confmf
+
+# Check whether --enable-dependency-tracking was given.
+if test "${enable_dependency_tracking+set}" = set; then :
+  enableval=$enable_dependency_tracking;
+fi
+
+if test "x$enable_dependency_tracking" != xno; then
+  am_depcomp="$ac_aux_dir/depcomp"
+  AMDEPBACKSLASH='\'
+fi
+ if test "x$enable_dependency_tracking" != xno; then
+  AMDEP_TRUE=
+  AMDEP_FALSE='#'
+else
+  AMDEP_TRUE='#'
+  AMDEP_FALSE=
+fi
+
+
+
+depcc="$CC"   am_compiler_list=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dependency style of $depcc" >&5
+$as_echo_n "checking dependency style of $depcc... " >&6; }
+if test "${am_cv_CC_dependencies_compiler_type+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
+  # We make a subdir and do the tests there.  Otherwise we can end up
+  # making bogus files that we don't know about and never remove.  For
+  # instance it was reported that on HP-UX the gcc test will end up
+  # making a dummy file named `D' -- because `-MD' means `put the output
+  # in D'.
+  mkdir conftest.dir
+  # Copy depcomp to subdir because otherwise we won't find it if we're
+  # using a relative directory.
+  cp "$am_depcomp" conftest.dir
+  cd conftest.dir
+  # We will build objects and dependencies in a subdirectory because
+  # it helps to detect inapplicable dependency modes.  For instance
+  # both Tru64's cc and ICC support -MD to output dependencies as a
+  # side effect of compilation, but ICC will put the dependencies in
+  # the current directory while Tru64 will put them in the object
+  # directory.
+  mkdir sub
+
+  am_cv_CC_dependencies_compiler_type=none
+  if test "$am_compiler_list" = ""; then
+     am_compiler_list=`sed -n 's/^#*\([a-zA-Z0-9]*\))$/\1/p' < ./depcomp`
+  fi
+  am__universal=false
+  case " $depcc " in #(
+     *\ -arch\ *\ -arch\ *) am__universal=true ;;
+     esac
+
+  for depmode in $am_compiler_list; do
+    # Setup a source with many dependencies, because some compilers
+    # like to wrap large dependency lists on column 80 (with \), and
+    # we should not choose a depcomp mode which is confused by this.
+    #
+    # We need to recreate these files for each test, as the compiler may
+    # overwrite some of them when testing with obscure command lines.
+    # This happens at least with the AIX C compiler.
+    : > sub/conftest.c
+    for i in 1 2 3 4 5 6; do
+      echo '#include "conftst'$i'.h"' >> sub/conftest.c
+      # Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
+      # Solaris 8's {/usr,}/bin/sh.
+      touch sub/conftst$i.h
+    done
+    echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
+
+    # We check with `-c' and `-o' for the sake of the "dashmstdout"
+    # mode.  It turns out that the SunPro C++ compiler does not properly
+    # handle `-M -o', and we need to detect this.  Also, some Intel
+    # versions had trouble with output in subdirs
+    am__obj=sub/conftest.${OBJEXT-o}
+    am__minus_obj="-o $am__obj"
+    case $depmode in
+    gcc)
+      # This depmode causes a compiler race in universal mode.
+      test "$am__universal" = false || continue
+      ;;
+    nosideeffect)
+      # after this tag, mechanisms are not by side-effect, so they'll
+      # only be used when explicitly requested
+      if test "x$enable_dependency_tracking" = xyes; then
+       continue
+      else
+       break
+      fi
+      ;;
+    msvisualcpp | msvcmsys)
+      # This compiler won't grok `-c -o', but also, the minuso test has
+      # not run yet.  These depmodes are late enough in the game, and
+      # so weak that their functioning should not be impacted.
+      am__obj=conftest.${OBJEXT-o}
+      am__minus_obj=
+      ;;
+    none) break ;;
+    esac
+    if depmode=$depmode \
+       source=sub/conftest.c object=$am__obj \
+       depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
+       $SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
+         >/dev/null 2>conftest.err &&
+       grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
+       grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
+       ${MAKE-make} -s -f confmf > /dev/null 2>&1; then
+      # icc doesn't choke on unknown options, it will just issue warnings
+      # or remarks (even with -Werror).  So we grep stderr for any message
+      # that says an option was ignored or not supported.
+      # When given -MP, icc 7.0 and 7.1 complain thusly:
+      #   icc: Command line warning: ignoring option '-M'; no argument required
+      # The diagnosis changed in icc 8.0:
+      #   icc: Command line remark: option '-MP' not supported
+      if (grep 'ignoring option' conftest.err ||
+          grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
+        am_cv_CC_dependencies_compiler_type=$depmode
+        break
+      fi
+    fi
+  done
+
+  cd ..
+  rm -rf conftest.dir
+else
+  am_cv_CC_dependencies_compiler_type=none
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $am_cv_CC_dependencies_compiler_type" >&5
+$as_echo "$am_cv_CC_dependencies_compiler_type" >&6; }
+CCDEPMODE=depmode=$am_cv_CC_dependencies_compiler_type
+
+ if
+  test "x$enable_dependency_tracking" != xno \
+  && test "$am_cv_CC_dependencies_compiler_type" = gcc3; then
+  am__fastdepCC_TRUE=
+  am__fastdepCC_FALSE='#'
+else
+  am__fastdepCC_TRUE='#'
+  am__fastdepCC_FALSE=
+fi
+
+
+
+# So far, the only shared library we might use is libopts.
+# It's a small library - we might as well use a static version of it.
+# Check whether --enable-shared was given.
+if test "${enable_shared+set}" = set; then :
+  enableval=$enable_shared; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_shared=yes ;;
+    no) enable_shared=no ;;
+    *)
+      enable_shared=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_shared=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_shared=no
+fi
+
+
+
+
+
+
+
+# Check whether --enable-static was given.
+if test "${enable_static+set}" = set; then :
+  enableval=$enable_static; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_static=yes ;;
+    no) enable_static=no ;;
+    *)
+     enable_static=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_static=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_static=yes
+fi
+
+
+# Check whether --enable-fast-install was given.
+if test "${enable_fast_install+set}" = set; then :
+  enableval=$enable_fast_install; p=${PACKAGE-default}
+    case $enableval in
+    yes) enable_fast_install=yes ;;
+    no) enable_fast_install=no ;;
+    *)
+      enable_fast_install=no
+      # Look at the argument we got.  We use all the common list separators.
+      lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+      for pkg in $enableval; do
+       IFS="$lt_save_ifs"
+       if test "X$pkg" = "X$p"; then
+         enable_fast_install=yes
+       fi
+      done
+      IFS="$lt_save_ifs"
+      ;;
+    esac
+else
+  enable_fast_install=yes
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for a sed that does not truncate output" >&5
+$as_echo_n "checking for a sed that does not truncate output... " >&6; }
+if test "${lt_cv_path_SED+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # Loop through the user's path and test for sed and gsed.
+# Then use that list of sed's as ones to test for truncation.
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+  for lt_ac_prog in sed gsed; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      if $as_executable_p "$as_dir/$lt_ac_prog$ac_exec_ext"; then
+        lt_ac_sed_list="$lt_ac_sed_list $as_dir/$lt_ac_prog$ac_exec_ext"
+      fi
+    done
+  done
+done
+lt_ac_max=0
+lt_ac_count=0
+# Add /usr/xpg4/bin/sed as it is typically found on Solaris
+# along with /bin/sed that truncates output.
+for lt_ac_sed in $lt_ac_sed_list /usr/xpg4/bin/sed; do
+  test ! -f $lt_ac_sed && continue
+  cat /dev/null > conftest.in
+  lt_ac_count=0
+  echo $ECHO_N "0123456789$ECHO_C" >conftest.in
+  # Check for GNU sed and select it if it is found.
+  if "$lt_ac_sed" --version 2>&1 < /dev/null | grep 'GNU' > /dev/null; then
+    lt_cv_path_SED=$lt_ac_sed
+    break
+  fi
+  while true; do
+    cat conftest.in conftest.in >conftest.tmp
+    mv conftest.tmp conftest.in
+    cp conftest.in conftest.nl
+    echo >>conftest.nl
+    $lt_ac_sed -e 's/a$//' < conftest.nl >conftest.out || break
+    cmp -s conftest.out conftest.nl || break
+    # 10000 chars as input seems more than enough
+    test $lt_ac_count -gt 10 && break
+    lt_ac_count=`expr $lt_ac_count + 1`
+    if test $lt_ac_count -gt $lt_ac_max; then
+      lt_ac_max=$lt_ac_count
+      lt_cv_path_SED=$lt_ac_sed
+    fi
+  done
+done
+
+fi
+
+SED=$lt_cv_path_SED
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $SED" >&5
+$as_echo "$SED" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for grep that handles long lines and -e" >&5
+$as_echo_n "checking for grep that handles long lines and -e... " >&6; }
+if test "${ac_cv_path_GREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$GREP"; then
+  ac_path_GREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in grep ggrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_GREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_GREP" && $as_test_x "$ac_path_GREP"; } || continue
+# Check for GNU ac_path_GREP and select it if it is found.
+  # Check for GNU $ac_path_GREP
+case `"$ac_path_GREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_GREP="$ac_path_GREP" ac_path_GREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'GREP' >> "conftest.nl"
+    "$ac_path_GREP" -e 'GREP$' -e '-(cannot match)-' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_GREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_GREP="$ac_path_GREP"
+      ac_path_GREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_GREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_GREP"; then
+    as_fn_error "no acceptable grep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_GREP=$GREP
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_GREP" >&5
+$as_echo "$ac_cv_path_GREP" >&6; }
+ GREP="$ac_cv_path_GREP"
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for egrep" >&5
+$as_echo_n "checking for egrep... " >&6; }
+if test "${ac_cv_path_EGREP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if echo a | $GREP -E '(a|b)' >/dev/null 2>&1
+   then ac_cv_path_EGREP="$GREP -E"
+   else
+     if test -z "$EGREP"; then
+  ac_path_EGREP_found=false
+  # Loop through the user's path and test for each of PROGNAME-LIST
+  as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH$PATH_SEPARATOR/usr/xpg4/bin
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_prog in egrep; do
+    for ac_exec_ext in '' $ac_executable_extensions; do
+      ac_path_EGREP="$as_dir/$ac_prog$ac_exec_ext"
+      { test -f "$ac_path_EGREP" && $as_test_x "$ac_path_EGREP"; } || continue
+# Check for GNU ac_path_EGREP and select it if it is found.
+  # Check for GNU $ac_path_EGREP
+case `"$ac_path_EGREP" --version 2>&1` in
+*GNU*)
+  ac_cv_path_EGREP="$ac_path_EGREP" ac_path_EGREP_found=:;;
+*)
+  ac_count=0
+  $as_echo_n 0123456789 >"conftest.in"
+  while :
+  do
+    cat "conftest.in" "conftest.in" >"conftest.tmp"
+    mv "conftest.tmp" "conftest.in"
+    cp "conftest.in" "conftest.nl"
+    $as_echo 'EGREP' >> "conftest.nl"
+    "$ac_path_EGREP" 'EGREP$' < "conftest.nl" >"conftest.out" 2>/dev/null || break
+    diff "conftest.out" "conftest.nl" >/dev/null 2>&1 || break
+    as_fn_arith $ac_count + 1 && ac_count=$as_val
+    if test $ac_count -gt ${ac_path_EGREP_max-0}; then
+      # Best one so far, save it but keep looking for a better one
+      ac_cv_path_EGREP="$ac_path_EGREP"
+      ac_path_EGREP_max=$ac_count
+    fi
+    # 10*(2^10) chars as input seems more than enough
+    test $ac_count -gt 10 && break
+  done
+  rm -f conftest.in conftest.tmp conftest.nl conftest.out;;
+esac
+
+      $ac_path_EGREP_found && break 3
+    done
+  done
+  done
+IFS=$as_save_IFS
+  if test -z "$ac_cv_path_EGREP"; then
+    as_fn_error "no acceptable egrep could be found in $PATH$PATH_SEPARATOR/usr/xpg4/bin" "$LINENO" 5
+  fi
+else
+  ac_cv_path_EGREP=$EGREP
+fi
+
+   fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_path_EGREP" >&5
+$as_echo "$ac_cv_path_EGREP" >&6; }
+ EGREP="$ac_cv_path_EGREP"
+
+
+
+# Check whether --with-gnu-ld was given.
+if test "${with_gnu_ld+set}" = set; then :
+  withval=$with_gnu_ld; test "$withval" = no || with_gnu_ld=yes
+else
+  with_gnu_ld=no
+fi
+
+ac_prog=ld
+if test "$GCC" = yes; then
+  # Check if gcc -print-prog-name=ld gives a path.
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ld used by $CC" >&5
+$as_echo_n "checking for ld used by $CC... " >&6; }
+  case $host in
+  *-*-mingw*)
+    # gcc leaves a trailing carriage return which upsets mingw
+    ac_prog=`($CC -print-prog-name=ld) 2>&5 | tr -d '\015'` ;;
+  *)
+    ac_prog=`($CC -print-prog-name=ld) 2>&5` ;;
+  esac
+  case $ac_prog in
+    # Accept absolute paths.
+    [\\/]* | ?:[\\/]*)
+      re_direlt='/[^/][^/]*/\.\./'
+      # Canonicalize the pathname of ld
+      ac_prog=`echo $ac_prog| $SED 's%\\\\%/%g'`
+      while echo $ac_prog | grep "$re_direlt" > /dev/null 2>&1; do
+       ac_prog=`echo $ac_prog| $SED "s%$re_direlt%/%"`
+      done
+      test -z "$LD" && LD="$ac_prog"
+      ;;
+  "")
+    # If it fails, then pretend we aren't using GCC.
+    ac_prog=ld
+    ;;
+  *)
+    # If it is relative, then search for the first ld in PATH.
+    with_gnu_ld=unknown
+    ;;
+  esac
+elif test "$with_gnu_ld" = yes; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for GNU ld" >&5
+$as_echo_n "checking for GNU ld... " >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for non-GNU ld" >&5
+$as_echo_n "checking for non-GNU ld... " >&6; }
+fi
+if test "${lt_cv_path_LD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -z "$LD"; then
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f "$ac_dir/$ac_prog" || test -f "$ac_dir/$ac_prog$ac_exeext"; then
+      lt_cv_path_LD="$ac_dir/$ac_prog"
+      # Check to see if the program is GNU ld.  I'd rather use --version,
+      # but apparently some variants of GNU ld only accept -v.
+      # Break only if it was the GNU/non-GNU ld that we prefer.
+      case `"$lt_cv_path_LD" -v 2>&1 </dev/null` in
+      *GNU* | *'with BFD'*)
+       test "$with_gnu_ld" != no && break
+       ;;
+      *)
+       test "$with_gnu_ld" != yes && break
+       ;;
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+else
+  lt_cv_path_LD="$LD" # Let the user override the test with a path.
+fi
+fi
+
+LD="$lt_cv_path_LD"
+if test -n "$LD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $LD" >&5
+$as_echo "$LD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+test -z "$LD" && as_fn_error "no acceptable ld found in \$PATH" "$LINENO" 5
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if the linker ($LD) is GNU ld" >&5
+$as_echo_n "checking if the linker ($LD) is GNU ld... " >&6; }
+if test "${lt_cv_prog_gnu_ld+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  # I'd rather use --version here, but apparently some GNU lds only accept -v.
+case `$LD -v 2>&1 </dev/null` in
+*GNU* | *'with BFD'*)
+  lt_cv_prog_gnu_ld=yes
+  ;;
+*)
+  lt_cv_prog_gnu_ld=no
+  ;;
+esac
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_gnu_ld" >&5
+$as_echo "$lt_cv_prog_gnu_ld" >&6; }
+with_gnu_ld=$lt_cv_prog_gnu_ld
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $LD option to reload object files" >&5
+$as_echo_n "checking for $LD option to reload object files... " >&6; }
+if test "${lt_cv_ld_reload_flag+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_ld_reload_flag='-r'
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_ld_reload_flag" >&5
+$as_echo "$lt_cv_ld_reload_flag" >&6; }
+reload_flag=$lt_cv_ld_reload_flag
+case $reload_flag in
+"" | " "*) ;;
+*) reload_flag=" $reload_flag" ;;
+esac
+reload_cmds='$LD$reload_flag -o $output$reload_objs'
+case $host_os in
+  darwin*)
+    if test "$GCC" = yes; then
+      reload_cmds='$CC -nostdlib ${wl}-r -o $output$reload_objs'
+    else
+      reload_cmds='$LD$reload_flag -o $output$reload_objs'
+    fi
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for BSD-compatible nm" >&5
+$as_echo_n "checking for BSD-compatible nm... " >&6; }
+if test "${lt_cv_path_NM+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$NM"; then
+  # Let the user override the test.
+  lt_cv_path_NM="$NM"
+else
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  for ac_dir in $PATH /usr/ccs/bin /usr/ucb /bin; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    tmp_nm="$ac_dir/${ac_tool_prefix}nm"
+    if test -f "$tmp_nm" || test -f "$tmp_nm$ac_exeext" ; then
+      # Check to see if the nm accepts a BSD-compat flag.
+      # Adding the `sed 1q' prevents false positives on HP-UX, which says:
+      #   nm: unknown option "B" ignored
+      # Tru64's nm complains that /dev/null is an invalid object file
+      case `"$tmp_nm" -B /dev/null 2>&1 | sed '1q'` in
+      */dev/null* | *'Invalid file or object type'*)
+       lt_cv_path_NM="$tmp_nm -B"
+       break
+        ;;
+      *)
+       case `"$tmp_nm" -p /dev/null 2>&1 | sed '1q'` in
+       */dev/null*)
+         lt_cv_path_NM="$tmp_nm -p"
+         break
+         ;;
+       *)
+         lt_cv_path_NM=${lt_cv_path_NM="$tmp_nm"} # keep the first match, but
+         continue # so that we can try to find one that supports BSD flags
+         ;;
+       esac
+      esac
+    fi
+  done
+  IFS="$lt_save_ifs"
+  test -z "$lt_cv_path_NM" && lt_cv_path_NM=nm
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_path_NM" >&5
+$as_echo "$lt_cv_path_NM" >&6; }
+NM="$lt_cv_path_NM"
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether ln -s works" >&5
+$as_echo_n "checking whether ln -s works... " >&6; }
+LN_S=$as_ln_s
+if test "$LN_S" = "ln -s"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no, using $LN_S" >&5
+$as_echo "no, using $LN_S" >&6; }
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to recognise dependent libraries" >&5
+$as_echo_n "checking how to recognise dependent libraries... " >&6; }
+if test "${lt_cv_deplibs_check_method+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_file_magic_cmd='$MAGIC_CMD'
+lt_cv_file_magic_test_file=
+lt_cv_deplibs_check_method='unknown'
+# Need to set the preceding variable on all platforms that support
+# interlibrary dependencies.
+# 'none' -- dependencies not supported.
+# `unknown' -- same as none, but documents that we really don't know.
+# 'pass_all' -- all dependencies passed with no checks.
+# 'test_compile' -- check by making test program.
+# 'file_magic [[regex]]' -- check by looking for files in library path
+# which responds to the $file_magic_cmd with a given extended regex.
+# If you have `file' or equivalent on your system and you're not sure
+# whether `pass_all' will *always* work, you probably want this one.
+
+case $host_os in
+aix4* | aix5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+beos*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+bsdi[45]*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib)'
+  lt_cv_file_magic_cmd='/usr/bin/file -L'
+  lt_cv_file_magic_test_file=/shlib/libc.so
+  ;;
+
+cygwin*)
+  # func_win32_libid is a shell function defined in ltmain.sh
+  lt_cv_deplibs_check_method='file_magic ^x86 archive import|^x86 DLL'
+  lt_cv_file_magic_cmd='func_win32_libid'
+  ;;
+
+mingw* | pw32*)
+  # Base MSYS/MinGW do not provide the 'file' command needed by
+  # func_win32_libid shell function, so use a weaker test based on 'objdump'.
+  lt_cv_deplibs_check_method='file_magic file format pei*-i386(.*architecture: i386)?'
+  lt_cv_file_magic_cmd='$OBJDUMP -f'
+  ;;
+
+darwin* | rhapsody*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+freebsd* | kfreebsd*-gnu | dragonfly*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    case $host_cpu in
+    i*86 )
+      # Not sure whether the presence of OpenBSD here was a mistake.
+      # Let's accept both of them until this is cleared up.
+      lt_cv_deplibs_check_method='file_magic (FreeBSD|OpenBSD|DragonFly)/i[3-9]86 (compact )?demand paged shared library'
+      lt_cv_file_magic_cmd=/usr/bin/file
+      lt_cv_file_magic_test_file=`echo /usr/lib/libc.so.*`
+      ;;
+    esac
+  else
+    lt_cv_deplibs_check_method=pass_all
+  fi
+  ;;
+
+gnu*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+hpux10.20* | hpux11*)
+  lt_cv_file_magic_cmd=/usr/bin/file
+  case $host_cpu in
+  ia64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - IA64'
+    lt_cv_file_magic_test_file=/usr/lib/hpux32/libc.so
+    ;;
+  hppa*64*)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|ELF-[0-9][0-9]) shared object file - PA-RISC [0-9].[0-9]'
+    lt_cv_file_magic_test_file=/usr/lib/pa20_64/libc.sl
+    ;;
+  *)
+    lt_cv_deplibs_check_method='file_magic (s[0-9][0-9][0-9]|PA-RISC[0-9].[0-9]) shared library'
+    lt_cv_file_magic_test_file=/usr/lib/libc.sl
+    ;;
+  esac
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $LD in
+  *-32|*"-32 ") libmagic=32-bit;;
+  *-n32|*"-n32 ") libmagic=N32;;
+  *-64|*"-64 ") libmagic=64-bit;;
+  *) libmagic=never-match;;
+  esac
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+netbsd*)
+  if echo __ELF__ | $CC -E - | grep __ELF__ > /dev/null; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so|_pic\.a)$'
+  fi
+  ;;
+
+newos6*)
+  lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (executable|dynamic lib)'
+  lt_cv_file_magic_cmd=/usr/bin/file
+  lt_cv_file_magic_test_file=/usr/lib/libnls.so
+  ;;
+
+nto-qnx*)
+  lt_cv_deplibs_check_method=unknown
+  ;;
+
+openbsd*)
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|\.so|_pic\.a)$'
+  else
+    lt_cv_deplibs_check_method='match_pattern /lib[^/]+(\.so\.[0-9]+\.[0-9]+|_pic\.a)$'
+  fi
+  ;;
+
+osf3* | osf4* | osf5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sco3.2v5*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+solaris*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  case $host_vendor in
+  motorola)
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [ML]SB (shared object|dynamic lib) M[0-9][0-9]* Version [0-9]'
+    lt_cv_file_magic_test_file=`echo /usr/lib/libc.so*`
+    ;;
+  ncr)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  sequent)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method='file_magic ELF [0-9][0-9]*-bit [LM]SB (shared object|dynamic lib )'
+    ;;
+  sni)
+    lt_cv_file_magic_cmd='/bin/file'
+    lt_cv_deplibs_check_method="file_magic ELF [0-9][0-9]*-bit [LM]SB dynamic lib"
+    lt_cv_file_magic_test_file=/lib/libc.so
+    ;;
+  siemens)
+    lt_cv_deplibs_check_method=pass_all
+    ;;
+  esac
+  ;;
+
+sysv5OpenUNIX8* | sysv5UnixWare7* | sysv5uw[78]* | unixware7* | sysv4*uw2*)
+  lt_cv_deplibs_check_method=pass_all
+  ;;
+esac
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_deplibs_check_method" >&5
+$as_echo "$lt_cv_deplibs_check_method" >&6; }
+file_magic_cmd=$lt_cv_file_magic_cmd
+deplibs_check_method=$lt_cv_deplibs_check_method
+test -z "$deplibs_check_method" && deplibs_check_method=unknown
+
+
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+  enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+# Some flags need to be propagated to the compiler or linker for good
+# libtool support.
+case $host in
+ia64-*-hpux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *ELF-32*)
+      HPUX_IA64_MODE="32"
+      ;;
+    *ELF-64*)
+      HPUX_IA64_MODE="64"
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+*-*-irix6*)
+  # Find out which ABI we are using.
+  echo '#line 4774 "configure"' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+   if test "$lt_cv_prog_gnu_ld" = yes; then
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -melf32bsmip"
+      ;;
+    *N32*)
+      LD="${LD-ld} -melf32bmipn32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -melf64bmip"
+      ;;
+    esac
+   else
+    case `/usr/bin/file conftest.$ac_objext` in
+    *32-bit*)
+      LD="${LD-ld} -32"
+      ;;
+    *N32*)
+      LD="${LD-ld} -n32"
+      ;;
+    *64-bit*)
+      LD="${LD-ld} -64"
+      ;;
+    esac
+   fi
+  fi
+  rm -rf conftest*
+  ;;
+
+x86_64-*linux*|ppc*-*linux*|powerpc*-*linux*|s390*-*linux*|sparc*-*linux*)
+  # Find out which ABI we are using.
+  echo 'int i;' > conftest.$ac_ext
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    case `/usr/bin/file conftest.o` in
+    *32-bit*)
+      case $host in
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_i386"
+          ;;
+        ppc64-*linux*|powerpc64-*linux*)
+          LD="${LD-ld} -m elf32ppclinux"
+          ;;
+        s390x-*linux*)
+          LD="${LD-ld} -m elf_s390"
+          ;;
+        sparc64-*linux*)
+          LD="${LD-ld} -m elf32_sparc"
+          ;;
+      esac
+      ;;
+    *64-bit*)
+      case $host in
+        x86_64-*linux*)
+          LD="${LD-ld} -m elf_x86_64"
+          ;;
+        ppc*-*linux*|powerpc*-*linux*)
+          LD="${LD-ld} -m elf64ppc"
+          ;;
+        s390*-*linux*)
+          LD="${LD-ld} -m elf64_s390"
+          ;;
+        sparc*-*linux*)
+          LD="${LD-ld} -m elf64_sparc"
+          ;;
+      esac
+      ;;
+    esac
+  fi
+  rm -rf conftest*
+  ;;
+
+*-*-sco3.2v5*)
+  # On SCO OpenServer 5, we need -belf to get full-featured binaries.
+  SAVE_CFLAGS="$CFLAGS"
+  CFLAGS="$CFLAGS -belf"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the C compiler needs -belf" >&5
+$as_echo_n "checking whether the C compiler needs -belf... " >&6; }
+if test "${lt_cv_cc_needs_belf+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+     cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  lt_cv_cc_needs_belf=yes
+else
+  lt_cv_cc_needs_belf=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+     ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_cc_needs_belf" >&5
+$as_echo "$lt_cv_cc_needs_belf" >&6; }
+  if test x"$lt_cv_cc_needs_belf" != x"yes"; then
+    # this is probably gcc 2.8.0, egcs 1.0 or newer; no need for -belf
+    CFLAGS="$SAVE_CFLAGS"
+  fi
+  ;;
+
+esac
+
+need_locks="$enable_libtool_lock"
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to run the C preprocessor" >&5
+$as_echo_n "checking how to run the C preprocessor... " >&6; }
+# On Suns, sometimes $CPP names a directory.
+if test -n "$CPP" && test -d "$CPP"; then
+  CPP=
+fi
+if test -z "$CPP"; then
+  if test "${ac_cv_prog_CPP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+      # Double quotes because CPP needs to be expanded
+    for CPP in "$CC -E" "$CC -E -traditional-cpp" "/lib/cpp"
+    do
+      ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+  break
+fi
+
+    done
+    ac_cv_prog_CPP=$CPP
+
+fi
+  CPP=$ac_cv_prog_CPP
+else
+  ac_cv_prog_CPP=$CPP
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $CPP" >&5
+$as_echo "$CPP" >&6; }
+ac_preproc_ok=false
+for ac_c_preproc_warn_flag in '' yes
+do
+  # Use a header file that comes with gcc, so configuring glibc
+  # with a fresh cross-compiler works.
+  # Prefer <limits.h> to <assert.h> if __STDC__ is defined, since
+  # <limits.h> exists even on freestanding compilers.
+  # On the NeXT, cc -E runs the code through the compiler's parser,
+  # not just through cpp. "Syntax error" is here to catch this case.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifdef __STDC__
+# include <limits.h>
+#else
+# include <assert.h>
+#endif
+                    Syntax error
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+
+else
+  # Broken: fails on valid input.
+continue
+fi
+rm -f conftest.err conftest.$ac_ext
+
+  # OK, works on sane cases.  Now check whether nonexistent headers
+  # can be detected and how.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ac_nonexistent.h>
+_ACEOF
+if ac_fn_c_try_cpp "$LINENO"; then :
+  # Broken: success on invalid input.
+continue
+else
+  # Passes both tests.
+ac_preproc_ok=:
+break
+fi
+rm -f conftest.err conftest.$ac_ext
+
+done
+# Because of `break', _AC_PREPROC_IFELSE's cleaning code was skipped.
+rm -f conftest.err conftest.$ac_ext
+if $ac_preproc_ok; then :
+
+else
+  { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+as_fn_error "C preprocessor \"$CPP\" fails sanity check
+See \`config.log' for more details." "$LINENO" 5; }
+fi
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+# On IRIX 5.3, sys/types and inttypes.h are conflicting.
+for ac_header in sys/types.h sys/stat.h stdlib.h string.h memory.h strings.h \
+                 inttypes.h stdint.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default
+"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+for ac_header in dlfcn.h
+do :
+  ac_fn_c_check_header_mongrel "$LINENO" "dlfcn.h" "ac_cv_header_dlfcn_h" "$ac_includes_default"
+if test "x$ac_cv_header_dlfcn_h" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_DLFCN_H 1
+_ACEOF
+
+fi
+
+done
+
+
+# Autoconf 2.13's AC_OBJEXT and AC_EXEEXT macros only works for C compilers!
+
+# find the maximum length of command line arguments
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking the maximum length of command line arguments" >&5
+$as_echo_n "checking the maximum length of command line arguments... " >&6; }
+if test "${lt_cv_sys_max_cmd_len+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+    i=0
+  teststring="ABCD"
+
+  case $build_os in
+  msdosdjgpp*)
+    # On DJGPP, this test can blow up pretty badly due to problems in libc
+    # (any single argument exceeding 2000 bytes causes a buffer overrun
+    # during glob expansion).  Even if it were fixed, the result of this
+    # check would be larger than it should be.
+    lt_cv_sys_max_cmd_len=12288;    # 12K is about right
+    ;;
+
+  gnu*)
+    # Under GNU Hurd, this test is not required because there is
+    # no limit to the length of command line arguments.
+    # Libtool will interpret -1 as no limit whatsoever
+    lt_cv_sys_max_cmd_len=-1;
+    ;;
+
+  cygwin* | mingw*)
+    # On Win9x/ME, this test blows up -- it succeeds, but takes
+    # about 5 minutes as the teststring grows exponentially.
+    # Worse, since 9x/ME are not pre-emptively multitasking,
+    # you end up with a "frozen" computer, even though with patience
+    # the test eventually succeeds (with a max line length of 256k).
+    # Instead, let's just punt: use the minimum linelength reported by
+    # all of the supported platforms: 8192 (on NT/2K/XP).
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  amigaos*)
+    # On AmigaOS with pdksh, this test takes hours, literally.
+    # So we just punt and use a minimum line length of 8192.
+    lt_cv_sys_max_cmd_len=8192;
+    ;;
+
+  netbsd* | freebsd* | openbsd* | darwin* | dragonfly*)
+    # This has been around since 386BSD, at least.  Likely further.
+    if test -x /sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/sbin/sysctl -n kern.argmax`
+    elif test -x /usr/sbin/sysctl; then
+      lt_cv_sys_max_cmd_len=`/usr/sbin/sysctl -n kern.argmax`
+    else
+      lt_cv_sys_max_cmd_len=65536      # usable default for all BSDs
+    fi
+    # And add a safety zone
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 4`
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \* 3`
+    ;;
+  osf*)
+    # Dr. Hans Ekkehard Plesser reports seeing a kernel panic running configure
+    # due to this test when exec_disable_arg_limit is 1 on Tru64. It is not
+    # nice to cause kernel panics so lets avoid the loop below.
+    # First set a reasonable default.
+    lt_cv_sys_max_cmd_len=16384
+    #
+    if test -x /sbin/sysconfig; then
+      case `/sbin/sysconfig -q proc exec_disable_arg_limit` in
+        *1*) lt_cv_sys_max_cmd_len=-1 ;;
+      esac
+    fi
+    ;;
+  *)
+    # If test is not a shell built-in, we'll probably end up computing a
+    # maximum length that is only half of the actual maximum length, but
+    # we can't tell.
+    SHELL=${SHELL-${CONFIG_SHELL-/bin/sh}}
+    while (test "X"`$SHELL $0 --fallback-echo "X$teststring" 2>/dev/null` \
+              = "XX$teststring") >/dev/null 2>&1 &&
+           new_result=`expr "X$teststring" : ".*" 2>&1` &&
+           lt_cv_sys_max_cmd_len=$new_result &&
+           test $i != 17 # 1/2 MB should be enough
+    do
+      i=`expr $i + 1`
+      teststring=$teststring$teststring
+    done
+    teststring=
+    # Add a significant safety factor because C++ compilers can tack on massive
+    # amounts of additional arguments before passing them to the linker.
+    # It appears as though 1/2 is a usable value.
+    lt_cv_sys_max_cmd_len=`expr $lt_cv_sys_max_cmd_len \/ 2`
+    ;;
+  esac
+
+fi
+
+if test -n $lt_cv_sys_max_cmd_len ; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_sys_max_cmd_len" >&5
+$as_echo "$lt_cv_sys_max_cmd_len" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: none" >&5
+$as_echo "none" >&6; }
+fi
+
+
+
+
+# Check for command to grab the raw symbol name followed by C symbol from nm.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking command to parse $NM output from $compiler object" >&5
+$as_echo_n "checking command to parse $NM output from $compiler object... " >&6; }
+if test "${lt_cv_sys_global_symbol_pipe+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+# These are sane defaults that work on at least a few old systems.
+# [They come from Ultrix.  What could be older than Ultrix?!! ;)]
+
+# Character class describing NM global symbol codes.
+symcode='[BCDEGRST]'
+
+# Regexp to match symbols that can be accessed directly from C.
+sympat='\([_A-Za-z][_A-Za-z0-9]*\)'
+
+# Transform an extracted symbol line into a proper C declaration
+lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^. .* \(.*\)$/extern int \1;/p'"
+
+# Transform an extracted symbol line into symbol name and symbol address
+lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+
+# Define system-specific variables.
+case $host_os in
+aix*)
+  symcode='[BCDT]'
+  ;;
+cygwin* | mingw* | pw32*)
+  symcode='[ABCDGISTW]'
+  ;;
+hpux*) # Its linker distinguishes data from code symbols
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDEGRST]'
+  fi
+  lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+  lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  ;;
+linux*)
+  if test "$host_cpu" = ia64; then
+    symcode='[ABCDGIRSTW]'
+    lt_cv_sys_global_symbol_to_cdecl="sed -n -e 's/^T .* \(.*\)$/extern int \1();/p' -e 's/^$symcode* .* \(.*\)$/extern char \1;/p'"
+    lt_cv_sys_global_symbol_to_c_name_address="sed -n -e 's/^: \([^ ]*\) $/  {\\\"\1\\\", (lt_ptr) 0},/p' -e 's/^$symcode* \([^ ]*\) \([^ ]*\)$/  {\"\2\", (lt_ptr) \&\2},/p'"
+  fi
+  ;;
+irix* | nonstopux*)
+  symcode='[BCDEGRST]'
+  ;;
+osf*)
+  symcode='[BCDEGQRST]'
+  ;;
+solaris* | sysv5*)
+  symcode='[BDRT]'
+  ;;
+sysv4)
+  symcode='[DFNSTU]'
+  ;;
+esac
+
+# Handle CRLF in mingw tool chain
+opt_cr=
+case $build_os in
+mingw*)
+  opt_cr=`echo 'x\{0,1\}' | tr x '\015'` # option cr in regexp
+  ;;
+esac
+
+# If we're using GNU nm, then use its standard symbol codes.
+case `$NM -V 2>&1` in
+*GNU* | *'with BFD'*)
+  symcode='[ABCDGIRSTW]' ;;
+esac
+
+# Try without a prefix undercore, then with it.
+for ac_symprfx in "" "_"; do
+
+  # Transform symcode, sympat, and symprfx into a raw symbol and a C symbol.
+  symxfrm="\\1 $ac_symprfx\\2 \\2"
+
+  # Write the raw and C identifiers.
+  lt_cv_sys_global_symbol_pipe="sed -n -e 's/^.*[      ]\($symcode$symcode*\)[         ][      ]*$ac_symprfx$sympat$opt_cr$/$symxfrm/p'"
+
+  # Check to see that the pipe works correctly.
+  pipe_works=no
+
+  rm -f conftest*
+  cat > conftest.$ac_ext <<EOF
+#ifdef __cplusplus
+extern "C" {
+#endif
+char nm_test_var;
+void nm_test_func(){}
+#ifdef __cplusplus
+}
+#endif
+int main(){nm_test_var='a';nm_test_func();return(0);}
+EOF
+
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }; then
+    # Now try to grab the symbols.
+    nlist=conftest.nm
+    if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist\""; } >&5
+  (eval $NM conftest.$ac_objext \| $lt_cv_sys_global_symbol_pipe \> $nlist) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s "$nlist"; then
+      # Try sorting and uniquifying the output.
+      if sort "$nlist" | uniq > "$nlist"T; then
+       mv -f "$nlist"T "$nlist"
+      else
+       rm -f "$nlist"T
+      fi
+
+      # Make sure that we snagged all the symbols we need.
+      if grep ' nm_test_var$' "$nlist" >/dev/null; then
+       if grep ' nm_test_func$' "$nlist" >/dev/null; then
+         cat <<EOF > conftest.$ac_ext
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+EOF
+         # Now generate the symbol file.
+         eval "$lt_cv_sys_global_symbol_to_cdecl"' < "$nlist" | grep -v main >> conftest.$ac_ext'
+
+         cat <<EOF >> conftest.$ac_ext
+#if defined (__STDC__) && __STDC__
+# define lt_ptr_t void *
+#else
+# define lt_ptr_t char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+const struct {
+  const char *name;
+  lt_ptr_t address;
+}
+lt_preloaded_symbols[] =
+{
+EOF
+         $SED "s/^$symcode$symcode* \(.*\) \(.*\)$/  {\"\2\", (lt_ptr_t) \&\2},/" < "$nlist" | grep -v main >> conftest.$ac_ext
+         cat <<\EOF >> conftest.$ac_ext
+  {0, (lt_ptr_t) 0}
+};
+
+#ifdef __cplusplus
+}
+#endif
+EOF
+         # Now try linking the two files.
+         mv conftest.$ac_objext conftstm.$ac_objext
+         lt_save_LIBS="$LIBS"
+         lt_save_CFLAGS="$CFLAGS"
+         LIBS="conftstm.$ac_objext"
+         CFLAGS="$CFLAGS$lt_prog_compiler_no_builtin_flag"
+         if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext}; then
+           pipe_works=yes
+         fi
+         LIBS="$lt_save_LIBS"
+         CFLAGS="$lt_save_CFLAGS"
+       else
+         echo "cannot find nm_test_func in $nlist" >&5
+       fi
+      else
+       echo "cannot find nm_test_var in $nlist" >&5
+      fi
+    else
+      echo "cannot run $lt_cv_sys_global_symbol_pipe" >&5
+    fi
+  else
+    echo "$progname: failed program was:" >&5
+    cat conftest.$ac_ext >&5
+  fi
+  rm -f conftest* conftst*
+
+  # Do not use the global_symbol_pipe unless it works.
+  if test "$pipe_works" = yes; then
+    break
+  else
+    lt_cv_sys_global_symbol_pipe=
+  fi
+done
+
+fi
+
+if test -z "$lt_cv_sys_global_symbol_pipe"; then
+  lt_cv_sys_global_symbol_to_cdecl=
+fi
+if test -z "$lt_cv_sys_global_symbol_pipe$lt_cv_sys_global_symbol_to_cdecl"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: failed" >&5
+$as_echo "failed" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5
+$as_echo "ok" >&6; }
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for objdir" >&5
+$as_echo_n "checking for objdir... " >&6; }
+if test "${lt_cv_objdir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  rm -f .libs 2>/dev/null
+mkdir .libs 2>/dev/null
+if test -d .libs; then
+  lt_cv_objdir=.libs
+else
+  # MS-DOS does not allow filenames that begin with a dot.
+  lt_cv_objdir=_libs
+fi
+rmdir .libs 2>/dev/null
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_objdir" >&5
+$as_echo "$lt_cv_objdir" >&6; }
+objdir=$lt_cv_objdir
+
+
+
+
+
+case $host_os in
+aix3*)
+  # AIX sometimes has problems with the GCC collect2 program.  For some
+  # reason, if we set the COLLECT_NAMES environment variable, the problems
+  # vanish in a puff of smoke.
+  if test "X${COLLECT_NAMES+set}" != Xset; then
+    COLLECT_NAMES=
+    export COLLECT_NAMES
+  fi
+  ;;
+esac
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='sed -e 1s/^X//'
+sed_quote_subst='s/\([\\"\\`$\\\\]\)/\\\1/g'
+
+# Same as above, but do not quote variable references.
+double_quote_subst='s/\([\\"\\`\\\\]\)/\\\1/g'
+
+# Sed substitution to delay expansion of an escaped shell variable in a
+# double_quote_subst'ed string.
+delay_variable_subst='s/\\\\\\\\\\\$/\\\\\\$/g'
+
+# Sed substitution to avoid accidental globbing in evaled expressions
+no_glob_subst='s/\*/\\\*/g'
+
+# Constants:
+rm="rm -f"
+
+# Global variables:
+default_ofile=libtool
+can_build_shared=yes
+
+# All known linkers require a `.a' archive for static linking (except MSVC,
+# which needs '.lib').
+libext=a
+ltmain="$ac_aux_dir/ltmain.sh"
+ofile="$default_ofile"
+with_gnu_ld="$lt_cv_prog_gnu_ld"
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_AR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$AR"; then
+  ac_cv_prog_AR="$AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_AR="${ac_tool_prefix}ar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+AR=$ac_cv_prog_AR
+if test -n "$AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $AR" >&5
+$as_echo "$AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_AR"; then
+  ac_ct_AR=$AR
+  # Extract the first word of "ar", so it can be a program name with args.
+set dummy ar; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_AR+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_AR"; then
+  ac_cv_prog_ac_ct_AR="$ac_ct_AR" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_AR="ar"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_AR=$ac_cv_prog_ac_ct_AR
+if test -n "$ac_ct_AR"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_AR" >&5
+$as_echo "$ac_ct_AR" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_AR" = x; then
+    AR="false"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    AR=$ac_ct_AR
+  fi
+else
+  AR="$ac_cv_prog_AR"
+fi
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args.
+set dummy ${ac_tool_prefix}ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$RANLIB"; then
+  ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+RANLIB=$ac_cv_prog_RANLIB
+if test -n "$RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $RANLIB" >&5
+$as_echo "$RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_RANLIB"; then
+  ac_ct_RANLIB=$RANLIB
+  # Extract the first word of "ranlib", so it can be a program name with args.
+set dummy ranlib; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_RANLIB+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_RANLIB"; then
+  ac_cv_prog_ac_ct_RANLIB="$ac_ct_RANLIB" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_RANLIB="ranlib"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_RANLIB=$ac_cv_prog_ac_ct_RANLIB
+if test -n "$ac_ct_RANLIB"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_RANLIB" >&5
+$as_echo "$ac_ct_RANLIB" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_RANLIB" = x; then
+    RANLIB=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    RANLIB=$ac_ct_RANLIB
+  fi
+else
+  RANLIB="$ac_cv_prog_RANLIB"
+fi
+
+if test -n "$ac_tool_prefix"; then
+  # Extract the first word of "${ac_tool_prefix}strip", so it can be a program name with args.
+set dummy ${ac_tool_prefix}strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$STRIP"; then
+  ac_cv_prog_STRIP="$STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_STRIP="${ac_tool_prefix}strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+STRIP=$ac_cv_prog_STRIP
+if test -n "$STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $STRIP" >&5
+$as_echo "$STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+
+fi
+if test -z "$ac_cv_prog_STRIP"; then
+  ac_ct_STRIP=$STRIP
+  # Extract the first word of "strip", so it can be a program name with args.
+set dummy strip; ac_word=$2
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5
+$as_echo_n "checking for $ac_word... " >&6; }
+if test "${ac_cv_prog_ac_ct_STRIP+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if test -n "$ac_ct_STRIP"; then
+  ac_cv_prog_ac_ct_STRIP="$ac_ct_STRIP" # Let the user override the test.
+else
+as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    for ac_exec_ext in '' $ac_executable_extensions; do
+  if { test -f "$as_dir/$ac_word$ac_exec_ext" && $as_test_x "$as_dir/$ac_word$ac_exec_ext"; }; then
+    ac_cv_prog_ac_ct_STRIP="strip"
+    $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5
+    break 2
+  fi
+done
+  done
+IFS=$as_save_IFS
+
+fi
+fi
+ac_ct_STRIP=$ac_cv_prog_ac_ct_STRIP
+if test -n "$ac_ct_STRIP"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_ct_STRIP" >&5
+$as_echo "$ac_ct_STRIP" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  if test "x$ac_ct_STRIP" = x; then
+    STRIP=":"
+  else
+    case $cross_compiling:$ac_tool_warned in
+yes:)
+{ $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using cross tools not prefixed with host triplet" >&5
+$as_echo "$as_me: WARNING: using cross tools not prefixed with host triplet" >&2;}
+ac_tool_warned=yes ;;
+esac
+    STRIP=$ac_ct_STRIP
+  fi
+else
+  STRIP="$ac_cv_prog_STRIP"
+fi
+
+
+old_CC="$CC"
+old_CFLAGS="$CFLAGS"
+
+# Set sane defaults for various variables
+test -z "$AR" && AR=ar
+test -z "$AR_FLAGS" && AR_FLAGS=cru
+test -z "$AS" && AS=as
+test -z "$CC" && CC=cc
+test -z "$LTCC" && LTCC=$CC
+test -z "$DLLTOOL" && DLLTOOL=dlltool
+test -z "$LD" && LD=ld
+test -z "$LN_S" && LN_S="ln -s"
+test -z "$MAGIC_CMD" && MAGIC_CMD=file
+test -z "$NM" && NM=nm
+test -z "$SED" && SED=sed
+test -z "$OBJDUMP" && OBJDUMP=objdump
+test -z "$RANLIB" && RANLIB=:
+test -z "$STRIP" && STRIP=:
+test -z "$ac_objext" && ac_objext=o
+
+# Determine commands to create old-style static archives.
+old_archive_cmds='$AR $AR_FLAGS $oldlib$oldobjs$old_deplibs'
+old_postinstall_cmds='chmod 644 $oldlib'
+old_postuninstall_cmds=
+
+if test -n "$RANLIB"; then
+  case $host_os in
+  openbsd*)
+    old_postinstall_cmds="\$RANLIB -t \$oldlib~$old_postinstall_cmds"
+    ;;
+  *)
+    old_postinstall_cmds="\$RANLIB \$oldlib~$old_postinstall_cmds"
+    ;;
+  esac
+  old_archive_cmds="$old_archive_cmds~\$RANLIB \$oldlib"
+fi
+
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# Only perform the check for file, if the check method requires it
+case $deplibs_check_method in
+file_magic*)
+  if test "$file_magic_cmd" = '$MAGIC_CMD'; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ${ac_tool_prefix}file" >&5
+$as_echo_n "checking for ${ac_tool_prefix}file... " >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/${ac_tool_prefix}file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/${ac_tool_prefix}file"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+if test -z "$lt_cv_path_MAGIC_CMD"; then
+  if test -n "$ac_tool_prefix"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for file" >&5
+$as_echo_n "checking for file... " >&6; }
+if test "${lt_cv_path_MAGIC_CMD+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  case $MAGIC_CMD in
+[\\/*] |  ?:[\\/]*)
+  lt_cv_path_MAGIC_CMD="$MAGIC_CMD" # Let the user override the test with a path.
+  ;;
+*)
+  lt_save_MAGIC_CMD="$MAGIC_CMD"
+  lt_save_ifs="$IFS"; IFS=$PATH_SEPARATOR
+  ac_dummy="/usr/bin$PATH_SEPARATOR$PATH"
+  for ac_dir in $ac_dummy; do
+    IFS="$lt_save_ifs"
+    test -z "$ac_dir" && ac_dir=.
+    if test -f $ac_dir/file; then
+      lt_cv_path_MAGIC_CMD="$ac_dir/file"
+      if test -n "$file_magic_test_file"; then
+       case $deplibs_check_method in
+       "file_magic "*)
+         file_magic_regex=`expr "$deplibs_check_method" : "file_magic \(.*\)"`
+         MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+         if eval $file_magic_cmd \$file_magic_test_file 2> /dev/null |
+           $EGREP "$file_magic_regex" > /dev/null; then
+           :
+         else
+           cat <<EOF 1>&2
+
+*** Warning: the command libtool uses to detect shared libraries,
+*** $file_magic_cmd, produces output that libtool cannot recognize.
+*** The result is that libtool may fail to recognize shared libraries
+*** as such.  This will affect the creation of libtool libraries that
+*** depend on shared libraries, but programs linked with such libtool
+*** libraries will work regardless of this problem.  Nevertheless, you
+*** may want to report the problem to your system manager and/or to
+*** bug-libtool@gnu.org
+
+EOF
+         fi ;;
+       esac
+      fi
+      break
+    fi
+  done
+  IFS="$lt_save_ifs"
+  MAGIC_CMD="$lt_save_MAGIC_CMD"
+  ;;
+esac
+fi
+
+MAGIC_CMD="$lt_cv_path_MAGIC_CMD"
+if test -n "$MAGIC_CMD"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $MAGIC_CMD" >&5
+$as_echo "$MAGIC_CMD" >&6; }
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+
+  else
+    MAGIC_CMD=:
+  fi
+fi
+
+  fi
+  ;;
+esac
+
+enable_dlopen=no
+enable_win32_dll=no
+
+# Check whether --enable-libtool-lock was given.
+if test "${enable_libtool_lock+set}" = set; then :
+  enableval=$enable_libtool_lock;
+fi
+
+test "x$enable_libtool_lock" != xno && enable_libtool_lock=yes
+
+
+# Check whether --with-pic was given.
+if test "${with_pic+set}" = set; then :
+  withval=$with_pic; pic_mode="$withval"
+else
+  pic_mode=default
+fi
+
+test -z "$pic_mode" && pic_mode=default
+
+# Use C for the default configuration in the libtool script
+tagname=
+lt_save_CC="$CC"
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+
+# Source file extension for C test sources.
+ac_ext=c
+
+# Object file extension for compiled C test sources.
+objext=o
+objext=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="int some_variable = 0;\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='int main(){return(0);}\n'
+
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm conftest*
+
+
+#
+# Check for any special shared library compilation flags.
+#
+lt_prog_cc_shlib=
+if test "$GCC" = no; then
+  case $host_os in
+  sco3.2v5*)
+    lt_prog_cc_shlib='-belf'
+    ;;
+  esac
+fi
+if test -n "$lt_prog_cc_shlib"; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&5
+$as_echo "$as_me: WARNING: \`$CC' requires \`$lt_prog_cc_shlib' to build shared libraries" >&2;}
+  if echo "$old_CC $old_CFLAGS " | grep "[     ]$lt_prog_cc_shlib[     ]" >/dev/null; then :
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&5
+$as_echo "$as_me: WARNING: add \`$lt_prog_cc_shlib' to the CC or CFLAGS env variable and reconfigure" >&2;}
+    lt_cv_prog_cc_can_build_shared=no
+  fi
+fi
+
+
+#
+# Check to make sure the static flag actually works.
+#
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler static flag $lt_prog_compiler_static works" >&5
+$as_echo_n "checking if $compiler static flag $lt_prog_compiler_static works... " >&6; }
+if test "${lt_prog_compiler_static_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_prog_compiler_static_works=no
+   save_LDFLAGS="$LDFLAGS"
+   LDFLAGS="$LDFLAGS $lt_prog_compiler_static"
+   printf "$lt_simple_link_test_code" > conftest.$ac_ext
+   if (eval $ac_link 2>conftest.err) && test -s conftest$ac_exeext; then
+     # The linker can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     if test -s conftest.err; then
+       # Append any errors to the config.log.
+       cat conftest.err 1>&5
+       $echo "X$_lt_linker_boilerplate" | $Xsed > conftest.exp
+       $SED '/^$/d' conftest.err >conftest.er2
+       if diff conftest.exp conftest.er2 >/dev/null; then
+         lt_prog_compiler_static_works=yes
+       fi
+     else
+       lt_prog_compiler_static_works=yes
+     fi
+   fi
+   $rm conftest*
+   LDFLAGS="$save_LDFLAGS"
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_static_works" >&5
+$as_echo "$lt_prog_compiler_static_works" >&6; }
+
+if test x"$lt_prog_compiler_static_works" = xyes; then
+    :
+else
+    lt_prog_compiler_static=
+fi
+
+
+
+
+lt_prog_compiler_no_builtin_flag=
+
+if test "$GCC" = yes; then
+  lt_prog_compiler_no_builtin_flag=' -fno-builtin'
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+  ac_outfile=conftest.$ac_objext
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:6177: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:6181: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag="$lt_prog_compiler_no_builtin_flag -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+lt_prog_compiler_wl=
+lt_prog_compiler_pic=
+lt_prog_compiler_static=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl='-Wl,'
+    lt_prog_compiler_static='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      lt_prog_compiler_pic='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic='-fno-common'
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       lt_prog_compiler_pic=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic='-fPIC'
+       ;;
+      esac
+      ;;
+
+    *)
+      lt_prog_compiler_pic='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl='-Wl,'
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static='-Bstatic'
+      else
+       lt_prog_compiler_static='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         lt_prog_compiler_pic='-qnocommon'
+         lt_prog_compiler_wl='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic='+Z'
+       ;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    linux*)
+      case $cc_basename in
+      icc* | ecc*)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-KPIC'
+       lt_prog_compiler_static='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+       # which looks to be a dead project)
+       lt_prog_compiler_wl='-Wl,'
+       lt_prog_compiler_pic='-fpic'
+       lt_prog_compiler_static='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static='-non_shared'
+        ;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static='-non_shared'
+      ;;
+
+    sco3.2v5*)
+      lt_prog_compiler_pic='-Kpic'
+      lt_prog_compiler_static='-dn'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+       lt_prog_compiler_wl='-Qoption ld ';;
+      *)
+       lt_prog_compiler_wl='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl='-Qoption ld '
+      lt_prog_compiler_pic='-PIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_pic='-KPIC'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+       lt_prog_compiler_pic='-Kconform_pic'
+       lt_prog_compiler_static='-Bstatic'
+      fi
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl='-Wl,'
+      lt_prog_compiler_can_build_shared=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic='-pic'
+      lt_prog_compiler_static='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared=no
+      ;;
+    esac
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic" >&5
+$as_echo "$lt_prog_compiler_pic" >&6; }
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic"; then
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic works... " >&6; }
+if test "${lt_prog_compiler_pic_works+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_prog_compiler_pic_works=no
+  ac_outfile=conftest.$ac_objext
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic -DPIC"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:6439: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:6443: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_prog_compiler_pic_works=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_works" >&5
+$as_echo "$lt_prog_compiler_pic_works" >&6; }
+
+if test x"$lt_prog_compiler_pic_works" = xyes; then
+    case $lt_prog_compiler_pic in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic=" $lt_prog_compiler_pic" ;;
+     esac
+else
+    lt_prog_compiler_pic=
+     lt_prog_compiler_can_build_shared=no
+fi
+
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic=
+    ;;
+  *)
+    lt_prog_compiler_pic="$lt_prog_compiler_pic -DPIC"
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:6501: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:6505: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
+     $SED '/^$/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o" >&5
+$as_echo "$lt_cv_prog_compiler_c_o" >&6; }
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  runpath_var=
+  allow_undefined_flag=
+  enable_shared_with_static_runtimes=no
+  archive_cmds=
+  archive_expsym_cmds=
+  old_archive_From_new_cmds=
+  old_archive_from_expsyms_cmds=
+  export_dynamic_flag_spec=
+  whole_archive_flag_spec=
+  thread_safe_flag_spec=
+  hardcode_libdir_flag_spec=
+  hardcode_libdir_flag_spec_ld=
+  hardcode_libdir_separator=
+  hardcode_direct=no
+  hardcode_minus_L=no
+  hardcode_shlibpath_var=unsupported
+  link_all_deplibs=unknown
+  hardcode_automatic=no
+  module_cmds=
+  module_expsym_cmds=
+  always_export_symbols=no
+  export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms="_GLOBAL_OFFSET_TABLE_"
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+       whole_archive_flag_spec="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+       whole_archive_flag_spec=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix3* | aix4* | aix5*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+       ld_shlibs=no
+       cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+
+      # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+      # that the semantics of dynamic libraries on AmigaOS, at least up
+      # to version 4, is to share data among multiple programs linked
+      # with the same dynamic library.  Since this doesn't match the
+      # behavior of shared libraries on other platforms, we can't use
+      # them.
+      ld_shlibs=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       allow_undefined_flag=unsupported
+       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+       # support --undefined.  This deserves some investigation.  FIXME
+       archive_cmds='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec='-L$libdir'
+      allow_undefined_flag=unsupported
+      always_export_symbols=no
+      enable_shared_with_static_runtimes=yes
+      export_symbols_cmds='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+       # If the export-symbols file already is a .def file (1st line
+       # is EXPORTS), use it as is; otherwise, prepend...
+       archive_expsym_cmds='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+         cp $export_symbols $output_objdir/$soname.def;
+       else
+         echo EXPORTS > $output_objdir/$soname.def;
+         cat $export_symbols >> $output_objdir/$soname.def;
+       fi~
+       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    linux*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       tmp_addflag=
+       case $cc_basename,$host_cpu in
+       pgcc*)                          # Portland Group C compiler
+         whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag'
+         ;;
+       pgf77* | pgf90* | pgf95*)       # Portland Group f77 and f90 compilers
+         whole_archive_flag_spec='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag -Mnomain' ;;
+       ecc*,ia64* | icc*,ia64*)                # Intel C compiler on ia64
+         tmp_addflag=' -i_dynamic' ;;
+       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
+         tmp_addflag=' -i_dynamic -nofor_main' ;;
+       ifc* | ifort*)                  # Intel Fortran compiler
+         tmp_addflag=' -nofor_main' ;;
+       esac
+       archive_cmds='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+       if test $supports_anon_versioning = yes; then
+         archive_expsym_cmds='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+         $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+       fi
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       archive_cmds='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+       wlarc=
+      else
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris* | sysv5*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+       ld_shlibs=no
+       cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+
+    sunos4*)
+      archive_cmds='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec=
+      export_dynamic_flag_spec=
+      whole_archive_flag_spec=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag=unsupported
+      always_export_symbols=yes
+      archive_expsym_cmds='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L=yes
+      if test "$GCC" = yes && test -z "$link_static_flag"; then
+       # Neither direct hardcoding nor static linking is supported with a
+       # broken collect2.
+       hardcode_direct=unsupported
+      fi
+      ;;
+
+    aix4* | aix5*)
+      if test "$host_cpu" = ia64; then
+       # On IA64, the linker does run time linking by default, so we don't
+       # have to do anything special.
+       aix_use_runtimelinking=no
+       exp_sym_flag='-Bexport'
+       no_entry_flag=""
+      else
+       # If we're using GNU nm, then we don't want the "-C" option.
+       # -C means demangle to AIX nm, but means don't demangle with GNU nm
+       if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+         export_symbols_cmds='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+       else
+         export_symbols_cmds='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+       fi
+       aix_use_runtimelinking=no
+
+       # Test if we are trying to use run time linking or normal
+       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+       # need to do runtime linking.
+       case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+         for ld_flag in $LDFLAGS; do
+         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+           aix_use_runtimelinking=yes
+           break
+         fi
+         done
+       esac
+
+       exp_sym_flag='-bexport'
+       no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds=''
+      hardcode_direct=yes
+      hardcode_libdir_separator=':'
+      link_all_deplibs=yes
+
+      if test "$GCC" = yes; then
+       case $host_os in aix4.[012]|aix4.[012].*)
+       # We only want to do this on AIX 4.2 and lower, the check
+       # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" && \
+          strings "$collect2name" | grep resolve_lib_name >/dev/null
+         then
+         # We have reworked collect2
+         hardcode_direct=yes
+         else
+         # We have old collect2
+         hardcode_direct=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         hardcode_minus_L=yes
+         hardcode_libdir_flag_spec='-L$libdir'
+         hardcode_libdir_separator=
+         fi
+       esac
+       shared_flag='-shared'
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag="$shared_flag "'${wl}-G'
+       fi
+      else
+       # not using gcc
+       if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+       else
+       if test "$aix_use_runtimelinking" = yes; then
+           shared_flag='${wl}-G'
+         else
+           shared_flag='${wl}-bM:SRE'
+       fi
+       fi
+      fi
+
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols=yes
+      if test "$aix_use_runtimelinking" = yes; then
+       # Warning - without using the other runtime loading flags (-brtl),
+       # -berok will link without error, but may produce a broken library.
+       allow_undefined_flag='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+       hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+       archive_expsym_cmds="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+       if test "$host_cpu" = ia64; then
+         hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
+         allow_undefined_flag="-z nodefs"
+         archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+       else
+        # Determine the default libpath from the value encoded in an empty executable.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+        hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
+         # Warning - without using the other run time loading flags,
+         # -berok will link without error, but may produce a broken library.
+         no_undefined_flag=' ${wl}-bernotok'
+         allow_undefined_flag=' ${wl}-berok'
+         # -bexpall does not export symbols beginning with underscore (_)
+         always_export_symbols=yes
+         # Exported symbols can be pulled into shared objects from archives
+         whole_archive_flag_spec=' '
+         archive_cmds_need_lc=yes
+         # This is similar to how AIX traditionally builds its shared libraries.
+         archive_expsym_cmds="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+       fi
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      # see comment about different semantics on the GNU ld section
+      ld_shlibs=no
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec=' '
+      allow_undefined_flag=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_From_new_cmds='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[012])
+         allow_undefined_flag='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[012])
+               allow_undefined_flag='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               allow_undefined_flag='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      archive_cmds_need_lc=no
+      hardcode_direct=no
+      hardcode_automatic=yes
+      hardcode_shlibpath_var=unsupported
+      whole_archive_flag_spec=''
+      link_all_deplibs=yes
+    if test "$GCC" = yes ; then
+       output_verbose_link_cmd='echo'
+        archive_cmds='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+      archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         archive_cmds='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+         module_cmds='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         archive_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          module_expsym_cmds='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         ld_shlibs=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    freebsd1*)
+      ld_shlibs=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | kfreebsd*-gnu | dragonfly*)
+      archive_cmds='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+       archive_cmds='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+       archive_cmds='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_direct=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L=yes
+      export_dynamic_flag_spec='${wl}-E'
+      ;;
+
+    hpux10* | hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*|ia64*)
+         archive_cmds='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         archive_cmds='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       esac
+      else
+       case $host_cpu in
+       hppa*64*|ia64*)
+         archive_cmds='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       *)
+         archive_cmds='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       esac
+      fi
+      if test "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*)
+         hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+         hardcode_libdir_flag_spec_ld='+b $libdir'
+         hardcode_libdir_separator=:
+         hardcode_direct=no
+         hardcode_shlibpath_var=no
+         ;;
+       ia64*)
+         hardcode_libdir_flag_spec='-L$libdir'
+         hardcode_direct=no
+         hardcode_shlibpath_var=no
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         hardcode_minus_L=yes
+         ;;
+       *)
+         hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
+         hardcode_libdir_separator=:
+         hardcode_direct=yes
+         export_dynamic_flag_spec='${wl}-E'
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         hardcode_minus_L=yes
+         ;;
+       esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+       archive_cmds='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       archive_cmds='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       hardcode_libdir_flag_spec_ld='-rpath $libdir'
+      fi
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      link_all_deplibs=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+       archive_cmds='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    newsos6)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      hardcode_shlibpath_var=no
+      ;;
+
+    openbsd*)
+      hardcode_direct=yes
+      hardcode_shlibpath_var=no
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+       archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+       hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+       export_dynamic_flag_spec='${wl}-E'
+      else
+       case $host_os in
+        openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+          archive_cmds='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+          hardcode_libdir_flag_spec='-R$libdir'
+          ;;
+        *)
+          archive_cmds='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+          hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
+          ;;
+       esac
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_minus_L=yes
+      allow_undefined_flag=unsupported
+      archive_cmds='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_From_new_cmds='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       allow_undefined_flag=' -expect_unresolved \*'
+       archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator=:
+      ;;
+
+    osf4* | osf5*)     # as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+       allow_undefined_flag=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
+      else
+       allow_undefined_flag=' -expect_unresolved \*'
+       archive_cmds='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       archive_expsym_cmds='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+       $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+
+       # Both c and cxx compiler support -rpath directly
+       hardcode_libdir_flag_spec='-rpath $libdir'
+      fi
+      hardcode_libdir_separator=:
+      ;;
+
+    sco3.2v5*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='${wl}-Bexport'
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ;;
+
+    solaris*)
+      no_undefined_flag=' -z text'
+      if test "$GCC" = yes; then
+       wlarc='${wl}'
+       archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+         $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+       wlarc=''
+       archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+       $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      fi
+      hardcode_libdir_flag_spec='-R$libdir'
+      hardcode_shlibpath_var=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+       # The compiler driver will combine linker options so we
+       # cannot just pass the convience library names through
+       # without $wl, iff we do not link with $LD.
+       # Luckily, gcc supports the same syntax we need for Sun Studio.
+       # Supported since Solaris 2.6 (maybe 2.5.1?)
+       case $wlarc in
+       '')
+         whole_archive_flag_spec='-z allextract$convenience -z defaultextract' ;;
+       *)
+         whole_archive_flag_spec='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
+       esac ;;
+      esac
+      link_all_deplibs=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+       # Use $CC to link under sequent, because it throws in some extra .o
+       # files that make .init and .fini sections work.
+       archive_cmds='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_direct=yes
+      hardcode_minus_L=yes
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+       sni)
+         archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct=yes # is this really true???
+       ;;
+       siemens)
+         ## LD is ld it makes a PLAMLIB
+         ## CC just makes a GrossModule.
+         archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+         reload_cmds='$CC -r -o $output$reload_objs'
+         hardcode_direct=no
+        ;;
+       motorola)
+         archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct=no #Motorola manual says yes, but my tests say they lie
+       ;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var=no
+      export_dynamic_flag_spec='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       hardcode_shlibpath_var=no
+       runpath_var=LD_RUN_PATH
+       hardcode_runpath_var=yes
+       ld_shlibs=yes
+      fi
+      ;;
+
+    sysv4.2uw2*)
+      archive_cmds='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct=yes
+      hardcode_minus_L=no
+      hardcode_shlibpath_var=no
+      hardcode_runpath_var=yes
+      runpath_var=LD_RUN_PATH
+      ;;
+
+   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[78]* | unixware7*)
+      no_undefined_flag='${wl}-z ${wl}text'
+      if test "$GCC" = yes; then
+       archive_cmds='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var=no
+      ;;
+
+    sysv5*)
+      no_undefined_flag=' -z text'
+      # $CC -shared without GNU ld will not create a library from C++
+      # object files and a static libstdc++, better avoid it by now
+      archive_cmds='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      archive_expsym_cmds='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      hardcode_libdir_flag_spec=
+      hardcode_shlibpath_var=no
+      runpath_var='LD_RUN_PATH'
+      ;;
+
+    uts4*)
+      archive_cmds='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec='-L$libdir'
+      hardcode_shlibpath_var=no
+      ;;
+
+    *)
+      ld_shlibs=no
+      ;;
+    esac
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs" >&5
+$as_echo "$ld_shlibs" >&6; }
+test "$ld_shlibs" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+      $rm conftest*
+      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag
+        allow_undefined_flag=
+        if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+        then
+         archive_cmds_need_lc=no
+        else
+         archive_cmds_need_lc=yes
+        fi
+        allow_undefined_flag=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc" >&5
+$as_echo "$archive_cmds_need_lc" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix4* | aix5*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+  if test "$GCC" = yes; then
+    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+  else
+    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+  fi
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+kfreebsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  *) # from 3.2 on
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,       ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+knetbsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action=
+if test -n "$hardcode_libdir_flag_spec" || \
+   test -n "$runpath_var" || \
+   test "X$hardcode_automatic" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, )" != no &&
+     test "$hardcode_minus_L" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action" >&5
+$as_echo "$hardcode_action" >&6; }
+
+if test "$hardcode_action" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+       ;;
+   *)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    ;;
+  esac
+fi
+
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+
+fi
+
+   ;;
+
+  *)
+    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_shl_load=yes
+else
+  ac_cv_lib_dld_shl_load=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_svld_dlopen=yes
+else
+  ac_cv_lib_svld_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_dld_link=yes
+else
+  ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = x""yes; then :
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 8373 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      LDFLAGS="$LDFLAGS $link_static_flag"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self_static+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 8471 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+
+# Report which librarie types wil actually be built
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if libtool supports shared libraries" >&5
+$as_echo_n "checking if libtool supports shared libraries... " >&6; }
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $can_build_shared" >&5
+$as_echo "$can_build_shared" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build shared libraries" >&5
+$as_echo_n "checking whether to build shared libraries... " >&6; }
+test "$can_build_shared" = "no" && enable_shared=no
+
+# On AIX, shared libraries and static libraries use the same namespace, and
+# are all built from PIC.
+case $host_os in
+aix3*)
+  test "$enable_shared" = yes && enable_static=no
+  if test -n "$RANLIB"; then
+    archive_cmds="$archive_cmds~\$RANLIB \$lib"
+    postinstall_cmds='$RANLIB $lib'
+  fi
+  ;;
+
+aix4* | aix5*)
+  if test "$host_cpu" != ia64 && test "$aix_use_runtimelinking" = no ; then
+    test "$enable_shared" = yes && enable_static=no
+  fi
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_shared" >&5
+$as_echo "$enable_shared" >&6; }
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether to build static libraries" >&5
+$as_echo_n "checking whether to build static libraries... " >&6; }
+# Make sure either enable_shared or enable_static is yes.
+test "$enable_shared" = yes || enable_static=yes
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $enable_static" >&5
+$as_echo "$enable_static" >&6; }
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler \
+    CC \
+    LD \
+    lt_prog_compiler_wl \
+    lt_prog_compiler_pic \
+    lt_prog_compiler_static \
+    lt_prog_compiler_no_builtin_flag \
+    export_dynamic_flag_spec \
+    thread_safe_flag_spec \
+    whole_archive_flag_spec \
+    enable_shared_with_static_runtimes \
+    old_archive_cmds \
+    old_archive_from_new_cmds \
+    predep_objects \
+    postdep_objects \
+    predeps \
+    postdeps \
+    compiler_lib_search_path \
+    archive_cmds \
+    archive_expsym_cmds \
+    postinstall_cmds \
+    postuninstall_cmds \
+    old_archive_from_expsyms_cmds \
+    allow_undefined_flag \
+    no_undefined_flag \
+    export_symbols_cmds \
+    hardcode_libdir_flag_spec \
+    hardcode_libdir_flag_spec_ld \
+    hardcode_libdir_separator \
+    hardcode_automatic \
+    module_cmds \
+    module_expsym_cmds \
+    lt_cv_prog_compiler_c_o \
+    exclude_expsyms \
+    include_expsyms; do
+
+    case $var in
+    old_archive_cmds | \
+    old_archive_from_new_cmds | \
+    archive_cmds | \
+    archive_expsym_cmds | \
+    module_cmds | \
+    module_expsym_cmds | \
+    old_archive_from_expsyms_cmds | \
+    export_symbols_cmds | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="${ofile}T"
+  trap "$rm \"$cfgfile\"; exit 1" 1 2 15
+  $rm -f "$cfgfile"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ofile" >&5
+$as_echo "$as_me: creating $ofile" >&6;}
+
+  cat <<__EOF__ >> "$cfgfile"
+#! $SHELL
+
+# `$echo "$cfgfile" | sed 's%^.*/%%'` - Provide generalized library-building support services.
+# Generated automatically by $PROGRAM (GNU $PACKAGE $VERSION$TIMESTAMP)
+# NOTE: Changes made to this file will be lost: look at ltmain.sh.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001
+# Free Software Foundation, Inc.
+#
+# This file is part of GNU Libtool:
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# A sed program that does not truncate output.
+SED=$lt_SED
+
+# Sed that helps us avoid accidentally triggering echo(1) options like -n.
+Xsed="$SED -e 1s/^X//"
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+# The names of the tagged configurations supported by this script.
+available_tags=
+
+# ### BEGIN LIBTOOL CONFIG
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds
+archive_expsym_cmds=$lt_archive_expsym_cmds
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds
+module_expsym_cmds=$lt_module_expsym_cmds
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms
+
+# ### END LIBTOOL CONFIG
+
+__EOF__
+
+
+  case $host_os in
+  aix3*)
+    cat <<\EOF >> "$cfgfile"
+
+# AIX sometimes has problems with the GCC collect2 program.  For some
+# reason, if we set the COLLECT_NAMES environment variable, the problems
+# vanish in a puff of smoke.
+if test "X${COLLECT_NAMES+set}" != Xset; then
+  COLLECT_NAMES=
+  export COLLECT_NAMES
+fi
+EOF
+    ;;
+  esac
+
+  # We use sed instead of cat because bash on DJGPP gets confused if
+  # if finds mixed CR/LF and LF-only lines.  Since sed operates in
+  # text mode, it properly converts lines to CR/LF.  This bash problem
+  # is reportedly fixed, but why not run on old versions too?
+  sed '$q' "$ltmain" >> "$cfgfile" || (rm -f "$cfgfile"; exit 1)
+
+  mv -f "$cfgfile" "$ofile" || \
+    (rm -f "$ofile" && cp "$cfgfile" "$ofile" && rm -f "$cfgfile")
+  chmod +x "$ofile"
+
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+
+# Check whether --with-tags was given.
+if test "${with_tags+set}" = set; then :
+  withval=$with_tags; tagnames="$withval"
+fi
+
+
+if test -f "$ltmain" && test -n "$tagnames"; then
+  if test ! -f "${ofile}"; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: output file \`$ofile' does not exist" >&5
+$as_echo "$as_me: WARNING: output file \`$ofile' does not exist" >&2;}
+  fi
+
+  if test -z "$LTCC"; then
+    eval "`$SHELL ${ofile} --config | grep '^LTCC='`"
+    if test -z "$LTCC"; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: output file \`$ofile' does not look like a libtool script" >&5
+$as_echo "$as_me: WARNING: output file \`$ofile' does not look like a libtool script" >&2;}
+    else
+      { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&5
+$as_echo "$as_me: WARNING: using \`LTCC=$LTCC', extracted from \`$ofile'" >&2;}
+    fi
+  fi
+
+  # Extract list of available tagged configurations in $ofile.
+  # Note that this assumes the entire list is on one line.
+  available_tags=`grep "^available_tags=" "${ofile}" | $SED -e 's/available_tags=\(.*$\)/\1/' -e 's/\"//g'`
+
+  lt_save_ifs="$IFS"; IFS="${IFS}$PATH_SEPARATOR,"
+  for tagname in $tagnames; do
+    IFS="$lt_save_ifs"
+    # Check whether tagname contains only valid characters
+    case `$echo "X$tagname" | $Xsed -e 's:[-_ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890,/]::g'` in
+    "") ;;
+    *)  as_fn_error "invalid tag name: $tagname" "$LINENO" 5
+       ;;
+    esac
+
+    if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "${ofile}" > /dev/null
+    then
+      as_fn_error "tag name \"$tagname\" already exists" "$LINENO" 5
+    fi
+
+    # Update the list of available tags.
+    if test -n "$tagname"; then
+      echo appending configuration tag \"$tagname\" to $ofile
+
+      case $tagname in
+      CXX)
+       if test -n "$CXX" && ( test "X$CXX" != "Xno" &&
+           ( (test "X$CXX" = "Xg++" && `g++ -v >/dev/null 2>&1` ) ||
+           (test "X$CXX" != "Xg++"))) ; then
+         :
+       else
+         tagname=""
+       fi
+       ;;
+
+      F77)
+       if test -n "$F77" && test "X$F77" != "Xno"; then
+         :
+       else
+         tagname=""
+       fi
+       ;;
+
+      GCJ)
+       if test -n "$GCJ" && test "X$GCJ" != "Xno"; then
+
+
+# Source file extension for Java test sources.
+ac_ext=java
+
+# Object file extension for compiled Java test sources.
+objext=o
+objext_GCJ=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code="class foo {}\n"
+
+# Code to be used in simple link tests
+lt_simple_link_test_code='public class conftest { public static void main(String[] argv) {}; }\n'
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm conftest*
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${GCJ-"gcj"}
+compiler=$CC
+compiler_GCJ=$CC
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+
+# GCJ did not exist at the time GCC didn't implicitly link libc in.
+archive_cmds_need_lc_GCJ=no
+
+old_archive_cmds_GCJ=$old_archive_cmds
+
+
+lt_prog_compiler_no_builtin_flag_GCJ=
+
+if test "$GCC" = yes; then
+  lt_prog_compiler_no_builtin_flag_GCJ=' -fno-builtin'
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -fno-rtti -fno-exceptions" >&5
+$as_echo_n "checking if $compiler supports -fno-rtti -fno-exceptions... " >&6; }
+if test "${lt_cv_prog_compiler_rtti_exceptions+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_rtti_exceptions=no
+  ac_outfile=conftest.$ac_objext
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="-fno-rtti -fno-exceptions"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:9250: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:9254: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_rtti_exceptions=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_rtti_exceptions" >&5
+$as_echo "$lt_cv_prog_compiler_rtti_exceptions" >&6; }
+
+if test x"$lt_cv_prog_compiler_rtti_exceptions" = xyes; then
+    lt_prog_compiler_no_builtin_flag_GCJ="$lt_prog_compiler_no_builtin_flag_GCJ -fno-rtti -fno-exceptions"
+else
+    :
+fi
+
+fi
+
+lt_prog_compiler_wl_GCJ=
+lt_prog_compiler_pic_GCJ=
+lt_prog_compiler_static_GCJ=
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $compiler option to produce PIC" >&5
+$as_echo_n "checking for $compiler option to produce PIC... " >&6; }
+
+  if test "$GCC" = yes; then
+    lt_prog_compiler_wl_GCJ='-Wl,'
+    lt_prog_compiler_static_GCJ='-static'
+
+    case $host_os in
+      aix*)
+      # All AIX code is PIC.
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static_GCJ='-Bstatic'
+      fi
+      ;;
+
+    amigaos*)
+      # FIXME: we need at least 68020 code to build shared libraries, but
+      # adding the `-m68020' flag to GCC prevents building anything better,
+      # like `-m68040'.
+      lt_prog_compiler_pic_GCJ='-m68020 -resident32 -malways-restore-a4'
+      ;;
+
+    beos* | cygwin* | irix5* | irix6* | nonstopux* | osf3* | osf4* | osf5*)
+      # PIC is the default for these OSes.
+      ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
+      ;;
+
+    darwin* | rhapsody*)
+      # PIC is the default on this platform
+      # Common symbols not allowed in MH_DYLIB files
+      lt_prog_compiler_pic_GCJ='-fno-common'
+      ;;
+
+    msdosdjgpp*)
+      # Just because we use GCC doesn't mean we suddenly get shared libraries
+      # on systems that don't support them.
+      lt_prog_compiler_can_build_shared_GCJ=no
+      enable_shared=no
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       lt_prog_compiler_pic_GCJ=-Kconform_pic
+      fi
+      ;;
+
+    hpux*)
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic_GCJ='-fPIC'
+       ;;
+      esac
+      ;;
+
+    *)
+      lt_prog_compiler_pic_GCJ='-fPIC'
+      ;;
+    esac
+  else
+    # PORTME Check for flag to pass linker flags through the system compiler.
+    case $host_os in
+    aix*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      if test "$host_cpu" = ia64; then
+       # AIX 5 now supports IA64 processor
+       lt_prog_compiler_static_GCJ='-Bstatic'
+      else
+       lt_prog_compiler_static_GCJ='-bnso -bI:/lib/syscalls.exp'
+      fi
+      ;;
+      darwin*)
+        # PIC is the default on this platform
+        # Common symbols not allowed in MH_DYLIB files
+       case $cc_basename in
+         xlc*)
+         lt_prog_compiler_pic_GCJ='-qnocommon'
+         lt_prog_compiler_wl_GCJ='-Wl,'
+         ;;
+       esac
+       ;;
+
+    mingw* | pw32* | os2*)
+      # This hack is so that the source file can tell whether it is being
+      # built for inclusion in a dll (and should export symbols for example).
+      lt_prog_compiler_pic_GCJ='-DDLL_EXPORT'
+      ;;
+
+    hpux9* | hpux10* | hpux11*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # PIC is the default for IA64 HP-UX and 64-bit HP-UX, but
+      # not for PA HP-UX.
+      case $host_cpu in
+      hppa*64*|ia64*)
+       # +Z the default
+       ;;
+      *)
+       lt_prog_compiler_pic_GCJ='+Z'
+       ;;
+      esac
+      # Is there a better lt_prog_compiler_static that works with the bundled CC?
+      lt_prog_compiler_static_GCJ='${wl}-a ${wl}archive'
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # PIC (with -KPIC) is the default.
+      lt_prog_compiler_static_GCJ='-non_shared'
+      ;;
+
+    newsos6)
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    linux*)
+      case $cc_basename in
+      icc* | ecc*)
+       lt_prog_compiler_wl_GCJ='-Wl,'
+       lt_prog_compiler_pic_GCJ='-KPIC'
+       lt_prog_compiler_static_GCJ='-static'
+        ;;
+      pgcc* | pgf77* | pgf90* | pgf95*)
+        # Portland Group compilers (*not* the Pentium gcc compiler,
+       # which looks to be a dead project)
+       lt_prog_compiler_wl_GCJ='-Wl,'
+       lt_prog_compiler_pic_GCJ='-fpic'
+       lt_prog_compiler_static_GCJ='-Bstatic'
+        ;;
+      ccc*)
+        lt_prog_compiler_wl_GCJ='-Wl,'
+        # All Alpha code is PIC.
+        lt_prog_compiler_static_GCJ='-non_shared'
+        ;;
+      esac
+      ;;
+
+    osf3* | osf4* | osf5*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      # All OSF/1 code is PIC.
+      lt_prog_compiler_static_GCJ='-non_shared'
+      ;;
+
+    sco3.2v5*)
+      lt_prog_compiler_pic_GCJ='-Kpic'
+      lt_prog_compiler_static_GCJ='-dn'
+      ;;
+
+    solaris*)
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      case $cc_basename in
+      f77* | f90* | f95*)
+       lt_prog_compiler_wl_GCJ='-Qoption ld ';;
+      *)
+       lt_prog_compiler_wl_GCJ='-Wl,';;
+      esac
+      ;;
+
+    sunos4*)
+      lt_prog_compiler_wl_GCJ='-Qoption ld '
+      lt_prog_compiler_pic_GCJ='-PIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      lt_prog_compiler_pic_GCJ='-KPIC'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec ;then
+       lt_prog_compiler_pic_GCJ='-Kconform_pic'
+       lt_prog_compiler_static_GCJ='-Bstatic'
+      fi
+      ;;
+
+    unicos*)
+      lt_prog_compiler_wl_GCJ='-Wl,'
+      lt_prog_compiler_can_build_shared_GCJ=no
+      ;;
+
+    uts4*)
+      lt_prog_compiler_pic_GCJ='-pic'
+      lt_prog_compiler_static_GCJ='-Bstatic'
+      ;;
+
+    *)
+      lt_prog_compiler_can_build_shared_GCJ=no
+      ;;
+    esac
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_GCJ" >&5
+$as_echo "$lt_prog_compiler_pic_GCJ" >&6; }
+
+#
+# Check to make sure the PIC flag actually works.
+#
+if test -n "$lt_prog_compiler_pic_GCJ"; then
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works" >&5
+$as_echo_n "checking if $compiler PIC flag $lt_prog_compiler_pic_GCJ works... " >&6; }
+if test "${lt_prog_compiler_pic_works_GCJ+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_prog_compiler_pic_works_GCJ=no
+  ac_outfile=conftest.$ac_objext
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+   lt_compiler_flag="$lt_prog_compiler_pic_GCJ"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   # The option is referenced via a variable to avoid confusing sed.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:9512: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>conftest.err)
+   ac_status=$?
+   cat conftest.err >&5
+   echo "$as_me:9516: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s "$ac_outfile"; then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings other than the usual output.
+     $echo "X$_lt_compiler_boilerplate" | $Xsed >conftest.exp
+     $SED '/^$/d' conftest.err >conftest.er2
+     if test ! -s conftest.err || diff conftest.exp conftest.er2 >/dev/null; then
+       lt_prog_compiler_pic_works_GCJ=yes
+     fi
+   fi
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_prog_compiler_pic_works_GCJ" >&5
+$as_echo "$lt_prog_compiler_pic_works_GCJ" >&6; }
+
+if test x"$lt_prog_compiler_pic_works_GCJ" = xyes; then
+    case $lt_prog_compiler_pic_GCJ in
+     "" | " "*) ;;
+     *) lt_prog_compiler_pic_GCJ=" $lt_prog_compiler_pic_GCJ" ;;
+     esac
+else
+    lt_prog_compiler_pic_GCJ=
+     lt_prog_compiler_can_build_shared_GCJ=no
+fi
+
+fi
+case $host_os in
+  # For platforms which do not support PIC, -DPIC is meaningless:
+  *djgpp*)
+    lt_prog_compiler_pic_GCJ=
+    ;;
+  *)
+    lt_prog_compiler_pic_GCJ="$lt_prog_compiler_pic_GCJ"
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $compiler supports -c -o file.$ac_objext" >&5
+$as_echo_n "checking if $compiler supports -c -o file.$ac_objext... " >&6; }
+if test "${lt_cv_prog_compiler_c_o_GCJ+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  lt_cv_prog_compiler_c_o_GCJ=no
+   $rm -r conftest 2>/dev/null
+   mkdir conftest
+   cd conftest
+   mkdir out
+   printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+   lt_compiler_flag="-o out/conftest2.$ac_objext"
+   # Insert the option either (1) after the last *FLAGS variable, or
+   # (2) before a word containing "conftest.", or (3) at the end.
+   # Note that $ac_compile itself does not contain backslashes and begins
+   # with a dollar sign (not a hyphen), so the echo should work correctly.
+   lt_compile=`echo "$ac_compile" | $SED \
+   -e 's:.*FLAGS}\{0,1\} :&$lt_compiler_flag :; t' \
+   -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \
+   -e 's:$: $lt_compiler_flag:'`
+   (eval echo "\"\$as_me:9574: $lt_compile\"" >&5)
+   (eval "$lt_compile" 2>out/conftest.err)
+   ac_status=$?
+   cat out/conftest.err >&5
+   echo "$as_me:9578: \$? = $ac_status" >&5
+   if (exit $ac_status) && test -s out/conftest2.$ac_objext
+   then
+     # The compiler can only warn and ignore the option if not recognized
+     # So say no if there are warnings
+     $echo "X$_lt_compiler_boilerplate" | $Xsed > out/conftest.exp
+     $SED '/^$/d' out/conftest.err >out/conftest.er2
+     if test ! -s out/conftest.err || diff out/conftest.exp out/conftest.er2 >/dev/null; then
+       lt_cv_prog_compiler_c_o_GCJ=yes
+     fi
+   fi
+   chmod u+w . 2>&5
+   $rm conftest*
+   # SGI C++ compiler will create directory out/ii_files/ for
+   # template instantiation
+   test -d out/ii_files && $rm out/ii_files/* && rmdir out/ii_files
+   $rm out/* && rmdir out
+   cd ..
+   rmdir conftest
+   $rm conftest*
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_prog_compiler_c_o_GCJ" >&5
+$as_echo "$lt_cv_prog_compiler_c_o_GCJ" >&6; }
+
+
+hard_links="nottested"
+if test "$lt_cv_prog_compiler_c_o_GCJ" = no && test "$need_locks" != no; then
+  # do not overwrite the value of need_locks provided by the user
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking if we can lock with hard links" >&5
+$as_echo_n "checking if we can lock with hard links... " >&6; }
+  hard_links=yes
+  $rm conftest*
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  touch conftest.a
+  ln conftest.a conftest.b 2>&5 || hard_links=no
+  ln conftest.a conftest.b 2>/dev/null && hard_links=no
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: $hard_links" >&5
+$as_echo "$hard_links" >&6; }
+  if test "$hard_links" = no; then
+    { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&5
+$as_echo "$as_me: WARNING: \`$CC' does not support \`-c -o', so \`make -j' may be unsafe" >&2;}
+    need_locks=warn
+  fi
+else
+  need_locks=no
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the $compiler linker ($LD) supports shared libraries" >&5
+$as_echo_n "checking whether the $compiler linker ($LD) supports shared libraries... " >&6; }
+
+  runpath_var=
+  allow_undefined_flag_GCJ=
+  enable_shared_with_static_runtimes_GCJ=no
+  archive_cmds_GCJ=
+  archive_expsym_cmds_GCJ=
+  old_archive_From_new_cmds_GCJ=
+  old_archive_from_expsyms_cmds_GCJ=
+  export_dynamic_flag_spec_GCJ=
+  whole_archive_flag_spec_GCJ=
+  thread_safe_flag_spec_GCJ=
+  hardcode_libdir_flag_spec_GCJ=
+  hardcode_libdir_flag_spec_ld_GCJ=
+  hardcode_libdir_separator_GCJ=
+  hardcode_direct_GCJ=no
+  hardcode_minus_L_GCJ=no
+  hardcode_shlibpath_var_GCJ=unsupported
+  link_all_deplibs_GCJ=unknown
+  hardcode_automatic_GCJ=no
+  module_cmds_GCJ=
+  module_expsym_cmds_GCJ=
+  always_export_symbols_GCJ=no
+  export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED '\''s/.* //'\'' | sort | uniq > $export_symbols'
+  # include_expsyms should be a list of space-separated symbols to be *always*
+  # included in the symbol list
+  include_expsyms_GCJ=
+  # exclude_expsyms can be an extended regexp of symbols to exclude
+  # it will be wrapped by ` (' and `)$', so one must not match beginning or
+  # end of line.  Example: `a|bc|.*d.*' will exclude the symbols `a' and `bc',
+  # as well as any symbol that contains `d'.
+  exclude_expsyms_GCJ="_GLOBAL_OFFSET_TABLE_"
+  # Although _GLOBAL_OFFSET_TABLE_ is a valid symbol C name, most a.out
+  # platforms (ab)use it in PIC code, but their linkers get confused if
+  # the symbol is explicitly referenced.  Since portable code cannot
+  # rely on this symbol name, it's probably fine to never include it in
+  # preloaded symbol tables.
+  extract_expsyms_cmds=
+  # Just being paranoid about ensuring that cc_basename is set.
+  for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+  case $host_os in
+  cygwin* | mingw* | pw32*)
+    # FIXME: the MSVC++ port hasn't been tested in a loooong time
+    # When not using gcc, we currently assume that we are using
+    # Microsoft Visual C++.
+    if test "$GCC" != yes; then
+      with_gnu_ld=no
+    fi
+    ;;
+  openbsd*)
+    with_gnu_ld=no
+    ;;
+  esac
+
+  ld_shlibs_GCJ=yes
+  if test "$with_gnu_ld" = yes; then
+    # If archive_cmds runs LD, not CC, wlarc should be empty
+    wlarc='${wl}'
+
+    # Set some defaults for GNU ld with shared library support. These
+    # are reset later if shared libraries are not supported. Putting them
+    # here allows them to be overridden if necessary.
+    runpath_var=LD_RUN_PATH
+    hardcode_libdir_flag_spec_GCJ='${wl}--rpath ${wl}$libdir'
+    export_dynamic_flag_spec_GCJ='${wl}--export-dynamic'
+    # ancient GNU ld didn't support --whole-archive et. al.
+    if $LD --help 2>&1 | grep 'no-whole-archive' > /dev/null; then
+       whole_archive_flag_spec_GCJ="$wlarc"'--whole-archive$convenience '"$wlarc"'--no-whole-archive'
+      else
+       whole_archive_flag_spec_GCJ=
+    fi
+    supports_anon_versioning=no
+    case `$LD -v 2>/dev/null` in
+      *\ [01].* | *\ 2.[0-9].* | *\ 2.10.*) ;; # catch versions < 2.11
+      *\ 2.11.93.0.2\ *) supports_anon_versioning=yes ;; # RH7.3 ...
+      *\ 2.11.92.0.12\ *) supports_anon_versioning=yes ;; # Mandrake 8.2 ...
+      *\ 2.11.*) ;; # other 2.11 versions
+      *) supports_anon_versioning=yes ;;
+    esac
+
+    # See if GNU ld supports shared libraries.
+    case $host_os in
+    aix3* | aix4* | aix5*)
+      # On AIX/PPC, the GNU linker is very broken
+      if test "$host_cpu" != ia64; then
+       ld_shlibs_GCJ=no
+       cat <<EOF 1>&2
+
+*** Warning: the GNU linker, at least up to release 2.9.1, is reported
+*** to be unable to reliably create shared libraries on AIX.
+*** Therefore, libtool is disabling shared libraries support.  If you
+*** really care for shared libraries, you may want to modify your PATH
+*** so that a non-GNU linker is found, and then restart.
+
+EOF
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_minus_L_GCJ=yes
+
+      # Samuel A. Falvo II <kc5tja@dolphin.openprojects.net> reports
+      # that the semantics of dynamic libraries on AmigaOS, at least up
+      # to version 4, is to share data among multiple programs linked
+      # with the same dynamic library.  Since this doesn't match the
+      # behavior of shared libraries on other platforms, we can't use
+      # them.
+      ld_shlibs_GCJ=no
+      ;;
+
+    beos*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       allow_undefined_flag_GCJ=unsupported
+       # Joseph Beckenbach <jrb3@best.com> says some releases of gcc
+       # support --undefined.  This deserves some investigation.  FIXME
+       archive_cmds_GCJ='$CC -nostart $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+      else
+       ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # _LT_AC_TAGVAR(hardcode_libdir_flag_spec, GCJ) is actually meaningless,
+      # as there is no search path for DLLs.
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      allow_undefined_flag_GCJ=unsupported
+      always_export_symbols_GCJ=no
+      enable_shared_with_static_runtimes_GCJ=yes
+      export_symbols_cmds_GCJ='$NM $libobjs $convenience | $global_symbol_pipe | $SED -e '\''/^[BCDGRS] /s/.* \([^ ]*\)/\1 DATA/'\'' | $SED -e '\''/^[AITW] /s/.* //'\'' | sort | uniq > $export_symbols'
+
+      if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
+        archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000 ${wl}--out-implib,$lib'
+       # If the export-symbols file already is a .def file (1st line
+       # is EXPORTS), use it as is; otherwise, prepend...
+       archive_expsym_cmds_GCJ='if test "x`$SED 1q $export_symbols`" = xEXPORTS; then
+         cp $export_symbols $output_objdir/$soname.def;
+       else
+         echo EXPORTS > $output_objdir/$soname.def;
+         cat $export_symbols >> $output_objdir/$soname.def;
+       fi~
+       $CC -shared $output_objdir/$soname.def $libobjs $deplibs $compiler_flags -o $output_objdir/$soname ${wl}--image-base=0x10000000  ${wl}--out-implib,$lib'
+      else
+       ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    linux*)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       tmp_addflag=
+       case $cc_basename,$host_cpu in
+       pgcc*)                          # Portland Group C compiler
+         whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag'
+         ;;
+       pgf77* | pgf90* | pgf95*)       # Portland Group f77 and f90 compilers
+         whole_archive_flag_spec_GCJ='${wl}--whole-archive`for conv in $convenience\"\"; do test  -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}--no-whole-archive'
+         tmp_addflag=' $pic_flag -Mnomain' ;;
+       ecc*,ia64* | icc*,ia64*)                # Intel C compiler on ia64
+         tmp_addflag=' -i_dynamic' ;;
+       efc*,ia64* | ifort*,ia64*)      # Intel Fortran compiler on ia64
+         tmp_addflag=' -i_dynamic -nofor_main' ;;
+       ifc* | ifort*)                  # Intel Fortran compiler
+         tmp_addflag=' -nofor_main' ;;
+       esac
+       archive_cmds_GCJ='$CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+
+       if test $supports_anon_versioning = yes; then
+         archive_expsym_cmds_GCJ='$echo "{ global:" > $output_objdir/$libname.ver~
+  cat $export_symbols | sed -e "s/\(.*\)/\1;/" >> $output_objdir/$libname.ver~
+  $echo "local: *; };" >> $output_objdir/$libname.ver~
+         $CC -shared'"$tmp_addflag"' $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-version-script ${wl}$output_objdir/$libname.ver -o $lib'
+       fi
+      else
+       ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       archive_cmds_GCJ='$LD -Bshareable $libobjs $deplibs $linker_flags -o $lib'
+       wlarc=
+      else
+       archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      fi
+      ;;
+
+    solaris* | sysv5*)
+      if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
+       ld_shlibs_GCJ=no
+       cat <<EOF 1>&2
+
+*** Warning: The releases 2.8.* of the GNU linker cannot reliably
+*** create shared libraries on Solaris systems.  Therefore, libtool
+*** is disabling shared libraries support.  We urge you to upgrade GNU
+*** binutils to release 2.9.1 or newer.  Another option is to modify
+*** your PATH or compiler configuration so that the native linker is
+*** used, and then restart.
+
+EOF
+      elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs_GCJ=no
+      fi
+      ;;
+
+    sunos4*)
+      archive_cmds_GCJ='$LD -assert pure-text -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      wlarc=
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    *)
+      if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
+       archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname -o $lib'
+       archive_expsym_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname $wl$soname ${wl}-retain-symbols-file $wl$export_symbols -o $lib'
+      else
+       ld_shlibs_GCJ=no
+      fi
+      ;;
+    esac
+
+    if test "$ld_shlibs_GCJ" = no; then
+      runpath_var=
+      hardcode_libdir_flag_spec_GCJ=
+      export_dynamic_flag_spec_GCJ=
+      whole_archive_flag_spec_GCJ=
+    fi
+  else
+    # PORTME fill in a description of your system's linker (not GNU ld)
+    case $host_os in
+    aix3*)
+      allow_undefined_flag_GCJ=unsupported
+      always_export_symbols_GCJ=yes
+      archive_expsym_cmds_GCJ='$LD -o $output_objdir/$soname $libobjs $deplibs $linker_flags -bE:$export_symbols -T512 -H512 -bM:SRE~$AR $AR_FLAGS $lib $output_objdir/$soname'
+      # Note: this linker hardcodes the directories in LIBPATH if there
+      # are no directories specified by -L.
+      hardcode_minus_L_GCJ=yes
+      if test "$GCC" = yes && test -z "$link_static_flag"; then
+       # Neither direct hardcoding nor static linking is supported with a
+       # broken collect2.
+       hardcode_direct_GCJ=unsupported
+      fi
+      ;;
+
+    aix4* | aix5*)
+      if test "$host_cpu" = ia64; then
+       # On IA64, the linker does run time linking by default, so we don't
+       # have to do anything special.
+       aix_use_runtimelinking=no
+       exp_sym_flag='-Bexport'
+       no_entry_flag=""
+      else
+       # If we're using GNU nm, then we don't want the "-C" option.
+       # -C means demangle to AIX nm, but means don't demangle with GNU nm
+       if $NM -V 2>&1 | grep 'GNU' > /dev/null; then
+         export_symbols_cmds_GCJ='$NM -Bpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+       else
+         export_symbols_cmds_GCJ='$NM -BCpg $libobjs $convenience | awk '\''{ if (((\$2 == "T") || (\$2 == "D") || (\$2 == "B")) && (substr(\$3,1,1) != ".")) { print \$3 } }'\'' | sort -u > $export_symbols'
+       fi
+       aix_use_runtimelinking=no
+
+       # Test if we are trying to use run time linking or normal
+       # AIX style linking. If -brtl is somewhere in LDFLAGS, we
+       # need to do runtime linking.
+       case $host_os in aix4.[23]|aix4.[23].*|aix5*)
+         for ld_flag in $LDFLAGS; do
+         if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
+           aix_use_runtimelinking=yes
+           break
+         fi
+         done
+       esac
+
+       exp_sym_flag='-bexport'
+       no_entry_flag='-bnoentry'
+      fi
+
+      # When large executables or shared objects are built, AIX ld can
+      # have problems creating the table of contents.  If linking a library
+      # or program results in "error TOC overflow" add -mminimal-toc to
+      # CXXFLAGS/CFLAGS for g++/gcc.  In the cases where that is not
+      # enough to fix the problem, add -Wl,-bbigtoc to LDFLAGS.
+
+      archive_cmds_GCJ=''
+      hardcode_direct_GCJ=yes
+      hardcode_libdir_separator_GCJ=':'
+      link_all_deplibs_GCJ=yes
+
+      if test "$GCC" = yes; then
+       case $host_os in aix4.[012]|aix4.[012].*)
+       # We only want to do this on AIX 4.2 and lower, the check
+       # below for broken collect2 doesn't work under 4.3+
+         collect2name=`${CC} -print-prog-name=collect2`
+         if test -f "$collect2name" && \
+          strings "$collect2name" | grep resolve_lib_name >/dev/null
+         then
+         # We have reworked collect2
+         hardcode_direct_GCJ=yes
+         else
+         # We have old collect2
+         hardcode_direct_GCJ=unsupported
+         # It fails to find uninstalled libraries when the uninstalled
+         # path is not listed in the libpath.  Setting hardcode_minus_L
+         # to unsupported forces relinking
+         hardcode_minus_L_GCJ=yes
+         hardcode_libdir_flag_spec_GCJ='-L$libdir'
+         hardcode_libdir_separator_GCJ=
+         fi
+       esac
+       shared_flag='-shared'
+       if test "$aix_use_runtimelinking" = yes; then
+         shared_flag="$shared_flag "'${wl}-G'
+       fi
+      else
+       # not using gcc
+       if test "$host_cpu" = ia64; then
+       # VisualAge C++, Version 5.5 for AIX 5L for IA-64, Beta 3 Release
+       # chokes on -Wl,-G. The following line is correct:
+         shared_flag='-G'
+       else
+       if test "$aix_use_runtimelinking" = yes; then
+           shared_flag='${wl}-G'
+         else
+           shared_flag='${wl}-bM:SRE'
+       fi
+       fi
+      fi
+
+      # It seems that -bexpall does not export symbols beginning with
+      # underscore (_), so it is better to generate a list of symbols to export.
+      always_export_symbols_GCJ=yes
+      if test "$aix_use_runtimelinking" = yes; then
+       # Warning - without using the other runtime loading flags (-brtl),
+       # -berok will link without error, but may produce a broken library.
+       allow_undefined_flag_GCJ='-berok'
+       # Determine the default libpath from the value encoded in an empty executable.
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+       hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
+       archive_expsym_cmds_GCJ="\$CC"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags `if test "x${allow_undefined_flag}" != "x"; then echo "${wl}${allow_undefined_flag}"; else :; fi` '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols $shared_flag"
+       else
+       if test "$host_cpu" = ia64; then
+         hardcode_libdir_flag_spec_GCJ='${wl}-R $libdir:/usr/lib:/lib'
+         allow_undefined_flag_GCJ="-z nodefs"
+         archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}${allow_undefined_flag} '"\${wl}$no_entry_flag \${wl}$exp_sym_flag:\$export_symbols"
+       else
+        # Determine the default libpath from the value encoded in an empty executable.
+        cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+
+aix_libpath=`dump -H conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`
+# Check for a 64-bit object if we didn't find anything.
+if test -z "$aix_libpath"; then aix_libpath=`dump -HX64 conftest$ac_exeext 2>/dev/null | $SED -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0  *\(.*\)$/\1/; p; }
+}'`; fi
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+if test -z "$aix_libpath"; then aix_libpath="/usr/lib:/lib"; fi
+
+        hardcode_libdir_flag_spec_GCJ='${wl}-blibpath:$libdir:'"$aix_libpath"
+         # Warning - without using the other run time loading flags,
+         # -berok will link without error, but may produce a broken library.
+         no_undefined_flag_GCJ=' ${wl}-bernotok'
+         allow_undefined_flag_GCJ=' ${wl}-berok'
+         # -bexpall does not export symbols beginning with underscore (_)
+         always_export_symbols_GCJ=yes
+         # Exported symbols can be pulled into shared objects from archives
+         whole_archive_flag_spec_GCJ=' '
+         archive_cmds_need_lc_GCJ=yes
+         # This is similar to how AIX traditionally builds its shared libraries.
+         archive_expsym_cmds_GCJ="\$CC $shared_flag"' -o $output_objdir/$soname $libobjs $deplibs $compiler_flags ${wl}-bE:$export_symbols ${wl}-bnoentry${allow_undefined_flag}~$AR $AR_FLAGS $output_objdir/$libname$release.a $output_objdir/$soname'
+       fi
+      fi
+      ;;
+
+    amigaos*)
+      archive_cmds_GCJ='$rm $output_objdir/a2ixlibrary.data~$echo "#define NAME $libname" > $output_objdir/a2ixlibrary.data~$echo "#define LIBRARY_ID 1" >> $output_objdir/a2ixlibrary.data~$echo "#define VERSION $major" >> $output_objdir/a2ixlibrary.data~$echo "#define REVISION $revision" >> $output_objdir/a2ixlibrary.data~$AR $AR_FLAGS $lib $libobjs~$RANLIB $lib~(cd $output_objdir && a2ixlibrary -32)'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_minus_L_GCJ=yes
+      # see comment about different semantics on the GNU ld section
+      ld_shlibs_GCJ=no
+      ;;
+
+    bsdi[45]*)
+      export_dynamic_flag_spec_GCJ=-rdynamic
+      ;;
+
+    cygwin* | mingw* | pw32*)
+      # When not using gcc, we currently assume that we are using
+      # Microsoft Visual C++.
+      # hardcode_libdir_flag_spec is actually meaningless, as there is
+      # no search path for DLLs.
+      hardcode_libdir_flag_spec_GCJ=' '
+      allow_undefined_flag_GCJ=unsupported
+      # Tell ltmain to make .lib files, not .a files.
+      libext=lib
+      # Tell ltmain to make .dll files, not .so files.
+      shrext_cmds=".dll"
+      # FIXME: Setting linknames here is a bad hack.
+      archive_cmds_GCJ='$CC -o $lib $libobjs $compiler_flags `echo "$deplibs" | $SED -e '\''s/ -lc$//'\''` -link -dll~linknames='
+      # The linker will automatically build a .lib file if we build a DLL.
+      old_archive_From_new_cmds_GCJ='true'
+      # FIXME: Should let the user specify the lib program.
+      old_archive_cmds_GCJ='lib /OUT:$oldlib$oldobjs$old_deplibs'
+      fix_srcfile_path_GCJ='`cygpath -w "$srcfile"`'
+      enable_shared_with_static_runtimes_GCJ=yes
+      ;;
+
+    darwin* | rhapsody*)
+      case $host_os in
+        rhapsody* | darwin1.[012])
+         allow_undefined_flag_GCJ='${wl}-undefined ${wl}suppress'
+         ;;
+       *) # Darwin 1.3 on
+         if test -z ${MACOSX_DEPLOYMENT_TARGET} ; then
+           allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+         else
+           case ${MACOSX_DEPLOYMENT_TARGET} in
+             10.[012])
+               allow_undefined_flag_GCJ='${wl}-flat_namespace ${wl}-undefined ${wl}suppress'
+               ;;
+             10.*)
+               allow_undefined_flag_GCJ='${wl}-undefined ${wl}dynamic_lookup'
+               ;;
+           esac
+         fi
+         ;;
+      esac
+      archive_cmds_need_lc_GCJ=no
+      hardcode_direct_GCJ=no
+      hardcode_automatic_GCJ=yes
+      hardcode_shlibpath_var_GCJ=unsupported
+      whole_archive_flag_spec_GCJ=''
+      link_all_deplibs_GCJ=yes
+    if test "$GCC" = yes ; then
+       output_verbose_link_cmd='echo'
+        archive_cmds_GCJ='$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring'
+      module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+      # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+      archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -dynamiclib $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags -install_name $rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+      module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+    else
+      case $cc_basename in
+        xlc*)
+         output_verbose_link_cmd='echo'
+         archive_cmds_GCJ='$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}`echo $rpath/$soname` $verstring'
+         module_cmds_GCJ='$CC $allow_undefined_flag -o $lib -bundle $libobjs $deplibs$compiler_flags'
+          # Don't fix this by using the ld -exported_symbols_list flag, it doesn't exist in older darwin lds
+         archive_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC -qmkshrobj $allow_undefined_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-install_name ${wl}$rpath/$soname $verstring~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          module_expsym_cmds_GCJ='sed -e "s,#.*,," -e "s,^[    ]*,," -e "s,^\(..*\),_&," < $export_symbols > $output_objdir/${libname}-symbols.expsym~$CC $allow_undefined_flag  -o $lib -bundle $libobjs $deplibs$compiler_flags~nmedit -s $output_objdir/${libname}-symbols.expsym ${lib}'
+          ;;
+       *)
+         ld_shlibs_GCJ=no
+          ;;
+      esac
+    fi
+      ;;
+
+    dgux*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    freebsd1*)
+      ld_shlibs_GCJ=no
+      ;;
+
+    # FreeBSD 2.2.[012] allows us to include c++rt0.o to get C++ constructor
+    # support.  Future versions do this automatically, but an explicit c++rt0.o
+    # does not break anything, and helps significantly (at the cost of a little
+    # extra space).
+    freebsd2.2*)
+      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags /usr/lib/c++rt0.o'
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    # Unfortunately, older versions of FreeBSD 2 do not have this feature.
+    freebsd2*)
+      archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    # FreeBSD 3 and greater uses gcc -shared to do shared libraries.
+    freebsd* | kfreebsd*-gnu | dragonfly*)
+      archive_cmds_GCJ='$CC -shared -o $lib $libobjs $deplibs $compiler_flags'
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    hpux9*)
+      if test "$GCC" = yes; then
+       archive_cmds_GCJ='$rm $output_objdir/$soname~$CC -shared -fPIC ${wl}+b ${wl}$install_libdir -o $output_objdir/$soname $libobjs $deplibs $compiler_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      else
+       archive_cmds_GCJ='$rm $output_objdir/$soname~$LD -b +b $install_libdir -o $output_objdir/$soname $libobjs $deplibs $linker_flags~test $output_objdir/$soname = $lib || mv $output_objdir/$soname $lib'
+      fi
+      hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      hardcode_direct_GCJ=yes
+
+      # hardcode_minus_L: Not really in the search PATH,
+      # but as the default location of the library.
+      hardcode_minus_L_GCJ=yes
+      export_dynamic_flag_spec_GCJ='${wl}-E'
+      ;;
+
+    hpux10* | hpux11*)
+      if test "$GCC" = yes -a "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*|ia64*)
+         archive_cmds_GCJ='$CC -shared ${wl}+h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       *)
+         archive_cmds_GCJ='$CC -shared -fPIC ${wl}+h ${wl}$soname ${wl}+b ${wl}$install_libdir -o $lib $libobjs $deplibs $compiler_flags'
+         ;;
+       esac
+      else
+       case $host_cpu in
+       hppa*64*|ia64*)
+         archive_cmds_GCJ='$LD -b +h $soname -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       *)
+         archive_cmds_GCJ='$LD -b +h $soname +b $install_libdir -o $lib $libobjs $deplibs $linker_flags'
+         ;;
+       esac
+      fi
+      if test "$with_gnu_ld" = no; then
+       case $host_cpu in
+       hppa*64*)
+         hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+         hardcode_libdir_flag_spec_ld_GCJ='+b $libdir'
+         hardcode_libdir_separator_GCJ=:
+         hardcode_direct_GCJ=no
+         hardcode_shlibpath_var_GCJ=no
+         ;;
+       ia64*)
+         hardcode_libdir_flag_spec_GCJ='-L$libdir'
+         hardcode_direct_GCJ=no
+         hardcode_shlibpath_var_GCJ=no
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         hardcode_minus_L_GCJ=yes
+         ;;
+       *)
+         hardcode_libdir_flag_spec_GCJ='${wl}+b ${wl}$libdir'
+         hardcode_libdir_separator_GCJ=:
+         hardcode_direct_GCJ=yes
+         export_dynamic_flag_spec_GCJ='${wl}-E'
+
+         # hardcode_minus_L: Not really in the search PATH,
+         # but as the default location of the library.
+         hardcode_minus_L_GCJ=yes
+         ;;
+       esac
+      fi
+      ;;
+
+    irix5* | irix6* | nonstopux*)
+      if test "$GCC" = yes; then
+       archive_cmds_GCJ='$CC -shared $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       archive_cmds_GCJ='$LD -shared $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       hardcode_libdir_flag_spec_ld_GCJ='-rpath $libdir'
+      fi
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      link_all_deplibs_GCJ=yes
+      ;;
+
+    netbsd*)
+      if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+       archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'  # a.out
+      else
+       archive_cmds_GCJ='$LD -shared -o $lib $libobjs $deplibs $linker_flags'      # ELF
+      fi
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    newsos6)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    openbsd*)
+      hardcode_direct_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+       archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags ${wl}-retain-symbols-file,$export_symbols'
+       hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+       export_dynamic_flag_spec_GCJ='${wl}-E'
+      else
+       case $host_os in
+        openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
+          archive_cmds_GCJ='$LD -Bshareable -o $lib $libobjs $deplibs $linker_flags'
+          hardcode_libdir_flag_spec_GCJ='-R$libdir'
+          ;;
+        *)
+          archive_cmds_GCJ='$CC -shared $pic_flag -o $lib $libobjs $deplibs $compiler_flags'
+          hardcode_libdir_flag_spec_GCJ='${wl}-rpath,$libdir'
+          ;;
+       esac
+      fi
+      ;;
+
+    os2*)
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_minus_L_GCJ=yes
+      allow_undefined_flag_GCJ=unsupported
+      archive_cmds_GCJ='$echo "LIBRARY $libname INITINSTANCE" > $output_objdir/$libname.def~$echo "DESCRIPTION \"$libname\"" >> $output_objdir/$libname.def~$echo DATA >> $output_objdir/$libname.def~$echo " SINGLE NONSHARED" >> $output_objdir/$libname.def~$echo EXPORTS >> $output_objdir/$libname.def~emxexp $libobjs >> $output_objdir/$libname.def~$CC -Zdll -Zcrtdll -o $lib $libobjs $deplibs $compiler_flags $output_objdir/$libname.def'
+      old_archive_From_new_cmds_GCJ='emximp -o $output_objdir/$libname.a $output_objdir/$libname.def'
+      ;;
+
+    osf3*)
+      if test "$GCC" = yes; then
+       allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+      else
+       allow_undefined_flag_GCJ=' -expect_unresolved \*'
+       archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+      fi
+      hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      hardcode_libdir_separator_GCJ=:
+      ;;
+
+    osf4* | osf5*)     # as osf3* with the addition of -msym flag
+      if test "$GCC" = yes; then
+       allow_undefined_flag_GCJ=' ${wl}-expect_unresolved ${wl}\*'
+       archive_cmds_GCJ='$CC -shared${allow_undefined_flag} $libobjs $deplibs $compiler_flags ${wl}-msym ${wl}-soname ${wl}$soname `test -n "$verstring" && echo ${wl}-set_version ${wl}$verstring` ${wl}-update_registry ${wl}${output_objdir}/so_locations -o $lib'
+       hardcode_libdir_flag_spec_GCJ='${wl}-rpath ${wl}$libdir'
+      else
+       allow_undefined_flag_GCJ=' -expect_unresolved \*'
+       archive_cmds_GCJ='$LD -shared${allow_undefined_flag} $libobjs $deplibs $linker_flags -msym -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib'
+       archive_expsym_cmds_GCJ='for i in `cat $export_symbols`; do printf "%s %s\\n" -exported_symbol "\$i" >> $lib.exp; done; echo "-hidden">> $lib.exp~
+       $LD -shared${allow_undefined_flag} -input $lib.exp $linker_flags $libobjs $deplibs -soname $soname `test -n "$verstring" && echo -set_version $verstring` -update_registry ${output_objdir}/so_locations -o $lib~$rm $lib.exp'
+
+       # Both c and cxx compiler support -rpath directly
+       hardcode_libdir_flag_spec_GCJ='-rpath $libdir'
+      fi
+      hardcode_libdir_separator_GCJ=:
+      ;;
+
+    sco3.2v5*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_GCJ=no
+      export_dynamic_flag_spec_GCJ='${wl}-Bexport'
+      runpath_var=LD_RUN_PATH
+      hardcode_runpath_var=yes
+      ;;
+
+    solaris*)
+      no_undefined_flag_GCJ=' -z text'
+      if test "$GCC" = yes; then
+       wlarc='${wl}'
+       archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+       archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+         $CC -shared ${wl}-M ${wl}$lib.exp ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags~$rm $lib.exp'
+      else
+       wlarc=''
+       archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+       $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      fi
+      hardcode_libdir_flag_spec_GCJ='-R$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      case $host_os in
+      solaris2.[0-5] | solaris2.[0-5].*) ;;
+      *)
+       # The compiler driver will combine linker options so we
+       # cannot just pass the convience library names through
+       # without $wl, iff we do not link with $LD.
+       # Luckily, gcc supports the same syntax we need for Sun Studio.
+       # Supported since Solaris 2.6 (maybe 2.5.1?)
+       case $wlarc in
+       '')
+         whole_archive_flag_spec_GCJ='-z allextract$convenience -z defaultextract' ;;
+       *)
+         whole_archive_flag_spec_GCJ='${wl}-z ${wl}allextract`for conv in $convenience\"\"; do test -n \"$conv\" && new_convenience=\"$new_convenience,$conv\"; done; $echo \"$new_convenience\"` ${wl}-z ${wl}defaultextract' ;;
+       esac ;;
+      esac
+      link_all_deplibs_GCJ=yes
+      ;;
+
+    sunos4*)
+      if test "x$host_vendor" = xsequent; then
+       # Use $CC to link under sequent, because it throws in some extra .o
+       # files that make .init and .fini sections work.
+       archive_cmds_GCJ='$CC -G ${wl}-h $soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds_GCJ='$LD -assert pure-text -Bstatic -o $lib $libobjs $deplibs $linker_flags'
+      fi
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=yes
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    sysv4)
+      case $host_vendor in
+       sni)
+         archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct_GCJ=yes # is this really true???
+       ;;
+       siemens)
+         ## LD is ld it makes a PLAMLIB
+         ## CC just makes a GrossModule.
+         archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+         reload_cmds_GCJ='$CC -r -o $output$reload_objs'
+         hardcode_direct_GCJ=no
+        ;;
+       motorola)
+         archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+         hardcode_direct_GCJ=no #Motorola manual says yes, but my tests say they lie
+       ;;
+      esac
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    sysv4.3*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_shlibpath_var_GCJ=no
+      export_dynamic_flag_spec_GCJ='-Bexport'
+      ;;
+
+    sysv4*MP*)
+      if test -d /usr/nec; then
+       archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+       hardcode_shlibpath_var_GCJ=no
+       runpath_var=LD_RUN_PATH
+       hardcode_runpath_var=yes
+       ld_shlibs_GCJ=yes
+      fi
+      ;;
+
+    sysv4.2uw2*)
+      archive_cmds_GCJ='$LD -G -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_direct_GCJ=yes
+      hardcode_minus_L_GCJ=no
+      hardcode_shlibpath_var_GCJ=no
+      hardcode_runpath_var=yes
+      runpath_var=LD_RUN_PATH
+      ;;
+
+   sysv5OpenUNIX8* | sysv5UnixWare7* |  sysv5uw[78]* | unixware7*)
+      no_undefined_flag_GCJ='${wl}-z ${wl}text'
+      if test "$GCC" = yes; then
+       archive_cmds_GCJ='$CC -shared ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      else
+       archive_cmds_GCJ='$CC -G ${wl}-h ${wl}$soname -o $lib $libobjs $deplibs $compiler_flags'
+      fi
+      runpath_var='LD_RUN_PATH'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    sysv5*)
+      no_undefined_flag_GCJ=' -z text'
+      # $CC -shared without GNU ld will not create a library from C++
+      # object files and a static libstdc++, better avoid it by now
+      archive_cmds_GCJ='$LD -G${allow_undefined_flag} -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      archive_expsym_cmds_GCJ='$echo "{ global:" > $lib.exp~cat $export_symbols | $SED -e "s/\(.*\)/\1;/" >> $lib.exp~$echo "local: *; };" >> $lib.exp~
+               $LD -G${allow_undefined_flag} -M $lib.exp -h $soname -o $lib $libobjs $deplibs $linker_flags~$rm $lib.exp'
+      hardcode_libdir_flag_spec_GCJ=
+      hardcode_shlibpath_var_GCJ=no
+      runpath_var='LD_RUN_PATH'
+      ;;
+
+    uts4*)
+      archive_cmds_GCJ='$LD -G -h $soname -o $lib $libobjs $deplibs $linker_flags'
+      hardcode_libdir_flag_spec_GCJ='-L$libdir'
+      hardcode_shlibpath_var_GCJ=no
+      ;;
+
+    *)
+      ld_shlibs_GCJ=no
+      ;;
+    esac
+  fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ld_shlibs_GCJ" >&5
+$as_echo "$ld_shlibs_GCJ" >&6; }
+test "$ld_shlibs_GCJ" = no && can_build_shared=no
+
+variables_saved_for_relink="PATH $shlibpath_var $runpath_var"
+if test "$GCC" = yes; then
+  variables_saved_for_relink="$variables_saved_for_relink GCC_EXEC_PREFIX COMPILER_PATH LIBRARY_PATH"
+fi
+
+#
+# Do we need to explicitly link libc?
+#
+case "x$archive_cmds_need_lc_GCJ" in
+x|xyes)
+  # Assume -lc should be added
+  archive_cmds_need_lc_GCJ=yes
+
+  if test "$enable_shared" = yes && test "$GCC" = yes; then
+    case $archive_cmds_GCJ in
+    *'~'*)
+      # FIXME: we may have to deal with multi-command sequences.
+      ;;
+    '$CC '*)
+      # Test whether the compiler implicitly links with -lc since on some
+      # systems, -lgcc has to come before -lc. If gcc already passes -lc
+      # to ld, don't add -lc before -lgcc.
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether -lc should be explicitly linked in" >&5
+$as_echo_n "checking whether -lc should be explicitly linked in... " >&6; }
+      $rm conftest*
+      printf "$lt_simple_compile_test_code" > conftest.$ac_ext
+
+      if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_compile\""; } >&5
+  (eval $ac_compile) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } 2>conftest.err; then
+        soname=conftest
+        lib=conftest
+        libobjs=conftest.$ac_objext
+        deplibs=
+        wl=$lt_prog_compiler_wl_GCJ
+        compiler_flags=-v
+        linker_flags=-v
+        verstring=
+        output_objdir=.
+        libname=conftest
+        lt_save_allow_undefined_flag=$allow_undefined_flag_GCJ
+        allow_undefined_flag_GCJ=
+        if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1\""; } >&5
+  (eval $archive_cmds_GCJ 2\>\&1 \| grep \" -lc \" \>/dev/null 2\>\&1) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; }
+        then
+         archive_cmds_need_lc_GCJ=no
+        else
+         archive_cmds_need_lc_GCJ=yes
+        fi
+        allow_undefined_flag_GCJ=$lt_save_allow_undefined_flag
+      else
+        cat conftest.err 1>&5
+      fi
+      $rm conftest*
+      { $as_echo "$as_me:${as_lineno-$LINENO}: result: $archive_cmds_need_lc_GCJ" >&5
+$as_echo "$archive_cmds_need_lc_GCJ" >&6; }
+      ;;
+    esac
+  fi
+  ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking dynamic linker characteristics" >&5
+$as_echo_n "checking dynamic linker characteristics... " >&6; }
+library_names_spec=
+libname_spec='lib$name'
+soname_spec=
+shrext_cmds=".so"
+postinstall_cmds=
+postuninstall_cmds=
+finish_cmds=
+finish_eval=
+shlibpath_var=
+shlibpath_overrides_runpath=unknown
+version_type=none
+dynamic_linker="$host_os ld.so"
+sys_lib_dlsearch_path_spec="/lib /usr/lib"
+if test "$GCC" = yes; then
+  sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+  if echo "$sys_lib_search_path_spec" | grep ';' >/dev/null ; then
+    # if the path contains ";" then we assume it to be the separator
+    # otherwise default to the standard path separator (i.e. ":") - it is
+    # assumed that no part of a normal pathname contains ";" but that should
+    # okay in the real world where ";" in dirpaths is itself problematic.
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+  else
+    sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+  fi
+else
+  sys_lib_search_path_spec="/lib /usr/lib /usr/local/lib"
+fi
+need_lib_prefix=unknown
+hardcode_into_libs=no
+
+# when you set need_version to no, make sure it does not cause -set_version
+# flags to be left without arguments
+need_version=unknown
+
+case $host_os in
+aix3*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix $libname.a'
+  shlibpath_var=LIBPATH
+
+  # AIX 3 has no versioning support, so we append a major version to the name.
+  soname_spec='${libname}${release}${shared_ext}$major'
+  ;;
+
+aix4* | aix5*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  hardcode_into_libs=yes
+  if test "$host_cpu" = ia64; then
+    # AIX 5 supports IA64
+    library_names_spec='${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext}$versuffix $libname${shared_ext}'
+    shlibpath_var=LD_LIBRARY_PATH
+  else
+    # With GCC up to 2.95.x, collect2 would create an import file
+    # for dependence libraries.  The import file would start with
+    # the line `#! .'.  This would cause the generated library to
+    # depend on `.', always an invalid library.  This was fixed in
+    # development snapshots of GCC prior to 3.0.
+    case $host_os in
+      aix4 | aix4.[01] | aix4.[01].*)
+      if { echo '#if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 97)'
+          echo ' yes '
+          echo '#endif'; } | ${CC} -E - | grep yes > /dev/null; then
+       :
+      else
+       can_build_shared=no
+      fi
+      ;;
+    esac
+    # AIX (on Power*) has no versioning support, so currently we can not hardcode correct
+    # soname into executable. Probably we can add versioning support to
+    # collect2, so additional links can be useful in future.
+    if test "$aix_use_runtimelinking" = yes; then
+      # If using run time linking (on AIX 4.2 or later) use lib<name>.so
+      # instead of lib<name>.a to let people know that these are not
+      # typical AIX shared libraries.
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    else
+      # We preserve .a as extension for shared libraries through AIX4.2
+      # and later when we are not doing run time linking.
+      library_names_spec='${libname}${release}.a $libname.a'
+      soname_spec='${libname}${release}${shared_ext}$major'
+    fi
+    shlibpath_var=LIBPATH
+  fi
+  ;;
+
+amigaos*)
+  library_names_spec='$libname.ixlibrary $libname.a'
+  # Create ${libname}_ixlibrary.a entries in /sys/libs.
+  finish_eval='for lib in `ls $libdir/*.ixlibrary 2>/dev/null`; do libname=`$echo "X$lib" | $Xsed -e '\''s%^.*/\([^/]*\)\.ixlibrary$%\1%'\''`; test $rm /sys/libs/${libname}_ixlibrary.a; $show "cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a"; cd /sys/libs && $LN_S $lib ${libname}_ixlibrary.a || exit 1; done'
+  ;;
+
+beos*)
+  library_names_spec='${libname}${shared_ext}'
+  dynamic_linker="$host_os ld.so"
+  shlibpath_var=LIBRARY_PATH
+  ;;
+
+bsdi[45]*)
+  version_type=linux
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/shlib /usr/lib /usr/X11/lib /usr/contrib/lib /lib /usr/local/lib"
+  sys_lib_dlsearch_path_spec="/shlib /usr/lib /usr/local/lib"
+  # the default ld.so.conf also contains /usr/contrib/lib and
+  # /usr/X11R6/lib (/usr/X11 is a link to /usr/X11R6), but let us allow
+  # libtool to hard-code these into programs
+  ;;
+
+cygwin* | mingw* | pw32*)
+  version_type=windows
+  shrext_cmds=".dll"
+  need_version=no
+  need_lib_prefix=no
+
+  case $GCC,$host_os in
+  yes,cygwin* | yes,mingw* | yes,pw32*)
+    library_names_spec='$libname.dll.a'
+    # DLL is installed to $(libdir)/../bin by postinstall_cmds
+    postinstall_cmds='base_file=`basename \${file}`~
+      dlpath=`$SHELL 2>&1 -c '\''. $dir/'\''\${base_file}'\''i;echo \$dlname'\''`~
+      dldir=$destdir/`dirname \$dlpath`~
+      test -d \$dldir || mkdir -p \$dldir~
+      $install_prog $dir/$dlname \$dldir/$dlname~
+      chmod a+x \$dldir/$dlname'
+    postuninstall_cmds='dldll=`$SHELL 2>&1 -c '\''. $file; echo \$dlname'\''`~
+      dlpath=$dir/\$dldll~
+       $rm \$dlpath'
+    shlibpath_overrides_runpath=yes
+
+    case $host_os in
+    cygwin*)
+      # Cygwin DLLs use 'cyg' prefix rather than 'lib'
+      soname_spec='`echo ${libname} | sed -e 's/^lib/cyg/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec="/usr/lib /lib/w32api /lib /usr/local/lib"
+      ;;
+    mingw*)
+      # MinGW DLLs use traditional 'lib' prefix
+      soname_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      sys_lib_search_path_spec=`$CC -print-search-dirs | grep "^libraries:" | $SED -e "s/^libraries://" -e "s,=/,/,g"`
+      if echo "$sys_lib_search_path_spec" | grep ';[c-zC-Z]:/' >/dev/null; then
+        # It is most probably a Windows format PATH printed by
+        # mingw gcc, but we are running on Cygwin. Gcc prints its search
+        # path with ; separators, and with drive letters. We can handle the
+        # drive letters (cygwin fileutils understands them), so leave them,
+        # especially as we might pass files found there to a mingw objdump,
+        # which wouldn't understand a cygwinified path. Ahh.
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED -e 's/;/ /g'`
+      else
+        sys_lib_search_path_spec=`echo "$sys_lib_search_path_spec" | $SED  -e "s/$PATH_SEPARATOR/ /g"`
+      fi
+      ;;
+    pw32*)
+      # pw32 DLLs use 'pw' prefix rather than 'lib'
+      library_names_spec='`echo ${libname} | sed -e 's/^lib/pw/'``echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext}'
+      ;;
+    esac
+    ;;
+
+  *)
+    library_names_spec='${libname}`echo ${release} | $SED -e 's/[.]/-/g'`${versuffix}${shared_ext} $libname.lib'
+    ;;
+  esac
+  dynamic_linker='Win32 ld.exe'
+  # FIXME: first we should search . and the directory the executable is in
+  shlibpath_var=PATH
+  ;;
+
+darwin* | rhapsody*)
+  dynamic_linker="$host_os dyld"
+  version_type=darwin
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${versuffix}$shared_ext ${libname}${release}${major}$shared_ext ${libname}$shared_ext'
+  soname_spec='${libname}${release}${major}$shared_ext'
+  shlibpath_overrides_runpath=yes
+  shlibpath_var=DYLD_LIBRARY_PATH
+  shrext_cmds='`test .$module = .yes && echo .so || echo .dylib`'
+  # Apple's gcc prints 'gcc -print-search-dirs' doesn't operate the same.
+  if test "$GCC" = yes; then
+    sys_lib_search_path_spec=`$CC -print-search-dirs | tr "\n" "$PATH_SEPARATOR" | sed -e 's/libraries:/@libraries:/' | tr "@" "\n" | grep "^libraries:" | sed -e "s/^libraries://" -e "s,=/,/,g" -e "s,$PATH_SEPARATOR, ,g" -e "s,.*,& /lib /usr/lib /usr/local/lib,g"`
+  else
+    sys_lib_search_path_spec='/lib /usr/lib /usr/local/lib'
+  fi
+  sys_lib_dlsearch_path_spec='/usr/local/lib /lib /usr/lib'
+  ;;
+
+dgux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname$shared_ext'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+freebsd1*)
+  dynamic_linker=no
+  ;;
+
+kfreebsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+freebsd* | dragonfly*)
+  # DragonFly does not have aout.  When/if they implement a new
+  # versioning mechanism, adjust this.
+  if test -x /usr/bin/objformat; then
+    objformat=`/usr/bin/objformat`
+  else
+    case $host_os in
+    freebsd[123]*) objformat=aout ;;
+    *) objformat=elf ;;
+    esac
+  fi
+  version_type=freebsd-$objformat
+  case $version_type in
+    freebsd-elf*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext} $libname${shared_ext}'
+      need_version=no
+      need_lib_prefix=no
+      ;;
+    freebsd-*)
+      library_names_spec='${libname}${release}${shared_ext}$versuffix $libname${shared_ext}$versuffix'
+      need_version=yes
+      ;;
+  esac
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_os in
+  freebsd2*)
+    shlibpath_overrides_runpath=yes
+    ;;
+  freebsd3.[01]* | freebsdelf3.[01]*)
+    shlibpath_overrides_runpath=yes
+    hardcode_into_libs=yes
+    ;;
+  *) # from 3.2 on
+    shlibpath_overrides_runpath=no
+    hardcode_into_libs=yes
+    ;;
+  esac
+  ;;
+
+gnu*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}${major} ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  hardcode_into_libs=yes
+  ;;
+
+hpux9* | hpux10* | hpux11*)
+  # Give a soname corresponding to the major version so that dld.sl refuses to
+  # link against other versions.
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  case $host_cpu in
+  ia64*)
+    shrext_cmds='.so'
+    hardcode_into_libs=yes
+    dynamic_linker="$host_os dld.so"
+    shlibpath_var=LD_LIBRARY_PATH
+    shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    if test "X$HPUX_IA64_MODE" = X32; then
+      sys_lib_search_path_spec="/usr/lib/hpux32 /usr/local/lib/hpux32 /usr/local/lib"
+    else
+      sys_lib_search_path_spec="/usr/lib/hpux64 /usr/local/lib/hpux64"
+    fi
+    sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+    ;;
+   hppa*64*)
+     shrext_cmds='.sl'
+     hardcode_into_libs=yes
+     dynamic_linker="$host_os dld.sl"
+     shlibpath_var=LD_LIBRARY_PATH # How should we handle SHLIB_PATH
+     shlibpath_overrides_runpath=yes # Unless +noenvvar is specified.
+     library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+     soname_spec='${libname}${release}${shared_ext}$major'
+     sys_lib_search_path_spec="/usr/lib/pa20_64 /usr/ccs/lib/pa20_64"
+     sys_lib_dlsearch_path_spec=$sys_lib_search_path_spec
+     ;;
+   *)
+    shrext_cmds='.sl'
+    dynamic_linker="$host_os dld.sl"
+    shlibpath_var=SHLIB_PATH
+    shlibpath_overrides_runpath=no # +s is required to enable SHLIB_PATH
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    ;;
+  esac
+  # HP-UX runs *really* slowly unless shared libraries are mode 555.
+  postinstall_cmds='chmod 555 $lib'
+  ;;
+
+irix5* | irix6* | nonstopux*)
+  case $host_os in
+    nonstopux*) version_type=nonstopux ;;
+    *)
+       if test "$lt_cv_prog_gnu_ld" = yes; then
+               version_type=linux
+       else
+               version_type=irix
+       fi ;;
+  esac
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${release}${shared_ext} $libname${shared_ext}'
+  case $host_os in
+  irix5* | nonstopux*)
+    libsuff= shlibsuff=
+    ;;
+  *)
+    case $LD in # libtool.m4 will add one of these switches to LD
+    *-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ")
+      libsuff= shlibsuff= libmagic=32-bit;;
+    *-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ")
+      libsuff=32 shlibsuff=N32 libmagic=N32;;
+    *-64|*"-64 "|*-melf64bmip|*"-melf64bmip ")
+      libsuff=64 shlibsuff=64 libmagic=64-bit;;
+    *) libsuff= shlibsuff= libmagic=never-match;;
+    esac
+    ;;
+  esac
+  shlibpath_var=LD_LIBRARY${shlibsuff}_PATH
+  shlibpath_overrides_runpath=no
+  sys_lib_search_path_spec="/usr/lib${libsuff} /lib${libsuff} /usr/local/lib${libsuff}"
+  sys_lib_dlsearch_path_spec="/usr/lib${libsuff} /lib${libsuff}"
+  hardcode_into_libs=yes
+  ;;
+
+# No shared lib support for Linux oldld, aout, or coff.
+linux*oldld* | linux*aout* | linux*coff*)
+  dynamic_linker=no
+  ;;
+
+# This must be Linux ELF.
+linux*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -n $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  # This implies no fast_install, which is unacceptable.
+  # Some rework will be needed to allow for fast_install
+  # before this can be enabled.
+  hardcode_into_libs=yes
+
+  # Append ld.so.conf contents to the search path
+  if test -f /etc/ld.so.conf; then
+    lt_ld_extra=`awk '/^include / { system(sprintf("cd /etc; cat %s", \$2)); skip = 1; } { if (!skip) print \$0; skip = 0; }' < /etc/ld.so.conf | $SED -e 's/#.*//;s/[:,       ]/ /g;s/=[^=]*$//;s/=[^= ]* / /g;/^$/d' | tr '\n' ' '`
+    sys_lib_dlsearch_path_spec="/lib /usr/lib $lt_ld_extra"
+  fi
+
+  # We used to test for /lib/ld.so.1 and disable shared libraries on
+  # powerpc, because MkLinux only supported shared libraries with the
+  # GNU dynamic linker.  Since this was broken with cross compilers,
+  # most powerpc-linux boxes support dynamic linking these days and
+  # people can always --disable-shared, the test was removed, and we
+  # assume the GNU/Linux dynamic linker is in use.
+  dynamic_linker='GNU/Linux ld.so'
+  ;;
+
+knetbsd*-gnu)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=no
+  hardcode_into_libs=yes
+  dynamic_linker='GNU ld.so'
+  ;;
+
+netbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  need_version=no
+  if echo __ELF__ | $CC -E - | grep __ELF__ >/dev/null; then
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+    finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+    dynamic_linker='NetBSD (a.out) ld.so'
+  else
+    library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major ${libname}${shared_ext}'
+    soname_spec='${libname}${release}${shared_ext}$major'
+    dynamic_linker='NetBSD ld.elf_so'
+  fi
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  ;;
+
+newsos6)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+nto-qnx*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  ;;
+
+openbsd*)
+  version_type=sunos
+  need_lib_prefix=no
+  # Some older versions of OpenBSD (3.3 at least) *do* need versioned libs.
+  case $host_os in
+    openbsd3.3 | openbsd3.3.*) need_version=yes ;;
+    *)                         need_version=no  ;;
+  esac
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/sbin" ldconfig -m $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
+    case $host_os in
+      openbsd2.[89] | openbsd2.[89].*)
+       shlibpath_overrides_runpath=no
+       ;;
+      *)
+       shlibpath_overrides_runpath=yes
+       ;;
+      esac
+  else
+    shlibpath_overrides_runpath=yes
+  fi
+  ;;
+
+os2*)
+  libname_spec='$name'
+  shrext_cmds=".dll"
+  need_lib_prefix=no
+  library_names_spec='$libname${shared_ext} $libname.a'
+  dynamic_linker='OS/2 ld.exe'
+  shlibpath_var=LIBPATH
+  ;;
+
+osf3* | osf4* | osf5*)
+  version_type=osf
+  need_lib_prefix=no
+  need_version=no
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  sys_lib_search_path_spec="/usr/shlib /usr/ccs/lib /usr/lib/cmplrs/cc /usr/lib /usr/local/lib /var/shlib"
+  sys_lib_dlsearch_path_spec="$sys_lib_search_path_spec"
+  ;;
+
+sco3.2v5*)
+  version_type=osf
+  soname_spec='${libname}${release}${shared_ext}$major'
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+solaris*)
+  version_type=linux
+  need_lib_prefix=no
+  need_version=no
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  hardcode_into_libs=yes
+  # ldd complains unless libraries are executable
+  postinstall_cmds='chmod +x $lib'
+  ;;
+
+sunos4*)
+  version_type=sunos
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${shared_ext}$versuffix'
+  finish_cmds='PATH="\$PATH:/usr/etc" ldconfig $libdir'
+  shlibpath_var=LD_LIBRARY_PATH
+  shlibpath_overrides_runpath=yes
+  if test "$with_gnu_ld" = yes; then
+    need_lib_prefix=no
+  fi
+  need_version=yes
+  ;;
+
+sysv4 | sysv4.2uw2* | sysv4.3* | sysv5*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  case $host_vendor in
+    sni)
+      shlibpath_overrides_runpath=no
+      need_lib_prefix=no
+      export_dynamic_flag_spec='${wl}-Blargedynsym'
+      runpath_var=LD_RUN_PATH
+      ;;
+    siemens)
+      need_lib_prefix=no
+      ;;
+    motorola)
+      need_lib_prefix=no
+      need_version=no
+      shlibpath_overrides_runpath=no
+      sys_lib_search_path_spec='/lib /usr/lib /usr/ccs/lib'
+      ;;
+  esac
+  ;;
+
+sysv4*MP*)
+  if test -d /usr/nec ;then
+    version_type=linux
+    library_names_spec='$libname${shared_ext}.$versuffix $libname${shared_ext}.$major $libname${shared_ext}'
+    soname_spec='$libname${shared_ext}.$major'
+    shlibpath_var=LD_LIBRARY_PATH
+  fi
+  ;;
+
+uts4*)
+  version_type=linux
+  library_names_spec='${libname}${release}${shared_ext}$versuffix ${libname}${release}${shared_ext}$major $libname${shared_ext}'
+  soname_spec='${libname}${release}${shared_ext}$major'
+  shlibpath_var=LD_LIBRARY_PATH
+  ;;
+
+*)
+  dynamic_linker=no
+  ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $dynamic_linker" >&5
+$as_echo "$dynamic_linker" >&6; }
+test "$dynamic_linker" = no && can_build_shared=no
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking how to hardcode library paths into programs" >&5
+$as_echo_n "checking how to hardcode library paths into programs... " >&6; }
+hardcode_action_GCJ=
+if test -n "$hardcode_libdir_flag_spec_GCJ" || \
+   test -n "$runpath_var_GCJ" || \
+   test "X$hardcode_automatic_GCJ" = "Xyes" ; then
+
+  # We can hardcode non-existant directories.
+  if test "$hardcode_direct_GCJ" != no &&
+     # If the only mechanism to avoid hardcoding is shlibpath_var, we
+     # have to relink, otherwise we might link with an installed library
+     # when we should be linking with a yet-to-be-installed one
+     ## test "$_LT_AC_TAGVAR(hardcode_shlibpath_var, GCJ)" != no &&
+     test "$hardcode_minus_L_GCJ" != no; then
+    # Linking always hardcodes the temporary library directory.
+    hardcode_action_GCJ=relink
+  else
+    # We can link without hardcoding, and we can hardcode nonexisting dirs.
+    hardcode_action_GCJ=immediate
+  fi
+else
+  # We cannot hardcode anything, or else we can only hardcode existing
+  # directories.
+  hardcode_action_GCJ=unsupported
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $hardcode_action_GCJ" >&5
+$as_echo "$hardcode_action_GCJ" >&6; }
+
+if test "$hardcode_action_GCJ" = relink; then
+  # Fast installation is not supported
+  enable_fast_install=no
+elif test "$shlibpath_overrides_runpath" = yes ||
+     test "$enable_shared" = no; then
+  # Fast installation is not necessary
+  enable_fast_install=needless
+fi
+
+striplib=
+old_striplib=
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether stripping libraries is possible" >&5
+$as_echo_n "checking whether stripping libraries is possible... " >&6; }
+if test -n "$STRIP" && $STRIP -V 2>&1 | grep "GNU strip" >/dev/null; then
+  test -z "$old_striplib" && old_striplib="$STRIP --strip-debug"
+  test -z "$striplib" && striplib="$STRIP --strip-unneeded"
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+else
+# FIXME - insert some real tests, host_os isn't really good enough
+  case $host_os in
+   darwin*)
+       if test -n "$STRIP" ; then
+         striplib="$STRIP -x"
+         { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
+$as_echo "yes" >&6; }
+       else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+fi
+       ;;
+   *)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5
+$as_echo "no" >&6; }
+    ;;
+  esac
+fi
+
+if test "x$enable_dlopen" != xyes; then
+  enable_dlopen=unknown
+  enable_dlopen_self=unknown
+  enable_dlopen_self_static=unknown
+else
+  lt_cv_dlopen=no
+  lt_cv_dlopen_libs=
+
+  case $host_os in
+  beos*)
+    lt_cv_dlopen="load_add_on"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+    ;;
+
+  mingw* | pw32*)
+    lt_cv_dlopen="LoadLibrary"
+    lt_cv_dlopen_libs=
+   ;;
+
+  cygwin*)
+    lt_cv_dlopen="dlopen"
+    lt_cv_dlopen_libs=
+   ;;
+
+  darwin*)
+  # if libdl is installed we need to link against it
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+
+    lt_cv_dlopen="dyld"
+    lt_cv_dlopen_libs=
+    lt_cv_dlopen_self=yes
+
+fi
+
+   ;;
+
+  *)
+    ac_fn_c_check_func "$LINENO" "shl_load" "ac_cv_func_shl_load"
+if test "x$ac_cv_func_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for shl_load in -ldld" >&5
+$as_echo_n "checking for shl_load in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_shl_load+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char shl_load ();
+int
+main ()
+{
+return shl_load ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_shl_load=yes
+else
+  ac_cv_lib_dld_shl_load=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_shl_load" >&5
+$as_echo "$ac_cv_lib_dld_shl_load" >&6; }
+if test "x$ac_cv_lib_dld_shl_load" = x""yes; then :
+  lt_cv_dlopen="shl_load" lt_cv_dlopen_libs="-dld"
+else
+  ac_fn_c_check_func "$LINENO" "dlopen" "ac_cv_func_dlopen"
+if test "x$ac_cv_func_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -ldl" >&5
+$as_echo_n "checking for dlopen in -ldl... " >&6; }
+if test "${ac_cv_lib_dl_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldl  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dl_dlopen=yes
+else
+  ac_cv_lib_dl_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dl_dlopen" >&5
+$as_echo "$ac_cv_lib_dl_dlopen" >&6; }
+if test "x$ac_cv_lib_dl_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-ldl"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dlopen in -lsvld" >&5
+$as_echo_n "checking for dlopen in -lsvld... " >&6; }
+if test "${ac_cv_lib_svld_dlopen+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lsvld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dlopen ();
+int
+main ()
+{
+return dlopen ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_svld_dlopen=yes
+else
+  ac_cv_lib_svld_dlopen=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_svld_dlopen" >&5
+$as_echo "$ac_cv_lib_svld_dlopen" >&6; }
+if test "x$ac_cv_lib_svld_dlopen" = x""yes; then :
+  lt_cv_dlopen="dlopen" lt_cv_dlopen_libs="-lsvld"
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for dld_link in -ldld" >&5
+$as_echo_n "checking for dld_link in -ldld... " >&6; }
+if test "${ac_cv_lib_dld_dld_link+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-ldld  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char dld_link ();
+int
+main ()
+{
+return dld_link ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_dld_dld_link=yes
+else
+  ac_cv_lib_dld_dld_link=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_dld_dld_link" >&5
+$as_echo "$ac_cv_lib_dld_dld_link" >&6; }
+if test "x$ac_cv_lib_dld_dld_link" = x""yes; then :
+  lt_cv_dlopen="dld_link" lt_cv_dlopen_libs="-dld"
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+
+fi
+
+    ;;
+  esac
+
+  if test "x$lt_cv_dlopen" != xno; then
+    enable_dlopen=yes
+  else
+    enable_dlopen=no
+  fi
+
+  case $lt_cv_dlopen in
+  dlopen)
+    save_CPPFLAGS="$CPPFLAGS"
+    test "x$ac_cv_header_dlfcn_h" = xyes && CPPFLAGS="$CPPFLAGS -DHAVE_DLFCN_H"
+
+    save_LDFLAGS="$LDFLAGS"
+    eval LDFLAGS=\"\$LDFLAGS $export_dynamic_flag_spec\"
+
+    save_LIBS="$LIBS"
+    LIBS="$lt_cv_dlopen_libs $LIBS"
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a program can dlopen itself" >&5
+$as_echo_n "checking whether a program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 11446 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self" >&5
+$as_echo "$lt_cv_dlopen_self" >&6; }
+
+    if test "x$lt_cv_dlopen_self" = xyes; then
+      LDFLAGS="$LDFLAGS $link_static_flag"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a statically linked program can dlopen itself" >&5
+$as_echo_n "checking whether a statically linked program can dlopen itself... " >&6; }
+if test "${lt_cv_dlopen_self_static+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+         if test "$cross_compiling" = yes; then :
+  lt_cv_dlopen_self_static=cross
+else
+  lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2
+  lt_status=$lt_dlunknown
+  cat > conftest.$ac_ext <<EOF
+#line 11544 "configure"
+#include "confdefs.h"
+
+#if HAVE_DLFCN_H
+#include <dlfcn.h>
+#endif
+
+#include <stdio.h>
+
+#ifdef RTLD_GLOBAL
+#  define LT_DLGLOBAL          RTLD_GLOBAL
+#else
+#  ifdef DL_GLOBAL
+#    define LT_DLGLOBAL                DL_GLOBAL
+#  else
+#    define LT_DLGLOBAL                0
+#  endif
+#endif
+
+/* We may have to define LT_DLLAZY_OR_NOW in the command line if we
+   find out it does not work in some platform. */
+#ifndef LT_DLLAZY_OR_NOW
+#  ifdef RTLD_LAZY
+#    define LT_DLLAZY_OR_NOW           RTLD_LAZY
+#  else
+#    ifdef DL_LAZY
+#      define LT_DLLAZY_OR_NOW         DL_LAZY
+#    else
+#      ifdef RTLD_NOW
+#        define LT_DLLAZY_OR_NOW       RTLD_NOW
+#      else
+#        ifdef DL_NOW
+#          define LT_DLLAZY_OR_NOW     DL_NOW
+#        else
+#          define LT_DLLAZY_OR_NOW     0
+#        endif
+#      endif
+#    endif
+#  endif
+#endif
+
+#ifdef __cplusplus
+extern "C" void exit (int);
+#endif
+
+void fnord() { int i=42;}
+int main ()
+{
+  void *self = dlopen (0, LT_DLGLOBAL|LT_DLLAZY_OR_NOW);
+  int status = $lt_dlunknown;
+
+  if (self)
+    {
+      if (dlsym (self,"fnord"))       status = $lt_dlno_uscore;
+      else if (dlsym( self,"_fnord")) status = $lt_dlneed_uscore;
+      /* dlclose (self); */
+    }
+
+    exit (status);
+}
+EOF
+  if { { eval echo "\"\$as_me\":${as_lineno-$LINENO}: \"$ac_link\""; } >&5
+  (eval $ac_link) 2>&5
+  ac_status=$?
+  $as_echo "$as_me:${as_lineno-$LINENO}: \$? = $ac_status" >&5
+  test $ac_status = 0; } && test -s conftest${ac_exeext} 2>/dev/null; then
+    (./conftest; exit; ) >&5 2>/dev/null
+    lt_status=$?
+    case x$lt_status in
+      x$lt_dlno_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_dlneed_uscore) lt_cv_dlopen_self_static=yes ;;
+      x$lt_unknown|x*) lt_cv_dlopen_self_static=no ;;
+    esac
+  else :
+    # compilation failed
+    lt_cv_dlopen_self_static=no
+  fi
+fi
+rm -fr conftest*
+
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lt_cv_dlopen_self_static" >&5
+$as_echo "$lt_cv_dlopen_self_static" >&6; }
+    fi
+
+    CPPFLAGS="$save_CPPFLAGS"
+    LDFLAGS="$save_LDFLAGS"
+    LIBS="$save_LIBS"
+    ;;
+  esac
+
+  case $lt_cv_dlopen_self in
+  yes|no) enable_dlopen_self=$lt_cv_dlopen_self ;;
+  *) enable_dlopen_self=unknown ;;
+  esac
+
+  case $lt_cv_dlopen_self_static in
+  yes|no) enable_dlopen_self_static=$lt_cv_dlopen_self_static ;;
+  *) enable_dlopen_self_static=unknown ;;
+  esac
+fi
+
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler_GCJ \
+    CC_GCJ \
+    LD_GCJ \
+    lt_prog_compiler_wl_GCJ \
+    lt_prog_compiler_pic_GCJ \
+    lt_prog_compiler_static_GCJ \
+    lt_prog_compiler_no_builtin_flag_GCJ \
+    export_dynamic_flag_spec_GCJ \
+    thread_safe_flag_spec_GCJ \
+    whole_archive_flag_spec_GCJ \
+    enable_shared_with_static_runtimes_GCJ \
+    old_archive_cmds_GCJ \
+    old_archive_from_new_cmds_GCJ \
+    predep_objects_GCJ \
+    postdep_objects_GCJ \
+    predeps_GCJ \
+    postdeps_GCJ \
+    compiler_lib_search_path_GCJ \
+    archive_cmds_GCJ \
+    archive_expsym_cmds_GCJ \
+    postinstall_cmds_GCJ \
+    postuninstall_cmds_GCJ \
+    old_archive_from_expsyms_cmds_GCJ \
+    allow_undefined_flag_GCJ \
+    no_undefined_flag_GCJ \
+    export_symbols_cmds_GCJ \
+    hardcode_libdir_flag_spec_GCJ \
+    hardcode_libdir_flag_spec_ld_GCJ \
+    hardcode_libdir_separator_GCJ \
+    hardcode_automatic_GCJ \
+    module_cmds_GCJ \
+    module_expsym_cmds_GCJ \
+    lt_cv_prog_compiler_c_o_GCJ \
+    exclude_expsyms_GCJ \
+    include_expsyms_GCJ; do
+
+    case $var in
+    old_archive_cmds_GCJ | \
+    old_archive_from_new_cmds_GCJ | \
+    archive_cmds_GCJ | \
+    archive_expsym_cmds_GCJ | \
+    module_cmds_GCJ | \
+    module_expsym_cmds_GCJ | \
+    old_archive_from_expsyms_cmds_GCJ | \
+    export_symbols_cmds_GCJ | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="$ofile"
+
+  cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_GCJ
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_GCJ
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler_GCJ
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_GCJ
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_GCJ
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_GCJ
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_GCJ
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_GCJ
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_GCJ
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_GCJ
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_GCJ
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_GCJ
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_GCJ
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds_GCJ
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_GCJ
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_GCJ
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_GCJ
+archive_expsym_cmds=$lt_archive_expsym_cmds_GCJ
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_GCJ
+module_expsym_cmds=$lt_module_expsym_cmds_GCJ
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_GCJ
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_GCJ
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_GCJ
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_GCJ
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_GCJ
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_GCJ
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_GCJ
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_GCJ
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_GCJ
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_GCJ
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_GCJ
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_GCJ
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_GCJ
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_GCJ
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_GCJ
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_GCJ
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path_GCJ"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_GCJ
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_GCJ
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_GCJ
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_GCJ
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+       else
+         tagname=""
+       fi
+       ;;
+
+      RC)
+
+
+# Source file extension for RC test sources.
+ac_ext=rc
+
+# Object file extension for compiled RC test sources.
+objext=o
+objext_RC=$objext
+
+# Code to be used in simple compile tests
+lt_simple_compile_test_code='sample MENU { MENUITEM "&Soup", 100, CHECKED }\n'
+
+# Code to be used in simple link tests
+lt_simple_link_test_code="$lt_simple_compile_test_code"
+
+# ltmain only uses $CC for tagged configurations so make sure $CC is set.
+
+# If no C compiler was specified, use CC.
+LTCC=${LTCC-"$CC"}
+
+# Allow CC to be a program name with arguments.
+compiler=$CC
+
+
+# save warnings/boilerplate of simple test code
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_compile_test_code" >conftest.$ac_ext
+eval "$ac_compile" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_compiler_boilerplate=`cat conftest.err`
+$rm conftest*
+
+ac_outfile=conftest.$ac_objext
+printf "$lt_simple_link_test_code" >conftest.$ac_ext
+eval "$ac_link" 2>&1 >/dev/null | $SED '/^$/d' >conftest.err
+_lt_linker_boilerplate=`cat conftest.err`
+$rm conftest*
+
+
+# Allow CC to be a program name with arguments.
+lt_save_CC="$CC"
+CC=${RC-"windres"}
+compiler=$CC
+compiler_RC=$CC
+for cc_temp in $compiler""; do
+  case $cc_temp in
+    compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
+    distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
+    \-*) ;;
+    *) break;;
+  esac
+done
+cc_basename=`$echo "X$cc_temp" | $Xsed -e 's%.*/%%' -e "s%^$host_alias-%%"`
+
+lt_cv_prog_compiler_c_o_RC=yes
+
+# The else clause should only fire when bootstrapping the
+# libtool distribution, otherwise you forgot to ship ltmain.sh
+# with your package, and you will get complaints that there are
+# no rules to generate ltmain.sh.
+if test -f "$ltmain"; then
+  # See if we are running on zsh, and set the options which allow our commands through
+  # without removal of \ escapes.
+  if test -n "${ZSH_VERSION+set}" ; then
+    setopt NO_GLOB_SUBST
+  fi
+  # Now quote all the things that may contain metacharacters while being
+  # careful not to overquote the AC_SUBSTed values.  We take copies of the
+  # variables and quote the copies for generation of the libtool script.
+  for var in echo old_CC old_CFLAGS AR AR_FLAGS EGREP RANLIB LN_S LTCC NM \
+    SED SHELL STRIP \
+    libname_spec library_names_spec soname_spec extract_expsyms_cmds \
+    old_striplib striplib file_magic_cmd finish_cmds finish_eval \
+    deplibs_check_method reload_flag reload_cmds need_locks \
+    lt_cv_sys_global_symbol_pipe lt_cv_sys_global_symbol_to_cdecl \
+    lt_cv_sys_global_symbol_to_c_name_address \
+    sys_lib_search_path_spec sys_lib_dlsearch_path_spec \
+    old_postinstall_cmds old_postuninstall_cmds \
+    compiler_RC \
+    CC_RC \
+    LD_RC \
+    lt_prog_compiler_wl_RC \
+    lt_prog_compiler_pic_RC \
+    lt_prog_compiler_static_RC \
+    lt_prog_compiler_no_builtin_flag_RC \
+    export_dynamic_flag_spec_RC \
+    thread_safe_flag_spec_RC \
+    whole_archive_flag_spec_RC \
+    enable_shared_with_static_runtimes_RC \
+    old_archive_cmds_RC \
+    old_archive_from_new_cmds_RC \
+    predep_objects_RC \
+    postdep_objects_RC \
+    predeps_RC \
+    postdeps_RC \
+    compiler_lib_search_path_RC \
+    archive_cmds_RC \
+    archive_expsym_cmds_RC \
+    postinstall_cmds_RC \
+    postuninstall_cmds_RC \
+    old_archive_from_expsyms_cmds_RC \
+    allow_undefined_flag_RC \
+    no_undefined_flag_RC \
+    export_symbols_cmds_RC \
+    hardcode_libdir_flag_spec_RC \
+    hardcode_libdir_flag_spec_ld_RC \
+    hardcode_libdir_separator_RC \
+    hardcode_automatic_RC \
+    module_cmds_RC \
+    module_expsym_cmds_RC \
+    lt_cv_prog_compiler_c_o_RC \
+    exclude_expsyms_RC \
+    include_expsyms_RC; do
+
+    case $var in
+    old_archive_cmds_RC | \
+    old_archive_from_new_cmds_RC | \
+    archive_cmds_RC | \
+    archive_expsym_cmds_RC | \
+    module_cmds_RC | \
+    module_expsym_cmds_RC | \
+    old_archive_from_expsyms_cmds_RC | \
+    export_symbols_cmds_RC | \
+    extract_expsyms_cmds | reload_cmds | finish_cmds | \
+    postinstall_cmds | postuninstall_cmds | \
+    old_postinstall_cmds | old_postuninstall_cmds | \
+    sys_lib_search_path_spec | sys_lib_dlsearch_path_spec)
+      # Double-quote double-evaled strings.
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$double_quote_subst\" -e \"\$sed_quote_subst\" -e \"\$delay_variable_subst\"\`\\\""
+      ;;
+    *)
+      eval "lt_$var=\\\"\`\$echo \"X\$$var\" | \$Xsed -e \"\$sed_quote_subst\"\`\\\""
+      ;;
+    esac
+  done
+
+  case $lt_echo in
+  *'\$0 --fallback-echo"')
+    lt_echo=`$echo "X$lt_echo" | $Xsed -e 's/\\\\\\\$0 --fallback-echo"$/$0 --fallback-echo"/'`
+    ;;
+  esac
+
+cfgfile="$ofile"
+
+  cat <<__EOF__ >> "$cfgfile"
+# ### BEGIN LIBTOOL TAG CONFIG: $tagname
+
+# Libtool was configured on host `(hostname || uname -n) 2>/dev/null | sed 1q`:
+
+# Shell to use when invoking shell scripts.
+SHELL=$lt_SHELL
+
+# Whether or not to build shared libraries.
+build_libtool_libs=$enable_shared
+
+# Whether or not to build static libraries.
+build_old_libs=$enable_static
+
+# Whether or not to add -lc for building shared libraries.
+build_libtool_need_lc=$archive_cmds_need_lc_RC
+
+# Whether or not to disallow shared libs when runtime libs are static
+allow_libtool_libs_with_static_runtimes=$enable_shared_with_static_runtimes_RC
+
+# Whether or not to optimize for fast installation.
+fast_install=$enable_fast_install
+
+# The host system.
+host_alias=$host_alias
+host=$host
+host_os=$host_os
+
+# The build system.
+build_alias=$build_alias
+build=$build
+build_os=$build_os
+
+# An echo program that does not interpret backslashes.
+echo=$lt_echo
+
+# The archiver.
+AR=$lt_AR
+AR_FLAGS=$lt_AR_FLAGS
+
+# A C compiler.
+LTCC=$lt_LTCC
+
+# A language-specific compiler.
+CC=$lt_compiler_RC
+
+# Is the compiler the GNU C compiler?
+with_gcc=$GCC_RC
+
+# An ERE matcher.
+EGREP=$lt_EGREP
+
+# The linker used to build libraries.
+LD=$lt_LD_RC
+
+# Whether we need hard or soft links.
+LN_S=$lt_LN_S
+
+# A BSD-compatible nm program.
+NM=$lt_NM
+
+# A symbol stripping program
+STRIP=$lt_STRIP
+
+# Used to examine libraries when file_magic_cmd begins "file"
+MAGIC_CMD=$MAGIC_CMD
+
+# Used on cygwin: DLL creation program.
+DLLTOOL="$DLLTOOL"
+
+# Used on cygwin: object dumper.
+OBJDUMP="$OBJDUMP"
+
+# Used on cygwin: assembler.
+AS="$AS"
+
+# The name of the directory that contains temporary libtool files.
+objdir=$objdir
+
+# How to create reloadable object files.
+reload_flag=$lt_reload_flag
+reload_cmds=$lt_reload_cmds
+
+# How to pass a linker flag through the compiler.
+wl=$lt_lt_prog_compiler_wl_RC
+
+# Object file suffix (normally "o").
+objext="$ac_objext"
+
+# Old archive suffix (normally "a").
+libext="$libext"
+
+# Shared library suffix (normally ".so").
+shrext_cmds='$shrext_cmds'
+
+# Executable file suffix (normally "").
+exeext="$exeext"
+
+# Additional compiler flags for building library objects.
+pic_flag=$lt_lt_prog_compiler_pic_RC
+pic_mode=$pic_mode
+
+# What is the maximum length of a command?
+max_cmd_len=$lt_cv_sys_max_cmd_len
+
+# Does compiler simultaneously support -c and -o options?
+compiler_c_o=$lt_lt_cv_prog_compiler_c_o_RC
+
+# Must we lock files when doing compilation?
+need_locks=$lt_need_locks
+
+# Do we need the lib prefix for modules?
+need_lib_prefix=$need_lib_prefix
+
+# Do we need a version for libraries?
+need_version=$need_version
+
+# Whether dlopen is supported.
+dlopen_support=$enable_dlopen
+
+# Whether dlopen of programs is supported.
+dlopen_self=$enable_dlopen_self
+
+# Whether dlopen of statically linked programs is supported.
+dlopen_self_static=$enable_dlopen_self_static
+
+# Compiler flag to prevent dynamic linking.
+link_static_flag=$lt_lt_prog_compiler_static_RC
+
+# Compiler flag to turn off builtin functions.
+no_builtin_flag=$lt_lt_prog_compiler_no_builtin_flag_RC
+
+# Compiler flag to allow reflexive dlopens.
+export_dynamic_flag_spec=$lt_export_dynamic_flag_spec_RC
+
+# Compiler flag to generate shared objects directly from archives.
+whole_archive_flag_spec=$lt_whole_archive_flag_spec_RC
+
+# Compiler flag to generate thread-safe objects.
+thread_safe_flag_spec=$lt_thread_safe_flag_spec_RC
+
+# Library versioning type.
+version_type=$version_type
+
+# Format of library name prefix.
+libname_spec=$lt_libname_spec
+
+# List of archive names.  First name is the real one, the rest are links.
+# The last name is the one that the linker finds with -lNAME.
+library_names_spec=$lt_library_names_spec
+
+# The coded name of the library, if different from the real name.
+soname_spec=$lt_soname_spec
+
+# Commands used to build and install an old-style archive.
+RANLIB=$lt_RANLIB
+old_archive_cmds=$lt_old_archive_cmds_RC
+old_postinstall_cmds=$lt_old_postinstall_cmds
+old_postuninstall_cmds=$lt_old_postuninstall_cmds
+
+# Create an old-style archive from a shared archive.
+old_archive_from_new_cmds=$lt_old_archive_from_new_cmds_RC
+
+# Create a temporary old-style archive to link instead of a shared archive.
+old_archive_from_expsyms_cmds=$lt_old_archive_from_expsyms_cmds_RC
+
+# Commands used to build and install a shared archive.
+archive_cmds=$lt_archive_cmds_RC
+archive_expsym_cmds=$lt_archive_expsym_cmds_RC
+postinstall_cmds=$lt_postinstall_cmds
+postuninstall_cmds=$lt_postuninstall_cmds
+
+# Commands used to build a loadable module (assumed same as above if empty)
+module_cmds=$lt_module_cmds_RC
+module_expsym_cmds=$lt_module_expsym_cmds_RC
+
+# Commands to strip libraries.
+old_striplib=$lt_old_striplib
+striplib=$lt_striplib
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predep_objects=$lt_predep_objects_RC
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdep_objects=$lt_postdep_objects_RC
+
+# Dependencies to place before the objects being linked to create a
+# shared library.
+predeps=$lt_predeps_RC
+
+# Dependencies to place after the objects being linked to create a
+# shared library.
+postdeps=$lt_postdeps_RC
+
+# The library search path used internally by the compiler when linking
+# a shared library.
+compiler_lib_search_path=$lt_compiler_lib_search_path_RC
+
+# Method to check whether dependent libraries are shared objects.
+deplibs_check_method=$lt_deplibs_check_method
+
+# Command to use when deplibs_check_method == file_magic.
+file_magic_cmd=$lt_file_magic_cmd
+
+# Flag that allows shared libraries with undefined symbols to be built.
+allow_undefined_flag=$lt_allow_undefined_flag_RC
+
+# Flag that forces no undefined symbols.
+no_undefined_flag=$lt_no_undefined_flag_RC
+
+# Commands used to finish a libtool library installation in a directory.
+finish_cmds=$lt_finish_cmds
+
+# Same as above, but a single script fragment to be evaled but not shown.
+finish_eval=$lt_finish_eval
+
+# Take the output of nm and produce a listing of raw symbols and C names.
+global_symbol_pipe=$lt_lt_cv_sys_global_symbol_pipe
+
+# Transform the output of nm in a proper C declaration
+global_symbol_to_cdecl=$lt_lt_cv_sys_global_symbol_to_cdecl
+
+# Transform the output of nm in a C name address pair
+global_symbol_to_c_name_address=$lt_lt_cv_sys_global_symbol_to_c_name_address
+
+# This is the shared library runtime path variable.
+runpath_var=$runpath_var
+
+# This is the shared library path variable.
+shlibpath_var=$shlibpath_var
+
+# Is shlibpath searched before the hard-coded library search path?
+shlibpath_overrides_runpath=$shlibpath_overrides_runpath
+
+# How to hardcode a shared library path into an executable.
+hardcode_action=$hardcode_action_RC
+
+# Whether we should hardcode library paths into libraries.
+hardcode_into_libs=$hardcode_into_libs
+
+# Flag to hardcode \$libdir into a binary during linking.
+# This must work even if \$libdir does not exist.
+hardcode_libdir_flag_spec=$lt_hardcode_libdir_flag_spec_RC
+
+# If ld is used when linking, flag to hardcode \$libdir into
+# a binary during linking. This must work even if \$libdir does
+# not exist.
+hardcode_libdir_flag_spec_ld=$lt_hardcode_libdir_flag_spec_ld_RC
+
+# Whether we need a single -rpath flag with a separated argument.
+hardcode_libdir_separator=$lt_hardcode_libdir_separator_RC
+
+# Set to yes if using DIR/libNAME${shared_ext} during linking hardcodes DIR into the
+# resulting binary.
+hardcode_direct=$hardcode_direct_RC
+
+# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
+# resulting binary.
+hardcode_minus_L=$hardcode_minus_L_RC
+
+# Set to yes if using SHLIBPATH_VAR=DIR during linking hardcodes DIR into
+# the resulting binary.
+hardcode_shlibpath_var=$hardcode_shlibpath_var_RC
+
+# Set to yes if building a shared library automatically hardcodes DIR into the library
+# and all subsequent libraries and executables linked against it.
+hardcode_automatic=$hardcode_automatic_RC
+
+# Variables whose values should be saved in libtool wrapper scripts and
+# restored at relink time.
+variables_saved_for_relink="$variables_saved_for_relink"
+
+# Whether libtool must link a program against all its dependency libraries.
+link_all_deplibs=$link_all_deplibs_RC
+
+# Compile-time system search path for libraries
+sys_lib_search_path_spec=$lt_sys_lib_search_path_spec
+
+# Run-time system search path for libraries
+sys_lib_dlsearch_path_spec=$lt_sys_lib_dlsearch_path_spec
+
+# Fix the shell variable \$srcfile for the compiler.
+fix_srcfile_path="$fix_srcfile_path_RC"
+
+# Set to yes if exported symbols are required.
+always_export_symbols=$always_export_symbols_RC
+
+# The commands to list exported symbols.
+export_symbols_cmds=$lt_export_symbols_cmds_RC
+
+# The commands to extract the exported symbol list from a shared archive.
+extract_expsyms_cmds=$lt_extract_expsyms_cmds
+
+# Symbols that should not be listed in the preloaded symbols.
+exclude_expsyms=$lt_exclude_expsyms_RC
+
+# Symbols that must always be exported.
+include_expsyms=$lt_include_expsyms_RC
+
+# ### END LIBTOOL TAG CONFIG: $tagname
+
+__EOF__
+
+
+else
+  # If there is no Makefile yet, we rely on a make rule to execute
+  # `config.status --recheck' to rerun these tests and create the
+  # libtool script then.
+  ltmain_in=`echo $ltmain | sed -e 's/\.sh$/.in/'`
+  if test -f "$ltmain_in"; then
+    test -f Makefile && make "$ltmain"
+  fi
+fi
+
+
+ac_ext=c
+ac_cpp='$CPP $CPPFLAGS'
+ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
+ac_link='$CC -o conftest$ac_exeext $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS >&5'
+ac_compiler_gnu=$ac_cv_c_compiler_gnu
+
+CC="$lt_save_CC"
+
+       ;;
+
+      *)
+       as_fn_error "Unsupported tag name: $tagname" "$LINENO" 5
+       ;;
+      esac
+
+      # Append the new tag name to the list of available tags.
+      if test -n "$tagname" ; then
+      available_tags="$available_tags $tagname"
+    fi
+    fi
+  done
+  IFS="$lt_save_ifs"
+
+  # Now substitute the updated list of available tags.
+  if eval "sed -e 's/^available_tags=.*\$/available_tags=\"$available_tags\"/' \"$ofile\" > \"${ofile}T\""; then
+    mv "${ofile}T" "$ofile"
+    chmod +x "$ofile"
+  else
+    rm -f "${ofile}T"
+    as_fn_error "unable to update list of available tagged configurations." "$LINENO" 5
+  fi
+fi
+
+
+
+# This can be used to rebuild libtool when needed
+LIBTOOL_DEPS="$ac_aux_dir/ltmain.sh"
+
+# Always use our own libtool.
+LIBTOOL='$(SHELL) $(top_builddir)/libtool'
+
+# Prevent multiple expansion
+
+
+
+
+
+
+
+
+
+
+# NTP has (so far) been relying on leading-edge autogen.
+# Therefore, by default:
+# - use the version we ship with
+# - do not install it
+# - build a static copy (AC_DISABLE_SHARED - done earlier)
+case "${enable_local_libopts+set}" in
+ set) ;;
+ *) enable_local_libopts=yes ;;
+esac
+case "${enable_libopts_install+set}" in
+ set) ;;
+ *) enable_libopts_install=no ;;
+esac
+
+  NEED_LIBOPTS_DIR=''
+
+  LIBOPTS_DIR=libopts
+
+  # Check whether --enable-local-libopts was given.
+if test "${enable_local_libopts+set}" = set; then :
+  enableval=$enable_local_libopts;
+    if test x$enableval = xyes ; then
+       { $as_echo "$as_me:${as_lineno-$LINENO}: Using supplied libopts tearoff" >&5
+$as_echo "$as_me: Using supplied libopts tearoff" >&6;}
+       LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la'
+       LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts'
+       NEED_LIBOPTS_DIR=true
+    fi
+fi
+
+
+  # Check whether --enable-libopts-install was given.
+if test "${enable_libopts_install+set}" = set; then :
+  enableval=$enable_libopts_install;
+fi
+
+   if test "X${enable_libopts_install}" != Xno; then
+  INSTALL_LIBOPTS_TRUE=
+  INSTALL_LIBOPTS_FALSE='#'
+else
+  INSTALL_LIBOPTS_TRUE='#'
+  INSTALL_LIBOPTS_FALSE=
+fi
+
+
+  if test -z "${NEED_LIBOPTS_DIR}" ; then
+     { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether autoopts-config can be found" >&5
+$as_echo_n "checking whether autoopts-config can be found... " >&6; }
+
+# Check whether --with-autoopts-config was given.
+if test "${with_autoopts_config+set}" = set; then :
+  withval=$with_autoopts_config; lo_cv_with_autoopts_config=${with_autoopts_config}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether autoopts-config is specified" >&5
+$as_echo_n "checking whether autoopts-config is specified... " >&6; }
+if test "${lo_cv_with_autoopts_config+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if autoopts-config --help 2>/dev/null 1>&2
+        then lo_cv_with_autoopts_config=autoopts-config
+        elif libopts-config --help 2>/dev/null 1>&2
+        then lo_cv_with_autoopts_config=libopts-config
+        else lo_cv_with_autoopts_config=no ; fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $lo_cv_with_autoopts_config" >&5
+$as_echo "$lo_cv_with_autoopts_config" >&6; }
+
+fi
+ # end of AC_ARG_WITH
+
+     if test "${lo_cv_test_autoopts+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+        if test -z "${lo_cv_with_autoopts_config}" \
+                -o X"${lo_cv_with_autoopts_config}" = Xno
+        then
+           if autoopts-config --help 2>/dev/null 1>&2
+           then lo_cv_with_autoopts_config=autoopts-config
+           elif libopts-config --help 2>/dev/null 1>&2
+           then lo_cv_with_autoopts_config=libopts-config
+           else lo_cv_with_autoopts_config=false ; fi
+        fi
+        lo_cv_test_autoopts=`
+            ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
+        if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
+        then lo_cv_test_autoopts=no ; fi
+
+fi
+ # end of CACHE_VAL
+     { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${lo_cv_test_autoopts}" >&5
+$as_echo "${lo_cv_test_autoopts}" >&6; }
+
+     if test "X${lo_cv_test_autoopts}" != Xno
+     then
+        LIBOPTS_LDADD="${lo_cv_test_autoopts}"
+        LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
+     else
+        LIBOPTS_LDADD='$(top_builddir)/libopts/libopts.la'
+        LIBOPTS_CFLAGS='-I$(top_srcdir)/libopts'
+        NEED_LIBOPTS_DIR=true
+     fi
+  fi # end of if test -z "${NEED_LIBOPTS_DIR}"
+
+   if test -n "${NEED_LIBOPTS_DIR}"; then
+  NEED_LIBOPTS_TRUE=
+  NEED_LIBOPTS_FALSE='#'
+else
+  NEED_LIBOPTS_TRUE='#'
+  NEED_LIBOPTS_FALSE=
+fi
+
+
+
+  LIBOPTS_DIR=libopts
+
+  ac_config_files="$ac_config_files libopts/Makefile"
+
+
+
+  if test -n "${NEED_LIBOPTS_DIR}" ; then
+
+
+if test X${INVOKE_LIBOPTS_MACROS_FIRST_done} != Xyes ; then
+  # =================
+  # AC_HEADER_STDC
+  # =================
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+  # =================
+  # AC_HEADER_DIRENT
+  # =================
+  ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+  as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
+$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <$ac_hdr>
+
+int
+main ()
+{
+if ((DIR *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_ac_Header=yes"
+else
+  eval "$as_ac_Header=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_ac_Header
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+_ACEOF
+
+ac_header_dirent=$ac_hdr; break
+fi
+
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' dir; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then :
+
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' x; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then :
+
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+
+  # =================
+  # AC_CHECK_HEADERS
+  # =================
+  for ac_header in dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \
+    setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \
+    sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h    \
+    utime.h sysexits.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+  # --------------------------------------------
+  # Verify certain entries from AC_CHECK_HEADERS
+  # --------------------------------------------
+  for f in sys_types sys_mman sys_param sys_stat sys_wait \
+           string errno stdlib memory setjmp
+  do eval as_ac_var=\${ac_cv_header_${f}_h+set}
+     test "${as_ac_var}" = set || \
+       as_fn_error "You must have ${f}.h on your system" "$LINENO" 5
+  done
+
+  # ================================================
+  # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise
+  # if varargs.h is present define HAVE_VARARGS_H.
+  # ================================================
+  for ac_header in stdarg.h varargs.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have stdarg.h or varargs.h on your system" "$LINENO" 5
+  fi
+
+  # ================================================
+  # Similarly for the string.h and strings.h headers
+  # ================================================
+  for ac_header in string.h strings.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have string.h or strings.h on your system" "$LINENO" 5
+  fi
+
+  # =====================
+  # ...and limits headers
+  # =====================
+  for ac_header in limits.h sys/limits.h values.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have one of limits.h, sys/limits.h or values.h" "$LINENO" 5
+  fi
+
+  # ========================
+  # ...and int types headers
+  # ========================
+  for ac_header in stdint.h inttypes.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default"
+if test "x$ac_cv_type_int8_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT8_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint8_t" "ac_cv_type_uint8_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint8_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT8_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default"
+if test "x$ac_cv_type_int16_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT16_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint16_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT16_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default"
+if test "x$ac_cv_type_int32_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT32_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint32_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT32_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_intptr_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INTPTR_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint_t" "ac_cv_type_uint_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT_T 1
+_ACEOF
+
+
+fi
+
+
+  # ====================
+  # uintptr type & sizes
+  # ====================
+  ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_uintptr_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINTPTR_T 1
+_ACEOF
+
+
+else
+
+$as_echo "#define uintptr_t unsigned long" >>confdefs.h
+
+fi
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char*" >&5
+$as_echo_n "checking size of char*... " >&6; }
+if test "${ac_cv_sizeof_charp+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char*))" "ac_cv_sizeof_charp"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_charp" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (char*)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_charp=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_charp" >&5
+$as_echo "$ac_cv_sizeof_charp" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_CHARP $ac_cv_sizeof_charp
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5
+$as_echo_n "checking size of int... " >&6; }
+if test "${ac_cv_sizeof_int+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_int" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (int)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_int=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5
+$as_echo "$ac_cv_sizeof_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
+$as_echo_n "checking size of long... " >&6; }
+if test "${ac_cv_sizeof_long+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (long)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
+$as_echo "$ac_cv_sizeof_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5
+$as_echo_n "checking size of short... " >&6; }
+if test "${ac_cv_sizeof_short+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_short" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (short)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_short=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5
+$as_echo "$ac_cv_sizeof_short" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+_ACEOF
+
+
+
+  # ----------------------------------------------------------------------
+  # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind.
+  # ----------------------------------------------------------------------
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pathfind in -lgen" >&5
+$as_echo_n "checking for pathfind in -lgen... " >&6; }
+if test "${ac_cv_lib_gen_pathfind+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgen  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pathfind ();
+int
+main ()
+{
+return pathfind ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_gen_pathfind=yes
+else
+  ac_cv_lib_gen_pathfind=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gen_pathfind" >&5
+$as_echo "$ac_cv_lib_gen_pathfind" >&6; }
+if test "x$ac_cv_lib_gen_pathfind" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBGEN 1
+_ACEOF
+
+  LIBS="-lgen $LIBS"
+
+fi
+
+  for ac_func in vprintf
+do :
+  ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf"
+if test "x$ac_cv_func_vprintf" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_VPRINTF 1
+_ACEOF
+
+ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt"
+if test "x$ac_cv_func__doprnt" = x""yes; then :
+
+$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h
+
+fi
+
+fi
+done
+
+
+  for ac_func in mmap canonicalize_file_name snprintf strdup strchr strrchr
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+  INVOKE_LIBOPTS_MACROS_FIRST_done=yes
+fi
+  # Check to see if a reg expr header is specified.
+
+
+# Check whether --with-regex-header was given.
+if test "${with_regex_header+set}" = set; then :
+  withval=$with_regex_header; libopts_cv_with_regex_header=${with_regex_header}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether a reg expr header is specified" >&5
+$as_echo_n "checking whether a reg expr header is specified... " >&6; }
+if test "${libopts_cv_with_regex_header+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  libopts_cv_with_regex_header=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_regex_header" >&5
+$as_echo "$libopts_cv_with_regex_header" >&6; }
+
+fi
+ # end of AC_ARG_WITH
+
+  if test "X${libopts_cv_with_regex_header}" != Xno
+  then
+    cat >>confdefs.h <<_ACEOF
+#define REGEX_HEADER <${libopts_cv_with_regex_header}>
+_ACEOF
+
+  else
+
+$as_echo "#define REGEX_HEADER <regex.h>" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if a working libregex can be found.
+
+
+# Check whether --with-libregex was given.
+if test "${with_libregex+set}" = set; then :
+  withval=$with_libregex; libopts_cv_with_libregex_root=${with_libregex}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether with-libregex was specified" >&5
+$as_echo_n "checking whether with-libregex was specified... " >&6; }
+if test "${libopts_cv_with_libregex_root+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  libopts_cv_with_libregex_root=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_root" >&5
+$as_echo "$libopts_cv_with_libregex_root" >&6; }
+
+fi
+ # end of AC_ARG_WITH libregex
+
+  if test "${with_libguile+set}" = set && \
+     test "${withval}" = no
+  then ## disabled by request
+    libopts_cv_with_libregex_root=no
+    libopts_cv_with_libregex_cflags=no
+    libopts_cv_with_libregex_libs=no
+  else
+
+
+# Check whether --with-libregex-cflags was given.
+if test "${with_libregex_cflags+set}" = set; then :
+  withval=$with_libregex_cflags; libopts_cv_with_libregex_cflags=${with_regex_cflags}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether with-libregex-cflags was specified" >&5
+$as_echo_n "checking whether with-libregex-cflags was specified... " >&6; }
+if test "${libopts_cv_with_libregex_cflags+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  libopts_cv_with_libregex_cflags=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_cflags" >&5
+$as_echo "$libopts_cv_with_libregex_cflags" >&6; }
+
+fi
+ # end of AC_ARG_WITH libregex-cflags
+
+
+# Check whether --with-libregex-libs was given.
+if test "${with_libregex_libs+set}" = set; then :
+  withval=$with_libregex_libs; libopts_cv_with_libregex_libs=${with_regex_libs}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether with-libregex-libs was specified" >&5
+$as_echo_n "checking whether with-libregex-libs was specified... " >&6; }
+if test "${libopts_cv_with_libregex_libs+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  libopts_cv_with_libregex_libs=no
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_with_libregex_libs" >&5
+$as_echo "$libopts_cv_with_libregex_libs" >&6; }
+
+fi
+ # end of AC_ARG_WITH libregex-libs
+
+  case "X${libopts_cv_with_libregex_cflags}" in
+  Xyes|Xno|X )
+    case "X${libopts_cv_with_libregex_root}" in
+    Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
+    * )        libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
+    esac
+  esac
+  case "X${libopts_cv_with_libregex_libs}" in
+  Xyes|Xno|X )
+    case "X${libopts_cv_with_libregex_root}" in
+    Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
+    * )        libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex";;
+    esac
+  esac
+  libopts_save_CPPFLAGS="${CPPFLAGS}"
+  libopts_save_LIBS="${LIBS}"
+  fi ## disabled by request
+
+  case "X${libopts_cv_with_libregex_cflags}" in
+  Xyes|Xno|X )
+    libopts_cv_with_libregex_cflags="" ;;
+  * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
+  esac
+  case "X${libopts_cv_with_libregex_libs}" in
+  Xyes|Xno|X )
+    libopts_cv_with_libregex_libs="" ;;
+  * )
+    LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
+  esac
+  LIBREGEX_CFLAGS=""
+  LIBREGEX_LIBS=""
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether libregex functions properly" >&5
+$as_echo_n "checking whether libregex functions properly... " >&6; }
+  if test "${libopts_cv_with_libregex+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_with_libregex=no
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+#include <stdlib.h>
+#include <sys/types.h>
+#include REGEX_HEADER
+static regex_t re;
+void comp_re( char const* pzPat ) {
+  int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
+  if (res == 0) return;
+  exit( res ); }
+int main() {
+  regmatch_t m[2];
+  comp_re( "^.*\$"   );
+  comp_re( "()|no.*" );
+  comp_re( "."       );
+  if (regexec( &re, "X", 2, m, 0 ) != 0)  return 1;
+  if ((m[0].rm_so != 0) || (m[0].rm_eo != 1)) {
+    fputs( "error: regex -->.<-- did not match\n", stderr );
+    return 1;
+  }
+  return 0; }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_with_libregex=yes
+else
+  libopts_cv_with_libregex=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of AC_TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_with_libregex
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_with_libregex}" >&5
+$as_echo "${libopts_cv_with_libregex}" >&6; }
+
+  if test "X${libopts_cv_with_libregex}" != Xno
+  then
+
+$as_echo "#define WITH_LIBREGEX 1" >>confdefs.h
+
+  else
+    CPPFLAGS="${libopts_save_CPPFLAGS}"
+    LIBS="${libopts_save_LIBS}"
+  fi
+
+
+
+  # Check to see if pathfind(3) works.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether pathfind(3) works" >&5
+$as_echo_n "checking whether pathfind(3) works... " >&6; }
+  if test "${libopts_cv_run_pathfind+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_run_pathfind=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+#include <stdlib.h>
+int main (int argc, char** argv) {
+   char* pz = pathfind( getenv( "PATH" ), "sh", "x" );
+   return (pz == 0) ? 1 : 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_run_pathfind=yes
+else
+  libopts_cv_run_pathfind=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_pathfind
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_pathfind}" >&5
+$as_echo "${libopts_cv_run_pathfind}" >&6; }
+
+  if test "X${libopts_cv_run_pathfind}" != Xno
+  then
+
+$as_echo "#define HAVE_PATHFIND 1" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if /dev/zero is readable device.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether /dev/zero is readable device" >&5
+$as_echo_n "checking whether /dev/zero is readable device... " >&6; }
+  if test "${libopts_cv_test_dev_zero+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+    libopts_cv_test_dev_zero=`exec 2> /dev/null
+dzero=\`ls -lL /dev/zero | egrep ^c......r\`
+test -z "${dzero}" && exit 1
+echo ${dzero}`
+    if test $? -ne 0
+    then libopts_cv_test_dev_zero=no
+    elif test -z "$libopts_cv_test_dev_zero"
+    then libopts_cv_test_dev_zero=no
+    fi
+
+fi
+ # end of CACHE_VAL of libopts_cv_test_dev_zero
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_test_dev_zero}" >&5
+$as_echo "${libopts_cv_test_dev_zero}" >&6; }
+
+  if test "X${libopts_cv_test_dev_zero}" != Xno
+  then
+
+$as_echo "#define HAVE_DEV_ZERO 1" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if we have a functional realpath(3C).
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether we have a functional realpath(3C)" >&5
+$as_echo_n "checking whether we have a functional realpath(3C)... " >&6; }
+  if test "${libopts_cv_run_realpath+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_run_realpath=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <limits.h>
+#include <stdlib.h>
+int main (int argc, char** argv) {
+#ifndef PATH_MAX
+choke me!!
+#else
+   char zPath[PATH_MAX+1];
+#endif
+   char *pz = realpath(argv[0], zPath);
+   return (pz == zPath) ? 0 : 1;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_run_realpath=yes
+else
+  libopts_cv_run_realpath=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_realpath
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_realpath}" >&5
+$as_echo "${libopts_cv_run_realpath}" >&6; }
+
+  if test "X${libopts_cv_run_realpath}" != Xno
+  then
+
+$as_echo "#define HAVE_REALPATH 1" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if strftime() works.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether strftime() works" >&5
+$as_echo_n "checking whether strftime() works... " >&6; }
+  if test "${libopts_cv_run_strftime+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_run_strftime=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <time.h>
+#include <string.h>
+char t_buf[ 64 ];
+int main() {
+  static char const z[] = "Thursday Aug 28 240";
+  struct tm tm;
+  tm.tm_sec   = 36;  /* seconds after the minute [0, 61]  */
+  tm.tm_min   = 44;  /* minutes after the hour [0, 59] */
+  tm.tm_hour  = 12;  /* hour since midnight [0, 23] */
+  tm.tm_mday  = 28;  /* day of the month [1, 31] */
+  tm.tm_mon   =  7;  /* months since January [0, 11] */
+  tm.tm_year  = 86;  /* years since 1900 */
+  tm.tm_wday  =  4;  /* days since Sunday [0, 6] */
+  tm.tm_yday  = 239; /* days since January 1 [0, 365] */
+  tm.tm_isdst =  1;  /* flag for daylight savings time */
+  strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
+  return (strcmp( t_buf, z ) != 0); }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_run_strftime=yes
+else
+  libopts_cv_run_strftime=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_strftime
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_strftime}" >&5
+$as_echo "${libopts_cv_run_strftime}" >&6; }
+
+  if test "X${libopts_cv_run_strftime}" != Xno
+  then
+
+$as_echo "#define HAVE_STRFTIME 1" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if fopen accepts "b" mode.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fopen accepts \"b\" mode" >&5
+$as_echo_n "checking whether fopen accepts \"b\" mode... " >&6; }
+  if test "${libopts_cv_run_fopen_binary+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_run_fopen_binary=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int main (int argc, char** argv) {
+FILE* fp = fopen("conftest.$ac_ext", "rb");
+return (fp == NULL) ? 1 : fclose(fp); }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_run_fopen_binary=yes
+else
+  libopts_cv_run_fopen_binary=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_fopen_binary}" >&5
+$as_echo "${libopts_cv_run_fopen_binary}" >&6; }
+
+  if test "X${libopts_cv_run_fopen_binary}" != Xno
+  then
+
+$as_echo "#define FOPEN_BINARY_FLAG \"b\"" >>confdefs.h
+
+  else
+
+$as_echo "#define FOPEN_BINARY_FLAG \"\"" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if fopen accepts "t" mode.
+
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether fopen accepts \"t\" mode" >&5
+$as_echo_n "checking whether fopen accepts \"t\" mode... " >&6; }
+  if test "${libopts_cv_run_fopen_text+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+  if test "$cross_compiling" = yes; then :
+  libopts_cv_run_fopen_text=no
+
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdio.h>
+int main (int argc, char** argv) {
+FILE* fp = fopen("conftest.$ac_ext", "rt");
+return (fp == NULL) ? 1 : fclose(fp); }
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+  libopts_cv_run_fopen_text=yes
+else
+  libopts_cv_run_fopen_text=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+ # end of TRY_RUN
+
+fi
+ # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
+  { $as_echo "$as_me:${as_lineno-$LINENO}: result: ${libopts_cv_run_fopen_text}" >&5
+$as_echo "${libopts_cv_run_fopen_text}" >&6; }
+
+  if test "X${libopts_cv_run_fopen_text}" != Xno
+  then
+
+$as_echo "#define FOPEN_TEXT_FLAG \"t\"" >>confdefs.h
+
+  else
+
+$as_echo "#define FOPEN_TEXT_FLAG \"\"" >>confdefs.h
+
+  fi
+
+
+
+  # Check to see if not wanting optional option args.
+
+  # Check whether --enable-optional-args was given.
+if test "${enable_optional_args+set}" = set; then :
+  enableval=$enable_optional_args; libopts_cv_enable_optional_args=${enable_optional_args}
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether not wanting optional option args" >&5
+$as_echo_n "checking whether not wanting optional option args... " >&6; }
+if test "${libopts_cv_enable_optional_args+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  libopts_cv_enable_optional_args=yes
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $libopts_cv_enable_optional_args" >&5
+$as_echo "$libopts_cv_enable_optional_args" >&6; }
+
+fi
+ # end of AC_ARG_ENABLE
+
+  if test "X${libopts_cv_enable_optional_args}" = Xno
+  then
+
+$as_echo "#define NO_OPTIONAL_OPT_ARGS 1" >>confdefs.h
+
+  fi
+
+
+
+
+  else
+
+if test X${INVOKE_LIBOPTS_MACROS_FIRST_done} != Xyes ; then
+  # =================
+  # AC_HEADER_STDC
+  # =================
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+  # =================
+  # AC_HEADER_DIRENT
+  # =================
+  ac_header_dirent=no
+for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
+  as_ac_Header=`$as_echo "ac_cv_header_dirent_$ac_hdr" | $as_tr_sh`
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_hdr that defines DIR" >&5
+$as_echo_n "checking for $ac_hdr that defines DIR... " >&6; }
+if { as_var=$as_ac_Header; eval "test \"\${$as_var+set}\" = set"; }; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <$ac_hdr>
+
+int
+main ()
+{
+if ((DIR *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  eval "$as_ac_Header=yes"
+else
+  eval "$as_ac_Header=no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+eval ac_res=\$$as_ac_Header
+              { $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_res" >&5
+$as_echo "$ac_res" >&6; }
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_hdr" | $as_tr_cpp` 1
+_ACEOF
+
+ac_header_dirent=$ac_hdr; break
+fi
+
+done
+# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
+if test $ac_header_dirent = dirent.h; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' dir; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then :
+
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing opendir" >&5
+$as_echo_n "checking for library containing opendir... " >&6; }
+if test "${ac_cv_search_opendir+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char opendir ();
+int
+main ()
+{
+return opendir ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' x; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_opendir=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_opendir+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_opendir+set}" = set; then :
+
+else
+  ac_cv_search_opendir=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_opendir" >&5
+$as_echo "$ac_cv_search_opendir" >&6; }
+ac_res=$ac_cv_search_opendir
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+
+  # =================
+  # AC_CHECK_HEADERS
+  # =================
+  for ac_header in dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \
+    setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \
+    sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h    \
+    utime.h sysexits.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+  # --------------------------------------------
+  # Verify certain entries from AC_CHECK_HEADERS
+  # --------------------------------------------
+  for f in sys_types sys_mman sys_param sys_stat sys_wait \
+           string errno stdlib memory setjmp
+  do eval as_ac_var=\${ac_cv_header_${f}_h+set}
+     test "${as_ac_var}" = set || \
+       as_fn_error "You must have ${f}.h on your system" "$LINENO" 5
+  done
+
+  # ================================================
+  # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise
+  # if varargs.h is present define HAVE_VARARGS_H.
+  # ================================================
+  for ac_header in stdarg.h varargs.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have stdarg.h or varargs.h on your system" "$LINENO" 5
+  fi
+
+  # ================================================
+  # Similarly for the string.h and strings.h headers
+  # ================================================
+  for ac_header in string.h strings.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have string.h or strings.h on your system" "$LINENO" 5
+  fi
+
+  # =====================
+  # ...and limits headers
+  # =====================
+  for ac_header in limits.h sys/limits.h values.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  if test `eval echo '${'$as_ac_Header'}'` != yes; then
+    as_fn_error "You must have one of limits.h, sys/limits.h or values.h" "$LINENO" 5
+  fi
+
+  # ========================
+  # ...and int types headers
+  # ========================
+  for ac_header in stdint.h inttypes.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+ break
+fi
+
+done
+
+  ac_fn_c_check_type "$LINENO" "int8_t" "ac_cv_type_int8_t" "$ac_includes_default"
+if test "x$ac_cv_type_int8_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT8_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint8_t" "ac_cv_type_uint8_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint8_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT8_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "int16_t" "ac_cv_type_int16_t" "$ac_includes_default"
+if test "x$ac_cv_type_int16_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT16_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint16_t" "ac_cv_type_uint16_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint16_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT16_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "int32_t" "ac_cv_type_int32_t" "$ac_includes_default"
+if test "x$ac_cv_type_int32_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INT32_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint32_t" "ac_cv_type_uint32_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint32_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT32_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "intptr_t" "ac_cv_type_intptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_intptr_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_INTPTR_T 1
+_ACEOF
+
+
+fi
+ac_fn_c_check_type "$LINENO" "uint_t" "ac_cv_type_uint_t" "$ac_includes_default"
+if test "x$ac_cv_type_uint_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINT_T 1
+_ACEOF
+
+
+fi
+
+
+  # ====================
+  # uintptr type & sizes
+  # ====================
+  ac_fn_c_check_type "$LINENO" "uintptr_t" "ac_cv_type_uintptr_t" "$ac_includes_default"
+if test "x$ac_cv_type_uintptr_t" = x""yes; then :
+
+cat >>confdefs.h <<_ACEOF
+#define HAVE_UINTPTR_T 1
+_ACEOF
+
+
+else
+
+$as_echo "#define uintptr_t unsigned long" >>confdefs.h
+
+fi
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of char*" >&5
+$as_echo_n "checking size of char*... " >&6; }
+if test "${ac_cv_sizeof_charp+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (char*))" "ac_cv_sizeof_charp"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_charp" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (char*)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_charp=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_charp" >&5
+$as_echo "$ac_cv_sizeof_charp" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_CHARP $ac_cv_sizeof_charp
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of int" >&5
+$as_echo_n "checking size of int... " >&6; }
+if test "${ac_cv_sizeof_int+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (int))" "ac_cv_sizeof_int"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_int" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (int)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_int=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_int" >&5
+$as_echo "$ac_cv_sizeof_int" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_INT $ac_cv_sizeof_int
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of long" >&5
+$as_echo_n "checking size of long... " >&6; }
+if test "${ac_cv_sizeof_long+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (long))" "ac_cv_sizeof_long"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_long" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (long)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_long=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_long" >&5
+$as_echo "$ac_cv_sizeof_long" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_LONG $ac_cv_sizeof_long
+_ACEOF
+
+
+  # The cast to long int works around a bug in the HP C Compiler
+# version HP92453-01 B.11.11.23709.GP, which incorrectly rejects
+# declarations like `int a3[[(sizeof (unsigned char)) >= 0]];'.
+# This bug is HP SR number 8606223364.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking size of short" >&5
+$as_echo_n "checking size of short... " >&6; }
+if test "${ac_cv_sizeof_short+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  if ac_fn_c_compute_int "$LINENO" "(long int) (sizeof (short))" "ac_cv_sizeof_short"        "$ac_includes_default"; then :
+
+else
+  if test "$ac_cv_type_short" = yes; then
+     { { $as_echo "$as_me:${as_lineno-$LINENO}: error: in \`$ac_pwd':" >&5
+$as_echo "$as_me: error: in \`$ac_pwd':" >&2;}
+{ as_fn_set_status 77
+as_fn_error "cannot compute sizeof (short)
+See \`config.log' for more details." "$LINENO" 5; }; }
+   else
+     ac_cv_sizeof_short=0
+   fi
+fi
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_sizeof_short" >&5
+$as_echo "$ac_cv_sizeof_short" >&6; }
+
+
+
+cat >>confdefs.h <<_ACEOF
+#define SIZEOF_SHORT $ac_cv_sizeof_short
+_ACEOF
+
+
+
+  # ----------------------------------------------------------------------
+  # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind.
+  # ----------------------------------------------------------------------
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for pathfind in -lgen" >&5
+$as_echo_n "checking for pathfind in -lgen... " >&6; }
+if test "${ac_cv_lib_gen_pathfind+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_check_lib_save_LIBS=$LIBS
+LIBS="-lgen  $LIBS"
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char pathfind ();
+int
+main ()
+{
+return pathfind ();
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_lib_gen_pathfind=yes
+else
+  ac_cv_lib_gen_pathfind=no
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext conftest.$ac_ext
+LIBS=$ac_check_lib_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_gen_pathfind" >&5
+$as_echo "$ac_cv_lib_gen_pathfind" >&6; }
+if test "x$ac_cv_lib_gen_pathfind" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_LIBGEN 1
+_ACEOF
+
+  LIBS="-lgen $LIBS"
+
+fi
+
+  for ac_func in vprintf
+do :
+  ac_fn_c_check_func "$LINENO" "vprintf" "ac_cv_func_vprintf"
+if test "x$ac_cv_func_vprintf" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_VPRINTF 1
+_ACEOF
+
+ac_fn_c_check_func "$LINENO" "_doprnt" "ac_cv_func__doprnt"
+if test "x$ac_cv_func__doprnt" = x""yes; then :
+
+$as_echo "#define HAVE_DOPRNT 1" >>confdefs.h
+
+fi
+
+fi
+done
+
+
+  for ac_func in mmap canonicalize_file_name snprintf strdup strchr strrchr
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+  INVOKE_LIBOPTS_MACROS_FIRST_done=yes
+fi
+  fi
+# end of AC_DEFUN of LIBOPTS_CHECK
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking if $CC can handle #warning" >&5
+$as_echo_n "checking if $CC can handle #warning... " >&6; }
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+#warning foo
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_cpp_warning=yes
+else
+  ac_cv_cpp_warning=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_cpp_warning" >&5
+$as_echo "$ac_cv_cpp_warning" >&6; }
+
+case "$ac_cv_cpp_warning" in
+ no)
+
+$as_echo "#define NO_OPTION_NAME_WARNINGS 1" >>confdefs.h
+
+    { $as_echo "$as_me:${as_lineno-$LINENO}: result: Enabling NO_OPTION_NAME_WARNINGS as #warning does not work" >&5
+$as_echo "Enabling NO_OPTION_NAME_WARNINGS as #warning does not work" >&6; }
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for inline" >&5
+$as_echo_n "checking for inline... " >&6; }
+if test "${ac_cv_c_inline+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_c_inline=no
+for ac_kw in inline __inline__ __inline; do
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#ifndef __cplusplus
+typedef int foo_t;
+static $ac_kw foo_t static_foo () {return 0; }
+$ac_kw foo_t foo () {return 0; }
+#endif
+
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_inline=$ac_kw
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+  test "$ac_cv_c_inline" != no && break
+done
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_inline" >&5
+$as_echo "$ac_cv_c_inline" >&6; }
+
+case $ac_cv_c_inline in
+  inline | yes) ;;
+  *)
+    case $ac_cv_c_inline in
+      no) ac_val=;;
+      *) ac_val=$ac_cv_c_inline;;
+    esac
+    cat >>confdefs.h <<_ACEOF
+#ifndef __cplusplus
+#define inline $ac_val
+#endif
+_ACEOF
+    ;;
+esac
+
+
+case "$ac_cv_c_inline" in
+ '')
+    ;;
+ *)
+
+$as_echo "#define HAVE_INLINE 1" >>confdefs.h
+
+
+esac
+
+
+# Checks for libraries.
+
+# Checks for header files.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ANSI C header files" >&5
+$as_echo_n "checking for ANSI C header files... " >&6; }
+if test "${ac_cv_header_stdc+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+#include <stdarg.h>
+#include <string.h>
+#include <float.h>
+
+int
+main ()
+{
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_stdc=yes
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+if test $ac_cv_header_stdc = yes; then
+  # SunOS 4.x string.h does not declare mem*, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <string.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "memchr" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <stdlib.h>
+
+_ACEOF
+if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
+  $EGREP "free" >/dev/null 2>&1; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f conftest*
+
+fi
+
+if test $ac_cv_header_stdc = yes; then
+  # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi.
+  if test "$cross_compiling" = yes; then :
+  :
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <ctype.h>
+#include <stdlib.h>
+#if ((' ' & 0x0FF) == 0x020)
+# define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
+# define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c))
+#else
+# define ISLOWER(c) \
+                  (('a' <= (c) && (c) <= 'i') \
+                    || ('j' <= (c) && (c) <= 'r') \
+                    || ('s' <= (c) && (c) <= 'z'))
+# define TOUPPER(c) (ISLOWER(c) ? ((c) | 0x40) : (c))
+#endif
+
+#define XOR(e, f) (((e) && !(f)) || (!(e) && (f)))
+int
+main ()
+{
+  int i;
+  for (i = 0; i < 256; i++)
+    if (XOR (islower (i), ISLOWER (i))
+       || toupper (i) != TOUPPER (i))
+      return 2;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_run "$LINENO"; then :
+
+else
+  ac_cv_header_stdc=no
+fi
+rm -f core *.core core.conftest.* gmon.out bb.out conftest$ac_exeext \
+  conftest.$ac_objext conftest.beam conftest.$ac_ext
+fi
+
+fi
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_stdc" >&5
+$as_echo "$ac_cv_header_stdc" >&6; }
+if test $ac_cv_header_stdc = yes; then
+
+$as_echo "#define STDC_HEADERS 1" >>confdefs.h
+
+fi
+
+for ac_header in arpa/inet.h fcntl.h float.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h syslog.h unistd.h
+do :
+  as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
+ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
+eval as_val=\$$as_ac_Header
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_header" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+
+done
+
+
+# Checks for typedefs, structures, and compiler characteristics.
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for an ANSI C-conforming const" >&5
+$as_echo_n "checking for an ANSI C-conforming const... " >&6; }
+if test "${ac_cv_c_const+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+int
+main ()
+{
+/* FIXME: Include the comments suggested by Paul. */
+#ifndef __cplusplus
+  /* Ultrix mips cc rejects this.  */
+  typedef int charset[2];
+  const charset cs;
+  /* SunOS 4.1.1 cc rejects this.  */
+  char const *const *pcpcc;
+  char **ppc;
+  /* NEC SVR4.0.2 mips cc rejects this.  */
+  struct point {int x, y;};
+  static struct point const zero = {0,0};
+  /* AIX XL C 1.02.0.0 rejects this.
+     It does not let you subtract one const X* pointer from another in
+     an arm of an if-expression whose if-part is not a constant
+     expression */
+  const char *g = "string";
+  pcpcc = &g + (g ? g-g : 0);
+  /* HPUX 7.0 cc rejects these. */
+  ++pcpcc;
+  ppc = (char**) pcpcc;
+  pcpcc = (char const *const *) ppc;
+  { /* SCO 3.2v4 cc rejects this.  */
+    char *t;
+    char const *s = 0 ? (char *) 0 : (char const *) 0;
+
+    *t++ = 0;
+    if (s) return 0;
+  }
+  { /* Someone thinks the Sun supposedly-ANSI compiler will reject this.  */
+    int x[] = {25, 17};
+    const int *foo = &x[0];
+    ++foo;
+  }
+  { /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */
+    typedef const int *iptr;
+    iptr p = 0;
+    ++p;
+  }
+  { /* AIX XL C 1.02.0.0 rejects this saying
+       "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */
+    struct s { int j; const int *ap[3]; };
+    struct s *b; b->j = 5;
+  }
+  { /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */
+    const int foo = 10;
+    if (!foo) return 0;
+  }
+  return !cs[0] && !zero.x;
+#endif
+
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_c_const=yes
+else
+  ac_cv_c_const=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_c_const" >&5
+$as_echo "$ac_cv_c_const" >&6; }
+if test $ac_cv_c_const = no; then
+
+$as_echo "#define const /**/" >>confdefs.h
+
+fi
+
+ac_fn_c_check_type "$LINENO" "size_t" "ac_cv_type_size_t" "$ac_includes_default"
+if test "x$ac_cv_type_size_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define size_t unsigned int
+_ACEOF
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether time.h and sys/time.h may both be included" >&5
+$as_echo_n "checking whether time.h and sys/time.h may both be included... " >&6; }
+if test "${ac_cv_header_time+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <sys/time.h>
+#include <time.h>
+
+int
+main ()
+{
+if ((struct tm *) 0)
+return 0;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_header_time=yes
+else
+  ac_cv_header_time=no
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_header_time" >&5
+$as_echo "$ac_cv_header_time" >&6; }
+if test $ac_cv_header_time = yes; then
+
+$as_echo "#define TIME_WITH_SYS_TIME 1" >>confdefs.h
+
+fi
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking whether struct tm is in sys/time.h or time.h" >&5
+$as_echo_n "checking whether struct tm is in sys/time.h or time.h... " >&6; }
+if test "${ac_cv_struct_tm+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <time.h>
+
+int
+main ()
+{
+struct tm tm;
+                                    int *p = &tm.tm_sec;
+                                    return !p;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_struct_tm=time.h
+else
+  ac_cv_struct_tm=sys/time.h
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_struct_tm" >&5
+$as_echo "$ac_cv_struct_tm" >&6; }
+if test $ac_cv_struct_tm = sys/time.h; then
+
+$as_echo "#define TM_IN_SYS_TIME 1" >>confdefs.h
+
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for ss_family field in struct sockaddr_storage" >&5
+$as_echo_n "checking for ss_family field in struct sockaddr_storage... " >&6; }
+if test "${ac_cv_have_ss_family_in_struct_ss+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+main ()
+{
+ struct sockaddr_storage s; s.ss_family = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+   ac_cv_have_ss_family_in_struct_ss="yes"
+else
+   ac_cv_have_ss_family_in_struct_ss="no"
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have_ss_family_in_struct_ss" >&5
+$as_echo "$ac_cv_have_ss_family_in_struct_ss" >&6; }
+case "$ac_cv_have_ss_family_in_struct_ss" in
+ yes)
+
+$as_echo "#define HAVE_SS_FAMILY_IN_SS 1" >>confdefs.h
+
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for __ss_family field in struct sockaddr_storage" >&5
+$as_echo_n "checking for __ss_family field in struct sockaddr_storage... " >&6; }
+if test "${ac_cv_have___ss_family_in_struct_ss+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+
+       cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+#include <sys/types.h>
+#include <sys/socket.h>
+
+int
+main ()
+{
+ struct sockaddr_storage s; s.__ss_family = 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+   ac_cv_have___ss_family_in_struct_ss="yes"
+else
+   ac_cv_have___ss_family_in_struct_ss="no"
+
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_have___ss_family_in_struct_ss" >&5
+$as_echo "$ac_cv_have___ss_family_in_struct_ss" >&6; }
+case "$ac_cv_have___ss_family_in_struct_ss" in
+ yes)
+
+$as_echo "#define HAVE___SS_FAMILY_IN_SS 1" >>confdefs.h
+
+    ;;
+esac
+
+case "$ac_cv_have_ss_family_in_struct_ss$ac_cv_have___ss_family_in_struct_ss" in
+ noyes)
+
+cat >>confdefs.h <<_ACEOF
+#define ss_family __ss_family
+_ACEOF
+
+
+cat >>confdefs.h <<_ACEOF
+#define ss_len __ss_len
+_ACEOF
+
+    ;;
+esac
+
+# Checks for library functions.
+#AC_FUNC_MEMCMP         dnl HMS: we don't have a memcmp.c to use here, so why bother?
+if test "${ac_cv_func_setvbuf_reversed+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_cv_func_setvbuf_reversed=no
+fi
+
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking return type of signal handlers" >&5
+$as_echo_n "checking return type of signal handlers... " >&6; }
+if test "${ac_cv_type_signal+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+#include <sys/types.h>
+#include <signal.h>
+
+int
+main ()
+{
+return *(signal (0, 0)) (0) == 1;
+  ;
+  return 0;
+}
+_ACEOF
+if ac_fn_c_try_compile "$LINENO"; then :
+  ac_cv_type_signal=int
+else
+  ac_cv_type_signal=void
+fi
+rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_type_signal" >&5
+$as_echo "$ac_cv_type_signal" >&6; }
+
+cat >>confdefs.h <<_ACEOF
+#define RETSIGTYPE $ac_cv_type_signal
+_ACEOF
+
+
+for ac_func in alarm
+do :
+  ac_fn_c_check_func "$LINENO" "alarm" "ac_cv_func_alarm"
+if test "x$ac_cv_func_alarm" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_ALARM 1
+_ACEOF
+
+fi
+done
+
+ac_fn_c_check_func "$LINENO" "gethostent" "ac_cv_func_gethostent"
+if test "x$ac_cv_func_gethostent" = x""yes; then :
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing gethostent" >&5
+$as_echo_n "checking for library containing gethostent... " >&6; }
+if test "${ac_cv_search_gethostent+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char gethostent ();
+int
+main ()
+{
+return gethostent ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' nsl; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib -lsocket $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_gethostent=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_gethostent+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_gethostent+set}" = set; then :
+
+else
+  ac_cv_search_gethostent=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_gethostent" >&5
+$as_echo "$ac_cv_search_gethostent" >&6; }
+ac_res=$ac_cv_search_gethostent
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+
+for ac_func in gettimeofday inet_ntoa memset
+do :
+  as_ac_var=`$as_echo "ac_cv_func_$ac_func" | $as_tr_sh`
+ac_fn_c_check_func "$LINENO" "$ac_func" "$as_ac_var"
+eval as_val=\$$as_ac_var
+   if test "x$as_val" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define `$as_echo "HAVE_$ac_func" | $as_tr_cpp` 1
+_ACEOF
+
+fi
+done
+
+for ac_func in socket
+do :
+  ac_fn_c_check_func "$LINENO" "socket" "ac_cv_func_socket"
+if test "x$ac_cv_func_socket" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SOCKET 1
+_ACEOF
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing socket" >&5
+$as_echo_n "checking for library containing socket... " >&6; }
+if test "${ac_cv_search_socket+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char socket ();
+int
+main ()
+{
+return socket ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' socket; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_socket=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_socket+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_socket+set}" = set; then :
+
+else
+  ac_cv_search_socket=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_socket" >&5
+$as_echo "$ac_cv_search_socket" >&6; }
+ac_res=$ac_cv_search_socket
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+done
+
+for ac_func in sqrt
+do :
+  ac_fn_c_check_func "$LINENO" "sqrt" "ac_cv_func_sqrt"
+if test "x$ac_cv_func_sqrt" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_SQRT 1
+_ACEOF
+
+else
+  { $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing sqrt" >&5
+$as_echo_n "checking for library containing sqrt... " >&6; }
+if test "${ac_cv_search_sqrt+set}" = set; then :
+  $as_echo_n "(cached) " >&6
+else
+  ac_func_search_save_LIBS=$LIBS
+cat confdefs.h - <<_ACEOF >conftest.$ac_ext
+/* end confdefs.h.  */
+
+/* Override any GCC internal prototype to avoid an error.
+   Use char because int might match the return type of a GCC
+   builtin and then its argument prototype would still apply.  */
+#ifdef __cplusplus
+extern "C"
+#endif
+char sqrt ();
+int
+main ()
+{
+return sqrt ();
+  ;
+  return 0;
+}
+_ACEOF
+for ac_lib in '' m; do
+  if test -z "$ac_lib"; then
+    ac_res="none required"
+  else
+    ac_res=-l$ac_lib
+    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
+  fi
+  if ac_fn_c_try_link "$LINENO"; then :
+  ac_cv_search_sqrt=$ac_res
+fi
+rm -f core conftest.err conftest.$ac_objext \
+    conftest$ac_exeext
+  if test "${ac_cv_search_sqrt+set}" = set; then :
+  break
+fi
+done
+if test "${ac_cv_search_sqrt+set}" = set; then :
+
+else
+  ac_cv_search_sqrt=no
+fi
+rm conftest.$ac_ext
+LIBS=$ac_func_search_save_LIBS
+fi
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_sqrt" >&5
+$as_echo "$ac_cv_search_sqrt" >&6; }
+ac_res=$ac_cv_search_sqrt
+if test "$ac_res" != no; then :
+  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
+
+fi
+
+fi
+done
+
+for ac_func in strrchr
+do :
+  ac_fn_c_check_func "$LINENO" "strrchr" "ac_cv_func_strrchr"
+if test "x$ac_cv_func_strrchr" = x""yes; then :
+  cat >>confdefs.h <<_ACEOF
+#define HAVE_STRRCHR 1
+_ACEOF
+
+fi
+done
+
+
+case "$host" in
+ *-*-hpux10.*) # at least for hppa2.0-hp-hpux10.20
+    case "$GCC" in
+     yes)
+       ;;
+     *) CFLAGS="$CFLAGS -Wp,-H18816"
+       ;;
+    esac
+    ;;
+ *-*-linux*)
+    CFLAGS="$CFLAGS -DADJTIME_MISSING"
+    ;;
+ *-*-sunos*)
+    CFLAGS="$CFLAGS -DNONBLOCK_BROKEN"
+    ;;
+esac
+
+{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for bin subdirectory" >&5
+$as_echo_n "checking for bin subdirectory... " >&6; }
+
+# Check whether --with-binsubdir was given.
+if test "${with_binsubdir+set}" = set; then :
+  withval=$with_binsubdir; use_binsubdir="$withval"
+else
+  use_binsubdir="bin"
+fi
+
+
+case "$use_binsubdir" in
+ bin)
+    ;;
+ sbin)
+    ;;
+ *)
+    as_fn_error "<$use_binsubdir> is illegal - must be \"bin\" or \"sbin\"" "$LINENO" 5
+    ;;
+esac
+{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $use_binsubdir" >&5
+$as_echo "$use_binsubdir" >&6; }
+BINSUBDIR=$use_binsubdir
+
+
+ac_config_files="$ac_config_files Makefile"
+
+cat >confcache <<\_ACEOF
+# This file is a shell script that caches the results of configure
+# tests run on this system so they can be shared between configure
+# scripts and configure runs, see configure's option --config-cache.
+# It is not useful on other systems.  If it contains results you don't
+# want to keep, you may remove or edit it.
+#
+# config.status only pays attention to the cache file if you give it
+# the --recheck option to rerun configure.
+#
+# `ac_cv_env_foo' variables (set or unset) will be overridden when
+# loading this file, other *unset* `ac_cv_foo' will be assigned the
+# following values.
+
+_ACEOF
+
+# The following way of writing the cache mishandles newlines in values,
+# but we know of no workaround that is simple, portable, and efficient.
+# So, we kill variables containing newlines.
+# Ultrix sh set writes to stderr and can't be redirected directly,
+# and sets the high bit in the cache file unless we assign to the vars.
+(
+  for ac_var in `(set) 2>&1 | sed -n 's/^\([a-zA-Z_][a-zA-Z0-9_]*\)=.*/\1/p'`; do
+    eval ac_val=\$$ac_var
+    case $ac_val in #(
+    *${as_nl}*)
+      case $ac_var in #(
+      *_cv_*) { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: cache variable $ac_var contains a newline" >&5
+$as_echo "$as_me: WARNING: cache variable $ac_var contains a newline" >&2;} ;;
+      esac
+      case $ac_var in #(
+      _ | IFS | as_nl) ;; #(
+      BASH_ARGV | BASH_SOURCE) eval $ac_var= ;; #(
+      *) { eval $ac_var=; unset $ac_var;} ;;
+      esac ;;
+    esac
+  done
+
+  (set) 2>&1 |
+    case $as_nl`(ac_space=' '; set) 2>&1` in #(
+    *${as_nl}ac_space=\ *)
+      # `set' does not quote correctly, so add quotes: double-quote
+      # substitution turns \\\\ into \\, and sed turns \\ into \.
+      sed -n \
+       "s/'/'\\\\''/g;
+         s/^\\([_$as_cr_alnum]*_cv_[_$as_cr_alnum]*\\)=\\(.*\\)/\\1='\\2'/p"
+      ;; #(
+    *)
+      # `set' quotes correctly as required by POSIX, so do not add quotes.
+      sed -n "/^[_$as_cr_alnum]*_cv_[_$as_cr_alnum]*=/p"
+      ;;
+    esac |
+    sort
+) |
+  sed '
+     /^ac_cv_env_/b end
+     t clear
+     :clear
+     s/^\([^=]*\)=\(.*[{}].*\)$/test "${\1+set}" = set || &/
+     t end
+     s/^\([^=]*\)=\(.*\)$/\1=${\1=\2}/
+     :end' >>confcache
+if diff "$cache_file" confcache >/dev/null 2>&1; then :; else
+  if test -w "$cache_file"; then
+    test "x$cache_file" != "x/dev/null" &&
+      { $as_echo "$as_me:${as_lineno-$LINENO}: updating cache $cache_file" >&5
+$as_echo "$as_me: updating cache $cache_file" >&6;}
+    cat confcache >$cache_file
+  else
+    { $as_echo "$as_me:${as_lineno-$LINENO}: not updating unwritable cache $cache_file" >&5
+$as_echo "$as_me: not updating unwritable cache $cache_file" >&6;}
+  fi
+fi
+rm -f confcache
+
+test "x$prefix" = xNONE && prefix=$ac_default_prefix
+# Let make expand exec_prefix.
+test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'
+
+DEFS=-DHAVE_CONFIG_H
+
+ac_libobjs=
+ac_ltlibobjs=
+for ac_i in : $LIBOBJS; do test "x$ac_i" = x: && continue
+  # 1. Remove the extension, and $U if already installed.
+  ac_script='s/\$U\././;s/\.o$//;s/\.obj$//'
+  ac_i=`$as_echo "$ac_i" | sed "$ac_script"`
+  # 2. Prepend LIBOBJDIR.  When used with automake>=1.10 LIBOBJDIR
+  #    will be set to the directory where LIBOBJS objects are built.
+  as_fn_append ac_libobjs " \${LIBOBJDIR}$ac_i\$U.$ac_objext"
+  as_fn_append ac_ltlibobjs " \${LIBOBJDIR}$ac_i"'$U.lo'
+done
+LIBOBJS=$ac_libobjs
+
+LTLIBOBJS=$ac_ltlibobjs
+
+
+ if test -n "$EXEEXT"; then
+  am__EXEEXT_TRUE=
+  am__EXEEXT_FALSE='#'
+else
+  am__EXEEXT_TRUE='#'
+  am__EXEEXT_FALSE=
+fi
+
+if test -z "${AMDEP_TRUE}" && test -z "${AMDEP_FALSE}"; then
+  as_fn_error "conditional \"AMDEP\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${am__fastdepCC_TRUE}" && test -z "${am__fastdepCC_FALSE}"; then
+  as_fn_error "conditional \"am__fastdepCC\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${INSTALL_LIBOPTS_TRUE}" && test -z "${INSTALL_LIBOPTS_FALSE}"; then
+  as_fn_error "conditional \"INSTALL_LIBOPTS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+if test -z "${NEED_LIBOPTS_TRUE}" && test -z "${NEED_LIBOPTS_FALSE}"; then
+  as_fn_error "conditional \"NEED_LIBOPTS\" was never defined.
+Usually this means the macro was only invoked conditionally." "$LINENO" 5
+fi
+
+: ${CONFIG_STATUS=./config.status}
+ac_write_fail=0
+ac_clean_files_save=$ac_clean_files
+ac_clean_files="$ac_clean_files $CONFIG_STATUS"
+{ $as_echo "$as_me:${as_lineno-$LINENO}: creating $CONFIG_STATUS" >&5
+$as_echo "$as_me: creating $CONFIG_STATUS" >&6;}
+as_write_fail=0
+cat >$CONFIG_STATUS <<_ASEOF || as_write_fail=1
+#! $SHELL
+# Generated by $as_me.
+# Run this file to recreate the current configuration.
+# Compiler output produced by configure, useful for debugging
+# configure, is in config.log if it exists.
+
+debug=false
+ac_cs_recheck=false
+ac_cs_silent=false
+
+SHELL=\${CONFIG_SHELL-$SHELL}
+export SHELL
+_ASEOF
+cat >>$CONFIG_STATUS <<\_ASEOF || as_write_fail=1
+## -------------------- ##
+## M4sh Initialization. ##
+## -------------------- ##
+
+# Be more Bourne compatible
+DUALCASE=1; export DUALCASE # for MKS sh
+if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
+  emulate sh
+  NULLCMD=:
+  # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
+  # is contrary to our usage.  Disable this feature.
+  alias -g '${1+"$@"}'='"$@"'
+  setopt NO_GLOB_SUBST
+else
+  case `(set -o) 2>/dev/null` in #(
+  *posix*) :
+    set -o posix ;; #(
+  *) :
+     ;;
+esac
+fi
+
+
+as_nl='
+'
+export as_nl
+# Printing a long string crashes Solaris 7 /usr/bin/printf.
+as_echo='\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\'
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo
+as_echo=$as_echo$as_echo$as_echo$as_echo$as_echo$as_echo
+# Prefer a ksh shell builtin over an external printf program on Solaris,
+# but without wasting forks for bash or zsh.
+if test -z "$BASH_VERSION$ZSH_VERSION" \
+    && (test "X`print -r -- $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='print -r --'
+  as_echo_n='print -rn --'
+elif (test "X`printf %s $as_echo`" = "X$as_echo") 2>/dev/null; then
+  as_echo='printf %s\n'
+  as_echo_n='printf %s'
+else
+  if test "X`(/usr/ucb/echo -n -n $as_echo) 2>/dev/null`" = "X-n $as_echo"; then
+    as_echo_body='eval /usr/ucb/echo -n "$1$as_nl"'
+    as_echo_n='/usr/ucb/echo -n'
+  else
+    as_echo_body='eval expr "X$1" : "X\\(.*\\)"'
+    as_echo_n_body='eval
+      arg=$1;
+      case $arg in #(
+      *"$as_nl"*)
+       expr "X$arg" : "X\\(.*\\)$as_nl";
+       arg=`expr "X$arg" : ".*$as_nl\\(.*\\)"`;;
+      esac;
+      expr "X$arg" : "X\\(.*\\)" | tr -d "$as_nl"
+    '
+    export as_echo_n_body
+    as_echo_n='sh -c $as_echo_n_body as_echo'
+  fi
+  export as_echo_body
+  as_echo='sh -c $as_echo_body as_echo'
+fi
+
+# The user is always right.
+if test "${PATH_SEPARATOR+set}" != set; then
+  PATH_SEPARATOR=:
+  (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
+    (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
+      PATH_SEPARATOR=';'
+  }
+fi
+
+
+# IFS
+# We need space, tab and new line, in precisely that order.  Quoting is
+# there to prevent editors from complaining about space-tab.
+# (If _AS_PATH_WALK were called with IFS unset, it would disable word
+# splitting by setting IFS to empty value.)
+IFS=" ""       $as_nl"
+
+# Find who we are.  Look in the path if we contain no directory separator.
+case $0 in #((
+  *[\\/]* ) as_myself=$0 ;;
+  *) as_save_IFS=$IFS; IFS=$PATH_SEPARATOR
+for as_dir in $PATH
+do
+  IFS=$as_save_IFS
+  test -z "$as_dir" && as_dir=.
+    test -r "$as_dir/$0" && as_myself=$as_dir/$0 && break
+  done
+IFS=$as_save_IFS
+
+     ;;
+esac
+# We did not find ourselves, most probably we were run as `sh COMMAND'
+# in which case we are not to be found in the path.
+if test "x$as_myself" = x; then
+  as_myself=$0
+fi
+if test ! -f "$as_myself"; then
+  $as_echo "$as_myself: error: cannot find myself; rerun with an absolute file name" >&2
+  exit 1
+fi
+
+# Unset variables that we do not need and which cause bugs (e.g. in
+# pre-3.0 UWIN ksh).  But do not cause bugs in bash 2.01; the "|| exit 1"
+# suppresses any "Segmentation fault" message there.  '((' could
+# trigger a bug in pdksh 5.2.14.
+for as_var in BASH_ENV ENV MAIL MAILPATH
+do eval test x\${$as_var+set} = xset \
+  && ( (unset $as_var) || exit 1) >/dev/null 2>&1 && unset $as_var || :
+done
+PS1='$ '
+PS2='> '
+PS4='+ '
+
+# NLS nuisances.
+LC_ALL=C
+export LC_ALL
+LANGUAGE=C
+export LANGUAGE
+
+# CDPATH.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+
+# as_fn_error ERROR [LINENO LOG_FD]
+# ---------------------------------
+# Output "`basename $0`: error: ERROR" to stderr. If LINENO and LOG_FD are
+# provided, also output the error to LOG_FD, referencing LINENO. Then exit the
+# script with status $?, using 1 if that was 0.
+as_fn_error ()
+{
+  as_status=$?; test $as_status -eq 0 && as_status=1
+  if test "$3"; then
+    as_lineno=${as_lineno-"$2"} as_lineno_stack=as_lineno_stack=$as_lineno_stack
+    $as_echo "$as_me:${as_lineno-$LINENO}: error: $1" >&$3
+  fi
+  $as_echo "$as_me: error: $1" >&2
+  as_fn_exit $as_status
+} # as_fn_error
+
+
+# as_fn_set_status STATUS
+# -----------------------
+# Set $? to STATUS, without forking.
+as_fn_set_status ()
+{
+  return $1
+} # as_fn_set_status
+
+# as_fn_exit STATUS
+# -----------------
+# Exit the shell with STATUS, even in a "trap 0" or "set -e" context.
+as_fn_exit ()
+{
+  set +e
+  as_fn_set_status $1
+  exit $1
+} # as_fn_exit
+
+# as_fn_unset VAR
+# ---------------
+# Portably unset VAR.
+as_fn_unset ()
+{
+  { eval $1=; unset $1;}
+}
+as_unset=as_fn_unset
+# as_fn_append VAR VALUE
+# ----------------------
+# Append the text in VALUE to the end of the definition contained in VAR. Take
+# advantage of any shell optimizations that allow amortized linear growth over
+# repeated appends, instead of the typical quadratic growth present in naive
+# implementations.
+if (eval "as_var=1; as_var+=2; test x\$as_var = x12") 2>/dev/null; then :
+  eval 'as_fn_append ()
+  {
+    eval $1+=\$2
+  }'
+else
+  as_fn_append ()
+  {
+    eval $1=\$$1\$2
+  }
+fi # as_fn_append
+
+# as_fn_arith ARG...
+# ------------------
+# Perform arithmetic evaluation on the ARGs, and store the result in the
+# global $as_val. Take advantage of shells that can avoid forks. The arguments
+# must be portable across $(()) and expr.
+if (eval "test \$(( 1 + 1 )) = 2") 2>/dev/null; then :
+  eval 'as_fn_arith ()
+  {
+    as_val=$(( $* ))
+  }'
+else
+  as_fn_arith ()
+  {
+    as_val=`expr "$@" || test $? -eq 1`
+  }
+fi # as_fn_arith
+
+
+if expr a : '\(a\)' >/dev/null 2>&1 &&
+   test "X`expr 00001 : '.*\(...\)'`" = X001; then
+  as_expr=expr
+else
+  as_expr=false
+fi
+
+if (basename -- /) >/dev/null 2>&1 && test "X`basename -- / 2>&1`" = "X/"; then
+  as_basename=basename
+else
+  as_basename=false
+fi
+
+if (as_dir=`dirname -- /` && test "X$as_dir" = X/) >/dev/null 2>&1; then
+  as_dirname=dirname
+else
+  as_dirname=false
+fi
+
+as_me=`$as_basename -- "$0" ||
+$as_expr X/"$0" : '.*/\([^/][^/]*\)/*$' \| \
+        X"$0" : 'X\(//\)$' \| \
+        X"$0" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X/"$0" |
+    sed '/^.*\/\([^/][^/]*\)\/*$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\/\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+
+# Avoid depending upon Character Ranges.
+as_cr_letters='abcdefghijklmnopqrstuvwxyz'
+as_cr_LETTERS='ABCDEFGHIJKLMNOPQRSTUVWXYZ'
+as_cr_Letters=$as_cr_letters$as_cr_LETTERS
+as_cr_digits='0123456789'
+as_cr_alnum=$as_cr_Letters$as_cr_digits
+
+ECHO_C= ECHO_N= ECHO_T=
+case `echo -n x` in #(((((
+-n*)
+  case `echo 'xy\c'` in
+  *c*) ECHO_T='        ';;     # ECHO_T is single tab character.
+  xy)  ECHO_C='\c';;
+  *)   echo `echo ksh88 bug on AIX 6.1` > /dev/null
+       ECHO_T='        ';;
+  esac;;
+*)
+  ECHO_N='-n';;
+esac
+
+rm -f conf$$ conf$$.exe conf$$.file
+if test -d conf$$.dir; then
+  rm -f conf$$.dir/conf$$.file
+else
+  rm -f conf$$.dir
+  mkdir conf$$.dir 2>/dev/null
+fi
+if (echo >conf$$.file) 2>/dev/null; then
+  if ln -s conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s='ln -s'
+    # ... but there are two gotchas:
+    # 1) On MSYS, both `ln -s file dir' and `ln file dir' fail.
+    # 2) DJGPP < 2.04 has no symlinks; `ln -s' creates a wrapper executable.
+    # In both cases, we have to default to `cp -p'.
+    ln -s conf$$.file conf$$.dir 2>/dev/null && test ! -f conf$$.exe ||
+      as_ln_s='cp -p'
+  elif ln conf$$.file conf$$ 2>/dev/null; then
+    as_ln_s=ln
+  else
+    as_ln_s='cp -p'
+  fi
+else
+  as_ln_s='cp -p'
+fi
+rm -f conf$$ conf$$.exe conf$$.dir/conf$$.file conf$$.file
+rmdir conf$$.dir 2>/dev/null
+
+
+# as_fn_mkdir_p
+# -------------
+# Create "$as_dir" as a directory, including parents if necessary.
+as_fn_mkdir_p ()
+{
+
+  case $as_dir in #(
+  -*) as_dir=./$as_dir;;
+  esac
+  test -d "$as_dir" || eval $as_mkdir_p || {
+    as_dirs=
+    while :; do
+      case $as_dir in #(
+      *\'*) as_qdir=`$as_echo "$as_dir" | sed "s/'/'\\\\\\\\''/g"`;; #'(
+      *) as_qdir=$as_dir;;
+      esac
+      as_dirs="'$as_qdir' $as_dirs"
+      as_dir=`$as_dirname -- "$as_dir" ||
+$as_expr X"$as_dir" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$as_dir" : 'X\(//\)[^/]' \| \
+        X"$as_dir" : 'X\(//\)$' \| \
+        X"$as_dir" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$as_dir" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      test -d "$as_dir" && break
+    done
+    test -z "$as_dirs" || eval "mkdir $as_dirs"
+  } || test -d "$as_dir" || as_fn_error "cannot create directory $as_dir"
+
+
+} # as_fn_mkdir_p
+if mkdir -p . 2>/dev/null; then
+  as_mkdir_p='mkdir -p "$as_dir"'
+else
+  test -d ./-p && rmdir ./-p
+  as_mkdir_p=false
+fi
+
+if test -x / >/dev/null 2>&1; then
+  as_test_x='test -x'
+else
+  if ls -dL / >/dev/null 2>&1; then
+    as_ls_L_option=L
+  else
+    as_ls_L_option=
+  fi
+  as_test_x='
+    eval sh -c '\''
+      if test -d "$1"; then
+       test -d "$1/.";
+      else
+       case $1 in #(
+       -*)set "./$1";;
+       esac;
+       case `ls -ld'$as_ls_L_option' "$1" 2>/dev/null` in #((
+       ???[sx]*):;;*)false;;esac;fi
+    '\'' sh
+  '
+fi
+as_executable_p=$as_test_x
+
+# Sed expression to map a string onto a valid CPP name.
+as_tr_cpp="eval sed 'y%*$as_cr_letters%P$as_cr_LETTERS%;s%[^_$as_cr_alnum]%_%g'"
+
+# Sed expression to map a string onto a valid variable name.
+as_tr_sh="eval sed 'y%*+%pp%;s%[^_$as_cr_alnum]%_%g'"
+
+
+exec 6>&1
+## ----------------------------------- ##
+## Main body of $CONFIG_STATUS script. ##
+## ----------------------------------- ##
+_ASEOF
+test $as_write_fail = 0 && chmod +x $CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# Save the log message, to keep $0 and so on meaningful, and to
+# report actual input values of CONFIG_FILES etc. instead of their
+# values after options handling.
+ac_log="
+This file was extended by $as_me, which was
+generated by GNU Autoconf 2.65.  Invocation command line was
+
+  CONFIG_FILES    = $CONFIG_FILES
+  CONFIG_HEADERS  = $CONFIG_HEADERS
+  CONFIG_LINKS    = $CONFIG_LINKS
+  CONFIG_COMMANDS = $CONFIG_COMMANDS
+  $ $0 $@
+
+on `(hostname || uname -n) 2>/dev/null | sed 1q`
+"
+
+_ACEOF
+
+case $ac_config_files in *"
+"*) set x $ac_config_files; shift; ac_config_files=$*;;
+esac
+
+case $ac_config_headers in *"
+"*) set x $ac_config_headers; shift; ac_config_headers=$*;;
+esac
+
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+# Files that config.status was made for.
+config_files="$ac_config_files"
+config_headers="$ac_config_headers"
+config_commands="$ac_config_commands"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+ac_cs_usage="\
+\`$as_me' instantiates files and other configuration actions
+from templates according to the current configuration.  Unless the files
+and actions are specified as TAGs, all are instantiated by default.
+
+Usage: $0 [OPTION]... [TAG]...
+
+  -h, --help       print this help, then exit
+  -V, --version    print version number and configuration settings, then exit
+      --config     print configuration, then exit
+  -q, --quiet, --silent
+                   do not print progress messages
+  -d, --debug      don't remove temporary files
+      --recheck    update $as_me by reconfiguring in the same conditions
+      --file=FILE[:TEMPLATE]
+                   instantiate the configuration file FILE
+      --header=FILE[:TEMPLATE]
+                   instantiate the configuration header FILE
+
+Configuration files:
+$config_files
+
+Configuration headers:
+$config_headers
+
+Configuration commands:
+$config_commands
+
+Report bugs to the package provider."
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`"
+ac_cs_version="\\
+config.status
+configured by $0, generated by GNU Autoconf 2.65,
+  with options \\"\$ac_cs_config\\"
+
+Copyright (C) 2009 Free Software Foundation, Inc.
+This config.status script is free software; the Free Software Foundation
+gives unlimited permission to copy, distribute and modify it."
+
+ac_pwd='$ac_pwd'
+srcdir='$srcdir'
+INSTALL='$INSTALL'
+MKDIR_P='$MKDIR_P'
+AWK='$AWK'
+test -n "\$AWK" || AWK=awk
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# The default lists apply if the user does not specify any file.
+ac_need_defaults=:
+while test $# != 0
+do
+  case $1 in
+  --*=*)
+    ac_option=`expr "X$1" : 'X\([^=]*\)='`
+    ac_optarg=`expr "X$1" : 'X[^=]*=\(.*\)'`
+    ac_shift=:
+    ;;
+  *)
+    ac_option=$1
+    ac_optarg=$2
+    ac_shift=shift
+    ;;
+  esac
+
+  case $ac_option in
+  # Handling of the options.
+  -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r)
+    ac_cs_recheck=: ;;
+  --version | --versio | --versi | --vers | --ver | --ve | --v | -V )
+    $as_echo "$ac_cs_version"; exit ;;
+  --config | --confi | --conf | --con | --co | --c )
+    $as_echo "$ac_cs_config"; exit ;;
+  --debug | --debu | --deb | --de | --d | -d )
+    debug=: ;;
+  --file | --fil | --fi | --f )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_FILES " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --header | --heade | --head | --hea )
+    $ac_shift
+    case $ac_optarg in
+    *\'*) ac_optarg=`$as_echo "$ac_optarg" | sed "s/'/'\\\\\\\\''/g"` ;;
+    esac
+    as_fn_append CONFIG_HEADERS " '$ac_optarg'"
+    ac_need_defaults=false;;
+  --he | --h)
+    # Conflict between --help and --header
+    as_fn_error "ambiguous option: \`$1'
+Try \`$0 --help' for more information.";;
+  --help | --hel | -h )
+    $as_echo "$ac_cs_usage"; exit ;;
+  -q | -quiet | --quiet | --quie | --qui | --qu | --q \
+  | -silent | --silent | --silen | --sile | --sil | --si | --s)
+    ac_cs_silent=: ;;
+
+  # This is an error.
+  -*) as_fn_error "unrecognized option: \`$1'
+Try \`$0 --help' for more information." ;;
+
+  *) as_fn_append ac_config_targets " $1"
+     ac_need_defaults=false ;;
+
+  esac
+  shift
+done
+
+ac_configure_extra_args=
+
+if $ac_cs_silent; then
+  exec 6>/dev/null
+  ac_configure_extra_args="$ac_configure_extra_args --silent"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+if \$ac_cs_recheck; then
+  set X '$SHELL' '$0' $ac_configure_args \$ac_configure_extra_args --no-create --no-recursion
+  shift
+  \$as_echo "running CONFIG_SHELL=$SHELL \$*" >&6
+  CONFIG_SHELL='$SHELL'
+  export CONFIG_SHELL
+  exec "\$@"
+fi
+
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+exec 5>>config.log
+{
+  echo
+  sed 'h;s/./-/g;s/^.../## /;s/...$/ ##/;p;x;p;x' <<_ASBOX
+## Running $as_me. ##
+_ASBOX
+  $as_echo "$ac_log"
+} >&5
+
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+#
+# INIT-COMMANDS
+#
+AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"
+
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+
+# Handling of arguments.
+for ac_config_target in $ac_config_targets
+do
+  case $ac_config_target in
+    "config.h") CONFIG_HEADERS="$CONFIG_HEADERS config.h" ;;
+    "depfiles") CONFIG_COMMANDS="$CONFIG_COMMANDS depfiles" ;;
+    "libopts/Makefile") CONFIG_FILES="$CONFIG_FILES libopts/Makefile" ;;
+    "Makefile") CONFIG_FILES="$CONFIG_FILES Makefile" ;;
+
+  *) as_fn_error "invalid argument: \`$ac_config_target'" "$LINENO" 5;;
+  esac
+done
+
+
+# If the user did not use the arguments to specify the items to instantiate,
+# then the envvar interface is used.  Set only those that are not.
+# We use the long form for the default assignment because of an extremely
+# bizarre bug on SunOS 4.1.3.
+if $ac_need_defaults; then
+  test "${CONFIG_FILES+set}" = set || CONFIG_FILES=$config_files
+  test "${CONFIG_HEADERS+set}" = set || CONFIG_HEADERS=$config_headers
+  test "${CONFIG_COMMANDS+set}" = set || CONFIG_COMMANDS=$config_commands
+fi
+
+# Have a temporary directory for convenience.  Make it in the build tree
+# simply because there is no reason against having it here, and in addition,
+# creating and moving files from /tmp can sometimes cause problems.
+# Hook for its removal unless debugging.
+# Note that there is a small window in which the directory will not be cleaned:
+# after its creation but before its name has been assigned to `$tmp'.
+$debug ||
+{
+  tmp=
+  trap 'exit_status=$?
+  { test -z "$tmp" || test ! -d "$tmp" || rm -fr "$tmp"; } && exit $exit_status
+' 0
+  trap 'as_fn_exit 1' 1 2 13 15
+}
+# Create a (secure) tmp directory for tmp files.
+
+{
+  tmp=`(umask 077 && mktemp -d "./confXXXXXX") 2>/dev/null` &&
+  test -n "$tmp" && test -d "$tmp"
+}  ||
+{
+  tmp=./conf$$-$RANDOM
+  (umask 077 && mkdir "$tmp")
+} || as_fn_error "cannot create a temporary directory in ." "$LINENO" 5
+
+# Set up the scripts for CONFIG_FILES section.
+# No need to generate them if there are no CONFIG_FILES.
+# This happens for instance with `./config.status config.h'.
+if test -n "$CONFIG_FILES"; then
+
+
+ac_cr=`echo X | tr X '\015'`
+# On cygwin, bash can eat \r inside `` if the user requested igncr.
+# But we know of no other shell where ac_cr would be empty at this
+# point, so we can use a bashism as a fallback.
+if test "x$ac_cr" = x; then
+  eval ac_cr=\$\'\\r\'
+fi
+ac_cs_awk_cr=`$AWK 'BEGIN { print "a\rb" }' </dev/null 2>/dev/null`
+if test "$ac_cs_awk_cr" = "a${ac_cr}b"; then
+  ac_cs_awk_cr='\r'
+else
+  ac_cs_awk_cr=$ac_cr
+fi
+
+echo 'BEGIN {' >"$tmp/subs1.awk" &&
+_ACEOF
+
+
+{
+  echo "cat >conf$$subs.awk <<_ACEOF" &&
+  echo "$ac_subst_vars" | sed 's/.*/&!$&$ac_delim/' &&
+  echo "_ACEOF"
+} >conf$$subs.sh ||
+  as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+ac_delim_num=`echo "$ac_subst_vars" | grep -c '$'`
+ac_delim='%!_!# '
+for ac_last_try in false false false false false :; do
+  . ./conf$$subs.sh ||
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+
+  ac_delim_n=`sed -n "s/.*$ac_delim\$/X/p" conf$$subs.awk | grep -c X`
+  if test $ac_delim_n = $ac_delim_num; then
+    break
+  elif $ac_last_try; then
+    as_fn_error "could not make $CONFIG_STATUS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+rm -f conf$$subs.sh
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+cat >>"\$tmp/subs1.awk" <<\\_ACAWK &&
+_ACEOF
+sed -n '
+h
+s/^/S["/; s/!.*/"]=/
+p
+g
+s/^[^!]*!//
+:repl
+t repl
+s/'"$ac_delim"'$//
+t delim
+:nl
+h
+s/\(.\{148\}\)..*/\1/
+t more1
+s/["\\]/\\&/g; s/^/"/; s/$/\\n"\\/
+p
+n
+b repl
+:more1
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t nl
+:delim
+h
+s/\(.\{148\}\)..*/\1/
+t more2
+s/["\\]/\\&/g; s/^/"/; s/$/"/
+p
+b
+:more2
+s/["\\]/\\&/g; s/^/"/; s/$/"\\/
+p
+g
+s/.\{148\}//
+t delim
+' <conf$$subs.awk | sed '
+/^[^""]/{
+  N
+  s/\n//
+}
+' >>$CONFIG_STATUS || ac_write_fail=1
+rm -f conf$$subs.awk
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+_ACAWK
+cat >>"\$tmp/subs1.awk" <<_ACAWK &&
+  for (key in S) S_is_set[key] = 1
+  FS = "\a"
+
+}
+{
+  line = $ 0
+  nfields = split(line, field, "@")
+  substed = 0
+  len = length(field[1])
+  for (i = 2; i < nfields; i++) {
+    key = field[i]
+    keylen = length(key)
+    if (S_is_set[key]) {
+      value = S[key]
+      line = substr(line, 1, len) "" value "" substr(line, len + keylen + 3)
+      len += length(value) + length(field[++i])
+      substed = 1
+    } else
+      len += 1 + keylen
+  }
+
+  print line
+}
+
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+if sed "s/$ac_cr//" < /dev/null > /dev/null 2>&1; then
+  sed "s/$ac_cr\$//; s/$ac_cr/$ac_cs_awk_cr/g"
+else
+  cat
+fi < "$tmp/subs1.awk" > "$tmp/subs.awk" \
+  || as_fn_error "could not setup config files machinery" "$LINENO" 5
+_ACEOF
+
+# VPATH may cause trouble with some makes, so we remove $(srcdir),
+# ${srcdir} and @srcdir@ from VPATH if srcdir is ".", strip leading and
+# trailing colons and then remove the whole line if VPATH becomes empty
+# (actually we leave an empty line to preserve line numbers).
+if test "x$srcdir" = x.; then
+  ac_vpsub='/^[         ]*VPATH[        ]*=/{
+s/:*\$(srcdir):*/:/
+s/:*\${srcdir}:*/:/
+s/:*@srcdir@:*/:/
+s/^\([^=]*=[    ]*\):*/\1/
+s/:*$//
+s/^[^=]*=[      ]*$//
+}'
+fi
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+fi # test -n "$CONFIG_FILES"
+
+# Set up the scripts for CONFIG_HEADERS section.
+# No need to generate them if there are no CONFIG_HEADERS.
+# This happens for instance with `./config.status Makefile'.
+if test -n "$CONFIG_HEADERS"; then
+cat >"$tmp/defines.awk" <<\_ACAWK ||
+BEGIN {
+_ACEOF
+
+# Transform confdefs.h into an awk script `defines.awk', embedded as
+# here-document in config.status, that substitutes the proper values into
+# config.h.in to produce config.h.
+
+# Create a delimiter string that does not exist in confdefs.h, to ease
+# handling of long lines.
+ac_delim='%!_!# '
+for ac_last_try in false false :; do
+  ac_t=`sed -n "/$ac_delim/p" confdefs.h`
+  if test -z "$ac_t"; then
+    break
+  elif $ac_last_try; then
+    as_fn_error "could not make $CONFIG_HEADERS" "$LINENO" 5
+  else
+    ac_delim="$ac_delim!$ac_delim _$ac_delim!! "
+  fi
+done
+
+# For the awk script, D is an array of macro values keyed by name,
+# likewise P contains macro parameters if any.  Preserve backslash
+# newline sequences.
+
+ac_word_re=[_$as_cr_Letters][_$as_cr_alnum]*
+sed -n '
+s/.\{148\}/&'"$ac_delim"'/g
+t rset
+:rset
+s/^[    ]*#[    ]*define[       ][      ]*/ /
+t def
+d
+:def
+s/\\$//
+t bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3"/p
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2"/p
+d
+:bsnl
+s/["\\]/\\&/g
+s/^ \('"$ac_word_re"'\)\(([^()]*)\)[    ]*\(.*\)/P["\1"]="\2"\
+D["\1"]=" \3\\\\\\n"\\/p
+t cont
+s/^ \('"$ac_word_re"'\)[        ]*\(.*\)/D["\1"]=" \2\\\\\\n"\\/p
+t cont
+d
+:cont
+n
+s/.\{148\}/&'"$ac_delim"'/g
+t clear
+:clear
+s/\\$//
+t bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/"/p
+d
+:bsnlc
+s/["\\]/\\&/g; s/^/"/; s/$/\\\\\\n"\\/p
+b cont
+' <confdefs.h | sed '
+s/'"$ac_delim"'/"\\\
+"/g' >>$CONFIG_STATUS || ac_write_fail=1
+
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  for (key in D) D_is_set[key] = 1
+  FS = "\a"
+}
+/^[\t ]*#[\t ]*(define|undef)[\t ]+$ac_word_re([\t (]|\$)/ {
+  line = \$ 0
+  split(line, arg, " ")
+  if (arg[1] == "#") {
+    defundef = arg[2]
+    mac1 = arg[3]
+  } else {
+    defundef = substr(arg[1], 2)
+    mac1 = arg[2]
+  }
+  split(mac1, mac2, "(") #)
+  macro = mac2[1]
+  prefix = substr(line, 1, index(line, defundef) - 1)
+  if (D_is_set[macro]) {
+    # Preserve the white space surrounding the "#".
+    print prefix "define", macro P[macro] D[macro]
+    next
+  } else {
+    # Replace #undef with comments.  This is necessary, for example,
+    # in the case of _POSIX_SOURCE, which is predefined and required
+    # on some systems where configure will not decide to define it.
+    if (defundef == "undef") {
+      print "/*", prefix defundef, macro, "*/"
+      next
+    }
+  }
+}
+{ print }
+_ACAWK
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+  as_fn_error "could not setup config headers machinery" "$LINENO" 5
+fi # test -n "$CONFIG_HEADERS"
+
+
+eval set X "  :F $CONFIG_FILES  :H $CONFIG_HEADERS    :C $CONFIG_COMMANDS"
+shift
+for ac_tag
+do
+  case $ac_tag in
+  :[FHLC]) ac_mode=$ac_tag; continue;;
+  esac
+  case $ac_mode$ac_tag in
+  :[FHL]*:*);;
+  :L* | :C*:*) as_fn_error "invalid tag \`$ac_tag'" "$LINENO" 5;;
+  :[FH]-) ac_tag=-:-;;
+  :[FH]*) ac_tag=$ac_tag:$ac_tag.in;;
+  esac
+  ac_save_IFS=$IFS
+  IFS=:
+  set x $ac_tag
+  IFS=$ac_save_IFS
+  shift
+  ac_file=$1
+  shift
+
+  case $ac_mode in
+  :L) ac_source=$1;;
+  :[FH])
+    ac_file_inputs=
+    for ac_f
+    do
+      case $ac_f in
+      -) ac_f="$tmp/stdin";;
+      *) # Look for the file first in the build tree, then in the source tree
+        # (if the path is not absolute).  The absolute path cannot be DOS-style,
+        # because $ac_f cannot contain `:'.
+        test -f "$ac_f" ||
+          case $ac_f in
+          [\\/$]*) false;;
+          *) test -f "$srcdir/$ac_f" && ac_f="$srcdir/$ac_f";;
+          esac ||
+          as_fn_error "cannot find input file: \`$ac_f'" "$LINENO" 5;;
+      esac
+      case $ac_f in *\'*) ac_f=`$as_echo "$ac_f" | sed "s/'/'\\\\\\\\''/g"`;; esac
+      as_fn_append ac_file_inputs " '$ac_f'"
+    done
+
+    # Let's still pretend it is `configure' which instantiates (i.e., don't
+    # use $as_me), people would be surprised to read:
+    #    /* config.h.  Generated by config.status.  */
+    configure_input='Generated from '`
+         $as_echo "$*" | sed 's|^[^:]*/||;s|:[^:]*/|, |g'
+       `' by configure.'
+    if test x"$ac_file" != x-; then
+      configure_input="$ac_file.  $configure_input"
+      { $as_echo "$as_me:${as_lineno-$LINENO}: creating $ac_file" >&5
+$as_echo "$as_me: creating $ac_file" >&6;}
+    fi
+    # Neutralize special characters interpreted by sed in replacement strings.
+    case $configure_input in #(
+    *\&* | *\|* | *\\* )
+       ac_sed_conf_input=`$as_echo "$configure_input" |
+       sed 's/[\\\\&|]/\\\\&/g'`;; #(
+    *) ac_sed_conf_input=$configure_input;;
+    esac
+
+    case $ac_tag in
+    *:-:* | *:-) cat >"$tmp/stdin" \
+      || as_fn_error "could not create $ac_file" "$LINENO" 5 ;;
+    esac
+    ;;
+  esac
+
+  ac_dir=`$as_dirname -- "$ac_file" ||
+$as_expr X"$ac_file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$ac_file" : 'X\(//\)[^/]' \| \
+        X"$ac_file" : 'X\(//\)$' \| \
+        X"$ac_file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$ac_file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+  as_dir="$ac_dir"; as_fn_mkdir_p
+  ac_builddir=.
+
+case "$ac_dir" in
+.) ac_dir_suffix= ac_top_builddir_sub=. ac_top_build_prefix= ;;
+*)
+  ac_dir_suffix=/`$as_echo "$ac_dir" | sed 's|^\.[\\/]||'`
+  # A ".." for each directory in $ac_dir_suffix.
+  ac_top_builddir_sub=`$as_echo "$ac_dir_suffix" | sed 's|/[^\\/]*|/..|g;s|/||'`
+  case $ac_top_builddir_sub in
+  "") ac_top_builddir_sub=. ac_top_build_prefix= ;;
+  *)  ac_top_build_prefix=$ac_top_builddir_sub/ ;;
+  esac ;;
+esac
+ac_abs_top_builddir=$ac_pwd
+ac_abs_builddir=$ac_pwd$ac_dir_suffix
+# for backward compatibility:
+ac_top_builddir=$ac_top_build_prefix
+
+case $srcdir in
+  .)  # We are building in place.
+    ac_srcdir=.
+    ac_top_srcdir=$ac_top_builddir_sub
+    ac_abs_top_srcdir=$ac_pwd ;;
+  [\\/]* | ?:[\\/]* )  # Absolute name.
+    ac_srcdir=$srcdir$ac_dir_suffix;
+    ac_top_srcdir=$srcdir
+    ac_abs_top_srcdir=$srcdir ;;
+  *) # Relative name.
+    ac_srcdir=$ac_top_build_prefix$srcdir$ac_dir_suffix
+    ac_top_srcdir=$ac_top_build_prefix$srcdir
+    ac_abs_top_srcdir=$ac_pwd/$srcdir ;;
+esac
+ac_abs_srcdir=$ac_abs_top_srcdir$ac_dir_suffix
+
+
+  case $ac_mode in
+  :F)
+  #
+  # CONFIG_FILE
+  #
+
+  case $INSTALL in
+  [\\/$]* | ?:[\\/]* ) ac_INSTALL=$INSTALL ;;
+  *) ac_INSTALL=$ac_top_build_prefix$INSTALL ;;
+  esac
+  ac_MKDIR_P=$MKDIR_P
+  case $MKDIR_P in
+  [\\/$]* | ?:[\\/]* ) ;;
+  */*) ac_MKDIR_P=$ac_top_build_prefix$MKDIR_P ;;
+  esac
+_ACEOF
+
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+# If the template does not know about datarootdir, expand it.
+# FIXME: This hack should be removed a few years after 2.60.
+ac_datarootdir_hack=; ac_datarootdir_seen=
+ac_sed_dataroot='
+/datarootdir/ {
+  p
+  q
+}
+/@datadir@/p
+/@docdir@/p
+/@infodir@/p
+/@localedir@/p
+/@mandir@/p'
+case `eval "sed -n \"\$ac_sed_dataroot\" $ac_file_inputs"` in
+*datarootdir*) ac_datarootdir_seen=yes;;
+*@datadir@*|*@docdir@*|*@infodir@*|*@localedir@*|*@mandir@*)
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&5
+$as_echo "$as_me: WARNING: $ac_file_inputs seems to ignore the --datarootdir setting" >&2;}
+_ACEOF
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+  ac_datarootdir_hack='
+  s&@datadir@&$datadir&g
+  s&@docdir@&$docdir&g
+  s&@infodir@&$infodir&g
+  s&@localedir@&$localedir&g
+  s&@mandir@&$mandir&g
+  s&\\\${datarootdir}&$datarootdir&g' ;;
+esac
+_ACEOF
+
+# Neutralize VPATH when `$srcdir' = `.'.
+# Shell code in configure.ac might set extrasub.
+# FIXME: do we really want to maintain this feature?
+cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
+ac_sed_extra="$ac_vpsub
+$extrasub
+_ACEOF
+cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
+:t
+/@[a-zA-Z_][a-zA-Z_0-9]*@/!b
+s|@configure_input@|$ac_sed_conf_input|;t t
+s&@top_builddir@&$ac_top_builddir_sub&;t t
+s&@top_build_prefix@&$ac_top_build_prefix&;t t
+s&@srcdir@&$ac_srcdir&;t t
+s&@abs_srcdir@&$ac_abs_srcdir&;t t
+s&@top_srcdir@&$ac_top_srcdir&;t t
+s&@abs_top_srcdir@&$ac_abs_top_srcdir&;t t
+s&@builddir@&$ac_builddir&;t t
+s&@abs_builddir@&$ac_abs_builddir&;t t
+s&@abs_top_builddir@&$ac_abs_top_builddir&;t t
+s&@INSTALL@&$ac_INSTALL&;t t
+s&@MKDIR_P@&$ac_MKDIR_P&;t t
+$ac_datarootdir_hack
+"
+eval sed \"\$ac_sed_extra\" "$ac_file_inputs" | $AWK -f "$tmp/subs.awk" >$tmp/out \
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
+
+test -z "$ac_datarootdir_hack$ac_datarootdir_seen" &&
+  { ac_out=`sed -n '/\${datarootdir}/p' "$tmp/out"`; test -n "$ac_out"; } &&
+  { ac_out=`sed -n '/^[         ]*datarootdir[  ]*:*=/p' "$tmp/out"`; test -z "$ac_out"; } &&
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&5
+$as_echo "$as_me: WARNING: $ac_file contains a reference to the variable \`datarootdir'
+which seems to be undefined.  Please make sure it is defined." >&2;}
+
+  rm -f "$tmp/stdin"
+  case $ac_file in
+  -) cat "$tmp/out" && rm -f "$tmp/out";;
+  *) rm -f "$ac_file" && mv "$tmp/out" "$ac_file";;
+  esac \
+  || as_fn_error "could not create $ac_file" "$LINENO" 5
+ ;;
+  :H)
+  #
+  # CONFIG_HEADER
+  #
+  if test x"$ac_file" != x-; then
+    {
+      $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs"
+    } >"$tmp/config.h" \
+      || as_fn_error "could not create $ac_file" "$LINENO" 5
+    if diff "$ac_file" "$tmp/config.h" >/dev/null 2>&1; then
+      { $as_echo "$as_me:${as_lineno-$LINENO}: $ac_file is unchanged" >&5
+$as_echo "$as_me: $ac_file is unchanged" >&6;}
+    else
+      rm -f "$ac_file"
+      mv "$tmp/config.h" "$ac_file" \
+       || as_fn_error "could not create $ac_file" "$LINENO" 5
+    fi
+  else
+    $as_echo "/* $configure_input  */" \
+      && eval '$AWK -f "$tmp/defines.awk"' "$ac_file_inputs" \
+      || as_fn_error "could not create -" "$LINENO" 5
+  fi
+# Compute "$ac_file"'s index in $config_headers.
+_am_arg="$ac_file"
+_am_stamp_count=1
+for _am_header in $config_headers :; do
+  case $_am_header in
+    $_am_arg | $_am_arg:* )
+      break ;;
+    * )
+      _am_stamp_count=`expr $_am_stamp_count + 1` ;;
+  esac
+done
+echo "timestamp for $_am_arg" >`$as_dirname -- "$_am_arg" ||
+$as_expr X"$_am_arg" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$_am_arg" : 'X\(//\)[^/]' \| \
+        X"$_am_arg" : 'X\(//\)$' \| \
+        X"$_am_arg" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$_am_arg" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`/stamp-h$_am_stamp_count
+ ;;
+
+  :C)  { $as_echo "$as_me:${as_lineno-$LINENO}: executing $ac_file commands" >&5
+$as_echo "$as_me: executing $ac_file commands" >&6;}
+ ;;
+  esac
+
+
+  case $ac_file$ac_mode in
+    "depfiles":C) test x"$AMDEP_TRUE" != x"" || {
+  # Autoconf 2.62 quotes --file arguments for eval, but not when files
+  # are listed without --file.  Let's play safe and only enable the eval
+  # if we detect the quoting.
+  case $CONFIG_FILES in
+  *\'*) eval set x "$CONFIG_FILES" ;;
+  *)   set x $CONFIG_FILES ;;
+  esac
+  shift
+  for mf
+  do
+    # Strip MF so we end up with the name of the file.
+    mf=`echo "$mf" | sed -e 's/:.*$//'`
+    # Check whether this is an Automake generated Makefile or not.
+    # We used to match only the files named `Makefile.in', but
+    # some people rename them; so instead we look at the file content.
+    # Grep'ing the first line is not enough: some people post-process
+    # each Makefile.in and add a new line on top of each file to say so.
+    # Grep'ing the whole file is not good either: AIX grep has a line
+    # limit of 2048, but all sed's we know have understand at least 4000.
+    if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
+      dirpart=`$as_dirname -- "$mf" ||
+$as_expr X"$mf" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$mf" : 'X\(//\)[^/]' \| \
+        X"$mf" : 'X\(//\)$' \| \
+        X"$mf" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$mf" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+    else
+      continue
+    fi
+    # Extract the definition of DEPDIR, am__include, and am__quote
+    # from the Makefile without running `make'.
+    DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
+    test -z "$DEPDIR" && continue
+    am__include=`sed -n 's/^am__include = //p' < "$mf"`
+    test -z "am__include" && continue
+    am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
+    # When using ansi2knr, U may be empty or an underscore; expand it
+    U=`sed -n 's/^U = //p' < "$mf"`
+    # Find all dependency output files, they are included files with
+    # $(DEPDIR) in their names.  We invoke sed twice because it is the
+    # simplest approach to changing $(DEPDIR) to its actual value in the
+    # expansion.
+    for file in `sed -n "
+      s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
+        sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
+      # Make sure the directory exists.
+      test -f "$dirpart/$file" && continue
+      fdir=`$as_dirname -- "$file" ||
+$as_expr X"$file" : 'X\(.*[^/]\)//*[^/][^/]*/*$' \| \
+        X"$file" : 'X\(//\)[^/]' \| \
+        X"$file" : 'X\(//\)$' \| \
+        X"$file" : 'X\(/\)' \| . 2>/dev/null ||
+$as_echo X"$file" |
+    sed '/^X\(.*[^/]\)\/\/*[^/][^/]*\/*$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)[^/].*/{
+           s//\1/
+           q
+         }
+         /^X\(\/\/\)$/{
+           s//\1/
+           q
+         }
+         /^X\(\/\).*/{
+           s//\1/
+           q
+         }
+         s/.*/./; q'`
+      as_dir=$dirpart/$fdir; as_fn_mkdir_p
+      # echo "creating $dirpart/$file"
+      echo '# dummy' > "$dirpart/$file"
+    done
+  done
+}
+ ;;
+
+  esac
+done # for ac_tag
+
+
+as_fn_exit 0
+_ACEOF
+ac_clean_files=$ac_clean_files_save
+
+test $ac_write_fail = 0 ||
+  as_fn_error "write failure creating $CONFIG_STATUS" "$LINENO" 5
+
+
+# configure is writing to config.log, and then calls config.status.
+# config.status does its own redirection, appending to config.log.
+# Unfortunately, on DOS this fails, as config.log is still kept open
+# by configure, so config.status won't be able to write to it; its
+# output is simply discarded.  So we exec the FD to /dev/null,
+# effectively closing config.log, so it can be properly (re)opened and
+# appended to by config.status.  When coming back to configure, we
+# need to make the FD available again.
+if test "$no_create" != yes; then
+  ac_cs_success=:
+  ac_config_status_args=
+  test "$silent" = yes &&
+    ac_config_status_args="$ac_config_status_args --quiet"
+  exec 5>/dev/null
+  $SHELL $CONFIG_STATUS $ac_config_status_args || ac_cs_success=false
+  exec 5>>config.log
+  # Use ||, not &&, to avoid exiting from the if with $? = 1, which
+  # would make configure fail if this is the last instruction.
+  $ac_cs_success || as_fn_exit $?
+fi
+if test -n "$ac_unrecognized_opts" && test "$enable_option_checking" != no; then
+  { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: unrecognized options: $ac_unrecognized_opts" >&5
+$as_echo "$as_me: WARNING: unrecognized options: $ac_unrecognized_opts" >&2;}
+fi
+
diff --git a/sntp/configure.ac b/sntp/configure.ac
new file mode 100644 (file)
index 0000000..be6943f
--- /dev/null
@@ -0,0 +1,159 @@
+# Process this file with autoconf to produce a configure script.
+AC_INIT(main.c)
+AM_INIT_AUTOMAKE([msntp],[1.6])
+AC_CONFIG_SRCDIR([header.h])
+AC_CANONICAL_HOST
+AM_CONFIG_HEADER(config.h)
+
+# Checks for programs.
+AC_PROG_CC
+
+# So far, the only shared library we might use is libopts.
+# It's a small library - we might as well use a static version of it.
+AC_DISABLE_SHARED
+
+m4_defun([_LT_AC_LANG_CXX_CONFIG], [:])
+m4_defun([_LT_AC_LANG_F77_CONFIG], [:])
+
+AC_PROG_LIBTOOL
+
+# NTP has (so far) been relying on leading-edge autogen.
+# Therefore, by default:
+# - use the version we ship with
+# - do not install it
+# - build a static copy (AC_DISABLE_SHARED - done earlier)
+case "${enable_local_libopts+set}" in
+ set) ;;
+ *) enable_local_libopts=yes ;;
+esac
+case "${enable_libopts_install+set}" in
+ set) ;;
+ *) enable_libopts_install=no ;;
+esac
+LIBOPTS_CHECK
+
+AC_MSG_CHECKING([[if $CC can handle #warning]])
+AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[]], [[#warning foo]])],[ac_cv_cpp_warning=yes],[ac_cv_cpp_warning=no])
+AC_MSG_RESULT([$ac_cv_cpp_warning])
+
+case "$ac_cv_cpp_warning" in
+ no)
+    AC_DEFINE([NO_OPTION_NAME_WARNINGS], [1], [Should we avoid #warning on option name collisions?])
+    AC_MSG_RESULT([[Enabling NO_OPTION_NAME_WARNINGS as #warning does not work]])
+    ;;
+esac
+
+AC_C_INLINE
+
+case "$ac_cv_c_inline" in
+ '')
+    ;;
+ *)
+    AC_DEFINE(HAVE_INLINE,1,[inline keyword or macro available])
+    AC_SUBST(HAVE_INLINE)
+esac
+
+
+# Checks for libraries.
+
+# Checks for header files.
+AC_HEADER_STDC
+AC_CHECK_HEADERS([arpa/inet.h fcntl.h float.h limits.h netdb.h netinet/in.h stdlib.h string.h sys/socket.h sys/time.h syslog.h unistd.h])
+
+# Checks for typedefs, structures, and compiler characteristics.
+AC_C_CONST
+AC_TYPE_SIZE_T
+AC_HEADER_TIME
+AC_STRUCT_TM
+
+AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
+               ac_cv_have_ss_family_in_struct_ss, [
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <sys/socket.h>
+               ],
+               [ struct sockaddr_storage s; s.ss_family = 1; ],
+               [ ac_cv_have_ss_family_in_struct_ss="yes" ],
+               [ ac_cv_have_ss_family_in_struct_ss="no" ],
+       )
+])
+case "$ac_cv_have_ss_family_in_struct_ss" in
+ yes)
+    AC_DEFINE(HAVE_SS_FAMILY_IN_SS, 1, [Does struct sockaddr_storage have ss_family?])
+    ;;
+esac
+
+AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
+               ac_cv_have___ss_family_in_struct_ss, [
+       AC_TRY_COMPILE(
+               [
+#include <sys/types.h>
+#include <sys/socket.h>
+               ],
+               [ struct sockaddr_storage s; s.__ss_family = 1; ],
+               [ ac_cv_have___ss_family_in_struct_ss="yes" ],
+               [ ac_cv_have___ss_family_in_struct_ss="no" ]
+       )
+])
+case "$ac_cv_have___ss_family_in_struct_ss" in
+ yes)
+    AC_DEFINE(HAVE___SS_FAMILY_IN_SS, 1, [Does struct sockaddr_storage have __ss_family?])
+    ;;
+esac
+
+case "$ac_cv_have_ss_family_in_struct_ss$ac_cv_have___ss_family_in_struct_ss" in
+ noyes)
+    AC_DEFINE_UNQUOTED([ss_family], [__ss_family], [normalize ss_family access])
+    AC_DEFINE_UNQUOTED([ss_len], [__ss_len], [normalize ss_len access])
+    ;;
+esac
+
+# Checks for library functions.
+#AC_FUNC_MEMCMP         dnl HMS: we don't have a memcmp.c to use here, so why bother?
+AC_FUNC_SETVBUF_REVERSED
+AC_TYPE_SIGNAL
+AC_CHECK_FUNCS([alarm])
+AC_CHECK_FUNC([gethostent], , AC_SEARCH_LIBS([gethostent], [nsl], , , [-lsocket]))
+AC_CHECK_FUNCS([gettimeofday inet_ntoa memset])
+AC_CHECK_FUNCS([socket], , AC_SEARCH_LIBS([socket], [socket]))
+AC_CHECK_FUNCS([sqrt], , AC_SEARCH_LIBS([sqrt], [m]))
+AC_CHECK_FUNCS([strrchr])
+
+case "$host" in
+ *-*-hpux10.*) # at least for hppa2.0-hp-hpux10.20
+    case "$GCC" in
+     yes)
+       ;;
+     *) CFLAGS="$CFLAGS -Wp,-H18816"
+       ;;
+    esac
+    ;;
+ *-*-linux*)
+    CFLAGS="$CFLAGS -DADJTIME_MISSING"
+    ;;
+ *-*-sunos*)
+    CFLAGS="$CFLAGS -DNONBLOCK_BROKEN"
+    ;;
+esac
+
+AC_MSG_CHECKING(for bin subdirectory)
+AC_ARG_WITH(binsubdir,
+       AC_HELP_STRING([--with-binsubdir], [bin ={bin,sbin}]),
+       use_binsubdir="$withval", use_binsubdir="bin")
+
+case "$use_binsubdir" in
+ bin)
+    ;;
+ sbin)
+    ;;
+ *)
+    AC_MSG_ERROR([<$use_binsubdir> is illegal - must be "bin" or "sbin"])
+    ;;
+esac
+AC_MSG_RESULT($use_binsubdir)
+BINSUBDIR=$use_binsubdir
+AC_SUBST(BINSUBDIR)
+
+AC_CONFIG_FILES([Makefile])
+AC_OUTPUT
diff --git a/sntp/depcomp b/sntp/depcomp
new file mode 100755 (executable)
index 0000000..04701da
--- /dev/null
@@ -0,0 +1,530 @@
+#! /bin/sh
+# depcomp - compile a program generating dependencies as side-effects
+
+scriptversion=2005-07-09.11
+
+# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
+
+case $1 in
+  '')
+     echo "$0: No command.  Try \`$0 --help' for more information." 1>&2
+     exit 1;
+     ;;
+  -h | --h*)
+    cat <<\EOF
+Usage: depcomp [--help] [--version] PROGRAM [ARGS]
+
+Run PROGRAMS ARGS to compile a file, generating dependencies
+as side-effects.
+
+Environment variables:
+  depmode     Dependency tracking mode.
+  source      Source file read by `PROGRAMS ARGS'.
+  object      Object file output by `PROGRAMS ARGS'.
+  DEPDIR      directory where to store dependencies.
+  depfile     Dependency file to output.
+  tmpdepfile  Temporary file to use when outputing dependencies.
+  libtool     Whether libtool is used (yes/no).
+
+Report bugs to <bug-automake@gnu.org>.
+EOF
+    exit $?
+    ;;
+  -v | --v*)
+    echo "depcomp $scriptversion"
+    exit $?
+    ;;
+esac
+
+if test -z "$depmode" || test -z "$source" || test -z "$object"; then
+  echo "depcomp: Variables source, object and depmode must be set" 1>&2
+  exit 1
+fi
+
+# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
+depfile=${depfile-`echo "$object" |
+  sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
+tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
+
+rm -f "$tmpdepfile"
+
+# Some modes work just like other modes, but use different flags.  We
+# parameterize here, but still list the modes in the big case below,
+# to make depend.m4 easier to write.  Note that we *cannot* use a case
+# here, because this file can only contain one case statement.
+if test "$depmode" = hp; then
+  # HP compiler uses -M and no extra arg.
+  gccflag=-M
+  depmode=gcc
+fi
+
+if test "$depmode" = dashXmstdout; then
+   # This is just like dashmstdout with a different argument.
+   dashmflag=-xM
+   depmode=dashmstdout
+fi
+
+case "$depmode" in
+gcc3)
+## gcc 3 implements dependency tracking that does exactly what
+## we want.  Yay!  Note: for some reason libtool 1.4 doesn't like
+## it if -MD -MP comes after the -MF stuff.  Hmm.
+  "$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  mv "$tmpdepfile" "$depfile"
+  ;;
+
+gcc)
+## There are various ways to get dependency output from gcc.  Here's
+## why we pick this rather obscure method:
+## - Don't want to use -MD because we'd like the dependencies to end
+##   up in a subdir.  Having to rename by hand is ugly.
+##   (We might end up doing this anyway to support other compilers.)
+## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
+##   -MM, not -M (despite what the docs say).
+## - Using -M directly means running the compiler twice (even worse
+##   than renaming).
+  if test -z "$gccflag"; then
+    gccflag=-MD,
+  fi
+  "$@" -Wp,"$gccflag$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
+## The second -e expression handles DOS-style file names with drive letters.
+  sed -e 's/^[^:]*: / /' \
+      -e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
+## This next piece of magic avoids the `deleted header file' problem.
+## The problem is that when a header file which appears in a .P file
+## is deleted, the dependency causes make to die (because there is
+## typically no way to rebuild the header).  We avoid this by adding
+## dummy dependencies for each header file.  Too bad gcc doesn't do
+## this for us directly.
+  tr ' ' '
+' < "$tmpdepfile" |
+## Some versions of gcc put a space before the `:'.  On the theory
+## that the space means something, we add a space to the output as
+## well.
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+hp)
+  # This case exists only to let depend.m4 do its work.  It works by
+  # looking at the text of this script.  This case will never be run,
+  # since it is checked for above.
+  exit 1
+  ;;
+
+sgi)
+  if test "$libtool" = yes; then
+    "$@" "-Wp,-MDupdate,$tmpdepfile"
+  else
+    "$@" -MDupdate "$tmpdepfile"
+  fi
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+
+  if test -f "$tmpdepfile"; then  # yes, the sourcefile depend on other files
+    echo "$object : \\" > "$depfile"
+
+    # Clip off the initial element (the dependent).  Don't try to be
+    # clever and replace this with sed code, as IRIX sed won't handle
+    # lines with more than a fixed number of characters (4096 in
+    # IRIX 6.2 sed, 8192 in IRIX 6.5).  We also remove comment lines;
+    # the IRIX cc adds comments like `#:fec' to the end of the
+    # dependency line.
+    tr ' ' '
+' < "$tmpdepfile" \
+    | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
+    tr '
+' ' ' >> $depfile
+    echo >> $depfile
+
+    # The second pass generates a dummy entry for each header file.
+    tr ' ' '
+' < "$tmpdepfile" \
+   | sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
+   >> $depfile
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+aix)
+  # The C for AIX Compiler uses -M and outputs the dependencies
+  # in a .u file.  In older versions, this file always lives in the
+  # current directory.  Also, the AIX compiler puts `$object:' at the
+  # start of each line; $object doesn't have directory information.
+  # Version 6 uses the directory in both cases.
+  stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
+  tmpdepfile="$stripped.u"
+  if test "$libtool" = yes; then
+    "$@" -Wc,-M
+  else
+    "$@" -M
+  fi
+  stat=$?
+
+  if test -f "$tmpdepfile"; then :
+  else
+    stripped=`echo "$stripped" | sed 's,^.*/,,'`
+    tmpdepfile="$stripped.u"
+  fi
+
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+
+  if test -f "$tmpdepfile"; then
+    outname="$stripped.o"
+    # Each line is of the form `foo.o: dependent.h'.
+    # Do two passes, one to just change these to
+    # `$object: dependent.h' and one to simply `dependent.h:'.
+    sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
+    sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
+  else
+    # The sourcefile does not contain any dependencies, so just
+    # store a dummy comment line, to avoid errors with the Makefile
+    # "include basename.Plo" scheme.
+    echo "#dummy" > "$depfile"
+  fi
+  rm -f "$tmpdepfile"
+  ;;
+
+icc)
+  # Intel's C compiler understands `-MD -MF file'.  However on
+  #    icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
+  # ICC 7.0 will fill foo.d with something like
+  #    foo.o: sub/foo.c
+  #    foo.o: sub/foo.h
+  # which is wrong.  We want:
+  #    sub/foo.o: sub/foo.c
+  #    sub/foo.o: sub/foo.h
+  #    sub/foo.c:
+  #    sub/foo.h:
+  # ICC 7.1 will output
+  #    foo.o: sub/foo.c sub/foo.h
+  # and will wrap long lines using \ :
+  #    foo.o: sub/foo.c ... \
+  #     sub/foo.h ... \
+  #     ...
+
+  "$@" -MD -MF "$tmpdepfile"
+  stat=$?
+  if test $stat -eq 0; then :
+  else
+    rm -f "$tmpdepfile"
+    exit $stat
+  fi
+  rm -f "$depfile"
+  # Each line is of the form `foo.o: dependent.h',
+  # or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
+  # Do two passes, one to just change these to
+  # `$object: dependent.h' and one to simply `dependent.h:'.
+  sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
+  # Some versions of the HPUX 10.20 sed can't process this invocation
+  # correctly.  Breaking it into two sed invocations is a workaround.
+  sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
+    sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+tru64)
+   # The Tru64 compiler uses -MD to generate dependencies as a side
+   # effect.  `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
+   # At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
+   # dependencies in `foo.d' instead, so we check for that too.
+   # Subdirectories are respected.
+   dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
+   test "x$dir" = "x$object" && dir=
+   base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
+
+   if test "$libtool" = yes; then
+      # With Tru64 cc, shared objects can also be used to make a
+      # static library.  This mecanism is used in libtool 1.4 series to
+      # handle both shared and static libraries in a single compilation.
+      # With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
+      #
+      # With libtool 1.5 this exception was removed, and libtool now
+      # generates 2 separate objects for the 2 libraries.  These two
+      # compilations output dependencies in in $dir.libs/$base.o.d and
+      # in $dir$base.o.d.  We have to check for both files, because
+      # one of the two compilations can be disabled.  We should prefer
+      # $dir$base.o.d over $dir.libs/$base.o.d because the latter is
+      # automatically cleaned when .libs/ is deleted, while ignoring
+      # the former would cause a distcleancheck panic.
+      tmpdepfile1=$dir.libs/$base.lo.d   # libtool 1.4
+      tmpdepfile2=$dir$base.o.d          # libtool 1.5
+      tmpdepfile3=$dir.libs/$base.o.d    # libtool 1.5
+      tmpdepfile4=$dir.libs/$base.d      # Compaq CCC V6.2-504
+      "$@" -Wc,-MD
+   else
+      tmpdepfile1=$dir$base.o.d
+      tmpdepfile2=$dir$base.d
+      tmpdepfile3=$dir$base.d
+      tmpdepfile4=$dir$base.d
+      "$@" -MD
+   fi
+
+   stat=$?
+   if test $stat -eq 0; then :
+   else
+      rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+      exit $stat
+   fi
+
+   for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
+   do
+     test -f "$tmpdepfile" && break
+   done
+   if test -f "$tmpdepfile"; then
+      sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
+      # That's a tab and a space in the [].
+      sed -e 's,^.*\.[a-z]*:[   ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
+   else
+      echo "#dummy" > "$depfile"
+   fi
+   rm -f "$tmpdepfile"
+   ;;
+
+#nosideeffect)
+  # This comment above is used by automake to tell side-effect
+  # dependency tracking mechanisms from slower ones.
+
+dashmstdout)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  test -z "$dashmflag" && dashmflag=-M
+  # Require at least two characters before searching for `:'
+  # in the target name.  This is to cope with DOS-style filenames:
+  # a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
+  "$@" $dashmflag |
+    sed 's:^[  ]*[^: ][^:][^:]*\:[    ]*:'"$object"'\: :' > "$tmpdepfile"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  tr ' ' '
+' < "$tmpdepfile" | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+dashXmstdout)
+  # This case only exists to satisfy depend.m4.  It is never actually
+  # run, as this mode is specially recognized in the preamble.
+  exit 1
+  ;;
+
+makedepend)
+  "$@" || exit $?
+  # Remove any Libtool call
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+  # X makedepend
+  shift
+  cleared=no
+  for arg in "$@"; do
+    case $cleared in
+    no)
+      set ""; shift
+      cleared=yes ;;
+    esac
+    case "$arg" in
+    -D*|-I*)
+      set fnord "$@" "$arg"; shift ;;
+    # Strip any option that makedepend may not understand.  Remove
+    # the object too, otherwise makedepend will parse it as a source file.
+    -*|$object)
+      ;;
+    *)
+      set fnord "$@" "$arg"; shift ;;
+    esac
+  done
+  obj_suffix="`echo $object | sed 's/^.*\././'`"
+  touch "$tmpdepfile"
+  ${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
+  rm -f "$depfile"
+  cat < "$tmpdepfile" > "$depfile"
+  sed '1,2d' "$tmpdepfile" | tr ' ' '
+' | \
+## Some versions of the HPUX 10.20 sed can't process this invocation
+## correctly.  Breaking it into two sed invocations is a workaround.
+    sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile" "$tmpdepfile".bak
+  ;;
+
+cpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout.
+  "$@" || exit $?
+
+  # Remove the call to Libtool.
+  if test "$libtool" = yes; then
+    while test $1 != '--mode=compile'; do
+      shift
+    done
+    shift
+  fi
+
+  # Remove `-o $object'.
+  IFS=" "
+  for arg
+  do
+    case $arg in
+    -o)
+      shift
+      ;;
+    $object)
+      shift
+      ;;
+    *)
+      set fnord "$@" "$arg"
+      shift # fnord
+      shift # $arg
+      ;;
+    esac
+  done
+
+  "$@" -E |
+    sed -n -e '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' \
+       -e '/^#line [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
+    sed '$ s: \\$::' > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  cat < "$tmpdepfile" >> "$depfile"
+  sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+msvisualcpp)
+  # Important note: in order to support this mode, a compiler *must*
+  # always write the preprocessed file to stdout, regardless of -o,
+  # because we must use -o when running libtool.
+  "$@" || exit $?
+  IFS=" "
+  for arg
+  do
+    case "$arg" in
+    "-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
+       set fnord "$@"
+       shift
+       shift
+       ;;
+    *)
+       set fnord "$@" "$arg"
+       shift
+       shift
+       ;;
+    esac
+  done
+  "$@" -E |
+  sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
+  rm -f "$depfile"
+  echo "$object : \\" > "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::   \1 \\:p' >> "$depfile"
+  echo "       " >> "$depfile"
+  . "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
+  rm -f "$tmpdepfile"
+  ;;
+
+none)
+  exec "$@"
+  ;;
+
+*)
+  echo "Unknown depmode $depmode" 1>&2
+  exit 1
+  ;;
+esac
+
+exit 0
+
+# Local Variables:
+# mode: shell-script
+# sh-indentation: 2
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/sntp/header.h b/sntp/header.h
new file mode 100644 (file)
index 0000000..c752d15
--- /dev/null
@@ -0,0 +1,87 @@
+/*  Copyright (C) 1996 N.M. Maclaren
+    Copyright (C) 1996 The University of Cambridge
+
+This includes all of the 'safe' headers and definitions used across modules.
+No changes should be needed for any system that is even remotely like Unix. */
+
+
+
+#include <ctype.h>
+#include <errno.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <time.h>
+
+
+
+#define VERSION         "1.6"          /* Just the version string */
+#define MAX_SOCKETS        10          /* Maximum number of addresses */
+
+#ifndef LOCKNAME
+#    define LOCKNAME "/etc/sntp.pid"  /* Stores the pid */
+#endif
+#ifndef SAVENAME
+#    define SAVENAME "/etc/sntp.state" /* Stores the recovery state */
+#endif
+
+
+
+/* Defined in main.c */
+
+#define op_client           1          /* Behave as a challenge client */
+#define op_listen           2          /* Behave as a listening client */
+
+extern const char *argv0;
+
+extern int verbose, operation;
+
+extern const char *lockname;
+
+extern void fatal (int syserr, const char *message, const char *insert);
+
+
+
+/* Defined in unix.c */
+
+extern void do_nothing (int seconds);
+
+extern int ftty (FILE *file);
+
+extern void set_lock (int lock);
+
+extern void log_message (const char *message);
+
+
+
+/* Defined in internet.c */
+
+/* extern void find_address (struct in_addr *address, int *port, char *hostname,
+    int timespan); */
+
+#define PREF_FAM_INET  1
+#define PREF_FAM_INET6 2
+extern void preferred_family(int);
+
+
+/* Defined in socket.c */
+
+extern void open_socket (int which, char *hostnames, int timespan);
+
+extern void write_socket (int which, void *packet, int length);
+
+extern int read_socket (int which, void *packet, int length, int waiting);
+
+extern int flush_socket (int which);
+
+extern void close_socket (int which);
+
+
+
+/* Defined in timing.c */
+
+extern double current_time (double offset);
+
+extern time_t convert_time (double value, int *millisecs);
+
+extern void adjust_time (double difference, int immediate, double ignore);
diff --git a/sntp/install-sh b/sntp/install-sh
new file mode 100755 (executable)
index 0000000..4d4a951
--- /dev/null
@@ -0,0 +1,323 @@
+#!/bin/sh
+# install - install a program, script, or datafile
+
+scriptversion=2005-05-14.22
+
+# This originates from X11R5 (mit/util/scripts/install.sh), which was
+# later released in X11R6 (xc/config/util/install.sh) with the
+# following copyright and license.
+#
+# Copyright (C) 1994 X Consortium
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to
+# deal in the Software without restriction, including without limitation the
+# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
+# sell copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
+# X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
+# AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNEC-
+# TION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+#
+# Except as contained in this notice, the name of the X Consortium shall not
+# be used in advertising or otherwise to promote the sale, use or other deal-
+# ings in this Software without prior written authorization from the X Consor-
+# tium.
+#
+#
+# FSF changes to this file are in the public domain.
+#
+# Calling this script install-sh is preferred over install.sh, to prevent
+# `make' implicit rules from creating a file called install from it
+# when there is no Makefile.
+#
+# This script is compatible with the BSD install script, but was written
+# from scratch.  It can only install one file at a time, a restriction
+# shared with many OS's install programs.
+
+# set DOITPROG to echo to test this script
+
+# Don't use :- since 4.3BSD and earlier shells don't like it.
+doit="${DOITPROG-}"
+
+# put in absolute paths if you don't have them in your path; or use env. vars.
+
+mvprog="${MVPROG-mv}"
+cpprog="${CPPROG-cp}"
+chmodprog="${CHMODPROG-chmod}"
+chownprog="${CHOWNPROG-chown}"
+chgrpprog="${CHGRPPROG-chgrp}"
+stripprog="${STRIPPROG-strip}"
+rmprog="${RMPROG-rm}"
+mkdirprog="${MKDIRPROG-mkdir}"
+
+chmodcmd="$chmodprog 0755"
+chowncmd=
+chgrpcmd=
+stripcmd=
+rmcmd="$rmprog -f"
+mvcmd="$mvprog"
+src=
+dst=
+dir_arg=
+dstarg=
+no_target_directory=
+
+usage="Usage: $0 [OPTION]... [-T] SRCFILE DSTFILE
+   or: $0 [OPTION]... SRCFILES... DIRECTORY
+   or: $0 [OPTION]... -t DIRECTORY SRCFILES...
+   or: $0 [OPTION]... -d DIRECTORIES...
+
+In the 1st form, copy SRCFILE to DSTFILE.
+In the 2nd and 3rd, copy all SRCFILES to DIRECTORY.
+In the 4th, create DIRECTORIES.
+
+Options:
+-c         (ignored)
+-d         create directories instead of installing files.
+-g GROUP   $chgrpprog installed files to GROUP.
+-m MODE    $chmodprog installed files to MODE.
+-o USER    $chownprog installed files to USER.
+-s         $stripprog installed files.
+-t DIRECTORY  install into DIRECTORY.
+-T         report an error if DSTFILE is a directory.
+--help     display this help and exit.
+--version  display version info and exit.
+
+Environment variables override the default commands:
+  CHGRPPROG CHMODPROG CHOWNPROG CPPROG MKDIRPROG MVPROG RMPROG STRIPPROG
+"
+
+while test -n "$1"; do
+  case $1 in
+    -c) shift
+        continue;;
+
+    -d) dir_arg=true
+        shift
+        continue;;
+
+    -g) chgrpcmd="$chgrpprog $2"
+        shift
+        shift
+        continue;;
+
+    --help) echo "$usage"; exit $?;;
+
+    -m) chmodcmd="$chmodprog $2"
+        shift
+        shift
+        continue;;
+
+    -o) chowncmd="$chownprog $2"
+        shift
+        shift
+        continue;;
+
+    -s) stripcmd=$stripprog
+        shift
+        continue;;
+
+    -t) dstarg=$2
+       shift
+       shift
+       continue;;
+
+    -T) no_target_directory=true
+       shift
+       continue;;
+
+    --version) echo "$0 $scriptversion"; exit $?;;
+
+    *)  # When -d is used, all remaining arguments are directories to create.
+       # When -t is used, the destination is already specified.
+       test -n "$dir_arg$dstarg" && break
+        # Otherwise, the last argument is the destination.  Remove it from $@.
+       for arg
+       do
+          if test -n "$dstarg"; then
+           # $@ is not empty: it contains at least $arg.
+           set fnord "$@" "$dstarg"
+           shift # fnord
+         fi
+         shift # arg
+         dstarg=$arg
+       done
+       break;;
+  esac
+done
+
+if test -z "$1"; then
+  if test -z "$dir_arg"; then
+    echo "$0: no input file specified." >&2
+    exit 1
+  fi
+  # It's OK to call `install-sh -d' without argument.
+  # This can happen when creating conditional directories.
+  exit 0
+fi
+
+for src
+do
+  # Protect names starting with `-'.
+  case $src in
+    -*) src=./$src ;;
+  esac
+
+  if test -n "$dir_arg"; then
+    dst=$src
+    src=
+
+    if test -d "$dst"; then
+      mkdircmd=:
+      chmodcmd=
+    else
+      mkdircmd=$mkdirprog
+    fi
+  else
+    # Waiting for this to be detected by the "$cpprog $src $dsttmp" command
+    # might cause directories to be created, which would be especially bad
+    # if $src (and thus $dsttmp) contains '*'.
+    if test ! -f "$src" && test ! -d "$src"; then
+      echo "$0: $src does not exist." >&2
+      exit 1
+    fi
+
+    if test -z "$dstarg"; then
+      echo "$0: no destination specified." >&2
+      exit 1
+    fi
+
+    dst=$dstarg
+    # Protect names starting with `-'.
+    case $dst in
+      -*) dst=./$dst ;;
+    esac
+
+    # If destination is a directory, append the input filename; won't work
+    # if double slashes aren't ignored.
+    if test -d "$dst"; then
+      if test -n "$no_target_directory"; then
+       echo "$0: $dstarg: Is a directory" >&2
+       exit 1
+      fi
+      dst=$dst/`basename "$src"`
+    fi
+  fi
+
+  # This sed command emulates the dirname command.
+  dstdir=`echo "$dst" | sed -e 's,/*$,,;s,[^/]*$,,;s,/*$,,;s,^$,.,'`
+
+  # Make sure that the destination directory exists.
+
+  # Skip lots of stat calls in the usual case.
+  if test ! -d "$dstdir"; then
+    defaultIFS='
+        '
+    IFS="${IFS-$defaultIFS}"
+
+    oIFS=$IFS
+    # Some sh's can't handle IFS=/ for some reason.
+    IFS='%'
+    set x `echo "$dstdir" | sed -e 's@/@%@g' -e 's@^%@/@'`
+    shift
+    IFS=$oIFS
+
+    pathcomp=
+
+    while test $# -ne 0 ; do
+      pathcomp=$pathcomp$1
+      shift
+      if test ! -d "$pathcomp"; then
+        $mkdirprog "$pathcomp"
+       # mkdir can fail with a `File exist' error in case several
+       # install-sh are creating the directory concurrently.  This
+       # is OK.
+       test -d "$pathcomp" || exit
+      fi
+      pathcomp=$pathcomp/
+    done
+  fi
+
+  if test -n "$dir_arg"; then
+    $doit $mkdircmd "$dst" \
+      && { test -z "$chowncmd" || $doit $chowncmd "$dst"; } \
+      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dst"; } \
+      && { test -z "$stripcmd" || $doit $stripcmd "$dst"; } \
+      && { test -z "$chmodcmd" || $doit $chmodcmd "$dst"; }
+
+  else
+    dstfile=`basename "$dst"`
+
+    # Make a couple of temp file names in the proper directory.
+    dsttmp=$dstdir/_inst.$$_
+    rmtmp=$dstdir/_rm.$$_
+
+    # Trap to clean up those temp files at exit.
+    trap 'ret=$?; rm -f "$dsttmp" "$rmtmp" && exit $ret' 0
+    trap '(exit $?); exit' 1 2 13 15
+
+    # Copy the file name to the temp name.
+    $doit $cpprog "$src" "$dsttmp" &&
+
+    # and set any options; do chmod last to preserve setuid bits.
+    #
+    # If any of these fail, we abort the whole thing.  If we want to
+    # ignore errors from any of these, just make sure not to ignore
+    # errors from the above "$doit $cpprog $src $dsttmp" command.
+    #
+    { test -z "$chowncmd" || $doit $chowncmd "$dsttmp"; } \
+      && { test -z "$chgrpcmd" || $doit $chgrpcmd "$dsttmp"; } \
+      && { test -z "$stripcmd" || $doit $stripcmd "$dsttmp"; } \
+      && { test -z "$chmodcmd" || $doit $chmodcmd "$dsttmp"; } &&
+
+    # Now rename the file to the real destination.
+    { $doit $mvcmd -f "$dsttmp" "$dstdir/$dstfile" 2>/dev/null \
+      || {
+          # The rename failed, perhaps because mv can't rename something else
+          # to itself, or perhaps because mv is so ancient that it does not
+          # support -f.
+
+          # Now remove or move aside any old file at destination location.
+          # We try this two ways since rm can't unlink itself on some
+          # systems and the destination file might be busy for other
+          # reasons.  In this case, the final cleanup might fail but the new
+          # file should still install successfully.
+          {
+            if test -f "$dstdir/$dstfile"; then
+              $doit $rmcmd -f "$dstdir/$dstfile" 2>/dev/null \
+              || $doit $mvcmd -f "$dstdir/$dstfile" "$rmtmp" 2>/dev/null \
+              || {
+                echo "$0: cannot unlink or rename $dstdir/$dstfile" >&2
+                (exit 1); exit 1
+              }
+            else
+              :
+            fi
+          } &&
+
+          # Now rename the file to the real destination.
+          $doit $mvcmd "$dsttmp" "$dstdir/$dstfile"
+        }
+    }
+  fi || { (exit 1); exit 1; }
+done
+
+# The final little trick to "correctly" pass the exit status to the exit trap.
+{
+  (exit 0); exit 0
+}
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/sntp/internet.c b/sntp/internet.c
new file mode 100644 (file)
index 0000000..a1040f1
--- /dev/null
@@ -0,0 +1,207 @@
+/*  Copyright (C) 1996 N.M. Maclaren
+    Copyright (C) 1996 The University of Cambridge
+
+This includes all of the code needed to handle Internet addressing.  It is way
+outside current POSIX, unfortunately.  It should be easy to convert to a system
+that uses another mechanism.  The signal handling is not necessary for its
+function, but is an attempt to avoid the program hanging when the name server
+is inaccessible. */
+
+
+
+#include "header.h"
+#include "internet.h"
+
+#include <netdb.h>
+#include <arpa/inet.h>
+
+#define INTERNET
+#include "kludges.h"
+#undef INTERNET
+
+
+/* Used to force dns resolving to ipv4 or ipv6 addresses. */
+static int pref_family;
+
+/* There needs to be some disgusting grobble for handling timeouts, which is
+identical to the grobble in socket.c. */
+
+static jmp_buf jump_buffer;
+
+static void jump_handler (int sig) {
+    longjmp(jump_buffer,1);
+}
+
+static void clear_alarm (void) {
+    int k;
+
+    k = errno;
+    alarm(0);
+    errno = 0;
+    if (signal(SIGALRM,SIG_DFL) == SIG_ERR)
+        fatal(1,"unable to reset signal handler",NULL);
+    errno = k;
+}
+
+void preferred_family(int fam) {
+       switch(fam) {
+       case PREF_FAM_INET:
+           pref_family = AF_INET;
+           break;
+#ifdef HAVE_IPV6
+       case PREF_FAM_INET6:
+           pref_family = AF_INET6;
+           break;
+#endif
+       default:
+           fatal(0,"unable to set the preferred family", NULL);
+           break;
+       }
+}
+
+#ifdef HAVE_IPV6
+
+void find_address (struct sockaddr_storage *address,
+    struct sockaddr_storage *anywhere,
+    int *port, char *hostname, int timespan) {
+
+/* Locate the specified NTP server and return its Internet address and port 
+number. */
+
+    int family, rval;
+    struct addrinfo hints;
+    struct addrinfo *res;
+
+    res = NULL;
+    memset(address, 0, sizeof(struct sockaddr_storage));
+    memset(anywhere, 0, sizeof(struct sockaddr_storage));
+
+    if (setjmp(jump_buffer))
+        fatal(0,"unable to set up access to NTP server %s",hostname);
+    errno = 0;
+    if (signal(SIGALRM,jump_handler) == SIG_ERR)
+        fatal(1,"unable to set up signal handler",NULL);
+    alarm((unsigned int)timespan);
+
+/* Look up the Internet name or IP number. */
+    memset(&hints, 0, sizeof(hints));
+    hints.ai_socktype = SOCK_DGRAM;
+    hints.ai_family = pref_family;
+    rval = getaddrinfo(hostname, "ntp", &hints, &res);
+    if (rval != 0)
+       fatal(0, "getaddrinfo(hostname, ntp)  failed with %s",
+           gai_strerror(rval));
+
+/* Now clear the timer and check the result. */
+
+    clear_alarm();
+    /* There can be more than one address in the list, but for now only
+    use the first. */
+    memcpy(address, res->ai_addr, res->ai_addrlen);
+    family = res->ai_family;
+    freeaddrinfo(res);
+
+    switch(family) {
+    case AF_INET:
+       hints.ai_family = AF_INET;
+       hints.ai_flags = AI_PASSIVE;
+       rval = getaddrinfo(NULL, "ntp", &hints, &res);
+       if (rval != 0)
+           fatal(0, "getaddrinfo(NULL, ntp) failed with %s",
+               gai_strerror(rval));
+       memcpy(anywhere, res->ai_addr, res->ai_addrlen);
+       freeaddrinfo(res);
+       break;
+    case AF_INET6:
+       hints.ai_family = AF_INET6;
+       hints.ai_flags = AI_PASSIVE;
+       rval = getaddrinfo(NULL, "ntp", &hints, &res);
+       if (rval != 0)
+           fatal(0, "getaddrinfo(NULL, ntp, INET6, AI_PASSIVE) failed with %s",
+               gai_strerror(rval));
+       memcpy(anywhere, res->ai_addr, res->ai_addrlen);
+       freeaddrinfo(res);
+       break;
+    }
+}
+
+#else
+
+void find_address (struct in_addr *address, struct in_addr *anywhere,
+    int *port, char *hostname, int timespan) {
+
+/* Locate the specified NTP server and return its Internet address and port 
+number. */
+
+    unsigned long ipaddr;
+    struct in_addr nowhere[1];
+    struct hostent *host;
+    struct servent *service;
+
+/* Set up the reserved Internet addresses, attempting not to assume that
+addresses are 32 bits. */
+
+    local_to_address(nowhere,INADDR_LOOPBACK);
+    local_to_address(anywhere,INADDR_ANY);
+
+/* Check the address, if any.  This assumes that the DNS is reliable, or is at
+least checked by someone else.  But it doesn't assume that it is accessible, so
+it needs to set up a timeout. */
+
+    if (hostname == NULL)
+        *address = *anywhere;
+    else {
+        if (setjmp(jump_buffer))
+            fatal(0,"unable to set up access to NTP server %s",hostname);
+        errno = 0;
+        if (signal(SIGALRM,jump_handler) == SIG_ERR)
+            fatal(1,"unable to set up signal handler",NULL);
+        alarm((unsigned int)timespan);
+
+/* Look up the Internet name or IP number. */
+
+        if (! isdigit(hostname[0])) {
+            errno = 0;
+            host = gethostbyname(hostname);
+        } else {
+            if ((ipaddr = inet_addr(hostname)) == (unsigned long)-1)
+                fatal(0,"invalid IP number %s",hostname);
+            network_to_address(address,ipaddr);
+            errno = 0;
+            host = gethostbyaddr((void *)address,sizeof(struct in_addr),
+                AF_INET);
+        }
+
+/* Now clear the timer and check the result. */
+
+        clear_alarm();
+        if (host == NULL) fatal(1,"unable to locate IP address/number",NULL);
+        if (host->h_length != sizeof(struct in_addr))
+            fatal(0,"the address does not seem to be an Internet one",NULL);
+        *address = *((struct in_addr **)host->h_addr_list)[0];
+        if (memcmp(address,nowhere,sizeof(struct in_addr)) == 0
+           || memcmp(address,anywhere,sizeof(struct in_addr)) == 0)
+            fatal(0,"reserved IP numbers cannot be used",NULL);
+        if (verbose)
+            fprintf(stderr,
+                "%s: using NTP server %s (%s)\n",
+                argv0,host->h_name,inet_ntoa(*address));
+    }
+
+/* Find out the port number (usually from /etc/services), and leave it in 
+network format.  This is assumed not to be obtained from a network service!
+Note that a port number is not assumed to be 16 bits. */
+
+    if ((service = getservbyname("ntp","udp")) != NULL) {
+        *port = service->s_port;
+        if (verbose > 2)
+            fprintf(stderr,"Using port %d for NTP\n",port_to_integer(*port));
+    } else {
+        *port = NTP_PORT;
+        if (verbose)
+            fprintf(stderr,
+                "%s: assuming port %d for NTP - check /etc/services\n",
+                argv0,port_to_integer(*port));
+    }
+}
+#endif
diff --git a/sntp/internet.h b/sntp/internet.h
new file mode 100644 (file)
index 0000000..5241314
--- /dev/null
@@ -0,0 +1,47 @@
+/*  Copyright (C) 1996 N.M. Maclaren
+    Copyright (C) 1996 The University of Cambridge
+
+This includes all of the 'Internet' headers and definitions used across
+modules, including those for handling timeouts.  No changes should be needed
+for any version of Unix with Internet (IP version 5) addressing, but would be
+for other addressing domains.  It needs <sys/socket.h> only because AF_INET is
+needed by gethostbyaddr and is defined there rather than in <netdb.h>, for some
+damn-fool reason. */
+
+
+
+#include <setjmp.h>
+#include <signal.h>
+
+#include <unistd.h>
+#include <sys/types.h>
+#include <netinet/in.h>
+#include <sys/socket.h>
+
+
+
+/* It is most unclear whether these should be here or in kludges.h, as they are
+kludges to keep 32-bit address dependencies out of the main body of internet.c,
+to allow for the much heralded arrival of IP version 6.  It will be interesting
+to see whether the universal availability of 64-bit integers arrives first. */
+
+#define local_to_address(x,y) ((x)->s_addr = htonl((unsigned long)y))
+#define network_to_address(x,y) ((x)->s_addr = (y))
+
+#define NTP_PORT htons((unsigned short)123)    /* If not in /etc/services */
+#define port_to_integer(x) (ntohs((unsigned short)(x)))
+
+
+#if defined(_SS_MAXSIZE) || defined(_SS_SIZE)
+#define HAVE_IPV6
+#endif
+
+/* Defined in internet.c */
+#ifdef HAVE_IPV6
+extern void find_address (struct sockaddr_storage *address,
+    struct sockaddr_storage *anywhere,
+    int *port, char *hostname, int timespan);
+#else
+extern void find_address (struct in_addr *address, struct in_addr *anywhere,
+    int *port, char *hostname, int timespan);
+#endif
diff --git a/sntp/kludges.h b/sntp/kludges.h
new file mode 100644 (file)
index 0000000..dc78c8d
--- /dev/null
@@ -0,0 +1,62 @@
+/*  Copyright (C) 1996, 2000 N.M. Maclaren
+    Copyright (C) 1996, 2000 The University of Cambridge
+
+This includes all of the kludges necessary for certain broken systems.  It is
+called after all other headers.  All of the modules set a flag to say which
+they are, but none of the current kludges critically need that information. */
+
+
+
+/* stdlib.h is broken under SunOS4. */
+
+#ifndef EXIT_SUCCESS
+#define EXIT_SUCCESS       0
+#define EXIT_FAILURE       1
+#endif
+
+
+
+/* stdio.h is also broken under SunOS4. */
+
+#ifndef SEEK_SET
+#define SEEK_SET           0
+#endif
+
+
+
+/* netinet/in.h sometimes omits INADDR_LOOPBACK, or makes it conditional on
+peculiar preprocessor symbols. */
+
+#ifndef INADDR_LOOPBACK
+#define INADDR_LOOPBACK    0x7f000001ul
+#endif
+
+
+
+/* HP-UX up to version 9.x does not have adjtime, so make it fail.  This needs
+a flag setting in Makefile. */
+
+#ifdef ADJTIME_MISSING
+#define adjtime(x,y)       1
+#endif
+
+
+
+/* O_NONBLOCK doesn't work under Ultrix 4.3.  This needs a flag setting in
+Makefile. */
+
+#ifdef NONBLOCK_BROKEN
+#ifdef O_NONBLOCK
+#undef O_NONBLOCK
+#endif
+#define O_NONBLOCK         O_NDELAY
+#endif
+
+
+
+/* Some older systems use EWOULDBLOCK rather than EAGAIN, but don't assume that
+it is defined.  The differences are not relevant to this program. */
+
+#ifndef EWOULDBLOCK
+#define EWOULDBLOCK        EAGAIN
+#endif
diff --git a/sntp/libopts/COPYING.lgpl b/sntp/libopts/COPYING.lgpl
new file mode 100644 (file)
index 0000000..129c5de
--- /dev/null
@@ -0,0 +1,502 @@
+                 GNU LESSER GENERAL PUBLIC LICENSE
+                      Version 2.1, February 1999
+
+ Copyright (C) 1991, 1999 Free Software Foundation, Inc.
+ 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+[This is the first released version of the Lesser GPL.  It also counts
+ as the successor of the GNU Library Public License, version 2, hence
+ the version number 2.1.]
+
+                           Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+Licenses are intended to guarantee your freedom to share and change
+free software--to make sure the software is free for all its users.
+
+  This license, the Lesser General Public License, applies to some
+specially designated software packages--typically libraries--of the
+Free Software Foundation and other authors who decide to use it.  You
+can use it too, but we suggest you first think carefully about whether
+this license or the ordinary General Public License is the better
+strategy to use in any particular case, based on the explanations below.
+
+  When we speak of free software, we are referring to freedom of use,
+not price.  Our General Public Licenses are designed to make sure that
+you have the freedom to distribute copies of free software (and charge
+for this service if you wish); that you receive source code or can get
+it if you want it; that you can change the software and use pieces of
+it in new free programs; and that you are informed that you can do
+these things.
+
+  To protect your rights, we need to make restrictions that forbid
+distributors to deny you these rights or to ask you to surrender these
+rights.  These restrictions translate to certain responsibilities for
+you if you distribute copies of the library or if you modify it.
+
+  For example, if you distribute copies of the library, whether gratis
+or for a fee, you must give the recipients all the rights that we gave
+you.  You must make sure that they, too, receive or can get the source
+code.  If you link other code with the library, you must provide
+complete object files to the recipients, so that they can relink them
+with the library after making changes to the library and recompiling
+it.  And you must show them these terms so they know their rights.
+
+  We protect your rights with a two-step method: (1) we copyright the
+library, and (2) we offer you this license, which gives you legal
+permission to copy, distribute and/or modify the library.
+
+  To protect each distributor, we want to make it very clear that
+there is no warranty for the free library.  Also, if the library is
+modified by someone else and passed on, the recipients should know
+that what they have is not the original version, so that the original
+author's reputation will not be affected by problems that might be
+introduced by others.
+
+  Finally, software patents pose a constant threat to the existence of
+any free program.  We wish to make sure that a company cannot
+effectively restrict the users of a free program by obtaining a
+restrictive license from a patent holder.  Therefore, we insist that
+any patent license obtained for a version of the library must be
+consistent with the full freedom of use specified in this license.
+
+  Most GNU software, including some libraries, is covered by the
+ordinary GNU General Public License.  This license, the GNU Lesser
+General Public License, applies to certain designated libraries, and
+is quite different from the ordinary General Public License.  We use
+this license for certain libraries in order to permit linking those
+libraries into non-free programs.
+
+  When a program is linked with a library, whether statically or using
+a shared library, the combination of the two is legally speaking a
+combined work, a derivative of the original library.  The ordinary
+General Public License therefore permits such linking only if the
+entire combination fits its criteria of freedom.  The Lesser General
+Public License permits more lax criteria for linking other code with
+the library.
+
+  We call this license the "Lesser" General Public License because it
+does Less to protect the user's freedom than the ordinary General
+Public License.  It also provides other free software developers Less
+of an advantage over competing non-free programs.  These disadvantages
+are the reason we use the ordinary General Public License for many
+libraries.  However, the Lesser license provides advantages in certain
+special circumstances.
+
+  For example, on rare occasions, there may be a special need to
+encourage the widest possible use of a certain library, so that it becomes
+a de-facto standard.  To achieve this, non-free programs must be
+allowed to use the library.  A more frequent case is that a free
+library does the same job as widely used non-free libraries.  In this
+case, there is little to gain by limiting the free library to free
+software only, so we use the Lesser General Public License.
+
+  In other cases, permission to use a particular library in non-free
+programs enables a greater number of people to use a large body of
+free software.  For example, permission to use the GNU C Library in
+non-free programs enables many more people to use the whole GNU
+operating system, as well as its variant, the GNU/Linux operating
+system.
+
+  Although the Lesser General Public License is Less protective of the
+users' freedom, it does ensure that the user of a program that is
+linked with the Library has the freedom and the wherewithal to run
+that program using a modified version of the Library.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.  Pay close attention to the difference between a
+"work based on the library" and a "work that uses the library".  The
+former contains code derived from the library, whereas the latter must
+be combined with the library in order to run.
+
+                 GNU LESSER GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License Agreement applies to any software library or other
+program which contains a notice placed by the copyright holder or
+other authorized party saying it may be distributed under the terms of
+this Lesser General Public License (also called "this License").
+Each licensee is addressed as "you".
+
+  A "library" means a collection of software functions and/or data
+prepared so as to be conveniently linked with application programs
+(which use some of those functions and data) to form executables.
+
+  The "Library", below, refers to any such software library or work
+which has been distributed under these terms.  A "work based on the
+Library" means either the Library or any derivative work under
+copyright law: that is to say, a work containing the Library or a
+portion of it, either verbatim or with modifications and/or translated
+straightforwardly into another language.  (Hereinafter, translation is
+included without limitation in the term "modification".)
+
+  "Source code" for a work means the preferred form of the work for
+making modifications to it.  For a library, complete source code means
+all the source code for all modules it contains, plus any associated
+interface definition files, plus the scripts used to control compilation
+and installation of the library.
+
+  Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running a program using the Library is not restricted, and output from
+such a program is covered only if its contents constitute a work based
+on the Library (independent of the use of the Library in a tool for
+writing it).  Whether that is true depends on what the Library does
+and what the program that uses the Library does.
+
+  1. You may copy and distribute verbatim copies of the Library's
+complete source code as you receive it, in any medium, provided that
+you conspicuously and appropriately publish on each copy an
+appropriate copyright notice and disclaimer of warranty; keep intact
+all the notices that refer to this License and to the absence of any
+warranty; and distribute a copy of this License along with the
+Library.
+
+  You may charge a fee for the physical act of transferring a copy,
+and you may at your option offer warranty protection in exchange for a
+fee.
+
+  2. You may modify your copy or copies of the Library or any portion
+of it, thus forming a work based on the Library, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) The modified work must itself be a software library.
+
+    b) You must cause the files modified to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    c) You must cause the whole of the work to be licensed at no
+    charge to all third parties under the terms of this License.
+
+    d) If a facility in the modified Library refers to a function or a
+    table of data to be supplied by an application program that uses
+    the facility, other than as an argument passed when the facility
+    is invoked, then you must make a good faith effort to ensure that,
+    in the event an application does not supply such function or
+    table, the facility still operates, and performs whatever part of
+    its purpose remains meaningful.
+
+    (For example, a function in a library to compute square roots has
+    a purpose that is entirely well-defined independent of the
+    application.  Therefore, Subsection 2d requires that any
+    application-supplied function or table used by this function must
+    be optional: if the application does not supply it, the square
+    root function must still compute square roots.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Library,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Library, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote
+it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Library.
+
+In addition, mere aggregation of another work not based on the Library
+with the Library (or with a work based on the Library) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may opt to apply the terms of the ordinary GNU General Public
+License instead of this License to a given copy of the Library.  To do
+this, you must alter all the notices that refer to this License, so
+that they refer to the ordinary GNU General Public License, version 2,
+instead of to this License.  (If a newer version than version 2 of the
+ordinary GNU General Public License has appeared, then you can specify
+that version instead if you wish.)  Do not make any other change in
+these notices.
+
+  Once this change is made in a given copy, it is irreversible for
+that copy, so the ordinary GNU General Public License applies to all
+subsequent copies and derivative works made from that copy.
+
+  This option is useful when you wish to copy part of the code of
+the Library into a program that is not a library.
+
+  4. You may copy and distribute the Library (or a portion or
+derivative of it, under Section 2) in object code or executable form
+under the terms of Sections 1 and 2 above provided that you accompany
+it with the complete corresponding machine-readable source code, which
+must be distributed under the terms of Sections 1 and 2 above on a
+medium customarily used for software interchange.
+
+  If distribution of object code is made by offering access to copy
+from a designated place, then offering equivalent access to copy the
+source code from the same place satisfies the requirement to
+distribute the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  5. A program that contains no derivative of any portion of the
+Library, but is designed to work with the Library by being compiled or
+linked with it, is called a "work that uses the Library".  Such a
+work, in isolation, is not a derivative work of the Library, and
+therefore falls outside the scope of this License.
+
+  However, linking a "work that uses the Library" with the Library
+creates an executable that is a derivative of the Library (because it
+contains portions of the Library), rather than a "work that uses the
+library".  The executable is therefore covered by this License.
+Section 6 states terms for distribution of such executables.
+
+  When a "work that uses the Library" uses material from a header file
+that is part of the Library, the object code for the work may be a
+derivative work of the Library even though the source code is not.
+Whether this is true is especially significant if the work can be
+linked without the Library, or if the work is itself a library.  The
+threshold for this to be true is not precisely defined by law.
+
+  If such an object file uses only numerical parameters, data
+structure layouts and accessors, and small macros and small inline
+functions (ten lines or less in length), then the use of the object
+file is unrestricted, regardless of whether it is legally a derivative
+work.  (Executables containing this object code plus portions of the
+Library will still fall under Section 6.)
+
+  Otherwise, if the work is a derivative of the Library, you may
+distribute the object code for the work under the terms of Section 6.
+Any executables containing that work also fall under Section 6,
+whether or not they are linked directly with the Library itself.
+
+  6. As an exception to the Sections above, you may also combine or
+link a "work that uses the Library" with the Library to produce a
+work containing portions of the Library, and distribute that work
+under terms of your choice, provided that the terms permit
+modification of the work for the customer's own use and reverse
+engineering for debugging such modifications.
+
+  You must give prominent notice with each copy of the work that the
+Library is used in it and that the Library and its use are covered by
+this License.  You must supply a copy of this License.  If the work
+during execution displays copyright notices, you must include the
+copyright notice for the Library among them, as well as a reference
+directing the user to the copy of this License.  Also, you must do one
+of these things:
+
+    a) Accompany the work with the complete corresponding
+    machine-readable source code for the Library including whatever
+    changes were used in the work (which must be distributed under
+    Sections 1 and 2 above); and, if the work is an executable linked
+    with the Library, with the complete machine-readable "work that
+    uses the Library", as object code and/or source code, so that the
+    user can modify the Library and then relink to produce a modified
+    executable containing the modified Library.  (It is understood
+    that the user who changes the contents of definitions files in the
+    Library will not necessarily be able to recompile the application
+    to use the modified definitions.)
+
+    b) Use a suitable shared library mechanism for linking with the
+    Library.  A suitable mechanism is one that (1) uses at run time a
+    copy of the library already present on the user's computer system,
+    rather than copying library functions into the executable, and (2)
+    will operate properly with a modified version of the library, if
+    the user installs one, as long as the modified version is
+    interface-compatible with the version that the work was made with.
+
+    c) Accompany the work with a written offer, valid for at
+    least three years, to give the same user the materials
+    specified in Subsection 6a, above, for a charge no more
+    than the cost of performing this distribution.
+
+    d) If distribution of the work is made by offering access to copy
+    from a designated place, offer equivalent access to copy the above
+    specified materials from the same place.
+
+    e) Verify that the user has already received a copy of these
+    materials or that you have already sent this user a copy.
+
+  For an executable, the required form of the "work that uses the
+Library" must include any data and utility programs needed for
+reproducing the executable from it.  However, as a special exception,
+the materials to be distributed need not include anything that is
+normally distributed (in either source or binary form) with the major
+components (compiler, kernel, and so on) of the operating system on
+which the executable runs, unless that component itself accompanies
+the executable.
+
+  It may happen that this requirement contradicts the license
+restrictions of other proprietary libraries that do not normally
+accompany the operating system.  Such a contradiction means you cannot
+use both them and the Library together in an executable that you
+distribute.
+
+  7. You may place library facilities that are a work based on the
+Library side-by-side in a single library together with other library
+facilities not covered by this License, and distribute such a combined
+library, provided that the separate distribution of the work based on
+the Library and of the other library facilities is otherwise
+permitted, and provided that you do these two things:
+
+    a) Accompany the combined library with a copy of the same work
+    based on the Library, uncombined with any other library
+    facilities.  This must be distributed under the terms of the
+    Sections above.
+
+    b) Give prominent notice with the combined library of the fact
+    that part of it is a work based on the Library, and explaining
+    where to find the accompanying uncombined form of the same work.
+
+  8. You may not copy, modify, sublicense, link with, or distribute
+the Library except as expressly provided under this License.  Any
+attempt otherwise to copy, modify, sublicense, link with, or
+distribute the Library is void, and will automatically terminate your
+rights under this License.  However, parties who have received copies,
+or rights, from you under this License will not have their licenses
+terminated so long as such parties remain in full compliance.
+
+  9. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Library or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Library (or any work based on the
+Library), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Library or works based on it.
+
+  10. Each time you redistribute the Library (or any work based on the
+Library), the recipient automatically receives a license from the
+original licensor to copy, distribute, link with or modify the Library
+subject to these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties with
+this License.
+
+  11. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Library at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Library by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Library.
+
+If any portion of this section is held invalid or unenforceable under any
+particular circumstance, the balance of the section is intended to apply,
+and the section as a whole is intended to apply in other circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  12. If the distribution and/or use of the Library is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Library under this License may add
+an explicit geographical distribution limitation excluding those countries,
+so that distribution is permitted only in or among countries not thus
+excluded.  In such case, this License incorporates the limitation as if
+written in the body of this License.
+
+  13. The Free Software Foundation may publish revised and/or new
+versions of the Lesser General Public License from time to time.
+Such new versions will be similar in spirit to the present version,
+but may differ in detail to address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Library
+specifies a version number of this License which applies to it and
+"any later version", you have the option of following the terms and
+conditions either of that version or of any later version published by
+the Free Software Foundation.  If the Library does not specify a
+license version number, you may choose any version ever published by
+the Free Software Foundation.
+
+  14. If you wish to incorporate parts of the Library into other free
+programs whose distribution conditions are incompatible with these,
+write to the author to ask for permission.  For software which is
+copyrighted by the Free Software Foundation, write to the Free
+Software Foundation; we sometimes make exceptions for this.  Our
+decision will be guided by the two goals of preserving the free status
+of all derivatives of our free software and of promoting the sharing
+and reuse of software generally.
+
+                           NO WARRANTY
+
+  15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
+WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
+EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
+OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
+KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
+IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
+LIBRARY IS WITH YOU.  SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
+THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
+WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
+AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
+FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
+CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
+LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
+RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
+FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
+SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
+DAMAGES.
+
+                    END OF TERMS AND CONDITIONS
+
+           How to Apply These Terms to Your New Libraries
+
+  If you develop a new library, and you want it to be of the greatest
+possible use to the public, we recommend making it free software that
+everyone can redistribute and change.  You can do so by permitting
+redistribution under these terms (or, alternatively, under the terms of the
+ordinary General Public License).
+
+  To apply these terms, attach the following notices to the library.  It is
+safest to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least the
+"copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the library's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This library is free software; you can redistribute it and/or
+    modify it under the terms of the GNU Lesser General Public
+    License as published by the Free Software Foundation; either
+    version 2.1 of the License, or (at your option) any later version.
+
+    This library is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+    Lesser General Public License for more details.
+
+    You should have received a copy of the GNU Lesser General Public
+    License along with this library; if not, write to the Free Software
+    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA
+
+Also add information on how to contact you by electronic and paper mail.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the library, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the
+  library `Frob' (a library for tweaking knobs) written by James Random Hacker.
+
+  <signature of Ty Coon>, 1 April 1990
+  Ty Coon, President of Vice
+
+That's all there is to it!
diff --git a/sntp/libopts/COPYING.mbsd b/sntp/libopts/COPYING.mbsd
new file mode 100644 (file)
index 0000000..8a70427
--- /dev/null
@@ -0,0 +1,26 @@
+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. The name of the author may not be used to endorse or promote
+       products derived from this software without specific prior
+       written permission.
+
+THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
+IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT,
+INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
+IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGE.
diff --git a/sntp/libopts/MakeDefs.inc b/sntp/libopts/MakeDefs.inc
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/sntp/libopts/Makefile.am b/sntp/libopts/Makefile.am
new file mode 100644 (file)
index 0000000..5f13861
--- /dev/null
@@ -0,0 +1,24 @@
+## LIBOPTS Makefile
+MAINTAINERCLEANFILES    = Makefile.in
+if INSTALL_LIBOPTS
+lib_LTLIBRARIES         = libopts.la
+else
+noinst_LTLIBRARIES      = libopts.la
+endif
+libopts_la_SOURCES      = libopts.c
+libopts_la_CPPFLAGS     = -I$(top_srcdir)
+libopts_la_LDFLAGS      = -version-info  29:0:4
+EXTRA_DIST              = \
+    COPYING.lgpl            COPYING.mbsd            MakeDefs.inc  \
+    README                  autoopts/options.h      autoopts/usage-txt.h  \
+    autoopts.c              autoopts.h              boolean.c  \
+    compat/windows-config.h compat/compat.h         compat/pathfind.c  \
+    compat/snprintf.c       compat/strdup.c         compat/strchr.c  \
+    configfile.c            cook.c                  enumeration.c  \
+    environment.c           genshell.c              genshell.h  \
+    load.c                  m4/libopts.m4           m4/liboptschk.m4  \
+    makeshell.c             nested.c                numeric.c  \
+    pgusage.c               proto.h                 putshell.c  \
+    restore.c               save.c                  sort.c  \
+    stack.c                 streqvcmp.c             text_mmap.c  \
+    tokenize.c              usage.c                 version.c
diff --git a/sntp/libopts/Makefile.in b/sntp/libopts/Makefile.in
new file mode 100644 (file)
index 0000000..b5f27c6
--- /dev/null
@@ -0,0 +1,546 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+subdir = libopts
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in
+ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
+am__aclocal_m4_deps = $(top_srcdir)/libopts/m4/libopts.m4 \
+       $(top_srcdir)/configure.ac
+am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+am__installdirs = "$(DESTDIR)$(libdir)"
+LTLIBRARIES = $(lib_LTLIBRARIES) $(noinst_LTLIBRARIES)
+libopts_la_LIBADD =
+am_libopts_la_OBJECTS = libopts_la-libopts.lo
+libopts_la_OBJECTS = $(am_libopts_la_OBJECTS)
+libopts_la_LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) \
+       $(LIBTOOLFLAGS) --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) \
+       $(libopts_la_LDFLAGS) $(LDFLAGS) -o $@
+@INSTALL_LIBOPTS_FALSE@am_libopts_la_rpath =
+@INSTALL_LIBOPTS_TRUE@am_libopts_la_rpath = -rpath $(libdir)
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = $(libopts_la_SOURCES)
+DIST_SOURCES = $(libopts_la_SOURCES)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+RANLIB = @RANLIB@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+sysconfdir = @sysconfdir@
+target_alias = @target_alias@
+top_build_prefix = @top_build_prefix@
+top_builddir = @top_builddir@
+top_srcdir = @top_srcdir@
+MAINTAINERCLEANFILES = Makefile.in
+@INSTALL_LIBOPTS_TRUE@lib_LTLIBRARIES = libopts.la
+@INSTALL_LIBOPTS_FALSE@noinst_LTLIBRARIES = libopts.la
+libopts_la_SOURCES = libopts.c
+libopts_la_CPPFLAGS = -I$(top_srcdir)
+libopts_la_LDFLAGS = -version-info  29:0:4
+EXTRA_DIST = \
+    COPYING.lgpl            COPYING.mbsd            MakeDefs.inc  \
+    README                  autoopts/options.h      autoopts/usage-txt.h  \
+    autoopts.c              autoopts.h              boolean.c  \
+    compat/windows-config.h compat/compat.h         compat/pathfind.c  \
+    compat/snprintf.c       compat/strdup.c         compat/strchr.c  \
+    configfile.c            cook.c                  enumeration.c  \
+    environment.c           genshell.c              genshell.h  \
+    load.c                  m4/libopts.m4           m4/liboptschk.m4  \
+    makeshell.c             nested.c                numeric.c  \
+    pgusage.c               proto.h                 putshell.c  \
+    restore.c               save.c                  sort.c  \
+    stack.c                 streqvcmp.c             text_mmap.c  \
+    tokenize.c              usage.c                 version.c
+
+all: all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --gnu libopts/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --gnu libopts/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-libLTLIBRARIES: $(lib_LTLIBRARIES)
+       @$(NORMAL_INSTALL)
+       test -z "$(libdir)" || $(MKDIR_P) "$(DESTDIR)$(libdir)"
+       @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+       list2=; for p in $$list; do \
+         if test -f $$p; then \
+           list2="$$list2 $$p"; \
+         else :; fi; \
+       done; \
+       test -z "$$list2" || { \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 '$(DESTDIR)$(libdir)'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL) $(INSTALL_STRIP_FLAG) $$list2 "$(DESTDIR)$(libdir)"; \
+       }
+
+uninstall-libLTLIBRARIES:
+       @$(NORMAL_UNINSTALL)
+       @list='$(lib_LTLIBRARIES)'; test -n "$(libdir)" || list=; \
+       for p in $$list; do \
+         $(am__strip_dir) \
+         echo " $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f '$(DESTDIR)$(libdir)/$$f'"; \
+         $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=uninstall rm -f "$(DESTDIR)$(libdir)/$$f"; \
+       done
+
+clean-libLTLIBRARIES:
+       -test -z "$(lib_LTLIBRARIES)" || rm -f $(lib_LTLIBRARIES)
+       @list='$(lib_LTLIBRARIES)'; for p in $$list; do \
+         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+         test "$$dir" != "$$p" || dir=.; \
+         echo "rm -f \"$${dir}/so_locations\""; \
+         rm -f "$${dir}/so_locations"; \
+       done
+
+clean-noinstLTLIBRARIES:
+       -test -z "$(noinst_LTLIBRARIES)" || rm -f $(noinst_LTLIBRARIES)
+       @list='$(noinst_LTLIBRARIES)'; for p in $$list; do \
+         dir="`echo $$p | sed -e 's|/[^/]*$$||'`"; \
+         test "$$dir" != "$$p" || dir=.; \
+         echo "rm -f \"$${dir}/so_locations\""; \
+         rm -f "$${dir}/so_locations"; \
+       done
+libopts.la: $(libopts_la_OBJECTS) $(libopts_la_DEPENDENCIES) 
+       $(libopts_la_LINK) $(am_libopts_la_rpath) $(libopts_la_OBJECTS) $(libopts_la_LIBADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libopts_la-libopts.Plo@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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+
+libopts_la-libopts.lo: libopts.c
+@am__fastdepCC_TRUE@   $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libopts_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -MT libopts_la-libopts.lo -MD -MP -MF $(DEPDIR)/libopts_la-libopts.Tpo -c -o libopts_la-libopts.lo `test -f 'libopts.c' || echo '$(srcdir)/'`libopts.c
+@am__fastdepCC_TRUE@   $(am__mv) $(DEPDIR)/libopts_la-libopts.Tpo $(DEPDIR)/libopts_la-libopts.Plo
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      source='libopts.c' object='libopts_la-libopts.lo' libtool=yes @AMDEPBACKSLASH@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LIBTOOL)  --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=compile $(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(libopts_la_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) -c -o libopts_la-libopts.lo `test -f 'libopts.c' || echo '$(srcdir)/'`libopts.c
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: check-am
+all-am: Makefile $(LTLIBRARIES)
+installdirs:
+       for dir in "$(DESTDIR)$(libdir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+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 "$(MAINTAINERCLEANFILES)" || rm -f $(MAINTAINERCLEANFILES)
+clean: clean-am
+
+clean-am: clean-generic clean-libLTLIBRARIES clean-libtool \
+       clean-noinstLTLIBRARIES mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am:
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-libLTLIBRARIES
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man:
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-libLTLIBRARIES
+
+.MAKE: install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-generic \
+       clean-libLTLIBRARIES clean-libtool clean-noinstLTLIBRARIES \
+       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-libLTLIBRARIES 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 uninstall uninstall-am uninstall-libLTLIBRARIES
+
+
+# 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.
+.NOEXPORT:
diff --git a/sntp/libopts/README b/sntp/libopts/README
new file mode 100644 (file)
index 0000000..7cbe0b0
--- /dev/null
@@ -0,0 +1,93 @@
+        THIS TARBALL IS NOT A FULL DISTRIBUTION.
+
+The contents of this tarball is designed to be incorporated into
+software packages that utilize the AutoOpts option automation
+package and are intended to be installed on systems that may not
+have libopts installed.  It is redistributable under the terms
+of either the LGPL (see COPYING.lgpl) or under the terms of
+the advertising clause free BSD license (see COPYING.mbsd).
+
+Usage Instructions for autoconf/automake/libtoolized projects:
+
+1. Install the unrolled tarball into your package source tree,
+   copying ``libopts.m4'' to your autoconf macro directory.
+
+   In your bootstrap (pre-configure) script, you can do this:
+
+      rm -rf libopts libopts-*
+      gunzip -c `autoopts-config libsrc` | tar -xvf -
+      mv -f libopts-*.*.* libopts
+      cp -fp libopts/m4/*.m4 m4/.
+
+   I tend to put my configure auxiliary files in "m4".
+   Whatever directory you choose, if it is not ".", then
+   be sure to tell autoconf about it with:
+
+      AC_CONFIG_AUX_DIR(m4)
+
+   This is one macro where you *MUST* remember to *NOT* quote
+   the argument.  If you do, automake will get lost.
+
+2. Add the following to your ``configure.ac'' file:
+
+      LIBOPTS_CHECK
+
+   or:
+
+      LIBOPTS_CHECK([relative/path/to/libopts])
+
+   This macro will automatically invoke
+
+      AC_CONFIG_FILES( [relative/path/to/libopts/Makefile] )
+
+   The default ``relative/path/to/libopts'' is simply
+   ``libopts''.
+
+3. Add the following to your top level ``Makefile.am'' file:
+
+      if NEED_LIBOPTS
+         SUBDIRS += $(LIBOPTS_DIR)
+      endif
+
+   where ``<...>'' can be whatever other files or directories
+   you may need.  The SUBDIRS must be properly ordered.
+   *PLEASE NOTE* it is crucial that the SUBDIRS be set under the
+   control of an automake conditional.  To work correctly,
+   automake has to know the range of possible values of SUBDIRS.
+   It's a magical name with magical properties.  ``NEED_LIBOPTS''
+   will be correctly set by the ``LIBOPTS_CHECK'' macro, above.
+
+4. Add ``$(LIBOPTS_CFLAGS)'' to relevant compiler flags and
+   ``$(LIBOPTS_LDADD)'' to relevant link options whereever
+   you need them in your build tree.
+
+5. Make sure your object files explicitly depend upon the
+   generated options header file.  e.g.:
+
+     $(prog_OBJECTS) : prog-opts.h
+     prog-opts.h : prog-opts.c
+     prog-opts.c : prog-opts.def
+         autogen prog-opts.def
+
+6. *OPTIONAL* --
+   If you are creating man pages and texi documentation from
+   the program options, you will need these rules somewhere, too:
+
+     man_MANS = prog.1
+     prog.1 : prog-opts.def
+         autogen -Tagman1.tpl -bprog prog-opts.def
+
+     prog-invoke.texi : prog-opts.def
+         autogen -Taginfo.tpl -bprog-invoke prog-opts.def
+
+If your package does not utilize the auto* tools, then you
+will need to hand craft the rules for building the library.
+
+LICENSING:
+
+This material is copyright 1993-2007 by Bruce Korb.
+You are licensed to use this under the terms of either
+the GNU Lesser General Public License (see: COPYING.lgpl), or,
+at your option, the modified Berkeley Software Distribution
+License (see:  COPYING.mbsd).  Both of these files should be
+included with this tarball.
diff --git a/sntp/libopts/autoopts.c b/sntp/libopts/autoopts.c
new file mode 100644 (file)
index 0000000..139841b
--- /dev/null
@@ -0,0 +1,1120 @@
+
+/*
+ *  $Id: autoopts.c,v 4.25 2007/04/15 19:01:18 bkorb Exp $
+ *  Time-stamp:      "2007-04-15 11:10:40 bkorb"
+ *
+ *  This file contains all of the routines that must be linked into
+ *  an executable to use the generated option processing.  The optional
+ *  routines are in separately compiled modules so that they will not
+ *  necessarily be linked in.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+static char const zNil[] = "";
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static tSuccess
+findOptDesc( tOptions* pOpts, tOptState* pOptState );
+
+static tSuccess
+nextOption( tOptions* pOpts, tOptState* pOptState );
+
+static tSuccess
+doPresets( tOptions* pOpts );
+
+static int
+checkConsistency( tOptions* pOpts );
+/* = = = END-STATIC-FORWARD = = = */
+
+LOCAL void *
+ao_malloc( size_t sz )
+{
+    void * res = malloc(sz);
+    if (res == NULL) {
+        fprintf( stderr, "malloc of %d bytes failed\n", (int)sz );
+        exit( EXIT_FAILURE );
+    }
+    return res;
+}
+#undef  malloc
+#define malloc(_s) ao_malloc(_s)
+
+LOCAL void *
+ao_realloc( void *p, size_t sz )
+{
+    void * res = realloc(p, sz);
+    if (res == NULL) {
+        fprintf( stderr, "realloc of %d bytes at 0x%p failed\n", (int)sz, p );
+        exit( EXIT_FAILURE );
+    }
+    return res;
+}
+#undef  realloc
+#define realloc(_p,_s) ao_realloc(_p,_s)
+
+
+LOCAL void
+ao_free( void *p )
+{
+    if (p != NULL)
+        free(p);
+}
+#undef  free
+#define free(_p) ao_free(_p)
+
+
+LOCAL char *
+ao_strdup( char const *str )
+{
+    char * res = strdup(str);
+    if (res == NULL) {
+        fprintf( stderr, "strdup of %d byte string failed\n", (int)strlen(str) );
+        exit( EXIT_FAILURE );
+    }
+    return res;
+}
+#undef  strdup
+#define strdup(_p) ao_strdup(_p)
+
+#ifndef HAVE_PATHFIND
+#  include "compat/pathfind.c"
+#endif
+
+#ifndef HAVE_SNPRINTF
+#  include "compat/snprintf.c"
+#endif
+
+#ifndef HAVE_STRDUP
+#  include "compat/strdup.c"
+#endif
+
+#ifndef HAVE_STRCHR
+#  include "compat/strchr.c"
+#endif
+
+/*
+ *  handleOption
+ *
+ *  This routine handles equivalencing, sets the option state flags and
+ *  invokes the handler procedure, if any.
+ */
+LOCAL tSuccess
+handleOption( tOptions* pOpts, tOptState* pOptState )
+{
+    /*
+     *  Save a copy of the option procedure pointer.
+     *  If this is an equivalence class option, we still want this proc.
+     */
+    tOptDesc* pOD = pOptState->pOD;
+    tOptProc* pOP = pOD->pOptProc;
+    if (pOD->fOptState & OPTST_ALLOC_ARG)
+        AGFREE(pOD->optArg.argString);
+
+    pOD->optArg.argString = pOptState->pzOptArg;
+
+    /*
+     *  IF we are presetting options, then we will ignore any un-presettable
+     *  options.  They are the ones either marked as such.
+     */
+    if (  ((pOpts->fOptSet & OPTPROC_PRESETTING) != 0)
+       && ((pOD->fOptState & OPTST_NO_INIT) != 0)
+       )
+        return PROBLEM;
+
+    /*
+     *  IF this is an equivalence class option,
+     *  THEN
+     *      Save the option value that got us to this option
+     *      entry.  (It may not be pOD->optChar[0], if this is an
+     *      equivalence entry.)
+     *      set the pointer to the equivalence class base
+     */
+    if (pOD->optEquivIndex != NO_EQUIVALENT) {
+        tOptDesc* p = pOpts->pOptDesc + pOD->optEquivIndex;
+
+        /*
+         * IF the current option state has not been defined (set on the
+         *    command line), THEN we will allow continued resetting of
+         *    the value.  Once "defined", then it must not change.
+         */
+        if ((pOD->fOptState & OPTST_DEFINED) != 0) {
+            /*
+             *  The equivalenced-to option has been found on the command
+             *  line before.  Make sure new occurrences are the same type.
+             *
+             *  IF this option has been previously equivalenced and
+             *     it was not the same equivalenced-to option,
+             *  THEN we have a usage problem.
+             */
+            if (p->optActualIndex != pOD->optIndex) {
+                fprintf( stderr, (char*)zMultiEquiv, p->pz_Name, pOD->pz_Name,
+                         (pOpts->pOptDesc + p->optActualIndex)->pz_Name);
+                return FAILURE;
+            }
+        } else {
+            /*
+             *  Set the equivalenced-to actual option index to no-equivalent
+             *  so that we set all the entries below.  This option may either
+             *  never have been selected before, or else it was selected by
+             *  some sort of "presetting" mechanism.
+             */
+            p->optActualIndex = NO_EQUIVALENT;
+        }
+
+        if (p->optActualIndex != pOD->optIndex) {
+            /*
+             *  First time through, copy over the state
+             *  and add in the equivalence flag
+             */
+            p->optActualValue = pOD->optValue;
+            p->optActualIndex = pOD->optIndex;
+            pOptState->flags |= OPTST_EQUIVALENCE;
+        }
+
+        /*
+         *  Copy the most recent option argument.  set membership state
+         *  is kept in ``p->optCookie''.  Do not overwrite.
+         */
+        p->optArg.argString = pOD->optArg.argString;
+        pOD = p;
+
+    } else {
+        pOD->optActualValue = pOD->optValue;
+        pOD->optActualIndex = pOD->optIndex;
+    }
+
+    pOD->fOptState &= OPTST_PERSISTENT_MASK;
+    pOD->fOptState |= (pOptState->flags & ~OPTST_PERSISTENT_MASK);
+
+    /*
+     *  Keep track of count only for DEFINED (command line) options.
+     *  IF we have too many, build up an error message and bail.
+     */
+    if (  (pOD->fOptState & OPTST_DEFINED)
+       && (++pOD->optOccCt > pOD->optMaxCt)  )  {
+
+        if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+            char const * pzEqv =
+                (pOD->optEquivIndex != NO_EQUIVALENT) ? zEquiv : zNil;
+
+            fputs( zErrOnly, stderr );
+
+            if (pOD->optMaxCt > 1)
+                fprintf(stderr, zAtMost, pOD->optMaxCt, pOD->pz_Name, pzEqv);
+            else
+                fprintf(stderr, zOnlyOne, pOD->pz_Name, pzEqv);
+        }
+
+        return FAILURE;
+    }
+
+    /*
+     *  If provided a procedure to call, call it
+     */
+    if (pOP != (tpOptProc)NULL)
+        (*pOP)( pOpts, pOD );
+
+    return SUCCESS;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  HUNT FOR OPTIONS IN THE ARGUMENT LIST
+ *
+ *  The next four procedures are "private" to nextOption().
+ *  nextOption() uses findOptDesc() to find the next descriptor and it, in
+ *  turn, uses longOptionFind() and shortOptionFind() to actually do the hunt.
+ *
+ *  longOptionFind
+ *
+ *  Find the long option descriptor for the current option
+ */
+LOCAL tSuccess
+longOptionFind( tOptions* pOpts, char* pzOptName, tOptState* pOptState )
+{
+    ag_bool    disable  = AG_FALSE;
+    char*      pzEq     = strchr( pzOptName, '=' );
+    tOptDesc*  pOD      = pOpts->pOptDesc;
+    int        idx      = 0;
+    int        idxLim   = pOpts->optCt;
+    int        matchCt  = 0;
+    int        matchIdx = 0;
+    int        nameLen;
+
+    /*
+     *  IF the value is attached to the name,
+     *  THEN clip it off.
+     *  Either way, figure out how long our name is
+     */
+    if (pzEq != NULL) {
+        nameLen = (int)(pzEq - pzOptName);
+        *pzEq = NUL;
+    } else nameLen = strlen( pzOptName );
+
+    do  {
+        if (SKIP_OPT(pOD))
+            continue;
+
+        if (strneqvcmp( pzOptName, pOD->pz_Name, nameLen ) == 0) {
+            /*
+             *  IF we have a complete match
+             *  THEN it takes priority over any already located partial
+             */
+            if (pOD->pz_Name[ nameLen ] == NUL) {
+                matchCt  = 1;
+                matchIdx = idx;
+                break;
+            }
+        }
+
+        /*
+         *  IF       there is a disable name
+         *     *AND* no argument value has been supplied
+         *              (disabled options may have no argument)
+         *     *AND* the option name matches the disable name
+         *  THEN ...
+         */
+        else if (  (pOD->pz_DisableName != NULL)
+                && (strneqvcmp(pzOptName, pOD->pz_DisableName, nameLen) == 0)
+                )  {
+            disable  = AG_TRUE;
+
+            /*
+             *  IF we have a complete match
+             *  THEN it takes priority over any already located partial
+             */
+            if (pOD->pz_DisableName[ nameLen ] == NUL) {
+                matchCt  = 1;
+                matchIdx = idx;
+                break;
+            }
+        }
+
+        else
+            continue;
+
+        /*
+         *  We found a partial match, either regular or disabling.
+         *  Remember the index for later.
+         */
+        matchIdx = idx;
+
+        if (++matchCt > 1)
+            break;
+
+    } while (pOD++, (++idx < idxLim));
+
+    if (pzEq != NULL)
+        *(pzEq++) = '=';
+
+    /*
+     *  Make sure we either found an exact match or found only one partial
+     */
+    if (matchCt == 1) {
+        /*
+         *  IF we found a disablement name,
+         *  THEN set the bit in the callers' flag word
+         */
+        if (disable)
+            pOptState->flags |= OPTST_DISABLED;
+
+        pOptState->pOD      = pOpts->pOptDesc + matchIdx;
+        pOptState->pzOptArg = pzEq;
+        pOptState->optType  = TOPT_LONG;
+        return SUCCESS;
+    }
+
+    /*
+     *  IF there is no equal sign
+     *     *AND* we are using named arguments
+     *     *AND* there is a default named option,
+     *  THEN return that option.
+     */
+    if (  (pzEq == NULL)
+       && NAMED_OPTS(pOpts)
+       && (pOpts->specOptIdx.default_opt != NO_EQUIVALENT)) {
+        pOptState->pOD = pOpts->pOptDesc + pOpts->specOptIdx.default_opt;
+
+        pOptState->pzOptArg = pzOptName;
+        pOptState->optType  = TOPT_DEFAULT;
+        return SUCCESS;
+    }
+
+    /*
+     *  IF we are to stop on errors (the default, actually)
+     *  THEN call the usage procedure.
+     */
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+        fprintf( stderr, zIllOptStr, pOpts->pzProgPath,
+                 (matchCt == 0) ? zIllegal : zAmbiguous, pzOptName );
+        (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+    }
+
+    return FAILURE;
+}
+
+
+/*
+ *  shortOptionFind
+ *
+ *  Find the short option descriptor for the current option
+ */
+LOCAL tSuccess
+shortOptionFind( tOptions* pOpts, uint_t optValue, tOptState* pOptState )
+{
+    tOptDesc*  pRes = pOpts->pOptDesc;
+    int        ct   = pOpts->optCt;
+
+    /*
+     *  Search the option list
+     */
+    for (;;) {
+        /*
+         *  IF the values match,
+         *  THEN we stop here
+         */
+        if ((! SKIP_OPT(pRes)) && (optValue == pRes->optValue)) {
+            pOptState->pOD     = pRes;
+            pOptState->optType = TOPT_SHORT;
+            return SUCCESS;
+        }
+
+        /*
+         *  Advance to next option description
+         */
+        pRes++;
+
+        /*
+         *  IF we have searched everything, ...
+         */
+        if (--ct <= 0)
+            break;
+    }
+
+    /*
+     *  IF    the character value is a digit
+     *    AND there is a special number option ("-n")
+     *  THEN the result is the "option" itself and the
+     *       option is the specially marked "number" option.
+     */
+    if (  isdigit( optValue )
+       && (pOpts->specOptIdx.number_option != NO_EQUIVALENT) ) {
+        pOptState->pOD = \
+        pRes           = pOpts->pOptDesc + pOpts->specOptIdx.number_option;
+        (pOpts->pzCurOpt)--;
+        pOptState->optType = TOPT_SHORT;
+        return SUCCESS;
+    }
+
+    /*
+     *  IF we are to stop on errors (the default, actually)
+     *  THEN call the usage procedure.
+     */
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+        fprintf( stderr, zIllOptChr, pOpts->pzProgPath, optValue );
+        (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+    }
+
+    return FAILURE;
+}
+
+
+/*
+ *  findOptDesc
+ *
+ *  Find the option descriptor for the current option
+ */
+static tSuccess
+findOptDesc( tOptions* pOpts, tOptState* pOptState )
+{
+    /*
+     *  IF we are continuing a short option list (e.g. -xyz...)
+     *  THEN continue a single flag option.
+     *  OTHERWISE see if there is room to advance and then do so.
+     */
+    if ((pOpts->pzCurOpt != NULL) && (*pOpts->pzCurOpt != NUL))
+        return shortOptionFind( pOpts, (tAoUC)*(pOpts->pzCurOpt), pOptState );
+
+    if (pOpts->curOptIdx >= pOpts->origArgCt)
+        return PROBLEM; /* NORMAL COMPLETION */
+
+    pOpts->pzCurOpt = pOpts->origArgVect[ pOpts->curOptIdx ];
+
+    /*
+     *  IF all arguments must be named options, ...
+     */
+    if (NAMED_OPTS(pOpts)) {
+        char* pz = pOpts->pzCurOpt;
+        pOpts->curOptIdx++;
+
+        /*
+         *  Skip over any flag/option markers.
+         *  In this mode, they are not required.
+         */
+        while (*pz == '-') pz++;
+
+        return longOptionFind( pOpts, pz, pOptState );
+    }
+
+    /*
+     *  Note the kind of flag/option marker
+     */
+    if (*((pOpts->pzCurOpt)++) != '-')
+        return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */
+
+    /*
+     *  Special hack for a hyphen by itself
+     */
+    if (*(pOpts->pzCurOpt) == NUL)
+        return PROBLEM; /* NORMAL COMPLETION - this + rest are operands */
+
+    /*
+     *  The current argument is to be processed as an option argument
+     */
+    pOpts->curOptIdx++;
+
+    /*
+     *  We have an option marker.
+     *  Test the next character for long option indication
+     */
+    if (pOpts->pzCurOpt[0] == '-') {
+        if (*++(pOpts->pzCurOpt) == NUL)
+            /*
+             *  NORMAL COMPLETION - NOT this arg, but rest are operands
+             */
+            return PROBLEM;
+
+        /*
+         *  We do not allow the hyphen to be used as a flag value.
+         *  Therefore, if long options are not to be accepted, we punt.
+         */
+        if ((pOpts->fOptSet & OPTPROC_LONGOPT) == 0) {
+            fprintf( stderr, zIllOptStr, pOpts->pzProgPath,
+                     zIllegal, pOpts->pzCurOpt-2 );
+            return FAILURE;
+        }
+
+        return longOptionFind( pOpts, pOpts->pzCurOpt, pOptState );
+    }
+
+    /*
+     *  If short options are not allowed, then do long
+     *  option processing.  Otherwise the character must be a
+     *  short (i.e. single character) option.
+     */
+    if ((pOpts->fOptSet & OPTPROC_SHORTOPT) != 0)
+        return shortOptionFind( pOpts, (tAoUC)*(pOpts->pzCurOpt), pOptState );
+
+    return longOptionFind( pOpts, pOpts->pzCurOpt, pOptState );
+}
+
+
+/*
+ *  nextOption
+ *
+ *  Find the option descriptor and option argument (if any) for the
+ *  next command line argument.  DO NOT modify the descriptor.  Put
+ *  all the state in the state argument so that the option can be skipped
+ *  without consequence (side effect).
+ */
+static tSuccess
+nextOption( tOptions* pOpts, tOptState* pOptState )
+{
+    tSuccess res;
+    enum { ARG_NONE, ARG_MAY, ARG_MUST } arg_type = ARG_NONE;
+    teOptArgType at;
+
+    res = findOptDesc( pOpts, pOptState );
+    if (! SUCCESSFUL( res ))
+        return res;
+    pOptState->flags |= (pOptState->pOD->fOptState & OPTST_PERSISTENT_MASK);
+    at = OPTST_GET_ARGTYPE(pOptState->flags);
+
+    /*
+     *  Figure out what to do about option arguments.  An argument may be
+     *  required, not associated with the option, or be optional.  We detect the
+     *  latter by examining for an option marker on the next possible argument.
+     *  Disabled mode option selection also disables option arguments.
+     */
+    if ((pOptState->flags & OPTST_DISABLED) != 0)
+        arg_type = ARG_NONE;
+    else if (at == OPARG_TYPE_NONE)
+        arg_type = ARG_NONE;
+    else if (pOptState->flags & OPTST_ARG_OPTIONAL)
+        arg_type = ARG_MAY;
+    else
+        arg_type = ARG_MUST;
+
+    switch (arg_type) {
+    case ARG_MUST:
+        /*
+         *  An option argument is required.  Long options can either have
+         *  a separate command line argument, or an argument attached by
+         *  the '=' character.  Figure out which.
+         */
+        switch (pOptState->optType) {
+        case TOPT_SHORT:
+            /*
+             *  See if an arg string follows the flag character
+             */
+            if (*++(pOpts->pzCurOpt) == NUL)
+                pOpts->pzCurOpt = pOpts->origArgVect[ pOpts->curOptIdx++ ];
+            pOptState->pzOptArg = pOpts->pzCurOpt;
+            break;
+
+        case TOPT_LONG:
+            /*
+             *  See if an arg string has already been assigned (glued on
+             *  with an `=' character)
+             */
+            if (pOptState->pzOptArg == NULL)
+                pOptState->pzOptArg = pOpts->origArgVect[ pOpts->curOptIdx++ ];
+            break;
+
+        default:
+#ifdef DEBUG
+            fputs( "AutoOpts lib error: option type not selected\n",
+                   stderr );
+            exit( EXIT_FAILURE );
+#endif
+
+        case TOPT_DEFAULT:
+            /*
+             *  The option was selected by default.  The current token is
+             *  the option argument.
+             */
+            break;
+        }
+
+        /*
+         *  Make sure we did not overflow the argument list.
+         */
+        if (pOpts->curOptIdx > pOpts->origArgCt) {
+            fprintf( stderr, zMisArg, pOpts->pzProgPath,
+                     pOptState->pOD->pz_Name );
+            return FAILURE;
+        }
+
+        pOpts->pzCurOpt = NULL;  /* next time advance to next arg */
+        break;
+
+    case ARG_MAY:
+        /*
+         *  An option argument is optional.
+         */
+        switch (pOptState->optType) {
+        case TOPT_SHORT:
+            if (*++pOpts->pzCurOpt != NUL)
+                pOptState->pzOptArg = pOpts->pzCurOpt;
+            else {
+                char* pzLA = pOpts->origArgVect[ pOpts->curOptIdx ];
+
+                /*
+                 *  BECAUSE it is optional, we must make sure
+                 *  we did not find another flag and that there
+                 *  is such an argument.
+                 */
+                if ((pzLA == NULL) || (*pzLA == '-'))
+                    pOptState->pzOptArg = NULL;
+                else {
+                    pOpts->curOptIdx++; /* argument found */
+                    pOptState->pzOptArg = pzLA;
+                }
+            }
+            break;
+
+        case TOPT_LONG:
+            /*
+             *  Look for an argument if we don't already have one (glued on
+             *  with a `=' character) *AND* we are not in named argument mode
+             */
+            if (  (pOptState->pzOptArg == NULL)
+               && (! NAMED_OPTS(pOpts))) {
+                char* pzLA = pOpts->origArgVect[ pOpts->curOptIdx ];
+
+                /*
+                 *  BECAUSE it is optional, we must make sure
+                 *  we did not find another flag and that there
+                 *  is such an argument.
+                 */
+                if ((pzLA == NULL) || (*pzLA == '-'))
+                    pOptState->pzOptArg = NULL;
+                else {
+                    pOpts->curOptIdx++; /* argument found */
+                    pOptState->pzOptArg = pzLA;
+                }
+            }
+            break;
+
+        default:
+        case TOPT_DEFAULT:
+            fputs( "AutoOpts lib error: defaulted to option with optional arg\n",
+                   stderr );
+            exit( EX_SOFTWARE );
+        }
+
+        /*
+         *  After an option with an optional argument, we will
+         *  *always* start with the next option because if there
+         *  were any characters following the option name/flag,
+         *  they would be interpreted as the argument.
+         */
+        pOpts->pzCurOpt = NULL;
+        break;
+
+    default: /* CANNOT */
+        /*
+         *  No option argument.  Make sure next time around we find
+         *  the correct option flag character for short options
+         */
+        if (pOptState->optType == TOPT_SHORT)
+            (pOpts->pzCurOpt)++;
+
+        /*
+         *  It is a long option.  Make sure there was no ``=xxx'' argument
+         */
+        else if (pOptState->pzOptArg != NULL) {
+            fprintf( stderr, zNoArg, pOpts->pzProgPath,
+                     pOptState->pOD->pz_Name );
+            return FAILURE;
+        }
+
+        /*
+         *  It is a long option.  Advance to next command line argument.
+         */
+        else
+            pOpts->pzCurOpt = NULL;
+    }
+
+    return SUCCESS;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  DO PRESETS
+ *
+ *  The next several routines do the immediate action pass on the command
+ *  line options, then the environment variables, then the config files in
+ *  reverse order.  Once done with that, the order is reversed and all
+ *  the config files and environment variables are processed again, this
+ *  time only processing the non-immediate action options.  doPresets()
+ *  will then return for optionProcess() to do the final pass on the command
+ *  line arguments.
+ */
+
+/*
+ *  doImmediateOpts - scan the command line for immediate action options
+ */
+LOCAL tSuccess
+doImmediateOpts( tOptions* pOpts )
+{
+    pOpts->curOptIdx = 1;     /* start by skipping program name */
+    pOpts->pzCurOpt  = NULL;
+
+    /*
+     *  Examine all the options from the start.  We process any options that
+     *  are marked for immediate processing.
+     */
+    for (;;) {
+        tOptState optState = OPTSTATE_INITIALIZER(PRESET);
+
+        switch (nextOption( pOpts, &optState )) {
+        case FAILURE: goto optionsDone;
+        case PROBLEM: return SUCCESS; /* no more args */
+        case SUCCESS: break;
+        }
+
+        /*
+         *  IF this *is* an immediate-attribute option, then do it.
+         */
+        if (! DO_IMMEDIATELY(optState.flags))
+            continue;
+
+        if (! SUCCESSFUL( handleOption( pOpts, &optState )))
+            break;
+    } optionsDone:;
+
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
+        (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+    return FAILURE;
+}
+
+
+LOCAL tSuccess
+doRegularOpts( tOptions* pOpts )
+{
+    /*
+     *  Now, process all the options from our current position onward.
+     *  (This allows interspersed options and arguments for the few
+     *  non-standard programs that require it.)
+     */
+    for (;;) {
+        tOptState optState = OPTSTATE_INITIALIZER(DEFINED);
+
+        switch (nextOption( pOpts, &optState )) {
+        case FAILURE: goto optionsDone;
+        case PROBLEM: return SUCCESS; /* no more args */
+        case SUCCESS: break;
+        }
+
+        /*
+         *  IF this is not being processed normally (i.e. is immediate action)
+         *  THEN skip it (unless we are supposed to do it a second time).
+         */
+        if (! DO_NORMALLY(optState.flags)) {
+            if (! DO_SECOND_TIME(optState.flags))
+                continue;
+            optState.pOD->optOccCt--; /* don't count last time */
+        }
+
+        if (! SUCCESSFUL( handleOption( pOpts, &optState )))
+            break;
+    } optionsDone:;
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0)
+        (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+    return FAILURE;
+}
+
+
+/*
+ *  doPresets - check for preset values from a config file or the envrionment
+ */
+static tSuccess
+doPresets( tOptions* pOpts )
+{
+    tOptDesc * pOD = NULL;
+
+    if (! SUCCESSFUL( doImmediateOpts( pOpts )))
+        return FAILURE;
+
+    /*
+     *  IF this option set has a --save-opts option, then it also
+     *  has a --load-opts option.  See if a command line option has disabled
+     *  option presetting.
+     */
+    if (pOpts->specOptIdx.save_opts != 0) {
+        pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
+        if (DISABLED_OPT(pOD))
+            return SUCCESS;
+    }
+
+    /*
+     *  Until we return from this procedure, disable non-presettable opts
+     */
+    pOpts->fOptSet |= OPTPROC_PRESETTING;
+    /*
+     *  IF there are no config files,
+     *  THEN do any environment presets and leave.
+     */
+    if (pOpts->papzHomeList == NULL) {
+        doEnvPresets( pOpts, ENV_ALL );
+    }
+    else {
+        doEnvPresets( pOpts, ENV_IMM );
+
+        /*
+         *  Check to see if environment variables have disabled presetting.
+         */
+        if ((pOD != NULL) && ! DISABLED_OPT(pOD))
+            internalFileLoad( pOpts );
+
+        /*
+         *  ${PROGRAM_LOAD_OPTS} value of "no" cannot disable other environment
+         *  variable options.  Only the loading of .rc files.
+         */
+        doEnvPresets( pOpts, ENV_NON_IMM );
+    }
+    pOpts->fOptSet &= ~OPTPROC_PRESETTING;
+
+    return SUCCESS;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  VERIFY OPTION CONSISTENCY
+ *
+ *  Make sure that the argument list passes our consistency tests.
+ */
+static int
+checkConsistency( tOptions* pOpts )
+{
+    int        errCt = 0;
+    tOptDesc*  pOD   = pOpts->pOptDesc;
+    int        oCt   = pOpts->presetOptCt;
+
+    /*
+     *  FOR each of "oCt" options, ...
+     */
+    for (;;) {
+        const int*  pMust = pOD->pOptMust;
+        const int*  pCant = pOD->pOptCant;
+
+        /*
+         *  IF the current option was provided on the command line
+         *  THEN ensure that any "MUST" requirements are not
+         *       "DEFAULT" (unspecified) *AND* ensure that any
+         *       "CANT" options have not been SET or DEFINED.
+         */
+        if (SELECTED_OPT(pOD)) {
+            if (pMust != NULL) for (;;) {
+                tOptDesc*  p = pOpts->pOptDesc + *(pMust++);
+                if (UNUSED_OPT(p)) {
+                    const tOptDesc* pN = pOpts->pOptDesc + pMust[-1];
+                    errCt++;
+                    fprintf( stderr, zReqFmt, pOD->pz_Name, pN->pz_Name );
+                }
+
+                if (*pMust == NO_EQUIVALENT)
+                    break;
+            }
+
+            if (pCant != NULL) for (;;) {
+                tOptDesc*  p = pOpts->pOptDesc + *(pCant++);
+                if (SELECTED_OPT(p)) {
+                    const tOptDesc* pN = pOpts->pOptDesc + pCant[-1];
+                    errCt++;
+                    fprintf( stderr, zCantFmt, pOD->pz_Name, pN->pz_Name );
+                }
+
+                if (*pCant == NO_EQUIVALENT)
+                    break;
+            }
+        }
+
+        /*
+         *  IF       this option is not equivalenced to another,
+         *        OR it is equivalenced to itself (is the equiv. root)
+         *  THEN we need to make sure it occurs often enough.
+         */
+        if (  (pOD->optEquivIndex == NO_EQUIVALENT)
+           || (pOD->optEquivIndex == pOD->optIndex) )   do {
+            /*
+             *  IF the occurrence counts have been satisfied,
+             *  THEN there is no problem.
+             */
+            if (pOD->optOccCt >= pOD->optMinCt)
+                break;
+
+            /*
+             *  IF MUST_SET means SET and PRESET are okay,
+             *  so min occurrence count doesn't count
+             */
+            if (  (pOD->fOptState & OPTST_MUST_SET)
+               && (pOD->fOptState & (OPTST_PRESET | OPTST_SET)) )
+                break;
+
+            errCt++;
+            if (pOD->optMinCt > 1)
+                 fprintf( stderr, zNotEnough, pOD->pz_Name, pOD->optMinCt );
+            else fprintf( stderr, zNeedOne, pOD->pz_Name );
+        } while (0);
+
+        if (--oCt <= 0)
+            break;
+        pOD++;
+    }
+
+    /*
+     *  IF we are stopping on errors, check to see if any remaining
+     *  arguments are required to be there or prohibited from being there.
+     */
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+
+        /*
+         *  Check for prohibition
+         */
+        if ((pOpts->fOptSet & OPTPROC_NO_ARGS) != 0) {
+            if (pOpts->origArgCt > pOpts->curOptIdx) {
+                fprintf( stderr, zNoArgs, pOpts->pzProgName );
+                ++errCt;
+            }
+        }
+
+        /*
+         *  ELSE not prohibited, check for being required
+         */
+        else if ((pOpts->fOptSet & OPTPROC_ARGS_REQ) != 0) {
+            if (pOpts->origArgCt <= pOpts->curOptIdx) {
+                fprintf( stderr, zArgsMust, pOpts->pzProgName );
+                ++errCt;
+            }
+        }
+    }
+
+    return errCt;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  THESE ROUTINES ARE CALLABLE FROM THE GENERATED OPTION PROCESSING CODE
+ */
+/*=--subblock=arg=arg_type,arg_name,arg_desc =*/
+/*=*
+ * library:  opts
+ * header:   your-opts.h
+ *
+ * lib_description:
+ *
+ *  These are the routines that libopts users may call directly from their
+ *  code.  There are several other routines that can be called by code
+ *  generated by the libopts option templates, but they are not to be
+ *  called from any other user code.  The @file{options.h} header is
+ *  fairly clear about this, too.
+=*/
+
+/*=export_func optionProcess
+ *
+ * what: this is the main option processing routine
+ *
+ * arg:  + tOptions* + pOpts + program options descriptor +
+ * arg:  + int       + argc  + program arg count  +
+ * arg:  + char**    + argv  + program arg vector +
+ *
+ * ret_type:  int
+ * ret_desc:  the count of the arguments processed
+ *
+ * doc:
+ *
+ * This is the main entry point for processing options.  It is intended
+ * that this procedure be called once at the beginning of the execution of
+ * a program.  Depending on options selected earlier, it is sometimes
+ * necessary to stop and restart option processing, or to select completely
+ * different sets of options.  This can be done easily, but you generally
+ * do not want to do this.
+ *
+ * The number of arguments processed always includes the program name.
+ * If one of the arguments is "--", then it is counted and the processing
+ * stops.  If an error was encountered and errors are to be tolerated, then
+ * the returned value is the index of the argument causing the error.
+ * A hyphen by itself ("-") will also cause processing to stop and will
+ * @emph{not} be counted among the processed arguments.  A hyphen by itself
+ * is treated as an operand.  Encountering an operand stops option
+ * processing.
+ *
+ * err:  Errors will cause diagnostics to be printed.  @code{exit(3)} may
+ *       or may not be called.  It depends upon whether or not the options
+ *       were generated with the "allow-errors" attribute, or if the
+ *       ERRSKIP_OPTERR or ERRSTOP_OPTERR macros were invoked.
+=*/
+int
+optionProcess(
+    tOptions*  pOpts,
+    int        argCt,
+    char**     argVect )
+{
+    if (! SUCCESSFUL( validateOptionsStruct( pOpts, argVect[0] )))
+        exit( EX_SOFTWARE );
+
+    /*
+     *  Establish the real program name, the program full path,
+     *  and do all the presetting the first time thru only.
+     */
+    if ((pOpts->fOptSet & OPTPROC_INITDONE) == 0) {
+        pOpts->origArgCt   = argCt;
+        pOpts->origArgVect = argVect;
+        pOpts->fOptSet    |= OPTPROC_INITDONE;
+
+        if (! SUCCESSFUL( doPresets( pOpts )))
+            return 0;
+
+        if ((pOpts->fOptSet & OPTPROC_REORDER) != 0)
+            optionSort( pOpts );
+
+        pOpts->curOptIdx   = 1;
+        pOpts->pzCurOpt    = NULL;
+    }
+
+    /*
+     *  IF we are (re)starting,
+     *  THEN reset option location
+     */
+    else if (pOpts->curOptIdx <= 0) {
+        pOpts->curOptIdx = 1;
+        pOpts->pzCurOpt  = NULL;
+    }
+
+    if (! SUCCESSFUL( doRegularOpts( pOpts )))
+        return pOpts->origArgCt;
+
+    /*
+     *  IF    there were no errors
+     *    AND we have RC/INI files
+     *    AND there is a request to save the files
+     *  THEN do that now before testing for conflicts.
+     *       (conflicts are ignored in preset options)
+     */
+    if (pOpts->specOptIdx.save_opts != 0) {
+        tOptDesc*  pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts;
+
+        if (SELECTED_OPT( pOD )) {
+            optionSaveFile( pOpts );
+            exit( EXIT_SUCCESS );
+        }
+    }
+
+    /*
+     *  IF we are checking for errors,
+     *  THEN look for too few occurrences of required options
+     */
+    if ((pOpts->fOptSet & OPTPROC_ERRSTOP) != 0) {
+        if (checkConsistency( pOpts ) != 0)
+            (*pOpts->pUsageProc)( pOpts, EXIT_FAILURE );
+    }
+
+    return pOpts->curOptIdx;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/autoopts.c */
diff --git a/sntp/libopts/autoopts.h b/sntp/libopts/autoopts.h
new file mode 100644 (file)
index 0000000..2645757
--- /dev/null
@@ -0,0 +1,387 @@
+
+/*
+ *  Time-stamp:      "2007-04-15 09:59:39 bkorb"
+ *
+ *  autoopts.h  $Id: autoopts.h,v 4.23 2007/04/15 19:01:18 bkorb Exp $
+ *  Time-stamp:      "2005-02-14 05:59:50 bkorb"
+ *
+ *  This file defines all the global structures and special values
+ *  used in the automated option processing library.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+#ifndef AUTOGEN_AUTOOPTS_H
+#define AUTOGEN_AUTOOPTS_H
+
+#include "compat/compat.h"
+
+#define AO_NAME_LIMIT           127
+#define AO_NAME_SIZE            ((size_t)(AO_NAME_LIMIT + 1))
+
+#ifndef AG_PATH_MAX
+#  ifdef PATH_MAX
+#    define AG_PATH_MAX         ((size_t)PATH_MAX)
+#  else
+#    define AG_PATH_MAX         ((size_t)4096)
+#  endif
+#else
+#  if defined(PATH_MAX) && (PATH_MAX > MAXPATHLEN)
+#     undef  AG_PATH_MAX
+#     define AG_PATH_MAX        ((size_t)PATH_MAX)
+#  endif
+#endif
+
+#undef  EXPORT
+#define EXPORT
+
+#if defined(_WIN32) && !defined(__CYGWIN__)
+# define DIRCH                  '\\'
+#else
+# define DIRCH                  '/'
+#endif
+
+#ifndef EX_NOINPUT
+#  define EX_NOINPUT            66
+#endif
+#ifndef EX_SOFTWARE
+#  define EX_SOFTWARE           70
+#endif
+#ifndef EX_CONFIG
+#  define EX_CONFIG             78
+#endif
+
+/*
+ *  Convert the number to a list usable in a printf call
+ */
+#define NUM_TO_VER(n)           ((n) >> 12), ((n) >> 7) & 0x001F, (n) & 0x007F
+
+#define NAMED_OPTS(po) \
+        (((po)->fOptSet & (OPTPROC_SHORTOPT | OPTPROC_LONGOPT)) == 0)
+
+#define SKIP_OPT(p)  (((p)->fOptState & (OPTST_DOCUMENT|OPTST_OMITTED)) != 0)
+
+typedef int tDirection;
+#define DIRECTION_PRESET        -1
+#define DIRECTION_PROCESS       1
+#define DIRECTION_CALLED        0
+
+#define PROCESSING(d)           ((d)>0)
+#define PRESETTING(d)           ((d)<0)
+
+#define ISNAMECHAR( c )         (isalnum(c) || ((c) == '_') || ((c) == '-'))
+
+/*
+ *  Procedure success codes
+ *
+ *  USAGE:  define procedures to return "tSuccess".  Test their results
+ *          with the SUCCEEDED, FAILED and HADGLITCH macros.
+ *
+ *  Microsoft sticks its nose into user space here, so for Windows' sake,
+ *  make sure all of these are undefined.
+ */
+#undef  SUCCESS
+#undef  FAILURE
+#undef  PROBLEM
+#undef  SUCCEEDED
+#undef  SUCCESSFUL
+#undef  FAILED
+#undef  HADGLITCH
+
+#define SUCCESS                 ((tSuccess) 0)
+#define FAILURE                 ((tSuccess)-1)
+#define PROBLEM                 ((tSuccess) 1)
+
+typedef int tSuccess;
+
+#define SUCCEEDED( p )          ((p) == SUCCESS)
+#define SUCCESSFUL( p )         SUCCEEDED( p )
+#define FAILED( p )             ((p) <  SUCCESS)
+#define HADGLITCH( p )          ((p) >  SUCCESS)
+
+/*
+ *  When loading a line (or block) of text as an option, the value can
+ *  be processed in any of several modes:
+ *
+ *  @table @samp
+ *  @item keep
+ *  Every part of the value between the delimiters is saved.
+ *
+ *  @item uncooked
+ *  Even if the value begins with quote characters, do not do quote processing.
+ *
+ *  @item cooked
+ *  If the value looks like a quoted string, then process it.
+ *  Double quoted strings are processed the way strings are in "C" programs,
+ *  except they are treated as regular characters if the following character
+ *  is not a well-established escape sequence.
+ *  Single quoted strings (quoted with apostrophies) are handled the way
+ *  strings are handled in shell scripts, *except* that backslash escapes
+ *  are honored before backslash escapes and apostrophies.
+ *  @end table
+ */
+typedef enum {
+    OPTION_LOAD_COOKED,
+    OPTION_LOAD_UNCOOKED,
+    OPTION_LOAD_KEEP
+} tOptionLoadMode;
+
+extern tOptionLoadMode option_load_mode;
+
+/*
+ *  The pager state is used by optionPagedUsage() procedure.
+ *  When it runs, it sets itself up to be called again on exit.
+ *  If, however, a routine needs a child process to do some work
+ *  before it is done, then 'pagerState' must be set to
+ *  'PAGER_STATE_CHILD' so that optionPagedUsage() will not try
+ *  to run the pager program before its time.
+ */
+typedef enum {
+    PAGER_STATE_INITIAL,
+    PAGER_STATE_READY,
+    PAGER_STATE_CHILD
+} tePagerState;
+
+extern tePagerState pagerState;
+
+typedef enum {
+    ENV_ALL,
+    ENV_IMM,
+    ENV_NON_IMM
+} teEnvPresetType;
+
+typedef enum {
+    TOPT_UNDEFINED = 0,
+    TOPT_SHORT,
+    TOPT_LONG,
+    TOPT_DEFAULT
+} teOptType;
+
+typedef struct {
+    tOptDesc*  pOD;
+    tCC*       pzOptArg;
+    tAoUL      flags;
+    teOptType  optType;
+} tOptState;
+#define OPTSTATE_INITIALIZER(st) \
+    { NULL, NULL, OPTST_ ## st, TOPT_UNDEFINED }
+
+#define TEXTTO_TABLE \
+        _TT_( LONGUSAGE ) \
+        _TT_( USAGE ) \
+        _TT_( VERSION )
+#define _TT_(n) \
+        TT_ ## n ,
+
+typedef enum { TEXTTO_TABLE COUNT_TT } teTextTo;
+
+#undef _TT_
+
+typedef struct {
+    tCC*    pzStr;
+    tCC*    pzReq;
+    tCC*    pzNum;
+    tCC*    pzKey;
+    tCC*    pzKeyL;
+    tCC*    pzBool;
+    tCC*    pzNest;
+    tCC*    pzOpt;
+    tCC*    pzNo;
+    tCC*    pzBrk;
+    tCC*    pzNoF;
+    tCC*    pzSpc;
+    tCC*    pzOptFmt;
+} arg_types_t;
+
+#define AGALOC( c, w )          ao_malloc((size_t)c)
+#define AGREALOC( p, c, w )     ao_realloc((void*)p, (size_t)c)
+#define AGFREE( p )             ao_free((void*)p)
+#define AGDUPSTR( p, s, w )     (p = ao_strdup(s))
+
+static void *
+ao_malloc( size_t sz );
+
+static void *
+ao_realloc( void *p, size_t sz );
+
+static void
+ao_free( void *p );
+
+static char *
+ao_strdup( char const *str );
+
+#define TAGMEM( m, t )
+
+/*
+ *  DO option handling?
+ *
+ *  Options are examined at two times:  at immediate handling time and at
+ *  normal handling time.  If an option is disabled, the timing may be
+ *  different from the handling of the undisabled option.  The OPTST_DIABLED
+ *  bit indicates the state of the currently discovered option.
+ *  So, here's how it works:
+ *
+ *  A) handling at "immediate" time, either 1 or 2:
+ *
+ *  1.  OPTST_DISABLED is not set:
+ *      IMM           must be set
+ *      DISABLE_IMM   don't care
+ *      TWICE         don't care
+ *      DISABLE_TWICE don't care
+ *      0 -and-  1 x x x
+ *
+ *  2.  OPTST_DISABLED is set:
+ *      IMM           don't care
+ *      DISABLE_IMM   must be set
+ *      TWICE         don't care
+ *      DISABLE_TWICE don't care
+ *      1 -and-  x 1 x x
+ */
+#define DO_IMMEDIATELY(_flg) \
+    (  (((_flg) & (OPTST_DISABLED|OPTST_IMM)) == OPTST_IMM) \
+    || (   ((_flg) & (OPTST_DISABLED|OPTST_DISABLE_IMM))    \
+        == (OPTST_DISABLED|OPTST_DISABLE_IMM)  ))
+
+/*  B) handling at "regular" time because it was not immediate
+ *
+ *  1.  OPTST_DISABLED is not set:
+ *      IMM           must *NOT* be set
+ *      DISABLE_IMM   don't care
+ *      TWICE         don't care
+ *      DISABLE_TWICE don't care
+ *      0 -and-  0 x x x
+ *
+ *  2.  OPTST_DISABLED is set:
+ *      IMM           don't care
+ *      DISABLE_IMM   don't care
+ *      TWICE         must be set
+ *      DISABLE_TWICE don't care
+ *      1 -and-  x x 1 x
+ */
+#define DO_NORMALLY(_flg) ( \
+       (((_flg) & (OPTST_DISABLED|OPTST_IMM))            == 0)  \
+    || (((_flg) & (OPTST_DISABLED|OPTST_DISABLE_IMM))    ==     \
+                  OPTST_DISABLED)  )
+
+/*  C)  handling at "regular" time because it is to be handled twice.
+ *      The immediate bit was already tested and found to be set:
+ *
+ *  3.  OPTST_DISABLED is not set:
+ *      IMM           is set (but don't care)
+ *      DISABLE_IMM   don't care
+ *      TWICE         must be set
+ *      DISABLE_TWICE don't care
+ *      0 -and-  ? x 1 x
+ *
+ *  4.  OPTST_DISABLED is set:
+ *      IMM           don't care
+ *      DISABLE_IMM   is set (but don't care)
+ *      TWICE         don't care
+ *      DISABLE_TWICE must be set
+ *      1 -and-  x ? x 1
+ */
+#define DO_SECOND_TIME(_flg) ( \
+       (((_flg) & (OPTST_DISABLED|OPTST_TWICE))          ==     \
+                  OPTST_TWICE)                                  \
+    || (((_flg) & (OPTST_DISABLED|OPTST_DISABLE_TWICE))  ==     \
+                  (OPTST_DISABLED|OPTST_DISABLE_TWICE)  ))
+
+/*
+ *  text_mmap structure.  Only active on platforms with mmap(2).
+ */
+#ifdef HAVE_SYS_MMAN_H
+#  include <sys/mman.h>
+#else
+#  ifndef  PROT_READ
+#   define PROT_READ            0x01
+#  endif
+#  ifndef  PROT_WRITE
+#   define PROT_WRITE           0x02
+#  endif
+#  ifndef  MAP_SHARED
+#   define MAP_SHARED           0x01
+#  endif
+#  ifndef  MAP_PRIVATE
+#   define MAP_PRIVATE          0x02
+#  endif
+#endif
+
+#ifndef MAP_FAILED
+#  define  MAP_FAILED           ((void*)-1)
+#endif
+
+#ifndef  _SC_PAGESIZE
+# ifdef  _SC_PAGE_SIZE
+#  define _SC_PAGESIZE          _SC_PAGE_SIZE
+# endif
+#endif
+
+#ifndef HAVE_STRCHR
+extern char* strchr( char const *s, int c);
+extern char* strrchr( char const *s, int c);
+#endif
+
+/*
+ *  Define and initialize all the user visible strings.
+ *  We do not do translations.  If translations are to be done, then
+ *  the client will provide a callback for that purpose.
+ */
+#undef DO_TRANSLATIONS
+#include "autoopts/usage-txt.h"
+
+/*
+ *  File pointer for usage output
+ */
+extern FILE* option_usage_fp;
+
+extern tOptProc optionPrintVersion, optionPagedUsage, optionLoadOpt;
+
+#endif /* AUTOGEN_AUTOOPTS_H */
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/autoopts.h */
diff --git a/sntp/libopts/autoopts/options.h b/sntp/libopts/autoopts/options.h
new file mode 100644 (file)
index 0000000..c2ceeb3
--- /dev/null
@@ -0,0 +1,977 @@
+/*   -*- buffer-read-only: t -*- vi: set ro:
+ *  
+ *  DO NOT EDIT THIS FILE   (options.h)
+ *  
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:34 PM PDT
+ *  From the definitions    funcs.def
+ *  and the template file   options_h
+ *
+ *  This file defines all the global structures and special values
+ *  used in the automated option processing library.
+ *
+ *  Automated Options copyright 1992-Y Bruce Korb
+ *
+ *  AutoOpts is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *  
+ *  AutoOpts is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with AutoOpts.  If not, write to:
+ *     The Free Software Foundation, Inc.,
+ *     51 Franklin Street, Fifth Floor
+ *     Boston, MA  02110-1301, USA.
+ */
+#ifndef AUTOOPTS_OPTIONS_H_GUARD
+#define AUTOOPTS_OPTIONS_H_GUARD
+#include <sys/types.h>
+
+#if defined(HAVE_STDINT_H)
+# include <stdint.h>
+#elif defined(HAVE_INTTYPES_H)
+# include <inttypes.h>
+#endif /* HAVE_STDINT/INTTYPES_H */
+
+#if defined(HAVE_LIMITS_H)
+# include <limits.h>
+#elif defined(HAVE_SYS_LIMITS_H)
+# include <sys/limits.h>
+#endif /* HAVE_LIMITS/SYS_LIMITS_H */
+
+#if defined(HAVE_SYSEXITS_H)
+#  include <sysexits.h>
+#endif /* HAVE_SYSEXITS_H */
+
+#ifndef EX_USAGE
+#  define EX_USAGE              64
+#endif
+
+/*
+ *  PUBLIC DEFINES
+ *
+ *  The following defines may be used in applications that need to test the
+ *  state of an option.  To test against these masks and values, a pointer
+ *  to an option descriptor must be obtained.  There are two ways:
+ *
+ *  1. inside an option processing procedure, it is the second argument,
+ *  conventionally "tOptDesc* pOD".
+ *
+ *  2.  Outside of an option procedure (or to reference a different option
+ *  descriptor), use either "&DESC( opt_name )" or "&pfx_DESC( opt_name )".
+ *
+ *  See the relevant generated header file to determine which and what
+ *  values for "opt_name" are available.
+ */
+
+#define  OPTIONS_STRUCT_VERSION  118784
+#define  OPTIONS_VERSION_STRING  "29:0:4"
+#define  OPTIONS_MINIMUM_VERSION 102400
+#define  OPTIONS_MIN_VER_STRING  "25:0:0"
+
+typedef enum {
+    OPARG_TYPE_NONE             = 0,
+    OPARG_TYPE_STRING           = 1,    /* default type/ vanilla string      */
+    OPARG_TYPE_ENUMERATION      = 2,    /* opt arg is an enum (keyword list) */
+    OPARG_TYPE_BOOLEAN          = 3,    /* opt arg is boolean-valued         */
+    OPARG_TYPE_MEMBERSHIP       = 4,    /* opt arg sets set membership bits  */
+    OPARG_TYPE_NUMERIC          = 5,    /* opt arg has numeric value         */
+    OPARG_TYPE_HIERARCHY        = 6     /* option arg is hierarchical value  */
+} teOptArgType;
+
+typedef struct optionValue {
+    teOptArgType        valType;
+    char*               pzName;
+    union {
+        char            strVal[1];      /* OPARG_TYPE_STRING      */
+        unsigned int    enumVal;        /* OPARG_TYPE_ENUMERATION */
+        unsigned int    boolVal;        /* OPARG_TYPE_BOOLEAN     */
+        unsigned long   setVal;         /* OPARG_TYPE_MEMBERSHIP  */
+        long            longVal;        /* OPARG_TYPE_NUMERIC     */
+        void*           nestVal;        /* OPARG_TYPE_HIERARCHY   */
+    } v;
+} tOptionValue;
+
+/*
+ *  Bits in the fOptState option descriptor field.
+ */
+typedef enum {
+    OPTST_SET_ID             =   0, /* Set via the "SET_OPT()" macro */
+    OPTST_PRESET_ID          =   1, /* Set via an RC/INI file        */
+    OPTST_DEFINED_ID         =   2, /* Set via a command line option */
+    OPTST_EQUIVALENCE_ID     =   4, /* selected by equiv'ed option   */
+    OPTST_DISABLED_ID        =   5, /* option is in disabled state   */
+    OPTST_ALLOC_ARG_ID       =   6, /* pzOptArg was allocated        */
+    OPTST_NO_INIT_ID         =   8, /* option cannot be preset       */
+    OPTST_NUMBER_OPT_ID      =   9, /* opt value (flag) is any digit */
+    OPTST_STACKED_ID         =  10, /* opt uses optionStackArg proc  */
+    OPTST_INITENABLED_ID     =  11, /* option defaults to enabled    */
+    OPTST_ARG_TYPE_1_ID      =  12, /* bit 1 of arg type enum        */
+    OPTST_ARG_TYPE_2_ID      =  13, /* bit 2 of arg type enum        */
+    OPTST_ARG_TYPE_3_ID      =  14, /* bit 3 of arg type enum        */
+    OPTST_ARG_TYPE_4_ID      =  15, /* bit 4 of arg type enum        */
+    OPTST_ARG_OPTIONAL_ID    =  16, /* the option arg not required   */
+    OPTST_IMM_ID             =  17, /* process opt on first pass     */
+    OPTST_DISABLE_IMM_ID     =  18, /* process disablement immed.    */
+    OPTST_OMITTED_ID         =  19, /* compiled out of program       */
+    OPTST_MUST_SET_ID        =  20, /* must be set or pre-set        */
+    OPTST_DOCUMENT_ID        =  21, /* opt is for doc only           */
+    OPTST_TWICE_ID           =  22, /* process opt twice - imm + reg */
+    OPTST_DISABLE_TWICE_ID   =  23  /* process disabled option twice */
+} opt_state_enum_t;
+
+#define OPTST_INIT           0U
+#define OPTST_SET            (1U << OPTST_SET_ID)
+#define OPTST_PRESET         (1U << OPTST_PRESET_ID)
+#define OPTST_DEFINED        (1U << OPTST_DEFINED_ID)
+#define OPTST_EQUIVALENCE    (1U << OPTST_EQUIVALENCE_ID)
+#define OPTST_DISABLED       (1U << OPTST_DISABLED_ID)
+#define OPTST_ALLOC_ARG      (1U << OPTST_ALLOC_ARG_ID)
+#define OPTST_NO_INIT        (1U << OPTST_NO_INIT_ID)
+#define OPTST_NUMBER_OPT     (1U << OPTST_NUMBER_OPT_ID)
+#define OPTST_STACKED        (1U << OPTST_STACKED_ID)
+#define OPTST_INITENABLED    (1U << OPTST_INITENABLED_ID)
+#define OPTST_ARG_TYPE_1     (1U << OPTST_ARG_TYPE_1_ID)
+#define OPTST_ARG_TYPE_2     (1U << OPTST_ARG_TYPE_2_ID)
+#define OPTST_ARG_TYPE_3     (1U << OPTST_ARG_TYPE_3_ID)
+#define OPTST_ARG_TYPE_4     (1U << OPTST_ARG_TYPE_4_ID)
+#define OPTST_ARG_OPTIONAL   (1U << OPTST_ARG_OPTIONAL_ID)
+#define OPTST_IMM            (1U << OPTST_IMM_ID)
+#define OPTST_DISABLE_IMM    (1U << OPTST_DISABLE_IMM_ID)
+#define OPTST_OMITTED        (1U << OPTST_OMITTED_ID)
+#define OPTST_MUST_SET       (1U << OPTST_MUST_SET_ID)
+#define OPTST_DOCUMENT       (1U << OPTST_DOCUMENT_ID)
+#define OPTST_TWICE          (1U << OPTST_TWICE_ID)
+#define OPTST_DISABLE_TWICE  (1U << OPTST_DISABLE_TWICE_ID)
+#define OPT_STATE_MASK       0x00FFFF77U
+
+#define OPTST_SET_MASK       (  \
+        OPTST_SET | \
+        OPTST_PRESET | \
+        OPTST_DEFINED )
+
+#define OPTST_MUTABLE_MASK   (  \
+        OPTST_SET | \
+        OPTST_PRESET | \
+        OPTST_DEFINED | \
+        OPTST_EQUIVALENCE | \
+        OPTST_DISABLED | \
+        OPTST_ALLOC_ARG )
+
+#define OPTST_SELECTED_MASK  (  \
+        OPTST_SET | \
+        OPTST_DEFINED )
+
+#define OPTST_ARG_TYPE_MASK  (  \
+        OPTST_ARG_TYPE_1 | \
+        OPTST_ARG_TYPE_2 | \
+        OPTST_ARG_TYPE_3 | \
+        OPTST_ARG_TYPE_4 )
+
+#ifdef NO_OPTIONAL_OPT_ARGS
+# undef  OPTST_ARG_OPTIONAL
+# define OPTST_ARG_OPTIONAL   0
+#endif
+
+#define OPTST_PERSISTENT_MASK (~OPTST_MUTABLE_MASK)
+
+#define SELECTED_OPT( pod )   ((pod)->fOptState  & OPTST_SELECTED_MASK)
+#define UNUSED_OPT(   pod )   (((pod)->fOptState & OPTST_SET_MASK) == 0)
+#define DISABLED_OPT( pod )   ((pod)->fOptState  & OPTST_DISABLED)
+#define OPTION_STATE( pod )   ((pod)->fOptState)
+
+#define OPTST_SET_ARGTYPE(n)  ((n) << OPTST_ARG_TYPE_1_ID)
+#define OPTST_GET_ARGTYPE(f)  (((f) & OPTST_ARG_TYPE_MASK)>>OPTST_ARG_TYPE_1_ID)
+
+/*
+ *  PRIVATE INTERFACES
+ *
+ *  The following values are used in the generated code to communicate
+ *  with the option library procedures.  They are not for public use
+ *  and may be subject to change.
+ */
+
+/*
+ *  Define the processing state flags
+ */
+typedef enum {
+    OPTPROC_LONGOPT_ID       =   0, /* Process long style options      */
+    OPTPROC_SHORTOPT_ID      =   1, /* Process short style "flags"     */
+    OPTPROC_ERRSTOP_ID       =   2, /* Stop on argument errors         */
+    OPTPROC_DISABLEDOPT_ID   =   3, /* Current option is disabled      */
+    OPTPROC_NO_REQ_OPT_ID    =   4, /* no options are required         */
+    OPTPROC_NUM_OPT_ID       =   5, /* there is a number option        */
+    OPTPROC_INITDONE_ID      =   6, /* have initializations been done? */
+    OPTPROC_NEGATIONS_ID     =   7, /* any negation options?           */
+    OPTPROC_ENVIRON_ID       =   8, /* check environment?              */
+    OPTPROC_NO_ARGS_ID       =   9, /* Disallow remaining arguments    */
+    OPTPROC_ARGS_REQ_ID      =  10, /* Require arguments after options */
+    OPTPROC_REORDER_ID       =  11, /* reorder operands after options  */
+    OPTPROC_GNUUSAGE_ID      =  12, /* emit usage in GNU style         */
+    OPTPROC_TRANSLATE_ID     =  13, /* Translate strings in tOptions   */
+    OPTPROC_HAS_IMMED_ID     =  14, /* program defines immed options   */
+    OPTPROC_PRESETTING_ID    =  19  /* opt processing in preset state  */
+} optproc_state_enum_t;
+
+#define OPTPROC_NONE         0U
+#define OPTPROC_LONGOPT      (1U << OPTPROC_LONGOPT_ID)
+#define OPTPROC_SHORTOPT     (1U << OPTPROC_SHORTOPT_ID)
+#define OPTPROC_ERRSTOP      (1U << OPTPROC_ERRSTOP_ID)
+#define OPTPROC_DISABLEDOPT  (1U << OPTPROC_DISABLEDOPT_ID)
+#define OPTPROC_NO_REQ_OPT   (1U << OPTPROC_NO_REQ_OPT_ID)
+#define OPTPROC_NUM_OPT      (1U << OPTPROC_NUM_OPT_ID)
+#define OPTPROC_INITDONE     (1U << OPTPROC_INITDONE_ID)
+#define OPTPROC_NEGATIONS    (1U << OPTPROC_NEGATIONS_ID)
+#define OPTPROC_ENVIRON      (1U << OPTPROC_ENVIRON_ID)
+#define OPTPROC_NO_ARGS      (1U << OPTPROC_NO_ARGS_ID)
+#define OPTPROC_ARGS_REQ     (1U << OPTPROC_ARGS_REQ_ID)
+#define OPTPROC_REORDER      (1U << OPTPROC_REORDER_ID)
+#define OPTPROC_GNUUSAGE     (1U << OPTPROC_GNUUSAGE_ID)
+#define OPTPROC_TRANSLATE    (1U << OPTPROC_TRANSLATE_ID)
+#define OPTPROC_HAS_IMMED    (1U << OPTPROC_HAS_IMMED_ID)
+#define OPTPROC_PRESETTING   (1U << OPTPROC_PRESETTING_ID)
+#define OPTPROC_STATE_MASK   0x00087FFFU
+
+#define STMTS(s)  do { s; } while (0)
+
+/*
+ *  The following must be #defined instead of typedef-ed
+ *  because "static const" cannot both be applied to a type,
+ *  tho each individually can...so they all are
+ */
+#define tSCC        static char const
+#define tCC         char const
+#define tAoSC       static char
+#define tAoUC       unsigned char
+#define tAoUI       unsigned int
+#define tAoUL       unsigned long
+#define tAoUS       unsigned short
+
+/*
+ *  It is so disgusting that there must be so many ways
+ *  of specifying TRUE and FALSE.
+ */
+typedef enum { AG_FALSE = 0, AG_TRUE } ag_bool;
+
+/*
+ *  Define a structure that describes each option and
+ *  a pointer to the procedure that handles it.
+ *  The argument is the count of this flag previously seen.
+ */
+typedef struct options  tOptions;
+typedef struct optDesc  tOptDesc;
+typedef struct optNames tOptNames;
+
+/*
+ *  The option procedures do the special processing for each
+ *  option flag that needs it.
+ */
+typedef void (tOptProc)( tOptions*  pOpts, tOptDesc* pOptDesc );
+typedef tOptProc*  tpOptProc;
+
+/*
+ *  The usage procedure will never return.  It calls "exit(2)"
+ *  with the "exitCode" argument passed to it.
+ */
+typedef void (tUsageProc)( tOptions* pOpts, int exitCode );
+typedef tUsageProc* tpUsageProc;
+
+/*
+ *  Special definitions.  "NOLIMIT" is the 'max' value to use when
+ *  a flag may appear multiple times without limit.  "NO_EQUIVALENT"
+ *  is an illegal value for 'optIndex' (option description index).
+ */
+#define NOLIMIT          USHRT_MAX
+#define OPTION_LIMIT     SHRT_MAX
+#define NO_EQUIVALENT    (OPTION_LIMIT+1)
+
+/*
+ *  Special values for optValue.  It must not be generatable from the
+ *  computation "optIndex +96".  Since "optIndex" is limited to 100, ...
+ */
+#define NUMBER_OPTION    '#'
+
+typedef struct argList tArgList;
+#define MIN_ARG_ALLOC_CT   6
+#define INCR_ARG_ALLOC_CT  8
+struct argList {
+    int             useCt;
+    int             allocCt;
+    tCC*            apzArgs[ MIN_ARG_ALLOC_CT ];
+};
+
+typedef union {
+    char const *    argString;
+    uintptr_t       argEnum;
+    uintptr_t       argIntptr;
+    long            argInt;
+    unsigned long   argUint;
+    unsigned int    argBool;
+} optArgBucket_t;
+
+/*
+ *  Descriptor structure for each option.
+ *  Only the fields marked "PUBLIC" are for public use.
+ */
+struct optDesc {
+    tAoUS const     optIndex;         /* PUBLIC */
+    tAoUS const     optValue;         /* PUBLIC */
+    tAoUS           optActualIndex;   /* PUBLIC */
+    tAoUS           optActualValue;   /* PUBLIC */
+
+    tAoUS const     optEquivIndex;    /* PUBLIC */
+    tAoUS const     optMinCt;
+    tAoUS const     optMaxCt;
+    tAoUS           optOccCt;         /* PUBLIC */
+
+    tAoUI           fOptState;        /* PUBLIC */
+    tAoUI           reserved;
+    optArgBucket_t  optArg;           /* PUBLIC */
+#   define          pzLastArg   optArg.argString
+    void*           optCookie;        /* PUBLIC */
+
+    const int *     pOptMust;
+    const int *     pOptCant;
+    tpOptProc       pOptProc;
+    char const*     pzText;
+
+    char const*     pz_NAME;
+    char const*     pz_Name;
+    char const*     pz_DisableName;
+    char const*     pz_DisablePfx;
+};
+
+/*
+ *  Some options need special processing, so we store their
+ *  indexes in a known place:
+ */
+typedef struct optSpecIndex tOptSpecIndex;
+struct optSpecIndex {
+    const tAoUS         more_help;
+    const tAoUS         save_opts;
+    const tAoUS         number_option;
+    const tAoUS         default_opt;
+};
+
+/*
+ *  The procedure generated for translating option text
+ */
+typedef void (tOptionXlateProc)(void);
+
+struct options {
+    int const           structVersion;
+    int                 origArgCt;
+    char**              origArgVect;
+    unsigned int        fOptSet;
+    unsigned int        curOptIdx;
+    char*               pzCurOpt;
+
+    char const*         pzProgPath;
+    char const*         pzProgName;
+    char const* const   pzPROGNAME;
+    char const* const   pzRcName;
+    char const* const   pzCopyright;
+    char const* const   pzCopyNotice;
+    char const* const   pzFullVersion;
+    char const* const* const papzHomeList;
+    char const* const   pzUsageTitle;
+    char const* const   pzExplain;
+    char const* const   pzDetail;
+    tOptDesc*   const   pOptDesc;
+    char const* const   pzBugAddr;
+
+    void*               pExtensions;
+    void*               pSavedState;
+
+    tpUsageProc         pUsageProc;
+    tOptionXlateProc*   pTransProc;
+
+    tOptSpecIndex       specOptIdx;
+    int const           optCt;
+    int const           presetOptCt;
+};
+
+/*
+ *  "token list" structure returned by "string_tokenize()"
+ */
+typedef struct {
+    unsigned long   tkn_ct;
+    unsigned char*  tkn_list[1];
+} token_list_t;
+
+/*
+ *  Hide the interface - it pollutes a POSIX claim, but leave it for
+ *  anyone #include-ing this header
+ */
+#define strneqvcmp      option_strneqvcmp
+#define streqvcmp       option_streqvcmp
+#define streqvmap       option_streqvmap
+#define strequate       option_strequate
+#define strtransform    option_strtransform
+
+/*
+ *  This is an output only structure used by text_mmap and text_munmap.
+ *  Clients must not alter the contents and must provide it to both
+ *  the text_mmap and text_munmap procedures.  BE ADVISED: if you are
+ *  mapping the file with PROT_WRITE the NUL byte at the end MIGHT NOT
+ *  BE WRITABLE.  In any event, that byte is not be written back
+ *  to the source file.  ALSO: if "txt_data" is valid and "txt_errno"
+ *  is not zero, then there *may* not be a terminating NUL.
+ */
+typedef struct {
+    void*       txt_data;      /* text file data   */
+    size_t      txt_size;      /* actual file size */
+    size_t      txt_full_size; /* mmaped mem size  */
+    int         txt_fd;        /* file descriptor  */
+    int         txt_zero_fd;   /* fd for /dev/zero */
+    int         txt_errno;     /* warning code     */
+    int         txt_prot;      /* "prot" flags     */
+    int         txt_flags;     /* mapping type     */
+    int         txt_alloc;     /* if we malloced memory */
+} tmap_info_t;
+
+#define TEXT_MMAP_FAILED_ADDR(a)  ((void*)(a) ==  (void*)MAP_FAILED)
+
+#ifdef  __cplusplus
+extern "C" {
+#define CPLUSPLUS_CLOSER }
+#else
+#define CPLUSPLUS_CLOSER
+#endif
+
+/*
+ *  The following routines may be coded into AutoOpts client code:
+ */
+
+/* From: tokenize.c line 115
+ *
+ * ao_string_tokenize - tokenize an input string
+ *
+ * Arguments:
+ *   string       string to be tokenized
+ *
+ * Returns: token_list_t* - pointer to a structure that lists each token
+ *
+ *  This function will convert one input string into a list of strings.
+ *  The list of strings is derived by separating the input based on
+ *  white space separation.  However, if the input contains either single
+ *  or double quote characters, then the text after that character up to
+ *  a matching quote will become the string in the list.
+ *  
+ *  The returned pointer should be deallocated with @code{free(3C)} when
+ *  are done using the data.  The data are placed in a single block of
+ *  allocated memory.  Do not deallocate individual token/strings.
+ *  
+ *  The structure pointed to will contain at least these two fields:
+ *  @table @samp
+ *  @item tkn_ct
+ *  The number of tokens found in the input string.
+ *  @item tok_list
+ *  An array of @code{tkn_ct + 1} pointers to substring tokens, with
+ *  the last pointer set to NULL.
+ *  @end table
+ *  
+ *  There are two types of quoted strings: single quoted (@code{'}) and
+ *  double quoted (@code{"}).  Singly quoted strings are fairly raw in that
+ *  escape characters (@code{\\}) are simply another character, except when
+ *  preceding the following characters:
+ *  @example
+ *  @code{\\}  double backslashes reduce to one
+ *  @code{'}   incorporates the single quote into the string
+ *  @code{\n}  suppresses both the backslash and newline character
+ *  @end example
+ *  
+ *  Double quote strings are formed according to the rules of string
+ *  constants in ANSI-C programs.
+ */
+extern token_list_t* ao_string_tokenize( char const* );
+
+
+/* From: configfile.c line 113
+ *
+ * configFileLoad - parse a configuration file
+ *
+ * Arguments:
+ *   pzFile       the file to load
+ *
+ * Returns: const tOptionValue* - An allocated, compound value structure
+ *
+ *  This routine will load a named configuration file and parse the
+ *  text as a hierarchically valued option.  The option descriptor
+ *  created from an option definition file is not used via this interface.
+ *  The returned value is "named" with the input file name and is of
+ *  type "@code{OPARG_TYPE_HIERARCHY}".  It may be used in calls to
+ *  @code{optionGetValue()}, @code{optionNextValue()} and
+ *  @code{optionUnloadNested()}.
+ */
+extern const tOptionValue* configFileLoad( char const* );
+
+
+/* From: configfile.c line 883
+ *
+ * optionFileLoad - Load the locatable config files, in order
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *   pzProg       program name
+ *
+ * Returns: int - 0 -> SUCCESS, -1 -> FAILURE
+ *
+ *  This function looks in all the specified directories for a configuration
+ *  file ("rc" file or "ini" file) and processes any found twice.  The first
+ *  time through, they are processed in reverse order (last file first).  At
+ *  that time, only "immediate action" configurables are processed.  For
+ *  example, if the last named file specifies not processing any more
+ *  configuration files, then no more configuration files will be processed.
+ *  Such an option in the @strong{first} named directory will have no effect.
+ *  
+ *  Once the immediate action configurables have been handled, then the
+ *  directories are handled in normal, forward order.  In that way, later
+ *  config files can override the settings of earlier config files.
+ *  
+ *  See the AutoOpts documentation for a thorough discussion of the
+ *  config file format.
+ *  
+ *  Configuration files not found or not decipherable are simply ignored.
+ */
+extern int optionFileLoad( tOptions*, char const* );
+
+
+/* From: configfile.c line 245
+ *
+ * optionFindNextValue - find a hierarcicaly valued option instance
+ *
+ * Arguments:
+ *   pOptDesc     an option with a nested arg type
+ *   pPrevVal     the last entry
+ *   name         name of value to find
+ *   value        the matching value
+ *
+ * Returns: const tOptionValue* - a compound value structure
+ *
+ *  This routine will find the next entry in a nested value option or
+ *  configurable.  It will search through the list and return the next entry
+ *  that matches the criteria.
+ */
+extern const tOptionValue* optionFindNextValue( const tOptDesc*, const tOptionValue*, char const*, char const* );
+
+
+/* From: configfile.c line 171
+ *
+ * optionFindValue - find a hierarcicaly valued option instance
+ *
+ * Arguments:
+ *   pOptDesc     an option with a nested arg type
+ *   name         name of value to find
+ *   value        the matching value
+ *
+ * Returns: const tOptionValue* - a compound value structure
+ *
+ *  This routine will find an entry in a nested value option or configurable.
+ *  It will search through the list and return a matching entry.
+ */
+extern const tOptionValue* optionFindValue( const tOptDesc*, char const*, char const* );
+
+
+/* From: restore.c line 188
+ *
+ * optionFree - free allocated option processing memory
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *
+ *  AutoOpts sometimes allocates memory and puts pointers to it in the
+ *  option state structures.  This routine deallocates all such memory.
+ */
+extern void optionFree( tOptions* );
+
+
+/* From: configfile.c line 314
+ *
+ * optionGetValue - get a specific value from a hierarcical list
+ *
+ * Arguments:
+ *   pOptValue    a hierarchcal value
+ *   valueName    name of value to get
+ *
+ * Returns: const tOptionValue* - a compound value structure
+ *
+ *  This routine will find an entry in a nested value option or configurable.
+ *  If "valueName" is NULL, then the first entry is returned.  Otherwise,
+ *  the first entry with a name that exactly matches the argument will be
+ *  returned.
+ */
+extern const tOptionValue* optionGetValue( const tOptionValue*, char const* );
+
+
+/* From: load.c line 521
+ *
+ * optionLoadLine - process a string for an option name and value
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *   pzLine       NUL-terminated text
+ *
+ *  This is a client program callable routine for setting options from, for
+ *  example, the contents of a file that they read in.  Only one option may
+ *  appear in the text.  It will be treated as a normal (non-preset) option.
+ *  
+ *  When passed a pointer to the option struct and a string, it will find
+ *  the option named by the first token on the string and set the option
+ *  argument to the remainder of the string.  The caller must NUL terminate
+ *  the string.  Any embedded new lines will be included in the option
+ *  argument.  If the input looks like one or more quoted strings, then the
+ *  input will be "cooked".  The "cooking" is identical to the string
+ *  formation used in AutoGen definition files (@pxref{basic expression}),
+ *  except that you may not use backquotes.
+ */
+extern void optionLoadLine( tOptions*, char const* );
+
+
+/* From: configfile.c line 373
+ *
+ * optionNextValue - get the next value from a hierarchical list
+ *
+ * Arguments:
+ *   pOptValue    a hierarchcal list value
+ *   pOldValue    a value from this list
+ *
+ * Returns: const tOptionValue* - a compound value structure
+ *
+ *  This routine will return the next entry after the entry passed in.  At the
+ *  end of the list, NULL will be returned.  If the entry is not found on the
+ *  list, NULL will be returned and "@var{errno}" will be set to EINVAL.
+ *  The "@var{pOldValue}" must have been gotten from a prior call to this
+ *  routine or to "@code{opitonGetValue()}".
+ */
+extern const tOptionValue* optionNextValue( const tOptionValue*, const tOptionValue* );
+
+
+/* From: usage.c line 128
+ *
+ * optionOnlyUsage - Print usage text for just the options
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *   ex_code      exit code for calling exit(3)
+ *
+ *  This routine will print only the usage for each option.
+ *  This function may be used when the emitted usage must incorporate
+ *  information not available to AutoOpts.
+ */
+extern void optionOnlyUsage( tOptions*, int );
+
+
+/* From: autoopts.c line 1012
+ *
+ * optionProcess - this is the main option processing routine
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *   argc         program arg count
+ *   argv         program arg vector
+ *
+ * Returns: int - the count of the arguments processed
+ *
+ *  This is the main entry point for processing options.  It is intended
+ *  that this procedure be called once at the beginning of the execution of
+ *  a program.  Depending on options selected earlier, it is sometimes
+ *  necessary to stop and restart option processing, or to select completely
+ *  different sets of options.  This can be done easily, but you generally
+ *  do not want to do this.
+ *  
+ *  The number of arguments processed always includes the program name.
+ *  If one of the arguments is "--", then it is counted and the processing
+ *  stops.  If an error was encountered and errors are to be tolerated, then
+ *  the returned value is the index of the argument causing the error.
+ *  A hyphen by itself ("-") will also cause processing to stop and will
+ *  @emph{not} be counted among the processed arguments.  A hyphen by itself
+ *  is treated as an operand.  Encountering an operand stops option
+ *  processing.
+ */
+extern int optionProcess( tOptions*, int, char** );
+
+
+/* From: restore.c line 145
+ *
+ * optionRestore - restore option state from memory copy
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *
+ *  Copy back the option state from saved memory.
+ *  The allocated memory is left intact, so this routine can be
+ *  called repeatedly without having to call optionSaveState again.
+ *  If you are restoring a state that was saved before the first call
+ *  to optionProcess(3AO), then you may change the contents of the
+ *  argc/argv parameters to optionProcess.
+ */
+extern void optionRestore( tOptions* );
+
+
+/* From: save.c line 334
+ *
+ * optionSaveFile - saves the option state to a file
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *
+ *  This routine will save the state of option processing to a file.  The name
+ *  of that file can be specified with the argument to the @code{--save-opts}
+ *  option, or by appending the @code{rcfile} attribute to the last
+ *  @code{homerc} attribute.  If no @code{rcfile} attribute was specified, it
+ *  will default to @code{.@i{programname}rc}.  If you wish to specify another
+ *  file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro.
+ */
+extern void optionSaveFile( tOptions* );
+
+
+/* From: restore.c line 93
+ *
+ * optionSaveState - saves the option state to memory
+ *
+ * Arguments:
+ *   pOpts        program options descriptor
+ *
+ *  This routine will allocate enough memory to save the current option
+ *  processing state.  If this routine has been called before, that memory
+ *  will be reused.  You may only save one copy of the option state.  This
+ *  routine may be called before optionProcess(3AO).  If you do call it
+ *  before the first call to optionProcess, then you may also change the
+ *  contents of argc/argv after you call optionRestore(3AO)
+ *  
+ *  In fact, more strongly put: it is safest to only use this function
+ *  before having processed any options.  In particular, the saving and
+ *  restoring of stacked string arguments and hierarchical values is
+ *  disabled.  The values are not saved.
+ */
+extern void optionSaveState( tOptions* );
+
+
+/* From: nested.c line 559
+ *
+ * optionUnloadNested - Deallocate the memory for a nested value
+ *
+ * Arguments:
+ *   pOptVal      the hierarchical value
+ *
+ *  A nested value needs to be deallocated.  The pointer passed in should
+ *  have been gotten from a call to @code{configFileLoad()} (See
+ *  @pxref{libopts-configFileLoad}).
+ */
+extern void optionUnloadNested( tOptionValue const * );
+
+
+/* From: version.c line 58
+ *
+ * optionVersion - return the compiled AutoOpts version number
+ *
+ * Returns: char const* - the version string in constant memory
+ *
+ *  Returns the full version string compiled into the library.
+ *  The returned string cannot be modified.
+ */
+extern char const* optionVersion( void );
+
+
+/* From: ../compat/pathfind.c line 34
+ *
+ * pathfind - fild a file in a list of directories
+ *
+ * Arguments:
+ *   path         colon separated list of search directories
+ *   file         the name of the file to look for
+ *   mode         the mode bits that must be set to match
+ *
+ * Returns: char* - the path to the located file
+ *
+ * the pathfind function is available only if HAVE_PATHFIND is not defined
+ *
+ *  pathfind looks for a a file with name "FILE" and "MODE" access
+ *  along colon delimited "PATH", and returns the full pathname as a
+ *  string, or NULL if not found.  If "FILE" contains a slash, then
+ *  it is treated as a relative or absolute path and "PATH" is ignored.
+ *  
+ *  @strong{NOTE}: this function is compiled into @file{libopts} only if
+ *  it is not natively supplied.
+ *  
+ *  The "MODE" argument is a string of option letters chosen from the
+ *  list below:
+ *  @example
+ *  Letter    Meaning
+ *  r         readable
+ *  w         writable
+ *  x         executable
+ *  f         normal file       (NOT IMPLEMENTED)
+ *  b         block special     (NOT IMPLEMENTED)
+ *  c         character special (NOT IMPLEMENTED)
+ *  d         directory         (NOT IMPLEMENTED)
+ *  p         FIFO (pipe)       (NOT IMPLEMENTED)
+ *  u         set user ID bit   (NOT IMPLEMENTED)
+ *  g         set group ID bit  (NOT IMPLEMENTED)
+ *  k         sticky bit        (NOT IMPLEMENTED)
+ *  s         size nonzero      (NOT IMPLEMENTED)
+ *  @end example
+ */
+#ifndef HAVE_PATHFIND
+extern char* pathfind( char const*, char const*, char const* );
+#endif /* HAVE_PATHFIND */
+
+
+/* From: streqvcmp.c line 233
+ *
+ * strequate - map a list of characters to the same value
+ *
+ * Arguments:
+ *   ch_list      characters to equivalence
+ *
+ *  Each character in the input string get mapped to the first character
+ *  in the string.
+ *  This function name is mapped to option_strequate so as to not conflict
+ *  with the POSIX name space.
+ */
+extern void strequate( char const* );
+
+
+/* From: streqvcmp.c line 143
+ *
+ * streqvcmp - compare two strings with an equivalence mapping
+ *
+ * Arguments:
+ *   str1         first string
+ *   str2         second string
+ *
+ * Returns: int - the difference between two differing characters
+ *
+ *  Using a character mapping, two strings are compared for "equivalence".
+ *  Each input character is mapped to a comparison character and the
+ *  mapped-to characters are compared for the two NUL terminated input strings.
+ *  This function name is mapped to option_streqvcmp so as to not conflict
+ *  with the POSIX name space.
+ */
+extern int streqvcmp( char const*, char const* );
+
+
+/* From: streqvcmp.c line 180
+ *
+ * streqvmap - Set the character mappings for the streqv functions
+ *
+ * Arguments:
+ *   From         Input character
+ *   To           Mapped-to character
+ *   ct           compare length
+ *
+ *  Set the character mapping.  If the count (@code{ct}) is set to zero, then
+ *  the map is cleared by setting all entries in the map to their index
+ *  value.  Otherwise, the "@code{From}" character is mapped to the "@code{To}"
+ *  character.  If @code{ct} is greater than 1, then @code{From} and @code{To}
+ *  are incremented and the process repeated until @code{ct} entries have been
+ *  set. For example,
+ *  @example
+ *  streqvmap( 'a', 'A', 26 );
+ *  @end example
+ *  @noindent
+ *  will alter the mapping so that all English lower case letters
+ *  will map to upper case.
+ *  
+ *  This function name is mapped to option_streqvmap so as to not conflict
+ *  with the POSIX name space.
+ */
+extern void streqvmap( char, char, int );
+
+
+/* From: streqvcmp.c line 102
+ *
+ * strneqvcmp - compare two strings with an equivalence mapping
+ *
+ * Arguments:
+ *   str1         first string
+ *   str2         second string
+ *   ct           compare length
+ *
+ * Returns: int - the difference between two differing characters
+ *
+ *  Using a character mapping, two strings are compared for "equivalence".
+ *  Each input character is mapped to a comparison character and the
+ *  mapped-to characters are compared for the two NUL terminated input strings.
+ *  The comparison is limited to @code{ct} bytes.
+ *  This function name is mapped to option_strneqvcmp so as to not conflict
+ *  with the POSIX name space.
+ */
+extern int strneqvcmp( char const*, char const*, int );
+
+
+/* From: streqvcmp.c line 259
+ *
+ * strtransform - convert a string into its mapped-to value
+ *
+ * Arguments:
+ *   dest         output string
+ *   src          input string
+ *
+ *  Each character in the input string is mapped and the mapped-to
+ *  character is put into the output.
+ *  This function name is mapped to option_strtransform so as to not conflict
+ *  with the POSIX name space.
+ */
+extern void strtransform( char*, char const* );
+
+/*  AutoOpts PRIVATE FUNCTIONS:  */
+tOptProc optionStackArg, optionUnstackArg, optionBooleanVal, optionNumericVal;
+
+extern char* ao_string_cook( char*, int* );
+
+extern unsigned int ao_string_cook_escape_char( char const*, char*, unsigned int );
+
+extern void export_options_to_guile( tOptions* );
+
+extern void genshelloptUsage( tOptions*, int );
+
+extern void optionBooleanVal( tOptions*, tOptDesc* );
+
+extern uintptr_t optionEnumerationVal( tOptions*, tOptDesc*, char const * const *, unsigned int );
+
+extern char const* optionKeywordName( tOptDesc*, unsigned int );
+
+extern void optionLoadOpt( tOptions*, tOptDesc* );
+
+extern ag_bool optionMakePath( char*, int, char const*, char const* );
+
+extern void optionNestedVal( tOptions*, tOptDesc* );
+
+extern void optionNumericVal( tOptions*, tOptDesc* );
+
+extern void optionPagedUsage( tOptions*, tOptDesc* );
+
+extern void optionParseShell( tOptions* );
+
+extern void optionPrintVersion( tOptions*, tOptDesc* );
+
+extern void optionPutShell( tOptions* );
+
+extern void optionSetMembers( tOptions*, tOptDesc*, char const * const *, unsigned int );
+
+extern void optionStackArg( tOptions*, tOptDesc* );
+
+extern void optionUnstackArg( tOptions*, tOptDesc* );
+
+extern void optionUsage( tOptions*, int );
+
+extern void optionVersionStderr( tOptions*, tOptDesc* );
+
+extern void* text_mmap( char const*, int, int, tmap_info_t* );
+
+extern int text_munmap( tmap_info_t* );
+
+CPLUSPLUS_CLOSER
+#endif /* AUTOOPTS_OPTIONS_H_GUARD */
+/*
+ * Local Variables:
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * options.h ends here */
diff --git a/sntp/libopts/autoopts/usage-txt.h b/sntp/libopts/autoopts/usage-txt.h
new file mode 100644 (file)
index 0000000..5aaaa01
--- /dev/null
@@ -0,0 +1,355 @@
+/*   -*- buffer-read-only: t -*- vi: set ro:
+ *  
+ *  DO NOT EDIT THIS FILE   (usage-txt.h)
+ *  
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:33 PM PDT
+ *  From the definitions    usage-txt.def
+ *  and the template file   usage-txt.tpl
+ *
+ *  This file handles all the bookkeeping required for tracking all the little
+ *  tiny strings used by the AutoOpts library.  There are 113
+ *  of them.  This is not versioned because it is entirely internal to the
+ *  library and accessed by client code only in a very well-controlled way:
+ *  they may substitute translated strings using a procedure that steps through
+ *  all the string pointers.
+ *
+ *  AutoOpts is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *  
+ *  AutoOpts is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *  
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with AutoOpts.  If not, write to:
+ *     The Free Software Foundation, Inc.,
+ *     51 Franklin Street, Fifth Floor
+ *     Boston, MA  02110-1301, USA.
+ */
+#ifndef AUTOOPTS_USAGE_TXT_H_GUARD
+#define AUTOOPTS_USAGE_TXT_H_GUARD
+
+#undef  cch_t
+#define cch_t char const
+
+/*
+ *  One structure to hold all the pointers to all the stringlets.
+ */
+typedef struct {
+  int       field_ct;
+  char*     utpz_GnuBoolArg;
+  char*     utpz_GnuKeyArg;
+  char*     utpz_GnuKeyLArg;
+  char*     utpz_GnuNumArg;
+  char*     utpz_GnuStrArg;
+  cch_t*    apz_str[ 108 ];
+} usage_text_t;
+
+/*
+ *  Declare the global structure with all the pointers to translated
+ *  strings.  This is then used by the usage generation procedure.
+ */
+extern usage_text_t option_usage_text;
+
+#if defined(AUTOOPTS_INTERNAL) /* DEFINE ALL THE STRINGS = = = = = */
+/*
+ *  Provide a mapping from a short name to fields in this structure.
+ */
+#define zAO_Bad               (option_usage_text.apz_str[  0])
+#define zAO_Big               (option_usage_text.apz_str[  1])
+#define zAO_Err               (option_usage_text.apz_str[  2])
+#define zAO_Sml               (option_usage_text.apz_str[  3])
+#define zAll                  (option_usage_text.apz_str[  4])
+#define zAlt                  (option_usage_text.apz_str[  5])
+#define zAmbigKey             (option_usage_text.apz_str[  6])
+#define zAmbiguous            (option_usage_text.apz_str[  7])
+#define zArgsMust             (option_usage_text.apz_str[  8])
+#define zAtMost               (option_usage_text.apz_str[  9])
+#define zAuto                 (option_usage_text.apz_str[ 10])
+#define zBadPipe              (option_usage_text.apz_str[ 11])
+#define zBadVerArg            (option_usage_text.apz_str[ 12])
+#define zCantFmt              (option_usage_text.apz_str[ 13])
+#define zCantSave             (option_usage_text.apz_str[ 14])
+#define zDefaultOpt           (option_usage_text.apz_str[ 15])
+#define zDis                  (option_usage_text.apz_str[ 16])
+#define zEnab                 (option_usage_text.apz_str[ 17])
+#define zEquiv                (option_usage_text.apz_str[ 18])
+#define zErrOnly              (option_usage_text.apz_str[ 19])
+#define zExamineFmt           (option_usage_text.apz_str[ 20])
+#define zFiveSpaces           (option_usage_text.apz_str[ 21])
+#define zFlagOkay             (option_usage_text.apz_str[ 22])
+#define zFmtFmt               (option_usage_text.apz_str[ 23])
+#define zForkFail             (option_usage_text.apz_str[ 24])
+#define zFSErrOptLoad         (option_usage_text.apz_str[ 25])
+#define zFSErrReadFile        (option_usage_text.apz_str[ 26])
+#define zGenshell             (option_usage_text.apz_str[ 27])
+#define zGnuBoolArg           (option_usage_text.utpz_GnuBoolArg)
+#define zGnuBreak             (option_usage_text.apz_str[ 28])
+#define zGnuKeyArg            (option_usage_text.utpz_GnuKeyArg)
+#define zGnuKeyLArg           (option_usage_text.utpz_GnuKeyLArg)
+#define zGnuNestArg           (option_usage_text.apz_str[ 29])
+#define zGnuNumArg            (option_usage_text.utpz_GnuNumArg)
+#define zGnuOptArg            (option_usage_text.apz_str[ 30])
+#define zGnuOptFmt            (option_usage_text.apz_str[ 31])
+#define zGnuStrArg            (option_usage_text.utpz_GnuStrArg)
+#define zIllOptChr            (option_usage_text.apz_str[ 32])
+#define zIllOptStr            (option_usage_text.apz_str[ 33])
+#define zIllegal              (option_usage_text.apz_str[ 34])
+#define zInvalOptDesc         (option_usage_text.apz_str[ 35])
+#define zKeyWords             (option_usage_text.apz_str[ 36])
+#define zLoadCooked           (option_usage_text.apz_str[ 37])
+#define zLoadKeep             (option_usage_text.apz_str[ 38])
+#define zLoadType             (option_usage_text.apz_str[ 39])
+#define zLoadUncooked         (option_usage_text.apz_str[ 40])
+#define zLtypeInteger         (option_usage_text.apz_str[ 41])
+#define zLtypeNest            (option_usage_text.apz_str[ 42])
+#define zLtypeString          (option_usage_text.apz_str[ 43])
+#define zLtypeBool            (option_usage_text.apz_str[ 44])
+#define zLtypeKeyword         (option_usage_text.apz_str[ 45])
+#define zLtypeSetMembership   (option_usage_text.apz_str[ 46])
+#define zMembers              (option_usage_text.apz_str[ 47])
+#define zMisArg               (option_usage_text.apz_str[ 48])
+#define zMultiEquiv           (option_usage_text.apz_str[ 49])
+#define zMust                 (option_usage_text.apz_str[ 50])
+#define zNeedOne              (option_usage_text.apz_str[ 51])
+#define zNoArg                (option_usage_text.apz_str[ 52])
+#define zNoArgs               (option_usage_text.apz_str[ 53])
+#define zNoCreat              (option_usage_text.apz_str[ 54])
+#define zNoFlags              (option_usage_text.apz_str[ 55])
+#define zNoKey                (option_usage_text.apz_str[ 56])
+#define zNoLim                (option_usage_text.apz_str[ 57])
+#define zNoPreset             (option_usage_text.apz_str[ 58])
+#define zNoRq_NoShrtTtl       (option_usage_text.apz_str[ 59])
+#define zNoRq_ShrtTtl         (option_usage_text.apz_str[ 60])
+#define zNoStat               (option_usage_text.apz_str[ 61])
+#define zNoState              (option_usage_text.apz_str[ 62])
+#define zNone                 (option_usage_text.apz_str[ 63])
+#define zNotDef               (option_usage_text.apz_str[ 64])
+#define zNotEnough            (option_usage_text.apz_str[ 65])
+#define zNotFile              (option_usage_text.apz_str[ 66])
+#define zNotNumber            (option_usage_text.apz_str[ 67])
+#define zNrmOptFmt            (option_usage_text.apz_str[ 68])
+#define zNumberOpt            (option_usage_text.apz_str[ 69])
+#define zOneSpace             (option_usage_text.apz_str[ 70])
+#define zOnlyOne              (option_usage_text.apz_str[ 71])
+#define zOptsOnly             (option_usage_text.apz_str[ 72])
+#define zPathFmt              (option_usage_text.apz_str[ 73])
+#define zPlsSendBugs          (option_usage_text.apz_str[ 74])
+#define zPreset               (option_usage_text.apz_str[ 75])
+#define zPresetFile           (option_usage_text.apz_str[ 76])
+#define zPresetIntro          (option_usage_text.apz_str[ 77])
+#define zProg                 (option_usage_text.apz_str[ 78])
+#define zProhib               (option_usage_text.apz_str[ 79])
+#define zReorder              (option_usage_text.apz_str[ 80])
+#define zReqFmt               (option_usage_text.apz_str[ 81])
+#define zReqOptFmt            (option_usage_text.apz_str[ 82])
+#define zReqThese             (option_usage_text.apz_str[ 83])
+#define zReq_NoShrtTtl        (option_usage_text.apz_str[ 84])
+#define zReq_ShrtTtl          (option_usage_text.apz_str[ 85])
+#define zSepChars             (option_usage_text.apz_str[ 86])
+#define zSetMembers           (option_usage_text.apz_str[ 87])
+#define zSetMemberSettings    (option_usage_text.apz_str[ 88])
+#define zShrtGnuOptFmt        (option_usage_text.apz_str[ 89])
+#define zSixSpaces            (option_usage_text.apz_str[ 90])
+#define zStdBoolArg           (option_usage_text.apz_str[ 91])
+#define zStdBreak             (option_usage_text.apz_str[ 92])
+#define zStdKeyArg            (option_usage_text.apz_str[ 93])
+#define zStdKeyLArg           (option_usage_text.apz_str[ 94])
+#define zStdNestArg           (option_usage_text.apz_str[ 95])
+#define zStdNoArg             (option_usage_text.apz_str[ 96])
+#define zStdNumArg            (option_usage_text.apz_str[ 97])
+#define zStdOptArg            (option_usage_text.apz_str[ 98])
+#define zStdReqArg            (option_usage_text.apz_str[ 99])
+#define zStdStrArg            (option_usage_text.apz_str[100])
+#define zTabHyp               (option_usage_text.apz_str[101])
+#define zTabHypAnd            (option_usage_text.apz_str[102])
+#define zTabout               (option_usage_text.apz_str[103])
+#define zThreeSpaces          (option_usage_text.apz_str[104])
+#define zTwoSpaces            (option_usage_text.apz_str[105])
+#define zUpTo                 (option_usage_text.apz_str[106])
+#define zValidKeys            (option_usage_text.apz_str[107])
+
+  /*
+   *  First, set up the strings.  Some of these are writable.  These are all in
+   *  English.  This gets compiled into libopts and is distributed here so that
+   *  xgettext (or equivalents) can extract these strings for translation.
+   */
+
+  static char    eng_zGnuBoolArg[] = "=T/F";
+  static char    eng_zGnuKeyArg[] = "=KWd";
+  static char    eng_zGnuKeyLArg[] = "=Mbr";
+  static char    eng_zGnuNumArg[] = "=num";
+  static char    eng_zGnuStrArg[] = "=str";
+static char const usage_txt[3208] =
+    "AutoOpts function called without option descriptor\n\0"
+    "\tThis exceeds the compiled library version:  \0"
+    "Automated Options Processing Error!\n"
+    "\t%s called AutoOpts function with structure version %d:%d:%d.\n\0"
+    "\tThis is less than the minimum library version:  \0"
+    "all\0"
+    "\t\t\t\t- an alternate for %s\n\0"
+    "%s error:  the keyword `%s' is ambiguous for %s\n\0"
+    "ambiguous\0"
+    "%s: Command line arguments required\n\0"
+    "%d %s%s options allowed\n\0"
+    "version and help options:\0"
+    "Error %d (%s) from the pipe(2) syscall\n\0"
+    "ERROR: version option argument '%c' invalid.  Use:\n"
+    "\t'v' - version only\n"
+    "\t'c' - version and copyright\n"
+    "\t'n' - version and copyright notice\n\0"
+    "ERROR:  %s option conflicts with the %s option\n\0"
+    "%s(optionSaveState): error: cannot allocate %d bytes\n\0"
+    "\t\t\t\t- default option for unnamed options\n\0"
+    "\t\t\t\t- disabled as --%s\n\0"
+    "\t\t\t\t- enabled by default\n\0"
+    "-equivalence\0"
+    "ERROR:  only \0"
+    " - examining environment variables named %s_*\n\0"
+    "     \0"
+    "Options are specified by doubled hyphens and their name\n"
+    "or by a single hyphen and the flag character.\n\0"
+    "%%-%ds %%s\n\0"
+    "fs error %d (%s) on fork - cannot obtain %s usage\n\0"
+    "File error %d (%s) opening %s for loading options\n\0"
+    "fs error %d (%s) reading file %s\n\0"
+    "\n"
+    "= = = = = = = =\n\n"
+    "This incarnation of genshell will produce\n"
+    "a shell script to parse the options for %s:\n\n\0"
+    "\n"
+    "%s\n\n\0"
+    "=Cplx\0"
+    "[=arg]\0"
+    "--%2$s%1$s\0"
+    "%s: illegal option -- %c\n\0"
+    "%s: %s option -- %s\n\0"
+    "illegal\0"
+    "AutoOpts ERROR:  invalid option descriptor for %s\n\0"
+    "words=\0"
+    "cooked\0"
+    "keep\0"
+    "type=\0"
+    "uncooked\0"
+    "integer\0"
+    "nested\0"
+    "string\0"
+    "bool\0"
+    "keyword\0"
+    "set\0"
+    "\t\t\t\t- is a set membership option\n\0"
+    "%s: option `%s' requires an argument\n\0"
+    "Equivalenced option '%s' was equivalenced to both\n"
+    "\t'%s' and '%s'\0"
+    "\t\t\t\t- must appear between %d and %d times\n\0"
+    "ERROR:  The %s option is required\n\0"
+    "%s: option `%s' cannot have an argument\n\0"
+    "%s: Command line arguments not allowed\n\0"
+    "error %d (%s) creating %s\n\0"
+    "Options are specified by single or double hyphens and their name.\n\0"
+    "%s error:  `%s' does not match any %s keywords\n\0"
+    "\t\t\t\t- may appear multiple times\n\0"
+    "\t\t\t\t- may not be preset\n\0"
+    "   Arg Option-Name    Description\n\0"
+    "  Flg Arg Option-Name    Description\n\0"
+    "error %d (%s) stat-ing %s\n\0"
+    "%s(optionRestore): error: no saved option state\n\0"
+    "none\0"
+    "'%s' not defined\n\0"
+    "ERROR:  The %s option must appear %d times\n\0"
+    "error:  cannot load options from non-regular file %s\n\0"
+    "%s error:  `%s' is not a recognizable number\n\0"
+    " %3s %s\0"
+    "The '-#<number>' option may omit the hash char\n\0"
+    " \0"
+    "one %s%s option allowed\n\0"
+    "All arguments are named options.\n\0"
+    " - reading file %s\0"
+    "\n"
+    "please send bug reports to:  %s\n\0"
+    "\t\t\t\t- may NOT appear - preset only\n\0"
+    "#  preset/initialization file\n"
+    "#  %s#\n\0"
+    "\n"
+    "The following option preset mechanisms are supported:\n\0"
+    "program\0"
+    "prohibits these options:\n\0"
+    "Operands and options may be intermixed.  They will be reordered.\n\0"
+    "ERROR:  %s option requires the %s option\n\0"
+    " %3s %-14s %s\0"
+    "requires these options:\n\0"
+    "   Arg Option-Name   Req?  Description\n\0"
+    "  Flg Arg Option-Name   Req?  Description\n\0"
+    "-_^\0"
+    "members=\0"
+    "or you may use a numeric representation.  Preceding these with a '!' will\n"
+    "clear the bits, specifying 'none' will clear all bits, and 'all' will set them\n"
+    "all.  Multiple entries may be passed as an option argument list.\n\0"
+    "%s\0"
+    "      \0"
+    "T/F\0"
+    "\n"
+    "%s\n\n"
+    "%s\0"
+    "KWd\0"
+    "Mbr\0"
+    "Cpx\0"
+    "no \0"
+    "Num\0"
+    "opt\0"
+    "YES\0"
+    "Str\0"
+    "\t\t\t\t- \0"
+    "\t\t\t\t-- and \0"
+    "\t\t\t\t%s\n\0"
+    "   \0"
+    "  \0"
+    "\t\t\t\t- may appear up to %d times\n\0"
+    "The valid \"%s\" option keywords are:\n\0";
+
+
+  /*
+   *  Now, define (and initialize) the structure that contains
+   *  the pointers to all these strings.
+   *  Aren't you glad you don't maintain this by hand?
+   */
+  usage_text_t option_usage_text = {
+    113,
+    eng_zGnuBoolArg, eng_zGnuKeyArg,  eng_zGnuKeyLArg, eng_zGnuNumArg,
+    eng_zGnuStrArg,
+    {
+      usage_txt +   0, usage_txt +  52, usage_txt +  98, usage_txt + 197,
+      usage_txt + 247, usage_txt + 251, usage_txt + 278, usage_txt + 327,
+      usage_txt + 337, usage_txt + 374, usage_txt + 399, usage_txt + 425,
+      usage_txt + 465, usage_txt + 602, usage_txt + 650, usage_txt + 704,
+      usage_txt + 746, usage_txt + 770, usage_txt + 796, usage_txt + 809,
+      usage_txt + 823, usage_txt + 870, usage_txt + 876, usage_txt + 979,
+      usage_txt + 991, usage_txt +1042, usage_txt +1093, usage_txt +1127,
+      usage_txt +1233, usage_txt +1239, usage_txt +1245, usage_txt +1252,
+      usage_txt +1263, usage_txt +1289, usage_txt +1310, usage_txt +1318,
+      usage_txt +1369, usage_txt +1376, usage_txt +1383, usage_txt +1388,
+      usage_txt +1394, usage_txt +1403, usage_txt +1411, usage_txt +1418,
+      usage_txt +1425, usage_txt +1430, usage_txt +1438, usage_txt +1442,
+      usage_txt +1476, usage_txt +1514, usage_txt +1579, usage_txt +1622,
+      usage_txt +1657, usage_txt +1698, usage_txt +1738, usage_txt +1765,
+      usage_txt +1832, usage_txt +1880, usage_txt +1913, usage_txt +1938,
+      usage_txt +1973, usage_txt +2011, usage_txt +2038, usage_txt +2087,
+      usage_txt +2092, usage_txt +2110, usage_txt +2154, usage_txt +2208,
+      usage_txt +2254, usage_txt +2262, usage_txt +2310, usage_txt +2312,
+      usage_txt +2337, usage_txt +2371, usage_txt +2390, usage_txt +2424,
+      usage_txt +2460, usage_txt +2498, usage_txt +2554, usage_txt +2562,
+      usage_txt +2588, usage_txt +2654, usage_txt +2696, usage_txt +2710,
+      usage_txt +2735, usage_txt +2775, usage_txt +2818, usage_txt +2822,
+      usage_txt +2831, usage_txt +3050, usage_txt +3053, usage_txt +3060,
+      usage_txt +3064, usage_txt +3072, usage_txt +3076, usage_txt +3080,
+      usage_txt +3084, usage_txt +3088, usage_txt +3092, usage_txt +3096,
+      usage_txt +3100, usage_txt +3104, usage_txt +3111, usage_txt +3123,
+      usage_txt +3131, usage_txt +3135, usage_txt +3138, usage_txt +3171
+    }
+  };
+
+#endif /* DO_TRANSLATIONS */
+#endif /* AUTOOPTS_USAGE_TXT_H_GUARD */
diff --git a/sntp/libopts/boolean.c b/sntp/libopts/boolean.c
new file mode 100644 (file)
index 0000000..37148a9
--- /dev/null
@@ -0,0 +1,106 @@
+
+/*
+ *  $Id: boolean.c,v 4.10 2007/02/04 17:44:12 bkorb Exp $
+ * Time-stamp:      "2007-01-13 10:10:39 bkorb"
+ *
+ *   Automated Options Paged Usage module.
+ *
+ *  This routine will run run-on options through a pager so the
+ *  user may examine, print or edit them at their leisure.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/*=export_func  optionBooleanVal
+ * private:
+ *
+ * what:  Decipher a boolean value
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Decipher a true or false value for a boolean valued option argument.
+ *  The value is true, unless it starts with 'n' or 'f' or "#f" or
+ *  it is an empty string or it is a number that evaluates to zero.
+=*/
+void
+optionBooleanVal( tOptions* pOpts, tOptDesc* pOD )
+{
+    char* pz;
+    ag_bool  res = AG_TRUE;
+
+    switch (*(pOD->optArg.argString)) {
+    case '0':
+    {
+        long  val = strtol( pOD->optArg.argString, &pz, 0 );
+        if ((val != 0) || (*pz != NUL))
+            break;
+        /* FALLTHROUGH */
+    }
+    case 'N':
+    case 'n':
+    case 'F':
+    case 'f':
+    case NUL:
+        res = AG_FALSE;
+        break;
+    case '#':
+        if (pOD->optArg.argString[1] != 'f')
+            break;
+        res = AG_FALSE;
+    }
+
+    if (pOD->fOptState & OPTST_ALLOC_ARG) {
+        AGFREE(pOD->optArg.argString);
+        pOD->fOptState &= ~OPTST_ALLOC_ARG;
+    }
+    pOD->optArg.argBool = res;
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/boolean.c */
diff --git a/sntp/libopts/compat/compat.h b/sntp/libopts/compat/compat.h
new file mode 100644 (file)
index 0000000..b3bd58f
--- /dev/null
@@ -0,0 +1,319 @@
+/*  -*- Mode: C -*-  */
+
+/* --- fake the preprocessor into handlng portability */
+/*
+ *  Time-stamp:      "2007-02-03 17:41:06 bkorb"
+ *
+ * Author:           Gary V Vaughan <gvaughan@oranda.demon.co.uk>
+ * Created:          Mon Jun 30 15:54:46 1997
+ *
+ * $Id: compat.h,v 4.16 2007/04/27 01:10:47 bkorb Exp $
+ */
+#ifndef COMPAT_H_GUARD
+#define COMPAT_H_GUARD 1
+
+#if defined(HAVE_CONFIG_H)
+#  include <config.h>
+
+#elif defined(_WIN32) && !defined(__CYGWIN__)
+#  include "windows-config.h"
+
+#else
+#  error "compat.h" requires "config.h"
+   choke me.
+#endif
+
+
+#ifndef HAVE_STRSIGNAL
+   char * strsignal( int signo );
+#endif
+
+#define  _GNU_SOURCE    1 /* for strsignal in GNU's libc */
+#define  __USE_GNU      1 /* exact same thing as above   */
+#define  __EXTENSIONS__ 1 /* and another way to call for it */
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  SYSTEM HEADERS:
+ */
+#include <sys/types.h>
+#ifdef HAVE_SYS_MMAN_H
+#  include <sys/mman.h>
+#endif
+#include <sys/param.h>
+#if HAVE_SYS_PROCSET_H
+#  include <sys/procset.h>
+#endif
+#include <sys/stat.h>
+#include <sys/wait.h>
+
+#if defined( HAVE_SOLARIS_SYSINFO )
+#  include <sys/systeminfo.h>
+#elif defined( HAVE_UNAME_SYSCALL )
+#  include <sys/utsname.h>
+#endif
+
+#ifdef DAEMON_ENABLED
+#  if HAVE_SYS_STROPTS_H
+#  include <sys/stropts.h>
+#  endif
+
+#  if HAVE_SYS_SOCKET_H
+#  include <sys/socket.h>
+#  endif
+
+#  if ! defined(HAVE_SYS_POLL_H) && ! defined(HAVE_SYS_SELECT_H)
+#    error This system cannot support daemon processing
+     Choke Me.
+#  endif
+
+#  if HAVE_SYS_POLL_H
+#  include <sys/poll.h>
+#  endif
+
+#  if HAVE_SYS_SELECT_H
+#  include <sys/select.h>
+#  endif
+
+#  if HAVE_NETINET_IN_H
+#  include <netinet/in.h>
+#  endif
+
+#  if HAVE_SYS_UN_H
+#  include <sys/un.h>
+#  endif
+#endif
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  USER HEADERS:
+ */
+#include <stdio.h>
+#include <assert.h>
+#include <ctype.h>
+
+/*
+ *  Directory opening stuff:
+ */
+# if defined (_POSIX_SOURCE)
+/* Posix does not require that the d_ino field be present, and some
+   systems do not provide it. */
+#    define REAL_DIR_ENTRY(dp) 1
+# else /* !_POSIX_SOURCE */
+#    define REAL_DIR_ENTRY(dp) (dp->d_ino != 0)
+# endif /* !_POSIX_SOURCE */
+
+# if defined (HAVE_DIRENT_H)
+#   include <dirent.h>
+#   define D_NAMLEN(dirent) strlen((dirent)->d_name)
+# else /* !HAVE_DIRENT_H */
+#   define dirent direct
+#   define D_NAMLEN(dirent) (dirent)->d_namlen
+#   if defined (HAVE_SYS_NDIR_H)
+#     include <sys/ndir.h>
+#   endif /* HAVE_SYS_NDIR_H */
+#   if defined (HAVE_SYS_DIR_H)
+#     include <sys/dir.h>
+#   endif /* HAVE_SYS_DIR_H */
+#   if defined (HAVE_NDIR_H)
+#     include <ndir.h>
+#   endif /* HAVE_NDIR_H */
+# endif /* !HAVE_DIRENT_H */
+
+#include <errno.h>
+#ifdef HAVE_FCNTL_H
+# include <fcntl.h>
+#endif
+#ifndef O_NONBLOCK
+# define O_NONBLOCK FNDELAY
+#endif
+
+#if defined(HAVE_LIBGEN) && defined(HAVE_LIBGEN_H)
+#  include <libgen.h>
+#endif
+
+#if defined(HAVE_LIMITS_H)  /* this is also in options.h */
+#  include <limits.h>
+#elif defined(HAVE_SYS_LIMITS_H)
+#  include <sys/limits.h>
+#endif /* HAVE_LIMITS/SYS_LIMITS_H */
+
+#include <memory.h>
+#include <setjmp.h>
+#include <signal.h>
+
+#if defined( HAVE_STDINT_H )
+#  include <stdint.h>
+#elif defined( HAVE_INTTYPES_H )
+#  include <inttypes.h>
+#endif
+
+#include <stdlib.h>
+#include <string.h>
+
+#include <time.h>
+
+#ifdef HAVE_UTIME_H
+#  include <utime.h>
+#endif
+
+#ifdef HAVE_UNISTD_H
+#  include <unistd.h>
+#endif
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  FIXUPS and CONVIENCE STUFF:
+ */
+#ifdef __cplusplus
+#   define EXTERN extern "C"
+#else
+#   define EXTERN extern
+#endif
+
+/* some systems #def errno! and others do not declare it!! */
+#ifndef errno
+   extern int errno;
+#endif
+
+/* Some machines forget this! */
+
+# ifndef EXIT_FAILURE
+#   define EXIT_SUCCESS 0
+#   define EXIT_FAILURE 1
+# endif
+
+#ifndef NUL
+#  define NUL '\0'
+#endif
+
+#ifndef NULL
+#  define NULL 0
+#endif
+
+#if !defined (MAXPATHLEN) && defined (HAVE_SYS_PARAM_H)
+#  include <sys/param.h>
+#endif /* !MAXPATHLEN && HAVE_SYS_PARAM_H */
+
+#if !defined (MAXPATHLEN) && defined (PATH_MAX)
+#  define MAXPATHLEN PATH_MAX
+#endif /* !MAXPATHLEN && PATH_MAX */
+
+#if !defined (MAXPATHLEN) && defined(_MAX_PATH)
+#  define PATH_MAX _MAX_PATH
+#  define MAXPATHLEN _MAX_PATH
+#endif
+
+#if !defined (MAXPATHLEN)
+#  define MAXPATHLEN ((size_t)4096)
+#endif /* MAXPATHLEN */
+
+#define AG_PATH_MAX  ((size_t)MAXPATHLEN)
+
+#ifndef LONG_MAX
+#  define LONG_MAX      ~(1L << (8*sizeof(long) -1))
+#  define INT_MAX       ~(1 << (8*sizeof(int) -1))
+#endif
+
+#ifndef ULONG_MAX
+#  define ULONG_MAX     ~(OUL)
+#  define UINT_MAX      ~(OU)
+#endif
+
+#ifndef SHORT_MAX
+#  define SHORT_MAX     ~(1 << (8*sizeof(short) -1))
+#else
+#  define USHORT_MAX    ~(OUS)
+#endif
+
+#ifndef HAVE_INT8_T
+  typedef signed char       int8_t;
+#endif
+#ifndef HAVE_UINT8_T
+  typedef unsigned char     uint8_t;
+#endif
+#ifndef HAVE_INT16_T
+  typedef signed short      int16_t;
+#endif
+#ifndef HAVE_UINT16_T
+  typedef unsigned short    uint16_t;
+#endif
+#ifndef HAVE_UINT_T
+  typedef unsigned int      uint_t;
+#endif
+
+#ifndef HAVE_INT32_T
+# if SIZEOF_INT == 4
+        typedef signed int      int32_t;
+# elif SIZEOF_LONG == 4
+        typedef signed long     int32_t;
+# endif
+#endif
+
+#ifndef HAVE_UINT32_T
+# if SIZEOF_INT == 4
+        typedef unsigned int    uint32_t;
+# elif SIZEOF_LONG == 4
+        typedef unsigned long   uint32_t;
+# else
+#   error Cannot create a uint32_t type.
+    Choke Me.
+# endif
+#endif
+
+#ifndef HAVE_INTPTR_T
+  typedef signed long   intptr_t;
+#endif
+#ifndef HAVE_UINTPTR_T
+  typedef unsigned long uintptr_t;
+#endif
+
+/* redefine these for BSD style string libraries */
+#ifndef HAVE_STRCHR
+#  define strchr        index
+#  define strrchr       rindex
+#endif
+
+#ifdef USE_FOPEN_BINARY
+#  ifndef FOPEN_BINARY_FLAG
+#    define FOPEN_BINARY_FLAG   "b"
+#  endif
+#  ifndef FOPEN_TEXT_FLAG
+#    define FOPEN_TEXT_FLAG     "t"
+#  endif
+#else
+#  ifndef FOPEN_BINARY_FLAG
+#    define FOPEN_BINARY_FLAG
+#  endif
+#  ifndef FOPEN_TEXT_FLAG
+#    define FOPEN_TEXT_FLAG
+#  endif
+#endif
+
+#ifndef STR
+#  define _STR(s) #s
+#  define STR(s)  _STR(s)
+#endif
+
+/* ##### Pointer sized word ##### */
+
+/* FIXME:  the MAX stuff in here is broken! */
+#if SIZEOF_CHARP > SIZEOF_INT
+   typedef long t_word;
+   #define WORD_MAX  LONG_MAX
+   #define WORD_MIN  LONG_MIN
+#else /* SIZEOF_CHARP <= SIZEOF_INT */
+   typedef int t_word;
+   #define WORD_MAX  INT_MAX
+   #define WORD_MIN  INT_MIN
+#endif
+
+#endif /* COMPAT_H_GUARD */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of compat/compat.h */
diff --git a/sntp/libopts/compat/pathfind.c b/sntp/libopts/compat/pathfind.c
new file mode 100644 (file)
index 0000000..96eb771
--- /dev/null
@@ -0,0 +1,339 @@
+/*  -*- Mode: C -*-  */
+
+/* pathfind.c --- find a FILE  MODE along PATH */
+
+/*
+ * Author:           Gary V Vaughan <gvaughan@oranda.demon.co.uk>
+ * Time-stamp:       "2006-09-23 19:46:16 bkorb"
+ * Created:          Tue Jun 24 15:07:31 1997
+ * Last Modified:    $Date: 2006/11/27 01:52:23 $
+ *            by: bkorb
+ *
+ * $Id: pathfind.c,v 4.10 2006/11/27 01:52:23 bkorb Exp $
+ */
+
+/* Code: */
+
+#include "compat.h"
+#ifndef HAVE_PATHFIND
+#if defined(__windows__) && !defined(__CYGWIN__)
+char*
+pathfind( char const*  path,
+          char const*  fileName,
+          char const*  mode )
+{
+    return NULL;
+}
+#else
+
+static char* make_absolute( char const *string, char const *dot_path );
+static char* canonicalize_pathname( char *path );
+static char* extract_colon_unit( char* dir, char const *string, int *p_index );
+
+
+/*=export_func pathfind
+ *
+ * what: fild a file in a list of directories
+ *
+ * ifndef: HAVE_PATHFIND
+ *
+ * arg:  + char const* + path + colon separated list of search directories +
+ * arg:  + char const* + file + the name of the file to look for +
+ * arg:  + char const* + mode + the mode bits that must be set to match +
+ *
+ * ret_type:  char*
+ * ret_desc:  the path to the located file
+ *
+ * doc:
+ *
+ * pathfind looks for a a file with name "FILE" and "MODE" access
+ * along colon delimited "PATH", and returns the full pathname as a
+ * string, or NULL if not found.  If "FILE" contains a slash, then
+ * it is treated as a relative or absolute path and "PATH" is ignored.
+ *
+ * @strong{NOTE}: this function is compiled into @file{libopts} only if
+ * it is not natively supplied.
+ *
+ * The "MODE" argument is a string of option letters chosen from the
+ * list below:
+ * @example
+ *          Letter    Meaning
+ *          r         readable
+ *          w         writable
+ *          x         executable
+ *          f         normal file       (NOT IMPLEMENTED)
+ *          b         block special     (NOT IMPLEMENTED)
+ *          c         character special (NOT IMPLEMENTED)
+ *          d         directory         (NOT IMPLEMENTED)
+ *          p         FIFO (pipe)       (NOT IMPLEMENTED)
+ *          u         set user ID bit   (NOT IMPLEMENTED)
+ *          g         set group ID bit  (NOT IMPLEMENTED)
+ *          k         sticky bit        (NOT IMPLEMENTED)
+ *          s         size nonzero      (NOT IMPLEMENTED)
+ * @end example
+ *
+ * example:
+ * To find the "ls" command using the "PATH" environment variable:
+ * @example
+ *    #include <stdlib.h>
+ *    char* pz_ls = pathfind( getenv("PATH"), "ls", "rx" );
+ *    <<do whatever with pz_ls>>
+ *    free( pz_ls );
+ * @end example
+ * The path is allocated with @code{malloc(3C)}, so you must @code{free(3C)}
+ * the result.  Also, do not use unimplemented file modes.  :-)
+ *
+ * err:  returns NULL if the file is not found.
+=*/
+char*
+pathfind( char const*  path,
+          char const*  fileName,
+          char const*  mode )
+{
+    int   p_index   = 0;
+    int   mode_bits = 0;
+    char* pathName  = NULL;
+    char  zPath[ AG_PATH_MAX + 1 ];
+
+    if (strchr( mode, 'r' )) mode_bits |= R_OK;
+    if (strchr( mode, 'w' )) mode_bits |= W_OK;
+    if (strchr( mode, 'x' )) mode_bits |= X_OK;
+
+    /*
+     *  FOR each non-null entry in the colon-separated path, DO ...
+     */
+    for (;;) {
+        DIR*  dirP;
+        char* colon_unit = extract_colon_unit( zPath, path, &p_index );
+
+        /*
+         *  IF no more entries, THEN quit
+         */
+        if (colon_unit == NULL)
+            break;
+
+        dirP = opendir( colon_unit );
+
+        /*
+         *  IF the directory is inaccessable, THEN next directory
+         */
+        if (dirP == NULL)
+            continue;
+
+        /*
+         *  FOR every entry in the given directory, ...
+         */
+        for (;;) {
+            struct dirent *entP = readdir( dirP );
+
+            if (entP == (struct dirent*)NULL)
+                break;
+
+            /*
+             *  IF the file name matches the one we are looking for, ...
+             */
+            if (strcmp( entP->d_name, fileName ) == 0) {
+                char* pzFullName = make_absolute( fileName, colon_unit);
+
+                /*
+                 *  Make sure we can access it in the way we want
+                 */
+                if (access( pzFullName, mode_bits ) >= 0) {
+                    /*
+                     *  We can, so normalize the name and return it below
+                     */
+                    pathName = canonicalize_pathname( pzFullName );
+                }
+
+                free( (void*)pzFullName );
+                break;
+            }
+        }
+
+        closedir( dirP );
+
+        if (pathName != NULL)
+            break;
+    }
+
+    return pathName;
+}
+
+/*
+ * Turn STRING  (a pathname) into an  absolute  pathname, assuming  that
+ * DOT_PATH contains the symbolic location of  `.'.  This always returns
+ * a new string, even if STRING was an absolute pathname to begin with.
+ */
+static char*
+make_absolute( char const *string, char const *dot_path )
+{
+    char *result;
+    int result_len;
+
+    if (!dot_path || *string == '/') {
+        result = strdup( string );
+    } else {
+        if (dot_path && dot_path[0]) {
+            result = malloc( 2 + strlen( dot_path ) + strlen( string ) );
+            strcpy( result, dot_path );
+            result_len = strlen( result );
+            if (result[result_len - 1] != '/') {
+                result[result_len++] = '/';
+                result[result_len] = '\0';
+            }
+        } else {
+            result = malloc( 3 + strlen( string ) );
+            result[0] = '.'; result[1] = '/'; result[2] = '\0';
+            result_len = 2;
+        }
+
+        strcpy( result + result_len, string );
+    }
+
+    return result;
+}
+
+/*
+ * Canonicalize PATH, and return a  new path.  The new path differs from
+ * PATH in that:
+ *
+ *    Multiple `/'s     are collapsed to a single `/'.
+ *    Leading `./'s     are removed.
+ *    Trailing `/.'s    are removed.
+ *    Trailing `/'s     are removed.
+ *    Non-leading `../'s and trailing `..'s are handled by removing
+ *                    portions of the path.
+ */
+static char*
+canonicalize_pathname( char *path )
+{
+    int i, start;
+    char stub_char, *result;
+
+    /* The result cannot be larger than the input PATH. */
+    result = strdup( path );
+
+    stub_char = (*path == '/') ? '/' : '.';
+
+    /* Walk along RESULT looking for things to compact. */
+    i = 0;
+    while (result[i]) {
+        while (result[i] != '\0' && result[i] != '/')
+            i++;
+
+        start = i++;
+
+        /* If we didn't find any  slashes, then there is nothing left to
+         * do.
+         */
+        if (!result[start])
+            break;
+
+        /* Handle multiple `/'s in a row. */
+        while (result[i] == '/')
+            i++;
+
+#if !defined (apollo)
+        if ((start + 1) != i)
+#else
+        if ((start + 1) != i && (start != 0 || i != 2))
+#endif /* apollo */
+        {
+            strcpy( result + start + 1, result + i );
+            i = start + 1;
+        }
+
+        /* Handle backquoted `/'. */
+        if (start > 0 && result[start - 1] == '\\')
+            continue;
+
+        /* Check for trailing `/', and `.' by itself. */
+        if ((start && !result[i])
+            || (result[i] == '.' && !result[i+1])) {
+            result[--i] = '\0';
+            break;
+        }
+
+        /* Check for `../', `./' or trailing `.' by itself. */
+        if (result[i] == '.') {
+            /* Handle `./'. */
+            if (result[i + 1] == '/') {
+                strcpy( result + i, result + i + 1 );
+                i = (start < 0) ? 0 : start;
+                continue;
+            }
+
+            /* Handle `../' or trailing `..' by itself. */
+            if (result[i + 1] == '.' &&
+                (result[i + 2] == '/' || !result[i + 2])) {
+                while (--start > -1 && result[start] != '/')
+                    ;
+                strcpy( result + start + 1, result + i + 2 );
+                i = (start < 0) ? 0 : start;
+                continue;
+            }
+        }
+    }
+
+    if (!*result) {
+        *result = stub_char;
+        result[1] = '\0';
+    }
+
+    return result;
+}
+
+/*
+ * Given a  string containing units of information separated  by colons,
+ * return the next one  pointed to by (P_INDEX), or NULL if there are no
+ * more.  Advance (P_INDEX) to the character after the colon.
+ */
+static char*
+extract_colon_unit( char* pzDir, char const *string, int *p_index )
+{
+    char*  pzDest = pzDir;
+    int    ix     = *p_index;
+
+    if (string == NULL)
+        return NULL;
+
+    if ((unsigned)ix >= strlen( string ))
+        return NULL;
+
+    {
+        char const* pzSrc = string + ix;
+
+        while (*pzSrc == ':')  pzSrc++;
+
+        for (;;) {
+            char ch = (*(pzDest++) = *(pzSrc++));
+            switch (ch) {
+            case ':':
+                pzDest[-1] = NUL;
+            case NUL:
+                goto copy_done;
+            }
+
+            if ((pzDest - pzDir) >= AG_PATH_MAX)
+                break;
+        } copy_done:;
+
+        ix = pzSrc - string;
+    }
+
+    if (*pzDir == NUL)
+        return NULL;
+
+    *p_index = ix;
+    return pzDir;
+}
+#endif /* __windows__ / __CYGWIN__ */
+#endif /* HAVE_PATHFIND */
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of compat/pathfind.c */
diff --git a/sntp/libopts/compat/snprintf.c b/sntp/libopts/compat/snprintf.c
new file mode 100644 (file)
index 0000000..fc91d63
--- /dev/null
@@ -0,0 +1,60 @@
+
+#ifndef HAVE_VPRINTF
+#include "choke-me: no vprintf and no snprintf"
+#endif
+
+#if defined(HAVE_STDARG_H)
+#  include <stdarg.h>
+#  ifndef   VA_START
+#    define VA_START(a, f)  va_start(a, f)
+#    define VA_END(a)       va_end(a)
+#  endif /* VA_START */
+#  define SNV_USING_STDARG_H
+
+#elif defined(HAVE_VARARGS_H)
+#  include <varargs.h>
+#  ifndef   VA_START
+#    define VA_START(a, f) va_start(a)
+#    define VA_END(a)    va_end(a)
+#  endif /* VA_START */
+#  undef  SNV_USING_STDARG_H
+
+#else
+#  include "must-have-stdarg-or-varargs"
+#endif
+
+static int
+snprintf(char *str, size_t n, char const *fmt, ...)
+{
+    va_list ap;
+    int rval;
+
+#ifdef VSPRINTF_CHARSTAR
+    char *rp;
+    VA_START(ap, fmt);
+    rp = vsprintf(str, fmt, ap);
+    VA_END(ap);
+    rval = strlen(rp);
+
+#else
+    VA_START(ap, fmt);
+    rval = vsprintf(str, fmt, ap);
+    VA_END(ap);
+#endif
+
+    if (rval > n) {
+        fprintf(stderr, "snprintf buffer overrun %d > %d\n", rval, (int)n);
+        abort();
+    }
+    return rval;
+}
+
+static int
+vsnprintf( char *str, size_t n, char const *fmt, va_list ap )
+{
+#ifdef VSPRINTF_CHARSTAR
+    return (strlen(vsprintf(str, fmt, ap)));
+#else
+    return (vsprintf(str, fmt, ap));
+#endif
+}
diff --git a/sntp/libopts/compat/strchr.c b/sntp/libopts/compat/strchr.c
new file mode 100644 (file)
index 0000000..413f999
--- /dev/null
@@ -0,0 +1,60 @@
+/*
+   SYNOPSIS
+       #include <string.h>
+
+       char *strchr(char const *s, int c);
+
+       char *strrchr(char const *s, int c);
+
+   DESCRIPTION
+       The  strchr() function returns a pointer to the first occurrence of the
+       character c in the string s.
+
+       The strrchr() function returns a pointer to the last occurrence of  the
+       character c in the string s.
+
+       Here  "character"  means "byte" - these functions do not work with wide
+       or multi-byte characters.
+
+   RETURN VALUE
+       The strchr() and strrchr() functions return a pointer  to  the  matched
+       character or NULL if the character is not found.
+
+   CONFORMING TO
+       SVID 3, POSIX, BSD 4.3, ISO 9899
+*/
+
+char*
+strchr( char const *s, int c)
+{
+    do {
+        if ((unsigned)*s == (unsigned)c)
+            return s;
+
+    } while (*(++s) != NUL);
+
+    return NULL;
+}
+
+char*
+strrchr( char const *s, int c)
+{
+    char const *e = s + strlen(s);
+
+    for (;;) {
+        if (--e < s)
+            break;
+
+        if ((unsigned)*e == (unsigned)c)
+            return e;
+    }
+    return NULL;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of compat/strsignal.c */
diff --git a/sntp/libopts/compat/strdup.c b/sntp/libopts/compat/strdup.c
new file mode 100644 (file)
index 0000000..e2933a8
--- /dev/null
@@ -0,0 +1,19 @@
+/*
+ * Platforms without strdup ?!?!?!
+ */
+
+static char *
+strdup( char const *s )
+{
+    char *cp;
+
+    if (s == NULL)
+        return NULL;
+
+    cp = (char *) AGALOC((unsigned) (strlen(s)+1), "strdup");
+
+    if (cp != NULL)
+        (void) strcpy(cp, s);
+
+    return cp;
+}
diff --git a/sntp/libopts/compat/windows-config.h b/sntp/libopts/compat/windows-config.h
new file mode 100644 (file)
index 0000000..2612980
--- /dev/null
@@ -0,0 +1,130 @@
+
+/*
+ * Time-stamp:        "2006-10-14 14:55:09 bkorb"
+ *             by: bkorb
+ * Last Committed:    $Date: 2007/04/28 22:19:23 $
+ */
+#ifndef WINDOWS_CONFIG_HACKERY
+#define WINDOWS_CONFIG_HACKERY 1
+
+/*
+ * The definitions below have been stolen from NTP's config.h for Windows.
+ * However, they may be kept here in order to keep libopts independent from
+ * the NTP project.
+ */
+#ifndef __windows__
+#  define __windows__ 4
+#endif
+
+/*
+ * Miscellaneous functions that Microsoft maps
+ * to other names
+ *
+ * #define inline __inline
+ * #define vsnprintf _vsnprintf
+ */
+#define snprintf _snprintf
+/*
+ * #define stricmp _stricmp
+ * #define strcasecmp _stricmp
+ * #define isascii __isascii
+ * #define finite _finite
+ * #define random      rand
+ * #define srandom     srand
+ */
+
+#define SIZEOF_INT   4
+#define SIZEOF_CHARP 4
+#define SIZEOF_LONG  4
+#define SIZEOF_SHORT 2
+
+typedef unsigned long uintptr_t;
+
+/*
+ * # define HAVE_NET_IF_H
+ * # define QSORT_USES_VOID_P
+ * # define HAVE_SETVBUF
+ * # define HAVE_VSPRINTF
+ * # define HAVE_SNPRINTF
+ * # define HAVE_VSNPRINTF
+ * # define HAVE_PROTOTYPES             /* from ntpq.mak * /
+ * # define HAVE_MEMMOVE
+ * # define HAVE_TERMIOS_H
+ * # define HAVE_ERRNO_H
+ * # define HAVE_STDARG_H
+ * # define HAVE_NO_NICE
+ * # define HAVE_MKTIME
+ * # define TIME_WITH_SYS_TIME
+ * # define HAVE_IO_COMPLETION_PORT
+ * # define ISC_PLATFORM_NEEDNTOP
+ * # define ISC_PLATFORM_NEEDPTON
+ * # define NEED_S_CHAR_TYPEDEF
+ * # define USE_PROTOTYPES              /* for ntp_types.h * /
+ *
+ * #define ULONG_CONST(a) a ## UL
+ */
+
+#define HAVE_LIMITS_H   1
+#define HAVE_STRDUP     1
+#define HAVE_STRCHR     1
+#define HAVE_FCNTL_H    1
+
+/*
+ * VS.NET's version of wspiapi.h has a bug in it
+ * where it assigns a value to a variable inside
+ * an if statement. It should be comparing them.
+ * We prevent inclusion since we are not using this
+ * code so we don't have to see the warning messages
+ */
+#ifndef _WSPIAPI_H_
+#define _WSPIAPI_H_
+#endif
+
+/* Prevent inclusion of winsock.h in windows.h */
+#ifndef _WINSOCKAPI_
+#define _WINSOCKAPI_
+#endif
+
+#ifndef __RPCASYNC_H__
+#define __RPCASYNC_H__
+#endif
+
+/* Include Windows headers */
+#include <windows.h>
+#include <winsock2.h>
+#include <limits.h>
+
+/*
+ * Compatibility declarations for Windows, assuming SYS_WINNT
+ * has been defined.
+ */
+#define strdup  _strdup
+#define stat    _stat       /* struct stat from <sys/stat.h> */
+#define unlink  _unlink
+#define fchmod( _x, _y );
+#define ssize_t SSIZE_T
+
+#include <io.h>
+#define open    _open
+#define close   _close
+#define read    _read
+#define write   _write
+#define lseek   _lseek
+#define pipe    _pipe
+#define dup2    _dup2
+
+#define O_RDWR     _O_RDWR
+#define O_RDONLY   _O_RDONLY
+#define O_EXCL     _O_EXCL
+
+#ifndef S_ISREG
+#  define S_IFREG _S_IFREG
+#  define       S_ISREG(mode)   (((mode) & S_IFREG) == S_IFREG)
+#endif
+
+#ifndef S_ISDIR
+#  define S_IFDIR _S_IFDIR
+#  define       S_ISDIR(mode)   (((mode) & S_IFDIR) == S_IFDIR)
+#endif
+
+#endif /* WINDOWS_CONFIG_HACKERY */
diff --git a/sntp/libopts/configfile.c b/sntp/libopts/configfile.c
new file mode 100644 (file)
index 0000000..e0b8a74
--- /dev/null
@@ -0,0 +1,1290 @@
+/*
+ *  $Id: configfile.c,v 1.21 2007/04/15 19:01:18 bkorb Exp $
+ *  Time-stamp:      "2007-04-15 11:22:46 bkorb"
+ *
+ *  configuration/rc/ini file handling.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+filePreset(
+    tOptions*     pOpts,
+    char const*   pzFileName,
+    int           direction );
+
+static char*
+handleComment( char* pzText );
+
+static char*
+handleConfig(
+    tOptions*     pOpts,
+    tOptState*    pOS,
+    char*         pzText,
+    int           direction );
+
+static char*
+handleDirective(
+    tOptions*     pOpts,
+    char*         pzText );
+
+static char*
+handleProgramSection(
+    tOptions*     pOpts,
+    char*         pzText );
+
+static char*
+handleStructure(
+    tOptions*     pOpts,
+    tOptState*    pOS,
+    char*         pzText,
+    int           direction );
+
+static char*
+parseKeyWordType(
+    tOptions*     pOpts,
+    char*         pzText,
+    tOptionValue* pType );
+
+static char*
+parseLoadMode(
+    char*               pzText,
+    tOptionLoadMode*    pMode );
+
+static char*
+parseSetMemType(
+    tOptions*     pOpts,
+    char*         pzText,
+    tOptionValue* pType );
+
+static char*
+parseValueType(
+    char*         pzText,
+    tOptionValue* pType );
+
+static char*
+skipUnknown( char* pzText );
+/* = = = END-STATIC-FORWARD = = = */
+
+
+/*=export_func  configFileLoad
+ *
+ * what:  parse a configuration file
+ * arg:   + char const*     + pzFile + the file to load +
+ *
+ * ret_type:  const tOptionValue*
+ * ret_desc:  An allocated, compound value structure
+ *
+ * doc:
+ *  This routine will load a named configuration file and parse the
+ *  text as a hierarchically valued option.  The option descriptor
+ *  created from an option definition file is not used via this interface.
+ *  The returned value is "named" with the input file name and is of
+ *  type "@code{OPARG_TYPE_HIERARCHY}".  It may be used in calls to
+ *  @code{optionGetValue()}, @code{optionNextValue()} and
+ *  @code{optionUnloadNested()}.
+ *
+ * err:
+ *  If the file cannot be loaded or processed, @code{NULL} is returned and
+ *  @var{errno} is set.  It may be set by a call to either @code{open(2)}
+ *  @code{mmap(2)} or other file system calls, or it may be:
+ *  @itemize @bullet
+ *  @item
+ *  @code{ENOENT} - the file was empty.
+ *  @item
+ *  @code{EINVAL} - the file contents are invalid -- not properly formed.
+ *  @item
+ *  @code{ENOMEM} - not enough memory to allocate the needed structures.
+ *  @end itemize
+=*/
+const tOptionValue*
+configFileLoad( char const* pzFile )
+{
+    tmap_info_t   cfgfile;
+    tOptionValue* pRes = NULL;
+    tOptionLoadMode save_mode = option_load_mode;
+
+    char* pzText =
+        text_mmap( pzFile, PROT_READ, MAP_PRIVATE, &cfgfile );
+
+    if (TEXT_MMAP_FAILED_ADDR(pzText))
+        return NULL; /* errno is set */
+
+    option_load_mode = OPTION_LOAD_COOKED;
+    pRes = optionLoadNested(pzText, pzFile, strlen(pzFile));
+
+    if (pRes == NULL) {
+        int err = errno;
+        text_munmap( &cfgfile );
+        errno = err;
+    } else
+        text_munmap( &cfgfile );
+
+    option_load_mode = save_mode;
+    return pRes;
+}
+
+
+/*=export_func  optionFindValue
+ *
+ * what:  find a hierarcicaly valued option instance
+ * arg:   + const tOptDesc* + pOptDesc + an option with a nested arg type +
+ * arg:   + char const*     + name     + name of value to find +
+ * arg:   + char const*     + value    + the matching value    +
+ *
+ * ret_type:  const tOptionValue*
+ * ret_desc:  a compound value structure
+ *
+ * doc:
+ *  This routine will find an entry in a nested value option or configurable.
+ *  It will search through the list and return a matching entry.
+ *
+ * err:
+ *  The returned result is NULL and errno is set:
+ *  @itemize @bullet
+ *  @item
+ *  @code{EINVAL} - the @code{pOptValue} does not point to a valid
+ *  hierarchical option value.
+ *  @item
+ *  @code{ENOENT} - no entry matched the given name.
+ *  @end itemize
+=*/
+const tOptionValue*
+optionFindValue( const tOptDesc* pOptDesc,
+                 char const* pzName, char const* pzVal )
+{
+    const tOptionValue* pRes = NULL;
+
+    if (  (pOptDesc == NULL)
+       || (OPTST_GET_ARGTYPE(pOptDesc->fOptState) != OPARG_TYPE_HIERARCHY))  {
+        errno = EINVAL;
+    }
+
+    else if (pOptDesc->optCookie == NULL) {
+        errno = ENOENT;
+    }
+
+    else do {
+        tArgList* pAL = pOptDesc->optCookie;
+        int    ct   = pAL->useCt;
+        void** ppOV = (void**)(pAL->apzArgs);
+
+        if (ct == 0) {
+            errno = ENOENT;
+            break;
+        }
+
+        if (pzName == NULL) {
+            pRes = (tOptionValue*)*ppOV;
+            break;
+        }
+
+        while (--ct >= 0) {
+            const tOptionValue* pOV = *(ppOV++);
+            const tOptionValue* pRV = optionGetValue( pOV, pzName );
+
+            if (pRV == NULL)
+                continue;
+
+            if (pzVal == NULL) {
+                pRes = pOV;
+                break;
+            }
+        }
+        if (pRes == NULL)
+            errno = ENOENT;
+    } while (0);
+
+    return pRes;
+}
+
+
+/*=export_func  optionFindNextValue
+ *
+ * what:  find a hierarcicaly valued option instance
+ * arg:   + const tOptDesc* + pOptDesc + an option with a nested arg type +
+ * arg:   + const tOptionValue* + pPrevVal + the last entry +
+ * arg:   + char const*     + name     + name of value to find +
+ * arg:   + char const*     + value    + the matching value    +
+ *
+ * ret_type:  const tOptionValue*
+ * ret_desc:  a compound value structure
+ *
+ * doc:
+ *  This routine will find the next entry in a nested value option or
+ *  configurable.  It will search through the list and return the next entry
+ *  that matches the criteria.
+ *
+ * err:
+ *  The returned result is NULL and errno is set:
+ *  @itemize @bullet
+ *  @item
+ *  @code{EINVAL} - the @code{pOptValue} does not point to a valid
+ *  hierarchical option value.
+ *  @item
+ *  @code{ENOENT} - no entry matched the given name.
+ *  @end itemize
+=*/
+const tOptionValue*
+optionFindNextValue( const tOptDesc* pOptDesc, const tOptionValue* pPrevVal,
+                 char const* pzName, char const* pzVal )
+{
+    int foundOldVal = 0;
+    tOptionValue* pRes = NULL;
+
+    if (  (pOptDesc == NULL)
+       || (OPTST_GET_ARGTYPE(pOptDesc->fOptState) != OPARG_TYPE_HIERARCHY))  {
+        errno = EINVAL;
+    }
+
+    else if (pOptDesc->optCookie == NULL) {
+        errno = ENOENT;
+    }
+
+    else do {
+        tArgList* pAL = pOptDesc->optCookie;
+        int    ct   = pAL->useCt;
+        void** ppOV = (void**)pAL->apzArgs;
+
+        if (ct == 0) {
+            errno = ENOENT;
+            break;
+        }
+
+        while (--ct >= 0) {
+            tOptionValue* pOV = *(ppOV++);
+            if (foundOldVal) {
+                pRes = pOV;
+                break;
+            }
+            if (pOV == pPrevVal)
+                foundOldVal = 1;
+        }
+        if (pRes == NULL)
+            errno = ENOENT;
+    } while (0);
+
+    return pRes;
+}
+
+
+/*=export_func  optionGetValue
+ *
+ * what:  get a specific value from a hierarcical list
+ * arg:   + const tOptionValue* + pOptValue + a hierarchcal value +
+ * arg:   + char const*   + valueName + name of value to get +
+ *
+ * ret_type:  const tOptionValue*
+ * ret_desc:  a compound value structure
+ *
+ * doc:
+ *  This routine will find an entry in a nested value option or configurable.
+ *  If "valueName" is NULL, then the first entry is returned.  Otherwise,
+ *  the first entry with a name that exactly matches the argument will be
+ *  returned.
+ *
+ * err:
+ *  The returned result is NULL and errno is set:
+ *  @itemize @bullet
+ *  @item
+ *  @code{EINVAL} - the @code{pOptValue} does not point to a valid
+ *  hierarchical option value.
+ *  @item
+ *  @code{ENOENT} - no entry matched the given name.
+ *  @end itemize
+=*/
+const tOptionValue*
+optionGetValue( const tOptionValue* pOld, char const* pzValName )
+{
+    tArgList*     pAL;
+    tOptionValue* pRes = NULL;
+
+    if ((pOld == NULL) || (pOld->valType != OPARG_TYPE_HIERARCHY)) {
+        errno = EINVAL;
+        return NULL;
+    }
+    pAL = pOld->v.nestVal;
+
+    if (pAL->useCt > 0) {
+        int    ct    = pAL->useCt;
+        void** papOV = (void**)(pAL->apzArgs);
+
+        if (pzValName == NULL) {
+            pRes = (tOptionValue*)*papOV;
+        }
+
+        else do {
+            tOptionValue* pOV = *(papOV++);
+            if (strcmp( pOV->pzName, pzValName ) == 0) {
+                pRes = pOV;
+                break;
+            }
+        } while (--ct > 0);
+    }
+    if (pRes == NULL)
+        errno = ENOENT;
+    return pRes;
+}
+
+
+/*=export_func  optionNextValue
+ *
+ * what:  get the next value from a hierarchical list
+ * arg:   + const tOptionValue* + pOptValue + a hierarchcal list value +
+ * arg:   + const tOptionValue* + pOldValue + a value from this list   +
+ *
+ * ret_type:  const tOptionValue*
+ * ret_desc:  a compound value structure
+ *
+ * doc:
+ *  This routine will return the next entry after the entry passed in.  At the
+ *  end of the list, NULL will be returned.  If the entry is not found on the
+ *  list, NULL will be returned and "@var{errno}" will be set to EINVAL.
+ *  The "@var{pOldValue}" must have been gotten from a prior call to this
+ *  routine or to "@code{opitonGetValue()}".
+ *
+ * err:
+ *  The returned result is NULL and errno is set:
+ *  @itemize @bullet
+ *  @item
+ *  @code{EINVAL} - the @code{pOptValue} does not point to a valid
+ *  hierarchical option value or @code{pOldValue} does not point to a
+ *  member of that option value.
+ *  @item
+ *  @code{ENOENT} - the supplied @code{pOldValue} pointed to the last entry.
+ *  @end itemize
+=*/
+tOptionValue const *
+optionNextValue(tOptionValue const * pOVList,tOptionValue const * pOldOV )
+{
+    tArgList*     pAL;
+    tOptionValue* pRes = NULL;
+    int           err  = EINVAL;
+
+    if ((pOVList == NULL) || (pOVList->valType != OPARG_TYPE_HIERARCHY)) {
+        errno = EINVAL;
+        return NULL;
+    }
+    pAL = pOVList->v.nestVal;
+    {
+        int    ct    = pAL->useCt;
+        void** papNV = (void**)(pAL->apzArgs);
+
+        while (ct-- > 0) {
+            tOptionValue* pNV = *(papNV++);
+            if (pNV == pOldOV) {
+                if (ct == 0) {
+                    err = ENOENT;
+
+                } else {
+                    err  = 0;
+                    pRes = (tOptionValue*)*papNV;
+                }
+                break;
+            }
+        }
+    }
+    if (err != 0)
+        errno = err;
+    return pRes;
+}
+
+
+/*  filePreset
+ *
+ *  Load a file containing presetting information (a configuration file).
+ */
+static void
+filePreset(
+    tOptions*     pOpts,
+    char const*   pzFileName,
+    int           direction )
+{
+    tmap_info_t   cfgfile;
+    tOptState     st = OPTSTATE_INITIALIZER(PRESET);
+    char*         pzFileText =
+        text_mmap( pzFileName, PROT_READ|PROT_WRITE, MAP_PRIVATE, &cfgfile );
+
+    if (TEXT_MMAP_FAILED_ADDR(pzFileText))
+        return;
+
+    if (direction == DIRECTION_CALLED) {
+        st.flags  = OPTST_DEFINED;
+        direction = DIRECTION_PROCESS;
+    }
+
+    /*
+     *  IF this is called via "optionProcess", then we are presetting.
+     *  This is the default and the PRESETTING bit will be set.
+     *  If this is called via "optionFileLoad", then the bit is not set
+     *  and we consider stuff set herein to be "set" by the client program.
+     */
+    if ((pOpts->fOptSet & OPTPROC_PRESETTING) == 0)
+        st.flags = OPTST_SET;
+
+    do  {
+        while (isspace( (int)*pzFileText ))  pzFileText++;
+
+        if (isalpha( (int)*pzFileText )) {
+            pzFileText = handleConfig( pOpts, &st, pzFileText, direction );
+
+        } else switch (*pzFileText) {
+        case '<':
+            if (isalpha( (int)pzFileText[1] ))
+                pzFileText = handleStructure(pOpts, &st, pzFileText, direction);
+
+            else switch (pzFileText[1]) {
+            case '?':
+                pzFileText = handleDirective( pOpts, pzFileText );
+                break;
+
+            case '!':
+                pzFileText = handleComment( pzFileText );
+                break;
+
+            case '/':
+                pzFileText = strchr( pzFileText+2, '>' );
+                if (pzFileText++ != NULL)
+                    break;
+
+            default:
+                goto all_done;
+            }
+            break;
+
+        case '[':
+            pzFileText = handleProgramSection( pOpts, pzFileText );
+            break;
+
+        case '#':
+            pzFileText = strchr( pzFileText+1, '\n' );
+            break;
+
+        default:
+            goto all_done; /* invalid format */
+        }
+    } while (pzFileText != NULL);
+
+ all_done:
+    text_munmap( &cfgfile );
+}
+
+
+/*  handleComment
+ *
+ *  "pzText" points to a "<!" sequence.
+ *  Theoretically, we should ensure that it begins with "<!--",
+ *  but actually I don't care that much.  It ends with "-->".
+ */
+static char*
+handleComment( char* pzText )
+{
+    char* pz = strstr( pzText, "-->" );
+    if (pz != NULL)
+        pz += 3;
+    return pz;
+}
+
+
+/*  handleConfig
+ *
+ *  "pzText" points to the start of some value name.
+ *  The end of the entry is the end of the line that is not preceded by
+ *  a backslash escape character.  The string value is always processed
+ *  in "cooked" mode.
+ */
+static char*
+handleConfig(
+    tOptions*     pOpts,
+    tOptState*    pOS,
+    char*         pzText,
+    int           direction )
+{
+    char* pzName = pzText++;
+    char* pzEnd  = strchr( pzText, '\n' );
+
+    if (pzEnd == NULL)
+        return pzText + strlen(pzText);
+
+    while (ISNAMECHAR( (int)*pzText ))  pzText++;
+    while (isspace( (int)*pzText )) pzText++;
+    if (pzText > pzEnd) {
+    name_only:
+        *pzEnd++ = NUL;
+        loadOptionLine( pOpts, pOS, pzName, direction, OPTION_LOAD_UNCOOKED );
+        return pzEnd;
+    }
+
+    /*
+     *  Either the first character after the name is a ':' or '=',
+     *  or else we must have skipped over white space.  Anything else
+     *  is an invalid format and we give up parsing the text.
+     */
+    if ((*pzText == '=') || (*pzText == ':')) {
+        while (isspace( (int)*++pzText ))   ;
+        if (pzText > pzEnd)
+            goto name_only;
+    } else if (! isspace((int)pzText[-1]))
+        return NULL;
+
+    /*
+     *  IF the value is continued, remove the backslash escape and push "pzEnd"
+     *  on to a newline *not* preceded by a backslash.
+     */
+    if (pzEnd[-1] == '\\') {
+        char* pcD = pzEnd-1;
+        char* pcS = pzEnd;
+
+        for (;;) {
+            char ch = *(pcS++);
+            switch (ch) {
+            case NUL:
+                pcS = NULL;
+
+            case '\n':
+                *pcD = NUL;
+                pzEnd = pcS;
+                goto copy_done;
+
+            case '\\':
+                if (*pcS == '\n') {
+                    ch = *(pcS++);
+                }
+                /* FALLTHROUGH */
+            default:
+                *(pcD++) = ch;
+            }
+        } copy_done:;
+
+    } else {
+        /*
+         *  The newline was not preceded by a backslash.  NUL it out
+         */
+        *(pzEnd++) = NUL;
+    }
+
+    /*
+     *  "pzName" points to what looks like text for one option/configurable.
+     *  It is NUL terminated.  Process it.
+     */
+    loadOptionLine( pOpts, pOS, pzName, direction, OPTION_LOAD_UNCOOKED );
+
+    return pzEnd;
+}
+
+
+/*  handleDirective
+ *
+ *  "pzText" points to a "<?" sequence.
+ *  For the moment, we only handle "<?program" directives.
+ */
+static char*
+handleDirective(
+    tOptions*     pOpts,
+    char*         pzText )
+{
+    char   ztitle[32] = "<?";
+    size_t title_len = strlen( zProg );
+    size_t name_len;
+
+    if (  (strncmp( pzText+2, zProg, title_len ) != 0)
+       || (! isspace( (int)pzText[title_len+2] )) )  {
+        pzText = strchr( pzText+2, '>' );
+        if (pzText != NULL)
+            pzText++;
+        return pzText;
+    }
+
+    name_len = strlen( pOpts->pzProgName );
+    strcpy( ztitle+2, zProg );
+    title_len += 2;
+
+    do  {
+        pzText += title_len;
+
+        if (isspace((int)*pzText)) {
+            while (isspace((int)*pzText))  pzText++;
+            if (  (strneqvcmp( pzText, pOpts->pzProgName, (int)name_len) == 0)
+               && (pzText[name_len] == '>'))  {
+                pzText += name_len + 1;
+                break;
+            }
+        }
+
+        pzText = strstr( pzText, ztitle );
+    } while (pzText != NULL);
+
+    return pzText;
+}
+
+
+/*  handleProgramSection
+ *
+ *  "pzText" points to a '[' character.
+ *  The "traditional" [PROG_NAME] segmentation of the config file.
+ *  Do not ever mix with the "<?program prog-name>" variation.
+ */
+static char*
+handleProgramSection(
+    tOptions*     pOpts,
+    char*         pzText )
+{
+    size_t len = strlen( pOpts->pzPROGNAME );
+    if (   (strncmp( pzText+1, pOpts->pzPROGNAME, len ) == 0)
+        && (pzText[len+1] == ']'))
+        return strchr( pzText + len + 2, '\n' );
+
+    if (len > 16)
+        return NULL;
+
+    {
+        char z[24];
+        sprintf( z, "[%s]", pOpts->pzPROGNAME );
+        pzText = strstr( pzText, z );
+    }
+
+    if (pzText != NULL)
+        pzText = strchr( pzText, '\n' );
+    return pzText;
+}
+
+
+/*  handleStructure
+ *
+ *  "pzText" points to a '<' character, followed by an alpha.
+ *  The end of the entry is either the "/>" following the name, or else a
+ *  "</name>" string.
+ */
+static char*
+handleStructure(
+    tOptions*     pOpts,
+    tOptState*    pOS,
+    char*         pzText,
+    int           direction )
+{
+    tOptionLoadMode mode = option_load_mode;
+    tOptionValue     valu;
+
+    char* pzName = ++pzText;
+    char* pzData;
+    char* pcNulPoint;
+
+    while (ISNAMECHAR( *pzText ))  pzText++;
+    pcNulPoint = pzText;
+    valu.valType = OPARG_TYPE_STRING;
+
+    switch (*pzText) {
+    case ' ':
+    case '\t':
+        pzText = parseAttributes( pOpts, pzText, &mode, &valu );
+        if (*pzText == '>')
+            break;
+        if (*pzText != '/')
+            return NULL;
+        /* FALLTHROUGH */
+
+    case '/':
+        if (pzText[1] != '>')
+            return NULL;
+        *pzText = NUL;
+        pzText += 2;
+        loadOptionLine( pOpts, pOS, pzName, direction, mode );
+        return pzText;
+
+    case '>':
+        break;
+
+    default:
+        pzText = strchr( pzText, '>');
+        if (pzText != NULL)
+            pzText++;
+        return pzText;
+    }
+
+    /*
+     *  If we are here, we have a value.  "pzText" points to a closing angle
+     *  bracket.  Separate the name from the value for a moment.
+     */
+    *pcNulPoint = NUL;
+    pzData = ++pzText;
+
+    /*
+     *  Find the end of the option text and NUL terminate it
+     */
+    {
+        char   z[64], *pz = z;
+        size_t len = strlen(pzName) + 4;
+        if (len > sizeof(z))
+            pz = AGALOC(len, "scan name");
+
+        sprintf( pz, "</%s>", pzName );
+        *pzText = ' ';
+        pzText = strstr( pzText, pz );
+        if (pz != z) AGFREE(pz);
+
+        if (pzText == NULL)
+            return pzText;
+
+        *pzText = NUL;
+
+        pzText += len-1;
+    }
+
+    /*
+     *  Rejoin the name and value for parsing by "loadOptionLine()".
+     *  Erase any attributes parsed by "parseAttributes()".
+     */
+    memset(pcNulPoint, ' ', pzData - pcNulPoint);
+
+    /*
+     *  "pzName" points to what looks like text for one option/configurable.
+     *  It is NUL terminated.  Process it.
+     */
+    loadOptionLine( pOpts, pOS, pzName, direction, mode );
+
+    return pzText;
+}
+
+
+/*  internalFileLoad
+ *
+ *  Load a configuration file.  This may be invoked either from
+ *  scanning the "homerc" list, or from a specific file request.
+ *  (see "optionFileLoad()", the implementation for --load-opts)
+ */
+LOCAL void
+internalFileLoad( tOptions* pOpts )
+{
+    int     idx;
+    int     inc = DIRECTION_PRESET;
+    char    zFileName[ AG_PATH_MAX+1 ];
+
+    if (pOpts->papzHomeList == NULL)
+        return;
+
+    /*
+     *  Find the last RC entry (highest priority entry)
+     */
+    for (idx = 0; pOpts->papzHomeList[ idx+1 ] != NULL; ++idx)  ;
+
+    /*
+     *  For every path in the home list, ...  *TWICE* We start at the last
+     *  (highest priority) entry, work our way down to the lowest priority,
+     *  handling the immediate options.
+     *  Then we go back up, doing the normal options.
+     */
+    for (;;) {
+        struct stat StatBuf;
+        cch_t*  pzPath;
+
+        /*
+         *  IF we've reached the bottom end, change direction
+         */
+        if (idx < 0) {
+            inc = DIRECTION_PROCESS;
+            idx = 0;
+        }
+
+        pzPath = pOpts->papzHomeList[ idx ];
+
+        /*
+         *  IF we've reached the top end, bail out
+         */
+        if (pzPath == NULL)
+            break;
+
+        idx += inc;
+
+        if (! optionMakePath( zFileName, (int)sizeof(zFileName),
+                              pzPath, pOpts->pzProgPath ))
+            continue;
+
+        /*
+         *  IF the file name we constructed is a directory,
+         *  THEN append the Resource Configuration file name
+         *  ELSE we must have the complete file name
+         */
+        if (stat( zFileName, &StatBuf ) != 0)
+            continue; /* bogus name - skip the home list entry */
+
+        if (S_ISDIR( StatBuf.st_mode )) {
+            size_t len = strlen( zFileName );
+            char* pz;
+
+            if (len + 1 + strlen( pOpts->pzRcName ) >= sizeof( zFileName ))
+                continue;
+
+            pz = zFileName + len;
+            if (pz[-1] != DIRCH)
+                *(pz++) = DIRCH;
+            strcpy( pz, pOpts->pzRcName );
+        }
+
+        filePreset( pOpts, zFileName, inc );
+
+        /*
+         *  IF we are now to skip config files AND we are presetting,
+         *  THEN change direction.  We must go the other way.
+         */
+        {
+            tOptDesc * pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts+1;
+            if (DISABLED_OPT(pOD) && PRESETTING(inc)) {
+                idx -= inc;  /* go back and reprocess current file */
+                inc =  DIRECTION_PROCESS;
+            }
+        }
+    } /* twice for every path in the home list, ... */
+}
+
+
+/*=export_func optionFileLoad
+ *
+ * what: Load the locatable config files, in order
+ *
+ * arg:  + tOptions*   + pOpts  + program options descriptor +
+ * arg:  + char const* + pzProg + program name +
+ *
+ * ret_type:  int
+ * ret_desc:  0 -> SUCCESS, -1 -> FAILURE
+ *
+ * doc:
+ *
+ * This function looks in all the specified directories for a configuration
+ * file ("rc" file or "ini" file) and processes any found twice.  The first
+ * time through, they are processed in reverse order (last file first).  At
+ * that time, only "immediate action" configurables are processed.  For
+ * example, if the last named file specifies not processing any more
+ * configuration files, then no more configuration files will be processed.
+ * Such an option in the @strong{first} named directory will have no effect.
+ *
+ * Once the immediate action configurables have been handled, then the
+ * directories are handled in normal, forward order.  In that way, later
+ * config files can override the settings of earlier config files.
+ *
+ * See the AutoOpts documentation for a thorough discussion of the
+ * config file format.
+ *
+ * Configuration files not found or not decipherable are simply ignored.
+ *
+ * err:  Returns the value, "-1" if the program options descriptor
+ *       is out of date or indecipherable.  Otherwise, the value "0" will
+ *       always be returned.
+=*/
+int
+optionFileLoad( tOptions* pOpts, char const* pzProgram )
+{
+    if (! SUCCESSFUL( validateOptionsStruct( pOpts, pzProgram )))
+        return -1;
+
+    pOpts->pzProgName = pzProgram;
+    internalFileLoad( pOpts );
+    return 0;
+}
+
+
+/*=export_func  optionLoadOpt
+ * private:
+ *
+ * what:  Load an option rc/ini file
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Processes the options found in the file named with
+ *  pOptDesc->optArg.argString.
+=*/
+void
+optionLoadOpt( tOptions* pOpts, tOptDesc* pOptDesc )
+{
+    /*
+     *  IF the option is not being disabled, THEN load the file.  There must
+     *  be a file.  (If it is being disabled, then the disablement processing
+     *  already took place.  It must be done to suppress preloading of ini/rc
+     *  files.)
+     */
+    if (! DISABLED_OPT( pOptDesc )) {
+        struct stat sb;
+        if (stat( pOptDesc->optArg.argString, &sb ) != 0) {
+            if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0)
+                return;
+
+            fprintf( stderr, zFSErrOptLoad, errno, strerror( errno ),
+                     pOptDesc->optArg.argString );
+            exit(EX_NOINPUT);
+            /* NOT REACHED */
+        }
+
+        if (! S_ISREG( sb.st_mode )) {
+            if ((pOpts->fOptSet & OPTPROC_ERRSTOP) == 0)
+                return;
+
+            fprintf( stderr, zNotFile, pOptDesc->optArg.argString );
+            exit(EX_NOINPUT);
+            /* NOT REACHED */
+        }
+
+        filePreset(pOpts, pOptDesc->optArg.argString, DIRECTION_CALLED);
+    }
+}
+
+
+/*  parseAttributes
+ *
+ *  Parse the various attributes of an XML-styled config file entry
+ */
+LOCAL char*
+parseAttributes(
+    tOptions*           pOpts,
+    char*               pzText,
+    tOptionLoadMode*    pMode,
+    tOptionValue*       pType )
+{
+    size_t lenLoadType = strlen( zLoadType );
+    size_t lenKeyWords = strlen( zKeyWords );
+    size_t lenSetMem   = strlen( zSetMembers );
+
+    do  {
+        switch (*pzText) {
+        case '/': pType->valType = OPARG_TYPE_NONE;
+        case '>': return pzText;
+
+        default:
+        case NUL: return NULL;
+
+        case ' ':
+        case '\t':
+        case '\n':
+        case '\f':
+        case '\r':
+        case '\v':
+            break;
+        }
+
+        while (isspace( (int)*++pzText ))   ;
+
+        if (strncmp( pzText, zLoadType, lenLoadType ) == 0) {
+            pzText = parseValueType( pzText+lenLoadType, pType );
+            continue;
+        }
+
+        if (strncmp( pzText, zKeyWords, lenKeyWords ) == 0) {
+            pzText = parseKeyWordType( pOpts, pzText+lenKeyWords, pType );
+            continue;
+        }
+
+        if (strncmp( pzText, zSetMembers, lenSetMem ) == 0) {
+            pzText = parseSetMemType( pOpts, pzText+lenSetMem, pType );
+            continue;
+        }
+
+        pzText = parseLoadMode( pzText, pMode );
+    } while (pzText != NULL);
+
+    return pzText;
+}
+
+
+/*  parseKeyWordType
+ *
+ *  "pzText" points to the character after "words=".
+ *  What should follow is a name of a keyword (enumeration) list.
+ */
+static char*
+parseKeyWordType(
+    tOptions*     pOpts,
+    char*         pzText,
+    tOptionValue* pType )
+{
+    return skipUnknown( pzText );
+}
+
+
+/*  parseLoadMode
+ *
+ *  "pzText" points to some name character.  We check for "cooked" or
+ *  "uncooked" or "keep".  This function should handle any attribute
+ *  that does not have an associated value.
+ */
+static char*
+parseLoadMode(
+    char*               pzText,
+    tOptionLoadMode*    pMode )
+{
+    {
+        size_t len = strlen(zLoadCooked);
+        if (strncmp( pzText, zLoadCooked, len ) == 0) {
+            if (  (pzText[len] == '>')
+               || (pzText[len] == '/')
+               || isspace((int)pzText[len])) {
+                *pMode = OPTION_LOAD_COOKED;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLoadUncooked);
+        if (strncmp( pzText, zLoadUncooked, len ) == 0) {
+            if (  (pzText[len] == '>')
+               || (pzText[len] == '/')
+               || isspace((int)pzText[len])) {
+                *pMode = OPTION_LOAD_UNCOOKED;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLoadKeep);
+        if (strncmp( pzText, zLoadKeep, len ) == 0) {
+            if (  (pzText[len] == '>')
+               || (pzText[len] == '/')
+               || isspace((int)pzText[len])) {
+                *pMode = OPTION_LOAD_KEEP;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+  unknown:
+    return skipUnknown( pzText );
+}
+
+
+/*  parseSetMemType
+ *
+ *  "pzText" points to the character after "members="
+ *  What should follow is a name of a "set membership".
+ *  A collection of bit flags.
+ */
+static char*
+parseSetMemType(
+    tOptions*     pOpts,
+    char*         pzText,
+    tOptionValue* pType )
+{
+    return skipUnknown( pzText );
+}
+
+
+/*  parseValueType
+ *
+ *  "pzText" points to the character after "type="
+ */
+static char*
+parseValueType(
+    char*         pzText,
+    tOptionValue* pType )
+{
+    {
+        size_t len = strlen(zLtypeString);
+        if (strncmp( pzText, zLtypeString, len ) == 0) {
+            if ((pzText[len] == '>') || isspace((int)pzText[len])) {
+                pType->valType = OPARG_TYPE_STRING;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLtypeInteger);
+        if (strncmp( pzText, zLtypeInteger, len ) == 0) {
+            if ((pzText[len] == '>') || isspace((int)pzText[len])) {
+                pType->valType = OPARG_TYPE_NUMERIC;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLtypeBool);
+        if (strncmp( pzText, zLtypeBool, len ) == 0) {
+            if ((pzText[len] == '>') || isspace(pzText[len])) {
+                pType->valType = OPARG_TYPE_BOOLEAN;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLtypeKeyword);
+        if (strncmp( pzText, zLtypeKeyword, len ) == 0) {
+            if ((pzText[len] == '>') || isspace((int)pzText[len])) {
+                pType->valType = OPARG_TYPE_ENUMERATION;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLtypeSetMembership);
+        if (strncmp( pzText, zLtypeSetMembership, len ) == 0) {
+            if ((pzText[len] == '>') || isspace((int)pzText[len])) {
+                pType->valType = OPARG_TYPE_MEMBERSHIP;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+    {
+        size_t len = strlen(zLtypeNest);
+        if (strncmp( pzText, zLtypeNest, len ) == 0) {
+            if ((pzText[len] == '>') || isspace((int)pzText[len])) {
+                pType->valType = OPARG_TYPE_HIERARCHY;
+                return pzText + len;
+            }
+            goto unknown;
+        }
+    }
+
+  unknown:
+    pType->valType = OPARG_TYPE_NONE;
+    return skipUnknown( pzText );
+}
+
+
+/*  skipUnknown
+ *
+ *  Skip over some unknown attribute
+ */
+static char*
+skipUnknown( char* pzText )
+{
+    for (;; pzText++) {
+        if (isspace( (int)*pzText ))  return pzText;
+        switch (*pzText) {
+        case NUL: return NULL;
+        case '/':
+        case '>': return pzText;
+        }
+    }
+}
+
+
+/*  validateOptionsStruct
+ *
+ *  Make sure the option descriptor is there and that we understand it.
+ *  This should be called from any user entry point where one needs to
+ *  worry about validity.  (Some entry points are free to assume that
+ *  the call is not the first to the library and, thus, that this has
+ *  already been called.)
+ */
+LOCAL tSuccess
+validateOptionsStruct( tOptions* pOpts, char const* pzProgram )
+{
+    if (pOpts == NULL) {
+        fputs( zAO_Bad, stderr );
+        exit( EX_CONFIG );
+    }
+
+    /*
+     *  IF the client has enabled translation and the translation procedure
+     *  is available, then go do it.
+     */
+    if (  ((pOpts->fOptSet & OPTPROC_TRANSLATE) != 0)
+       && (pOpts->pTransProc != 0) ) {
+        (*pOpts->pTransProc)();
+        pOpts->fOptSet &= ~OPTPROC_TRANSLATE;
+    }
+
+    /*
+     *  IF the struct version is not the current, and also
+     *     either too large (?!) or too small,
+     *  THEN emit error message and fail-exit
+     */
+    if (  ( pOpts->structVersion  != OPTIONS_STRUCT_VERSION  )
+       && (  (pOpts->structVersion > OPTIONS_STRUCT_VERSION  )
+          || (pOpts->structVersion < OPTIONS_MINIMUM_VERSION )
+       )  )  {
+
+        fprintf( stderr, zAO_Err, pOpts->origArgVect[0],
+                 NUM_TO_VER( pOpts->structVersion ));
+        if (pOpts->structVersion > OPTIONS_STRUCT_VERSION )
+            fputs( zAO_Big, stderr );
+        else
+            fputs( zAO_Sml, stderr );
+
+        return FAILURE;
+    }
+
+    /*
+     *  If the program name hasn't been set, then set the name and the path
+     *  and the set of equivalent characters.
+     */
+    if (pOpts->pzProgName == NULL) {
+        char const* pz = strrchr( pzProgram, DIRCH );
+
+        if (pz == NULL)
+             pOpts->pzProgName = pzProgram;
+        else pOpts->pzProgName = pz+1;
+
+        pOpts->pzProgPath = pzProgram;
+
+        /*
+         *  when comparing long names, these are equivalent
+         */
+        strequate( zSepChars );
+    }
+
+    return SUCCESS;
+}
+
+
+/**
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/configfile.c */
diff --git a/sntp/libopts/cook.c b/sntp/libopts/cook.c
new file mode 100644 (file)
index 0000000..bebd123
--- /dev/null
@@ -0,0 +1,354 @@
+
+/*
+ *  $Id: cook.c,v 4.10 2007/02/04 17:44:12 bkorb Exp $
+ *  Time-stamp:      "2006-09-24 15:21:02 bkorb"
+ *
+ *  This file contains the routines that deal with processing quoted strings
+ *  into an internal format.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+/* = = = END-STATIC-FORWARD = = = */
+
+/*=export_func  ao_string_cook_escape_char
+ * private:
+ *
+ * what:  escape-process a string fragment
+ * arg:   + char const*  + pzScan  + points to character after the escape +
+ * arg:   + char*        + pRes    + Where to put the result byte +
+ * arg:   + unsigned int + nl_ch   + replacement char if scanned char is \n +
+ *
+ * ret-type: unsigned int
+ * ret-desc: The number of bytes consumed processing the escaped character.
+ *
+ * doc:
+ *
+ *  This function converts "t" into "\t" and all your other favorite
+ *  escapes, including numeric ones:  hex and ocatal, too.
+ *  The returned result tells the caller how far to advance the
+ *  scan pointer (passed in).  The default is to just pass through the
+ *  escaped character and advance the scan by one.
+ *
+ *  Some applications need to keep an escaped newline, others need to
+ *  suppress it.  This is accomplished by supplying a '\n' replacement
+ *  character that is different from \n, if need be.  For example, use
+ *  0x7F and never emit a 0x7F.
+ *
+ * err:  @code{NULL} is returned if the string is mal-formed.
+=*/
+unsigned int
+ao_string_cook_escape_char( char const* pzIn, char* pRes, u_int nl )
+{
+    unsigned int  res = 1;
+
+    switch (*pRes = *pzIn++) {
+    case NUL:         /* NUL - end of input string */
+        return 0;
+    case '\r':
+        if (*pzIn != '\n')
+            return 1;
+        res++;
+        /* FALLTHROUGH */
+    case '\n':        /* NL  - emit newline        */
+        *pRes = (char)nl;
+        return res;
+
+    case 'a': *pRes = '\a'; break;
+    case 'b': *pRes = '\b'; break;
+    case 'f': *pRes = '\f'; break;
+    case 'n': *pRes = '\n'; break;
+    case 'r': *pRes = '\r'; break;
+    case 't': *pRes = '\t'; break;
+    case 'v': *pRes = '\v'; break;
+
+    case 'x':         /* HEX Escape       */
+        if (isxdigit( (int)*pzIn ))  {
+            unsigned int  val;
+            unsigned char ch = *pzIn++;
+
+            if ((ch >= 'A') && (ch <= 'F'))
+                val = 10 + (ch - 'A');
+            else if ((ch >= 'a') && (ch <= 'f'))
+                val = 10 + (ch - 'a');
+            else val = ch - '0';
+
+            ch = *pzIn;
+
+            if (! isxdigit( ch )) {
+                *pRes = val;
+                res   = 2;
+                break;
+            }
+            val <<= 4;
+            if ((ch >= 'A') && (ch <= 'F'))
+                val += 10 + (ch - 'A');
+            else if ((ch >= 'a') && (ch <= 'f'))
+                val += 10 + (ch - 'a');
+            else val += ch - '0';
+
+            res = 3;
+            *pRes = val;
+        }
+        break;
+
+    default:
+        /*
+         *  IF the character copied was an octal digit,
+         *  THEN set the output character to an octal value
+         */
+        if (isdigit( (int)*pRes ) && (*pRes < '8'))  {
+            unsigned int  val = *pRes - '0';
+            unsigned char ch  = *pzIn++;
+
+            /*
+             *  IF the second character is *not* an octal digit,
+             *  THEN save the value and bail
+             */
+            if ((ch < '0') || (ch > '7')) {
+                *pRes = val;
+                break;
+            }
+
+            val = (val<<3) + (ch - '0');
+            ch  = *pzIn;
+            res = 2;
+
+            /*
+             *  IF the THIRD character is *not* an octal digit,
+             *  THEN save the value and bail
+             */
+            if ((ch < '0') || (ch > '7')) {
+                *pRes = val;
+                break;
+            }
+
+            /*
+             *  IF the new value would not be too large,
+             *  THEN add on the third and last character value
+             */
+            if ((val<<3) < 0xFF) {
+                val = (val<<3) + (ch - '0');
+                res = 3;
+            }
+
+            *pRes = val;
+            break;
+        }
+    }
+
+    return res;
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  A quoted string has been found.
+ *  Find the end of it and compress any escape sequences.
+ */
+/*=export_func  ao_string_cook
+ * private:
+ *
+ * what:  concatenate and escape-process strings
+ * arg:   + char* + pzScan     + The *MODIFIABLE* input buffer +
+ * arg:   + int*  + pLineCt    + The (possibly NULL) pointer to a line count +
+ *
+ * ret-type: char*
+ * ret-desc: The address of the text following the processed strings.
+ *           The return value is NULL if the strings are ill-formed.
+ *
+ * doc:
+ *
+ *  A series of one or more quoted strings are concatenated together.
+ *  If they are quoted with double quotes (@code{"}), then backslash
+ *  escapes are processed per the C programming language.  If they are
+ *  single quote strings, then the backslashes are honored only when they
+ *  precede another backslash or a single quote character.
+ *
+ * err:  @code{NULL} is returned if the string(s) is/are mal-formed.
+=*/
+char*
+ao_string_cook( char* pzScan, int* pLineCt )
+{
+    int   l = 0;
+    char  q = *pzScan;
+
+    /*
+     *  It is a quoted string.  Process the escape sequence characters
+     *  (in the set "abfnrtv") and make sure we find a closing quote.
+     */
+    char* pzD = pzScan++;
+    char* pzS = pzScan;
+
+    if (pLineCt == NULL)
+        pLineCt = &l;
+
+    for (;;) {
+        /*
+         *  IF the next character is the quote character, THEN we may end the
+         *  string.  We end it unless the next non-blank character *after* the
+         *  string happens to also be a quote.  If it is, then we will change
+         *  our quote character to the new quote character and continue
+         *  condensing text.
+         */
+        while (*pzS == q) {
+            *pzD = NUL; /* This is probably the end of the line */
+            pzS++;
+
+        scan_for_quote:
+            while (isspace((int)*pzS))
+                if (*(pzS++) == '\n')
+                    (*pLineCt)++;
+
+            /*
+             *  IF the next character is a quote character,
+             *  THEN we will concatenate the strings.
+             */
+            switch (*pzS) {
+            case '"':
+            case '\'':
+                break;
+
+            case '/':
+                /*
+                 *  Allow for a comment embedded in the concatenated string.
+                 */
+                switch (pzS[1]) {
+                default:  return NULL;
+                case '/':
+                    /*
+                     *  Skip to end of line
+                     */
+                    pzS = strchr( pzS, '\n' );
+                    if (pzS == NULL)
+                        return NULL;
+                    (*pLineCt)++;
+                    break;
+
+                case '*':
+                {
+                    char* p = strstr( pzS+2, "*/" );
+                    /*
+                     *  Skip to terminating star slash
+                     */
+                    if (p == NULL)
+                        return NULL;
+                    while (pzS < p) {
+                        if (*(pzS++) == '\n')
+                            (*pLineCt)++;
+                    }
+
+                    pzS = p + 2;
+                }
+                }
+                goto scan_for_quote;
+
+            default:
+                /*
+                 *  The next non-whitespace character is not a quote.
+                 *  The series of quoted strings has come to an end.
+                 */
+                return pzS;
+            }
+
+            q = *(pzS++);  /* assign new quote character and advance scan */
+        }
+
+        /*
+         *  We are inside a quoted string.  Copy text.
+         */
+        switch (*(pzD++) = *(pzS++)) {
+        case NUL:
+            return NULL;
+
+        case '\n':
+            (*pLineCt)++;
+            break;
+
+        case '\\':
+            /*
+             *  IF we are escaping a new line,
+             *  THEN drop both the escape and the newline from
+             *       the result string.
+             */
+            if (*pzS == '\n') {
+                pzS++;
+                pzD--;
+                (*pLineCt)++;
+            }
+
+            /*
+             *  ELSE IF the quote character is '"' or '`',
+             *  THEN we do the full escape character processing
+             */
+            else if (q != '\'') {
+                int ct = ao_string_cook_escape_char( pzS, pzD-1, (u_int)'\n' );
+                if (ct == 0)
+                    return NULL;
+
+                pzS += ct;
+            }     /* if (q != '\'')                  */
+
+            /*
+             *  OTHERWISE, we only process "\\", "\'" and "\#" sequences.
+             *  The latter only to easily hide preprocessing directives.
+             */
+            else switch (*pzS) {
+            case '\\':
+            case '\'':
+            case '#':
+                pzD[-1] = *pzS++;
+            }
+        }     /* switch (*(pzD++) = *(pzS++))    */
+    }         /* for (;;)                        */
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/cook.c */
diff --git a/sntp/libopts/enumeration.c b/sntp/libopts/enumeration.c
new file mode 100644 (file)
index 0000000..67dd4f4
--- /dev/null
@@ -0,0 +1,498 @@
+
+/*
+ *  $Id: enumeration.c,v 4.17 2007/02/04 17:44:12 bkorb Exp $
+ * Time-stamp:      "2007-01-13 10:22:35 bkorb"
+ *
+ *   Automated Options Paged Usage module.
+ *
+ *  This routine will run run-on options through a pager so the
+ *  user may examine, print or edit them at their leisure.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+tSCC*  pz_enum_err_fmt;
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+enumError(
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC* const *  paz_names,
+    int           name_ct );
+
+static uintptr_t
+findName(
+    tCC*          pzName,
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC* const *  paz_names,
+    unsigned int  name_ct );
+/* = = = END-STATIC-FORWARD = = = */
+
+static void
+enumError(
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC* const *  paz_names,
+    int           name_ct )
+{
+    size_t max_len = 0;
+    size_t ttl_len = 0;
+
+    if (pOpts != NULL)
+        fprintf( option_usage_fp, pz_enum_err_fmt, pOpts->pzProgName,
+                 pOD->optArg.argString, pOD->pz_Name );
+
+    fprintf( option_usage_fp, zValidKeys, pOD->pz_Name );
+
+    if (**paz_names == 0x7F) {
+        paz_names++;
+        name_ct--;
+    }
+
+    /*
+     *  Figure out the maximum length of any name, plus the total length
+     *  of all the names.
+     */
+    {
+        tCC * const * paz = paz_names;
+        int   ct  = name_ct;
+
+        do  {
+            size_t len = strlen( *(paz++) ) + 1;
+            if (len > max_len)
+                max_len = len;
+            ttl_len += len;
+        } while (--ct > 0);
+    }
+
+    /*
+     *  IF any one entry is about 1/2 line or longer, print one per line
+     */
+    if (max_len > 35) {
+        do  {
+            fprintf( option_usage_fp, "  %s\n", *(paz_names++) );
+        } while (--name_ct > 0);
+    }
+
+    /*
+     *  ELSE IF they all fit on one line, then do so.
+     */
+    else if (ttl_len < 76) {
+        fputc( ' ', option_usage_fp );
+        do  {
+            fputc( ' ', option_usage_fp );
+            fputs( *(paz_names++), option_usage_fp );
+        } while (--name_ct > 0);
+        fputc( '\n', option_usage_fp );
+    }
+
+    /*
+     *  Otherwise, columnize the output
+     */
+    else {
+        int   ent_no = 0;
+        char  zFmt[16];  /* format for all-but-last entries on a line */
+
+        sprintf( zFmt, "%%-%ds", (int)max_len );
+        max_len = 78 / max_len; /* max_len is now max entries on a line */
+        fputs( "  ", option_usage_fp );
+
+        /*
+         *  Loop through all but the last entry
+         */
+        while (--name_ct > 0) {
+            if (++ent_no == max_len) {
+                /*
+                 *  Last entry on a line.  Start next line, too.
+                 */
+                fprintf( option_usage_fp, "%s\n  ", *(paz_names++) );
+                ent_no = 0;
+            }
+
+            else
+                fprintf( option_usage_fp, zFmt, *(paz_names++) );
+        }
+        fprintf( option_usage_fp, "%s\n", *paz_names );
+    }
+
+    /*
+     *  IF we do not have a pOpts pointer, then this output is being requested
+     *  by the usage procedure.  Let's not re-invoke it recursively.
+     */
+    if (pOpts != NULL)
+        (*(pOpts->pUsageProc))( pOpts, EXIT_FAILURE );
+    if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP)
+        fputs( zSetMemberSettings, option_usage_fp );
+}
+
+
+static uintptr_t
+findName(
+    tCC*          pzName,
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC* const *  paz_names,
+    unsigned int  name_ct )
+{
+    uintptr_t     res = name_ct;
+    size_t        len = strlen( (char*)pzName );
+    uintptr_t     idx;
+    /*
+     *  Look for an exact match, but remember any partial matches.
+     *  Multiple partial matches means we have an ambiguous match.
+     */
+    for (idx = 0; idx < name_ct; idx++) {
+        if (strncmp( (char*)paz_names[idx], (char*)pzName, len) == 0) {
+            if (paz_names[idx][len] == NUL)
+                return idx;  /* full match */
+
+            if (res != name_ct) {
+                pz_enum_err_fmt = zAmbigKey;
+                option_usage_fp = stderr;
+                enumError( pOpts, pOD, paz_names, (int)name_ct );
+            }
+            res = idx; /* save partial match */
+        }
+    }
+
+    /*
+     *  no partial match -> error
+     */
+    if (res == name_ct) {
+        pz_enum_err_fmt = zNoKey;
+        option_usage_fp = stderr;
+        enumError( pOpts, pOD, paz_names, (int)name_ct );
+    }
+
+    /*
+     *  Return the matching index as a char* pointer.
+     *  The result gets stashed in a char* pointer, so it will have to fit.
+     */
+    return res;
+}
+
+
+/*=export_func  optionKeywordName
+ * what:  Convert between enumeration values and strings
+ * private:
+ *
+ * arg:   tOptDesc*,     pOD,       enumeration option description
+ * arg:   unsigned int,  enum_val,  the enumeration value to map
+ *
+ * ret_type:  char const*
+ * ret_desc:  the enumeration name from const memory
+ *
+ * doc:   This converts an enumeration value into the matching string.
+=*/
+char const*
+optionKeywordName(
+    tOptDesc*     pOD,
+    unsigned int  enum_val )
+{
+    tOptDesc od;
+
+    od.optArg.argEnum = enum_val;
+    (*(pOD->pOptProc))( (void*)(2UL), &od );
+    return od.optArg.argString;
+}
+
+
+/*=export_func  optionEnumerationVal
+ * what:  Convert from a string to an enumeration value
+ * private:
+ *
+ * arg:   tOptions*,     pOpts,     the program options descriptor
+ * arg:   tOptDesc*,     pOD,       enumeration option description
+ * arg:   char const * const *,  paz_names, list of enumeration names
+ * arg:   unsigned int,  name_ct,   number of names in list
+ *
+ * ret_type:  uintptr_t
+ * ret_desc:  the enumeration value
+ *
+ * doc:   This converts the optArg.argString string from the option description
+ *        into the index corresponding to an entry in the name list.
+ *        This will match the generated enumeration value.
+ *        Full matches are always accepted.  Partial matches are accepted
+ *        if there is only one partial match.
+=*/
+uintptr_t
+optionEnumerationVal(
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC * const * paz_names,
+    unsigned int  name_ct )
+{
+    uintptr_t res = 0UL;
+
+    /*
+     *  IF the program option descriptor pointer is invalid,
+     *  then it is some sort of special request.
+     */
+    switch ((uintptr_t)pOpts) {
+    case 0UL:
+        /*
+         *  print the list of enumeration names.
+         */
+        enumError( pOpts, pOD, paz_names, (int)name_ct );
+        break;
+
+    case 1UL:
+    {
+        unsigned int ix = pOD->optArg.argEnum;
+        /*
+         *  print the name string.
+         */
+        if (ix >= name_ct)
+            printf( "INVALID-%d", ix );
+        else
+            fputs( paz_names[ ix ], stdout );
+
+        break;
+    }
+
+    case 2UL:
+    {
+        tSCC zInval[] = "*INVALID*";
+        unsigned int ix = pOD->optArg.argEnum;
+        /*
+         *  Replace the enumeration value with the name string.
+         */
+        if (ix >= name_ct)
+            return (uintptr_t)zInval;
+
+        res = (uintptr_t)paz_names[ ix ];
+        break;
+    }
+
+    default:
+        res = findName( pOD->optArg.argString, pOpts, pOD, paz_names, name_ct );
+
+        if (pOD->fOptState & OPTST_ALLOC_ARG) {
+            AGFREE(pOD->optArg.argString);
+            pOD->fOptState &= ~OPTST_ALLOC_ARG;
+            pOD->optArg.argString = NULL;
+        }
+    }
+
+    return res;
+}
+
+
+/*=export_func  optionSetMembers
+ * what:  Convert between bit flag values and strings
+ * private:
+ *
+ * arg:   tOptions*,     pOpts,     the program options descriptor
+ * arg:   tOptDesc*,     pOD,       enumeration option description
+ * arg:   char const * const *,
+ *                       paz_names, list of enumeration names
+ * arg:   unsigned int,  name_ct,   number of names in list
+ *
+ * doc:   This converts the optArg.argString string from the option description
+ *        into the index corresponding to an entry in the name list.
+ *        This will match the generated enumeration value.
+ *        Full matches are always accepted.  Partial matches are accepted
+ *        if there is only one partial match.
+=*/
+void
+optionSetMembers(
+    tOptions*     pOpts,
+    tOptDesc*     pOD,
+    tCC* const *  paz_names,
+    unsigned int  name_ct )
+{
+    /*
+     *  IF the program option descriptor pointer is invalid,
+     *  then it is some sort of special request.
+     */
+    switch ((uintptr_t)pOpts) {
+    case 0UL:
+        /*
+         *  print the list of enumeration names.
+         */
+        enumError( pOpts, pOD, paz_names, (int)name_ct );
+        return;
+
+    case 1UL:
+    {
+        /*
+         *  print the name string.
+         */
+        uintptr_t bits = (uintptr_t)pOD->optCookie;
+        uintptr_t res  = 0;
+        size_t    len  = 0;
+
+        while (bits != 0) {
+            if (bits & 1) {
+                if (len++ > 0) fputs( " | ", stdout );
+                fputs( paz_names[ res ], stdout );
+            }
+            if (++res >= name_ct) break;
+            bits >>= 1;
+        }
+        return;
+    }
+
+    case 2UL:
+    {
+        char*     pz;
+        uintptr_t bits = (uintptr_t)pOD->optCookie;
+        uintptr_t res  = 0;
+        size_t    len  = 0;
+
+        /*
+         *  Replace the enumeration value with the name string.
+         *  First, determine the needed length, then allocate and fill in.
+         */
+        while (bits != 0) {
+            if (bits & 1)
+                len += strlen( paz_names[ res ]) + 8;
+            if (++res >= name_ct) break;
+            bits >>= 1;
+        }
+
+        pOD->optArg.argString = pz = AGALOC( len, "enum name" );
+
+        /*
+         *  Start by clearing all the bits.  We want to turn off any defaults
+         *  because we will be restoring to current state, not adding to
+         *  the default set of bits.
+         */
+        strcpy( pz, "none" );
+        pz += 4;
+        bits = (uintptr_t)pOD->optCookie;
+        res = 0;
+        while (bits != 0) {
+            if (bits & 1) {
+                strcpy( pz, " + " );
+                strcpy( pz+3, paz_names[ res ]);
+                pz += strlen( paz_names[ res ]) + 3;
+            }
+            if (++res >= name_ct) break;
+            bits >>= 1;
+        }
+        return;
+    }
+
+    default:
+        break;
+    }
+
+    {
+        tCC*      pzArg = pOD->optArg.argString;
+        uintptr_t res;
+        if ((pzArg == NULL) || (*pzArg == NUL)) {
+            pOD->optCookie = (void*)0;
+            return;
+        }
+
+        res = (uintptr_t)pOD->optCookie;
+        for (;;) {
+            tSCC zSpn[] = " ,|+\t\r\f\n";
+            int  iv, len;
+
+            pzArg += strspn( pzArg, zSpn );
+            iv = (*pzArg == '!');
+            if (iv)
+                pzArg += strspn( pzArg+1, zSpn ) + 1;
+
+            len = strcspn( pzArg, zSpn );
+            if (len == 0)
+                break;
+
+            if ((len == 3) && (strncmp(pzArg, zAll, (size_t)3) == 0)) {
+                if (iv)
+                     res = 0;
+                else res = ~0UL;
+            }
+            else if ((len == 4) && (strncmp(pzArg, zNone, (size_t)4) == 0)) {
+                if (! iv)
+                    res = 0;
+            }
+            else do {
+                char* pz;
+                uintptr_t bit = strtoul( pzArg, &pz, 0 );
+
+                if (pz != pzArg + len) {
+                    char z[ AO_NAME_SIZE ];
+                    tCC* p;
+                    if (*pz != NUL) {
+                        if (len >= AO_NAME_LIMIT)
+                            break;
+                        strncpy( z, pzArg, (size_t)len );
+                        z[len] = NUL;
+                        p = z;
+                    } else {
+                        p = pzArg;
+                    }
+
+                    bit = 1UL << findName(p, pOpts, pOD, paz_names, name_ct);
+                }
+                if (iv)
+                     res &= ~bit;
+                else res |= bit;
+            } while (0);
+
+            if (pzArg[len] == NUL)
+                break;
+            pzArg += len + 1;
+        }
+        if (name_ct < (8 * sizeof( uintptr_t ))) {
+            res &= (1UL << name_ct) - 1UL;
+        }
+
+        pOD->optCookie = (void*)res;
+    }
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/enumeration.c */
diff --git a/sntp/libopts/environment.c b/sntp/libopts/environment.c
new file mode 100644 (file)
index 0000000..9fb1550
--- /dev/null
@@ -0,0 +1,279 @@
+
+/*
+ *  $Id: environment.c,v 4.13 2007/04/15 19:01:18 bkorb Exp $
+ * Time-stamp:      "2007-04-15 11:50:35 bkorb"
+ *
+ *  This file contains all of the routines that must be linked into
+ *  an executable to use the generated option processing.  The optional
+ *  routines are in separately compiled modules so that they will not
+ *  necessarily be linked in.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+checkEnvOpt(tOptState * os, char * env_name,
+            tOptions* pOpts, teEnvPresetType type);
+/* = = = END-STATIC-FORWARD = = = */
+
+/*
+ *  doPrognameEnv - check for preset values from the ${PROGNAME}
+ *  environment variable.  This is accomplished by parsing the text into
+ *  tokens, temporarily replacing the arg vector and calling
+ *  doImmediateOpts and/or doRegularOpts.
+ */
+LOCAL void
+doPrognameEnv( tOptions* pOpts, teEnvPresetType type )
+{
+    char const*   pczOptStr = getenv( pOpts->pzPROGNAME );
+    token_list_t* pTL;
+    int           sv_argc;
+    tAoUI         sv_flag;
+    char**        sv_argv;
+
+    /*
+     *  IF there is no such environment variable
+     *   *or* there is, but we are doing immediate opts and there are
+     *        no immediate opts to do (--help inside $PROGNAME is silly,
+     *        but --no-load-defs is not, so that is marked)
+     *  THEN bail out now.  (
+     */
+    if (  (pczOptStr == NULL)
+       || (  (type == ENV_IMM)
+          && ((pOpts->fOptSet & OPTPROC_HAS_IMMED) == 0)  )  )
+        return;
+
+    /*
+     *  Tokenize the string.  If there's nothing of interest, we'll bail
+     *  here immediately.
+     */
+    pTL = ao_string_tokenize( pczOptStr );
+    if (pTL == NULL)
+        return;
+
+    /*
+     *  Substitute our $PROGNAME argument list for the real one
+     */
+    sv_argc = pOpts->origArgCt;
+    sv_argv = pOpts->origArgVect;
+    sv_flag = pOpts->fOptSet;
+
+    /*
+     *  We add a bogus pointer to the start of the list.  The program name
+     *  has already been pulled from "argv", so it won't get dereferenced.
+     *  The option scanning code will skip the "program name" at the start
+     *  of this list of tokens, so we accommodate this way ....
+     */
+    pOpts->origArgVect = (char**)(pTL->tkn_list - 1);
+    pOpts->origArgCt   = pTL->tkn_ct   + 1;
+    pOpts->fOptSet    &= ~OPTPROC_ERRSTOP;
+
+    pOpts->curOptIdx   = 1;
+    pOpts->pzCurOpt    = NULL;
+
+    switch (type) {
+    case ENV_IMM:
+        /*
+         *  We know the OPTPROC_HAS_IMMED bit is set.
+         */
+        (void)doImmediateOpts( pOpts );
+        break;
+
+    case ENV_NON_IMM:
+        (void)doRegularOpts( pOpts );
+        break;
+
+    default:
+        /*
+         *  Only to immediate opts if the OPTPROC_HAS_IMMED bit is set.
+         */
+        if (pOpts->fOptSet & OPTPROC_HAS_IMMED) {
+            (void)doImmediateOpts( pOpts );
+            pOpts->curOptIdx = 1;
+            pOpts->pzCurOpt  = NULL;
+        }
+        (void)doRegularOpts( pOpts );
+        break;
+    }
+
+    /*
+     *  Free up the temporary arg vector and restore the original program args.
+     */
+    free( pTL );
+    pOpts->origArgVect = sv_argv;
+    pOpts->origArgCt   = sv_argc;
+    pOpts->fOptSet     = sv_flag;
+}
+
+static void
+checkEnvOpt(tOptState * os, char * env_name,
+            tOptions* pOpts, teEnvPresetType type)
+{
+    os->pzOptArg = getenv( env_name );
+    if (os->pzOptArg == NULL)
+        return;
+
+    os->flags    = OPTST_PRESET | OPTST_ALLOC_ARG | os->pOD->fOptState;
+    os->optType  = TOPT_UNDEFINED;
+
+    if (  (os->pOD->pz_DisablePfx != NULL)
+       && (streqvcmp( os->pzOptArg, os->pOD->pz_DisablePfx ) == 0)) {
+        os->flags |= OPTST_DISABLED;
+        os->pzOptArg = NULL;
+    }
+
+    switch (type) {
+    case ENV_IMM:
+        /*
+         *  Process only immediate actions
+         */
+        if (DO_IMMEDIATELY(os->flags))
+            break;
+        return;
+
+    case ENV_NON_IMM:
+        /*
+         *  Process only NON immediate actions
+         */
+        if (DO_NORMALLY(os->flags) || DO_SECOND_TIME(os->flags))
+            break;
+        return;
+
+    default: /* process everything */
+        break;
+    }
+
+    /*
+     *  Make sure the option value string is persistent and consistent.
+     *
+     *  The interpretation of the option value depends
+     *  on the type of value argument the option takes
+     */
+    if (os->pzOptArg != NULL) {
+        if (OPTST_GET_ARGTYPE(os->pOD->fOptState) == OPARG_TYPE_NONE) {
+            os->pzOptArg = NULL;
+        } else if (  (os->pOD->fOptState & OPTST_ARG_OPTIONAL)
+                     && (*os->pzOptArg == NUL)) {
+            os->pzOptArg = NULL;
+        } else if (*os->pzOptArg == NUL) {
+            os->pzOptArg = zNil;
+        } else {
+            AGDUPSTR( os->pzOptArg, os->pzOptArg, "option argument" );
+            os->flags |= OPTST_ALLOC_ARG;
+        }
+    }
+
+    handleOption( pOpts, os );
+}
+
+/*
+ *  doEnvPresets - check for preset values from the envrionment
+ *  This routine should process in all, immediate or normal modes....
+ */
+LOCAL void
+doEnvPresets( tOptions* pOpts, teEnvPresetType type )
+{
+    int        ct;
+    tOptState  st;
+    char*      pzFlagName;
+    size_t     spaceLeft;
+    char       zEnvName[ AO_NAME_SIZE ];
+
+    /*
+     *  Finally, see if we are to look at the environment
+     *  variables for initial values.
+     */
+    if ((pOpts->fOptSet & OPTPROC_ENVIRON) == 0)
+        return;
+
+    doPrognameEnv( pOpts, type );
+
+    ct  = pOpts->presetOptCt;
+    st.pOD = pOpts->pOptDesc;
+
+    pzFlagName = zEnvName
+        + snprintf( zEnvName, sizeof( zEnvName ), "%s_", pOpts->pzPROGNAME );
+    spaceLeft = AO_NAME_SIZE - (pzFlagName - zEnvName) - 1;
+
+    for (;ct-- > 0; st.pOD++) {
+        /*
+         *  If presetting is disallowed, then skip this entry
+         */
+        if (  ((st.pOD->fOptState & OPTST_NO_INIT) != 0)
+           || (st.pOD->optEquivIndex != NO_EQUIVALENT)  )
+            continue;
+
+        /*
+         *  IF there is no such environment variable,
+         *  THEN skip this entry, too.
+         */
+        if (strlen( st.pOD->pz_NAME ) >= spaceLeft)
+            continue;
+
+        /*
+         *  Set up the option state
+         */
+        strcpy( pzFlagName, st.pOD->pz_NAME );
+        checkEnvOpt(&st, zEnvName, pOpts, type);
+    }
+
+    /*
+     *  Special handling for ${PROGNAME_LOAD_OPTS}
+     */
+    if (pOpts->specOptIdx.save_opts != 0) {
+        st.pOD = pOpts->pOptDesc + pOpts->specOptIdx.save_opts + 1;
+        strcpy( pzFlagName, st.pOD->pz_NAME );
+        checkEnvOpt(&st, zEnvName, pOpts, type);
+    }
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/environment.c */
diff --git a/sntp/libopts/genshell.c b/sntp/libopts/genshell.c
new file mode 100644 (file)
index 0000000..de098a5
--- /dev/null
@@ -0,0 +1,354 @@
+/*   -*- buffer-read-only: t -*- vi: set ro:
+ *  
+ *  DO NOT EDIT THIS FILE   (genshell.c)
+ *  
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:35 PM PDT
+ *  From the definitions    genshell.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This source file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  genshellopt author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved
+ *
+ * genshellopt is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * genshellopt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with genshellopt.  If not, write to:
+ *     The Free Software Foundation, Inc.,
+ *     51 Franklin Street, Fifth Floor
+ *     Boston, MA  02110-1301, USA.
+ */
+
+
+#include <limits.h>
+
+#define OPTION_CODE_COMPILE 1
+#include "genshell.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+tSCC zCopyright[] =
+       "genshellopt copyright (c) 1999-2007 Bruce Korb, all rights reserved";
+tSCC zCopyrightNotice[] =
+       "genshellopt is free software; you can redistribute it and/or\n\
+modify it under the terms of the GNU Lesser General Public\n\
+License as published by the Free Software Foundation; either\n\
+version 2.1 of the License, or (at your option) any later version.\n\n\
+genshellopt is distributed in the hope that it will be useful,\n\
+but WITHOUT ANY WARRANTY; without even the implied warranty of\n\
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\n\
+Lesser General Public License for more details.\n\n\
+You should have received a copy of the GNU Lesser General Public\n\
+License along with genshellopt.  If not, write to:\n\
+\tThe Free Software Foundation, Inc.,\n\
+\t51 Franklin Street, Fifth Floor\n\
+\tBoston, MA  02110-1301, USA.";
+extern tUsageProc genshelloptUsage;
+
+#ifndef NULL
+#  define NULL 0
+#endif
+#ifndef EXIT_SUCCESS
+#  define  EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#  define  EXIT_FAILURE 1
+#endif
+/*
+ *  Script option description:
+ */
+tSCC    zScriptText[] =
+        "Output Script File";
+tSCC    zScript_NAME[]             = "SCRIPT";
+tSCC    zScript_Name[]             = "script";
+#define SCRIPT_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Shell option description:
+ */
+tSCC    zShellText[] =
+        "Shell name (follows \"#!\" magic)";
+tSCC    zShell_NAME[]              = "SHELL";
+tSCC    zNotShell_Name[]           = "no-shell";
+tSCC    zNotShell_Pfx[]            = "no";
+#define zShell_Name                  (zNotShell_Name + 3)
+#define SHELL_FLAGS       (OPTST_INITENABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+/*
+ *  Help/More_Help/Version option descriptions:
+ */
+tSCC zHelpText[]       = "Display usage information and exit";
+tSCC zHelp_Name[]      = "help";
+
+tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
+tSCC zMore_Help_Name[] = "more-help";
+
+tSCC zVersionText[]    = "Output version information and exit";
+tSCC zVersion_Name[]   = "version";
+/*
+ *  Declare option callback procedures
+ */
+extern tOptProc
+    optionPagedUsage, optionPrintVersion;
+static tOptProc
+    doUsageOpt;
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Genshellopt Option Descriptions.
+ */
+static tOptDesc optDesc[ OPTION_CT ] = {
+  {  /* entry idx, value */ 0, VALUE_OPT_SCRIPT,
+     /* equiv idx, value */ 0, VALUE_OPT_SCRIPT,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SCRIPT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zScriptText, zScript_NAME, zScript_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 1, VALUE_OPT_SHELL,
+     /* equiv idx, value */ 1, VALUE_OPT_SHELL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SHELL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zShellText, zShell_NAME, zShell_Name,
+     /* disablement strs */ zNotShell_Name, zNotShell_Pfx },
+
+#ifdef NO_OPTIONAL_OPT_ARGS
+#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
+#else
+#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
+                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
+#endif
+
+  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionPrintVersion,
+     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
+     /* disablement strs */ NULL, NULL },
+
+#undef VERSION_OPT_FLAGS
+
+
+  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doUsageOpt,
+     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ optionPagedUsage,
+     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
+     /* disablement strs */ NULL, NULL }
+};
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Genshellopt Option Environment
+ */
+tSCC   zPROGNAME[]   = "GENSHELLOPT";
+tSCC   zUsageTitle[] =
+"genshellopt - Generate Shell Option Processing Script - Ver. 1\n\
+USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
+#define zRcName     NULL
+#define apzHomeList NULL
+
+tSCC   zBugsAddr[]    = "autogen-users@lists.sourceforge.net";
+tSCC   zExplain[]     = "\n\
+Note that `shell' is only useful if the output file does not already\n\
+exist.  If it does, then the shell name and optional first argument\n\
+will be extracted from the script file.\n";
+tSCC    zDetail[]     = "\n\
+If the script file already exists and contains Automated Option Processing\n\
+text, the second line of the file through the ending tag will be replaced\n\
+by the newly generated text.  The first `#!' line will be regenerated.\n";
+tSCC    zFullVersion[] = GENSHELLOPT_FULL_VERSION;
+/* extracted from optcode.tpl near line 408 */
+
+#if defined(ENABLE_NLS)
+# define OPTPROC_BASE OPTPROC_TRANSLATE
+  static tOptionXlateProc translate_option_strings;
+#else
+# define OPTPROC_BASE OPTPROC_NONE
+# define translate_option_strings NULL
+#endif /* ENABLE_NLS */
+
+tOptions genshelloptOptions = {
+    OPTIONS_STRUCT_VERSION,
+    0, NULL,                    /* original argc + argv    */
+    ( OPTPROC_BASE
+    + OPTPROC_ERRSTOP
+    + OPTPROC_SHORTOPT
+    + OPTPROC_LONGOPT
+    + OPTPROC_NO_REQ_OPT
+    + OPTPROC_NEGATIONS
+    + OPTPROC_NO_ARGS ),
+    0, NULL,                    /* current option index, current option */
+    NULL,         NULL,         zPROGNAME,
+    zRcName,      zCopyright,   zCopyrightNotice,
+    zFullVersion, apzHomeList,  zUsageTitle,
+    zExplain,     zDetail,      optDesc,
+    zBugsAddr,                  /* address to send bugs to */
+    NULL, NULL,                 /* extensions/saved state  */
+    genshelloptUsage,       /* usage procedure */
+    translate_option_strings,   /* translation procedure */
+    /*
+     *  Indexes to special options
+     */
+    { INDEX_OPT_MORE_HELP,
+       0 /* no option state saving */,
+      NO_EQUIVALENT /* index of '-#' option */,
+      NO_EQUIVALENT /* index of default opt */
+    },
+    5 /* full option count */, 2 /* user option count */
+};
+
+/*
+ *  Create the static procedure(s) declared above.
+ */
+static void
+doUsageOpt(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    USAGE( EXIT_SUCCESS );
+}
+/* extracted from optcode.tpl near line 514 */
+
+#if ENABLE_NLS
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <autoopts/usage-txt.h>
+
+static char* AO_gettext( char const* pz );
+static void  coerce_it(void** s);
+
+static char*
+AO_gettext( char const* pz )
+{
+    char* pzRes;
+    if (pz == NULL)
+        return NULL;
+    pzRes = _(pz);
+    if (pzRes == pz)
+        return pzRes;
+    pzRes = strdup( pzRes );
+    if (pzRes == NULL) {
+        fputs( _("No memory for duping translated strings\n"), stderr );
+        exit( EXIT_FAILURE );
+    }
+    return pzRes;
+}
+
+static void coerce_it(void** s) { *s = AO_gettext(*s); }
+#define COERSION(_f) \
+  coerce_it((void*)&(genshelloptOptions._f))
+
+/*
+ *  This invokes the translation code (e.g. gettext(3)).
+ */
+static void
+translate_option_strings( void )
+{
+    /*
+     *  Guard against re-translation.  It won't work.  The strings will have
+     *  been changed by the first pass through this code.  One shot only.
+     */
+    if (option_usage_text.field_ct == 0)
+        return;
+    /*
+     *  Do the translations.  The first pointer follows the field count field.
+     *  The field count field is the size of a pointer.
+     */
+    {
+        char** ppz = (char**)(void*)&(option_usage_text);
+        int    ix  = option_usage_text.field_ct;
+
+        do {
+            ppz++;
+            *ppz = AO_gettext(*ppz);
+        } while (--ix > 0);
+    }
+    option_usage_text.field_ct = 0;
+
+    {
+        tOptDesc* pOD = genshelloptOptions.pOptDesc;
+        int       ix  = genshelloptOptions.optCt;
+
+        for (;;) {
+            pOD->pzText           = AO_gettext(pOD->pzText);
+            pOD->pz_NAME          = AO_gettext(pOD->pz_NAME);
+            pOD->pz_Name          = AO_gettext(pOD->pz_Name);
+            pOD->pz_DisableName   = AO_gettext(pOD->pz_DisableName);
+            pOD->pz_DisablePfx    = AO_gettext(pOD->pz_DisablePfx);
+            if (--ix <= 0)
+                break;
+            pOD++;
+        }
+    }
+    COERSION(pzCopyright);
+    COERSION(pzCopyNotice);
+    COERSION(pzFullVersion);
+    COERSION(pzUsageTitle);
+    COERSION(pzExplain);
+    COERSION(pzDetail);
+}
+
+#endif /* ENABLE_NLS */
+
+#ifdef  __cplusplus
+}
+#endif
+/* genshell.c ends here */
diff --git a/sntp/libopts/genshell.h b/sntp/libopts/genshell.h
new file mode 100644 (file)
index 0000000..b57677d
--- /dev/null
@@ -0,0 +1,149 @@
+/*   -*- buffer-read-only: t -*- vi: set ro:
+ *  
+ *  DO NOT EDIT THIS FILE   (genshell.h)
+ *  
+ *  It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:35 PM PDT
+ *  From the definitions    genshell.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This header file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  genshellopt author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * genshellopt copyright 1999-2007 Bruce Korb - all rights reserved
+ *
+ * genshellopt is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
+ * 
+ * genshellopt is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ * 
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with genshellopt.  If not, write to:
+ *     The Free Software Foundation, Inc.,
+ *     51 Franklin Street, Fifth Floor
+ *     Boston, MA  02110-1301, USA.
+ */
+/*
+ *  This file contains the programmatic interface to the Automated
+ *  Options generated for the genshellopt program.
+ *  These macros are documented in the AutoGen info file in the
+ *  "AutoOpts" chapter.  Please refer to that doc for usage help.
+ */
+#ifndef AUTOOPTS_GENSHELL_H_GUARD
+#define AUTOOPTS_GENSHELL_H_GUARD
+#include <autoopts/options.h>
+
+/*
+ *  Ensure that the library used for compiling this generated header is at
+ *  least as new as the version current when the header template was released
+ *  (not counting patch version increments).  Also ensure that the oldest
+ *  tolerable version is at least as old as what was current when the header
+ *  template was released.
+ */
+#define AO_TEMPLATE_VERSION 118784
+#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
+ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
+# error option template version mismatches autoopts/options.h header
+  Choke Me.
+#endif
+
+/*
+ *  Enumeration of each option:
+ */
+typedef enum {
+        INDEX_OPT_SCRIPT           =  0,
+        INDEX_OPT_SHELL            =  1,
+        INDEX_OPT_VERSION          = 2,
+        INDEX_OPT_HELP             = 3,
+        INDEX_OPT_MORE_HELP        = 4
+} teOptIndex;
+
+#define OPTION_CT    5
+#define GENSHELLOPT_VERSION       "1"
+#define GENSHELLOPT_FULL_VERSION  "genshellopt - Generate Shell Option Processing Script - Ver. 1"
+
+/*
+ *  Interface defines for all options.  Replace "n" with the UPPER_CASED
+ *  option name (as in the teOptIndex enumeration above).
+ *  e.g. HAVE_OPT( SCRIPT )
+ */
+#define         DESC(n) (genshelloptOptions.pOptDesc[INDEX_OPT_## n])
+#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
+#define      OPT_ARG(n) (DESC(n).optArg.argString)
+#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
+#define    COUNT_OPT(n) (DESC(n).optOccCt)
+#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
+#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
+#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
+#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
+#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
+#define    CLEAR_OPT(n) STMTS( \
+                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
+                if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
+                    DESC(n).fOptState |= OPTST_DISABLED; \
+                DESC(n).optCookie = NULL )
+
+/*
+ *  Interface defines for specific options.
+ */
+#define VALUE_OPT_SCRIPT         'o'
+#define VALUE_OPT_SHELL          's'
+
+#define VALUE_OPT_VERSION       'v'
+#define VALUE_OPT_HELP          '?'
+#define VALUE_OPT_MORE_HELP     '!'
+/*
+ *  Interface defines not associated with particular options
+ */
+#define ERRSKIP_OPTERR  STMTS( genshelloptOptions.fOptSet &= ~OPTPROC_ERRSTOP )
+#define ERRSTOP_OPTERR  STMTS( genshelloptOptions.fOptSet |= OPTPROC_ERRSTOP )
+#define RESTART_OPT(n)  STMTS( \
+                genshelloptOptions.curOptIdx = (n); \
+                genshelloptOptions.pzCurOpt  = NULL )
+#define START_OPT       RESTART_OPT(1)
+#define USAGE(c)        (*genshelloptOptions.pUsageProc)( &genshelloptOptions, c )
+/* extracted from opthead.tpl near line 360 */
+
+/* * * * * *
+ *
+ *  Declare the genshellopt option descriptor.
+ */
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+extern tOptions   genshelloptOptions;
+
+#ifndef _
+#  if ENABLE_NLS
+#    include <stdio.h>
+     static inline char* aoGetsText( char const* pz ) {
+         if (pz == NULL) return NULL;
+         return (char*)gettext( pz );
+     }
+#    define _(s)  aoGetsText(s)
+#  else  /* ENABLE_NLS */
+#    define _(s)  s
+#  endif /* ENABLE_NLS */
+#endif
+
+#ifdef  __cplusplus
+}
+#endif
+#endif /* AUTOOPTS_GENSHELL_H_GUARD */
+/* genshell.h ends here */
diff --git a/sntp/libopts/libopts.c b/sntp/libopts/libopts.c
new file mode 100644 (file)
index 0000000..feb7557
--- /dev/null
@@ -0,0 +1,30 @@
+#define AUTOOPTS_INTERNAL
+#include "compat/compat.h"
+#define LOCAL static
+#include "autoopts/options.h"
+#include "autoopts/usage-txt.h"
+#include "genshell.h"
+#include "autoopts.h"
+#include "proto.h"
+#include "autoopts.c"
+#include "boolean.c"
+#include "configfile.c"
+#include "cook.c"
+#include "enumeration.c"
+#include "environment.c"
+#include "genshell.c"
+#include "load.c"
+#include "makeshell.c"
+#include "nested.c"
+#include "numeric.c"
+#include "pgusage.c"
+#include "putshell.c"
+#include "restore.c"
+#include "save.c"
+#include "sort.c"
+#include "stack.c"
+#include "streqvcmp.c"
+#include "text_mmap.c"
+#include "tokenize.c"
+#include "usage.c"
+#include "version.c"
diff --git a/sntp/libopts/load.c b/sntp/libopts/load.c
new file mode 100644 (file)
index 0000000..eeeb125
--- /dev/null
@@ -0,0 +1,563 @@
+
+/*
+ *  $Id: load.c,v 4.20 2007/02/04 22:17:39 bkorb Exp $
+ *  Time-stamp:      "2007-02-04 11:54:57 bkorb"
+ *
+ *  This file contains the routines that deal with processing text strings
+ *  for options, either from a NUL-terminated string passed in or from an
+ *  rc/ini file.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+tOptionLoadMode option_load_mode = OPTION_LOAD_UNCOOKED;
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static ag_bool
+insertProgramPath(
+    char*   pzBuf,
+    int     bufSize,
+    tCC*    pzName,
+    tCC*    pzProgPath );
+
+static ag_bool
+insertEnvVal(
+    char*   pzBuf,
+    int     bufSize,
+    tCC*    pzName,
+    tCC*    pzProgPath );
+
+static char*
+assembleArgValue( char* pzTxt, tOptionLoadMode mode );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*=export_func  optionMakePath
+ * private:
+ *
+ * what:  translate and construct a path
+ * arg:   + char*       + pzBuf      + The result buffer +
+ * arg:   + int         + bufSize    + The size of this buffer +
+ * arg:   + char const* + pzName     + The input name +
+ * arg:   + char const* + pzProgPath + The full path of the current program +
+ *
+ * ret-type: ag_bool
+ * ret-desc: AG_TRUE if the name was handled, otherwise AG_FALSE.
+ *           If the name does not start with ``$'', then it is handled
+ *           simply by copying the input name to the output buffer and
+ *           resolving the name with either @code{canonicalize_file_name(3GLIBC)}
+ *           or @code{realpath(3C)}.
+ *
+ * doc:
+ *
+ *  This routine will copy the @code{pzName} input name into the @code{pzBuf}
+ *  output buffer, carefully not exceeding @code{bufSize} bytes.  If the
+ *  first character of the input name is a @code{'$'} character, then there
+ *  is special handling:
+ *  @*
+ *  @code{$$} is replaced with the directory name of the @code{pzProgPath},
+ *  searching @code{$PATH} if necessary.
+ *  @*
+ *  @code{$@} is replaced with the AutoGen package data installation directory
+ *  (aka @code{pkgdatadir}).
+ *  @*
+ *  @code{$NAME} is replaced by the contents of the @code{NAME} environment
+ *  variable.  If not found, the search fails.
+ *
+ *  Please note: both @code{$$} and @code{$NAME} must be at the start of the
+ *     @code{pzName} string and must either be the entire string or be followed
+ *     by the @code{'/'} (backslash on windows) character.
+ *
+ * err:  @code{AG_FALSE} is returned if:
+ *       @*
+ *       @bullet{} The input name exceeds @code{bufSize} bytes.
+ *       @*
+ *       @bullet{} @code{$$}, @code{$@@} or @code{$NAME} is not the full string
+ *                 and the next character is not '/'.
+ *       @*
+ *       @bullet{} libopts was built without PKGDATADIR defined and @code{$@@}
+ *                 was specified.
+ *       @*
+ *       @bullet{} @code{NAME} is not a known environment variable
+ *       @*
+ *       @bullet{} @code{canonicalize_file_name} or @code{realpath} return
+ *                 errors (cannot resolve the resulting path).
+=*/
+ag_bool
+optionMakePath(
+    char*   pzBuf,
+    int     bufSize,
+    tCC*    pzName,
+    tCC*    pzProgPath )
+{
+    size_t  name_len = strlen( pzName );
+
+#   ifndef PKGDATADIR
+#     define PKGDATADIR ""
+#   endif
+
+    tSCC    pkgdatadir[] = PKGDATADIR;
+
+    ag_bool res = AG_TRUE;
+
+    if (bufSize <= name_len)
+        return AG_FALSE;
+
+    /*
+     *  IF not an environment variable, just copy the data
+     */
+    if (*pzName != '$') {
+        tCC*  pzS = pzName;
+        char* pzD = pzBuf;
+        int   ct  = bufSize;
+
+        for (;;) {
+            if ( (*(pzD++) = *(pzS++)) == NUL)
+                break;
+            if (--ct <= 0)
+                return AG_FALSE;
+        }
+    }
+
+    /*
+     *  IF the name starts with "$$", then it must be "$$" or
+     *  it must start with "$$/".  In either event, replace the "$$"
+     *  with the path to the executable and append a "/" character.
+     */
+    else switch (pzName[1]) {
+    case NUL:
+        return AG_FALSE;
+
+    case '$':
+        res = insertProgramPath( pzBuf, bufSize, pzName, pzProgPath );
+        break;
+
+    case '@':
+        if (pkgdatadir[0] == NUL)
+            return AG_FALSE;
+
+        if (name_len + sizeof (pkgdatadir) > bufSize)
+            return AG_FALSE;
+
+        strcpy(pzBuf, pkgdatadir);
+        strcpy(pzBuf + sizeof(pkgdatadir) - 1, pzName + 2);
+        break;
+
+    default:
+        res = insertEnvVal( pzBuf, bufSize, pzName, pzProgPath );
+    }
+
+    if (! res)
+        return AG_FALSE;
+
+#if defined(HAVE_CANONICALIZE_FILE_NAME)
+    {
+        char* pz = canonicalize_file_name(pzBuf);
+        if (pz == NULL)
+            return AG_FALSE;
+        if (strlen(pz) < bufSize)
+            strcpy(pzBuf, pz);
+        free(pz);
+    }
+
+#elif defined(HAVE_REALPATH)
+    {
+        char z[ PATH_MAX+1 ];
+
+        if (realpath( pzBuf, z ) == NULL)
+            return AG_FALSE;
+
+        if (strlen(z) < bufSize)
+            strcpy( pzBuf, z );
+    }
+#endif
+
+    return AG_TRUE;
+}
+
+
+static ag_bool
+insertProgramPath(
+    char*   pzBuf,
+    int     bufSize,
+    tCC*    pzName,
+    tCC*    pzProgPath )
+{
+    tCC*    pzPath;
+    tCC*    pz;
+    int     skip = 2;
+
+    switch (pzName[2]) {
+    case DIRCH:
+        skip = 3;
+    case NUL:
+        break;
+    default:
+        return AG_FALSE;
+    }
+
+    /*
+     *  See if the path is included in the program name.
+     *  If it is, we're done.  Otherwise, we have to hunt
+     *  for the program using "pathfind".
+     */
+    if (strchr( pzProgPath, DIRCH ) != NULL)
+        pzPath = pzProgPath;
+    else {
+        pzPath = pathfind( getenv( "PATH" ), (char*)pzProgPath, "rx" );
+
+        if (pzPath == NULL)
+            return AG_FALSE;
+    }
+
+    pz = strrchr( pzPath, DIRCH );
+
+    /*
+     *  IF we cannot find a directory name separator,
+     *  THEN we do not have a path name to our executable file.
+     */
+    if (pz == NULL)
+        return AG_FALSE;
+
+    pzName += skip;
+
+    /*
+     *  Concatenate the file name to the end of the executable path.
+     *  The result may be either a file or a directory.
+     */
+    if ((pz - pzPath)+1 + strlen(pzName) >= bufSize)
+        return AG_FALSE;
+
+    memcpy( pzBuf, pzPath, (size_t)((pz - pzPath)+1) );
+    strcpy( pzBuf + (pz - pzPath) + 1, pzName );
+
+    /*
+     *  If the "pzPath" path was gotten from "pathfind()", then it was
+     *  allocated and we need to deallocate it.
+     */
+    if (pzPath != pzProgPath)
+        free( (void*)pzPath );
+    return AG_TRUE;
+}
+
+
+static ag_bool
+insertEnvVal(
+    char*   pzBuf,
+    int     bufSize,
+    tCC*    pzName,
+    tCC*    pzProgPath )
+{
+    char* pzDir = pzBuf;
+
+    for (;;) {
+        int ch = (int)*++pzName;
+        if (! ISNAMECHAR( ch ))
+            break;
+        *(pzDir++) = (char)ch;
+    }
+
+    if (pzDir == pzBuf)
+        return AG_FALSE;
+
+    *pzDir = NUL;
+
+    pzDir = getenv( pzBuf );
+
+    /*
+     *  Environment value not found -- skip the home list entry
+     */
+    if (pzDir == NULL)
+        return AG_FALSE;
+
+    if (strlen( pzDir ) + 1 + strlen( pzName ) >= bufSize)
+        return AG_FALSE;
+
+    sprintf( pzBuf, "%s%s", pzDir, pzName );
+    return AG_TRUE;
+}
+
+
+LOCAL void
+mungeString( char* pzTxt, tOptionLoadMode mode )
+{
+    char* pzE;
+
+    if (mode == OPTION_LOAD_KEEP)
+        return;
+
+    if (isspace( (int)*pzTxt )) {
+        char* pzS = pzTxt;
+        char* pzD = pzTxt;
+        while (isspace( (int)*++pzS ))  ;
+        while ((*(pzD++) = *(pzS++)) != NUL)   ;
+        pzE = pzD-1;
+    } else
+        pzE = pzTxt + strlen( pzTxt );
+
+    while ((pzE > pzTxt) && isspace( (int)pzE[-1] ))  pzE--;
+    *pzE = NUL;
+
+    if (mode == OPTION_LOAD_UNCOOKED)
+        return;
+
+    switch (*pzTxt) {
+    default: return;
+    case '"':
+    case '\'': break;
+    }
+
+    switch (pzE[-1]) {
+    default: return;
+    case '"':
+    case '\'': break;
+    }
+
+    (void)ao_string_cook( pzTxt, NULL );
+}
+
+
+static char*
+assembleArgValue( char* pzTxt, tOptionLoadMode mode )
+{
+    tSCC zBrk[] = " \t:=";
+    char* pzEnd = strpbrk( pzTxt, zBrk );
+    int   space_break;
+
+    /*
+     *  Not having an argument to a configurable name is okay.
+     */
+    if (pzEnd == NULL)
+        return pzTxt + strlen(pzTxt);
+
+    /*
+     *  If we are keeping all whitespace, then the  modevalue starts with the
+     *  character that follows the end of the configurable name, regardless
+     *  of which character caused it.
+     */
+    if (mode == OPTION_LOAD_KEEP) {
+        *(pzEnd++) = NUL;
+        return pzEnd;
+    }
+
+    /*
+     *  If the name ended on a white space character, remember that
+     *  because we'll have to skip over an immediately following ':' or '='
+     *  (and the white space following *that*).
+     */
+    space_break = isspace((int)*pzEnd);
+    *(pzEnd++) = NUL;
+    while (isspace((int)*pzEnd))  pzEnd++;
+    if (space_break && ((*pzEnd == ':') || (*pzEnd == '=')))
+        while (isspace((int)*++pzEnd))  ;
+
+    return pzEnd;
+}
+
+
+/*
+ *  Load an option from a block of text.  The text must start with the
+ *  configurable/option name and be followed by its associated value.
+ *  That value may be processed in any of several ways.  See "tOptionLoadMode"
+ *  in autoopts.h.
+ */
+LOCAL void
+loadOptionLine(
+    tOptions*   pOpts,
+    tOptState*  pOS,
+    char*       pzLine,
+    tDirection  direction,
+    tOptionLoadMode   load_mode )
+{
+    while (isspace( (int)*pzLine ))  pzLine++;
+
+    {
+        char* pzArg = assembleArgValue( pzLine, load_mode );
+
+        if (! SUCCESSFUL( longOptionFind( pOpts, pzLine, pOS )))
+            return;
+        if (pOS->flags & OPTST_NO_INIT)
+            return;
+        pOS->pzOptArg = pzArg;
+    }
+
+    switch (pOS->flags & (OPTST_IMM|OPTST_DISABLE_IMM)) {
+    case 0:
+        /*
+         *  The selected option has no immediate action.
+         *  THEREFORE, if the direction is PRESETTING
+         *  THEN we skip this option.
+         */
+        if (PRESETTING(direction))
+            return;
+        break;
+
+    case OPTST_IMM:
+        if (PRESETTING(direction)) {
+            /*
+             *  We are in the presetting direction with an option we handle
+             *  immediately for enablement, but normally for disablement.
+             *  Therefore, skip if disabled.
+             */
+            if ((pOS->flags & OPTST_DISABLED) == 0)
+                return;
+        } else {
+            /*
+             *  We are in the processing direction with an option we handle
+             *  immediately for enablement, but normally for disablement.
+             *  Therefore, skip if NOT disabled.
+             */
+            if ((pOS->flags & OPTST_DISABLED) != 0)
+                return;
+        }
+        break;
+
+    case OPTST_DISABLE_IMM:
+        if (PRESETTING(direction)) {
+            /*
+             *  We are in the presetting direction with an option we handle
+             *  immediately for disablement, but normally for disablement.
+             *  Therefore, skip if NOT disabled.
+             */
+            if ((pOS->flags & OPTST_DISABLED) != 0)
+                return;
+        } else {
+            /*
+             *  We are in the processing direction with an option we handle
+             *  immediately for disablement, but normally for disablement.
+             *  Therefore, skip if disabled.
+             */
+            if ((pOS->flags & OPTST_DISABLED) == 0)
+                return;
+        }
+        break;
+
+    case OPTST_IMM|OPTST_DISABLE_IMM:
+        /*
+         *  The selected option is always for immediate action.
+         *  THEREFORE, if the direction is PROCESSING
+         *  THEN we skip this option.
+         */
+        if (PROCESSING(direction))
+            return;
+        break;
+    }
+
+    /*
+     *  Fix up the args.
+     */
+    if (OPTST_GET_ARGTYPE(pOS->pOD->fOptState) == OPARG_TYPE_NONE) {
+        if (*pOS->pzOptArg != NUL)
+            return;
+        pOS->pzOptArg = NULL;
+
+    } else if (pOS->pOD->fOptState & OPTST_ARG_OPTIONAL) {
+        if (*pOS->pzOptArg == NUL)
+             pOS->pzOptArg = NULL;
+        else {
+            AGDUPSTR( pOS->pzOptArg, pOS->pzOptArg, "option argument" );
+            pOS->flags |= OPTST_ALLOC_ARG;
+        }
+
+    } else {
+        if (*pOS->pzOptArg == NUL)
+             pOS->pzOptArg = zNil;
+        else {
+            AGDUPSTR( pOS->pzOptArg, pOS->pzOptArg, "option argument" );
+            pOS->flags |= OPTST_ALLOC_ARG;
+        }
+    }
+
+    {
+        tOptionLoadMode sv = option_load_mode;
+        option_load_mode = load_mode;
+        handleOption( pOpts, pOS );
+        option_load_mode = sv;
+    }
+}
+
+
+/*=export_func  optionLoadLine
+ *
+ * what:  process a string for an option name and value
+ *
+ * arg:   tOptions*,   pOpts,  program options descriptor
+ * arg:   char const*, pzLine, NUL-terminated text
+ *
+ * doc:
+ *
+ *  This is a client program callable routine for setting options from, for
+ *  example, the contents of a file that they read in.  Only one option may
+ *  appear in the text.  It will be treated as a normal (non-preset) option.
+ *
+ *  When passed a pointer to the option struct and a string, it will find
+ *  the option named by the first token on the string and set the option
+ *  argument to the remainder of the string.  The caller must NUL terminate
+ *  the string.  Any embedded new lines will be included in the option
+ *  argument.  If the input looks like one or more quoted strings, then the
+ *  input will be "cooked".  The "cooking" is identical to the string
+ *  formation used in AutoGen definition files (@pxref{basic expression}),
+ *  except that you may not use backquotes.
+ *
+ * err:   Invalid options are silently ignored.  Invalid option arguments
+ *        will cause a warning to print, but the function should return.
+=*/
+void
+optionLoadLine(
+    tOptions*  pOpts,
+    tCC*       pzLine )
+{
+    tOptState st = OPTSTATE_INITIALIZER(SET);
+    char* pz;
+    AGDUPSTR( pz, pzLine, "user option line" );
+    loadOptionLine( pOpts, &st, pz, DIRECTION_PROCESS, OPTION_LOAD_COOKED );
+    AGFREE( pz );
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/load.c */
diff --git a/sntp/libopts/m4/libopts.m4 b/sntp/libopts/m4/libopts.m4
new file mode 100644 (file)
index 0000000..adc3235
--- /dev/null
@@ -0,0 +1,509 @@
+dnl  -*- buffer-read-only: t -*- vi: set ro:
+dnl 
+dnl DO NOT EDIT THIS FILE   (libopts.m4)
+dnl 
+dnl It has been AutoGen-ed  Saturday May  5, 2007 at 12:02:37 PM PDT
+dnl From the definitions    libopts.def
+dnl and the template file   conftest.tpl
+dnl
+dnl do always before generated macros:
+dnl
+AC_DEFUN([INVOKE_LIBOPTS_MACROS_FIRST],[
+[if test X${INVOKE_LIBOPTS_MACROS_FIRST_done} != Xyes ; then]
+  # =================
+  # AC_HEADER_STDC
+  # =================
+  AC_HEADER_STDC
+  # =================
+  # AC_HEADER_DIRENT
+  # =================
+  AC_HEADER_DIRENT
+  
+  # =================
+  # AC_CHECK_HEADERS
+  # =================
+  AC_CHECK_HEADERS(dlfcn.h errno.h fcntl.h libgen.h memory.h netinet/in.h \
+    setjmp.h sys/mman.h sys/param.h sys/poll.h sys/procset.h sys/select.h \
+    sys/socket.h sys/stropts.h sys/time.h sys/un.h sys/wait.h unistd.h    \
+    utime.h sysexits.h)
+  
+  # --------------------------------------------
+  # Verify certain entries from AC_CHECK_HEADERS
+  # --------------------------------------------
+  [for f in sys_types sys_mman sys_param sys_stat sys_wait \
+           string errno stdlib memory setjmp
+  do eval as_ac_var=\${ac_cv_header_${f}_h+set}
+     test "${as_ac_var}" = set] || \
+       AC_MSG_ERROR([You must have ${f}.h on your system])
+  done
+  
+  # ================================================
+  # AC_CHECK_HEADERS: stdarg.h is present define HAVE_STDARG_H, otherwise
+  # if varargs.h is present define HAVE_VARARGS_H.
+  # ================================================
+  AC_CHECK_HEADERS(stdarg.h varargs.h, break)
+  [if test `eval echo '${'$as_ac_Header'}'` != yes; then]
+    AC_MSG_ERROR([You must have stdarg.h or varargs.h on your system])
+  fi
+  
+  # ================================================
+  # Similarly for the string.h and strings.h headers
+  # ================================================
+  AC_CHECK_HEADERS(string.h strings.h, break)
+  [if test `eval echo '${'$as_ac_Header'}'` != yes; then]
+    AC_MSG_ERROR([You must have string.h or strings.h on your system])
+  fi
+  
+  # =====================
+  # ...and limits headers
+  # =====================
+  AC_CHECK_HEADERS(limits.h sys/limits.h values.h, break)
+  [if test `eval echo '${'$as_ac_Header'}'` != yes; then]
+    AC_MSG_ERROR([You must have one of limits.h, sys/limits.h or values.h])
+  fi
+  
+  # ========================
+  # ...and int types headers
+  # ========================
+  AC_CHECK_HEADERS(stdint.h inttypes.h, break)
+  AC_CHECK_TYPES([int8_t, uint8_t, int16_t, uint16_t, int32_t, uint32_t,
+     intptr_t, uint_t])
+  
+  # ====================
+  # uintptr type & sizes
+  # ====================
+  AC_CHECK_TYPES([uintptr_t], ,
+         [AC_DEFINE([uintptr_t], unsigned long,
+                    [Alternate uintptr_t for systems without it.])])
+  AC_CHECK_SIZEOF(char*, 4)
+  AC_CHECK_SIZEOF(int,   4)
+  AC_CHECK_SIZEOF(long,  4)
+  AC_CHECK_SIZEOF(short, 2)
+  
+  # ----------------------------------------------------------------------
+  # AC_CHECK_LIB for SVR4 libgen, and use it if it defines pathfind.
+  # ----------------------------------------------------------------------
+  AC_CHECK_LIB(gen, pathfind)
+  AC_FUNC_VPRINTF
+  AC_CHECK_FUNCS([mmap canonicalize_file_name snprintf strdup strchr strrchr])
+[  INVOKE_LIBOPTS_MACROS_FIRST_done=yes
+fi]])
+
+dnl
+dnl @synopsis  INVOKE_LIBOPTS_MACROS
+dnl
+dnl  This macro will invoke the AutoConf macros specified in libopts.def
+dnl  that have not been disabled with "omit-invocation".
+dnl
+AC_DEFUN([LIBOPTS_WITH_REGEX_HEADER],[
+  AC_ARG_WITH([regex-header],
+    AC_HELP_STRING([--with-regex-header], [a reg expr header is specified]),
+    [libopts_cv_with_regex_header=${with_regex_header}],
+    AC_CACHE_CHECK([whether a reg expr header is specified], libopts_cv_with_regex_header,
+      libopts_cv_with_regex_header=no)
+  ) # end of AC_ARG_WITH
+
+  if test "X${libopts_cv_with_regex_header}" != Xno
+  then
+    AC_DEFINE_UNQUOTED([REGEX_HEADER],[<${libopts_cv_with_regex_header}>])
+  else
+    AC_DEFINE([REGEX_HEADER],[<regex.h>],[name of regex header file])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_WITH_REGEX_HEADER
+
+
+AC_DEFUN([LIBOPTS_WITHLIB_REGEX],[
+  AC_ARG_WITH([libregex],
+    AC_HELP_STRING([--with-libregex], [libregex installation prefix]),
+    [libopts_cv_with_libregex_root=${with_libregex}],
+    AC_CACHE_CHECK([whether with-libregex was specified], libopts_cv_with_libregex_root,
+      libopts_cv_with_libregex_root=no)
+  ) # end of AC_ARG_WITH libregex
+
+  if test "${with_libguile+set}" = set && \
+     test "${withval}" = no
+  then ## disabled by request
+    libopts_cv_with_libregex_root=no
+    libopts_cv_with_libregex_cflags=no
+    libopts_cv_with_libregex_libs=no
+  else
+
+  AC_ARG_WITH([libregex-cflags],
+    AC_HELP_STRING([--with-libregex-cflags], [libregex compile flags]),
+    [libopts_cv_with_libregex_cflags=${with_regex_cflags}],
+    AC_CACHE_CHECK([whether with-libregex-cflags was specified], libopts_cv_with_libregex_cflags,
+      libopts_cv_with_libregex_cflags=no)
+  ) # end of AC_ARG_WITH libregex-cflags
+
+  AC_ARG_WITH([libregex-libs],
+    AC_HELP_STRING([--with-libregex-libs], [libregex link command arguments]),
+    [libopts_cv_with_libregex_libs=${with_regex_libs}],
+    AC_CACHE_CHECK([whether with-libregex-libs was specified], libopts_cv_with_libregex_libs,
+      libopts_cv_with_libregex_libs=no)
+  ) # end of AC_ARG_WITH libregex-libs
+
+  case "X${libopts_cv_with_libregex_cflags}" in
+  Xyes|Xno|X )
+    case "X${libopts_cv_with_libregex_root}" in
+    Xyes|Xno|X ) libopts_cv_with_libregex_cflags=no ;;
+    * )        libopts_cv_with_libregex_cflags=-I${libopts_cv_with_libregex_root}/include ;;
+    esac
+  esac
+  case "X${libopts_cv_with_libregex_libs}" in
+  Xyes|Xno|X )
+    case "X${libopts_cv_with_libregex_root}" in
+    Xyes|Xno|X ) libopts_cv_with_libregex_libs=no ;;
+    * )        libopts_cv_with_libregex_libs="-L${libopts_cv_with_libregex_root}/lib -lregex";;
+    esac
+  esac
+  libopts_save_CPPFLAGS="${CPPFLAGS}"
+  libopts_save_LIBS="${LIBS}"
+  fi ## disabled by request
+
+  case "X${libopts_cv_with_libregex_cflags}" in
+  Xyes|Xno|X )
+    libopts_cv_with_libregex_cflags="" ;;
+  * ) CPPFLAGS="${CPPFLAGS} ${libopts_cv_with_libregex_cflags}" ;;
+  esac
+  case "X${libopts_cv_with_libregex_libs}" in
+  Xyes|Xno|X )
+    libopts_cv_with_libregex_libs="" ;;
+  * )
+    LIBS="${LIBS} ${libopts_cv_with_libregex_libs}" ;;
+  esac
+  LIBREGEX_CFLAGS=""
+  LIBREGEX_LIBS=""
+  AC_MSG_CHECKING([whether libregex functions properly])
+  AC_CACHE_VAL([libopts_cv_with_libregex],[
+  AC_TRY_RUN([@%:@include <stdio.h>
+@%:@include <stdlib.h>
+@%:@include <sys/types.h>
+@%:@include REGEX_HEADER
+static regex_t re;
+void comp_re( char const* pzPat ) {
+  int res = regcomp( &re, pzPat, REG_EXTENDED|REG_ICASE|REG_NEWLINE );
+  if (res == 0) return;
+  exit( res ); }
+int main() {
+  regmatch_t m@<:@2@:>@;
+  comp_re( "^.*\@S|@"   );
+  comp_re( "()|no.*" );
+  comp_re( "."       );
+  if (regexec( &re, "X", 2, m, 0 ) != 0)  return 1;
+  if ((m@<:@0@:>@.rm_so != 0) || (m@<:@0@:>@.rm_eo != 1)) {
+    fputs( "error: regex -->.<-- did not match\n", stderr );
+    return 1;
+  }
+  return 0; }],
+    [libopts_cv_with_libregex=yes], [libopts_cv_with_libregex=no],
+    [libopts_cv_with_libregex=no]) # end of AC_TRY_RUN 
+  ]) # end of AC_CACHE_VAL for libopts_cv_with_libregex
+  AC_MSG_RESULT([${libopts_cv_with_libregex}])
+
+  if test "X${libopts_cv_with_libregex}" != Xno
+  then
+    AC_DEFINE([WITH_LIBREGEX],[1],
+        [Define this if a working libregex can be found])
+  else
+    CPPFLAGS="${libopts_save_CPPFLAGS}"
+    LIBS="${libopts_save_LIBS}"
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_WITHLIB_REGEX
+
+
+AC_DEFUN([LIBOPTS_RUN_PATHFIND],[
+  AC_MSG_CHECKING([whether pathfind(3) works])
+  AC_CACHE_VAL([libopts_cv_run_pathfind],[
+  AC_TRY_RUN([@%:@include <string.h>
+@%:@include <stdlib.h>
+int main (int argc, char** argv) {
+   char* pz = pathfind( getenv( "PATH" ), "sh", "x" );
+   return (pz == 0) ? 1 : 0;
+}],
+    [libopts_cv_run_pathfind=yes],[libopts_cv_run_pathfind=no],[libopts_cv_run_pathfind=no]
+  ) # end of TRY_RUN
+  ]) # end of AC_CACHE_VAL for libopts_cv_run_pathfind
+  AC_MSG_RESULT([${libopts_cv_run_pathfind}])
+
+  if test "X${libopts_cv_run_pathfind}" != Xno
+  then
+    AC_DEFINE([HAVE_PATHFIND],[1],
+        [Define this if pathfind(3) works])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_RUN_PATHFIND
+
+
+AC_DEFUN([LIBOPTS_TEST_DEV_ZERO],[
+  AC_MSG_CHECKING([whether /dev/zero is readable device])
+  AC_CACHE_VAL([libopts_cv_test_dev_zero],[
+    libopts_cv_test_dev_zero=`exec 2> /dev/null
+dzero=\`ls -lL /dev/zero | egrep ^c......r\`
+test -z "${dzero}" && exit 1
+echo ${dzero}`
+    if test $? -ne 0
+    then libopts_cv_test_dev_zero=no
+    elif test -z "$libopts_cv_test_dev_zero"
+    then libopts_cv_test_dev_zero=no
+    fi
+  ]) # end of CACHE_VAL of libopts_cv_test_dev_zero
+  AC_MSG_RESULT([${libopts_cv_test_dev_zero}])
+
+  if test "X${libopts_cv_test_dev_zero}" != Xno
+  then
+    AC_DEFINE([HAVE_DEV_ZERO],[1],
+        [Define this if /dev/zero is readable device])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_TEST_DEV_ZERO
+
+
+AC_DEFUN([LIBOPTS_RUN_REALPATH],[
+  AC_MSG_CHECKING([whether we have a functional realpath(3C)])
+  AC_CACHE_VAL([libopts_cv_run_realpath],[
+  AC_TRY_RUN([@%:@include <limits.h>
+@%:@include <stdlib.h>
+int main (int argc, char** argv) {
+@%:@ifndef PATH_MAX
+choke me!!
+@%:@else
+   char zPath@<:@PATH_MAX+1@:>@;
+@%:@endif
+   char *pz = realpath(argv@<:@0@:>@, zPath);
+   return (pz == zPath) ? 0 : 1;
+}],
+    [libopts_cv_run_realpath=yes],[libopts_cv_run_realpath=no],[libopts_cv_run_realpath=no]
+  ) # end of TRY_RUN
+  ]) # end of AC_CACHE_VAL for libopts_cv_run_realpath
+  AC_MSG_RESULT([${libopts_cv_run_realpath}])
+
+  if test "X${libopts_cv_run_realpath}" != Xno
+  then
+    AC_DEFINE([HAVE_REALPATH],[1],
+        [Define this if we have a functional realpath(3C)])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_RUN_REALPATH
+
+
+AC_DEFUN([LIBOPTS_RUN_STRFTIME],[
+  AC_MSG_CHECKING([whether strftime() works])
+  AC_CACHE_VAL([libopts_cv_run_strftime],[
+  AC_TRY_RUN([@%:@include <time.h>
+@%:@include <string.h>
+char t_buf@<:@ 64 @:>@;
+int main() {
+  static char const z@<:@@:>@ = "Thursday Aug 28 240";
+  struct tm tm;
+  tm.tm_sec   = 36;  /* seconds after the minute @<:@0, 61@:>@  */
+  tm.tm_min   = 44;  /* minutes after the hour @<:@0, 59@:>@ */
+  tm.tm_hour  = 12;  /* hour since midnight @<:@0, 23@:>@ */
+  tm.tm_mday  = 28;  /* day of the month @<:@1, 31@:>@ */
+  tm.tm_mon   =  7;  /* months since January @<:@0, 11@:>@ */
+  tm.tm_year  = 86;  /* years since 1900 */
+  tm.tm_wday  =  4;  /* days since Sunday @<:@0, 6@:>@ */
+  tm.tm_yday  = 239; /* days since January 1 @<:@0, 365@:>@ */
+  tm.tm_isdst =  1;  /* flag for daylight savings time */
+  strftime( t_buf, sizeof( t_buf ), "%A %b %d %j", &tm );
+  return (strcmp( t_buf, z ) != 0); }],
+    [libopts_cv_run_strftime=yes],[libopts_cv_run_strftime=no],[libopts_cv_run_strftime=no]
+  ) # end of TRY_RUN
+  ]) # end of AC_CACHE_VAL for libopts_cv_run_strftime
+  AC_MSG_RESULT([${libopts_cv_run_strftime}])
+
+  if test "X${libopts_cv_run_strftime}" != Xno
+  then
+    AC_DEFINE([HAVE_STRFTIME],[1],
+        [Define this if strftime() works])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_RUN_STRFTIME
+
+
+AC_DEFUN([LIBOPTS_RUN_FOPEN_BINARY],[
+  AC_MSG_CHECKING([whether fopen accepts "b" mode])
+  AC_CACHE_VAL([libopts_cv_run_fopen_binary],[
+  AC_TRY_RUN([@%:@include <stdio.h>
+int main (int argc, char** argv) {
+FILE* fp = fopen("conftest.@S|@ac_ext", "rb");
+return (fp == NULL) ? 1 : fclose(fp); }],
+    [libopts_cv_run_fopen_binary=yes],[libopts_cv_run_fopen_binary=no],[libopts_cv_run_fopen_binary=no]
+  ) # end of TRY_RUN
+  ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_binary
+  AC_MSG_RESULT([${libopts_cv_run_fopen_binary}])
+
+  if test "X${libopts_cv_run_fopen_binary}" != Xno
+  then
+    AC_DEFINE([FOPEN_BINARY_FLAG],"b",
+       [fopen(3) accepts a 'b' in the mode flag])
+  else
+    AC_DEFINE([FOPEN_BINARY_FLAG],"",
+       [fopen(3) accepts a 'b' in the mode flag])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_BINARY
+
+
+AC_DEFUN([LIBOPTS_RUN_FOPEN_TEXT],[
+  AC_MSG_CHECKING([whether fopen accepts "t" mode])
+  AC_CACHE_VAL([libopts_cv_run_fopen_text],[
+  AC_TRY_RUN([@%:@include <stdio.h>
+int main (int argc, char** argv) {
+FILE* fp = fopen("conftest.@S|@ac_ext", "rt");
+return (fp == NULL) ? 1 : fclose(fp); }],
+    [libopts_cv_run_fopen_text=yes],[libopts_cv_run_fopen_text=no],[libopts_cv_run_fopen_text=no]
+  ) # end of TRY_RUN
+  ]) # end of AC_CACHE_VAL for libopts_cv_run_fopen_text
+  AC_MSG_RESULT([${libopts_cv_run_fopen_text}])
+
+  if test "X${libopts_cv_run_fopen_text}" != Xno
+  then
+    AC_DEFINE([FOPEN_TEXT_FLAG],"t",
+       [fopen(3) accepts a 't' in the mode flag])
+  else
+    AC_DEFINE([FOPEN_TEXT_FLAG],"",
+       [fopen(3) accepts a 't' in the mode flag])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_RUN_FOPEN_TEXT
+
+
+AC_DEFUN([LIBOPTS_DISABLE_OPTIONAL_ARGS],[
+  AC_ARG_ENABLE([optional-args],
+    AC_HELP_STRING([--disable-optional-args], [not wanting optional option args]),
+    [libopts_cv_enable_optional_args=${enable_optional_args}],
+    AC_CACHE_CHECK([whether not wanting optional option args], libopts_cv_enable_optional_args,
+      libopts_cv_enable_optional_args=yes)
+  ) # end of AC_ARG_ENABLE
+
+  if test "X${libopts_cv_enable_optional_args}" = Xno
+  then
+    AC_DEFINE([NO_OPTIONAL_OPT_ARGS], [1],
+          [Define this if optional arguments are disallowed])
+  fi
+  
+]) # end of AC_DEFUN of LIBOPTS_DISABLE_OPTIONAL_ARGS
+
+
+AC_DEFUN([INVOKE_LIBOPTS_MACROS],[
+  INVOKE_LIBOPTS_MACROS_FIRST
+  # Check to see if a reg expr header is specified.
+  LIBOPTS_WITH_REGEX_HEADER
+
+  # Check to see if a working libregex can be found.
+  LIBOPTS_WITHLIB_REGEX
+
+  # Check to see if pathfind(3) works.
+  LIBOPTS_RUN_PATHFIND
+
+  # Check to see if /dev/zero is readable device.
+  LIBOPTS_TEST_DEV_ZERO
+
+  # Check to see if we have a functional realpath(3C).
+  LIBOPTS_RUN_REALPATH
+
+  # Check to see if strftime() works.
+  LIBOPTS_RUN_STRFTIME
+
+  # Check to see if fopen accepts "b" mode.
+  LIBOPTS_RUN_FOPEN_BINARY
+
+  # Check to see if fopen accepts "t" mode.
+  LIBOPTS_RUN_FOPEN_TEXT
+
+  # Check to see if not wanting optional option args.
+  LIBOPTS_DISABLE_OPTIONAL_ARGS
+
+]) # end AC_DEFUN of INVOKE_LIBOPTS_MACROS
+
+dnl @synopsis  LIBOPTS_CHECK
+dnl
+dnl Time-stamp:        "2006-09-23 19:36:24 bkorb"
+dnl Last Committed:    $Date: 2006/09/24 02:59:00 $
+dnl
+dnl If autoopts-config works, add the linking information to LIBS.
+dnl Otherwise, add ``libopts-${ao_rev}'' to SUBDIRS and run all
+dnl the config tests that the library needs.  Invoke the
+dnl "INVOKE_LIBOPTS_MACROS" macro iff we are building libopts.
+dnl
+dnl Default to system libopts
+dnl
+AC_DEFUN([LIBOPTS_CHECK],[
+  [NEED_LIBOPTS_DIR='']
+  m4_pushdef([AO_Libopts_Dir],
+           [ifelse($1, , [libopts], [$1])])
+  AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir)
+  AC_ARG_ENABLE([local-libopts],
+    AC_HELP_STRING([--enable-local-libopts],
+       [Force using the supplied libopts tearoff code]),[
+    if test x$enableval = xyes ; then
+       AC_MSG_NOTICE([Using supplied libopts tearoff])
+       LIBOPTS_LDADD='$(top_builddir)/AO_Libopts_Dir/libopts.la'
+       LIBOPTS_CFLAGS='-I$(top_srcdir)/AO_Libopts_Dir'
+       NEED_LIBOPTS_DIR=true
+    fi])
+
+  AC_ARG_ENABLE([libopts-install],
+    AC_HELP_STRING([--disable-libopts-install],
+       [Do not install libopts with client installation]))
+  AM_CONDITIONAL([INSTALL_LIBOPTS],[test "X${enable_libopts_install}" != Xno])
+
+  [if test -z "${NEED_LIBOPTS_DIR}" ; then]
+     AC_MSG_CHECKING([whether autoopts-config can be found])
+     AC_ARG_WITH([autoopts-config],
+        AC_HELP_STRING([--with-autoopts-config],
+             [specify the config-info script]),
+        [lo_cv_with_autoopts_config=${with_autoopts_config}],
+        AC_CACHE_CHECK([whether autoopts-config is specified],
+             [lo_cv_with_autoopts_config],
+             [if autoopts-config --help 2>/dev/null 1>&2
+        then lo_cv_with_autoopts_config=autoopts-config
+        elif libopts-config --help 2>/dev/null 1>&2
+        then lo_cv_with_autoopts_config=libopts-config
+        else lo_cv_with_autoopts_config=no ; fi])
+     ) # end of AC_ARG_WITH
+
+     AC_CACHE_VAL([lo_cv_test_autoopts],[
+        if test -z "${lo_cv_with_autoopts_config}" \
+                -o X"${lo_cv_with_autoopts_config}" = Xno
+        then
+           if autoopts-config --help 2>/dev/null 1>&2
+           then lo_cv_with_autoopts_config=autoopts-config
+           elif libopts-config --help 2>/dev/null 1>&2
+           then lo_cv_with_autoopts_config=libopts-config
+           else lo_cv_with_autoopts_config=false ; fi
+        fi
+        lo_cv_test_autoopts=`
+            ${lo_cv_with_autoopts_config} --libs` 2> /dev/null
+        if test $? -ne 0 -o -z "${lo_cv_test_autoopts}"
+        then lo_cv_test_autoopts=no ; fi
+     ]) # end of CACHE_VAL
+     AC_MSG_RESULT([${lo_cv_test_autoopts}])
+
+     [if test "X${lo_cv_test_autoopts}" != Xno
+     then
+        LIBOPTS_LDADD="${lo_cv_test_autoopts}"
+        LIBOPTS_CFLAGS="`${lo_cv_with_autoopts_config} --cflags`"
+     else
+        LIBOPTS_LDADD='$(top_builddir)/]AO_Libopts_Dir[/libopts.la'
+        LIBOPTS_CFLAGS='-I$(top_srcdir)/]AO_Libopts_Dir['
+        NEED_LIBOPTS_DIR=true
+     fi
+  fi # end of if test -z "${NEED_LIBOPTS_DIR}"]
+
+  AM_CONDITIONAL([NEED_LIBOPTS], [test -n "${NEED_LIBOPTS_DIR}"])
+  AC_SUBST(LIBOPTS_LDADD)
+  AC_SUBST(LIBOPTS_CFLAGS)
+  AC_SUBST(LIBOPTS_DIR, AO_Libopts_Dir)
+  AC_CONFIG_FILES(AO_Libopts_Dir/Makefile)
+  m4_popdef([AO_Libopts_Dir])
+
+  [if test -n "${NEED_LIBOPTS_DIR}" ; then]
+    INVOKE_LIBOPTS_MACROS
+  else
+    INVOKE_LIBOPTS_MACROS_FIRST
+  [fi
+# end of AC_DEFUN of LIBOPTS_CHECK]
+])
diff --git a/sntp/libopts/m4/liboptschk.m4 b/sntp/libopts/m4/liboptschk.m4
new file mode 100644 (file)
index 0000000..14e7f27
--- /dev/null
@@ -0,0 +1,42 @@
+# liboptschk.m4 serial 1 (autogen - 5.7.3)
+dnl Copyright (C) 2005 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+dnl Time-stamp:        "2006-09-23 19:42:31 bkorb"
+dnl Last Committed:    $Date: 2006/09/24 02:59:00 $
+
+dnl This file can can be used in projects which are not available under
+dnl the GNU General Public License or the GNU Library General Public
+dnl License but which still want to provide support for the GNU gettext
+dnl functionality.
+dnl Please note that the actual code of the GNU gettext library is covered
+dnl by the GNU Library General Public License, and the rest of the GNU
+dnl gettext package package is covered by the GNU General Public License.
+dnl They are *not* in the public domain.
+
+dnl Authors:
+dnl   Ulrich Drepper <drepper@cygnus.com>, 1995-2000.
+dnl   Bruno Haible <haible@clisp.cons.org>, 2000-2003.
+
+AC_PREREQ(2.50)
+
+AC_DEFUN([ag_FIND_LIBOPTS],
+    [if test "X${ac_cv_header_autoopts_options_h}" == Xno
+    then
+      :
+    else
+      f=`autoopts-config cflags` 2>/dev/null
+      test X"${f}" = X && f=`libopts-config cflags` 2>/dev/null
+      if test X"${f}" = X
+      then
+        :
+      else
+        AC_DEFINE([HAVE_LIBOPTS],[1],[define if we can find libopts])
+        CFLAGS="${CFLAGS} ${f}"
+        f=`autoopts-config ldflags` 2>/dev/null
+        test X"${f}" = X && f=`libopts-config ldflags` 2>/dev/null
+        LIBS="${LIBS} ${f}"
+      fi
+    fi])
diff --git a/sntp/libopts/makeshell.c b/sntp/libopts/makeshell.c
new file mode 100644 (file)
index 0000000..8447d45
--- /dev/null
@@ -0,0 +1,1122 @@
+
+/*
+ *  $Id: makeshell.c,v 4.20 2007/02/04 17:44:12 bkorb Exp $
+ * Time-stamp:      "2007-01-27 06:05:45 bkorb"
+ *
+ *  This module will interpret the options set in the tOptions
+ *  structure and create a Bourne shell script capable of parsing them.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+tOptions*  pShellParseOptions = NULL;
+
+/* * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Setup Format Strings
+ */
+tSCC zStartMarker[] =
+"# # # # # # # # # # -- do not modify this marker --\n#\n"
+"#  DO NOT EDIT THIS SECTION";
+
+tSCC zPreamble[] =
+"%s OF %s\n#\n"
+"#  From here to the next `-- do not modify this marker --',\n"
+"#  the text has been generated %s\n";
+
+tSCC zEndPreamble[] =
+"#  From the %s option definitions\n#\n";
+
+tSCC zMultiDef[] = "\n"
+"if test -z \"${%1$s_%2$s}\"\n"
+"then\n"
+"  %1$s_%2$s_CT=0\n"
+"else\n"
+"  %1$s_%2$s_CT=1\n"
+"  %1$s_%2$s_1=\"${%1$s_%2$s}\"\n"
+"fi\n"
+"export %1$s_%2$s_CT";
+
+tSCC zSingleDef[] = "\n"
+"%1$s_%2$s=\"${%1$s_%2$s-'%3$s'}\"\n"
+"%1$s_%2$s_set=false\n"
+"export %1$s_%2$s\n";
+
+tSCC zSingleNoDef[] = "\n"
+"%1$s_%2$s=\"${%1$s_%2$s}\"\n"
+"%1$s_%2$s_set=false\n"
+"export %1$s_%2$s\n";
+
+/* * * * * * * * * * * * * * * * * * * * *
+ *
+ *  LOOP START
+ *
+ *  The loop may run in either of two modes:
+ *  all options are named options (loop only)
+ *  regular, marked option processing.
+ */
+tSCC zLoopCase[] = "\n"
+"OPT_PROCESS=true\n"
+"OPT_ARG=\"$1\"\n\n"
+"while ${OPT_PROCESS} && [ $# -gt 0 ]\ndo\n"
+"    OPT_ELEMENT=''\n"
+"    OPT_ARG_VAL=''\n\n"
+     /*
+      *  'OPT_ARG' may or may not match the current $1
+      */
+"    case \"${OPT_ARG}\" in\n"
+"    -- )\n"
+"        OPT_PROCESS=false\n"
+"        shift\n"
+"        ;;\n\n";
+
+tSCC zLoopOnly[] = "\n"
+"OPT_ARG=\"$1\"\n\n"
+"while [ $# -gt 0 ]\ndo\n"
+"    OPT_ELEMENT=''\n"
+"    OPT_ARG_VAL=''\n\n"
+"    OPT_ARG=\"${1}\"\n";
+
+/* * * * * * * * * * * * * * * *
+ *
+ *  CASE SELECTORS
+ *
+ *  If the loop runs as a regular option loop,
+ *  then we must have selectors for each acceptable option
+ *  type (long option, flag character and non-option)
+ */
+tSCC zLongSelection[] =
+"    --* )\n";
+
+tSCC zFlagSelection[] =
+"    -* )\n";
+
+tSCC zEndSelection[] =
+"        ;;\n\n";
+
+tSCC zNoSelection[] =
+"    * )\n"
+"         OPT_PROCESS=false\n"
+"         ;;\n"
+"    esac\n\n";
+
+/* * * * * * * * * * * * * * * *
+ *
+ *  LOOP END
+ */
+tSCC zLoopEnd[] =
+"    if [ -n \"${OPT_ARG_VAL}\" ]\n"
+"    then\n"
+"        eval %1$s_${OPT_NAME}${OPT_ELEMENT}=\"'${OPT_ARG_VAL}'\"\n"
+"        export %1$s_${OPT_NAME}${OPT_ELEMENT}\n"
+"    fi\n"
+"done\n\n"
+"unset OPT_PROCESS || :\n"
+"unset OPT_ELEMENT || :\n"
+"unset OPT_ARG || :\n"
+"unset OPT_ARG_NEEDED || :\n"
+"unset OPT_NAME || :\n"
+"unset OPT_CODE || :\n"
+"unset OPT_ARG_VAL || :\n%2$s";
+
+tSCC zTrailerMarker[] = "\n"
+"# # # # # # # # # #\n#\n"
+"#  END OF AUTOMATED OPTION PROCESSING\n"
+"#\n# # # # # # # # # # -- do not modify this marker --\n";
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  OPTION SELECTION
+ */
+tSCC zOptionCase[] =
+"        case \"${OPT_CODE}\" in\n";
+
+tSCC zOptionPartName[] =
+"        '%s' | \\\n";
+
+tSCC zOptionFullName[] =
+"        '%s' )\n";
+
+tSCC zOptionFlag[] =
+"        '%c' )\n";
+
+tSCC zOptionEndSelect[] =
+"            ;;\n\n";
+
+tSCC zOptionUnknown[] =
+"        * )\n"
+"            echo Unknown %s: \"${OPT_CODE}\" >&2\n"
+"            echo \"$%s_USAGE_TEXT\"\n"
+"            exit 1\n"
+"            ;;\n"
+"        esac\n\n";
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  OPTION PROCESSING
+ *
+ *  Formats for emitting the text for handling particular options
+ */
+tSCC zTextExit[] =
+"            echo \"$%s_%s_TEXT\"\n"
+"            exit 0\n";
+
+tSCC zPagedUsageExit[] =
+"            echo \"$%s_LONGUSAGE_TEXT\" | ${PAGER-more}\n"
+"            exit 0\n";
+
+tSCC zCmdFmt[] =
+"            %s\n";
+
+tSCC zCountTest[] =
+"            if [ $%1$s_%2$s_CT -ge %3$d ] ; then\n"
+"                echo Error:  more than %3$d %2$s options >&2\n"
+"                echo \"$%1$s_USAGE_TEXT\"\n"
+"                exit 1 ; fi\n";
+
+tSCC zMultiArg[] =
+"            %1$s_%2$s_CT=`expr ${%1$s_%2$s_CT} + 1`\n"
+"            OPT_ELEMENT=\"_${%1$s_%2$s_CT}\"\n"
+"            OPT_NAME='%2$s'\n";
+
+tSCC zSingleArg[] =
+"            if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
+"                echo Error:  duplicate %2$s option >&2\n"
+"                echo \"$%1$s_USAGE_TEXT\"\n"
+"                exit 1 ; fi\n"
+"            %1$s_%2$s_set=true\n"
+"            OPT_NAME='%2$s'\n";
+
+tSCC zNoMultiArg[] =
+"            %1$s_%2$s_CT=0\n"
+"            OPT_ELEMENT=''\n"
+"            %1$s_%2$s='%3$s'\n"
+"            export %1$s_%2$s\n"
+"            OPT_NAME='%2$s'\n";
+
+tSCC zNoSingleArg[] =
+"            if [ -n \"${%1$s_%2$s}\" ] && ${%1$s_%2$s_set} ; then\n"
+"                echo Error:  duplicate %2$s option >&2\n"
+"                echo \"$%1$s_USAGE_TEXT\"\n"
+"                exit 1 ; fi\n"
+"            %1$s_%2$s_set=true\n"
+"            %1$s_%2$s='%3$s'\n"
+"            export %1$s_%2$s\n"
+"            OPT_NAME='%2$s'\n";
+
+tSCC zMayArg[]  =
+"            eval %1$s_%2$s${OPT_ELEMENT}=true\n"
+"            export %1$s_%2$s${OPT_ELEMENT}\n"
+"            OPT_ARG_NEEDED=OK\n";
+
+tSCC zMustArg[] =
+"            OPT_ARG_NEEDED=YES\n";
+
+tSCC zCantArg[] =
+"            eval %1$s_%2$s${OPT_ELEMENT}=true\n"
+"            export %1$s_%2$s${OPT_ELEMENT}\n"
+"            OPT_ARG_NEEDED=NO\n";
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  LONG OPTION PROCESSING
+ *
+ *  Formats for emitting the text for handling long option types
+ */
+tSCC zLongOptInit[] =
+"        OPT_CODE=`echo \"X${OPT_ARG}\"|sed 's/^X-*//'`\n"
+"        shift\n"
+"        OPT_ARG=\"$1\"\n\n"
+"        case \"${OPT_CODE}\" in *=* )\n"
+"            OPT_ARG_VAL=`echo \"${OPT_CODE}\"|sed 's/^[^=]*=//'`\n"
+"            OPT_CODE=`echo \"${OPT_CODE}\"|sed 's/=.*$//'` ;; esac\n\n";
+
+tSCC zLongOptArg[] =
+"        case \"${OPT_ARG_NEEDED}\" in\n"
+"        NO )\n"
+"            OPT_ARG_VAL=''\n"
+"            ;;\n\n"
+"        YES )\n"
+"            if [ -z \"${OPT_ARG_VAL}\" ]\n"
+"            then\n"
+"                if [ $# -eq 0 ]\n"
+"                then\n"
+"                    echo No argument provided for ${OPT_NAME} option >&2\n"
+"                    echo \"$%s_USAGE_TEXT\"\n"
+"                    exit 1\n"
+"                fi\n\n"
+"                OPT_ARG_VAL=\"${OPT_ARG}\"\n"
+"                shift\n"
+"                OPT_ARG=\"$1\"\n"
+"            fi\n"
+"            ;;\n\n"
+"        OK )\n"
+"            if [ -z \"${OPT_ARG_VAL}\" ] && [ $# -gt 0 ]\n"
+"            then\n"
+"                case \"${OPT_ARG}\" in -* ) ;; * )\n"
+"                    OPT_ARG_VAL=\"${OPT_ARG}\"\n"
+"                    shift\n"
+"                    OPT_ARG=\"$1\" ;; esac\n"
+"            fi\n"
+"            ;;\n"
+"        esac\n";
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  FLAG OPTION PROCESSING
+ *
+ *  Formats for emitting the text for handling flag option types
+ */
+tSCC zFlagOptInit[] =
+"        OPT_CODE=`echo \"X${OPT_ARG}\" | sed 's/X-\\(.\\).*/\\1/'`\n"
+"        OPT_ARG=` echo \"X${OPT_ARG}\" | sed 's/X-.//'`\n\n";
+
+tSCC zFlagOptArg[] =
+"        case \"${OPT_ARG_NEEDED}\" in\n"
+"        NO )\n"
+"            if [ -n \"${OPT_ARG}\" ]\n"
+"            then\n"
+"                OPT_ARG=-\"${OPT_ARG}\"\n"
+"            else\n"
+"                shift\n"
+"                OPT_ARG=\"$1\"\n"
+"            fi\n"
+"            ;;\n\n"
+"        YES )\n"
+"            if [ -n \"${OPT_ARG}\" ]\n"
+"            then\n"
+"                OPT_ARG_VAL=\"${OPT_ARG}\"\n\n"
+"            else\n"
+"                if [ $# -eq 0 ]\n"
+"                then\n"
+"                    echo No argument provided for ${OPT_NAME} option >&2\n"
+"                    echo \"$%s_USAGE_TEXT\"\n"
+"                    exit 1\n"
+"                fi\n"
+"                shift\n"
+"                OPT_ARG_VAL=\"$1\"\n"
+"            fi\n\n"
+"            shift\n"
+"            OPT_ARG=\"$1\"\n"
+"            ;;\n\n"
+"        OK )\n"
+"            if [ -n \"${OPT_ARG}\" ]\n"
+"            then\n"
+"                OPT_ARG_VAL=\"${OPT_ARG}\"\n"
+"                shift\n"
+"                OPT_ARG=\"$1\"\n\n"
+"            else\n"
+"                shift\n"
+"                if [ $# -gt 0 ]\n"
+"                then\n"
+"                    case \"$1\" in -* ) ;; * )\n"
+"                        OPT_ARG_VAL=\"$1\"\n"
+"                        shift ;; esac\n"
+"                    OPT_ARG=\"$1\"\n"
+"                fi\n"
+"            fi\n"
+"            ;;\n"
+"        esac\n";
+
+tSCC* pzShell = NULL;
+static char*  pzLeader  = NULL;
+static char*  pzTrailer = NULL;
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD );
+
+static void
+emitUsage( tOptions* pOpts );
+
+static void
+emitSetup( tOptions* pOpts );
+
+static void
+printOptionAction( tOptions* pOpts, tOptDesc* pOptDesc );
+
+static void
+printOptionInaction( tOptions* pOpts, tOptDesc* pOptDesc );
+
+static void
+emitFlag( tOptions* pOpts );
+
+static void
+emitMatchExpr( tCC* pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts );
+
+static void
+emitLong( tOptions* pOpts );
+
+static void
+openOutput( char const* pzFile );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*=export_func  optionParseShell
+ * private:
+ *
+ * what:  Decipher a boolean value
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ *
+ * doc:
+ *  Emit a shell script that will parse the command line options.
+=*/
+void
+optionParseShell( tOptions* pOpts )
+{
+    /*
+     *  Check for our SHELL option now.
+     *  IF the output file contains the "#!" magic marker,
+     *  it will override anything we do here.
+     */
+    if (HAVE_OPT( SHELL ))
+        pzShell = OPT_ARG( SHELL );
+
+    else if (! ENABLED_OPT( SHELL ))
+        pzShell = NULL;
+
+    else if ((pzShell = getenv( "SHELL" )),
+             pzShell == NULL)
+
+        pzShell = "/bin/sh";
+
+    /*
+     *  Check for a specified output file
+     */
+    if (HAVE_OPT( SCRIPT ))
+        openOutput( OPT_ARG( SCRIPT ));
+
+    emitUsage( pOpts );
+    emitSetup( pOpts );
+
+    /*
+     *  There are four modes of option processing.
+     */
+    switch (pOpts->fOptSet & (OPTPROC_LONGOPT|OPTPROC_SHORTOPT)) {
+    case OPTPROC_LONGOPT:
+        fputs( zLoopCase,        stdout );
+
+        fputs( zLongSelection,   stdout );
+        fputs( zLongOptInit,     stdout );
+        emitLong( pOpts );
+        printf( zLongOptArg,     pOpts->pzPROGNAME );
+        fputs( zEndSelection,    stdout );
+
+        fputs( zNoSelection,     stdout );
+        break;
+
+    case 0:
+        fputs( zLoopOnly,        stdout );
+        fputs( zLongOptInit,     stdout );
+        emitLong( pOpts );
+        printf( zLongOptArg,     pOpts->pzPROGNAME );
+        break;
+
+    case OPTPROC_SHORTOPT:
+        fputs( zLoopCase,        stdout );
+
+        fputs( zFlagSelection,   stdout );
+        fputs( zFlagOptInit,     stdout );
+        emitFlag( pOpts );
+        printf( zFlagOptArg,     pOpts->pzPROGNAME );
+        fputs( zEndSelection,    stdout );
+
+        fputs( zNoSelection,     stdout );
+        break;
+
+    case OPTPROC_LONGOPT|OPTPROC_SHORTOPT:
+        fputs( zLoopCase,        stdout );
+
+        fputs( zLongSelection,   stdout );
+        fputs( zLongOptInit,     stdout );
+        emitLong( pOpts );
+        printf( zLongOptArg,     pOpts->pzPROGNAME );
+        fputs( zEndSelection,    stdout );
+
+        fputs( zFlagSelection,   stdout );
+        fputs( zFlagOptInit,     stdout );
+        emitFlag( pOpts );
+        printf( zFlagOptArg,     pOpts->pzPROGNAME );
+        fputs( zEndSelection,    stdout );
+
+        fputs( zNoSelection,     stdout );
+        break;
+    }
+
+    printf( zLoopEnd, pOpts->pzPROGNAME, zTrailerMarker );
+    if ((pzTrailer != NULL) && (*pzTrailer != '\0'))
+        fputs( pzTrailer, stdout );
+    else if (ENABLED_OPT( SHELL ))
+        printf( "\nenv | grep '^%s_'\n", pOpts->pzPROGNAME );
+
+    fflush( stdout );
+    fchmod( STDOUT_FILENO, 0755 );
+    fclose( stdout );
+}
+
+
+static void
+textToVariable( tOptions* pOpts, teTextTo whichVar, tOptDesc* pOD )
+{
+#   define _TT_(n) tSCC z ## n [] = #n;
+    TEXTTO_TABLE
+#   undef _TT_
+#   define _TT_(n) z ## n ,
+      static char const*  apzTTNames[] = { TEXTTO_TABLE };
+#   undef _TT_
+
+#if defined(__windows__) && !defined(__CYGWIN__)
+    printf( "%1$s_%2$s_TEXT='no %2$s text'\n",
+            pOpts->pzPROGNAME, apzTTNames[ whichVar ]);
+#else
+    int  nlHoldCt = 0;
+    int  pipeFd[2];
+    FILE* fp;
+
+    printf( "%s_%s_TEXT='", pOpts->pzPROGNAME, apzTTNames[ whichVar ]);
+    fflush( stdout );
+
+    if (pipe( pipeFd ) != 0) {
+        fprintf( stderr, zBadPipe, errno, strerror( errno ));
+        exit( EXIT_FAILURE );
+    }
+
+    switch (fork()) {
+    case -1:
+        fprintf( stderr, zForkFail, errno, strerror(errno), pOpts->pzProgName);
+        exit( EXIT_FAILURE );
+        break;
+
+    case 0:
+        dup2( pipeFd[1], STDERR_FILENO );
+        dup2( pipeFd[1], STDOUT_FILENO );
+        close( pipeFd[0] );
+
+        switch (whichVar) {
+        case TT_LONGUSAGE:
+            (*(pOpts->pUsageProc))( pOpts, EXIT_SUCCESS );
+            /* NOTREACHED */
+            exit( EXIT_FAILURE );
+
+        case TT_USAGE:
+            (*(pOpts->pUsageProc))( pOpts, EXIT_FAILURE );
+            /* NOTREACHED */
+            exit( EXIT_FAILURE );
+
+        case TT_VERSION:
+            if (pOD->fOptState & OPTST_ALLOC_ARG) {
+                AGFREE(pOD->optArg.argString);
+                pOD->fOptState &= ~OPTST_ALLOC_ARG;
+            }
+            pOD->optArg.argString = "c";
+            optionPrintVersion( pOpts, pOD );
+            /* NOTREACHED */
+
+        default:
+            exit( EXIT_FAILURE );
+        }
+
+    default:
+        close( pipeFd[1] );
+        fp = fdopen( pipeFd[0], "r" FOPEN_BINARY_FLAG );
+    }
+
+    for (;;) {
+        int  ch = fgetc( fp );
+        switch (ch) {
+
+        case '\n':
+            nlHoldCt++;
+            break;
+
+        case '\'':
+            while (nlHoldCt > 0) {
+                fputc( '\n', stdout );
+                nlHoldCt--;
+            }
+            fputs( "'\\''", stdout );
+            break;
+
+        case EOF:
+            goto endCharLoop;
+
+        default:
+            while (nlHoldCt > 0) {
+                fputc( '\n', stdout );
+                nlHoldCt--;
+            }
+            fputc( ch, stdout );
+            break;
+        }
+    } endCharLoop:;
+
+    fputs( "'\n\n", stdout );
+    close( pipeFd[0] );
+#endif
+}
+
+
+static void
+emitUsage( tOptions* pOpts )
+{
+    char     zTimeBuf[ AO_NAME_SIZE ];
+
+    /*
+     *  First, switch stdout to the output file name.
+     *  Then, change the program name to the one defined
+     *  by the definitions (rather than the current
+     *  executable name).  Down case the upper cased name.
+     */
+    if (pzLeader != NULL)
+        fputs( pzLeader, stdout );
+
+    {
+        tSCC    zStdout[] = "stdout";
+        tCC*    pzOutName;
+
+        {
+            time_t    curTime = time( NULL );
+            struct tm*  pTime = localtime( &curTime );
+            strftime(zTimeBuf, AO_NAME_SIZE, "%A %B %e, %Y at %r %Z", pTime );
+        }
+
+        if (HAVE_OPT( SCRIPT ))
+             pzOutName = OPT_ARG( SCRIPT );
+        else pzOutName = zStdout;
+
+        if ((pzLeader == NULL) && (pzShell != NULL))
+            printf( "#! %s\n", pzShell );
+
+        printf( zPreamble, zStartMarker, pzOutName, zTimeBuf );
+    }
+
+    /*
+     *  Get a copy of the original program name in lower case
+     */
+    {
+        char* pzPN = zTimeBuf;
+        tCC*  pz   = pOpts->pzPROGNAME;
+        for (;;) {
+            if ((*pzPN++ = tolower( *pz++ )) == '\0')
+                break;
+        }
+    }
+
+    printf( zEndPreamble, pOpts->pzPROGNAME );
+
+    pOpts->pzProgPath = pOpts->pzProgName = zTimeBuf;
+    textToVariable( pOpts, TT_LONGUSAGE, NULL );
+    textToVariable( pOpts, TT_USAGE,     NULL );
+
+    {
+        tOptDesc* pOptDesc = pOpts->pOptDesc;
+        int       optionCt = pOpts->optCt;
+
+        for (;;) {
+            if (pOptDesc->pOptProc == optionPrintVersion) {
+                textToVariable( pOpts, TT_VERSION, pOptDesc );
+                break;
+            }
+
+            if (--optionCt <= 0)
+                break;
+            pOptDesc++;
+        }
+    }
+}
+
+
+static void
+emitSetup( tOptions* pOpts )
+{
+    tOptDesc* pOptDesc = pOpts->pOptDesc;
+    int       optionCt = pOpts->presetOptCt;
+    char const* pzFmt;
+    char const* pzDefault;
+
+    for (;optionCt > 0; pOptDesc++, --optionCt) {
+        char zVal[16];
+
+        /*
+         *  Options that are either usage documentation or are compiled out
+         *  are not to be processed.
+         */
+        if (SKIP_OPT(pOptDesc) || (pOptDesc->pz_NAME == NULL))
+            continue;
+
+        if (pOptDesc->optMaxCt > 1)
+             pzFmt = zMultiDef;
+        else pzFmt = zSingleDef;
+
+        /*
+         *  IF this is an enumeration/bitmask option, then convert the value
+         *  to a string before printing the default value.
+         */
+        switch (OPTST_GET_ARGTYPE(pOptDesc->fOptState)) {
+        case OPARG_TYPE_ENUMERATION:
+            (*(pOptDesc->pOptProc))( (tOptions*)2UL, pOptDesc );
+            pzDefault = pOptDesc->optArg.argString;
+            break;
+
+        /*
+         *  Numeric and membership bit options are just printed as a number.
+         */
+        case OPARG_TYPE_NUMERIC:
+            snprintf( zVal, sizeof( zVal ), "%d",
+                      (int)pOptDesc->optArg.argInt );
+            pzDefault = zVal;
+            break;
+
+        case OPARG_TYPE_MEMBERSHIP:
+            snprintf( zVal, sizeof( zVal ), "%lu",
+                      (unsigned long)pOptDesc->optArg.argIntptr );
+            pzDefault = zVal;
+            break;
+
+        case OPARG_TYPE_BOOLEAN:
+            pzDefault = (pOptDesc->optArg.argBool) ? "true" : "false";
+            break;
+
+        default:
+            if (pOptDesc->optArg.argString == NULL) {
+                if (pzFmt == zSingleDef)
+                    pzFmt = zSingleNoDef;
+                pzDefault = NULL;
+            }
+            else
+                pzDefault = pOptDesc->optArg.argString;
+        }
+
+        printf( pzFmt, pOpts->pzPROGNAME, pOptDesc->pz_NAME, pzDefault );
+    }
+}
+
+
+static void
+printOptionAction( tOptions* pOpts, tOptDesc* pOptDesc )
+{
+    if (pOptDesc->pOptProc == optionPrintVersion)
+        printf( zTextExit, pOpts->pzPROGNAME, "VERSION" );
+
+    else if (pOptDesc->pOptProc == optionPagedUsage)
+        printf( zPagedUsageExit, pOpts->pzPROGNAME );
+
+    else if (pOptDesc->pOptProc == optionLoadOpt) {
+        printf( zCmdFmt, "echo 'Warning:  Cannot load options files' >&2" );
+        printf( zCmdFmt, "OPT_ARG_NEEDED=YES" );
+
+    } else if (pOptDesc->pz_NAME == NULL) {
+
+        if (pOptDesc->pOptProc == NULL) {
+            printf( zCmdFmt, "echo 'Warning:  Cannot save options files' "
+                    ">&2" );
+            printf( zCmdFmt, "OPT_ARG_NEEDED=OK" );
+        } else
+            printf( zTextExit, pOpts->pzPROGNAME, "LONGUSAGE" );
+
+    } else {
+        if (pOptDesc->optMaxCt == 1)
+            printf( zSingleArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME );
+        else {
+            if ((unsigned)pOptDesc->optMaxCt < NOLIMIT)
+                printf( zCountTest, pOpts->pzPROGNAME,
+                        pOptDesc->pz_NAME, pOptDesc->optMaxCt );
+
+            printf( zMultiArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME );
+        }
+
+        /*
+         *  Fix up the args.
+         */
+        if (OPTST_GET_ARGTYPE(pOptDesc->fOptState) == OPARG_TYPE_NONE) {
+            printf( zCantArg, pOpts->pzPROGNAME, pOptDesc->pz_NAME );
+
+        } else if (pOptDesc->fOptState & OPTST_ARG_OPTIONAL) {
+            printf( zMayArg,  pOpts->pzPROGNAME, pOptDesc->pz_NAME );
+
+        } else {
+            fputs( zMustArg, stdout );
+        }
+    }
+    fputs( zOptionEndSelect, stdout );
+}
+
+
+static void
+printOptionInaction( tOptions* pOpts, tOptDesc* pOptDesc )
+{
+    if (pOptDesc->pOptProc == optionLoadOpt) {
+        printf( zCmdFmt, "echo 'Warning:  Cannot suppress the loading of "
+                "options files' >&2" );
+
+    } else if (pOptDesc->optMaxCt == 1)
+        printf( zNoSingleArg, pOpts->pzPROGNAME,
+                pOptDesc->pz_NAME, pOptDesc->pz_DisablePfx );
+    else
+        printf( zNoMultiArg, pOpts->pzPROGNAME,
+                pOptDesc->pz_NAME, pOptDesc->pz_DisablePfx );
+
+    printf( zCmdFmt, "OPT_ARG_NEEDED=NO" );
+    fputs( zOptionEndSelect, stdout );
+}
+
+
+static void
+emitFlag( tOptions* pOpts )
+{
+    tOptDesc* pOptDesc = pOpts->pOptDesc;
+    int       optionCt = pOpts->optCt;
+
+    fputs( zOptionCase, stdout );
+
+    for (;optionCt > 0; pOptDesc++, --optionCt) {
+
+        if (SKIP_OPT(pOptDesc))
+            continue;
+
+        if (isprint( pOptDesc->optValue )) {
+            printf( zOptionFlag, pOptDesc->optValue );
+            printOptionAction( pOpts, pOptDesc );
+        }
+    }
+    printf( zOptionUnknown, "flag", pOpts->pzPROGNAME );
+}
+
+
+/*
+ *  Emit the match text for a long option
+ */
+static void
+emitMatchExpr( tCC* pzMatchName, tOptDesc* pCurOpt, tOptions* pOpts )
+{
+    tOptDesc* pOD = pOpts->pOptDesc;
+    int       oCt = pOpts->optCt;
+    int       min = 1;
+    char      zName[ 256 ];
+    char*     pz  = zName;
+
+    for (;;) {
+        int matchCt = 0;
+
+        /*
+         *  Omit the current option, Documentation opts and compiled out opts.
+         */
+        if ((pOD == pCurOpt) || SKIP_OPT(pOD)){
+            if (--oCt <= 0)
+                break;
+            pOD++;
+            continue;
+        }
+
+        /*
+         *  Check each character of the name case insensitively.
+         *  They must not be the same.  They cannot be, because it would
+         *  not compile correctly if they were.
+         */
+        while (  toupper( pOD->pz_Name[matchCt] )
+              == toupper( pzMatchName[matchCt] ))
+            matchCt++;
+
+        if (matchCt > min)
+            min = matchCt;
+
+        /*
+         *  Check the disablement name, too.
+         */
+        if (pOD->pz_DisableName != NULL) {
+            matchCt = 0;
+            while (  toupper( pOD->pz_DisableName[matchCt] )
+                  == toupper( pzMatchName[matchCt] ))
+                matchCt++;
+            if (matchCt > min)
+                min = matchCt;
+        }
+        if (--oCt <= 0)
+            break;
+        pOD++;
+    }
+
+    /*
+     *  IF the 'min' is all or one short of the name length,
+     *  THEN the entire string must be matched.
+     */
+    if (  (pzMatchName[min  ] == NUL)
+       || (pzMatchName[min+1] == NUL) )
+        printf( zOptionFullName, pzMatchName );
+
+    else {
+        int matchCt = 0;
+        for (; matchCt <= min; matchCt++)
+            *pz++ = pzMatchName[matchCt];
+
+        for (;;) {
+            *pz = NUL;
+            printf( zOptionPartName, zName );
+            *pz++ = pzMatchName[matchCt++];
+            if (pzMatchName[matchCt] == NUL) {
+                *pz = NUL;
+                printf( zOptionFullName, zName );
+                break;
+            }
+        }
+    }
+}
+
+
+/*
+ *  Emit GNU-standard long option handling code
+ */
+static void
+emitLong( tOptions* pOpts )
+{
+    tOptDesc* pOD = pOpts->pOptDesc;
+    int       ct  = pOpts->optCt;
+
+    fputs( zOptionCase, stdout );
+
+    /*
+     *  do each option, ...
+     */
+    do  {
+        /*
+         *  Documentation & compiled-out options
+         */
+        if (SKIP_OPT(pOD))
+            continue;
+
+        emitMatchExpr( pOD->pz_Name, pOD, pOpts );
+        printOptionAction( pOpts, pOD );
+
+        /*
+         *  Now, do the same thing for the disablement version of the option.
+         */
+        if (pOD->pz_DisableName != NULL) {
+            emitMatchExpr( pOD->pz_DisableName, pOD, pOpts );
+            printOptionInaction( pOpts, pOD );
+        }
+    } while (pOD++, --ct > 0);
+
+    printf( zOptionUnknown, "option", pOpts->pzPROGNAME );
+}
+
+
+static void
+openOutput( char const* pzFile )
+{
+    FILE* fp;
+    char* pzData = NULL;
+    struct stat stbf;
+
+    do  {
+        char*    pzScan;
+        size_t sizeLeft;
+
+        /*
+         *  IF we cannot stat the file,
+         *  THEN assume we are creating a new file.
+         *       Skip the loading of the old data.
+         */
+        if (stat( pzFile, &stbf ) != 0)
+            break;
+
+        /*
+         *  The file must be a regular file
+         */
+        if (! S_ISREG( stbf.st_mode )) {
+            fprintf( stderr, zNotFile, pzFile );
+            exit( EXIT_FAILURE );
+        }
+
+        pzData = AGALOC(stbf.st_size + 1, "file data");
+        fp = fopen( pzFile, "r" FOPEN_BINARY_FLAG );
+
+        sizeLeft = (unsigned)stbf.st_size;
+        pzScan   = pzData;
+
+        /*
+         *  Read in all the data as fast as our OS will let us.
+         */
+        for (;;) {
+            int inct = fread( (void*)pzScan, (size_t)1, sizeLeft, fp);
+            if (inct == 0)
+                break;
+
+            pzScan   += inct;
+            sizeLeft -= inct;
+
+            if (sizeLeft == 0)
+                break;
+        }
+
+        /*
+         *  NUL-terminate the leader and look for the trailer
+         */
+        *pzScan = '\0';
+        fclose( fp );
+        pzScan  = strstr( pzData, zStartMarker );
+        if (pzScan == NULL) {
+            pzTrailer = pzData;
+            break;
+        }
+
+        *(pzScan++) = NUL;
+        pzScan  = strstr( pzScan, zTrailerMarker );
+        if (pzScan == NULL) {
+            pzTrailer = pzData;
+            break;
+        }
+
+        /*
+         *  Check to see if the data contains
+         *  our marker.  If it does, then we will skip over it
+         */
+        pzTrailer = pzScan + sizeof( zTrailerMarker ) - 1;
+        pzLeader  = pzData;
+    } while (AG_FALSE);
+
+    freopen( pzFile, "w" FOPEN_BINARY_FLAG, stdout );
+}
+
+
+/*=export_func genshelloptUsage
+ * private:
+ * what: The usage function for the genshellopt generated program
+ *
+ * arg:  + tOptions* + pOpts    + program options descriptor +
+ * arg:  + int       + exitCode + usage text type to produce +
+ *
+ * doc:
+ *  This function is used to create the usage strings for the option
+ *  processing shell script code.  Two child processes are spawned
+ *  each emitting the usage text in either the short (error exit)
+ *  style or the long style.  The generated program will capture this
+ *  and create shell script variables containing the two types of text.
+=*/
+void
+genshelloptUsage( tOptions*  pOpts, int exitCode )
+{
+#if defined(__windows__) && !defined(__CYGWIN__)
+    optionUsage( pOpts, exitCode );
+#else
+    /*
+     *  IF not EXIT_SUCCESS,
+     *  THEN emit the short form of usage.
+     */
+    if (exitCode != EXIT_SUCCESS)
+        optionUsage( pOpts, exitCode );
+    fflush( stderr );
+    fflush( stdout );
+
+    option_usage_fp = stdout;
+
+    /*
+     *  First, print our usage
+     */
+    switch (fork()) {
+    case -1:
+        optionUsage( pOpts, EXIT_FAILURE );
+        /*NOTREACHED*/
+        _exit( EXIT_FAILURE );
+
+    case 0:
+        pagerState = PAGER_STATE_CHILD;
+        optionUsage( pOpts, EXIT_SUCCESS );
+        /*NOTREACHED*/
+        _exit( EXIT_FAILURE );
+
+    default:
+    {
+        int  sts;
+        wait( &sts );
+    }
+    }
+
+    /*
+     *  Generate the pzProgName, since optionProcess() normally
+     *  gets it from the command line
+     */
+    {
+        char* pz;
+        AGDUPSTR( pz, pShellParseOptions->pzPROGNAME, "program name" );
+        pShellParseOptions->pzProgName = pz;
+        while (*pz != NUL) {
+            *pz = tolower( *pz );
+            pz++;
+        }
+    }
+
+    /*
+     *  Separate the makeshell usage from the client usage
+     */
+    fprintf( option_usage_fp, zGenshell, pShellParseOptions->pzProgName );
+    fflush( option_usage_fp );
+
+    /*
+     *  Now, print the client usage.
+     */
+    switch (fork()) {
+    case 0:
+        pagerState = PAGER_STATE_CHILD;
+        /*FALLTHROUGH*/
+    case -1:
+        optionUsage( pShellParseOptions, EXIT_FAILURE );
+
+    default:
+    {
+        int  sts;
+        wait( &sts );
+    }
+    }
+
+    exit( EXIT_SUCCESS );
+#endif
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/makeshell.c */
diff --git a/sntp/libopts/nested.c b/sntp/libopts/nested.c
new file mode 100644 (file)
index 0000000..b39f8d1
--- /dev/null
@@ -0,0 +1,733 @@
+
+/*
+ *  $Id: nested.c,v 4.14 2007/02/04 17:44:12 bkorb Exp $
+ *  Time-stamp:      "2007-01-26 11:04:35 bkorb"
+ *
+ *   Automated Options Nested Values module.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+removeBackslashes( char* pzSrc );
+
+static char const*
+scanQuotedString( char const* pzTxt );
+
+static tOptionValue*
+addStringValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen );
+
+static tOptionValue*
+addBoolValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen );
+
+static tOptionValue*
+addNumberValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen );
+
+static tOptionValue*
+addNestedValue( void** pp, char const* pzName, size_t nameLen,
+                char* pzValue, size_t dataLen );
+
+static char const*
+scanNameEntry(char const* pzName, tOptionValue* pRes);
+
+static char const*
+scanXmlEntry( char const* pzName, tOptionValue* pRes );
+
+static void
+unloadNestedArglist( tArgList* pAL );
+
+static void
+sortNestedList( tArgList* pAL );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*  removeBackslashes
+ *
+ *  This function assumes that all newline characters were preceeded by
+ *  backslashes that need removal.
+ */
+static void
+removeBackslashes( char* pzSrc )
+{
+    char* pzD = strchr(pzSrc, '\n');
+
+    if (pzD == NULL)
+        return;
+    *--pzD = '\n';
+
+    for (;;) {
+        char ch = ((*pzD++) = *(pzSrc++));
+        switch (ch) {
+        case '\n': *--pzD = ch; break;
+        case NUL:  return;
+        default:
+            ;
+        }
+    }
+}
+
+
+/*  scanQuotedString
+ *
+ *  Find the end of a quoted string, skipping escaped quote characters.
+ */
+static char const*
+scanQuotedString( char const* pzTxt )
+{
+    char q = *(pzTxt++); /* remember the type of quote */
+
+    for (;;) {
+        char ch = *(pzTxt++);
+        if (ch == NUL)
+            return pzTxt-1;
+
+        if (ch == q)
+            return pzTxt;
+
+        if (ch == '\\') {
+            ch = *(pzTxt++);
+            /*
+             *  IF the next character is NUL, drop the backslash, too.
+             */
+            if (ch == NUL)
+                return pzTxt - 2;
+
+            /*
+             *  IF the quote character or the escape character were escaped,
+             *  then skip both, as long as the string does not end.
+             */
+            if ((ch == q) || (ch == '\\')) {
+                if (*(pzTxt++) == NUL)
+                    return pzTxt-1;
+            }
+        }
+    }
+}
+
+
+/*  addStringValue
+ *
+ *  Associate a name with either a string or no value.
+ */
+static tOptionValue*
+addStringValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen )
+{
+    tOptionValue* pNV;
+    size_t sz = nameLen + dataLen + sizeof(*pNV);
+
+    pNV = AGALOC( sz, "option name/str value pair" );
+    if (pNV == NULL)
+        return NULL;
+
+    if (pzValue == NULL) {
+        pNV->valType = OPARG_TYPE_NONE;
+        pNV->pzName = pNV->v.strVal;
+
+    } else {
+        pNV->valType = OPARG_TYPE_STRING;
+        if (dataLen > 0)
+            memcpy( pNV->v.strVal, pzValue, dataLen );
+        pNV->v.strVal[dataLen] = NUL;
+        pNV->pzName = pNV->v.strVal + dataLen + 1;
+    }
+
+    memcpy( pNV->pzName, pzName, nameLen );
+    pNV->pzName[ nameLen ] = NUL;
+    addArgListEntry( pp, pNV );
+    return pNV;
+}
+
+
+/*  addBoolValue
+ *
+ *  Associate a name with either a string or no value.
+ */
+static tOptionValue*
+addBoolValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen )
+{
+    tOptionValue* pNV;
+    size_t sz = nameLen + sizeof(*pNV) + 1;
+
+    pNV = AGALOC( sz, "option name/bool value pair" );
+    if (pNV == NULL)
+        return NULL;
+    while (isspace( (int)*pzValue ) && (dataLen > 0)) {
+        dataLen--; pzValue++;
+    }
+    if (dataLen == 0)
+        pNV->v.boolVal = 0;
+    else if (isdigit( (int)*pzValue ))
+        pNV->v.boolVal = atoi( pzValue );
+    else switch (*pzValue) {
+    case 'f':
+    case 'F':
+    case 'n':
+    case 'N':
+        pNV->v.boolVal = 0; break;
+    default:
+        pNV->v.boolVal = 1;
+    }
+
+    pNV->valType = OPARG_TYPE_BOOLEAN;
+    pNV->pzName = (char*)(pNV + 1);
+    memcpy( pNV->pzName, pzName, nameLen );
+    pNV->pzName[ nameLen ] = NUL;
+    addArgListEntry( pp, pNV );
+    return pNV;
+}
+
+
+/*  addNumberValue
+ *
+ *  Associate a name with either a string or no value.
+ */
+static tOptionValue*
+addNumberValue( void** pp, char const* pzName, size_t nameLen,
+                char const* pzValue, size_t dataLen )
+{
+    tOptionValue* pNV;
+    size_t sz = nameLen + sizeof(*pNV) + 1;
+
+    pNV = AGALOC( sz, "option name/bool value pair" );
+    if (pNV == NULL)
+        return NULL;
+    while (isspace( (int)*pzValue ) && (dataLen > 0)) {
+        dataLen--; pzValue++;
+    }
+    if (dataLen == 0)
+        pNV->v.boolVal = 0;
+    else
+        pNV->v.boolVal = atoi( pzValue );
+
+    pNV->valType = OPARG_TYPE_NUMERIC;
+    pNV->pzName = (char*)(pNV + 1);
+    memcpy( pNV->pzName, pzName, nameLen );
+    pNV->pzName[ nameLen ] = NUL;
+    addArgListEntry( pp, pNV );
+    return pNV;
+}
+
+
+/*  addNestedValue
+ *
+ *  Associate a name with either a string or no value.
+ */
+static tOptionValue*
+addNestedValue( void** pp, char const* pzName, size_t nameLen,
+                char* pzValue, size_t dataLen )
+{
+    tOptionValue* pNV;
+
+    if (dataLen == 0) {
+        size_t sz = nameLen + sizeof(*pNV) + 1;
+        pNV = AGALOC( sz, "empty nested value pair" );
+        if (pNV == NULL)
+            return NULL;
+        pNV->v.nestVal = NULL;
+        pNV->valType = OPARG_TYPE_HIERARCHY;
+        pNV->pzName = (char*)(pNV + 1);
+        memcpy( pNV->pzName, pzName, nameLen );
+        pNV->pzName[ nameLen ] = NUL;
+
+    } else {
+        pNV = optionLoadNested( pzValue, pzName, nameLen );
+    }
+
+    if (pNV != NULL)
+        addArgListEntry( pp, pNV );
+
+    return pNV;
+}
+
+
+/*  scanNameEntry
+ *
+ *  We have an entry that starts with a name.  Find the end of it, cook it
+ *  (if called for) and create the name/value association.
+ */
+static char const*
+scanNameEntry(char const* pzName, tOptionValue* pRes)
+{
+    tOptionValue* pNV;
+    char const * pzScan = pzName+1;
+    char const * pzVal;
+    size_t       nameLen = 1;
+    size_t       dataLen = 0;
+
+    while (ISNAMECHAR( (int)*pzScan ))  { pzScan++; nameLen++; }
+
+    while (isspace( (int)*pzScan )) {
+        char ch = *(pzScan++);
+        if ((ch == '\n') || (ch == ',')) {
+            addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL,(size_t)0);
+            return pzScan - 1;
+        }
+    }
+
+    switch (*pzScan) {
+    case '=':
+    case ':':
+        while (isspace( (int)*++pzScan ))  ;
+        switch (*pzScan) {
+        case ',':  goto comma_char;
+        case '"':
+        case '\'': goto quote_char;
+        case NUL:  goto nul_byte;
+        default:   goto default_char;
+        }
+
+    case ',':
+    comma_char:
+        pzScan++;
+        /* FALLTHROUGH */
+
+    case NUL:
+    nul_byte:
+        addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
+        break;
+
+    case '"':
+    case '\'':
+    quote_char:
+        pzVal = pzScan;
+        pzScan = scanQuotedString( pzScan );
+        dataLen = pzScan - pzVal;
+        pNV = addStringValue( &(pRes->v.nestVal), pzName, nameLen, pzVal,
+                              dataLen );
+        if ((pNV != NULL) && (option_load_mode == OPTION_LOAD_COOKED))
+            ao_string_cook( pNV->v.strVal, NULL );
+        break;
+
+    default:
+    default_char:
+        /*
+         *  We have found some strange text value.  It ends with a newline
+         *  or a comma.
+         */
+        pzVal = pzScan;
+        for (;;) {
+            char ch = *(pzScan++);
+            switch (ch) {
+            case NUL:
+                pzScan--;
+                dataLen = pzScan - pzVal;
+                goto string_done;
+                /* FALLTHROUGH */
+
+            case '\n':
+                if (   (pzScan > pzVal + 2)
+                    && (pzScan[-2] == '\\')
+                    && (pzScan[ 0] != NUL))
+                    continue;
+                /* FALLTHROUGH */
+
+            case ',':
+                dataLen = (pzScan - pzVal) - 1;
+            string_done:
+                pNV = addStringValue( &(pRes->v.nestVal), pzName, nameLen,
+                                      pzVal, dataLen );
+                if (pNV != NULL)
+                    removeBackslashes( pNV->v.strVal );
+                goto leave_scan_name;
+            }
+        }
+        break;
+    } leave_scan_name:;
+
+    return pzScan;
+}
+
+
+/*  scanXmlEntry
+ *
+ *  We've found a '<' character.  We ignore this if it is a comment or a
+ *  directive.  If it is something else, then whatever it is we are looking
+ *  at is bogus.  Returning NULL stops processing.
+ */
+static char const*
+scanXmlEntry( char const* pzName, tOptionValue* pRes )
+{
+    size_t nameLen = 1, valLen = 0;
+    char const*   pzScan = ++pzName;
+    char const*   pzVal;
+    tOptionValue  valu;
+    tOptionValue* pNewVal;
+    tOptionLoadMode save_mode = option_load_mode;
+
+    if (! isalpha((int)*pzName)) {
+        switch (*pzName) {
+        default:
+            pzName = NULL;
+            break;
+
+        case '!':
+            pzName = strstr( pzName, "-->" );
+            if (pzName != NULL)
+                pzName += 3;
+            break;
+
+        case '?':
+            pzName = strchr( pzName, '>' );
+            if (pzName != NULL)
+                pzName++;
+            break;
+        }
+        return pzName;
+    }
+
+    while (isalpha( (int)*++pzScan ))  nameLen++;
+    if (nameLen > 64)
+        return NULL;
+    valu.valType = OPARG_TYPE_STRING;
+
+    switch (*pzScan) {
+    case ' ':
+    case '\t':
+        pzScan = parseAttributes(
+            NULL, (char*)pzScan, &option_load_mode, &valu );
+        if (*pzScan == '>') {
+            pzScan++;
+            break;
+        }
+
+        if (*pzScan != '/') {
+            option_load_mode = save_mode;
+            return NULL;
+        }
+        /* FALLTHROUGH */
+
+    case '/':
+        if (*++pzScan != '>') {
+            option_load_mode = save_mode;
+            return NULL;
+        }
+        addStringValue(&(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
+        option_load_mode = save_mode;
+        return pzScan+2;
+
+    default:
+        option_load_mode = save_mode;
+        return NULL;
+
+    case '>':
+        pzScan++;
+        break;
+    }
+
+    pzVal = pzScan;
+
+    {
+        char z[68];
+        char* pzD = z;
+        int  ct = nameLen;
+        char const* pzS = pzName;
+
+        *(pzD++) = '<';
+        *(pzD++) = '/';
+
+        do  {
+            *(pzD++) = *(pzS++);
+        } while (--ct > 0);
+        *(pzD++) = '>';
+        *pzD = NUL;
+
+        pzScan = strstr( pzScan, z );
+        if (pzScan == NULL) {
+            option_load_mode = save_mode;
+            return NULL;
+        }
+        valLen = (pzScan - pzVal);
+        pzScan += nameLen + 3;
+        while (isspace(  (int)*pzScan ))  pzScan++;
+    }
+
+    switch (valu.valType) {
+    case OPARG_TYPE_NONE:
+        addStringValue( &(pRes->v.nestVal), pzName, nameLen, NULL, (size_t)0);
+        break;
+
+    case OPARG_TYPE_STRING:
+        pNewVal = addStringValue(
+            &(pRes->v.nestVal), pzName, nameLen, pzVal, valLen);
+
+        if (option_load_mode == OPTION_LOAD_KEEP)
+            break;
+        mungeString( pNewVal->v.strVal, option_load_mode );
+        break;
+
+    case OPARG_TYPE_BOOLEAN:
+        addBoolValue( &(pRes->v.nestVal), pzName, nameLen, pzVal, valLen );
+        break;
+
+    case OPARG_TYPE_NUMERIC:
+        addNumberValue( &(pRes->v.nestVal), pzName, nameLen, pzVal, valLen );
+        break;
+
+    case OPARG_TYPE_HIERARCHY:
+    {
+        char* pz = AGALOC( valLen+1, "hierarchical scan" );
+        if (pz == NULL)
+            break;
+        memcpy( pz, pzVal, valLen );
+        pz[valLen] = NUL;
+        addNestedValue( &(pRes->v.nestVal), pzName, nameLen, pz, valLen );
+        AGFREE(pz);
+        break;
+    }
+
+    case OPARG_TYPE_ENUMERATION:
+    case OPARG_TYPE_MEMBERSHIP:
+    default:
+        break;
+    }
+
+    option_load_mode = save_mode;
+    return pzScan;
+}
+
+
+/*  unloadNestedArglist
+ *
+ *  Deallocate a list of option arguments.  This must have been gotten from
+ *  a hierarchical option argument, not a stacked list of strings.  It is
+ *  an internal call, so it is not validated.  The caller is responsible for
+ *  knowing what they are doing.
+ */
+static void
+unloadNestedArglist( tArgList* pAL )
+{
+    int ct = pAL->useCt;
+    tCC** ppNV = pAL->apzArgs;
+
+    while (ct-- > 0) {
+        tOptionValue* pNV = (tOptionValue*)(void*)*(ppNV++);
+        if (pNV->valType == OPARG_TYPE_HIERARCHY)
+            unloadNestedArglist( pNV->v.nestVal );
+        AGFREE( pNV );
+    }
+
+    AGFREE( (void*)pAL );
+}
+
+
+/*=export_func  optionUnloadNested
+ *
+ * what:  Deallocate the memory for a nested value
+ * arg:   + tOptionValue const * + pOptVal + the hierarchical value +
+ *
+ * doc:
+ *  A nested value needs to be deallocated.  The pointer passed in should
+ *  have been gotten from a call to @code{configFileLoad()} (See
+ *  @pxref{libopts-configFileLoad}).
+=*/
+void
+optionUnloadNested( tOptionValue const * pOV )
+{
+    if (pOV == NULL) return;
+    if (pOV->valType != OPARG_TYPE_HIERARCHY) {
+        errno = EINVAL;
+        return;
+    }
+
+    unloadNestedArglist( pOV->v.nestVal );
+
+    AGFREE( (void*)pOV );
+}
+
+
+/*  sortNestedList
+ *
+ *  This is a _stable_ sort.  The entries are sorted alphabetically,
+ *  but within entries of the same name the ordering is unchanged.
+ *  Typically, we also hope the input is sorted.
+ */
+static void
+sortNestedList( tArgList* pAL )
+{
+    int ix;
+    int lm = pAL->useCt;
+
+    /*
+     *  This loop iterates "useCt" - 1 times.
+     */
+    for (ix = 0; ++ix < lm;) {
+        int iy = ix-1;
+        tOptionValue* pNewNV = (tOptionValue*)(void*)(pAL->apzArgs[ix]);
+        tOptionValue* pOldNV = (tOptionValue*)(void*)(pAL->apzArgs[iy]);
+
+        /*
+         *  For as long as the new entry precedes the "old" entry,
+         *  move the old pointer.  Stop before trying to extract the
+         *  "-1" entry.
+         */
+        while (strcmp( pOldNV->pzName, pNewNV->pzName ) > 0) {
+            pAL->apzArgs[iy+1] = (void*)pOldNV;
+            pOldNV = (tOptionValue*)(void*)(pAL->apzArgs[--iy]);
+            if (iy < 0)
+                break;
+        }
+
+        /*
+         *  Always store the pointer.  Sometimes it is redundant,
+         *  but the redundancy is cheaper than a test and branch sequence.
+         */
+        pAL->apzArgs[iy+1] = (void*)pNewNV;
+    }
+}
+
+
+/* optionLoadNested
+ * private:
+ *
+ * what:  parse a hierarchical option argument
+ * arg:   + char const*     + pzTxt   + the text to scan +
+ * arg:   + char const*     + pzName  + the name for the text +
+ * arg:   + size_t          + nameLen + the length of "name"  +
+ *
+ * ret_type:  tOptionValue*
+ * ret_desc:  An allocated, compound value structure
+ *
+ * doc:
+ *  A block of text represents a series of values.  It may be an
+ *  entire configuration file, or it may be an argument to an
+ *  option that takes a hierarchical value.
+ */
+LOCAL tOptionValue*
+optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen)
+{
+    tOptionValue* pRes;
+    tArgList*     pAL;
+
+    /*
+     *  Make sure we have some data and we have space to put what we find.
+     */
+    if (pzTxt == NULL) {
+        errno = EINVAL;
+        return NULL;
+    }
+    while (isspace( (int)*pzTxt ))  pzTxt++;
+    if (*pzTxt == NUL) {
+        errno = ENOENT;
+        return NULL;
+    }
+    pRes = AGALOC( sizeof(*pRes) + nameLen + 1, "nested args" );
+    if (pRes == NULL) {
+        errno = ENOMEM;
+        return NULL;
+    }
+    pRes->valType   = OPARG_TYPE_HIERARCHY;
+    pRes->pzName    = (char*)(pRes + 1);
+    memcpy( pRes->pzName, pzName, nameLen );
+    pRes->pzName[ nameLen ] = NUL;
+
+    pAL = AGALOC( sizeof(*pAL), "nested arg list" );
+    if (pAL == NULL) {
+        AGFREE( pRes );
+        return NULL;
+    }
+    pRes->v.nestVal = pAL;
+    pAL->useCt   = 0;
+    pAL->allocCt = MIN_ARG_ALLOC_CT;
+
+    /*
+     *  Scan until we hit a NUL.
+     */
+    do  {
+        while (isspace( (int)*pzTxt ))  pzTxt++;
+        if (isalpha( (int)*pzTxt )) {
+            pzTxt = scanNameEntry( pzTxt, pRes );
+        }
+        else switch (*pzTxt) {
+        case NUL: goto scan_done;
+        case '<': pzTxt = scanXmlEntry( pzTxt, pRes );
+                  if (*pzTxt == ',') pzTxt++;     break;
+        case '#': pzTxt = strchr( pzTxt, '\n' );  break;
+        default:  goto woops;
+        }
+    } while (pzTxt != NULL); scan_done:;
+
+    pAL = pRes->v.nestVal;
+    if (pAL->useCt != 0) {
+        sortNestedList( pAL );
+        return pRes;
+    }
+
+ woops:
+    AGFREE( pRes->v.nestVal );
+    AGFREE( pRes );
+    return NULL;
+}
+
+
+/*=export_func  optionNestedVal
+ * private:
+ *
+ * what:  parse a hierarchical option argument
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Nested value was found on the command line
+=*/
+void
+optionNestedVal( tOptions* pOpts, tOptDesc* pOD )
+{
+    tOptionValue* pOV = optionLoadNested(
+        pOD->optArg.argString, pOD->pz_Name, strlen(pOD->pz_Name));
+
+    if (pOV != NULL)
+        addArgListEntry( &(pOD->optCookie), (void*)pOV );
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/nested.c */
diff --git a/sntp/libopts/numeric.c b/sntp/libopts/numeric.c
new file mode 100644 (file)
index 0000000..05ee9b5
--- /dev/null
@@ -0,0 +1,93 @@
+
+/*
+ *  $Id: numeric.c,v 4.11 2007/02/04 17:44:12 bkorb Exp $
+ *  Time-stamp:      "2007-01-13 10:28:20 bkorb"
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/*=export_func  optionNumericVal
+ * private:
+ *
+ * what:  Decipher a boolean value
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Decipher a numeric value.
+=*/
+void
+optionNumericVal( tOptions* pOpts, tOptDesc* pOD )
+{
+    char* pz;
+    long  val;
+
+    /*
+     *  Numeric options may have a range associated with it.
+     *  If it does, the usage procedure requests that it be
+     *  emitted by passing a NULL pOD pointer.
+     */
+    if ((pOD == NULL) || (pOD->optArg.argString == NULL))
+        return;
+
+    val = strtol( pOD->optArg.argString, &pz, 0 );
+    if (*pz != NUL) {
+        fprintf( stderr, zNotNumber, pOpts->pzProgName, pOD->optArg.argString );
+        (*(pOpts->pUsageProc))(pOpts, EXIT_FAILURE);
+    }
+
+    if (pOD->fOptState & OPTST_ALLOC_ARG) {
+        AGFREE(pOD->optArg.argString);
+        pOD->fOptState &= ~OPTST_ALLOC_ARG;
+    }
+
+    pOD->optArg.argInt = val;
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/numeric.c */
diff --git a/sntp/libopts/pgusage.c b/sntp/libopts/pgusage.c
new file mode 100644 (file)
index 0000000..c417c63
--- /dev/null
@@ -0,0 +1,157 @@
+
+/*
+ *  $Id: pgusage.c,v 4.12 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2006-07-16 08:13:26 bkorb"
+ *
+ *   Automated Options Paged Usage module.
+ *
+ *  This routine will run run-on options through a pager so the
+ *  user may examine, print or edit them at their leisure.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+tePagerState pagerState = PAGER_STATE_INITIAL;
+
+/*=export_func  optionPagedUsage
+ * private:
+ *
+ * what:  Decipher a boolean value
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Run the usage output through a pager.
+ *  This is very handy if it is very long.
+=*/
+void
+optionPagedUsage( tOptions* pOptions, tOptDesc* pOD )
+{
+#if defined(__windows__) && !defined(__CYGWIN__)
+    (*pOptions->pUsageProc)( pOptions, EXIT_SUCCESS );
+#else
+    static pid_t     my_pid;
+    char zPageUsage[ 1024 ];
+
+    /*
+     *  IF we are being called after the usage proc is done
+     *     (and thus has called "exit(2)")
+     *  THEN invoke the pager to page through the usage file we created.
+     */
+    switch (pagerState) {
+    case PAGER_STATE_INITIAL:
+    {
+        my_pid  = getpid();
+#ifdef HAVE_SNPRINTF
+        snprintf(zPageUsage, sizeof(zPageUsage), "/tmp/use.%lu", (tAoUL)my_pid);
+#else
+        sprintf( zPageUsage, "/tmp/use.%lu", (tAoUL)my_pid );
+#endif
+        unlink( zPageUsage );
+
+        /*
+         *  Set usage output to this temporary file
+         */
+        option_usage_fp = fopen( zPageUsage, "w" FOPEN_BINARY_FLAG );
+        if (option_usage_fp == NULL)
+            _exit( EXIT_FAILURE );
+
+        pagerState = PAGER_STATE_READY;
+
+        /*
+         *  Set up so this routine gets called during the exit logic
+         */
+        atexit( (void(*)(void))optionPagedUsage );
+
+        /*
+         *  The usage procedure will now put the usage information into
+         *  the temporary file we created above.
+         */
+        (*pOptions->pUsageProc)( pOptions, EXIT_SUCCESS );
+
+        /*NOTREACHED*/
+        _exit( EXIT_FAILURE );
+    }
+
+    case PAGER_STATE_READY:
+    {
+        tSCC zPage[]  = "%1$s /tmp/use.%2$lu ; rm -f /tmp/use.%2$lu";
+        tCC* pzPager  = (tCC*)getenv( "PAGER" );
+
+        /*
+         *  Use the "more(1)" program if "PAGER" has not been defined
+         */
+        if (pzPager == NULL)
+            pzPager = "more";
+
+        /*
+         *  Page the file and remove it when done.
+         */
+#ifdef HAVE_SNPRINTF
+        snprintf(zPageUsage, sizeof(zPageUsage), zPage, pzPager, (tAoUL)my_pid);
+#else
+        sprintf( zPageUsage, zPage, pzPager, (tAoUL)my_pid );
+#endif
+        fclose( stderr );
+        dup2( STDOUT_FILENO, STDERR_FILENO );
+
+        (void)system( zPageUsage );
+    }
+
+    case PAGER_STATE_CHILD:
+        /*
+         *  This is a child process used in creating shell script usage.
+         */
+        break;
+    }
+#endif
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/pgusage.c */
diff --git a/sntp/libopts/proto.h b/sntp/libopts/proto.h
new file mode 100644 (file)
index 0000000..e87ab87
--- /dev/null
@@ -0,0 +1,91 @@
+/* -*- buffer-read-only: t -*- vi: set ro:
+ *
+ * Prototypes for autoopts
+ * Generated Sat May  5 12:02:36 PDT 2007
+ */
+#ifndef AUTOOPTS_PROTO_H_GUARD
+#define AUTOOPTS_PROTO_H_GUARD 1
+#ifndef LOCAL
+#  define LOCAL extern
+#  define REDEF_LOCAL 1
+#else
+#  undef  REDEF_LOCAL
+#endif
+/*\n *  Extracted from autoopts.c\n */
+LOCAL void *
+ao_malloc( size_t sz );
+
+LOCAL void *
+ao_realloc( void *p, size_t sz );
+
+LOCAL void
+ao_free( void *p );
+
+LOCAL char *
+ao_strdup( char const *str );
+
+LOCAL tSuccess
+handleOption( tOptions* pOpts, tOptState* pOptState );
+
+LOCAL tSuccess
+longOptionFind( tOptions* pOpts, char* pzOptName, tOptState* pOptState );
+
+LOCAL tSuccess
+shortOptionFind( tOptions* pOpts, uint_t optValue, tOptState* pOptState );
+
+LOCAL tSuccess
+doImmediateOpts( tOptions* pOpts );
+
+LOCAL tSuccess
+doRegularOpts( tOptions* pOpts );
+
+/*\n *  Extracted from configfile.c\n */
+LOCAL void
+internalFileLoad( tOptions* pOpts );
+
+LOCAL char*
+parseAttributes(
+    tOptions*           pOpts,
+    char*               pzText,
+    tOptionLoadMode*    pMode,
+    tOptionValue*       pType );
+
+LOCAL tSuccess
+validateOptionsStruct( tOptions* pOpts, char const* pzProgram );
+
+/*\n *  Extracted from environment.c\n */
+LOCAL void
+doPrognameEnv( tOptions* pOpts, teEnvPresetType type );
+
+LOCAL void
+doEnvPresets( tOptions* pOpts, teEnvPresetType type );
+
+/*\n *  Extracted from load.c\n */
+LOCAL void
+mungeString( char* pzTxt, tOptionLoadMode mode );
+
+LOCAL void
+loadOptionLine(
+    tOptions*   pOpts,
+    tOptState*  pOS,
+    char*       pzLine,
+    tDirection  direction,
+    tOptionLoadMode   load_mode );
+
+/*\n *  Extracted from nested.c\n */
+LOCAL tOptionValue*
+optionLoadNested(char const* pzTxt, char const* pzName, size_t nameLen);
+
+/*\n *  Extracted from sort.c\n */
+LOCAL void
+optionSort( tOptions* pOpts );
+
+/*\n *  Extracted from stack.c\n */
+LOCAL void
+addArgListEntry( void** ppAL, void* entry );
+
+#ifdef REDEF_LOCAL
+#  undef LOCAL
+#  define LOCAL
+#endif
+#endif /* AUTOOPTS_PROTO_H_GUARD */
diff --git a/sntp/libopts/putshell.c b/sntp/libopts/putshell.c
new file mode 100644 (file)
index 0000000..93d9ef5
--- /dev/null
@@ -0,0 +1,335 @@
+
+/*
+ *  $Id: putshell.c,v 4.18 2007/02/04 17:44:12 bkorb Exp $
+ * Time-stamp:      "2007-01-13 10:29:39 bkorb"
+ *
+ *  This module will interpret the options set in the tOptions
+ *  structure and print them to standard out in a fashion that
+ *  will allow them to be interpreted by the Bourne or Korn shells.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+putQuotedStr( tCC* pzStr );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*
+ *  Make sure embedded single quotes come out okay.  The initial quote has
+ *  been emitted and the closing quote will be upon return.
+ */
+static void
+putQuotedStr( tCC* pzStr )
+{
+    /*
+     *  Handle empty strings to make the rest of the logic simpler.
+     */
+    if ((pzStr == NULL) || (*pzStr == NUL)) {
+        fputs( "''", stdout );
+        return;
+    }
+
+    /*
+     *  Emit any single quotes/apostrophes at the start of the string and
+     *  bail if that is all we need to do.
+     */
+    while (*pzStr == '\'') {
+        fputs( "\\'", stdout );
+        pzStr++;
+    }
+    if (*pzStr == NUL)
+        return;
+
+    /*
+     *  Start the single quote string
+     */
+    fputc( '\'', stdout );
+    for (;;) {
+        tCC* pz = strchr( pzStr, '\'' );
+        if (pz == NULL)
+            break;
+
+        /*
+         *  Emit the string up to the single quote (apostrophe) we just found.
+         */
+        (void)fwrite( pzStr, (size_t)(pz - pzStr), (size_t)1, stdout );
+        fputc( '\'', stdout );
+        pzStr = pz;
+
+        /*
+         *  Emit an escaped apostrophe for every one we find.
+         *  If that ends the string, do not re-open the single quotes.
+         */
+        while (*++pzStr == '\'')   fputs( "\\'", stdout );
+        if (*pzStr == NUL)
+            return;
+
+        fputc( '\'', stdout );
+    }
+
+    /*
+     *  If we broke out of the loop, we must still emit the remaining text
+     *  and then close the single quote string.
+     */
+    fputs( pzStr, stdout );
+    fputc( '\'', stdout );
+}
+
+
+/*=export_func  optionPutShell
+ * what:  write a portable shell script to parse options
+ * private:
+ * arg:   tOptions*, pOpts, the program options descriptor
+ * doc:   This routine will emit portable shell script text for parsing
+ *        the options described in the option definitions.
+=*/
+void
+optionPutShell( tOptions* pOpts )
+{
+    int  optIx = 0;
+    tSCC zOptCtFmt[]  = "OPTION_CT=%d\nexport OPTION_CT\n";
+    tSCC zOptNumFmt[] = "%1$s_%2$s=%3$d # 0x%3$X\nexport %1$s_%2$s\n";
+    tSCC zOptDisabl[] = "%1$s_%2$s=%3$s\nexport %1$s_%2$s\n";
+    tSCC zOptValFmt[] = "%s_%s=";
+    tSCC zOptEnd[]    = "\nexport %s_%s\n";
+    tSCC zFullOptFmt[]= "%1$s_%2$s='%3$s'\nexport %1$s_%2$s\n";
+    tSCC zEquivMode[] = "%1$s_%2$s_MODE='%3$s'\nexport %1$s_%2$s_MODE\n";
+
+    printf( zOptCtFmt, pOpts->curOptIdx-1 );
+
+    do  {
+        tOptDesc* pOD = pOpts->pOptDesc + optIx;
+
+        if (SKIP_OPT(pOD))
+            continue;
+
+        /*
+         *  Equivalence classes are hard to deal with.  Where the
+         *  option data wind up kind of squishes around.  For the purposes
+         *  of emitting shell state, they are not recommended, but we'll
+         *  do something.  I guess we'll emit the equivalenced-to option
+         *  at the point in time when the base option is found.
+         */
+        if (pOD->optEquivIndex != NO_EQUIVALENT)
+            continue; /* equivalence to a different option */
+
+        /*
+         *  Equivalenced to a different option.  Process the current option
+         *  as the equivalenced-to option.  Keep the persistent state bits,
+         *  but copy over the set-state bits.
+         */
+        if (pOD->optActualIndex != optIx) {
+            tOptDesc* p   = pOpts->pOptDesc + pOD->optActualIndex;
+            p->optArg     = pOD->optArg;
+            p->fOptState &= OPTST_PERSISTENT_MASK;
+            p->fOptState |= pOD->fOptState & ~OPTST_PERSISTENT_MASK;
+            printf( zEquivMode, pOpts->pzPROGNAME, pOD->pz_NAME, p->pz_NAME );
+            pOD = p;
+        }
+
+        /*
+         *  If the argument type is a set membership bitmask, then we always
+         *  emit the thing.  We do this because it will always have some sort
+         *  of bitmask value and we need to emit the bit values.
+         */
+        if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP) {
+            char const * pz;
+            uintptr_t val = 1;
+            printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
+                    (int)(uintptr_t)(pOD->optCookie) );
+            pOD->optCookie = (void*)(uintptr_t)~0UL;
+            (*(pOD->pOptProc))( (tOptions*)2UL, pOD );
+
+            /*
+             *  We are building the typeset list.  The list returned starts with
+             *  'none + ' for use by option saving stuff.  We must ignore that.
+             */
+            pz = pOD->optArg.argString + 7;
+            while (*pz != NUL) {
+                printf( "typeset -x -i %s_", pOD->pz_NAME );
+                pz += strspn( pz, " +\t\n\f" );
+                for (;;) {
+                    int ch = *(pz++);
+                         if (islower( ch ))  fputc( toupper( ch ), stdout );
+                    else if (isalnum( ch ))  fputc( ch, stdout );
+                    else if (isspace( ch )
+                          || (ch == '+'))    goto name_done;
+                    else if (ch == NUL)      { pz--; goto name_done; }
+                    else fputc( '_', stdout );
+                } name_done:;
+                printf( "=%1$lu # 0x%1$lX\n", (unsigned long)val );
+                val <<= 1;
+            }
+
+            AGFREE(pOD->optArg.argString);
+            pOD->optArg.argString = NULL;
+            pOD->fOptState &= ~OPTST_ALLOC_ARG;
+            continue;
+        }
+
+        /*
+         *  IF the option was either specified or it wakes up enabled,
+         *  then we will emit information.  Otherwise, skip it.
+         *  The idea is that if someone defines an option to initialize
+         *  enabled, we should tell our shell script that it is enabled.
+         */
+        if (UNUSED_OPT( pOD ) && DISABLED_OPT( pOD ))
+            continue;
+
+        /*
+         *  Handle stacked arguments
+         */
+        if (  (pOD->fOptState & OPTST_STACKED)
+           && (pOD->optCookie != NULL) )  {
+            tSCC zOptCookieCt[] = "%1$s_%2$s_CT=%3$d\nexport %1$s_%2$s_CT\n";
+
+            tArgList*    pAL = (tArgList*)pOD->optCookie;
+            tCC**        ppz = pAL->apzArgs;
+            int          ct  = pAL->useCt;
+
+            printf( zOptCookieCt, pOpts->pzPROGNAME, pOD->pz_NAME, ct );
+
+            while (--ct >= 0) {
+                tSCC numarg_z[] = "%s_%s_%d=";
+                tSCC end_z[]    = "\nexport %s_%s_%d\n";
+
+                printf( numarg_z, pOpts->pzPROGNAME, pOD->pz_NAME,
+                        pAL->useCt - ct );
+                putQuotedStr( *(ppz++) );
+                printf( end_z, pOpts->pzPROGNAME, pOD->pz_NAME,
+                        pAL->useCt - ct );
+            }
+        }
+
+        /*
+         *  If the argument has been disabled,
+         *  Then set its value to the disablement string
+         */
+        else if ((pOD->fOptState & OPTST_DISABLED) != 0)
+            printf( zOptDisabl, pOpts->pzPROGNAME, pOD->pz_NAME,
+                    (pOD->pz_DisablePfx != NULL)
+                    ? pOD->pz_DisablePfx : "false" );
+
+        /*
+         *  If the argument type is numeric, the last arg pointer
+         *  is really the VALUE of the string that was pointed to.
+         */
+        else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NUMERIC)
+            printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
+                    (int)pOD->optArg.argInt );
+
+        /*
+         *  If the argument type is an enumeration, then it is much
+         *  like a text value, except we call the callback function
+         *  to emit the value corresponding to the "optArg" number.
+         */
+        else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_ENUMERATION) {
+            printf( zOptValFmt, pOpts->pzPROGNAME, pOD->pz_NAME );
+            fputc( '\'', stdout );
+            (*(pOD->pOptProc))( (tOptions*)1UL, pOD );
+            fputc( '\'', stdout );
+            printf( zOptEnd, pOpts->pzPROGNAME, pOD->pz_NAME );
+        }
+
+        /*
+         *  If the argument type is numeric, the last arg pointer
+         *  is really the VALUE of the string that was pointed to.
+         */
+        else if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_BOOLEAN)
+            printf( zFullOptFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
+                    (pOD->optArg.argBool == 0) ? "false" : "true" );
+
+        /*
+         *  IF the option has an empty value,
+         *  THEN we set the argument to the occurrence count.
+         */
+        else if (  (pOD->optArg.argString == NULL)
+                || (pOD->optArg.argString[0] == NUL) )
+
+            printf( zOptNumFmt, pOpts->pzPROGNAME, pOD->pz_NAME,
+                    pOD->optOccCt );
+
+        /*
+         *  This option has a text value
+         */
+        else {
+            printf( zOptValFmt, pOpts->pzPROGNAME, pOD->pz_NAME );
+            putQuotedStr( pOD->optArg.argString );
+            printf( zOptEnd, pOpts->pzPROGNAME, pOD->pz_NAME );
+        }
+    } while (++optIx < pOpts->presetOptCt );
+
+    if (  ((pOpts->fOptSet & OPTPROC_REORDER) != 0)
+       && (pOpts->curOptIdx < pOpts->origArgCt)) {
+        fputs( "set --", stdout );
+        for (optIx = pOpts->curOptIdx; optIx < pOpts->origArgCt; optIx++) {
+            char* pzArg = pOpts->origArgVect[ optIx ];
+            if (strchr( pzArg, '\'' ) == NULL)
+                printf( " '%s'", pzArg );
+            else {
+                fputs( " '", stdout );
+                for (;;) {
+                    char ch = *(pzArg++);
+                    switch (ch) {
+                    case '\'':  fputs( "'\\''", stdout ); break;
+                    case NUL:   goto arg_done;
+                    default:    fputc( ch, stdout ); break;
+                    }
+                } arg_done:;
+                fputc( '\'', stdout );
+            }
+        }
+        fputs( "\nOPTION_CT=0\n", stdout );
+    }
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/putshell.c */
diff --git a/sntp/libopts/restore.c b/sntp/libopts/restore.c
new file mode 100644 (file)
index 0000000..91eac08
--- /dev/null
@@ -0,0 +1,250 @@
+
+/*
+ *  restore.c  $Id: restore.c,v 4.10 2007/02/04 17:44:12 bkorb Exp $
+ * Time-stamp:      "2007-01-13 14:13:17 bkorb"
+ *
+ *  This module's routines will save the current option state to memory
+ *  and restore it.  If saved prior to the initial optionProcess call,
+ *  then the initial state will be restored.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/*
+ *  optionFixupSavedOpts  Really, it just wipes out option state for
+ *  options that are troublesome to copy.  viz., stacked strings and
+ *  hierarcicaly valued option args.  We do duplicate string args that
+ *  have been marked as allocated though.
+ */
+static void
+fixupSavedOptionArgs(tOptions* pOpts)
+{
+    tOptions* p   = pOpts->pSavedState;
+    tOptDesc* pOD = pOpts->pOptDesc;
+    int       ct  = pOpts->optCt;
+
+    /*
+     *  Make sure that allocated stuff is only referenced in the
+     *  archived copy of the data.
+     */
+    for (; ct-- > 0; pOD++)  {
+        switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+        case OPARG_TYPE_STRING:
+            if (pOD->fOptState & OPTST_STACKED) {
+                tOptDesc* q = p->pOptDesc + (pOD - pOpts->pOptDesc);
+                q->optCookie = NULL;
+            }
+            if (pOD->fOptState & OPTST_ALLOC_ARG) {
+                tOptDesc* q = p->pOptDesc + (pOD - pOpts->pOptDesc);
+                AGDUPSTR(q->optArg.argString, pOD->optArg.argString, "arg");
+            }
+            break;
+
+        case OPARG_TYPE_HIERARCHY:
+        {
+            tOptDesc* q = p->pOptDesc + (pOD - pOpts->pOptDesc);
+            q->optCookie = NULL;
+        }
+        }
+    }
+}
+
+/*=export_func optionSaveState
+ *
+ * what:  saves the option state to memory
+ * arg:   tOptions*, pOpts, program options descriptor
+ *
+ * doc:
+ *
+ *  This routine will allocate enough memory to save the current option
+ *  processing state.  If this routine has been called before, that memory
+ *  will be reused.  You may only save one copy of the option state.  This
+ *  routine may be called before optionProcess(3AO).  If you do call it
+ *  before the first call to optionProcess, then you may also change the
+ *  contents of argc/argv after you call optionRestore(3AO)
+ *
+ *  In fact, more strongly put: it is safest to only use this function
+ *  before having processed any options.  In particular, the saving and
+ *  restoring of stacked string arguments and hierarchical values is
+ *  disabled.  The values are not saved.
+ *
+ * err:   If it fails to allocate the memory,
+ *        it will print a message to stderr and exit.
+ *        Otherwise, it will always succeed.
+=*/
+void
+optionSaveState(tOptions* pOpts)
+{
+    tOptions* p = (tOptions*)pOpts->pSavedState;
+
+    if (p == NULL) {
+        size_t sz = sizeof( *pOpts ) + (pOpts->optCt * sizeof( tOptDesc ));
+        p = AGALOC( sz, "saved option state" );
+        if (p == NULL) {
+            tCC* pzName = pOpts->pzProgName;
+            if (pzName == NULL) {
+                pzName = pOpts->pzPROGNAME;
+                if (pzName == NULL)
+                    pzName = zNil;
+            }
+            fprintf( stderr, zCantSave, pzName, sz );
+            exit( EXIT_FAILURE );
+        }
+
+        pOpts->pSavedState = p;
+    }
+
+    memcpy( p, pOpts, sizeof( *p ));
+    memcpy( p + 1, pOpts->pOptDesc, p->optCt * sizeof( tOptDesc ));
+
+    fixupSavedOptionArgs(pOpts);
+}
+
+
+/*=export_func optionRestore
+ *
+ * what:  restore option state from memory copy
+ * arg:   tOptions*, pOpts, program options descriptor
+ *
+ * doc:  Copy back the option state from saved memory.
+ *       The allocated memory is left intact, so this routine can be
+ *       called repeatedly without having to call optionSaveState again.
+ *       If you are restoring a state that was saved before the first call
+ *       to optionProcess(3AO), then you may change the contents of the
+ *       argc/argv parameters to optionProcess.
+ *
+ * err:  If you have not called @code{optionSaveState} before, a diagnostic is
+ *       printed to @code{stderr} and exit is called.
+=*/
+void
+optionRestore( tOptions* pOpts )
+{
+    tOptions* p = (tOptions*)pOpts->pSavedState;
+
+    if (p == NULL) {
+        tCC* pzName = pOpts->pzProgName;
+        if (pzName == NULL) {
+            pzName = pOpts->pzPROGNAME;
+            if (pzName == NULL)
+                pzName = zNil;
+        }
+        fprintf( stderr, zNoState, pzName );
+        exit( EXIT_FAILURE );
+    }
+
+    pOpts->pSavedState = NULL;
+    optionFree(pOpts);
+
+    memcpy( pOpts, p, sizeof( *p ));
+    memcpy( pOpts->pOptDesc, p+1, p->optCt * sizeof( tOptDesc ));
+    pOpts->pSavedState = p;
+
+    fixupSavedOptionArgs(pOpts);
+}
+
+/* = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = = */
+
+/*=export_func optionFree
+ *
+ * what:  free allocated option processing memory
+ * arg:   tOptions*, pOpts, program options descriptor
+ *
+ * doc:   AutoOpts sometimes allocates memory and puts pointers to it in the
+ *        option state structures.  This routine deallocates all such memory.
+ *
+ * err:   As long as memory has not been corrupted,
+ *        this routine is always successful.
+=*/
+void
+optionFree( tOptions* pOpts )
+{
+ free_saved_state:
+    {
+        tOptDesc* p = pOpts->pOptDesc;
+        int ct = pOpts->optCt;
+        do  {
+            if (p->fOptState & OPTST_ALLOC_ARG) {
+                AGFREE(p->optArg.argString);
+                p->optArg.argString = NULL;
+                p->fOptState &= ~OPTST_ALLOC_ARG;
+            }
+
+            switch (OPTST_GET_ARGTYPE(p->fOptState)) {
+            case OPARG_TYPE_STRING:
+#ifdef WITH_LIBREGEX
+                if (  (p->fOptState & OPTST_STACKED)
+                   && (p->optCookie != NULL)) {
+                    p->optArg.argString = ".*";
+                    optionUnstackArg(pOpts, p);
+                }
+#else
+                /* leak memory */;
+#endif
+                break;
+
+            case OPARG_TYPE_HIERARCHY:
+                if (p->optCookie != NULL)
+                    unloadNestedArglist(p->optCookie);
+                break;
+            }
+
+            p->optCookie = NULL;
+        } while (p++, --ct > 0);
+    }
+    if (pOpts->pSavedState != NULL) {
+        tOptions * p = (tOptions*)pOpts->pSavedState;
+        memcpy( pOpts, p, sizeof( *p ));
+        memcpy( pOpts->pOptDesc, p+1, p->optCt * sizeof( tOptDesc ));
+        AGFREE( pOpts->pSavedState );
+        pOpts->pSavedState = NULL;
+        goto free_saved_state;
+    }
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/restore.c */
diff --git a/sntp/libopts/save.c b/sntp/libopts/save.c
new file mode 100644 (file)
index 0000000..c889520
--- /dev/null
@@ -0,0 +1,521 @@
+
+/*
+ *  save.c  $Id: save.c,v 4.18 2007/04/15 19:01:18 bkorb Exp $
+ * Time-stamp:      "2007-04-15 11:11:10 bkorb"
+ *
+ *  This module's routines will take the currently set options and
+ *  store them into an ".rc" file for re-interpretation the next
+ *  time the invoking program is run.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+tSCC  zWarn[] = "%s WARNING:  cannot save options - ";
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static tCC*
+findDirName( tOptions* pOpts, int* p_free );
+
+static tCC*
+findFileName( tOptions* pOpts, int* p_free_name );
+
+static void
+printEntry(
+    FILE *     fp,
+    tOptDesc * p,
+    tCC*       pzLA );
+/* = = = END-STATIC-FORWARD = = = */
+
+static tCC*
+findDirName( tOptions* pOpts, int* p_free )
+{
+    tCC*  pzDir;
+
+    if (pOpts->specOptIdx.save_opts == 0)
+        return NULL;
+
+    pzDir = pOpts->pOptDesc[ pOpts->specOptIdx.save_opts ].optArg.argString;
+    if ((pzDir != NULL) && (*pzDir != NUL))
+        return pzDir;
+
+    /*
+     *  This function only works if there is a directory where
+     *  we can stash the RC (INI) file.
+     */
+    {
+        tCC* const* papz = pOpts->papzHomeList;
+        if (papz == NULL)
+            return NULL;
+
+        while (papz[1] != NULL) papz++;
+        pzDir = *papz;
+    }
+
+    /*
+     *  IF it does not require deciphering an env value, then just copy it
+     */
+    if (*pzDir != '$')
+        return pzDir;
+
+    {
+        tCC*  pzEndDir = strchr( ++pzDir, DIRCH );
+        char* pzFileName;
+        char* pzEnv;
+
+        if (pzEndDir != NULL) {
+            char z[ AO_NAME_SIZE ];
+            if ((pzEndDir - pzDir) > AO_NAME_LIMIT )
+                return NULL;
+            strncpy( z, pzDir, (size_t)(pzEndDir - pzDir) );
+            z[ (pzEndDir - pzDir) ] = NUL;
+            pzEnv = getenv( z );
+        } else {
+
+            /*
+             *  Make sure we can get the env value (after stripping off
+             *  any trailing directory or file names)
+             */
+            pzEnv = getenv( pzDir );
+        }
+
+        if (pzEnv == NULL) {
+            fprintf( stderr, zWarn, pOpts->pzProgName );
+            fprintf( stderr, zNotDef, pzDir );
+            return NULL;
+        }
+
+        if (pzEndDir == NULL)
+            return pzEnv;
+
+        {
+            size_t sz = strlen( pzEnv ) + strlen( pzEndDir ) + 2;
+            pzFileName = (char*)AGALOC( sz, "dir name" );
+        }
+
+        if (pzFileName == NULL)
+            return NULL;
+
+        *p_free = 1;
+        /*
+         *  Glue together the full name into the allocated memory.
+         *  FIXME: We lose track of this memory.
+         */
+        sprintf( pzFileName, "%s/%s", pzEnv, pzEndDir );
+        return pzFileName;
+    }
+}
+
+
+static tCC*
+findFileName( tOptions* pOpts, int* p_free_name )
+{
+    tCC*   pzDir;
+    struct stat stBuf;
+    int    free_dir_name = 0;
+
+    pzDir = findDirName( pOpts, &free_dir_name );
+    if (pzDir == NULL)
+        return NULL;
+
+    /*
+     *  See if we can find the specified directory.  We use a once-only loop
+     *  structure so we can bail out early.
+     */
+    if (stat( pzDir, &stBuf ) != 0) do {
+
+        /*
+         *  IF we could not, check to see if we got a full
+         *  path to a file name that has not been created yet.
+         */
+        if (errno == ENOENT) {
+            char z[AG_PATH_MAX];
+
+            /*
+             *  Strip off the last component, stat the remaining string and
+             *  that string must name a directory
+             */
+            char* pzDirCh = strrchr( pzDir, DIRCH );
+            if (pzDirCh == NULL) {
+                stBuf.st_mode = S_IFREG;
+                continue;  /* bail out of error condition */
+            }
+
+            strncpy( z, pzDir, (size_t)(pzDirCh - pzDir));
+            z[ pzDirCh - pzDir ] = NUL;
+
+            if (  (stat( z, &stBuf ) == 0)
+               && S_ISDIR( stBuf.st_mode )) {
+
+                /*
+                 *  We found the directory.  Restore the file name and
+                 *  mark the full name as a regular file
+                 */
+                stBuf.st_mode = S_IFREG;
+                continue;  /* bail out of error condition */
+            }
+        }
+
+        /*
+         *  We got a bogus name.
+         */
+        fprintf( stderr, zWarn, pOpts->pzProgName );
+        fprintf( stderr, zNoStat, errno, strerror( errno ), pzDir );
+        if (free_dir_name)
+            AGFREE( (void*)pzDir );
+        return NULL;
+    } while (0);
+
+    /*
+     *  IF what we found was a directory,
+     *  THEN tack on the config file name
+     */
+    if (S_ISDIR( stBuf.st_mode )) {
+        size_t sz = strlen( pzDir ) + strlen( pOpts->pzRcName ) + 2;
+
+        {
+            char*  pzPath = (char*)AGALOC( sz, "file name" );
+#ifdef HAVE_SNPRINTF
+            snprintf( pzPath, sz, "%s/%s", pzDir, pOpts->pzRcName );
+#else
+            sprintf( pzPath, "%s/%s", pzDir, pOpts->pzRcName );
+#endif
+            if (free_dir_name)
+                AGFREE( (void*)pzDir );
+            pzDir = pzPath;
+            free_dir_name = 1;
+        }
+
+        /*
+         *  IF we cannot stat the object for any reason other than
+         *     it does not exist, then we bail out
+         */
+        if (stat( pzDir, &stBuf ) != 0) {
+            if (errno != ENOENT) {
+                fprintf( stderr, zWarn, pOpts->pzProgName );
+                fprintf( stderr, zNoStat, errno, strerror( errno ),
+                         pzDir );
+                AGFREE( (void*)pzDir );
+                return NULL;
+            }
+
+            /*
+             *  It does not exist yet, but it will be a regular file
+             */
+            stBuf.st_mode = S_IFREG;
+        }
+    }
+
+    /*
+     *  Make sure that whatever we ultimately found, that it either is
+     *  or will soon be a file.
+     */
+    if (! S_ISREG( stBuf.st_mode )) {
+        fprintf( stderr, zWarn, pOpts->pzProgName );
+        fprintf( stderr, zNotFile, pzDir );
+        if (free_dir_name)
+            AGFREE( (void*)pzDir );
+        return NULL;
+    }
+
+    /*
+     *  Get rid of the old file
+     */
+    unlink( pzDir );
+    *p_free_name = free_dir_name;
+    return pzDir;
+}
+
+
+static void
+printEntry(
+    FILE *     fp,
+    tOptDesc * p,
+    tCC*       pzLA )
+{
+    /*
+     *  There is an argument.  Pad the name so values line up.
+     *  Not disabled *OR* this got equivalenced to another opt,
+     *  then use current option name.
+     *  Otherwise, there must be a disablement name.
+     */
+    {
+        char const * pz;
+        if (! DISABLED_OPT(p) || (p->optEquivIndex != NO_EQUIVALENT))
+            pz = p->pz_Name;
+        else
+            pz = p->pz_DisableName;
+
+        fprintf(fp, "%-18s", pz);
+    }
+    /*
+     *  IF the option is numeric only,
+     *  THEN the char pointer is really the number
+     */
+    if (OPTST_GET_ARGTYPE(p->fOptState) == OPARG_TYPE_NUMERIC)
+        fprintf( fp, "  %d\n", (int)(t_word)pzLA );
+
+    /*
+     *  OTHERWISE, FOR each line of the value text, ...
+     */
+    else if (pzLA == NULL)
+        fputc( '\n', fp );
+
+    else {
+        fputc( ' ', fp ); fputc( ' ', fp );
+        for (;;) {
+            tCC* pzNl = strchr( pzLA, '\n' );
+
+            /*
+             *  IF this is the last line
+             *  THEN bail and print it
+             */
+            if (pzNl == NULL)
+                break;
+
+            /*
+             *  Print the continuation and the text from the current line
+             */
+            (void)fwrite( pzLA, (size_t)(pzNl - pzLA), (size_t)1, fp );
+            pzLA = pzNl+1; /* advance the Last Arg pointer */
+            fputs( "\\\n", fp );
+        }
+
+        /*
+         *  Terminate the entry
+         */
+        fputs( pzLA, fp );
+        fputc( '\n', fp );
+    }
+}
+
+
+/*=export_func  optionSaveFile
+ *
+ * what:  saves the option state to a file
+ *
+ * arg:   tOptions*,   pOpts,  program options descriptor
+ *
+ * doc:
+ *
+ * This routine will save the state of option processing to a file.  The name
+ * of that file can be specified with the argument to the @code{--save-opts}
+ * option, or by appending the @code{rcfile} attribute to the last
+ * @code{homerc} attribute.  If no @code{rcfile} attribute was specified, it
+ * will default to @code{.@i{programname}rc}.  If you wish to specify another
+ * file, you should invoke the @code{SET_OPT_SAVE_OPTS( @i{filename} )} macro.
+ *
+ * err:
+ *
+ * If no @code{homerc} file was specified, this routine will silently return
+ * and do nothing.  If the output file cannot be created or updated, a message
+ * will be printed to @code{stderr} and the routine will return.
+=*/
+void
+optionSaveFile( tOptions* pOpts )
+{
+    tOptDesc* pOD;
+    int       ct;
+    FILE*     fp;
+
+    {
+        int   free_name = 0;
+        tCC*  pzFName = findFileName( pOpts, &free_name );
+        if (pzFName == NULL)
+            return;
+
+        fp = fopen( pzFName, "w" FOPEN_BINARY_FLAG );
+        if (fp == NULL) {
+            fprintf( stderr, zWarn, pOpts->pzProgName );
+            fprintf( stderr, zNoCreat, errno, strerror( errno ), pzFName );
+            if (free_name)
+                AGFREE((void*) pzFName );
+            return;
+        }
+
+        if (free_name)
+            AGFREE( (void*)pzFName );
+    }
+
+    {
+        char const*  pz = pOpts->pzUsageTitle;
+        fputs( "#  ", fp );
+        do { fputc( *pz, fp ); } while (*(pz++) != '\n');
+    }
+
+    {
+        time_t  timeVal = time( NULL );
+        char*   pzTime  = ctime( &timeVal );
+
+        fprintf( fp, zPresetFile, pzTime );
+#ifdef HAVE_ALLOCATED_CTIME
+        /*
+         *  The return values for ctime(), localtime(), and gmtime()
+         *  normally point to static data that is overwritten by each call.
+         *  The test to detect allocated ctime, so we leak the memory.
+         */
+        AGFREE( (void*)pzTime );
+#endif
+    }
+
+    /*
+     *  FOR each of the defined options, ...
+     */
+    ct  = pOpts->presetOptCt;
+    pOD = pOpts->pOptDesc;
+    do  {
+        int arg_state;
+        tOptDesc*  p;
+
+        /*
+         *  IF    the option has not been defined
+         *     OR it does not take an initialization value
+         *     OR it is equivalenced to another option
+         *  THEN continue (ignore it)
+         */
+        if (UNUSED_OPT( pOD ))
+            continue;
+
+        if ((pOD->fOptState & (OPTST_NO_INIT|OPTST_DOCUMENT|OPTST_OMITTED))
+            != 0)
+            continue;
+
+        if (  (pOD->optEquivIndex != NO_EQUIVALENT)
+              && (pOD->optEquivIndex != pOD->optIndex))
+            continue;
+
+        /*
+         *  Set a temporary pointer to the real option description
+         *  (i.e. account for equivalencing)
+         */
+        p = ((pOD->fOptState & OPTST_EQUIVALENCE) != 0)
+            ? (pOpts->pOptDesc + pOD->optActualIndex) : pOD;
+
+        /*
+         *  IF    no arguments are allowed
+         *  THEN just print the name and continue
+         */
+        if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NONE) {
+            char const * pznm =
+                (DISABLED_OPT( p )) ? p->pz_DisableName : p->pz_Name;
+            /*
+             *  If the option was disabled and the disablement name is NULL,
+             *  then the disablement was caused by aliasing.
+             *  Use the name as the string to emit.
+             */
+            if (pznm == NULL)
+                pznm = p->pz_Name;
+
+            fprintf(fp, "%s\n", pznm);
+            continue;
+        }
+
+        arg_state = OPTST_GET_ARGTYPE(p->fOptState);
+        switch (arg_state) {
+        case 0:
+        case OPARG_TYPE_NUMERIC:
+            printEntry( fp, p, (void*)(p->optArg.argInt));
+            break;
+
+        case OPARG_TYPE_STRING:
+            if (p->fOptState & OPTST_STACKED) {
+                tArgList*  pAL = (tArgList*)p->optCookie;
+                int        uct = pAL->useCt;
+                tCC**      ppz = pAL->apzArgs;
+
+                /*
+                 *  Disallow multiple copies of disabled options.
+                 */
+                if (uct > 1)
+                    p->fOptState &= ~OPTST_DISABLED;
+
+                while (uct-- > 0)
+                    printEntry( fp, p, *(ppz++) );
+            } else {
+                printEntry( fp, p, p->optArg.argString );
+            }
+            break;
+
+        case OPARG_TYPE_ENUMERATION:
+        case OPARG_TYPE_MEMBERSHIP:
+        {
+            uintptr_t val = p->optArg.argEnum;
+            /*
+             *  This is a magic incantation that will convert the
+             *  bit flag values back into a string suitable for printing.
+             */
+            (*(p->pOptProc))( (tOptions*)2UL, p );
+            printEntry( fp, p, (void*)(p->optArg.argString));
+
+            if (  (p->optArg.argString != NULL)
+               && (arg_state != OPARG_TYPE_ENUMERATION)) {
+                /*
+                 *  set membership strings get allocated
+                 */
+                AGFREE( (void*)p->optArg.argString );
+                p->fOptState &= ~OPTST_ALLOC_ARG;
+            }
+
+            p->optArg.argEnum = val;
+            break;
+        }
+
+        case OPARG_TYPE_BOOLEAN:
+            printEntry( fp, p, p->optArg.argBool ? "true" : "false" );
+            break;
+
+        default:
+            break; /* cannot handle - skip it */
+        }
+    } while ( (pOD++), (--ct > 0));
+
+    fclose( fp );
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/save.c */
diff --git a/sntp/libopts/sort.c b/sntp/libopts/sort.c
new file mode 100644 (file)
index 0000000..ead7133
--- /dev/null
@@ -0,0 +1,359 @@
+
+/*
+ *  sort.c  $Id: sort.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2006-10-18 11:29:04 bkorb"
+ *
+ *  This module implements argument sorting.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static tSuccess
+mustHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS,
+               char** ppzOpts, int* pOptsIdx );
+
+static tSuccess
+mayHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS,
+              char** ppzOpts, int* pOptsIdx );
+
+static tSuccess
+checkShortOpts( tOptions* pOpts, char* pzArg, tOptState* pOS,
+                char** ppzOpts, int* pOptsIdx );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*
+ *  "mustHandleArg" and "mayHandleArg" are really similar.  The biggest
+ *  difference is that "may" will consume the next argument only if it
+ *  does not start with a hyphen and "must" will consume it, hyphen or not.
+ */
+static tSuccess
+mustHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS,
+               char** ppzOpts, int* pOptsIdx )
+{
+    /*
+     *  An option argument is required.  Long options can either have
+     *  a separate command line argument, or an argument attached by
+     *  the '=' character.  Figure out which.
+     */
+    switch (pOS->optType) {
+    case TOPT_SHORT:
+        /*
+         *  See if an arg string follows the flag character.  If not,
+         *  the next arg must be the option argument.
+         */
+        if (*pzArg != NUL)
+            return SUCCESS;
+        break;
+
+    case TOPT_LONG:
+        /*
+         *  See if an arg string has already been assigned (glued on
+         *  with an `=' character).  If not, the next is the opt arg.
+         */
+        if (pOS->pzOptArg != NULL)
+            return SUCCESS;
+        break;
+
+    default:
+        return FAILURE;
+    }
+    if (pOpts->curOptIdx >= pOpts->origArgCt)
+        return FAILURE;
+
+    ppzOpts[ (*pOptsIdx)++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+    return SUCCESS;
+}
+
+static tSuccess
+mayHandleArg( tOptions* pOpts, char* pzArg, tOptState* pOS,
+              char** ppzOpts, int* pOptsIdx )
+{
+    /*
+     *  An option argument is optional.
+     */
+    switch (pOS->optType) {
+    case TOPT_SHORT:
+        /*
+         *  IF nothing is glued on after the current flag character,
+         *  THEN see if there is another argument.  If so and if it
+         *  does *NOT* start with a hyphen, then it is the option arg.
+         */
+        if (*pzArg != NUL)
+            return SUCCESS;
+        break;
+
+    case TOPT_LONG:
+        /*
+         *  Look for an argument if we don't already have one (glued on
+         *  with a `=' character)
+         */
+        if (pOS->pzOptArg != NULL)
+            return SUCCESS;
+        break;
+
+    default:
+        return FAILURE;
+    }
+    if (pOpts->curOptIdx >= pOpts->origArgCt)
+        return PROBLEM;
+
+    pzArg = pOpts->origArgVect[ pOpts->curOptIdx ];
+    if (*pzArg != '-')
+        ppzOpts[ (*pOptsIdx)++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+    return SUCCESS;
+}
+
+/*
+ *  Process a string of short options glued together.  If the last one
+ *  does or may take an argument, the do the argument processing and leave.
+ */
+static tSuccess
+checkShortOpts( tOptions* pOpts, char* pzArg, tOptState* pOS,
+                char** ppzOpts, int* pOptsIdx )
+{
+    while (*pzArg != NUL) {
+        if (FAILED( shortOptionFind( pOpts, (tAoUC)*pzArg, pOS )))
+            return FAILURE;
+
+        /*
+         *  See if we can have an arg.
+         */
+        if (OPTST_GET_ARGTYPE(pOS->pOD->fOptState) == OPARG_TYPE_NONE) {
+            pzArg++;
+
+        } else if (pOS->pOD->fOptState & OPTST_ARG_OPTIONAL) {
+            /*
+             *  Take an argument if it is not attached and it does not
+             *  start with a hyphen.
+             */
+            if (pzArg[1] != NUL)
+                return SUCCESS;
+
+            pzArg = pOpts->origArgVect[ pOpts->curOptIdx ];
+            if (*pzArg != '-')
+                ppzOpts[ (*pOptsIdx)++ ] =
+                    pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+            return SUCCESS;
+
+        } else {
+            /*
+             *  IF we need another argument, be sure it is there and
+             *  take it.
+             */
+            if (pzArg[1] == NUL) {
+                if (pOpts->curOptIdx >= pOpts->origArgCt)
+                    return FAILURE;
+                ppzOpts[ (*pOptsIdx)++ ] =
+                    pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+            }
+            return SUCCESS;
+        }
+    }
+    return SUCCESS;
+}
+
+/*
+ *  If the program wants sorted options (separated operands and options),
+ *  then this routine will to the trick.
+ */
+LOCAL void
+optionSort( tOptions* pOpts )
+{
+    char** ppzOpts;
+    char** ppzOpds;
+    int    optsIdx = 0;
+    int    opdsIdx = 0;
+
+    tOptState os = OPTSTATE_INITIALIZER(DEFINED);
+
+    /*
+     *  Disable for POSIX conformance, or if there are no operands.
+     */
+    if (  (getenv( "POSIXLY_CORRECT" ) != NULL)
+       || NAMED_OPTS(pOpts))
+        return;
+
+    /*
+     *  Make sure we can allocate two full-sized arg vectors.
+     */
+    ppzOpts = malloc( pOpts->origArgCt * sizeof( char* ));
+    if (ppzOpts == NULL)
+        goto exit_no_mem;
+
+    ppzOpds = malloc( pOpts->origArgCt * sizeof( char* ));
+    if (ppzOpds == NULL) {
+        free( ppzOpts );
+        goto exit_no_mem;
+    }
+
+    pOpts->curOptIdx = 1;
+    pOpts->pzCurOpt  = NULL;
+
+    /*
+     *  Now, process all the options from our current position onward.
+     *  (This allows interspersed options and arguments for the few
+     *  non-standard programs that require it.)
+     */
+    for (;;) {
+        char* pzArg;
+        tSuccess res;
+
+        /*
+         *  If we're out of arguments, we're done.  Join the option and
+         *  operand lists into the original argument vector.
+         */
+        if (pOpts->curOptIdx >= pOpts->origArgCt) {
+            errno = 0;
+            goto joinLists;
+        }
+
+        pzArg = pOpts->origArgVect[ pOpts->curOptIdx ];
+        if (*pzArg != '-') {
+            ppzOpds[ opdsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+            continue;
+        }
+
+        switch (pzArg[1]) {
+        case NUL:
+            /*
+             *  A single hyphen is an operand.
+             */
+            ppzOpds[ opdsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+            continue;
+
+        case '-':
+            /*
+             *  Two consecutive hypens.  Put them on the options list and then
+             *  _always_ force the remainder of the arguments to be operands.
+             */
+            if (pzArg[2] == NUL) {
+                ppzOpts[ optsIdx++ ] =
+                    pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+                goto restOperands;
+            }
+            res = longOptionFind( pOpts, pzArg+2, &os );
+            break;
+
+        default:
+            /*
+             *  If short options are not allowed, then do long
+             *  option processing.  Otherwise the character must be a
+             *  short (i.e. single character) option.
+             */
+            if ((pOpts->fOptSet & OPTPROC_SHORTOPT) == 0) {
+                res = longOptionFind( pOpts, pzArg+1, &os );
+            } else {
+                res = shortOptionFind( pOpts, (tAoUC)pzArg[1], &os );
+            }
+            break;
+        }
+        if (FAILED( res )) {
+            errno = EINVAL;
+            goto freeTemps;
+        }
+
+        /*
+         *  We've found an option.  Add the argument to the option list.
+         *  Next, we have to see if we need to pull another argument to be
+         *  used as the option argument.
+         */
+        ppzOpts[ optsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+
+        if (OPTST_GET_ARGTYPE(os.pOD->fOptState) == OPARG_TYPE_NONE) {
+            /*
+             *  No option argument.  If we have a short option here,
+             *  then scan for short options until we get to the end
+             *  of the argument string.
+             */
+            if (  (os.optType == TOPT_SHORT)
+               && FAILED( checkShortOpts( pOpts, pzArg+2, &os,
+                                          ppzOpts, &optsIdx )) )  {
+                errno = EINVAL;
+                goto freeTemps;
+            }
+
+        } else if (os.pOD->fOptState & OPTST_ARG_OPTIONAL) {
+            switch (mayHandleArg( pOpts, pzArg+2, &os, ppzOpts, &optsIdx )) {
+            case FAILURE: errno = EIO; goto freeTemps;
+            case PROBLEM: errno = 0;   goto joinLists;
+            }
+
+        } else {
+            switch (mustHandleArg( pOpts, pzArg+2, &os, ppzOpts, &optsIdx )) {
+            case PROBLEM:
+            case FAILURE: errno = EIO; goto freeTemps;
+            }
+        }
+    } /* for (;;) */
+
+ restOperands:
+    while (pOpts->curOptIdx < pOpts->origArgCt)
+        ppzOpds[ opdsIdx++ ] = pOpts->origArgVect[ (pOpts->curOptIdx)++ ];
+
+ joinLists:
+    if (optsIdx > 0)
+        memcpy( pOpts->origArgVect + 1, ppzOpts, optsIdx * sizeof( char* ));
+    if (opdsIdx > 0)
+        memcpy( pOpts->origArgVect + 1 + optsIdx,
+                ppzOpds, opdsIdx * sizeof( char* ));
+
+ freeTemps:
+    free( ppzOpts );
+    free( ppzOpds );
+    return;
+
+ exit_no_mem:
+    errno = ENOMEM;
+    return;
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/sort.c */
diff --git a/sntp/libopts/stack.c b/sntp/libopts/stack.c
new file mode 100644 (file)
index 0000000..6d77f72
--- /dev/null
@@ -0,0 +1,269 @@
+
+/*
+ *  stack.c
+ *  $Id: stack.c,v 4.13 2007/02/04 17:44:12 bkorb Exp $
+ *  Time-stamp:      "2007-01-13 10:43:21 bkorb"
+ *
+ *  This is a special option processing routine that will save the
+ *  argument to an option in a FIFO queue.
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+#ifdef WITH_LIBREGEX
+#  include REGEX_HEADER
+#endif
+
+/*=export_func  optionUnstackArg
+ * private:
+ *
+ * what:  Remove option args from a stack
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Invoked for options that are equivalenced to stacked options.
+=*/
+void
+optionUnstackArg(
+    tOptions*  pOpts,
+    tOptDesc*  pOptDesc )
+{
+    int       res;
+
+    tArgList* pAL = (tArgList*)pOptDesc->optCookie;
+    /*
+     *  IF we don't have any stacked options,
+     *  THEN indicate that we don't have any of these options
+     */
+    if (pAL == NULL) {
+        pOptDesc->fOptState &= OPTST_PERSISTENT_MASK;
+        if ( (pOptDesc->fOptState & OPTST_INITENABLED) == 0)
+            pOptDesc->fOptState |= OPTST_DISABLED;
+        return;
+    }
+
+#ifdef WITH_LIBREGEX
+    {
+        regex_t   re;
+        int       i, ct, dIdx;
+
+        if (regcomp( &re, pOptDesc->optArg.argString, REG_NOSUB ) != 0)
+            return;
+
+        /*
+         *  search the list for the entry(s) to remove.  Entries that
+         *  are removed are *not* copied into the result.  The source
+         *  index is incremented every time.  The destination only when
+         *  we are keeping a define.
+         */
+        for (i = 0, dIdx = 0, ct = pAL->useCt; --ct >= 0; i++) {
+            tCC*      pzSrc = pAL->apzArgs[ i ];
+            char*     pzEq  = strchr( pzSrc, '=' );
+
+            if (pzEq != NULL)
+                *pzEq = NUL;
+
+            res = regexec( &re, pzSrc, (size_t)0, NULL, 0 );
+            switch (res) {
+            case 0:
+                /*
+                 *  Remove this entry by reducing the in-use count
+                 *  and *not* putting the string pointer back into
+                 *  the list.
+                 */
+                AGFREE(pzSrc);
+                pAL->useCt--;
+                break;
+
+            default:
+            case REG_NOMATCH:
+                if (pzEq != NULL)
+                    *pzEq = '=';
+
+                /*
+                 *  IF we have dropped an entry
+                 *  THEN we have to move the current one.
+                 */
+                if (dIdx != i)
+                    pAL->apzArgs[ dIdx ] = pzSrc;
+                dIdx++;
+            }
+        }
+
+        regfree( &re );
+    }
+#else  /* not WITH_LIBREGEX */
+    {
+        int i, ct, dIdx;
+
+        /*
+         *  search the list for the entry(s) to remove.  Entries that
+         *  are removed are *not* copied into the result.  The source
+         *  index is incremented every time.  The destination only when
+         *  we are keeping a define.
+         */
+        for (i = 0, dIdx = 0, ct = pAL->useCt; --ct >= 0; i++) {
+            tCC*      pzSrc = pAL->apzArgs[ i ];
+            char*     pzEq  = strchr( pzSrc, '=' );
+
+            if (pzEq != NULL)
+                *pzEq = NUL;
+
+            if (strcmp( pzSrc, pOptDesc->optArg.argString ) == 0) {
+                /*
+                 *  Remove this entry by reducing the in-use count
+                 *  and *not* putting the string pointer back into
+                 *  the list.
+                 */
+                AGFREE(pzSrc);
+                pAL->useCt--;
+            } else {
+                if (pzEq != NULL)
+                    *pzEq = '=';
+
+                /*
+                 *  IF we have dropped an entry
+                 *  THEN we have to move the current one.
+                 */
+                if (dIdx != i)
+                    pAL->apzArgs[ dIdx ] = pzSrc;
+                dIdx++;
+            }
+        }
+    }
+#endif /* WITH_LIBREGEX */
+    /*
+     *  IF we have unstacked everything,
+     *  THEN indicate that we don't have any of these options
+     */
+    if (pAL->useCt == 0) {
+        pOptDesc->fOptState &= OPTST_PERSISTENT_MASK;
+        if ( (pOptDesc->fOptState & OPTST_INITENABLED) == 0)
+            pOptDesc->fOptState |= OPTST_DISABLED;
+        AGFREE( (void*)pAL );
+        pOptDesc->optCookie = NULL;
+    }
+}
+
+
+/*
+ *  Put an entry into an argument list.  The first argument points to
+ *  a pointer to the argument list structure.  It gets passed around
+ *  as an opaque address.
+ */
+LOCAL void
+addArgListEntry( void** ppAL, void* entry )
+{
+    tArgList* pAL = *(void**)ppAL;
+
+    /*
+     *  IF we have never allocated one of these,
+     *  THEN allocate one now
+     */
+    if (pAL == NULL) {
+        pAL = (tArgList*)AGALOC( sizeof( *pAL ), "new option arg stack" );
+        if (pAL == NULL)
+            return;
+        pAL->useCt   = 0;
+        pAL->allocCt = MIN_ARG_ALLOC_CT;
+        *ppAL = (void*)pAL;
+    }
+
+    /*
+     *  ELSE if we are out of room
+     *  THEN make it bigger
+     */
+    else if (pAL->useCt >= pAL->allocCt) {
+        size_t sz = sizeof( *pAL );
+        pAL->allocCt += INCR_ARG_ALLOC_CT;
+
+        /*
+         *  The base structure contains space for MIN_ARG_ALLOC_CT
+         *  pointers.  We subtract it off to find our augment size.
+         */
+        sz += sizeof(char*) * (pAL->allocCt - MIN_ARG_ALLOC_CT);
+        pAL = (tArgList*)AGREALOC( (void*)pAL, sz, "expanded opt arg stack" );
+        if (pAL == NULL)
+            return;
+        *ppAL = (void*)pAL;
+    }
+
+    /*
+     *  Insert the new argument into the list
+     */
+    pAL->apzArgs[ (pAL->useCt)++ ] = entry;
+}
+
+
+/*=export_func  optionStackArg
+ * private:
+ *
+ * what:  put option args on a stack
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  Keep an entry-ordered list of option arguments.
+=*/
+void
+optionStackArg(
+    tOptions*  pOpts,
+    tOptDesc*  pOD )
+{
+    char * pz;
+
+    if (pOD->optArg.argString == NULL)
+        return;
+
+    AGDUPSTR(pz, pOD->optArg.argString, "stack arg");
+    addArgListEntry( &(pOD->optCookie), (void*)pz );
+}
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/stack.c */
diff --git a/sntp/libopts/streqvcmp.c b/sntp/libopts/streqvcmp.c
new file mode 100644 (file)
index 0000000..8249794
--- /dev/null
@@ -0,0 +1,289 @@
+
+/*
+ *  $Id: streqvcmp.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2006-07-26 18:25:53 bkorb"
+ *
+ *  String Equivalence Comparison
+ *
+ *  These routines allow any character to be mapped to any other
+ *  character before comparison.  In processing long option names,
+ *  the characters "-", "_" and "^" all need to be equivalent
+ *  (because they are treated so by different development environments).
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/*
+ * This array is designed for mapping upper and lower case letter
+ * together for a case independent comparison.  The mappings are
+ * based upon ascii character sequences.
+ */
+static unsigned char charmap[] = {
+    0x00, 0x01, 0x02, 0x03,  0x04, 0x05, 0x06, '\a',
+    '\b', '\t', '\n', '\v',  '\f', '\r', 0x0E, 0x0F,
+    0x10, 0x11, 0x12, 0x13,  0x14, 0x15, 0x16, 0x17,
+    0x18, 0x19, 0x1A, 0x1B,  0x1C, 0x1D, 0x1E, 0x1F,
+
+    ' ',  '!',  '"',  '#',   '$',  '%',  '&',  '\'',
+    '(',  ')',  '*',  '+',   ',',  '-',  '.',  '/',
+    '0',  '1',  '2',  '3',   '4',  '5',  '6',  '7',
+    '8',  '9',  ':',  ';',   '<',  '=',  '>',  '?',
+
+    '@',  'a',  'b',  'c',   'd',  'e',  'f',  'g',
+    'h',  'i',  'j',  'k',   'l',  'm',  'n',  'o',
+    'p',  'q',  'r',  's',   't',  'u',  'v',  'w',
+    'x',  'y',  'z',  '[',   '\\', ']',  '^',  '_',
+    '`',  'a',  'b',  'c',   'd',  'e',  'f',  'g',
+    'h',  'i',  'j',  'k',   'l',  'm',  'n',  'o',
+    'p',  'q',  'r',  's',   't',  'u',  'v',  'w',
+    'x',  'y',  'z',  '{',   '|',  '}',  '~',  0x7f,
+
+    0x80, 0x81, 0x82, 0x83,  0x84, 0x85, 0x86, 0x87,
+    0x88, 0x89, 0x8A, 0x8B,  0x8C, 0x8D, 0x8E, 0x8F,
+    0x90, 0x91, 0x92, 0x93,  0x94, 0x95, 0x96, 0x97,
+    0x98, 0x99, 0x9A, 0x9B,  0x9C, 0x9D, 0x9E, 0x9F,
+    0xA0, 0xA1, 0xA2, 0xA3,  0xA4, 0xA5, 0xA6, 0xA7,
+    0xA8, 0xA9, 0xAA, 0xAB,  0xAC, 0xAD, 0xAE, 0xAF,
+    0xB0, 0xB1, 0xB2, 0xB3,  0xB4, 0xB5, 0xB6, 0xB7,
+    0xB8, 0xB9, 0xBA, 0xBB,  0xBC, 0xBD, 0xBE, 0xBF,
+
+    0xC0, 0xC1, 0xC2, 0xC3,  0xC4, 0xC5, 0xC6, 0xC7,
+    0xC8, 0xC9, 0xCA, 0xCB,  0xCC, 0xCD, 0xCE, 0xCF,
+    0xD0, 0xD1, 0xD2, 0xD3,  0xD4, 0xD5, 0xD6, 0xD7,
+    0xD8, 0xD9, 0xDA, 0xDB,  0xDC, 0xDD, 0xDE, 0xDF,
+    0xE0, 0xE1, 0xE2, 0xE3,  0xE4, 0xE5, 0xE6, 0xE7,
+    0xE8, 0xE9, 0xEA, 0xEB,  0xEC, 0xED, 0xEE, 0xEF,
+    0xF0, 0xF1, 0xF2, 0xF3,  0xF4, 0xF5, 0xF6, 0xF7,
+    0xF8, 0xF9, 0xFA, 0xFB,  0xFC, 0xFD, 0xFE, 0xFF,
+};
+
+
+/*=export_func strneqvcmp
+ *
+ * what: compare two strings with an equivalence mapping
+ *
+ * arg:  + char const* + str1 + first string +
+ * arg:  + char const* + str2 + second string +
+ * arg:  + int         + ct   + compare length +
+ *
+ * ret_type:  int
+ * ret_desc:  the difference between two differing characters
+ *
+ * doc:
+ *
+ * Using a character mapping, two strings are compared for "equivalence".
+ * Each input character is mapped to a comparison character and the
+ * mapped-to characters are compared for the two NUL terminated input strings.
+ * The comparison is limited to @code{ct} bytes.
+ * This function name is mapped to option_strneqvcmp so as to not conflict
+ * with the POSIX name space.
+ *
+ * err:  none checked.  Caller responsible for seg faults.
+=*/
+int
+strneqvcmp( tCC* s1, tCC* s2, int ct )
+{
+    for (; ct > 0; --ct) {
+        unsigned char u1 = (unsigned char) *s1++;
+        unsigned char u2 = (unsigned char) *s2++;
+        int dif = charmap[ u1 ] - charmap[ u2 ];
+
+        if (dif != 0)
+            return dif;
+
+        if (u1 == NUL)
+            return 0;
+    }
+
+    return 0;
+}
+
+
+/*=export_func streqvcmp
+ *
+ * what: compare two strings with an equivalence mapping
+ *
+ * arg:  + char const* + str1 + first string +
+ * arg:  + char const* + str2 + second string +
+ *
+ * ret_type:  int
+ * ret_desc:  the difference between two differing characters
+ *
+ * doc:
+ *
+ * Using a character mapping, two strings are compared for "equivalence".
+ * Each input character is mapped to a comparison character and the
+ * mapped-to characters are compared for the two NUL terminated input strings.
+ * This function name is mapped to option_streqvcmp so as to not conflict
+ * with the POSIX name space.
+ *
+ * err:  none checked.  Caller responsible for seg faults.
+=*/
+int
+streqvcmp( tCC* s1, tCC* s2 )
+{
+    for (;;) {
+        unsigned char u1 = (unsigned char) *s1++;
+        unsigned char u2 = (unsigned char) *s2++;
+        int dif = charmap[ u1 ] - charmap[ u2 ];
+
+        if (dif != 0)
+            return dif;
+
+        if (u1 == NUL)
+            return 0;
+    }
+}
+
+
+/*=export_func streqvmap
+ *
+ * what: Set the character mappings for the streqv functions
+ *
+ * arg:  + char + From + Input character +
+ * arg:  + char + To   + Mapped-to character +
+ * arg:  + int  + ct   + compare length +
+ *
+ * doc:
+ *
+ * Set the character mapping.  If the count (@code{ct}) is set to zero, then
+ * the map is cleared by setting all entries in the map to their index
+ * value.  Otherwise, the "@code{From}" character is mapped to the "@code{To}"
+ * character.  If @code{ct} is greater than 1, then @code{From} and @code{To}
+ * are incremented and the process repeated until @code{ct} entries have been
+ * set. For example,
+ * @example
+ *    streqvmap( 'a', 'A', 26 );
+ * @end example
+ * @noindent
+ * will alter the mapping so that all English lower case letters
+ * will map to upper case.
+ *
+ * This function name is mapped to option_streqvmap so as to not conflict
+ * with the POSIX name space.
+ *
+ * err:  none.
+=*/
+void
+streqvmap( char From, char To, int ct )
+{
+    if (ct == 0) {
+        ct = sizeof( charmap ) - 1;
+        do  {
+            charmap[ ct ] = ct;
+        } while (--ct >= 0);
+    }
+
+    else {
+        int  chTo   = (int)To   & 0xFF;
+        int  chFrom = (int)From & 0xFF;
+
+        do  {
+            charmap[ chFrom ] = (unsigned)chTo;
+            chFrom++;
+            chTo++;
+            if ((chFrom >= sizeof( charmap )) || (chTo >= sizeof( charmap )))
+                break;
+        } while (--ct > 0);
+    }
+}
+
+
+/*=export_func strequate
+ *
+ * what: map a list of characters to the same value
+ *
+ * arg:  + char const* + ch_list + characters to equivalence +
+ *
+ * doc:
+ *
+ * Each character in the input string get mapped to the first character
+ * in the string.
+ * This function name is mapped to option_strequate so as to not conflict
+ * with the POSIX name space.
+ *
+ * err:  none.
+=*/
+void
+strequate( char const* s )
+{
+    if ((s != NULL) && (*s != NUL)) {
+        unsigned char equiv = (unsigned)*s;
+        while (*s != NUL)
+            charmap[ (unsigned)*(s++) ] = equiv;
+    }
+}
+
+
+/*=export_func strtransform
+ *
+ * what: convert a string into its mapped-to value
+ *
+ * arg:  + char*       + dest + output string +
+ * arg:  + char const* + src  + input string +
+ *
+ * doc:
+ *
+ * Each character in the input string is mapped and the mapped-to
+ * character is put into the output.
+ * This function name is mapped to option_strtransform so as to not conflict
+ * with the POSIX name space.
+ *
+ * err:  none.
+=*/
+void
+strtransform( char* d, char const* s )
+{
+    do  {
+        *(d++) = (char)charmap[ (unsigned)*s ];
+    } while (*(s++) != NUL);
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/streqvcmp.c */
diff --git a/sntp/libopts/text_mmap.c b/sntp/libopts/text_mmap.c
new file mode 100644 (file)
index 0000000..ced2977
--- /dev/null
@@ -0,0 +1,363 @@
+/*
+ * $Id: text_mmap.c,v 4.15 2006/11/27 01:52:23 bkorb Exp $
+ *
+ * Time-stamp:      "2006-09-10 14:50:04 bkorb"
+ */
+
+#ifndef MAP_ANONYMOUS
+#  ifdef   MAP_ANON
+#  define  MAP_ANONYMOUS   MAP_ANON
+#  endif
+#endif
+
+/*
+ *  Some weird systems require that a specifically invalid FD number
+ *  get passed in as an argument value.  Which value is that?  Well,
+ *  as everybody knows, if open(2) fails, it returns -1, so that must
+ *  be the value.  :)
+ */
+#define AO_INVALID_FD  -1
+
+#define FILE_WRITABLE(_prt,_flg) \
+        (   (_prt & PROT_WRITE) \
+         && ((_flg & (MAP_SHARED|MAP_PRIVATE)) == MAP_SHARED))
+#define MAP_FAILED_PTR ((void*)MAP_FAILED)
+
+/*=export_func  text_mmap
+ * private:
+ *
+ * what:  map a text file with terminating NUL
+ *
+ * arg:   char const*,  pzFile,  name of the file to map
+ * arg:   int,          prot,    mmap protections (see mmap(2))
+ * arg:   int,          flags,   mmap flags (see mmap(2))
+ * arg:   tmap_info_t*, mapinfo, returned info about the mapping
+ *
+ * ret-type:   void*
+ * ret-desc:   The mmaped data address
+ *
+ * doc:
+ *
+ * This routine will mmap a file into memory ensuring that there is at least
+ * one @file{NUL} character following the file data.  It will return the
+ * address where the file contents have been mapped into memory.  If there is a
+ * problem, then it will return @code{MAP_FAILED} and set @file{errno}
+ * appropriately.
+ *
+ * The named file does not exist, @code{stat(2)} will set @file{errno} as it
+ * will.  If the file is not a regular file, @file{errno} will be
+ * @code{EINVAL}.  At that point, @code{open(2)} is attempted with the access
+ * bits set appropriately for the requested @code{mmap(2)} protections and flag
+ * bits.  On failure, @file{errno} will be set according to the documentation
+ * for @code{open(2)}.  If @code{mmap(2)} fails, @file{errno} will be set as
+ * that routine sets it.  If @code{text_mmap} works to this point, a valid
+ * address will be returned, but there may still be ``issues''.
+ *
+ * If the file size is not an even multiple of the system page size, then
+ * @code{text_map} will return at this point and @file{errno} will be zero.
+ * Otherwise, an anonymous map is attempted.  If not available, then an attempt
+ * is made to @code{mmap(2)} @file{/dev/zero}.  If any of these fail, the
+ * address of the file's data is returned, bug @code{no} @file{NUL} characters
+ * are mapped after the end of the data.
+ *
+ * see: mmap(2), open(2), stat(2)
+ *
+ * err: Any error code issued by mmap(2), open(2), stat(2) is possible.
+ *      Additionally, if the specified file is not a regular file, then
+ *      errno will be set to @code{EINVAL}.
+ *
+ * example:
+ * #include <mylib.h>
+ * tmap_info_t mi;
+ * int no_nul;
+ * void* data = text_mmap( "file", PROT_WRITE, MAP_PRIVATE, &mi );
+ * if (data == MAP_FAILED) return;
+ * no_nul = (mi.txt_size == mi.txt_full_size);
+ * << use the data >>
+ * text_munmap( &mi );
+=*/
+void*
+text_mmap( char const* pzFile, int prot, int flags, tmap_info_t* pMI )
+{
+    memset( pMI, 0, sizeof(*pMI) );
+#ifdef HAVE_MMAP
+    pMI->txt_zero_fd = -1;
+#endif
+    pMI->txt_fd = -1;
+
+    /*
+     *  Make sure we can stat the regular file.  Save the file size.
+     */
+    {
+        struct stat sb;
+        if (stat( pzFile, &sb ) != 0) {
+            pMI->txt_errno = errno;
+            return MAP_FAILED_PTR;
+        }
+
+        if (! S_ISREG( sb.st_mode )) {
+            pMI->txt_errno = errno = EINVAL;
+            return MAP_FAILED_PTR;
+        }
+
+        pMI->txt_size = sb.st_size;
+    }
+
+    /*
+     *  Map mmap flags and protections into open flags and do the open.
+     */
+    {
+        int o_flag;
+        /*
+         *  See if we will be updating the file.  If we can alter the memory
+         *  and if we share the data and we are *not* copy-on-writing the data,
+         *  then our updates will show in the file, so we must open with
+         *  write access.
+         */
+        if (FILE_WRITABLE(prot,flags))
+            o_flag = O_RDWR;
+        else
+            o_flag = O_RDONLY;
+
+        /*
+         *  If you're not sharing the file and you are writing to it,
+         *  then don't let anyone else have access to the file.
+         */
+        if (((flags & MAP_SHARED) == 0) && (prot & PROT_WRITE))
+            o_flag |= O_EXCL;
+
+        pMI->txt_fd = open( pzFile, o_flag );
+    }
+
+    if (pMI->txt_fd == AO_INVALID_FD) {
+        pMI->txt_errno = errno;
+        return MAP_FAILED_PTR;
+    }
+
+#ifdef HAVE_MMAP /* * * * * WITH MMAP * * * * * */
+    /*
+     *  do the mmap.  If we fail, then preserve errno, close the file and
+     *  return the failure.
+     */
+    pMI->txt_data =
+        mmap(NULL, pMI->txt_size+1, prot, flags, pMI->txt_fd, (size_t)0);
+    if (pMI->txt_data == MAP_FAILED_PTR) {
+        pMI->txt_errno = errno;
+        goto fail_return;
+    }
+
+    /*
+     *  Most likely, everything will turn out fine now.  The only difficult
+     *  part at this point is coping with files with sizes that are a multiple
+     *  of the page size.  Handling that is what this whole thing is about.
+     */
+    pMI->txt_zero_fd = -1;
+    pMI->txt_errno   = 0;
+
+    {
+        void* pNuls;
+#ifdef _SC_PAGESIZE
+        size_t pgsz = sysconf(_SC_PAGESIZE);
+#else
+        size_t pgsz = getpagesize();
+#endif
+        /*
+         *  Compute the pagesize rounded mapped memory size.
+         *  IF this is not the same as the file size, then there are NUL's
+         *  at the end of the file mapping and all is okay.
+         */
+        pMI->txt_full_size = (pMI->txt_size + (pgsz - 1)) & ~(pgsz - 1);
+        if (pMI->txt_size != pMI->txt_full_size)
+            return pMI->txt_data;
+
+        /*
+         *  Still here?  We have to remap the trailing inaccessible page
+         *  either anonymously or to /dev/zero.
+         */
+        pMI->txt_full_size += pgsz;
+#if defined(MAP_ANONYMOUS)
+        pNuls = mmap(
+                (void*)(((char*)pMI->txt_data) + pMI->txt_size),
+                pgsz, PROT_READ|PROT_WRITE,
+                MAP_ANONYMOUS|MAP_FIXED|MAP_PRIVATE, AO_INVALID_FD, (size_t)0);
+
+        if (pNuls != MAP_FAILED_PTR)
+            return pMI->txt_data;
+
+        pMI->txt_errno = errno;
+
+#elif defined(HAVE_DEV_ZERO)
+        pMI->txt_zero_fd = open( "/dev/zero", O_RDONLY );
+
+        if (pMI->txt_zero_fd == AO_INVALID_FD) {
+            pMI->txt_errno = errno;
+
+        } else {
+            pNuls = mmap(
+                    (void*)(((char*)pMI->txt_data) + pMI->txt_size), pgsz,
+                    PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED,
+                    pMI->txt_zero_fd, 0 );
+
+            if (pNuls != MAP_FAILED_PTR)
+                return pMI->txt_data;
+
+            pMI->txt_errno = errno;
+            close( pMI->txt_zero_fd );
+            pMI->txt_zero_fd = -1;
+        }
+#endif
+
+        pMI->txt_full_size = pMI->txt_size;
+    }
+
+    {
+        void* p = AGALOC( pMI->txt_size+1, "file text" );
+        memcpy( p, pMI->txt_data, pMI->txt_size );
+        ((char*)p)[pMI->txt_size] = NUL;
+        munmap(pMI->txt_data, pMI->txt_size );
+        pMI->txt_data = p;
+    }
+    pMI->txt_alloc = 1;
+    return pMI->txt_data;
+
+#else /* * * * * * no HAVE_MMAP * * * * * */
+
+    pMI->txt_data = AGALOC( pMI->txt_size+1, "file text" );
+    if (pMI->txt_data == NULL) {
+        pMI->txt_errno = ENOMEM;
+        goto fail_return;
+    }
+
+    {
+        size_t sz = pMI->txt_size;
+        char*  pz = pMI->txt_data;
+
+        while (sz > 0) {
+            ssize_t rdct = read( pMI->txt_fd, pz, sz );
+            if (rdct <= 0) {
+                pMI->txt_errno = errno;
+                fprintf( stderr, zFSErrReadFile,
+                         errno, strerror( errno ), pzFile );
+                free( pMI->txt_data );
+                goto fail_return;
+            }
+
+            pz += rdct;
+            sz -= rdct;
+        }
+
+        *pz = NUL;
+    }
+
+    /*
+     *  We never need a dummy page mapped in
+     */
+    pMI->txt_zero_fd = -1;
+    pMI->txt_errno   = 0;
+
+    return pMI->txt_data;
+
+#endif /* * * * * * no HAVE_MMAP * * * * * */
+
+ fail_return:
+    if (pMI->txt_fd >= 0) {
+        close( pMI->txt_fd );
+        pMI->txt_fd = -1;
+    }
+    errno = pMI->txt_errno;
+    pMI->txt_data = MAP_FAILED_PTR;
+    return pMI->txt_data;
+}
+
+
+/*=export_func  text_munmap
+ * private:
+ *
+ * what:  unmap the data mapped in by text_mmap
+ *
+ * arg:   tmap_info_t*, mapinfo, info about the mapping
+ *
+ * ret-type:   int
+ * ret-desc:   -1 or 0.  @file{errno} will have the error code.
+ *
+ * doc:
+ *
+ * This routine will unmap the data mapped in with @code{text_mmap} and close
+ * the associated file descriptors opened by that function.
+ *
+ * see: munmap(2), close(2)
+ *
+ * err: Any error code issued by munmap(2) or close(2) is possible.
+=*/
+int
+text_munmap( tmap_info_t* pMI )
+{
+#ifdef HAVE_MMAP
+    int res = 0;
+    if (pMI->txt_alloc) {
+        /*
+         *  IF the user has write permission and the text is not mapped private,
+         *  then write back any changes.  Hopefully, nobody else has modified
+         *  the file in the mean time.
+         */
+        if (   ((pMI->txt_prot & PROT_WRITE) != 0)
+            && ((pMI->txt_flags & MAP_PRIVATE) == 0))  {
+
+            if (lseek(pMI->txt_fd, (size_t)0, SEEK_SET) != 0)
+                goto error_return;
+
+            res = (write( pMI->txt_fd, pMI->txt_data, pMI->txt_size ) < 0)
+                ? errno : 0;
+        }
+
+        AGFREE( pMI->txt_data );
+        errno = res;
+    } else {
+        res = munmap( pMI->txt_data, pMI->txt_full_size );
+    }
+    if (res != 0)
+        goto error_return;
+
+    res = close( pMI->txt_fd );
+    if (res != 0)
+        goto error_return;
+
+    pMI->txt_fd = -1;
+    errno = 0;
+    if (pMI->txt_zero_fd != -1) {
+        res = close( pMI->txt_zero_fd );
+        pMI->txt_zero_fd = -1;
+    }
+
+ error_return:
+    pMI->txt_errno = errno;
+    return res;
+#else  /* HAVE_MMAP */
+
+    errno = 0;
+    /*
+     *  IF the memory is writable *AND* it is not private (copy-on-write)
+     *     *AND* the memory is "sharable" (seen by other processes)
+     *  THEN rewrite the data.
+     */
+    if (   FILE_WRITABLE(pMI->txt_prot, pMI->txt_flags)
+        && (lseek( pMI->txt_fd, 0, SEEK_SET ) >= 0) ) {
+        write( pMI->txt_fd, pMI->txt_data, pMI->txt_size );
+    }
+
+    close( pMI->txt_fd );
+    pMI->txt_fd = -1;
+    pMI->txt_errno = errno;
+    free( pMI->txt_data );
+
+    return pMI->txt_errno;
+#endif /* HAVE_MMAP */
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/text_mmap.c */
diff --git a/sntp/libopts/tokenize.c b/sntp/libopts/tokenize.c
new file mode 100644 (file)
index 0000000..0e576ce
--- /dev/null
@@ -0,0 +1,321 @@
+/*
+ *  This file defines the string_tokenize interface
+ * Time-stamp:      "2006-06-24 15:27:49 bkorb"
+ *
+ *  string_tokenize copyright 2005 Bruce Korb
+ *
+ *  string_tokenize is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU Lesser General Public
+ *  License as published by the Free Software Foundation; either
+ *  version 2.1 of the License, or (at your option) any later version.
+ *
+ *  string_tokenize is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ *  Lesser General Public License for more details.
+ *
+ *  You should have received a copy of the GNU Lesser General Public
+ *  License along with string_tokenize; if not, write to:
+ *             The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ */
+#include <ctype.h>
+#include <errno.h>
+#include <stdlib.h>
+
+#define cc_t   const unsigned char
+#define ch_t   unsigned char
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+copy_cooked( ch_t** ppDest, char const ** ppSrc );
+
+static void
+copy_raw( ch_t** ppDest, char const ** ppSrc );
+/* = = = END-STATIC-FORWARD = = = */
+
+static void
+copy_cooked( ch_t** ppDest, char const ** ppSrc )
+{
+    ch_t* pDest = (ch_t*)*ppDest;
+    const ch_t* pSrc  = (const ch_t*)(*ppSrc + 1);
+
+    for (;;) {
+        ch_t ch = *(pSrc++);
+        switch (ch) {
+        case NUL:   *ppSrc = NULL; return;
+        case '"':   goto done;
+        case '\\':
+            pSrc += ao_string_cook_escape_char( (char*)pSrc, (char*)&ch, 0x7F );
+            if (ch == 0x7F)
+                break;
+            /* FALLTHROUGH */
+
+        default:
+            *(pDest++) = ch;
+        }
+    }
+
+ done:
+    *ppDest = (ch_t*)pDest; /* next spot for storing character */
+    *ppSrc  = (char const *)pSrc;  /* char following closing quote    */
+}
+
+
+static void
+copy_raw( ch_t** ppDest, char const ** ppSrc )
+{
+    ch_t* pDest = *ppDest;
+    cc_t* pSrc  = (cc_t*) (*ppSrc + 1);
+
+    for (;;) {
+        ch_t ch = *(pSrc++);
+        switch (ch) {
+        case NUL:   *ppSrc = NULL; return;
+        case '\'':  goto done;
+        case '\\':
+            /*
+             *  *Four* escapes are handled:  newline removal, escape char
+             *  quoting and apostrophe quoting
+             */
+            switch (*pSrc) {
+            case NUL:   *ppSrc = NULL; return;
+            case '\r':
+                if (*(++pSrc) == '\n')
+                    ++pSrc;
+                continue;
+
+            case '\n':
+                ++pSrc;
+                continue;
+
+            case '\'':
+                ch = '\'';
+                /* FALLTHROUGH */
+
+            case '\\':
+                ++pSrc;
+                break;
+            }
+            /* FALLTHROUGH */
+
+        default:
+            *(pDest++) = ch;
+        }
+    }
+
+ done:
+    *ppDest = pDest; /* next spot for storing character */
+    *ppSrc  = (char const *) pSrc;  /* char following closing quote    */
+}
+
+
+/*=export_func ao_string_tokenize
+ *
+ * what: tokenize an input string
+ *
+ * arg:  + char const* + string + string to be tokenized +
+ *
+ * ret_type:  token_list_t*
+ * ret_desc:  pointer to a structure that lists each token
+ *
+ * doc:
+ *
+ * This function will convert one input string into a list of strings.
+ * The list of strings is derived by separating the input based on
+ * white space separation.  However, if the input contains either single
+ * or double quote characters, then the text after that character up to
+ * a matching quote will become the string in the list.
+ *
+ *  The returned pointer should be deallocated with @code{free(3C)} when
+ *  are done using the data.  The data are placed in a single block of
+ *  allocated memory.  Do not deallocate individual token/strings.
+ *
+ *  The structure pointed to will contain at least these two fields:
+ *  @table @samp
+ *  @item tkn_ct
+ *  The number of tokens found in the input string.
+ *  @item tok_list
+ *  An array of @code{tkn_ct + 1} pointers to substring tokens, with
+ *  the last pointer set to NULL.
+ *  @end table
+ *
+ * There are two types of quoted strings: single quoted (@code{'}) and
+ * double quoted (@code{"}).  Singly quoted strings are fairly raw in that
+ * escape characters (@code{\\}) are simply another character, except when
+ * preceding the following characters:
+ * @example
+ * @code{\\}  double backslashes reduce to one
+ * @code{'}   incorporates the single quote into the string
+ * @code{\n}  suppresses both the backslash and newline character
+ * @end example
+ *
+ * Double quote strings are formed according to the rules of string
+ * constants in ANSI-C programs.
+ *
+ * example:
+ * @example
+ *    #include <stdlib.h>
+ *    int ix;
+ *    token_list_t* ptl = ao_string_tokenize( some_string )
+ *    for (ix = 0; ix < ptl->tkn_ct; ix++)
+ *       do_something_with_tkn( ptl->tkn_list[ix] );
+ *    free( ptl );
+ * @end example
+ * Note that everything is freed with the one call to @code{free(3C)}.
+ *
+ * err:
+ *  NULL is returned and @code{errno} will be set to indicate the problem:
+ *  @itemize @bullet
+ *  @item
+ *  @code{EINVAL} - There was an unterminated quoted string.
+ *  @item
+ *  @code{ENOENT} - The input string was empty.
+ *  @item
+ *  @code{ENOMEM} - There is not enough memory.
+ *  @end itemize
+=*/
+token_list_t*
+ao_string_tokenize( char const* str )
+{
+    int max_token_ct = 1; /* allow for trailing NUL on string */
+    token_list_t* res;
+
+    if (str == NULL)  goto bogus_str;
+
+    /*
+     *  Trim leading white space.  Use "ENOENT" and a NULL return to indicate
+     *  an empty string was passed.
+     */
+    while (isspace( (ch_t)*str ))  str++;
+    if (*str == NUL) {
+    bogus_str:
+        errno = ENOENT;
+        return NULL;
+    }
+
+    /*
+     *  Take an approximate count of tokens.  If no quoted strings are used,
+     *  it will be accurate.  If quoted strings are used, it will be a little
+     *  high and we'll squander the space for a few extra pointers.
+     */
+    {
+        cc_t* pz = (cc_t*)str;
+
+        do {
+            max_token_ct++;
+            while (! isspace( *++pz ))
+                if (*pz == NUL) goto found_nul;
+            while (isspace( *pz ))  pz++;
+        } while (*pz != NUL);
+
+    found_nul:
+        ;
+    }
+
+    res = malloc( sizeof(*res) + strlen(str) + (max_token_ct * sizeof(ch_t*)) );
+    if (res == NULL) {
+        errno = ENOMEM;
+        return res;
+    }
+
+    /*
+     *  Now copy each token into the output buffer.
+     */
+    {
+        ch_t* pzDest = (ch_t*)(res->tkn_list + (max_token_ct + 1));
+        res->tkn_ct  = 0;
+
+        do  {
+            res->tkn_list[ res->tkn_ct++ ] = pzDest;
+            for (;;) {
+                int ch = (ch_t)*str;
+                if (isspace( ch )) {
+                found_white_space:
+                    while (isspace( (ch_t)*++str ))  ;
+                    break;
+                }
+
+                switch (ch) {
+                case '"':
+                    copy_cooked( &pzDest, &str );
+                    if (str == NULL) {
+                        free(res);
+                        errno = EINVAL;
+                        return NULL;
+                    }
+                    if (isspace( (ch_t)*str ))
+                        goto found_white_space;
+                    break;
+
+                case '\'':
+                    copy_raw( &pzDest, &str );
+                    if (str == NULL) {
+                        free(res);
+                        errno = EINVAL;
+                        return NULL;
+                    }
+                    if (isspace( (ch_t)*str ))
+                        goto found_white_space;
+                    break;
+
+                case NUL:
+                    goto copy_done;
+
+                default:
+                    str++;
+                    *(pzDest++) = ch;
+                }
+            } copy_done:;
+
+            /*
+             * NUL terminate the last token and see if we have any more tokens.
+             */
+            *(pzDest++) = NUL;
+        } while (*str != NUL);
+
+        res->tkn_list[ res->tkn_ct ] = NULL;
+    }
+
+    return res;
+}
+
+#ifdef TEST
+#include <stdio.h>
+#include <string.h>
+
+int
+main( int argc, char** argv )
+{
+    if (argc == 1) {
+        printf("USAGE:  %s arg [ ... ]\n", *argv);
+        return 1;
+    }
+    while (--argc > 0) {
+        char* arg = *(++argv);
+        token_list_t* p = ao_string_tokenize( arg );
+        if (p == NULL) {
+            printf( "Parsing string ``%s'' failed:\n\terrno %d (%s)\n",
+                    arg, errno, strerror( errno ));
+        } else {
+            int ix = 0;
+            printf( "Parsed string ``%s''\ninto %d tokens:\n", arg, p->tkn_ct );
+            do {
+                printf( " %3d:  ``%s''\n", ix+1, p->tkn_list[ix] );
+            } while (++ix < p->tkn_ct);
+            free(p);
+        }
+    }
+    return 0;
+}
+#endif
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/tokenize.c */
diff --git a/sntp/libopts/usage.c b/sntp/libopts/usage.c
new file mode 100644 (file)
index 0000000..960339b
--- /dev/null
@@ -0,0 +1,740 @@
+
+/*
+ *  usage.c  $Id: usage.c,v 4.15 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2007-04-15 11:02:46 bkorb"
+ *
+ *  This module implements the default usage procedure for
+ *  Automated Options.  It may be overridden, of course.
+ *
+ *  Sort options:
+    --start=END-[S]TATIC-FORWARD --patt='^/\*($|[^:])' \
+    --out=xx.c key='^[a-zA-Z0-9_]+\(' --trail='^/\*:' \
+    --spac=2 --input=usage.c
+ */
+
+/*
+ *  Automated Options copyright 1992-2007 Bruce Korb
+ *
+ *  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+#define OPTPROC_L_N_S  (OPTPROC_LONGOPT | OPTPROC_SHORTOPT)
+
+static arg_types_t argTypes;
+
+FILE* option_usage_fp = NULL;
+static char    zOptFmtLine[ 16 ];
+static ag_bool displayEnum;
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static ag_bool
+checkGNUUsage( tOptions* pOpts );
+
+static void
+printExtendedUsage(
+    tOptions*     pOptions,
+    tOptDesc*     pOD,
+    arg_types_t*  pAT );
+
+static void
+printInitList(
+    tCC* const* papz,
+    ag_bool*    pInitIntro,
+    tCC*        pzRc,
+    tCC*        pzPN );
+
+static void
+printOneUsage(
+    tOptions*     pOptions,
+    tOptDesc*     pOD,
+    arg_types_t*  pAT );
+
+static void
+printOptionUsage(
+    tOptions* pOpts,
+    int       ex_code,
+    tCC*      pOptTitle );
+
+static void
+printProgramDetails( tOptions* pOptions );
+
+static int
+setGnuOptFmts( tOptions* pOpts, tCC** ppT );
+
+static int
+setStdOptFmts( tOptions* pOpts, tCC** ppT );
+/* = = = END-STATIC-FORWARD = = = */
+
+
+/*
+ *  Figure out if we should try to format usage text sort-of like
+ *  the way many GNU programs do.
+ */
+static ag_bool
+checkGNUUsage( tOptions* pOpts )
+{
+    char* pz = getenv( "AUTOOPTS_USAGE" );
+    if (pz == NULL)
+        ;
+
+    else if (streqvcmp( pz, "gnu" ) == 0)
+        pOpts->fOptSet |= OPTPROC_GNUUSAGE;
+
+    else if (streqvcmp( pz, "autoopts" ) == 0)
+        pOpts->fOptSet &= ~OPTPROC_GNUUSAGE;
+
+    return (pOpts->fOptSet & OPTPROC_GNUUSAGE) ? AG_TRUE : AG_FALSE;
+}
+
+
+/*=export_func  optionOnlyUsage
+ *
+ * what:  Print usage text for just the options
+ * arg:   + tOptions*   + pOpts    + program options descriptor +
+ * arg:   + int         + ex_code  + exit code for calling exit(3) +
+ *
+ * doc:
+ *  This routine will print only the usage for each option.
+ *  This function may be used when the emitted usage must incorporate
+ *  information not available to AutoOpts.
+=*/
+void
+optionOnlyUsage(
+    tOptions* pOpts,
+    int       ex_code )
+{
+    tCC* pOptTitle = NULL;
+
+    /*
+     *  Determine which header and which option formatting strings to use
+     */
+    if (checkGNUUsage(pOpts)) {
+        (void)setGnuOptFmts( pOpts, &pOptTitle );
+    }
+    else {
+        (void)setStdOptFmts( pOpts, &pOptTitle );
+    }
+
+    printOptionUsage( pOpts, ex_code, pOptTitle );
+}
+
+
+/*=export_func  optionUsage
+ * private:
+ *
+ * what:  Print usage text
+ * arg:   + tOptions* + pOptions + program options descriptor +
+ * arg:   + int       + exitCode + exit code for calling exit(3) +
+ *
+ * doc:
+ *  This routine will print usage in both GNU-standard and AutoOpts-expanded
+ *  formats.  The descriptor specifies the default, but AUTOOPTS_USAGE will
+ *  over-ride this, providing the value of it is set to either "gnu" or
+ *  "autoopts".  This routine will @strong{not} return.
+ *
+ *  If "exitCode" is "EX_USAGE" (normally 64), then output will to to stdout
+ *  and the actual exit code will be "EXIT_SUCCESS".
+=*/
+void
+optionUsage(
+    tOptions* pOptions,
+    int       usage_exit_code )
+{
+    int actual_exit_code =
+        (usage_exit_code == EX_USAGE) ? EXIT_SUCCESS : usage_exit_code;
+
+    displayEnum = AG_FALSE;
+
+    /*
+     *  Paged usage will preset option_usage_fp to an output file.
+     *  If it hasn't already been set, then set it to standard output
+     *  on successful exit (help was requested), otherwise error out.
+     */
+    if (option_usage_fp == NULL)
+        option_usage_fp = (actual_exit_code != EXIT_SUCCESS) ? stderr : stdout;
+
+    fprintf( option_usage_fp, pOptions->pzUsageTitle, pOptions->pzProgName );
+
+    {
+        tCC* pOptTitle = NULL;
+
+        /*
+         *  Determine which header and which option formatting strings to use
+         */
+        if (checkGNUUsage(pOptions)) {
+            int flen = setGnuOptFmts( pOptions, &pOptTitle );
+            sprintf( zOptFmtLine, zFmtFmt, flen );
+            fputc( '\n', option_usage_fp );
+        }
+        else {
+            int flen = setStdOptFmts( pOptions, &pOptTitle );
+            sprintf( zOptFmtLine, zFmtFmt, flen );
+
+            /*
+             *  When we exit with EXIT_SUCCESS and the first option is a doc
+             *  option, we do *NOT* want to emit the column headers.
+             *  Otherwise, we do.
+             */
+            if (  (usage_exit_code != EXIT_SUCCESS)
+               || ((pOptions->pOptDesc->fOptState & OPTST_DOCUMENT) == 0) )
+
+                fputs( pOptTitle, option_usage_fp );
+        }
+
+        printOptionUsage( pOptions, usage_exit_code, pOptTitle );
+    }
+
+    /*
+     *  Describe the mechanics of denoting the options
+     */
+    switch (pOptions->fOptSet & OPTPROC_L_N_S) {
+    case OPTPROC_L_N_S:     fputs( zFlagOkay, option_usage_fp ); break;
+    case OPTPROC_SHORTOPT:  break;
+    case OPTPROC_LONGOPT:   fputs( zNoFlags,  option_usage_fp ); break;
+    case 0:                 fputs( zOptsOnly, option_usage_fp ); break;
+    }
+
+    if ((pOptions->fOptSet & OPTPROC_NUM_OPT) != 0) {
+        fputs( zNumberOpt, option_usage_fp );
+    }
+
+    if ((pOptions->fOptSet & OPTPROC_REORDER) != 0) {
+        fputs( zReorder, option_usage_fp );
+    }
+
+    if (pOptions->pzExplain != NULL)
+        fputs( pOptions->pzExplain, option_usage_fp );
+
+    /*
+     *  IF the user is asking for help (thus exiting with SUCCESS),
+     *  THEN see what additional information we can provide.
+     */
+    if (usage_exit_code == EXIT_SUCCESS)
+        printProgramDetails( pOptions );
+
+    if (pOptions->pzBugAddr != NULL)
+        fprintf( option_usage_fp, zPlsSendBugs, pOptions->pzBugAddr );
+    fflush( option_usage_fp );
+
+    exit( actual_exit_code );
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *   PER OPTION TYPE USAGE INFORMATION
+ */
+static void
+printExtendedUsage(
+    tOptions*     pOptions,
+    tOptDesc*     pOD,
+    arg_types_t*  pAT )
+{
+    /*
+     *  IF there are option conflicts or dependencies,
+     *  THEN print them here.
+     */
+    if (  (pOD->pOptMust != NULL)
+       || (pOD->pOptCant != NULL) ) {
+
+        fputs( zTabHyp, option_usage_fp );
+
+        /*
+         *  DEPENDENCIES:
+         */
+        if (pOD->pOptMust != NULL) {
+            const int* pOptNo = pOD->pOptMust;
+
+            fputs( zReqThese, option_usage_fp );
+            for (;;) {
+                fprintf( option_usage_fp, zTabout, pOptions->pOptDesc[
+                             *pOptNo ].pz_Name );
+                if (*++pOptNo == NO_EQUIVALENT)
+                    break;
+            }
+
+            if (pOD->pOptCant != NULL)
+                fputs( zTabHypAnd, option_usage_fp );
+        }
+
+        /*
+         *  CONFLICTS:
+         */
+        if (pOD->pOptCant != NULL) {
+            const int* pOptNo = pOD->pOptCant;
+
+            fputs( zProhib, option_usage_fp );
+            for (;;) {
+                fprintf( option_usage_fp, zTabout, pOptions->pOptDesc[
+                             *pOptNo ].pz_Name );
+                if (*++pOptNo == NO_EQUIVALENT)
+                    break;
+            }
+        }
+    }
+
+    /*
+     *  IF there is a disablement string
+     *  THEN print the disablement info
+     */
+    if (pOD->pz_DisableName != NULL )
+        fprintf( option_usage_fp, zDis, pOD->pz_DisableName );
+
+    /*
+     *  IF the numeric option has a special callback,
+     *  THEN call it, requesting the range or other special info
+     */
+    if (  (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NUMERIC)
+       && (pOD->pOptProc != NULL)
+       && (pOD->pOptProc != optionNumericVal) ) {
+        (*(pOD->pOptProc))( pOptions, NULL );
+    }
+
+    /*
+     *  IF the option defaults to being enabled,
+     *  THEN print that out
+     */
+    if (pOD->fOptState & OPTST_INITENABLED)
+        fputs( zEnab, option_usage_fp );
+
+    /*
+     *  IF  the option is in an equivalence class
+     *        AND not the designated lead
+     *  THEN print equivalence and leave it at that.
+     */
+    if (  (pOD->optEquivIndex != NO_EQUIVALENT)
+       && (pOD->optEquivIndex != pOD->optActualIndex )  )  {
+        fprintf( option_usage_fp, zAlt,
+                 pOptions->pOptDesc[ pOD->optEquivIndex ].pz_Name );
+        return;
+    }
+
+    /*
+     *  IF this particular option can NOT be preset
+     *    AND some form of presetting IS allowed,
+     *    AND it is not an auto-managed option (e.g. --help, et al.)
+     *  THEN advise that this option may not be preset.
+     */
+    if (  ((pOD->fOptState & OPTST_NO_INIT) != 0)
+       && (  (pOptions->papzHomeList != NULL)
+          || (pOptions->pzPROGNAME != NULL)
+          )
+       && (pOD->optIndex < pOptions->presetOptCt)
+       )
+
+        fputs( zNoPreset, option_usage_fp );
+
+    /*
+     *  Print the appearance requirements.
+     */
+    if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_MEMBERSHIP)
+        fputs( zMembers, option_usage_fp );
+
+    else switch (pOD->optMinCt) {
+    case 1:
+    case 0:
+        switch (pOD->optMaxCt) {
+        case 0:       fputs( zPreset, option_usage_fp ); break;
+        case NOLIMIT: fputs( zNoLim, option_usage_fp );  break;
+        case 1:       break;
+            /*
+             * IF the max is more than one but limited, print "UP TO" message
+             */
+        default:      fprintf( option_usage_fp, zUpTo, pOD->optMaxCt );  break;
+        }
+        break;
+
+    default:
+        /*
+         *  More than one is required.  Print the range.
+         */
+        fprintf( option_usage_fp, zMust, pOD->optMinCt, pOD->optMaxCt );
+    }
+
+    if (  NAMED_OPTS( pOptions )
+       && (pOptions->specOptIdx.default_opt == pOD->optIndex))
+        fputs( zDefaultOpt, option_usage_fp );
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *   Figure out where all the initialization files might live.
+ *   This requires translating some environment variables and
+ *   testing to see if a name is a directory or a file.  It's
+ *   squishy, but important to tell users how to find these files.
+ */
+static void
+printInitList(
+    tCC* const* papz,
+    ag_bool*    pInitIntro,
+    tCC*        pzRc,
+    tCC*        pzPN )
+{
+    char zPath[ AG_PATH_MAX+1 ];
+
+    if (papz == NULL)
+        return;
+
+    fputs( zPresetIntro, option_usage_fp );
+    *pInitIntro = AG_FALSE;
+
+    for (;;) {
+        char const* pzPath = *(papz++);
+
+        if (pzPath == NULL)
+            break;
+
+        if (optionMakePath(zPath, (int)sizeof( zPath ), pzPath, pzPN))
+            pzPath = zPath;
+
+        /*
+         *  Print the name of the "homerc" file.  If the "rcfile" name is
+         *  not empty, we may or may not print that, too...
+         */
+        fprintf( option_usage_fp, zPathFmt, pzPath );
+        if (*pzRc != NUL) {
+            struct stat sb;
+
+            /*
+             *  IF the "homerc" file is a directory,
+             *  then append the "rcfile" name.
+             */
+            if (  (stat( pzPath, &sb ) == 0)
+              &&  S_ISDIR( sb.st_mode ) ) {
+                fputc( DIRCH, option_usage_fp );
+                fputs( pzRc, option_usage_fp );
+            }
+        }
+
+        fputc( '\n', option_usage_fp );
+    }
+}
+
+
+/*
+ *  Print the usage information for a single option.
+ */
+static void
+printOneUsage(
+    tOptions*     pOptions,
+    tOptDesc*     pOD,
+    arg_types_t*  pAT )
+{
+    /*
+     *  Flag prefix: IF no flags at all, then omit it.  If not printable
+     *  (not allowed for this option), then blank, else print it.
+     *  Follow it with a comma if we are doing GNU usage and long
+     *  opts are to be printed too.
+     */
+    if ((pOptions->fOptSet & OPTPROC_SHORTOPT) == 0)
+        fputs( pAT->pzSpc, option_usage_fp );
+    else if (! isgraph( pOD->optValue)) {
+        if (  (pOptions->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
+           == (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
+            fputc( ' ', option_usage_fp );
+        fputs( pAT->pzNoF, option_usage_fp );
+    } else {
+        fprintf( option_usage_fp, "   -%c", pOD->optValue );
+        if (  (pOptions->fOptSet & (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
+           == (OPTPROC_GNUUSAGE|OPTPROC_LONGOPT))
+            fputs( ", ", option_usage_fp );
+    }
+
+    {
+        char  z[ 80 ];
+        tCC*  pzArgType;
+        /*
+         *  Determine the argument type string first on its usage, then,
+         *  when the option argument is required, base the type string on the
+         *  argument type.
+         */
+        if (OPTST_GET_ARGTYPE(pOD->fOptState) == OPARG_TYPE_NONE) {
+            pzArgType = pAT->pzNo;
+
+        } else if (pOD->fOptState & OPTST_ARG_OPTIONAL) {
+            pzArgType = pAT->pzOpt;
+
+        } else switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+        case OPARG_TYPE_ENUMERATION: pzArgType = pAT->pzKey;  break;
+        case OPARG_TYPE_MEMBERSHIP:  pzArgType = pAT->pzKeyL; break;
+        case OPARG_TYPE_BOOLEAN:     pzArgType = pAT->pzBool; break;
+        case OPARG_TYPE_NUMERIC:     pzArgType = pAT->pzNum;  break;
+        case OPARG_TYPE_HIERARCHY:   pzArgType = pAT->pzNest; break;
+        case OPARG_TYPE_STRING:      pzArgType = pAT->pzStr;  break;
+        default:                     goto bogus_desc;         break;
+        }
+
+        snprintf( z, sizeof(z), pAT->pzOptFmt, pzArgType, pOD->pz_Name,
+                  (pOD->optMinCt != 0) ? pAT->pzReq : pAT->pzOpt );
+
+        fprintf( option_usage_fp, zOptFmtLine, z, pOD->pzText );
+
+        switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+        case OPARG_TYPE_ENUMERATION:
+        case OPARG_TYPE_MEMBERSHIP:
+            displayEnum = (pOD->pOptProc != NULL) ? AG_TRUE : displayEnum;
+        }
+    }
+    return;
+
+ bogus_desc:
+    fprintf( stderr, zInvalOptDesc, pOD->pz_Name );
+    exit( EX_SOFTWARE );
+}
+
+
+/*
+ *  Print out the usage information for just the options.
+ */
+static void
+printOptionUsage(
+    tOptions* pOpts,
+    int       ex_code,
+    tCC*      pOptTitle )
+{
+    int        ct     = pOpts->optCt;
+    int        optNo  = 0;
+    tOptDesc*  pOD    = pOpts->pOptDesc;
+    int        docCt  = 0;
+
+    do  {
+        if ((pOD->fOptState & OPTST_OMITTED) != 0)
+            continue;
+
+        if ((pOD->fOptState & OPTST_DOCUMENT) != 0) {
+            if (ex_code == EXIT_SUCCESS) {
+                fprintf(option_usage_fp, argTypes.pzBrk, pOD->pzText,
+                        pOptTitle);
+                docCt++;
+            }
+
+            continue;
+        }
+
+        /*
+         *  IF       this is the first auto-opt maintained option
+         *    *AND*  we are doing a full help
+         *    *AND*  there are documentation options
+         *    *AND*  the last one was not a doc option,
+         *  THEN document that the remaining options are not user opts
+         */
+        if (  (pOpts->presetOptCt == optNo)
+              && (ex_code == EXIT_SUCCESS)
+              && (docCt > 0)
+              && ((pOD[-1].fOptState & OPTST_DOCUMENT) == 0) )
+            fprintf( option_usage_fp, argTypes.pzBrk, zAuto, pOptTitle );
+
+        printOneUsage( pOpts, pOD, &argTypes );
+
+        /*
+         *  IF we were invoked because of the --help option,
+         *  THEN print all the extra info
+         */
+        if (ex_code == EXIT_SUCCESS)
+            printExtendedUsage( pOpts, pOD, &argTypes );
+
+    }  while (pOD++, optNo++, (--ct > 0));
+
+    fputc( '\n', option_usage_fp );
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *   PROGRAM DETAILS
+ */
+static void
+printProgramDetails( tOptions* pOptions )
+{
+    ag_bool  initIntro = AG_TRUE;
+
+    /*
+     *  Display all the places we look for config files
+     */
+    printInitList( pOptions->papzHomeList, &initIntro,
+                   pOptions->pzRcName, pOptions->pzProgPath );
+
+    /*
+     *  Let the user know about environment variable settings
+     */
+    if ((pOptions->fOptSet & OPTPROC_ENVIRON) != 0) {
+        if (initIntro)
+            fputs( zPresetIntro, option_usage_fp );
+
+        fprintf( option_usage_fp, zExamineFmt, pOptions->pzPROGNAME );
+    }
+
+    /*
+     *  IF we found an enumeration,
+     *  THEN hunt for it again.  Call the handler proc with a NULL
+     *       option struct pointer.  That tells it to display the keywords.
+     */
+    if (displayEnum) {
+        int        ct     = pOptions->optCt;
+        int        optNo  = 0;
+        tOptDesc*  pOD    = pOptions->pOptDesc;
+
+        fputc( '\n', option_usage_fp );
+        fflush( option_usage_fp );
+        do  {
+            switch (OPTST_GET_ARGTYPE(pOD->fOptState)) {
+            case OPARG_TYPE_ENUMERATION:
+            case OPARG_TYPE_MEMBERSHIP:
+                (*(pOD->pOptProc))( NULL, pOD );
+            }
+        }  while (pOD++, optNo++, (--ct > 0));
+    }
+
+    /*
+     *  If there is a detail string, now is the time for that.
+     */
+    if (pOptions->pzDetail != NULL)
+        fputs( pOptions->pzDetail, option_usage_fp );
+}
+
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *   OPTION LINE FORMATTING SETUP
+ *
+ *  The "OptFmt" formats receive three arguments:
+ *  1.  the type of the option's argument
+ *  2.  the long name of the option
+ *  3.  "YES" or "no ", depending on whether or not the option must appear
+ *      on the command line.
+ *  These formats are used immediately after the option flag (if used) has
+ *  been printed.
+ *
+ *  Set up the formatting for GNU-style output
+ */
+static int
+setGnuOptFmts( tOptions* pOpts, tCC** ppT )
+{
+    int  flen = 22;
+    *ppT = zNoRq_ShrtTtl;
+
+    argTypes.pzStr  = zGnuStrArg;
+    argTypes.pzReq  = zOneSpace;
+    argTypes.pzNum  = zGnuNumArg;
+    argTypes.pzKey  = zGnuKeyArg;
+    argTypes.pzKeyL = zGnuKeyLArg;
+    argTypes.pzBool = zGnuBoolArg;
+    argTypes.pzNest = zGnuNestArg;
+    argTypes.pzOpt  = zGnuOptArg;
+    argTypes.pzNo   = zOneSpace;
+    argTypes.pzBrk  = zGnuBreak;
+    argTypes.pzNoF  = zSixSpaces;
+    argTypes.pzSpc  = zThreeSpaces;
+
+    switch (pOpts->fOptSet & OPTPROC_L_N_S) {
+    case OPTPROC_L_N_S:    argTypes.pzOptFmt = zGnuOptFmt;     break;
+    case OPTPROC_LONGOPT:  argTypes.pzOptFmt = zGnuOptFmt;     break;
+    case 0:                argTypes.pzOptFmt = zGnuOptFmt + 2; break;
+    case OPTPROC_SHORTOPT:
+        argTypes.pzOptFmt = zShrtGnuOptFmt;
+        zGnuStrArg[0] = zGnuNumArg[0] = zGnuKeyArg[0] = zGnuBoolArg[0] = ' ';
+        argTypes.pzOpt = " [arg]";
+        flen = 8;
+        break;
+    }
+
+    return flen;
+}
+
+
+/*
+ *  Standard (AutoOpts normal) option line formatting
+ */
+static int
+setStdOptFmts( tOptions* pOpts, tCC** ppT )
+{
+    int  flen = 0;
+
+    argTypes.pzStr  = zStdStrArg;
+    argTypes.pzReq  = zStdReqArg;
+    argTypes.pzNum  = zStdNumArg;
+    argTypes.pzKey  = zStdKeyArg;
+    argTypes.pzKeyL = zStdKeyLArg;
+    argTypes.pzBool = zStdBoolArg;
+    argTypes.pzNest = zStdNestArg;
+    argTypes.pzOpt  = zStdOptArg;
+    argTypes.pzNo   = zStdNoArg;
+    argTypes.pzBrk  = zStdBreak;
+    argTypes.pzNoF  = zFiveSpaces;
+    argTypes.pzSpc  = zTwoSpaces;
+
+    switch (pOpts->fOptSet & (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT)) {
+    case (OPTPROC_NO_REQ_OPT | OPTPROC_SHORTOPT):
+        *ppT = zNoRq_ShrtTtl;
+        argTypes.pzOptFmt = zNrmOptFmt;
+        flen = 19;
+        break;
+
+    case OPTPROC_NO_REQ_OPT:
+        *ppT = zNoRq_NoShrtTtl;
+        argTypes.pzOptFmt = zNrmOptFmt;
+        flen = 19;
+        break;
+
+    case OPTPROC_SHORTOPT:
+        *ppT = zReq_ShrtTtl;
+        argTypes.pzOptFmt = zReqOptFmt;
+        flen = 24;
+        break;
+
+    case 0:
+        *ppT = zReq_NoShrtTtl;
+        argTypes.pzOptFmt = zReqOptFmt;
+        flen = 24;
+    }
+
+    return flen;
+}
+
+
+/*:
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/usage.c */
diff --git a/sntp/libopts/version.c b/sntp/libopts/version.c
new file mode 100644 (file)
index 0000000..85949d5
--- /dev/null
@@ -0,0 +1,178 @@
+
+/*  $Id: version.c,v 4.10 2007/04/28 22:19:23 bkorb Exp $
+ * Time-stamp:      "2007-04-28 10:08:34 bkorb"
+ *
+ *  This module implements the default usage procedure for
+ *  Automated Options.  It may be overridden, of course.
+ */
+
+static char const zAOV[] =
+    "Automated Options version %s, copyright (c) 1999-2007 Bruce Korb\n";
+
+/*  Automated Options is free software.
+ *  You may redistribute it and/or modify it under the terms of the
+ *  GNU General Public License, as published by the Free Software
+ *  Foundation; either version 2, or (at your option) any later version.
+ *
+ *  Automated Options is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with Automated Options.  See the file "COPYING".  If not,
+ *  write to:  The Free Software Foundation, Inc.,
+ *             51 Franklin Street, Fifth Floor,
+ *             Boston, MA  02110-1301, USA.
+ *
+ * As a special exception, Bruce Korb gives permission for additional
+ * uses of the text contained in his release of AutoOpts.
+ *
+ * The exception is that, if you link the AutoOpts library with other
+ * files to produce an executable, this does not by itself cause the
+ * resulting executable to be covered by the GNU General Public License.
+ * Your use of that executable is in no way restricted on account of
+ * linking the AutoOpts library code into it.
+ *
+ * This exception does not however invalidate any other reasons why
+ * the executable file might be covered by the GNU General Public License.
+ *
+ * This exception applies only to the code released by Bruce Korb under
+ * the name AutoOpts.  If you copy code from other sources under the
+ * General Public License into a copy of AutoOpts, as the General Public
+ * License permits, the exception does not apply to the code that you add
+ * in this way.  To avoid misleading anyone as to the status of such
+ * modified files, you must delete this exception notice from them.
+ *
+ * If you write modifications of your own for AutoOpts, it is your choice
+ * whether to permit this exception to apply to your modifications.
+ * If you do not wish that, delete this exception notice.
+ */
+
+/* = = = START-STATIC-FORWARD = = = */
+/* static forward declarations maintained by :mkfwd */
+static void
+printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp );
+/* = = = END-STATIC-FORWARD = = = */
+
+/*=export_func  optionVersion
+ *
+ * what:     return the compiled AutoOpts version number
+ * ret_type: char const*
+ * ret_desc: the version string in constant memory
+ * doc:
+ *  Returns the full version string compiled into the library.
+ *  The returned string cannot be modified.
+=*/
+char const*
+optionVersion( void )
+{
+    static char const zVersion[] =
+        STR( AO_CURRENT.AO_REVISION );
+
+    return zVersion;
+}
+
+
+static void
+printVersion( tOptions* pOpts, tOptDesc* pOD, FILE* fp )
+{
+    char swCh;
+
+    /*
+     *  IF the optional argument flag is off, or the argument is not provided,
+     *  then just print the version.
+     */
+    if (  ((pOD->fOptState & OPTST_ARG_OPTIONAL) == 0)
+       || (pOD->optArg.argString == NULL))
+         swCh = 'v';
+    else swCh = tolower(pOD->optArg.argString[0]);
+
+    if (pOpts->pzFullVersion != NULL) {
+        fputs( pOpts->pzFullVersion, fp );
+        fputc( '\n', fp );
+
+    } else {
+        char const *pz = pOpts->pzUsageTitle;
+        do { fputc(*pz, fp); } while (*(pz++) != '\n');
+    }
+
+    switch (swCh) {
+    case NUL: /* arg provided, but empty */
+    case 'v':
+        break;
+
+    case 'c':
+        if (pOpts->pzCopyright != NULL) {
+            fputs( pOpts->pzCopyright, fp );
+            fputc( '\n', fp );
+        }
+        fprintf( fp, zAOV, optionVersion() );
+        if (pOpts->pzBugAddr != NULL)
+            fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr );
+        break;
+
+    case 'n':
+        if (pOpts->pzCopyright != NULL) {
+            fputs( pOpts->pzCopyright, fp );
+            fputc( '\n', fp );
+            fputc( '\n', fp );
+        }
+
+        if (pOpts->pzCopyNotice != NULL) {
+            fputs( pOpts->pzCopyNotice, fp );
+            fputc( '\n', fp );
+        }
+
+        fprintf( fp, zAOV, optionVersion() );
+        if (pOpts->pzBugAddr != NULL)
+            fprintf( fp, zPlsSendBugs, pOpts->pzBugAddr );
+        break;
+
+    default:
+        fprintf( stderr, zBadVerArg, swCh );
+        exit( EXIT_FAILURE );
+    }
+
+    exit( EXIT_SUCCESS );
+}
+
+/*=export_func  optionPrintVersion
+ * private:
+ *
+ * what:  Print the program version
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  This routine will print the version to stdout.
+=*/
+void
+optionPrintVersion( tOptions*  pOpts, tOptDesc*  pOD )
+{
+    printVersion( pOpts, pOD, stdout );
+}
+
+/*=export_func  optionVersionStderr
+ * private:
+ *
+ * what:  Print the program version to stderr
+ * arg:   + tOptions* + pOpts    + program options descriptor +
+ * arg:   + tOptDesc* + pOptDesc + the descriptor for this arg +
+ *
+ * doc:
+ *  This routine will print the version to stderr.
+=*/
+void
+optionVersionStderr( tOptions*  pOpts, tOptDesc*  pOD )
+{
+    printVersion( pOpts, pOD, stderr );
+}
+
+/*
+ * Local Variables:
+ * mode: C
+ * c-file-style: "stroustrup"
+ * indent-tabs-mode: nil
+ * End:
+ * end of autoopts/version.c */
diff --git a/sntp/ltmain.sh b/sntp/ltmain.sh
new file mode 100644 (file)
index 0000000..06823e0
--- /dev/null
@@ -0,0 +1,6863 @@
+# ltmain.sh - Provide generalized library-building support services.
+# NOTE: Changing this file will not affect anything until you rerun configure.
+#
+# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005
+# Free Software Foundation, Inc.
+# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful, but
+# WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+# General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+#
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+basename="s,^.*/,,g"
+
+# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
+# is ksh but when the shell is invoked as "sh" and the current value of
+# the _XPG environment variable is not equal to 1 (one), the special
+# positional parameter $0, within a function call, is the name of the
+# function.
+progpath="$0"
+
+# The name of this program:
+progname=`echo "$progpath" | $SED $basename`
+modename="$progname"
+
+# Global variables:
+EXIT_SUCCESS=0
+EXIT_FAILURE=1
+
+PROGRAM=ltmain.sh
+PACKAGE=libtool
+VERSION=1.5.22
+TIMESTAMP=" (1.1220.2.365 2005/12/18 22:14:06)"
+
+# See if we are running on zsh, and set the options which allow our
+# commands through without removal of \ escapes.
+if test -n "${ZSH_VERSION+set}" ; then
+  setopt NO_GLOB_SUBST
+fi
+
+# Check that we have a working $echo.
+if test "X$1" = X--no-reexec; then
+  # Discard the --no-reexec flag, and continue.
+  shift
+elif test "X$1" = X--fallback-echo; then
+  # Avoid inline document here, it may be left over
+  :
+elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
+  # Yippee, $echo works!
+  :
+else
+  # Restart under the correct shell, and then maybe $echo will work.
+  exec $SHELL "$progpath" --no-reexec ${1+"$@"}
+fi
+
+if test "X$1" = X--fallback-echo; then
+  # used as fallback echo
+  shift
+  cat <<EOF
+$*
+EOF
+  exit $EXIT_SUCCESS
+fi
+
+default_mode=
+help="Try \`$progname --help' for more information."
+magic="%%%MAGIC variable%%%"
+mkdir="mkdir"
+mv="mv -f"
+rm="rm -f"
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed="${SED}"' -e 1s/^X//'
+sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
+# test EBCDIC or ASCII
+case `echo X|tr X '\101'` in
+ A) # ASCII based system
+    # \n is not interpreted correctly by Solaris 8 /usr/ucb/tr
+  SP2NL='tr \040 \012'
+  NL2SP='tr \015\012 \040\040'
+  ;;
+ *) # EBCDIC based system
+  SP2NL='tr \100 \n'
+  NL2SP='tr \r\n \100\100'
+  ;;
+esac
+
+# NLS nuisances.
+# Only set LANG and LC_ALL to C if already set.
+# These must not be set unconditionally because not all systems understand
+# e.g. LANG=C (notably SCO).
+# We save the old values to restore during execute mode.
+if test "${LC_ALL+set}" = set; then
+  save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
+fi
+if test "${LANG+set}" = set; then
+  save_LANG="$LANG"; LANG=C; export LANG
+fi
+
+# Make sure IFS has a sensible default
+lt_nl='
+'
+IFS="  $lt_nl"
+
+if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
+  $echo "$modename: not configured to build any kind of library" 1>&2
+  $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+  exit $EXIT_FAILURE
+fi
+
+# Global variables.
+mode=$default_mode
+nonopt=
+prev=
+prevopt=
+run=
+show="$echo"
+show_help=
+execute_dlfiles=
+duplicate_deps=no
+preserve_args=
+lo2o="s/\\.lo\$/.${objext}/"
+o2lo="s/\\.${objext}\$/.lo/"
+
+#####################################
+# Shell function definitions:
+# This seems to be the best place for them
+
+# func_mktempdir [string]
+# Make a temporary directory that won't clash with other running
+# libtool processes, and avoids race conditions if possible.  If
+# given, STRING is the basename for that directory.
+func_mktempdir ()
+{
+    my_template="${TMPDIR-/tmp}/${1-$progname}"
+
+    if test "$run" = ":"; then
+      # Return a directory name, but don't create it in dry-run mode
+      my_tmpdir="${my_template}-$$"
+    else
+
+      # If mktemp works, use that first and foremost
+      my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
+
+      if test ! -d "$my_tmpdir"; then
+       # Failing that, at least try and use $RANDOM to avoid a race
+       my_tmpdir="${my_template}-${RANDOM-0}$$"
+
+       save_mktempdir_umask=`umask`
+       umask 0077
+       $mkdir "$my_tmpdir"
+       umask $save_mktempdir_umask
+      fi
+
+      # If we're not in dry-run mode, bomb out on failure
+      test -d "$my_tmpdir" || {
+        $echo "cannot create temporary directory \`$my_tmpdir'" 1>&2
+       exit $EXIT_FAILURE
+      }
+    fi
+
+    $echo "X$my_tmpdir" | $Xsed
+}
+
+
+# func_win32_libid arg
+# return the library type of file 'arg'
+#
+# Need a lot of goo to handle *both* DLLs and import libs
+# Has to be a shell function in order to 'eat' the argument
+# that is supplied when $file_magic_command is called.
+func_win32_libid ()
+{
+  win32_libid_type="unknown"
+  win32_fileres=`file -L $1 2>/dev/null`
+  case $win32_fileres in
+  *ar\ archive\ import\ library*) # definitely import
+    win32_libid_type="x86 archive import"
+    ;;
+  *ar\ archive*) # could be an import, or static
+    if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
+      $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
+      win32_nmres=`eval $NM -f posix -A $1 | \
+       $SED -n -e '1,100{/ I /{s,.*,import,;p;q;};}'`
+      case $win32_nmres in
+      import*)  win32_libid_type="x86 archive import";;
+      *)        win32_libid_type="x86 archive static";;
+      esac
+    fi
+    ;;
+  *DLL*)
+    win32_libid_type="x86 DLL"
+    ;;
+  *executable*) # but shell scripts are "executable" too...
+    case $win32_fileres in
+    *MS\ Windows\ PE\ Intel*)
+      win32_libid_type="x86 DLL"
+      ;;
+    esac
+    ;;
+  esac
+  $echo $win32_libid_type
+}
+
+
+# func_infer_tag arg
+# Infer tagged configuration to use if any are available and
+# if one wasn't chosen via the "--tag" command line option.
+# Only attempt this if the compiler in the base compile
+# command doesn't match the default compiler.
+# arg is usually of the form 'gcc ...'
+func_infer_tag ()
+{
+    if test -n "$available_tags" && test -z "$tagname"; then
+      CC_quoted=
+      for arg in $CC; do
+       case $arg in
+         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
+         arg="\"$arg\""
+         ;;
+       esac
+       CC_quoted="$CC_quoted $arg"
+      done
+      case $@ in
+      # Blanks in the command may have been stripped by the calling shell,
+      # but not from the CC environment variable when configure was run.
+      " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
+      # Blanks at the start of $base_compile will cause this to fail
+      # if we don't check for them as well.
+      *)
+       for z in $available_tags; do
+         if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
+           # Evaluate the configuration.
+           eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
+           CC_quoted=
+           for arg in $CC; do
+           # Double-quote args containing other shell metacharacters.
+           case $arg in
+             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
+             arg="\"$arg\""
+             ;;
+           esac
+           CC_quoted="$CC_quoted $arg"
+         done
+           case "$@ " in
+             " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
+             # The compiler in the base compile command matches
+             # the one in the tagged configuration.
+             # Assume this is the tagged configuration we want.
+             tagname=$z
+             break
+             ;;
+           esac
+         fi
+       done
+       # If $tagname still isn't set, then no tagged configuration
+       # was found and let the user know that the "--tag" command
+       # line option must be used.
+       if test -z "$tagname"; then
+         $echo "$modename: unable to infer tagged configuration"
+         $echo "$modename: specify a tag with \`--tag'" 1>&2
+         exit $EXIT_FAILURE
+#        else
+#          $echo "$modename: using $tagname tagged configuration"
+       fi
+       ;;
+      esac
+    fi
+}
+
+
+# func_extract_an_archive dir oldlib
+func_extract_an_archive ()
+{
+    f_ex_an_ar_dir="$1"; shift
+    f_ex_an_ar_oldlib="$1"
+
+    $show "(cd $f_ex_an_ar_dir && $AR x $f_ex_an_ar_oldlib)"
+    $run eval "(cd \$f_ex_an_ar_dir && $AR x \$f_ex_an_ar_oldlib)" || exit $?
+    if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
+     :
+    else
+      $echo "$modename: ERROR: object name conflicts: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 1>&2
+      exit $EXIT_FAILURE
+    fi
+}
+
+# func_extract_archives gentop oldlib ...
+func_extract_archives ()
+{
+    my_gentop="$1"; shift
+    my_oldlibs=${1+"$@"}
+    my_oldobjs=""
+    my_xlib=""
+    my_xabs=""
+    my_xdir=""
+    my_status=""
+
+    $show "${rm}r $my_gentop"
+    $run ${rm}r "$my_gentop"
+    $show "$mkdir $my_gentop"
+    $run $mkdir "$my_gentop"
+    my_status=$?
+    if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
+      exit $my_status
+    fi
+
+    for my_xlib in $my_oldlibs; do
+      # Extract the objects.
+      case $my_xlib in
+       [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
+       *) my_xabs=`pwd`"/$my_xlib" ;;
+      esac
+      my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
+      my_xdir="$my_gentop/$my_xlib"
+
+      $show "${rm}r $my_xdir"
+      $run ${rm}r "$my_xdir"
+      $show "$mkdir $my_xdir"
+      $run $mkdir "$my_xdir"
+      exit_status=$?
+      if test "$exit_status" -ne 0 && test ! -d "$my_xdir"; then
+       exit $exit_status
+      fi
+      case $host in
+      *-darwin*)
+       $show "Extracting $my_xabs"
+       # Do not bother doing anything if just a dry run
+       if test -z "$run"; then
+         darwin_orig_dir=`pwd`
+         cd $my_xdir || exit $?
+         darwin_archive=$my_xabs
+         darwin_curdir=`pwd`
+         darwin_base_archive=`$echo "X$darwin_archive" | $Xsed -e 's%^.*/%%'`
+         darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
+         if test -n "$darwin_arches"; then 
+           darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
+           darwin_arch=
+           $show "$darwin_base_archive has multiple architectures $darwin_arches"
+           for darwin_arch in  $darwin_arches ; do
+             mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+             lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
+             cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
+             func_extract_an_archive "`pwd`" "${darwin_base_archive}"
+             cd "$darwin_curdir"
+             $rm "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
+           done # $darwin_arches
+      ## Okay now we have a bunch of thin objects, gotta fatten them up :)
+           darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print| xargs basename | sort -u | $NL2SP`
+           darwin_file=
+           darwin_files=
+           for darwin_file in $darwin_filelist; do
+             darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
+             lipo -create -output "$darwin_file" $darwin_files
+           done # $darwin_filelist
+           ${rm}r unfat-$$
+           cd "$darwin_orig_dir"
+         else
+           cd "$darwin_orig_dir"
+           func_extract_an_archive "$my_xdir" "$my_xabs"
+         fi # $darwin_arches
+       fi # $run
+       ;;
+      *)
+        func_extract_an_archive "$my_xdir" "$my_xabs"
+        ;;
+      esac
+      my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
+    done
+    func_extract_archives_result="$my_oldobjs"
+}
+# End of Shell function definitions
+#####################################
+
+# Darwin sucks
+eval std_shrext=\"$shrext_cmds\"
+
+disable_libs=no
+
+# Parse our command line options once, thoroughly.
+while test "$#" -gt 0
+do
+  arg="$1"
+  shift
+
+  case $arg in
+  -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
+  *) optarg= ;;
+  esac
+
+  # If the previous option needs an argument, assign it.
+  if test -n "$prev"; then
+    case $prev in
+    execute_dlfiles)
+      execute_dlfiles="$execute_dlfiles $arg"
+      ;;
+    tag)
+      tagname="$arg"
+      preserve_args="${preserve_args}=$arg"
+
+      # Check whether tagname contains only valid characters
+      case $tagname in
+      *[!-_A-Za-z0-9,/]*)
+       $echo "$progname: invalid tag name: $tagname" 1>&2
+       exit $EXIT_FAILURE
+       ;;
+      esac
+
+      case $tagname in
+      CC)
+       # Don't test for the "default" C tag, as we know, it's there, but
+       # not specially marked.
+       ;;
+      *)
+       if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
+         taglist="$taglist $tagname"
+         # Evaluate the configuration.
+         eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
+       else
+         $echo "$progname: ignoring unknown tag $tagname" 1>&2
+       fi
+       ;;
+      esac
+      ;;
+    *)
+      eval "$prev=\$arg"
+      ;;
+    esac
+
+    prev=
+    prevopt=
+    continue
+  fi
+
+  # Have we seen a non-optional argument yet?
+  case $arg in
+  --help)
+    show_help=yes
+    ;;
+
+  --version)
+    $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
+    $echo
+    $echo "Copyright (C) 2005  Free Software Foundation, Inc."
+    $echo "This is free software; see the source for copying conditions.  There is NO"
+    $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
+    exit $?
+    ;;
+
+  --config)
+    ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
+    # Now print the configurations for the tags.
+    for tagname in $taglist; do
+      ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
+    done
+    exit $?
+    ;;
+
+  --debug)
+    $echo "$progname: enabling shell trace mode"
+    set -x
+    preserve_args="$preserve_args $arg"
+    ;;
+
+  --dry-run | -n)
+    run=:
+    ;;
+
+  --features)
+    $echo "host: $host"
+    if test "$build_libtool_libs" = yes; then
+      $echo "enable shared libraries"
+    else
+      $echo "disable shared libraries"
+    fi
+    if test "$build_old_libs" = yes; then
+      $echo "enable static libraries"
+    else
+      $echo "disable static libraries"
+    fi
+    exit $?
+    ;;
+
+  --finish) mode="finish" ;;
+
+  --mode) prevopt="--mode" prev=mode ;;
+  --mode=*) mode="$optarg" ;;
+
+  --preserve-dup-deps) duplicate_deps="yes" ;;
+
+  --quiet | --silent)
+    show=:
+    preserve_args="$preserve_args $arg"
+    ;;
+
+  --tag)
+    prevopt="--tag"
+    prev=tag
+    preserve_args="$preserve_args --tag"
+    ;;
+  --tag=*)
+    set tag "$optarg" ${1+"$@"}
+    shift
+    prev=tag
+    preserve_args="$preserve_args --tag"
+    ;;
+
+  -dlopen)
+    prevopt="-dlopen"
+    prev=execute_dlfiles
+    ;;
+
+  -*)
+    $echo "$modename: unrecognized option \`$arg'" 1>&2
+    $echo "$help" 1>&2
+    exit $EXIT_FAILURE
+    ;;
+
+  *)
+    nonopt="$arg"
+    break
+    ;;
+  esac
+done
+
+if test -n "$prevopt"; then
+  $echo "$modename: option \`$prevopt' requires an argument" 1>&2
+  $echo "$help" 1>&2
+  exit $EXIT_FAILURE
+fi
+
+case $disable_libs in
+no) 
+  ;;
+shared)
+  build_libtool_libs=no
+  build_old_libs=yes
+  ;;
+static)
+  build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
+  ;;
+esac
+
+# If this variable is set in any of the actions, the command in it
+# will be execed at the end.  This prevents here-documents from being
+# left over by shells.
+exec_cmd=
+
+if test -z "$show_help"; then
+
+  # Infer the operation mode.
+  if test -z "$mode"; then
+    $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
+    $echo "*** Future versions of Libtool will require --mode=MODE be specified." 1>&2
+    case $nonopt in
+    *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
+      mode=link
+      for arg
+      do
+       case $arg in
+       -c)
+          mode=compile
+          break
+          ;;
+       esac
+      done
+      ;;
+    *db | *dbx | *strace | *truss)
+      mode=execute
+      ;;
+    *install*|cp|mv)
+      mode=install
+      ;;
+    *rm)
+      mode=uninstall
+      ;;
+    *)
+      # If we have no mode, but dlfiles were specified, then do execute mode.
+      test -n "$execute_dlfiles" && mode=execute
+
+      # Just use the default operation mode.
+      if test -z "$mode"; then
+       if test -n "$nonopt"; then
+         $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
+       else
+         $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
+       fi
+      fi
+      ;;
+    esac
+  fi
+
+  # Only execute mode is allowed to have -dlopen flags.
+  if test -n "$execute_dlfiles" && test "$mode" != execute; then
+    $echo "$modename: unrecognized option \`-dlopen'" 1>&2
+    $echo "$help" 1>&2
+    exit $EXIT_FAILURE
+  fi
+
+  # Change the help message to a mode-specific one.
+  generic_help="$help"
+  help="Try \`$modename --help --mode=$mode' for more information."
+
+  # These modes are in order of execution frequency so that they run quickly.
+  case $mode in
+  # libtool compile mode
+  compile)
+    modename="$modename: compile"
+    # Get the compilation command and the source file.
+    base_compile=
+    srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
+    suppress_opt=yes
+    suppress_output=
+    arg_mode=normal
+    libobj=
+    later=
+
+    for arg
+    do
+      case $arg_mode in
+      arg  )
+       # do not "continue".  Instead, add this to base_compile
+       lastarg="$arg"
+       arg_mode=normal
+       ;;
+
+      target )
+       libobj="$arg"
+       arg_mode=normal
+       continue
+       ;;
+
+      normal )
+       # Accept any command-line options.
+       case $arg in
+       -o)
+         if test -n "$libobj" ; then
+           $echo "$modename: you cannot specify \`-o' more than once" 1>&2
+           exit $EXIT_FAILURE
+         fi
+         arg_mode=target
+         continue
+         ;;
+
+       -static | -prefer-pic | -prefer-non-pic)
+         later="$later $arg"
+         continue
+         ;;
+
+       -no-suppress)
+         suppress_opt=no
+         continue
+         ;;
+
+       -Xcompiler)
+         arg_mode=arg  #  the next one goes into the "base_compile" arg list
+         continue      #  The current "srcfile" will either be retained or
+         ;;            #  replaced later.  I would guess that would be a bug.
+
+       -Wc,*)
+         args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
+         lastarg=
+         save_ifs="$IFS"; IFS=','
+         for arg in $args; do
+           IFS="$save_ifs"
+
+           # Double-quote args containing other shell metacharacters.
+           # Many Bourne shells cannot handle close brackets correctly
+           # in scan sets, so we specify it separately.
+           case $arg in
+             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
+             arg="\"$arg\""
+             ;;
+           esac
+           lastarg="$lastarg $arg"
+         done
+         IFS="$save_ifs"
+         lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
+
+         # Add the arguments to base_compile.
+         base_compile="$base_compile $lastarg"
+         continue
+         ;;
+
+       * )
+         # Accept the current argument as the source file.
+         # The previous "srcfile" becomes the current argument.
+         #
+         lastarg="$srcfile"
+         srcfile="$arg"
+         ;;
+       esac  #  case $arg
+       ;;
+      esac    #  case $arg_mode
+
+      # Aesthetically quote the previous argument.
+      lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
+
+      case $lastarg in
+      # Double-quote args containing other shell metacharacters.
+      # Many Bourne shells cannot handle close brackets correctly
+      # in scan sets, and some SunOS ksh mistreat backslash-escaping
+      # in scan sets (worked around with variable expansion),
+      # and furthermore cannot handle '|' '&' '(' ')' in scan sets 
+      # at all, so we specify them separately.
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+       lastarg="\"$lastarg\""
+       ;;
+      esac
+
+      base_compile="$base_compile $lastarg"
+    done # for arg
+
+    case $arg_mode in
+    arg)
+      $echo "$modename: you must specify an argument for -Xcompile"
+      exit $EXIT_FAILURE
+      ;;
+    target)
+      $echo "$modename: you must specify a target with \`-o'" 1>&2
+      exit $EXIT_FAILURE
+      ;;
+    *)
+      # Get the name of the library object.
+      [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
+      ;;
+    esac
+
+    # Recognize several different file suffixes.
+    # If the user specifies -o file.o, it is replaced with file.lo
+    xform='[cCFSifmso]'
+    case $libobj in
+    *.ada) xform=ada ;;
+    *.adb) xform=adb ;;
+    *.ads) xform=ads ;;
+    *.asm) xform=asm ;;
+    *.c++) xform=c++ ;;
+    *.cc) xform=cc ;;
+    *.ii) xform=ii ;;
+    *.class) xform=class ;;
+    *.cpp) xform=cpp ;;
+    *.cxx) xform=cxx ;;
+    *.f90) xform=f90 ;;
+    *.for) xform=for ;;
+    *.java) xform=java ;;
+    esac
+
+    libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
+
+    case $libobj in
+    *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
+    *)
+      $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
+      exit $EXIT_FAILURE
+      ;;
+    esac
+
+    func_infer_tag $base_compile
+
+    for arg in $later; do
+      case $arg in
+      -static)
+       build_old_libs=yes
+       continue
+       ;;
+
+      -prefer-pic)
+       pic_mode=yes
+       continue
+       ;;
+
+      -prefer-non-pic)
+       pic_mode=no
+       continue
+       ;;
+      esac
+    done
+
+    qlibobj=`$echo "X$libobj" | $Xsed -e "$sed_quote_subst"`
+    case $qlibobj in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+       qlibobj="\"$qlibobj\"" ;;
+    esac
+    test "X$libobj" != "X$qlibobj" \
+       && $echo "X$libobj" | grep '[]~#^*{};<>?"'"'"'  &()|`$[]' \
+       && $echo "$modename: libobj name \`$libobj' may not contain shell special characters."
+    objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+    xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
+    if test "X$xdir" = "X$obj"; then
+      xdir=
+    else
+      xdir=$xdir/
+    fi
+    lobj=${xdir}$objdir/$objname
+
+    if test -z "$base_compile"; then
+      $echo "$modename: you must specify a compilation command" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    # Delete any leftover library objects.
+    if test "$build_old_libs" = yes; then
+      removelist="$obj $lobj $libobj ${libobj}T"
+    else
+      removelist="$lobj $libobj ${libobj}T"
+    fi
+
+    $run $rm $removelist
+    trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
+
+    # On Cygwin there's no "real" PIC flag so we must build both object types
+    case $host_os in
+    cygwin* | mingw* | pw32* | os2*)
+      pic_mode=default
+      ;;
+    esac
+    if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
+      # non-PIC code in shared libraries is not supported
+      pic_mode=default
+    fi
+
+    # Calculate the filename of the output object if compiler does
+    # not support -o with -c
+    if test "$compiler_c_o" = no; then
+      output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
+      lockfile="$output_obj.lock"
+      removelist="$removelist $output_obj $lockfile"
+      trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
+    else
+      output_obj=
+      need_locks=no
+      lockfile=
+    fi
+
+    # Lock this critical section if it is needed
+    # We use this script file to make the link, it avoids creating a new file
+    if test "$need_locks" = yes; then
+      until $run ln "$progpath" "$lockfile" 2>/dev/null; do
+       $show "Waiting for $lockfile to be removed"
+       sleep 2
+      done
+    elif test "$need_locks" = warn; then
+      if test -f "$lockfile"; then
+       $echo "\
+*** ERROR, $lockfile exists and contains:
+`cat $lockfile 2>/dev/null`
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit $EXIT_FAILURE
+      fi
+      $echo "$srcfile" > "$lockfile"
+    fi
+
+    if test -n "$fix_srcfile_path"; then
+      eval srcfile=\"$fix_srcfile_path\"
+    fi
+    qsrcfile=`$echo "X$srcfile" | $Xsed -e "$sed_quote_subst"`
+    case $qsrcfile in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+      qsrcfile="\"$qsrcfile\"" ;;
+    esac
+
+    $run $rm "$libobj" "${libobj}T"
+
+    # Create a libtool object file (analogous to a ".la" file),
+    # but don't create it if we're doing a dry run.
+    test -z "$run" && cat > ${libobj}T <<EOF
+# $libobj - a libtool object file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# Name of the PIC object.
+EOF
+
+    # Only build a PIC object if we are building libtool libraries.
+    if test "$build_libtool_libs" = yes; then
+      # Without this assignment, base_compile gets emptied.
+      fbsd_hideous_sh_bug=$base_compile
+
+      if test "$pic_mode" != no; then
+       command="$base_compile $qsrcfile $pic_flag"
+      else
+       # Don't build PIC code
+       command="$base_compile $qsrcfile"
+      fi
+
+      if test ! -d "${xdir}$objdir"; then
+       $show "$mkdir ${xdir}$objdir"
+       $run $mkdir ${xdir}$objdir
+       exit_status=$?
+       if test "$exit_status" -ne 0 && test ! -d "${xdir}$objdir"; then
+         exit $exit_status
+       fi
+      fi
+
+      if test -z "$output_obj"; then
+       # Place PIC objects in $objdir
+       command="$command -o $lobj"
+      fi
+
+      $run $rm "$lobj" "$output_obj"
+
+      $show "$command"
+      if $run eval "$command"; then :
+      else
+       test -n "$output_obj" && $run $rm $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      if test "$need_locks" = warn &&
+        test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+       $echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed, then go on to compile the next one
+      if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
+       $show "$mv $output_obj $lobj"
+       if $run $mv $output_obj $lobj; then :
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
+      fi
+
+      # Append the name of the PIC object to the libtool object file.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+pic_object='$objdir/$objname'
+
+EOF
+
+      # Allow error messages only from the first compilation.
+      if test "$suppress_opt" = yes; then
+        suppress_output=' >/dev/null 2>&1'
+      fi
+    else
+      # No PIC object so indicate it doesn't exist in the libtool
+      # object file.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+pic_object=none
+
+EOF
+    fi
+
+    # Only build a position-dependent object if we build old libraries.
+    if test "$build_old_libs" = yes; then
+      if test "$pic_mode" != yes; then
+       # Don't build PIC code
+       command="$base_compile $qsrcfile"
+      else
+       command="$base_compile $qsrcfile $pic_flag"
+      fi
+      if test "$compiler_c_o" = yes; then
+       command="$command -o $obj"
+      fi
+
+      # Suppress compiler output if we already did a PIC compilation.
+      command="$command$suppress_output"
+      $run $rm "$obj" "$output_obj"
+      $show "$command"
+      if $run eval "$command"; then :
+      else
+       $run $rm $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      if test "$need_locks" = warn &&
+        test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
+       $echo "\
+*** ERROR, $lockfile contains:
+`cat $lockfile 2>/dev/null`
+
+but it should contain:
+$srcfile
+
+This indicates that another process is trying to use the same
+temporary object file, and libtool could not work around it because
+your compiler does not support \`-c' and \`-o' together.  If you
+repeat this compilation, it may succeed, by chance, but you had better
+avoid parallel builds (make -j) in this platform, or get a better
+compiler."
+
+       $run $rm $removelist
+       exit $EXIT_FAILURE
+      fi
+
+      # Just move the object if needed
+      if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
+       $show "$mv $output_obj $obj"
+       if $run $mv $output_obj $obj; then :
+       else
+         error=$?
+         $run $rm $removelist
+         exit $error
+       fi
+      fi
+
+      # Append the name of the non-PIC object the libtool object file.
+      # Only append if the libtool object file exists.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+# Name of the non-PIC object.
+non_pic_object='$objname'
+
+EOF
+    else
+      # Append the name of the non-PIC object the libtool object file.
+      # Only append if the libtool object file exists.
+      test -z "$run" && cat >> ${libobj}T <<EOF
+# Name of the non-PIC object.
+non_pic_object=none
+
+EOF
+    fi
+
+    $run $mv "${libobj}T" "${libobj}"
+
+    # Unlock the critical section if it was locked
+    if test "$need_locks" != no; then
+      $run $rm "$lockfile"
+    fi
+
+    exit $EXIT_SUCCESS
+    ;;
+
+  # libtool link mode
+  link | relink)
+    modename="$modename: link"
+    case $host in
+    *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+      # It is impossible to link a dll without this setting, and
+      # we shouldn't force the makefile maintainer to figure out
+      # which system we are compiling for in order to pass an extra
+      # flag for every libtool invocation.
+      # allow_undefined=no
+
+      # FIXME: Unfortunately, there are problems with the above when trying
+      # to make a dll which has undefined symbols, in which case not
+      # even a static library is built.  For now, we need to specify
+      # -no-undefined on the libtool link line when we can be certain
+      # that all symbols are satisfied, otherwise we get a static library.
+      allow_undefined=yes
+      ;;
+    *)
+      allow_undefined=yes
+      ;;
+    esac
+    libtool_args="$nonopt"
+    base_compile="$nonopt $@"
+    compile_command="$nonopt"
+    finalize_command="$nonopt"
+
+    compile_rpath=
+    finalize_rpath=
+    compile_shlibpath=
+    finalize_shlibpath=
+    convenience=
+    old_convenience=
+    deplibs=
+    old_deplibs=
+    compiler_flags=
+    linker_flags=
+    dllsearchpath=
+    lib_search_path=`pwd`
+    inst_prefix_dir=
+
+    avoid_version=no
+    dlfiles=
+    dlprefiles=
+    dlself=no
+    export_dynamic=no
+    export_symbols=
+    export_symbols_regex=
+    generated=
+    libobjs=
+    ltlibs=
+    module=no
+    no_install=no
+    objs=
+    non_pic_objects=
+    notinst_path= # paths that contain not-installed libtool libraries
+    precious_files_regex=
+    prefer_static_libs=no
+    preload=no
+    prev=
+    prevarg=
+    release=
+    rpath=
+    xrpath=
+    perm_rpath=
+    temp_rpath=
+    thread_safe=no
+    vinfo=
+    vinfo_number=no
+
+    func_infer_tag $base_compile
+
+    # We need to know -static, to get the right output filenames.
+    for arg
+    do
+      case $arg in
+      -all-static | -static)
+       if test "X$arg" = "X-all-static"; then
+         if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
+           $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
+         fi
+         if test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+         prefer_static_libs=yes
+       else
+         if test -z "$pic_flag" && test -n "$link_static_flag"; then
+           dlopen_self=$dlopen_self_static
+         fi
+         prefer_static_libs=built
+       fi
+       build_libtool_libs=no
+       build_old_libs=yes
+       break
+       ;;
+      esac
+    done
+
+    # See if our shared archives depend on static archives.
+    test -n "$old_archive_from_new_cmds" && build_old_libs=yes
+
+    # Go through the arguments, transforming them on the way.
+    while test "$#" -gt 0; do
+      arg="$1"
+      shift
+      case $arg in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+       qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
+       ;;
+      *) qarg=$arg ;;
+      esac
+      libtool_args="$libtool_args $qarg"
+
+      # If the previous option needs an argument, assign it.
+      if test -n "$prev"; then
+       case $prev in
+       output)
+         compile_command="$compile_command @OUTPUT@"
+         finalize_command="$finalize_command @OUTPUT@"
+         ;;
+       esac
+
+       case $prev in
+       dlfiles|dlprefiles)
+         if test "$preload" = no; then
+           # Add the symbol object into the linking commands.
+           compile_command="$compile_command @SYMFILE@"
+           finalize_command="$finalize_command @SYMFILE@"
+           preload=yes
+         fi
+         case $arg in
+         *.la | *.lo) ;;  # We handle these cases below.
+         force)
+           if test "$dlself" = no; then
+             dlself=needless
+             export_dynamic=yes
+           fi
+           prev=
+           continue
+           ;;
+         self)
+           if test "$prev" = dlprefiles; then
+             dlself=yes
+           elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
+             dlself=yes
+           else
+             dlself=needless
+             export_dynamic=yes
+           fi
+           prev=
+           continue
+           ;;
+         *)
+           if test "$prev" = dlfiles; then
+             dlfiles="$dlfiles $arg"
+           else
+             dlprefiles="$dlprefiles $arg"
+           fi
+           prev=
+           continue
+           ;;
+         esac
+         ;;
+       expsyms)
+         export_symbols="$arg"
+         if test ! -f "$arg"; then
+           $echo "$modename: symbol file \`$arg' does not exist"
+           exit $EXIT_FAILURE
+         fi
+         prev=
+         continue
+         ;;
+       expsyms_regex)
+         export_symbols_regex="$arg"
+         prev=
+         continue
+         ;;
+       inst_prefix)
+         inst_prefix_dir="$arg"
+         prev=
+         continue
+         ;;
+       precious_regex)
+         precious_files_regex="$arg"
+         prev=
+         continue
+         ;;
+       release)
+         release="-$arg"
+         prev=
+         continue
+         ;;
+       objectlist)
+         if test -f "$arg"; then
+           save_arg=$arg
+           moreargs=
+           for fil in `cat $save_arg`
+           do
+#            moreargs="$moreargs $fil"
+             arg=$fil
+             # A libtool-controlled object.
+
+             # Check to see that this really is a libtool object.
+             if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+               pic_object=
+               non_pic_object=
+
+               # Read the .lo file
+               # If there is no directory component, then add one.
+               case $arg in
+               */* | *\\*) . $arg ;;
+               *) . ./$arg ;;
+               esac
+
+               if test -z "$pic_object" || \
+                  test -z "$non_pic_object" ||
+                  test "$pic_object" = none && \
+                  test "$non_pic_object" = none; then
+                 $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+                 exit $EXIT_FAILURE
+               fi
+
+               # Extract subdirectory from the argument.
+               xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+               if test "X$xdir" = "X$arg"; then
+                 xdir=
+               else
+                 xdir="$xdir/"
+               fi
+
+               if test "$pic_object" != none; then
+                 # Prepend the subdirectory the object is found in.
+                 pic_object="$xdir$pic_object"
+
+                 if test "$prev" = dlfiles; then
+                   if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+                     dlfiles="$dlfiles $pic_object"
+                     prev=
+                     continue
+                   else
+                     # If libtool objects are unsupported, then we need to preload.
+                     prev=dlprefiles
+                   fi
+                 fi
+
+                 # CHECK ME:  I think I busted this.  -Ossama
+                 if test "$prev" = dlprefiles; then
+                   # Preload the old-style object.
+                   dlprefiles="$dlprefiles $pic_object"
+                   prev=
+                 fi
+
+                 # A PIC object.
+                 libobjs="$libobjs $pic_object"
+                 arg="$pic_object"
+               fi
+
+               # Non-PIC object.
+               if test "$non_pic_object" != none; then
+                 # Prepend the subdirectory the object is found in.
+                 non_pic_object="$xdir$non_pic_object"
+
+                 # A standard non-PIC object
+                 non_pic_objects="$non_pic_objects $non_pic_object"
+                 if test -z "$pic_object" || test "$pic_object" = none ; then
+                   arg="$non_pic_object"
+                 fi
+               else
+                 # If the PIC object exists, use it instead.
+                 # $xdir was prepended to $pic_object above.
+                 non_pic_object="$pic_object"
+                 non_pic_objects="$non_pic_objects $non_pic_object"
+               fi
+             else
+               # Only an error if not doing a dry-run.
+               if test -z "$run"; then
+                 $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+                 exit $EXIT_FAILURE
+               else
+                 # Dry-run case.
+
+                 # Extract subdirectory from the argument.
+                 xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+                 if test "X$xdir" = "X$arg"; then
+                   xdir=
+                 else
+                   xdir="$xdir/"
+                 fi
+
+                 pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+                 non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+                 libobjs="$libobjs $pic_object"
+                 non_pic_objects="$non_pic_objects $non_pic_object"
+               fi
+             fi
+           done
+         else
+           $echo "$modename: link input file \`$save_arg' does not exist"
+           exit $EXIT_FAILURE
+         fi
+         arg=$save_arg
+         prev=
+         continue
+         ;;
+       rpath | xrpath)
+         # We need an absolute path.
+         case $arg in
+         [\\/]* | [A-Za-z]:[\\/]*) ;;
+         *)
+           $echo "$modename: only absolute run-paths are allowed" 1>&2
+           exit $EXIT_FAILURE
+           ;;
+         esac
+         if test "$prev" = rpath; then
+           case "$rpath " in
+           *" $arg "*) ;;
+           *) rpath="$rpath $arg" ;;
+           esac
+         else
+           case "$xrpath " in
+           *" $arg "*) ;;
+           *) xrpath="$xrpath $arg" ;;
+           esac
+         fi
+         prev=
+         continue
+         ;;
+       xcompiler)
+         compiler_flags="$compiler_flags $qarg"
+         prev=
+         compile_command="$compile_command $qarg"
+         finalize_command="$finalize_command $qarg"
+         continue
+         ;;
+       xlinker)
+         linker_flags="$linker_flags $qarg"
+         compiler_flags="$compiler_flags $wl$qarg"
+         prev=
+         compile_command="$compile_command $wl$qarg"
+         finalize_command="$finalize_command $wl$qarg"
+         continue
+         ;;
+       xcclinker)
+         linker_flags="$linker_flags $qarg"
+         compiler_flags="$compiler_flags $qarg"
+         prev=
+         compile_command="$compile_command $qarg"
+         finalize_command="$finalize_command $qarg"
+         continue
+         ;;
+       shrext)
+         shrext_cmds="$arg"
+         prev=
+         continue
+         ;;
+       darwin_framework|darwin_framework_skip)
+         test "$prev" = "darwin_framework" && compiler_flags="$compiler_flags $arg"
+         compile_command="$compile_command $arg"
+         finalize_command="$finalize_command $arg"
+         prev=
+         continue
+         ;;
+       *)
+         eval "$prev=\"\$arg\""
+         prev=
+         continue
+         ;;
+       esac
+      fi # test -n "$prev"
+
+      prevarg="$arg"
+
+      case $arg in
+      -all-static)
+       if test -n "$link_static_flag"; then
+         compile_command="$compile_command $link_static_flag"
+         finalize_command="$finalize_command $link_static_flag"
+       fi
+       continue
+       ;;
+
+      -allow-undefined)
+       # FIXME: remove this flag sometime in the future.
+       $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
+       continue
+       ;;
+
+      -avoid-version)
+       avoid_version=yes
+       continue
+       ;;
+
+      -dlopen)
+       prev=dlfiles
+       continue
+       ;;
+
+      -dlpreopen)
+       prev=dlprefiles
+       continue
+       ;;
+
+      -export-dynamic)
+       export_dynamic=yes
+       continue
+       ;;
+
+      -export-symbols | -export-symbols-regex)
+       if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+         $echo "$modename: more than one -exported-symbols argument is not allowed"
+         exit $EXIT_FAILURE
+       fi
+       if test "X$arg" = "X-export-symbols"; then
+         prev=expsyms
+       else
+         prev=expsyms_regex
+       fi
+       continue
+       ;;
+
+      -framework|-arch|-isysroot)
+       case " $CC " in
+         *" ${arg} ${1} "* | *" ${arg} ${1} "*) 
+               prev=darwin_framework_skip ;;
+         *) compiler_flags="$compiler_flags $arg"
+            prev=darwin_framework ;;
+       esac
+       compile_command="$compile_command $arg"
+       finalize_command="$finalize_command $arg"
+       continue
+       ;;
+
+      -inst-prefix-dir)
+       prev=inst_prefix
+       continue
+       ;;
+
+      # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
+      # so, if we see these flags be careful not to treat them like -L
+      -L[A-Z][A-Z]*:*)
+       case $with_gcc/$host in
+       no/*-*-irix* | /*-*-irix*)
+         compile_command="$compile_command $arg"
+         finalize_command="$finalize_command $arg"
+         ;;
+       esac
+       continue
+       ;;
+
+      -L*)
+       dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
+       # We need an absolute path.
+       case $dir in
+       [\\/]* | [A-Za-z]:[\\/]*) ;;
+       *)
+         absdir=`cd "$dir" && pwd`
+         if test -z "$absdir"; then
+           $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
+           absdir="$dir"
+           notinst_path="$notinst_path $dir"
+         fi
+         dir="$absdir"
+         ;;
+       esac
+       case "$deplibs " in
+       *" -L$dir "*) ;;
+       *)
+         deplibs="$deplibs -L$dir"
+         lib_search_path="$lib_search_path $dir"
+         ;;
+       esac
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+         testbindir=`$echo "X$dir" | $Xsed -e 's*/lib$*/bin*'`
+         case :$dllsearchpath: in
+         *":$dir:"*) ;;
+         *) dllsearchpath="$dllsearchpath:$dir";;
+         esac
+         case :$dllsearchpath: in
+         *":$testbindir:"*) ;;
+         *) dllsearchpath="$dllsearchpath:$testbindir";;
+         esac
+         ;;
+       esac
+       continue
+       ;;
+
+      -l*)
+       if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
+         case $host in
+         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos*)
+           # These systems don't actually have a C or math library (as such)
+           continue
+           ;;
+         *-*-os2*)
+           # These systems don't actually have a C library (as such)
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+           # Do not include libc due to us having libc/libc_r.
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-rhapsody* | *-*-darwin1.[012])
+           # Rhapsody C and math libraries are in the System framework
+           deplibs="$deplibs -framework System"
+           continue
+           ;;
+         *-*-sco3.2v5* | *-*-sco5v6*)
+           # Causes problems with __ctype
+           test "X$arg" = "X-lc" && continue
+           ;;
+         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+           # Compiler inserts libc in the correct place for threads to work
+           test "X$arg" = "X-lc" && continue
+           ;;
+         esac
+       elif test "X$arg" = "X-lc_r"; then
+        case $host in
+        *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+          # Do not include libc_r directly, use -pthread flag.
+          continue
+          ;;
+        esac
+       fi
+       deplibs="$deplibs $arg"
+       continue
+       ;;
+
+      # Tru64 UNIX uses -model [arg] to determine the layout of C++
+      # classes, name mangling, and exception handling.
+      -model)
+       compile_command="$compile_command $arg"
+       compiler_flags="$compiler_flags $arg"
+       finalize_command="$finalize_command $arg"
+       prev=xcompiler
+       continue
+       ;;
+
+     -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
+       compiler_flags="$compiler_flags $arg"
+       compile_command="$compile_command $arg"
+       finalize_command="$finalize_command $arg"
+       continue
+       ;;
+
+      -module)
+       module=yes
+       continue
+       ;;
+
+      # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
+      # -r[0-9][0-9]* specifies the processor on the SGI compiler
+      # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
+      # +DA*, +DD* enable 64-bit mode on the HP compiler
+      # -q* pass through compiler args for the IBM compiler
+      # -m* pass through architecture-specific compiler args for GCC
+      # -m*, -t[45]*, -txscale* pass through architecture-specific
+      # compiler args for GCC
+      # -pg pass through profiling flag for GCC
+      # @file GCC response files
+      -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*|-pg| \
+      -t[45]*|-txscale*|@*)
+
+       # Unknown arguments in both finalize_command and compile_command need
+       # to be aesthetically quoted because they are evaled later.
+       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+       case $arg in
+       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
+         arg="\"$arg\""
+         ;;
+       esac
+        compile_command="$compile_command $arg"
+        finalize_command="$finalize_command $arg"
+        compiler_flags="$compiler_flags $arg"
+        continue
+        ;;
+
+      -shrext)
+       prev=shrext
+       continue
+       ;;
+
+      -no-fast-install)
+       fast_install=no
+       continue
+       ;;
+
+      -no-install)
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+         # The PATH hackery in wrapper scripts is required on Windows
+         # in order for the loader to find any dlls it needs.
+         $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
+         $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
+         fast_install=no
+         ;;
+       *) no_install=yes ;;
+       esac
+       continue
+       ;;
+
+      -no-undefined)
+       allow_undefined=no
+       continue
+       ;;
+
+      -objectlist)
+       prev=objectlist
+       continue
+       ;;
+
+      -o) prev=output ;;
+
+      -precious-files-regex)
+       prev=precious_regex
+       continue
+       ;;
+
+      -release)
+       prev=release
+       continue
+       ;;
+
+      -rpath)
+       prev=rpath
+       continue
+       ;;
+
+      -R)
+       prev=xrpath
+       continue
+       ;;
+
+      -R*)
+       dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
+       # We need an absolute path.
+       case $dir in
+       [\\/]* | [A-Za-z]:[\\/]*) ;;
+       *)
+         $echo "$modename: only absolute run-paths are allowed" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+       case "$xrpath " in
+       *" $dir "*) ;;
+       *) xrpath="$xrpath $dir" ;;
+       esac
+       continue
+       ;;
+
+      -static)
+       # The effects of -static are defined in a previous loop.
+       # We used to do the same as -all-static on platforms that
+       # didn't have a PIC flag, but the assumption that the effects
+       # would be equivalent was wrong.  It would break on at least
+       # Digital Unix and AIX.
+       continue
+       ;;
+
+      -thread-safe)
+       thread_safe=yes
+       continue
+       ;;
+
+      -version-info)
+       prev=vinfo
+       continue
+       ;;
+      -version-number)
+       prev=vinfo
+       vinfo_number=yes
+       continue
+       ;;
+
+      -Wc,*)
+       args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
+       arg=
+       save_ifs="$IFS"; IFS=','
+       for flag in $args; do
+         IFS="$save_ifs"
+         case $flag in
+           *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
+           flag="\"$flag\""
+           ;;
+         esac
+         arg="$arg $wl$flag"
+         compiler_flags="$compiler_flags $flag"
+       done
+       IFS="$save_ifs"
+       arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
+       ;;
+
+      -Wl,*)
+       args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
+       arg=
+       save_ifs="$IFS"; IFS=','
+       for flag in $args; do
+         IFS="$save_ifs"
+         case $flag in
+           *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
+           flag="\"$flag\""
+           ;;
+         esac
+         arg="$arg $wl$flag"
+         compiler_flags="$compiler_flags $wl$flag"
+         linker_flags="$linker_flags $flag"
+       done
+       IFS="$save_ifs"
+       arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
+       ;;
+
+      -Xcompiler)
+       prev=xcompiler
+       continue
+       ;;
+
+      -Xlinker)
+       prev=xlinker
+       continue
+       ;;
+
+      -XCClinker)
+       prev=xcclinker
+       continue
+       ;;
+
+      # Some other compiler flag.
+      -* | +*)
+       # Unknown arguments in both finalize_command and compile_command need
+       # to be aesthetically quoted because they are evaled later.
+       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+       case $arg in
+       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
+         arg="\"$arg\""
+         ;;
+       esac
+       ;;
+
+      *.$objext)
+       # A standard object.
+       objs="$objs $arg"
+       ;;
+
+      *.lo)
+       # A libtool-controlled object.
+
+       # Check to see that this really is a libtool object.
+       if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+         pic_object=
+         non_pic_object=
+
+         # Read the .lo file
+         # If there is no directory component, then add one.
+         case $arg in
+         */* | *\\*) . $arg ;;
+         *) . ./$arg ;;
+         esac
+
+         if test -z "$pic_object" || \
+            test -z "$non_pic_object" ||
+            test "$pic_object" = none && \
+            test "$non_pic_object" = none; then
+           $echo "$modename: cannot find name of object for \`$arg'" 1>&2
+           exit $EXIT_FAILURE
+         fi
+
+         # Extract subdirectory from the argument.
+         xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+         if test "X$xdir" = "X$arg"; then
+           xdir=
+         else
+           xdir="$xdir/"
+         fi
+
+         if test "$pic_object" != none; then
+           # Prepend the subdirectory the object is found in.
+           pic_object="$xdir$pic_object"
+
+           if test "$prev" = dlfiles; then
+             if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
+               dlfiles="$dlfiles $pic_object"
+               prev=
+               continue
+             else
+               # If libtool objects are unsupported, then we need to preload.
+               prev=dlprefiles
+             fi
+           fi
+
+           # CHECK ME:  I think I busted this.  -Ossama
+           if test "$prev" = dlprefiles; then
+             # Preload the old-style object.
+             dlprefiles="$dlprefiles $pic_object"
+             prev=
+           fi
+
+           # A PIC object.
+           libobjs="$libobjs $pic_object"
+           arg="$pic_object"
+         fi
+
+         # Non-PIC object.
+         if test "$non_pic_object" != none; then
+           # Prepend the subdirectory the object is found in.
+           non_pic_object="$xdir$non_pic_object"
+
+           # A standard non-PIC object
+           non_pic_objects="$non_pic_objects $non_pic_object"
+           if test -z "$pic_object" || test "$pic_object" = none ; then
+             arg="$non_pic_object"
+           fi
+         else
+           # If the PIC object exists, use it instead.
+           # $xdir was prepended to $pic_object above.
+           non_pic_object="$pic_object"
+           non_pic_objects="$non_pic_objects $non_pic_object"
+         fi
+       else
+         # Only an error if not doing a dry-run.
+         if test -z "$run"; then
+           $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
+           exit $EXIT_FAILURE
+         else
+           # Dry-run case.
+
+           # Extract subdirectory from the argument.
+           xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
+           if test "X$xdir" = "X$arg"; then
+             xdir=
+           else
+             xdir="$xdir/"
+           fi
+
+           pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
+           non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
+           libobjs="$libobjs $pic_object"
+           non_pic_objects="$non_pic_objects $non_pic_object"
+         fi
+       fi
+       ;;
+
+      *.$libext)
+       # An archive.
+       deplibs="$deplibs $arg"
+       old_deplibs="$old_deplibs $arg"
+       continue
+       ;;
+
+      *.la)
+       # A libtool-controlled library.
+
+       if test "$prev" = dlfiles; then
+         # This library was specified with -dlopen.
+         dlfiles="$dlfiles $arg"
+         prev=
+       elif test "$prev" = dlprefiles; then
+         # The library was specified with -dlpreopen.
+         dlprefiles="$dlprefiles $arg"
+         prev=
+       else
+         deplibs="$deplibs $arg"
+       fi
+       continue
+       ;;
+
+      # Some other compiler argument.
+      *)
+       # Unknown arguments in both finalize_command and compile_command need
+       # to be aesthetically quoted because they are evaled later.
+       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+       case $arg in
+       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
+         arg="\"$arg\""
+         ;;
+       esac
+       ;;
+      esac # arg
+
+      # Now actually substitute the argument into the commands.
+      if test -n "$arg"; then
+       compile_command="$compile_command $arg"
+       finalize_command="$finalize_command $arg"
+      fi
+    done # argument parsing loop
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
+      eval arg=\"$export_dynamic_flag_spec\"
+      compile_command="$compile_command $arg"
+      finalize_command="$finalize_command $arg"
+    fi
+
+    oldlibs=
+    # calculate the name of the file, without its directory
+    outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
+    libobjs_save="$libobjs"
+
+    if test -n "$shlibpath_var"; then
+      # get the directories listed in $shlibpath_var
+      eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
+    else
+      shlib_search_path=
+    fi
+    eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
+    eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
+
+    output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
+    if test "X$output_objdir" = "X$output"; then
+      output_objdir="$objdir"
+    else
+      output_objdir="$output_objdir/$objdir"
+    fi
+    # Create the object directory.
+    if test ! -d "$output_objdir"; then
+      $show "$mkdir $output_objdir"
+      $run $mkdir $output_objdir
+      exit_status=$?
+      if test "$exit_status" -ne 0 && test ! -d "$output_objdir"; then
+       exit $exit_status
+      fi
+    fi
+
+    # Determine the type of output
+    case $output in
+    "")
+      $echo "$modename: you must specify an output file" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+      ;;
+    *.$libext) linkmode=oldlib ;;
+    *.lo | *.$objext) linkmode=obj ;;
+    *.la) linkmode=lib ;;
+    *) linkmode=prog ;; # Anything else should be a program.
+    esac
+
+    case $host in
+    *cygwin* | *mingw* | *pw32*)
+      # don't eliminate duplications in $postdeps and $predeps
+      duplicate_compiler_generated_deps=yes
+      ;;
+    *)
+      duplicate_compiler_generated_deps=$duplicate_deps
+      ;;
+    esac
+    specialdeplibs=
+
+    libs=
+    # Find all interdependent deplibs by searching for libraries
+    # that are linked more than once (e.g. -la -lb -la)
+    for deplib in $deplibs; do
+      if test "X$duplicate_deps" = "Xyes" ; then
+       case "$libs " in
+       *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+       esac
+      fi
+      libs="$libs $deplib"
+    done
+
+    if test "$linkmode" = lib; then
+      libs="$predeps $libs $compiler_lib_search_path $postdeps"
+
+      # Compute libraries that are listed more than once in $predeps
+      # $postdeps and mark them as special (i.e., whose duplicates are
+      # not to be eliminated).
+      pre_post_deps=
+      if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
+       for pre_post_dep in $predeps $postdeps; do
+         case "$pre_post_deps " in
+         *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
+         esac
+         pre_post_deps="$pre_post_deps $pre_post_dep"
+       done
+      fi
+      pre_post_deps=
+    fi
+
+    deplibs=
+    newdependency_libs=
+    newlib_search_path=
+    need_relink=no # whether we're linking any uninstalled libtool libraries
+    notinst_deplibs= # not-installed libtool libraries
+    case $linkmode in
+    lib)
+       passes="conv link"
+       for file in $dlfiles $dlprefiles; do
+         case $file in
+         *.la) ;;
+         *)
+           $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
+           exit $EXIT_FAILURE
+           ;;
+         esac
+       done
+       ;;
+    prog)
+       compile_deplibs=
+       finalize_deplibs=
+       alldeplibs=no
+       newdlfiles=
+       newdlprefiles=
+       passes="conv scan dlopen dlpreopen link"
+       ;;
+    *)  passes="conv"
+       ;;
+    esac
+    for pass in $passes; do
+      if test "$linkmode,$pass" = "lib,link" ||
+        test "$linkmode,$pass" = "prog,scan"; then
+       libs="$deplibs"
+       deplibs=
+      fi
+      if test "$linkmode" = prog; then
+       case $pass in
+       dlopen) libs="$dlfiles" ;;
+       dlpreopen) libs="$dlprefiles" ;;
+       link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
+       esac
+      fi
+      if test "$pass" = dlopen; then
+       # Collect dlpreopened libraries
+       save_deplibs="$deplibs"
+       deplibs=
+      fi
+      for deplib in $libs; do
+       lib=
+       found=no
+       case $deplib in
+       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
+         if test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$deplib $compile_deplibs"
+           finalize_deplibs="$deplib $finalize_deplibs"
+         else
+           compiler_flags="$compiler_flags $deplib"
+         fi
+         continue
+         ;;
+       -l*)
+         if test "$linkmode" != lib && test "$linkmode" != prog; then
+           $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
+           continue
+         fi
+         name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
+         for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
+           for search_ext in .la $std_shrext .so .a; do
+             # Search the libtool library
+             lib="$searchdir/lib${name}${search_ext}"
+             if test -f "$lib"; then
+               if test "$search_ext" = ".la"; then
+                 found=yes
+               else
+                 found=no
+               fi
+               break 2
+             fi
+           done
+         done
+         if test "$found" != yes; then
+           # deplib doesn't seem to be a libtool library
+           if test "$linkmode,$pass" = "prog,link"; then
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           else
+             deplibs="$deplib $deplibs"
+             test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+           fi
+           continue
+         else # deplib is a libtool library
+           # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
+           # We need to do some special things here, and not later.
+           if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+             case " $predeps $postdeps " in
+             *" $deplib "*)
+               if (${SED} -e '2q' $lib |
+                    grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+                 library_names=
+                 old_library=
+                 case $lib in
+                 */* | *\\*) . $lib ;;
+                 *) . ./$lib ;;
+                 esac
+                 for l in $old_library $library_names; do
+                   ll="$l"
+                 done
+                 if test "X$ll" = "X$old_library" ; then # only static version available
+                   found=no
+                   ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+                   test "X$ladir" = "X$lib" && ladir="."
+                   lib=$ladir/$old_library
+                   if test "$linkmode,$pass" = "prog,link"; then
+                     compile_deplibs="$deplib $compile_deplibs"
+                     finalize_deplibs="$deplib $finalize_deplibs"
+                   else
+                     deplibs="$deplib $deplibs"
+                     test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
+                   fi
+                   continue
+                 fi
+               fi
+               ;;
+             *) ;;
+             esac
+           fi
+         fi
+         ;; # -l
+       -L*)
+         case $linkmode in
+         lib)
+           deplibs="$deplib $deplibs"
+           test "$pass" = conv && continue
+           newdependency_libs="$deplib $newdependency_libs"
+           newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+           ;;
+         prog)
+           if test "$pass" = conv; then
+             deplibs="$deplib $deplibs"
+             continue
+           fi
+           if test "$pass" = scan; then
+             deplibs="$deplib $deplibs"
+           else
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           fi
+           newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
+           ;;
+         *)
+           $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
+           ;;
+         esac # linkmode
+         continue
+         ;; # -L
+       -R*)
+         if test "$pass" = link; then
+           dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
+           # Make sure the xrpath contains only unique directories.
+           case "$xrpath " in
+           *" $dir "*) ;;
+           *) xrpath="$xrpath $dir" ;;
+           esac
+         fi
+         deplibs="$deplib $deplibs"
+         continue
+         ;;
+       *.la) lib="$deplib" ;;
+       *.$libext)
+         if test "$pass" = conv; then
+           deplibs="$deplib $deplibs"
+           continue
+         fi
+         case $linkmode in
+         lib)
+           valid_a_lib=no
+           case $deplibs_check_method in
+             match_pattern*)
+               set dummy $deplibs_check_method
+               match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+               if eval $echo \"$deplib\" 2>/dev/null \
+                   | $SED 10q \
+                   | $EGREP "$match_pattern_regex" > /dev/null; then
+                 valid_a_lib=yes
+               fi
+               ;;
+             pass_all)
+               valid_a_lib=yes
+               ;;
+            esac
+           if test "$valid_a_lib" != yes; then
+             $echo
+             $echo "*** Warning: Trying to link with static lib archive $deplib."
+             $echo "*** I have the capability to make that library automatically link in when"
+             $echo "*** you link to this library.  But I can only do this if you have a"
+             $echo "*** shared version of the library, which you do not appear to have"
+             $echo "*** because the file extensions .$libext of this argument makes me believe"
+             $echo "*** that it is just a static archive that I should not used here."
+           else
+             $echo
+             $echo "*** Warning: Linking the shared library $output against the"
+             $echo "*** static library $deplib is not portable!"
+             deplibs="$deplib $deplibs"
+           fi
+           continue
+           ;;
+         prog)
+           if test "$pass" != link; then
+             deplibs="$deplib $deplibs"
+           else
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           fi
+           continue
+           ;;
+         esac # linkmode
+         ;; # *.$libext
+       *.lo | *.$objext)
+         if test "$pass" = conv; then
+           deplibs="$deplib $deplibs"
+         elif test "$linkmode" = prog; then
+           if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
+             # If there is no dlopen support or we're linking statically,
+             # we need to preload.
+             newdlprefiles="$newdlprefiles $deplib"
+             compile_deplibs="$deplib $compile_deplibs"
+             finalize_deplibs="$deplib $finalize_deplibs"
+           else
+             newdlfiles="$newdlfiles $deplib"
+           fi
+         fi
+         continue
+         ;;
+       %DEPLIBS%)
+         alldeplibs=yes
+         continue
+         ;;
+       esac # case $deplib
+       if test "$found" = yes || test -f "$lib"; then :
+       else
+         $echo "$modename: cannot find the library \`$lib' or unhandled argument \`$deplib'" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       # Check to see that this really is a libtool archive.
+       if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       else
+         $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
+       test "X$ladir" = "X$lib" && ladir="."
+
+       dlname=
+       dlopen=
+       dlpreopen=
+       libdir=
+       library_names=
+       old_library=
+       # If the library was installed with an old release of libtool,
+       # it will not redefine variables installed, or shouldnotlink
+       installed=yes
+       shouldnotlink=no
+       avoidtemprpath=
+
+
+       # Read the .la file
+       case $lib in
+       */* | *\\*) . $lib ;;
+       *) . ./$lib ;;
+       esac
+
+       if test "$linkmode,$pass" = "lib,link" ||
+          test "$linkmode,$pass" = "prog,scan" ||
+          { test "$linkmode" != prog && test "$linkmode" != lib; }; then
+         test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
+         test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
+       fi
+
+       if test "$pass" = conv; then
+         # Only check for convenience libraries
+         deplibs="$lib $deplibs"
+         if test -z "$libdir"; then
+           if test -z "$old_library"; then
+             $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
+             exit $EXIT_FAILURE
+           fi
+           # It is a libtool convenience library, so add in its objects.
+           convenience="$convenience $ladir/$objdir/$old_library"
+           old_convenience="$old_convenience $ladir/$objdir/$old_library"
+           tmp_libs=
+           for deplib in $dependency_libs; do
+             deplibs="$deplib $deplibs"
+              if test "X$duplicate_deps" = "Xyes" ; then
+               case "$tmp_libs " in
+               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+               esac
+              fi
+             tmp_libs="$tmp_libs $deplib"
+           done
+         elif test "$linkmode" != prog && test "$linkmode" != lib; then
+           $echo "$modename: \`$lib' is not a convenience library" 1>&2
+           exit $EXIT_FAILURE
+         fi
+         continue
+       fi # $pass = conv
+
+
+       # Get the name of the library we link against.
+       linklib=
+       for l in $old_library $library_names; do
+         linklib="$l"
+       done
+       if test -z "$linklib"; then
+         $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       # This library was specified with -dlopen.
+       if test "$pass" = dlopen; then
+         if test -z "$libdir"; then
+           $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
+           exit $EXIT_FAILURE
+         fi
+         if test -z "$dlname" ||
+            test "$dlopen_support" != yes ||
+            test "$build_libtool_libs" = no; then
+           # If there is no dlname, no dlopen support or we're linking
+           # statically, we need to preload.  We also need to preload any
+           # dependent libraries so libltdl's deplib preloader doesn't
+           # bomb out in the load deplibs phase.
+           dlprefiles="$dlprefiles $lib $dependency_libs"
+         else
+           newdlfiles="$newdlfiles $lib"
+         fi
+         continue
+       fi # $pass = dlopen
+
+       # We need an absolute path.
+       case $ladir in
+       [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
+       *)
+         abs_ladir=`cd "$ladir" && pwd`
+         if test -z "$abs_ladir"; then
+           $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
+           $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
+           abs_ladir="$ladir"
+         fi
+         ;;
+       esac
+       laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+
+       # Find the relevant object directory and library name.
+       if test "X$installed" = Xyes; then
+         if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+           $echo "$modename: warning: library \`$lib' was moved." 1>&2
+           dir="$ladir"
+           absdir="$abs_ladir"
+           libdir="$abs_ladir"
+         else
+           dir="$libdir"
+           absdir="$libdir"
+         fi
+         test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
+       else
+         if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
+           dir="$ladir"
+           absdir="$abs_ladir"
+           # Remove this search path later
+           notinst_path="$notinst_path $abs_ladir"
+         else
+           dir="$ladir/$objdir"
+           absdir="$abs_ladir/$objdir"
+           # Remove this search path later
+           notinst_path="$notinst_path $abs_ladir"
+         fi
+       fi # $installed = yes
+       name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+
+       # This library was specified with -dlpreopen.
+       if test "$pass" = dlpreopen; then
+         if test -z "$libdir"; then
+           $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
+           exit $EXIT_FAILURE
+         fi
+         # Prefer using a static library (so that no silly _DYNAMIC symbols
+         # are required to link).
+         if test -n "$old_library"; then
+           newdlprefiles="$newdlprefiles $dir/$old_library"
+         # Otherwise, use the dlname, so that lt_dlopen finds it.
+         elif test -n "$dlname"; then
+           newdlprefiles="$newdlprefiles $dir/$dlname"
+         else
+           newdlprefiles="$newdlprefiles $dir/$linklib"
+         fi
+       fi # $pass = dlpreopen
+
+       if test -z "$libdir"; then
+         # Link the convenience library
+         if test "$linkmode" = lib; then
+           deplibs="$dir/$old_library $deplibs"
+         elif test "$linkmode,$pass" = "prog,link"; then
+           compile_deplibs="$dir/$old_library $compile_deplibs"
+           finalize_deplibs="$dir/$old_library $finalize_deplibs"
+         else
+           deplibs="$lib $deplibs" # used for prog,scan pass
+         fi
+         continue
+       fi
+
+
+       if test "$linkmode" = prog && test "$pass" != link; then
+         newlib_search_path="$newlib_search_path $ladir"
+         deplibs="$lib $deplibs"
+
+         linkalldeplibs=no
+         if test "$link_all_deplibs" != no || test -z "$library_names" ||
+            test "$build_libtool_libs" = no; then
+           linkalldeplibs=yes
+         fi
+
+         tmp_libs=
+         for deplib in $dependency_libs; do
+           case $deplib in
+           -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
+           esac
+           # Need to link against all dependency_libs?
+           if test "$linkalldeplibs" = yes; then
+             deplibs="$deplib $deplibs"
+           else
+             # Need to hardcode shared library paths
+             # or/and link against static libraries
+             newdependency_libs="$deplib $newdependency_libs"
+           fi
+           if test "X$duplicate_deps" = "Xyes" ; then
+             case "$tmp_libs " in
+             *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+             esac
+           fi
+           tmp_libs="$tmp_libs $deplib"
+         done # for deplib
+         continue
+       fi # $linkmode = prog...
+
+       if test "$linkmode,$pass" = "prog,link"; then
+         if test -n "$library_names" &&
+            { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
+           # We need to hardcode the library path
+           if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
+             # Make sure the rpath contains only unique directories.
+             case "$temp_rpath " in
+             *" $dir "*) ;;
+             *" $absdir "*) ;;
+             *) temp_rpath="$temp_rpath $absdir" ;;
+             esac
+           fi
+
+           # Hardcode the library path.
+           # Skip directories that are in the system default run-time
+           # search path.
+           case " $sys_lib_dlsearch_path " in
+           *" $absdir "*) ;;
+           *)
+             case "$compile_rpath " in
+             *" $absdir "*) ;;
+             *) compile_rpath="$compile_rpath $absdir"
+             esac
+             ;;
+           esac
+           case " $sys_lib_dlsearch_path " in
+           *" $libdir "*) ;;
+           *)
+             case "$finalize_rpath " in
+             *" $libdir "*) ;;
+             *) finalize_rpath="$finalize_rpath $libdir"
+             esac
+             ;;
+           esac
+         fi # $linkmode,$pass = prog,link...
+
+         if test "$alldeplibs" = yes &&
+            { test "$deplibs_check_method" = pass_all ||
+              { test "$build_libtool_libs" = yes &&
+                test -n "$library_names"; }; }; then
+           # We only need to search for static libraries
+           continue
+         fi
+       fi
+
+       link_static=no # Whether the deplib will be linked statically
+       use_static_libs=$prefer_static_libs
+       if test "$use_static_libs" = built && test "$installed" = yes ; then
+         use_static_libs=no
+       fi
+       if test -n "$library_names" &&
+          { test "$use_static_libs" = no || test -z "$old_library"; }; then
+         if test "$installed" = no; then
+           notinst_deplibs="$notinst_deplibs $lib"
+           need_relink=yes
+         fi
+         # This is a shared library
+
+         # Warn about portability, can't link against -module's on
+         # some systems (darwin)
+         if test "$shouldnotlink" = yes && test "$pass" = link ; then
+           $echo
+           if test "$linkmode" = prog; then
+             $echo "*** Warning: Linking the executable $output against the loadable module"
+           else
+             $echo "*** Warning: Linking the shared library $output against the loadable module"
+           fi
+           $echo "*** $linklib is not portable!"
+         fi
+         if test "$linkmode" = lib &&
+            test "$hardcode_into_libs" = yes; then
+           # Hardcode the library path.
+           # Skip directories that are in the system default run-time
+           # search path.
+           case " $sys_lib_dlsearch_path " in
+           *" $absdir "*) ;;
+           *)
+             case "$compile_rpath " in
+             *" $absdir "*) ;;
+             *) compile_rpath="$compile_rpath $absdir"
+             esac
+             ;;
+           esac
+           case " $sys_lib_dlsearch_path " in
+           *" $libdir "*) ;;
+           *)
+             case "$finalize_rpath " in
+             *" $libdir "*) ;;
+             *) finalize_rpath="$finalize_rpath $libdir"
+             esac
+             ;;
+           esac
+         fi
+
+         if test -n "$old_archive_from_expsyms_cmds"; then
+           # figure out the soname
+           set dummy $library_names
+           realname="$2"
+           shift; shift
+           libname=`eval \\$echo \"$libname_spec\"`
+           # use dlname if we got it. it's perfectly good, no?
+           if test -n "$dlname"; then
+             soname="$dlname"
+           elif test -n "$soname_spec"; then
+             # bleh windows
+             case $host in
+             *cygwin* | mingw*)
+               major=`expr $current - $age`
+               versuffix="-$major"
+               ;;
+             esac
+             eval soname=\"$soname_spec\"
+           else
+             soname="$realname"
+           fi
+
+           # Make a new name for the extract_expsyms_cmds to use
+           soroot="$soname"
+           soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
+           newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
+
+           # If the library has no export list, then create one now
+           if test -f "$output_objdir/$soname-def"; then :
+           else
+             $show "extracting exported symbol list from \`$soname'"
+             save_ifs="$IFS"; IFS='~'
+             cmds=$extract_expsyms_cmds
+             for cmd in $cmds; do
+               IFS="$save_ifs"
+               eval cmd=\"$cmd\"
+               $show "$cmd"
+               $run eval "$cmd" || exit $?
+             done
+             IFS="$save_ifs"
+           fi
+
+           # Create $newlib
+           if test -f "$output_objdir/$newlib"; then :; else
+             $show "generating import library for \`$soname'"
+             save_ifs="$IFS"; IFS='~'
+             cmds=$old_archive_from_expsyms_cmds
+             for cmd in $cmds; do
+               IFS="$save_ifs"
+               eval cmd=\"$cmd\"
+               $show "$cmd"
+               $run eval "$cmd" || exit $?
+             done
+             IFS="$save_ifs"
+           fi
+           # make sure the library variables are pointing to the new library
+           dir=$output_objdir
+           linklib=$newlib
+         fi # test -n "$old_archive_from_expsyms_cmds"
+
+         if test "$linkmode" = prog || test "$mode" != relink; then
+           add_shlibpath=
+           add_dir=
+           add=
+           lib_linked=yes
+           case $hardcode_action in
+           immediate | unsupported)
+             if test "$hardcode_direct" = no; then
+               add="$dir/$linklib"
+               case $host in
+                 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
+                 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
+                 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
+                   *-*-unixware7*) add_dir="-L$dir" ;;
+                 *-*-darwin* )
+                   # if the lib is a module then we can not link against
+                   # it, someone is ignoring the new warnings I added
+                   if /usr/bin/file -L $add 2> /dev/null |
+                      $EGREP ": [^:]* bundle" >/dev/null ; then
+                     $echo "** Warning, lib $linklib is a module, not a shared library"
+                     if test -z "$old_library" ; then
+                       $echo
+                       $echo "** And there doesn't seem to be a static archive available"
+                       $echo "** The link will probably fail, sorry"
+                     else
+                       add="$dir/$old_library"
+                     fi
+                   fi
+               esac
+             elif test "$hardcode_minus_L" = no; then
+               case $host in
+               *-*-sunos*) add_shlibpath="$dir" ;;
+               esac
+               add_dir="-L$dir"
+               add="-l$name"
+             elif test "$hardcode_shlibpath_var" = no; then
+               add_shlibpath="$dir"
+               add="-l$name"
+             else
+               lib_linked=no
+             fi
+             ;;
+           relink)
+             if test "$hardcode_direct" = yes; then
+               add="$dir/$linklib"
+             elif test "$hardcode_minus_L" = yes; then
+               add_dir="-L$dir"
+               # Try looking first in the location we're being installed to.
+               if test -n "$inst_prefix_dir"; then
+                 case $libdir in
+                   [\\/]*)
+                     add_dir="$add_dir -L$inst_prefix_dir$libdir"
+                     ;;
+                 esac
+               fi
+               add="-l$name"
+             elif test "$hardcode_shlibpath_var" = yes; then
+               add_shlibpath="$dir"
+               add="-l$name"
+             else
+               lib_linked=no
+             fi
+             ;;
+           *) lib_linked=no ;;
+           esac
+
+           if test "$lib_linked" != yes; then
+             $echo "$modename: configuration error: unsupported hardcode properties"
+             exit $EXIT_FAILURE
+           fi
+
+           if test -n "$add_shlibpath"; then
+             case :$compile_shlibpath: in
+             *":$add_shlibpath:"*) ;;
+             *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
+             esac
+           fi
+           if test "$linkmode" = prog; then
+             test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
+             test -n "$add" && compile_deplibs="$add $compile_deplibs"
+           else
+             test -n "$add_dir" && deplibs="$add_dir $deplibs"
+             test -n "$add" && deplibs="$add $deplibs"
+             if test "$hardcode_direct" != yes && \
+                test "$hardcode_minus_L" != yes && \
+                test "$hardcode_shlibpath_var" = yes; then
+               case :$finalize_shlibpath: in
+               *":$libdir:"*) ;;
+               *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+               esac
+             fi
+           fi
+         fi
+
+         if test "$linkmode" = prog || test "$mode" = relink; then
+           add_shlibpath=
+           add_dir=
+           add=
+           # Finalize command for both is simple: just hardcode it.
+           if test "$hardcode_direct" = yes; then
+             add="$libdir/$linklib"
+           elif test "$hardcode_minus_L" = yes; then
+             add_dir="-L$libdir"
+             add="-l$name"
+           elif test "$hardcode_shlibpath_var" = yes; then
+             case :$finalize_shlibpath: in
+             *":$libdir:"*) ;;
+             *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
+             esac
+             add="-l$name"
+           elif test "$hardcode_automatic" = yes; then
+             if test -n "$inst_prefix_dir" &&
+                test -f "$inst_prefix_dir$libdir/$linklib" ; then
+               add="$inst_prefix_dir$libdir/$linklib"
+             else
+               add="$libdir/$linklib"
+             fi
+           else
+             # We cannot seem to hardcode it, guess we'll fake it.
+             add_dir="-L$libdir"
+             # Try looking first in the location we're being installed to.
+             if test -n "$inst_prefix_dir"; then
+               case $libdir in
+                 [\\/]*)
+                   add_dir="$add_dir -L$inst_prefix_dir$libdir"
+                   ;;
+               esac
+             fi
+             add="-l$name"
+           fi
+
+           if test "$linkmode" = prog; then
+             test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
+             test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
+           else
+             test -n "$add_dir" && deplibs="$add_dir $deplibs"
+             test -n "$add" && deplibs="$add $deplibs"
+           fi
+         fi
+       elif test "$linkmode" = prog; then
+         # Here we assume that one of hardcode_direct or hardcode_minus_L
+         # is not unsupported.  This is valid on all known static and
+         # shared platforms.
+         if test "$hardcode_direct" != unsupported; then
+           test -n "$old_library" && linklib="$old_library"
+           compile_deplibs="$dir/$linklib $compile_deplibs"
+           finalize_deplibs="$dir/$linklib $finalize_deplibs"
+         else
+           compile_deplibs="-l$name -L$dir $compile_deplibs"
+           finalize_deplibs="-l$name -L$dir $finalize_deplibs"
+         fi
+       elif test "$build_libtool_libs" = yes; then
+         # Not a shared library
+         if test "$deplibs_check_method" != pass_all; then
+           # We're trying link a shared library against a static one
+           # but the system doesn't support it.
+
+           # Just print a warning and add the library to dependency_libs so
+           # that the program can be linked against the static library.
+           $echo
+           $echo "*** Warning: This system can not link to static lib archive $lib."
+           $echo "*** I have the capability to make that library automatically link in when"
+           $echo "*** you link to this library.  But I can only do this if you have a"
+           $echo "*** shared version of the library, which you do not appear to have."
+           if test "$module" = yes; then
+             $echo "*** But as you try to build a module library, libtool will still create "
+             $echo "*** a static module, that should work as long as the dlopening application"
+             $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
+             if test -z "$global_symbol_pipe"; then
+               $echo
+               $echo "*** However, this would only work if libtool was able to extract symbol"
+               $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+               $echo "*** not find such a program.  So, this module is probably useless."
+               $echo "*** \`nm' from GNU binutils and a full rebuild may help."
+             fi
+             if test "$build_old_libs" = no; then
+               build_libtool_libs=module
+               build_old_libs=yes
+             else
+               build_libtool_libs=no
+             fi
+           fi
+         else
+           deplibs="$dir/$old_library $deplibs"
+           link_static=yes
+         fi
+       fi # link shared/static library?
+
+       if test "$linkmode" = lib; then
+         if test -n "$dependency_libs" &&
+            { test "$hardcode_into_libs" != yes ||
+              test "$build_old_libs" = yes ||
+              test "$link_static" = yes; }; then
+           # Extract -R from dependency_libs
+           temp_deplibs=
+           for libdir in $dependency_libs; do
+             case $libdir in
+             -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
+                  case " $xrpath " in
+                  *" $temp_xrpath "*) ;;
+                  *) xrpath="$xrpath $temp_xrpath";;
+                  esac;;
+             *) temp_deplibs="$temp_deplibs $libdir";;
+             esac
+           done
+           dependency_libs="$temp_deplibs"
+         fi
+
+         newlib_search_path="$newlib_search_path $absdir"
+         # Link against this library
+         test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
+         # ... and its dependency_libs
+         tmp_libs=
+         for deplib in $dependency_libs; do
+           newdependency_libs="$deplib $newdependency_libs"
+           if test "X$duplicate_deps" = "Xyes" ; then
+             case "$tmp_libs " in
+             *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
+             esac
+           fi
+           tmp_libs="$tmp_libs $deplib"
+         done
+
+         if test "$link_all_deplibs" != no; then
+           # Add the search paths of all dependency libraries
+           for deplib in $dependency_libs; do
+             case $deplib in
+             -L*) path="$deplib" ;;
+             *.la)
+               dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
+               test "X$dir" = "X$deplib" && dir="."
+               # We need an absolute path.
+               case $dir in
+               [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
+               *)
+                 absdir=`cd "$dir" && pwd`
+                 if test -z "$absdir"; then
+                   $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
+                   absdir="$dir"
+                 fi
+                 ;;
+               esac
+               if grep "^installed=no" $deplib > /dev/null; then
+                 path="$absdir/$objdir"
+               else
+                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+                 if test -z "$libdir"; then
+                   $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
+                   exit $EXIT_FAILURE
+                 fi
+                 if test "$absdir" != "$libdir"; then
+                   $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
+                 fi
+                 path="$absdir"
+               fi
+               depdepl=
+               case $host in
+               *-*-darwin*)
+                 # we do not want to link against static libs,
+                 # but need to link against shared
+                 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
+                 if test -n "$deplibrary_names" ; then
+                   for tmp in $deplibrary_names ; do
+                     depdepl=$tmp
+                   done
+                   if test -f "$path/$depdepl" ; then
+                     depdepl="$path/$depdepl"
+                   fi
+                   # do not add paths which are already there
+                   case " $newlib_search_path " in
+                   *" $path "*) ;;
+                   *) newlib_search_path="$newlib_search_path $path";;
+                   esac
+                 fi
+                 path=""
+                 ;;
+               *)
+                 path="-L$path"
+                 ;;
+               esac
+               ;;
+             -l*)
+               case $host in
+               *-*-darwin*)
+                 # Again, we only want to link against shared libraries
+                 eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
+                 for tmp in $newlib_search_path ; do
+                   if test -f "$tmp/lib$tmp_libs.dylib" ; then
+                     eval depdepl="$tmp/lib$tmp_libs.dylib"
+                     break
+                   fi
+                 done
+                 path=""
+                 ;;
+               *) continue ;;
+               esac
+               ;;
+             *) continue ;;
+             esac
+             case " $deplibs " in
+             *" $path "*) ;;
+             *) deplibs="$path $deplibs" ;;
+             esac
+             case " $deplibs " in
+             *" $depdepl "*) ;;
+             *) deplibs="$depdepl $deplibs" ;;
+             esac
+           done
+         fi # link_all_deplibs != no
+       fi # linkmode = lib
+      done # for deplib in $libs
+      dependency_libs="$newdependency_libs"
+      if test "$pass" = dlpreopen; then
+       # Link the dlpreopened libraries before other libraries
+       for deplib in $save_deplibs; do
+         deplibs="$deplib $deplibs"
+       done
+      fi
+      if test "$pass" != dlopen; then
+       if test "$pass" != conv; then
+         # Make sure lib_search_path contains only unique directories.
+         lib_search_path=
+         for dir in $newlib_search_path; do
+           case "$lib_search_path " in
+           *" $dir "*) ;;
+           *) lib_search_path="$lib_search_path $dir" ;;
+           esac
+         done
+         newlib_search_path=
+       fi
+
+       if test "$linkmode,$pass" != "prog,link"; then
+         vars="deplibs"
+       else
+         vars="compile_deplibs finalize_deplibs"
+       fi
+       for var in $vars dependency_libs; do
+         # Add libraries to $var in reverse order
+         eval tmp_libs=\"\$$var\"
+         new_libs=
+         for deplib in $tmp_libs; do
+           # FIXME: Pedantically, this is the right thing to do, so
+           #        that some nasty dependency loop isn't accidentally
+           #        broken:
+           #new_libs="$deplib $new_libs"
+           # Pragmatically, this seems to cause very few problems in
+           # practice:
+           case $deplib in
+           -L*) new_libs="$deplib $new_libs" ;;
+           -R*) ;;
+           *)
+             # And here is the reason: when a library appears more
+             # than once as an explicit dependence of a library, or
+             # is implicitly linked in more than once by the
+             # compiler, it is considered special, and multiple
+             # occurrences thereof are not removed.  Compare this
+             # with having the same library being listed as a
+             # dependency of multiple other libraries: in this case,
+             # we know (pedantically, we assume) the library does not
+             # need to be listed more than once, so we keep only the
+             # last copy.  This is not always right, but it is rare
+             # enough that we require users that really mean to play
+             # such unportable linking tricks to link the library
+             # using -Wl,-lname, so that libtool does not consider it
+             # for duplicate removal.
+             case " $specialdeplibs " in
+             *" $deplib "*) new_libs="$deplib $new_libs" ;;
+             *)
+               case " $new_libs " in
+               *" $deplib "*) ;;
+               *) new_libs="$deplib $new_libs" ;;
+               esac
+               ;;
+             esac
+             ;;
+           esac
+         done
+         tmp_libs=
+         for deplib in $new_libs; do
+           case $deplib in
+           -L*)
+             case " $tmp_libs " in
+             *" $deplib "*) ;;
+             *) tmp_libs="$tmp_libs $deplib" ;;
+             esac
+             ;;
+           *) tmp_libs="$tmp_libs $deplib" ;;
+           esac
+         done
+         eval $var=\"$tmp_libs\"
+       done # for var
+      fi
+      # Last step: remove runtime libs from dependency_libs
+      # (they stay in deplibs)
+      tmp_libs=
+      for i in $dependency_libs ; do
+       case " $predeps $postdeps $compiler_lib_search_path " in
+       *" $i "*)
+         i=""
+         ;;
+       esac
+       if test -n "$i" ; then
+         tmp_libs="$tmp_libs $i"
+       fi
+      done
+      dependency_libs=$tmp_libs
+    done # for pass
+    if test "$linkmode" = prog; then
+      dlfiles="$newdlfiles"
+      dlprefiles="$newdlprefiles"
+    fi
+
+    case $linkmode in
+    oldlib)
+      if test -n "$deplibs"; then
+       $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$rpath"; then
+       $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$xrpath"; then
+       $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$vinfo"; then
+       $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$release"; then
+       $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
+      fi
+
+      if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
+       $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
+      fi
+
+      # Now set the variables for building old libraries.
+      build_libtool_libs=no
+      oldlibs="$output"
+      objs="$objs$old_deplibs"
+      ;;
+
+    lib)
+      # Make sure we only generate libraries of the form `libNAME.la'.
+      case $outputname in
+      lib*)
+       name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
+       eval shared_ext=\"$shrext_cmds\"
+       eval libname=\"$libname_spec\"
+       ;;
+      *)
+       if test "$module" = no; then
+         $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+       fi
+       if test "$need_lib_prefix" != no; then
+         # Add the "lib" prefix for modules if required
+         name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+         eval shared_ext=\"$shrext_cmds\"
+         eval libname=\"$libname_spec\"
+       else
+         libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
+       fi
+       ;;
+      esac
+
+      if test -n "$objs"; then
+       if test "$deplibs_check_method" != pass_all; then
+         $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
+         exit $EXIT_FAILURE
+       else
+         $echo
+         $echo "*** Warning: Linking the shared library $output against the non-libtool"
+         $echo "*** objects $objs is not portable!"
+         libobjs="$libobjs $objs"
+       fi
+      fi
+
+      if test "$dlself" != no; then
+       $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
+      fi
+
+      set dummy $rpath
+      if test "$#" -gt 2; then
+       $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
+      fi
+      install_libdir="$2"
+
+      oldlibs=
+      if test -z "$rpath"; then
+       if test "$build_libtool_libs" = yes; then
+         # Building a libtool convenience library.
+         # Some compilers have problems with a `.al' extension so
+         # convenience libraries should have the same extension an
+         # archive normally would.
+         oldlibs="$output_objdir/$libname.$libext $oldlibs"
+         build_libtool_libs=convenience
+         build_old_libs=yes
+       fi
+
+       if test -n "$vinfo"; then
+         $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
+       fi
+
+       if test -n "$release"; then
+         $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
+       fi
+      else
+
+       # Parse the version information argument.
+       save_ifs="$IFS"; IFS=':'
+       set dummy $vinfo 0 0 0
+       IFS="$save_ifs"
+
+       if test -n "$8"; then
+         $echo "$modename: too many parameters to \`-version-info'" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       # convert absolute version numbers to libtool ages
+       # this retains compatibility with .la files and attempts
+       # to make the code below a bit more comprehensible
+
+       case $vinfo_number in
+       yes)
+         number_major="$2"
+         number_minor="$3"
+         number_revision="$4"
+         #
+         # There are really only two kinds -- those that
+         # use the current revision as the major version
+         # and those that subtract age and use age as
+         # a minor version.  But, then there is irix
+         # which has an extra 1 added just for fun
+         #
+         case $version_type in
+         darwin|linux|osf|windows)
+           current=`expr $number_major + $number_minor`
+           age="$number_minor"
+           revision="$number_revision"
+           ;;
+         freebsd-aout|freebsd-elf|sunos)
+           current="$number_major"
+           revision="$number_minor"
+           age="0"
+           ;;
+         irix|nonstopux)
+           current=`expr $number_major + $number_minor - 1`
+           age="$number_minor"
+           revision="$number_minor"
+           ;;
+         esac
+         ;;
+       no)
+         current="$2"
+         revision="$3"
+         age="$4"
+         ;;
+       esac
+
+       # Check that each of the things are valid numbers.
+       case $current in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         $echo "$modename: CURRENT \`$current' must be a nonnegative integer" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+
+       case $revision in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         $echo "$modename: REVISION \`$revision' must be a nonnegative integer" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+
+       case $age in
+       0|[1-9]|[1-9][0-9]|[1-9][0-9][0-9]|[1-9][0-9][0-9][0-9]|[1-9][0-9][0-9][0-9][0-9]) ;;
+       *)
+         $echo "$modename: AGE \`$age' must be a nonnegative integer" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+
+       if test "$age" -gt "$current"; then
+         $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
+         $echo "$modename: \`$vinfo' is not valid version information" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       # Calculate the version variables.
+       major=
+       versuffix=
+       verstring=
+       case $version_type in
+       none) ;;
+
+       darwin)
+         # Like Linux, but with the current version available in
+         # verstring for coding it into the library header
+         major=.`expr $current - $age`
+         versuffix="$major.$age.$revision"
+         # Darwin ld doesn't like 0 for these options...
+         minor_current=`expr $current + 1`
+         verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
+         ;;
+
+       freebsd-aout)
+         major=".$current"
+         versuffix=".$current.$revision";
+         ;;
+
+       freebsd-elf)
+         major=".$current"
+         versuffix=".$current";
+         ;;
+
+       irix | nonstopux)
+         major=`expr $current - $age + 1`
+
+         case $version_type in
+           nonstopux) verstring_prefix=nonstopux ;;
+           *)         verstring_prefix=sgi ;;
+         esac
+         verstring="$verstring_prefix$major.$revision"
+
+         # Add in all the interfaces that we are compatible with.
+         loop=$revision
+         while test "$loop" -ne 0; do
+           iface=`expr $revision - $loop`
+           loop=`expr $loop - 1`
+           verstring="$verstring_prefix$major.$iface:$verstring"
+         done
+
+         # Before this point, $major must not contain `.'.
+         major=.$major
+         versuffix="$major.$revision"
+         ;;
+
+       linux)
+         major=.`expr $current - $age`
+         versuffix="$major.$age.$revision"
+         ;;
+
+       osf)
+         major=.`expr $current - $age`
+         versuffix=".$current.$age.$revision"
+         verstring="$current.$age.$revision"
+
+         # Add in all the interfaces that we are compatible with.
+         loop=$age
+         while test "$loop" -ne 0; do
+           iface=`expr $current - $loop`
+           loop=`expr $loop - 1`
+           verstring="$verstring:${iface}.0"
+         done
+
+         # Make executables depend on our current version.
+         verstring="$verstring:${current}.0"
+         ;;
+
+       sunos)
+         major=".$current"
+         versuffix=".$current.$revision"
+         ;;
+
+       windows)
+         # Use '-' rather than '.', since we only want one
+         # extension on DOS 8.3 filesystems.
+         major=`expr $current - $age`
+         versuffix="-$major"
+         ;;
+
+       *)
+         $echo "$modename: unknown library version type \`$version_type'" 1>&2
+         $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+
+       # Clear the version info if we defaulted, and they specified a release.
+       if test -z "$vinfo" && test -n "$release"; then
+         major=
+         case $version_type in
+         darwin)
+           # we can't check for "0.0" in archive_cmds due to quoting
+           # problems, so we reset it completely
+           verstring=
+           ;;
+         *)
+           verstring="0.0"
+           ;;
+         esac
+         if test "$need_version" = no; then
+           versuffix=
+         else
+           versuffix=".0.0"
+         fi
+       fi
+
+       # Remove version info from name if versioning should be avoided
+       if test "$avoid_version" = yes && test "$need_version" = no; then
+         major=
+         versuffix=
+         verstring=""
+       fi
+
+       # Check to see if the archive will have undefined symbols.
+       if test "$allow_undefined" = yes; then
+         if test "$allow_undefined_flag" = unsupported; then
+           $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
+           build_libtool_libs=no
+           build_old_libs=yes
+         fi
+       else
+         # Don't allow undefined symbols.
+         allow_undefined_flag="$no_undefined_flag"
+       fi
+      fi
+
+      if test "$mode" != relink; then
+       # Remove our outputs, but don't remove object files since they
+       # may have been created when compiling PIC objects.
+       removelist=
+       tempremovelist=`$echo "$output_objdir/*"`
+       for p in $tempremovelist; do
+         case $p in
+           *.$objext)
+              ;;
+           $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
+              if test "X$precious_files_regex" != "X"; then
+                if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
+                then
+                  continue
+                fi
+              fi
+              removelist="$removelist $p"
+              ;;
+           *) ;;
+         esac
+       done
+       if test -n "$removelist"; then
+         $show "${rm}r $removelist"
+         $run ${rm}r $removelist
+       fi
+      fi
+
+      # Now set the variables for building old libraries.
+      if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
+       oldlibs="$oldlibs $output_objdir/$libname.$libext"
+
+       # Transform .lo files to .o files.
+       oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
+      fi
+
+      # Eliminate all temporary directories.
+      for path in $notinst_path; do
+       lib_search_path=`$echo "$lib_search_path " | ${SED} -e "s% $path % %g"`
+       deplibs=`$echo "$deplibs " | ${SED} -e "s% -L$path % %g"`
+       dependency_libs=`$echo "$dependency_libs " | ${SED} -e "s% -L$path % %g"`
+      done
+
+      if test -n "$xrpath"; then
+       # If the user specified any rpath flags, then add them.
+       temp_xrpath=
+       for libdir in $xrpath; do
+         temp_xrpath="$temp_xrpath -R$libdir"
+         case "$finalize_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_rpath="$finalize_rpath $libdir" ;;
+         esac
+       done
+       if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
+         dependency_libs="$temp_xrpath $dependency_libs"
+       fi
+      fi
+
+      # Make sure dlfiles contains only unique files that won't be dlpreopened
+      old_dlfiles="$dlfiles"
+      dlfiles=
+      for lib in $old_dlfiles; do
+       case " $dlprefiles $dlfiles " in
+       *" $lib "*) ;;
+       *) dlfiles="$dlfiles $lib" ;;
+       esac
+      done
+
+      # Make sure dlprefiles contains only unique files
+      old_dlprefiles="$dlprefiles"
+      dlprefiles=
+      for lib in $old_dlprefiles; do
+       case "$dlprefiles " in
+       *" $lib "*) ;;
+       *) dlprefiles="$dlprefiles $lib" ;;
+       esac
+      done
+
+      if test "$build_libtool_libs" = yes; then
+       if test -n "$rpath"; then
+         case $host in
+         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
+           # these systems don't actually have a c library (as such)!
+           ;;
+         *-*-rhapsody* | *-*-darwin1.[012])
+           # Rhapsody C library is in the System framework
+           deplibs="$deplibs -framework System"
+           ;;
+         *-*-netbsd*)
+           # Don't link with libc until the a.out ld.so is fixed.
+           ;;
+         *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
+           # Do not include libc due to us having libc/libc_r.
+           ;;
+         *-*-sco3.2v5* | *-*-sco5v6*)
+           # Causes problems with __ctype
+           ;;
+         *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
+           # Compiler inserts libc in the correct place for threads to work
+           ;;
+         *)
+           # Add libc to deplibs on all other systems if necessary.
+           if test "$build_libtool_need_lc" = "yes"; then
+             deplibs="$deplibs -lc"
+           fi
+           ;;
+         esac
+       fi
+
+       # Transform deplibs into only deplibs that can be linked in shared.
+       name_save=$name
+       libname_save=$libname
+       release_save=$release
+       versuffix_save=$versuffix
+       major_save=$major
+       # I'm not sure if I'm treating the release correctly.  I think
+       # release should show up in the -l (ie -lgmp5) so we don't want to
+       # add it in twice.  Is that correct?
+       release=""
+       versuffix=""
+       major=""
+       newdeplibs=
+       droppeddeps=no
+       case $deplibs_check_method in
+       pass_all)
+         # Don't check for shared/static.  Everything works.
+         # This might be a little naive.  We might want to check
+         # whether the library exists or not.  But this is on
+         # osf3 & osf4 and I'm not really sure... Just
+         # implementing what was already the behavior.
+         newdeplibs=$deplibs
+         ;;
+       test_compile)
+         # This code stresses the "libraries are programs" paradigm to its
+         # limits. Maybe even breaks it.  We compile a program, linking it
+         # against the deplibs as a proxy for the library.  Then we can check
+         # whether they linked in statically or dynamically with ldd.
+         $rm conftest.c
+         cat > conftest.c <<EOF
+         int main() { return 0; }
+EOF
+         $rm conftest
+         $LTCC $LTCFLAGS -o conftest conftest.c $deplibs
+         if test "$?" -eq 0 ; then
+           ldd_output=`ldd conftest`
+           for i in $deplibs; do
+             name=`expr $i : '-l\(.*\)'`
+             # If $name is empty we are operating on a -L argument.
+              if test "$name" != "" && test "$name" -ne "0"; then
+               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+                 case " $predeps $postdeps " in
+                 *" $i "*)
+                   newdeplibs="$newdeplibs $i"
+                   i=""
+                   ;;
+                 esac
+               fi
+               if test -n "$i" ; then
+                 libname=`eval \\$echo \"$libname_spec\"`
+                 deplib_matches=`eval \\$echo \"$library_names_spec\"`
+                 set dummy $deplib_matches
+                 deplib_match=$2
+                 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                   newdeplibs="$newdeplibs $i"
+                 else
+                   droppeddeps=yes
+                   $echo
+                   $echo "*** Warning: dynamic linker does not accept needed library $i."
+                   $echo "*** I have the capability to make that library automatically link in when"
+                   $echo "*** you link to this library.  But I can only do this if you have a"
+                   $echo "*** shared version of the library, which I believe you do not have"
+                   $echo "*** because a test_compile did reveal that the linker did not use it for"
+                   $echo "*** its dynamic dependency list that programs get resolved with at runtime."
+                 fi
+               fi
+             else
+               newdeplibs="$newdeplibs $i"
+             fi
+           done
+         else
+           # Error occurred in the first compile.  Let's try to salvage
+           # the situation: Compile a separate program for each library.
+           for i in $deplibs; do
+             name=`expr $i : '-l\(.*\)'`
+             # If $name is empty we are operating on a -L argument.
+              if test "$name" != "" && test "$name" != "0"; then
+               $rm conftest
+               $LTCC $LTCFLAGS -o conftest conftest.c $i
+               # Did it work?
+               if test "$?" -eq 0 ; then
+                 ldd_output=`ldd conftest`
+                 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+                   case " $predeps $postdeps " in
+                   *" $i "*)
+                     newdeplibs="$newdeplibs $i"
+                     i=""
+                     ;;
+                   esac
+                 fi
+                 if test -n "$i" ; then
+                   libname=`eval \\$echo \"$libname_spec\"`
+                   deplib_matches=`eval \\$echo \"$library_names_spec\"`
+                   set dummy $deplib_matches
+                   deplib_match=$2
+                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
+                     newdeplibs="$newdeplibs $i"
+                   else
+                     droppeddeps=yes
+                     $echo
+                     $echo "*** Warning: dynamic linker does not accept needed library $i."
+                     $echo "*** I have the capability to make that library automatically link in when"
+                     $echo "*** you link to this library.  But I can only do this if you have a"
+                     $echo "*** shared version of the library, which you do not appear to have"
+                     $echo "*** because a test_compile did reveal that the linker did not use this one"
+                     $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
+                   fi
+                 fi
+               else
+                 droppeddeps=yes
+                 $echo
+                 $echo "*** Warning!  Library $i is needed by this library but I was not able to"
+                 $echo "***  make it link in!  You will probably need to install it or some"
+                 $echo "*** library that it depends on before this library will be fully"
+                 $echo "*** functional.  Installing it before continuing would be even better."
+               fi
+             else
+               newdeplibs="$newdeplibs $i"
+             fi
+           done
+         fi
+         ;;
+       file_magic*)
+         set dummy $deplibs_check_method
+         file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+         for a_deplib in $deplibs; do
+           name=`expr $a_deplib : '-l\(.*\)'`
+           # If $name is empty we are operating on a -L argument.
+            if test "$name" != "" && test  "$name" != "0"; then
+             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+               case " $predeps $postdeps " in
+               *" $a_deplib "*)
+                 newdeplibs="$newdeplibs $a_deplib"
+                 a_deplib=""
+                 ;;
+               esac
+             fi
+             if test -n "$a_deplib" ; then
+               libname=`eval \\$echo \"$libname_spec\"`
+               for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+                 for potent_lib in $potential_libs; do
+                     # Follow soft links.
+                     if ls -lLd "$potent_lib" 2>/dev/null \
+                        | grep " -> " >/dev/null; then
+                       continue
+                     fi
+                     # The statement above tries to avoid entering an
+                     # endless loop below, in case of cyclic links.
+                     # We might still enter an endless loop, since a link
+                     # loop can be closed while we follow links,
+                     # but so what?
+                     potlib="$potent_lib"
+                     while test -h "$potlib" 2>/dev/null; do
+                       potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
+                       case $potliblink in
+                       [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
+                       *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
+                       esac
+                     done
+                     if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
+                        | ${SED} 10q \
+                        | $EGREP "$file_magic_regex" > /dev/null; then
+                       newdeplibs="$newdeplibs $a_deplib"
+                       a_deplib=""
+                       break 2
+                     fi
+                 done
+               done
+             fi
+             if test -n "$a_deplib" ; then
+               droppeddeps=yes
+               $echo
+               $echo "*** Warning: linker path does not have real file for library $a_deplib."
+               $echo "*** I have the capability to make that library automatically link in when"
+               $echo "*** you link to this library.  But I can only do this if you have a"
+               $echo "*** shared version of the library, which you do not appear to have"
+               $echo "*** because I did check the linker path looking for a file starting"
+               if test -z "$potlib" ; then
+                 $echo "*** with $libname but no candidates were found. (...for file magic test)"
+               else
+                 $echo "*** with $libname and none of the candidates passed a file format test"
+                 $echo "*** using a file magic. Last file checked: $potlib"
+               fi
+             fi
+           else
+             # Add a -L argument.
+             newdeplibs="$newdeplibs $a_deplib"
+           fi
+         done # Gone through all deplibs.
+         ;;
+       match_pattern*)
+         set dummy $deplibs_check_method
+         match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
+         for a_deplib in $deplibs; do
+           name=`expr $a_deplib : '-l\(.*\)'`
+           # If $name is empty we are operating on a -L argument.
+           if test -n "$name" && test "$name" != "0"; then
+             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+               case " $predeps $postdeps " in
+               *" $a_deplib "*)
+                 newdeplibs="$newdeplibs $a_deplib"
+                 a_deplib=""
+                 ;;
+               esac
+             fi
+             if test -n "$a_deplib" ; then
+               libname=`eval \\$echo \"$libname_spec\"`
+               for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
+                 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
+                 for potent_lib in $potential_libs; do
+                   potlib="$potent_lib" # see symlink-check above in file_magic test
+                   if eval $echo \"$potent_lib\" 2>/dev/null \
+                       | ${SED} 10q \
+                       | $EGREP "$match_pattern_regex" > /dev/null; then
+                     newdeplibs="$newdeplibs $a_deplib"
+                     a_deplib=""
+                     break 2
+                   fi
+                 done
+               done
+             fi
+             if test -n "$a_deplib" ; then
+               droppeddeps=yes
+               $echo
+               $echo "*** Warning: linker path does not have real file for library $a_deplib."
+               $echo "*** I have the capability to make that library automatically link in when"
+               $echo "*** you link to this library.  But I can only do this if you have a"
+               $echo "*** shared version of the library, which you do not appear to have"
+               $echo "*** because I did check the linker path looking for a file starting"
+               if test -z "$potlib" ; then
+                 $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
+               else
+                 $echo "*** with $libname and none of the candidates passed a file format test"
+                 $echo "*** using a regex pattern. Last file checked: $potlib"
+               fi
+             fi
+           else
+             # Add a -L argument.
+             newdeplibs="$newdeplibs $a_deplib"
+           fi
+         done # Gone through all deplibs.
+         ;;
+       none | unknown | *)
+         newdeplibs=""
+         tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
+           -e 's/ -[LR][^ ]*//g'`
+         if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
+           for i in $predeps $postdeps ; do
+             # can't use Xsed below, because $i might contain '/'
+             tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
+           done
+         fi
+         if $echo "X $tmp_deplibs" | $Xsed -e 's/[     ]//g' \
+           | grep . >/dev/null; then
+           $echo
+           if test "X$deplibs_check_method" = "Xnone"; then
+             $echo "*** Warning: inter-library dependencies are not supported in this platform."
+           else
+             $echo "*** Warning: inter-library dependencies are not known to be supported."
+           fi
+           $echo "*** All declared inter-library dependencies are being dropped."
+           droppeddeps=yes
+         fi
+         ;;
+       esac
+       versuffix=$versuffix_save
+       major=$major_save
+       release=$release_save
+       libname=$libname_save
+       name=$name_save
+
+       case $host in
+       *-*-rhapsody* | *-*-darwin1.[012])
+         # On Rhapsody replace the C library is the System framework
+         newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
+         ;;
+       esac
+
+       if test "$droppeddeps" = yes; then
+         if test "$module" = yes; then
+           $echo
+           $echo "*** Warning: libtool could not satisfy all declared inter-library"
+           $echo "*** dependencies of module $libname.  Therefore, libtool will create"
+           $echo "*** a static module, that should work as long as the dlopening"
+           $echo "*** application is linked with the -dlopen flag."
+           if test -z "$global_symbol_pipe"; then
+             $echo
+             $echo "*** However, this would only work if libtool was able to extract symbol"
+             $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
+             $echo "*** not find such a program.  So, this module is probably useless."
+             $echo "*** \`nm' from GNU binutils and a full rebuild may help."
+           fi
+           if test "$build_old_libs" = no; then
+             oldlibs="$output_objdir/$libname.$libext"
+             build_libtool_libs=module
+             build_old_libs=yes
+           else
+             build_libtool_libs=no
+           fi
+         else
+           $echo "*** The inter-library dependencies that have been dropped here will be"
+           $echo "*** automatically added whenever a program is linked with this library"
+           $echo "*** or is declared to -dlopen it."
+
+           if test "$allow_undefined" = no; then
+             $echo
+             $echo "*** Since this library must not contain undefined symbols,"
+             $echo "*** because either the platform does not support them or"
+             $echo "*** it was explicitly requested with -no-undefined,"
+             $echo "*** libtool will only create a static version of it."
+             if test "$build_old_libs" = no; then
+               oldlibs="$output_objdir/$libname.$libext"
+               build_libtool_libs=module
+               build_old_libs=yes
+             else
+               build_libtool_libs=no
+             fi
+           fi
+         fi
+       fi
+       # Done checking deplibs!
+       deplibs=$newdeplibs
+      fi
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+       case " $new_libs " in
+       *" -L$path/$objdir "*) ;;
+       *)
+         case " $deplibs " in
+         *" -L$path/$objdir "*)
+           new_libs="$new_libs -L$path/$objdir" ;;
+         esac
+         ;;
+       esac
+      done
+      for deplib in $deplibs; do
+       case $deplib in
+       -L*)
+         case " $new_libs " in
+         *" $deplib "*) ;;
+         *) new_libs="$new_libs $deplib" ;;
+         esac
+         ;;
+       *) new_libs="$new_libs $deplib" ;;
+       esac
+      done
+      deplibs="$new_libs"
+
+
+      # All the library-specific variables (install_libdir is set above).
+      library_names=
+      old_library=
+      dlname=
+
+      # Test again, we may have decided not to build it any more
+      if test "$build_libtool_libs" = yes; then
+       if test "$hardcode_into_libs" = yes; then
+         # Hardcode the library paths
+         hardcode_libdirs=
+         dep_rpath=
+         rpath="$finalize_rpath"
+         test "$mode" != relink && rpath="$compile_rpath$rpath"
+         for libdir in $rpath; do
+           if test -n "$hardcode_libdir_flag_spec"; then
+             if test -n "$hardcode_libdir_separator"; then
+               if test -z "$hardcode_libdirs"; then
+                 hardcode_libdirs="$libdir"
+               else
+                 # Just accumulate the unique libdirs.
+                 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+                 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+                   ;;
+                 *)
+                   hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+                   ;;
+                 esac
+               fi
+             else
+               eval flag=\"$hardcode_libdir_flag_spec\"
+               dep_rpath="$dep_rpath $flag"
+             fi
+           elif test -n "$runpath_var"; then
+             case "$perm_rpath " in
+             *" $libdir "*) ;;
+             *) perm_rpath="$perm_rpath $libdir" ;;
+             esac
+           fi
+         done
+         # Substitute the hardcoded libdirs into the rpath.
+         if test -n "$hardcode_libdir_separator" &&
+            test -n "$hardcode_libdirs"; then
+           libdir="$hardcode_libdirs"
+           if test -n "$hardcode_libdir_flag_spec_ld"; then
+             eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
+           else
+             eval dep_rpath=\"$hardcode_libdir_flag_spec\"
+           fi
+         fi
+         if test -n "$runpath_var" && test -n "$perm_rpath"; then
+           # We should set the runpath_var.
+           rpath=
+           for dir in $perm_rpath; do
+             rpath="$rpath$dir:"
+           done
+           eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
+         fi
+         test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
+       fi
+
+       shlibpath="$finalize_shlibpath"
+       test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
+       if test -n "$shlibpath"; then
+         eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
+       fi
+
+       # Get the real and link names of the library.
+       eval shared_ext=\"$shrext_cmds\"
+       eval library_names=\"$library_names_spec\"
+       set dummy $library_names
+       realname="$2"
+       shift; shift
+
+       if test -n "$soname_spec"; then
+         eval soname=\"$soname_spec\"
+       else
+         soname="$realname"
+       fi
+       if test -z "$dlname"; then
+         dlname=$soname
+       fi
+
+       lib="$output_objdir/$realname"
+       linknames=
+       for link
+       do
+         linknames="$linknames $link"
+       done
+
+       # Use standard objects if they are pic
+       test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+
+       # Prepare the list of exported symbols
+       if test -z "$export_symbols"; then
+         if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
+           $show "generating symbol list for \`$libname.la'"
+           export_symbols="$output_objdir/$libname.exp"
+           $run $rm $export_symbols
+           cmds=$export_symbols_cmds
+           save_ifs="$IFS"; IFS='~'
+           for cmd in $cmds; do
+             IFS="$save_ifs"
+             eval cmd=\"$cmd\"
+             if len=`expr "X$cmd" : ".*"` &&
+              test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+               $show "$cmd"
+               $run eval "$cmd" || exit $?
+               skipped_export=false
+             else
+               # The command line is too long to execute in one step.
+               $show "using reloadable object file for export list..."
+               skipped_export=:
+               # Break out early, otherwise skipped_export may be
+               # set to false by a later but shorter cmd.
+               break
+             fi
+           done
+           IFS="$save_ifs"
+           if test -n "$export_symbols_regex"; then
+             $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
+             $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
+             $show "$mv \"${export_symbols}T\" \"$export_symbols\""
+             $run eval '$mv "${export_symbols}T" "$export_symbols"'
+           fi
+         fi
+       fi
+
+       if test -n "$export_symbols" && test -n "$include_expsyms"; then
+         $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
+       fi
+
+       tmp_deplibs=
+       for test_deplib in $deplibs; do
+               case " $convenience " in
+               *" $test_deplib "*) ;;
+               *)
+                       tmp_deplibs="$tmp_deplibs $test_deplib"
+                       ;;
+               esac
+       done
+       deplibs="$tmp_deplibs"
+
+       if test -n "$convenience"; then
+         if test -n "$whole_archive_flag_spec"; then
+           save_libobjs=$libobjs
+           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+         else
+           gentop="$output_objdir/${outputname}x"
+           generated="$generated $gentop"
+
+           func_extract_archives $gentop $convenience
+           libobjs="$libobjs $func_extract_archives_result"
+         fi
+       fi
+       
+       if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
+         eval flag=\"$thread_safe_flag_spec\"
+         linker_flags="$linker_flags $flag"
+       fi
+
+       # Make a backup of the uninstalled library when relinking
+       if test "$mode" = relink; then
+         $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
+       fi
+
+       # Do each of the archive commands.
+       if test "$module" = yes && test -n "$module_cmds" ; then
+         if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+           eval test_cmds=\"$module_expsym_cmds\"
+           cmds=$module_expsym_cmds
+         else
+           eval test_cmds=\"$module_cmds\"
+           cmds=$module_cmds
+         fi
+       else
+       if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+         eval test_cmds=\"$archive_expsym_cmds\"
+         cmds=$archive_expsym_cmds
+       else
+         eval test_cmds=\"$archive_cmds\"
+         cmds=$archive_cmds
+         fi
+       fi
+
+       if test "X$skipped_export" != "X:" &&
+          len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+          test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+         :
+       else
+         # The command line is too long to link in one step, link piecewise.
+         $echo "creating reloadable object files..."
+
+         # Save the value of $output and $libobjs because we want to
+         # use them later.  If we have whole_archive_flag_spec, we
+         # want to use save_libobjs as it was before
+         # whole_archive_flag_spec was expanded, because we can't
+         # assume the linker understands whole_archive_flag_spec.
+         # This may have to be revisited, in case too many
+         # convenience libraries get linked in and end up exceeding
+         # the spec.
+         if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
+           save_libobjs=$libobjs
+         fi
+         save_output=$output
+         output_la=`$echo "X$output" | $Xsed -e "$basename"`
+
+         # Clear the reloadable object creation command queue and
+         # initialize k to one.
+         test_cmds=
+         concat_cmds=
+         objlist=
+         delfiles=
+         last_robj=
+         k=1
+         output=$output_objdir/$output_la-${k}.$objext
+         # Loop over the list of objects to be linked.
+         for obj in $save_libobjs
+         do
+           eval test_cmds=\"$reload_cmds $objlist $last_robj\"
+           if test "X$objlist" = X ||
+              { len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+                test "$len" -le "$max_cmd_len"; }; then
+             objlist="$objlist $obj"
+           else
+             # The command $test_cmds is almost too long, add a
+             # command to the queue.
+             if test "$k" -eq 1 ; then
+               # The first file doesn't have a previous command to add.
+               eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
+             else
+               # All subsequent reloadable object files will link in
+               # the last one created.
+               eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
+             fi
+             last_robj=$output_objdir/$output_la-${k}.$objext
+             k=`expr $k + 1`
+             output=$output_objdir/$output_la-${k}.$objext
+             objlist=$obj
+             len=1
+           fi
+         done
+         # Handle the remaining objects by creating one last
+         # reloadable object file.  All subsequent reloadable object
+         # files will link in the last one created.
+         test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+         eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
+
+         if ${skipped_export-false}; then
+           $show "generating symbol list for \`$libname.la'"
+           export_symbols="$output_objdir/$libname.exp"
+           $run $rm $export_symbols
+           libobjs=$output
+           # Append the command to create the export file.
+           eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
+          fi
+
+         # Set up a command to remove the reloadable object files
+         # after they are used.
+         i=0
+         while test "$i" -lt "$k"
+         do
+           i=`expr $i + 1`
+           delfiles="$delfiles $output_objdir/$output_la-${i}.$objext"
+         done
+
+         $echo "creating a temporary reloadable object file: $output"
+
+         # Loop through the commands generated above and execute them.
+         save_ifs="$IFS"; IFS='~'
+         for cmd in $concat_cmds; do
+           IFS="$save_ifs"
+           $show "$cmd"
+           $run eval "$cmd" || exit $?
+         done
+         IFS="$save_ifs"
+
+         libobjs=$output
+         # Restore the value of output.
+         output=$save_output
+
+         if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
+           eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
+         fi
+         # Expand the library linking commands again to reset the
+         # value of $libobjs for piecewise linking.
+
+         # Do each of the archive commands.
+         if test "$module" = yes && test -n "$module_cmds" ; then
+           if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
+             cmds=$module_expsym_cmds
+           else
+             cmds=$module_cmds
+           fi
+         else
+         if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
+           cmds=$archive_expsym_cmds
+         else
+           cmds=$archive_cmds
+           fi
+         fi
+
+         # Append the command to remove the reloadable object files
+         # to the just-reset $cmds.
+         eval cmds=\"\$cmds~\$rm $delfiles\"
+       fi
+       save_ifs="$IFS"; IFS='~'
+       for cmd in $cmds; do
+         IFS="$save_ifs"
+         eval cmd=\"$cmd\"
+         $show "$cmd"
+         $run eval "$cmd" || {
+           lt_exit=$?
+
+           # Restore the uninstalled library and exit
+           if test "$mode" = relink; then
+             $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
+           fi
+
+           exit $lt_exit
+         }
+       done
+       IFS="$save_ifs"
+
+       # Restore the uninstalled library and exit
+       if test "$mode" = relink; then
+         $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
+
+         if test -n "$convenience"; then
+           if test -z "$whole_archive_flag_spec"; then
+             $show "${rm}r $gentop"
+             $run ${rm}r "$gentop"
+           fi
+         fi
+
+         exit $EXIT_SUCCESS
+       fi
+
+       # Create links to the real library.
+       for linkname in $linknames; do
+         if test "$realname" != "$linkname"; then
+           $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
+           $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
+         fi
+       done
+
+       # If -module or -export-dynamic was specified, set the dlname.
+       if test "$module" = yes || test "$export_dynamic" = yes; then
+         # On all known operating systems, these are identical.
+         dlname="$soname"
+       fi
+      fi
+      ;;
+
+    obj)
+      if test -n "$deplibs"; then
+       $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
+      fi
+
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$rpath"; then
+       $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$xrpath"; then
+       $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$vinfo"; then
+       $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
+      fi
+
+      if test -n "$release"; then
+       $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
+      fi
+
+      case $output in
+      *.lo)
+       if test -n "$objs$old_deplibs"; then
+         $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
+         exit $EXIT_FAILURE
+       fi
+       libobj="$output"
+       obj=`$echo "X$output" | $Xsed -e "$lo2o"`
+       ;;
+      *)
+       libobj=
+       obj="$output"
+       ;;
+      esac
+
+      # Delete the old objects.
+      $run $rm $obj $libobj
+
+      # Objects from convenience libraries.  This assumes
+      # single-version convenience libraries.  Whenever we create
+      # different ones for PIC/non-PIC, this we'll have to duplicate
+      # the extraction.
+      reload_conv_objs=
+      gentop=
+      # reload_cmds runs $LD directly, so let us get rid of
+      # -Wl from whole_archive_flag_spec
+      wl=
+
+      if test -n "$convenience"; then
+       if test -n "$whole_archive_flag_spec"; then
+         eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
+       else
+         gentop="$output_objdir/${obj}x"
+         generated="$generated $gentop"
+
+         func_extract_archives $gentop $convenience
+         reload_conv_objs="$reload_objs $func_extract_archives_result"
+       fi
+      fi
+
+      # Create the old-style object.
+      reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
+
+      output="$obj"
+      cmds=$reload_cmds
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+       IFS="$save_ifs"
+       eval cmd=\"$cmd\"
+       $show "$cmd"
+       $run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+
+      # Exit if we aren't doing a library object file.
+      if test -z "$libobj"; then
+       if test -n "$gentop"; then
+         $show "${rm}r $gentop"
+         $run ${rm}r $gentop
+       fi
+
+       exit $EXIT_SUCCESS
+      fi
+
+      if test "$build_libtool_libs" != yes; then
+       if test -n "$gentop"; then
+         $show "${rm}r $gentop"
+         $run ${rm}r $gentop
+       fi
+
+       # Create an invalid libtool object if no PIC, so that we don't
+       # accidentally link it into a program.
+       # $show "echo timestamp > $libobj"
+       # $run eval "echo timestamp > $libobj" || exit $?
+       exit $EXIT_SUCCESS
+      fi
+
+      if test -n "$pic_flag" || test "$pic_mode" != default; then
+       # Only do commands if we really have different PIC objects.
+       reload_objs="$libobjs $reload_conv_objs"
+       output="$libobj"
+       cmds=$reload_cmds
+       save_ifs="$IFS"; IFS='~'
+       for cmd in $cmds; do
+         IFS="$save_ifs"
+         eval cmd=\"$cmd\"
+         $show "$cmd"
+         $run eval "$cmd" || exit $?
+       done
+       IFS="$save_ifs"
+      fi
+
+      if test -n "$gentop"; then
+       $show "${rm}r $gentop"
+       $run ${rm}r $gentop
+      fi
+
+      exit $EXIT_SUCCESS
+      ;;
+
+    prog)
+      case $host in
+       *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
+      esac
+      if test -n "$vinfo"; then
+       $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
+      fi
+
+      if test -n "$release"; then
+       $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
+      fi
+
+      if test "$preload" = yes; then
+       if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
+          test "$dlopen_self_static" = unknown; then
+         $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
+       fi
+      fi
+
+      case $host in
+      *-*-rhapsody* | *-*-darwin1.[012])
+       # On Rhapsody replace the C library is the System framework
+       compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+       finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
+       ;;
+      esac
+
+      case $host in
+      *darwin*)
+        # Don't allow lazy linking, it breaks C++ global constructors
+        if test "$tagname" = CXX ; then
+        compile_command="$compile_command ${wl}-bind_at_load"
+        finalize_command="$finalize_command ${wl}-bind_at_load"
+        fi
+        ;;
+      esac
+
+
+      # move library search paths that coincide with paths to not yet
+      # installed libraries to the beginning of the library search list
+      new_libs=
+      for path in $notinst_path; do
+       case " $new_libs " in
+       *" -L$path/$objdir "*) ;;
+       *)
+         case " $compile_deplibs " in
+         *" -L$path/$objdir "*)
+           new_libs="$new_libs -L$path/$objdir" ;;
+         esac
+         ;;
+       esac
+      done
+      for deplib in $compile_deplibs; do
+       case $deplib in
+       -L*)
+         case " $new_libs " in
+         *" $deplib "*) ;;
+         *) new_libs="$new_libs $deplib" ;;
+         esac
+         ;;
+       *) new_libs="$new_libs $deplib" ;;
+       esac
+      done
+      compile_deplibs="$new_libs"
+
+
+      compile_command="$compile_command $compile_deplibs"
+      finalize_command="$finalize_command $finalize_deplibs"
+
+      if test -n "$rpath$xrpath"; then
+       # If the user specified any rpath flags, then add them.
+       for libdir in $rpath $xrpath; do
+         # This is the magic to use -rpath.
+         case "$finalize_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_rpath="$finalize_rpath $libdir" ;;
+         esac
+       done
+      fi
+
+      # Now hardcode the library paths
+      rpath=
+      hardcode_libdirs=
+      for libdir in $compile_rpath $finalize_rpath; do
+       if test -n "$hardcode_libdir_flag_spec"; then
+         if test -n "$hardcode_libdir_separator"; then
+           if test -z "$hardcode_libdirs"; then
+             hardcode_libdirs="$libdir"
+           else
+             # Just accumulate the unique libdirs.
+             case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+             *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+               ;;
+             *)
+               hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+               ;;
+             esac
+           fi
+         else
+           eval flag=\"$hardcode_libdir_flag_spec\"
+           rpath="$rpath $flag"
+         fi
+       elif test -n "$runpath_var"; then
+         case "$perm_rpath " in
+         *" $libdir "*) ;;
+         *) perm_rpath="$perm_rpath $libdir" ;;
+         esac
+       fi
+       case $host in
+       *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
+         testbindir=`$echo "X$libdir" | $Xsed -e 's*/lib$*/bin*'`
+         case :$dllsearchpath: in
+         *":$libdir:"*) ;;
+         *) dllsearchpath="$dllsearchpath:$libdir";;
+         esac
+         case :$dllsearchpath: in
+         *":$testbindir:"*) ;;
+         *) dllsearchpath="$dllsearchpath:$testbindir";;
+         esac
+         ;;
+       esac
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+        test -n "$hardcode_libdirs"; then
+       libdir="$hardcode_libdirs"
+       eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      compile_rpath="$rpath"
+
+      rpath=
+      hardcode_libdirs=
+      for libdir in $finalize_rpath; do
+       if test -n "$hardcode_libdir_flag_spec"; then
+         if test -n "$hardcode_libdir_separator"; then
+           if test -z "$hardcode_libdirs"; then
+             hardcode_libdirs="$libdir"
+           else
+             # Just accumulate the unique libdirs.
+             case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
+             *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
+               ;;
+             *)
+               hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
+               ;;
+             esac
+           fi
+         else
+           eval flag=\"$hardcode_libdir_flag_spec\"
+           rpath="$rpath $flag"
+         fi
+       elif test -n "$runpath_var"; then
+         case "$finalize_perm_rpath " in
+         *" $libdir "*) ;;
+         *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
+         esac
+       fi
+      done
+      # Substitute the hardcoded libdirs into the rpath.
+      if test -n "$hardcode_libdir_separator" &&
+        test -n "$hardcode_libdirs"; then
+       libdir="$hardcode_libdirs"
+       eval rpath=\" $hardcode_libdir_flag_spec\"
+      fi
+      finalize_rpath="$rpath"
+
+      if test -n "$libobjs" && test "$build_old_libs" = yes; then
+       # Transform all the library objects into standard objects.
+       compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+       finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+      fi
+
+      dlsyms=
+      if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
+       if test -n "$NM" && test -n "$global_symbol_pipe"; then
+         dlsyms="${outputname}S.c"
+       else
+         $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
+       fi
+      fi
+
+      if test -n "$dlsyms"; then
+       case $dlsyms in
+       "") ;;
+       *.c)
+         # Discover the nlist of each of the dlfiles.
+         nlist="$output_objdir/${outputname}.nm"
+
+         $show "$rm $nlist ${nlist}S ${nlist}T"
+         $run $rm "$nlist" "${nlist}S" "${nlist}T"
+
+         # Parse the name list into a source file.
+         $show "creating $output_objdir/$dlsyms"
+
+         test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
+/* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
+/* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
+
+#ifdef __cplusplus
+extern \"C\" {
+#endif
+
+/* Prevent the only kind of declaration conflicts we can make. */
+#define lt_preloaded_symbols some_other_symbol
+
+/* External symbol declarations for the compiler. */\
+"
+
+         if test "$dlself" = yes; then
+           $show "generating symbol list for \`$output'"
+
+           test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
+
+           # Add our own program objects to the symbol list.
+           progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
+           for arg in $progfiles; do
+             $show "extracting global C symbols from \`$arg'"
+             $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+           done
+
+           if test -n "$exclude_expsyms"; then
+             $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
+             $run eval '$mv "$nlist"T "$nlist"'
+           fi
+
+           if test -n "$export_symbols_regex"; then
+             $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
+             $run eval '$mv "$nlist"T "$nlist"'
+           fi
+
+           # Prepare the list of exported symbols
+           if test -z "$export_symbols"; then
+             export_symbols="$output_objdir/$outputname.exp"
+             $run $rm $export_symbols
+             $run eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
+              case $host in
+              *cygwin* | *mingw* )
+               $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+               $run eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
+                ;;
+              esac
+           else
+             $run eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
+             $run eval 'grep -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
+             $run eval 'mv "$nlist"T "$nlist"'
+              case $host in
+              *cygwin* | *mingw* )
+               $run eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
+               $run eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
+                ;;
+              esac
+           fi
+         fi
+
+         for arg in $dlprefiles; do
+           $show "extracting global C symbols from \`$arg'"
+           name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
+           $run eval '$echo ": $name " >> "$nlist"'
+           $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
+         done
+
+         if test -z "$run"; then
+           # Make sure we have at least an empty file.
+           test -f "$nlist" || : > "$nlist"
+
+           if test -n "$exclude_expsyms"; then
+             $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
+             $mv "$nlist"T "$nlist"
+           fi
+
+           # Try sorting and uniquifying the output.
+           if grep -v "^: " < "$nlist" |
+               if sort -k 3 </dev/null >/dev/null 2>&1; then
+                 sort -k 3
+               else
+                 sort +2
+               fi |
+               uniq > "$nlist"S; then
+             :
+           else
+             grep -v "^: " < "$nlist" > "$nlist"S
+           fi
+
+           if test -f "$nlist"S; then
+             eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
+           else
+             $echo '/* NONE */' >> "$output_objdir/$dlsyms"
+           fi
+
+           $echo >> "$output_objdir/$dlsyms" "\
+
+#undef lt_preloaded_symbols
+
+#if defined (__STDC__) && __STDC__
+# define lt_ptr void *
+#else
+# define lt_ptr char *
+# define const
+#endif
+
+/* The mapping between symbol names and symbols. */
+"
+
+           case $host in
+           *cygwin* | *mingw* )
+         $echo >> "$output_objdir/$dlsyms" "\
+/* DATA imports from DLLs on WIN32 can't be const, because
+   runtime relocations are performed -- see ld's documentation
+   on pseudo-relocs */
+struct {
+"
+             ;;
+           * )
+         $echo >> "$output_objdir/$dlsyms" "\
+const struct {
+"
+             ;;
+           esac
+
+
+         $echo >> "$output_objdir/$dlsyms" "\
+  const char *name;
+  lt_ptr address;
+}
+lt_preloaded_symbols[] =
+{\
+"
+
+           eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
+
+           $echo >> "$output_objdir/$dlsyms" "\
+  {0, (lt_ptr) 0}
+};
+
+/* This works around a problem in FreeBSD linker */
+#ifdef FREEBSD_WORKAROUND
+static const void *lt_preloaded_setup() {
+  return lt_preloaded_symbols;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif\
+"
+         fi
+
+         pic_flag_for_symtable=
+         case $host in
+         # compiling the symbol table file with pic_flag works around
+         # a FreeBSD bug that causes programs to crash when -lm is
+         # linked before any other PIC object.  But we must not use
+         # pic_flag when linking with -static.  The problem exists in
+         # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
+         *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
+           case "$compile_command " in
+           *" -static "*) ;;
+           *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
+           esac;;
+         *-*-hpux*)
+           case "$compile_command " in
+           *" -static "*) ;;
+           *) pic_flag_for_symtable=" $pic_flag";;
+           esac
+         esac
+
+         # Now compile the dynamic symbol file.
+         $show "(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
+         $run eval '(cd $output_objdir && $LTCC  $LTCFLAGS -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
+
+         # Clean up the generated files.
+         $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
+         $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
+
+         # Transform the symbol file into the correct name.
+          case $host in
+          *cygwin* | *mingw* )
+            if test -f "$output_objdir/${outputname}.def" ; then
+              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
+              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}.def $output_objdir/${outputname}S.${objext}%"`
+            else
+              compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+              finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+             fi
+            ;;
+          * )
+            compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+            finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
+            ;;
+          esac
+         ;;
+       *)
+         $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+      else
+       # We keep going just in case the user didn't refer to
+       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
+       # really was required.
+
+       # Nullify the symbol file.
+       compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
+       finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
+      fi
+
+      if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
+       # Replace the output file specification.
+       compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+       link_command="$compile_command$compile_rpath"
+
+       # We have no uninstalled library dependencies, so finalize right now.
+       $show "$link_command"
+       $run eval "$link_command"
+       exit_status=$?
+
+       # Delete the generated files.
+       if test -n "$dlsyms"; then
+         $show "$rm $output_objdir/${outputname}S.${objext}"
+         $run $rm "$output_objdir/${outputname}S.${objext}"
+       fi
+
+       exit $exit_status
+      fi
+
+      if test -n "$shlibpath_var"; then
+       # We should set the shlibpath_var
+       rpath=
+       for dir in $temp_rpath; do
+         case $dir in
+         [\\/]* | [A-Za-z]:[\\/]*)
+           # Absolute path.
+           rpath="$rpath$dir:"
+           ;;
+         *)
+           # Relative path: add a thisdir entry.
+           rpath="$rpath\$thisdir/$dir:"
+           ;;
+         esac
+       done
+       temp_rpath="$rpath"
+      fi
+
+      if test -n "$compile_shlibpath$finalize_shlibpath"; then
+       compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
+      fi
+      if test -n "$finalize_shlibpath"; then
+       finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
+      fi
+
+      compile_var=
+      finalize_var=
+      if test -n "$runpath_var"; then
+       if test -n "$perm_rpath"; then
+         # We should set the runpath_var.
+         rpath=
+         for dir in $perm_rpath; do
+           rpath="$rpath$dir:"
+         done
+         compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
+       fi
+       if test -n "$finalize_perm_rpath"; then
+         # We should set the runpath_var.
+         rpath=
+         for dir in $finalize_perm_rpath; do
+           rpath="$rpath$dir:"
+         done
+         finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
+       fi
+      fi
+
+      if test "$no_install" = yes; then
+       # We don't need to create a wrapper script.
+       link_command="$compile_var$compile_command$compile_rpath"
+       # Replace the output file specification.
+       link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
+       # Delete the old output file.
+       $run $rm $output
+       # Link the executable and exit
+       $show "$link_command"
+       $run eval "$link_command" || exit $?
+       exit $EXIT_SUCCESS
+      fi
+
+      if test "$hardcode_action" = relink; then
+       # Fast installation is not supported
+       link_command="$compile_var$compile_command$compile_rpath"
+       relink_command="$finalize_var$finalize_command$finalize_rpath"
+
+       $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
+       $echo "$modename: \`$output' will be relinked during installation" 1>&2
+      else
+       if test "$fast_install" != no; then
+         link_command="$finalize_var$compile_command$finalize_rpath"
+         if test "$fast_install" = yes; then
+           relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
+         else
+           # fast_install is set to needless
+           relink_command=
+         fi
+       else
+         link_command="$compile_var$compile_command$compile_rpath"
+         relink_command="$finalize_var$finalize_command$finalize_rpath"
+       fi
+      fi
+
+      # Replace the output file specification.
+      link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
+
+      # Delete the old output files.
+      $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
+
+      $show "$link_command"
+      $run eval "$link_command" || exit $?
+
+      # Now create the wrapper script.
+      $show "creating $output"
+
+      # Quote the relink command for shipping.
+      if test -n "$relink_command"; then
+       # Preserve any variables that may affect compiler behavior
+       for var in $variables_saved_for_relink; do
+         if eval test -z \"\${$var+set}\"; then
+           relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
+         elif eval var_value=\$$var; test -z "$var_value"; then
+           relink_command="$var=; export $var; $relink_command"
+         else
+           var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
+           relink_command="$var=\"$var_value\"; export $var; $relink_command"
+         fi
+       done
+       relink_command="(cd `pwd`; $relink_command)"
+       relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Quote $echo for shipping.
+      if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
+       case $progpath in
+       [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
+       *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
+       esac
+       qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
+      else
+       qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
+      fi
+
+      # Only actually do things if our run command is non-null.
+      if test -z "$run"; then
+       # win32 will think the script is a binary if it has
+       # a .exe suffix, so we strip it off here.
+       case $output in
+         *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
+       esac
+       # test for cygwin because mv fails w/o .exe extensions
+       case $host in
+         *cygwin*)
+           exeext=.exe
+           outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
+         *) exeext= ;;
+       esac
+       case $host in
+         *cygwin* | *mingw* )
+            output_name=`basename $output`
+            output_path=`dirname $output`
+            cwrappersource="$output_path/$objdir/lt-$output_name.c"
+            cwrapper="$output_path/$output_name.exe"
+            $rm $cwrappersource $cwrapper
+            trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
+
+           cat > $cwrappersource <<EOF
+
+/* $cwrappersource - temporary wrapper executable for $objdir/$outputname
+   Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+
+   The $output program cannot be directly executed until all the libtool
+   libraries that it depends on are installed.
+
+   This wrapper executable should never be moved out of the build directory.
+   If it is, it will not operate correctly.
+
+   Currently, it simply execs the wrapper *script* "/bin/sh $output",
+   but could eventually absorb all of the scripts functionality and
+   exec $objdir/$outputname directly.
+*/
+EOF
+           cat >> $cwrappersource<<"EOF"
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <malloc.h>
+#include <stdarg.h>
+#include <assert.h>
+#include <string.h>
+#include <ctype.h>
+#include <sys/stat.h>
+
+#if defined(PATH_MAX)
+# define LT_PATHMAX PATH_MAX
+#elif defined(MAXPATHLEN)
+# define LT_PATHMAX MAXPATHLEN
+#else
+# define LT_PATHMAX 1024
+#endif
+
+#ifndef DIR_SEPARATOR
+# define DIR_SEPARATOR '/'
+# define PATH_SEPARATOR ':'
+#endif
+
+#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
+  defined (__OS2__)
+# define HAVE_DOS_BASED_FILE_SYSTEM
+# ifndef DIR_SEPARATOR_2
+#  define DIR_SEPARATOR_2 '\\'
+# endif
+# ifndef PATH_SEPARATOR_2
+#  define PATH_SEPARATOR_2 ';'
+# endif
+#endif
+
+#ifndef DIR_SEPARATOR_2
+# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
+#else /* DIR_SEPARATOR_2 */
+# define IS_DIR_SEPARATOR(ch) \
+        (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
+#endif /* DIR_SEPARATOR_2 */
+
+#ifndef PATH_SEPARATOR_2
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
+#else /* PATH_SEPARATOR_2 */
+# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
+#endif /* PATH_SEPARATOR_2 */
+
+#define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
+#define XFREE(stale) do { \
+  if (stale) { free ((void *) stale); stale = 0; } \
+} while (0)
+
+/* -DDEBUG is fairly common in CFLAGS.  */
+#undef DEBUG
+#if defined DEBUGWRAPPER
+# define DEBUG(format, ...) fprintf(stderr, format, __VA_ARGS__)
+#else
+# define DEBUG(format, ...)
+#endif
+
+const char *program_name = NULL;
+
+void * xmalloc (size_t num);
+char * xstrdup (const char *string);
+const char * base_name (const char *name);
+char * find_executable(const char *wrapper);
+int    check_executable(const char *path);
+char * strendzap(char *str, const char *pat);
+void lt_fatal (const char *message, ...);
+
+int
+main (int argc, char *argv[])
+{
+  char **newargz;
+  int i;
+
+  program_name = (char *) xstrdup (base_name (argv[0]));
+  DEBUG("(main) argv[0]      : %s\n",argv[0]);
+  DEBUG("(main) program_name : %s\n",program_name);
+  newargz = XMALLOC(char *, argc+2);
+EOF
+
+            cat >> $cwrappersource <<EOF
+  newargz[0] = (char *) xstrdup("$SHELL");
+EOF
+
+            cat >> $cwrappersource <<"EOF"
+  newargz[1] = find_executable(argv[0]);
+  if (newargz[1] == NULL)
+    lt_fatal("Couldn't find %s", argv[0]);
+  DEBUG("(main) found exe at : %s\n",newargz[1]);
+  /* we know the script has the same name, without the .exe */
+  /* so make sure newargz[1] doesn't end in .exe */
+  strendzap(newargz[1],".exe");
+  for (i = 1; i < argc; i++)
+    newargz[i+1] = xstrdup(argv[i]);
+  newargz[argc+1] = NULL;
+
+  for (i=0; i<argc+1; i++)
+  {
+    DEBUG("(main) newargz[%d]   : %s\n",i,newargz[i]);
+    ;
+  }
+
+EOF
+
+            case $host_os in
+              mingw*)
+                cat >> $cwrappersource <<EOF
+  execv("$SHELL",(char const **)newargz);
+EOF
+              ;;
+              *)
+                cat >> $cwrappersource <<EOF
+  execv("$SHELL",newargz);
+EOF
+              ;;
+            esac
+
+            cat >> $cwrappersource <<"EOF"
+  return 127;
+}
+
+void *
+xmalloc (size_t num)
+{
+  void * p = (void *) malloc (num);
+  if (!p)
+    lt_fatal ("Memory exhausted");
+
+  return p;
+}
+
+char *
+xstrdup (const char *string)
+{
+  return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
+;
+}
+
+const char *
+base_name (const char *name)
+{
+  const char *base;
+
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  /* Skip over the disk name in MSDOS pathnames. */
+  if (isalpha ((unsigned char)name[0]) && name[1] == ':')
+    name += 2;
+#endif
+
+  for (base = name; *name; name++)
+    if (IS_DIR_SEPARATOR (*name))
+      base = name + 1;
+  return base;
+}
+
+int
+check_executable(const char * path)
+{
+  struct stat st;
+
+  DEBUG("(check_executable)  : %s\n", path ? (*path ? path : "EMPTY!") : "NULL!");
+  if ((!path) || (!*path))
+    return 0;
+
+  if ((stat (path, &st) >= 0) &&
+      (
+        /* MinGW & native WIN32 do not support S_IXOTH or S_IXGRP */
+#if defined (S_IXOTH)
+       ((st.st_mode & S_IXOTH) == S_IXOTH) ||
+#endif
+#if defined (S_IXGRP)
+       ((st.st_mode & S_IXGRP) == S_IXGRP) ||
+#endif
+       ((st.st_mode & S_IXUSR) == S_IXUSR))
+      )
+    return 1;
+  else
+    return 0;
+}
+
+/* Searches for the full path of the wrapper.  Returns
+   newly allocated full path name if found, NULL otherwise */
+char *
+find_executable (const char* wrapper)
+{
+  int has_slash = 0;
+  const char* p;
+  const char* p_next;
+  /* static buffer for getcwd */
+  char tmp[LT_PATHMAX + 1];
+  int tmp_len;
+  char* concat_name;
+
+  DEBUG("(find_executable)  : %s\n", wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!");
+
+  if ((wrapper == NULL) || (*wrapper == '\0'))
+    return NULL;
+
+  /* Absolute path? */
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  if (isalpha ((unsigned char)wrapper[0]) && wrapper[1] == ':')
+  {
+    concat_name = xstrdup (wrapper);
+    if (check_executable(concat_name))
+      return concat_name;
+    XFREE(concat_name);
+  }
+  else
+  {
+#endif
+    if (IS_DIR_SEPARATOR (wrapper[0]))
+    {
+      concat_name = xstrdup (wrapper);
+      if (check_executable(concat_name))
+        return concat_name;
+      XFREE(concat_name);
+    }
+#if defined (HAVE_DOS_BASED_FILE_SYSTEM)
+  }
+#endif
+
+  for (p = wrapper; *p; p++)
+    if (*p == '/')
+    {
+      has_slash = 1;
+      break;
+    }
+  if (!has_slash)
+  {
+    /* no slashes; search PATH */
+    const char* path = getenv ("PATH");
+    if (path != NULL)
+    {
+      for (p = path; *p; p = p_next)
+      {
+        const char* q;
+        size_t p_len;
+        for (q = p; *q; q++)
+          if (IS_PATH_SEPARATOR(*q))
+            break;
+        p_len = q - p;
+        p_next = (*q == '\0' ? q : q + 1);
+        if (p_len == 0)
+        {
+          /* empty path: current directory */
+          if (getcwd (tmp, LT_PATHMAX) == NULL)
+            lt_fatal ("getcwd failed");
+          tmp_len = strlen(tmp);
+          concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
+          memcpy (concat_name, tmp, tmp_len);
+          concat_name[tmp_len] = '/';
+          strcpy (concat_name + tmp_len + 1, wrapper);
+        }
+        else
+        {
+          concat_name = XMALLOC(char, p_len + 1 + strlen(wrapper) + 1);
+          memcpy (concat_name, p, p_len);
+          concat_name[p_len] = '/';
+          strcpy (concat_name + p_len + 1, wrapper);
+        }
+        if (check_executable(concat_name))
+          return concat_name;
+        XFREE(concat_name);
+      }
+    }
+    /* not found in PATH; assume curdir */
+  }
+  /* Relative path | not found in path: prepend cwd */
+  if (getcwd (tmp, LT_PATHMAX) == NULL)
+    lt_fatal ("getcwd failed");
+  tmp_len = strlen(tmp);
+  concat_name = XMALLOC(char, tmp_len + 1 + strlen(wrapper) + 1);
+  memcpy (concat_name, tmp, tmp_len);
+  concat_name[tmp_len] = '/';
+  strcpy (concat_name + tmp_len + 1, wrapper);
+
+  if (check_executable(concat_name))
+    return concat_name;
+  XFREE(concat_name);
+  return NULL;
+}
+
+char *
+strendzap(char *str, const char *pat)
+{
+  size_t len, patlen;
+
+  assert(str != NULL);
+  assert(pat != NULL);
+
+  len = strlen(str);
+  patlen = strlen(pat);
+
+  if (patlen <= len)
+  {
+    str += len - patlen;
+    if (strcmp(str, pat) == 0)
+      *str = '\0';
+  }
+  return str;
+}
+
+static void
+lt_error_core (int exit_status, const char * mode,
+          const char * message, va_list ap)
+{
+  fprintf (stderr, "%s: %s: ", program_name, mode);
+  vfprintf (stderr, message, ap);
+  fprintf (stderr, ".\n");
+
+  if (exit_status >= 0)
+    exit (exit_status);
+}
+
+void
+lt_fatal (const char *message, ...)
+{
+  va_list ap;
+  va_start (ap, message);
+  lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
+  va_end (ap);
+}
+EOF
+          # we should really use a build-platform specific compiler
+          # here, but OTOH, the wrappers (shell script and this C one)
+          # are only useful if you want to execute the "real" binary.
+          # Since the "real" binary is built for $host, then this
+          # wrapper might as well be built for $host, too.
+          $run $LTCC $LTCFLAGS -s -o $cwrapper $cwrappersource
+          ;;
+        esac
+        $rm $output
+        trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
+
+       $echo > $output "\
+#! $SHELL
+
+# $output - temporary wrapper script for $objdir/$outputname
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# The $output program cannot be directly executed until all the libtool
+# libraries that it depends on are installed.
+#
+# This wrapper script should never be moved out of the build directory.
+# If it is, it will not operate correctly.
+
+# Sed substitution that helps us do robust quoting.  It backslashifies
+# metacharacters that are still active within double-quoted strings.
+Xsed='${SED} -e 1s/^X//'
+sed_quote_subst='$sed_quote_subst'
+
+# The HP-UX ksh and POSIX shell print the target directory to stdout
+# if CDPATH is set.
+(unset CDPATH) >/dev/null 2>&1 && unset CDPATH
+
+relink_command=\"$relink_command\"
+
+# This environment variable determines our operation mode.
+if test \"\$libtool_install_magic\" = \"$magic\"; then
+  # install mode needs the following variable:
+  notinst_deplibs='$notinst_deplibs'
+else
+  # When we are sourced in execute mode, \$file and \$echo are already set.
+  if test \"\$libtool_execute_magic\" != \"$magic\"; then
+    echo=\"$qecho\"
+    file=\"\$0\"
+    # Make sure echo works.
+    if test \"X\$1\" = X--no-reexec; then
+      # Discard the --no-reexec flag, and continue.
+      shift
+    elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
+      # Yippee, \$echo works!
+      :
+    else
+      # Restart under the correct shell, and then maybe \$echo will work.
+      exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
+    fi
+  fi\
+"
+       $echo >> $output "\
+
+  # Find the directory that this script lives in.
+  thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
+  test \"x\$thisdir\" = \"x\$file\" && thisdir=.
+
+  # Follow symbolic links until we get to the real thisdir.
+  file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
+  while test -n \"\$file\"; do
+    destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
+
+    # If there was a directory component, then change thisdir.
+    if test \"x\$destdir\" != \"x\$file\"; then
+      case \"\$destdir\" in
+      [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
+      *) thisdir=\"\$thisdir/\$destdir\" ;;
+      esac
+    fi
+
+    file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
+    file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
+  done
+
+  # Try to get the absolute directory name.
+  absdir=\`cd \"\$thisdir\" && pwd\`
+  test -n \"\$absdir\" && thisdir=\"\$absdir\"
+"
+
+       if test "$fast_install" = yes; then
+         $echo >> $output "\
+  program=lt-'$outputname'$exeext
+  progdir=\"\$thisdir/$objdir\"
+
+  if test ! -f \"\$progdir/\$program\" || \\
+     { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
+       test \"X\$file\" != \"X\$progdir/\$program\"; }; then
+
+    file=\"\$\$-\$program\"
+
+    if test ! -d \"\$progdir\"; then
+      $mkdir \"\$progdir\"
+    else
+      $rm \"\$progdir/\$file\"
+    fi"
+
+         $echo >> $output "\
+
+    # relink executable if necessary
+    if test -n \"\$relink_command\"; then
+      if relink_command_output=\`eval \$relink_command 2>&1\`; then :
+      else
+       $echo \"\$relink_command_output\" >&2
+       $rm \"\$progdir/\$file\"
+       exit $EXIT_FAILURE
+      fi
+    fi
+
+    $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
+    { $rm \"\$progdir/\$program\";
+      $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
+    $rm \"\$progdir/\$file\"
+  fi"
+       else
+         $echo >> $output "\
+  program='$outputname'
+  progdir=\"\$thisdir/$objdir\"
+"
+       fi
+
+       $echo >> $output "\
+
+  if test -f \"\$progdir/\$program\"; then"
+
+       # Export our shlibpath_var if we have one.
+       if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
+         $echo >> $output "\
+    # Add our own library path to $shlibpath_var
+    $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
+
+    # Some systems cannot cope with colon-terminated $shlibpath_var
+    # The second colon is a workaround for a bug in BeOS R4 sed
+    $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
+
+    export $shlibpath_var
+"
+       fi
+
+       # fixup the dll searchpath if we need to.
+       if test -n "$dllsearchpath"; then
+         $echo >> $output "\
+    # Add the dll search path components to the executable PATH
+    PATH=$dllsearchpath:\$PATH
+"
+       fi
+
+       $echo >> $output "\
+    if test \"\$libtool_execute_magic\" != \"$magic\"; then
+      # Run the actual program with our arguments.
+"
+       case $host in
+       # Backslashes separate directories on plain windows
+       *-*-mingw | *-*-os2*)
+         $echo >> $output "\
+      exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
+"
+         ;;
+
+       *)
+         $echo >> $output "\
+      exec \"\$progdir/\$program\" \${1+\"\$@\"}
+"
+         ;;
+       esac
+       $echo >> $output "\
+      \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
+      exit $EXIT_FAILURE
+    fi
+  else
+    # The program doesn't exist.
+    \$echo \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
+    \$echo \"This script is just a wrapper for \$program.\" 1>&2
+    $echo \"See the $PACKAGE documentation for more information.\" 1>&2
+    exit $EXIT_FAILURE
+  fi
+fi\
+"
+       chmod +x $output
+      fi
+      exit $EXIT_SUCCESS
+      ;;
+    esac
+
+    # See if we need to build an old-fashioned archive.
+    for oldlib in $oldlibs; do
+
+      if test "$build_libtool_libs" = convenience; then
+       oldobjs="$libobjs_save"
+       addlibs="$convenience"
+       build_libtool_libs=no
+      else
+       if test "$build_libtool_libs" = module; then
+         oldobjs="$libobjs_save"
+         build_libtool_libs=no
+       else
+         oldobjs="$old_deplibs $non_pic_objects"
+       fi
+       addlibs="$old_convenience"
+      fi
+
+      if test -n "$addlibs"; then
+       gentop="$output_objdir/${outputname}x"
+       generated="$generated $gentop"
+
+       func_extract_archives $gentop $addlibs
+       oldobjs="$oldobjs $func_extract_archives_result"
+      fi
+
+      # Do each command in the archive commands.
+      if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
+       cmds=$old_archive_from_new_cmds
+      else
+       # POSIX demands no paths to be encoded in archives.  We have
+       # to avoid creating archives with duplicate basenames if we
+       # might have to extract them afterwards, e.g., when creating a
+       # static archive out of a convenience library, or when linking
+       # the entirety of a libtool archive into another (currently
+       # not supported by libtool).
+       if (for obj in $oldobjs
+           do
+             $echo "X$obj" | $Xsed -e 's%^.*/%%'
+           done | sort | sort -uc >/dev/null 2>&1); then
+         :
+       else
+         $echo "copying selected object files to avoid basename conflicts..."
+
+         if test -z "$gentop"; then
+           gentop="$output_objdir/${outputname}x"
+           generated="$generated $gentop"
+
+           $show "${rm}r $gentop"
+           $run ${rm}r "$gentop"
+           $show "$mkdir $gentop"
+           $run $mkdir "$gentop"
+           exit_status=$?
+           if test "$exit_status" -ne 0 && test ! -d "$gentop"; then
+             exit $exit_status
+           fi
+         fi
+
+         save_oldobjs=$oldobjs
+         oldobjs=
+         counter=1
+         for obj in $save_oldobjs
+         do
+           objbase=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
+           case " $oldobjs " in
+           " ") oldobjs=$obj ;;
+           *[\ /]"$objbase "*)
+             while :; do
+               # Make sure we don't pick an alternate name that also
+               # overlaps.
+               newobj=lt$counter-$objbase
+               counter=`expr $counter + 1`
+               case " $oldobjs " in
+               *[\ /]"$newobj "*) ;;
+               *) if test ! -f "$gentop/$newobj"; then break; fi ;;
+               esac
+             done
+             $show "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
+             $run ln "$obj" "$gentop/$newobj" ||
+             $run cp "$obj" "$gentop/$newobj"
+             oldobjs="$oldobjs $gentop/$newobj"
+             ;;
+           *) oldobjs="$oldobjs $obj" ;;
+           esac
+         done
+       fi
+
+       eval cmds=\"$old_archive_cmds\"
+
+       if len=`expr "X$cmds" : ".*"` &&
+            test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
+         cmds=$old_archive_cmds
+       else
+         # the command line is too long to link in one step, link in parts
+         $echo "using piecewise archive linking..."
+         save_RANLIB=$RANLIB
+         RANLIB=:
+         objlist=
+         concat_cmds=
+         save_oldobjs=$oldobjs
+
+         # Is there a better way of finding the last object in the list?
+         for obj in $save_oldobjs
+         do
+           last_oldobj=$obj
+         done
+         for obj in $save_oldobjs
+         do
+           oldobjs="$objlist $obj"
+           objlist="$objlist $obj"
+           eval test_cmds=\"$old_archive_cmds\"
+           if len=`expr "X$test_cmds" : ".*" 2>/dev/null` &&
+              test "$len" -le "$max_cmd_len"; then
+             :
+           else
+             # the above command should be used before it gets too long
+             oldobjs=$objlist
+             if test "$obj" = "$last_oldobj" ; then
+               RANLIB=$save_RANLIB
+             fi
+             test -z "$concat_cmds" || concat_cmds=$concat_cmds~
+             eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
+             objlist=
+           fi
+         done
+         RANLIB=$save_RANLIB
+         oldobjs=$objlist
+         if test "X$oldobjs" = "X" ; then
+           eval cmds=\"\$concat_cmds\"
+         else
+           eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
+         fi
+       fi
+      fi
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+        eval cmd=\"$cmd\"
+       IFS="$save_ifs"
+       $show "$cmd"
+       $run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+    done
+
+    if test -n "$generated"; then
+      $show "${rm}r$generated"
+      $run ${rm}r$generated
+    fi
+
+    # Now create the libtool archive.
+    case $output in
+    *.la)
+      old_library=
+      test "$build_old_libs" = yes && old_library="$libname.$libext"
+      $show "creating $output"
+
+      # Preserve any variables that may affect compiler behavior
+      for var in $variables_saved_for_relink; do
+       if eval test -z \"\${$var+set}\"; then
+         relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
+       elif eval var_value=\$$var; test -z "$var_value"; then
+         relink_command="$var=; export $var; $relink_command"
+       else
+         var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
+         relink_command="$var=\"$var_value\"; export $var; $relink_command"
+       fi
+      done
+      # Quote the link command for shipping.
+      relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
+      relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
+      if test "$hardcode_automatic" = yes ; then
+       relink_command=
+      fi
+
+
+      # Only create the output if not a dry run.
+      if test -z "$run"; then
+       for installed in no yes; do
+         if test "$installed" = yes; then
+           if test -z "$install_libdir"; then
+             break
+           fi
+           output="$output_objdir/$outputname"i
+           # Replace all uninstalled libtool libraries with the installed ones
+           newdependency_libs=
+           for deplib in $dependency_libs; do
+             case $deplib in
+             *.la)
+               name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
+               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
+               if test -z "$libdir"; then
+                 $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
+                 exit $EXIT_FAILURE
+               fi
+               newdependency_libs="$newdependency_libs $libdir/$name"
+               ;;
+             *) newdependency_libs="$newdependency_libs $deplib" ;;
+             esac
+           done
+           dependency_libs="$newdependency_libs"
+           newdlfiles=
+           for lib in $dlfiles; do
+             name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+             eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+             if test -z "$libdir"; then
+               $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+               exit $EXIT_FAILURE
+             fi
+             newdlfiles="$newdlfiles $libdir/$name"
+           done
+           dlfiles="$newdlfiles"
+           newdlprefiles=
+           for lib in $dlprefiles; do
+             name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
+             eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
+             if test -z "$libdir"; then
+               $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+               exit $EXIT_FAILURE
+             fi
+             newdlprefiles="$newdlprefiles $libdir/$name"
+           done
+           dlprefiles="$newdlprefiles"
+         else
+           newdlfiles=
+           for lib in $dlfiles; do
+             case $lib in
+               [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+               *) abs=`pwd`"/$lib" ;;
+             esac
+             newdlfiles="$newdlfiles $abs"
+           done
+           dlfiles="$newdlfiles"
+           newdlprefiles=
+           for lib in $dlprefiles; do
+             case $lib in
+               [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
+               *) abs=`pwd`"/$lib" ;;
+             esac
+             newdlprefiles="$newdlprefiles $abs"
+           done
+           dlprefiles="$newdlprefiles"
+         fi
+         $rm $output
+         # place dlname in correct position for cygwin
+         tdlname=$dlname
+         case $host,$output,$installed,$module,$dlname in
+           *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
+         esac
+         $echo > $output "\
+# $outputname - a libtool library file
+# Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
+#
+# Please DO NOT delete this file!
+# It is necessary for linking the library.
+
+# The name that we can dlopen(3).
+dlname='$tdlname'
+
+# Names of this library.
+library_names='$library_names'
+
+# The name of the static archive.
+old_library='$old_library'
+
+# Libraries that this one depends upon.
+dependency_libs='$dependency_libs'
+
+# Version information for $libname.
+current=$current
+age=$age
+revision=$revision
+
+# Is this an already installed library?
+installed=$installed
+
+# Should we warn about portability when linking against -modules?
+shouldnotlink=$module
+
+# Files to dlopen/dlpreopen
+dlopen='$dlfiles'
+dlpreopen='$dlprefiles'
+
+# Directory that this library needs to be installed in:
+libdir='$install_libdir'"
+         if test "$installed" = no && test "$need_relink" = yes; then
+           $echo >> $output "\
+relink_command=\"$relink_command\""
+         fi
+       done
+      fi
+
+      # Do a symbolic link so that the libtool archive can be found in
+      # LD_LIBRARY_PATH before the program is installed.
+      $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
+      $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
+      ;;
+    esac
+    exit $EXIT_SUCCESS
+    ;;
+
+  # libtool install mode
+  install)
+    modename="$modename: install"
+
+    # There may be an optional sh(1) argument at the beginning of
+    # install_prog (especially on Windows NT).
+    if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
+       # Allow the use of GNU shtool's install command.
+       $echo "X$nonopt" | grep shtool > /dev/null; then
+      # Aesthetically quote it.
+      arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
+      case $arg in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+       arg="\"$arg\""
+       ;;
+      esac
+      install_prog="$arg "
+      arg="$1"
+      shift
+    else
+      install_prog=
+      arg=$nonopt
+    fi
+
+    # The real first argument should be the name of the installation program.
+    # Aesthetically quote it.
+    arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+    case $arg in
+    *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \      ]*|*]*|"")
+      arg="\"$arg\""
+      ;;
+    esac
+    install_prog="$install_prog$arg"
+
+    # We need to accept at least all the BSD install flags.
+    dest=
+    files=
+    opts=
+    prev=
+    install_type=
+    isdir=no
+    stripme=
+    for arg
+    do
+      if test -n "$dest"; then
+       files="$files $dest"
+       dest=$arg
+       continue
+      fi
+
+      case $arg in
+      -d) isdir=yes ;;
+      -f) 
+       case " $install_prog " in
+       *[\\\ /]cp\ *) ;;
+       *) prev=$arg ;;
+       esac
+       ;;
+      -g | -m | -o) prev=$arg ;;
+      -s)
+       stripme=" -s"
+       continue
+       ;;
+      -*)
+       ;;
+      *)
+       # If the previous option needed an argument, then skip it.
+       if test -n "$prev"; then
+         prev=
+       else
+         dest=$arg
+         continue
+       fi
+       ;;
+      esac
+
+      # Aesthetically quote the argument.
+      arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
+      case $arg in
+      *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \    ]*|*]*|"")
+       arg="\"$arg\""
+       ;;
+      esac
+      install_prog="$install_prog $arg"
+    done
+
+    if test -z "$install_prog"; then
+      $echo "$modename: you must specify an install program" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    if test -n "$prev"; then
+      $echo "$modename: the \`$prev' option requires an argument" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    if test -z "$files"; then
+      if test -z "$dest"; then
+       $echo "$modename: no file or destination specified" 1>&2
+      else
+       $echo "$modename: you must specify a destination" 1>&2
+      fi
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    # Strip any trailing slash from the destination.
+    dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
+
+    # Check to see that the destination is a directory.
+    test -d "$dest" && isdir=yes
+    if test "$isdir" = yes; then
+      destdir="$dest"
+      destname=
+    else
+      destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
+      test "X$destdir" = "X$dest" && destdir=.
+      destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
+
+      # Not a directory, so check to see that there is only one file specified.
+      set dummy $files
+      if test "$#" -gt 2; then
+       $echo "$modename: \`$dest' is not a directory" 1>&2
+       $echo "$help" 1>&2
+       exit $EXIT_FAILURE
+      fi
+    fi
+    case $destdir in
+    [\\/]* | [A-Za-z]:[\\/]*) ;;
+    *)
+      for file in $files; do
+       case $file in
+       *.lo) ;;
+       *)
+         $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+      done
+      ;;
+    esac
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    staticlibs=
+    future_libdirs=
+    current_libdirs=
+    for file in $files; do
+
+      # Do each installation.
+      case $file in
+      *.$libext)
+       # Do the static libraries later.
+       staticlibs="$staticlibs $file"
+       ;;
+
+      *.la)
+       # Check to see that this really is a libtool archive.
+       if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       else
+         $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       library_names=
+       old_library=
+       relink_command=
+       # If there is no directory component, then add one.
+       case $file in
+       */* | *\\*) . $file ;;
+       *) . ./$file ;;
+       esac
+
+       # Add the libdir to current_libdirs if it is the destination.
+       if test "X$destdir" = "X$libdir"; then
+         case "$current_libdirs " in
+         *" $libdir "*) ;;
+         *) current_libdirs="$current_libdirs $libdir" ;;
+         esac
+       else
+         # Note the libdir as a future libdir.
+         case "$future_libdirs " in
+         *" $libdir "*) ;;
+         *) future_libdirs="$future_libdirs $libdir" ;;
+         esac
+       fi
+
+       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
+       test "X$dir" = "X$file/" && dir=
+       dir="$dir$objdir"
+
+       if test -n "$relink_command"; then
+         # Determine the prefix the user has applied to our future dir.
+         inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
+
+         # Don't allow the user to place us outside of our expected
+         # location b/c this prevents finding dependent libraries that
+         # are installed to the same prefix.
+         # At present, this check doesn't affect windows .dll's that
+         # are installed into $libdir/../bin (currently, that works fine)
+         # but it's something to keep an eye on.
+         if test "$inst_prefix_dir" = "$destdir"; then
+           $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
+           exit $EXIT_FAILURE
+         fi
+
+         if test -n "$inst_prefix_dir"; then
+           # Stick the inst_prefix_dir data into the link command.
+           relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
+         else
+           relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
+         fi
+
+         $echo "$modename: warning: relinking \`$file'" 1>&2
+         $show "$relink_command"
+         if $run eval "$relink_command"; then :
+         else
+           $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+           exit $EXIT_FAILURE
+         fi
+       fi
+
+       # See the names of the shared library.
+       set dummy $library_names
+       if test -n "$2"; then
+         realname="$2"
+         shift
+         shift
+
+         srcname="$realname"
+         test -n "$relink_command" && srcname="$realname"T
+
+         # Install the shared library and build the symlinks.
+         $show "$install_prog $dir/$srcname $destdir/$realname"
+         $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
+         if test -n "$stripme" && test -n "$striplib"; then
+           $show "$striplib $destdir/$realname"
+           $run eval "$striplib $destdir/$realname" || exit $?
+         fi
+
+         if test "$#" -gt 0; then
+           # Delete the old symlinks, and create new ones.
+           # Try `ln -sf' first, because the `ln' binary might depend on
+           # the symlink we replace!  Solaris /bin/ln does not understand -f,
+           # so we also need to try rm && ln -s.
+           for linkname
+           do
+             if test "$linkname" != "$realname"; then
+                $show "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
+                $run eval "(cd $destdir && { $LN_S -f $realname $linkname || { $rm $linkname && $LN_S $realname $linkname; }; })"
+             fi
+           done
+         fi
+
+         # Do each command in the postinstall commands.
+         lib="$destdir/$realname"
+         cmds=$postinstall_cmds
+         save_ifs="$IFS"; IFS='~'
+         for cmd in $cmds; do
+           IFS="$save_ifs"
+           eval cmd=\"$cmd\"
+           $show "$cmd"
+           $run eval "$cmd" || {
+             lt_exit=$?
+
+             # Restore the uninstalled library and exit
+             if test "$mode" = relink; then
+               $run eval '(cd $output_objdir && $rm ${realname}T && $mv ${realname}U $realname)'
+             fi
+
+             exit $lt_exit
+           }
+         done
+         IFS="$save_ifs"
+       fi
+
+       # Install the pseudo-library for information purposes.
+       name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+       instname="$dir/$name"i
+       $show "$install_prog $instname $destdir/$name"
+       $run eval "$install_prog $instname $destdir/$name" || exit $?
+
+       # Maybe install the static library, too.
+       test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
+       ;;
+
+      *.lo)
+       # Install (i.e. copy) a libtool object.
+
+       # Figure out destination file name, if it wasn't already specified.
+       if test -n "$destname"; then
+         destfile="$destdir/$destname"
+       else
+         destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+         destfile="$destdir/$destfile"
+       fi
+
+       # Deduce the name of the destination old-style object file.
+       case $destfile in
+       *.lo)
+         staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
+         ;;
+       *.$objext)
+         staticdest="$destfile"
+         destfile=
+         ;;
+       *)
+         $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+         ;;
+       esac
+
+       # Install the libtool object if requested.
+       if test -n "$destfile"; then
+         $show "$install_prog $file $destfile"
+         $run eval "$install_prog $file $destfile" || exit $?
+       fi
+
+       # Install the old object if enabled.
+       if test "$build_old_libs" = yes; then
+         # Deduce the name of the old-style object file.
+         staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
+
+         $show "$install_prog $staticobj $staticdest"
+         $run eval "$install_prog \$staticobj \$staticdest" || exit $?
+       fi
+       exit $EXIT_SUCCESS
+       ;;
+
+      *)
+       # Figure out destination file name, if it wasn't already specified.
+       if test -n "$destname"; then
+         destfile="$destdir/$destname"
+       else
+         destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+         destfile="$destdir/$destfile"
+       fi
+
+       # If the file is missing, and there is a .exe on the end, strip it
+       # because it is most likely a libtool script we actually want to
+       # install
+       stripped_ext=""
+       case $file in
+         *.exe)
+           if test ! -f "$file"; then
+             file=`$echo $file|${SED} 's,.exe$,,'`
+             stripped_ext=".exe"
+           fi
+           ;;
+       esac
+
+       # Do a test to see if this is really a libtool program.
+       case $host in
+       *cygwin*|*mingw*)
+           wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
+           ;;
+       *)
+           wrapper=$file
+           ;;
+       esac
+       if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
+         notinst_deplibs=
+         relink_command=
+
+         # Note that it is not necessary on cygwin/mingw to append a dot to
+         # foo even if both foo and FILE.exe exist: automatic-append-.exe
+         # behavior happens only for exec(3), not for open(2)!  Also, sourcing
+         # `FILE.' does not work on cygwin managed mounts.
+         #
+         # If there is no directory component, then add one.
+         case $wrapper in
+         */* | *\\*) . ${wrapper} ;;
+         *) . ./${wrapper} ;;
+         esac
+
+         # Check the variables that should have been set.
+         if test -z "$notinst_deplibs"; then
+           $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
+           exit $EXIT_FAILURE
+         fi
+
+         finalize=yes
+         for lib in $notinst_deplibs; do
+           # Check to see that each library is installed.
+           libdir=
+           if test -f "$lib"; then
+             # If there is no directory component, then add one.
+             case $lib in
+             */* | *\\*) . $lib ;;
+             *) . ./$lib ;;
+             esac
+           fi
+           libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
+           if test -n "$libdir" && test ! -f "$libfile"; then
+             $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
+             finalize=no
+           fi
+         done
+
+         relink_command=
+         # Note that it is not necessary on cygwin/mingw to append a dot to
+         # foo even if both foo and FILE.exe exist: automatic-append-.exe
+         # behavior happens only for exec(3), not for open(2)!  Also, sourcing
+         # `FILE.' does not work on cygwin managed mounts.
+         #
+         # If there is no directory component, then add one.
+         case $wrapper in
+         */* | *\\*) . ${wrapper} ;;
+         *) . ./${wrapper} ;;
+         esac
+
+         outputname=
+         if test "$fast_install" = no && test -n "$relink_command"; then
+           if test "$finalize" = yes && test -z "$run"; then
+             tmpdir=`func_mktempdir`
+             file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
+             outputname="$tmpdir/$file"
+             # Replace the output file specification.
+             relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
+
+             $show "$relink_command"
+             if $run eval "$relink_command"; then :
+             else
+               $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
+               ${rm}r "$tmpdir"
+               continue
+             fi
+             file="$outputname"
+           else
+             $echo "$modename: warning: cannot relink \`$file'" 1>&2
+           fi
+         else
+           # Install the binary that we compiled earlier.
+           file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
+         fi
+       fi
+
+       # remove .exe since cygwin /usr/bin/install will append another
+       # one anyway 
+       case $install_prog,$host in
+       */usr/bin/install*,*cygwin*)
+         case $file:$destfile in
+         *.exe:*.exe)
+           # this is ok
+           ;;
+         *.exe:*)
+           destfile=$destfile.exe
+           ;;
+         *:*.exe)
+           destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
+           ;;
+         esac
+         ;;
+       esac
+       $show "$install_prog$stripme $file $destfile"
+       $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
+       test -n "$outputname" && ${rm}r "$tmpdir"
+       ;;
+      esac
+    done
+
+    for file in $staticlibs; do
+      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+
+      # Set up the ranlib parameters.
+      oldlib="$destdir/$name"
+
+      $show "$install_prog $file $oldlib"
+      $run eval "$install_prog \$file \$oldlib" || exit $?
+
+      if test -n "$stripme" && test -n "$old_striplib"; then
+       $show "$old_striplib $oldlib"
+       $run eval "$old_striplib $oldlib" || exit $?
+      fi
+
+      # Do each command in the postinstall commands.
+      cmds=$old_postinstall_cmds
+      save_ifs="$IFS"; IFS='~'
+      for cmd in $cmds; do
+       IFS="$save_ifs"
+       eval cmd=\"$cmd\"
+       $show "$cmd"
+       $run eval "$cmd" || exit $?
+      done
+      IFS="$save_ifs"
+    done
+
+    if test -n "$future_libdirs"; then
+      $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
+    fi
+
+    if test -n "$current_libdirs"; then
+      # Maybe just do a dry run.
+      test -n "$run" && current_libdirs=" -n$current_libdirs"
+      exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
+    else
+      exit $EXIT_SUCCESS
+    fi
+    ;;
+
+  # libtool finish mode
+  finish)
+    modename="$modename: finish"
+    libdirs="$nonopt"
+    admincmds=
+
+    if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
+      for dir
+      do
+       libdirs="$libdirs $dir"
+      done
+
+      for libdir in $libdirs; do
+       if test -n "$finish_cmds"; then
+         # Do each command in the finish commands.
+         cmds=$finish_cmds
+         save_ifs="$IFS"; IFS='~'
+         for cmd in $cmds; do
+           IFS="$save_ifs"
+           eval cmd=\"$cmd\"
+           $show "$cmd"
+           $run eval "$cmd" || admincmds="$admincmds
+       $cmd"
+         done
+         IFS="$save_ifs"
+       fi
+       if test -n "$finish_eval"; then
+         # Do the single finish_eval.
+         eval cmds=\"$finish_eval\"
+         $run eval "$cmds" || admincmds="$admincmds
+       $cmds"
+       fi
+      done
+    fi
+
+    # Exit here if they wanted silent mode.
+    test "$show" = : && exit $EXIT_SUCCESS
+
+    $echo "X----------------------------------------------------------------------" | $Xsed
+    $echo "Libraries have been installed in:"
+    for libdir in $libdirs; do
+      $echo "   $libdir"
+    done
+    $echo
+    $echo "If you ever happen to want to link against installed libraries"
+    $echo "in a given directory, LIBDIR, you must either use libtool, and"
+    $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
+    $echo "flag during linking and do at least one of the following:"
+    if test -n "$shlibpath_var"; then
+      $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
+      $echo "     during execution"
+    fi
+    if test -n "$runpath_var"; then
+      $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
+      $echo "     during linking"
+    fi
+    if test -n "$hardcode_libdir_flag_spec"; then
+      libdir=LIBDIR
+      eval flag=\"$hardcode_libdir_flag_spec\"
+
+      $echo "   - use the \`$flag' linker flag"
+    fi
+    if test -n "$admincmds"; then
+      $echo "   - have your system administrator run these commands:$admincmds"
+    fi
+    if test -f /etc/ld.so.conf; then
+      $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
+    fi
+    $echo
+    $echo "See any operating system documentation about shared libraries for"
+    $echo "more information, such as the ld(1) and ld.so(8) manual pages."
+    $echo "X----------------------------------------------------------------------" | $Xsed
+    exit $EXIT_SUCCESS
+    ;;
+
+  # libtool execute mode
+  execute)
+    modename="$modename: execute"
+
+    # The first argument is the command name.
+    cmd="$nonopt"
+    if test -z "$cmd"; then
+      $echo "$modename: you must specify a COMMAND" 1>&2
+      $echo "$help"
+      exit $EXIT_FAILURE
+    fi
+
+    # Handle -dlopen flags immediately.
+    for file in $execute_dlfiles; do
+      if test ! -f "$file"; then
+       $echo "$modename: \`$file' is not a file" 1>&2
+       $echo "$help" 1>&2
+       exit $EXIT_FAILURE
+      fi
+
+      dir=
+      case $file in
+      *.la)
+       # Check to see that this really is a libtool archive.
+       if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
+       else
+         $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
+         $echo "$help" 1>&2
+         exit $EXIT_FAILURE
+       fi
+
+       # Read the libtool library.
+       dlname=
+       library_names=
+
+       # If there is no directory component, then add one.
+       case $file in
+       */* | *\\*) . $file ;;
+       *) . ./$file ;;
+       esac
+
+       # Skip this library if it cannot be dlopened.
+       if test -z "$dlname"; then
+         # Warn if it was a shared library.
+         test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
+         continue
+       fi
+
+       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+       test "X$dir" = "X$file" && dir=.
+
+       if test -f "$dir/$objdir/$dlname"; then
+         dir="$dir/$objdir"
+       else
+         $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
+         exit $EXIT_FAILURE
+       fi
+       ;;
+
+      *.lo)
+       # Just add the directory containing the .lo file.
+       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+       test "X$dir" = "X$file" && dir=.
+       ;;
+
+      *)
+       $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
+       continue
+       ;;
+      esac
+
+      # Get the absolute pathname.
+      absdir=`cd "$dir" && pwd`
+      test -n "$absdir" && dir="$absdir"
+
+      # Now add the directory to shlibpath_var.
+      if eval "test -z \"\$$shlibpath_var\""; then
+       eval "$shlibpath_var=\"\$dir\""
+      else
+       eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
+      fi
+    done
+
+    # This variable tells wrapper scripts just to set shlibpath_var
+    # rather than running their programs.
+    libtool_execute_magic="$magic"
+
+    # Check if any of the arguments is a wrapper script.
+    args=
+    for file
+    do
+      case $file in
+      -*) ;;
+      *)
+       # Do a test to see if this is really a libtool program.
+       if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+         # If there is no directory component, then add one.
+         case $file in
+         */* | *\\*) . $file ;;
+         *) . ./$file ;;
+         esac
+
+         # Transform arg to wrapped name.
+         file="$progdir/$program"
+       fi
+       ;;
+      esac
+      # Quote arguments (to preserve shell metacharacters).
+      file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
+      args="$args \"$file\""
+    done
+
+    if test -z "$run"; then
+      if test -n "$shlibpath_var"; then
+       # Export the shlibpath_var.
+       eval "export $shlibpath_var"
+      fi
+
+      # Restore saved environment variables
+      if test "${save_LC_ALL+set}" = set; then
+       LC_ALL="$save_LC_ALL"; export LC_ALL
+      fi
+      if test "${save_LANG+set}" = set; then
+       LANG="$save_LANG"; export LANG
+      fi
+
+      # Now prepare to actually exec the command.
+      exec_cmd="\$cmd$args"
+    else
+      # Display what would be done.
+      if test -n "$shlibpath_var"; then
+       eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
+       $echo "export $shlibpath_var"
+      fi
+      $echo "$cmd$args"
+      exit $EXIT_SUCCESS
+    fi
+    ;;
+
+  # libtool clean and uninstall mode
+  clean | uninstall)
+    modename="$modename: $mode"
+    rm="$nonopt"
+    files=
+    rmforce=
+    exit_status=0
+
+    # This variable tells wrapper scripts just to set variables rather
+    # than running their programs.
+    libtool_install_magic="$magic"
+
+    for arg
+    do
+      case $arg in
+      -f) rm="$rm $arg"; rmforce=yes ;;
+      -*) rm="$rm $arg" ;;
+      *) files="$files $arg" ;;
+      esac
+    done
+
+    if test -z "$rm"; then
+      $echo "$modename: you must specify an RM program" 1>&2
+      $echo "$help" 1>&2
+      exit $EXIT_FAILURE
+    fi
+
+    rmdirs=
+
+    origobjdir="$objdir"
+    for file in $files; do
+      dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
+      if test "X$dir" = "X$file"; then
+       dir=.
+       objdir="$origobjdir"
+      else
+       objdir="$dir/$origobjdir"
+      fi
+      name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
+      test "$mode" = uninstall && objdir="$dir"
+
+      # Remember objdir for removal later, being careful to avoid duplicates
+      if test "$mode" = clean; then
+       case " $rmdirs " in
+         *" $objdir "*) ;;
+         *) rmdirs="$rmdirs $objdir" ;;
+       esac
+      fi
+
+      # Don't error if the file doesn't exist and rm -f was used.
+      if (test -L "$file") >/dev/null 2>&1 \
+       || (test -h "$file") >/dev/null 2>&1 \
+       || test -f "$file"; then
+       :
+      elif test -d "$file"; then
+       exit_status=1
+       continue
+      elif test "$rmforce" = yes; then
+       continue
+      fi
+
+      rmfiles="$file"
+
+      case $name in
+      *.la)
+       # Possibly a libtool archive, so verify it.
+       if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+         . $dir/$name
+
+         # Delete the libtool libraries and symlinks.
+         for n in $library_names; do
+           rmfiles="$rmfiles $objdir/$n"
+         done
+         test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
+
+         case "$mode" in
+         clean)
+           case "  $library_names " in
+           # "  " in the beginning catches empty $dlname
+           *" $dlname "*) ;;
+           *) rmfiles="$rmfiles $objdir/$dlname" ;;
+           esac
+            test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
+           ;;
+         uninstall)
+           if test -n "$library_names"; then
+             # Do each command in the postuninstall commands.
+             cmds=$postuninstall_cmds
+             save_ifs="$IFS"; IFS='~'
+             for cmd in $cmds; do
+               IFS="$save_ifs"
+               eval cmd=\"$cmd\"
+               $show "$cmd"
+               $run eval "$cmd"
+               if test "$?" -ne 0 && test "$rmforce" != yes; then
+                 exit_status=1
+               fi
+             done
+             IFS="$save_ifs"
+           fi
+
+           if test -n "$old_library"; then
+             # Do each command in the old_postuninstall commands.
+             cmds=$old_postuninstall_cmds
+             save_ifs="$IFS"; IFS='~'
+             for cmd in $cmds; do
+               IFS="$save_ifs"
+               eval cmd=\"$cmd\"
+               $show "$cmd"
+               $run eval "$cmd"
+               if test "$?" -ne 0 && test "$rmforce" != yes; then
+                 exit_status=1
+               fi
+             done
+             IFS="$save_ifs"
+           fi
+           # FIXME: should reinstall the best remaining shared library.
+           ;;
+         esac
+       fi
+       ;;
+
+      *.lo)
+       # Possibly a libtool object, so verify it.
+       if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+
+         # Read the .lo file
+         . $dir/$name
+
+         # Add PIC object to the list of files to remove.
+         if test -n "$pic_object" \
+            && test "$pic_object" != none; then
+           rmfiles="$rmfiles $dir/$pic_object"
+         fi
+
+         # Add non-PIC object to the list of files to remove.
+         if test -n "$non_pic_object" \
+            && test "$non_pic_object" != none; then
+           rmfiles="$rmfiles $dir/$non_pic_object"
+         fi
+       fi
+       ;;
+
+      *)
+       if test "$mode" = clean ; then
+         noexename=$name
+         case $file in
+         *.exe)
+           file=`$echo $file|${SED} 's,.exe$,,'`
+           noexename=`$echo $name|${SED} 's,.exe$,,'`
+           # $file with .exe has already been added to rmfiles,
+           # add $file without .exe
+           rmfiles="$rmfiles $file"
+           ;;
+         esac
+         # Do a test to see if this is a libtool program.
+         if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
+           relink_command=
+           . $dir/$noexename
+
+           # note $name still contains .exe if it was in $file originally
+           # as does the version of $file that was added into $rmfiles
+           rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
+           if test "$fast_install" = yes && test -n "$relink_command"; then
+             rmfiles="$rmfiles $objdir/lt-$name"
+           fi
+           if test "X$noexename" != "X$name" ; then
+             rmfiles="$rmfiles $objdir/lt-${noexename}.c"
+           fi
+         fi
+       fi
+       ;;
+      esac
+      $show "$rm $rmfiles"
+      $run $rm $rmfiles || exit_status=1
+    done
+    objdir="$origobjdir"
+
+    # Try to remove the ${objdir}s in the directories where we deleted files
+    for dir in $rmdirs; do
+      if test -d "$dir"; then
+       $show "rmdir $dir"
+       $run rmdir $dir >/dev/null 2>&1
+      fi
+    done
+
+    exit $exit_status
+    ;;
+
+  "")
+    $echo "$modename: you must specify a MODE" 1>&2
+    $echo "$generic_help" 1>&2
+    exit $EXIT_FAILURE
+    ;;
+  esac
+
+  if test -z "$exec_cmd"; then
+    $echo "$modename: invalid operation mode \`$mode'" 1>&2
+    $echo "$generic_help" 1>&2
+    exit $EXIT_FAILURE
+  fi
+fi # test -z "$show_help"
+
+if test -n "$exec_cmd"; then
+  eval exec $exec_cmd
+  exit $EXIT_FAILURE
+fi
+
+# We need to display help for each of the modes.
+case $mode in
+"") $echo \
+"Usage: $modename [OPTION]... [MODE-ARG]...
+
+Provide generalized library-building support services.
+
+    --config          show all configuration variables
+    --debug           enable verbose shell tracing
+-n, --dry-run         display commands without modifying any files
+    --features        display basic configuration information and exit
+    --finish          same as \`--mode=finish'
+    --help            display this help message and exit
+    --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
+    --quiet           same as \`--silent'
+    --silent          don't print informational messages
+    --tag=TAG         use configuration variables from tag TAG
+    --version         print version information
+
+MODE must be one of the following:
+
+      clean           remove files from the build directory
+      compile         compile a source file into a libtool object
+      execute         automatically set library path, then run a program
+      finish          complete the installation of libtool libraries
+      install         install libraries or executables
+      link            create a library or an executable
+      uninstall       remove libraries from an installed directory
+
+MODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
+a more detailed description of MODE.
+
+Report bugs to <bug-libtool@gnu.org>."
+  exit $EXIT_SUCCESS
+  ;;
+
+clean)
+  $echo \
+"Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
+
+Remove files from the build directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, object or program, all the files associated
+with it are deleted. Otherwise, only FILE itself is deleted using RM."
+  ;;
+
+compile)
+  $echo \
+"Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
+
+Compile a source file into a libtool library object.
+
+This mode accepts the following additional options:
+
+  -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
+  -prefer-pic       try to building PIC objects only
+  -prefer-non-pic   try to building non-PIC objects only
+  -static           always build a \`.o' file suitable for static linking
+
+COMPILE-COMMAND is a command to be used in creating a \`standard' object file
+from the given SOURCEFILE.
+
+The output file name is determined by removing the directory component from
+SOURCEFILE, then substituting the C source code suffix \`.c' with the
+library object suffix, \`.lo'."
+  ;;
+
+execute)
+  $echo \
+"Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
+
+Automatically set library path, then run a program.
+
+This mode accepts the following additional options:
+
+  -dlopen FILE      add the directory containing FILE to the library path
+
+This mode sets the library path environment variable according to \`-dlopen'
+flags.
+
+If any of the ARGS are libtool executable wrappers, then they are translated
+into their corresponding uninstalled binary, and any of their required library
+directories are added to the library path.
+
+Then, COMMAND is executed, with ARGS as arguments."
+  ;;
+
+finish)
+  $echo \
+"Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
+
+Complete the installation of libtool libraries.
+
+Each LIBDIR is a directory that contains libtool libraries.
+
+The commands that this mode executes may require superuser privileges.  Use
+the \`--dry-run' option if you just want to see what would be executed."
+  ;;
+
+install)
+  $echo \
+"Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
+
+Install executables or libraries.
+
+INSTALL-COMMAND is the installation command.  The first component should be
+either the \`install' or \`cp' program.
+
+The rest of the components are interpreted as arguments to that command (only
+BSD-compatible install options are recognized)."
+  ;;
+
+link)
+  $echo \
+"Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
+
+Link object files or libraries together to form another library, or to
+create an executable program.
+
+LINK-COMMAND is a command using the C compiler that you would use to create
+a program from several object files.
+
+The following components of LINK-COMMAND are treated specially:
+
+  -all-static       do not do any dynamic linking at all
+  -avoid-version    do not add a version suffix if possible
+  -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
+  -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
+  -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
+  -export-symbols SYMFILE
+                   try to export only the symbols listed in SYMFILE
+  -export-symbols-regex REGEX
+                   try to export only the symbols matching REGEX
+  -LLIBDIR          search LIBDIR for required installed libraries
+  -lNAME            OUTPUT-FILE requires the installed library libNAME
+  -module           build a library that can dlopened
+  -no-fast-install  disable the fast-install mode
+  -no-install       link a not-installable executable
+  -no-undefined     declare that a library does not refer to external symbols
+  -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
+  -objectlist FILE  Use a list of object files found in FILE to specify objects
+  -precious-files-regex REGEX
+                    don't remove output files matching REGEX
+  -release RELEASE  specify package release information
+  -rpath LIBDIR     the created library will eventually be installed in LIBDIR
+  -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
+  -static           do not do any dynamic linking of libtool libraries
+  -version-info CURRENT[:REVISION[:AGE]]
+                   specify library version info [each variable defaults to 0]
+
+All other options (arguments beginning with \`-') are ignored.
+
+Every other argument is treated as a filename.  Files ending in \`.la' are
+treated as uninstalled libtool libraries, other files are standard or library
+object files.
+
+If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
+only library objects (\`.lo' files) may be specified, and \`-rpath' is
+required, except when creating a convenience library.
+
+If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
+using \`ar' and \`ranlib', or on Windows using \`lib'.
+
+If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
+is created, otherwise an executable program is created."
+  ;;
+
+uninstall)
+  $echo \
+"Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
+
+Remove libraries from an installation directory.
+
+RM is the name of the program to use to delete files associated with each FILE
+(typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
+to RM.
+
+If FILE is a libtool library, all the files associated with it are deleted.
+Otherwise, only FILE itself is deleted using RM."
+  ;;
+
+*)
+  $echo "$modename: invalid operation mode \`$mode'" 1>&2
+  $echo "$help" 1>&2
+  exit $EXIT_FAILURE
+  ;;
+esac
+
+$echo
+$echo "Try \`$modename --help' for more information about other modes."
+
+exit $?
+
+# The TAGs below are defined such that we never get into a situation
+# in which we disable both kinds of libraries.  Given conflicting
+# choices, we go for a static library, that is the most portable,
+# since we can't tell whether shared libraries were disabled because
+# the user asked for that or because the platform doesn't support
+# them.  This is particularly important on AIX, because we don't
+# support having both static and shared libraries enabled at the same
+# time on that platform, so we default to a shared-only configuration.
+# If a disable-shared tag is given, we'll fallback to a static-only
+# configuration.  But we'll never go from static-only to shared-only.
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-shared
+disable_libs=shared
+# ### END LIBTOOL TAG CONFIG: disable-shared
+
+# ### BEGIN LIBTOOL TAG CONFIG: disable-static
+disable_libs=static
+# ### END LIBTOOL TAG CONFIG: disable-static
+
+# Local Variables:
+# mode:shell-script
+# sh-indentation:2
+# End:
diff --git a/sntp/main.c b/sntp/main.c
new file mode 100644 (file)
index 0000000..0cc4f03
--- /dev/null
@@ -0,0 +1,1735 @@
+/*  Copyright (C) 1996, 1997, 2000 N.M. Maclaren
+    Copyright (C) 1996, 1997, 2000 The University of Cambridge
+
+This is a complete SNTP implementation, which was easier to write than to port
+xntp to a new version of Unix with any hope of maintaining it thereafter.  It
+supports the full SNTP (RFC 2030) client- and server-side challenge-response
+and broadcast protocols.  It should achieve nearly optimal accuracy with very
+few transactions, provided only that a client has access to a trusted server
+and that communications are not INVARIABLY slow.  As this is the environment in
+which 90-99% of all NTP systems are run ....
+
+The specification of this program is:
+
+    sntp [ --help | -h | -? ] [ -v | -V | -W ]
+        [ -q [ -f savefile ] |
+            [ { -r | -a } [ -P prompt ] [ -l lockfile ] ]
+            [ -c count ] [ -e minerr ][ -E maxerr ]
+            [ -d delay | -x [ separation ] [ -f savefile ] ]
+            [ -4 | -6 ] [ address(es) ] ]
+
+    --help, -h and -? all print the syntax of the command.
+
+    -v indicates that diagnostic messages should be written to standard error,
+and -V requests more output for investigating apparently inconsistent
+timestamps.  -W requests very verbose debugging output, and will interfere with
+the timing when writing to the terminal (because of line buffered output from
+C); it is useful only when debugging the source.  Note that the times produced
+by -V and -W are the corrections needed, and not the error in the local clock.
+
+    -q indicates that it will query a savefile that is being maintained by
+it being run in daemon mode.
+
+     The default is that it should behave as a client, and the following options
+are then relevant:
+
+    -r indicates that the system clock should be reset by 'settimeofday'.
+Naturally, this will work only if the user has enough privilege.
+
+    -a indicates that the system clock should be reset by 'adjtime'.
+Naturally, this will work only if the user has enough privilege.
+
+    -x indicates that the program should run as a daemon (i.e. forever), and
+allow for clock drift.
+
+    -4 or -6 force dns resolving to ipv4 or ipv6 addresses.
+
+    The default is to write the current date and time to the standard output in
+a format like '1996 Oct 15 20:17:25.123 + 4.567 +/- 0.089 secs', indicating the
+estimated true (local) time and the error in the local clock.  In daemon mode,
+it will add drift information in a format like ' + 1.3 +/- 0.1 ppm', and
+display this at roughly 'separation' intervals.
+
+    'minerr' is the maximum ignorable variation between the clocks.  Acceptable
+values are from 0.001 to 1, and the default is 0.1 if 'address' is specified
+and 0.5 otherwise.
+
+    'maxerr' is the maximum value of various delays that are deemed acceptable.
+Acceptable values are from 1 to 60, and the default is 5.  It should sometimes
+be increased if there are problems with the network, NTP server or system
+clock, but take care.
+
+    'prompt' is the maximum clock change that will be made automatically.
+Acceptable values are from 1 to 3600, and the default is 30.  If the program is
+being run interactively, larger values will cause a prompt.  The value may also
+be 'no', and the change will be made without prompting.
+
+    'count' is the maximum number of NTP packets to require.  Acceptable values
+are from 1 to 25 if 'address' is specified and '-x' is not, and from 5 to 25
+otherwise; the default is 5.  If the maximum isn't enough, you need a better
+consistency algorithm than this program uses.  Don't increase it.
+
+    'delay' is a rough limit on the total running time in seconds.  Acceptable
+values are from 1 to 3600, and the default is 15 if 'address' is specified and
+300 otherwise.
+
+    'separation' is the time to wait between calls to the server in minutes if
+'address' is specified, and the minimum time between broadcast packets if not.
+Acceptable values are from 1 to 1440 (a day), and the default is 300.
+
+    'lockfile' may be used in an update mode to ensure that there is only
+one copy of sntp running at once.  The default is installation-dependent,
+but will usually be /etc/sntp.pid.
+
+    'savefile' may be used in daemon mode to store a record of previous
+packets, which may speed up recalculating the drift after sntp has to be
+restarted (e.g. because of network or server outages).  The default is
+installation-dependent, but will usually be /etc/sntp.state.  Note that
+there is no locking of this file, and using it twice may cause chaos.
+
+    'address' is the DNS name or IP number of a host to poll; if no name is
+given, the program waits for broadcasts.  Note that a single component numeric
+address is not allowed.
+
+For sanity, it is also required that 'minerr' < 'maxerr' < 'delay' (if
+listening for broadcasts, 'delay/count' and, in daemon mode, 'separation') and,
+for sordid Unixish reasons, that 2*'count' < 'delay'.  The last could be fixed,
+but isn't worth it.  Note that none of the above values are closely linked to
+the limits described in the NTP protocol (RFC 1305).  Do not increase the
+compiled-in bounds excessively, or the code will fail.
+
+The algorithm used to decide whether to accept a correction is whether it would
+seem to improve matters.  Unlike the 'xntp' suite, little attempt is made to
+handle really knotted scenarios, and diagnostics are written to standard error.
+In non-daemon client mode, it is intended to be run as a command or in a 'cron'
+job.  Unlike 'ntpdate', its default mode is simply to display the clock error.
+
+It assumes that floating-point arithmetic is tolerably efficient, which is true
+for even the cheapest personal computer nowadays.  If, however, you want to
+port this to a toaster, you may have problems!
+
+In its terminating modes, its return code is EXIT_SUCCESS if the operation was
+completed successfully and EXIT_FAILURE otherwise.
+
+In daemon mode, it runs for ever and stops with a return code EXIT_FAILURE
+only after a severe error.  In daemon mode, it will fail if the server is
+inaccessible for a long time or seriously sick, and will need manual
+restarting.
+
+
+WARNING: this program has reached its 'hack count' and needs restructuring,
+badly.  Perhaps the worst code is in run_daemon().  You are advised not to
+fiddle unless you really have to. */
+
+
+
+#include "header.h"
+
+#include <limits.h>
+#include <float.h>
+#include <math.h>
+
+#define MAIN
+#include "kludges.h"
+#undef MAIN
+
+
+
+/* NTP definitions.  Note that these assume 8-bit bytes - sigh.  There is
+little point in parameterising everything, as it is neither feasible nor
+useful.  It would be very useful if more fields could be defined as
+unspecified.  The NTP packet-handling routines contain a lot of extra
+assumptions. */
+
+#define JAN_1970   2208988800.0        /* 1970 - 1900 in seconds */
+#define NTP_SCALE  4294967296.0        /* 2^32, of course! */
+
+#define NTP_PACKET_MIN       48        /* Without authentication */
+#define NTP_PACKET_MAX       68        /* With authentication (ignored) */
+#define NTP_DISP_FIELD        8        /* Offset of dispersion field */
+#define NTP_REFERENCE        16        /* Offset of reference timestamp */
+#define NTP_ORIGINATE        24        /* Offset of originate timestamp */
+#define NTP_RECEIVE          32        /* Offset of receive timestamp */
+#define NTP_TRANSMIT         40        /* Offset of transmit timestamp */
+
+#define NTP_LI_FUDGE          0        /* The current 'status' */
+#define NTP_VERSION           3        /* The current version */
+#define NTP_VERSION_MAX       4        /* The maximum valid version */
+#define NTP_STRATUM          15        /* The current stratum as a server */
+#define NTP_STRATUM_MAX      15        /* The maximum valid stratum */
+#define NTP_POLLING           8        /* The current 'polling interval' */
+#define NTP_PRECISION         0        /* The current 'precision' - 1 sec. */
+
+#define NTP_ACTIVE            1        /* NTP symmetric active request */
+#define NTP_PASSIVE           2        /* NTP symmetric passive response */
+#define NTP_CLIENT            3        /* NTP client request */
+#define NTP_SERVER            4        /* NTP server response */
+#define NTP_BROADCAST         5        /* NTP server broadcast */
+
+#define NTP_INSANITY     3600.0        /* Errors beyond this are hopeless */
+#define RESET_MIN            15        /* Minimum period between resets */
+#define ABSCISSA            3.0        /* Scale factor for standard errors */
+
+
+
+/* Local definitions and global variables (mostly options).  These are all of
+the quantities that control the main actions of the program.  The first three 
+are the only ones that are exported to other modules. */
+
+const char *argv0 = NULL;              /* For diagnostics only - not NULL */
+int verbose = 0,                       /* Default = 0, -v = 1, -V = 2, -W = 3 */
+    operation = 0;                     /* Defined in header.h - see action */
+const char *lockname = NULL;           /* The name of the lock file */
+int unprivport = 0;                    /* Use an unpriv port for query? */
+
+#define COUNT_MAX          25          /* Do NOT increase this! */
+#define WEEBLE_FACTOR     1.2          /* See run_server() and run_daemon() */
+#define ETHERNET_MAX        5          /* See run_daemon() and run_client() */
+
+#define action_display      1          /* Just display the result */
+#define action_reset        2          /* Reset using 'settimeofday' */
+#define action_adjust       3          /* Reset using 'adjtime' */
+#define action_broadcast    4          /* Behave as a server, broadcasting */
+#define action_server       5          /* Behave as a server for clients */
+#define action_query        6          /* Query a daemon savefile */
+
+#define save_read_only      1          /* Read the saved state only */
+#define save_read_check     2          /* Read and check it */
+#define save_write          3          /* Write the saved state */
+#define save_clear          4          /* Clear the saved state */
+
+static const char version[] = VERSION; /* For reverse engineering :-) */
+static int action = 0,                 /* Defined above - see operation */
+    count = 0,                         /* -c value in seconds */
+    delay = 0,                         /* -d or -x value in seconds */
+    attempts = 0,                      /* Packets transmitted up to 2*count */
+    waiting = 0,                       /* -d/-c except for in daemon mode */
+    locked = 0;                        /* set_lock(1) has been called */
+static double outgoing[2*COUNT_MAX],   /* Transmission timestamps */
+    minerr = 0.0,                      /* -e value in seconds */
+    maxerr = 0.0,                      /* -E value in seconds */
+    prompt = 0.0,                      /* -p value in seconds */
+    dispersion = 0.0;                  /* The source dispersion in seconds */
+static FILE *savefile = NULL;          /* Holds the data to restart from */
+
+
+
+/* The unpacked NTP data structure, with all the fields even remotely relevant
+to SNTP. */
+
+typedef struct NTP_DATA {
+    unsigned char status, version, mode, stratum, polling;
+    signed char precision;
+    double dispersion, reference, originate, receive, transmit, current;
+} ntp_data;
+
+
+
+/* The following structure is used to keep a record of packets in daemon mode;
+it contains only the information that is actually used for the drift and error
+calculations. */
+
+typedef struct {
+    double dispersion, weight, when, offset, error;
+} data_record;
+
+void syntax(int);
+void display_data(ntp_data *);
+void display_packet(unsigned char *, int);
+void pack_ntp(unsigned char *, int, ntp_data *);
+void unpack_ntp(ntp_data *, unsigned char *, int);
+void make_packet(ntp_data *, int);
+int read_packet(int, ntp_data *, double *, double *);
+void format_time(char *, int, double, double, double, double, int);
+double reset_clock(double, double, int);
+void run_server(void);
+double estimate_stats(int *, int *, data_record *, double, double *, double *,
+       double *, double *, double *, double *, int *, int);
+double correct_drift(double *, double *, double);
+void handle_saving(int, int *, int *, int *, data_record *, double *,
+       double *, double *);
+void query_savefile(void);
+void run_daemon(char **, int, int);
+void run_client(char **, int);
+
+void fatal (int syserr, const char *message, const char *insert) {
+
+/* Issue a diagnostic and stop.  Be a little paranoid about recursion. */
+
+    int k = errno;
+    static int called = 0;
+
+    if (message != NULL) {
+        fprintf(stderr,"%s: ",argv0);
+        fprintf(stderr,message,insert);
+        fprintf(stderr,"\n");
+    }
+    errno = k;
+    if (syserr) perror(argv0);
+    if (! called) {
+        called = 1;
+        if (savefile != NULL && fclose(savefile))
+            fatal(1,"unable to close the daemon save file",NULL);
+        if (locked) set_lock(0);
+    }
+    exit(EXIT_FAILURE);
+}
+
+
+
+void syntax (int halt) {
+
+/* The standard, unfriendly Unix error message.  Some errors are diagnosed more
+helpfully.  This is called before any files or sockets are opened. */
+
+    fprintf(stderr,"Syntax: %s [ --help | -h | -? ] [ -v | -V | -W ] \n",argv0);
+    fprintf(stderr,"    [ -q [ -f savefile ] |\n");
+    fprintf(stderr,"        [ { -r | -a } [ -P prompt ] [ -l lockfile ] ]\n");
+    fprintf(stderr,"            [ -c count ] [ -e minerr ] [ -E maxerr ]\n");
+    fprintf(stderr,"            [ -d delay | -x [ separation ] ");
+    fprintf(stderr,"[ -f savefile ] ]\n");
+    fprintf(stderr,"        [ -4 | -6 ] [-u] [ address(es) ] ]\n");
+    if (halt) exit(EXIT_FAILURE);
+}
+
+
+
+void display_data (ntp_data *data) {
+
+/* This formats the essential NTP data, as a debugging aid. */
+
+    fprintf(stderr,"sta=%d ver=%d mod=%d str=%d pol=%d dis=%.6f ref=%.6f\n",
+        data->status,data->version,data->mode,data->stratum,data->polling,
+        data->dispersion,data->reference);
+    fprintf(stderr,"ori=%.6f rec=%.6f\n",data->originate,data->receive);
+    fprintf(stderr,"tra=%.6f cur=%.6f\n",data->transmit,data->current);
+}
+
+
+
+void display_packet (unsigned char *packet, int length) {
+
+/* This formats a possible packet very roughly, as a debugging aid. */
+
+    int i;
+
+    if (length < NTP_PACKET_MIN || length > NTP_PACKET_MAX) return;
+    for (i = 0; i < length; ++i) {
+        if (i != 0 && i%32 == 0)
+            fprintf(stderr,"\n");
+         else if (i != 0 && i%4 == 0)
+             fprintf(stderr," ");
+         fprintf(stderr,"%.2x",packet[i]);
+    }
+    fprintf(stderr,"\n");
+}
+
+
+
+void pack_ntp (unsigned char *packet, int length, ntp_data *data) {
+
+/* Pack the essential data into an NTP packet, bypassing struct layout and
+endian problems.  Note that it ignores fields irrelevant to SNTP. */
+
+    int i, k;
+    double d;
+
+    memset(packet,0,(size_t)length);
+    packet[0] = (data->status<<6)|(data->version<<3)|data->mode;
+    packet[1] = data->stratum;
+    packet[2] = data->polling;
+    packet[3] = data->precision;
+    d = data->originate/NTP_SCALE;
+    for (i = 0; i < 8; ++i) {
+        if ((k = (int)(d *= 256.0)) >= 256) k = 255;
+        packet[NTP_ORIGINATE+i] = k;
+        d -= k;
+    }
+    d = data->receive/NTP_SCALE;
+    for (i = 0; i < 8; ++i) {
+        if ((k = (int)(d *= 256.0)) >= 256) k = 255;
+        packet[NTP_RECEIVE+i] = k;
+        d -= k;
+    }
+    d = data->transmit/NTP_SCALE;
+    for (i = 0; i < 8; ++i) {
+        if ((k = (int)(d *= 256.0)) >= 256) k = 255;
+        packet[NTP_TRANSMIT+i] = k;
+        d -= k;
+    }
+}
+
+
+
+void unpack_ntp (ntp_data *data, unsigned char *packet, int length) {
+
+/* Unpack the essential data from an NTP packet, bypassing struct layout and
+endian problems.  Note that it ignores fields irrelevant to SNTP. */
+
+    int i;
+    double d;
+
+    data->current = current_time(JAN_1970);    /* Best to come first */
+    data->status = (packet[0] >> 6);
+    data->version = (packet[0] >> 3)&0x07;
+    data->mode = packet[0]&0x07;
+    data->stratum = packet[1];
+    data->polling = packet[2];
+    data->precision = packet[3];
+    d = 0.0;
+    for (i = 0; i < 4; ++i) d = 256.0*d+packet[NTP_DISP_FIELD+i];
+    data->dispersion = d/65536.0;
+    d = 0.0;
+    for (i = 0; i < 8; ++i) d = 256.0*d+packet[NTP_REFERENCE+i];
+    data->reference = d/NTP_SCALE;
+    d = 0.0;
+    for (i = 0; i < 8; ++i) d = 256.0*d+packet[NTP_ORIGINATE+i];
+    data->originate = d/NTP_SCALE;
+    d = 0.0;
+    for (i = 0; i < 8; ++i) d = 256.0*d+packet[NTP_RECEIVE+i];
+    data->receive = d/NTP_SCALE;
+    d = 0.0;
+    for (i = 0; i < 8; ++i) d = 256.0*d+packet[NTP_TRANSMIT+i];
+    data->transmit = d/NTP_SCALE;
+}
+
+
+
+void make_packet (ntp_data *data, int mode) {
+
+/* Create an outgoing NTP packet, either from scratch or starting from a
+request from a client.  Note that it implements the NTP specification, even
+when this is clearly misguided, except possibly for the setting of LI.  It
+would be easy enough to add a sanity flag, but I am not in the business of
+designing an alternative protocol (however much better it might be). */
+
+    data->status = NTP_LI_FUDGE<<6;
+    data->stratum = NTP_STRATUM;
+    data->reference = data->dispersion = 0.0;
+    if (mode == NTP_SERVER) {
+        data->mode = (data->mode == NTP_CLIENT ? NTP_SERVER : NTP_PASSIVE);
+        data->originate = data->transmit;
+        data->receive = data->current;
+    } else {
+        data->version = NTP_VERSION;
+        data->mode = mode;
+        data->polling = NTP_POLLING;
+        data->precision = NTP_PRECISION;
+        data->receive = data->originate = 0.0;
+    }
+    data->current = data->transmit = current_time(JAN_1970);
+}
+
+
+
+int read_packet (int which, ntp_data *data, double *off, double *err) {
+
+/* Check the packet and work out the offset and optionally the error.  Note
+that this contains more checking than xntp does.  This returns 0 for success, 1
+for failure and 2 for an ignored broadcast packet (a kludge for servers).  Note
+that it must not change its arguments if it fails. */
+
+    unsigned char receive[NTP_PACKET_MAX+1];
+    double delay1, delay2, x, y;
+    int response = 0, failed, length, i, k;
+
+/* Read the packet and deal with diagnostics. */
+
+    if ((length = read_socket(which,receive,NTP_PACKET_MAX+1,waiting)) <= 0)
+        return 1;
+    if (length < NTP_PACKET_MIN || length > NTP_PACKET_MAX) {
+        if (verbose)
+            fprintf(stderr,"%s: bad length %d for NTP packet on socket %d\n",
+                argv0,length,which);
+        return 1;
+    }
+    if (verbose > 2) {
+        fprintf(stderr,"Incoming packet on socket %d:\n",which);
+        display_packet(receive,length);
+    }
+    unpack_ntp(data,receive,length);
+    if (verbose > 2) display_data(data);
+
+/* Start by checking that the packet looks reasonable.  Be a little paranoid,
+but allow for version 1 semantics and sick clients. */
+
+    if (operation == op_listen)
+        failed = (data->mode != NTP_BROADCAST);
+    else {
+        failed = (data->mode != NTP_SERVER && data->mode != NTP_PASSIVE);
+        response = 1;
+    }
+    if (failed || data->status == 3 || data->version < 1 ||
+            data->version > NTP_VERSION_MAX ||
+            data->stratum > NTP_STRATUM_MAX) {
+        if (verbose)
+            fprintf(stderr,
+                "%s: Unusable NTP packet rejected on socket %d (f=%d, status %d, version %d, stratum %d)\n",
+                argv0, which,
+               failed, data->status, data->version, data->stratum);
+        return 1;
+    }
+
+/* Note that the conventions are very poorly defined in the NTP protocol, so we
+have to guess.  Any full NTP server perpetrating completely unsynchronised
+packets is an abomination, anyway, so reject it. */
+
+    delay1 = data->transmit-data->receive;
+    delay2 = data->current-data->originate;
+    failed = (
+             (  data->stratum != 0
+             /* && data->stratum != NTP_STRATUM_MAX */
+             && data->reference == 0.0
+             )
+            || data->transmit == 0.0
+            );
+    if (response &&
+            (data->originate == 0.0 || data->receive == 0.0 ||
+                (data->reference != 0.0 && data->receive < data->reference) ||
+                delay1 < 0.0 || delay1 > NTP_INSANITY || delay2 < 0.0 ||
+                data->dispersion > NTP_INSANITY))
+        failed = 1;
+    if (failed) {
+        if (verbose)
+            fprintf(stderr,
+                "%s: incomprehensible NTP packet rejected on socket %d\n",
+                argv0,which);
+        return 1;
+    }
+    if (data->stratum == NTP_STRATUM_MAX) {
+       fprintf(stderr,
+           "%s: unsynch NTP response on socket %d\n",
+           argv0,which);
+        return 1;
+    }
+
+/* If it is a response, check that it corresponds to one of our requests and
+has got here in a reasonable length of time. */
+
+    if (response) {
+        k = 0;
+        for (i = 0; i < attempts; ++i)
+            if (data->originate == outgoing[i]) {
+                outgoing[i] = 0.0;
+                ++k;
+            }
+        if (k != 1 || delay2 > NTP_INSANITY) {
+            if (verbose)
+                fprintf(stderr,
+                    "%s: bad response from NTP server rejected on socket %d\n",
+                    argv0,which);
+            return 1;
+        }
+    }
+
+/* Now return the time information.  If it is a server response, it contains
+enough information that we can be almost certain that we have not been fooled
+too badly.  Heaven help us with broadcasts - make a wild kludge here, and see
+elsewhere for other kludges. */
+
+    if (dispersion < data->dispersion) dispersion = data->dispersion;
+    if (operation == op_listen) {
+        *off = data->transmit-data->current;
+        *err = NTP_INSANITY;
+    } else {
+        x = data->receive-data->originate;
+        y = (data->transmit == 0.0 ? 0.0 : data->transmit-data->current);
+        *off = 0.5*(x+y);
+        *err = x-y;
+        x = data->current-data->originate;
+        if (0.5*x > *err) *err = 0.5*x;
+    }
+    return 0;
+}
+
+
+
+void format_time (char *text, int length, double offset, double error,
+    double drift, double drifterr, int precision) {
+
+/* Format the current time into a string, with the extra information as
+requested.  Note that the rest of the program uses the correction needed, which
+is what is printed for diagnostics, but this formats the error in the local
+system for display to users.  So the results from this are the negation of
+those printed by the verbose options. */
+
+    int milli, len;
+    time_t now;
+    struct tm *gmt;
+    static const char *months[] = {
+        "Jan", "Feb", "Mar", "Apr", "May", "Jun",
+        "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+    };
+
+/* Work out and format the current local time.  Note that some semi-ANSI
+systems do not set the return value from (s)printf. */
+
+    now = convert_time(current_time(offset),&milli);
+    errno = 0;
+    if ((gmt = localtime(&now)) == NULL)
+        fatal(1,"unable to work out local time",NULL);
+    len = 21;
+    if (length <= len) fatal(0,"internal error calling format_time",NULL);
+    errno = 0;
+    precision /= -3;
+    len += precision;
+    sprintf(text,"%.4d %s %.2d %.2d:%.2d:%.2d.%.*d",
+            gmt->tm_year+1900,months[gmt->tm_mon],gmt->tm_mday,
+            gmt->tm_hour,gmt->tm_min,gmt->tm_sec,precision,milli);
+    if (strlen(text) != len)
+        fatal(1,"unable to format current local time",NULL);
+
+/* Append the information about the offset, if requested. */
+
+    if (error >= 0.0) {
+        if (length < len+30)
+            fatal(0,"internal error calling format_time",NULL);
+        errno = 0;
+        sprintf(&text[len]," %c %.*f +/- %.*f secs",(offset > 0.0 ? '-' : '+'),
+               precision,(offset > 0.0 ? offset : -offset),
+               precision,dispersion+error);
+        if (strlen(&text[len]) < 22)
+            fatal(1,"unable to format clock correction",NULL);
+    }
+
+/* Append the information about the drift, if requested. */
+
+    if (drifterr >= 0.0) {
+        len = strlen(text);
+        if (length < len+25)
+            fatal(0,"internal error calling format_time",NULL);
+        errno = 0;
+        sprintf(&text[len]," %c %.1f +/- %.1f ppm",
+                (drift > 0.0 ? '-' : '+'),1.0e6*fabs(drift),
+                1.0e6*drifterr);
+        if (strlen(&text[len]) < 17)
+            fatal(1,"unable to format clock correction",NULL);
+    }
+
+/* It would be better to check for field overflow, but it is a lot of code to
+trap extremely implausible scenarios.  This will usually stop chaos from
+spreading. */
+
+    if (strlen(text) >= length)
+        fatal(0,"internal error calling format_time",NULL);
+}
+
+
+
+double reset_clock (double offset, double error, int daemon) {
+
+/* Reset the clock, if appropriate, and return the correction actually used.
+This contains most of the checking for whether changes are worthwhile, except
+in daemon mode. */
+
+    double absoff = (offset < 0 ? -offset : offset);
+    char text[50];
+
+/* If the correction is large, ask for confirmation before proceeding. */
+
+    if (absoff > prompt) {
+        if (! daemon && ftty(stdin) && ftty(stdout)) {
+            printf("The time correction is %.3f +/- %.3f+%.3f seconds\n",
+                offset,dispersion,error);
+            printf("Do you want to correct the time anyway? ");
+            fflush(stdout);
+            if (toupper(getchar()) != 'Y') {
+                printf("OK - quitting\n");
+                fatal(0,NULL,NULL);
+            }
+        } else {
+            sprintf(text,"%.3f +/- %.3f+%.3f",offset,dispersion,error);
+            fatal(0,"time correction too large: %s seconds",text);
+        }
+    }
+
+/* See if the correction is reasonably reliable and worth making. */
+
+    if (absoff < (daemon ? 0.5 : 1.0)*minerr) {
+        if (daemon ? verbose > 1 : verbose)
+            fprintf(stderr,"%s: correction %.3f +/- %.3f+%.3f secs - ignored\n",
+                argv0,offset,dispersion,error);
+        return 0.0;
+    } else if (absoff < 2.0*error) {
+        if (daemon ? verbose > 1 : verbose)
+            fprintf(stderr,
+                "%s: correction %.3f +/- %.3f+%.3f secs - suppressed\n",
+                argv0,offset,dispersion,error);
+        return 0.0;
+    }
+
+/* Make the correction.  Provide some protection against the previous
+correction not having completed, but it will rarely help much. */
+
+    adjust_time(offset,(action == action_reset ? 1 : 0),
+        (daemon ? 2.0*minerr : 0.0));
+    if (daemon ? verbose > 1 : verbose) {
+        format_time(text,50,0.0,-1.0,0.0,-1.0,-10);
+        fprintf(stderr,
+            "%s: time changed by %.3f secs to %s +/- %.3f+%.3f\n",
+            argv0,offset,text,dispersion,error);
+    }
+    return offset;
+}
+
+
+double estimate_stats (int *a_total, int *a_index, data_record *record,
+    double correction, double *a_disp, double *a_when, double *a_offset,
+    double *a_error, double *a_drift, double *a_drifterr, int *a_wait,
+    int update) {
+
+/* This updates the running statistics and returns the best estimate of what to
+do now.  It returns the timestamp relevant to the correction.  If broadcasts
+are rare and the drift is large, it will fail - you should then use a better
+synchronisation method.  It will also fail if something goes severely wrong
+(e.g. if the local clock is reset by another process or the transmission errors
+are beyond reason).
+
+There is a kludge for synchronisation loss during down time.  If it detects
+this, it will update only the history data and return zero; this is then
+handled specially in run_daemon().  While it could correct the offset, this
+might not always be the right thing to do. */
+
+    double weight, disp, when, offset, error, drift, drifterr,
+        now, e, w, x, y, z;
+    int total = *a_total, index = *a_index, wait = *a_wait, i;
+    char text[50];
+/* Correct the previous data and store a new entry in the circular buffer. */
+
+    for (i = 0; i < total; ++i) {
+        record[i].when += correction;
+        record[i].offset -= correction;
+    }
+    if (update) {
+        record[index].dispersion = *a_disp;
+        record[index].when = *a_when;
+        record[index].offset = *a_offset;
+        if (verbose > 1)
+            fprintf(stderr,"%s: corr=%.3f when=%.3f disp=%.3f off=%.3f",
+                argv0,correction,*a_when,*a_disp,*a_offset); /* See below */
+        if (operation == op_listen) {
+            if (verbose > 1) fprintf(stderr,"\n");
+            record[index].error = minerr;
+            record[index].weight = 1.0;
+        } else {
+            if (verbose > 1) fprintf(stderr," err=%.3f\n",*a_error);
+            record[index].error = x = *a_error;
+            record[index].weight = 1.0/(x > minerr ? x*x : minerr*minerr);
+        }
+        if (++index >= count) index = 0;
+        *a_index = index;
+        if (++total > count) total = count;
+        *a_total = total;
+        if (verbose > 2)
+            fprintf(stderr,"corr=%.6f tot=%d ind=%d\n",correction,total,index);
+    }
+
+/* If there is insufficient data yet, use the latest estimates and return
+forthwith.  Note that this will not work for broadcasts, but they will be
+disabled in run_daemon(). */
+
+    if ((operation == op_listen && total < count && update) || total < 3) {
+        *a_drift = 0.0;
+        *a_drifterr = -1.0;
+        *a_wait = delay;
+        return *a_when;
+    }
+
+/* Work out the average time, offset, error etc.  Note that the dispersion is
+not subject to the central limit theorem.  Unfortunately, the variation in the
+source's dispersion is our only indication of how consistent its clock is. */
+
+    disp = weight = when = offset = y = 0.0;
+    for (i = 0; i < total; ++i) {
+        weight += w = record[i].weight;
+        when += w*record[i].when;
+        offset += w*record[i].offset;
+        y += w*record[i].dispersion;
+        if (disp < record[i].dispersion)
+            disp = record[i].dispersion;
+    }
+    when /= weight;
+    offset /= weight;
+    y /= weight;
+    if (verbose > 2)
+        fprintf(stderr,"disp=%.6f wgt=%.3f when=%.6f off=%.6f\n",
+            disp,weight,when,offset);
+
+/* If there is enough data, estimate the drift and errors by regression.  Note
+that it is essential to calculate the mean square error, not the mean error. */
+
+    error = drift = x = z = 0.0;
+    for (i = 0; i < total; ++i) {
+        w = record[i].weight/weight;
+        x += w*(record[i].when-when)*(record[i].when-when);
+        drift += w*(record[i].when-when)*(record[i].offset-offset);
+        z += w*(record[i].offset-offset)*(record[i].offset-offset);
+        error += w*record[i].error*record[i].error+
+            2.0*w*(record[i].dispersion-y)*(record[i].dispersion-y);
+    }
+    if (verbose > 2)
+        fprintf(stderr,"X2=%.3f XY=%.6f Y2=%.9f E2=%.9f ",x,drift,z,error);
+
+/* When calculating the errors, add some paranoia mainly to check for coding
+errors and complete lunacy, attempting to retry if at all possible.  Because
+glitches at this point are so common, log a reset even in non-verbose mode.
+There will be more thorough checks later.  Note that we cannot usefully check
+the error for broadcasts. */
+
+    z -= drift*drift/x;
+    if (verbose > 2) fprintf(stderr,"S2=%.9f\n",z);
+    if (! update) {
+        if (z > 1.0e6)
+            fatal(0,"stored data too unreliable for time estimation",NULL);
+    } else if (operation == op_client) {
+        e = error+disp*disp+minerr*minerr;
+        if (z > e) {
+            if (verbose || z >= maxerr*maxerr)
+                fprintf(stderr,
+                    "%s: excessively high error %.3f > %.3f > %.3f\n",
+                    argv0,sqrt(z),sqrt(e),sqrt(error));
+            if (total <= 1)
+                return 0.0;
+            else if (z < maxerr*maxerr) {
+                sprintf(text,"resetting on error %.3g > %.3g",
+                    sqrt(z),sqrt(e));
+                log_message(text);
+                return 0.0;
+            } else
+                fatal(0,"incompatible (i.e. erroneous) timestamps",NULL);
+        } else if (z > error && verbose)
+            fprintf(stderr,
+                "%s: anomalously high error %.3f > %.3f, but < %.3f\n",
+                argv0,sqrt(z),sqrt(error),sqrt(e));
+    } else {
+        if (z > maxerr*maxerr)
+            fatal(0,"broadcasts too unreliable for time estimation",NULL);
+    }
+    drift /= x;
+    drifterr = ABSCISSA*sqrt(z/(x*total));
+    error = (operation == op_listen ? minerr : 0.0)+ABSCISSA*sqrt(z/total);
+    if (verbose > 2)
+        fprintf(stderr,"err=%.6f drift=%.6f+/-%.6f\n",error,drift,drifterr);
+    if (error+drifterr*delay > NTP_INSANITY)
+        fatal(0,"unable to get a reasonable drift estimate",NULL);
+
+/* Estimate the optimal short-loop period, checking it carefully.  Remember to
+check that this whole process is likely to be accurate enough and that the
+delay function may be inaccurate. */
+
+    wait = delay;
+    x = (drift < 0.0 ? -drift : drift);
+    if (x*delay < 0.5*minerr) {
+        if (verbose > 2) fprintf(stderr,"Drift too small to correct\n");
+    } else if (x < 2.0*drifterr) {
+        if (verbose > 2)
+            fprintf(stderr,"Drift correction suppressed\n");
+    } else {
+        if ((z = drifterr*delay) < 0.5*minerr) z = 0.5*minerr;
+        wait = (x < z/delay ? delay : (int)(z/x+0.5));
+        wait = (int)(delay/(int)(delay/(double)wait+0.999)+0.999);
+        if (wait > delay)
+            fatal(0,"internal error in drift calculation",NULL);
+        if (update && (drift*wait > maxerr || wait < RESET_MIN)) {
+            sprintf(text,"%.6f+/-%.6f",drift,drifterr);
+            fatal(0,"drift correction too large: %s",text);
+        }
+    }
+    if (wait < *a_wait/2) wait = *a_wait/2;
+    if (wait > *a_wait*2) wait = *a_wait*2;
+
+/* Now work out what the correction should be, as distinct from what it should
+have been, remembering that older times are less certain. */
+
+    now = current_time(JAN_1970);
+    x = now-when;
+    offset += x*drift;
+    error += x*drifterr;
+    for (i = 0; i < total; ++i) {
+        x = now-record[i].when;
+        z = record[i].error+x*drifterr;
+        if (z < error) {
+            when = record[i].when;
+            offset = record[i].offset+x*drift;
+            error = z;
+        }
+    }
+    if (verbose > 2)
+        fprintf(stderr,"now=%.6f when=%.6f off=%.6f err=%.6f wait=%d\n",
+            now,when,offset,error,wait);
+
+/* Finally, return the result. */
+
+    *a_disp = disp;
+    *a_when = when;
+    *a_offset = offset;
+    *a_error = error;
+    *a_drift = drift;
+    *a_drifterr = drifterr;
+    *a_wait = wait;
+    return now;
+}
+
+
+
+double correct_drift (double *a_when, double *a_offset, double drift) {
+
+/* Correct for the drift since the last time it was done, provided that a long
+enough time has elapsed.  And do remember to kludge up the time and
+discrepancy, when appropriate. */
+
+    double d, x;
+
+    d = current_time(JAN_1970)-*a_when;
+    *a_when += d;
+    x = *a_offset+d*drift;
+    if (verbose > 2)
+        fprintf(stderr,"Correction %.6f @ %.6f off=%.6f ",x,*a_when,*a_offset);
+    if (d >= waiting && (x < 0.0 ? -x : x) >= 0.5*minerr) {
+        if (verbose > 2) fprintf(stderr,"performed\n");
+        adjust_time(x,(action == action_reset ? 1 : 0),0.5*minerr);
+        *a_offset = 0.0;
+        return x;
+    } else {
+        if (verbose > 2) fprintf(stderr,"ignored\n");
+        *a_offset = x;
+        return 0.0;
+    }
+}
+
+
+
+void handle_saving (int operation, int *total, int *index, int *cycle,
+    data_record *record, double *previous, double *when, double *correction) {
+
+/* This handles the saving and restoring of the state to a file.  While it is
+subject to spoofing, this is not a major security problem.  But, out of general
+paranoia, check everything in sight when restoring.  Note that this function
+has no external effect if something goes wrong. */
+
+    struct {
+        data_record record[COUNT_MAX];
+        double previous, when, correction;
+        int operation, delay, count, total, index, cycle, waiting;
+    } buffer;
+    double x, y;
+    int i, j;
+
+    if (savefile == NULL) return;
+
+/* Read the restart file and print its data in diagnostic mode.  Note that some
+care is necessary to avoid introducing a security exposure - but we trust the
+C library not to trash the stack on bad numbers! */
+
+    if (operation == save_read_only || operation == save_read_check) {
+        if (fread(&buffer,sizeof(buffer),1,savefile) != 1 || ferror(savefile)) {
+            if (ferror(savefile))
+                fatal(1,"unable to read record from daemon save file",NULL);
+            else if (verbose)
+                fprintf(stderr,"%s: bad daemon restart information\n",argv0);
+            return;
+        }
+        if (verbose > 2) {
+            fprintf(stderr,"Reading prev=%.6f when=%.6f corr=%.6f\n",
+                buffer.previous,buffer.when,buffer.correction);
+            fprintf(stderr,"op=%d dly=%d cnt=%d tot=%d ind=%d cyc=%d wait=%d\n",
+                buffer.operation,buffer.delay,buffer.count,buffer.total,
+                buffer.index,buffer.cycle,buffer.waiting);
+            if (buffer.total < COUNT_MAX)
+                for (i = 0; i < buffer.total; ++i)
+                    fprintf(stderr,
+                        "disp=%.6f wgt=%.3f when=%.6f off=%.6f err=%.6f\n",
+                        buffer.record[i].dispersion,buffer.record[i].weight,
+                        buffer.record[i].when,buffer.record[i].offset,
+                        buffer.record[i].error);
+        }
+
+
+/* Start checking the data for sanity. */
+
+        if (buffer.operation == 0 && buffer.delay == 0 && buffer.count == 0) {
+            if (operation < 0)
+                fatal(0,"the daemon save file has been cleared",NULL);
+            if (verbose)
+                fprintf(stderr,"%s: restarting from a cleared file\n",argv0);
+            return;
+        }
+        if (operation == save_read_check) {
+            if (buffer.operation != operation || buffer.delay != delay ||
+                    buffer.count != count) {
+                if (verbose)
+                    fprintf(stderr,"%s: different parameters for restart\n",
+                        argv0);
+                return;
+            }
+            if (buffer.total < 1 || buffer.total > count || buffer.index < 0 ||
+                    buffer.index >= count || buffer.cycle < 0 ||
+                    buffer.cycle >= count || buffer.correction < -maxerr ||
+                    buffer.correction > maxerr || buffer.waiting < RESET_MIN ||
+                    buffer.waiting > delay || buffer.previous > buffer.when ||
+                    buffer.previous < buffer.when-count*delay ||
+                    buffer.when >= *when) {
+                if (verbose)
+                    fprintf(stderr,"%s: corrupted restart information\n",argv0);
+                return;
+            }
+
+/* Checking the record is even more tedious. */
+
+            x = *when;
+            y = 0.0;
+            for (i = 0; i < buffer.total; ++i) {
+                if (buffer.record[i].dispersion < 0.0 ||
+                        buffer.record[i].dispersion > maxerr ||
+                        buffer.record[i].weight <= 0.0 ||
+                        buffer.record[i].weight > 1.001/(minerr*minerr) ||
+                        buffer.record[i].offset < -count*maxerr ||
+                        buffer.record[i].offset > count*maxerr ||
+                        buffer.record[i].error < 0.0 ||
+                        buffer.record[i].error > maxerr) {
+                    if (verbose)
+                        fprintf(stderr,"%s: corrupted restart record\n",argv0);
+                    return;
+                }
+                if (buffer.record[i].when < x) x = buffer.record[i].when;
+                if (buffer.record[i].when > y) y = buffer.record[i].when;
+            }
+
+/* Check for consistency and, finally, whether this is too old. */
+
+            if (y > buffer.when || y-x < (buffer.total-1)*delay ||
+                    y-x > (buffer.total-1)*count*delay) {
+                if (verbose)
+                    fprintf(stderr,"%s: corrupted restart times\n",argv0);
+                return;
+            }
+            if (buffer.when < *when-count*delay) {
+                if (verbose)
+                    fprintf(stderr,"%s: restart information too old\n",argv0);
+                return;
+            }
+        }
+
+/* If we get here, just copy the data back. */
+
+        memcpy(record,buffer.record,sizeof(buffer.record));
+        *previous = buffer.previous;
+        *when = buffer.when;
+        *correction = buffer.correction;
+        *total = buffer.total;
+        *index = buffer.index;
+        *cycle = buffer.cycle;
+        waiting = buffer.waiting;
+        memset(&buffer,0,sizeof(buffer));
+
+/* Print out the data if requested. */
+
+        if (verbose > 1) {
+            fprintf(stderr,"%s: prev=%.3f when=%.3f corr=%.3f\n",
+                argv0,*previous,*when,*correction);
+            for (i = 0; i < *total; ++i) {
+                if ((j = i+*index-*total) < 0) j += *total;
+                fprintf(stderr,"%s: when=%.3f disp=%.3f off=%.3f",
+                    argv0,record[j].when,record[j].dispersion,record[j].offset);
+                if (operation == op_client)
+                    fprintf(stderr," err=%.3f\n",record[j].error);
+                else
+                    fprintf(stderr,"\n");
+            }
+        }
+
+/* All errors on output are fatal. */
+
+    } else if (operation == save_write) {
+        memcpy(buffer.record,record,sizeof(buffer.record));
+        buffer.previous = *previous;
+        buffer.when = *when;
+        buffer.correction = *correction;
+        buffer.operation = operation;
+        buffer.delay = delay;
+        buffer.count = count;
+        buffer.total = *total;
+        buffer.index = *index;
+        buffer.cycle = *cycle;
+        buffer.waiting = waiting;
+        if (fseek(savefile,0l,SEEK_SET) != 0 ||
+                fwrite(&buffer,sizeof(buffer),1,savefile) != 1 ||
+                fflush(savefile) != 0 || ferror(savefile))
+            fatal(1,"unable to write record to daemon save file",NULL);
+        if (verbose > 2) {
+            fprintf(stderr,"Writing prev=%.6f when=%.6f corr=%.6f\n",
+                *previous,*when,*correction);
+            fprintf(stderr,"op=%d dly=%d cnt=%d tot=%d ind=%d cyc=%d wait=%d\n",
+                operation,delay,count,*total,*index,*cycle,waiting);
+            if (*total < COUNT_MAX)
+                for (i = 0; i < *total; ++i)
+                    fprintf(stderr,
+                        "disp=%.6f wgt=%.3f when=%.6f off=%.6f err=%.6f\n",
+                        record[i].dispersion,record[i].weight,
+                        record[i].when,record[i].offset,record[i].error);
+        }
+
+/* Clearing the save file is similar. */
+
+    } else if (operation == save_clear) {
+        if (fseek(savefile,0l,SEEK_SET) != 0 ||
+                fwrite(&buffer,sizeof(buffer),1,savefile) != 1 ||
+                fflush(savefile) != 0 || ferror(savefile))
+            fatal(1,"unable to clear daemon save file",NULL);
+    } else
+        fatal(0,"internal error in handle_saving",NULL);
+}
+
+
+
+void query_savefile (void) {
+
+/* This queries a daemon save file. */
+
+    double previous, when, correction = 0.0, offset = 0.0, error = -1.0,
+        drift = 0.0, drifterr = -1.0;
+    data_record record[COUNT_MAX];
+    int total = 0, index = 0, cycle = 0;
+    char text[100];
+
+/* This is a few lines stripped out of run_daemon() and slightly hacked. */
+
+    previous = when = current_time(JAN_1970);
+    if (verbose > 2) {
+        format_time(text,50,0.0,-1.0,0.0,-1.0,-10);
+        fprintf(stderr,"Started=%.6f %s\n",when,text);
+    }
+    handle_saving(save_read_only,&total,&index,&cycle,record,&previous,&when,
+        &correction);
+    estimate_stats(&total,&index,record,correction,&dispersion,
+        &when,&offset,&error,&drift,&drifterr,&waiting,0);
+    format_time(text,100,offset,error,drift,drifterr,-10);
+    printf("%s\n",text);
+    if (fclose(savefile)) fatal(1,"unable to close daemon save file",NULL);
+    if (verbose > 2) fprintf(stderr,"Stopped normally\n");
+    exit(EXIT_SUCCESS);
+}
+
+
+
+void run_daemon (char *hostnames[], int nhosts, int initial) {
+
+/* This does not adjust the time between calls to the server, but it does
+adjust the time between clock resets.  This function will survive short periods
+of server inaccessibility or network glitches, but not long ones, and will then
+need restarting manually.
+
+It is far too complex for a single function, but could really only be
+simplified by making most of its variables global or by a similarly horrible
+trick.  Oh, for nested scopes as in Algol 68! */
+
+    double history[COUNT_MAX], started, previous, when, correction = 0.0,
+        weeble = 1.0, accepts = 0.0, rejects = 0.0, flushes = 0.0,
+        replicates = 0.0, skips = 0.0, offset = 0.0, error = -1.0,
+        drift = 0.0, drifterr = -1.0, maxoff = 0.0, x;
+    data_record record[COUNT_MAX];
+    int total = 0, index = 0, item = 0, rej_level = 0, rep_level = 0,
+        cycle = 0, retry = 1, i, j, k;
+    unsigned char transmit[NTP_PACKET_MIN];
+    ntp_data data;
+    char text[100];
+
+/* After initialising, restore from a previous run if possible.  Note that
+only a few of the variables are actually needed to control the operation and
+the rest are mainly for diagnostics. */
+
+    started = previous = when = current_time(JAN_1970);
+    if (verbose > 2) {
+        format_time(text,50,0.0,-1.0,0.0,-1.0,-10);
+        fprintf(stderr,"Started=%.6f %s\n",when,text);
+    }
+    if (initial) {
+        handle_saving(save_read_check,&total,&index,&cycle,record,
+            &previous,&when,&correction);
+        cycle = (nhosts > 0 ? cycle%nhosts : 0);
+        if (total > 0 && started-previous < delay) {
+            if (verbose > 2) fprintf(stderr,"Last packet too recent\n");
+            retry = 0;
+        }
+        if (verbose > 2)
+            fprintf(stderr,"prev=%.6f when=%.6f retry=%d\n",
+                previous,when,retry);
+        for (i = 0; i < nhosts; ++i) open_socket(i,hostnames[i],delay);
+        if (action != action_display) {
+            set_lock(1);
+            locked = 1;
+        }
+    }
+    dispersion = 0.0;
+    attempts = 0;
+    for (i = 0; i < count; ++i) history[i] = 0.0;
+    while (1) {
+
+/* Print out a reasonable amount of diagnostics, rather like a server.  Note
+that it may take a little time, but shouldn't affect the estimates much.  Then
+check that we aren't in a failing loop. */
+
+        if (verbose > 2) fprintf(stderr,"item=%d rej=%d\n",item,rej_level);
+        x = current_time(JAN_1970)-started;
+        if (verbose &&
+                x/3600.0+accepts+rejects+flushes+replicates+skips >= weeble) {
+            weeble *= WEEBLE_FACTOR;
+            x -= 3600.0*(i = (int)(x/3600.0));
+            x -= 60.0*(j = (int)(x/60.0));
+            if (i > 0)
+                fprintf(stderr,"%s: after %d hours %d mins ",argv0,i,j);
+            else if (j > 0)
+                fprintf(stderr,"%s: after %d mins %.0f secs ",argv0,j,x);
+            else
+                fprintf(stderr,"%s: after %.1f secs ",argv0,x);
+            fprintf(stderr,"acc. %.0f rej. %.0f flush %.0f",
+                accepts,rejects,flushes);
+            if (operation == op_listen)
+                fprintf(stderr," rep. %.0f skip %.0f",replicates,skips);
+            fprintf(stderr," max.off. %.3f corr. %.3f\n",maxoff,correction);
+            format_time(text,100,offset,error,drift,drifterr,-10);
+            fprintf(stderr,"%s: %s\n",argv0,text);
+            maxoff = 0.0;
+        }
+        if (current_time(JAN_1970)-previous > count*delay) {
+            if (verbose)
+                fprintf(stderr,"%s: no packets in too long a period\n",argv0);
+            return;
+        }
+
+/* Listen for the next broadcast packet.  This allows up to ETHERNET_MAX
+replications per packet, for systems with multiple addresses for receiving
+broadcasts; the only reason for a limit is to protect against broken NTP
+servers always returning the same time. */
+
+        if (operation == op_listen) {
+            flushes += flush_socket(0);
+            if (read_packet(0,&data,&offset,&error)) {
+                ++rejects;
+                if (++rej_level > count)
+                    fatal(0,"too many bad or lost packets",NULL);
+                if (action != action_display && drifterr >= 0.0) {
+                    correction += correct_drift(&when,&offset,drift);
+                    handle_saving(save_write,&total,&index,&cycle,record,
+                        &previous,&when,&correction);
+                }
+                continue;
+            }
+            if ((rej_level -= (count < 5 ? count : 5)) < 0) rej_level = 0;
+            x = data.transmit;
+            for (i = 0; i < count; ++i)
+                if (x == history[i]) {
+                    ++replicates;
+                    if (++rep_level > ETHERNET_MAX)
+                        fatal(0,"too many replicated packets",NULL);
+                    goto continue1;
+                }
+            rep_level = 0;
+            history[item] = x;
+            if (++item >= count) item = 0;
+
+/* Accept a packet only after a long enough period has elapsed. */
+
+            when = data.current;
+            if (! retry && when < previous+delay) {
+                if (verbose > 2) fprintf(stderr,"Skipping too recent packet\n");
+                ++skips;
+                continue;
+            }
+            retry = 0;
+            if (verbose > 2)
+                fprintf(stderr,"Offset=%.6f @ %.6f disp=%.6f\n",
+                    offset,when,dispersion);
+
+/* Handle the client/server model.  It keeps a record of transmitted times,
+mainly out of paranoia.  The waiting time is kludged up to attempt to provide
+reasonable resilience against both lost packets and dead servers.  But it
+won't handle much of either, and will stop after a while, needing manual
+restarting.  Running it under cron is the best approach. */
+
+        } else {
+            if (! retry) {
+               if (verbose > 2) fprintf(stderr,"Sleeping for %d\n",waiting);
+               do_nothing(waiting);
+            }
+            make_packet(&data,NTP_CLIENT);
+            outgoing[item] = data.transmit;
+            if (++item >= 2*count) item = 0;
+            if (attempts < 2*count) ++attempts;
+            if (verbose > 2) {
+                fprintf(stderr,"Outgoing packet on socket %d:\n",cycle);
+                display_data(&data);
+            }
+            pack_ntp(transmit,NTP_PACKET_MIN,&data);
+            if (verbose > 2) display_packet(transmit,NTP_PACKET_MIN);
+            flushes += flush_socket(cycle);
+            write_socket(cycle,transmit,NTP_PACKET_MIN);
+
+/* Read the packet and check that it is an appropriate response.  Because this
+is rather more numerically sensitive than simple resynchronisation, reject all
+very inaccurate packets.  Be careful if you modify this, because the error
+handling is rather nasty to avoid replicating code. */
+
+            k = read_packet(cycle,&data,&offset,&error);
+            if (++cycle >= nhosts) cycle = 0;
+            if (! k)
+                when = (data.originate+data.current)/2.0;
+            else if (action != action_display && drifterr >= 0.0) {
+                correction += correct_drift(&when,&offset,drift);
+                handle_saving(save_write,&total,&index,&cycle,record,
+                    &previous,&when,&correction);
+            }
+            if (! k && ! retry && when < previous+delay-2) {
+                if (verbose)
+                    fprintf(stderr,"%s: packets out of order on socket %d\n",
+                        argv0,cycle);
+                k = 1;
+            }
+            if (! k && data.current-data.originate > maxerr) {
+                if (verbose)
+                    fprintf(stderr,
+                        "%s: very slow response rejected on socket %d\n",
+                        argv0,cycle);
+                k = 1;
+            }
+
+/* Count the number of rejected packets and fail if there are too many. */
+
+            if (k) {
+                ++rejects;
+                if (++rej_level > count)
+                    fatal(0,"too many bad or lost packets",NULL);
+                else {
+                    retry = 1;
+                    continue;
+                }
+            } else
+                retry = 0;
+            if ((rej_level -= (count < 5 ? count : 5)) < 0) rej_level = 0;
+            if (verbose > 2)
+                fprintf(stderr,"Offset=%.6f+/-%.6f @ %.6f disp=%.6f\n",
+                    offset,error,when,dispersion);
+        }
+   
+/* Calculate the statistics, and display the results or make the initial
+correction.  Note that estimate_stats() will return zero if a timestamp
+indicates synchronisation loss (usually due to down time or a change of server,
+somewhere upstream), and that the recovery operation is unstructured, so great
+care should be taken when modifying it.  Also, we want to clear the saved state
+is the statistics are bad. */
+
+        handle_saving(save_clear,&total,&index,&cycle,record,&previous,&when,
+            &correction);
+        ++accepts;
+        dispersion = data.dispersion;
+        previous = when =
+            estimate_stats(&total,&index,record,correction,&dispersion,
+                &when,&offset,&error,&drift,&drifterr,&waiting,1);
+        if (verbose > 2) {
+            fprintf(stderr,"tot=%d ind=%d dis=%.3f when=%.3f off=%.3f ",
+                total,index,dispersion,when,offset);
+            fprintf(stderr,"err=%.3f wait=%d\n",error,waiting);
+        }
+        if (when == 0.0) return;
+        x = (maxoff < 0.0 ? -maxoff : maxoff);
+        if ((offset < 0.0 ? -offset : offset) > x) maxoff = offset;
+        correction = 0.0;
+        if (operation == op_client || accepts >= count) {
+            if (action == action_display) {
+                format_time(text,100,offset,error,drift,drifterr,-10);
+                printf("%s\n",text);
+            } else {
+                x = reset_clock(offset,error,1);
+                correction += x;
+                offset -= x;
+            }
+        } else
+            waiting = delay;
+        handle_saving(save_write,&total,&index,&cycle,record,&previous,&when,
+            &correction);
+
+/* Now correct the clock for a while, before getting another packet and
+updating the statistics. */
+
+        while (when < previous+delay-waiting) {
+            do_nothing(waiting);
+            if (action == action_display)
+                when += waiting;
+            else {
+                correction += correct_drift(&when,&offset,drift);
+                handle_saving(save_write,&total,&index,&cycle,record,
+                    &previous,&when,&correction);
+            }
+        }
+continue1: ;
+    }
+}
+
+
+
+void run_client (char *hostnames[], int nhosts) {
+
+/* Get enough responses to do something with; or not, as the case may be.  Note
+that it allows for half of the packets to be bad, so may make up to twice as
+many attempts as specified by the -c value.  The deadline checking is merely
+paranoia, to protect against broken signal handling - it cannot easily be
+triggered if the signal handling works. */
+
+    double history[COUNT_MAX], guesses[COUNT_MAX], offset, error, deadline,
+        a, b, x, y;
+    int precs[COUNT_MAX], precision = 0;
+    int accepts = 0, rejects = 0, flushes = 0, replicates = 0, cycle = 0, k;
+    unsigned char transmit[NTP_PACKET_MIN];
+    ntp_data data;
+    char text[100];
+
+    if (verbose > 2) {
+        format_time(text,50,0.0,-1.0,0.0,-1.0,-10);
+        fprintf(stderr,"Started=%.6f %s\n",current_time(JAN_1970),text);
+    }
+    for (k = 0; k < nhosts; ++k) open_socket(k,hostnames[k],delay);
+    if (action != action_display) {
+        set_lock(1);
+        locked = 1;
+    }
+    attempts = 0;
+    deadline = current_time(JAN_1970)+delay;
+
+/* Listen to broadcast packets and select the best (i.e. earliest).  This will
+be sensitive to a bad NTP broadcaster, but I believe such things are very rare
+in practice.  In any case, if you have one, it is probably the only one on your
+subnet, so you are knackered!  This allows up to ETHERNET_MAX replications per
+packet, for systems with multiple addresses for receiving broadcasts; the only
+reason for a limit is to protect against broken NTP servers always returning
+the same time. */
+
+    if (operation == op_listen) {
+        while (accepts < count) {
+            if (current_time(JAN_1970) > deadline)
+                fatal(0,"not enough valid broadcasts received in time",NULL);
+            flushes += flush_socket(0);
+            if (read_packet(0,&data,&x,&y)) {
+                if (++rejects > count)
+                    fatal(0,"too many bad or lost packets",NULL);
+                else
+                    continue;
+            } else {
+                a = data.transmit;
+                for (k = 0; k < accepts; ++k)
+                    if (a == history[k]) {
+                        if (++replicates > ETHERNET_MAX*count)
+                            fatal(0,"too many replicated packets",NULL);
+                        goto continue1;
+                    }
+                history[accepts] = a;
+               precs[accepts] = data.precision;
+                guesses[accepts++] = x;
+            }
+            if (verbose > 2)
+                fprintf(stderr,"Offset=%.6f disp=%.6f\n",x,dispersion);
+            else if (verbose > 1)
+                fprintf(stderr,"%s: offset=%.3f disp=%.3f\n",
+                    argv0,x,dispersion);
+
+/* Note that bubblesort IS a good method for this amount of data.  */
+
+            for (k = accepts-2; k >= 0; --k)
+                if (guesses[k] < guesses[k+1])
+                    break;
+                else {
+                    x = guesses[k];
+                    guesses[k] = guesses[k+1];
+                    guesses[k+1] = x;
+                   precision = precs[k];
+                   precs[k] = precs[k+1];
+                   precs[k+1] = precision;
+                }
+continue1:  ;
+        }
+        offset = guesses[0];
+       precision = precs[0];
+        error = minerr+guesses[count <= 5 ? count-1 : 5]-offset;
+        if (verbose > 2)
+            fprintf(stderr,"accepts=%d rejects=%d flushes=%d replicates=%d\n",
+                accepts,rejects,flushes,replicates);
+
+/* Handle the client/server model.  It keeps a record of transmitted times,
+mainly out of paranoia. */
+
+    } else {
+        offset = 0.0;
+       precision = 0;
+        error = NTP_INSANITY;
+        while (accepts < count && attempts < 2*count) {
+            if (current_time(JAN_1970) > deadline)
+                fatal(0,"not enough valid responses received in time",NULL);
+            make_packet(&data,NTP_CLIENT);
+            precs[attempts] = data.precision;
+            outgoing[attempts++] = data.transmit;
+            if (verbose > 2) {
+                fprintf(stderr,"Outgoing packet on socket %d:\n",cycle);
+                display_data(&data);
+            }
+            pack_ntp(transmit,NTP_PACKET_MIN,&data);
+            if (verbose > 2) display_packet(transmit,NTP_PACKET_MIN);
+            flushes += flush_socket(cycle);
+            write_socket(cycle,transmit,NTP_PACKET_MIN);
+            if (read_packet(cycle,&data,&x,&y)) {
+                if (++rejects > count)
+                    fatal(0,"too many bad or lost packets",NULL);
+                else
+                    continue;
+            } else
+                ++accepts;
+            if (++cycle >= nhosts) cycle = 0;
+
+/* Work out the most accurate time, and check that it isn't more accurate than
+the results warrant. */
+
+            if (verbose > 2)
+                fprintf(stderr,"Offset=%.6f+/-%.6f disp=%.6f\n",x,y,dispersion);
+            else if (verbose > 1)
+                fprintf(stderr,"%s: offset=%.3f+/-%.3f disp=%.3f\n",
+                    argv0,x,y,dispersion);
+            if ((a = x-offset) < 0.0) a = -a;
+            if (accepts <= 1) a = 0.0;
+            b = error+y;
+            if (y < error) {
+                offset = x;
+                error = y;
+               precision = data.precision;
+            }
+            if (verbose > 2)
+                fprintf(stderr,"best=%.6f+/-%.6f\n",offset,error);
+            if (a > b) {
+                sprintf(text,"%d",cycle);
+                fatal(0,"inconsistent times got from NTP server on socket %s",
+                    text);
+            }
+            if (error <= minerr) break;
+        }
+        if (verbose > 2)
+            fprintf(stderr,"accepts=%d rejects=%d flushes=%d\n",
+                accepts,rejects,flushes);
+    }
+
+/* Tidy up the socket, issues diagnostics and perform the action. */
+
+    for (k = 0; k < nhosts; ++k) close_socket(k);
+    if (accepts == 0) fatal(0,"no acceptable packets received",NULL);
+    if (error > NTP_INSANITY)
+        fatal(0,"unable to get a reasonable time estimate",NULL);
+    if (verbose > 2)
+        fprintf(stderr,"Correction: %.6f +/- %.6f disp=%.6f\n",
+            offset,error,dispersion);
+    if (action == action_display) {
+        format_time(text,75,offset,error,0.0,-1.0,precision);
+        printf("%s\n",text);
+    } else
+        (void)reset_clock(offset,error,0);
+    if (locked) set_lock(0);
+    if (verbose > 2) fprintf(stderr,"Stopped normally\n");
+    exit(EXIT_SUCCESS);
+}
+
+
+
+int main (int argc, char *argv[]) {
+
+/* This is the entry point and all that.  It decodes the arguments and calls
+one of the specialised routines to do the work. */
+
+    char *hostnames[MAX_SOCKETS], *savename = NULL;
+    int daemon = 0, nhosts = 0, help = 0, args = argc-1, k;
+    char c;
+
+    if (argv[0] == NULL || argv[0][0] == '\0')
+        argv0 = "sntp";
+    else if ((argv0 = strrchr(argv[0],'/')) != NULL)
+        ++argv0;
+    else
+        argv0 = argv[0];
+
+    setvbuf(stdout,NULL,_IOLBF,BUFSIZ);
+    setvbuf(stderr,NULL,_IOLBF,BUFSIZ);
+
+    if (INT_MAX < 2147483647) fatal(0,"sntp requires >= 32-bit ints",NULL);
+    if (DBL_EPSILON > 1.0e-13)
+        fatal(0,"sntp requires doubles with eps <= 1.0e-13",NULL);
+    for (k = 0; k < MAX_SOCKETS; ++k) hostnames[k] = NULL;
+
+/* Decode the arguments. */
+
+    while (argc > 1) {
+        k = 1;
+       if (strcmp(argv[1],"-4") == 0)
+           preferred_family(PREF_FAM_INET);
+       else if (strcmp(argv[1],"-6") == 0)
+           preferred_family(PREF_FAM_INET6);
+        else if (strcmp(argv[1],"-u") == 0)
+            ++unprivport;
+        else if (strcmp(argv[1],"-q") == 0 && action == 0)
+            action = action_query;
+        else if (strcmp(argv[1],"-r") == 0 && action == 0)
+            action = action_reset;
+        else if (strcmp(argv[1],"-a") == 0 && action == 0)
+            action = action_adjust;
+        else if (strcmp(argv[1],"-l") == 0 && lockname == NULL && argc > 2) {
+            lockname = argv[2];
+            k = 2;
+        } else if ((strcmp(argv[1],"-x") == 0) &&
+                daemon == 0) {
+            if (argc > 2 && sscanf(argv[2],"%d%c",&daemon,&c) == 1) {
+                if (daemon < 1 || daemon > 1440)
+                    fatal(0,"%s option value out of range",argv[1]);
+                k = 2;
+            } else
+                daemon = 300;
+        } else if (strcmp(argv[1],"-f") == 0 && savename == NULL && argc > 2) {
+            savename = argv[2];
+            k = 2;
+        } else if ((strcmp(argv[1],"--help") == 0 ||
+                    strcmp(argv[1],"-h") == 0 || strcmp(argv[1],"-?") == 0) &&
+                help == 0)
+            help = 1;
+        else if (strcmp(argv[1],"-v") == 0 && verbose == 0)
+            verbose = 1;
+        else if (strcmp(argv[1],"-V") == 0 && verbose == 0)
+            verbose = 2;
+        else if (strcmp(argv[1],"-W") == 0 && verbose == 0)
+            verbose = 3;
+        else if (strcmp(argv[1],"-e") == 0 && minerr == 0.0 && argc > 2) {
+            if (sscanf(argv[2],"%lf%c",&minerr,&c) != 1) syntax(1);
+            if (minerr <= 0.000999999 || minerr > 1.0)
+                fatal(0,"%s option value out of range","-e");
+            k = 2;
+        } else if (strcmp(argv[1],"-E") == 0 && maxerr == 0.0 && argc > 2) {
+            if (sscanf(argv[2],"%lf%c",&maxerr,&c) != 1) syntax(1);
+            if (maxerr < 1.0 || maxerr > 60.0)
+                fatal(0,"%s option value out of range","-E");
+            k = 2;
+        } else if (strcmp(argv[1],"-P") == 0 && prompt == 0.0 && argc > 2) {
+            if (strcmp(argv[2],"no") == 0)
+                prompt = (double)INT_MAX;
+            else {
+                if (sscanf(argv[2],"%lf%c",&prompt,&c) != 1) syntax(1);
+                if (prompt < 1.0 || prompt > 3600.0)
+                    fatal(0,"%s option value out of range","-p");
+            }
+            k = 2;
+        } else if (strcmp(argv[1],"-d") == 0 && delay == 0 && argc > 2) {
+            if (sscanf(argv[2],"%d%c",&delay,&c) != 1) syntax(1);
+            if (delay < 1 || delay > 3600)
+                fatal(0,"%s option value out of range","-d");
+            k = 2;
+        } else if (strcmp(argv[1],"-c") == 0 && count == 0 && argc > 2) {
+            if (sscanf(argv[2],"%d%c",&count,&c) != 1) syntax(1);
+            if (count < 1 || count > COUNT_MAX)
+                fatal(0,"%s option value out of range","-c");
+            k = 2;
+        } else
+            break;
+        argc -= k;
+        argv += k;
+    }
+
+/* Check the arguments for consistency and set the defaults. */
+
+    if (action == action_query) {
+        if (argc != 1 || minerr != 0.0 || maxerr != 0.0 || count != 0 ||
+                delay != 0 || daemon != 0 || prompt != 0.0 || lockname != NULL)
+            syntax(1);
+    } else {
+        if (argc < 1 || argc > MAX_SOCKETS || (daemon != 0 && delay != 0))
+            syntax(1);
+        if ((prompt || lockname != NULL) &&
+                action != action_reset && action != action_adjust)
+            syntax(1);
+        if (count > 0 && count < argc-1)
+            fatal(0,"-c value less than number of addresses",NULL);
+       if (argc > 1) {
+            operation = op_client;
+            for (k = 1; k < argc; ++k) {
+                if (argv[k][0] == '\0' || argv[k][0] == '-')
+                    fatal(0,"invalid Internet address '%s'",argv[k]);
+                hostnames[k-1] = argv[k];
+            }
+            nhosts = argc-1;
+        } else {
+            operation = op_listen;
+            nhosts = 0;
+        }
+        if (action == 0) action = action_display;
+        if (minerr <= 0.0) minerr = (operation == op_listen ? 0.5 : 0.1);
+        if (maxerr <= 0.0) maxerr = 5.0;
+        if (count == 0) count = (argc-1 < 5 ? 5 : argc-1);
+        if ((argc == 1 || (daemon != 0 && action != action_query)) && count < 5)
+            fatal(0,"at least 5 packets needed in this mode",NULL);
+        if ((action == action_reset || action == action_adjust) &&
+                lockname == NULL)
+            lockname = LOCKNAME;
+
+/* The '-x' option changes the implications of many other settings, though this
+is not usually apparent to the caller.  Most of the time delays are to ensure
+that stuck states terminate, and do not affect the result. */
+
+        if (daemon != 0) {
+            if (minerr >= maxerr || maxerr >= daemon)
+                fatal(0,"values not in order -e < -E < -x",NULL);
+            waiting = delay = daemon *= 60;
+        } else {
+            if (savename != NULL)
+                fatal(0,"-f can be specified only with -x",NULL);
+            if (delay == 0)
+                delay = (operation == op_listen ? 300 :
+                        (2*count >= 15 ? 2*count+1 :15));
+            if (operation == op_listen) {
+                if (minerr >= maxerr || maxerr >= delay/count)
+                    fatal(0,"values not in order -e < -E < -d/-c",NULL);
+            } else {
+                if (minerr >= maxerr || maxerr >= delay)
+                    fatal(0,"values not in order -e < -E < -d",NULL);
+            }
+            if (2*count >= delay) fatal(0,"-c must be less than half -d",NULL);
+            waiting = delay/count;
+        }
+        if (prompt == 0.0) prompt = 30.0;
+    }
+    if ((daemon || action == action_query) && savename == NULL)
+        savename = SAVENAME;
+
+/* Diagnose where we are, if requested, and separate out the classes of 
+operation.  The calls do not return. */
+
+    if (help) syntax(args == 1);
+    if (verbose) {
+        fprintf(stderr,"%s options: a=%d v=%d e=%.3f E=%.3f P=%.3f\n",
+            argv0,action,verbose,minerr,maxerr,prompt);
+        fprintf(stderr,"    d=%d c=%d %c=%d op=%d l=%s f=%s",
+            delay,count,'x',daemon,operation,
+            (lockname == NULL ? "" : lockname),
+            (savename == NULL ? "" : savename));
+        for (k = 0; k < MAX_SOCKETS; ++k)
+            if (hostnames[k] != NULL) fprintf(stderr," %s",hostnames[k]);
+        fprintf(stderr,"\n");
+    }
+    if (nhosts == 0) nhosts = 1;    /* Kludge for broadcasts */
+    if (action == action_query) {
+        if (savename == NULL || savename[0] == '\0')
+            fatal(0,"no daemon save file specified",NULL);
+        else if ((savefile = fopen(savename,"rb")) == NULL)
+            fatal(0,"unable to open the daemon save file",NULL);
+        query_savefile();
+    } else if (daemon != 0) {
+        if (savename != NULL && savename[0] != '\0' &&
+                (savefile = fopen(savename,"rb+")) == NULL &&
+                (savefile = fopen(savename,"wb+")) == NULL)
+            fatal(0,"unable to open the daemon save file",NULL);
+        run_daemon(hostnames,nhosts,1);
+        while (1) run_daemon(hostnames,nhosts,0);
+    } else
+        run_client(hostnames,nhosts);
+    fatal(0,"internal error at end of main",NULL);
+    return EXIT_FAILURE;
+}
diff --git a/sntp/missing b/sntp/missing
new file mode 100755 (executable)
index 0000000..894e786
--- /dev/null
@@ -0,0 +1,360 @@
+#! /bin/sh
+# Common stub for a few missing GNU programs while installing.
+
+scriptversion=2005-06-08.21
+
+# Copyright (C) 1996, 1997, 1999, 2000, 2002, 2003, 2004, 2005
+#   Free Software Foundation, Inc.
+# Originally by Fran,cois Pinard <pinard@iro.umontreal.ca>, 1996.
+
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
+# 02110-1301, USA.
+
+# As a special exception to the GNU General Public License, if you
+# distribute this file as part of a program that contains a
+# configuration script generated by Autoconf, you may include it under
+# the same distribution terms that you use for the rest of that program.
+
+if test $# -eq 0; then
+  echo 1>&2 "Try \`$0 --help' for more information"
+  exit 1
+fi
+
+run=:
+
+# In the cases where this matters, `missing' is being run in the
+# srcdir already.
+if test -f configure.ac; then
+  configure_ac=configure.ac
+else
+  configure_ac=configure.in
+fi
+
+msg="missing on your system"
+
+case "$1" in
+--run)
+  # Try to run requested program, and just exit if it succeeds.
+  run=
+  shift
+  "$@" && exit 0
+  # Exit code 63 means version mismatch.  This often happens
+  # when the user try to use an ancient version of a tool on
+  # a file that requires a minimum version.  In this case we
+  # we should proceed has if the program had been absent, or
+  # if --run hadn't been passed.
+  if test $? = 63; then
+    run=:
+    msg="probably too old"
+  fi
+  ;;
+
+  -h|--h|--he|--hel|--help)
+    echo "\
+$0 [OPTION]... PROGRAM [ARGUMENT]...
+
+Handle \`PROGRAM [ARGUMENT]...' for when PROGRAM is missing, or return an
+error status if there is no known handling for PROGRAM.
+
+Options:
+  -h, --help      display this help and exit
+  -v, --version   output version information and exit
+  --run           try to run the given command, and emulate it if it fails
+
+Supported PROGRAM values:
+  aclocal      touch file \`aclocal.m4'
+  autoconf     touch file \`configure'
+  autoheader   touch file \`config.h.in'
+  automake     touch all \`Makefile.in' files
+  bison        create \`y.tab.[ch]', if possible, from existing .[ch]
+  flex         create \`lex.yy.c', if possible, from existing .c
+  help2man     touch the output file
+  lex          create \`lex.yy.c', if possible, from existing .c
+  makeinfo     touch the output file
+  tar          try tar, gnutar, gtar, then tar without non-portable flags
+  yacc         create \`y.tab.[ch]', if possible, from existing .[ch]
+
+Send bug reports to <bug-automake@gnu.org>."
+    exit $?
+    ;;
+
+  -v|--v|--ve|--ver|--vers|--versi|--versio|--version)
+    echo "missing $scriptversion (GNU Automake)"
+    exit $?
+    ;;
+
+  -*)
+    echo 1>&2 "$0: Unknown \`$1' option"
+    echo 1>&2 "Try \`$0 --help' for more information"
+    exit 1
+    ;;
+
+esac
+
+# Now exit if we have it, but it failed.  Also exit now if we
+# don't have it and --version was passed (most likely to detect
+# the program).
+case "$1" in
+  lex|yacc)
+    # Not GNU programs, they don't have --version.
+    ;;
+
+  tar)
+    if test -n "$run"; then
+       echo 1>&2 "ERROR: \`tar' requires --run"
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       exit 1
+    fi
+    ;;
+
+  *)
+    if test -z "$run" && ($1 --version) > /dev/null 2>&1; then
+       # We have it, but it failed.
+       exit 1
+    elif test "x$2" = "x--version" || test "x$2" = "x--help"; then
+       # Could not run --version or --help.  This is probably someone
+       # running `$TOOL --version' or `$TOOL --help' to check whether
+       # $TOOL exists and not knowing $TOOL uses missing.
+       exit 1
+    fi
+    ;;
+esac
+
+# If it does not exist, or fails to run (possibly an outdated version),
+# try to emulate it.
+case "$1" in
+  aclocal*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acinclude.m4' or \`${configure_ac}'.  You might want
+         to install the \`Automake' and \`Perl' packages.  Grab them from
+         any GNU archive site."
+    touch aclocal.m4
+    ;;
+
+  autoconf)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`${configure_ac}'.  You might want to install the
+         \`Autoconf' and \`GNU m4' packages.  Grab them from any GNU
+         archive site."
+    touch configure
+    ;;
+
+  autoheader)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`acconfig.h' or \`${configure_ac}'.  You might want
+         to install the \`Autoconf' and \`GNU m4' packages.  Grab them
+         from any GNU archive site."
+    files=`sed -n 's/^[ ]*A[CM]_CONFIG_HEADER(\([^)]*\)).*/\1/p' ${configure_ac}`
+    test -z "$files" && files="config.h"
+    touch_files=
+    for f in $files; do
+      case "$f" in
+      *:*) touch_files="$touch_files "`echo "$f" |
+                                      sed -e 's/^[^:]*://' -e 's/:.*//'`;;
+      *) touch_files="$touch_files $f.in";;
+      esac
+    done
+    touch $touch_files
+    ;;
+
+  automake*)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified \`Makefile.am', \`acinclude.m4' or \`${configure_ac}'.
+         You might want to install the \`Automake' and \`Perl' packages.
+         Grab them from any GNU archive site."
+    find . -type f -name Makefile.am -print |
+          sed 's/\.am$/.in/' |
+          while read f; do touch "$f"; done
+    ;;
+
+  autom4te)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, but is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.
+         You can get \`$1' as part of \`Autoconf' from any GNU
+         archive site."
+
+    file=`echo "$*" | sed -n 's/.*--output[ =]*\([^ ]*\).*/\1/p'`
+    test -z "$file" && file=`echo "$*" | sed -n 's/.*-o[ ]*\([^ ]*\).*/\1/p'`
+    if test -f "$file"; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo "#! /bin/sh"
+       echo "# Created by GNU Automake missing as a replacement of"
+       echo "#  $ $@"
+       echo "exit 0"
+       chmod +x $file
+       exit 1
+    fi
+    ;;
+
+  bison|yacc)
+    echo 1>&2 "\
+WARNING: \`$1' $msg.  You should only need it if
+         you modified a \`.y' file.  You may need the \`Bison' package
+         in order for those modifications to take effect.  You can get
+         \`Bison' from any GNU archive site."
+    rm -f y.tab.c y.tab.h
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+       case "$LASTARG" in
+       *.y)
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/c/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" y.tab.c
+           fi
+           SRCFILE=`echo "$LASTARG" | sed 's/y$/h/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" y.tab.h
+           fi
+         ;;
+       esac
+    fi
+    if [ ! -f y.tab.h ]; then
+       echo >y.tab.h
+    fi
+    if [ ! -f y.tab.c ]; then
+       echo 'main() { return 0; }' >y.tab.c
+    fi
+    ;;
+
+  lex|flex)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.l' file.  You may need the \`Flex' package
+         in order for those modifications to take effect.  You can get
+         \`Flex' from any GNU archive site."
+    rm -f lex.yy.c
+    if [ $# -ne 1 ]; then
+        eval LASTARG="\${$#}"
+       case "$LASTARG" in
+       *.l)
+           SRCFILE=`echo "$LASTARG" | sed 's/l$/c/'`
+           if [ -f "$SRCFILE" ]; then
+                cp "$SRCFILE" lex.yy.c
+           fi
+         ;;
+       esac
+    fi
+    if [ ! -f lex.yy.c ]; then
+       echo 'main() { return 0; }' >lex.yy.c
+    fi
+    ;;
+
+  help2man)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+        you modified a dependency of a manual page.  You may need the
+        \`Help2man' package in order for those modifications to take
+        effect.  You can get \`Help2man' from any GNU archive site."
+
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+       file=`echo "$*" | sed -n 's/.*--output=\([^ ]*\).*/\1/p'`
+    fi
+    if [ -f "$file" ]; then
+       touch $file
+    else
+       test -z "$file" || exec >$file
+       echo ".ab help2man is required to generate this page"
+       exit 1
+    fi
+    ;;
+
+  makeinfo)
+    echo 1>&2 "\
+WARNING: \`$1' is $msg.  You should only need it if
+         you modified a \`.texi' or \`.texinfo' file, or any other file
+         indirectly affecting the aspect of the manual.  The spurious
+         call might also be the consequence of using a buggy \`make' (AIX,
+         DU, IRIX).  You might want to install the \`Texinfo' package or
+         the \`GNU make' package.  Grab either from any GNU archive site."
+    # The file to touch is that specified with -o ...
+    file=`echo "$*" | sed -n 's/.*-o \([^ ]*\).*/\1/p'`
+    if test -z "$file"; then
+      # ... or it is the one specified with @setfilename ...
+      infile=`echo "$*" | sed 's/.* \([^ ]*\) *$/\1/'`
+      file=`sed -n '/^@setfilename/ { s/.* \([^ ]*\) *$/\1/; p; q; }' $infile`
+      # ... or it is derived from the source name (dir/f.texi becomes f.info)
+      test -z "$file" && file=`echo "$infile" | sed 's,.*/,,;s,.[^.]*$,,'`.info
+    fi
+    # If the file does not exist, the user really needs makeinfo;
+    # let's fail without touching anything.
+    test -f $file || exit 1
+    touch $file
+    ;;
+
+  tar)
+    shift
+
+    # We have already tried tar in the generic part.
+    # Look for gnutar/gtar before invocation to avoid ugly error
+    # messages.
+    if (gnutar --version > /dev/null 2>&1); then
+       gnutar "$@" && exit 0
+    fi
+    if (gtar --version > /dev/null 2>&1); then
+       gtar "$@" && exit 0
+    fi
+    firstarg="$1"
+    if shift; then
+       case "$firstarg" in
+       *o*)
+           firstarg=`echo "$firstarg" | sed s/o//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+       case "$firstarg" in
+       *h*)
+           firstarg=`echo "$firstarg" | sed s/h//`
+           tar "$firstarg" "$@" && exit 0
+           ;;
+       esac
+    fi
+
+    echo 1>&2 "\
+WARNING: I can't seem to be able to run \`tar' with the given arguments.
+         You may want to install GNU tar or Free paxutils, or check the
+         command line arguments."
+    exit 1
+    ;;
+
+  *)
+    echo 1>&2 "\
+WARNING: \`$1' is needed, and is $msg.
+         You might have modified some files without having the
+         proper tools for further handling them.  Check the \`README' file,
+         it often tells you about the needed prerequisites for installing
+         this package.  You may also peek at any GNU archive site, in case
+         some other package would contain this missing \`$1' program."
+    exit 1
+    ;;
+esac
+
+exit 0
+
+# Local variables:
+# eval: (add-hook 'write-file-hooks 'time-stamp)
+# time-stamp-start: "scriptversion="
+# time-stamp-format: "%:y-%02m-%02d.%02H"
+# time-stamp-end: "$"
+# End:
diff --git a/sntp/sntp-opts.c b/sntp/sntp-opts.c
new file mode 100644 (file)
index 0000000..37c4e7c
--- /dev/null
@@ -0,0 +1,691 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (sntp-opts.c)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:49 AM EST
+ *  From the definitions    sntp-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This source file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  sntp author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * sntp copyright 1970-2006 ntp.org - all rights reserved
+ *
+ *         General Public Licence for the software known as MSNTP
+ *         ------------------------------------------------------
+ * 
+ *       (c) Copyright, N.M. Maclaren, 1996, 1997, 2000
+ *       (c) Copyright, University of Cambridge, 1996, 1997, 2000
+ * 
+ * 
+ * 
+ * Free use of MSNTP in source and binary forms is permitted, provided that this
+ * entire licence is duplicated in all copies, and that any documentation,
+ * announcements, and other materials related to use acknowledge that the software
+ * was developed by N.M. Maclaren (hereafter refered to as the Author) at the
+ * University of Cambridge.  Neither the name of the Author nor the University of
+ * Cambridge may be used to endorse or promote products derived from this material
+ * without specific prior written permission.
+ * 
+ * The Author and the University of Cambridge retain the copyright and all other
+ * legal rights to the software and make it available non-exclusively.  All users
+ * must ensure that the software in all its derivations carries a copyright notice
+ * in the form:
+ *       (c) Copyright N.M. Maclaren,
+ *       (c) Copyright University of Cambridge.
+ * 
+ * 
+ * 
+ *                            NO WARRANTY
+ * 
+ * Because the MSNTP software is licensed free of charge, the Author and the
+ * University of Cambridge provide absolutely no warranty, either expressed or
+ * implied, including, but not limited to, the implied warranties of
+ * merchantability and fitness for a particular purpose.  The entire risk as to
+ * the quality and performance of the MSNTP software is with you.  Should MSNTP
+ * prove defective, you assume the cost of all necessary servicing or repair.
+ * 
+ * In no event, unless required by law, will the Author or the University of
+ * Cambridge, or any other party who may modify and redistribute this software as
+ * permitted in accordance with the provisions below, be liable for damages for
+ * any losses whatsoever, including but not limited to lost profits, lost monies,
+ * lost or corrupted data, or other special, incidental or consequential losses
+ * that may arise out of the use or inability to use the MSNTP software.
+ * 
+ * 
+ * 
+ *                          COPYING POLICY
+ * 
+ * Permission is hereby granted for copying and distribution of copies of the
+ * MSNTP source and binary files, and of any part thereof, subject to the
+ * following licence conditions:
+ * 
+ * 1. You may distribute MSNTP or components of MSNTP, with or without additions
+ * developed by you or by others.  No charge, other than an "at-cost" distribution
+ * fee, may be charged for copies, derivations, or distributions of this material
+ * without the express written consent of the copyright holders.
+ * 
+ * 2. You may also distribute MSNTP along with any other product for sale,
+ * provided that the cost of the bundled package is the same regardless of whether
+ * MSNTP is included or not, and provided that those interested only in MSNTP must
+ * be notified that it is a product freely available from the University of
+ * Cambridge.
+ * 
+ * 3. If you distribute MSNTP software or parts of MSNTP, with or without
+ * additions developed by you or others, then you must either make available the
+ * source to all portions of the MSNTP system (exclusive of any additions made by
+ * you or by others) upon request, or instead you may notify anyone requesting
+ * source that it is freely available from the University of Cambridge.
+ * 
+ * 4. You may not omit any of the copyright notices on either the source files,
+ * the executable files, or the documentation.
+ * 
+ * 5. You may not omit transmission of this License agreement with whatever
+ * portions of MSNTP that are distributed.
+ * 
+ * 6. Any users of this software must be notified that it is without warranty or
+ * guarantee of any nature, express or implied, nor is there any fitness for use
+ * represented.
+ * 
+ * 
+ * October 1996
+ * April 1997
+ * October 2000
+ */
+
+
+#include <limits.h>
+
+#define OPTION_CODE_COMPILE 1
+#include "sntp-opts.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+tSCC zCopyright[] =
+       "sntp copyright (c) 1970-2006 ntp.org, all rights reserved";
+tSCC zCopyrightNotice[] =
+       
+/* extracted from sntp-opts.def near line 12 */
+"        General Public Licence for the software known as MSNTP\n\
+        ------------------------------------------------------\n\n\
+\t  (c) Copyright, N.M. Maclaren, 1996, 1997, 2000\n\
+\t  (c) Copyright, University of Cambridge, 1996, 1997, 2000\n\n\n\n\
+Free use of MSNTP in source and binary forms is permitted, provided that this\n\
+entire licence is duplicated in all copies, and that any documentation,\n\
+announcements, and other materials related to use acknowledge that the software\n\
+was developed by N.M. Maclaren (hereafter refered to as the Author) at the\n\
+University of Cambridge.  Neither the name of the Author nor the University of\n\
+Cambridge may be used to endorse or promote products derived from this material\n\
+without specific prior written permission.\n\n\
+The Author and the University of Cambridge retain the copyright and all other\n\
+legal rights to the software and make it available non-exclusively.  All users\n\
+must ensure that the software in all its derivations carries a copyright notice\n\
+in the form:\n\
+\t  (c) Copyright N.M. Maclaren,\n\
+\t  (c) Copyright University of Cambridge.\n\n\n\n\
+                           NO WARRANTY\n\n\
+Because the MSNTP software is licensed free of charge, the Author and the\n\
+University of Cambridge provide absolutely no warranty, either expressed or\n\
+implied, including, but not limited to, the implied warranties of\n\
+merchantability and fitness for a particular purpose.  The entire risk as to\n\
+the quality and performance of the MSNTP software is with you.  Should MSNTP\n\
+prove defective, you assume the cost of all necessary servicing or repair.\n\n\
+In no event, unless required by law, will the Author or the University of\n\
+Cambridge, or any other party who may modify and redistribute this software as\n\
+permitted in accordance with the provisions below, be liable for damages for\n\
+any losses whatsoever, including but not limited to lost profits, lost monies,\n\
+lost or corrupted data, or other special, incidental or consequential losses\n\
+that may arise out of the use or inability to use the MSNTP software.\n\n\n\n\
+                         COPYING POLICY\n\n\
+Permission is hereby granted for copying and distribution of copies of the\n\
+MSNTP source and binary files, and of any part thereof, subject to the\n\
+following licence conditions:\n\n\
+1. You may distribute MSNTP or components of MSNTP, with or without additions\n\
+developed by you or by others.  No charge, other than an \"at-cost\" distribution\n\
+fee, may be charged for copies, derivations, or distributions of this material\n\
+without the express written consent of the copyright holders.\n\n\
+2. You may also distribute MSNTP along with any other product for sale,\n\
+provided that the cost of the bundled package is the same regardless of whether\n\
+MSNTP is included or not, and provided that those interested only in MSNTP must\n\
+be notified that it is a product freely available from the University of\n\
+Cambridge.\n\n\
+3. If you distribute MSNTP software or parts of MSNTP, with or without\n\
+additions developed by you or others, then you must either make available the\n\
+source to all portions of the MSNTP system (exclusive of any additions made by\n\
+you or by others) upon request, or instead you may notify anyone requesting\n\
+source that it is freely available from the University of Cambridge.\n\n\
+4. You may not omit any of the copyright notices on either the source files,\n\
+the executable files, or the documentation.\n\n\
+5. You may not omit transmission of this License agreement with whatever\n\
+portions of MSNTP that are distributed.\n\n\
+6. Any users of this software must be notified that it is without warranty or\n\
+guarantee of any nature, express or implied, nor is there any fitness for use\n\
+represented.\n\n\n\
+October 1996\n\
+April 1997\n\
+October 2000";
+extern tUsageProc optionUsage;
+
+#ifndef NULL
+#  define NULL 0
+#endif
+#ifndef EXIT_SUCCESS
+#  define  EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#  define  EXIT_FAILURE 1
+#endif
+/*
+ *  Ipv4 option description:
+ */
+tSCC    zIpv4Text[] =
+        "Force IPv4 DNS name resolution";
+tSCC    zIpv4_NAME[]               = "IPV4";
+tSCC    zIpv4_Name[]               = "ipv4";
+#define IPV4_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Ipv6 option description:
+ */
+tSCC    zIpv6Text[] =
+        "Force IPv6 DNS name resolution";
+tSCC    zIpv6_NAME[]               = "IPV6";
+tSCC    zIpv6_Name[]               = "ipv6";
+#define IPV6_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Unprivport option description:
+ */
+tSCC    zUnprivportText[] =
+        "Use an unprivileged port";
+tSCC    zUnprivport_NAME[]         = "UNPRIVPORT";
+tSCC    zUnprivport_Name[]         = "unprivport";
+#define UNPRIVPORT_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Normalverbose option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zNormalverboseText[] =
+        "Slightly verbose";
+tSCC    zNormalverbose_NAME[]      = "NORMALVERBOSE";
+tSCC    zNormalverbose_Name[]      = "normalverbose";
+static const int
+    aNormalverboseCantList[] = {
+    INDEX_OPT_EXTRAVERBOSE,
+    INDEX_OPT_MEGAVERBOSE, NO_EQUIVALENT };
+#define NORMALVERBOSE_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Extraverbose option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zExtraverboseText[] =
+        "Extra verbose";
+tSCC    zExtraverbose_NAME[]       = "EXTRAVERBOSE";
+tSCC    zExtraverbose_Name[]       = "extraverbose";
+static const int
+    aExtraverboseCantList[] = {
+    INDEX_OPT_NORMALVERBOSE,
+    INDEX_OPT_MEGAVERBOSE, NO_EQUIVALENT };
+#define EXTRAVERBOSE_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Megaverbose option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zMegaverboseText[] =
+        "Mega verbose";
+tSCC    zMegaverbose_NAME[]        = "MEGAVERBOSE";
+tSCC    zMegaverbose_Name[]        = "megaverbose";
+static const int
+    aMegaverboseCantList[] = {
+    INDEX_OPT_NORMALVERBOSE,
+    INDEX_OPT_EXTRAVERBOSE, NO_EQUIVALENT };
+#define MEGAVERBOSE_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Settimeofday option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zSettimeofdayText[] =
+        "Set (step) the time with settimeofday()";
+tSCC    zSettimeofday_NAME[]       = "SETTIMEOFDAY";
+tSCC    zSettimeofday_Name[]       = "settimeofday";
+static const int
+    aSettimeofdayCantList[] = {
+    INDEX_OPT_ADJTIME, NO_EQUIVALENT };
+#define SETTIMEOFDAY_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Adjtime option description with
+ *  "Must also have options" and "Incompatible options":
+ */
+tSCC    zAdjtimeText[] =
+        "Set (slew) the time with adjtime()";
+tSCC    zAdjtime_NAME[]            = "ADJTIME";
+tSCC    zAdjtime_Name[]            = "adjtime";
+static const int
+    aAdjtimeCantList[] = {
+    INDEX_OPT_SETTIMEOFDAY, NO_EQUIVALENT };
+#define ADJTIME_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Help/More_Help/Version option descriptions:
+ */
+tSCC zHelpText[]       = "Display usage information and exit";
+tSCC zHelp_Name[]      = "help";
+
+tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
+tSCC zMore_Help_Name[] = "more-help";
+
+tSCC zVersionText[]    = "Output version information and exit";
+tSCC zVersion_Name[]   = "version";
+
+/*
+ *  Save/Load_Opts option description:
+ */
+tSCC zSave_OptsText[]     = "Save the option state to a config file";
+tSCC zSave_Opts_Name[]    = "save-opts";
+
+tSCC zLoad_OptsText[]     = "Load options from a config file";
+tSCC zLoad_Opts_NAME[]    = "LOAD_OPTS";
+
+tSCC zNotLoad_Opts_Name[] = "no-load-opts";
+tSCC zNotLoad_Opts_Pfx[]  = "no";
+#define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
+/*
+ *  Declare option callback procedures
+ */
+#if defined(TEST_SNTP_OPTS)
+/*
+ *  Under test, omit argument processing, or call optionStackArg,
+ *  if multiple copies are allowed.
+ */
+extern tOptProc
+    optionPagedUsage, optionVersionStderr;
+static tOptProc
+    doUsageOpt;
+
+#else /* NOT defined TEST_SNTP_OPTS */
+/*
+ *  When not under test, there are different procs to use
+ */
+extern tOptProc
+    optionPagedUsage, optionPrintVersion;
+static tOptProc
+    doUsageOpt;
+#endif /* defined(TEST_SNTP_OPTS) */
+#ifdef TEST_SNTP_OPTS
+# define DOVERPROC optionVersionStderr
+#else
+# define DOVERPROC optionPrintVersion
+#endif /* TEST_SNTP_OPTS */
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Sntp Option Descriptions.
+ */
+static tOptDesc optDesc[ OPTION_CT ] = {
+  {  /* entry idx, value */ 0, VALUE_OPT_IPV4,
+     /* equiv idx, value */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IPV4_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIpv4Text, zIpv4_NAME, zIpv4_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 1, VALUE_OPT_IPV6,
+     /* equiv idx, value */ NOLIMIT, NOLIMIT,
+     /* equivalenced to  */ INDEX_OPT_IPV4,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IPV6_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIpv6Text, zIpv6_NAME, zIpv6_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 2, VALUE_OPT_UNPRIVPORT,
+     /* equiv idx, value */ 2, VALUE_OPT_UNPRIVPORT,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ UNPRIVPORT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zUnprivportText, zUnprivport_NAME, zUnprivport_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 3, VALUE_OPT_NORMALVERBOSE,
+     /* equiv idx, value */ 3, VALUE_OPT_NORMALVERBOSE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ NORMALVERBOSE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aNormalverboseCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zNormalverboseText, zNormalverbose_NAME, zNormalverbose_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 4, VALUE_OPT_EXTRAVERBOSE,
+     /* equiv idx, value */ 4, VALUE_OPT_EXTRAVERBOSE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ EXTRAVERBOSE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aExtraverboseCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zExtraverboseText, zExtraverbose_NAME, zExtraverbose_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 5, VALUE_OPT_MEGAVERBOSE,
+     /* equiv idx, value */ 5, VALUE_OPT_MEGAVERBOSE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ MEGAVERBOSE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aMegaverboseCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zMegaverboseText, zMegaverbose_NAME, zMegaverbose_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 6, VALUE_OPT_SETTIMEOFDAY,
+     /* equiv idx, value */ 6, VALUE_OPT_SETTIMEOFDAY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SETTIMEOFDAY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aSettimeofdayCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSettimeofdayText, zSettimeofday_NAME, zSettimeofday_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 7, VALUE_OPT_ADJTIME,
+     /* equiv idx, value */ 7, VALUE_OPT_ADJTIME,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ ADJTIME_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, aAdjtimeCantList,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zAdjtimeText, zAdjtime_NAME, zAdjtime_Name,
+     /* disablement strs */ NULL, NULL },
+
+#ifdef NO_OPTIONAL_OPT_ARGS
+#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
+#else
+#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
+                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
+#endif
+
+  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ DOVERPROC,
+     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
+     /* disablement strs */ NULL, NULL },
+
+#undef VERSION_OPT_FLAGS
+
+
+  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doUsageOpt,
+     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ optionPagedUsage,
+     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
+                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
+                         | OPTST_DISABLE_IMM, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionLoadOpt,
+     /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
+     /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
+};
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Sntp Option Environment
+ */
+tSCC   zPROGNAME[]   = "SNTP";
+tSCC   zUsageTitle[] =
+"sntp - standard SNTP program - Ver. 4.2.4p8\n\
+USAGE:  %s [ -<flag> | --<name> ]...\n";
+tSCC   zRcName[]     = ".ntprc";
+tSCC*  apzHomeList[] = {
+       "$HOME",
+       ".",
+       NULL };
+
+tSCC   zBugsAddr[]    = "http://bugs.ntp.org, bugs@ntp.org";
+#define zExplain NULL
+tSCC    zDetail[]     = "\n\
+.I sntp\n\
+can be used as a SNTP client to query a NTP or SNTP server and either display\n\
+the time or set the local system's time (given suitable privilege).  It can be\n\
+run as an interactive command or in a\n\
+.I cron\n\
+job.\n\
+NTP is the Network Time Protocol (RFC 1305) and SNTP is the\n\
+Simple Network Time Protocol (RFC 2030, which supersedes RFC 1769).\n";
+tSCC    zFullVersion[] = SNTP_FULL_VERSION;
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
+
+#if defined(ENABLE_NLS)
+# define OPTPROC_BASE OPTPROC_TRANSLATE
+  static tOptionXlateProc translate_option_strings;
+#else
+# define OPTPROC_BASE OPTPROC_NONE
+# define translate_option_strings NULL
+#endif /* ENABLE_NLS */
+
+tOptions sntpOptions = {
+    OPTIONS_STRUCT_VERSION,
+    0, NULL,                    /* original argc + argv    */
+    ( OPTPROC_BASE
+    + OPTPROC_ERRSTOP
+    + OPTPROC_SHORTOPT
+    + OPTPROC_LONGOPT
+    + OPTPROC_NO_REQ_OPT
+    + OPTPROC_ENVIRON
+    + OPTPROC_NO_ARGS
+    + OPTPROC_HAS_IMMED ),
+    0, NULL,                    /* current option index, current option */
+    NULL,         NULL,         zPROGNAME,
+    zRcName,      zCopyright,   zCopyrightNotice,
+    zFullVersion, apzHomeList,  zUsageTitle,
+    zExplain,     zDetail,      optDesc,
+    zBugsAddr,                  /* address to send bugs to */
+    NULL, NULL,                 /* extensions/saved state  */
+    optionUsage,       /* usage procedure */
+    translate_option_strings,   /* translation procedure */
+    /*
+     *  Indexes to special options
+     */
+    { INDEX_OPT_MORE_HELP,
+      INDEX_OPT_SAVE_OPTS,
+      NO_EQUIVALENT /* index of '-#' option */,
+      NO_EQUIVALENT /* index of default opt */
+    },
+    13 /* full option count */, 8 /* user option count */
+};
+
+/*
+ *  Create the static procedure(s) declared above.
+ */
+static void
+doUsageOpt(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    USAGE( EXIT_SUCCESS );
+}
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
+
+#if defined(TEST_SNTP_OPTS) /* TEST MAIN PROCEDURE: */
+
+int
+main( int argc, char** argv )
+{
+    int res = EXIT_SUCCESS;
+    (void)optionProcess( &sntpOptions, argc, argv );
+    {
+        void optionPutShell( tOptions* );
+        optionPutShell( &sntpOptions );
+    }
+    return res;
+}
+#endif  /* defined TEST_SNTP_OPTS */
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
+
+#if ENABLE_NLS
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <autoopts/usage-txt.h>
+
+static char* AO_gettext( char const* pz );
+static void  coerce_it(void** s);
+
+static char*
+AO_gettext( char const* pz )
+{
+    char* pzRes;
+    if (pz == NULL)
+        return NULL;
+    pzRes = _(pz);
+    if (pzRes == pz)
+        return pzRes;
+    pzRes = strdup( pzRes );
+    if (pzRes == NULL) {
+        fputs( _("No memory for duping translated strings\n"), stderr );
+        exit( EXIT_FAILURE );
+    }
+    return pzRes;
+}
+
+static void coerce_it(void** s) { *s = AO_gettext(*s); }
+#define COERSION(_f) \
+  coerce_it((void*)&(sntpOptions._f))
+
+/*
+ *  This invokes the translation code (e.g. gettext(3)).
+ */
+static void
+translate_option_strings( void )
+{
+    /*
+     *  Guard against re-translation.  It won't work.  The strings will have
+     *  been changed by the first pass through this code.  One shot only.
+     */
+    if (option_usage_text.field_ct == 0)
+        return;
+    /*
+     *  Do the translations.  The first pointer follows the field count field.
+     *  The field count field is the size of a pointer.
+     */
+    {
+        char** ppz = (char**)(void*)&(option_usage_text);
+        int    ix  = option_usage_text.field_ct;
+
+        do {
+            ppz++;
+            *ppz = AO_gettext(*ppz);
+        } while (--ix > 0);
+    }
+    option_usage_text.field_ct = 0;
+
+    {
+        tOptDesc* pOD = sntpOptions.pOptDesc;
+        int       ix  = sntpOptions.optCt;
+
+        for (;;) {
+            pOD->pzText           = AO_gettext(pOD->pzText);
+            pOD->pz_NAME          = AO_gettext(pOD->pz_NAME);
+            pOD->pz_Name          = AO_gettext(pOD->pz_Name);
+            pOD->pz_DisableName   = AO_gettext(pOD->pz_DisableName);
+            pOD->pz_DisablePfx    = AO_gettext(pOD->pz_DisablePfx);
+            if (--ix <= 0)
+                break;
+            pOD++;
+        }
+    }
+    COERSION(pzCopyright);
+    COERSION(pzCopyNotice);
+    COERSION(pzFullVersion);
+    COERSION(pzUsageTitle);
+    COERSION(pzExplain);
+    COERSION(pzDetail);
+}
+
+#endif /* ENABLE_NLS */
+
+#ifdef  __cplusplus
+}
+#endif
+/* sntp-opts.c ends here */
diff --git a/sntp/sntp-opts.def b/sntp/sntp-opts.def
new file mode 100644 (file)
index 0000000..b4c7f6b
--- /dev/null
@@ -0,0 +1,327 @@
+/* -*- Mode: Text -*- */
+
+autogen definitions options;
+
+#include autogen-version.def
+
+copyright = {
+    date  = "1970-2006";
+    owner = "ntp.org";
+    eaddr = "http://bugs.ntp.org, bugs@ntp.org";
+    type  = note;
+    text  = `cat COPYRIGHT`;
+};
+
+
+prog-name      = "sntp";
+prog-title     = "standard SNTP program";
+homerc         =  $HOME, ".";
+long-opts;
+
+config-header  = "config.h";
+
+#ifndef __windows__
+rcfile         = ".ntprc";
+#else
+rcfile         = "ntp.ini";
+#endif
+
+environrc;
+
+#include version.def
+
+test-main;
+
+flag = {
+    name      = ipv4;
+    value     = 4;
+    equivalence = ipv4;
+    descrip   = "Force IPv4 DNS name resolution";
+    doc = <<-  _EndOfDoc_
+       Force DNS resolution of following host names on the command line
+       to the IPv4 namespace.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = ipv6;
+    value     = 6;
+    equivalence = ipv4;
+    descrip   = "Force IPv6 DNS name resolution";
+    doc = <<-  _EndOfDoc_
+       Force DNS resolution of following host names on the command line
+       to the IPv6 namespace.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = unprivport;
+    value     = u;
+    descrip   = "Use an unprivileged port";
+    doc = <<-  _EndOfDoc_
+       Use an unprivilegded UDP port for our queries.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = normalverbose;
+    value     = v;
+    flags-cant = extraverbose, megaverbose;
+    descrip   = "Slightly verbose";
+    doc = <<-  _EndOfDoc_
+       Diagnostic messages for non-fatal errors and a limited amount of
+       tracing should be written to standard error.  Fatal ones always
+       produce a diagnostic.  This option should be set when there is a
+       suspected problem with the server, network or the source.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = extraverbose;
+    value     = V;
+    flags-cant = normalverbose, megaverbose;
+    descrip   = "Extra verbose";
+    doc = <<-  _EndOfDoc_
+       Produce more and less comprehensible output, mainly for investigating
+       problems with apparently inconsistent timestamps.  This option should
+       be set when the program fails with a message indicating that is the
+       trouble.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = megaverbose;
+    value     = W;
+    flags-cant = normalverbose, extraverbose;
+    descrip   = "Mega verbose";
+    doc = <<-  _EndOfDoc_
+       Very verbose debugging output that will interfere with the timing
+       when writing to the terminal (because of line buffered output from C).
+       Note that the times produced by this are the corrections needed, and
+       not the error in the local clock.  This option should be set only when
+       debugging the source.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = settimeofday;
+    value     = r;
+    flags-cant = adjtime;
+    descrip   = "Set (step) the time with settimeofday()";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = adjtime;
+    value     = a;
+    flags-cant = settimeofday;
+    descrip   = "Set (slew) the time with adjtime()";
+    doc = <<-  _EndOfDoc_
+       _EndOfDoc_;
+};
+
+detail = <<-  _END_DETAIL
+.I sntp
+can be used as a SNTP client to query a NTP or SNTP server and either display
+the time or set the local system's time (given suitable privilege).  It can be
+run as an interactive command or in a
+.I cron
+job.
+NTP is the Network Time Protocol (RFC 1305) and SNTP is the
+Simple Network Time Protocol (RFC 2030, which supersedes RFC 1769).
+       _END_DETAIL;
+
+prog-man-descrip = <<-  _END_PROG_MAN_DESCRIP
+.I sntp
+can be used as a SNTP client to query a NTP or SNTP server and either display
+the time or set the local system's time (given suitable privilege).  It can be
+run as an interactive command or in a
+.I cron
+job.
+NTP is the Network Time Protocol (RFC 1305) and SNTP is the
+Simple Network Time Protocol (RFC 2030, which supersedes RFC 1769).
+.SS Options
+.PP
+.I sntp
+recognizes the following options:
+.TP
+.B \-v
+indicates that diagnostic messages for non-fatal errors and a limited amount of
+tracing should be written to standard error.  Fatal ones always produce a
+diagnostic.  This option should be set when there is a suspected problem with
+the server, network or the source.
+.TP
+.B \-V
+requests more and less comprehensible output, mainly for investigating problems
+with apparently inconsistent timestamps.  This option should be set when the
+program fails with a message indicating that is the trouble.
+.TP
+.B \-W
+requests very verbose debugging output, and will interfere with the timing
+when writing to the terminal (because of line buffered output from C).  Note
+that the times produced by this are the corrections needed, and not the error
+in the local clock.  This option should be set only when debugging the source.
+.TP
+.B \-q
+indicates that it should query a daemon save file being maintained by it.
+This needs no privilege and will change neither the save file nor the clock.
+.PP
+The default is that it should behave as a client, and the following options
+are then relevant:
+.TP
+.B \-r
+indicates that the system clock should be reset by
+.IR settimeofday .
+Naturally, this will work only if the user has enough privilege.
+.TP
+.B \-a
+indicates that the system clock should be reset by
+.IR adjtime .
+Naturally, this will work only if the user has enough privilege.
+.PP
+The default is to write the estimated correct local date and time (i.e. not
+UTC) to the standard output in a format like
+.BR "'1996 Oct 15 20:17:25.123 + 4.567 +/- 0.089 secs'" ,
+where the
+.B "'+ 4.567 +/- 0.089 secs'"
+indicates the estimated error in the time on the local system.
+.TP
+.BI \-l " lockfile"
+sets the name of the lock file to ensure that there is only
+one copy of
+.I sntp
+running at once.  The default is installation-dependent, but will usually be
+.IR /etc/sntp.pid .
+.TP
+.BI \-e " minerr"
+sets the maximum ignorable variation between the clocks to
+.IR minerr .
+Acceptable values are from 0.001 to 1, and the default is 0.1 if a NTP host is
+is specified and 0.5 otherwise.
+.TP
+.BI \-E " maxerr"
+sets the maximum value of various delays that are deemed acceptable to
+.IR maxerr .
+Acceptable values are from 1 to 60, and the default is 5.  It should sometimes
+be increased if there are problems with the network, NTP server or system
+clock, but take care.
+.TP
+.BI \-P  " prompt"
+sets the maximum clock change that will be made automatically to
+.IR maxerr .
+Acceptable values are from 1 to 3600 or
+.IR no ,
+and the default is 30.  If the program is being run interactively in ordinary
+client mode, and the system clock is to be changed, larger corrections will
+prompt the user for confirmation.  Specifying
+.I no
+will disable this and the correction will be made regardless.
+.TP
+.BI \-c " count"
+sets the maximum number of NTP packets required to
+.IR count .
+Acceptable values are from 1 to 25 if a NTP host is specified and from 5 to 25
+otherwise, and the default is 5.  If the maximum isn't enough, the system needs
+a better consistency algorithm than this program uses.
+.TP
+.BI \-d " delay"
+sets a rough limit on the total running time to
+.I delay
+seconds.  Acceptable values are from 1 to 3600, and the default is 15 if a NTP
+host is specified and 300 otherwise.
+.TP
+.B -4
+force IPv4 DNS resolution.
+.TP
+.B -6
+force IPv6 DNS resolution.
+.PP
+.B address(es)
+are the DNS names or IP numbers of hosts to use for the challenge and response
+protocol; if no names are given, the program waits for broadcasts.  Polling a
+server is vastly more reliable than listening to broadcasts.  Note that a
+single component numeric address is not allowed, to avoid ambiguities.  If
+more than one name is give, they will be used in a round-robin fashion.
+.PP
+Constraints:
+.IP
+.B minerr
+must be less than
+.B maxerr
+which must be less than
+.B delay
+(or, if a NTP host is not specified
+.BR delay / count "),"
+and
+.B count
+must be less than half of
+.BR delay .
+.IP
+In update mode,
+.B maxerr
+must be less than
+.BR prompt.
+.PP
+Note that none of the above values are closely linked to the limits described
+in the NTP protocol (RFC 1305).
+.SH USAGE
+The simplest use of this program is as an unprivileged command to check the
+current time and error in the local clock.  For example:
+.IP
+.B sntp ntpserver.somewhere
+.PP
+With suitable privilege, it can be run as a command or in a
+.I cron
+job to reset the local clock from a reliable server, like the
+.I ntpdate
+and
+.I rdate
+commands.  For example:
+.IP
+.B sntp -a ntpserver.somewhere
+.PP
+More information on how to use this utility is given in the
+.I README
+file in the distribution.  In particular, this
+.I man
+page does not describe how to set it up as a server, which needs special care
+to avoid propagating misinformation.
+.SH RETURN VALUE
+When used as a client in non-daemon mode, the program returns a zero exit
+status for success, and a non-zero one otherwise. When used as a daemon
+(either client or server), it does not return except after a serious error.
+.SH BUGS
+The program implements the SNTP protocol, and does not provide all NTP 
+facilities.  In particular, it contains no checks against any form of spoofing.
+If this is a serious concern, some network security mechanism (like a firewall
+or even just
+.IR tcpwrappers )
+should be installed.
+.PP
+There are some errors, ambiguities and inconsistencies in the RFCs, and this
+code may not interwork with all other NTP implementations.  Any unreasonable
+restrictions should be reported as bugs to whoever is responsible.  It may
+be difficult to find out who that is.
+.PP
+The program will stop as soon as it feels that things have got out of control.
+In client daemon mode, it will usually fail during an extended period of
+network or server inaccessibility or excessively slow performance, or when the
+local clock is reset by another process.  It will then need restarting
+manually.  Experienced system administrators can write a shell script, a
+.I cron
+job or put it in
+.IR inittab ,
+to do this automatically.
+.PP
+The error cannot be estimated reliably with broadcast packets or for the drift
+in daemon mode (even with client-server packets), and the guess made by the
+program may be wrong (possibly even very wrong).  If this is a problem, then
+setting the
+.B \-c
+option to a larger value may help.  Or it may not.
+.SH AUTHOR
+.I sntp
+was developed by N.M. Maclaren of the University of Cambridge Computing
+Service.
+       _END_PROG_MAN_DESCRIP;
diff --git a/sntp/sntp-opts.h b/sntp/sntp-opts.h
new file mode 100644 (file)
index 0000000..e73737a
--- /dev/null
@@ -0,0 +1,283 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (sntp-opts.h)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:49 AM EST
+ *  From the definitions    sntp-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This header file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  sntp author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * sntp copyright 1970-2006 ntp.org - all rights reserved
+ *
+ *         General Public Licence for the software known as MSNTP
+ *         ------------------------------------------------------
+ * 
+ *       (c) Copyright, N.M. Maclaren, 1996, 1997, 2000
+ *       (c) Copyright, University of Cambridge, 1996, 1997, 2000
+ * 
+ * 
+ * 
+ * Free use of MSNTP in source and binary forms is permitted, provided that this
+ * entire licence is duplicated in all copies, and that any documentation,
+ * announcements, and other materials related to use acknowledge that the software
+ * was developed by N.M. Maclaren (hereafter refered to as the Author) at the
+ * University of Cambridge.  Neither the name of the Author nor the University of
+ * Cambridge may be used to endorse or promote products derived from this material
+ * without specific prior written permission.
+ * 
+ * The Author and the University of Cambridge retain the copyright and all other
+ * legal rights to the software and make it available non-exclusively.  All users
+ * must ensure that the software in all its derivations carries a copyright notice
+ * in the form:
+ *       (c) Copyright N.M. Maclaren,
+ *       (c) Copyright University of Cambridge.
+ * 
+ * 
+ * 
+ *                            NO WARRANTY
+ * 
+ * Because the MSNTP software is licensed free of charge, the Author and the
+ * University of Cambridge provide absolutely no warranty, either expressed or
+ * implied, including, but not limited to, the implied warranties of
+ * merchantability and fitness for a particular purpose.  The entire risk as to
+ * the quality and performance of the MSNTP software is with you.  Should MSNTP
+ * prove defective, you assume the cost of all necessary servicing or repair.
+ * 
+ * In no event, unless required by law, will the Author or the University of
+ * Cambridge, or any other party who may modify and redistribute this software as
+ * permitted in accordance with the provisions below, be liable for damages for
+ * any losses whatsoever, including but not limited to lost profits, lost monies,
+ * lost or corrupted data, or other special, incidental or consequential losses
+ * that may arise out of the use or inability to use the MSNTP software.
+ * 
+ * 
+ * 
+ *                          COPYING POLICY
+ * 
+ * Permission is hereby granted for copying and distribution of copies of the
+ * MSNTP source and binary files, and of any part thereof, subject to the
+ * following licence conditions:
+ * 
+ * 1. You may distribute MSNTP or components of MSNTP, with or without additions
+ * developed by you or by others.  No charge, other than an "at-cost" distribution
+ * fee, may be charged for copies, derivations, or distributions of this material
+ * without the express written consent of the copyright holders.
+ * 
+ * 2. You may also distribute MSNTP along with any other product for sale,
+ * provided that the cost of the bundled package is the same regardless of whether
+ * MSNTP is included or not, and provided that those interested only in MSNTP must
+ * be notified that it is a product freely available from the University of
+ * Cambridge.
+ * 
+ * 3. If you distribute MSNTP software or parts of MSNTP, with or without
+ * additions developed by you or others, then you must either make available the
+ * source to all portions of the MSNTP system (exclusive of any additions made by
+ * you or by others) upon request, or instead you may notify anyone requesting
+ * source that it is freely available from the University of Cambridge.
+ * 
+ * 4. You may not omit any of the copyright notices on either the source files,
+ * the executable files, or the documentation.
+ * 
+ * 5. You may not omit transmission of this License agreement with whatever
+ * portions of MSNTP that are distributed.
+ * 
+ * 6. Any users of this software must be notified that it is without warranty or
+ * guarantee of any nature, express or implied, nor is there any fitness for use
+ * represented.
+ * 
+ * 
+ * October 1996
+ * April 1997
+ * October 2000
+ */
+/*
+ *  This file contains the programmatic interface to the Automated
+ *  Options generated for the sntp program.
+ *  These macros are documented in the AutoGen info file in the
+ *  "AutoOpts" chapter.  Please refer to that doc for usage help.
+ */
+#ifndef AUTOOPTS_SNTP_OPTS_H_GUARD
+#define AUTOOPTS_SNTP_OPTS_H_GUARD
+#include "config.h"
+#include <autoopts/options.h>
+
+/*
+ *  Ensure that the library used for compiling this generated header is at
+ *  least as new as the version current when the header template was released
+ *  (not counting patch version increments).  Also ensure that the oldest
+ *  tolerable version is at least as old as what was current when the header
+ *  template was released.
+ */
+#define AO_TEMPLATE_VERSION 118784
+#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
+ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
+# error option template version mismatches autoopts/options.h header
+  Choke Me.
+#endif
+
+/*
+ *  Enumeration of each option:
+ */
+typedef enum {
+        INDEX_OPT_IPV4             =  0,
+        INDEX_OPT_IPV6             =  1,
+        INDEX_OPT_UNPRIVPORT       =  2,
+        INDEX_OPT_NORMALVERBOSE    =  3,
+        INDEX_OPT_EXTRAVERBOSE     =  4,
+        INDEX_OPT_MEGAVERBOSE      =  5,
+        INDEX_OPT_SETTIMEOFDAY     =  6,
+        INDEX_OPT_ADJTIME          =  7,
+        INDEX_OPT_VERSION          = 8,
+        INDEX_OPT_HELP             = 9,
+        INDEX_OPT_MORE_HELP        = 10,
+        INDEX_OPT_SAVE_OPTS        = 11,
+        INDEX_OPT_LOAD_OPTS        = 12
+} teOptIndex;
+
+#define OPTION_CT    13
+#define SNTP_VERSION       "4.2.4p8"
+#define SNTP_FULL_VERSION  "sntp - standard SNTP program - Ver. 4.2.4p8"
+
+/*
+ *  Interface defines for all options.  Replace "n" with the UPPER_CASED
+ *  option name (as in the teOptIndex enumeration above).
+ *  e.g. HAVE_OPT( IPV4 )
+ */
+#define         DESC(n) (sntpOptions.pOptDesc[INDEX_OPT_## n])
+#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
+#define      OPT_ARG(n) (DESC(n).optArg.argString)
+#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
+#define    COUNT_OPT(n) (DESC(n).optOccCt)
+#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
+#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
+#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
+#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
+#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
+#define    CLEAR_OPT(n) STMTS( \
+                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
+                if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
+                    DESC(n).fOptState |= OPTST_DISABLED; \
+                DESC(n).optCookie = NULL )
+
+/*
+ *  Make sure there are no #define name conflicts with the option names
+ */
+#ifndef     NO_OPTION_NAME_WARNINGS
+# ifdef    IPV4
+#  warning undefining IPV4 due to option name conflict
+#  undef   IPV4
+# endif
+# ifdef    IPV6
+#  warning undefining IPV6 due to option name conflict
+#  undef   IPV6
+# endif
+# ifdef    UNPRIVPORT
+#  warning undefining UNPRIVPORT due to option name conflict
+#  undef   UNPRIVPORT
+# endif
+# ifdef    NORMALVERBOSE
+#  warning undefining NORMALVERBOSE due to option name conflict
+#  undef   NORMALVERBOSE
+# endif
+# ifdef    EXTRAVERBOSE
+#  warning undefining EXTRAVERBOSE due to option name conflict
+#  undef   EXTRAVERBOSE
+# endif
+# ifdef    MEGAVERBOSE
+#  warning undefining MEGAVERBOSE due to option name conflict
+#  undef   MEGAVERBOSE
+# endif
+# ifdef    SETTIMEOFDAY
+#  warning undefining SETTIMEOFDAY due to option name conflict
+#  undef   SETTIMEOFDAY
+# endif
+# ifdef    ADJTIME
+#  warning undefining ADJTIME due to option name conflict
+#  undef   ADJTIME
+# endif
+#else  /* NO_OPTION_NAME_WARNINGS */
+# undef IPV4
+# undef IPV6
+# undef UNPRIVPORT
+# undef NORMALVERBOSE
+# undef EXTRAVERBOSE
+# undef MEGAVERBOSE
+# undef SETTIMEOFDAY
+# undef ADJTIME
+#endif  /*  NO_OPTION_NAME_WARNINGS */
+
+/*
+ *  Interface defines for specific options.
+ */
+#define VALUE_OPT_IPV4           '4'
+#define WHICH_OPT_IPV4           (DESC(IPV4).optActualValue)
+#define WHICH_IDX_IPV4           (DESC(IPV4).optActualIndex)
+#define VALUE_OPT_IPV6           '6'
+#define VALUE_OPT_UNPRIVPORT     'u'
+#define VALUE_OPT_NORMALVERBOSE  'v'
+#define VALUE_OPT_EXTRAVERBOSE   'V'
+#define VALUE_OPT_MEGAVERBOSE    'W'
+#define VALUE_OPT_SETTIMEOFDAY   'r'
+#define VALUE_OPT_ADJTIME        'a'
+
+#define VALUE_OPT_VERSION       'v'
+#define VALUE_OPT_HELP          '?'
+#define VALUE_OPT_MORE_HELP     '!'
+#define VALUE_OPT_SAVE_OPTS     '>'
+#define VALUE_OPT_LOAD_OPTS     '<'
+#define SET_OPT_SAVE_OPTS(a)   STMTS( \
+        DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
+        DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
+        DESC(SAVE_OPTS).optArg.argString = (char const*)(a) )
+/*
+ *  Interface defines not associated with particular options
+ */
+#define ERRSKIP_OPTERR  STMTS( sntpOptions.fOptSet &= ~OPTPROC_ERRSTOP )
+#define ERRSTOP_OPTERR  STMTS( sntpOptions.fOptSet |= OPTPROC_ERRSTOP )
+#define RESTART_OPT(n)  STMTS( \
+                sntpOptions.curOptIdx = (n); \
+                sntpOptions.pzCurOpt  = NULL )
+#define START_OPT       RESTART_OPT(1)
+#define USAGE(c)        (*sntpOptions.pUsageProc)( &sntpOptions, c )
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/opthead.tpl near line 360 */
+
+/* * * * * *
+ *
+ *  Declare the sntp option descriptor.
+ */
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+extern tOptions   sntpOptions;
+
+#ifndef _
+#  if ENABLE_NLS
+#    include <stdio.h>
+     static inline char* aoGetsText( char const* pz ) {
+         if (pz == NULL) return NULL;
+         return (char*)gettext( pz );
+     }
+#    define _(s)  aoGetsText(s)
+#  else  /* ENABLE_NLS */
+#    define _(s)  s
+#  endif /* ENABLE_NLS */
+#endif
+
+#ifdef  __cplusplus
+}
+#endif
+#endif /* AUTOOPTS_SNTP_OPTS_H_GUARD */
+/* sntp-opts.h ends here */
diff --git a/sntp/sntp-opts.menu b/sntp/sntp-opts.menu
new file mode 100644 (file)
index 0000000..e3c8d81
--- /dev/null
@@ -0,0 +1 @@
+* sntp Invocation::                Invoking sntp
diff --git a/sntp/sntp-opts.texi b/sntp/sntp-opts.texi
new file mode 100644 (file)
index 0000000..7ba2e21
--- /dev/null
@@ -0,0 +1,225 @@
+@node sntp Invocation
+@section Invoking sntp
+@pindex sntp
+@cindex standard SNTP program
+@ignore
+# 
+# EDIT THIS FILE WITH CAUTION  (sntp-opts.texi)
+# 
+# It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:51 AM EST
+# From the definitions    sntp-opts.def
+# and the template file   aginfo.tpl
+@end ignore
+This program has no explanation.
+
+.I sntp
+can be used as a SNTP client to query a NTP or SNTP server and either display
+the time or set the local system's time (given suitable privilege).  It can be
+run as an interactive command or in a
+.I cron
+job.
+NTP is the Network Time Protocol (RFC 1305) and SNTP is the
+Simple Network Time Protocol (RFC 2030, which supersedes RFC 1769).
+
+This section was generated by @strong{AutoGen},
+the aginfo template and the option descriptions for the @command{sntp} program.  It documents the sntp usage text and option meanings.
+
+This software is released under a specialized copyright license.
+
+@menu
+* sntp usage::                  sntp usage help (-?)
+* sntp adjtime::                adjtime option (-a)
+* sntp extraverbose::           extraverbose option (-V)
+* sntp ipv4::                   ipv4 option (-4)
+* sntp ipv6::                   ipv6 option (-6)
+* sntp megaverbose::            megaverbose option (-W)
+* sntp normalverbose::          normalverbose option (-v)
+* sntp settimeofday::           settimeofday option (-r)
+* sntp unprivport::             unprivport option (-u)
+@end menu
+
+@node sntp usage
+@subsection sntp usage help (-?)
+@cindex sntp usage
+
+This is the automatically generated usage text for sntp:
+
+@exampleindent 0
+@example
+sntp - standard SNTP program - Ver. 4.2.5p247-RC
+USAGE:  sntp [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]... ...
+  Flg Arg Option-Name    Description
+   -4 no  ipv4           Force IPv4 DNS name resolution
+                                - prohibits these options:
+                                ipv6
+   -6 no  ipv6           Force IPv6 DNS name resolution
+                                - prohibits these options:
+                                ipv4
+   -d no  normalverbose  Normal verbose
+   -K Str kod            KoD history filename
+   -p no  syslog         Logging with syslog
+                                - prohibits these options:
+                                filelog
+   -l Str filelog        Logging to specified logfile
+                                - prohibits these options:
+                                syslog
+   -s no  settod         Set (step) the time with settimeofday()
+                                - prohibits these options:
+                                adjtime
+   -j no  adjtime        Set (slew) the time with adjtime()
+                                - prohibits these options:
+                                settod
+   -b Str broadcast      Use broadcasts to the address specified for synchronisation
+   -t Num timeout        Specify the number of seconds to wait for broadcasts
+   -a Num authentication Enable authentication with the key keyno. This option is used as -a keyno
+   -k Str keyfile        Specify a keyfile. SNTP will look in this file for the key specified with -a
+      opt version        Output version information and exit
+   -? no  help           Display extended usage information and exit
+   -! no  more-help      Extended usage information passed thru pager
+   -> opt save-opts      Save the option state to a config file
+   -< Str load-opts      Load options from a config file
+                                - disabled as --no-load-opts
+                                - may appear multiple times
+
+Options are specified by doubled hyphens and their name
+or by a single hyphen and the flag character.
+
+The following option preset mechanisms are supported:
+ - reading file /users/stenn/.ntprc
+ - reading file /deacon/backroom/snaps/ntp-stable/sntp/.ntprc
+ - examining environment variables named SNTP_*
+
+.I sntp
+can be used as a SNTP client to query a NTP or SNTP server and either display
+the time or set the local system's time (given suitable privilege).  It can be
+run as an interactive command or in a
+.I cron
+job.
+NTP is the Network Time Protocol (RFC 1305) and SNTP is the
+Simple Network Time Protocol (RFC 2030, which supersedes RFC 1769).
+
+please send bug reports to:  http://bugs.ntp.org, bugs@@ntp.org
+@end example
+@exampleindent 4
+
+@node sntp ipv4
+@subsection ipv4 option (-4)
+@cindex sntp-ipv4
+
+This is the ``force ipv4 dns name resolution'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is a member of the ipv4 class of options.
+@end itemize
+
+Force DNS resolution of following host names on the command line
+to the IPv4 namespace.
+
+@node sntp ipv6
+@subsection ipv6 option (-6)
+@cindex sntp-ipv6
+
+This is the ``force ipv6 dns name resolution'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+is a member of the ipv4 class of options.
+@end itemize
+
+Force DNS resolution of following host names on the command line
+to the IPv6 namespace.
+
+@node sntp unprivport
+@subsection unprivport option (-u)
+@cindex sntp-unprivport
+
+This is the ``use an unprivileged port'' option.
+Use an unprivilegded UDP port for our queries.
+
+@node sntp normalverbose
+@subsection normalverbose option (-v)
+@cindex sntp-normalverbose
+
+This is the ``slightly verbose'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+extraverbose, megaverbose.
+@end itemize
+
+Diagnostic messages for non-fatal errors and a limited amount of
+tracing should be written to standard error.  Fatal ones always
+produce a diagnostic.  This option should be set when there is a
+suspected problem with the server, network or the source.
+
+@node sntp extraverbose
+@subsection extraverbose option (-V)
+@cindex sntp-extraverbose
+
+This is the ``extra verbose'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+normalverbose, megaverbose.
+@end itemize
+
+Produce more and less comprehensible output, mainly for investigating
+problems with apparently inconsistent timestamps.  This option should
+be set when the program fails with a message indicating that is the
+trouble.
+
+@node sntp megaverbose
+@subsection megaverbose option (-W)
+@cindex sntp-megaverbose
+
+This is the ``mega verbose'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+normalverbose, extraverbose.
+@end itemize
+
+Very verbose debugging output that will interfere with the timing
+when writing to the terminal (because of line buffered output from C).
+Note that the times produced by this are the corrections needed, and
+not the error in the local clock.  This option should be set only when
+debugging the source.
+
+@node sntp settimeofday
+@subsection settimeofday option (-r)
+@cindex sntp-settimeofday
+
+This is the ``set (step) the time with settimeofday()'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+adjtime.
+@end itemize
+
+
+
+@node sntp adjtime
+@subsection adjtime option (-a)
+@cindex sntp-adjtime
+
+This is the ``set (slew) the time with adjtime()'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must not appear in combination with any of the following options:
+settimeofday.
+@end itemize
+
+
diff --git a/sntp/sntp.1 b/sntp/sntp.1
new file mode 100644 (file)
index 0000000..20c7d80
--- /dev/null
@@ -0,0 +1,400 @@
+.TH SNTP 1 2009-12-08 "( 4.2.4p8)" "Programmer's Manual"
+.\"  EDIT THIS FILE WITH CAUTION  (sntp.1)
+.\"  
+.\"  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:50 AM EST
+.\"  From the definitions    sntp-opts.def
+.\"  and the template file   agman1.tpl
+.\"
+.SH NAME
+sntp \- standard SNTP program
+.SH SYNOPSIS
+.B sntp
+.\" Mixture of short (flag) options and long options
+.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..."
+.PP
+All arguments must be options.
+.SH "DESCRIPTION"
+This manual page documents, briefly, the \fBsntp\fP command.
+.I sntp
+can be used as a SNTP client to query a NTP or SNTP server and either display
+the time or set the local system's time (given suitable privilege).  It can be
+run as an interactive command or in a
+.I cron
+job.
+NTP is the Network Time Protocol (RFC 1305) and SNTP is the
+Simple Network Time Protocol (RFC 2030, which supersedes RFC 1769).
+.SS Options
+.PP
+.I sntp
+recognizes the following options:
+.TP
+.B \-v
+indicates that diagnostic messages for non-fatal errors and a limited amount of
+tracing should be written to standard error.  Fatal ones always produce a
+diagnostic.  This option should be set when there is a suspected problem with
+the server, network or the source.
+.TP
+.B \-V
+requests more and less comprehensible output, mainly for investigating problems
+with apparently inconsistent timestamps.  This option should be set when the
+program fails with a message indicating that is the trouble.
+.TP
+.B \-W
+requests very verbose debugging output, and will interfere with the timing
+when writing to the terminal (because of line buffered output from C).  Note
+that the times produced by this are the corrections needed, and not the error
+in the local clock.  This option should be set only when debugging the source.
+.TP
+.B \-q
+indicates that it should query a daemon save file being maintained by it.
+This needs no privilege and will change neither the save file nor the clock.
+.PP
+The default is that it should behave as a client, and the following options
+are then relevant:
+.TP
+.B \-r
+indicates that the system clock should be reset by
+.IR settimeofday .
+Naturally, this will work only if the user has enough privilege.
+.TP
+.B \-a
+indicates that the system clock should be reset by
+.IR adjtime .
+Naturally, this will work only if the user has enough privilege.
+.PP
+The default is to write the estimated correct local date and time (i.e. not
+UTC) to the standard output in a format like
+.BR "'1996 Oct 15 20:17:25.123 + 4.567 +/- 0.089 secs'" ,
+where the
+.B "'+ 4.567 +/- 0.089 secs'"
+indicates the estimated error in the time on the local system.
+.TP
+.BI \-l " lockfile"
+sets the name of the lock file to ensure that there is only
+one copy of
+.I sntp
+running at once.  The default is installation-dependent, but will usually be
+.IR /etc/sntp.pid .
+.TP
+.BI \-e " minerr"
+sets the maximum ignorable variation between the clocks to
+.IR minerr .
+Acceptable values are from 0.001 to 1, and the default is 0.1 if a NTP host is
+is specified and 0.5 otherwise.
+.TP
+.BI \-E " maxerr"
+sets the maximum value of various delays that are deemed acceptable to
+.IR maxerr .
+Acceptable values are from 1 to 60, and the default is 5.  It should sometimes
+be increased if there are problems with the network, NTP server or system
+clock, but take care.
+.TP
+.BI \-P  " prompt"
+sets the maximum clock change that will be made automatically to
+.IR maxerr .
+Acceptable values are from 1 to 3600 or
+.IR no ,
+and the default is 30.  If the program is being run interactively in ordinary
+client mode, and the system clock is to be changed, larger corrections will
+prompt the user for confirmation.  Specifying
+.I no
+will disable this and the correction will be made regardless.
+.TP
+.BI \-c " count"
+sets the maximum number of NTP packets required to
+.IR count .
+Acceptable values are from 1 to 25 if a NTP host is specified and from 5 to 25
+otherwise, and the default is 5.  If the maximum isn't enough, the system needs
+a better consistency algorithm than this program uses.
+.TP
+.BI \-d " delay"
+sets a rough limit on the total running time to
+.I delay
+seconds.  Acceptable values are from 1 to 3600, and the default is 15 if a NTP
+host is specified and 300 otherwise.
+.TP
+.B \-4
+force IPv4 DNS resolution.
+.TP
+.B \-6
+force IPv6 DNS resolution.
+.PP
+.B address(es)
+are the DNS names or IP numbers of hosts to use for the challenge and response
+protocol; if no names are given, the program waits for broadcasts.  Polling a
+server is vastly more reliable than listening to broadcasts.  Note that a
+single component numeric address is not allowed, to avoid ambiguities.  If
+more than one name is give, they will be used in a round-robin fashion.
+.PP
+Constraints:
+.IP
+.B minerr
+must be less than
+.B maxerr
+which must be less than
+.B delay
+(or, if a NTP host is not specified
+.BR delay / count "),"
+and
+.B count
+must be less than half of
+.BR delay .
+.IP
+In update mode,
+.B maxerr
+must be less than
+.BR prompt.
+.PP
+Note that none of the above values are closely linked to the limits described
+in the NTP protocol (RFC 1305).
+.SH USAGE
+The simplest use of this program is as an unprivileged command to check the
+current time and error in the local clock.  For example:
+.IP
+.B sntp ntpserver.somewhere
+.PP
+With suitable privilege, it can be run as a command or in a
+.I cron
+job to reset the local clock from a reliable server, like the
+.I ntpdate
+and
+.I rdate
+commands.  For example:
+.IP
+.B sntp \-a ntpserver.somewhere
+.PP
+More information on how to use this utility is given in the
+.I README
+file in the distribution.  In particular, this
+.I man
+page does not describe how to set it up as a server, which needs special care
+to avoid propagating misinformation.
+.SH RETURN VALUE
+When used as a client in non-daemon mode, the program returns a zero exit
+status for success, and a non-zero one otherwise. When used as a daemon
+(either client or server), it does not return except after a serious error.
+.SH BUGS
+The program implements the SNTP protocol, and does not provide all NTP 
+facilities.  In particular, it contains no checks against any form of spoofing.
+If this is a serious concern, some network security mechanism (like a firewall
+or even just
+.IR tcpwrappers )
+should be installed.
+.PP
+There are some errors, ambiguities and inconsistencies in the RFCs, and this
+code may not interwork with all other NTP implementations.  Any unreasonable
+restrictions should be reported as bugs to whoever is responsible.  It may
+be difficult to find out who that is.
+.PP
+The program will stop as soon as it feels that things have got out of control.
+In client daemon mode, it will usually fail during an extended period of
+network or server inaccessibility or excessively slow performance, or when the
+local clock is reset by another process.  It will then need restarting
+manually.  Experienced system administrators can write a shell script, a
+.I cron
+job or put it in
+.IR inittab ,
+to do this automatically.
+.PP
+The error cannot be estimated reliably with broadcast packets or for the drift
+in daemon mode (even with client-server packets), and the guess made by the
+program may be wrong (possibly even very wrong).  If this is a problem, then
+setting the
+.B \-c
+option to a larger value may help.  Or it may not.
+.SH AUTHOR
+.I sntp
+was developed by N.M. Maclaren of the University of Cambridge Computing
+Service.
+.SH OPTIONS
+.TP
+.BR \-4 ", " \--ipv4
+Force IPv4 DNS name resolution.
+This option is a member of the ipv4 class of options.
+.sp
+Force DNS resolution of following host names on the command line
+to the IPv4 namespace.
+.TP
+.BR \-6 ", " \--ipv6
+Force IPv6 DNS name resolution.
+This option is a member of the ipv4 class of options.
+.sp
+Force DNS resolution of following host names on the command line
+to the IPv6 namespace.
+.TP
+.BR \-u ", " \--unprivport
+Use an unprivileged port.
+.sp
+Use an unprivilegded UDP port for our queries.
+.TP
+.BR \-v ", " \--normalverbose
+Slightly verbose.
+This option must not appear in combination with any of the following options:
+extraverbose, megaverbose.
+.sp
+Diagnostic messages for non-fatal errors and a limited amount of
+tracing should be written to standard error.  Fatal ones always
+produce a diagnostic.  This option should be set when there is a
+suspected problem with the server, network or the source.
+.TP
+.BR \-V ", " \--extraverbose
+Extra verbose.
+This option must not appear in combination with any of the following options:
+normalverbose, megaverbose.
+.sp
+Produce more and less comprehensible output, mainly for investigating
+problems with apparently inconsistent timestamps.  This option should
+be set when the program fails with a message indicating that is the
+trouble.
+.TP
+.BR \-W ", " \--megaverbose
+Mega verbose.
+This option must not appear in combination with any of the following options:
+normalverbose, extraverbose.
+.sp
+Very verbose debugging output that will interfere with the timing
+when writing to the terminal (because of line buffered output from C).
+Note that the times produced by this are the corrections needed, and
+not the error in the local clock.  This option should be set only when
+debugging the source.
+.TP
+.BR \-r ", " \--settimeofday
+Set (step) the time with settimeofday().
+This option must not appear in combination with any of the following options:
+adjtime.
+.sp
+
+.TP
+.BR \-a ", " \--adjtime
+Set (slew) the time with adjtime().
+This option must not appear in combination with any of the following options:
+settimeofday.
+.sp
+
+.TP
+.BR \-? , " \--help"
+Display usage information and exit.
+.TP
+.BR \-! , " \--more-help"
+Extended usage information passed thru pager.
+.TP
+.BR \-> " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]"
+Save the option state to \fIrcfile\fP.  The default is the \fIlast\fP
+configuration file listed in the \fBOPTION PRESETS\fP section, below.
+.TP
+.BR \-< " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts"
+Load options from \fIrcfile\fP.
+The \fIno-load-opts\fP form will disable the loading
+of earlier RC/INI files.  \fI--no-load-opts\fP is handled early,
+out of order.
+.TP
+.BR \-v " [{\fIv|c|n\fP}]," " \--version" "[=\fI{v|c|n}\fP]"
+Output version of program and exit.  The default mode is `v', a simple
+version.  The `c' mode will print copyright information and `n' will
+print the full copyright notice.
+.SH OPTION PRESETS
+Any option that is not marked as \fInot presettable\fP may be preset
+by loading values from configuration ("RC" or ".INI") file(s) and values from
+environment variables named:
+.nf
+  \fBSNTP_<option-name>\fP or \fBSNTP\fP
+.fi
+.aj
+The environmental presets take precedence (are processed later than)
+the configuration files.
+The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP".
+If any of these are directories, then the file \fI.ntprc\fP
+is searched for within those directories.
+.SH AUTHOR
+ntp.org
+.br
+Please send bug reports to:  http://bugs.ntp.org, bugs@ntp.org
+
+.PP
+.nf
+.na
+        General Public Licence for the software known as MSNTP
+        \------------------------------------------------------
+
+         (c) Copyright, N.M. Maclaren, 1996, 1997, 2000
+         (c) Copyright, University of Cambridge, 1996, 1997, 2000
+
+
+
+Free use of MSNTP in source and binary forms is permitted, provided that this
+entire licence is duplicated in all copies, and that any documentation,
+announcements, and other materials related to use acknowledge that the software
+was developed by N.M. Maclaren (hereafter refered to as the Author) at the
+University of Cambridge.  Neither the name of the Author nor the University of
+Cambridge may be used to endorse or promote products derived from this material
+without specific prior written permission.
+
+The Author and the University of Cambridge retain the copyright and all other
+legal rights to the software and make it available non-exclusively.  All users
+must ensure that the software in all its derivations carries a copyright notice
+in the form:
+         (c) Copyright N.M. Maclaren,
+         (c) Copyright University of Cambridge.
+
+
+
+                           NO WARRANTY
+
+Because the MSNTP software is licensed free of charge, the Author and the
+University of Cambridge provide absolutely no warranty, either expressed or
+implied, including, but not limited to, the implied warranties of
+merchantability and fitness for a particular purpose.  The entire risk as to
+the quality and performance of the MSNTP software is with you.  Should MSNTP
+prove defective, you assume the cost of all necessary servicing or repair.
+
+In no event, unless required by law, will the Author or the University of
+Cambridge, or any other party who may modify and redistribute this software as
+permitted in accordance with the provisions below, be liable for damages for
+any losses whatsoever, including but not limited to lost profits, lost monies,
+lost or corrupted data, or other special, incidental or consequential losses
+that may arise out of the use or inability to use the MSNTP software.
+
+
+
+                         COPYING POLICY
+
+Permission is hereby granted for copying and distribution of copies of the
+MSNTP source and binary files, and of any part thereof, subject to the
+following licence conditions:
+
+1. You may distribute MSNTP or components of MSNTP, with or without additions
+developed by you or by others.  No charge, other than an "at-cost" distribution
+fee, may be charged for copies, derivations, or distributions of this material
+without the express written consent of the copyright holders.
+
+2. You may also distribute MSNTP along with any other product for sale,
+provided that the cost of the bundled package is the same regardless of whether
+MSNTP is included or not, and provided that those interested only in MSNTP must
+be notified that it is a product freely available from the University of
+Cambridge.
+
+3. If you distribute MSNTP software or parts of MSNTP, with or without
+additions developed by you or others, then you must either make available the
+source to all portions of the MSNTP system (exclusive of any additions made by
+you or by others) upon request, or instead you may notify anyone requesting
+source that it is freely available from the University of Cambridge.
+
+4. You may not omit any of the copyright notices on either the source files,
+the executable files, or the documentation.
+
+5. You may not omit transmission of this License agreement with whatever
+portions of MSNTP that are distributed.
+
+6. Any users of this software must be notified that it is without warranty or
+guarantee of any nature, express or implied, nor is there any fitness for use
+represented.
+
+
+October 1996
+April 1997
+October 2000
+.fi
+.ad
+.PP
+This manual page was \fIAutoGen\fP-erated from the \fBsntp\fP
+option definitions.
diff --git a/sntp/socket.c b/sntp/socket.c
new file mode 100644 (file)
index 0000000..02fabb8
--- /dev/null
@@ -0,0 +1,385 @@
+/*  Copyright (C) 1996, 2000 N.M. Maclaren
+    Copyright (C) 1996, 2000 The University of Cambridge
+
+This includes all of the code needed to handle Berkeley sockets.  It is way
+outside current POSIX, unfortunately.  It should be easy to convert to a system
+that uses another mechanism.  It does not currently use socklen_t, because
+the only system that the author uses that has it is Linux. */
+
+
+
+#include "config.h"
+
+#include "header.h"
+#include "internet.h"
+#include <fcntl.h>
+
+#define SOCKET
+#include "kludges.h"
+#undef SOCKET
+
+
+
+/* The code needs to set some variables during the open, for use by later
+functions. */
+
+static int initial = 1,
+    descriptors[MAX_SOCKETS];
+
+#ifdef HAVE_IPV6
+static struct sockaddr_storage here[MAX_SOCKETS], there[MAX_SOCKETS];
+#else
+static struct sockaddr_in here[MAX_SOCKETS], there[MAX_SOCKETS];
+#endif
+
+void display_in_hex(const void *, int);
+#ifdef HAVE_IPV6
+void display_sock_in_hex(struct sockaddr_storage *);
+#else
+void display_sock_in_hex (struct sockaddr_in *);
+#endif
+
+/* There needs to be some disgusting grobble for handling timeouts, that is
+identical to the grobble in internet.c. */
+
+static jmp_buf jump_buffer;
+
+static void jump_handler (int sig) {
+    longjmp(jump_buffer,1);
+}
+
+static void clear_alarm (void) {
+    int k;
+
+    k = errno;
+    alarm(0);
+    errno = 0;
+    if (signal(SIGALRM,SIG_DFL) == SIG_ERR)
+        fatal(1,"unable to reset signal handler",NULL);
+    errno = k;
+}
+
+
+
+void display_in_hex (const void *data, int length) {
+    int i;
+
+    for (i = 0; i < length; ++i)
+        fprintf(stderr,"%.2x",((const unsigned char *)data)[i]);
+}
+
+#ifdef HAVE_IPV6
+
+void display_sock_in_hex (struct sockaddr_storage *sock) {
+    int family;
+    struct sockaddr_in *sin;
+    struct sockaddr_in6 *sin6;
+
+    family = sock->ss_family;
+    switch(family) {
+    case AF_INET:
+       sin = (struct sockaddr_in *)sock;
+       display_in_hex(&sin->sin_addr, sizeof(struct in_addr));
+       fprintf(stderr,"/");
+       display_in_hex(&sin->sin_port, 2);
+       break;
+    case AF_INET6:
+       sin6 = (struct sockaddr_in6 *)sock;
+       display_in_hex(&sin6->sin6_addr, sizeof(struct in6_addr));
+       fprintf(stderr,"/");
+       display_in_hex(&sin6->sin6_port, 2);
+       break;
+    }
+}
+
+#else
+
+void display_sock_in_hex (struct sockaddr_in *sock) {
+    int family, len;
+    struct sockaddr_in *sin;
+
+    family = sock->sin_family;
+    switch(family) {
+    case AF_INET:
+       sin = (struct sockaddr_in *)sock;
+       display_in_hex(&sin->sin_addr, sizeof(struct in_addr));
+       fprintf(stderr,"/");
+       display_in_hex(&sin->sin_port, 2);
+       break;
+    }
+}
+#endif
+
+extern int unprivport;
+
+#ifdef HAVE_IPV6
+
+void open_socket (int which, char *hostname, int timespan) {
+
+/* Locate the specified NTP server, set up a couple of addresses and open a
+socket. */
+
+    int port, k, sl;
+    struct sockaddr_storage address, anywhere;
+
+/* Initialise and find out the server and port number.  Note that the port
+number is in network format. */
+
+    if (initial)
+       for (k = 0; k < MAX_SOCKETS; ++k)
+           descriptors[k] = -1;
+    initial = 0;
+    if (which < 0 || which >= MAX_SOCKETS || descriptors[which] >= 0)
+        fatal(0,"socket index out of range or already open",NULL);
+    if (verbose > 2)
+       fprintf(stderr,"Looking for the socket addresses\n");
+    find_address(&address,&anywhere,&port,hostname,timespan);
+    if (verbose > 2) {
+        fprintf(stderr,"Internet address: address=");
+        display_sock_in_hex(&address);
+        fprintf(stderr," anywhere=");
+        display_sock_in_hex(&anywhere);
+        fputc('\n',stderr);
+    }
+
+/* Set up our own and the target addresses.  Note that the target address will
+be reset before use in server mode. */
+
+    memset(&here[which], 0, sizeof(struct sockaddr_storage));
+    here[which] = anywhere;
+    if (operation != op_listen || unprivport)
+        ((struct sockaddr_in6 *)&here[which])->sin6_port = 0;
+    memset(&there[which], 0, sizeof(struct sockaddr_storage));
+    there[which] = address;
+    if (verbose > 2) {
+        fprintf(stderr,"Initial sockets: here=");
+        display_sock_in_hex(&here[which]);
+        fprintf(stderr," there=");
+        display_sock_in_hex(&there[which]);
+        fputc('\n',stderr);
+    }
+
+/* Allocate a local UDP socket and configure it. */
+
+    switch(((struct sockaddr_in *)&there[which])->sin_family) {
+    case AF_INET:
+       sl = sizeof(struct sockaddr_in);
+       break;
+#ifdef HAVE_IPV6
+    case AF_INET6:
+       sl = sizeof(struct sockaddr_in6);
+       break;
+#endif
+    default:
+       sl = 0;
+       break;
+    }
+    errno = 0;
+    if ((descriptors[which] = socket(here[which].ss_family,SOCK_DGRAM,0)) < 0
+       || bind(descriptors[which],(struct sockaddr *)&here[which], sl) < 0)
+        fatal(1,"unable to allocate socket for NTP",NULL);
+}
+
+#else
+
+void open_socket (int which, char *hostname, int timespan) {
+
+/* Locate the specified NTP server, set up a couple of addresses and open a
+socket. */
+
+    int port, k;
+    struct in_addr address, anywhere;
+
+/* Initialise and find out the server and port number.  Note that the port
+number is in network format. */
+
+    if (initial) for (k = 0; k < MAX_SOCKETS; ++k) descriptors[k] = -1;
+    initial = 0;
+    if (which < 0 || which >= MAX_SOCKETS || descriptors[which] >= 0)
+        fatal(0,"socket index out of range or already open",NULL);
+    if (verbose > 2) fprintf(stderr,"Looking for the socket addresses\n");
+    find_address(&address,&anywhere,&port,hostname,timespan);
+    if (verbose > 2) {
+        fprintf(stderr,"Internet address: address=");
+        display_in_hex(&address,sizeof(struct in_addr));
+        fprintf(stderr," anywhere=");
+        display_in_hex(&anywhere,sizeof(struct in_addr));
+        fputc('\n',stderr);
+    }
+
+/* Set up our own and the target addresses. */
+
+    memset(&here[which],0,sizeof(struct sockaddr_in));
+    here[which].sin_family = AF_INET;
+    here[which].sin_port =
+        (operation == op_listen || !unprivport ? port : 0);
+    here[which].sin_addr = anywhere;
+    memset(&there[which],0,sizeof(struct sockaddr_in));
+    there[which].sin_family = AF_INET;
+    there[which].sin_port = port;
+    there[which].sin_addr = address;
+    if (verbose > 2) {
+        fprintf(stderr,"Initial sockets: here=");
+        display_in_hex(&here[which].sin_addr,sizeof(struct in_addr));
+        fputc('/',stderr);
+        display_in_hex(&here[which].sin_port,sizeof(here[which].sin_port));
+        fprintf(stderr," there=");
+        display_in_hex(&there[which].sin_addr,sizeof(struct in_addr));
+        fputc('/',stderr);
+        display_in_hex(&there[which].sin_port,sizeof(there[which].sin_port));
+        fputc('\n',stderr);
+    }
+
+/* Allocate a local UDP socket and configure it. */
+
+    errno = 0;
+    if ((descriptors[which] = socket(AF_INET,SOCK_DGRAM,0)) < 0 ||
+            bind(descriptors[which],(struct sockaddr *)&here[which],
+                    sizeof(here[which]))  < 0)
+        fatal(1,"unable to allocate socket for NTP",NULL);
+}
+
+#endif
+
+extern void write_socket (int which, void *packet, int length) {
+
+/* Any errors in doing this are fatal - including blocking.  Yes, this leaves a
+server vulnerable to a denial of service attack. */
+
+    int k, sl;
+
+    switch(((struct sockaddr_in *)&there[which])->sin_family) {
+    case AF_INET:
+       sl = sizeof(struct sockaddr_in);
+       break;
+#ifdef HAVE_IPV6
+    case AF_INET6:
+       sl = sizeof(struct sockaddr_in6);
+       break;
+#endif
+    default:
+       sl = 0;
+       break;
+    }
+    if (which < 0 || which >= MAX_SOCKETS || descriptors[which] < 0)
+        fatal(0,"socket index out of range or not open",NULL);
+    errno = 0;
+    k = sendto(descriptors[which],packet,(size_t)length,0,
+            (struct sockaddr *)&there[which],sl);
+    if (k != length) fatal(1,"unable to send NTP packet",NULL);
+}
+
+
+
+extern int read_socket (int which, void *packet, int length, int waiting) {
+
+/* Read a packet and return its length or -1 for failure.  Only incorrect
+length and timeout are not fatal. */
+
+#ifdef HAVE_IPV6
+    struct sockaddr_storage scratch, *ptr;
+#else
+    struct sockaddr_in scratch, *ptr;
+#endif
+    int n;
+    int k;
+
+/* Under normal circumstances, set up a timeout. */
+
+    if (which < 0 || which >= MAX_SOCKETS || descriptors[which] < 0)
+        fatal(0,"socket index out of range or not open",NULL);
+    if (waiting > 0) {
+        if (setjmp(jump_buffer)) {
+            if (verbose > 2)
+                fprintf(stderr,"Receive timed out\n");
+            else if (verbose > 1)
+                fprintf(stderr,"%s: receive timed out after %d seconds\n",
+                    argv0,waiting);
+            return -1;
+        }
+        errno = 0;
+        if (signal(SIGALRM,jump_handler) == SIG_ERR)
+            fatal(1,"unable to set up signal handler",NULL);
+        alarm((unsigned int)waiting);
+    }
+
+/* Get the packet and clear the timeout, if any.  */
+
+    memcpy(ptr = &scratch,&there[which],sizeof(scratch));
+    n = sizeof(scratch);
+    errno = 0;
+    k = recvfrom(descriptors[which],packet,(size_t)length,0,
+        (struct sockaddr *)ptr,&n);
+    if (waiting > 0) clear_alarm();
+
+/* Now issue some low-level diagnostics. */
+
+    if (k <= 0) fatal(1,"unable to receive NTP packet from server",NULL);
+    if (verbose > 2) {
+        fprintf(stderr,"Packet of length %d received from ",k);
+        display_sock_in_hex(ptr);
+        fputc('\n',stderr);
+    }
+    return k;
+}
+
+
+
+extern int flush_socket (int which) {
+
+/* Get rid of any outstanding input, because it may have been hanging around
+for a while.  Ignore packet length oddities and return the number of packets
+skipped. */
+
+#ifdef HAVE_IPV6
+    struct sockaddr_storage scratch;
+#else
+    struct sockaddr_in scratch;
+#endif
+    int n;
+    char buffer[256];
+    int flags, count = 0, total = 0, k;
+
+/* The code is the obvious. */
+
+    if (which < 0 || which >= MAX_SOCKETS || descriptors[which] < 0)
+        fatal(0,"socket index out of range or not open",NULL);
+    if (verbose > 2) fprintf(stderr,"Flushing outstanding packets\n");
+    errno = 0;
+    if ((flags = fcntl(descriptors[which],F_GETFL,0)) < 0 ||
+            fcntl(descriptors[which],F_SETFL,flags|O_NONBLOCK) == -1)
+        fatal(1,"unable to set non-blocking mode",NULL);
+    while (1) {
+        n = sizeof(scratch);
+        errno = 0;
+        k = recvfrom(descriptors[which],buffer,256,0,
+            (struct sockaddr *)&scratch,&n);
+        if (k < 0) {
+            if (errno == EAGAIN || errno == EWOULDBLOCK) break;
+            fatal(1,"unable to flush socket",NULL);
+        }
+        ++count;
+        total += k;
+    }
+    errno = 0;
+    if (fcntl(descriptors[which],F_SETFL,flags) == -1)
+        fatal(1,"unable to restore blocking mode",NULL);
+    if (verbose > 2)
+        fprintf(stderr,"Flushed %d packets totalling %d bytes\n",count,total);
+    return count;
+}
+
+
+
+extern void close_socket (int which) {
+
+/* There is little point in shielding this with a timeout, because any hangs
+are unlikely to be interruptible.  It can get called when the sockets haven't
+been opened, so ignore that case. */
+
+    if (which < 0 || which >= MAX_SOCKETS)
+        fatal(0,"socket index out of range",NULL);
+    if (descriptors[which] < 0) return;
+    errno = 0;
+    if (close(descriptors[which])) fatal(1,"unable to close NTP socket",NULL);
+}
diff --git a/sntp/timing.c b/sntp/timing.c
new file mode 100644 (file)
index 0000000..f69cd2b
--- /dev/null
@@ -0,0 +1,112 @@
+/*  Copyright (C) 1996 N.M. Maclaren
+    Copyright (C) 1996 The University of Cambridge
+
+This includes all of the code needed to handle the time.  It assumes rather
+more than is defined by POSIX, unfortunately.  Systems that do not have the
+'X/Open' extensions may need changes. */
+
+
+
+#include "header.h"
+
+#include <sys/types.h>
+#include <sys/time.h>
+
+#define TIMING
+#include "kludges.h"
+#undef TIMING
+
+
+
+#define MILLION_L    1000000l          /* For conversion to/from timeval */
+#define MILLION_D       1.0e6          /* Must be equal to MILLION_L */
+
+
+
+double current_time (double offset) {
+
+/* Get the current UTC time in seconds since the Epoch plus an offset (usually
+the time from the beginning of the century to the Epoch!) */
+
+    struct timeval current;
+
+    errno = 0;
+    if (gettimeofday(&current,NULL))
+        fatal(1,"unable to read current machine/system time",NULL);
+    return offset+current.tv_sec+1.0e-6*current.tv_usec;
+}
+
+
+
+time_t convert_time (double value, int *millisecs) {
+
+/* Convert the time to the ANSI C form. */
+
+    time_t result = (time_t)value;
+
+    if ((*millisecs = (int)(1000.0*(value-result))) >= 1000) {
+        *millisecs = 0;
+        ++result;
+    }
+    return result;
+}
+
+
+
+void adjust_time (double difference, int immediate, double ignore) {
+
+/* Adjust the current UTC time.  This is portable, even if struct timeval uses
+an unsigned long for tv_sec. */
+
+    struct timeval old, new, adjust, previous;
+    char text[40];
+    long n;
+
+/* Start by converting to timeval format. Note that we have to cater for
+negative, unsigned values. */
+
+    if ((n = (long)difference) > difference) --n;
+    adjust.tv_sec = n;
+    adjust.tv_usec = (long)(MILLION_D*(difference-n));
+    errno = 0;
+    if (gettimeofday(&old,NULL))
+        fatal(1,"unable to read machine/system time",NULL);
+    new.tv_sec = old.tv_sec+adjust.tv_sec;
+    new.tv_usec = (n = (long)old.tv_usec+(long)adjust.tv_usec);
+    if (n < 0) {
+        new.tv_usec += MILLION_L;
+        --new.tv_sec;
+    } else if (n >= MILLION_L) {
+        new.tv_usec -= MILLION_L;
+        ++new.tv_sec;
+    }
+
+/* Now diagnose the situation if necessary, and perform the dirty deed. */
+
+    if (verbose > 2)
+        fprintf(stderr,
+            "Times: old=(%ld,%.6ld) new=(%ld,%.6ld) adjust=(%ld,%.6ld)\n",
+            (long)old.tv_sec,(long)old.tv_usec,
+            (long)new.tv_sec,(long)new.tv_usec,
+            (long)adjust.tv_sec,(long)adjust.tv_usec);
+    if (immediate) {
+        errno = 0;
+        if (settimeofday(&new,NULL))
+            fatal(1,"unable to reset current system time",NULL);
+    } else {
+       previous.tv_sec  = 0;
+       previous.tv_usec = 0;
+        errno = 0;
+        if (adjtime(&adjust,&previous))
+            fatal(1,"unable to adjust current system time",NULL);
+        if (previous.tv_sec != 0 || previous.tv_usec != 0) {
+            sprintf(text,"(%ld,%.6ld)",
+                (long)previous.tv_sec,(long)previous.tv_usec);
+            if (previous.tv_sec+1.0e-6*previous.tv_usec > ignore)
+                fatal(0,"outstanding time adjustment %s",text);
+            else if (verbose)
+                fprintf(stderr,"%s: outstanding time adjustment %s\n",
+                    argv0,text);
+        }
+    }
+}
diff --git a/sntp/unix.c b/sntp/unix.c
new file mode 100644 (file)
index 0000000..c9d5d74
--- /dev/null
@@ -0,0 +1,92 @@
+/*  Copyright (C) 1996 N.M. Maclaren
+    Copyright (C) 1996 The University of Cambridge
+
+This includes code that really should have been part of ANSI/ISO C, but was
+left out for historical reasons (despite requests to define ftty), plus
+the get_lock() and log_message() functions.
+*/
+
+#include "header.h"
+
+#include <sys/types.h>
+#include <unistd.h>
+#include <syslog.h>
+#include <signal.h>
+
+#define UNIX
+#include "kludges.h"
+#undef UNIX
+
+
+void do_nothing (int seconds) {
+
+/* Wait for a fixed period, possibly uninterruptibly.  This should not wait
+for less than the specified period, if that can be avoided. */
+
+    sleep((unsigned int)(seconds+2));          /* +2 is enough for POSIX */
+}
+
+
+
+int ftty (FILE *file) {
+
+/* Return whether the file is attached to an interactive device. */
+
+    return isatty(fileno(file));
+}
+
+
+
+void set_lock (int lock) {
+
+/* Check that we have enough privileges to reset the time and that no other
+updating msntp process is running, but don't bother with fancy interlocking.
+This function is really only to permit the daemon mode to be restarted in a
+cron job and improve the diagnostics; it can be replaced by a 'return'
+statement if it causes implementation difficulties.  Note that there is little
+point in clearing the lock under Unix, but do so anyway. */
+
+    FILE *file;
+    long pid;
+
+    if (lockname == NULL || lockname[0] == '\0') return;
+    if (lock) {
+        errno = 0;
+        if ((file = fopen(lockname,"r")) != NULL &&
+                fscanf(file,"%ld",&pid) == 1 && kill(pid,0) == 0) {
+            if (verbose || isatty(STDIN_FILENO) || isatty(STDOUT_FILENO))
+                fatal(0,"another msntp process is currently running",NULL);
+            else
+                fatal(0,NULL,NULL);
+        }
+        if (file != NULL) fclose(file);
+        errno = 0;
+        if ((file = fopen(lockname,"w")) == NULL ||
+                fprintf(file,"%ld\n",(long)getpid()) <= 0 ||
+                ferror(file) || fclose(file) != 0)
+            fatal(1,"unable to write PID to %s",lockname);
+        adjust_time(0.0,1,0.0);
+    } else {
+        errno = 0;
+        if (remove(lockname) != 0)
+            fatal(1,"unable to remove the msntp lockname %s",lockname);
+    }
+}       
+
+
+
+/*
+ * Log a message, crudely.
+ * This is used in only one place, but could be used more widely.
+ */
+
+void
+log_message (const char *message)
+{
+
+    syslog(
+#ifdef LOG_DAEMON
+       LOG_DAEMON |
+#endif
+       LOG_WARNING, "%s", message);
+}
diff --git a/sntp/version.def b/sntp/version.def
new file mode 100644 (file)
index 0000000..f0dc444
--- /dev/null
@@ -0,0 +1 @@
+version = '4.2.4p8';
diff --git a/util/Makefile.am b/util/Makefile.am
new file mode 100644 (file)
index 0000000..f73121f
--- /dev/null
@@ -0,0 +1,46 @@
+#AUTOMAKE_OPTIONS = ../ansi2knr no-dependencies
+AUTOMAKE_OPTIONS=      ansi2knr
+
+bin_PROGRAMS=  @MAKE_NTPTIME@ @MAKE_TICKADJ@ @MAKE_TIMETRIM@ \
+               ntp-keygen
+EXTRA_PROGRAMS=        audio-pcm byteorder hist jitter kern longsize \
+       ntptime pps-api precision sht testrs6000 tg tickadj timetrim
+
+AM_CPPFLAGS=   -I$(top_srcdir)/include $(LIBOPTS_CFLAGS)
+# LDADD might need RESLIB and ADJLIB
+LDADD=         ../libntp/libntp.a
+ntp_keygen_SOURCES = ntp-keygen.c ntp-keygen-opts.c ntp-keygen-opts.h
+ntp_keygen_LDADD=      @LCRYPTO@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+
+ETAGS_ARGS=    Makefile.am
+#EXTRA_DIST=   README TAGS
+EXTRA_DIST=    ntp-keygen-opts.def ntp-keygen.1 ntp-keygen-opts.texi ntp-keygen-opts.menu
+BUILT_SOURCES= ntp-keygen-opts.c ntp-keygen-opts.h ntp-keygen.1        \
+               ntp-keygen-opts.texi ntp-keygen-opts.menu
+man_MANS=      ntp-keygen.1
+run_ag=         cd $(srcdir) && autogen -L ../include --writable
+std_def_list=  $(top_srcdir)/include/debug-opt.def             \
+               $(top_srcdir)/include/autogen-version.def       \
+               $(top_srcdir)/include/copyright.def             \
+               $(top_srcdir)/include/homerc.def                \
+               $(top_srcdir)/include/version.def
+
+$(srcdir)/ntp-keygen-opts.h: $(srcdir)/ntp-keygen-opts.c
+$(srcdir)/ntp-keygen-opts.c: $(srcdir)/ntp-keygen-opts.def $(std_def_list)
+       $(run_ag) ntp-keygen-opts.def
+
+$(srcdir)/ntp-keygen.1: $(srcdir)/ntp-keygen-opts.def $(std_def_list)
+       $(run_ag) -Tagman1.tpl -bntp-keygen ntp-keygen-opts.def
+
+$(srcdir)/ntp-keygen-opts.texi $(srcdir)/ntp-keygen-opts.menu: $(srcdir)/ntp-keygen-opts.def $(std_def_list)
+       $(run_ag) -Taginfo.tpl -DLEVEL=section ntp-keygen-opts.def
+
+
+jitter_SOURCES=        jitter.c jitter.h
+jitter_LDADD=
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE)
+
+kern.o: kern.c
+       $(COMPILE) -DHAVE_TIMEX_H -c kern.c
diff --git a/util/Makefile.in b/util/Makefile.in
new file mode 100644 (file)
index 0000000..75830d0
--- /dev/null
@@ -0,0 +1,827 @@
+# Makefile.in generated by automake 1.11 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.
+# 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.
+
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
+# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE.
+
+@SET_MAKE@
+
+VPATH = @srcdir@
+pkgdatadir = $(datadir)/@PACKAGE@
+pkgincludedir = $(includedir)/@PACKAGE@
+pkglibdir = $(libdir)/@PACKAGE@
+pkglibexecdir = $(libexecdir)/@PACKAGE@
+am__cd = CDPATH="$${ZSH_VERSION+.}$(PATH_SEPARATOR)" && cd
+install_sh_DATA = $(install_sh) -c -m 644
+install_sh_PROGRAM = $(install_sh) -c
+install_sh_SCRIPT = $(install_sh) -c
+INSTALL_HEADER = $(INSTALL_DATA)
+transform = $(program_transform_name)
+NORMAL_INSTALL = :
+PRE_INSTALL = :
+POST_INSTALL = :
+NORMAL_UNINSTALL = :
+PRE_UNINSTALL = :
+POST_UNINSTALL = :
+build_triplet = @build@
+host_triplet = @host@
+ANSI2KNR = @ANSI2KNR@
+bin_PROGRAMS = @MAKE_NTPTIME@ @MAKE_TICKADJ@ @MAKE_TIMETRIM@ \
+       ntp-keygen$(EXEEXT)
+EXTRA_PROGRAMS = audio-pcm$(EXEEXT) byteorder$(EXEEXT) hist$(EXEEXT) \
+       jitter$(EXEEXT) kern$(EXEEXT) longsize$(EXEEXT) \
+       ntptime$(EXEEXT) pps-api$(EXEEXT) precision$(EXEEXT) \
+       sht$(EXEEXT) testrs6000$(EXEEXT) tg$(EXEEXT) tickadj$(EXEEXT) \
+       timetrim$(EXEEXT)
+subdir = util
+DIST_COMMON = README $(srcdir)/Makefile.am $(srcdir)/Makefile.in \
+       ansi2knr.1 ansi2knr.c
+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__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \
+       $(ACLOCAL_M4)
+mkinstalldirs = $(install_sh) -d
+CONFIG_HEADER = $(top_builddir)/config.h
+CONFIG_CLEAN_FILES =
+CONFIG_CLEAN_VPATH_FILES =
+am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"
+PROGRAMS = $(bin_PROGRAMS)
+audio_pcm_SOURCES = audio-pcm.c
+audio_pcm_OBJECTS = audio-pcm$U.$(OBJEXT)
+audio_pcm_LDADD = $(LDADD)
+audio_pcm_DEPENDENCIES = ../libntp/libntp.a
+byteorder_SOURCES = byteorder.c
+byteorder_OBJECTS = byteorder$U.$(OBJEXT)
+byteorder_LDADD = $(LDADD)
+byteorder_DEPENDENCIES = ../libntp/libntp.a
+hist_SOURCES = hist.c
+hist_OBJECTS = hist$U.$(OBJEXT)
+hist_LDADD = $(LDADD)
+hist_DEPENDENCIES = ../libntp/libntp.a
+am_jitter_OBJECTS = jitter$U.$(OBJEXT)
+jitter_OBJECTS = $(am_jitter_OBJECTS)
+jitter_DEPENDENCIES =
+kern_SOURCES = kern.c
+kern_OBJECTS = kern$U.$(OBJEXT)
+kern_LDADD = $(LDADD)
+kern_DEPENDENCIES = ../libntp/libntp.a
+longsize_SOURCES = longsize.c
+longsize_OBJECTS = longsize$U.$(OBJEXT)
+longsize_LDADD = $(LDADD)
+longsize_DEPENDENCIES = ../libntp/libntp.a
+am_ntp_keygen_OBJECTS = ntp-keygen$U.$(OBJEXT) \
+       ntp-keygen-opts$U.$(OBJEXT)
+ntp_keygen_OBJECTS = $(am_ntp_keygen_OBJECTS)
+am__DEPENDENCIES_1 =
+ntp_keygen_DEPENDENCIES = $(am__DEPENDENCIES_1) ../libntp/libntp.a
+ntptime_SOURCES = ntptime.c
+ntptime_OBJECTS = ntptime$U.$(OBJEXT)
+ntptime_LDADD = $(LDADD)
+ntptime_DEPENDENCIES = ../libntp/libntp.a
+pps_api_SOURCES = pps-api.c
+pps_api_OBJECTS = pps-api$U.$(OBJEXT)
+pps_api_LDADD = $(LDADD)
+pps_api_DEPENDENCIES = ../libntp/libntp.a
+precision_SOURCES = precision.c
+precision_OBJECTS = precision$U.$(OBJEXT)
+precision_LDADD = $(LDADD)
+precision_DEPENDENCIES = ../libntp/libntp.a
+sht_SOURCES = sht.c
+sht_OBJECTS = sht$U.$(OBJEXT)
+sht_LDADD = $(LDADD)
+sht_DEPENDENCIES = ../libntp/libntp.a
+testrs6000_SOURCES = testrs6000.c
+testrs6000_OBJECTS = testrs6000$U.$(OBJEXT)
+testrs6000_LDADD = $(LDADD)
+testrs6000_DEPENDENCIES = ../libntp/libntp.a
+tg_SOURCES = tg.c
+tg_OBJECTS = tg$U.$(OBJEXT)
+tg_LDADD = $(LDADD)
+tg_DEPENDENCIES = ../libntp/libntp.a
+tickadj_SOURCES = tickadj.c
+tickadj_OBJECTS = tickadj$U.$(OBJEXT)
+tickadj_LDADD = $(LDADD)
+tickadj_DEPENDENCIES = ../libntp/libntp.a
+timetrim_SOURCES = timetrim.c
+timetrim_OBJECTS = timetrim$U.$(OBJEXT)
+timetrim_LDADD = $(LDADD)
+timetrim_DEPENDENCIES = ../libntp/libntp.a
+DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
+depcomp = $(SHELL) $(top_srcdir)/depcomp
+am__depfiles_maybe = depfiles
+am__mv = mv -f
+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)
+CCLD = $(CC)
+LINK = $(LIBTOOL) --tag=CC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
+       --mode=link $(CCLD) $(AM_CFLAGS) $(CFLAGS) $(AM_LDFLAGS) \
+       $(LDFLAGS) -o $@
+SOURCES = audio-pcm.c byteorder.c hist.c $(jitter_SOURCES) kern.c \
+       longsize.c $(ntp_keygen_SOURCES) ntptime.c pps-api.c \
+       precision.c sht.c testrs6000.c tg.c tickadj.c timetrim.c
+DIST_SOURCES = audio-pcm.c byteorder.c hist.c $(jitter_SOURCES) kern.c \
+       longsize.c $(ntp_keygen_SOURCES) ntptime.c pps-api.c \
+       precision.c sht.c testrs6000.c tg.c tickadj.c timetrim.c
+am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`;
+am__vpath_adj = case $$p in \
+    $(srcdir)/*) f=`echo "$$p" | sed "s|^$$srcdirstrip/||"`;; \
+    *) f=$$p;; \
+  esac;
+am__strip_dir = f=`echo $$p | sed -e 's|^.*/||'`;
+am__install_max = 40
+am__nobase_strip_setup = \
+  srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*|]/\\\\&/g'`
+am__nobase_strip = \
+  for p in $$list; do echo "$$p"; done | sed -e "s|$$srcdirstrip/||"
+am__nobase_list = $(am__nobase_strip_setup); \
+  for p in $$list; do echo "$$p $$p"; done | \
+  sed "s| $$srcdirstrip/| |;"' / .*\//!s/ .*/ ./; s,\( .*\)/[^/]*$$,\1,' | \
+  $(AWK) 'BEGIN { files["."] = "" } { files[$$2] = files[$$2] " " $$1; \
+    if (++n[$$2] == $(am__install_max)) \
+      { print $$2, files[$$2]; n[$$2] = 0; files[$$2] = "" } } \
+    END { for (dir in files) print dir, files[dir] }'
+am__base_list = \
+  sed '$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;$$!N;s/\n/ /g' | \
+  sed '$$!N;$$!N;$$!N;$$!N;s/\n/ /g'
+man1dir = $(mandir)/man1
+NROFF = nroff
+MANS = $(man_MANS)
+ETAGS = etags
+CTAGS = ctags
+DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
+ACLOCAL = @ACLOCAL@
+AMTAR = @AMTAR@
+AR = @AR@
+ARLIB_DIR = @ARLIB_DIR@
+AUTOCONF = @AUTOCONF@
+AUTOHEADER = @AUTOHEADER@
+AUTOMAKE = @AUTOMAKE@
+AWK = @AWK@
+BINSUBDIR = @BINSUBDIR@
+CC = @CC@
+CCDEPMODE = @CCDEPMODE@
+CFLAGS = @CFLAGS@
+CHUTEST = @CHUTEST@
+CLKTEST = @CLKTEST@
+CPP = @CPP@
+CPPFLAGS = @CPPFLAGS@
+CYGPATH_W = @CYGPATH_W@
+DCFD = @DCFD@
+DEFS = @DEFS@
+DEPDIR = @DEPDIR@
+ECHO = @ECHO@
+ECHO_C = @ECHO_C@
+ECHO_N = @ECHO_N@
+ECHO_T = @ECHO_T@
+EF_LIBS = @EF_LIBS@
+EF_PROGS = @EF_PROGS@
+EGREP = @EGREP@
+EXEEXT = @EXEEXT@
+GREP = @GREP@
+HAVE_INLINE = @HAVE_INLINE@
+INSTALL = @INSTALL@
+INSTALL_DATA = @INSTALL_DATA@
+INSTALL_PROGRAM = @INSTALL_PROGRAM@
+INSTALL_SCRIPT = @INSTALL_SCRIPT@
+INSTALL_STRIP_PROGRAM = @INSTALL_STRIP_PROGRAM@
+LCRYPTO = @LCRYPTO@
+LDFLAGS = @LDFLAGS@
+LIBOBJS = @LIBOBJS@
+LIBOPTS_CFLAGS = @LIBOPTS_CFLAGS@
+LIBOPTS_DIR = @LIBOPTS_DIR@
+LIBOPTS_LDADD = @LIBOPTS_LDADD@
+LIBPARSE = @LIBPARSE@
+LIBS = @LIBS@
+LIBTOOL = @LIBTOOL@
+LN_S = @LN_S@
+LSCF = @LSCF@
+LTLIBOBJS = @LTLIBOBJS@
+MAKEINFO = @MAKEINFO@
+MAKE_ADJTIMED = @MAKE_ADJTIMED@
+MAKE_CHECK_LAYOUT = @MAKE_CHECK_LAYOUT@
+MAKE_CHECK_Y2K = @MAKE_CHECK_Y2K@
+MAKE_LIBNTPSIM = @MAKE_LIBNTPSIM@
+MAKE_LIBPARSE = @MAKE_LIBPARSE@
+MAKE_LIBPARSE_KERNEL = @MAKE_LIBPARSE_KERNEL@
+MAKE_NTPDSIM = @MAKE_NTPDSIM@
+MAKE_NTPTIME = @MAKE_NTPTIME@
+MAKE_PARSEKMODULE = @MAKE_PARSEKMODULE@
+MAKE_TICKADJ = @MAKE_TICKADJ@
+MAKE_TIMETRIM = @MAKE_TIMETRIM@
+MKDIR_P = @MKDIR_P@
+OBJEXT = @OBJEXT@
+OPENSSL = @OPENSSL@
+OPENSSL_INC = @OPENSSL_INC@
+OPENSSL_LIB = @OPENSSL_LIB@
+PACKAGE = @PACKAGE@
+PACKAGE_BUGREPORT = @PACKAGE_BUGREPORT@
+PACKAGE_NAME = @PACKAGE_NAME@
+PACKAGE_STRING = @PACKAGE_STRING@
+PACKAGE_TARNAME = @PACKAGE_TARNAME@
+PACKAGE_URL = @PACKAGE_URL@
+PACKAGE_VERSION = @PACKAGE_VERSION@
+PATH_PERL = @PATH_PERL@
+PATH_SEPARATOR = @PATH_SEPARATOR@
+PATH_SH = @PATH_SH@
+PROPDELAY = @PROPDELAY@
+RANLIB = @RANLIB@
+READLINE_LIBS = @READLINE_LIBS@
+SET_MAKE = @SET_MAKE@
+SHELL = @SHELL@
+STRIP = @STRIP@
+TESTDCF = @TESTDCF@
+U = @U@
+VERSION = @VERSION@
+abs_builddir = @abs_builddir@
+abs_srcdir = @abs_srcdir@
+abs_top_builddir = @abs_top_builddir@
+abs_top_srcdir = @abs_top_srcdir@
+ac_ct_CC = @ac_ct_CC@
+am__include = @am__include@
+am__leading_dot = @am__leading_dot@
+am__quote = @am__quote@
+am__tar = @am__tar@
+am__untar = @am__untar@
+bindir = @bindir@
+build = @build@
+build_alias = @build_alias@
+build_cpu = @build_cpu@
+build_os = @build_os@
+build_vendor = @build_vendor@
+builddir = @builddir@
+datadir = @datadir@
+datarootdir = @datarootdir@
+docdir = @docdir@
+dvidir = @dvidir@
+exec_prefix = @exec_prefix@
+host = @host@
+host_alias = @host_alias@
+host_cpu = @host_cpu@
+host_os = @host_os@
+host_vendor = @host_vendor@
+htmldir = @htmldir@
+includedir = @includedir@
+infodir = @infodir@
+install_sh = @install_sh@
+libdir = @libdir@
+libexecdir = @libexecdir@
+localedir = @localedir@
+localstatedir = @localstatedir@
+mandir = @mandir@
+mkdir_p = @mkdir_p@
+oldincludedir = @oldincludedir@
+pdfdir = @pdfdir@
+prefix = @prefix@
+program_transform_name = @program_transform_name@
+psdir = @psdir@
+sbindir = @sbindir@
+sharedstatedir = @sharedstatedir@
+srcdir = @srcdir@
+subdirs = @subdirs@
+sysconfdir = @sysconfdir@
+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 = ansi2knr
+AM_CPPFLAGS = -I$(top_srcdir)/include $(LIBOPTS_CFLAGS)
+# LDADD might need RESLIB and ADJLIB
+LDADD = ../libntp/libntp.a
+ntp_keygen_SOURCES = ntp-keygen.c ntp-keygen-opts.c ntp-keygen-opts.h
+ntp_keygen_LDADD = @LCRYPTO@ $(LIBOPTS_LDADD) ../libntp/libntp.a
+ETAGS_ARGS = Makefile.am
+#EXTRA_DIST=   README TAGS
+EXTRA_DIST = ntp-keygen-opts.def ntp-keygen.1 ntp-keygen-opts.texi ntp-keygen-opts.menu
+BUILT_SOURCES = ntp-keygen-opts.c ntp-keygen-opts.h ntp-keygen.1       \
+               ntp-keygen-opts.texi ntp-keygen-opts.menu
+
+man_MANS = ntp-keygen.1
+run_ag = cd $(srcdir) && autogen -L ../include --writable
+std_def_list = $(top_srcdir)/include/debug-opt.def             \
+               $(top_srcdir)/include/autogen-version.def       \
+               $(top_srcdir)/include/copyright.def             \
+               $(top_srcdir)/include/homerc.def                \
+               $(top_srcdir)/include/version.def
+
+jitter_SOURCES = jitter.c jitter.h
+jitter_LDADD = 
+all: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) all-am
+
+.SUFFIXES:
+.SUFFIXES: .c .lo .o .obj
+$(srcdir)/Makefile.in:  $(srcdir)/Makefile.am  $(am__configure_deps)
+       @for dep in $?; do \
+         case '$(am__configure_deps)' in \
+           *$$dep*) \
+             ( cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh ) \
+               && { if test -f $@; then exit 0; else break; fi; }; \
+             exit 1;; \
+         esac; \
+       done; \
+       echo ' cd $(top_srcdir) && $(AUTOMAKE) --foreign util/Makefile'; \
+       $(am__cd) $(top_srcdir) && \
+         $(AUTOMAKE) --foreign util/Makefile
+.PRECIOUS: Makefile
+Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
+       @case '$?' in \
+         *config.status*) \
+           cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh;; \
+         *) \
+           echo ' cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe)'; \
+           cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ $(am__depfiles_maybe);; \
+       esac;
+
+$(top_builddir)/config.status: $(top_srcdir)/configure $(CONFIG_STATUS_DEPENDENCIES)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+
+$(top_srcdir)/configure:  $(am__configure_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(ACLOCAL_M4):  $(am__aclocal_m4_deps)
+       cd $(top_builddir) && $(MAKE) $(AM_MAKEFLAGS) am--refresh
+$(am__aclocal_m4_deps):
+install-binPROGRAMS: $(bin_PROGRAMS)
+       @$(NORMAL_INSTALL)
+       test -z "$(bindir)" || $(MKDIR_P) "$(DESTDIR)$(bindir)"
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       for p in $$list; do echo "$$p $$p"; done | \
+       sed 's/$(EXEEXT)$$//' | \
+       while read p p1; do if test -f $$p || test -f $$p1; \
+         then echo "$$p"; echo "$$p"; else :; fi; \
+       done | \
+       sed -e 'p;s,.*/,,;n;h' -e 's|.*|.|' \
+           -e 'p;x;s,.*/,,;s/$(EXEEXT)$$//;$(transform);s/$$/$(EXEEXT)/' | \
+       sed 'N;N;N;s,\n, ,g' | \
+       $(AWK) 'BEGIN { files["."] = ""; dirs["."] = 1 } \
+         { d=$$3; if (dirs[d] != 1) { print "d", d; dirs[d] = 1 } \
+           if ($$2 == $$4) files[d] = files[d] " " $$1; \
+           else { print "f", $$3 "/" $$4, $$1; } } \
+         END { for (d in files) print "f", d, files[d] }' | \
+       while read type dir files; do \
+           if test "$$dir" = .; then dir=; else dir=/$$dir; fi; \
+           test -z "$$files" || { \
+           echo " $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files '$(DESTDIR)$(bindir)$$dir'"; \
+           $(INSTALL_PROGRAM_ENV) $(LIBTOOL) $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) --mode=install $(INSTALL_PROGRAM) $$files "$(DESTDIR)$(bindir)$$dir" || exit $$?; \
+           } \
+       ; done
+
+uninstall-binPROGRAMS:
+       @$(NORMAL_UNINSTALL)
+       @list='$(bin_PROGRAMS)'; test -n "$(bindir)" || list=; \
+       files=`for p in $$list; do echo "$$p"; done | \
+         sed -e 'h;s,^.*/,,;s/$(EXEEXT)$$//;$(transform)' \
+             -e 's/$$/$(EXEEXT)/' `; \
+       test -n "$$list" || exit 0; \
+       echo " ( cd '$(DESTDIR)$(bindir)' && rm -f" $$files ")"; \
+       cd "$(DESTDIR)$(bindir)" && rm -f $$files
+
+clean-binPROGRAMS:
+       @list='$(bin_PROGRAMS)'; test -n "$$list" || exit 0; \
+       echo " rm -f" $$list; \
+       rm -f $$list || exit $$?; \
+       test -n "$(EXEEXT)" || exit 0; \
+       list=`for p in $$list; do echo "$$p"; done | sed 's/$(EXEEXT)$$//'`; \
+       echo " rm -f" $$list; \
+       rm -f $$list
+audio-pcm$(EXEEXT): $(audio_pcm_OBJECTS) $(audio_pcm_DEPENDENCIES) 
+       @rm -f audio-pcm$(EXEEXT)
+       $(LINK) $(audio_pcm_OBJECTS) $(audio_pcm_LDADD) $(LIBS)
+byteorder$(EXEEXT): $(byteorder_OBJECTS) $(byteorder_DEPENDENCIES) 
+       @rm -f byteorder$(EXEEXT)
+       $(LINK) $(byteorder_OBJECTS) $(byteorder_LDADD) $(LIBS)
+hist$(EXEEXT): $(hist_OBJECTS) $(hist_DEPENDENCIES) 
+       @rm -f hist$(EXEEXT)
+       $(LINK) $(hist_OBJECTS) $(hist_LDADD) $(LIBS)
+jitter$(EXEEXT): $(jitter_OBJECTS) $(jitter_DEPENDENCIES) 
+       @rm -f jitter$(EXEEXT)
+       $(LINK) $(jitter_OBJECTS) $(jitter_LDADD) $(LIBS)
+kern$(EXEEXT): $(kern_OBJECTS) $(kern_DEPENDENCIES) 
+       @rm -f kern$(EXEEXT)
+       $(LINK) $(kern_OBJECTS) $(kern_LDADD) $(LIBS)
+longsize$(EXEEXT): $(longsize_OBJECTS) $(longsize_DEPENDENCIES) 
+       @rm -f longsize$(EXEEXT)
+       $(LINK) $(longsize_OBJECTS) $(longsize_LDADD) $(LIBS)
+ntp-keygen$(EXEEXT): $(ntp_keygen_OBJECTS) $(ntp_keygen_DEPENDENCIES) 
+       @rm -f ntp-keygen$(EXEEXT)
+       $(LINK) $(ntp_keygen_OBJECTS) $(ntp_keygen_LDADD) $(LIBS)
+ntptime$(EXEEXT): $(ntptime_OBJECTS) $(ntptime_DEPENDENCIES) 
+       @rm -f ntptime$(EXEEXT)
+       $(LINK) $(ntptime_OBJECTS) $(ntptime_LDADD) $(LIBS)
+pps-api$(EXEEXT): $(pps_api_OBJECTS) $(pps_api_DEPENDENCIES) 
+       @rm -f pps-api$(EXEEXT)
+       $(LINK) $(pps_api_OBJECTS) $(pps_api_LDADD) $(LIBS)
+precision$(EXEEXT): $(precision_OBJECTS) $(precision_DEPENDENCIES) 
+       @rm -f precision$(EXEEXT)
+       $(LINK) $(precision_OBJECTS) $(precision_LDADD) $(LIBS)
+sht$(EXEEXT): $(sht_OBJECTS) $(sht_DEPENDENCIES) 
+       @rm -f sht$(EXEEXT)
+       $(LINK) $(sht_OBJECTS) $(sht_LDADD) $(LIBS)
+testrs6000$(EXEEXT): $(testrs6000_OBJECTS) $(testrs6000_DEPENDENCIES) 
+       @rm -f testrs6000$(EXEEXT)
+       $(LINK) $(testrs6000_OBJECTS) $(testrs6000_LDADD) $(LIBS)
+tg$(EXEEXT): $(tg_OBJECTS) $(tg_DEPENDENCIES) 
+       @rm -f tg$(EXEEXT)
+       $(LINK) $(tg_OBJECTS) $(tg_LDADD) $(LIBS)
+tickadj$(EXEEXT): $(tickadj_OBJECTS) $(tickadj_DEPENDENCIES) 
+       @rm -f tickadj$(EXEEXT)
+       $(LINK) $(tickadj_OBJECTS) $(tickadj_LDADD) $(LIBS)
+timetrim$(EXEEXT): $(timetrim_OBJECTS) $(timetrim_DEPENDENCIES) 
+       @rm -f timetrim$(EXEEXT)
+       $(LINK) $(timetrim_OBJECTS) $(timetrim_LDADD) $(LIBS)
+
+mostlyclean-compile:
+       -rm -f *.$(OBJEXT)
+
+distclean-compile:
+       -rm -f *.tab.c
+./ansi2knr: ansi2knr.$(OBJEXT)
+       $(LINK) ansi2knr.$(OBJEXT) $(LIBS)
+ansi2knr.$(OBJEXT): $(CONFIG_HEADER)
+
+clean-krextra:
+       -rm -f ansi2knr
+
+mostlyclean-kr:
+       -test "$U" = "" || rm -f *_.c
+
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/audio-pcm$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/byteorder$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/hist$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/jitter$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/kern$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/longsize$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp-keygen$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntp-keygen-opts$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/ntptime$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/pps-api$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/precision$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/sht$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/testrs6000$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tg$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tickadj$U.Po@am__quote@
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/timetrim$U.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c $<
+
+.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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(COMPILE) -c `$(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@
+@AMDEP_TRUE@@am__fastdepCC_FALSE@      DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@
+@am__fastdepCC_FALSE@  $(LTCOMPILE) -c -o $@ $<
+audio-pcm_.c: audio-pcm.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/audio-pcm.c; then echo $(srcdir)/audio-pcm.c; else echo audio-pcm.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+byteorder_.c: byteorder.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/byteorder.c; then echo $(srcdir)/byteorder.c; else echo byteorder.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+hist_.c: hist.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/hist.c; then echo $(srcdir)/hist.c; else echo hist.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+jitter_.c: jitter.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/jitter.c; then echo $(srcdir)/jitter.c; else echo jitter.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+kern_.c: kern.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/kern.c; then echo $(srcdir)/kern.c; else echo kern.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+longsize_.c: longsize.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/longsize.c; then echo $(srcdir)/longsize.c; else echo longsize.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp-keygen_.c: ntp-keygen.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp-keygen.c; then echo $(srcdir)/ntp-keygen.c; else echo ntp-keygen.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntp-keygen-opts_.c: ntp-keygen-opts.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntp-keygen-opts.c; then echo $(srcdir)/ntp-keygen-opts.c; else echo ntp-keygen-opts.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+ntptime_.c: ntptime.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/ntptime.c; then echo $(srcdir)/ntptime.c; else echo ntptime.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+pps-api_.c: pps-api.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/pps-api.c; then echo $(srcdir)/pps-api.c; else echo pps-api.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+precision_.c: precision.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/precision.c; then echo $(srcdir)/precision.c; else echo precision.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+sht_.c: sht.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/sht.c; then echo $(srcdir)/sht.c; else echo sht.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+testrs6000_.c: testrs6000.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/testrs6000.c; then echo $(srcdir)/testrs6000.c; else echo testrs6000.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+tg_.c: tg.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tg.c; then echo $(srcdir)/tg.c; else echo tg.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+tickadj_.c: tickadj.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/tickadj.c; then echo $(srcdir)/tickadj.c; else echo tickadj.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+timetrim_.c: timetrim.c $(ANSI2KNR)
+       $(CPP) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) `if test -f $(srcdir)/timetrim.c; then echo $(srcdir)/timetrim.c; else echo timetrim.c; fi` | sed 's/^# \([0-9]\)/#line \1/' | $(ANSI2KNR) > $@ || rm -f $@
+audio-pcm_.$(OBJEXT) audio-pcm_.lo byteorder_.$(OBJEXT) byteorder_.lo \
+hist_.$(OBJEXT) hist_.lo jitter_.$(OBJEXT) jitter_.lo kern_.$(OBJEXT) \
+kern_.lo longsize_.$(OBJEXT) longsize_.lo ntp-keygen_.$(OBJEXT) \
+ntp-keygen_.lo ntp-keygen-opts_.$(OBJEXT) ntp-keygen-opts_.lo \
+ntptime_.$(OBJEXT) ntptime_.lo pps-api_.$(OBJEXT) pps-api_.lo \
+precision_.$(OBJEXT) precision_.lo sht_.$(OBJEXT) sht_.lo \
+testrs6000_.$(OBJEXT) testrs6000_.lo tg_.$(OBJEXT) tg_.lo \
+tickadj_.$(OBJEXT) tickadj_.lo timetrim_.$(OBJEXT) timetrim_.lo : \
+$(ANSI2KNR)
+
+mostlyclean-libtool:
+       -rm -f *.lo
+
+clean-libtool:
+       -rm -rf .libs _libs
+install-man1: $(man_MANS)
+       @$(NORMAL_INSTALL)
+       test -z "$(man1dir)" || $(MKDIR_P) "$(DESTDIR)$(man1dir)"
+       @list=''; test -n "$(man1dir)" || exit 0; \
+       { for i in $$list; do echo "$$i"; done; \
+       l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.1[a-z]*$$/p'; \
+       } | while read p; do \
+         if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+         echo "$$d$$p"; echo "$$p"; \
+       done | \
+       sed -e 'n;s,.*/,,;p;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,' | \
+       sed 'N;N;s,\n, ,g' | { \
+       list=; while read file base inst; do \
+         if test "$$base" = "$$inst"; then list="$$list $$file"; else \
+           echo " $(INSTALL_DATA) '$$file' '$(DESTDIR)$(man1dir)/$$inst'"; \
+           $(INSTALL_DATA) "$$file" "$(DESTDIR)$(man1dir)/$$inst" || exit $$?; \
+         fi; \
+       done; \
+       for i in $$list; do echo "$$i"; done | $(am__base_list) | \
+       while read files; do \
+         test -z "$$files" || { \
+           echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(man1dir)'"; \
+           $(INSTALL_DATA) $$files "$(DESTDIR)$(man1dir)" || exit $$?; }; \
+       done; }
+
+uninstall-man1:
+       @$(NORMAL_UNINSTALL)
+       @list=''; test -n "$(man1dir)" || exit 0; \
+       files=`{ for i in $$list; do echo "$$i"; done; \
+       l2='$(man_MANS)'; for i in $$l2; do echo "$$i"; done | \
+         sed -n '/\.1[a-z]*$$/p'; \
+       } | sed -e 's,.*/,,;h;s,.*\.,,;s,^[^1][0-9a-z]*$$,1,;x' \
+             -e 's,\.[0-9a-z]*$$,,;$(transform);G;s,\n,.,'`; \
+       test -z "$$files" || { \
+         echo " ( cd '$(DESTDIR)$(man1dir)' && rm -f" $$files ")"; \
+         cd "$(DESTDIR)$(man1dir)" && rm -f $$files; }
+
+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)
+       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; }; }'`; \
+       shift; \
+       if test -z "$(ETAGS_ARGS)$$*$$unique"; then :; else \
+         test -n "$$unique" || unique=$$empty_fix; \
+         if test $$# -gt 0; then \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             "$$@" $$unique; \
+         else \
+           $(ETAGS) $(ETAGSFLAGS) $(AM_ETAGSFLAGS) $(ETAGS_ARGS) \
+             $$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; }; }'`; \
+       test -z "$(CTAGS_ARGS)$$unique" \
+         || $(CTAGS) $(CTAGSFLAGS) $(AM_CTAGSFLAGS) $(CTAGS_ARGS) \
+            $$unique
+
+GTAGS:
+       here=`$(am__cd) $(top_builddir) && pwd` \
+         && $(am__cd) $(top_srcdir) \
+         && gtags -i $(GTAGS_ARGS) "$$here"
+
+distclean-tags:
+       -rm -f TAGS ID GTAGS GRTAGS GSYMS GPATH tags
+
+distdir: $(DISTFILES)
+       @list='$(MANS)'; if test -n "$$list"; then \
+         list=`for p in $$list; do \
+           if test -f $$p; then d=; else d="$(srcdir)/"; fi; \
+           if test -f "$$d$$p"; then echo "$$d$$p"; else :; fi; done`; \
+         if test -n "$$list" && \
+           grep 'ab help2man is required to generate this page' $$list >/dev/null; then \
+           echo "error: found man pages containing the \`missing help2man' replacement text:" >&2; \
+           grep -l 'ab help2man is required to generate this page' $$list | sed 's/^/         /' >&2; \
+           echo "       to fix them, install help2man, remove and regenerate the man pages;" >&2; \
+           echo "       typically \`make maintainer-clean' will remove them" >&2; \
+           exit 1; \
+         else :; fi; \
+       else :; fi
+       @srcdirstrip=`echo "$(srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       topsrcdirstrip=`echo "$(top_srcdir)" | sed 's/[].[^$$\\*]/\\\\&/g'`; \
+       list='$(DISTFILES)'; \
+         dist_files=`for file in $$list; do echo $$file; done | \
+         sed -e "s|^$$srcdirstrip/||;t" \
+             -e "s|^$$topsrcdirstrip/|$(top_builddir)/|;t"`; \
+       case $$dist_files in \
+         */*) $(MKDIR_P) `echo "$$dist_files" | \
+                          sed '/\//!d;s|^|$(distdir)/|;s,/[^/]*$$,,' | \
+                          sort -u` ;; \
+       esac; \
+       for file in $$dist_files; do \
+         if test -f $$file || test -d $$file; then d=.; else d=$(srcdir); fi; \
+         if test -d $$d/$$file; then \
+           dir=`echo "/$$file" | sed -e 's,/[^/]*$$,,'`; \
+           if test -d "$(distdir)/$$file"; then \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           if test -d $(srcdir)/$$file && test $$d != $(srcdir); then \
+             cp -fpR $(srcdir)/$$file "$(distdir)$$dir" || exit 1; \
+             find "$(distdir)/$$file" -type d ! -perm -700 -exec chmod u+rwx {} \;; \
+           fi; \
+           cp -fpR $$d/$$file "$(distdir)$$dir" || exit 1; \
+         else \
+           test -f "$(distdir)/$$file" \
+           || cp -p $$d/$$file "$(distdir)/$$file" \
+           || exit 1; \
+         fi; \
+       done
+check-am: all-am
+check: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) check-am
+all-am: Makefile $(ANSI2KNR) $(PROGRAMS) $(MANS)
+installdirs:
+       for dir in "$(DESTDIR)$(bindir)" "$(DESTDIR)$(man1dir)"; do \
+         test -z "$$dir" || $(MKDIR_P) "$$dir"; \
+       done
+install: $(BUILT_SOURCES)
+       $(MAKE) $(AM_MAKEFLAGS) install-am
+install-exec: install-exec-am
+install-data: install-data-am
+uninstall: uninstall-am
+
+install-am: all-am
+       @$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-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
+mostlyclean-generic:
+
+clean-generic:
+
+distclean-generic:
+       -test -z "$(CONFIG_CLEAN_FILES)" || rm -f $(CONFIG_CLEAN_FILES)
+       -test . = "$(srcdir)" || test -z "$(CONFIG_CLEAN_VPATH_FILES)" || rm -f $(CONFIG_CLEAN_VPATH_FILES)
+
+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-binPROGRAMS clean-generic clean-krextra clean-libtool \
+       mostlyclean-am
+
+distclean: distclean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+distclean-am: clean-am distclean-compile distclean-generic \
+       distclean-tags
+
+dvi: dvi-am
+
+dvi-am:
+
+html: html-am
+
+html-am:
+
+info: info-am
+
+info-am:
+
+install-data-am: install-man
+
+install-dvi: install-dvi-am
+
+install-dvi-am:
+
+install-exec-am: install-binPROGRAMS
+
+install-html: install-html-am
+
+install-html-am:
+
+install-info: install-info-am
+
+install-info-am:
+
+install-man: install-man1
+
+install-pdf: install-pdf-am
+
+install-pdf-am:
+
+install-ps: install-ps-am
+
+install-ps-am:
+
+installcheck-am:
+
+maintainer-clean: maintainer-clean-am
+       -rm -rf ./$(DEPDIR)
+       -rm -f Makefile
+maintainer-clean-am: distclean-am maintainer-clean-generic
+
+mostlyclean: mostlyclean-am
+
+mostlyclean-am: mostlyclean-compile mostlyclean-generic mostlyclean-kr \
+       mostlyclean-libtool
+
+pdf: pdf-am
+
+pdf-am:
+
+ps: ps-am
+
+ps-am:
+
+uninstall-am: uninstall-binPROGRAMS uninstall-man
+
+uninstall-man: uninstall-man1
+
+.MAKE: all check install install-am install-strip
+
+.PHONY: CTAGS GTAGS all all-am check check-am clean clean-binPROGRAMS \
+       clean-generic clean-krextra clean-libtool ctags distclean \
+       distclean-compile distclean-generic distclean-libtool \
+       distclean-tags distdir dvi dvi-am html html-am info info-am \
+       install install-am install-binPROGRAMS 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-man1 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 \
+       uninstall-binPROGRAMS uninstall-man uninstall-man1
+
+
+$(srcdir)/ntp-keygen-opts.h: $(srcdir)/ntp-keygen-opts.c
+$(srcdir)/ntp-keygen-opts.c: $(srcdir)/ntp-keygen-opts.def $(std_def_list)
+       $(run_ag) ntp-keygen-opts.def
+
+$(srcdir)/ntp-keygen.1: $(srcdir)/ntp-keygen-opts.def $(std_def_list)
+       $(run_ag) -Tagman1.tpl -bntp-keygen ntp-keygen-opts.def
+
+$(srcdir)/ntp-keygen-opts.texi $(srcdir)/ntp-keygen-opts.menu: $(srcdir)/ntp-keygen-opts.def $(std_def_list)
+       $(run_ag) -Taginfo.tpl -DLEVEL=section ntp-keygen-opts.def
+
+../libntp/libntp.a:
+       cd ../libntp && $(MAKE)
+
+kern.o: kern.c
+       $(COMPILE) -DHAVE_TIMEX_H -c kern.c
+
+# 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.
+.NOEXPORT:
diff --git a/util/README b/util/README
new file mode 100644 (file)
index 0000000..297a562
--- /dev/null
@@ -0,0 +1,37 @@
+README file for directory ./util of the NTP Version 4 distribution
+
+This directory contains the sources for the various utility programs.
+See the README and RELNOTES files in the parent directory for directions
+on how to make and install these programs.
+
+The ntptime.c program checks the kernel configuration for the NTP user
+interface syscalls ntp_gettime() and ntp_adjtime().  If present, the
+current timekeeping data are displayed.  If not, a dissapointment is
+displayed.  See the kernel page file in the HTML documentation in
+distribution for further details. ntptime will be built be if configure
+believes your system can use it.
+
+The jitter.c program can be used to determine the timing jitter due to
+the operating system in a gettimeofday() call.  For most systems the
+dominant contribution to the jitter budget is the period of the hardware
+interrupt, usually in the range 10 us-1 ms.  For those systems with
+microsecond counters, such as recent Sun and certain HP and DEC systems,
+the jitter is dominated only by the operating system.
+
+The timetrim.c program can be used with SGI machines to implement a
+scheme to discipline the hardware clock frequency.  See the source code
+for further information.
+
+The byteorder.c and longsize.c programs are used during the configuration
+process to determine the byte order (little or big endian) and longword
+size (32 or 64 bits).  See the configure scripts for further details.
+
+The testrs6000.c program is used for testing purposes with the IBM
+RS/6000 AIX machines. Bill Jones <jones@chpc.utexas.edu> reports:
+"I could not get a tickadj of less than 40 us to work on a RS6000.
+If you set it less than 40 us do so at your own risk!"
+
+The tickadj.c program can be used to read and set various kernel
+parameters affecting NTP operations. See the tickadj page in the HTML
+documentation for further details.  tickadj will be built if configure
+believes your system can use it.
diff --git a/util/ansi2knr.1 b/util/ansi2knr.1
new file mode 100644 (file)
index 0000000..f9ee5a6
--- /dev/null
@@ -0,0 +1,36 @@
+.TH ANSI2KNR 1 "19 Jan 1996"
+.SH NAME
+ansi2knr \- convert ANSI C to Kernighan & Ritchie C
+.SH SYNOPSIS
+.I ansi2knr
+[--varargs] input_file [output_file]
+.SH DESCRIPTION
+If no output_file is supplied, output goes to stdout.
+.br
+There are no error messages.
+.sp
+.I ansi2knr
+recognizes function definitions by seeing a non-keyword identifier at the left
+margin, followed by a left parenthesis, with a right parenthesis as the last
+character on the line, and with a left brace as the first token on the
+following line (ignoring possible intervening comments).  It will recognize a
+multi-line header provided that no intervening line ends with a left or right
+brace or a semicolon.  These algorithms ignore whitespace and comments, except
+that the function name must be the first thing on the line.
+.sp
+The following constructs will confuse it:
+.br
+     - Any other construct that starts at the left margin and follows the
+above syntax (such as a macro or function call).
+.br
+     - Some macros that tinker with the syntax of the function header.
+.sp
+The --varargs switch is obsolete, and is recognized only for
+backwards compatibility.  The present version of
+.I ansi2knr
+will always attempt to convert a ... argument to va_alist and va_dcl.
+.SH AUTHOR
+L. Peter Deutsch <ghost@aladdin.com> wrote the original ansi2knr and
+continues to maintain the current version; most of the code in the current
+version is his work.  ansi2knr also includes contributions by Francois
+Pinard <pinard@iro.umontreal.ca> and Jim Avera <jima@netcom.com>.
diff --git a/util/ansi2knr.c b/util/ansi2knr.c
new file mode 100644 (file)
index 0000000..a042674
--- /dev/null
@@ -0,0 +1,739 @@
+/* Copyright (C) 1989, 2000 Aladdin Enterprises.  All rights reserved. */
+
+/*$Id: ansi2knr.c,v 1.3 2000/04/13 03:41:48 lpd Exp $*/
+/* Convert ANSI C function definitions to K&R ("traditional C") syntax */
+
+/*
+ansi2knr is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY.  No author or distributor accepts responsibility to anyone for the
+consequences of using it or for whether it serves any particular purpose or
+works at all, unless he says so in writing.  Refer to the GNU General Public
+License (the "GPL") for full details.
+
+Everyone is granted permission to copy, modify and redistribute ansi2knr,
+but only under the conditions described in the GPL.  A copy of this license
+is supposed to have been given to you along with ansi2knr so you can know
+your rights and responsibilities.  It should be in a file named COPYLEFT,
+or, if there is no file named COPYLEFT, a file named COPYING.  Among other
+things, the copyright notice and this notice must be preserved on all
+copies.
+
+We explicitly state here what we believe is already implied by the GPL: if
+the ansi2knr program is distributed as a separate set of sources and a
+separate executable file which are aggregated on a storage medium together
+with another program, this in itself does not bring the other program under
+the GPL, nor does the mere fact that such a program or the procedures for
+constructing it invoke the ansi2knr executable bring any other part of the
+program under the GPL.
+*/
+
+/*
+ * Usage:
+       ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]
+ * --filename provides the file name for the #line directive in the output,
+ * overriding input_file (if present).
+ * If no input_file is supplied, input is read from stdin.
+ * If no output_file is supplied, output goes to stdout.
+ * There are no error messages.
+ *
+ * ansi2knr recognizes function definitions by seeing a non-keyword
+ * identifier at the left margin, followed by a left parenthesis, with a
+ * right parenthesis as the last character on the line, and with a left
+ * brace as the first token on the following line (ignoring possible
+ * intervening comments and/or preprocessor directives), except that a line
+ * consisting of only
+ *     identifier1(identifier2)
+ * will not be considered a function definition unless identifier2 is
+ * the word "void", and a line consisting of
+ *     identifier1(identifier2, <<arbitrary>>)
+ * will not be considered a function definition.
+ * ansi2knr will recognize a multi-line header provided that no intervening
+ * line ends with a left or right brace or a semicolon.  These algorithms
+ * ignore whitespace, comments, and preprocessor directives, except that
+ * the function name must be the first thing on the line.  The following
+ * constructs will confuse it:
+ *     - Any other construct that starts at the left margin and
+ *         follows the above syntax (such as a macro or function call).
+ *     - Some macros that tinker with the syntax of function headers.
+ */
+
+/*
+ * The original and principal author of ansi2knr is L. Peter Deutsch
+ * <ghost@aladdin.com>.  Other authors are noted in the change history
+ * that follows (in reverse chronological order):
+
+       lpd 2000-04-12 backs out Eggert's changes because of bugs:
+       - concatlits didn't declare the type of its bufend argument;
+       - concatlits didn't recognize when it was inside a comment;
+       - scanstring could scan backward past the beginning of the string; when
+       - the check for \ + newline in scanstring was unnecessary.
+
+       2000-03-05  Paul Eggert  <eggert@twinsun.com>
+
+       Add support for concatenated string literals.
+       * ansi2knr.c (concatlits): New decl.
+       (main): Invoke concatlits to concatenate string literals.
+       (scanstring): Handle backslash-newline correctly.  Work with
+       character constants.  Fix bug when scanning backwards through
+       backslash-quote.  Check for unterminated strings.
+       (convert1): Parse character constants, too.
+       (appendline, concatlits): New functions.
+       * ansi2knr.1: Document this.
+
+       lpd 1999-08-17 added code to allow preprocessor directives
+               wherever comments are allowed
+       lpd 1999-04-12 added minor fixes from Pavel Roskin
+               <pavel_roskin@geocities.com> for clean compilation with
+               gcc -W -Wall
+       lpd 1999-03-22 added hack to recognize lines consisting of
+               identifier1(identifier2, xxx) as *not* being procedures
+       lpd 1999-02-03 made indentation of preprocessor commands consistent
+       lpd 1999-01-28 fixed two bugs: a '/' in an argument list caused an
+               endless loop; quoted strings within an argument list
+               confused the parser
+       lpd 1999-01-24 added a check for write errors on the output,
+               suggested by Jim Meyering <meyering@ascend.com>
+       lpd 1998-11-09 added further hack to recognize identifier(void)
+               as being a procedure
+       lpd 1998-10-23 added hack to recognize lines consisting of
+               identifier1(identifier2) as *not* being procedures
+       lpd 1997-12-08 made input_file optional; only closes input and/or
+               output file if not stdin or stdout respectively; prints
+               usage message on stderr rather than stdout; adds
+               --filename switch (changes suggested by
+               <ceder@lysator.liu.se>)
+       lpd 1996-01-21 added code to cope with not HAVE_CONFIG_H and with
+               compilers that don't understand void, as suggested by
+               Tom Lane
+       lpd 1996-01-15 changed to require that the first non-comment token
+               on the line following a function header be a left brace,
+               to reduce sensitivity to macros, as suggested by Tom Lane
+               <tgl@sss.pgh.pa.us>
+       lpd 1995-06-22 removed #ifndefs whose sole purpose was to define
+               undefined preprocessor symbols as 0; changed all #ifdefs
+               for configuration symbols to #ifs
+       lpd 1995-04-05 changed copyright notice to make it clear that
+               including ansi2knr in a program does not bring the entire
+               program under the GPL
+       lpd 1994-12-18 added conditionals for systems where ctype macros
+               don't handle 8-bit characters properly, suggested by
+               Francois Pinard <pinard@iro.umontreal.ca>;
+               removed --varargs switch (this is now the default)
+       lpd 1994-10-10 removed CONFIG_BROKETS conditional
+       lpd 1994-07-16 added some conditionals to help GNU `configure',
+               suggested by Francois Pinard <pinard@iro.umontreal.ca>;
+               properly erase prototype args in function parameters,
+               contributed by Jim Avera <jima@netcom.com>;
+               correct error in writeblanks (it shouldn't erase EOLs)
+       lpd 1989-xx-xx original version
+ */
+
+/* Most of the conditionals here are to make ansi2knr work with */
+/* or without the GNU configure machinery. */
+
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+
+#if HAVE_CONFIG_H
+
+/*
+   For properly autoconfiguring ansi2knr, use AC_CONFIG_HEADER(config.h).
+   This will define HAVE_CONFIG_H and so, activate the following lines.
+ */
+
+# if STDC_HEADERS || HAVE_STRING_H
+#  include <string.h>
+# else
+#  include <strings.h>
+# endif
+
+#else /* not HAVE_CONFIG_H */
+
+/* Otherwise do it the hard way */
+
+# ifdef BSD
+#  include <strings.h>
+# else
+#  ifdef VMS
+    extern int strlen(), strncmp();
+#  else
+#   include <string.h>
+#  endif
+# endif
+
+#endif /* not HAVE_CONFIG_H */
+
+#if STDC_HEADERS
+# include <stdlib.h>
+#else
+/*
+   malloc and free should be declared in stdlib.h,
+   but if you've got a K&R compiler, they probably aren't.
+ */
+# ifdef MSDOS
+#  include <malloc.h>
+# else
+#  ifdef VMS
+     extern char *malloc();
+     extern void free();
+#  else
+     extern char *malloc();
+     extern int free();
+#  endif
+# endif
+
+#endif
+
+/* Define NULL (for *very* old compilers). */
+#ifndef NULL
+# define NULL (0)
+#endif
+
+/*
+ * The ctype macros don't always handle 8-bit characters correctly.
+ * Compensate for this here.
+ */
+#ifdef isascii
+# undef HAVE_ISASCII           /* just in case */
+# define HAVE_ISASCII 1
+#else
+#endif
+#if STDC_HEADERS || !HAVE_ISASCII
+# define is_ascii(c) 1
+#else
+# define is_ascii(c) isascii(c)
+#endif
+
+#define is_space(c) (is_ascii(c) && isspace(c))
+#define is_alpha(c) (is_ascii(c) && isalpha(c))
+#define is_alnum(c) (is_ascii(c) && isalnum(c))
+
+/* Scanning macros */
+#define isidchar(ch) (is_alnum(ch) || (ch) == '_')
+#define isidfirstchar(ch) (is_alpha(ch) || (ch) == '_')
+
+/* Forward references */
+char *ppdirforward();
+char *ppdirbackward();
+char *skipspace();
+char *scanstring();
+int writeblanks();
+int test1();
+int convert1();
+
+/* The main program */
+int
+main(argc, argv)
+    int argc;
+    char *argv[];
+{      FILE *in = stdin;
+       FILE *out = stdout;
+       char *filename = 0;
+       char *program_name = argv[0];
+       char *output_name = 0;
+#define bufsize 5000                   /* arbitrary size */
+       char *buf;
+       char *line;
+       char *more;
+       char *usage =
+         "Usage: ansi2knr [--filename FILENAME] [INPUT_FILE [OUTPUT_FILE]]\n";
+       /*
+        * In previous versions, ansi2knr recognized a --varargs switch.
+        * If this switch was supplied, ansi2knr would attempt to convert
+        * a ... argument to va_alist and va_dcl; if this switch was not
+        * supplied, ansi2knr would simply drop any such arguments.
+        * Now, ansi2knr always does this conversion, and we only
+        * check for this switch for backward compatibility.
+        */
+       int convert_varargs = 1;
+       int output_error;
+
+       while ( argc > 1 && argv[1][0] == '-' ) {
+         if ( !strcmp(argv[1], "--varargs") ) {
+           convert_varargs = 1;
+           argc--;
+           argv++;
+           continue;
+         }
+         if ( !strcmp(argv[1], "--filename") && argc > 2 ) {
+           filename = argv[2];
+           argc -= 2;
+           argv += 2;
+           continue;
+         }
+         fprintf(stderr, "%s: Unrecognized switch: %s\n", program_name,
+                 argv[1]);
+         fprintf(stderr, usage);
+         exit(1);
+       }
+       switch ( argc )
+          {
+       default:
+               fprintf(stderr, usage);
+               exit(0);
+       case 3:
+               output_name = argv[2];
+               out = fopen(output_name, "w");
+               if ( out == NULL ) {
+                 fprintf(stderr, "%s: Cannot open output file %s\n",
+                         program_name, output_name);
+                 exit(1);
+               }
+               /* falls through */
+       case 2:
+               in = fopen(argv[1], "r");
+               if ( in == NULL ) {
+                 fprintf(stderr, "%s: Cannot open input file %s\n",
+                         program_name, argv[1]);
+                 exit(1);
+               }
+               if ( filename == 0 )
+                 filename = argv[1];
+               /* falls through */
+       case 1:
+               break;
+          }
+       if ( filename )
+         fprintf(out, "#line 1 \"%s\"\n", filename);
+       buf = malloc(bufsize);
+       if ( buf == NULL )
+          {
+               fprintf(stderr, "Unable to allocate read buffer!\n");
+               exit(1);
+          }
+       line = buf;
+       while ( fgets(line, (unsigned)(buf + bufsize - line), in) != NULL )
+          {
+test:          line += strlen(line);
+               switch ( test1(buf) )
+                  {
+               case 2:                 /* a function header */
+                       convert1(buf, out, 1, convert_varargs);
+                       break;
+               case 1:                 /* a function */
+                       /* Check for a { at the start of the next line. */
+                       more = ++line;
+f:                     if ( line >= buf + (bufsize - 1) ) /* overflow check */
+                         goto wl;
+                       if ( fgets(line, (unsigned)(buf + bufsize - line), in) == NULL )
+                         goto wl;
+                       switch ( *skipspace(ppdirforward(more), 1) )
+                         {
+                         case '{':
+                           /* Definitely a function header. */
+                           convert1(buf, out, 0, convert_varargs);
+                           fputs(more, out);
+                           break;
+                         case 0:
+                           /* The next line was blank or a comment: */
+                           /* keep scanning for a non-comment. */
+                           line += strlen(line);
+                           goto f;
+                         default:
+                           /* buf isn't a function header, but */
+                           /* more might be. */
+                           fputs(buf, out);
+                           strcpy(buf, more);
+                           line = buf;
+                           goto test;
+                         }
+                       break;
+               case -1:                /* maybe the start of a function */
+                       if ( line != buf + (bufsize - 1) ) /* overflow check */
+                         continue;
+                       /* falls through */
+               default:                /* not a function */
+wl:                    fputs(buf, out);
+                       break;
+                  }
+               line = buf;
+          }
+       if ( line != buf )
+         fputs(buf, out);
+       free(buf);
+       if ( output_name ) {
+         output_error = ferror(out);
+         output_error |= fclose(out);
+       } else {                /* out == stdout */
+         fflush(out);
+         output_error = ferror(out);
+       }
+       if ( output_error ) {
+         fprintf(stderr, "%s: error writing to %s\n", program_name,
+                 (output_name ? output_name : "stdout"));
+         exit(1);
+       }
+       if ( in != stdin )
+         fclose(in);
+       return 0;
+}
+
+/*
+ * Skip forward or backward over one or more preprocessor directives.
+ */
+char *
+ppdirforward(p)
+    char *p;
+{
+    for (; *p == '#'; ++p) {
+       for (; *p != '\r' && *p != '\n'; ++p)
+           if (*p == 0)
+               return p;
+       if (*p == '\r' && p[1] == '\n')
+           ++p;
+    }
+    return p;
+}
+char *
+ppdirbackward(p, limit)
+    char *p;
+    char *limit;
+{
+    char *np = p;
+
+    for (;; p = --np) {
+       if (*np == '\n' && np[-1] == '\r')
+           --np;
+       for (; np > limit && np[-1] != '\r' && np[-1] != '\n'; --np)
+           if (np[-1] == 0)
+               return np;
+       if (*np != '#')
+           return p;
+    }
+}
+
+/*
+ * Skip over whitespace, comments, and preprocessor directives,
+ * in either direction.
+ */
+char *
+skipspace(p, dir)
+    char *p;
+    int dir;                   /* 1 for forward, -1 for backward */
+{
+    for ( ; ; ) {
+       while ( is_space(*p) )
+           p += dir;
+       if ( !(*p == '/' && p[dir] == '*') )
+           break;
+       p += dir;  p += dir;
+       while ( !(*p == '*' && p[dir] == '/') ) {
+           if ( *p == 0 )
+               return p;       /* multi-line comment?? */
+           p += dir;
+       }
+       p += dir;  p += dir;
+    }
+    return p;
+}
+
+/* Scan over a quoted string, in either direction. */
+char *
+scanstring(p, dir)
+    char *p;
+    int dir;
+{
+    for (p += dir; ; p += dir)
+       if (*p == '"' && p[-dir] != '\\')
+           return p + dir;
+}
+
+/*
+ * Write blanks over part of a string.
+ * Don't overwrite end-of-line characters.
+ */
+int
+writeblanks(start, end)
+    char *start;
+    char *end;
+{      char *p;
+       for ( p = start; p < end; p++ )
+         if ( *p != '\r' && *p != '\n' )
+           *p = ' ';
+       return 0;
+}
+
+/*
+ * Test whether the string in buf is a function definition.
+ * The string may contain and/or end with a newline.
+ * Return as follows:
+ *     0 - definitely not a function definition;
+ *     1 - definitely a function definition;
+ *     2 - definitely a function prototype (NOT USED);
+ *     -1 - may be the beginning of a function definition,
+ *             append another line and look again.
+ * The reason we don't attempt to convert function prototypes is that
+ * Ghostscript's declaration-generating macros look too much like
+ * prototypes, and confuse the algorithms.
+ */
+int
+test1(buf)
+    char *buf;
+{      char *p = buf;
+       char *bend;
+       char *endfn;
+       int contin;
+
+       if ( !isidfirstchar(*p) )
+         return 0;             /* no name at left margin */
+       bend = skipspace(ppdirbackward(buf + strlen(buf) - 1, buf), -1);
+       switch ( *bend )
+          {
+          case ';': contin = 0 /*2*/; break;
+          case ')': contin = 1; break;
+          case '{': return 0;          /* not a function */
+          case '}': return 0;          /* not a function */
+          default: contin = -1;
+          }
+       while ( isidchar(*p) )
+         p++;
+       endfn = p;
+       p = skipspace(p, 1);
+       if ( *p++ != '(' )
+         return 0;             /* not a function */
+       p = skipspace(p, 1);
+       if ( *p == ')' )
+         return 0;             /* no parameters */
+       /* Check that the apparent function name isn't a keyword. */
+       /* We only need to check for keywords that could be followed */
+       /* by a left parenthesis (which, unfortunately, is most of them). */
+          {    static char *words[] =
+                  {    "asm", "auto", "case", "char", "const", "double",
+                       "extern", "float", "for", "if", "int", "long",
+                       "register", "return", "short", "signed", "sizeof",
+                       "static", "switch", "typedef", "unsigned",
+                       "void", "volatile", "while", 0
+                  };
+               char **key = words;
+               char *kp;
+               unsigned len = endfn - buf;
+
+               while ( (kp = *key) != 0 )
+                  {    if ( strlen(kp) == len && !strncmp(kp, buf, len) )
+                         return 0;     /* name is a keyword */
+                       key++;
+                  }
+          }
+          {
+              char *id = p;
+              int len;
+              /*
+               * Check for identifier1(identifier2) and not
+               * identifier1(void), or identifier1(identifier2, xxxx).
+               */
+
+              while ( isidchar(*p) )
+                  p++;
+              len = p - id;
+              p = skipspace(p, 1);
+              if (*p == ',' ||
+                  (*p == ')' && (len != 4 || strncmp(id, "void", 4)))
+                  )
+                  return 0;    /* not a function */
+          }
+       /*
+        * If the last significant character was a ), we need to count
+        * parentheses, because it might be part of a formal parameter
+        * that is a procedure.
+        */
+       if (contin > 0) {
+           int level = 0;
+
+           for (p = skipspace(buf, 1); *p; p = skipspace(p + 1, 1))
+               level += (*p == '(' ? 1 : *p == ')' ? -1 : 0);
+           if (level > 0)
+               contin = -1;
+       }
+       return contin;
+}
+
+/* Convert a recognized function definition or header to K&R syntax. */
+int
+convert1(buf, out, header, convert_varargs)
+    char *buf;
+    FILE *out;
+    int header;                        /* Boolean */
+    int convert_varargs;       /* Boolean */
+{      char *endfn;
+       char *p;
+       /*
+        * The breaks table contains pointers to the beginning and end
+        * of each argument.
+        */
+       char **breaks;
+       unsigned num_breaks = 2;        /* for testing */
+       char **btop;
+       char **bp;
+       char **ap;
+       char *vararg = 0;
+
+       /* Pre-ANSI implementations don't agree on whether strchr */
+       /* is called strchr or index, so we open-code it here. */
+       for ( endfn = buf; *(endfn++) != '('; )
+         ;
+top:   p = endfn;
+       breaks = (char **)malloc(sizeof(char *) * num_breaks * 2);
+       if ( breaks == NULL )
+          {    /* Couldn't allocate break table, give up */
+               fprintf(stderr, "Unable to allocate break table!\n");
+               fputs(buf, out);
+               return -1;
+          }
+       btop = breaks + num_breaks * 2 - 2;
+       bp = breaks;
+       /* Parse the argument list */
+       do
+          {    int level = 0;
+               char *lp = NULL;
+               char *rp = NULL;
+               char *end = NULL;
+
+               if ( bp >= btop )
+                  {    /* Filled up break table. */
+                       /* Allocate a bigger one and start over. */
+                       free((char *)breaks);
+                       num_breaks <<= 1;
+                       goto top;
+                  }
+               *bp++ = p;
+               /* Find the end of the argument */
+               for ( ; end == NULL; p++ )
+                  {    switch(*p)
+                          {
+                          case ',':
+                               if ( !level ) end = p;
+                               break;
+                          case '(':
+                               if ( !level ) lp = p;
+                               level++;
+                               break;
+                          case ')':
+                               if ( --level < 0 ) end = p;
+                               else rp = p;
+                               break;
+                          case '/':
+                               if (p[1] == '*')
+                                   p = skipspace(p, 1) - 1;
+                               break;
+                          case '"':
+                              p = scanstring(p, 1) - 1;
+                              break;
+                          default:
+                               ;
+                          }
+                  }
+               /* Erase any embedded prototype parameters. */
+               if ( lp && rp )
+                 writeblanks(lp + 1, rp);
+               p--;                    /* back up over terminator */
+               /* Find the name being declared. */
+               /* This is complicated because of procedure and */
+               /* array modifiers. */
+               for ( ; ; )
+                  {    p = skipspace(p - 1, -1);
+                       switch ( *p )
+                          {
+                          case ']':    /* skip array dimension(s) */
+                          case ')':    /* skip procedure args OR name */
+                          {    int level = 1;
+                               while ( level )
+                                switch ( *--p )
+                                  {
+                                  case ']': case ')':
+                                      level++;
+                                      break;
+                                  case '[': case '(':
+                                      level--;
+                                      break;
+                                  case '/':
+                                      if (p > buf && p[-1] == '*')
+                                          p = skipspace(p, -1) + 1;
+                                      break;
+                                  case '"':
+                                      p = scanstring(p, -1) + 1;
+                                      break;
+                                  default: ;
+                                  }
+                          }
+                               if ( *p == '(' && *skipspace(p + 1, 1) == '*' )
+                                  {    /* We found the name being declared */
+                                       while ( !isidfirstchar(*p) )
+                                         p = skipspace(p, 1) + 1;
+                                       goto found;
+                                  }
+                               break;
+                          default:
+                               goto found;
+                          }
+                  }
+found:         if ( *p == '.' && p[-1] == '.' && p[-2] == '.' )
+                 {     if ( convert_varargs )
+                         {     *bp++ = "va_alist";
+                               vararg = p-2;
+                         }
+                       else
+                         {     p++;
+                               if ( bp == breaks + 1 ) /* sole argument */
+                                 writeblanks(breaks[0], p);
+                               else
+                                 writeblanks(bp[-1] - 1, p);
+                               bp--;
+                         }
+                  }
+               else
+                  {    while ( isidchar(*p) ) p--;
+                       *bp++ = p+1;
+                  }
+               p = end;
+          }
+       while ( *p++ == ',' );
+       *bp = p;
+       /* Make a special check for 'void' arglist */
+       if ( bp == breaks+2 )
+          {    p = skipspace(breaks[0], 1);
+               if ( !strncmp(p, "void", 4) )
+                  {    p = skipspace(p+4, 1);
+                       if ( p == breaks[2] - 1 )
+                          {    bp = breaks;    /* yup, pretend arglist is empty */
+                               writeblanks(breaks[0], p + 1);
+                          }
+                  }
+          }
+       /* Put out the function name and left parenthesis. */
+       p = buf;
+       while ( p != endfn ) putc(*p, out), p++;
+       /* Put out the declaration. */
+       if ( header )
+         {     fputs(");", out);
+               for ( p = breaks[0]; *p; p++ )
+                 if ( *p == '\r' || *p == '\n' )
+                   putc(*p, out);
+         }
+       else
+         {     for ( ap = breaks+1; ap < bp; ap += 2 )
+                 {     p = *ap;
+                       while ( isidchar(*p) )
+                         putc(*p, out), p++;
+                       if ( ap < bp - 1 )
+                         fputs(", ", out);
+                 }
+               fputs(")  ", out);
+               /* Put out the argument declarations */
+               for ( ap = breaks+2; ap <= bp; ap += 2 )
+                 (*ap)[-1] = ';';
+               if ( vararg != 0 )
+                 {     *vararg = 0;
+                       fputs(breaks[0], out);          /* any prior args */
+                       fputs("va_dcl", out);           /* the final arg */
+                       fputs(bp[0], out);
+                 }
+               else
+                 fputs(breaks[0], out);
+         }
+       free((char *)breaks);
+       return 0;
+}
diff --git a/util/audio-pcm.c b/util/audio-pcm.c
new file mode 100644 (file)
index 0000000..6f2e4fa
--- /dev/null
@@ -0,0 +1,154 @@
+/*
+ * audio-pcm.c - Scope out the PCM audio stuff
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#if defined(HAVE_MACHINE_SOUNDCARD_H) || defined(HAVE_SYS_SOUNDCARD_H)
+
+#include "audio.h"
+#include "ntp_stdlib.h"
+#include "ntp_syslog.h"
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif
+#include <stdio.h>
+#include "ntp_string.h"
+
+#ifdef HAVE_SYS_IOCTL_H
+#include <sys/ioctl.h>
+#endif /* HAVE_SYS_IOCTL_H */
+
+#include <fcntl.h>
+
+#ifdef HAVE_MACHINE_SOUNDCARD_H
+# include <machine/soundcard.h>
+# define PCM_STYLE_SOUND
+#else
+# ifdef HAVE_SYS_SOUNDCARD_H
+#  include <sys/soundcard.h>
+#  define PCM_STYLE_SOUND
+# endif
+#endif
+
+/*
+ * Global variables
+ */
+static int ctl_fd;             /* audio control file descriptor */
+
+const char *m_names[SOUND_MIXER_NRDEVICES] = SOUND_DEVICE_NAMES ;
+
+void
+d_fmt(
+      unsigned int format
+      )
+{
+
+  if (format & AFMT_MU_LAW)    printf("MU_LAW ");
+  if (format & AFMT_A_LAW)     printf("A_LAW ");
+  if (format & AFMT_IMA_ADPCM) printf("IMA_ADPCM ");
+  if (format & AFMT_U8)                printf("U8 ");
+  if (format & AFMT_S16_LE)    printf("S16_LE ");
+  if (format & AFMT_S16_BE)    printf("S16_BE ");
+  if (format & AFMT_S8)                printf("S8 ");
+  if (format & AFMT_U16_LE)    printf("U16_LE ");
+  if (format & AFMT_U16_BE)    printf("U16_BE ");
+  if (format & AFMT_MPEG)      printf("MPEG ");
+  if (format & AFMT_AC3)       printf("AC3 ");
+  printf("\n");
+}
+
+void
+d_mixer(
+       unsigned int mixer
+       )
+{
+  int i;
+  int n = 0;
+
+  for (i = 0; i < SOUND_MIXER_NRDEVICES; ++i)
+    if ((1 << i) & mixer) {
+      if (n)
+       printf(", ");
+      printf("%s", m_names[i]);
+      n = 1;
+    }
+  printf("\n");
+}
+
+int
+main( )
+{
+       int     unit = 0;       /* device unit (0-3) */
+# define AI_DEV                "/dev/audio%d"
+# define AC_DEV                "/dev/mixer%d"
+       char ai_dev[30];
+       char ac_dev[30];
+       struct snd_size s_size;
+       snd_chan_param s_c_p;
+       snd_capabilities s_c;
+       int fd;
+       int rval;
+       char *dname = ai_dev;           /* device name */
+       char *actl = ac_dev;
+       int devmask = 0, recmask = 0, recsrc = 0;
+
+       (void)sprintf(ai_dev, AI_DEV, unit);
+       (void)sprintf(ac_dev, AC_DEV, unit);
+
+       /*
+        * Open audio device. Do not complain if not there.
+        */
+       fd = open(dname, O_RDWR | O_NONBLOCK, 0777);
+       if (fd < 0)
+               return (fd);
+
+       /*
+        * Open audio control device.
+        */
+       ctl_fd = open(actl, O_RDWR);
+       if (ctl_fd < 0) {
+               fprintf(stderr, "invalid control device <%s>\n", actl);
+               close(fd);
+               return(ctl_fd);
+       }
+
+       printf("input:   <%s> %d\n", dname, fd);
+       printf("control: <%s> %d\n", actl, ctl_fd);
+
+       if (ioctl(ctl_fd, SOUND_MIXER_READ_DEVMASK, &devmask) == -1)
+           printf("SOUND_MIXER_READ_DEVMASK: %s\n", strerror(errno));
+       if (ioctl(ctl_fd, SOUND_MIXER_READ_RECMASK, &recmask) == -1)
+           printf("SOUND_MIXER_READ_RECMASK: %s\n", strerror(errno));
+       if (ioctl(ctl_fd, SOUND_MIXER_READ_RECSRC, &recsrc) == -1)
+           printf("SOUND_MIXER_READ_RECSRC: %s\n", strerror(errno));
+
+       printf("devmask: %#x recmask: %#x recsrc: %#x\n",
+               devmask, recmask, recsrc);
+       printf("Devmask: "); d_mixer(devmask);
+       printf("Recmask: "); d_mixer(recmask);
+       printf("RecSrc:  "); d_mixer(recsrc);
+
+       /*
+        * Set audio device parameters.
+        */
+       rval = fd;
+
+       if (ioctl(fd, AIOGSIZE, &s_size) == -1)
+           printf("AIOGSIZE: %s\n", strerror(errno));
+       else
+           printf("play_size %d, rec_size %d\n",
+               s_size.play_size, s_size.rec_size);
+
+       if (ioctl(fd, AIOGFMT, &s_c_p) == -1)
+           printf("AIOGFMT: %s\n", strerror(errno));
+       else {
+         printf("play_rate %lu, rec_rate %lu, play_format %#lx, rec_format %#lx\n",
+                s_c_p.play_rate, s_c_p.rec_rate, s_c_p.play_format, s_c_p.rec_format);
+         printf("Play format: "); d_fmt(s_c_p.play_format);
+         printf("Rec format:  "); d_fmt(s_c_p.rec_format);
+       }
+
+}
+#endif /* HAVE_{MACHINE_SOUNDCARD,SYS_SOUNDCARD}_H */
diff --git a/util/byteorder.c b/util/byteorder.c
new file mode 100644 (file)
index 0000000..188536f
--- /dev/null
@@ -0,0 +1,56 @@
+/*
+ * This works on:
+ *   Crays
+ *   Conven
+ *   sparc's
+ *   Dec mip machines
+ *   Dec alpha machines
+ *   RS6000
+ *   SGI's
+ */
+
+#include <stdio.h>
+
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       int i;
+       int big;
+       union {
+               unsigned long l;
+               char c[sizeof(long)];
+       } u;
+
+#if defined(LONG8)
+       u.l = (((long)0x08070605) << 32) | (long)0x04030201;
+#else
+       u.l = 0x04030201;
+#endif
+       if (sizeof(long) > 4) {
+               if (u.c[0] == 0x08) big = 1;
+               else                big = 0;
+       } else {
+               if (u.c[0] == 0x04) big = 1;
+               else                big = 0;
+       }
+       for (i=0; i< sizeof(long); i++) {
+               if (big == 1 && (u.c[i] == (sizeof(long) - i))) { 
+                       continue; 
+               } else if (big == 0 && (u.c[i] == (i+1))) {
+                       continue;
+               } else {
+                       big = -1;
+                       break;
+               }
+       }
+
+       if (big == 1) {
+               printf("XNTP_BIG_ENDIAN\n");
+       } else if (big == 0) {
+               printf("XNTP_LITTLE_ENDIAN\n");
+       }
+       exit(0);
+}
diff --git a/util/hist.c b/util/hist.c
new file mode 100644 (file)
index 0000000..9453b6c
--- /dev/null
@@ -0,0 +1,113 @@
+/*
+ * This program can be used to calibrate the clock reading jitter of a
+ * particular CPU and operating system. It first tickles every element
+ * of an array, in order to force pages into memory, then repeatedly calls
+ * gettimeofday() and, finally, writes out the time values for later
+ * analysis. From this you can determine the jitter and if the clock ever
+ * runs backwards.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntp_types.h"
+
+#include <stdio.h>
+#include <stdlib.h>
+
+#define NBUF 100001            /* size of basic histogram */
+#define NSRT 20000             /* size of overflow histogram */
+#define NCNT (600 * 1000000)   /* sample interval (us) */
+
+int col P((long *, long *));
+
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       struct timeval ts, tr, tp;
+       struct timezone tzp;
+       int i, j, n;
+       long t, u, v, w, gtod[NBUF], ovfl[NSRT];
+
+       /*
+        * Force pages into memory
+        */
+       for (i = 0; i < NBUF; i++)
+           gtod[i] = 0;
+       for (i = 0; i < NSRT; i++)
+           ovfl[i] = 0;
+
+       /*
+        * Construct histogram
+        */
+       n = 0;
+       gettimeofday(&ts, &tzp);
+       t = ts.tv_sec * 1000000 + ts.tv_usec;
+       v = t;
+       while (1) {
+               gettimeofday(&tr, &tzp);
+               u = tr.tv_sec * 1000000 + tr.tv_usec; 
+               if (u - v > NCNT)
+                   break;
+               w = u - t;
+               if (w <= 0) {
+/*
+                       printf("error <= 0 %ld %d %d, %d %d\n", w, ts.tv_sec,
+                              ts.tv_usec, tr.tv_sec, tr.tv_usec);
+*/
+               } else if (w > NBUF - 1) {
+                       ovfl[n] = w;
+                       if (n < NSRT - 1)
+                           n++;
+               } else {
+                       gtod[w]++;
+               }
+               ts = tr;
+               t = u;
+       }
+
+       /*
+        * Write out histogram
+        */
+       for (i = 0; i < NBUF - 1; i++) {
+               if (gtod[i] > 0)
+                   printf("%ld %ld\n", i, gtod[i]);
+       }
+       if (n == 0)
+           return;
+       qsort(
+#ifdef QSORT_USES_VOID_P
+           (void *)
+#else
+           (char *)
+#endif
+           ovfl, (size_t)n, sizeof(long), col);
+       w = 0;
+       j = 0;
+       for (i = 0; i < n; i++) {
+               if (ovfl[i] != w) {
+                       if (j > 0)
+                           printf("%ld %ld\n", w, j);
+                       w = ovfl[i];
+                       j = 1;
+               } else
+                   j++;
+       }
+       if (j > 0)
+           printf("%ld %ld\n", w, j);
+       exit(0);
+}
+
+int
+col(
+       long *x,
+       long *y
+       )
+{
+       return (*x - *y);
+}
diff --git a/util/jitter.c b/util/jitter.c
new file mode 100644 (file)
index 0000000..dda2655
--- /dev/null
@@ -0,0 +1,137 @@
+/*
+ * This program can be used to calibrate the clock reading jitter of a
+ * particular CPU and operating system. It first tickles every element
+ * of an array, in order to force pages into memory, then repeatedly
+ * reads the system clock and, finally, writes out the time values for
+ * later analysis. From this you can determine the jitter and if the
+ * clock ever runs backwards.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <sys/time.h>
+#include <stdlib.h>
+#include "jitter.h"
+
+#define NBUF   80002
+#define FRAC   4294967296.             /* a bbbbillion */
+#define JAN_1970 2208988800UL          /* Unix base epoch */
+#define CLOCK_GETTIME                  /* Solaris hires clock */
+
+int debug;
+char progname[10];
+double sys_residual;
+double average;
+void sys_gettime(l_fp *);
+
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       l_fp tr;
+       int i, j;
+       double dtemp, gtod[NBUF];
+
+       /*
+        * Force pages into memory
+        */
+       for (i = 0; i < NBUF; i ++)
+           gtod[i] = 0;
+
+       /*
+        * Construct gtod array
+        */
+       for (i = 0; i < NBUF; i ++) {
+               get_systime(&tr);
+               LFPTOD(&tr, gtod[i]);
+       }
+
+       /*
+        * Write out gtod array for later processing with Matlab
+        */
+       average = 0;
+       for (i = 0; i < NBUF - 2; i++) {
+               gtod[i] = gtod[i + 1] - gtod[i];
+               printf("%13.9f\n", gtod[i]);
+               average += gtod[i];
+       }
+
+       /*
+        * Sort the gtod array and display deciles
+        */
+       for (i = 0; i < NBUF - 2; i++) {
+               for (j = 0; j <= i; j++) {
+                       if (gtod[j] > gtod[i]) {
+                               dtemp = gtod[j];
+                               gtod[j] = gtod[i];
+                               gtod[i] = dtemp;
+                       }
+               }
+       }
+       average = average / (NBUF - 2);
+       fprintf(stderr, "Average %13.9f\n", average);
+       fprintf(stderr, "First rank\n");
+       for (i = 0; i < 10; i++)
+               fprintf(stderr, "%2d %13.9f\n", i, gtod[i]);
+       fprintf(stderr, "Last rank\n");
+       for (i = NBUF - 12; i < NBUF - 2; i++)
+               fprintf(stderr, "%2d %13.9f\n", i, gtod[i]);
+       exit(0);
+}
+
+
+/*
+ * get_systime - return system time in NTP timestamp format.
+ */
+void
+get_systime(
+       l_fp *now               /* system time */
+       )
+{
+       double dtemp;
+
+#if defined(HAVE_CLOCK_GETTIME) || defined(HAVE_GETCLOCK)
+       struct timespec ts;     /* seconds and nanoseconds */
+
+       /*
+        * Convert Unix clock from seconds and nanoseconds to seconds.
+        */
+# 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;
+
+#else /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
+       struct timeval tv;      /* seconds and microseconds */
+
+       /*
+        * Convert Unix clock from seconds and microseconds to seconds.
+        */
+       gettimeofday(&tv, NULL);
+       now->l_i = tv.tv_sec + JAN_1970;
+       dtemp = tv.tv_usec / 1e6;
+
+#endif /* HAVE_CLOCK_GETTIME || HAVE_GETCLOCK */
+
+       /*
+        * Renormalize to seconds past 1900 and fraction.
+        */
+       dtemp += sys_residual;
+       if (dtemp >= 1) {
+               dtemp -= 1;
+               now->l_i++;
+       } else if (dtemp < -1) {
+               dtemp += 1;
+               now->l_i--;
+       }
+       dtemp *= FRAC;
+       now->l_uf = (u_int32)dtemp;
+}
diff --git a/util/jitter.h b/util/jitter.h
new file mode 100644 (file)
index 0000000..d0fba44
--- /dev/null
@@ -0,0 +1,412 @@
+/*
+ *  ntp_types.h - defines how int32 and u_int32 are treated.
+ *  For 64 bit systems like the DEC Alpha, they have to be defined
+ *  as int and u_int.
+ *  For 32 bit systems, define them as long and u_long
+ */
+#define SIZEOF_INT 4
+
+/*
+ * Set up for prototyping
+ */
+#ifndef P
+#if defined(__STDC__) || defined(HAVE_PROTOTYPES)
+#define P(x)    x
+#else /* not __STDC__ and not HAVE_PROTOTYPES */
+#define P(x)    ()
+#endif /* not __STDC__ and HAVE_PROTOTYPES */
+#endif /* P */
+
+/*
+ * VMS DECC (v4.1), {u_char,u_short,u_long} are only in SOCKET.H,
+ *                      and u_int isn't defined anywhere
+ */
+#if defined(VMS)
+#include <socket.h>
+typedef unsigned int u_int;
+/*
+ * Note: VMS DECC has  long == int  (even on __alpha),
+ *       so the distinction below doesn't matter
+ */
+#endif /* VMS */
+
+#if (SIZEOF_INT == 4)
+# ifndef int32
+#  define int32 int
+# endif
+# ifndef u_int32
+#  define u_int32 unsigned int
+# endif
+#else /* not sizeof(int) == 4 */
+# if (SIZEOF_LONG == 4)
+# else /* not sizeof(long) == 4 */
+#  ifndef int32
+#   define int32 long
+#  endif
+#  ifndef u_int32
+#   define u_int32 unsigned long
+#  endif
+# endif /* not sizeof(long) == 4 */
+# include "Bletch: what's 32 bits on this machine?"
+#endif /* not sizeof(int) == 4 */
+
+typedef unsigned short associd_t; /* association ID */
+typedef u_int32 keyid_t;        /* cryptographic key ID */
+typedef u_int32 tstamp_t;       /* NTP seconds timestamp */
+
+/*
+ * NTP uses two fixed point formats.  The first (l_fp) is the "long"
+ * format and is 64 bits long with the decimal between bits 31 and 32.
+ * This is used for time stamps in the NTP packet header (in network
+ * byte order) and for internal computations of offsets (in local host
+ * byte order). We use the same structure for both signed and unsigned
+ * values, which is a big hack but saves rewriting all the operators
+ * twice. Just to confuse this, we also sometimes just carry the
+ * fractional part in calculations, in both signed and unsigned forms.
+ * Anyway, an l_fp looks like:
+ *
+ *    0                          1                   2                   3
+ *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                        Integral Part                         |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |                        Fractional Part                       |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ */
+typedef struct {
+       union {
+               u_int32 Xl_ui;
+               int32 Xl_i;
+       } Ul_i;
+       union {
+               u_int32 Xl_uf;
+               int32 Xl_f;
+       } Ul_f;
+} l_fp;
+
+#define l_ui   Ul_i.Xl_ui              /* unsigned integral part */
+#define        l_i     Ul_i.Xl_i               /* signed integral part */
+#define        l_uf    Ul_f.Xl_uf              /* unsigned fractional part */
+#define        l_f     Ul_f.Xl_f               /* signed fractional part */
+
+/*
+ * Fractional precision (of an l_fp) is actually the number of
+ * bits in a long.
+ */
+#define        FRACTION_PREC   (32)
+
+
+/*
+ * The second fixed point format is 32 bits, with the decimal between
+ * bits 15 and 16.  There is a signed version (s_fp) and an unsigned
+ * version (u_fp).  This is used to represent synchronizing distance
+ * and synchronizing dispersion in the NTP packet header (again, in
+ * network byte order) and internally to hold both distance and
+ * dispersion values (in local byte order).  In network byte order
+ * it looks like:
+ *
+ *    0                          1                   2                   3
+ *    0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *   |           Integer Part       |     Fraction Part             |
+ *   +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
+ *
+ */
+typedef int32 s_fp;
+typedef u_int32 u_fp;
+
+/*
+ * A unit second in fp format.  Actually 2**(half_the_bits_in_a_long)
+ */
+#define        FP_SECOND       (0x10000)
+
+/*
+ * Byte order conversions
+ */
+#define        HTONS_FP(x)     (htonl(x))
+#define        HTONL_FP(h, n)  do { (n)->l_ui = htonl((h)->l_ui); \
+                            (n)->l_uf = htonl((h)->l_uf); } while (0)
+#define        NTOHS_FP(x)     (ntohl(x))
+#define        NTOHL_FP(n, h)  do { (h)->l_ui = ntohl((n)->l_ui); \
+                            (h)->l_uf = ntohl((n)->l_uf); } while (0)
+#define        NTOHL_MFP(ni, nf, hi, hf) \
+       do { (hi) = ntohl(ni); (hf) = ntohl(nf); } while (0)
+#define        HTONL_MFP(hi, hf, ni, nf) \
+       do { (ni) = ntohl(hi); (nf) = ntohl(hf); } while (0)
+
+/* funny ones.  Converts ts fractions to net order ts */
+#define        HTONL_UF(uf, nts) \
+       do { (nts)->l_ui = 0; (nts)->l_uf = htonl(uf); } while (0)
+#define        HTONL_F(f, nts) do { (nts)->l_uf = htonl(f); \
+                               if ((f) & 0x80000000) \
+                                       (nts)->l_i = -1; \
+                               else \
+                                       (nts)->l_i = 0; \
+                       } while (0)
+
+/*
+ * Conversions between the two fixed point types
+ */
+#define        MFPTOFP(x_i, x_f)       (((x_i) >= 0x00010000) ? 0x7fffffff : \
+                               (((x_i) <= -0x00010000) ? 0x80000000 : \
+                               (((x_i)<<16) | (((x_f)>>16)&0xffff))))
+#define        LFPTOFP(v)              MFPTOFP((v)->l_i, (v)->l_f)
+
+#define UFPTOLFP(x, v) ((v)->l_ui = (u_fp)(x)>>16, (v)->l_uf = (x)<<16)
+#define FPTOLFP(x, v)  (UFPTOLFP((x), (v)), (x) < 0 ? (v)->l_ui -= 0x10000 : 0)
+
+#define MAXLFP(v) ((v)->l_ui = 0x7fffffff, (v)->l_uf = 0xffffffff)
+#define MINLFP(v) ((v)->l_ui = 0x80000000, (v)->l_uf = 0)
+
+/*
+ * Primitive operations on long fixed point values.  If these are
+ * reminiscent of assembler op codes it's only because some may
+ * be replaced by inline assembler for particular machines someday.
+ * These are the (kind of inefficient) run-anywhere versions.
+ */
+#define        M_NEG(v_i, v_f)         /* v = -v */ \
+       do { \
+               if ((v_f) == 0) \
+                       (v_i) = -((s_fp)(v_i)); \
+               else { \
+                       (v_f) = -((s_fp)(v_f)); \
+                       (v_i) = ~(v_i); \
+               } \
+       } while(0)
+
+#define        M_NEGM(r_i, r_f, a_i, a_f)      /* r = -a */ \
+       do { \
+               if ((a_f) == 0) { \
+                       (r_f) = 0; \
+                       (r_i) = -(a_i); \
+               } else { \
+                       (r_f) = -(a_f); \
+                       (r_i) = ~(a_i); \
+               } \
+       } while(0)
+
+#define M_ADD(r_i, r_f, a_i, a_f)      /* r += a */ \
+       do { \
+               register u_int32 lo_tmp; \
+               register u_int32 hi_tmp; \
+               \
+               lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \
+               hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \
+               if (lo_tmp & 0x10000) \
+                       hi_tmp++; \
+               (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
+               \
+               (r_i) += (a_i); \
+               if (hi_tmp & 0x10000) \
+                       (r_i)++; \
+       } while (0)
+
+#define M_ADD3(r_ovr, r_i, r_f, a_ovr, a_i, a_f) /* r += a, three word */ \
+       do { \
+               register u_int32 lo_tmp; \
+               register u_int32 hi_tmp; \
+               \
+               lo_tmp = ((r_f) & 0xffff) + ((a_f) & 0xffff); \
+               hi_tmp = (((r_f) >> 16) & 0xffff) + (((a_f) >> 16) & 0xffff); \
+               if (lo_tmp & 0x10000) \
+                       hi_tmp++; \
+               (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
+               \
+               lo_tmp = ((r_i) & 0xffff) + ((a_i) & 0xffff); \
+               if (hi_tmp & 0x10000) \
+                       lo_tmp++; \
+               hi_tmp = (((r_i) >> 16) & 0xffff) + (((a_i) >> 16) & 0xffff); \
+               if (lo_tmp & 0x10000) \
+                       hi_tmp++; \
+               (r_i) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
+               \
+               (r_ovr) += (a_ovr); \
+               if (hi_tmp & 0x10000) \
+                       (r_ovr)++; \
+       } while (0)
+
+#define M_SUB(r_i, r_f, a_i, a_f)      /* r -= a */ \
+       do { \
+               register u_int32 lo_tmp; \
+               register u_int32 hi_tmp; \
+               \
+               if ((a_f) == 0) { \
+                       (r_i) -= (a_i); \
+               } else { \
+                       lo_tmp = ((r_f) & 0xffff) + ((-((s_fp)(a_f))) & 0xffff); \
+                       hi_tmp = (((r_f) >> 16) & 0xffff) \
+                           + (((-((s_fp)(a_f))) >> 16) & 0xffff); \
+                       if (lo_tmp & 0x10000) \
+                               hi_tmp++; \
+                       (r_f) = ((hi_tmp & 0xffff) << 16) | (lo_tmp & 0xffff); \
+                       \
+                       (r_i) += ~(a_i); \
+                       if (hi_tmp & 0x10000) \
+                               (r_i)++; \
+               } \
+       } while (0)
+
+#define        M_RSHIFTU(v_i, v_f)             /* v >>= 1, v is unsigned */ \
+       do { \
+               (v_f) = (u_int32)(v_f) >> 1; \
+               if ((v_i) & 01) \
+                       (v_f) |= 0x80000000; \
+               (v_i) = (u_int32)(v_i) >> 1; \
+       } while (0)
+
+#define        M_RSHIFT(v_i, v_f)              /* v >>= 1, v is signed */ \
+       do { \
+               (v_f) = (u_int32)(v_f) >> 1; \
+               if ((v_i) & 01) \
+                       (v_f) |= 0x80000000; \
+               if ((v_i) & 0x80000000) \
+                       (v_i) = ((v_i) >> 1) | 0x80000000; \
+               else \
+                       (v_i) = (v_i) >> 1; \
+       } while (0)
+
+#define        M_LSHIFT(v_i, v_f)              /* v <<= 1 */ \
+       do { \
+               (v_i) <<= 1; \
+               if ((v_f) & 0x80000000) \
+                       (v_i) |= 0x1; \
+               (v_f) <<= 1; \
+       } while (0)
+
+#define        M_LSHIFT3(v_ovr, v_i, v_f)      /* v <<= 1, with overflow */ \
+       do { \
+               (v_ovr) <<= 1; \
+               if ((v_i) & 0x80000000) \
+                       (v_ovr) |= 0x1; \
+               (v_i) <<= 1; \
+               if ((v_f) & 0x80000000) \
+                       (v_i) |= 0x1; \
+               (v_f) <<= 1; \
+       } while (0)
+
+#define        M_ADDUF(r_i, r_f, uf)           /* r += uf, uf is u_int32 fraction */ \
+       M_ADD((r_i), (r_f), 0, (uf))    /* let optimizer worry about it */
+
+#define        M_SUBUF(r_i, r_f, uf)           /* r -= uf, uf is u_int32 fraction */ \
+       M_SUB((r_i), (r_f), 0, (uf))    /* let optimizer worry about it */
+
+#define        M_ADDF(r_i, r_f, f)             /* r += f, f is a int32 fraction */ \
+       do { \
+               if ((f) > 0) \
+                       M_ADD((r_i), (r_f), 0, (f)); \
+               else if ((f) < 0) \
+                       M_ADD((r_i), (r_f), (-1), (f));\
+       } while(0)
+
+#define        M_ISNEG(v_i, v_f)               /* v < 0 */ \
+       (((v_i) & 0x80000000) != 0)
+
+#define        M_ISHIS(a_i, a_f, b_i, b_f)     /* a >= b unsigned */ \
+       (((u_int32)(a_i)) > ((u_int32)(b_i)) || \
+         ((a_i) == (b_i) && ((u_int32)(a_f)) >= ((u_int32)(b_f))))
+
+#define        M_ISGEQ(a_i, a_f, b_i, b_f)     /* a >= b signed */ \
+       (((int32)(a_i)) > ((int32)(b_i)) || \
+         ((a_i) == (b_i) && ((u_int32)(a_f)) >= ((u_int32)(b_f))))
+
+#define        M_ISEQU(a_i, a_f, b_i, b_f)     /* a == b unsigned */ \
+       ((a_i) == (b_i) && (a_f) == (b_f))
+
+/*
+ * Operations on the long fp format
+ */
+#define        L_ADD(r, a)     M_ADD((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
+#define        L_SUB(r, a)     M_SUB((r)->l_ui, (r)->l_uf, (a)->l_ui, (a)->l_uf)
+#define        L_NEG(v)        M_NEG((v)->l_ui, (v)->l_uf)
+#define L_ADDUF(r, uf) M_ADDUF((r)->l_ui, (r)->l_uf, (uf))
+#define L_SUBUF(r, uf) M_SUBUF((r)->l_ui, (r)->l_uf, (uf))
+#define        L_ADDF(r, f)    M_ADDF((r)->l_ui, (r)->l_uf, (f))
+#define        L_RSHIFT(v)     M_RSHIFT((v)->l_i, (v)->l_uf)
+#define        L_RSHIFTU(v)    M_RSHIFT((v)->l_ui, (v)->l_uf)
+#define        L_LSHIFT(v)     M_LSHIFT((v)->l_ui, (v)->l_uf)
+#define        L_CLR(v)        ((v)->l_ui = (v)->l_uf = 0)
+
+#define        L_ISNEG(v)      (((v)->l_ui & 0x80000000) != 0)
+#define L_ISZERO(v)    ((v)->l_ui == 0 && (v)->l_uf == 0)
+#define        L_ISHIS(a, b)   ((a)->l_ui > (b)->l_ui || \
+                         ((a)->l_ui == (b)->l_ui && (a)->l_uf >= (b)->l_uf))
+#define        L_ISGEQ(a, b)   ((a)->l_i > (b)->l_i || \
+                         ((a)->l_i == (b)->l_i && (a)->l_uf >= (b)->l_uf))
+#define        L_ISEQU(a, b)   M_ISEQU((a)->l_ui, (a)->l_uf, (b)->l_ui, (b)->l_uf)
+
+/*
+ * s_fp/double and u_fp/double conversions
+ */
+#define FRIC           65536.                  /* 2^16 as a double */
+#define DTOFP(r)       ((s_fp)((r) * FRIC))
+#define DTOUFP(r)      ((u_fp)((r) * FRIC))
+#define FPTOD(r)       ((double)(r) / FRIC)
+
+/*
+ * l_fp/double conversions
+ */
+#define FRAC           4294967296.             /* 2^32 as a double */
+#define M_DTOLFP(d, r_i, r_uf)                         /* double to l_fp */ \
+       do { \
+               register double d_tmp; \
+               \
+               d_tmp = (d); \
+               if (d_tmp < 0) { \
+                       d_tmp = -d_tmp; \
+                       (r_i) = (int32)(d_tmp); \
+                       (r_uf) = (u_int32)(((d_tmp) - (double)(r_i)) * FRAC); \
+                       M_NEG((r_i), (r_uf)); \
+               } else { \
+                       (r_i) = (int32)(d_tmp); \
+                       (r_uf) = (u_int32)(((d_tmp) - (double)(r_i)) * FRAC); \
+               } \
+       } while (0)
+#define M_LFPTOD(r_i, r_uf, d)                         /* l_fp to double */ \
+       do { \
+               register l_fp l_tmp; \
+               \
+               l_tmp.l_i = (r_i); \
+               l_tmp.l_f = (r_uf); \
+               if (l_tmp.l_i < 0) { \
+                       M_NEG(l_tmp.l_i, l_tmp.l_uf); \
+                       (d) = -((double)l_tmp.l_i + ((double)l_tmp.l_uf) / FRAC); \
+               } else { \
+                       (d) = (double)l_tmp.l_i + ((double)l_tmp.l_uf) / FRAC; \
+               } \
+       } while (0)
+#define DTOLFP(d, v)   M_DTOLFP((d), (v)->l_ui, (v)->l_uf)
+#define LFPTOD(v, d)   M_LFPTOD((v)->l_ui, (v)->l_uf, (d))
+
+/*
+ * Prototypes
+ */
+#if 0
+extern char *  dofptoa         P((u_fp, int, short, int));
+extern char *  dolfptoa        P((u_long, u_long, int, short, int));
+#endif
+
+extern int     atolfp          P((const char *, l_fp *));
+extern int     buftvtots       P((const char *, l_fp *));
+extern char *  fptoa           P((s_fp, short));
+extern char *  fptoms          P((s_fp, short));
+extern int     hextolfp        P((const char *, l_fp *));
+extern  void    gpstolfp        P((int, int, unsigned long, l_fp *));
+extern int     mstolfp         P((const char *, l_fp *));
+extern char *  prettydate      P((l_fp *));
+extern char *  gmprettydate    P((l_fp *));
+extern char *  uglydate        P((l_fp *));
+extern  void    mfp_mul         P((int32 *, u_int32 *, int32, u_int32, int32, u_int32));
+
+extern void    get_systime     P((l_fp *));
+extern int     step_systime    P((double));
+extern int     adj_systime     P((double));
+
+#define        lfptoa(_fpv, _ndec)     mfptoa((_fpv)->l_ui, (_fpv)->l_uf, (_ndec))
+#define        lfptoms(_fpv, _ndec)    mfptoms((_fpv)->l_ui, (_fpv)->l_uf, (_ndec))
+
+#define        ufptoa(_fpv, _ndec)     dofptoa((_fpv), 0, (_ndec), 0)
+#define        ufptoms(_fpv, _ndec)    dofptoa((_fpv), 0, (_ndec), 1)
+#define        ulfptoa(_fpv, _ndec)    dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 0)
+#define        ulfptoms(_fpv, _ndec)   dolfptoa((_fpv)->l_ui, (_fpv)->l_uf, 0, (_ndec), 1)
+#define        umfptoa(_fpi, _fpf, _ndec) dolfptoa((_fpi), (_fpf), 0, (_ndec), 0)
diff --git a/util/kern.c b/util/kern.c
new file mode 100644 (file)
index 0000000..b193d6f
--- /dev/null
@@ -0,0 +1,225 @@
+/*
+ * This program simulates a first-order, type-II phase-lock loop using
+ * actual code segments from modified kernel distributions for SunOS,
+ * Ultrix and OSF/1 kernels. These segments do not use any licensed code.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <math.h>
+#include <sys/time.h>
+
+#ifdef HAVE_TIMEX_H
+# include "timex.h"
+#endif
+
+/*
+ * Phase-lock loop definitions
+ */
+#define HZ 100                 /* timer interrupt frequency (Hz) */
+#define MAXPHASE 512000                /* max phase error (us) */
+#define MAXFREQ 200            /* max frequency error (ppm) */
+#define TAU 2                  /* time constant (shift 0 - 6) */
+#define POLL 16                        /* interval between updates (s) */
+#define MAXSEC 1200            /* max interval between updates (s) */
+
+/*
+ * Function declarations
+ */
+void hardupdate();
+void hardclock();
+void second_overflow();
+
+/*
+ * Kernel variables
+ */
+int tick;                      /* timer interrupt period (us) */
+int fixtick;                   /* amortization constant (ppm) */
+struct timeval timex;          /* ripoff of kernel time variable */
+
+/*
+ * Phase-lock loop variables
+ */
+int time_status = TIME_BAD;    /* clock synchronization status */
+long time_offset = 0;          /* time adjustment (us) */
+long time_constant = 0;                /* pll time constant */
+long time_tolerance = MAXFREQ; /* frequency tolerance (ppm) */
+long time_precision = 1000000 / HZ; /* clock precision (us) */
+long time_maxerror = MAXPHASE; /* maximum error (us) */
+long time_esterror = MAXPHASE; /* estimated error (us) */
+long time_phase = 0;           /* phase offset (scaled us) */
+long time_freq = 0;            /* frequency offset (scaled ppm) */
+long time_adj = 0;             /* tick adjust (scaled 1 / HZ) */
+long time_reftime = 0;         /* time at last adjustment (s) */
+
+/*
+ * Simulation variables
+ */
+double timey = 0;              /* simulation time (us) */
+long timez = 0;                        /* current error (us) */
+long poll_interval = 0;                /* poll counter */
+
+/*
+ * Simulation test program
+ */
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       tick = 1000000 / HZ;
+       fixtick = 1000000 % HZ;
+       timex.tv_sec = 0;
+       timex.tv_usec = MAXPHASE;
+       time_freq = 0;
+       time_constant = TAU;
+       printf("tick %d us, fixtick %d us\n", tick, fixtick);
+       printf("      time    offset      freq   _offset     _freq      _adj\n");
+
+       /*
+        * Grind the loop until ^C
+        */
+       while (1) {
+               timey += (double)(1000000) / HZ;
+               if (timey >= 1000000)
+                   timey -= 1000000;
+               hardclock();
+               if (timex.tv_usec >= 1000000) {
+                       timex.tv_usec -= 1000000;
+                       timex.tv_sec++;
+                       second_overflow();
+                       poll_interval++;
+                       if (!(poll_interval % POLL)) {
+                               timez = (long)timey - timex.tv_usec;
+                               if (timez > 500000)
+                                   timez -= 1000000;
+                               if (timez < -500000)
+                                   timez += 1000000;
+                               hardupdate(timez);
+                               printf("%10li%10li%10.2f  %08lx  %08lx  %08lx\n",
+                                      timex.tv_sec, timez,
+                                      (double)time_freq / (1 << SHIFT_KF),
+                                      time_offset, time_freq, time_adj);
+                       }
+               }
+       }
+}
+
+/*
+ * This routine simulates the ntp_adjtime() call
+ *
+ * For default SHIFT_UPDATE = 12, offset is limited to +-512 ms, the
+ * maximum interval between updates is 4096 s and the maximum frequency
+ * offset is +-31.25 ms/s.
+ */
+void
+hardupdate(
+       long offset
+       )
+{
+       long ltemp, mtemp;
+
+       time_offset = offset << SHIFT_UPDATE;
+       mtemp = timex.tv_sec - time_reftime;
+       time_reftime = timex.tv_sec;
+       if (mtemp > MAXSEC)
+           mtemp = 0;
+
+       /* ugly multiply should be replaced */
+       if (offset < 0)
+           time_freq -= (-offset * mtemp) >>
+                   (time_constant + time_constant);
+       else
+           time_freq += (offset * mtemp) >>
+                   (time_constant + time_constant);
+       ltemp = time_tolerance << SHIFT_KF;
+       if (time_freq > ltemp)
+           time_freq = ltemp;
+       else if (time_freq < -ltemp)
+           time_freq = -ltemp;
+       if (time_status == TIME_BAD)
+           time_status = TIME_OK;
+}
+
+/*
+ * This routine simulates the timer interrupt
+ */
+void
+hardclock(void)
+{
+       int ltemp, time_update;
+
+       time_update = tick;     /* computed by adjtime() */
+       time_phase += time_adj;
+       if (time_phase < -FINEUSEC) {
+               ltemp = -time_phase >> SHIFT_SCALE;
+               time_phase += ltemp << SHIFT_SCALE;
+               time_update -= ltemp;
+       }
+       else if (time_phase > FINEUSEC) {
+               ltemp = time_phase >> SHIFT_SCALE;
+               time_phase -= ltemp << SHIFT_SCALE;
+               time_update += ltemp;
+       }
+       timex.tv_usec += time_update;
+}
+
+/*
+ * This routine simulates the overflow of the microsecond field
+ *
+ * With SHIFT_SCALE = 23, the maximum frequency adjustment is +-256 us
+ * per tick, or 25.6 ms/s at a clock frequency of 100 Hz. The time
+ * contribution is shifted right a minimum of two bits, while the frequency
+ * contribution is a right shift. Thus, overflow is prevented if the
+ * frequency contribution is limited to half the maximum or 15.625 ms/s.
+ */
+void
+second_overflow(void)
+{
+       int ltemp;
+
+       time_maxerror += time_tolerance;
+       if (time_offset < 0) {
+               ltemp = -time_offset >>
+                       (SHIFT_KG + time_constant);
+               time_offset += ltemp;
+               time_adj = -(ltemp <<
+                            (SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE));
+       } else {
+               ltemp = time_offset >>
+                       (SHIFT_KG + time_constant);
+               time_offset -= ltemp;
+               time_adj = ltemp <<
+                       (SHIFT_SCALE - SHIFT_HZ - SHIFT_UPDATE);
+       }
+       if (time_freq < 0)
+           time_adj -= -time_freq >> (SHIFT_KF + SHIFT_HZ - SHIFT_SCALE);
+       else
+           time_adj += time_freq >> (SHIFT_KF + SHIFT_HZ - SHIFT_SCALE);
+       time_adj += fixtick << (SHIFT_SCALE - SHIFT_HZ);
+
+       /* ugly divide should be replaced */
+       if (timex.tv_sec % 86400 == 0) {
+               switch (time_status) {
+
+                   case TIME_INS:
+                       timex.tv_sec--; /* !! */
+                       time_status = TIME_OOP;
+                       break;
+
+                   case TIME_DEL:
+                       timex.tv_sec++;
+                       time_status = TIME_OK;
+                       break;
+
+                   case TIME_OOP:
+                       time_status = TIME_OK;
+                       break;
+               }
+       }
+}
diff --git a/util/longsize.c b/util/longsize.c
new file mode 100644 (file)
index 0000000..bba1955
--- /dev/null
@@ -0,0 +1,11 @@
+#include <stdio.h>
+
+main()
+{
+       if (sizeof(long) == 8) { 
+               printf("-DLONG8\n");
+       } else if (sizeof(long) == 4) {
+               printf("-DLONG4\n");
+       }
+       exit(0);
+}
diff --git a/util/ntp-keygen-opts.c b/util/ntp-keygen-opts.c
new file mode 100644 (file)
index 0000000..cb242c0
--- /dev/null
@@ -0,0 +1,1044 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (ntp-keygen-opts.c)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:56 AM EST
+ *  From the definitions    ntp-keygen-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This source file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  ntp-keygen author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * ntp-keygen copyright 1970-2009 David L. Mills and/or others - all rights reserved
+ *
+ * see html/copyright.html
+ */
+
+
+#include <limits.h>
+#include <stdio.h>
+#define OPTION_CODE_COMPILE 1
+#include "ntp-keygen-opts.h"
+
+#ifdef  __cplusplus
+extern "C" {
+#endif
+tSCC zCopyright[] =
+       "ntp-keygen copyright (c) 1970-2009 David L. Mills and/or others, all rights reserved";
+tSCC zCopyrightNotice[] =
+       
+/* extracted from ../include/copyright.def near line 8 */
+"see html/copyright.html";
+extern tUsageProc optionUsage;
+
+/*
+ *  global included definitions
+ */
+#include <stdlib.h>
+#ifdef __windows
+  extern int atoi(const char*);
+#else
+# include <stdlib.h>
+#endif
+
+#ifndef NULL
+#  define NULL 0
+#endif
+#ifndef EXIT_SUCCESS
+#  define  EXIT_SUCCESS 0
+#endif
+#ifndef EXIT_FAILURE
+#  define  EXIT_FAILURE 1
+#endif
+/*
+ *  Certificate option description:
+ */
+#ifdef OPENSSL
+tSCC    zCertificateText[] =
+        "certificate scheme";
+tSCC    zCertificate_NAME[]        = "CERTIFICATE";
+tSCC    zCertificate_Name[]        = "certificate";
+#define CERTIFICATE_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+#else   /* disable Certificate */
+#define VALUE_OPT_CERTIFICATE NO_EQUIVALENT
+#define CERTIFICATE_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zCertificateText       NULL
+#define zCertificate_NAME      NULL
+#define zCertificate_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Debug_Level option description:
+ */
+#ifdef DEBUG
+tSCC    zDebug_LevelText[] =
+        "Increase output debug message level";
+tSCC    zDebug_Level_NAME[]        = "DEBUG_LEVEL";
+tSCC    zDebug_Level_Name[]        = "debug-level";
+#define DEBUG_LEVEL_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Debug_Level */
+#define VALUE_OPT_DEBUG_LEVEL NO_EQUIVALENT
+#define DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zDebug_LevelText       NULL
+#define zDebug_Level_NAME      NULL
+#define zDebug_Level_Name      NULL
+#endif  /* DEBUG */
+
+/*
+ *  Set_Debug_Level option description:
+ */
+#ifdef DEBUG
+tSCC    zSet_Debug_LevelText[] =
+        "Set the output debug message level";
+tSCC    zSet_Debug_Level_NAME[]    = "SET_DEBUG_LEVEL";
+tSCC    zSet_Debug_Level_Name[]    = "set-debug-level";
+#define SET_DEBUG_LEVEL_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+#else   /* disable Set_Debug_Level */
+#define VALUE_OPT_SET_DEBUG_LEVEL NO_EQUIVALENT
+#define SET_DEBUG_LEVEL_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zSet_Debug_LevelText       NULL
+#define zSet_Debug_Level_NAME      NULL
+#define zSet_Debug_Level_Name      NULL
+#endif  /* DEBUG */
+
+/*
+ *  Id_Key option description:
+ */
+#ifdef OPENSSL
+tSCC    zId_KeyText[] =
+        "Write identity keys";
+tSCC    zId_Key_NAME[]             = "ID_KEY";
+tSCC    zId_Key_Name[]             = "id-key";
+#define ID_KEY_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Id_Key */
+#define VALUE_OPT_ID_KEY NO_EQUIVALENT
+#define ID_KEY_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zId_KeyText       NULL
+#define zId_Key_NAME      NULL
+#define zId_Key_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Gq_Params option description:
+ */
+#ifdef OPENSSL
+tSCC    zGq_ParamsText[] =
+        "Generate GQ parameters and keys";
+tSCC    zGq_Params_NAME[]          = "GQ_PARAMS";
+tSCC    zGq_Params_Name[]          = "gq-params";
+#define GQ_PARAMS_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Gq_Params */
+#define VALUE_OPT_GQ_PARAMS NO_EQUIVALENT
+#define GQ_PARAMS_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zGq_ParamsText       NULL
+#define zGq_Params_NAME      NULL
+#define zGq_Params_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Gq_Keys option description:
+ */
+#ifdef OPENSSL
+tSCC    zGq_KeysText[] =
+        "update GQ keys";
+tSCC    zGq_Keys_NAME[]            = "GQ_KEYS";
+tSCC    zGq_Keys_Name[]            = "gq-keys";
+#define GQ_KEYS_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Gq_Keys */
+#define VALUE_OPT_GQ_KEYS NO_EQUIVALENT
+#define GQ_KEYS_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zGq_KeysText       NULL
+#define zGq_Keys_NAME      NULL
+#define zGq_Keys_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Host_Key option description:
+ */
+#ifdef OPENSSL
+tSCC    zHost_KeyText[] =
+        "generate RSA host key";
+tSCC    zHost_Key_NAME[]           = "HOST_KEY";
+tSCC    zHost_Key_Name[]           = "host-key";
+#define HOST_KEY_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Host_Key */
+#define VALUE_OPT_HOST_KEY NO_EQUIVALENT
+#define HOST_KEY_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zHost_KeyText       NULL
+#define zHost_Key_NAME      NULL
+#define zHost_Key_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Iffkey option description:
+ */
+#ifdef OPENSSL
+tSCC    zIffkeyText[] =
+        "generate IFF parameters";
+tSCC    zIffkey_NAME[]             = "IFFKEY";
+tSCC    zIffkey_Name[]             = "iffkey";
+#define IFFKEY_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Iffkey */
+#define VALUE_OPT_IFFKEY NO_EQUIVALENT
+#define IFFKEY_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zIffkeyText       NULL
+#define zIffkey_NAME      NULL
+#define zIffkey_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Issuer_Name option description:
+ */
+#ifdef OPENSSL
+tSCC    zIssuer_NameText[] =
+        "set issuer name";
+tSCC    zIssuer_Name_NAME[]        = "ISSUER_NAME";
+tSCC    zIssuer_Name_Name[]        = "issuer-name";
+#define ISSUER_NAME_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Issuer_Name */
+#define VALUE_OPT_ISSUER_NAME NO_EQUIVALENT
+#define ISSUER_NAME_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zIssuer_NameText       NULL
+#define zIssuer_Name_NAME      NULL
+#define zIssuer_Name_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Md5key option description:
+ */
+tSCC    zMd5keyText[] =
+        "generate MD5 keys";
+tSCC    zMd5key_NAME[]             = "MD5KEY";
+tSCC    zMd5key_Name[]             = "md5key";
+#define MD5KEY_FLAGS       (OPTST_DISABLED)
+
+/*
+ *  Modulus option description:
+ */
+#ifdef OPENSSL
+tSCC    zModulusText[] =
+        "modulus";
+tSCC    zModulus_NAME[]            = "MODULUS";
+tSCC    zModulus_Name[]            = "modulus";
+#define MODULUS_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+
+#else   /* disable Modulus */
+#define VALUE_OPT_MODULUS NO_EQUIVALENT
+#define MODULUS_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zModulusText       NULL
+#define zModulus_NAME      NULL
+#define zModulus_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Pvt_Cert option description:
+ */
+#ifdef OPENSSL
+tSCC    zPvt_CertText[] =
+        "generate PC private certificate";
+tSCC    zPvt_Cert_NAME[]           = "PVT_CERT";
+tSCC    zPvt_Cert_Name[]           = "pvt-cert";
+#define PVT_CERT_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Pvt_Cert */
+#define VALUE_OPT_PVT_CERT NO_EQUIVALENT
+#define PVT_CERT_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zPvt_CertText       NULL
+#define zPvt_Cert_NAME      NULL
+#define zPvt_Cert_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Pvt_Passwd option description:
+ */
+#ifdef OPENSSL
+tSCC    zPvt_PasswdText[] =
+        "output private password";
+tSCC    zPvt_Passwd_NAME[]         = "PVT_PASSWD";
+tSCC    zPvt_Passwd_Name[]         = "pvt-passwd";
+#define PVT_PASSWD_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+#else   /* disable Pvt_Passwd */
+#define VALUE_OPT_PVT_PASSWD NO_EQUIVALENT
+#define PVT_PASSWD_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zPvt_PasswdText       NULL
+#define zPvt_Passwd_NAME      NULL
+#define zPvt_Passwd_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Get_Pvt_Passwd option description:
+ */
+#ifdef OPENSSL
+tSCC    zGet_Pvt_PasswdText[] =
+        "input private password";
+tSCC    zGet_Pvt_Passwd_NAME[]     = "GET_PVT_PASSWD";
+tSCC    zGet_Pvt_Passwd_Name[]     = "get-pvt-passwd";
+#define GET_PVT_PASSWD_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+#else   /* disable Get_Pvt_Passwd */
+#define VALUE_OPT_GET_PVT_PASSWD NO_EQUIVALENT
+#define GET_PVT_PASSWD_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zGet_Pvt_PasswdText       NULL
+#define zGet_Pvt_Passwd_NAME      NULL
+#define zGet_Pvt_Passwd_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Sign_Key option description:
+ */
+#ifdef OPENSSL
+tSCC    zSign_KeyText[] =
+        "generate sign key (RSA or DSA)";
+tSCC    zSign_Key_NAME[]           = "SIGN_KEY";
+tSCC    zSign_Key_Name[]           = "sign-key";
+#define SIGN_KEY_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+#else   /* disable Sign_Key */
+#define VALUE_OPT_SIGN_KEY NO_EQUIVALENT
+#define SIGN_KEY_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zSign_KeyText       NULL
+#define zSign_Key_NAME      NULL
+#define zSign_Key_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Subject_Name option description:
+ */
+#ifdef OPENSSL
+tSCC    zSubject_NameText[] =
+        "set subject name";
+tSCC    zSubject_Name_NAME[]       = "SUBJECT_NAME";
+tSCC    zSubject_Name_Name[]       = "subject-name";
+#define SUBJECT_NAME_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_STRING))
+
+#else   /* disable Subject_Name */
+#define VALUE_OPT_SUBJECT_NAME NO_EQUIVALENT
+#define SUBJECT_NAME_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zSubject_NameText       NULL
+#define zSubject_Name_NAME      NULL
+#define zSubject_Name_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Trusted_Cert option description:
+ */
+#ifdef OPENSSL
+tSCC    zTrusted_CertText[] =
+        "trusted certificate (TC scheme)";
+tSCC    zTrusted_Cert_NAME[]       = "TRUSTED_CERT";
+tSCC    zTrusted_Cert_Name[]       = "trusted-cert";
+#define TRUSTED_CERT_FLAGS       (OPTST_DISABLED)
+
+#else   /* disable Trusted_Cert */
+#define VALUE_OPT_TRUSTED_CERT NO_EQUIVALENT
+#define TRUSTED_CERT_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zTrusted_CertText       NULL
+#define zTrusted_Cert_NAME      NULL
+#define zTrusted_Cert_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Mv_Params option description:
+ */
+#ifdef OPENSSL
+tSCC    zMv_ParamsText[] =
+        "generate <num> MV parameters";
+tSCC    zMv_Params_NAME[]          = "MV_PARAMS";
+tSCC    zMv_Params_Name[]          = "mv-params";
+#define MV_PARAMS_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+
+#else   /* disable Mv_Params */
+#define VALUE_OPT_MV_PARAMS NO_EQUIVALENT
+#define MV_PARAMS_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zMv_ParamsText       NULL
+#define zMv_Params_NAME      NULL
+#define zMv_Params_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Mv_Keys option description:
+ */
+#ifdef OPENSSL
+tSCC    zMv_KeysText[] =
+        "update <num> MV keys";
+tSCC    zMv_Keys_NAME[]            = "MV_KEYS";
+tSCC    zMv_Keys_Name[]            = "mv-keys";
+#define MV_KEYS_FLAGS       (OPTST_DISABLED \
+        | OPTST_SET_ARGTYPE(OPARG_TYPE_NUMERIC))
+
+#else   /* disable Mv_Keys */
+#define VALUE_OPT_MV_KEYS NO_EQUIVALENT
+#define MV_KEYS_FLAGS       (OPTST_OMITTED | OPTST_NO_INIT)
+#define zMv_KeysText       NULL
+#define zMv_Keys_NAME      NULL
+#define zMv_Keys_Name      NULL
+#endif  /* OPENSSL */
+
+/*
+ *  Help/More_Help/Version option descriptions:
+ */
+tSCC zHelpText[]       = "Display usage information and exit";
+tSCC zHelp_Name[]      = "help";
+
+tSCC zMore_HelpText[]  = "Extended usage information passed thru pager";
+tSCC zMore_Help_Name[] = "more-help";
+
+tSCC zVersionText[]    = "Output version information and exit";
+tSCC zVersion_Name[]   = "version";
+
+/*
+ *  Save/Load_Opts option description:
+ */
+tSCC zSave_OptsText[]     = "Save the option state to a config file";
+tSCC zSave_Opts_Name[]    = "save-opts";
+
+tSCC zLoad_OptsText[]     = "Load options from a config file";
+tSCC zLoad_Opts_NAME[]    = "LOAD_OPTS";
+
+tSCC zNotLoad_Opts_Name[] = "no-load-opts";
+tSCC zNotLoad_Opts_Pfx[]  = "no";
+#define zLoad_Opts_Name   (zNotLoad_Opts_Name + 3)
+/*
+ *  Declare option callback procedures
+ */
+#ifdef DEBUG
+  static tOptProc doOptSet_Debug_Level;
+#else /* not DEBUG */
+# define doOptSet_Debug_Level NULL
+#endif /* def/not DEBUG */
+#ifdef OPENSSL
+  static tOptProc doOptModulus;
+#else /* not OPENSSL */
+# define doOptModulus NULL
+#endif /* def/not OPENSSL */
+#ifdef OPENSSL
+  extern tOptProc optionNumericVal;
+#else /* not OPENSSL */
+# define optionNumericVal NULL
+#endif /* def/not OPENSSL */
+#ifdef OPENSSL
+  extern tOptProc optionNumericVal;
+#else /* not OPENSSL */
+# define optionNumericVal NULL
+#endif /* def/not OPENSSL */
+#if defined(TEST_NTP_KEYGEN_OPTS)
+/*
+ *  Under test, omit argument processing, or call optionStackArg,
+ *  if multiple copies are allowed.
+ */
+extern tOptProc
+    optionNumericVal, optionPagedUsage, optionVersionStderr;
+static tOptProc
+    doOptModulus, doUsageOpt;
+
+/*
+ *  #define map the "normal" callout procs to the test ones...
+ */
+#define SET_DEBUG_LEVEL_OPT_PROC optionStackArg
+
+
+#else /* NOT defined TEST_NTP_KEYGEN_OPTS */
+/*
+ *  When not under test, there are different procs to use
+ */
+extern tOptProc
+    optionPagedUsage, optionPrintVersion;
+static tOptProc
+    doUsageOpt;
+
+/*
+ *  #define map the "normal" callout procs
+ */
+#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
+
+#define SET_DEBUG_LEVEL_OPT_PROC doOptSet_Debug_Level
+#endif /* defined(TEST_NTP_KEYGEN_OPTS) */
+#ifdef TEST_NTP_KEYGEN_OPTS
+# define DOVERPROC optionVersionStderr
+#else
+# define DOVERPROC optionPrintVersion
+#endif /* TEST_NTP_KEYGEN_OPTS */
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Ntp_Keygen Option Descriptions.
+ */
+static tOptDesc optDesc[ OPTION_CT ] = {
+  {  /* entry idx, value */ 0, VALUE_OPT_CERTIFICATE,
+     /* equiv idx, value */ 0, VALUE_OPT_CERTIFICATE,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ CERTIFICATE_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zCertificateText, zCertificate_NAME, zCertificate_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 1, VALUE_OPT_DEBUG_LEVEL,
+     /* equiv idx, value */ 1, VALUE_OPT_DEBUG_LEVEL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ DEBUG_LEVEL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zDebug_LevelText, zDebug_Level_NAME, zDebug_Level_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 2, VALUE_OPT_SET_DEBUG_LEVEL,
+     /* equiv idx, value */ 2, VALUE_OPT_SET_DEBUG_LEVEL,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ SET_DEBUG_LEVEL_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ SET_DEBUG_LEVEL_OPT_PROC,
+     /* desc, NAME, name */ zSet_Debug_LevelText, zSet_Debug_Level_NAME, zSet_Debug_Level_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 3, VALUE_OPT_ID_KEY,
+     /* equiv idx, value */ 3, VALUE_OPT_ID_KEY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ ID_KEY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zId_KeyText, zId_Key_NAME, zId_Key_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 4, VALUE_OPT_GQ_PARAMS,
+     /* equiv idx, value */ 4, VALUE_OPT_GQ_PARAMS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ GQ_PARAMS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zGq_ParamsText, zGq_Params_NAME, zGq_Params_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 5, VALUE_OPT_GQ_KEYS,
+     /* equiv idx, value */ 5, VALUE_OPT_GQ_KEYS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ GQ_KEYS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zGq_KeysText, zGq_Keys_NAME, zGq_Keys_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 6, VALUE_OPT_HOST_KEY,
+     /* equiv idx, value */ 6, VALUE_OPT_HOST_KEY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ HOST_KEY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zHost_KeyText, zHost_Key_NAME, zHost_Key_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 7, VALUE_OPT_IFFKEY,
+     /* equiv idx, value */ 7, VALUE_OPT_IFFKEY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ IFFKEY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIffkeyText, zIffkey_NAME, zIffkey_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 8, VALUE_OPT_ISSUER_NAME,
+     /* equiv idx, value */ 8, VALUE_OPT_ISSUER_NAME,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ ISSUER_NAME_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zIssuer_NameText, zIssuer_Name_NAME, zIssuer_Name_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 9, VALUE_OPT_MD5KEY,
+     /* equiv idx, value */ 9, VALUE_OPT_MD5KEY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ MD5KEY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zMd5keyText, zMd5key_NAME, zMd5key_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 10, VALUE_OPT_MODULUS,
+     /* equiv idx, value */ 10, VALUE_OPT_MODULUS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ MODULUS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doOptModulus,
+     /* desc, NAME, name */ zModulusText, zModulus_NAME, zModulus_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 11, VALUE_OPT_PVT_CERT,
+     /* equiv idx, value */ 11, VALUE_OPT_PVT_CERT,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PVT_CERT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPvt_CertText, zPvt_Cert_NAME, zPvt_Cert_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 12, VALUE_OPT_PVT_PASSWD,
+     /* equiv idx, value */ 12, VALUE_OPT_PVT_PASSWD,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ PVT_PASSWD_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zPvt_PasswdText, zPvt_Passwd_NAME, zPvt_Passwd_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 13, VALUE_OPT_GET_PVT_PASSWD,
+     /* equiv idx, value */ 13, VALUE_OPT_GET_PVT_PASSWD,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ GET_PVT_PASSWD_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zGet_Pvt_PasswdText, zGet_Pvt_Passwd_NAME, zGet_Pvt_Passwd_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 14, VALUE_OPT_SIGN_KEY,
+     /* equiv idx, value */ 14, VALUE_OPT_SIGN_KEY,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SIGN_KEY_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSign_KeyText, zSign_Key_NAME, zSign_Key_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 15, VALUE_OPT_SUBJECT_NAME,
+     /* equiv idx, value */ 15, VALUE_OPT_SUBJECT_NAME,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ SUBJECT_NAME_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSubject_NameText, zSubject_Name_NAME, zSubject_Name_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 16, VALUE_OPT_TRUSTED_CERT,
+     /* equiv idx, value */ 16, VALUE_OPT_TRUSTED_CERT,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ TRUSTED_CERT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zTrusted_CertText, zTrusted_Cert_NAME, zTrusted_Cert_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 17, VALUE_OPT_MV_PARAMS,
+     /* equiv idx, value */ 17, VALUE_OPT_MV_PARAMS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ MV_PARAMS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionNumericVal,
+     /* desc, NAME, name */ zMv_ParamsText, zMv_Params_NAME, zMv_Params_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ 18, VALUE_OPT_MV_KEYS,
+     /* equiv idx, value */ 18, VALUE_OPT_MV_KEYS,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ MV_KEYS_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionNumericVal,
+     /* desc, NAME, name */ zMv_KeysText, zMv_Keys_NAME, zMv_Keys_Name,
+     /* disablement strs */ NULL, NULL },
+
+#ifdef NO_OPTIONAL_OPT_ARGS
+#  define VERSION_OPT_FLAGS     OPTST_IMM | OPTST_NO_INIT
+#else
+#  define VERSION_OPT_FLAGS     OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) | \
+                                OPTST_ARG_OPTIONAL | OPTST_IMM | OPTST_NO_INIT
+#endif
+
+  {  /* entry idx, value */ INDEX_OPT_VERSION, VALUE_OPT_VERSION,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ VERSION_OPT_FLAGS, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ DOVERPROC,
+     /* desc, NAME, name */ zVersionText, NULL, zVersion_Name,
+     /* disablement strs */ NULL, NULL },
+
+#undef VERSION_OPT_FLAGS
+
+
+  {  /* entry idx, value */ INDEX_OPT_HELP, VALUE_OPT_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ doUsageOpt,
+     /* desc, NAME, name */ zHelpText, NULL, zHelp_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_MORE_HELP, VALUE_OPT_MORE_HELP,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_IMM | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ optionPagedUsage,
+     /* desc, NAME, name */ zMore_HelpText, NULL, zMore_Help_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_SAVE_OPTS, VALUE_OPT_SAVE_OPTS,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, 1, 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING)
+                          | OPTST_ARG_OPTIONAL | OPTST_NO_INIT, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL,  NULL,
+     /* option proc      */ NULL,
+     /* desc, NAME, name */ zSave_OptsText, NULL, zSave_Opts_Name,
+     /* disablement strs */ NULL, NULL },
+
+  {  /* entry idx, value */ INDEX_OPT_LOAD_OPTS, VALUE_OPT_LOAD_OPTS,
+     /* equiv idx value  */ NO_EQUIVALENT, 0,
+     /* equivalenced to  */ NO_EQUIVALENT,
+     /* min, max, act ct */ 0, NOLIMIT, 0,
+     /* opt state flags  */ OPTST_SET_ARGTYPE(OPARG_TYPE_STRING) \
+                         | OPTST_DISABLE_IMM, 0,
+     /* last opt argumnt */ { NULL },
+     /* arg list/cookie  */ NULL,
+     /* must/cannot opts */ NULL, NULL,
+     /* option proc      */ optionLoadOpt,
+     /* desc, NAME, name */ zLoad_OptsText, zLoad_Opts_NAME, zLoad_Opts_Name,
+     /* disablement strs */ zNotLoad_Opts_Name, zNotLoad_Opts_Pfx }
+};
+
+/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
+ *
+ *  Define the Ntp_Keygen Option Environment
+ */
+tSCC   zPROGNAME[]   = "NTP_KEYGEN";
+tSCC   zUsageTitle[] =
+"ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.4p8\n\
+USAGE:  %s [ -<flag> [<val>] | --<name>[{=| }<val>] ]...\n";
+tSCC   zRcName[]     = ".ntprc";
+tSCC*  apzHomeList[] = {
+       "$HOME",
+       ".",
+       NULL };
+
+tSCC   zBugsAddr[]    = "http://bugs.ntp.org, bugs@ntp.org";
+#define zExplain NULL
+tSCC    zDetail[]     = "\n\
+If there is no new host key, look for an existing one.\n\
+If one is not found, create it.\n";
+tSCC    zFullVersion[] = NTP_KEYGEN_FULL_VERSION;
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 408 */
+
+#if defined(ENABLE_NLS)
+# define OPTPROC_BASE OPTPROC_TRANSLATE
+  static tOptionXlateProc translate_option_strings;
+#else
+# define OPTPROC_BASE OPTPROC_NONE
+# define translate_option_strings NULL
+#endif /* ENABLE_NLS */
+
+tOptions ntp_keygenOptions = {
+    OPTIONS_STRUCT_VERSION,
+    0, NULL,                    /* original argc + argv    */
+    ( OPTPROC_BASE
+    + OPTPROC_ERRSTOP
+    + OPTPROC_SHORTOPT
+    + OPTPROC_LONGOPT
+    + OPTPROC_NO_REQ_OPT
+    + OPTPROC_ENVIRON
+    + OPTPROC_NO_ARGS
+    + OPTPROC_HAS_IMMED ),
+    0, NULL,                    /* current option index, current option */
+    NULL,         NULL,         zPROGNAME,
+    zRcName,      zCopyright,   zCopyrightNotice,
+    zFullVersion, apzHomeList,  zUsageTitle,
+    zExplain,     zDetail,      optDesc,
+    zBugsAddr,                  /* address to send bugs to */
+    NULL, NULL,                 /* extensions/saved state  */
+    optionUsage,       /* usage procedure */
+    translate_option_strings,   /* translation procedure */
+    /*
+     *  Indexes to special options
+     */
+    { INDEX_OPT_MORE_HELP,
+      INDEX_OPT_SAVE_OPTS,
+      NO_EQUIVALENT /* index of '-#' option */,
+      NO_EQUIVALENT /* index of default opt */
+    },
+    24 /* full option count */, 19 /* user option count */
+};
+
+/*
+ *  Create the static procedure(s) declared above.
+ */
+static void
+doUsageOpt(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    USAGE( EXIT_SUCCESS );
+}
+
+#if ! defined(TEST_NTP_KEYGEN_OPTS)
+
+/* * * * * * *
+ *
+ *   For the set-debug-level option, when DEBUG is #define-d.
+ */
+#ifdef DEBUG
+static void
+doOptSet_Debug_Level(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    /* extracted from ../include/debug-opt.def, line 29 */
+DESC(DEBUG_LEVEL).optOccCt = atoi( pOptDesc->pzLastArg );
+}
+#endif /* defined DEBUG */
+
+#endif /* defined(TEST_NTP_KEYGEN_OPTS) */
+
+/* * * * * * *
+ *
+ *   For the modulus option, when OPENSSL is #define-d.
+ */
+#ifdef OPENSSL
+static void
+doOptModulus(
+    tOptions*   pOptions,
+    tOptDesc*   pOptDesc )
+{
+    static const struct {const int rmin, rmax;} rng[ 1 ] = {
+        { 256, 2048 } };
+    int val;
+    int ix;
+    char const* pzIndent = "\t\t\t\t  ";
+    extern FILE* option_usage_fp;
+
+    if (pOptDesc == NULL) /* usage is requesting range list
+                             option_usage_fp has already been set */
+        goto emit_ranges;
+
+    val = atoi( pOptDesc->optArg.argString );
+    for (ix = 0; ix < 1; ix++) {
+        if (val < rng[ix].rmin)
+            continue;  /* ranges need not be ordered. */
+        if (val == rng[ix].rmin)
+            goto valid_return;
+        if (rng[ix].rmax == INT_MIN)
+            continue;
+        if (val <= rng[ix].rmax)
+            goto valid_return;
+    }
+
+    option_usage_fp = stderr;
+    fprintf(stderr, _("%s error:  %s option value ``%s''is out of range.\n"),
+            pOptions->pzProgName, pOptDesc->pz_Name, pOptDesc->optArg.argString);
+    pzIndent = "\t";
+
+  emit_ranges:
+    fprintf( option_usage_fp, _("%sit must lie in the range: %d to %d\n"),
+             pzIndent, rng[0].rmin, rng[0].rmax );
+    if (pOptDesc == NULL)
+        return;
+
+    USAGE( EXIT_FAILURE );
+    /* NOTREACHED */
+    return;
+
+  valid_return:
+    pOptDesc->optArg.argInt = val;
+}
+#endif /* defined OPENSSL */
+
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optmain.tpl near line 92 */
+
+#if defined(TEST_NTP_KEYGEN_OPTS) /* TEST MAIN PROCEDURE: */
+
+int
+main( int argc, char** argv )
+{
+    int res = EXIT_SUCCESS;
+    (void)optionProcess( &ntp_keygenOptions, argc, argv );
+    {
+        void optionPutShell( tOptions* );
+        optionPutShell( &ntp_keygenOptions );
+    }
+    return res;
+}
+#endif  /* defined TEST_NTP_KEYGEN_OPTS */
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/optcode.tpl near line 514 */
+
+#if ENABLE_NLS
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <unistd.h>
+#include <autoopts/usage-txt.h>
+
+static char* AO_gettext( char const* pz );
+static void  coerce_it(void** s);
+
+static char*
+AO_gettext( char const* pz )
+{
+    char* pzRes;
+    if (pz == NULL)
+        return NULL;
+    pzRes = _(pz);
+    if (pzRes == pz)
+        return pzRes;
+    pzRes = strdup( pzRes );
+    if (pzRes == NULL) {
+        fputs( _("No memory for duping translated strings\n"), stderr );
+        exit( EXIT_FAILURE );
+    }
+    return pzRes;
+}
+
+static void coerce_it(void** s) { *s = AO_gettext(*s); }
+#define COERSION(_f) \
+  coerce_it((void*)&(ntp_keygenOptions._f))
+
+/*
+ *  This invokes the translation code (e.g. gettext(3)).
+ */
+static void
+translate_option_strings( void )
+{
+    /*
+     *  Guard against re-translation.  It won't work.  The strings will have
+     *  been changed by the first pass through this code.  One shot only.
+     */
+    if (option_usage_text.field_ct == 0)
+        return;
+    /*
+     *  Do the translations.  The first pointer follows the field count field.
+     *  The field count field is the size of a pointer.
+     */
+    {
+        char** ppz = (char**)(void*)&(option_usage_text);
+        int    ix  = option_usage_text.field_ct;
+
+        do {
+            ppz++;
+            *ppz = AO_gettext(*ppz);
+        } while (--ix > 0);
+    }
+    option_usage_text.field_ct = 0;
+
+    {
+        tOptDesc* pOD = ntp_keygenOptions.pOptDesc;
+        int       ix  = ntp_keygenOptions.optCt;
+
+        for (;;) {
+            pOD->pzText           = AO_gettext(pOD->pzText);
+            pOD->pz_NAME          = AO_gettext(pOD->pz_NAME);
+            pOD->pz_Name          = AO_gettext(pOD->pz_Name);
+            pOD->pz_DisableName   = AO_gettext(pOD->pz_DisableName);
+            pOD->pz_DisablePfx    = AO_gettext(pOD->pz_DisablePfx);
+            if (--ix <= 0)
+                break;
+            pOD++;
+        }
+    }
+    COERSION(pzCopyright);
+    COERSION(pzCopyNotice);
+    COERSION(pzFullVersion);
+    COERSION(pzUsageTitle);
+    COERSION(pzExplain);
+    COERSION(pzDetail);
+}
+
+#endif /* ENABLE_NLS */
+
+#ifdef  __cplusplus
+}
+#endif
+/* ntp-keygen-opts.c ends here */
diff --git a/util/ntp-keygen-opts.def b/util/ntp-keygen-opts.def
new file mode 100644 (file)
index 0000000..1e5d988
--- /dev/null
@@ -0,0 +1,209 @@
+/* -*- Mode: Text -*- */
+
+autogen definitions options;
+
+#include copyright.def
+#include homerc.def
+#include autogen-version.def
+
+prog-name      = "ntp-keygen";
+prog-title     = "Create a NTP host key";
+package        = ntp;
+
+test-main;
+
+include        = '#include <stdlib.h>';
+#include       version.def
+
+flag = {
+    name      = certificate;
+    value     = c;
+    arg-type  = string;
+    arg-name  = scheme;
+    ifdef     = OPENSSL;
+    descrip   = "certificate scheme";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+#include       debug-opt.def
+
+flag = {
+    name      = id-key;
+    value     = e;
+    ifdef     = OPENSSL;
+    descrip   = "Write identity keys";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = gq-params;
+    value     = G;
+    ifdef     = OPENSSL;
+    descrip   = "Generate GQ parameters and keys";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = gq-keys;
+    value     = g;
+    ifdef     = OPENSSL;
+    descrip   = "update GQ keys";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = host-key;
+    value     = H;
+    ifdef     = OPENSSL;
+    descrip   = "generate RSA host key";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = iffkey;
+    value     = I;
+    ifdef     = OPENSSL;
+    descrip   = "generate IFF parameters";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = issuer-name;
+    value     = i;
+    ifdef     = OPENSSL;
+    descrip   = "set issuer name";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = md5key;
+    value     = M;
+    descrip   = "generate MD5 keys";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = modulus;
+    value     = m;
+    arg-type  = number;
+    arg-name  = modulus;
+    arg-range = '256->2048';
+    ifdef     = OPENSSL;
+    descrip   = "modulus";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = pvt-cert;
+    value     = P;
+    ifdef     = OPENSSL;
+    descrip   = "generate PC private certificate";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = pvt-passwd;
+    value     = p;
+    ifdef     = OPENSSL;
+    arg-type  = string;
+    arg-name  = passwd;
+    descrip   = "output private password";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = get-pvt-passwd;
+    value     = q;
+    ifdef     = OPENSSL;
+    arg-type  = string;
+    arg-name  = passwd;
+    descrip   = "input private password";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = sign-key;
+    value     = S;
+    arg-type  = string;
+    arg-name  = sign;
+    ifdef     = OPENSSL;
+    descrip   = "generate sign key (RSA or DSA)";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = subject-name;
+    value     = s;
+    arg-type  = string;
+    arg-name  = host;
+    ifdef     = OPENSSL;
+    descrip   = "set subject name";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = trusted-cert;
+    value     = T;
+    ifdef     = OPENSSL;
+    descrip   = "trusted certificate (TC scheme)";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = mv-params;
+    value     = V;
+    arg-type  = number;
+    arg-name  = num;
+    ifdef     = OPENSSL;
+    descrip   = "generate <num> MV parameters";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+flag = {
+    name      = mv-keys;
+    value     = v;
+    arg-type  = number;
+    arg-name  = num;
+    ifdef     = OPENSSL;
+    descrip   = "update <num> MV keys";
+    doc = <<-  _EndOfDoc_
+       Just some descriptive text.
+       _EndOfDoc_;
+};
+
+detail = <<-  _EODetail_
+       If there is no new host key, look for an existing one.
+       If one is not found, create it.
+       _EODetail_;
diff --git a/util/ntp-keygen-opts.h b/util/ntp-keygen-opts.h
new file mode 100644 (file)
index 0000000..e34a0a7
--- /dev/null
@@ -0,0 +1,318 @@
+/*  
+ *  EDIT THIS FILE WITH CAUTION  (ntp-keygen-opts.h)
+ *  
+ *  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:55 AM EST
+ *  From the definitions    ntp-keygen-opts.def
+ *  and the template file   options
+ *
+ * Generated from AutoOpts 29:0:4 templates.
+ */
+
+/*
+ *  This file was produced by an AutoOpts template.  AutoOpts is a
+ *  copyrighted work.  This header file is not encumbered by AutoOpts
+ *  licensing, but is provided under the licensing terms chosen by the
+ *  ntp-keygen author or copyright holder.  AutoOpts is licensed under
+ *  the terms of the LGPL.  The redistributable library (``libopts'') is
+ *  licensed under the terms of either the LGPL or, at the users discretion,
+ *  the BSD license.  See the AutoOpts and/or libopts sources for details.
+ *
+ * This source file is copyrighted and licensed under the following terms:
+ *
+ * ntp-keygen copyright 1970-2009 David L. Mills and/or others - all rights reserved
+ *
+ * see html/copyright.html
+ */
+/*
+ *  This file contains the programmatic interface to the Automated
+ *  Options generated for the ntp-keygen program.
+ *  These macros are documented in the AutoGen info file in the
+ *  "AutoOpts" chapter.  Please refer to that doc for usage help.
+ */
+#ifndef AUTOOPTS_NTP_KEYGEN_OPTS_H_GUARD
+#define AUTOOPTS_NTP_KEYGEN_OPTS_H_GUARD
+#include "config.h"
+#include <autoopts/options.h>
+
+/*
+ *  Ensure that the library used for compiling this generated header is at
+ *  least as new as the version current when the header template was released
+ *  (not counting patch version increments).  Also ensure that the oldest
+ *  tolerable version is at least as old as what was current when the header
+ *  template was released.
+ */
+#define AO_TEMPLATE_VERSION 118784
+#if (AO_TEMPLATE_VERSION < OPTIONS_MINIMUM_VERSION) \
+ || (AO_TEMPLATE_VERSION > OPTIONS_STRUCT_VERSION)
+# error option template version mismatches autoopts/options.h header
+  Choke Me.
+#endif
+
+/*
+ *  Enumeration of each option:
+ */
+typedef enum {
+        INDEX_OPT_CERTIFICATE      =  0,
+        INDEX_OPT_DEBUG_LEVEL      =  1,
+        INDEX_OPT_SET_DEBUG_LEVEL  =  2,
+        INDEX_OPT_ID_KEY           =  3,
+        INDEX_OPT_GQ_PARAMS        =  4,
+        INDEX_OPT_GQ_KEYS          =  5,
+        INDEX_OPT_HOST_KEY         =  6,
+        INDEX_OPT_IFFKEY           =  7,
+        INDEX_OPT_ISSUER_NAME      =  8,
+        INDEX_OPT_MD5KEY           =  9,
+        INDEX_OPT_MODULUS          = 10,
+        INDEX_OPT_PVT_CERT         = 11,
+        INDEX_OPT_PVT_PASSWD       = 12,
+        INDEX_OPT_GET_PVT_PASSWD   = 13,
+        INDEX_OPT_SIGN_KEY         = 14,
+        INDEX_OPT_SUBJECT_NAME     = 15,
+        INDEX_OPT_TRUSTED_CERT     = 16,
+        INDEX_OPT_MV_PARAMS        = 17,
+        INDEX_OPT_MV_KEYS          = 18,
+        INDEX_OPT_VERSION          = 19,
+        INDEX_OPT_HELP             = 20,
+        INDEX_OPT_MORE_HELP        = 21,
+        INDEX_OPT_SAVE_OPTS        = 22,
+        INDEX_OPT_LOAD_OPTS        = 23
+} teOptIndex;
+
+#define OPTION_CT    24
+#define NTP_KEYGEN_VERSION       "4.2.4p8"
+#define NTP_KEYGEN_FULL_VERSION  "ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.4p8"
+
+/*
+ *  Interface defines for all options.  Replace "n" with the UPPER_CASED
+ *  option name (as in the teOptIndex enumeration above).
+ *  e.g. HAVE_OPT( CERTIFICATE )
+ */
+#define         DESC(n) (ntp_keygenOptions.pOptDesc[INDEX_OPT_## n])
+#define     HAVE_OPT(n) (! UNUSED_OPT(& DESC(n)))
+#define      OPT_ARG(n) (DESC(n).optArg.argString)
+#define    STATE_OPT(n) (DESC(n).fOptState & OPTST_SET_MASK)
+#define    COUNT_OPT(n) (DESC(n).optOccCt)
+#define    ISSEL_OPT(n) (SELECTED_OPT(&DESC(n)))
+#define ISUNUSED_OPT(n) (UNUSED_OPT(& DESC(n)))
+#define  ENABLED_OPT(n) (! DISABLED_OPT(& DESC(n)))
+#define  STACKCT_OPT(n) (((tArgList*)(DESC(n).optCookie))->useCt)
+#define STACKLST_OPT(n) (((tArgList*)(DESC(n).optCookie))->apzArgs)
+#define    CLEAR_OPT(n) STMTS( \
+                DESC(n).fOptState &= OPTST_PERSISTENT_MASK;   \
+                if ( (DESC(n).fOptState & OPTST_INITENABLED) == 0) \
+                    DESC(n).fOptState |= OPTST_DISABLED; \
+                DESC(n).optCookie = NULL )
+
+/*
+ *  Make sure there are no #define name conflicts with the option names
+ */
+#ifndef     NO_OPTION_NAME_WARNINGS
+# ifdef    CERTIFICATE
+#  warning undefining CERTIFICATE due to option name conflict
+#  undef   CERTIFICATE
+# endif
+# ifdef    DEBUG_LEVEL
+#  warning undefining DEBUG_LEVEL due to option name conflict
+#  undef   DEBUG_LEVEL
+# endif
+# ifdef    SET_DEBUG_LEVEL
+#  warning undefining SET_DEBUG_LEVEL due to option name conflict
+#  undef   SET_DEBUG_LEVEL
+# endif
+# ifdef    ID_KEY
+#  warning undefining ID_KEY due to option name conflict
+#  undef   ID_KEY
+# endif
+# ifdef    GQ_PARAMS
+#  warning undefining GQ_PARAMS due to option name conflict
+#  undef   GQ_PARAMS
+# endif
+# ifdef    GQ_KEYS
+#  warning undefining GQ_KEYS due to option name conflict
+#  undef   GQ_KEYS
+# endif
+# ifdef    HOST_KEY
+#  warning undefining HOST_KEY due to option name conflict
+#  undef   HOST_KEY
+# endif
+# ifdef    IFFKEY
+#  warning undefining IFFKEY due to option name conflict
+#  undef   IFFKEY
+# endif
+# ifdef    ISSUER_NAME
+#  warning undefining ISSUER_NAME due to option name conflict
+#  undef   ISSUER_NAME
+# endif
+# ifdef    MD5KEY
+#  warning undefining MD5KEY due to option name conflict
+#  undef   MD5KEY
+# endif
+# ifdef    MODULUS
+#  warning undefining MODULUS due to option name conflict
+#  undef   MODULUS
+# endif
+# ifdef    PVT_CERT
+#  warning undefining PVT_CERT due to option name conflict
+#  undef   PVT_CERT
+# endif
+# ifdef    PVT_PASSWD
+#  warning undefining PVT_PASSWD due to option name conflict
+#  undef   PVT_PASSWD
+# endif
+# ifdef    GET_PVT_PASSWD
+#  warning undefining GET_PVT_PASSWD due to option name conflict
+#  undef   GET_PVT_PASSWD
+# endif
+# ifdef    SIGN_KEY
+#  warning undefining SIGN_KEY due to option name conflict
+#  undef   SIGN_KEY
+# endif
+# ifdef    SUBJECT_NAME
+#  warning undefining SUBJECT_NAME due to option name conflict
+#  undef   SUBJECT_NAME
+# endif
+# ifdef    TRUSTED_CERT
+#  warning undefining TRUSTED_CERT due to option name conflict
+#  undef   TRUSTED_CERT
+# endif
+# ifdef    MV_PARAMS
+#  warning undefining MV_PARAMS due to option name conflict
+#  undef   MV_PARAMS
+# endif
+# ifdef    MV_KEYS
+#  warning undefining MV_KEYS due to option name conflict
+#  undef   MV_KEYS
+# endif
+#else  /* NO_OPTION_NAME_WARNINGS */
+# undef CERTIFICATE
+# undef DEBUG_LEVEL
+# undef SET_DEBUG_LEVEL
+# undef ID_KEY
+# undef GQ_PARAMS
+# undef GQ_KEYS
+# undef HOST_KEY
+# undef IFFKEY
+# undef ISSUER_NAME
+# undef MD5KEY
+# undef MODULUS
+# undef PVT_CERT
+# undef PVT_PASSWD
+# undef GET_PVT_PASSWD
+# undef SIGN_KEY
+# undef SUBJECT_NAME
+# undef TRUSTED_CERT
+# undef MV_PARAMS
+# undef MV_KEYS
+#endif  /*  NO_OPTION_NAME_WARNINGS */
+
+/*
+ *  Interface defines for specific options.
+ */
+#ifdef OPENSSL
+#define VALUE_OPT_CERTIFICATE    'c'
+#endif /* OPENSSL */
+#ifdef DEBUG
+#define VALUE_OPT_DEBUG_LEVEL    'd'
+#endif /* DEBUG */
+#ifdef DEBUG
+#define VALUE_OPT_SET_DEBUG_LEVEL 'D'
+#endif /* DEBUG */
+#ifdef OPENSSL
+#define VALUE_OPT_ID_KEY         'e'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_GQ_PARAMS      'G'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_GQ_KEYS        'g'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_HOST_KEY       'H'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_IFFKEY         'I'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_ISSUER_NAME    'i'
+#endif /* OPENSSL */
+#define VALUE_OPT_MD5KEY         'M'
+#ifdef OPENSSL
+#define VALUE_OPT_MODULUS        'm'
+#define OPT_VALUE_MODULUS        (DESC(MODULUS).optArg.argInt)
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_PVT_CERT       'P'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_PVT_PASSWD     'p'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_GET_PVT_PASSWD 'q'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_SIGN_KEY       'S'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_SUBJECT_NAME   's'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_TRUSTED_CERT   'T'
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_MV_PARAMS      'V'
+#define OPT_VALUE_MV_PARAMS      (DESC(MV_PARAMS).optArg.argInt)
+#endif /* OPENSSL */
+#ifdef OPENSSL
+#define VALUE_OPT_MV_KEYS        'v'
+#define OPT_VALUE_MV_KEYS        (DESC(MV_KEYS).optArg.argInt)
+#endif /* OPENSSL */
+
+#define VALUE_OPT_VERSION       'v'
+#define VALUE_OPT_HELP          '?'
+#define VALUE_OPT_MORE_HELP     '!'
+#define VALUE_OPT_SAVE_OPTS     '>'
+#define VALUE_OPT_LOAD_OPTS     '<'
+#define SET_OPT_SAVE_OPTS(a)   STMTS( \
+        DESC(SAVE_OPTS).fOptState &= OPTST_PERSISTENT_MASK; \
+        DESC(SAVE_OPTS).fOptState |= OPTST_SET; \
+        DESC(SAVE_OPTS).optArg.argString = (char const*)(a) )
+/*
+ *  Interface defines not associated with particular options
+ */
+#define ERRSKIP_OPTERR  STMTS( ntp_keygenOptions.fOptSet &= ~OPTPROC_ERRSTOP )
+#define ERRSTOP_OPTERR  STMTS( ntp_keygenOptions.fOptSet |= OPTPROC_ERRSTOP )
+#define RESTART_OPT(n)  STMTS( \
+                ntp_keygenOptions.curOptIdx = (n); \
+                ntp_keygenOptions.pzCurOpt  = NULL )
+#define START_OPT       RESTART_OPT(1)
+#define USAGE(c)        (*ntp_keygenOptions.pUsageProc)( &ntp_keygenOptions, c )
+/* extracted from /usr/local/gnu/autogen-5.9.1/share/autogen/opthead.tpl near line 360 */
+
+/* * * * * *
+ *
+ *  Declare the ntp-keygen option descriptor.
+ */
+#ifdef  __cplusplus
+extern "C" {
+#endif
+
+extern tOptions   ntp_keygenOptions;
+
+#ifndef _
+#  if ENABLE_NLS
+#    include <stdio.h>
+     static inline char* aoGetsText( char const* pz ) {
+         if (pz == NULL) return NULL;
+         return (char*)gettext( pz );
+     }
+#    define _(s)  aoGetsText(s)
+#  else  /* ENABLE_NLS */
+#    define _(s)  s
+#  endif /* ENABLE_NLS */
+#endif
+
+#ifdef  __cplusplus
+}
+#endif
+#endif /* AUTOOPTS_NTP_KEYGEN_OPTS_H_GUARD */
+/* ntp-keygen-opts.h ends here */
diff --git a/util/ntp-keygen-opts.menu b/util/ntp-keygen-opts.menu
new file mode 100644 (file)
index 0000000..bc5cfe9
--- /dev/null
@@ -0,0 +1 @@
+* ntp-keygen Invocation::          Invoking ntp-keygen
diff --git a/util/ntp-keygen-opts.texi b/util/ntp-keygen-opts.texi
new file mode 100644 (file)
index 0000000..d54e9ba
--- /dev/null
@@ -0,0 +1,364 @@
+@node ntp-keygen Invocation
+@section Invoking ntp-keygen
+@pindex ntp-keygen
+@cindex Create a NTP host key
+@ignore
+# 
+# EDIT THIS FILE WITH CAUTION  (ntp-keygen-opts.texi)
+# 
+# It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:57 AM EST
+# From the definitions    ntp-keygen-opts.def
+# and the template file   aginfo.tpl
+@end ignore
+This program has no explanation.
+
+If there is no new host key, look for an existing one.
+If one is not found, create it.
+
+This section was generated by @strong{AutoGen},
+the aginfo template and the option descriptions for the @command{ntp-keygen} program.  It documents the ntp-keygen usage text and option meanings.
+
+This software is released under a specialized copyright license.
+
+@menu
+* ntp-keygen usage::                  ntp-keygen usage help (-?)
+* ntp-keygen certificate::            certificate option (-c)
+* ntp-keygen debug-level::            debug-level option (-d)
+* ntp-keygen get-pvt-passwd::         get-pvt-passwd option (-q)
+* ntp-keygen gq-keys::                gq-keys option (-g)
+* ntp-keygen gq-params::              gq-params option (-G)
+* ntp-keygen host-key::               host-key option (-H)
+* ntp-keygen id-key::                 id-key option (-e)
+* ntp-keygen iffkey::                 iffkey option (-I)
+* ntp-keygen issuer-name::            issuer-name option (-i)
+* ntp-keygen md5key::                 md5key option (-M)
+* ntp-keygen modulus::                modulus option (-m)
+* ntp-keygen mv-keys::                mv-keys option (-v)
+* ntp-keygen mv-params::              mv-params option (-V)
+* ntp-keygen pvt-cert::               pvt-cert option (-P)
+* ntp-keygen pvt-passwd::             pvt-passwd option (-p)
+* ntp-keygen set-debug-level::        set-debug-level option (-D)
+* ntp-keygen sign-key::               sign-key option (-S)
+* ntp-keygen subject-name::           subject-name option (-s)
+* ntp-keygen trusted-cert::           trusted-cert option (-T)
+@end menu
+
+@node ntp-keygen usage
+@subsection ntp-keygen usage help (-?)
+@cindex ntp-keygen usage
+
+This is the automatically generated usage text for ntp-keygen:
+
+@exampleindent 0
+@example
+Using OpenSSL version 90704f
+ntp-keygen (ntp) - Create a NTP host key - Ver. 4.2.5p247-RC
+USAGE:  ntp-keygen [ -<flag> [<val>] | --<name>[@{=| @}<val>] ]...
+  Flg Arg Option-Name    Description
+   -c Str certificate    certificate scheme
+   -d no  debug-level    Increase output debug message level
+                                - may appear multiple times
+   -D Str set-debug-level Set the output debug message level
+                                - may appear multiple times
+   -e no  id-key         Write IFF or GQ identity keys
+   -G no  gq-params      Generate GQ parameters and keys
+   -H no  host-key       generate RSA host key
+   -I no  iffkey         generate IFF parameters
+   -i Str issuer-name    set issuer name
+   -M no  md5key         generate MD5 keys
+   -m Num modulus        modulus
+                                - it must be:  256 to 2048
+   -P no  pvt-cert       generate PC private certificate
+   -p Str pvt-passwd     output private password
+   -q Str get-pvt-passwd input private password
+   -S Str sign-key       generate sign key (RSA or DSA)
+   -s Str subject-name   set subject name
+   -T no  trusted-cert   trusted certificate (TC scheme)
+   -V Num mv-params      generate <num> MV parameters
+   -v Num mv-keys        update <num> MV keys
+      opt version        Output version information and exit
+   -? no  help           Display extended usage information and exit
+   -! no  more-help      Extended usage information passed thru pager
+   -> opt save-opts      Save the option state to a config file
+   -< Str load-opts      Load options from a config file
+                                - disabled as --no-load-opts
+                                - may appear multiple times
+
+Options are specified by doubled hyphens and their name
+or by a single hyphen and the flag character.
+
+The following option preset mechanisms are supported:
+ - reading file /users/stenn/.ntprc
+ - reading file /deacon/backroom/snaps/ntp-stable/util/.ntprc
+ - examining environment variables named NTP_KEYGEN_*
+
+If there is no new host key, look for an existing one.
+If one is not found, create it.
+
+please send bug reports to:  http://bugs.ntp.org, bugs@@ntp.org
+@end example
+@exampleindent 4
+
+@node ntp-keygen certificate
+@subsection certificate option (-c)
+@cindex ntp-keygen-certificate
+
+This is the ``certificate scheme'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen debug-level
+@subsection debug-level option (-d)
+@cindex ntp-keygen-debug-level
+
+This is the ``increase output debug message level'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@item
+must be compiled in by defining @code{DEBUG} during the compilation.
+@end itemize
+
+Increase the debugging message output level.
+
+@node ntp-keygen set-debug-level
+@subsection set-debug-level option (-D)
+@cindex ntp-keygen-set-debug-level
+
+This is the ``set the output debug message level'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+may appear an unlimited number of times.
+@item
+must be compiled in by defining @code{DEBUG} during the compilation.
+@end itemize
+
+Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+
+@node ntp-keygen id-key
+@subsection id-key option (-e)
+@cindex ntp-keygen-id-key
+
+This is the ``write identity keys'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen gq-params
+@subsection gq-params option (-G)
+@cindex ntp-keygen-gq-params
+
+This is the ``generate gq parameters and keys'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen gq-keys
+@subsection gq-keys option (-g)
+@cindex ntp-keygen-gq-keys
+
+This is the ``update gq keys'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen host-key
+@subsection host-key option (-H)
+@cindex ntp-keygen-host-key
+
+This is the ``generate rsa host key'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen iffkey
+@subsection iffkey option (-I)
+@cindex ntp-keygen-iffkey
+
+This is the ``generate iff parameters'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen issuer-name
+@subsection issuer-name option (-i)
+@cindex ntp-keygen-issuer-name
+
+This is the ``set issuer name'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen md5key
+@subsection md5key option (-M)
+@cindex ntp-keygen-md5key
+
+This is the ``generate md5 keys'' option.
+Just some descriptive text.
+
+@node ntp-keygen modulus
+@subsection modulus option (-m)
+@cindex ntp-keygen-modulus
+
+This is the ``modulus'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen pvt-cert
+@subsection pvt-cert option (-P)
+@cindex ntp-keygen-pvt-cert
+
+This is the ``generate pc private certificate'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen pvt-passwd
+@subsection pvt-passwd option (-p)
+@cindex ntp-keygen-pvt-passwd
+
+This is the ``output private password'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen get-pvt-passwd
+@subsection get-pvt-passwd option (-q)
+@cindex ntp-keygen-get-pvt-passwd
+
+This is the ``input private password'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen sign-key
+@subsection sign-key option (-S)
+@cindex ntp-keygen-sign-key
+
+This is the ``generate sign key (rsa or dsa)'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen subject-name
+@subsection subject-name option (-s)
+@cindex ntp-keygen-subject-name
+
+This is the ``set subject name'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen trusted-cert
+@subsection trusted-cert option (-T)
+@cindex ntp-keygen-trusted-cert
+
+This is the ``trusted certificate (tc scheme)'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen mv-params
+@subsection mv-params option (-V)
+@cindex ntp-keygen-mv-params
+
+This is the ``generate <num> mv parameters'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
+
+@node ntp-keygen mv-keys
+@subsection mv-keys option (-v)
+@cindex ntp-keygen-mv-keys
+
+This is the ``update <num> mv keys'' option.
+
+This option has some usage constraints.  It:
+@itemize @bullet
+@item
+must be compiled in by defining @code{OPENSSL} during the compilation.
+@end itemize
+
+Just some descriptive text.
diff --git a/util/ntp-keygen.1 b/util/ntp-keygen.1
new file mode 100644 (file)
index 0000000..90f8d5c
--- /dev/null
@@ -0,0 +1,176 @@
+.TH NTP-KEYGEN 1 2009-12-08 "(ntp 4.2.4p8)" "Programmer's Manual"
+.\"  EDIT THIS FILE WITH CAUTION  (ntp-keygen.1)
+.\"  
+.\"  It has been AutoGen-ed  Tuesday December  8, 2009 at 08:14:57 AM EST
+.\"  From the definitions    ntp-keygen-opts.def
+.\"  and the template file   agman1.tpl
+.\"
+.SH NAME
+ntp-keygen \- Create a NTP host key
+.SH SYNOPSIS
+.B ntp-keygen
+.\" Mixture of short (flag) options and long options
+.RB [ \-\fIflag\fP " [\fIvalue\fP]]... [" \--\fIopt-name\fP " [[=| ]\fIvalue\fP]]..."
+.PP
+All arguments must be options.
+.SH "DESCRIPTION"
+This manual page documents, briefly, the \fBntp-keygen\fP command.
+If there is no new host key, look for an existing one.
+If one is not found, create it.
+.SH OPTIONS
+.TP
+.BR \-c " \fIscheme\fP, " \--certificate "=" \fIscheme\fP
+certificate scheme.
+.sp
+Just some descriptive text.
+.TP
+.BR \-d ", " \--debug-level
+Increase output debug message level.
+This option may appear an unlimited number of times.
+.sp
+Increase the debugging message output level.
+.TP
+.BR \-D " \fIstring\fP, " \--set-debug-level "=" \fIstring\fP
+Set the output debug message level.
+This option may appear an unlimited number of times.
+.sp
+Set the output debugging level.  Can be supplied multiple times,
+but each overrides the previous value(s).
+.TP
+.BR \-e ", " \--id-key
+Write identity keys.
+.sp
+Just some descriptive text.
+.TP
+.BR \-G ", " \--gq-params
+Generate GQ parameters and keys.
+.sp
+Just some descriptive text.
+.TP
+.BR \-g ", " \--gq-keys
+update GQ keys.
+.sp
+Just some descriptive text.
+.TP
+.BR \-H ", " \--host-key
+generate RSA host key.
+.sp
+Just some descriptive text.
+.TP
+.BR \-I ", " \--iffkey
+generate IFF parameters.
+.sp
+Just some descriptive text.
+.TP
+.BR \-i ", " \--issuer-name
+set issuer name.
+.sp
+Just some descriptive text.
+.TP
+.BR \-M ", " \--md5key
+generate MD5 keys.
+.sp
+Just some descriptive text.
+.TP
+.BR \-m " \fImodulus\fP, " \--modulus "=" \fImodulus\fP
+modulus.
+This option takes an integer number as its argument.
+The value of \fImodulus\fP is constrained to being:
+.in +4
+.nf
+.na
+in the range  256 through 2048
+.fi
+.in -4
+.sp
+Just some descriptive text.
+.TP
+.BR \-P ", " \--pvt-cert
+generate PC private certificate.
+.sp
+Just some descriptive text.
+.TP
+.BR \-p " \fIpasswd\fP, " \--pvt-passwd "=" \fIpasswd\fP
+output private password.
+.sp
+Just some descriptive text.
+.TP
+.BR \-q " \fIpasswd\fP, " \--get-pvt-passwd "=" \fIpasswd\fP
+input private password.
+.sp
+Just some descriptive text.
+.TP
+.BR \-S " \fIsign\fP, " \--sign-key "=" \fIsign\fP
+generate sign key (RSA or DSA).
+.sp
+Just some descriptive text.
+.TP
+.BR \-s " \fIhost\fP, " \--subject-name "=" \fIhost\fP
+set subject name.
+.sp
+Just some descriptive text.
+.TP
+.BR \-T ", " \--trusted-cert
+trusted certificate (TC scheme).
+.sp
+Just some descriptive text.
+.TP
+.BR \-V " \fInum\fP, " \--mv-params "=" \fInum\fP
+generate <num> MV parameters.
+This option takes an integer number as its argument.
+.sp
+Just some descriptive text.
+.TP
+.BR \-v " \fInum\fP, " \--mv-keys "=" \fInum\fP
+update <num> MV keys.
+This option takes an integer number as its argument.
+.sp
+Just some descriptive text.
+.TP
+.BR \-? , " \--help"
+Display usage information and exit.
+.TP
+.BR \-! , " \--more-help"
+Extended usage information passed thru pager.
+.TP
+.BR \-> " [\fIrcfile\fP]," " \--save-opts" "[=\fIrcfile\fP]"
+Save the option state to \fIrcfile\fP.  The default is the \fIlast\fP
+configuration file listed in the \fBOPTION PRESETS\fP section, below.
+.TP
+.BR \-< " \fIrcfile\fP," " \--load-opts" "=\fIrcfile\fP," " \--no-load-opts"
+Load options from \fIrcfile\fP.
+The \fIno-load-opts\fP form will disable the loading
+of earlier RC/INI files.  \fI--no-load-opts\fP is handled early,
+out of order.
+.TP
+.BR \-v " [{\fIv|c|n\fP}]," " \--version" "[=\fI{v|c|n}\fP]"
+Output version of program and exit.  The default mode is `v', a simple
+version.  The `c' mode will print copyright information and `n' will
+print the full copyright notice.
+.SH OPTION PRESETS
+Any option that is not marked as \fInot presettable\fP may be preset
+by loading values from configuration ("RC" or ".INI") file(s) and values from
+environment variables named:
+.nf
+  \fBNTP_KEYGEN_<option-name>\fP or \fBNTP_KEYGEN\fP
+.fi
+.aj
+The environmental presets take precedence (are processed later than)
+the configuration files.
+The \fIhomerc\fP files are "\fI$HOME\fP", and "\fI.\fP".
+If any of these are directories, then the file \fI.ntprc\fP
+is searched for within those directories.
+.SH AUTHOR
+David L. Mills and/or others
+.br
+Please send bug reports to:  http://bugs.ntp.org, bugs@ntp.org
+
+.PP
+.nf
+.na
+see html/copyright.html
+.fi
+.ad
+.PP
+This manual page was \fIAutoGen\fP-erated from the \fBntp-keygen\fP
+option definitions.
diff --git a/util/ntp-keygen.c b/util/ntp-keygen.c
new file mode 100644 (file)
index 0000000..6c14518
--- /dev/null
@@ -0,0 +1,1890 @@
+/*
+ * Program to generate cryptographic keys for NTP clients and servers
+ *
+ * This program generates files "ntpkey_<type>_<hostname>.<filestamp>",
+ * where <type> is the file type, <hostname> is the generating host and
+ * <filestamp> is the NTP seconds in decimal format. The NTP programs
+ * expect generic names such as "ntpkey_<type>_whimsy.udel.edu" with the
+ * association maintained by soft links.
+ *
+ * Files are prefixed with a header giving the name and date of creation
+ * followed by a type-specific descriptive label and PEM-encoded data
+ * string compatible with programs of the OpenSSL library.
+ *
+ * Note that private keys can be password encrypted as per OpenSSL
+ * conventions.
+ *
+ * The file types include
+ *
+ * ntpkey_MD5key_<hostname>.<filestamp>
+ *     MD5 (128-bit) keys used to compute message digests in symmetric
+ *     key cryptography
+ *
+ * ntpkey_RSAkey_<hostname>.<filestamp>
+ * ntpkey_host_<hostname> (RSA) link
+ *     RSA private/public host key pair used for public key signatures
+ *     and data encryption
+ *
+ * ntpkey_DSAkey_<hostname>.<filestamp>
+ * ntpkey_sign_<hostname> (RSA or DSA) link
+ *     DSA private/public sign key pair used for public key signatures,
+ *     but not data encryption
+ *
+ * ntpkey_IFFpar_<hostname>.<filestamp>
+ * ntpkey_iff_<hostname> (IFF server/client) link
+ * ntpkey_iffkey_<hostname> (IFF client) link
+ *     Schnorr (IFF) server/client identity parameters
+ *
+ * ntpkey_IFFkey_<hostname>.<filestamp>
+ *     Schnorr (IFF) client identity parameters
+ *
+ * ntpkey_GQpar_<hostname>.<filestamp>,
+ * ntpkey_gq_<hostname> (GQ) link
+ *     Guillou-Quisquater (GQ) identity parameters
+ *
+ * ntpkey_MVpar_<hostname>.<filestamp>,
+ *     Mu-Varadharajan (MV) server identity parameters 
+ *
+ * ntpkey_MVkeyX_<hostname>.<filestamp>,
+ * ntpkey_mv_<hostname> (MV server) link
+ * ntpkey_mvkey_<hostname> (MV client) link
+ *     Mu-Varadharajan (MV) client identity parameters
+ *
+ * ntpkey_XXXcert_<hostname>.<filestamp>
+ * ntpkey_cert_<hostname> (RSA or DSA) link
+ *     X509v3 certificate using RSA or DSA public keys and signatures.
+ *     XXX is a code identifying the message digest and signature
+ *     encryption algorithm
+ *
+ * Available digest/signature schemes
+ *
+ * RSA:        RSA-MD2, RSA-MD5, RSA-SHA, RSA-SHA1, RSA-MDC2, EVP-RIPEMD160
+ * DSA:        DSA-SHA, DSA-SHA1
+ *
+ * Note: Once in a while because of some statistical fluke this program
+ * fails to generate and verify some cryptographic data, as indicated by
+ * exit status -1. In this case simply run the program again. If the
+ * program does complete with return code 0, the data are correct as
+ * verified.
+ *
+ * These cryptographic routines are characterized by the prime modulus
+ * size in bits. The default value of 512 bits is a compromise between
+ * cryptographic strength and computing time and is ordinarily
+ * considered adequate for this application. The routines have been
+ * tested with sizes of 256, 512, 1024 and 2048 bits. Not all message
+ * digest and signature encryption schemes work with sizes less than 512
+ * bits. The computing time for sizes greater than 2048 bits is
+ * prohibitive on all but the fastest processors. An UltraSPARC Blade
+ * 1000 took something over nine minutes to generate and verify the
+ * values with size 2048. An old SPARC IPC would take a week.
+ *
+ * The OpenSSL library used by this program expects a random seed file.
+ * As described in the OpenSSL documentation, the file name defaults to
+ * first the RANDFILE environment variable in the user's home directory
+ * and then .rnd in the user's home directory.
+ */
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+#include <string.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <sys/stat.h>
+#include <sys/time.h>
+#if HAVE_SYS_TYPES_H
+# include <sys/types.h>
+#endif
+#include "ntp_types.h"
+#include "ntp_random.h"
+#include "l_stdlib.h"
+
+#include "ntp-keygen-opts.h"
+
+#ifdef SYS_WINNT
+extern int     ntp_getopt      P((int, char **, const char *));
+#define getopt ntp_getopt
+#define optarg ntp_optarg
+#endif
+
+#ifdef OPENSSL
+#include "openssl/bn.h"
+#include "openssl/evp.h"
+#include "openssl/err.h"
+#include "openssl/rand.h"
+#include "openssl/pem.h"
+#include "openssl/x509v3.h"
+#include <openssl/objects.h>
+#endif /* OPENSSL */
+
+/*
+ * Cryptodefines
+ */
+#define        MD5KEYS         16      /* number of MD5 keys generated */
+#define        JAN_1970        ULONG_CONST(2208988800) /* NTP seconds */
+#define YEAR           ((long)60*60*24*365) /* one year in seconds */
+#define MAXFILENAME    256     /* max file name length */
+#define MAXHOSTNAME    256     /* max host name length */
+#ifdef OPENSSL
+#define        PLEN            512     /* default prime modulus size (bits) */
+
+/*
+ * Strings used in X509v3 extension fields
+ */
+#define KEY_USAGE              "digitalSignature,keyCertSign"
+#define BASIC_CONSTRAINTS      "critical,CA:TRUE"
+#define EXT_KEY_PRIVATE                "private"
+#define EXT_KEY_TRUST          "trustRoot"
+#endif /* OPENSSL */
+
+/*
+ * Prototypes
+ */
+FILE   *fheader        P((const char *, const char *));
+void   fslink          P((const char *, const char *));
+int    gen_md5         P((char *));
+#ifdef OPENSSL
+EVP_PKEY *gen_rsa      P((char *));
+EVP_PKEY *gen_dsa      P((char *));
+EVP_PKEY *gen_iff      P((char *));
+EVP_PKEY *gen_gqpar    P((char *));
+EVP_PKEY *gen_gqkey    P((char *, EVP_PKEY *));
+EVP_PKEY *gen_mv       P((char *));
+int    x509            P((EVP_PKEY *, const EVP_MD *, char *, char *));
+void   cb              P((int, int, void *));
+EVP_PKEY *genkey       P((char *, char *));
+u_long asn2ntp         P((ASN1_TIME *));
+#endif /* OPENSSL */
+
+/*
+ * Program variables
+ */
+extern char *optarg;           /* command line argument */
+int    debug = 0;              /* debug, not de bug */
+int    rval;                   /* return status */
+#ifdef OPENSSL
+u_int  modulus = PLEN;         /* prime modulus size (bits) */
+#endif
+int    nkeys = 0;              /* MV keys */
+time_t epoch;                  /* Unix epoch (seconds) since 1970 */
+char   *hostname;              /* host name (subject name) */
+char   *trustname;             /* trusted host name (issuer name) */
+char   filename[MAXFILENAME + 1]; /* file name */
+char   *passwd1 = NULL;        /* input private key password */
+char   *passwd2 = NULL;        /* output private key password */
+#ifdef OPENSSL
+long   d0, d1, d2, d3;         /* callback counters */
+#endif /* OPENSSL */
+
+#ifdef SYS_WINNT
+BOOL init_randfile();
+
+/*
+ * Don't try to follow symbolic links
+ */
+int
+readlink(char * link, char * file, int len) {
+       return (-1);
+}
+/*
+ * Don't try to create a symbolic link for now.
+ * Just move the file to the name you need.
+ */
+int
+symlink(char *filename, char *linkname) {
+       DeleteFile(linkname);
+       MoveFile(filename, linkname);
+       return 0;
+}
+void
+InitWin32Sockets() {
+       WORD wVersionRequested;
+       WSADATA wsaData;
+       wVersionRequested = MAKEWORD(2,0);
+       if (WSAStartup(wVersionRequested, &wsaData))
+       {
+               fprintf(stderr, "No useable winsock.dll");
+               exit(1);
+       }
+}
+#endif /* SYS_WINNT */
+
+/*
+ * Main program
+ */
+int
+main(
+       int     argc,           /* command line options */
+       char    **argv
+       )
+{
+       struct timeval tv;      /* initialization vector */
+       int     md5key = 0;     /* generate MD5 keys */
+#ifdef OPENSSL
+       X509    *cert = NULL;   /* X509 certificate */
+       EVP_PKEY *pkey_host = NULL; /* host key */
+       EVP_PKEY *pkey_sign = NULL; /* sign key */
+       EVP_PKEY *pkey_iff = NULL; /* IFF parameters */
+       EVP_PKEY *pkey_gq = NULL; /* GQ parameters */
+       EVP_PKEY *pkey_mv = NULL; /* MV parameters */
+       int     hostkey = 0;    /* generate RSA keys */
+       int     iffkey = 0;     /* generate IFF parameters */
+       int     gqpar = 0;      /* generate GQ parameters */
+       int     gqkey = 0;      /* update GQ keys */
+       int     mvpar = 0;      /* generate MV parameters */
+       int     mvkey = 0;      /* update MV keys */
+       char    *sign = NULL;   /* sign key */
+       EVP_PKEY *pkey = NULL;  /* temp key */
+       const EVP_MD *ectx;     /* EVP digest */
+       char    pathbuf[MAXFILENAME + 1];
+       const char *scheme = NULL; /* digest/signature scheme */
+       char    *exten = NULL;  /* private extension */
+       char    *grpkey = NULL; /* identity extension */
+       int     nid;            /* X509 digest/signature scheme */
+       FILE    *fstr = NULL;   /* file handle */
+       u_int   temp;
+#define iffsw   HAVE_OPT(ID_KEY)
+#endif /* OPENSSL */
+       char    hostbuf[MAXHOSTNAME + 1];
+
+#ifdef SYS_WINNT
+       /* Initialize before OpenSSL checks */
+       InitWin32Sockets();
+       if(!init_randfile())
+               fprintf(stderr, "Unable to initialize .rnd file\n");
+#endif
+
+#ifdef OPENSSL
+       /*
+        * OpenSSL version numbers: MNNFFPPS: major minor fix patch status
+        * We match major, minor, fix and status (not patch)
+        */
+       if ((SSLeay() ^ OPENSSL_VERSION_NUMBER) & ~0xff0L) {
+               fprintf(stderr,
+                   "OpenSSL version mismatch. Built against %lx, you have %lx\n",
+                   OPENSSL_VERSION_NUMBER, SSLeay());
+               return (-1);
+
+       } else {
+               fprintf(stderr,
+                   "Using OpenSSL version %lx\n", SSLeay());
+       }
+#endif /* OPENSSL */
+
+       /*
+        * Process options, initialize host name and timestamp.
+        */
+       gethostname(hostbuf, MAXHOSTNAME);
+       hostname = hostbuf;
+#ifdef OPENSSL
+       trustname = hostbuf;
+       passwd1 = hostbuf;
+#endif
+#ifndef SYS_WINNT
+       gettimeofday(&tv, 0);
+#else
+       gettimeofday(&tv);
+#endif
+       epoch = tv.tv_sec;
+       rval = 0;
+
+       {
+               int optct = optionProcess(&ntp_keygenOptions, argc, argv);
+               argc -= optct;
+               argv += optct;
+       }
+
+#ifdef OPENSSL
+       if (HAVE_OPT( CERTIFICATE ))
+           scheme = OPT_ARG( CERTIFICATE );
+#endif
+
+       debug = DESC(DEBUG_LEVEL).optOccCt;
+
+#ifdef OPENSSL
+       if (HAVE_OPT( GQ_PARAMS ))
+           gqpar++;
+
+       if (HAVE_OPT( GQ_KEYS ))
+           gqkey++;
+
+       if (HAVE_OPT( HOST_KEY ))
+           hostkey++;
+
+       if (HAVE_OPT( IFFKEY ))
+           iffkey++;
+
+       if (HAVE_OPT( ISSUER_NAME ))
+           trustname = OPT_ARG( ISSUER_NAME );
+#endif
+
+       if (HAVE_OPT( MD5KEY ))
+           md5key++;
+
+#ifdef OPENSSL
+       if (HAVE_OPT( MODULUS ))
+           modulus = OPT_VALUE_MODULUS;
+
+       if (HAVE_OPT( PVT_CERT ))
+           exten = EXT_KEY_PRIVATE;
+
+       if (HAVE_OPT( PVT_PASSWD ))
+           passwd2 = OPT_ARG( PVT_PASSWD );
+
+       if (HAVE_OPT( GET_PVT_PASSWD ))
+           passwd1 = OPT_ARG( GET_PVT_PASSWD );
+
+       if (HAVE_OPT( SIGN_KEY ))
+           sign = OPT_ARG( SIGN_KEY );
+
+       if (HAVE_OPT( SUBJECT_NAME ))
+           hostname = OPT_ARG( SUBJECT_NAME );
+
+       if (HAVE_OPT( TRUSTED_CERT ))
+           exten = EXT_KEY_TRUST;
+
+       if (HAVE_OPT( MV_PARAMS )) {
+               mvpar++;
+               nkeys = OPT_VALUE_MV_PARAMS;
+       }
+
+       if (HAVE_OPT( MV_KEYS )) {
+               mvkey++;
+               nkeys = OPT_VALUE_MV_KEYS;
+       }
+#endif
+
+       if (passwd1 != NULL && passwd2 == NULL)
+               passwd2 = passwd1;
+#ifdef OPENSSL
+       /*
+        * Seed random number generator and grow weeds.
+        */
+       ERR_load_crypto_strings();
+       OpenSSL_add_all_algorithms();
+       if (RAND_file_name(pathbuf, MAXFILENAME) == NULL) {
+               fprintf(stderr, "RAND_file_name %s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               return (-1);
+       }
+       temp = RAND_load_file(pathbuf, -1);
+       if (temp == 0) {
+               fprintf(stderr,
+                   "RAND_load_file %s not found or empty\n", pathbuf);
+               return (-1);
+       }
+       fprintf(stderr,
+           "Random seed file %s %u bytes\n", pathbuf, temp);
+       RAND_add(&epoch, sizeof(epoch), 4.0);
+#endif
+
+       /*
+        * Generate new parameters and keys as requested. These replace
+        * any values already generated.
+        */
+       if (md5key)
+               gen_md5("MD5");
+#ifdef OPENSSL
+       if (hostkey)
+               pkey_host = genkey("RSA", "host");
+       if (sign != NULL)
+               pkey_sign = genkey(sign, "sign");
+       if (iffkey)
+               pkey_iff = gen_iff("iff");
+       if (gqpar)
+               pkey_gq = gen_gqpar("gq");
+       if (mvpar)
+               pkey_mv = gen_mv("mv");
+
+       /*
+        * If there is no new host key, look for an existing one. If not
+        * found, create it.
+        */
+       while (pkey_host == NULL && rval == 0 && !HAVE_OPT(ID_KEY)) {
+               sprintf(filename, "ntpkey_host_%s", hostname);
+               if ((fstr = fopen(filename, "r")) != NULL) {
+                       pkey_host = PEM_read_PrivateKey(fstr, NULL,
+                           NULL, passwd1);
+                       fclose(fstr);
+                       readlink(filename, filename,  sizeof(filename));
+                       if (pkey_host == NULL) {
+                               fprintf(stderr, "Host key\n%s\n",
+                                   ERR_error_string(ERR_get_error(),
+                                   NULL));
+                               rval = -1;
+                       } else {
+                               fprintf(stderr,
+                                   "Using host key %s\n", filename);
+                       }
+                       break;
+
+               } else if ((pkey_host = genkey("RSA", "host")) ==
+                   NULL) {
+                       rval = -1;
+                       break;
+               }
+       }
+
+       /*
+        * If there is no new sign key, look for an existing one. If not
+        * found, use the host key instead.
+        */
+       pkey = pkey_sign;
+       while (pkey_sign == NULL && rval == 0 && !HAVE_OPT(ID_KEY)) {
+               sprintf(filename, "ntpkey_sign_%s", hostname);
+               if ((fstr = fopen(filename, "r")) != NULL) {
+                       pkey_sign = PEM_read_PrivateKey(fstr, NULL,
+                           NULL, passwd1);
+                       fclose(fstr);
+                       readlink(filename, filename, sizeof(filename));
+                       if (pkey_sign == NULL) {
+                               fprintf(stderr, "Sign key\n%s\n",
+                                   ERR_error_string(ERR_get_error(),
+                                   NULL));
+                               rval = -1;
+                       } else {
+                               fprintf(stderr, "Using sign key %s\n",
+                                   filename);
+                       }
+                       break;
+               } else {
+                       pkey = pkey_host;
+                       fprintf(stderr, "Using host key as sign key\n");
+                       break;
+               }
+       }
+
+       /*
+        * If there is no new IFF file, look for an existing one.
+        */
+       if (pkey_iff == NULL && rval == 0) {
+               sprintf(filename, "ntpkey_iff_%s", hostname);
+               if ((fstr = fopen(filename, "r")) != NULL) {
+                       pkey_iff = PEM_read_PrivateKey(fstr, NULL,
+                           NULL, passwd1);
+                       fclose(fstr);
+                       readlink(filename, filename, sizeof(filename));
+                       if (pkey_iff == NULL) {
+                               fprintf(stderr, "IFF parameters\n%s\n",
+                                   ERR_error_string(ERR_get_error(),
+                                   NULL));
+                               rval = -1;
+                       } else {
+                               fprintf(stderr,
+                                   "Using IFF parameters %s\n",
+                                   filename);
+                       }
+               }
+       }
+
+       /*
+        * If there is no new GQ file, look for an existing one.
+        */
+       if (pkey_gq == NULL && rval == 0 && !HAVE_OPT(ID_KEY)) {
+               sprintf(filename, "ntpkey_gq_%s", hostname);
+               if ((fstr = fopen(filename, "r")) != NULL) {
+                       pkey_gq = PEM_read_PrivateKey(fstr, NULL, NULL,
+                           passwd1);
+                       fclose(fstr);
+                       readlink(filename, filename, sizeof(filename));
+                       if (pkey_gq == NULL) {
+                               fprintf(stderr, "GQ parameters\n%s\n",
+                                   ERR_error_string(ERR_get_error(),
+                                   NULL));
+                               rval = -1;
+                       } else {
+                               fprintf(stderr,
+                                   "Using GQ parameters %s\n",
+                                   filename);
+                       }
+               }
+       }
+
+       /*
+        * If there is a GQ parameter file, create GQ private/public
+        * keys and extract the public key for the certificate.
+        */
+       if (pkey_gq != NULL && rval == 0) {
+               gen_gqkey("gq", pkey_gq);
+               grpkey = BN_bn2hex(pkey_gq->pkey.rsa->q);
+       }
+
+       /*
+        * Generate a X509v3 certificate.
+        */
+       while (scheme == NULL && rval == 0 && !HAVE_OPT(ID_KEY)) {
+               sprintf(filename, "ntpkey_cert_%s", hostname);
+               if ((fstr = fopen(filename, "r")) != NULL) {
+                       cert = PEM_read_X509(fstr, NULL, NULL, NULL);
+                       fclose(fstr);
+                       readlink(filename, filename, sizeof(filename));
+                       if (cert == NULL) {
+                               fprintf(stderr, "Cert \n%s\n",
+                                   ERR_error_string(ERR_get_error(),
+                                   NULL));
+                               rval = -1;
+                       } else {
+                               nid = OBJ_obj2nid(
+                                cert->cert_info->signature->algorithm);
+                               scheme = OBJ_nid2sn(nid);
+                               fprintf(stderr,
+                                   "Using scheme %s from %s\n", scheme,
+                                    filename);
+                               break;
+                       }
+               }
+               scheme = "RSA-MD5";
+       }
+       if (pkey != NULL && rval == 0 && !HAVE_OPT(ID_KEY)) {
+               ectx = EVP_get_digestbyname(scheme);
+               if (ectx == NULL) {
+                       fprintf(stderr,
+                           "Invalid digest/signature combination %s\n",
+                           scheme);
+                       rval = -1;
+               } else {
+                       x509(pkey, ectx, grpkey, exten);
+               }
+       }
+
+       /*
+        * Write the IFF client parameters and keys as a DSA private key
+        * encoded in PEM. Note the private key is obscured.
+        */
+       if (pkey_iff != NULL && rval == 0 && HAVE_OPT(ID_KEY)) {
+               DSA     *dsa;
+               char    *sptr;
+               char    *tld;
+
+               sptr = strrchr(filename, '.');
+               tld = malloc(strlen(sptr));     /* we have an extra byte ... */
+               strcpy(tld, 1+sptr);            /* ... see? */
+               sprintf(filename, "ntpkey_IFFkey_%s.%s", trustname,
+                   tld);
+               free(tld);
+               fprintf(stderr, "Writing new IFF key %s\n", filename);
+               fprintf(stdout, "# %s\n# %s", filename, ctime(&epoch));
+               dsa = pkey_iff->pkey.dsa;
+               BN_copy(dsa->priv_key, BN_value_one());
+               pkey = EVP_PKEY_new();
+               EVP_PKEY_assign_DSA(pkey, dsa);
+               PEM_write_PrivateKey(stdout, pkey, passwd2 ?
+                   EVP_des_cbc() : NULL, NULL, 0, NULL, passwd2);
+               fclose(stdout);
+               if (debug)
+                       DSA_print_fp(stdout, dsa, 0);
+       }
+
+       /*
+        * Return the marbles.
+        */
+       if (grpkey != NULL)
+               OPENSSL_free(grpkey);
+       if (pkey_host != NULL)
+               EVP_PKEY_free(pkey_host);
+       if (pkey_sign != NULL)
+               EVP_PKEY_free(pkey_sign);
+       if (pkey_iff != NULL)
+               EVP_PKEY_free(pkey_iff);
+       if (pkey_gq != NULL)
+               EVP_PKEY_free(pkey_gq);
+       if (pkey_mv != NULL)
+               EVP_PKEY_free(pkey_mv);
+#endif /* OPENSSL */
+       return (rval);
+}
+
+
+#if 0
+/*
+ * Generate random MD5 key with password.
+ */
+int
+gen_md5(
+       char    *id             /* file name id */
+       )
+{
+       BIGNUM  *key;
+       BIGNUM  *keyid;
+       FILE    *str;
+       u_char  bin[16];
+
+       fprintf(stderr, "Generating MD5 keys...\n");
+       str = fheader("MD5key", hostname);
+       keyid = BN_new(); key = BN_new();
+       BN_rand(keyid, 16, -1, 0);
+       BN_rand(key, 128, -1, 0);
+       BN_bn2bin(key, bin);
+       PEM_write_fp(str, MD5, NULL, bin);
+       fclose(str);
+       fslink(id, hostname);
+       return (1);
+}
+
+
+#else
+/*
+ * Generate semi-random MD5 keys compatible with NTPv3 and NTPv4
+ */
+int
+gen_md5(
+       char    *id             /* file name id */
+       )
+{
+       u_char  md5key[16];     /* MD5 key */
+       FILE    *str;
+       u_int   temp = 0;       /* Initialize to prevent warnings during compile */
+       int     i, j;
+
+       fprintf(stderr, "Generating MD5 keys...\n");
+       str = fheader("MD5key", hostname);
+       ntp_srandom(epoch);
+       for (i = 1; i <= MD5KEYS; i++) {
+               for (j = 0; j < 16; j++) {
+                       while (1) {
+                               temp = ntp_random() & 0xff;
+                               if (temp == '#')
+                                       continue;
+                               if (temp > 0x20 && temp < 0x7f)
+                                       break;
+                       }
+                       md5key[j] = (u_char)temp;
+               }
+               md5key[15] = '\0';
+               fprintf(str, "%2d MD5 %16s      # MD5 key\n", i,
+                   md5key);
+       }
+       fclose(str);
+       fslink(id, hostname);
+       return (1);
+}
+#endif /* OPENSSL */
+
+
+#ifdef OPENSSL
+/*
+ * Generate RSA public/private key pair
+ */
+EVP_PKEY *                     /* public/private key pair */
+gen_rsa(
+       char    *id             /* file name id */
+       )
+{
+       EVP_PKEY *pkey;         /* private key */
+       RSA     *rsa;           /* RSA parameters and key pair */
+       FILE    *str;
+
+       fprintf(stderr, "Generating RSA keys (%d bits)...\n", modulus);
+       rsa = RSA_generate_key(modulus, 3, cb, "RSA");
+       fprintf(stderr, "\n");
+       if (rsa == NULL) {
+               fprintf(stderr, "RSA generate keys fails\n%s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               rval = -1;
+               return (NULL);
+       }
+
+       /*
+        * For signature encryption it is not necessary that the RSA
+        * parameters be strictly groomed and once in a while the
+        * modulus turns out to be non-prime. Just for grins, we check
+        * the primality.
+        */
+       if (!RSA_check_key(rsa)) {
+               fprintf(stderr, "Invalid RSA key\n%s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               RSA_free(rsa);
+               rval = -1;
+               return (NULL);
+       }
+
+       /*
+        * Write the RSA parameters and keys as a RSA private key
+        * encoded in PEM.
+        */
+       str = fheader("RSAkey", hostname);
+       pkey = EVP_PKEY_new();
+       EVP_PKEY_assign_RSA(pkey, rsa);
+       PEM_write_PrivateKey(str, pkey, passwd2 ? EVP_des_cbc() : NULL,
+           NULL, 0, NULL, passwd2);
+       fclose(str);
+       if (debug)
+               RSA_print_fp(stdout, rsa, 0);
+       fslink(id, hostname);
+       return (pkey);
+}
+
+/*
+ * Generate DSA public/private key pair
+ */
+EVP_PKEY *                     /* public/private key pair */
+gen_dsa(
+       char    *id             /* file name id */
+       )
+{
+       EVP_PKEY *pkey;         /* private key */
+       DSA     *dsa;           /* DSA parameters */
+       u_char  seed[20];       /* seed for parameters */
+       FILE    *str;
+
+       /*
+        * Generate DSA parameters.
+        */
+       fprintf(stderr,
+           "Generating DSA parameters (%d bits)...\n", modulus);
+       RAND_bytes(seed, sizeof(seed));
+       dsa = DSA_generate_parameters(modulus, seed, sizeof(seed), NULL,
+           NULL, cb, "DSA");
+       fprintf(stderr, "\n");
+       if (dsa == NULL) {
+               fprintf(stderr, "DSA generate parameters fails\n%s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               rval = -1;
+               return (NULL);
+       }
+
+       /*
+        * Generate DSA keys.
+        */
+       fprintf(stderr, "Generating DSA keys (%d bits)...\n", modulus);
+       if (!DSA_generate_key(dsa)) {
+               fprintf(stderr, "DSA generate keys fails\n%s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               DSA_free(dsa);
+               rval = -1;
+               return (NULL);
+       }
+
+       /*
+        * Write the DSA parameters and keys as a DSA private key
+        * encoded in PEM.
+        */
+       str = fheader("DSAkey", hostname);
+       pkey = EVP_PKEY_new();
+       EVP_PKEY_assign_DSA(pkey, dsa);
+       PEM_write_PrivateKey(str, pkey, passwd2 ? EVP_des_cbc() : NULL,
+           NULL, 0, NULL, passwd2);
+       fclose(str);
+       if (debug)
+               DSA_print_fp(stdout, dsa, 0);
+       fslink(id, hostname);
+       return (pkey);
+}
+
+
+/*
+ * Generate Schnorr (IFF) parameters and keys
+ *
+ * The Schnorr (IFF)identity scheme is intended for use when
+ * certificates are generated by some other trusted certificate
+ * authority and the parameters cannot be conveyed in the certificate
+ * itself. For this purpose, new generations of IFF values must be
+ * securely transmitted to all members of the group before use. There
+ * are two kinds of files: server/client files that include private and
+ * public parameters and client files that include only public
+ * parameters. The scheme is self contained and independent of new
+ * generations of host keys, sign keys and certificates.
+ *
+ * The IFF values hide in a DSA cuckoo structure which uses the same
+ * parameters. The values are used by an identity scheme based on DSA
+ * cryptography and described in Stimson p. 285. The p is a 512-bit
+ * prime, g a generator of Zp* and q a 160-bit prime that divides p - 1
+ * and is a qth root of 1 mod p; that is, g^q = 1 mod p. The TA rolls a
+ * private random group key b (0 < b < q), then computes public
+ * v = g^(q - a). All values except the group key are known to all group
+ * members; the group key is known to the group servers, but not the
+ * group clients. Alice challenges Bob to confirm identity using the
+ * protocol described below.
+ */
+EVP_PKEY *                     /* DSA cuckoo nest */
+gen_iff(
+       char    *id             /* file name id */
+       )
+{
+       EVP_PKEY *pkey;         /* private key */
+       DSA     *dsa;           /* DSA parameters */
+       u_char  seed[20];       /* seed for parameters */
+       BN_CTX  *ctx;           /* BN working space */
+       BIGNUM  *b, *r, *k, *u, *v, *w; /* BN temp */
+       FILE    *str;
+       u_int   temp;
+
+       /*
+        * Generate DSA parameters for use as IFF parameters.
+        */
+       fprintf(stderr, "Generating IFF parameters (%d bits)...\n",
+           modulus);
+       RAND_bytes(seed, sizeof(seed));
+       dsa = DSA_generate_parameters(modulus, seed, sizeof(seed), NULL,
+           NULL, cb, "IFF");
+       fprintf(stderr, "\n");
+       if (dsa == NULL) {
+               fprintf(stderr, "DSA generate parameters fails\n%s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               rval = -1;
+               return (NULL);;
+       }
+
+       /*
+        * Generate the private and public keys. The DSA parameters and
+        * these keys are distributed to all members of the group.
+        */
+       fprintf(stderr, "Generating IFF keys (%d bits)...\n", modulus);
+       b = BN_new(); r = BN_new(); k = BN_new();
+       u = BN_new(); v = BN_new(); w = BN_new(); ctx = BN_CTX_new();
+       BN_rand(b, BN_num_bits(dsa->q), -1, 0); /* a */
+       BN_mod(b, b, dsa->q, ctx);
+       BN_sub(v, dsa->q, b);
+       BN_mod_exp(v, dsa->g, v, dsa->p, ctx); /* g^(q - b) mod p */
+       BN_mod_exp(u, dsa->g, b, dsa->p, ctx);  /* g^b mod p */
+       BN_mod_mul(u, u, v, dsa->p, ctx);
+       temp = BN_is_one(u);
+       fprintf(stderr,
+           "Confirm g^(q - b) g^b = 1 mod p: %s\n", temp == 1 ?
+           "yes" : "no");
+       if (!temp) {
+               BN_free(b); BN_free(r); BN_free(k);
+               BN_free(u); BN_free(v); BN_free(w); BN_CTX_free(ctx);
+               rval = -1;
+               return (NULL);
+       }
+       dsa->priv_key = BN_dup(b);              /* private key */
+       dsa->pub_key = BN_dup(v);               /* public key */
+
+       /*
+        * Here is a trial round of the protocol. First, Alice rolls
+        * random r (0 < r < q) and sends it to Bob. She needs only
+        * modulus q.
+        */
+       BN_rand(r, BN_num_bits(dsa->q), -1, 0); /* r */
+       BN_mod(r, r, dsa->q, ctx);
+
+       /*
+        * Bob rolls random k (0 < k < q), computes y = k + b r mod q
+        * and x = g^k mod p, then sends (y, x) to Alice. He needs
+        * moduli p, q and the group key b.
+        */
+       BN_rand(k, BN_num_bits(dsa->q), -1, 0); /* k, 0 < k < q  */
+       BN_mod(k, k, dsa->q, ctx);
+       BN_mod_mul(v, dsa->priv_key, r, dsa->q, ctx); /* b r mod q */
+       BN_add(v, v, k);
+       BN_mod(v, v, dsa->q, ctx);              /* y = k + b r mod q */
+       BN_mod_exp(u, dsa->g, k, dsa->p, ctx);  /* x = g^k mod p */
+
+       /*
+        * Alice computes g^y v^r and verifies the result is equal to x.
+        * She needs modulus p, generator g, and the public key v, as
+        * well as her original r.
+        */
+       BN_mod_exp(v, dsa->g, v, dsa->p, ctx); /* g^y mod p */
+       BN_mod_exp(w, dsa->pub_key, r, dsa->p, ctx); /* v^r */
+       BN_mod_mul(v, w, v, dsa->p, ctx);       /* product mod p */
+       temp = BN_cmp(u, v);
+       fprintf(stderr,
+           "Confirm g^k = g^(k + b r) g^(q - b) r: %s\n", temp ==
+           0 ? "yes" : "no");
+       BN_free(b); BN_free(r); BN_free(k);
+       BN_free(u); BN_free(v); BN_free(w); BN_CTX_free(ctx);
+       if (temp != 0) {
+               DSA_free(dsa);
+               rval = -1;
+               return (NULL);
+       }
+
+       /*
+        * Write the IFF server parameters and keys as a DSA private key
+        * encoded in PEM.
+        *
+        * p    modulus p
+        * q    modulus q
+        * g    generator g
+        * priv_key b
+        * public_key v
+        */
+       str = fheader("IFFpar", trustname);
+       pkey = EVP_PKEY_new();
+       EVP_PKEY_assign_DSA(pkey, dsa);
+       PEM_write_PrivateKey(str, pkey, passwd2 ? EVP_des_cbc() : NULL,
+           NULL, 0, NULL, passwd2);
+       fclose(str);
+       if (debug)
+               DSA_print_fp(stdout, dsa, 0);
+       fslink(id, trustname);
+       return (pkey);
+}
+
+
+/*
+ * Generate Guillou-Quisquater (GQ) parameters and keys
+ *
+ * The Guillou-Quisquater (GQ) identity scheme is intended for use when
+ * the parameters, keys and certificates are generated by this program.
+ * The scheme uses a certificate extension field do convey the public
+ * key of a particular group identified by a group key known only to
+ * members of the group. The scheme is self contained and independent of
+ * new generations of host keys and sign keys.
+ *
+ * The GQ parameters hide in a RSA cuckoo structure which uses the same
+ * parameters. The values are used by an identity scheme based on RSA
+ * cryptography and described in Stimson p. 300 (with errors). The 512-
+ * bit public modulus is n = p q, where p and q are secret large primes.
+ * The TA rolls private random group key b as RSA exponent. These values
+ * are known to all group members.
+ *
+ * When rolling new certificates, a member recomputes the private and
+ * public keys. The private key u is a random roll, while the public key
+ * is the inverse obscured by the group key v = (u^-1)^b. These values
+ * replace the private and public keys normally generated by the RSA
+ * scheme. Alice challenges Bob to confirm identity using the protocol
+ * described below.
+ */
+EVP_PKEY *                     /* RSA cuckoo nest */
+gen_gqpar(
+       char    *id             /* file name id */
+       )
+{
+       EVP_PKEY *pkey;         /* private key */
+       RSA     *rsa;           /* GQ parameters */
+       BN_CTX  *ctx;           /* BN working space */
+       FILE    *str;
+
+       /*
+        * Generate RSA parameters for use as GQ parameters.
+        */
+       fprintf(stderr,
+           "Generating GQ parameters (%d bits)...\n", modulus);
+       rsa = RSA_generate_key(modulus, 3, cb, "GQ");
+       fprintf(stderr, "\n");
+       if (rsa == NULL) {
+               fprintf(stderr, "RSA generate keys fails\n%s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               rval = -1;
+               return (NULL);
+       }
+
+       /*
+        * Generate the group key b, which is saved in the e member of
+        * the RSA structure. These values are distributed to all
+        * members of the group, but shielded from all other groups. We
+        * don't use all the parameters, but set the unused ones to a
+        * small number to minimize the file size.
+        */
+       ctx = BN_CTX_new();
+       BN_rand(rsa->e, BN_num_bits(rsa->n), -1, 0); /* b */
+       BN_mod(rsa->e, rsa->e, rsa->n, ctx);
+       BN_copy(rsa->d, BN_value_one());
+       BN_copy(rsa->p, BN_value_one());
+       BN_copy(rsa->q, BN_value_one());
+       BN_copy(rsa->dmp1, BN_value_one());
+       BN_copy(rsa->dmq1, BN_value_one());
+       BN_copy(rsa->iqmp, BN_value_one());
+
+       /*
+        * Write the GQ parameters as a RSA private key encoded in PEM.
+        * The public and private keys are filled in later.
+        *
+        * n    modulus n
+        * e    group key b
+        * (remaining values are not used)
+        */
+       str = fheader("GQpar", trustname);
+       pkey = EVP_PKEY_new();
+       EVP_PKEY_assign_RSA(pkey, rsa);
+       PEM_write_PrivateKey(str, pkey, passwd2 ? EVP_des_cbc() : NULL,
+           NULL, 0, NULL, passwd2);
+       fclose(str);
+       if (debug)
+               RSA_print_fp(stdout, rsa, 0);
+       fslink(id, trustname);
+       return (pkey);
+}
+
+
+/*
+ * Update Guillou-Quisquater (GQ) parameters
+ */
+EVP_PKEY *                     /* RSA cuckoo nest */
+gen_gqkey(
+       char    *id,            /* file name id */
+       EVP_PKEY *gqpar         /* GQ parameters */
+       )
+{
+       EVP_PKEY *pkey;         /* private key */
+       RSA     *rsa;           /* RSA parameters */
+       BN_CTX  *ctx;           /* BN working space */
+       BIGNUM  *u, *v, *g, *k, *r, *y; /* BN temps */
+       FILE    *str;
+       u_int   temp;
+
+       /*
+        * Generate GQ keys. Note that the group key b is the e member
+        * of
+        * the GQ parameters.
+        */
+       fprintf(stderr, "Updating GQ keys (%d bits)...\n", modulus);
+       ctx = BN_CTX_new(); u = BN_new(); v = BN_new();
+       g = BN_new(); k = BN_new(); r = BN_new(); y = BN_new();
+
+       /*
+        * When generating his certificate, Bob rolls random private key
+        * u. 
+        */
+       rsa = gqpar->pkey.rsa;
+       BN_rand(u, BN_num_bits(rsa->n), -1, 0); /* u */
+       BN_mod(u, u, rsa->n, ctx);
+       BN_mod_inverse(v, u, rsa->n, ctx);      /* u^-1 mod n */
+       BN_mod_mul(k, v, u, rsa->n, ctx);
+
+       /*
+        * Bob computes public key v = (u^-1)^b, which is saved in an
+        * extension field on his certificate. We check that u^b v =
+        * 1 mod n.
+        */
+       BN_mod_exp(v, v, rsa->e, rsa->n, ctx);
+       BN_mod_exp(g, u, rsa->e, rsa->n, ctx); /* u^b */
+       BN_mod_mul(g, g, v, rsa->n, ctx); /* u^b (u^-1)^b */
+       temp = BN_is_one(g);
+       fprintf(stderr,
+           "Confirm u^b (u^-1)^b = 1 mod n: %s\n", temp ? "yes" :
+           "no");
+       if (!temp) {
+               BN_free(u); BN_free(v);
+               BN_free(g); BN_free(k); BN_free(r); BN_free(y);
+               BN_CTX_free(ctx);
+               RSA_free(rsa);
+               rval = -1;
+               return (NULL);
+       }
+       BN_copy(rsa->p, u);                     /* private key */
+       BN_copy(rsa->q, v);                     /* public key */
+
+       /*
+        * Here is a trial run of the protocol. First, Alice rolls
+        * random r (0 < r < n) and sends it to Bob. She needs only
+        * modulus n from the parameters.
+        */
+       BN_rand(r, BN_num_bits(rsa->n), -1, 0); /* r */
+       BN_mod(r, r, rsa->n, ctx);
+
+       /*
+        * Bob rolls random k (0 < k < n), computes y = k u^r mod n and
+        * g = k^b mod n, then sends (y, g) to Alice. He needs modulus n
+        * from the parameters and his private key u. 
+        */
+       BN_rand(k, BN_num_bits(rsa->n), -1, 0); /* k */
+       BN_mod(k, k, rsa->n, ctx);
+       BN_mod_exp(y, rsa->p, r, rsa->n, ctx);  /* u^r mod n */
+       BN_mod_mul(y, k, y, rsa->n, ctx);       /* y = k u^r mod n */
+       BN_mod_exp(g, k, rsa->e, rsa->n, ctx); /* g = k^b mod n */
+
+       /*
+        * Alice computes v^r y^b mod n and verifies the result is equal
+        * to g. She needs modulus n, generator g and group key b from
+        * the parameters and Bob's public key v = (u^-1)^b from his
+        * certificate.
+        */
+       BN_mod_exp(v, rsa->q, r, rsa->n, ctx);  /* v^r mod n */
+       BN_mod_exp(y, y, rsa->e, rsa->n, ctx); /* y^b mod n */
+       BN_mod_mul(y, v, y, rsa->n, ctx);       /* v^r y^b mod n */
+       temp = BN_cmp(y, g);
+       fprintf(stderr, "Confirm g^k = v^r y^b mod n: %s\n", temp == 0 ?
+           "yes" : "no");
+       BN_CTX_free(ctx); BN_free(u); BN_free(v);
+       BN_free(g); BN_free(k); BN_free(r); BN_free(y);
+       if (temp != 0) {
+               RSA_free(rsa);
+               rval = -1;
+               return (NULL);
+       }
+
+       /*
+        * Write the GQ parameters and keys as a RSA private key encoded
+        * in PEM.
+        *
+        * n    modulus n
+        * e    group key b
+        * p    private key u
+        * q    public key (u^-1)^b
+        * (remaining values are not used)
+        */
+       str = fheader("GQpar", trustname);
+       pkey = EVP_PKEY_new();
+       EVP_PKEY_assign_RSA(pkey, rsa);
+       PEM_write_PrivateKey(str, pkey, passwd2 ? EVP_des_cbc() : NULL,
+           NULL, 0, NULL, passwd2);
+       fclose(str);
+       if (debug)
+               RSA_print_fp(stdout, rsa, 0);
+       fslink(id, trustname);
+       return (pkey);
+}
+
+
+/*
+ * Generate Mu-Varadharajan (MV) parameters and keys
+ *
+ * The Mu-Varadharajan (MV) cryptosystem is useful when servers
+ * broadcast messages to clients, but clients never send messages to
+ * servers. There is one encryption key for the server and a separate
+ * decryption key for each client. It operates something like a
+ * pay-per-view satellite broadcasting system where the session key is
+ * encrypted by the broadcaster and the decryption keys are held in a
+ * tamperproof set-top box. We don't use it this way, but read on.
+ *
+ * The MV parameters and private encryption key hide in a DSA cuckoo
+ * structure which uses the same parameters, but generated in a
+ * different way. The values are used in an encryption scheme similar to
+ * El Gamal cryptography and a polynomial formed from the expansion of
+ * product terms (x - x[j]), as described in Mu, Y., and V.
+ * Varadharajan: Robust and Secure Broadcasting, Proc. Indocrypt 2001,
+ * 223-231. The paper has significant errors and serious omissions.
+ *
+ * Let q be the product of n distinct primes s'[j] (j = 1...n), where
+ * each s'[j] has m significant bits. Let p be a prime p = 2 * q + 1, so
+ * that q and each s'[j] divide p - 1 and p has M = n * m + 1
+ * significant bits. Let g be a generator of Zp; that is, gcd(g, p - 1)
+ * = 1 and g^q = 1 mod p. We do modular arithmetic over Zq and then
+ * project into Zp* as exponents of g. Sometimes we have to compute an
+ * inverse b^-1 of random b in Zq, but for that purpose we require
+ * gcd(b, q) = 1. We expect M to be in the 500-bit range and n
+ * relatively small, like 30. Associated with each s'[j] is an element
+ * s[j] such that s[j] s'[j] = s'[j] mod q. We find s[j] as the quotient
+ * (q + s'[j]) / s'[j]. These are the parameters of the scheme and they
+ * are expensive to compute.
+ *
+ * We set up an instance of the scheme as follows. A set of random
+ * values x[j] mod q (j = 1...n), are generated as the zeros of a
+ * polynomial of order n. The product terms (x - x[j]) are expanded to
+ * form coefficients a[i] mod q (i = 0...n) in powers of x. These are
+ * used as exponents of the generator g mod p to generate the private
+ * encryption key A. The pair (gbar, ghat) of public server keys and the
+ * pairs (xbar[j], xhat[j]) (j = 1...n) of private client keys are used
+ * to construct the decryption keys. The devil is in the details.
+ *
+ * This routine generates a private encryption file including the
+ * private encryption key E and public key (gbar, ghat). It then
+ * generates decryption files including the private key (xbar[j],
+ * xhat[j]) for each client. E is a permutation that encrypts a block
+ * y = E x. The jth client computes the inverse permutation E^-1 =
+ * gbar^xhat[j] ghat^xbar[j] and decrypts the block x = E^-1 y.
+ *
+ * The distinguishing characteristic of this scheme is the capability to
+ * revoke keys. Included in the calculation of E, gbar and ghat is the
+ * product s = prod(s'[j]) (j = 1...n) above. If the factor s'[j] is
+ * subsequently removed from the product and E, gbar and ghat
+ * recomputed, the jth client will no longer be able to compute E^-1 and
+ * thus unable to decrypt the block.
+ */
+EVP_PKEY *                     /* DSA cuckoo nest */
+gen_mv(
+       char    *id             /* file name id */
+       )
+{
+       EVP_PKEY *pkey, *pkey1; /* private key */
+       DSA     *dsa;           /* DSA parameters */
+       DSA     *sdsa;          /* DSA parameters */
+       BN_CTX  *ctx;           /* BN working space */
+       BIGNUM  **x;            /* polynomial zeros vector */
+       BIGNUM  **a;            /* polynomial coefficient vector */
+       BIGNUM  **g;            /* public key vector */
+       BIGNUM  **s, **s1;      /* private enabling keys */
+       BIGNUM  **xbar, **xhat; /* private keys vector */
+       BIGNUM  *b;             /* group key */
+       BIGNUM  *b1;            /* inverse group key */
+       BIGNUM  *ss;            /* enabling key */
+       BIGNUM  *biga;          /* master encryption key */
+       BIGNUM  *bige;          /* session encryption key */
+       BIGNUM  *gbar, *ghat;   /* public key */
+       BIGNUM  *u, *v, *w;     /* BN scratch */
+       int     i, j, n;
+       FILE    *str;
+       u_int   temp;
+       char    ident[20];
+
+       /*
+        * Generate MV parameters.
+        *
+        * The object is to generate a multiplicative group Zp* modulo a
+        * prime p and a subset Zq mod q, where q is the product of n
+        * distinct primes s'[j] (j = 1...n) and q divides p - 1. We
+        * first generate n distinct primes, which may have to be
+        * regenerated later. As a practical matter, it is tough to find
+        * more than 31 distinct primes for modulus 512 or 61 primes for
+        * modulus 1024. The latter can take several hundred iterations
+        * and several minutes on a Sun Blade 1000.
+        */
+       n = nkeys;
+       fprintf(stderr,
+           "Generating MV parameters for %d keys (%d bits)...\n", n,
+           modulus / n);
+       ctx = BN_CTX_new(); u = BN_new(); v = BN_new(); w = BN_new();
+       b = BN_new(); b1 = BN_new();
+       dsa = DSA_new();
+       dsa->p = BN_new();
+       dsa->q = BN_new();
+       dsa->g = BN_new();
+       s = malloc((n + 1) * sizeof(BIGNUM));
+       s1 = malloc((n + 1) * sizeof(BIGNUM));
+       for (j = 1; j <= n; j++)
+               s1[j] = BN_new();
+       temp = 0;
+       for (j = 1; j <= n; j++) {
+               while (1) {
+                       fprintf(stderr, "Birthdays %d\r", temp);
+                       BN_generate_prime(s1[j], modulus / n, 0, NULL,
+                           NULL, NULL, NULL);
+                       for (i = 1; i < j; i++) {
+                               if (BN_cmp(s1[i], s1[j]) == 0)
+                                       break;
+                       }
+                       if (i == j)
+                               break;
+                       temp++;
+               }
+       }
+       fprintf(stderr, "Birthday keys rejected %d\n", temp);
+
+       /*
+        * Compute the modulus q as the product of the primes. Compute
+        * the modulus p as 2 * q + 1 and test p for primality. If p
+        * is composite, replace one of the primes with a new distinct
+        * one and try again. Note that q will hardly be a secret since
+        * we have to reveal p to servers and clients. However,
+        * factoring q to find the primes should be adequately hard, as
+        * this is the same problem considered hard in RSA. Question: is
+        * it as hard to find n small prime factors totalling n bits as
+        * it is to find two large prime factors totalling n bits?
+        * Remember, the bad guy doesn't know n.
+        */
+       temp = 0;
+       while (1) {
+               fprintf(stderr, "Duplicate keys rejected %d\r", ++temp);
+               BN_one(dsa->q);
+               for (j = 1; j <= n; j++)
+                       BN_mul(dsa->q, dsa->q, s1[j], ctx);
+               BN_copy(dsa->p, dsa->q);
+               BN_add(dsa->p, dsa->p, dsa->p);
+               BN_add_word(dsa->p, 1);
+               if (BN_is_prime(dsa->p, BN_prime_checks, NULL, ctx,
+                   NULL))
+                       break;
+
+               j = temp % n + 1;
+               while (1) {
+                       BN_generate_prime(u, modulus / n, 0, 0, NULL,
+                           NULL, NULL);
+                       for (i = 1; i <= n; i++) {
+                               if (BN_cmp(u, s1[i]) == 0)
+                                       break;
+                       }
+                       if (i > n)
+                               break;
+               }
+               BN_copy(s1[j], u);
+       }
+       fprintf(stderr, "Duplicate keys rejected %d\n", temp);
+
+       /*
+        * Compute the generator g using a random roll such that
+        * gcd(g, p - 1) = 1 and g^q = 1. This is a generator of p, not
+        * q.
+        */
+       BN_copy(v, dsa->p);
+       BN_sub_word(v, 1);
+       while (1) {
+               BN_rand(dsa->g, BN_num_bits(dsa->p) - 1, 0, 0);
+               BN_mod(dsa->g, dsa->g, dsa->p, ctx);
+               BN_gcd(u, dsa->g, v, ctx);
+               if (!BN_is_one(u))
+                       continue;
+
+               BN_mod_exp(u, dsa->g, dsa->q, dsa->p, ctx);
+               if (BN_is_one(u))
+                       break;
+       }
+
+       /*
+        * Compute s[j] such that s[j] * s'[j] = s'[j] for all j. The
+        * easy way to do this is to compute q + s'[j] and divide the
+        * result by s'[j]. Exercise for the student: prove the
+        * remainder is always zero.
+        */
+       for (j = 1; j <= n; j++) {
+               s[j] = BN_new();
+               BN_add(s[j], dsa->q, s1[j]);
+               BN_div(s[j], u, s[j], s1[j], ctx);
+       }
+
+       /*
+        * Setup is now complete. Roll random polynomial roots x[j]
+        * (0 < x[j] < q) for all j. While it may not be strictly
+        * necessary, Make sure each root has no factors in common with
+        * q.
+        */
+       fprintf(stderr,
+           "Generating polynomial coefficients for %d roots (%d bits)\n",
+           n, BN_num_bits(dsa->q)); 
+       x = malloc((n + 1) * sizeof(BIGNUM));
+       for (j = 1; j <= n; j++) {
+               x[j] = BN_new();
+               while (1) {
+                       BN_rand(x[j], BN_num_bits(dsa->q), 0, 0);
+                       BN_mod(x[j], x[j], dsa->q, ctx);
+                       BN_gcd(u, x[j], dsa->q, ctx);
+                       if (BN_is_one(u))
+                               break;
+               }
+       }
+
+       /*
+        * Generate polynomial coefficients a[i] (i = 0...n) from the
+        * expansion of root products (x - x[j]) mod q for all j. The
+        * method is a present from Charlie Boncelet.
+        */
+       a = malloc((n + 1) * sizeof(BIGNUM));
+       for (i = 0; i <= n; i++) {
+               a[i] = BN_new();
+               BN_one(a[i]);
+       }
+       for (j = 1; j <= n; j++) {
+               BN_zero(w);
+               for (i = 0; i < j; i++) {
+                       BN_copy(u, dsa->q);
+                       BN_mod_mul(v, a[i], x[j], dsa->q, ctx);
+                       BN_sub(u, u, v);
+                       BN_add(u, u, w);
+                       BN_copy(w, a[i]);
+                       BN_mod(a[i], u, dsa->q, ctx);
+               }
+       }
+
+       /*
+        * Generate g[i] = g^a[i] mod p for all i and the generator g.
+        */
+       fprintf(stderr, "Generating g[i] parameters\n");
+       g = malloc((n + 1) * sizeof(BIGNUM));
+       for (i = 0; i <= n; i++) {
+               g[i] = BN_new();
+               BN_mod_exp(g[i], dsa->g, a[i], dsa->p, ctx);
+       }
+
+       /*
+        * Verify prod(g[i]^(a[i] x[j]^i)) = 1 for all i, j; otherwise,
+        * exit. Note the a[i] x[j]^i exponent is computed mod q, but
+        * the g[i] is computed mod p. also note the expression given in
+        * the paper is incorrect.
+        */
+       temp = 1;
+       for (j = 1; j <= n; j++) {
+               BN_one(u);
+               for (i = 0; i <= n; i++) {
+                       BN_set_word(v, i);
+                       BN_mod_exp(v, x[j], v, dsa->q, ctx);
+                       BN_mod_mul(v, v, a[i], dsa->q, ctx);
+                       BN_mod_exp(v, dsa->g, v, dsa->p, ctx);
+                       BN_mod_mul(u, u, v, dsa->p, ctx);
+               }
+               if (!BN_is_one(u))
+                       temp = 0;
+       }
+       fprintf(stderr,
+           "Confirm prod(g[i]^(x[j]^i)) = 1 for all i, j: %s\n", temp ?
+           "yes" : "no");
+       if (!temp) {
+               rval = -1;
+               return (NULL);
+       }
+
+       /*
+        * Make private encryption key A. Keep it around for awhile,
+        * since it is expensive to compute.
+        */
+       biga = BN_new();
+       BN_one(biga);
+       for (j = 1; j <= n; j++) {
+               for (i = 0; i < n; i++) {
+                       BN_set_word(v, i);
+                       BN_mod_exp(v, x[j], v, dsa->q, ctx);
+                       BN_mod_exp(v, g[i], v, dsa->p, ctx);
+                       BN_mod_mul(biga, biga, v, dsa->p, ctx);
+               }
+       }
+
+       /*
+        * Roll private random group key b mod q (0 < b < q), where
+        * gcd(b, q) = 1 to guarantee b^1 exists, then compute b^-1
+        * mod q. If b is changed, the client keys must be recomputed.
+        */
+       while (1) {
+               BN_rand(b, BN_num_bits(dsa->q), 0, 0);
+               BN_mod(b, b, dsa->q, ctx);
+               BN_gcd(u, b, dsa->q, ctx);
+               if (BN_is_one(u))
+                       break;
+       }
+       BN_mod_inverse(b1, b, dsa->q, ctx);
+
+       /*
+        * Make private client keys (xbar[j], xhat[j]) for all j. Note
+        * that the keys for the jth client involve s[j], but not s'[j]
+        * or the product s = prod(s'[j]) mod q, which is the enabling
+        * key.
+        */
+       xbar = malloc((n + 1) * sizeof(BIGNUM));
+       xhat = malloc((n + 1) * sizeof(BIGNUM));
+       for (j = 1; j <= n; j++) {
+               xbar[j] = BN_new(); xhat[j] = BN_new();
+               BN_zero(xbar[j]);
+               BN_set_word(v, n);
+               for (i = 1; i <= n; i++) {
+                       if (i == j)
+                               continue;
+                       BN_mod_exp(u, x[i], v, dsa->q, ctx);
+                       BN_add(xbar[j], xbar[j], u);
+               }
+               BN_mod_mul(xbar[j], xbar[j], b1, dsa->q, ctx);
+               BN_mod_exp(xhat[j], x[j], v, dsa->q, ctx);
+               BN_mod_mul(xhat[j], xhat[j], s[j], dsa->q, ctx);
+       }
+
+       /*
+        * The enabling key is initially q by construction. We can
+        * revoke client j by dividing q by s'[j]. The quotient becomes
+        * the enabling key s. Note we always have to revoke one key;
+        * otherwise, the plaintext and cryptotext would be identical.
+        */
+       ss = BN_new();
+       BN_copy(ss, dsa->q);
+       BN_div(ss, u, dsa->q, s1[n], ctx);
+
+       /*
+        * Make private server encryption key E = A^s and public server
+        * keys gbar = g^s mod p and ghat = g^(s b) mod p. The (gbar,
+        * ghat) is the public key provided to the server, which uses it
+        * to compute the session encryption key and public key included
+        * in its messages. These values must be regenerated if the
+        * enabling key is changed.
+        */
+       bige = BN_new(); gbar = BN_new(); ghat = BN_new();
+       BN_mod_exp(bige, biga, ss, dsa->p, ctx);
+       BN_mod_exp(gbar, dsa->g, ss, dsa->p, ctx);
+       BN_mod_mul(v, ss, b, dsa->q, ctx);
+       BN_mod_exp(ghat, dsa->g, v, dsa->p, ctx);
+
+       /*
+        * We produce the key media in three steps. The first step is to
+        * generate the private values that do not depend on the
+        * enabling key. These include the server values p, q, g, b, A
+        * and the client values s'[j], xbar[j] and xhat[j] for each j.
+        * The p, xbar[j] and xhat[j] values are encoded in private
+        * files which are distributed to respective clients. The p, q,
+        * g, A and s'[j] values (will be) written to a secret file to
+        * be read back later.
+        *
+        * The secret file (will be) read back at some later time to
+        * enable/disable individual keys and generate/regenerate the
+        * enabling key s. The p, q, E, gbar and ghat values are written
+        * to a secret file to be read back later by the server.
+        *
+        * The server reads the secret file and rolls the session key
+        * k, which is used only once, then computes E^k, gbar^k and
+        * ghat^k. The E^k is the session encryption key. The encrypted
+        * data, gbar^k and ghat^k are transmtted to clients in an
+        * extension field. The client receives the message and computes
+        * x = (gbar^k)^xbar[j] (ghat^k)^xhat[j], finds the session
+        * encryption key E^k as the inverse x^-1 and decrypts the data.
+        */
+       BN_copy(dsa->g, bige);
+       dsa->priv_key = BN_dup(gbar);
+       dsa->pub_key = BN_dup(ghat);
+
+       /*
+        * Write the MV server parameters and keys as a DSA private key
+        * encoded in PEM.
+        *
+        * p    modulus p
+        * q    modulus q (used only to generate k)
+        * g    E mod p
+        * priv_key gbar mod p
+        * pub_key ghat mod p
+        */
+       str = fheader("MVpar", trustname);
+       pkey = EVP_PKEY_new();
+       EVP_PKEY_assign_DSA(pkey, dsa);
+       PEM_write_PrivateKey(str, pkey, passwd2 ? EVP_des_cbc() : NULL,
+           NULL, 0, NULL, passwd2);
+       fclose(str);
+       if (debug)
+               DSA_print_fp(stdout, dsa, 0);
+       fslink(id, trustname);
+
+       /*
+        * Write the parameters and private key (xbar[j], xhat[j]) for
+        * all j as a DSA private key encoded in PEM. It is used only by
+        * the designated recipient(s) who pay a suitably outrageous fee
+        * for its use.
+        */
+       sdsa = DSA_new();
+       sdsa->p = BN_dup(dsa->p);
+       sdsa->q = BN_dup(BN_value_one());
+       sdsa->g = BN_dup(BN_value_one());
+       sdsa->priv_key = BN_new();
+       sdsa->pub_key = BN_new();
+       for (j = 1; j <= n; j++) {
+               BN_copy(sdsa->priv_key, xbar[j]);
+               BN_copy(sdsa->pub_key, xhat[j]);
+               BN_mod_exp(v, dsa->priv_key, sdsa->pub_key, dsa->p,
+                   ctx);
+               BN_mod_exp(u, dsa->pub_key, sdsa->priv_key, dsa->p,
+                   ctx);
+               BN_mod_mul(u, u, v, dsa->p, ctx);
+               BN_mod_mul(u, u, dsa->g, dsa->p, ctx);
+               BN_free(xbar[j]); BN_free(xhat[j]);
+               BN_free(x[j]); BN_free(s[j]); BN_free(s1[j]);
+               if (!BN_is_one(u)) {
+                       fprintf(stderr, "Revoke key %d\n", j);
+                       continue;
+               }
+
+               /*
+                * Write the client parameters as a DSA private key
+                * encoded in PEM. We don't make links for these.
+                *
+                * p    modulus p
+                * priv_key xbar[j] mod q
+                * pub_key xhat[j] mod q
+                * (remaining values are not used)
+                */
+               sprintf(ident, "MVkey%d", j);
+               str = fheader(ident, trustname);
+               pkey1 = EVP_PKEY_new();
+               EVP_PKEY_set1_DSA(pkey1, sdsa);
+               PEM_write_PrivateKey(str, pkey1, passwd2 ?
+                   EVP_des_cbc() : NULL, NULL, 0, NULL, passwd2);
+               fclose(str);
+               fprintf(stderr, "ntpkey_%s_%s.%lu\n", ident, trustname,
+                   epoch + JAN_1970);
+               if (debug)
+                       DSA_print_fp(stdout, sdsa, 0);
+               EVP_PKEY_free(pkey1);
+       }
+
+       /*
+        * Free the countries.
+        */
+       for (i = 0; i <= n; i++) {
+               BN_free(a[i]);
+               BN_free(g[i]);
+       }
+       BN_free(u); BN_free(v); BN_free(w); BN_CTX_free(ctx);
+       BN_free(b); BN_free(b1); BN_free(biga); BN_free(bige);
+       BN_free(ss); BN_free(gbar); BN_free(ghat);
+       DSA_free(sdsa);
+
+       /*
+        * Free the world.
+        */
+       free(x); free(a); free(g); free(s); free(s1);
+       free(xbar); free(xhat);
+       return (pkey);
+}
+
+
+/*
+ * Generate X509v3 scertificate.
+ *
+ * The certificate consists of the version number, serial number,
+ * validity interval, issuer name, subject name and public key. For a
+ * self-signed certificate, the issuer name is the same as the subject
+ * name and these items are signed using the subject private key. The
+ * validity interval extends from the current time to the same time one
+ * year hence. For NTP purposes, it is convenient to use the NTP seconds
+ * of the current time as the serial number.
+ */
+int
+x509   (
+       EVP_PKEY *pkey,         /* generic signature algorithm */
+       const EVP_MD *md,       /* generic digest algorithm */
+       char    *gqpub,         /* identity extension (hex string) */
+       char    *exten          /* private cert extension */
+       )
+{
+       X509    *cert;          /* X509 certificate */
+       X509_NAME *subj;        /* distinguished (common) name */
+       X509_EXTENSION *ex;     /* X509v3 extension */
+       FILE    *str;           /* file handle */
+       ASN1_INTEGER *serial;   /* serial number */
+       const char *id;         /* digest/signature scheme name */
+       char    pathbuf[MAXFILENAME + 1];
+
+       /*
+        * Generate X509 self-signed certificate.
+        *
+        * Set the certificate serial to the NTP seconds for grins. Set
+        * the version to 3. Set the subject name and issuer name to the
+        * subject name in the request. Set the initial validity to the
+        * current time and the final validity one year hence. 
+        */
+       id = OBJ_nid2sn(md->pkey_type);
+       fprintf(stderr, "Generating certificate %s\n", id);
+       cert = X509_new();
+       X509_set_version(cert, 2L);
+       serial = ASN1_INTEGER_new();
+       ASN1_INTEGER_set(serial, epoch + JAN_1970);
+       X509_set_serialNumber(cert, serial);
+       ASN1_INTEGER_free(serial);
+       X509_time_adj(X509_get_notBefore(cert), 0L, &epoch);
+       X509_time_adj(X509_get_notAfter(cert), YEAR, &epoch);
+       subj = X509_get_subject_name(cert);
+       X509_NAME_add_entry_by_txt(subj, "commonName", MBSTRING_ASC,
+           (unsigned char *) hostname, strlen(hostname), -1, 0);
+       subj = X509_get_issuer_name(cert);
+       X509_NAME_add_entry_by_txt(subj, "commonName", MBSTRING_ASC,
+           (unsigned char *) trustname, strlen(trustname), -1, 0);
+       if (!X509_set_pubkey(cert, pkey)) {
+               fprintf(stderr, "Assign key fails\n%s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               X509_free(cert);
+               rval = -1;
+               return (0);
+       }
+
+       /*
+        * Add X509v3 extensions if present. These represent the minimum
+        * set defined in RFC3280 less the certificate_policy extension,
+        * which is seriously obfuscated in OpenSSL.
+        */
+       /*
+        * The basic_constraints extension CA:TRUE allows servers to
+        * sign client certficitates.
+        */
+       fprintf(stderr, "%s: %s\n", LN_basic_constraints,
+           BASIC_CONSTRAINTS);
+       ex = X509V3_EXT_conf_nid(NULL, NULL, NID_basic_constraints,
+           BASIC_CONSTRAINTS);
+       if (!X509_add_ext(cert, ex, -1)) {
+               fprintf(stderr, "Add extension field fails\n%s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               rval = -1;
+               return (0);
+       }
+       X509_EXTENSION_free(ex);
+
+       /*
+        * The key_usage extension designates the purposes the key can
+        * be used for.
+        */
+       fprintf(stderr, "%s: %s\n", LN_key_usage, KEY_USAGE);
+       ex = X509V3_EXT_conf_nid(NULL, NULL, NID_key_usage, KEY_USAGE);
+       if (!X509_add_ext(cert, ex, -1)) {
+               fprintf(stderr, "Add extension field fails\n%s\n",
+                   ERR_error_string(ERR_get_error(), NULL));
+               rval = -1;
+               return (0);
+       }
+       X509_EXTENSION_free(ex);
+       /*
+        * The subject_key_identifier is used for the GQ public key.
+        * This should not be controversial.
+        */
+       if (gqpub != NULL) {
+               fprintf(stderr, "%s\n", LN_subject_key_identifier);
+               ex = X509V3_EXT_conf_nid(NULL, NULL,
+                   NID_subject_key_identifier, gqpub);
+               if (!X509_add_ext(cert, ex, -1)) {
+                       fprintf(stderr,
+                           "Add extension field fails\n%s\n",
+                           ERR_error_string(ERR_get_error(), NULL));
+                       rval = -1;
+                       return (0);
+               }
+               X509_EXTENSION_free(ex);
+       }
+
+       /*
+        * The extended key usage extension is used for special purpose
+        * here. The semantics probably do not conform to the designer's
+        * intent and will likely change in future.
+        * 
+        * "trustRoot" designates a root authority
+        * "private" designates a private certificate
+        */
+       if (exten != NULL) {
+               fprintf(stderr, "%s: %s\n", LN_ext_key_usage, exten);
+               ex = X509V3_EXT_conf_nid(NULL, NULL,
+                   NID_ext_key_usage, exten);
+               if (!X509_add_ext(cert, ex, -1)) {
+                       fprintf(stderr,
+                           "Add extension field fails\n%s\n",
+                           ERR_error_string(ERR_get_error(), NULL));
+                       rval = -1;
+                       return (0);
+               }
+               X509_EXTENSION_free(ex);
+       }
+
+       /*
+        * Sign and verify.
+        */
+       X509_sign(cert, pkey, md);
+       if (!X509_verify(cert, pkey)) {
+               fprintf(stderr, "Verify %s certificate fails\n%s\n", id,
+                   ERR_error_string(ERR_get_error(), NULL));
+               X509_free(cert);
+               rval = -1;
+               return (0);
+       }
+
+       /*
+        * Write the certificate encoded in PEM.
+        */
+       sprintf(pathbuf, "%scert", id);
+       str = fheader(pathbuf, hostname);
+       PEM_write_X509(str, cert);
+       fclose(str);
+       if (debug)
+               X509_print_fp(stdout, cert);
+       X509_free(cert);
+       fslink("cert", hostname);
+       return (1);
+}
+
+#if 0  /* asn2ntp is not used */
+/*
+ * asn2ntp - convert ASN1_TIME time structure to NTP time
+ */
+u_long
+asn2ntp        (
+       ASN1_TIME *asn1time     /* pointer to ASN1_TIME structure */
+       )
+{
+       char    *v;             /* pointer to ASN1_TIME string */
+       struct  tm tm;          /* time decode structure time */
+
+       /*
+        * Extract time string YYMMDDHHMMSSZ from ASN.1 time structure.
+        * Note that the YY, MM, DD fields start with one, the HH, MM,
+        * SS fiels start with zero and the Z character should be 'Z'
+        * for UTC. Also note that years less than 50 map to years
+        * greater than 100. Dontcha love ASN.1?
+        */
+       if (asn1time->length > 13)
+               return (-1);
+       v = (char *)asn1time->data;
+       tm.tm_year = (v[0] - '0') * 10 + v[1] - '0';
+       if (tm.tm_year < 50)
+               tm.tm_year += 100;
+       tm.tm_mon = (v[2] - '0') * 10 + v[3] - '0' - 1;
+       tm.tm_mday = (v[4] - '0') * 10 + v[5] - '0';
+       tm.tm_hour = (v[6] - '0') * 10 + v[7] - '0';
+       tm.tm_min = (v[8] - '0') * 10 + v[9] - '0';
+       tm.tm_sec = (v[10] - '0') * 10 + v[11] - '0';
+       tm.tm_wday = 0;
+       tm.tm_yday = 0;
+       tm.tm_isdst = 0;
+       return (mktime(&tm) + JAN_1970);
+}
+#endif
+
+/*
+ * Callback routine
+ */
+void
+cb     (
+       int     n1,             /* arg 1 */
+       int     n2,             /* arg 2 */
+       void    *chr            /* arg 3 */
+       )
+{
+       switch (n1) {
+       case 0:
+               d0++;
+               fprintf(stderr, "%s %d %d %lu\r", (char *)chr, n1, n2,
+                   d0);
+               break;
+       case 1:
+               d1++;
+               fprintf(stderr, "%s\t\t%d %d %lu\r", (char *)chr, n1,
+                   n2, d1);
+               break;
+       case 2:
+               d2++;
+               fprintf(stderr, "%s\t\t\t\t%d %d %lu\r", (char *)chr,
+                   n1, n2, d2);
+               break;
+       case 3:
+               d3++;
+               fprintf(stderr, "%s\t\t\t\t\t\t%d %d %lu\r",
+                   (char *)chr, n1, n2, d3);
+               break;
+       }
+}
+
+
+/*
+ * Generate key
+ */
+EVP_PKEY *                     /* public/private key pair */
+genkey(
+       char    *type,          /* key type (RSA or DSA) */
+       char    *id             /* file name id */
+       )
+{
+       if (type == NULL)
+               return (NULL);
+       if (strcmp(type, "RSA") == 0)
+               return (gen_rsa(id));
+
+       else if (strcmp(type, "DSA") == 0)
+               return (gen_dsa(id));
+
+       fprintf(stderr, "Invalid %s key type %s\n", id, type);
+       rval = -1;
+       return (NULL);
+}
+#endif /* OPENSSL */
+
+
+/*
+ * Generate file header
+ */
+FILE *
+fheader        (
+       const char *id,         /* file name id */
+       const char *name        /* owner name */
+       )
+{
+       FILE    *str;           /* file handle */
+
+       sprintf(filename, "ntpkey_%s_%s.%lu", id, name, epoch +
+           JAN_1970);
+       if ((str = fopen(filename, "w")) == NULL) {
+               perror("Write");
+               exit (-1);
+       }
+       fprintf(str, "# %s\n# %s", filename, ctime(&epoch));
+       return (str);
+}
+
+
+/*
+ * Generate symbolic links
+ */
+void
+fslink(
+       const char *id,         /* file name id */
+       const char *name        /* owner name */
+       )
+{
+       char    linkname[MAXFILENAME]; /* link name */
+       int     temp;
+
+       sprintf(linkname, "ntpkey_%s_%s", id, name);
+       remove(linkname);
+       temp = symlink(filename, linkname);
+       if (temp < 0)
+               perror(id);
+       fprintf(stderr, "Generating new %s file and link\n", id);
+       fprintf(stderr, "%s->%s\n", linkname, filename);
+}
diff --git a/util/ntptime.c b/util/ntptime.c
new file mode 100644 (file)
index 0000000..8f9d0c3
--- /dev/null
@@ -0,0 +1,440 @@
+/*
+ * NTP test program
+ *
+ * This program tests to see if the NTP user interface routines
+ * ntp_gettime() and ntp_adjtime() have been implemented in the kernel.
+ * If so, each of these routines is called to display current timekeeping
+ * data.
+ *
+ * For more information, see the README.kern file in the doc directory
+ * of the xntp3 distribution.
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include "ntp_fp.h"
+#include "ntp_unixtime.h"
+#include "ntp_syscall.h"
+#include "ntp_stdlib.h"
+
+#include <stdio.h>
+#include <ctype.h>
+#include <signal.h>
+#include <setjmp.h>
+
+#ifdef NTP_SYSCALLS_STD
+# ifndef SYS_DECOSF1
+#  define BADCALL -1           /* this is supposed to be a bad syscall */
+# endif /* SYS_DECOSF1 */
+#endif
+
+#ifdef HAVE_STRUCT_NTPTIMEVAL_TIME_TV_NSEC
+#define tv_frac_sec tv_nsec
+#else
+#define tv_frac_sec tv_usec
+#endif
+
+
+#define TIMEX_MOD_BITS \
+"\20\1OFFSET\2FREQUENCY\3MAXERROR\4ESTERROR\5STATUS\6TIMECONST\
+\13PLL\14FLL\15MICRO\16NANO\17CLKB\20CLKA"
+#define TIMEX_STA_BITS \
+"\20\1PLL\2PPSFREQ\3PPSTIME\4FLL\5INS\6DEL\7UNSYNC\10FREQHOLD\
+\11PPSSIGNAL\12PPSJITTER\13PPSWANDER\14PPSERROR\15CLOCKERR\
+\16NANO\17MODE\20CLK"
+
+#define SCALE_FREQ 65536               /* frequency scale */
+
+
+/*
+ * Function prototypes
+ */
+char *sprintb          P((u_int, const char *));
+const char *timex_state        P((int));
+
+#ifdef SIGSYS
+void pll_trap          P((int));
+
+static struct sigaction newsigsys;     /* new sigaction status */
+static struct sigaction sigsys;                /* current sigaction status */
+static sigjmp_buf env;         /* environment var. for pll_trap() */
+#endif
+
+static volatile int pll_control; /* (0) daemon, (1) kernel loop */
+static volatile int status;    /* most recent status bits */
+static volatile int flash;     /* most recent ntp_adjtime() bits */
+char* progname;
+static char optargs[] = "MNT:cde:f:hm:o:rs:t:";
+
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       extern int ntp_optind;
+       extern char *ntp_optarg;
+#ifdef SUBST_ADJTIMEX
+      struct timex ntv;
+#else
+       struct ntptimeval ntv;
+#endif
+       struct timeval tv;
+       struct timex ntx, _ntx;
+       int     times[20];
+       double ftemp, gtemp, htemp;
+       long time_frac;                         /* ntv.time.tv_frac_sec (us/ns) */
+       l_fp ts;
+       volatile unsigned ts_mask = TS_MASK;            /* defaults to 20 bits (us) */
+       volatile unsigned ts_roundbit = TS_ROUNDBIT;    /* defaults to 20 bits (us) */
+       volatile int fdigits = 6;                       /* fractional digits for us */
+       int c;
+       int errflg      = 0;
+       int cost        = 0;
+       volatile int rawtime    = 0;
+
+       memset((char *)&ntx, 0, sizeof(ntx));
+       progname = argv[0];
+       while ((c = ntp_getopt(argc, argv, optargs)) != EOF) switch (c) {
+#ifdef MOD_MICRO
+           case 'M':
+               ntx.modes |= MOD_MICRO;
+               break;
+#endif
+#ifdef MOD_NANO
+           case 'N':
+               ntx.modes |= MOD_NANO;
+               break;
+#endif
+#ifdef NTP_API
+# if NTP_API > 3
+           case 'T':
+               ntx.modes = MOD_TAI;
+               ntx.constant = atoi(ntp_optarg);
+               break;
+# endif
+#endif
+           case 'c':
+               cost++;
+               break;
+           case 'e':
+               ntx.modes |= MOD_ESTERROR;
+               ntx.esterror = atoi(ntp_optarg);
+               break;
+           case 'f':
+               ntx.modes |= MOD_FREQUENCY;
+               ntx.freq = (long)(atof(ntp_optarg) * SCALE_FREQ);
+               break;
+           case 'm':
+               ntx.modes |= MOD_MAXERROR;
+               ntx.maxerror = atoi(ntp_optarg);
+               break;
+           case 'o':
+               ntx.modes |= MOD_OFFSET;
+               ntx.offset = atoi(ntp_optarg);
+               break;
+           case 'r':
+               rawtime++;
+               break;
+           case 's':
+               ntx.modes |= MOD_STATUS;
+               ntx.status = atoi(ntp_optarg);
+               if (ntx.status < 0 || ntx.status >= 0x100) errflg++;
+               break;
+           case 't':
+               ntx.modes |= MOD_TIMECONST;
+               ntx.constant = atoi(ntp_optarg);
+               break;
+           default:
+               errflg++;
+       }
+       if (errflg || (ntp_optind != argc)) {
+               (void) fprintf(stderr,
+                              "usage: %s [-%s]\n\n\
+%s%s%s\
+-c             display the time taken to call ntp_gettime (us)\n\
+-e esterror    estimate of the error (us)\n\
+-f frequency   Frequency error (-500 .. 500) (ppm)\n\
+-h             display this help info\n\
+-m maxerror    max possible error (us)\n\
+-o offset      current offset (ms)\n\
+-r             print the unix and NTP time raw\n\
+-s status      Set the status bits\n\
+-t timeconstant        log2 of PLL time constant (0 .. %d)\n",
+                              progname, optargs,
+#ifdef MOD_MICRO
+"-M            switch to microsecond mode\n",
+#else
+"",
+#endif
+#ifdef MOD_NANO
+"-N            switch to nanosecond mode\n",
+#else
+"",
+#endif
+#ifdef NTP_API
+# if NTP_API > 3
+"-T tai_offset set TAI offset\n",
+# else
+"",
+# endif
+#else
+"",
+#endif
+                              MAXTC);
+               exit(2);
+       }
+
+#ifdef SIGSYS
+       /*
+        * Test to make sure the sigaction() works in case of invalid
+        * syscall codes.
+        */
+       newsigsys.sa_handler = pll_trap;
+       newsigsys.sa_flags = 0;
+       if (sigaction(SIGSYS, &newsigsys, &sigsys)) {
+               perror("sigaction() fails to save SIGSYS trap");
+               exit(1);
+       }
+#endif /* SIGSYS */
+
+#ifdef BADCALL
+       /*
+        * Make sure the trapcatcher works.
+        */
+       pll_control = 1;
+#ifdef SIGSYS
+       if (sigsetjmp(env, 1) == 0)
+       {
+#endif
+               status = syscall(BADCALL, &ntv); /* dummy parameter */
+               if ((status < 0) && (errno == ENOSYS))
+                       --pll_control;
+#ifdef SIGSYS
+       }
+#endif
+       if (pll_control)
+           printf("sigaction() failed to catch an invalid syscall\n");
+#endif /* BADCALL */
+
+       if (cost) {
+#ifdef SIGSYS
+               if (sigsetjmp(env, 1) == 0) {
+#endif
+                       for (c = 0; c < sizeof times / sizeof times[0]; c++) {
+                               status = ntp_gettime(&ntv);
+                               if ((status < 0) && (errno == ENOSYS))
+                                       --pll_control;
+                               if (pll_control < 0)
+                                       break;
+                               times[c] = ntv.time.tv_frac_sec;
+                       }
+#ifdef SIGSYS
+               }
+#endif
+               if (pll_control >= 0) {
+                       printf("[ us %06d:", times[0]);
+                       for (c = 1; c < sizeof times / sizeof times[0]; c++)
+                           printf(" %d", times[c] - times[c - 1]);
+                       printf(" ]\n");
+               }
+       }
+#ifdef SIGSYS
+       if (sigsetjmp(env, 1) == 0) {
+#endif
+               status = ntp_gettime(&ntv);
+               if ((status < 0) && (errno == ENOSYS))
+                       --pll_control;
+#ifdef SIGSYS
+       }
+#endif
+       _ntx.modes = 0;                         /* Ensure nothing is set */
+#ifdef SIGSYS
+       if (sigsetjmp(env, 1) == 0) {
+#endif
+               status = ntp_adjtime(&_ntx);
+               if ((status < 0) && (errno == ENOSYS))
+                       --pll_control;
+               flash = _ntx.status;
+#ifdef SIGSYS
+       }
+#endif
+       if (pll_control < 0) {
+               printf("NTP user interface routines are not configured in this kernel.\n");
+               goto lexit;
+       }
+
+       /*
+        * Fetch timekeeping data and display.
+        */
+       status = ntp_gettime(&ntv);
+       if (status < 0)
+               perror("ntp_gettime() call fails");
+       else {
+               printf("ntp_gettime() returns code %d (%s)\n",
+                   status, timex_state(status));
+               time_frac = ntv.time.tv_frac_sec;
+#ifdef STA_NANO
+               if (flash & STA_NANO) {
+                       ntv.time.tv_frac_sec /= 1000;
+                       ts_mask = 0xfffffffc;   /* 1/2^30 */
+                       ts_roundbit = 0x00000002;
+                       fdigits = 9;
+               }
+#endif
+               tv.tv_sec = ntv.time.tv_sec;
+               tv.tv_usec = ntv.time.tv_frac_sec;
+               TVTOTS(&tv, &ts);
+               ts.l_ui += JAN_1970;
+               ts.l_uf += ts_roundbit;
+               ts.l_uf &= ts_mask;
+               printf("  time %s, (.%0*d),\n",
+                      prettydate(&ts), fdigits, (int) time_frac);
+               printf("  maximum error %lu us, estimated error %lu us",
+                      (u_long)ntv.maxerror, (u_long)ntv.esterror);
+               if (rawtime)
+                   printf("  ntptime=%x.%x unixtime=%x.%0*d %s",
+                   (unsigned int) ts.l_ui, (unsigned int) ts.l_uf,
+                   (int) ntv.time.tv_sec, fdigits, (int) time_frac,
+                   ctime((const time_t *) &ntv.time.tv_sec));
+#if NTP_API > 3
+               printf(", TAI offset %ld\n", (long)ntv.tai);
+#else
+               printf("\n");
+#endif /* NTP_API */
+       }
+       status = ntp_adjtime(&ntx);
+       if (status < 0)
+               perror((errno == EPERM) ? 
+                  "Must be root to set kernel values\nntp_adjtime() call fails" :
+                  "ntp_adjtime() call fails");
+       else {
+               flash = ntx.status;
+               printf("ntp_adjtime() returns code %d (%s)\n",
+                    status, timex_state(status));
+               printf("  modes %s,\n", sprintb(ntx.modes, TIMEX_MOD_BITS));
+               ftemp = (double)ntx.offset;
+#ifdef STA_NANO
+               if (flash & STA_NANO)
+                       ftemp /= 1000.0;
+#endif
+               printf("  offset %.3f", ftemp);
+               ftemp = (double)ntx.freq / SCALE_FREQ;
+               printf(" us, frequency %.3f ppm, interval %d s,\n",
+                    ftemp, 1 << ntx.shift);
+               printf("  maximum error %lu us, estimated error %lu us,\n",
+                    (u_long)ntx.maxerror, (u_long)ntx.esterror);
+               printf("  status %s,\n", sprintb((u_int)ntx.status, TIMEX_STA_BITS));
+               ftemp = (double)ntx.tolerance / SCALE_FREQ;
+               gtemp = (double)ntx.precision;
+#ifdef STA_NANO
+               if (flash & STA_NANO)
+                       gtemp /= 1000.0;
+#endif
+               printf(
+                   "  time constant %lu, precision %.3f us, tolerance %.0f ppm,\n",
+                   (u_long)ntx.constant, gtemp, ftemp);
+               if (ntx.shift == 0)
+                       exit (0);
+               ftemp = (double)ntx.ppsfreq / SCALE_FREQ;
+               gtemp = (double)ntx.stabil / SCALE_FREQ;
+               htemp = (double)ntx.jitter;
+#ifdef STA_NANO
+               if (flash & STA_NANO)
+                       htemp /= 1000.0;
+#endif
+               printf(
+                   "  pps frequency %.3f ppm, stability %.3f ppm, jitter %.3f us,\n",
+                   ftemp, gtemp, htemp);
+               printf("  intervals %lu, jitter exceeded %lu, stability exceeded %lu, errors %lu.\n",
+                   (u_long)ntx.calcnt, (u_long)ntx.jitcnt,
+                   (u_long)ntx.stbcnt, (u_long)ntx.errcnt);
+               return (0);
+       }
+
+       /*
+        * Put things back together the way we found them.
+        */
+    lexit:
+#ifdef SIGSYS
+       if (sigaction(SIGSYS, &sigsys, (struct sigaction *)NULL)) {
+               perror("sigaction() fails to restore SIGSYS trap");
+               exit(1);
+       }
+#endif
+       exit(0);
+}
+
+#ifdef SIGSYS
+/*
+ * pll_trap - trap processor for undefined syscalls
+ */
+void
+pll_trap(
+       int arg
+       )
+{
+       pll_control--;
+       siglongjmp(env, 1);
+}
+#endif
+
+/*
+ * Print a value a la the %b format of the kernel's printf
+ */
+char *
+sprintb(
+       register u_int v,
+       register const char *bits
+       )
+{
+       register char *cp;
+       register int i, any = 0;
+       register char c;
+       static char buf[132];
+
+       if (bits && *bits == 8)
+           (void)sprintf(buf, "0%o", v);
+       else
+           (void)sprintf(buf, "0x%x", v);
+       cp = buf + strlen(buf);
+       if (bits) {
+               bits++;
+               *cp++ = ' ';
+               *cp++ = '(';
+               while ((i = *bits++) != 0) {
+                       if (v & (1 << (i-1))) {
+                               if (any)
+                                   *cp++ = ',';
+                               any = 1;
+                               for (; (c = *bits) > 32; bits++)
+                                   *cp++ = c;
+                       } else
+                           for (; *bits > 32; bits++)
+                               continue;
+               }
+               *cp++ = ')';
+       }
+       *cp = '\0';
+       return (buf);
+}
+
+const char *timex_states[] = {
+       "OK", "INS", "DEL", "OOP", "WAIT", "ERROR"
+};
+
+const char *
+timex_state(
+       register int s
+       )
+{
+       static char buf[32];
+
+       if (s >= 0 && s < sizeof(timex_states) / sizeof(timex_states[0]))
+           return (timex_states[s]);
+       sprintf(buf, "TIME-#%d", s);
+       return (buf);
+}
diff --git a/util/pps-api.c b/util/pps-api.c
new file mode 100644 (file)
index 0000000..60c98b8
--- /dev/null
@@ -0,0 +1,100 @@
+/*
+
+Try to run this program to see what the PPS-API finds. You give it the
+device as argument and you may have to modify the pp.mode = BLA assignment.
+
+Poul-Henning
+
+*/
+
+#include <stdio.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <err.h>
+#include <sys/types.h>
+#include <time.h>
+#include <sys/timepps.h>
+#include <sys/termios.h>
+
+#define timespecsub(vvp, uvp)                                           \
+        do {                                                            \
+                (vvp)->tv_sec -= (uvp)->tv_sec;                         \
+                (vvp)->tv_nsec -= (uvp)->tv_nsec;                       \
+                if ((vvp)->tv_nsec < 0) {                               \
+                        (vvp)->tv_sec--;                                \
+                        (vvp)->tv_nsec += 1000000000;                   \
+                }                                                       \
+        } while (0)
+
+
+void
+Chew(struct timespec *tsa, struct timespec *tsc, unsigned sa, unsigned sc)
+{
+       static int idx;
+       struct timespec ts;
+
+       printf("%d.%09d ", tsa->tv_sec, tsa->tv_nsec);
+       printf("%d.%09d ", tsc->tv_sec, tsc->tv_nsec);
+       printf("%u %u ", sa, sc);
+
+       ts = *tsc;
+       timespecsub(&ts,tsa);
+       printf("%.9f ", ts.tv_sec + ts.tv_nsec / 1e9);
+       printf("\n");
+       fflush(stdout);
+}
+
+int
+main(int argc, char **argv)
+{
+       int fd;
+       pps_info_t pi;
+       pps_params_t pp;
+       pps_handle_t ph;
+       int i, mode;
+       u_int olda, oldc;
+       double d = 0;
+       struct timespec to;
+
+       if (argc < 2)
+               argv[1] = "/dev/cuaa1";
+       setbuf(stdout, 0);
+       fd = open(argv[1], O_RDONLY);
+       if (fd < 0) 
+               err(1, argv[1]);
+       i = time_pps_create(fd, &ph);
+       if (i < 0)
+               err(1, "time_pps_create");
+
+       i = time_pps_getcap(ph, &mode);
+       if (i < 0)
+               err(1, "time_pps_getcap");
+
+       pp.mode = PPS_CAPTUREASSERT | PPS_ECHOASSERT;
+       pp.mode = PPS_CAPTUREBOTH;
+       /* pp.mode = PPS_CAPTUREASSERT; */
+
+       i = time_pps_setparams(ph, &pp);
+       if (i < 0)
+               err(1, "time_pps_setparams");
+
+       while (1) {
+               to.tv_nsec = 0;
+               to.tv_sec = 0;
+               i = time_pps_fetch(ph, PPS_TSFMT_TSPEC, &pi, &to);
+               if (i < 0)
+                       err(1, "time_pps_fetch");
+               if (olda == pi.assert_sequence &&
+                   oldc == pi.clear_sequence) {
+                       usleep(10000);
+                       continue;
+               }
+
+               Chew(&pi.assert_timestamp, &pi.clear_timestamp,
+                       pi.assert_sequence, pi.clear_sequence);
+               olda = pi.assert_sequence;
+               oldc = pi.clear_sequence;
+       }
+
+       return(0);
+}
diff --git a/util/precision.c b/util/precision.c
new file mode 100644 (file)
index 0000000..b1516b3
--- /dev/null
@@ -0,0 +1,171 @@
+#include "ntp_unixtime.h"
+
+#include <stdio.h>
+
+#define        DEFAULT_SYS_PRECISION   -99
+
+int default_get_resolution();
+int default_get_precision();
+
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       printf("log2(resolution) = %d, log2(precision) = %d\n",
+              default_get_resolution(),
+              default_get_precision());
+       return 0;
+}
+
+/* Find the resolution of the system clock by watching how the current time
+ * changes as we read it repeatedly.
+ *
+ * struct timeval is only good to 1us, which may cause problems as machines
+ * get faster, but until then the logic goes:
+ *
+ * If a machine has resolution (i.e. accurate timing info) > 1us, then it will
+ * probably use the "unused" low order bits as a counter (to force time to be
+ * a strictly increaing variable), incrementing it each time any process
+ * requests the time [[ or maybe time will stand still ? ]].
+ *
+ * SO: the logic goes:
+ *
+ *      IF      the difference from the last time is "small" (< MINSTEP)
+ *      THEN    this machine is "counting" with the low order bits
+ *      ELIF    this is not the first time round the loop
+ *      THEN    this machine *WAS* counting, and has now stepped
+ *      ELSE    this machine has resolution < time to read clock
+ *
+ * SO: if it exits on the first loop, assume "full accuracy" (1us)
+ *     otherwise, take the log2(observered difference, rounded UP)
+ *
+ * MINLOOPS > 1 ensures that even if there is a STEP between the initial call
+ * and the first loop, it doesn't stop too early.
+ * Making it even greater allows MINSTEP to be reduced, assuming that the
+ * chance of MINSTEP-1 other processes getting in and calling gettimeofday
+ * between this processes's calls.
+ * Reducing MINSTEP may be necessary as this sets an upper bound for the time
+ * to actually call gettimeofday.
+ */
+
+#define        DUSECS  1000000
+#define        HUSECS  (1024 * 1024)
+#define        MINSTEP 5       /* some systems increment uS on each call */
+/* Don't use "1" as some *other* process may read too*/
+/*We assume no system actually *ANSWERS* in this time*/
+#define MAXSTEP 20000   /* maximum clock increment (us) */
+#define MINLOOPS 5      /* minimum number of step samples */
+#define        MAXLOOPS HUSECS /* Assume precision < .1s ! */
+
+int
+default_get_resolution(void)
+{
+       struct timeval tp;
+       struct timezone tzp;
+       long last;
+       int i;
+       long diff;
+       long val;
+       int minsteps = MINLOOPS;        /* need at least this many steps */
+
+       gettimeofday(&tp, &tzp);
+       last = tp.tv_usec;
+       for (i = - --minsteps; i< MAXLOOPS; i++) {
+               gettimeofday(&tp, &tzp);
+               diff = tp.tv_usec - last;
+               if (diff < 0) diff += DUSECS;
+               if (diff > MINSTEP) if (minsteps-- <= 0) break;
+               last = tp.tv_usec;
+       }
+
+       printf("resolution = %ld usec after %d loop%s\n",
+              diff, i, (i==1) ? "" : "s");
+
+       diff = (diff *3)/2;
+       if (i >= MAXLOOPS) {
+               printf(
+                       "     (Boy this machine is fast ! %d loops without a step)\n",
+                       MAXLOOPS);
+               diff = 1; /* No STEP, so FAST machine */
+       }
+       if (i == 0) {
+               printf(
+                       "     (The resolution is less than the time to read the clock -- Assume 1us)\n");
+               diff = 1; /* time to read clock >= resolution */
+       }
+       for (i=0, val=HUSECS; val>0; i--, val >>= 1) if (diff >= val) return i;
+       printf("     (Oh dear -- that wasn't expected ! I'll guess !)\n");
+       return DEFAULT_SYS_PRECISION /* Something's BUST, so lie ! */;
+}
+
+/* ===== Rest of this code lifted straight from xntpd/ntp_proto.c ! ===== */
+
+/*
+ * This routine calculates the differences between successive calls to
+ * gettimeofday(). If a difference is less than zero, the us field
+ * has rolled over to the next second, so we add a second in us. If
+ * the difference is greater than zero and less than MINSTEP, the
+ * clock has been advanced by a small amount to avoid standing still.
+ * If the clock has advanced by a greater amount, then a timer interrupt
+ * has occurred and this amount represents the precision of the clock.
+ * In order to guard against spurious values, which could occur if we
+ * happen to hit a fat interrupt, we do this for MINLOOPS times and
+ * keep the minimum value obtained.
+ */  
+int
+default_get_precision(void)
+{
+       struct timeval tp;
+       struct timezone tzp;
+#ifdef HAVE_GETCLOCK
+       struct timespec ts;
+#endif
+       long last;
+       int i;
+       long diff;
+       long val;
+       long usec;
+
+       usec = 0;
+       val = MAXSTEP;
+#ifdef HAVE_GETCLOCK
+       (void) getclock(TIMEOFDAY, &ts);
+       tp.tv_sec = ts.tv_sec;
+       tp.tv_usec = ts.tv_nsec / 1000;
+#else /*  not HAVE_GETCLOCK */
+       GETTIMEOFDAY(&tp, &tzp);
+#endif /* not HAVE_GETCLOCK */
+       last = tp.tv_usec;
+       for (i = 0; i < MINLOOPS && usec < HUSECS;) {
+#ifdef HAVE_GETCLOCK
+               (void) getclock(TIMEOFDAY, &ts);
+               tp.tv_sec = ts.tv_sec;
+               tp.tv_usec = ts.tv_nsec / 1000;
+#else /*  not HAVE_GETCLOCK */
+               GETTIMEOFDAY(&tp, &tzp);
+#endif /* not HAVE_GETCLOCK */
+               diff = tp.tv_usec - last;
+               last = tp.tv_usec;
+               if (diff < 0)
+                   diff += DUSECS;
+               usec += diff;
+               if (diff > MINSTEP) {
+                       i++;
+                       if (diff < val)
+                           val = diff;
+               }
+       }
+       printf("precision  = %ld usec after %d loop%s\n",
+              val, i, (i == 1) ? "" : "s");
+       if (usec >= HUSECS) {
+               printf("     (Boy this machine is fast ! usec was %ld)\n",
+                      usec);
+               val = MINSTEP;  /* val <= MINSTEP; fast machine */
+       }
+       diff = HUSECS;
+       for (i = 0; diff > val; i--)
+           diff >>= 1;
+       return (i);
+}
diff --git a/util/sht.c b/util/sht.c
new file mode 100644 (file)
index 0000000..b993de9
--- /dev/null
@@ -0,0 +1,185 @@
+/* 
+ * sht.c - Testprogram for shared memory refclock
+ * read/write shared memory segment; see usage
+ */
+#ifndef SYS_WINNT
+#include <sys/types.h>
+#include <sys/ipc.h>
+#include <sys/shm.h>
+#include <stdio.h>
+#include <time.h>
+#include <unistd.h>
+#include <stdlib.h>
+#else
+#include <windows.h>
+#include <time.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <iostream.h>
+#define sleep(x) Sleep(x*1000)
+#endif
+#include <assert.h>
+struct shmTime {
+       int    mode; /* 0 - if valid set
+                     *       use values, 
+                     *       clear valid
+                     * 1 - if valid set 
+                     *       if count before and after read of values is equal,
+                     *         use values 
+                     *       clear valid
+                     */
+       int    count;
+       time_t clockTimeStampSec;
+       int    clockTimeStampUSec;
+       time_t receiveTimeStampSec;
+       int    receiveTimeStampUSec;
+       int    leap;
+       int    precision;
+       int    nsamples;
+       int    valid;
+};
+
+struct shmTime *
+getShmTime (
+       int unit
+       )
+{
+#ifndef SYS_WINNT
+       int shmid=shmget (0x4e545030+unit, sizeof (struct shmTime), IPC_CREAT|0777);
+       if (shmid==-1) {
+               perror ("shmget");
+               exit (1);
+       }
+       else {
+               struct shmTime *p=(struct shmTime *)shmat (shmid, 0, 0);
+               if ((int)(long)p==-1) {
+                       perror ("shmat");
+                       p=0;
+               }
+               assert (p!=0);
+               return p;
+       }
+#else
+       char buf[10];
+       LPSECURITY_ATTRIBUTES psec=0;
+       sprintf (buf,"NTP%d",unit);
+       SECURITY_DESCRIPTOR sd;
+       SECURITY_ATTRIBUTES sa;
+       HANDLE shmid;
+
+       assert (InitializeSecurityDescriptor(&sd, SECURITY_DESCRIPTOR_REVISION));
+       assert (SetSecurityDescriptorDacl(&sd,1,0,0));
+       sa.nLength=sizeof (SECURITY_ATTRIBUTES);
+       sa.lpSecurityDescriptor=&sd;
+       sa.bInheritHandle=0;
+       shmid=CreateFileMapping ((HANDLE)0xffffffff, 0, PAGE_READWRITE,
+                                psec, sizeof (struct shmTime),buf);
+       if (!shmid) {
+               shmid=CreateFileMapping ((HANDLE)0xffffffff, 0, PAGE_READWRITE,
+                                        0, sizeof (struct shmTime),buf);
+               cout <<"CreateFileMapping with psec!=0 failed"<<endl;
+       }
+
+       if (!shmid) {
+               char mbuf[1000];
+               FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
+                              0, GetLastError (), 0, mbuf, sizeof (mbuf), 0);
+               int x=GetLastError ();
+               cout <<"CreateFileMapping "<<buf<<":"<<mbuf<<endl;
+               exit (1);
+       }
+       else {
+               struct shmTime *p=(struct shmTime *) MapViewOfFile (shmid, 
+                                                                   FILE_MAP_WRITE, 0, 0, sizeof (struct shmTime));
+               if (p==0) {
+                       char mbuf[1000];
+                       FormatMessage (FORMAT_MESSAGE_FROM_SYSTEM,
+                                      0, GetLastError (), 0, mbuf, sizeof (mbuf), 0);
+                       cout <<"MapViewOfFile "<<buf<<":"<<mbuf<<endl;
+                       exit (1);
+               }
+               return p;
+       }
+       return 0;
+#endif
+}
+
+
+int
+main (
+       int argc,
+       char *argv[]
+       )
+{
+       volatile struct shmTime *p=getShmTime(2);
+       if (argc<=1) {
+               printf ("usage: %s r[c][l]|w|snnn\n",argv[0]);
+               printf ("       r read shared memory\n");
+               printf ("        c clear valid-flag\n");
+               printf ("        l loop (so, rcl will read and clear in a loop\n");
+               printf ("       w write shared memory with current time\n");
+               printf ("       snnnn set nsamples to nnn\n");
+               printf ("       lnnnn set leap to nnn\n");
+               printf ("       pnnnn set precision to -nnn\n");
+               exit (0);
+       }
+       switch (argv[1][0]) {
+           case 's': {
+                   p->nsamples=atoi(&argv[1][1]);
+           }
+           break;
+           case 'l': {
+                   p->leap=atoi(&argv[1][1]);
+           }
+           break;
+           case 'p': {
+                   p->precision=-atoi(&argv[1][1]);
+           }
+           break;
+           case 'r': {
+                   char *ap=&argv[1][1];
+                   int clear=0;
+                   int loop=0;
+                   printf ("reader\n");
+                   while (*ap) {
+                           switch (*ap) {
+                               case 'l' : loop=1; break;
+                               case 'c' : clear=1; break;
+                           }
+                           ap++;
+                   }
+                   do {
+                           printf ("mode=%d, count=%d, clock=%d.%d, rec=%d.%d,\n",
+                                   p->mode,p->count,p->clockTimeStampSec,p->clockTimeStampUSec,
+                                   p->receiveTimeStampSec,p->receiveTimeStampUSec);
+                           printf ("  leap=%d, precision=%d, nsamples=%d, valid=%d\n",
+                                   p->leap, p->precision, p->nsamples, p->valid);
+                           if (!p->valid)
+                               printf ("***\n");
+                           if (clear) {
+                                   p->valid=0;
+                                   printf ("cleared\n");
+                           }
+                           if (loop)
+                               sleep (1);
+                   } while (loop);
+           }
+           break;
+           case 'w': {
+                   printf ("writer\n");
+                   p->mode=0;
+                   if (!p->valid) {
+                           p->clockTimeStampSec=time(0)-20;
+                           p->clockTimeStampUSec=0;
+                           p->receiveTimeStampSec=time(0)-1;
+                           p->receiveTimeStampUSec=0;
+                           printf ("%d %d\n",p->clockTimeStampSec, p->receiveTimeStampSec);
+                           p->valid=1;
+                   }
+                   else {
+                           printf ("p->valid still set\n"); /* not an error! */
+                   }
+           }
+           break;
+       }
+}
diff --git a/util/testrs6000.c b/util/testrs6000.c
new file mode 100644 (file)
index 0000000..e4d939a
--- /dev/null
@@ -0,0 +1,55 @@
+/* Checks for the RS/6000 AIX adjtime() bug, in which if a negative
+ * offset is given, the system gets messed up and never completes the
+ * adjustment.  If the problem is fixed, this program will print the
+ * time, sit there for 10 seconds, and exit.  If the problem isn't fixed,
+ * the program will print an occasional "result=nnnnnn" (the residual
+ * slew from adjtime()).
+ *
+ * Compile this with bsdcc and run it as root!
+ */
+#include <signal.h>
+#include <sys/time.h>
+#include <time.h>
+#include <stdio.h>
+
+int timeout();
+struct timeval adjustment, result;
+
+int
+main (
+       int argc,
+       char *argv[]
+       )
+{
+       struct itimerval value, oldvalue;
+       int i;
+       time_t curtime;
+
+       curtime = time(0);
+       printf("Starting: %s", ctime(&curtime));
+       value.it_interval.tv_sec = value.it_value.tv_sec = 1;
+       value.it_interval.tv_usec = value.it_value.tv_usec = 0;
+       adjustment.tv_sec = 0;
+       adjustment.tv_usec = -2000;
+       signal(SIGALRM, timeout);
+       setitimer(ITIMER_REAL, &value, &oldvalue);
+       for (i=0; i<10; i++) {
+               pause();
+       }
+}
+
+int
+timeout(
+       int sig,
+       int code,
+       struct sigcontext *scp
+       )
+{
+       signal (SIGALRM, timeout);
+       if (adjtime(&adjustment, &result)) 
+           printf("adjtime call failed\n");
+       if (result.tv_sec != 0 || result.tv_usec != 0) {
+               printf("result.u = %d.%06.6d  ", (int) result.tv_sec,
+                      (int) result.tv_usec);
+       }
+}
diff --git a/util/tg.c b/util/tg.c
new file mode 100644 (file)
index 0000000..aa3950d
--- /dev/null
+++ b/util/tg.c
@@ -0,0 +1,652 @@
+/*
+ * tg.c generate WWV or IRIG signals for test
+ */
+/*
+ * This program can generate audio signals that simulate the WWV/H
+ * broadcast timecode. Alternatively, it can generate the IRIG-B
+ * timecode commonly used to synchronize laboratory equipment. It is
+ * intended to test the WWV/H driver (refclock_wwv.c) and the IRIG
+ * driver (refclock_irig.c) in the NTP driver collection.
+ *
+ * Besides testing the drivers themselves, this program can be used to
+ * synchronize remote machines over audio transmission lines or program
+ * feeds. The program reads the time on the local machine and sets the
+ * initial epoch of the signal generator within one millisecond.
+ * Alernatively, the initial epoch can be set to an arbitrary time. This
+ * is useful when searching for bugs and testing for correct response to
+ * a leap second in UTC. Note however, the ultimate accuracy is limited
+ * by the intrinsic frequency error of the codec sample clock, which can
+ # reach well over 100 PPM.
+ *
+ * The default is to route generated signals to the line output
+ * jack; the s option on the command line routes these signals to the
+ * internal speaker as well. The v option controls the speaker volume
+ * over the range 0-255. The signal generator by default uses WWV
+ * format; the h option switches to WWVH format and the i option
+ * switches to IRIG-B format.
+ *
+ * Once started the program runs continuously. The default initial epoch
+ * for the signal generator is read from the computer system clock when
+ * the program starts. The y option specifies an alternate epoch using a
+ * string yydddhhmmss, where yy is the year of century, ddd the day of
+ * year, hh the hour of day and mm the minute of hour. For instance,
+ * 1946Z on 1 January 2006 is 060011946. The l option lights the leap
+ * warning bit in the WWV/H timecode, so is handy to check for correct
+ * behavior at the next leap second epoch. The remaining options are
+ * specified below under the Parse Options heading. Most of these are
+ * for testing.
+ *
+ * During operation the program displays the WWV/H timecode (9 digits)
+ * or IRIG timecode (20 digits) as each new string is constructed. The
+ * display is followed by the BCD binary bits as transmitted. Note that
+ * the transmissionorder is low-order first as the frame is processed
+ * left to right. For WWV/H The leap warning L preceeds the first bit.
+ * For IRIG the on-time marker M preceeds the first (units) bit, so its
+ * code is delayed one bit and the next digit (tens) needs only three
+ * bits.
+ *
+ * The program has been tested with the Sun Blade 1500 running Solaris
+ * 10, but not yet with other machines. It uses no special features and
+ * should be readily portable to other hardware and operating systems.
+ */
+#include <stdio.h>
+#include <stdlib.h>
+#include <time.h>
+#include <sys/audio.h>
+#include <math.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <string.h>
+#include <unistd.h>
+
+#define        SECOND  8000            /* one second of 125-us samples */
+#define BUFLNG 400             /* buffer size */
+#define        DEVICE  "/dev/audio"    /* default audio device */
+#define        WWV     0               /* WWV encoder */
+#define        IRIG    1               /* IRIG-B encoder */
+#define        OFF     0               /* zero amplitude */
+#define        LOW     1               /* low amplitude */
+#define        HIGH    2               /* high amplitude */
+#define        DATA0   200             /* WWV/H 0 pulse */
+#define        DATA1   500             /* WWV/H 1 pulse */
+#define PI     800             /* WWV/H PI pulse */
+#define        M2      2               /* IRIG 0 pulse */
+#define        M5      5               /* IRIG 1 pulse */
+#define        M8      8               /* IRIG PI pulse */
+
+/*
+ * Companded sine table amplitude 3000 units
+ */
+int c3000[] = {1, 48, 63, 70, 78, 82, 85, 89, 92, 94,  /* 0-9 */
+     96,  98,  99, 100, 101, 101, 102, 103, 103, 103,  /* 10-19 */
+    103, 103, 103, 103, 102, 101, 101, 100,  99,  98,  /* 20-29 */
+     96,  94,  92,  89,  85,  82,  78,  70,  63,  48,  /* 30-39 */
+    129, 176, 191, 198, 206, 210, 213, 217, 220, 222,  /* 40-49 */
+    224, 226, 227, 228, 229, 229, 230, 231, 231, 231,  /* 50-59 */
+    231, 231, 231, 231, 230, 229, 229, 228, 227, 226,  /* 60-69 */
+    224, 222, 220, 217, 213, 210, 206, 198, 191, 176};         /* 70-79 */
+/*
+ * Companded sine table amplitude 6000 units
+ */
+int c6000[] = {1, 63, 78, 86, 93, 98, 101, 104, 107, 110, /* 0-9 */
+    112, 113, 115, 116, 117, 117, 118, 118, 119, 119,  /* 10-19 */
+    119, 119, 119, 118, 118, 117, 117, 116, 115, 113,  /* 20-29 */
+    112, 110, 107, 104, 101,  98,  93,  86,  78,  63,  /* 30-39 */
+    129, 191, 206, 214, 221, 226, 229, 232, 235, 238,  /* 40-49 */
+    240, 241, 243, 244, 245, 245, 246, 246, 247, 247,  /* 50-59 */
+    247, 247, 247, 246, 246, 245, 245, 244, 243, 241,  /* 60-69 */
+    240, 238, 235, 232, 229, 226, 221, 214, 206, 191};         /* 70-79 */
+
+/*
+ * Decoder operations at the end of each second are driven by a state
+ * machine. The transition matrix consists of a dispatch table indexed
+ * by second number. Each entry in the table contains a case switch
+ * number and argument.
+ */
+struct progx {
+       int sw;                 /* case switch number */
+       int arg;                /* argument */
+};
+
+/*
+ * Case switch numbers
+ */
+#define DATA   0               /* send data (0, 1, PI) */
+#define COEF   1               /* send BCD bit */
+#define        DEC     2               /* decrement to next digit */
+#define        MIN     3               /* minute pulse */
+#define        LEAP    4               /* leap warning */
+#define        DUT1    5               /* DUT1 bits */
+#define        DST1    6               /* DST1 bit */
+#define        DST2    7               /* DST2 bit */
+
+/*
+ * WWV/H format (100-Hz, 9 digits, 1 m frame)
+ */
+struct progx progx[] = {
+       {MIN,   800},           /* 0 minute sync pulse */
+       {DATA,  DATA0},         /* 1 */
+       {DST2,  0},             /* 2 DST2 */
+       {LEAP,  0},             /* 3 leap warning */
+       {COEF,  1},             /* 4 1 year units */
+       {COEF,  2},             /* 5 2 */
+       {COEF,  4},             /* 6 4 */
+       {COEF,  8},             /* 7 8 */
+       {DEC,   DATA0},         /* 8 */
+       {DATA,  PI},            /* 9 p1 */
+       {COEF,  1},             /* 10 1 minute units */
+       {COEF,  2},             /* 11 2 */
+       {COEF,  4},             /* 12 4 */
+       {COEF,  8},             /* 13 8 */
+       {DEC,   DATA0},         /* 14 */
+       {COEF,  1},             /* 15 10 minute tens */
+       {COEF,  2},             /* 16 20 */
+       {COEF,  4},             /* 17 40 */
+       {COEF,  8},             /* 18 80 (not used) */
+       {DEC,   PI},            /* 19 p2 */
+       {COEF,  1},             /* 20 1 hour units */
+       {COEF,  2},             /* 21 2 */
+       {COEF,  4},             /* 22 4 */
+       {COEF,  8},             /* 23 8 */
+       {DEC,   DATA0},         /* 24 */
+       {COEF,  1},             /* 25 10 hour tens */
+       {COEF,  2},             /* 26 20 */
+       {COEF,  4},             /* 27 40 (not used) */
+       {COEF,  8},             /* 28 80 (not used) */
+       {DEC,   PI},            /* 29 p3 */
+       {COEF,  1},             /* 30 1 day units */
+       {COEF,  2},             /* 31 2 */
+       {COEF,  4},             /* 32 4 */
+       {COEF,  8},             /* 33 8 */
+       {DEC,   DATA0},         /* 34 not used */
+       {COEF,  1},             /* 35 10 day tens */
+       {COEF,  2},             /* 36 20 */
+       {COEF,  4},             /* 37 40 */
+       {COEF,  8},             /* 38 80 */
+       {DEC,   PI},            /* 39 p4 */
+       {COEF,  1},             /* 40 100 day hundreds */
+       {COEF,  2},             /* 41 200 */
+       {COEF,  4},             /* 42 400 (not used) */
+       {COEF,  8},             /* 43 800 (not used) */
+       {DEC,   DATA0},         /* 44 */
+       {DATA,  DATA0},         /* 45 */
+       {DATA,  DATA0},         /* 46 */
+       {DATA,  DATA0},         /* 47 */
+       {DATA,  DATA0},         /* 48 */
+       {DATA,  PI},            /* 49 p5 */
+       {DUT1,  8},             /* 50 DUT1 sign */
+       {COEF,  1},             /* 51 10 year tens */
+       {COEF,  2},             /* 52 20 */
+       {COEF,  4},             /* 53 40 */
+       {COEF,  8},             /* 54 80 */
+       {DST1,  0},             /* 55 DST1 */
+       {DUT1,  1},             /* 56 0.1 DUT1 fraction */
+       {DUT1,  2},             /* 57 0.2 */
+       {DUT1,  4},             /* 58 0.4 */
+       {DATA,  PI},            /* 59 p6 */
+       {DATA,  DATA0},         /* 60 leap */
+};
+
+/*
+ * IRIG format except first frame (1000 Hz, 20 digits, 1 s frame)
+ */
+struct progx progy[] = {
+       {COEF,  1},             /* 0 1 units */
+       {COEF,  2},             /* 1 2 */
+       {COEF,  4},             /* 2 4 */
+       {COEF,  8},             /* 3 8 */
+       {DEC,   M2},            /* 4 im */
+       {COEF,  1},             /* 5 10 tens */
+       {COEF,  2},             /* 6 20 */
+       {COEF,  4},             /* 7 40 */
+       {COEF,  8},             /* 8 80 */
+       {DEC,   M8},            /* 9 pi */
+};
+
+/*
+ * IRIG format first frame (1000 Hz, 20 digits, 1 s frame)
+ */
+struct progx progz[] = {
+       {MIN,   M8},            /* 0 pi (second) */
+       {COEF,  1},             /* 1 1 units */
+       {COEF,  2},             /* 2 2 */
+       {COEF,  4},             /* 3 4 */
+       {COEF,  8},             /* 4 8 */
+       {DEC,   M2},            /* 5 im */
+       {COEF,  1},             /* 6 10 tens */
+       {COEF,  2},             /* 7 20 */
+       {COEF,  4},             /* 8 40 */
+       {DEC,   M8},            /* 9 pi */
+};
+
+/*
+ * Forward declarations
+ */
+void   sec(int);               /* send second */
+void   digit(int);             /* encode digit */
+void   peep(int, int, int);    /* send cycles */
+void   delay(int);             /* delay samples */
+
+/*
+ * Global variables
+ */
+char   buffer[BUFLNG];         /* output buffer */
+int    bufcnt = 0;             /* buffer counter */
+int    second = 0;             /* seconds counter */
+int    fd;                     /* audio codec file descriptor */
+int    tone = 1000;            /* WWV sync frequency */
+int    level = AUDIO_MAX_GAIN / 8; /* output level */
+int    port = AUDIO_LINE_OUT;  /* output port */
+int    encode = WWV;           /* encoder select */
+int    leap = 0;               /* leap indicator */
+int    dst = 0;                /* winter/summer time */
+int    dut1 = 0;               /* DUT1 correction (sign, magnitude) */
+int    utc = 0;                /* option epoch */
+
+/*
+ * Main program
+ */
+int
+main(
+       int     argc,           /* command line options */
+       char    **argv          /* poiniter to list of tokens */
+       )
+{
+       struct timeval tv;      /* system clock at startup */
+       audio_info_t info;      /* Sun audio structure */
+       struct tm *tm = NULL;   /* structure returned by gmtime */
+       char    device[50];     /* audio device */
+       char    code[100];      /* timecode */
+       int     rval, temp, arg, sw, ptr;
+       int     minute, hour, day, year;
+       int     i;
+
+       /*
+        * Parse options
+        */
+       strcpy(device, DEVICE);
+       year = 0;
+       while ((temp = getopt(argc, argv, "a:dhilsu:v:y:")) != -1) {
+               switch (temp) {
+
+               case 'a':       /* specify audio device (/dev/audio) */
+                       strcpy(device, optarg);
+                       break;
+
+               case 'd':       /* set DST for summer (WWV/H only) */
+                       dst++;
+                       break;
+
+               case 'h':       /* select WWVH sync frequency */
+                       tone = 1200;
+                       break;
+
+               case 'i':       /* select irig format */
+                       encode = IRIG;
+                       break;
+
+               case 'l':       /* set leap warning bit (WWV/H only) */
+                       leap++;
+                       break;
+
+               case 's':       /* enable speaker */
+                       port |= AUDIO_SPEAKER;
+                       break;
+
+               case 'u':       /* set DUT1 offset (-7 to +7) */
+                       sscanf(optarg, "%d", &dut1);
+                       if (dut1 < 0)
+                               dut1 = abs(dut1);
+                       else
+                               dut1 |= 0x8;
+                       break;
+
+               case 'v':       /* set output level (0-255) */
+                       sscanf(optarg, "%d", &level);
+                       break;
+
+               case 'y':       /* set initial date and time */
+                       sscanf(optarg, "%2d%3d%2d%2d", &year, &day,
+                           &hour, &minute);
+                       utc++;
+                       break;
+
+               defult:
+                       printf("invalid option %c\n", temp);
+                       break;
+               }
+       }
+
+       /*
+        * Open audio device and set options
+        */
+       fd = open("/dev/audio", O_WRONLY);
+       if (fd <= 0) {
+               printf("audio open %s\n", strerror(errno));
+               exit(1);
+       }
+       rval = ioctl(fd, AUDIO_GETINFO, &info);
+       if (rval < 0) {
+               printf("audio control %s\n", strerror(errno));
+               exit(0);
+       }
+       info.play.port = port;
+       info.play.gain = level;
+       info.play.sample_rate = SECOND;
+       info.play.channels = 1;
+       info.play.precision = 8;
+       info.play.encoding = AUDIO_ENCODING_ULAW;
+       printf("port %d gain %d rate %d chan %d prec %d encode %d\n",
+           info.play.port, info.play.gain, info.play.sample_rate,
+           info.play.channels, info.play.precision,
+           info.play.encoding);
+       ioctl(fd, AUDIO_SETINFO, &info);
+
+       /*
+        * Unless specified otherwise, read the system clock and
+        * initialize the time.
+        */
+       if (!utc) {
+               gettimeofday(&tv, NULL);
+               tm = gmtime(&tv.tv_sec);
+               minute = tm->tm_min;
+               hour = tm->tm_hour;
+               day = tm->tm_yday + 1;
+               year = tm->tm_year % 100;
+               second = tm->tm_sec;
+
+               /*
+                * Delay the first second so the generator is accurately
+                * aligned with the system clock within one sample (125
+                * microseconds ).
+                */
+               delay(SECOND - tv.tv_usec * 8 / 1000);
+       }
+       memset(code, 0, sizeof(code));
+       switch (encode) {
+
+       /*
+        * For WWV/H and default time, carefully set the signal
+        * generator seconds number to agree with the current time.
+        */ 
+       case WWV:
+               printf("year %d day %d time %02d:%02d:%02d tone %d\n",
+                   year, day, hour, minute, second, tone);
+               sprintf(code, "%01d%03d%02d%02d%01d", year / 10, day,
+                   hour, minute, year % 10);
+               printf("%s\n", code);
+               ptr = 8;
+               for (i = 0; i <= second; i++) {
+                       if (progx[i].sw == DEC)
+                               ptr--;
+               }
+               break;
+
+       /*
+        * For IRIG the signal generator runs every second, so requires
+        * no additional alignment.
+        */
+       case IRIG:
+               printf("sbs %x year %d day %d time %02d:%02d:%02d\n",
+                   0, year, day, hour, minute, second);
+               break;
+       }
+
+       /*
+        * Run the signal generator to generate new timecode strings
+        * once per minute for WWV/H and once per second for IRIG.
+        */
+       while(1) {
+
+               /*
+                * Crank the state machine to propagate carries to the
+                * year of century. Note that we delayed up to one
+                * second for alignment after reading the time, so this
+                * is the next second.
+                */
+               second = (second + 1) % 60;
+               if (second == 0) {
+                       minute++;
+                       if (minute >= 60) {
+                               minute = 0;
+                               hour++;
+                       }
+                       if (hour >= 24) {
+                               hour = 0;
+                               day++;
+                       }
+
+                       /*
+                        * At year rollover check for leap second.
+                        */
+                       if (day >= (year & 0x3 ? 366 : 367)) {
+                               if (leap) {
+                                       sec(DATA0);
+                                       printf("\nleap!");
+                                       leap = 0;
+                               }
+                               day = 1;
+                               year++;
+                       }
+                       if (encode == WWV) {
+                               sprintf(code, "%01d%03d%02d%02d%01d",
+                                   year / 10, day, hour, minute, year %
+                                   10);
+                               printf("\n%s\n", code);
+                               ptr = 8;
+                       }
+               }
+               if (encode == IRIG) {
+                       sprintf(code, "%04x%04d%06d%02d%02d%02d", 0,
+                           year, day, hour, minute, second);
+                       printf("%s\n", code);
+                       ptr = 19;
+               }
+
+               /*
+                * Generate data for the second
+                */
+               switch(encode) {
+
+               /*
+                * The IRIG second consists of 20 BCD digits of width-
+                * modulateod pulses at 2, 5 and 8 ms and modulated 50
+                * percent on the 1000-Hz carrier.
+                */
+               case IRIG:
+                       for (i = 0; i < 100; i++) {
+                               if (i < 10) {
+                                       sw = progz[i].sw;
+                                       arg = progz[i].arg;
+                               } else {
+                                       sw = progy[i % 10].sw;
+                                       arg = progy[i % 10].arg;
+                               }
+                               switch(sw) {
+
+                               case COEF:      /* send BCD bit */
+                                       if (code[ptr] & arg) {
+                                               peep(M5, 1000, HIGH);
+                                               peep(M5, 1000, LOW);
+                                               printf("1");
+                                       } else {
+                                               peep(M2, 1000, HIGH);
+                                               peep(M8, 1000, LOW);
+                                               printf("0");
+                                       }
+                                       break;
+
+                               case DEC:       /* send IM/PI bit */
+                                       ptr--;
+                                       printf(" ");
+                                       peep(arg, 1000, HIGH);
+                                       peep(10 - arg, 1000, LOW);
+                                       break;
+
+                               case MIN:       /* send data bit */
+                                       peep(arg, 1000, HIGH);
+                                       peep(10 - arg, 1000, LOW);
+                                       printf("M ");
+                                       break;
+                               }
+                               if (ptr < 0)
+                                       break;
+                       }
+                       printf("\n");
+                       break;
+
+               /*
+                * The WWV/H second consists of 9 BCD digits of width-
+                * modulateod pulses 200, 500 and 800 ms at 100-Hz.
+                */
+               case WWV:
+                       sw = progx[second].sw;
+                       arg = progx[second].arg;
+                       switch(sw) {
+
+                       case DATA:              /* send data bit */
+                               sec(arg);
+                               break;
+
+                       case COEF:              /* send BCD bit */
+                               if (code[ptr] & arg) {
+                                       sec(DATA1);
+                                       printf("1");
+                               } else {
+                                       sec(DATA0);
+                                       printf("0");
+                               }
+                               break;
+
+                       case LEAP:              /* send leap bit */
+                               if (leap) {
+                                       sec(DATA1);
+                                       printf("L ");
+                               } else {
+                                       sec(DATA0);
+                                       printf("  ");
+                               }
+                               break;
+
+                       case DEC:               /* send data bit */
+                               ptr--;
+                               sec(arg);
+                               printf(" ");
+                               break;
+
+                       case MIN:               /* send minute sync */
+                               peep(arg, tone, HIGH);
+                               peep(1000 - arg, tone, OFF);
+                               break;
+
+                       case DUT1:              /* send DUT1 bits */
+                               if (dut1 & arg)
+                                       sec(DATA1);
+                               else
+                                       sec(DATA0);
+                               break;
+                               
+                       case DST1:              /* send DST1 bit */
+                               ptr--;
+                               if (dst)
+                                       sec(DATA1);
+                               else
+                                       sec(DATA0);
+                               printf(" ");
+                               break;
+
+                       case DST2:              /* send DST2 bit */
+                               if (dst)
+                                       sec(DATA1);
+                               else
+                                       sec(DATA0);
+                               break;
+                       }
+               }
+       }
+}
+
+
+/*
+ * Generate WWV/H 0 or 1 data pulse.
+ */
+void sec(
+       int     code            /* DATA0, DATA1, PI */
+       )
+{
+       /*
+        * The WWV data pulse begins with 5 ms of 1000 Hz follwed by a
+        * guard time of 25 ms. The data pulse is 170, 570 or 770 ms at
+        * 100 Hz corresponding to 0, 1 or position indicator (PI),
+        * respectively. Note the 100-Hz data pulses are transmitted 6
+        * dB below the 1000-Hz sync pulses. Originally the data pulses
+        * were transmited 10 dB below the sync pulses, but the station
+        * engineers increased that to 6 dB because the Heath GC-1000
+        * WWV/H radio clock worked much better.
+        */
+       peep(5, tone, HIGH);            /* send seconds tick */
+       peep(25, tone, OFF);
+       peep(code - 30, 100, LOW);      /* send data */
+       peep(1000 - code, 100, OFF);
+}
+
+
+/*
+ * Generate cycles of 100 Hz or any multiple of 100 Hz.
+ */
+void peep(
+       int     pulse,          /* pulse length (ms) */
+       int     freq,           /* frequency (Hz) */
+       int     amp             /* amplitude */
+       )
+{
+       int     increm;         /* phase increment */
+       int     i, j;
+
+       if (amp == OFF || freq == 0)
+               increm = 10;
+       else
+               increm = freq / 100;
+       j = 0;
+       for (i = 0 ; i < pulse * 8; i++) {
+               switch (amp) {
+
+               case HIGH:
+                       buffer[bufcnt++] = ~c6000[j];
+                       break;
+
+               case LOW:
+                       buffer[bufcnt++] = ~c3000[j];
+                       break;
+
+               default:
+                       buffer[bufcnt++] = ~0;
+               }
+               if (bufcnt >= BUFLNG) {
+                       write(fd, buffer, BUFLNG);
+                       bufcnt = 0;
+               }
+               j = (j + increm) % 80;
+       }
+}
+
+
+/*
+ * Delay for initial phasing
+ */
+void delay (
+       int     delay           /* delay in samples */
+       )
+{
+       int     samples;        /* samples remaining */
+
+       samples = delay;
+       memset(buffer, 0, BUFLNG);
+       while (samples >= BUFLNG) {
+               write(fd, buffer, BUFLNG);
+               samples -= BUFLNG;
+       }
+               write(fd, buffer, samples);
+}
diff --git a/util/tickadj.c b/util/tickadj.c
new file mode 100644 (file)
index 0000000..4a7f2c4
--- /dev/null
@@ -0,0 +1,902 @@
+/*
+ * tickadj - read, and possibly modify, the kernel `tick' and
+ *          `tickadj' variables, as well as `dosynctodr'.  Note that
+ *          this operates on the running kernel only.  I'd like to be
+ *          able to read and write the binary as well, but haven't
+ *          mastered this yet.
+ *
+ * HMS: The #includes here are different from those in xntpd/ntp_unixclock.c
+ *      These seem "worse".
+ */
+
+#ifdef HAVE_CONFIG_H
+# include <config.h>
+#endif
+
+#include "ntp_types.h"
+#include "l_stdlib.h"
+
+#include <stdio.h>
+#ifdef HAVE_UNISTD_H
+# include <unistd.h>
+#endif /* HAVE_UNISTD_H */
+
+#ifdef HAVE___ADJTIMEX         /* Linux */
+
+#include <sys/timex.h>
+struct timex txc;
+
+#if 0
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       int     c, i;
+       int     quiet = 0;
+       int     errflg = 0;
+       char    *progname;
+       extern int ntp_optind;
+       extern char *ntp_optarg;
+
+       progname = argv[0];
+       if (argc==2 && argv[1][0] != '-') { /* old Linux format, for compatability */
+           if ((i = atoi(argv[1])) > 0) {
+                   txc.time_tick = i;
+                   txc.modes = ADJ_TIMETICK;
+           } else {
+                   fprintf(stderr, "Silly value for tick: %s\n", argv[1]);
+                   errflg++;
+           }
+       } else {
+           while ((c = ntp_getopt(argc, argv, "a:qt:")) != EOF) {
+               switch (c) {
+                   case 'a':
+                       if ((i=atoi(ntp_optarg)) > 0) {
+                               txc.tickadj = i;
+                               txc.modes |= ADJ_TICKADJ;
+                       } else {
+                               (void) fprintf(stderr,
+                                      "%s: unlikely value for tickadj: %s\n",
+                                      progname, ntp_optarg);
+                               errflg++;
+                       }
+                       break;
+
+                   case 'q':
+                       quiet = 1;
+                       break;
+
+                   case 't':
+                       if ((i=atoi(ntp_optarg)) > 0) {
+                               txc.time_tick = i;
+                               txc.modes |= ADJ_TIMETICK;
+                       } else {
+                               (void) fprintf(stderr,
+                                      "%s: unlikely value for tick: %s\n",
+                                      progname, ntp_optarg);
+                               errflg++;
+                       }
+                       break;
+
+                   default:
+                       fprintf(stderr,
+                           "Usage: %s [tick_value]\n-or-   %s [ -q ] [ -t tick ] [ -a tickadj ]\n",
+                           progname, progname);
+                       errflg++;
+                       break;
+               }
+           }
+       }
+
+       if (!errflg) {
+               if (__adjtimex(&txc) < 0)
+                       perror("adjtimex");
+               else if (!quiet)
+                       printf("tick     = %ld\ntick_adj = %d\n",
+                           txc.time_tick, txc.tickadj);
+       }
+
+       exit(errflg ? 1 : 0);
+}
+#else
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       if (argc > 2)
+       {
+               fprintf(stderr, "Usage: %s [tick_value]\n", argv[0]);
+               exit(-1);
+       }
+       else if (argc == 2)
+       {
+#ifdef ADJ_TIMETICK
+               if ( (txc.time_tick = atoi(argv[1])) < 1 )
+#else
+               if ( (txc.tick = atoi(argv[1])) < 1 )
+#endif
+               {
+                       fprintf(stderr, "Silly value for tick: %s\n", argv[1]);
+                       exit(-1);
+               }
+#ifdef ADJ_TIMETICK
+               txc.modes = ADJ_TIMETICK;
+#else
+#ifdef MOD_OFFSET
+               txc.modes = ADJ_TICK;
+#else
+               txc.mode = ADJ_TICK;
+#endif
+#endif
+       }
+       else
+       {
+#ifdef ADJ_TIMETICK
+               txc.modes = 0;
+#else
+#ifdef MOD_OFFSET
+               txc.modes = 0;
+#else
+               txc.mode = 0;
+#endif
+#endif
+       }
+    
+       if (__adjtimex(&txc) < 0)
+       {
+               perror("adjtimex");
+       }
+       else
+       {
+#ifdef ADJ_TIMETICK
+               printf("tick     = %ld\ntick_adj = %ld\n", txc.time_tick, txc.tickadj);
+#else
+               printf("tick = %ld\n", txc.tick);
+#endif
+       }
+
+       exit(0);
+}
+#endif
+
+#else /* not Linux... kmem tweaking: */
+
+#ifdef HAVE_SYS_FILE_H
+# include <sys/file.h>
+#endif
+#include <sys/stat.h>
+
+#ifdef HAVE_SYS_PARAM_H
+# include <sys/param.h>
+#endif
+
+#ifdef NLIST_STRUCT
+# include <nlist.h>
+#else /* not NLIST_STRUCT */ /* was defined(SYS_AUX3) || defined(SYS_AUX2) */
+# include <sys/resource.h>
+# include <sys/file.h>
+# include <a.out.h>
+# include <sys/var.h>
+#endif
+
+#include "ntp_io.h"
+#include "ntp_stdlib.h"
+
+#ifdef hz /* Was: RS6000 */
+# undef hz
+#endif /* hz */
+
+#ifdef HAVE_KVM_OPEN
+# include <kvm.h>
+#endif
+
+#ifdef SYS_VXWORKS
+/* vxWorks needs mode flag -casey*/
+#define open(name, flags)   open(name, flags, 0777)
+#endif
+
+#ifndef L_SET  /* Was: defined(SYS_PTX) || defined(SYS_IX86OSF1) */
+# define L_SET SEEK_SET
+#endif
+
+#ifndef HZ
+# define HZ    DEFAULT_HZ
+#endif
+
+#define        KMEM    "/dev/kmem"
+#define        STREQ(a, b)     (*(a) == *(b) && strcmp((a), (b)) == 0)
+
+char *progname;
+volatile int debug;
+
+int dokmem = 1;
+int writetickadj = 0;
+int writeopttickadj = 0;
+int unsetdosync = 0;
+int writetick = 0;
+int quiet = 0;
+int setnoprintf = 0;
+
+const char *kmem = KMEM;
+const char *file = NULL;
+int   fd  = -1;
+
+static void    getoffsets      P((off_t *, off_t *, off_t *, off_t *));
+static int     openfile        P((const char *, int));
+static void    writevar        P((int, off_t, int));
+static void    readvar         P((int, off_t, int *));
+
+/*
+ * main - parse arguments and handle options
+ */
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       int c;
+       int errflg = 0;
+       off_t tickadj_offset;
+       off_t tick_offset;
+       off_t dosync_offset;
+       off_t noprintf_offset;
+       int tickadj, ktickadj;  /* HMS: Why isn't this u_long? */
+       int tick, ktick;        /* HMS: Why isn't this u_long? */
+       int dosynctodr;
+       int noprintf;
+       int hz;
+       int hz_int, hz_hundredths;
+       int recommend_tickadj;
+       long tmp;
+
+       progname = argv[0];
+       while ((c = ntp_getopt(argc, argv, "a:Adkpqst:")) != EOF)
+       {
+               switch (c)
+               {
+                   case 'a':
+                       writetickadj = atoi(ntp_optarg);
+                       if (writetickadj <= 0)
+                       {
+                               (void) fprintf(stderr,
+                                              "%s: unlikely value for tickadj: %s\n",
+                                              progname, ntp_optarg);
+                               errflg++;
+                       }
+
+#if defined SCO5_CLOCK
+                       if (writetickadj % HZ) 
+                       {
+                               writetickadj = (writetickadj / HZ) * HZ;
+                               (void) fprintf(stderr,
+                                              "tickadj truncated to: %d\n", writetickadj);
+                       }
+#endif /* SCO5_CLOCK */
+
+                       break;
+                   case 'A':
+                       writeopttickadj = 1;
+                       break;
+                   case 'd':
+                       ++debug;
+                       break;
+                   case 'k':
+                       dokmem = 1;
+                       break;
+                   case 'p':
+                       setnoprintf = 1;
+                       break;
+                   case 'q':
+                       quiet = 1;
+                       break;
+                   case 's':
+                       unsetdosync = 1;
+                       break;
+                   case 't':
+                       writetick = atoi(ntp_optarg);
+                       if (writetick <= 0)
+                       {
+                               (void) fprintf(stderr,
+                                              "%s: unlikely value for tick: %s\n",
+                                              progname, ntp_optarg);
+                               errflg++;
+                       }
+                       break;
+                   default:
+                       errflg++;
+                       break;
+               }
+       }
+       if (errflg || ntp_optind != argc)
+       {
+               (void) fprintf(stderr,
+                              "usage: %s [-Adkpqs] [-a newadj] [-t newtick]\n", progname);
+               exit(2);
+       }
+
+       getoffsets(&tick_offset, &tickadj_offset, &dosync_offset, &noprintf_offset);
+
+       if (debug)
+       {
+               (void) printf("tick offset = %lu\n", (unsigned long)tick_offset);
+               (void) printf("tickadj offset = %lu\n", (unsigned long)tickadj_offset);
+               (void) printf("dosynctodr offset = %lu\n", (unsigned long)dosync_offset);
+               (void) printf("noprintf offset = %lu\n", (unsigned long)noprintf_offset);
+       }
+
+       if (writetick && (tick_offset == 0))
+       {
+               (void) fprintf(stderr, 
+                              "No tick kernel variable\n");
+               errflg++;
+       }
+       
+       if (writeopttickadj && (tickadj_offset == 0))
+       {
+               (void) fprintf(stderr, 
+                              "No tickadj kernel variable\n");
+               errflg++;
+       }
+
+       if (unsetdosync && (dosync_offset == 0))
+       {
+               (void) fprintf(stderr, 
+                              "No dosynctodr kernel variable\n");
+               errflg++;
+       }
+       
+       if (setnoprintf && (noprintf_offset == 0))
+       {
+               (void) fprintf(stderr, 
+                              "No noprintf kernel variable\n");
+               errflg++;
+       }
+
+       if (tick_offset != 0)
+       {
+               readvar(fd, tick_offset, &tick);
+#if defined(TICK_NANO) && defined(K_TICK_NAME)
+               if (!quiet)
+                   (void) printf("KERNEL %s = %d nsec\n", K_TICK_NAME, tick);
+#endif /* TICK_NANO && K_TICK_NAME */
+
+#ifdef TICK_NANO
+               tick /= 1000;
+#endif
+       }
+       else
+       {
+               tick = 0;
+       }
+
+       if (tickadj_offset != 0)
+       {
+               readvar(fd, tickadj_offset, &tickadj);
+
+#ifdef SCO5_CLOCK
+               /* scale from nsec/sec to usec/tick */
+               tickadj /= (1000L * HZ);
+#endif /*SCO5_CLOCK */
+
+#if defined(TICKADJ_NANO) && defined(K_TICKADJ_NAME)
+               if (!quiet)
+                   (void) printf("KERNEL %s = %d nsec\n", K_TICKADJ_NAME, tickadj);
+#endif /* TICKADJ_NANO && K_TICKADJ_NAME */
+
+#ifdef TICKADJ_NANO
+               tickadj += 999;
+               tickadj /= 1000;
+#endif
+       }
+       else
+       {
+               tickadj = 0;
+       }
+
+       if (dosync_offset != 0)
+       {
+               readvar(fd, dosync_offset, &dosynctodr);
+       }
+
+       if (noprintf_offset != 0)
+       {
+               readvar(fd, noprintf_offset, &noprintf);
+       }
+
+       (void) close(fd);
+
+       if (unsetdosync && dosync_offset == 0)
+       {
+               (void) fprintf(stderr,
+                              "%s: can't find %s in namelist\n",
+                              progname,
+#ifdef K_DOSYNCTODR_NAME
+                              K_DOSYNCTODR_NAME
+#else /* not K_DOSYNCTODR_NAME */
+                              "dosynctodr"
+#endif /* not K_DOSYNCTODR_NAME */
+                              );
+               exit(1);
+       }
+
+       hz = HZ;
+#if defined(HAVE_SYSCONF) && defined(_SC_CLK_TCK)
+       hz = (int) sysconf (_SC_CLK_TCK);
+#endif /* not HAVE_SYSCONF && _SC_CLK_TCK */
+#ifdef OVERRIDE_HZ
+       hz = DEFAULT_HZ;
+#endif
+       ktick = tick;
+#ifdef PRESET_TICK
+       tick = PRESET_TICK;
+#endif /* PRESET_TICK */
+#ifdef TICKADJ_NANO
+       tickadj /= 1000;
+       if (tickadj == 0)
+           tickadj = 1;
+#endif
+       ktickadj = tickadj;
+#ifdef PRESET_TICKADJ
+       tickadj = (PRESET_TICKADJ) ? PRESET_TICKADJ : 1;
+#endif /* PRESET_TICKADJ */
+
+       if (!quiet)
+       {
+               if (tick_offset != 0)
+               {
+                       (void) printf("KERNEL tick = %d usec (from %s kernel variable)\n",
+                                     ktick,
+#ifdef K_TICK_NAME
+                                     K_TICK_NAME
+#else
+                                     "<this can't happen>"
+#endif                 
+                                     );
+               }
+#ifdef PRESET_TICK
+               (void) printf("PRESET tick = %d usec\n", tick);
+#endif /* PRESET_TICK */
+               if (tickadj_offset != 0)
+               {
+                       (void) printf("KERNEL tickadj = %d usec (from %s kernel variable)\n",
+                                     ktickadj,
+#ifdef K_TICKADJ_NAME
+                                     K_TICKADJ_NAME
+#else
+                                     "<this can't happen>"
+#endif
+                                     );
+               }
+#ifdef PRESET_TICKADJ
+               (void) printf("PRESET tickadj = %d usec\n", tickadj);
+#endif /* PRESET_TICKADJ */
+               if (dosync_offset != 0)
+               {
+                       (void) printf("dosynctodr is %s\n", dosynctodr ? "on" : "off");
+               }
+               if (noprintf_offset != 0)
+               {
+                       (void) printf("kernel level printf's: %s\n",
+                                     noprintf ? "off" : "on");
+               }
+       }
+
+       if (tick <= 0)
+       {
+               (void) fprintf(stderr, "%s: the value of tick is silly!\n",
+                              progname);
+               exit(1);
+       }
+
+       hz_int = (int)(1000000L / (long)tick);
+       hz_hundredths = (int)((100000000L / (long)tick) - ((long)hz_int * 100L));
+       if (!quiet)
+       {
+               (void) printf("KERNEL hz = %d\n", hz);
+               (void) printf("calculated hz = %d.%02d Hz\n", hz_int,
+                             hz_hundredths);
+       }
+
+#if defined SCO5_CLOCK
+       recommend_tickadj = 100;
+#else /* SCO5_CLOCK */
+       tmp = (long) tick * 500L;
+       recommend_tickadj = (int)(tmp / 1000000L);
+       if (tmp % 1000000L > 0)
+       {
+               recommend_tickadj++;
+       }
+
+#ifdef MIN_REC_TICKADJ
+       if (recommend_tickadj < MIN_REC_TICKADJ)
+       {
+               recommend_tickadj = MIN_REC_TICKADJ;
+       }
+#endif /* MIN_REC_TICKADJ */
+#endif /* SCO5_CLOCK */
+  
+
+       if ((!quiet) && (tickadj_offset != 0))
+       {
+               (void) printf("recommended value of tickadj = %d us\n",
+                             recommend_tickadj);
+       }
+
+       if (   writetickadj == 0
+              && !writeopttickadj
+              && !unsetdosync
+              && writetick == 0
+              && !setnoprintf)
+       {
+               exit(errflg ? 1 : 0);
+       }
+
+       if (writetickadj == 0 && writeopttickadj)
+       {
+               writetickadj = recommend_tickadj;
+       }
+
+       fd = openfile(file, O_WRONLY);
+
+       if (setnoprintf && (noprintf_offset != 0))
+       {
+               if (!quiet)
+               {
+                       (void) fprintf(stderr, "setting noprintf: ");
+                       (void) fflush(stderr);
+               }
+               writevar(fd, noprintf_offset, 1);
+               if (!quiet)
+               {
+                       (void) fprintf(stderr, "done!\n");
+               }
+       }
+
+       if ((writetick > 0) && (tick_offset != 0))
+       {
+               if (!quiet)
+               {
+                       (void) fprintf(stderr, "writing tick, value %d: ",
+                                      writetick);
+                       (void) fflush(stderr);
+               }
+               writevar(fd, tick_offset, writetick);
+               if (!quiet)
+               {
+                       (void) fprintf(stderr, "done!\n");
+               }
+       }
+
+       if ((writetickadj > 0) && (tickadj_offset != 0))
+       {
+               if (!quiet)
+               {
+                       (void) fprintf(stderr, "writing tickadj, value %d: ",
+                                      writetickadj);
+                       (void) fflush(stderr);
+               }
+
+#ifdef SCO5_CLOCK
+               /* scale from usec/tick to nsec/sec */
+               writetickadj *= (1000L * HZ);
+#endif /* SCO5_CLOCK */
+
+               writevar(fd, tickadj_offset, writetickadj);
+               if (!quiet)
+               {
+                       (void) fprintf(stderr, "done!\n");
+               }
+       }
+
+       if (unsetdosync && (dosync_offset != 0))
+       {
+               if (!quiet)
+               {
+                       (void) fprintf(stderr, "zeroing dosynctodr: ");
+                       (void) fflush(stderr);
+               }
+               writevar(fd, dosync_offset, 0);
+               if (!quiet)
+               {
+                       (void) fprintf(stderr, "done!\n");
+               }
+       }
+       (void) close(fd);
+       return(errflg ? 1 : 0);
+}
+
+/*
+ * getoffsets - read the magic offsets from the specified file
+ */
+static void
+getoffsets(
+       off_t *tick_off,
+       off_t *tickadj_off,
+       off_t *dosync_off,
+       off_t *noprintf_off
+       )
+{
+
+#ifndef NOKMEM
+# ifndef HAVE_KVM_OPEN
+       const char **kname;
+# endif
+#endif
+
+#ifndef NOKMEM
+# ifdef NLIST_NAME_UNION
+#  define NL_B {{
+#  define NL_E }}
+# else
+#  define NL_B {
+#  define NL_E }
+# endif
+#endif
+
+#define K_FILLER_NAME "DavidLetterman"
+
+#ifdef NLIST_EXTRA_INDIRECTION
+       int i;
+#endif
+
+#ifndef NOKMEM
+       static struct nlist nl[] =
+       {
+               NL_B
+#ifdef K_TICKADJ_NAME
+#define N_TICKADJ      0
+               K_TICKADJ_NAME
+#else
+               K_FILLER_NAME
+#endif
+               NL_E,
+               NL_B
+#ifdef K_TICK_NAME
+#define N_TICK         1
+               K_TICK_NAME
+#else
+               K_FILLER_NAME
+#endif
+               NL_E,
+               NL_B
+#ifdef K_DOSYNCTODR_NAME
+#define N_DOSYNC       2
+               K_DOSYNCTODR_NAME
+#else
+               K_FILLER_NAME
+#endif
+               NL_E,
+               NL_B
+#ifdef K_NOPRINTF_NAME
+#define N_NOPRINTF     3
+               K_NOPRINTF_NAME
+#else
+               K_FILLER_NAME
+#endif
+               NL_E,
+               NL_B "" NL_E,
+       };
+
+#ifndef HAVE_KVM_OPEN
+       static const char *kernels[] =
+       {
+#ifdef HAVE_GETBOOTFILE
+               NULL,                   /* *** SEE BELOW! *** */
+#endif
+               "/kernel/unix",
+               "/kernel",
+               "/vmunix",
+               "/unix",
+               "/mach",
+               "/hp-ux",
+               "/386bsd",
+               "/netbsd",
+               "/stand/vmunix",
+               "/bsd",
+               NULL
+       };
+#endif /* not HAVE_KVM_OPEN */
+
+#ifdef HAVE_KVM_OPEN
+       /*
+        * Solaris > 2.5 doesn't have a kernel file.  Use the kvm_* interface
+        * to read the kernel name list. -- stolcke 3/4/96
+        */
+       kvm_t *kvm_handle = kvm_open(NULL, NULL, NULL, O_RDONLY, progname);
+
+       if (kvm_handle == NULL)
+       {
+               (void) fprintf(stderr,
+                              "%s: kvm_open failed\n",
+                              progname);
+               exit(1);
+       }
+       if (kvm_nlist(kvm_handle, nl) == -1)
+       {
+               (void) fprintf(stderr,
+                              "%s: kvm_nlist failed\n",
+                              progname);
+               exit(1);
+       }
+       kvm_close(kvm_handle);
+#else /* not HAVE_KVM_OPEN */
+#ifdef HAVE_GETBOOTFILE                /* *** SEE HERE! *** */
+       if (kernels[0] == NULL)
+       {
+               char * cp = (char *)getbootfile();
+
+               if (cp)
+               {
+                       kernels[0] = cp;
+               }
+               else
+               {
+                       kernels[0] = "/Placeholder";
+               }
+       }
+#endif /* HAVE_GETBOOTFILE */
+       for (kname = kernels; *kname != NULL; kname++)
+       {
+               struct stat stbuf;
+
+               if (stat(*kname, &stbuf) == -1)
+               {
+                       continue;
+               }
+               if (nlist(*kname, nl) >= 0)
+               {
+                       break;
+               }
+               else
+               {
+                       (void) fprintf(stderr,
+                                      "%s: nlist didn't find needed symbols from <%s>: %s\n",
+                                      progname, *kname, strerror(errno));
+               }
+       }
+       if (*kname == NULL)
+       {
+               (void) fprintf(stderr,
+                              "%s: Couldn't find the kernel\n",
+                              progname);
+               exit(1);
+       }
+#endif /* HAVE_KVM_OPEN */
+
+       if (dokmem)
+       {
+               file = kmem;
+
+               fd = openfile(file, O_RDONLY);
+#ifdef NLIST_EXTRA_INDIRECTION
+               /*
+                * Go one more round of indirection.
+                */
+               for (i = 0; i < (sizeof(nl) / sizeof(struct nlist)); i++)
+               {
+                       if ((nl[i].n_value) && (nl[i].n_sclass == 0x6b))
+                       {
+                               readvar(fd, nl[i].n_value, &nl[i].n_value);
+                       }
+               }
+#endif /* NLIST_EXTRA_INDIRECTION */
+       }
+#endif /* not NOKMEM */
+
+       *tickadj_off  = 0;
+       *tick_off     = 0;
+       *dosync_off   = 0;
+       *noprintf_off = 0;
+
+#if defined(N_TICKADJ)
+       *tickadj_off = nl[N_TICKADJ].n_value;
+#endif
+
+#if defined(N_TICK)
+       *tick_off = nl[N_TICK].n_value;
+#endif
+
+#if defined(N_DOSYNC)
+       *dosync_off = nl[N_DOSYNC].n_value;
+#endif
+
+#if defined(N_NOPRINTF)
+       *noprintf_off = nl[N_NOPRINTF].n_value;
+#endif
+       return;
+}
+
+#undef N_TICKADJ
+#undef N_TICK
+#undef N_DOSYNC
+#undef N_NOPRINTF
+
+
+/*
+ * openfile - open the file, check for errors
+ */
+static int
+openfile(
+       const char *name,
+       int mode
+       )
+{
+       int ifd;
+
+       ifd = open(name, mode);
+       if (ifd < 0)
+       {
+               (void) fprintf(stderr, "%s: open %s: ", progname, name);
+               perror("");
+               exit(1);
+       }
+       return ifd;
+}
+
+
+/*
+ * writevar - write a variable into the file
+ */
+static void
+writevar(
+       int ofd,
+       off_t off,
+       int var
+       )
+{
+       
+       if (lseek(ofd, off, L_SET) == -1)
+       {
+               (void) fprintf(stderr, "%s: lseek fails: ", progname);
+               perror("");
+               exit(1);
+       }
+       if (write(ofd, (char *)&var, sizeof(int)) != sizeof(int))
+       {
+               (void) fprintf(stderr, "%s: write fails: ", progname);
+               perror("");
+               exit(1);
+       }
+       return;
+}
+
+
+/*
+ * readvar - read a variable from the file
+ */
+static void
+readvar(
+       int ifd,
+       off_t off,
+       int *var
+       )
+{
+       int i;
+       
+       if (lseek(ifd, off, L_SET) == -1)
+       {
+               (void) fprintf(stderr, "%s: lseek fails: ", progname);
+               perror("");
+               exit(1);
+       }
+       i = read(ifd, (char *)var, sizeof(int));
+       if (i < 0)
+       {
+               (void) fprintf(stderr, "%s: read fails: ", progname);
+               perror("");
+               exit(1);
+       }
+       if (i != sizeof(int))
+       {
+               (void) fprintf(stderr, "%s: read expected %d, got %d\n",
+                              progname, (int)sizeof(int), i);
+               exit(1);
+       }
+       return;
+}
+#endif /* not Linux */
diff --git a/util/timetrim.c b/util/timetrim.c
new file mode 100644 (file)
index 0000000..911ea28
--- /dev/null
@@ -0,0 +1,116 @@
+#if defined(sgi) || defined(_UNICOSMP)
+/*
+ * timetrim.c
+ * 
+ * "timetrim" allows setting and adjustment of the system clock frequency
+ * trim parameter on Silicon Graphics machines.  The trim value native
+ * units are nanoseconds per second (10**-9), so a trim value of 1 makes
+ * the system clock step ahead 1 nanosecond more per second than a value
+ * of zero.  Xntpd currently uses units of 2**-20 secs for its frequency
+ * offset (drift) values; to convert to a timetrim value, multiply by
+ * 1E9 / 2**20 (about 954).
+ * 
+ * "timetrim" with no arguments just prints out the current kernel value.
+ * With a numeric argument, the kernel value is set to the supplied value.
+ * The "-i" flag causes the supplied value to be added to the kernel value.
+ * The "-n" option causes all input and output to be in xntpd units rather
+ * than timetrim native units.
+ *
+ * Note that there is a limit of +-3000000 (0.3%) on the timetrim value
+ * which is (silently?) enforced by the kernel.
+ * 
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include <stdio.h>
+#include <ctype.h>
+#include <stdlib.h>
+#ifdef HAVE_SYS_SYSSGI_H
+# include <sys/syssgi.h>
+#endif
+#ifdef HAVE_SYS_SYSTUNE_H
+# include <sys/systune.h>
+#endif
+
+#define abs(X) (((X) < 0) ? -(X) : (X))
+#define USAGE "usage: timetrim [-n] [[-i] value]\n"
+#define SGITONTP(X) ((double)(X) * 1048576.0/1.0e9)
+#define NTPTOSGI(X) ((long)((X) * 1.0e9/1048576.0))
+
+int
+main(
+       int argc,
+       char *argv[]
+       )
+{
+       char *rem;
+       int incremental = 0, ntpunits = 0;
+       long timetrim;
+       double value;
+       
+       while (--argc && **++argv == '-' && isalpha((int)argv[0][1])) {
+               switch (argv[0][1]) {
+                   case 'i':
+                       incremental++;
+                       break;
+                   case 'n':
+                       ntpunits++;
+                       break;
+                   default:
+                       fprintf(stderr, USAGE);
+                       exit(1);
+               }
+       }
+
+#ifdef HAVE_SYS_SYSSGI_H
+       if (syssgi(SGI_GETTIMETRIM, &timetrim) < 0) {
+               perror("syssgi");
+               exit(2);
+       }
+#endif
+#ifdef HAVE_SYS_SYSTUNE_H
+       if (systune(SYSTUNE_GET, "timetrim", &timetrim) < 0) {
+               perror("systune");
+               exit(2);
+       }
+#endif
+
+       if (argc == 0) {
+               if (ntpunits)
+                   fprintf(stdout, "%0.5f\n", SGITONTP(timetrim));
+               else
+                   fprintf(stdout, "%ld\n", timetrim);
+       } else if (argc != 1) {
+               fprintf(stderr, USAGE);
+               exit(1);
+       } else {
+               value = strtod(argv[0], &rem);
+               if (*rem != '\0') {
+                       fprintf(stderr, USAGE);
+                       exit(1);
+               }
+               if (ntpunits)
+                   value = NTPTOSGI(value);
+               if (incremental)
+                   timetrim += value;
+               else
+                   timetrim = value;
+#ifdef HAVE_SYS_SYSSGI_H
+               if (syssgi(SGI_SETTIMETRIM, timetrim) < 0) {
+                       perror("syssgi");
+                       exit(2);
+               }
+#endif
+#ifdef HAVE_SYS_SYSTUNE_H
+               if (systune(SYSTUNE_SET, "timer", "timetrim", &timetrim) < 0) {
+                       perror("systune");
+                       exit(2);
+               }
+#endif
+       }
+       return 0;
+}
+#endif
diff --git a/version b/version
new file mode 100644 (file)
index 0000000..1308e73
--- /dev/null
+++ b/version
@@ -0,0 +1 @@
+1.1612
diff --git a/version.m4 b/version.m4
new file mode 100644 (file)
index 0000000..7d687b9
--- /dev/null
@@ -0,0 +1 @@
+m4_define([VERSION_NUMBER],[4.2.4p8])